@cuongtran001/kanna 1.46.0 → 1.47.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 (113) hide show
  1. package/dist/client/assets/ChatPage-CaWwjZR4.js +80 -0
  2. package/dist/client/assets/CronJobRow-BNg3n_6B.js +1 -0
  3. package/dist/client/assets/{CronJobsPage-Ds0fuLQ2.js → CronJobsPage-DGPCpgi2.js} +1 -1
  4. package/dist/client/assets/{KannaSocketProvider-xaosB1_L.js → KannaSocketProvider-ls8_E7wV.js} +1 -1
  5. package/dist/client/assets/LocalProjectsPage-DjkIU-CI.js +1 -0
  6. package/dist/client/assets/SettingsPage-BQdG2Gpn.js +9 -0
  7. package/dist/client/assets/{WorkflowsPage-TUgWb8uA.js → WorkflowsPage-DuyAZ4os.js} +1 -1
  8. package/dist/client/assets/{WorkflowsSection-BI6yF_eK.js → WorkflowsSection-B21zGQbZ.js} +7 -7
  9. package/dist/client/assets/auth-CkUMBgRL.js +1 -0
  10. package/dist/client/assets/{branding-W7LM30YD.js → branding-CxXZpUoc.js} +1 -1
  11. package/dist/client/assets/{chatSounds-WUMh8tDW.js → chatSounds-vvLzl8A_.js} +1 -1
  12. package/dist/client/assets/editor-icons-BYPupL7B.js +1 -0
  13. package/dist/client/assets/index-B7QF_u-n.js +68 -0
  14. package/dist/client/assets/index-BTYDMm-o.css +1 -0
  15. package/dist/client/assets/{lexicalToReact-CrNpi1lG.js → lexicalToReact-CmBG3fG-.js} +2 -2
  16. package/dist/client/assets/{pushClient-CJtm8awC.js → pushClient-Bl0yS8dB.js} +1 -1
  17. package/dist/client/assets/timer.adapter-D4UNPu_T.js +1 -0
  18. package/dist/client/assets/useKannaState-VCszkCW6.js +5 -0
  19. package/dist/client/assets/workflowsStore-DIyxNBAq.js +1 -0
  20. package/dist/client/index.html +11 -11
  21. package/package.json +1 -1
  22. package/src/server/__fixtures__/plugins/hello/index.ts +5 -0
  23. package/src/server/agent.stack-spawn.test.ts +71 -2
  24. package/src/server/agent.ts +1 -0
  25. package/src/server/board-registry.test.ts +94 -0
  26. package/src/server/board-registry.ts +51 -2
  27. package/src/server/board-start-work.test.ts +90 -0
  28. package/src/server/board-start-work.ts +24 -8
  29. package/src/server/claude-loop-commands.test.ts +127 -0
  30. package/src/server/claude-loop-commands.ts +22 -6
  31. package/src/server/claude-plugin-update-checker.adapter.test.ts +2 -0
  32. package/src/server/claude-pty/driver.test.ts +32 -41
  33. package/src/server/claude-pty/driver.ts +12 -20
  34. package/src/server/claude-pty/env.test.ts +39 -0
  35. package/src/server/claude-pty/env.ts +31 -0
  36. package/src/server/claude-session-config.test.ts +1 -1
  37. package/src/server/claude-session-config.ts +52 -10
  38. package/src/server/claude-session-spawner.ts +8 -1
  39. package/src/server/claude-session-start.test.ts +28 -0
  40. package/src/server/claude-session-start.ts +8 -1
  41. package/src/server/claude-spawn-helpers.test.ts +42 -0
  42. package/src/server/claude-spawn-helpers.ts +32 -0
  43. package/src/server/claude-subagent-wiring.test.ts +3 -0
  44. package/src/server/claude-subagent-wiring.ts +15 -3
  45. package/src/server/claude-turn-starter.test.ts +35 -0
  46. package/src/server/claude-turn-starter.ts +28 -4
  47. package/src/server/cli-runtime.ts +19 -0
  48. package/src/server/codex-plugin-update-checker.adapter.test.ts +2 -0
  49. package/src/server/design/raw-ink-guard.test.ts +58 -0
  50. package/src/server/event-store-apply.ts +4 -2
  51. package/src/server/event-store-chat-lifecycle.ts +23 -0
  52. package/src/server/event-store-helpers.ts +2 -0
  53. package/src/server/event-store-write-ops.test.ts +75 -0
  54. package/src/server/event-store-write-ops.ts +54 -0
  55. package/src/server/event-store.stack-methods.test.ts +69 -0
  56. package/src/server/event-store.ts +12 -0
  57. package/src/server/events.ts +19 -0
  58. package/src/server/http-dispatcher.ts +9 -1
  59. package/src/server/kanna-mcp.ts +1 -1
  60. package/src/server/package-update-manager.test.ts +37 -2
  61. package/src/server/package-update-manager.ts +4 -0
  62. package/src/server/plugin-cli-dispatch.test.ts +5 -1
  63. package/src/server/plugin-system-acceptance.test.tsx +97 -1
  64. package/src/server/plugins/installed-plugin-store.test.ts +87 -0
  65. package/src/server/plugins/installed-plugin-store.ts +47 -0
  66. package/src/server/plugins/plugin-child-entry.adapter.ts +8 -0
  67. package/src/server/plugins/plugin-service-host.ts +20 -2
  68. package/src/server/plugins/plugin-service.ts +63 -5
  69. package/src/server/read-models.ts +45 -21
  70. package/src/server/skill-update-applier.adapter.test.ts +52 -0
  71. package/src/server/skill-update-applier.adapter.ts +82 -13
  72. package/src/server/skill-update-checker.adapter.test.ts +93 -58
  73. package/src/server/skill-update-checker.adapter.ts +59 -81
  74. package/src/server/subagent-provider-run.test.ts +35 -16
  75. package/src/server/subagent-provider-run.ts +33 -8
  76. package/src/server/ws-router-boards.test.ts +81 -0
  77. package/src/server/ws-router-boards.ts +15 -0
  78. package/src/server/ws-router-misc.test.ts +1 -0
  79. package/src/server/ws-router-misc.ts +14 -0
  80. package/src/server/ws-router-project.test.ts +1 -0
  81. package/src/server/ws-router-project.ts +8 -0
  82. package/src/shared/boards/dependencies.test.ts +149 -0
  83. package/src/shared/boards/dependencies.ts +180 -0
  84. package/src/shared/boards/types.ts +22 -2
  85. package/src/shared/boards/worktree-cleanup.ts +26 -0
  86. package/src/shared/design/tone-pairings.ts +5 -0
  87. package/src/shared/kanna-system-prompt.test.ts +153 -7
  88. package/src/shared/kanna-system-prompt.ts +99 -9
  89. package/src/shared/packages/parse-claude-plugins.ts +2 -0
  90. package/src/shared/packages/parse-codex-plugins.ts +1 -0
  91. package/src/shared/packages/parse-skill-lock.test.ts +30 -0
  92. package/src/shared/packages/parse-skill-lock.ts +2 -0
  93. package/src/shared/packages/skill-update-classifier.test.ts +158 -45
  94. package/src/shared/packages/skill-update-classifier.ts +74 -16
  95. package/src/shared/packages/tag-order.test.ts +50 -0
  96. package/src/shared/packages/tag-order.ts +57 -0
  97. package/src/shared/packages/types.ts +20 -3
  98. package/src/shared/plugins/kanna-plugin.d.ts +23 -1
  99. package/src/shared/protocol.ts +12 -1
  100. package/src/shared/stack-activity.test.ts +73 -0
  101. package/src/shared/stack-activity.ts +84 -0
  102. package/src/shared/types.ts +30 -0
  103. package/dist/client/assets/ChatPage-DK_ravan.js +0 -80
  104. package/dist/client/assets/CronJobRow-BBxYNjP-.js +0 -1
  105. package/dist/client/assets/LocalProjectsPage-DxVBV-j0.js +0 -1
  106. package/dist/client/assets/SettingsPage-C_vKQcrc.js +0 -9
  107. package/dist/client/assets/auth-DCKMIizv.js +0 -1
  108. package/dist/client/assets/editor-icons-D176ujta.js +0 -1
  109. package/dist/client/assets/index-D23u9oVK.css +0 -1
  110. package/dist/client/assets/index-DgmAZaSQ.js +0 -68
  111. package/dist/client/assets/timer.adapter-BccZI8Ee.js +0 -1
  112. package/dist/client/assets/useKannaState-Cd1N3uyE.js +0 -5
  113. package/dist/client/assets/workflowsStore-Dot81h2V.js +0 -1
@@ -0,0 +1,80 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-BBdwAnLG.js","assets/rolldown-runtime-hePW80VL.js","assets/react-CwJFpaho.js","assets/preload-helper-Czpn1I53.js","assets/jsx-runtime-NZYk81nU.js","assets/dist-BhKHwQyU.js"])))=>i.map(i=>d[i]);
2
+ import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{t as n}from"./react-CwJFpaho.js";import{t as r}from"./react-dom-DX3XddaT.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{E as a,F as o,G as s,M as c,N as l,O as u,P as d,U as f,W as p,a as m,i as h,j as g,n as _,o as v,t as y}from"./chatFocusPolicy-DlNQnC-P.js";import{t as b}from"./jsx-runtime-NZYk81nU.js";import{$ as x,Ct as S,Dt as C,Et as w,Ft as T,G as E,Gt as D,H as O,I as k,J as A,Lt as j,N as M,Nt as N,Ot as P,Pt as F,Q as I,R as L,Rt as ee,St as R,Tt as z,Ut as te,V as ne,W as B,Wt as V,X as re,Xt as ie,Y as ae,Yt as oe,Z as se,Zt as ce,_t as le,a as H,at as ue,b as de,bt as fe,ct as pe,dt as me,et as he,ft as ge,gt as _e,ht as ve,it as ye,jt as be,mt as xe,nn as U,o as Se,ot as Ce,pt as we,q as Te,qt as Ee,rn as De,rt as Oe,st as ke,t as Ae,tt as je,ut as Me,vt as Ne,wt as Pe,xt as Fe,yt as Ie,z as Le,zt as Re}from"./lexicalToReact-CmBG3fG-.js";import{$ as ze,A as Be,B as Ve,C as He,D as Ue,E as We,F as Ge,G as Ke,H as qe,I as Je,J as Ye,K as Xe,L as Ze,M as Qe,N as $e,O as W,P as et,Q as tt,R as nt,S as rt,T as it,U as at,V as ot,W as st,X as ct,Y as lt,Z as ut,_ as dt,a as ft,b as G,c as pt,d as mt,et as ht,f as gt,g as _t,h as vt,i as yt,j as bt,k as xt,l as St,m as Ct,nt as wt,o as Tt,p as Et,q as Dt,r as Ot,rt as kt,s as At,tt as jt,u as Mt,v as Nt,w as Pt,x as Ft,y as It,z as Lt}from"./WorkflowsSection-B21zGQbZ.js";import{$ as Rt,B as zt,C as Bt,E as Vt,I as Ht,J as Ut,M as Wt,O as Gt,Q as Kt,R as qt,S as Jt,T as Yt,V as Xt,X as Zt,Y as Qt,Z as $t,_ as en,_t as tn,a as nn,b as rn,c as an,ct as on,d as sn,et as cn,f as ln,g as un,gt as dn,h as fn,ht as pn,it as mn,l as hn,m as gn,mt as _n,n as vn,nt as yn,o as bn,ot as xn,p as Sn,pt as Cn,q as wn,r as Tn,rt as En,s as Dn,st as On,t as kn,tt as An,u as jn,ut as Mn,v as Nn,vt as Pn,w as Fn,x as In,y as Ln,z as Rn}from"./useKannaState-VCszkCW6.js";import{$ as zn,I as Bn,L as Vn,N as Hn,P as Un,Q as Wn,Y as Gn,at as Kn,c as qn,f as Jn,g as Yn,h as Xn,it as Zn,o as Qn,ot as $n,p as er,rt as tr,st as nr,y as rr}from"./auth-CkUMBgRL.js";import{_ as ir,a as ar,b as or,c as sr,d as cr,f as lr,g as ur,h as dr,i as fr,m as pr,n as mr,o as hr,p as gr,r as _r,s as vr,t as yr,u as br,v as xr,x as Sr,y as Cr}from"./editor-icons-BYPupL7B.js";import{n as wr,o as Tr,s as Er}from"./KannaSocketProvider-ls8_E7wV.js";import{i as Dr,n as Or,r as kr,t as Ar}from"./clipboard.adapter-oOX2ilg4.js";import{t as jr}from"./chevron-right-CfYhmMd0.js";import{t as Mr}from"./terminal-DN6RVlGE.js";import{c as Nr,i as Pr,n as Fr,o as Ir,r as Lr,t as Rr}from"./workflowsStore-DIyxNBAq.js";import{t as zr}from"./ellipsis-DxdBZfX2.js";import{t as Br}from"./external-link-Y8PeBHhL.js";import{t as Vr}from"./folder-iHFIywEf.js";import{i as Hr,r as Ur}from"./status-pill-7oGKnp-A.js";import{a as Wr,i as Gr,n as Kr,o as qr,r as Jr,t as Yr}from"./CronJobRow-BNg3n_6B.js";import{a as Xr,c as Zr,i as Qr,l as $r,r as ei}from"./statusLabel-CCBzc1NW.js";import{t as ti}from"./plus-B-yZJldk.js";import{t as ni}from"./square-pen-i4HSLucd.js";import{_ as ri,a as ii,d as ai,i as oi,l as si,n as ci,o as li,r as ui,s as di,t as fi}from"./timer.adapter-D4UNPu_T.js";import{t as pi}from"./input-DKS4Wabz.js";import{c as mi,d as hi,f as gi,l as _i,m as vi,s as yi,u as bi}from"./branding-CxXZpUoc.js";import{d as xi,l as Si,s as Ci}from"./pushClient-Bl0yS8dB.js";import{c as wi,n as Ti,r as Ei,s as Di,t as Oi}from"./formatters-wSVyvDFZ.js";import{n as ki,r as Ai,t as ji}from"./formatDuration-BbWTR_M_.js";import{n as Mi,r as Ni,t as Pi}from"./popover-Z9RcEVxM.js";import{a as Fi,i as Ii,n as Li,s as Ri,t as zi}from"./columnStyle-BFon0FD4.js";import{t as Bi}from"./state-mark-BaDrojX-.js";var Vi=g(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Hi=g(`asterisk`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m18.065 8.496-12.125 7`,key:`1h26g9`}],[`path`,{d:`m5.94 8.504 12.125 7`,key:`k77sdm`}]]),Ui=g(`at-sign`,[[`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`}]]),Wi=g(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),Gi=g(`bell`,[[`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`}]]),Ki=g(`building-2`,[[`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`}]]),qi=g(`calendar-x-2`,[[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`m17 16 5 5`,key:`1a37d9`}],[`path`,{d:`m17 21 5-5`,key:`1b797a`}],[`path`,{d:`M21 12V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h8`,key:`14ws7l`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}]]),Ji=g(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),Yi=g(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Xi=g(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]]),Zi=g(`circle-dashed`,[[`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`}]]),Qi=g(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]),$i=g(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ea=g(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),ta=g(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),na=g(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),ra=g(`eraser`,[[`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`}]]),ia=g(`git-branch-plus`,[[`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`}]]),aa=g(`git-compare`,[[`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`}]]),oa=g(`git-merge`,[[`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`}]]),sa=g(`git-pull-request`,[[`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`}]]),ca=g(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),la=g(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),ua=g(`link-2-off`,[[`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`}]]),da=g(`link-2`,[[`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`}]]),fa=g(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),pa=g(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),ma=g(`minimize`,[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]),ha=g(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),ga=g(`paperclip`,[[`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`}]]),_a=g(`pen-line`,[[`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`}]]),va=g(`pencil-line`,[[`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`}]]),ya=g(`rotate-cw`,[[`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`}]]),ba=g(`rows-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]]),xa=g(`rows-3`,[[`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`}]]),Sa=g(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Ca=g(`skip-forward`,[[`path`,{d:`M21 4v16`,key:`7j8fe9`}],[`path`,{d:`M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`zs4d6`}]]),wa=g(`slash`,[[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}]]),Ta=g(`sliders-horizontal`,[[`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`}]]),Ea=g(`square-terminal`,[[`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`}]]),Da=g(`text-wrap`,[[`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`}]]),Oa=g(`upload`,[[`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`}]]),ka=g(`zap`,[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]),K=e(n(),1),Aa=e(r(),1),q=e(b(),1),ja={bold:`bold`,italic:`italic`,strikeThrough:`strikethrough`,subscript:`subscript`,superscript:`superscript`,underline:`underline`},Ma=Symbol.for(`@lexical/dragon/WindowState`);function Na(e,t,n){let r=function(e){let t=e[Ma];return t===void 0&&(t={dispose:()=>{},editors:new Map,installs:new Set},e[Ma]=t),t}(e);if(r.installs.size===0){let t=La.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 Pa.bind(null,e,r,t,n)}function Pa(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[Ma])}function Fa(e){return e&&e.ownerDocument.defaultView}function Ia(e){let t=M(()=>Fa(e.getRootElement()),t=>e.registerRootListener(e=>{t.value=Fa(e)}));return k(()=>{let n=t.value;if(n)return Na(n,Symbol(`@lexical/dragon/editorInstall`),e)})}function La(e){if(e.origin!==this.location.origin)return;let t=function(e){let t=e[Ma];if(t===void 0)return null;let n=Ce(xe(e.document));return B(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=je();if(P(t)){let r=t.anchor,l=r.getNode(),u=0,d=0;if(Me(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()),Me(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=ja[c];e!==void 0&&t.formatText(e)}e.stopImmediatePropagation()}})}}}}}var Ra=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),za=t(((e,t)=>{t.exports=Ra()}))();(0,K.forwardRef)(function(e,t){return K.createElement(`div`,{ref:t,...e})});var Ba=(0,K.forwardRef)(function(e,t){return K.createElement(`div`,{ref:t,...e})}),Va=Ba,Ha={OS:`web`};function Ua(e,t){return t===void 0?e:Math.max(0,Math.min(t,e))}function Wa(e,t){return t===void 0||!Number.isFinite(t)||!Number.isFinite(e.scrollLength)||t<=e.scrollLength?t!==void 0&&Number.isFinite(t)&&Number.isFinite(e.scrollLength)?0:void 0:Math.max(0,t-e.scrollLength)}function Ga(){return`normal`}function Ka(e){return e?.horizontalRTLScrollType??Ga()}function qa(e){return e?.rtl??!1}function Ja(e){return Ya(e?.props)}function Ya(e){return!!e?.horizontal&&qa(e)}function Xa(e){return e?.horizontal?(Ya(e)?e.stylePaddingLeft:e.stylePaddingRight)||0:e?.stylePaddingBottom||0}function Za(e,t){return t&&(Ja(e)?t.left:t.right)||0}function Qa(e,t,n,r){return!Ja(e)||r===void 0||!Number.isFinite(r)?t:Math.max(0,r-t-n)}function $a(e,t,n){if(!e||!Ja(e))return t;let r=Wa(e,n),i=Ua(t,r),a=Ka(e);return a===`negative`?i===0?0:-i:a===`inverted`?r===void 0?i:Ua(r-i,r):i}function eo(e,t,n){if(!Ja(e))return e.horizontalRTLScrollType=void 0,t;let r=Wa(e,n);if(t<0)return e.horizontalRTLScrollType=`negative`,Ua(-t,r);if(r===void 0)return t;let i=t,a=r-t;if(!Number.isFinite(a))return e.horizontalRTLScrollType=`normal`,i;let o=e.horizontalRTLScrollType;if(o===`inverted`)return Ua(a,r);if(o===`normal`)return Ua(i,r);if(!e.hasScrolled)return e.horizontalRTLScrollType=Ga(),Ua(i,r);let s=e.scroll,c=Math.abs(i-s),l=Math.abs(a-s)+.5<c;return e.horizontalRTLScrollType=l?`inverted`:`normal`,Ua(l?a:i,r)}var to=e=>e,no=K.createContext(null),ro=`\0`,io=0;function ao({children:e}){let[t]=K.useState(()=>({animatedScrollY:to(0),columnWrapperStyle:void 0,containerLayoutTriggers:new Map,contextNum:io++,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 K.createElement(no.Provider,{value:t},e)}function oo(){return K.useContext(no)}function so(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=J(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(uo(e,i,n));return()=>{for(let e of r)e()}}}}function co(e){return e.length===1?e[0]:e.join(ro)}function lo(e){return e.split(ro)}function uo(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 J(e,t){let{values:n}=e;return n.get(t)}function Y(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 fo(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 po(e,t,n){let{positionListeners:r}=e,i=r.get(t);if(i)for(let e of i)e(n)}function mo(e){let t=K.useContext(no),n=co(e),{subscribe:r,get:i}=K.useMemo(()=>so(t,lo(n)),[t,n]);return(0,za.useSyncExternalStore)(r,i,i)}function ho(e,t){let n=K.useContext(no),{subscribe:r,get:i}=K.useMemo(()=>so(n,[e]),[n,e]),a=K.useCallback(()=>t(i()[0]),[i,t]);return(0,za.useSyncExternalStore)(r,a,a)}function go(e){return Math.max(0,e??0)}function _o(e,t){let n=e.state,{props:r}=n,i=r.horizontal,a=r.contentInset??n.nativeContentInset,o=(i?Za(n,a):a?.bottom)||0,s=go(t??r.contentInsetEndAdjustment),c=J(e,`anchoredEndSpaceSize`),l=r.anchoredEndSpace&&c?c:0,u=n.contentInsetOverride??void 0,d=o+s;if(u){let e={bottom:0,left:0,right:0,...a,...u};return Math.max(((i?Za(n,e):e.bottom)||0)+s,l)}return Math.max(d,l)}function vo(e){let{values:t,state:n}=e,r=n.props.horizontal?n.props.stylePaddingLeft||0:t.get(`stylePaddingTop`)||0,i=n.props.horizontal?n.props.stylePaddingRight||0:n.props.stylePaddingBottom||0,a=t.get(`alignItemsAtEndPadding`)||0,o=t.get(`headerSize`)||0,s=t.get(`footerSize`)||0,c=_o(e),l=n.pendingTotalSize??n.totalSize??t.get(`totalSize`),u=Math.max(0,l-(n.props.data.length>0?e.scrollAxisGap:0));return o+s+u+r+a+i+(c||0)}var yo=({children:e})=>K.createElement(Ba,{style:{alignItems:`center`,flexDirection:`row`,justifyContent:`space-between`}},e);K.memo(function(){let e=oo(),[t=0,n=0,r=0,i=0,a=0,o=0,s=!1]=mo([`totalSize`,`scrollAdjust`,`debugRawScroll`,`debugComputedScroll`,`numContainers`,`numContainersPooled`,`isAtEnd`]),c=vo(e),[,l]=(0,K.useReducer)(e=>e+1,0);return bo(()=>{l()},100),K.createElement(Ba,{pointerEvents:`none`,style:{backgroundColor:`#FFFFFFCC`,borderRadius:4,padding:4,paddingBottom:4,paddingLeft:4,position:`absolute`,right:0,top:0}},K.createElement(yo,null,K.createElement(Va,null,`TotalSize:`),K.createElement(Va,null,t.toFixed(2))),K.createElement(yo,null,K.createElement(Va,null,`ContentSize:`),K.createElement(Va,null,c.toFixed(2))),K.createElement(yo,null,K.createElement(Va,null,`At end:`),K.createElement(Va,null,String(s))),K.createElement(yo,null,K.createElement(Va,null,`ScrollAdjust:`),K.createElement(Va,null,n.toFixed(2))),K.createElement(yo,null,K.createElement(Va,null,`RawScroll: `),K.createElement(Va,null,r.toFixed(2))),K.createElement(yo,null,K.createElement(Va,null,`ComputedScroll: `),K.createElement(Va,null,i.toFixed(2))))});function bo(e,t){(0,K.useEffect)(()=>{let n=setInterval(e,t);return()=>clearInterval(n)},[t])}var xo=!0,So=new WeakMap;function Co(e){return So.get(e)}function wo(e,t){So.set(e,t)}var To=typeof __DEV__<`u`?__DEV__:void 0,Eo=typeof process<`u`?`production`:void 0,Do=(typeof Eo==`string`?Eo.toLowerCase()!==`production`:void 0)??To??!1,Oo=-1e7,ko=1,Ao=Do&&!1,jo=Do&&!1;function Mo({scheduledWork:e}){e.cancel(`checkFinishedScrollFrame`),e.cancel(`checkFinishedScrollRetryFrame`),e.cancel(`checkFinishedScrollFallback`),e.cancel(`platformScrollCompletion`)}function No(e){let t=e.pendingScrollResolve??e.pendingScrollToEnd?.resolve;e.pendingScrollResolve=void 0,e.pendingScrollToEnd=void 0,t?.()}function Po(e){Mo(e),e.scheduledWork.cancel(`imperativeScrollReady`),e.scrollingTo=void 0,e.scrollTargetPinnedRange=void 0,No(e)}function Fo(e,t,n){return{...t,nativeEvent:{...t.nativeEvent,contentOffset:e.props.horizontal?{x:n,y:0}:{x:0,y:n}}}}function Io(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,Fo(i,a,t??i.scrollPending??i.scroll??0)))}var Lo=1;function Ro(e){return!!(e?.didDispatchNativeScroll||e?.didRetrySilentInitialScroll||e?.watchdog)}function zo(e){e.initialScrollSession=void 0}function Bo(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 Vo(e,t=(t=>(t=(t=>(t=e.initialScrollSession)?.kind)())??`bootstrap`)()){var n;return e.initialScrollSession?e.initialScrollSession.kind!==t&&(e.initialScrollSession=Bo({bootstrap:e.initialScrollSession.kind===`bootstrap`?e.initialScrollSession.bootstrap:void 0,completion:e.initialScrollSession.completion,kind:t,previousDataLength:e.initialScrollSession.previousDataLength})):e.initialScrollSession=Bo({completion:{},kind:t,previousDataLength:0}),(n=e.initialScrollSession).completion??(n.completion={}),e.initialScrollSession.completion}var Ho={didDispatchNativeScroll(e){return!!e.initialScrollSession?.completion?.didDispatchNativeScroll},didRetrySilentInitialScroll(e){return!!e.initialScrollSession?.completion?.didRetrySilentInitialScroll},markInitialScrollNativeDispatch(e){Vo(e).didDispatchNativeScroll=!0},markSilentInitialScrollRetry(e){Vo(e).didRetrySilentInitialScroll=!0},resetFlags(e){if(!e.initialScrollSession)return;let t=Vo(e,e.initialScrollSession.kind);t.didDispatchNativeScroll=void 0,t.didRetrySilentInitialScroll=void 0}},Uo={clear(e){Uo.set(e,void 0)},didReachTarget(e,t){return Math.abs(e-t.targetOffset)<=Lo},get(e){return e.initialScrollSession?.completion?.watchdog},hasNonZeroTargetOffset(e){return e!==void 0&&e>Lo},isAtZeroTargetOffset(e){return e<=Lo},set(e,t){if(!t&&!e.initialScrollSession?.completion?.watchdog)return;let n=Vo(e);n.watchdog=t?{startScroll:t.startScroll,targetOffset:t.targetOffset}:void 0}};function Wo(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&&!Ro(i)?zo(e):(e.initialScrollSession=Bo({bootstrap:o,completion:i,kind:r,previousDataLength:t.previousDataLength??n?.previousDataLength??0}),e.initialScrollSession)}var Go=1.3;function Ko(e,t,n){let r=Math.abs(e);return!t&&n>0&&r>=n*Go||!t&&n<=0&&r>0}var qo=(e,t,n,r,i,a,o,s)=>{let c=t||n>0&&Math.abs(e)<=n,l=()=>{s({atThreshold:t,contentSize:a.contentSize,dataLength:a.dataLength,scrollPosition:a.scrollPosition})};return r?Ko(e,t,n)?(s(void 0),!1):(c&&(!i||i.atThreshold!==t||i.contentSize!==a.contentSize||i.dataLength!==a.dataLength)&&l(),!0):c?(o(e),l(),!0):!1};function Jo(e,t){let n=e.state;t===`start`?(n.isStartReached=!1,n.startReachedSnapshot=void 0):(n.isEndReached=!1,n.endReachedSnapshot=void 0)}function Yo(e){let t=e.state;if(!t.edgeReachedGate)return;let n=vo(e),r=n-t.scroll-t.scrollLength-_o(e),i=n<t.scrollLength,a=t.props.onStartReachedThreshold*t.scrollLength,o=t.props.onEndReachedThreshold*t.scrollLength,s=Ko(t.scroll,!1,a),c=Ko(r,i,o);s&&c&&(t.edgeReachedGate=void 0)}function Xo(e,t,n,r){return!e.state.edgeReachedGate||n===t||!!r}function Zo(e){e.state.edgeReachedGate=`closed`}function Qo(e){e.state.edgeReachedGate&&(e.state.edgeReachedGate=`prepared`)}function $o(e,t){let n=e.state;if(n.edgeReachedGate!==`prepared`)return;let r=t<0?`start`:`end`;return n.edgeReachedGate=`closed`,Jo(e,r),r}function es(e){return!!e?.initialScroll&&!e.didFinishInitialScroll}function ts(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=vo(e);if(Yo(e),r.props.data.length===0&&a>0&&u<=a){Y(e,`isAtEnd`,!0),Y(e,`isNearEnd`,!0),Y(e,`isWithinMaintainScrollAtEndThreshold`,!0);return}if(u>0&&i){let i=_o(e),d=u-o-a-i,f=u<a;Y(e,`isAtEnd`,f||d<=ko),Y(e,`isNearEnd`,f||d<=l*a),Y(e,`isWithinMaintainScrollAtEndThreshold`,f||d<=c*a||r.pendingMaintainScrollAtEnd||s===`animated`||s===`instant`),es(r)||s||(r.isEndReached=qo(d,f,l*a,r.isEndReached,r.endReachedSnapshot,{contentSize:u,dataLength:r.props.data?.length,scrollPosition:o},i=>{var a,o;Xo(e,`end`,t,n)&&(Zo(e),(o=(a=r.props).onEndReached)==null||o.call(a,{distanceFromEnd:i}))},e=>{r.endReachedSnapshot=e}))}}function ns(e,t,n){let r=e?.state;if(!r)return;let{isStartReached:i,props:{data:a,onStartReachedThreshold:o},scroll:s,scrollLength:c,startReachedSnapshot:l,totalSize:u}=r,d=a.length,f=o*c;Yo(e),i&&f>0&&s>f&&l&&(l.contentSize!==u||l.dataLength!==d)&&(r.isStartReached=!1,r.startReachedSnapshot=void 0),Y(e,`isAtStart`,s<=ko),Y(e,`isNearStart`,s<=f),es(r)||r.scrollingTo||(r.isStartReached=qo(s,!1,f,r.isStartReached,l,{contentSize:u,dataLength:d,scrollPosition:s},i=>{var a,o;Xo(e,`start`,t,n)&&(Zo(e),(o=(a=r.props).onStartReached)==null||o.call(a,{distanceFromStart:i}))},e=>{r.startReachedSnapshot=e}))}function rs(e,t){let n=!e.state.edgeReachedGate;ts(e,t,n),ns(e,t,n)}function is(e){var t;let n=e.state;n.props?.data&&((t=n.triggerCalculateItemsInView)==null||t.call(n,{forceFullItemPositions:!0})),rs(e)}var as=6,os=3,ss=250;function cs(e){e.state.scheduledWork.cancel(`adaptiveRender`)}function ls(e,t){let n=e.state;cs(e),t<=0?us(e,`normal`,`scroll`):n.scheduledWork.timeout(()=>us(e,`normal`,`scroll`),t,`adaptiveRender`)}function us(e,t,n){var r,i;J(e,`adaptiveRender`)!==t&&(Y(e,`adaptiveRender`,t),(i=(r=e.state.props.adaptiveRender)?.onChange)==null||i.call(r,t,n))}function ds(e){cs(e);let t=e.state.props.adaptiveRender?.initialMode??`normal`;J(e,`adaptiveRender`)!==t&&us(e,t,`initial`)}function fs(e,t,n){let r=e.state,i=r.props.adaptiveRender,a=J(e,`adaptiveRender`);if(J(e,`readyToRender`)){if(i){let o=i.enterVelocity??as,s=i.exitVelocity??os,c=i.exitDelay??ss,l=a===`light`?s:o,u=n?.forceLight||Math.abs(t)>l?`light`:`normal`;u!==(r.scheduledWork.has(`adaptiveRender`)?`normal`:a)&&(u===`light`?(us(e,`light`,`scroll`),ls(e,c)):a===`light`&&ls(e,c))}else ds(e)}}var ps=50;function ms(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`&&!J(e,`readyToRender`)&&!i?Math.min(n,ps):n}function hs(e){let{state:t}=e;t.props.drawDistance<=ps||t.scheduledWork.has(`fullDrawDistancePrewarm`)||t.scheduledWork.frame(()=>t.triggerCalculateItemsInView?.call(t),`fullDrawDistancePrewarm`)}function gs(e,{resetLayout:t,resetInitialScroll:n}){let{state:r}=e;t&&(r.didContainersLayout=!1,r.queuedInitialLayout=!1),n&&(r.didFinishInitialScroll=!1),Y(e,`readyToRender`,!1),ds(e)}function _s(e,{didLayout:t,didInitialScroll:n}){let{state:r}=e,{loadStartTime:i,props:{onLoad:a}}=r;t&&(r.didContainersLayout=!0),n&&(r.didFinishInitialScroll=!0),r.didContainersLayout&&r.didFinishInitialScroll&&!J(e,`readyToRender`)&&(Y(e,`readyToRender`,!0),us(e,`normal`,`ready`),r.props.drawDistance>ps&&hs(e),r.didLoad||(r.didLoad=!0,a&&a({elapsedTimeInMs:Date.now()-i})))}var vs=2e3;function ys(e,t){e.scroll=t,e.scrollPending=t,e.scrollPrev=t}function bs(e){e.scheduledWork.cancel(`preservedInitialScroll`)}function xs(e){bs(e),e.clearPreservedInitialScrollOnNextFinish=void 0,e.initialScroll=void 0,Wo(e)}function Ss(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&&(Mo(t),t.scrollingTo=void 0,t.scrollTargetPinnedRange=void 0),Ho.resetFlags(t),Wo(t,{bootstrap:null}),Cs(e))}function Cs(e,t){var n;let r=e.state;if(t?.resolvedOffset!==void 0)ys(r,t.resolvedOffset);else if(t?.syncObservedOffset&&r.initialScrollSession?.kind===`offset`){let e=((n=r.refScroller.current)?.getCurrentScrollOffset)?.call(n);typeof e==`number`&&Number.isFinite(e)&&ys(r,e)}let i=()=>{var n;let i=r.initialScrollSession?.kind===`bootstrap`,a=t?.resolvedOffset??r.scrollPending??r.scroll??0;Uo.clear(r),t?.preserveTarget&&r.initialScroll?(r.clearPreservedInitialScrollOnNextFinish=void 0,Wo(r),bs(r),t?.schedulePreservedTargetClear&&r.scheduledWork.timeout(()=>{!r.didFinishInitialScroll||r.scrollingTo?.isInitialScroll||!r.initialScroll||xs(r)},vs,`preservedInitialScroll`)):xs(r),t?.recalculateItems&&is(e),_s(e,{didInitialScroll:!0}),i&&Io(e,a),(n=t?.onFinished)==null||n.call(t)};if(t?.waitForCompletionFrame){requestAnimationFrame(i);return}i()}function ws(e,t){let n=e.state;return t===void 0?0:n.positions[t]||0}function Ts(e){let{state:t}=e;return(t.props.horizontal?(Ja(t)?t.props.stylePaddingRight:t.props.stylePaddingLeft)||0:J(e,`stylePaddingTop`)||0)+(J(e,`alignItemsAtEndPadding`)||0)+(J(e,`headerSize`)||0)}function Es(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 Ds(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 Os(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-Ds(e)-_o(e)):0}function ks(e){let{state:t}=e,n=J(e,`alignItemsAtEndPadding`)||0,r=Os(e);if(n!==r){let i=t.maintainingScrollAtEnd===`pending-animated`||t.maintainingScrollAtEnd===`animated`,a=t.didContainersLayout&&t.props.maintainScrollAtEnd?.animated&&(i||n>r&&J(e,`isWithinMaintainScrollAtEndThreshold`));a&&!i&&!t.pendingMaintainScrollAtEnd?t.scheduledWork.microtask(()=>{!t.maintainingScrollAtEnd&&!t.pendingMaintainScrollAtEnd&&Y(e,`alignItemsAtEndPadding`,Os(e))},`alignItemsAtEndPaddingFallback`):a||Y(e,`alignItemsAtEndPadding`,r)}}function As(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&&Y(e,`totalSize`,o):(i.pendingTotalSize=void 0,i.totalSize=o,r&&Y(e,`totalSize`,o),ks(e))}function js(e,t,n,r=!0){let{sizes:i}=e.state,a=i.get(t),o=a===void 0?n:n-a;o!==0&&As(e,t,o,r),i.set(t,n)}function Ms(e){return typeof e==`function`}function Ns(e){return Array.isArray(e)}var Ps=new Set;function Fs(e,t){Do&&!Ps.has(e)&&(Ps.add(e),console.warn(`[legend-list] ${t}`))}function Is(e){return Math.floor(e*8)/8}function Ls(e){return e==null}function Rs(e,t){let n=t===`Left`||t===`Right`?e.paddingHorizontal:e.paddingVertical;return e[`padding${t}`]??n??e.padding??0}function zs(e,t,n){return Rs(e,n)+Rs(t,n)}function Bs(e,t){let n=(e.state?.containerItemKeys)?.get(t);if(n!==void 0)return n;let r=J(e,`numContainers`);for(let n=0;n<r;n++)if(J(e,`containerItemKey${n}`)===t)return n;return-1}function Vs(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.sizesKnown.set(t,c))}return c}function Hs(e,t){return Vs(e,Es(e.state,t),t,e.state.props.data[t])}function Us(e,t,n){for(let r=t;r<=n;r++)if(Hs(e,r)===void 0)return!1;return!0}function Ws(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,g=l.get(t);if(a&&g!==void 0)return g;if(h=Vs(e,t,n,r,s),h!==void 0)return js(e,t,h,o),h;let _=s?.itemType??(f?f(r,n)??``:``);if(i&&!p){let e=u[_]?.avg;e!==void 0&&(h=Is(e))}if(h===void 0&&g!==void 0)return g;if(h===void 0&&i&&p){let e=p.averageSizeSnapshot?.[_];e!==void 0&&(h=Is(e))}return h===void 0&&(h=d+e.scrollAxisGap),js(e,t,h,o),h}function Gs(e,t){if(!(t===void 0||t<0))return Ws(e,Es(e.state,t),t,e.state.props.data[t])}function Ks(e,t,n){let r=e.state,{index:i,viewOffset:a,viewPosition:o}=n,s=t;if(a&&(s-=a),i!==void 0){let t=Ts(e);t&&(s+=t)}if(o!==void 0&&i!==void 0){let t=r.props.data.length;if(t===0)return s;let n=i<0||i>=t,a=r.props.estimatedItemSize??0,c=n?a:Ws(e,Es(r,i),i,r.props.data[i]),l=Math.max(0,c-(n?0:e.scrollAxisGap)),u=_o(e);if(s-=o*(r.scrollLength-u-l),!n&&i===r.props.data.length-1){let t=J(e,`footerSize`)||0;s+=t}}return s}function qs(e,t,n){let r=e.state,i=vo(e),a=t;if(Number.isFinite(i)&&Number.isFinite(r.scrollLength)&&Ha.OS!==`android`){let e=Math.max(0,i-r.scrollLength),o=n?.viewOffset,s=e+(typeof o==`number`&&o<0?-o:0);a=Math.min(t,s)}return a=Math.max(0,a),a}function Js(e){let t=e.state;if(t?.scrollingTo){Mo(t);let n=t.pendingScrollResolve;t.pendingScrollResolve=void 0;let r=t.scrollingTo;if(t.scrollHistory.length=0,t.scrollingTo=void 0,t.scrollTargetPinnedRange=void 0,t.pendingTotalSize!==void 0&&As(e,null,t.pendingTotalSize),t.scrollAdjustHandler.commitPendingAdjust(r),r.isInitialScroll||t.initialScroll){let i=t.initialScrollSession?.kind===`offset`,a=!!r.isInitialScroll&&!t.clearPreservedInitialScrollOnNextFinish&&t.props.data.length>0&&t.initialScroll?.viewPosition===1;Cs(e,{onFinished:()=>{n?.()},preserveTarget:i&&t.props.data.length===0||a,recalculateItems:!0,schedulePreservedTargetClear:a,syncObservedOffset:i,waitForCompletionFrame:!!r.waitForInitialScrollCompletionFrame});return}is(e),n?.()}}var Ys=80,Xs=1500,Zs=320,Qs=1;function $s(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,u=l?vo(e):void 0,d=l?$a(n,a,u):0,f=l?0:a;if(o.scrollTo({animated:c,x:d,y:f}),c)ec(e,{readOffset:()=>o.getCurrentScrollOffset(),target:o.getScrollEventTarget?.call(o)??null,targetOffset:a});else{n.scroll=a;let t=n.scrollingTo;n.scheduledWork.timeout(()=>{t===n.scrollingTo&&Js(e)},100,`platformScrollCompletion`)}}function ec(e,t){let{readOffset:n,target:r,targetOffset:i}=t;if(!r){Js(e);return}let a=`onscrollend`in r,o,s=!1,{scheduledWork:c,scrollingTo:l}=e.state,u=setTimeout(()=>p(`max`),Xs),d=()=>{r.removeEventListener(`scroll`,m),a&&r.removeEventListener(`scrollend`,h),o!==void 0&&clearTimeout(o),clearTimeout(u)},f=()=>{s||(s=!0,d())},p=t=>{if(s)return;if(l!==e.state.scrollingTo){c.cancel(`platformScrollCompletion`);return}let r=n(),a=Math.abs(r-i)<=Qs;t===`scrollend`&&!a||(c.cancel(`platformScrollCompletion`),Js(e))},m=()=>{o!==void 0&&clearTimeout(o),o=setTimeout(()=>p(`idle`),Ys)},h=()=>p(`scrollend`);r.addEventListener(`scroll`,m),a?r.addEventListener(`scrollend`,h):o=setTimeout(()=>p(`idle`),Zs),c.register(`platformScrollCompletion`,f)}function tc(e){if(!e.scrollRequestTracker){let t=0,n=n=>{let r=e.state;r.scheduledWork.cancel(`imperativeScrollReady`);let i=++t;return No(r),r.pendingScrollResolve=n,i},r=(n,r,i)=>{let a=e.state;n===t&&(!i()||!a.scrollingTo)&&(a.pendingScrollResolve===r&&(a.pendingScrollResolve=void 0),r())};e.scrollRequestTracker={isCurrent:e=>e===t,runNow:r,runNowIfIdle:t=>{let i=e.state;return i.pendingScrollResolve||i.scrollingTo?Promise.resolve():new Promise(e=>{let i=n(e);r(i,e,t)})},start:n}}return e.scrollRequestTracker}function nc(e,t,n){let r=e.state;if(Math.abs(t)>.1){let n=()=>{r.scrollAdjustHandler.requestAdjust(t),r.adjustingFromInitialMount&&r.adjustingFromInitialMount--};r.scroll+=t,r.scrollForNextCalculateItemsInView=void 0,J(e,`readyToRender`)?n():(r.adjustingFromInitialMount=(r.adjustingFromInitialMount||0)+1,requestAnimationFrame(n))}}function rc(e){var t;let{state:n}=e,r=J(e,`alignItemsAtEndPadding`)||0,i=Os(e);n.maintainingScrollAtEnd=void 0,n.pendingMaintainScrollAtEnd=!1,r!==i&&(Y(e,`alignItemsAtEndPadding`,i),n.scrollForNextCalculateItemsInView=void 0,(t=n.triggerCalculateItemsInView)==null||t.call(n,{forceFullItemPositions:!0}),nc(e,qs(e,n.scroll+i-r)-n.scroll))}function ic(e){let t=e.state,{didContainersLayout:n,didFinishInitialScroll:r,pendingNativeMVCPAdjust:i,props:{maintainScrollAtEnd:a}}=t,o=J(e,`isWithinMaintainScrollAtEndThreshold`),s=!!t.pendingMaintainScrollAtEnd,c=!!((o||s)&&a&&r);if(c&&!n)return t.pendingMaintainScrollAtEnd=!0,!1;if(i)return t.pendingMaintainScrollAtEnd=c,!1;if(c&&n){if(t.pendingMaintainScrollAtEnd=!1,vo(e)<t.scrollLength&&(t.scroll=0),t.maintainingScrollAtEnd)t.pendingMaintainScrollAtEnd=!0;else{let n=a.animated?`pending-animated`:`pending-instant`,r=a.animated?`animated`:`instant`,i=t.scroll;t.maintainingScrollAtEnd=n,requestAnimationFrame(()=>{if(t.maintainingScrollAtEnd!==n)return;let o=J(e,`isWithinMaintainScrollAtEndThreshold`),c=t.scroll!==i;s||o||!c?(t.maintainingScrollAtEnd=r,tc(e).runNowIfIdle(()=>e.scrollToEnd({animated:a.animated})).then(()=>{t.maintainingScrollAtEnd===r&&(t.pendingMaintainScrollAtEnd?(t.maintainingScrollAtEnd=void 0,ic(e)):rc(e))})):t.maintainingScrollAtEnd===n&&rc(e)})}return!0}return rc(e),!1}var ac=.1,oc=300,sc=2,cc=1;function lc(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;return}return i}function uc(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)<=ac&&l?.id===n?l.quietPasses+1:0;if(!i&&u>=sc){e.mvcpAnchorLock=void 0;return}e.mvcpAnchorLock={expiresAt:a+oc,id:n,position:r,quietPasses:u}}}function dc(e,t,n,r,i,a){return!1}function fc(e,t,n){if(Math.abs(t)<=ac)return 0;let r=Math.max(0,n-e.scrollLength)-e.scroll;return t<0?Math.max(t,Math.min(0,r)):t>0?Math.min(t,Math.max(0,r)):0}function pc(e,t){return e<0?-t:t}function mc(e,t,n){let r=e.state;r.pendingNativeMVCPAdjust=void 0;let i=t-n;Math.abs(i)>ac&&nc(e,i)}function hc(e){let t=e.state,n=t.pendingNativeMVCPAdjust;if(!n||Math.abs(n.manualApplied)>ac)return;let r=vo(e),i=fc(t,n.amount,r);if(Math.abs(i)<=ac)return;let a=n.amount-i;Math.abs(a)<=ac||(n.manualApplied=a,nc(e,a),n.furthestProgressTowardAmount=0)}function gc(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>ac||i>0&&a<-ac,s=pc(i,a);if(Math.abs(i)<=ac)return n.pendingNativeMVCPAdjust=void 0,!0;if(o)return n.pendingNativeMVCPAdjust=void 0,!1;if(s+ac>=Math.abs(i))return mc(e,i,a),!0;let c=Math.max(0,vo(e)-n.scrollLength);return Math.abs(t-c)<=cc||n.pendingMaintainScrollAtEnd&&J(e,`isWithinMaintainScrollAtEndThreshold`)&&s>ac?(mc(e,i,a),!0):s>r.furthestProgressTowardAmount+ac?(r.furthestProgressTowardAmount=s,!1):(r.furthestProgressTowardAmount>ac&&s<r.furthestProgressTowardAmount-ac&&(n.pendingNativeMVCPAdjust=void 0),!1)}function _c(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(t&&r.pendingScrollToEnd&&f===void 0){r.mvcpAnchorLock=void 0;return}let p=lc(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,b=t?s:c,x=r.indexByKey,S=r.scroll;if(vo(e),b){if(p&&_===void 0?(h=p.id,m=p.position):_===void 0?i.length>0&&r.didContainersLayout&&!t&&(h=i.find(e=>x.get(e)!==void 0)):h=Es(r,_),t&&i.length>0&&r.didContainersLayout)for(let e=0;e<i.length;e++){let t=i[e],n=x.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=x.get(h);e!==void 0&&(m=a[e])}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=x.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=x.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=x.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=x.get(h),s=t===void 0?void 0:a[t];if(s!==void 0){let t=vo(e),a=s-m;if(a!==0&&y&&r.scroll+r.scrollLength>t){if(a>0)a=Math.max(0,t-r.scroll-r.scrollLength);else{let e=Math.max(0,t-r.scrollLength);r.scroll=e,r.scrollPending=e,a=0}}n=a,i=h,o=s}}if(v&&v>0){let t=Ws(e,h,_,r.props.data[_]),i=f?.itemSize;if(t!==void 0&&i!==void 0&&t!==i){let e=t-i;e!==0&&(n+=e*v,f.itemSize=t)}}if(uc(r,{anchorId:i,anchorPosition:o,dataChanged:t,now:u,positionDiff:n}),dc()){r.pendingNativeMVCPAdjust={amount:n,furthestProgressTowardAmount:0,manualApplied:0,startScroll:S},hc(e);return}Math.abs(n)>ac&&((r.maintainingScrollAtEnd===`pending-animated`||r.maintainingScrollAtEnd===`animated`)&&J(e,`isWithinMaintainScrollAtEndThreshold`)||nc(e,n))}}}var vc=1e3,yc=200,bc=e=>{let{scrollHistory:t}=e,n=t.length-1;if(n<1)return 0;let r=t[n];if(Date.now()-r.time>vc)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>vc)break;if(c===0||l<=0)continue;let d=r.time-n.time,f=Math.exp(-d/yc);a+=c/l*f,o+=f}return o>0?a/o:0};function xc(e){let t=e.mvcpAnchorLock;return t?Date.now()>t.expiresAt?(e.mvcpAnchorLock=void 0,!1):!0:!1}function Sc(e){return e.dataChangeNeedsScrollUpdate||xc(e)}function Cc(e,t,n,r){let i=e.state,{ignoreScrollFromMVCP:a,lastScrollAdjustForHistory:o,scrollAdjustHandler:s,scrollHistory:c,scrollingTo:l}=i,u=i.scroll;r?.markHasScrolled!==!1&&(i.hasScrolled=!0);let d=Date.now();i.lastBatchingAction=d;let f=s.getAdjust(),p=o!==void 0&&Math.abs(f-o)>.1;if(p&&(c.length=0),i.lastScrollAdjustForHistory=f,l===void 0&&(c.length!==0||t!==i.scroll)&&(p||c.push({scroll:t,time:d})),c.length>5&&c.shift(),a&&!l){let{lt:e,gt:n}=a;if(e&&t<e||n&&t>n){i.ignoreScrollFromMVCPIgnored=!0;return}}i.scrollPrev=u,i.scrollPrevTime=i.scrollTime,i.scroll=t,i.scrollTime=d;let m=Math.abs(t-u),h=!!r?.fromNativeScrollEvent&&m>.1&&!p&&l===void 0&&!i.pendingNativeMVCPAdjust,g=h&&t<u&&!!(i.maintainingScrollAtEnd||i.pendingMaintainScrollAtEnd);g&&rc(e);let _=h?$o(e,t-u):void 0,v=gc(e,t),y=i.scrollLength,b=y>0&&l===void 0&&m>y&&!i.pendingNativeMVCPAdjust,x=bc(i);fs(e,x,{forceLight:b});let S=i.scrollLastCalculate;if(Sc(i)||v||g||_!==void 0||n||S===void 0||Math.abs(i.scroll-S)>2){i.scrollLastCalculate=i.scroll,i.ignoreScrollFromMVCPIgnored=!1,i.lastScrollDelta=m;let t=()=>{var t;let n={doMVCP:l!==void 0,scrollVelocity:x};b&&(n.drawDistanceMode=`visible-first`),(t=i.triggerCalculateItemsInView)==null||t.call(i,n),rs(e,_)};b?(i.mvcpAnchorLock=void 0,i.pendingNativeMVCPAdjust=void 0,i.userScrollAnchorReset={keys:new Set},i.scheduledWork.cancel(`mvcpRecalculate`),(0,Aa.flushSync)(t),hs(e)):t();let n=!!i.pendingMaintainScrollAtEnd||!!i.props.maintainScrollAtEnd?.onDataChange;v&&n&&(i.pendingMaintainScrollAtEnd=!1,ic(e)),i.dataChangeNeedsScrollUpdate=!1,i.lastScrollDelta=0}}function wc(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 Tc(e,t){let{isInitialScroll:n,requestedOffset:r,targetOffset:i}=t,a=Uo.get(e),o=!e.didFinishInitialScroll&&(n||!!a)&&Uo.hasNonZeroTargetOffset(i),s=!e.didFinishInitialScroll&&!!a&&Uo.isAtZeroTargetOffset(r);if(o){e.hasScrolled=!1,Uo.set(e,{startScroll:a?.startScroll??e.scroll,targetOffset:i});return}s&&Uo.clear(e)}function Ec(e,t){let n=e.state,r=n.props.data.length,i=0,a=r-1,o;for(;i<=a;){let e=Math.floor((i+a)/2),r=n.positions[e];r===void 0?a=e-1:r<=t?(o=e,i=e+1):a=e-1}return o}function Dc(e,t){let n=e.state.positions[t];if(n===void 0)return;let r=Gs(e,t)??0;return n+(Number.isFinite(r)?r:0)}function Oc(e,t,n){let r=e.state,i=r.props.data.length;if(i===0)return;let a=Math.max(0,t),o=Math.max(a,t+r.scrollLength),s=n===void 0?Ec(e,a):Math.max(0,Math.min(i-1,n));if(s===void 0)return;if(n!==void 0&&r.positions[s]===void 0)return{end:s,start:s};if(n===void 0){let t=Dc(e,s);if(t===void 0||t<=a)return}for(;s>0;){let e=r.positions[s];if(e===void 0||e<=a||r.positions[s-1]===void 0)break;s--}for(;s>0;){let t=Dc(e,s-1);if(t===void 0||t<=a)break;s--}let c=s;for(;c+1<i;){let e=r.positions[c+1];if(e===void 0||e>o)break;c++}return{end:c,start:s}}function kc(e,t,n){let r=Oc(e,t,n);r?(e.state.scrollTargetPinnedRange=r,e.state.scrollForNextCalculateItemsInView=void 0):e.state.scrollTargetPinnedRange=void 0}function Ac(e,t){var n;let r=e.state,{noScrollingTo:i,forceScroll:a,...o}=t,{animated:s,isInitialScroll:c,offset:l,precomputedWithViewOffset:u,waitForInitialScrollCompletionFrame:d}=o,{props:{horizontal:f}}=r;Mo(r);let p=u?l:Ks(e,l,o),m=!!c&&r.initialScrollSession?.kind===`offset`,h=qs(e,p,o),g=m?p:h;if(r.scrollHistory.length=0,!i){c&&Ho.resetFlags(r);let t=wc(r);r.scrollingTo={...o,...t?{averageSizeSnapshot:t}:{},targetOffset:h,waitForInitialScrollCompletionFrame:d},c||kc(e,h,o.index)}r.scrollPending=h,Tc(r,{isInitialScroll:c,requestedOffset:g,targetOffset:h}),!c&&!i&&Math.abs(r.scroll-h)>1&&(s?r.scrollTargetPinnedRange&&((n=r.triggerCalculateItemsInView)==null||n.call(r)):Cc(e,h,!0,{markHasScrolled:!1})),a||!c||Ha.OS===`android`?$s(e,{animated:s,horizontal:f,offset:g}):r.scroll=g}function jc(e,t){return t<=0?-1:e>=t?t-1:e<0?0:e}function Mc(e,{index:t,viewOffset:n=0,animated:r=!0,forceScroll:i,isInitialScroll:a,viewPosition:o}){let s=e.state,{data:c}=s.props;t=jc(t,c.length);let l=Gs(e,t),u=ws(e,t);t===c.length-1&&o===void 0&&(o=1),s.scrollForNextCalculateItemsInView=void 0,Ac(e,{animated:r,forceScroll:i,index:t,isInitialScroll:a,itemSize:l,offset:u,viewOffset:n,viewPosition:o??0})}function Nc(e,t){let{forceScroll:n,resolvedOffset:r,target:i,waitForCompletionFrame:a}=t,o=i.index,s=o===void 0?void 0:jc(o,e.state.props.data.length),c=Gs(e,s);Ac(e,{animated:!1,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,waitForInitialScrollCompletionFrame:a})}function Pc(e,t,n){let{state:r}=e;r.clearPreservedInitialScrollOnNextFinish=void 0,r.scheduledWork.cancel(`preservedInitialScroll`),r.initialScroll=t,n?.resetDidFinish&&gs(e,{resetInitialScroll:!0}),Wo(r,{kind:r.initialScrollSession?.kind===`offset`?`offset`:`bootstrap`})}function Fc(e,t){return e.state.initialScrollSession?.kind===`offset`?t.contentOffset??0:qs(e,Ks(e,t.index===void 0?0:ws(e,t.index),t),t)}function Ic(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 Lc(e,t){let n=e.state,r=Ic(n,{requiresMeasuredLayout:!0});if(!r)return!1;let{initialScroll:i,isInitialScrollInProgress:a,queuedInitialLayout:o}=r,s=a?r.scrollingTo:void 0,c=Fc(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=l!==void 0&&Math.abs(n.scroll-c)<=1&&Math.abs(n.scrollPending-c)<=1;return!t?.forceScroll&&!u&&a&&!d||t?.forceScroll&&f?!1:(u&&n.initialScrollSession?.kind!==`offset`&&Pc(e,{...i,contentOffset:c}),Nc(e,{forceScroll:t?.forceScroll??(!!o||a&&u),resolvedOffset:c,target:i}),!0)}function Rc(e,t){let n=e.state,r=Ic(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 Nc(e,{forceScroll:t?.forceScroll??(c||!!a),resolvedOffset:o,target:i}),!0}function zc(e,t){return e.state.initialScrollSession?.kind===`offset`?Rc(e,{forceScroll:t?.forceScroll}):Lc(e,{forceScroll:t?.forceScroll})}function Bc(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=Es(e,a);if(t===void 0||!e.sizesKnown.has(t))return!1}}return r}var Vc=1,Hc=8,Uc=24,Wc=`LegendList bootstrap initial scroll aborted after exceeding convergence bounds.`;function Gc(e){return e.initialScrollSession?.kind===`bootstrap`?e.initialScrollSession.bootstrap:void 0}function Kc(e){return e.initialScrollSession?.kind===`offset`}function qc(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 Jc(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){l=e;continue}let a=n(e);if(a===void 0){l=e;continue}if(t+a<=r)break;l=e}for(;l<t;l++){let e=i[l];if(e===void 0)continue;let t=n(l);if(t!==void 0){if(e<s&&e+t>r)c.push(l);else if(c.length>0&&e>=s)break}}return c}function Yc(e){let{mountFrameCount:t,maxFrames:n=Hc,maxPasses:r=Uc,passCount:i}=e;return t>=n||i>=r}function Xc(e,t){return Yc(t)?(Do&&console.warn(Wc),Cl(e),!0):!1}function Zc(e){let t=Gc(e),n=t?.frameHandle;n!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(n),t&&(t.frameHandle=void 0),Wo(e,{bootstrap:null,kind:e.initialScrollSession?.kind})}function Qc(e,t){let n=Gc(e);Wo(e,{bootstrap:{frameHandle:n?.frameHandle,mountFrameCount:n?.mountFrameCount??0,passCount:0,previousResolvedOffset:void 0,scroll:t.scroll,seedContentOffset:t.seedContentOffset??n?.seedContentOffset??t.scroll,targetIndexSeed:t.targetIndexSeed,visibleIndices:void 0},kind:`bootstrap`})}function $c(e,t){let n=Gc(e);n?(n.passCount=0,n.previousResolvedOffset=void 0,n.scroll=t?.scroll??n.scroll,n.seedContentOffset=t?.seedContentOffset??n.seedContentOffset,n.targetIndexSeed=t?.targetIndexSeed??n.targetIndexSeed,n.visibleIndices=void 0,Wo(e,{bootstrap:n,kind:`bootstrap`})):t?.scroll!==void 0&&Qc(e,{scroll:t.scroll,seedContentOffset:t.seedContentOffset,targetIndexSeed:t.targetIndexSeed})}function el(e){requestAnimationFrame(()=>{var t;Gc(e)&&((t=e.triggerCalculateItemsInView)==null||t.call(e,{forceFullItemPositions:!0}))})}function tl(e){let t=e.state,n=Gc(t);!n||n.frameHandle!==void 0||(n.frameHandle=requestAnimationFrame(()=>{let n=Gc(t);n&&(n.frameHandle=void 0,n.mountFrameCount+=1,!Xc(e,{mountFrameCount:n.mountFrameCount,passCount:n.passCount})&&tl(e))}))}function nl(e,t){$c(e.state,t),tl(e),el(e.state)}function rl(e){let{dataLength:t,footerSize:n,preserveForFooterLayout:r,stylePaddingEnd:i}=e;return{contentOffset:void 0,index:Math.max(0,t-1),preserveForBottomPadding:!0,preserveForFooterLayout:r,viewOffset:-i-n,viewPosition:1}}function il(e){return!!e?.preserveForBottomPadding}function al(e){return!!e?.preserveForFooterLayout}function ol(e){return!!(e&&e.viewPosition===1&&(il(e)||al(e)))}function sl(e){let{dataLength:t,footerSize:n,initialScrollAtEnd:r,stylePaddingEnd:i,target:a}=e,o=al(a);return{...a,contentOffset:void 0,index:r?Math.max(0,t-1):a.index,preserveForBottomPadding:!0,preserveForFooterLayout:o,viewOffset:-i-(o?n:0),viewPosition:1}}function cl(e,t){return e.index===t.index&&e.preserveForBottomPadding===t.preserveForBottomPadding&&e.preserveForFooterLayout===t.preserveForFooterLayout&&e.viewOffset===t.viewOffset&&e.viewPosition===t.viewPosition}function ll(e,t){let{dataLength:n,stylePaddingEnd:r,target:i}=t;al(i)&&Pc(e,rl({dataLength:n,footerSize:0,preserveForFooterLayout:void 0,stylePaddingEnd:r}))}function ul(e){xs(e)}function dl(e,t,n=Vc){let r=e.state;if(!r.didFinishInitialScroll)return!1;let i=fl(r);return Math.abs(i-Fc(e,t))>n}function fl(e){var t;let n=((t=e.refScroller.current)?.getCurrentScrollOffset)?.call(t);return typeof n==`number`&&Number.isFinite(n)?n:e.scrollPending??e.scroll??0}function pl(e){let t=e.state,n=t.initialScroll;if(!t.didFinishInitialScroll||t.scrollingTo?.isInitialScroll||!n||n.viewPosition!==1||t.props.data.length===0||Kc(t))return;let r=typeof t.lastNativeScroll==`number`&&Number.isFinite(t.lastNativeScroll)?t.lastNativeScroll:fl(t);return Fc(e,n)-r}function ml(e){return pl(e)!==void 0&&(hl(e,{}),!0)}function hl(e,t){let n=e.state;n.preservedEndAnchorCorrection=t,requestAnimationFrame(()=>{let r=n.preservedEndAnchorCorrection;if(r!==t)return;let i=pl(e);if(i===void 0||Math.abs(i)<=Vc){n.preservedEndAnchorCorrection=void 0;return}(!r.lastRequestTime||(n.lastNativeScrollTime??0)>r.lastRequestTime)&&(r.lastRequestTime=Date.now(),nc(e,i)),hl(e,t)})}function gl(e){let t=e.state,n=t.initialScroll;!t.didFinishInitialScroll||t.scrollingTo?.isInitialScroll||n?.viewPosition!==1||t.preservedEndAnchorCorrection||dl(e,n)&&(ol(n)&&J(e,`isAtEnd`)||(al(n)?ll(e,{dataLength:t.props.data.length,stylePaddingEnd:Xa(t.props),target:n}):ul(t)))}function _l(e,t){let{initialScrollAtEnd:n,target:r}=t,i=e.state,a=Fc(e,r),o=a===0&&!n&&(Kc(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?(Zc(i),Cs(e,{resolvedOffset:a})):s?(Zc(i),Cs(e,{preserveTarget:!0,resolvedOffset:a})):(Qc(i,{scroll:a,seedContentOffset:0,targetIndexSeed:r.index}),tl(e))}function vl(e,t){let{dataLength:n,didDataChange:r,initialScrollAtEnd:i,previousDataLength:a,stylePaddingEnd:o}=t,s=e.state,c=s.initialScroll;if(Kc(s)||!c)return;let l=!!(s.didFinishInitialScroll&&a===0&&n>0&&c.index!==void 0),u=Gc(s);if(!i&&r&&n>0&&s.didFinishInitialScroll&&!u&&!l){xs(s);return}let d=n>0&&(i||ol(c));if(!(!r&&!l&&!d)){if(d){let t=i?rl({dataLength:n,footerSize:J(e,`footerSize`)||0,preserveForFooterLayout:al(c),stylePaddingEnd:o}):sl({dataLength:n,footerSize:J(e,`footerSize`)||0,initialScrollAtEnd:i,stylePaddingEnd:o,target:c});if(!l&&dl(e,c)){ll(e,{dataLength:n,stylePaddingEnd:o,target:c});return}if(!cl(c,t)||u||l||r){Pc(e,t,{resetDidFinish:l}),nl(e,{scroll:Fc(e,t),seedContentOffset:l&&!u?fl(s):void 0,targetIndexSeed:t.index});return}}r&&(u||l)&&(Pc(e,c,{resetDidFinish:l}),nl(e,{scroll:Fc(e,c),seedContentOffset:l&&!u?fl(s):void 0,targetIndexSeed:c.index}))}}function yl(e,t){let{dataLength:n,footerSize:r,initialScrollAtEnd:i,stylePaddingEnd:a}=t,o=e.state;if(!i)return;let s=o.initialScroll;if(!(Kc(o)||n===0||!s)&&(Gc(o)||al(s))){if(dl(e,s))ll(e,{dataLength:n,stylePaddingEnd:a,target:s});else{let t=rl({dataLength:n,footerSize:r,preserveForFooterLayout:al(s),stylePaddingEnd:a});s.index===t.index&&s.viewPosition===t.viewPosition&&s.viewOffset===t.viewOffset?ll(e,{dataLength:n,stylePaddingEnd:a,target:s}):(Pc(e,t,{resetDidFinish:!!o.didFinishInitialScroll}),nl(e,{scroll:Fc(e,t),targetIndexSeed:t.index}))}}}function bl(e){let t=e.state,n=t.initialScroll,r=Gc(t);if(n&&t.props.data.length>0&&!Kc(t)&&(r||n.viewPosition===1)){let i=Fc(e,n),a=t.scrollingTo?.isInitialScroll?t.scrollingTo:void 0;if(!r&&(a||t.didFinishInitialScroll)){let r=i-(a?a.targetOffset??a.offset:fl(t));Math.abs(r)>Vc&&(t.didFinishInitialScroll?ml(e):a&&(t.initialScroll={...n,contentOffset:i},Nc(e,{forceScroll:!0,resolvedOffset:i,target:t.initialScroll})))}else nl(e,{scroll:i,targetIndexSeed:n.index})}}function xl(e){let t=e.state,n=Gc(t),r=t.initialScroll;if(!n||!r||Kc(t)||t.scrollingTo?.isInitialScroll||(n.passCount+=1,Xc(e,{mountFrameCount:n.mountFrameCount,passCount:n.passCount})))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=Fc(e,r),a=Bc(t,t.startBuffered,t.endBuffered),o=Math.abs(n.scroll-i)>1,{data:s}=t.props,c=Jc({dataLength:s.length,getSize:n=>{let r=t.idCache[n]??Es(t,n);return t.sizes.get(r)??Ws(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]??Es(t,e);return t.sizesKnown.has(n)}),u=n.previousResolvedOffset,d=n.visibleIndices;if(n.previousResolvedOffset=i,n.visibleIndices=c,o){n.scroll=i,el(t);return}if(!(!a||!l)){if(!(u!==void 0&&Math.abs(u-i)<=Vc&&qc(d,c))){el(t);return}Zc(t),Nc(e,{forceScroll:!0,resolvedOffset:i,target:r,waitForCompletionFrame:Ha.OS===`web`})}}function Sl(e,t){let n=e.state;Zc(n);let r=!n.clearPreservedInitialScrollOnNextFinish&&n.props.data.length>0&&n.initialScroll?.viewPosition===1;Cs(e,{preserveTarget:r,recalculateItems:!0,resolvedOffset:t,schedulePreservedTargetClear:r})}function Cl(e){let t=e.state,n=Gc(t),r=t.initialScroll;n&&r&&!Kc(t)&&t.refScroller.current?(Zc(t),Nc(e,{forceScroll:!0,resolvedOffset:n.scroll,target:r,waitForCompletionFrame:Ha.OS===`web`})):Sl(e,Gc(t)?.scroll??t.scrollPending??t.scroll??0)}function wl(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 Tl(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=wl(e,n,r,a?a(r,n)??``:void 0);return e.containerItemMetadata.set(t,s),s}function El(e,t,n,r){let{getFixedItemSize:i}=e.props,a=Tl(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 Dl(e){for(let t of e.containerItemMetadata.values())t.didResolveFixedItemSize=!1,t.fixedItemSize=void 0}var Ol=20,kl=1,Al=1,jl=16;function Ml(e,t){let n=e.state.scrollingTo;t?.onlyIfAligned&&(!n?.isInitialScroll||n.animated||!Vl(e,n).isAtResolvedTarget)||e.state.scheduledWork.frame(()=>Hl(e),`checkFinishedScrollFrame`)}function Nl(e,t){let{clampedTargetOffset:n,scrollingTo:r}=t;return!r.isInitialScroll||e.hasScrolled||n<=kl}function Pl(e,t){return!!t?.isInitialScroll&&Ho.didDispatchNativeScroll(e)&&!e.hasScrolled}function Fl(e){return Uo.get(e)?.targetOffset}function Il(e){let t=Fl(e);return!e.didFinishInitialScroll&&Uo.hasNonZeroTargetOffset(t)}function Ll(e,t){if(!t.isInitialScroll||t.animated||!e.didContainersLayout||e.initialScrollSession?.kind===`bootstrap`)return!1;let n=t.targetOffset??t.offset;return Uo.hasNonZeroTargetOffset(n)&&Ho.didDispatchNativeScroll(e)&&!e.hasScrolled||Uo.isAtZeroTargetOffset(n)||Math.abs(e.scroll-n)>1||Math.abs(e.scrollPending-n)>1?!1:!!t.waitForInitialScrollCompletionFrame||Il(e)}function Rl(e){let{state:t}=e;return!!t.scrollingTo?.isInitialScroll&&t.props.data.length>0&&vo(e)<=t.scrollLength&&t.scrollPending<=Al}function zl(e,t){return t.index===e.state.props.data.length-1&&t.viewPosition===1}function Bl(e,t){let n=t.index;return qs(e,zl(e,t)&&n!==void 0?Ks(e,ws(e,n),t):t.targetOffset??qs(e,t.offset-(t.viewOffset||0),t),t)}function Vl(e,t){let{state:n}=e,r=n.scrollPending,i=n.scrollAdjustHandler.getAdjust(),a=Bl(e,t),o=qs(e,r,t),s=Math.abs(r-a),c=a+i,l=Math.abs(r-c),u=!t.animated||Ha.OS===`ios`;return{clampedTargetOffset:a,isAtResolvedTarget:Math.abs(r-o)<1&&(s<1||u&&l<1)}}function Hl(e){let t=e.state.scrollingTo;if(!t)return;let{state:n}=e,r=Vl(e,t);r.isAtResolvedTarget&&Nl(n,{clampedTargetOffset:r.clampedTargetOffset,scrollingTo:t})&&Js(e)}function Ul(e,t){var n;(n=e.state.refScroller.current)==null||n.scrollTo({animated:!1,x:e.state.props.horizontal?t:0,y:e.state.props.horizontal?0:t})}function Wl(e){let t=e.state;if(t.scheduledWork.has(`checkFinishedScrollFallback`))return;let n=t.scrollingTo,r=Rl(e),i=Pl(t,n),a=n!==void 0&&Ll(t,n),o=n?.isInitialScroll&&!r&&!a||!t.didContainersLayout,s=r||a?0:i?jl:o?500:100,c=0,l=e=>{t.scheduledWork.timeout(u,e,`checkFinishedScrollFallback`)},u=()=>{let n=t.scrollingTo;if(n){c++;let r=Il(t)&&!t.hasScrolled,a=i?5:r?Ol:5,o=Rl(e),s=Ll(t,n),u=Vl(e,n),d=Ha.OS===`android`,f=t.hasScrolled&&(!n.isInitialScroll||u.isAtResolvedTarget),p=n.isInitialScroll&&!u.isAtResolvedTarget&&c<=a;o||f||s||d||c>a?Js(e):((r||p)&&c<=a&&Ul(e,Fl(t)??n.targetOffset??t.scrollPending),l(i?jl:100))}};l(s)}function Gl(e){let t=e.state,n=t.initialScroll;return t.didFinishInitialScroll?ml(e):!n||t.initialScrollSession?.kind===`offset`||n.viewPosition!==1||t.props.data.length===0?!1:zc(e,{forceScroll:!0})}function Kl(e){if(!e.state.initialScroll)return;let t=()=>zc(e,{forceScroll:!0});t(),e.state.initialScrollSession?.kind!==`offset`&&requestAnimationFrame(t),Ml(e,{onlyIfAligned:!0})}function ql(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;if(l&&(l.contentOffset===void 0||!!l.preserveForFooterLayout!==d&&c.initialScrollSession?.kind!==`offset`)&&Pc(e,{...l,contentOffset:u,preserveForFooterLayout:d}),s&&l&&c.initialScrollSession?.kind!==`offset`){_l(e,{initialScrollAtEnd:o,target:c.initialScroll});return}!n&&!u&&!(l&&r===0&&!(u===0&&!o))&&(l&&!o?Cs(e,{resolvedOffset:u}):_s(e,{didInitialScroll:!0}))}function Jl(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(n>0&&(u.hasHadNonEmptyData=!0),f&&(o?(Pc(e,o),Wo(u,{kind:s,previousDataLength:d})):xs(u)),u.initialScrollSession&&(u.initialScrollSession.previousDataLength=n),Wo(u),l){vl(e,{dataLength:n,didDataChange:r,initialScrollAtEnd:a,previousDataLength: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&&gs(e,{resetInitialScroll:!0}),zc(e))}function Yl(e){e.indexByKey.clear(),e.idCache.length=0,e.positions.length=0,e.columns.length=0,e.columnSpans.length=0}function Xl(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 Zl(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||Y(e,`containerLayoutEpoch`,(J(e,`containerLayoutEpoch`)??0)+1)}function Ql(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]??Es(i,n),p=Tl(i,t,n,d),m=r?.updateLayout??!0,h=!1,g=!1;if(m){let c=s[n];if(c===void 0)return Y(e,`containerPosition${t}`,Oo),{didChangePosition:!1,didRefreshData:!1};let l=Qa(i,(c||0)-(r?.scrollAdjustPending??0),i.sizes.get(f)??Ws(e,f,n,d,void 0,void 0,void 0,p),J(e,`totalSize`)),u=a[n]||1,m=o[n]||1,g=J(e,`containerPosition${t}`),_=J(e,`containerColumn${t}`),v=J(e,`containerSpan${t}`);l>Oo&&l!==g&&(Y(e,`containerPosition${t}`,l),h=!0),u>=0&&u!==_&&Y(e,`containerColumn${t}`,u),m!==v&&Y(e,`containerSpan${t}`,m)}J(e,`containerItemIndex${t}`)!==n&&Y(e,`containerItemIndex${t}`,n);let _=J(e,`containerItemData${t}`),v=()=>{Y(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=J(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 $l(e,t,n){let r=e.state,i=J(e,`numColumns`),a=t;r.columns[t]!==1&&(a=eu(r,i,t));let o=0,s=r.columns[a];if(a>0){let t=a-1;o=(r.positions[t]??0)+tu(e,eu(r,i,t),t,n)}return{column:s,currentRowTop:o,startIndex:a}}function eu(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 tu(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=Ws(e,t,s,a[s],r);n>o&&(o=n)}return o}function nu(e){let t=e.state,{positions:n,props:{data:r}}=t,i=J(e,`numColumns`)??1;if(r.length===0)As(e,null,0);else{let a=r.length-1,o=Es(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=Ws(e,t.idCache[o]??Es(t,o),o,r[o]);n>i&&(i=n)}As(e,null,s+i)}else{let t=Ws(e,o,a,r[a]);t!==void 0&&As(e,null,s+t)}}}}function ru(e){let t=e.state,{props:{snapToIndices:n}}=t,r=t.props.horizontal?vo(e):void 0,i=Array(n.length);for(let e=0;e<n.length;e++){let a=n[e];Es(t,a);let o=t.positions[a];i[e]=$a(t,o,r)}Y(e,`snapToOffsets`,i)}function iu(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=g.length,x=J(e,`numColumns`)??1,S=x>1,C=Do?new Map:void 0,w=J(e,`extraData`),T=_?{span:1}:void 0,E=c.lastScrollDelta,D=o??bc(c),O=!r&&!t&&(i||Math.abs(D)>0||c.scrollLength>0&&E>c.scrollLength),k=a+1e3,A=!n||t||c.scrollAdjustHandler.getAdjust()!==0||(J(e,`scrollAdjustPending`)??0)!==0,j=0,M=1,N=0;if(t&&(d.length=0),S||(u.length&&=0,d.length&&=0),s>0){if(S){let{startIndex:t,currentRowTop:n}=$l(e,s,!0);s=t,j=n}else if(s<b){let t=s-1,n=Es(c,t);j=(p[t]??0)+(h.get(n)??Ws(e,n,t,g[t],!0,A,!1))}}let P=t||f.size===0,F=S&&!!_&&!!T,I=!1,L;for(let n=s;n<b;n++){if(O&&L!==void 0&&n>L){I=!0;break}O&&L===void 0&&!y&&!t&&j>k&&(L=n+(S?x:1)+10);let r=m[n]??Es(c,n),i=1;if(F){T.span=1,_(T,g[n],n,x,w);let e=T.span;e!==void 0&&Number.isFinite(e)&&(i=Math.max(1,Math.min(x,Math.round(e))))}S&&M+i-1>x&&(j+=N,M=1,N=0);let a=h.get(r),o=a===void 0?Ws(e,r,n,g[n],!0,A,!1):a;Do&&P&&(C.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.`),C.set(r,n)),j!==p[n]&&(p[n]=j,l&&po(e,r,j)),P&&f.set(r,n),S?(u[n]=M,d[n]=i,o>N&&(N=o),M+=i,M>x&&(j+=N,M=1,N=0)):j+=o}I||nu(e),v&&ru(e)}function au(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 ou(e){let{viewabilityConfig:t,viewabilityConfigCallbackPairs:n,onViewableItemsChanged:r}=e;return(t||r)&&(n=[...n||[],{onViewableItemsChanged:r,viewabilityConfig:t||{viewAreaCoveragePercentThreshold:0}}]),n}function su(e,t,n,r,i,a,o=i,s=a){let{props:{data:c}}=e;for(let l of n){let n=au(t,l.viewabilityConfig.id);n.start=i,n.end=a,n.startBuffered=o,n.endBuffered=s,l.viewabilityConfig.minimumViewTime?e.scheduledWork.timeout(()=>cu(c,l,e,t,r),l.viewabilityConfig.minimumViewTime):cu(c,l,e,t,r)}}function cu(e,t,n,r,i){let{viewabilityConfig:a,onViewableItemsChanged:o}=t,s=a.id,c=au(r,s),{viewableItems:l,start:u,end:d,startBuffered:f,endBuffered:p}=c,m;for(let[e,t]of r.mapViewabilityAmountValues)uu(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=Bs(r,t.key),l=!1;o!==void 0&&s!==void 0&&(l=du(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=Es(n,t),s=Bs(r,e);if(du(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];fu(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 lu(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 uu(e,t,n,r,i,a,o,s){let{sizes:c,scroll:l}=e,u=(J(t,`stylePaddingTop`)||0)+(J(t,`alignItemsAtEndPadding`)||0)+(J(t,`headerSize`)||0),{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(!lu(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=_?x/a*100:0,w={containerId:r,index:s,isViewable:(b?100:p?C:S)>=m,item:o,key:i,percentOfScroller:C,percentVisible:S,scrollSize:a,size:_,sizeVisible:x};if(!lu(t.mapViewabilityAmountValues.get(r),w)){t.mapViewabilityAmountValues.set(r,w);let e=t.mapViewabilityAmountCallbacks.get(r);e&&e(w)}return w}function du(e,t,n,r,i,a,o,s){let c=t.mapViewabilityAmountValues.get(r);return(!c||c.key!==i||c.index!==s)&&(c=uu(e,t,n,r,i,a,o,s)),c.isViewable}function fu(e,t,n,r){let i=n+t;e.mapViewabilityValues.set(i,r),e.mapViewabilityCallbacks.get(i)?.(r)}var pu=Aa.unstable_batchedUpdates,mu=typeof pu==`function`?pu:e=>e(),hu=32,gu=64,_u=3;function vu(e,t){if(e<=0||t<=0)return 0;let n=Math.ceil(t*_u),r=t+gu;return Math.min(Math.max(e,t),Math.max(t,Math.min(n,r),Math.min(e,hu)))}function yu(e,t){return e<=0||t<=0?0:Math.min(Math.max(e,t),Math.max(t,Math.ceil(t*1.5)))}function bu(e,t,n,r,i,a,o){let s=t.length;if(s===0)return[];let c=J(e,`numContainers`),l=e.state,{containerItemMetadata:u,stickyContainerPool:d}=l,f=l.props.recycleItems&&!!l.props.positionComponentInternal,p=i.length>0?new Set(i):void 0,m=t.map((e,t)=>({isSticky:l.props.stickyHeaderIndicesSet.has(e),itemIndex:e,itemType:a?.(e),order:t})),h=m.filter(e=>!e.isSticky),g=m.filter(e=>e.isSticky),_=[],v=[];for(let t=0;t<c;t++){let i=J(e,`containerItemKey${t}`),a=!!p?.has(t);if(!(i&&o?.has(i)&&l.indexByKey.has(i))){if(d.has(t))(i===void 0||a)&&v.push({containerIndex:t,distance:1/0});else if(i===void 0||a)_.push({containerIndex:t,distance:1/0});else if(!f){let e=l.indexByKey.get(i);if(e!==void 0&&(e<n||e>r)){let i=e<n?n-e:e-r;_.push({containerIndex:t,distance:i})}}}}_.sort(xu);let y=Array(s),b=c,x=!1,S=(e,t)=>{y[e.order]={containerIndex:t,itemIndex:e.itemIndex,itemType:e.itemType},p?.delete(t)&&(x=!0)},C=(e,t,n)=>{for(let r of e){if(y[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);S(r,n.containerIndex)}}},w=(e,t,n)=>{a&&C(e,t,(e,t)=>t!==void 0&&e===t),C(e,t,e=>e===void 0),n&&C(e,t,()=>!0)};w(h,_,!0),w(g,v,!1);for(let e of m){if(y[e.order])continue;let t=b++;e.isSticky&&d.add(t),S(e,t)}if(x&&(i.length=0,p))for(let e of p)i.push(e);if(Do){let t=J(e,`numContainersPooled`)??1/0;b>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:b-c}})}return y}function xu(e,t){return t.distance-e.distance}function Su(e){let t=e.state;t.queuedInitialLayout=!0,ts(e),_s(e,{didLayout:!0}),t.pendingMaintainScrollAtEnd&&ic(e)}var Cu=4,wu=100;function Tu(e,t){if(t<=0)return 0;let n=Math.min(1,Math.abs(e)/Cu);return Math.sign(e)*t*n}function Eu(e){let t=e.state;t.scheduledWork.timeout(()=>{var e;t.scrollHistory.length=0,(e=t.triggerCalculateItemsInView)==null||e.call(t)},wu,`renderRangeProjection`)}function Du(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 Ou(e,t){let n=e.state,r=!1;for(let i of n.stickyContainerPool){let a=J(e,`containerItemKey${i}`);if((a?n.indexByKey.get(a):void 0)===t){r=!0;break}}return r}function ku(e,t,n,r,i,a,o){let s=e.state;Y(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(Ou(e,u))continue;let d=s.idCache[u]??Es(s,u);d&&!s.containerItemKeys.has(d)&&(u<a||u>o)&&!i.has(u)&&(i.add(u),r.push(u))}}function Au(e,t,n,r,i,a,o){let s=e.state;for(let c of s.stickyContainerPool){let l=J(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),Y(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]??Es(s,u);if(t){let i=s.positions[u],a=s.sizes.get(t)??Ws(e,t,u,s.props.data[u]);p=i!==void 0&&n>i+a+r*3}}p&&a.push(c)}}function ju(e,t,n,r,i,a){let o=!1;return e.startNoBuffer===null&&n+r>i&&(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 Mu(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]??Es(e,i);n.push(t)}return n}function Nu(e,t){let n=e.props.onFirstVisibleItemChanged;if(!n||t===null||t<0||t>=e.props.data.length)return;let r=e.idCache[t]??Es(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 Pu(e,t){let n=e.state,{endBuffered:r,idCache:i,positions:a,props:{data:o},sizes:s,startBuffered:c}=n;if(c===null||r===null||c<0||r<c)return null;for(let l=c;l<=r&&l<o.length;l++){let r=i[l]??Es(n,l),c=s.get(r)??Ws(e,r,l,o[l]);if(a[l]+c>t)return l}return null}function Fu(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]??Es(a,t),o=u.get(n)??Ws(e,n,t,l[t]),d=c[t];if(ju(f,t,d,o,r,i))break}Object.assign(a,{endNoBuffer:f.endNoBuffer,firstFullyOnScreenIndex:f.firstFullyOnScreenIndex,idsInView:Mu(a,f),startNoBuffer:f.startNoBuffer}),Nu(a,f.startNoBuffer),f.startNoBuffer!==null&&f.endNoBuffer!==null&&su(a,e,t,n,f.startNoBuffer,f.endNoBuffer,d,o)}function Iu(e,t={}){let n=e.state;mu(()=>{var r,i,a;let{columns:o,containerItemKeys:s,enableScrollForNextCalculateItemsInView:c,idCache:l,indexByKey:u,minIndexSizeChanged:d,positions:f,props:{alwaysRenderIndicesArr:p,alwaysRenderIndicesSet:m,getItemType:h,keyExtractor:g,onStickyHeaderChange:_},scrollForNextCalculateItemsInView:v,scrollLength:y,sizes:b,startBufferedId:x,viewabilityConfigCallbackPairs:S}=n,{data:C}=n.props,w=n.props.stickyHeaderIndicesArr||[],T=n.props.stickyHeaderIndicesSet||new Set,E=ms(e,t.drawDistanceMode),{dataChanged:D,doMVCP:O,forceFullItemPositions:k,mvcpAdjustmentSource:A}=t,j=n.initialScrollSession?.kind===`bootstrap`?n.initialScrollSession.bootstrap:void 0,M=!!j,N=J(e,`numContainers`);if(!C||y===0||!N)return;let P=vo(e),F,I=J(e,`stylePaddingTop`)+J(e,`alignItemsAtEndPadding`)+J(e,`headerSize`),L=J(e,`numColumns`),ee=t.scrollVelocity??bc(n),{initialScroll:R,queuedInitialLayout:z}=n,te=M?j?.scroll??n.scroll:!z&&es(n)&&R?Fc(e,R):n.scroll,ne=0,B=0,V=0,re=0,ie=0,ae=0,oe=te,se=t=>{oe=t,ne=J(e,`scrollAdjustPending`)??0,B=ne-I,V=Math.round(t+0+B),V+y>P&&(V=Math.max(0,P-y))};se(te);let ce=J(e,`activeStickyIndex`),le=()=>{let t=w.length>0?Du(w,V,n):-1,r=t>=0?w[t]:-1,i=ce!==r;return(t>=0||ce>=0)&&Y(e,`activeStickyIndex`,r),{currentStickyIdx:t,finishCalculateItemsInView:_&&w.length>0&&i?()=>{let e=C[r];e!==void 0&&_?.({index:r,item:e})}:void 0}},H=D?void 0:le(),ue=E,de=E;ee>0||ee===0&&V<Math.max(50,E)?(ue=E*.5,de=E*1.5):(ue=E*1.5,de=E*.5);let fe=!D&&!k&&!M&&!es(n)&&!n.scrollingTo&&!n.pendingNativeMVCPAdjust&&J(e,`readyToRender`)?Tu(ee,Math.min(ue,de)):0,pe=()=>{let e=Math.max(0,V),t=Math.max(0,-oe);ie=Math.max(e,V+y+t),re=e-ue+fe,ae=ie+de+fe};if(pe(),fe!==0&&Eu(e),c&&!M&&!D&&!k&&v){let{top:t,bottom:i}=v;if(t===null&&i===null)n.scrollForNextCalculateItemsInView=void 0;else if((t===null||re>t)&&(i===null||ae<i)&&!Sc(n)){S?Fu(e,S,y,V,ie):n.props.onFirstVisibleItemChanged&&Nu(n,Pu(e,V)),(r=H?.finishCalculateItemsInView)==null||r.call(H);return}}let me=O&&!M?_c(e,D):void 0;D&&Yl(n);let he=k||D?0:d??n.startBuffered??0;iu(e,D,{doMVCP:O,forceFullUpdate:!!k||d!==void 0,optimizeForVisibleWindow:!k&&!D&&L>1&&d!==void 0,scrollBottomBuffered:ae,scrollVelocity:ee,startIndex:he}),P=vo(e),d!==void 0&&(n.minIndexSizeChanged=void 0);let ge;if(D&&O&&n.props.maintainVisibleContentPosition.data&&n.didContainersLayout&&n.idsInView.length>0){let e=n.props.maintainVisibleContentPosition.shouldRestorePosition;ge=new Set;for(let t of n.idsInView){let n=u.get(t);n!==void 0&&(e&&!e(C[n],n,C)||ge.add(t))}}let _e=n.scroll,ve=J(e,`scrollAdjustPending`)??0;me?.(),me&&(n.scroll!==_e||(J(e,`scrollAdjustPending`)??0)!==ve)&&(se(n.scroll),pe()),D&&(H=le());let ye=null,be=null,xe=null,U=(M?j?.targetIndexSeed:void 0)??(!D&&x&&u.get(x)||0);for(let t=U;t>=0;t--){let r=l[t]??Es(n,t);if(f[t]+(b.get(r)??Ws(e,r,t,C[t]))>re)U=t;else break}if(L>1)for(;U>0;){let e=o[U];if(e===1||e===void 0)break;--U}let Se=!1,Ce,we,Te=0;for(let t=0;t<N;t++){let n=J(e,`containerItemKey${t}`);if(n!==void 0){let e=u.get(n);Te=Math.max(Te,e)}}let Ee={endNoBuffer:null,firstFullyOnScreenIndex:void 0,startNoBuffer:null},De=C.length;for(let t=Math.max(0,U);t<De&&(!Se||t<=Te);t++){let r=l[t]??Es(n,t),i=b.get(r)??Ws(e,r,t,C[t]),a=f[t];Se||(ju(Ee,t,a,i,V,ie),ye===null&&a+i>re&&(ye=t,be=r,Ce=re<0?null:a),Ee.startNoBuffer!==null&&(a<=ae?(xe=t,we=ae>P?null:a+i):Se=!0))}Object.assign(n,{endBuffered:xe,endNoBuffer:Ee.endNoBuffer,firstFullyOnScreenIndex:Ee.firstFullyOnScreenIndex,idsInView:Mu(n,Ee),startBuffered:ye,startBufferedId:be,startNoBuffer:Ee.startNoBuffer}),c&&Ce!==void 0&&we!==void 0&&(n.scrollForNextCalculateItemsInView=Ls(Ce)&&Ls(we)?void 0:{bottom:we,top:Ce});let Oe=N,ke=[];if(D)for(let t=0;t<Oe;t++){let n=J(e,`containerItemKey${t}`);(!g||n&&u.get(n)===void 0)&&ke.push(t)}let Ae=n.scrollTargetPinnedRange,je=0,Me=-1;Ae&&(je=Math.max(0,Math.min(Ae.start,Ae.end)),Me=Math.min(De-1,Math.max(Ae.start,Ae.end)));let Ne=je<=Me,Pe=e=>m.has(e)||Ne&&e>=je&&e<=Me;if(ye!==null&&xe!==null){let t=[],r=new Set,a=e=>{if(e>=0&&e<De){let i=l[e]??Es(n,e),a=s.get(i);a===void 0?!Ls(i)&&!r.has(e)&&(r.add(e),t.push(e)):n.stickyContainerPool.add(a)}};for(let e=ye;e<=xe;e++){let i=l[e]??Es(n,e);s.has(i)||(r.add(e),t.push(e))}for(let e of p)a(e);if(Ne)for(let e=je;e<=Me;e++)a(e);if(w.length>0?ku(e,w,H?.currentStickyIdx??-1,t,r,ye,xe):ce!==-1&&Y(e,`activeStickyIndex`,-1),t.length>0){let r=bu(e,t,ye,xe,ke,h?e=>{let t=h(C[e],e);return t===void 0?``:String(t)}:void 0,ge);for(let t of r){let r=t.itemIndex,a=t.containerIndex,o=l[r]??Es(n,r),c=J(e,`containerItemKey${a}`);if(c&&c!==o&&s.delete(c),n.containerItemMetadata.set(a,wl(n,r,C[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)||El(n,a,r,C[r]).fixedItemSize!==void 0;Y(e,`containerLayoutReady${a}`,t)}Y(e,`containerItemKey${a}`,o),Y(e,`containerItemIndex${a}`,r),Y(e,`containerItemData${a}`,C[r]),s.set(o,a),(i=n.userScrollAnchorReset)==null||i.keys.add(o);let u=`containerSticky${a}`,d=T.has(r),f=Pe(r);d?(Y(e,u,!0),n.stickyContainerPool.add(a)):(J(e,u)&&Y(e,u,!1),f?n.stickyContainerPool.add(a):n.stickyContainerPool.delete(a)),a>=Oe&&(Oe=a+1)}Oe!==N&&(Y(e,`numContainers`,Oe),Oe>J(e,`numContainersPooled`)&&Y(e,`numContainersPooled`,yu(De,Oe)))}n.userScrollAnchorReset?.keys.size===0&&(n.userScrollAnchorReset=void 0)}n.stickyContainerPool.size>0&&Au(e,w,V,E,H?.currentStickyIdx??-1,ke,Pe);let Fe=ke.length>0?new Set(ke):void 0,Ie=!1;for(let t=0;t<Oe;t++){let r=J(e,`containerItemKey${t}`);if(Fe?.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)&&(Y(e,`containerSticky${t}`,!1),n.stickyContainerPool.delete(t)),Y(e,`containerItemKey${t}`,void 0),Y(e,`containerItemIndex${t}`,void 0),Y(e,`containerItemData${t}`,void 0),Y(e,`containerPosition${t}`,Oo),Y(e,`containerColumn${t}`,-1),Y(e,`containerSpan${t}`,1);else{let n=u.get(r);n!==void 0&&(Ie=Ql(e,t,n,{scrollAdjustPending:ne,updateLayout:!0}).didChangePosition||Ie)}}if(F&&xo&&Zl(e,F),Ie&&Y(e,`lastPositionUpdate`,Date.now()),M){xl(e);return}Nu(n,Ee.startNoBuffer),!z&&!n.didContainersLayout&&(es(n)?Bc(n,n.startBuffered,n.endBuffered):Bc(n,n.startNoBuffer,n.endNoBuffer)||Bc(n,n.startBuffered,n.endBuffered))&&(Su(e),Kl(e)),S&&Ee.startNoBuffer!==null&&Ee.endNoBuffer!==null&&su(e.state,e,S,y,Ee.startNoBuffer,Ee.endNoBuffer,ye??Ee.startNoBuffer,xe??Ee.endNoBuffer),(a=H?.finishCalculateItemsInView)==null||a.call(H)})}function Lu(e){var t,n;let r=e.state,i=r.props.anchoredEndSpace,a=J(e,`anchoredEndSpaceSize`),o=r.anchoredEndSpaceReadyAnchorIndex,s=r.anchoredEndSpaceReadyAnchorKey,c=i?.anchorIndex,l,u=!0,d=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=Es(r,t);let i=0,c=!1;for(let r=t;r<s.length;r++){let a=Hs(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)+Xa(r.props),u=!c,d=c?a||0:Math.max(0,r.scrollLength-i-o)}else t>=0&&(u=!1)}let f=a!==d&&(a!==void 0||i!==void 0),p=(a||0)!==d;return u&&(f||o!==c||s!==l)&&(r.anchoredEndSpaceReadyAnchorIndex=c,r.anchoredEndSpaceReadyAnchorKey=l,f&&(Y(e,`anchoredEndSpaceSize`,d),(t=i?.onSizeChanged)==null||t.call(i,d)),p&&(ks(e),Cc(e,r.scroll,!0,{markHasScrolled:!1})),(n=i?.onReady)==null||n.call(i,{anchorIndex:c,anchorKey:l,size:d})),d}function Ru(e){let t=e.state;t.userScrollAnchorReset===void 0?t.mvcpAnchorLock?t.scheduledWork.has(`mvcpRecalculate`)||t.scheduledWork.frame(()=>Iu(e,{doMVCP:!0,mvcpAdjustmentSource:`item-size`}),`mvcpRecalculate`):(t.scheduledWork.cancel(`mvcpRecalculate`),Iu(e,{doMVCP:!0,mvcpAdjustmentSource:`item-size`})):(Iu(e),t.userScrollAnchorReset?.keys.size===0&&(t.userScrollAnchorReset=void 0))}function zu(e,t,n){if(e.state.needsOtherAxisSize){let r=n?t.height:t.width,i=J(e,`otherAxisSize`);(!i||r>i)&&Y(e,`otherAxisSize`,r)}}var Bu;function Vu(e){let t=Bu===void 0;Bu??=new Map;try{e()}finally{if(t){let e=Bu;Bu=void 0;for(let[t,n]of e)Gu(t,n)}}}function Hu(e,t){e.didChange||=t.didChange,e.didMeasureUserScrollAnchorResetItem||=t.didMeasureUserScrollAnchorResetItem,e.needsRecalculate||=t.needsRecalculate,e.shouldMaintainScrollAtEnd||=t.shouldMaintainScrollAtEnd}function Uu(e,t){let n=e.state;t.needsRecalculate?(n.scrollForNextCalculateItemsInView=void 0,Ru(e)):t.didMeasureUserScrollAnchorResetItem&&n.userScrollAnchorReset?.keys.size===0&&(n.userScrollAnchorReset=void 0),t.didChange&&Lu(e),t.didChange&&t.shouldMaintainScrollAtEnd&&ic(e)}function Wu(e,t){if(Bu){let n=Bu.get(e);n?n.push(t):Bu.set(e,[t])}else Gu(e,[t])}function Gu(e,t){let n=e.state,r={};for(let i of t)if(i.containerId===void 0||J(e,`containerItemKey${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?El(n,i.containerId,t,a):void 0;Hu(r,Ku(e,i.itemKey,i.size,o))}Uu(e,r)}function Ku(e,t,n,r){let i=e.state,a=!!i.userScrollAnchorReset?.keys.delete(t),{didContainersLayout:o,sizesKnown:s,props:{getFixedItemSize:c,getItemType:l,horizontal:u,onItemSizeChanged:d,data:f,maintainScrollAtEnd:p}}=i;if(!f)return{didMeasureUserScrollAnchorResetItem:a};let m=i.indexByKey.get(t);if(c){if(m===void 0)return{didMeasureUserScrollAnchorResetItem:a};let o=i.props.data[m];if(o===void 0)return{didMeasureUserScrollAnchorResetItem:a};if(!r?.didResolveFixedItemSize){let e=r?.itemType??(l?l(o,m)??``:``);r={didResolveFixedItemSize:!0,fixedItemSize:c(o,m,e),itemType:e}}let d=r.fixedItemSize;if(d!==void 0&&d===s.get(t))return zu(e,n,u),{didMeasureUserScrollAnchorResetItem:a}}let h=!o,g=!1,_,v=i.sizesKnown.get(t),y=qu(e,t,n,r),b=Is(u?n.width:n.height);if(y!==0){_=_===void 0?m:Math.min(_,m);let{startBuffered:e,endBuffered:n}=i;h||=m>=e&&m<=n,!h&&i.containerItemKeys.has(t)&&(h=!0),(v===void 0||Math.abs(v-b)>5)&&(g=!0),d?.({index:m,itemData:i.props.data[m],itemKey:t,previous:b-y,size:b})}if(_!==void 0&&(i.minIndexSizeChanged=i.minIndexSizeChanged===void 0?_:Math.min(i.minIndexSizeChanged,_)),zu(e,n,u),o||Bc(i,i.startBuffered,i.endBuffered)){let e=g&&!!p?.onItemLayout;return{didChange:y!==0,didMeasureUserScrollAnchorResetItem:a,needsRecalculate:h,shouldMaintainScrollAtEnd:e}}return{didChange:y!==0,didMeasureUserScrollAnchorResetItem:a}}function qu(e,t,n,r){let{indexByKey:i,sizesKnown:a,averageSizes:o,props:{data:s,horizontal:c,getItemType:l,getFixedItemSize:u}}=e.state;if(!s)return 0;let d=i.get(t),f=s[d],p=r?.itemType,m=r?.fixedItemSize;u&&!r?.didResolveFixedItemSize&&(p=l?l(f,d)??``:``,m=u(f,d,p));let h=Ws(e,t,d,f,void 0,void 0,void 0,r?.didResolveFixedItemSize||p!==void 0||m!==void 0?{didResolveFixedItemSize:r?.didResolveFixedItemSize,fixedItemSize:m,itemType:p}:void 0),g=c?n.width:n.height,_=a.get(t),v=Math.round(g);if(a.set(t,v),m===void 0&&v>0){p??=l?l(f,d)??``:``;let e=o[p];e||=o[p]={avg:0,num:0},e.num===0?(e.avg=v,e.num++):_!==void 0&&_>0?e.avg+=(v-_)/e.num:(e.avg=(e.avg*e.num+v)/(e.num+1),e.num++)}return!h||Math.abs(h-v)>.1?(js(e,t,v),v-h):0}function Ju(e,t=null){let n=[],r=t??e.viewRefs.keys();for(let t of r){let r=e.viewRefs.get(t),i=J(e,`containerItemKey${t}`),a=r?.current;if(i!==void 0&&a){let e=a.getBoundingClientRect();wo(a,e),n.push({containerId:t,itemKey:i,size:{height:e.height,width:e.width}})}}n.length>0&&Gu(e,n)}var Yu=K.forwardRef,Xu=K.memo,Zu=Xu(function({children:e}){let t=oo(),[n]=mo([`containerLayoutEpoch`]);return K.useLayoutEffect(()=>{{let e=Xl(t);e!==void 0&&Ju(t,e)}},[t,n]),e}),Qu=e=>K.isValidElement(e)?e:e?K.createElement(e,null):null,$u={contain:`paint layout style`,...typeof document<`u`&&document.getElementById(`react-native-stylesheet`)?{display:`flex`,flexDirection:`column`}:{}},ed=Xu(function({id:e,horizontal:t,style:n,refView:r,...i}){let[a=Oo]=mo([`containerPosition${e}`]),o=Ns(n)?Object.assign({},...n):n,s=t?{...$u,...o,left:a}:{...$u,...o,top:a},{animatedScrollY:c,onLayout:l,onLayoutChange:u,stickyHeaderConfig:d,...f}=i;return K.createElement(`div`,{ref:r,...f,style:s})}),td=Xu(function({id:e,horizontal:t,style:n,refView:r,animatedScrollY:i,stickyHeaderConfig:a,onLayout:o,onLayoutChange:s,children:c,...l}){let[u=Oo,d,f]=mo([`containerPosition${e}`,`activeStickyIndex`,`containerItemIndex${e}`]),p=K.useMemo(()=>(Ns(n)?Object.assign({},...n):n)??{},[n]),m=K.useMemo(()=>{let e={...$u,...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=K.useMemo(()=>a?.backdropComponent?K.createElement(`div`,{style:{inset:0,pointerEvents:`none`,position:`absolute`}},Qu(a.backdropComponent)):null,[a?.backdropComponent]);return K.createElement(`div`,{ref:r,style:m,...l},h,c)}),nd=ed;function rd(e){(0,K.useState)(()=>e())}var id=(0,K.createContext)(null),ad=-1;function od(){return(0,K.useContext)(id)}function sd(){let e=od(),[t]=mo([`containerItemKey${e?.containerId??ad}`]);return ho(`lastItemKeys`,n=>e&&!Ls(t)&&n?.includes(t)||!1)}function cd({ItemSeparatorComponent:e,leadingItem:t}){return sd()?null:K.createElement(e,{leadingItem:t})}var ld=null;function ud(){return ld||=new ResizeObserver(e=>{Vu(()=>{for(let t of e){let e=dd.get(t.target);if(e)for(let n of e)n(t)}})}),ld}var dd=new WeakMap;function fd(e,t){if(typeof ResizeObserver>`u`||!e)return()=>{};let n=ud(),r=dd.get(e)??new Set;return r.size===0&&(dd.set(e,r),n.observe(e,{box:`border-box`})),r.add(t),()=>{r.delete(t),r.size===0&&(dd.delete(e),n.unobserve(e))}}function pd({ref:e,measureInLayoutEffect:t=!0,onLayoutProp:n,onLayoutChange:r,webLayoutResync:i},a){return(0,K.useLayoutEffect)(()=>{let a=e.current,o=((a?.getScrollableNode)?.call(a)??null)||a;if(!o)return;let s=(e,t)=>{(e.height!==0||e.width!==0)&&(r(e,t),n?.({nativeEvent:{layout:e}}))},c;if(t){let e=o.getBoundingClientRect();s(md(e),!0),c=e}return fd(o,e=>{let t=e.target instanceof HTMLElement?e.target:void 0,n=Array.isArray(e.borderBoxSize)?e.borderBoxSize[0]:e.borderBoxSize,r=n?{height:n.blockSize,left:e.contentRect.left,top:e.contentRect.top,width:n.inlineSize}:t?.getBoundingClientRect()??e.contentRect,a=c??Co(o),l=a===void 0||r.width!==a.width||r.height!==a.height;c=r;let u=!!i?.();(l||u)&&s(md(r),!1)})},[t,...a||[]]),{}}function md(e){return e?{height:e.height,width:e.width,x:e.left,y:e.top}:{height:0,width:0,x:0,y:0}}var hd=new Map,gd;function _d(e){hd.delete(e)}function vd(e,t){hd.set(e,t),gd===void 0&&(gd=requestAnimationFrame(()=>{let e=Array.from(hd.values());hd.clear(),gd=void 0,Vu(()=>{for(let t of e)t()})}))}function yd({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=Is(n[c]);i.lastSize&&Is(i.lastSize[c]);let u=a.sizesKnown.get(o),d=()=>{i.lastSize=s,Wu(t,{containerId:e,itemKey:o,size:s})};!Sc(a)&&u!==void 0&&l+1<u?vd(i,()=>{if(i.itemKey===o){let e=r.current,t=(e?.getBoundingClientRect)?.call(e);t&&(s={height:t.height,width:t.width}),d()}}):(_d(i),d())}function bd({containerId:e,ctx:t,horizontal:n,itemKey:r,ref:i}){let a=(0,K.useRef)({didLayout:!1,horizontal:n,itemKey:r});a.current.horizontal=n,a.current.itemKey=r;let[o,s]=(0,K.useState)(0),c=(0,K.useCallback)(n=>{yd({containerId:e,ctx:t,rectangle:n,ref:i,state:a.current})},[e,t,i]),l=(0,K.useCallback)(()=>{Zl(t,e)},[e,t]);(0,K.useLayoutEffect)(()=>(t.containerLayoutTriggers.set(e,l),()=>{_d(a.current),t.containerLayoutTriggers.get(e)===l&&t.containerLayoutTriggers.delete(e)}),[e,t,l]),(0,K.useLayoutEffect)(()=>{Zl(t,e)});let{onLayout:u}=pd({measureInLayoutEffect:!xo,onLayoutChange:c,ref:i,webLayoutResync:()=>Sc(t.state)},[r,o]);return(0,K.useEffect)(()=>{},[e,t,r]),{onLayout:u,triggerLayout:l}}function xd({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&&Ha.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 Sd=Xu(function({id:e,itemKey:t,recycleItems:n,horizontal:r,getRenderedItem:i,ItemSeparatorComponent:a,stickyHeaderConfig:o}){let s=oo(),{columnWrapperStyle:c,animatedScrollY:l}=s,u=Ja(s.state),d=s.state.props.positionComponentInternal,f=s.state.props.stickyPositionComponentInternal,[p=0,m=1,h,g=1,_,v]=mo([`containerColumn${e}`,`containerSpan${e}`,`containerItemData${e}`,`numColumns`,`extraData`,`containerSticky${e}`]),y=(0,K.useRef)(null),{onLayout:b,triggerLayout:x}=bd({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,K.useMemo)(()=>xd({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,K.useMemo)(()=>t===void 0?null:i(t,e),[t,h,_]),{renderedItem:O}=D||{},k=(0,K.useMemo)(()=>(s.viewRefs.set(e,y),{containerId:e,triggerLayout:x}),[e,x]),A=v?f||td:d||nd;return K.createElement(A,{animatedScrollY:v?l:void 0,horizontal:r,id:e,key:n?void 0:t,onLayout:b,refView:y,stickyHeaderConfig:o,style:E},K.createElement(id.Provider,{value:k},O,D&&a&&K.createElement(cd,{ItemSeparatorComponent:a,leadingItem:D.item})))});function Cd({id:e,horizontal:t,recycleItems:n,ItemSeparatorComponent:r,getRenderedItem:i,stickyHeaderConfig:a,ContainerComponent:o=Sd}){let[s]=mo([`containerItemKey${e}`]);return s===void 0?null:K.createElement(o,{getRenderedItem:i,horizontal:t,ItemSeparatorComponent:r,id:e,itemKey:s,recycleItems:n,stickyHeaderConfig:a})}var wd=Xu(function(e){return K.createElement(Cd,{...e})});function Td(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=Ed(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}}a?e.insertBefore(i,a):e.appendChild(i)}}}function Ed(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 Dd(e){let t=oo(),n=(0,K.useRef)(void 0);(0,K.useEffect)(()=>{let r=uo(t,`lastPositionUpdate`,()=>{n.current!==void 0&&clearTimeout(n.current),n.current=setTimeout(()=>{let r=e.current;if(r){let e=new Map;for(let[n,r]of t.viewRefs){let i=r.current,a=J(t,`containerItemIndex${n}`);i&&a!==void 0&&e.set(i,a)}Td(r,e)}n.current=void 0},500)});return()=>{r(),n.current!==void 0&&clearTimeout(n.current)}},[t])}function Od(e,t){let[n,r]=(0,K.useState)(t),i=n!==t;return(0,K.useLayoutEffect)(()=>{r(t)},[t]),e&&!i}var kd=Xu(function({freshDataTransitionEpoch:e,horizontal:t,numColumns:n,children:r}){let i=(0,K.useRef)(null),a=oo(),o=a.columnWrapperStyle,s=Ja(a.state),[c,l,u]=mo([`otherAxisSize`,`readyToRender`,`totalSize`]),d=Od(!!l,e);Dd(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(d||(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 K.createElement(`div`,{ref:i,style:f},K.createElement(Zu,null,r))}),Ad=Xu(function({freshDataTransitionEpoch:e,horizontal:t,recycleItems:n,ItemSeparatorComponent:r,getRenderedItem:i,stickyHeaderConfig:a}){let[o,s]=mo([`numContainersPooled`,`numColumns`]),c=[];for(let e=0;e<o;e++)c.push(K.createElement(wd,{getRenderedItem:i,horizontal:t,ItemSeparatorComponent:r,id:e,key:e,recycleItems:n,stickyHeaderConfig:a}));return K.createElement(kd,{freshDataTransitionEpoch:e,horizontal:t,numColumns:s},c)});function jd(e){return Ns(e)?Object.assign({},...e.filter(Boolean)):e}var Md={create:e=>e,flatten:e=>jd(e)};function Nd(e){let t=K.useRef(e);return t.current=e,t}function Pd(e){let t=Nd(e),n=(0,K.useRef)(void 0),r=(0,K.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,K.useEffect)(()=>()=>{r.cancel()},[r]),r}var Fd=`legend-list-content-container`,Id=`legend-list-scrollbar-x-hidden`,Ld=`legend-list-scrollbar-y-hidden`;function Rd(){return typeof document>`u`?null:document.scrollingElement||document.documentElement||document.body}function zd(){return typeof window>`u`?{x:0,y:0}:{x:window.scrollX??window.pageXOffset??0,y:window.scrollY??window.pageYOffset??0}}function Bd(e,t){let n=e?.getBoundingClientRect();return{left:(n?.left??0)+t.x,top:(n?.top??0)+t.y}}function Vd(e){return{height:e?.scrollHeight??0,width:e?.scrollWidth??0}}function Hd(e,t,n){return Vd(n?t:e)}function Ud(e,t,n){if(t&&typeof window<`u`){let t=e?.getBoundingClientRect();return{height:n?t?.height??e?.clientHeight??window.innerHeight:window.innerHeight,width:n?window.innerWidth:t?.width??e?.clientWidth??window.innerWidth}}return{height:e?.clientHeight??0,width:e?.clientWidth??0}}function Wd(e,t){return Math.max(0,Math.min(e,t))}function Gd(e,t){return t?e.width:e.height}function Kd(e,t,n){return Math.max(0,Gd(e,n)-Gd(t,n))}function qd(e,t){return t&&Rd()||e}function Jd(e,t){return t&&typeof window<`u`?window:e}function Yd(e,t,n){let r=e.getBoundingClientRect(),i=zd();return{height:t&&typeof window<`u`&&!n?window.innerHeight:r.height,width:t&&typeof window<`u`&&n?window.innerWidth:r.width,x:t?r.left+i.x:r.left,y:t?r.top+i.y:r.top}}function Xd({clampedOffset:e,horizontal:t,listPos:n,scroll:r}){return{left:t?n.left+e:r.x,top:t?r.y:n.top+e}}var Zd=`legend-list-scrollbar-axis-hidden-style`,Qd=200,$d=`.${Ld}::-webkit-scrollbar:vertical{width:0;display:none;}.${Id}::-webkit-scrollbar:horizontal{height:0;display:none;}`;function ef(){if(typeof document>`u`||document.getElementById(Zd))return;let e=document.createElement(`style`);e.id=Zd,e.textContent=$d,document.head.appendChild(e)}function tf(e){let t=e.state?.props?.contentInsetEndAdjustment;return Math.max(0,t??0)}function nf(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 rf(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 af=(0,K.forwardRef)(function({children:e,style:t,contentContainerClassName:n,contentContainerStyle:r,horizontal:i=!1,contentOffset:a,maintainVisibleContentPosition:o,onScroll:s,onInternalScrollEnd:c,onMomentumScrollEnd:l,showsHorizontalScrollIndicator:u=!0,showsVerticalScrollIndicator:d=!0,refreshControl:f,useWindowScroll:p=!1,onLayout:m,...h},g){let _=oo(),[v]=mo([`anchoredEndSpaceSize`]),y=(0,K.useRef)(null),b=(0,K.useRef)(null),x=p,S=(0,K.useCallback)(()=>Jd(y.current,x),[x]),C=(0,K.useCallback)(()=>{let e=y.current;return Kd(Hd(e,b.current,x),Ud(e,x,i),i)},[i,x]),w=(0,K.useCallback)(()=>{let e=y.current;if(x){let t=C(),n=zd(),r=Bd(e,n);return Wd(i?n.x-r.left:n.y-r.top,t)}return e?i?e.scrollLeft:e.scrollTop:0},[C,i,x]),T=(0,K.useCallback)((e,t)=>{let n=y.current,r=S();if(!r||typeof r.scrollTo!=`function`)return;let a=Wd(e,C()),o={behavior:t?`smooth`:`auto`};if(x){let e=zd(),{left:t,top:r}=Xd({clampedOffset:a,horizontal:i,listPos:Bd(n,e),scroll:e});o.left=t,o.top=r}else i?o.left=a:o.top=a;r.scrollTo(o)},[C,S,i,x]);(0,K.useImperativeHandle)(g,()=>({getBoundingClientRect:()=>y.current?.getBoundingClientRect(),getCurrentScrollOffset:w,getScrollableNode:()=>qd(y.current,x),getScrollEventTarget:()=>S(),getScrollResponder:()=>qd(y.current,x),isWindowScroll:()=>x,scrollBy:(e,t)=>{let n=S();!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;T(i?t:n,r)},scrollToEnd:(e={})=>{let{animated:t=!0}=e,n=C();T(n,t)},scrollToOffset:e=>{let{offset:t,animated:n=!0}=e;T(t,n)}}),[w,C,S,i,x,T]);let E=Pd((0,K.useCallback)(()=>{if(!s||!y.current)return;let e=Vd(b.current),t=Ud(y.current,x,i),n=w();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}}})},[w,i,x,s])),D=(0,K.useRef)(void 0),O=(0,K.useCallback)(()=>{let e=D.current;e!==void 0&&(clearTimeout(e),D.current=void 0),E.flush(),c?.()},[c,E]),k=(0,K.useCallback)(e=>{if(!s)return;let t=_.state;if(t?.scrollingTo||t?.initialScrollSession&&!t.didFinishInitialScroll||t?.initialScroll&&!t.didFinishInitialScroll||t&&Sc(t)?E.flush():E.schedule(),c){let e=D.current;e!==void 0&&clearTimeout(e),D.current=setTimeout(O,Qd)}},[_.state,O,c,s,E]);(0,K.useLayoutEffect)(()=>{let e=S();if(e)return e.addEventListener(`scroll`,k,{passive:!0}),`onscrollend`in e&&e.addEventListener(`scrollend`,O),()=>{e.removeEventListener(`scroll`,k),`onscrollend`in e&&e.removeEventListener(`scrollend`,O);let t=D.current;t!==void 0&&(clearTimeout(t),D.current=void 0),E.cancel()}},[O,S,k,E]),(0,K.useEffect)(()=>{let e=()=>{a&&T(i?a.x||0:a.y||0,!1)};e(),requestAnimationFrame(e)},[a?.x,a?.y,i,T]),(0,K.useLayoutEffect)(()=>{if(!m||!y.current)return;let e=y.current,t=()=>{m({nativeEvent:{layout:Yd(e,x,i)}})};t();let n=new ResizeObserver(()=>{t()});n.observe(e);let r=()=>{t()};return x&&typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`resize`,r),()=>{n.disconnect(),x&&typeof window<`u`&&typeof window.removeEventListener==`function`&&window.removeEventListener(`resize`,r)}},[x,m]);let A=!x&&(i?!u&&Id:!d&&Ld);(0,K.useLayoutEffect)(()=>{A&&ef()},[A]);let j={...x?{}:{overflow:`auto`,overflowX:i||u?`auto`:`hidden`,overflowY:i?d?`auto`:`hidden`:`auto`,WebkitOverflowScrolling:`touch`},...Md.flatten(t),...o?{overflowAnchor:`none`}:{}},M=tf(_),N=_.state?.props?.anchoredEndSpace&&v?v:0,P=Math.max(0,M-N),F=P?i?{flexShrink:0,width:P}:{height:P}:void 0,I={display:i?`flex`:`block`,flexDirection:i?`row`:void 0,minHeight:i?void 0:`100%`,minWidth:i?`100%`:void 0,...Md.flatten(r),...o?{overflowAnchor:`none`}:{}},L=n?`${Fd} ${n}`:Fd,{contentContainerClassName:ee,contentInset:R,scrollEventThrottle:z,ScrollComponent:te,snapToOffsets:ne,useWindowScroll:B,className:V,...re}=h,ie=x?[]:nf(ne);ie.length>0&&(j.scrollSnapType=i?`x mandatory`:`y mandatory`,I.position=I.position??`relative`);let ae=A?V?`${V} ${A}`:A:V;return Do&&/(?:^|\s)(?:[a-z0-9_-]+:)*gap(?:-[xy])?-(?:\[[^\]]+\]|[^\s]+)/.test(`${n??``} ${V??``}`)&&Fs(`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.`),K.createElement(`div`,{className:ae,ref:y,...re,style:j},f,K.createElement(`div`,{className:L,ref:b,style:I},ie.map(e=>K.createElement(`div`,{"aria-hidden":!0,"data-legend-list-snap-anchor":e,key:`snap-${e}`,style:rf(e,i)})),e,F?K.createElement(`div`,{"aria-hidden":!0,style:F}):null))});function of({horizontal:e,needsOtherAxisSize:t,otherAxisSize:n}){if(!(!t||!n||n<=0))return e?{height:n}:{width:n}}function sf(e,t){let n=oo();(0,K.useLayoutEffect)(()=>uo(n,e,e=>{t(e)}),[t,n,e])}function cf(e){return e?{contentSizeKey:`scrollWidth`,paddingEndProp:`paddingRight`,viewportSizeKey:`clientWidth`,x:1,y:0}:{contentSizeKey:`scrollHeight`,paddingEndProp:`paddingBottom`,viewportSizeKey:`clientHeight`,x:0,y:1}}function lf(e,t){let n=e.state?.refScroller.current,r=(n?.getScrollableNode)?.call(n)??null,i=null;return r&&(i=t?.isConnected&&t.parentElement===r?t:r.querySelector(`:scope > .${Fd}`)),r?{contentNode:i,scrollElement:r}:null}function uf(e,t,n){e.scrollBy({behavior:`auto`,left:t,top:n})}function df(){let e=oo(),t=K.useRef(0),n=K.useRef(0),r=K.useRef(void 0),i=K.useRef(void 0),a=K.useRef(null),o=K.useCallback(()=>{let o=J(e,`scrollAdjust`),s=J(e,`scrollAdjustUserOffset`),c=(o||0)+(s||0);if(c-t.current!==0){let o=lf(e,a.current);if(o){let t=!!e.state.props.horizontal,c=cf(t),{contentNode:l,scrollElement:u}=o,d=t?u.scrollLeft:u.scrollTop,f=(s||0)-n.current,p=(f===0?e.state.scroll:d+f)-d,m=Math.abs(p)>.01,h=()=>uf(u,c.x*p,c.y*p);if(a.current=l,m&&l){let t=l[c.contentSizeKey],n=u[c.viewportSizeKey],a=d+p;if(p>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`;i.current={baseline:s,value:d},l.style[c.paddingEndProp]=d,l.offsetHeight,h(),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 h()}else m&&h()}t.current=c,n.current=s||0}},[e]);return sf(`scrollAdjust`,o),sf(`scrollAdjustUserOffset`,o),null}var ff=K.forwardRef(function({ScrollComponent:e,...t},n){let[r]=mo([`snapToOffsets`]);return K.createElement(e,{...t,ref:n,snapToOffsets:r})}),pf=.1;function mf(e,t,n){let r=J(e,t)!==n;return r&&(Y(e,t,n),ks(e)),r}function hf(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-pf&&Math.abs(c)>pf}function gf(e,t){let{state:n}=e,r=J(e,`headerSize`)||0,i=r!==t,a=n.didMeasureHeader||r>pf;i&&(Y(e,`headerSize`,t),ks(e),a&&hf(e,r,t)&&nc(e,t-r)),n.didMeasureHeader=!0}function _f(e,t){let n=mf(e,`footerSize`,t);return n&&Lu(e),n}function vf(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 yf(e,t){let{state:n}=e,r=n.contentInsetOverride,i=t??void 0,a=!vf(r,i);return n.contentInsetOverride=i,a&&ks(e),a}function bf(e,t){let n=Nd(e),r=Nd(t);return K.useMemo(()=>K.forwardRef((e,t)=>n.current?.call(n,r.current(e,t))??null),[r,n])}var xf=({onLayoutChange:e,refView:t,children:n,...r})=>{let i=(0,K.useRef)(null),a=t??i;return pd({onLayoutChange:e,ref:a}),K.createElement(`div`,{...r,ref:a},n)},Sf=Xu(function({horizontal:e}){let[t=0]=mo([`alignItemsAtEndPadding`]);return t<=0?null:K.createElement(Ba,{style:e?{flexShrink:0,width:t}:{flexShrink:0,height:t}},null)}),Cf=Xu(function({canRender:e,freshDataTransitionEpoch:t,style:n,contentContainerStyle:r,horizontal:i,initialContentOffset:a,recycleItems:o,ItemSeparatorComponent:s,alignItemsAtEnd:c,onScroll:l,onLayout:u,ListHeaderComponent:d,ListHeaderComponentStyle:f,ListFooterComponent:p,ListFooterComponentStyle:m,ListEmptyComponent:h,getRenderedItem:g,refScrollView:_,renderScrollComponent:v,onLayoutFooter:y,onInternalScrollBeginDrag:b,onInternalScrollEnd:x,scrollAdjustHandler:S,snapToIndices:C,stickyHeaderConfig:w,stickyHeaderIndices:T,useWindowScroll:E=!1,...D}){let O=oo(),k=O.state.props.maintainVisibleContentPosition,[A=0,j=0]=mo([`anchoredEndSpaceSize`,`otherAxisSize`]),M=O.state.props.alignItemsAtEndPaddingEnabled,N=!!O.state.props.anchoredEndSpace&&O.state.props.anchoredEndSpaceOwner===`list`&&A>0,P;if(N){let e=i?Ja(O.state)?`Left`:`Right`:`Bottom`,t=Md.flatten(r);P={[`padding${e}`]:zs({},t||{},e)+A}}let F=of({horizontal:i,needsOtherAxisSize:O.state.needsOtherAxisSize,otherAxisSize:j}),I=bf(v,(e,t)=>({...e,ref:t})),L=v?I:af,ee=C?ff:L,R=(0,K.useCallback)((e,t)=>{let n=_f(O,e);t?.(),n&&O.state.props.maintainScrollAtEnd?.onFooterLayout&&ic(O)},[O]);(0,K.useLayoutEffect)(()=>{d||gf(O,0),p||R(0)},[d,p,O,R]);let z=(0,K.useCallback)(e=>{let t=e[i?`width`:`height`];gf(O,t)},[O,i]),te=(0,K.useCallback)((e,t)=>{let n=e[i?`width`:`height`];R(n,()=>{y?.(e,t)})},[i,y,R]);return K.createElement(ee,{...D,...L===af?{onInternalScrollEnd:x,useWindowScroll:E}:{},contentContainerStyle:[i?{height:`100%`}:{},r,P,{boxSizing:`border-box`}],contentOffset:a===void 0?void 0:i?{x:a,y:0}:{x:0,y:a},horizontal:i,maintainVisibleContentPosition:k.size||k.data?{minIndexForVisible:0}:void 0,onLayout:u,onScroll:l,ref:_,ScrollComponent:C?L:void 0,style:F?[F,n]:n},K.createElement(df,null),d&&K.createElement(xf,{onLayoutChange:z,style:f},Qu(d)),h&&Qu(h),M&&K.createElement(Sf,{horizontal:i}),e&&!h&&K.createElement(Ad,{freshDataTransitionEpoch:t,getRenderedItem:g,horizontal:i,ItemSeparatorComponent:s,recycleItems:o,stickyHeaderConfig:w}),p&&K.createElement(xf,{onLayoutChange:te,style:m},Qu(p)),Do&&Ao)}),wf=100,Tf=.9,Ef=.9;function Df(e){let t=oo(),{anchoredEndSpace:n,childrenMode:r,keyExtractor:i,numColumns:a,renderScrollComponent:o,useWindowScroll:s}=e,c=!!n;(0,K.useEffect)(()=>{c&&(a??1)>1&&Fs(`anchoredEndSpaceNumColumns`,`anchoredEndSpace is only supported when numColumns is 1. Using it with multiple columns may produce incorrect anchored spacing.`)},[c,a]),(0,K.useEffect)(()=>{s&&o&&Fs(`useWindowScrollRenderScrollComponent`,`useWindowScroll is not supported when renderScrollComponent is provided.`)},[o,s]),(0,K.useEffect)(()=>{!i&&!t.state.isFirst&&t.state.didDataChange&&!r&&Fs(`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,K.useEffect)(()=>{let e=t.state,n=e.props.data.length;if(e.props.useWindowScroll||n<wf)return;let r=()=>{let e=J(t,`readyToRender`),r=J(t,`numContainers`)||0,i=J(t,`totalSize`)||0,a=t.state.scrollLength||0;if(!e||i<=0||a<=0)return;let o=r>=Math.ceil(n*Tf),s=a>=i*Ef;o&&s&&Fs(`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=[uo(t,`numContainers`,r),uo(t,`readyToRender`,r),uo(t,`totalSize`,r)];return()=>{for(let e of i)e()}},[t])}function Of(e){}var kf=Do?Df:Of;function Af(e,t,{didColumnsChange:n=!1}={}){let r=e.state,{previousData:i}=r,{maintainScrollAtEnd:a}=r.props;if(n){r.sizes.clear(),r.sizesKnown.clear(),Dl(r);for(let e in r.averageSizes)delete r.averageSizes[e];r.minIndexSizeChanged=0,r.scrollForNextCalculateItemsInView=void 0}Iu(e,{dataChanged:!0,doMVCP:!0});let o=!n&&a?.onDataChange&&ic(e);!o&&i&&t.length>i.length&&(r.isEndReached=!1),o||rs(e),delete r.previousData}function jf(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 Mf=`containerLayoutReady`;function Nf(e){for(let t of e.values.keys())t.startsWith(Mf)&&Y(e,t,void 0)}function Pf(e){let t=e.state,{scrollLength:n,props:{data:r,getFixedItemSize:i,getItemType:a,numColumns:o,estimatedItemSize:s}}=t,c=ms(e),l=J(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++)Y(e,`containerPosition${t}`,Oo),Y(e,`containerColumn${t}`,-1),Y(e,`containerSpan${t}`,1);return Y(e,`numContainers`,u),Y(e,`numContainersPooled`,vu(r.length,u)),t.lastLayout&&(t.initialScroll?requestAnimationFrame(()=>{Iu(e,{dataChanged:!0,doMVCP:!0})}):Iu(e,{dataChanged:!0,doMVCP:!0})),!0}}function Ff(){return typeof window>`u`?{height:0,width:0}:{height:window.innerHeight,width:window.innerWidth}}function If(e,t,n){let r=e.state,{maintainScrollAtEnd:i,useWindowScroll:a}=r.props,o=r.props.horizontal?`width`:`height`,s=r.props.horizontal?`height`:`width`,c=t;if(a){let e=Ff()[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;h&&(r.scrollLength=d,r.otherAxisSize=f,ks(e),r.lastBatchingAction=Date.now(),r.scrollForNextCalculateItemsInView=void 0,d>0&&Pf(e),p&&Iu(e,{doMVCP:!0}),(h||f!==m)&&Y(e,`scrollSize`,{height:c.height,width:c.width}),i?.onLayout&&ic(e),rs(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),Do&&l===0&&Fs(`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 Lf(e,t){let n=Uo.get(e);if(n&&Uo.didReachTarget(t,n)){Uo.clear(e);return}n&&(e.hasScrolled=!1,Uo.set(e,{startScroll:n.startScroll,targetOffset:n.targetOffset}))}function Rf(e){return!!e.initialScroll&&e.initialScrollSession?.kind===`bootstrap`&&!e.didFinishInitialScroll}function zf(e){return{...e,nativeEvent:{...e.nativeEvent}}}function Bf(e,t){let n=e.state,{scrollProcessingEnabled:r}=n;if(r===!1||t.nativeEvent?.contentSize?.height===0&&t.nativeEvent.contentSize?.width===0)return;let i=!1;if(t.nativeEvent?.contentInset){let{contentInset:e}=t.nativeEvent,r=n.nativeContentInset;(!r||r.top!==e.top||r.bottom!==e.bottom||r.left!==e.left||r.right!==e.right)&&(n.nativeContentInset=e,i=!0)}let a=t.nativeEvent.contentOffset[n.props.horizontal?`x`:`y`];if(n.props.horizontal&&(a=eo(n,a,t.nativeEvent.contentSize?.width)),n.didFinishInitialScroll&&n.initialScroll?.viewPosition===1&&(n.scroll,n.scrollLength),n.lastNativeScroll=a,n.lastNativeScrollTime=Date.now(),n.scrollingTo&&n.scrollingTo.offset>=a){let t=qs(e,a,n.scrollingTo);if(a!==t&&Math.abs(a-t)>1){a=t,Ac(e,{forceScroll:!0,isInitialScroll:!0,noScrollingTo:!0,offset:a});return}}n.scrollPending=a,Cc(e,a,i,{fromNativeScrollEvent:!0}),Lf(n,a),gl(e),n.scrollingTo&&Ml(e),n.props.onScroll&&(Rf(n)?n.deferredPublicOnScrollEvent=zf(t):n.props.onScroll(t))}var Vf=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()}},Hf=class{constructor(e){this.appliedAdjust=0,this.pendingAdjust=0,this.ctx=e}requestAdjust(e){let t=this.ctx.state.scrollingTo;t?.animated&&!t.isInitialScroll?(this.pendingAdjust+=e,Y(this.ctx,`scrollAdjustPending`,this.pendingAdjust)):(this.appliedAdjust+=e,Y(this.ctx,`scrollAdjust`,this.appliedAdjust)),this.ctx.state.scrollingTo&&Ml(this.ctx)}getAdjust(){return this.appliedAdjust}commitPendingAdjust(e){{let t=this.ctx.state,n=this.pendingAdjust;if(this.pendingAdjust=0,n!==0){let r;if(e?.index!==void 0){let t=ws(this.ctx,e.index);r=Ks(this.ctx,t,e),r=qs(this.ctx,r,e)}else r=qs(this.ctx,t.scroll+n);let i=r-t.scroll;(Math.abs(i)>.1||Math.abs(n)>.1)&&(this.appliedAdjust+=i,t.scroll=r,t.scrollForNextCalculateItemsInView=void 0,Y(this.ctx,`scrollAdjust`,this.appliedAdjust)),Y(this.ctx,`scrollAdjustPending`,0),Iu(this.ctx)}}}};function Uf(e,t){let n=e.state,r=n.props.data.length-1;if(r===-1)return!1;let i=n.props.stylePaddingBottom||0,a=J(e,`footerSize`)||0;return Mc(e,{...t,index:r,viewOffset:-i-a+(t?.viewOffset||0),viewPosition:1}),!0}function Wf(e,t){let n=e.state,r=_o(e,t),i=_o(e)-r;if(i!==0){let t=!!J(e,`isWithinMaintainScrollAtEndThreshold`);Cc(e,n.scroll,!0,{markHasScrolled:!1}),!Gl(e)&&t&&i>0&&nc(e,i)}}function Gf(e){return(0,K.useMemo)(()=>e?(t,n,r)=>t!==void 0&&n!==void 0?e(t,n,r):void 0:void 0,[e])}var Kf=(...e)=>(0,K.useCallback)(t=>{for(let n of e)n&&(Ms(n)?n(t):n.current=t)},e);function qf(e){return null}function Jf(e,t,n,r){return r}function Yf(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 Xf=`default`;function Zf(e){let t={};for(let n in e.averageSizes){let r=e.averageSizes[n];r&&(t[n||Xf]={average:r.avg,count:r.num})}return t}function Qf(e){Zl(e)}function $f(e,t){let n=e.state,r=tc(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||Us(e,o,a-1)},o=(e,t,a)=>{let o=Date.now(),s=0,c=()=>{if(!r.isCurrent(e))return;i()||!a()?s=0:s+=1;let l=Date.now()-o>=800;if(s>=2||l){t();return}n.scheduledWork.frame(c,`imperativeScrollReady`)};n.scheduledWork.frame(c,`imperativeScrollReady`)},s=(e,t,n,a=()=>!0)=>{let s=()=>r.runNow(e,t,n);i()||!a()?o(e,s,a):s()},c=(t,n=()=>!0)=>new Promise(i=>{let a=r.start(i);Ss(e),s(a,i,t,n)});n.runPendingScrollToEnd=()=>{let t=n.pendingScrollToEnd;t&&(n.pendingScrollToEnd=void 0,r.isCurrent(t.token)&&s(t.token,t.resolve,()=>Uf(e,t.options),()=>a(n.props.data.length-1,!0)))};let l=t=>{if(n){let{index:r,...i}=t,{startNoBuffer:a,endNoBuffer:o}=n;if(r<a||r>o){let t=r<a?0:1;return Mc(e,{...i,index:r,viewPosition:t}),!0}}return!1},u=n.refScroller;return{clearCaches:t=>{var r;let i=t?.mode??`sizes`;n.sizes.clear(),n.sizesKnown.clear(),Dl(n);for(let e in n.averageSizes)delete n.averageSizes[e];n.minIndexSizeChanged=0,n.scrollForNextCalculateItemsInView=void 0,n.pendingTotalSize=void 0,n.totalSize=0,Y(e,`totalSize`,0),i===`full`&&(n.indexByKey.clear(),n.idCache.length=0,n.positions.length=0,n.columns.length=0,n.columnSpans.length=0),Qf(e),(r=n.triggerCalculateItemsInView)==null||r.call(n,{forceFullItemPositions:!0})},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:J(e,`activeStickyIndex`),contentLength:vo(e),data:n.props.data,elementAtIndex:t=>e.viewRefs.get(Bs(e,Es(n,t)))?.current,end:n.endNoBuffer,endBuffered:n.endBuffered,getAverageItemSizes:()=>Zf(n),indexByKey:e=>n.indexByKey.get(e),isAtEnd:J(e,`isAtEnd`),isAtStart:J(e,`isAtStart`),isEndReached:n.isEndReached,isNearEnd:J(e,`isNearEnd`),isNearStart:J(e,`isNearStart`),isStartReached:n.isStartReached,isWithinMaintainScrollAtEndThreshold:J(e,`isWithinMaintainScrollAtEndThreshold`),listen:(t,n)=>uo(e,t,n),listenToPosition:(t,n)=>fo(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:bc(n),sizeAtIndex:e=>n.sizesKnown.get(Es(n,e)),sizes:n.sizesKnown,start:n.startNoBuffer,startBuffered:n.startBuffered}),reportContentInset:t=>{let r=yf(e,t);Cc(e,n.scroll,!0,{markHasScrolled:!1}),r&&Gl(e)},scrollIndexIntoView:e=>c(()=>l(e)),scrollItemIntoView:({item:e,...t})=>c(()=>{let r=n.props.data.indexOf(e);return r!==-1&&(l({index:r,...t}),!0)}),scrollToEnd:i=>new Promise(a=>{var o;let s=r.start(a);n.pendingScrollToEnd={options:i,resolve:a,token:s},t?.(),Ss(e),t||(o=n.runPendingScrollToEnd)==null||o.call(n)}),scrollToIndex:t=>c(()=>(Mc(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&&(Mc(e,{index:i,...r}),!0)}),scrollToOffset:t=>c(()=>(Ac(e,t),!0)),setItemSize:(t,n)=>{Wu(e,{itemKey:t,size:n})},setScrollProcessingEnabled:e=>{n.scrollProcessingEnabled=e},setVisibleContentAnchorOffset:t=>{Y(e,`scrollAdjustUserOffset`,Ms(t)?t(J(e,`scrollAdjustUserOffset`)||0):t)}}}var ep=(e,t)=>e-t,tp=e=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.floor(e)):0,np=(e,t,n)=>{n>=0&&n<t&&e.add(n)};function rp(e,t,n,r){if(t.length===0)return[];let i=new Set,a=t.length,o=tp(e?.top);if(o>0)for(let e=0;e<Math.min(o,a);e++)np(i,a,e);let s=tp(e?.bottom);if(s>0)for(let e=Math.max(0,a-s);e<a;e++)np(i,a,e);if(e?.indices?.length)for(let t of e.indices)Number.isFinite(t)&&np(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)&&(np(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++)np(i,a,t)}let c=Array.from(i);return c.sort(ep),c}function ip(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=J(e,`extraData`),m=a?i.itemData:u[d];return l&&!Ls(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 ap(e,t){return{animated:!1,onDataChange:t?e?.dataChange??!1:!0,onFooterLayout:t?e?.footerLayout??!1:!0,onItemLayout:t?e?.itemLayout??!1:!0,onLayout:t?e?.layout??!1:!0}}function op(e){if(e)return e===!0?{...ap(void 0,!1),animated:!1}:{...ap(e.on,`on`in e),animated:e.animated??!1}}function sp(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 cp(e,{stylePaddingTop:t}){let n=e.state;if(t!==void 0){let r=J(e,`stylePaddingTop`)||0;if(t<r){let t=J(e,`totalSize`)||0;Y(e,`totalSize`,t+r),n.timeoutSetPaddingTop=setTimeout(()=>{t=J(e,`totalSize`)||0,Y(e,`totalSize`,t-r)},16)}Y(e,`stylePaddingTop`,t)}}function lp(e){let t=(0,K.useRef)(null),n=(0,K.useRef)(0),r=(0,K.useRef)(null),i=()=>{t.current&&=(clearTimeout(t.current),null)};return(0,K.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 up(e,t){let n=lp(`throttle`);return r=>n(e,t,{nativeEvent:r.nativeEvent})}var dp=Xu(Yu(function(e,t){let{children:n,data:r,renderItem:i,...a}=e,o=n!==void 0&&r===void 0?{...a,childrenMode:!0,data:(Ns(n)?n:K.Children.toArray(n)).flat(1),renderItem:({item:e})=>e}:{...a,data:r||[],renderItem:i};return K.createElement(ao,null,K.createElement(fp,{...o,ref:t}))})),fp=Yu(function(e,t){let n=(0,K.useCallback)(e=>{},[]);e.recycleItems===void 0&&Fs(`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:L,onEndReached:ee,onEndReachedThreshold:R=.5,onItemSizeChanged:z,onMetricsChange:te,onLayout:ne,onLoad:B,onMomentumScrollEnd:V,onRefresh:re,onScroll:ie,onScrollBeginDrag:ae,onStartReached:oe,onStartReachedThreshold:se=.5,onStickyHeaderChange:ce,onFirstVisibleItemChanged:le,onViewableItemsChanged:H,progressViewOffset:ue,recycleItems:de=!1,refreshControl:fe,refreshing:pe,refScrollView:me,renderScrollComponent:he,renderItem:ge,scrollEventThrottle:_e,snapToIndices:ve,stickyHeaderIndices:ye,style:be,useWindowScroll:xe=!1,viewabilityConfig:U,viewabilityConfigCallbackPairs:Se,...Ce}=e,we=e.animatedPropsInternal,Te=e.anchoredEndSpaceOwnerInternal??`list`,Ee=e.positionComponentInternal,De=e.stickyPositionComponentInternal,{anchoredEndSpaceOwnerInternal:Oe,positionComponentInternal:ke,stickyPositionComponentInternal:Ae,...je}=Ce,Me=Md.flatten(s),Ne=r&&!y&&Me?.minHeight==null&&l.length>0,Pe=r&&!Ne&&(y?Me?.minWidth==null:Me?.minHeight==null),Fe={...Me,...r&&!Ne?{display:`flex`,flexDirection:y?`row`:`column`,...Pe?{flexGrow:1}:{},justifyContent:`flex-end`}:{}},Ie={...Md.flatten(be)},Le=zs(Ie,Fe,`Top`),Re=zs(Ie,Fe,`Bottom`),ze=zs(Ie,Fe,`Left`),Be=zs(Ie,Fe,`Right`),Ve=Xa({horizontal:y,rtl:b,stylePaddingBottom:Re,stylePaddingLeft:ze,stylePaddingRight:Be}),He=op(N),Ue=sp(F),We=C!=null,Ge=w!=null,Ke=!S&&!We&&!Ge&&Ya({horizontal:y,rtl:b}),qe=!S&&!We&&(Ge||Ke),Je=S||We,Ye=typeof C==`number`&&!Ge&&l.length>1&&C>=l.length-1,Xe=S?{index:Math.max(0,l.length-1),preserveForBottomPadding:!0,viewOffset:-Ve,viewPosition:1}:We?typeof C==`object`?{index:C.index??0,preserveForBottomPadding:C.viewOffset===void 0&&C.viewPosition===1||void 0,viewOffset:C.viewOffset??(C.viewPosition===1?-Ve:0),viewPosition:C.viewPosition??0}:{index:C??0,preserveForBottomPadding:Ye?!0:void 0,viewOffset:w??(Ye?-Ve:0),viewPosition:Ye?1:void 0}:qe?{contentOffset:w??0,index:0,viewOffset:0}:void 0,[Ze,Qe]=K.useState(!xo),[,$e]=K.useReducer(e=>e+1,0),W=oo();W.columnWrapperStyle=o||(Fe?Yf(Fe):void 0);let et=y?W.columnWrapperStyle?.columnGap??W.columnWrapperStyle?.gap:W.columnWrapperStyle?.rowGap??W.columnWrapperStyle?.gap,tt=typeof et==`number`&&Number.isFinite(et)?et:0,nt=(0,K.useRef)(null),rt=Kf(nt,me),it=O??((e,t)=>t.toString()),at=ye,ot=p,st=(0,K.useRef)(ot),ct=(0,K.useMemo)(()=>{let e=rp(a,l,it,i?.anchorIndex);return{arr:e,set:new Set(e)}},[i?.anchorIndex,a?.top,a?.bottom,(a?.indices)?.join(`,`),(a?.keys)?.join(`,`),l,u,d,it]),lt=!!xe&&!he,ut=(0,K.useRef)(void 0),dt=!!L,ft=(0,K.useRef)(dt);if(!ut.current){if(!W.state){let e=(h??{height:0,width:0})[y?`width`:`height`];W.values.set(`adaptiveRender`,T?.initialMode??`normal`),W.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,hasHadNonEmptyData:l.length>0,idCache:[],idsInView:[],indexByKey:new Map,initialScroll:Xe,initialScrollSession:Xe?{kind:qe?`offset`:`bootstrap`,previousDataLength:l.length}:void 0,isEndReached:null,isFirst:!0,isStartReached:null,lastBatchingAction:Date.now(),lastLayout:void 0,lastScrollDelta:0,loadStartTime:Date.now(),minIndexSizeChanged:0,nativeContentInset:void 0,nativeMarginTop:0,pendingDataComparison:void 0,pendingNativeMVCPAdjust:void 0,positions:[],props:{},queuedCalculateItemsInView:0,refScroller:{current:null},scheduledWork:new Vf,scroll:0,scrollAdjustHandler:new Hf(W),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=W.state;W.scrollToEnd=e=>Uf(W,e),t.triggerCalculateItemsInView=e=>Iu(W,e),t.reprocessCurrentScroll=()=>Cc(W,t.scroll,!0),Y(W,`maintainVisibleContentPosition`,Ue),Y(W,`extraData`,g),x!==void 0&&Y(W,`headerSize`,x)}ut.current=W.state}let G=ut.current,pt=G.isFirst,mt=G.props.adaptiveRender,ht=G.props.hideItemsUntilMeasured,gt=G.props.numColumns,_t=!pt&&W.scrollAxisGap!==tt;W.scrollAxisGap=tt,G.didColumnsChange=I!==gt||_t;let vt=G.props.data?.length??0,yt=G.props.data!==l,bt=G.props.dataKey!==u,xt=G.props.dataVersion!==d,St=bt||xt||yt&&jf(G,l,G.props.data),Ct=!pt&&St&&G.hasHadNonEmptyData&&(bt||vt===0)&&l.length>0;St&&!S&&G.didFinishInitialScroll&&G.initialScroll?.viewPosition===1&&G.props.data.length>0&&xs(G),St&&(G.dataChangeEpoch+=1,G.dataChangeNeedsScrollUpdate=!0,G.didDataChange=!0,G.previousData=G.props.data),Ct&&(G.freshDataTransitionEpoch+=1);let wt=up(ie??n,_e??0),Tt=_e&&ie?wt:ie,Et=!pt&&!St&&G.props.anchoredEndSpace?.anchorIndex!==i?.anchorIndex;G.props={adaptiveRender:T,alignItemsAtEnd:r,alignItemsAtEndPaddingEnabled:Ne,alwaysRender:a,alwaysRenderIndicesArr:ct.arr,alwaysRenderIndicesSet:ct.set,anchoredEndSpace:i,anchoredEndSpaceOwner:Te,animatedProps:we,contentContainerAlignItems:Fe.alignItems,contentInset:c,contentInsetEndAdjustment:ot,data:l,dataKey:u,dataVersion:d,drawDistance:f,estimatedItemSize:m,getFixedItemSize:Gf(_),getItemType:Gf(v),hideItemsUntilMeasured:E,horizontal:!!y,itemsAreEqual:D,keyExtractor:Gf(it),maintainScrollAtEnd:He,maintainScrollAtEndThreshold:P,maintainVisibleContentPosition:Ue,numColumns:I,onEndReached:ee,onEndReachedThreshold:R,onFirstVisibleItemChanged:le,onItemSizeChanged:z,onLoad:B,onMomentumScrollEnd:V,onScroll:Tt,onScrollBeginDrag:ae,onStartReached:oe,onStartReachedThreshold:se,onStickyHeaderChange:ce,overrideItemLayout:L,positionComponentInternal:Ee,recycleItems:!!de,renderItem:ge,rtl:b,snapToIndices:ve,stickyHeaderIndicesArr:at??[],stickyHeaderIndicesSet:(0,K.useMemo)(()=>new Set(at??[]),[at?.join(`,`)]),stickyPositionComponentInternal:De,stylePaddingBottom:Re,stylePaddingLeft:ze,stylePaddingRight:Be,stylePaddingTop:Le,useWindowScroll:lt},G.refScroller=nt,!pt&&mt&&!T&&ds(W),!pt&&ht&&!E&&Nf(W);let Dt=(0,K.useMemo)(()=>l.length?Array.from({length:Math.min(I,l.length)},(e,t)=>Es(G,l.length-1-t)):[],[l,u,d,I]),Ot=e=>{Y(W,`lastItemKeys`,Dt),Y(W,`numColumns`,I);let t=J(W,`stylePaddingTop`);cp(W,{stylePaddingTop:Le}),ut.current.props.stylePaddingBottom=Re,ks(W);let n=Le-t;e&&Ue.size&&n&&t!==void 0&&Ha.OS};pt&&(Ot(!1),Yl(G),iu(W,!0));let kt=(0,K.useMemo)(()=>{let e=G.initialScroll;if(!e)return;let t=e.contentOffset??Fc(W,e);return Je&&G.initialScrollSession?.kind===`bootstrap`&&Ha.OS===`web`?void 0:t},[Je]);(0,K.useLayoutEffect)(()=>{ql(W,{alwaysDispatchInitialScroll:Ke,dataLength:l.length,hasFooterComponent:!!A,initialContentOffset:kt,initialScrollAtEnd:S,useBootstrapInitialScroll:Je})},[]),(pt||St||G.didColumnsChange)&&(ut.current.lastBatchingAction=Date.now(),!O&&!pt&&St&&(ut.current.sizes.clear(),ut.current.positions.length=0,ut.current.totalSize=0,Y(W,`totalSize`,0))),Do&&kf(e),(0,K.useLayoutEffect)(()=>{Ct&&gs(W,{resetInitialScroll:!!Xe,resetLayout:!0}),Jl(W,{dataLength:l.length,didDataChange:St,didStartFreshData:Ct,initialScrollAtEnd:S,latestInitialScroll:Xe,latestInitialScrollSessionKind:qe?`offset`:`bootstrap`,stylePaddingEnd:Ve,useBootstrapInitialScroll:Je})},[l.length,u,St,Ct,S,Ve,Je]),(0,K.useLayoutEffect)(()=>{var e;Et&&(G.scrollForNextCalculateItemsInView=void 0,(e=G.triggerCalculateItemsInView)==null||e.call(G)),Lu(W)},[W,l,d,i?.anchorIndex,i?.anchorMaxSize,i?.anchorOffset,Et,y,I,b,Re,ze,Be]),(0,K.useLayoutEffect)(()=>{let e=st.current;st.current=ot,Wf(W,e)},[W,ot]);let At=(0,K.useCallback)(e=>{Je&&yl(W,{dataLength:l.length,footerSize:e[y?`width`:`height`],initialScrollAtEnd:S,stylePaddingEnd:Ve})},[l.length,S,y,Ve,Je]),{onLayout:jt}=pd({onLayoutChange:(0,K.useCallback)((e,t)=>{let n=G.scrollLength,r=G.otherAxisSize;If(W,e,Qe),Lu(W);let i=n!==G.scrollLength||r!==G.otherAxisSize;Je&&!t&&i&&bl(W),!Je&&zc(W)},[l.length,S,Ve,Je]),onLayoutProp:ne,ref:nt});(0,K.useLayoutEffect)(()=>{ve&&ru(W)},[ve]),(0,K.useLayoutEffect)(()=>Ot(!0),[u,d,Dt.join(`,`),I,tt,Re,Le,Ne]),(0,K.useLayoutEffect)(()=>{let{didColumnsChange:e,didDataChange:t,isFirst:n,props:{data:r}}=G;!(r.length>0&&Pf(W))&&!n&&(t||e)&&Af(W,r,{didColumnsChange:e}),t&&(G.pendingDataComparison=void 0),G.didColumnsChange=!1,G.didDataChange=!1,G.isFirst=!1},[l,u,d,I,tt]),(0,K.useLayoutEffect)(()=>{var e;Y(W,`extraData`,g);let t=ft.current!==dt;ft.current=dt,(dt||t)&&I>1&&((e=G.triggerCalculateItemsInView)==null||e.call(G,{forceFullItemPositions:!0}))},[g,dt,I]),(0,K.useEffect)(()=>{if(!te)return;let e,t=()=>{let t={footerSize:J(W,`footerSize`)||0,headerSize:J(W,`headerSize`)||0};(!e||t.headerSize!==e.headerSize||t.footerSize!==e.footerSize)&&(e=t,te(t))};t();let n=[uo(W,`headerSize`,t),uo(W,`footerSize`,t)];return()=>{for(let e of n)e()}},[W,te]),(0,K.useEffect)(()=>{let e=ou({onViewableItemsChanged:H,viewabilityConfig:U,viewabilityConfigCallbackPairs:Se});G.viewabilityConfigCallbackPairs=e,G.enableScrollForNextCalculateItemsInView=!0,e&&(G.scrollForNextCalculateItemsInView=void 0)},[U,Se,H]),rd(()=>{}),(0,K.useImperativeHandle)(t,()=>$f(W,$e),[]),(0,K.useEffect)(()=>()=>{Po(G),G.scheduledWork.dispose()},[G]),(0,K.useLayoutEffect)(()=>{var e;(e=G.runPendingScrollToEnd)==null||e.call(G)}),(0,K.useEffect)(()=>{Je||zc(W)},[W,Je]);let Mt=(0,K.useMemo)(()=>({getRenderedItem:(e,t)=>ip(W,e,t),onMomentumScrollEnd:e=>{Wl(W),G.props.onMomentumScrollEnd&&G.props.onMomentumScrollEnd(e)},onScroll:e=>Bf(W,e),onScrollBeginDrag:e=>{var t,n;let r=G.maintainingScrollAtEnd;(r===`animated`||r===`instant`)&&Po(G),r&&rc(W),Qo(W),(n=(t=G.props).onScrollBeginDrag)==null||n.call(t,e)},onScrollEnd:()=>Qo(W)}),[]),Nt=Jf(at,y,W,Mt.onScroll),Pt=fe;return K.createElement(K.Fragment,null,K.createElement(Cf,{...je,alignItemsAtEnd:r,canRender:Ze,contentContainerStyle:Fe,contentInset:c,freshDataTransitionEpoch:G.freshDataTransitionEpoch,getRenderedItem:Mt.getRenderedItem,horizontal:y,initialContentOffset:kt,ListEmptyComponent:l.length===0?k:void 0,ListFooterComponent:A,ListFooterComponentStyle:j,ListHeaderComponent:M,onInternalScrollBeginDrag:Mt.onScrollBeginDrag,onInternalScrollEnd:Mt.onScrollEnd,onLayout:jt,onLayoutFooter:At,onMomentumScrollEnd:Mt.onMomentumScrollEnd,onScroll:Nt,recycleItems:de,refreshControl:Pt?Le>0?K.cloneElement(Pt,{progressViewOffset:(Pt.props.progressViewOffset??0)+Le}):Pt:re&&K.createElement(qf,{onRefresh:re,progressViewOffset:(ue||0)+Le,refreshing:!!pe}),refScrollView:rt,renderScrollComponent:he,scrollAdjustHandler:ut.current?.scrollAdjustHandler,scrollEventThrottle:0,snapToIndices:ve,stickyHeaderIndices:at,style:Ie,useWindowScroll:lt}),Do&&jo)}),pp=dp;function mp({rootRef:e,disabled:t=!1}){let n=(0,K.useRef)(null),[r,i]=(0,K.useState)(!1);return(0,K.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 hp=c()(er(e=>({checkedPathsByProjectId:{},reconcileProject:(t,n)=>e(e=>{let r=e.checkedPathsByProjectId[t]??{},i=Object.fromEntries(n.map(e=>[e,r[e]??!0]));return Object.keys(r).length===Object.keys(i).length&&Object.entries(i).every(([e,t])=>r[e]===t)?e:{checkedPathsByProjectId:{...e.checkedPathsByProjectId,[t]:i}}}),toggleChecked:(t,n)=>e(e=>{let r=e.checkedPathsByProjectId[t]??{};return{checkedPathsByProjectId:{...e.checkedPathsByProjectId,[t]:{...r,[n]:!(r[n]??!0)}}}}),toggleAllChecked:(t,n)=>e(e=>{if(n.length===0)return e;let r=e.checkedPathsByProjectId[t]??{},i=!n.every(e=>r[e]??!0);return{checkedPathsByProjectId:{...e.checkedPathsByProjectId,[t]:{...r,...Object.fromEntries(n.map(e=>[e,i]))}}}})}),{name:`diff-commit-selections`,version:2})),X=c()(e=>({isGenerating:!1,commitModeInFlight:null,isSyncing:!1,isGitHubPublishModalOpen:!1,patchesByPath:{},patchErrorsByPath:{},loadingPatchPaths:{},setIsGenerating:t=>e({isGenerating:t}),setCommitModeInFlight:t=>e({commitModeInFlight:t}),setIsSyncing:t=>e({isSyncing: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=>{let{[t]:n,...r}=e.loadingPatchPaths;return{loadingPatchPaths:r}}),clearPatchError:t=>e(e=>{if(!(t in e.patchErrorsByPath))return e;let{[t]:n,...r}=e.patchErrorsByPath;return{patchErrorsByPath:r}}),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})})),gp=ci(`DiffFileCard`,()=>e=>({selectedAttachmentId:null,setSelectedAttachmentId:t=>e({selectedAttachmentId:t})}));function _p({label:e,fact:t,className:n}){return(0,q.jsxs)(`div`,{className:u(`flex items-baseline gap-2 px-1 py-1 font-mono text-xs tracking-wide tabular-nums text-muted-foreground`,n),children:[(0,q.jsx)(`span`,{children:e}),t===void 0?null:(0,q.jsx)(`span`,{className:`ml-auto pl-3 truncate`,children:t})]})}function vp({className:e,...t}){return(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:e,"aria-hidden":`true`,...t,children:(0,q.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`})})}function yp(e){switch(e.kind){case`local`:return 0;case`pull_request`:return 1;default:return 2}}function bp(e){let t=new Map;for(let n of e){let e=t.get(n.name);(!e||yp(n)<yp(e))&&t.set(n.name,n)}return t}function xp(e,t){let n=bp([...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 Sp(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 Cp(e,t,n){let r=n.trim().toLowerCase(),i=e=>Sp(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 wp(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 Tp(e){return e?`Last fetched ${wp(e)}`:`No local fetch recorded`}function Ep(e){return e.isUntracked}function Dp(e){return Ep(e)?e.path.includes(`/`):!1}function Op(e){return!e.isCollapsed&&!e.hasPreviewAttachment&&e.patch===void 0&&e.patchError===void 0&&!e.isPatchLoading}function kp(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:t.path.split(`/`).pop()??t.path,absolutePath:t.path,relativePath:t.path,contentUrl:`/api/projects/${e}/files/${encodeURIComponent(t.path)}/content`,mimeType:t.mimeType,size:t.size}}function Ap(e){return e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}function jp(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?Ap(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}}var Mp=new Set([`changes`,`history`]),Np=new Set([`public`,`private`]),Pp=new Set([`branches`,`pull_requests`]);function Fp(e){return Mp.has(e)}function Ip(e){return Np.has(e)}function Lp(e){return Pp.has(e)}var Rp={},zp=(0,K.lazy)(()=>i(()=>import(`./react-BBdwAnLG.js`).then(e=>({default:e.PatchDiff})),__vite__mapDeps([0,1,2,3,4,5])));function Bp(e){return(0,q.jsxs)(hi,{delayDuration:0,children:[(0,q.jsx)(vi,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,"aria-label":e.label,onClick:e.onClick,className:u(`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,q.jsx)(gi,{children:e.label})]})}function Vp({checked:e,mixed:t=!1,label:n,className:r,onClick:i}){let a;return a=t?(0,q.jsx)(tt,{className:`h-3 w-3`,strokeWidth:3}):e?(0,q.jsx)(Dr,{className:`h-3 w-3`,strokeWidth:3}):null,(0,q.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:u(`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 Hp({entry:e,isPendingPush:t=!1,ports:n}){let r=n?.dom??o,i=wp(e.authoredAt),a=!!e.githubUrl,s;return s=e.tags.length>0?(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1`,children:[e.tags.map(e=>(0,q.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,q.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-muted border border-border px-2 py-0.5 text-xs`,children:(0,q.jsx)(wt,{className:`size-3`})}):null]}):t?(0,q.jsx)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1`,children:(0,q.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-muted border border-border px-2 py-0.5 text-xs`,children:(0,q.jsx)(wt,{className:`size-3`})})}):null,(0,q.jsxs)(`button`,{type:`button`,disabled:!a,onClick:()=>{e.githubUrl&&r.openWindow(e.githubUrl,`_blank`,`noopener,noreferrer`)},className:u(`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,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.summary}),e.description?(0,q.jsx)(`div`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.description}):null,(0,q.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1 text-xs text-muted-foreground`,children:[e.authorName?(0,q.jsx)(`span`,{className:`truncate`,children:e.authorName}):null,e.authorName&&i?(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`•`}):null,i?(0,q.jsx)(`span`,{children:i}):null]})]}),s]})}function Up({open:e,onOpenChange:t,onGetGitHubPublishInfo:n,onCheckGitHubRepoAvailability:r,onPublish:i,ports:o}){let s=o?.timer??fi,c=X(e=>e.publishInfo),l=X(e=>e.isLoadingPublishInfo),d=X(e=>e.publishOwner),f=X(e=>e.publishName),p=X(e=>e.publishVisibility),m=X(e=>e.publishDescription),h=X(e=>e.publishAvailability),g=X(e=>e.isCheckingPublishAvailability),_=X(e=>e.isPublishing),v=X(e=>e.setPublishInfo),y=X(e=>e.setIsLoadingPublishInfo),b=X(e=>e.setPublishOwner),x=X(e=>e.setPublishName),S=X(e=>e.setPublishVisibility),C=(0,K.useCallback)(e=>{Ip(e)&&S(e)},[S]),w=X(e=>e.setPublishDescription),T=X(e=>e.setPublishAvailability),E=X(e=>e.setIsCheckingPublishAvailability),D=X(e=>e.setIsPublishing);(0,K.useEffect)(()=>{if(!e)return;let t=!1;return y(!0),T(null),n().then(e=>{t||(v(e),b(e.owners[0]??e.activeAccountLogin??``),x(e.suggestedRepoName),S(`private`),w(``))}).finally(()=>{t||y(!1)}),()=>{t=!0}},[n,e,T,w,v,y,x,b,S]),(0,K.useEffect)(()=>{if(!e||!c?.ghInstalled||!c.authenticated)return;let t=d.trim(),n=f.trim();if(!t||!n){T(null);return}let i=!1;E(!0);let a=s.setTimeout(()=>{r({owner:t,name:n}).then(e=>{i||T(e)}).finally(()=>{i||E(!1)})},250);return()=>{i=!0,s.clearTimeout(a)}},[c?.authenticated,c?.ghInstalled,f,r,e,d,T,E,s]);async function O(){if(!(!d.trim()||!f.trim())){D(!0);try{let e=await i({owner:d.trim(),name:f.trim(),visibility:p,description:m});De(e)&&e.ok&&t(!1)}finally{D(!1)}}}let k=!!(c?.ghInstalled&&c.authenticated&&d.trim()&&f.trim()&&h?.available&&!g&&!_),A;A=g?(0,q.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-3 flex items-center text-muted-foreground`,children:(0,q.jsx)(Or,{className:`size-4 animate-spin`})}):h?(0,q.jsx)(`div`,{className:`absolute inset-y-0 right-2 flex items-center`,children:(0,q.jsxs)(hi,{delayDuration:0,children:[(0,q.jsx)(vi,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":h.message,className:u(`flex size-6 items-center justify-center rounded-md`,h.available?`text-success-text`:`text-destructive`),children:h.available?(0,q.jsx)(Dr,{className:`size-4`}):(0,q.jsx)(ut,{className:`size-4`})})}),(0,q.jsx)(gi,{children:h.message})]})}):null;let j;return j=l?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,q.jsx)(Or,{className:`size-4 animate-spin`}),(0,q.jsx)(`span`,{children:`Checking GitHub CLI…`})]}):c&&!c.ghInstalled?(0,q.jsxs)(`div`,{className:`space-y-2 text-sm text-muted-foreground`,children:[(0,q.jsx)(`p`,{children:`GitHub CLI is not installed.`}),(0,q.jsx)(`div`,{className:`rounded-lg border border-border px-3 py-2 font-mono text-xs text-foreground`,children:`brew install gh`}),(0,q.jsx)(`p`,{children:`Then run:`}),(0,q.jsx)(`div`,{className:`rounded-lg border border-border px-3 py-2 font-mono text-xs text-foreground`,children:`gh auth login`})]}):c&&!c.authenticated?(0,q.jsxs)(`div`,{className:`space-y-2 text-sm text-muted-foreground`,children:[(0,q.jsx)(`p`,{children:`GitHub CLI is installed but not signed in.`}),(0,q.jsx)(`div`,{className:`rounded-lg border border-border px-3 py-2 font-mono text-xs text-foreground`,children:`gh auth login`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`space-y-2`,children:(0,q.jsxs)(br,{value:d,onValueChange:b,children:[(0,q.jsx)(pr,{className:`pl-[11px] [&>span]:flex [&>span]:items-center [&>span]:gap-2`,children:(0,q.jsx)(dr,{placeholder:`Select owner`})}),(0,q.jsx)(cr,{children:(c?.owners??[]).map(e=>(0,q.jsx)(gr,{value:e,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e===c?.activeAccountLogin?(0,q.jsx)(ct,{className:`size-4 text-muted-foreground`}):(0,q.jsx)(Ki,{className:`size-4 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`pl-[1px]`,children:e})]})},e))})]})}),(0,q.jsx)(`div`,{className:`space-y-2`,children:(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(pi,{value:f,onChange:e=>x(e.target.value),placeholder:`my-repo`,className:`pl-9 pr-10`}),(0,q.jsx)(va,{className:`pointer-events-none absolute inset-y-0 left-3 my-auto size-4 text-muted-foreground`}),A]})}),(0,q.jsx)(`div`,{className:`space-y-2`,children:(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(jt,{className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,q.jsx)(Si,{value:m,onChange:e=>w(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,q.jsx)(`div`,{className:`space-y-2`,children:(0,q.jsxs)(br,{value:p,onValueChange:C,children:[(0,q.jsx)(pr,{className:`pl-[11px] [&>span]:flex [&>span]:items-center [&>span]:gap-2`,children:(0,q.jsx)(dr,{placeholder:`Select visibility`})}),(0,q.jsxs)(cr,{children:[(0,q.jsx)(gr,{value:`private`,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(ir,{className:`size-4 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`pl-[1px]`,children:`Private`})]})}),(0,q.jsx)(gr,{value:`public`,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(ca,{className:`size-4 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`pl-[1px]`,children:`Public`})]})})]})]})})]}),(0,q.jsx)(ui,{open:e,onOpenChange:t,children:(0,q.jsxs)(ii,{size:`sm`,className:`max-w-[min(92vw,475px)]`,children:[(0,q.jsxs)(oi,{className:`space-y-2 px-4 pb-4 pt-4`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(ai,{children:`Push to GitHub`}),(0,q.jsx)(li,{children:`Create a GitHub repository from this local project using GitHub CLI.`})]}),j]}),(0,q.jsxs)(di,{children:[(0,q.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,q.jsx)(a,{size:`sm`,disabled:!k,onClick:()=>void O(),children:_?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Or,{className:`mr-1.5 size-3.5 animate-spin`}),`Publishing…`]}):`Push to GitHub`})]})]})})}function Wp({value:e,onChange:t,placeholder:n,disabled:r,trailingAction:i}){return(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(Ur,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,q.jsx)(pi,{value:e,onChange:e=>t(e.target.value),placeholder:n,className:u(`h-9 pl-7 text-sm`,i?`pr-14`:void 0),disabled:r}),i?(0,q.jsx)(`div`,{className:`absolute right-1 top-1/2 -translate-y-1/2`,children:i}):null]})}function Gp({title:e,entries:t,emptyLabel:n,selectedName:r,disabled:i,stickyTitle:a=!1,onSelect:o}){return t.length===0&&!n?null:(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(_p,{label:e,fact:t.length>0?String(t.length):void 0,className:u(a&&`sticky top-0 z-10 bg-background`)}),t.length===0?(0,q.jsx)(`div`,{className:`px-1 py-1 text-xs text-muted-foreground`,children:n}):t.map(e=>{let t=r===e.name;return(0,q.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>o(e),className:u(`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:[e.kind===`pull_request`?(0,q.jsx)(sa,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,q.jsx)(ht,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex w-full items-center gap-3`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden whitespace-nowrap text-sm text-foreground`,children:e.displayName}),e.updatedAt?(0,q.jsx)(`div`,{className:`ml-auto shrink-0 text-right text-xs text-muted-foreground`,children:wp(e.updatedAt)}):null]}),e.kind===`pull_request`&&e.description||e.headLabel?(0,q.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]})]},e.id)})]})}function Kp({open:e,onOpenChange:t,branchList:n,currentBranchName:r,onPreviewMergeBranch:i,onMergeBranch:o}){let s=X(e=>e.mergeBranchQuery),c=X(e=>e.mergeBranchSelectedName),l=X(e=>e.mergePreview),u=X(e=>e.mergePreviewError),d=X(e=>e.isMergePreviewLoading),f=X(e=>e.isMergeBranching),p=X(e=>e.setMergeBranchQuery),m=X(e=>e.setMergeBranchSelectedName),h=X(e=>e.setMergePreview),g=X(e=>e.setMergePreviewError),_=X(e=>e.setIsMergePreviewLoading),v=X(e=>e.setIsMergeBranching),y=X(e=>e.resetMergeBranchModal),b=X(e=>e.resetMergePreview),x=(0,K.useMemo)(()=>n?xp(n,r):{defaultBranch:void 0,recent:[],other:[]},[n,r]),S=s.trim().toLowerCase(),C=(0,K.useCallback)(e=>!S||[e.displayName,e.name,e.description,e.prTitle,e.headLabel].some(e=>e?.toLowerCase().includes(S)),[S]),w=x.defaultBranch&&C(x.defaultBranch)?x.defaultBranch:void 0,T=x.recent.filter(C),E=x.other.filter(C),D=(0,K.useMemo)(()=>c?[x.defaultBranch,...x.recent,...x.other].find(e=>e!==void 0&&e.name===c)??null:null,[x.defaultBranch,x.other,x.recent,c]);(0,K.useEffect)(()=>{e||y()},[e,y]),(0,K.useEffect)(()=>{if(!e||!D){b();return}let t=!1;return h(null),g(null),_(!0),i(D).then(e=>{t||h(e)}).catch(e=>{t||g(e instanceof Error?e.message:String(e))}).finally(()=>{t||_(!1)}),()=>{t=!0}},[i,e,b,D,_,h,g]);let O=!D||!l||d||f||l.status!==`mergeable`;async function k(){if(!(!D||O)){v(!0);try{(await o(D))?.ok&&t(!1)}finally{v(!1)}}}let A;A=l?l.status===`up_to_date`?(0,q.jsx)(Dr,{className:`mt-1 size-3.5 shrink-0 text-success-text`}):l.status===`conflicts`?(0,q.jsx)(ut,{className:`mt-1 size-3.5 shrink-0 text-warning-text`}):l.status===`mergeable`?(0,q.jsx)(ia,{className:`mt-1 size-3.5 shrink-0 text-muted-foreground`}):(0,q.jsx)(ut,{className:`mt-1 size-3.5 shrink-0 text-destructive`}):null;let j;return j=D?d?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,q.jsx)(Or,{className:`size-3.5 animate-spin`}),(0,q.jsx)(`span`,{children:`Checking merge preview…`})]}):u?(0,q.jsx)(`div`,{className:`text-sm text-destructive`,children:u}):l?(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[A,(0,q.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:l.message}),l.detail?(0,q.jsx)(`div`,{className:`line-clamp-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:l.detail}):null]})]}):(0,q.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Preview unavailable.`}):(0,q.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Select a branch to preview the merge.`}),(0,q.jsx)(ui,{open:e,onOpenChange:t,children:(0,q.jsxs)(ii,{size:`sm`,className:`max-w-[min(92vw,475px)]`,children:[(0,q.jsxs)(oi,{className:`flex min-h-0 flex-col gap-3 px-4 pb-4 pt-4`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(ai,{children:[`Merge into `,r??`current branch`]}),(0,q.jsx)(li,{children:`Choose a branch to continue.`})]}),(0,q.jsx)(Wp,{value:s,onChange:p,placeholder:`Search branches`}),(0,q.jsxs)(`div`,{className:`max-h-[375px] space-y-3 overflow-y-auto pr-1`,children:[(0,q.jsx)(Gp,{title:`Default Branch`,entries:w?[w]:[],emptyLabel:`No default branch available.`,selectedName:c,onSelect:e=>m(e.name)}),(0,q.jsx)(Gp,{title:`Recent Branches`,entries:T,emptyLabel:`No recent branches.`,selectedName:c,onSelect:e=>m(e.name)}),(0,q.jsx)(Gp,{title:`Other Branches`,entries:E,emptyLabel:`No other branches match this search.`,selectedName:c,onSelect:e=>m(e.name)})]}),(0,q.jsx)(`div`,{className:`px-2`,children:j})]}),(0,q.jsx)(di,{children:(0,q.jsxs)(`div`,{className:`flex min-w-0 w-full items-center justify-end gap-2`,children:[(0,q.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,q.jsx)(a,{className:`max-w-full min-w-0`,size:`sm`,disabled:O,onClick:()=>void k(),children:f?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Or,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}),`Merging…`]}):(0,q.jsx)(`span`,{className:`block max-w-full truncate`,children:`Merge`})})]})})]})})}function qp({currentBranchName:e,onListBranches:t,onPreviewMergeBranch:n,onMergeBranch:r,onCheckoutBranch:i,onCreateBranch:o}){let s=X(e=>e.branchSwitcherOpen),c=X(e=>e.mergeModalOpen),l=X(e=>e.branchSwitcherIsLoading),u=X(e=>e.branchSwitcherIsMutating),d=X(e=>e.branchSwitcherQuery),f=X(e=>e.branchSwitcherEntryView),p=X(e=>e.branchList),m=X(e=>e.branchSwitcherError),h=X(e=>e.setBranchSwitcherOpen),g=X(e=>e.setMergeModalOpen),_=X(e=>e.setBranchSwitcherIsLoading),v=X(e=>e.setBranchSwitcherIsMutating),y=X(e=>e.setBranchSwitcherQuery),b=X(e=>e.setBranchSwitcherEntryView),x=(0,K.useCallback)(e=>{Lp(e)&&b(e)},[b]),S=X(e=>e.setBranchList),C=X(e=>e.setBranchSwitcherError);(0,K.useEffect)(()=>{s&&(_(!0),C(null),t().then(e=>S(e)).catch(e=>{C(e instanceof Error?e.message:String(e))}).finally(()=>{_(!1)}))},[t,s,S,C,_]);let{currentName:w,recent:T,local:E,remote:D,pullRequests:O,totalPullRequestCount:k}=Cp(p??null,e,d);async function A(e){v(!0);try{await i(e),h(!1),y(``),b(`branches`)}finally{v(!1)}}async function j(){v(!0);try{await o(),h(!1),y(``),b(`branches`)}finally{v(!1)}}function M(){h(!1),g(!0)}let N;N=p?.pullRequestsStatus===`error`?p.pullRequestsError??`Could not load pull requests.`:p?.pullRequestsStatus===`unavailable`?`Pull requests unavailable for this repository.`:`No open pull requests.`;let P;return P=l?(0,q.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground`,children:[(0,q.jsx)(Or,{className:`h-4 w-4 animate-spin`}),(0,q.jsx)(`span`,{children:`Loading branches…`})]}):m?(0,q.jsx)(`div`,{className:`rounded-lg border border-border px-3 py-2 text-sm text-muted-foreground`,children:m}):f===`pull_requests`?(0,q.jsx)(Gp,{title:`Open PRs`,entries:O,emptyLabel:N,disabled:u,stickyTitle:!0,onSelect:e=>{A(e)}}):(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(Gp,{title:`Recent`,entries:T,emptyLabel:`No recent branches.`,disabled:u,stickyTitle:!0,onSelect:e=>{A(e)}}),(0,q.jsx)(Gp,{title:`Local`,entries:E,emptyLabel:`No local branches.`,disabled:u,stickyTitle:!0,onSelect:e=>{A(e)}}),(0,q.jsx)(Gp,{title:`Remote`,entries:D,emptyLabel:`No remote branches.`,disabled:u,stickyTitle:!0,onSelect:e=>{A(e)}})]}),(0,q.jsxs)(Pi,{open:s,onOpenChange:h,children:[(0,q.jsx)(Ni,{asChild:!0,children:(0,q.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,q.jsx)(ht,{className:`h-3.5 w-3.5 shrink-0`}),(0,q.jsx)(`span`,{className:`truncate`,children:e??`Detached HEAD`}),(0,q.jsx)(or,{className:`h-3.5 w-3.5 shrink-0`})]})}),(0,q.jsx)(Mi,{align:`start`,className:`w-[320px] p-2`,children:(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(Wp,{value:d,onChange:y,placeholder:f===`pull_requests`?`Search pull requests`:`Search branches`,disabled:l||u,trailingAction:(0,q.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void j(),disabled:l||u,className:`h-7 px-2 text-xs hover:!bg-transparent hover:!border-border/0`,children:`+ New`})}),(0,q.jsx)(yi,{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,q.jsx)(`div`,{className:`max-h-[420px] overflow-y-auto pr-1.5 -mr-[8px]`,children:P}),w?(0,q.jsx)(a,{variant:`default`,size:`sm`,disabled:l||u||!!m,onClick:M,className:`h-9 w-full justify-center rounded-lg px-3 text-sm`,children:(0,q.jsxs)(`span`,{className:`block max-w-full truncate`,children:[(0,q.jsx)(oa,{className:`mr-1.5 inline h-3.5 w-3.5 shrink-0`}),`Merge branch into `,w,`...`]})}):null]})}),(0,q.jsx)(Kp,{open:c,onOpenChange:g,branchList:p,currentBranchName:w,onPreviewMergeBranch:n,onMergeBranch:r})]})}function Jp({file:e,rootRef:t,projectId:n,isCollapsed:r,isChecked:i,editorLabel:a,diffRenderMode:s,wrapLines:c,onToggleCollapsed:l,onToggleChecked:d,fileActions:f,patch:p,patchError:m,isPatchLoading:h,onLoadPatch:g,ports:_}){let v=_?.dom??o,y=Ep(e),b=Dp(e),x=gp.useScopedStore(e=>e.selectedAttachmentId),S=gp.useScopedStore(e=>e.setSelectedAttachmentId),C=(0,K.useRef)(null),w=(0,K.useRef)(null),{sentinelRef:T,isStuck:E}=mp({rootRef:t,disabled:r}),D=(0,K.useMemo)(()=>kp(n,e),[e,n]),O=D!==null,k=Op({isCollapsed:r,hasPreviewAttachment:O,patch:p,patchError:m,isPatchLoading:h});(0,K.useEffect)(()=>{if(!k)return;let t=`${e.path}\u0000${e.patchDigest}`;w.current!==t&&(w.current=t,g(e.path).catch(()=>{}))},[e.patchDigest,e.path,g,k]);function A(e){if(Ke(e).openInNewTab){v.openWindow(new URL(e.contentUrl,v.getOrigin()).toString(),`_blank`,`noopener,noreferrer`);return}S(e.id)}function j(e){e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();C.current&&v.dispatchContextMenuEvent(C.current,t.left+t.width/2,t.bottom)}function M(){if(!r){l();return}if(O||p!==void 0){l();return}if(!h){if(!(m!==void 0||Op({isCollapsed:!1,hasPreviewAttachment:O,patch:p,patchError:m,isPatchLoading:h}))){l();return}g(e.path).then(()=>{l()}).catch(()=>{})}}let N;N=h&&r&&!D?(0,q.jsx)(Or,{className:`h-3.5 w-3.5 shrink-0 animate-spin`}):r?(0,q.jsx)(or,{className:`h-3.5 w-3.5 shrink-0`}):(0,q.jsx)(Cr,{className:`h-3.5 w-3.5 shrink-0`});let P;return P=D?(0,q.jsx)(`div`,{className:`flex justify-center p-3`,children:D.kind===`image`?(0,q.jsx)(xt,{attachment:D,onClick:()=>A(D)}):(0,q.jsx)(W,{attachment:D,onClick:()=>A(D)})}):h?(0,q.jsxs)(`div`,{className:`flex items-center justify-center px-3 py-8 text-sm text-muted-foreground`,children:[(0,q.jsx)(Or,{className:`mr-2 h-4 w-4 animate-spin`}),`Loading diff...`]}):m?(0,q.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:m}):p===void 0?(0,q.jsx)(`div`,{className:`px-3 py-4 text-sm text-muted-foreground`,children:`Diff unavailable.`}):(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`Preparing diff…`}),children:(0,q.jsx)(zp,{patch:p,options:{diffStyle:s,disableFileHeader:!0,disableBackground:!1,overflow:c?`wrap`:`scroll`,lineDiffType:`word`,diffIndicators:`classic`}})}),(0,q.jsxs)(wn,{children:[(0,q.jsx)($t,{asChild:!0,children:(0,q.jsxs)(`div`,{ref:C,className:`relative rounded-lg border border-border bg-background`,children:[r?null:(0,q.jsx)(`div`,{ref:T,className:`pointer-events-none absolute inset-x-0 top-0 h-px`,"aria-hidden":`true`}),(0,q.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:M,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),M())},className:u(`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,q.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,q.jsx)(Vp,{checked:i,onClick:d}),(0,q.jsx)(`div`,{className:`min-w-0 truncate select-none ml-2 mr-1`,children:e.path})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 select-none`,children:[(0,q.jsxs)(`span`,{className:`whitespace-nowrap text-xs font-mono`,children:[e.additions>0?(0,q.jsxs)(`span`,{className:`text-success-text`,children:[`+`,e.additions]}):null,e.deletions>0?(0,q.jsxs)(`span`,{className:e.additions>0?`ml-2 text-destructive`:`text-destructive`,children:[`-`,e.deletions]}):null]}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Open actions for ${e.path}`,onClick: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:(0,q.jsx)(zr,{className:`h-3.5 w-3.5 shrink-0`})}),N]})]}),r?null:(0,q.jsx)(`div`,{className:`kanna-diff-patch overflow-hidden rounded-b-[calc(theme(borderRadius.lg)-1px)] pb-[1px]`,children:P}),(0,q.jsx)(Nt,{source:D&&x===D.id?Ft(D,`user_attachment`):null,open:D!==null&&x===D.id,onOpenChange:e=>!e&&S(null)})]},e.path)}),(0,q.jsxs)(Ut,{children:[(0,q.jsxs)(Qt,{onSelect:t=>{t.stopPropagation(),f.onOpenFile(e.path)},children:[(0,q.jsx)($n,{className:`h-3.5 w-3.5`}),(0,q.jsxs)(`span`,{className:`text-xs font-medium`,children:[`Open in `,a]})]}),(0,q.jsxs)(Qt,{onSelect:t=>{t.stopPropagation(),f.onOpenInFinder(e.path)},children:[(0,q.jsx)(Kn,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{className:`text-xs font-medium`,children:`Open in Finder`})]}),(0,q.jsxs)(Qt,{onSelect:t=>{t.stopPropagation(),f.onDiscardFile(e.path)},className:`text-destructive hover:bg-destructive/10 focus:bg-destructive/10`,children:[(0,q.jsx)(tr,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{className:`text-xs font-medium`,children:`Discard Changes`})]}),(0,q.jsxs)(Qt,{disabled:!y,onSelect:t=>{t.stopPropagation(),y&&f.onIgnoreFile(e.path)},children:[(0,q.jsx)(Wi,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{className:`text-xs font-medium`,children:`Ignore File`})]}),(0,q.jsxs)(Qt,{disabled:!b,onSelect:t=>{t.stopPropagation(),b&&f.onIgnoreFolder(e.path)},children:[(0,q.jsx)(Wi,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{className:`text-xs font-medium`,children:`Ignore folder...`})]}),(0,q.jsx)(Zt,{}),(0,q.jsxs)(Qt,{onSelect:t=>{t.stopPropagation(),f.onCopyFilePath(e.path)},children:[(0,q.jsx)(kr,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{className:`text-xs font-medium`,children:`Copy File Path`})]}),(0,q.jsxs)(Qt,{onSelect:t=>{t.stopPropagation(),f.onCopyRelativePath(e.path)},children:[(0,q.jsx)(kr,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{className:`text-xs font-medium`,children:`Copy Relative Path`})]})]})]})}function Yp({projectId:e,diffs:t,editorLabel:n,diffRenderMode:r,wrapLines:i,onOpenFile:s,onOpenInFinder:c,onDiscardFile:l,onIgnoreFile:u,onIgnoreFolder:d,onCopyFilePath:f,onCopyRelativePath:p,onListBranches:m,onPreviewMergeBranch:h,onMergeBranch:g,onCheckoutBranch:_,onCreateBranch:v,onGenerateCommitMessage:y,onInitializeGit:b,onGetGitHubPublishInfo:x,onCheckGitHubRepoAvailability:S,onSetupGitHub:C,onCommit:w,onSyncWithRemote:T,onLoadPatch:E,onDiffRenderModeChange:D,onWrapLinesChange:O,ports:k}){let A=k?.dom??o,j=(0,K.useMemo)(()=>({onOpenFile:s,onOpenInFinder:c,onDiscardFile:l,onIgnoreFile:u,onIgnoreFolder:d,onCopyFilePath:f,onCopyRelativePath:p}),[s,c,l,u,d,f,p]),M=t.files.length>0,N=X(e=>e.isGenerating),P=X(e=>e.commitModeInFlight),F=X(e=>e.isSyncing),I=X(e=>e.isGitHubPublishModalOpen),L=X(e=>e.patchesByPath),ee=X(e=>e.patchErrorsByPath),R=X(e=>e.loadingPatchPaths),z=X(e=>e.setIsGenerating),te=X(e=>e.setCommitModeInFlight),ne=X(e=>e.setIsSyncing),B=X(e=>e.setIsGitHubPublishModalOpen),V=X(e=>e.reconcilePatches),re=X(e=>e.setPatchLoading),ie=X(e=>e.clearPatchLoading),ae=X(e=>e.clearPatchError),oe=X(e=>e.setPatchResult),se=X(e=>e.setPatchError),ce=(0,K.useRef)(null),le=(0,K.useRef)(null),H=(0,K.useRef)({}),ue=(0,K.useMemo)(()=>t.files.map(e=>e.path),[t.files]),de=(0,K.useMemo)(()=>ue.join(`\0`),[ue]),fe=M?`changes`:`history`,pe=Ln(t=>e?t.projectUi[e]?.viewMode??fe:fe),me=Ln(t=>e?t.projectUi[e]?.collapsedPaths??Rp:Rp),he=Ln(t=>e?t.projectUi[e]?.summary??``:``),ge=Ln(t=>e?t.projectUi[e]?.description??``:``),_e=Ln(e=>e.reconcileCollapsedPaths),ve=Ln(e=>e.toggleCollapsedPath),ye=Ln(e=>e.setViewMode),be=Ln(e=>e.setCommitDraft),xe=Ln(e=>e.setCommitSummary),U=Ln(e=>e.setCommitDescription),Se=Ln(e=>e.clearCommitDraft),Ce=hp(t=>e?t.checkedPathsByProjectId[e]??Rp:Rp),we=hp(e=>e.reconcileProject),Te=hp(e=>e.toggleChecked),Ee=hp(e=>e.toggleAllChecked),De=(0,K.useCallback)(t=>{e&&ve(e,t)},[e,ve]),Oe=(0,K.useCallback)(t=>{e&&Te(e,t)},[e,Te]),ke=(0,K.useCallback)(()=>{e&&Ee(e,ue)},[e,Ee,ue]),Ae=(0,K.useCallback)(t=>{e&&Fp(t)&&ye(e,t)},[e,ye]),je=(0,K.useCallback)(t=>{e&&xe(e,t.target.value)},[e,xe]),Me=(0,K.useCallback)(t=>{e&&U(e,t.target.value)},[e,U]),Ne=(0,K.useRef)(M);(0,K.useEffect)(()=>{e&&_e(e,ue)},[ue,de,e,_e]),(0,K.useEffect)(()=>{let e=Object.fromEntries(t.files.map(e=>[e.path,e.patchDigest]));V(ue,t=>H.current[t]===e[t]),H.current=e},[t.files,ue,de,V]),(0,K.useEffect)(()=>{e&&we(e,ue)},[ue,de,e,we]),(0,K.useEffect)(()=>{if(e){if(Ne.current!==M){ye(e,M?`changes`:`history`),Ne.current=M;return}Ne.current=M}},[M,e,ye]);let Pe=(0,K.useMemo)(()=>t.files.filter(e=>Ce[e.path]??!0).map(e=>e.path),[Ce,t.files]),Fe=Pe.length,Ie=t.files.length>0&&Fe===t.files.length,Le=Fe>0&&Fe<t.files.length,Re=he.trim(),ze=Re.length>0,Be=P!==null,Ve=N||Be,He=t.branchHistory?.entries??[],{syncAction:Ue,compareUrl:We,canOpenPullRequest:Ge,primaryCommitMode:Ke,isPublishedBranch:qe,hasRemoteOrigin:Je,behindCount:Ye,aheadCount:Xe,resolvedBranchName:Ze}=jp(t),Qe=t.status===`ready`&&Fe>0&&!Ve,$e=t.status===`ready`&&Fe>0&&ze&&!Ve;async function W(t){if($e){te(t);try{let n=await w({paths:Pe,summary:Re,description:ge.trim(),mode:t});(n?.ok||n?.localCommitCreated)&&e&&Se(e)}finally{te(null)}}}async function et(){if(Qe){z(!0);try{let t=await y({paths:Pe});e&&be(e,{summary:t.subject,description:t.body})}finally{z(!1)}}}function tt(e){if(!(!(e.metaKey||e.ctrlKey)||e.key!==`Enter`)){if(e.preventDefault(),ze){W(Ke);return}et()}}async function nt(e=Ue){if(!(t.status!==`ready`||F)){ne(!0);try{await T(e)}finally{ne(!1)}}}let rt=(0,K.useCallback)(async e=>{let{patchesByPath:n,loadingPatchPaths:r}=X.getState();if(n[e]!==void 0||r[e])return n[e]??``;re(e),ae(e);try{let n=await E(e);oe(e,n);let r=t.files.find(t=>t.path===e)?.patchDigest;return r&&(H.current={...H.current,[e]:r}),n}catch(t){let n=t instanceof Error?t.message:String(t);throw se(e,n),t}finally{ie(e)}},[ae,ie,t.files,E,se,re,oe]),it=(0,K.useCallback)(e=>e.path,[]),at=(0,K.useCallback)(({item:t})=>{let a=me[t.path]??!0,o=Ce[t.path]??!0;return(0,q.jsx)(`div`,{className:`pb-1.5`,children:(0,q.jsx)(gp.Provider,{init:void 0,children:(0,q.jsx)(Jp,{file:t,rootRef:ce,projectId:e,isCollapsed:a,isChecked:o,editorLabel:n,diffRenderMode:r,wrapLines:i,onToggleCollapsed:()=>De(t.path),onToggleChecked:()=>Oe(t.path),fileActions:j,patch:L[t.path],patchError:ee[t.path],isPatchLoading:!!R[t.path],onLoadPatch:rt,ports:k})})})},[Ce,me,r,n,j,rt,R,ee,L,k,Oe,De,e,i]);(0,K.useEffect)(()=>{let e=le.current?.getScrollableNode?.();ce.current=e instanceof HTMLElement?e:null},[pe,t.files.length]);let ot=Ie?`Unselect all files from commit`:`Select all files for commit`,st;st=t.status===`ready`?Je?Ue===`publish`?(0,q.jsxs)(a,{variant:`ghost`,size:`sm`,onClick:()=>void nt(),disabled:F,className:`h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0`,children:[F?(0,q.jsx)(Or,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(Oa,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:`Publish Branch`})]}):(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Ue===`fetch`?(0,q.jsxs)(hi,{delayDuration:0,children:[(0,q.jsx)(vi,{asChild:!0,children:(0,q.jsxs)(a,{variant:`ghost`,size:`sm`,onClick:()=>void nt(),disabled:F,className:`h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0`,children:[F?(0,q.jsx)(Or,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(Hr,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:`Fetch`})]})}),(0,q.jsx)(gi,{children:Tp(t.lastFetchedAt)})]}):(0,q.jsxs)(a,{variant:`ghost`,size:`sm`,onClick:()=>void nt(),disabled:F,className:`h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0`,children:[F?(0,q.jsx)(Or,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(Nr,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:`Pull`}),(0,q.jsx)(`span`,{className:`inline-flex min-w-4 items-center justify-center rounded-full bg-muted px-1 text-xs text-muted-foreground`,children:Ye})]}),qe&&Xe>0?(0,q.jsxs)(a,{variant:`default`,size:`sm`,onClick:()=>void nt(`push`),disabled:F,className:`h-7 gap-1.5 px-2 text-xs`,children:[F?(0,q.jsx)(Or,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(Oa,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:`Push`}),(0,q.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:Xe})]}):null,Ge&&We?(0,q.jsxs)(a,{variant:`ghost`,size:`sm`,onClick:()=>{A.openWindow(We,`_blank`,`noopener,noreferrer`)},className:`h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0`,children:[(0,q.jsx)(sa,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:`PR`})]}):null]}):(0,q.jsxs)(a,{variant:`default`,size:`sm`,onClick:()=>B(!0),className:`h-7 gap-1.5 px-3 text-xs`,children:[(0,q.jsx)(vp,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:`Push to GitHub`})]}):null;let ct;ct=t.status===`no_repo`?(0,q.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 py-3 text-center`,children:(0,q.jsxs)(`div`,{className:`flex max-w-[280px] flex-col items-center gap-3`,children:[(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Initialize git here to start tracking branches, diffs, and history.`}),(0,q.jsx)(a,{size:`sm`,onClick:()=>void b(),children:`Init Git`})]})}):pe===`history`?He.length===0?(0,q.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 py-3 text-center`,children:(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No recent commits on `,t.branchName??`this branch`,`.`]})}):(0,q.jsx)(`div`,{className:`h-full overflow-y-auto [scrollbar-gutter:stable] space-y-1.5 p-1.5`,children:He.map((e,t)=>(0,q.jsx)(Hp,{entry:e,isPendingPush:t<Xe,ports:k},e.sha))}):t.files.length===0?(0,q.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 py-3 text-center`,children:(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No file changes.`})}):null;let lt;lt=ze?Be?(0,q.jsx)(Or,{strokeWidth:2.5,className:`size-3 shrink-0 animate-spin`}):Ke===`commit_and_push`&&t.hasUpstream?(0,q.jsx)(Oa,{strokeWidth:2.5,className:`size-3 shrink-0`}):Ke===`commit_and_push`?(0,q.jsx)(ia,{strokeWidth:2.5,className:`size-3 shrink-0`}):(0,q.jsx)(Dr,{strokeWidth:2.5,className:`size-3 shrink-0`}):N?(0,q.jsx)(Or,{strokeWidth:2.5,className:`size-3 shrink-0 animate-spin`}):(0,q.jsx)(_a,{strokeWidth:2.5,className:`size-3 shrink-0`});let ut;return ut=ze?Be?P===`commit_only`?`Committing...`:`Committing & Pushing...`:Ke===`commit_only`?(0,q.jsxs)(q.Fragment,{children:[`Commit to `,(0,q.jsx)(ht,{strokeWidth:2.5,className:`mr-[4.5px] ml-0.5 inline size-3 `}),Ze]}):t.hasUpstream?(0,q.jsxs)(q.Fragment,{children:[`Commit & push to `,(0,q.jsx)(ht,{strokeWidth:2.5,className:`mr-[4.5px] ml-0.5 inline size-3 `}),Ze]}):(0,q.jsxs)(q.Fragment,{children:[`Commit & publish `,(0,q.jsx)(ht,{strokeWidth:2.5,className:`mr-[4.5px] ml-0.5 inline size-3 `}),Ze]}):N?`Generating...`:(0,q.jsxs)(q.Fragment,{children:[`Generate message for `,(0,q.jsx)(ht,{strokeWidth:2.5,className:`mr-[4.5px] ml-0.5 inline size-3 `}),Ze]}),(0,q.jsx)(`div`,{className:`h-full min-h-0 border-l border-border bg-background md:min-w-[370px]`,children:(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border pl-2.5 pr-2 py-2`,children:[(0,q.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:(0,q.jsx)(qp,{currentBranchName:t.branchName,onListBranches:m,onPreviewMergeBranch:h,onMergeBranch:g,onCheckoutBranch:_,onCreateBranch:v})}),st]}),(0,q.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`sticky top-0 z-30 pl-[14px] pr-[12px] pt-[6px] bg-gradient-to-b from-background to-transparent`,children:(0,q.jsx)(`div`,{className:`relative h-[40px] flex min-w-0 items-center justify-center gap-[13px]`,children:(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-between gap-[13px] relative`,children:[pe===`changes`?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground/70`,children:[(0,q.jsx)(Vp,{checked:Ie,mixed:Le,label:ot,onClick:ke}),(0,q.jsxs)(`span`,{children:[Fe,` files`]})]}):(0,q.jsx)(`div`,{}),(0,q.jsx)(`div`,{className:`pointer-events-none absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2`,children:(0,q.jsx)(`div`,{className:`pointer-events-auto`,children:(0,q.jsx)(yi,{value:pe,onValueChange:Ae,size:`sm`,optionClassName:`flex-1 justify-center`,options:[{value:`changes`,label:`Changes`},{value:`history`,label:`History`}]})})}),pe===`changes`?(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(Bp,{label:`Unified diff`,active:r===`unified`,onClick:()=>D(`unified`),children:(0,q.jsx)(xa,{className:`h-4 w-4`})}),(0,q.jsx)(Bp,{label:`Side-by-side diff`,active:r===`split`,onClick:()=>D(`split`),children:(0,q.jsx)(ta,{className:`h-4 w-4`})}),(0,q.jsx)(Bp,{label:i?`Disable word wrap`:`Enable word wrap`,active:i,onClick:()=>O(!i),children:(0,q.jsx)(Da,{className:`h-4 w-4`})})]}):(0,q.jsx)(`div`,{})]})})}),(0,q.jsxs)(`div`,{className:`h-full min-h-0`,children:[ct,t.status!==`no_repo`&&pe!==`history`&&t.files.length>0&&(0,q.jsxs)(`div`,{className:`relative h-full min-h-0`,children:[(0,q.jsx)(pp,{ref:le,data:t.files,keyExtractor:it,renderItem:at,extraData:{collapsedPaths:me,checkedPaths:Ce,patchesByPath:L,patchErrorsByPath:ee,loadingPatchPaths:R,diffRenderMode:r,wrapLines:i},estimatedItemSize:44,className:`h-full overflow-y-auto [scrollbar-gutter:stable] p-1.5`,contentContainerStyle:{paddingBottom:pe===`changes`?220:40}}),pe===`changes`?(0,q.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 py-1 pb-6 z-30`,children:[(0,q.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 top-0 bg-gradient-to-t from-background to-transparent`}),(0,q.jsx)(`div`,{className:`pointer-events-auto relative`,children:(0,q.jsxs)(`div`,{className:`space-y-0 rounded-xl mx-auto max-w-[700px]`,children:[(0,q.jsx)(pi,{value:he,onChange:je,onKeyDown:tt,placeholder:`Commit message (override)`,className:`rounded-t-xl rounded-b-none px-3`,disabled:Ve||t.status!==`ready`}),(0,q.jsx)(Si,{value:ge,onChange:Me,onKeyDown:tt,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:Ve||t.status!==`ready`}),(0,q.jsx)(`div`,{className:`w-full flex flex-row`,children:(0,q.jsxs)(wn,{children:[(0,q.jsx)($t,{asChild:!0,children:(0,q.jsx)(a,{type:`button`,className:`-mt-px w-full rounded-xl`,disabled:ze?!$e:!Qe,onClick:()=>{if(ze){W(Ke);return}et()},children:(0,q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[lt,(0,q.jsx)(`span`,{className:`min-w-0 truncate text-left`,children:ut})]})})}),t.hasUpstream?(0,q.jsx)(Ut,{children:(0,q.jsx)(Qt,{disabled:!ze||!$e,onSelect:e=>{e.stopPropagation(),W(`commit_only`)},children:`Commit Only`})}):null]})})]})})]}):null]})]})]}),(0,q.jsx)(Up,{open:I,onOpenChange:B,onGetGitHubPublishInfo:x,onCheckGitHubRepoAvailability:S,onPublish:C,ports:k})]})})}var Xp=(0,K.memo)(Yp);function Zp(e={}){return(e.dom??o).getInnerWidth()}var Qp=c()(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:Zp(),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 $p(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function em(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function tm(e){return e/100*window.innerHeight}function nm(e){return e/100*window.innerWidth}function rm(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 im({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=rm(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=em(t,i);break;case`em`:r=$p(t,i);break;case`vh`:r=tm(i);break;case`vw`:r=nm(i)}return r}function am(e){return parseFloat(e.toFixed(3))}function om({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function sm(e){let{panels:t}=e,n=om({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=am(im({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=am(im({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=am(im({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=am(im({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function cm(e,t=`Assertion error`){if(!e)throw Error(t)}function lm(e,t){return Array.from(t).sort(e===`horizontal`?um:dm)}function um(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function dm(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function fm(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function pm(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 mm({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}=pm(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return cm(i,`No rect found`),i}var hm;function gm(){return hm===void 0&&(hm=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),hm}function _m(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=lm(n,Array.from(t.children).filter(fm).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,mm({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=gm()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:om({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var vm=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);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}}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)}}},ym={cursorFlags:0,state:`inactive`},bm=new vm;function xm(){return ym}function Sm(e){return bm.addListener(`change`,e)}function Cm(e){let t=ym,n={...ym};n.cursorFlags=e,ym=n,bm.emit(`change`,{prev:t,next:n})}function wm(e){let t=ym;ym=e,bm.emit(`change`,{prev:t,next:e})}var Tm=e=>e,Em=()=>{},Dm=1,Om=2,km=4,Am=8,jm=3,Mm=12,Nm;function Pm(){return Nm===void 0&&(Nm=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(Nm=!0)),Nm}function Fm({cursorFlags:e,groups: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&&Pm()){let t=(e&Dm)!==0,n=(e&Om)!==0,r=(e&km)!==0,i=(e&Am)!==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 Pm()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var Im=new WeakMap;function Lm(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=Im.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=xm();switch(r.state){case`active`:case`hover`:{let e=Fm({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),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)}Im.set(e,{prevStyle:t,styleSheet:n})}var Rm=new Map,zm=new vm;function Bm(e){Rm=new Map(Rm),Rm.delete(e)}function Vm(e,t){for(let[t]of Rm)if(t.id===e)return t}function Hm(e,t){for(let[t,n]of Rm)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Um(){return Rm}function Wm(e,t){return zm.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function Gm(e,t,n){let r=Rm.get(e);Rm=new Map(Rm),Rm.set(e,t),zm.emit(`groupChange`,{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function Km(e){let t=xm(),n=Um(),r=!1;return t.state===`active`&&(wm({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(Lm(e),r=!0,t.hitRegions.forEach(e=>{if(!n.has(e.group))return;let t=Hm(e.group.id,!0);Gm(e.group,t,{isUserInteraction:!0})}))),r}function qm(e){e.defaultPrevented||Km(e.currentTarget)}function Jm(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=pm(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t)}}return r?{distance:i,hitRegion:r}:void 0}function Ym(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Xm(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:nh(e),b:nh(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();cm(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:th(eh(n.a)),b:th(eh(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 Zm=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Qm(e){let t=getComputedStyle(rh(e)??e).display;return t===`flex`||t===`inline-flex`}function $m(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Qm(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`||Zm.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function eh(e){let t=e.length;for(;t--;){let n=e[t];if(cm(n,`Missing node`),$m(n))return n}return null}function th(e){return e&&Number(getComputedStyle(e).zIndex)||0}function nh(e){let t=[];for(;e;)t.push(e),e=rh(e);return t}function rh(e){let{parentNode:t}=e;return Ym(t)?t.host:t}function ih(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 ah({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!fm(n)||n.contains(e)||e.contains(n))return!0;if(Xm(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(ih(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function oh(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=_m(r),a=Jm(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&ah({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function sh(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 ch(e,t,n=0){return Math.abs(am(e)-am(t))<=n}function lh(e,t){return ch(e,t)?0:e>t?1:-1}function uh({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(lh(r,c)<0){if(a){let e=(i+c)/2;r=lh(r,e)<0?i:c}else r=c}return r=Math.min(s,r),r=am(r),r}function dh({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(ch(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;cm(u!=null,`Invalid first pivot index`),cm(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];cm(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(cm(n!=null,`Previous layout not found for panel index ${t}`),ch(n,i)){let t=o-n;lh(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];cm(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(cm(n!=null,`Previous layout not found for panel index ${t}`),ch(n,o)){let t=n-i;lh(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];cm(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&lh(i,c)<0){if(e>0){let t=c-o,n=t/2;lh(i+e,c)<0&&(e=lh(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;lh(i-e,c)<0&&(e=lh(100+e,n)>0?0:-t)}}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];cm(e!=null,`Previous layout not found for panel index ${r}`);let a=uh({overrideDisabledPanels:o,panelConstraints: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];cm(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=uh({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!ch(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(sh(c,l))return i;{let t=e<0?d:u,r=s[t];cm(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=uh({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!ch(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];cm(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=uh({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(ch(i,s)||(t-=s-i,l[r]=s),ch(t,0))break;e>0?r--:r++}}}if(!ch(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function fh(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||lh(e[n],t[n])!==0)return!1;return!0}function ph({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!ch(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];cm(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];cm(i!=null,`No layout data found for index ${e}`);let o=r[e];cm(o!=null,`No layout data found for index ${e}`);let s=uh({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!ch(a,0))for(let e=0;e<t.length;e++){let n=r[e];cm(n!=null,`No layout data found for index ${e}`);let i=n+a,o=uh({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,ch(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function mh({groupId:e,panelId:t}){let n=()=>{let t=Um();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:e,panels:n,prevLayout:r,derivedPanelConstraints:i})=>{let o=a(),s=n.findIndex(e=>e.id===t),c=s===0,l=s===n.length-1;if(l&&e<o&&(c||n.slice(0,s).every((e,t)=>{let n=i[t];return n?.collapsible&&ch(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:am(100-e)}}return dh({delta:l?o-e:e-o,initialLayout:r,panelConstraints:i,pivotIndices:l?[s-1,s]:[s,s+1],prevLayout:r,trigger:`imperative-api`})},s=e=>{if(e===a())return;let{defaultLayoutDeferred:t,derivedPanelConstraints:r,group:i,groupSize:s,layout:c,separatorToPanels:l}=n(),u=ph({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});fh(c,u)||Gm(i,{defaultLayoutDeferred:t,derivedPanelConstraints:r,groupSize:s,layout:u,separatorToPanels:l})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),o=a();e&&o!==t&&(n.expandToSize=o,s(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:o}=i(),c=a();if(e&&c===t){let e=o.expandToSize??n;e===0&&(e=1),s(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&ch(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=om({group:t}),o=am(im({groupSize:a,panelElement:r,styleProp:e})/a*100);s(o)}}}function hh(e){e.defaultPrevented||oh(e,Um()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=mh({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function gh(e){let t=Um();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 _h({groupId:e}){let t=()=>{let t=Um();for(let[n,r]of t)if(n.id===e)return{group: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{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=ph({layout:e,panelConstraints:r});return n?o:(fh(o,c)||Gm(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function vh(e,t){let n=gh(e),r=Hm(n.id,!0),i=n.separators.find(t=>t.element===e);cm(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);cm(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=_h({groupId:n.id}).getLayout(),c=ph({layout:dh({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});fh(s,c)||Gm(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function yh(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=gh(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&vh(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&vh(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&vh(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&vh(t,-5);break;case`End`:e.preventDefault(),vh(t,100);break;case`Enter`:{e.preventDefault();let n=gh(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=Hm(n.id,!0),o=n.separators.find(e=>e.element===t);cm(o,`Matching separator not found`);let s=a.get(o);cm(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(cm(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];vh(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=gh(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);cm(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),vh(t,-100)}}function bh(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Um(),n=oh(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),wm({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}function xh({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=dh({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(fh(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?Dm:Om;break;case`vertical`:s|=d<0?km:Am}}else Gm(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&jm:c|=s&jm,t.movementY===0?c|=o&Mm:c|=s&Mm,Cm(c),Lm(e)}function Sh(e){let t=Um(),n=xm();n.state===`active`&&xh({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}function Ch(e){if(e.defaultPrevented)return;let t=xm(),n=Um();switch(t.state){case`active`:if(e.buttons===0){wm({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{if(!n.has(e.group))return;let t=Hm(e.group.id,!0);Gm(e.group,t,{isUserInteraction:!0})});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}xh({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=oh(e,n);r.length===0?t.state!==`inactive`&&wm({cursorFlags:0,state:`inactive`}):wm({cursorFlags:0,hitRegions:r,state:`hover`}),Lm(e.currentTarget);break}}}function wh(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(xm().state){case`hover`:wm({cursorFlags:0,state:`inactive`})}}function Th(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||Km(e.currentTarget)&&e.preventDefault()}function Eh(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=am(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=am((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function Dh(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=om({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:am(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function Oh(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 kh(e,t){return e.length===t.length&&e.every((e,n)=>Oh(e,t[n]))}function Ah({group:e,nextGroupSize:t,prevGroupSize: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.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=am(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]=am((r[e]??0)/a*l);else{let e=am(l/c.length);for(let t of c)u[t]=e}return u}function jh(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}var Mh=new Map;function Nh(e){let t=!0;cm(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=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=om({group:e});if(t===0)return;let n=Hm(e.id);if(!n)return;let r=sm(e),i=n.defaultLayoutDeferred?Eh(r):n.layout,a=ph({layout:Ah({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&fh(n.layout,a)&&kh(n.derivedPanelConstraints,r)&&n.groupSize===t)continue;Gm(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else Dh(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{cm(!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=om({group:e}),s=sm(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(jh(e.panels,l)||(l=void 0));let u=ph({layout:e.mutableState.layouts[c]??l??Eh(s),panelConstraints:s}),d=e.element.ownerDocument;Mh.set(d,(Mh.get(d)??0)+1);let f=new Map;return _m(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),Gm(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{cm(!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`,yh)}),Mh.get(d)===1&&(d.addEventListener(`contextmenu`,qm,!0),d.addEventListener(`dblclick`,hh,!0),d.addEventListener(`pointerdown`,bh,!0),d.addEventListener(`pointerleave`,Sh),d.addEventListener(`pointermove`,Ch),d.addEventListener(`pointerout`,wh),d.addEventListener(`pointerup`,Th,!0)),function(){t=!1,Mh.set(d,Math.max(0,(Mh.get(d)??0)-1)),Bm(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,yh)}),Mh.get(d)||(d.removeEventListener(`contextmenu`,qm,!0),d.removeEventListener(`dblclick`,hh,!0),d.removeEventListener(`pointerdown`,bh,!0),d.removeEventListener(`pointerleave`,Sh),d.removeEventListener(`pointermove`,Ch),d.removeEventListener(`pointerout`,wh),d.removeEventListener(`pointerup`,Th,!0)),a.disconnect()}}function Ph(){let[e,t]=(0,K.useState)({});return[e,(0,K.useCallback)(()=>t({}),[])]}function Fh(e){let t=(0,K.useId)();return`${e??t}`}var Ih=typeof window<`u`?K.useLayoutEffect:K.useEffect;function Lh(e){let t=(0,K.useRef)(e);return Ih(()=>{t.current=e},[e]),(0,K.useCallback)((...e)=>t.current?.(...e),[t])}function Rh(...e){return Lh(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t}})})}function zh(e){let t=(0,K.useRef)({...e});return Ih(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var Bh=(0,K.createContext)(null);function Vh(e,t){let n=(0,K.useRef)({getLayout:()=>({}),setLayout:Tm});(0,K.useImperativeHandle)(t,()=>n.current,[]),Ih(()=>{Object.assign(n.current,_h({groupId:e}))})}function Hh({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,K.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=Lh(e=>{fh(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=Lh((e,t)=>{fh(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t}))}),_=Fh(s),v=(0,K.useRef)(null),[y,b]=Ph(),x=(0,K.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=Rh(v,a);Vh(_,o);let C=Lh((e,t)=>{let r=xm(),i=Vm(e),a=Hm(e);if(a){let e=!1;return r.state===`active`&&(e=r.hitRegions.some(e=>e.group===i)),{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=zh({defaultLayout:n,disableCursor:r}),T=(0,K.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=lm(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=lm(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=Vm(_),i=Hm(_);r&&i&&Gm(r,{...i,derivedPanelConstraints:sm(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,K.useRef)(null);return Ih(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=Nh(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=Hm(r.id,!0);!o&&s.length>0&&(h(c),g(c,!1));let l=Wm(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=ch(t.collapsedSize,i[t.panelId]),a=ch(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=xm().state!==`active`;h(i),o&&g(i,e.isUserInteraction)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,K.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,q.jsx)(Bh.Provider,{value:T,children:(0,q.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}Hh.displayName=`Group`;function Uh(){let e=(0,K.useContext)(Bh);return cm(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Wh(e,t){let{id:n}=Uh(),r=(0,K.useRef)({collapse:Em,expand:Em,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Em});(0,K.useImperativeHandle)(t,()=>r.current,[]),Ih(()=>{Object.assign(r.current,mh({groupId:n,panelId:e}))})}function Gh({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=Fh(c),_=zh({disabled:a}),v=(0,K.useRef)(null),y=Rh(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=Uh(),T=d!==null,E=Lh((e,t,n)=>{d?.(e,c,n)});Ih(()=>{let e=v.current;if(e!==null){let t={element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}};return C(t)}},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,K.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),Wh(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,K.useSyncExternalStore)(e=>Wm(x,e),D,D),k;return k=O?JSON.parse(O):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,q.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...Kh,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,q.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}Gh.displayName=`Panel`;var Kh={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function qh({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=ph({layout:dh({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=ph({layout:dh({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Jh({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=Fh(a),l=zh({disabled:n,disableDoubleClick:r}),[u,d]=(0,K.useState)({}),[f,p]=(0,K.useState)(`inactive`),[m,h]=(0,K.useState)(!1),g=(0,K.useRef)(null),_=Rh(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=Uh(),C=b===`horizontal`?`vertical`:`horizontal`;Ih(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=Sm(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=Wm(y,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(qh({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,K.useEffect)(()=>{S(c,{disabled:n,disableDoubleClick:r})},[n,r,c,S]);let w;n&&!v&&(w=`not-allowed`);let T;if(n)T=`disabled`;else switch(f){case`active`:T=`active`;break;default:T=m?`focus`:f}return(0,q.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":C,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":T,"data-testid":c,id:c,onBlur:()=>h(!1),onFocus:()=>h(!0),ref:_,role:`separator`,style:{flexBasis:`auto`,cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}Jh.displayName=`Separator`;var Yh=({className:e,...t})=>(0,q.jsx)(Hh,{className:u(`flex h-full w-full`,e),...t}),Xh=e=>(0,q.jsx)(Gh,{...e}),Zh={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`},Qh={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`},$h=`before:bg-border before:transition-colors data-[separator=hover]:before:bg-ring data-[separator=active]:before:bg-ring focus-visible:before:bg-ring`,eg=({withHandle:e,orientation:t,disabled:n,className:r,...i})=>(0,q.jsx)(Jh,{disabled:n,className:u(`relative flex items-center justify-center bg-transparent focus-visible:outline-none`,Zh[t],e&&Qh[t],e&&$h,r),...i,children:(0,q.jsx)(`span`,{className:`sr-only`,children:t===`vertical`?`Resize rows`:`Resize columns`})}),tg=0,ng=0,rg=0,ig=0,ag;(e=>{function t(e,t,n,r){return r===void 0?`#${ug(e)}${ug(t)}${ug(n)}`:`#${ug(e)}${ug(t)}${ug(n)}${ug(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})(ag||={});var og;(e=>{function t(e,t){if(ig=(t.rgba&255)/255,ig===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 tg=a+Math.round((n-a)*ig),ng=o+Math.round((r-o)*ig),rg=s+Math.round((i-s)*ig),{css:ag.toCss(tg,ng,rg),rgba:ag.toRgba(tg,ng,rg)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=lg.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return ag.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[tg,ng,rg]=lg.toChannels(t),{css:ag.toCss(tg,ng,rg),rgba:t}}e.opaque=i;function a(e,t){return ig=Math.round(t*255),[tg,ng,rg]=lg.toChannels(e.rgba),{css:ag.toCss(tg,ng,rg,ig),rgba:ag.toRgba(tg,ng,rg,ig)}}e.opacity=a;function o(e,t){return ig=e.rgba&255,a(e,ig*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(og||={});var sg;(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 tg=parseInt(e.slice(1,2).repeat(2),16),ng=parseInt(e.slice(2,3).repeat(2),16),rg=parseInt(e.slice(3,4).repeat(2),16),ag.toColor(tg,ng,rg);case 5:return tg=parseInt(e.slice(1,2).repeat(2),16),ng=parseInt(e.slice(2,3).repeat(2),16),rg=parseInt(e.slice(3,4).repeat(2),16),ig=parseInt(e.slice(4,5).repeat(2),16),ag.toColor(tg,ng,rg,ig);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 tg=parseInt(r[1]),ng=parseInt(r[2]),rg=parseInt(r[3]),ig=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),ag.toColor(tg,ng,rg,ig);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[tg,ng,rg,ig]=t.getImageData(0,0,1,1).data,ig!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:ag.toRgba(tg,ng,rg,ig),css:e}}e.toColor=r})(sg||={});var cg;(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})(cg||={});var lg;(e=>{function t(e,t){if(ig=(t&255)/255,ig===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 tg=a+Math.round((n-a)*ig),ng=o+Math.round((r-o)*ig),rg=s+Math.round((i-s)*ig),ag.toRgba(tg,ng,rg)}e.blend=t;function n(e,t,n){let a=cg.relativeLuminance(e>>8),o=cg.relativeLuminance(t>>8);if(dg(a,o)<n){if(o<a){let o=r(e,t,n),s=dg(a,cg.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>dg(a,cg.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=dg(a,cg.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>dg(a,cg.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=dg(cg.relativeLuminance2(o,s,c),cg.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=dg(cg.relativeLuminance2(o,s,c),cg.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=dg(cg.relativeLuminance2(o,s,c),cg.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=dg(cg.relativeLuminance2(o,s,c),cg.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})(lg||={});function ug(e){let t=e.toString(16);return t.length<2?`0`+t:t}function dg(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var fg=Object.freeze((()=>{let e=[sg.toColor(`#2e3436`),sg.toColor(`#cc0000`),sg.toColor(`#4e9a06`),sg.toColor(`#c4a000`),sg.toColor(`#3465a4`),sg.toColor(`#75507b`),sg.toColor(`#06989a`),sg.toColor(`#d3d7cf`),sg.toColor(`#555753`),sg.toColor(`#ef2929`),sg.toColor(`#8ae234`),sg.toColor(`#fce94f`),sg.toColor(`#729fcf`),sg.toColor(`#ad7fa8`),sg.toColor(`#34e2e2`),sg.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:ag.toCss(r,i,a),rgba:ag.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:ag.toCss(n,n,n),rgba:ag.toRgba(n,n,n)})}return e})());function pg(e,t,n){return Math.max(t,Math.min(e,n))}function mg(e){switch(e){case`&`:return`&amp;`;case`<`:return`&lt;`}return e}var hg=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);if(!o){console.warn(`Can't get cell at row=${t}, col=${e}`);continue}this._nextCell(o,i,t,e),i=o}}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 gg(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function _g(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function vg(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 yg=class extends hg{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&&!_g(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)&&_g(i,o)&&(c=!0),s&&(a.getChars()||a.getWidth()===0)&&_g(i,o)&&_g(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=!gg(e,t),i=!_g(e,t),a=!vg(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?!_g(this._cursorStyle,e):a.length>0){this._nullCellCount>0&&(_g(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&&(_g(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}},bg=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let r=t.length,i=n===void 0?r:pg(n+e.rows,0,r);return this._serializeBufferByRange(e,t,{start:r-i,end:r-1},!1)}_serializeBufferByRange(e,t,n,r){return new yg(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 xg(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:pg(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(){}},xg=class extends hg{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:fg}_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=!gg(e,t),i=!_g(e,t),a=!vg(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+=mg(e.getChars())}_serializeString(){return this._htmlContent}},Sg=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=wg.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 Cg(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 wg=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(!Cg(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]}},Tg=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Eg(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 Dg=class{constructor(e=Eg,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||Tg;this._linkProvider=this._terminal.registerLinkProvider(new Sg(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},Og=Object.defineProperty,kg=Object.getOwnPropertyDescriptor,Ag=(e,t)=>{for(var n in t)Og(e,n,{get:t[n],enumerable:!0})},jg=(e,t,n,r)=>{for(var i=r>1?void 0:r?kg(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&&Og(t,n,i),i},Z=(e,t)=>(n,r)=>t(n,r,e),Mg=`Terminal input`,Ng={get:()=>Mg,set:e=>Mg=e},Pg=`Too much output to announce, navigate to rows manually to read`,Fg={get:()=>Pg,set:e=>Pg=e};function Ig(e){return e.replace(/\r?\n/g,`\r`)}function Lg(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Rg(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function zg(e,t,n,r){e.stopPropagation(),e.clipboardData&&Bg(e.clipboardData.getData(`text/plain`),t,n,r)}function Bg(e,t,n,r){e=Ig(e),e=Lg(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Vg(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 Hg(e,t,n,r,i){Vg(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ug(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Wg(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 Gg=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);continue}i!==65279&&(t[r++]=i)}return r}},Kg=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){d--;continue}if(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}},qg=``,Jg=` `,Yg=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Xg}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}},Xg=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}},Zg=class e extends Yg{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Xg,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?Ug(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()]}},Qg=`di$target`,$g=`di$dependencies`,e_=new Map;function t_(e){return e[$g]||[]}function n_(e){if(e_.has(e))return e_.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);r_(t,e,r)};return t._id=e,e_.set(e,t),t}function r_(e,t,n){t[Qg]===t?t[$g].push({id:e,index:n}):(t[$g]=[{id:e,index:n}],t[Qg]=t)}var i_=n_(`BufferService`),a_=n_(`CoreMouseService`),o_=n_(`CoreService`),s_=n_(`CharsetService`),c_=n_(`InstantiationService`),l_=n_(`LogService`),u_=n_(`OptionsService`),d_=n_(`OscLinkService`),f_=n_(`UnicodeService`),p_=n_(`DecorationService`),m_=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 Zg,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):h_(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)}};m_=jg([Z(0,i_),Z(1,u_),Z(2,d_)],m_);function h_(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 g_=n_(`CharSizeService`),__=n_(`CoreBrowserService`),v_=n_(`MouseService`),y_=n_(`RenderService`),b_=n_(`SelectionService`),x_=n_(`CharacterJoinerService`),S_=n_(`ThemeService`),C_=n_(`LinkProviderService`),w_=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?A_.isErrorNoTelemetry(e)?new A_(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 T_(e){D_(e)||w_.onUnexpectedError(e)}var E_=`Canceled`;function D_(e){return e instanceof O_||e instanceof Error&&e.name===E_&&e.message===E_}var O_=class extends Error{constructor(){super(E_),this.name=this.message}};function k_(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var A_=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`}},j_=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function M_(e,t=0){return e[e.length-(1+t)]}var N_;(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})(N_||={});var P_=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||N_.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};P_.empty=new P_(e=>{});function F_(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 I_;(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})(I_||={});var L_=null;function R_(e){return L_?.trackDisposable(e),e}function z_(e){L_?.markAsDisposed(e)}function B_(e,t){L_?.setParent(e,t)}function V_(e){return L_?.markAsSingleton(e),e}function H_(e){if(I_.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 U_(...e){return W_(()=>H_(e))}function W_(e){let t=R_({dispose:F_(()=>{z_(t),e()})});return t}var G_=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,R_(this)}dispose(){this._isDisposed||(z_(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{H_(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return B_(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),B_(e,null))}};G_.DISABLE_DISPOSED_WARNING=!1;var K_=G_,q_=class{constructor(){this._store=new K_,R_(this),B_(this._store,this)}dispose(){z_(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};q_.None=Object.freeze({dispose(){}});var J_=class{constructor(){this._isDisposed=!1,R_(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&B_(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,z_(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&B_(e,null),e}},Y_=typeof window==`object`?window:globalThis,X_=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};X_.Undefined=new X_(void 0);var Z_=X_,Q_=class{constructor(){this._first=Z_.Undefined,this._last=Z_.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Z_.Undefined}clear(){let e=this._first;for(;e!==Z_.Undefined;){let t=e.next;e.prev=Z_.Undefined,e.next=Z_.Undefined,e=t}this._first=Z_.Undefined,this._last=Z_.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Z_(e);if(this._first===Z_.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!==Z_.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Z_.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Z_.Undefined&&e.next!==Z_.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Z_.Undefined&&e.next===Z_.Undefined?(this._first=Z_.Undefined,this._last=Z_.Undefined):e.next===Z_.Undefined?(this._last=this._last.prev,this._last.next=Z_.Undefined):e.prev===Z_.Undefined&&(this._first=this._first.next,this._first.prev=Z_.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==Z_.Undefined;)yield e.element,e=e.next}},$_=globalThis.performance&&typeof globalThis.performance.now==`function`,ev=class e{static create(t){return new e(t)}constructor(e){this._now=$_&&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}},tv;(e=>{e.None=()=>q_.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(U_(...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 Q({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 Q({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 Q({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 Q({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 Q({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 Q;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 Q(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 K_?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(tv||={});var nv=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 ev,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}}};nv.all=new Set,nv._idPool=0;var rv=nv,iv=-1,av=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 cv(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}};av._idPool=1;var ov=av,sv=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
+ `))}},cv=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},lv=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},uv=0,dv=class{constructor(e){this.value=e,this.id=uv++}},fv=2,Q=class{constructor(e){this._size=0,this._options=e,this._leakageMon=iv>0||this._options?.leakWarningThreshold?new ov(e?.onListenerError??T_,this._options?.leakWarningThreshold??iv):void 0,this._perfMon=this._options?._profName?new rv(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 lv(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||T_)(n),q_.None}if(this._disposed)return q_.None;t&&(e=e.bind(t));let r=new dv(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=sv.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof dv?(this._deliveryQueue??=new pv,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=W_(()=>{i?.(),this._removeListener(r)});return n instanceof K_?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*fv<=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||T_;if(!n){e.value(t);return}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 dv)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}},pv=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}},mv=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Q,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}};mv.INSTANCE=new mv;var hv=mv;function gv(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}hv.INSTANCE.onDidChangeZoomLevel;function _v(e){return hv.INSTANCE.getZoomFactor(e)}hv.INSTANCE.onDidChangeFullscreen;var vv=typeof navigator==`object`?navigator.userAgent:``,yv=vv.indexOf(`Firefox`)>=0,bv=vv.indexOf(`AppleWebKit`)>=0,xv=vv.indexOf(`Chrome`)>=0,Sv=!xv&&vv.indexOf(`Safari`)>=0;vv.indexOf(`Electron/`),vv.indexOf(`Android`);var Cv=!1;if(typeof Y_.matchMedia==`function`){let e=Y_.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=Y_.matchMedia(`(display-mode: fullscreen)`);Cv=e.matches,gv(Y_,e,({matches:e})=>{Cv&&t.matches||(Cv=e)})}function wv(){return Cv}var Tv=`en`,Ev=!1,Dv=!1,Ov=!1,kv=!1,Av=!1,jv=Tv,Mv,Nv=globalThis,Pv;typeof Nv.vscode<`u`&&typeof Nv.vscode.process<`u`?Pv=Nv.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Pv=process);var Fv=typeof Pv?.versions?.electron==`string`&&Pv?.type===`renderer`;if(typeof Pv==`object`){Ev=Pv.platform===`win32`,Dv=Pv.platform===`darwin`,Ov=Pv.platform===`linux`,Ov&&Pv.env.SNAP&&Pv.env.SNAP_REVISION,Pv.env.CI||Pv.env.BUILD_ARTIFACTSTAGINGDIRECTORY,jv=Tv;let e=Pv.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,jv=t.resolvedLanguage||Tv,t.languagePack?.translationsConfigFile}catch{}kv=!0}else typeof navigator==`object`&&!Fv?(Mv=navigator.userAgent,Ev=Mv.indexOf(`Windows`)>=0,Dv=Mv.indexOf(`Macintosh`)>=0,(Mv.indexOf(`Macintosh`)>=0||Mv.indexOf(`iPad`)>=0||Mv.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Ov=Mv.indexOf(`Linux`)>=0,Mv?.indexOf(`Mobi`),Av=!0,jv=globalThis._VSCODE_NLS_LANGUAGE||Tv,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var Iv=Ev,Lv=Dv,Rv=Ov,zv=kv;Av&&typeof Nv.importScripts==`function`&&Nv.origin;var Bv=Mv,Vv=jv,Hv;(e=>{function t(){return Vv}e.value=t;function n(){return Vv.length===2?Vv===`en`:Vv.length>=3&&Vv[0]===`e`&&Vv[1]===`n`&&Vv[2]===`-`}e.isDefaultVariant=n;function r(){return Vv===`en`}e.isDefault=r})(Hv||={});var Uv=typeof Nv.postMessage==`function`&&!Nv.importScripts;(()=>{if(Uv){let e=[];Nv.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}),Nv.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var Wv=!!(Bv&&Bv.indexOf(`Chrome`)>=0);Bv&&Bv.indexOf(`Firefox`),!Wv&&Bv&&Bv.indexOf(`Safari`),Bv&&Bv.indexOf(`Edg/`),Bv&&Bv.indexOf(`Android`);var Gv=typeof navigator==`object`?navigator:{};zv||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||Gv&&Gv.clipboard&&Gv.clipboard.writeText,zv||Gv&&Gv.clipboard&&Gv.clipboard.readText,zv||wv()||Gv.keyboard,`ontouchstart`in Y_||Gv.maxTouchPoints,Y_.PointerEvent&&(`ontouchstart`in Y_||navigator.maxTouchPoints);var Kv=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}},qv=new Kv,Jv=new Kv,Yv=new Kv,Xv=Array(230),Zv;(e=>{function t(e){return qv.keyCodeToStr(e)}e.toString=t;function n(e){return qv.strToKeyCode(e)}e.fromString=n;function r(e){return Jv.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return Yv.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return Jv.strToKeyCode(e)||Yv.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 qv.keyCodeToStr(e)}e.toElectronAccelerator=o})(Zv||={});var Qv=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 $v([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},$v=class{constructor(e){if(e.length===0)throw k_(`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 ey(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return Zv.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(yv)switch(t){case 59:return 85;case 60:if(Rv)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Lv)return 57}else if(bv&&(Lv&&t===93||!Lv&&t===92))return 57;return Xv[t]||0}var ty=Lv?256:2048,ny=512,ry=1024,iy=Lv?2048:256,ay=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=ey(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|=ty),this.altKey&&(t|=ny),this.shiftKey&&(t|=ry),this.metaKey&&(t|=iy),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Qv(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},oy=new WeakMap;function sy(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 cy=class{static getSameOriginWindowChain(e){let t=oy.get(e);if(!t){t=[],oy.set(e,t);let n=e,r;do r=sy(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}}},ly=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=cy.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},uy=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(xv){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?yv&&!Lv?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=Sv&&Iv?-(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?yv&&!Lv?-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()}},dy=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),fy;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof py?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:tv.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:dy})})(fy||={});var py=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?dy:(this._emitter||=new Q,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},my=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 j_(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new j_(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},hy=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 j_(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=W_(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var gy;(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})(gy||={});var _y=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 Q,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 tv.toPromise(this._onStateChanged.event)}while(!0)},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())}};_y.EMPTY=_y.fromArray([]);function vy(e){return yy(e,0)}function yy(e,t){switch(typeof e){case`object`:return e===null?by(349,t):Array.isArray(e)?Cy(e,t):wy(e,t);case`string`:return Sy(e,t);case`boolean`:return xy(e,t);case`number`:return by(e,t);case`undefined`:return by(937,t);default:return by(617,t)}}function by(e,t){return(t<<5)-t+e|0}function xy(e,t){return by(e?433:863,t)}function Sy(e,t){t=by(149417,t);for(let n=0,r=e.length;n<r;n++)t=by(e.charCodeAt(n),t);return t}function Cy(e,t){return t=by(104579,t),e.reduce((e,t)=>yy(t,e),t)}function wy(e,t){return t=by(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Sy(n,t),yy(e[n],t)),t)}var{registerWindow:Ty,getWindow:Ey,getDocument:Dy,getWindows:Oy,getWindowsCount:ky,getWindowId:Ay,getWindowById:jy,hasWindow:My,onDidRegisterWindow:Ny,onWillUnregisterWindow:Py,onDidUnregisterWindow:Fy}=function(){let e=new Map,t={window:Y_,disposables:new K_};e.set(Y_.vscodeWindowId,t);let n=new Q,r=new Q,i=new Q;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 q_.None;let a=new K_,o={window:t,disposables:a.add(new K_)};return e.set(t.vscodeWindowId,o),a.add(W_(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(Ly(t,Ky.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:Y_},getDocument(e){return Ey(e).document}}}(),Iy=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 Ly(e,t,n,r){return new Iy(e,t,n,r)}function Ry(e,t){return function(n){return t(new ly(e,n))}}function zy(e){return function(t){return e(new ay(t))}}var By=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=Ry(Ey(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=zy(n)),Ly(e,t,i,r)},Vy,Hy=class extends hy{constructor(e){super(),this.defaultTarget=e&&Ey(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Uy=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){T_(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(Uy.sort),a.shift().execute();r.set(i,!1)};Vy=(t,r,a=0)=>{let o=Ay(t),s=new Uy(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 Wy=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}};Wy.None=new Wy(0,0);function Gy(e){let t=e.getBoundingClientRect(),n=Ey(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=vy(n),a=r.get(i);if(a)a.users+=1;else{let o=new Q,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(W_(()=>{--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 Ky={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:bv?`webkitAnimationStart`:`animationstart`,ANIMATION_END:bv?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:bv?`webkitAnimationIteration`:`animationiteration`},qy=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=Jy(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Jy(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Jy(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Jy(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Jy(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Jy(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Jy(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Jy(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Jy(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Jy(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Jy(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=Jy(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=Jy(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Jy(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 Jy(e){return typeof e==`number`?`${e}px`:e}function Yy(e){return new qy(e)}var Xy=class{constructor(){this._hooks=new K_,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(W_(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Ey(e)}this._hooks.add(Ly(a,Ky.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(Ly(a,Ky.POINTER_UP,e=>this.stopMonitoring(!0)))}};function Zy(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 Qy;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(Qy||={});var $y=class e extends q_{constructor(){super(),this.dispatched=!1,this.targets=new Q_,this.ignoreTargets=new Q_,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(tv.runAndSubscribe(Ny,({window:e,disposables:t})=>{t.add(Ly(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(Ly(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(Ly(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:Y_,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=V_(new e),W_(e.INSTANCE.targets.push(t))):q_.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=V_(new e),W_(e.INSTANCE.ignoreTargets.push(t))):q_.None}static isTouchDevice(){return`ontouchstart`in Y_||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(Qy.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-M_(s.rollingPageX))<30&&Math.abs(s.initialPageY-M_(s.rollingPageY))<30){let e=this.newGestureEvent(Qy.Tap,s.initialTarget);e.pageX=M_(s.rollingPageX),e.pageY=M_(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-M_(s.rollingPageX))<30&&Math.abs(s.initialPageY-M_(s.rollingPageY))<30){let e=this.newGestureEvent(Qy.Contextmenu,s.initialTarget);e.pageX=M_(s.rollingPageX),e.pageY=M_(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=M_(s.rollingPageX),n=M_(s.rollingPageY),i=M_(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(Qy.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===Qy.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===Qy.Change||t.type===Qy.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=Vy(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(Qy.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(Qy.Change,i.initialTarget);a.translationX=r.pageX-M_(i.rollingPageX),a.translationY=r.pageY-M_(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)}};$y.SCROLL_FRICTION=-.005,$y.HOLD_DELAY=700,$y.CLEAR_TAP_COUNT_TIME=400,jg([Zy],$y,`isTouchDevice`,1);var eb=$y,tb=class extends q_{onclick(e,t){this._register(Ly(e,Ky.CLICK,n=>t(new ly(Ey(e),n))))}onmousedown(e,t){this._register(Ly(e,Ky.MOUSE_DOWN,n=>t(new ly(Ey(e),n))))}onmouseover(e,t){this._register(Ly(e,Ky.MOUSE_OVER,n=>t(new ly(Ey(e),n))))}onmouseleave(e,t){this._register(Ly(e,Ky.MOUSE_LEAVE,n=>t(new ly(Ey(e),n))))}onkeydown(e,t){this._register(Ly(e,Ky.KEY_DOWN,e=>t(new ay(e))))}onkeyup(e,t){this._register(Ly(e,Ky.KEY_UP,e=>t(new ay(e))))}oninput(e,t){this._register(Ly(e,Ky.INPUT,t))}onblur(e,t){this._register(Ly(e,Ky.BLUR,t))}onfocus(e,t){this._register(Ly(e,Ky.FOCUS,t))}onchange(e,t){this._register(Ly(e,Ky.CHANGE,t))}ignoreGesture(e){return eb.ignoreTarget(e)}},nb=11,rb=class extends tb{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=nb+`px`,this.domNode.style.height=nb+`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 Xy),this._register(By(this.bgDomNode,Ky.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(By(this.domNode,Ky.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new Hy),this._pointerdownScheduleRepeatTimer=this._register(new my)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Ey(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},ib=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}}},ab=class extends q_{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new ib(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 lb(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=lb.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)))}},ob=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function sb(e,t){let n=t-e;return function(t){return e+n*db(t)}}function cb(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var lb=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),cb(sb(e,r),sb(i,t),.33)}return sb(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 ob(this.scrollLeft(t),this.scrollTop(t),!1):new ob(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 ub(e){return e**3}function db(e){return 1-ub(1-e)}var fb=class extends q_{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 my)}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(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_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`:``)))}},pb=140,mb=class extends tb{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 fb(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Xy),this._shouldRender=!0,this.domNode=Yy(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(Ly(this.domNode.domNode,Ky.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new rb(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Yy(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(Ly(this.slider.domNode,Ky.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=Gy(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(Iv&&a>pb){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()}},hb=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)}},gb=class extends mb{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new hb(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}},_b=class extends mb{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new hb(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}},vb=500,yb=50,bb=!0,xb=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Sb=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(!0);return t<=.5}acceptStandardWheelEvent(e){if(xv){let t=_v(Ey(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 xb(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}};Sb.INSTANCE=new Sb;var Cb=Sb,wb=class extends tb{constructor(e,t,n){super(),this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Q),this.onWillScroll=this._onWillScroll.event,this._options=Eb(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 _b(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new gb(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=Yy(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Yy(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Yy(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 my),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=H_(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,Lv&&(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 uy(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=H_(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(Ly(this._listenOnDomNode,Ky.MOUSE_WHEEL,e=>{this._onMouseWheel(new uy(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=Cb.INSTANCE;bb&&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=!Lv&&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=yb*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=yb*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)&&(bb&&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(),vb)}},Tb=class extends wb{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 Eb(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,Lv&&(t.className+=` mac`),t}var Db=class extends q_{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new ab({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>Vy(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Tb(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(tv.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(W_(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(W_(()=>this._styleElement.remove())),this._register(tv.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}};Db=jg([Z(2,i_),Z(3,__),Z(4,a_),Z(5,S_),Z(6,u_),Z(7,y_)],Db);var Ob=class extends q_{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(W_(()=>{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()}};Ob=jg([Z(1,i_),Z(2,__),Z(3,p_),Z(4,y_)],Ob);var kb=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)}},Ab={full:0,left:0,center:0,right:0},jb={full:0,left:0,center:0,right:0},Mb={full:0,left:0,center:0,right:0},Nb=class extends q_{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 kb,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(W_(()=>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);jb.full=this._canvas.width,jb.left=e,jb.center=t,jb.right=e,this._refreshDrawHeightConstants(),Mb.full=1,Mb.left=1,Mb.center=1+jb.left,Mb.right=1+jb.left+jb.center}_refreshDrawHeightConstants(){Ab.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);Ab.left=t,Ab.center=t,Ab.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ab.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ab.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ab.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ab.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(Mb[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ab[e.position||`full`]/2),jb[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ab[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}))}};Nb=jg([Z(2,i_),Z(3,p_),Z(4,y_),Z(5,u_),Z(6,S_),Z(7,__)],Nb);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 Pb;(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=`Ÿ`))(Pb||={});var Fb;(e=>e.ST=`${$.ESC}\\`)(Fb||={});var Ib=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)}}};Ib=jg([Z(2,i_),Z(3,u_),Z(4,o_),Z(5,y_)],Ib);var Lb=0,Rb=0,zb=0,Bb=0,Vb={css:`#00000000`,rgba:0},Hb;(e=>{function t(e,t,n,r){return r===void 0?`#${qb(e)}${qb(t)}${qb(n)}`:`#${qb(e)}${qb(t)}${qb(n)}${qb(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})(Hb||={});var Ub;(e=>{function t(e,t){if(Bb=(t.rgba&255)/255,Bb===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 Lb=a+Math.round((n-a)*Bb),Rb=o+Math.round((r-o)*Bb),zb=s+Math.round((i-s)*Bb),{css:Hb.toCss(Lb,Rb,zb),rgba:Hb.toRgba(Lb,Rb,zb)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Kb.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return Hb.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Lb,Rb,zb]=Kb.toChannels(t),{css:Hb.toCss(Lb,Rb,zb),rgba:t}}e.opaque=i;function a(e,t){return Bb=Math.round(t*255),[Lb,Rb,zb]=Kb.toChannels(e.rgba),{css:Hb.toCss(Lb,Rb,zb,Bb),rgba:Hb.toRgba(Lb,Rb,zb,Bb)}}e.opacity=a;function o(e,t){return Bb=e.rgba&255,a(e,Bb*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(Ub||={});var Wb;(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 Lb=parseInt(e.slice(1,2).repeat(2),16),Rb=parseInt(e.slice(2,3).repeat(2),16),zb=parseInt(e.slice(3,4).repeat(2),16),Hb.toColor(Lb,Rb,zb);case 5:return Lb=parseInt(e.slice(1,2).repeat(2),16),Rb=parseInt(e.slice(2,3).repeat(2),16),zb=parseInt(e.slice(3,4).repeat(2),16),Bb=parseInt(e.slice(4,5).repeat(2),16),Hb.toColor(Lb,Rb,zb,Bb);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 Lb=parseInt(r[1]),Rb=parseInt(r[2]),zb=parseInt(r[3]),Bb=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),Hb.toColor(Lb,Rb,zb,Bb);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Lb,Rb,zb,Bb]=t.getImageData(0,0,1,1).data,Bb!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:Hb.toRgba(Lb,Rb,zb,Bb),css:e}}e.toColor=r})(Wb||={});var Gb;(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})(Gb||={});var Kb;(e=>{function t(e,t){if(Bb=(t&255)/255,Bb===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 Lb=a+Math.round((n-a)*Bb),Rb=o+Math.round((r-o)*Bb),zb=s+Math.round((i-s)*Bb),Hb.toRgba(Lb,Rb,zb)}e.blend=t;function n(e,t,n){let a=Gb.relativeLuminance(e>>8),o=Gb.relativeLuminance(t>>8);if(Jb(a,o)<n){if(o<a){let o=r(e,t,n),s=Jb(a,Gb.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>Jb(a,Gb.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Jb(a,Gb.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>Jb(a,Gb.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=Jb(Gb.relativeLuminance2(o,s,c),Gb.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=Jb(Gb.relativeLuminance2(o,s,c),Gb.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=Jb(Gb.relativeLuminance2(o,s,c),Gb.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=Jb(Gb.relativeLuminance2(o,s,c),Gb.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})(Kb||={});function qb(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Jb(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Yb=class extends Yg{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()]}},Xb=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Zg}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||Jg.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++)Xb._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||Jg.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}};Xb=jg([Z(0,i_)],Xb);function Zb(e){return 57508<=e&&e<=57558}function Qb(e){return 9472<=e&&e<=9631}function $b(e){return Zb(e)||Qb(e)}function ex(){return{css:{canvas:tx(),cell:tx()},device:{canvas:tx(),cell:tx(),char:{width:0,height:0,left:0,top:0}}}}function tx(){return{width:0,height:0}}var nx=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 Zg,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 Yb(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,L=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{L=!0});let ee=N.getChars()||Jg;if(ee===` `&&(N.isUnderline()||N.isOverline())&&(ee=`\xA0`),T=m*s-c.get(ee,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&&!L&&j){N.isInvisible()?_+=Jg:_+=ee,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()?Jg:N.getChars()||Jg,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault())){if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${Yg.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(),z=N.getFgColorMode(),te=N.getBgColor(),ne=N.getBgColorMode(),B=!!N.isInverse();if(B){let e=R;R=te,te=e;let t=z;z=ne,ne=t}let V,re,ie=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&ie||(e.backgroundColorRGB&&(ne=50331648,te=e.backgroundColorRGB.rgba>>8&16777215,V=e.backgroundColorRGB),e.foregroundColorRGB&&(z=50331648,R=e.foregroundColorRGB.rgba>>8&16777215,re=e.foregroundColorRGB),ie=e.options.layer===`top`)}),!ie&&P&&(V=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,te=V.rgba>>8&16777215,ne=50331648,ie=!0,p.selectionForeground&&(z=50331648,R=p.selectionForeground.rgba>>8&16777215,re=p.selectionForeground)),ie&&D.push(`xterm-decoration-top`);let ae;switch(ne){case 16777216:case 33554432:ae=p.ansi[te],D.push(`xterm-bg-${te}`);break;case 50331648:ae=Hb.toColor(te>>16,te>>8&255,te&255),this._addStyle(h,`background-color:#${rx((te>>>0).toString(16),`0`,6)}`);break;default:B?(ae=p.foreground,D.push(`xterm-bg-257`)):ae=p.background}switch(V||N.isDim()&&(V=Ub.multiplyOpacity(ae,.5)),z){case 16777216:case 33554432:N.isBold()&&R<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(R+=8),this._applyMinimumContrast(h,ae,p.ansi[R],N,V,void 0)||D.push(`xterm-fg-${R}`);break;case 50331648:let e=Hb.toColor(R>>16&255,R>>8&255,R&255);this._applyMinimumContrast(h,ae,e,N,V,re)||this._addStyle(h,`color:#${rx(R.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,ae,p.foreground,N,V,re)||B&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!F&&!A&&!L&&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||$b(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=Ub.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]}};nx=jg([Z(1,x_),Z(2,u_),Z(3,__),Z(4,o_),Z(5,p_),Z(6,S_)],nx);function rx(e,t,n){for(;e.length<n;)e=t+e;return e}var ix=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}},ax=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);if(s>=e.rows||c<0){this.clear();return}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 ox(){return new ax}var sx=`xterm-dom-renderer-owner-`,cx=`xterm-rows`,lx=`xterm-fg-`,ux=`xterm-bg-`,dx=`xterm-focus`,fx=`xterm-selection`,px=1,mx=class extends q_{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=px++,this._rowElements=[],this._selectionRenderModel=ox(),this.onRequestRedraw=this._register(new Q).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(cx),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(fx),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=ex(),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(nx,document),this._element.classList.add(sx+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(W_(()=>{this._element.classList.remove(sx+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new ix(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} .${cx} 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} .${cx} { 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} .${cx} .xterm-dim { color: ${Ub.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} .${cx}.${dx} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${cx}.${dx} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${cx}.${dx} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${cx} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${cx} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${cx} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${cx} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${cx} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${fx} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${fx} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${fx} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${lx}${n} { color: ${r.css}; }${this._terminalSelector} .${lx}${n}.xterm-dim { color: ${Ub.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${ux}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${lx}257 { color: ${Ub.opaque(e.background).css}; }${this._terminalSelector} .${lx}257.xterm-dim { color: ${Ub.multiplyOpacity(Ub.opaque(e.background),.5).css}; }${this._terminalSelector} .${ux}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(dx),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(dx),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`.${sx}${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))}}};mx=jg([Z(7,c_),Z(8,g_),Z(9,u_),Z(10,i_),Z(11,o_),Z(12,__),Z(13,S_)],mx);var hx=class extends q_{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new vx(this._optionsService))}catch{this._measureStrategy=this._register(new _x(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())}};hx=jg([Z(2,u_)],hx);var gx=class extends q_{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)}},_x=class extends gx{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}},vx=class extends gx{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}},yx=class extends q_{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 bx(this._window)),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(tv.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ly(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(Ly(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}},bx=class extends q_{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new J_),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(W_(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ly(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)}},xx=class extends q_{constructor(){super(),this.linkProviders=[],this._register(W_(()=>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 Sx(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 Cx(e,t,n,r,i,a,o,s,c){if(!a)return;let l=Sx(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 wx=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return Cx(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=Sx(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])}}};wx=jg([Z(0,y_),Z(1,g_)],wx);var Tx=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=[]}},Ex={};Ag(Ex,{getSafariVersion:()=>Nx,isChromeOS:()=>zx,isFirefox:()=>Ax,isIpad:()=>Fx,isIphone:()=>Ix,isLegacyEdge:()=>jx,isLinux:()=>Rx,isMac:()=>Px,isNode:()=>Dx,isSafari:()=>Mx,isWindows:()=>Lx});var Dx=typeof process<`u`&&`title`in process,Ox=Dx?`node`:navigator.userAgent,kx=Dx?`node`:navigator.platform,Ax=Ox.includes(`Firefox`),jx=Ox.includes(`Edge`),Mx=/^((?!chrome|android).)*safari/i.test(Ox);function Nx(){if(!Mx)return 0;let e=Ox.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Px=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(kx),Fx=kx===`iPad`,Ix=kx===`iPhone`,Lx=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(kx),Rx=kx.indexOf(`Linux`)>=0,zx=/\bCrOS\b/.test(Ox),Bx=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()}},Vx=class extends Bx{_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())}}},Hx=class extends Bx{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Ux=!Dx&&`requestIdleCallback`in window?Hx:Vx,Wx=class{constructor(){this._queue=new Ux}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Gx=class extends q_{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 J_),this._pausedResizeTask=new Wx,this._observerDisposable=this._register(new J_),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 Q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Tx((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Kx(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(W_(()=>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=W_(()=>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()}};Gx=jg([Z(2,u_),Z(3,g_),Z(4,o_),Z(5,p_),Z(6,i_),Z(7,__),Z(8,S_)],Gx);var Kx=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 qx(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return Xx(i,a,e,t,n,r)+Zx(a,t,n,r)+Qx(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,aS(Math.abs(i-e),iS(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return aS(Yx(a>t?e:i,n)+(s-1)*n.cols+1+Jx(a>t?i:e,n),iS(o,r))}function Jx(e,t){return e-1}function Yx(e,t){return t.cols-e}function Xx(e,t,n,r,i,a){return Zx(t,r,i,a).length===0?``:aS(rS(e,t,e,t-eS(t,i),!1,i).length,iS(`D`,a))}function Zx(e,t,n,r){let i=e-eS(e,n),a=t-eS(t,n);return aS(Math.abs(i-a)-$x(e,t,n),iS(nS(e,t),r))}function Qx(e,t,n,r,i,a){let o;o=Zx(t,r,i,a).length>0?r-eS(r,i):t;let s=r,c=tS(e,t,n,r,i,a);return aS(rS(e,o,n,s,c===`C`,i).length,iS(c,a))}function $x(e,t,n){let r=0,i=e-eS(e,n),a=t-eS(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=nS(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function eS(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 tS(e,t,n,r,i,a){let o;return o=Zx(n,r,i,a).length>0?r-eS(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function nS(e,t){return e>t?`A`:`B`}function rS(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 iS(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function aS(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var oS=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 sS(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 cS=50,lS=15,uS=50,dS=500,fS=RegExp(`\xA0`,`g`),pS=class extends q_{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 Zg,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Q),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 oS(this._bufferService),this._activeSelectionMode=0,this._register(W_(()=>{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(fS,` `)).join(Lx?`\r
14
+ `:`
15
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),Rx&&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=sS(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=Sx(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,-cS),cS),t/=cS,t/Math.abs(t)+Math.round(t*(lS-1)))}shouldForceSelection(e){return Px?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(),uS)}_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&&!(Px&&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<dS&&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=qx(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]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!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)}_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=sS(n,this._bufferService.cols)}};pS=jg([Z(3,i_),Z(4,o_),Z(5,v_),Z(6,u_),Z(7,y_),Z(8,__)],pS);var mS=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={}}},hS=class{constructor(){this._color=new mS,this._css=new mS}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()}},gS=Object.freeze((()=>{let e=[Wb.toColor(`#2e3436`),Wb.toColor(`#cc0000`),Wb.toColor(`#4e9a06`),Wb.toColor(`#c4a000`),Wb.toColor(`#3465a4`),Wb.toColor(`#75507b`),Wb.toColor(`#06989a`),Wb.toColor(`#d3d7cf`),Wb.toColor(`#555753`),Wb.toColor(`#ef2929`),Wb.toColor(`#8ae234`),Wb.toColor(`#fce94f`),Wb.toColor(`#729fcf`),Wb.toColor(`#ad7fa8`),Wb.toColor(`#34e2e2`),Wb.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:Hb.toCss(r,i,a),rgba:Hb.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:Hb.toCss(n,n,n),rgba:Hb.toRgba(n,n,n)})}return e})()),_S=Wb.toColor(`#ffffff`),vS=Wb.toColor(`#000000`),yS=Wb.toColor(`#ffffff`),bS=vS,xS={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},SS=_S,CS=class extends q_{constructor(e){super(),this._optionsService=e,this._contrastCache=new hS,this._halfContrastCache=new hS,this._onChangeColors=this._register(new Q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:_S,background:vS,cursor:yS,cursorAccent:bS,selectionForeground:void 0,selectionBackgroundTransparent:xS,selectionBackgroundOpaque:Ub.blend(vS,xS),selectionInactiveBackgroundTransparent:xS,selectionInactiveBackgroundOpaque:Ub.blend(vS,xS),scrollbarSliderBackground:Ub.opacity(_S,.2),scrollbarSliderHoverBackground:Ub.opacity(_S,.4),scrollbarSliderActiveBackground:Ub.opacity(_S,.5),overviewRulerBorder:_S,ansi:gS.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=wS(e.foreground,_S),t.background=wS(e.background,vS),t.cursor=Ub.blend(t.background,wS(e.cursor,yS)),t.cursorAccent=Ub.blend(t.background,wS(e.cursorAccent,bS)),t.selectionBackgroundTransparent=wS(e.selectionBackground,xS),t.selectionBackgroundOpaque=Ub.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=wS(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ub.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?wS(e.selectionForeground,Vb):void 0,t.selectionForeground===Vb&&(t.selectionForeground=void 0),Ub.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ub.opacity(t.selectionBackgroundTransparent,.3)),Ub.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ub.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=wS(e.scrollbarSliderBackground,Ub.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=wS(e.scrollbarSliderHoverBackground,Ub.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=wS(e.scrollbarSliderActiveBackground,Ub.opacity(t.foreground,.5)),t.overviewRulerBorder=wS(e.overviewRulerBorder,SS),t.ansi=gS.slice(),t.ansi[0]=wS(e.black,gS[0]),t.ansi[1]=wS(e.red,gS[1]),t.ansi[2]=wS(e.green,gS[2]),t.ansi[3]=wS(e.yellow,gS[3]),t.ansi[4]=wS(e.blue,gS[4]),t.ansi[5]=wS(e.magenta,gS[5]),t.ansi[6]=wS(e.cyan,gS[6]),t.ansi[7]=wS(e.white,gS[7]),t.ansi[8]=wS(e.brightBlack,gS[8]),t.ansi[9]=wS(e.brightRed,gS[9]),t.ansi[10]=wS(e.brightGreen,gS[10]),t.ansi[11]=wS(e.brightYellow,gS[11]),t.ansi[12]=wS(e.brightBlue,gS[12]),t.ansi[13]=wS(e.brightMagenta,gS[13]),t.ansi[14]=wS(e.brightCyan,gS[14]),t.ansi[15]=wS(e.brightWhite,gS[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]=wS(e.extendedAnsi[r],gS[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];return}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()}}};CS=jg([Z(0,u_)],CS);function wS(e,t){if(e!==void 0)try{return Wb.toColor(e)}catch{}return t}var TS=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)}},ES=class{constructor(){this._services=new TS,this._services.set(c_,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=t_(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)}},DS={trace:0,debug:1,info:2,warn:3,error:4,off:5},OS=`xterm.js: `,kS=class extends q_{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),AS=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=DS[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?``:OS)+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)}};kS=jg([Z(0,u_)],kS);var AS,jS=class extends q_{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Q),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}},MS=3,NS=Object.freeze(new Yg),PS=0,FS=2,IS=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*MS);let r=t||Zg.fromCharData([0,qg,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*MS+0],n=t&2097151;return[this._data[e*MS+1],t&2097152?this._combined[e]:n?Ug(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*MS+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*MS+0]=e|2097152|t[2]<<22):this._data[e*MS+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*MS+0]>>22}hasWidth(e){return this._data[e*MS+0]&12582912}getFg(e){return this._data[e*MS+1]}getBg(e){return this._data[e*MS+2]}hasContent(e){return this._data[e*MS+0]&4194303}getCodePoint(e){let t=this._data[e*MS+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*MS+0]&2097152}getString(e){let t=this._data[e*MS+0];return t&2097152?this._combined[e]:t&2097151?Ug(t&2097151):``}isProtected(e){return this._data[e*MS+2]&536870912}loadCell(e,t){return PS=e*MS,t.content=this._data[PS+0],t.fg=this._data[PS+1],t.bg=this._data[PS+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*MS+0]=t.content,this._data[e*MS+1]=t.fg,this._data[e*MS+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*MS+0]=t|n<<22,this._data[e*MS+1]=r.fg,this._data[e*MS+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*MS+0];r&2097152?this._combined[e]+=Ug(t):r&2097151?(this._combined[e]=Ug(r&2097151)+Ug(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*MS+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 Zg;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 Zg;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++;return}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*FS<this._data.buffer.byteLength;let n=e*MS;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*FS<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*FS<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);return}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*MS+0]&4194303)return e+(this._data[e*MS+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*MS+0]&4194303||this._data[e*MS+2]&50331648)return e+(this._data[e*MS+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<MS;e++)this._data[(n+i)*MS+e]=a[(t+i)*MS+e];a[(t+i)*MS+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<MS;e++)this._data[(n+i)*MS+e]=a[(t+i)*MS+e];a[(t+i)*MS+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*MS+0],n=e&2097151,a=e&2097152?this._combined[t]:n?Ug(n):Jg;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 LS(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=VS(u,d,t),p=1,m=0;for(;p<u.length;){let e=VS(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 RS(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 zS(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 BS(e,t,n){let r=[],i=e.map((n,r)=>VS(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=VS(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 VS(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 HS=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),H_(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};HS._nextId=1;var US=HS,WS={},GS=WS.B;WS[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},WS.A={"#":`£`},WS.B=void 0,WS[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},WS.C=WS[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},WS.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},WS.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},WS.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},WS.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},WS.E=WS[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},WS.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},WS.H=WS[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},WS[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var KS=4294967295,qS=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=NS.clone(),this.savedCharset=GS,this.markers=[],this._nullCell=Zg.fromCharData([0,qg,1,0]),this._whitespaceCell=Zg.fromCharData([0,Jg,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ux,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new jS(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 Xg),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 Xg),this._whitespaceCell}getBlankLine(e,t){return new IS(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>KS?KS:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=NS);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 jS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(NS),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 IS(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 IS(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=LS(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(NS),n);if(r.length>0){let n=RS(this.lines,r);zS(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(NS),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new IS(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(NS),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=BS(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(NS,!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--,_=VS(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 US(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)}},JS=class extends q_{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Q),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 qS(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new qS(!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)}},YS=2,XS=1,ZS=class extends q_{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,YS),this.rows=Math.max(e.rawOptions.rows||0,XS),this.buffers=this._register(new JS(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))}};ZS=jg([Z(0,u_)],ZS);var QS={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:Px,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},$S=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],eC=class extends q_{constructor(e){super(),this._onOptionChange=this._register(new Q),this.onOptionChange=this._onOptionChange.event;let t={...QS};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(W_(()=>{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 QS))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in QS))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||=QS[e],!tC(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=QS[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=$S.includes(t)?t:QS[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 tC(e){return e===`block`||e===`underline`||e===`bar`}function nC(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]&&nC(e[r],t-1);return n}var rC=Object.freeze({insertMode:!1}),iC=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),aC=class extends q_{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 Q),this.onData=this._onData.event,this._onUserInput=this._register(new Q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=nC(rC),this.decPrivateModes=nC(iC)}reset(){this.modes=nC(rC),this.decPrivateModes=nC(iC)}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))}};aC=jg([Z(0,i_),Z(1,l_),Z(2,u_)],aC);var oC={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 sC(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 cC=String.fromCharCode,lC={DEFAULT:e=>{let t=[sC(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${cC(t[0])}${cC(t[1])}${cC(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${sC(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${sC(e,!0)};${e.x};${e.y}${t}`}},uC=class extends q_{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 Q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(oC))this.addProtocol(e,oC[e]);for(let e of Object.keys(lC))this.addEncoding(e,lC[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}};uC=jg([Z(0,i_),Z(1,o_),Z(2,u_)],uC);var dC=[[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]],fC=[[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]],pC;function mC(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 hC=class{constructor(){if(this.version=`6`,!pC){pC=new Uint8Array(65536),pC.fill(1),pC[0]=0,pC.fill(0,1,32),pC.fill(0,127,160),pC.fill(2,4352,4448),pC[9001]=2,pC[9002]=2,pC.fill(2,11904,42192),pC[12351]=1,pC.fill(2,44032,55204),pC.fill(2,63744,64256),pC.fill(2,65040,65050),pC.fill(2,65072,65136),pC.fill(2,65280,65377),pC.fill(2,65504,65511);for(let e=0;e<dC.length;++e)pC.fill(0,dC[e][0],dC[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?pC[e]:mC(e,fC)?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=gC.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return gC.createPropertyValue(0,n,r)}},gC=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Q,this.onChange=this._onChange.event;let e=new hC;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)}},_C=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 vC(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 yC=2147483647,bC=256,xC=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>bC)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;return}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>yC?yC: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>yC?yC: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,yC):e}},SC=[],CC=class{constructor(){this._state=0,this._active=SC,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=SC}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=SC,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||SC,!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`,Wg(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=SC,this._id=-1,this._state=0}}},wC=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+=Wg(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}},TC=[],EC=class{constructor(){this._handlers=Object.create(null),this._active=TC,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=TC}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=TC,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||TC,!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`,Wg(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=TC,this._ident=0}},DC=new xC;DC.addParam(0);var OC=class{constructor(e){this._handler=e,this._data=``,this._params=DC,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():DC,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Wg(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=DC,this._data=``,this._hitLimit=!1,e));return this._params=DC,this._data=``,this._hitLimit=!1,t}},kC=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}},AC=160,jC=function(){let e=new kC(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(AC,0,2,0),e.add(AC,8,5,8),e.add(AC,6,0,6),e.add(AC,11,0,11),e.add(AC,13,13,13),e}(),MC=class extends q_{constructor(e=jC){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 xC,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(W_(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new CC),this._dcsParser=this._register(new EC),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:AC)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<AC){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<AC){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<AC){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<AC){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<AC){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<AC){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}}},NC=/^([\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})$/,PC=/^[\da-f]+$/;function FC(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=NC.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),PC.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 IC(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 LC(e,t=16){let[n,r,i]=e;return`rgb:${IC(n,t)}/${IC(r,t)}/${IC(i,t)}`}var RC={"(":0,")":1,"*":2,"+":3,"-":1,".":2},zC=131072,BC=10;function VC(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 HC=5e3,UC=0,WC=class extends q_{constructor(e,t,n,r,i,a,o,s,c=new MC){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 Gg,this._utf8Decoder=new Kg,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=NS.clone(),this._eraseAttrDataInternal=NS.clone(),this._onRequestBell=this._register(new Q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Q),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 GC(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(Pb.IND,()=>this.index()),this._parser.setExecuteHandler(Pb.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Pb.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new wC(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new wC(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new wC(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new wC(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new wC(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new wC(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new wC(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new wC(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new wC(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new wC(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new wC(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new wC(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 WS)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 OC((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`),HC))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${HC} 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>zC&&(a=this._parseStack.position+zC)}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<zC&&(this._parseBuffer=new Uint32Array(Math.min(e.length,zC))),o||this._dirtyRowTracker.clearRange(),e.length>zC)for(let t=a;t<e.length;t+=zC){let a=t+zC<e.length?t+zC: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=gC.extractWidth(t);let n=gC.extractShouldJoin(t),m=n?gC.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(Ug(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 IS&&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);continue}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=>!VC(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new OC(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new wC(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(NS));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=gC.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,GS),this._charsetService.setgCharset(1,GS),this._charsetService.setgCharset(2,GS),this._charsetService.setgCharset(3,GS);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|=Yg.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=NS.fg,e.bg=NS.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|=NS.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=NS.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|=NS.fg&16777215,r.bg&=-67108864,r.bg|=NS.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=NS.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(!VC(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>BC&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>BC&&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(KC(n)){if(r===`?`)t.push({type:0,index:n});else{let e=FC(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=FC(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]);KC(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,GS),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(RC[e[0]],WS[e[1]]||GS),!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=NS.clone(),this._eraseAttrDataInternal=NS.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 Zg;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)}},GC=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&&(UC=e,e=t,t=UC),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};GC=jg([Z(0,i_)],GC);function KC(e){return 0<=e&&e<256}var qC=5e7,JC=12,YC=50,XC=class extends q_{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 Q),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>qC)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>=JC?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>=JC)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>YC&&(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()}},ZC=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)))}};ZC=jg([Z(0,i_)],ZC);var QC=!1,$C=class extends q_{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new J_),this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onData=this._register(new Q),this.onData=this._onData.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Q),this._instantiationService=new ES,this.optionsService=this._register(new eC(e)),this._instantiationService.setService(u_,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(ZS)),this._instantiationService.setService(i_,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(kS)),this._instantiationService.setService(l_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(aC)),this._instantiationService.setService(o_,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(uC)),this._instantiationService.setService(a_,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(gC)),this._instantiationService.setService(f_,this.unicodeService),this._charsetService=this._instantiationService.createInstance(_C),this._instantiationService.setService(s_,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(ZC),this._instantiationService.setService(d_,this._oscLinkService),this._inputHandler=this._register(new WC(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(tv.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(tv.forward(this._bufferService.onResize,this._onResize)),this._register(tv.forward(this.coreService.onData,this._onData)),this._register(tv.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 XC((e,t)=>this._inputHandler.parse(e,t))),this._register(tv.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Q),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&&!QC&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),QC=!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,YS),t=Math.max(t,XS),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(vC.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(vC(this._bufferService),!1))),this._windowsWrappingHeuristics.value=W_(()=>{for(let t of e)t.dispose()})}}},ew={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 tw(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=ew[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 nw=0,rw=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ux,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ux,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||(nw=this._search(t),nw===-1)||this._getKey(this._array[nw])!==t)return!1;do if(this._array[nw]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(nw),!0;while(++nw<this._array.length&&this._getKey(this._array[nw])===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&&(nw=this._search(e),!(nw<0||nw>=this._array.length)&&this._getKey(this._array[nw])===e))do yield this._array[nw];while(++nw<this._array.length&&this._getKey(this._array[nw])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(nw=this._search(e),!(nw<0||nw>=this._array.length)&&this._getKey(this._array[nw])===e))do t(this._array[nw]);while(++nw<this._array.length&&this._getKey(this._array[nw])===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}},iw=0,aw=0,ow=class extends q_{constructor(){super(),this._decorations=new rw(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(W_(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new sw(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=>{iw=t.options.x??0,aw=iw+(t.options.width??1),e>=iw&&e<aw&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},sw=class extends K_{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Q),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?Wb.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?Wb.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},cw=1e3,lw=class{constructor(e,t=cw){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)}},uw=20,dw=class extends q_{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 lw(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(Ly(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(W_(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<uw+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
17
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===uw+1&&(this._liveRegion.textContent+=Fg.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})`}};dw=jg([Z(1,c_),Z(2,__),Z(3,y_)],dw);var fw=class extends q_{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 Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(W_(()=>{H_(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(Ly(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ly(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(Ly(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(Ly(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){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}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&&pw(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,H_(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}}};fw=jg([Z(1,v_),Z(2,y_),Z(3,i_),Z(4,C_)],fw);function pw(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 mw=class extends $C{constructor(e={}){super(e),this._linkifier=this._register(new J_),this.browser=Ex,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new J_),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(ow),this._instantiationService.setService(p_,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(xx),this._instantiationService.setService(C_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(m_)),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(tv.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(tv.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(tv.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(tv.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(W_(()=>{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=Ub.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${LC(r)}${Fb.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=Hb.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=Hb.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(dw,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(Ly(this.element,`copy`,e=>{this.hasSelection()&&Rg(e,this._selectionService)}));let e=e=>zg(e,this.textarea,this.coreService,this.optionsService);this._register(Ly(this.textarea,`paste`,e)),this._register(Ly(this.element,`paste`,e)),Ax?this._register(Ly(this.element,`mousedown`,e=>{e.button===2&&Hg(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ly(this.element,`contextmenu`,e=>{Hg(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Rx&&this._register(Ly(this.element,`auxclick`,e=>{e.button===1&&Vg(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ly(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(Ly(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(Ly(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(Ly(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(Ly(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(Ly(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(Ly(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(Ly(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`,Ng.get()),zx||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(yx,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(__,this._coreBrowserService),this._register(Ly(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(Ly(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(hx,this._document,this._helperContainer),this._instantiationService.setService(g_,this._charSizeService),this._themeService=this._instantiationService.createInstance(CS),this._instantiationService.setService(S_,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Xb),this._instantiationService.setService(x_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Gx,this.rows,this.screenElement)),this._instantiationService.setService(y_,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(Ib,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(wx),this._instantiationService.setService(v_,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(fw,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(Db,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(pS,this.element,this.screenElement,r)),this._instantiationService.setService(b_,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(tv.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Ob,this.screenElement)),this._register(Ly(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(dw,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Nb,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Nb,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(mx,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(Ly(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(Ly(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){Bg(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=tw(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)&&(hw(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){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}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(NS));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 hw(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var gw=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)}},_w=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 Zg)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},vw=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 _w(t)}getNullCell(){return new Zg}},yw=class extends q_{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new vw(this._core.buffers.normal,`normal`),this._alternate=new vw(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)}},bw=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)}},xw=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}},Sw=[`cols`,`rows`],Cw=0,ww=class extends q_{constructor(e){super(),this._core=this._register(new mw(e)),this._addonManager=this._register(new gw),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(Sw.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 bw(this._core),this._parser}get unicode(){return this._checkProposedApi(),new xw(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 yw(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 Ng.get()},set promptLabel(e){Ng.set(e)},get tooMuchOutput(){return Fg.get()},set tooMuchOutput(e){Fg.set(e)}}}_verifyIntegers(...e){for(Cw of e)if(Cw===1/0||isNaN(Cw)||Cw%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(Cw of e)if(Cw&&(Cw===1/0||isNaN(Cw)||Cw%1!=0||Cw<0))throw Error(`This API only accepts positive integers`)}},Tw=ci(`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})})),Ew={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`},Dw={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 Ow(e,t,n){return n.getCssVar(e,t)}function kw(e,t){let n=e===`dark`?Dw:Ew,r=Ow(`--foreground`,e===`dark`?`#f8fafc`:`#0f172a`,t);return{foreground:r,background:`transparent`,cursor:r,cursorAccent:Ow(`--background`,e===`dark`?`#000000`:`#ffffff`,t),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 Aw(e){return{cols:Math.max(1,e.cols||80),rows:Math.max(1,e.rows||24)}}function jw(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 Mw(e){e.refresh(0,Math.max(0,e.rows-1))}function Nw(e){return/mac/i.test(e)}var Pw=13;function Fw(e){return Math.round(Pw*zn(e))}function Iw(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:Nw(r)}}function Lw(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(!Nw(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 Rw(e,t,n,r,i,a){let o=jw(e,t,a)??Aw(e);return n.current&&n.current.cols===o.cols&&n.current.rows===o.rows?o:(e.resize(o.cols,o.rows),n.current=o,r&&i(o.cols,o.rows),o)}function zw({projectId:e,terminalId:t,socket:n,scrollback:r,connectionStatus:i,clearVersion:a=0,focusRequestVersion:s=0,onPathChange:c,onCommandSent:l,ports:u={}}){let d=u.dom??o,f=u.timer??fi,{resolvedTheme:p}=H(),m=(0,K.useRef)(null),h=(0,K.useRef)(null),g=(0,K.useRef)(null),_=(0,K.useRef)(l),v=(0,K.useRef)(Pw),y=(0,K.useRef)(!1),b=(0,K.useRef)(0),x=(0,K.useRef)(null),S=(0,K.useRef)(null),C=Tw.useScopedStore(e=>e.metadata),w=Tw.useScopedStore(e=>e.error),T=Tw.useScopedStore(e=>e.setError),E=Tw.useScopedStore(e=>e.setMetadataConditional),D=Tw.useScopedStore(e=>e.setMetadataFromExit),O=Tw.useScopedStore(e=>e.resetTerminal),k=kw(p===`dark`?`dark`:`light`,d),A=ce(e=>e.settings?.typography?.scale),j=Qn(e=>e.typographyOverride),M=Fw(Wn(j,A)),N=(0,K.useCallback)(e=>{n.command({type:`terminal.input`,terminalId:t,data:e}).catch(e=>{T(e instanceof Error?e.message:String(e))}),(e.includes(`\r`)||e.includes(`
19
+ `))&&_.current?.()},[n,t,T]),P=(0,K.useCallback)((e,r)=>{n.command({type:`terminal.resize`,terminalId:t,cols:e,rows:r}).catch(()=>{})},[n,t]),F=(0,K.useCallback)(()=>{let e=()=>{let e=h.current,t=m.current;!e||!t||!y.current||Rw(e,t,S,!0,P,d)};f.requestAnimationFrame(()=>{e(),f.setTimeout(e,0)})},[d,P,f]);return(0,K.useEffect)(()=>{_.current=l},[l]),(0,K.useEffect)(()=>{v.current=M},[M]),(0,K.useEffect)(()=>{let e=new ww(Iw(r,k,v.current)),i=new bg;e.loadAddon(i),e.loadAddon(new Dg),e.attachCustomKeyEventHandler(e=>{if(e.type!==`keydown`)return!0;let t=Lw(e);return!t||(e.preventDefault(),N(t),!1)}),h.current=e;let a=m.current;a&&(e.open(a),g.current&&e.write(g.current),Rw(e,a,S,!1,()=>{},d),Mw(e),F());let o=e.onData(e=>{N(e)}),s=e.onResize(({cols:e,rows:t})=>{if(!y.current)return;let n={cols:e,rows:t};S.current&&S.current.cols===e&&S.current.rows===t||(S.current=n,P(e,t))}),c=new ResizeObserver(()=>{let e=h.current,r=m.current;!e||!r||Rw(e,r,S,y.current,(e,r)=>{n.command({type:`terminal.resize`,terminalId:t,cols:e,rows:r}).catch(()=>{})},d)});return a&&c.observe(a),()=>{c.disconnect(),s.dispose(),o.dispose(),g.current=i.serialize(),e.dispose(),h.current=null}},[d,F,r,N,P,n,t,k]),(0,K.useEffect)(()=>{let e=h.current;e&&(e.options.scrollback=r)},[r]),(0,K.useEffect)(()=>{let e=h.current;e&&(e.options.theme=k,Mw(e))},[k]),(0,K.useEffect)(()=>{let e=h.current,t=m.current;!e||!t||(e.options.fontSize=M,Mw(e),Rw(e,t,S,y.current,P,d))},[M,d,P]),(0,K.useEffect)(()=>{if(s===0)return;let e=h.current;e&&f.requestAnimationFrame(()=>{e.focus()})},[s,f]),(0,K.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(),Mw(e),n.command({type:`terminal.close`,terminalId:t}).catch(e=>{T(e instanceof Error?e.message:String(e))}))},[a,n,t,O,T]),(0,K.useEffect)(()=>{c?.(C?.cwd??null)},[C?.cwd,c]),(0,K.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),Mw(t),!0)},o=()=>{let i=h.current,o=m.current;if(!i||!o)return;let s=jw(i,o,d)??Aw(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),e&&a(e),F()}).catch(e=>{T(e instanceof Error?e.message:String(e))})},s=()=>{let e=++b.current,t=()=>{if(b.current!==e)return;let n=h.current,r=m.current;if(!n||!r)return;Rw(n,r,S,!1,()=>{},d);let i=r.getBoundingClientRect();if(i.width<=0||i.height<=0){f.requestAnimationFrame(t);return}o()};f.requestAnimationFrame(()=>{f.requestAnimationFrame(t)})};return s(),n.subscribeTerminal(t,{onSnapshot:e=>{if(!e){y.current=!1,x.current=null,i===`connected`&&s();return}y.current=!0,T(null),a(e)&&F()},onEvent:e=>{let t=h.current;if(t){if(e.type===`terminal.output`){t.write(e.data);return}e.type===`terminal.exit`&&D(e.exitCode)}}})},[i,d,e,F,r,n,t,f,E,D,T]),(0,q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden pb-4`,children:[(0,q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden px-3 py-1`,children:(0,q.jsx)(`div`,{ref:m,className:`kanna-terminal min-h-0 min-w-0 flex-1 overflow-hidden w-full`})}),w?(0,q.jsxs)(`div`,{className:`px-3 py-1 text-xs text-destructive`,children:[`Terminal error: `,w]}):null]})}function Bw(e){return(0,q.jsx)(Tw.Provider,{init:void 0,children:(0,q.jsx)(zw,{...e})})}function Vw(e){return e+24}function Hw(e,t){return Math.max(1,e)*Vw(t)}var Uw=ci(`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}}))})),Ww=(0,K.memo)(({projectId:e,terminalId:t,size:n,isLast:r,minTerminalWidth:i,path:o,socket:s,scrollback:c,connectionStatus:l,clearVersion:u,focusRequestVersion:d,splitTerminalShortcut:f,onAddTerminal:p,onRemoveTerminal:m,onClearTerminal:h,onPathChange:g,onCommandSent:_,setPaneElement:v})=>{let y=(0,K.useCallback)(e=>{v(t,e)},[v,t]),b=(0,K.useCallback)(()=>{h(t),g(t,null)},[h,g,t]),x=(0,K.useCallback)(()=>{p(e,t)},[p,e,t]),S=(0,K.useCallback)(()=>{m(e,t)},[m,e,t]),C=(0,K.useCallback)(e=>{g(t,e)},[g,t]);return(0,q.jsxs)(K.Fragment,{children:[(0,q.jsx)(Xh,{id:t,defaultSize:`${n}%`,minSize:`${i}px`,className:`min-h-0 overflow-hidden`,style:{minWidth:i},children:(0,q.jsxs)(`div`,{ref:y,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,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pr-2 pt-2 pb-1`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1 text-left`,children:(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`shrink-0 text-sm font-medium`,children:`Terminal`}),(0,q.jsx)(`div`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:o??``})]})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(a,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clear terminal`,onClick:b,children:(0,q.jsx)(ra,{className:`size-3.5`})}),(0,q.jsxs)(mi,{children:[(0,q.jsx)(bi,{asChild:!0,children:(0,q.jsx)(a,{variant:`ghost`,size:`icon-sm`,"aria-label":`Add terminal to the right`,onClick:x,children:(0,q.jsx)(ti,{className:`size-3.5`})})}),(0,q.jsx)(_i,{side:`bottom`,shortcut:f})]}),(0,q.jsx)(a,{variant:`ghost`,size:`icon-sm`,"aria-label":`Archive terminal`,onClick:S,children:(0,q.jsx)(ri,{className:`size-3.5`})})]})]}),(0,q.jsx)(Bw,{projectId:e,terminalId:t,socket:s,scrollback:c,connectionStatus:l,clearVersion:u,focusRequestVersion:d,onCommandSent:_,onPathChange:C})]})}),r?null:(0,q.jsx)(eg,{withHandle:!0,orientation:`horizontal`})]})});function Gw({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,K.useRef)(null),p=(0,K.useRef)({}),m=(0,K.useRef)([]),h=Uw.useScopedStore(e=>e.viewportWidth),g=Uw.useScopedStore(e=>e.pathsByTerminalId),_=Uw.useScopedStore(e=>e.clearVersionsByTerminalId),v=Uw.useScopedStore(e=>e.setViewportWidth),y=Uw.useScopedStore(e=>e.updatePath),b=Uw.useScopedStore(e=>e.incrementClearVersion);(0,K.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=Vw(a),C=Hw(x,a),w=Math.max(h,C),T=(0,K.useMemo)(()=>t.terminals.map(e=>e.id).join(`:`),[t.terminals]),E=(0,K.useCallback)((e,t)=>{p.current[e]=t},[]),D=(0,K.useCallback)((e,t)=>{y(e,t)},[y]),O=(0,K.useCallback)(e=>{b(e)},[b]),k=(0,K.useCallback)(n=>{u(e,t.terminals.map(e=>n[e.id]??e.size))},[t.terminals,u,e]);return(0,K.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,q.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,q.jsx)(`div`,{ref:f,className:`min-h-0 flex-1 overflow-x-auto overflow-y-hidden`,children:(0,q.jsx)(`div`,{className:`h-full min-h-0`,style:{width:w||`100%`},children:(0,q.jsx)(Yh,{orientation:`horizontal`,className:`h-full min-h-0`,onLayoutChanged:k,children:t.terminals.map((a,u)=>(0,q.jsx)(Ww,{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 Kw(e){return(0,q.jsx)(Uw.Provider,{init:void 0,children:(0,q.jsx)(Gw,{...e})})}var qw=(0,K.memo)(Kw),Jw=(0,K.memo)(({projectId:e,terminalLayout:t,addTerminal:n,socket:r,connectionStatus:i,scrollback:a,minColumnWidth:o,splitTerminalShortcut:s,focusRequestVersion:c,onTerminalCommandSent:l,onRemoveTerminal:u,onTerminalLayout:d})=>(0,q.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:(0,q.jsx)(qw,{projectId:e,layout:t,onAddTerminal:n,socket:r,connectionStatus:i,scrollback:a,minColumnWidth:o,splitTerminalShortcut:s,focusRequestVersion:c,onTerminalCommandSent:l,onRemoveTerminal:u,onTerminalLayout:d})})),Yw=`What are we building?`,Xw=5e3,Zw={status:`unknown`,files:[]};function Qw(e){let t=e.replaceAll(`\\`,`/`).replace(/\/+/g,`/`).replace(/\/$/u,``),n=t.lastIndexOf(`/`);return n<=0?null:`${t.slice(0,n)}/`}function $w(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 eT(e){return Array.from(e).includes(`Files`)}function tT(e){return e.startsWith(`/`)||e===`~`||e.startsWith(`~/`)||/^[A-Za-z]:[\\/]/u.test(e)}function nT(e,t){let n=e.includes(`\\`)&&!e.includes(`/`)?`\\`:`/`;return`${e.replace(/[\\/]+$/u,``)}${n}${t.replace(/^[\\/]+/u,``)}`}function rT(e,t){return!e||tT(t)?t:nT(e,t)}function iT({state:e,projectId:t,showRightSidebar:n,ports:r}){let i=r?.dom??o,a=r?.timer??fi,s=Cn(),c=Qp(e=>e.diffRenderMode),l=Qp(e=>e.wrapDiffLines),u=Qp(e=>e.setDiffRenderMode),d=Qp(e=>e.setWrapDiffLines),f=(0,K.useRef)(null),p=(0,K.useRef)(!1),m=(0,K.useRef)(null),h=(0,K.useRef)(e.activeChatId),g=(0,K.useRef)(e.runtime?.localPath??e.navbarLocalPath??null),{handleOpenLocalLink:_,handleCopyPath:v,handleOpenExternalPath:y}=e;(0,K.useEffect)(()=>{h.current=e.activeChatId},[e.activeChatId]),(0,K.useEffect)(()=>{g.current=e.runtime?.localPath??e.navbarLocalPath??null},[e.navbarLocalPath,e.runtime?.localPath]);let b=(0,K.useCallback)(()=>{let t=h.current;t&&e.socket.command({type:`chat.refreshDiffs`,chatId:t}).catch(()=>{})},[e.socket]),x=(0,K.useCallback)(()=>{let t=h.current;!t||!n||e.socket.command({type:`chat.refreshDiffs`,chatId:t}).catch(()=>{})},[n,e.socket]),S=(0,K.useCallback)(()=>{!h.current||!n||(f.current!==null&&a.clearTimeout(f.current),f.current=a.setTimeout(()=>{f.current=null,x()},1e3))},[x,n,a]),C=(0,K.useCallback)(e=>{let t=g.current,n=rT(t,e);_({path:n},`open_editor`)},[_]),w=(0,K.useCallback)(e=>{let t=g.current;v(rT(t,e))},[v]),T=(0,K.useCallback)(e=>{v(e)},[v]),E=(0,K.useCallback)(async n=>{if(!t)throw Error(`Project not found`);let r=h.current;return(await e.socket.command({type:`project.readDiffPatch`,projectId:t,path:n,...r?{chatId:r}:{}})).patch},[h,t,e.socket]),D=(0,K.useCallback)(t=>{let n=h.current;n&&(async()=>{if(await s.confirm({title:`Discard Changes`,description:`Discard changes for "${t}"? This cannot be undone.`,confirmLabel:`Discard`,confirmVariant:`destructive`}))try{await e.socket.command({type:`chat.discardDiffFile`,chatId:n,path:t})}catch(e){await s.alert({title:`Discard failed`,description:e instanceof Error?e.message:String(e),closeLabel:`OK`})}})()},[s,e.socket]),O=(0,K.useCallback)(t=>{let n=h.current;n&&(async()=>{if(await s.confirm({title:`Ignore File`,description:`Add "${t}" to .gitignore?`,confirmLabel:`Ignore`,confirmVariant:`destructive`}))try{await e.socket.command({type:`chat.ignoreDiffFile`,chatId:n,path:t})}catch(e){await s.alert({title:`Ignore failed`,description:e instanceof Error?e.message:String(e),closeLabel:`OK`})}})()},[s,e.socket]),k=(0,K.useCallback)(t=>{let n=h.current;if(!n)return;let r=Qw(t);r&&(async()=>{let t=await s.prompt({title:`Ignore Folder`,description:`Edit the folder pattern to add to .gitignore.`,initialValue:r,confirmLabel:`Ignore`});if(t)try{await e.socket.command({type:`chat.ignoreDiffFile`,chatId:n,path:t})}catch(e){await s.alert({title:`Ignore failed`,description:e instanceof Error?e.message:String(e),closeLabel:`OK`})}})()},[s,e.socket]),A=(0,K.useCallback)(e=>{y(`open_finder`,e)},[y]),j=(0,K.useCallback)(async t=>{let n=h.current;if(!n)return null;try{let r=await e.socket.command({type:`chat.commitDiffs`,chatId:n,paths:t.paths,summary:t.summary,description:t.description,mode:t.mode});return r.snapshotChanged&&x(),r.ok||await s.alert({title:r.title,description:r.localCommitCreated?`${r.message}\n\nA local commit was created, but the push did not complete.${r.detail?`\n\n${r.detail}`:``}`:`${r.message}${r.detail?`\n\n${r.detail}`:``}`,closeLabel:`OK`}),r}catch(e){return await s.alert({title:`Commit failed`,description:e instanceof Error?e.message:String(e),closeLabel:`OK`}),null}},[s,x,e.socket]),M=(0,K.useCallback)(async t=>{let n=h.current;if(!n)return null;try{let r=await e.socket.command({type:`chat.syncBranch`,chatId:n,action:t});return r.snapshotChanged&&x(),r.ok||await s.alert({title:r.title,description:`${r.message}${r.detail?`\n\n${r.detail}`:``}`,closeLabel:`OK`}),r}catch(e){return await s.alert({title:`Git sync failed`,description:e instanceof Error?e.message:String(e),closeLabel:`OK`}),null}},[s,x,e.socket]),N=(0,K.useCallback)(async t=>{let n=h.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]),P=(0,K.useCallback)(async()=>{let t=h.current;if(!t)return null;try{let n=await e.socket.command({type:`chat.initGit`,chatId:t});return n.snapshotChanged&&b(),n.ok||await s.alert({title:n.title,description:`${n.message}${n.detail?`\n\n${n.detail}`:``}`,closeLabel:`OK`}),n}catch(e){return await s.alert({title:`Initialize git failed`,description:e instanceof Error?e.message:String(e),closeLabel:`OK`}),null}},[s,b,e.socket]),F=(0,K.useCallback)(async()=>{let t=h.current;return t?await e.socket.command({type:`chat.getGitHubPublishInfo`,chatId:t}):{ghInstalled:!1,authenticated:!1,owners:[],suggestedRepoName:`my-repo`}},[e.socket]),I=(0,K.useCallback)(async t=>{let n=h.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,K.useCallback)(async t=>{let n=h.current;if(!n)return null;try{let r=await e.socket.command({type:`chat.publishToGitHub`,chatId:n,owner:t.owner,name:t.name,visibility:t.visibility,description:t.description.trim()||void 0});return r.snapshotChanged&&b(),r.ok||await s.alert({title:r.title,description:`${r.message}${r.detail?`\n\n${r.detail}`:``}`,closeLabel:`OK`}),r}catch(e){return await s.alert({title:`Publish failed`,description:e instanceof Error?e.message:String(e),closeLabel:`OK`}),null}},[s,b,e.socket]),ee=(0,K.useCallback)(async()=>{let t=h.current;return t?await e.socket.command({type:`chat.listBranches`,chatId:t}):{recent:[],local:[],remote:[],pullRequests:[],pullRequestsStatus:`unavailable`}},[e.socket]),R=(0,K.useCallback)(async t=>{let n=h.current;if(!n)return;let r=!1;if((e.chatDiffSnapshot?.files.length??0)>0){if(!await s.confirm({title:`Bring Changes?`,description:`You have uncommitted changes. Bring them to ${t.name}?`,confirmLabel:`Bring Changes`,cancelLabel:`Stay Here`}))return;r=!0}try{let i=await e.socket.command({type:`chat.checkoutBranch`,chatId:n,branch:$w(t),bringChanges:r});i.snapshotChanged&&x(),!i.ok&&!i.cancelled&&await s.alert({title:i.title,description:`${i.message}${i.detail?`\n\n${i.detail}`:``}`,closeLabel:`OK`})}catch(e){await s.alert({title:`Checkout failed`,description:e instanceof Error?e.message:String(e),closeLabel:`OK`})}},[s,x,e.chatDiffSnapshot?.files.length,e.socket]),z=(0,K.useCallback)(async t=>{let n=h.current;return n?await e.socket.command({type:`chat.previewMergeBranch`,chatId:n,branch:$w(t)}):{currentBranchName:void 0,targetBranchName:t.name,targetDisplayName:t.displayName,status:`error`,commitCount:0,hasConflicts:!1,message:`Merge preview unavailable.`}},[e.socket]),te=(0,K.useCallback)(async t=>{let n=h.current;if(!n)return null;try{let r=await e.socket.command({type:`chat.mergeBranch`,chatId:n,branch:$w(t)});return r.snapshotChanged&&x(),r.ok||await s.alert({title:r.title,description:`${r.message}${r.detail?`\n\n${r.detail}`:``}`,closeLabel:`OK`}),r}catch(e){return await s.alert({title:`Merge failed`,description:e instanceof Error?e.message:String(e),closeLabel:`OK`}),null}},[s,x,e.socket]),ne=(0,K.useCallback)(async()=>{let t=h.current;if(!t)return;let n=await s.prompt({title:`New Branch`,description:`Enter a branch name.`,placeholder:`feature/my-branch`,confirmLabel:`Create`});if(!n)return;let r=await ee(),i=r.currentBranchName,a=r.defaultBranchName,o=a;a&&i&&a!==i&&(o=await s.confirm({title:`Branch Base`,description:`Create "${n}" from ${i} instead of ${a}?`,confirmLabel:`From ${i}`,cancelLabel:`From ${a}`})?i:a);try{let r=await e.socket.command({type:`chat.createBranch`,chatId:t,name:n,baseBranchName:o});r.snapshotChanged&&x(),r.ok||await s.alert({title:r.title,description:`${r.message}${r.detail?`\n\n${r.detail}`:``}`,closeLabel:`OK`})}catch(e){await s.alert({title:`Create branch failed`,description:e instanceof Error?e.message:String(e),closeLabel:`OK`})}},[s,ee,x,e.socket]);return(0,K.useEffect)(()=>{if(!t||!n)return;let e=a.setInterval(()=>{x()},Xw);return()=>a.clearInterval(e)},[t,x,n,a]),(0,K.useEffect)(()=>{!t||!n||x()},[t,x,n]),(0,K.useEffect)(()=>{!t||!e.activeChatId||m.current!==t&&(m.current=t,b())},[t,b,e.activeChatId]),(0,K.useEffect)(()=>{if(!t||!n)return;function e(){i.getVisibilityState()===`visible`&&x()}let r=i.addWindowListener(`focus`,e),a=i.addDocumentListener(`visibilitychange`,e);return()=>{r(),a()}},[i,t,x,n]),(0,K.useEffect)(()=>{n&&p.current&&!e.isProcessing&&x(),p.current=e.isProcessing},[x,n,e.isProcessing]),(0,K.useEffect)(()=>()=>{f.current!==null&&a.clearTimeout(f.current)},[a]),(0,K.useEffect)(()=>{n||f.current!==null&&(a.clearTimeout(f.current),f.current=null)},[t,n,a]),{diffRenderMode:c,wrapDiffLines:l,setDiffRenderMode:u,setWrapDiffLines:d,scheduleTerminalDiffRefresh:S,handleOpenDiffFile:C,handleCopyDiffFilePath:w,handleCopyDiffRelativePath:T,handleLoadDiffPatch:E,handleDiscardDiffFile:D,handleIgnoreDiffFile:O,handleIgnoreDiffFolder:k,handleOpenDiffInFinder:A,handleCommitDiffs:j,handleSyncBranch:M,handleGenerateCommitMessage:N,handleInitializeGit:P,handleGetGitHubPublishInfo:F,handleCheckGitHubRepoAvailability:I,handleSetupGitHub:L,handleListBranches:ee,handleCheckoutBranch:R,handlePreviewMergeBranch:z,handleMergeBranch:te,handleCreateBranch:ne}}function aT(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 oT=c()(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&&aT(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 sT(e){let t=Dn(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?.focusedTabId??r[0]?.tabId??null}}function cT(e){return`${e*100}%`}function lT({node:e,...t}){let{onResizeGroup:n}=t,r=(0,K.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,q.jsx)(Yh,{orientation:e.direction,className:`min-h-0 min-w-0`,onLayoutChanged:r,children:e.children.map((n,r)=>(0,q.jsxs)(K.Fragment,{children:[(0,q.jsx)(Xh,{id:n.id,defaultSize:cT(e.sizes[r]??1/e.children.length),className:`min-h-0 min-w-0`,children:(0,q.jsx)(pT,{...t,node:n})}),r<e.children.length-1?(0,q.jsx)(eg,{withHandle:!0,orientation:e.direction}):null]},n.id))})}function uT({node:e,focusedPaneId:t,renderPane:n,onFocusPane:r}){let i=t===e.id,a=(0,K.useCallback)(()=>r(e.id),[e.id,r]),{setNodeRef:o}=Rn({id:e.id}),s=oT(t=>t.overPaneId===e.id),c=oT(e=>e.intent);return(0,q.jsxs)(`div`,{ref:o,"data-pane-id":e.id,"data-pane-focused":i?`true`:`false`,className:u(`relative flex h-full min-h-0 min-w-0 flex-col overflow-hidden`),onPointerDownCapture:a,children:[n(e,i),s&&c?(0,q.jsx)(fT,{intent:c}):null]})}var dT={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 fT({intent:e}){return(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-pane-drop":e.kind===`merge`?`merge`:`split-${e.position}`,className:u(`pointer-events-none absolute z-10 border border-destructive bg-destructive/[0.08]`,e.kind===`merge`?`inset-0`:dT[e.position])})}function pT(e){return an(e.node)?(0,q.jsx)(lT,{...e,node:e.node}):(0,q.jsx)(uT,{...e,node:e.node})}function mT({layout:e,...t}){let n=Vt(e=>e.width),r=(0,K.useMemo)(()=>Fn(n)?sT(e):null,[n,e]);return r?(0,q.jsx)(`div`,{"data-pane-mobile":`true`,className:`flex h-full min-h-0 min-w-0 flex-col`,children:(0,q.jsx)(pT,{...t,node:r,focusedPaneId:r.id})}):(0,q.jsx)(pT,{...t,node:e.root,focusedPaneId:e.focusedPaneId})}function hT({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 gT(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 _T=ci(`PaneScoped`,()=>e=>({layoutWidth:0,setLayoutWidth:t=>e({layoutWidth: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}),tabRecency:[],noteTabActivated:t=>e(e=>{let n=gT(e.tabRecency,t);return n===e.tabRecency?e:{tabRecency:n}})}));function vT(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)}}var yT=7;function bT(e,t,n){return Math.min(n,Math.max(t,e))}function xT({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=bT(r??60,60,200),o=i<a*t,s=o?a:Math.round(bT(i/t,a,200));return{tabWidth:s,showLabel:s-60>=yT,scrolls:o}}function ST(e,t){switch(e.kind){case`chat`:{let n=t.chatStatuses?.[e.chatId];return{label:t.chatTitles?.[e.chatId]??`Chat`,icon:pa,pinned:n?.status===`running`||n?.status===`starting`,closable:!0,indicator:n?cn(n):null,sessionBadge:An(n?.sessionState)}}case`board`:return{label:t.boardTitles?.[e.boardId]??`Board`,icon:_n,pinned:!1,closable:!0,indicator:null,sessionBadge:null};case`changes`:return{label:`Changes`,icon:aa,pinned:!1,closable:!0,indicator:null,sessionBadge:null};case`terminal`:return{label:t.terminalTitles?.[e.terminalId]??`Terminal`,icon:Ea,pinned:t.liveTerminalIds?.has(e.terminalId)??!1,closable:!0,indicator:null,sessionBadge:null}}}var CT=52,wT=`Open another tab to split — a pane cannot be left empty`,TT=1;function ET({pane:e,isPaneFocused:t,width:n,presentation:r,onSelectTab:i,onCloseTab:a,onSplit:o}){let s=Vt(e=>e.width),c=Fn(s),l=ce(e=>e.settings?.panes.tabMinWidth??60),d=!c,f=e.tabs.length>1,p=xT({availableWidth:n,tabCount:e.tabs.length,actionsWidth:d?CT:0,minTabWidth:c?124:l}),m=(0,K.useCallback)(()=>o(`right`),[o]),h=(0,K.useCallback)(()=>o(`bottom`),[o]),g=(0,K.useRef)(null),_=(0,K.useRef)(!1),v=e.focusedTabId;return(0,K.useEffect)(()=>{let e=g.current?.querySelector(`[data-tab-active="true"]`);if(typeof e?.scrollIntoView!=`function`)return;let t=!_.current;_.current=!0,e.scrollIntoView({block:`nearest`,inline:`nearest`,...t?{behavior:`instant`}:{}})},[v]),(0,q.jsxs)(`div`,{"data-pane-tab-strip":!0,className:u(`flex shrink-0 items-stretch border-b border-border bg-background`,Tr),children:[(0,q.jsx)(`div`,{ref:g,"data-swipe-scroll-x":p.scrolls?`true`:void 0,className:u(`flex min-w-0 flex-1 items-stretch`,p.scrolls&&`overflow-x-auto overscroll-x-contain touch-pan-x motion-safe:scroll-smooth`),style:{WebkitOverflowScrolling:`touch`},children:e.tabs.map(n=>{let o=e.focusedTabId===n.tabId,{label:s,icon:l,closable:u,indicator:d,sessionBadge:f}=ST(n.target,r);return(0,q.jsx)(DT,{tabId:n.tabId,label:s,Icon:l,indicator:d,sessionBadge:f,isActive:o,isPaneFocused:t,showLabel:p.showLabel,closable:u,isPhone:c,width:p.tabWidth,onSelect:i,onClose:a},n.tabId)})}),d?(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 px-1`,children:[(0,q.jsx)(OT,{label:`Split right`,disabledReason:wT,disabled:!f,onClick:m,icon:ta}),(0,q.jsx)(OT,{label:`Split down`,disabledReason:wT,disabled:!f,onClick:h,icon:ba})]}):null]})}function DT({tabId:e,label:t,Icon:n,indicator:r,sessionBadge:i,isActive:a,isPaneFocused:o,showLabel:s,closable:c,isPhone:l,width:d,onSelect:f,onClose:p}){let m=(0,K.useCallback)(()=>f(e),[f,e]),h=(0,K.useCallback)(t=>{t.stopPropagation(),p(e)},[p,e]),g=(0,K.useCallback)(t=>{t.button!==TT||!c||(t.preventDefault(),t.stopPropagation(),p(e))},[c,p,e]),_=(0,K.useCallback)(e=>{e.button===TT&&e.preventDefault()},[]),{attributes:v,listeners:y,setNodeRef:b,isDragging:x}=qt({id:e,disabled:l}),S=(0,q.jsxs)(`div`,{ref:b,...v,...y,role:`tab`,"aria-selected":a,"data-tab-id":e,"data-tab-active":a?`true`:`false`,onClick:m,onAuxClick:g,onMouseDown:_,className:u(`group relative flex shrink-0 cursor-pointer items-center gap-1.5 border-r border-border px-3`,a?`bg-background text-foreground`:`text-muted-foreground hover:bg-muted/40`,l?`touch-pan-x`:`touch-none`,x&&`opacity-50`),style:{width:d},children:[a?(0,q.jsx)(`span`,{"aria-hidden":!0,"data-tab-indicator":o?`focused`:`unfocused`,className:u(`absolute inset-x-0 top-0 h-0.5`,o?`bg-destructive`:`bg-border`)}):null,r?(0,q.jsx)(`span`,{"aria-hidden":!0,"data-tab-status":r.tone,className:`flex size-3.5 shrink-0 items-center justify-center`,children:(0,q.jsx)(`span`,{className:u(`h-2 w-2 rounded-full`,Kt(r.tone))})}):(0,q.jsx)(n,{className:`size-3.5 shrink-0`}),r?(0,q.jsx)(`span`,{className:`sr-only`,children:r.label}):null,i&&s?(0,q.jsx)(`span`,{"aria-hidden":!0,"data-tab-session-badge":!0,className:u(`flex shrink-0 items-center`,i.toneClass),children:(0,q.jsx)(yn,{kind:i.kind})}):null,s?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:t}):null,c?(0,q.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,q.jsx)(ri,{className:`size-3`})}):null]}),C=[];return r&&C.push(r.label),i&&C.push(i.title),s&&C.length===0?S:(0,q.jsxs)(hi,{children:[(0,q.jsx)(vi,{asChild:!0,children:S}),(0,q.jsxs)(gi,{side:`bottom`,children:[(0,q.jsx)(`span`,{children:t}),C.map(e=>(0,q.jsx)(`span`,{className:`block text-muted-foreground`,children:e},e))]})]})}function OT({label:e,icon:t,onClick:n,disabled:r,disabledReason:i}){let a=(0,K.useCallback)(()=>{r||n()},[r,n]);return(0,q.jsxs)(hi,{children:[(0,q.jsx)(vi,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,"aria-label":e,"aria-disabled":r,onClick:a,className:u(`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,q.jsx)(t,{className:`size-3.5`})})}),(0,q.jsx)(gi,{side:`bottom`,children:r&&i?i:e})]})}function kT(e){return(0,q.jsx)(_T.Provider,{init:void 0,children:(0,q.jsx)(AT,{...e})})}function AT({pane:e,isFocused:t,registry:n,presentation:r,onSelectTab:i,onCloseTab:a,onSplit:o}){let s=(0,K.useRef)(null),c=_T.useScopedStoreApi(),l=_T.useScopedStore(e=>e.setLayoutWidth),d=_T.useScopedStore(e=>e.layoutWidth);(0,K.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 f=(0,K.useCallback)(t=>{let n=e.focusedTabId??e.tabs[0]?.tabId;n&&o({tabId:n,paneId:e.id,position:t})},[e.focusedTabId,e.tabs,e.id,o]),p=e.focusedTabId??e.tabs[0]?.tabId??null,m=_T.useScopedStore(e=>e.tabRecency),h=_T.useScopedStore(e=>e.noteTabActivated);(0,K.useEffect)(()=>{p&&h(p)},[p,h]);let g=(0,K.useMemo)(()=>new Set(hT({tabs:e.tabs,activeTabId:p,recency:m})),[e.tabs,p,m]);return(0,q.jsxs)(`div`,{ref:s,className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,q.jsx)(ET,{pane:e,isPaneFocused:t,width:d,presentation:r,onSelectTab:i,onCloseTab:a,onSplit:f}),(0,q.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:e.tabs.filter(e=>g.has(e.tabId)).map(r=>{let i=r.tabId===p;return(0,q.jsx)(`div`,{className:u(`absolute inset-0 flex min-h-0 min-w-0 flex-col`,!i&&`invisible pointer-events-none`),inert:!i,children:vT(n,r.target,e,t&&i,i)},r.tabId)})})]})}var jT=[[`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}]],MT=new Set([`cmd`,`meta`,`ctrl`,`control`,`alt`,`option`,`shift`]);function NT(e){return e.split(`+`).map(e=>e.trim().toLowerCase()).some(e=>MT.has(e))}function PT(e){if(!e)return!1;if(e.isContentEditable)return!0;let t=e.tagName?.toUpperCase();return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function FT(e,t,n){for(let[r,i]of jT){let a=Yn(e,r,t);if(a)return n&&!NT(a)?null:i}return null}var IT=.4;function LT({pointer:e,rect:t,mergeRatio:n=IT}){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 RT(e,t){return e instanceof MouseEvent?{x:e.clientX+t.x,y:e.clientY+t.y}:null}function zT({children:e,onMoveTab:t,onSplitWithTab:n}){let r=Xt(zt(Wt,{activationConstraint:{distance:4}})),i=oT(e=>e.beginDrag),a=oT(e=>e.hoverPane),o=oT(e=>e.clearHover),s=oT(e=>e.endDrag),c=(0,K.useCallback)(e=>i(String(e.active.id)),[i]),l=(0,K.useCallback)(e=>{let t=e.over;if(!t){o();return}let n=RT(e.activatorEvent,e.delta);if(!n){o();return}a(String(t.id),LT({pointer:n,rect:t.rect}))},[o,a]),u=(0,K.useCallback)(e=>{let{intent:r,overPaneId:i}=oT.getState(),a=String(e.active.id);if(s(),!(!e.over||!i||!r)){if(r.kind===`merge`){t(a,i);return}n(a,i,r.position)}},[s,t,n]);return(0,q.jsx)(Gt,{sensors:r,collisionDetection:Ht,onDragStart:c,onDragMove:l,onDragEnd:u,onDragCancel:s,children:e})}function BT(e){let t=[...e.sidebarData.starredProjectGroups,...e.sidebarData.projectGroups].flatMap(e=>[...e.chats,...e.previewChats,...e.olderChats]);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]))])}}var VT={};function HT(e){let t=[...e.starredProjectGroups,...e.projectGroups].flatMap(e=>[...e.chats,...e.previewChats,...e.olderChats]);return Object.fromEntries(t.map(e=>[e.chatId,{title:e.title,status:e.status,unread:e.unread,activity:e.activity,...e.stateEnteredAt==null?{}:{stateEnteredAt:e.stateEnteredAt}}]))}var UT=[],WT=[],GT={},KT=ci(`ChatTabScoped`,()=>e=>({toolGroupExpanded:GT,setToolGroupExpanded:t=>e(e=>({toolGroupExpanded:t(e.toolGroupExpanded)})),resetToolGroupExpanded:()=>e({toolGroupExpanded:GT}),inputHeight:148,setInputHeight:t=>e({inputHeight:t}),showScrollToBottom:!1,setShowScrollToBottom:t=>e({showScrollToBottom:t}),attachments:UT,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:WT,loading:!1,error:null},setMentionSuggestions:t=>e({mentionSuggestions:t}),sharePopoverOpen:!1,setSharePopoverOpen:t=>e({sharePopoverOpen:t}),chatSettingsOpen:!1,setChatSettingsOpen:t=>e({chatSettingsOpen:t})})),qT=(0,K.createContext)(null);function JT(){let e=(0,K.use)(qT);if(!e)throw Error(`useChatTabState must be used inside a ChatTabRoot`);return e}function YT({chatId:e,timer:t,dom:n,children:r}){let i=Tn(e,{timer:t,dom:n});return(0,q.jsx)(qT.Provider,{value:i,children:(0,q.jsx)(KT.Provider,{init:void 0,children:r})})}var XT=c()(e=>({syncingBoardId:null,openCardId:null,syncPanelOpen:!1,schemaPanelOpen:!1,messageByBoard:{},renamingBoardId:null,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}),startRenameBoard:(t,n)=>e({renamingBoardId:t,titleDraft:n}),setTitleDraft:t=>e({titleDraft:t}),stopRenameBoard:()=>e({renamingBoardId:null,titleDraft:``}),startSync:t=>e({syncingBoardId:t}),finishSync:(t,n)=>e(e=>({syncingBoardId:e.syncingBoardId===t?null:e.syncingBoardId,messageByBoard:{...e.messageByBoard,[t]:n}}))})),ZT=c()((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}),reset:()=>e({detail:null,error:null,draft:``,editingFieldId:null,fieldDraft:``,startingWork:!1,startWorkNote:null,resolvingCleanup:!1})})),QT=`add`;function $T(e){return`c:${e}`}function eE({cardId:e,blockers:t,candidates:n,socket:r,onChanged:i,onError:a}){let o=(0,K.useMemo)(()=>new Set(t.map(e=>e.cardId)),[t]),s=(0,K.useMemo)(()=>n.filter(t=>t.id!==e&&!o.has(t.id)),[o,e,n]),c=(0,K.useCallback)(t=>{t!==QT&&r.command({type:`board.card.block`,cardId:e,blockedByCardId:t.slice(2)}).then(i).catch(e=>{a(U(e))})},[e,i,a,r]),l=(0,K.useCallback)(t=>{r.command({type:`board.card.unblock`,cardId:e,blockedByCardId:t}).then(i).catch(e=>{a(U(e))})},[e,i,a,r]);return t.length===0&&s.length===0?null:(0,q.jsxs)(`section`,{children:[(0,q.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:`Blocked by`}),t.length>0?(0,q.jsx)(`ul`,{className:`mb-2 space-y-0.5`,children:t.map(e=>(0,q.jsx)(tE,{blocker:e,onRemove:l},e.cardId))}):null,s.length>0?(0,q.jsxs)(br,{value:QT,onValueChange:c,children:[(0,q.jsx)(pr,{"aria-label":`Add a blocker`,className:`h-8 px-2 text-13`,children:(0,q.jsx)(dr,{})}),(0,q.jsxs)(cr,{children:[(0,q.jsx)(gr,{value:QT,children:`Add a blocker…`}),s.map(e=>(0,q.jsx)(gr,{value:$T(e.id),children:e.title},e.id))]})]}):null]})}function tE({blocker:e,onRemove:t}){let n=(0,K.useCallback)(()=>{t(e.cardId)},[e.cardId,t]);return(0,q.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[e.cleared?(0,q.jsx)(Dr,{"aria-hidden":!0,className:`size-3 shrink-0 text-muted-foreground`}):(0,q.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-warning`}),(0,q.jsx)(`span`,{className:u(`min-w-0 flex-1 truncate text-13`,e.cleared?`text-muted-foreground line-through`:`text-foreground`),children:e.title}),(0,q.jsx)(`span`,{className:`sr-only`,children:e.cleared?`Done`:`Not done`}),(0,q.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,q.jsx)(ri,{"aria-hidden":!0,className:`size-3`})})]})}function nE(e){switch(e){case`agent`:return`Agent`;case`sync`:return`Sync`;case`user`:return`You`}}function rE(e){return e.reused?null:e.movedToColumnId===null?`Started · no column marked active`:null}function iE(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 aE=[];function oE(e){return e.options??aE}function sE(e){return e?.kind===`select`?e.optionId:null}function cE(e){return e?.kind===`multiselect`?e.optionIds:lE}var lE=[];function uE(e,t){let n=cE(e);return n.includes(t)?n.filter(e=>e!==t):[...n,t]}function dE(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 hE(t.value);case`select`:return t.optionId??``;case`multiselect`:return t.optionIds.join(`, `);case`label`:return t.values.join(`, `)}}function fE(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 _E(e,n)?{kind:`select`,optionId:n}:null;case`multiselect`:{let t=vE(n).filter(t=>_E(e,t));return t.length===0?null:{kind:`multiselect`,optionIds:t}}case`label`:{let e=vE(n);return e.length===0?null:{kind:`label`,values:e}}}}function pE(e,t){if(e.kind===`select`){let n=sE(t);return n===null?``:gE(e,n)??``}return e.kind===`multiselect`?cE(t).map(t=>gE(e,t)).filter(e=>e!==null).join(`, `):dE(e,t)}function mE(e,t,n){let r={...e};return n===null?delete r[t]:r[t]=n,r}function hE(e){return new Date(e).toISOString().slice(0,10)}function gE(e,t){return oE(e).find(e=>e.id===t)?.label??null}function _E(e,t){return oE(e).some(e=>e.id===t)}function vE(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e!==``)}function yE(e){switch(e.kind){case`idle`:return`Start work`;case`worktree`:return`Resume`;case`chat`:return`Open chat`}}function bE(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 xE(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 SE(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 CE=[];function wE(e){bn.getState().openTab({kind:`chat`,chatId:e})}var TE=[],EE=[],DE={},OE=[],kE=new Set([`labels`,`assignee`]);function AE(e){return e.filter(e=>e.kind===`chat`).sort((e,t)=>t.createdAt-e.createdAt)}function jE({externalRef:e,content:t}){let n=t.externalUrl,r=n?.kind===`url`?n.value:null;return(0,q.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5`,children:[(0,q.jsxs)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:[`#`,e]}),r?(0,q.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,"aria-label":`Open on GitHub`,className:`text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(Br,{"aria-hidden":!0,className:`size-3`})}):null]})}function ME({cardId:e,socket:t,chatFacts:n,cardFields:r,boardCards:i,onClose:o,onChanged:s}){let c=ZT(e=>e.detail),l=ZT(e=>e.error),d=ZT(e=>e.draft),{setDetail:f,setError:p,setDraft:m,reset:h}=ZT.getState(),g=(0,K.useCallback)(()=>{t.command({type:`board.card.detail`,cardId:e}).then(f).catch(e=>{p(U(e))})},[e,f,p,t]);(0,K.useEffect)(()=>{h(),g()},[g,h]);let _=(0,K.useCallback)(()=>{let n=ZT.getState().draft.trim();n!==``&&(m(``),t.command({type:`board.card.comment`,cardId:e,body:n}).then(()=>{g(),s?.()}).catch(e=>{p(U(e))}))},[e,g,s,m,p,t]),v=(0,K.useCallback)(()=>{g(),s?.()},[g,s]),y=(0,K.useCallback)(()=>{t.command({type:`board.card.archive`,cardId:e}).then(()=>{s?.(),o()}).catch(e=>{p(U(e))})},[e,s,o,p,t]),b=(0,K.useCallback)(()=>{ZT.getState().beginStartWork(),t.command({type:`board.card.startWork`,cardId:e}).then(e=>{wE(e.chatId),ZT.getState().endStartWork(rE(e)),g(),s?.()}).catch(e=>{ZT.getState().endStartWork(null),p(U(e))})},[e,g,s,p,t]),x=(0,K.useCallback)(n=>{ZT.getState().beginCleanup(),t.command({type:`board.card.resolveWorktree`,cardId:e,decision:n}).then(()=>{ZT.getState().endCleanup(),g(),s?.()}).catch(e=>{ZT.getState().endCleanup(),p(U(e))})},[e,g,s,p,t]),S=(0,K.useCallback)(()=>{x(`merge`)},[x]),C=(0,K.useCallback)(()=>{x(`discard`)},[x]),w=(0,K.useCallback)(()=>{x(`leave`)},[x]),T=(0,K.useCallback)(e=>{m(e.currentTarget.value)},[m]),E=(0,K.useCallback)((n,r)=>{let i=ZT.getState().detail?.card.content;i&&t.command({type:`board.card.update`,cardId:e,content:mE(i,n,r)}).then(()=>{g(),s?.()}).catch(e=>{p(U(e))})},[e,g,s,p,t]),D=ZT(e=>e.startingWork),O=ZT(e=>e.startWorkNote),k=ZT(e=>e.resolvingCleanup),A=c?.card??null,j=c?.startWork??null,M=c?.cleanup??null,N=M?bE(M):null,P=M?xE(M):null,F=A?.content??DE,I=r??EE,L=AE(c?.links??TE),ee=n??VT,R=c?.externalRef!=null&&I.length>0&&I.every(e=>kE.has(e.id));return(0,q.jsxs)(`aside`,{className:u(`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,q.jsxs)(`header`,{className:`flex items-start gap-2 border-b border-border px-4 py-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`h2`,{className:`text-15 font-semibold leading-snug text-foreground [text-wrap:pretty]`,children:A?.title??`Loading…`}),c?.externalRef?(0,q.jsx)(jE,{externalRef:c.externalRef,content:F}):null]}),(0,q.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`Close card`,className:`rounded-md p-1 text-muted-foreground hover:bg-secondary`,children:(0,q.jsx)(ri,{className:`size-4`})})]}),l?(0,q.jsx)(`p`,{className:`px-4 py-2 text-13 text-destructive-text`,children:l}):null,(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[j?(0,q.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(a,{size:`sm`,onClick:b,disabled:D||j.blockedReason!==null,children:D?`Starting…`:yE(j.status)}),(0,q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:j.branch})]}),j.blockedReason?(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:j.blockedReason}):null,O?(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:O}):null]}):null,A?(0,q.jsx)(eE,{cardId:A.id,blockers:c?.blockers??OE,candidates:i??CE,socket:t,onChanged:v,onError:p}):null,M?(0,q.jsxs)(`section`,{className:`space-y-2 border border-border p-3`,children:[(0,q.jsxs)(`p`,{className:`text-13 text-foreground [text-wrap:pretty]`,children:[`This card is done. What should happen to `,(0,q.jsx)(`span`,{className:`font-mono`,children:M.branch}),`?`]}),(0,q.jsx)(`p`,{className:`text-13 tabular-nums text-muted-foreground`,children:SE(M)}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(a,{size:`sm`,onClick:S,disabled:k||P!==null,children:`Merge`}),(0,q.jsx)(a,{variant:`secondary`,size:`sm`,onClick:C,disabled:k||N!==null,children:`Discard worktree`}),(0,q.jsx)(a,{variant:`ghost`,size:`sm`,onClick:w,disabled:k,children:`Leave it`})]}),N?(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:N}):null,P?(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:P}):null]}):null,L.length>0?(0,q.jsxs)(`section`,{children:[(0,q.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:`Linked chat`}),(0,q.jsx)(`ul`,{className:`space-y-0.5`,children:L.map(e=>(0,q.jsx)(WE,{chatId:e.targetId,chat:ee[e.targetId]},e.targetId))})]}):null,I.length>0?(0,q.jsx)(`dl`,{className:`space-y-3 text-13`,children:I.map(e=>(0,q.jsx)(NE,{field:e,value:F[e.id],onCommit:E,readOnly:R},e.id))}):null,(0,q.jsxs)(`section`,{children:[(0,q.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:`Comments`}),c&&c.comments.length===0?(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Nothing recorded yet.`}):null,(0,q.jsx)(`ul`,{className:`space-y-3`,children:(c?.comments??[]).map(e=>(0,q.jsxs)(`li`,{className:`border-b border-border pb-3 last:border-b-0`,children:[(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:nE(e.author.kind)}),(0,q.jsx)(`p`,{className:`whitespace-pre-wrap text-13 text-foreground`,children:e.body})]},e.id))})]})]}),(0,q.jsxs)(`footer`,{className:`space-y-2 border-t border-border px-4 py-3`,children:[(0,q.jsx)(Si,{value:d,onChange:T,rows:2,placeholder:`Record what you did…`,"aria-label":`New comment`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(a,{size:`sm`,onClick:_,disabled:d.trim()===``,children:`Comment`}),(0,q.jsx)(a,{variant:`ghost`,size:`sm`,className:`ml-auto text-destructive-text`,onClick:y,children:`Archive`})]})]})]})}function NE({field:e,value:t,onCommit:n,readOnly:r}){let i=e.kind===`longtext`;return(0,q.jsxs)(`div`,{className:i?`space-y-1`:`flex gap-3`,children:[(0,q.jsx)(`dt`,{className:u(`shrink-0 text-muted-foreground`,i?`text-xs font-medium`:`w-20 pt-0.5`),children:e.label}),(0,q.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(FE,{field:e,value:t,onCommit:n,readOnly:r})})]})}function PE({field:e,value:t}){let n=pE(e,t);return(0,q.jsx)(`span`,{className:u(`px-1.5 py-0.5 text-13`,n===``?`text-muted-foreground`:`text-foreground`),children:n===``?IE(e):n})}function FE({readOnly:e,...t}){if(e)return(0,q.jsx)(PE,{field:t.field,value:t.value});switch(t.field.kind){case`select`:return(0,q.jsx)(HE,{...t});case`multiselect`:return(0,q.jsx)(UE,{...t});default:return(0,q.jsx)(zE,{...t})}}function IE(e){return e.required?`Required`:`Empty`}function LE({token:e}){return e?(0,q.jsx)(`span`,{"aria-hidden":!0,className:u(`size-1.5 shrink-0 rounded-full`,zi[e])}):null}var RE={url:`url`,number:`number`,date:`date`};function zE({field:e,value:t,onCommit:n}){let r=ZT(t=>t.editingFieldId===e.id),i=ZT(e=>e.fieldDraft),a=(0,K.useCallback)(()=>{ZT.getState().beginFieldEdit(e.id,dE(e,t))},[e,t]),o=(0,K.useCallback)(e=>{ZT.getState().setFieldDraft(e.currentTarget.value)},[]),s=(0,K.useCallback)(()=>{let t=ZT.getState().takeFieldDraft(e.id);t!==null&&n(e.id,fE(e,t))},[e,n]),c=(0,K.useCallback)(t=>{t.key===`Escape`?ZT.getState().cancelFieldEdit():t.key===`Enter`&&e.kind!==`longtext`&&s()},[e.kind,s]),l=(0,K.useCallback)(e=>{e?.focus()},[]),d=e.kind===`number`||e.kind===`date`,f=pE(e,t);if(r)return e.kind===`longtext`?(0,q.jsx)(Si,{ref:l,value:i,"aria-label":e.label,rows:Math.min(20,Math.max(3,i.split(`
20
+ `).length+1)),onChange:o,onBlur:s,onKeyDown:c}):(0,q.jsx)(`input`,{ref:l,type:RE[e.kind]??`text`,value:i,"aria-label":e.label,"aria-required":e.required||void 0,onChange:o,onBlur:s,onKeyDown:c,className:u(`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,q.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.label}`,onClick:a,className:u(`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===``?IE(e):f});return e.kind===`url`&&f!==``?(0,q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,q.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,q.jsx)(`span`,{className:`truncate`,children:f.replace(/^https:\/\//,``)}),(0,q.jsx)(Br,{"aria-hidden":!0,className:`size-3 shrink-0`})]}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.label}`,onClick:a,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,q.jsx)($r,{"aria-hidden":!0,className:`size-3`})})]}):p}var BE=`c`;function VE(e){return`o:${e}`}function HE({field:e,value:t,onCommit:n}){let r=sE(t),i=(0,K.useCallback)(t=>{n(e.id,t===BE?null:fE(e,t.slice(2)))},[e,n]);return(0,q.jsxs)(br,{value:r===null?BE:VE(r),onValueChange:i,children:[(0,q.jsx)(pr,{"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,q.jsx)(dr,{placeholder:IE(e)})}),(0,q.jsxs)(cr,{children:[(0,q.jsx)(gr,{value:BE,children:IE(e)}),oE(e).map(e=>(0,q.jsx)(gr,{value:VE(e.id),children:(0,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(LE,{token:e.colorToken}),e.label]})},e.id))]})]})}function UE({field:e,value:t,onCommit:n}){let r=cE(t),i=(0,K.useCallback)(r=>{let i=uE(t,r.currentTarget.value);n(e.id,i.length===0?null:{kind:`multiselect`,optionIds:i})},[e.id,n,t]),a=oE(e);return a.length===0?(0,q.jsx)(`span`,{className:`px-1.5 text-muted-foreground`,children:IE(e)}):(0,q.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:a.map(e=>{let t=r.includes(e.id);return(0,q.jsxs)(`button`,{type:`button`,value:e.id,"aria-label":e.label,"aria-pressed":t,onClick:i,className:u(`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,q.jsx)(LE,{token:e.colorToken}),e.label]},e.id)})})}function WE({chatId:e,chat:t}){let n=(0,K.useCallback)(()=>{wE(e)},[e]);if(!t)return(0,q.jsx)(`li`,{className:`px-1.5 py-1 text-13 text-muted-foreground`,children:`This chat no longer exists.`});let r=cn(t),i=iE(t.activity);return(0,q.jsxs)(`li`,{children:[(0,q.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,q.jsx)(`span`,{"aria-hidden":!0,className:`flex h-3 w-1.5 shrink-0 items-center`,children:r?(0,q.jsx)(`span`,{className:u(`size-1.5 rounded-full`,Kt(r.tone))}):null}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-13 text-foreground`,children:t.title}),(0,q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:r?.label??ei(t.status)})]}),i.map(e=>(0,q.jsx)(`p`,{"data-work-row":!0,className:`px-3.5 py-0.5 text-xs text-muted-foreground`,children:e},e))]})}function GE(e){return e.sourceRef.provider===`github-issues`?`${e.sourceRef.owner}/${e.sourceRef.repo}`:null}var KE={repoDraft:``,direction:`pull`,allowAgentPush:!1,rowDirections:{}},qE=c()(e=>({status:null,error:null,saving:!1,repoDraft:``,direction:`pull`,allowAgentPush:!1,rowDirections:{},savingRow:null,confirmingDetach:null,setStatus:t=>e({status:t,error:null,savingRow:null,confirmingDetach:null,...KE}),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}),reset:()=>e({status:null,error:null,saving:!1,savingRow:null,confirmingDetach:null,...KE})})),JE=/^[A-Za-z0-9._-]+$/u;function YE(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||!JE.test(r)||!JE.test(i)?null:{owner:r,repo:i}}var XE=[{value:`pull`,label:`Pull`},{value:`push`,label:`Push`},{value:`both`,label:`Both`}];function ZE(e){let t=e.resolvedAs===`local`?`kept yours`:`took theirs`;return`${e.field} changed in both places · ${t}`}function QE({bindingId:e,onDisconnect:t}){let n=(0,K.useCallback)(()=>{t(e)},[e,t]);return(0,q.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,q.jsx)(ri,{className:`size-3.5`})})}function $E({label:e,column:t,absent:n}){return(0,q.jsxs)(`div`,{className:`flex gap-3`,children:[(0,q.jsx)(`dt`,{className:`w-28 shrink-0 text-muted-foreground`,children:e}),(0,q.jsx)(`dd`,{className:t?`text-foreground`:`text-muted-foreground`,children:t?.title??n})]})}function eD(e,t){if(!e.repo)return!1;let{owner:n,repo:r}=e.repo;return t.some(e=>e.sourceRef.provider===`github-issues`&&e.sourceRef.owner===n&&e.sourceRef.repo===r)}function tD(e,t){return t?e?`Moving…`:`Connecting…`:e?`Move here`:`Connect`}function nD({suggestion:e,direction:t,isConfirming:n,isSaving:r,onConnect:i,onSetDirection:o,onCancelDetach:s}){let c=(0,K.useCallback)(()=>i(e),[i,e]),l=(0,K.useCallback)(t=>o(e.projectId,t),[o,e.projectId]),u=(0,K.useCallback)(()=>s(),[s]),d=e.repo?`${e.repo.owner}/${e.repo.repo}`:null;return(0,q.jsxs)(`li`,{className:`space-y-2 rounded-md border border-border px-3 py-2.5`,children:[(0,q.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`p`,{className:`text-13 font-medium text-foreground`,children:e.projectName}),(0,q.jsx)(`p`,{className:d?`font-mono text-xs text-muted-foreground`:`text-xs italic text-muted-foreground`,children:d??`No remote configured`})]})}),d&&e.boundTo?(0,q.jsx)(`p`,{className:`text-13 text-warning-text [text-wrap:pretty]`,children:n?`Moving "${d}" 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,d?(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(yi,{value:t,onValueChange:l,options:XE,size:`sm`}),(0,q.jsx)(`div`,{className:`flex-1`}),n?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(a,{variant:`ghost`,size:`sm`,onClick:u,disabled:r,children:`Cancel`}),(0,q.jsx)(a,{size:`sm`,onClick:c,disabled:r,children:r?tD(!0,!0):`Confirm move`})]}):(0,q.jsx)(a,{size:`sm`,variant:e.boundTo?`ghost`:`default`,onClick:c,disabled:r,children:tD(e.boundTo!==null,r)})]}):null]})}function rD(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 iD({boardId:e,socket:t,onClose:n}){let r=qE(e=>e.status),i=qE(e=>e.error),o=qE(e=>e.saving),s=qE(e=>e.repoDraft),c=qE(e=>e.direction),l=qE(e=>e.allowAgentPush),u=qE(e=>e.rowDirections),d=qE(e=>e.savingRow),f=qE(e=>e.confirmingDetach),{setStatus:p,setError:m,setRepoDraft:h,setDirection:g,setAllowAgentPush:_,reset:v}=qE.getState(),y=(0,K.useCallback)(()=>{t.command({type:`board.sync.status`,boardId:e}).then(p).catch(e=>{m(U(e))})},[e,m,p,t]);(0,K.useEffect)(()=>{v(),y()},[y,v]);let b=(0,K.useCallback)(e=>{h(e.currentTarget.value)},[h]),x=(0,K.useCallback)(e=>{_(e.currentTarget.checked)},[_]),S=(0,K.useCallback)(()=>{let n=qE.getState(),r=YE(n.repoDraft);if(!r){m(`That is not a repository. Use owner/repo, or paste its GitHub URL.`);return}let i=n.status?.suggestedRepos.find(e=>e.repo?.owner===r.owner&&e.repo?.repo===r.repo);n.beginSave(),t.command({type:`board.sync.bind`,boardId:e,owner:r.owner,repo:r.repo,direction:n.direction,allowAgentPush:n.allowAgentPush,projectId:i?.projectId??null}).then(()=>{qE.getState().endSave(),y()}).catch(e=>{qE.getState().endSave(),m(U(e))})},[e,y,m,t]),C=(0,K.useCallback)(n=>{t.command({type:`board.sync.unbind`,boardId:e,bindingId:n}).then(y).catch(e=>{m(U(e))})},[e,y,m,t]),w=(0,K.useCallback)(n=>{if(!n.repo)return;let r=qE.getState();if(n.boundTo&&r.confirmingDetach!==n.projectId){r.setConfirmingDetach(n.projectId);return}r.setSavingRow(n.projectId),r.setConfirmingDetach(null),t.command({type:`board.sync.bind`,boardId:e,owner:n.repo.owner,repo:n.repo.repo,direction:r.rowDirections[n.projectId]??r.direction,allowAgentPush:r.allowAgentPush,projectId:n.projectId,detachFromBoardId:n.boundTo?.boardId??null}).then(()=>{qE.getState().setSavingRow(null),y()}).catch(e=>{qE.getState().setSavingRow(null),m(U(e))})},[e,y,m,t]),T=(0,K.useCallback)(()=>{let n=qE.getState();if(!n.status)return;let r=n.status.bindings,i=n.status.suggestedRepos.filter(e=>e.repo&&!e.boundTo&&!eD(e,r));i.length!==0&&(n.beginSave(),Promise.all(i.map(r=>t.command({type:`board.sync.bind`,boardId:e,owner:r.repo.owner,repo:r.repo.repo,direction:n.rowDirections[r.projectId]??n.direction,allowAgentPush:n.allowAgentPush,projectId:r.projectId,detachFromBoardId:null}))).then(()=>{qE.getState().endSave(),y()}).catch(e=>{qE.getState().endSave(),m(U(e))}))},[e,y,m,t]),E=(0,K.useCallback)((e,t)=>{qE.getState().setRowDirection(e,t)},[]),D=(0,K.useCallback)(()=>{qE.getState().setConfirmingDetach(null)},[]),O=r?rD(r.routing,c):null,k=r?r.suggestedRepos.filter(e=>!eD(e,r.bindings)):null,A=k?k.filter(e=>e.repo&&!e.boundTo).length:0;return(0,q.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,q.jsxs)(`header`,{className:`flex items-start gap-2 border-b border-border px-4 py-3`,children:[(0,q.jsx)(`h2`,{className:`min-w-0 flex-1 text-15 font-semibold leading-snug text-foreground`,children:`Sync`}),(0,q.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close sync settings`,className:`rounded-md p-1 text-muted-foreground hover:bg-secondary`,children:(0,q.jsx)(ri,{className:`size-4`})})]}),i?(0,q.jsx)(`p`,{className:`px-4 py-2 text-13 text-destructive-text`,children:i}):null,r?(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[(0,q.jsxs)(`section`,{className:`space-y-2`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Direction`}),(0,q.jsx)(yi,{value:c,onValueChange:g,options:XE,size:`sm`})]}),(0,q.jsx)(`section`,{className:`space-y-2`,children:(0,q.jsxs)(`label`,{className:`flex items-start gap-2 text-13 text-foreground`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:l,onChange:x,className:`mt-0.5 accent-primary`}),(0,q.jsxs)(`span`,{children:[`Let agent changes reach GitHub`,(0,q.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,q.jsxs)(`section`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`p`,{className:`flex-1 text-xs font-medium text-muted-foreground`,children:k.length===1?`Repository`:`Repositories`}),A>1?(0,q.jsx)(a,{size:`sm`,onClick:T,disabled:o,children:o?`Connecting…`:`Connect all ${A}`}):null]}),(0,q.jsx)(`ul`,{className:`space-y-2`,children:k.map(e=>(0,q.jsx)(nD,{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,q.jsxs)(`section`,{className:`space-y-2`,children:[(0,q.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,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(pi,{id:`board-sync-repo`,value:s,onChange:b,placeholder:`owner/repo`,spellCheck:!1,className:`flex-1 font-mono text-13`}),(0,q.jsx)(a,{size:`sm`,onClick:S,disabled:o||s.trim().length===0,children:o?`Saving…`:`Connect`})]})]}),r.bindings.length>0?(0,q.jsxs)(`section`,{className:`space-y-2`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Connected repositories`}),(0,q.jsx)(`ul`,{className:`space-y-1`,children:r.bindings.map(e=>(0,q.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border border-border px-2 py-1.5`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-13 text-foreground`,children:GE(e)??e.providerId}),(0,q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.direction}),(0,q.jsx)(QE,{bindingId:e.id,onDisconnect:C})]},e.id))})]}):null,(0,q.jsxs)(`section`,{className:`space-y-2`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Where issues land`}),(0,q.jsxs)(`dl`,{className:`space-y-2 text-13`,children:[(0,q.jsx)($E,{label:`Open issues`,column:r.routing.open,absent:`First column`}),(0,q.jsx)($E,{label:`Closed issues`,column:r.routing.closed,absent:`Nowhere`})]}),O?(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground [text-wrap:pretty]`,children:O}):null]}),(0,q.jsxs)(`section`,{className:`space-y-2`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Conflicts`}),r.conflicts.length===0?(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Nothing has changed in both places.`}):(0,q.jsx)(`ul`,{className:`space-y-2`,children:r.conflicts.map(e=>(0,q.jsxs)(`li`,{className:`border-b border-border pb-2 text-13 last:border-b-0`,children:[(0,q.jsx)(`p`,{className:`text-foreground`,children:ZE(e)}),(0,q.jsx)(`p`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:e.cardId})]},e.id))})]})]}):(0,q.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading sync settings…`})})]})}function aD({token:e,selected:t,label:n,onSelect:r}){return(0,q.jsx)(`button`,{type:`button`,value:e??``,onClick:r,"aria-label":n,"aria-pressed":t,className:u(`flex size-6 items-center justify-center rounded-md border`,t?`border-ring`:`border-transparent hover:border-border`),children:(0,q.jsx)(`span`,{"aria-hidden":!0,className:u(`size-2 rounded-full`,e?zi[e]:`border border-border bg-transparent`)})})}var oD=[`muted-icon`,`info`,`success`,`warning`,`destructive`];function sD(e){return oD.some(t=>t===e)}var cD=[`start`,`active`,`review`,`done`],lD=[`text`,`longtext`,`url`,`number`,`date`,`select`,`multiselect`,`label`];function uD(e){return cD.some(t=>t===e)}function dD(e){return lD.some(t=>t===e)}var fD={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 pD(e){return fD[e]??null}var mD={text:`Text`,longtext:`Long text`,url:`Link`,number:`Number`,date:`Date`,select:`Single choice`,multiselect:`Multiple choice`,label:`Tags`};function hD(e){return e===`select`||e===`multiselect`}function gD(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 _D(e,t){return kD(gD(e),new Set(t.map(e=>e.id)))}function vD(e,t){return kD(gD(e),new Set(t.map(e=>e.id)))}function yD(e,t,n){let r=t.trim();return r===``?e:[...e,{id:_D(r,e),label:r,kind:n,options:hD(n)?[]:null,required:!1}]}function bD(e,t,n){return AD(e,t,e=>({...e,label:n}))}function xD(e,t){return AD(e,t,e=>({...e,required:!e.required}))}function SD(e,t){return e.filter(e=>e.id!==t)}function CD(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 wD(e,t,n){let r=n.trim();return r===``?e:jD(e,t,e=>[...e,{id:vD(r,e),label:r,colorToken:null}])}function TD(e,t,n,r){return jD(e,t,e=>e.map(e=>e.id===n?{...e,label:r}:e))}function ED(e,t,n){return jD(e,t,e=>e.filter(e=>e.id!==n))}function DD(e,t,n,r){let i=sD(r)?r:null;return jD(e,t,e=>e.map(e=>e.id===n?{...e,colorToken:i}:e))}function OD(e){let t=new Set(e.map(e=>e.id));return Object.keys(fD).filter(e=>!t.has(e))}function kD(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}${String(n)}`);)n+=1;return`${e}${String(n)}`}function AD(e,t,n){return e.map(e=>e.id===t?n(e):e)}function jD(e,t,n){return AD(e,t,e=>e.options===null?e:{...e,options:n(e.options)})}var MD=[],ND={},PD=c()(e=>({draft:MD,newLabel:``,newKind:`text`,optionDraftByField:ND,pendingRemovalFieldId:null,saving:!1,error:null,open:t=>e({draft:t,newLabel:``,newKind:`text`,optionDraftByField:ND,pendingRemovalFieldId:null,saving:!1,error:null}),setNewLabel:t=>e({newLabel:t}),setNewKind:t=>e({newKind:dD(t)?t:`text`}),addField:()=>e(e=>({draft:yD(e.draft,e.newLabel,e.newKind),newLabel:``})),renameField:(t,n)=>e(e=>({draft:bD(e.draft,t,n)})),moveField:(t,n)=>e(e=>({draft:CD(e.draft,t,n)})),toggleRequired:t=>e(e=>({draft:xD(e.draft,t)})),askRemoveField:t=>e({pendingRemovalFieldId:t}),cancelRemoveField:()=>e({pendingRemovalFieldId:null}),removeField:t=>e(e=>({draft:SD(e.draft,t),pendingRemovalFieldId:null})),setOptionDraft:(t,n)=>e(e=>({optionDraftByField:{...e.optionDraftByField,[t]:n}})),addOption:t=>e(e=>({draft:wD(e.draft,t,e.optionDraftByField[t]??``),optionDraftByField:{...e.optionDraftByField,[t]:``}})),renameOption:(t,n,r)=>e(e=>({draft:TD(e.draft,t,n,r)})),removeOption:(t,n)=>e(e=>({draft:ED(e.draft,t,n)})),setOptionColor:(t,n,r)=>e(e=>({draft:DD(e.draft,t,n,r)})),beginSave:()=>e({saving:!0,error:null}),endSave:t=>e({saving:!1,error:t})})),FD=[`text`,`longtext`,`url`,`number`,`date`,`select`,`multiselect`,`label`];function ID(){return PD.getState()}function LD({boardId:e,socket:t,onClose:n}){let r=PD(e=>e.draft),i=PD(e=>e.newLabel),o=PD(e=>e.newKind),s=PD(e=>e.saving),c=PD(e=>e.error),l=(0,K.useCallback)(e=>{ID().setNewLabel(e.currentTarget.value)},[]),u=(0,K.useCallback)(e=>{ID().setNewKind(e.currentTarget.value)},[]),d=(0,K.useCallback)(()=>{ID().addField()},[]),f=(0,K.useCallback)(()=>{let r=ID();r.beginSave(),t.command({type:`board.update`,boardId:e,cardFields:r.draft}).then(()=>{ID().endSave(null),n()}).catch(e=>{ID().endSave(U(e))})},[e,n,t]),p=OD(r);return(0,q.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,q.jsxs)(`header`,{className:`flex items-start gap-2 border-b border-border px-4 py-3`,children:[(0,q.jsx)(`h2`,{className:`min-w-0 flex-1 text-15 font-semibold leading-snug text-foreground`,children:`Card fields`}),(0,q.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close card fields`,className:`rounded-md p-1 text-muted-foreground hover:bg-secondary`,children:(0,q.jsx)(ri,{className:`size-4`})})]}),c?(0,q.jsx)(`p`,{className:`px-4 py-2 text-13 text-destructive-text`,children:c}):null,(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[(0,q.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.`}),r.length===0?(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`No fields yet, so cards on this board are title-only.`}):(0,q.jsx)(`ul`,{className:`space-y-4`,children:r.map((e,t)=>(0,q.jsx)(RD,{field:e,first:t===0,last:t===r.length-1},e.id))}),(0,q.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-4`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Add a field`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(pi,{"aria-label":`New field name`,value:i,onChange:l,placeholder:`Name`,className:`min-w-0 flex-1`}),(0,q.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:FD.map(e=>(0,q.jsx)(`option`,{value:e,children:mD[e]},e))})]}),(0,q.jsx)(a,{size:`sm`,variant:`secondary`,onClick:d,disabled:i.trim()===``,children:`Add field`}),p.length>0?(0,q.jsxs)(`p`,{className:`text-13 text-muted-foreground [text-wrap:pretty]`,children:[`Not on this board: `,(0,q.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,q.jsxs)(`footer`,{className:`flex items-center gap-2 border-t border-border px-4 py-3`,children:[(0,q.jsx)(a,{size:`sm`,onClick:f,disabled:s,children:s?`Saving…`:`Save`}),(0,q.jsx)(`span`,{className:`text-13 text-muted-foreground`,children:`Nothing is written until you save.`})]})]})}function RD({field:e,first:t,last:n}){let r=PD(t=>t.pendingRemovalFieldId===e.id),i=PD(t=>t.optionDraftByField[e.id]??``),o=e.id,s=(0,K.useCallback)(e=>{ID().renameField(o,e.currentTarget.value)},[o]),c=(0,K.useCallback)(()=>{ID().moveField(o,-1)},[o]),l=(0,K.useCallback)(()=>{ID().moveField(o,1)},[o]),u=(0,K.useCallback)(()=>{ID().toggleRequired(o)},[o]),d=(0,K.useCallback)(()=>{ID().askRemoveField(o)},[o]),f=(0,K.useCallback)(()=>{ID().cancelRemoveField()},[]),p=(0,K.useCallback)(()=>{ID().removeField(o)},[o]),m=(0,K.useCallback)(e=>{ID().setOptionDraft(o,e.currentTarget.value)},[o]),h=(0,K.useCallback)(()=>{ID().addOption(o)},[o]),g=pD(e.id);return(0,q.jsxs)(`li`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(pi,{"aria-label":`Name of the ${e.id} field`,value:e.label,onChange:s,className:`min-w-0 flex-1`}),(0,q.jsx)(BD,{label:`Move ${e.label} up`,onClick:c,disabled:t,children:(0,q.jsx)(Cr,{"aria-hidden":!0,className:`size-4`})}),(0,q.jsx)(BD,{label:`Move ${e.label} down`,onClick:l,disabled:n,children:(0,q.jsx)(or,{"aria-hidden":!0,className:`size-4`})}),(0,q.jsx)(BD,{label:`Remove ${e.label}`,onClick:d,destructive:!0,children:(0,q.jsx)(tr,{"aria-hidden":!0,className:`size-4`})})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-13 text-muted-foreground`,children:[(0,q.jsx)(`span`,{className:`font-mono text-xs`,children:e.id}),(0,q.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,q.jsx)(`span`,{children:mD[e.kind]}),(0,q.jsxs)(`label`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,q.jsx)(`input`,{type:`checkbox`,"aria-label":`${e.label} is required`,checked:e.required,onChange:u,className:`accent-primary`}),(0,q.jsx)(`span`,{children:`Required`})]})]}),r?(0,q.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border p-2`,children:[(0,q.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,q.jsx)(`p`,{className:`text-13 text-destructive-text [text-wrap:pretty]`,children:g}):null,(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(a,{size:`sm`,variant:`ghost`,className:`text-destructive-text`,onClick:p,children:`Remove`}),(0,q.jsx)(a,{size:`sm`,variant:`secondary`,onClick:f,children:`Keep`})]})]}):null,e.options===null?null:(0,q.jsxs)(`div`,{className:`space-y-2 border-l border-border pl-3`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Options`}),e.options.length===0?(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`No options yet, so this field offers nothing.`}):(0,q.jsx)(`ul`,{className:`space-y-2`,children:e.options.map(t=>(0,q.jsx)(zD,{fieldId:e.id,option:t},t.id))}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(pi,{"aria-label":`New option for ${e.label}`,value:i,onChange:m,placeholder:`Name`,className:`min-w-0 flex-1`}),(0,q.jsx)(a,{size:`sm`,variant:`secondary`,onClick:h,disabled:i.trim()===``,children:`Add option`})]})]})]})}function zD({fieldId:e,option:t}){let n=t.id,r=(0,K.useCallback)(t=>{ID().renameOption(e,n,t.currentTarget.value)},[e,n]),i=(0,K.useCallback)(t=>{ID().setOptionColor(e,n,t.currentTarget.value)},[e,n]),a=(0,K.useCallback)(()=>{ID().removeOption(e,n)},[e,n]);return(0,q.jsxs)(`li`,{className:`space-y-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(pi,{"aria-label":`Name of the ${t.id} option`,value:t.label,onChange:r,className:`min-w-0 flex-1`}),(0,q.jsx)(BD,{label:`Remove option ${t.label}`,onClick:a,destructive:!0,children:(0,q.jsx)(tr,{"aria-hidden":!0,className:`size-4`})})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(aD,{token:null,label:`Colour ${t.id} none`,selected:t.colorToken===null,onSelect:i}),oD.map(e=>(0,q.jsx)(aD,{token:e,label:`Colour ${t.id} ${e}`,selected:t.colorToken===e,onSelect:i},e))]})]})}function BD({label:e,onClick:t,disabled:n,destructive:r,children:i}){return(0,q.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 VD(){var e=[...arguments];return function(){e.forEach(function(e){return e()})}}function HD(e){if(Array.isArray(e))return e}function UD(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 WD(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 GD(e,t){if(e){if(typeof e==`string`)return WD(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)?WD(e,t):void 0}}function KD(){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 qD(e,t){return HD(e)||UD(e,t)||GD(e,t)||KD()}var JD=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})),YD=t((e=>{var t=e&&e.__assign||function(){return t=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},t.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=void 0;var n=JD();function r(e){if(e!==void 0)return typeof e==`boolean`?{capture:e}:e}function i(e,n){return n==null?e:t(t({},e),{options:t(t({},r(n)),r(e.options))})}function a(e,t,r){var a=t.map(function(t){var a=i(t,r);return(0,n.bind)(e,a)});return function(){a.forEach(function(e){return e()})}}e.bindAll=a})),XD=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=e.bind=void 0;var t=JD();Object.defineProperty(e,"bind",{enumerable:!0,get:function(){return t.bind}});var n=YD();Object.defineProperty(e,"bindAll",{enumerable:!0,get:function(){return n.bindAll}})}))(),ZD=`data-pdnd-honey-pot`;function QD(e){return e instanceof Element&&e.hasAttribute(`data-pdnd-honey-pot`)}function $D(e){var t=qD(document.elementsFromPoint(e.x,e.y),2),n=t[0],r=t[1];return n?QD(n)?r??null:n:null}function eO(e){"@babel/helpers - typeof";return eO=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},eO(e)}function tO(e,t){if(eO(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(eO(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function nO(e){var t=tO(e,`string`);return eO(t)==`symbol`?t:t+``}function rO(e,t,n){return(t=nO(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var iO=2147483647,aO={inset:`unset`,border:`none`,padding:0,margin:0,overflow:`visible`,color:`inherit`,background:`transparent`,width:`auto`,height:`auto`};function oO(e){var t=null;return function(){if(!t){var n=[...arguments];t={result:e.apply(this,n)}}return t.result}}var sO=oO(function(){return typeof HTMLElement<`u`&&typeof HTMLElement.prototype.showPopover==`function`});function cO(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 lO(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?cO(Object(n),!0).forEach(function(t){rO(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cO(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var uO=2,dO=uO/2;function fO(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}function pO(e){return{x:e.x-dO,y:e.y-dO}}function mO(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}function hO(e){return{x:Math.min(e.x,window.innerWidth-uO),y:Math.min(e.y,window.innerHeight-uO)}}function gO(e){var t=e.client,n=hO(mO(pO(fO(t))));return DOMRect.fromRect({x:n.x,y:n.y,width:uO,height:uO})}function _O(e){var t=e.clientRect;return{left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`}}function vO(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 yO(e){var t=e.initial,n=document.createElement(`div`);n.setAttribute(ZD,`true`),sO()&&n.setAttribute(`popover`,`manual`);var r=gO({client:t});Object.assign(n.style,lO(lO({position:`fixed`},sO()?aO:{zIndex:iO}),{},{backgroundColor:`transparent`,padding:0,margin:0,boxSizing:`border-box`,pointerEvents:`auto`},_O({clientRect:r}))),document.body.appendChild(n),sO()&&n.showPopover();var i=(0,XD.bind)(window,{type:`pointermove`,listener:function(e){r=gO({client:{x:e.clientX,y:e.clientY}}),Object.assign(n.style,_O({clientRect:r}))},options:{capture:!0}});return function(e){var t=e.current;if(i(),vO({client:t,clientRect:r})){n.remove();return}function a(){o(),n.remove()}var o=(0,XD.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 bO(){var e=null;function t(){return e=null,(0,XD.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=yO({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 xO(e){if(Array.isArray(e))return WD(e)}function SO(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function CO(){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 wO(e){return xO(e)||SO(e)||GD(e)||CO()}var TO=oO(function(){return navigator.userAgent.includes(`Firefox`)}),EO=oO(function(){var e=navigator.userAgent;return e.includes(`AppleWebKit`)&&!e.includes(`Chrome`)});function DO(e){return`nodeName`in e}function OO(e){return DO(e)&&e.ownerDocument!==document}var kO={isLeavingWindow:Symbol(`leaving`),isEnteringWindow:Symbol(`entering`)};(function(){if(typeof window>`u`||!EO())return;function e(){return{enterCount:0,isOverWindow:!1}}var t=e();function n(){t=e()}(0,XD.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[kO.isEnteringWindow]=!0),t.isOverWindow=!0,t.enterCount++}},{type:`dragleave`,listener:function(e){t.enterCount--,t.isOverWindow&&t.enterCount===0&&(e[kO.isLeavingWindow]=!0,t.isOverWindow=!1)}}],{capture:!0})})();function AO(e){var t=e.dragLeave;return EO()?t.hasOwnProperty(kO.isLeavingWindow):!1}function jO(e){var t=e.dragLeave,n=t.type,r=t.relatedTarget;return n===`dragleave`?EO()?AO({dragLeave:t}):r==null?!0:TO()?OO(r):r instanceof HTMLIFrameElement:!1}function MO(e){var t=e.onDragEnd;return[{type:`pointermove`,listener:function(){var e=0;return function(){if(e<20){e++;return}t()}}()},{type:`pointerdown`,listener:t}]}function NO(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 PO=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}(function(e){return e()}),FO=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 IO(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}}),FO.schedule(function(){a({eventName:`onDragStart`,payload:{source:t,location:o}})})},dragUpdate:function(e){var r=e.current;FO.flush(),PO.cancel(),a({eventName:`onDropTargetChange`,payload:{source:t,location:{initial:n,previous:i,current:r}}})},drag:function(e){var r=e.current;PO(function(){FO.flush(),a({eventName:`onDrag`,payload:{source:t,location:{initial:n,previous:i,current:r}}})})},drop:function(e){var r=e.current,o=e.updatedSourcePayload;FO.flush(),PO.cancel(),a({eventName:`onDrop`,payload:{source:o??t,location:{current:r,previous:i,initial:n}}})}}}var LO={isActive:!1};function RO(){return!LO.isActive}function zO(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}function BO(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 VO(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=e.dispatchEvent;if(!RO())return;var a=UO({event:t,dragType:n,getDropTargetsOver:r});LO.isActive=!0;var o={current:a};HO({event:t,current:a.dropTargets});var s=IO({source:n.payload,dispatchEvent:i,initial:a});function c(e){var t=BO({current:o.current.dropTargets,next:e.dropTargets});o.current=e,t&&s.dragUpdate({current:o.current})}function l(e){var t=NO(e),i=r({target:QD(e.target)?$D({x:t.clientX,y:t.clientY}):e.target,input:t,source:n.payload,current:o.current.dropTargets});i.length&&(e.preventDefault(),HO({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(){LO.isActive=!1,f()}var f=(0,XD.bindAll)(window,[{type:`dragover`,listener:function(e){l(e),s.drag({current:o.current})}},{type:`dragenter`,listener:l},{type:`dragleave`,listener:function(e){jO({dragLeave:e})&&(c({input:o.current.input,dropTargets:[]}),n.startedFrom===`external`&&u())}},{type:`drop`,listener:function(e){if(o.current={dropTargets:o.current.dropTargets,input:NO(e)},!o.current.dropTargets.length){u();return}e.preventDefault(),HO({event:e,current:o.current.dropTargets}),s.drop({current:o.current,updatedSourcePayload:n.type===`external`?n.getDropPayload(e):null}),d()}},{type:`dragend`,listener:function(e){o.current={dropTargets:o.current.dropTargets,input:NO(e)},u()}}].concat(wO(MO({onDragEnd:u}))),{capture:!0});s.start({nativeSetDragImage:zO(t)})}function HO(e){var t=e.event,n=e.current[0]?.dropEffect;n!=null&&t.dataTransfer&&(t.dataTransfer.dropEffect=n)}function UO(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=NO(t);return n.startedFrom===`external`?{input:i,dropTargets:[]}:{input:i,dropTargets:r({input:i,source:n.payload,target:t.target,current:[]})}}var WO={canStart:RO,start:VO},GO=new Map;function KO(e){var t=e.typeKey,n=e.mount,r=GO.get(t);if(r)return r.usageCount++,r;var i={typeKey:t,unmount:n(),usageCount:1};return GO.set(t,i),i}function qO(e){var t=KO(e);return function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),GO.delete(e.typeKey))}}function JO(e,t){var n=t.attribute,r=t.value;return e.setAttribute(n,r),function(){return e.removeAttribute(n)}}function YO(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 XO(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?YO(Object(n),!0).forEach(function(t){rO(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YO(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ZO(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=QO(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 QO(e,t){if(e){if(typeof e==`string`)return $O(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)?$O(e,t):void 0}}function $O(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 ek(e){return e.slice(0).reverse()}function tk(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 oO(VD(JO(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(wO(l),[h])})}function l(e){var t=e.eventName,n=e.payload,i=ZO(n.location.current.dropTargets),a;try{for(i.s();!(a=i.n()).done;){var o,s=a.value,c=r.get(s.element),l=XO(XO({},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=ZO(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=XO(XO({},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=ZO(t.location.current.dropTargets),m;try{for(p.s();!(m=p.n()).done;){var h,g,_=m.value;if(!i.has(_.element)){var v=XO(XO({},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=ek(a),l=ek(o),u=[],d=0;d<s.length;d++){var f,p=s[d],m=l[d];if(m!=null){u.push(m);continue}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(XO(XO({},p),{},{isActiveDueToStickiness:!0}))}return ek(u)}return{dropTargetForConsumers:s,getIsOver:f,dispatchEvent:d}}function nk(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=rk(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 rk(e,t){if(e){if(typeof e==`string`)return ik(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)?ik(e,t):void 0}}function ik(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 ak(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 ok(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ak(Object(n),!0).forEach(function(t){rO(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ak(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function sk(){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=ok({},r);e.add(i),n(i);function a(){e.delete(i),t&&t.active.delete(i)}return oO(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=nk(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 ck(e){var t=e.typeKey,n=e.mount,r=e.dispatchEventToSource,i=e.onPostDispatch,a=e.defaultDropEffect,o=sk(),s=tk({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;WO.start({event:t,dragType:n,getDropTargetsOver:s.getIsOver,dispatchEvent:c})}function u(){function e(){return n({canStart:WO.canStart,start:l})}return qO({typeKey:t,mount:e})}return{registerUsage:u,dropTarget:s.dropTargetForConsumers,monitor:o.monitorForConsumers}}var lk=oO(function(){return navigator.userAgent.toLocaleLowerCase().includes(`android`)}),uk=`pdnd:android-fallback`,dk=`text/plain`,fk=`application/vnd.pdnd`,pk=new WeakMap;function mk(e){return pk.set(e.element,e),function(){pk.delete(e.element)}}var hk=bO(),gk=ck({typeKey:`element`,defaultDropEffect:`move`,mount:function(e){return VD(hk.bindEvents(),(0,XD.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=pk.get(n);if(r){var i=NO(t),a={element:r.element,dragHandle:r.dragHandle??null,input:i};if(r.canDrag&&!r.canDrag(a)){t.preventDefault();return}if(r.dragHandle){var o=$D({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=qD(l[c],2),d=u[0],f=u[1];t.dataTransfer.setData(d,f??``)}lk()&&!t.dataTransfer.types.includes(`text/plain`)&&!t.dataTransfer.types.includes(`text/uri-list`)&&t.dataTransfer.setData(dk,uk),t.dataTransfer.setData(fk,``);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=pk.get(i.source.element))==null||(n=t[r])==null||n.call(t,i)},onPostDispatch:hk.getOnPostDispatch()}),_k=gk.dropTarget,vk=gk.monitor;function yk(e){return oO(VD(gk.registerUsage(),mk(e),JO(e.element,{attribute:`draggable`,value:`true`})))}var bk=new Map,xk=new Set;function Sk(e){Ck(e);var t=bk.get(e);if(t)return t;var n={timeOfEngagementStart:Date.now()};return bk.set(e,n),n}function Ck(e){xk.add(e)}function wk(e){xk.clear(),e(),bk.forEach(function(e,t){xk.has(t)||bk.delete(t)}),xk.clear()}function Tk(){bk.clear()}var Ek=new Map;function Dk(e){var t=Ek.get(e);if(t)return t;var n=Ok(e);return Ek.set(e,n),n}function Ok(e){var t={type:`idle`},n=[];function r(e){if(t.type===`running`){var i=e-t.timeLastFrameFinished,a=t.latestArgs,o=$D({x:a.location.current.input.clientX,y:a.location.current.input.clientY});wk(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),Tk(),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){if(t.type===`idle`){a(e);return}t.latestArgs=e}return e({onDragStart:a,onDropTargetChange:o,onDrag:o,onDrop:i}),{onFrame:function(e){n.push(e)}}}var kk=`data-auto-scrollable`,Ak=`[${kk}="true"]`;function jk(e){return e.setAttribute(kk,`true`),function(){return e.removeAttribute(kk)}}function Mk(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 Nk(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Mk(Object(n),!0).forEach(function(t){rO(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mk(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Pk={startHitboxAtPercentageRemainingOfElement:{top:.25,right:.25,bottom:.25,left:.25},maxScrollAtPercentageRemainingOfHitbox:{top:.5,right:.5,bottom:.5,left:.5},timeDampeningDurationMs:400,maxMainAxisHitboxSize:180},Fk={standard:900,fast:1500};function Ik(e){return Nk(Nk({},Pk),{},{maxPixelScrollPerSecond:Fk[e?.maxScrollSpeed??`standard`]})}var Lk={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}},Rk=[`top`,`right`,`bottom`,`left`],zk={top:`vertical`,right:`horizontal`,bottom:`vertical`,left:`horizontal`},Bk={start:`top`,end:`bottom`,point:`y`,size:`height`},Vk={start:`left`,end:`right`,point:`x`,size:`width`},Hk={vertical:{mainAxis:Bk,crossAxis:Vk},horizontal:{mainAxis:Vk,crossAxis:Bk}},Uk={top:`start`,right:`end`,bottom:`end`,left:`start`};function Wk(e){var t=e.edge,n=e.axis;return function(e){var r=e.clientRect,i=e.config,a=Hk[n],o=a.mainAxis,s=a.crossAxis,c=Uk[t],l=Math.min(i.startHitboxAtPercentageRemainingOfElement[t]*r[o.size],i.maxMainAxisHitboxSize);return DOMRect.fromRect(rO(rO(rO(rO({},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 Gk={top:Wk({axis:`vertical`,edge:`top`}),right:Wk({axis:`horizontal`,edge:`right`}),bottom:Wk({axis:`vertical`,edge:`bottom`}),left:Wk({axis:`horizontal`,edge:`left`})};function Kk(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 qk(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 Jk(e){var t=e.client,n=e.axis,r=e.edge,i=e.hitbox,a=e.config,o=Hk[n].mainAxis,s=Uk[r],c=i[o.size]*a.maxScrollAtPercentageRemainingOfHitbox[r];return s===`end`?Kk({startOfRange:i[o.start],endOfRange:i[o.end]-c,value:t[o.point]}):1-Kk({startOfRange:i[o.start]+c,endOfRange:i[o.end],value:t[o.point]})}function Yk(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=qk({timeSinceLastFrame:n,config:c}),u=(s?Jk({client:t,edge:o,hitbox:a,axis:i,config:c}):1)*Kk({startOfRange:r.timeOfEngagementStart,endOfRange:r.timeOfEngagementStart+c.timeDampeningDurationMs,value:Date.now()}),d=Math.max(l*u,1);return Uk[o]===`end`?d:-1*d}function Xk(e,t){return t===`all`||e===t}function Zk(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 Qk(e){return e.getBoundingClientRect()}function $k(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?Qk:s,l={x:n.clientX,y:n.clientY},u=c(t),d=Rk.reduce(function(e,n){var r=Gk[n]({clientRect:u,config:a}),i=zk[n];return!Xk(i,o)||!Zk({client:l,clientRect:r})||!Lk[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 Yk({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?Yk({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 Yk({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?Yk({client:l,edge:n.edge,hitbox:n.hitbox,axis:e,timeSinceLastFrame:r,engagement:i,isDistanceDampeningEnabled:!0,config:a}):0}()}}function eA(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=tA(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 tA(e,t){if(e){if(typeof e==`string`)return nA(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)?nA(e,t):void 0}}function nA(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 rA(e){return!!(e.top||e.left)}function iA(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(!rA(s)||!t)return s;var c=t.closest(Ak);if(!c)return s;var l=i(c);if(!l)return s;function u(){return iA({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=Sk(c),p=Ik(l.getConfiguration?.call(l,d)),m=$k({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 aA(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=eA(a),l;try{for(c.s();!(l=c.n()).done;){var u=l.value;if(!(u.canScroll&&!u.canScroll(s))){var d=$k({element:o,engagement:Sk(o),input:t,config:Ik(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 oA(e){var t=e.input,n=e.findEntry,r=e.timeSinceLastFrame,i=e.source,a=e.getWindowScrollEntries,o=e.underUsersPointer,s=iA({target:o,timeSinceLastFrame:r,input:t,source:i,findEntry:n});rA(s)&&aA({input:t,source:i,entries:a(),timeSinceLastFrame:r,available:s})}function sA(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 cA(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?sA(Object(n),!0).forEach(function(t){rO(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sA(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function lA(e){var t=e.monitor,n=new Map,r=new Set;function i(e){return n.set(e.element,e),oO(VD(jk(e.element),function(){return n.delete(e.element)}))}function a(){var e=cA({},arguments.length>0&&arguments[0]!==void 0?arguments[0]:{});r.add(e);function t(){r.delete(e)}return oO(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;oA({input:t.location.current.input,source:t.source,findEntry:o,underUsersPointer:n,timeSinceLastFrame:r,getWindowScrollEntries:s})}return Dk(t).onFrame(c),{autoScroll:i,autoScrollWindow:a}}var uA=lA({monitor:vk}),dA=uA.autoScroll;uA.autoScrollWindow;function fA(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 pA(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?fA(Object(n),!0).forEach(function(t){rO(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fA(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var mA={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 hA(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:mA[e](o,a)}}).sort(function(e,t){return e.value-t.value})[0]?.edge??null;return pA(pA({},e),{},rO({},_A,s))}function gA(e){return e[_A]??null}var _A=Symbol(`closestEdge`);function vA(e,t){return`${String(e)} ${t}${e===1?``:`s`}`}function yA(e){return e.nextFireAt===null?{tone:`muted`,label:`Scheduled`,clock:null}:{tone:`muted`,label:`Runs in`,clock:{kind:`countdown`,until:e.nextFireAt}}}function bA(e){let{activity:t}=e,n=cn(e),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??ei(`waiting_for_user`),clock:r};if(t.workflow){let{name:e,agentCount:n}=t.workflow;return{tone:`warning`,label:`${e??`Workflow`} · ${vA(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:vA(t.agents,`agent`),clock:r}:n?.tone===`warning`?{tone:`warning`,label:n.label,clock:r}:t.backgroundTasks>0?{tone:`warning`,label:vA(t.backgroundTasks,`background task`),clock:r}:t.cron&&!t.cron.paused?yA(t.cron):n?{tone:n.tone,label:n.label,clock:null}:null}function xA(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=bA(t);if(r)return{chatId:e,...r,linkedCount:n.length}}let r=n[0];return r?{chatId:r.chatId,tone:null,label:vA(n.length,`chat`),linkedCount:n.length,clock:null}:null}function SA(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=CA(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 CA(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 wA(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 TA(e,t,n){let r=e.findIndex(e=>e.id===t);return r<0?null:n===`top`?t:e[r+1]?.id??null}function EA(e,t,n){let r=e.findIndex(e=>e.id===t);return r<0?null:n===`left`?t:e[r+1]?.id??null}function DA(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=e.content.labels,n=t?.kind===`label`?t.values:[];if(!r.some(e=>n.includes(e)))return!1}return!0})}function OA(e,t){return t!==null&&e.createdAt>t}function kA(e,t){return t===null?0:e.filter(e=>OA(e,t)).length}var AA=c()(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 jA(e,t){return n=>n.cardDrop?.columnId===e&&n.cardDrop.beforeCardId===t}function MA(e){return t=>t.cardDrop?.columnId===e&&t.cardDrop.beforeCardId===null}var NA={text:``,labels:[]},PA=c(e=>({filterByBoard:{},setText:(t,n)=>e(e=>({filterByBoard:{...e.filterByBoard,[t]:{...e.filterByBoard[t]??NA,text:n}}})),setLabels:(t,n)=>e(e=>({filterByBoard:{...e.filterByBoard,[t]:{...e.filterByBoard[t]??NA,labels:n}}})),clear:t=>e(e=>{let{[t]:n,...r}=e.filterByBoard;return{filterByBoard:r}})}));function FA(e){return t=>t.filterByBoard[e]??NA}function IA({boardId:e}){let t=PA(FA(e)),n=(0,K.useCallback)(t=>{PA.getState().setText(e,t.currentTarget.value)},[e]),r=(0,K.useCallback)(()=>{PA.getState().clear(e)},[e]),i=t.text.length>0||t.labels.length>0;return(0,q.jsxs)(`div`,{className:`flex items-center gap-1 px-1 pb-1.5`,children:[(0,q.jsx)(`input`,{value:t.text,onChange:n,placeholder:`Filter…`,"aria-label":`Filter cards`,className:u(`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,q.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,q.jsx)(ri,{"aria-hidden":!0,className:`size-3`})}):null]})}var LA={title:``,semantic:null,colorToken:null,wipLimit:null},RA=c()(e=>({openColumnId:null,draft:LA,open:(t,n)=>e({openColumnId:t,draft:n}),close:()=>e({openColumnId:null,draft:LA}),setTitle:t=>e(e=>({draft:{...e.draft,title:t}})),setSemantic:t=>e(e=>({draft:{...e.draft,semantic:uD(t)?t:null}})),setColorToken:t=>e(e=>({draft:{...e.draft,colorToken:sD(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}}})})),zA=[{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 BA({columnId:e,value:t,canDelete:n,onSave:r,onDelete:i}){let o=RA(t=>t.openColumnId===e),s=RA(e=>e.draft),c=(0,K.useCallback)(n=>{let r=RA.getState();n?r.open(e,t):r.close()},[e,t]),l=(0,K.useCallback)(e=>{RA.getState().setTitle(e.currentTarget.value)},[]),u=(0,K.useCallback)(e=>{RA.getState().setWipLimit(e.currentTarget.value)},[]),d=(0,K.useCallback)(e=>{RA.getState().setSemantic(e.currentTarget.value)},[]),f=(0,K.useCallback)(e=>{RA.getState().setColorToken(e.currentTarget.value)},[]),p=(0,K.useCallback)(()=>{let t=RA.getState();t.draft.title.trim()!==``&&(r(e,{...t.draft,title:t.draft.title.trim()}),t.close())},[e,r]),m=(0,K.useCallback)(()=>{i(e),RA.getState().close()},[e,i]),h=zA.find(e=>(e.value===``?null:e.value)===s.semantic)?.hint;return(0,q.jsxs)(Pi,{open:o,onOpenChange:c,children:[(0,q.jsx)(Ni,{asChild:!0,children:(0,q.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,q.jsx)(zr,{"aria-hidden":!0,className:`size-4`})})}),(0,q.jsxs)(Mi,{align:`end`,className:`w-72 space-y-4 p-3`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground`,htmlFor:`column-title-${e}`,children:`Name`}),(0,q.jsx)(pi,{id:`column-title-${e}`,value:s.title,onChange:l})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground`,htmlFor:`column-role-${e}`,children:`Role`}),(0,q.jsx)(`select`,{id:`column-role-${e}`,value:s.semantic??``,onChange:d,className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-13 text-foreground`,children:zA.map(e=>(0,q.jsx)(`option`,{value:e.value,children:e.label},e.label))}),h?(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:h}):null]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Dot`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(aD,{token:null,label:`No dot`,selected:s.colorToken===null,onSelect:f}),oD.map(e=>(0,q.jsx)(aD,{token:e,label:e,selected:s.colorToken===e,onSelect:f},e))]})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground`,htmlFor:`column-wip-${e}`,children:`WIP limit`}),(0,q.jsx)(pi,{id:`column-wip-${e}`,value:s.wipLimit===null?``:String(s.wipLimit),onChange:u,inputMode:`numeric`,placeholder:`None`,className:`tabular-nums`}),(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Advisory. Going over is shown, never blocked.`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border pt-3`,children:[(0,q.jsx)(a,{size:`sm`,onClick:p,disabled:s.title.trim()===``,children:`Save`}),(0,q.jsx)(a,{variant:`ghost`,size:`sm`,className:`ml-auto text-destructive-text`,onClick:m,disabled:!n,children:`Delete`})]}),n?null:(0,q.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Move or archive its cards before deleting it.`})]})]})}var VA=c()(e=>({draft:``,setDraft:t=>e({draft:t}),clear:()=>e({draft:``})})),HA=c()(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 UA(e){return t=>t.draftByColumn[e]??``}var WA=`kanna-board-card`,GA=`kanna-board-column`,KA={current:[]};function qA(e){let{view:t,onCardMove:n,onColumnMove:r}=e,i=(0,K.useRef)(null),a=(0,K.useRef)(t);(0,K.useLayoutEffect)(()=>{a.current=t,KA.current=t.columns});let o=t.board.id,s=PA(FA(o)),c=(0,K.useCallback)(e=>{let t=AA.getState().cardDrop;if(AA.getState().endDrag(),!t)return;let r=SA(a.current,e,t);r&&n(r)},[n]),l=(0,K.useCallback)(e=>{let{columnDropBeforeId:t,columnDropActive:n}=AA.getState();if(AA.getState().endDrag(),!n)return;let i=wA(a.current.columns,e,t);i&&r(i.columnId,i.afterColumnId)},[r]);return(0,K.useEffect)(()=>{let e=i.current;if(e)return dA({element:e})},[]),(0,q.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]??JA,i=n.semantic===`start`,a=i?DA(r,s):r;return(0,q.jsx)(QA,{column:n,cards:a,total:t.counts[n.id]??r.length,newSince:i?t.newSince??null:null,chatLinksByCard:t.chatLinksByCard??XA,chatFacts:e.chatFacts??ZA,onCardDrop:c,onColumnDrop:l,onOpenCard:e.onOpenCard,onLoadMore:e.onLoadMore,onColumnSave:e.onColumnSave,onColumnDelete:e.onColumnDelete,onCardAdd:e.onCardAdd,onMoveToTop:e.onMoveToTop},n.id)}),(0,q.jsx)(sj,{onAdd:e.onColumnAdd,isFirst:t.columns.length===0})]})}var JA=[],YA=[],XA={},ZA={};function QA({column:e,cards:t,total:n,newSince:r,chatLinksByCard:i,chatFacts:a,onOpenCard:o,onLoadMore:s,onColumnSave:c,onColumnDelete:l,onCardAdd:d,onCardDrop:f,onColumnDrop:p,onMoveToTop:m}){let h=(0,K.useRef)(null),g=(0,K.useRef)(null),_=e.id,v=AA(e=>e.draggingColumnId===_),y=AA(e=>e.columnDropActive&&e.columnDropBeforeId===_),b=AA(MA(_));(0,K.useEffect)(()=>{let e=h.current,t=g.current;if(!e||!t)return;let n=AA.getState();return VD(yk({element:e,dragHandle:e.querySelector(`[data-column-handle]`)??void 0,getInitialData:()=>({[GA]:!0,columnId:_}),onDragStart:()=>{n.startColumnDrag(_)},onDrop:()=>{p(_)}}),_k({element:e,canDrop:({source:e})=>e.data[GA]===!0,getData:({input:e,element:t})=>hA({columnId:_},{input:e,element:t,allowedEdges:[`left`,`right`]}),onDragEnter:({self:e})=>{$A(e.data,_)},onDrag:({self:e})=>{$A(e.data,_)}}),_k({element:t,canDrop:({source:e})=>e.data[WA]===!0,getData:()=>({columnId:_}),onDragEnter:()=>{n.setCardDrop({columnId:_,beforeCardId:null})},onDragLeave:()=>{n.setCardDrop(null)}}),dA({element:t}))},[_,p]);let x=Li(n,e.wipLimit),S=(0,K.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=r===null?0:kA(t,r);return(0,q.jsxs)(`div`,{ref:h,className:u(`relative flex h-full w-[300px] shrink-0 flex-col border-r border-border px-3`,v&&`opacity-40`),children:[y?(0,q.jsx)(ij,{}):null,(0,q.jsxs)(`div`,{"data-column-handle":!0,className:`flex cursor-grab items-center gap-2 px-1 pb-2 pt-1`,children:[e.colorToken?(0,q.jsx)(`span`,{"aria-hidden":!0,className:u(`size-1.5 shrink-0 rounded-full`,zi[e.colorToken])}):null,(0,q.jsx)(`span`,{className:`truncate text-[0.9375rem] font-semibold leading-tight text-foreground`,children:e.title}),(0,q.jsx)(`span`,{className:u(`ml-auto font-mono text-xs tabular-nums`,x?`text-warning-text`:`text-muted-foreground`),children:C&&w>0?(0,q.jsxs)(q.Fragment,{children:[n,(0,q.jsxs)(`span`,{className:`text-info-text`,children:[` · `,w,` new`]})]}):n}),(0,q.jsx)(BA,{columnId:_,value:S,canDelete:n===0,onSave:c,onDelete:l})]}),C?(0,q.jsx)(IA,{boardId:e.boardId}):null,(0,q.jsxs)(`div`,{ref:g,className:`min-h-0 flex-1 space-y-2 overflow-y-auto px-1 py-2`,children:[t.map(e=>(0,q.jsx)(ej,{card:e,columnId:_,cards:t,chatIds:i[e.id]??YA,chatFacts:a,newSince:r,onOpen:o,onCardDrop:f,onMoveToTop:m},e.id)),b?(0,q.jsx)(rj,{}):null,n>t.length?(0,q.jsx)(aj,{columnId:_,onLoadMore:s}):null]}),(0,q.jsx)(oj,{columnId:_,onAdd:d})]})}function $A(e,t){let n=gA(e);if(n!==`left`&&n!==`right`)return;let r=EA(KA.current,t,n);AA.getState().setColumnDrop(r,!0)}function ej({card:e,columnId:t,cards:n,chatIds:r,chatFacts:i,newSince:a,onOpen:o,onCardDrop:s,onMoveToTop:c}){let l=(0,K.useRef)(null),d=e.id,f=AA(e=>e.draggingCardId===d),p=AA(jA(t,d)),m=(0,K.useRef)(n);(0,K.useLayoutEffect)(()=>{m.current=n}),(0,K.useEffect)(()=>{let e=l.current;if(!e)return;let n=AA.getState();return VD(yk({element:e,getInitialData:()=>({[WA]:!0,cardId:d}),onDragStart:()=>{n.startCardDrag(d)},onDrop:()=>{s(d)}}),_k({element:e,canDrop:({source:e})=>e.data[WA]===!0,getData:({input:e,element:t})=>hA({cardId:d},{input:e,element:t,allowedEdges:[`top`,`bottom`]}),onDragEnter:({self:e})=>{nj(e.data,t,d,m.current)},onDrag:({self:e})=>{nj(e.data,t,d,m.current)}}))},[d,t,s]);let h=(0,K.useCallback)(()=>{o(d)},[d,o]),g=(0,K.useCallback)(()=>{c(d)},[d,c]),_=xA(r,i),v=OA(e,a);return(0,q.jsxs)(`div`,{ref:l,className:`relative`,children:[p?(0,q.jsx)(rj,{}):null,(0,q.jsxs)(wn,{children:[(0,q.jsx)($t,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,onClick:h,className:u(`w-full cursor-grab rounded-lg border border-border bg-card px-3 py-2 text-left`,`transition-colors duration-150 hover:bg-secondary`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,f&&`opacity-40`),children:[(0,q.jsx)(`span`,{className:`line-clamp-2 text-sm font-medium leading-snug text-foreground [text-wrap:pretty]`,children:e.title}),v?(0,q.jsxs)(`span`,{className:`mt-1 flex items-center gap-1 text-xs text-info-text`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-info`}),(0,q.jsx)(`span`,{children:`New`})]}):null,_?(0,q.jsxs)(`span`,{className:u(`mt-1.5 flex items-center gap-1.5 text-xs`,Rt(_.tone)),children:[_.tone?(0,q.jsx)(`span`,{"aria-hidden":!0,className:u(`size-1.5 shrink-0 rounded-full`,Kt(_.tone))}):(0,q.jsx)(pa,{"aria-hidden":!0,className:`size-3 shrink-0`}),(0,q.jsx)(`span`,{children:_.label}),_.clock===null?null:(0,q.jsx)(tj,{clock:_.clock})]}):null]})}),(0,q.jsx)(Ut,{children:(0,q.jsx)(Qt,{onSelect:g,children:`Move to top`})})]})]})}function tj({clock:e}){let t=qr(1e3),n=e.kind===`elapsed`?Ai(Math.max(0,t-e.since)):ki(e.until-t);return(0,q.jsx)(`span`,{className:`tabular-nums`,children:n})}function nj(e,t,n,r){let i=gA(e);if(i!==`top`&&i!==`bottom`)return;let a=TA(r,n,i);AA.getState().setCardDrop({columnId:t,beforeCardId:a})}function rj(){return(0,q.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-px w-full rounded-full bg-primary`})}function ij(){return(0,q.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 left-0 w-px bg-primary`})}function aj({columnId:e,onLoadMore:t}){let n=(0,K.useRef)(null);return(0,K.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,q.jsxs)(`div`,{ref:n,className:`space-y-2`,"aria-hidden":!0,children:[(0,q.jsx)(`div`,{className:`h-14 w-full animate-pulse rounded-lg border border-border bg-secondary`}),(0,q.jsx)(`div`,{className:`h-14 w-full animate-pulse rounded-lg border border-border bg-secondary`})]})}function oj({columnId:e,onAdd:t}){let n=HA(UA(e)),r=(0,K.useCallback)(t=>{HA.getState().setDraft(e,t.currentTarget.value)},[e]),i=(0,K.useCallback)(n=>{n.preventDefault();let r=(HA.getState().draftByColumn[e]??``).trim();r!==``&&(HA.getState().clear(e),t(e,r))},[e,t]);return(0,q.jsx)(`form`,{onSubmit:i,className:`shrink-0 px-1 pb-1 pt-2`,children:(0,q.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 sj({onAdd:e,isFirst:t}){let n=VA(e=>e.draft),r=(0,K.useCallback)(e=>{VA.getState().setDraft(e.currentTarget.value)},[]),i=(0,K.useCallback)(t=>{t.preventDefault();let n=VA.getState().draft.trim();n!==``&&(VA.getState().clear(),e(n))},[e]);return(0,q.jsxs)(`form`,{onSubmit:i,className:`w-64 shrink-0 px-3 pt-1`,children:[t?(0,q.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,q.jsx)(`input`,{value:n,onChange:r,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 cj(e,t){let n=lj(e,t.cardId);if(n===null||!(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(uj(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 lj(e,t){for(let[n,r]of Object.entries(e.cards))if(r.some(e=>e.id===t))return n;return null}function uj(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 dj(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 fj=[];function pj({boardId:e,socket:t,chatFacts:n,onOpenCard:r,onOpenBoards:i}){let o=Ri(Fi(e)),s=Ri(Ii(e));(0,K.useEffect)(()=>t.subscribe({type:`board`,boardId:e,pageSize:s},e=>{Ri.getState().setBoardView(e.boardId,e.view)}),[e,s,t]);let c=(0,K.useCallback)(n=>{let r=Ri.getState().viewByBoard[e];r&&Ri.getState().setBoardView(e,cj(r,n)),t.command({type:`board.card.move`,cardId:n.cardId,toColumnId:n.toColumnId,aboveCardId:n.aboveCardId,belowCardId:n.belowCardId}).catch(()=>{})},[e,t]),l=XT(e=>e.openCardId),d=(0,K.useCallback)(e=>{XT.getState().openCard(e),r?.(e)},[r]),f=(0,K.useCallback)(()=>{XT.getState().closeCard()},[]),p=XT(e=>e.syncPanelOpen),m=(0,K.useCallback)(()=>{XT.getState().openSyncPanel()},[]),h=(0,K.useCallback)(()=>{XT.getState().closeSyncPanel()},[]),g=XT(e=>e.schemaPanelOpen),_=(0,K.useCallback)(()=>{let t=Ri.getState().viewByBoard[e];t&&(PD.getState().open(t.board.cardFields),XT.getState().openSchemaPanel())},[e]),v=(0,K.useCallback)(()=>{XT.getState().closeSchemaPanel()},[]),y=XT(t=>t.syncingBoardId===e),b=XT(t=>t.messageByBoard[e]??null),x=(0,K.useCallback)(()=>{let n=XT.getState();n.startSync(e),t.command({type:`board.sync.pull`,boardId:e}).then(t=>{let r=t.conflicts>0?`, ${String(t.conflicts)} conflicts`:``;n.finishSync(e,`Synced · ${String(t.created)} new, ${String(t.updated)} updated${r}`)}).catch(t=>{n.finishSync(e,U(t))})},[e,t]),S=(0,K.useCallback)((n,r)=>{let i=Ri.getState().viewByBoard[e];i&&Ri.getState().setBoardView(e,dj(i,n,r)),t.command({type:`board.column.move`,columnId:n,afterColumnId:r}).catch(()=>{})},[e,t]),C=(0,K.useCallback)((n,r)=>{t.command({type:`board.column.update`,columnId:n,title:r.title,semantic:r.semantic,colorToken:r.colorToken,wipLimit:r.wipLimit}).catch(t=>{XT.getState().finishSync(e,U(t))})},[e,t]),w=(0,K.useCallback)(n=>{t.command({type:`board.column.delete`,columnId:n}).catch(t=>{XT.getState().finishSync(e,U(t))})},[e,t]),T=(0,K.useCallback)(n=>{let r=Ri.getState().viewByBoard[e]?.columns.at(-1)?.id??null;t.command({type:`board.column.create`,boardId:e,title:n,afterColumnId:r}).catch(t=>{XT.getState().finishSync(e,U(t))})},[e,t]),E=(0,K.useCallback)(n=>{let r=Ri.getState().viewByBoard[e];if(!r)return;let i=Object.values(r.cards).flat().find(e=>e.id===n);if(!i)return;let a=(r.cards[i.columnId]??[])[0];a?.id!==n&&t.command({type:`board.card.move`,cardId:n,toColumnId:i.columnId,aboveCardId:null,belowCardId:a?.id??null}).catch(()=>{})},[e,t]),D=(0,K.useCallback)((n,r)=>{let i=Ri.getState().viewByBoard[e]?.cards[n]?.at(-1)?.id??null;t.command({type:`board.card.create`,boardId:e,columnId:n,title:r,afterCardId:i}).catch(t=>{XT.getState().finishSync(e,U(t))})},[e,t]),O=XT(t=>t.renamingBoardId===e),k=XT(e=>e.titleDraft),A=(0,K.useCallback)(()=>{let t=Ri.getState().viewByBoard[e];t&&XT.getState().startRenameBoard(e,t.board.title)},[e]),j=(0,K.useCallback)(e=>{XT.getState().setTitleDraft(e.currentTarget.value)},[]),M=(0,K.useCallback)(()=>{let{titleDraft:n}=XT.getState(),r=Ri.getState().viewByBoard[e];XT.getState().stopRenameBoard();let i=n.trim();i!==``&&i!==r?.board.title&&t.command({type:`board.update`,boardId:e,title:i}).catch(t=>{XT.getState().finishSync(e,U(t))})},[e,t]),N=(0,K.useCallback)(e=>{e.key===`Enter`&&M(),e.key===`Escape`&&XT.getState().stopRenameBoard()},[M]),P=(0,K.useCallback)(e=>{e?.select()},[]),F=(0,K.useCallback)(()=>{Ri.getState().growPage(e)},[e]),I=o&&o.board.ownerKind===`project`&&i?o.board.ownerId:null,L=(0,K.useCallback)(()=>{I&&i?.(I)},[i,I]),ee=(0,K.useMemo)(()=>o?o.columns.flatMap(e=>(o.cards[e.id]??[]).map(e=>({id:e.id,title:e.title}))):fj,[o]);return o?(0,q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-background`,children:[(0,q.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border px-3 py-1.5`,children:[I?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,onClick:L,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,q.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-13 text-muted-foreground`,children:`/`})]}):null,O?(0,q.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,q.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,q.jsx)(`span`,{className:`truncate font-mono text-xs tabular-nums text-muted-foreground`,children:b}):null,(0,q.jsxs)(a,{variant:`secondary`,size:`sm`,className:`ml-auto`,onClick:x,disabled:y,children:[(0,q.jsx)(Hr,{"aria-hidden":!0,className:u(`size-3.5`,y&&`animate-spin`)}),y?`Syncing…`:`Sync`]}),(0,q.jsx)(a,{variant:`ghost`,size:`sm`,onClick:_,"aria-label":`Card fields`,children:(0,q.jsx)(fa,{"aria-hidden":!0,className:`size-3.5`})}),(0,q.jsx)(a,{variant:`ghost`,size:`sm`,onClick:m,"aria-label":`Sync settings`,children:(0,q.jsx)(ur,{"aria-hidden":!0,className:`size-3.5`})})]}),(0,q.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[p?(0,q.jsx)(iD,{boardId:e,socket:t,onClose:h}):null,g?(0,q.jsx)(LD,{boardId:e,socket:t,onClose:v}):null,l?(0,q.jsx)(ME,{cardId:l,socket:t,chatFacts:n,cardFields:o.board.cardFields,boardCards:ee,onClose:f}):null,(0,q.jsx)(qA,{view:o,chatFacts:n,onCardMove:c,onColumnMove:S,onOpenCard:d,onLoadMore:F,onColumnSave:C,onColumnDelete:w,onColumnAdd:T,onCardAdd:D,onMoveToTop:E})]})]}):(0,q.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background p-8`,children:(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading board…`})})}var mj=22.5,hj=3,gj=3,_j=2;function vj(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=_j+(i>0?e/i:0)*17;return{x:hj+t*gj,topY:yj(mj-n),live:!1}});return n&&a.push({x:hj+r.length*gj,topY:yj(3.5),live:!0}),{ticks:a,baselineY:mj,size:26}}function yj(e){return Math.round(e*100)/100}function bj(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 xj=(0,K.createContext)(null);function Sj(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function Cj(){let e=(0,K.useContext)(xj);return e??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);throw 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.`)}(8),e}var wj=R?K.useLayoutEffect:K.useEffect,Tj={tag:N};function Ej({initialConfig:e,children:t}){let n=(0,K.useMemo)(()=>{let{theme:t,namespace:n,nodes:r,onError:i,onWarn:a,editorState:o,html:s}=e,c=Sj(null,t),l=j({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=Pe();if(t.isEmpty()){let n=_e();t.append(n);let r=e.getRootElement(),i=R&&r!==null?Ie(r):null;(je()!==null||i!==null&&i===r)&&n.select()}},Tj);else if(t!==null)switch(typeof t){case`string`:{let n=e.parseEditorState(t);e.setEditorState(n,Tj);break}case`object`:e.setEditorState(t,Tj);break;case`function`:e.update(()=>{Pe().isEmpty()&&t(e)},Tj)}}}(l,o),[l,c]},[]);return wj(()=>{let t=e.editable,[r]=n;r.setEditable(t===void 0||t)},[]),(0,q.jsx)(xj.Provider,{value:n,children:t})}var Dj=R?K.useLayoutEffect:K.useEffect;function Oj(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function kj(){return function(e){let[t]=Cj(),n=(0,K.useMemo)(()=>e(t),[t,e]),[r,i]=(0,K.useState)(()=>n.initialValueFn()),a=(0,K.useRef)(r);return Dj(()=>{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}(Oj)}var Aj=F({name:`@lexical/react/ReactProvider`});function jj(){return Pe().getTextContent()}function Mj(e,t=!0){if(e)return!1;let n=jj();return t&&(n=n.trim()),n===``}function Nj(e){if(!Mj(e,!1))return!1;let t=Pe().getChildren(),n=t.length;if(n>1)return!1;for(let e=0;e<n;e++){let n=t[e];if(he(n))return!1;if(ue(n)){if(!z(n)||n.__indent!==0)return!1;let t=n.getChildren(),r=t.length;for(let n=0;n<r;n++){let n=t[e];if(!Me(n))return!1}}}return!0}function Pj(e){return()=>Nj(e)}function Fj(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);throw 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.`)}var Ij=R?K.useLayoutEffect:K.useEffect;function Lj({editor:e,ErrorBoundary:t}){return function(e,t){let[n,r]=(0,K.useState)(()=>e.getDecorators());return Ij(()=>e.registerDecoratorListener(e=>{(0,Aa.flushSync)(()=>{r(e)})}),[e]),(0,K.useEffect)(()=>{r(e.getDecorators())},[e]),(0,K.useMemo)(()=>{let r=[],i=Object.keys(n);for(let a=0;a<i.length;a++){let o=i[a],s=(0,q.jsx)(t,{onError:t=>e._onError(t),children:(0,q.jsx)(K.Suspense,{fallback:null,children:n[o]})}),c=e.getElementByKey(o);c!==null&&r.push((0,Aa.createPortal)(s,c,o))}return r},[t,n,e])}(e,t)}function Rj({editor:e,ErrorBoundary:t}){return function(e){let t=L.maybeFromEditor(e);if(t&&t.hasExtensionByName(Aj.name)){for(let e of[`@lexical/plain-text`,`@lexical/rich-text`])t.hasExtensionByName(e)&&Fj(320,e);return!0}return!1}(e)?null:(0,q.jsx)(Lj,{editor:e,ErrorBoundary:t})}function zj(e){return e.read(`latest`,Pj(e.isComposing()))}function Bj({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){let[r]=Cj();return function(e){Ij(()=>Te(de(e),Ia(e)),[e])}(r),(0,q.jsxs)(q.Fragment,{children:[e,(0,q.jsx)(Vj,{content:t}),(0,q.jsx)(Rj,{editor:r,ErrorBoundary:n})]})}function Vj({content:e}){let[t]=Cj(),n=function(e){let[t,n]=(0,K.useState)(()=>zj(e));return Ij(()=>{function t(){let t=zj(e);n(t)}return t(),Te(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),r=kj();return n?typeof e==`function`?e(r):e:null}var Hj=R?K.useLayoutEffect:K.useEffect;function Uj({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=`textbox`,spellCheck:_=!0,style:v,tabIndex:y,"data-testid":b,...x},S){let[C,w]=(0,K.useState)(e.isEditable()),T=(0,K.useCallback)(t=>{t&&t.ownerDocument&&t.ownerDocument.defaultView?e.setRootElement(t):e.setRootElement(null)},[e]),E=(0,K.useMemo)(()=>function(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n!=null&&(n.current=t)}}(S,T),[T,S]);return Hj(()=>(w(e.isEditable()),e.registerEditableListener(e=>{w(e)})),[e]),(0,q.jsx)(`div`,{"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":C&&g===`combobox`?!!o: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,autoCapitalize:p,className:m,contentEditable:C,"data-testid":b,id:h,ref:E,role:g,spellCheck:_,style:v,tabIndex:y??(C?void 0:-1),...x})}var Wj=(0,K.forwardRef)(Uj);function Gj(e){return e.read(`latest`,Pj(e.isComposing()))}var Kj=(0,K.forwardRef)(qj);function qj(e,t){let{placeholder:n,...r}=e,[i]=Cj();return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Wj,{editor:i,...r,ref:t}),n!=null&&(0,q.jsx)(Jj,{editor:i,content:n})]})}function Jj({content:e,editor:t}){let n=function(e){let[t,n]=(0,K.useState)(()=>Gj(e));return Hj(()=>{function t(){let t=Gj(e);n(t)}return t(),Te(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),[r,i]=(0,K.useState)(t.isEditable());if((0,K.useLayoutEffect)(()=>(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,q.jsx)(`div`,{"aria-hidden":!0,children:a})}function Yj(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(!(P(a)&&P(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||ne(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)&&Me(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!Me(l)||!Me(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}function Xj(e,t,n){let r=n(),i=0,a=r,o=0,s=null;return(c,l,u,d,f,p)=>{let m=n();if(p.has(`composition-start`)&&(a=r,o=i,s=c),p.has(`historic`))return i=0,r=m,2;p.has(`composition-end`)&&s&&(r=a,i=o,c=s);let h=p.has(`paste`)||p.has(`cut`)?0:Yj(c,l,d,f,e.isComposing()),g=(()=>{let n=u===null||u.editor===e,a=p.has(Fe);if(!a&&n&&p.has(`history-merge`))return 0;if(h===1)return 2;if(c===null)return 1;let o=l._selection;if(!(d.size>0||f.size>0))return o===null?2:0;let s=typeof t==`number`?t:t.peek();return!1===a&&h!==0&&h===i&&m<r+s&&n||d.size===1&&function(e,t,n){let r=t._nodeMap.get(e),i=n._nodeMap.get(e),a=t._selection,o=n._selection;return!(P(a)&&P(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!Me(r)||!Me(i)||r.__parent!==i.__parent)&&JSON.stringify(t.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>i.exportJSON()))}(Array.from(d)[0],c,l)?0:1})();return r=m,i=h,g}}function Zj(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function Qj(e,t,n,r=Date.now,i,a=null){let o=Xj(e,n,r),s=()=>{i&&i(t)};return s(),Te(e.registerCommand(ke,()=>(function(e,t,n){let r=t.redoStack,i=t.undoStack;if(i.length!==0){let a=t.current,o=i.pop();a!==null&&(r.push(a),e.dispatchCommand(E,!0)),i.length===0&&e.dispatchCommand(be,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(ge,()=>(function(e,t,n){let r=t.redoStack,i=t.undoStack;if(r.length!==0){let a=t.current;a!==null&&(i.push(a),e.dispatchCommand(be,!0));let o=r.pop();r.length===0&&e.dispatchCommand(E,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(we,()=>(Zj(t,i),!1),0),e.registerCommand(Oe,()=>(Zj(t,i),e.dispatchCommand(E,!1),e.dispatchCommand(be,!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){if(d.length!==0&&(t.redoStack=[],e.dispatchCommand(E,!1)),u!==null){f.push({...u});let t=typeof a==`number`||a===null?a:a.peek();t!==null&&f.length>t&&f.splice(0,f.length-t),e.dispatchCommand(be,!0)}}else if(m===2)return;t.current={editor:e,editorState:n},s()}))}function $j(){return{current:null,redoStack:[],undoStack:[]}}Date.now;function eM({delay:e,externalHistoryState:t}){let[n]=Cj();return function(e,t,n=1e3){let r=(0,K.useMemo)(()=>t||$j(),[t]);(0,K.useEffect)(()=>Qj(e,r,n),[n,e,r])}(n,t,e),null}var tM=K.forwardRef(({className:e,children:t,...n},r)=>(0,q.jsx)(`div`,{ref:r,className:u(`relative overflow-y-auto overscroll-contain touch-pan-y`,e),style:{WebkitOverflowScrolling:`touch`},...n,children:t}));tM.displayName=`ScrollArea`;var nM=`(display-mode: standalone)`;function rM(e={dom:o}){let[t,n]=(0,K.useState)(()=>{let t=e.dom.isIOSStandalone(),n=e.dom.matchesMediaQuery(nM);return t||n});return(0,K.useEffect)(()=>e.dom.addMediaQueryListener(nM,t=>{n(t||e.dom.isIOSStandalone())}),[e.dom]),t}function iM(e){return e===null||!Number.isFinite(e)?null:e<10?`${e.toFixed(1).replace(/\.0$/,``)}%`:`${Math.round(e)}%`}function aM({usage:e}){let t=iM(e.usedPercentage),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,q.jsxs)(Pi,{children:[(0,q.jsx)(Ni,{asChild:!0,children:(0,q.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 ${vt(e.usedTokens)} tokens used`,children:(0,q.jsxs)(`span`,{className:`relative flex h-6 w-6 items-center justify-center`,children:[(0,q.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:`-rotate-90 absolute inset-0 h-full w-full transform-gpu`,"aria-hidden":`true`,children:[(0,q.jsx)(`circle`,{cx:`12`,cy:`12`,r,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`text-muted-foreground/20`}),(0,q.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,q.jsx)(`span`,{className:u(`relative flex size-5 items-center justify-center rounded-full bg-background text-xs font-medium`,`text-muted-foreground`),children:e.usedPercentage===null?vt(e.usedTokens):Math.round(e.usedPercentage)})]})})}),(0,q.jsx)(Mi,{side:`top`,align:`center`,className:`w-max max-w-none px-3 py-2`,children:(0,q.jsx)(`div`,{className:`space-y-1.5 leading-tight`,children:e.maxTokens!==void 0&&t?(0,q.jsxs)(`div`,{className:`whitespace-nowrap text-xs font-medium text-foreground`,children:[(0,q.jsx)(`span`,{children:t}),(0,q.jsx)(`span`,{className:`mx-1`,children:`·`}),(0,q.jsx)(`span`,{children:vt(e.usedTokens)}),(0,q.jsx)(`span`,{children:`/`}),(0,q.jsxs)(`span`,{children:[vt(e.maxTokens),` context used`]})]}):(0,q.jsxs)(`div`,{className:`text-sm text-foreground`,children:[vt(e.usedTokens),` tokens used so far`]})})})]})}function oM({totals:e,className:t}){if(!e)return null;let n=e.cacheHitPercentage===null?null:uM(e.cacheHitPercentage),r=e.costUsd>0?_t(e.costUsd):null;return(0,q.jsxs)(Pi,{children:[(0,q.jsx)(Ni,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,"aria-label":dM(e,n,r),className:u(`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,q.jsx)(sM,{label:`in`,value:vt(e.inputTokens)}),(0,q.jsx)(cM,{}),(0,q.jsx)(sM,{label:`out`,value:vt(e.outputTokens)}),n===null?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(cM,{}),(0,q.jsx)(sM,{label:`cache`,value:n})]}),r===null?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(cM,{}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:r})]})]})}),(0,q.jsx)(Mi,{side:`top`,align:`center`,className:`w-max max-w-none px-3 py-2`,children:(0,q.jsxs)(`div`,{className:`space-y-1 text-xs leading-tight`,children:[(0,q.jsx)(lM,{label:`Input`,value:vt(e.inputTokens)}),(0,q.jsx)(lM,{label:`Output`,value:vt(e.outputTokens)}),(0,q.jsx)(lM,{label:`Cache read`,value:vt(e.cachedTokens)}),n===null?null:(0,q.jsx)(lM,{label:`Cache hit`,value:n}),r===null?null:(0,q.jsx)(lM,{label:`Cost`,value:r})]})})]})}function sM({label:e,value:t}){return(0,q.jsxs)(`span`,{className:`inline-flex items-baseline gap-1 tabular-nums`,children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,q.jsx)(`span`,{children:e})]})}function cM(){return(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground/50`,children:`·`})}function lM({label:e,value:t}){return(0,q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-6 whitespace-nowrap`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,q.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:t})]})}function uM(e){let t=Math.max(0,Math.min(100,e));return t<10?`${t.toFixed(1).replace(/\.0$/,``)}%`:`${Math.round(t)}%`}function dM(e,t,n){let r=[`Input ${vt(e.inputTokens)}`,`Output ${vt(e.outputTokens)}`,`Cache ${vt(e.cachedTokens)}`];return t!==null&&r.push(`hit ${t}`),n!==null&&r.push(`cost ${n}`),`Session tokens: ${r.join(`, `)}`}var fM=class extends Error{constructor(){super(`Upload aborted`),this.name=`UploadAbortedError`}},pM=80;function mM(e){let t=new(e.XHR??XMLHttpRequest),n=!1,r=0,i=-1;return{promise:new Promise((a,o)=>{function s(t,n,a=!1){let o=n>0?n:e.file.size,s=o>0?Math.floor(t/o*100):0,c=Date.now(),l=c-r>=pM;!a&&!l&&s===i||(r=c,i=s,e.onProgress({loaded:t,total:o}))}t.upload.addEventListener(`progress`,t=>{s(t.loaded,t.lengthComputable?t.total:e.file.size)}),t.upload.addEventListener(`load`,()=>{s(e.file.size,e.file.size,!0)}),t.addEventListener(`load`,()=>{if(n)return;let e;try{e=t.responseText?JSON.parse(t.responseText):null}catch{e=null}if(t.status>=200&&t.status<300){let t=e?.attachments;if(!Array.isArray(t)){o(Error(`Upload failed: malformed response`));return}a({attachments:t});return}let r=e?.error;o(Error(typeof r==`string`?r:`Upload failed`))}),t.addEventListener(`error`,()=>{n||o(Error(`Upload failed`))}),t.addEventListener(`abort`,()=>{o(new fM)});let c=new FormData;c.append(`files`,e.file),t.open(`POST`,`/api/projects/${encodeURIComponent(e.projectId)}/uploads`),t.send(c)}),abort:()=>{if(!n){n=!0;try{t.abort()}catch{}}}}}var hM=`(^|[\\s\\n\\t])@agent/([a-z0-9_-]+)`;function gM(){return new RegExp(hM,`gi`)}var _M=R?K.useLayoutEffect:K.useEffect,vM=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}}},yM=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 bM(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top>=r.top-6&&n.top<=r.bottom+6}function xM(e,t,n,r){let[i]=Cj();(0,K.useEffect)(()=>{if(t!=null&&e!=null){let e=i.getRootElement(),a=e==null?document.body:Le(e,!1),o=!1,s=bM(t,a),c=function(){o||=(window.requestAnimationFrame(function(){n(),o=!1}),!0);let e=bM(t,a);e!==s&&(s=e,r?.(e))},l=new ResizeObserver(n),u=ae(e??t);return l.observe(t),Te(A(window,`resize`,n),A(document,`scroll`,c,{capture:!0,passive:!0}),...u.map(e=>A(e,`scroll`,c,{capture:!0,passive:!0})),()=>l.unobserve(t))}},[t,i,r,n,e])}var SM=ye(`SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND`);function CM({index:e,isSelected:t,onClick:n,onMouseEnter:r,option:i}){let a=`item`;return t&&(a+=` selected`),(0,q.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,q.jsx)(`span`,{className:`text`,children:i.title})]},i.key)}function wM({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,K.useState)(null),f=u===null?null:Math.min(i.length-1,u),p=r.match&&r.match.matchingString;(0,K.useEffect)(()=>{l&&d(0)},[p,l]);let m=(0,K.useCallback)(n=>{t.update(()=>{o(n,r.match!=null&&s?function(e){let t=je();if(!P(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,K.useCallback)(e=>{let n=t.getRootElement();n!==null&&(n.setAttribute(`aria-activedescendant`,`typeahead-item-`+e),d(e))},[t]),g=(0,K.useCallback)(()=>n.current&&i.length?Aa.createPortal((0,q.jsx)(`div`,{className:`typeahead-popover mentions-menu`,children:(0,q.jsx)(`ul`,{children:i.map((e,t)=>(0,q.jsx)(CM,{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,K.useEffect)(()=>()=>{let e=t.getRootElement();e!==null&&e.removeAttribute(`aria-activedescendant`)},[t]),_M(()=>{i===null?d(null):f===null&&l&&h(0)},[i,f,h,l]),(0,K.useEffect)(()=>Te(t.registerCommand(SM,({option:e})=>!(!e.ref||e.ref.current==null)&&(yM(e.ref.current),!0),c)),[t,h,c]),(0,K.useEffect)(()=>Te(t.registerCommand(fe,e=>{let n=e;if(i!==null&&i.length){let e=f===null||f===i.length-1?0:f+1;h(e);let r=i[e];if(!r)return h(-1),n.preventDefault(),n.stopImmediatePropagation(),!0;r.ref&&r.ref.current&&t.dispatchCommand(SM,{index:e,option:r}),n.preventDefault(),n.stopImmediatePropagation()}return!0},c),t.registerCommand(C,e=>{let t=e;if(i!==null&&i.length){let e=f===null||f===0?i.length-1:f-1;h(e);let n=i[e];if(!n)return h(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&yM(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0},c),t.registerCommand(le,t=>{let n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0},c),t.registerCommand(Ne,e=>{let t=e;return i!==null&&f!==null&&i[f]!=null&&(t.preventDefault(),t.stopImmediatePropagation(),m(i[f]),!0)},c),t.registerCommand(ve,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 _=(0,K.useMemo)(()=>({options:i,selectOptionAndCleanUp:m,selectedIndex:f,setHighlightedIndex:d}),[m,f,i]);return a==null?g():a(n,_,r.match?r.match.matchingString:``)}function TM(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 EM(e,t,n,r,i=!0){let[a]=Cj(),o=r??function(e){if(!R)return;let t=e.getRootElement();if(t!==null){let e=t.getRootNode();return w(e)?e:t.ownerDocument.body}return document.body}(a),s=R?pe(a.getRootElement()).createElement(`div`):null,c=(0,K.useRef)(s),l=(0,K.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;if(r.style.top=`${l+f+3+(i?window.pageYOffset:0)}px`,r.style.left=`${a+window.pageXOffset}px`,r.style.height=`${d}px`,r.style.width=`${u}px`,s!==null){s.style.top=`${l}`;let e=s.getBoundingClientRect(),n=e.height,o=e.width,c=t.getBoundingClientRect();a+o>c.right&&(r.style.left=`${c.right-o+window.pageXOffset}px`),(l+n>window.innerHeight||l+n>c.bottom)&&l-c.top>n+d&&(r.style.top=`${l-n-d+(i?window.pageYOffset:0)}px`)}r.isConnected||(TM(r,n),o.append(r)),r.setAttribute(`id`,`typeahead-menu`),t.setAttribute(`aria-controls`,`typeahead-menu`)}},[a,e,i,n,o]);(0,K.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,K.useCallback)(n=>{e!==null&&(n||t(null))},[e,t]);return xM(e,c.current,l,u),s!=null&&s===c.current&&(TM(s,n),o?.append(s)),c}function DM({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]=Cj(),[p,m]=(0,K.useState)(null),h=EM(p,m,s,l),g=(0,K.useCallback)(()=>{if(p===null)return;let e=()=>{m(null)},t;try{t=i&&i()}finally{t?t.then(e,e):e()}},[i,p]),_=(0,K.useCallback)(e=>{m(e),r!=null&&p===null&&r(e)},[r,p]);return(0,K.useEffect)(()=>{let e=f.registerUpdateListener(()=>{f.read(`latest`,()=>{if(!f.isEditable())return void g();if(f.isComposing())return;let e=f._window||window,n=e.document.createRange(),r=je(),i=function(e){let t=null;return e.read(`latest`,()=>{let e=je();P(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(!P(r)||!r.isCollapsed()||i===null||n===null)return void g();let a=o(i,f);if(t(a?a.matchingString:null),a!==null&&(d||!function(e,t){return t===0&&e.read(`latest`,()=>{let e=je();if(P(e)){let t=e.anchor.getNode().getPreviousSibling();return Me(t)&&t.isTextEntity()}return!1})}(f,a.leadOffset))&&function(e,t,n,r){let i=I(n);if(i===null||!i.isCollapsed)return!1;let a=S(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}(a.leadOffset,n,e,f.getRootElement())!==null)return void(0,K.startTransition)(()=>_({getRect:()=>n.getBoundingClientRect(),match:a}));g()})});return()=>{e()}},[f,o,t,p,g,_,d]),(0,K.useEffect)(()=>f.registerEditableListener(e=>{e||g()}),[f,g]),p===null||f===null||h.current===null?null:(0,q.jsx)(wM,{close:g,resolution:p,editor:f,anchorElementRef:h,options:e,menuRenderFn:a,shouldSplitNodeWithQuery:!0,onSelectOption:n,commandPriority:c,preselectFirstItem:u})}async function OM(e,t,n={}){let r=n.http??Re,i=new URLSearchParams({query:t});try{let t=await r.getJson(`/api/projects/${encodeURIComponent(e)}/paths?${i.toString()}`,{signal:n.signal});return t.ok?t.data.paths??[]:[]}catch{return[]}}var kM=120,AM={http:Re,timer:fi},jM={items:[],loading:!1,error:null};function MM(e){let{http:t,timer:n}=e.ports??AM,r=KT.useScopedStore(e=>e.mentionSuggestions),i=KT.useScopedStore(e=>e.setMentionSuggestions),a=KT.useScopedStoreApi(),o=(0,K.useRef)(null),s=(0,K.useRef)(null);return(0,K.useEffect)(()=>{if(!e.enabled||!e.projectId){i(jM);return}o.current!==null&&n.clearTimeout(o.current),s.current?.abort(),i({items:a.getState().mentionSuggestions.items,loading:!0,error:null});let r=new AbortController;return s.current=r,o.current=n.setTimeout(()=>{OM(e.projectId,e.query,{signal:r.signal,http:t}).then(e=>{r.signal.aborted||i({items:e,loading:!1,error:null})})},kM),()=>{o.current!==null&&n.clearTimeout(o.current),r.abort()}},[e.enabled,e.projectId,e.query,t,n,i,a]),r}var NM=[];function PM(e,t){let n=t.toLowerCase();if(n&&!(`agent/`.startsWith(n)||n.startsWith(`agent/`)))return[];let r=n.startsWith(`agent/`)?n.slice(6):``;return e.filter(e=>e.name.toLowerCase().includes(r)).sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({kind:`agent`,subagent:e}))}function FM(e){let t=ce(e=>e.settings?.subagents??NM);return(0,K.useMemo)(()=>({items:e.enabled?PM(t,e.query):[]}),[e.enabled,e.query,t])}function IM(e,t){return e===null?!1:e.x!==t.x||e.y!==t.y}function LM(){let e=(0,K.useRef)(null);return(0,K.useCallback)((t,n,r)=>{let i={x:t.clientX,y:t.clientY},a=IM(e.current,i);e.current=i,a&&r(n)},[])}var RM=/(?:^|\s)(@((?:[^@\s]){0,200}))$/;function zM(){return(0,K.useCallback)((e,t)=>{let n=RM.exec(e);return n===null?null:{leadOffset:n.index+(n[0].length-n[1].length),matchingString:n[2]??``,replaceableString:n[1]}},[])}var BM=class extends vM{data;constructor(e){let t=e.kind===`agent`?`agent:${e.subagent.id}`:`path:${e.path.kind}:${e.path.path}`;super(t),this.data=e}};function VM({projectId:e}){let t=KT.useScopedStore(e=>e.mentionQuery),n=KT.useScopedStore(e=>e.setMentionQuery),r=zM(),i=t!==null,a=MM({projectId:e,query:t??``,enabled:i}),o=FM({query:t??``,enabled:i}),s=(0,K.useMemo)(()=>{let e=o.items.map(e=>new BM({kind:`agent`,subagent:e.subagent})),t=a.items.map(e=>new BM({kind:`path`,path:e}));return[...e,...t]},[o.items,a.items]),c=LM(),l=(0,K.useCallback)(e=>{n(e)},[n]),d=(0,K.useCallback)((e,t,n)=>{let r=e.data,i=r.kind===`agent`?Ue({mentionKind:`agent`,value:r.subagent.name,label:r.subagent.name}):Ue({mentionKind:`path`,value:r.path.path,label:r.path.path});t===null?x([i]):t.replace(i);let a=re(` `);i.insertAfter(a),a.select(),n()},[]),f=(0,K.useCallback)((e,{selectedIndex:t,selectOptionAndCleanUp:n,setHighlightedIndex:r,options:i})=>{if(e.current==null||i.length===0&&!a.loading)return null;let o=(e,t)=>{e.preventDefault(),n(t)},s=(e,t)=>{c(e,t,r)};return(0,q.jsx)(`ul`,{role:`listbox`,"data-kanna-typeahead-menu":`mention`,className:`absolute bottom-full left-0 mb-2 w-full max-w-md md:max-w-xl max-h-64 overflow-auto rounded-md border border-border bg-popover shadow-md`,children:a.loading&&i.length===0?Array.from({length:4}).map((e,t)=>(0,q.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-1.5`,"aria-hidden":`true`,children:[(0,q.jsx)(`span`,{className:`h-3.5 w-3.5 rounded bg-muted animate-pulse`}),(0,q.jsx)(`span`,{className:`h-3 w-40 max-w-full rounded bg-muted animate-pulse`})]},t)):i.map((e,n)=>{let r=n===t,i=e.data,a=i.kind===`path`?i.path:null,c=a?.kind===`dir`?Vr:jt,l;return l=i.kind===`agent`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Sr,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,q.jsxs)(`span`,{className:`font-mono truncate`,children:[`agent/`,i.subagent.name]}),i.subagent.description?(0,q.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:i.subagent.description}):null]}):a?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`font-mono truncate`,children:a.path})]}):null,(0,q.jsxs)(`li`,{ref:e.setRefElement,role:`option`,"aria-selected":r,onMouseDown:t=>o(t,e),onMouseMove:e=>s(e,n),className:u(`flex items-center gap-2 px-3 py-1.5 cursor-pointer text-sm`,r&&`bg-accent text-accent-foreground`),children:[(0,q.jsx)(Ui,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),l]},e.key)})})},[a.loading,c]);return(0,q.jsx)(DM,{options:s,onQueryChange:l,onSelectOption:d,triggerFn:r,menuRenderFn:f})}var HM=[];function UM(e,t){return t?e.byProjectId[t]??HM:HM}function WM(e){return rn(t=>UM(t,e))}function GM(e){return e.replace(/^\/+/,``)}var KM={project:0,personal:0,builtin:1,plugin:2};function qM(e,t){let n=(KM[e.scope??``]??1)-(KM[t.scope??``]??1);return n===0?e.name.localeCompare(t.name):n}function JM(e,t){return t===`codex`?e.filter(e=>e.scope===`builtin`):e}function YM(e,t){if(t===``)return[...e].sort(qM);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(qM),...i.sort(qM)]}var XM=new Map;function ZM(e,t){return`${GM(e)}:${GM(t)}`}function QM(e,t){if(t.length===0)return{commands:e,promptByName:XM};let n=new Set(e.map(e=>GM(e.name))),r=[...e],i=new Map;for(let e of t){let t=ZM(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:XM}:{commands:r,promptByName:i}}var $M=/(?:^|\s)(\/(\S*))$/;function eN(){return(0,K.useCallback)((e,t)=>{let n=$M.exec(e);return n===null?null:{leadOffset:n.index+(n[0].length-n[1].length),matchingString:n[2]??``,replaceableString:n[1]}},[])}var tN=class extends vM{command;constructor(e){super(e.name),this.command=e}};function nN(e){let t=new Set,n=[];for(let r of e){let e=GM(r.name);t.has(e)||(t.add(e),n.push(r))}return n}function rN({command:e,promptByName:t,textNodeContainingQuery:n}){let r=t.get(GM(e.name));if(r!==void 0){let e=re(r);n===null?x([e]):n.replace(e),e.select(r.length,r.length);return}let i=We({commandName:GM(e.name),hasArgument:!!e.argumentHint});n===null?x([i]):n.replace(i);let a=re(` `);i.insertAfter(a),a.select()}function iN({projectId:e,provider:t}){let n=KT.useScopedStore(e=>e.slashQuery),r=KT.useScopedStore(e=>e.setSlashQuery),i=WM(e),a=xn(En),o=eN(),s=LM(),c=(0,K.useMemo)(()=>QM(JM(i,t),a),[t,i,a]),l=(0,K.useMemo)(()=>nN(YM(c.commands,n??``)).map(e=>new tN(e)),[c,n]),d=(0,K.useCallback)(e=>{r(e)},[r]),f=(0,K.useCallback)((e,t,n)=>{rN({command:e.command,promptByName:c.promptByName,textNodeContainingQuery:t}),n()},[c]),p=(0,K.useCallback)((e,{selectedIndex:t,selectOptionAndCleanUp:n,setHighlightedIndex:r,options:i})=>{if(e.current==null||i.length===0)return null;let a=(e,t)=>{e.preventDefault(),n(t)},o=(e,t)=>{s(e,t,r)};return(0,q.jsx)(`ul`,{role:`listbox`,"data-kanna-typeahead-menu":`slash`,className:`absolute bottom-full left-0 mb-2 w-full max-w-md md:max-w-xl max-h-64 overflow-auto rounded-md border border-border bg-popover shadow-md`,children:i.map((e,n)=>{let r=n===t,i=e.command;return(0,q.jsxs)(`li`,{ref:e.setRefElement,role:`option`,"aria-selected":r,onMouseDown:t=>a(t,e),onMouseMove:e=>o(e,n),className:u(`flex flex-col gap-0.5 px-3 py-1.5 cursor-pointer text-sm sm:flex-row sm:items-center sm:gap-3`,r&&`bg-accent text-accent-foreground`),children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,q.jsxs)(`span`,{className:`font-mono break-all sm:whitespace-nowrap sm:break-normal`,children:[`/`,GM(i.name)]}),i.kind===`skill`?(0,q.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,i.argumentHint?(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground whitespace-nowrap`,children:i.argumentHint}):null]}),i.description?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground sm:text-right`,children:Oi(i.description)}):null]},e.key)})})},[s]);return(0,q.jsx)(DM,{options:l,onQueryChange:d,onSelectOption:f,triggerFn:o,menuRenderFn:p})}var aN={"image/gif":`gif`,"image/jpeg":`jpg`,"image/png":`png`,"image/webp":`webp`};function oN(e){return aN[e.type]??`bin`}function sN(e){let t=e.name.trim().toLowerCase();return!t||t===`image.${oN(e)}`||t===`image.png`}function cN(e,t,n){if(e.name&&!sN(e))return e;let r=oN(e),i=`clipboard-${n}${t===0?``:`-${t}`}.${r}`;return Object.defineProperty(e,"name",{configurable:!0,value:i}),e}function lN(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(cN(e,n.length,t))}return n}function uN(e){return e?e.types.includes(`text/plain`)||e.types.includes(`text/html`):!1}async function dN(e,t,n,r,i){if(e.length===0||e.length>50)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(()=>{x([Pt(a)])})}catch(e){if(e instanceof Error&&e.name===`UploadAbortedError`)return;i?.(e instanceof Error?e.message:String(e))}await o()}let s=[];for(let t=0;t<Math.min(3,e.length);t++)s.push(o());await Promise.all(s)}function fN({projectId:e,onUploadError:t,uploadFileFn:n=mM}){let[r]=Cj();return(0,K.useEffect)(()=>r.registerCommand(se,i=>{if(!(i instanceof ClipboardEvent))return!1;let a=i.clipboardData,o=lN(a?.items??[],Date.now());if(o.length===0)return!1;let s=uN(a);return e&&dN(o,r,e,n,t),!s},3),[r,e,t,n]),null}async function pN(e,t,n,r,i){if(e.length===0||e.length>50)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(()=>{x([Pt(a)])})}catch(e){if(e instanceof Error&&e.name===`UploadAbortedError`)return;i?.(e instanceof Error?e.message:String(e))}await o()}let s=[];for(let t=0;t<Math.min(3,e.length);t++)s.push(o());await Promise.all(s)}function mN(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 hN({projectId:e,onUploadError:t,uploadFileFn:n=mM}){let[r]=Cj();return(0,K.useEffect)(()=>{let i=r.registerCommand(O,e=>mN(e).length!==0&&(e.preventDefault(),!0),3),a=r.registerCommand(T,i=>{let a=mN(i);return a.length!==0&&(i.preventDefault(),e&&pN(a,r,e,n,t),!0)},3);return()=>{i(),a()}},[r,e,t,n]),null}function gN(e){if(Me(e))return e.getTextContent();if(me(e))return`
26
+ `;if(ue(e)){let t=``,n=e.getChildren();for(let e of n)t+=gN(e);return t}return e.getTextContent()}function _N(e){let t=``,n=[];return e.getEditorState().read(()=>{let e=Pe().getChildren(),r=[];for(let t of e)r.push(gN(t));t=r.join(`
27
+ `),t=t.replace(/(?:\r\n|\r|\n)+$/,``).trimEnd(),n=it().map(e=>e.getAttachment())}),{text:t,attachments:n}}function vN(e=o){return e.hasTypeaheadMenuOpen()}function yN({onSubmit:e,disabled:t,dom:n=o}){let[r]=Cj(),i=(0,K.useRef)(!1),a=(0,K.useRef)(!1);return(0,K.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,K.useEffect)(()=>r.registerCommand(ve,o=>{if(t||!o||i.current||o.isComposing||o.keyCode===229||o.shiftKey||vN(n)||n.isTouchDevice()&&!n.matchesMediaQuery(`(hover: hover) and (pointer: fine)`)||a.current)return!1;let s=_N(r);return s.text.trim().length>0||s.attachments.length>0?(o.preventDefault(),r.update(()=>{let e=Pe();e.clear(),e.append(_e())}),a.current=!0,Promise.resolve().then(()=>{a.current=!1}),e(s),!0):!1},3),[r,t,e,n]),null}function bN({onChange:e}){let[t]=Cj();return(0,K.useEffect)(()=>t.registerUpdateListener(({editorState:t})=>{let n=t.toJSON(),r=``;t.read(()=>{r=Pe().getTextContent()}),e(n,r)}),[t,e]),null}var xN=/(\S+)$/;function SN(e,t){let n=xN.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 CN(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 wN({snippets:e}){let[t]=Cj();return(0,K.useEffect)(()=>{let n=!1;return t.registerCommand(Ne,r=>{let i=CN(r,vN(),e.length,n);return r.repeat||(n=!1),i===`ignore`?!1:i===`swallow-repeat`?(r.preventDefault(),!0):t.getEditorState().read(()=>{let t=je();if(!P(t)||!t.isCollapsed())return!1;let n=t.anchor.getNode();return Me(n)?SN(n.getTextContent().slice(0,t.anchor.offset),e)!==null:!1})?(n=!0,r.preventDefault(),t.update(()=>{let t=je();if(!P(t)||!t.isCollapsed())return;let n=t.anchor,r=n.getNode();if(!Me(r))return;let i=n.offset,a=r.getTextContent().slice(0,i),o=xN.exec(a);if(o===null)return;let s=SN(a,e);if(s===null)return;let c=o[1],l=i-c.length,u=s.expansion.split(`
28
+ `);if(r.spliceText(l,c.length,u[0]??``,!0),u.length>1){let e=je();if(!P(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)},[t,e]),null}function TN(e,t){return e&&!t}function EN(e){let t=e.maxAttachments??ON;return e.currentAttachmentCount+e.queuedAttachmentCount+e.incomingAttachmentCount>t}var DN=[],ON=50,kN=3;function AN(e,t,n){return e.provider===`claude`?{...e,model:t,modelOptions:{...e.modelOptions,contextWindow:Bn(t,e.modelOptions.contextWindow,n)}}:{...e,model:t}}function jN(e,t,n){return!t||e.provider===t?e:t===`claude`?{provider:`claude`,model:n.claude.model,modelOptions:{...n.claude.modelOptions},planMode:e.planMode}:{provider:`codex`,model:n.codex.model,modelOptions:{...n.codex.modelOptions},planMode:e.planMode}}function MN(e){return e.map(e=>({...e,status:`uploaded`}))}async function NN(e,t){e.contentUrl&&await Ye(e.contentUrl,{http:t})}function PN({bridgeRef:e}){let[t]=Cj();return(0,K.useEffect)(()=>(e.current={clearEditor:()=>{t.update(()=>{let e=Pe();e.clear(),e.append(_e())})},hydrateFromDraft:(e,n)=>{if(e)try{let n=t.parseEditorState(e);t.setEditorState(n);return}catch{}n?t.update(()=>{let e=Pe();e.clear();let t=_e();t.append(re(n)),e.append(t)}):t.update(()=>{let e=Pe();e.clear(),e.append(_e())})},readCurrentPayload:()=>_N(t),focusEditor:()=>{t.focus()}},()=>{e.current=null}),[t,e]),null}function FN({isDisabled:e}){let[t]=Cj();return(0,K.useEffect)(()=>{t.setEditable(!e)},[t,e]),null}function IN({onTextChange:e}){let[t]=Cj();return(0,K.useEffect)(()=>(e(_N(t).text),t.registerUpdateListener(()=>{e(_N(t).text)})),[t,e]),null}function LN({children:e,onError:t}){return e}var RN=(0,K.forwardRef)(({onSubmit:e,onLayoutChange:t,onCancel:n,disabled:r,canCancel:i,chatId:s,projectId:c,inputElementRef:l,activeProvider:d,availableProviders:f,contextWindowSnapshot:p=null,sessionTotals:m=null,previousPrompt:h=null,ports:g,hasUnpausedCronJob:_=!1},v)=>{let b=g?.dom??o,x=g?.http??Re,{getDraft:S,setDraft:C,clearDraft:w,getAttachmentDrafts:T,setAttachmentDrafts:E,clearAttachmentDrafts:D}=In(),{providerDefaults:O,getComposerState:k,initializeComposerForChat:A,setChatComposerModel:j,setChatComposerPlanMode:M,resetChatComposerFromProvider:N}=Jn(),P=s??`__new__`,F=Jn(e=>e.chatStates[P])??k(P),I=rM(),L=KT.useScopedStore(e=>e.attachments),ee=KT.useScopedStore(e=>e.setAttachments),R=KT.useScopedStore(e=>e.selectedAttachmentId),z=KT.useScopedStore(e=>e.setSelectedAttachmentId),ne=KT.useScopedStore(e=>e.uploadError),B=KT.useScopedStore(e=>e.setUploadError),V=KT.useScopedStore(e=>e.currentText),re=KT.useScopedStore(e=>e.setCurrentText),ae=KT.useScopedStore(e=>e.chatSettingsOpen),oe=KT.useScopedStore(e=>e.setChatSettingsOpen),se=(0,K.useRef)([]),le=(0,K.useRef)(null),H=(0,K.useRef)(0),ue=(0,K.useRef)([]),de=(0,K.useRef)(0),fe=(0,K.useRef)(new Set),pe=(0,K.useRef)(c??null),me=(0,K.useRef)(s??null),he=(0,K.useRef)(null),ge=jN(F,d,O),_e=F.provider,ve=ce(te),ye=ce(ie),be=(0,K.useRef)(null),xe=(f.find(e=>e.id===_e)??f[0])?.supportsPlanMode??!1,U=(0,K.useMemo)(()=>{if(ge.provider!==`claude`)return p;let{modelOptions:e}=ge,t=Vn(Bn(ge.model,e.contextWindow,ve));return dt(p,t)},[p,ve,ge]),Ce=L.filter(e=>e.status===`uploaded`),we=L.some(e=>e.status===`uploading`),Te=V.trim().length>0,Ee=V.trim().length>0||Ce.length>0,De=[...L].sort((e,t)=>e.kind===t.kind?0:e.kind===`image`?-1:1),Oe=L.find(e=>e.id===R)??null,ke=ce(e=>e.settings?.subagents??DN),Ae=(0,K.useMemo)(()=>{let e=new Map(ke.map(e=>[e.name.toLowerCase(),e])),t=[...V.matchAll(gM())],n=[];for(let r of t){let t=r[2];if(!t)continue;let i=e.get(t.toLowerCase());n.push(i?{kind:`ok`,label:i.name,id:i.id}:{kind:`missing`,label:t})}return n},[V,ke]),je=(0,K.useCallback)(e=>{e.previewUrl&&URL.revokeObjectURL(e.previewUrl)},[]),Me=(0,K.useCallback)(e=>{let t=e?.cleanupPreviews??!0;de.current+=1,fe.current.clear(),ee(e=>(t&&e.forEach(je),[])),se.current=[],H.current=0,z(null),B(null)},[je,ee,z,B]),Ne=(0,K.useRef)(void 0),Pe=(0,K.useCallback)(()=>{if(c)for(;H.current<kN&&se.current.length>0;){let e=se.current.shift();if(!e)break;H.current+=1;let t=crypto.randomUUID(),n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,r=de.current,i=mM({projectId:c,file:e,onProgress:({loaded:e,total:n})=>{if(r!==de.current)return;let i=n>0?e/n:0;ee(e=>e.map(e=>e.id===t?{...e,uploadProgress:i}:e))}});ee(r=>[...r,{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:i.abort}]),(async()=>{try{let{attachments:e}=await i.promise,a=e[0];if(!a)throw Error(`Upload failed`);if(r!==de.current){NN(a,x),n&&URL.revokeObjectURL(n);return}if(fe.current.has(t)){fe.current.delete(t),n&&URL.revokeObjectURL(n),NN(a,x);return}ee(e=>e.map(e=>e.id===t?{...e,...a,previewUrl:e.previewUrl,status:`uploaded`,uploadProgress:1,cancelUpload:void 0}:e)),B(null)}catch(e){if(r!==de.current){n&&URL.revokeObjectURL(n);return}if(e instanceof fM){ee(e=>e.filter(e=>e.id!==t)),fe.current.delete(t),n&&URL.revokeObjectURL(n);return}ee(e=>e.map(e=>e.id===t?{...e,status:`failed`,cancelUpload:void 0}:e)),B(e instanceof Error?e.message:String(e))}finally{H.current=Math.max(0,H.current-1),Ne.current?.()}})()}},[x,c,ee,B]);(0,K.useEffect)(()=>{Ne.current=Pe},[Pe]);let Fe=(0,K.useCallback)(e=>{if(!c){B(`Open a project before uploading files.`);return}if(EN({currentAttachmentCount:ue.current.length,queuedAttachmentCount:se.current.length,incomingAttachmentCount:e.length})){B(`You can upload up to ${ON} files at a time.`);return}se.current.push(...e),B(null),Pe()},[Pe,c,B]);(0,K.useImperativeHandle)(v,()=>({enqueueFiles:Fe}),[Fe]);let Ie=(0,K.useCallback)(()=>{let e;return e=ge.provider===`claude`?{claude:{...ge.modelOptions}}:{codex:{...ge.modelOptions}},{provider:_e,model:ge.model,modelOptions:e,planMode:xe?ge.planMode:!1}},[ge,_e,xe]),Le=(0,K.useCallback)(async(t,n)=>{let r=ue.current,i=R,a=ne,o=[...Ce.map(({previewUrl:e,status:t,uploadProgress:n,cancelUpload:r,...i})=>i),...n],c={...Ie(),attachments:o};he.current?.clearEditor(),re(``),s&&w(s),Me({cleanupPreviews:!1}),me.current&&D(me.current);try{await e(t,c),r.forEach(je)}catch(e){Zr.error(`[ChatInput] Submit failed:`,String(e)),s&&C(s,t),ee(r),z(i),B(a)}},[Ce,Ie,s,w,Me,D,e,je,R,ne,C,re,ee,z,B]),ze=(0,K.useCallback)(async e=>{!Ee||we||await Le(e.text,e.attachments)},[Ee,we,Le]),Be=(0,K.useCallback)(async()=>{if(!Ee||we)return;let e=he.current?.readCurrentPayload()??{text:V,attachments:[]};await Le(e.text,e.attachments)},[Ee,we,V,Le]),Ve=(0,K.useCallback)((e,t)=>{s&&C(s,e,t)},[s,C]);(0,K.useEffect)(()=>{A(P,{providerHint:d})},[P,A,d]),(0,K.useEffect)(()=>{me.current=s??null},[s]),(0,K.useEffect)(()=>{if(!s)he.current?.clearEditor();else{let e=S(s);e?he.current?.hydrateFromDraft(e.lexicalState??null,e.text):he.current?.clearEditor()}he.current?.focusEditor()},[s]),(0,K.useEffect)(()=>{de.current+=1,se.current=[],H.current=0,fe.current.clear(),z(null),B(null),(0,K.startTransition)(()=>{ee(e=>(e.forEach(je),MN(s?T(s):[])))})},[s,je,T,z,B,ee]),(0,K.useEffect)(()=>{let e=pe.current;pe.current=c??null,e!==null&&c!==e&&(Me(),s&&D(s))},[c,s,Me,D]),(0,K.useEffect)(()=>{ue.current=L},[L]),(0,K.useEffect)(()=>{if(!s)return;let e=L.filter(e=>e.status===`uploaded`).map(({previewUrl:e,status:t,uploadProgress:n,cancelUpload:r,...i})=>i);if(e.length===0){D(s);return}E(s,e)},[L,s,D,E]),(0,K.useEffect)(()=>()=>{ue.current.forEach(je)},[je]),(0,K.useLayoutEffect)(()=>{t?.()},[t,L.length,ne,V]),(0,K.useEffect)(()=>b.addWindowListener(`resize`,()=>{t?.()}),[b,t]);function He(e){Jn.getState().setComposerState(P,e(ge))}function Ue(e){He(t=>t.provider===`claude`&&Hn(e)||t.provider===`codex`&&Un(e)?{...t,modelOptions:{...t.modelOptions,reasoningEffort:e}}:t)}function We(e){He(t=>t.provider===`claude`?AN({...t,modelOptions:{...t.modelOptions,contextWindow:e}},t.model,ve):t)}function Ge(e){M(P,e)}function qe(){Ge(!ge.planMode)}function Je(e){if(Ke(e).openInNewTab){b.openWindow(new URL(e.contentUrl,b.getOrigin()).toString(),`_blank`,`noopener,noreferrer`);return}z(e.id)}function Ye(e){e.status===`uploading`&&e.cancelUpload?.(),fe.current.add(e.id),ee(t=>{let n=t.find(t=>t.id===e.id);return n&&je(n),t.filter(t=>t.id!==e.id)}),R===e.id&&z(null),e.status===`uploaded`&&(fe.current.delete(e.id),NN(e,x))}function Xe(e){if(!e.nativeEvent.isComposing){if(e.key===`Tab`&&e.shiftKey&&xe){e.preventDefault(),qe();return}if(e.key===`Escape`&&i){e.preventDefault(),n?.();return}e.key===`ArrowUp`&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&V.length===0&&h&&(e.preventDefault(),he.current?.hydrateFromDraft(null,h),re(h),s&&C(s,h))}}let Ze=(0,K.useCallback)(e=>{B(e)},[B]),Qe=(0,K.useMemo)(()=>Se({namespace:`kanna-composer-${P}`,nodes:[...G],editable:!r}),[P]);function $e(e){return(0,q.jsx)(sr,{availableProviders:f,selectedProvider:_e,showCodexCliRequirementHints:!0,model:ge.model,modelOptions:ge.modelOptions,onProviderChange:e=>N(P,e),onModelChange:_?void 0:(e,t)=>j(P,t),onModelOptionChange:e=>{switch(e.type){case`claudeReasoningEffort`:case`codexReasoningEffort`:Ue(e.effort);break;case`contextWindow`:We(e.contextWindow);break;case`fastMode`:He(t=>t.provider===`claude`||t.provider===`openrouter`?t:{...t,modelOptions:{...t.modelOptions,fastMode:e.fastMode}})}},planMode:ge.planMode,onPlanModeChange:Ge,includePlanMode:xe,className:e})}return(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:u(`px-3 pt-0`,I&&`px-5`),children:[(0,q.jsxs)(`div`,{className:`max-w-[840px] mx-auto`,children:[Ae.length>0?(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1 px-2 pt-2`,children:Ae.map((e,t)=>(0,q.jsxs)(`span`,{className:u(`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:[(0,q.jsx)(Sr,{className:`h-3 w-3`}),`agent/`,e.label,e.kind===`missing`&&(0,q.jsx)(`span`,{className:`ml-1 font-medium`,children:`unknown`})]},`${e.kind}:${e.label}:${t}`))}):null,L.length>0?(0,q.jsx)(tM,{className:`overflow-x-auto overflow-y-hidden whitespace-nowrap px-2 pb-2`,children:(0,q.jsx)(`div`,{className:`flex items-end gap-2 pt-2`,children:De.map(e=>(0,q.jsx)(`div`,{className:u(`flex shrink-0 flex-col justify-end`,e.status===`failed`&&`text-destructive`),children:e.kind===`image`?(0,q.jsx)(xt,{attachment:e,previewUrl:e.previewUrl,size:`composer`,onClick:e.status===`uploaded`?()=>Je(e):void 0,onRemove:()=>Ye(e),uploadProgress:e.status===`uploading`?e.uploadProgress??null:void 0,onCancelUpload:e.status===`uploading`?()=>Ye(e):void 0}):(0,q.jsx)(W,{attachment:e,onClick:e.status===`uploaded`&&e.contentUrl?()=>Je(e):void 0,onRemove:()=>Ye(e),uploadProgress:e.status===`uploading`?e.uploadProgress??null:void 0,onCancelUpload:e.status===`uploading`?()=>Ye(e):void 0})},e.id))})}):null,(0,q.jsxs)(`div`,{className:`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`,onKeyDown:Xe,children:[(0,q.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Add attachment`,disabled:r,onPointerDown:e=>e.preventDefault(),onClick:()=>be.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,q.jsx)(ga,{className:`h-5 w-5`})}),(0,q.jsx)(`input`,{ref:be,type:`file`,multiple:!0,disabled:r,tabIndex:-1,"aria-hidden":`true`,className:`sr-only`,onChange:e=>{let t=[...e.target.files??[]];t.length>0&&Fe(t),e.target.value=``}}),(0,q.jsx)(Ej,{initialConfig:Qe,children:(0,q.jsxs)(`div`,{[y]:``,className:`relative flex-1 min-w-0`,children:[(0,q.jsx)(Bj,{contentEditable:(0,q.jsx)(Kj,{placeholder:(0,q.jsx)(`div`,{className:`pointer-events-none absolute top-3 left-3 md:top-4 md:left-6 text-muted-foreground text-base select-none`,children:`Build something...`}),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:LN}),(0,q.jsx)(eM,{}),(0,q.jsx)(VM,{projectId:c??null}),(0,q.jsx)(iN,{projectId:c??null,provider:_e}),(0,q.jsx)(fN,{projectId:c??null,onUploadError:Ze}),(0,q.jsx)(hN,{projectId:c??null,onUploadError:Ze}),(0,q.jsx)(wN,{snippets:ye}),(0,q.jsx)(yN,{onSubmit:ze,disabled:r||we}),(0,q.jsx)(bN,{onChange:Ve}),(0,q.jsx)(PN,{bridgeRef:he}),(0,q.jsx)(FN,{isDisabled:r}),(0,q.jsx)(IN,{onTextChange:re})]})}),(0,q.jsx)(a,{type:`button`,onPointerDown:e=>{e.preventDefault(),!r&&Te&&!we?Be():i?n?.():!r&&Ee&&!we&&Be()},disabled:r||!i&&!Ee||we,size:`icon`,"aria-label":TN(!!i,Te)?`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:TN(!!i,Te)?(0,q.jsx)(`div`,{className:`w-3 h-3 md:w-4 md:h-4 rounded-xs bg-current`}):(0,q.jsx)(wt,{className:`h-5 w-5 md:h-6 md:w-6`})})]})]}),ne?(0,q.jsx)(`div`,{className:`max-w-[840px] mx-auto mt-2 px-1 text-sm text-destructive`,children:ne}):null]}),(0,q.jsxs)(`div`,{className:u(`relative py-3 max-w-[840px] mx-auto`,I&&`p-5 pt-3`),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`hidden md:block`,children:$e(`mx-auto max-w-[840px]`)}),(0,q.jsxs)(ui,{open:ae,onOpenChange:oe,children:[(0,q.jsxs)(a,{ref:le,variant:`outline`,size:`default`,className:`ml-3 md:hidden`,onClick:()=>oe(!0),"aria-haspopup":`dialog`,children:[(0,q.jsx)(Ta,{className:`size-4`}),`Chat settings`]}),(0,q.jsxs)(ii,{size:`sm`,restoreFocus:`trigger`,onCloseAutoFocus:e=>{e.preventDefault(),le.current?.focus({preventScroll:!0})},children:[(0,q.jsxs)(si,{children:[(0,q.jsx)(ai,{children:`Chat settings`}),(0,q.jsx)(li,{children:`Choose the provider, model, reasoning, context, and permission mode for this chat.`})]}),(0,q.jsx)(oi,{children:$e(`flex-wrap justify-start gap-2`)})]})]})]}),m??U?(0,q.jsxs)(`div`,{className:`hidden shrink-0 items-center gap-2 pr-3 md:flex`,children:[(0,q.jsx)(oM,{totals:m??null}),U?(0,q.jsx)(aM,{usage:U}):null]}):null]}),m??U?(0,q.jsxs)(`div`,{className:`flex md:hidden items-center justify-end gap-2 px-[13px] pt-2`,children:[(0,q.jsx)(oM,{totals:m??null}),U?(0,q.jsx)(aM,{usage:U}):null]}):null]}),(0,q.jsx)(Nt,{source:Oe?Ft(Oe,`user_attachment`):null,open:Oe!==null,onOpenChange:e=>!e&&z(null)})]})}),zN=(0,K.memo)(RN),BN=(0,K.forwardRef)((e,t)=>(0,q.jsx)(a,{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,q.jsx)(da,{strokeWidth:2,className:`h-4.5`})})),VN=ci(`SharePopoverBody`,()=>e=>({busy:!1,setBusy:t=>e({busy:t})}));function HN(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 UN(e){let t=e.clipboard??Ar,n=VN.useScopedStore(e=>e.busy),r=VN.useScopedStore(e=>e.setBusy),i=e.shares.filter(e=>!e.revoked),{onMint:o,chatId:s}=e,c=(0,K.useCallback)(async()=>{r(!0);try{await o(s)}catch{}finally{r(!1)}},[o,s,r]);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(a,{variant:`default`,disabled:n,"data-share-mint":``,onClick:()=>{c()},children:n?`Creating…`:`Create share link`}),i.length===0?(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No active share links for this chat.`}):(0,q.jsx)(`ul`,{className:`space-y-2`,children:i.map(n=>(0,q.jsxs)(`li`,{className:`flex flex-col gap-1 rounded border border-border/40 p-2 text-xs`,children:[(0,q.jsx)(`code`,{className:`break-all`,children:n.url}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(a,{size:`sm`,variant:`ghost`,onClick:()=>{t.writeText(n.url)},children:[(0,q.jsx)(kr,{className:`h-3.5 w-3.5 mr-1`}),`Copy`]}),(0,q.jsxs)(a,{size:`sm`,variant:`ghost`,"data-share-revoke":``,onClick:()=>{e.onRevoke(n.tokenId)},children:[(0,q.jsx)(ua,{className:`h-3.5 w-3.5 mr-1`}),`Revoke`]}),(0,q.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:HN(n.expiresAt,e.now)})]})]},n.tokenId))})]})}function WN(e){return(0,q.jsx)(VN.Provider,{init:void 0,children:(0,q.jsx)(UN,{...e})})}function GN(e){let t=(0,K.useMemo)(()=>Date.now(),[e.open]);return(0,q.jsxs)(hi,{children:[(0,q.jsxs)(Pi,{open:e.open,onOpenChange:e.onOpenChange,children:[(0,q.jsx)(vi,{asChild:!0,children:(0,q.jsx)(Ni,{asChild:!0,children:e.trigger})}),(0,q.jsx)(Mi,{align:`end`,className:`w-96 p-4 space-y-3`,children:(0,q.jsx)(WN,{chatId:e.chatId,shares:e.shares,now:t,onMint:e.onMint,onRevoke:e.onRevoke})})]}),(0,q.jsx)(gi,{side:`bottom`,children:`Mint a public read-only link`})]})}function KN({bindings:e,provider:t,onOpenPath:n}){return e.length<=1?null:(0,q.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=e.worktreePath.split(`/`).pop()??e.worktreePath,r=e.role===`primary`,i=e.projectStatus===`missing`;return(0,q.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,q.jsx)(`span`,{className:`text-emerald-500`,children:`●`}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,q.jsx)(`span`,{className:`font-mono tabular-nums text-xs${i?` line-through text-muted-foreground`:``}`,children:t})]},e.projectId)}),t===`codex`&&(0,q.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground ml-2`,children:`codex: cwd-only`})]})}var qN=2;function JN({durationsMs:e,live:t=!1,label:n,className:r}){let{ticks:i,baselineY:a,size:o}=vj(e,{live:t});return(0,q.jsxs)(`svg`,{role:`img`,"aria-label":n,viewBox:`0 0 ${o} ${o}`,className:u(`h-[26px] w-[26px] shrink-0`,r),children:[(0,q.jsx)(`line`,{x1:1,y1:a,x2:o-1,y2:a,stroke:`currentColor`,strokeWidth:1,className:`text-border`}),i.map((e,t)=>(0,q.jsxs)(`g`,{className:e.live?`text-logo`:`text-muted-foreground`,children:[(0,q.jsx)(`line`,{x1:e.x,y1:a-.5,x2:e.x,y2:e.topY,stroke:`currentColor`,strokeWidth:1.4}),e.live?(0,q.jsx)(`line`,{x1:e.x+qN,y1:a-.5,x2:e.x+qN,y2:e.topY,stroke:`currentColor`,strokeWidth:1.4}):null]},t))]})}function YN(e){return e.replace(/[/\\]+$/,``)}function XN(e,t){let n=YN(e);if(!t)return n.split(/[/\\]/).filter(Boolean).pop()??``;let r=YN(t);if(n===r)return`~`;for(let e of[`/`,`\\`])if(n.startsWith(r+e))return`~/${n.slice(r.length+1).replace(/\\/g,`/`)}`;return n}function ZN({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?XN(n,i):``,o=r??`Detached HEAD`;return a?`${a} · ${o}`:o}var QN=ci(`OpenExternalSelect`,({initialValue:e})=>t=>({lastValue:e,setLastValue:e=>t({lastValue:e})})),$N=`kanna:last-open-external`,eP=`py-2 pl-2 pr-8`,tP=`rounded-md text-sm font-normal focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground`,nP=`flex items-center gap-3`,rP=`h-5 w-5 shrink-0`;function iP({value:e,label:t,isMac:n}){return(0,q.jsxs)(`span`,{className:nP,children:[(0,q.jsx)(sP,{value:e,isMac:n,className:rP}),(0,q.jsx)(`span`,{children:t})]})}function aP(e,t){return{preset:e,commandTemplate:e===`custom`&&t?.trim()||qn(e)}}function oP(e,t){if(e===`finder`)return t?`Finder`:`Folder`;if(e===`terminal`)return`Terminal`;if(e===`preview`)return`Preview`;if(e==="default")return`Default App`;let n=e.slice(7);return n===`vscode`?`VS Code`:mr.find(e=>e.value===n)?.label??`Editor`}function sP({value:e,isMac:t,className:n}){if(e===`finder`)return t?(0,q.jsx)(fr,{className:n}):(0,q.jsx)(ar,{className:n});if(e===`terminal`)return(0,q.jsx)(vr,{className:n});if(e===`preview`)return(0,q.jsx)(hr,{className:n});if(e==="default")return(0,q.jsx)(yr,{className:n});let r=e.slice(7),i=mr.find(e=>e.value===r)?.value??`vscode`;return(0,q.jsx)(_r,{preset:i,className:n})}function cP(e,t){if(e===`finder`||e===`terminal`||e===`preview`||e==="default")return e;if(e?.startsWith(`editor:`)){let t=e.slice(7);if(Gn(t))return`editor:${t}`}return t}function lP({editorPreset:e,isMac:t,includeFinder:n=!0,includeTerminal:r=!1,includePreview:i=!1,includeDefault:a=!1,menuKind:o=`context`}){let s={value:`finder`,label:t?`Finder`:`Folder`},c={value:`terminal`,label:`Terminal`},l={value:`preview`,label:`Preview`},u={value:`default`,label:`Default App`},d=[{value:`editor:cursor`,label:`Cursor`},{value:`editor:xcode`,label:`Xcode`},{value:`editor:windsurf`,label:`Windsurf`},...e===`custom`?[{value:`editor:custom`,label:`Custom`}]:[]],f=`editor:${e}`,p=[...d.filter(e=>e.value===f),...d.filter(e=>e.value!==f)];return o===`navbar`?[...p.filter(e=>e.value===f),...n?[s]:[],...r?[c]:[],...p.filter(e=>e.value!==f)]:[...p,...i&&t?[l]:[],...n?[s]:[],...r?[c]:[],...a?[u]:[]]}function uP(e){if(e.value===`finder`){e.onOpenExternal(`open_finder`);return}if(e.value===`terminal`){e.onOpenExternal(`open_terminal`);return}if(e.value===`preview`){e.onOpenExternal(`open_preview`);return}if(e.value==="default"){e.onOpenExternal(`open_default`);return}let t=e.value.slice(7),n=mr.find(e=>e.value===t)?.value??`vscode`;e.onOpenExternal(`open_editor`,aP(n,e.editorCommandTemplate))}function dP({isMac:e,editorPreset:t,editorCommandTemplate:n,finderShortcut:r,editorShortcut:i,onOpenExternal:o,ports:s}){let c=s?.storage??Ci,l=`editor:${t}`,u=QN.useScopedStore(e=>e.lastValue),d=QN.useScopedStore(e=>e.setLastValue);(0,K.useEffect)(()=>{d(cP(c.getItem($N),l))},[l,d,c]);let f=(0,K.useMemo)(()=>lP({editorPreset:t,isMac:e,includeFinder:!0,includeTerminal:!0,menuKind:`navbar`}),[t,e]);function p(e){d(e),c.setItem($N,e),uP({value:e,editorCommandTemplate:n,onOpenExternal:o})}let m;return m=u===`finder`?r:u===`editor:${t}`?i:void 0,(0,q.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto]`,children:[(0,q.jsxs)(mi,{children:[(0,q.jsx)(bi,{asChild:!0,children:(0,q.jsx)(a,{variant:`ghost`,size:`none`,onClick:()=>p(u),title:`Open in ${oP(u,e)}`,className:`border-0 !pl-2.5 !pr-1 hover:!border-border/0 hover:!bg-transparent`,children:(0,q.jsx)(sP,{value:u,isMac:e,className:`size-6`})})}),(0,q.jsx)(_i,{side:`bottom`,shortcut:m})]}),(0,q.jsxs)(br,{value:void 0,onValueChange:e=>p(cP(e,u)),children:[(0,q.jsx)(pr,{"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,q.jsx)(`span`,{className:`flex items-center justify-center`,children:(0,q.jsx)(or,{className:`h-4 w-4 opacity-60`})})}),(0,q.jsx)(cr,{align:`end`,children:(0,q.jsx)(lr,{children:f.map(t=>(0,q.jsx)(gr,{value:t.value,className:eP,children:(0,q.jsx)(iP,{value:t.value,label:t.label,isMac:e})},t.value))})})]})]})}function fP({isMac:e,editorPreset:t,editorCommandTemplate:n,finderShortcut:r,editorShortcut:i,onOpenExternal:a,ports:o}){let s=`editor:${t}`;return(0,q.jsx)(QN.Provider,{init:{initialValue:s},children:(0,q.jsx)(dP,{isMac:e,editorPreset:t,editorCommandTemplate:n,finderShortcut:r,editorShortcut:i,onOpenExternal:a,ports:o})})}function pP({isMac:e,editorPreset:t,editorCommandTemplate:n,includeFinder:r=!0,includeTerminal:i=!1,includePreview:a=!1,includeDefault:o=!1,onOpenExternal:s}){let c=lP({editorPreset:t,isMac:e,includeFinder:r,includeTerminal:i,includePreview:a,includeDefault:o}),l=(0,K.useCallback)((e,t)=>{e.preventDefault(),uP({value:t,editorCommandTemplate:n,onOpenExternal:s})},[n,s]);return(0,q.jsx)(Ut,{className:`rounded-lg p-1`,children:c.map(t=>(0,q.jsx)(Qt,{className:`${eP} ${tP}`,onSelect:e=>l(e,t.value),children:(0,q.jsx)(iP,{value:t.value,label:t.label,isMac:e})},t.value))})}var mP=ci(`PtyInstanceRow`,()=>e=>({confirmKill:!1,setConfirmKill:t=>e({confirmKill:t})})),hP={spawning:`var(--warning)`,"trust-dialog":`var(--warning)`,ready:`var(--success, oklch(0.72 0.16 145))`,streaming:`var(--primary)`,cancelling:`var(--warning)`,exited:`var(--muted-foreground)`},gP={spawning:`spawning`,"trust-dialog":`trust`,ready:`ready`,streaming:`streaming`,cancelling:`cancelling`,exited:`exited`};function _P(e){return e.length<=40?e:`…${e.slice(-39)}`}function vP(e){return e.length>8?e.slice(0,8):e}function yP(e,t){return Ti(e,t??Date.now())}function bP(e){if(e<1024)return`${e} B`;let t=e/1024;if(t<1024)return`${t.toFixed(0)} KB`;let n=t/1024;return n<1024?`${n.toFixed(0)} MB`:`${(n/1024).toFixed(1)} GB`}function xP(e){return e>=100?`${e.toFixed(0)}%`:`${e.toFixed(1)}%`}function SP({phase:e}){return(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded-full text-xs font-mono tracking-wide tabular-nums`,style:{background:`color-mix(in oklch, var(--muted) 60%, transparent)`},children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`inline-block w-[6px] h-[6px] rounded-full`,style:{backgroundColor:hP[e]}}),(0,q.jsx)(`span`,{style:{color:hP[e]},children:gP[e]})]})}function CP({instance:e,onOpenChat:t,onCancel:n,onKill:r}){return(0,q.jsx)(mP.Provider,{init:void 0,children:(0,q.jsx)(wP,{instance:e,onOpenChat:t,onCancel:n,onKill:r})})}function wP({instance:e,onOpenChat:t,onCancel:n,onKill:r}){let i=mP.useScopedStore(e=>e.confirmKill),a=mP.useScopedStoreApi(),o=(0,K.useCallback)(()=>{let t=a.getState();t.confirmKill?(r(e.chatId),t.setConfirmKill(!1)):t.setConfirmKill(!0)},[a,e.chatId,r]);return(0,q.jsxs)(`div`,{className:`group border border-border/60 rounded-lg p-3 flex flex-col gap-2 hover:border-border transition-colors`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e.chatId),className:`text-xs font-mono font-medium text-foreground hover:text-primary transition-colors text-left truncate flex-1 min-w-0`,children:vP(e.chatId)}),(0,q.jsx)(SP,{phase:e.phase})]}),(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-xs text-muted-foreground font-mono tabular-nums`,children:[(0,q.jsxs)(xi,{tooltip:e.cwd,children:[(0,q.jsx)(`span`,{className:`text-foreground/40`,children:`cwd`}),` `,_P(e.cwd)]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-foreground/40`,children:`pid`}),` `,e.pid??`—`]}),(0,q.jsxs)(xi,{tooltip:e.model,children:[(0,q.jsx)(`span`,{className:`text-foreground/40`,children:`model`}),` `,e.model||`—`]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-foreground/40`,children:`up`}),` `,yP(e.startedAt,e.exitedAt)]}),e.accountLabel?(0,q.jsxs)(xi,{className:`col-span-2`,tooltip:e.accountLabel,children:[(0,q.jsx)(`span`,{className:`text-foreground/40`,children:`acct`}),` `,e.accountLabel,e.oauthMasked?(0,q.jsxs)(`span`,{className:`text-foreground/30`,children:[` · `,e.oauthMasked]}):null]}):null,e.planMode===null?null:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-foreground/40`,children:`plan`}),` `,e.planMode?`on`:`off`]}),e.smokeTest?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-foreground/40`,children:`smoke`}),` `,(0,q.jsx)(`span`,{style:{color:e.smokeTest===`pass`?hP.ready:hP.exited},children:e.smokeTest})]}):null,e.rssBytes===null?null:(0,q.jsxs)(xi,{className:`col-span-2`,tooltip:`Resident memory (current · peak across session)`,children:[(0,q.jsx)(`span`,{className:`text-foreground/40`,children:`mem`}),` `,bP(e.rssBytes),e.rssPeakBytes!==null&&e.rssPeakBytes>e.rssBytes?(0,q.jsxs)(`span`,{className:`text-foreground/30`,children:[` · peak `,bP(e.rssPeakBytes)]}):null]}),e.cpuPercent===null?null:(0,q.jsxs)(xi,{className:`col-span-2`,tooltip:`CPU usage % across process tree (current · peak; >100% = multi-core)`,children:[(0,q.jsx)(`span`,{className:`text-foreground/40`,children:`cpu`}),` `,xP(e.cpuPercent),e.cpuPeakPercent!==null&&e.cpuPeakPercent>e.cpuPercent?(0,q.jsxs)(`span`,{className:`text-foreground/30`,children:[` · peak `,xP(e.cpuPeakPercent)]}):null]})]}),e.phase===`exited`?(0,q.jsxs)(`div`,{className:`text-xs font-mono text-muted-foreground pt-1`,children:[`exited`,e.exitCode===null?``:` · code ${e.exitCode}`]}):(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 pt-1`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e.chatId),className:`text-xs font-mono px-2 py-1 rounded-md border border-border/60 hover:bg-muted/40 transition-colors`,children:`open`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>n(e.chatId),className:`text-xs font-mono px-2 py-1 rounded-md border border-border/60 hover:bg-muted/40 transition-colors`,children:`cancel`}),(0,q.jsx)(`button`,{type:`button`,onClick:o,onBlur:()=>a.getState().setConfirmKill(!1),className:`text-xs font-mono px-2 py-1 rounded-md border transition-colors ml-auto`,style:{borderColor:i?`var(--destructive)`:`var(--border)`,color:i?`var(--destructive)`:void 0},"aria-label":i?`Confirm kill`:`Kill PTY process`,children:i?`confirm kill?`:`kill`})]})]})}function TP({instances:e,liveCount:t,open:n,onOpenChange:r,onOpenChat:i,onCancel:a,onKill:o}){let s=t>0,c=s?`${t} claude PTY instance${t===1?``:`s`}`:`No live PTY instances`;return(0,q.jsxs)(Pi,{open:n,onOpenChange:r,children:[(0,q.jsxs)(hi,{children:[(0,q.jsx)(vi,{asChild:!0,children:(0,q.jsx)(Ni,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,"aria-label":c,className:`inline-flex items-center gap-1.5 px-1.5 h-9 rounded-md hover:bg-transparent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`inline-block w-[7px] h-[7px] rounded-full flex-shrink-0`,style:{backgroundColor:s?hP.ready:`var(--muted-foreground)`}}),(0,q.jsxs)(`span`,{className:`text-xs font-mono font-medium tabular-nums leading-none`,style:{color:s?hP.ready:`var(--muted-foreground)`},children:[`pty `,t]})]})})}),(0,q.jsx)(gi,{side:`bottom`,children:c})]}),(0,q.jsxs)(Mi,{align:`end`,sideOffset:8,className:`w-[420px] p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,q.jsx)(`h3`,{className:`text-xs font-mono tracking-wider text-foreground/60`,children:`claude pty instances`}),(0,q.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground tabular-nums`,children:[t,` live`]})]}),e.length===0?(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground text-center py-6 font-mono`,children:`no instances yet`}):(0,q.jsx)(`div`,{className:`flex flex-col gap-2 max-h-[60vh] overflow-y-auto`,children:e.map(e=>(0,q.jsx)(CP,{instance:e,onOpenChat:i,onCancel:a,onKill:o},e.chatId))})]})]})}function EP({socket:e,onOpenChat:t}){let n=sn(),r=Sn(),i=gn(),a=(0,K.useCallback)(e=>{let t=ln.getState();e?t.openPopover():t.closePopover()},[]),o=(0,K.useCallback)(e=>{ln.getState().closePopover(),t?.(e)},[t]),s=(0,K.useCallback)(t=>{if(!e)return;let n={type:`pty.cancel`,chatId:t};e.command(n).catch(()=>{})},[e]),c=(0,K.useCallback)(t=>{if(!e)return;let n={type:`pty.kill`,chatId:t};e.command(n).catch(()=>{})},[e]),l=(0,K.useMemo)(()=>n,[n]);return(0,q.jsx)(TP,{instances:l,liveCount:r,open:i,onOpenChange:a,onOpenChat:o,onCancel:s,onKill:c})}var DP=[];function OP({durationsMs:e,status:t}){let n=e??DP,r=t===`running`;if(n.length===0&&!r)return null;let i=n.length+ +!!r;return(0,q.jsx)(JN,{durationsMs:n,live:r,label:`Session shape: ${String(i)} ${i===1?`turn`:`turns`}${r?`, running`:``}`})}function kP(e,t){e.preventDefault(),e.stopPropagation();let n=e.currentTarget.getBoundingClientRect();t.dispatchContextMenuEvent(e.currentTarget,n.left+n.width/2,n.bottom)}function AP({showOnDesktop:e,onToggleEmbeddedTerminal:t,dom:n}){return t?(0,q.jsxs)(wn,{children:[(0,q.jsx)($t,{asChild:!0,children:(0,q.jsx)(a,{variant:`ghost`,size:`none`,onClick:e=>kP(e,n),title:`More actions`,className:u(`border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent`,e?`flex`:`flex md:hidden`),children:(0,q.jsx)(zr,{strokeWidth:2,className:`h-4.5`})})}),(0,q.jsx)(Ut,{children:t?(0,q.jsxs)(Qt,{onSelect:e=>{e.preventDefault(),t()},children:[(0,q.jsx)(Mr,{strokeWidth:2,className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{className:`text-xs font-medium`,children:`Toggle Terminal`})]}):null})]}):null}function jP({chatId:e}){return jn(hn(e))?(0,q.jsxs)(hi,{children:[(0,q.jsx)(vi,{asChild:!0,children:(0,q.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,q.jsx)(`span`,{"aria-hidden":!0,className:`inline-block w-[6px] h-[6px] rounded-full`,style:{backgroundColor:`var(--warning)`}}),(0,q.jsx)(`span`,{style:{color:`var(--warning)`},children:`following`})]})}),(0,q.jsx)(gi,{side:`bottom`,children:`Live view of an external Claude session. Sending a message takes over and stops following.`})]}):null}function MP({turnDurationsMs:e,sidebarCollapsed:t,onOpenSidebar:n,onExpandSidebar:r,onNewChat:i,localPath:s,embeddedTerminalVisible:c=!1,onToggleEmbeddedTerminal:l,rightSidebarVisible:d=!1,onToggleRightSidebar:f,onOpenExternal:p,editorPreset:m=`cursor`,editorCommandTemplate:h,platform:g=`darwin`,finderShortcut:_,editorShortcut:v,terminalShortcut:y,rightSidebarShortcut:b,branchName:x,homeDir:S,hasGitRepo:C=!0,gitStatus:w=`unknown`,timings:T,status:E,resolvedBindings:D,provider:O,onOpenPath:k=()=>void 0,socket:A,onOpenPtyChat:j,currentChatId:M,shareShares:N,onShareMint:P,onShareRevoke:F,silent:I,onToggleSilent:L,dom:ee}){let R=ee??o,z=ZN({hasGitRepo:C,gitStatus:w,localPath:s,branchName:x,homeDir:S}),te=KT.useScopedStore(e=>e.sharePopoverOpen),ne=KT.useScopedStore(e=>e.setSharePopoverOpen),B=g===`darwin`;return(0,q.jsxs)(Mn,{className:u(`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,q.jsxs)(`div`,{className:`relative flex items-center gap-2 w-full`,children:[(0,q.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,q.jsx)(a,{variant:`ghost`,size:`icon-mobile`,className:`md:hidden`,onClick:n,"aria-label":`Open sidebar`,children:(0,q.jsx)(Zn,{className:`size-4.5`})}),t&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`flex items-center justify-center w-[36px] h-[36px]`,children:(0,q.jsx)(tn,{className:`h-4 w-4 sm:h-5 sm:w-5 text-logo ml-1 hidden md:block`})}),(0,q.jsx)(a,{variant:`ghost`,size:`icon`,className:`hidden md:flex`,onClick:r,title:`Expand sidebar`,"aria-label":`Expand sidebar`,children:(0,q.jsx)(dn,{className:`size-4.5`})})]}),(0,q.jsx)(a,{variant:`ghost`,size:`icon`,className:`hover:!border-border/0 hover:!bg-transparent`,onClick:i,title:`Compose`,"aria-label":`New chat`,children:(0,q.jsx)(ni,{className:`size-4.5`})})]}),T&&E?(0,q.jsx)(`div`,{className:`flex-1 min-w-0 flex items-center justify-center select-none`,children:(0,q.jsxs)(hi,{children:[(0,q.jsx)(vi,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2 cursor-default min-w-0`,children:[(0,q.jsxs)(`span`,{className:`flex md:hidden items-center gap-1`,children:[(0,q.jsx)(Bi,{tone:Qr(E),className:Xr(Qr(E))}),(0,q.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:ei(E)}),(0,q.jsx)(`span`,{className:`hidden min-[430px]:inline text-xs font-mono tabular-nums text-foreground/80`,children:Ai(T.derivedAtMs-T.stateEnteredAt)})]}),(0,q.jsxs)(`span`,{className:`hidden md:flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(Bi,{tone:Qr(E),className:Xr(Qr(E))}),(0,q.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:ei(E)})]}),(0,q.jsx)(`span`,{className:`text-xs font-mono tabular-nums text-foreground/80`,children:Ai(T.derivedAtMs-T.stateEnteredAt)}),(0,q.jsx)(OP,{durationsMs:e,status:E}),(0,q.jsx)(`span`,{className:`h-3 w-px bg-border/60`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:ji(T.derivedAtMs-T.activeSessionStartedAt)}),T.lastTurnDurationMs==null?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`h-3 w-px bg-border/60`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:ji(T.lastTurnDurationMs)})]})]})]})}),(0,q.jsx)(gi,{side:`bottom`,className:`text-left`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5 text-xs`,children:[(0,q.jsxs)(`div`,{children:[`Chat created `,ji(T.derivedAtMs-T.chatCreatedAt),` ago`]}),(0,q.jsxs)(`div`,{children:[`Idle `,ji(T.cumulativeMs.idle)]}),(0,q.jsxs)(`div`,{children:[`Running `,ji(T.cumulativeMs.running)]}),(0,q.jsxs)(`div`,{children:[`Waiting `,ji(T.cumulativeMs.waiting_for_user)]})]})})]})}):(0,q.jsx)(`div`,{className:`flex-1 min-w-0`}),(0,q.jsx)(jP,{chatId:M}),(0,q.jsxs)(`div`,{className:`flex items-center flex-shrink-0 border border-border rounded-2xl`,children:[(0,q.jsx)(EP,{socket:A,onOpenChat:j}),L==null?null:(0,q.jsxs)(hi,{children:[(0,q.jsx)(vi,{asChild:!0,children:(0,q.jsx)(a,{variant:`ghost`,size:`none`,onClick:L,"aria-pressed":I??!1,"aria-label":I?`Unsilence notifications`:`Silence notifications`,className:u(`border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent`,I&&`text-muted-foreground`),children:I?(0,q.jsx)(Pn,{strokeWidth:2,className:`size-4.5`}):(0,q.jsx)(Gi,{strokeWidth:2,className:`size-4.5`})})}),(0,q.jsx)(gi,{side:`bottom`,children:I?`Unsilence notifications`:`Silence notifications`})]})]}),s&&(p||l||f)?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[p?(0,q.jsx)(`div`,{className:`hidden py-0.5 md:block border border-border rounded-2xl`,children:(0,q.jsx)(fP,{isMac:B,editorPreset:m,editorCommandTemplate:h,finderShortcut:_,editorShortcut:v,onOpenExternal:p})}):null,l||f?(0,q.jsxs)(`div`,{className:`flex items-center border border-border rounded-2xl px-2 py-0.5`,children:[(0,q.jsx)(AP,{showOnDesktop:d,onToggleEmbeddedTerminal:l,dom:R}),l?(0,q.jsxs)(mi,{children:[(0,q.jsx)(bi,{asChild:!0,children:(0,q.jsx)(a,{variant:`ghost`,size:`none`,onClick:l,"aria-label":`Toggle terminal`,"aria-pressed":c,className:u(d?`hidden`:`hidden md:flex`,`border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent`,c&&`text-foreground`),children:(0,q.jsx)(Mr,{strokeWidth:2,className:`h-4.5`})})}),(0,q.jsx)(_i,{side:`bottom`,shortcut:y})]}):null,M&&P&&F?(0,q.jsx)(GN,{chatId:M,shares:N??[],open:te,onOpenChange:ne,trigger:(0,q.jsx)(BN,{}),onMint:P,onRevoke:F}):null,f?(0,q.jsxs)(mi,{children:[(0,q.jsx)(bi,{asChild:!0,children:(0,q.jsxs)(a,{variant:`ghost`,onClick:f,className:u(`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`,d&&`text-foreground`),children:[d?(0,q.jsx)(ha,{strokeWidth:2.25,className:`h-4`}):(0,q.jsx)(ht,{strokeWidth:2.25,className:`h-4`}),z&&!d?(0,q.jsx)(`div`,{className:`text-13 font-mono max-w-[280px] truncate hidden md:block`,children:z}):null]})}),(0,q.jsx)(_i,{side:`bottom`,shortcut:b})]}):null]}):null]}):null]}),D&&D.length>1&&(0,q.jsx)(KN,{bindings:D,provider:O??null,onOpenPath:k})]})}var NP={dom:o,timer:fi};function PP({rootRef:e,fallbackRef:t,enabled:n,canCancel:r,ports:i=NP}){let{dom:a,timer:o}=i;(0,K.useEffect)(()=>{if(!n)return;let i=0,s=null,c=n=>{let r=n instanceof Element?n:null,i=e.current,o=t.current;if(v({trigger:`pointer`,activeElement:a.getActiveElement(),pointerStartTarget:s,pointerEndTarget:r,root:i,fallback:o,hasActiveOverlay:a.hasFocusOverlay(),hasActiveSelection:m(a.getSelection())})!==`restore`){s=null;return}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=()=>{s=null;let e=t.current;!e||e.disabled||e.focus({preventScroll:!0})},f=e=>{if(e.key!==`Escape`)return;let n=t.current;v({trigger:`escape`,activeElement:a.getActiveElement(),fallback:n,hasActiveOverlay:a.hasFocusOverlay(),canCancel:r,defaultPrevented:e.defaultPrevented})===`escape-focus`&&(e.preventDefault(),n?.focus({preventScroll:!0}))},p=a.addWindowCaptureListener(`pointerdown`,l),g=a.addWindowCaptureListener(`pointerup`,u),_=a.addWindowCaptureListener(`keydown`,f),y=a.addWindowCustomListener(h,d);return()=>{o.cancelAnimationFrame(i),p(),g(),_(),y()}},[r,a,n,t,e,o])}function FP(e){return e.visibilityState===`visible`?e.activeChatId:null}function IP(e){e.socket.setFocusedChat(FP({activeChatId:e.activeChatId,visibilityState:e.visibilityState}))}function LP({socket:e,activeChatId:t,ports:n}){let r=n?.dom??o;(0,K.useEffect)(()=>{let n=()=>{IP({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.setFocusedChat(null)}},[e,t,r])}var RP=ci(`UserMessage`,()=>e=>({selectedAttachmentId:null,setSelectedAttachmentId:t=>e({selectedAttachmentId:t})}));function zP(e){let t=e.match(/^<system-message>\s*([\s\S]*?)\s*<\/system-message>\s*([\s\S]*)$/);return t?{systemMessage:t[1]?.trim()||null,body:t[2]??``}:{systemMessage:null,body:e}}function BP({content:e,attachments:t=[],steered:n=!1,autoContinue:r,ports:i}){let a=i?.dom??o,s=RP.useScopedStore(e=>e.selectedAttachmentId),c=RP.useScopedStore(e=>e.setSelectedAttachmentId),l=Bt(),u=(0,K.useMemo)(()=>zP(e),[e]),d=!l.readonly,f=(0,K.useMemo)(()=>t.filter(e=>e.kind===`image`&&e.contentUrl),[t]),p=(0,K.useMemo)(()=>t.filter(e=>e.kind!==`image`||!e.contentUrl),[t]),m=t.find(e=>e.id===s)??null,h=m?Ft(m,`user_attachment`):null;function g(e){if(!(!d||!e.contentUrl)){if(Ke(e).openInNewTab){a.openWindow(new URL(e.contentUrl,a.getBaseURI()||a.getHref()).toString(),`_blank`,`noopener,noreferrer`);return}c(e.id)}}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,children:[f.length>0?(0,q.jsx)(`div`,{className:`flex max-w-[85%] flex-wrap gap-3 sm:max-w-[80%]`,children:f.map(e=>(0,q.jsx)(xt,{attachment:e,onClick:d?()=>g(e):void 0},e.id))}):null,p.length>0?(0,q.jsx)(`div`,{className:`flex max-w-[85%] flex-wrap gap-2 sm:max-w-[80%]`,children:p.map(e=>(0,q.jsx)(W,{attachment:e,onClick:d?()=>g(e):void 0},e.id))}):null,u.body||!u.body&&t.length===0&&e&&!u.systemMessage?(0,q.jsxs)(`div`,{className:`flex w-full flex-col gap-0.5`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 select-none font-mono text-xs tracking-wide text-muted-foreground`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,children:`You`}),n?(0,q.jsx)(ka,{"aria-label":`Sent mid-turn`,className:`size-3.5 shrink-0`}):null]}),(0,q.jsx)(`div`,{className:`min-w-0 text-foreground prose prose-sm dark:prose-invert [&_p]:whitespace-pre-line`,children:Ae(u.body)})]}):null,r?(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground opacity-70`,children:`auto-sent`}):null]}),(0,q.jsx)(Nt,{source:h,open:h!==null,onOpenChange:e=>!e&&c(null)})]})}var VP=(0,K.memo)(({content:e,attachments:t=[],steered:n=!1,autoContinue:r,ports:i})=>(0,q.jsx)(RP.Provider,{init:void 0,children:(0,q.jsx)(BP,{content:e,attachments:t,steered:n,autoContinue:r,ports:i})}));function HP({json:e}){return(0,q.jsx)(`div`,{className:`flex gap-3 justify-start`,children:(0,q.jsx)(`div`,{className:`flex-1 max-w-[90%]`,children:(0,q.jsx)(`pre`,{className:`text-xs font-mono whitespace-pre-wrap break-words bg-muted rounded-lg p-3 overflow-auto max-h-96`,children:e})})})}var UP=e=>ci(e,()=>e=>({open:!1,setOpen:t=>e({open:t})})),WP=UP(`CollapsibleSection`),GP=UP(`ExpandableMcpServer`),KP=UP(`RawMessageSection`);function qP({title:e,count:t,children:n,badge:r}){let i=WP.useScopedStore(e=>e.open),a=WP.useScopedStore(e=>e.setOpen);return t===0?null:(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity`,children:[(0,q.jsx)(jr,{className:u(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,i&&`rotate-90`)}),(0,q.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:e}),(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:t}),r]}),i&&(0,q.jsx)(`div`,{className:`ml-5`,children:n})]})}function JP({title:e,count:t,children:n,badge:r}){return(0,q.jsx)(WP.Provider,{init:void 0,children:(0,q.jsx)(qP,{title:e,count:t,badge:r,children:n})})}function YP({title:e,items:t,icon:n,getIcon:r}){return t.length===0?null:(0,q.jsx)(JP,{title:e,count:t.length,children:(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,q.jsx)(Ge,{icon:r?r(e):n,children:e},e))})})}function XP(e){let t=e.match(/^mcp__([^_]+)__(.+)$/);return t?{server:t[1],tool:t[2]}:null}function ZP({status:e}){let t;return t=e===`connected`?`bg-success`:e===`pending`?`bg-warning`:`bg-destructive`,(0,q.jsx)(`span`,{className:u(`inline-block h-2 w-2 rounded-full shrink-0`,t)})}function QP(e){switch(e){case`connected`:return`Connected`;case`failed`:return`Failed`;case`needs-auth`:return`Needs auth`;case`pending`:return`Connecting...`;case`disabled`:return`Disabled`;default:return e}}function $P({server:e}){let t=GP.useScopedStore(e=>e.open),n=GP.useScopedStore(e=>e.setOpen),r=e.status===`connected`;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`button`,{onClick:()=>r&&e.tools.length>0&&n(!t),className:u(`flex items-center gap-1.5`,r&&e.tools.length>0&&`cursor-pointer hover:opacity-60 transition-opacity`),children:[r&&e.tools.length>0&&(0,q.jsx)(jr,{className:u(`h-3 w-3 text-muted-foreground transition-transform duration-200`,t&&`rotate-90`)}),(0,q.jsx)(ZP,{status:e.status}),(0,q.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:Di(e.name)}),r?(0,q.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[e.tools.length,` tools`]}):(0,q.jsx)(`span`,{className:`text-muted-foreground/50`,children:QP(e.status)})]}),!r&&e.error&&(0,q.jsx)(`span`,{className:`text-destructive ml-5`,children:e.error}),t&&e.tools.length>0&&(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5 ml-5`,children:e.tools.map(t=>(0,q.jsx)(Ge,{icon:ot(`mcp__${e.name}__${t}`),children:t},t))})]})}function eF({server:e}){return(0,q.jsx)(GP.Provider,{init:void 0,children:(0,q.jsx)($P,{server:e})})}function tF({servers:e}){if(e.length===0)return null;let t=e.filter(e=>e.status===`connected`),n=e.filter(e=>e.status!==`connected`),r=n.length>0?(0,q.jsxs)(`span`,{className:`flex items-center gap-1 ml-1`,children:[(0,q.jsx)(ZP,{status:`failed`}),(0,q.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[n.length,` disconnected`]})]}):null;return(0,q.jsx)(JP,{title:`MCP Servers`,count:e.length,badge:r,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t.map(e=>(0,q.jsx)(eF,{server:e},e.name)),n.map(e=>(0,q.jsx)(eF,{server:e},e.name))]})})}function nF({rawJson:e}){let t=KP.useScopedStore(e=>e.open),n=KP.useScopedStore(e=>e.setOpen);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity`,children:[(0,q.jsx)(jr,{className:u(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,t&&`rotate-90`)}),(0,q.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Raw Message`})]}),t&&(0,q.jsx)(`pre`,{className:`ml-5 text-xs whitespace-pre-wrap break-all border border-border rounded-md p-3 overflow-x-auto max-h-96 overflow-y-auto`,children:e})]})}function rF({rawJson:e}){return(0,q.jsx)(KP.Provider,{init:void 0,children:(0,q.jsx)(nF,{rawJson:e})})}function iF({message:e,rawJson:t}){let{coreTools:n,mcpServersWithTools:r}=(0,K.useMemo)(()=>{let t=new Map,n=[];for(let r of e.tools){let e=XP(r);if(e){let n=t.get(e.server)||[];n.push(e.tool),t.set(e.server,n)}else n.push(r)}return{coreTools:n,mcpServersWithTools:e.mcpServers.map(e=>({name:e.name,status:e.status,error:e.error,tools:t.get(e.name)||[]}))}},[e.tools,e.mcpServers]);return(0,q.jsx)(Je,{children:(0,q.jsxs)(bt,{expandedContent:(0,q.jsx)(Lt,{className:`my-4 text-xs`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(Ze,{children:e.model}),(0,q.jsx)(YP,{title:`Tools`,items:n,getIcon:e=>qe[e]??Ve}),(0,q.jsx)(YP,{title:`Agents`,items:e.agents,icon:ct}),(0,q.jsx)(YP,{title:`Commands`,items:e.slashCommands,icon:wa}),(0,q.jsx)(tF,{servers:r}),t&&(0,q.jsx)(rF,{rawJson:t})]})}),children:[(0,q.jsx)(Hi,{className:`h-5 w-5 text-logo`}),(0,q.jsx)(et,{children:`Session Started`})]})})}var aF=ci(`AccountInfoMessage`,()=>e=>({expanded:!1,setExpanded:t=>e({expanded:t})})),oF={"kanna-oauth-pool":`Pool token`,"claude-pro":`Claude Pro`,"claude-max":`Claude Max`,openrouter:`OpenRouter`};function sF(e,t){return e?oF[e]??e:t?`API key (${t})`:null}function cF({message:e}){let{organization:t,tokenSource:n,apiKeySource:r,subscriptionType:i,email:a,oauthKeyMasked:o}=e.accountInfo,s=o??t??a??`Unknown account`,c=sF(n,r),l=aF.useScopedStore(e=>e.expanded),d=aF.useScopedStore(e=>e.setExpanded);return(0,q.jsx)(Je,{children:(0,q.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>d(!l),"aria-expanded":l,className:`group/account flex w-full items-center gap-2.5 text-left transition-opacity hover:opacity-80 focus-visible:opacity-100`,children:[(0,q.jsx)(`span`,{className:`text-12 font-medium text-muted-foreground`,children:`Account`}),(0,q.jsx)(`span`,{className:`h-3 w-px bg-border/60`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-13 font-medium leading-snug text-foreground`,children:s}),c?(0,q.jsx)(`span`,{className:`hidden whitespace-nowrap text-xs text-muted-foreground sm:inline`,children:c}):null,(0,q.jsx)(jr,{className:u(`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground transition-transform duration-200`,l&&`rotate-90`),"aria-hidden":!0})]}),c?(0,q.jsx)(`span`,{className:`mt-0.5 text-xs text-muted-foreground sm:hidden`,children:c}):null,l?(0,q.jsx)(Lt,{className:`mt-3 mb-2 text-xs`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(Qe,{label:`OAuth key`,copyText:s,children:(0,q.jsx)(`code`,{className:`block text-xs whitespace-pre-wrap break-all`,children:s})}),(0,q.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-5 gap-y-1.5`,children:[c?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Source`}),(0,q.jsx)(`dd`,{className:`text-foreground/90`,children:c})]}):null,i?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Plan`}),(0,q.jsx)(`dd`,{className:`text-foreground/90`,children:i})]}):null,a?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Email`}),(0,q.jsx)(`dd`,{className:`font-mono break-all text-foreground/90`,children:a})]}):null,t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Organization`}),(0,q.jsx)(`dd`,{className:`text-foreground/90`,children:t})]}):null]})]})}):null]})})}function lF({message:e}){return(0,q.jsx)(aF.Provider,{init:void 0,children:(0,q.jsx)(cF,{message:e})})}function uF({message:e,onRemove:t}){return(0,q.jsx)(at.Provider,{init:void 0,children:(0,q.jsx)(dF,{message:e,onRemove:t})})}function dF({message:e,onRemove:t}){let n=at.useScopedStore(e=>e.copied),r=at.useScopedStore(e=>e.setCopied),i=`/cron ${e.instruction} ${e.mode} ${e.scheduleText}`,a=(0,K.useCallback)(async()=>{await Ar.writeText(i),r(!0),fi.setTimeout(()=>r(!1),2e3)},[i,r]),o=e.upcomingFires??(e.nextFireAt===null?[]:[e.nextFireAt]);return(0,q.jsxs)(`div`,{className:`px-0.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(Er,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`Cron job armed`}),(0,q.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.jobId}),(0,q.jsx)(`span`,{className:`rounded-full border border-border px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:e.mode===`inline`?`inline · runs in this chat`:`spawn · new chat per run`})]})})]}),(0,q.jsx)(xi,{tooltip:e.instruction,className:`mt-1.5 text-sm text-foreground/90`,children:e.instruction}),(0,q.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,q.jsxs)(`span`,{children:[e.scheduleHuman,e.scheduleHuman===e.scheduleText?null:(0,q.jsx)(`span`,{className:`ml-1.5 font-mono opacity-70`,children:e.scheduleText})]}),e.model?(0,q.jsx)(`span`,{className:`font-mono`,children:e.model}):null,e.mode===`spawn`&&e.cwd?(0,q.jsx)(xi,{tooltip:e.cwd,className:`max-w-48`,inline:!0,children:(0,q.jsx)(`span`,{className:`font-mono`,children:e.cwd})}):null]}),o.length>0?(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5 text-xs tabular-nums text-muted-foreground`,children:o.map((e,t)=>(0,q.jsxs)(`span`,{children:[t===0?`next`:` ${t+1}.`,` `,new Date(e).toLocaleString()]},e))}):null]}),e.mode===`inline`?(0,q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Context is cleared before every run — this chat becomes a monitoring view.`}):null,(0,q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,q.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-muted/40`,onClick:a,children:[n?(0,q.jsx)(Dr,{className:`h-3.5 w-3.5 text-success-text`,"aria-hidden":`true`}):(0,q.jsx)(kr,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),n?`Copied`:`Edit`]}),t?(0,q.jsxs)(`button`,{type:`button`,"aria-label":`Disarm cron job ${e.jobId}`,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:border-destructive/50 hover:text-destructive`,onClick:()=>t(e.jobId),children:[(0,q.jsx)(tr,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Disarm`]}):null]})]})}function fF({message:e}){return(0,q.jsx)(at.Provider,{init:void 0,children:(0,q.jsx)(pF,{message:e})})}function pF({message:e}){let t=at.useScopedStore(e=>e.copied),n=at.useScopedStore(e=>e.setCopied),r=e.suggestion,i=(0,K.useCallback)(async()=>{r!==void 0&&(await Ar.writeText(r),n(!0),fi.setTimeout(()=>n(!1),2e3))},[r,n]);return(0,q.jsxs)(`div`,{className:`bg-destructive/10 px-4 py-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(qi,{className:`h-4 w-4 shrink-0 text-destructive`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`Invalid /cron command`})]}),e.input===void 0?null:(0,q.jsx)(`code`,{className:`mt-1.5 block truncate rounded-md border border-border bg-muted/40 px-2.5 py-1.5 font-mono text-xs text-muted-foreground`,children:e.input}),(0,q.jsx)(`p`,{className:`mt-1.5 text-sm text-foreground/90`,children:e.message}),r===void 0?null:(0,q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,q.jsx)(`code`,{className:`min-w-0 flex-1 truncate rounded-md border border-border bg-muted/40 px-2.5 py-1.5 font-mono text-xs text-foreground`,children:r}),(0,q.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-muted/40`,onClick:i,children:[t?(0,q.jsx)(Dr,{className:`h-3.5 w-3.5 text-success-text`,"aria-hidden":`true`}):(0,q.jsx)(kr,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),t?`Copied`:`Copy fix`]})]})]})}function mF({message:e}){return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,q.jsx)(Er,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/70`,"aria-hidden":`true`}),(0,q.jsxs)(`span`,{className:`text-xs`,children:[`Cron job`,(0,q.jsxs)(`span`,{className:`font-mono`,children:[` `,e.jobId,` `]}),e.change]})]})}function hF({message:e,cronJobs:t}){let n=t??[];return(0,q.jsxs)(`div`,{className:`px-0.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Er,{className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`Cron jobs`}),(0,q.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:[n.length,` armed`]})]}),n.length===0?(0,q.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:`No cron jobs armed in this chat.`}):(0,q.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.map(e=>(0,q.jsxs)(`div`,{className:`flex items-baseline gap-3 text-sm`,children:[(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:e.jobId}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground/90`,children:e.instruction}),(0,q.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[Gr(e.schedule,e.scheduleText),` · `,e.mode,e.paused?` · paused`:``]}),e.lastRun?(0,q.jsx)(Jr,{status:e.lastRun.status}):null]},e.jobId))}),e.help?(0,q.jsxs)(`div`,{className:`mt-3 border-t border-border pt-2 font-mono text-xs text-muted-foreground`,children:[(0,q.jsx)(`div`,{children:`/cron <instruction> inline|spawn <schedule>`}),(0,q.jsx)(`div`,{children:`/cron list · /cron remove <id> · /cron pause <id> · /cron resume <id>`}),(0,q.jsx)(`div`,{children:"schedules: `0 9 * * 1-5` · `*/30 * * * * *` (leading second) · @hourly @daily @weekly @monthly · every 30s / every 5m / every 2h"}),(0,q.jsxs)(`div`,{className:`mt-1`,children:[`inline: `,Wr(`inline`),`; spawn: `,Wr(`spawn`),`. Next-fire times use server-local time.`]})]}):null]})}function gF({message:e}){let t=e.missedCount??1;return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,q.jsx)(Ca,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/70`,"aria-hidden":`true`}),(0,q.jsxs)(`span`,{className:`text-xs tabular-nums`,children:[t===1?`Cron run skipped`:`Cron runs skipped ${t}×`,(0,q.jsxs)(`span`,{className:`font-mono`,children:[` `,e.jobId]}),` — `,_F(e.reason)]})]})}function _F(e){switch(e){case`chat_busy`:return`chat was busy`;case`previous_run_active`:return`previous run still running`;case`server_offline`:return`missed while the server was offline`}}function vF(e){return e===429?`Rate Limited`:e===500?`Internal Server Error`:e===502?`Bad Gateway`:e===503?`Service Unavailable`:e===529?`Overloaded`:e>=500?`Server Error`:`API Error`}function yF(e){if(e!==0)return`https://status.claude.com`}function bF({message:e}){let t=e.status>0?`${e.status} ${vF(e.status)}`:`API Error`,n=yF(e.status);return(0,q.jsx)(`div`,{className:`w-full max-w-[70ch]`,children:(0,q.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2.5 space-y-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-destructive-text`,children:[(0,q.jsx)(ut,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{className:` tracking-wide`,children:t})]}),(0,q.jsx)(`div`,{className:`text-sm whitespace-pre-wrap break-words text-foreground/90`,children:e.text}),(e.requestId||n)&&(0,q.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground pt-0.5`,children:[n&&(0,q.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:`Check status`}),e.requestId&&(0,q.jsxs)(`span`,{children:[`Request ID: `,(0,q.jsx)(`code`,{className:`text-xs`,children:e.requestId})]})]})]})})}var xF=`https://www.anthropic.com/legal/aup`;function SF(e){return e.replace(/^API Error:\s*/i,``)}function CF({message:e}){let t=SF(e.text);return(0,q.jsx)(`div`,{className:`w-full max-w-[70ch]`,children:(0,q.jsxs)(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2.5 space-y-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-warning-text`,children:[(0,q.jsx)(pn,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{className:` tracking-wide`,children:`Blocked by Usage Policy`})]}),(0,q.jsx)(`div`,{className:`text-sm whitespace-pre-wrap break-words text-foreground/90`,children:t}),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground pt-0.5`,children:[(0,q.jsx)(`a`,{href:xF,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:`Usage Policy`}),e.requestId&&(0,q.jsxs)(`span`,{children:[`Request ID: `,(0,q.jsx)(`code`,{className:`text-xs`,children:e.requestId})]})]})]})})}var wF=ci(`AskUserQuestionInteractive`,()=>e=>({currentIndex:0,answers:{},customInputs:{},setCurrentIndex:t=>e({currentIndex:t}),setAnswers:t=>e({answers:t}),setCustomInputs:t=>e({customInputs:t})}));function TF({question:e,header:t,currentIndex:n,totalQuestions:r,onBack:i,children:a}){let o=i&&n>0,s=o||r>1||!!t,c;return c=o?(0,q.jsx)(`button`,{onClick:i,className:`text-muted-foreground hover:opacity-60 transition-opacity flex items-center`,children:(0,q.jsx)(Yi,{className:`h-4 w-4 -ml-0.5`,strokeWidth:3})}):r>1?(0,q.jsxs)(`span`,{className:`text-xs font-semibold tracking-wide text-muted-foreground whitespace-nowrap`,children:[n+1,` of `,r]}):null,(0,q.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsxs)(`div`,{className:`p-3 px-4 bg-card border-b border-border`,children:[s&&(0,q.jsxs)(`div`,{className:`flex flex-row items-center gap-2 mb-1`,children:[c,t?(0,q.jsx)(`span`,{className:`text-xs font-semibold tracking-wide text-muted-foreground text-pretty`,children:t}):null]}),(0,q.jsx)(`h3`,{className:`font-medium text-foreground text-sm text-pretty`,children:e})]}),r>1&&(0,q.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-border`,children:(0,q.jsx)(`div`,{className:`h-full bg-muted-foreground/40`,style:{width:`${n/r*100}%`}})})]}),a]})}function EF({label:e,description:t}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`text-foreground text-sm`,children:e}),t&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:t})]})}function DF({selected:e,multiSelect:t,onClick:n}){let r=u(`flex-shrink-0 w-5 h-5 border-1 flex items-center justify-center`,t?`rounded`:`rounded-full`,e?`border-transparent bg-foreground`:`border-muted-foreground/50 bg-background`,n&&e&&`cursor-pointer`),i=e?(0,q.jsx)(Dr,{strokeWidth:3,className:`translate-y-[0.5px] h-3 w-3 text-white dark:text-background`}):null;return n?(0,q.jsx)(`button`,{type:`button`,onClick:n,className:r,children:i}):(0,q.jsx)(`div`,{"aria-hidden":!0,className:r,children:i})}function OF({option:e,selected:t,multiSelect:n,onClick:r,isLast:i}){let a=`w-full text-left p-3 pt-2.5 pl-4 pr-5 bg-background`,o=i?``:`border-b border-border`;return r?(0,q.jsx)(`button`,{onClick:r,className:u(a,o,`transition-colors cursor-pointer`),children:(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,q.jsx)(EF,{label:e.label,description:e.description})}),(0,q.jsx)(DF,{selected:t,multiSelect:n})]})}):(0,q.jsx)(`div`,{className:u(a,o),children:(0,q.jsx)(EF,{label:e.label,description:e.description})})}function kF({questions:e,onSubmit:t,onCancel:n,ports:r={}}){let i=r.timer??fi,o=wF.useScopedStore(e=>e.currentIndex),s=wF.useScopedStore(e=>e.answers),c=wF.useScopedStore(e=>e.customInputs),l=wF.useScopedStore(e=>e.setCurrentIndex),d=wF.useScopedStore(e=>e.setAnswers),f=wF.useScopedStore(e=>e.setCustomInputs);if(e.length===0)return null;let p=e=>e.id||e.question,m=(t,n)=>{let r=c[t]?.trim(),i=s[t]||``;if((n||e.find(e=>p(e)===t))?.multiSelect)return[i,r].filter(Boolean).flatMap(e=>e.split(`, `).filter(Boolean));let a=r||i;return a?[a]:[]},h=e=>{let t=s[p(e)]||``;return e.multiSelect?t.split(`, `).filter(Boolean):[t]},g=(t,n)=>{let r=p(t);if(t.multiSelect){let e=s[r]?s[r].split(`, `).filter(Boolean):[],t=e.includes(n)?e.filter(e=>e!==n):[...e,n];d({...s,[r]:t.join(`, `)})}else d({...s,[r]:n}),f({...c,[r]:``}),o<e.length-1&&i.setTimeout(()=>l(o+1),150)},_=(e,t)=>{let n=p(e);f({...c,[n]:t}),t&&!e.multiSelect&&d({...s,[n]:``})},v=e=>{let t=p(e);e.multiSelect&&c[t]&&f({...c,[t]:``})},y=e.every(e=>m(p(e),e).length>0),b=e[Math.min(o,e.length-1)],x=o>=e.length-1,S=m(p(b),b).length>0,C=()=>{o<e.length-1&&l(o+1)},w=()=>{o>0&&l(o-1)},T=()=>{if(!y)return;let n={};for(let t of e){let e=p(t);n[e]=m(e,t)}t(n)},E=e=>{if(e.key===`Enter`&&S){if(e.preventDefault(),x){T();return}C()}},D=h(b),O=c[p(b)]||``;return(0,q.jsxs)(`div`,{className:`w-full space-y-3`,children:[(0,q.jsxs)(TF,{question:b.question,header:b.header,currentIndex:o,totalQuestions:e.length,onBack:o>0?w:void 0,children:[b.options?.map(e=>(0,q.jsx)(OF,{option:e,selected:D.includes(e.label),multiSelect:b.multiSelect,onClick:()=>g(b,e.label)},e.label)),(0,q.jsx)(`div`,{className:`transition-colors bg-background`,children:(0,q.jsxs)(`div`,{className:`flex pr-5 items-center justify-between gap-3`,children:[(0,q.jsx)(`input`,{type:`text`,value:O,onChange:e=>_(b,e.target.value),onKeyDown:E,placeholder:`Other...`,className:`flex-1 px-3 !py-1 pl-4 min-h-[55px] min-w-0 text-sm bg-transparent outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background rounded-md text-foreground placeholder:text-muted-foreground`}),(0,q.jsx)(DF,{selected:!!O,multiSelect:b.multiSelect,onClick:b.multiSelect&&O?()=>v(b):void 0})]})})]}),(0,q.jsxs)(`div`,{className:`flex items-center mx-2`,children:[n?(0,q.jsx)(a,{size:`sm`,variant:`outline`,className:`rounded-full`,onClick:n,children:`Cancel`}):null,(0,q.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[!x&&S&&(b.multiSelect||!!O)&&(0,q.jsx)(a,{size:`sm`,onClick:C,children:`Next`}),x&&(0,q.jsx)(a,{size:`sm`,onClick:T,disabled:!y,className:u(!y&&`opacity-50 cursor-not-allowed`,`rounded-full`),children:`Submit`})]})]})]})}function AF({questions:e,onSubmit:t,onCancel:n,ports:r}){return(0,q.jsx)(wF.Provider,{init:void 0,children:(0,q.jsx)(kF,{questions:e,onSubmit:t,onCancel:n,ports:r})})}function jF({savedAnswers:e,isComplete:t}){return n=>({submittedAnswers:e??null,isSubmitted:t,submitError:null,markSubmitted:e=>n({submittedAnswers:e,isSubmitted:!0,submitError:null}),markSubmitFailed:e=>n(t=>t.isSubmitted||t.submitError!==e?{isSubmitted:!1,submitError:e}:t)})}var MF=ci(`AskUserQuestionMessage`,jF);function NF(e){return e?.answers}function PF(e){return e.id||e.question}function FF({questions:e,statusLabel:t,testId:n}){return(0,q.jsx)(`div`,{className:`w-full`,"data-testid":n,children:(0,q.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`font-medium text-sm p-3 px-4 pr-5 bg-muted border-b border-border flex flex-row items-center justify-between gap-3`,children:[(0,q.jsxs)(`p`,{children:[`Question`,e.length===1?``:`s`]}),(0,q.jsx)(`p`,{className:`text-muted-foreground`,children:t})]}),e.map((t,n)=>(0,q.jsxs)(`div`,{className:u(`w-full p-3 pt-2.5 pl-4 pr-5 bg-background flex items-start justify-between gap-3`,n<e.length-1&&`border-b border-border`),children:[(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[t.header&&(0,q.jsx)(`div`,{className:`text-xs font-semibold tracking-wide text-muted-foreground text-pretty`,children:t.header}),(0,q.jsx)(`div`,{className:`text-sm text-pretty`,children:t.question})]}),(0,q.jsx)(`div`,{className:`max-w-[50%] text-right text-xs text-muted-foreground text-pretty`,children:t.options?.map(e=>e.label).join(`, `)||`Freeform response`})]},PF(t)))]})})}function IF({message:e,onSubmit:t,isLatest:n}){let r=Bt(),i=e.input.questions,a=!!e.result,o=NF(e.result),s=e.result?.discarded===!0,c=MF.useScopedStore(e=>e.submittedAnswers),l=MF.useScopedStore(e=>e.isSubmitted),d=MF.useScopedStore(e=>e.markSubmitted),f=MF.useScopedStore(e=>e.markSubmitFailed),p=MF.useScopedStore(e=>e.submitError),m=(0,K.useCallback)(n=>{d(n);try{let r=t(e.toolId,i,n);r&&typeof r.then==`function`&&r.catch(e=>{f(U(e))})}catch(e){f(U(e))}},[d,f,t,e.toolId,i]);if(l||a){let e=o||c||{};return(0,q.jsx)(`div`,{className:`w-full`,children:(0,q.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`font-medium text-sm p-3 px-4 pr-5 bg-muted border-b border-border flex flex-row items-center justify-between`,children:[(0,q.jsxs)(`p`,{children:[`Question`,i.length===1?``:`s`]}),(0,q.jsx)(`p`,{className:``,children:s?`Discarded`:`Answers`})]}),i.map((t,n)=>{let r=e[PF(t)]||e[t.question]||[],a=n===i.length-1,o=t.options?r.map(e=>t.options?.find(t=>t.label===e)?.description).filter(e=>!!e):[];return(0,q.jsxs)(`div`,{className:u(`w-full p-3 pt-2.5 pl-4 pr-5 bg-background flex items-start justify-between gap-3`,!a&&`border-b border-border`),children:[(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[t.header&&(0,q.jsx)(`div`,{className:`text-xs font-semibold tracking-wide text-muted-foreground text-pretty`,children:t.header}),(0,q.jsx)(`div`,{className:`text-sm text-pretty`,children:t.question})]}),(0,q.jsx)(`div`,{className:`max-w-[50%] text-right`,children:r.length>0?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-pretty`,children:r.join(`, `)}),o.length>0&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5 text-pretty`,children:o.join(` · `)})]}):(0,q.jsx)(`div`,{className:`text-sm font-medium italic`,children:s?`Discarded`:`No Response`})})]},PF(t))})]})})}return r.readonly?(0,q.jsx)(FF,{questions:i,statusLabel:`Awaiting response`}):n?r.askUserQuestionSurface===`footer`?(0,q.jsx)(FF,{questions:i,statusLabel:`Answer below`,testId:`ask-user-question-moved:${e.toolId}`}):(0,q.jsxs)(`div`,{className:`w-full`,children:[p?(0,q.jsx)(`div`,{className:`mb-2 rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive whitespace-pre-wrap`,"data-testid":`ask-user-question-error:${e.toolId}`,children:p}):null,(0,q.jsx)(AF,{questions:i,onSubmit:m})]}):(0,q.jsx)(`div`,{className:`w-full py-2`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(ze,{className:`h-4 w-4 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Questions pending (newer question active)`})]})})}function LF({message:e,onSubmit:t,isLatest:n}){let r=NF(e.result)??null,i=!!e.result;return(0,q.jsx)(MF.Provider,{init:{savedAnswers:r,isComplete:i},children:(0,q.jsx)(IF,{message:e,onSubmit:t,isLatest:n})})}function RF(){return e=>({expanded:!1,copied:!1,showEditInput:!1,editMessage:``,setExpanded:t=>e({expanded:t}),setCopied:t=>e({copied:t}),setEditMessage:t=>e({editMessage:t}),openEdit:()=>e({showEditInput:!0}),cancelEdit:()=>e(e=>e.showEditInput||e.editMessage!==``?{showEditInput:!1,editMessage:``}:e)})}var zF=ci(`ExitPlanModeMessage`,RF);function BF({message:e,onConfirm:t,isLatest:n,ports:r={}}){let i=Bt(),o=r.clipboard??Ar,s=r.timer??fi,c=!!e.result,l=zF.useScopedStore(e=>e.expanded),d=zF.useScopedStore(e=>e.copied),f=zF.useScopedStore(e=>e.showEditInput),p=zF.useScopedStore(e=>e.editMessage),m=zF.useScopedStore(e=>e.setExpanded),h=zF.useScopedStore(e=>e.setCopied),g=zF.useScopedStore(e=>e.setEditMessage),_=zF.useScopedStore(e=>e.openEdit),v=zF.useScopedStore(e=>e.cancelEdit),y=(0,K.useRef)(null),b=(0,K.useCallback)(n=>{n.key===`Enter`&&!n.shiftKey&&p.trim()&&(n.preventDefault(),t(e.toolId,!1,void 0,p.trim())),n.key===`Escape`&&v()},[p,t,e.toolId,v]),x=e.input;(0,K.useEffect)(()=>{f&&y.current&&y.current.focus()},[f]);let S=async()=>{x?.plan&&(await o.writeText(x.plan),h(!0),s.setTimeout(()=>h(!1),2e3))},C=c?e.result:null,w=C?.discarded===!0,T;T=w?`Discarded`:C?.clearContext?`Approved & Cleared Context`:C?.confirmed?`Approved`:C?.message?`Adjusted: "${C.message}"`:`Adjusted Plan`;let E;return E=c?(0,q.jsx)(`div`,{className:`flex justify-end mx-2`,children:(0,q.jsxs)(`span`,{className:`pl-4 inline text-sm font-medium bg-background text-foreground/60 border border-border py-1.5 px-3 rounded-[20px] leading-relaxed max-w-[85%] sm:max-w-[80%]`,children:[(0,q.jsx)(`em`,{children:T}),(0,q.jsx)(na,{className:`inline h-4 w-4 ml-1.5 -mt-0.5`})]})}):n?i.readonly?(0,q.jsx)(`div`,{className:`flex justify-end mx-2`,children:(0,q.jsx)(`span`,{className:`inline text-sm text-muted-foreground italic`,children:`Plan pending in original session`})}):(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!f&&(0,q.jsxs)(`div`,{className:`flex flex-col md:flex-row items-stretch md:items-center justify-end gap-2 mx-2`,children:[(0,q.jsxs)(a,{size:`sm`,onClick:()=>t(e.toolId,!0,!0),className:`rounded-full bg-primary text-background pr-4 md:order-last`,children:[(0,q.jsx)(Ji,{className:`h-4 w-4 mr-1.5`}),`Approve & Clear`]}),(0,q.jsxs)(`div`,{className:`flex items-stretch md:items-center gap-2 md:contents`,children:[(0,q.jsxs)(a,{size:`sm`,variant:`outline`,onClick:_,className:`rounded-full border-border flex-1 md:flex-initial md:order-first`,children:[(0,q.jsx)($r,{className:`h-4 w-4 mr-1.5`}),`Suggest Edits`]}),(0,q.jsxs)(a,{size:`sm`,variant:`outline`,onClick:()=>t(e.toolId,!0),className:`rounded-full border-border flex-1 md:flex-initial`,children:[(0,q.jsx)(Dr,{className:`h-4 w-4 mr-1.5`}),`Approve`]})]})]}),f&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(`textarea`,{ref:y,value:p,onChange:e=>g(e.target.value),onKeyDown:b,placeholder:`Describe what you'd like to change...`,rows:3,className:`w-full rounded-2xl border border-border bg-muted dark:bg-card px-4 py-3 text-sm text-foreground placeholder:text-muted-foreground resize-none outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2 mx-2`,children:[(0,q.jsx)(a,{size:`sm`,variant:`ghost`,onClick:v,className:`rounded-full text-muted-foreground`,children:`Cancel`}),(0,q.jsxs)(a,{size:`sm`,disabled:!p.trim(),onClick:()=>t(e.toolId,!1,void 0,p.trim()),className:`rounded-full bg-primary text-background disabled:opacity-50 disabled:pointer-events-none`,children:[(0,q.jsx)(Sa,{className:`h-4 w-4 mr-1.5`}),`Adjust Plan`]})]})]})]}):(0,q.jsx)(`div`,{className:`flex justify-end mx-2`,children:(0,q.jsx)(`span`,{className:`inline text-sm text-muted-foreground italic`,children:`Plan pending (newer prompt active)`})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`relative rounded-2xl border border-border overflow-hidden group/plan`,children:[x?.plan&&(0,q.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":d?`Copied`:`Copy plan`,className:u(`absolute top-2 right-2 z-10 h-11 w-11 md:h-8 md:w-8 rounded-md text-muted-foreground opacity-100 md:opacity-0 md:group-hover/plan:opacity-100 transition-opacity [@media(hover:none)]:!opacity-100`,!d&&`hover:text-foreground`,d&&`hover:!bg-transparent hover:!border-transparent`),onClick:S,children:d?(0,q.jsx)(Dr,{className:`h-4 w-4 text-success-text`}):(0,q.jsx)(kr,{className:`h-4 w-4`})}),(0,q.jsxs)(`div`,{className:u(`!pt-5 !pb-0 px-4 md:py-4.5 md:px-5.5 bg-muted dark:bg-card overflow-scroll no-pre-highlight transition-colors`,c&&!l?`max-h-[min(400px,40vh)] `:``,c?`hover:!pb-[32px]`:``),children:[c&&(0,q.jsxs)(a,{variant:`ghost`,className:`absolute z-10 bottom-2 pr-2.5 !pl-3.5 h-[34px] inline-flex gap-1 text-sm left-[50%] -translate-x-[50%] text-muted-foreground bg-background hover:text-foreground opacity-0 group-hover/plan:opacity-100 transition-[color,opacity] rounded-md border border-border`,onClick:()=>m(!l),children:[l?`Show Less`:`Show More`,(0,q.jsx)(or,{className:`size-3.5 transition-transform ${l?`rotate-180`:``}`})]}),x?.plan?(0,q.jsxs)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:[It(x.plan),(0,q.jsx)(`div`,{className:`mt-5`})]}):(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No plan provided`})]})]}),E]})}function VF({message:e,onConfirm:t,isLatest:n,ports:r}){return(0,q.jsx)(zF.Provider,{init:void 0,children:(0,q.jsx)(BF,{message:e,onConfirm:t,isLatest:n,ports:r})})}var HF={completed:{Icon:Dr,iconClass:`text-success-text`,textClass:`text-muted-foreground`},in_progress:{Icon:Or,iconClass:`text-foreground animate-spin`,textClass:`text-foreground font-medium`},pending:{Icon:$i,iconClass:`text-muted-foreground`,textClass:`text-muted-foreground`}};function UF({message:e}){let t=e.input.todos;return t.length?(0,q.jsx)(`div`,{className:`w-full`,children:(0,q.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,q.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,q.jsx)(fa,{className:`h-4 w-4 text-muted-foreground`}),`Progress`]}),(0,q.jsx)(`div`,{children:t.map((e,n)=>{let r=n===t.length-1,{Icon:i,iconClass:a,textClass:o}=HF[e.status];return(0,q.jsxs)(`div`,{className:u(`flex items-center gap-3 px-4 py-2.5 bg-background`,!r&&`border-b border-border`),children:[(0,q.jsx)(i,{className:u(`h-4 w-4 flex-shrink-0`,a)}),(0,q.jsx)(`span`,{className:u(`text-sm`,o),children:e.status===`in_progress`?e.activeForm:e.content})]},n)})})]})}):null}var WF=ci(`OfferDownloadMessage`,()=>e=>({probeState:`idle`,previewOpen:!1,setProbeState:t=>e({probeState:t}),setPreviewOpen:t=>e({previewOpen:t})}));function GF({message:e}){let t=e.result,n=t?.contentUrl,r=WF.useScopedStore(e=>e.probeState),i=WF.useScopedStore(e=>e.previewOpen),a=WF.useScopedStore(e=>e.setProbeState),o=WF.useScopedStore(e=>e.setPreviewOpen);if((0,K.useEffect)(()=>{if(!n)return;let e=new AbortController;return lt(n,{signal:e.signal}).then(t=>{e.signal.aborted||(t.kind===`ready`?a(`ready`):t.kind===`missing`&&a(`missing`))}),()=>e.abort()},[n,a]),!t||!n)return null;let s={id:`offer-download-${e.toolId}`,kind:`file`,displayName:t.displayName||t.fileName,absolutePath:t.relativePath,relativePath:t.relativePath,contentUrl:n,mimeType:t.mimeType??`application/octet-stream`,size:t.size},c=st(s),l=Dt(c,t.mimeType),u=t.size>0?Be(t.size):null,d=(0,q.jsxs)(q.Fragment,{children:[l,u?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(`span`,{className:`tabular-nums`,children:u})]}):null]});if(r===`missing`)return(0,q.jsx)(`div`,{className:`flex`,"data-testid":`offer-download-link`,children:(0,q.jsx)(W,{attachment:s,disabledReason:`File no longer available`})});if(!Ke(s).openInNewTab){let e=`Preview ${s.displayName}, ${l}${u?`, ${u}`:``}`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`flex`,"data-testid":`offer-download-link`,children:(0,q.jsx)(W,{attachment:s,onClick:()=>o(!0),meta:d,ariaLabel:e})}),(0,q.jsx)(Nt,{source:i?Ft(s,`offer_download`):null,open:i,onOpenChange:o})]})}let f=[`Download`,s.displayName,l,u].filter(e=>!!e);return(0,q.jsx)(`div`,{className:`flex`,"data-testid":`offer-download-link`,children:(0,q.jsx)(W,{attachment:s,href:n,download:t.fileName||void 0,meta:d,ariaLabel:f.join(`, `)})})}function KF({message:e}){return(0,q.jsx)(WF.Provider,{init:void 0,children:(0,q.jsx)(GF,{message:e})})}var qF=ci(`PreviewFileMessage`,()=>e=>({probeState:`idle`,previewOpen:!1,setProbeState:t=>e({probeState:t}),setPreviewOpen:t=>e({previewOpen:t})}));function JF({message:e}){let t=e.result,n=t?.contentUrl,r=qF.useScopedStore(e=>e.probeState),i=qF.useScopedStore(e=>e.previewOpen),a=qF.useScopedStore(e=>e.setProbeState),o=qF.useScopedStore(e=>e.setPreviewOpen);if((0,K.useEffect)(()=>{if(!n)return;let e=new AbortController;return lt(n,{signal:e.signal}).then(t=>{e.signal.aborted||(t.kind===`ready`?a(`ready`):t.kind===`missing`&&a(`missing`))}),()=>e.abort()},[n,a]),!t||!n)return null;let s={id:`preview-file-${e.toolId}`,kind:`file`,displayName:t.displayName||t.fileName,absolutePath:t.relativePath,relativePath:t.relativePath,contentUrl:n,mimeType:t.mimeType,size:t.size},c=st(s),l=Dt(c,t.mimeType),u=t.size>0?Be(t.size):null,d=(0,q.jsxs)(q.Fragment,{children:[l,u?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(`span`,{className:`tabular-nums`,children:u})]}):null]});if(r===`missing`)return(0,q.jsx)(`div`,{className:`flex`,"data-testid":`preview-file-card`,children:(0,q.jsx)(W,{attachment:s,disabledReason:`File no longer available`})});let f=`Preview ${s.displayName}, ${l}${u?`, ${u}`:``}`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`flex`,"data-testid":`preview-file-card`,children:(0,q.jsx)(W,{attachment:s,onClick:()=>o(!0),meta:d,ariaLabel:f})}),(0,q.jsx)(Nt,{source:i?Ft(s,`preview_file`):null,open:i,onOpenChange:o})]})}function YF({message:e}){return(0,q.jsx)(qF.Provider,{init:void 0,children:(0,q.jsx)(JF,{message:e})})}var XF=new Map;function ZF(e){let t=XF.get(e);return t===void 0?void 0:t}function QF(e){let{cacheKey:t,enabled:n,ref:r,fetcher:i,rootMargin:a}=e,o=ZF(t),s=(0,K.useRef)(null);s.current===null&&(s.current=d(()=>({state:o===void 0?`idle`:`ready`,data:o===void 0?null:o,error:null})));let c=l(s.current,e=>e.state),u=l(s.current,e=>e.data),f=l(s.current,e=>e.error),p=(0,K.useRef)(t),m=(0,K.useRef)(null),h=(0,K.useRef)(t);return h.current=t,(0,K.useEffect)(()=>{if(p.current===t)return;p.current=t;let e=ZF(t);s.current.setState({state:e===void 0?`idle`:`ready`,data:e===void 0?null:e,error:null})},[t]),(0,K.useEffect)(()=>{if(!n||o!==void 0)return;let e=r.current;if(!e||typeof IntersectionObserver>`u`)return;let c=!1,l=t,u=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;if(u.disconnect(),c)return;let e=new AbortController;m.current=e,s.current.setState({state:`loading`}),i(e.signal).then(e=>{c||h.current!==l||(XF.set(l,e),s.current.setState({data:e,state:`ready`}))}).catch(t=>{c||e.signal.aborted||h.current!==l||s.current.setState({error:t instanceof Error?t:Error(String(t)),state:`error`})});break}},{rootMargin:a??`200px`});return u.observe(e),()=>{c=!0,u.disconnect(),m.current?.abort(),m.current=null}},[o,t,n,r,i,a]),(0,K.useMemo)(()=>({state:c,data:u,error:f}),[c,u,f])}function $F({source:e,onOpen:t,variant:n}){let r={id:e.id,kind:`file`,displayName:e.displayName,mimeType:e.mimeType,size:e.size??0,contentUrl:e.contentUrl,relativePath:e.relativePath??``,absolutePath:``},i=st(r),a=Dt(i,e.mimeType),o=e.size&&e.size>0?Be(e.size):null;return i===`image`?(0,q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Preview ${e.displayName}`,className:`overflow-hidden rounded-xl border border-border bg-background`,children:(0,q.jsx)(`img`,{src:e.contentUrl,alt:e.altText??e.displayName,loading:`lazy`,className:`max-h-64 w-auto max-w-full object-contain`})}):n===`expanded`&&(i===`text`||i===`code`||i===`markdown`||i===`json`||i===`table`)?(0,q.jsx)(eI,{source:e,onOpen:t,friendlyType:a,sizeLabel:o}):(0,q.jsx)(W,{attachment:r,onClick:t,meta:(0,q.jsxs)(q.Fragment,{children:[a,o?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(`span`,{className:`tabular-nums`,children:o})]}):null]}),ariaLabel:`Preview ${e.displayName}, ${a}${o?`, ${o}`:``}`})}var eI=function({source:e,onOpen:t,friendlyType:n,sizeLabel:r}){let i=(0,K.useRef)(null),a=e.contentUrl,o=(0,K.useCallback)(async e=>{let t=await Xe(a,4096);if(e.aborted)throw Error(`aborted`);return t.content.slice(0,200)},[a]),s=QF({ref:i,enabled:!0,cacheKey:`snippet:${e.id}|${e.contentUrl}|${e.size??0}`,fetcher:o}),c=s.state===`ready`&&typeof s.data==`string`?s.data:``;return(0,q.jsxs)(`button`,{ref:i,type:`button`,onClick:t,"aria-label":`Preview ${e.displayName}`,className:`flex w-full max-w-md flex-col items-start gap-1 rounded-xl border border-border bg-background p-3 text-left hover:bg-accent/40`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.displayName}),(0,q.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n,r?` · ${r}`:``]}),c?(0,q.jsx)(`pre`,{className:`line-clamp-3 max-h-16 w-full whitespace-pre-wrap break-words text-xs text-muted-foreground`,children:c}):null]})},tI=ci(`ImageGenerationMessage`,()=>e=>({open:!1,setOpen:t=>e({open:t})}));function nI({message:e}){let{status:t,revisedPrompt:n}=e.input,r=e.result,i=r?.contentUrl,a=e.isError||t===`failed`,o=tI.useScopedStore(e=>e.open),s=tI.useScopedStore(e=>e.setOpen);if(!a&&!r&&t===`in_progress`)return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md border border-border/40 bg-muted/30 px-3 py-2 text-sm text-muted-foreground`,"data-testid":`image-generation-pending`,children:[(0,q.jsx)(`span`,{children:`Generating image…`}),n?(0,q.jsx)(`span`,{className:`italic`,children:n}):null]});if(a||!r||!i)return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm`,"data-testid":`image-generation-error`,children:[(0,q.jsx)(`span`,{children:`Image generation failed.`}),r?.relativePath?(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:r.relativePath}):null]});let c={id:`image-gen-${e.toolId}`,contentUrl:i,displayName:r.fileName,fileName:r.fileName,relativePath:r.relativePath,mimeType:`image/png`,origin:`image_generation`,altText:n??void 0};return(0,q.jsxs)(`figure`,{className:`flex flex-col gap-2`,"data-testid":`image-generation`,children:[(0,q.jsx)($F,{source:c,onOpen:()=>s(!0),variant:`expanded`}),n?(0,q.jsx)(`figcaption`,{className:`text-xs text-muted-foreground italic`,children:n}):null,(0,q.jsx)(Nt,{source:o?c:null,open:o,onOpenChange:s})]})}function rI({message:e}){return(0,q.jsx)(tI.Provider,{init:void 0,children:(0,q.jsx)(nI,{message:e})})}function iI({message:e}){return(0,q.jsx)(`div`,{className:`flex items-center justify-end gap-2 text-sm text-muted-foreground`,children:(0,q.jsxs)(`div`,{className:`inline-flex gap-1.5 items-center justify-center whitespace-nowrap text-sm font-medium bg-background text-foreground/60 border border-border h-9 pl-1 pr-4 rounded-full`,children:[(0,q.jsx)(Qi,{className:`h-4 w-4 ml-1.5`}),(0,q.jsx)(`em`,{children:`Interrupted`})]})})}var aI={user_send:{Icon:la,iconClass:`text-muted-foreground`,title:`Loop stopped by your message`,detail:`Your message took over the armed loop and disarmed it — sending a message never resumes a loop, it stops one. It will not pick itself back up.`},repeated_failures:{Icon:ut,iconClass:`text-destructive`,title:`Loop stopped after repeated failures`,detail:`Kanna disarmed the loop because its iterations kept failing. Read the failed approaches in the tracking file before re-arming it.`},goal_met:{Icon:Xi,iconClass:`text-muted-foreground`,title:`Loop finished`,detail:`The goal was met, so the loop disarmed itself.`},chat_deleted:{Icon:Qi,iconClass:`text-muted-foreground`,title:`Loop disarmed`,detail:`The chat was deleted.`}};function oI({message:e}){let{Icon:t,iconClass:n,title:r,detail:i}=aI[e.reason],a=e.trackingFileRel!==void 0||e.workdirAbs!==void 0;return(0,q.jsx)(`div`,{className:`px-0.5`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(t,{className:u(`mt-0.5 h-4 w-4 shrink-0`,n),"aria-hidden":`true`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:r}),i?(0,q.jsx)(`p`,{className:`mt-1 text-sm text-foreground/90`,children:i}):null,a?(0,q.jsxs)(`div`,{className:`mt-2 flex flex-col gap-0.5 text-xs text-muted-foreground`,children:[e.trackingFileRel===void 0?null:(0,q.jsx)(xi,{tooltip:e.trackingFileRel,inline:!0,children:(0,q.jsxs)(`span`,{children:[`Plan `,(0,q.jsx)(`span`,{className:`font-mono`,children:e.trackingFileRel})]})}),e.workdirAbs===void 0?null:(0,q.jsx)(xi,{tooltip:e.workdirAbs,inline:!0,children:(0,q.jsxs)(`span`,{children:[`Worktree `,(0,q.jsx)(`span`,{className:`font-mono`,children:e.workdirAbs})]})})]}):null,e.resumable?(0,q.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`This loop can be re-armed with the `,(0,q.jsx)(`span`,{className:`font-mono`,children:`resume_loop`}),` tool.`]}):null]})]})})}var sI=8,cI=6;function lI(){let e=`zigzag-${(0,K.useId)().replace(/[^a-zA-Z0-9]/g,``)}`;return(0,q.jsxs)(`svg`,{"aria-hidden":!0,className:`flex-1 text-border`,height:cI,children:[(0,q.jsx)(`pattern`,{id:e,width:sI,height:cI,patternUnits:`userSpaceOnUse`,children:(0,q.jsx)(`path`,{d:`M0 5 L${sI/2} 1 L${sI} 5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,q.jsx)(`rect`,{width:`100%`,height:cI,fill:`url(#${e})`})]})}function uI({label:e}){return(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(lI,{}),(0,q.jsx)(`span`,{className:`text-xs tracking-widest text-muted-foreground flex-shrink-0`,children:e}),(0,q.jsx)(lI,{})]})}function dI(){return(0,q.jsx)(uI,{label:`Compacted`})}function fI(){return(0,q.jsx)(uI,{label:`Context Cleared`})}function pI({message:e}){let t=e.path.lastIndexOf(`/`),n=t>=0?e.path.slice(0,t+1):``,r=t>=0?e.path.slice(t+1):e.path;return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,q.jsx)(jt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/70`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`text-xs`,children:`Loaded`}),(0,q.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:[n?(0,q.jsx)(`span`,{className:`opacity-60`,children:n}):null,(0,q.jsx)(`span`,{className:`text-foreground/70`,children:r})]})]})}function mI({message:e}){return(0,q.jsx)(Je,{children:(0,q.jsxs)(bt,{expandedContent:(0,q.jsx)(Lt,{className:`my-4 text-xs`,children:(0,q.jsx)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:Ae(e.summary)})}),children:[(0,q.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:(0,q.jsx)(ma,{className:`h-4.5 w-4.5 text-muted-foreground`})}),(0,q.jsx)(et,{children:`Summarized`})]})})}var hI={compacting:`Compacting...`};function gI({message:e}){let t=hI[e.status]||e.status;return(0,q.jsxs)(Je,{className:`grid grid-cols-[auto_1fr] items-center gap-1.5 text-sm animate-pulse`,children:[(0,q.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:(0,q.jsx)(ma,{className:`h-4.5 w-4.5 text-muted-foreground`})}),(0,q.jsx)(et,{className:`text-left transition-opacity duration-200 truncate`,children:t})]})}function _I(e){return e.kind===`tool`}var vI={read_file:{key:`read`,singular:`read`,plural:`reads`},edit_file:{key:`edit`,singular:`edit`,plural:`edits`},write_file:{key:`write`,singular:`write`,plural:`writes`},delete_file:{key:`delete`,singular:`delete`,plural:`deletes`},bash:{key:`bash`,singular:`command`,plural:`commands`},grep:{key:`grep`,singular:`search`,plural:`searches`},glob:{key:`glob`,singular:`glob`,plural:`globs`},subagent_task:{key:`task`,singular:`agent`,plural:`agents`},web_search:{key:`websearch`,singular:`web search`,plural:`web searches`},skill:{key:`skill`,singular:`skill`,plural:`skills`},todo_write:{key:`todo`,singular:`todo update`,plural:`todo updates`}},yI={key:`other`,singular:`tool call`,plural:`tool calls`};function bI(e){return vI[e]??yI}function xI(e){let t=new Map,n=[];for(let r of e){if(!_I(r))continue;let e=r.toolKind,i=bI(e),a=t.get(i.key);a?a.count++:(t.set(i.key,{category:i,count:1}),n.push(i.key))}return n.map(e=>{let{category:n,count:r}=t.get(e);return`${r} ${r===1?n.singular:n.plural}`}).join(`, `)}function SI({messages:e,isLoading:t,localPath:n,expanded:r,onExpandedChange:i,chatId:a}){let o=(0,K.useMemo)(()=>xI(e),[e]),s=e.some(e=>_I(e)&&e.result===void 0)&&t;return(0,q.jsx)(Je,{className:`w-full`,children:(0,q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,q.jsx)(`button`,{onClick:()=>i(!r),className:`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${!r&&!s?`hover:opacity-60 transition-opacity`:``}`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] items-center gap-1.5`,children:[(0,q.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:(0,q.jsx)(jr,{className:`h-4.5 w-4.5 text-muted-icon transition-transform motion-reduce:transition-none duration-200 ${r?`rotate-90`:``}`})}),(0,q.jsx)(et,{className:`text-left`,children:(0,q.jsx)(Mt,{animate:s,children:o})})]})}),r&&(0,q.jsxs)(`div`,{className:`my-4 flex flex-col gap-3`,children:[e.filter(_I).map(e=>(0,q.jsx)(yt,{message:e,isLoading:t,localPath:n,chatId:a},e.id)),e.length>5&&(0,q.jsx)(`button`,{onClick:()=>i(!1),className:`cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-xs hover:opacity-80 transition-opacity`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] items-center gap-1.5`,children:[(0,q.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:(0,q.jsx)(jr,{className:`h-4.5 w-4.5 text-muted-icon -rotate-90`})}),(0,q.jsx)(et,{className:`text-left`,children:`Collapse`})]})})]})]})})}function CI(e){if(e!==`system`)return e}function wI(e,t){let n=CI(t),r=new Intl.DateTimeFormat(`en-GB`,{timeZone:n,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).formatToParts(new Date(e)),i=e=>r.find(t=>t.type===e)?.value??`00`,a=i(`hour`);return a===`24`&&(a=`00`),`${i(`day`)}/${i(`month`)}/${i(`year`)} ${a}:${i(`minute`)}`}var TI=/^(\d{2})\/(\d{2})\/(\d{4}) (\d{2}):(\d{2})$/;function EI(e,t){if(e===`system`)return-new Date(t).getTimezoneOffset();let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour12:!1,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).formatToParts(new Date(t)),r=e=>Number(n.find(t=>t.type===e)?.value??0),i=r(`hour`);i===24&&(i=0);let a=Date.UTC(r(`year`),r(`month`)-1,r(`day`),i,r(`minute`),r(`second`));return Math.round((a-t)/6e4)}function DI(e,t){let n=TI.exec(e.trim());if(!n)return null;let[,r,i,a,o,s]=n,c=Number(r),l=Number(i),u=Number(a),d=Number(o),f=Number(s);if(l<1||l>12||c<1||c>31||d>23||f>59)return null;let p=Date.UTC(u,l-1,c,d,f),m=EI(t,p),h=p-m*6e4;return h-(EI(t,h)-m)*6e4}var OI=ci(`AutoContinueCard`,({initialDraft:e})=>t=>({draft:e,editing:!1,setDraft:e=>t({draft:e}),setEditing:e=>t({editing:e})}));function kI({schedule:e,onAccept:t,onReschedule:n,onCancel:r}){let i=wI(e.scheduledAt??e.resetAt,e.tz);return(0,q.jsx)(OI.Provider,{init:{initialDraft:i},children:(0,q.jsx)(AI,{schedule:e,onAccept:t,onReschedule:n,onCancel:r})})}function AI({schedule:e,onAccept:t,onReschedule:n,onCancel:r}){let i=OI.useScopedStore(e=>e.draft),a=OI.useScopedStore(e=>e.editing),o=OI.useScopedStore(e=>e.setDraft),s=OI.useScopedStore(e=>e.setEditing),c=(0,K.useMemo)(()=>DI(i,e.tz),[i,e.tz]),l=c!==null&&c>Date.now(),u;if(u=c===null?`Use format dd/mm/yyyy hh:mm`:l?null:`Time must be in the future`,e.state===`fired`){let t=wI(e.scheduledAt??e.resetAt,e.tz);return(0,q.jsx)(St,{title:`Auto-continued at ${t}`,tone:`success`})}if(e.state===`cancelled`)return(0,q.jsx)(St,{title:`Auto-continue cancelled`,tone:`muted`});if(e.state===`proposed`){let n=e.resetAt<=Date.now();return(0,q.jsx)(St,{title:`Rate limit hit — schedule auto-continue?`,description:n?`Reset time has passed — accept to continue now.`:void 0,body:(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(pi,{value:i,onChange:e=>o(e.target.value),placeholder:`dd/mm/yyyy hh:mm`}),u&&(0,q.jsx)(`div`,{className:`text-destructive text-xs`,children:u})]}),actions:[{id:`schedule`,label:`Schedule`,variant:`primary`,disabled:!l,onClick:()=>{c!==null&&t(c)}},{id:`dismiss`,label:`Dismiss`,variant:`ghost`,onClick:()=>r()}]})}let d=wI(e.scheduledAt??e.resetAt,e.tz),f=e.tz===`system`?`local`:e.tz;if(!a)return(0,q.jsx)(St,{title:`Auto-continue at ${d} (${f})`,actions:[{id:`change`,label:`Change time`,variant:`secondary`,onClick:()=>s(!0)},{id:`cancel`,label:`Cancel`,variant:`ghost`,onClick:()=>r()}]});let p=[{id:`save`,label:`Save`,variant:`primary`,disabled:!l,onClick:()=>{c!==null&&(n(c),s(!1))}},{id:`back`,label:`Back`,variant:`ghost`,onClick:()=>s(!1)}];return(0,q.jsx)(St,{title:`Auto-continue at ${d} (${f})`,body:(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(pi,{value:i,onChange:e=>o(e.target.value),placeholder:`dd/mm/yyyy hh:mm`}),u&&(0,q.jsx)(`div`,{className:`text-destructive text-xs`,children:u})]}),actions:p})}function jI({toolRequestId:e,plan:t,onAnswer:n}){return(0,q.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`font-medium text-sm p-3 px-4 bg-muted border-b border-border flex items-center justify-between`,children:[(0,q.jsx)(`span`,{children:`Plan`}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Reconnected — awaiting your response`})]}),(0,q.jsx)(`div`,{className:`bg-background px-4 py-3`,children:(0,q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap`,children:t})}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3 bg-background border-t border-border`,children:[(0,q.jsx)(a,{size:`sm`,variant:`outline`,className:`rounded-full`,onClick:()=>n(e,{kind:`deny`,reason:`user_canceled`}),children:`Edit`}),(0,q.jsx)(a,{size:`sm`,className:`rounded-full`,onClick:()=>n(e,{kind:`answer`,payload:{confirmed:!0}}),children:`Confirm`})]})]})}function MI({toolRequestId:e,toolName:t,args:n,onAnswer:r}){let i=[`command`,`path`,`url`,`pattern`,`query`].find(e=>typeof n[e]==`string`&&String(n[e]).length>0),o=i===void 0?void 0:n[i],s=typeof o==`string`?o:JSON.stringify(n);return(0,q.jsxs)(`div`,{className:`rounded-2xl border border-border bg-background px-4 py-3 text-sm`,children:[(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Pending tool:`}),(0,q.jsx)(`span`,{className:`font-mono text-foreground`,children:t})]}),s?(0,q.jsx)(`pre`,{className:`mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground`,children:s}):null,(0,q.jsxs)(`div`,{className:`mt-3 flex items-center justify-end gap-2`,children:[(0,q.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>r(e,{kind:`deny`,reason:`user_canceled`}),children:`Deny`}),(0,q.jsx)(a,{variant:`default`,size:`sm`,onClick:()=>r(e,{kind:`allow`}),children:`Allow`})]})]})}function NI({entry:e,onAnswer:t}){let{toolRequestId:n,toolName:r,arguments:i}=e;if(r===`mcp__kanna__ask_user_question`){let e=(Array.isArray(i.questions)?i.questions.filter(De):[]).map(e=>{let t;return t=typeof e.question==`string`?e.question:typeof e.text==`string`?e.text:``,{id:typeof e.id==`string`?e.id:void 0,question:t,header:typeof e.header==`string`?e.header:void 0,options:Array.isArray(e.options)?e.options.filter(De).filter(e=>typeof e.label==`string`):void 0,multiSelect:typeof e.multiSelect==`boolean`&&e.multiSelect}});return(0,q.jsx)(AF,{questions:e,onSubmit:r=>t(n,{kind:`answer`,payload:{questions:e,answers:r}}),onCancel:()=>t(n,{kind:`deny`,reason:`user_canceled`})})}if(r===`mcp__kanna__exit_plan_mode`){let e=typeof i.plan==`string`?i.plan:``;return(0,q.jsx)(jI,{toolRequestId:n,plan:e,onAnswer:t})}return(0,q.jsx)(MI,{toolRequestId:n,toolName:r,args:i,onAnswer:t})}var PI=`mcp__kanna__delegate_subagent`;function FI(e){let t=[];for(let n of e){if(n.kind!==`tool`||n.toolKind!==`mcp_generic`||n.toolName!==`mcp__kanna__delegate_subagent`)continue;let e=n.input.payload.subagent_id;typeof e==`string`&&t.push({toolId:n.toolId,subagentId:e})}return t}function II(e,t){let n=new Map;for(let e of t){let t=e.subagentId??`\0null`,r=n.get(t)??[];r.push(e),n.set(t,r)}for(let e of n.values())e.sort((e,t)=>e.startedAt-t.startedAt||e.runId.localeCompare(t.runId));let r=new Map,i=new Set,a=new Map;for(let t of e){let e=n.get(t.subagentId);if(!e)continue;let o=a.get(t.subagentId)??0,s=e[o];s&&(r.set(t.toolId,s),i.add(s.runId),a.set(t.subagentId,o+1))}return{matched:r,orphans:t.filter(e=>!i.has(e.runId))}}var LI=()=>{},RI={onAskUserQuestionSubmit:LI,onExitPlanModeConfirm:LI,onToolRequestAnswer:LI,onAutoContinueAccept:LI,onAutoContinueReschedule:LI,onAutoContinueCancel:LI,onRetryFailedTurn:void 0,onCronRemove:void 0,schedules:{},cronJobs:[],chatId:void 0,onToolGroupExpandedChange:LI,subagentRuns:{},editorPreset:`cursor`,editorCommandTemplate:void 0,platform:`darwin`,queuedMessages:[],runtimeStatus:null,isDraining:!1,commandError:null,onStopDraining:LI,onSteerQueuedMessage:LI,onRemoveQueuedMessage:LI,localPath:void 0,latestToolIds:{},isProcessing:!1},zI=(0,K.createContext)(RI);function BI(){return(0,K.useContext)(zI)}function VI({value:e,children:t}){return(0,q.jsx)(zI.Provider,{value:e,children:t})}var HI=new Set([`AskUserQuestion`,`ExitPlanMode`,`TodoWrite`,PI,Pr]),UI=new Set([`offer_download`,`image_generation`]);function WI(e){return e.kind===`tool`}function GI(e){return!WI(e)||UI.has(e.toolKind)?!1:!HI.has(e.toolName)}function KI(e,{isFirstSystem:t,isFirstAccount:n,isLatestTodoWrite:r,hideResult:i,isFinalStatus:a}){let o=!e.hidden;if(o)switch(e.kind){case`system_init`:o=t;break;case`account_info`:o=n;break;case`tool`:o=e.toolKind!==`todo_write`||r;break;case`result`:o=!i&&(!e.success||e.durationMs>6e4);break;case`context_window_updated`:o=!1;break;case`status`:o=a;break;default:o=!0}return{isFirstSystem:t,isFirstAccount:n,isLatestTodoWrite:r,hideResult:i,isFinalStatus:a,shouldRender:o}}function qI(e,t){let n=e.findIndex(e=>e.kind===`system_init`),r=e.findIndex(e=>e.kind===`account_info`);return e.map((i,a)=>{let o=e[a-1],s=e[a+1];return KI(i,{isFirstSystem:n===a,isFirstAccount:r===a,isLatestTodoWrite:i.id===t.TodoWrite,hideResult:s?.kind===`context_cleared`||o?.kind===`context_cleared`,isFinalStatus:a===e.length-1})})}function JI(e,t){let n=[],r=0;for(;r<e.length;){let i=e[r];if(t[r]?.shouldRender&&GI(i)){let a=[i],o=r;for(r+=1;r<e.length;){let n=e[r];if(!t[r]?.shouldRender){r+=1;continue}if(!GI(n))break;a.push(n),r+=1}a.length>=2?n.push({type:`tool-group`,messages:a,startIndex:o}):n.push({type:`single`,message:i,index:o});continue}n.push({type:`single`,message:i,index:r}),r+=1}return n}function YI(e){return e.type===`single`?e.message.id:`tool-group:${e.messages[0]?.id??e.startIndex}`}function XI(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function ZI(e,t){return e.id===t.id&&e.kind===t.kind&&e.displayName===t.displayName&&e.absolutePath===t.absolutePath&&e.relativePath===t.relativePath&&e.contentUrl===t.contentUrl&&e.mimeType===t.mimeType&&e.size===t.size}function QI(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>ZI(e,t[n]))}function $I(e,t){if(e===t)return!0;if(e.kind!==t.kind||e.id!==t.id||e.hidden!==t.hidden)return!1;switch(e.kind){case`user_prompt`:return e.content===(t.kind===`user_prompt`?t.content:null)&&t.kind===`user_prompt`&&e.steered===t.steered&&e.autoContinue?.scheduleId===t.autoContinue?.scheduleId&&QI(e.attachments,t.attachments);case`system_init`:return t.kind===`system_init`&&e.provider===t.provider&&e.model===t.model&&XI(e.tools,t.tools)&&XI(e.agents,t.agents)&&XI(e.slashCommands,t.slashCommands)&&e.debugRaw===t.debugRaw;case`account_info`:return t.kind===`account_info`&&e.accountInfo===t.accountInfo;case`assistant_text`:return t.kind===`assistant_text`&&e.text===t.text;case`assistant_thinking`:return t.kind===`assistant_thinking`&&e.text===t.text;case`api_error`:return t.kind===`api_error`&&e.status===t.status&&e.text===t.text&&e.requestId===t.requestId;case`policy_refusal`:return t.kind===`policy_refusal`&&e.text===t.text&&e.requestId===t.requestId;case`tool`:return t.kind===`tool`&&e.toolKind===t.toolKind&&e.toolName===t.toolName&&e.toolId===t.toolId&&e.isError===t.isError&&e.input===t.input&&e.result===t.result&&e.rawResult===t.rawResult;case`result`:return t.kind===`result`&&e.success===t.success&&e.cancelled===t.cancelled&&e.result===t.result&&e.durationMs===t.durationMs&&e.costUsd===t.costUsd&&e.codexErrorInfo===t.codexErrorInfo;case`status`:return t.kind===`status`&&e.status===t.status;case`compact_summary`:return t.kind===`compact_summary`&&e.summary===t.summary;case`context_window_updated`:return t.kind===`context_window_updated`&&e.usage===t.usage;case`memory_loaded`:return t.kind===`memory_loaded`&&e.path===t.path;case`loop_disarmed`:return t.kind===`loop_disarmed`&&e.reason===t.reason&&e.resumable===t.resumable&&e.trackingFileRel===t.trackingFileRel&&e.workdirAbs===t.workdirAbs;case`compact_boundary`:case`context_cleared`:case`interrupted`:return!0;case`unknown`:return t.kind===`unknown`&&e.json===t.json;case`auto_continue_prompt`:return t.kind===`auto_continue_prompt`&&e.scheduleId===t.scheduleId;case`pending_tool_request`:return t.kind===`pending_tool_request`&&e.toolRequestId===t.toolRequestId&&e.toolName===t.toolName;case`cron_armed`:case`cron_command_error`:case`cron_run`:case`cron_run_skipped`:case`cron_list`:case`cron_job_change`:return!0}}function eL(e,t){return e.kind!==t.kind||e.id!==t.id?!1:e.kind===`single`&&t.kind===`single`?e.index===t.index&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.isFirstSystem===t.isFirstSystem&&e.isFirstAccount===t.isFirstAccount&&e.isLatestAskUserQuestion===t.isLatestAskUserQuestion&&e.isLatestExitPlanMode===t.isLatestExitPlanMode&&e.isLatestTodoWrite===t.isLatestTodoWrite&&e.hideResult===t.hideResult&&e.isFinalStatus===t.isFinalStatus&&$I(e.message,t.message):e.kind===`tool-group`&&t.kind===`tool-group`&&e.startIndex===t.startIndex&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.messages.length===t.messages.length&&e.messages.every((e,n)=>$I(e,t.messages[n]))}function tL(e,t){let n=new Map,r=e.length!==t.byId.size,i=e.map((e,i)=>{let a=t.byId.get(e.id),o=a&&eL(a,e)?a:e;return n.set(e.id,o),!r&&t.result[i]!==o&&(r=!0),o});return r?{byId:n,result:i}:t}function nL(e){let t=(0,K.useRef)({byId:new Map,result:[]}),n=(0,K.useMemo)(()=>tL(e,t.current),[e]);return(0,K.useLayoutEffect)(()=>{t.current=n}),n.result}var rL=(e,t)=>{},iL=(0,K.memo)(({message:e,index:t,isLoading:n,localPath:r,isFirstSystem:i,isFirstAccount:a,isLatestAskUserQuestion:o,isLatestExitPlanMode:s,isLatestTodoWrite:c,hideResult:l,isFinalStatus:u,onAskUserQuestionSubmit:d,onExitPlanModeConfirm:f,onToolRequestAnswer:p=rL,schedules:m,cronJobs:h,onAutoContinueAccept:g,onAutoContinueReschedule:v,onAutoContinueCancel:y,onRetryFailedTurn:b,onCronRemove:x,chatId:S})=>{let C=null;if(e.kind===`user_prompt`)C=(0,q.jsx)(VP,{content:e.content,attachments:e.attachments,steered:e.steered,autoContinue:e.autoContinue},e.id);else switch(e.kind){case`auto_continue_prompt`:{let t=m[e.scheduleId];if(!t){C=(0,q.jsx)(`div`,{className:`rounded border px-3 py-2 text-sm opacity-70`,children:`Auto-continue expired`},e.id);break}C=(0,q.jsx)(kI,{schedule:t,onAccept:t=>g(e.scheduleId,t),onReschedule:t=>v(e.scheduleId,t),onCancel:()=>y(e.scheduleId)},e.id);break}case`unknown`:C=(0,q.jsx)(HP,{json:e.json},e.id);break;case`system_init`:C=i?(0,q.jsx)(iF,{message:e,rawJson:e.debugRaw},e.id):null;break;case`account_info`:C=a?(0,q.jsx)(lF,{message:e},e.id):null;break;case`assistant_text`:C=(0,q.jsx)(gt,{message:e},e.id);break;case`assistant_thinking`:C=(0,q.jsx)(mt,{message:e},e.id);break;case`api_error`:C=(0,q.jsx)(bF,{message:e},e.id);break;case`policy_refusal`:C=(0,q.jsx)(CF,{message:e},e.id);break;case`tool`:if(e.isError){C=(0,q.jsx)(yt,{message:e,isLoading:n,localPath:r,chatId:S},e.id);break}if(e.toolKind===`ask_user_question`){C=(0,q.jsx)(LF,{message:e,onSubmit:d,isLatest:o},e.id);break}if(e.toolKind===`exit_plan_mode`){C=(0,q.jsx)(VF,{message:e,onConfirm:f,isLatest:s},e.id);break}if(e.toolKind===`todo_write`){C=c?(0,q.jsx)(UF,{message:e},e.id):null;break}if(e.toolKind===`offer_download`&&e.result){C=(0,q.jsx)(KF,{message:e},e.id);break}if(e.toolKind===`preview_file`&&e.result){C=(0,q.jsx)(YF,{message:e},e.id);break}if(e.toolKind===`image_generation`){C=(0,q.jsx)(rI,{message:e},e.id);break}C=(0,q.jsx)(yt,{message:e,isLoading:n,localPath:r,chatId:S},e.id);break;case`result`:C=l?null:(0,q.jsx)(At,{message:e,onRetry:b},e.id);break;case`context_window_updated`:C=null;break;case`interrupted`:C=(0,q.jsx)(iI,{message:e},e.id);break;case`compact_boundary`:C=(0,q.jsx)(dI,{},e.id);break;case`context_cleared`:C=(0,q.jsx)(fI,{},e.id);break;case`memory_loaded`:C=(0,q.jsx)(pI,{message:e},e.id);break;case`compact_summary`:C=(0,q.jsx)(mI,{message:e},e.id);break;case`status`:C=u?(0,q.jsx)(gI,{message:e},e.id):null;break;case`pending_tool_request`:C=(0,q.jsx)(NI,{entry:e,onAnswer:p},e.id);break;case`cron_armed`:C=(0,q.jsx)(uF,{message:e,onRemove:x},e.id);break;case`cron_command_error`:C=(0,q.jsx)(fF,{message:e},e.id);break;case`cron_run`:C=(0,q.jsx)(Kr,{message:e,cronJobs:h},e.id);break;case`cron_run_skipped`:C=(0,q.jsx)(gF,{message:e},e.id);break;case`cron_list`:C=(0,q.jsx)(hF,{message:e,cronJobs:h},e.id);break;case`cron_job_change`:C=(0,q.jsx)(mF,{message:e},e.id);break;case`loop_disarmed`:C=(0,q.jsx)(oI,{message:e},e.id)}return C?(0,q.jsx)(`div`,{id:`msg-${e.id}`,className:`group relative`,"data-index":t,[_]:``,children:C}):null},(e,t)=>e.index===t.index&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.isFirstSystem===t.isFirstSystem&&e.isFirstAccount===t.isFirstAccount&&e.isLatestAskUserQuestion===t.isLatestAskUserQuestion&&e.isLatestExitPlanMode===t.isLatestExitPlanMode&&e.isLatestTodoWrite===t.isLatestTodoWrite&&e.hideResult===t.hideResult&&e.isFinalStatus===t.isFinalStatus&&e.onAskUserQuestionSubmit===t.onAskUserQuestionSubmit&&e.onExitPlanModeConfirm===t.onExitPlanModeConfirm&&e.onToolRequestAnswer===t.onToolRequestAnswer&&e.schedules===t.schedules&&e.cronJobs===t.cronJobs&&e.onAutoContinueAccept===t.onAutoContinueAccept&&e.onAutoContinueReschedule===t.onAutoContinueReschedule&&e.onAutoContinueCancel===t.onAutoContinueCancel&&e.onCronRemove===t.onCronRemove&&e.chatId===t.chatId&&$I(e.message,t.message)),aL=(0,K.memo)(({id:e,messages:t,isLoading:n,localPath:r,expanded:i,onExpandedChange:a,chatId:o})=>(0,q.jsx)(`div`,{className:`group relative`,[_]:``,children:(0,q.jsx)(SI,{messages:t,isLoading:n,localPath:r,expanded:i,onExpandedChange:t=>a(e,t),chatId:o})}),(e,t)=>e.id===t.id&&e.startIndex===t.startIndex&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.expanded===t.expanded&&e.onExpandedChange===t.onExpandedChange&&e.chatId===t.chatId&&e.messages.length===t.messages.length&&e.messages.every((e,n)=>$I(e,t.messages[n])));function oL(e,{isLoading:t,localPath:n,latestToolIds:r}){let i=qI(e,r),a=JI(e,i),o=[];for(let e of a){if(e.type===`tool-group`){o.push({kind:`tool-group`,id:YI(e),startIndex:e.startIndex,messages:e.messages,isLoading:t&&e.messages.some(e=>e.kind===`tool`&&e.result===void 0),localPath:n});continue}let a=i[e.index];if(!a)continue;let s={kind:`single`,id:YI(e),message:e.message,index:e.index,isLoading:e.message.kind===`tool`&&e.message.result===void 0&&t,localPath:n,isFirstSystem:a.isFirstSystem,isFirstAccount:a.isFirstAccount,isLatestAskUserQuestion:e.message.id===r.AskUserQuestion,isLatestExitPlanMode:e.message.id===r.ExitPlanMode,isLatestTodoWrite:a.isLatestTodoWrite,hideResult:a.hideResult,isFinalStatus:a.isFinalStatus};a.shouldRender&&o.push(s)}return o}var sL=(0,K.memo)(({row:e,toolGroupExpanded:t})=>{let{onToolGroupExpandedChange:n,onAskUserQuestionSubmit:r,onExitPlanModeConfirm:i,onToolRequestAnswer:a,schedules:o,cronJobs:s,onAutoContinueAccept:c,onAutoContinueReschedule:l,onAutoContinueCancel:u,onRetryFailedTurn:d,onCronRemove:f,chatId:p}=BI();return e.kind===`tool-group`?(0,q.jsx)(aL,{id:e.id,startIndex:e.startIndex,messages:e.messages,isLoading:e.isLoading,localPath:e.localPath,expanded:t??!1,onExpandedChange:n,chatId:p}):(0,q.jsx)(iL,{message:e.message,index:e.index,isLoading:e.isLoading,localPath:e.localPath,isFirstSystem:e.isFirstSystem,isFirstAccount:e.isFirstAccount,isLatestAskUserQuestion:e.isLatestAskUserQuestion,isLatestExitPlanMode:e.isLatestExitPlanMode,isLatestTodoWrite:e.isLatestTodoWrite,hideResult:e.hideResult,isFinalStatus:e.isFinalStatus,onAskUserQuestionSubmit:r,onExitPlanModeConfirm:i,onToolRequestAnswer:a,schedules:o,cronJobs:s,onAutoContinueAccept:c,onAutoContinueReschedule:l,onAutoContinueCancel:u,onRetryFailedTurn:d,onCronRemove:f,chatId:p})},(e,t)=>{if(e.toolGroupExpanded!==t.toolGroupExpanded||e.row.kind!==t.row.kind||e.row.id!==t.row.id)return!1;if(e.row.kind===`tool-group`&&t.row.kind===`tool-group`){let n=e.row,r=t.row;return n.startIndex===r.startIndex&&n.isLoading===r.isLoading&&n.localPath===r.localPath&&n.messages.length===r.messages.length&&n.messages.every((e,t)=>$I(e,r.messages[t]))}return e.row.kind===`single`&&t.row.kind===`single`&&e.row.index===t.row.index&&e.row.isLoading===t.row.isLoading&&e.row.localPath===t.row.localPath&&e.row.isFirstSystem===t.row.isFirstSystem&&e.row.isFirstAccount===t.row.isFirstAccount&&e.row.isLatestAskUserQuestion===t.row.isLatestAskUserQuestion&&e.row.isLatestExitPlanMode===t.row.isLatestExitPlanMode&&e.row.isLatestTodoWrite===t.row.isLatestTodoWrite&&e.row.hideResult===t.row.hideResult&&e.row.isFinalStatus===t.row.isFinalStatus&&$I(e.row.message,t.row.message)}),cL={},lL=[],uL=[];function dL(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??uL;if(n.content.trim().length!==0||r.length!==0)return{content:n.content,attachments:[...r]}}return null}var fL=Object.freeze([]),pL=c((e,t)=>({sharesByChat:{},listForChat(e){return t().sharesByChat[e]??fL},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 mL({onStop:e}){return(0,q.jsx)(Je,{className:`ml-[1px]`,children:(0,q.jsx)($e,{children:(0,q.jsxs)(`div`,{className:`group/draining relative flex items-center gap-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 group-hover/draining:opacity-0 transition-opacity`,children:[(0,q.jsx)(Or,{className:`size-4.5 animate-spin text-muted-icon`}),(0,q.jsx)(Mt,{className:`ml-[1px] text-sm`,shimmerWidth:44,children:`Running...`})]}),(0,q.jsxs)(`button`,{onClick:e,className:`absolute inset-0 flex items-center gap-1.5 opacity-0 group-hover/draining:opacity-100 transition-opacity cursor-pointer`,children:[(0,q.jsx)(ri,{className:`size-4.5 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Stop`})]})]})})})}function hL({message:e,onRemove:t,onSendNow:n}){return(0,q.jsx)(`div`,{className:`flex justify-end py-2`,children:(0,q.jsxs)(`div`,{className:`flex max-w-[85%] sm:max-w-[80%] flex-col items-end gap-1.5`,children:[e.attachments.length>0?(0,q.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:e.attachments.map(e=>(0,q.jsxs)(`div`,{className:`max-w-[220px] rounded-xl border border-dashed border-border bg-transparent px-3 py-2 text-left`,children:[(0,q.jsx)(`div`,{className:`truncate text-13 font-medium text-foreground`,children:e.displayName}),(0,q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.mimeType})]},e.id))}):null,e.content?(0,q.jsxs)(`div`,{className:`relative group`,children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-[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,q.jsx)(`div`,{children:Ae(e.content)}),(0,q.jsx)(a,{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`,onClick:n,children:(0,q.jsx)(wt,{className:`size-3.5`})})]}),(0,q.jsx)(a,{type:`button`,variant:`none`,size:`none`,className:`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%]`,onClick:t,children:(0,q.jsx)(ri,{className:`size-3`})})]}):null]})})}var gL={connecting:`Connecting...`,acquiring_sandbox:`Booting...`,initializing:`Initializing...`,starting:`Starting...`,running:`Running...`,waiting_for_user:`Waiting...`,failed:`Failed`};function _L({status:e}){let t=(e?gL[e]:void 0)||`Processing...`;return(0,q.jsx)(Je,{className:`ml-[1px]`,children:(0,q.jsxs)($e,{children:[e===`failed`?(0,q.jsx)(ri,{className:`size-4.5 text-destructive`}):(0,q.jsx)(Or,{className:`size-4.5 animate-spin text-muted-icon`}),(0,q.jsx)(Mt,{className:`ml-[1px] text-sm`,shimmerWidth:44,children:t})]})})}function vL({jobs:e,chatId:t}){return e.length===0?null:(0,q.jsx)(`div`,{className:`w-full`,children:(0,q.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,q.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,q.jsx)(Er,{className:`h-4 w-4 text-muted-foreground`}),`Cron jobs`,(0,q.jsxs)(`span`,{className:`ml-auto text-xs font-normal text-muted-foreground tabular-nums`,children:[e.length,` armed`]})]}),(0,q.jsx)(`div`,{children:e.map((n,r)=>(0,q.jsx)(Yr,{job:n,chatId:t,divider:r<e.length-1},n.jobId))})]})})}var yL={user_prompt:`user`,assistant_text:`assistant`,assistant_thinking:`assistant`,compact_summary:`assistant`,tool:`tool`,system_init:`chrome`,account_info:`chrome`,result:`chrome`,status:`chrome`,compact_boundary:`chrome`,context_cleared:`chrome`,interrupted:`chrome`,memory_loaded:`chrome`,context_window_updated:`chrome`,api_error:`card`,policy_refusal:`card`,pending_tool_request:`card`,auto_continue_prompt:`card`,unknown:`card`,loop_disarmed:`card`,cron_armed:`card`,cron_command_error:`card`,cron_run:`card`,cron_list:`card`,cron_run_skipped:`chrome`,cron_job_change:`chrome`};function bL(e){return e.kind===`tool-group`?`tool`:yL[e.message.kind]??`card`}function xL(e,t){return e===null?0:e===`chrome`||t===`chrome`?8:e===`tool`&&t===`tool`?0:e===`assistant`&&t===`tool`||e===`tool`&&t===`assistant`||e===`user`&&t===`user`?4:e===`assistant`&&t===`assistant`?12:32}function SL(e){return e===32}function CL(e,t){return xL(e?bL(e):null,bL(t))}var wL={0:`pt-0`,4:`pt-1`,8:`pt-2`,12:`pt-3`,16:`pt-4`,24:`pt-6`,32:`pt-8`},TL=`relative before:absolute before:inset-x-0 before:top-4 before:h-px before:bg-border before:content-['']`;function EL(e){let t=new Map,n=null;for(let r of e){let e=CL(n,r),i=wL[e];t.set(r.id,SL(e)?`${i} ${TL}`:i),n=r}return t}function DL(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 OL({error:e,runId:t,onRetry:n,onOpenSettings:r}){let i=e.code===`TIMEOUT`||e.code===`PROVIDER_ERROR`,a=e.code===`AUTH_REQUIRED`;return(0,q.jsxs)(`div`,{"data-testid":`subagent-error:${t}`,className:`rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-destructive`,children:[(0,q.jsx)(ut,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:DL(e.code)})]}),(0,q.jsx)(`p`,{className:`mt-1 text-foreground`,children:e.message}),(0,q.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[a&&r&&(0,q.jsxs)(`button`,{type:`button`,onClick:r,className:`inline-flex items-center gap-1 text-xs underline`,children:[(0,q.jsx)(xr,{className:`h-3 w-3`}),` Open settings`]}),i&&n&&(0,q.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1 text-xs underline`,children:[(0,q.jsx)(ya,{className:`h-3 w-3`}),` Retry`]})]})]})}function kL({pendingTool:e,onAskUserQuestionSubmit:t,onExitPlanModeSubmit:n}){if(e.toolKind===`ask_user_question`){let n=e.input.questions,r=Array.isArray(n)?n.filter(e=>De(e)):[],i={id:e.toolUseId,kind:`tool`,toolKind:`ask_user_question`,toolName:`AskUserQuestion`,toolId:e.toolUseId,input:{questions:r},timestamp:new Date(e.requestedAt).toISOString()};return(0,q.jsxs)(`div`,{"data-testid":`subagent-pending-tool:${e.toolUseId}`,children:[(0,q.jsx)(`div`,{className:`text-xs tracking-wide text-muted-foreground mb-1`,children:`awaiting your response`}),(0,q.jsx)(LF,{message:i,onSubmit:t,isLatest:!0})]})}if(e.toolKind===`exit_plan_mode`){let t=e.input,r={id:e.toolUseId,kind:`tool`,toolKind:`exit_plan_mode`,toolName:`ExitPlanMode`,toolId:e.toolUseId,input:{plan:typeof t.plan==`string`?t.plan:void 0,summary:typeof t.summary==`string`?t.summary:void 0},timestamp:new Date(e.requestedAt).toISOString()};return(0,q.jsxs)(`div`,{"data-testid":`subagent-pending-tool:${e.toolUseId}`,children:[(0,q.jsx)(`div`,{className:`text-xs tracking-wide text-muted-foreground mb-1`,children:`awaiting your response`}),(0,q.jsx)(VF,{message:r,onConfirm:(e,t,r,i)=>n(e,{confirmed:t,clearContext:r,message:i}),isLatest:!0})]})}return null}var AL=40;function jL(e){return wi(e,AL)}function ML(e,t){switch(e.toolKind){case`bash`:{let t=e.input.description||(e.input.command?Ei(e.input.command):``);return t?`$ ${jL(t)}`:`running bash...`}case`read_file`:{let n=He(e.input.filePath,t);return n?`reading ${jL(n)}`:`reading file...`}case`write_file`:{let n=He(e.input.filePath,t);return n?`writing ${jL(n)}`:`writing file...`}case`edit_file`:{let n=He(e.input.filePath,t);return n?`editing ${jL(n)}`:`editing file...`}case`delete_file`:{let n=He(e.input.filePath,t);return n?`deleting ${jL(n)}`:`deleting file...`}case`glob`:return e.input.pattern?`globbing ${jL(e.input.pattern)}`:`globbing...`;case`grep`:return e.input.pattern?`grepping ${jL(e.input.pattern)}`:`grepping...`;case`web_search`:return e.input.query?`searching: ${jL(e.input.query)}`:`searching web...`;case`skill`:return e.input.skill?`skill ${jL(e.input.skill)}`:`running skill...`;case`todo_write`:return`updating todos...`;case`subagent_task`:return e.input.subagentType?`delegating ${jL(e.input.subagentType)}`:`delegating...`;case`ask_user_question`:return`asking...`;case`exit_plan_mode`:return`presenting plan...`;case`offer_download`:return`preparing download...`;case`image_generation`:return`generating image...`;case`mcp_generic`:return jL(`${e.input.server}.${e.input.tool}`);case`unknown_tool`:return`running ${jL(e.toolName)}`;default:return`running...`}}function NL(e,t){if(e.pendingTool)return`waiting for input...`;let n=e.entries,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 ML(i.tool,t)}return n[n.length-1]?.kind===`assistant_text`?`streaming...`:`running...`}function PL({run:e,indentDepth:t,localPath:n,onOpenSettings:r,onRetry:i,onSubagentAskUserQuestionSubmit:a,onSubagentExitPlanModeSubmit:o,onCancelSubagentRun:s,suppressPendingTool:c=!1}){let l=Lr(e.entries),d=l.some(e=>e.kind===`assistant_text`),f=e.status===`running`&&d,p=e.status===`running`?NL(e,n):``;return(0,q.jsxs)(`div`,{"data-testid":`subagent-message:${e.runId}`,className:u(`border-l-2 border-accent pl-3 py-2 space-y-2`),style:{marginLeft:`${t*24}px`},[_]:``,children:[(0,q.jsxs)(`header`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,q.jsx)(Sr,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:e.subagentName}),(0,q.jsxs)(`span`,{className:`opacity-60`,children:[e.provider,e.model?`/${e.model}`:``]}),e.usage?.outputTokens!=null&&(0,q.jsxs)(`span`,{className:`opacity-60`,children:[`· `,e.usage.inputTokens??0,`↑ `,e.usage.outputTokens,`↓`]}),e.status===`running`&&(0,q.jsx)(`span`,{"data-testid":`subagent-activity:${e.runId}`,className:`ml-auto inline-block animate-pulse`,children:p}),s&&e.status===`running`&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`subagent-cancel:${e.runId}`,"aria-label":`Cancel subagent`,onClick:()=>s(e.chatId,e.runId),className:`text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(ri,{className:`h-3.5 w-3.5`})})]}),l.map(t=>(0,q.jsx)(Tt,{message:t,localPath:n,isRunning:e.status===`running`},t.id)),!c&&e.pendingTool&&(0,q.jsx)(kL,{pendingTool:e.pendingTool,onAskUserQuestionSubmit:(t,n,r)=>a?.(e.runId,t,n,r),onExitPlanModeSubmit:(t,n)=>o?.(e.runId,t,n)}),l.length===0&&e.finalText&&(0,q.jsxs)(`div`,{className:u(`whitespace-pre-wrap text-sm`,f&&`text-foreground/80`),children:[e.finalText,f&&(0,q.jsx)(`span`,{className:`ml-0.5 inline-block w-2 animate-pulse`,children:`▍`})]}),e.status===`failed`&&e.error&&(0,q.jsx)(`div`,{children:(0,q.jsx)(OL,{error:e.error,runId:e.runId,subagentId:e.subagentId,onOpenSettings:r,onRetry:i})})]})}var FL=3e4;function IL({record:e,onAccept:t,onStop:n,onRetry:r,onDismiss:i,ports:a={}}){let o=a.timer??fi,s=a.clipboard??Ar,c=(0,K.useRef)(null),l=(0,K.useRef)(e.state);(0,K.useEffect)(()=>{e.state!==l.current&&c.current&&(c.current(),c.current=null),l.current=e.state},[e.state]);let u=()=>new Promise(e=>{c.current=e,o.setTimeout(()=>{c.current===e&&(c.current=null,e())},FL)});if(e.state===`proposed`)return(0,q.jsx)(St,{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 u()}},{id:`dismiss`,label:`Dismiss`,variant:`ghost`,onClick:()=>i(e.tunnelId)}]});if(e.state===`active`){let t=e.url??``;return(0,q.jsx)(St,{title:`Tunnel live on port ${e.port}`,tone:`success`,body:(0,q.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`font-mono break-all underline-offset-4 hover:underline`,children:t}),actions:[{id:`copy`,label:`Copy URL`,variant:`secondary`,onClick:async()=>{t&&await s.writeText(t)}},{id:`stop`,label:`Stop tunnel`,variant:`ghost`,onClick:async()=>{await n(e.tunnelId),await u()}}]})}return e.state===`stopped`?(0,q.jsx)(St,{title:`Tunnel stopped (port ${e.port})`,tone:`muted`}):(0,q.jsx)(St,{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 u()}},{id:`dismiss`,label:`Dismiss`,variant:`ghost`,onClick:()=>i(e.tunnelId)}]})}var LL={done:{Icon:Dr,iconClass:`text-success-text`,textClass:`text-muted-foreground`},running:{Icon:Or,iconClass:`text-foreground animate-spin`,textClass:`text-foreground font-medium`},pending:{Icon:Zi,iconClass:`text-muted-foreground`,textClass:`text-muted-foreground`},failed:{Icon:ut,iconClass:`text-destructive`,textClass:`text-muted-foreground line-through decoration-destructive/40`}};function RL({loopProgress:e,onResume:t}){let{armed:n,rows:r,rateLimit:i}=e;return!n&&r.length===0&&!i?null:(0,q.jsx)(`div`,{className:`w-full`,children:(0,q.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,q.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,q.jsx)(fa,{className:`h-4 w-4 text-muted-foreground`}),`Progress`,n?(0,q.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1.5 text-xs font-normal text-muted-foreground`,children:[(0,q.jsx)(Bi,{tone:`active`,className:`text-foreground`}),`Loop running`]}):null]}),i?(0,q.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 bg-amber-500/[0.06] border-b border-border`,children:[(0,q.jsx)(ea,{className:`h-4 w-4 flex-shrink-0 text-amber-500 dark:text-amber-400`}),(0,q.jsxs)(`span`,{className:`text-sm text-foreground`,children:[i.scheduled?`Resumes`:`Usage limit — resets`,` `,wI(i.resetAt,i.tz)]}),!i.scheduled&&t?(0,q.jsx)(a,{variant:`secondary`,size:`sm`,className:`ml-auto`,onClick:()=>t(i.scheduleId,Date.now()),children:`Resume now`}):null]}):null,r.length===0?(0,q.jsx)(`div`,{className:`px-4 py-3 text-sm text-muted-foreground bg-background`,children:`Waiting for the first chunk…`}):(0,q.jsx)(`div`,{children:r.map((e,t)=>{let n=t===r.length-1,{Icon:i,iconClass:a,textClass:o}=LL[e.status];return(0,q.jsxs)(`div`,{className:u(`flex items-center gap-3 px-4 py-2.5 bg-background`,!n&&`border-b border-border`),children:[(0,q.jsx)(i,{className:u(`h-4 w-4 flex-shrink-0`,a)}),(0,q.jsx)(`span`,{className:u(`text-sm truncate`,o),children:e.label})]},e.runId)})})]})})}var zL=ci(`BackgroundTasksSection`,()=>e=>({expandedTaskId:null,output:null,setExpandedTaskId:t=>e({expandedTaskId:t}),setOutput:t=>e({output:t})}));function BL(e){return e?e.includes(`bash`)||e.includes(`shell`)?Ea:e.includes(`agent`)||e.includes(`task`)||e.includes(`teammate`)?Sr:e.includes(`workflow`)?Ir:Zi:Zi}function VL({chatId:e,tasks:t}){let n=qr(1e3),r=wr(),i=zL.useScopedStore(e=>e.expandedTaskId),a=zL.useScopedStore(e=>e.output),o=zL.useScopedStore(e=>e.setExpandedTaskId),s=zL.useScopedStore(e=>e.setOutput),c=(0,K.useCallback)(e=>{s({taskId:e.taskId,content:e.content,truncated:e.truncated})},[s]);return(0,K.useEffect)(()=>{if(!(!i||!r))return r.subscribe({type:`background-task-output`,chatId:e,taskId:i},c)},[i,e,r,c]),(0,q.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,q.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,q.jsx)(kt,{className:`h-4 w-4 text-muted-foreground`}),`Background tasks`,(0,q.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1.5 text-xs font-normal text-muted-foreground`,children:[(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-warning`}),t.length,` running`]})]}),(0,q.jsx)(`div`,{children:t.map((e,r)=>{let s=BL(e.taskType),c=r===t.length-1,l=i===e.id,d=a?.taskId===e.id?a:null;return(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:u(`flex items-center gap-3 px-4 py-2.5 bg-background`,(!c||l)&&`border-b border-border`),children:[(0,q.jsx)(s,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`text-sm text-foreground truncate`,children:e.description??`Background task`}),(0,q.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 flex-shrink-0`,children:[(0,q.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.id}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:Ai(Math.max(0,n-e.startedAt))}),e.hasOutput&&(0,q.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,q.jsx)(Cr,{className:`h-4 w-4`}):(0,q.jsx)(or,{className:`h-4 w-4`})})]})]}),l&&(0,q.jsxs)(`div`,{className:u(`bg-card`,!c&&`border-b border-border`),children:[d?.truncated&&(0,q.jsx)(`p`,{className:`px-4 pt-2 text-xs text-muted-foreground`,children:`Earlier output was truncated.`}),(0,q.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:d?.content||`Waiting for output…`})]})]},e.id)})})]})}function HL({chatId:e,tasks:t}){return t.length===0?null:(0,q.jsx)(`div`,{className:`w-full`,children:(0,q.jsx)(zL.Provider,{init:void 0,children:(0,q.jsx)(VL,{chatId:e,tasks:t})})})}var UL=t((e=>{var t=n(),i=r();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}var o=Symbol.for(`react.transitional.element`),s=Symbol.for(`react.portal`),c=Symbol.for(`react.fragment`),l=Symbol.for(`react.strict_mode`),u=Symbol.for(`react.profiler`),d=Symbol.for(`react.consumer`),f=Symbol.for(`react.context`),p=Symbol.for(`react.forward_ref`),m=Symbol.for(`react.suspense`),h=Symbol.for(`react.suspense_list`),g=Symbol.for(`react.memo`),_=Symbol.for(`react.lazy`),v=Symbol.for(`react.scope`),y=Symbol.for(`react.activity`),b=Symbol.for(`react.legacy_hidden`),x=Symbol.for(`react.memo_cache_sentinel`),S=Symbol.for(`react.view_transition`),C=Symbol.iterator;function w(e){return typeof e!=`object`||!e?null:(e=C&&e[C]||e[`@@iterator`],typeof e==`function`?e:null)}var T=Array.isArray;function E(e,t){var n=e.length&3,r=e.length-n,i=t;for(t=0;t<r;){var a=e.charCodeAt(t)&255|(e.charCodeAt(++t)&255)<<8|(e.charCodeAt(++t)&255)<<16|(e.charCodeAt(++t)&255)<<24;++t,a=3432918353*(a&65535)+((3432918353*(a>>>16)&65535)<<16)&4294967295,a=a<<15|a>>>17,a=461845907*(a&65535)+((461845907*(a>>>16)&65535)<<16)&4294967295,i^=a,i=i<<13|i>>>19,i=5*(i&65535)+((5*(i>>>16)&65535)<<16)&4294967295,i=(i&65535)+27492+(((i>>>16)+58964&65535)<<16)}switch(a=0,n){case 3:a^=(e.charCodeAt(t+2)&255)<<16;case 2:a^=(e.charCodeAt(t+1)&255)<<8;case 1:a^=e.charCodeAt(t)&255,a=3432918353*(a&65535)+((3432918353*(a>>>16)&65535)<<16)&4294967295,a=a<<15|a>>>17,i^=461845907*(a&65535)+((461845907*(a>>>16)&65535)<<16)&4294967295}return i^=e.length,i^=i>>>16,i=2246822507*(i&65535)+((2246822507*(i>>>16)&65535)<<16)&4294967295,i^=i>>>13,i=3266489909*(i&65535)+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^i>>>16)>>>0}var D=Object.assign,O=Object.prototype.hasOwnProperty,k=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),A={},j={};function M(e){return O.call(j,e)?!0:O.call(A,e)?!1:k.test(e)?j[e]=!0:(A[e]=!0,!1)}var N=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `)),P=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),F=/["'&<>]/;function I(e){if(typeof e==`boolean`||typeof e==`number`||typeof e==`bigint`)return``+e;e=``+e;var t=F.exec(e);if(t){var n=``,r,i=0;for(r=t.index;r<e.length;r++){switch(e.charCodeAt(r)){case 34:t=`&quot;`;break;case 38:t=`&amp;`;break;case 39:t=`&#x27;`;break;case 60:t=`&lt;`;break;case 62:t=`&gt;`;break;default:continue}i!==r&&(n+=e.slice(i,r)),i=r+1,n+=t}e=i===r?n:n+e.slice(i,r)}return e}var L=/([A-Z])/g,ee=/^ms-/,R=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function z(e){return R.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}var te=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},V=ne.d;ne.d={f:V.f,r:V.r,D:st,C:ct,L:lt,m:ut,X:ft,S:dt,M:G};var re=[],ie=null,ae=/(<\/|<)(s)(cript)/gi;function oe(e,t,n,r){return``+t+(n===`s`?`\\u0073`:`\\u0053`)+r}function se(e,t,n,r,i){return{idPrefix:e===void 0?``:e,nextFormID:0,streamingFormat:0,bootstrapScriptContent:n,bootstrapScripts:r,bootstrapModules:i,instructions:0,hasBody:!1,hasHtml:!1,unknownResources:{},dnsResources:{},connectResources:{default:{},anonymous:{},credentials:{}},imageResources:{},styleResources:{},scriptResources:{},moduleUnknownResources:{},moduleScriptResources:{}}}function ce(e,t,n,r){return{insertionMode:e,selectedValue:t,tagScope:n,viewTransition:r}}function le(e,t,n){var r=e.tagScope&-25;switch(t){case`noscript`:return ce(2,null,r|1,null);case`select`:return ce(2,n.value==null?n.defaultValue:n.value,r,null);case`svg`:return ce(4,null,r,null);case`picture`:return ce(2,null,r|2,null);case`math`:return ce(5,null,r,null);case`foreignObject`:return ce(2,null,r,null);case`table`:return ce(6,null,r,null);case`thead`:case`tbody`:case`tfoot`:return ce(7,null,r,null);case`colgroup`:return ce(9,null,r,null);case`tr`:return ce(8,null,r,null);case`head`:if(2>e.insertionMode)return ce(3,null,r,null);break;case`html`:if(e.insertionMode===0)return ce(1,null,r,null)}return 6<=e.insertionMode||2>e.insertionMode?ce(2,null,r,null):e.tagScope===r?e:ce(e.insertionMode,e.selectedValue,r,null)}function H(e){return e===null?null:{update:e.update,enter:`none`,exit:`none`,share:e.update,name:e.autoName,autoName:e.autoName,nameIdx:0}}function ue(e,t){return t.tagScope&32&&(e.instructions|=128),ce(t.insertionMode,t.selectedValue,t.tagScope|12,H(t.viewTransition))}function de(e,t){e=H(t.viewTransition);var n=t.tagScope|16;return e!==null&&e.share!==`none`&&(n|=64),ce(t.insertionMode,t.selectedValue,n,e)}var fe=new Map;function pe(e,t){if(typeof t!=`object`)throw Error(a(62));var n=!0,r;for(r in t)if(O.call(t,r)){var i=t[r];if(i!=null&&typeof i!=`boolean`&&i!==``){if(r.indexOf(`--`)===0){var o=I(r);i=I((``+i).trim())}else o=fe.get(r),o===void 0&&(o=I(r.replace(L,`-$1`).toLowerCase().replace(ee,`-ms-`)),fe.set(r,o)),i=typeof i==`number`?i===0||N.has(r)?``+i:i+`px`:I((``+i).trim());n?(n=!1,e.push(` style="`,o,`:`,i)):e.push(`;`,o,`:`,i)}}n||e.push(`"`)}function me(e,t,n){n&&typeof n!=`function`&&typeof n!=`symbol`&&e.push(` `,t,`=""`)}function he(e,t,n){typeof n!=`function`&&typeof n!=`symbol`&&typeof n!=`boolean`&&e.push(` `,t,`="`,I(n),`"`)}var ge=I(`javascript:throw new Error('React form unexpectedly submitted.')`);function _e(e,t){this.push(`<input type="hidden"`),ve(e),he(this,`name`,t),he(this,`value`,e),this.push(`/>`)}function ve(e){if(typeof e!=`string`)throw Error(a(480))}function ye(e,t){if(typeof t.$$FORM_ACTION==`function`){var n=e.nextFormID++;e=e.idPrefix+n;try{var r=t.$$FORM_ACTION(e);return r&&r.data?.forEach(ve),r}catch(e){if(typeof e==`object`&&e&&typeof e.then==`function`)throw e}}return null}function be(e,t,n,r,i,a,o,s){var c=null;if(typeof r==`function`){var l=ye(t,r);l===null?(e.push(` `,`formAction`,`="`,ge,`"`),o=a=i=r=s=null,Ce(t,n)):(s=l.name,r=l.action||``,i=l.encType,a=l.method,o=l.target,c=l.data)}return s!=null&&xe(e,`name`,s),r!=null&&xe(e,`formAction`,r),i!=null&&xe(e,`formEncType`,i),a!=null&&xe(e,`formMethod`,a),o!=null&&xe(e,`formTarget`,o),c}function xe(e,t,n){switch(t){case`className`:he(e,`class`,n);break;case`tabIndex`:he(e,`tabindex`,n);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:he(e,t,n);break;case`style`:pe(e,n);break;case`src`:case`href`:if(n===``)break;case`action`:case`formAction`:if(n==null||typeof n==`function`||typeof n==`symbol`||typeof n==`boolean`)break;n=z(``+n),e.push(` `,t,`="`,I(n),`"`);break;case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`ref`:break;case`autoFocus`:case`multiple`:case`muted`:me(e,t.toLowerCase(),n);break;case`xlinkHref`:if(typeof n==`function`||typeof n==`symbol`||typeof n==`boolean`)break;n=z(``+n),e.push(` `,`xlink:href`,`="`,I(n),`"`);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:typeof n!=`function`&&typeof n!=`symbol`&&e.push(` `,t,`="`,I(n),`"`);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:n&&typeof n!=`function`&&typeof n!=`symbol`&&e.push(` `,t,`=""`);break;case`capture`:case`download`:!0===n?e.push(` `,t,`=""`):!1!==n&&typeof n!=`function`&&typeof n!=`symbol`&&e.push(` `,t,`="`,I(n),`"`);break;case`cols`:case`rows`:case`size`:case`span`:typeof n!=`function`&&typeof n!=`symbol`&&!isNaN(n)&&1<=n&&e.push(` `,t,`="`,I(n),`"`);break;case`rowSpan`:case`start`:typeof n==`function`||typeof n==`symbol`||isNaN(n)||e.push(` `,t,`="`,I(n),`"`);break;case`xlinkActuate`:he(e,`xlink:actuate`,n);break;case`xlinkArcrole`:he(e,`xlink:arcrole`,n);break;case`xlinkRole`:he(e,`xlink:role`,n);break;case`xlinkShow`:he(e,`xlink:show`,n);break;case`xlinkTitle`:he(e,`xlink:title`,n);break;case`xlinkType`:he(e,`xlink:type`,n);break;case`xmlBase`:he(e,`xml:base`,n);break;case`xmlLang`:he(e,`xml:lang`,n);break;case`xmlSpace`:he(e,`xml:space`,n);break;default:if((!(2<t.length)||t[0]!==`o`&&t[0]!==`O`||t[1]!==`n`&&t[1]!==`N`)&&(t=P.get(t)||t,M(t))){switch(typeof n){case`function`:case`symbol`:return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`)return}e.push(` `,t,`="`,I(n),`"`)}}}function U(e,t,n){if(t!=null){if(n!=null)throw Error(a(60));if(typeof t!=`object`||!(`__html`in t))throw Error(a(61));t=t.__html,t!=null&&e.push(``+t)}}function Se(e){var n=``;return t.Children.forEach(e,function(e){e!=null&&(n+=e)}),n}function Ce(e,t){if(!(e.instructions&16)){e.instructions|=16;var n=t.preamble,r=t.bootstrapChunks;(n.htmlChunks||n.headChunks)&&r.length===0?(r.push(t.startInlineScript),rt(r,e),r.push(`>`,`addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error('React form unexpectedly submitted.')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.ownerDocument||c,(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,d,b))}});`,`<\/script>`)):r.unshift(t.startInlineScript,`>`,`addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error('React form unexpectedly submitted.')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.ownerDocument||c,(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,d,b))}});`,`<\/script>`)}}function we(e,t){for(var n in e.push(Pe(`link`)),t)if(O.call(t,n)){var r=t[n];if(r!=null)switch(n){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(399,`link`));default:xe(e,n,r)}}return e.push(`/>`),null}var Te=/(<\/|<)(s)(tyle)/gi;function Ee(e,t,n,r){return``+t+(n===`s`?`\\73 `:`\\53 `)+r}function De(e,t,n){for(var r in e.push(Pe(n)),t)if(O.call(t,r)){var i=t[r];if(i!=null)switch(r){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(399,n));default:xe(e,r,i)}}return e.push(`/>`),null}function Oe(e,t){e.push(Pe(`title`));var n=null,r=null,i;for(i in t)if(O.call(t,i)){var a=t[i];if(a!=null)switch(i){case`children`:n=a;break;case`dangerouslySetInnerHTML`:r=a;break;default:xe(e,i,a)}}return e.push(`>`),t=Array.isArray(n)?2>n.length?n[0]:null:n,typeof t!=`function`&&typeof t!=`symbol`&&t!=null&&e.push(I(``+t)),U(e,r,n),e.push(Le(`title`)),null}function ke(e,t){e.push(Pe(`script`));var n=null,r=null,i;for(i in t)if(O.call(t,i)){var a=t[i];if(a!=null)switch(i){case`children`:n=a;break;case`dangerouslySetInnerHTML`:r=a;break;default:xe(e,i,a)}}return e.push(`>`),U(e,r,n),typeof n==`string`&&e.push((``+n).replace(ae,oe)),e.push(Le(`script`)),null}function Ae(e,t,n){e.push(Pe(n));var r=n=null,i;for(i in t)if(O.call(t,i)){var a=t[i];if(a!=null)switch(i){case`children`:n=a;break;case`dangerouslySetInnerHTML`:r=a;break;default:xe(e,i,a)}}return e.push(`>`),U(e,r,n),n}function je(e,t,n){e.push(Pe(n));var r=n=null,i;for(i in t)if(O.call(t,i)){var a=t[i];if(a!=null)switch(i){case`children`:n=a;break;case`dangerouslySetInnerHTML`:r=a;break;default:xe(e,i,a)}}return e.push(`>`),U(e,r,n),typeof n==`string`?(e.push(I(n)),null):n}var Me=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Ne=new Map;function Pe(e){var t=Ne.get(e);if(t===void 0){if(!Me.test(e))throw Error(a(65,e));t=`<`+e,Ne.set(e,t)}return t}function Fe(e,t,n,r,i,o,s,c,l){switch(t){case`div`:case`span`:case`svg`:case`path`:break;case`a`:e.push(Pe(`a`));var u=null,d=null,f;for(f in n)if(O.call(n,f)){var p=n[f];if(p!=null)switch(f){case`children`:u=p;break;case`dangerouslySetInnerHTML`:d=p;break;case`href`:p===``?he(e,`href`,``):xe(e,f,p);break;default:xe(e,f,p)}}if(e.push(`>`),U(e,d,u),typeof u==`string`){e.push(I(u));var m=null}else m=u;return m;case`g`:case`p`:case`li`:break;case`select`:e.push(Pe(`select`));var h=null,g=null,_;for(_ in n)if(O.call(n,_)){var v=n[_];if(v!=null)switch(_){case`children`:h=v;break;case`dangerouslySetInnerHTML`:g=v;break;case`defaultValue`:case`value`:break;default:xe(e,_,v)}}return e.push(`>`),U(e,g,h),h;case`option`:var y=c.selectedValue;e.push(Pe(`option`));var b=null,x=null,S=null,C=null,w;for(w in n)if(O.call(n,w)){var E=n[w];if(E!=null)switch(w){case`children`:b=E;break;case`selected`:S=E;break;case`dangerouslySetInnerHTML`:C=E;break;case`value`:x=E;default:xe(e,w,E)}}if(y!=null){var k=x===null?Se(b):``+x;if(T(y)){for(var A=0;A<y.length;A++)if(``+y[A]===k){e.push(` selected=""`);break}}else``+y===k&&e.push(` selected=""`)}else S&&e.push(` selected=""`);return e.push(`>`),U(e,C,b),b;case`textarea`:e.push(Pe(`textarea`));var j=null,N=null,P=null,F;for(F in n)if(O.call(n,F)){var L=n[F];if(L!=null)switch(F){case`children`:P=L;break;case`value`:j=L;break;case`defaultValue`:N=L;break;case`dangerouslySetInnerHTML`:throw Error(a(91));default:xe(e,F,L)}}if(j===null&&N!==null&&(j=N),e.push(`>`),P!=null){if(j!=null)throw Error(a(92));if(T(P)){if(1<P.length)throw Error(a(93));j=``+P[0]}j=``+P}return typeof j==`string`&&j[0]===`
29
+ `&&e.push(`
30
+ `),j!==null&&e.push(I(``+j)),null;case`input`:e.push(Pe(`input`));var ee=null,R=null,te=null,ne=null,B=null,V=null,ie=null,ae=null,oe=null,se;for(se in n)if(O.call(n,se)){var ce=n[se];if(ce!=null)switch(se){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(399,`input`));case`name`:ee=ce;break;case`formAction`:R=ce;break;case`formEncType`:te=ce;break;case`formMethod`:ne=ce;break;case`formTarget`:B=ce;break;case`defaultChecked`:oe=ce;break;case`defaultValue`:ie=ce;break;case`checked`:ae=ce;break;case`value`:V=ce;break;default:xe(e,se,ce)}}var le=be(e,r,i,R,te,ne,B,ee);return ae===null?oe!==null&&me(e,`checked`,oe):me(e,`checked`,ae),V===null?ie!==null&&xe(e,`value`,ie):xe(e,`value`,V),e.push(`/>`),le?.forEach(_e,e),null;case`button`:e.push(Pe(`button`));var H=null,ue=null,de=null,fe=null,ve=null,Me=null,Ne=null,Fe;for(Fe in n)if(O.call(n,Fe)){var Ie=n[Fe];if(Ie!=null)switch(Fe){case`children`:H=Ie;break;case`dangerouslySetInnerHTML`:ue=Ie;break;case`name`:de=Ie;break;case`formAction`:fe=Ie;break;case`formEncType`:ve=Ie;break;case`formMethod`:Me=Ie;break;case`formTarget`:Ne=Ie;break;default:xe(e,Fe,Ie)}}var Re=be(e,r,i,fe,ve,Me,Ne,de);if(e.push(`>`),Re?.forEach(_e,e),U(e,ue,H),typeof H==`string`){e.push(I(H));var ze=null}else ze=H;return ze;case`form`:e.push(Pe(`form`));var Be=null,Ve=null,He=null,Ue=null,We=null,Ge=null,Ke;for(Ke in n)if(O.call(n,Ke)){var qe=n[Ke];if(qe!=null)switch(Ke){case`children`:Be=qe;break;case`dangerouslySetInnerHTML`:Ve=qe;break;case`action`:He=qe;break;case`encType`:Ue=qe;break;case`method`:We=qe;break;case`target`:Ge=qe;break;default:xe(e,Ke,qe)}}var Je=null,Ye=null;if(typeof He==`function`){var Xe=ye(r,He);Xe===null?(e.push(` `,`action`,`="`,ge,`"`),Ge=We=Ue=He=null,Ce(r,i)):(He=Xe.action||``,Ue=Xe.encType,We=Xe.method,Ge=Xe.target,Je=Xe.data,Ye=Xe.name)}if(He!=null&&xe(e,`action`,He),Ue!=null&&xe(e,`encType`,Ue),We!=null&&xe(e,`method`,We),Ge!=null&&xe(e,`target`,Ge),e.push(`>`),Ye!==null&&(e.push(`<input type="hidden"`),he(e,`name`,Ye),e.push(`/>`),Je?.forEach(_e,e)),U(e,Ve,Be),typeof Be==`string`){e.push(I(Be));var Ze=null}else Ze=Be;return Ze;case`menuitem`:for(var Qe in e.push(Pe(`menuitem`)),n)if(O.call(n,Qe)){var $e=n[Qe];if($e!=null)switch(Qe){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(400));default:xe(e,Qe,$e)}}return e.push(`>`),null;case`object`:e.push(Pe(`object`));var W=null,et=null,tt;for(tt in n)if(O.call(n,tt)){var nt=n[tt];if(nt!=null)switch(tt){case`children`:W=nt;break;case`dangerouslySetInnerHTML`:et=nt;break;case`data`:var rt=z(``+nt);if(rt===``)break;e.push(` `,`data`,`="`,I(rt),`"`);break;default:xe(e,tt,nt)}}if(e.push(`>`),U(e,et,W),typeof W==`string`){e.push(I(W));var it=null}else it=W;return it;case`title`:var at=c.tagScope&1,ot=c.tagScope&4;if(c.insertionMode===4||at||n.itemProp!=null)var st=Oe(e,n);else ot?st=null:(Oe(i.hoistableChunks,n),st=void 0);return st;case`link`:var ct=c.tagScope&1,lt=c.tagScope&4,ut=n.rel,dt=n.href,ft=n.precedence;if(c.insertionMode===4||ct||n.itemProp!=null||typeof ut!=`string`||typeof dt!=`string`||dt===``){we(e,n);var G=null}else if(n.rel===`stylesheet`){if(typeof ft!=`string`||n.disabled!=null||n.onLoad||n.onError)G=we(e,n);else{var ht=i.styles.get(ft),gt=r.styleResources.hasOwnProperty(dt)?r.styleResources[dt]:void 0;if(gt!==null){r.styleResources[dt]=null,ht||(ht={precedence:I(ft),rules:[],hrefs:[],sheets:new Map},i.styles.set(ft,ht));var _t={state:0,props:D({},n,{"data-precedence":n.precedence,precedence:null})};if(gt){gt.length===2&&pt(_t.props,gt);var vt=i.preloads.stylesheets.get(dt);vt&&0<vt.length?vt.length=0:_t.state=1}ht.sheets.set(dt,_t),s&&s.stylesheets.add(_t)}else if(ht){var yt=ht.sheets.get(dt);yt&&s&&s.stylesheets.add(yt)}l&&e.push(`<!-- -->`),G=null}}else n.onLoad||n.onError?G=we(e,n):(l&&e.push(`<!-- -->`),G=lt?null:we(i.hoistableChunks,n));return G;case`script`:var bt=c.tagScope&1,xt=n.async;if(typeof n.src!=`string`||!n.src||!xt||typeof xt==`function`||typeof xt==`symbol`||n.onLoad||n.onError||c.insertionMode===4||bt||n.itemProp!=null)var St=ke(e,n);else{var Ct=n.src;if(n.type===`module`)var wt=r.moduleScriptResources,Tt=i.preloads.moduleScripts;else wt=r.scriptResources,Tt=i.preloads.scripts;var Et=wt.hasOwnProperty(Ct)?wt[Ct]:void 0;if(Et!==null){wt[Ct]=null;var Dt=n;if(Et){Et.length===2&&(Dt=D({},n),pt(Dt,Et));var Ot=Tt.get(Ct);Ot&&(Ot.length=0)}var kt=[];i.scripts.add(kt),ke(kt,Dt)}l&&e.push(`<!-- -->`),St=null}return St;case`style`:var At=c.tagScope&1,jt=n.precedence,Mt=n.href,Nt=n.nonce;if(c.insertionMode===4||At||n.itemProp!=null||typeof jt!=`string`||typeof Mt!=`string`||Mt===``){e.push(Pe(`style`));var Pt=null,Ft=null,It;for(It in n)if(O.call(n,It)){var Lt=n[It];if(Lt!=null)switch(It){case`children`:Pt=Lt;break;case`dangerouslySetInnerHTML`:Ft=Lt;break;default:xe(e,It,Lt)}}e.push(`>`);var Rt=Array.isArray(Pt)?2>Pt.length?Pt[0]:null:Pt;typeof Rt!=`function`&&typeof Rt!=`symbol`&&Rt!=null&&e.push((``+Rt).replace(Te,Ee)),U(e,Ft,Pt),e.push(Le(`style`));var zt=null}else{var Bt=i.styles.get(jt);if((r.styleResources.hasOwnProperty(Mt)?r.styleResources[Mt]:void 0)!==null){r.styleResources[Mt]=null,Bt||(Bt={precedence:I(jt),rules:[],hrefs:[],sheets:new Map},i.styles.set(jt,Bt));var Vt=i.nonce.style;if(!Vt||Vt===Nt){Bt.hrefs.push(I(Mt));var Ht=Bt.rules,Ut=null,Wt=null,Gt;for(Gt in n)if(O.call(n,Gt)){var Kt=n[Gt];if(Kt!=null)switch(Gt){case`children`:Ut=Kt;break;case`dangerouslySetInnerHTML`:Wt=Kt}}var qt=Array.isArray(Ut)?2>Ut.length?Ut[0]:null:Ut;typeof qt!=`function`&&typeof qt!=`symbol`&&qt!=null&&Ht.push((``+qt).replace(Te,Ee)),U(Ht,Wt,Ut)}}Bt&&s&&s.styles.add(Bt),l&&e.push(`<!-- -->`),zt=void 0}return zt;case`meta`:var Jt=c.tagScope&1,Yt=c.tagScope&4;if(c.insertionMode===4||Jt||n.itemProp!=null)var Xt=De(e,n,`meta`);else l&&e.push(`<!-- -->`),Xt=Yt?null:typeof n.charSet==`string`?De(i.charsetChunks,n,`meta`):n.name===`viewport`?De(i.viewportChunks,n,`meta`):De(i.hoistableChunks,n,`meta`);return Xt;case`listing`:case`pre`:e.push(Pe(t));var Zt=null,Qt=null,$t;for($t in n)if(O.call(n,$t)){var en=n[$t];if(en!=null)switch($t){case`children`:Zt=en;break;case`dangerouslySetInnerHTML`:Qt=en;break;default:xe(e,$t,en)}}if(e.push(`>`),Qt!=null){if(Zt!=null)throw Error(a(60));if(typeof Qt!=`object`||!(`__html`in Qt))throw Error(a(61));var tn=Qt.__html;tn!=null&&(typeof tn==`string`&&0<tn.length&&tn[0]===`
31
+ `?e.push(`
32
+ `,tn):e.push(``+tn))}return typeof Zt==`string`&&Zt[0]===`
33
+ `&&e.push(`
34
+ `),Zt;case`img`:var nn=c.tagScope&3,rn=n.src,an=n.srcSet;if(!(n.loading===`lazy`||!rn&&!an||typeof rn!=`string`&&rn!=null||typeof an!=`string`&&an!=null||n.fetchPriority===`low`||nn)&&(typeof rn!=`string`||rn[4]!==`:`||rn[0]!==`d`&&rn[0]!==`D`||rn[1]!==`a`&&rn[1]!==`A`||rn[2]!==`t`&&rn[2]!==`T`||rn[3]!==`a`&&rn[3]!==`A`)&&(typeof an!=`string`||an[4]!==`:`||an[0]!==`d`&&an[0]!==`D`||an[1]!==`a`&&an[1]!==`A`||an[2]!==`t`&&an[2]!==`T`||an[3]!==`a`&&an[3]!==`A`)){s!==null&&c.tagScope&64&&(s.suspenseyImages=!0);var on=typeof n.sizes==`string`?n.sizes:void 0,sn=an?an+`
35
+ `+(on||``):rn,cn=i.preloads.images,ln=cn.get(sn);if(ln)(n.fetchPriority===`high`||10>i.highImagePreloads.size)&&(cn.delete(sn),i.highImagePreloads.add(ln));else if(!r.imageResources.hasOwnProperty(sn)){r.imageResources[sn]=re;var un=n.crossOrigin,dn=typeof un==`string`?un===`use-credentials`?un:``:void 0,fn=i.headers,pn;fn&&0<fn.remainingCapacity&&typeof n.srcSet!=`string`&&(n.fetchPriority===`high`||500>fn.highImagePreloads.length)&&(pn=mt(rn,`image`,{imageSrcSet:n.srcSet,imageSizes:n.sizes,crossOrigin:dn,integrity:n.integrity,nonce:n.nonce,type:n.type,fetchPriority:n.fetchPriority,referrerPolicy:n.refererPolicy}),0<=(fn.remainingCapacity-=pn.length+2))?(i.resets.image[sn]=re,fn.highImagePreloads&&(fn.highImagePreloads+=`, `),fn.highImagePreloads+=pn):(ln=[],we(ln,{rel:`preload`,as:`image`,href:an?void 0:rn,imageSrcSet:an,imageSizes:on,crossOrigin:dn,integrity:n.integrity,type:n.type,fetchPriority:n.fetchPriority,referrerPolicy:n.referrerPolicy}),n.fetchPriority===`high`||10>i.highImagePreloads.size?i.highImagePreloads.add(ln):(i.bulkPreloads.add(ln),cn.set(sn,ln)))}}return De(e,n,`img`);case`base`:case`area`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`param`:case`source`:case`track`:case`wbr`:return De(e,n,t);case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:break;case`head`:if(2>c.insertionMode){var mn=o||i.preamble;if(mn.headChunks)throw Error(a(545,"`<head>`"));o!==null&&e.push(`<!--head-->`),mn.headChunks=[];var hn=Ae(mn.headChunks,n,`head`)}else hn=je(e,n,`head`);return hn;case`body`:if(2>c.insertionMode){var gn=o||i.preamble;if(gn.bodyChunks)throw Error(a(545,"`<body>`"));o!==null&&e.push(`<!--body-->`),gn.bodyChunks=[];var _n=Ae(gn.bodyChunks,n,`body`)}else _n=je(e,n,`body`);return _n;case`html`:if(c.insertionMode===0){var vn=o||i.preamble;if(vn.htmlChunks)throw Error(a(545,"`<html>`"));o!==null&&e.push(`<!--html-->`),vn.htmlChunks=[``];var yn=Ae(vn.htmlChunks,n,`html`)}else yn=je(e,n,`html`);return yn;default:if(t.indexOf(`-`)!==-1){e.push(Pe(t));var bn=null,xn=null,Sn;for(Sn in n)if(O.call(n,Sn)){var Cn=n[Sn];if(Cn!=null){var wn=Sn;switch(Sn){case`children`:bn=Cn;break;case`dangerouslySetInnerHTML`:xn=Cn;break;case`style`:pe(e,Cn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`ref`:break;case`className`:wn=`class`;default:if(M(Sn)&&typeof Cn!=`function`&&typeof Cn!=`symbol`&&!1!==Cn){if(!0===Cn)Cn=``;else if(typeof Cn==`object`)continue;e.push(` `,wn,`="`,I(Cn),`"`)}}}}return e.push(`>`),U(e,xn,bn),bn}}return je(e,n,t)}var Ie=new Map;function Le(e){var t=Ie.get(e);return t===void 0&&(t=`</`+e+`>`,Ie.set(e,t)),t}function Re(e,t){e=e.preamble,e.htmlChunks===null&&t.htmlChunks&&(e.htmlChunks=t.htmlChunks),e.headChunks===null&&t.headChunks&&(e.headChunks=t.headChunks),e.bodyChunks===null&&t.bodyChunks&&(e.bodyChunks=t.bodyChunks)}function ze(e,t){t=t.bootstrapChunks;for(var n=0;n<t.length-1;n++)e.push(t[n]);return n<t.length?(n=t[n],t.length=0,e.push(n)):!0}function Be(e,t,n){if(e.push(`<!--$?--><template id="`),n===null)throw Error(a(395));return e.push(t.boundaryPrefix),t=n.toString(16),e.push(t),e.push(`"></template>`)}function Ve(e,t,n,r){switch(n.insertionMode){case 0:case 1:case 3:case 2:return e.push(`<div hidden id="`),e.push(t.segmentPrefix),t=r.toString(16),e.push(t),e.push(`">`);case 4:return e.push(`<svg aria-hidden="true" style="display:none" id="`),e.push(t.segmentPrefix),t=r.toString(16),e.push(t),e.push(`">`);case 5:return e.push(`<math aria-hidden="true" style="display:none" id="`),e.push(t.segmentPrefix),t=r.toString(16),e.push(t),e.push(`">`);case 6:return e.push(`<table hidden id="`),e.push(t.segmentPrefix),t=r.toString(16),e.push(t),e.push(`">`);case 7:return e.push(`<table hidden><tbody id="`),e.push(t.segmentPrefix),t=r.toString(16),e.push(t),e.push(`">`);case 8:return e.push(`<table hidden><tr id="`),e.push(t.segmentPrefix),t=r.toString(16),e.push(t),e.push(`">`);case 9:return e.push(`<table hidden><colgroup id="`),e.push(t.segmentPrefix),t=r.toString(16),e.push(t),e.push(`">`);default:throw Error(a(397))}}function He(e,t){switch(t.insertionMode){case 0:case 1:case 3:case 2:return e.push(`</div>`);case 4:return e.push(`</svg>`);case 5:return e.push(`</math>`);case 6:return e.push(`</table>`);case 7:return e.push(`</tbody></table>`);case 8:return e.push(`</tr></table>`);case 9:return e.push(`</colgroup></table>`);default:throw Error(a(397))}}var Ue=/[<\u2028\u2029]/g;function We(e){return JSON.stringify(e).replace(Ue,function(e){switch(e){case`<`:return`\\u003c`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:throw Error(`escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React`)}})}var Ge=/[&><\u2028\u2029]/g;function Ke(e){return JSON.stringify(e).replace(Ge,function(e){switch(e){case`&`:return`\\u0026`;case`>`:return`\\u003e`;case`<`:return`\\u003c`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:throw Error(`escapeJSObjectForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React`)}})}var qe=!1,Je=!0;function Ye(e){var t=e.rules,n=e.hrefs,r=0;if(n.length){for(this.push(ie.startInlineStyle),this.push(` media="not all" data-precedence="`),this.push(e.precedence),this.push(`" data-href="`);r<n.length-1;r++)this.push(n[r]),this.push(` `);for(this.push(n[r]),this.push(`">`),r=0;r<t.length;r++)this.push(t[r]);Je=this.push(`</style>`),qe=!0,t.length=0,n.length=0}}function Xe(e){return e.state===2?!1:qe=!0}function Ze(e,t,n){return qe=!1,Je=!0,ie=n,t.styles.forEach(Ye,e),ie=null,t.stylesheets.forEach(Xe),qe&&(n.stylesToHoist=!0),Je}function Qe(e){for(var t=0;t<e.length;t++)this.push(e[t]);e.length=0}var $e=[];function W(e){we($e,e.props);for(var t=0;t<$e.length;t++)this.push($e[t]);$e.length=0,e.state=2}function et(e){var t=0<e.sheets.size;e.sheets.forEach(W,this),e.sheets.clear();var n=e.rules,r=e.hrefs;if(!t||r.length){if(this.push(ie.startInlineStyle),this.push(` data-precedence="`),this.push(e.precedence),e=0,r.length){for(this.push(`" data-href="`);e<r.length-1;e++)this.push(r[e]),this.push(` `);this.push(r[e])}for(this.push(`">`),e=0;e<n.length;e++)this.push(n[e]);this.push(`</style>`),n.length=0,r.length=0}}function tt(e){if(e.state===0){e.state=1;var t=e.props;for(we($e,{rel:`preload`,as:`style`,href:e.props.href,crossOrigin:t.crossOrigin,fetchPriority:t.fetchPriority,integrity:t.integrity,media:t.media,hrefLang:t.hrefLang,referrerPolicy:t.referrerPolicy}),e=0;e<$e.length;e++)this.push($e[e]);$e.length=0}}function nt(e){e.sheets.forEach(tt,this),e.sheets.clear()}function rt(e,t){!(t.instructions&32)&&(t.instructions|=32,e.push(` id="`,I(`_`+t.idPrefix+`R_`),`"`))}function it(e,t){e.push(`[`);var n=`[`;t.stylesheets.forEach(function(t){if(t.state!==2){if(t.state===3)e.push(n),t=Ke(``+t.props.href),e.push(t),e.push(`]`),n=`,[`;else{e.push(n);var r=t.props[`data-precedence`],i=t.props,o=z(``+t.props.href);for(var s in o=Ke(o),e.push(o),r=``+r,e.push(`,`),r=Ke(r),e.push(r),i)if(O.call(i,s)&&(r=i[s],r!=null))switch(s){case`href`:case`rel`:case`precedence`:case`data-precedence`:break;case`children`:case`dangerouslySetInnerHTML`:throw Error(a(399,`link`));default:at(e,s,r)}e.push(`]`),n=`,[`,t.state=3}}}),e.push(`]`)}function at(e,t,n){var r=t.toLowerCase();switch(typeof n){case`function`:case`symbol`:return}switch(t){case`innerHTML`:case`dangerouslySetInnerHTML`:case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`style`:case`ref`:return;case`className`:r=`class`,t=``+n;break;case`hidden`:if(!1===n)return;t=``;break;case`src`:case`href`:n=z(n),t=``+n;break;default:if(2<t.length&&(t[0]===`o`||t[0]===`O`)&&(t[1]===`n`||t[1]===`N`)||!M(t))return;t=``+n}e.push(`,`),r=Ke(r),e.push(r),e.push(`,`),r=Ke(t),e.push(r)}function ot(){return{styles:new Set,stylesheets:new Set,suspenseyImages:!1}}function st(e){var t=Bn||null;if(t){var n=t.resumableState,r=t.renderState;if(typeof e==`string`&&e){if(!n.dnsResources.hasOwnProperty(e)){n.dnsResources[e]=null,n=r.headers;var i,a;(a=n&&0<n.remainingCapacity)&&(a=(i=`<`+(``+e).replace(ht,gt)+`>; rel=dns-prefetch`,0<=(n.remainingCapacity-=i.length+2))),a?(r.resets.dns[e]=null,n.preconnects&&(n.preconnects+=`, `),n.preconnects+=i):(i=[],we(i,{href:e,rel:`dns-prefetch`}),r.preconnects.add(i))}Fr(t)}}else V.D(e)}function ct(e,t){var n=Bn||null;if(n){var r=n.resumableState,i=n.renderState;if(typeof e==`string`&&e){var a=t===`use-credentials`?`credentials`:typeof t==`string`?`anonymous`:`default`;if(!r.connectResources[a].hasOwnProperty(e)){r.connectResources[a][e]=null,r=i.headers;var o,s;if(s=r&&0<r.remainingCapacity){if(s=`<`+(``+e).replace(ht,gt)+`>; rel=preconnect`,typeof t==`string`){var c=(``+t).replace(_t,vt);s+=`; crossorigin="`+c+`"`}s=(o=s,0<=(r.remainingCapacity-=o.length+2))}s?(i.resets.connect[a][e]=null,r.preconnects&&(r.preconnects+=`, `),r.preconnects+=o):(a=[],we(a,{rel:`preconnect`,href:e,crossOrigin:t}),i.preconnects.add(a))}Fr(n)}}else V.C(e,t)}function lt(e,t,n){var r=Bn||null;if(r){var i=r.resumableState,a=r.renderState;if(t&&e){switch(t){case`image`:if(n)var o=n.imageSrcSet,s=n.imageSizes,c=n.fetchPriority;var l=o?o+`
36
+ `+(s||``):e;if(i.imageResources.hasOwnProperty(l))return;i.imageResources[l]=re,i=a.headers;var u;i&&0<i.remainingCapacity&&typeof o!=`string`&&c===`high`&&(u=mt(e,t,n),0<=(i.remainingCapacity-=u.length+2))?(a.resets.image[l]=re,i.highImagePreloads&&(i.highImagePreloads+=`, `),i.highImagePreloads+=u):(i=[],we(i,D({rel:`preload`,href:o?void 0:e,as:t},n)),c===`high`?a.highImagePreloads.add(i):(a.bulkPreloads.add(i),a.preloads.images.set(l,i)));break;case`style`:if(i.styleResources.hasOwnProperty(e))return;o=[],we(o,D({rel:`preload`,href:e,as:t},n)),i.styleResources[e]=!n||typeof n.crossOrigin!=`string`&&typeof n.integrity!=`string`?re:[n.crossOrigin,n.integrity],a.preloads.stylesheets.set(e,o),a.bulkPreloads.add(o);break;case`script`:if(i.scriptResources.hasOwnProperty(e))return;o=[],a.preloads.scripts.set(e,o),a.bulkPreloads.add(o),we(o,D({rel:`preload`,href:e,as:t},n)),i.scriptResources[e]=!n||typeof n.crossOrigin!=`string`&&typeof n.integrity!=`string`?re:[n.crossOrigin,n.integrity];break;default:if(i.unknownResources.hasOwnProperty(t)){if(o=i.unknownResources[t],o.hasOwnProperty(e))return}else o={},i.unknownResources[t]=o;if(o[e]=re,(i=a.headers)&&0<i.remainingCapacity&&t===`font`&&(l=mt(e,t,n),0<=(i.remainingCapacity-=l.length+2)))a.resets.font[e]=re,i.fontPreloads&&(i.fontPreloads+=`, `),i.fontPreloads+=l;else switch(i=[],e=D({rel:`preload`,href:e,as:t},n),we(i,e),t){case`font`:a.fontPreloads.add(i);break;default:a.bulkPreloads.add(i)}}Fr(r)}}else V.L(e,t,n)}function ut(e,t){var n=Bn||null;if(n){var r=n.resumableState,i=n.renderState;if(e){var a=t&&typeof t.as==`string`?t.as:`script`;switch(a){case`script`:if(r.moduleScriptResources.hasOwnProperty(e))return;a=[],r.moduleScriptResources[e]=!t||typeof t.crossOrigin!=`string`&&typeof t.integrity!=`string`?re:[t.crossOrigin,t.integrity],i.preloads.moduleScripts.set(e,a);break;default:if(r.moduleUnknownResources.hasOwnProperty(a)){var o=r.unknownResources[a];if(o.hasOwnProperty(e))return}else o={},r.moduleUnknownResources[a]=o;a=[],o[e]=re}we(a,D({rel:`modulepreload`,href:e},t)),i.bulkPreloads.add(a),Fr(n)}}else V.m(e,t)}function dt(e,t,n){var r=Bn||null;if(r){var i=r.resumableState,a=r.renderState;if(e){t||=`default`;var o=a.styles.get(t),s=i.styleResources.hasOwnProperty(e)?i.styleResources[e]:void 0;s!==null&&(i.styleResources[e]=null,o||(o={precedence:I(t),rules:[],hrefs:[],sheets:new Map},a.styles.set(t,o)),t={state:0,props:D({rel:`stylesheet`,href:e,"data-precedence":t},n)},s&&(s.length===2&&pt(t.props,s),(a=a.preloads.stylesheets.get(e))&&0<a.length?a.length=0:t.state=1),o.sheets.set(e,t),Fr(r))}}else V.S(e,t,n)}function ft(e,t){var n=Bn||null;if(n){var r=n.resumableState,i=n.renderState;if(e){var a=r.scriptResources.hasOwnProperty(e)?r.scriptResources[e]:void 0;a!==null&&(r.scriptResources[e]=null,t=D({src:e,async:!0},t),a&&(a.length===2&&pt(t,a),e=i.preloads.scripts.get(e))&&(e.length=0),e=[],i.scripts.add(e),ke(e,t),Fr(n))}}else V.X(e,t)}function G(e,t){var n=Bn||null;if(n){var r=n.resumableState,i=n.renderState;if(e){var a=r.moduleScriptResources.hasOwnProperty(e)?r.moduleScriptResources[e]:void 0;a!==null&&(r.moduleScriptResources[e]=null,t=D({src:e,type:`module`,async:!0},t),a&&(a.length===2&&pt(t,a),e=i.preloads.moduleScripts.get(e))&&(e.length=0),e=[],i.scripts.add(e),ke(e,t),Fr(n))}}else V.M(e,t)}function pt(e,t){e.crossOrigin??=t[0],e.integrity??=t[1]}function mt(e,t,n){for(var r in e=(``+e).replace(ht,gt),t=(``+t).replace(_t,vt),t=`<`+e+`>; rel=preload; as="`+t+`"`,n)O.call(n,r)&&(e=n[r],typeof e==`string`&&(t+=`; `+r.toLowerCase()+`="`+(``+e).replace(_t,vt)+`"`));return t}var ht=/[<>\r\n]/g;function gt(e){switch(e){case`<`:return`%3C`;case`>`:return`%3E`;case`
37
+ `:return`%0A`;case`\r`:return`%0D`;default:throw Error(`escapeLinkHrefForHeaderContextReplacer encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React`)}}var _t=/["';,\r\n]/g;function vt(e){switch(e){case`"`:return`%22`;case`'`:return`%27`;case`;`:return`%3B`;case`,`:return`%2C`;case`
38
+ `:return`%0A`;case`\r`:return`%0D`;default:throw Error(`escapeStringForLinkHeaderQuotedParamValueContextReplacer encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React`)}}function yt(e){this.styles.add(e)}function bt(e){this.stylesheets.add(e)}function xt(e,t){t.styles.forEach(yt,e),t.stylesheets.forEach(bt,e),t.suspenseyImages&&(e.suspenseyImages=!0)}function St(e,t){var n=e.idPrefix,r=[],i=e.bootstrapScriptContent,a=e.bootstrapScripts,o=e.bootstrapModules;i!==void 0&&(r.push(`<script`),rt(r,e),r.push(`>`,(``+i).replace(ae,oe),`<\/script>`)),i=n+`P:`;var s=n+`S:`;n+=`B:`;var c=new Set,l=new Set,u=new Set,d=new Map,f=new Set,p=new Set,m=new Set,h={images:new Map,stylesheets:new Map,scripts:new Map,moduleScripts:new Map};if(a!==void 0)for(var g=0;g<a.length;g++){var _=a[g],v,y=void 0,b=void 0,x={rel:`preload`,as:`script`,fetchPriority:`low`,nonce:void 0};typeof _==`string`?x.href=v=_:(x.href=v=_.src,x.integrity=b=typeof _.integrity==`string`?_.integrity:void 0,x.crossOrigin=y=typeof _==`string`||_.crossOrigin==null?void 0:_.crossOrigin===`use-credentials`?`use-credentials`:``),_=e;var S=v;_.scriptResources[S]=null,_.moduleScriptResources[S]=null,_=[],we(_,x),f.add(_),r.push(`<script src="`,I(v),`"`),typeof b==`string`&&r.push(` integrity="`,I(b),`"`),typeof y==`string`&&r.push(` crossorigin="`,I(y),`"`),rt(r,e),r.push(` async=""><\/script>`)}if(o!==void 0)for(a=0;a<o.length;a++)x=o[a],y=v=void 0,b={rel:`modulepreload`,fetchPriority:`low`,nonce:void 0},typeof x==`string`?b.href=g=x:(b.href=g=x.src,b.integrity=y=typeof x.integrity==`string`?x.integrity:void 0,b.crossOrigin=v=typeof x==`string`||x.crossOrigin==null?void 0:x.crossOrigin===`use-credentials`?`use-credentials`:``),x=e,_=g,x.scriptResources[_]=null,x.moduleScriptResources[_]=null,x=[],we(x,b),f.add(x),r.push(`<script type="module" src="`,I(g),`"`),typeof y==`string`&&r.push(` integrity="`,I(y),`"`),typeof v==`string`&&r.push(` crossorigin="`,I(v),`"`),rt(r,e),r.push(` async=""><\/script>`);return{placeholderPrefix:i,segmentPrefix:s,boundaryPrefix:n,startInlineScript:`<script`,startInlineStyle:`<style`,preamble:{htmlChunks:null,headChunks:null,bodyChunks:null},externalRuntimeScript:null,bootstrapChunks:r,importMapChunks:[],onHeaders:void 0,headers:null,resets:{font:{},dns:{},connect:{default:{},anonymous:{},credentials:{}},image:{},style:{}},charsetChunks:[],viewportChunks:[],hoistableChunks:[],preconnects:c,fontPreloads:l,highImagePreloads:u,styles:d,bootstrapScripts:f,scripts:p,bulkPreloads:m,preloads:h,nonce:{script:void 0,style:void 0},stylesToHoist:!1,generateStaticMarkup:t}}function Ct(e,t,n,r){return n.generateStaticMarkup?(e.push(I(t)),!1):(t===``?e=r:(r&&e.push(`<!-- -->`),e.push(I(t)),e=!0),e)}function wt(e,t,n,r){t.generateStaticMarkup||n&&r&&e.push(`<!-- -->`)}var Tt=Function.prototype.bind,Et=Symbol.for(`react.client.reference`);function Dt(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===Et?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case c:return`Fragment`;case u:return`Profiler`;case l:return`StrictMode`;case m:return`Suspense`;case h:return`SuspenseList`;case y:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case s:return`Portal`;case f:return e.displayName||`Context`;case d:return(e._context.displayName||`Context`)+`.Consumer`;case p:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case g:return t=e.displayName||null,t===null?Dt(e.type)||`Memo`:t;case _:t=e._payload,e=e._init;try{return Dt(e(t))}catch{}}return null}var Ot={},kt=null;function At(e,t){if(e!==t){e.context._currentValue2=e.parentValue,e=e.parent;var n=t.parent;if(e===null){if(n!==null)throw Error(a(401))}else{if(n===null)throw Error(a(401));At(e,n)}t.context._currentValue2=t.value}}function jt(e){e.context._currentValue2=e.parentValue,e=e.parent,e!==null&&jt(e)}function Mt(e){var t=e.parent;t!==null&&Mt(t),e.context._currentValue2=e.value}function Nt(e,t){if(e.context._currentValue2=e.parentValue,e=e.parent,e===null)throw Error(a(402));e.depth===t.depth?At(e,t):Nt(e,t)}function Pt(e,t){var n=t.parent;if(n===null)throw Error(a(402));e.depth===n.depth?At(e,n):Pt(e,n),t.context._currentValue2=t.value}function Ft(e){var t=kt;t!==e&&(t===null?Mt(e):e===null?jt(t):t.depth===e.depth?At(t,e):t.depth>e.depth?Nt(t,e):Pt(t,e),kt=e)}var It={enqueueSetState:function(e,t){e=e._reactInternals,e.queue!==null&&e.queue.push(t)},enqueueReplaceState:function(e,t){e=e._reactInternals,e.replace=!0,e.queue=[t]},enqueueForceUpdate:function(){}},Lt={id:1,overflow:``};function Rt(e,t,n){var r=e.id;e=e.overflow;var i=32-zt(r)-1;r&=~(1<<i),n+=1;var a=32-zt(t)+i;if(30<a){var o=i-i%5;return a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,{id:1<<32-zt(t)+i|n<<i|r,overflow:a+e}}return{id:1<<a|n<<i|r,overflow:e}}var zt=Math.clz32?Math.clz32:Ht,Bt=Math.log,Vt=Math.LN2;function Ht(e){return e>>>=0,e===0?32:31-(Bt(e)/Vt|0)|0}function Ut(){}var Wt=Error(a(460));function Gt(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Ut,Ut),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason;default:switch(typeof t.status==`string`?t.then(Ut,Ut):(e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason}throw Kt=t,Wt}}var Kt=null;function qt(){if(Kt===null)throw Error(a(459));var e=Kt;return Kt=null,e}function Jt(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Yt=typeof Object.is==`function`?Object.is:Jt,Xt=null,Zt=null,Qt=null,$t=null,en=null,tn=null,nn=!1,rn=!1,an=0,on=0,sn=-1,cn=0,ln=null,un=null,dn=0;function fn(){if(Xt===null)throw Error(a(321));return Xt}function pn(){if(0<dn)throw Error(a(312));return{memoizedState:null,queue:null,next:null}}function mn(){return tn===null?en===null?(nn=!1,en=tn=pn()):(nn=!0,tn=en):tn.next===null?(nn=!1,tn=tn.next=pn()):(nn=!0,tn=tn.next),tn}function hn(){var e=ln;return ln=null,e}function gn(){$t=Qt=Zt=Xt=null,rn=!1,en=null,dn=0,tn=un=null}function _n(e,t){return typeof t==`function`?t(e):t}function vn(e,t,n){if(Xt=fn(),tn=mn(),nn){var r=tn.queue;if(t=r.dispatch,un!==null&&(n=un.get(r),n!==void 0)){un.delete(r),r=tn.memoizedState;do r=e(r,n.action),n=n.next;while(n!==null);return tn.memoizedState=r,[r,t]}return[tn.memoizedState,t]}return e=e===_n?typeof t==`function`?t():t:n===void 0?t:n(t),tn.memoizedState=e,e=tn.queue={last:null,dispatch:null},e=e.dispatch=bn.bind(null,Xt,e),[tn.memoizedState,e]}function yn(e,t){if(Xt=fn(),tn=mn(),t=t===void 0?null:t,tn!==null){var n=tn.memoizedState;if(n!==null&&t!==null){var r=n[1];a:if(r===null)r=!1;else{for(var i=0;i<r.length&&i<t.length;i++)if(!Yt(t[i],r[i])){r=!1;break a}r=!0}if(r)return n[0]}}return e=e(),tn.memoizedState=[e,t],e}function bn(e,t,n){if(25<=dn)throw Error(a(301));if(e===Xt){if(rn=!0,e={action:n,next:null},un===null&&(un=new Map),n=un.get(t),n===void 0)un.set(t,e);else{for(t=n;t.next!==null;)t=t.next;t.next=e}}}function xn(){throw Error(a(440))}function Sn(){throw Error(a(394))}function Cn(){throw Error(a(479))}function wn(e,t,n){fn();var r=on++,i=Qt;if(typeof e.$$FORM_ACTION==`function`){var a=null,o=$t;i=i.formState;var s=e.$$IS_SIGNATURE_EQUAL;if(i!==null&&typeof s==`function`){var c=i[1];s.call(e,i[2],i[3])&&(a=n===void 0?`k`+E(JSON.stringify([o,null,r]),0):`p`+n,c===a&&(sn=r,t=i[0]))}var l=e.bind(null,t);return e=function(e){l(e)},typeof l.$$FORM_ACTION==`function`&&(e.$$FORM_ACTION=function(e){e=l.$$FORM_ACTION(e),n!==void 0&&(n+=``,e.action=n);var t=e.data;return t&&(a===null&&(a=n===void 0?`k`+E(JSON.stringify([o,null,r]),0):`p`+n),t.append(`$ACTION_KEY`,a)),e}),[t,e,!1]}var u=e.bind(null,t);return[t,function(e){u(e)},!1]}function Tn(e){var t=cn;return cn+=1,ln===null&&(ln=[]),Gt(ln,e,t)}function En(){throw Error(a(393))}var Dn={readContext:function(e){return e._currentValue2},use:function(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Tn(e);if(e.$$typeof===f)return e._currentValue2}throw Error(a(438,String(e)))},useContext:function(e){return fn(),e._currentValue2},useMemo:yn,useReducer:vn,useRef:function(e){Xt=fn(),tn=mn();var t=tn.memoizedState;return t===null?(e={current:e},tn.memoizedState=e):t},useState:function(e){return vn(_n,e)},useInsertionEffect:Ut,useLayoutEffect:Ut,useCallback:function(e,t){return yn(function(){return e},t)},useImperativeHandle:Ut,useEffect:Ut,useDebugValue:Ut,useDeferredValue:function(e,t){return fn(),t===void 0?e:t},useTransition:function(){return fn(),[!1,Sn]},useId:function(){var e=Zt.treeContext,t=e.overflow;e=e.id,e=(e&~(1<<32-zt(e)-1)).toString(32)+t;var n=On;if(n===null)throw Error(a(404));return t=an++,e=`_`+n.idPrefix+`R_`+e,0<t&&(e+=`H`+t.toString(32)),e+`_`},useSyncExternalStore:function(e,t,n){if(n===void 0)throw Error(a(407));return n()},useOptimistic:function(e){return fn(),[e,Cn]},useActionState:wn,useFormState:wn,useHostTransitionStatus:function(){return fn(),B},useMemoCache:function(e){for(var t=Array(e),n=0;n<e;n++)t[n]=x;return t},useCacheRefresh:function(){return En},useEffectEvent:function(){return xn}},On=null,kn={getCacheForType:function(){throw Error(a(248))},cacheSignal:function(){throw Error(a(248))}},An,jn;function Mn(e){if(An===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);An=t&&t[1]||``,jn=-1<e.stack.indexOf(`
39
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
40
+ `+An+e+jn}var Nn=!1;function Pn(e,t){if(!e||Nn)return``;Nn=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
41
+ `),l=s.split(`
42
+ `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
43
+ `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Nn=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Mn(n):``}function Fn(e){if(typeof e==`string`)return Mn(e);if(typeof e==`function`)return e.prototype&&e.prototype.isReactComponent?Pn(e,!0):Pn(e,!1);if(typeof e==`object`&&e){switch(e.$$typeof){case p:return Pn(e.render,!1);case g:return Pn(e.type,!1);case _:var t=e,n=t._payload;t=t._init;try{e=t(n)}catch{return Mn(`Lazy`)}return Fn(e)}if(typeof e.name==`string`){a:{n=e.name,t=e.env;var r=e.debugLocation;if(r!=null&&(e=Error.prepareStackTrace,Error.prepareStackTrace=void 0,r=r.stack,Error.prepareStackTrace=e,r.startsWith(`Error: react-stack-top-frame
44
+ `)&&(r=r.slice(29)),e=r.indexOf(`
45
+ `),e!==-1&&(r=r.slice(e+1)),e=r.indexOf(`react_stack_bottom_frame`),e!==-1&&(e=r.lastIndexOf(`
46
+ `,e)),e=e===-1?``:r=r.slice(0,e),r=e.lastIndexOf(`
47
+ `),e=r===-1?e:e.slice(r+1),e.indexOf(n)!==-1)){n=`
48
+ `+e;break a}n=Mn(n+(t?` [`+t+`]`:``))}return n}}switch(e){case h:return Mn(`SuspenseList`);case m:return Mn(`Suspense`)}return``}function In(e,t){return(500<t.byteSize||!1)&&t.contentPreamble===null}function Ln(e){if(typeof e==`object`&&e&&typeof e.environmentName==`string`){var t=e.environmentName;e=[e].slice(0),typeof e[0]==`string`?e.splice(0,1,`[%s] `+e[0],` `+t+` `):e.splice(0,0,`[%s]`,` `+t+` `),e.unshift(console),t=Tt.apply(console.error,e),t()}else console.error(e);return null}function Rn(e,t,n,r,i,a,o,s,c,l,u){var d=new Set;this.destination=null,this.flushScheduled=!1,this.resumableState=e,this.renderState=t,this.rootFormatContext=n,this.progressiveChunkSize=r===void 0?12800:r,this.status=10,this.fatalError=null,this.pendingRootTasks=this.allPendingTasks=this.nextSegmentId=0,this.completedPreambleSegments=this.completedRootSegment=null,this.byteSize=0,this.abortableTasks=d,this.pingedTasks=[],this.clientRenderedBoundaries=[],this.completedBoundaries=[],this.partialBoundaries=[],this.trackedPostpones=null,this.onError=i===void 0?Ln:i,this.onPostpone=l===void 0?Ut:l,this.onAllReady=a===void 0?Ut:a,this.onShellReady=o===void 0?Ut:o,this.onShellError=s===void 0?Ut:s,this.onFatalError=c===void 0?Ut:c,this.formState=u===void 0?null:u}function zn(e,t,n,r,i,a,o,s,c,l,u,d){return t=new Rn(t,n,r,i,a,o,s,c,l,u,d),n=Gn(t,0,null,r,!1,!1),n.parentFlushed=!0,e=Un(t,null,e,-1,null,n,null,null,t.abortableTasks,null,r,null,Lt,null,null),Kn(e),t.pingedTasks.push(e),t}var Bn=null;function Vn(e,t){e.pingedTasks.push(t),e.pingedTasks.length===1&&(e.flushScheduled=e.destination!==null,Cr(e))}function Hn(e,t,n,r,i){return n={status:0,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,row:t,completedSegments:[],byteSize:0,fallbackAbortableTasks:n,errorDigest:null,contentState:ot(),fallbackState:ot(),contentPreamble:r,fallbackPreamble:i,trackedContentKeyPath:null,trackedFallbackNode:null},t!==null&&(t.pendingTasks++,r=t.boundaries,r!==null&&(e.allPendingTasks++,n.pendingTasks++,r.push(n)),e=t.inheritedHoistables,e!==null&&xt(n.contentState,e)),n}function Un(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){e.allPendingTasks++,i===null?e.pendingRootTasks++:i.pendingTasks++,p!==null&&p.pendingTasks++;var h={replay:null,node:n,childIndex:r,ping:function(){return Vn(e,h)},blockedBoundary:i,blockedSegment:a,blockedPreamble:o,hoistableState:s,abortSet:c,keyPath:l,formatContext:u,context:d,treeContext:f,row:p,componentStack:m,thenableState:t};return c.add(h),h}function Wn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.allPendingTasks++,a===null?e.pendingRootTasks++:a.pendingTasks++,f!==null&&f.pendingTasks++,n.pendingTasks++;var m={replay:n,node:r,childIndex:i,ping:function(){return Vn(e,m)},blockedBoundary:a,blockedSegment:null,blockedPreamble:null,hoistableState:o,abortSet:s,keyPath:c,formatContext:l,context:u,treeContext:d,row:f,componentStack:p,thenableState:t};return s.add(m),m}function Gn(e,t,n,r,i,a){return{status:0,parentFlushed:!1,id:-1,index:t,chunks:[],children:[],preambleChildren:[],parentFormatContext:r,boundary:n,lastPushedText:i,textEmbedded:a}}function Kn(e){var t=e.node;if(typeof t==`object`&&t)switch(t.$$typeof){case o:e.componentStack={parent:e.componentStack,type:t.type}}}function qn(e){return e===null?null:{parent:e.parent,type:`Suspense Fallback`}}function Jn(e){var t={};return e&&Object.defineProperty(t,"componentStack",{configurable:!0,enumerable:!0,get:function(){try{var n=``,r=e;do n+=Fn(r.type),r=r.parent;while(r);var i=n}catch(e){i=`
49
+ Error generating stack: `+e.message+`
50
+ `+e.stack}return Object.defineProperty(t,"componentStack",{value:i}),i}}),t}function Yn(e,t,n){if(e=e.onError,t=e(t,n),t==null||typeof t==`string`)return t}function Xn(e,t){var n=e.onShellError,r=e.onFatalError;n(t),r(t),e.destination===null?(e.status=13,e.fatalError=t):(e.status=14,e.destination.destroy(t))}function Zn(e,t){Qn(e,t.next,t.hoistables)}function Qn(e,t,n){for(;t!==null;){n!==null&&(xt(t.hoistables,n),t.inheritedHoistables=n);var r=t.boundaries;if(r!==null){t.boundaries=null;for(var i=0;i<r.length;i++){var a=r[i];n!==null&&xt(a.contentState,n),Sr(e,a,null,null)}}if(t.pendingTasks--,0<t.pendingTasks)break;n=t.hoistables,t=t.next}}function $n(e,t){var n=t.boundaries;if(n!==null&&t.pendingTasks===n.length){for(var r=!0,i=0;i<n.length;i++){var a=n[i];if(a.pendingTasks!==1||a.parentFlushed||In(e,a)){r=!1;break}}r&&Qn(e,t,t.hoistables)}}function er(e){var t={pendingTasks:1,boundaries:null,hoistables:ot(),inheritedHoistables:null,together:!1,next:null};return e!==null&&0<e.pendingTasks&&(t.pendingTasks++,t.boundaries=[],e.next=t),t}function tr(e,t,n,r,i){var a=t.keyPath,o=t.treeContext,s=t.row;t.keyPath=n,n=r.length;var c=null;if(t.replay!==null){var l=t.replay.slots;if(typeof l==`object`&&l)for(var u=0;u<n;u++){var d=i!==`backwards`&&i!==`unstable_legacy-backwards`?u:n-1-u,f=r[d];t.row=c=er(c),t.treeContext=Rt(o,n,d);var p=l[d];typeof p==`number`?(ar(e,t,p,f,d),delete l[d]):mr(e,t,f,d),--c.pendingTasks===0&&Zn(e,c)}else for(l=0;l<n;l++)u=i!==`backwards`&&i!==`unstable_legacy-backwards`?l:n-1-l,d=r[u],t.row=c=er(c),t.treeContext=Rt(o,n,u),mr(e,t,d,u),--c.pendingTasks===0&&Zn(e,c)}else if(i!==`backwards`&&i!==`unstable_legacy-backwards`)for(i=0;i<n;i++)l=r[i],t.row=c=er(c),t.treeContext=Rt(o,n,i),mr(e,t,l,i),--c.pendingTasks===0&&Zn(e,c);else{for(i=t.blockedSegment,l=i.children.length,u=i.chunks.length,d=n-1;0<=d;d--){f=r[d],t.row=c=er(c),t.treeContext=Rt(o,n,d),p=Gn(e,u,null,t.formatContext,d!==0||i.lastPushedText,!0),i.children.splice(l,0,p),t.blockedSegment=p;try{mr(e,t,f,d),wt(p.chunks,e.renderState,p.lastPushedText,p.textEmbedded),p.status=1,--c.pendingTasks===0&&Zn(e,c)}catch(t){throw p.status=e.status===12?3:4,t}}t.blockedSegment=i,i.lastPushedText=!1}s!==null&&c!==null&&0<c.pendingTasks&&(s.pendingTasks++,c.next=s),t.treeContext=o,t.row=s,t.keyPath=a}function nr(e,t,n,r,i,a){var o=t.thenableState;for(t.thenableState=null,Xt={},Zt=t,Qt=e,$t=n,on=an=0,sn=-1,cn=0,ln=o,e=r(i,a);rn;)rn=!1,on=an=0,sn=-1,cn=0,dn+=1,tn=null,e=r(i,a);return gn(),e}function rr(e,t,n,r,i,a,o){var s=!1;if(a!==0&&e.formState!==null){var c=t.blockedSegment;if(c!==null){s=!0,c=c.chunks;for(var l=0;l<a;l++)l===o?c.push(`<!--F!-->`):c.push(`<!--F-->`)}}a=t.keyPath,t.keyPath=n,i?(n=t.treeContext,t.treeContext=Rt(n,1,0),mr(e,t,r,-1),t.treeContext=n):s?mr(e,t,r,-1):or(e,t,r,-1),t.keyPath=a}function ir(e,t,n,r,i,o){if(typeof r==`function`){if(r.prototype&&r.prototype.isReactComponent){var s=i;if(`ref`in i)for(var x in s={},i)x!==`ref`&&(s[x]=i[x]);var C=r.defaultProps;if(C)for(var E in s===i&&(s=D({},s,i)),C)s[E]===void 0&&(s[E]=C[E]);i=s,s=Ot,C=r.contextType,typeof C==`object`&&C&&(s=C._currentValue2),s=new r(i,s);var O=s.state===void 0?null:s.state;if(s.updater=It,s.props=i,s.state=O,C={queue:[],replace:!1},s._reactInternals=C,o=r.contextType,s.context=typeof o==`object`&&o?o._currentValue2:Ot,o=r.getDerivedStateFromProps,typeof o==`function`&&(o=o(i,O),O=o==null?O:D({},O,o),s.state=O),typeof r.getDerivedStateFromProps!=`function`&&typeof s.getSnapshotBeforeUpdate!=`function`&&(typeof s.UNSAFE_componentWillMount==`function`||typeof s.componentWillMount==`function`)){if(r=s.state,typeof s.componentWillMount==`function`&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount==`function`&&s.UNSAFE_componentWillMount(),r!==s.state&&It.enqueueReplaceState(s,s.state,null),C.queue!==null&&0<C.queue.length){if(r=C.queue,o=C.replace,C.queue=null,C.replace=!1,o&&r.length===1)s.state=r[0];else{for(C=o?r[0]:s.state,O=!0,o=+!!o;o<r.length;o++)E=r[o],E=typeof E==`function`?E.call(s,C,i,void 0):E,E!=null&&(O?(O=!1,C=D({},C,E)):D(C,E));s.state=C}}else C.queue=null}if(r=s.render(),e.status===12)throw null;i=t.keyPath,t.keyPath=n,or(e,t,r,-1),t.keyPath=i}else{if(r=nr(e,t,n,r,i,void 0),e.status===12)throw null;rr(e,t,n,r,an!==0,on,sn)}}else if(typeof r==`string`){if(s=t.blockedSegment,s===null)s=i.children,C=t.formatContext,O=t.keyPath,t.formatContext=le(C,r,i),t.keyPath=n,mr(e,t,s,-1),t.formatContext=C,t.keyPath=O;else{if(O=Fe(s.chunks,r,i,e.resumableState,e.renderState,t.blockedPreamble,t.hoistableState,t.formatContext,s.lastPushedText),s.lastPushedText=!1,C=t.formatContext,o=t.keyPath,t.keyPath=n,(t.formatContext=le(C,r,i)).insertionMode===3){n=Gn(e,0,null,t.formatContext,!1,!1),s.preambleChildren.push(n),t.blockedSegment=n;try{n.status=6,mr(e,t,O,-1),wt(n.chunks,e.renderState,n.lastPushedText,n.textEmbedded),n.status=1}finally{t.blockedSegment=s}}else mr(e,t,O,-1);t.formatContext=C,t.keyPath=o;a:{switch(t=s.chunks,e=e.resumableState,r){case`title`:case`style`:case`script`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`img`:case`input`:case`keygen`:case`link`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:break a;case`body`:if(1>=C.insertionMode){e.hasBody=!0;break a}break;case`html`:if(C.insertionMode===0){e.hasHtml=!0;break a}break;case`head`:if(1>=C.insertionMode)break a}t.push(Le(r))}s.lastPushedText=!1}}else{switch(r){case b:case l:case u:case c:r=t.keyPath,t.keyPath=n,or(e,t,i.children,-1),t.keyPath=r;return;case y:r=t.blockedSegment,r===null?i.mode!==`hidden`&&(r=t.keyPath,t.keyPath=n,mr(e,t,i.children,-1),t.keyPath=r):i.mode!==`hidden`&&(e.renderState.generateStaticMarkup||r.chunks.push(`<!--&-->`),r.lastPushedText=!1,s=t.keyPath,t.keyPath=n,mr(e,t,i.children,-1),t.keyPath=s,e.renderState.generateStaticMarkup||r.chunks.push(`<!--/&-->`),r.lastPushedText=!1);return;case h:a:{if(r=i.children,i=i.revealOrder,i===`forwards`||i===`backwards`||i===`unstable_legacy-backwards`){if(T(r)){tr(e,t,n,r,i);break a}if((s=w(r))&&(s=s.call(r))){if(C=s.next(),!C.done){do C=s.next();while(!C.done);tr(e,t,n,r,i)}break a}}i===`together`?(i=t.keyPath,s=t.row,C=t.row=er(null),C.boundaries=[],C.together=!0,t.keyPath=n,or(e,t,r,-1),--C.pendingTasks===0&&Zn(e,C),t.keyPath=i,t.row=s,s!==null&&0<C.pendingTasks&&(s.pendingTasks++,C.next=s)):(i=t.keyPath,t.keyPath=n,or(e,t,r,-1),t.keyPath=i)}return;case S:case v:throw Error(a(343));case m:a:if(t.replay!==null){r=t.keyPath,s=t.formatContext,C=t.row,t.keyPath=n,t.formatContext=de(e.resumableState,s),t.row=null,n=i.children;try{mr(e,t,n,-1)}finally{t.keyPath=r,t.formatContext=s,t.row=C}}else{r=t.keyPath,o=t.formatContext;var k=t.row,A=t.blockedBoundary;E=t.blockedPreamble;var j=t.hoistableState;x=t.blockedSegment;var M=i.fallback;i=i.children;var N=new Set,P=Hn(e,t.row,N,null,null);e.trackedPostpones!==null&&(P.trackedContentKeyPath=n);var F=Gn(e,x.chunks.length,P,t.formatContext,!1,!1);x.children.push(F),x.lastPushedText=!1;var I=Gn(e,0,null,t.formatContext,!1,!1);if(I.parentFlushed=!0,e.trackedPostpones!==null){s=t.componentStack,C=[n[0],`Suspense Fallback`,n[2]],O=[C[1],C[2],[],null],e.trackedPostpones.workingMap.set(C,O),P.trackedFallbackNode=O,t.blockedSegment=F,t.blockedPreamble=P.fallbackPreamble,t.keyPath=C,t.formatContext=ue(e.resumableState,o),t.componentStack=qn(s),F.status=6;try{mr(e,t,M,-1),wt(F.chunks,e.renderState,F.lastPushedText,F.textEmbedded),F.status=1}catch(t){throw F.status=e.status===12?3:4,t}finally{t.blockedSegment=x,t.blockedPreamble=E,t.keyPath=r,t.formatContext=o}t=Un(e,null,i,-1,P,I,P.contentPreamble,P.contentState,t.abortSet,n,de(e.resumableState,t.formatContext),t.context,t.treeContext,null,s),Kn(t),e.pingedTasks.push(t)}else{t.blockedBoundary=P,t.blockedPreamble=P.contentPreamble,t.hoistableState=P.contentState,t.blockedSegment=I,t.keyPath=n,t.formatContext=de(e.resumableState,o),t.row=null,I.status=6;try{if(mr(e,t,i,-1),wt(I.chunks,e.renderState,I.lastPushedText,I.textEmbedded),I.status=1,xr(P,I),P.pendingTasks===0&&P.status===0){if(P.status=1,!In(e,P)){k!==null&&--k.pendingTasks===0&&Zn(e,k),e.pendingRootTasks===0&&t.blockedPreamble&&Er(e);break a}}else k!==null&&k.together&&$n(e,k)}catch(n){P.status=4,e.status===12?(I.status=3,s=e.fatalError):(I.status=4,s=n),C=Jn(t.componentStack),O=Yn(e,s,C),P.errorDigest=O,dr(e,P)}finally{t.blockedBoundary=A,t.blockedPreamble=E,t.hoistableState=j,t.blockedSegment=x,t.keyPath=r,t.formatContext=o,t.row=k}t=Un(e,null,M,-1,A,F,P.fallbackPreamble,P.fallbackState,N,[n[0],`Suspense Fallback`,n[2]],ue(e.resumableState,t.formatContext),t.context,t.treeContext,t.row,qn(t.componentStack)),Kn(t),e.pingedTasks.push(t)}}return}if(typeof r==`object`&&r)switch(r.$$typeof){case p:if(`ref`in i)for(M in s={},i)M!==`ref`&&(s[M]=i[M]);else s=i;r=nr(e,t,n,r.render,s,o),rr(e,t,n,r,an!==0,on,sn);return;case g:ir(e,t,n,r.type,i,o);return;case f:if(C=i.children,s=t.keyPath,i=i.value,O=r._currentValue2,r._currentValue2=i,o=kt,kt=r={parent:o,depth:o===null?0:o.depth+1,context:r,parentValue:O,value:i},t.context=r,t.keyPath=n,or(e,t,C,-1),e=kt,e===null)throw Error(a(403));e.context._currentValue2=e.parentValue,e=kt=e.parent,t.context=e,t.keyPath=s;return;case d:i=i.children,r=i(r._context._currentValue2),i=t.keyPath,t.keyPath=n,or(e,t,r,-1),t.keyPath=i;return;case _:if(s=r._init,r=s(r._payload),e.status===12)throw null;ir(e,t,n,r,i,o);return}throw Error(a(130,r==null?r:typeof r,``))}}function ar(e,t,n,r,i){var a=t.replay,o=t.blockedBoundary,s=Gn(e,0,null,t.formatContext,!1,!1);s.id=n,s.parentFlushed=!0;try{t.replay=null,t.blockedSegment=s,mr(e,t,r,i),s.status=1,o===null?e.completedRootSegment=s:(xr(o,s),o.parentFlushed&&e.partialBoundaries.push(o))}finally{t.replay=a,t.blockedSegment=null}}function or(e,t,n,r){t.replay!==null&&typeof t.replay.slots==`number`?ar(e,t,t.replay.slots,n,r):(t.node=n,t.childIndex=r,n=t.componentStack,Kn(t),sr(e,t),t.componentStack=n)}function sr(e,t){var n=t.node,r=t.childIndex;if(n!==null){if(typeof n==`object`){switch(n.$$typeof){case o:var i=n.type,c=n.key,l=n.props;n=l.ref;var u=n===void 0?null:n,d=Dt(i),p=c??(r===-1?0:r);if(c=[t.keyPath,d,p],t.replay!==null)a:{var h=t.replay;for(r=h.nodes,n=0;n<r.length;n++){var g=r[n];if(p===g[1]){if(g.length===4){if(d!==null&&d!==g[0])throw Error(a(490,g[0],d));var v=g[2];d=g[3],p=t.node,t.replay={nodes:v,slots:d,pendingTasks:1};try{if(ir(e,t,c,i,l,u),t.replay.pendingTasks===1&&0<t.replay.nodes.length)throw Error(a(488));t.replay.pendingTasks--}catch(a){if(typeof a==`object`&&a&&(a===Wt||typeof a.then==`function`))throw t.node===p?t.replay=h:r.splice(n,1),a;t.replay.pendingTasks--,l=Jn(t.componentStack),c=e,e=t.blockedBoundary,i=a,l=Yn(c,i,l),gr(c,e,v,d,i,l)}t.replay=h}else{if(i!==m)throw Error(a(490,`Suspense`,Dt(i)||`Unknown`));b:{h=void 0,i=g[5],u=g[2],d=g[3],p=g[4]===null?[]:g[4][2],g=g[4]===null?null:g[4][3];var y=t.keyPath,b=t.formatContext,x=t.row,S=t.replay,C=t.blockedBoundary,E=t.hoistableState,D=l.children,O=l.fallback,k=new Set;l=Hn(e,t.row,k,null,null),l.parentFlushed=!0,l.rootSegmentID=i,t.blockedBoundary=l,t.hoistableState=l.contentState,t.keyPath=c,t.formatContext=de(e.resumableState,b),t.row=null,t.replay={nodes:u,slots:d,pendingTasks:1};try{if(mr(e,t,D,-1),t.replay.pendingTasks===1&&0<t.replay.nodes.length)throw Error(a(488));if(t.replay.pendingTasks--,l.pendingTasks===0&&l.status===0){l.status=1,e.completedBoundaries.push(l);break b}}catch(n){l.status=4,v=Jn(t.componentStack),h=Yn(e,n,v),l.errorDigest=h,t.replay.pendingTasks--,e.clientRenderedBoundaries.push(l)}finally{t.blockedBoundary=C,t.hoistableState=E,t.replay=S,t.keyPath=y,t.formatContext=b,t.row=x}v=Wn(e,null,{nodes:p,slots:g,pendingTasks:0},O,-1,C,l.fallbackState,k,[c[0],`Suspense Fallback`,c[2]],ue(e.resumableState,t.formatContext),t.context,t.treeContext,t.row,qn(t.componentStack)),Kn(v),e.pingedTasks.push(v)}}r.splice(n,1);break a}}}else ir(e,t,c,i,l,u);return;case s:throw Error(a(257));case _:if(v=n._init,n=v(n._payload),e.status===12)throw null;or(e,t,n,r);return}if(T(n)){cr(e,t,n,r);return}if((v=w(n))&&(v=v.call(n))){if(n=v.next(),!n.done){l=[];do l.push(n.value),n=v.next();while(!n.done);cr(e,t,l,r)}return}if(typeof n.then==`function`)return t.thenableState=null,or(e,t,Tn(n),r);if(n.$$typeof===f)return or(e,t,n._currentValue2,r);throw r=Object.prototype.toString.call(n),Error(a(31,r===`[object Object]`?`object with keys {`+Object.keys(n).join(`, `)+`}`:r))}typeof n==`string`?(r=t.blockedSegment,r!==null&&(r.lastPushedText=Ct(r.chunks,n,e.renderState,r.lastPushedText))):(typeof n==`number`||typeof n==`bigint`)&&(r=t.blockedSegment,r!==null&&(r.lastPushedText=Ct(r.chunks,``+n,e.renderState,r.lastPushedText)))}}function cr(e,t,n,r){var i=t.keyPath;if(r!==-1&&(t.keyPath=[t.keyPath,`Fragment`,r],t.replay!==null)){for(var o=t.replay,s=o.nodes,c=0;c<s.length;c++){var l=s[c];if(l[1]===r){r=l[2],l=l[3],t.replay={nodes:r,slots:l,pendingTasks:1};try{if(cr(e,t,n,-1),t.replay.pendingTasks===1&&0<t.replay.nodes.length)throw Error(a(488));t.replay.pendingTasks--}catch(i){if(typeof i==`object`&&i&&(i===Wt||typeof i.then==`function`))throw i;t.replay.pendingTasks--,n=Jn(t.componentStack);var u=t.blockedBoundary,d=i;n=Yn(e,d,n),gr(e,u,r,l,d,n)}t.replay=o,s.splice(c,1);break}}t.keyPath=i;return}if(o=t.treeContext,s=n.length,t.replay!==null&&(c=t.replay.slots,typeof c==`object`&&c)){for(r=0;r<s;r++)l=n[r],t.treeContext=Rt(o,s,r),u=c[r],typeof u==`number`?(ar(e,t,u,l,r),delete c[r]):mr(e,t,l,r);t.treeContext=o,t.keyPath=i;return}for(c=0;c<s;c++)r=n[c],t.treeContext=Rt(o,s,c),mr(e,t,r,c);t.treeContext=o,t.keyPath=i}function lr(e,t,n){if(n.status=5,n.rootSegmentID=e.nextSegmentId++,e=n.trackedContentKeyPath,e===null)throw Error(a(486));var r=n.trackedFallbackNode,i=[],o=t.workingMap.get(e);return o===void 0?(n=[e[1],e[2],i,null,r,n.rootSegmentID],t.workingMap.set(e,n),Rr(n,e[0],t),n):(o[4]=r,o[5]=n.rootSegmentID,o)}function ur(e,t,n,r){r.status=5;var i=n.keyPath,o=n.blockedBoundary;if(o===null)r.id=e.nextSegmentId++,t.rootSlots=r.id,e.completedRootSegment!==null&&(e.completedRootSegment.status=5);else{if(o!==null&&o.status===0){var s=lr(e,t,o);if(o.trackedContentKeyPath===i&&n.childIndex===-1){r.id===-1&&(r.id=r.parentFlushed?o.rootSegmentID:e.nextSegmentId++),s[3]=r.id;return}}if(r.id===-1&&(r.id=r.parentFlushed&&o!==null?o.rootSegmentID:e.nextSegmentId++),n.childIndex===-1)i===null?t.rootSlots=r.id:(n=t.workingMap.get(i),n===void 0?(n=[i[1],i[2],[],r.id],Rr(n,i[0],t)):n[3]=r.id);else{if(i===null){if(e=t.rootSlots,e===null)e=t.rootSlots={};else if(typeof e==`number`)throw Error(a(491))}else if(o=t.workingMap,s=o.get(i),s===void 0)e={},s=[i[1],i[2],[],e],o.set(i,s),Rr(s,i[0],t);else if(e=s[3],e===null)e=s[3]={};else if(typeof e==`number`)throw Error(a(491));e[n.childIndex]=r.id}}}function dr(e,t){e=e.trackedPostpones,e!==null&&(t=t.trackedContentKeyPath,t!==null&&(t=e.workingMap.get(t),t!==void 0&&(t.length=4,t[2]=[],t[3]=null)))}function fr(e,t,n){return Wn(e,n,t.replay,t.node,t.childIndex,t.blockedBoundary,t.hoistableState,t.abortSet,t.keyPath,t.formatContext,t.context,t.treeContext,t.row,t.componentStack)}function pr(e,t,n){var r=t.blockedSegment,i=Gn(e,r.chunks.length,null,t.formatContext,r.lastPushedText,!0);return r.children.push(i),r.lastPushedText=!1,Un(e,n,t.node,t.childIndex,t.blockedBoundary,i,t.blockedPreamble,t.hoistableState,t.abortSet,t.keyPath,t.formatContext,t.context,t.treeContext,t.row,t.componentStack)}function mr(e,t,n,r){var i=t.formatContext,a=t.context,o=t.keyPath,s=t.treeContext,c=t.componentStack,l=t.blockedSegment;if(l===null){l=t.replay;try{return or(e,t,n,r)}catch(u){if(gn(),n=u===Wt?qt():u,e.status!==12&&typeof n==`object`&&n){if(typeof n.then==`function`){r=u===Wt?hn():null,e=fr(e,t,r).ping,n.then(e,e),t.formatContext=i,t.context=a,t.keyPath=o,t.treeContext=s,t.componentStack=c,t.replay=l,Ft(a);return}if(n.message===`Maximum call stack size exceeded`){n=u===Wt?hn():null,n=fr(e,t,n),e.pingedTasks.push(n),t.formatContext=i,t.context=a,t.keyPath=o,t.treeContext=s,t.componentStack=c,t.replay=l,Ft(a);return}}}}else{var u=l.children.length,d=l.chunks.length;try{return or(e,t,n,r)}catch(r){if(gn(),l.children.length=u,l.chunks.length=d,n=r===Wt?qt():r,e.status!==12&&typeof n==`object`&&n){if(typeof n.then==`function`){l=n,n=r===Wt?hn():null,e=pr(e,t,n).ping,l.then(e,e),t.formatContext=i,t.context=a,t.keyPath=o,t.treeContext=s,t.componentStack=c,Ft(a);return}if(n.message===`Maximum call stack size exceeded`){l=r===Wt?hn():null,l=pr(e,t,l),e.pingedTasks.push(l),t.formatContext=i,t.context=a,t.keyPath=o,t.treeContext=s,t.componentStack=c,Ft(a);return}}}}throw t.formatContext=i,t.context=a,t.keyPath=o,t.treeContext=s,Ft(a),n}function hr(e){var t=e.blockedBoundary,n=e.blockedSegment;n!==null&&(n.status=3,Sr(this,t,e.row,n))}function gr(e,t,n,r,i,o){for(var s=0;s<n.length;s++){var c=n[s];if(c.length===4)gr(e,t,c[2],c[3],i,o);else{c=c[5];var l=e,u=o,d=Hn(l,null,new Set,null,null);d.parentFlushed=!0,d.rootSegmentID=c,d.status=4,d.errorDigest=u,d.parentFlushed&&l.clientRenderedBoundaries.push(d)}}if(n.length=0,r!==null){if(t===null)throw Error(a(487));if(t.status!==4&&(t.status=4,t.errorDigest=o,t.parentFlushed&&e.clientRenderedBoundaries.push(t)),typeof r==`object`)for(var f in r)delete r[f]}}function _r(e,t,n){var r=e.blockedBoundary,i=e.blockedSegment;if(i!==null){if(i.status===6)return;i.status=3}var a=Jn(e.componentStack);if(r===null){if(t.status!==13&&t.status!==14){if(r=e.replay,r===null){t.trackedPostpones!==null&&i!==null?(r=t.trackedPostpones,Yn(t,n,a),ur(t,r,e,i),Sr(t,null,e.row,i)):(Yn(t,n,a),Xn(t,n));return}r.pendingTasks--,r.pendingTasks===0&&0<r.nodes.length&&(i=Yn(t,n,a),gr(t,null,r.nodes,r.slots,n,i)),t.pendingRootTasks--,t.pendingRootTasks===0&&yr(t)}}else{var o=t.trackedPostpones;if(r.status!==4){if(o!==null&&i!==null)return Yn(t,n,a),ur(t,o,e,i),r.fallbackAbortableTasks.forEach(function(e){return _r(e,t,n)}),r.fallbackAbortableTasks.clear(),Sr(t,r,e.row,i);r.status=4,i=Yn(t,n,a),r.status=4,r.errorDigest=i,dr(t,r),r.parentFlushed&&t.clientRenderedBoundaries.push(r)}r.pendingTasks--,i=r.row,i!==null&&--i.pendingTasks===0&&Zn(t,i),r.fallbackAbortableTasks.forEach(function(e){return _r(e,t,n)}),r.fallbackAbortableTasks.clear()}e=e.row,e!==null&&--e.pendingTasks===0&&Zn(t,e),t.allPendingTasks--,t.allPendingTasks===0&&br(t)}function vr(e,t){try{var n=e.renderState,r=n.onHeaders;if(r){var i=n.headers;if(i){n.headers=null;var a=i.preconnects;if(i.fontPreloads&&(a&&(a+=`, `),a+=i.fontPreloads),i.highImagePreloads&&(a&&(a+=`, `),a+=i.highImagePreloads),!t){var o=n.styles.values(),s=o.next();b:for(;0<i.remainingCapacity&&!s.done;s=o.next())for(var c=s.value.sheets.values(),l=c.next();0<i.remainingCapacity&&!l.done;l=c.next()){var u=l.value,d=u.props,f=d.href,p=u.props,m=mt(p.href,`style`,{crossOrigin:p.crossOrigin,integrity:p.integrity,nonce:p.nonce,type:p.type,fetchPriority:p.fetchPriority,referrerPolicy:p.referrerPolicy,media:p.media});if(0<=(i.remainingCapacity-=m.length+2))n.resets.style[f]=re,a&&(a+=`, `),a+=m,n.resets.style[f]=typeof d.crossOrigin==`string`||typeof d.integrity==`string`?[d.crossOrigin,d.integrity]:re;else break b}}r(a?{Link:a}:{})}}}catch(t){Yn(e,t,{})}}function yr(e){e.trackedPostpones===null&&vr(e,!0),e.trackedPostpones===null&&Er(e),e.onShellError=Ut,e=e.onShellReady,e()}function br(e){vr(e,e.trackedPostpones===null||e.completedRootSegment===null||e.completedRootSegment.status!==5),Er(e),e=e.onAllReady,e()}function xr(e,t){if(t.chunks.length===0&&t.children.length===1&&t.children[0].boundary===null&&t.children[0].id===-1){var n=t.children[0];n.id=t.id,n.parentFlushed=!0,n.status!==1&&n.status!==3&&n.status!==4||xr(e,n)}else e.completedSegments.push(t)}function Sr(e,t,n,r){if(n!==null&&(--n.pendingTasks===0?Zn(e,n):n.together&&$n(e,n)),e.allPendingTasks--,t===null){if(r!==null&&r.parentFlushed){if(e.completedRootSegment!==null)throw Error(a(389));e.completedRootSegment=r}e.pendingRootTasks--,e.pendingRootTasks===0&&yr(e)}else if(t.pendingTasks--,t.status!==4){if(t.pendingTasks===0){if(t.status===0&&(t.status=1),r!==null&&r.parentFlushed&&(r.status===1||r.status===3)&&xr(t,r),t.parentFlushed&&e.completedBoundaries.push(t),t.status===1)n=t.row,n!==null&&xt(n.hoistables,t.contentState),In(e,t)||(t.fallbackAbortableTasks.forEach(hr,e),t.fallbackAbortableTasks.clear(),n!==null&&--n.pendingTasks===0&&Zn(e,n)),e.pendingRootTasks===0&&e.trackedPostpones===null&&t.contentPreamble!==null&&Er(e);else if(t.status===5&&(t=t.row,t!==null)){if(e.trackedPostpones!==null){n=e.trackedPostpones;var i=t.next;if(i!==null&&(r=i.boundaries,r!==null))for(i.boundaries=null,i=0;i<r.length;i++){var o=r[i];lr(e,n,o),Sr(e,o,null,null)}}--t.pendingTasks===0&&Zn(e,t)}}else r===null||!r.parentFlushed||r.status!==1&&r.status!==3||(xr(t,r),t.completedSegments.length===1&&t.parentFlushed&&e.partialBoundaries.push(t)),t=t.row,t!==null&&t.together&&$n(e,t)}e.allPendingTasks===0&&br(e)}function Cr(e){if(e.status!==14&&e.status!==13){var t=kt,n=te.H;te.H=Dn;var r=te.A;te.A=kn;var i=Bn;Bn=e;var o=On;On=e.resumableState;try{var s=e.pingedTasks,c;for(c=0;c<s.length;c++){var l=s[c],u=e,d=l.blockedSegment;if(d===null){var f=u;if(l.replay.pendingTasks!==0){Ft(l.context);try{if(typeof l.replay.slots==`number`?ar(f,l,l.replay.slots,l.node,l.childIndex):sr(f,l),l.replay.pendingTasks===1&&0<l.replay.nodes.length)throw Error(a(488));l.replay.pendingTasks--,l.abortSet.delete(l),Sr(f,l.blockedBoundary,l.row,null)}catch(e){gn();var p=e===Wt?qt():e;if(typeof p==`object`&&p&&typeof p.then==`function`){var m=l.ping;p.then(m,m),l.thenableState=e===Wt?hn():null}else{l.replay.pendingTasks--,l.abortSet.delete(l);var h=Jn(l.componentStack);u=void 0;var g=f,_=l.blockedBoundary,v=f.status===12?f.fatalError:p,y=l.replay.nodes,b=l.replay.slots;u=Yn(g,v,h),gr(g,_,y,b,v,u),f.pendingRootTasks--,f.pendingRootTasks===0&&yr(f),f.allPendingTasks--,f.allPendingTasks===0&&br(f)}}}}else if(f=void 0,g=d,g.status===0){g.status=6,Ft(l.context);var x=g.children.length,S=g.chunks.length;try{sr(u,l),wt(g.chunks,u.renderState,g.lastPushedText,g.textEmbedded),l.abortSet.delete(l),g.status=1,Sr(u,l.blockedBoundary,l.row,g)}catch(e){gn(),g.children.length=x,g.chunks.length=S;var C=e===Wt?qt():u.status===12?u.fatalError:e;if(u.status===12&&u.trackedPostpones!==null){var w=u.trackedPostpones,T=Jn(l.componentStack);l.abortSet.delete(l),Yn(u,C,T),ur(u,w,l,g),Sr(u,l.blockedBoundary,l.row,g)}else if(typeof C==`object`&&C&&typeof C.then==`function`){g.status=0,l.thenableState=e===Wt?hn():null;var E=l.ping;C.then(E,E)}else{var D=Jn(l.componentStack);l.abortSet.delete(l),g.status=4;var O=l.blockedBoundary,k=l.row;if(k!==null&&--k.pendingTasks===0&&Zn(u,k),u.allPendingTasks--,f=Yn(u,C,D),O===null)Xn(u,C);else if(O.pendingTasks--,O.status!==4){O.status=4,O.errorDigest=f,dr(u,O);var A=O.row;A!==null&&--A.pendingTasks===0&&Zn(u,A),O.parentFlushed&&u.clientRenderedBoundaries.push(O),u.pendingRootTasks===0&&u.trackedPostpones===null&&O.contentPreamble!==null&&Er(u)}u.allPendingTasks===0&&br(u)}}}}s.splice(0,c),e.destination!==null&&Pr(e,e.destination)}catch(t){Yn(e,t,{}),Xn(e,t)}finally{On=o,te.H=n,te.A=r,n===Dn&&Ft(t),Bn=i}}}function wr(e,t,n){t.preambleChildren.length&&n.push(t.preambleChildren);for(var r=!1,i=0;i<t.children.length;i++)r=Tr(e,t.children[i],n)||r;return r}function Tr(e,t,n){var r=t.boundary;if(r===null)return wr(e,t,n);var i=r.contentPreamble,o=r.fallbackPreamble;if(i===null||o===null)return!1;switch(r.status){case 1:if(Re(e.renderState,i),e.byteSize+=r.byteSize,t=r.completedSegments[0],!t)throw Error(a(391));return wr(e,t,n);case 5:if(e.trackedPostpones!==null)return!0;case 4:if(t.status===1)return Re(e.renderState,o),wr(e,t,n);default:return!0}}function Er(e){if(e.completedRootSegment&&e.completedPreambleSegments===null){var t=[],n=e.byteSize,r=Tr(e,e.completedRootSegment,t),i=e.renderState.preamble;!1===r||i.headChunks&&i.bodyChunks?e.completedPreambleSegments=t:e.byteSize=n}}function Dr(e,t,n,r){switch(n.parentFlushed=!0,n.status){case 0:n.id=e.nextSegmentId++;case 5:return r=n.id,n.lastPushedText=!1,n.textEmbedded=!1,e=e.renderState,t.push(`<template id="`),t.push(e.placeholderPrefix),e=r.toString(16),t.push(e),t.push(`"></template>`);case 1:n.status=2;var i=!0,o=n.chunks,s=0;n=n.children;for(var c=0;c<n.length;c++){for(i=n[c];s<i.index;s++)t.push(o[s]);i=kr(e,t,i,r)}for(;s<o.length-1;s++)t.push(o[s]);return s<o.length&&(i=t.push(o[s])),i;case 3:return!0;default:throw Error(a(390))}}var Or=0;function kr(e,t,n,r){var i=n.boundary;if(i===null)return Dr(e,t,n,r);if(i.parentFlushed=!0,i.status===4){var o=i.row;return o!==null&&--o.pendingTasks===0&&Zn(e,o),e.renderState.generateStaticMarkup||(i=i.errorDigest,t.push(`<!--$!-->`),t.push(`<template`),i&&(t.push(` data-dgst="`),i=I(i),t.push(i),t.push(`"`)),t.push(`></template>`)),Dr(e,t,n,r),e=e.renderState.generateStaticMarkup?!0:t.push(`<!--/$-->`),e}if(i.status!==1)return i.status===0&&(i.rootSegmentID=e.nextSegmentId++),0<i.completedSegments.length&&e.partialBoundaries.push(i),Be(t,e.renderState,i.rootSegmentID),r&&xt(r,i.fallbackState),Dr(e,t,n,r),t.push(`<!--/$-->`);if(!Nr&&In(e,i)&&Or+i.byteSize>e.progressiveChunkSize)return i.rootSegmentID=e.nextSegmentId++,e.completedBoundaries.push(i),Be(t,e.renderState,i.rootSegmentID),Dr(e,t,n,r),t.push(`<!--/$-->`);if(Or+=i.byteSize,r&&xt(r,i.contentState),n=i.row,n!==null&&In(e,i)&&--n.pendingTasks===0&&Zn(e,n),e.renderState.generateStaticMarkup||t.push(`<!--$-->`),n=i.completedSegments,n.length!==1)throw Error(a(391));return kr(e,t,n[0],r),e=e.renderState.generateStaticMarkup?!0:t.push(`<!--/$-->`),e}function Ar(e,t,n,r){return Ve(t,e.renderState,n.parentFormatContext,n.id),kr(e,t,n,r),He(t,n.parentFormatContext)}function jr(e,t,n){Or=n.byteSize;for(var r=n.completedSegments,i=0;i<r.length;i++)Mr(e,t,n,r[i]);r.length=0,r=n.row,r!==null&&In(e,n)&&--r.pendingTasks===0&&Zn(e,r),Ze(t,n.contentState,e.renderState),r=e.resumableState,e=e.renderState,i=n.rootSegmentID,n=n.contentState;var a=e.stylesToHoist;return e.stylesToHoist=!1,t.push(e.startInlineScript),t.push(`>`),a?(!(r.instructions&4)&&(r.instructions|=4,t.push(`$RX=function(b,c,d,e,f){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),f&&(a.cstck=f),b._reactRetry&&b._reactRetry())};`)),!(r.instructions&2)&&(r.instructions|=2,t.push(`$RB=[];$RV=function(a){$RT=performance.now();for(var b=0;b<a.length;b+=2){var c=a[b],e=a[b+1];null!==e.parentNode&&e.parentNode.removeChild(e);var f=c.parentNode;if(f){var g=c.previousSibling,h=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d||"/&"===d)if(0===h)break;else h--;else"$"!==d&&"$?"!==d&&"$~"!==d&&"$!"!==d&&"&"!==d||h++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;e.firstChild;)f.insertBefore(e.firstChild,c);g.data="$";g._reactRetry&&requestAnimationFrame(g._reactRetry)}}a.length=0};
51
+ $RC=function(a,b){if(b=document.getElementById(b))(a=document.getElementById(a))?(a.previousSibling.data="$~",$RB.push(a,b),2===$RB.length&&("number"!==typeof $RT?requestAnimationFrame($RV.bind(null,$RB)):(a=performance.now(),setTimeout($RV.bind(null,$RB),2300>a&&2E3<a?2300-a:$RT+300-a)))):b.parentNode.removeChild(b)};`)),r.instructions&8?t.push(`$RR("`):(r.instructions|=8,t.push(`$RM=new Map;$RR=function(n,w,p){function u(q){this._p=null;q()}for(var r=new Map,t=document,h,b,e=t.querySelectorAll("link[data-precedence],style[data-precedence]"),v=[],k=0;b=e[k++];)"not all"===b.getAttribute("media")?v.push(b):("LINK"===b.tagName&&$RM.set(b.getAttribute("href"),b),r.set(b.dataset.precedence,h=b));e=0;b=[];var l,a;for(k=!0;;){if(k){var f=p[e++];if(!f){k=!1;e=0;continue}var c=!1,m=0;var d=f[m++];if(a=$RM.get(d)){var g=a._p;c=!0}else{a=t.createElement("link");a.href=d;a.rel=
52
+ "stylesheet";for(a.dataset.precedence=l=f[m++];g=f[m++];)a.setAttribute(g,f[m++]);g=a._p=new Promise(function(q,x){a.onload=u.bind(a,q);a.onerror=u.bind(a,x)});$RM.set(d,a)}d=a.getAttribute("media");!g||d&&!matchMedia(d).matches||b.push(g);if(c)continue}else{a=v[e++];if(!a)break;l=a.getAttribute("data-precedence");a.removeAttribute("media")}c=r.get(l)||h;c===h&&(h=a);r.set(l,a);c?c.parentNode.insertBefore(a,c.nextSibling):(c=t.head,c.insertBefore(a,c.firstChild))}if(p=document.getElementById(n))p.previousSibling.data=
53
+ "$~";Promise.all(b).then($RC.bind(null,n,w),$RX.bind(null,n,"CSS failed to load"))};$RR("`))):(!(r.instructions&2)&&(r.instructions|=2,t.push(`$RB=[];$RV=function(a){$RT=performance.now();for(var b=0;b<a.length;b+=2){var c=a[b],e=a[b+1];null!==e.parentNode&&e.parentNode.removeChild(e);var f=c.parentNode;if(f){var g=c.previousSibling,h=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d||"/&"===d)if(0===h)break;else h--;else"$"!==d&&"$?"!==d&&"$~"!==d&&"$!"!==d&&"&"!==d||h++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;e.firstChild;)f.insertBefore(e.firstChild,c);g.data="$";g._reactRetry&&requestAnimationFrame(g._reactRetry)}}a.length=0};
54
+ $RC=function(a,b){if(b=document.getElementById(b))(a=document.getElementById(a))?(a.previousSibling.data="$~",$RB.push(a,b),2===$RB.length&&("number"!==typeof $RT?requestAnimationFrame($RV.bind(null,$RB)):(a=performance.now(),setTimeout($RV.bind(null,$RB),2300>a&&2E3<a?2300-a:$RT+300-a)))):b.parentNode.removeChild(b)};`)),t.push(`$RC("`)),r=i.toString(16),t.push(e.boundaryPrefix),t.push(r),t.push(`","`),t.push(e.segmentPrefix),t.push(r),a?(t.push(`",`),it(t,n)):t.push(`"`),n=t.push(`)<\/script>`),ze(t,e)&&n}function Mr(e,t,n,r){if(r.status===2)return!0;var i=n.contentState,o=r.id;if(o===-1){if((r.id=n.rootSegmentID)===-1)throw Error(a(392));return Ar(e,t,r,i)}return o===n.rootSegmentID?Ar(e,t,r,i):(Ar(e,t,r,i),n=e.resumableState,e=e.renderState,t.push(e.startInlineScript),t.push(`>`),n.instructions&1?t.push(`$RS("`):(n.instructions|=1,t.push(`$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("`)),t.push(e.segmentPrefix),o=o.toString(16),t.push(o),t.push(`","`),t.push(e.placeholderPrefix),t.push(o),t=t.push(`")<\/script>`),t)}var Nr=!1;function Pr(e,t){try{if(!(0<e.pendingRootTasks)){var n,r=e.completedRootSegment;if(r!==null){if(r.status===5)return;var i=e.completedPreambleSegments;if(i===null)return;Or=e.byteSize;var a=e.resumableState,o=e.renderState,s=o.preamble,c=s.htmlChunks,l=s.headChunks,u;if(c){for(u=0;u<c.length;u++)t.push(c[u]);if(l)for(u=0;u<l.length;u++)t.push(l[u]);else{var d=Pe(`head`);t.push(d),t.push(`>`)}}else if(l)for(u=0;u<l.length;u++)t.push(l[u]);var f=o.charsetChunks;for(u=0;u<f.length;u++)t.push(f[u]);f.length=0,o.preconnects.forEach(Qe,t),o.preconnects.clear();var p=o.viewportChunks;for(u=0;u<p.length;u++)t.push(p[u]);p.length=0,o.fontPreloads.forEach(Qe,t),o.fontPreloads.clear(),o.highImagePreloads.forEach(Qe,t),o.highImagePreloads.clear(),ie=o,o.styles.forEach(et,t),ie=null;var m=o.importMapChunks;for(u=0;u<m.length;u++)t.push(m[u]);m.length=0,o.bootstrapScripts.forEach(Qe,t),o.scripts.forEach(Qe,t),o.scripts.clear(),o.bulkPreloads.forEach(Qe,t),o.bulkPreloads.clear(),a.instructions|=32;var h=o.hoistableChunks;for(u=0;u<h.length;u++)t.push(h[u]);for(a=h.length=0;a<i.length;a++){var g=i[a];for(o=0;o<g.length;o++)kr(e,t,g[o],null)}var _=e.renderState.preamble,v=_.headChunks;if(_.htmlChunks||v){var y=Le(`head`);t.push(y)}var b=_.bodyChunks;if(b)for(i=0;i<b.length;i++)t.push(b[i]);kr(e,t,r,null),e.completedRootSegment=null;var x=e.renderState;if(e.allPendingTasks!==0||e.clientRenderedBoundaries.length!==0||e.completedBoundaries.length!==0||e.trackedPostpones!==null&&(e.trackedPostpones.rootNodes.length!==0||e.trackedPostpones.rootSlots!==null)){var S=e.resumableState;if(!(S.instructions&64)){if(S.instructions|=64,t.push(x.startInlineScript),!(S.instructions&32)){S.instructions|=32;var C=`_`+S.idPrefix+`R_`;t.push(` id="`);var w=I(C);t.push(w),t.push(`"`)}t.push(`>`),t.push(`requestAnimationFrame(function(){$RT=performance.now()});`),t.push(`<\/script>`)}}ze(t,x)}var T=e.renderState;r=0;var E=T.viewportChunks;for(r=0;r<E.length;r++)t.push(E[r]);E.length=0,T.preconnects.forEach(Qe,t),T.preconnects.clear(),T.fontPreloads.forEach(Qe,t),T.fontPreloads.clear(),T.highImagePreloads.forEach(Qe,t),T.highImagePreloads.clear(),T.styles.forEach(nt,t),T.scripts.forEach(Qe,t),T.scripts.clear(),T.bulkPreloads.forEach(Qe,t),T.bulkPreloads.clear();var D=T.hoistableChunks;for(r=0;r<D.length;r++)t.push(D[r]);D.length=0;var O=e.clientRenderedBoundaries;for(n=0;n<O.length;n++){var k=O[n];T=t;var A=e.resumableState,j=e.renderState,M=k.rootSegmentID,N=k.errorDigest;T.push(j.startInlineScript),T.push(`>`),A.instructions&4?T.push(`$RX("`):(A.instructions|=4,T.push(`$RX=function(b,c,d,e,f){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),f&&(a.cstck=f),b._reactRetry&&b._reactRetry())};;$RX("`)),T.push(j.boundaryPrefix);var P=M.toString(16);if(T.push(P),T.push(`"`),N){T.push(`,`);var F=We(N||``);T.push(F)}var L=T.push(`)<\/script>`);if(!L){e.destination=null,n++,O.splice(0,n);return}}O.splice(0,n);var ee=e.completedBoundaries;for(n=0;n<ee.length;n++)if(!jr(e,t,ee[n])){e.destination=null,n++,ee.splice(0,n);return}ee.splice(0,n),Nr=!0;var R=e.partialBoundaries;for(n=0;n<R.length;n++){var z=R[n];a:{O=e,k=t,Or=z.byteSize;var te=z.completedSegments;for(L=0;L<te.length;L++)if(!Mr(O,k,z,te[L])){L++,te.splice(0,L);var ne=!1;break a}te.splice(0,L);var B=z.row;B!==null&&B.together&&z.pendingTasks===1&&(B.pendingTasks===1?Qn(O,B,B.hoistables):B.pendingTasks--),ne=Ze(k,z.contentState,O.renderState)}if(!ne){e.destination=null,n++,R.splice(0,n);return}}R.splice(0,n),Nr=!1;var V=e.completedBoundaries;for(n=0;n<V.length;n++)if(!jr(e,t,V[n])){e.destination=null,n++,V.splice(0,n);return}V.splice(0,n)}}finally{Nr=!1,e.allPendingTasks===0&&e.clientRenderedBoundaries.length===0&&e.completedBoundaries.length===0&&(e.flushScheduled=!1,n=e.resumableState,n.hasBody&&(R=Le(`body`),t.push(R)),n.hasHtml&&(n=Le(`html`),t.push(n)),e.status=14,t.push(null),e.destination=null)}}function Fr(e){if(!1===e.flushScheduled&&e.pingedTasks.length===0&&e.destination!==null){e.flushScheduled=!0;var t=e.destination;t?Pr(e,t):e.flushScheduled=!1}}function Ir(e,t){if(e.status===13)e.status=14,t.destroy(e.fatalError);else if(e.status!==14&&e.destination===null){e.destination=t;try{Pr(e,t)}catch(t){Yn(e,t,{}),Xn(e,t)}}}function Lr(e,t){(e.status===11||e.status===10)&&(e.status=12);try{var n=e.abortableTasks;if(0<n.size){var r=t===void 0?Error(a(432)):typeof t==`object`&&t&&typeof t.then==`function`?Error(a(530)):t;e.fatalError=r,n.forEach(function(t){return _r(t,e,r)}),n.clear()}e.destination!==null&&Pr(e,e.destination)}catch(t){Yn(e,t,{}),Xn(e,t)}}function Rr(e,t,n){if(t===null)n.rootNodes.push(e);else{var r=n.workingMap,i=r.get(t);i===void 0&&(i=[t[1],t[2],[],null],r.set(t,i),Rr(i,t[0],n)),i[2].push(e)}}function zr(){}function Br(e,t,n,r){var i=!1,o=null,s=``,c=!1;if(t=se(t?t.identifierPrefix:void 0),e=zn(e,t,St(t,n),ce(0,null,0,null),1/0,zr,void 0,function(){c=!0},void 0,void 0,void 0),e.flushScheduled=e.destination!==null,Cr(e),e.status===10&&(e.status=11),e.trackedPostpones===null&&vr(e,e.pendingRootTasks===0),Lr(e,r),Ir(e,{push:function(e){return e!==null&&(s+=e),!0},destroy:function(e){i=!0,o=e}}),i&&o!==r)throw o;if(!c)throw Error(a(426));return s}e.renderToStaticMarkup=function(e,t){return Br(e,t,!0,`The server used "renderToStaticMarkup" which does not support Suspense. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server`)},e.renderToString=function(e,t){return Br(e,t,!1,`The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server`)},e.version=`19.2.8`})),WL=t((e=>{var t=n(),i=r();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}var o=Symbol.for(`react.transitional.element`),s=Symbol.for(`react.portal`),c=Symbol.for(`react.fragment`),l=Symbol.for(`react.strict_mode`),u=Symbol.for(`react.profiler`),d=Symbol.for(`react.consumer`),f=Symbol.for(`react.context`),p=Symbol.for(`react.forward_ref`),m=Symbol.for(`react.suspense`),h=Symbol.for(`react.suspense_list`),g=Symbol.for(`react.memo`),_=Symbol.for(`react.lazy`),v=Symbol.for(`react.scope`),y=Symbol.for(`react.activity`),b=Symbol.for(`react.legacy_hidden`),x=Symbol.for(`react.memo_cache_sentinel`),S=Symbol.for(`react.view_transition`),C=Symbol.iterator;function w(e){return typeof e!=`object`||!e?null:(e=C&&e[C]||e[`@@iterator`],typeof e==`function`?e:null)}var T=Array.isArray;function E(e,t){var n=e.length&3,r=e.length-n,i=t;for(t=0;t<r;){var a=e.charCodeAt(t)&255|(e.charCodeAt(++t)&255)<<8|(e.charCodeAt(++t)&255)<<16|(e.charCodeAt(++t)&255)<<24;++t,a=3432918353*(a&65535)+((3432918353*(a>>>16)&65535)<<16)&4294967295,a=a<<15|a>>>17,a=461845907*(a&65535)+((461845907*(a>>>16)&65535)<<16)&4294967295,i^=a,i=i<<13|i>>>19,i=5*(i&65535)+((5*(i>>>16)&65535)<<16)&4294967295,i=(i&65535)+27492+(((i>>>16)+58964&65535)<<16)}switch(a=0,n){case 3:a^=(e.charCodeAt(t+2)&255)<<16;case 2:a^=(e.charCodeAt(t+1)&255)<<8;case 1:a^=e.charCodeAt(t)&255,a=3432918353*(a&65535)+((3432918353*(a>>>16)&65535)<<16)&4294967295,a=a<<15|a>>>17,i^=461845907*(a&65535)+((461845907*(a>>>16)&65535)<<16)&4294967295}return i^=e.length,i^=i>>>16,i=2246822507*(i&65535)+((2246822507*(i>>>16)&65535)<<16)&4294967295,i^=i>>>13,i=3266489909*(i&65535)+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^i>>>16)>>>0}var D=new MessageChannel,O=[];D.port1.onmessage=function(){var e=O.shift();e&&e()};function k(e){O.push(e),D.port2.postMessage(null)}function A(e){setTimeout(function(){throw e})}var j=Promise,M=typeof queueMicrotask==`function`?queueMicrotask:function(e){j.resolve(null).then(e).catch(A)},N=null,P=0;function F(e,t){if(t.byteLength!==0){if(2048<t.byteLength)0<P&&(e.enqueue(new Uint8Array(N.buffer,0,P)),N=new Uint8Array(2048),P=0),e.enqueue(t);else{var n=N.length-P;n<t.byteLength&&(n===0?e.enqueue(N):(N.set(t.subarray(0,n),P),e.enqueue(N),t=t.subarray(n)),N=new Uint8Array(2048),P=0),N.set(t,P),P+=t.byteLength}}}function I(e,t){return F(e,t),!0}function L(e){N&&0<P&&(e.enqueue(new Uint8Array(N.buffer,0,P)),N=null,P=0)}var ee=new TextEncoder;function R(e){return ee.encode(e)}function z(e){return ee.encode(e)}function te(e){return e.byteLength}function ne(e,t){typeof e.error==`function`?e.error(t):e.close()}var B=Object.assign,V=Object.prototype.hasOwnProperty,re=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),ie={},ae={};function oe(e){return V.call(ae,e)?!0:V.call(ie,e)?!1:re.test(e)?ae[e]=!0:(ie[e]=!0,!1)}var se=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `)),ce=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),le=/["'&<>]/;function H(e){if(typeof e==`boolean`||typeof e==`number`||typeof e==`bigint`)return``+e;e=``+e;var t=le.exec(e);if(t){var n=``,r,i=0;for(r=t.index;r<e.length;r++){switch(e.charCodeAt(r)){case 34:t=`&quot;`;break;case 38:t=`&amp;`;break;case 39:t=`&#x27;`;break;case 60:t=`&lt;`;break;case 62:t=`&gt;`;break;default:continue}i!==r&&(n+=e.slice(i,r)),i=r+1,n+=t}e=i===r?n:n+e.slice(i,r)}return e}var ue=/([A-Z])/g,de=/^ms-/,fe=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function pe(e){return fe.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}var me=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge={pending:!1,data:null,method:null,action:null},_e=he.d;he.d={f:_e.f,r:_e.r,D:_r,C:vr,L:yr,m:br,X:Sr,S:xr,M:Cr};var ve=[],ye=null;z(`"></template>`);var be=z(`<script`),xe=z(`<\/script>`),U=z(`<script src="`),Se=z(`<script type="module" src="`),Ce=z(` nonce="`),we=z(` integrity="`),Te=z(` crossorigin="`),Ee=z(` async=""><\/script>`),De=z(`<style`),Oe=/(<\/|<)(s)(cript)/gi;function ke(e,t,n,r){return``+t+(n===`s`?`\\u0073`:`\\u0053`)+r}var Ae=z(`<script type="importmap">`),je=z(`<\/script>`);function Me(e,t,n,r,i,a){n=typeof t==`string`?t:t&&t.script;var o=n===void 0?be:z(`<script nonce="`+H(n)+`"`),s=typeof t==`string`?void 0:t&&t.style,c=s===void 0?De:z(`<style nonce="`+H(s)+`"`),l=e.idPrefix,u=[],d=e.bootstrapScriptContent,f=e.bootstrapScripts,p=e.bootstrapModules;if(d!==void 0&&(u.push(o),lr(u,e),u.push(ot,R((``+d).replace(Oe,ke)),xe)),d=[],r!==void 0&&(d.push(Ae),d.push(R((``+JSON.stringify(r)).replace(Oe,ke))),d.push(je)),r=i?{preconnects:``,fontPreloads:``,highImagePreloads:``,remainingCapacity:2+(typeof a==`number`?a:2e3)}:null,i={placeholderPrefix:z(l+`P:`),segmentPrefix:z(l+`S:`),boundaryPrefix:z(l+`B:`),startInlineScript:o,startInlineStyle:c,preamble:Pe(),externalRuntimeScript:null,bootstrapChunks:u,importMapChunks:d,onHeaders:i,headers:r,resets:{font:{},dns:{},connect:{default:{},anonymous:{},credentials:{}},image:{},style:{}},charsetChunks:[],viewportChunks:[],hoistableChunks:[],preconnects:new Set,fontPreloads:new Set,highImagePreloads:new Set,styles:new Map,bootstrapScripts:new Set,scripts:new Set,bulkPreloads:new Set,preloads:{images:new Map,stylesheets:new Map,scripts:new Map,moduleScripts:new Map},nonce:{script:n,style:s},hoistableState:null,stylesToHoist:!1},f!==void 0)for(r=0;r<f.length;r++)l=f[r],s=o=void 0,c={rel:`preload`,as:`script`,fetchPriority:`low`,nonce:t},typeof l==`string`?c.href=a=l:(c.href=a=l.src,c.integrity=s=typeof l.integrity==`string`?l.integrity:void 0,c.crossOrigin=o=typeof l==`string`||l.crossOrigin==null?void 0:l.crossOrigin===`use-credentials`?`use-credentials`:``),l=e,d=a,l.scriptResources[d]=null,l.moduleScriptResources[d]=null,l=[],mt(l,c),i.bootstrapScripts.add(l),u.push(U,R(H(a)),Xe),n&&u.push(Ce,R(H(n)),Xe),typeof s==`string`&&u.push(we,R(H(s)),Xe),typeof o==`string`&&u.push(Te,R(H(o)),Xe),lr(u,e),u.push(Ee);if(p!==void 0)for(t=0;t<p.length;t++)s=p[t],a=r=void 0,o={rel:`modulepreload`,fetchPriority:`low`,nonce:n},typeof s==`string`?o.href=f=s:(o.href=f=s.src,o.integrity=a=typeof s.integrity==`string`?s.integrity:void 0,o.crossOrigin=r=typeof s==`string`||s.crossOrigin==null?void 0:s.crossOrigin===`use-credentials`?`use-credentials`:``),s=e,c=f,s.scriptResources[c]=null,s.moduleScriptResources[c]=null,s=[],mt(s,o),i.bootstrapScripts.add(s),u.push(Se,R(H(f)),Xe),n&&u.push(Ce,R(H(n)),Xe),typeof a==`string`&&u.push(we,R(H(a)),Xe),typeof r==`string`&&u.push(Te,R(H(r)),Xe),lr(u,e),u.push(Ee);return i}function Ne(e,t,n,r,i){return{idPrefix:e===void 0?``:e,nextFormID:0,streamingFormat:0,bootstrapScriptContent:n,bootstrapScripts:r,bootstrapModules:i,instructions:0,hasBody:!1,hasHtml:!1,unknownResources:{},dnsResources:{},connectResources:{default:{},anonymous:{},credentials:{}},imageResources:{},styleResources:{},scriptResources:{},moduleUnknownResources:{},moduleScriptResources:{}}}function Pe(){return{htmlChunks:null,headChunks:null,bodyChunks:null}}function Fe(e,t,n,r){return{insertionMode:e,selectedValue:t,tagScope:n,viewTransition:r}}function Ie(e){return Fe(e===`http://www.w3.org/2000/svg`?4:e===`http://www.w3.org/1998/Math/MathML`?5:0,null,0,null)}function Le(e,t,n){var r=e.tagScope&-25;switch(t){case`noscript`:return Fe(2,null,r|1,null);case`select`:return Fe(2,n.value==null?n.defaultValue:n.value,r,null);case`svg`:return Fe(4,null,r,null);case`picture`:return Fe(2,null,r|2,null);case`math`:return Fe(5,null,r,null);case`foreignObject`:return Fe(2,null,r,null);case`table`:return Fe(6,null,r,null);case`thead`:case`tbody`:case`tfoot`:return Fe(7,null,r,null);case`colgroup`:return Fe(9,null,r,null);case`tr`:return Fe(8,null,r,null);case`head`:if(2>e.insertionMode)return Fe(3,null,r,null);break;case`html`:if(e.insertionMode===0)return Fe(1,null,r,null)}return 6<=e.insertionMode||2>e.insertionMode?Fe(2,null,r,null):e.tagScope===r?e:Fe(e.insertionMode,e.selectedValue,r,null)}function Re(e){return e===null?null:{update:e.update,enter:`none`,exit:`none`,share:e.update,name:e.autoName,autoName:e.autoName,nameIdx:0}}function ze(e,t){return t.tagScope&32&&(e.instructions|=128),Fe(t.insertionMode,t.selectedValue,t.tagScope|12,Re(t.viewTransition))}function Be(e,t){e=Re(t.viewTransition);var n=t.tagScope|16;return e!==null&&e.share!==`none`&&(n|=64),Fe(t.insertionMode,t.selectedValue,n,e)}var Ve=z(`<!-- -->`);function He(e,t,n,r){return t===``?r:(r&&e.push(Ve),e.push(R(H(t))),!0)}var Ue=new Map,We=z(` style="`),Ge=z(`:`),Ke=z(`;`);function qe(e,t){if(typeof t!=`object`)throw Error(a(62));var n=!0,r;for(r in t)if(V.call(t,r)){var i=t[r];if(i!=null&&typeof i!=`boolean`&&i!==``){if(r.indexOf(`--`)===0){var o=R(H(r));i=R(H((``+i).trim()))}else o=Ue.get(r),o===void 0&&(o=z(H(r.replace(ue,`-$1`).toLowerCase().replace(de,`-ms-`))),Ue.set(r,o)),i=typeof i==`number`?i===0||se.has(r)?R(``+i):R(i+`px`):R(H((``+i).trim()));n?(n=!1,e.push(We,o,Ge,i)):e.push(Ke,o,Ge,i)}}n||e.push(Xe)}var Je=z(` `),Ye=z(`="`),Xe=z(`"`),Ze=z(`=""`);function Qe(e,t,n){n&&typeof n!=`function`&&typeof n!=`symbol`&&e.push(Je,R(t),Ze)}function $e(e,t,n){typeof n!=`function`&&typeof n!=`symbol`&&typeof n!=`boolean`&&e.push(Je,R(t),Ye,R(H(n)),Xe)}var W=z(H(`javascript:throw new Error('React form unexpectedly submitted.')`)),et=z(`<input type="hidden"`);function tt(e,t){this.push(et),nt(e),$e(this,`name`,t),$e(this,`value`,e),this.push(st)}function nt(e){if(typeof e!=`string`)throw Error(a(480))}function rt(e,t){if(typeof t.$$FORM_ACTION==`function`){var n=e.nextFormID++;e=e.idPrefix+n;try{var r=t.$$FORM_ACTION(e);return r&&r.data?.forEach(nt),r}catch(e){if(typeof e==`object`&&e&&typeof e.then==`function`)throw e}}return null}function it(e,t,n,r,i,a,o,s){var c=null;if(typeof r==`function`){var l=rt(t,r);l===null?(e.push(Je,R(`formAction`),Ye,W,Xe),o=a=i=r=s=null,ft(t,n)):(s=l.name,r=l.action||``,i=l.encType,a=l.method,o=l.target,c=l.data)}return s!=null&&at(e,`name`,s),r!=null&&at(e,`formAction`,r),i!=null&&at(e,`formEncType`,i),a!=null&&at(e,`formMethod`,a),o!=null&&at(e,`formTarget`,o),c}function at(e,t,n){switch(t){case`className`:$e(e,`class`,n);break;case`tabIndex`:$e(e,`tabindex`,n);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:$e(e,t,n);break;case`style`:qe(e,n);break;case`src`:case`href`:if(n===``)break;case`action`:case`formAction`:if(n==null||typeof n==`function`||typeof n==`symbol`||typeof n==`boolean`)break;n=pe(``+n),e.push(Je,R(t),Ye,R(H(n)),Xe);break;case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`ref`:break;case`autoFocus`:case`multiple`:case`muted`:Qe(e,t.toLowerCase(),n);break;case`xlinkHref`:if(typeof n==`function`||typeof n==`symbol`||typeof n==`boolean`)break;n=pe(``+n),e.push(Je,R(`xlink:href`),Ye,R(H(n)),Xe);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:typeof n!=`function`&&typeof n!=`symbol`&&e.push(Je,R(t),Ye,R(H(n)),Xe);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:n&&typeof n!=`function`&&typeof n!=`symbol`&&e.push(Je,R(t),Ze);break;case`capture`:case`download`:!0===n?e.push(Je,R(t),Ze):!1!==n&&typeof n!=`function`&&typeof n!=`symbol`&&e.push(Je,R(t),Ye,R(H(n)),Xe);break;case`cols`:case`rows`:case`size`:case`span`:typeof n!=`function`&&typeof n!=`symbol`&&!isNaN(n)&&1<=n&&e.push(Je,R(t),Ye,R(H(n)),Xe);break;case`rowSpan`:case`start`:typeof n==`function`||typeof n==`symbol`||isNaN(n)||e.push(Je,R(t),Ye,R(H(n)),Xe);break;case`xlinkActuate`:$e(e,`xlink:actuate`,n);break;case`xlinkArcrole`:$e(e,`xlink:arcrole`,n);break;case`xlinkRole`:$e(e,`xlink:role`,n);break;case`xlinkShow`:$e(e,`xlink:show`,n);break;case`xlinkTitle`:$e(e,`xlink:title`,n);break;case`xlinkType`:$e(e,`xlink:type`,n);break;case`xmlBase`:$e(e,`xml:base`,n);break;case`xmlLang`:$e(e,`xml:lang`,n);break;case`xmlSpace`:$e(e,`xml:space`,n);break;default:if((!(2<t.length)||t[0]!==`o`&&t[0]!==`O`||t[1]!==`n`&&t[1]!==`N`)&&(t=ce.get(t)||t,oe(t))){switch(typeof n){case`function`:case`symbol`:return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`)return}e.push(Je,R(t),Ye,R(H(n)),Xe)}}}var ot=z(`>`),st=z(`/>`);function ct(e,t,n){if(t!=null){if(n!=null)throw Error(a(60));if(typeof t!=`object`||!(`__html`in t))throw Error(a(61));t=t.__html,t!=null&&e.push(R(``+t))}}function lt(e){var n=``;return t.Children.forEach(e,function(e){e!=null&&(n+=e)}),n}var ut=z(` selected=""`),dt=z(`addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error('React form unexpectedly submitted.')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.ownerDocument||c,(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,d,b))}});`);function ft(e,t){if(!(e.instructions&16)){e.instructions|=16;var n=t.preamble,r=t.bootstrapChunks;(n.htmlChunks||n.headChunks)&&r.length===0?(r.push(t.startInlineScript),lr(r,e),r.push(ot,dt,xe)):r.unshift(t.startInlineScript,ot,dt,xe)}}var G=z(`<!--F!-->`),pt=z(`<!--F-->`);function mt(e,t){for(var n in e.push(Ot(`link`)),t)if(V.call(t,n)){var r=t[n];if(r!=null)switch(n){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(399,`link`));default:at(e,n,r)}}return e.push(st),null}var ht=/(<\/|<)(s)(tyle)/gi;function gt(e,t,n,r){return``+t+(n===`s`?`\\73 `:`\\53 `)+r}function _t(e,t,n){for(var r in e.push(Ot(n)),t)if(V.call(t,r)){var i=t[r];if(i!=null)switch(r){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(399,n));default:at(e,r,i)}}return e.push(st),null}function vt(e,t){e.push(Ot(`title`));var n=null,r=null,i;for(i in t)if(V.call(t,i)){var a=t[i];if(a!=null)switch(i){case`children`:n=a;break;case`dangerouslySetInnerHTML`:r=a;break;default:at(e,i,a)}}return e.push(ot),t=Array.isArray(n)?2>n.length?n[0]:null:n,typeof t!=`function`&&typeof t!=`symbol`&&t!=null&&e.push(R(H(``+t))),ct(e,r,n),e.push(Mt(`title`)),null}var yt=z(`<!--head-->`),bt=z(`<!--body-->`),xt=z(`<!--html-->`);function St(e,t){e.push(Ot(`script`));var n=null,r=null,i;for(i in t)if(V.call(t,i)){var a=t[i];if(a!=null)switch(i){case`children`:n=a;break;case`dangerouslySetInnerHTML`:r=a;break;default:at(e,i,a)}}return e.push(ot),ct(e,r,n),typeof n==`string`&&e.push(R((``+n).replace(Oe,ke))),e.push(Mt(`script`)),null}function Ct(e,t,n){e.push(Ot(n));var r=n=null,i;for(i in t)if(V.call(t,i)){var a=t[i];if(a!=null)switch(i){case`children`:n=a;break;case`dangerouslySetInnerHTML`:r=a;break;default:at(e,i,a)}}return e.push(ot),ct(e,r,n),n}function wt(e,t,n){e.push(Ot(n));var r=n=null,i;for(i in t)if(V.call(t,i)){var a=t[i];if(a!=null)switch(i){case`children`:n=a;break;case`dangerouslySetInnerHTML`:r=a;break;default:at(e,i,a)}}return e.push(ot),ct(e,r,n),typeof n==`string`?(e.push(R(H(n))),null):n}var Tt=z(`
55
+ `),Et=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Dt=new Map;function Ot(e){var t=Dt.get(e);if(t===void 0){if(!Et.test(e))throw Error(a(65,e));t=z(`<`+e),Dt.set(e,t)}return t}var kt=z(`<!DOCTYPE html>`);function At(e,t,n,r,i,o,s,c,l){switch(t){case`div`:case`span`:case`svg`:case`path`:break;case`a`:e.push(Ot(`a`));var u=null,d=null,f;for(f in n)if(V.call(n,f)){var p=n[f];if(p!=null)switch(f){case`children`:u=p;break;case`dangerouslySetInnerHTML`:d=p;break;case`href`:p===``?$e(e,`href`,``):at(e,f,p);break;default:at(e,f,p)}}if(e.push(ot),ct(e,d,u),typeof u==`string`){e.push(R(H(u)));var m=null}else m=u;return m;case`g`:case`p`:case`li`:break;case`select`:e.push(Ot(`select`));var h=null,g=null,_;for(_ in n)if(V.call(n,_)){var v=n[_];if(v!=null)switch(_){case`children`:h=v;break;case`dangerouslySetInnerHTML`:g=v;break;case`defaultValue`:case`value`:break;default:at(e,_,v)}}return e.push(ot),ct(e,g,h),h;case`option`:var y=c.selectedValue;e.push(Ot(`option`));var b=null,x=null,S=null,C=null,w;for(w in n)if(V.call(n,w)){var E=n[w];if(E!=null)switch(w){case`children`:b=E;break;case`selected`:S=E;break;case`dangerouslySetInnerHTML`:C=E;break;case`value`:x=E;default:at(e,w,E)}}if(y!=null){var D=x===null?lt(b):``+x;if(T(y)){for(var O=0;O<y.length;O++)if(``+y[O]===D){e.push(ut);break}}else``+y===D&&e.push(ut)}else S&&e.push(ut);return e.push(ot),ct(e,C,b),b;case`textarea`:e.push(Ot(`textarea`));var k=null,A=null,j=null,M;for(M in n)if(V.call(n,M)){var N=n[M];if(N!=null)switch(M){case`children`:j=N;break;case`value`:k=N;break;case`defaultValue`:A=N;break;case`dangerouslySetInnerHTML`:throw Error(a(91));default:at(e,M,N)}}if(k===null&&A!==null&&(k=A),e.push(ot),j!=null){if(k!=null)throw Error(a(92));if(T(j)){if(1<j.length)throw Error(a(93));k=``+j[0]}k=``+j}return typeof k==`string`&&k[0]===`
56
+ `&&e.push(Tt),k!==null&&e.push(R(H(``+k))),null;case`input`:e.push(Ot(`input`));var P=null,F=null,I=null,L=null,ee=null,z=null,te=null,ne=null,re=null,ie;for(ie in n)if(V.call(n,ie)){var ae=n[ie];if(ae!=null)switch(ie){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(399,`input`));case`name`:P=ae;break;case`formAction`:F=ae;break;case`formEncType`:I=ae;break;case`formMethod`:L=ae;break;case`formTarget`:ee=ae;break;case`defaultChecked`:re=ae;break;case`defaultValue`:te=ae;break;case`checked`:ne=ae;break;case`value`:z=ae;break;default:at(e,ie,ae)}}var se=it(e,r,i,F,I,L,ee,P);return ne===null?re!==null&&Qe(e,`checked`,re):Qe(e,`checked`,ne),z===null?te!==null&&at(e,`value`,te):at(e,`value`,z),e.push(st),se?.forEach(tt,e),null;case`button`:e.push(Ot(`button`));var ce=null,le=null,ue=null,de=null,fe=null,me=null,he=null,ge;for(ge in n)if(V.call(n,ge)){var _e=n[ge];if(_e!=null)switch(ge){case`children`:ce=_e;break;case`dangerouslySetInnerHTML`:le=_e;break;case`name`:ue=_e;break;case`formAction`:de=_e;break;case`formEncType`:fe=_e;break;case`formMethod`:me=_e;break;case`formTarget`:he=_e;break;default:at(e,ge,_e)}}var ye=it(e,r,i,de,fe,me,he,ue);if(e.push(ot),ye?.forEach(tt,e),ct(e,le,ce),typeof ce==`string`){e.push(R(H(ce)));var be=null}else be=ce;return be;case`form`:e.push(Ot(`form`));var xe=null,U=null,Se=null,Ce=null,we=null,Te=null,Ee;for(Ee in n)if(V.call(n,Ee)){var De=n[Ee];if(De!=null)switch(Ee){case`children`:xe=De;break;case`dangerouslySetInnerHTML`:U=De;break;case`action`:Se=De;break;case`encType`:Ce=De;break;case`method`:we=De;break;case`target`:Te=De;break;default:at(e,Ee,De)}}var Oe=null,ke=null;if(typeof Se==`function`){var Ae=rt(r,Se);Ae===null?(e.push(Je,R(`action`),Ye,W,Xe),Te=we=Ce=Se=null,ft(r,i)):(Se=Ae.action||``,Ce=Ae.encType,we=Ae.method,Te=Ae.target,Oe=Ae.data,ke=Ae.name)}if(Se!=null&&at(e,`action`,Se),Ce!=null&&at(e,`encType`,Ce),we!=null&&at(e,`method`,we),Te!=null&&at(e,`target`,Te),e.push(ot),ke!==null&&(e.push(et),$e(e,`name`,ke),e.push(st),Oe?.forEach(tt,e)),ct(e,U,xe),typeof xe==`string`){e.push(R(H(xe)));var je=null}else je=xe;return je;case`menuitem`:for(var Me in e.push(Ot(`menuitem`)),n)if(V.call(n,Me)){var Ne=n[Me];if(Ne!=null)switch(Me){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(400));default:at(e,Me,Ne)}}return e.push(ot),null;case`object`:e.push(Ot(`object`));var Pe=null,Fe=null,Ie;for(Ie in n)if(V.call(n,Ie)){var Le=n[Ie];if(Le!=null)switch(Ie){case`children`:Pe=Le;break;case`dangerouslySetInnerHTML`:Fe=Le;break;case`data`:var Re=pe(``+Le);if(Re===``)break;e.push(Je,R(`data`),Ye,R(H(Re)),Xe);break;default:at(e,Ie,Le)}}if(e.push(ot),ct(e,Fe,Pe),typeof Pe==`string`){e.push(R(H(Pe)));var ze=null}else ze=Pe;return ze;case`title`:var Be=c.tagScope&1,He=c.tagScope&4;if(c.insertionMode===4||Be||n.itemProp!=null)var Ue=vt(e,n);else He?Ue=null:(vt(i.hoistableChunks,n),Ue=void 0);return Ue;case`link`:var We=c.tagScope&1,Ge=c.tagScope&4,Ke=n.rel,Ze=n.href,nt=n.precedence;if(c.insertionMode===4||We||n.itemProp!=null||typeof Ke!=`string`||typeof Ze!=`string`||Ze===``){mt(e,n);var dt=null}else if(n.rel===`stylesheet`){if(typeof nt!=`string`||n.disabled!=null||n.onLoad||n.onError)dt=mt(e,n);else{var G=i.styles.get(nt),pt=r.styleResources.hasOwnProperty(Ze)?r.styleResources[Ze]:void 0;if(pt!==null){r.styleResources[Ze]=null,G||(G={precedence:R(H(nt)),rules:[],hrefs:[],sheets:new Map},i.styles.set(nt,G));var Et={state:0,props:B({},n,{"data-precedence":n.precedence,precedence:null})};if(pt){pt.length===2&&wr(Et.props,pt);var Dt=i.preloads.stylesheets.get(Ze);Dt&&0<Dt.length?Dt.length=0:Et.state=1}G.sheets.set(Ze,Et),s&&s.stylesheets.add(Et)}else if(G){var At=G.sheets.get(Ze);At&&s&&s.stylesheets.add(At)}l&&e.push(Ve),dt=null}}else n.onLoad||n.onError?dt=mt(e,n):(l&&e.push(Ve),dt=Ge?null:mt(i.hoistableChunks,n));return dt;case`script`:var jt=c.tagScope&1,Nt=n.async;if(typeof n.src!=`string`||!n.src||!Nt||typeof Nt==`function`||typeof Nt==`symbol`||n.onLoad||n.onError||c.insertionMode===4||jt||n.itemProp!=null)var Pt=St(e,n);else{var Ft=n.src;if(n.type===`module`)var It=r.moduleScriptResources,Lt=i.preloads.moduleScripts;else It=r.scriptResources,Lt=i.preloads.scripts;var Rt=It.hasOwnProperty(Ft)?It[Ft]:void 0;if(Rt!==null){It[Ft]=null;var zt=n;if(Rt){Rt.length===2&&(zt=B({},n),wr(zt,Rt));var Bt=Lt.get(Ft);Bt&&(Bt.length=0)}var Vt=[];i.scripts.add(Vt),St(Vt,zt)}l&&e.push(Ve),Pt=null}return Pt;case`style`:var Ht=c.tagScope&1,Ut=n.precedence,Wt=n.href,Gt=n.nonce;if(c.insertionMode===4||Ht||n.itemProp!=null||typeof Ut!=`string`||typeof Wt!=`string`||Wt===``){e.push(Ot(`style`));var Kt=null,qt=null,Jt;for(Jt in n)if(V.call(n,Jt)){var Yt=n[Jt];if(Yt!=null)switch(Jt){case`children`:Kt=Yt;break;case`dangerouslySetInnerHTML`:qt=Yt;break;default:at(e,Jt,Yt)}}e.push(ot);var Xt=Array.isArray(Kt)?2>Kt.length?Kt[0]:null:Kt;typeof Xt!=`function`&&typeof Xt!=`symbol`&&Xt!=null&&e.push(R((``+Xt).replace(ht,gt))),ct(e,qt,Kt),e.push(Mt(`style`));var Zt=null}else{var Qt=i.styles.get(Ut);if((r.styleResources.hasOwnProperty(Wt)?r.styleResources[Wt]:void 0)!==null){r.styleResources[Wt]=null,Qt||(Qt={precedence:R(H(Ut)),rules:[],hrefs:[],sheets:new Map},i.styles.set(Ut,Qt));var $t=i.nonce.style;if(!$t||$t===Gt){Qt.hrefs.push(R(H(Wt)));var en=Qt.rules,tn=null,nn=null,rn;for(rn in n)if(V.call(n,rn)){var an=n[rn];if(an!=null)switch(rn){case`children`:tn=an;break;case`dangerouslySetInnerHTML`:nn=an}}var on=Array.isArray(tn)?2>tn.length?tn[0]:null:tn;typeof on!=`function`&&typeof on!=`symbol`&&on!=null&&en.push(R((``+on).replace(ht,gt))),ct(en,nn,tn)}}Qt&&s&&s.styles.add(Qt),l&&e.push(Ve),Zt=void 0}return Zt;case`meta`:var sn=c.tagScope&1,cn=c.tagScope&4;if(c.insertionMode===4||sn||n.itemProp!=null)var ln=_t(e,n,`meta`);else l&&e.push(Ve),ln=cn?null:typeof n.charSet==`string`?_t(i.charsetChunks,n,`meta`):n.name===`viewport`?_t(i.viewportChunks,n,`meta`):_t(i.hoistableChunks,n,`meta`);return ln;case`listing`:case`pre`:e.push(Ot(t));var un=null,dn=null,fn;for(fn in n)if(V.call(n,fn)){var pn=n[fn];if(pn!=null)switch(fn){case`children`:un=pn;break;case`dangerouslySetInnerHTML`:dn=pn;break;default:at(e,fn,pn)}}if(e.push(ot),dn!=null){if(un!=null)throw Error(a(60));if(typeof dn!=`object`||!(`__html`in dn))throw Error(a(61));var mn=dn.__html;mn!=null&&(typeof mn==`string`&&0<mn.length&&mn[0]===`
57
+ `?e.push(Tt,R(mn)):e.push(R(``+mn)))}return typeof un==`string`&&un[0]===`
58
+ `&&e.push(Tt),un;case`img`:var hn=c.tagScope&3,gn=n.src,_n=n.srcSet;if(!(n.loading===`lazy`||!gn&&!_n||typeof gn!=`string`&&gn!=null||typeof _n!=`string`&&_n!=null||n.fetchPriority===`low`||hn)&&(typeof gn!=`string`||gn[4]!==`:`||gn[0]!==`d`&&gn[0]!==`D`||gn[1]!==`a`&&gn[1]!==`A`||gn[2]!==`t`&&gn[2]!==`T`||gn[3]!==`a`&&gn[3]!==`A`)&&(typeof _n!=`string`||_n[4]!==`:`||_n[0]!==`d`&&_n[0]!==`D`||_n[1]!==`a`&&_n[1]!==`A`||_n[2]!==`t`&&_n[2]!==`T`||_n[3]!==`a`&&_n[3]!==`A`)){s!==null&&c.tagScope&64&&(s.suspenseyImages=!0);var vn=typeof n.sizes==`string`?n.sizes:void 0,yn=_n?_n+`
59
+ `+(vn||``):gn,bn=i.preloads.images,xn=bn.get(yn);if(xn)(n.fetchPriority===`high`||10>i.highImagePreloads.size)&&(bn.delete(yn),i.highImagePreloads.add(xn));else if(!r.imageResources.hasOwnProperty(yn)){r.imageResources[yn]=ve;var Sn=n.crossOrigin,Cn=typeof Sn==`string`?Sn===`use-credentials`?Sn:``:void 0,wn=i.headers,Tn;wn&&0<wn.remainingCapacity&&typeof n.srcSet!=`string`&&(n.fetchPriority===`high`||500>wn.highImagePreloads.length)&&(Tn=Tr(gn,`image`,{imageSrcSet:n.srcSet,imageSizes:n.sizes,crossOrigin:Cn,integrity:n.integrity,nonce:n.nonce,type:n.type,fetchPriority:n.fetchPriority,referrerPolicy:n.refererPolicy}),0<=(wn.remainingCapacity-=Tn.length+2))?(i.resets.image[yn]=ve,wn.highImagePreloads&&(wn.highImagePreloads+=`, `),wn.highImagePreloads+=Tn):(xn=[],mt(xn,{rel:`preload`,as:`image`,href:_n?void 0:gn,imageSrcSet:_n,imageSizes:vn,crossOrigin:Cn,integrity:n.integrity,type:n.type,fetchPriority:n.fetchPriority,referrerPolicy:n.referrerPolicy}),n.fetchPriority===`high`||10>i.highImagePreloads.size?i.highImagePreloads.add(xn):(i.bulkPreloads.add(xn),bn.set(yn,xn)))}}return _t(e,n,`img`);case`base`:case`area`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`param`:case`source`:case`track`:case`wbr`:return _t(e,n,t);case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:break;case`head`:if(2>c.insertionMode){var En=o||i.preamble;if(En.headChunks)throw Error(a(545,"`<head>`"));o!==null&&e.push(yt),En.headChunks=[];var Dn=Ct(En.headChunks,n,`head`)}else Dn=wt(e,n,`head`);return Dn;case`body`:if(2>c.insertionMode){var On=o||i.preamble;if(On.bodyChunks)throw Error(a(545,"`<body>`"));o!==null&&e.push(bt),On.bodyChunks=[];var kn=Ct(On.bodyChunks,n,`body`)}else kn=wt(e,n,`body`);return kn;case`html`:if(c.insertionMode===0){var An=o||i.preamble;if(An.htmlChunks)throw Error(a(545,"`<html>`"));o!==null&&e.push(xt),An.htmlChunks=[kt];var jn=Ct(An.htmlChunks,n,`html`)}else jn=wt(e,n,`html`);return jn;default:if(t.indexOf(`-`)!==-1){e.push(Ot(t));var Mn=null,Nn=null,Pn;for(Pn in n)if(V.call(n,Pn)){var Fn=n[Pn];if(Fn!=null){var In=Pn;switch(Pn){case`children`:Mn=Fn;break;case`dangerouslySetInnerHTML`:Nn=Fn;break;case`style`:qe(e,Fn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`ref`:break;case`className`:In=`class`;default:if(oe(Pn)&&typeof Fn!=`function`&&typeof Fn!=`symbol`&&!1!==Fn){if(!0===Fn)Fn=``;else if(typeof Fn==`object`)continue;e.push(Je,R(In),Ye,R(H(Fn)),Xe)}}}}return e.push(ot),ct(e,Nn,Mn),Mn}}return wt(e,n,t)}var jt=new Map;function Mt(e){var t=jt.get(e);return t===void 0&&(t=z(`</`+e+`>`),jt.set(e,t)),t}function Nt(e,t){e=e.preamble,e.htmlChunks===null&&t.htmlChunks&&(e.htmlChunks=t.htmlChunks),e.headChunks===null&&t.headChunks&&(e.headChunks=t.headChunks),e.bodyChunks===null&&t.bodyChunks&&(e.bodyChunks=t.bodyChunks)}function Pt(e,t){t=t.bootstrapChunks;for(var n=0;n<t.length-1;n++)F(e,t[n]);return n<t.length?(n=t[n],t.length=0,I(e,n)):!0}var Ft=z(`requestAnimationFrame(function(){$RT=performance.now()});`),It=z(`<template id="`),Lt=z(`"></template>`),Rt=z(`<!--&-->`),zt=z(`<!--/&-->`),Bt=z(`<!--$-->`),Vt=z(`<!--$?--><template id="`),Ht=z(`"></template>`),Ut=z(`<!--$!-->`),Wt=z(`<!--/$-->`),Gt=z(`<template`),Kt=z(`"`),qt=z(` data-dgst="`);z(` data-msg="`),z(` data-stck="`),z(` data-cstck="`);var Jt=z(`></template>`);function Yt(e,t,n){if(F(e,Vt),n===null)throw Error(a(395));return F(e,t.boundaryPrefix),F(e,R(n.toString(16))),I(e,Ht)}var Xt=z(`<div hidden id="`),Zt=z(`">`),Qt=z(`</div>`),$t=z(`<svg aria-hidden="true" style="display:none" id="`),en=z(`">`),tn=z(`</svg>`),nn=z(`<math aria-hidden="true" style="display:none" id="`),rn=z(`">`),an=z(`</math>`),on=z(`<table hidden id="`),sn=z(`">`),cn=z(`</table>`),ln=z(`<table hidden><tbody id="`),un=z(`">`),dn=z(`</tbody></table>`),fn=z(`<table hidden><tr id="`),pn=z(`">`),mn=z(`</tr></table>`),hn=z(`<table hidden><colgroup id="`),gn=z(`">`),_n=z(`</colgroup></table>`);function vn(e,t,n,r){switch(n.insertionMode){case 0:case 1:case 3:case 2:return F(e,Xt),F(e,t.segmentPrefix),F(e,R(r.toString(16))),I(e,Zt);case 4:return F(e,$t),F(e,t.segmentPrefix),F(e,R(r.toString(16))),I(e,en);case 5:return F(e,nn),F(e,t.segmentPrefix),F(e,R(r.toString(16))),I(e,rn);case 6:return F(e,on),F(e,t.segmentPrefix),F(e,R(r.toString(16))),I(e,sn);case 7:return F(e,ln),F(e,t.segmentPrefix),F(e,R(r.toString(16))),I(e,un);case 8:return F(e,fn),F(e,t.segmentPrefix),F(e,R(r.toString(16))),I(e,pn);case 9:return F(e,hn),F(e,t.segmentPrefix),F(e,R(r.toString(16))),I(e,gn);default:throw Error(a(397))}}function yn(e,t){switch(t.insertionMode){case 0:case 1:case 3:case 2:return I(e,Qt);case 4:return I(e,tn);case 5:return I(e,an);case 6:return I(e,cn);case 7:return I(e,dn);case 8:return I(e,mn);case 9:return I(e,_n);default:throw Error(a(397))}}var bn=z(`$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("`),xn=z(`$RS("`),Sn=z(`","`),Cn=z(`")<\/script>`);z(`<template data-rsi="" data-sid="`),z(`" data-pid="`);var wn=z(`$RB=[];$RV=function(a){$RT=performance.now();for(var b=0;b<a.length;b+=2){var c=a[b],e=a[b+1];null!==e.parentNode&&e.parentNode.removeChild(e);var f=c.parentNode;if(f){var g=c.previousSibling,h=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d||"/&"===d)if(0===h)break;else h--;else"$"!==d&&"$?"!==d&&"$~"!==d&&"$!"!==d&&"&"!==d||h++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;e.firstChild;)f.insertBefore(e.firstChild,c);g.data="$";g._reactRetry&&requestAnimationFrame(g._reactRetry)}}a.length=0};
60
+ $RC=function(a,b){if(b=document.getElementById(b))(a=document.getElementById(a))?(a.previousSibling.data="$~",$RB.push(a,b),2===$RB.length&&("number"!==typeof $RT?requestAnimationFrame($RV.bind(null,$RB)):(a=performance.now(),setTimeout($RV.bind(null,$RB),2300>a&&2E3<a?2300-a:$RT+300-a)))):b.parentNode.removeChild(b)};`);R(`$RV=function(A,g){function k(a,b){var e=a.getAttribute(b);e&&(b=a.style,l.push(a,b.viewTransitionName,b.viewTransitionClass),"auto"!==e&&(b.viewTransitionClass=e),(a=a.getAttribute("vt-name"))||(a="_T_"+K++ +"_"),b.viewTransitionName=a,B=!0)}var B=!1,K=0,l=[];try{var f=document.__reactViewTransition;if(f){f.finished.finally($RV.bind(null,g));return}var m=new Map;for(f=1;f<g.length;f+=2)for(var h=g[f].querySelectorAll("[vt-share]"),d=0;d<h.length;d++){var c=h[d];m.set(c.getAttribute("vt-name"),c)}var u=[];for(h=0;h<g.length;h+=2){var C=g[h],x=C.parentNode;if(x){var v=x.getBoundingClientRect();if(v.left||v.top||v.width||v.height){c=C;for(f=0;c;){if(8===c.nodeType){var r=c.data;if("/$"===r)if(0===f)break;else f--;else"$"!==r&&"$?"!==r&&"$~"!==r&&"$!"!==r||f++}else if(1===c.nodeType){d=c;var D=d.getAttribute("vt-name"),y=m.get(D);k(d,y?"vt-share":"vt-exit");y&&(k(y,"vt-share"),m.set(D,null));var E=d.querySelectorAll("[vt-share]");for(d=0;d<E.length;d++){var F=E[d],G=F.getAttribute("vt-name"),
61
+ H=m.get(G);H&&(k(F,"vt-share"),k(H,"vt-share"),m.set(G,null))}}c=c.nextSibling}for(var I=g[h+1],t=I.firstElementChild;t;)null!==m.get(t.getAttribute("vt-name"))&&k(t,"vt-enter"),t=t.nextElementSibling;c=x;do for(var n=c.firstElementChild;n;){var J=n.getAttribute("vt-update");J&&"none"!==J&&!l.includes(n)&&k(n,"vt-update");n=n.nextElementSibling}while((c=c.parentNode)&&1===c.nodeType&&"none"!==c.getAttribute("vt-update"));u.push.apply(u,I.querySelectorAll('img[src]:not([loading="lazy"])'))}}}if(B){var z=
62
+ document.__reactViewTransition=document.startViewTransition({update:function(){A(g);for(var a=[document.documentElement.clientHeight,document.fonts.ready],b={},e=0;e<u.length;b={g:b.g},e++)if(b.g=u[e],!b.g.complete){var p=b.g.getBoundingClientRect();0<p.bottom&&0<p.right&&p.top<window.innerHeight&&p.left<window.innerWidth&&(p=new Promise(function(w){return function(q){w.g.addEventListener("load",q);w.g.addEventListener("error",q)}}(b)),a.push(p))}return Promise.race([Promise.all(a),new Promise(function(w){var q=
63
+ performance.now();setTimeout(w,2300>q&&2E3<q?2300-q:500)})])},types:[]});z.ready.finally(function(){for(var a=l.length-3;0<=a;a-=3){var b=l[a],e=b.style;e.viewTransitionName=l[a+1];e.viewTransitionClass=l[a+1];""===b.getAttribute("style")&&b.removeAttribute("style")}});z.finished.finally(function(){document.__reactViewTransition===z&&(document.__reactViewTransition=null)});$RB=[];return}}catch(a){}A(g)}.bind(null,$RV);`);var Tn=z(`$RC("`),En=z(`$RM=new Map;$RR=function(n,w,p){function u(q){this._p=null;q()}for(var r=new Map,t=document,h,b,e=t.querySelectorAll("link[data-precedence],style[data-precedence]"),v=[],k=0;b=e[k++];)"not all"===b.getAttribute("media")?v.push(b):("LINK"===b.tagName&&$RM.set(b.getAttribute("href"),b),r.set(b.dataset.precedence,h=b));e=0;b=[];var l,a;for(k=!0;;){if(k){var f=p[e++];if(!f){k=!1;e=0;continue}var c=!1,m=0;var d=f[m++];if(a=$RM.get(d)){var g=a._p;c=!0}else{a=t.createElement("link");a.href=d;a.rel=
64
+ "stylesheet";for(a.dataset.precedence=l=f[m++];g=f[m++];)a.setAttribute(g,f[m++]);g=a._p=new Promise(function(q,x){a.onload=u.bind(a,q);a.onerror=u.bind(a,x)});$RM.set(d,a)}d=a.getAttribute("media");!g||d&&!matchMedia(d).matches||b.push(g);if(c)continue}else{a=v[e++];if(!a)break;l=a.getAttribute("data-precedence");a.removeAttribute("media")}c=r.get(l)||h;c===h&&(h=a);r.set(l,a);c?c.parentNode.insertBefore(a,c.nextSibling):(c=t.head,c.insertBefore(a,c.firstChild))}if(p=document.getElementById(n))p.previousSibling.data=
65
+ "$~";Promise.all(b).then($RC.bind(null,n,w),$RX.bind(null,n,"CSS failed to load"))};$RR("`),Dn=z(`$RR("`),On=z(`","`),kn=z(`",`),An=z(`"`),jn=z(`)<\/script>`);z(`<template data-rci="" data-bid="`),z(`<template data-rri="" data-bid="`),z(`" data-sid="`),z(`" data-sty="`);var Mn=z(`$RX=function(b,c,d,e,f){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),f&&(a.cstck=f),b._reactRetry&&b._reactRetry())};`),Nn=z(`$RX=function(b,c,d,e,f){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),f&&(a.cstck=f),b._reactRetry&&b._reactRetry())};;$RX("`),Pn=z(`$RX("`),Fn=z(`"`),In=z(`,`),Ln=z(`)<\/script>`);z(`<template data-rxi="" data-bid="`),z(`" data-dgst="`),z(`" data-msg="`),z(`" data-stck="`),z(`" data-cstck="`);var Rn=/[<\u2028\u2029]/g;function zn(e){return JSON.stringify(e).replace(Rn,function(e){switch(e){case`<`:return`\\u003c`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:throw Error(`escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React`)}})}var Bn=/[&><\u2028\u2029]/g;function Vn(e){return JSON.stringify(e).replace(Bn,function(e){switch(e){case`&`:return`\\u0026`;case`>`:return`\\u003e`;case`<`:return`\\u003c`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:throw Error(`escapeJSObjectForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React`)}})}var Hn=z(` media="not all" data-precedence="`),Un=z(`" data-href="`),Wn=z(`">`),Gn=z(`</style>`),Kn=!1,qn=!0;function Jn(e){var t=e.rules,n=e.hrefs,r=0;if(n.length){for(F(this,ye.startInlineStyle),F(this,Hn),F(this,e.precedence),F(this,Un);r<n.length-1;r++)F(this,n[r]),F(this,nr);for(F(this,n[r]),F(this,Wn),r=0;r<t.length;r++)F(this,t[r]);qn=I(this,Gn),Kn=!0,t.length=0,n.length=0}}function Yn(e){return e.state===2?!1:Kn=!0}function Xn(e,t,n){return Kn=!1,qn=!0,ye=n,t.styles.forEach(Jn,e),ye=null,t.stylesheets.forEach(Yn),Kn&&(n.stylesToHoist=!0),qn}function Zn(e){for(var t=0;t<e.length;t++)F(this,e[t]);e.length=0}var Qn=[];function $n(e){mt(Qn,e.props);for(var t=0;t<Qn.length;t++)F(this,Qn[t]);Qn.length=0,e.state=2}var er=z(` data-precedence="`),tr=z(`" data-href="`),nr=z(` `),rr=z(`">`),ir=z(`</style>`);function ar(e){var t=0<e.sheets.size;e.sheets.forEach($n,this),e.sheets.clear();var n=e.rules,r=e.hrefs;if(!t||r.length){if(F(this,ye.startInlineStyle),F(this,er),F(this,e.precedence),e=0,r.length){for(F(this,tr);e<r.length-1;e++)F(this,r[e]),F(this,nr);F(this,r[e])}for(F(this,rr),e=0;e<n.length;e++)F(this,n[e]);F(this,ir),n.length=0,r.length=0}}function or(e){if(e.state===0){e.state=1;var t=e.props;for(mt(Qn,{rel:`preload`,as:`style`,href:e.props.href,crossOrigin:t.crossOrigin,fetchPriority:t.fetchPriority,integrity:t.integrity,media:t.media,hrefLang:t.hrefLang,referrerPolicy:t.referrerPolicy}),e=0;e<Qn.length;e++)F(this,Qn[e]);Qn.length=0}}function sr(e){e.sheets.forEach(or,this),e.sheets.clear()}z(`<link rel="expect" href="#`),z(`" blocking="render"/>`);var cr=z(` id="`);function lr(e,t){!(t.instructions&32)&&(t.instructions|=32,e.push(cr,R(H(`_`+t.idPrefix+`R_`)),Xe))}var ur=z(`[`),dr=z(`,[`),fr=z(`,`),pr=z(`]`);function mr(e,t){F(e,ur);var n=ur;t.stylesheets.forEach(function(t){if(t.state!==2){if(t.state===3)F(e,n),F(e,R(Vn(``+t.props.href))),F(e,pr),n=dr;else{F(e,n);var r=t.props[`data-precedence`],i=t.props;for(var o in F(e,R(Vn(pe(``+t.props.href)))),r=``+r,F(e,fr),F(e,R(Vn(r))),i)if(V.call(i,o)&&(r=i[o],r!=null))switch(o){case`href`:case`rel`:case`precedence`:case`data-precedence`:break;case`children`:case`dangerouslySetInnerHTML`:throw Error(a(399,`link`));default:hr(e,o,r)}F(e,pr),n=dr,t.state=3}}}),F(e,pr)}function hr(e,t,n){var r=t.toLowerCase();switch(typeof n){case`function`:case`symbol`:return}switch(t){case`innerHTML`:case`dangerouslySetInnerHTML`:case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`style`:case`ref`:return;case`className`:r=`class`,t=``+n;break;case`hidden`:if(!1===n)return;t=``;break;case`src`:case`href`:n=pe(n),t=``+n;break;default:if(2<t.length&&(t[0]===`o`||t[0]===`O`)&&(t[1]===`n`||t[1]===`N`)||!oe(t))return;t=``+n}F(e,fr),F(e,R(Vn(r))),F(e,fr),F(e,R(Vn(t)))}function gr(){return{styles:new Set,stylesheets:new Set,suspenseyImages:!1}}function _r(e){var t=Zi||null;if(t){var n=t.resumableState,r=t.renderState;if(typeof e==`string`&&e){if(!n.dnsResources.hasOwnProperty(e)){n.dnsResources[e]=null,n=r.headers;var i,a;(a=n&&0<n.remainingCapacity)&&(a=(i=`<`+(``+e).replace(Er,Dr)+`>; rel=dns-prefetch`,0<=(n.remainingCapacity-=i.length+2))),a?(r.resets.dns[e]=null,n.preconnects&&(n.preconnects+=`, `),n.preconnects+=i):(i=[],mt(i,{href:e,rel:`dns-prefetch`}),r.preconnects.add(i))}Ka(t)}}else _e.D(e)}function vr(e,t){var n=Zi||null;if(n){var r=n.resumableState,i=n.renderState;if(typeof e==`string`&&e){var a=t===`use-credentials`?`credentials`:typeof t==`string`?`anonymous`:`default`;if(!r.connectResources[a].hasOwnProperty(e)){r.connectResources[a][e]=null,r=i.headers;var o,s;if(s=r&&0<r.remainingCapacity){if(s=`<`+(``+e).replace(Er,Dr)+`>; rel=preconnect`,typeof t==`string`){var c=(``+t).replace(Or,kr);s+=`; crossorigin="`+c+`"`}s=(o=s,0<=(r.remainingCapacity-=o.length+2))}s?(i.resets.connect[a][e]=null,r.preconnects&&(r.preconnects+=`, `),r.preconnects+=o):(a=[],mt(a,{rel:`preconnect`,href:e,crossOrigin:t}),i.preconnects.add(a))}Ka(n)}}else _e.C(e,t)}function yr(e,t,n){var r=Zi||null;if(r){var i=r.resumableState,a=r.renderState;if(t&&e){switch(t){case`image`:if(n)var o=n.imageSrcSet,s=n.imageSizes,c=n.fetchPriority;var l=o?o+`
66
+ `+(s||``):e;if(i.imageResources.hasOwnProperty(l))return;i.imageResources[l]=ve,i=a.headers;var u;i&&0<i.remainingCapacity&&typeof o!=`string`&&c===`high`&&(u=Tr(e,t,n),0<=(i.remainingCapacity-=u.length+2))?(a.resets.image[l]=ve,i.highImagePreloads&&(i.highImagePreloads+=`, `),i.highImagePreloads+=u):(i=[],mt(i,B({rel:`preload`,href:o?void 0:e,as:t},n)),c===`high`?a.highImagePreloads.add(i):(a.bulkPreloads.add(i),a.preloads.images.set(l,i)));break;case`style`:if(i.styleResources.hasOwnProperty(e))return;o=[],mt(o,B({rel:`preload`,href:e,as:t},n)),i.styleResources[e]=!n||typeof n.crossOrigin!=`string`&&typeof n.integrity!=`string`?ve:[n.crossOrigin,n.integrity],a.preloads.stylesheets.set(e,o),a.bulkPreloads.add(o);break;case`script`:if(i.scriptResources.hasOwnProperty(e))return;o=[],a.preloads.scripts.set(e,o),a.bulkPreloads.add(o),mt(o,B({rel:`preload`,href:e,as:t},n)),i.scriptResources[e]=!n||typeof n.crossOrigin!=`string`&&typeof n.integrity!=`string`?ve:[n.crossOrigin,n.integrity];break;default:if(i.unknownResources.hasOwnProperty(t)){if(o=i.unknownResources[t],o.hasOwnProperty(e))return}else o={},i.unknownResources[t]=o;if(o[e]=ve,(i=a.headers)&&0<i.remainingCapacity&&t===`font`&&(l=Tr(e,t,n),0<=(i.remainingCapacity-=l.length+2)))a.resets.font[e]=ve,i.fontPreloads&&(i.fontPreloads+=`, `),i.fontPreloads+=l;else switch(i=[],e=B({rel:`preload`,href:e,as:t},n),mt(i,e),t){case`font`:a.fontPreloads.add(i);break;default:a.bulkPreloads.add(i)}}Ka(r)}}else _e.L(e,t,n)}function br(e,t){var n=Zi||null;if(n){var r=n.resumableState,i=n.renderState;if(e){var a=t&&typeof t.as==`string`?t.as:`script`;switch(a){case`script`:if(r.moduleScriptResources.hasOwnProperty(e))return;a=[],r.moduleScriptResources[e]=!t||typeof t.crossOrigin!=`string`&&typeof t.integrity!=`string`?ve:[t.crossOrigin,t.integrity],i.preloads.moduleScripts.set(e,a);break;default:if(r.moduleUnknownResources.hasOwnProperty(a)){var o=r.unknownResources[a];if(o.hasOwnProperty(e))return}else o={},r.moduleUnknownResources[a]=o;a=[],o[e]=ve}mt(a,B({rel:`modulepreload`,href:e},t)),i.bulkPreloads.add(a),Ka(n)}}else _e.m(e,t)}function xr(e,t,n){var r=Zi||null;if(r){var i=r.resumableState,a=r.renderState;if(e){t||=`default`;var o=a.styles.get(t),s=i.styleResources.hasOwnProperty(e)?i.styleResources[e]:void 0;s!==null&&(i.styleResources[e]=null,o||(o={precedence:R(H(t)),rules:[],hrefs:[],sheets:new Map},a.styles.set(t,o)),t={state:0,props:B({rel:`stylesheet`,href:e,"data-precedence":t},n)},s&&(s.length===2&&wr(t.props,s),(a=a.preloads.stylesheets.get(e))&&0<a.length?a.length=0:t.state=1),o.sheets.set(e,t),Ka(r))}}else _e.S(e,t,n)}function Sr(e,t){var n=Zi||null;if(n){var r=n.resumableState,i=n.renderState;if(e){var a=r.scriptResources.hasOwnProperty(e)?r.scriptResources[e]:void 0;a!==null&&(r.scriptResources[e]=null,t=B({src:e,async:!0},t),a&&(a.length===2&&wr(t,a),e=i.preloads.scripts.get(e))&&(e.length=0),e=[],i.scripts.add(e),St(e,t),Ka(n))}}else _e.X(e,t)}function Cr(e,t){var n=Zi||null;if(n){var r=n.resumableState,i=n.renderState;if(e){var a=r.moduleScriptResources.hasOwnProperty(e)?r.moduleScriptResources[e]:void 0;a!==null&&(r.moduleScriptResources[e]=null,t=B({src:e,type:`module`,async:!0},t),a&&(a.length===2&&wr(t,a),e=i.preloads.moduleScripts.get(e))&&(e.length=0),e=[],i.scripts.add(e),St(e,t),Ka(n))}}else _e.M(e,t)}function wr(e,t){e.crossOrigin??=t[0],e.integrity??=t[1]}function Tr(e,t,n){for(var r in e=(``+e).replace(Er,Dr),t=(``+t).replace(Or,kr),t=`<`+e+`>; rel=preload; as="`+t+`"`,n)V.call(n,r)&&(e=n[r],typeof e==`string`&&(t+=`; `+r.toLowerCase()+`="`+(``+e).replace(Or,kr)+`"`));return t}var Er=/[<>\r\n]/g;function Dr(e){switch(e){case`<`:return`%3C`;case`>`:return`%3E`;case`
67
+ `:return`%0A`;case`\r`:return`%0D`;default:throw Error(`escapeLinkHrefForHeaderContextReplacer encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React`)}}var Or=/["';,\r\n]/g;function kr(e){switch(e){case`"`:return`%22`;case`'`:return`%27`;case`;`:return`%3B`;case`,`:return`%2C`;case`
68
+ `:return`%0A`;case`\r`:return`%0D`;default:throw Error(`escapeStringForLinkHeaderQuotedParamValueContextReplacer encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React`)}}function Ar(e){this.styles.add(e)}function jr(e){this.stylesheets.add(e)}function Mr(e,t){t.styles.forEach(Ar,e),t.stylesheets.forEach(jr,e),t.suspenseyImages&&(e.suspenseyImages=!0)}function Nr(e){return 0<e.stylesheets.size||e.suspenseyImages}var Pr=Function.prototype.bind,Fr=Symbol.for(`react.client.reference`);function Ir(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===Fr?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case c:return`Fragment`;case u:return`Profiler`;case l:return`StrictMode`;case m:return`Suspense`;case h:return`SuspenseList`;case y:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case s:return`Portal`;case f:return e.displayName||`Context`;case d:return(e._context.displayName||`Context`)+`.Consumer`;case p:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case g:return t=e.displayName||null,t===null?Ir(e.type)||`Memo`:t;case _:t=e._payload,e=e._init;try{return Ir(e(t))}catch{}}return null}var Lr={},Rr=null;function zr(e,t){if(e!==t){e.context._currentValue=e.parentValue,e=e.parent;var n=t.parent;if(e===null){if(n!==null)throw Error(a(401))}else{if(n===null)throw Error(a(401));zr(e,n)}t.context._currentValue=t.value}}function Br(e){e.context._currentValue=e.parentValue,e=e.parent,e!==null&&Br(e)}function Vr(e){var t=e.parent;t!==null&&Vr(t),e.context._currentValue=e.value}function Hr(e,t){if(e.context._currentValue=e.parentValue,e=e.parent,e===null)throw Error(a(402));e.depth===t.depth?zr(e,t):Hr(e,t)}function Ur(e,t){var n=t.parent;if(n===null)throw Error(a(402));e.depth===n.depth?zr(e,n):Ur(e,n),t.context._currentValue=t.value}function Wr(e){var t=Rr;t!==e&&(t===null?Vr(e):e===null?Br(t):t.depth===e.depth?zr(t,e):t.depth>e.depth?Hr(t,e):Ur(t,e),Rr=e)}var Gr={enqueueSetState:function(e,t){e=e._reactInternals,e.queue!==null&&e.queue.push(t)},enqueueReplaceState:function(e,t){e=e._reactInternals,e.replace=!0,e.queue=[t]},enqueueForceUpdate:function(){}},Kr={id:1,overflow:``};function qr(e,t,n){var r=e.id;e=e.overflow;var i=32-Jr(r)-1;r&=~(1<<i),n+=1;var a=32-Jr(t)+i;if(30<a){var o=i-i%5;return a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,{id:1<<32-Jr(t)+i|n<<i|r,overflow:a+e}}return{id:1<<a|n<<i|r,overflow:e}}var Jr=Math.clz32?Math.clz32:Zr,Yr=Math.log,Xr=Math.LN2;function Zr(e){return e>>>=0,e===0?32:31-(Yr(e)/Xr|0)|0}function Qr(){}var $r=Error(a(460));function ei(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Qr,Qr),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason;default:switch(typeof t.status==`string`?t.then(Qr,Qr):(e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason}throw ti=t,$r}}var ti=null;function ni(){if(ti===null)throw Error(a(459));var e=ti;return ti=null,e}function ri(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var ii=typeof Object.is==`function`?Object.is:ri,ai=null,oi=null,si=null,ci=null,li=null,ui=null,di=!1,fi=!1,pi=0,mi=0,hi=-1,gi=0,_i=null,vi=null,yi=0;function bi(){if(ai===null)throw Error(a(321));return ai}function xi(){if(0<yi)throw Error(a(312));return{memoizedState:null,queue:null,next:null}}function Si(){return ui===null?li===null?(di=!1,li=ui=xi()):(di=!0,ui=li):ui.next===null?(di=!1,ui=ui.next=xi()):(di=!0,ui=ui.next),ui}function Ci(){var e=_i;return _i=null,e}function wi(){ci=si=oi=ai=null,fi=!1,li=null,yi=0,ui=vi=null}function Ti(e,t){return typeof t==`function`?t(e):t}function Ei(e,t,n){if(ai=bi(),ui=Si(),di){var r=ui.queue;if(t=r.dispatch,vi!==null&&(n=vi.get(r),n!==void 0)){vi.delete(r),r=ui.memoizedState;do r=e(r,n.action),n=n.next;while(n!==null);return ui.memoizedState=r,[r,t]}return[ui.memoizedState,t]}return e=e===Ti?typeof t==`function`?t():t:n===void 0?t:n(t),ui.memoizedState=e,e=ui.queue={last:null,dispatch:null},e=e.dispatch=Oi.bind(null,ai,e),[ui.memoizedState,e]}function Di(e,t){if(ai=bi(),ui=Si(),t=t===void 0?null:t,ui!==null){var n=ui.memoizedState;if(n!==null&&t!==null){var r=n[1];a:if(r===null)r=!1;else{for(var i=0;i<r.length&&i<t.length;i++)if(!ii(t[i],r[i])){r=!1;break a}r=!0}if(r)return n[0]}}return e=e(),ui.memoizedState=[e,t],e}function Oi(e,t,n){if(25<=yi)throw Error(a(301));if(e===ai){if(fi=!0,e={action:n,next:null},vi===null&&(vi=new Map),n=vi.get(t),n===void 0)vi.set(t,e);else{for(t=n;t.next!==null;)t=t.next;t.next=e}}}function ki(){throw Error(a(440))}function Ai(){throw Error(a(394))}function ji(){throw Error(a(479))}function Mi(e,t,n){bi();var r=mi++,i=si;if(typeof e.$$FORM_ACTION==`function`){var a=null,o=ci;i=i.formState;var s=e.$$IS_SIGNATURE_EQUAL;if(i!==null&&typeof s==`function`){var c=i[1];s.call(e,i[2],i[3])&&(a=n===void 0?`k`+E(JSON.stringify([o,null,r]),0):`p`+n,c===a&&(hi=r,t=i[0]))}var l=e.bind(null,t);return e=function(e){l(e)},typeof l.$$FORM_ACTION==`function`&&(e.$$FORM_ACTION=function(e){e=l.$$FORM_ACTION(e),n!==void 0&&(n+=``,e.action=n);var t=e.data;return t&&(a===null&&(a=n===void 0?`k`+E(JSON.stringify([o,null,r]),0):`p`+n),t.append(`$ACTION_KEY`,a)),e}),[t,e,!1]}var u=e.bind(null,t);return[t,function(e){u(e)},!1]}function Ni(e){var t=gi;return gi+=1,_i===null&&(_i=[]),ei(_i,e,t)}function Pi(){throw Error(a(393))}var Fi={readContext:function(e){return e._currentValue},use:function(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Ni(e);if(e.$$typeof===f)return e._currentValue}throw Error(a(438,String(e)))},useContext:function(e){return bi(),e._currentValue},useMemo:Di,useReducer:Ei,useRef:function(e){ai=bi(),ui=Si();var t=ui.memoizedState;return t===null?(e={current:e},ui.memoizedState=e):t},useState:function(e){return Ei(Ti,e)},useInsertionEffect:Qr,useLayoutEffect:Qr,useCallback:function(e,t){return Di(function(){return e},t)},useImperativeHandle:Qr,useEffect:Qr,useDebugValue:Qr,useDeferredValue:function(e,t){return bi(),t===void 0?e:t},useTransition:function(){return bi(),[!1,Ai]},useId:function(){var e=oi.treeContext,t=e.overflow;e=e.id,e=(e&~(1<<32-Jr(e)-1)).toString(32)+t;var n=Ii;if(n===null)throw Error(a(404));return t=pi++,e=`_`+n.idPrefix+`R_`+e,0<t&&(e+=`H`+t.toString(32)),e+`_`},useSyncExternalStore:function(e,t,n){if(n===void 0)throw Error(a(407));return n()},useOptimistic:function(e){return bi(),[e,ji]},useActionState:Mi,useFormState:Mi,useHostTransitionStatus:function(){return bi(),ge},useMemoCache:function(e){for(var t=Array(e),n=0;n<e;n++)t[n]=x;return t},useCacheRefresh:function(){return Pi},useEffectEvent:function(){return ki}},Ii=null,Li={getCacheForType:function(){throw Error(a(248))},cacheSignal:function(){throw Error(a(248))}},Ri,zi;function Bi(e){if(Ri===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ri=t&&t[1]||``,zi=-1<e.stack.indexOf(`
69
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
70
+ `+Ri+e+zi}var Vi=!1;function Hi(e,t){if(!e||Vi)return``;Vi=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
71
+ `),l=s.split(`
72
+ `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
73
+ `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Vi=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Bi(n):``}function Ui(e){if(typeof e==`string`)return Bi(e);if(typeof e==`function`)return e.prototype&&e.prototype.isReactComponent?Hi(e,!0):Hi(e,!1);if(typeof e==`object`&&e){switch(e.$$typeof){case p:return Hi(e.render,!1);case g:return Hi(e.type,!1);case _:var t=e,n=t._payload;t=t._init;try{e=t(n)}catch{return Bi(`Lazy`)}return Ui(e)}if(typeof e.name==`string`){a:{n=e.name,t=e.env;var r=e.debugLocation;if(r!=null&&(e=Error.prepareStackTrace,Error.prepareStackTrace=void 0,r=r.stack,Error.prepareStackTrace=e,r.startsWith(`Error: react-stack-top-frame
74
+ `)&&(r=r.slice(29)),e=r.indexOf(`
75
+ `),e!==-1&&(r=r.slice(e+1)),e=r.indexOf(`react_stack_bottom_frame`),e!==-1&&(e=r.lastIndexOf(`
76
+ `,e)),e=e===-1?``:r=r.slice(0,e),r=e.lastIndexOf(`
77
+ `),e=r===-1?e:e.slice(r+1),e.indexOf(n)!==-1)){n=`
78
+ `+e;break a}n=Bi(n+(t?` [`+t+`]`:``))}return n}}switch(e){case h:return Bi(`SuspenseList`);case m:return Bi(`Suspense`)}return``}function Wi(e,t){return(500<t.byteSize||Nr(t.contentState))&&t.contentPreamble===null}function Gi(e){if(typeof e==`object`&&e&&typeof e.environmentName==`string`){var t=e.environmentName;e=[e].slice(0),typeof e[0]==`string`?e.splice(0,1,`%c%s%c `+e[0],`background: #e6e6e6;background: light-dark(rgba(0,0,0,0.1), rgba(255,255,255,0.25));color: #000000;color: light-dark(#000000, #ffffff);border-radius: 2px`,` `+t+` `,``):e.splice(0,0,`%c%s%c`,`background: #e6e6e6;background: light-dark(rgba(0,0,0,0.1), rgba(255,255,255,0.25));color: #000000;color: light-dark(#000000, #ffffff);border-radius: 2px`,` `+t+` `,``),e.unshift(console),t=Pr.apply(console.error,e),t()}else console.error(e);return null}function Ki(e,t,n,r,i,a,o,s,c,l,u){var d=new Set;this.destination=null,this.flushScheduled=!1,this.resumableState=e,this.renderState=t,this.rootFormatContext=n,this.progressiveChunkSize=r===void 0?12800:r,this.status=10,this.fatalError=null,this.pendingRootTasks=this.allPendingTasks=this.nextSegmentId=0,this.completedPreambleSegments=this.completedRootSegment=null,this.byteSize=0,this.abortableTasks=d,this.pingedTasks=[],this.clientRenderedBoundaries=[],this.completedBoundaries=[],this.partialBoundaries=[],this.trackedPostpones=null,this.onError=i===void 0?Gi:i,this.onPostpone=l===void 0?Qr:l,this.onAllReady=a===void 0?Qr:a,this.onShellReady=o===void 0?Qr:o,this.onShellError=s===void 0?Qr:s,this.onFatalError=c===void 0?Qr:c,this.formState=u===void 0?null:u}function qi(e,t,n,r,i,a,o,s,c,l,u,d){return t=new Ki(t,n,r,i,a,o,s,c,l,u,d),n=na(t,0,null,r,!1,!1),n.parentFlushed=!0,e=ea(t,null,e,-1,null,n,null,null,t.abortableTasks,null,r,null,Kr,null,null),ra(e),t.pingedTasks.push(e),t}function Ji(e,t,n,r,i,a,o,s,c,l,u){return e=qi(e,t,n,r,i,a,o,s,c,l,u,void 0),e.trackedPostpones={workingMap:new Map,rootNodes:[],rootSlots:null},e}function Yi(e,t,n,r,i,a,o,s,c){return n=new Ki(t.resumableState,n,t.rootFormatContext,t.progressiveChunkSize,r,i,a,o,s,c,null),n.nextSegmentId=t.nextSegmentId,typeof t.replaySlots==`number`?(r=na(n,0,null,t.rootFormatContext,!1,!1),r.parentFlushed=!0,e=ea(n,null,e,-1,null,r,null,null,n.abortableTasks,null,t.rootFormatContext,null,Kr,null,null),ra(e),n.pingedTasks.push(e),n):(e=ta(n,null,{nodes:t.replayNodes,slots:t.replaySlots,pendingTasks:0},e,-1,null,null,n.abortableTasks,null,t.rootFormatContext,null,Kr,null,null),ra(e),n.pingedTasks.push(e),n)}function Xi(e,t,n,r,i,a,o,s,c){return e=Yi(e,t,n,r,i,a,o,s,c),e.trackedPostpones={workingMap:new Map,rootNodes:[],rootSlots:null},e}var Zi=null;function Qi(e,t){e.pingedTasks.push(t),e.pingedTasks.length===1&&(e.flushScheduled=e.destination!==null,e.trackedPostpones!==null||e.status===10?M(function(){return Na(e)}):k(function(){return Na(e)}))}function $i(e,t,n,r,i){return n={status:0,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,row:t,completedSegments:[],byteSize:0,fallbackAbortableTasks:n,errorDigest:null,contentState:gr(),fallbackState:gr(),contentPreamble:r,fallbackPreamble:i,trackedContentKeyPath:null,trackedFallbackNode:null},t!==null&&(t.pendingTasks++,r=t.boundaries,r!==null&&(e.allPendingTasks++,n.pendingTasks++,r.push(n)),e=t.inheritedHoistables,e!==null&&Mr(n.contentState,e)),n}function ea(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){e.allPendingTasks++,i===null?e.pendingRootTasks++:i.pendingTasks++,p!==null&&p.pendingTasks++;var h={replay:null,node:n,childIndex:r,ping:function(){return Qi(e,h)},blockedBoundary:i,blockedSegment:a,blockedPreamble:o,hoistableState:s,abortSet:c,keyPath:l,formatContext:u,context:d,treeContext:f,row:p,componentStack:m,thenableState:t};return c.add(h),h}function ta(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.allPendingTasks++,a===null?e.pendingRootTasks++:a.pendingTasks++,f!==null&&f.pendingTasks++,n.pendingTasks++;var m={replay:n,node:r,childIndex:i,ping:function(){return Qi(e,m)},blockedBoundary:a,blockedSegment:null,blockedPreamble:null,hoistableState:o,abortSet:s,keyPath:c,formatContext:l,context:u,treeContext:d,row:f,componentStack:p,thenableState:t};return s.add(m),m}function na(e,t,n,r,i,a){return{status:0,parentFlushed:!1,id:-1,index:t,chunks:[],children:[],preambleChildren:[],parentFormatContext:r,boundary:n,lastPushedText:i,textEmbedded:a}}function ra(e){var t=e.node;if(typeof t==`object`&&t)switch(t.$$typeof){case o:e.componentStack={parent:e.componentStack,type:t.type}}}function ia(e){return e===null?null:{parent:e.parent,type:`Suspense Fallback`}}function aa(e){var t={};return e&&Object.defineProperty(t,"componentStack",{configurable:!0,enumerable:!0,get:function(){try{var n=``,r=e;do n+=Ui(r.type),r=r.parent;while(r);var i=n}catch(e){i=`
79
+ Error generating stack: `+e.message+`
80
+ `+e.stack}return Object.defineProperty(t,"componentStack",{value:i}),i}}),t}function oa(e,t,n){if(e=e.onError,t=e(t,n),t==null||typeof t==`string`)return t}function sa(e,t){var n=e.onShellError,r=e.onFatalError;n(t),r(t),e.destination===null?(e.status=13,e.fatalError=t):(e.status=14,ne(e.destination,t))}function ca(e,t){la(e,t.next,t.hoistables)}function la(e,t,n){for(;t!==null;){n!==null&&(Mr(t.hoistables,n),t.inheritedHoistables=n);var r=t.boundaries;if(r!==null){t.boundaries=null;for(var i=0;i<r.length;i++){var a=r[i];n!==null&&Mr(a.contentState,n),Ma(e,a,null,null)}}if(t.pendingTasks--,0<t.pendingTasks)break;n=t.hoistables,t=t.next}}function ua(e,t){var n=t.boundaries;if(n!==null&&t.pendingTasks===n.length){for(var r=!0,i=0;i<n.length;i++){var a=n[i];if(a.pendingTasks!==1||a.parentFlushed||Wi(e,a)){r=!1;break}}r&&la(e,t,t.hoistables)}}function da(e){var t={pendingTasks:1,boundaries:null,hoistables:gr(),inheritedHoistables:null,together:!1,next:null};return e!==null&&0<e.pendingTasks&&(t.pendingTasks++,t.boundaries=[],e.next=t),t}function fa(e,t,n,r,i){var a=t.keyPath,o=t.treeContext,s=t.row;t.keyPath=n,n=r.length;var c=null;if(t.replay!==null){var l=t.replay.slots;if(typeof l==`object`&&l)for(var u=0;u<n;u++){var d=i!==`backwards`&&i!==`unstable_legacy-backwards`?u:n-1-u,f=r[d];t.row=c=da(c),t.treeContext=qr(o,n,d);var p=l[d];typeof p==`number`?(ga(e,t,p,f,d),delete l[d]):Ta(e,t,f,d),--c.pendingTasks===0&&ca(e,c)}else for(l=0;l<n;l++)u=i!==`backwards`&&i!==`unstable_legacy-backwards`?l:n-1-l,d=r[u],t.row=c=da(c),t.treeContext=qr(o,n,u),Ta(e,t,d,u),--c.pendingTasks===0&&ca(e,c)}else if(i!==`backwards`&&i!==`unstable_legacy-backwards`)for(i=0;i<n;i++)l=r[i],t.row=c=da(c),t.treeContext=qr(o,n,i),Ta(e,t,l,i),--c.pendingTasks===0&&ca(e,c);else{for(i=t.blockedSegment,l=i.children.length,u=i.chunks.length,d=n-1;0<=d;d--){f=r[d],t.row=c=da(c),t.treeContext=qr(o,n,d),p=na(e,u,null,t.formatContext,d!==0||i.lastPushedText,!0),i.children.splice(l,0,p),t.blockedSegment=p;try{Ta(e,t,f,d),p.lastPushedText&&p.textEmbedded&&p.chunks.push(Ve),p.status=1,ja(e,t.blockedBoundary,p),--c.pendingTasks===0&&ca(e,c)}catch(t){throw p.status=e.status===12?3:4,t}}t.blockedSegment=i,i.lastPushedText=!1}s!==null&&c!==null&&0<c.pendingTasks&&(s.pendingTasks++,c.next=s),t.treeContext=o,t.row=s,t.keyPath=a}function pa(e,t,n,r,i,a){var o=t.thenableState;for(t.thenableState=null,ai={},oi=t,si=e,ci=n,mi=pi=0,hi=-1,gi=0,_i=o,e=r(i,a);fi;)fi=!1,mi=pi=0,hi=-1,gi=0,yi+=1,ui=null,e=r(i,a);return wi(),e}function ma(e,t,n,r,i,a,o){var s=!1;if(a!==0&&e.formState!==null){var c=t.blockedSegment;if(c!==null){s=!0,c=c.chunks;for(var l=0;l<a;l++)l===o?c.push(G):c.push(pt)}}a=t.keyPath,t.keyPath=n,i?(n=t.treeContext,t.treeContext=qr(n,1,0),Ta(e,t,r,-1),t.treeContext=n):s?Ta(e,t,r,-1):_a(e,t,r,-1),t.keyPath=a}function ha(e,t,n,r,i,o){if(typeof r==`function`){if(r.prototype&&r.prototype.isReactComponent){var s=i;if(`ref`in i)for(var x in s={},i)x!==`ref`&&(s[x]=i[x]);var C=r.defaultProps;if(C)for(var E in s===i&&(s=B({},s,i)),C)s[E]===void 0&&(s[E]=C[E]);i=s,s=Lr,C=r.contextType,typeof C==`object`&&C&&(s=C._currentValue),s=new r(i,s);var D=s.state===void 0?null:s.state;if(s.updater=Gr,s.props=i,s.state=D,C={queue:[],replace:!1},s._reactInternals=C,o=r.contextType,s.context=typeof o==`object`&&o?o._currentValue:Lr,o=r.getDerivedStateFromProps,typeof o==`function`&&(o=o(i,D),D=o==null?D:B({},D,o),s.state=D),typeof r.getDerivedStateFromProps!=`function`&&typeof s.getSnapshotBeforeUpdate!=`function`&&(typeof s.UNSAFE_componentWillMount==`function`||typeof s.componentWillMount==`function`)){if(r=s.state,typeof s.componentWillMount==`function`&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount==`function`&&s.UNSAFE_componentWillMount(),r!==s.state&&Gr.enqueueReplaceState(s,s.state,null),C.queue!==null&&0<C.queue.length){if(r=C.queue,o=C.replace,C.queue=null,C.replace=!1,o&&r.length===1)s.state=r[0];else{for(C=o?r[0]:s.state,D=!0,o=+!!o;o<r.length;o++)E=r[o],E=typeof E==`function`?E.call(s,C,i,void 0):E,E!=null&&(D?(D=!1,C=B({},C,E)):B(C,E));s.state=C}}else C.queue=null}if(r=s.render(),e.status===12)throw null;i=t.keyPath,t.keyPath=n,_a(e,t,r,-1),t.keyPath=i}else{if(r=pa(e,t,n,r,i,void 0),e.status===12)throw null;ma(e,t,n,r,pi!==0,mi,hi)}}else if(typeof r==`string`){if(s=t.blockedSegment,s===null)s=i.children,C=t.formatContext,D=t.keyPath,t.formatContext=Le(C,r,i),t.keyPath=n,Ta(e,t,s,-1),t.formatContext=C,t.keyPath=D;else{if(D=At(s.chunks,r,i,e.resumableState,e.renderState,t.blockedPreamble,t.hoistableState,t.formatContext,s.lastPushedText),s.lastPushedText=!1,C=t.formatContext,o=t.keyPath,t.keyPath=n,(t.formatContext=Le(C,r,i)).insertionMode===3){n=na(e,0,null,t.formatContext,!1,!1),s.preambleChildren.push(n),t.blockedSegment=n;try{n.status=6,Ta(e,t,D,-1),n.lastPushedText&&n.textEmbedded&&n.chunks.push(Ve),n.status=1,ja(e,t.blockedBoundary,n)}finally{t.blockedSegment=s}}else Ta(e,t,D,-1);t.formatContext=C,t.keyPath=o;a:{switch(t=s.chunks,e=e.resumableState,r){case`title`:case`style`:case`script`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`img`:case`input`:case`keygen`:case`link`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:break a;case`body`:if(1>=C.insertionMode){e.hasBody=!0;break a}break;case`html`:if(C.insertionMode===0){e.hasHtml=!0;break a}break;case`head`:if(1>=C.insertionMode)break a}t.push(Mt(r))}s.lastPushedText=!1}}else{switch(r){case b:case l:case u:case c:r=t.keyPath,t.keyPath=n,_a(e,t,i.children,-1),t.keyPath=r;return;case y:r=t.blockedSegment,r===null?i.mode!==`hidden`&&(r=t.keyPath,t.keyPath=n,Ta(e,t,i.children,-1),t.keyPath=r):i.mode!==`hidden`&&(r.chunks.push(Rt),r.lastPushedText=!1,s=t.keyPath,t.keyPath=n,Ta(e,t,i.children,-1),t.keyPath=s,r.chunks.push(zt),r.lastPushedText=!1);return;case h:a:{if(r=i.children,i=i.revealOrder,i===`forwards`||i===`backwards`||i===`unstable_legacy-backwards`){if(T(r)){fa(e,t,n,r,i);break a}if((s=w(r))&&(s=s.call(r))){if(C=s.next(),!C.done){do C=s.next();while(!C.done);fa(e,t,n,r,i)}break a}}i===`together`?(i=t.keyPath,s=t.row,C=t.row=da(null),C.boundaries=[],C.together=!0,t.keyPath=n,_a(e,t,r,-1),--C.pendingTasks===0&&ca(e,C),t.keyPath=i,t.row=s,s!==null&&0<C.pendingTasks&&(s.pendingTasks++,C.next=s)):(i=t.keyPath,t.keyPath=n,_a(e,t,r,-1),t.keyPath=i)}return;case S:case v:throw Error(a(343));case m:a:if(t.replay!==null){r=t.keyPath,s=t.formatContext,C=t.row,t.keyPath=n,t.formatContext=Be(e.resumableState,s),t.row=null,n=i.children;try{Ta(e,t,n,-1)}finally{t.keyPath=r,t.formatContext=s,t.row=C}}else{r=t.keyPath,o=t.formatContext;var O=t.row;E=t.blockedBoundary,x=t.blockedPreamble;var k=t.hoistableState,A=t.blockedSegment,j=i.fallback;i=i.children;var M=new Set,N=2>t.formatContext.insertionMode?$i(e,t.row,M,Pe(),Pe()):$i(e,t.row,M,null,null);e.trackedPostpones!==null&&(N.trackedContentKeyPath=n);var P=na(e,A.chunks.length,N,t.formatContext,!1,!1);A.children.push(P),A.lastPushedText=!1;var F=na(e,0,null,t.formatContext,!1,!1);if(F.parentFlushed=!0,e.trackedPostpones!==null){s=t.componentStack,C=[n[0],`Suspense Fallback`,n[2]],D=[C[1],C[2],[],null],e.trackedPostpones.workingMap.set(C,D),N.trackedFallbackNode=D,t.blockedSegment=P,t.blockedPreamble=N.fallbackPreamble,t.keyPath=C,t.formatContext=ze(e.resumableState,o),t.componentStack=ia(s),P.status=6;try{Ta(e,t,j,-1),P.lastPushedText&&P.textEmbedded&&P.chunks.push(Ve),P.status=1,ja(e,E,P)}catch(t){throw P.status=e.status===12?3:4,t}finally{t.blockedSegment=A,t.blockedPreamble=x,t.keyPath=r,t.formatContext=o}t=ea(e,null,i,-1,N,F,N.contentPreamble,N.contentState,t.abortSet,n,Be(e.resumableState,t.formatContext),t.context,t.treeContext,null,s),ra(t),e.pingedTasks.push(t)}else{t.blockedBoundary=N,t.blockedPreamble=N.contentPreamble,t.hoistableState=N.contentState,t.blockedSegment=F,t.keyPath=n,t.formatContext=Be(e.resumableState,o),t.row=null,F.status=6;try{if(Ta(e,t,i,-1),F.lastPushedText&&F.textEmbedded&&F.chunks.push(Ve),F.status=1,ja(e,N,F),q(N,F),N.pendingTasks===0&&N.status===0){if(N.status=1,!Wi(e,N)){O!==null&&--O.pendingTasks===0&&ca(e,O),e.pendingRootTasks===0&&t.blockedPreamble&&Ia(e);break a}}else O!==null&&O.together&&ua(e,O)}catch(n){N.status=4,e.status===12?(F.status=3,s=e.fatalError):(F.status=4,s=n),C=aa(t.componentStack),D=oa(e,s,C),N.errorDigest=D,Sa(e,N)}finally{t.blockedBoundary=E,t.blockedPreamble=x,t.hoistableState=k,t.blockedSegment=A,t.keyPath=r,t.formatContext=o,t.row=O}t=ea(e,null,j,-1,E,P,N.fallbackPreamble,N.fallbackState,M,[n[0],`Suspense Fallback`,n[2]],ze(e.resumableState,t.formatContext),t.context,t.treeContext,t.row,ia(t.componentStack)),ra(t),e.pingedTasks.push(t)}}return}if(typeof r==`object`&&r)switch(r.$$typeof){case p:if(`ref`in i)for(A in s={},i)A!==`ref`&&(s[A]=i[A]);else s=i;r=pa(e,t,n,r.render,s,o),ma(e,t,n,r,pi!==0,mi,hi);return;case g:ha(e,t,n,r.type,i,o);return;case f:if(C=i.children,s=t.keyPath,i=i.value,D=r._currentValue,r._currentValue=i,o=Rr,Rr=r={parent:o,depth:o===null?0:o.depth+1,context:r,parentValue:D,value:i},t.context=r,t.keyPath=n,_a(e,t,C,-1),e=Rr,e===null)throw Error(a(403));e.context._currentValue=e.parentValue,e=Rr=e.parent,t.context=e,t.keyPath=s;return;case d:i=i.children,r=i(r._context._currentValue),i=t.keyPath,t.keyPath=n,_a(e,t,r,-1),t.keyPath=i;return;case _:if(s=r._init,r=s(r._payload),e.status===12)throw null;ha(e,t,n,r,i,o);return}throw Error(a(130,r==null?r:typeof r,``))}}function ga(e,t,n,r,i){var a=t.replay,o=t.blockedBoundary,s=na(e,0,null,t.formatContext,!1,!1);s.id=n,s.parentFlushed=!0;try{t.replay=null,t.blockedSegment=s,Ta(e,t,r,i),s.status=1,ja(e,o,s),o===null?e.completedRootSegment=s:(q(o,s),o.parentFlushed&&e.partialBoundaries.push(o))}finally{t.replay=a,t.blockedSegment=null}}function _a(e,t,n,r){t.replay!==null&&typeof t.replay.slots==`number`?ga(e,t,t.replay.slots,n,r):(t.node=n,t.childIndex=r,n=t.componentStack,ra(t),va(e,t),t.componentStack=n)}function va(e,t){var n=t.node,r=t.childIndex;if(n!==null){if(typeof n==`object`){switch(n.$$typeof){case o:var i=n.type,c=n.key,l=n.props;n=l.ref;var u=n===void 0?null:n,d=Ir(i),p=c??(r===-1?0:r);if(c=[t.keyPath,d,p],t.replay!==null)a:{var h=t.replay;for(r=h.nodes,n=0;n<r.length;n++){var g=r[n];if(p===g[1]){if(g.length===4){if(d!==null&&d!==g[0])throw Error(a(490,g[0],d));var v=g[2];d=g[3],p=t.node,t.replay={nodes:v,slots:d,pendingTasks:1};try{if(ha(e,t,c,i,l,u),t.replay.pendingTasks===1&&0<t.replay.nodes.length)throw Error(a(488));t.replay.pendingTasks--}catch(a){if(typeof a==`object`&&a&&(a===$r||typeof a.then==`function`))throw t.node===p?t.replay=h:r.splice(n,1),a;t.replay.pendingTasks--,l=aa(t.componentStack),c=e,e=t.blockedBoundary,i=a,l=oa(c,i,l),Da(c,e,v,d,i,l)}t.replay=h}else{if(i!==m)throw Error(a(490,`Suspense`,Ir(i)||`Unknown`));b:{h=void 0,i=g[5],u=g[2],d=g[3],p=g[4]===null?[]:g[4][2],g=g[4]===null?null:g[4][3];var y=t.keyPath,b=t.formatContext,x=t.row,S=t.replay,C=t.blockedBoundary,E=t.hoistableState,D=l.children,O=l.fallback,k=new Set;l=2>t.formatContext.insertionMode?$i(e,t.row,k,Pe(),Pe()):$i(e,t.row,k,null,null),l.parentFlushed=!0,l.rootSegmentID=i,t.blockedBoundary=l,t.hoistableState=l.contentState,t.keyPath=c,t.formatContext=Be(e.resumableState,b),t.row=null,t.replay={nodes:u,slots:d,pendingTasks:1};try{if(Ta(e,t,D,-1),t.replay.pendingTasks===1&&0<t.replay.nodes.length)throw Error(a(488));if(t.replay.pendingTasks--,l.pendingTasks===0&&l.status===0){l.status=1,e.completedBoundaries.push(l);break b}}catch(n){l.status=4,v=aa(t.componentStack),h=oa(e,n,v),l.errorDigest=h,t.replay.pendingTasks--,e.clientRenderedBoundaries.push(l)}finally{t.blockedBoundary=C,t.hoistableState=E,t.replay=S,t.keyPath=y,t.formatContext=b,t.row=x}v=ta(e,null,{nodes:p,slots:g,pendingTasks:0},O,-1,C,l.fallbackState,k,[c[0],`Suspense Fallback`,c[2]],ze(e.resumableState,t.formatContext),t.context,t.treeContext,t.row,ia(t.componentStack)),ra(v),e.pingedTasks.push(v)}}r.splice(n,1);break a}}}else ha(e,t,c,i,l,u);return;case s:throw Error(a(257));case _:if(v=n._init,n=v(n._payload),e.status===12)throw null;_a(e,t,n,r);return}if(T(n)){ya(e,t,n,r);return}if((v=w(n))&&(v=v.call(n))){if(n=v.next(),!n.done){l=[];do l.push(n.value),n=v.next();while(!n.done);ya(e,t,l,r)}return}if(typeof n.then==`function`)return t.thenableState=null,_a(e,t,Ni(n),r);if(n.$$typeof===f)return _a(e,t,n._currentValue,r);throw r=Object.prototype.toString.call(n),Error(a(31,r===`[object Object]`?`object with keys {`+Object.keys(n).join(`, `)+`}`:r))}typeof n==`string`?(r=t.blockedSegment,r!==null&&(r.lastPushedText=He(r.chunks,n,e.renderState,r.lastPushedText))):(typeof n==`number`||typeof n==`bigint`)&&(r=t.blockedSegment,r!==null&&(r.lastPushedText=He(r.chunks,``+n,e.renderState,r.lastPushedText)))}}function ya(e,t,n,r){var i=t.keyPath;if(r!==-1&&(t.keyPath=[t.keyPath,`Fragment`,r],t.replay!==null)){for(var o=t.replay,s=o.nodes,c=0;c<s.length;c++){var l=s[c];if(l[1]===r){r=l[2],l=l[3],t.replay={nodes:r,slots:l,pendingTasks:1};try{if(ya(e,t,n,-1),t.replay.pendingTasks===1&&0<t.replay.nodes.length)throw Error(a(488));t.replay.pendingTasks--}catch(i){if(typeof i==`object`&&i&&(i===$r||typeof i.then==`function`))throw i;t.replay.pendingTasks--,n=aa(t.componentStack);var u=t.blockedBoundary,d=i;n=oa(e,d,n),Da(e,u,r,l,d,n)}t.replay=o,s.splice(c,1);break}}t.keyPath=i;return}if(o=t.treeContext,s=n.length,t.replay!==null&&(c=t.replay.slots,typeof c==`object`&&c)){for(r=0;r<s;r++)l=n[r],t.treeContext=qr(o,s,r),u=c[r],typeof u==`number`?(ga(e,t,u,l,r),delete c[r]):Ta(e,t,l,r);t.treeContext=o,t.keyPath=i;return}for(c=0;c<s;c++)r=n[c],t.treeContext=qr(o,s,c),Ta(e,t,r,c);t.treeContext=o,t.keyPath=i}function ba(e,t,n){if(n.status=5,n.rootSegmentID=e.nextSegmentId++,e=n.trackedContentKeyPath,e===null)throw Error(a(486));var r=n.trackedFallbackNode,i=[],o=t.workingMap.get(e);return o===void 0?(n=[e[1],e[2],i,null,r,n.rootSegmentID],t.workingMap.set(e,n),Ya(n,e[0],t),n):(o[4]=r,o[5]=n.rootSegmentID,o)}function xa(e,t,n,r){r.status=5;var i=n.keyPath,o=n.blockedBoundary;if(o===null)r.id=e.nextSegmentId++,t.rootSlots=r.id,e.completedRootSegment!==null&&(e.completedRootSegment.status=5);else{if(o!==null&&o.status===0){var s=ba(e,t,o);if(o.trackedContentKeyPath===i&&n.childIndex===-1){r.id===-1&&(r.id=r.parentFlushed?o.rootSegmentID:e.nextSegmentId++),s[3]=r.id;return}}if(r.id===-1&&(r.id=r.parentFlushed&&o!==null?o.rootSegmentID:e.nextSegmentId++),n.childIndex===-1)i===null?t.rootSlots=r.id:(n=t.workingMap.get(i),n===void 0?(n=[i[1],i[2],[],r.id],Ya(n,i[0],t)):n[3]=r.id);else{if(i===null){if(e=t.rootSlots,e===null)e=t.rootSlots={};else if(typeof e==`number`)throw Error(a(491))}else if(o=t.workingMap,s=o.get(i),s===void 0)e={},s=[i[1],i[2],[],e],o.set(i,s),Ya(s,i[0],t);else if(e=s[3],e===null)e=s[3]={};else if(typeof e==`number`)throw Error(a(491));e[n.childIndex]=r.id}}}function Sa(e,t){e=e.trackedPostpones,e!==null&&(t=t.trackedContentKeyPath,t!==null&&(t=e.workingMap.get(t),t!==void 0&&(t.length=4,t[2]=[],t[3]=null)))}function Ca(e,t,n){return ta(e,n,t.replay,t.node,t.childIndex,t.blockedBoundary,t.hoistableState,t.abortSet,t.keyPath,t.formatContext,t.context,t.treeContext,t.row,t.componentStack)}function wa(e,t,n){var r=t.blockedSegment,i=na(e,r.chunks.length,null,t.formatContext,r.lastPushedText,!0);return r.children.push(i),r.lastPushedText=!1,ea(e,n,t.node,t.childIndex,t.blockedBoundary,i,t.blockedPreamble,t.hoistableState,t.abortSet,t.keyPath,t.formatContext,t.context,t.treeContext,t.row,t.componentStack)}function Ta(e,t,n,r){var i=t.formatContext,a=t.context,o=t.keyPath,s=t.treeContext,c=t.componentStack,l=t.blockedSegment;if(l===null){l=t.replay;try{return _a(e,t,n,r)}catch(u){if(wi(),n=u===$r?ni():u,e.status!==12&&typeof n==`object`&&n){if(typeof n.then==`function`){r=u===$r?Ci():null,e=Ca(e,t,r).ping,n.then(e,e),t.formatContext=i,t.context=a,t.keyPath=o,t.treeContext=s,t.componentStack=c,t.replay=l,Wr(a);return}if(n.message===`Maximum call stack size exceeded`){n=u===$r?Ci():null,n=Ca(e,t,n),e.pingedTasks.push(n),t.formatContext=i,t.context=a,t.keyPath=o,t.treeContext=s,t.componentStack=c,t.replay=l,Wr(a);return}}}}else{var u=l.children.length,d=l.chunks.length;try{return _a(e,t,n,r)}catch(r){if(wi(),l.children.length=u,l.chunks.length=d,n=r===$r?ni():r,e.status!==12&&typeof n==`object`&&n){if(typeof n.then==`function`){l=n,n=r===$r?Ci():null,e=wa(e,t,n).ping,l.then(e,e),t.formatContext=i,t.context=a,t.keyPath=o,t.treeContext=s,t.componentStack=c,Wr(a);return}if(n.message===`Maximum call stack size exceeded`){l=r===$r?Ci():null,l=wa(e,t,l),e.pingedTasks.push(l),t.formatContext=i,t.context=a,t.keyPath=o,t.treeContext=s,t.componentStack=c,Wr(a);return}}}}throw t.formatContext=i,t.context=a,t.keyPath=o,t.treeContext=s,Wr(a),n}function Ea(e){var t=e.blockedBoundary,n=e.blockedSegment;n!==null&&(n.status=3,Ma(this,t,e.row,n))}function Da(e,t,n,r,i,o){for(var s=0;s<n.length;s++){var c=n[s];if(c.length===4)Da(e,t,c[2],c[3],i,o);else{c=c[5];var l=e,u=o,d=$i(l,null,new Set,null,null);d.parentFlushed=!0,d.rootSegmentID=c,d.status=4,d.errorDigest=u,d.parentFlushed&&l.clientRenderedBoundaries.push(d)}}if(n.length=0,r!==null){if(t===null)throw Error(a(487));if(t.status!==4&&(t.status=4,t.errorDigest=o,t.parentFlushed&&e.clientRenderedBoundaries.push(t)),typeof r==`object`)for(var f in r)delete r[f]}}function Oa(e,t,n){var r=e.blockedBoundary,i=e.blockedSegment;if(i!==null){if(i.status===6)return;i.status=3}var a=aa(e.componentStack);if(r===null){if(t.status!==13&&t.status!==14){if(r=e.replay,r===null){t.trackedPostpones!==null&&i!==null?(r=t.trackedPostpones,oa(t,n,a),xa(t,r,e,i),Ma(t,null,e.row,i)):(oa(t,n,a),sa(t,n));return}r.pendingTasks--,r.pendingTasks===0&&0<r.nodes.length&&(i=oa(t,n,a),Da(t,null,r.nodes,r.slots,n,i)),t.pendingRootTasks--,t.pendingRootTasks===0&&K(t)}}else{var o=t.trackedPostpones;if(r.status!==4){if(o!==null&&i!==null)return oa(t,n,a),xa(t,o,e,i),r.fallbackAbortableTasks.forEach(function(e){return Oa(e,t,n)}),r.fallbackAbortableTasks.clear(),Ma(t,r,e.row,i);r.status=4,i=oa(t,n,a),r.status=4,r.errorDigest=i,Sa(t,r),r.parentFlushed&&t.clientRenderedBoundaries.push(r)}r.pendingTasks--,i=r.row,i!==null&&--i.pendingTasks===0&&ca(t,i),r.fallbackAbortableTasks.forEach(function(e){return Oa(e,t,n)}),r.fallbackAbortableTasks.clear()}e=e.row,e!==null&&--e.pendingTasks===0&&ca(t,e),t.allPendingTasks--,t.allPendingTasks===0&&Aa(t)}function ka(e,t){try{var n=e.renderState,r=n.onHeaders;if(r){var i=n.headers;if(i){n.headers=null;var a=i.preconnects;if(i.fontPreloads&&(a&&(a+=`, `),a+=i.fontPreloads),i.highImagePreloads&&(a&&(a+=`, `),a+=i.highImagePreloads),!t){var o=n.styles.values(),s=o.next();b:for(;0<i.remainingCapacity&&!s.done;s=o.next())for(var c=s.value.sheets.values(),l=c.next();0<i.remainingCapacity&&!l.done;l=c.next()){var u=l.value,d=u.props,f=d.href,p=u.props,m=Tr(p.href,`style`,{crossOrigin:p.crossOrigin,integrity:p.integrity,nonce:p.nonce,type:p.type,fetchPriority:p.fetchPriority,referrerPolicy:p.referrerPolicy,media:p.media});if(0<=(i.remainingCapacity-=m.length+2))n.resets.style[f]=ve,a&&(a+=`, `),a+=m,n.resets.style[f]=typeof d.crossOrigin==`string`||typeof d.integrity==`string`?[d.crossOrigin,d.integrity]:ve;else break b}}r(a?{Link:a}:{})}}}catch(t){oa(e,t,{})}}function K(e){e.trackedPostpones===null&&ka(e,!0),e.trackedPostpones===null&&Ia(e),e.onShellError=Qr,e=e.onShellReady,e()}function Aa(e){ka(e,e.trackedPostpones===null||e.completedRootSegment===null||e.completedRootSegment.status!==5),Ia(e),e=e.onAllReady,e()}function q(e,t){if(t.chunks.length===0&&t.children.length===1&&t.children[0].boundary===null&&t.children[0].id===-1){var n=t.children[0];n.id=t.id,n.parentFlushed=!0,n.status!==1&&n.status!==3&&n.status!==4||q(e,n)}else e.completedSegments.push(t)}function ja(e,t,n){if(te!==null){n=n.chunks;for(var r=0,i=0;i<n.length;i++)r+=n[i].byteLength;t===null?e.byteSize+=r:t.byteSize+=r}}function Ma(e,t,n,r){if(n!==null&&(--n.pendingTasks===0?ca(e,n):n.together&&ua(e,n)),e.allPendingTasks--,t===null){if(r!==null&&r.parentFlushed){if(e.completedRootSegment!==null)throw Error(a(389));e.completedRootSegment=r}e.pendingRootTasks--,e.pendingRootTasks===0&&K(e)}else if(t.pendingTasks--,t.status!==4){if(t.pendingTasks===0){if(t.status===0&&(t.status=1),r!==null&&r.parentFlushed&&(r.status===1||r.status===3)&&q(t,r),t.parentFlushed&&e.completedBoundaries.push(t),t.status===1)n=t.row,n!==null&&Mr(n.hoistables,t.contentState),Wi(e,t)||(t.fallbackAbortableTasks.forEach(Ea,e),t.fallbackAbortableTasks.clear(),n!==null&&--n.pendingTasks===0&&ca(e,n)),e.pendingRootTasks===0&&e.trackedPostpones===null&&t.contentPreamble!==null&&Ia(e);else if(t.status===5&&(t=t.row,t!==null)){if(e.trackedPostpones!==null){n=e.trackedPostpones;var i=t.next;if(i!==null&&(r=i.boundaries,r!==null))for(i.boundaries=null,i=0;i<r.length;i++){var o=r[i];ba(e,n,o),Ma(e,o,null,null)}}--t.pendingTasks===0&&ca(e,t)}}else r===null||!r.parentFlushed||r.status!==1&&r.status!==3||(q(t,r),t.completedSegments.length===1&&t.parentFlushed&&e.partialBoundaries.push(t)),t=t.row,t!==null&&t.together&&ua(e,t)}e.allPendingTasks===0&&Aa(e)}function Na(e){if(e.status!==14&&e.status!==13){var t=Rr,n=me.H;me.H=Fi;var r=me.A;me.A=Li;var i=Zi;Zi=e;var o=Ii;Ii=e.resumableState;try{var s=e.pingedTasks,c;for(c=0;c<s.length;c++){var l=s[c],u=e,d=l.blockedSegment;if(d===null){var f=u;if(l.replay.pendingTasks!==0){Wr(l.context);try{if(typeof l.replay.slots==`number`?ga(f,l,l.replay.slots,l.node,l.childIndex):va(f,l),l.replay.pendingTasks===1&&0<l.replay.nodes.length)throw Error(a(488));l.replay.pendingTasks--,l.abortSet.delete(l),Ma(f,l.blockedBoundary,l.row,null)}catch(e){wi();var p=e===$r?ni():e;if(typeof p==`object`&&p&&typeof p.then==`function`){var m=l.ping;p.then(m,m),l.thenableState=e===$r?Ci():null}else{l.replay.pendingTasks--,l.abortSet.delete(l);var h=aa(l.componentStack);u=void 0;var g=f,_=l.blockedBoundary,v=f.status===12?f.fatalError:p,y=l.replay.nodes,b=l.replay.slots;u=oa(g,v,h),Da(g,_,y,b,v,u),f.pendingRootTasks--,f.pendingRootTasks===0&&K(f),f.allPendingTasks--,f.allPendingTasks===0&&Aa(f)}}}}else if(f=void 0,g=d,g.status===0){g.status=6,Wr(l.context);var x=g.children.length,S=g.chunks.length;try{va(u,l),g.lastPushedText&&g.textEmbedded&&g.chunks.push(Ve),l.abortSet.delete(l),g.status=1,ja(u,l.blockedBoundary,g),Ma(u,l.blockedBoundary,l.row,g)}catch(e){wi(),g.children.length=x,g.chunks.length=S;var C=e===$r?ni():u.status===12?u.fatalError:e;if(u.status===12&&u.trackedPostpones!==null){var w=u.trackedPostpones,T=aa(l.componentStack);l.abortSet.delete(l),oa(u,C,T),xa(u,w,l,g),Ma(u,l.blockedBoundary,l.row,g)}else if(typeof C==`object`&&C&&typeof C.then==`function`){g.status=0,l.thenableState=e===$r?Ci():null;var E=l.ping;C.then(E,E)}else{var D=aa(l.componentStack);l.abortSet.delete(l),g.status=4;var O=l.blockedBoundary,k=l.row;if(k!==null&&--k.pendingTasks===0&&ca(u,k),u.allPendingTasks--,f=oa(u,C,D),O===null)sa(u,C);else if(O.pendingTasks--,O.status!==4){O.status=4,O.errorDigest=f,Sa(u,O);var A=O.row;A!==null&&--A.pendingTasks===0&&ca(u,A),O.parentFlushed&&u.clientRenderedBoundaries.push(O),u.pendingRootTasks===0&&u.trackedPostpones===null&&O.contentPreamble!==null&&Ia(u)}u.allPendingTasks===0&&Aa(u)}}}}s.splice(0,c),e.destination!==null&&Wa(e,e.destination)}catch(t){oa(e,t,{}),sa(e,t)}finally{Ii=o,me.H=n,me.A=r,n===Fi&&Wr(t),Zi=i}}}function Pa(e,t,n){t.preambleChildren.length&&n.push(t.preambleChildren);for(var r=!1,i=0;i<t.children.length;i++)r=Fa(e,t.children[i],n)||r;return r}function Fa(e,t,n){var r=t.boundary;if(r===null)return Pa(e,t,n);var i=r.contentPreamble,o=r.fallbackPreamble;if(i===null||o===null)return!1;switch(r.status){case 1:if(Nt(e.renderState,i),e.byteSize+=r.byteSize,t=r.completedSegments[0],!t)throw Error(a(391));return Pa(e,t,n);case 5:if(e.trackedPostpones!==null)return!0;case 4:if(t.status===1)return Nt(e.renderState,o),Pa(e,t,n);default:return!0}}function Ia(e){if(e.completedRootSegment&&e.completedPreambleSegments===null){var t=[],n=e.byteSize,r=Fa(e,e.completedRootSegment,t),i=e.renderState.preamble;!1===r||i.headChunks&&i.bodyChunks?e.completedPreambleSegments=t:e.byteSize=n}}function La(e,t,n,r){switch(n.parentFlushed=!0,n.status){case 0:n.id=e.nextSegmentId++;case 5:return r=n.id,n.lastPushedText=!1,n.textEmbedded=!1,e=e.renderState,F(t,It),F(t,e.placeholderPrefix),e=R(r.toString(16)),F(t,e),I(t,Lt);case 1:n.status=2;var i=!0,o=n.chunks,s=0;n=n.children;for(var c=0;c<n.length;c++){for(i=n[c];s<i.index;s++)F(t,o[s]);i=za(e,t,i,r)}for(;s<o.length-1;s++)F(t,o[s]);return s<o.length&&(i=I(t,o[s])),i;case 3:return!0;default:throw Error(a(390))}}var Ra=0;function za(e,t,n,r){var i=n.boundary;if(i===null)return La(e,t,n,r);if(i.parentFlushed=!0,i.status===4){var o=i.row;o!==null&&--o.pendingTasks===0&&ca(e,o),i=i.errorDigest,I(t,Ut),F(t,Gt),i&&(F(t,qt),F(t,R(H(i))),F(t,Kt)),I(t,Jt),La(e,t,n,r)}else if(i.status!==1)i.status===0&&(i.rootSegmentID=e.nextSegmentId++),0<i.completedSegments.length&&e.partialBoundaries.push(i),Yt(t,e.renderState,i.rootSegmentID),r&&Mr(r,i.fallbackState),La(e,t,n,r);else if(!Ua&&Wi(e,i)&&(Ra+i.byteSize>e.progressiveChunkSize||Nr(i.contentState)))i.rootSegmentID=e.nextSegmentId++,e.completedBoundaries.push(i),Yt(t,e.renderState,i.rootSegmentID),La(e,t,n,r);else{if(Ra+=i.byteSize,r&&Mr(r,i.contentState),n=i.row,n!==null&&Wi(e,i)&&--n.pendingTasks===0&&ca(e,n),I(t,Bt),n=i.completedSegments,n.length!==1)throw Error(a(391));za(e,t,n[0],r)}return I(t,Wt)}function Ba(e,t,n,r){return vn(t,e.renderState,n.parentFormatContext,n.id),za(e,t,n,r),yn(t,n.parentFormatContext)}function Va(e,t,n){Ra=n.byteSize;for(var r=n.completedSegments,i=0;i<r.length;i++)Ha(e,t,n,r[i]);r.length=0,r=n.row,r!==null&&Wi(e,n)&&--r.pendingTasks===0&&ca(e,r),Xn(t,n.contentState,e.renderState),r=e.resumableState,e=e.renderState,i=n.rootSegmentID,n=n.contentState;var a=e.stylesToHoist;return e.stylesToHoist=!1,F(t,e.startInlineScript),F(t,ot),a?(!(r.instructions&4)&&(r.instructions|=4,F(t,Mn)),!(r.instructions&2)&&(r.instructions|=2,F(t,wn)),r.instructions&8?F(t,Dn):(r.instructions|=8,F(t,En))):(!(r.instructions&2)&&(r.instructions|=2,F(t,wn)),F(t,Tn)),r=R(i.toString(16)),F(t,e.boundaryPrefix),F(t,r),F(t,On),F(t,e.segmentPrefix),F(t,r),a?(F(t,kn),mr(t,n)):F(t,An),n=I(t,jn),Pt(t,e)&&n}function Ha(e,t,n,r){if(r.status===2)return!0;var i=n.contentState,o=r.id;if(o===-1){if((r.id=n.rootSegmentID)===-1)throw Error(a(392));return Ba(e,t,r,i)}return o===n.rootSegmentID?Ba(e,t,r,i):(Ba(e,t,r,i),n=e.resumableState,e=e.renderState,F(t,e.startInlineScript),F(t,ot),n.instructions&1?F(t,xn):(n.instructions|=1,F(t,bn)),F(t,e.segmentPrefix),o=R(o.toString(16)),F(t,o),F(t,Sn),F(t,e.placeholderPrefix),F(t,o),t=I(t,Cn),t)}var Ua=!1;function Wa(e,t){N=new Uint8Array(2048),P=0;try{if(!(0<e.pendingRootTasks)){var n,r=e.completedRootSegment;if(r!==null){if(r.status===5)return;var i=e.completedPreambleSegments;if(i===null)return;Ra=e.byteSize;var a=e.resumableState,o=e.renderState,s=o.preamble,c=s.htmlChunks,l=s.headChunks,u;if(c){for(u=0;u<c.length;u++)F(t,c[u]);if(l)for(u=0;u<l.length;u++)F(t,l[u]);else F(t,Ot(`head`)),F(t,ot)}else if(l)for(u=0;u<l.length;u++)F(t,l[u]);var d=o.charsetChunks;for(u=0;u<d.length;u++)F(t,d[u]);d.length=0,o.preconnects.forEach(Zn,t),o.preconnects.clear();var f=o.viewportChunks;for(u=0;u<f.length;u++)F(t,f[u]);f.length=0,o.fontPreloads.forEach(Zn,t),o.fontPreloads.clear(),o.highImagePreloads.forEach(Zn,t),o.highImagePreloads.clear(),ye=o,o.styles.forEach(ar,t),ye=null;var p=o.importMapChunks;for(u=0;u<p.length;u++)F(t,p[u]);p.length=0,o.bootstrapScripts.forEach(Zn,t),o.scripts.forEach(Zn,t),o.scripts.clear(),o.bulkPreloads.forEach(Zn,t),o.bulkPreloads.clear(),c||l||(a.instructions|=32);var m=o.hoistableChunks;for(u=0;u<m.length;u++)F(t,m[u]);for(a=m.length=0;a<i.length;a++){var h=i[a];for(o=0;o<h.length;o++)za(e,t,h[o],null)}var g=e.renderState.preamble,_=g.headChunks;(g.htmlChunks||_)&&F(t,Mt(`head`));var v=g.bodyChunks;if(v)for(i=0;i<v.length;i++)F(t,v[i]);za(e,t,r,null),e.completedRootSegment=null;var y=e.renderState;if(e.allPendingTasks!==0||e.clientRenderedBoundaries.length!==0||e.completedBoundaries.length!==0||e.trackedPostpones!==null&&(e.trackedPostpones.rootNodes.length!==0||e.trackedPostpones.rootSlots!==null)){var b=e.resumableState;if(!(b.instructions&64)){if(b.instructions|=64,F(t,y.startInlineScript),!(b.instructions&32)){b.instructions|=32;var x=`_`+b.idPrefix+`R_`;F(t,cr),F(t,R(H(x))),F(t,Xe)}F(t,ot),F(t,Ft),I(t,xe)}}Pt(t,y)}var S=e.renderState;r=0;var C=S.viewportChunks;for(r=0;r<C.length;r++)F(t,C[r]);C.length=0,S.preconnects.forEach(Zn,t),S.preconnects.clear(),S.fontPreloads.forEach(Zn,t),S.fontPreloads.clear(),S.highImagePreloads.forEach(Zn,t),S.highImagePreloads.clear(),S.styles.forEach(sr,t),S.scripts.forEach(Zn,t),S.scripts.clear(),S.bulkPreloads.forEach(Zn,t),S.bulkPreloads.clear();var w=S.hoistableChunks;for(r=0;r<w.length;r++)F(t,w[r]);w.length=0;var T=e.clientRenderedBoundaries;for(n=0;n<T.length;n++){var E=T[n];S=t;var D=e.resumableState,O=e.renderState,k=E.rootSegmentID,A=E.errorDigest;F(S,O.startInlineScript),F(S,ot),D.instructions&4?F(S,Pn):(D.instructions|=4,F(S,Nn)),F(S,O.boundaryPrefix),F(S,R(k.toString(16))),F(S,Fn),A&&(F(S,In),F(S,R(zn(A||``))));var j=I(S,Ln);if(!j){e.destination=null,n++,T.splice(0,n);return}}T.splice(0,n);var M=e.completedBoundaries;for(n=0;n<M.length;n++)if(!Va(e,t,M[n])){e.destination=null,n++,M.splice(0,n);return}M.splice(0,n),L(t),N=new Uint8Array(2048),P=0,Ua=!0;var ee=e.partialBoundaries;for(n=0;n<ee.length;n++){var z=ee[n];a:{T=e,E=t,Ra=z.byteSize;var te=z.completedSegments;for(j=0;j<te.length;j++)if(!Ha(T,E,z,te[j])){j++,te.splice(0,j);var ne=!1;break a}te.splice(0,j);var B=z.row;B!==null&&B.together&&z.pendingTasks===1&&(B.pendingTasks===1?la(T,B,B.hoistables):B.pendingTasks--),ne=Xn(E,z.contentState,T.renderState)}if(!ne){e.destination=null,n++,ee.splice(0,n);return}}ee.splice(0,n),Ua=!1;var V=e.completedBoundaries;for(n=0;n<V.length;n++)if(!Va(e,t,V[n])){e.destination=null,n++,V.splice(0,n);return}V.splice(0,n)}}finally{Ua=!1,e.allPendingTasks===0&&e.clientRenderedBoundaries.length===0&&e.completedBoundaries.length===0?(e.flushScheduled=!1,n=e.resumableState,n.hasBody&&F(t,Mt(`body`)),n.hasHtml&&F(t,Mt(`html`)),L(t),e.status=14,t.close(),e.destination=null):L(t)}}function Ga(e){e.flushScheduled=e.destination!==null,M(function(){return Na(e)}),k(function(){e.status===10&&(e.status=11),e.trackedPostpones===null&&ka(e,e.pendingRootTasks===0)})}function Ka(e){!1===e.flushScheduled&&e.pingedTasks.length===0&&e.destination!==null&&(e.flushScheduled=!0,k(function(){var t=e.destination;t?Wa(e,t):e.flushScheduled=!1}))}function qa(e,t){if(e.status===13)e.status=14,ne(t,e.fatalError);else if(e.status!==14&&e.destination===null){e.destination=t;try{Wa(e,t)}catch(t){oa(e,t,{}),sa(e,t)}}}function Ja(e,t){(e.status===11||e.status===10)&&(e.status=12);try{var n=e.abortableTasks;if(0<n.size){var r=t===void 0?Error(a(432)):typeof t==`object`&&t&&typeof t.then==`function`?Error(a(530)):t;e.fatalError=r,n.forEach(function(t){return Oa(t,e,r)}),n.clear()}e.destination!==null&&Wa(e,e.destination)}catch(t){oa(e,t,{}),sa(e,t)}}function Ya(e,t,n){if(t===null)n.rootNodes.push(e);else{var r=n.workingMap,i=r.get(t);i===void 0&&(i=[t[1],t[2],[],null],r.set(t,i),Ya(i,t[0],n)),i[2].push(e)}}function Xa(e){var t=e.trackedPostpones;if(t===null||t.rootNodes.length===0&&t.rootSlots===null)return e.trackedPostpones=null;if(e.completedRootSegment===null||e.completedRootSegment.status!==5&&e.completedPreambleSegments!==null){var n=e.nextSegmentId,r=t.rootSlots,i=e.resumableState;i.bootstrapScriptContent=void 0,i.bootstrapScripts=void 0,i.bootstrapModules=void 0}else{n=0,r=-1,i=e.resumableState;var a=e.renderState;i.nextFormID=0,i.hasBody=!1,i.hasHtml=!1,i.unknownResources={font:a.resets.font},i.dnsResources=a.resets.dns,i.connectResources=a.resets.connect,i.imageResources=a.resets.image,i.styleResources=a.resets.style,i.scriptResources={},i.moduleUnknownResources={},i.moduleScriptResources={},i.instructions=0}return{nextSegmentId:n,rootFormatContext:e.rootFormatContext,progressiveChunkSize:e.progressiveChunkSize,resumableState:e.resumableState,replayNodes:t.rootNodes,replaySlots:r}}function Za(){var e=t.version;if(e!==`19.2.8`)throw Error(a(527,e,`19.2.8`))}Za(),Za(),e.prerender=function(e,t){return new Promise(function(n,r){var i=t?t.onHeaders:void 0,a;i&&(a=function(e){i(new Headers(e))});var o=Ne(t?t.identifierPrefix:void 0,t?t.unstable_externalRuntimeSrc:void 0,t?t.bootstrapScriptContent:void 0,t?t.bootstrapScripts:void 0,t?t.bootstrapModules:void 0),s=Ji(e,o,Me(o,void 0,t?t.unstable_externalRuntimeSrc:void 0,t?t.importMap:void 0,a,t?t.maxHeadersLength:void 0),Ie(t?t.namespaceURI:void 0),t?t.progressiveChunkSize:void 0,t?t.onError:void 0,function(){var e=new ReadableStream({type:`bytes`,pull:function(e){qa(s,e)},cancel:function(e){s.destination=null,Ja(s,e)}},{highWaterMark:0});e={postponed:Xa(s),prelude:e},n(e)},void 0,void 0,r,t?t.onPostpone:void 0);if(t&&t.signal){var c=t.signal;if(c.aborted)Ja(s,c.reason);else{var l=function(){Ja(s,c.reason),c.removeEventListener(`abort`,l)};c.addEventListener(`abort`,l)}}Ga(s)})},e.renderToReadableStream=function(e,t){return new Promise(function(n,r){var i,a,o=new Promise(function(e,t){a=e,i=t}),s=t?t.onHeaders:void 0,c;s&&(c=function(e){s(new Headers(e))});var l=Ne(t?t.identifierPrefix:void 0,t?t.unstable_externalRuntimeSrc:void 0,t?t.bootstrapScriptContent:void 0,t?t.bootstrapScripts:void 0,t?t.bootstrapModules:void 0),u=qi(e,l,Me(l,t?t.nonce:void 0,t?t.unstable_externalRuntimeSrc:void 0,t?t.importMap:void 0,c,t?t.maxHeadersLength:void 0),Ie(t?t.namespaceURI:void 0),t?t.progressiveChunkSize:void 0,t?t.onError:void 0,a,function(){var e=new ReadableStream({type:`bytes`,pull:function(e){qa(u,e)},cancel:function(e){u.destination=null,Ja(u,e)}},{highWaterMark:0});e.allReady=o,n(e)},function(e){o.catch(function(){}),r(e)},i,t?t.onPostpone:void 0,t?t.formState:void 0);if(t&&t.signal){var d=t.signal;if(d.aborted)Ja(u,d.reason);else{var f=function(){Ja(u,d.reason),d.removeEventListener(`abort`,f)};d.addEventListener(`abort`,f)}}Ga(u)})},e.resume=function(e,t,n){return new Promise(function(r,i){var a,o,s=new Promise(function(e,t){o=e,a=t}),c=Yi(e,t,Me(t.resumableState,n?n.nonce:void 0,void 0,void 0,void 0,void 0),n?n.onError:void 0,o,function(){var e=new ReadableStream({type:`bytes`,pull:function(e){qa(c,e)},cancel:function(e){c.destination=null,Ja(c,e)}},{highWaterMark:0});e.allReady=s,r(e)},function(e){s.catch(function(){}),i(e)},a,n?n.onPostpone:void 0);if(n&&n.signal){var l=n.signal;if(l.aborted)Ja(c,l.reason);else{var u=function(){Ja(c,l.reason),l.removeEventListener(`abort`,u)};l.addEventListener(`abort`,u)}}Ga(c)})},e.resumeAndPrerender=function(e,t,n){return new Promise(function(r,i){var a=Xi(e,t,Me(t.resumableState,void 0,void 0,void 0,void 0,void 0),n?n.onError:void 0,function(){var e=new ReadableStream({type:`bytes`,pull:function(e){qa(a,e)},cancel:function(e){a.destination=null,Ja(a,e)}},{highWaterMark:0});e={postponed:Xa(a),prelude:e},r(e)},void 0,void 0,i,n?n.onPostpone:void 0);if(n&&n.signal){var o=n.signal;if(o.aborted)Ja(a,o.reason);else{var s=function(){Ja(a,o.reason),o.removeEventListener(`abort`,s)};o.addEventListener(`abort`,s)}}Ga(a)})},e.version=`19.2.8`})),GL=t((e=>{var t=UL(),n=WL();e.version=t.version,e.renderToString=t.renderToString,e.renderToStaticMarkup=t.renderToStaticMarkup,e.renderToReadableStream=n.renderToReadableStream,e.resume=n.resume}))();function KL(e){return(0,q.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 qL=class extends K.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){if(this.state.failed)return KL(this.props.pluginId);try{(0,GL.renderToStaticMarkup)((0,q.jsx)(q.Fragment,{children:this.props.children}))}catch{return KL(this.props.pluginId)}return this.props.children}};function JL({panels:e,theme:t}){return e.length===0?null:(0,q.jsx)(`div`,{className:`w-full`,children:(0,q.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,q.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,q.jsx)(nr,{className:`h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),`Plugins`]}),(0,q.jsx)(`div`,{children:e.map((n,r)=>{let i=r===e.length-1,{Component:a}=n;return(0,q.jsx)(`div`,{className:u(`px-4 py-3 bg-background`,!i&&`border-b border-border`),children:(0,q.jsx)(qL,{pluginId:n.pluginId,children:(0,q.jsx)(a,{theme:t})})},`${n.pluginId}:${n.surfaceId}`)})})]})})}var YL={colors:{foreground:`var(--foreground)`}};function XL(){let e=xn(mn);return(0,q.jsx)(JL,{panels:e,theme:YL})}var ZL={askUserQuestionSurface:`footer`},QL={askUserQuestionSurface:`inline`};function $L(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 eR(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 tR=(0,K.memo)(({activeChatId:e,listRef:t,messages:n,transcriptPaddingBottom:r,isHistoryLoading:i,hasOlderHistory:a,loadOlderHistory:s,showScrollButton:c,onIsAtEndChange:l,scrollToBottom:d,typedEmptyStateText:f,isEmptyStateTypingComplete:p,isPageFileDragActive:m,showEmptyState:h,onOpenLocalLink:g,headerOffsetPx:_=72,ports:v})=>{let{localPath:y,latestToolIds:b,isProcessing:x,queuedMessages:S,runtimeStatus:C,isDraining:w,commandError:T,onStopDraining:E,onSteerQueuedMessage:D,onRemoveQueuedMessage:O,onAskUserQuestionSubmit:k,onSubagentAskUserQuestionSubmit:A,onSubagentExitPlanModeSubmit:j,schedules:M,cronJobs:N,onAutoContinueAccept:P,tunnels:F,liveTunnelId:I,onTunnelAccept:L,onTunnelStop:ee,onTunnelRetry:R,subagentRuns:z,onCancelSubagentRun:te,loopProgress:ne,workflowRuns:B,backgroundTasks:V,getWorkflowRunDetail:re,getSubagentTranscript:ie,editorPreset:ae,editorCommandTemplate:oe,platform:se}=BI(),ce=v?.dom??o,le=v?.timer??fi,H=(0,K.useRef)(0),ue=(0,K.useRef)(null),de=KT.useScopedStore(e=>e.toolGroupExpanded),fe=KT.useScopedStore(e=>e.resetToolGroupExpanded),pe=Qp(e=>e.localLinkMenuTarget),me=Qp(e=>e.setLocalLinkMenuTarget),he=Qp(e=>e.setLocalLinkMenuOpen),ge=se===`darwin`,_e=nL((0,K.useMemo)(()=>oL(n,{isLoading:x,localPath:y??void 0,latestToolIds:b}),[x,b,y,n])),ve=(0,K.useMemo)(()=>EL(_e),[_e]);(0,K.useEffect)(()=>{fe()},[e,fe]),(0,K.useEffect)(()=>{let e=H.current;if(H.current=_e.length,e>0||_e.length===0)return;l(!0);let n=le.requestAnimationFrame(()=>{t.current?.scrollToEnd?.({animated:!1})});return()=>le.cancelAnimationFrame(n)},[t,l,_e.length,le]);let{runsByDelegateToolId:ye,childrenByParentRunId:be}=(0,K.useMemo)(()=>{let{matched:e}=II(FI(n),Object.values(z).filter(e=>e.parentRunId===null)),t=new Map;for(let e of Object.values(z)){if(e.parentRunId===null)continue;let n=t.get(e.parentRunId)??[];n.push(e),t.set(e.parentRunId,n)}let r=(e,t)=>e.startedAt-t.startedAt||e.runId.localeCompare(t.runId);for(let e of t.values())e.sort(r);return{runsByDelegateToolId:e,childrenByParentRunId:t}},[n,z]),xe=(0,K.useMemo)(()=>eR(z),[z]),U=(0,K.useMemo)(()=>$L(n,b),[n,b]),Se=(0,K.useMemo)(()=>function e(t,n){let r=be.get(t.runId)??[];return(0,q.jsxs)(K.Fragment,{children:[(0,q.jsx)(PL,{run:t,indentDepth:n,localPath:y??``,onSubagentAskUserQuestionSubmit:A,onSubagentExitPlanModeSubmit:j,onCancelSubagentRun:te,suppressPendingTool:!0}),r.map(t=>e(t,n+1))]},t.runId)},[be,y,A,j,te]),Ce=(0,K.useCallback)(e=>{let n=typeof e==`object`&&e&&`currentTarget`in e&&e.currentTarget instanceof HTMLElement?e.currentTarget:t.current?.getScrollableNode?.();if(n instanceof HTMLElement){l(n.scrollHeight-n.clientHeight-n.scrollTop<=4);return}let r=t.current?.getState?.();r&&l(r.isAtEnd)},[t,l]);(0,K.useEffect)(()=>{let e,n=le.requestAnimationFrame(()=>{let n=t.current?.getScrollableNode?.();if(!(n instanceof HTMLElement))return;let r=()=>{Ce({currentTarget:n})};n.addEventListener(`scroll`,r,{passive:!0}),r(),e=()=>{n.removeEventListener(`scroll`,r)}});return()=>{le.cancelAnimationFrame(n),e?.()}},[e,Ce,t,_e.length,le]),(0,K.useEffect)(()=>{let e,n=le.requestAnimationFrame(()=>{let n=t.current?.getScrollableNode?.();if(!(n instanceof HTMLElement))return;let r=n.scrollBy;if(typeof r!=`function`)return;let i=!1,a,o=()=>{a!==void 0&&le.clearTimeout(a),a=le.setTimeout(()=>{a=void 0,i=!1},120)};function s(...e){i||Reflect.apply(r,n,e)}n.scrollBy=s;let c=()=>{a!==void 0&&(le.clearTimeout(a),a=void 0),i=!0},l=()=>{o()},u=()=>{i&&o()};n.addEventListener(`touchstart`,c,{passive:!0}),n.addEventListener(`touchend`,l,{passive:!0}),n.addEventListener(`touchcancel`,l,{passive:!0}),n.addEventListener(`scroll`,u,{passive:!0}),e=()=>{a!==void 0&&le.clearTimeout(a),n.removeEventListener(`touchstart`,c),n.removeEventListener(`touchend`,l),n.removeEventListener(`touchcancel`,l),n.removeEventListener(`scroll`,u),n.scrollBy===s&&Reflect.deleteProperty(n,`scrollBy`)}});return()=>{le.cancelAnimationFrame(n),e?.()}},[e,t,le]);let we=(0,K.useCallback)(()=>{i||!a||s()},[a,i,s]),Te=(0,K.useCallback)(e=>{if(e.trigger!==`contextmenu`){g(e,rt(e.path)?`open_editor`:`open_default`);return}me(e),le.requestAnimationFrame(()=>{let t=ue.current;if(!t)return;let n=e.clientX??ce.getInnerWidth()/2,r=e.clientY??ce.getInnerHeight()/2;ce.dispatchContextMenuEvent(t,n,r)})},[ce,g,me,le]),Ee=(0,K.useCallback)(({item:e})=>{let t=e.kind===`single`&&e.message.kind===`tool`&&e.message.toolName===`mcp__kanna__delegate_subagent`?e.message.toolId:null,n=t==null?null:ye.get(t);return(0,q.jsxs)(`div`,{className:u(`mx-auto w-full max-w-[800px]`,ve.get(e.id)??`pt-4`),"data-transcript-row-id":e.id,children:[(0,q.jsx)(sL,{row:e,toolGroupExpanded:e.kind===`tool-group`?de[e.id]??!1:void 0}),n?Se(n,0):null]})},[de,ye,Se,ve]),De=(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-[800px]`,style:{paddingTop:`${_}px`},children:i?(0,q.jsx)(`div`,{className:`flex justify-center pb-4`,children:(0,q.jsx)(`span`,{className:`text-sm translate-y-[-0.5px]`,children:(0,q.jsx)(Mt,{animate:!0,shimmerWidth:72,children:`Loading more messages...`})})}):null}),Oe=I&&F?F[I]:void 0,ke=(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-[800px] pt-4`,children:[(0,q.jsx)(XL,{}),ne&&(ne.armed||ne.rows.length>0)?(0,q.jsx)(`div`,{className:`pb-4`,children:(0,q.jsx)(RL,{loopProgress:ne,onResume:P})}):null,e&&N.length>0?(0,q.jsx)(`div`,{className:`pb-4`,children:(0,q.jsx)(vL,{jobs:N,chatId:e})}):null,B&&B.length>0&&re?(0,q.jsx)(`div`,{className:`pb-4`,children:(0,q.jsx)(Ot,{runs:B,getRunDetail:re})}):null,Oe&&L&&ee&&R&&(0,q.jsx)(`div`,{className:`pb-4`,children:(0,q.jsx)(IL,{record:Oe,onAccept:L,onStop:ee,onRetry:R,onDismiss:ee})}),e&&V&&V.length>0?(0,q.jsx)(`div`,{className:`pb-4`,children:(0,q.jsx)(HL,{chatId:e,tasks:V})}):null,x?(0,q.jsx)(_L,{status:C??void 0}):null,S.map(e=>(0,q.jsx)(hL,{message:e,onRemove:()=>void O(e.id),onSendNow:()=>void D(e.id)},e.id)),!x&&w?(0,q.jsx)(mL,{onStop:()=>void E()}):null,T?(0,q.jsx)(`div`,{className:`rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive whitespace-pre-wrap`,children:pt(T)}):null,U?(0,q.jsxs)(`div`,{className:`mb-3`,"data-testid":`main-pending-footer:${U.toolId}`,children:[(0,q.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,q.jsx)(ze,{className:`h-3.5 w-3.5 shrink-0`}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`text-foreground`,children:`Claude`}),` needs your input`]})]}),(0,q.jsx)(Jt,{value:QL,children:(0,q.jsx)(LF,{message:U,onSubmit:k,isLatest:!0})})]}):null,xe.length>0&&A&&j?xe.map(e=>(0,q.jsxs)(`div`,{"data-testid":`subagent-pending-footer:${e.runId}`,className:`mb-3`,children:[(0,q.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,q.jsx)(Sr,{className:`h-3.5 w-3.5 shrink-0`}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`text-foreground`,children:e.subagentName}),` needs your input`]})]}),(0,q.jsx)(kL,{pendingTool:e.pendingTool,onAskUserQuestionSubmit:(t,n,r)=>A(e.runId,t,n,r),onExitPlanModeSubmit:(t,n)=>j(e.runId,t,n)})]},e.runId)):null]});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ft,{value:ie??null,children:(0,q.jsx)(nt,{onOpenLocalLink:Te,children:(0,q.jsx)(Jt,{value:U?ZL:QL,children:(0,q.jsx)(pp,{ref:t,data:_e,extraData:{toolGroupExpanded:de,schedules:M,tunnels:F,liveTunnelId:I},keyExtractor:nR,renderItem:Ee,estimatedItemSize:48,initialScrollAtEnd:!0,maintainScrollAtEnd:!0,maintainScrollAtEndThreshold:.1,maintainVisibleContentPosition:!0,onScroll:Ce,onStartReached:we,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:De,ListFooterComponent:ke})})})}),(0,q.jsxs)(wn,{onOpenChange:he,children:[(0,q.jsx)($t,{asChild:!0,children:(0,q.jsx)(`span`,{ref:ue,"aria-hidden":`true`,className:`pointer-events-none fixed size-px opacity-0`,style:{left:pe?.clientX??0,top:pe?.clientY??0}})}),pe?(0,q.jsx)(pP,{isMac:ge,editorPreset:ae,editorCommandTemplate:oe,includeFinder:!0,includePreview:!0,includeDefault:!0,onOpenExternal:(e,t)=>{g(pe,e,t)}}):null]}),h?(0,q.jsx)(`div`,{className:`pointer-events-none absolute inset-x-4 animate-fade-in`,style:{top:_,bottom:r},children:(0,q.jsx)(`div`,{className:`mx-auto flex h-full max-w-[800px] items-center justify-center`,children:(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 text-muted-foreground opacity-70`,children:[(0,q.jsx)(tn,{strokeWidth:1.5,className:`kanna-empty-state-flower size-8 text-muted-foreground`}),(0,q.jsx)(`div`,{className:`kanna-empty-state-text flex max-w-xs items-center text-center text-base font-normal text-muted-foreground`,"aria-label":Yw,children:(0,q.jsxs)(`span`,{className:`relative inline-grid place-items-start`,children:[(0,q.jsxs)(`span`,{className:`invisible col-start-1 row-start-1 flex items-center whitespace-pre`,children:[(0,q.jsx)(`span`,{children:Yw}),(0,q.jsx)(`span`,{className:`kanna-typewriter-cursor-slot`,"aria-hidden":`true`})]}),(0,q.jsxs)(`span`,{className:`col-start-1 row-start-1 flex items-center whitespace-pre`,children:[(0,q.jsx)(`span`,{children:f}),(0,q.jsx)(`span`,{className:`kanna-typewriter-cursor-slot`,"aria-hidden":`true`,children:(0,q.jsx)(`span`,{className:`kanna-typewriter-cursor`,"data-typing-complete":p?`true`:`false`})})]})]})})]})})}):null,m?(0,q.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-30`,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-background/70`}),(0,q.jsx)(`div`,{className:`absolute inset-6 `,children:(0,q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 text-center`,children:[(0,q.jsx)(Oa,{className:`mx-auto size-14 text-foreground`,strokeWidth:1.75}),(0,q.jsx)(`div`,{className:`text-xl font-medium text-foreground`,children:`Drop up to 10 files`})]})})})]}):null,(0,q.jsx)(`div`,{style:{bottom:r-20},className:u(`absolute left-1/2 z-10 -translate-x-1/2 transition-[transform,opacity] motion-reduce:transition-none`,c?`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,q.jsx)(`button`,{onClick:d,"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,q.jsx)(Vi,{"aria-hidden":`true`,className:`h-5 w-5`})})})]})});function nR(e){return e.id}var rR=[],iR={};function aR(){let e=(0,K.useRef)(null),t=KT.useScopedStore(e=>e.inputHeight),n=KT.useScopedStore(e=>e.setInputHeight),r=KT.useScopedStoreApi(),i=(0,K.useCallback)(()=>{let t=e.current;if(!t)return;let i=t.getBoundingClientRect().height,a=r.getState().inputHeight,o=kn(a,i);o!==a&&n(o)},[n,r]);return(0,K.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:vn(t)}}function oR(e,t,n){let r=Qp(e=>e.typedEmptyStateText),i=Qp(e=>e.isEmptyStateTypingComplete),a=Qp(e=>e.setTypedEmptyStateText),o=Qp(e=>e.setIsEmptyStateTypingComplete),s=Qp(e=>e.resetEmptyStateTyping);return(0,K.useEffect)(()=>{if(!e)return;s();let t=0,r=n.setInterval(()=>{t+=1,a(Yw.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 sR(e){let t=Qp(e=>e.isPageFileDragActive),n=Qp(e=>e.setIsPageFileDragActive),r=(0,K.useRef)(0),i=(0,K.useCallback)(e=>eT(e.dataTransfer?.types??[]),[]);return{isPageFileDragActive:t,handleTranscriptDragEnter:(0,K.useCallback)(t=>{!i(t)||!e.hasSelectedProject||(t.preventDefault(),r.current+=1,n(!0))},[e.hasSelectedProject,i,n]),handleTranscriptDragOver:(0,K.useCallback)(r=>{!i(r)||!e.hasSelectedProject||(r.preventDefault(),r.dataTransfer.dropEffect=`copy`,t||n(!0))},[e.hasSelectedProject,i,t,n]),handleTranscriptDragLeave:(0,K.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,K.useCallback)(t=>{!i(t)||!e.hasSelectedProject||(t.preventDefault(),r.current=0,n(!1),e.onFilesDropped([...t.dataTransfer.files]))},[e,i,n])}}function cR({timer:e,dom:t,onToggleEmbeddedTerminal:n,onToggleRightSidebar:r}){let i=JT(),a=(0,K.useRef)(null),o=(0,K.useRef)(!0),s=(0,K.useRef)(null),c=(0,K.useRef)(null),l=(0,K.useRef)(null),u=(0,K.useRef)(null),{inputRef:d,syncInputHeight:p,transcriptPaddingBottom:m}=aR(),h=KT.useScopedStore(e=>e.showScrollToBottom),g=KT.useScopedStore(e=>e.setShowScrollToBottom),_=KT.useScopedStore(e=>e.setToolGroupExpanded),v=(0,K.useCallback)((e,t)=>{_(n=>n[e]===t?n:{...n,[e]:t})},[_]),y=f(),b=(0,K.useCallback)(e=>{y(`/chat/${e}`)},[y]),x=i.activeProjectId,S=en(e=>x?e.projects[x]:void 0)??fn,C=Ln(e=>x?e.projects[x]:void 0)??Nn,w=ce(D),T=ce(V),E=S.terminals.length>0,O=!!(x&&S.isVisible&&E),k=!!(x&&C.isVisible),A=(0,K.useMemo)(()=>rr(i.keybindings),[i.keybindings]),j=(0,K.useMemo)(()=>Ct(i.chatSnapshot?.messages??[]),[i.chatSnapshot?.messages]),M=(0,K.useMemo)(()=>Et(i.chatSnapshot?.messages??[],Object.values(i.chatSnapshot?.subagentRuns??{})),[i.chatSnapshot?.messages,i.chatSnapshot?.subagentRuns]),N=(0,K.useMemo)(()=>bj(i.messages),[i.messages]),P=i.messages.length===0&&i.runtime?.title===`New Chat`,F=(0,K.useCallback)(()=>{s.current!==null&&(e.clearTimeout(s.current),s.current=null)},[e]),I=(0,K.useCallback)(t=>{if(o.current!==t){if(o.current=t,t){F(),g(!1);return}F(),s.current=e.setTimeout(()=>{g(!0),s.current=null},150)}},[F,g,e]),L=(0,K.useCallback)(()=>{let e=a.current?.getState?.();e&&I(e.isAtEnd)},[I]),R=(0,K.useCallback)(async(e=!0)=>{o.current=!0,F(),g(!1),await a.current?.scrollToEnd?.({animated:e})},[F,g]),z=(0,K.useCallback)(async(e,t)=>{await R(!1),await i.handleSend(e,t)},[R,i]),te=(0,K.useRef)({messages:i.messages,submit:z});(0,K.useEffect)(()=>{te.current={messages:i.messages,submit:z}},[i.messages,z]);let ne=(0,K.useCallback)(async e=>{let{messages:t,submit:n}=te.current,r=dL(t,e);r&&await n(r.content,{attachments:r.attachments})},[]),B=(0,K.useCallback)((e,t)=>{let n=i.activeChatId;n&&i.socket.command({type:`autoContinue.accept`,chatId:n,scheduleId:e,scheduledAt:t}).catch(()=>{})},[i.activeChatId,i.socket]),re=(0,K.useCallback)((e,t)=>{let n=i.activeChatId;n&&i.socket.command({type:`autoContinue.reschedule`,chatId:n,scheduleId:e,scheduledAt:t}).catch(()=>{})},[i.activeChatId,i.socket]),ie=(0,K.useCallback)(e=>{let t=i.activeChatId;t&&i.socket.command({type:`cron.remove`,chatId:t,jobId:e}).catch(()=>{})},[i.activeChatId,i.socket]),ae=(0,K.useCallback)(e=>{let t=i.activeChatId;t&&i.socket.command({type:`autoContinue.cancel`,chatId:t,scheduleId:e}).catch(()=>{})},[i.activeChatId,i.socket]),oe=(0,K.useCallback)(async e=>{let t=i.activeChatId;t&&await i.socket.command({type:`tunnel.accept`,chatId:t,tunnelId:e})},[i.activeChatId,i.socket]),se=(0,K.useCallback)(async e=>{let t=i.activeChatId;t&&await i.socket.command({type:`tunnel.stop`,chatId:t,tunnelId:e})},[i.activeChatId,i.socket]),le=(0,K.useCallback)(async e=>{let t=i.activeChatId;t&&await i.socket.command({type:`tunnel.retry`,chatId:t,tunnelId:e})},[i.activeChatId,i.socket]),H=(0,K.useCallback)((e,t)=>{i.socket.command({type:`chat.cancelSubagentRun`,chatId:e,runId:t}).catch(()=>{})},[i.socket]),ue=Fr(ee(Rr(i.activeChatId??``))),de=(0,K.useCallback)(async e=>{let t=i.activeChatId;return t?i.socket.command({type:`workflows.getRun`,chatId:t,runId:e}):null},[i.activeChatId,i.socket]),fe=(0,K.useCallback)(async e=>{let t=i.activeChatId;return t?i.socket.command({type:`subagents.getRun`,chatId:t,agentId:e}):[]},[i.activeChatId,i.socket]),pe=(0,K.useMemo)(()=>({onAskUserQuestionSubmit:i.handleAskUserQuestion,onExitPlanModeConfirm:i.handleExitPlanMode,onToolRequestAnswer:i.handleToolRequestAnswer,onAutoContinueAccept:B,onAutoContinueReschedule:re,onAutoContinueCancel:ae,onRetryFailedTurn:ne,onCronRemove:ie,schedules:i.chatSnapshot?.schedules??cL,cronJobs:i.chatSnapshot?.cronJobs??lL,chatId:i.activeChatId??void 0,onToolGroupExpandedChange:v,onSubagentAskUserQuestionSubmit:i.handleSubagentAskUserQuestion,onSubagentExitPlanModeSubmit:i.handleSubagentExitPlanMode,subagentRuns:i.chatSnapshot?.subagentRuns??iR,editorPreset:w,editorCommandTemplate:T,onCancelSubagentRun:H,getSubagentTranscript:fe,platform:i.localProjects?.machine.platform??`darwin`,tunnels:i.chatSnapshot?.tunnels,liveTunnelId:i.chatSnapshot?.liveTunnelId,onTunnelAccept:oe,onTunnelStop:se,onTunnelRetry:le,queuedMessages:i.queuedMessages,runtimeStatus:i.runtimeStatus,isDraining:i.isDraining,commandError:i.commandError,onStopDraining:i.handleStopDraining,onSteerQueuedMessage:i.handleSteerQueuedMessage,onRemoveQueuedMessage:i.handleRemoveQueuedMessage,loopProgress:i.chatSnapshot?.loopProgress,workflowRuns:ue.length>0?ue:void 0,backgroundTasks:i.runtime?.backgroundTasks,getWorkflowRunDetail:de,localPath:i.runtime?.localPath,latestToolIds:i.latestToolIds,isProcessing:i.isProcessing}),[i.handleAskUserQuestion,i.handleExitPlanMode,i.handleToolRequestAnswer,B,re,ae,ne,ie,i.chatSnapshot?.schedules,i.chatSnapshot?.cronJobs,i.activeChatId,v,i.handleSubagentAskUserQuestion,i.handleSubagentExitPlanMode,i.chatSnapshot?.subagentRuns,w,T,H,fe,i.localProjects?.machine.platform,i.chatSnapshot?.tunnels,i.chatSnapshot?.liveTunnelId,oe,se,le,i.queuedMessages,i.runtimeStatus,i.isDraining,i.commandError,i.handleStopDraining,i.handleSteerQueuedMessage,i.handleRemoveQueuedMessage,i.chatSnapshot?.loopProgress,ue,i.runtime?.backgroundTasks,de,i.runtime?.localPath,i.latestToolIds,i.isProcessing]),me=Yt(e=>e.pushConfig?.preferences.mutedChatIds??rR),he=i.activeChatId!=null&&me.includes(i.activeChatId),ge=(0,K.useCallback)(()=>{let e=i.activeChatId;e&&i.socket.command({type:`push.setChatMute`,chatId:e,muted:!he}).catch(()=>{})},[i.activeChatId,i.socket,he]),_e=pL(e=>e.listForChat(i.activeChatId??``)),ve=pL(e=>e.addShare),ye=pL(e=>e.removeShare),be=(0,K.useCallback)(async e=>{let t=await i.socket.command({type:`share.mint`,payload:{chatId:e}});t.ok&&t.kind===`mint`&&ve(e,t.data.summary)},[ve,i.socket]),xe=(0,K.useCallback)(async e=>{let t=i.activeChatId;t&&(await i.socket.command({type:`share.revoke`,payload:{tokenId:e}})).ok&&ye(t,e)},[ye,i.activeChatId,i.socket]);PP({rootRef:c,fallbackRef:l,enabled:i.hasSelectedProject,canCancel:i.canCancel}),LP({socket:i.socket,activeChatId:i.activeChatId});let U=(0,K.useCallback)(e=>{!i.hasSelectedProject||e.length===0||u.current?.enqueueFiles(e)},[i.hasSelectedProject]),{isPageFileDragActive:Se,handleTranscriptDragEnter:Ce,handleTranscriptDragOver:we,handleTranscriptDragLeave:Te,handleTranscriptDrop:Ee}=sR({hasSelectedProject:i.hasSelectedProject,onFilesDropped:U}),{typedEmptyStateText:De,isEmptyStateTypingComplete:Oe}=oR(P,i.activeChatId,e);return(0,K.useEffect)(()=>()=>F(),[F]),(0,K.useEffect)(()=>{o.current=!0,F(),g(!1)},[F,g,i.activeChatId]),(0,K.useEffect)(()=>{let t=e.requestAnimationFrame(()=>{L()}),n=e.setTimeout(()=>{L()},350);return()=>{e.cancelAnimationFrame(t),e.clearTimeout(n)}},[O,L,e]),(0,K.useEffect)(()=>t.addWindowListener(`resize`,()=>{L()}),[t,L]),(0,K.useEffect)(()=>{if(!o.current)return;let t=null,n=e.requestAnimationFrame(()=>{a.current?.scrollToEnd?.({animated:!1}),t=e.requestAnimationFrame(()=>{a.current?.scrollToEnd?.({animated:!1})})});return()=>{e.cancelAnimationFrame(n),t!==null&&e.cancelAnimationFrame(t)}},[i.commandError,i.isDraining,i.isProcessing,i.messages.length,i.queuedMessages.length,i.runtimeStatus,e]),(0,q.jsxs)(On,{ref:c,className:`bg-background h-full flex flex-col overflow-hidden border-0 rounded-none relative`,onDragEnter:Ce,onDragOver:we,onDragLeave:Te,onDrop:Ee,children:[(0,q.jsxs)(on,{className:`flex flex-1 min-h-0 flex-col overflow-hidden p-0 relative`,children:[(0,q.jsx)(MP,{turnDurationsMs:N,sidebarCollapsed:i.sidebarCollapsed,onOpenSidebar:i.openSidebar,onExpandSidebar:i.expandSidebar,onNewChat:i.handleCompose,localPath:i.navbarLocalPath,embeddedTerminalVisible:O,onToggleEmbeddedTerminal:x?n:void 0,rightSidebarVisible:k,onToggleRightSidebar:x?r:void 0,onOpenExternal:i.handleOpenExternal,editorPreset:w,editorCommandTemplate:T,platform:i.localProjects?.machine.platform,finderShortcut:A.bindings.openInFinder,editorShortcut:A.bindings.openInEditor,terminalShortcut:A.bindings.toggleEmbeddedTerminal,rightSidebarShortcut:A.bindings.toggleRightSidebar,branchName:i.chatDiffSnapshot?.branchName,homeDir:i.localProjects?.machine.homeDir,hasGitRepo:i.chatDiffSnapshot?.status!==`no_repo`,gitStatus:i.chatDiffSnapshot?.status,timings:i.runtime?.timings,status:i.runtime?.status,socket:i.socket,onOpenPtyChat:b,currentChatId:i.activeChatId??void 0,shareShares:_e,onShareMint:be,onShareRevoke:xe,silent:he,onToggleSilent:ge}),(0,q.jsx)(VI,{value:pe,children:(0,q.jsx)(tR,{activeChatId:i.activeChatId,listRef:a,messages:i.messages,transcriptPaddingBottom:m,isHistoryLoading:i.isHistoryLoading,hasOlderHistory:i.hasOlderHistory,loadOlderHistory:i.loadOlderHistory,onOpenLocalLink:i.handleOpenLocalLink,showScrollButton:h&&i.messages.length>0,onIsAtEndChange:I,scrollToBottom:()=>R(!0),typedEmptyStateText:De,isEmptyStateTypingComplete:Oe,isPageFileDragActive:Se,showEmptyState:P})})]}),(0,q.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-20 pointer-events-none`,children:(0,q.jsx)(`div`,{className:`bg-gradient-to-t from-background via-background pointer-events-auto`,ref:d,children:(0,q.jsx)(zN,{ref:u,inputElementRef:l,onLayoutChange:p,onSubmit:z,onCancel:i.handleCancel,disabled:!i.hasSelectedProject,canCancel:i.canCancel,chatId:i.activeChatId,projectId:x,activeProvider:i.runtime?.provider??null,availableProviders:i.availableProviders,contextWindowSnapshot:j,sessionTotals:M,previousPrompt:i.previousPrompt,hasUnpausedCronJob:(i.chatSnapshot?.cronJobs??lL).some(e=>!e.paused)},i.activeChatId??`new-chat`)})})]})}var lR=`flex-1 flex flex-col min-h-0 min-w-0 relative`;function uR(e){let t=Qp(e=>e.layoutWidth),n=Qp(e=>e.setLayoutWidth);return(0,K.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{let e=t.clientWidth,r=Qp.getState().layoutWidth;Math.abs(r-e)>=1&&n(e)},i=new ResizeObserver(r);return i.observe(t),r(),()=>i.disconnect()},[e,n]),t}function dR({ports:e={}}={}){let t=e.dom??o,n=e.timer??fi,r=p(),i=Cn(),a=(0,K.useRef)(null),c=r.activeProjectId,l=r.activeChatId,{boardId:u}=s(),d=f(),m=r.sidebarData,h=nn().chatNavigator,g=r.handleOpenExternal,_=en(e=>e.projects),v=Ri(e=>e.boardsByOwner),y=Ri(e=>e.viewByBoard),b=(c?_[c]:void 0)??fn,x=Ln(e=>c?e.projects[c]:void 0)??Nn,S=Ln(e=>e.size),C=en(e=>e.addTerminal),w=en(e=>e.removeTerminal),T=en(e=>e.toggleVisibility),E=en(e=>e.setTerminalSizes),D=Ln(e=>e.toggleVisibility),O=ce(oe),k=ce(Ee),A=(0,K.useMemo)(()=>rr(r.keybindings),[r.keybindings]),j=b.terminals.length>0,M=!!(c&&x.isVisible),N=bn(e=>e.layout),P=(0,K.useMemo)(()=>Dn(N.root).some(e=>e.tabs.length>0),[N]),F=bn(e=>e.seedFromLegacy),I=bn(e=>e.focusPane),L=bn(e=>e.focusTab),ee=bn(e=>e.closeTab),R=bn(e=>e.splitPane),z=bn(e=>e.setGroupSizes),te=bn(e=>e.focusAdjacentPane),ne=bn(e=>e.resizeFocusedPane),B=bn(e=>e.cycleFocusedPaneTab),V=bn(e=>e.closeFocusedTab),re=bn(e=>e.splitFocusedPane),ie=bn(e=>e.moveTabToPane),ae=bn(e=>e.openTab),se=bn(e=>e.getLayout);(0,K.useEffect)(()=>{c&&F({terminals:b.terminals,mainSizes:b.mainSizes,terminalSizes:b.terminals.map(e=>e.size),changesVisible:x.isVisible,changesSizePercent:S??33})},[c,F,b,x,S]),(0,K.useEffect)(()=>{let e=Dn(se().root).flatMap(e=>e.tabs);for(let t of b.terminals)e.some(e=>e.target.kind===`terminal`&&e.target.terminalId===t.id)||ae({kind:`terminal`,terminalId:t.id});for(let t of e)t.target.kind===`terminal`&&!un(_,t.target.terminalId)&&ee(t.tabId);let t=e.find(e=>e.target.kind===`changes`);M&&!t&&ae({kind:`changes`}),!M&&t&&ee(t.tabId),l&&ae({kind:`chat`,chatId:l}),u&&ae({kind:`board`,boardId:u})},[b.terminals,_,M,l,u,ae,ee,se]);let le=(0,K.useCallback)(()=>{let e=se(),t=Dn(e.root).find(t=>t.id===e.focusedPaneId),n=t?.tabs.find(e=>e.tabId===t.focusedTabId);n?.target.kind===`chat`&&n.target.chatId!==l&&h.openChat(n.target.chatId)},[se,l,h]),H=(0,K.useCallback)(e=>{L(e),le()},[L,le]),ue=(0,K.useCallback)(({tabId:e,paneId:t,position:n})=>{R({tabId:e,targetPaneId:t,position:n})},[R]),de=(0,K.useCallback)(e=>{I(e),le()},[I,le]),fe=(0,K.useCallback)((e,t)=>{z(e,t)},[z]),pe=(0,K.useCallback)((e,t)=>{ie(e,t)},[ie]),me=(0,K.useCallback)((e,t,n)=>{R({tabId:e,targetPaneId:t,position:n})},[R]),he=(0,K.useMemo)(()=>BT({terminalProjects:_,sidebarData:m,boardsByOwner:v,boardViews:y}),[_,m,v,y]),ge=(0,K.useMemo)(()=>HT(m),[m]);uR(a);let{diffRenderMode:_e,wrapDiffLines:ve,setDiffRenderMode:ye,setWrapDiffLines:be,scheduleTerminalDiffRefresh:xe,handleOpenDiffFile:U,handleCopyDiffFilePath:Se,handleCopyDiffRelativePath:Ce,handleLoadDiffPatch:we,handleDiscardDiffFile:Te,handleIgnoreDiffFile:De,handleIgnoreDiffFolder:Oe,handleOpenDiffInFinder:ke,handleCommitDiffs:Ae,handleSyncBranch:je,handleGenerateCommitMessage:Me,handleInitializeGit:Ne,handleGetGitHubPublishInfo:Pe,handleCheckGitHubRepoAvailability:Fe,handleSetupGitHub:Ie,handleListBranches:Le,handleCheckoutBranch:Re,handlePreviewMergeBranch:ze,handleMergeBranch:Be,handleCreateBranch:Ve}=iT({state:r,projectId:c,showRightSidebar:M}),He=(0,K.useCallback)(()=>{if(c){if(j){T(c);return}C(c)}},[C,j,c,T]),Ue=(0,K.useCallback)(()=>{c&&D(c)},[c,D]),We=(0,K.useCallback)(()=>{if(c){if(M){D(c);return}if(r.chatDiffSnapshot?.status===`no_repo`){(async()=>{await i.confirm({title:`Initialize Git?`,description:`Initialize a local git repository in this project?`,confirmLabel:`Init Git`,cancelLabel:`Cancel`})&&(await Ne())?.ok&&!M&&D(c)})();return}D(c)}},[i,Ne,c,M,r.chatDiffSnapshot?.status,D]),Ge=(0,K.useCallback)((e,t)=>{r.socket.command({type:`terminal.close`,terminalId:t}).catch(()=>{}),w(e,t)},[w,r.socket]),Ke=(0,K.useCallback)(e=>{let t=Dn(se().root).flatMap(e=>e.tabs).find(t=>t.tabId===e);if(t?.target.kind===`terminal`){let n=un(_,t.target.terminalId);n?Ge(n.projectId,t.target.terminalId):ee(e);return}if(t?.target.kind===`changes`){c&&D(c);return}if(t?.target.kind===`chat`){let n=t.target.chatId,r=Dn(se().root).flatMap(e=>e.tabs).find(t=>t.tabId!==e&&t.target.kind===`chat`&&t.target.chatId!==n)?.target;ee(e),n===l&&(r?.kind===`chat`?h.openChat(r.chatId):h.closeChat());return}ee(e)},[c,_,ee,se,Ge,D,l,h]);(0,K.useEffect)(()=>{function e(e){if(c){if(Xn(A,`toggleEmbeddedTerminal`,e)){e.preventDefault(),He();return}if(Xn(A,`toggleRightSidebar`,e)){e.preventDefault(),We();return}if(Xn(A,`openInFinder`,e)){e.preventDefault(),g(`open_finder`);return}if(Xn(A,`openInEditor`,e)){e.preventDefault(),g(`open_editor`);return}if(Xn(A,`addSplitTerminal`,e)){e.preventDefault(),C(c);return}}let t=e.target,n=FT(A,e,PT(t instanceof HTMLElement?t:null));if(n)switch(e.preventDefault(),n.kind){case`focus`:te(n.direction),le();return;case`resize`:ne(n.direction);return;case`split`:re(n.position);return;case`closeTab`:V(),le();return;case`cycleTab`:B(n.delta),le()}}return t.addWindowListener(`keydown`,e)},[C,V,B,t,te,g,He,We,c,ne,A,re,le]);let qe=(0,K.useMemo)(()=>c?{projectId:c,diffs:r.chatDiffSnapshot??Zw,editorLabel:r.editorLabel,diffRenderMode:_e,wrapLines:ve,onOpenFile:U,onOpenInFinder:ke,onDiscardFile:Te,onIgnoreFile:De,onIgnoreFolder:Oe,onCopyFilePath:Se,onCopyRelativePath:Ce,onLoadPatch:we,onListBranches:Le,onPreviewMergeBranch:ze,onMergeBranch:Be,onCheckoutBranch:Re,onCreateBranch:Ve,onGenerateCommitMessage:Me,onInitializeGit:Ne,onGetGitHubPublishInfo:Pe,onCheckGitHubRepoAvailability:Fe,onSetupGitHub:Ie,onCommit:Ae,onSyncWithRemote:je,onDiffRenderModeChange:ye,onWrapLinesChange:be,onClose:Ue}:null,[_e,Fe,Re,Ue,Ae,Se,Ce,Ve,Te,Me,Pe,De,Oe,Ne,Le,we,Be,U,ke,ze,Ie,je,c,ye,be,r.chatDiffSnapshot,r.editorLabel,ve]),Je=(0,K.useCallback)(e=>{d(`/boards/${e}`)},[d]),Ye={board:(e,t,n,i)=>i?(0,q.jsx)(pj,{boardId:e.boardId,socket:r.socket,chatFacts:ge,onOpenBoards:Je}):null,chat:e=>(0,q.jsx)(YT,{chatId:e.chatId,timer:n,dom:t,children:(0,q.jsx)(cR,{timer:n,dom:t,onToggleEmbeddedTerminal:He,onToggleRightSidebar:We})}),changes:()=>qe?(0,q.jsx)(Xp,{...qe}):null,terminal:(e,t,n)=>{let i=un(_,e.terminalId);if(!i)return null;let a=_[i.projectId]??fn;return(0,q.jsx)(Jw,{projectId:i.projectId,terminalLayout:{...a,terminals:[i.terminal]},addTerminal:C,socket:r.socket,connectionStatus:r.connectionStatus,scrollback:O,minColumnWidth:k,splitTerminalShortcut:A.bindings.addSplitTerminal,focusRequestVersion:+!!n,onTerminalCommandSent:xe,onRemoveTerminal:Ge,onTerminalLayout:E})}};return(0,q.jsx)(`div`,{ref:a,className:lR,children:P?(0,q.jsx)(zT,{onMoveTab:pe,onSplitWithTab:me,children:(0,q.jsx)(mT,{layout:N,renderPane:(e,t)=>(0,q.jsx)(kT,{pane:e,isFocused:t,registry:Ye,presentation:he,onSelectTab:H,onCloseTab:Ke,onSplit:ue}),onFocusPane:de,onResizeGroup:fe})}):(0,q.jsx)(YT,{chatId:r.activeChatId,timer:n,dom:t,children:(0,q.jsx)(cR,{timer:n,dom:t,onToggleEmbeddedTerminal:He,onToggleRightSidebar:We})})})}export{dR as WorkspacePage};