@marimo-team/frontend 0.11.7-dev18 → 0.11.7-dev20

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 (147) hide show
  1. package/dist/assets/ConnectedDataExplorerComponent-w4JtcQnX.js +22 -0
  2. package/dist/assets/VegaLite-C3vrX1sl.js +11 -0
  3. package/dist/assets/{_baseEach-DRLOG7FR.js → _baseEach-3bh4w8O5.js} +1 -1
  4. package/dist/assets/_baseMap-glsH48d0.js +1 -0
  5. package/dist/assets/{_baseUniq-Z6tslDId.js → _baseUniq-DiZVfNws.js} +1 -1
  6. package/dist/assets/{any-language-editor-CN-68zq0.js → any-language-editor-Td4CiSWq.js} +1 -1
  7. package/dist/assets/arc-B5qYPUYs.js +1 -0
  8. package/dist/assets/architectureDiagram-UYN6MBPD-_zUJ3sPF.js +1 -0
  9. package/dist/assets/asn1-DWPaVWf6.js +1 -0
  10. package/dist/assets/blockDiagram-ZHA2E4KO-BfcTeJYV.js +1 -0
  11. package/dist/assets/{c4Diagram-6F5ED5ID-CSsWcf65.js → c4Diagram-6F5ED5ID-DPEWArCd.js} +1 -1
  12. package/dist/assets/channel-Cs3dPfbb.js +1 -0
  13. package/dist/assets/{chunk-5HRBRIJM-i5Phh7bi.js → chunk-5HRBRIJM-CJULNzvM.js} +1 -1
  14. package/dist/assets/chunk-7U56Z5CX-CrqVatd5.js +1 -0
  15. package/dist/assets/{chunk-ASOPGD6M-Bsu_b9jH.js → chunk-ASOPGD6M-Cqd0uJ5x.js} +1 -1
  16. package/dist/assets/{chunk-KFBOBJHC-C9sMPfZc.js → chunk-KFBOBJHC-Bx60GBk-.js} +1 -1
  17. package/dist/assets/chunk-T2TOU4HS-CZtzgYcF.js +1 -0
  18. package/dist/assets/{chunk-TMUBEWPD-yD_WnSdD.js → chunk-TMUBEWPD-DxIckh-_.js} +1 -1
  19. package/dist/assets/classDiagram-LNE6IOMH-C6KisOx7.js +1 -0
  20. package/dist/assets/classDiagram-v2-MQ7JQ4JX-C6KisOx7.js +1 -0
  21. package/dist/assets/{clike-BPCXT8V3.js → clike-D5G9EsPi.js} +1 -1
  22. package/dist/assets/clone-BCumVPVe.js +1 -0
  23. package/dist/assets/{cobol-DbZRNMTs.js → cobol-stawOqaz.js} +1 -1
  24. package/dist/assets/{compile-BgV4bhlK.js → compile-DpOrs6EE.js} +1 -1
  25. package/dist/assets/createWsUrl-7RQYp955.js +1 -0
  26. package/dist/assets/{cytoscape.esm-BOa7ANXG.js → cytoscape.esm-bH-fs5wT.js} +1 -1
  27. package/dist/assets/{dagre-4EVJKHTY-qlyr5wai.js → dagre-4EVJKHTY-BV3tGaaB.js} +1 -1
  28. package/dist/assets/data-editor-DHygRlG6.js +1 -0
  29. package/dist/assets/diagram-QW4FP2JN-D7oehDJn.js +1 -0
  30. package/dist/assets/edit-page-BSYEerOP.js +8 -0
  31. package/dist/assets/{erDiagram-6RL3IURR-V5QiSeMD.js → erDiagram-6RL3IURR-enfYB8UZ.js} +1 -1
  32. package/dist/assets/flowDiagram-7ASYPVHJ-8Zeo1fU-.js +1 -0
  33. package/dist/assets/ganttDiagram-NTVNEXSI-Dnct8G7G.js +1 -0
  34. package/dist/assets/{gitGraph-YCYPL57B-CrdOXnVg.js → gitGraph-YCYPL57B-DuCTV50P.js} +1 -1
  35. package/dist/assets/gitGraphDiagram-NRZ2UAAF-DaZnIa2W.js +1 -0
  36. package/dist/assets/{graph-CuAM9DuN.js → graph-Bebvc7sH.js} +1 -1
  37. package/dist/assets/haxe-D25e-2l-.js +1 -0
  38. package/dist/assets/home-page-DvvFipqG.js +7 -0
  39. package/dist/assets/index-5MgyR5u4.js +1 -0
  40. package/dist/assets/index-BEwcOn30.js +1 -0
  41. package/dist/assets/index-BPjmIK6A.js +1 -0
  42. package/dist/assets/{index-BXs5VcPX.js → index-B_havdzb.js} +1 -1
  43. package/dist/assets/{index-DWSqZU7l.js → index-BdmbAOuc.js} +1 -1
  44. package/dist/assets/{index-RZIsHI4j.js → index-BhiySLZg.js} +1 -1
  45. package/dist/assets/{index-CBffH0xV.js → index-BjnwDPr-.js} +1 -1
  46. package/dist/assets/{index-eUGIYQ9e.js → index-Bz9cfgjt.js} +1 -1
  47. package/dist/assets/index-C2X7uoAD.js +1 -0
  48. package/dist/assets/index-CiJb4Mle.js +80 -0
  49. package/dist/assets/index-DXMqR_Zd.js +1 -0
  50. package/dist/assets/{index-D_b38AF4.js → index-DfR5w5NP.js} +1 -1
  51. package/dist/assets/{index-BxXkbUY_.js → index-DjgnfB9H.js} +1 -1
  52. package/dist/assets/index-Dr2ZPnCQ.js +1 -0
  53. package/dist/assets/{index-C4vyzbl_.js → index-GCtCp-R2.js} +1 -1
  54. package/dist/assets/{index-dBf568lL.js → index-Xc2Awynv.js} +1 -1
  55. package/dist/assets/{index-nafBc7vH.js → index-uf2cvbuA.js} +1 -1
  56. package/dist/assets/{infoDiagram-A4XQUW5V-BQi5KH8U.js → infoDiagram-A4XQUW5V-Bvry8CWw.js} +1 -1
  57. package/dist/assets/javascript-D48wDJXV.js +1 -0
  58. package/dist/assets/{journeyDiagram-G5WM74LC-CYv86MSD.js → journeyDiagram-G5WM74LC-B1tHR3la.js} +1 -1
  59. package/dist/assets/{kanban-definition-QRCXZQQD-LxchZzZC.js → kanban-definition-QRCXZQQD-DEpy9dsI.js} +1 -1
  60. package/dist/assets/layout-DTcYIVAT.js +1 -0
  61. package/dist/assets/{linear-DnzJFOVg.js → linear-BClD6Ci6.js} +1 -1
  62. package/dist/assets/main-CEaoNRsh.js +1 -0
  63. package/dist/assets/mermaid-CQUi_C2V.js +13 -0
  64. package/dist/assets/min-CBL4Q-10.js +1 -0
  65. package/dist/assets/mindmap-definition-GWI6TPTV-CxDnnlo2.js +1 -0
  66. package/dist/assets/{mirc-1Vs7mkDM.js → mirc-DkvFAiy5.js} +1 -1
  67. package/dist/assets/mllike-3c2dg9RT.js +1 -0
  68. package/dist/assets/pieDiagram-YF2LJOPJ-CA-cLprF.js +1 -0
  69. package/dist/assets/{pig-C9krdGUD.js → pig-CwGJVRC4.js} +1 -1
  70. package/dist/assets/{pug-JtgdeyKq.js → pug-_kJOm_E2.js} +1 -1
  71. package/dist/assets/quadrantDiagram-OS5C2QUG-CRdTX2Oj.js +1 -0
  72. package/dist/assets/react-plotly-Br5tXLC8.js +71 -0
  73. package/dist/assets/requirementDiagram-MIRIMTAZ-DjnO7cJC.js +1 -0
  74. package/dist/assets/{run-page-BpxdWHNP.js → run-page-DJZCAA9J.js} +1 -1
  75. package/dist/assets/{sankeyDiagram-Y46BX6SQ-2stxT0h5.js → sankeyDiagram-Y46BX6SQ-CA7pPSz8.js} +1 -1
  76. package/dist/assets/{scheme-DlxeS-fJ.js → scheme-qjP0V5Ag.js} +1 -1
  77. package/dist/assets/sequenceDiagram-G6AWOVSC-CobvIrAE.js +1 -0
  78. package/dist/assets/{slides-component-CpzjtzJd.js → slides-component-CAqsGEd_.js} +1 -1
  79. package/dist/assets/{sortBy-D5PrM5k_.js → sortBy-BLRfDpgw.js} +1 -1
  80. package/dist/assets/sql-B3SPsWL6.js +1 -0
  81. package/dist/assets/stateDiagram-MAYHULR4-B1DIWW90.js +1 -0
  82. package/dist/assets/stateDiagram-v2-4JROLMXI-B6hoSXQr.js +1 -0
  83. package/dist/assets/{step-CaHXtLdi.js → step-xJWGRC3d.js} +1 -1
  84. package/dist/assets/{tcl-BWtglvHf.js → tcl-B2fODqDH.js} +1 -1
  85. package/dist/assets/terminal-DMSO4zO9.js +1 -0
  86. package/dist/assets/{time-B-QFhLuD.js → time-FlebwGeO.js} +1 -1
  87. package/dist/assets/{timeline-definition-U7ZMHBDA-Cu5fPfiD.js → timeline-definition-U7ZMHBDA-D4-uV6jf.js} +1 -1
  88. package/dist/assets/{transform-D6ULhE8R.js → transform-CdY8z5kT.js} +1 -1
  89. package/dist/assets/tree-Dq2G8ueb.js +8 -0
  90. package/dist/assets/ttcn-BxnYHtq8.js +1 -0
  91. package/dist/assets/ttcn-cfg-CKJxb-l2.js +1 -0
  92. package/dist/assets/useMarimoWebSocket-dha3n46P.js +15 -0
  93. package/dist/assets/{vega-component-530U8AUz.js → vega-component-C8Wxr3vK.js} +1 -1
  94. package/dist/assets/velocity-BdD_26Jv.js +1 -0
  95. package/dist/assets/{xychartDiagram-6QU3TZC5-C7CZWV9M.js → xychartDiagram-6QU3TZC5-BTdCoP-6.js} +1 -1
  96. package/dist/index.html +1 -1
  97. package/package.json +4 -4
  98. package/dist/assets/ConnectedDataExplorerComponent-Dw0lgEx7.js +0 -22
  99. package/dist/assets/VegaLite-i28zbrOg.js +0 -11
  100. package/dist/assets/_baseMap-Csmk0lES.js +0 -1
  101. package/dist/assets/arc-BTlVLyGF.js +0 -1
  102. package/dist/assets/architectureDiagram-UYN6MBPD-CLCthGnb.js +0 -1
  103. package/dist/assets/asn1-BhA3SgW2.js +0 -1
  104. package/dist/assets/blockDiagram-ZHA2E4KO-D8VEqjcW.js +0 -1
  105. package/dist/assets/channel-DHzdgD-d.js +0 -1
  106. package/dist/assets/chunk-7U56Z5CX-D088hXP5.js +0 -1
  107. package/dist/assets/chunk-T2TOU4HS-Depm1_8y.js +0 -1
  108. package/dist/assets/classDiagram-LNE6IOMH-K-Wjg4zZ.js +0 -1
  109. package/dist/assets/classDiagram-v2-MQ7JQ4JX-K-Wjg4zZ.js +0 -1
  110. package/dist/assets/clone-C6gbuftv.js +0 -1
  111. package/dist/assets/createWsUrl-BclB4Lh8.js +0 -1
  112. package/dist/assets/data-editor-O7GB1dOJ.js +0 -1
  113. package/dist/assets/diagram-QW4FP2JN-CeEn361s.js +0 -1
  114. package/dist/assets/edit-page-D09PcIbh.js +0 -8
  115. package/dist/assets/flowDiagram-7ASYPVHJ-DswX-o5B.js +0 -1
  116. package/dist/assets/ganttDiagram-NTVNEXSI-O1FeJt3C.js +0 -1
  117. package/dist/assets/gitGraphDiagram-NRZ2UAAF-DqXKCt3x.js +0 -1
  118. package/dist/assets/haxe-75PMBtaN.js +0 -1
  119. package/dist/assets/home-page-D_b-tjJr.js +0 -7
  120. package/dist/assets/index-6w92-PnA.js +0 -1
  121. package/dist/assets/index-BZUrKLLV.js +0 -1
  122. package/dist/assets/index-BhVxrMm_.js +0 -92
  123. package/dist/assets/index-Cex802kZ.js +0 -1
  124. package/dist/assets/index-DhKR_xS-.js +0 -1
  125. package/dist/assets/index-YvMhMx5m.js +0 -1
  126. package/dist/assets/index-ooJzGCEl.js +0 -1
  127. package/dist/assets/javascript-CLZUXWcY.js +0 -1
  128. package/dist/assets/layout-BVzdLZD3.js +0 -1
  129. package/dist/assets/main-DPWVgc5Y.js +0 -1
  130. package/dist/assets/mermaid-Bic4bmVF.js +0 -13
  131. package/dist/assets/min-Dw7ZDVyc.js +0 -1
  132. package/dist/assets/mindmap-definition-GWI6TPTV-Dgrbeals.js +0 -1
  133. package/dist/assets/mllike-B8DYu8SS.js +0 -1
  134. package/dist/assets/pieDiagram-YF2LJOPJ-DH_aAvgk.js +0 -1
  135. package/dist/assets/quadrantDiagram-OS5C2QUG-Cdx6px7r.js +0 -1
  136. package/dist/assets/react-plotly-ABMk2537.js +0 -71
  137. package/dist/assets/requirementDiagram-MIRIMTAZ-foNUTolX.js +0 -1
  138. package/dist/assets/sequenceDiagram-G6AWOVSC-DsLWeuD6.js +0 -1
  139. package/dist/assets/sql-BP5jFf-w.js +0 -1
  140. package/dist/assets/stateDiagram-MAYHULR4-DTsueJwY.js +0 -1
  141. package/dist/assets/stateDiagram-v2-4JROLMXI-Co4r5BV4.js +0 -1
  142. package/dist/assets/terminal-DCpCpEop.js +0 -1
  143. package/dist/assets/tree-CYy93deY.js +0 -8
  144. package/dist/assets/ttcn-BXRxJEWs.js +0 -1
  145. package/dist/assets/ttcn-cfg-Ce4xWtqN.js +0 -1
  146. package/dist/assets/useMarimoWebSocket-m-9tpiCT.js +0 -15
  147. package/dist/assets/velocity-Bo4HNIcG.js +0 -1
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-eUGIYQ9e.js","./VegaLite-i28zbrOg.js","./index-BhVxrMm_.js","./index-CmekZQwh.css","./compile-BgV4bhlK.js","./time-B-QFhLuD.js","./step-CaHXtLdi.js","./linear-DnzJFOVg.js","./init-DLRA0X12.js","./range-CtcPcB_L.js","./ordinal-BcaZTuz9.js","./colors-bszWmPJw.js","./arc-BTlVLyGF.js","./index-6w92-PnA.js","./terminal-DCpCpEop.js","./createWsUrl-BclB4Lh8.js","./terminal-WibgYtSD.css"])))=>i.map(i=>d[i]);
2
- var e,t=Object.defineProperty,n=(e,n,r)=>((e,n,r)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r)(e,"symbol"!=typeof n?n+"":n,r);import{aD as r,J as o,hq as s,hr as i,hs as a,ht as l,hu as c,hv as d,R as u,hw as h,hx as f,hy as p,hz as m,hA as g,hB as y,hC as b,hD as x,hE as v,ax as w,eQ as k,fc as S,es as C,hF as E,d9 as N,G as j,a9 as _,P as I,eE as A,eF as T,eG as M,eI as D,eC as O,eD as R,eH as P,hG as L,hH as z,dF as F,ar as B,H as U,hI as $,dg as H,hJ as V,hK as W,hL as G,eB as q,cn as Y,$ as X,hM as J,dH as K,hN as Z,hO as Q,a5 as ee,hP as te,dL as ne,hQ as re,hR as oe,M as se,b9 as ie,aM as ae,hS as le,hT as ce,dA as de,hU as ue,hV as he,dD as fe,hW as pe,hX as me,hY as ge,d8 as ye,hZ as be,h_ as xe,bb as ve,h$ as we,i0 as ke,aO as Se,e0 as Ce,aP as Ee,i1 as Ne,i2 as je,i3 as _e,a0 as Ie,a1 as Ae,a2 as Te,b1 as Me,i4 as De,ac as Oe,dB as Re,fD as Pe,fG as Le,aJ as ze,fa as Fe,ay as Be,i5 as Ue,i6 as $e,i7 as He,fb as Ve,i8 as We,i9 as Ge,fg as qe,ia as Ye,ib as Xe,ic as Je,id as Ke,dq as Ze,W as Qe,a3 as et,a$ as tt,a4 as nt,ie as rt,av as ot,a6 as st,az as it,eo as at,bf as lt,dN as ct,ig as dt,ed as ut,ih as ht,df as ft,dG as pt,eK as mt,ii as gt,ba as yt,ij as bt,dx as xt,ik as vt,il as wt,b5 as kt,im as St,io as Ct,ip as Et,aF as Nt,_ as jt,Z as _t,iq as It,fk as At,fm as Tt,ir as Mt,is as Dt,it as Ot,dw as Rt,iu as Pt,iv as Lt,iw as zt,ix as Ft,iy as Bt,ff as Ut,da as $t,aQ as Ht,iz as Vt,a8 as Wt,bc as Gt,iA as qt,fH as Yt,iB as Xt,a7 as Jt,dr as Kt,iC as Zt,Y as Qt,iD as en,aW as tn,bd as nn,iE as rn,iF as on,iG as sn,iH as an,dE as ln,aR as cn,aS as dn,iI as un,iJ as hn,dn as fn,iK as pn,iL as mn,k as gn,j as yn,iM as bn,iN as xn,iO as vn,eU as wn,iP as kn,iQ as Sn,de as Cn,iR as En,iS as Nn,ap as jn,aN as _n,ad as In,iT as An,b4 as Tn,iU as Mn,fK as Dn,iV as On,aI as Rn,fJ as Pn,iW as Ln,iX as zn,dI as Fn,iY as Bn,iZ as Un,i_ as $n,i$ as Hn,j0 as Vn,dJ as Wn,j1 as Gn,j2 as qn,j3 as Yn,j4 as Xn,j5 as Jn,aE as Kn,as as Zn,j6 as Qn,f0 as er,j7 as tr,j8 as nr,f8 as rr,j9 as or,eT as sr,ja as ir,jb as ar,jc as lr,jd as cr,je as dr,jf as ur,eZ as hr,m as fr,jg as pr,jh as mr,ji as gr,t as yr,jj as br,jk as xr,fx as vr,jl as wr,jm as kr,an as Sr,ec as Cr,jn as Er,jo as Nr,jp as jr,jq as _r,jr as Ir,js as Ar,jt as Tr,ju as Mr,jv as Dr,jw as Or,jx as Rr,jy as Pr,jz as Lr,jA as zr,jB as Fr,jC as Br,jD as Ur,jE as $r,jF as Hr,jG as Vr,jH as Wr,jI as Gr,jJ as qr,jK as Yr,jL as Xr,jM as Jr,jN as Kr,jO as Zr,jP as Qr,jQ as eo,jR as to,jS as no,jT as ro,jU as oo,jV as so,jW as io,jX as ao,jY as lo,jZ as co,j_ as uo,j$ as ho,k0 as fo,k1 as po,k2 as mo,k3 as go,k4 as yo,k5 as bo,k6 as xo,k7 as vo,k8 as wo,k9 as ko,dO as So,ka as Co,kb as Eo,dR as No,kc as jo,kd as _o,ke as Io,kf as Ao,kg as To,kh as Mo,ki as Do,ae as Oo,kj as Ro,dV as Po,kk as Lo,kl as zo,km as Fo,kn as Bo,ko as Uo,kp as $o,kq as Ho,kr as Vo,ks as Wo,kt as Go,aa as qo,ku as Yo,kv as Xo,eb as Jo,kw as Ko,kx as Zo,ky as Qo,kz as es,kA as ts,kB as ns,kC as rs,kD as os,kE as ss,kF as is,kG as as,kH as ls,kI as cs,kJ as ds,kK as us,fI as hs,kL as fs,kM as ps,kN as ms,kO as gs,a_ as ys,f5 as bs,fL as xs,kP as vs,kQ as ws,kR as ks,kS as Ss,kT as Cs,kU as Es,kV as Ns,kW as js,kX as _s,kY as Is,kZ as As,k_ as Ts,e5 as Ms,b0 as Ds,aK as Os,K as Rs,T as Ps,k$ as Ls,l0 as zs,l1 as Fs,l2 as Bs,l3 as Us,l4 as $s,l5 as Hs,l6 as Vs,b2 as Ws,l7 as Gs,l8 as qs,dv as Ys,l9 as Xs,la as Js,lb as Ks,lc as Zs,db as Qs,eO as ei,dz as ti,ld as ni,le as ri,lf as oi,aZ as si,lg as ii,eu as ai,fl as li,fq as ci,fo as di,fr as ui,ft as hi,fv as fi,fz as pi,fu as mi,lh as gi,li as yi,lj as bi,lk as xi,ep as vi,ll as wi,lm as ki,ln as Si,lo as Ci,O as Ei,Q as Ni,lp as ji,lq as _i,lr as Ii,eS as Ai,dh as Ti,aL as Mi,ls as Di,lt as Oi,lu as Ri,lv as Pi,ea as Li,lw as zi,lx as Fi,du as Bi,ly as Ui,lz as $i,lA as Hi,lB as Vi,lC as Wi,eM as Gi,lD as qi,lE as Yi,dM as Xi,lF as Ji,lG as Ki,lH as Zi,lI as Qi,lJ as ea,lK as ta,lL as na,lM as ra,lN as oa,lO as sa,lP as ia,lQ as aa,lR as la,lS as ca,lT as da,di as ua,lU as ha,lV as fa,lW as pa,lX as ma,lY as ga,aw as ya,b6 as ba,lZ as xa,l_ as va,l$ as wa,m0 as ka,m1 as Sa,m2 as Ca,m3 as Ea,m4 as Na,m5 as ja,m6 as _a,m7 as Ia,m8 as Aa,e$ as Ta,m9 as Ma,ma as Da,mb as Oa,mc as Ra,fy as Pa,md as La,me as za,d1 as Fa,mf as Ba,em as Ua,mg as $a,mh as Ha,mi as Va,mj as Wa,mk as Ga,ml as qa,mm as Ya,aA as Xa,mn as Ja,mo as Ka,mp as Za,mq as Qa,mr as el,ms as tl,mt as nl,mu as rl,g as ol,mv as sl,aH as il,ef as al}from"./index-BhVxrMm_.js";import{G as ll,M as cl,b as dl,g as ul,c as hl,A as fl,s as pl,k as ml,B as gl,d as yl,u as bl,a as xl,S as vl,K as wl,e as kl,i as Sl,f as Cl,h as El,L as Nl,j as jl,l as _l,m as Il,n as Al,o as Tl,p as Ml,q as Dl,P as Ol,r as Rl,t as Pl,T as Ll,C as zl}from"./tree-CYy93deY.js";import{b as Fl,c as Bl,L as Ul,I as $l,N as Hl,V as Vl,F as Wl,d as Gl,M as ql,l as Yl,g as Xl,E as Jl,e as Kl,f as Zl,h as Ql,i as ec,j as tc,k as nc,m as rc,n as oc,o as sc,p as ic,u as ac,C as lc,R as cc,a as dc,A as uc,q as hc,r as fc,O as pc,T as mc,s as gc,t as yc}from"./useMarimoWebSocket-m-9tpiCT.js";import{s as bc,i as xc,T as vc,a as wc}from"./transform-D6ULhE8R.js";import{W as kc}from"./step-CaHXtLdi.js";import{W as Sc,d as Cc}from"./compile-BgV4bhlK.js";import{s as Ec}from"./sortBy-D5PrM5k_.js";import"./main-DPWVgc5Y.js";import"./createWsUrl-BclB4Lh8.js";import"./index-6w92-PnA.js";import"./time-B-QFhLuD.js";import"./linear-DnzJFOVg.js";import"./init-DLRA0X12.js";import"./range-CtcPcB_L.js";import"./ordinal-BcaZTuz9.js";import"./colors-bszWmPJw.js";import"./arc-BTlVLyGF.js";import"./_baseEach-DRLOG7FR.js";import"./_baseMap-Csmk0lES.js";
3
- /**
4
- * @license lucide-react v0.474.0 - ISC
5
- *
6
- * This source code is licensed under the ISC license.
7
- * See the LICENSE file in the root directory of this source tree.
8
- */const Nc=r("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),jc=r("ArrowRightFromLine",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M21 12H7",key:"13ipq5"}],["path",{d:"m15 18 6-6-6-6",key:"6tx3qv"}]]),_c=r("ArrowRightToLine",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]),Ic=r("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),Ac=r("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]),Tc=r("BetweenHorizontalStart",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]),Mc=r("BookMarked",[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]),Dc=r("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]),Oc=r("ChevronsDown",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]),Rc=r("ChevronsUp",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]),Pc=r("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Lc=r("CircleEllipsis",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]),zc=r("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Fc=r("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Bc=r("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]),Uc=r("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]),$c=r("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]),Hc=r("Command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),Vc=r("CopyMinus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Wc=r("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),Gc=r("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]),qc=r("FastForward",[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]]),Yc=r("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]),Xc=r("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]),Jc=r("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]),Kc=r("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),Zc=r("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]),Qc=r("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),ed=r("HardDriveDownload",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]),td=r("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),nd=r("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]),rd=r("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),od=r("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),sd=r("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),id=r("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]),ad=r("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]),ld=r("MemoryStick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]),cd=r("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),dd=r("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),ud=r("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]),hd=r("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]),fd=r("PackageCheck",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]),pd=r("PackageX",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["path",{d:"m17 13 5 5m-5 0 5-5",key:"im3w4b"}]]),md=r("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),gd=r("PartyPopper",[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]]),yd=r("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]),bd=r("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),xd=r("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),vd=r("Regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]),wd=r("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),kd=r("Rows3",[["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"}]]),Sd=r("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),Cd=r("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]),Ed=r("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),Nd=r("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),jd=r("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),_d=r("SquareDashedBottomCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}]]),Id=r("SquareEqual",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]),Ad=r("SquareM",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]),Td=r("SquarePlay",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 8 6 4-6 4Z",key:"f1r3lt"}]]),Md=r("SquarePlus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Dd=r("SquarePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Od=r("SquareTerminal",[["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"}]]),Rd=r("TextCursorInput",[["path",{d:"M5 4h1a3 3 0 0 1 3 3 3 3 0 0 1 3-3h1",key:"18xjzo"}],["path",{d:"M13 20h-1a3 3 0 0 1-3-3 3 3 0 0 1-3 3H5",key:"fj48gi"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M9 7v10",key:"1vc8ob"}]]),Pd=r("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]),Ld=r("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),zd=r("View",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),Fd=r("WholeWord",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]),Bd=r("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),Ud=r("ZapOff",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),$d=r("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);const Hd=o.createContext({}),Vd=o.forwardRef((function(e,t){[e,t]=c(e,t,Hd);let{toolbarProps:n}=function(e,t){const{"aria-label":n,"aria-labelledby":r,orientation:c="horizontal"}=e;let[d,u]=o.useState(!1);s((()=>{var e;u(!(!t.current||!(null===(e=t.current.parentElement)||void 0===e?void 0:e.closest('[role="toolbar"]'))))}));const{direction:h}=i(),f="rtl"===h&&"horizontal"===c;let p=l(t);const m=o.useRef(null);return{toolbarProps:{...a(e,{labelable:!0}),role:d?"group":"toolbar","aria-orientation":c,"aria-label":n,"aria-labelledby":null==n?r:void 0,onKeyDownCapture:d?void 0:e=>{if(e.currentTarget.contains(e.target)){if("horizontal"===c&&"ArrowRight"===e.key||"vertical"===c&&"ArrowDown"===e.key)f?p.focusPrevious():p.focusNext();else{if(!("horizontal"===c&&"ArrowLeft"===e.key||"vertical"===c&&"ArrowUp"===e.key))return"Tab"===e.key?(e.stopPropagation(),m.current=document.activeElement,void(e.shiftKey?p.focusFirst():p.focusLast())):void 0;f?p.focusNext():p.focusPrevious()}e.stopPropagation(),e.preventDefault()}},onFocusCapture:d?void 0:e=>{var n,r;m.current&&!e.currentTarget.contains(e.relatedTarget)&&(null===(n=t.current)||void 0===n?void 0:n.contains(e.target))&&(null===(r=m.current)||void 0===r||r.focus(),m.current=null)},onBlurCapture:d?void 0:e=>{e.currentTarget.contains(e.relatedTarget)||m.current||(m.current=e.target)}}}}(e,t),r=d({...e,values:{orientation:e.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),f=a(e);return delete f.id,u.createElement("div",{...h(n,f),...r,ref:t,slot:e.slot||void 0,"data-orientation":e.orientation||"horizontal"},r.children)}));function Wd(e,t){const n=+f(e)-+f(t);return n<0?-1:n>0?1:n}function Gd(e,t){const n=f(e,null==t?void 0:t.in);return+function(e,t){const n=f(e,null==t?void 0:t.in);return n.setHours(23,59,59,999),n}(n,t)==+function(e,t){const n=f(e,null==t?void 0:t.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}(n,t)}function qd(e,t,n){const[r,o,s]=m(null==n?void 0:n.in,e,e,t),i=Wd(o,s),a=Math.abs(function(e,t,n){const[r,o]=m(null==n?void 0:n.in,e,t);return 12*(r.getFullYear()-o.getFullYear())+(r.getMonth()-o.getMonth())}(o,s));if(a<1)return 0;1===o.getMonth()&&o.getDate()>27&&o.setDate(30),o.setMonth(o.getMonth()-i*a);let l=Wd(o,s)===-i;Gd(r)&&1===a&&1===Wd(r,s)&&(l=!1);const c=i*(a-+l);return 0===c?0:c}function Yd(e,t,n){const r=function(e,t){return+f(e)-+f(t)}(e,t)/1e3;return(o=null==n?void 0:n.roundingMethod,e=>{const t=(o?Math[o]:Math.trunc)(e);return 0===t?0:t})(r);var o}function Xd(e,t){return function(e,t,n){const r=v(),o=(null==n?void 0:n.locale)??r.locale??g,s=Wd(e,t);if(isNaN(s))throw new RangeError("Invalid time value");const i=Object.assign({},n,{addSuffix:null==n?void 0:n.addSuffix,comparison:s}),[a,l]=m(null==n?void 0:n.in,...s>0?[t,e]:[e,t]),c=Yd(l,a),d=(y(l)-y(a))/1e3,u=Math.round((c-d)/60);let h;if(u<2)return(null==n?void 0:n.includeSeconds)?c<5?o.formatDistance("lessThanXSeconds",5,i):c<10?o.formatDistance("lessThanXSeconds",10,i):c<20?o.formatDistance("lessThanXSeconds",20,i):c<40?o.formatDistance("halfAMinute",0,i):c<60?o.formatDistance("lessThanXMinutes",1,i):o.formatDistance("xMinutes",1,i):0===u?o.formatDistance("lessThanXMinutes",1,i):o.formatDistance("xMinutes",u,i);if(u<45)return o.formatDistance("xMinutes",u,i);if(u<90)return o.formatDistance("aboutXHours",1,i);if(u<b){const e=Math.round(u/60);return o.formatDistance("aboutXHours",e,i)}if(u<2520)return o.formatDistance("xDays",1,i);if(u<x){const e=Math.round(u/b);return o.formatDistance("xDays",e,i)}if(u<2*x)return h=Math.round(u/x),o.formatDistance("aboutXMonths",h,i);if(h=qd(l,a),h<12){const e=Math.round(u/x);return o.formatDistance("xMonths",e,i)}{const e=h%12,t=Math.trunc(h/12);return e<3?o.formatDistance("aboutXYears",t,i):e<9?o.formatDistance("overXYears",t,i):o.formatDistance("almostXYears",t+1,i)}}(e,function(e){return p(e,Date.now())}(e),t)}const Jd={markdown:!0,inline_ai_tooltip:!1,wasm_layouts:!1,scratchpad:!0,chat_sidebar:!1,rtc:!1};function Kd(e){var t;return(null==(t=k().experimental)?void 0:t[e])??Jd[e]}!function(e,t){if("undefined"==typeof window)return;const n=`__marimo__${t}`;window[n]&&w.warn(`Overwriting existing debug object ${n}`),window[n]=e}((function(e,t){const n=k();n.experimental=n.experimental??{},n.experimental[e]=t,S({config:n})}),"setFeatureFlag");const Zd=()=>{const e=j.c(7),{selectedLayout:t}=Fl(),{setLayoutView:n}=Bl();if(_()&&!Kd("wasm_layouts"))return null;let r,o,s,i;return e[0]!==n?(r=e=>n(e),e[0]=n,e[1]=r):r=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(o=I.jsx(O,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:I.jsx(R,{placeholder:"Select a view"})}),e[2]=o):o=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(s=I.jsx(A,{children:I.jsxs(T,{children:[I.jsx(M,{children:"View as"}),Ul.map(nu)]})}),e[3]=s):s=e[3],e[4]!==t||e[5]!==r?(i=I.jsxs(P,{"data-testid":"layout-select",value:t,onValueChange:r,children:[o,s]}),e[4]=t,e[5]=r,e[6]=i):i=e[6],i};function Qd(e){const t=eu(e);return I.jsx(t,{className:"h-4 w-4"})}function eu(e){switch(e){case"vertical":return id;case"grid":return ll;case"slides":return xd;default:return C(e),E}}function tu(e){return N(e)}function nu(e){return I.jsx(D,{value:e,children:I.jsxs("div",{className:"flex items-center gap-1.5 leading-5",children:[Qd(e),I.jsx("span",{children:tu(e)})]})},e)}function ru(){const e=j.c(7);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[n,r]=function(e,t){const n=j.c(10);let r;n[0]!==t||n[1]!==e?(r=new L(e,t),n[0]=t,n[1]=e,n[2]=r):r=n[2];const s=r;let i;n[3]!==s?(i=()=>s.get(),n[3]=s,n[4]=i):i=n[4];const[a,l]=o.useState(i);let c;n[5]!==s?(c=e=>{l(e),s.set(e)},n[5]=s,n[6]=c):c=n[6];const d=c;let u;return n[7]!==d||n[8]!==a?(u=[a,d],n[7]=d,n[8]=a,n[9]=u):u=n[9],u}("marimo:commands",t);let s,i;return e[1]!==n||e[2]!==r?(s=e=>{const t=(o=[e,...n],[...new Set(o)]);var o;r(t.slice(0,3))},e[1]=n,e[2]=r,e[3]=s):s=e[3],e[4]!==n||e[5]!==s?(i={recentCommands:n,addRecentCommand:s},e[4]=n,e[5]=s,e[6]=i):i=e[6],i}function ou(e){return void 0!==e.dropdown}function su(e,t=""){return e.flatMap((e=>e.label?ou(e)?su(e.dropdown,`${t+e.label} > `):{...e,label:t+e.label}:[]))}const iu=e=>{const t=j.c(8),{children:n,layerTop:r}=e,o=void 0!==r&&r;let s;t[0]!==n?(s=u.Children.toArray(n),t[0]=n,t[1]=s):s=t[1];const[i,a]=s,l=`second-icon absolute ${o?"top-[-2px] left-[-2px]":"bottom-[-2px] right-[-2px]"} rounded-full`;let c,d;return t[2]!==a||t[3]!==l?(c=I.jsx("div",{className:l,children:a}),t[2]=a,t[3]=l,t[4]=c):c=t[4],t[5]!==i||t[6]!==c?(d=I.jsxs("div",{className:"multi-icon relative w-fit",children:[i,c]}),t[5]=i,t[6]=c,t[7]=d):d=t[7],d};function au(){const e=j.c(2),t=lu();let n;e[0]!==t?(n=()=>t(V(H())),e[0]=t,e[1]=n):n=e[1];return B(n)}function lu(){const e=j.c(2),{prepareForRun:t}=U();let n;e[0]!==t?(n=async e=>{if(0===e.length)return;const{cellHandles:n,cellData:r}=H(),o=[];for(const s of e){const e=n[s];e.current?(o.push(W(e.current.editorView)),e.current.registerRun()):(t({cellId:s}),o.push(r[s].code))}await G({cellIds:e,codes:o}).catch(cu)},e[0]=t,e[1]=n):n=e[1];return B(n)}function cu(e){w.error(e)}const du=q(null),uu=q(!1),hu=q({chats:[],activeChatId:null}),fu=q((e=>{const t=e(hu);return t.chats.find((e=>e.id===t.activeChatId))}),((e,t,n)=>{t(hu,(e=>({...e,activeChatId:n})))})),pu=e=>{const t=j.c(7);let n,r;t[0]!==e?(n=t=>{var n;(t.ctrlKey||t.metaKey)&&"z"===t.key&&(t.preventDefault(),t.stopPropagation(),null==(n=e.onClick)||n.call(e,t))},t[0]=e,t[1]=n):n=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r={capture:!0},t[2]=r):r=t[2],Y(window,"keydown",n,r);const o=e.children??"Undo";let s,i;return t[3]===Symbol.for("react.memo_cache_sentinel")?(s=I.jsx(J,{className:"ml-2",shortcut:"cmd-z"}),t[3]=s):s=t[3],t[4]!==o||t[5]!==e?(i=I.jsxs(X,{"data-testid":"undo-button",size:"sm",variant:"outline",...e,children:[o," ",s]}),t[4]=o,t[5]=e,t[6]=i):i=t[6],i};function mu(){const e=j.c(3),{deleteCell:t,undoDeleteCell:n}=U();let r;return e[0]!==t||e[1]!==n?(r=e=>{if(K.get(Z))return;const{cellId:r}=e;t({cellId:r}),Q({cellId:r}).catch((()=>{n()}));const{dismiss:o}=ee({title:"Cell deleted",description:"You can bring it back by clicking undo or through the command palette.",action:I.jsx(pu,{"data-testid":"undo-delete-button",onClick:()=>{n(),s()}})}),s=o},e[0]=t,e[1]=n,e[2]=r):r=e[2],B(r)}function gu(e,t,n,r=K){if(t in r.get(te))return!1;const{cellData:o,cellIds:s}=r.get(ne),i=new RegExp(`import[ \t]+${e}[ \t]+as[ \t]+${t}`,"g");for(const a of s.inOrderIds)if(i.test(o[a].code))return!1;return n(`import ${e} as ${t}`),!0}function yu(e,t,n){return gu("marimo","mo",(r=>{const o=re.create();t({cellId:n??"__end__",before:!1,code:r,lastCodeRun:e?r:void 0,newCellId:o,autoFocus:!1}),e&&G({cellIds:[o],codes:[r]})}))}function bu(){const e=j.c(3),{splitCell:t,undoSplitCell:n}=U();let r;return e[0]!==t||e[1]!==n?(r=e=>{const r=oe(e.cellId);if(!r)return;const o=W(r);t(e);const{dismiss:s}=ee({title:"Cell split",action:I.jsx(pu,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{n({...e,snapshot:o}),i()},children:"Undo"})}),i=s},e[0]=t,e[1]=n,e[2]=r):r=e[2],B(r)}function xu(e){const t=j.c(49),{cell:n}=e,{createNewCell:r,updateCellConfig:o,updateCellCode:s,updateCellName:i,moveCell:a,sendToTop:l,sendToBottom:c,addColumnBreakpoint:d,clearCellOutput:u}=U(),h=bu(),f=function(e){const t=j.c(3),n=lu();let r;return t[0]!==e||t[1]!==n?(r=()=>{void 0!==e&&n([e])},t[0]=e,t[1]=n,t[2]=r):r=t[2],B(r)}(null==n?void 0:n.cellId),p=!se(Z),m=mu(),{openModal:g}=ie(),y=ae(du),b=se(le),x=se(ce),v=se(de),w=se(ue);if(!n||v){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],e}const{cellId:k,config:S,getEditorView:C,name:E,hasOutput:N,hasConsoleOutput:_,status:A}=n;let T;t[1]!==k||t[2]!==S.disabled||t[3]!==o?(T=async()=>{const e={disabled:!S.disabled};await _e({configs:{[k]:e}}),o({cellId:k,config:e})},t[1]=k,t[2]=S.disabled,t[3]=o,t[4]=T):T=t[4];const M=T;let D;t[5]!==k||t[6]!==S.hide_code||t[7]!==C||t[8]!==o?(D=async()=>{const e={hide_code:!S.hide_code};await _e({configs:{[k]:e}}),o({cellId:k,config:e});const t=C();t&&(e.hide_code?t.contentDOM.blur():t.focus())},t[5]=k,t[6]=S.hide_code,t[7]=C,t[8]=o,t[9]=D):D=t[9];const O=D;let R,P,L,$,H;if(t[10]===Symbol.for("react.memo_cache_sentinel")?(R=I.jsx(Rd,{size:13,strokeWidth:1.5}),t[10]=R):R=t[10],t[11]!==k||t[12]!==E||t[13]!==g||t[14]!==i?(P=()=>{g(I.jsxs(Ie,{children:[I.jsx(Ae,{children:I.jsx(Te,{children:"Rename cell"})}),I.jsxs("div",{className:"flex items-center justify-between",children:[I.jsx(Me,{htmlFor:"cell-name",children:"Cell name"}),I.jsx(Hl,{placeholder:"cell name",value:E,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),g(null))},onChange:e=>i({cellId:k,name:e})})]})]}))},t[11]=k,t[12]=E,t[13]=g,t[14]=i,t[15]=P):P=t[15],t[16]!==k||t[17]!==i?(L=e=>i({cellId:k,name:e}),t[16]=k,t[17]=i,t[18]=L):L=t[18],t[19]!==E||t[20]!==L?($=I.jsx(Hl,{placeholder:"cell name",value:E,onChange:L}),t[19]=E,t[20]=L,t[21]=$):$=t[21],t[22]!==d||t[23]!==b||t[24]!==w||t[25]!==x||t[26]!==p||t[27]!==k||t[28]!==u||t[29]!==S.disabled||t[30]!==S.hide_code||t[31]!==r||t[32]!==m||t[33]!==C||t[34]!==_||t[35]!==N||t[36]!==a||t[37]!==f||t[38]!==c||t[39]!==l||t[40]!==y||t[41]!==h||t[42]!==A||t[43]!==P||t[44]!==$||t[45]!==M||t[46]!==O||t[47]!==s){H=[[{icon:R,label:"Name",disableClick:!0,handle:Su,handleHeadless:P,rightElement:$},{icon:I.jsx(bd,{size:13,strokeWidth:1.5}),label:"Run cell",hotkey:"cell.run",hidden:"running"===A||"queued"===A||"disabled-transitively"===A||S.disabled,handle:()=>f()},{icon:I.jsx(he,{size:13,strokeWidth:1.5}),label:"AI completion",hidden:!b,handle:()=>{y((e=>(null==e?void 0:e.cellId)===k?null:{cellId:k}))},hotkey:"cell.aiCompletion"},{icon:I.jsx(Cd,{size:13,strokeWidth:1.5}),label:"Split cell",hotkey:"cell.splitCell",handle:()=>h({cellId:k})},{icon:I.jsx($l,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!N,handle:()=>function(e){const t=document.getElementById(z.create(e));t&&(t.classList.add("printing-output"),F(t,"result.png").finally((()=>{t.classList.remove("printing-output")})))}(k)},{icon:I.jsx(fe,{size:13,strokeWidth:1.5}),label:"Format cell",hotkey:"cell.format",handle:()=>{const e=C();e&&pe({[k]:e},s)}},{icon:S.hide_code?I.jsx(me,{size:13,strokeWidth:1.5}):I.jsx(ge,{size:13,strokeWidth:1.5}),label:S.hide_code?"Show code":"Hide code",handle:O,hotkey:"cell.hideCode"},{icon:S.disabled?I.jsx(Ud,{size:13,strokeWidth:1.5}):I.jsx($d,{size:13,strokeWidth:1.5}),label:"Reactive execution",rightElement:I.jsx(ye,{"data-testid":"cell-disable-switch",checked:!S.disabled,size:"sm",onCheckedChange:M}),handle:M},{icon:I.jsx(be,{size:13,strokeWidth:1.5}),label:"Clear output",hidden:!(N||_),handle:()=>{u({cellId:k})}}],[{icon:I.jsx(cl,{}),label:"Convert to Markdown",hotkey:"cell.viewAsMarkdown",handle:()=>{const e=C();e&&(yu(x,r),xe(e,"markdown",{keepCodeAsIs:!0}))}},{icon:I.jsx(ve,{size:13,strokeWidth:1.5}),label:"Convert to SQL",handle:()=>{const e=C();e&&(yu(x,r),xe(e,"sql",{keepCodeAsIs:!0}))}},{icon:I.jsx(dl,{}),label:"Toggle as Python",handle:()=>{const e=C();e&&(yu(x,r),we(e,"python",{force:!0}))}}],[{icon:I.jsxs(iu,{children:[I.jsx(zc,{size:13,strokeWidth:1.5}),I.jsx(ke,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>r({cellId:k,before:!0})},{icon:I.jsxs(iu,{children:[I.jsx(zc,{size:13,strokeWidth:1.5}),I.jsx(Se,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>r({cellId:k,before:!1})},{icon:I.jsx(ke,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>a({cellId:k,before:!0})},{icon:I.jsx(Se,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>a({cellId:k,before:!1})},{icon:I.jsx(Ce,{size:13,strokeWidth:1.5}),label:"Move cell left",hotkey:"cell.moveLeft",handle:()=>a({cellId:k,direction:"left"}),hidden:"columns"!==w},{icon:I.jsx(Ee,{size:13,strokeWidth:1.5}),label:"Move cell right",hotkey:"cell.moveRight",handle:()=>a({cellId:k,direction:"right"}),hidden:"columns"!==w},{icon:I.jsx(Rc,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>l({cellId:k})},{icon:I.jsx(Oc,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>c({cellId:k})},{icon:I.jsx(Ne,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",hidden:"columns"!==w,handle:()=>d({cellId:k})}],[{label:"Delete",hidden:!p,variant:"danger",icon:I.jsx(je,{size:13,strokeWidth:1.5}),handle:()=>{m({cellId:k})}}]].map(wu).filter(vu),t[22]=d,t[23]=b,t[24]=w,t[25]=x,t[26]=p,t[27]=k,t[28]=u,t[29]=S.disabled,t[30]=S.hide_code,t[31]=r,t[32]=m,t[33]=C,t[34]=_,t[35]=N,t[36]=a,t[37]=f,t[38]=c,t[39]=l,t[40]=y,t[41]=h,t[42]=A,t[43]=P,t[44]=$,t[45]=M,t[46]=O,t[47]=s,t[48]=H}else H=t[48];return H}function vu(e){return e.length>0}function wu(e){return e.filter(ku)}function ku(e){return!e.hidden}function Su(e){null==e||e.stopPropagation(),null==e||e.preventDefault()}const Cu=q(null);function Eu(){return se(Cu)}const Nu=q((e=>{const t=e(Cu);return t?t===De?null:ju(t,e(ne)):null}));function ju(e,t){var n;const{cellData:r,cellHandles:o,cellRuntime:s}=t,i=r[e],a=s[e],l=null==(n=o[e])?void 0:n.current;if(!i||!l)return null;return{cellId:e,name:i.name,config:i.config,status:a?a.status:"idle",getEditorView:()=>l.editorView,hasOutput:null!=(null==a?void 0:a.output),hasConsoleOutput:null!=(null==a?void 0:a.consoleOutputs)}}function _u(e){return!e.hidden}const Iu=q(!1),Au=()=>{const e=j.c(32),[t,n]=ze(Iu),r=hl(),o=se(Nu),s=se(Fe);let i;e[0]!==o?(i={cell:o},e[0]=o,e[1]=i):i=e[1];let a=xu(i).flat();a=su(a);const l=function(){const e=j.c(46),{theme:t}=Oe(),[n,r]=Re(),[o,s]=Pe();let i;e[0]!==r?(i=async e=>{await S({config:e}).then((()=>{r(e)}))},e[0]=r,e[1]=i):i=e[1];const a=i;let l;e[2]!==s?(l=async e=>{await Le({config:e}).then((()=>{s(e)}))},e[2]=s,e[3]=l):l=e[3];const c=l;let d,u;if(e[4]!==o||e[5]!==c){let t;e[7]!==o.width?(t=e=>e!==o.width,e[7]=o.width,e[8]=t):t=e[8],d=ul().filter(t).map((e=>({label:`App config > Set width=${e}`,handle:()=>{c({...o,width:e})}}))),e[4]=o,e[5]=c,e[6]=d}else d=e[6];e[9]!==n||e[10]!==a||e[11]!==t?(u={label:"Config > Toggle dark mode",handle:()=>{a({...n,display:{...n.display,theme:"dark"===t?"light":"dark"}})}},e[9]=n,e[10]=a,e[11]=t,e[12]=u):u=e[12];const h="vim"===n.keymap.preset;let f,p;e[13]!==n||e[14]!==a?(f=()=>{a({...n,keymap:{...n.keymap,preset:"vim"}})},e[13]=n,e[14]=a,e[15]=f):f=e[15],e[16]!==h||e[17]!==f?(p={label:"Config > Switch keymap to VIM",hidden:h,handle:f},e[16]=h,e[17]=f,e[18]=p):p=e[18];const m="default"===n.keymap.preset;let g,y,b;e[19]!==n||e[20]!==a?(g=()=>{a({...n,keymap:{...n.keymap,preset:"default"}})},e[19]=n,e[20]=a,e[21]=g):g=e[21],e[22]!==m||e[23]!==g?(y={label:"Config > Switch keymap to default (current: VIM)",hidden:m,handle:g},e[22]=m,e[23]=g,e[24]=y):y=e[24],e[25]!==n||e[26]!==a?(b=()=>{a({...n,completion:{...n.completion,copilot:!1}})},e[25]=n,e[26]=a,e[27]=b):b=e[27];const x="github"!==n.completion.copilot;let v,w;e[28]!==b||e[29]!==x?(v={label:"Config > Disable GitHub Copilot",handle:b,hidden:x},e[28]=b,e[29]=x,e[30]=v):v=e[30],e[31]!==n||e[32]!==a?(w=()=>{a({...n,completion:{...n.completion,copilot:"github"}})},e[31]=n,e[32]=a,e[33]=w):w=e[33];const k="github"===n.completion.copilot;let C,E;e[34]!==w||e[35]!==k?(C={label:"Config > Enable GitHub Copilot",handle:w,hidden:k},e[34]=w,e[35]=k,e[36]=C):C=e[36],e[37]!==v||e[38]!==C||e[39]!==d||e[40]!==u||e[41]!==p||e[42]!==y?(E=[...d,u,p,y,v,C],e[37]=v,e[38]=C,e[39]=d,e[40]=u,e[41]=p,e[42]=y,e[43]=E):E=e[43];const N=E;let _;return e[44]!==N?(_=N.filter(_u),e[44]=N,e[45]=_):_=e[45],_}();let c=gh();c=[...su(c),...su(l)];const d=c.filter(Tu),u=Be.keyBy(d,Mu),{recentCommands:h,addRecentCommand:f}=ru(),p=new Set(h);let m,g;e[2]!==s||e[3]!==n?(m=e=>{Ve(s.getHotkey("global.commandPalette").key)(e)&&(e.preventDefault(),n(Du))},e[2]=s,e[3]=n,e[4]=m):m=e[4],Y(document,"keydown",m),e[5]!==f||e[6]!==s||e[7]!==r||e[8]!==n?(g=(e,t)=>{const o=r[e];if(!o)return null;const i=s.getHotkey(e);return I.jsxs(We,{disabled:t.disabled,onSelect:()=>{f(e),n(!1),requestAnimationFrame((()=>{o()}))},value:i.name,children:[I.jsxs("span",{children:[i.name,t.tooltip&&I.jsx("span",{className:"ml-2",children:t.tooltip})]}),I.jsx(Ge,{children:I.jsx(qe,{shortcut:i.key})})]},e)},e[5]=f,e[6]=s,e[7]=r,e[8]=n,e[9]=g):g=e[9];const y=g;let b;e[10]!==f||e[11]!==s||e[12]!==n?(b=(e,t,r,o)=>{const i=void 0===r?{}:r;return I.jsxs(We,{disabled:i.disabled,onSelect:()=>{f(e),n(!1),requestAnimationFrame((()=>{t()}))},value:e,children:[I.jsxs("span",{children:[e,i.tooltip&&I.jsxs("span",{className:"ml-2",children:["(",i.tooltip,")"]})]}),o&&I.jsx(Ge,{children:I.jsx(qe,{shortcut:s.getHotkey(o).key})})]},e)},e[10]=f,e[11]=s,e[12]=n,e[13]=b):b=e[13];const x=b,v=Ye;let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=I.jsx(Xe,{placeholder:"Type to search..."}),e[14]=w):w=e[14];const k=Je;let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=I.jsx(Ke,{children:"No results found."}),e[15]=C):C=e[15];const E=h.length>0&&I.jsxs(I.Fragment,{children:[I.jsx(Ue,{heading:"Recently Used",children:h.map((e=>{const t=u[e];return $e(e)?y(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip}):t&&!ou(t)?x(t.label,t.handleHeadless||t.handle,{disabled:t.disabled,tooltip:t.tooltip}):null}))}),I.jsx(He,{})]}),N=Ue,_=s.iterate().map((e=>{if(p.has(e))return null;const t=u[e];return y(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip})})),A=d.map((e=>p.has(e.label)?null:x(e.label,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip}))),T=a.map((e=>p.has(e.label)?null:x(`Cell > ${e.label}`,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip})));let M,D,O;return e[16]!==N||e[17]!==T||e[18]!==_||e[19]!==A?(M=I.jsxs(N,{heading:"Commands",children:[_,A,T]}),e[16]=N,e[17]=T,e[18]=_,e[19]=A,e[20]=M):M=e[20],e[21]!==k||e[22]!==M||e[23]!==C||e[24]!==E?(D=I.jsxs(k,{children:[C,E,M]}),e[21]=k,e[22]=M,e[23]=C,e[24]=E,e[25]=D):D=e[25],e[26]!==v||e[27]!==t||e[28]!==n||e[29]!==D||e[30]!==w?(O=I.jsxs(v,{open:t,onOpenChange:n,children:[w,D]}),e[26]=v,e[27]=t,e[28]=n,e[29]=D,e[30]=w,e[31]=O):O=e[31],O};function Tu(e){return!e.hotkey}function Mu(e){return e.label}function Du(e){return!e}const Ou="https://static.marimo.app",Ru=e=>{const t=j.c(24),{onClose:n}=e,[r,s]=o.useState("");let i;i=Math.random().toString(36).slice(2,6);const a=`${r}-${i}`,l=`${Ou}/static/${a}`;let c,d,u,h,f,p,m,g,y,b,x;return t[0]!==n||t[1]!==a?(c=async e=>{e.preventDefault(),n();const t=await Ze({download:!1,includeCode:!0,files:Vl.INSTANCE.filenames()}),r=ee({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Ou}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:t,path:a})}).catch((()=>{r.dismiss(),ee({title:"Error uploading static page",description:I.jsxs("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",I.jsx("a",{href:Qe.issuesPage,target:"_blank",rel:"noreferrer",className:"underline",children:"GitHub"}),"."]})})})),r.dismiss(),ee({title:"Static page uploaded!",description:I.jsxs("div",{children:["The URL has been copied to your clipboard.",I.jsx("br",{}),"You can share it with anyone."]})})},t[0]=n,t[1]=a,t[2]=c):c=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(d=I.jsx(Te,{children:"Share static notebook"}),t[3]=d):d=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(u=I.jsxs(Ae,{children:[d,I.jsxs(et,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",I.jsx("a",{href:Ou,target:"_blank",rel:"noreferrer",children:Ou}),"."]})]}),t[4]=u):u=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(h=e=>{const t=e.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,"");s(t)},t[5]=h):h=t[5],t[6]!==r?(f=I.jsx(tt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:r,placeholder:"Notebook slug",onChange:h,required:!0,autoComplete:"off"}),t[6]=r,t[7]=f):f=t[7],t[8]!==l?(p=I.jsxs("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx(Pu,{text:l}),I.jsx("span",{className:"text-primary",children:l})]})]}),t[8]=l,t[9]=p):p=t[9],t[10]!==f||t[11]!==p?(m=I.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[f,p]}),t[10]=f,t[11]=p,t[12]=m):m=t[12],t[13]!==n?(g=I.jsx(X,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[13]=n,t[14]=g):g=t[14],t[15]!==l?(y=I.jsx(X,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await nt(l)},children:"Create"}),t[15]=l,t[16]=y):y=t[16],t[17]!==y||t[18]!==g?(b=I.jsxs(rt,{children:[g,y]}),t[17]=y,t[18]=g,t[19]=b):b=t[19],t[20]!==b||t[21]!==c||t[22]!==m?(x=I.jsx(Ie,{className:"w-fit",children:I.jsxs("form",{onSubmit:c,children:[u,m,b]})}),t[20]=b,t[21]=c,t[22]=m,t[23]=x):x=t[23],x},Pu=e=>{const t=j.c(8),[n,r]=u.useState(!1);let o;t[0]!==e.text?(o=ot.stopPropagation((async t=>{t.preventDefault(),await nt(e.text),r(!0),setTimeout((()=>r(!1)),2e3)})),t[0]=e.text,t[1]=o):o=t[1];const s=o;let i,a,l;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=I.jsx(st,{size:14,strokeWidth:1.5}),t[2]=i):i=t[2],t[3]!==s?(a=I.jsx(X,{"data-testid":"copy-static-notebook-url-button",onClick:s,size:"xs",variant:"secondary",children:i}),t[3]=s,t[4]=a):a=t[4],t[5]!==n||t[6]!==a?(l=I.jsx(it,{content:"Copied!",open:n,children:a}),t[5]=n,t[6]=a,t[7]=l):l=t[7],l};function Lu(){const e=j.c(3),{openConfirm:t}=ie(),n=ae(at);let r;return e[0]!==t||e[1]!==n?(r=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:I.jsx(lt,{onClick:async()=>{n({state:ct.CLOSING}),await dt(),ut()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}const zu=new ht("marimo:sidebar",ft.object({selectedPanel:ft.string().optional().transform((e=>e)),isSidebarOpen:ft.boolean(),isTerminalOpen:ft.boolean()}),(function(){return{selectedPanel:"variables",isSidebarOpen:!1,isTerminalOpen:!1}}));const{reducer:Fu,createActions:Bu,valueAtom:Uu,useActions:$u}=pt((()=>zu.get()),{openApplication:(e,t)=>({...e,selectedPanel:t,isSidebarOpen:!e.isSidebarOpen||e.selectedPanel!==t}),toggleSidebarPanel:e=>({...e,isSidebarOpen:!e.isSidebarOpen}),setIsSidebarOpen:(e,t)=>({...e,isSidebarOpen:t}),toggleTerminal:e=>({...e,isTerminalOpen:!e.isTerminalOpen}),setIsTerminalOpen:(e,t)=>({...e,isTerminalOpen:t})},[(e,t)=>zu.set(t)]),Hu=()=>{const e=j.c(2),t=se(Uu);if(t.isSidebarOpen)return t;let n;return e[0]!==t?(n={...t,selectedPanel:void 0},e[0]=t,e[1]=n):n=e[1],n};function Vu(){return $u()}const Wu=[{type:"files",Icon:Zc,tooltip:"View files",position:"sidebar"},{type:"variables",Icon:mt,tooltip:"Explore variables",position:"sidebar"},{type:"datasources",Icon:ve,tooltip:"Explore data sources",position:"sidebar"},{type:"dependencies",Icon:dd,tooltip:"Explore dependencies",position:"sidebar"},{type:"packages",Icon:Dc,tooltip:"Manage packages",position:"sidebar"},{type:"outline",Icon:Ed,tooltip:"View outline",position:"sidebar"},{type:"chat",Icon:gt,tooltip:"Chat with AI",position:"sidebar",hidden:!Kd("chat_sidebar")},{type:"documentation",Icon:Pd,tooltip:"View live docs",position:"sidebar"},{type:"logs",Icon:yt,tooltip:"Notebook logs",position:"sidebar"},{type:"tracing",Icon:fl,tooltip:"Tracing",position:"sidebar"},{type:"snippets",Icon:_d,tooltip:"Snippets",position:"sidebar"},{type:"scratchpad",Icon:ud,hidden:!Kd("scratchpad"),tooltip:"Scratchpad",position:"sidebar"},{type:"errors",Icon:be,tooltip:"View errors",position:"footer"}];function Gu(){const e=j.c(2),t=ae(bt);let n;e[0]!==t?(n=()=>{const e=document.getElementsByClassName("output-area"),n=window.innerHeight||document.documentElement.clientHeight;let r;r=null;for(const t of Array.from(e)){const e=t.getBoundingClientRect();if(e.top>=0&&e.top<=n||e.bottom>=0&&e.bottom<=n){r=xt.parse(t.parentNode.id);break}}t((e=>({mode:vt(e.mode),cellAnchor:r}))),requestAnimationFrame((()=>{var e;null!==r&&(null==(e=document.getElementById(xt.create(r)))||e.scrollIntoView())}))},e[0]=t,e[1]=n):n=e[1];return n}function qu(){return ft.string().optional().describe(Ct.of({label:"Password",inputType:"password",placeholder:"password"}))}function Yu(){return ft.string().nonempty().describe(Ct.of({label:"Host",placeholder:"localhost"}))}function Xu(){return ft.string().describe(Ct.of({label:"Database",placeholder:"db name"}))}function Ju(){return ft.string().nonempty().describe(Ct.of({label:"Username",placeholder:"username"}))}function Ku(e){return ft.coerce.string().default(e.toString()).describe(Ct.of({label:"Port",inputType:"number",placeholder:e.toString()})).transform(Number).refine((e=>e>=0&&e<=65535),{message:"Port must be between 0 and 65535"})}const Zu=ft.object({type:ft.literal("postgres"),host:Yu(),port:Ku(5432),database:Xu(),username:Ju(),password:qu(),ssl:ft.boolean().default(!1).describe(Ct.of({label:"Use SSL"}))}).describe(Ct.of({direction:"two-columns"})),Qu=ft.object({type:ft.literal("mysql"),host:Yu(),port:Ku(3306),database:Xu(),username:Ju(),password:qu(),ssl:ft.boolean().default(!1).describe(Ct.of({label:"Use SSL"}))}).describe(Ct.of({direction:"two-columns"})),eh=ft.object({type:ft.literal("sqlite"),database:Xu().describe(Ct.of({label:"Database Path"}))}).describe(Ct.of({direction:"two-columns"})),th=ft.object({type:ft.literal("duckdb"),database:Xu().describe(Ct.of({label:"Database Path"})),read_only:ft.boolean().default(!1).describe(Ct.of({label:"Read Only"}))}).describe(Ct.of({direction:"two-columns"})),nh=ft.object({type:ft.literal("snowflake"),account:ft.string().nonempty().describe(Ct.of({label:"Account"})),warehouse:ft.string().optional().describe(Ct.of({label:"Warehouse"})),database:Xu(),schema:ft.string().optional().describe(Ct.of({label:"Schema"})),username:Ju(),password:qu(),role:ft.string().optional().describe(Ct.of({label:"Role"}))}).describe(Ct.of({direction:"two-columns"})),rh=ft.object({type:ft.literal("bigquery"),project:ft.string().nonempty().describe(Ct.of({label:"Project ID"})),dataset:ft.string().nonempty().describe(Ct.of({label:"Dataset"})),credentials_json:ft.string().describe(Ct.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(Ct.of({direction:"two-columns"})),oh=ft.discriminatedUnion("type",[Zu,Qu,eh,th,nh,rh]),sh={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy"};const ih=Nt("marimo:preferred-connection","sqlalchemy"),ah=[{name:"PostgreSQL",schema:Zu,color:"#336791",logo:"postgres"},{name:"MySQL",schema:Qu,color:"#00758F",logo:"mysql"},{name:"SQLite",schema:eh,color:"#003B57",logo:"sqlite"},{name:"DuckDB",schema:th,color:"#FFD700",logo:"duckdb"},{name:"Snowflake",schema:nh,color:"#29B5E8",logo:"snowflake"},{name:"BigQuery",schema:rh,color:"#4285F4",logo:"googlebigquery"}],lh=e=>{const t=j.c(4),{onSelect:n}=e;let r,o;return t[0]!==n?(r=ah.map((e=>{const{name:t,schema:r,color:o,logo:s}=e;return I.jsxs("button",{type:"button",className:"h-28 flex flex-col items-center justify-center gap-3 transition-all hover:scale-105 hover:brightness-110 rounded shadow-smSolid hover:shadow-mdSolid",style:{backgroundColor:o},onClick:()=>n(r),children:[I.jsx(Mt,{name:s,className:"w-10 h-10 text-white brightness-0 invert dark:invert"}),I.jsx("span",{className:"text-white font-medium text-lg",children:t})]},t)})),t[0]=n,t[1]=r):r=t[1],t[2]!==r?(o=I.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:r}),t[2]=r,t[3]=o):o=t[3],o},ch=e=>{const t=j.c(35),{schema:n,onSubmit:r,onBack:o}=e;let s,i,a;t[0]!==n?(s=It(n),t[0]=n,t[1]=s):s=t[1],t[2]!==n?(i=At(n),t[2]=n,t[3]=i):i=t[3],t[4]!==s||t[5]!==i?(a={defaultValues:s,resolver:i,reValidateMode:"onChange"},t[4]=s,t[5]=i,t[6]=a):a=t[6];const l=Tt(a),[c,d]=ze(ih);let u,h,f,p;t[7]!==l||t[8]!==r?(u=l.handleSubmit(r),t[7]=l,t[8]=r,t[9]=u):u=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(h=I.jsx(Dt,{}),t[10]=h):h=t[10],t[11]!==l||t[12]!==n?(f=I.jsx(Ot,{schema:n,form:l,children:h}),t[11]=l,t[12]=n,t[13]=f):f=t[13],t[14]!==o?(p=I.jsx(X,{type:"button",variant:"outline",onClick:o,children:"Back"}),t[14]=o,t[15]=p):p=t[15];const m=!l.formState.isValid;let g,y,b,x,v,w,k,S;return t[16]!==m?(g=I.jsx(X,{type:"submit",disabled:m,children:"Add"}),t[16]=m,t[17]=g):g=t[17],t[18]!==p||t[19]!==g?(y=I.jsxs("div",{className:"flex gap-2",children:[p,g]}),t[18]=p,t[19]=g,t[20]=y):y=t[20],t[21]!==d?(b=e=>d(e),t[21]=d,t[22]=b):b=t[22],t[23]===Symbol.for("react.memo_cache_sentinel")?(x=I.jsxs("div",{className:"flex flex-col gap-1 items-end",children:[I.jsx(O,{children:I.jsx(R,{placeholder:"Select a library"})}),I.jsx("span",{className:"text-xs text-muted-foreground",children:"Preferred connection library"})]}),t[23]=x):x=t[23],t[24]===Symbol.for("react.memo_cache_sentinel")?(v=I.jsx(A,{children:I.jsx(T,{children:Object.entries(sh).map(fh)})}),t[24]=v):v=t[24],t[25]!==c||t[26]!==b?(w=I.jsx("div",{children:I.jsxs(P,{value:c,onValueChange:b,children:[x,v]})}),t[25]=c,t[26]=b,t[27]=w):w=t[27],t[28]!==y||t[29]!==w?(k=I.jsxs("div",{className:"flex gap-2 justify-between",children:[y,w]}),t[28]=y,t[29]=w,t[30]=k):k=t[30],t[31]!==k||t[32]!==u||t[33]!==f?(S=I.jsxs("form",{onSubmit:u,className:"space-y-4",children:[f,k]}),t[31]=k,t[32]=u,t[33]=f,t[34]=S):S=t[34],S},dh=e=>{const t=j.c(5),{onSubmit:n}=e,[r,s]=o.useState(null);if(!r){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx(lh,{onSelect:s}),t[0]=e):e=t[0],e}let i,a;return t[1]===Symbol.for("react.memo_cache_sentinel")?(i=()=>s(null),t[1]=i):i=t[1],t[2]!==n||t[3]!==r?(a=I.jsx(ch,{schema:r,onSubmit:n,onBack:i}),t[2]=n,t[3]=r,t[4]=a):a=t[4],a},uh=e=>{const t=j.c(6),{children:n}=e,[r,s]=o.useState(!1);let i,a,l;return t[0]!==n?(i=I.jsx(jt,{asChild:!0,children:n}),t[0]=n,t[1]=i):i=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(a=I.jsx(hh,{onClose:()=>s(!1)}),t[2]=a):a=t[2],t[3]!==r||t[4]!==i?(l=I.jsxs(_t,{open:r,onOpenChange:s,children:[i,a]}),t[3]=r,t[4]=i,t[5]=l):l=t[5],l},hh=e=>{const t=j.c(11),{onClose:n}=e,{createNewCell:r}=U(),o=Eu(),s=se(ih);let i;t[0]!==r||t[1]!==o?(i=e=>{r({code:e,before:!1,cellId:o??"__end__",skipIfCodeExists:!0,autoFocus:!0})},t[0]=r,t[1]=o,t[2]=i):i=t[2];const a=i;let l;t[3]!==a||t[4]!==n||t[5]!==s?(l=e=>{a(function(e,t){if(!(t in sh))throw new Error(`Unsupported library: ${t}`);oh.parse(e);const n="sqlmodel"===t?["from sqlmodel import create_engine","import os"]:["from sqlalchemy import create_engine","import os"];let r="";switch(e.type){case"postgres":r=`\npassword = os.environ.get("POSTGRES_PASSWORD", "${e.password}")\nDATABASE_URL = f"postgresql://${e.username}:{password}@${e.host}:${e.port}/${e.database}"\nengine = create_engine(DATABASE_URL${e.ssl?", connect_args={'sslmode': 'require'}":""})\n`;break;case"mysql":r=`\npassword = os.environ.get("MYSQL_PASSWORD", "${e.password}")\nDATABASE_URL = f"mysql+pymysql://${e.username}:{password}@${e.host}:${e.port}/${e.database}"\nengine = create_engine(DATABASE_URL${e.ssl?", connect_args={'ssl': {'ssl-mode': 'preferred'}}":""})\n`;break;case"sqlite":r=`\nDATABASE_URL = "sqlite:///${e.database}"\nengine = create_engine(DATABASE_URL)\n`;break;case"snowflake":{n.push("from snowflake.sqlalchemy import URL"),n.push("import sqlalchemy as sa");const t={account:e.account,user:e.username,password:`os.environ.get("SNOWFLAKE_PASSWORD", "${e.password}")`,database:e.database,warehouse:e.warehouse,schema:e.schema,role:e.role},o=Object.entries(t).filter((([,e])=>e)).map((([e,t])=>` ${e}=${t}`)).join(",\n");r=`\npassword = os.environ.get("SNOWFLAKE_PASSWORD", "${e.password}")\nengine = sa.create_engine(\n URL(\n${o}\n )\n)\n`;break}case"bigquery":n.push("import json"),r=`\ncredentials = json.loads("""${e.credentials_json}""")\nengine = create_engine(f"bigquery://${e.project}/${e.dataset}", credentials_info=credentials)\n`;break;case"duckdb":r=`\nengine = create_engine("duckdb:${e.database||":memory:"}"${e.read_only?", read_only=True":""})\n`;break;default:Et(e)}return`${n.join("\n")}\n${r.trim()}`}(e,s)),n()},t[3]=a,t[4]=n,t[5]=s,t[6]=l):l=t[6];const c=l;let d,u,h;return t[7]===Symbol.for("react.memo_cache_sentinel")?(d=I.jsx(Te,{children:"Add Database Connection"}),t[7]=d):d=t[7],t[8]===Symbol.for("react.memo_cache_sentinel")?(u=I.jsxs(Ae,{className:"mb-4",children:[d,I.jsxs(et,{children:["Connect to your database to query data directly from your notebook. Learn more about how to connect to your database in our"," ",I.jsx("a",{href:"http://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database",target:"_blank",rel:"noreferrer",className:"text-link hover:underline",children:"docs."})]})]}),t[8]=u):u=t[8],t[9]!==c?(h=I.jsxs(Ie,{children:[u,I.jsx(dh,{onSubmit:e=>{c(e)}})]}),t[9]=c,t[10]=h):h=t[10],h};function fh(e){const[t,n]=e;return I.jsx(D,{value:t,children:n},t)}const ph=()=>{const e=j.c(2),{updateCellConfig:t}=U();let n;return e[0]!==t?(n=async()=>{const e=new Rt,n=H(),r=n.cellIds.inOrderIds,o={};for(const t of r){if(void 0===n.cellData[t])continue;const{code:r,config:s}=n.cellData[t];s.hide_code||e.isSupported(r)&&(o[t]={hide_code:!0})}const s=Be.entries(o);if(0!==s.length){await _e({configs:o});for(const[e,n]of s)t({cellId:e,config:n})}},e[0]=t,e[1]=n):n=e[1],n},mh=e=>{null==e||e.preventDefault(),null==e||e.stopPropagation()};function gh(){const e=j.c(133),t=Pt(),{openModal:n,closeModal:r}=ie(),{openApplication:o}=Vu(),{selectedPanel:s}=Hu(),[i]=ze(bt),a=se(de),l=ph(),{updateCellConfig:c,undoDeleteCell:d,clearAllCellOutputs:u}=U(),h=Lu(),f=au(),p=function(e){const t=j.c(4),{openPrompt:n,closeModal:r}=ie();let o;return t[0]!==r||t[1]!==n||t[2]!==e?(o=()=>{if(!e)return null;const t=wt.guessDeliminator(e),o=kt.basename(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${o}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:n=>{const o=t.join(kt.dirname(e),n);St({source:e,destination:o}).then((()=>{r(),ee({title:"Notebook copied",description:"A copy of the notebook has been created."}),window.open(`/?file=${o}`,"_blank")}))}})},t[0]=r,t[1]=n,t[2]=e,t[3]=o):o=t[3],o}(t),m=ae(Iu),g=ae(pl),y=ae(ml),b=se(Lt),x=se(zt),v=se(Ft),{selectedLayout:w}=Fl(),{setLayoutView:k}=Bl(),S=Gu(),C=Dh;let E,A,T,M,D,O,R,P,L,z,F,B,$;e[0]===Symbol.for("react.memo_cache_sentinel")?(E=I.jsx(Nd,{size:14,strokeWidth:1.5}),e[0]=E):E=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(A=I.jsx(Vt,{size:14,strokeWidth:1.5}),e[1]=A):A=e[1],e[2]!==r||e[3]!==n?(T={icon:A,label:"Publish HTML to web",handle:async()=>{n(I.jsx(Ru,{onClose:r}))}},e[2]=r,e[3]=n,e[4]=T):T=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(M={icon:I.jsx(sd,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",handle:Mh},e[5]=M):M=e[5],e[6]!==T?(D={icon:E,label:"Share",handle:mh,dropdown:[T,M]},e[6]=T,e[7]=D):D=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(O=I.jsx(Wt,{size:14,strokeWidth:1.5}),e[8]=O):O=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(R=I.jsx(Wl,{size:14,strokeWidth:1.5}),e[9]=R):R=e[9],e[10]!==t?(P={icon:R,label:"Download as HTML",handle:async()=>{t?await Gl({filename:t,includeCode:!0}):ee({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},e[10]=t,e[11]=P):P=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(L=I.jsx(Wl,{size:14,strokeWidth:1.5}),e[12]=L):L=e[12],e[13]!==t?(z={icon:L,label:"Download as HTML (exclude code)",handle:async()=>{t?await Gl({filename:t,includeCode:!1}):ee({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},e[13]=t,e[14]=z):z=e[14],e[15]===Symbol.for("react.memo_cache_sentinel")?(F={icon:I.jsx(cl,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:Th},B={icon:I.jsx($c,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:Ah},e[15]=F,e[16]=B):(F=e[15],B=e[16]),e[17]===Symbol.for("react.memo_cache_sentinel")?($=I.jsx($l,{size:14,strokeWidth:1.5}),e[17]=$):$=e[17];const W="present"!==i.mode;let G,q,Y;e[18]!==i.mode?(G="present"===i.mode?void 0:I.jsxs("span",{children:["Only available in app view. ",I.jsx("br",{}),"Toggle with: ",Bt("global.hideCode",!1)]}),e[18]=i.mode,e[19]=G):G=e[19],e[20]!==W||e[21]!==G?(q={divider:!0,icon:$,label:"Download as PNG",disabled:W,tooltip:G,handle:Ih},e[20]=W,e[21]=G,e[22]=q):q=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=I.jsx(Gt,{size:14,strokeWidth:1.5}),e[23]=Y):Y=e[23];const X="present"!==i.mode;let J,K,Z,Q,te,ne,re,oe,le,ce,ue,he,fe,pe,me,ye;e[24]!==i.mode?(J="present"===i.mode?void 0:I.jsxs("span",{children:["Only available in app view. ",I.jsx("br",{}),"Toggle with: ",Bt("global.hideCode",!1)]}),e[24]=i.mode,e[25]=J):J=e[25],e[26]!==X||e[27]!==J?(K={icon:Y,label:"Download as PDF",disabled:X,tooltip:J,handle:jh},e[26]=X,e[27]=J,e[28]=K):K=e[28],e[29]!==q||e[30]!==K||e[31]!==P||e[32]!==z?(Z={icon:O,label:"Download",handle:mh,dropdown:[P,z,F,B,q,K]},e[29]=q,e[30]=K,e[31]=P,e[32]=z,e[33]=Z):Z=e[33],e[34]===Symbol.for("react.memo_cache_sentinel")?(Q=I.jsx(md,{size:14,strokeWidth:1.5}),e[34]=Q):Q=e[34],e[35]!==o||e[36]!==s?(te=Wu.flatMap((e=>{const{type:t,Icon:n,hidden:r}=e;return r?[]:{label:N(t),rightElement:C(s===t),icon:I.jsx(n,{size:14,strokeWidth:1.5}),handle:()=>o(t)}})),e[35]=o,e[36]=s,e[37]=te):te=e[37],e[38]!==te?(ne={divider:!0,icon:Q,label:"Helper panel",handle:mh,dropdown:te},e[38]=te,e[39]=ne):ne=e[39],e[40]===Symbol.for("react.memo_cache_sentinel")?(re=I.jsx(xd,{size:14,strokeWidth:1.5}),e[40]=re):re=e[40],e[41]!==i.mode?(oe="present"===i.mode?I.jsx(Ut,{size:14,strokeWidth:1.5}):I.jsx(od,{size:14,strokeWidth:1.5}),e[41]=i.mode,e[42]=oe):oe=e[42],e[43]!==S?(le=()=>{S()},e[43]=S,e[44]=le):le=e[44],e[45]!==oe||e[46]!==le?(ce={icon:oe,label:"Toggle app view",hotkey:"global.hideCode",handle:le},e[45]=oe,e[46]=le,e[47]=ce):ce=e[47],e[48]!==w||e[49]!==k||e[50]!==S||e[51]!==i.mode?(ue=Ul.map(((e,t)=>{const n=eu(e);return{divider:0===t,label:tu(e),icon:I.jsx(n,{size:14,strokeWidth:1.5}),rightElement:I.jsx("div",{className:"w-8 flex justify-end",children:w===e&&I.jsx($t,{size:14})}),handle:()=>{k(e),"edit"===i.mode&&S()}}})),e[48]=w,e[49]=k,e[50]=S,e[51]=i.mode,e[52]=ue):ue=e[52],e[53]!==ce||e[54]!==ue?(he={icon:re,label:"Present as",handle:mh,dropdown:[ce,...ue]},e[53]=ce,e[54]=ue,e[55]=he):he=e[55],e[56]===Symbol.for("react.memo_cache_sentinel")?(fe=I.jsx(Jc,{size:14,strokeWidth:1.5}),e[56]=fe):fe=e[56],e[57]!==t?(pe=!t||_(),e[57]=t,e[58]=pe):pe=e[58],e[59]!==p||e[60]!==pe?(me={icon:fe,label:"Create notebook copy",hidden:pe,handle:p},e[59]=p,e[60]=pe,e[61]=me):me=e[61],e[62]===Symbol.for("react.memo_cache_sentinel")?(ye=I.jsx(Fc,{size:14,strokeWidth:1.5}),e[62]=ye):ye=e[62];const xe=!t;let we,ke;e[63]!==xe?(we={icon:ye,label:"Copy code to clipboard",hidden:xe,handle:Nh},e[63]=xe,e[64]=we):we=e[64],e[65]===Symbol.for("react.memo_cache_sentinel")?(ke=I.jsx($d,{size:14,strokeWidth:1.5}),e[65]=ke):ke=e[65];const Se=!b||a;let Ce,Ee,Ne;e[66]!==c?(Ce=async()=>{const e=H(),t=qt(e),n=Be.fromEntries(t.map(Eh));await _e({configs:n});for(const r of t)c({cellId:r,config:{disabled:!1}})},e[66]=c,e[67]=Ce):Ce=e[67],e[68]!==Se||e[69]!==Ce?(Ee={icon:ke,label:"Enable all cells",hidden:Se,handle:Ce},e[68]=Se,e[69]=Ce,e[70]=Ee):Ee=e[70],e[71]===Symbol.for("react.memo_cache_sentinel")?(Ne=I.jsx(Ud,{size:14,strokeWidth:1.5}),e[71]=Ne):Ne=e[71];const je=!x||a;let Ie,Ae,Te,Me,De,Oe,Re,Pe,Le;e[72]!==c?(Ie=async()=>{const e=H(),t=V(e),n=Be.fromEntries(t.map(Ch));await _e({configs:n});for(const r of t)c({cellId:r,config:{disabled:!0}})},e[72]=c,e[73]=Ie):Ie=e[73],e[74]!==je||e[75]!==Ie?(Ae={icon:Ne,label:"Disable all cells",hidden:je,handle:Ie},e[74]=je,e[75]=Ie,e[76]=Ae):Ae=e[76],e[77]===Symbol.for("react.memo_cache_sentinel")?(Te=I.jsx(ge,{size:14,strokeWidth:1.5}),e[77]=Te):Te=e[77],e[78]!==l?(Me={icon:Te,label:"Hide all markdown code",handle:l},e[78]=l,e[79]=Me):Me=e[79],e[80]===Symbol.for("react.memo_cache_sentinel")?(De=I.jsx(be,{size:14,strokeWidth:1.5}),e[80]=De):De=e[80],e[81]!==u?(Oe={icon:De,label:"Clear all outputs",handle:()=>{u()}},e[81]=u,e[82]=Oe):Oe=e[82],e[83]===Symbol.for("react.memo_cache_sentinel")?(Re=I.jsx(qc,{size:14,strokeWidth:1.5}),e[83]=Re):Re=e[83],e[84]!==f?(Pe={icon:Re,label:"Re-run all cells",hotkey:"global.runAll",handle:async()=>{f()}},e[84]=f,e[85]=Pe):Pe=e[85],e[86]===Symbol.for("react.memo_cache_sentinel")?(Le=I.jsx(Ld,{size:14,strokeWidth:1.5}),e[86]=Le):Le=e[86];const Fe=!v||a;let Ue,$e,He,Ve,We,Ge,qe,Ye,Xe,Je,Ke,Ze,Qe,et,tt,nt,rt,ot;e[87]!==d?(Ue=()=>{d()},e[87]=d,e[88]=Ue):Ue=e[88],e[89]!==Fe||e[90]!==Ue?($e={icon:Le,label:"Undo cell deletion",hidden:Fe,handle:Ue},e[89]=Fe,e[90]=Ue,e[91]=$e):$e=e[91],e[92]===Symbol.for("react.memo_cache_sentinel")?(He=I.jsx(ve,{size:14,strokeWidth:1.5}),e[92]=He):He=e[92],e[93]!==r||e[94]!==n?(Ve={icon:He,label:"Add database connection",handle:()=>{n(I.jsx(hh,{onClose:r}))}},e[93]=r,e[94]=n,e[95]=Ve):Ve=e[95],e[96]===Symbol.for("react.memo_cache_sentinel")?(We=I.jsx(Hc,{size:14,strokeWidth:1.5}),e[96]=We):We=e[96],e[97]!==m?(Ge={divider:!0,icon:We,label:"Command palette",hotkey:"global.commandPalette",handle:()=>m(Sh)},e[97]=m,e[98]=Ge):Ge=e[98],e[99]===Symbol.for("react.memo_cache_sentinel")?(qe=I.jsx(Yt,{size:14,strokeWidth:1.5}),e[99]=qe):qe=e[99],e[100]!==g?(Ye={icon:qe,label:"User settings",handle:()=>g(kh)},e[100]=g,e[101]=Ye):Ye=e[101],e[102]===Symbol.for("react.memo_cache_sentinel")?(Xe=I.jsx(rd,{size:14,strokeWidth:1.5}),e[102]=Xe):Xe=e[102],e[103]!==y?(Je={icon:Xe,label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>y(wh)},e[103]=y,e[104]=Je):Je=e[104],e[105]===Symbol.for("react.memo_cache_sentinel")?(Ke={icon:I.jsx(Mc,{size:14,strokeWidth:1.5}),label:"Open documentation",handle:vh},e[105]=Ke):Ke=e[105],e[106]===Symbol.for("react.memo_cache_sentinel")?(Ze=I.jsx(nd,{size:14,strokeWidth:1.5}),e[106]=Ze):Ze=e[106],e[107]===Symbol.for("react.memo_cache_sentinel")?(Qe={divider:!0,icon:Ze,label:"Return home",hidden:!location.search.includes("file"),handle:xh},et=I.jsx(Xc,{size:14,strokeWidth:1.5}),e[107]=Qe,e[108]=et):(Qe=e[107],et=e[108]),e[109]===Symbol.for("react.memo_cache_sentinel")?(tt={icon:et,label:"New notebook",hidden:!location.search.includes("file"),handle:bh},nt=I.jsx(Dd,{size:14,strokeWidth:1.5}),e[109]=tt,e[110]=nt):(tt=e[109],nt=e[110]),e[111]!==h?(rt={icon:nt,label:"Restart kernel",variant:"danger",handle:h},e[111]=h,e[112]=rt):rt=e[112],e[113]!==Z||e[114]!==ne||e[115]!==he||e[116]!==me||e[117]!==we||e[118]!==Ee||e[119]!==D||e[120]!==Ae||e[121]!==Me||e[122]!==Oe||e[123]!==Pe||e[124]!==$e||e[125]!==Ve||e[126]!==Ge||e[127]!==Ye||e[128]!==Je||e[129]!==rt?(ot=[D,Z,ne,he,me,we,Ee,Ae,Me,Oe,Pe,$e,Ve,Ge,Ye,Je,Ke,Qe,tt,rt],e[113]=Z,e[114]=ne,e[115]=he,e[116]=me,e[117]=we,e[118]=Ee,e[119]=D,e[120]=Ae,e[121]=Me,e[122]=Oe,e[123]=Pe,e[124]=$e,e[125]=Ve,e[126]=Ge,e[127]=Ye,e[128]=Je,e[129]=rt,e[130]=ot):ot=e[130];const st=ot;let it;return e[131]!==st?(it=st.filter(yh),e[131]=st,e[132]=it):it=e[132],it}function yh(e){return!e.hidden}function bh(){const e=Ht();window.open(e,"_blank")}function xh(){const e=document.baseURI.split("?")[0];window.open(e,"_self")}function vh(){window.open("https://docs.marimo.io","_blank")}function wh(e){return!e}function kh(e){return!e}function Sh(e){return!e}function Ch(e){return[e,{disabled:!0}]}function Eh(e){return[e,{disabled:!1}]}async function Nh(){const e=await Xt();await nt(e.contents),ee({title:"Copied",description:"Code copied to clipboard."})}async function jh(){const e=new Event("export-beforeprint"),t=new Event("export-afterprint");window.dispatchEvent(e),setTimeout(_h,0),setTimeout((()=>window.dispatchEvent(t)),0)}function _h(){return window.print()}async function Ih(){const e=document.getElementById("App");e&&await F(e,document.title)}async function Ah(){const e=await Xt();Jt(new Blob([e.contents],{type:"text/plain"}),Kt.toPY(document.title))}async function Th(){const e=await Zt({download:!1});Jt(new Blob([e],{type:"text/plain"}),Kt.toMarkdown(document.title))}async function Mh(){const e=await Xt(),t=Qt({code:e.contents});await nt(t),ee({title:"Copied",description:"Link copied to clipboard."})}function Dh(e){return I.jsx("div",{className:"w-8 flex justify-end",children:e&&I.jsx($t,{size:14})})}const Oh=()=>{const e=j.c(10),t=gh();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=I.jsx(gl,{"aria-label":"Config",shape:"circle",size:"small",className:"h-[27px] w-[27px]","data-testid":"notebook-menu-dropdown",color:"hint-green",children:I.jsx(ql,{strokeWidth:1.8})}),e[0]=n):n=e[0];const r=n,o=Rh;let s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s=e=>{const t=I.jsx(tn,{variant:e.variant,disabled:e.disabled,onSelect:t=>e.handle(t),"data-testid":`notebook-menu-dropdown-${e.label}`,children:o(e)},e.label);return e.tooltip?I.jsx(it,{content:e.tooltip,side:"left",delayDuration:100,children:I.jsx("span",{children:t})},e.label):t},e[1]=s):s=e[1];const i=s;let a,l,c,d,h;if(e[2]===Symbol.for("react.memo_cache_sentinel")?(a=I.jsx(nn,{asChild:!0,children:r}),e[2]=a):a=e[2],e[3]!==t){let n;e[5]===Symbol.for("react.memo_cache_sentinel")?(n=e=>e.hidden?null:e.dropdown?I.jsxs(rn,{children:[I.jsx(on,{"data-testid":`notebook-menu-dropdown-${e.label}`,children:o(e)}),I.jsx(sn,{children:I.jsx(an,{children:e.dropdown.map((e=>I.jsxs(u.Fragment,{children:[e.divider&&I.jsx(ln,{}),i(e)]},e.label)))})})]},e.label):I.jsxs(u.Fragment,{children:[e.divider&&I.jsx(ln,{}),i(e)]},e.label),e[5]=n):n=e[5],l=t.map(n),e[3]=t,e[4]=l}else l=e[4];return e[6]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx(ln,{}),e[6]=c):c=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(d=I.jsx("div",{className:"flex-1 px-2 text-xs text-muted-foreground",children:I.jsxs("span",{children:["Version: ",en()]})}),e[7]=d):d=e[7],e[8]!==l?(h=I.jsxs(cn,{modal:!1,children:[a,I.jsxs(dn,{align:"end",className:"no-print w-[240px]",children:[l,c,d]})]}),e[8]=l,e[9]=h):h=e[9],h};function Rh(e){return I.jsxs(I.Fragment,{children:[e.icon&&I.jsx("span",{className:"flex-0 mr-2",children:e.icon}),I.jsx("span",{className:"flex-1",children:e.labelElement||e.label}),e.hotkey&&I.jsx(un,{shortcut:e.hotkey,className:"ml-4"}),e.rightElement]})}const Ph=hn({findText:"",replaceText:"",caseSensitive:!1,wholeWord:!1,regexp:!1,isOpen:!1,currentView:void 0},((e,t)=>{if(void 0===t)return e;switch(t.type){case"setFind":return{...e,findText:t.find};case"setReplace":return{...e,replaceText:t.replace};case"setCaseSensitive":return{...e,caseSensitive:t.caseSensitive};case"setWholeWord":return{...e,wholeWord:t.wholeWord};case"setRegex":return{...e,regexp:t.regexp};case"setIsOpen":return{...e,isOpen:t.isOpen};case"setCurrentView":return{...e,currentView:{view:t.view,range:t.range}};case"clearCurrentView":return{...e,currentView:void 0}}}));function Lh(e){if([...document.querySelectorAll('[role="dialog"][data-state="open"]')].some((e=>e instanceof HTMLElement&&e.childNodes.length>0)))return!1;if(e){const t=e.state.selection.main,n=e.state.sliceDoc(t.from,t.to);n?(K.set(Ph,{type:"setFind",find:n}),K.set(Ph,{type:"setCurrentView",view:e,range:{from:t.from,to:t.to}})):K.set(Ph,{type:"setCurrentView",view:e,range:{from:0,to:0}})}return K.get(Ph).isOpen?(K.set(Ph,{type:"setIsOpen",isOpen:!1}),requestAnimationFrame((()=>{K.set(Ph,{type:"setIsOpen",isOpen:!0})})),!0):(K.set(Ph,{type:"setIsOpen",isOpen:!0}),!0)}function zh(){return!!K.get(Ph).isOpen&&(K.set(Ph,{type:"setIsOpen",isOpen:!1}),!0)}function Fh(e){return fn("create"in e,'Expected query to have a "create" method'),e}function Bh(e){return()=>{const t=K.get(Ph),n=new pn({search:t.findText,caseSensitive:t.caseSensitive,regexp:t.regexp,replace:t.replaceText,wholeWord:t.wholeWord});return!!n.valid&&e({query:Fh(n).create(),search:n})}}const Uh=e=>Bh((({query:t})=>{const n=mn(),r=K.get(Ph).currentView||{view:n[0],range:{from:0,to:0}};let o=r.range.to;"prev"===e&&(n.reverse(),o=r.range.from);let s=n.indexOf(r.view);s<0&&(s=0);const i=[...n,...n].slice(s);for(const a of i){const n="next"===e?t.nextMatch(a.state,0,o??0):t.prevMatch(a.state,o??a.state.doc.length,a.state.doc.length);if(!n){o=null,a.dispatch({selection:gn.single(0)});continue}const r=gn.single(n.from,n.to);return a.dispatch({selection:r,effects:[yn.scrollIntoView(r.main,{y:"center"})],userEvent:"select.search"}),K.set(Ph,{type:"setCurrentView",view:a,range:{from:n.from,to:n.to}}),n}return!1})),$h=Uh("next"),Hh=Uh("prev"),Vh=Bh((({query:e})=>{var t;const n=mn(),r=[];for(const o of n){if(o.state.readOnly)continue;const n=null==(t=e.matchAll(o.state,1e9))?void 0:t.map((t=>{const{from:n,to:r}=t;return{from:n,to:r,insert:e.getReplacement(t)}}));if(!n||0===n.length)continue;const s=o.state.doc.toString();r.push((()=>{o.dispatch({changes:[{from:0,to:o.state.doc.length,insert:s}],userEvent:"input.replace.all"})})),o.dispatch({changes:n,userEvent:"input.replace.all"})}return()=>{for(const e of r)e()}})),Wh=Bh((({query:e})=>{const t=mn(),n=K.get(Ph).currentView||{view:t[0],range:{from:0,to:0}};let r=n.range.from,o=t.indexOf(n.view);o<0&&(o=0);const s=[...t,...t].slice(o);for(const i of s){const t=e.nextMatch(i.state,0,r??0);if(!t){r=null,i.dispatch({selection:gn.single(0)});continue}const n=i.state.toText(e.getReplacement(t));return i.dispatch({changes:[{from:t.from,to:t.to,insert:n}],userEvent:"input.replace"}),$h()}return!1})),Gh=Bh((({query:e})=>{const t=mn();let n=0;const r=new Map;for(const o of t){const t=e.matchAll(o.state,1e9)||[];for(const e of t){const{from:t,to:s}=e,i=r.get(o)||new Map;i.set(`${t}:${s}`,n++),r.set(o,i)}}return{count:n,position:r}})),qh=bn.define();function Yh(){const e=mn();for(const t of e)t.state.readOnly||t.dispatch({effects:qh.of(new pn({search:""}))})}const Xh=xn.define({create(){const e=K.get(Ph);return Fh(new pn({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord})).create()},update(e,t){for(const n of t.effects)n.is(qh)&&(e=Fh(n.value).create());return e}}),Jh=vn.mark({class:"cm-searchMatch"}),Kh=vn.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Zh=wn.fromClass(class{constructor(e){this.view=e,this.decorations=void 0,this.decorations=this.highlight(e.state.field(Xh))}update(e){const t=e.state.field(Xh);(t!==e.startState.field(Xh)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight(e){if(!e.spec.valid)return vn.none;const{view:t}=this,n=new kn,r=t.visibleRanges,o=r.length;for(let s=0;s<o;s++){let{to:i}=r[s];const{from:a}=r[s];for(;s<o-1&&i>r[s+1].from-500;)i=r[++s].to;e.highlight(t.state,a,i,((e,r)=>{const o=t.state.selection.ranges.some((t=>t.from===e&&t.to===r));n.add(e,r,o?Kh:Jh)}))}return n.finish()}},{decorations:e=>e.decorations}),Qh=yn.baseTheme({"&light .cm-searchMatch":{backgroundColor:"#99ff7780"},"&dark .cm-searchMatch":{backgroundColor:"#22bb0070"},"&light .cm-searchMatch-selected":{backgroundColor:"transparent"},"&dark .cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff88 !important"}}),ef=()=>{var e;const t=j.c(102),[n,r]=o.useState(!1),[s,i]=ze(Ph),[a,l]=o.useState(),c=o.useRef(null),d=se(Fe);let u,h;t[0]!==n||t[1]!==s.isOpen?(u=()=>(!n||!s.isOpen)&&Lh(),t[0]=n,t[1]=s.isOpen,t[2]=u):u=t[2],yl("cell.findAndReplace",u),t[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{const e=Gh();l(!1===e?void 0:e)},t[3]=h):h=t[3];const f=h;let p,m,g,y;if(t[4]!==s.isOpen?(p=()=>{s.isOpen&&c.current&&(c.current.focus(),c.current.select())},m=[s.isOpen],t[4]=s.isOpen,t[5]=p,t[6]=m):(p=t[5],m=t[6]),o.useEffect(p,m),t[7]!==s.findText||t[8]!==s.isOpen?(g=()=>{if(s.isOpen){if(""===s.findText)return l(void 0),void Yh();f(),function(){const e=K.get(Ph),t=mn();for(const n of t)n.state.readOnly||n.dispatch({effects:qh.of(new pn({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord}))})}()}else Yh()},t[7]=s.findText,t[8]=s.isOpen,t[9]=g):g=t[9],t[10]!==s.caseSensitive||t[11]!==s.findText||t[12]!==s.isOpen||t[13]!==s.regexp||t[14]!==s.wholeWord?(y=[s.findText,s.isOpen,s.caseSensitive,s.regexp,s.wholeWord],t[10]=s.caseSensitive,t[11]=s.findText,t[12]=s.isOpen,t[13]=s.regexp,t[14]=s.wholeWord,t[15]=y):y=t[15],o.useEffect(g,y),!s.isOpen)return null;const b=s.currentView;let x;t[16]!==a||t[17]!==b?(x=b&&a?null==(e=a.position.get(b.view))?void 0:e.get(`${b.range.from}:${b.range.to}`):void 0,t[16]=a,t[17]=b,t[18]=x):x=t[18];const v=x;let w,k,S,C,E,N,_,A,T,M,D;t[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>r(!0),t[19]=w):w=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(k=()=>r(!1),t[20]=k):k=t[20],t[21]!==i?(S=e=>{"Escape"===e.key&&i({type:"setIsOpen",isOpen:!1})},t[21]=i,t[22]=S):S=t[22],t[23]!==i?(C=()=>i({type:"setIsOpen",isOpen:!1}),t[23]=i,t[24]=C):C=t[24],t[25]===Symbol.for("react.memo_cache_sentinel")?(E=I.jsx(Cn,{className:"w-4 h-4"}),t[25]=E):E=t[25],t[26]!==C?(N=I.jsx("div",{className:"absolute top-0 right-0",children:I.jsx(X,{"data-testid":"close-find-replace-button",onClick:C,size:"xs",variant:"text",children:E})}),t[26]=C,t[27]=N):N=t[27],t[28]!==i?(_=e=>{i({type:"setFind",find:e.target.value})},t[28]=i,t[29]=_):_=t[29],t[30]!==s.findText||t[31]!==_?(A=I.jsx(tt,{ref:c,"data-testid":"find-input",value:s.findText,autoFocus:!0,className:"mr-2 mb-0",placeholder:"Find",onKeyDown:nf,onChange:_}),t[30]=s.findText,t[31]=_,t[32]=A):A=t[32],t[33]!==i?(T=e=>{i({type:"setReplace",replace:e.target.value})},t[33]=i,t[34]=T):T=t[34],t[35]!==s.replaceText||t[36]!==T?(M=I.jsx(tt,{"data-testid":"replace-input",value:s.replaceText,placeholder:"Replace",onChange:T}),t[35]=s.replaceText,t[36]=T,t[37]=M):M=t[37],t[38]!==A||t[39]!==M?(D=I.jsxs("div",{className:"flex flex-col flex-2 gap-2 w-[55%]",children:[A,M]}),t[38]=A,t[39]=M,t[40]=D):D=t[40];const O=s.caseSensitive?"on":"off";let R,P,L;t[41]!==i?(R=e=>i({type:"setCaseSensitive",caseSensitive:e}),t[41]=i,t[42]=R):R=t[42],t[43]===Symbol.for("react.memo_cache_sentinel")?(P=I.jsx(En,{className:"w-4 h-4"}),t[43]=P):P=t[43],t[44]!==s.caseSensitive||t[45]!==O||t[46]!==R?(L=I.jsx(it,{content:"Case Sensitive",children:I.jsx(Sn,{size:"sm",pressed:s.caseSensitive,"data-state":O,onPressedChange:R,children:P})}),t[44]=s.caseSensitive,t[45]=O,t[46]=R,t[47]=L):L=t[47];const z=s.wholeWord?"on":"off";let F,B,U;t[48]!==i?(F=e=>i({type:"setWholeWord",wholeWord:e}),t[48]=i,t[49]=F):F=t[49],t[50]===Symbol.for("react.memo_cache_sentinel")?(B=I.jsx(Fd,{className:"w-4 h-4"}),t[50]=B):B=t[50],t[51]!==s.wholeWord||t[52]!==z||t[53]!==F?(U=I.jsx(it,{content:"Match Whole Word",children:I.jsx(Sn,{size:"sm",pressed:s.wholeWord,"data-state":z,onPressedChange:F,children:B})}),t[51]=s.wholeWord,t[52]=z,t[53]=F,t[54]=U):U=t[54];const $=s.regexp?"on":"off";let H,V,W,G,q;t[55]!==i?(H=e=>i({type:"setRegex",regexp:e}),t[55]=i,t[56]=H):H=t[56],t[57]===Symbol.for("react.memo_cache_sentinel")?(V=I.jsx(vd,{className:"w-4 h-4"}),t[57]=V):V=t[57],t[58]!==s.regexp||t[59]!==$||t[60]!==H?(W=I.jsx(it,{content:"Use Regular Expression",children:I.jsx(Sn,{size:"sm",pressed:s.regexp,"data-state":$,onPressedChange:H,children:V})}),t[58]=s.regexp,t[59]=$,t[60]=H,t[61]=W):W=t[61],t[62]!==L||t[63]!==U||t[64]!==W?(G=I.jsxs("div",{className:"flex items-center gap-[2px]",children:[L,U,W]}),t[62]=L,t[63]=U,t[64]=W,t[65]=G):G=t[65],t[66]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{Wh()&&f()},t[66]=q):q=t[66];const Y=""===s.findText;let J,Z;t[67]!==Y?(J=I.jsx(X,{"data-testid":"replace-next-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:q,disabled:Y,children:"Replace Next"}),t[67]=Y,t[68]=J):J=t[68],t[69]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>{const e=Vh();if(!e)return;f();const{dismiss:t}=ee({title:"Replaced all occurrences",action:I.jsx(pu,{"data-testid":"undo-replace-all-button",onClick:()=>{e(),n()}})}),n=t},t[69]=Z):Z=t[69];const Q=""===s.findText;let te,ne,re,oe,ie,ae,le,ce,de,ue,he,fe;return t[70]!==Q?(te=I.jsx(X,{"data-testid":"replace-all-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:Z,disabled:Q,children:"Replace All"}),t[70]=Q,t[71]=te):te=t[71],t[72]!==J||t[73]!==te?(ne=I.jsxs("div",{className:"flex items-center gap-[2px]",children:[J,te]}),t[72]=J,t[73]=te,t[74]=ne):ne=t[74],t[75]!==G||t[76]!==ne?(re=I.jsxs("div",{className:"flex flex-col gap-2",children:[G,ne]}),t[75]=G,t[76]=ne,t[77]=re):re=t[77],t[78]!==D||t[79]!==re?(oe=I.jsxs("div",{className:"flex items-center gap-3",children:[D,re]}),t[78]=D,t[79]=re,t[80]=oe):oe=t[80],t[81]===Symbol.for("react.memo_cache_sentinel")?(ie=I.jsx(it,{content:"Find Previous",children:I.jsx(X,{"data-testid":"find-prev-button",size:"xs",variant:"secondary",onClick:rf,children:I.jsx(Nc,{className:"w-4 h-4"})})}),t[81]=ie):ie=t[81],t[82]===Symbol.for("react.memo_cache_sentinel")?(ae=I.jsx(it,{content:"Find Next",children:I.jsx(X,{"data-testid":"find-next-button",size:"xs",variant:"secondary",onClick:of,children:I.jsx(Ic,{className:"w-4 h-4"})})}),t[82]=ae):ae=t[82],t[83]!==v||t[84]!==a?(le=null!=a&&null==v&&I.jsxs("span",{className:"text-sm",children:[a.count," matches"]}),t[83]=v,t[84]=a,t[85]=le):le=t[85],t[86]!==v||t[87]!==a?(ce=null!=a&&null!=v&&I.jsxs("span",{className:"text-sm",children:[v+1," of ",a.count]}),t[86]=v,t[87]=a,t[88]=ce):ce=t[88],t[89]!==le||t[90]!==ce?(de=I.jsxs("div",{className:"flex items-center gap-2",children:[ie,ae,le,ce]}),t[89]=le,t[90]=ce,t[91]=de):de=t[91],t[92]!==d?(ue=d.getHotkey("cell.findAndReplace"),t[92]=d,t[93]=ue):ue=t[93],t[94]!==ue.key?(he=I.jsxs("div",{className:"text-xs text-muted-foreground flex gap-1 mt-2",children:["Press"," ",I.jsx(qe,{shortcut:ue.key})," ","again to open the native browser search."]}),t[94]=ue.key,t[95]=he):he=t[95],t[96]!==N||t[97]!==oe||t[98]!==de||t[99]!==he||t[100]!==S?(fe=I.jsx(Nn,{restoreFocus:!0,autoFocus:!0,children:I.jsxs("div",{onFocus:w,onClick:tf,onBlur:k,className:"fixed top-0 right-0 w-[500px] flex flex-col bg-[var(--sage-1)] p-4 z-50 mt-2 mr-3 rounded-md shadow-lg border gap-2 print:hidden",onKeyDown:S,children:[N,oe,de,he]})}),t[96]=N,t[97]=oe,t[98]=de,t[99]=he,t[100]=S,t[101]=fe):fe=t[101],fe};function tf(e){e.stopPropagation(),e.preventDefault()}function nf(e){"Enter"===e.key&&(e.shiftKey?Hh():$h())}function rf(){return Hh()}function of(){return $h()}function sf(e){const t=j.c(3),[n,r]=o.useState(!1);let s,i;return t[0]!==e?(s=()=>{if(!e)return;r(!1);const t=setTimeout((()=>{r(!0)}),200);return()=>clearTimeout(t)},i=[e],t[0]=e,t[1]=s,t[2]=i):(s=t[1],i=t[2]),o.useEffect(s,i),e&&n}const af=()=>{const e=j.c(6),t=ae(Iu);let n;e[0]!==t?(n=()=>t(lf),e[0]=t,e[1]=n):n=e[1];const r=n;let o,s,i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=Bt("global.commandPalette"),e[2]=o):o=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(s=I.jsx(Hc,{strokeWidth:1.5,size:18}),e[3]=s):s=e[3],e[4]!==r?(i=I.jsx(it,{content:o,children:I.jsx(gl,{"data-testid":"command-palette-button",onClick:r,shape:"rectangle",color:"hint-green",children:s})}),e[4]=r,e[5]=i):i=e[5],i};function lf(e){return!e}const cf=e=>{const{children:t}=e;return se(de)?null:t},df=e=>{const{children:t}=e;return se(de)?t:null},uf=e=>{const t=j.c(38),{resetOnBlur:n,placeholderText:r,initialValue:s,flexibleWidth:i,onNameChange:a,className:l}=e,c=void 0!==n&&n,d=void 0===s?null:s,u=void 0!==i&&i,[h,f]=o.useState(d);let p;t[0]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[0]=p):p=t[0];const[m,g]=o.useState(p),[y,b]=o.useState(!1),x=o.useRef(null),v=o.useRef(!1);let w,k,S;t[1]!==d?(w=()=>{f(d)},k=[d],t[1]=d,t[2]=w,t[3]=k):(w=t[2],k=t[3]),o.useEffect(w,k),t[4]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{b(!0)},t[4]=S):S=t[4];const C=S;let E;t[5]!==d||t[6]!==c?(E=e=>{var t;(null==(t=e.relatedTarget)?void 0:t.closest(".filename-input"))||(b(!1),c&&f(d))},t[5]=d,t[6]=c,t[7]=E):E=t[7];const N=E;let _;t[8]!==h?(_=kt.dirname(h||""),t[8]=h,t[9]=_):_=t[9];const A=_,T=kt.basename(h||""),M=m.filter((e=>kt.basename(e.path).startsWith(T)));let D,O;t[10]!==A||t[11]!==y?(D=async()=>{if(!y)return void g([]);const e=await An({path:A});g(e.files)},O=[A,y],t[10]=A,t[11]=y,t[12]=D,t[13]=O):(D=t[12],O=t[13]);const{loading:R}=jn(D,O),P=function(e,t,n){if(!e)return;if(e.endsWith("/"))return;(Kd("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(kt.extension(e))||(e=e.endsWith(".")?`${e}py`:e.endsWith(".p")?`${e}y`:`${e}.py`);if(t.some((t=>t.path===e||kt.basename(t.path)===e)))return;if(n&&(n===e||kt.basename(n)===e))return;return e}(h,m,d),L=(P||M.length>0)&&I.jsxs(Je,{className:"font-mono",children:[!R&&I.jsx(Ke,{children:"No files"}),P&&I.jsxs(We,{variant:"success",className:"py-2 px-3",onSelect:()=>{var e;P&&(v.current=!0,a(P),null==(e=x.current)||e.blur())},children:[I.jsx(Yc,{className:"w-4 h-4 mr-2"})," ",I.jsxs("span",{className:"text-sm",children:[d?"Rename to: ":"Save as: ",I.jsx("span",{className:"font-medium text-sm",children:kt.basename(P)})]})]},"_rename_"),M.map((e=>{const t=e.isDirectory?"directory":_n(e.path),n=Tn[t];return I.jsxs(We,{variant:e.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{e.isDirectory?f(`${e.path}/`):f(e.path)},children:[I.jsx(n,{className:"w-4 h-4 mr-2"})," ",kt.basename(e.path)]},e.path)}))]}),z=10*Math.max(20,(null==h?void 0:h.length)||(null==r?void 0:r.length)||0),F=y?h||"":d||"";let B,U,$;t[14]!==u||t[15]!==z?(B=u?{maxWidth:z}:void 0,t[14]=u,t[15]=z,t[16]=B):B=t[16],t[17]!==l?(U=In(l,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60"),t[17]=l,t[18]=U):U=t[18],t[19]!==r||t[20]!==F||t[21]!==B||t[22]!==U?($=I.jsx(Mn,{children:I.jsx(Xe,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:F,onKeyDown:hf,icon:null,ref:x,onValueChange:f,placeholder:r,autoComplete:"off",style:B,className:U})}),t[19]=r,t[20]=F,t[21]=B,t[22]=U,t[23]=$):$=t[23];const H=L&&"group-focus-within:block";let V,W,G,q,Y;return t[24]!==H?(V=In("p-0 w-full min-w-80 max-w-80vw hidden",H),t[24]=H,t[25]=V):V=t[25],t[26]!==L||t[27]!==V?(W=I.jsx(Dn,{side:"bottom",className:V,portal:!1,children:L}),t[26]=L,t[27]=V,t[28]=W):W=t[28],t[29]!==$||t[30]!==W?(G=I.jsxs(Je,{children:[$,W]}),t[29]=$,t[30]=W,t[31]=G):G=t[31],t[32]!==N||t[33]!==G?(q=I.jsx(On,{onFocus:C,onBlur:N,shouldFilter:!1,id:"filename-input",className:"bg-transparent group filename-input",children:G}),t[32]=N,t[33]=G,t[34]=q):q=t[34],t[35]!==y||t[36]!==q?(Y=I.jsx(Rn,{children:I.jsx(Pn,{open:y,modal:!1,children:q})}),t[35]=y,t[36]=q,t[37]=Y):Y=t[37],Y};function hf(e){"Escape"===e.key&&e.currentTarget.blur()}function ff(e){return JSON.stringify(e)}const pf=q(void 0),mf=q((e=>{const t=e(pf);return function(e,t,n){if(!n)return!1;const{cellIds:r,cellData:o}=e,s=r.inOrderIds.map((e=>o[e])),i=s.map((e=>e.code)),a=s.map((e=>e.config)),l=s.map((e=>e.name));return!(Ln(i,n.codes)&&Ln(l,n.names)&&zn(a,n.configs)&&zn(t.selectedLayout,n.layout.selectedLayout)&&zn(t.layoutData,n.layout.layoutData))}(e(ne),e(Yl),t)}));const gf=e=>{const t=j.c(35),n=Pt(),r=()=>{Jt(new Blob([s()],{type:"text/plain"}),`${e.proposedName}.json`)};let o;t[0]!==n?(o=()=>{const e=H(),t=Fn(e);return JSON.stringify({filename:n,cells:t.map(bf)},null,2)},t[0]=n,t[1]=o):o=t[1];const s=B(o);let i,a,l,c,d,u,h,f,p,m,g,y,b,x,v,w,k;return t[2]!==r||t[3]!==e?(i=t=>{t.preventDefault(),r(),e.closeModal()},t[2]=r,t[3]=e,t[4]=i):i=t[4],t[5]!==e?(a=t=>{"Escape"===t.key&&e.closeModal()},t[5]=e,t[6]=a):a=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(l=I.jsx(Te,{className:"text-accent-foreground mb-6",children:"Download unsaved changes?"}),t[7]=l):l=t[7],t[8]===Symbol.for("react.memo_cache_sentinel")?(c={wordBreak:"break-word"},t[8]=c):c=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(d=I.jsx("p",{children:"This app has unsaved changes. To recover:"}),u={paddingBottom:"10px"},t[9]=d,t[10]=u):(d=t[9],u=t[10]),t[11]!==e.proposedName?(h=I.jsxs("li",{style:u,children:['Click the "Download" button. This will download a file called ',I.jsxs("code",{children:[e.proposedName,".json"]}),". This file contains your code."]}),t[11]=e.proposedName,t[12]=h):h=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(f={paddingBottom:"10px"},t[13]=f):f=t[13],t[14]===Symbol.for("react.memo_cache_sentinel")?(p={display:"block",padding:"10px"},t[14]=p):p=t[14],t[15]!==e.proposedName?(m=I.jsxs("code",{style:p,children:["marimo recover ",e.proposedName,".json ",">"," ",e.proposedName,".py"]}),t[15]=e.proposedName,t[16]=m):m=t[16],t[17]!==e.proposedName?(g=I.jsxs("code",{children:[e.proposedName,".py"]}),t[17]=e.proposedName,t[18]=g):g=t[18],t[19]!==m||t[20]!==g?(y=I.jsxs("li",{style:f,children:["In your terminal, type",m,"to overwrite ",g," with the recovered changes."]}),t[19]=m,t[20]=g,t[21]=y):y=t[21],t[22]!==y||t[23]!==h?(b=I.jsx(et,{className:"markdown break-words",style:c,children:I.jsxs("div",{className:"prose dark:prose-invert",children:[d,I.jsxs("ol",{children:[h,y]})]})}),t[22]=y,t[23]=h,t[24]=b):b=t[24],t[25]!==e.closeModal?(x=I.jsx(X,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:e.closeModal,children:"Cancel"}),t[25]=e.closeModal,t[26]=x):x=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(v=I.jsx(X,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"}),t[27]=v):v=t[27],t[28]!==x?(w=I.jsxs(rt,{children:[x,v]}),t[28]=x,t[29]=w):w=t[29],t[30]!==i||t[31]!==b||t[32]!==w||t[33]!==a?(k=I.jsx(Ie,{className:"w-fit",children:I.jsxs("form",{onSubmit:i,onKeyDown:a,children:[l,b,w]})}),t[30]=i,t[31]=b,t[32]=w,t[33]=a,t[34]=k):k=t[34],k},yf=e=>{const t=j.c(12),{filename:n,needsSave:r}=e,{openModal:o,closeModal:s}=ie();let i;t[0]!==n?(i=null===n?"app":n.slice(0,-3),t[0]=n,t[1]=i):i=t[1];const a=i;let l;t[2]!==s||t[3]!==r||t[4]!==o||t[5]!==a?(l=()=>{r&&o(I.jsx(gf,{proposedName:a,closeModal:s}))},t[2]=s,t[3]=r,t[4]=o,t[5]=a,t[6]=l):l=t[6];const c=l;let d;yl("global.save",c),t[7]===Symbol.for("react.memo_cache_sentinel")?(d=Bt("global.save"),t[7]=d):d=t[7];const u=r?"yellow":"gray";let h,f;return t[8]===Symbol.for("react.memo_cache_sentinel")?(h=I.jsx(Sd,{strokeWidth:1.5,size:18}),t[8]=h):h=t[8],t[9]!==c||t[10]!==u?(f=I.jsx(it,{content:d,children:I.jsx(gl,{onClick:c,id:"save-button","aria-label":"Save",className:"rectangle",color:u,children:h})}),t[9]=c,t[10]=u,t[11]=f):f=t[11],f};function bf(e){return{name:e.name,code:e.code}}const xf=5e3;async function vf(){await Un({download:!1})}async function wf(){await $n({download:!1,includeCode:!0,files:Vl.INSTANCE.filenames()})}async function kf(){await Hn({download:!1})}const Sf=e=>{const t=j.c(13),{kioskMode:n,appConfig:r}=e,s=Pt();let i;t[0]!==r||t[1]!==n?(i={appConfig:r,kioskMode:n},t[0]=r,t[1]=n,t[2]=i):i=t[2];const{saveOrNameNotebook:a,needsSave:l,closed:c}=function(e){const t=j.c(41),{kioskMode:n}=e,r=se(Vn),{updateCellCode:s}=U(),i=Wn(),[a]=ze(at),l=Pt(),{openModal:c,closeModal:d,openAlert:u}=ie(),h=ae(pf),f=Gn(),p=se(mf),m=Fl();let g;t[0]!==r||t[1]!==a.state||t[2]!==n||t[3]!==m||t[4]!==i||t[5]!==u||t[6]!==h||t[7]!==s?(g=(e,t)=>{const o=Fn(i),l=o.map(_f),c=o.map(jf),d=o.map(Nf),f=qn(i);n||0!==c.length&&(a.state===ct.OPEN?(w.log("saving to ",e),Yn({cellIds:l,codes:c,names:d,filename:e,configs:f,layout:Xl(),persist:!0}).then((()=>{t&&r.format_on_save&&Xn(s),h({names:d,codes:c,configs:f,layout:m})}))):u("Failed to save notebook: not connected to a kernel."))},t[0]=r,t[1]=a.state,t[2]=n,t[3]=m,t[4]=i,t[5]=u,t[6]=h,t[7]=s,t[8]=g):g=t[8];const y=B(g);let b;t[9]!==a.state||t[10]!==l||t[11]!==y?(b=e=>{const t=void 0!==e&&e;null!==l&&a.state===ct.OPEN&&y(l,t)},t[9]=a.state,t[10]=l,t[11]=y,t[12]=b):b=t[12];const x=B(b);let v;t[13]!==y||t[14]!==f?(v=e=>{f(e).then((e=>{null!==e&&y(e,!0)}))},t[13]=y,t[14]=f,t[15]=v):v=t[15];const k=v;let S;t[16]!==d||t[17]!==a.state||t[18]!==l||t[19]!==k||t[20]!==c||t[21]!==x?(S=()=>{x(!0),null===l&&a.state!==ct.CLOSED&&c(I.jsx(If,{onClose:d,onSave:k}))},t[16]=d,t[17]=a.state,t[18]=l,t[19]=k,t[20]=c,t[21]=x,t[22]=S):S=t[22];const C=B(S);let E,N;if(t[23]!==i){const e=Fn(i);E=e.map(Ef),N=e.map(Cf),t[23]=i,t[24]=E,t[25]=N}else E=t[24],N=t[25];const _=N;let A;t[26]!==i?(A=qn(i),t[26]=i,t[27]=A):A=t[27];const T=A;let M;t[28]!==r||t[29]!==_||t[30]!==E||t[31]!==T||t[32]!==a||t[33]!==n||t[34]!==p||t[35]!==x?(M={onSave:x,needsSave:p,codes:E,cellConfigs:T,cellNames:_,connStatus:a,config:r,kioskMode:n},t[28]=r,t[29]=_,t[30]=E,t[31]=T,t[32]=a,t[33]=n,t[34]=p,t[35]=x,t[36]=M):M=t[36];!function(e){const t=j.c(21),{codes:n,cellConfigs:r,config:s,connStatus:i,cellNames:a,needsSave:l,kioskMode:c,onSave:d}=e,u=o.useRef(null);let h;t[0]!==n?(h=n.join(":"),t[0]=n,t[1]=h):h=t[1];const f=h;let p;t[2]!==r?(p=r.map(ff).join(":"),t[2]=r,t[3]=p):p=t[3];const m=p;let g;t[4]!==a?(g=a.join(":"),t[4]=a,t[5]=g):g=t[5];const y=g;let b,x;t[6]!==s||t[7]!==i.state||t[8]!==c||t[9]!==l||t[10]!==d?(b=()=>{if(!c)return"after_delay"===s.autosave&&(null!==u.current&&clearTimeout(u.current),l&&i.state===ct.OPEN&&(u.current=setTimeout(d,s.autosave_delay))),()=>{null!==u.current&&clearTimeout(u.current)}},t[6]=s,t[7]=i.state,t[8]=c,t[9]=l,t[10]=d,t[11]=b):b=t[11],t[12]!==m||t[13]!==y||t[14]!==f||t[15]!==s||t[16]!==i.state||t[17]!==c||t[18]!==l||t[19]!==d?(x=[f,m,y,s,i.state,d,c,l],t[12]=m,t[13]=y,t[14]=f,t[15]=s,t[16]=i.state,t[17]=c,t[18]=l,t[19]=d,t[20]=x):x=t[20],o.useEffect(b,x)}(M);const D=a.state===ct.CLOSED;let O;t[37]!==p||t[38]!==C||t[39]!==D?(O={saveOrNameNotebook:C,needsSave:p,closed:D},t[37]=p,t[38]=C,t[39]=D,t[40]=O):O=t[40];return O}(i);let d;!function(){const e=j.c(6),t=se(Bn),{state:n}=se(at),r=t.auto_download.includes("markdown"),o=t.auto_download.includes("html"),s=t.auto_download.includes("ipynb"),i=!r||n!==ct.OPEN,a=!o||n!==ct.OPEN,l=!s||n!==ct.OPEN;let c,d,u;e[0]!==i?(c={delayMs:xf,whenVisible:!0,disabled:i},e[0]=i,e[1]=c):c=e[1],bl(kf,c),e[2]!==a?(d={delayMs:xf,whenVisible:!0,disabled:a},e[2]=a,e[3]=d):d=e[3],bl(wf,d),e[4]!==l?(u={delayMs:xf,whenVisible:!0,disabled:l},e[4]=l,e[5]=u):u=e[5],bl(vf,u)}(),t[3]!==a?(d=e=>{e.preventDefault(),e.stopPropagation(),a()},t[3]=a,t[4]=d):d=t[4];const u=d;if(yl("global.save",a),c){let e;return t[5]!==s||t[6]!==l?(e=I.jsx(yf,{filename:s,needsSave:l}),t[5]=s,t[6]=l,t[7]=e):e=t[7],e}let h;t[8]===Symbol.for("react.memo_cache_sentinel")?(h=Bt("global.save"),t[8]=h):h=t[8];const f=l?"yellow":"hint-green";let p,m;return t[9]===Symbol.for("react.memo_cache_sentinel")?(p=I.jsx(Sd,{strokeWidth:1.5,size:18}),t[9]=p):p=t[9],t[10]!==u||t[11]!==f?(m=I.jsx(it,{content:h,children:I.jsx(gl,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:f,onClick:u,children:p})}),t[10]=u,t[11]=f,t[12]=m):m=t[12],m};function Cf(e){return e.name}function Ef(e){return e.code}function Nf(e){return e.name}function jf(e){return e.code}function _f(e){return e.id}const If=e=>{const t=j.c(17),{onClose:n,onSave:r}=e,[s,i]=o.useState();let a;t[0]!==n||t[1]!==r?(a=e=>{i(e),e.trim()&&(r(e),n())},t[0]=n,t[1]=r,t[2]=a):a=t[2];const l=a;let c,d,u,h;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx(Te,{children:"Save notebook"}),t[3]=c):c=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(d=I.jsx(Me,{className:"text-md pt-6 px-1",children:"Save as"}),t[4]=d):d=t[4],t[5]!==l?(u=I.jsxs("div",{className:"flex flex-col",children:[d,I.jsx(uf,{onNameChange:l,placeholderText:"filename",className:"missing-filename"})]}),t[5]=l,t[6]=u):u=t[6],t[7]!==n?(h=I.jsx(X,{"data-testid":"cancel-save-dialog-button","aria-label":"Cancel",variant:"secondary",onClick:n,children:"Cancel"}),t[7]=n,t[8]=h):h=t[8];const f=!s;let p,m,g;return t[9]!==f?(p=I.jsx(X,{"data-testid":"submit-save-dialog-button","aria-label":"Save",variant:"default",disabled:f,type:"submit",children:"Save"}),t[9]=f,t[10]=p):p=t[10],t[11]!==h||t[12]!==p?(m=I.jsxs(rt,{children:[h,p]}),t[11]=h,t[12]=p,t[13]=m):m=t[13],t[14]!==u||t[15]!==m?(g=I.jsxs(Ie,{children:[c,u,m]}),t[14]=u,t[15]=m,t[16]=g):g=t[16],g},Af=e=>{const t=j.c(42),{presenting:n,onTogglePresenting:r,onInterrupt:o,onRun:s,closed:i,running:a,appConfig:l}=e,c=l.width,d=se(Ft),u=se(Jn),{undoDeleteCell:h}=U();let f,p,m=null;if(!i&&d){let e,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx(Ld,{size:16,strokeWidth:1.5}),t[0]=e):e=t[0],t[1]!==h?(n=I.jsx(it,{content:"Undo cell deletion",children:I.jsx(gl,{"data-testid":"undo-delete-cell",size:"medium",color:"hint-green",shape:"circle",onClick:h,children:e})}),t[1]=h,t[2]=n):n=t[2],m=n}t[3]!==n?(f=!n&&I.jsx(ef,{}),t[3]=n,t[4]=f):f=t[4],t[5]!==i||t[6]!==n?(p=!i&&I.jsxs("div",{className:Df,children:[n&&I.jsx(Zd,{}),I.jsx(Oh,{}),I.jsx(xl,{}),I.jsx(vl,{description:"This will terminate the Python kernel. You'll lose all data that's in memory."})]}),t[5]=i,t[6]=n,t[7]=p):p=t[7];const g="compact"===c&&"xl:flex-row items-end";let y,b,x,v,w,k,S,C,E,N,_,A,T;return t[8]!==g?(y=In(Of,g),t[8]=g,t[9]=y):y=t[9],t[10]!==l?(b=I.jsx(cf,{children:I.jsx(Sf,{kioskMode:!1,appConfig:l})}),t[10]=l,t[11]=b):b=t[11],t[12]===Symbol.for("react.memo_cache_sentinel")?(x=Bt("global.hideCode"),t[12]=x):x=t[12],t[13]!==n?(v=n?I.jsx(Ut,{strokeWidth:1.5,size:18}):I.jsx(od,{strokeWidth:1.5,size:18}),t[13]=n,t[14]=v):v=t[14],t[15]!==r||t[16]!==v?(w=I.jsx(it,{content:x,children:I.jsx(gl,{"data-testid":"hide-code-button",id:"preview-button",shape:"rectangle",color:"hint-green",onClick:r,children:v})}),t[15]=r,t[16]=v,t[17]=w):w=t[17],t[18]===Symbol.for("react.memo_cache_sentinel")?(C=I.jsx(af,{}),k=I.jsx(wl,{}),S=I.jsx("div",{}),t[18]=k,t[19]=S,t[20]=C):(k=t[18],S=t[19],C=t[20]),t[21]!==i||t[22]!==o||t[23]!==a?(E=!i&&I.jsx(Mf,{running:a,onInterrupt:o}),t[21]=i,t[22]=o,t[23]=a,t[24]=E):E=t[24],t[25]!==i||t[26]!==u||t[27]!==s?(N=!i&&I.jsx(Tf,{needsRun:u,onRun:s}),t[25]=i,t[26]=u,t[27]=s,t[28]=N):N=t[28],t[29]!==E||t[30]!==N||t[31]!==m?(_=I.jsx(cf,{children:I.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[m,E,N]})}),t[29]=E,t[30]=N,t[31]=m,t[32]=_):_=t[32],t[33]!==_||t[34]!==y||t[35]!==b||t[36]!==w?(A=I.jsxs("div",{className:y,children:[b,w,C,k,S,_]}),t[33]=_,t[34]=y,t[35]=b,t[36]=w,t[37]=A):A=t[37],t[38]!==f||t[39]!==A||t[40]!==p?(T=I.jsxs(I.Fragment,{children:[f,p,A]}),t[38]=f,t[39]=A,t[40]=p,t[41]=T):T=t[41],T},Tf=e=>{const t=j.c(5),{needsRun:n,onRun:r}=e;if(n){let e,n,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=Bt("global.runStale"),t[0]=e):e=t[0],t[1]===Symbol.for("react.memo_cache_sentinel")?(n=I.jsx(bd,{strokeWidth:1.5,size:16}),t[1]=n):n=t[1],t[2]!==r?(o=I.jsx(it,{content:e,children:I.jsx(gl,{"data-testid":"run-button",size:"medium",color:"yellow",shape:"circle",onClick:r,children:n})}),t[2]=r,t[3]=o):o=t[3],o}let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=I.jsx(it,{content:"Nothing to run",children:I.jsx(gl,{"data-testid":"run-button",className:"inactive-button",color:"disabled",size:"medium",shape:"circle",children:I.jsx(bd,{strokeWidth:1.5,size:16})})}),t[4]=o):o=t[4],o},Mf=e=>{const t=j.c(8),{running:n,onInterrupt:r}=e,o=sf(n);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=Bt("global.interrupt"),t[0]=s):s=t[0];const i=!o&&"inactive-button active:shadow-xsSolid";let a;t[1]!==i?(a=In(i),t[1]=i,t[2]=a):a=t[2];const l=o?"yellow":"disabled",c=o?r:Kn.NOOP;let d,u;return t[3]===Symbol.for("react.memo_cache_sentinel")?(d=I.jsx(E,{strokeWidth:1.5,size:16}),t[3]=d):d=t[3],t[4]!==a||t[5]!==l||t[6]!==c?(u=I.jsx(it,{content:s,children:I.jsx(gl,{className:a,"data-testid":"interrupt-button",size:"medium",color:l,shape:"circle",onClick:c,children:d})}),t[4]=a,t[5]=l,t[6]=c,t[7]=u):u=t[7],u},Df="absolute top-3 right-5 m-0 flex items-center space-x-3 min-h-[28px] no-print pointer-events-auto z-30 print:hidden",Of="absolute bottom-5 right-5 flex flex-col gap-2 items-center no-print pointer-events-auto z-30 print:hidden",Rf=e=>{const t=j.c(7),{filename:n}=e,r=Gn();let o;t[0]!==n?(o=n?kt.basename(n):"untitled marimo app",t[0]=n,t[1]=o):o=t[1];const s=null===n?"missing-filename":"filename";let i;return t[2]!==n||t[3]!==r||t[4]!==o||t[5]!==s?(i=I.jsx(uf,{placeholderText:o,initialValue:n,onNameChange:r,flexibleWidth:!0,resetOnBlur:!0,"data-testid":"filename-input",className:s}),t[2]=n,t[3]=r,t[4]=o,t[5]=s,t[6]=i):i=t[6],i},Pf=Zn(Qn,400),Lf=(e,t)=>{K.get(de)||e.isEmpty()||t.isEmpty()||zn(e.inOrderIds,t.inOrderIds)||Pf({cell_ids:e.inOrderIds})};function zf(e){return[er.of([{key:"Escape",preventDefault:!1,run:zh},{key:e.getHotkey("cell.selectNextOccurrence").key,preventDefault:!0,run:tr},{key:e.getHotkey("cell.findAndReplace").key,preventDefault:!0,run:Lh}]),nr(),Zh,Xh,Qh]}var Ff=Object.defineProperty,Bf=(e,t,n)=>(((e,t,n)=>{t in e?Ff(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);const Uf=xn.define({create:()=>({suggestion:null}),update(e,t){const n=t.effects.find((e=>e.is($f)));return t.state.doc&&n&&t.state.doc==n.value.doc?{suggestion:n.value.text}:{suggestion:null}}}),$f=bn.define();class Hf extends or{constructor(e){super(),Bf(this,"suggestion"),this.suggestion=e}toDOM(){const e=document.createElement("span");return e.style.opacity="0.4",e.className="cm-inline-suggestion",e.textContent=this.suggestion,e}get lineBreaks(){return this.suggestion.split("\n").length-1}}const Vf=e=>wn.fromClass(class{async update(t){const n=t.state.doc;if(!t.docChanged)return;const r=await e(t.state);t.view.dispatch({effects:$f.of({text:r,doc:n})})}}),Wf=wn.fromClass(class{constructor(){Bf(this,"decorations"),this.decorations=vn.none}update(e){var t;const n=null==(t=e.state.field(Uf))?void 0:t.suggestion;this.decorations=n?function(e,t){const n=e.state.selection.main.head,r=[],o=vn.widget({widget:new Hf(t),side:1});return r.push(o.range(n)),vn.set(r)}(e.view,n):vn.none}},{decorations:e=>e.decorations}),Gf=rr.highest(er.of([{key:"Tab",run:e=>{var t;const n=null==(t=e.state.field(Uf))?void 0:t.suggestion;return!!n&&(e.dispatch({...qf(e.state,n,e.state.selection.main.head,e.state.selection.main.head)}),!0)}}]));function qf(e,t,n,r){return{...e.changeByRange((o=>{if(o==e.selection.main)return{changes:{from:n,to:r,insert:t},range:gn.cursor(n+t.length)};const s=r-n;return!o.empty||s&&e.sliceDoc(o.from-s,o.from)!=e.sliceDoc(n,r)?{range:o}:{changes:{from:o.from-s,to:o.from,insert:t},range:gn.cursor(o.from-s+t.length)}})),userEvent:"input.complete"}}function Yf(e){const{delay:t=500}=e,n=function(e,t,n){let r=()=>{};return(...o)=>(r(),new Promise(((s,i)=>{const a=setTimeout((()=>s(e(...o))),t);r=()=>{clearTimeout(a),void 0!==n&&i(n)}})))}(e.fetchFn,t);return[Uf,Vf(n),Wf,Gf]}const Xf=bn.define(),Jf=bn.define(),Kf=bn.define();function Zf(e,t){if(!e)throw new Error(t)}function Qf(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int 32: "+e)}function ep(e){if("number"!=typeof e)throw new Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint 32: "+e)}function tp(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw new Error("invalid float 32: "+e)}const np=Symbol("@bufbuild/protobuf/enum-type");function rp(e){const t=e[np];return Zf(t,"missing enum type on enum object"),t}function op(e,t,n,r){e[np]=sp(t,n.map((t=>({no:t.no,name:t.name,localName:e[t.no]}))))}function sp(e,t,n){const r=Object.create(null),o=Object.create(null),s=[];for(const i of t){const e=ap(i);s.push(e),r[i.name]=e,o[i.no]=e}return{typeName:e,values:s,findName:e=>r[e],findNumber:e=>o[e]}}function ip(e,t,n){const r={};for(const o of t){const e=ap(o);r[e.localName]=e.no,r[e.no]=e.localName}return op(r,e,t),r}function ap(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class lp{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const n=this.getType().runtime.bin,r=n.makeReadOptions(t);return n.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,t){const n=this.getType(),r=n.runtime.json,o=r.makeReadOptions(t);return r.readMessage(n,e,o,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(n,t)}toBinary(e){const t=this.getType().runtime.bin,n=t.makeWriteOptions(e),r=n.writerFactory();return t.writeMessage(this,r,n),r.finish()}toJson(e){const t=this.getType().runtime.json,n=t.makeWriteOptions(e);return t.writeMessage(this,n)}toJsonString(e){var t;const n=this.toJson(e);return JSON.stringify(n,null,null!==(t=null==e?void 0:e.prettySpaces)&&void 0!==t?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function cp(){let e=0,t=0;for(let r=0;r<28;r+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<r,!(128&n))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let r=3;r<=31;r+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<r,!(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function dp(e,t,n){for(let s=0;s<28;s+=7){const r=e>>>s,o=!(r>>>7==0&&0==t),i=255&(o?128|r:r);if(n.push(i),!o)return}const r=e>>>28&15|(7&t)<<4,o=!!(t>>3);if(n.push(255&(o?128|r:r)),o){for(let e=3;e<31;e+=7){const r=t>>>e,o=!(r>>>7==0),s=255&(o?128|r:r);if(n.push(s),!o)return}n.push(t>>>31&1)}}const up=4294967296;function hp(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let r=0,o=0;function s(t,s){const i=Number(e.slice(t,s));o*=n,r=r*n+i,r>=up&&(o+=r/up|0,r%=up)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),t?mp(r,o):pp(r,o)}function fp(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(up*t+e);const n=16777215&(e>>>24|t<<8),r=t>>16&65535;let o=(16777215&e)+6777216*n+6710656*r,s=n+8147497*r,i=2*r;const a=1e7;return o>=a&&(s+=Math.floor(o/a),o%=a),s>=a&&(i+=Math.floor(s/a),s%=a),i.toString()+gp(s)+gp(o)}function pp(e,t){return{lo:0|e,hi:0|t}}function mp(e,t){return t=~t,e?e=1+~e:t+=1,pp(e,t)}const gp=e=>{const t=String(e);return"0000000".slice(t.length)+t};function yp(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function bp(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let n=5;128&e&&n<10;n++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var xp={};const vp=function(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"1"!==xp.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),r=BigInt("0"),o=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const r="bigint"==typeof e?e:BigInt(e);if(r>n||r<t)throw new Error(`int64 invalid: ${e}`);return r},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>o||t<r)throw new Error(`uint64 invalid: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)),uDec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0))}}const t=e=>Zf(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>Zf(/^[0-9]+$/.test(e),`uint64 invalid: ${e}`);return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),t(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),n(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),t(e),hp(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),n(e),hp(e)),dec:(e,t)=>function(e,t){let n=pp(e,t);const r=2147483648&n.hi;r&&(n=mp(n.lo,n.hi));const o=fp(n.lo,n.hi);return r?"-"+o:o}(e,t),uDec:(e,t)=>fp(e,t)}}();var wp,kp,Sp,Cp,Ep,Np;function jp(e,t,n){if(t===n)return!0;if(e==wp.BYTES){if(!(t instanceof Uint8Array&&n instanceof Uint8Array))return!1;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}switch(e){case wp.UINT64:case wp.FIXED64:case wp.INT64:case wp.SFIXED64:case wp.SINT64:return t==n}return!1}function _p(e,t){switch(e){case wp.BOOL:return!1;case wp.UINT64:case wp.FIXED64:case wp.INT64:case wp.SFIXED64:case wp.SINT64:return 0==t?vp.zero:"0";case wp.DOUBLE:case wp.FLOAT:return 0;case wp.BYTES:return new Uint8Array(0);case wp.STRING:return"";default:return 0}}function Ip(e,t){switch(e){case wp.BOOL:return!1===t;case wp.STRING:return""===t;case wp.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return 0==t}}(kp=wp||(wp={}))[kp.DOUBLE=1]="DOUBLE",kp[kp.FLOAT=2]="FLOAT",kp[kp.INT64=3]="INT64",kp[kp.UINT64=4]="UINT64",kp[kp.INT32=5]="INT32",kp[kp.FIXED64=6]="FIXED64",kp[kp.FIXED32=7]="FIXED32",kp[kp.BOOL=8]="BOOL",kp[kp.STRING=9]="STRING",kp[kp.BYTES=12]="BYTES",kp[kp.UINT32=13]="UINT32",kp[kp.SFIXED32=15]="SFIXED32",kp[kp.SFIXED64=16]="SFIXED64",kp[kp.SINT32=17]="SINT32",kp[kp.SINT64=18]="SINT64",(Cp=Sp||(Sp={}))[Cp.BIGINT=0]="BIGINT",Cp[Cp.STRING=1]="STRING",(Np=Ep||(Ep={}))[Np.Varint=0]="Varint",Np[Np.Bit64=1]="Bit64",Np[Np.LengthDelimited=2]="LengthDelimited",Np[Np.StartGroup=3]="StartGroup",Np[Np.EndGroup=4]="EndGroup",Np[Np.Bit32=5]="Bit32";class Ap{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let t=new Uint8Array(e),n=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],n),n+=this.chunks[r].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(ep(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return Qf(e),yp(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){tp(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){ep(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Qf(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Qf(e),yp(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=vp.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=vp.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=vp.enc(e);return dp(t.lo,t.hi,this.buf),this}sint64(e){let t=vp.enc(e),n=t.hi>>31;return dp(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=vp.uEnc(e);return dp(t.lo,t.hi,this.buf),this}}class Tp{constructor(e,t){this.varint64=cp,this.uint32=bp,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case Ep.Varint:for(;128&this.buf[this.pos++];);break;case Ep.Bit64:this.pos+=4;case Ep.Bit32:this.pos+=4;break;case Ep.LengthDelimited:let n=this.uint32();this.pos+=n;break;case Ep.StartGroup:for(;;){const[e,n]=this.tag();if(n===Ep.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(n,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return vp.dec(...this.varint64())}uint64(){return vp.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,vp.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return vp.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return vp.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function Mp(e){const t=e.field.localName,n=Object.create(null);return n[t]=function(e){const t=e.field;if(t.repeated)return[];if(void 0!==t.default)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return _p(t.T,t.L);case"message":const e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}(e),[n,()=>n[t]]}let Dp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Op=[];for(let aX=0;aX<Dp.length;aX++)Op[Dp[aX].charCodeAt(0)]=aX;Op["-".charCodeAt(0)]=Dp.indexOf("+"),Op["_".charCodeAt(0)]=Dp.indexOf("/");const Rp={dec(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let n,r=new Uint8Array(t),o=0,s=0,i=0;for(let a=0;a<e.length;a++){if(n=Op[e.charCodeAt(a)],void 0===n)switch(e[a]){case"=":s=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(s){case 0:i=n,s=1;break;case 1:r[o++]=i<<2|(48&n)>>4,i=n,s=2;break;case 2:r[o++]=(15&i)<<4|(60&n)>>2,i=n,s=3;break;case 3:r[o++]=(3&i)<<6|n,s=0}}if(1==s)throw Error("invalid base64 string.");return r.subarray(0,o)},enc(e){let t,n="",r=0,o=0;for(let s=0;s<e.length;s++)switch(t=e[s],r){case 0:n+=Dp[t>>2],o=(3&t)<<4,r=1;break;case 1:n+=Dp[o|t>>4],o=(15&t)<<2,r=2;break;case 2:n+=Dp[o|t>>6],n+=Dp[63&t],r=0}return r&&(n+=Dp[o],n+="=",1==r&&(n+="=")),n}};function Pp(e,t,n){Fp(t,e);const r=t.runtime.bin.makeReadOptions(n),o=function(e,t){if(!t.repeated&&("enum"==t.kind||"scalar"==t.kind)){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter((e=>e.no===t.no))}(e.getType().runtime.bin.listUnknownFields(e),t.field),[s,i]=Mp(t);for(const a of o)t.runtime.bin.readField(s,r.readerFactory(a.data),t.field,a.wireType,r);return i()}function Lp(e,t,n,r){Fp(t,e);const o=t.runtime.bin.makeReadOptions(r),s=t.runtime.bin.makeWriteOptions(r);if(zp(e,t)){const n=e.getType().runtime.bin.listUnknownFields(e).filter((e=>e.no!=t.field.no));e.getType().runtime.bin.discardUnknownFields(e);for(const t of n)e.getType().runtime.bin.onUnknownField(e,t.no,t.wireType,t.data)}const i=s.writerFactory();let a=t.field;a.opt||a.repeated||"enum"!=a.kind&&"scalar"!=a.kind||(a=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(a,n,i,s);const l=o.readerFactory(i.finish());for(;l.pos<l.len;){const[t,n]=l.tag(),r=l.skip(n,t);e.getType().runtime.bin.onUnknownField(e,t,n,r)}}function zp(e,t){const n=e.getType();return t.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(e).find((e=>e.no==t.field.no))}function Fp(e,t){Zf(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function Bp(e,t){const n=e.localName;if(e.repeated)return t[n].length>0;if(e.oneof)return t[e.oneof.localName].case===n;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?void 0!==t[n]:"enum"==e.kind?t[n]!==e.T.values[0].no:!Ip(e.T,t[n]);case"message":return void 0!==t[n];case"map":return Object.keys(t[n]).length>0}}function Up(e,t){const n=e.localName,r=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[n]={};break;case"enum":t[n]=r?e.T.values[0].no:void 0;break;case"scalar":t[n]=r?_p(e.T,e.L):void 0;break;case"message":t[n]=void 0}}function $p(e,t){if(null===e||"object"!=typeof e)return!1;if(!Object.getOwnPropertyNames(lp.prototype).every((t=>t in e&&"function"==typeof e[t])))return!1;const n=e.getType();return null!==n&&"function"==typeof n&&"typeName"in n&&"string"==typeof n.typeName&&(void 0===t||n.typeName==t.typeName)}function Hp(e,t){return $p(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}wp.DOUBLE,wp.FLOAT,wp.INT64,wp.UINT64,wp.INT32,wp.UINT32,wp.BOOL,wp.STRING,wp.BYTES;const Vp={ignoreUnknownFields:!1},Wp={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Gp(e){return e?Object.assign(Object.assign({},Vp),e):Vp}function qp(e){return e?Object.assign(Object.assign({},Wp),e):Wp}const Yp=Symbol(),Xp=Symbol();function Jp(e){if(null===e)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":`"${e.split('"').join('\\"')}"`;default:return String(e)}}function Kp(e,t,n,r,o){let s=n.localName;if(n.repeated){if(Zf("map"!=n.kind),null===t)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${o.typeName}.${n.name} from JSON: ${Jp(t)}`);const a=e[s];for(const e of t){if(null===e)throw new Error(`cannot decode field ${o.typeName}.${n.name} from JSON: ${Jp(e)}`);switch(n.kind){case"message":a.push(n.T.fromJson(e,r));break;case"enum":const t=em(n.T,e,r.ignoreUnknownFields,!0);t!==Xp&&a.push(t);break;case"scalar":try{a.push(Qp(n.T,e,n.L,!0))}catch(i){let t=`cannot decode field ${o.typeName}.${n.name} from JSON: ${Jp(e)}`;throw i instanceof Error&&i.message.length>0&&(t+=`: ${i.message}`),new Error(t)}}}}else if("map"==n.kind){if(null===t)return;if("object"!=typeof t||Array.isArray(t))throw new Error(`cannot decode field ${o.typeName}.${n.name} from JSON: ${Jp(t)}`);const a=e[s];for(const[e,s]of Object.entries(t)){if(null===s)throw new Error(`cannot decode field ${o.typeName}.${n.name} from JSON: map value null`);let l;try{l=Zp(n.K,e)}catch(i){let e=`cannot decode map key for field ${o.typeName}.${n.name} from JSON: ${Jp(t)}`;throw i instanceof Error&&i.message.length>0&&(e+=`: ${i.message}`),new Error(e)}switch(n.V.kind){case"message":a[l]=n.V.T.fromJson(s,r);break;case"enum":const e=em(n.V.T,s,r.ignoreUnknownFields,!0);e!==Xp&&(a[l]=e);break;case"scalar":try{a[l]=Qp(n.V.T,s,Sp.BIGINT,!0)}catch(i){let e=`cannot decode map value for field ${o.typeName}.${n.name} from JSON: ${Jp(t)}`;throw i instanceof Error&&i.message.length>0&&(e+=`: ${i.message}`),new Error(e)}}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:s},s="value"),n.kind){case"message":const a=n.T;if(null===t&&"google.protobuf.Value"!=a.typeName)return;let l=e[s];$p(l)?l.fromJson(t,r):(e[s]=l=a.fromJson(t,r),a.fieldWrapper&&!n.oneof&&(e[s]=a.fieldWrapper.unwrapField(l)));break;case"enum":const c=em(n.T,t,r.ignoreUnknownFields,!1);switch(c){case Yp:Up(n,e);break;case Xp:break;default:e[s]=c}break;case"scalar":try{const r=Qp(n.T,t,n.L,!1);if(r===Yp)Up(n,e);else e[s]=r}catch(i){let e=`cannot decode field ${o.typeName}.${n.name} from JSON: ${Jp(t)}`;throw i instanceof Error&&i.message.length>0&&(e+=`: ${i.message}`),new Error(e)}}}function Zp(e,t){if(e===wp.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1}return Qp(e,t,Sp.BIGINT,!0).toString()}function Qp(e,t,n,r){if(null===t)return r?_p(e,n):Yp;switch(e){case wp.DOUBLE:case wp.FLOAT:if("NaN"===t)return Number.NaN;if("Infinity"===t)return Number.POSITIVE_INFINITY;if("-Infinity"===t)return Number.NEGATIVE_INFINITY;if(""===t)break;if("string"==typeof t&&t.trim().length!==t.length)break;if("string"!=typeof t&&"number"!=typeof t)break;const r=Number(t);if(Number.isNaN(r))break;if(!Number.isFinite(r))break;return e==wp.FLOAT&&tp(r),r;case wp.INT32:case wp.FIXED32:case wp.SFIXED32:case wp.SINT32:case wp.UINT32:let s;if("number"==typeof t?s=t:"string"==typeof t&&t.length>0&&t.trim().length===t.length&&(s=Number(t)),void 0===s)break;return e==wp.UINT32||e==wp.FIXED32?ep(s):Qf(s),s;case wp.INT64:case wp.SFIXED64:case wp.SINT64:if("number"!=typeof t&&"string"!=typeof t)break;const i=vp.parse(t);return n?i.toString():i;case wp.FIXED64:case wp.UINT64:if("number"!=typeof t&&"string"!=typeof t)break;const a=vp.uParse(t);return n?a.toString():a;case wp.BOOL:if("boolean"!=typeof t)break;return t;case wp.STRING:if("string"!=typeof t)break;try{encodeURIComponent(t)}catch(o){throw new Error("invalid UTF8")}return t;case wp.BYTES:if(""===t)return new Uint8Array(0);if("string"!=typeof t)break;return Rp.dec(t)}throw new Error}function em(e,t,n,r){if(null===t)return"google.protobuf.NullValue"==e.typeName?0:r?e.values[0].no:Yp;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const r=e.findName(t);if(void 0!==r)return r.no;if(n)return Xp}throw new Error(`cannot decode enum ${e.typeName} from JSON: ${Jp(t)}`)}function tm(e){return!(!e.repeated&&"map"!=e.kind)||!e.oneof&&("message"!=e.kind&&(!e.opt&&!e.req))}function nm(e,t,n){if("map"==e.kind){Zf("object"==typeof t&&null!=t);const r={},o=Object.entries(t);switch(e.V.kind){case"scalar":for(const[n,s]of o)r[n.toString()]=om(e.V.T,s);break;case"message":for(const[e,s]of o)r[e.toString()]=s.toJson(n);break;case"enum":const t=e.V.T;for(const[e,s]of o)r[e.toString()]=rm(t,s,n.enumAsInteger)}return n.emitDefaultValues||o.length>0?r:void 0}if(e.repeated){Zf(Array.isArray(t));const r=[];switch(e.kind){case"scalar":for(let n=0;n<t.length;n++)r.push(om(e.T,t[n]));break;case"enum":for(let o=0;o<t.length;o++)r.push(rm(e.T,t[o],n.enumAsInteger));break;case"message":for(let e=0;e<t.length;e++)r.push(t[e].toJson(n))}return n.emitDefaultValues||r.length>0?r:void 0}switch(e.kind){case"scalar":return om(e.T,t);case"enum":return rm(e.T,t,n.enumAsInteger);case"message":return Hp(e.T,t).toJson(n)}}function rm(e,t,n){var r;if(Zf("number"==typeof t),"google.protobuf.NullValue"==e.typeName)return null;if(n)return t;const o=e.findNumber(t);return null!==(r=null==o?void 0:o.name)&&void 0!==r?r:t}function om(e,t){switch(e){case wp.INT32:case wp.SFIXED32:case wp.SINT32:case wp.FIXED32:case wp.UINT32:return Zf("number"==typeof t),t;case wp.FLOAT:case wp.DOUBLE:return Zf("number"==typeof t),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case wp.STRING:return Zf("string"==typeof t),t;case wp.BOOL:return Zf("boolean"==typeof t),t;case wp.UINT64:case wp.FIXED64:case wp.INT64:case wp.SFIXED64:case wp.SINT64:return Zf("bigint"==typeof t||"string"==typeof t||"number"==typeof t),t.toString();case wp.BYTES:return Zf(t instanceof Uint8Array),Rp.enc(t)}}const sm=Symbol("@bufbuild/protobuf/unknown-fields"),im={readUnknownFields:!0,readerFactory:e=>new Tp(e)},am={writeUnknownFields:!0,writerFactory:()=>new Ap};function lm(e){return e?Object.assign(Object.assign({},im),e):im}function cm(e){return e?Object.assign(Object.assign({},am),e):am}function dm(e,t,n,r,o){let{repeated:s,localName:i}=n;switch(n.oneof&&((e=e[n.oneof.localName]).case!=i&&delete e.value,e.case=i,i="value"),n.kind){case"scalar":case"enum":const a="enum"==n.kind?wp.INT32:n.T;let l=fm;if("scalar"==n.kind&&n.L>0&&(l=hm),s){let n=e[i];if(r==Ep.LengthDelimited&&a!=wp.STRING&&a!=wp.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(l(t,a))}else n.push(l(t,a))}else e[i]=l(t,a);break;case"message":const c=n.T;s?e[i].push(um(t,new c,o,n)):$p(e[i])?um(t,e[i],o,n):(e[i]=um(t,new c,o,n),!c.fieldWrapper||n.oneof||n.repeated||(e[i]=c.fieldWrapper.unwrapField(e[i])));break;case"map":let[d,u]=function(e,t,n){const r=t.uint32(),o=t.pos+r;let s,i;for(;t.pos<o;){const[r]=t.tag();switch(r){case 1:s=fm(t,e.K);break;case 2:switch(e.V.kind){case"scalar":i=fm(t,e.V.T);break;case"enum":i=t.int32();break;case"message":i=um(t,new e.V.T,n,void 0)}}}void 0===s&&(s=_p(e.K,Sp.BIGINT));"string"!=typeof s&&"number"!=typeof s&&(s=s.toString());if(void 0===i)switch(e.V.kind){case"scalar":i=_p(e.V.T,Sp.BIGINT);break;case"enum":i=e.V.T.values[0].no;break;case"message":i=new e.V.T}return[s,i]}(n,t,o);e[i][d]=u}}function um(e,t,n,r){const o=t.getType().runtime.bin,s=null==r?void 0:r.delimited;return o.readMessage(t,e,s?r.no:e.uint32(),n,s),t}function hm(e,t){const n=fm(e,t);return"bigint"==typeof n?n.toString():n}function fm(e,t){switch(t){case wp.STRING:return e.string();case wp.BOOL:return e.bool();case wp.DOUBLE:return e.double();case wp.FLOAT:return e.float();case wp.INT32:return e.int32();case wp.INT64:return e.int64();case wp.UINT64:return e.uint64();case wp.FIXED64:return e.fixed64();case wp.BYTES:return e.bytes();case wp.FIXED32:return e.fixed32();case wp.SFIXED32:return e.sfixed32();case wp.SFIXED64:return e.sfixed64();case wp.SINT64:return e.sint64();case wp.UINT32:return e.uint32();case wp.SINT32:return e.sint32()}}function pm(e,t,n,r){Zf(void 0!==t);const o=e.repeated;switch(e.kind){case"scalar":case"enum":let s="enum"==e.kind?wp.INT32:e.T;if(o)if(Zf(Array.isArray(t)),e.packed)!function(e,t,n,r){if(!r.length)return;e.tag(n,Ep.LengthDelimited).fork();let[,o]=bm(t);for(let s=0;s<r.length;s++)e[o](r[s]);e.join()}(n,s,e.no,t);else for(const r of t)ym(n,s,e.no,r);else ym(n,s,e.no,t);break;case"message":if(o){Zf(Array.isArray(t));for(const o of t)gm(n,r,e,o)}else gm(n,r,e,t);break;case"map":Zf("object"==typeof t&&null!=t);for(const[o,i]of Object.entries(t))mm(n,r,e,o,i)}}function mm(e,t,n,r,o){e.tag(n.no,Ep.LengthDelimited),e.fork();let s=r;switch(n.K){case wp.INT32:case wp.FIXED32:case wp.UINT32:case wp.SFIXED32:case wp.SINT32:s=Number.parseInt(r);break;case wp.BOOL:Zf("true"==r||"false"==r),s="true"==r}switch(ym(e,n.K,1,s),n.V.kind){case"scalar":ym(e,n.V.T,2,o);break;case"enum":ym(e,wp.INT32,2,o);break;case"message":Zf(void 0!==o),e.tag(2,Ep.LengthDelimited).bytes(o.toBinary(t))}e.join()}function gm(e,t,n,r){const o=Hp(n.T,r);n.delimited?e.tag(n.no,Ep.StartGroup).raw(o.toBinary(t)).tag(n.no,Ep.EndGroup):e.tag(n.no,Ep.LengthDelimited).bytes(o.toBinary(t))}function ym(e,t,n,r){Zf(void 0!==r);let[o,s]=bm(t);e.tag(n,o)[s](r)}function bm(e){let t=Ep.Varint;switch(e){case wp.BYTES:case wp.STRING:t=Ep.LengthDelimited;break;case wp.DOUBLE:case wp.FIXED64:case wp.SFIXED64:t=Ep.Bit64;break;case wp.FIXED32:case wp.SFIXED32:case wp.FLOAT:t=Ep.Bit32}return[t,wp[e].toLowerCase()]}function xm(e){if(void 0===e)return e;if($p(e))return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function vm(e){return e instanceof Uint8Array?e:new Uint8Array(e)}class wm{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const e={};for(const t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){const e={};for(const t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort(((e,t)=>e.no-t.no))),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}}function km(e,t){const n=Cm(e);return t?n:Im(_m(n))}const Sm=Cm;function Cm(e){let t=!1;const n=[];for(let r=0;r<e.length;r++){let o=e.charAt(r);switch(o){case"_":t=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(o),t=!1;break;default:t&&(t=!1,o=o.toUpperCase()),n.push(o)}}return n.join("")}const Em=new Set(["constructor","toString","toJSON","valueOf"]),Nm=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),jm=e=>`${e}$`,_m=e=>Nm.has(e)?jm(e):e,Im=e=>Em.has(e)?jm(e):e;class Am{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=km(e,!1)}addField(e){Zf(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}}const Tm=(Mm=e=>new wm(e,(e=>function(e){var t,n,r,o,s,i;const a=[];let l;for(const c of"function"==typeof e?e():e){const e=c;if(e.localName=km(c.name,void 0!==c.oneof),e.jsonName=null!==(t=c.jsonName)&&void 0!==t?t:Sm(c.name),e.repeated=null!==(n=c.repeated)&&void 0!==n&&n,"scalar"==c.kind&&(e.L=null!==(r=c.L)&&void 0!==r?r:Sp.BIGINT),e.delimited=null!==(o=c.delimited)&&void 0!==o&&o,e.req=null!==(s=c.req)&&void 0!==s&&s,e.opt=null!==(i=c.opt)&&void 0!==i&&i,void 0===c.packed&&(e.packed="enum"==c.kind||"scalar"==c.kind&&c.T!=wp.BYTES&&c.T!=wp.STRING),void 0!==c.oneof){const t="string"==typeof c.oneof?c.oneof:c.oneof.name;l&&l.name==t||(l=new Am(t)),e.oneof=l,l.addField(e)}a.push(e)}return a}(e))),Dm=e=>{for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,r=e;if(t.repeated)r[n]=[];else switch(t.kind){case"oneof":r[n]={case:void 0};break;case"enum":r[n]=0;break;case"map":r[n]={};break;case"scalar":r[n]=_p(t.T,t.L)}}},{syntax:"proto3",json:{makeReadOptions:Gp,makeWriteOptions:qp,readMessage(e,t,n,r){if(null==t||Array.isArray(t)||"object"!=typeof t)throw new Error(`cannot decode message ${e.typeName} from JSON: ${Jp(t)}`);r=null!=r?r:new e;const o=new Map,s=n.typeRegistry;for(const[i,a]of Object.entries(t)){const t=e.fields.findJsonName(i);if(t){if(t.oneof){if(null===a&&"scalar"==t.kind)continue;const n=o.get(t.oneof);if(void 0!==n)throw new Error(`cannot decode message ${e.typeName} from JSON: multiple keys for oneof "${t.oneof.name}" present: "${n}", "${i}"`);o.set(t.oneof,i)}Kp(r,a,t,n,e)}else{let t=!1;if((null==s?void 0:s.findExtension)&&i.startsWith("[")&&i.endsWith("]")){const o=s.findExtension(i.substring(1,i.length-1));if(o&&o.extendee.typeName==e.typeName){t=!0;const[e,s]=Mp(o);Kp(e,a,o.field,n,o),Lp(r,o,s(),n)}}if(!t&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${e.typeName} from JSON: key "${i}" is unknown`)}}return r},writeMessage(e,t){const n=e.getType(),r={};let o;try{for(o of n.fields.byNumber()){if(!Bp(o,e)){if(o.req)throw"required field not set";if(!t.emitDefaultValues)continue;if(!tm(o))continue}const n=nm(o,o.oneof?e[o.oneof.localName].value:e[o.localName],t);void 0!==n&&(r[t.useProtoFieldName?o.name:o.jsonName]=n)}const s=t.typeRegistry;if(null==s?void 0:s.findExtensionFor)for(const o of n.runtime.bin.listUnknownFields(e)){const i=s.findExtensionFor(n.typeName,o.no);if(i&&zp(e,i)){const n=Pp(e,i,t),o=nm(i.field,n,t);void 0!==o&&(r[i.field.jsonName]=o)}}}catch(s){const e=o?`cannot encode field ${n.typeName}.${o.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,t=s instanceof Error?s.message:String(s);throw new Error(e+(t.length>0?`: ${t}`:""))}return r},readScalar:(e,t,n)=>Qp(e,t,null!=n?n:Sp.BIGINT,!0),writeScalar(e,t,n){if(void 0!==t)return n||Ip(e,t)?om(e,t):void 0},debug:Jp},bin:{makeReadOptions:lm,makeWriteOptions:cm,listUnknownFields(e){var t;return null!==(t=e[sm])&&void 0!==t?t:[]},discardUnknownFields(e){delete e[sm]},writeUnknownFields(e,t){const n=e[sm];if(n)for(const r of n)t.tag(r.no,r.wireType).raw(r.data)},onUnknownField(e,t,n,r){const o=e;Array.isArray(o[sm])||(o[sm]=[]),o[sm].push({no:t,wireType:n,data:r})},readMessage(e,t,n,r,o){const s=e.getType(),i=o?t.len:t.pos+n;let a,l;for(;t.pos<i&&([a,l]=t.tag(),!0!==o||l!=Ep.EndGroup);){const n=s.fields.find(a);if(n)dm(e,t,n,l,r);else{const n=t.skip(l,a);r.readUnknownFields&&this.onUnknownField(e,a,l,n)}}if(o&&(l!=Ep.EndGroup||a!==n))throw new Error("invalid end group tag")},readField:dm,writeMessage(e,t,n){const r=e.getType();for(const o of r.fields.byNumber())if(Bp(o,e))pm(o,o.oneof?e[o.oneof.localName].value:e[o.localName],t,n);else if(o.req)throw new Error(`cannot encode field ${r.typeName}.${o.name} to binary: required field not set`);return n.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,n,r){void 0!==t&&pm(e,t,n,r)}},util:Object.assign(Object.assign({},{setEnumType:op,initPartial(e,t){if(void 0===e)return;const n=t.getType();for(const r of n.fields.byMember()){const n=r.localName,o=t,s=e;if(null!=s[n])switch(r.kind){case"oneof":const e=s[n].case;if(void 0===e)continue;const t=r.findField(e);let i=s[n].value;t&&"message"==t.kind&&!$p(i,t.T)?i=new t.T(i):t&&"scalar"===t.kind&&t.T===wp.BYTES&&(i=vm(i)),o[n]={case:e,value:i};break;case"scalar":case"enum":let a=s[n];r.T===wp.BYTES&&(a=r.repeated?a.map(vm):vm(a)),o[n]=a;break;case"map":switch(r.V.kind){case"scalar":case"enum":if(r.V.T===wp.BYTES)for(const[t,r]of Object.entries(s[n]))o[n][t]=vm(r);else Object.assign(o[n],s[n]);break;case"message":const e=r.V.T;for(const t of Object.keys(s[n])){let r=s[n][t];e.fieldWrapper||(r=new e(r)),o[n][t]=r}}break;case"message":const l=r.T;if(r.repeated)o[n]=s[n].map((e=>$p(e,l)?e:new l(e)));else{const e=s[n];l.fieldWrapper?"google.protobuf.BytesValue"===l.typeName?o[n]=vm(e):o[n]=e:o[n]=$p(e,l)?e:new l(e)}}}},equals:(e,t,n)=>t===n||!(!t||!n)&&e.fields.byMember().every((e=>{const r=t[e.localName],o=n[e.localName];if(e.repeated){if(r.length!==o.length)return!1;switch(e.kind){case"message":return r.every(((t,n)=>e.T.equals(t,o[n])));case"scalar":return r.every(((t,n)=>jp(e.T,t,o[n])));case"enum":return r.every(((e,t)=>jp(wp.INT32,e,o[t])))}throw new Error(`repeated cannot contain ${e.kind}`)}switch(e.kind){case"message":return e.T.equals(r,o);case"enum":return jp(wp.INT32,r,o);case"scalar":return jp(e.T,r,o);case"oneof":if(r.case!==o.case)return!1;const t=e.findField(r.case);if(void 0===t)return!0;switch(t.kind){case"message":return t.T.equals(r.value,o.value);case"enum":return jp(wp.INT32,r.value,o.value);case"scalar":return jp(t.T,r.value,o.value)}throw new Error(`oneof cannot contain ${t.kind}`);case"map":const n=Object.keys(r).concat(Object.keys(o));switch(e.V.kind){case"message":const t=e.V.T;return n.every((e=>t.equals(r[e],o[e])));case"enum":return n.every((e=>jp(wp.INT32,r[e],o[e])));case"scalar":const s=e.V.T;return n.every((e=>jp(s,r[e],o[e])))}}})),clone(e){const t=e.getType(),n=new t,r=n;for(const o of t.fields.byMember()){const t=e[o.localName];let n;if(o.repeated)n=t.map(xm);else if("map"==o.kind){n=r[o.localName];for(const[e,r]of Object.entries(t))n[e]=xm(r)}else n="oneof"==o.kind?o.findField(t.case)?{case:t.case,value:xm(t.value)}:{case:void 0}:xm(t);r[o.localName]=n}for(const o of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(r,o.no,o.wireType,o.data);return n}}),{newFieldList:Mm,initFields:Dm}),makeMessageType(e,t,n){return function(e,t,n,r){var o;const s=null!==(o=null==r?void 0:r.localName)&&void 0!==o?o:t.substring(t.lastIndexOf(".")+1),i={[s]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[s];return Object.setPrototypeOf(i.prototype,new lp),Object.assign(i,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary:(e,t)=>(new i).fromBinary(e,t),fromJson:(e,t)=>(new i).fromJson(e,t),fromJsonString:(e,t)=>(new i).fromJsonString(e,t),equals:(t,n)=>e.util.equals(i,t,n)}),i}(this,e,t,n)},makeEnum:ip,makeEnumType:sp,getEnumType:rp,makeExtension(e,t,n){return function(e,t,n,r){let o;return{typeName:t,extendee:n,get field(){if(!o){const n="function"==typeof r?r():r;n.name=t.split(".").pop(),n.jsonName=`[${t}]`,o=e.util.newFieldList([n]).list()[0]}return o},runtime:e}}(this,e,t,n)}});var Mm,Dm,Om,Rm,Pm,Lm,zm,Fm,Bm,Um,$m,Hm,Vm,Wm,Gm,qm;(Rm=Om||(Om={}))[Rm.Unary=0]="Unary",Rm[Rm.ServerStreaming=1]="ServerStreaming",Rm[Rm.ClientStreaming=2]="ClientStreaming",Rm[Rm.BiDiStreaming=3]="BiDiStreaming",(Lm=Pm||(Pm={}))[Lm.NoSideEffects=1]="NoSideEffects",Lm[Lm.Idempotent=2]="Idempotent",(Fm=zm||(zm={}))[Fm.UNSPECIFIED=0]="UNSPECIFIED",Fm[Fm.JUPYTER_FORMAT=77]="JUPYTER_FORMAT",Tm.util.setEnumType(zm,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]),(Um=Bm||(Bm={}))[Um.CODEIUM=0]="CODEIUM",Tm.util.setEnumType(Bm,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]),(Hm=$m||($m={}))[Hm.UNSPECIFIED=0]="UNSPECIFIED",Hm[Hm.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",Hm[Hm.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",Hm[Hm.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",Hm[Hm.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION",Tm.util.setEnumType($m,"exa.codeium_common_pb.EventType",[{no:0,name:"EVENT_TYPE_UNSPECIFIED"},{no:1,name:"EVENT_TYPE_ENABLE_CODEIUM"},{no:2,name:"EVENT_TYPE_DISABLE_CODEIUM"},{no:3,name:"EVENT_TYPE_SHOW_PREVIOUS_COMPLETION"},{no:4,name:"EVENT_TYPE_SHOW_NEXT_COMPLETION"}]),(Wm=Vm||(Vm={}))[Wm.UNSPECIFIED=0]="UNSPECIFIED",Wm[Wm.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",Wm[Wm.CACHE=2]="CACHE",Wm[Wm.NETWORK=3]="NETWORK",Tm.util.setEnumType(Vm,"exa.codeium_common_pb.CompletionSource",[{no:0,name:"COMPLETION_SOURCE_UNSPECIFIED"},{no:1,name:"COMPLETION_SOURCE_TYPING_AS_SUGGESTED"},{no:2,name:"COMPLETION_SOURCE_CACHE"},{no:3,name:"COMPLETION_SOURCE_NETWORK"}]),(qm=Gm||(Gm={}))[qm.UNSPECIFIED=0]="UNSPECIFIED",qm[qm.C=1]="C",qm[qm.CLOJURE=2]="CLOJURE",qm[qm.COFFEESCRIPT=3]="COFFEESCRIPT",qm[qm.CPP=4]="CPP",qm[qm.CSHARP=5]="CSHARP",qm[qm.CSS=6]="CSS",qm[qm.CUDACPP=7]="CUDACPP",qm[qm.DOCKERFILE=8]="DOCKERFILE",qm[qm.GO=9]="GO",qm[qm.GROOVY=10]="GROOVY",qm[qm.HANDLEBARS=11]="HANDLEBARS",qm[qm.HASKELL=12]="HASKELL",qm[qm.HCL=13]="HCL",qm[qm.HTML=14]="HTML",qm[qm.INI=15]="INI",qm[qm.JAVA=16]="JAVA",qm[qm.JAVASCRIPT=17]="JAVASCRIPT",qm[qm.JSON=18]="JSON",qm[qm.JULIA=19]="JULIA",qm[qm.KOTLIN=20]="KOTLIN",qm[qm.LATEX=21]="LATEX",qm[qm.LESS=22]="LESS",qm[qm.LUA=23]="LUA",qm[qm.MAKEFILE=24]="MAKEFILE",qm[qm.MARKDOWN=25]="MARKDOWN",qm[qm.OBJECTIVEC=26]="OBJECTIVEC",qm[qm.OBJECTIVECPP=27]="OBJECTIVECPP",qm[qm.PERL=28]="PERL",qm[qm.PHP=29]="PHP",qm[qm.PLAINTEXT=30]="PLAINTEXT",qm[qm.PROTOBUF=31]="PROTOBUF",qm[qm.PBTXT=32]="PBTXT",qm[qm.PYTHON=33]="PYTHON",qm[qm.R=34]="R",qm[qm.RUBY=35]="RUBY",qm[qm.RUST=36]="RUST",qm[qm.SASS=37]="SASS",qm[qm.SCALA=38]="SCALA",qm[qm.SCSS=39]="SCSS",qm[qm.SHELL=40]="SHELL",qm[qm.SQL=41]="SQL",qm[qm.STARLARK=42]="STARLARK",qm[qm.SWIFT=43]="SWIFT",qm[qm.TSX=44]="TSX",qm[qm.TYPESCRIPT=45]="TYPESCRIPT",qm[qm.VISUALBASIC=46]="VISUALBASIC",qm[qm.VUE=47]="VUE",qm[qm.XML=48]="XML",qm[qm.XSL=49]="XSL",qm[qm.YAML=50]="YAML",qm[qm.SVELTE=51]="SVELTE",qm[qm.TOML=52]="TOML",qm[qm.DART=53]="DART",qm[qm.RST=54]="RST",qm[qm.OCAML=55]="OCAML",qm[qm.CMAKE=56]="CMAKE",qm[qm.PASCAL=57]="PASCAL",qm[qm.ELIXIR=58]="ELIXIR",qm[qm.FSHARP=59]="FSHARP",qm[qm.LISP=60]="LISP",qm[qm.MATLAB=61]="MATLAB",qm[qm.POWERSHELL=62]="POWERSHELL",qm[qm.SOLIDITY=63]="SOLIDITY",qm[qm.ADA=64]="ADA",qm[qm.OCAML_INTERFACE=65]="OCAML_INTERFACE",Tm.util.setEnumType(Gm,"exa.codeium_common_pb.Language",[{no:0,name:"LANGUAGE_UNSPECIFIED"},{no:1,name:"LANGUAGE_C"},{no:2,name:"LANGUAGE_CLOJURE"},{no:3,name:"LANGUAGE_COFFEESCRIPT"},{no:4,name:"LANGUAGE_CPP"},{no:5,name:"LANGUAGE_CSHARP"},{no:6,name:"LANGUAGE_CSS"},{no:7,name:"LANGUAGE_CUDACPP"},{no:8,name:"LANGUAGE_DOCKERFILE"},{no:9,name:"LANGUAGE_GO"},{no:10,name:"LANGUAGE_GROOVY"},{no:11,name:"LANGUAGE_HANDLEBARS"},{no:12,name:"LANGUAGE_HASKELL"},{no:13,name:"LANGUAGE_HCL"},{no:14,name:"LANGUAGE_HTML"},{no:15,name:"LANGUAGE_INI"},{no:16,name:"LANGUAGE_JAVA"},{no:17,name:"LANGUAGE_JAVASCRIPT"},{no:18,name:"LANGUAGE_JSON"},{no:19,name:"LANGUAGE_JULIA"},{no:20,name:"LANGUAGE_KOTLIN"},{no:21,name:"LANGUAGE_LATEX"},{no:22,name:"LANGUAGE_LESS"},{no:23,name:"LANGUAGE_LUA"},{no:24,name:"LANGUAGE_MAKEFILE"},{no:25,name:"LANGUAGE_MARKDOWN"},{no:26,name:"LANGUAGE_OBJECTIVEC"},{no:27,name:"LANGUAGE_OBJECTIVECPP"},{no:28,name:"LANGUAGE_PERL"},{no:29,name:"LANGUAGE_PHP"},{no:30,name:"LANGUAGE_PLAINTEXT"},{no:31,name:"LANGUAGE_PROTOBUF"},{no:32,name:"LANGUAGE_PBTXT"},{no:33,name:"LANGUAGE_PYTHON"},{no:34,name:"LANGUAGE_R"},{no:35,name:"LANGUAGE_RUBY"},{no:36,name:"LANGUAGE_RUST"},{no:37,name:"LANGUAGE_SASS"},{no:38,name:"LANGUAGE_SCALA"},{no:39,name:"LANGUAGE_SCSS"},{no:40,name:"LANGUAGE_SHELL"},{no:41,name:"LANGUAGE_SQL"},{no:42,name:"LANGUAGE_STARLARK"},{no:43,name:"LANGUAGE_SWIFT"},{no:44,name:"LANGUAGE_TSX"},{no:45,name:"LANGUAGE_TYPESCRIPT"},{no:46,name:"LANGUAGE_VISUALBASIC"},{no:47,name:"LANGUAGE_VUE"},{no:48,name:"LANGUAGE_XML"},{no:49,name:"LANGUAGE_XSL"},{no:50,name:"LANGUAGE_YAML"},{no:51,name:"LANGUAGE_SVELTE"},{no:52,name:"LANGUAGE_TOML"},{no:53,name:"LANGUAGE_DART"},{no:54,name:"LANGUAGE_RST"},{no:55,name:"LANGUAGE_OCAML"},{no:56,name:"LANGUAGE_CMAKE"},{no:57,name:"LANGUAGE_PASCAL"},{no:58,name:"LANGUAGE_ELIXIR"},{no:59,name:"LANGUAGE_FSHARP"},{no:60,name:"LANGUAGE_LISP"},{no:61,name:"LANGUAGE_MATLAB"},{no:62,name:"LANGUAGE_POWERSHELL"},{no:63,name:"LANGUAGE_SOLIDITY"},{no:64,name:"LANGUAGE_ADA"},{no:65,name:"LANGUAGE_OCAML_INTERFACE"}]);const Ym=class e extends lp{constructor(e){super(),n(this,"completionId",""),n(this,"text",""),n(this,"prefix",""),n(this,"stop",""),n(this,"score",0),n(this,"tokens",[]),n(this,"decodedTokens",[]),n(this,"probabilities",[]),n(this,"adjustedProbabilities",[]),n(this,"generatedLength",vp.zero),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(Ym,"runtime",Tm),n(Ym,"typeName","exa.codeium_common_pb.Completion"),n(Ym,"fields",Tm.util.newFieldList((()=>[{no:1,name:"completion_id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"prefix",kind:"scalar",T:9},{no:4,name:"stop",kind:"scalar",T:9},{no:5,name:"score",kind:"scalar",T:1},{no:6,name:"tokens",kind:"scalar",T:4,repeated:!0},{no:7,name:"decoded_tokens",kind:"scalar",T:9,repeated:!0},{no:8,name:"probabilities",kind:"scalar",T:1,repeated:!0},{no:9,name:"adjusted_probabilities",kind:"scalar",T:1,repeated:!0},{no:10,name:"generated_length",kind:"scalar",T:4}])));let Xm=Ym;const Jm=class e extends lp{constructor(e){super(),n(this,"ideName",""),n(this,"ideVersion",""),n(this,"extensionName",""),n(this,"extensionVersion",""),n(this,"apiKey",""),n(this,"locale",""),n(this,"sessionId",""),n(this,"requestId",vp.zero),n(this,"userAgent",""),n(this,"url",""),n(this,"authSource",Bm.CODEIUM),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(Jm,"runtime",Tm),n(Jm,"typeName","exa.codeium_common_pb.Metadata"),n(Jm,"fields",Tm.util.newFieldList((()=>[{no:1,name:"ide_name",kind:"scalar",T:9},{no:7,name:"ide_version",kind:"scalar",T:9},{no:12,name:"extension_name",kind:"scalar",T:9},{no:2,name:"extension_version",kind:"scalar",T:9},{no:3,name:"api_key",kind:"scalar",T:9},{no:4,name:"locale",kind:"scalar",T:9},{no:10,name:"session_id",kind:"scalar",T:9},{no:9,name:"request_id",kind:"scalar",T:4},{no:13,name:"user_agent",kind:"scalar",T:9},{no:14,name:"url",kind:"scalar",T:9},{no:15,name:"auth_source",kind:"enum",T:Tm.getEnumType(Bm)}])));let Km=Jm;const Zm=class e extends lp{constructor(e){super(),n(this,"tabSize",vp.zero),n(this,"insertSpaces",!1),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(Zm,"runtime",Tm),n(Zm,"typeName","exa.codeium_common_pb.EditorOptions"),n(Zm,"fields",Tm.util.newFieldList((()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}])));let Qm=Zm;e=class extends lp{constructor(e){super(),n(this,"eventType",$m.UNSPECIFIED),n(this,"eventJson",""),n(this,"timestampUnixMs",vp.zero),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}},n(e,"runtime",Tm),n(e,"typeName","exa.codeium_common_pb.Event"),n(e,"fields",Tm.util.newFieldList((()=>[{no:1,name:"event_type",kind:"enum",T:Tm.getEnumType($m)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}])));class eg extends or{constructor(e,t){super(),n(this,"index"),n(this,"total"),this.index=e,this.total=t}toDOM(){const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className="cm-codeium-cycle";const t=e.appendChild(document.createElement("span"));t.className="cm-codeium-cycle-explanation",t.innerText=`${this.index+1}/${this.total}`;const n=e.appendChild(document.createElement("button"));return n.className="cm-codeium-cycle-key",n.innerText="→ (Ctrl ])",n.dataset.action="codeium-cycle",e}ignoreEvent(){return!1}}const tg=sr.define({combine:e=>ir(e,{language:Gm.TYPESCRIPT,timeout:150,widgetClass:eg,alwaysOn:!0},{})}),ng=sr.define({combine:e=>ir(e,{override:()=>[]},{})}),rg=vn.mark({class:"cm-ghostText"}),og=xn.define({create:e=>null,update(e,t){var n;const r=t.state.facet(tg);for(const o of t.effects){if(o.is(Xf)){const{changeSpecs:e,index:t}=o.value,s=e[t].map((e=>rg.range(e.absoluteStartPos,e.absoluteEndPos))),i=null==(n=s.at(-1))?void 0:n.to;return{index:t,decorations:vn.set([...s,...void 0!==i&&e.length>1&&r.widgetClass?[vn.widget({widget:new r.widgetClass(t,e.length),side:1}).range(i)]:[]]),changeSpecs:e,reverseChangeSet:o.value.reverseChangeSet}}if(o.is(Jf))return null;if(o.is(Kf))return null}return e?{...e,decorations:e.decorations.map(t.changes),reverseChangeSet:e.reverseChangeSet.map(t.changes)}:e},provide:e=>yn.decorations.from(e,(e=>(null==e?void 0:e.decorations)||vn.none))}),sg=ar.define(),ig=ar.define();var ag,lg;function cg(e){const t=ag[e];return"string"!=typeof t?e.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,(e=>"_"+e.toLowerCase()))}let dg;(lg=ag||(ag={}))[lg.Canceled=1]="Canceled",lg[lg.Unknown=2]="Unknown",lg[lg.InvalidArgument=3]="InvalidArgument",lg[lg.DeadlineExceeded=4]="DeadlineExceeded",lg[lg.NotFound=5]="NotFound",lg[lg.AlreadyExists=6]="AlreadyExists",lg[lg.PermissionDenied=7]="PermissionDenied",lg[lg.ResourceExhausted=8]="ResourceExhausted",lg[lg.FailedPrecondition=9]="FailedPrecondition",lg[lg.Aborted=10]="Aborted",lg[lg.OutOfRange=11]="OutOfRange",lg[lg.Unimplemented=12]="Unimplemented",lg[lg.Internal=13]="Internal",lg[lg.Unavailable=14]="Unavailable",lg[lg.DataLoss=15]="DataLoss",lg[lg.Unauthenticated=16]="Unauthenticated";class ug extends Error{constructor(e,t=ag.Unknown,n,r,o){super(function(e,t){return e.length?`[${cg(t)}] ${e}`:`[${cg(t)}]`}(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(null!=n?n:{}),this.details=null!=r?r:[],this.cause=o}static from(e,t=ag.Unknown){return e instanceof ug?e:e instanceof Error?"AbortError"==e.name?new ug(e.message,ag.Canceled):new ug(e.message,t,void 0,void 0,e):new ug(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error&&(Object.getPrototypeOf(e)===ug.prototype||"ConnectError"===e.name&&"code"in e&&"number"==typeof e.code&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&"string"==typeof e.rawMessage&&"cause"in e)}findDetails(e){const t="typeName"in e?{findMessage:t=>t===e.typeName?e:void 0}:e,n=[];for(const o of this.details){if("getType"in o){t.findMessage(o.getType().typeName)&&n.push(o);continue}const e=t.findMessage(o.type);if(e)try{n.push(e.fromBinary(o.value))}catch(r){}}return n}}var hg=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}},fg=function(e){return this instanceof fg?(this.v=e,this):new fg(e)},pg=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),s=[];return r={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),r[Symbol.asyncIterator]=function(){return this},r;function i(e,t){o[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=o[e](t)).value instanceof fg?Promise.resolve(n.value.v).then(l,c):d(s[0][2],n)}catch(r){d(s[0][3],r)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function d(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}};function mg(e){return pg(this,arguments,(function*(){yield fg(yield*function(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){t[r]=e[r]?function(t){return(n=!n)?{value:fg(e[r](t)),done:!1}:o?o(t):t}:o}}(hg(e)))}))}var gg=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}},yg=function(e){return this instanceof yg?(this.v=e,this):new yg(e)},bg=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),s=[];return r={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),r[Symbol.asyncIterator]=function(){return this},r;function i(e,t){o[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=o[e](t)).value instanceof yg?Promise.resolve(n.value.v).then(l,c):d(s[0][2],n)}catch(r){d(s[0][3],r)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function d(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}};function xg(e,t){const n=function(){var n,r;return bg(this,arguments,(function*(){const o=yield yg(e);null===(n=null==t?void 0:t.onHeader)||void 0===n||n.call(t,o.header),yield yg(yield*function(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){t[r]=e[r]?function(t){return(n=!n)?{value:yg(e[r](t)),done:!1}:o?o(t):t}:o}}(gg(o.message))),null===(r=null==t?void 0:t.onTrailer)||void 0===r||r.call(t,o.trailer)}))}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function vg(e){if(!e.aborted)return;if(void 0!==e.reason)return e.reason;const t=new Error("This operation was aborted");return t.name="AbortError",t}function wg(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}function kg(e,t,n){const r="string"==typeof t?t:t.typeName,o="string"==typeof n?n:n.name;return e.toString().replace(/\/?$/,`/${r}/${o}`)}function Sg(e,t){return t instanceof e?t:new e(t)}function Cg(e,t){function n(t){return!0===t.done?t:{done:t.done,value:Sg(e,t.value)}}return{[Symbol.asyncIterator](){const e=t[Symbol.asyncIterator](),r={next:()=>e.next().then(n)};return void 0!==e.throw&&(r.throw=t=>e.throw(t).then(n)),void 0!==e.return&&(r.return=t=>e.return(t).then(n)),r}}}function Eg(e,t){var n;return null!==(n=null==t?void 0:t.concat().reverse().reduce(((e,t)=>t(e)),e))&&void 0!==n?n:e}function Ng(e){var t;const n=Object.assign({},e);return null!==(t=n.ignoreUnknownFields)&&void 0!==t||(n.ignoreUnknownFields=!0),n}function jg(e,t,n,r){const o=t?_g(e.I,r):Ig(e.I,n);return{parse:(t?_g(e.O,r):Ig(e.O,n)).parse,serialize:o.serialize}}function _g(e,t){return{parse(n){try{return e.fromBinary(n,t)}catch(r){const e=r instanceof Error?r.message:String(r);throw new ug(`parse binary: ${e}`,ag.InvalidArgument)}},serialize(e){try{return e.toBinary(t)}catch(n){const e=n instanceof Error?n.message:String(n);throw new ug(`serialize binary: ${e}`,ag.Internal)}}}}function Ig(e,t){var n,r;const o=null!==(n=null==t?void 0:t.textEncoder)&&void 0!==n?n:new TextEncoder,s=null!==(r=null==t?void 0:t.textDecoder)&&void 0!==r?r:new TextDecoder,i=Ng(t);return{parse(t){try{const n=s.decode(t);return e.fromJsonString(n,i)}catch(n){throw ug.from(n,ag.InvalidArgument)}},serialize(e){try{const t=e.toJsonString(i);return o.encode(t)}catch(t){throw ug.from(t,ag.Internal)}}}}const Ag=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function Tg(e,t,n){if(t&&new Headers(t).forEach(((e,t)=>n.metadata.append(t,e))),"object"!=typeof e||null==e||Array.isArray(e)||!("code"in e)||"string"!=typeof e.code)throw n;const r=function(e){if(!dg){dg={};for(const e of Object.values(ag))"string"!=typeof e&&(dg[cg(e)]=e)}return dg[e]}(e.code);if(void 0===r)throw n;const o=e.message;if(null!=o&&"string"!=typeof o)throw n;const s=new ug(null!=o?o:"",r,t);if("details"in e&&Array.isArray(e.details))for(const a of e.details){if(null===a||"object"!=typeof a||Array.isArray(a)||"string"!=typeof a.type||"string"!=typeof a.value||"debug"in a&&"object"!=typeof a.debug)throw n;try{s.details.push({type:a.type,value:Rp.dec(a.value),debug:a.debug})}catch(i){throw n}}return s}function Mg(e){const t=new ug("invalid end stream",ag.InvalidArgument);let n;try{n=JSON.parse("string"==typeof e?e:(new TextDecoder).decode(e))}catch(o){throw t}if("object"!=typeof n||null==n||Array.isArray(n))throw t;const r=new Headers;if("metadata"in n){if("object"!=typeof n.metadata||null==n.metadata||Array.isArray(n.metadata))throw t;for(const[e,o]of Object.entries(n.metadata)){if(!Array.isArray(o)||o.some((e=>"string"!=typeof e)))throw t;for(const t of o)r.append(e,t)}}return{metadata:r,error:"error"in n?Tg(n.error,r,t):void 0}}const Dg="Content-Type",Og="Content-Length",Rg="Content-Encoding",Pg="Accept-Encoding",Lg="Connect-Protocol-Version";function zg(e){const t=new Headers,n=new Headers;return e.forEach(((e,r)=>{r.toLowerCase().startsWith("trailer-")?n.set(r.substring(8),e):t.set(r,e)})),[t,n]}function Fg(e,t,n,r,o){const s=new Headers(null!=r?r:{});return void 0!==n&&s.set("Connect-Timeout-Ms",`${n}`),s.set(Dg,e==Om.Unary?t?"application/proto":"application/json":t?"application/connect+proto":"application/connect+json"),s.set(Lg,"1"),s}function Bg(e,t,n){const r=function(e){const t=null==e?void 0:e.match(Ag);if(!t)return;return{stream:!!t[1],binary:!!t[3]}}(n.get("Content-Type"));if(200!==t){const o=new ug(`HTTP ${t}`,function(e){switch(e){case 400:return ag.InvalidArgument;case 401:return ag.Unauthenticated;case 403:return ag.PermissionDenied;case 404:return ag.Unimplemented;case 408:return ag.DeadlineExceeded;case 409:return ag.Aborted;case 412:return ag.FailedPrecondition;case 413:case 431:return ag.ResourceExhausted;case 415:return ag.Internal;case 429:case 502:case 503:case 504:return ag.Unavailable;default:return ag.Unknown}}(t),n);if(e==Om.Unary&&r&&!r.binary)return{isUnaryError:!0,unaryError:o};throw o}return{isUnaryError:!1}}const Ug="application/";function $g(e,t,n){let r="?connect=v1";const o=e.header.get(Dg);0===(null==o?void 0:o.indexOf(Ug))&&(r+="&encoding="+encodeURIComponent(o.slice(12)));const s=e.header.get(Rg);null!==s&&"identity"!==s&&(r+="&compression="+encodeURIComponent(s),n=!0),n&&(r+="&base64=1"),r+="&message="+function(e,t){return t?Rp.enc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent((new TextDecoder).decode(e))}(t,n);const i=e.url+r,a=new Headers(e.header);return[Lg,Dg,Og,Rg,Pg].forEach((e=>a.delete(e))),Object.assign(Object.assign({},e),{init:Object.assign(Object.assign({},e.init),{method:"GET"}),url:i,header:a})}function Hg(e){const{signal:t,cleanup:n}=function(e){const t=new AbortController,n=()=>{t.abort(new ug("the operation timed out",ag.DeadlineExceeded))};let r;return void 0!==e&&(e<=0?n():r=setTimeout(n,e)),{signal:t.signal,cleanup:()=>clearTimeout(r)}}(e.timeoutMs),r=function(...e){const t=new AbortController,n=e.filter((e=>void 0!==e)).concat(t.signal);for(const o of n){if(o.aborted){r.apply(o);break}o.addEventListener("abort",r)}function r(){t.signal.aborted||t.abort(vg(this));for(const e of n)e.removeEventListener("abort",r)}return t}(e.signal,t);return[r.signal,function(e){const o=ug.from(t.aborted?vg(t):e);return r.abort(o),n(),Promise.reject(o)},function(){n(),r.abort()}]}var Vg,Wg,Gg,qg,Yg,Xg;(Wg=Vg||(Vg={}))[Wg.UNSPECIFIED=0]="UNSPECIFIED",Wg[Wg.INACTIVE=1]="INACTIVE",Wg[Wg.PROCESSING=2]="PROCESSING",Wg[Wg.SUCCESS=3]="SUCCESS",Wg[Wg.WARNING=4]="WARNING",Wg[Wg.ERROR=5]="ERROR",Tm.util.setEnumType(Vg,"exa.language_server_pb.CodeiumState",[{no:0,name:"CODEIUM_STATE_UNSPECIFIED"},{no:1,name:"CODEIUM_STATE_INACTIVE"},{no:2,name:"CODEIUM_STATE_PROCESSING"},{no:3,name:"CODEIUM_STATE_SUCCESS"},{no:4,name:"CODEIUM_STATE_WARNING"},{no:5,name:"CODEIUM_STATE_ERROR"}]),(qg=Gg||(Gg={}))[qg.UNSPECIFIED=0]="UNSPECIFIED",qg[qg.SINGLE=1]="SINGLE",qg[qg.MULTI=2]="MULTI",Tm.util.setEnumType(Gg,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]),(Xg=Yg||(Yg={}))[Xg.UNSPECIFIED=0]="UNSPECIFIED",Xg[Xg.INLINE=1]="INLINE",Xg[Xg.BLOCK=2]="BLOCK",Xg[Xg.INLINE_MASK=3]="INLINE_MASK",Tm.util.setEnumType(Yg,"exa.language_server_pb.CompletionPartType",[{no:0,name:"COMPLETION_PART_TYPE_UNSPECIFIED"},{no:1,name:"COMPLETION_PART_TYPE_INLINE"},{no:2,name:"COMPLETION_PART_TYPE_BLOCK"},{no:3,name:"COMPLETION_PART_TYPE_INLINE_MASK"}]);const Jg=class e extends lp{constructor(e){super(),n(this,"threshold",0),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(Jg,"runtime",Tm),n(Jg,"typeName","exa.language_server_pb.MultilineConfig"),n(Jg,"fields",Tm.util.newFieldList((()=>[{no:1,name:"threshold",kind:"scalar",T:2}])));let Kg=Jg;const Zg=class e extends lp{constructor(e){super(),n(this,"metadata"),n(this,"document"),n(this,"editorOptions"),n(this,"otherDocuments",[]),n(this,"experimentConfig"),n(this,"modelName",""),n(this,"multilineConfig"),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(Zg,"runtime",Tm),n(Zg,"typeName","exa.language_server_pb.GetCompletionsRequest"),n(Zg,"fields",Tm.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:Km},{no:2,name:"document",kind:"message",T:fy},{no:3,name:"editor_options",kind:"message",T:Qm},{no:5,name:"other_documents",kind:"message",T:fy,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:my},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:Kg}])));let Qg=Zg;const ey=class e extends lp{constructor(e){super(),n(this,"state"),n(this,"completionItems",[]),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(ey,"runtime",Tm),n(ey,"typeName","exa.language_server_pb.GetCompletionsResponse"),n(ey,"fields",Tm.util.newFieldList((()=>[{no:1,name:"state",kind:"message",T:yy},{no:2,name:"completion_items",kind:"message",T:Ey,repeated:!0}])));let ty=ey;const ny=class e extends lp{constructor(e){super(),n(this,"metadata"),n(this,"completionId",""),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(ny,"runtime",Tm),n(ny,"typeName","exa.language_server_pb.AcceptCompletionRequest"),n(ny,"fields",Tm.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:Km},{no:2,name:"completion_id",kind:"scalar",T:9}])));let ry=ny;const oy=class e extends lp{constructor(e){super(),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(oy,"runtime",Tm),n(oy,"typeName","exa.language_server_pb.AcceptCompletionResponse"),n(oy,"fields",Tm.util.newFieldList((()=>[])));let sy=oy;const iy=class e extends lp{constructor(e){super(),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(iy,"runtime",Tm),n(iy,"typeName","exa.language_server_pb.GetAuthTokenRequest"),n(iy,"fields",Tm.util.newFieldList((()=>[])));let ay=iy;const ly=class e extends lp{constructor(e){super(),n(this,"authToken",""),n(this,"uuid",""),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(ly,"runtime",Tm),n(ly,"typeName","exa.language_server_pb.GetAuthTokenResponse"),n(ly,"fields",Tm.util.newFieldList((()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}])));let cy=ly;const dy=class e extends lp{constructor(e){super(),n(this,"row",vp.zero),n(this,"col",vp.zero),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(dy,"runtime",Tm),n(dy,"typeName","exa.language_server_pb.DocumentPosition"),n(dy,"fields",Tm.util.newFieldList((()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}])));let uy=dy;const hy=class e extends lp{constructor(e){super(),n(this,"absolutePath",""),n(this,"relativePath",""),n(this,"text",""),n(this,"editorLanguage",""),n(this,"language",Gm.UNSPECIFIED),n(this,"cursorOffset",vp.zero),n(this,"cursorPosition"),n(this,"lineEnding",""),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(hy,"runtime",Tm),n(hy,"typeName","exa.language_server_pb.Document"),n(hy,"fields",Tm.util.newFieldList((()=>[{no:1,name:"absolute_path",kind:"scalar",T:9},{no:2,name:"relative_path",kind:"scalar",T:9},{no:3,name:"text",kind:"scalar",T:9},{no:4,name:"editor_language",kind:"scalar",T:9},{no:5,name:"language",kind:"enum",T:Tm.getEnumType(Gm)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:uy},{no:7,name:"line_ending",kind:"scalar",T:9}])));let fy=hy;const py=class e extends lp{constructor(e){super(),n(this,"forceEnableExperiments",[]),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(py,"runtime",Tm),n(py,"typeName","exa.language_server_pb.ExperimentConfig"),n(py,"fields",Tm.util.newFieldList((()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:Tm.getEnumType(zm),repeated:!0}])));let my=py;const gy=class e extends lp{constructor(e){super(),n(this,"state",Vg.UNSPECIFIED),n(this,"message",""),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(gy,"runtime",Tm),n(gy,"typeName","exa.language_server_pb.State"),n(gy,"fields",Tm.util.newFieldList((()=>[{no:1,name:"state",kind:"enum",T:Tm.getEnumType(Vg)},{no:2,name:"message",kind:"scalar",T:9}])));let yy=gy;const by=class e extends lp{constructor(e){super(),n(this,"startOffset",vp.zero),n(this,"endOffset",vp.zero),n(this,"startPosition"),n(this,"endPosition"),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(by,"runtime",Tm),n(by,"typeName","exa.language_server_pb.Range"),n(by,"fields",Tm.util.newFieldList((()=>[{no:1,name:"start_offset",kind:"scalar",T:4},{no:2,name:"end_offset",kind:"scalar",T:4},{no:3,name:"start_position",kind:"message",T:uy},{no:4,name:"end_position",kind:"message",T:uy}])));let xy=by;const vy=class e extends lp{constructor(e){super(),n(this,"text",""),n(this,"deltaCursorOffset",vp.zero),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(vy,"runtime",Tm),n(vy,"typeName","exa.language_server_pb.Suffix"),n(vy,"fields",Tm.util.newFieldList((()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}])));let wy=vy;const ky=class e extends lp{constructor(e){super(),n(this,"text",""),n(this,"offset",vp.zero),n(this,"type",Yg.UNSPECIFIED),n(this,"prefix",""),n(this,"line",vp.zero),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(ky,"runtime",Tm),n(ky,"typeName","exa.language_server_pb.CompletionPart"),n(ky,"fields",Tm.util.newFieldList((()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"offset",kind:"scalar",T:4},{no:3,name:"type",kind:"enum",T:Tm.getEnumType(Yg)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}])));let Sy=ky;const Cy=class e extends lp{constructor(e){super(),n(this,"completion"),n(this,"suffix"),n(this,"range"),n(this,"source",Vm.UNSPECIFIED),n(this,"completionParts",[]),Tm.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Tm.util.equals(e,t,n)}};n(Cy,"runtime",Tm),n(Cy,"typeName","exa.language_server_pb.CompletionItem"),n(Cy,"fields",Tm.util.newFieldList((()=>[{no:1,name:"completion",kind:"message",T:Xm},{no:5,name:"suffix",kind:"message",T:wy},{no:2,name:"range",kind:"message",T:xy},{no:3,name:"source",kind:"enum",T:Tm.getEnumType(Vm)},{no:8,name:"completion_parts",kind:"message",T:Sy,repeated:!0}])));let Ey=Cy;const Ny={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:Qg,O:ty,kind:Om.Unary},acceptCompletion:{name:"AcceptCompletion",I:ry,O:sy,kind:Om.Unary},getAuthToken:{name:"GetAuthToken",I:ay,O:cy,kind:Om.Unary}}};var jy=function(e){return this instanceof jy?(this.v=e,this):new jy(e)},_y=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),s=[];return r={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),r[Symbol.asyncIterator]=function(){return this},r;function i(e,t){o[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=o[e](t)).value instanceof jy?Promise.resolve(n.value.v).then(l,c):d(s[0][2],n)}catch(r){d(s[0][3],r)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function d(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}};const Iy=function(e){var t;!function(){try{new Headers}catch(e){throw new Error("connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.")}}();const n=null!==(t=e.useBinaryFormat)&&void 0!==t&&t;return{async unary(t,r,o,s,i,a,l){var c;const{serialize:d,parse:u}=jg(r,n,e.jsonOptions,e.binaryOptions);return s=void 0===s?e.defaultTimeoutMs:s<=0?void 0:s,await function(e){const t=Eg(e.next,e.interceptors),[n,r,o]=Hg(e);return t(Object.assign(Object.assign({},e.req),{message:Sg(e.req.method.I,e.req.message),signal:n})).then((e=>(o(),e)),r)}({interceptors:e.interceptors,signal:o,timeoutMs:s,req:{stream:!1,service:t,method:r,url:kg(e.baseUrl,t,r),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:Fg(r.kind,n,s,i),contextValues:null!=l?l:wg(),message:a},next:async o=>{var s;let i=null;!0===e.useHttpGet&&r.idempotency===Pm.NoSideEffects?o=$g(o,d(o.message),n):i=d(o.message);const a=null!==(s=e.fetch)&&void 0!==s?s:globalThis.fetch,l=await a(o.url,Object.assign(Object.assign({},o.init),{headers:o.header,signal:o.signal,body:i})),{isUnaryError:c,unaryError:h}=Bg(r.kind,l.status,l.headers);if(c)throw Tg(await l.json(),function(...e){const t=new Headers;for(const n of e)n.forEach(((e,n)=>{t.append(n,e)}));return t}(...zg(l.headers)),h);const[f,p]=zg(l.headers);return{stream:!1,service:t,method:r,header:f,message:n?u(new Uint8Array(await l.arrayBuffer())):r.O.fromJson(await l.json(),Ng(e.jsonOptions)),trailer:p}}})},async stream(t,r,o,s,i,a,l){var c;const{serialize:d,parse:u}=jg(r,n,e.jsonOptions,e.binaryOptions);function h(e,t,n){return _y(this,arguments,(function*(){const r=function(e){let t,n=new Uint8Array(0);function r(e){const t=new Uint8Array(n.length+e.length);t.set(n),t.set(e,n.length),n=t}return new ReadableStream({start(){t=e.getReader()},async pull(e){let o;for(;;){if(void 0===o&&n.byteLength>=5){let e=0;for(let t=1;t<5;t++)e=(e<<8)+n[t];o={flags:n[0],length:e}}if(void 0!==o&&n.byteLength>=o.length+5)break;const e=await t.read();if(e.done)break;r(e.value)}if(void 0===o)return 0==n.byteLength?void e.close():void e.error(new ug("premature end of stream",ag.DataLoss));const s=n.subarray(5,5+o.length);n=n.subarray(5+o.length),e.enqueue({flags:o.flags,data:s})}})}(e).getReader();let o=!1;for(;;){const e=yield jy(r.read());if(e.done)break;const{flags:s,data:i}=e.value;if(2&~s)yield yield jy(u(i));else{o=!0;const e=Mg(i);if(e.error){const t=e.error;throw n.forEach(((e,n)=>{t.metadata.append(n,e)})),t}e.metadata.forEach(((e,n)=>t.set(n,e)))}}if(!o)throw"missing EndStreamResponse"}))}async function f(e){if(r.kind!=Om.ServerStreaming)throw"The fetch API does not support streaming request bodies";const t=await e[Symbol.asyncIterator]().next();if(1==t.done)throw"missing request message";return function(e,t){const n=new Uint8Array(t.length+5);n.set(t,5);const r=new DataView(n.buffer,n.byteOffset,n.byteLength);return r.setUint8(0,e),r.setUint32(1,t.length),n}(0,d(t.value))}return s=void 0===s?e.defaultTimeoutMs:s<=0?void 0:s,await function(e){const t=Eg(e.next,e.interceptors),[n,r,o]=Hg(e),s=Object.assign(Object.assign({},e.req),{message:Cg(e.req.method.I,e.req.message),signal:n});let i=!1;return n.addEventListener("abort",(function(){var t,n;const r=e.req.message[Symbol.asyncIterator]();i||null===(t=r.throw)||void 0===t||t.call(r,this.reason).catch((()=>{})),null===(n=r.return)||void 0===n||n.call(r).catch((()=>{}))})),t(s).then((e=>Object.assign(Object.assign({},e),{message:{[Symbol.asyncIterator](){const t=e.message[Symbol.asyncIterator]();return{next:()=>t.next().then((e=>(1==e.done&&(i=!0,o()),e)),r)}}}})),r)}({interceptors:e.interceptors,timeoutMs:s,signal:o,req:{stream:!0,service:t,method:r,url:kg(e.baseUrl,t,r),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:Fg(r.kind,n,s,i),contextValues:null!=l?l:wg(),message:a},next:async t=>{var n;const o=null!==(n=e.fetch)&&void 0!==n?n:globalThis.fetch,s=await o(t.url,Object.assign(Object.assign({},t.init),{headers:t.header,signal:t.signal,body:await f(t.message)}));if(Bg(r.kind,s.status,s.headers),null===s.body)throw"missing response body";const i=new Headers;return Object.assign(Object.assign({},t),{header:s.headers,trailer:i,message:h(s.body,i,s.headers)})}})}}}({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}),Ay=(My=Iy,function(e,t){const n={};for(const[r,o]of Object.entries(e.methods)){const s=t(Object.assign(Object.assign({},o),{localName:r,service:e}));null!=s&&(n[r]=s)}return n}(Ty=Ny,(e=>{switch(e.kind){case Om.Unary:return function(e,t,n){return async function(r,o){var s,i;const a=await e.unary(t,n,null==o?void 0:o.signal,null==o?void 0:o.timeoutMs,null==o?void 0:o.headers,r,null==o?void 0:o.contextValues);return null===(s=null==o?void 0:o.onHeader)||void 0===s||s.call(o,a.header),null===(i=null==o?void 0:o.onTrailer)||void 0===i||i.call(o,a.trailer),a.message}}(My,Ty,e);case Om.ServerStreaming:return function(e,t,n){return function(r,o){return xg(e.stream(t,n,null==o?void 0:o.signal,null==o?void 0:o.timeoutMs,null==o?void 0:o.headers,mg([r]),null==o?void 0:o.contextValues),o)}}(My,Ty,e);case Om.ClientStreaming:return function(e,t,n){return async function(r,o){var s,i,a,l,c,d;const u=await e.stream(t,n,null==o?void 0:o.signal,null==o?void 0:o.timeoutMs,null==o?void 0:o.headers,r,null==o?void 0:o.contextValues);let h;null===(c=null==o?void 0:o.onHeader)||void 0===c||c.call(o,u.header);try{for(var f,p=!0,m=gg(u.message);!(s=(f=await m.next()).done);p=!0)l=f.value,p=!1,h=l}catch(g){i={error:g}}finally{try{p||s||!(a=m.return)||await a.call(m)}finally{if(i)throw i.error}}if(!h)throw new ug("protocol error: missing response message",ag.Internal);return null===(d=null==o?void 0:o.onTrailer)||void 0===d||d.call(o,u.trailer),h}}(My,Ty,e);case Om.BiDiStreaming:return function(e,t,n){return function(r,o){return xg(e.stream(t,n,null==o?void 0:o.signal,null==o?void 0:o.timeoutMs,null==o?void 0:o.headers,r,null==o?void 0:o.contextValues),o)}}(My,Ty,e);default:return null}})));var Ty,My;let Dy;try{Dy=crypto.randomUUID()}catch{Dy=function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(+e^(crypto.getRandomValues(new Uint8Array(1))[0]??0)&15>>+e/4).toString(16)))}()}async function Oy(e,t){const n=e.state.facet(tg),{override:r}=e.state.facet(ng),o=await r(),s=e.state,i=s.selection.main.head,a=s.doc.toString();try{const r=await async function({text:e,cursorOffset:t,config:n,otherDocuments:r}){return await Ay.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:n.apiKey,sessionId:Dy,authSource:n.authSource},document:{text:e,cursorOffset:BigInt(t),language:n.language,editorLanguage:"typescript",lineEnding:"\n"},editorOptions:{tabSize:2n,insertSpaces:!0},otherDocuments:r,multilineConfig:void 0},{headers:{Authorization:`Basic ${n.apiKey}-${Dy}`}})}({text:a,cursorOffset:i,config:n,otherDocuments:o});if(!r||0===r.completionItems.length)return;if(void 0!==t&&i!==t||"active"===lr(e.state)||!e.hasFocus)return;const l=r.completionItems.map((e=>{let t=0;return e.completionParts.filter((e=>3!==e.type)).map((e=>{const n=Number(e.offset),r=2===e.type?`\n${e.text}`:e.text,o={absoluteStartPos:t+n,absoluteEndPos:t+n+r.length,from:n,to:n,insert:r};return t+=r.length,o}))})),c=0,d=l.at(c);if(!d)return;const u=cr.of(d,s.doc.length),h=u.invert(s.doc);e.dispatch({changes:u,effects:Xf.of({index:c,reverseChangeSet:h,changeSpecs:l}),annotations:[ig.of(null),sg.of(null),dr.addToHistory.of(!1)]})}catch(l){console.warn("copilot completion failed",l),await new Promise((e=>setTimeout(e,300)))}}function Ry(){let e=null,t=0;return yn.updateListener.of((n=>{const r=n.view.state.facet(tg);if(!r.alwaysOn)return;if(!function(e){return e.docChanged&&!e.transactions.some((e=>e.effects.some((e=>e.is(Jf)||e.is(Kf)))))}(n))return;if(e&&clearTimeout(e),function(e){if(!e.view.hasFocus)return!0;if(e.state.field(og))return!0;if("active"===lr(e.state))return!0;for(const t of e.transactions)if(void 0!==t.annotation(sg))return!0}(n))return;const o=n.state.selection.main.head;r.shouldComplete&&!r.shouldComplete(new ur(n.view.state,o,!1))||(e=setTimeout((async()=>{o===t&&await Oy(n.view,t)}),r.timeout),t=o)}))}function Py(e){var t;const n=e.state.field(og);if(!n)return!1;const r=null==(t=n.reverseChangeSet)?void 0:t.invert(e.state.doc);e.dispatch({changes:n.reverseChangeSet,effects:Jf.of(null),annotations:[ig.of(null),sg.of(null),dr.addToHistory.of(!1)]});let o=0;return null==r||r.iterChangedRanges(((e,t,n,r)=>{o=r})),e.dispatch({changes:r,selection:gn.cursor(o),annotations:[sg.of(null),dr.addToHistory.of(!0)]}),!0}const Ly=e=>{const{state:t}=e,n=t.field(og);if(!n)return!1;const{changeSpecs:r}=n;if(r.length<2)return!1;const o=(n.index+1)%r.length,s=r.at(o);if(!s)return!1;const i=n.reverseChangeSet.apply(t.doc),a=cr.of(n.reverseChangeSet,t.doc.length).compose(cr.of(s,i.length)),l=cr.of(s,i.length).invert(i);return e.dispatch({changes:a,effects:Xf.of({index:o,reverseChangeSet:l,changeSpecs:r}),annotations:[ig.of(null),sg.of(null),dr.addToHistory.of(!1)]}),!0};function zy(e){const t=e.state.field(og);return!!t&&(e.dispatch({changes:t.reverseChangeSet,effects:Kf.of(null),annotations:[ig.of(null),sg.of(null),dr.addToHistory.of(!1)]}),!1)}function Fy(){return yn.domEventHandlers({keydown:(e,t)=>("]"!==e.key||!e.ctrlKey)&&("Shift"!==e.key&&"Control"!==e.key&&"Alt"!==e.key&&"Meta"!==e.key&&function(e,t){return!!e.state.field(og)&&("Tab"===t?Py(e):zy(e))}(t,e.key)),mouseup(e,t){const n=e.target;return"BUTTON"===n.nodeName&&"codeium-cycle"===n.dataset.action?(Ly(t),e.stopPropagation(),e.preventDefault(),!0):function(e){var t,n;let r=!1;const o=null==(t=e.state.selection.asSingle().ranges.at(0))?void 0:t.head,s=e.state.field(og);return!(void 0===o||!s)&&(null==(n=s.decorations)||n.between(o,o,(()=>{r=!0})),r)}(t)?Py(t):zy(t)}})}const By=e=>{const t=[];return"codeium"===e.copilot&&e.codeium_api_key&&t.push(function(e){return[tg.of(e),og,rr.highest(er.of([{key:"Ctrl-]",run:Ly}])),rr.highest(yn.updateListener.of((e=>{e.focusChanged&&zy(e.view)}))),rr.high(Fy()),Ry()]}({apiKey:e.codeium_api_key,language:Gm.PYTHON}),ng.of({override:async()=>[{text:hr(""),language:Gm.PYTHON,editorLanguage:"python"}]})),"github"===e.copilot&&t.push(Yf({delay:500,fetchFn:async e=>{if(!Sl())return"";if(0===e.doc.length)return"";await new Promise((e=>setTimeout(e,20)));const t=e.doc.toString(),n=function(e,t){const n=e.doc.toString(),r=t.split("\n").length-n.split("\n").length,o=function(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}(e.doc,e.selection.main.head);return o.line+=r,{doc:{source:t,tabSize:e.tabSize,indentSize:1,insertSpaces:!0,path:El,version:"replace_me",uri:`file://${El}`,relativePath:El,languageId:Nl,position:o}}}(e,hr(t)),r=function(e,t,n){if(0===e.completions.length)return"";const{displayText:r,position:o}=e.completions[0],s=o.character-t.character,i=s<0?r.slice(-s):r,a=n.doc.sliceString(n.selection.main.head,n.doc.length);for(let l=0;l<i.length;l++){const e=i.slice(l);if(a.startsWith(e))return i.slice(0,l)}return i}(await Cl().getCompletion(n),n.doc.position,e);return r&&w.debug("Copilot suggestion:",r),r}})),[...t,kl().slice(0,-2)]};const Uy=vn.mark({class:"underline"}),$y=bn.define(),Hy=bn.define(),Vy=xn.define({create:()=>vn.none,update(e,t){let n=e.map(t.changes);for(const r of t.effects)r.is($y)?n=e.update({add:[Uy.range(r.value.from,r.value.to)]}):r.is(Hy)&&(n=vn.none);return n},provide:e=>yn.decorations.from(e)});class Wy{constructor(e,t){this.view=void 0,this.commandClickMode=void 0,this.hoveredRange=void 0,this.onClick=void 0,this.keydown=e=>{"Meta"!==e.key&&"Control"!==e.key||(this.commandClickMode=!0,this.view.dom.addEventListener("mousemove",this.mousemove),this.view.dom.addEventListener("click",this.click))},this.keyup=e=>{"Meta"!==e.key&&"Control"!==e.key||this.exitCommandClickMode()},this.windowBlur=()=>{this.commandClickMode&&this.exitCommandClickMode()},this.mousemove=e=>{if(!e.metaKey&&!e.ctrlKey)return void this.exitCommandClickMode();if(!this.commandClickMode)return void this.clearUnderline();const t=this.view.posAtCoords({x:e.clientX,y:e.clientY});if(null==t)return void this.clearUnderline();const n=fr(this.view.state).cursorAt(t);if("VariableName"===n.name){const{from:e,to:r}=n;if(this.hoveredRange&&this.hoveredRange.from===e&&this.hoveredRange.to===r)return;this.clearUnderline(),this.hoveredRange={from:e,to:r,position:t},this.view.dispatch({effects:$y.of(this.hoveredRange)})}else this.clearUnderline()},this.click=e=>{if(this.hoveredRange){const t=this.view.state.doc.sliceString(this.hoveredRange.from,this.hoveredRange.to);e.preventDefault(),e.stopPropagation(),this.onClick(this.view,t),this.view.dispatch({selection:{head:this.hoveredRange.position,anchor:this.hoveredRange.position}})}},this.view=e,this.commandClickMode=!1,this.hoveredRange=null,this.onClick=t,window.addEventListener("keydown",this.keydown),window.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.windowBlur),window.addEventListener("mouseleave",this.windowBlur)}update(e){}destroy(){window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),window.removeEventListener("blur",this.windowBlur),window.removeEventListener("mouseleave",this.windowBlur),this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click)}exitCommandClickMode(){this.commandClickMode=!1,this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click),this.clearUnderline()}clearUnderline(){this.hoveredRange&&(this.view.dispatch({effects:Hy.of(null)}),this.hoveredRange=null)}}const Gy=({variant:e,settings:t,styles:n})=>{const r=yn.theme({"&":{backgroundColor:t.background,color:t.foreground},".cm-content":{caretColor:t.caret},".cm-cursor, .cm-dropCursor":{borderLeftColor:t.caret},"&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection":{backgroundColor:t.selection},".cm-activeLine":{backgroundColor:t.lineHighlight},".cm-gutters":{backgroundColor:t.gutterBackground,color:t.gutterForeground},".cm-activeLineGutter":{backgroundColor:t.lineHighlight}},{dark:"dark"===e}),o=mr.define(n);return[r,gr(o)]};Gy({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:yr.comment,color:"#404080"},{tag:[yr.string,yr.regexp],color:"#999999"},{tag:yr.number,color:"#7090B0"},{tag:[yr.bool,yr.null],color:"#8080A0"},{tag:[yr.punctuation,yr.derefOperator],color:"#805080"},{tag:yr.keyword,color:"#60B0FF"},{tag:yr.definitionKeyword,color:"#B0FFF0"},{tag:yr.moduleKeyword,color:"#60B0FF"},{tag:yr.operator,color:"#A0A0FF"},{tag:[yr.variableName,yr.self],color:"#008080"},{tag:yr.operatorKeyword,color:"#A0A0FF"},{tag:yr.controlKeyword,color:"#80A0FF"},{tag:yr.className,color:"#70E080"},{tag:[yr.function(yr.propertyName),yr.propertyName],color:"#50A0A0"},{tag:yr.tagName,color:"#009090"},{tag:yr.modifier,color:"#B0FFF0"},{tag:[yr.squareBracket,yr.attributeName],color:"#D0D0FF"}]}),Gy({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:yr.comment,color:"#787b8099"},{tag:yr.string,color:"#86b300"},{tag:yr.regexp,color:"#4cbf99"},{tag:[yr.number,yr.bool,yr.null],color:"#ffaa33"},{tag:yr.variableName,color:"#5c6166"},{tag:[yr.definitionKeyword,yr.modifier],color:"#fa8d3e"},{tag:[yr.keyword,yr.special(yr.brace)],color:"#fa8d3e"},{tag:yr.operator,color:"#ed9366"},{tag:yr.separator,color:"#5c6166b3"},{tag:yr.punctuation,color:"#5c6166"},{tag:[yr.definition(yr.propertyName),yr.function(yr.variableName)],color:"#f2ae49"},{tag:[yr.className,yr.definition(yr.typeName)],color:"#22a4e6"},{tag:[yr.tagName,yr.typeName,yr.self,yr.labelName],color:"#55b4d4"},{tag:yr.angleBracket,color:"#55b4d480"},{tag:yr.attributeName,color:"#f2ae49"}]}),Gy({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:yr.comment,color:"#6E6E6E"},{tag:[yr.string,yr.regexp,yr.special(yr.brace)],color:"#5C81B3"},{tag:yr.number,color:"#C1E1B8"},{tag:yr.bool,color:"#53667D"},{tag:[yr.definitionKeyword,yr.modifier,yr.function(yr.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[yr.keyword,yr.moduleKeyword,yr.operatorKeyword,yr.operator],color:"#697A8E",fontWeight:"bold"},{tag:[yr.variableName,yr.attributeName],color:"#708E67"},{tag:[yr.function(yr.variableName),yr.definition(yr.propertyName),yr.derefOperator],color:"#fff"},{tag:yr.tagName,color:"#A3D295"}]}),Gy({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:yr.comment,color:"#666666"},{tag:[yr.string,yr.special(yr.brace)],color:"#54BE0D"},{tag:yr.regexp,color:"#E9C062"},{tag:yr.number,color:"#CF6A4C"},{tag:[yr.keyword,yr.operator],color:"#5EA6EA"},{tag:yr.variableName,color:"#7587A6"},{tag:[yr.definitionKeyword,yr.modifier],color:"#F9EE98"},{tag:[yr.propertyName,yr.function(yr.variableName)],color:"#937121"},{tag:[yr.typeName,yr.angleBracket,yr.tagName],color:"#9B859D"}]}),Gy({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:yr.comment,color:"#6B4E32"},{tag:[yr.keyword,yr.operator,yr.derefOperator],color:"#EF5D32"},{tag:yr.className,color:"#EFAC32",fontWeight:"bold"},{tag:[yr.typeName,yr.propertyName,yr.function(yr.variableName),yr.definition(yr.variableName)],color:"#EFAC32"},{tag:yr.definition(yr.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:yr.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[yr.number,yr.bool],color:"#6C99BB"},{tag:[yr.variableName,yr.self],color:"#7DAF9C"},{tag:[yr.string,yr.special(yr.brace),yr.regexp],color:"#D9D762"},{tag:[yr.angleBracket,yr.tagName,yr.attributeName],color:"#EFCB43"}]}),Gy({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:yr.comment,color:"#404040"},{tag:[yr.string,yr.special(yr.brace),yr.regexp],color:"#00D8FF"},{tag:yr.number,color:"#E62286"},{tag:[yr.variableName,yr.attributeName,yr.self],color:"#E62286",fontWeight:"bold"},{tag:yr.function(yr.variableName),color:"#fff",fontWeight:"bold"}]}),Gy({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:yr.comment,color:"#BCC8BA"},{tag:[yr.string,yr.special(yr.brace),yr.regexp],color:"#5D90CD"},{tag:[yr.number,yr.bool,yr.null],color:"#46A609"},{tag:yr.keyword,color:"#AF956F"},{tag:[yr.definitionKeyword,yr.modifier],color:"#C52727"},{tag:[yr.angleBracket,yr.tagName,yr.attributeName],color:"#606060"},{tag:yr.self,color:"#000"}]}),Gy({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:yr.comment,color:"#0088FF"},{tag:yr.string,color:"#3AD900"},{tag:yr.regexp,color:"#80FFC2"},{tag:[yr.number,yr.bool,yr.null],color:"#FF628C"},{tag:[yr.definitionKeyword,yr.modifier],color:"#FFEE80"},{tag:yr.variableName,color:"#CCCCCC"},{tag:yr.self,color:"#FF80E1"},{tag:[yr.className,yr.definition(yr.propertyName),yr.function(yr.variableName),yr.definition(yr.typeName),yr.labelName],color:"#FFDD00"},{tag:[yr.keyword,yr.operator],color:"#FF9D00"},{tag:[yr.propertyName,yr.typeName],color:"#80FFBB"},{tag:yr.special(yr.brace),color:"#EDEF7D"},{tag:yr.attributeName,color:"#9EFFFF"},{tag:yr.derefOperator,color:"#fff"}]}),Gy({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:yr.comment,color:"#AEAEAE"},{tag:[yr.string,yr.special(yr.brace),yr.regexp],color:"#8DFF8E"},{tag:[yr.className,yr.definition(yr.propertyName),yr.function(yr.variableName),yr.function(yr.definition(yr.variableName)),yr.definition(yr.typeName)],color:"#A3EBFF"},{tag:[yr.number,yr.bool,yr.null],color:"#62E9BD"},{tag:[yr.keyword,yr.operator],color:"#2BF1DC"},{tag:[yr.definitionKeyword,yr.modifier],color:"#F8FBB1"},{tag:[yr.variableName,yr.self],color:"#B683CA"},{tag:[yr.angleBracket,yr.tagName,yr.typeName,yr.propertyName],color:"#60A4F1"},{tag:yr.derefOperator,color:"#E0E0E0"},{tag:yr.attributeName,color:"#7BACCA"}]}),Gy({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:yr.comment,color:"#6272a4"},{tag:[yr.string,yr.special(yr.brace)],color:"#f1fa8c"},{tag:[yr.number,yr.self,yr.bool,yr.null],color:"#bd93f9"},{tag:[yr.keyword,yr.operator],color:"#ff79c6"},{tag:[yr.definitionKeyword,yr.typeName],color:"#8be9fd"},{tag:yr.definition(yr.typeName),color:"#f8f8f2"},{tag:[yr.className,yr.definition(yr.propertyName),yr.function(yr.variableName),yr.attributeName],color:"#50fa7b"}]}),Gy({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:yr.comment,color:"#AAAAAA"},{tag:[yr.keyword,yr.operator,yr.typeName,yr.tagName,yr.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[yr.attributeName,yr.definition(yr.propertyName)],color:"#4F9FD0"},{tag:[yr.className,yr.string,yr.special(yr.brace)],color:"#CF4F5F"},{tag:yr.number,color:"#CF4F5F",fontWeight:"bold"},{tag:yr.variableName,fontWeight:"bold"}]}),Gy({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:yr.comment,color:"#9995b7"},{tag:yr.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[yr.definitionKeyword,yr.modifier],color:"#ff5792"},{tag:[yr.className,yr.tagName,yr.definition(yr.typeName)],color:"#0094f0"},{tag:[yr.number,yr.bool,yr.null,yr.special(yr.brace)],color:"#5842ff"},{tag:[yr.definition(yr.propertyName),yr.function(yr.variableName)],color:"#0095a8"},{tag:yr.typeName,color:"#b3694d"},{tag:[yr.propertyName,yr.variableName],color:"#fa8900"},{tag:yr.operator,color:"#ff5792"},{tag:yr.self,color:"#e64100"},{tag:[yr.string,yr.regexp],color:"#00b368"},{tag:[yr.paren,yr.bracket],color:"#0431fa"},{tag:yr.labelName,color:"#00bdd6"},{tag:yr.attributeName,color:"#e64100"},{tag:yr.angleBracket,color:"#9995b7"}]}),Gy({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:yr.comment,color:"#9893a5"},{tag:[yr.bool,yr.null],color:"#286983"},{tag:yr.number,color:"#d7827e"},{tag:yr.className,color:"#d7827e"},{tag:[yr.angleBracket,yr.tagName,yr.typeName],color:"#56949f"},{tag:yr.attributeName,color:"#907aa9"},{tag:yr.punctuation,color:"#797593"},{tag:[yr.keyword,yr.modifier],color:"#286983"},{tag:[yr.string,yr.regexp],color:"#ea9d34"},{tag:yr.variableName,color:"#d7827e"}]}),Gy({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:yr.comment,color:"#CFCFCF"},{tag:[yr.number,yr.bool,yr.null],color:"#E66C29"},{tag:[yr.className,yr.definition(yr.propertyName),yr.function(yr.variableName),yr.labelName,yr.definition(yr.typeName)],color:"#2EB43B"},{tag:yr.keyword,color:"#D8B229"},{tag:yr.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[yr.definitionKeyword,yr.modifier],color:"#925A47"},{tag:yr.string,color:"#704D3D"},{tag:yr.typeName,color:"#2F8996"},{tag:[yr.variableName,yr.propertyName],color:"#77ACB0"},{tag:yr.self,color:"#77ACB0",fontWeight:"bold"},{tag:yr.regexp,color:"#E3965E"},{tag:[yr.tagName,yr.angleBracket],color:"#BAA827"},{tag:yr.attributeName,color:"#B06520"},{tag:yr.derefOperator,color:"#000"}]}),Gy({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:yr.comment,color:"#93A1A1"},{tag:yr.string,color:"#2AA198"},{tag:yr.regexp,color:"#D30102"},{tag:yr.number,color:"#D33682"},{tag:yr.variableName,color:"#268BD2"},{tag:[yr.keyword,yr.operator,yr.punctuation],color:"#859900"},{tag:[yr.definitionKeyword,yr.modifier],color:"#073642",fontWeight:"bold"},{tag:[yr.className,yr.self,yr.definition(yr.propertyName)],color:"#268BD2"},{tag:yr.function(yr.variableName),color:"#268BD2"},{tag:[yr.bool,yr.null],color:"#B58900"},{tag:yr.tagName,color:"#268BD2",fontWeight:"bold"},{tag:yr.angleBracket,color:"#93A1A1"},{tag:yr.attributeName,color:"#93A1A1"},{tag:yr.typeName,color:"#859900"}]}),Gy({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:yr.comment,color:"#8E908C"},{tag:[yr.variableName,yr.self,yr.propertyName,yr.attributeName,yr.regexp],color:"#C82829"},{tag:[yr.number,yr.bool,yr.null],color:"#F5871F"},{tag:[yr.className,yr.typeName,yr.definition(yr.typeName)],color:"#C99E00"},{tag:[yr.string,yr.special(yr.brace)],color:"#718C00"},{tag:yr.operator,color:"#3E999F"},{tag:[yr.definition(yr.propertyName),yr.function(yr.variableName)],color:"#4271AE"},{tag:yr.keyword,color:"#8959A8"},{tag:yr.derefOperator,color:"#4D4D4C"}]});const qy=Gy({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#cceeff44",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:yr.comment,color:"#708090"},{tag:yr.variableName,color:"#000000"},{tag:[yr.string,yr.special(yr.brace)],color:"#a11"},{tag:yr.number,color:"#164"},{tag:yr.bool,color:"#219"},{tag:yr.null,color:"#219"},{tag:yr.keyword,color:"#708",fontWeight:500},{tag:yr.className,color:"#00f"},{tag:yr.definition(yr.typeName),color:"#00f"},{tag:yr.typeName,color:"#085"},{tag:yr.angleBracket,color:"#000000"},{tag:yr.tagName,color:"#170"},{tag:yr.attributeName,color:"#00c"},{tag:yr.operator,color:"#a2f",fontWeight:500},{tag:[yr.function(yr.variableName)],color:"#00c"},{tag:[yr.propertyName],color:"#05a"}]}),Yy=Gy({variant:"dark",settings:{background:"#282c34",foreground:"#abb2bf",caret:"#528bff",selection:"#3E4451",lineHighlight:"#2c313c",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:yr.comment,color:"#5c6370"},{tag:yr.variableName,color:"#abb2bf"},{tag:[yr.string,yr.special(yr.brace)],color:"#98c379"},{tag:yr.number,color:"#d19a66"},{tag:yr.bool,color:"#d19a66"},{tag:yr.null,color:"#d19a66"},{tag:yr.keyword,color:"#c678dd",fontWeight:500},{tag:yr.className,color:"#61afef"},{tag:yr.definition(yr.typeName),color:"#61afef"},{tag:yr.typeName,color:"#56b6c2"},{tag:yr.angleBracket,color:"#abb2bf"},{tag:yr.tagName,color:"#e06c75"},{tag:yr.attributeName,color:"#d19a66"},{tag:yr.operator,color:"#56b6c2",fontWeight:500},{tag:[yr.function(yr.variableName)],color:"#61afef"},{tag:[yr.propertyName],color:"#e5c07b"}]});const Xy="packages-install-input",Jy=["%alias","%cd","%clear","%debug","%env","%load","%load_ext","%lsmagic","%matplotlib","%pwd","%who_ls","%system","%%time","%%timeit","%%writefile","%%capture","%%html","%%latex"];let Ky;function Zy(){const e=async e=>{const t=K.get(wr),n={...t,runtime:{...t.runtime,auto_reload:e}};await S({config:n}).then((()=>K.set(wr,n)))},t=()=>{requestAnimationFrame((()=>{const e=document.getElementById(Xy);e&&e.focus()}))},n=[{match:"!pip install",onMatch:()=>{K.set(Uu,(e=>({...e,isSidebarOpen:!0,selectedPanel:"packages"}))),t()},title:"Package Installation",description:I.jsxs(I.Fragment,{children:["The package manager sidebar has been opened.",I.jsx("br",{}),"Install packages directly from there instead."]})},{match:"!uv pip install",onMatch:()=>{K.set(Uu,(e=>({...e,isSidebarOpen:!0,selectedPanel:"packages"}))),t()},title:"Package Installation",description:I.jsxs(I.Fragment,{children:["The package manager sidebar has been opened.",I.jsx("br",{}),"Install packages directly from there instead."]})},{match:"%autoreload 2",onMatch:async()=>{await e("autorun")},title:"Module reload",description:I.jsxs(I.Fragment,{children:["Module reload mode set to ",I.jsx("b",{children:"autorun"})," - module changes will re-run the cells that import them."]})},{match:"%autoreload 1",onMatch:async()=>{await e("lazy")},title:"Module reload",description:I.jsxs(I.Fragment,{children:["Module reload mode set to ",I.jsx("b",{children:"lazy"})," - module changes will mark the cells that import them as stale."]})},{match:"%autoreload 0",onMatch:async()=>{await e("off")},title:"Module reload",description:I.jsx(I.Fragment,{children:"Module reload disabled - module changes will not be detected."})},{match:"!ls",onMatch:()=>{},title:"Listing files",description:I.jsxs(I.Fragment,{children:["Shell commands are not directly supported.",I.jsx("br",{}),"Use ",I.jsx("code",{children:"import subprocess; subprocess.run(['ls'])"})," instead."]})},...Jy.map((e=>({match:e,onMatch:()=>{},title:I.jsx(vr,{className:"inline",children:e}),description:I.jsxs(I.Fragment,{children:["Magic commands are not supported in marimo. Read more about replacements in the"," ",I.jsx("a",{href:"https://docs.marimo.io/guides/coming_from/jupyter/#adapting-to-the-absence-of-magic-commands",target:"_blank",className:"text-link underline cursor-pointer",rel:"noopener noreferrer",children:"documentation"}),"."]})})))],r=new Map(n.map((e=>[e.match,e])));return yn.updateListener.of((e=>{if(e.docChanged){const t=e.state.selection.main,n=e.state.doc,o=n.lineAt(t.head),s=n.sliceString(o.from,t.anchor).trim(),i=r.get(s);i&&(i.onMatch(),Ky?Ky.upsert({title:i.title,description:i.description}):Ky=ee({title:i.title,description:i.description}))}}))}function Qy(){return[yn.domEventHandlers({paste:(e,t)=>{var n;const r=null==(n=e.clipboardData)?void 0:n.getData("text/plain");if(!(null==r?void 0:r.includes("@app.cell")))return!1;const o=function(e){if(!e.includes("@app.cell"))return[];const t=[],n=e.split("\n");let r=[],o=!1,s=0,i=!1,a=!1,l=0;const c=/\(/g,d=/\)/g,u=new Set(["@"]);function h(e){return(e.match(c)||[]).length-(e.match(d)||[]).length}function f(){if(0!==r.length){for(;r.length>0&&r[r.length-1].trim().startsWith("return");)r.pop();r.some((e=>""!==e.trim()))&&t.push(function(e){const t=e.split("\n");if(0===t.length)return"";const n=t.filter((e=>e.trim().length>0));if(0===n.length)return"";const r=/^\s*/,o=Math.min(...n.map((e=>{var t;return(null==(t=e.match(r))?void 0:t[0].length)??Number.POSITIVE_INFINITY})));return 0===o?e.trim():t.map((e=>e.slice(o))).join("\n").trim()}(r.join("\n"))),r=[]}}for(const p of n){const e=p.trim();(e||o)&&(e.startsWith("@app.cell")?(f(),o=!0,s=1):s>0?(e.startsWith("def")&&e.includes("(")&&!e.includes("):")&&(i=!0,l=h(e)),s--):i?(l+=h(e),0===l&&(i=!1)):o&&(u.has(e[0])||e.startsWith("if __name__")?(f(),o=e.startsWith("@")):e.startsWith("return")?e.includes("(")&&!e.endsWith(")")&&(a=!0,l=h(e)):a?(l+=h(e),0===l&&(a=!1)):r.push(p)))}return f(),t}(r);if(0===o.length)return!1;return t.state.facet(kr).createManyBelow(o),!0}})]}const eb={showInput:"Mod-l",acceptEdit:"Mod-y",rejectEdit:"Mod-u"},tb=sr.define({combine:e=>Object.assign({},...e)}),nb=bn.define(),rb=xn.define({create:()=>!1,update(e,t){for(const n of t.effects)if(n.is(nb))return n.value;return e},compare:(e,t)=>e===t}),ob=bn.define(),sb=xn.define({create:()=>({show:!1,from:0,to:0}),update(e,t){for(const n of t.effects)if(n.is(ob))return n.value;return e}}),ib=bn.define(),ab=xn.define({create:()=>null,update(e,t){for(const n of t.effects)if(n.is(ib))return n.value;return e}}),lb=bn.define(),cb=xn.define({create:()=>!1,update(e,t){for(const n of t.effects)if(n.is(lb))return n.value;return e}}),db=yn.baseTheme({".cm-ai-tooltip":{userSelect:"none",pointerEvents:"none",fontFamily:"system-ui, -apple-system, sans-serif",position:"absolute",right:"8px",padding:"2px 6px",borderRadius:"4px",fontSize:"12px",backgroundColor:"#0E639C",color:"#ffffff",border:"1px solid transparent",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",zIndex:"999","& > span":{pointerEvents:"auto",cursor:"pointer",display:"inline-block",padding:"2px"},"&:hover":{backgroundColor:"#1177bb"}},".cm-ai-input-container":{display:"flex",flexDirection:"column",gap:"4px",width:"calc(100% + 7px)",padding:"5px 5px",margin:"0 -6px",backgroundColor:"light-dark(rgb(241, 243, 245), rgb(40, 40, 40))"},".cm-ai-input":{display:"block",width:"100%",padding:"3px 8px",border:"2px solid rgb(51, 154, 240)",borderRadius:"5px",fontSize:"12px"},".cm-ai-help-info":{fontSize:"10px",paddingLeft:"10px",height:"18px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))"},".cm-ai-generate-btn":{background:"#0E639C",border:"none",padding:"2px 6px",color:"#ffffff",cursor:"pointer",font:"inherit",borderRadius:"4px","&:hover":{backgroundColor:"#1177bb"}},".cm-line.cm-ai-selection, .cm-line.cm-ai-selection.cm-active-line":{backgroundColor:"light-dark(color-mix(in srgb, rgb(223, 227, 232) 50%, transparent), color-mix(in srgb, rgb(50, 50, 50) 50%, transparent)) !important"},".cm-line:has(.cm-new-code-line)":{backgroundColor:"light-dark(color-mix(in srgb, rgb(183, 235, 143) 50%, transparent), color-mix(in srgb, rgb(40, 100, 40) 50%, transparent)) !important"},".cm-old-code-container":{backgroundColor:"light-dark(rgb(255, 205, 205), rgb(100, 40, 40))",position:"relative",display:"flex",width:"100%",alignItems:"center"},".cm-code-button":{position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"16px"},".cm-floating-buttons":{fontFamily:"sans-serif",position:"absolute",bottom:"0",right:"0",display:"flex"},".cm-floating-button":{fontFamily:"sans-serif",padding:"2px 5px",fontSize:"10px",cursor:"pointer",fontWeight:"700"},".cm-floating-accept":{backgroundColor:"light-dark(rgb(55, 125, 34), rgb(40, 80, 25))",borderTopLeftRadius:"5px",borderBottomLeftRadius:"5px",opacity:"0.8",color:"white","&:hover":{opacity:"1"}},".cm-floating-reject":{backgroundColor:"light-dark(rgb(220, 53, 69), rgb(180, 40, 50))",color:"white",borderTopRightRadius:"5px",opacity:"0.8",borderBottomRightRadius:"5px","&:hover":{opacity:"1"}},".hotkey":{display:"inline-block",padding:"0 4px",borderRadius:"3px",backgroundColor:"rgba(255, 255, 255, 0.1)",fontSize:"90%"},".cm-ai-loading-indicator":{fontStyle:"italic",fontSize:"10px",paddingLeft:"12px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",opacity:"0",transition:"opacity 0.3s ease-in-out","&::after":{content:'""',display:"inline-block",animation:"ellipsis-pulse 1.5s steps(4, end) infinite"},"&:not(:empty)":{opacity:"1"}},".cm-ai-input:disabled":{opacity:"0.5"},"@keyframes ellipsis-pulse":{"0%":{content:"'.'"},"25%":{content:"'..'"},"50%":{content:"'...'"},"75%":{content:"''"}},".cm-ai-loading-container":{display:"flex",alignItems:"center",padding:"0 8px"},".cm-ai-cancel-btn":{padding:"2px 8px",fontSize:"10px",borderRadius:"4px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",cursor:"pointer","&:hover":{background:"light-dark(rgb(223, 227, 232), rgb(50, 50, 50))"}},".hidden":{display:"none"}}),ub="⌘",hb="⊞ Win",fb="Ctrl";function pb(e){if(!e.prompt)throw new Error("prompt function is required");const t={onAcceptEdit:e.onAcceptEdit,onRejectEdit:e.onRejectEdit,onError:e.onError||console.error,inputDebounceTime:e.inputDebounceTime||300,keymaps:{...eb,...e.keymaps}};return[tb.of(t),rb,sb,ab,cb,mb,db,er.of([{key:eb.showInput,run:gb}]),rr.highest([er.of([{key:eb.acceptEdit,run:yb},{key:eb.rejectEdit,run:bb}])]),yn.updateListener.of((e=>{if(e.selectionSet){const{from:t,to:n}=e.state.selection.main,r=e.state.field(sb),o=e.state.field(ab),s=e.state.field(rb),i=t!==n&&!r.show&&!o;s!==i&&e.view.dispatch({effects:nb.of(i)})}})),yn.decorations.of((e=>{const t=e.state.field(ab);return t?vn.set([vn.mark({class:"cm-new-code-line"}).range(t.from,t.to)]):vn.none})),yn.decorations.compute(["doc",sb],(t=>{const n=t.field(sb),r=[];if(n.show)for(let o=n.from;o<n.to;o++)r.push(vn.line({class:"cm-ai-selection"}).range(o)),o===n.from&&r.push(vn.widget({widget:new wb(e.prompt),side:-1}).range(n.from));return vn.set(r)})),xn.define({create:e=>vn.none,update(e,t){const n=t.state.field(ab);return n?vn.set([vn.widget({widget:new xb(n.oldCode),block:!0}).range(n.from)]):vn.none},provide:e=>yn.decorations.from(e)})]}const mb=wn.fromClass(class{constructor(e){n(this,"decorations"),n(this,"tooltip",null),this.decorations=this.createDecorations(e)}update(e){const t=e.startState.doc,n=e.state.doc,r=e.startState.selection.main,o=e.state.selection.main;(t.lineAt(r.from).number!==n.lineAt(o.from).number||e.docChanged||e.viewportChanged||e.transactions.some((e=>e.effects.some((e=>e.is(nb))))))&&(this.decorations=this.createDecorations(e.view))}createDecorations(e){var t;const{from:n,to:r}=e.state.selection.main,o=e.state.field(sb),s=e.state.field(ab),i=e.state.field(rb),a=e.state.doc;if(n===r||o.show||s||!i||n<0||r>a.length)return vn.none;let l=n,c=r;for(;l<c&&0===a.lineAt(l).length;)l=a.lineAt(l+1).from;for(;c>l&&0===a.lineAt(c).length;)c=a.lineAt(c-1).to;if(l===c)return vn.none;if(!this.tooltip){const n=e.state.facet(tb),r={...eb,...n.keymaps};this.tooltip=document.createElement("div"),this.tooltip.className="cm-ai-tooltip",this.tooltip.innerHTML=`<span>Edit <span class="hotkey">${vb(r.showInput)}</span></span>`,null==(t=this.tooltip.querySelector("span"))||t.addEventListener("click",(t=>{t.stopPropagation(),gb(e)}))}const d=this.tooltip;return vn.set([vn.widget({widget:new class extends or{toDOM(){return d}ignoreEvent(){return!0}},side:-1}).range(l)])}destroy(){var e;null==(e=this.tooltip)||e.remove(),this.tooltip=null}},{decorations:e=>e.decorations}),gb=e=>{const{state:t}=e,n=t.selection.main;if(n.from===n.to)return e.dispatch({effects:[nb.of(!1)]}),!1;const r=t.doc,o=r.lineAt(n.from),s=r.lineAt(n.to);if(t.sliceDoc(n.from,n.to).trim().length<1)return!1;const i=Math.max(0,Math.min(o.from,r.length)),a=Math.max(0,Math.min(s.to,r.length));return e.dispatch({effects:[ob.of({show:!0,from:i,to:a}),nb.of(!1)],selection:gn.cursor(i)}),!0},yb=e=>!!e.state.field(ab)&&(e.dispatch({effects:[ib.of(null),ob.of({show:!1,from:0,to:0}),lb.of(!1)]}),!0),bb=e=>{const t=e.state.field(ab);return!!t&&(e.dispatch({changes:{from:t.from,to:t.to,insert:t.oldCode},effects:[ib.of(null),ob.of({show:!1,from:0,to:0}),lb.of(!1)]}),!0)};class xb extends or{constructor(e){super(),n(this,"oldCode"),this.oldCode=e}toDOM(e){const t=document.createElement("div");t.className="cm-old-code-container",t.setAttribute("role","region"),t.setAttribute("aria-label","Previous code version");const n=document.createElement("div");n.className="cm-old-code cm-line",n.textContent=this.oldCode;const r=document.createElement("div");r.className="cm-floating-buttons";const o=e.state.facet(tb),s={...eb,...o.keymaps},i=document.createElement("button");i.innerHTML=`<span class="hotkey">${vb(s.acceptEdit)}</span> Accept`,i.className="cm-floating-button cm-floating-accept",i.setAttribute("aria-label","Accept changes"),i.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),e.focus(),yb(e)}));const a=document.createElement("button");return a.innerHTML=`<span class="hotkey">${vb(s.rejectEdit)}</span> Reject`,a.className="cm-floating-button cm-floating-reject",a.setAttribute("aria-label","Reject changes"),a.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),e.focus(),bb(e)})),r.append(i,a),t.append(n,r),t}updateDOM(e,t){return!0}}function vb(e){return e.replace("Mod",navigator.platform.startsWith("Mac")?ub:navigator.platform.startsWith("Win")?hb:fb).replace("-"," ").toUpperCase()}class wb extends or{constructor(e){super(),n(this,"complete"),n(this,"abortController",null),this.complete=e}toDOM(e){const t=e.state.facet(tb),n=document.createElement("div");n.className="cm-ai-input-container";const r=document.createElement("form");r.className="cm-ai-input-form",r.setAttribute("role","search"),r.setAttribute("aria-label","AI editing instructions"),r.addEventListener("submit",(e=>e.preventDefault()));const o=document.createElement("input");o.className="cm-ai-input",o.placeholder="Editing instructions...",o.setAttribute("aria-label","AI editing instructions"),o.setAttribute("autocomplete","off"),o.setAttribute("spellcheck","true");const s=document.createElement("div");s.className="cm-ai-loading-container";const i=document.createElement("div");i.classList.add("cm-ai-loading-indicator"),i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.textContent="Generating";const a=document.createElement("button");a.className="cm-ai-cancel-btn",a.textContent="Cancel",a.setAttribute("aria-label","Cancel code generation"),a.addEventListener("click",(()=>{this.cleanup(),e.dispatch({effects:[ob.of({show:!1,from:0,to:0}),lb.of(!1)]}),e.focus()})),s.append(a,i);const l=document.createElement("div");l.className="cm-ai-help-info",l.setAttribute("role","status"),l.setAttribute("aria-live","polite"),l.textContent="Esc to close";e.state.field(cb)?(l.classList.add("hidden"),o.disabled=!0):s.classList.add("hidden"),requestAnimationFrame((()=>o.focus()));const c=async()=>{var n;const r=e.state.field(sb),i=o.value.trim();if(!r.show||!i)return;const a=e.state.sliceDoc(r.from,r.to),c=e.state.sliceDoc(0,r.from),d=e.state.sliceDoc(r.to);this.abortController=new AbortController,e.dispatch({effects:lb.of(!0)}),s.classList.remove("hidden"),l.classList.add("hidden"),o.disabled=!0;try{const t=await this.complete({prompt:i,selection:a,codeBefore:c,codeAfter:d,editorView:e,signal:this.abortController.signal});if(!e.state.field(sb).show)return;if(!t||"string"!=typeof t)throw new Error("Invalid completion result");e.dispatch({changes:{from:r.from,to:r.to,insert:t},effects:[ob.of({show:!1,from:r.from,to:r.to}),ib.of({from:r.from,to:r.from+t.length,oldCode:a,newCode:t}),lb.of(!1)],selection:gn.cursor(r.to)})}catch(u){if(u instanceof DOMException&&"AbortError"===u.name)return;null==(n=t.onError)||n.call(t,u)}finally{this.cleanup(),s.classList.add("hidden"),l.classList.remove("hidden"),o.disabled=!1,e.focus()}};let d="";return o.addEventListener("input",(()=>{const e=o.value.trim();if(e!==d)if(d=e,l.textContent="",e){const e=document.createElement("button");e.className="cm-ai-generate-btn",e.textContent="⏎ Generate",e.setAttribute("aria-label","Generate code"),e.addEventListener("click",c),l.appendChild(e)}else{const e=document.createTextNode("Esc to close");l.appendChild(e)}})),o.addEventListener("keydown",(async t=>{"Enter"!==t.key||t.shiftKey?"Escape"===t.key&&(this.cleanup(),e.dispatch({effects:[ob.of({show:!1,from:0,to:0}),lb.of(!1)]}),e.focus()):(t.preventDefault(),await c())})),r.append(o),n.append(r,s,l),n}cleanup(){var e;null==(e=this.abortController)||e.abort(),this.abortController=null}destroy(){this.cleanup()}}const kb=e=>{const{cellId:t,cellMovementCallbacks:n,cellCodeCallbacks:r,keymapConfig:o,hotkeys:s,enableAI:i}=e;return[jl(o,n),[yn.domEventHandlers({drop:(e,t)=>{var n,r;const o=null==(n=e.dataTransfer)?void 0:n.files[0];if(null==o?void 0:o.type.startsWith("text/"))return e.preventDefault(),br(t,o),!0;if(null==o?void 0:o.type.startsWith("image/"))return e.preventDefault(),xr(t,o),!0;const s=null==(r=e.dataTransfer)?void 0:r.getData("text/plain");if(s){e.preventDefault();const n=t.posAtCoords({x:e.clientX,y:e.clientY});return null!==n&&t.dispatch({changes:{from:n,to:n,insert:s},scrollIntoView:!0}),!0}return!1},dragover:e=>{e.preventDefault()}})],Qy(),Zy(),Er(t,n,s),Nr(t,r,s),Sb(e),[Vy,(a=(e,t)=>{pr(e,t)},wn.define((e=>new Wy(e,a)))),yn.baseTheme({".underline":{textDecoration:"underline",cursor:"pointer",color:"var(--link)"}})],i&&Kd("inline_ai_tooltip")?pb({prompt:e=>async function(e){var t,n;const r=`\nGiven the following code context, ${e.prompt}\n\nSELECTED CODE:\n${e.selection}\n\nCODE BEFORE SELECTION:\n${e.codeBefore}\n\nCODE AFTER SELECTION:\n${e.codeAfter}\n\nInstructions:\n1. Modify ONLY the selected code\n2. Keep the same indentation selected code\n3. Maintain consistent style with surrounding code\n4. Ensure the edit is complete and can be inserted directly\n5. Return ONLY the replacement code, no explanations, no code fences.\n\nYour task: ${e.prompt}`,o=await fetch(Sr("api/ai/completion").toString(),{method:"POST",headers:Cr.headers(),body:JSON.stringify({prompt:r,code:"",includeOtherCode:"",language:e.language})}),s=(null==(t=e.selection.match(/^\s*/))?void 0:t[0])||"",i=null==(n=o.body)?void 0:n.getReader();if(!i)throw new Error("Failed to get response reader");let a="";for(;;){const{done:e,value:t}=await i.read();if(e)break;a+=(new TextDecoder).decode(t)}return a.startsWith(s)||(a=s+a),a}({prompt:e.prompt,selection:e.selection,codeBefore:e.codeBefore,codeAfter:e.codeAfter,language:eo(e.editorView)})}):[]];var a},Sb=e=>{const{theme:t,hotkeys:n,completionConfig:r}=e;return[yn.lineWrapping,jr(),_r(),Ir(),Ar(),Tr(),Mr(),Dr(),Or({position:"fixed",parent:document.querySelector("#App")??void 0}),Rr(),"dark"===t?Yy:qy,Pr(),By(r),Lr(),zr(),rr.high(er.of(Fr)),Br(),Ur(),$r.of(" "),gr(Hr,{fallback:!0}),er.of(Vr),Wr(e),Gr.of(qr()),Yr.allowMultipleSelections.of(!0),zf(n),er.of([{key:"Tab",run:e=>Xr(e)||(e=>{const{from:t,to:n}=e.state.selection.main;if(t!==n)return!1;const r=e.state.doc.lineAt(n);return""!==r.text.slice(0,n-r.from).trim()&&to(e)})(e)||Jr(e),preventDefault:!0},{key:n.getHotkey("completion.moveDown").key,run:e=>null!==lr(e.state)&&(Kr(!0)(e),!0),preventDefault:!0},{key:n.getHotkey("completion.moveUp").key,run:e=>null!==lr(e.state)&&(Kr(!1)(e),!0),preventDefault:!0}]),er.of([...Zr,Qr])]};function Cb(e){const t=e.current;if(null===t)throw new ReferenceError("Attempting to dereference null object.");return t}var Eb="ContextMenu",[Nb,jb]=no(Eb,[ro]),_b=ro(),[Ib,Ab]=Nb(Eb),Tb=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:s,modal:i=!0}=e,[a,l]=o.useState(!1),c=_b(t),d=vo(r),u=o.useCallback((e=>{l(e),d(e)}),[d]);return I.jsx(Ib,{scope:t,open:a,onOpenChange:u,modal:i,children:I.jsx(wo,{...c,dir:s,open:a,onOpenChange:u,modal:i,children:n})})};Tb.displayName=Eb;var Mb="ContextMenuTrigger",Db=o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...s}=e,i=Ab(Mb,n),a=_b(n),l=o.useRef({x:0,y:0}),c=o.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=o.useRef(0),u=o.useCallback((()=>window.clearTimeout(d.current)),[]),h=e=>{l.current={x:e.clientX,y:e.clientY},i.onOpenChange(!0)};return o.useEffect((()=>u),[u]),o.useEffect((()=>{r&&u()}),[r,u]),I.jsxs(I.Fragment,{children:[I.jsx(oo,{...a,virtualRef:c}),I.jsx(so.span,{"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,...s,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:io(e.onContextMenu,(e=>{u(),h(e),e.preventDefault()})),onPointerDown:r?e.onPointerDown:io(e.onPointerDown,Wb((e=>{u(),d.current=window.setTimeout((()=>h(e)),700)}))),onPointerMove:r?e.onPointerMove:io(e.onPointerMove,Wb(u)),onPointerCancel:r?e.onPointerCancel:io(e.onPointerCancel,Wb(u)),onPointerUp:r?e.onPointerUp:io(e.onPointerUp,Wb(u))})]})}));Db.displayName=Mb;var Ob=e=>{const{__scopeContextMenu:t,...n}=e,r=_b(t);return I.jsx(ko,{...r,...n})};Ob.displayName="ContextMenuPortal";var Rb="ContextMenuContent",Pb=o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,s=Ab(Rb,n),i=_b(n),a=o.useRef(!1);return I.jsx(ao,{...i,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var n;null==(n=e.onCloseAutoFocus)||n.call(e,t),!t.defaultPrevented&&a.current&&t.preventDefault(),a.current=!1},onInteractOutside:t=>{var n;null==(n=e.onInteractOutside)||n.call(e,t),t.defaultPrevented||s.modal||(a.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}));Pb.displayName=Rb;o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=_b(n);return I.jsx(lo,{...o,...r,ref:t})})).displayName="ContextMenuGroup";var Lb=o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=_b(n);return I.jsx(co,{...o,...r,ref:t})}));Lb.displayName="ContextMenuLabel";var zb=o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=_b(n);return I.jsx(uo,{...o,...r,ref:t})}));zb.displayName="ContextMenuItem";var Fb=o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=_b(n);return I.jsx(ho,{...o,...r,ref:t})}));Fb.displayName="ContextMenuCheckboxItem";o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=_b(n);return I.jsx(fo,{...o,...r,ref:t})})).displayName="ContextMenuRadioGroup";var Bb=o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=_b(n);return I.jsx(po,{...o,...r,ref:t})}));Bb.displayName="ContextMenuRadioItem";var Ub=o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=_b(n);return I.jsx(mo,{...o,...r,ref:t})}));Ub.displayName="ContextMenuItemIndicator";var $b=o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=_b(n);return I.jsx(go,{...o,...r,ref:t})}));$b.displayName="ContextMenuSeparator";o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=_b(n);return I.jsx(yo,{...o,...r,ref:t})})).displayName="ContextMenuArrow";var Hb=o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=_b(n);return I.jsx(bo,{...o,...r,ref:t})}));Hb.displayName="ContextMenuSubTrigger";var Vb=o.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=_b(n);return I.jsx(xo,{...o,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}));function Wb(e){return t=>"mouse"!==t.pointerType?e(t):void 0}Vb.displayName="ContextMenuSubContent";var Gb=Pb,qb=Lb,Yb=zb,Xb=Fb,Jb=Bb,Kb=Ub,Zb=$b,Qb=Hb,ex=Vb;const tx=Tb,nx=Db,rx=So(Ob);o.forwardRef(((e,t)=>{const n=j.c(14);let r,o,s,i,a,l,c;return n[0]!==e?(({className:o,inset:s,children:r,...i}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s,n[4]=i):(r=n[1],o=n[2],s=n[3],i=n[4]),n[5]!==o||n[6]!==s?(a=Co({className:o,inset:s}),n[5]=o,n[6]=s,n[7]=a):a=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=I.jsx(To,{className:"ml-auto h-4 w-4"}),n[8]=l):l=n[8],n[9]!==r||n[10]!==i||n[11]!==t||n[12]!==a?(c=I.jsxs(Qb,{ref:t,className:a,...i,children:[r,l]}),n[9]=r,n[10]=i,n[11]=t,n[12]=a,n[13]=c):c=n[13],c})).displayName=Qb.displayName;const ox="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2";o.forwardRef(((e,t)=>{const n=j.c(9);let r,o,s,i;return n[0]!==e?(({className:r,...o}=e),n[0]=e,n[1]=r,n[2]=o):(r=n[1],o=n[2]),n[3]!==r?(s=In(Eo({subcontent:!0}),ox,r),n[3]=r,n[4]=s):s=n[4],n[5]!==o||n[6]!==t||n[7]!==s?(i=I.jsx(ex,{ref:t,className:s,...o}),n[5]=o,n[6]=t,n[7]=s,n[8]=i):i=n[8],i})).displayName=ex.displayName;const sx=o.forwardRef(((e,t)=>{const n=j.c(9);let r,o,s,i;return n[0]!==e?(({className:r,...o}=e),n[0]=e,n[1]=r,n[2]=o):(r=n[1],o=n[2]),n[3]!==r?(s=In(Eo(),ox,r),n[3]=r,n[4]=s):s=n[4],n[5]!==o||n[6]!==t||n[7]!==s?(i=I.jsx(rx,{children:I.jsx(No,{children:I.jsx(Gb,{ref:t,className:s,...o})})}),n[5]=o,n[6]=t,n[7]=s,n[8]=i):i=n[8],i}));sx.displayName=Gb.displayName;const ix=o.forwardRef(((e,t)=>{const n=j.c(13);let r,o,s,i,a,l;return n[0]!==e?(({className:r,inset:o,variant:i,...s}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s,n[4]=i):(r=n[1],o=n[2],s=n[3],i=n[4]),n[5]!==r||n[6]!==o||n[7]!==i?(a=jo({className:r,inset:o,variant:i}),n[5]=r,n[6]=o,n[7]=i,n[8]=a):a=n[8],n[9]!==s||n[10]!==t||n[11]!==a?(l=I.jsx(Yb,{ref:t,className:a,...s}),n[9]=s,n[10]=t,n[11]=a,n[12]=l):l=n[12],l}));ix.displayName=Yb.displayName;o.forwardRef(((e,t)=>{const n=j.c(15);let r,o,s,i,a,l,c,d;return n[0]!==e?(({className:s,children:o,checked:r,...i}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s,n[4]=i):(r=n[1],o=n[2],s=n[3],i=n[4]),n[5]!==s?(a=_o({className:s}),n[5]=s,n[6]=a):a=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=_o(),n[7]=l):l=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx("span",{className:l,children:I.jsx(Kb,{children:I.jsx(Mo,{className:"h-4 w-4"})})}),n[8]=c):c=n[8],n[9]!==r||n[10]!==o||n[11]!==i||n[12]!==t||n[13]!==a?(d=I.jsxs(Xb,{ref:t,className:a,checked:r,...i,children:[c,o]}),n[9]=r,n[10]=o,n[11]=i,n[12]=t,n[13]=a,n[14]=d):d=n[14],d})).displayName=Xb.displayName;o.forwardRef(((e,t)=>{const n=j.c(13);let r,o,s,i,a,l,c;return n[0]!==e?(({className:o,children:r,...s}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]),n[4]!==o?(i=_o({className:o}),n[4]=o,n[5]=i):i=n[5],n[6]===Symbol.for("react.memo_cache_sentinel")?(a=_o(),n[6]=a):a=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=I.jsx("span",{className:a,children:I.jsx(Kb,{children:I.jsx(Do,{className:"h-4 w-4 fill-current"})})}),n[7]=l):l=n[7],n[8]!==r||n[9]!==s||n[10]!==t||n[11]!==i?(c=I.jsxs(Jb,{ref:t,className:i,...s,children:[l,r]}),n[8]=r,n[9]=s,n[10]=t,n[11]=i,n[12]=c):c=n[12],c})).displayName=Jb.displayName;o.forwardRef(((e,t)=>{const n=j.c(11);let r,o,s,i,a;return n[0]!==e?(({className:r,inset:o,...s}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]),n[4]!==r||n[5]!==o?(i=Io({className:r,inset:o}),n[4]=r,n[5]=o,n[6]=i):i=n[6],n[7]!==s||n[8]!==t||n[9]!==i?(a=I.jsx(qb,{ref:t,className:i,...s}),n[7]=s,n[8]=t,n[9]=i,n[10]=a):a=n[10],a})).displayName=qb.displayName;const ax=o.forwardRef(((e,t)=>{const n=j.c(9);let r,o,s,i;return n[0]!==e?(({className:r,...o}=e),n[0]=e,n[1]=r,n[2]=o):(r=n[1],o=n[2]),n[3]!==r?(s=In(Ao({className:r})),n[3]=r,n[4]=s):s=n[4],n[5]!==o||n[6]!==t||n[7]!==s?(i=I.jsx(Zb,{ref:t,className:s,...o}),n[5]=o,n[6]=t,n[7]=s,n[8]=i):i=n[8],i}));ax.displayName=Zb.displayName;const lx=e=>{const t=j.c(14),{appClosed:n,onClick:r,tooltipContent:o}=e;let s;t[0]!==r?(s=()=>null==r?void 0:r({code:""}),t[0]=r,t[1]=s):s=t[1];const i=n&&" inactive-button";let a,l,c,d,u;return t[2]!==i?(a=In("shoulder-button hover-action",i),t[2]=i,t[3]=a):a=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(l=I.jsx(Oo,{strokeWidth:1.8}),t[4]=l):l=t[4],t[5]!==s||t[6]!==a?(c=I.jsx(gl,{onClick:s,className:a,onMouseDown:ot.preventFocus,shape:"circle",size:"small",color:"hint-green","data-testid":"create-cell-button",children:l}),t[5]=s,t[6]=a,t[7]=c):c=t[7],t[8]!==c||t[9]!==o?(d=I.jsx(it,{content:o,usePortal:!1,children:c}),t[8]=c,t[9]=o,t[10]=d):d=t[10],t[11]!==r||t[12]!==d?(u=I.jsx(cx,{onClick:r,children:d}),t[11]=r,t[12]=d,t[13]=u):u=t[13],u},cx=e=>{const t=j.c(24),{children:n,onClick:r}=e;if(!r)return n;let o,s,i,a,l,c,d,u,h,f,p,m;return t[0]!==n?(o=I.jsx(nx,{children:n}),t[0]=n,t[1]=o):o=t[1],t[2]!==r?(s=e=>{e.stopPropagation(),r({code:""})},t[2]=r,t[3]=s):s=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(i=I.jsx("div",{className:"mr-3 text-muted-foreground",children:I.jsx(dl,{})}),t[4]=i):i=t[4],t[5]!==s?(a=I.jsxs(ix,{onSelect:s,children:[i,"Python cell"]},"python"),t[5]=s,t[6]=a):a=t[6],t[7]!==r?(l=e=>{e.stopPropagation(),r({code:(new Rt).defaultCode})},t[7]=r,t[8]=l):l=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx("div",{className:"mr-3 text-muted-foreground",children:I.jsx(cl,{})}),t[9]=c):c=t[9],t[10]!==l?(d=I.jsxs(ix,{onSelect:l,children:[c,"Markdown cell"]},"markdown"),t[10]=l,t[11]=d):d=t[11],t[12]!==r?(u=e=>{e.stopPropagation(),r({code:(new Ro).getDefaultCode()})},t[12]=r,t[13]=u):u=t[13],t[14]===Symbol.for("react.memo_cache_sentinel")?(h=I.jsx("div",{className:"mr-3 text-muted-foreground",children:I.jsx(ve,{size:13,strokeWidth:1.5})}),t[14]=h):h=t[14],t[15]!==u?(f=I.jsxs(ix,{onSelect:u,children:[h,"SQL cell"]},"sql"),t[15]=u,t[16]=f):f=t[16],t[17]!==a||t[18]!==d||t[19]!==f?(p=I.jsxs(sx,{children:[a,d,f]}),t[17]=a,t[18]=d,t[19]=f,t[20]=p):p=t[20],t[21]!==o||t[22]!==p?(m=I.jsxs(tx,{children:[o,p]}),t[21]=o,t[22]=p,t[23]=m):m=t[23],m},dx=Po("rounded-full shadow-xsSolid border p-[5px] transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 active:shadow-none bg-background",{variants:{variant:{default:"hover:bg-accent hover:text-accent-foreground",stale:"bg-[var(--yellow-3)] hover:bg-[var(--yellow-4)] text-[var(--yellow-11)]",green:"hover:bg-[var(--grass-2)] hover:text-[var(--grass-11)] hover:border-[var(--grass-7)],",disabled:"opacity-50 cursor-not-allowed",danger:"hover:bg-[var(--red-3)] hover:text-[var(--red-11)]"}},defaultVariants:{variant:"default"}}),ux=e=>{const t=j.c(21);let n,r,o,s,i;t[0]!==e?(({children:n,tooltip:s,disabled:o,variant:i,...r}=e),t[0]=e,t[1]=n,t[2]=r,t[3]=o,t[4]=s,t[5]=i):(n=t[1],r=t[2],o=t[3],s=t[4],i=t[5]);const a=void 0!==o&&o;let l,c,d;t[6]!==a||t[7]!==r?(l=e=>{var t;a||null==(t=r.onClick)||t.call(r,e)},t[6]=a,t[7]=r,t[8]=l):l=t[8],t[9]!==r.className||t[10]!==i?(c=In(dx({variant:i}),r.className),t[9]=r.className,t[10]=i,t[11]=c):c=t[11],t[12]!==n||t[13]!==a||t[14]!==r||t[15]!==l||t[16]!==c?(d=I.jsx("button",{disabled:a,...r,onClick:l,onMouseDown:ot.preventFocus,className:c,children:n}),t[12]=n,t[13]=a,t[14]=r,t[15]=l,t[16]=c,t[17]=d):d=t[17];const u=d;if(s){let e;return t[18]!==u||t[19]!==s?(e=I.jsx(it,{content:s,side:"top",delayDuration:200,usePortal:!1,children:u}),t[18]=u,t[19]=s,t[20]=e):e=t[20],e}return u},hx=({children:e,className:t})=>I.jsx(Vd,{className:In("flex items-center gap-1 bg-background m-[2px] rounded-full",t),children:e});const fx=e=>{const t=j.c(22),{onClick:n,appClosed:r,needsRun:o,status:s,config:i,edited:a}=e,l="disabled-transitively"===s,c="running"===s||"queued"===s,d=r||c||!i.disabled&&l&&!a;let u;t[0]!==r||t[1]!==d||t[2]!==c||t[3]!==o?(u=function(e,t,n,r){return e?"disabled":t&&!n?"stale":n||r?"disabled":"green"}(r,o,c,d),t[0]=r,t[1]=d,t[2]=c,t[3]=o,t[4]=u):u=t[4];const h=u;if(i.disabled){let e,r;return t[5]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx(ed,{}),t[5]=e):e=t[5],t[6]!==d||t[7]!==n||t[8]!==h?(r=I.jsx(ux,{tooltip:"Add code to notebook",disabled:d,onClick:n,variant:h,"data-testid":"run-button",children:e}),t[6]=d,t[7]=n,t[8]=h,t[9]=r):r=t[9],r}if(!i.disabled&&l&&!a){let e,r;return t[10]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx(bd,{strokeWidth:1.2}),t[10]=e):e=t[10],t[11]!==d||t[12]!==n||t[13]!==h?(r=I.jsx(ux,{disabled:d,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:n,variant:h,"data-testid":"run-button",children:e}),t[11]=d,t[12]=n,t[13]=h,t[14]=r):r=t[14],r}let f,p,m;if(r)f="App disconnected";else if("queued"===s)f="This cell is already queued to run";else if("running"===s)f="This cell is already running.";else{let e;t[15]===Symbol.for("react.memo_cache_sentinel")?(e=Bt("cell.run"),t[15]=e):e=t[15],f=e}return t[16]===Symbol.for("react.memo_cache_sentinel")?(p=I.jsx(bd,{strokeWidth:1.2}),t[16]=p):p=t[16],t[17]!==d||t[18]!==n||t[19]!==f||t[20]!==h?(m=I.jsx(ux,{tooltip:f,disabled:d,onClick:n,variant:h,"data-testid":"run-button",children:p}),t[17]=d,t[18]=n,t[19]=f,t[20]=h,t[21]=m):m=t[21],m},px=e=>{const t=j.c(10),{status:n,appClosed:r,onClick:o}=e;let s;s=r?"App disconnected":"running"===n?"A cell can't be deleted when it's running":"queued"===n?"A cell can't be deleted when it's queued to run":"Delete";const i=s,a=(r||("running"===n||"queued"===n))&&"inactive-button";let l,c,d,u,h;return t[0]!==a?(l=In("hover:bg-transparent text-destructive/60 hover:text-destructive",a),t[0]=a,t[1]=l):l=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(c={boxShadow:"none"},d=I.jsx(je,{size:14}),t[2]=c,t[3]=d):(c=t[2],d=t[3]),t[4]!==o||t[5]!==l?(u=I.jsx(X,{variant:"ghost",size:"icon",onClick:o,"data-testid":"delete-button",onMouseDown:ot.preventFocus,className:l,style:c,children:d}),t[4]=o,t[5]=l,t[6]=u):u=t[6],t[7]!==u||t[8]!==s?(h=I.jsx(it,{content:i,usePortal:!1,children:u}),t[7]=u,t[8]=s,t[9]=h):h=t[9],h};const mx=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),gx=new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),yx=e=>{const t=j.c(79),{editing:n,status:r,disabled:o,staleInputs:s,edited:i,interrupted:a,elapsedTime:l,runStartTimestamp:c,lastRunStartTimestamp:d,uninstantiated:u}=e;if(!n)return null;const h=c??d;let f;t[0]!==h?(f=h?I.jsx(xx,{lastRanTime:h}):null,t[0]=h,t[1]=f):f=t[1];const p=f;if(o&&"running"===r)return w.error("CellStatusComponent: disabled and running"),null;if(o&&s){let e,n,r,o;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx("span",{children:"This cell is stale, but it's disabled and can't be run"}),t[2]=e):e=t[2],t[3]!==p?(n=I.jsxs("div",{className:"flex flex-col gap-1",children:[e,p]}),t[3]=p,t[4]=n):n=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(r=I.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:I.jsxs(iu,{children:[I.jsx(Ac,{className:"h-5 w-5",strokeWidth:1.5}),I.jsx(zo,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[5]=r):r=t[5],t[6]!==n?(o=I.jsx(it,{content:n,usePortal:!0,children:r}),t[6]=n,t[7]=o):o=t[7],o}if(o){let e,n,r,o;return t[8]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx("span",{children:"This cell is disabled"}),t[8]=e):e=t[8],t[9]!==p?(n=I.jsxs("div",{className:"flex flex-col gap-1",children:[e,p]}),t[9]=p,t[10]=n):n=t[10],t[11]===Symbol.for("react.memo_cache_sentinel")?(r=I.jsx("div",{className:"cell-status-icon cell-status-disabled","data-testid":"cell-status","data-status":"disabled",children:I.jsx(Ac,{className:"h-5 w-5",strokeWidth:1.5})}),t[11]=r):r=t[11],t[12]!==n?(o=I.jsx(it,{content:n,usePortal:!0,children:r}),t[12]=n,t[13]=o):o=t[13],o}if(!s&&"disabled-transitively"===r){let e,n,r,o;return t[14]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx("span",{children:"An ancestor of this cell is disabled, so it can't be run"}),t[14]=e):e=t[14],t[15]!==p?(n=I.jsxs("div",{className:"flex flex-col gap-1",children:[e,p]}),t[15]=p,t[16]=n):n=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(r=I.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"disabled-transitively",children:I.jsxs(iu,{layerTop:!0,children:[I.jsx(Bd,{className:"h-5 w-5",strokeWidth:1.5}),I.jsx(Ac,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[17]=r):r=t[17],t[18]!==n?(o=I.jsx(it,{content:n,usePortal:!0,children:r}),t[18]=n,t[19]=o):o=t[19],o}if(s&&"disabled-transitively"===r){let e,n,r,o;return t[20]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx("span",{children:"This cell is stale, but an ancestor is disabled so it can't be run"}),t[20]=e):e=t[20],t[21]!==p?(n=I.jsxs("div",{className:"flex flex-col gap-1",children:[e,p]}),t[21]=p,t[22]=n):n=t[22],t[23]===Symbol.for("react.memo_cache_sentinel")?(r=I.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:I.jsxs(iu,{children:[I.jsx(zo,{className:"h-5 w-5",strokeWidth:1}),I.jsx(Ac,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[23]=r):r=t[23],t[24]!==n?(o=I.jsx(it,{content:n,usePortal:!0,children:r}),t[24]=n,t[25]=o):o=t[25],o}if("running"===r){let e,n,r,o,s;return t[26]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx("span",{children:"This cell is running"}),t[26]=e):e=t[26],t[27]!==p?(n=I.jsxs("div",{className:"flex flex-col gap-1",children:[e,p]}),t[27]=p,t[28]=n):n=t[28],t[29]!==c?(r=Lo.fromSeconds(c)||Lo.now(),t[29]=c,t[30]=r):r=t[30],t[31]!==r?(o=I.jsx("div",{className:"cell-status-icon elapsed-time running","data-testid":"cell-status","data-status":"running",children:I.jsx(wx,{startTime:r})}),t[31]=r,t[32]=o):o=t[32],t[33]!==n||t[34]!==o?(s=I.jsx(it,{content:n,usePortal:!0,children:o}),t[33]=n,t[34]=o,t[35]=s):s=t[35],s}if("queued"===r){let e,n,r,o;return t[36]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx("span",{children:"This cell is queued to run"}),t[36]=e):e=t[36],t[37]!==p?(n=I.jsxs("div",{className:"flex flex-col gap-1",children:[e,p]}),t[37]=p,t[38]=n):n=t[38],t[39]===Symbol.for("react.memo_cache_sentinel")?(r=I.jsx("div",{className:"cell-status-icon cell-status-queued","data-testid":"cell-status","data-status":"queued",children:I.jsx(Jl,{className:"h-5 w-5",strokeWidth:1.5})}),t[39]=r):r=t[39],t[40]!==n?(o=I.jsx(it,{content:n,usePortal:!0,children:r}),t[40]=n,t[41]=o):o=t[41],o}if(i||a||s||u){let e;t[42]!==l?(e=vx(l),t[42]=l,t[43]=e):e=t[43];const n=e;let r;t[44]!==l||t[45]!==n?(r=l?I.jsx(bx,{elapsedTime:n}):null,t[44]=l,t[45]=n,t[46]=r):r=t[46];const o=r;let s,c,d,h,f,m="";if(u)s="This cell has not yet been run";else if(a){let e;s="This cell was interrupted when it was last run",t[47]!==o?(e=I.jsxs("span",{children:["This cell ran for ",o," before being interrupted"]}),t[47]=o,t[48]=e):e=t[48],m=e}else if(i){let e;s="This cell has been modified since it was last run",t[49]!==o?(e=I.jsxs("span",{children:["This cell took ",o," to run"]}),t[49]=o,t[50]=e):e=t[50],m=e}else{let e;s="This cell has not been run with the latest inputs",t[51]!==o?(e=I.jsxs("span",{children:["This cell took ",o," to run"]}),t[51]=o,t[52]=e):e=t[52],m=e}return t[53]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx("div",{className:"cell-status-stale","data-testid":"cell-status","data-status":"outdated",children:I.jsx(zo,{className:"h-5 w-5",strokeWidth:1.5})}),t[53]=c):c=t[53],t[54]!==s?(d=I.jsx(it,{content:s,usePortal:!0,children:c}),t[54]=s,t[55]=d):d=t[55],t[56]!==l||t[57]!==n||t[58]!==p||t[59]!==m?(h=l&&I.jsx(it,{content:I.jsxs("div",{className:"flex flex-col gap-1",children:[m,p]}),usePortal:!0,children:I.jsx("div",{className:"elapsed-time hover-action","data-testid":"cell-status","data-status":"outdated",children:I.jsx("span",{children:n})})}),t[56]=l,t[57]=n,t[58]=p,t[59]=m,t[60]=h):h=t[60],t[61]!==d||t[62]!==h?(f=I.jsxs("div",{className:"cell-status-icon flex items-center gap-2",children:[d,h]}),t[61]=d,t[62]=h,t[63]=f):f=t[63],f}if(null!==l){let e;t[64]!==l?(e=vx(l),t[64]=l,t[65]=e):e=t[65];const n=e;let r;t[66]!==l||t[67]!==n?(r=l?I.jsx(bx,{elapsedTime:n}):null,t[66]=l,t[67]=n,t[68]=r):r=t[68];const o=r;let s,i,a,c;return t[69]!==o?(s=I.jsxs("span",{children:["This cell took ",o," to run"]}),t[69]=o,t[70]=s):s=t[70],t[71]!==p||t[72]!==s?(i=I.jsxs("div",{className:"flex flex-col gap-1",children:[s,p]}),t[71]=p,t[72]=s,t[73]=i):i=t[73],t[74]!==n?(a=I.jsx("div",{className:"cell-status-icon elapsed-time hover-action","data-testid":"cell-status","data-status":"idle",children:I.jsx("span",{children:n})}),t[74]=n,t[75]=a):a=t[75],t[76]!==i||t[77]!==a?(c=I.jsx(it,{content:i,usePortal:!0,children:a}),t[76]=i,t[77]=a,t[78]=c):c=t[78],c}return null},bx=e=>{const t=j.c(2);let n;return t[0]!==e.elapsedTime?(n=I.jsx("span",{className:"tracking-wide font-semibold",children:e.elapsedTime}),t[0]=e.elapsedTime,t[1]=n):n=t[1],n},xx=e=>{const t=j.c(18),n=1e3*e.lastRanTime;let r,o,s,i,a,l,c,d,u;if(t[0]!==n){const e=new Date(n),d=new Date,u=e.toDateString()===d.toDateString()?mx:gx;i="Ran at",a=" ",l=I.jsx("strong",{className:"tracking-wide font-semibold",children:u.format(e)}),c=" ",r="text-muted-foreground",o="(",s=Xd(e),t[0]=n,t[1]=r,t[2]=o,t[3]=s,t[4]=i,t[5]=a,t[6]=l,t[7]=c}else r=t[1],o=t[2],s=t[3],i=t[4],a=t[5],l=t[6],c=t[7];return t[8]!==r||t[9]!==o||t[10]!==s?(d=I.jsxs("span",{className:r,children:[o,s," ago)"]}),t[8]=r,t[9]=o,t[10]=s,t[11]=d):d=t[11],t[12]!==i||t[13]!==a||t[14]!==l||t[15]!==c||t[16]!==d?(u=I.jsxs("span",{children:[i,a,l,c,d]}),t[12]=i,t[13]=a,t[14]=l,t[15]=c,t[16]=d,t[17]=u):u=t[17],u};function vx(e){if(null===e)return"";const t=e,n=t/1e3;if(n>=60){return`${Math.floor(n/60)}m${Math.floor(n%60)}s`}return n>=1?`${n.toFixed(2).toString()}s`:`${t.toFixed(0).toString()}ms`}const wx=e=>{const t=j.c(6);let n;t[0]!==e.startTime?(n=e.startTime.toMilliseconds(),t[0]=e.startTime,t[1]=n):n=t[1];const r=function(e){const t=o.useRef(e),[n,r]=o.useState(e);return o.useEffect((()=>{const e=setInterval((()=>{r(Lo.now().toMilliseconds())}),17);return()=>clearInterval(e)}),[]),n-t.current}(n);let s,i;return t[2]!==r?(s=vx(r),t[2]=r,t[3]=s):s=t[3],t[4]!==s?(i=I.jsx("span",{children:s}),t[4]=s,t[5]=i):i=t[5],i},kx={display:"none"};function Sx(e){let{id:t,value:n}=e;return u.createElement("div",{id:t,style:kx},n)}function Cx(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return u.createElement("div",{id:t,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":r,"aria-atomic":!0},n)}const Ex=o.createContext(null);const Nx={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},jx={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function _x(e){let{announcements:t=jx,container:n,hiddenTextDescribedById:r,screenReaderInstructions:s=Nx}=e;const{announce:i,announcement:a}=function(){const[e,t]=o.useState("");return{announce:o.useCallback((e=>{null!=e&&t(e)}),[]),announcement:e}}(),l=Wo("DndLiveRegion"),[c,d]=o.useState(!1);if(o.useEffect((()=>{d(!0)}),[]),function(e){const t=o.useContext(Ex);o.useEffect((()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)}),[e,t])}(o.useMemo((()=>({onDragStart(e){let{active:n}=e;i(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&i(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;i(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;i(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;i(t.onDragCancel({active:n,over:r}))}})),[i,t])),!c)return null;const h=u.createElement(u.Fragment,null,u.createElement(Sx,{id:r,value:s.draggable}),u.createElement(Cx,{id:l,announcement:a}));return n?qo.createPortal(h,n):h}var Ix,Ax;function Tx(){}function Mx(e,t){return o.useMemo((()=>({sensor:e,options:null!=t?t:{}})),[e,t])}(Ax=Ix||(Ix={})).DragStart="dragStart",Ax.DragMove="dragMove",Ax.DragEnd="dragEnd",Ax.DragCancel="dragCancel",Ax.DragOver="dragOver",Ax.RegisterDroppable="registerDroppable",Ax.SetDroppableDisabled="setDroppableDisabled",Ax.UnregisterDroppable="unregisterDroppable";const Dx=Object.freeze({x:0,y:0});function Ox(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Rx(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Px(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Lx(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function zx(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function Fx(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const Bx=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Fx(t,t.left,t.top),s=[];for(const i of r){const{id:e}=i,t=n.get(e);if(t){const n=Ox(Fx(t),o);s.push({id:e,data:{droppableContainer:i,value:n}})}}return s.sort(Rx)};function Ux(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),i=o-r,a=s-n;if(r<o&&n<s){const n=t.width*t.height,r=e.width*e.height,o=i*a;return Number((o/(n+r-o)).toFixed(4))}return 0}const $x=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const s of r){const{id:e}=s,r=n.get(e);if(r){const n=Ux(r,t);n>0&&o.push({id:e,data:{droppableContainer:s,value:n}})}}return o.sort(Px)};function Hx(e,t){const{top:n,left:r,bottom:o,right:s}=t;return n<=e.y&&e.y<=o&&r<=e.x&&e.x<=s}function Vx(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Dx}function Wx(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce(((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x})),{...t})}}const Gx=Wx(1);const qx={ignoreTransform:!1};function Yx(e,t){void 0===t&&(t=qx);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=Fo(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=function(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}(t);if(!r)return e;const{scaleX:o,scaleY:s,x:i,y:a}=r,l=e.left-i-(1-o)*parseFloat(n),c=e.top-a-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=o?e.width/o:e.width,u=s?e.height/s:e.height;return{width:d,height:u,top:c,right:l+d,bottom:c+u,left:l}}(n,t,r))}const{top:r,left:o,width:s,height:i,bottom:a,right:l}=n;return{top:r,left:o,width:s,height:i,bottom:a,right:l}}function Xx(e){return Yx(e,{ignoreTransform:!0})}function Jx(e,t){const n=[];return e?function r(o){if(null!=t&&n.length>=t)return n;if(!o)return n;if(ns(o)&&null!=o.scrollingElement&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Qo(o)||rs(o))return n;if(n.includes(o))return n;const s=Fo(e).getComputedStyle(o);return o!==e&&function(e,t){void 0===t&&(t=Fo(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((e=>{const r=t[e];return"string"==typeof r&&n.test(r)}))}(o,s)&&n.push(o),function(e,t){return void 0===t&&(t=Fo(e).getComputedStyle(e)),"fixed"===t.position}(o,s)?n:r(o.parentNode)}(e):n}function Kx(e){const[t]=Jx(e,1);return null!=t?t:null}function Zx(e){return Zo&&e?os(e)?e:ss(e)?ns(e)||e===Bo(e).scrollingElement?window:Qo(e)?e:null:null:null}function Qx(e){return os(e)?e.scrollX:e.scrollLeft}function ev(e){return os(e)?e.scrollY:e.scrollTop}function tv(e){return{x:Qx(e),y:ev(e)}}var nv,rv;function ov(e){return!(!Zo||!e)&&e===document.scrollingElement}function sv(e){const t={x:0,y:0},n=ov(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}(rv=nv||(nv={}))[rv.Forward=1]="Forward",rv[rv.Backward=-1]="Backward";const iv={x:.2,y:.2};function av(e,t,n,r,o){let{top:s,left:i,right:a,bottom:l}=n;void 0===r&&(r=10),void 0===o&&(o=iv);const{isTop:c,isBottom:d,isLeft:u,isRight:h}=sv(e),f={x:0,y:0},p={x:0,y:0},m=t.height*o.y,g=t.width*o.x;return!c&&s<=t.top+m?(f.y=nv.Backward,p.y=r*Math.abs((t.top+m-s)/m)):!d&&l>=t.bottom-m&&(f.y=nv.Forward,p.y=r*Math.abs((t.bottom-m-l)/m)),!h&&a>=t.right-g?(f.x=nv.Forward,p.x=r*Math.abs((t.right-g-a)/g)):!u&&i<=t.left+g&&(f.x=nv.Backward,p.x=r*Math.abs((t.left+g-i)/g)),{direction:f,speed:p}}function lv(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function cv(e){return e.reduce(((e,t)=>Ho(e,tv(t))),Dx)}const dv=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+Qx(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+ev(t)),0)}]];class uv{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=Jx(t),r=cv(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[o,s,i]of dv)for(const e of s)Object.defineProperty(this,e,{get:()=>{const t=i(n),s=r[o]-t;return this.rect[e]+s},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class hv{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach((e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)}))},this.target=e}add(e,t,n){var r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function fv(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t&&r>t.y}var pv,mv,gv,yv;function bv(e){e.preventDefault()}function xv(e){e.stopPropagation()}(mv=pv||(pv={})).Click="click",mv.DragStart="dragstart",mv.Keydown="keydown",mv.ContextMenu="contextmenu",mv.Resize="resize",mv.SelectionChange="selectionchange",mv.VisibilityChange="visibilitychange",(yv=gv||(gv={})).Space="Space",yv.Down="ArrowDown",yv.Right="ArrowRight",yv.Left="ArrowLeft",yv.Up="ArrowUp",yv.Esc="Escape",yv.Enter="Enter",yv.Tab="Tab";const vv={start:[gv.Space,gv.Enter],cancel:[gv.Esc],end:[gv.Space,gv.Enter,gv.Tab]},wv=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case gv.Right:return{...n,x:n.x+25};case gv.Left:return{...n,x:n.x-25};case gv.Down:return{...n,y:n.y+25};case gv.Up:return{...n,y:n.y-25}}};class kv{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new hv(Bo(t)),this.windowListeners=new hv(Fo(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(pv.Resize,this.handleCancel),this.windowListeners.add(pv.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add(pv.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&function(e,t){if(void 0===t&&(t=Yx),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);Kx(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(n),t(Dx)}handleKeyDown(e){if(Uo(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:o=vv,coordinateGetter:s=wv,scrollBehavior:i="smooth"}=r,{code:a}=e;if(o.end.includes(a))return void this.handleEnd(e);if(o.cancel.includes(a))return void this.handleCancel(e);const{collisionRect:l}=n.current,c=l?{x:l.left,y:l.top}:Dx;this.referenceCoordinates||(this.referenceCoordinates=c);const d=s(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=$o(d,c),r={x:0,y:0},{scrollableAncestors:o}=n.current;for(const n of o){const o=e.code,{isTop:s,isRight:a,isLeft:l,isBottom:c,maxScroll:u,minScroll:h}=sv(n),f=lv(n),p={x:Math.min(o===gv.Right?f.right-f.width/2:f.right,Math.max(o===gv.Right?f.left:f.left+f.width/2,d.x)),y:Math.min(o===gv.Down?f.bottom-f.height/2:f.bottom,Math.max(o===gv.Down?f.top:f.top+f.height/2,d.y))},m=o===gv.Right&&!a||o===gv.Left&&!l,g=o===gv.Down&&!c||o===gv.Up&&!s;if(m&&p.x!==d.x){const e=n.scrollLeft+t.x,s=o===gv.Right&&e<=u.x||o===gv.Left&&e>=h.x;if(s&&!t.y)return void n.scrollTo({left:e,behavior:i});r.x=s?n.scrollLeft-e:o===gv.Right?n.scrollLeft-u.x:n.scrollLeft-h.x,r.x&&n.scrollBy({left:-r.x,behavior:i});break}if(g&&p.y!==d.y){const e=n.scrollTop+t.y,s=o===gv.Down&&e<=u.y||o===gv.Up&&e>=h.y;if(s&&!t.x)return void n.scrollTo({top:e,behavior:i});r.y=s?n.scrollTop-e:o===gv.Down?n.scrollTop-u.y:n.scrollTop-h.y,r.y&&n.scrollBy({top:-r.y,behavior:i});break}}this.handleMove(e,Ho($o(d,this.referenceCoordinates),r))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function Sv(e){return Boolean(e&&"distance"in e)}function Cv(e){return Boolean(e&&"delay"in e)}kv.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=vv,onActivation:o}=t,{active:s}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const t=s.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==o||o({event:e.nativeEvent}),!0)}return!1}}];class Ev{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=Fo(e);return e instanceof t?e:Bo(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:o}=e,{target:s}=o;this.props=e,this.events=t,this.document=Bo(s),this.documentListeners=new hv(this.document),this.listeners=new hv(n),this.windowListeners=new hv(Fo(s)),this.initialCoordinates=null!=(r=Go(o))?r:Dx,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(pv.Resize,this.handleCancel),this.windowListeners.add(pv.DragStart,bv),this.windowListeners.add(pv.VisibilityChange,this.handleCancel),this.windowListeners.add(pv.ContextMenu,bv),this.documentListeners.add(pv.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Cv(t))return this.timeoutId=setTimeout(this.handleStart,t.delay),void this.handlePending(t);if(Sv(t))return void this.handlePending(t)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(pv.Click,xv,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(pv.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:o}=this,{onMove:s,options:{activationConstraint:i}}=o;if(!r)return;const a=null!=(t=Go(e))?t:Dx,l=$o(r,a);if(!n&&i){if(Sv(i)){if(null!=i.tolerance&&fv(l,i.tolerance))return this.handleCancel();if(fv(l,i.distance))return this.handleStart()}return Cv(i)&&fv(l,i.tolerance)?this.handleCancel():void this.handlePending(i,l)}e.cancelable&&e.preventDefault(),s(a)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===gv.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const Nv={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class jv extends Ev{constructor(e){const{event:t}=e,n=Bo(t.target);super(e,Nv,n)}}jv.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button)&&(null==r||r({event:n}),!0)}}];const _v={move:{name:"mousemove"},end:{name:"mouseup"}};var Iv,Av;(Av=Iv||(Iv={}))[Av.RightClick=2]="RightClick";(class extends Ev{constructor(e){super(e,_v,Bo(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==Iv.RightClick&&(null==r||r({event:n}),!0)}}];const Tv={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var Mv,Dv,Ov,Rv;function Pv(e){let{acceleration:t,activator:n=Mv.Pointer,canScroll:r,draggingRect:s,enabled:i,interval:a=5,order:l=Ov.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:f}=e;const p=function(e){let{delta:t,disabled:n}=e;const r=Jo(t);return Ko((e=>{if(n||!r||!e)return Lv;const o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[nv.Backward]:e.x[nv.Backward]||-1===o.x,[nv.Forward]:e.x[nv.Forward]||1===o.x},y:{[nv.Backward]:e.y[nv.Backward]||-1===o.y,[nv.Forward]:e.y[nv.Forward]||1===o.y}}}),[n,t,r])}({delta:h,disabled:!i}),[m,g]=Xo(),y=o.useRef({x:0,y:0}),b=o.useRef({x:0,y:0}),x=o.useMemo((()=>{switch(n){case Mv.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Mv.DraggableRect:return s}}),[n,s,c]),v=o.useRef(null),w=o.useCallback((()=>{const e=v.current;if(!e)return;const t=y.current.x*b.current.x,n=y.current.y*b.current.y;e.scrollBy(t,n)}),[]),k=o.useMemo((()=>l===Ov.TreeOrder?[...d].reverse():d),[l,d]);o.useEffect((()=>{if(i&&d.length&&x){for(const e of k){if(!1===(null==r?void 0:r(e)))continue;const n=d.indexOf(e),o=u[n];if(!o)continue;const{direction:s,speed:i}=av(e,o,x,t,f);for(const e of["x","y"])p[e][s[e]]||(i[e]=0,s[e]=0);if(i.x>0||i.y>0)return g(),v.current=e,m(w,a),y.current=i,void(b.current=s)}y.current={x:0,y:0},b.current={x:0,y:0},g()}else g()}),[t,w,r,g,i,a,JSON.stringify(x),JSON.stringify(p),m,d,k,u,JSON.stringify(f)])}(class extends Ev{constructor(e){super(e,Tv)}static setup(){return window.addEventListener(Tv.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Tv.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return!(o.length>1)&&(null==r||r({event:n}),!0)}}],(Dv=Mv||(Mv={}))[Dv.Pointer=0]="Pointer",Dv[Dv.DraggableRect=1]="DraggableRect",(Rv=Ov||(Ov={}))[Rv.TreeOrder=0]="TreeOrder",Rv[Rv.ReversedTreeOrder=1]="ReversedTreeOrder";const Lv={x:{[nv.Backward]:!1,[nv.Forward]:!1},y:{[nv.Backward]:!1,[nv.Forward]:!1}};var zv,Fv,Bv;(Fv=zv||(zv={}))[Fv.Always=0]="Always",Fv[Fv.BeforeDragging=1]="BeforeDragging",Fv[Fv.WhileDragging=2]="WhileDragging",(Bv||(Bv={})).Optimized="optimized";const Uv=new Map;function $v(e,t){return Ko((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function Hv(e){let{callback:t,disabled:n}=e;const r=is(t),s=o.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(r)}),[n]);return o.useEffect((()=>()=>null==s?void 0:s.disconnect()),[s]),s}function Vv(e){return new uv(Yx(e),e)}function Wv(e,t,n){void 0===t&&(t=Vv);const[r,s]=o.useState(null);function i(){s((r=>{if(!e)return null;var o;if(!1===e.isConnected)return null!=(o=null!=r?r:n)?o:null;const s=t(e);return JSON.stringify(r)===JSON.stringify(s)?r:s}))}const a=function(e){let{callback:t,disabled:n}=e;const r=is(t),s=o.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(r)}),[r,n]);return o.useEffect((()=>()=>null==s?void 0:s.disconnect()),[s]),s}({callback(t){if(e)for(const n of t){const{type:t,target:r}=n;if("childList"===t&&r instanceof HTMLElement&&r.contains(e)){i();break}}}}),l=Hv({callback:i});return Yo((()=>{i(),e?(null==l||l.observe(e),null==a||a.observe(document.body,{childList:!0,subtree:!0})):(null==l||l.disconnect(),null==a||a.disconnect())}),[e]),r}const Gv=[];function qv(e,t){void 0===t&&(t=[]);const n=o.useRef(null);return o.useEffect((()=>{n.current=null}),t),o.useEffect((()=>{const t=e!==Dx;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)}),[e]),n.current?$o(e,n.current):Dx}function Yv(e){return o.useMemo((()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null),[e])}const Xv=[];function Jv(e){let{measure:t}=e;const[n,r]=o.useState(null),s=Hv({callback:o.useCallback((e=>{for(const{target:n}of e)if(Qo(n)){r((e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r}));break}}),[t])}),i=o.useCallback((e=>{const n=function(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Qo(t)?t:e}(e);null==s||s.disconnect(),n&&(null==s||s.observe(n)),r(n?t(n):null)}),[t,s]),[a,l]=es(i);return o.useMemo((()=>({nodeRef:a,rect:n,setRef:l})),[n,a,l])}const Kv=[{sensor:jv,options:{}},{sensor:kv,options:{}}],Zv={current:{}},Qv={draggable:{measure:Xx},droppable:{measure:Xx,strategy:zv.WhileDragging,frequency:Bv.Optimized},dragOverlay:{measure:Yx}};class ew extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter((e=>{let{disabled:t}=e;return!t}))}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const tw={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ew,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Tx},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Qv,measureDroppableContainers:Tx,windowRect:null,measuringScheduled:!1},nw={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Tx,draggableNodes:new Map,over:null,measureDroppableContainers:Tx},rw=o.createContext(nw),ow=o.createContext(tw);function sw(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ew}}}function iw(e,t){switch(t.type){case Ix.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ix.DragMove:return null==e.draggable.active?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Ix.DragEnd:case Ix.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ix.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new ew(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case Ix.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const i=new ew(e.droppable.containers);return i.set(n,{...s,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case Ix.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new ew(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function aw(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:s}=o.useContext(rw),i=Jo(r),a=Jo(null==n?void 0:n.id);return o.useEffect((()=>{if(!t&&!r&&i&&null!=a){if(!Uo(i))return;if(document.activeElement===i.target)return;const e=s.get(a);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame((()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=ts(e);if(t){t.focus();break}}}))}}),[r,t,s,a,i]),null}const lw=o.createContext({...Dx,scaleX:1,scaleY:1});var cw,dw;(dw=cw||(cw={}))[dw.Uninitialized=0]="Uninitialized",dw[dw.Initializing=1]="Initializing",dw[dw.Initialized=2]="Initialized";const uw=o.memo((function(e){var t,n,r,s;let{id:i,accessibility:a,autoScroll:l=!0,children:c,sensors:d=Kv,collisionDetection:h=$x,measuring:f,modifiers:p,...m}=e;const g=o.useReducer(iw,void 0,sw),[y,b]=g,[x,v]=function(){const[e]=o.useState((()=>new Set)),t=o.useCallback((t=>(e.add(t),()=>e.delete(t))),[e]);return[o.useCallback((t=>{let{type:n,event:r}=t;e.forEach((e=>{var t;return null==(t=e[n])?void 0:t.call(e,r)}))}),[e]),t]}(),[w,k]=o.useState(cw.Uninitialized),S=w===cw.Initialized,{draggable:{active:C,nodes:E,translate:N},droppable:{containers:j}}=y,_=null!=C?E.get(C):null,I=o.useRef({initial:null,translated:null}),A=o.useMemo((()=>{var e;return null!=C?{id:C,data:null!=(e=null==_?void 0:_.data)?e:Zv,rect:I}:null}),[C,_]),T=o.useRef(null),[M,D]=o.useState(null),[O,R]=o.useState(null),P=Vo(m,Object.values(m)),L=Wo("DndDescribedBy",i),z=o.useMemo((()=>j.getEnabled()),[j]),F=(B=f,o.useMemo((()=>({draggable:{...Qv.draggable,...null==B?void 0:B.draggable},droppable:{...Qv.droppable,...null==B?void 0:B.droppable},dragOverlay:{...Qv.dragOverlay,...null==B?void 0:B.dragOverlay}})),[null==B?void 0:B.draggable,null==B?void 0:B.droppable,null==B?void 0:B.dragOverlay]));var B;const{droppableRects:U,measureDroppableContainers:$,measuringScheduled:H}=function(e,t){let{dragging:n,dependencies:r,config:s}=t;const[i,a]=o.useState(null),{frequency:l,measure:c,strategy:d}=s,u=o.useRef(e),h=function(){switch(d){case zv.Always:return!1;case zv.BeforeDragging:return n;default:return!n}}(),f=Vo(h),p=o.useCallback((function(e){void 0===e&&(e=[]),f.current||a((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[f]),m=o.useRef(null),g=Ko((t=>{if(h&&!n)return Uv;if(!t||t===Uv||u.current!==e||null!=i){const t=new Map;for(let n of e){if(!n)continue;if(i&&i.length>0&&!i.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,r=e?new uv(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t}),[e,i,n,h,c]);return o.useEffect((()=>{u.current=e}),[e]),o.useEffect((()=>{h||p()}),[n,h]),o.useEffect((()=>{i&&i.length>0&&a(null)}),[JSON.stringify(i)]),o.useEffect((()=>{h||"number"!=typeof l||null!==m.current||(m.current=setTimeout((()=>{p(),m.current=null}),l))}),[l,h,p,...r]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:null!=i}}(z,{dragging:S,dependencies:[N.x,N.y],config:F.droppable}),V=function(e,t){const n=null!=t?e.get(t):void 0,r=n?n.node.current:null;return Ko((e=>{var n;return null==t?null:null!=(n=null!=r?r:e)?n:null}),[r,t])}(E,C),W=o.useMemo((()=>O?Go(O):null),[O]),G=function(){const e=!1===(null==M?void 0:M.autoScrollEnabled),t="object"==typeof l?!1===l.enabled:!1===l,n=S&&!e&&!t;if("object"==typeof l)return{...l,enabled:n};return{enabled:n}}(),q=function(e,t){return $v(e,t)}(V,F.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:r,config:s=!0}=e;const i=o.useRef(!1),{x:a,y:l}="boolean"==typeof s?{x:s,y:s}:s;Yo((()=>{if(!a&&!l||!t)return void(i.current=!1);if(i.current||!r)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const o=Vx(n(e),r);if(a||(o.x=0),l||(o.y=0),i.current=!0,Math.abs(o.x)>0||Math.abs(o.y)>0){const t=Kx(e);t&&t.scrollBy({top:o.y,left:o.x})}}),[t,a,l,r,n])}({activeNode:null!=C?E.get(C):null,config:G.layoutShiftCompensation,initialRect:q,measure:F.draggable.measure});const Y=Wv(V,F.draggable.measure,q),X=Wv(V?V.parentElement:null),J=o.useRef({activatorEvent:null,active:null,activeNode:V,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:E,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),K=j.getNodeFor(null==(t=J.current.over)?void 0:t.id),Z=Jv({measure:F.dragOverlay.measure}),Q=null!=(n=Z.nodeRef.current)?n:V,ee=S?null!=(r=Z.rect)?r:Y:null,te=Boolean(Z.nodeRef.current&&Z.rect),ne=Vx(re=te?null:Y,$v(re));var re;const oe=Yv(Q?Fo(Q):null),se=function(e){const t=o.useRef(e),n=Ko((n=>e?n&&n!==Gv&&e&&t.current&&e.parentNode===t.current.parentNode?n:Jx(e):Gv),[e]);return o.useEffect((()=>{t.current=e}),[e]),n}(S?null!=K?K:V:null),ie=function(e,t){void 0===t&&(t=Yx);const[n]=e,r=Yv(n?Fo(n):null),[s,i]=o.useState(Xv);function a(){i((()=>e.length?e.map((e=>ov(e)?r:new uv(t(e),e))):Xv))}const l=Hv({callback:a});return Yo((()=>{null==l||l.disconnect(),a(),e.forEach((e=>null==l?void 0:l.observe(e)))}),[e]),s}(se),ae=function(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...r})),n):n}(p,{transform:{x:N.x-ne.x,y:N.y-ne.y,scaleX:1,scaleY:1},activatorEvent:O,active:A,activeNodeRect:Y,containerNodeRect:X,draggingNodeRect:ee,over:J.current.over,overlayNodeRect:Z.rect,scrollableAncestors:se,scrollableAncestorRects:ie,windowRect:oe}),le=W?Ho(W,N):null,ce=function(e){const[t,n]=o.useState(null),r=o.useRef(e),s=o.useCallback((e=>{const t=Zx(e.target);t&&n((e=>e?(e.set(t,tv(t)),new Map(e)):null))}),[]);return o.useEffect((()=>{const t=r.current;if(e!==t){o(t);const i=e.map((e=>{const t=Zx(e);return t?(t.addEventListener("scroll",s,{passive:!0}),[t,tv(t)]):null})).filter((e=>null!=e));n(i.length?new Map(i):null),r.current=e}return()=>{o(e),o(t)};function o(e){e.forEach((e=>{const t=Zx(e);null==t||t.removeEventListener("scroll",s)}))}}),[s,e]),o.useMemo((()=>e.length?t?Array.from(t.values()).reduce(((e,t)=>Ho(e,t)),Dx):cv(e):Dx),[e,t])}(se),de=qv(ce),ue=qv(ce,[Y]),he=Ho(ae,de),fe=ee?Gx(ee,ae):null,pe=A&&fe?h({active:A,collisionRect:fe,droppableRects:U,droppableContainers:z,pointerCoordinates:le}):null,me=zx(pe,"id"),[ge,ye]=o.useState(null),be=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(te?ae:Ho(ae,ue),null!=(s=null==ge?void 0:ge.rect)?s:null,Y),xe=o.useRef(null),ve=o.useCallback(((e,t)=>{let{sensor:n,options:r}=t;if(null==T.current)return;const o=E.get(T.current);if(!o)return;const s=e.nativeEvent,i=new n({active:T.current,activeNode:o,event:s,options:r,context:J,onAbort(e){if(!E.get(e))return;const{onDragAbort:t}=P.current,n={id:e};null==t||t(n),x({type:"onDragAbort",event:n})},onPending(e,t,n,r){if(!E.get(e))return;const{onDragPending:o}=P.current,s={id:e,constraint:t,initialCoordinates:n,offset:r};null==o||o(s),x({type:"onDragPending",event:s})},onStart(e){const t=T.current;if(null==t)return;const n=E.get(t);if(!n)return;const{onDragStart:r}=P.current,o={activatorEvent:s,active:{id:t,data:n.data,rect:I}};qo.unstable_batchedUpdates((()=>{null==r||r(o),k(cw.Initializing),b({type:Ix.DragStart,initialCoordinates:e,active:t}),x({type:"onDragStart",event:o}),D(xe.current),R(s)}))},onMove(e){b({type:Ix.DragMove,coordinates:e})},onEnd:a(Ix.DragEnd),onCancel:a(Ix.DragCancel)});function a(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:o}=J.current;let i=null;if(t&&o){const{cancelDrop:a}=P.current;if(i={activatorEvent:s,active:t,collisions:n,delta:o,over:r},e===Ix.DragEnd&&"function"==typeof a){await Promise.resolve(a(i))&&(e=Ix.DragCancel)}}T.current=null,qo.unstable_batchedUpdates((()=>{b({type:e}),k(cw.Uninitialized),ye(null),D(null),R(null),xe.current=null;const t=e===Ix.DragEnd?"onDragEnd":"onDragCancel";if(i){const e=P.current[t];null==e||e(i),x({type:t,event:i})}}))}}xe.current=i}),[E]),we=function(e,t){return o.useMemo((()=>e.reduce(((e,n)=>{const{sensor:r}=n;return[...e,...r.activators.map((e=>({eventName:e.eventName,handler:t(e.handler,n)})))]}),[])),[e,t])}(d,o.useCallback(((e,t)=>(n,r)=>{const o=n.nativeEvent,s=E.get(r);if(null!==T.current||!s||o.dndKit||o.defaultPrevented)return;const i={active:s};!0===e(n,t.options,i)&&(o.dndKit={capturedBy:t.sensor},T.current=r,ve(n,t))}),[E,ve]));!function(e){o.useEffect((()=>{if(!Zo)return;const t=e.map((e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()}));return()=>{for(const e of t)null==e||e()}}),e.map((e=>{let{sensor:t}=e;return t})))}(d),Yo((()=>{Y&&w===cw.Initializing&&k(cw.Initialized)}),[Y,w]),o.useEffect((()=>{const{onDragMove:e}=P.current,{active:t,activatorEvent:n,collisions:r,over:o}=J.current;if(!t||!n)return;const s={active:t,activatorEvent:n,collisions:r,delta:{x:he.x,y:he.y},over:o};qo.unstable_batchedUpdates((()=>{null==e||e(s),x({type:"onDragMove",event:s})}))}),[he.x,he.y]),o.useEffect((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:o}=J.current;if(!e||null==T.current||!t||!o)return;const{onDragOver:s}=P.current,i=r.get(me),a=i&&i.rect.current?{id:i.id,rect:i.rect.current,data:i.data,disabled:i.disabled}:null,l={active:e,activatorEvent:t,collisions:n,delta:{x:o.x,y:o.y},over:a};qo.unstable_batchedUpdates((()=>{ye(a),null==s||s(l),x({type:"onDragOver",event:l})}))}),[me]),Yo((()=>{J.current={activatorEvent:O,active:A,activeNode:V,collisionRect:fe,collisions:pe,droppableRects:U,draggableNodes:E,draggingNode:Q,draggingNodeRect:ee,droppableContainers:j,over:ge,scrollableAncestors:se,scrollAdjustedTranslate:he},I.current={initial:ee,translated:fe}}),[A,V,pe,fe,E,Q,ee,U,j,ge,se,he]),Pv({...G,delta:N,draggingRect:fe,pointerCoordinates:le,scrollableAncestors:se,scrollableAncestorRects:ie});const ke=o.useMemo((()=>({active:A,activeNode:V,activeNodeRect:Y,activatorEvent:O,collisions:pe,containerNodeRect:X,dragOverlay:Z,draggableNodes:E,droppableContainers:j,droppableRects:U,over:ge,measureDroppableContainers:$,scrollableAncestors:se,scrollableAncestorRects:ie,measuringConfiguration:F,measuringScheduled:H,windowRect:oe})),[A,V,Y,O,pe,X,Z,E,j,U,ge,$,se,ie,F,H,oe]),Se=o.useMemo((()=>({activatorEvent:O,activators:we,active:A,activeNodeRect:Y,ariaDescribedById:{draggable:L},dispatch:b,draggableNodes:E,over:ge,measureDroppableContainers:$})),[O,we,A,Y,b,L,E,ge,$]);return u.createElement(Ex.Provider,{value:v},u.createElement(rw.Provider,{value:Se},u.createElement(ow.Provider,{value:ke},u.createElement(lw.Provider,{value:be},c)),u.createElement(aw,{disabled:!1===(null==a?void 0:a.restoreFocus)})),u.createElement(_x,{...a,hiddenTextDescribedById:L}))})),hw=o.createContext(null),fw="button";function pw(e){let{id:t,data:n,disabled:r=!1,attributes:s}=e;const i=Wo("Draggable"),{activators:a,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=o.useContext(rw),{role:p=fw,roleDescription:m="draggable",tabIndex:g=0}=null!=s?s:{},y=(null==c?void 0:c.id)===t,b=o.useContext(y?lw:hw),[x,v]=es(),[w,k]=es(),S=function(e,t){return o.useMemo((()=>e.reduce(((e,n)=>{let{eventName:r,handler:o}=n;return e[r]=e=>{o(e,t)},e}),{})),[e,t])}(a,t),C=Vo(n);Yo((()=>(h.set(t,{id:t,key:i,node:x,activatorNode:w,data:C}),()=>{const e=h.get(t);e&&e.key===i&&h.delete(t)})),[h,t]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:o.useMemo((()=>({role:p,tabIndex:g,"aria-disabled":r,"aria-pressed":!(!y||p!==fw)||void 0,"aria-roledescription":m,"aria-describedby":u.draggable})),[r,p,g,y,m,u.draggable]),isDragging:y,listeners:r?void 0:S,node:x,over:f,setNodeRef:v,setActivatorNodeRef:k,transform:b}}const mw={timeout:25};function gw(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function yw(e,t){return e.reduce(((e,n,r)=>{const o=t.get(n);return o&&(e[r]=o),e}),Array(e.length))}function bw(e){return null!==e&&e>=0}const xw={scaleX:1,scaleY:1},vw=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:s,index:i}=e;const a=null!=(t=n[o])?t:r;if(!a)return null;const l=function(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];if(!r||!o&&!s)return 0;if(n<t)return o?r.left-(o.left+o.width):s.left-(r.left+r.width);return s?s.left-(r.left+r.width):r.left-(o.left+o.width)}(n,i,o);if(i===o){const e=n[s];return e?{x:o<s?e.left+e.width-(a.left+a.width):e.left-a.left,y:0,...xw}:null}return i>o&&i<=s?{x:-a.width-l,y:0,...xw}:i<o&&i>=s?{x:a.width+l,y:0,...xw}:{x:0,y:0,...xw}};const ww=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=gw(t,r,n),i=t[o],a=s[o];return a&&i?{x:a.left-i.left,y:a.top-i.top,scaleX:a.width/i.width,scaleY:a.height/i.height}:null},kw={scaleX:1,scaleY:1},Sw=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:s,overIndex:i}=e;const a=null!=(t=s[n])?t:r;if(!a)return null;if(o===n){const e=s[i];return e?{x:0,y:n<i?e.top+e.height-(a.top+a.height):e.top-a.top,...kw}:null}const l=function(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];if(!r)return 0;if(n<t)return o?r.top-(o.top+o.height):s?s.top-(r.top+r.height):0;return s?s.top-(r.top+r.height):o?r.top-(o.top+o.height):0}(s,o,n);return o>n&&o<=i?{x:0,y:-a.height-l,...kw}:o<n&&o>=i?{x:0,y:a.height+l,...kw}:{x:0,y:0,...kw}};const Cw="Sortable",Ew=u.createContext({activeIndex:-1,containerId:Cw,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:ww,disabled:{draggable:!1,droppable:!1}});function Nw(e){let{children:t,id:n,items:r,strategy:s=ww,disabled:i=!1}=e;const{active:a,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=o.useContext(ow),f=Wo(Cw,n),p=Boolean(null!==l.rect),m=o.useMemo((()=>r.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[r]),g=null!=a,y=a?m.indexOf(a.id):-1,b=d?m.indexOf(d.id):-1,x=o.useRef(m),v=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(m,x.current),w=-1!==b&&-1===y||v,k=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(i);Yo((()=>{v&&g&&h(m)}),[v,m,g,h]),o.useEffect((()=>{x.current=m}),[m]);const S=o.useMemo((()=>({activeIndex:y,containerId:f,disabled:k,disableTransforms:w,items:m,overIndex:b,useDragOverlay:p,sortedRects:yw(m,c),strategy:s})),[y,f,k.draggable,k.droppable,w,m,b,c,p,s]);return u.createElement(Ew.Provider,{value:S},t)}const jw=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return gw(n,r,o).indexOf(t)},_w=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:a,previousContainerId:l,transition:c}=e;return!(!c||!r)&&((a===s||o!==i)&&(!!n||i!==o&&t===l))},Iw={duration:200,easing:"ease"},Aw="transform",Tw=ls.Transition.toString({property:Aw,duration:0,easing:"linear"}),Mw={roleDescription:"sortable"};function Dw(e){let{animateLayoutChanges:t=_w,attributes:n,disabled:r,data:s,getNewIndex:i=jw,id:a,strategy:l,resizeObserverConfig:c,transition:d=Iw}=e;const{items:u,containerId:h,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:g,overIndex:y,useDragOverlay:b,strategy:x}=o.useContext(Ew),v=function(e,t){var n,r;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(r=null==e?void 0:e.droppable)?r:t.droppable}}(r,p),w=u.indexOf(a),k=o.useMemo((()=>({sortable:{containerId:h,index:w,items:u},...s})),[h,s,w,u]),S=o.useMemo((()=>u.slice(u.indexOf(a))),[u,a]),{rect:C,node:E,isOver:N,setNodeRef:j}=function(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:s}=e;const i=Wo("Droppable"),{active:a,dispatch:l,over:c,measureDroppableContainers:d}=o.useContext(rw),u=o.useRef({disabled:n}),h=o.useRef(!1),f=o.useRef(null),p=o.useRef(null),{disabled:m,updateMeasurementsFor:g,timeout:y}={...mw,...s},b=Vo(null!=g?g:r),x=Hv({callback:o.useCallback((()=>{h.current?(null!=p.current&&clearTimeout(p.current),p.current=setTimeout((()=>{d(Array.isArray(b.current)?b.current:[b.current]),p.current=null}),y)):h.current=!0}),[y]),disabled:m||!a}),v=o.useCallback(((e,t)=>{x&&(t&&(x.unobserve(t),h.current=!1),e&&x.observe(e))}),[x]),[w,k]=es(v),S=Vo(t);return o.useEffect((()=>{x&&w.current&&(x.disconnect(),h.current=!1,x.observe(w.current))}),[w,x]),o.useEffect((()=>(l({type:Ix.RegisterDroppable,element:{id:r,key:i,disabled:n,node:w,rect:f,data:S}}),()=>l({type:Ix.UnregisterDroppable,key:i,id:r}))),[r]),o.useEffect((()=>{n!==u.current.disabled&&(l({type:Ix.SetDroppableDisabled,id:r,key:i,disabled:n}),u.current.disabled=n)}),[r,i,n,l]),{active:a,rect:f,isOver:(null==c?void 0:c.id)===r,node:w,over:c,setNodeRef:k}}({id:a,data:k,disabled:v.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:_,activatorEvent:I,activeNodeRect:A,attributes:T,setNodeRef:M,listeners:D,isDragging:O,over:R,setActivatorNodeRef:P,transform:L}=pw({id:a,data:k,attributes:{...Mw,...n},disabled:v.draggable}),z=as(j,M),F=Boolean(_),B=F&&!m&&bw(f)&&bw(y),U=!b&&O,$=U&&B?L:null,H=B?null!=$?$:(null!=l?l:x)({rects:g,activeNodeRect:A,activeIndex:f,overIndex:y,index:w}):null,V=bw(f)&&bw(y)?i({id:a,items:u,activeIndex:f,overIndex:y}):w,W=null==_?void 0:_.id,G=o.useRef({activeId:W,items:u,newIndex:V,containerId:h}),q=u!==G.current.items,Y=t({active:_,containerId:h,isDragging:O,isSorting:F,id:a,index:w,items:u,newIndex:G.current.newIndex,previousItems:G.current.items,previousContainerId:G.current.containerId,transition:d,wasDragging:null!=G.current.activeId}),X=function(e){let{disabled:t,index:n,node:r,rect:s}=e;const[i,a]=o.useState(null),l=o.useRef(n);return Yo((()=>{if(!t&&n!==l.current&&r.current){const e=s.current;if(e){const t=Yx(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&a(n)}}n!==l.current&&(l.current=n)}),[t,n,r,s]),o.useEffect((()=>{i&&a(null)}),[i]),i}({disabled:!Y,index:w,node:E,rect:C});return o.useEffect((()=>{F&&G.current.newIndex!==V&&(G.current.newIndex=V),h!==G.current.containerId&&(G.current.containerId=h),u!==G.current.items&&(G.current.items=u)}),[F,V,h,u]),o.useEffect((()=>{if(W===G.current.activeId)return;if(null!=W&&null==G.current.activeId)return void(G.current.activeId=W);const e=setTimeout((()=>{G.current.activeId=W}),50);return()=>clearTimeout(e)}),[W]),{active:_,activeIndex:f,attributes:T,data:k,rect:C,index:w,newIndex:V,items:u,isOver:N,isSorting:F,isDragging:O,listeners:D,node:E,overIndex:y,over:R,setNodeRef:z,setActivatorNodeRef:P,setDroppableNodeRef:j,setDraggableNodeRef:M,transform:null!=X?X:H,transition:function(){if(X||q&&G.current.newIndex===w)return Tw;if(U&&!Uo(I)||!d)return;if(F||Y)return ls.Transition.toString({...d,property:Aw});return}()}}function Ow(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&"object"==typeof t.sortable&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const Rw=[gv.Down,gv.Right,gv.Up,gv.Left],Pw=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:s,over:i,scrollableAncestors:a}}=t;if(Rw.includes(e.code)){if(e.preventDefault(),!n||!r)return;const t=[];s.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const s=o.get(n.id);if(s)switch(e.code){case gv.Down:r.top<s.top&&t.push(n);break;case gv.Up:r.top>s.top&&t.push(n);break;case gv.Left:r.left>s.left&&t.push(n);break;case gv.Right:r.left<s.left&&t.push(n)}}));const l=(e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Lx(t),s=[];for(const i of r){const{id:e}=i,t=n.get(e);if(t){const n=Lx(t),r=o.reduce(((e,t,r)=>e+Ox(n[r],t)),0),a=Number((r/4).toFixed(4));s.push({id:e,data:{droppableContainer:i,value:a}})}}return s.sort(Rx)})({active:n,collisionRect:r,droppableRects:o,droppableContainers:t,pointerCoordinates:null});let c=zx(l,"id");if(c===(null==i?void 0:i.id)&&l.length>1&&(c=l[1].id),null!=c){const e=s.get(n.id),t=s.get(c),i=t?o.get(t.id):null,l=null==t?void 0:t.node.current;if(l&&i&&e&&t){const n=Jx(l).some(((e,t)=>a[t]!==e)),o=Lw(e,t),s=function(e,t){if(!Ow(e)||!Ow(t))return!1;if(!Lw(e,t))return!1;return e.data.current.sortable.index<t.data.current.sortable.index}(e,t),c=n||!o?{x:0,y:0}:{x:s?r.width-i.width:0,y:s?r.height-i.height:0},d={x:i.left,y:i.top};return c.x&&c.y?d:$o(d,c)}}}};function Lw(e,t){return!(!Ow(e)||!Ow(t))&&e.data.current.sortable.containerId===t.data.current.sortable.containerId}function zw(...e){return t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}}const Fw=u.createContext(null),Bw=o.memo((()=>o.useContext(Fw)));Bw.displayName="DragHandle";const Uw=u.forwardRef(((e,t)=>{const n=j.c(21);let r,o,s,i,a;n[0]!==e?(({cellId:o,canMoveX:r,...s}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]),n[4]!==o?(i=o.toString(),n[4]=o,n[5]=i):i=n[5],n[6]!==i?(a={id:i},n[6]=i,n[7]=a):a=n[7];const{attributes:l,listeners:c,setNodeRef:d,transform:u,transition:h,isDragging:f}=Dw(a);let p;n[8]!==u?(p=function(e){return!e||0===e.x&&0===e.y&&1===e.scaleX&&1===e.scaleY}(u)?null:u,n[8]=u,n[9]=p):p=n[9];const m=p,g=null==m?void 0:h;let y;return n[10]!==l||n[11]!==r||n[12]!==o||n[13]!==f||n[14]!==c||n[15]!==s||n[16]!==t||n[17]!==d||n[18]!==m||n[19]!==g?(y=I.jsx($w,{ref:t,cellId:o,canMoveX:r,...s,attributes:l,listeners:c,setNodeRef:d,transform:m,transition:g,isDragging:f}),n[10]=l,n[11]=r,n[12]=o,n[13]=f,n[14]=c,n[15]=s,n[16]=t,n[17]=d,n[18]=m,n[19]=g,n[20]=y):y=n[20],y}));Uw.displayName="SortableCell";const $w=u.forwardRef(((e,t)=>{const n=j.c(37);let r,o,s,i,a,l,c,d,u,h;if(n[0]!==e){const{cellId:t,canMoveX:h,children:f,attributes:p,listeners:m,setNodeRef:g,transform:y,transition:b,isDragging:x,...v}=e;o=h,s=f,r=p,a=m,c=g,d=y,u=b,i=x,l=v,n[0]=e,n[1]=r,n[2]=o,n[3]=s,n[4]=i,n[5]=a,n[6]=l,n[7]=c,n[8]=d,n[9]=u}else r=n[1],o=n[2],s=n[3],i=n[4],a=n[5],l=n[6],c=n[7],d=n[8],u=n[9];n[10]!==o||n[11]!==d?(h=d?ls.Transform.toString({x:o?d.x:0,y:d.y,scaleX:1,scaleY:1}):void 0,n[10]=o,n[11]=d,n[12]=h):h=n[12];const f=i?2:void 0;let p;n[13]!==h||n[14]!==f||n[15]!==u?(p={transform:h,transition:u,zIndex:f,position:"relative"},n[13]=h,n[14]=f,n[15]=u,n[16]=p):p=n[16];const m=p;let g,y;n[17]===Symbol.for("react.memo_cache_sentinel")?(g=I.jsx(Qc,{strokeWidth:1,size:20}),n[17]=g):g=n[17],n[18]!==r||n[19]!==a?(y=I.jsx("div",{...r,...a,onMouseDown:ot.preventFocus,"data-testid":"drag-button",className:"py-[1px] cursor-grab opacity-50 hover:opacity-100 hover-action hover:bg-muted rounded border border-transparent hover:border-border active:bg-accent",children:g}),n[18]=r,n[19]=a,n[20]=y):y=n[20];const b=y,x=Boolean(d);let v;n[21]!==t||n[22]!==c?(v=e=>{zw(t,c)(e)},n[21]=t,n[22]=c,n[23]=v):v=n[23];const w=x&&"is-moving";let k,S,C;return n[24]!==l.className||n[25]!==w?(k=In(l.className,w,"outline-offset-4 outline-primary/40 rounded-lg"),n[24]=l.className,n[25]=w,n[26]=k):k=n[26],n[27]!==s||n[28]!==b?(S=I.jsx(Fw.Provider,{value:b,children:s}),n[27]=s,n[28]=b,n[29]=S):S=n[29],n[30]!==i||n[31]!==l||n[32]!==m||n[33]!==v||n[34]!==k||n[35]!==S?(C=I.jsx("div",{tabIndex:-1,ref:v,...l,"data-is-dragging":i,className:k,style:m,children:S}),n[30]=i,n[31]=l,n[32]=m,n[33]=v,n[34]=k,n[35]=S,n[36]=C):C=n[36],C}));$w.displayName="SortableCellInternal";const Hw=u.memo(u.forwardRef(((e,t)=>{const n=j.c(34);let r,s,i;n[0]!==e?(({children:r,showTooltip:i,...s}=e),n[0]=e,n[1]=r,n[2]=s,n[3]=i):(r=n[1],s=n[2],i=n[3]);const a=void 0===i||i,[l,c]=o.useState(!1);let d;n[4]!==s?(d={cell:s},n[4]=s,n[5]=d):d=n[5];const u=xu(d),h=cs();let f,p,m,g,y,b;if(n[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>({toggle:()=>c(Ww)}),n[6]=f):f=n[6],o.useImperativeHandle(t,f),n[7]===Symbol.for("react.memo_cache_sentinel")?(p=I.jsx(Xe,{placeholder:"Search actions...",className:"h-6 m-1"}),n[7]=p):p=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(m=I.jsx(Ke,{children:"No results"}),n[8]=m):m=n[8],n[9]!==u){let e;n[11]!==u.length?(e=(e,t)=>I.jsxs(o.Fragment,{children:[I.jsx(Ue,{children:e.map((e=>I.jsx(We,{onSelect:()=>{e.disableClick||(e.handle(),c(!1))},variant:e.variant,children:I.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&I.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:e.icon}),I.jsx("div",{className:"flex-1",children:e.label}),I.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&ds(e.hotkey),e.rightElement]})]})},e.label)))},t),t<u.length-1&&I.jsx(He,{})]},t),n[11]=u.length,n[12]=e):e=n[12],g=u.map(e),n[9]=u,n[10]=g}else g=n[10];n[13]!==g?(y=I.jsxs(On,{children:[p,I.jsxs(us,{children:[m,g]})]}),n[13]=g,n[14]=y):y=n[14],n[15]!==h||n[16]!==y?(b=I.jsx(Dn,{className:"w-[300px] p-0 pt-1",...h,children:y}),n[15]=h,n[16]=y,n[17]=b):b=n[17];const x=b;if(!a){let e,t;return n[18]!==r?(e=I.jsx(hs,{asChild:!0,children:r}),n[18]=r,n[19]=e):e=n[19],n[20]!==x||n[21]!==l||n[22]!==e?(t=I.jsxs(Pn,{open:l,onOpenChange:c,children:[e,x]}),n[20]=x,n[21]=l,n[22]=e,n[23]=t):t=n[23],t}let v;n[24]===Symbol.for("react.memo_cache_sentinel")?(v=I.jsx(fs,{tabIndex:-1,children:Bt("cell.cellActions")}),n[24]=v):v=n[24];const w=!l&&v;let k,S,C;return n[25]!==r?(k=I.jsx(ps,{children:I.jsx(hs,{className:"flex",children:r})}),n[25]=r,n[26]=k):k=n[26],n[27]!==w||n[28]!==k?(S=I.jsxs(ms,{delayDuration:200,disableHoverableContent:!0,children:[w,k]}),n[27]=w,n[28]=k,n[29]=S):S=n[29],n[30]!==x||n[31]!==l||n[32]!==S?(C=I.jsxs(Pn,{open:l,onOpenChange:c,children:[S,x]}),n[30]=x,n[31]=l,n[32]=S,n[33]=C):C=n[33],C}))),Vw=u.memo((e=>{const t=j.c(5),{children:n,cellId:r}=e;let o,s;t[0]!==r?(s=function(e){return q((t=>ju(e,t(ne))))}(r),t[0]=r,t[1]=s):s=t[1],o=s;const i=se(o);if(!i)return null;let a;return t[2]!==n||t[3]!==i?(a=I.jsx(Hw,{showTooltip:!1,...i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}));function Ww(e){return!e}Vw.displayName="ConnectionCellActionsDropdown";const Gw=e=>{const t=j.c(30);let n,r,o;t[0]!==e?(({children:n,...r}=e),t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),t[3]!==r?(o={cell:r},t[3]=r,t[4]=o):o=t[4];const s=xu(o),[i,a]=u.useState(),l=Boolean(i);let c,d,h,f,p,m,g,y,b;if(t[5]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx(st,{size:13,strokeWidth:1.5}),t[5]=c):c=t[5],t[6]!==r.cellId?(d=async()=>{var e;if(null==(e=window.getSelection())?void 0:e.toString())return void document.execCommand("copy");const t=document.getElementById(z.create(r.cellId));t?await nt(t.textContent??""):w.warn("cell-context-menu: output not found")},t[6]=r.cellId,t[7]=d):d=t[7],t[8]!==s||t[9]!==n||t[10]!==i||t[11]!==r||t[12]!==l||t[13]!==d){const e=[{label:"Copy",hidden:l,icon:c,handle:d},{label:"Cut",hidden:Boolean(i),icon:I.jsx(Cd,{size:13,strokeWidth:1.5}),handle:qw},{label:"Paste",hidden:Boolean(i),icon:I.jsx(Bc,{size:13,strokeWidth:1.5}),handle:async()=>{const{getEditorView:e}=r,t=e();if(t)try{const e=await navigator.clipboard.readText();if(e){const{from:n,to:r}=t.state.selection.main,o=t.state.update({changes:{from:n,to:r,insert:e}});t.dispatch(o)}}catch(n){const e=n;w.error("Failed to paste from clipboard",e),gs({command:"paste"})}}},{label:"Copy image",hidden:!i,icon:I.jsx(Fc,{size:13,strokeWidth:1.5}),handle:async()=>{if(i){const e=await fetch(i.src),t=await e.blob(),n=new ClipboardItem({[t.type]:t});await navigator.clipboard.write([n]).then(Yw).catch(Xw)}}},{icon:I.jsx($l,{size:13,strokeWidth:1.5}),label:"Download image",hidden:!i,handle:()=>{if(i){const e=document.createElement("a");e.download="image.png",e.href=i.src,e.click()}}},{label:"Go to Definition",icon:I.jsx(ys,{size:13,strokeWidth:1.5}),handle:()=>{const{getEditorView:e}=r,t=e();t&&bs(t)}}];let o;f=tx,t[19]===Symbol.for("react.memo_cache_sentinel")?(o=e=>{e.target instanceof HTMLImageElement?a(e.target):a(void 0)},t[19]=o):o=t[19],t[20]!==n?(g=I.jsx(nx,{onContextMenu:o,asChild:!0,children:n}),t[20]=n,t[21]=g):g=t[21],h=sx,p="w-[300px]",m=[e,...s].map(Kw),t[8]=s,t[9]=n,t[10]=i,t[11]=r,t[12]=l,t[13]=d,t[14]=h,t[15]=f,t[16]=p,t[17]=m,t[18]=g}else h=t[14],f=t[15],p=t[16],m=t[17],g=t[18];return t[22]!==h||t[23]!==p||t[24]!==m?(y=I.jsx(h,{className:p,children:m}),t[22]=h,t[23]=p,t[24]=m,t[25]=y):y=t[25],t[26]!==f||t[27]!==g||t[28]!==y?(b=I.jsxs(f,{children:[g,y]}),t[26]=f,t[27]=g,t[28]=y,t[29]=b):b=t[29],b};function qw(){document.execCommand("cut")}function Yw(){ee({title:"Copied image to clipboard"})}function Xw(e){ee({title:"Failed to copy image to clipboard. Try downloading instead.",description:e.message}),w.error("Failed to copy image to clipboard",e)}function Jw(e){return e.hidden?null:I.jsx(ix,{onSelect:t=>{e.handle(t)},variant:e.variant,children:I.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&I.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:e.icon}),I.jsx("div",{className:"flex-1",children:e.label}),I.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&ds(e.hotkey),e.rightElement]})]})},e.label)}function Kw(e,t){return I.jsxs(o.Fragment,{children:[e.map(Jw),t<e.length-1&&I.jsx(ax,{})]},t)}const Zw=e=>{const t=j.c(24),{editorView:n,code:r,currentLanguageAdapter:o,onAfterToggle:s}=e;let i,a;t[0]!==r?(a=(new Rt).isSupported(r)||""===r.trim(),t[0]=r,t[1]=a):a=t[1],i=a;const l=i;let c,d;t[2]!==r?(d=(new Ro).isSupported(r)||""===r.trim(),t[2]=r,t[3]=d):d=t[3],c=d;const u=c&&"python"===o;let h,f;t[4]===Symbol.for("react.memo_cache_sentinel")?(h=I.jsx(ve,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),t[4]=h):h=t[4],t[5]!==o||t[6]!==n||t[7]!==s||t[8]!==u?(f=I.jsx(Qw,{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:u,icon:h,toType:"sql",displayName:"SQL",onAfterToggle:s}),t[5]=o,t[6]=n,t[7]=s,t[8]=u,t[9]=f):f=t[9];const p=l&&"python"===o;let m,g,y,b,x;return t[10]===Symbol.for("react.memo_cache_sentinel")?(m=I.jsx(cl,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[10]=m):m=t[10],t[11]!==o||t[12]!==n||t[13]!==s||t[14]!==p?(g=I.jsx(Qw,{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:p,icon:m,toType:"markdown",displayName:"Markdown",onAfterToggle:s}),t[11]=o,t[12]=n,t[13]=s,t[14]=p,t[15]=g):g=t[15],t[16]===Symbol.for("react.memo_cache_sentinel")?(y=I.jsx(dl,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[16]=y):y=t[16],t[17]!==o||t[18]!==n?(b=I.jsx(Qw,{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:!0,icon:y,toType:"python",displayName:"Python",onAfterToggle:Kn.NOOP}),t[17]=o,t[18]=n,t[19]=b):b=t[19],t[20]!==g||t[21]!==b||t[22]!==f?(x=I.jsxs("div",{className:"absolute right-3 top-2 z-20 flex hover-action gap-1",children:[f,g,b]}),t[20]=g,t[21]=b,t[22]=f,t[23]=x):x=t[23],x},Qw=e=>{const t=j.c(10),{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:o,icon:s,toType:i,displayName:a,onAfterToggle:l}=e;let c;t[0]!==n||t[1]!==l||t[2]!==i?(c=()=>{n&&(xe(n,i),l())},t[0]=n,t[1]=l,t[2]=i,t[3]=c):c=t[3];const d=c;if(!o)return null;if(r===i)return null;const u=`View as ${a}`;let h,f;return t[4]!==d||t[5]!==s?(h=I.jsx(X,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:d,children:s}),t[4]=d,t[5]=s,t[6]=h):h=t[6],t[7]!==u||t[8]!==h?(f=I.jsx(it,{content:u,children:h}),t[7]=u,t[8]=h,t[9]=f):f=t[9],f};var ek={modified:{doc:""},original:{doc:""}},tk=o.createContext(ek);function nk(e,t){return xs({},e,t,{modified:xs({},e.modified,t.modified),original:xs({},e.original,t.original)})}var rk=()=>o.useContext(tk),ok=e=>{var{children:t,theme:n}=e,[r,s]=o.useReducer(nk,xs({},ek,{theme:n}));return o.useEffect((()=>s({theme:n})),[n]),I.jsx(tk.Provider,{value:xs({},r,{dispatch:s}),children:t})},sk=["extensions","value","selection","onChange"],ik=e=>{var{extensions:t=[],value:n,selection:r,onChange:s}=e,i=vs(e,sk),{theme:a,dispatch:l}=rk(),c=ws(xs({},i,{theme:a}));return o.useEffect((()=>l({original:{doc:n,selection:r,extensions:[...c,...t]},originalExtension:{onChange:s,option:i,extension:[t]}})),[e]),null};ik.displayName="CodeMirrorMerge.Original";var ak=["extensions","value","selection","onChange"],lk=e=>{var{extensions:t=[],value:n,selection:r,onChange:s}=e,i=vs(e,ak),{theme:a,dispatch:l}=rk(),c=ws(xs({},i,{theme:a}));return o.useEffect((()=>{l({modified:{doc:n,selection:r,extensions:[...c,...t]},modifiedExtension:{onChange:s,option:i,extension:[t]}})}),[e]),null};lk.displayName="CodeMirrorMerge.Modified";class ck{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(e,t){return new ck(this.fromA+e,this.toA+e,this.fromB+t,this.toB+t)}}function dk(e,t,n,r,o,s){if(e==r)return[];let i=yk(e,t,n,r,o,s),a=bk(e,t+i,n,r,o+i,s),l=(n-=a)-(t+=i),c=(s-=a)-(o+=i);if(!l||!c)return[new ck(t,n,o,s)];if(l>c){let i=e.slice(t,n).indexOf(r.slice(o,s));if(i>-1)return[new ck(t,t+i,o,o),new ck(t+i+c,n,s,s)]}else if(c>l){let i=r.slice(o,s).indexOf(e.slice(t,n));if(i>-1)return[new ck(t,t,o,o+i),new ck(n,n,o+i+l,s)]}if(1==l||1==c)return[new ck(t,n,o,s)];let d=vk(e,t,n,r,o,s);if(d){let[i,a,l]=d;return dk(e,t,i,r,o,a).concat(dk(e,i+l,n,r,a+l,s))}return function(e,t,n,r,o,s){let i=n-t,a=s-o;if(uk<1e9&&Math.min(i,a)>16*uk)return Math.min(i,a)>64*uk?[new ck(t,n,o,s)]:wk(e,t,n,r,o,s);let l=Math.ceil((i+a)/2);fk.reset(l),pk.reset(l);let c=(n,s)=>e.charCodeAt(t+n)==r.charCodeAt(o+s),d=(t,o)=>e.charCodeAt(n-t-1)==r.charCodeAt(s-o-1),u=(i-a)%2!=0?pk:null,h=u?null:fk;for(let f=0;f<l;f++){if(f>uk)return wk(e,t,n,r,o,s);let p=fk.advance(f,i,a,l,u,!1,c)||pk.advance(f,i,a,l,h,!0,d);if(p)return mk(e,t,n,t+p[0],r,o,s,o+p[1])}return[new ck(t,n,o,s)]}(e,t,n,r,o,s)}let uk=1e9;class hk{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let t=0;t<this.len;t++)this.vec[t]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,o,s,i){for(let a=-e+this.start;a<=e-this.end;a+=2){let l=r+a,c=a==-e||a!=e&&this.vec[l-1]<this.vec[l+1]?this.vec[l+1]:this.vec[l-1]+1,d=c-a;for(;c<t&&d<n&&i(c,d);)c++,d++;if(this.vec[l]=c,c>t)this.end+=2;else if(d>n)this.start+=2;else if(o){let e=r+(t-n)-a;if(e>=0&&e<this.len&&-1!=o.vec[e])if(s){let n=o.vec[e];if(n>=t-c)return[n,r+n-e]}else{if(c>=t-o.vec[e])return[c,d]}}}return null}}const fk=new hk,pk=new hk;function mk(e,t,n,r,o,s,i,a){let l=!1;return Mk(e,r)||++r!=n||(l=!0),Mk(o,a)||++a!=i||(l=!0),l?[new ck(t,n,s,i)]:dk(e,t,r,o,s,a).concat(dk(e,r,n,o,a,i))}function gk(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function yk(e,t,n,r,o,s){if(t==n||t==s||e.charCodeAt(t)!=r.charCodeAt(o))return 0;let i=gk(n-t,s-o);for(let a=t,l=o;;){let o=a+i,c=l+i;if(o>n||c>s||e.slice(a,o)!=r.slice(l,c)){if(1==i)return a-t-(Mk(e,a)?0:1);i>>=1}else{if(o==n||c==s)return o-t;a=o,l=c}}}function bk(e,t,n,r,o,s){if(t==n||o==s||e.charCodeAt(n-1)!=r.charCodeAt(s-1))return 0;let i=gk(n-t,s-o);for(let a=n,l=s;;){let s=a-i,c=l-i;if(s<t||c<o||e.slice(s,a)!=r.slice(c,l)){if(1==i)return n-a-(Mk(e,a)?0:1);i>>=1}else{if(s==t||c==o)return n-s;a=s,l=c}}}function xk(e,t,n,r,o,s,i,a){let l=r.slice(o,s),c=null;for(;;){if(c||i<a)return c;for(let a=t+i;;){Mk(e,a)||a++;let d=a+i;if(Mk(e,d)||(d+=d==a+1?1:-1),d>=n)break;let u=e.slice(a,d),h=-1;for(;-1!=(h=l.indexOf(u,h+1));){let i=yk(e,d,n,r,o+h+u.length,s),l=bk(e,t,a,r,o,o+h),f=u.length+i+l;(!c||c[2]<f)&&(c=[a-l,o+h-l,f])}a=d}if(a<0)return c;i>>=1}}function vk(e,t,n,r,o,s){let i=n-t,a=s-o;if(i<a){let i=vk(r,o,s,e,t,n);return i&&[i[1],i[0],i[2]]}return i<4||2*a<i?null:xk(e,t,n,r,o,s,Math.floor(i/4),-1)}function wk(e,t,n,r,o,s){let i,a=n-t,l=s-o;if(a<l){let l=xk(r,o,s,e,t,n,Math.floor(a/6),50);i=l&&[l[1],l[0],l[2]]}else i=xk(e,t,n,r,o,s,Math.floor(l/6),50);if(!i)return[new ck(t,n,o,s)];let[c,d,u]=i;return dk(e,t,c,r,o,d).concat(dk(e,c+u,n,r,d+u,s))}function kk(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],o=e[n];r.toA>o.fromA-t&&r.toB>o.fromB-t&&(e[n-1]=new ck(r.fromA,o.toA,r.fromB,o.toB),e.splice(n--,1))}}let Sk;try{Sk=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch(sX){}function Ck(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Ek(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?Ck(n)?1:0:Sk?Ak(n)&&t!=e.length-1?Sk.test(e.slice(t,t+2))?2:0:Sk.test(String.fromCharCode(n))?1:0:0}function Nk(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?Ck(n)?1:0:Sk?Tk(n)&&1!=t?Sk.test(e.slice(t-2,t))?2:0:Sk.test(String.fromCharCode(n))?1:0:0}function jk(e,t,n){if(t==e.length||!Nk(e,t))return t;for(let r=t,o=t+n;;){let n=Ek(e,r);if(!n)return r;if(r+=n,r>o)return t}}function _k(e,t,n){if(!t||!Ek(e,t))return t;for(let r=t,o=t-n;;){let n=Nk(e,r);if(!n)return r;if(r-=n,r<o)return t}}function Ik(e,t,n){for(let r=t,o=t-n;;){let n=r?e.charCodeAt(r-1):10;if(10==n)return r;if(r--,r<o||32!=n&&9!=n)return t}}const Ak=e=>e>=55296&&e<=56319,Tk=e=>e>=56320&&e<=57343;function Mk(e,t){return!t||t==e.length||!Ak(e.charCodeAt(t-1))||!Tk(e.charCodeAt(t))}function Dk(e,t,n){var r;return uk=(null!==(r=null==n?void 0:n.scanLimit)&&void 0!==r?r:1e9)>>1,function(e,t,n){for(;;){kk(n,1);let r=!1;for(let o=0;o<n.length;o++){let s,i,a=n[o];(s=yk(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new ck(a.fromA+s,a.toA,a.fromB+s,a.toB)),(i=bk(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new ck(a.fromA,a.toA-i,a.fromB,a.toB-i));let l=a.toA-a.fromA,c=a.toB-a.fromB;if(l&&c)continue;let d=a.fromA-(o?n[o-1].toA:0),u=(o<n.length-1?n[o+1].fromA:e.length)-a.toA;if(!d||!u)continue;let h=l?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);d<=h.length&&e.slice(a.fromA-d,a.fromA)==h.slice(h.length-d)?(n[o]=new ck(a.fromA-d,a.toA-d,a.fromB-d,a.toB-d),r=!0):u<=h.length&&e.slice(a.toA,a.toA+u)==h.slice(0,u)&&(n[o]=new ck(a.fromA+u,a.toA+u,a.fromB+u,a.toB+u),r=!0)}if(!r)break}return n}(e,t,dk(e,0,e.length,t,0,t.length))}function Ok(e,t,n){return function(e,t,n){for(let r=0,o=0;o<e.length;o++){let s=e[o],i=s.toA-s.fromA,a=s.toB-s.fromB;if(i&&a||i>3||a>3){let l=o==e.length-1?t.length:e[o+1].fromA,c=s.fromA-r,d=l-s.toA,u=_k(t,s.fromA,Math.min(c,5)),h=jk(t,s.toA,Math.min(d,5)),f=s.fromA-u,p=h-s.toA;if(!i||!a){let d,m,g=Math.max(i,a),[y,b,x]=i?[t,s.fromA,s.toA]:[n,s.fromB,s.toB];f&&p?(g>f&&t.slice(u,s.fromA)==y.slice(x-f,x)?(s=e[o]=new ck(u,u+i,s.fromB-f,s.toB-f),u=s.fromA,h=jk(t,s.toA,Math.min(l-s.toA,5))):g>p&&t.slice(s.toA,h)==y.slice(b,b+p)&&(s=e[o]=new ck(h-i,h,s.fromB+p,s.toB+p),h=s.toA,u=_k(t,s.fromA,Math.min(s.fromA-r,5))),f=s.fromA-u,p=h-s.toA):f||p||!(m=s.fromA-(d=Ik(t,s.fromA,c)))||t.slice(d,s.fromA)!=y.slice(x-m,x)||(s=e[o]=new ck(d,d+i,s.fromB-m,s.toB-m))}(f||p)&&(s=e[o]=new ck(s.fromA-f,s.toA+p,s.fromB-f,s.toB+p)),r=s.toA}}return kk(e,3),e}(Dk(e,t,n),e,t)}const Rk=sr.define({combine:e=>e[0]}),Pk=bn.define(),Lk=xn.define({create:e=>null,update(e,t){for(let n of t.effects)n.is(Pk)&&(e=n.value);return e}});class zk{constructor(e,t,n,r,o){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=o}offset(e,t){return e||t?new zk(this.changes,this.fromA+e,this.toA+e,this.fromB+t,this.toB+t):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return Uk(Ok(e.toString(),t.toString(),n),e,t,0,0)}static updateA(e,t,n,r,o){return Wk(Vk(e,r,!0,n.length),e,t,n,o)}static updateB(e,t,n,r,o){return Wk(Vk(e,r,!1,t.length),e,t,n,o)}}function Fk(e,t,n,r){let o=n.lineAt(e),s=r.lineAt(t);return o.to==e&&s.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[o.from,s.from]}function Bk(e,t,n,r){let o=n.lineAt(e),s=r.lineAt(t);return o.from==e&&s.from==t?[e,t]:[o.to+1,s.to+1]}function Uk(e,t,n,r,o){let s=[];for(let i=0;i<e.length;i++){let a=e[i],[l,c]=Fk(a.fromA+r,a.fromB+o,t,n),[d,u]=Bk(a.toA+r,a.toB+o,t,n),h=[a.offset(-l+r,-c+o)];for(;i<e.length-1;){let s=e[i+1],[a,f]=Fk(s.fromA+r,s.fromB+o,t,n);if(a>d+1&&f>u+1)break;h.push(s.offset(-l+r,-c+o)),[d,u]=Bk(s.toA+r,s.toB+o,t,n),i++}s.push(new zk(h,l,Math.max(l,d),c,Math.max(c,u)))}return s}const $k=1e3;function Hk(e,t,n,r){let o=0,s=e.length;for(;;){if(o==s){let r=0,s=0;o&&({toA:r,toB:s}=e[o-1]);let i=t-(n?r:s);return[r+i,s+i]}let i=o+s>>1,a=e[i],[l,c]=n?[a.fromA,a.toA]:[a.fromB,a.toB];if(l>t)s=i;else{if(!(c<=t))return r?[a.fromA,a.fromB]:[a.toA,a.toB];o=i+1}}}function Vk(e,t,n,r){let o=[];return t.iterChangedRanges(((s,i,a,l)=>{let c=0,d=n?t.length:r,u=0,h=n?r:t.length;s>$k&&([c,u]=Hk(e,s-$k,n,!0)),i<t.length-$k&&([d,h]=Hk(e,i+$k,n,!1));let f,p=l-a-(i-s),[m,g]=n?[p,0]:[0,p];o.length&&(f=o[o.length-1]).toA>=c?o[o.length-1]={fromA:f.fromA,fromB:f.fromB,toA:d,toB:h,diffA:f.diffA+m,diffB:f.diffB+g}:o.push({fromA:c,toA:d,fromB:u,toB:h,diffA:m,diffB:g})})),o}function Wk(e,t,n,r,o){if(!e.length)return t;let s=0,i=0,a=0,l=[];for(let c of e){let e=c.fromA+i,d=c.toA+i+c.diffA,u=c.fromB+a,h=c.toB+a+c.diffB;for(;s<t.length;){let n=t[s];if(n.toA+i<=e&&n.toB+a<=u)l.push(n.offset(i,a));else if(n.fromA+i>d)break;s++}for(let t of Uk(Ok(n.sliceString(e,d),r.sliceString(u,h),o),n,r,e,u))l.push(t);for(i+=c.diffA,a+=c.diffB;s<t.length;){let e=t[s];if(e.fromA>d+i&&e.fromB>h+a)break;s++}}for(;s<t.length;)l.push(t[s++].offset(i,a));return l}const Gk=wn.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=eS(e))}update(e){var t,n;(e.docChanged||e.viewportChanged||(t=e.startState,n=e.state,t.field(Lk,!1)!=n.field(Lk,!1))||function(e,t){return e.facet(Rk)!=t.facet(Rk)}(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=eS(e.view))}},{decorations:e=>e.deco}),qk=rr.low(ks({class:"cm-changeGutter",markers:e=>{var t;return(null===(t=e.plugin(Gk))||void 0===t?void 0:t.gutter)||Ss.empty}}));const Yk=vn.line({class:"cm-changedLine"}),Xk=vn.mark({class:"cm-changedText"}),Jk=vn.mark({tagName:"ins",class:"cm-insertedLine"}),Kk=vn.mark({tagName:"del",class:"cm-deletedLine"}),Zk=new class extends Ns{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Qk(e,t,n,r,o,s){let i=n?e.fromA:e.fromB,a=n?e.toA:e.toB,l=0;if(i!=a){o.add(i,i,Yk),o.add(i,a,n?Kk:Jk),s&&s.add(i,i,Zk);for(let c=t.iterRange(i,a-1),d=i;!c.next().done;){if(c.lineBreak){d++,o.add(d,d,Yk),s&&s.add(d,d,Zk);continue}let t=d+c.value.length;if(r)for(;l<e.changes.length;){let r=e.changes[l],s=i+(n?r.fromA:r.fromB),a=i+(n?r.toA:r.toB),c=Math.max(d,s),u=Math.min(t,a);if(c<u&&o.add(c,u,Xk),!(a<t))break;l++}d=t}}}function eS(e){let t=e.state.field(Lk),{side:n,highlightChanges:r,markGutter:o}=e.state.facet(Rk),s="a"==n,i=new kn,a=o?new kn:null,{from:l,to:c}=e.viewport;for(let d of t){if((s?d.fromA:d.fromB)>=c)break;(s?d.toA:d.toB)>l&&Qk(d,e.state.doc,s,r,i,a)}return{deco:i.finish(),gutter:a&&a.finish()}}class tS extends or{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const nS=bn.define({map:(e,t)=>e.map(t)}),rS=xn.define({create:()=>vn.none,update:(e,t)=>{for(let n of t.effects)if(n.is(nS))return n.value;return e.map(t.changes)},provide:e=>yn.decorations.from(e)}),oS=.01;const sS=bn.define({map:(e,t)=>t.mapPos(e)});class iS extends or{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement("div");return t.className="cm-collapsedLines",t.textContent="⦚ "+e.state.phrase("$ unchanged lines",this.lines)+" ⦚",t.addEventListener("click",(t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:sS.of(n)});let{side:r,sibling:o}=e.state.facet(Rk);o&&o().dispatch({effects:sS.of(aS(n,e.state.field(Lk),"a"==r))})})),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}}function aS(e,t,n){let r=0,o=0;for(let s=0;;s++){let i=s<t.length?t[s]:null;if(!i||(n?i.fromA:i.fromB)>=e)return o+(e-r);[r,o]=n?[i.toA,i.toB]:[i.toB,i.toA]}}const lS=xn.define({create:e=>vn.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(sS)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>yn.decorations.from(e)});function cS({margin:e=3,minSize:t=4}){return lS.init((n=>function(e,t,n){let r=new kn,o="a"==e.facet(Rk).side,s=e.field(Lk),i=1;for(let a=0;;a++){let l=a<s.length?s[a]:null,c=a?i+t:1,d=l?e.doc.lineAt(o?l.fromA:l.fromB).number-1-t:e.doc.lines,u=d-c+1;if(u>=n&&r.add(e.doc.line(c).from,e.doc.line(d).to,vn.replace({widget:new iS(u),block:!0})),!l)break;i=e.doc.lineAt(Math.min(e.doc.length,o?l.toA:l.toB)).number}return r.finish()}(n,e,t)))}const dS=yn.styleModule.of(new Cs({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),uS=yn.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb2266, #22bb2266) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff8866, #88ff8866) bottom/100% 2px no-repeat"},".cm-insertedLine, .cm-deletedLine":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer"},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"}}),hS=new Es,fS=new Es;class pS{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig;let t=[rr.low(Gk),uS,dS,rS,yn.updateListener.of((e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some((e=>e.effects.some((e=>e.is(nS)))))&&this.measure()}))],n=[Rk.of({side:"a",sibling:()=>this.b,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&n.push(qk);let r=Yr.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],yn.editorAttributes.of({class:"cm-merge-a"}),fS.of(n),t]}),o=[Rk.of({side:"b",sibling:()=>this.a,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&o.push(qk);let s=Yr.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],yn.editorAttributes.of({class:"cm-merge-b"}),fS.of(o),t]});this.chunks=zk.build(r.doc,s.doc,this.diffConf);let i=[Lk.init((()=>this.chunks)),hS.of(e.collapseUnchanged?cS(e.collapseUnchanged):[])];r=r.update({effects:bn.appendConfig.of(i)}).state,s=s.update({effects:bn.appendConfig.of(i)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let a=e.orientation||"a-b",l=document.createElement("div");l.className="cm-mergeViewEditor";let c=document.createElement("div");c.className="cm-mergeViewEditor",this.editorDOM.appendChild("a-b"==a?l:c),this.editorDOM.appendChild("a-b"==a?c:l),this.a=new yn({state:r,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new yn({state:s,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,"b-to-a"==e.revertControls,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some((e=>e.docChanged))){let n=e[e.length-1],r=e.reduce(((e,t)=>e.compose(t.changes)),cr.empty(e[0].startState.doc.length));this.chunks=t==this.a?zk.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):zk.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:Pk.of(this.chunks)})]);let o=t==this.a?this.b:this.a;o.update([o.state.update({effects:Pk.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let t="b-a"!=e.orientation;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;"revertControls"in e&&(t=!!e.revertControls,n="b-to-a"==e.revertControls),"renderRevertControl"in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t="highlightChanges"in e,n="gutter"in e,r="collapseUnchanged"in e;if(t||n||r){let o=[],s=[];if(t||n){let r=this.a.state.facet(Rk),i=n?!1!==e.gutter:r.markGutter,a=t?!1!==e.highlightChanges:r.highlightChanges;o.push(fS.reconfigure([Rk.of({side:"a",sibling:()=>this.b,highlightChanges:a,markGutter:i}),i?qk:[]])),s.push(fS.reconfigure([Rk.of({side:"b",sibling:()=>this.a,highlightChanges:a,markGutter:i}),i?qk:[]]))}if(r){let t=hS.reconfigure(e.collapseUnchanged?cS(e.collapseUnchanged):[]);o.push(t),s.push(t)}this.a.dispatch({effects:o}),this.b.dispatch({effects:s})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",(e=>this.revertClicked(e))),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame((()=>{this.measuring=-1,this.measure()}))}}measure(){!function(e,t,n){let r=new kn,o=new kn,s=e.state.field(rS).iter(),i=t.state.field(rS).iter(),a=0,l=0,c=0,d=0;for(let p=0;;p++){let u=p<n.length?n[p]:null;if(a<(u?u.fromA:e.state.doc.length)){let n=e.lineBlockAt(a).top+c-(t.lineBlockAt(l).top+d);n<-.01?(c-=n,r.add(a,a,vn.widget({widget:new tS(-n),block:!0,side:-1}))):n>oS&&(d+=n,o.add(l,l,vn.widget({widget:new tS(n),block:!0,side:-1})))}if(!u)break;for(a=u.toA,l=u.toB;s.value&&s.from<a;)c-=s.value.spec.widget.height,s.next();for(;i.value&&i.from<l;)d-=i.value.spec.widget.height,i.next()}for(;s.value;)c-=s.value.spec.widget.height,s.next();for(;i.value;)d-=i.value.spec.widget.height,i.next();let u=e.contentHeight+c-(t.contentHeight+d);u<oS?r.add(e.state.doc.length,e.state.doc.length,vn.widget({widget:new tS(-u),block:!0,side:1})):u>oS&&o.add(t.state.doc.length,t.state.doc.length,vn.widget({widget:new tS(u),block:!0,side:1}));let h=r.finish(),f=o.finish();Ss.eq([h],[e.state.field(rS)])||e.dispatch({effects:nS.of(h)}),Ss.eq([f],[t.state.field(rS)])||t.dispatch({effects:nS.of(f)})}(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let o=0;o<this.chunks.length;o++){let s=this.chunks[o];if(s.fromA>n.to||s.fromB>r.to)break;if(s.fromA<n.from||s.fromB<r.from)continue;let i=this.a.lineBlockAt(s.fromA).top+"px";for(;t&&+t.dataset.chunk<o;)t=mS(t);t&&t.dataset.chunk==String(o)?(t.style.top!=i&&(t.style.top=i),t=t.nextSibling):e.insertBefore(this.renderRevertButton(i,o),t)}for(;t;)t=mS(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement("button");let e=this.a.state.phrase("Revert this chunk");n.setAttribute("aria-label",e),n.setAttribute("title",e),n.textContent=this.revertToLeft?"⇜":"⇝"}return n.style.top=e,n.setAttribute("data-chunk",String(t)),n}revertClicked(e){let t,n=e.target;for(;n&&n.parentNode!=this.revertDOM;)n=n.parentNode;if(n&&(t=this.chunks[n.dataset.chunk])){let[n,r,o,s,i,a]=this.revertToA?[this.b,this.a,t.fromB,t.toB,t.fromA,t.toA]:[this.a,this.b,t.fromA,t.toA,t.fromB,t.toB],l=n.state.sliceDoc(o,Math.max(o,s-1));o!=s&&a<=r.state.doc.length&&(l+=n.state.lineBreak),r.dispatch({changes:{from:i,to:Math.min(r.state.doc.length,a),insert:l},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function mS(e){let t=e.nextSibling;return e.remove(),t}var gS=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl"],yS=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],bS=u.forwardRef(((e,t)=>{var{className:n,children:r,orientation:s,revertControls:i,highlightChanges:a,gutter:l,collapseUnchanged:c,destroyRerender:d=!0,renderRevertControl:u}=e,h=vs(e,gS),f=rk(),{modified:p,modifiedExtension:m,original:g,originalExtension:y,theme:b,dispatch:x}=f,v=vs(f,yS),w=o.useRef(null),k=o.useRef(),S={orientation:s,revertControls:i,highlightChanges:a,gutter:l,collapseUnchanged:c,renderRevertControl:u};o.useImperativeHandle(t,(()=>({container:w.current,view:k.current,modified:p,original:g,config:xs({a:g,b:p,parent:w.current},S)})),[w,k,p,g,S]);var C=yn.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==y?void 0:y.onChange)){var t=e.state.doc.toString();null==y||y.onChange(t,e)}})),E=yn.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==m?void 0:m.onChange)){var t=e.state.doc.toString();null==m||m.onChange(t,e)}}));o.useEffect((()=>{!k.current&&w.current&&y&&m&&(k.current=new pS(xs({a:xs({},g,{extensions:[...(null==y?void 0:y.extension)||[],...ws(xs({},null==y?void 0:y.option,{theme:b})),C]}),b:xs({},p,{extensions:[...(null==m?void 0:m.extension)||[],...ws(xs({},null==m?void 0:m.option,{theme:b})),E]}),parent:w.current},S)),x({view:k.current}))}),[k,w,y,m]),o.useEffect((()=>{if(g&&g.doc&&k.current){var e,t,n=null==(e=k.current)?void 0:e.a.state.doc.toString();if(n!==g.doc)null==(t=k.current)||t.a.dispatch({changes:{from:0,to:n.length,insert:g.doc||""}})}if(p&&p.doc&&k.current){var r,o,s=null==(r=k.current)?void 0:r.b.state.doc.toString();if(s!==p.doc)null==(o=k.current)||o.b.dispatch({changes:{from:0,to:s.length,insert:p.doc||""}})}if(d&&k.current){var i=k.current.a.state.selection.ranges[0].from,a=k.current.b.state.selection.ranges[0].from;k.current.destroy(),k.current=new pS(xs({a:xs({},g,{extensions:[...(null==y?void 0:y.extension)||[],...ws(xs({},null==y?void 0:y.option,{theme:b}))]}),b:xs({},p,{extensions:[...(null==m?void 0:m.extension)||[],...ws(xs({},null==m?void 0:m.option,{theme:b}))]}),parent:w.current},S)),i&&(k.current.a.focus(),k.current.a.dispatch({selection:{anchor:i,head:i}})),a&&(k.current.b.focus(),k.current.b.dispatch({selection:{anchor:a,head:a}}))}}),[k,b,w.current,g,p,y,m,d]),o.useEffect((()=>()=>k.current&&k.current.destroy()),[]),o.useEffect((()=>{if(k.current){var e={};v.orientation!==s&&(e.orientation=s),v.revertControls!==i&&(e.revertControls=i),v.highlightChanges!==a&&(e.highlightChanges=a),v.gutter!==l&&(e.gutter=l),v.collapseUnchanged!==c&&(e.collapseUnchanged=c),v.renderRevertControl!==u&&(e.collapseUnchanged=c),Object.keys(e).length&&x&&k.current&&(k.current.reconfigure(xs({},e)),x(xs({},e)))}}),[x,k,s,i,a,l,c,u]);return I.jsx("div",xs({ref:w,className:"cm-merge-theme"+(n?" "+n:"")},h,{children:r}))}));bS.displayName="CodeMirrorMerge.Internal";var xS=["theme"],vS=u.forwardRef(((e,t)=>{var{theme:n}=e,r=vs(e,xS);return I.jsx(ok,{theme:n,children:I.jsx(bS,xs({},r,{ref:t}))})}));vS.Original=ik,vS.Modified=lk,vS.displayName="CodeMirrorMerge";const wS=vS.Original,kS=vS.Modified,SS=[js(),yn.lineWrapping],CS=e=>{const t=j.c(55),{className:n,onChange:r,initialPrompt:s,currentLanguageAdapter:i,currentCode:a,declineChange:l,acceptChange:c,enabled:d,children:h}=e;let f;t[0]===Symbol.for("react.memo_cache_sentinel")?(f={},t[0]=f):f=t[0];const[p,m]=o.useState(f),[g,y]=ze(uu);let b,x,v,w,k;t[1]===Symbol.for("react.memo_cache_sentinel")?(b=Sr("api/ai/completion").toString(),x=Cr.headers(),t[1]=b,t[2]=x):(b=t[1],x=t[2]),t[3]!==a||t[4]!==g?(v=g?hr(a):"",t[3]=a,t[4]=g,t[5]=v):v=t[5],t[6]!==p||t[7]!==a||t[8]!==i||t[9]!==v?(w={...p,includeOtherCode:v,code:a,language:i},t[6]=p,t[7]=a,t[8]=i,t[9]=v,t[10]=w):w=t[10],t[11]!==s||t[12]!==w?(k={api:b,headers:x,initialInput:s,streamProtocol:"text",experimental_throttle:100,body:w,onError:ES},t[11]=s,t[12]=w,t[13]=k):k=t[13];const{completion:S,input:C,stop:E,isLoading:N,setCompletion:_,setInput:A,handleSubmit:T}=_s(k),M=u.useRef(null);let D,O,R,P;t[14]!==d?(D=()=>{const e=M.current;d&&e&&(requestAnimationFrame((()=>{var t;null==(t=e.view)||t.focus()})),Is(M.current.view))},O=[d],t[14]=d,t[15]=D,t[16]=O):(D=t[15],O=t[16]),o.useEffect(D,O),t[17]!==d||t[18]!==s||t[19]!==A?(P=()=>{d&&A(s||"")},R=[d,s,A],t[17]=d,t[18]=s,t[19]=A,t[20]=R,t[21]=P):(R=t[20],P=t[21]),o.useEffect(P,R);const{theme:L}=Oe();let z;t[22]!==n?(z=In("flex flex-col w-full rounded-[inherit] overflow-hidden",n),t[22]=n,t[23]=z):z=t[23];const F=d&&"max-h-[400px] min-h-11 visible",B=!d&&"max-h-0 min-h-0 invisible";let U,$,H,V;t[24]!==F||t[25]!==B?(U=In("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300 overflow-hidden",F,B),t[24]=F,t[25]=B,t[26]=U):U=t[26],t[27]!==c||t[28]!==S||t[29]!==l||t[30]!==d||t[31]!==T||t[32]!==g||t[33]!==C||t[34]!==N||t[35]!==_||t[36]!==y||t[37]!==A||t[38]!==E||t[39]!==L?($=d&&I.jsxs(I.Fragment,{children:[I.jsx(he,{className:"text-[var(--blue-10)] flex-shrink-0",size:16}),I.jsx(As,{inputRef:M,theme:L,onClose:()=>{l(),_("")},value:C,onChange:e=>{A(e),m(Ts(e))},onSubmit:()=>{N||T()}}),N&&I.jsxs(X,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:E,children:[I.jsx(Ms,{className:"animate-spin mr-1",size:14}),"Stop"]}),!N&&S&&I.jsx(X,{"data-testid":"accept-completion-button",variant:"text",size:"xs",className:"mb-0",disabled:N,onClick:()=>{c(S),_("")},children:I.jsx("span",{className:"text-[var(--grass-11)] opacity-100",children:"Accept"})}),I.jsx("div",{className:"h-full w-px bg-border mx-2"}),I.jsx(it,{content:"Include code from other cells",children:I.jsxs("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[I.jsx(Ds,{"data-testid":"include-other-cells-checkbox",id:"include-other-cells",checked:g,onCheckedChange:e=>y(Boolean(e))}),I.jsx(Me,{htmlFor:"include-other-cells",className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),I.jsx(X,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:N,onClick:()=>{E(),l(),_("")},children:I.jsx(Cn,{className:"text-[var(--red-10)]",size:16})})]}),t[27]=c,t[28]=S,t[29]=l,t[30]=d,t[31]=T,t[32]=g,t[33]=C,t[34]=N,t[35]=_,t[36]=y,t[37]=A,t[38]=E,t[39]=L,t[40]=$):$=t[40],t[41]!==U||t[42]!==$?(H=I.jsx("div",{className:U,children:$}),t[41]=U,t[42]=$,t[43]=H):H=t[43],t[44]!==S||t[45]!==a||t[46]!==d||t[47]!==r||t[48]!==L?(V=S&&d&&I.jsxs(vS,{className:"cm",theme:L,children:[I.jsx(wS,{onChange:r,value:a,extensions:SS}),I.jsx(kS,{value:S,editable:!1,readOnly:!0,extensions:SS})]}),t[44]=S,t[45]=a,t[46]=d,t[47]=r,t[48]=L,t[49]=V):V=t[49];const W=(!S||!d)&&h;let G;return t[50]!==z||t[51]!==H||t[52]!==V||t[53]!==W?(G=I.jsxs("div",{className:z,children:[H,V,W]}),t[50]=z,t[51]=H,t[52]=V,t[53]=W,t[54]=G):G=t[54],G};function ES(e){ee({title:"Completion failed",description:Os(e)})}const NS=()=>new Map,jS=e=>{const t=NS();return e.forEach(((e,n)=>{t.set(n,e)})),t},_S=(e,t,n)=>{let r=e.get(t);return void 0===r&&e.set(t,r=n()),r},IS=()=>new Set,AS=e=>e[e.length-1],TS=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},MS=Array.from,DS=Array.isArray;class OS{constructor(){this._observers=NS()}on(e,t){return _S(this._observers,e,IS).add(t),t}once(e,t){const n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){const n=this._observers.get(e);void 0!==n&&(n.delete(t),0===n.size&&this._observers.delete(e))}emit(e,t){return MS((this._observers.get(e)||NS()).values()).forEach((e=>e(...t)))}destroy(){this._observers=NS()}}class RS{constructor(){this._observers=NS()}on(e,t){_S(this._observers,e,IS).add(t)}once(e,t){const n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){const n=this._observers.get(e);void 0!==n&&(n.delete(t),0===n.size&&this._observers.delete(e))}emit(e,t){return MS((this._observers.get(e)||NS()).values()).forEach((e=>e(...t)))}destroy(){this._observers=NS()}}const PS=Math.floor,LS=Math.abs,zS=(e,t)=>e<t?e:t,FS=(e,t)=>e>t?e:t,BS=Math.pow,US=e=>0!==e?e<0:1/e<0,$S=64,HS=128,VS=127,WS=Number.MAX_SAFE_INTEGER,GS=Number.isInteger||(e=>"number"==typeof e&&isFinite(e)&&PS(e)===e),qS=String.fromCharCode,YS=/^\s*/g,XS=/([A-Z])/g,JS=(e,t)=>(e=>e.replace(YS,""))(e.replace(XS,(e=>`${t}${(e=>e.toLowerCase())(e)}`))),KS="undefined"!=typeof TextEncoder?new TextEncoder:null,ZS=KS?e=>KS.encode(e):e=>{const t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let o=0;o<n;o++)r[o]=t.codePointAt(o);return r};let QS="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});QS&&1===QS.decode(new Uint8Array).length&&(QS=null);class eC{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const tC=()=>new eC,nC=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},rC=e=>{const t=new Uint8Array(nC(e));let n=0;for(let r=0;r<e.bufs.length;r++){const o=e.bufs[r];t.set(o,n),n+=o.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},oC=(e,t)=>{const n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(2*n),e.cpos=0),e.cbuf[e.cpos++]=t},sC=oC,iC=(e,t)=>{for(;t>VS;)oC(e,HS|VS&t),t=PS(t/128);oC(e,VS&t)},aC=(e,t)=>{const n=US(t);for(n&&(t=-t),oC(e,(t>63?HS:0)|(n?$S:0)|63&t),t=PS(t/64);t>0;)oC(e,(t>VS?HS:0)|VS&t),t=PS(t/128)},lC=new Uint8Array(3e4),cC=lC.length/3,dC=KS&&KS.encodeInto?(e,t)=>{if(t.length<cC){const n=KS.encodeInto(t,lC).written||0;iC(e,n);for(let t=0;t<n;t++)oC(e,lC[t])}else hC(e,ZS(t))}:(e,t)=>{const n=unescape(encodeURIComponent(t)),r=n.length;iC(e,r);for(let o=0;o<r;o++)oC(e,n.codePointAt(o))},uC=(e,t)=>{const n=e.cbuf.length,r=e.cpos,o=zS(n-r,t.length),s=t.length-o;e.cbuf.set(t.subarray(0,o),r),e.cpos+=o,s>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(FS(2*n,s)),e.cbuf.set(t.subarray(o)),e.cpos=s)},hC=(e,t)=>{iC(e,t.byteLength),uC(e,t)},fC=(e,t)=>{((e,t)=>{const n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(2*FS(n,t)),e.cpos=0)})(e,t);const n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},pC=new DataView(new ArrayBuffer(4)),mC=(e,t)=>{switch(typeof t){case"string":oC(e,119),dC(e,t);break;case"number":GS(t)&&LS(t)<=2147483647?(oC(e,125),aC(e,t)):(n=t,pC.setFloat32(0,n),pC.getFloat32(0)===n?(oC(e,124),((e,t)=>{fC(e,4).setFloat32(0,t,!1)})(e,t)):(oC(e,123),((e,t)=>{fC(e,8).setFloat64(0,t,!1)})(e,t)));break;case"bigint":oC(e,122),((e,t)=>{fC(e,8).setBigInt64(0,t,!1)})(e,t);break;case"object":if(null===t)oC(e,126);else if(DS(t)){oC(e,117),iC(e,t.length);for(let n=0;n<t.length;n++)mC(e,t[n])}else if(t instanceof Uint8Array)oC(e,116),hC(e,t);else{oC(e,118);const n=Object.keys(t);iC(e,n.length);for(let r=0;r<n.length;r++){const o=n[r];dC(e,o),mC(e,t[o])}}break;case"boolean":oC(e,t?120:121);break;default:oC(e,127)}var n};class gC extends eC{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&iC(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const yC=e=>{e.count>0&&(aC(e.encoder,1===e.count?e.s:-e.s),e.count>1&&iC(e.encoder,e.count-2))};class bC{constructor(){this.encoder=new eC,this.s=0,this.count=0}write(e){this.s===e?this.count++:(yC(this),this.count=1,this.s=e)}toUint8Array(){return yC(this),rC(this.encoder)}}const xC=e=>{if(e.count>0){const t=2*e.diff+(1===e.count?0:1);aC(e.encoder,t),e.count>1&&iC(e.encoder,e.count-2)}};class vC{constructor(){this.encoder=new eC,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(xC(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return xC(this),rC(this.encoder)}}class wC{constructor(){this.sarr=[],this.s="",this.lensE=new bC}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new eC;return this.sarr.push(this.s),this.s="",dC(e,this.sarr.join("")),uC(e,this.lensE.toUint8Array()),rC(e)}}const kC=e=>new Error(e),SC=()=>{throw kC("Method unimplemented")},CC=()=>{throw kC("Unexpected case")},EC=kC("Unexpected end of array"),NC=kC("Integer out of Range");class jC{constructor(e){this.arr=e,this.pos=0}}const _C=e=>new jC(e),IC=e=>((e,t)=>{const n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n})(e,TC(e)),AC=e=>e.arr[e.pos++],TC=e=>{let t=0,n=1;const r=e.arr.length;for(;e.pos<r;){const r=e.arr[e.pos++];if(t+=(r&VS)*n,n*=128,r<HS)return t;if(t>WS)throw NC}throw EC},MC=e=>{let t=e.arr[e.pos++],n=63&t,r=64;const o=(t&$S)>0?-1:1;if(!(t&HS))return o*n;const s=e.arr.length;for(;e.pos<s;){if(t=e.arr[e.pos++],n+=(t&VS)*r,r*=128,t<HS)return o*n;if(n>WS)throw NC}throw EC},DC=QS?e=>QS.decode(IC(e)):e=>{let t=TC(e);if(0===t)return"";{let n=String.fromCodePoint(AC(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(AC(e));else for(;t>0;){const r=t<1e4?t:1e4,o=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,o),t-=r}return decodeURIComponent(escape(n))}},OC=(e,t)=>{const n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},RC=[e=>{},e=>null,MC,e=>OC(e,4).getFloat32(0,!1),e=>OC(e,8).getFloat64(0,!1),e=>OC(e,8).getBigInt64(0,!1),e=>!1,e=>!0,DC,e=>{const t=TC(e),n={};for(let r=0;r<t;r++){n[DC(e)]=PC(e)}return n},e=>{const t=TC(e),n=[];for(let r=0;r<t;r++)n.push(PC(e));return n},IC],PC=e=>RC[127-AC(e)](e);class LC extends jC{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){var e;return 0===this.count&&(this.s=this.reader(this),(e=this).pos!==e.arr.length?this.count=TC(this)+1:this.count=-1),this.count--,this.s}}class zC extends jC{constructor(e){super(e),this.s=0,this.count=0}read(){if(0===this.count){this.s=MC(this);const e=US(this.s);this.count=1,e&&(this.s=-this.s,this.count=TC(this)+2)}return this.count--,this.s}}class FC extends jC{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(0===this.count){const e=MC(this),t=1&e;this.diff=PS(e/2),this.count=1,t&&(this.count=TC(this)+2)}return this.s+=this.diff,this.count--,this.s}}class BC{constructor(e){this.decoder=new zC(e),this.str=DC(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const UC=crypto.getRandomValues.bind(crypto),$C=()=>UC(new Uint32Array(1))[0],HC="10000000-1000-4000-8000-100000000000",VC=()=>HC.replace(/[018]/g,(e=>(e^$C()&15>>e/4).toString(16))),WC=Date.now,GC=e=>new Promise(e);Promise.all.bind(Promise);const qC=e=>void 0===e?null:e;let YC=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},XC=!0;try{"undefined"!=typeof localStorage&&localStorage&&(YC=localStorage,XC=!1)}catch(iX){}const JC=YC,KC=Object.assign,ZC=Object.keys,QC=e=>ZC(e).length,eE=e=>ZC(e).length,tE=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),nE=Object.freeze,rE=e=>{for(const t in e){const n=e[t];"object"!=typeof n&&"function"!=typeof n||rE(e[t])}return nE(e)},oE=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&oE(e,t,n+1)}},sE=e=>e,iE=(e,t)=>{if(null==e||null==t)return((e,t)=>e===t)(e,t);if(e.constructor!==t.constructor)return!1;if(e===t)return!0;switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(const n of e.keys())if(!t.has(n)||!iE(e.get(n),t.get(n)))return!1;break;case Object:if(QC(e)!==QC(t))return!1;for(const n in e)if(!tE(e,n)||!iE(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!iE(e[n],t[n]))return!1;break;default:return!1}return!0};var aE={};const lE="undefined"!=typeof process&&process.release&&/node|io\.js/.test(process.release.name)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),cE="undefined"!=typeof window&&"undefined"!=typeof document&&!lE;let dE;const uE=e=>(()=>{if(void 0===dE)if(lE){dE=NS();const e=process.argv;let t=null;for(let n=0;n<e.length;n++){const r=e[n];"-"===r[0]?(null!==t&&dE.set(t,""),t=r):null!==t&&(dE.set(t,r),t=null)}null!==t&&dE.set(t,"")}else"object"==typeof location?(dE=NS(),(location.search||"?").slice(1).split("&").forEach((e=>{if(0!==e.length){const[t,n]=e.split("=");dE.set(`--${JS(t,"-")}`,n),dE.set(`-${JS(t,"-")}`,n)}}))):dE=NS();return dE})().has(e),hE=e=>qC(lE?aE[e.toUpperCase().replaceAll("-","_")]:JC.getItem(e)),fE=e=>uE("--"+e)||null!==hE(e);fE("production");const pE=lE&&["true","1","2"].includes(aE.FORCE_COLOR)||!uE("--no-colors")&&!fE("no-color")&&(!lE||process.stdout.isTTY)&&(!lE||uE("--color")||null!==hE("COLORTERM")||(hE("TERM")||"").includes("color")),mE=e=>new Uint8Array(e),gE=cE?e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=qS(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"),yE=cE?e=>{const t=atob(e),n=mE(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}:e=>{const t=Buffer.from(e,"base64");return n=t.buffer,r=t.byteOffset,o=t.byteLength,new Uint8Array(n,r,o);var n,r,o};class bE{constructor(e,t){this.left=e,this.right=t}}const xE=(e,t)=>new bE(e,t);"undefined"!=typeof DOMParser&&new DOMParser;const vE=Symbol,wE=vE(),kE=vE(),SE=vE(),CE=vE(),EE=vE(),NE=vE(),jE=vE(),_E=vE(),IE=vE(),AE={[wE]:xE("font-weight","bold"),[kE]:xE("font-weight","normal"),[SE]:xE("color","blue"),[EE]:xE("color","green"),[CE]:xE("color","grey"),[NE]:xE("color","red"),[jE]:xE("color","purple"),[_E]:xE("color","orange"),[IE]:xE("color","black")},TE=pE?e=>{var t;1===e.length&&(null==(t=e[0])?void 0:t.constructor)===Function&&(e=e[0]());const n=[],r=[],o=NS();let s=[],i=0;for(;i<e.length;i++){const t=e[i],s=AE[t];if(void 0!==s)o.set(s.left,s.right);else{if(void 0===t)break;if(t.constructor!==String&&t.constructor!==Number)break;{const e=((e,t)=>{const n=[];for(const[r,o]of e)n.push(t(o,r));return n})(o,((e,t)=>`${t}:${e};`)).join("");i>0||e.length>0?(n.push("%c"+t),r.push(e)):n.push(t)}}}for(i>0&&(s=r,s.unshift(n.join("")));i<e.length;i++){const t=e[i];t instanceof Symbol||s.push(t)}return s}:e=>{var t;1===e.length&&(null==(t=e[0])?void 0:t.constructor)===Function&&(e=e[0]());const n=[],r=[];let o=0;for(;o<e.length;o++){const t=e[o];if(void 0===t)break;if(t.constructor===String||t.constructor===Number)n.push(t);else if(t.constructor===Object)break}for(o>0&&r.push(n.join(""));o<e.length;o++){const t=e[o];t instanceof Symbol||r.push(t)}return r},ME=(...e)=>{console.warn(...TE(e)),e.unshift(_E),DE.forEach((t=>t.print(e)))},DE=IS(),OE=e=>({[Symbol.iterator](){return this},next:e}),RE=(e,t)=>OE((()=>{const{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}));class PE{constructor(e,t){this.clock=e,this.len=t}}class LE{constructor(){this.clients=new Map}}const zE=(e,t,n)=>t.clients.forEach(((t,r)=>{const o=e.doc.store.clients.get(r);for(let s=0;s<t.length;s++){const r=t[s];LN(e,o,r.clock,r.len,n)}})),FE=(e,t)=>{const n=e.clients.get(t.client);return void 0!==n&&null!==((e,t)=>{let n=0,r=e.length-1;for(;n<=r;){const o=PS((n+r)/2),s=e[o],i=s.clock;if(i<=t){if(t<i+s.len)return o;n=o+1}else r=o-1}return null})(n,t.clock)},BE=e=>{e.clients.forEach((e=>{let t,n;for(e.sort(((e,t)=>e.clock-t.clock)),t=1,n=1;t<e.length;t++){const r=e[n-1],o=e[t];r.clock+r.len>=o.clock?r.len=FS(r.len,o.clock+o.len-r.clock):(n<t&&(e[n]=o),n++)}e.length=n}))},UE=e=>{const t=new LE;for(let n=0;n<e.length;n++)e[n].clients.forEach(((r,o)=>{if(!t.clients.has(o)){const s=r.slice();for(let t=n+1;t<e.length;t++)TS(s,e[t].clients.get(o)||[]);t.clients.set(o,s)}}));return BE(t),t},$E=(e,t,n,r)=>{_S(e.clients,t,(()=>[])).push(new PE(n,r))},HE=e=>{const t=new LE;return e.clients.forEach(((e,n)=>{const r=[];for(let t=0;t<e.length;t++){const n=e[t];if(n.deleted){const o=n.id.clock;let s=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[1+ ++t])s+=n.length;r.push(new PE(o,s))}}r.length>0&&t.clients.set(n,r)})),t},VE=(e,t)=>{iC(e.restEncoder,t.clients.size),MS(t.clients.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([t,n])=>{e.resetDsCurVal(),iC(e.restEncoder,t);const r=n.length;iC(e.restEncoder,r);for(let o=0;o<r;o++){const t=n[o];e.writeDsClock(t.clock),e.writeDsLen(t.len)}}))},WE=e=>{const t=new LE,n=TC(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();const n=TC(e.restDecoder),r=TC(e.restDecoder);if(r>0){const o=_S(t.clients,n,(()=>[]));for(let t=0;t<r;t++)o.push(new PE(e.readDsClock(),e.readDsLen()))}}return t},GE=(e,t,n)=>{const r=new LE,o=TC(e.restDecoder);for(let s=0;s<o;s++){e.resetDsCurVal();const o=TC(e.restDecoder),s=TC(e.restDecoder),i=n.clients.get(o)||[],a=AN(n,o);for(let n=0;n<s;n++){const n=e.readDsClock(),s=n+e.readDsLen();if(n<a){a<s&&$E(r,o,a,s-a);let e=MN(i,n),l=i[e];for(!l.deleted&&l.id.clock<n&&(i.splice(e+1,0,N_(t,l,n-l.id.clock)),e++);e<i.length&&(l=i[e++],l.id.clock<s);)l.deleted||(s<l.id.clock+l.length&&i.splice(e,0,N_(t,l,s-l.id.clock)),l.delete(t))}else $E(r,o,n,s-n)}}if(r.clients.size>0){const e=new nN;return iC(e.restEncoder,0),VE(e,r),e.toUint8Array()}return null},qE=$C;class YE extends OS{constructor({guid:e=VC(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:i=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=qE(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new _N,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=s,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=GC((e=>{this.on("load",(()=>{this.isLoaded=!0,e(this)}))}));const a=()=>GC((e=>{const t=n=>{void 0!==n&&!0!==n||(this.off("sync",t),e())};this.on("sync",t)}));this.on("sync",(e=>{!1===e&&this.isSynced&&(this.whenSynced=a()),this.isSynced=void 0===e||!0===e,this.isSynced&&!this.isLoaded&&this.emit("load",[this])})),this.whenSynced=a()}load(){const e=this._item;null===e||this.shouldLoad||HN(e.parent.doc,(e=>{e.subdocsLoaded.add(this)}),null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(MS(this.subdocs).map((e=>e.guid)))}transact(e,t=null){return HN(this,e,t)}get(e,t=pj){const n=_S(this.share,e,(()=>{const e=new t;return e._integrate(this,null),e})),r=n.constructor;if(t!==pj&&r!==t){if(r===pj){const r=new t;r._map=n._map,n._map.forEach((e=>{for(;null!==e;e=e.left)e.parent=r})),r._start=n._start;for(let e=r._start;null!==e;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}throw new Error(`Type with the name ${e} has already been defined with a different constructor`)}return n}getArray(e=""){return this.get(e,Mj)}getText(e=""){return this.get(e,Jj)}getMap(e=""){return this.get(e,Oj)}getXmlElement(e=""){return this.get(e,Qj)}getXmlFragment(e=""){return this.get(e,Zj)}toJSON(){const e={};return this.share.forEach(((t,n)=>{e[n]=t.toJSON()})),e}destroy(){this.isDestroyed=!0,MS(this.subdocs).forEach((e=>e.destroy()));const e=this._item;if(null!==e){this._item=null;const t=e.content;t.doc=new YE({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,HN(e.parent.doc,(n=>{const r=t.doc;e.deleted||n.subdocsAdded.add(r),n.subdocsRemoved.add(this)}),null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class XE{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return TC(this.restDecoder)}readDsLen(){return TC(this.restDecoder)}}class JE extends XE{readLeftID(){return yN(TC(this.restDecoder),TC(this.restDecoder))}readRightID(){return yN(TC(this.restDecoder),TC(this.restDecoder))}readClient(){return TC(this.restDecoder)}readInfo(){return AC(this.restDecoder)}readString(){return DC(this.restDecoder)}readParentInfo(){return 1===TC(this.restDecoder)}readTypeRef(){return TC(this.restDecoder)}readLen(){return TC(this.restDecoder)}readAny(){return PC(this.restDecoder)}readBuf(){return(e=>{const t=mE(e.byteLength);return t.set(e),t})(IC(this.restDecoder))}readJSON(){return JSON.parse(DC(this.restDecoder))}readKey(){return DC(this.restDecoder)}}class KE{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=TC(this.restDecoder),this.dsCurrVal}readDsLen(){const e=TC(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class ZE extends KE{constructor(e){super(e),this.keys=[],TC(e),this.keyClockDecoder=new FC(IC(e)),this.clientDecoder=new zC(IC(e)),this.leftClockDecoder=new FC(IC(e)),this.rightClockDecoder=new FC(IC(e)),this.infoDecoder=new LC(IC(e),AC),this.stringDecoder=new BC(IC(e)),this.parentInfoDecoder=new LC(IC(e),AC),this.typeRefDecoder=new zC(IC(e)),this.lenDecoder=new zC(IC(e))}readLeftID(){return new mN(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new mN(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return PC(this.restDecoder)}readBuf(){return IC(this.restDecoder)}readJSON(){return PC(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const e=this.stringDecoder.read();return this.keys.push(e),e}}}class QE{constructor(){this.restEncoder=tC()}toUint8Array(){return rC(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){iC(this.restEncoder,e)}writeDsLen(e){iC(this.restEncoder,e)}}class eN extends QE{writeLeftID(e){iC(this.restEncoder,e.client),iC(this.restEncoder,e.clock)}writeRightID(e){iC(this.restEncoder,e.client),iC(this.restEncoder,e.clock)}writeClient(e){iC(this.restEncoder,e)}writeInfo(e){sC(this.restEncoder,e)}writeString(e){dC(this.restEncoder,e)}writeParentInfo(e){iC(this.restEncoder,e?1:0)}writeTypeRef(e){iC(this.restEncoder,e)}writeLen(e){iC(this.restEncoder,e)}writeAny(e){mC(this.restEncoder,e)}writeBuf(e){hC(this.restEncoder,e)}writeJSON(e){dC(this.restEncoder,JSON.stringify(e))}writeKey(e){dC(this.restEncoder,e)}}class tN{constructor(){this.restEncoder=tC(),this.dsCurrVal=0}toUint8Array(){return rC(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,iC(this.restEncoder,t)}writeDsLen(e){0===e&&CC(),iC(this.restEncoder,e-1),this.dsCurrVal+=e}}class nN extends tN{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new vC,this.clientEncoder=new bC,this.leftClockEncoder=new vC,this.rightClockEncoder=new vC,this.infoEncoder=new gC(sC),this.stringEncoder=new wC,this.parentInfoEncoder=new gC(sC),this.typeRefEncoder=new bC,this.lenEncoder=new bC}toUint8Array(){const e=tC();return iC(e,0),hC(e,this.keyClockEncoder.toUint8Array()),hC(e,this.clientEncoder.toUint8Array()),hC(e,this.leftClockEncoder.toUint8Array()),hC(e,this.rightClockEncoder.toUint8Array()),hC(e,rC(this.infoEncoder)),hC(e,this.stringEncoder.toUint8Array()),hC(e,rC(this.parentInfoEncoder)),hC(e,this.typeRefEncoder.toUint8Array()),hC(e,this.lenEncoder.toUint8Array()),uC(e,rC(this.restEncoder)),rC(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){mC(this.restEncoder,e)}writeBuf(e){hC(this.restEncoder,e)}writeJSON(e){mC(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);void 0===t?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const rN=(e,t,n)=>{const r=new Map;n.forEach(((e,n)=>{AN(t,n)>e&&r.set(n,e)})),IN(t).forEach(((e,t)=>{n.has(t)||r.set(t,0)})),iC(e.restEncoder,r.size),MS(r.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([n,r])=>{((e,t,n,r)=>{r=FS(r,t[0].id.clock);const o=MN(t,r);iC(e.restEncoder,t.length-o),e.writeClient(n),iC(e.restEncoder,r);const s=t[o];s.write(e,r-s.id.clock);for(let i=o+1;i<t.length;i++)t[i].write(e,0)})(e,t.clients.get(n),n,r)}))},oN=(e,t,n,r=new ZE(e))=>HN(t,(e=>{e.local=!1;let t=!1;const n=e.doc,o=n.store,s=((e,t)=>{const n=NS(),r=TC(e.restDecoder);for(let o=0;o<r;o++){const r=TC(e.restDecoder),o=new Array(r),s=e.readClient();let i=TC(e.restDecoder);n.set(s,{i:0,refs:o});for(let n=0;n<r;n++){const r=e.readInfo();switch(31&r){case 0:{const t=e.readLen();o[n]=new o_(yN(s,i),t),i+=t;break}case 10:{const t=TC(e.restDecoder);o[n]=new M_(yN(s,i),t),i+=t;break}default:{const a=!(192&r),l=new I_(yN(s,i),null,(r&HS)===HS?e.readLeftID():null,null,(r&$S)===$S?e.readRightID():null,a?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,!a||32&~r?null:e.readString(),A_(e,r));o[n]=l,i+=l.length}}}}return n})(r,n),i=((e,t,n)=>{const r=[];let o=MS(n.keys()).sort(((e,t)=>e-t));if(0===o.length)return null;const s=()=>{if(0===o.length)return null;let e=n.get(o[o.length-1]);for(;e.refs.length===e.i;){if(o.pop(),!(o.length>0))return null;e=n.get(o[o.length-1])}return e};let i=s();if(null===i)return null;const a=new _N,l=new Map,c=(e,t)=>{const n=l.get(e);(null==n||n>t)&&l.set(e,t)};let d=i.refs[i.i++];const u=new Map,h=()=>{for(const e of r){const t=e.id.client,r=n.get(t);r?(r.i--,a.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):a.clients.set(t,[e]),o=o.filter((e=>e!==t))}r.length=0};for(;;){if(d.constructor!==M_){const o=_S(u,d.id.client,(()=>AN(t,d.id.client)))-d.id.clock;if(o<0)r.push(d),c(d.id.client,d.id.clock-1),h();else{const s=d.getMissing(e,t);if(null!==s){r.push(d);const e=n.get(s)||{refs:[],i:0};if(e.refs.length!==e.i){d=e.refs[e.i++];continue}c(s,AN(t,s)),h()}else(0===o||o<d.length)&&(d.integrate(e,o),u.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(null!==i&&i.i<i.refs.length)d=i.refs[i.i++];else{if(i=s(),null===i)break;d=i.refs[i.i++]}}if(a.clients.size>0){const e=new nN;return rN(e,a,new Map),iC(e.restEncoder,0),{missing:l,update:e.toUint8Array()}}return null})(e,o,s),a=o.pendingStructs;if(a){for(const[e,n]of a.missing)if(n<AN(o,e)){t=!0;break}if(i){for(const[e,t]of i.missing){const n=a.missing.get(e);(null==n||n>t)&&a.missing.set(e,t)}a.update=ZN([a.update,i.update])}}else o.pendingStructs=i;const l=GE(r,e,o);if(o.pendingDs){const t=new ZE(_C(o.pendingDs));TC(t.restDecoder);const n=GE(t,e,o);o.pendingDs=l&&n?ZN([l,n]):l||n}else o.pendingDs=l;if(t){const t=o.pendingStructs.update;o.pendingStructs=null,sN(e.doc,t)}}),n,!1),sN=(e,t,n,r=ZE)=>{const o=_C(t);oN(o,e,n,new r(o))},iN=(e,t=new Uint8Array([0]),n=new nN)=>{((e,t,n=new Map)=>{rN(e,t.store,n),VE(e,HE(t.store))})(n,e,aN(t));const r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(QN(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===eN)return JN(r.map(((e,t)=>0===t?e:rj(e))));if(n.constructor===nN)return ZN(r)}return r[0]},aN=e=>(e=>{const t=new Map,n=TC(e.restDecoder);for(let r=0;r<n;r++){const n=TC(e.restDecoder),r=TC(e.restDecoder);t.set(n,r)}return t})(new XE(_C(e))),lN=(e,t)=>(iC(e.restEncoder,t.size),MS(t.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([t,n])=>{iC(e.restEncoder,t),iC(e.restEncoder,n)})),e),cN=(e,t=new tN)=>(e instanceof Map?lN(t,e):((e,t)=>{lN(e,IN(t.store))})(t,e),t.toUint8Array());class dN{constructor(){this.l=[]}}const uN=()=>new dN,hN=(e,t)=>e.l.push(t),fN=(e,t)=>{const n=e.l,r=n.length;e.l=n.filter((e=>t!==e)),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},pN=(e,t,n)=>oE(e.l,[t,n]);class mN{constructor(e,t){this.client=e,this.clock=t}}const gN=(e,t)=>e===t||null!==e&&null!==t&&e.client===t.client&&e.clock===t.clock,yN=(e,t)=>new mN(e,t),bN=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw CC()},xN=(e,t)=>{for(;null!==t;){if(t.parent===e)return!0;t=t.parent._item}return!1};class vN{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}}const wN=e=>{const t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),null!=e.assoc&&(t.assoc=e.assoc),t},kN=e=>new vN(null==e.type?null:yN(e.type.client,e.type.clock),e.tname??null,null==e.item?null:yN(e.item.client,e.item.clock),null==e.assoc?0:e.assoc);class SN{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}}const CN=(e,t,n)=>{let r=null,o=null;return null===e._item?o=bN(e):r=yN(e._item.id.client,e._item.id.clock),new vN(r,o,t,n)},EN=(e,t,n=!0)=>{const r=t.store,o=e.item,s=e.type,i=e.tname,a=e.assoc;let l=null,c=0;if(null!==o){if(AN(r,o.client)<=o.clock)return null;const e=n?C_(r,o):((e,t)=>{const n=DN(e,t);return{item:n,diff:t.clock-n.id.clock}})(r,o),t=e.item;if(!(t instanceof I_))return null;if(l=t.parent,null===l._item||!l._item.deleted){c=t.deleted||!t.countable?0:e.diff+(a>=0?0:1);let n=t.left;for(;null!==n;)!n.deleted&&n.countable&&(c+=n.length),n=n.left}}else{if(null!==i)l=t.get(i);else{if(null===s)throw CC();{if(AN(r,s.client)<=s.clock)return null;const{item:e}=n?C_(r,s):{item:DN(r,s)};if(!(e instanceof I_&&e.content instanceof S_))return null;l=e.content.type}}c=a>=0?l._length:0}return((e,t,n=0)=>new SN(e,t,n))(l,c,e.assoc)},NN=(e,t)=>void 0===t?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!FE(t.ds,e.id),jN=(e,t)=>{const n=_S(e.meta,jN,IS),r=e.doc.store;n.has(t)||(t.sv.forEach(((t,n)=>{t<AN(r,n)&&RN(e,yN(n,t))})),zE(e,t.ds,(e=>{})),n.add(t))};class _N{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const IN=e=>{const t=new Map;return e.clients.forEach(((e,n)=>{const r=e[e.length-1];t.set(n,r.id.clock+r.length)})),t},AN=(e,t)=>{const n=e.clients.get(t);if(void 0===n)return 0;const r=n[n.length-1];return r.id.clock+r.length},TN=(e,t)=>{let n=e.clients.get(t.id.client);if(void 0===n)n=[],e.clients.set(t.id.client,n);else{const e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw CC()}n.push(t)},MN=(e,t)=>{let n=0,r=e.length-1,o=e[r],s=o.id.clock;if(s===t)return r;let i=PS(t/(s+o.length-1)*r);for(;n<=r;){if(o=e[i],s=o.id.clock,s<=t){if(t<s+o.length)return i;n=i+1}else r=i-1;i=PS((n+r)/2)}throw CC()},DN=(e,t)=>{const n=e.clients.get(t.client);return n[MN(n,t.clock)]},ON=(e,t,n)=>{const r=MN(t,n),o=t[r];return o.id.clock<n&&o instanceof I_?(t.splice(r+1,0,N_(e,o,n-o.id.clock)),r+1):r},RN=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[ON(e,n,t.clock)]},PN=(e,t,n)=>{const r=t.clients.get(n.client),o=MN(r,n.clock),s=r[o];return n.clock!==s.id.clock+s.length-1&&s.constructor!==o_&&r.splice(o+1,0,N_(e,s,n.clock-s.id.clock+1)),s},LN=(e,t,n,r,o)=>{if(0===r)return;const s=n+r;let i,a=ON(e,t,n);do{i=t[a++],s<i.id.clock+i.length&&ON(e,t,s),o(i)}while(a<t.length&&t[a].id.clock<s)};class zN{constructor(e,t,n){this.doc=e,this.deleteSet=new LE,this.beforeState=IN(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const FN=(e,t)=>!(0===t.deleteSet.clients.size&&!((e,t)=>{for(const[n,r]of e)if(t(r,n))return!0;return!1})(t.afterState,((e,n)=>t.beforeState.get(n)!==e)))&&(BE(t.deleteSet),((e,t)=>{rN(e,t.doc.store,t.beforeState)})(e,t),VE(e,t.deleteSet),!0),BN=(e,t,n)=>{const r=t._item;(null===r||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&_S(e.changed,t,IS).add(n)},UN=(e,t)=>{let n=e[t],r=e[t-1],o=t;for(;o>0&&(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n));n=r,r=e[--o-1])n instanceof I_&&null!==n.parentSub&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);const s=t-o;return s&&e.splice(t+1-s,s),s},$N=(e,t)=>{if(t<e.length){const n=e[t],r=n.doc,o=r.store,s=n.deleteSet,i=n._mergeStructs;try{BE(s),n.afterState=IN(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const e=[];n.changed.forEach(((t,r)=>e.push((()=>{null!==r._item&&r._item.deleted||r._callObserver(n,t)})))),e.push((()=>{n.changedParentTypes.forEach(((e,t)=>{t._dEH.l.length>0&&(null===t._item||!t._item.deleted)&&((e=e.filter((e=>null===e.target._item||!e.target._item.deleted))).forEach((e=>{e.currentTarget=t,e._path=null})),e.sort(((e,t)=>e.path.length-t.path.length)),pN(t._dEH,e,n))}))})),e.push((()=>r.emit("afterTransaction",[n,r]))),oE(e,[]),n._needFormattingCleanup&&qj(n)}finally{r.gc&&((e,t,n)=>{for(const[r,o]of e.clients.entries()){const e=t.clients.get(r);for(let r=o.length-1;r>=0;r--){const s=o[r],i=s.clock+s.len;for(let r=MN(e,s.clock),o=e[r];r<e.length&&o.id.clock<i;o=e[++r]){const o=e[r];if(s.clock+s.len<=o.id.clock)break;o instanceof I_&&o.deleted&&!o.keep&&n(o)&&o.gc(t,!1)}}}})(s,o,r.gcFilter),((e,t)=>{e.clients.forEach(((e,n)=>{const r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){const n=e[t];for(let e=zS(r.length-1,1+MN(r,n.clock+n.len-1)),t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+UN(r,e)}}))})(s,o),n.afterState.forEach(((e,t)=>{const r=n.beforeState.get(t)||0;if(r!==e){const e=o.clients.get(t),n=FS(MN(e,r),1);for(let t=e.length-1;t>=n;)t-=1+UN(e,t)}}));for(let e=i.length-1;e>=0;e--){const{client:t,clock:n}=i[e].id,r=o.clients.get(t),s=MN(r,n);s+1<r.length&&UN(r,s+1)>1||s>0&&UN(r,s)}if(n.local||n.afterState.get(r.clientID)===n.beforeState.get(r.clientID)||(((...e)=>{console.log(...TE(e)),DE.forEach((t=>t.print(e)))})(_E,wE,"[yjs] ",kE,NE,"Changed the client-id because another client seems to be using it."),r.clientID=qE()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const e=new eN;FN(e,n)&&r.emit("update",[e.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const e=new nN;FN(e,n)&&r.emit("updateV2",[e.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=n;(a.size>0||c.size>0||l.size>0)&&(a.forEach((e=>{e.clientID=r.clientID,null==e.collectionid&&(e.collectionid=r.collectionid),r.subdocs.add(e)})),c.forEach((e=>r.subdocs.delete(e))),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,n]),c.forEach((e=>e.destroy()))),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):$N(e,t+1)}}},HN=(e,t,n=null,r=!0)=>{const o=e._transactionCleanups;let s=!1,i=null;null===e._transaction&&(s=!0,e._transaction=new zN(e,n,r),o.push(e._transaction),1===o.length&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{i=t(e._transaction)}finally{if(s){const t=e._transaction===o[0];e._transaction=null,t&&$N(o,0)}}return i};class VN{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const WN=(e,t,n)=>{zE(e,n.deletions,(e=>{e instanceof I_&&t.scope.some((t=>xN(t,e)))&&E_(e,!1)}))},GN=(e,t,n)=>{let r=null;const o=e.doc,s=e.scope;HN(o,(n=>{for(;t.length>0&&null===e.currStackItem;){const r=o.store,i=t.pop(),a=new Set,l=[];let c=!1;zE(n,i.insertions,(e=>{if(e instanceof I_){if(null!==e.redone){let{item:t,diff:o}=C_(r,e.id);o>0&&(t=RN(n,yN(t.id.client,t.id.clock+o))),e=t}!e.deleted&&s.some((t=>xN(t,e)))&&l.push(e)}})),zE(n,i.deletions,(e=>{e instanceof I_&&s.some((t=>xN(t,e)))&&!FE(i.insertions,e.id)&&a.add(e)})),a.forEach((t=>{c=null!==__(n,t,a,i.insertions,e.ignoreRemoteMapChanges,e)||c}));for(let t=l.length-1;t>=0;t--){const r=l[t];e.deleteFilter(r)&&(r.delete(n),c=!0)}e.currStackItem=c?i:null}n.changed.forEach(((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)})),r=n}),e);const i=e.currStackItem;if(null!=i){const t=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return i};class qN extends OS{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:i=(DS(e)?e[0].doc:e.doc)}={}){super(),this.scope=[],this.doc=i,this.addToScope(e),this.deleteFilter=r,o.add(this),this.trackedOrigins=o,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=s,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!(this.captureTransaction(e)&&this.scope.some((t=>e.changedParentTypes.has(t)))&&(this.trackedOrigins.has(e.origin)||e.origin&&this.trackedOrigins.has(e.origin.constructor))))return;const t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);const o=new LE;e.afterState.forEach(((t,n)=>{const r=e.beforeState.get(n)||0,s=t-r;s>0&&$E(o,n,r,s)}));const s=WC();let i=!1;if(this.lastChange>0&&s-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){const t=r[r.length-1];t.deletions=UE([t.deletions,e.deleteSet]),t.insertions=UE([t.insertions,o])}else r.push(new VN(e.deleteSet,o)),i=!0;t||n||(this.lastChange=s),zE(e,e.deleteSet,(e=>{e instanceof I_&&this.scope.some((t=>xN(t,e)))&&E_(e,!0)}));const a=[{stackItem:r[r.length-1],origin:e.origin,type:t?"redo":"undo",changedParentTypes:e.changedParentTypes},this];i?this.emit("stack-item-added",a):this.emit("stack-item-updated",a)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",(()=>{this.destroy()}))}addToScope(e){(e=DS(e)?e:[e]).forEach((e=>{this.scope.every((t=>t!==e))&&(e.doc!==this.doc&&ME("[yjs#509] Not same Y.Doc"),this.scope.push(e))}))}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact((n=>{e&&(this.undoStack.forEach((e=>WN(n,this,e))),this.undoStack=[]),t&&(this.redoStack.forEach((e=>WN(n,this,e))),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])}))}stopCapturing(){this.lastChange=0}undo(){let e;this.undoing=!0;try{e=GN(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){let e;this.redoing=!0;try{e=GN(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}class YN{constructor(e,t){this.gen=function*(e){const t=TC(e.restDecoder);for(let n=0;n<t;n++){const t=TC(e.restDecoder),n=e.readClient();let r=TC(e.restDecoder);for(let o=0;o<t;o++){const t=e.readInfo();if(10===t){const t=TC(e.restDecoder);yield new M_(yN(n,r),t),r+=t}else if(31&t){const o=!(192&t),s=new I_(yN(n,r),null,(t&HS)===HS?e.readLeftID():null,null,(t&$S)===$S?e.readRightID():null,o?e.readParentInfo()?e.readString():e.readLeftID():null,!o||32&~t?null:e.readString(),A_(e,t));yield s,r+=s.length}else{const t=e.readLen();yield new o_(yN(n,r),t),r+=t}}}}(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do{this.curr=this.gen.next().value||null}while(this.filterSkips&&null!==this.curr&&this.curr.constructor===M_);return this.curr}}class XN{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const JN=e=>ZN(e,JE,eN),KN=(e,t)=>{if(e.constructor===o_){const{client:n,clock:r}=e.id;return new o_(yN(n,r+t),e.length-t)}if(e.constructor===M_){const{client:n,clock:r}=e.id;return new M_(yN(n,r+t),e.length-t)}{const n=e,{client:r,clock:o}=n.id;return new I_(yN(r,o+t),null,yN(r,o+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},ZN=(e,t=ZE,n=nN)=>{if(1===e.length)return e[0];const r=e.map((e=>new t(_C(e))));let o=r.map((e=>new YN(e,!0))),s=null;const i=new n,a=new XN(i);for(;o=o.filter((e=>null!==e.curr)),o.sort(((e,t)=>{if(e.curr.id.client===t.curr.id.client){const n=e.curr.id.clock-t.curr.id.clock;return 0===n?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===M_?1:-1:n}return t.curr.id.client-e.curr.id.client})),0!==o.length;){const e=o[0],t=e.curr.id.client;if(null!==s){let n=e.curr,r=!1;for(;null!==n&&n.id.clock+n.length<=s.struct.id.clock+s.struct.length&&n.id.client>=s.struct.id.client;)n=e.next(),r=!0;if(null===n||n.id.client!==t||r&&n.id.clock>s.struct.id.clock+s.struct.length)continue;if(t!==s.struct.id.client)tj(a,s.struct,s.offset),s={struct:n,offset:0},e.next();else if(s.struct.id.clock+s.struct.length<n.id.clock)if(s.struct.constructor===M_)s.struct.length=n.id.clock+n.length-s.struct.id.clock;else{tj(a,s.struct,s.offset);const e=n.id.clock-s.struct.id.clock-s.struct.length;s={struct:new M_(yN(t,s.struct.id.clock+s.struct.length),e),offset:0}}else{const t=s.struct.id.clock+s.struct.length-n.id.clock;t>0&&(s.struct.constructor===M_?s.struct.length-=t:n=KN(n,t)),s.struct.mergeWith(n)||(tj(a,s.struct,s.offset),s={struct:n,offset:0},e.next())}}else s={struct:e.curr,offset:0},e.next();for(let n=e.curr;null!==n&&n.id.client===t&&n.id.clock===s.struct.id.clock+s.struct.length&&n.constructor!==M_;n=e.next())tj(a,s.struct,s.offset),s={struct:n,offset:0}}null!==s&&(tj(a,s.struct,s.offset),s=null),nj(a);const l=r.map((e=>WE(e))),c=UE(l);return VE(i,c),i.toUint8Array()},QN=(e,t,n=ZE,r=nN)=>{const o=aN(t),s=new r,i=new XN(s),a=new n(_C(e)),l=new YN(a,!1);for(;l.curr;){const e=l.curr,t=e.id.client,n=o.get(t)||0;if(l.curr.constructor!==M_)if(e.id.clock+e.length>n)for(tj(i,e,FS(n-e.id.clock,0)),l.next();l.curr&&l.curr.id.client===t;)tj(i,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===t&&l.curr.id.clock+l.curr.length<=n;)l.next();else l.next()}nj(i);const c=WE(a);return VE(s,c),s.toUint8Array()},ej=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:rC(e.encoder.restEncoder)}),e.encoder.restEncoder=tC(),e.written=0)},tj=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&ej(e),0===e.written&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),iC(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},nj=e=>{ej(e);const t=e.encoder.restEncoder;iC(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const r=e.clientStructs[n];iC(t,r.written),uC(t,r.restEncoder)}},rj=e=>((e,t,n,r)=>{const o=new n(_C(e)),s=new YN(o,!1),i=new r,a=new XN(i);for(let c=s.curr;null!==c;c=s.next())tj(a,t(c),0);nj(a);const l=WE(o);return VE(i,l),i.toUint8Array()})(e,sE,ZE,eN),oj="You must not compute changes after the event-handler fired.";class sj{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=ij(this.currentTarget,this.target))}deletes(e){return FE(this.transaction.deleteSet,e.id)}get keys(){if(null===this._keys){if(0===this.transaction.doc._transactionCleanups.length)throw kC(oj);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach((n=>{if(null!==n){const r=t._map.get(n);let o,s;if(this.adds(r)){let e=r.left;for(;null!==e&&this.adds(e);)e=e.left;if(this.deletes(r)){if(null===e||!this.deletes(e))return;o="delete",s=AS(e.content.getContent())}else null!==e&&this.deletes(e)?(o="update",s=AS(e.content.getContent())):(o="add",s=void 0)}else{if(!this.deletes(r))return;o="delete",s=AS(r.content.getContent())}e.set(n,{action:o,oldValue:s})}})),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(null===e){if(0===this.transaction.doc._transactionCleanups.length)throw kC(oj);const t=this.target,n=IS(),r=IS(),o=[];e={added:n,deleted:r,delta:o,keys:this.keys};if(this.transaction.changed.get(t).has(null)){let e=null;const s=()=>{e&&o.push(e)};for(let o=t._start;null!==o;o=o.right)o.deleted?this.deletes(o)&&!this.adds(o)&&(null!==e&&void 0!==e.delete||(s(),e={delete:0}),e.delete+=o.length,r.add(o)):this.adds(o)?(null!==e&&void 0!==e.insert||(s(),e={insert:[]}),e.insert=e.insert.concat(o.content.getContent()),n.add(o)):(null!==e&&void 0!==e.retain||(s(),e={retain:0}),e.retain+=o.length);null!==e&&void 0===e.retain&&s()}this._changes=e}return e}}const ij=(e,t)=>{const n=[];for(;null!==t._item&&t!==e;){if(null!==t._item.parentSub)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&null!==r;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},aj=()=>{ME("Invalid access: Add Yjs type to a document before reading data.")};let lj=0;class cj{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=lj++}}const dj=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=lj++},uj=(e,t)=>{if(null===e._start||0===t||null===e._searchMarker)return null;const n=0===e._searchMarker.length?null:e._searchMarker.reduce(((e,n)=>LS(t-e.index)<LS(t-n.index)?e:n));let r=e._start,o=0;for(null!==n&&(r=n.p,o=n.index,(e=>{e.timestamp=lj++})(n));null!==r.right&&o<t;){if(!r.deleted&&r.countable){if(t<o+r.length)break;o+=r.length}r=r.right}for(;null!==r.left&&o>t;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);for(;null!==r.left&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);return null!==n&&LS(n.index-o)<r.parent.length/80?(dj(n,r,o),n):((e,t,n)=>{if(e.length>=80){const r=e.reduce(((e,t)=>e.timestamp<t.timestamp?e:t));return dj(r,t,n),r}{const r=new cj(t,n);return e.push(r),r}})(e._searchMarker,r,o)},hj=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){const o=e[r];if(n>0){let t=o.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(o.index-=t.length);if(null===t||!0===t.marker){e.splice(r,1);continue}o.p=t,t.marker=!0}(t<o.index||n>0&&t===o.index)&&(o.index=FS(t,o.index+n))}},fj=(e,t,n)=>{const r=e,o=t.changedParentTypes;for(;_S(o,e,(()=>[])).push(n),null!==e._item;)e=e._item.parent;pN(r._eH,n,t)};class pj{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=uN(),this._dEH=uN(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw SC()}clone(){throw SC()}_write(e){}get _first(){let e=this._start;for(;null!==e&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){hN(this._eH,e)}observeDeep(e){hN(this._dEH,e)}unobserve(e){fN(this._eH,e)}unobserveDeep(e){fN(this._dEH,e)}toJSON(){}}const mj=(e,t,n)=>{e.doc??aj(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t;const o=[];let s=e._start;for(;null!==s&&r>0;){if(s.countable&&!s.deleted){const e=s.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)o.push(e[n]),r--;t=0}}s=s.right}return o},gj=e=>{e.doc??aj();const t=[];let n=e._start;for(;null!==n;){if(n.countable&&!n.deleted){const e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},yj=(e,t)=>{let n=0,r=e._start;for(e.doc??aj();null!==r;){if(r.countable&&!r.deleted){const o=r.content.getContent();for(let r=0;r<o.length;r++)t(o[r],n++,e)}r=r.right}},bj=(e,t)=>{const n=[];return yj(e,((r,o)=>{n.push(t(r,o,e))})),n},xj=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(null===n){for(;null!==t&&t.deleted;)t=t.right;if(null===t)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}const e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},vj=(e,t)=>{e.doc??aj();const n=uj(e,t);let r=e._start;for(null!==n&&(r=n.p,t-=n.index);null!==r;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},wj=(e,t,n,r)=>{let o=n;const s=e.doc,i=s.clientID,a=s.store,l=null===n?t._start:n.right;let c=[];const d=()=>{c.length>0&&(o=new I_(yN(i,AN(a,i)),o,o&&o.lastId,l,l&&l.id,t,null,new f_(c)),o.integrate(e,0),c=[])};r.forEach((n=>{if(null===n)c.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(n);break;default:switch(d(),n.constructor){case Uint8Array:case ArrayBuffer:o=new I_(yN(i,AN(a,i)),o,o&&o.lastId,l,l&&l.id,t,null,new s_(new Uint8Array(n))),o.integrate(e,0);break;case YE:o=new I_(yN(i,AN(a,i)),o,o&&o.lastId,l,l&&l.id,t,null,new l_(n)),o.integrate(e,0);break;default:if(!(n instanceof pj))throw new Error("Unexpected content type in insert operation");o=new I_(yN(i,AN(a,i)),o,o&&o.lastId,l,l&&l.id,t,null,new S_(n)),o.integrate(e,0)}}})),d()},kj=()=>kC("Length exceeded!"),Sj=(e,t,n,r)=>{if(n>t._length)throw kj();if(0===n)return t._searchMarker&&hj(t._searchMarker,n,r.length),wj(e,t,null,r);const o=n,s=uj(t,n);let i=t._start;for(null!==s&&(i=s.p,0===(n-=s.index)&&(i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0));null!==i;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){n<i.length&&RN(e,yN(i.id.client,i.id.clock+n));break}n-=i.length}return t._searchMarker&&hj(t._searchMarker,o,r.length),wj(e,t,i,r)},Cj=(e,t,n,r)=>{if(0===r)return;const o=n,s=r,i=uj(t,n);let a=t._start;for(null!==i&&(a=i.p,n-=i.index);null!==a&&n>0;a=a.right)!a.deleted&&a.countable&&(n<a.length&&RN(e,yN(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&null!==a;)a.deleted||(r<a.length&&RN(e,yN(a.id.client,a.id.clock+r)),a.delete(e),r-=a.length),a=a.right;if(r>0)throw kj();t._searchMarker&&hj(t._searchMarker,o,-s+r)},Ej=(e,t,n)=>{const r=t._map.get(n);void 0!==r&&r.delete(e)},Nj=(e,t,n,r)=>{const o=t._map.get(n)||null,s=e.doc,i=s.clientID;let a;if(null==r)a=new f_([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:a=new f_([r]);break;case Uint8Array:a=new s_(r);break;case YE:a=new l_(r);break;default:if(!(r instanceof pj))throw new Error("Unexpected content type");a=new S_(r)}new I_(yN(i,AN(s.store,i)),o,o&&o.lastId,null,null,t,n,a).integrate(e,0)},jj=(e,t)=>{e.doc??aj();const n=e._map.get(t);return void 0===n||n.deleted?void 0:n.content.getContent()[n.length-1]},_j=e=>{const t={};return e.doc??aj(),e._map.forEach(((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])})),t},Ij=(e,t)=>{e.doc??aj();const n=e._map.get(t);return void 0!==n&&!n.deleted},Aj=e=>{return e.doc??aj(),t=e._map.entries(),n=e=>!e[1].deleted,OE((()=>{let e;do{e=t.next()}while(!e.done&&!n(e.value));return e}));var t,n};class Tj extends sj{}class Mj extends pj{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new Mj;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Mj}clone(){const e=new Mj;return e.insert(0,this.toArray().map((e=>e instanceof pj?e.clone():e))),e}get length(){return this.doc??aj(),this._length}_callObserver(e,t){super._callObserver(e,t),fj(this,e,new Tj(this,e))}insert(e,t){null!==this.doc?HN(this.doc,(n=>{Sj(n,this,e,t)})):this._prelimContent.splice(e,0,...t)}push(e){null!==this.doc?HN(this.doc,(t=>{((e,t,n)=>{let r=(t._searchMarker||[]).reduce(((e,t)=>t.index>e.index?t:e),{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;wj(e,t,r,n)})(t,this,e)})):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){null!==this.doc?HN(this.doc,(n=>{Cj(n,this,e,t)})):this._prelimContent.splice(e,t)}get(e){return vj(this,e)}toArray(){return gj(this)}slice(e=0,t=this.length){return mj(this,e,t)}toJSON(){return this.map((e=>e instanceof pj?e.toJSON():e))}map(e){return bj(this,e)}forEach(e){yj(this,e)}[Symbol.iterator](){return xj(this)}_write(e){e.writeTypeRef(g_)}}class Dj extends sj{constructor(e,t,n){super(e,t),this.keysChanged=n}}class Oj extends pj{constructor(e){super(),this._prelimContent=null,this._prelimContent=void 0===e?new Map:new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach(((e,t)=>{this.set(t,e)})),this._prelimContent=null}_copy(){return new Oj}clone(){const e=new Oj;return this.forEach(((t,n)=>{e.set(n,t instanceof pj?t.clone():t)})),e}_callObserver(e,t){fj(this,e,new Dj(this,e,t))}toJSON(){this.doc??aj();const e={};return this._map.forEach(((t,n)=>{if(!t.deleted){const r=t.content.getContent()[t.length-1];e[n]=r instanceof pj?r.toJSON():r}})),e}get size(){return[...Aj(this)].length}keys(){return RE(Aj(this),(e=>e[0]))}values(){return RE(Aj(this),(e=>e[1].content.getContent()[e[1].length-1]))}entries(){return RE(Aj(this),(e=>[e[0],e[1].content.getContent()[e[1].length-1]]))}forEach(e){this.doc??aj(),this._map.forEach(((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)}))}[Symbol.iterator](){return this.entries()}delete(e){null!==this.doc?HN(this.doc,(t=>{Ej(t,this,e)})):this._prelimContent.delete(e)}set(e,t){return null!==this.doc?HN(this.doc,(n=>{Nj(n,this,e,t)})):this._prelimContent.set(e,t),t}get(e){return jj(this,e)}has(e){return Ij(this,e)}clear(){null!==this.doc?HN(this.doc,(e=>{this.forEach((function(t,n,r){Ej(e,r,n)}))})):this._prelimContent.clear()}_write(e){e.writeTypeRef(y_)}}const Rj=(e,t)=>e===t||"object"==typeof e&&"object"==typeof t&&e&&t&&((e,t)=>e===t||eE(e)===eE(t)&&((e,t)=>{for(const n in e)if(!t(e[n],n))return!1;return!0})(e,((e,n)=>(void 0!==e||tE(t,n))&&t[n]===e)))(e,t);class Pj{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){if(null===this.right&&CC(),this.right.content.constructor===d_)this.right.deleted||Bj(this.currentAttributes,this.right.content);else this.right.deleted||(this.index+=this.right.length);this.left=this.right,this.right=this.right.right}}const Lj=(e,t,n)=>{for(;null!==t.right&&n>0;){if(t.right.content.constructor===d_)t.right.deleted||Bj(t.currentAttributes,t.right.content);else t.right.deleted||(n<t.right.length&&RN(e,yN(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);t.left=t.right,t.right=t.right.right}return t},zj=(e,t,n,r)=>{const o=new Map,s=r?uj(t,n):null;if(s){const t=new Pj(s.p.left,s.p,s.index,o);return Lj(e,t,n-s.index)}{const r=new Pj(null,t._start,0,o);return Lj(e,r,n)}},Fj=(e,t,n,r)=>{for(;null!==n.right&&(!0===n.right.deleted||n.right.content.constructor===d_&&Rj(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const o=e.doc,s=o.clientID;r.forEach(((r,i)=>{const a=n.left,l=n.right,c=new I_(yN(s,AN(o.store,s)),a,a&&a.lastId,l,l&&l.id,t,null,new d_(i,r));c.integrate(e,0),n.right=c,n.forward()}))},Bj=(e,t)=>{const{key:n,value:r}=t;null===r?e.delete(n):e.set(n,r)},Uj=(e,t)=>{for(;null!==e.right&&(e.right.deleted||e.right.content.constructor===d_&&Rj(t[e.right.content.key]??null,e.right.content.value));)e.forward()},$j=(e,t,n,r)=>{const o=e.doc,s=o.clientID,i=new Map;for(const a in r){const l=r[a],c=n.currentAttributes.get(a)??null;if(!Rj(c,l)){i.set(a,c);const{left:r,right:d}=n;n.right=new I_(yN(s,AN(o.store,s)),r,r&&r.lastId,d,d&&d.id,t,null,new d_(a,l)),n.right.integrate(e,0),n.forward()}}return i},Hj=(e,t,n,r,o)=>{n.currentAttributes.forEach(((e,t)=>{void 0===o[t]&&(o[t]=null)}));const s=e.doc,i=s.clientID;Uj(n,o);const a=$j(e,t,n,o),l=r.constructor===String?new p_(r):r instanceof pj?new S_(r):new c_(r);let{left:c,right:d,index:u}=n;t._searchMarker&&hj(t._searchMarker,n.index,l.getLength()),d=new I_(yN(i,AN(s.store,i)),c,c&&c.lastId,d,d&&d.id,t,null,l),d.integrate(e,0),n.right=d,n.index=u,n.forward(),Fj(e,t,n,a)},Vj=(e,t,n,r,o)=>{const s=e.doc,i=s.clientID;Uj(n,o);const a=$j(e,t,n,o);e:for(;null!==n.right&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===d_));){if(!n.right.deleted)switch(n.right.content.constructor){case d_:{const{key:t,value:s}=n.right.content,i=o[t];if(void 0!==i){if(Rj(i,s))a.delete(t);else{if(0===r)break e;a.set(t,s)}n.right.delete(e)}else n.currentAttributes.set(t,s);break}default:r<n.right.length&&RN(e,yN(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let o="";for(;r>0;r--)o+="\n";n.right=new I_(yN(i,AN(s.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new p_(o)),n.right.integrate(e,0),n.forward()}Fj(e,t,n,a)},Wj=(e,t,n,r,o)=>{let s=t;const i=NS();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===d_){const e=s.content;i.set(e.key,e)}s=s.right}let a=0,l=!1;for(;t!==s;){if(n===t&&(l=!0),!t.deleted){const n=t.content;switch(n.constructor){case d_:{const{key:s,value:c}=n,d=r.get(s)??null;i.get(s)===n&&d!==c||(t.delete(e),a++,l||(o.get(s)??null)!==c||d===c||(null===d?o.delete(s):o.set(s,d))),l||t.deleted||Bj(o,n);break}}}t=t.right}return a},Gj=e=>{let t=0;return HN(e.doc,(n=>{let r=e._start,o=e._start,s=NS();const i=jS(s);for(;o;){if(!1===o.deleted)if(o.content.constructor===d_)Bj(i,o.content);else t+=Wj(n,r,o,s,i),s=jS(i),r=o;o=o.right}})),t},qj=e=>{const t=new Set,n=e.doc;for(const[r,o]of e.afterState.entries()){const s=e.beforeState.get(r)||0;o!==s&&LN(e,n.store.clients.get(r),s,o,(e=>{e.deleted||e.content.constructor!==d_||e.constructor===o_||t.add(e.parent)}))}HN(n,(n=>{zE(e,e.deleteSet,(e=>{if(e instanceof o_||!e.parent._hasFormatting||t.has(e.parent))return;const r=e.parent;e.content.constructor===d_?t.add(r):((e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===d_){const r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}})(n,e)}));for(const e of t)Gj(e)}))},Yj=(e,t,n)=>{const r=n,o=jS(t.currentAttributes),s=t.right;for(;n>0&&null!==t.right;){if(!1===t.right.deleted)switch(t.right.content.constructor){case S_:case c_:case p_:n<t.right.length&&RN(e,yN(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}s&&Wj(e,s,t.right,o,t.currentAttributes);const i=(t.left||t.right).parent;return i._searchMarker&&hj(i._searchMarker,t.index,-r+n),t};class Xj extends sj{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach((e=>{null===e?this.childListChanged=!0:this.keysChanged.add(e)}))}get changes(){if(null===this._changes){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(null===this._delta){const e=this.target.doc,t=[];HN(e,(e=>{const n=new Map,r=new Map;let o=this.target._start,s=null;const i={};let a="",l=0,c=0;const d=()=>{if(null!==s){let e=null;switch(s){case"delete":c>0&&(e={delete:c}),c=0;break;case"insert":("object"==typeof a||a.length>0)&&(e={insert:a},n.size>0&&(e.attributes={},n.forEach(((t,n)=>{null!==t&&(e.attributes[n]=t)})))),a="";break;case"retain":l>0&&(e={retain:l},(e=>{for(const t in e)return!1;return!0})(i)||(e.attributes=KC({},i))),l=0}e&&t.push(e),s=null}};for(;null!==o;){switch(o.content.constructor){case S_:case c_:this.adds(o)?this.deletes(o)||(d(),s="insert",a=o.content.getContent()[0],d()):this.deletes(o)?("delete"!==s&&(d(),s="delete"),c+=1):o.deleted||("retain"!==s&&(d(),s="retain"),l+=1);break;case p_:this.adds(o)?this.deletes(o)||("insert"!==s&&(d(),s="insert"),a+=o.content.str):this.deletes(o)?("delete"!==s&&(d(),s="delete"),c+=o.length):o.deleted||("retain"!==s&&(d(),s="retain"),l+=o.length);break;case d_:{const{key:t,value:a}=o.content;if(this.adds(o)){if(!this.deletes(o)){const l=n.get(t)??null;Rj(l,a)?null!==a&&o.delete(e):("retain"===s&&d(),Rj(a,r.get(t)??null)?delete i[t]:i[t]=a)}}else if(this.deletes(o)){r.set(t,a);const e=n.get(t)??null;Rj(e,a)||("retain"===s&&d(),i[t]=e)}else if(!o.deleted){r.set(t,a);const n=i[t];void 0!==n&&(Rj(n,a)?null!==n&&o.delete(e):("retain"===s&&d(),null===a?delete i[t]:i[t]=a))}o.deleted||("insert"===s&&d(),Bj(n,o.content));break}}o=o.right}for(d();t.length>0;){const e=t[t.length-1];if(void 0===e.retain||void 0!==e.attributes)break;t.pop()}})),this._delta=t}return this._delta}}class Jj extends pj{constructor(e){super(),this._pending=void 0!==e?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??aj(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach((e=>e()))}catch(iX){console.error(iX)}this._pending=null}_copy(){return new Jj}clone(){const e=new Jj;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const n=new Xj(this,e,t);fj(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??aj();let e="",t=this._start;for(;null!==t;)!t.deleted&&t.countable&&t.content.constructor===p_&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){null!==this.doc?HN(this.doc,(n=>{const r=new Pj(null,this._start,0,new Map);for(let o=0;o<e.length;o++){const s=e[o];if(void 0!==s.insert){const i=t||"string"!=typeof s.insert||o!==e.length-1||null!==r.right||"\n"!==s.insert.slice(-1)?s.insert:s.insert.slice(0,-1);("string"!=typeof i||i.length>0)&&Hj(n,this,r,i,s.attributes||{})}else void 0!==s.retain?Vj(n,this,r,s.retain,s.attributes||{}):void 0!==s.delete&&Yj(n,r,s.delete)}})):this._pending.push((()=>this.applyDelta(e)))}toDelta(e,t,n){this.doc??aj();const r=[],o=new Map,s=this.doc;let i="",a=this._start;function l(){if(i.length>0){const e={};let t=!1;o.forEach(((n,r)=>{t=!0,e[r]=n}));const n={insert:i};t&&(n.attributes=e),r.push(n),i=""}}const c=()=>{for(;null!==a;){if(NN(a,e)||void 0!==t&&NN(a,t))switch(a.content.constructor){case p_:{const r=o.get("ychange");void 0===e||NN(a,e)?void 0===t||NN(a,t)?void 0!==r&&(l(),o.delete("ychange")):void 0!==r&&r.user===a.id.client&&"added"===r.type||(l(),o.set("ychange",n?n("added",a.id):{type:"added"})):void 0!==r&&r.user===a.id.client&&"removed"===r.type||(l(),o.set("ychange",n?n("removed",a.id):{type:"removed"})),i+=a.content.str;break}case S_:case c_:{l();const e={insert:a.content.getContent()[0]};if(o.size>0){const t={};e.attributes=t,o.forEach(((e,n)=>{t[n]=e}))}r.push(e);break}case d_:NN(a,e)&&(l(),Bj(o,a.content))}a=a.right}l()};return e||t?HN(s,(n=>{e&&jN(n,e),t&&jN(n,t),c()}),"cleanup"):c(),r}insert(e,t,n){if(t.length<=0)return;const r=this.doc;null!==r?HN(r,(r=>{const o=zj(r,this,e,!n);n||(n={},o.currentAttributes.forEach(((e,t)=>{n[t]=e}))),Hj(r,this,o,t,n)})):this._pending.push((()=>this.insert(e,t,n)))}insertEmbed(e,t,n){const r=this.doc;null!==r?HN(r,(r=>{const o=zj(r,this,e,!n);Hj(r,this,o,t,n||{})})):this._pending.push((()=>this.insertEmbed(e,t,n||{})))}delete(e,t){if(0===t)return;const n=this.doc;null!==n?HN(n,(n=>{Yj(n,zj(n,this,e,!0),t)})):this._pending.push((()=>this.delete(e,t)))}format(e,t,n){if(0===t)return;const r=this.doc;null!==r?HN(r,(r=>{const o=zj(r,this,e,!1);null!==o.right&&Vj(r,this,o,t,n)})):this._pending.push((()=>this.format(e,t,n)))}removeAttribute(e){null!==this.doc?HN(this.doc,(t=>{Ej(t,this,e)})):this._pending.push((()=>this.removeAttribute(e)))}setAttribute(e,t){null!==this.doc?HN(this.doc,(n=>{Nj(n,this,e,t)})):this._pending.push((()=>this.setAttribute(e,t)))}getAttribute(e){return jj(this,e)}getAttributes(){return _j(this)}_write(e){e.writeTypeRef(b_)}}class Kj{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??aj()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(null!==e&&(!this._firstCall||e.deleted||!this._filter(t)))do{if(t=e.content.type,e.deleted||t.constructor!==Qj&&t.constructor!==Zj||null===t._start)for(;null!==e;){if(null!==e.right){e=e.right;break}e=e.parent===this._root?null:e.parent._item}else e=t._start}while(null!==e&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,null===e?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Zj extends pj{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Zj}clone(){const e=new Zj;return e.insert(0,this.toArray().map((e=>e instanceof pj?e.clone():e))),e}get length(){return this.doc??aj(),null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(e){return new Kj(this,e)}querySelector(e){e=e.toUpperCase();const t=new Kj(this,(t=>t.nodeName&&t.nodeName.toUpperCase()===e)).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),MS(new Kj(this,(t=>t.nodeName&&t.nodeName.toUpperCase()===e)))}_callObserver(e,t){fj(this,e,new e_(this,t,e))}toString(){return bj(this,(e=>e.toString())).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},n){const r=e.createDocumentFragment();return void 0!==n&&n._createAssociation(r,this),yj(this,(o=>{r.insertBefore(o.toDOM(e,t,n),null)})),r}insert(e,t){null!==this.doc?HN(this.doc,(n=>{Sj(n,this,e,t)})):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(null!==this.doc)HN(this.doc,(n=>{const r=e&&e instanceof pj?e._item:e;wj(n,this,r,t)}));else{const n=this._prelimContent,r=null===e?0:n.findIndex((t=>t===e))+1;if(0===r&&null!==e)throw kC("Reference item not found");n.splice(r,0,...t)}}delete(e,t=1){null!==this.doc?HN(this.doc,(n=>{Cj(n,this,e,t)})):this._prelimContent.splice(e,t)}toArray(){return gj(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return vj(this,e)}slice(e=0,t=this.length){return mj(this,e,t)}forEach(e){yj(this,e)}_write(e){e.writeTypeRef(v_)}}class Qj extends Zj{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach(((e,t)=>{this.setAttribute(t,e)})),this._prelimAttrs=null}_copy(){return new Qj(this.nodeName)}clone(){const e=new Qj(this.nodeName);return((e,t)=>{for(const n in e)t(e[n],n)})(this.getAttributes(),((t,n)=>{"string"==typeof t&&e.setAttribute(n,t)})),e.insert(0,this.toArray().map((e=>e instanceof pj?e.clone():e))),e}toString(){const e=this.getAttributes(),t=[],n=[];for(const s in e)n.push(s);n.sort();const r=n.length;for(let s=0;s<r;s++){const r=n[s];t.push(r+'="'+e[r]+'"')}const o=this.nodeName.toLocaleLowerCase();return`<${o}${t.length>0?" "+t.join(" "):""}>${super.toString()}</${o}>`}removeAttribute(e){null!==this.doc?HN(this.doc,(t=>{Ej(t,this,e)})):this._prelimAttrs.delete(e)}setAttribute(e,t){null!==this.doc?HN(this.doc,(n=>{Nj(n,this,e,t)})):this._prelimAttrs.set(e,t)}getAttribute(e){return jj(this,e)}hasAttribute(e){return Ij(this,e)}getAttributes(e){return e?((e,t)=>{const n={};return e._map.forEach(((e,r)=>{let o=e;for(;null!==o&&(!t.sv.has(o.id.client)||o.id.clock>=(t.sv.get(o.id.client)||0));)o=o.left;null!==o&&NN(o,t)&&(n[r]=o.content.getContent()[o.length-1])})),n})(this,e):_j(this)}toDOM(e=document,t={},n){const r=e.createElement(this.nodeName),o=this.getAttributes();for(const s in o){const e=o[s];"string"==typeof e&&r.setAttribute(s,e)}return yj(this,(o=>{r.appendChild(o.toDOM(e,t,n))})),void 0!==n&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(x_),e.writeKey(this.nodeName)}}class e_ extends sj{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach((e=>{null===e?this.childListChanged=!0:this.attributesChanged.add(e)}))}}class t_ extends Oj{constructor(e){super(),this.hookName=e}_copy(){return new t_(this.hookName)}clone(){const e=new t_(this.hookName);return this.forEach(((t,n)=>{e.set(n,t)})),e}toDOM(e=document,t={},n){const r=t[this.hookName];let o;return o=void 0!==r?r.createDom(this):document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),void 0!==n&&n._createAssociation(o,this),o}_write(e){e.writeTypeRef(w_),e.writeKey(this.hookName)}}class n_ extends Jj{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new n_}clone(){const e=new n_;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,n){const r=e.createTextNode(this.toString());return void 0!==n&&n._createAssociation(r,this),r}toString(){return this.toDelta().map((e=>{const t=[];for(const r in e.attributes){const n=[];for(const t in e.attributes[r])n.push({key:t,value:e.attributes[r][t]});n.sort(((e,t)=>e.key<t.key?-1:1)),t.push({nodeName:r,attrs:n})}t.sort(((e,t)=>e.nodeName<t.nodeName?-1:1));let n="";for(let r=0;r<t.length;r++){const e=t[r];n+=`<${e.nodeName}`;for(let t=0;t<e.attrs.length;t++){const r=e.attrs[t];n+=` ${r.key}="${r.value}"`}n+=">"}n+=e.insert;for(let r=t.length-1;r>=0;r--)n+=`</${t[r].nodeName}>`;return n})).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(k_)}}class r_{constructor(e,t){this.id=e,this.length=t}get deleted(){throw SC()}mergeWith(e){return!1}write(e,t,n){throw SC()}integrate(e,t){throw SC()}}class o_ extends r_{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),TN(e.doc.store,this)}write(e,t){e.writeInfo(0),e.writeLen(this.length-t)}getMissing(e,t){return null}}class s_{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new s_(this.content)}splice(e){throw SC()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}class i_{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new i_(this.len)}splice(e){const t=new i_(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){$E(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const a_=(e,t)=>new YE({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class l_{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),null!==e.meta&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new l_(a_(this.doc.guid,this.opts))}splice(e){throw SC()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}class c_{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new c_(this.embed)}splice(e){throw SC()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}class d_{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new d_(this.key,this.value)}splice(e){throw SC()}mergeWith(e){return!1}integrate(e,t){const n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}class u_{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new u_(this.arr)}splice(e){const t=new u_(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){const t=this.arr[r];e.writeString(void 0===t?"undefined":JSON.stringify(t))}}getRef(){return 2}}const h_="development"===hE("node_env");class f_{constructor(e){this.arr=e,h_&&rE(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new f_(this.arr)}splice(e){const t=new f_(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){const t=this.arr[r];e.writeAny(t)}}getRef(){return 8}}class p_{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new p_(this.str)}splice(e){const t=new p_(this.str.slice(e));this.str=this.str.slice(0,e);const n=this.str.charCodeAt(e-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(0===t?this.str:this.str.slice(t))}getRef(){return 4}}const m_=[e=>new Mj,e=>new Oj,e=>new Jj,e=>new Qj(e.readKey()),e=>new Zj,e=>new t_(e.readKey()),e=>new n_],g_=0,y_=1,b_=2,x_=3,v_=4,w_=5,k_=6;class S_{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new S_(this.type._copy())}splice(e){throw SC()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;null!==t;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach((t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)})),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;null!==t;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach((t=>{for(;null!==t;)t.gc(e,!0),t=t.left})),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const C_=(e,t)=>{let n,r=t,o=0;do{o>0&&(r=yN(r.client,r.clock+o)),n=DN(e,r),o=r.clock-n.id.clock,r=n.redone}while(null!==r&&n instanceof I_);return{item:n,diff:o}},E_=(e,t)=>{for(;null!==e&&e.keep!==t;)e.keep=t,e=e.parent._item},N_=(e,t,n)=>{const{client:r,clock:o}=t.id,s=new I_(yN(r,o+n),t,yN(r,o+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&s.markDeleted(),t.keep&&(s.keep=!0),null!==t.redone&&(s.redone=yN(t.redone.client,t.redone.clock+n)),t.right=s,null!==s.right&&(s.right.left=s),e._mergeStructs.push(s),null!==s.parentSub&&null===s.right&&s.parent._map.set(s.parentSub,s),t.length=n,s},j_=(e,t)=>((e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1})(e,(e=>FE(e.deletions,t))),__=(e,t,n,r,o,s)=>{const i=e.doc,a=i.store,l=i.clientID,c=t.redone;if(null!==c)return RN(e,c);let d,u=t.parent._item,h=null;if(null!==u&&!0===u.deleted){if(null===u.redone&&(!n.has(u)||null===__(e,u,n,r,o,s)))return null;for(;null!==u.redone;)u=RN(e,u.redone)}const f=null===u?t.parent:u.content.type;if(null===t.parentSub){for(h=t.left,d=t;null!==h;){let t=h;for(;null!==t&&t.parent._item!==u;)t=null===t.redone?null:RN(e,t.redone);if(null!==t&&t.parent._item===u){h=t;break}h=h.left}for(;null!==d;){let t=d;for(;null!==t&&t.parent._item!==u;)t=null===t.redone?null:RN(e,t.redone);if(null!==t&&t.parent._item===u){d=t;break}d=d.right}}else if(d=null,t.right&&!o){for(h=t;null!==h&&null!==h.right&&(h.right.redone||FE(r,h.right.id)||j_(s.undoStack,h.right.id)||j_(s.redoStack,h.right.id));)for(h=h.right;h.redone;)h=RN(e,h.redone);if(h&&null!==h.right)return null}else h=f._map.get(t.parentSub)||null;const p=AN(a,l),m=yN(l,p),g=new I_(m,h,h&&h.lastId,d,d&&d.id,f,t.parentSub,t.content.copy());return t.redone=m,E_(g,!0),g.integrate(e,0),g};class I_ extends r_{constructor(e,t,n,r,o,s,i,a){super(e,a.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=o,this.parent=s,this.parentSub=i,this.redone=null,this.content=a,this.info=this.content.isCountable()?2:0}set marker(e){(8&this.info)>0!==e&&(this.info^=8)}get marker(){return(8&this.info)>0}get keep(){return(1&this.info)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(2&this.info)>0}get deleted(){return(4&this.info)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=AN(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=AN(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===mN&&this.id.client!==this.parent.client&&this.parent.clock>=AN(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=PN(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=RN(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===o_||this.right&&this.right.constructor===o_)this.parent=null;else if(this.parent){if(this.parent.constructor===mN){const e=DN(t,this.parent);e.constructor===o_?this.parent=null:this.parent=e.content.type}}else this.left&&this.left.constructor===I_&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===I_&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=PN(e,e.doc.store,yN(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let t,n=this.left;if(null!==n)t=n.right;else if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start;const r=new Set,o=new Set;for(;null!==t&&t!==this.right;){if(o.add(t),r.add(t),gN(this.origin,t.origin)){if(t.id.client<this.id.client)n=t,r.clear();else if(gN(this.rightOrigin,t.rightOrigin))break}else{if(null===t.origin||!o.has(DN(e.doc.store,t.origin)))break;r.has(DN(e.doc.store,t.origin))||(n=t,r.clear())}t=t.right}this.left=n}if(null!==this.left){const e=this.left.right;this.right=e,this.left.right=this}else{let e;if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(e)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),TN(e.doc.store,this),this.content.integrate(e,this),BN(e,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(e)}else new o_(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;null!==e&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;null!==e&&e.deleted;)e=e.left;return e}get lastId(){return 1===this.length?this.id:yN(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&gN(e.origin,this.lastId)&&this.right===e&&gN(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&null===this.redone&&null===e.redone&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const t=this.parent._searchMarker;return t&&t.forEach((t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))})),e.keep&&(this.keep=!0),this.right=e.right,null!==this.right&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const t=this.parent;this.countable&&null===this.parentSub&&(t._length-=this.length),this.markDeleted(),$E(e.deleteSet,this.id.client,this.id.clock,this.length),BN(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw CC();this.content.gc(e),t?((e,t,n)=>{const r=e.clients.get(t.id.client);r[MN(r,t.id.clock)]=n})(e,this,new o_(this.id,this.length)):this.content=new i_(this.length)}write(e,t){const n=t>0?yN(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,o=this.parentSub,s=31&this.content.getRef()|(null===n?0:HS)|(null===r?0:$S)|(null===o?0:32);if(e.writeInfo(s),null!==n&&e.writeLeftID(n),null!==r&&e.writeRightID(r),null===n&&null===r){const t=this.parent;if(void 0!==t._item){const n=t._item;if(null===n){const n=bN(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===mN?(e.writeParentInfo(!1),e.writeLeftID(t)):CC();null!==o&&e.writeString(o)}this.content.write(e,t)}}const A_=(e,t)=>T_[31&t](e),T_=[()=>{CC()},e=>new i_(e.readLen()),e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++){const t=e.readString();"undefined"===t?n.push(void 0):n.push(JSON.parse(t))}return new u_(n)},e=>new s_(e.readBuf()),e=>new p_(e.readString()),e=>new c_(e.readJSON()),e=>new d_(e.readKey(),e.readJSON()),e=>new S_(m_[e.readTypeRef()](e)),e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new f_(n)},e=>new l_(a_(e.readString(),e.readAny())),()=>{CC()}];class M_ extends r_{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){CC()}write(e,t){e.writeInfo(10),iC(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const D_="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},O_="__ $YJS$ __";!0===D_[O_]&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),D_[O_]=!0;class R_{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:wN(this.yanchor),yhead:wN(this.yhead)}}static fromJSON(e){return new R_(kN(e.yanchor),kN(e.yhead))}}class P_{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new qN(e)}toYPos(e,t=0){return((e,t,n=0)=>{let r=e._start;if(n<0){if(0===t)return CN(e,null,n);t--}for(;null!==r;){if(!r.deleted&&r.countable){if(r.length>t)return CN(e,yN(r.id.client,r.id.clock+t),n);t-=r.length}if(null===r.right&&n<0)return CN(e,r.lastId,n);r=r.right}return CN(e,null,n)})(this.ytext,e,t)}fromYPos(e){const t=EN(kN(e),this.ytext.doc);if(null==t||t.type!==this.ytext)throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");return{pos:t.index,assoc:t.assoc}}toYRange(e){const t=e.assoc,n=this.toYPos(e.anchor,t),r=this.toYPos(e.head,t);return new R_(n,r)}fromYRange(e){const t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?gn.cursor(n.pos,n.assoc):gn.range(t.pos,n.pos)}}const L_=sr.define({combine:e=>e[e.length-1]}),z_=ar.define();const F_=wn.fromClass(class{constructor(e){this.view=e,this.conf=e.state.facet(L_),this._observer=(t,n)=>{if(n.origin!==this.conf){const n=t.delta,r=[];let o=0;for(let e=0;e<n.length;e++){const t=n[e];null!=t.insert?r.push({from:o,to:o,insert:t.insert}):null!=t.delete?(r.push({from:o,to:o+t.delete,insert:""}),o+=t.delete):o+=t.retain}e.dispatch({changes:r,annotations:[z_.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(e){if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(z_)===this.conf)return;const t=this.conf.ytext;t.doc.transact((()=>{let n=0;e.changes.iterChanges(((e,r,o,s,i)=>{const a=i.sliceString(0,i.length,"\n");e!==r&&t.delete(e+n,r-e),a.length>0&&t.insert(e+n,a),n+=a.length-(r-e)}))}),this.conf)}destroy(){this._ytext.unobserve(this._observer)}});class B_{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return null!=this.undoManager.undo()}redo(){return null!=this.undoManager.redo()}}const U_=sr.define({combine:e=>e[e.length-1]});const $_=wn.fromClass(class{constructor(e){this.view=e,this.conf=e.state.facet(U_),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(L_),this._beforeChangeSelection=null,this._mux=(()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else void 0!==n&&n()}})(),this._onStackItemAdded=({stackItem:e,changedParentTypes:t})=>{t.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!e.meta.has(this)&&e.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:t})=>{const n=t.meta.get(this);if(n){const t=this.syncConf.fromYRange(n);e.dispatch(e.state.update({selection:t,effects:[yn.scrollIntoView(t)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on("stack-item-added",this._onStackItemAdded),this._undoManager.on("stack-item-popped",this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(e){!e.selectionSet||0!==e.transactions.length&&e.transactions[0].annotation(z_)===this.syncConf||this._storeSelection()}destroy(){this._undoManager.off("stack-item-added",this._onStackItemAdded),this._undoManager.off("stack-item-popped",this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}}),H_=(e,t,{undoManager:n=new qN(e)}={})=>{const r=new P_(e,t),o=[L_.of(r),F_];return!1!==n&&o.push(U_.of(new B_(n)),$_,yn.domEventHandlers({beforeinput:(e,t)=>"historyUndo"===e.inputType?(({state:e,dispatch:t})=>e.facet(U_).undo()||!0)(t):"historyRedo"===e.inputType&&(({state:e,dispatch:t})=>e.facet(U_).redo()||!0)(t)})),o},V_=new Map;const W_="undefined"==typeof BroadcastChannel?class{constructor(e){var t;this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&null!==this.onmessage&&this.onmessage({data:yE(t.newValue||"")}),t=this._onChange,XC||addEventListener("storage",t)}postMessage(e){JC.setItem(this.room,gE(new Uint8Array(e)))}close(){var e;e=this._onChange,XC||removeEventListener("storage",e)}}:BroadcastChannel,G_=e=>_S(V_,e,(()=>{const t=IS(),n=new W_(e);return n.onmessage=e=>t.forEach((t=>t(e.data,"broadcastchannel"))),{bc:n,subs:t}})),q_=(e,t,n=null)=>{const r=G_(e);r.bc.postMessage(t),r.subs.forEach((e=>e(t,n)))},Y_=(e,t)=>{iC(e,0);const n=(e=>cN(e,new QE))(t);hC(e,n)},X_=(e,t,n)=>{iC(e,1),hC(e,((e,t)=>iN(e,t,new eN))(t,n))},J_=(e,t,n)=>{try{((e,t,n)=>{sN(e,t,n,JE)})(t,IC(e),n)}catch(r){console.error("Caught error while handling a Yjs update",r)}},K_=J_,Z_=(e,t,n,r)=>{const o=TC(e);switch(o){case 0:((e,t,n)=>{X_(t,n,IC(e))})(e,t,n);break;case 1:J_(e,n,r);break;case 2:K_(e,n,r);break;default:throw new Error("Unknown message type")}return o},Q_=3e4;class eI extends RS{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const e=WC();null!==this.getLocalState()&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const t=[];this.meta.forEach(((n,r)=>{r!==this.clientID&&Q_<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)})),t.length>0&&tI(this,t,"timeout")}),PS(3e3)),e.on("destroy",(()=>{this.destroy()})),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,n=this.meta.get(t),r=void 0===n?0:n.clock+1,o=this.states.get(t);null===e?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:WC()});const s=[],i=[],a=[],l=[];null===e?l.push(t):null==o?null!=e&&s.push(t):(i.push(t),iE(o,e)||a.push(t)),(s.length>0||a.length>0||l.length>0)&&this.emit("change",[{added:s,updated:a,removed:l},"local"]),this.emit("update",[{added:s,updated:i,removed:l},"local"])}setLocalStateField(e,t){const n=this.getLocalState();null!==n&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}}const tI=(e,t,n)=>{const r=[];for(let o=0;o<t.length;o++){const n=t[o];if(e.states.has(n)){if(e.states.delete(n),n===e.clientID){const t=e.meta.get(n);e.meta.set(n,{clock:t.clock+1,lastUpdated:WC()})}r.push(n)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},nI=(e,t,n=e.states)=>{const r=t.length,o=tC();iC(o,r);for(let s=0;s<r;s++){const r=t[s],i=n.get(r)||null,a=e.meta.get(r).clock;iC(o,r),iC(o,a),dC(o,JSON.stringify(i))}return rC(o)},rI=[];rI[0]=(e,t,n,r,o)=>{iC(e,0);const s=Z_(t,e,n.doc,n);r&&1===s&&!n.synced&&(n.synced=!0)},rI[3]=(e,t,n,r,o)=>{iC(e,1),hC(e,nI(n.awareness,Array.from(n.awareness.getStates().keys())))},rI[1]=(e,t,n,r,o)=>{((e,t,n)=>{const r=_C(t),o=WC(),s=[],i=[],a=[],l=[],c=TC(r);for(let d=0;d<c;d++){const t=TC(r);let n=TC(r);const c=JSON.parse(DC(r)),d=e.meta.get(t),u=e.states.get(t),h=void 0===d?0:d.clock;(h<n||h===n&&null===c&&e.states.has(t))&&(null===c?t===e.clientID&&null!=e.getLocalState()?n++:e.states.delete(t):e.states.set(t,c),e.meta.set(t,{clock:n,lastUpdated:o}),void 0===d&&null!==c?s.push(t):void 0!==d&&null===c?l.push(t):null!==c&&(iE(c,u)||a.push(t),i.push(t)))}(s.length>0||a.length>0||l.length>0)&&e.emit("change",[{added:s,updated:a,removed:l},n]),(s.length>0||i.length>0||l.length>0)&&e.emit("update",[{added:s,updated:i,removed:l},n])})(n.awareness,IC(t),n)},rI[2]=(e,t,n,r,o)=>{((e,t,n)=>{0===TC(e)&&n(t,DC(e))})(t,n.doc,((e,t)=>oI(n,t)))};const oI=(e,t)=>console.warn(`Permission denied to access ${e.url}.\n${t}`),sI=(e,t,n)=>{const r=_C(t),o=tC(),s=TC(r),i=e.messageHandlers[s];return i?i(o,r,e,n,s):console.error("Unable to compute message"),o},iI=(e,t,n)=>{t===e.ws&&(e.emit("connection-close",[n,e]),e.ws=null,t.close(),e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,tI(e.awareness,Array.from(e.awareness.getStates().keys()).filter((t=>t!==e.doc.clientID)),e),e.emit("status",[{status:"disconnected"}])):e.wsUnsuccessfulReconnects++,setTimeout(aI,zS(100*BS(2,e.wsUnsuccessfulReconnects),e.maxBackoffTime),e))},aI=e=>{if(e.shouldConnect&&null===e.ws){const t=new e._WS(e.url,e.protocols);t.binaryType="arraybuffer",e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{e.wsLastMessageReceived=WC();const r=sI(e,new Uint8Array(n.data),!0);nC(r)>1&&t.send(rC(r))},t.onerror=t=>{e.emit("connection-error",[t,e])},t.onclose=n=>{iI(e,t,n)},t.onopen=()=>{e.wsLastMessageReceived=WC(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit("status",[{status:"connected"}]);const n=tC();if(iC(n,0),Y_(n,e.doc),t.send(rC(n)),null!==e.awareness.getLocalState()){const n=tC();iC(n,1),hC(n,nI(e.awareness,[e.doc.clientID])),t.send(rC(n))}},e.emit("status",[{status:"connecting"}])}},lI=(e,t)=>{const n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&q_(e.bcChannel,t,e)};class cI extends OS{constructor(e,t,n,{connect:r=!0,awareness:o=new eI(n),params:s={},protocols:i=[],WebSocketPolyfill:a=WebSocket,resyncInterval:l=-1,maxBackoffTime:c=2500,disableBc:d=!1}={}){for(super();"/"===e[e.length-1];)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+"/"+t,this.maxBackoffTime=c,this.params=s,this.protocols=i,this.roomname=t,this.doc=n,this._WS=a,this.awareness=o,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=d,this.wsUnsuccessfulReconnects=0,this.messageHandlers=rI.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,l>0&&(this._resyncInterval=setInterval((()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const e=tC();iC(e,0),Y_(e,n),this.ws.send(rC(e))}}),l)),this._bcSubscriber=(e,t)=>{if(t!==this){const t=sI(this,new Uint8Array(e),!1);nC(t)>1&&q_(this.bcChannel,rC(t),this)}},this._updateHandler=(e,t)=>{if(t!==this){const t=tC();iC(t,0),((e,t)=>{iC(e,2),hC(e,t)})(t,e),lI(this,rC(t))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:e,updated:t,removed:n},r)=>{const s=e.concat(t).concat(n),i=tC();iC(i,1),hC(i,nI(o,s)),lI(this,rC(i))},this._exitHandler=()=>{tI(this.awareness,[n.clientID],"app closed")},lE&&"undefined"!=typeof process&&process.on("exit",this._exitHandler),o.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval((()=>{this.wsconnected&&3e4<WC()-this.wsLastMessageReceived&&iI(this,this.ws,null)}),3e3),r&&this.connect()}get url(){const e=((e,t)=>{const n=[];for(const r in e)n.push(t(e[r],r));return n})(this.params,((e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`)).join("&");return this.serverUrl+"/"+this.roomname+(0===e.length?"":"?"+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}destroy(){0!==this._resyncInterval&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),lE&&"undefined"!=typeof process&&process.off("exit",this._exitHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;var e,t;this.bcconnected||(e=this.bcChannel,t=this._bcSubscriber,G_(e).subs.add(t),this.bcconnected=!0);const n=tC();iC(n,0),Y_(n,this.doc),q_(this.bcChannel,rC(n),this);const r=tC();iC(r,0),X_(r,this.doc),q_(this.bcChannel,rC(r),this);const o=tC();iC(o,3),q_(this.bcChannel,rC(o),this);const s=tC();iC(s,1),hC(s,nI(this.awareness,[this.doc.clientID])),q_(this.bcChannel,rC(s),this)}disconnectBc(){const e=tC();iC(e,1),hC(e,nI(this.awareness,[this.doc.clientID],new Map)),lI(this,rC(e)),this.bcconnected&&(((e,t)=>{const n=G_(e),r=n.subs.delete(t);r&&0===n.subs.size&&(n.bc.close(),V_.delete(e))})(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),null!==this.ws&&iI(this,this.ws,null)}connect(){this.shouldConnect=!0,this.wsconnected||null!==this.ws||(aI(this),this.connectBc())}}const dI="code";class uI{constructor(){this.providers=new Map,this.listenForConnectionChanges()}static getInstance(){return uI.instance||(uI.instance=new uI),uI.instance}getOrCreateProvider(e,t){const n=this.providers.get(e);if(n)return{provider:n,ytext:n.doc.getText(dI)};const r=new YE,o=r.getText(dI);t&&0===o.length&&o.insert(0,t);const s={session_id:Ps()},i=new URLSearchParams(window.location.search).get(Rs.filePath);i&&(s.file=i);const a=new cI("ws",e,r,{params:s});return this.providers.set(e,a),{provider:a,ytext:o}}listenForConnectionChanges(){K.sub(at,(()=>{const e=K.get(at);(e.state===ct.CLOSED||e.state===ct.CLOSING)&&this.disconnectAll()}))}disconnect(e){const t=this.providers.get(e);t&&(t.destroy(),this.providers.delete(e))}disconnectAll(){for(const[e]of this.providers)this.disconnect(e)}}function hI(e,t=""){if(_())return{extension:[],code:t};const n=uI.getInstance(),{ytext:r}=n.getOrCreateProvider(e,t),o=H_(r,null);return{code:r.toJSON(),extension:o}}uI.instance=void 0;const fI=({theme:e,showPlaceholder:t,allowFocus:n,id:r,config:s,code:i,status:a,serializedEditorState:l,setEditorView:c,runCell:d,updateCellCode:u,createNewCell:h,deleteCell:f,focusCell:p,moveCell:m,moveToNextCell:g,updateCellConfig:y,clearSerializedEditorState:b,userConfig:x,editorViewRef:v,editorViewParentRef:w,hidden:k,hasOutput:S,temporarilyShowCode:C,languageAdapter:E,setLanguageAdapter:N})=>{var _;const[A,T]=ze(du),M=function(){const e=j.c(2),t=ae(Cu);let n;return e[0]!==t?(n=e=>{De!==e&&t(e)},e[0]=t,e[1]=n):n=e[1],n}(),D="running"===a||"queued"===a,{sendToTop:O,sendToBottom:R}=U(),P=bu(),L="markdown"===E,z=B((()=>!D&&(f({cellId:r}),!0))),F=o.useCallback((()=>h({cellId:r,before:!1})),[r,h]),$=o.useCallback((()=>h({cellId:r,before:!0})),[r,h]),H=o.useCallback((()=>m({cellId:r,before:!1})),[r,m]),V=o.useCallback((()=>m({cellId:r,before:!0})),[r,m]),W=o.useCallback((()=>p({cellId:r,before:!1})),[r,p]),G=o.useCallback((()=>p({cellId:r,before:!0})),[r,p]),q=B((()=>{const e=!s.hide_code;return _e({configs:{[r]:{hide_code:e}}}),y({cellId:r,config:{hide_code:e}}),e})),Y=se(ce),X=B((()=>{yu(Y,h)})),J=Ls(x),Z=o.useMemo((()=>{const n=kb({cellId:r,showPlaceholder:t,enableAI:J,cellCodeCallbacks:{updateCellCode:u,afterToggleMarkdown:X},cellMovementCallbacks:{onRun:d,deleteCell:z,createAbove:$,createBelow:F,createManyBelow:e=>{for(const t of[...e].reverse())h({code:t,before:!1,cellId:r,skipIfCodeExists:!0})},moveUp:V,moveDown:H,focusUp:G,focusDown:W,sendToTop:O,sendToBottom:R,splitCell:P,moveToNextCell:g,toggleHideCode:q,aiCellCompletion:()=>{let e=!1;return T((t=>(null==t?void 0:t.cellId)===r?(e=!0,null):{cellId:r})),e}},completionConfig:x.completion,keymapConfig:x.keymap,theme:e,hotkeys:new zs(x.keymap.overrides??{})});return n.push(wn.define((e=>{const t=e.state.field(Fs);return N(t.type),{update(e){const t=e.state.field(Fs);N(t.type)}}}))),n}),[r,x.keymap,x.completion,J,e,t,$,F,G,W,V,H,g,O,R,P,h,q,u,z,d,T,X,N]),Q=B((()=>{if(Kd("rtc")){const e=hI(r);Z.push(e.extension),i=e.code}const e=new yn({state:Yr.create({doc:i,extensions:Z})});c(e),xe(e,Bs(e.state).type)})),ee=B((()=>{if(fn(null!==v.current,"Editor view is not initialized"),Kd("rtc")){const e=hI(r);Z.push(e.extension)}v.current.dispatch({effects:[bn.reconfigure.of([Z]),Us(v.current,x.completion,new zs(x.keymap.overrides??{}))]})})),te=B((()=>{if(fn(l,"Editor view is not initialized"),Kd("rtc")){const e=hI(r,i);Z.push(e.extension)}const e=new yn({state:Yr.fromJSON(l,{doc:i,extensions:Z},{history:$s})});xe(e,Bs(e.state).type),c(e),b({cellId:r})}));o.useEffect((()=>{null===l?null===v.current?Q():ee():te(),null!==v.current&&w&&null!==w.current&&w.current.replaceChildren(v.current.dom)}),[Q,ee,te,v,w,l,Z]);const re=null===v.current||null!==l;o.useEffect((()=>{const e=null!==K.get(ne).scrollKey;re&&n&&!e&&requestAnimationFrame((()=>{var e,t;null==(e=v.current)||e.focus(),null==(t=v.current)||t.dom.scrollIntoView({behavior:"smooth",block:"nearest"})}))}),[re,n,v]),o.useEffect((()=>{const e=v.current;return()=>{null==e||e.destroy()}}),[v]);const oe=k&&!L||k&&L&&!S;let ie="";return L&&k&&S?ie="h-0 overflow-hidden":k&&(ie="opacity-20 h-8 overflow-hidden"),I.jsx(CS,{enabled:(null==A?void 0:A.cellId)===r,initialPrompt:null==A?void 0:A.initialPrompt,currentCode:(null==(_=v.current)?void 0:_.state.doc.toString())??i,currentLanguageAdapter:E,declineChange:B((()=>{var e;T(null),null==(e=v.current)||e.focus()})),onChange:B((e=>{var t;null==(t=v.current)||t.dispatch({changes:{from:0,to:v.current.state.doc.length,insert:e}})})),acceptChange:B((e=>{var t,n;null==(t=v.current)||t.dispatch({changes:{from:0,to:v.current.state.doc.length,insert:e}}),null==(n=v.current)||n.focus(),T(null)})),children:I.jsxs("div",{className:"relative w-full",onFocus:()=>M(r),children:[oe&&I.jsx(Hs,{tooltip:"Edit code",className:"absolute inset-0 z-10",onClick:C}),I.jsx(pI,{className:ie,editorView:v.current,ref:w}),!k&&I.jsx("div",{className:"absolute top-1 right-5",children:I.jsx(Zw,{code:i,editorView:v.current,currentLanguageAdapter:E,onAfterToggle:X})})]})})},pI=u.forwardRef(((e,t)=>{const n=j.c(10),{className:r,editorView:s}=e,i=o.useRef(null);let a,l,c,d,u;return n[0]!==s?(a=()=>{null!==s&&null!==i.current&&0===i.current.children.length&&i.current.append(s.dom)},l=[s,i],n[0]=s,n[1]=a,n[2]=l):(a=n[1],l=n[2]),o.useEffect(a,l),n[3]!==r?(c=In("cm",r),n[3]=r,n[4]=c):c=n[4],n[5]!==t?(d=e=>{t?zw(t,i)(e):zw(i)(e)},n[5]=t,n[6]=d):d=n[6],n[7]!==c||n[8]!==d?(u=I.jsx("div",{className:c,ref:d,"data-testid":"cell-editor"}),n[7]=c,n[8]=d,n[9]=u):u=n[9],u}));pI.displayName="CellCodeMirrorEditor";const mI=Kd("rtc")?function(e){const t=t=>{const n=j.c(2);if(se(at).state===ct.CONNECTING)return null;let r;return n[0]!==t?(r=I.jsx(e,{...t}),n[0]=t,n[1]=r):r=n[1],r};return t.displayName=`WithWaitUntilConnected(${e.displayName})`,t}(o.memo(fI)):o.memo(fI),gI=e=>{const t=j.c(10);let n,r,o,s;return t[0]!==e.left?(n=I.jsx("div",{className:"flex-1 flex item-center gap-2",children:e.left}),t[0]=e.left,t[1]=n):n=t[1],t[2]!==e.center?(r=I.jsx("div",{className:"flex-1 flex item-center gap-2 justify-center",children:e.center}),t[2]=e.center,t[3]=r):r=t[3],t[4]!==e.right?(o=I.jsx("div",{className:"flex-1 flex item-center gap-2 justify-end",children:e.right}),t[4]=e.right,t[5]=o):o=t[5],t[6]!==n||t[7]!==r||t[8]!==o?(s=I.jsxs("div",{className:"flex items-center gap-2 w-full px-3",children:[n,r,o]}),t[6]=n,t[7]=r,t[8]=o,t[9]=s):s=t[9],s},yI=e=>{const t=j.c(8);if(!e.canCollapse&&!e.isCollapsed)return null;const n=e.isCollapsed?"Expand":"Collapse";let r,o,s;return t[0]!==e.isCollapsed?(r=I.jsx(bI,{isCollapsed:e.isCollapsed}),t[0]=e.isCollapsed,t[1]=r):r=t[1],t[2]!==n||t[3]!==r?(o=I.jsx(it,{content:n,children:r}),t[2]=n,t[3]=r,t[4]=o):o=t[4],t[5]!==e.onClick||t[6]!==o?(s=I.jsx(X,{variant:"text",size:"icon",onClick:e.onClick,children:o}),t[5]=e.onClick,t[6]=o,t[7]=s):s=t[7],s},bI=e=>{const t=j.c(2),{isCollapsed:n}=e;let r;return t[0]!==n?(r=n?I.jsx(Ee,{className:"w-5 h-5 flex-shrink-0"}):I.jsx(Se,{className:"w-5 h-5 flex-shrink-0"}),t[0]=n,t[1]=r):r=t[1],r},xI=o.memo((e=>{const t=j.c(24),{onClick:n,count:r,cellId:o}=e,s=Wn();let i;t[0]!==o||t[1]!==s?(i=Vs(s,o),t[0]=o,t[1]=s,t[2]=i):i=t[2];const a=i;let l,c;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=In("flex items-center justify-between w-[calc(100%-2rem)] h-9 bg-muted rounded-b mx-4 opacity-80 hover:opacity-100 cursor-pointer"),t[3]=l):l=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx(Gs,{className:"w-4 h-4 flex-shrink-0"}),t[4]=c):c=t[4];const d=1===r?"cell":"cells";let u,h,f,p,m,g,y;return t[5]!==r||t[6]!==d?(u=I.jsxs(I.Fragment,{children:[c,I.jsxs("span",{className:"text-sm text-gray-500",children:[r," ",d," collapsed"]})]}),t[5]=r,t[6]=d,t[7]=u):u=t[7],t[8]!==a.errored?(h=a.errored&&I.jsx(it,{content:"Has errors",delayDuration:100,children:I.jsx(hd,{className:"w-4 h-4 flex-shrink-0 text-destructive"})}),t[8]=a.errored,t[9]=h):h=t[9],t[10]!==a.stale?(f=a.stale&&I.jsx(it,{content:"Has stale cells",delayDuration:100,children:I.jsx(Ws,{className:"w-4 h-4 flex-shrink-0 text-[var(--yellow-11)]"})}),t[10]=a.stale,t[11]=f):f=t[11],t[12]!==a.runningOrQueued?(p=a.runningOrQueued&&I.jsx(it,{content:"Running",delayDuration:100,children:I.jsx(Ms,{className:"w-4 h-4 flex-shrink-0 animate-spin"})}),t[12]=a.runningOrQueued,t[13]=p):p=t[13],t[14]!==h||t[15]!==f||t[16]!==p?(m=I.jsxs(I.Fragment,{children:[h,f,p]}),t[14]=h,t[15]=f,t[16]=p,t[17]=m):m=t[17],t[18]!==u||t[19]!==m?(g=I.jsx(gI,{center:u,right:m}),t[18]=u,t[19]=m,t[20]=g):g=t[20],t[21]!==n||t[22]!==g?(y=I.jsx("div",{onClick:n,className:l,children:g}),t[21]=n,t[22]=g,t[23]=y):y=t[23],y}));xI.displayName="CollapsedCellBanner";const vI=e=>{const t=j.c(6),{appClosed:n,status:r}=e,o=sf("running"===r);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=Bt("global.interrupt"),t[0]=s):s=t[0];const i=n||!o,a=o?qs:Kn.NOOP,l=o?"stale":"disabled";let c,d;return t[1]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx(E,{strokeWidth:1.5}),t[1]=c):c=t[1],t[2]!==i||t[3]!==a||t[4]!==l?(d=I.jsx(ux,{tooltip:s,disabled:i,onClick:a,variant:l,"data-testid":"run-button",children:c}),t[2]=i,t[3]=a,t[4]=l,t[5]=d):d=t[5],d},wI={width:void 0,height:void 0};function kI(e,t,n){return e[t]?Array.isArray(e[t])?e[t][0][n]:e[t][n]:"contentBoxSize"===t?e.contentRect["inlineSize"===n?"width":"height"]:void 0}const SI=e=>{const t=j.c(27),{edited:n,appClosed:r,status:o,cellConfig:s,needsRun:i,hasOutput:a,hasConsoleOutput:l,onRun:c,cellActionDropdownRef:d,cellId:u,getEditorView:h,name:f}=e,p=!i&&"hover-action";let m;t[0]!==p?(m=In(p),t[0]=p,t[1]=m):m=t[1];const g=r?Kn.NOOP:c;let y,b,x,v,w;return t[2]!==r||t[3]!==s||t[4]!==n||t[5]!==i||t[6]!==o||t[7]!==g?(y=I.jsx(fx,{edited:n,onClick:g,appClosed:r,status:o,config:s,needsRun:i}),t[2]=r,t[3]=s,t[4]=n,t[5]=i,t[6]=o,t[7]=g,t[8]=y):y=t[8],t[9]!==r||t[10]!==o?(b=I.jsx(vI,{status:o,appClosed:r}),t[9]=r,t[10]=o,t[11]=b):b=t[11],t[12]===Symbol.for("react.memo_cache_sentinel")?(x=I.jsx(ux,{variant:"green",tooltip:null,"data-testid":"cell-actions-button",children:I.jsx(Jl,{strokeWidth:1.5})}),t[12]=x):x=t[12],t[13]!==d||t[14]!==s||t[15]!==u||t[16]!==h||t[17]!==l||t[18]!==a||t[19]!==f||t[20]!==o?(v=I.jsx(Hw,{ref:d,cellId:u,status:o,getEditorView:h,name:f,config:s,hasOutput:a,hasConsoleOutput:l,children:x}),t[13]=d,t[14]=s,t[15]=u,t[16]=h,t[17]=l,t[18]=a,t[19]=f,t[20]=o,t[21]=v):v=t[21],t[22]!==m||t[23]!==y||t[24]!==b||t[25]!==v?(w=I.jsxs(hx,{className:m,children:[y,b,v]}),t[22]=m,t[23]=y,t[24]=b,t[25]=v,t[26]=w):w=t[26],w},CI=o.memo(o.forwardRef((({theme:e,showPlaceholder:t,allowFocus:n,id:r,code:s,output:i,consoleOutputs:a,status:l,runStartTimestamp:c,lastRunStartTimestamp:d,runElapsedTimeMs:u,edited:h,interrupted:f,errored:p,stopped:m,staleInputs:g,serializedEditorState:y,mode:b,debuggerActive:x,appClosed:v,canDelete:k,updateCellCode:S,prepareForRun:C,createNewCell:E,deleteCell:N,focusCell:j,moveCell:_,setStdinResponse:A,moveToNextCell:T,updateCellConfig:M,clearSerializedEditorState:D,sendToBottom:O,sendToTop:R,collapseCell:P,expandCell:L,userConfig:z,outline:F,isCollapsed:U,collapseCount:$,config:H,canMoveX:V,name:q},Y)=>{w.debug("Rendering Cell",r);const X=o.useRef(null),J=o.useRef(null),K=o.useRef(null),Z=ae(du),[Q,ee]=o.useState(!1),[te,ne]=o.useState(),re=H.disabled||"disabled-transitively"===l,oe=oi({executionTime:u,status:l,errored:p,interrupted:f,stopped:m}),se=h||f||g&&!re,ie="running"===l||"queued"===l,le=Ys({status:l,output:i,runStartTimestamp:c,interrupted:f,staleInputs:g},h),ce=("queued"===l||h||g)&&!f,de="edit"===b,ue=o.useCallback((()=>{const e=Cb(K),t=W(e);return"markdown"!==eo(e)&&Xs(e),C({cellId:r}),t}),[r,K,C]);o.useImperativeHandle(Y,(()=>({get editorView(){return Cb(K)},registerRun:ue})),[K,ue]);const he=o.useCallback((()=>K.current),[K]),fe=B((async()=>{if(ie)return;const e=ue();await G({cellIds:[r],codes:[e]}).catch((e=>{w.error("Error running cell",e)}))})),pe=o.useCallback(((e={})=>E({cellId:r,before:!1,...e})),[r,E]),me=o.useCallback(((e={})=>E({cellId:r,before:!0,...e})),[r,E]),ge=o.useCallback((e=>{null===X.current||X.current.contains(e.relatedTarget)||null===K.current||Xs(K.current)}),[]),ye=o.useCallback((e=>{if(X.current===document.activeElement&&null!==K.current&&"active"===lr(K.current.state)){for(const t of Js)if(e.key===t.key&&t.run){t.run(K.current),e.preventDefault(),e.stopPropagation();break}K.current.focus()}}),[X,K]),be=!H.hide_code||Q,xe="markdown"===te,ve=xe&&!be,we=o.useRef(null),ke=Ks(F),[Se,Ce]=o.useState(!1),[Ee,Ne]=o.useState(!1);!function(e){const{ref:t,box:n="content-box",skip:r}=e,s=o.useRef({...wI}),i=o.useRef(void 0);i.current=e.onResize,o.useEffect((()=>{if(!t.current||r)return;if("undefined"==typeof window||!("ResizeObserver"in window))return;const e=new ResizeObserver((([e])=>{const t="border-box"===n?"borderBoxSize":"device-pixel-content-box"===n?"devicePixelContentBoxSize":"contentBoxSize",r=kI(e,t,"inlineSize"),o=kI(e,t,"blockSize");if(s.current.width!==r||s.current.height!==o){const e={width:r,height:o};s.current.width=r,s.current.height=o,i.current&&i.current(e)}}));return e.observe(t.current,{box:n}),()=>{e.disconnect()}}),[n,t,r])}({ref:we,skip:!xe,onResize:e=>{const t=e.height&&e.height<68,n=ve&&(t||"below"===De);Ce(n),ke&&n?Ne(!0):Ee&&Ne(!1)}});const je=o.useRef(null),Ie=o.useCallback((()=>{var e,t;if(!be){ee(!0),null==(e=K.current)||e.focus();const n=null==(t=je.current)?void 0:t.parentElement,r=()=>{requestAnimationFrame((()=>{var e;(null==n?void 0:n.contains(document.activeElement))||(ee(!1),null==(e=K.current)||e.dom.blur(),null==n||n.removeEventListener("focusout",r))}))};null==n||n.addEventListener("focusout",r)}}),[be,K]),Ae=()=>{ve&&Ie()},Te=!Zs(i),Me=a.length>0,De=z.display.cell_output,Oe=Te&&"above"===De,Re=Te&&"below"===De,Pe=e=>I.jsx(Hs,{tooltip:"Edit markdown",className:In("z-20 relative",e),onClick:Ie}),Le=Te&&I.jsxs("div",{className:"relative",onDoubleClick:Ae,children:[I.jsx("div",{className:"absolute top-5 -left-8 z-10 print:hidden",children:I.jsx(yI,{isCollapsed:U,onClick:()=>{U?L({cellId:r}):P({cellId:r})},canCollapse:ke})}),ve&&Re&&Pe("top-3"),I.jsx(Qs,{allowExpand:de,forceExpand:ve,output:i,className:"output-area",cellId:r,stale:le}),ve&&Oe&&Pe("bottom-3")]}),ze=ei("Cell","hover-actions-parent z-10",{published:!de,interactive:de,"needs-run":se,"has-error":p,stopped:m,disabled:H.disabled,stale:"disabled-transitively"===l,borderless:ve&&Te&&de}),Fe=xt.create(r);_l(de?X:null,{"cell.run":fe,"cell.runAndNewBelow":()=>{fe(),T({cellId:r,before:!1})},"cell.runAndNewAbove":()=>{fe(),T({cellId:r,before:!0})},"cell.createAbove":me,"cell.createBelow":pe,"cell.moveUp":()=>_({cellId:r,before:!0}),"cell.moveDown":()=>_({cellId:r,before:!1}),"cell.moveLeft":()=>V?_({cellId:r,direction:"left"}):void 0,"cell.moveRight":()=>V?_({cellId:r,direction:"right"}):void 0,"cell.hideCode":()=>{var e,t,n;const o=!H.hide_code;_e({configs:{[r]:{hide_code:o}}}),M({cellId:r,config:{hide_code:o}}),o?(null==(e=K.current)||e.contentDOM.blur(),null==(t=X.current)||t.focus()):null==(n=K.current)||n.focus()},"cell.focusDown":()=>T({cellId:r,before:!1}),"cell.focusUp":()=>T({cellId:r,before:!0}),"cell.sendToBottom":()=>O({cellId:r}),"cell.sendToTop":()=>R({cellId:r}),"cell.aiCompletion":()=>{let e=!1;Z((t=>(null==t?void 0:t.cellId)===r?(e=!0,null):{cellId:r})),e&&Cb(K).focus()},"cell.cellActions":()=>{var e;null==(e=J.current)||e.toggle()}}),Il(de?X:null,{ArrowDown:e=>(!e||!ot.fromInput(e))&&(T({cellId:r,before:!1,noCreate:!0}),!0),ArrowUp:e=>(!e||!ot.fromInput(e))&&(T({cellId:r,before:!0,noCreate:!0}),!0),Enter:()=>(Ae(),!1),..."vim"!==z.keymap.preset||be?{}:{j:e=>(!e||!ot.fromInput(e))&&(T({cellId:r,before:!1,noCreate:!0}),!0),k:e=>(!e||!ot.fromInput(e))&&(T({cellId:r,before:!0,noCreate:!0}),!0)}});const Be=B((e=>{Z({cellId:r,initialPrompt:e.prompt})}));if(!de){const e=ti(null==i?void 0:i.mimetype);return p||f||m||e?null:I.jsx("div",{tabIndex:-1,id:Fe,ref:X,className:ze,"data-cell-id":r,"data-cell-name":q,children:Le})}const Ue=I.jsx(yx,{status:l,staleInputs:g,interrupted:f,editing:de,edited:h,disabled:H.disabled??!1,elapsedTime:u,runStartTimestamp:c,uninstantiated:oe,lastRunStartTimestamp:d});return I.jsx(ni,{children:I.jsx(Gw,{cellId:r,config:H,status:l,getEditorView:he,hasOutput:Te,hasConsoleOutput:Me,name:q,children:I.jsxs(Uw,{tabIndex:-1,ref:X,"data-status":l,onBlur:ge,onKeyDown:ye,cellId:r,canMoveX:V,title:H.disabled?"This cell is disabled":"disabled-transitively"===l?"This cell has a disabled ancestor":void 0,children:[I.jsxs("div",{className:ze,id:Fe,ref:we,"data-cell-id":r,"data-cell-name":q,children:["above"===De&&Le,I.jsxs("div",{className:In("tray"),"data-hidden":ve,children:[I.jsx("div",{className:"absolute right-2 -top-4 z-10",children:I.jsx(SI,{edited:h,appClosed:v,status:l,cellConfig:H,needsRun:se,hasOutput:Te,hasConsoleOutput:Me,cellActionDropdownRef:J,cellId:r,name:q,getEditorView:he,onRun:fe})}),I.jsxs("div",{className:In("absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-20",ve&&Oe&&"-top-7",ve&&Re&&"-bottom-8",ve&&Ee&&"-left-[3.8rem]"),children:[I.jsx(lx,{tooltipContent:Bt("cell.createAbove"),appClosed:v,onClick:v?void 0:me}),I.jsx("div",{className:"flex-1"}),I.jsx(lx,{tooltipContent:Bt("cell.createBelow"),appClosed:v,onClick:v?void 0:pe})]}),I.jsx(mI,{theme:e,showPlaceholder:t,allowFocus:n,id:r,code:s,config:H,status:l,serializedEditorState:y,runCell:fe,updateCellCode:S,setEditorView:e=>{K.current=e},createNewCell:E,deleteCell:N,focusCell:j,moveCell:_,moveToNextCell:T,updateCellConfig:M,clearSerializedEditorState:D,userConfig:z,editorViewRef:K,editorViewParentRef:je,hidden:!be,hasOutput:Te,temporarilyShowCode:Ie,languageAdapter:te,setLanguageAdapter:ne}),I.jsxs("div",{className:In("shoulder-right z-20",ve&&"below"===De&&"top-14"),children:[!Se&&Ue,I.jsxs("div",{className:"flex gap-2 items-end",children:[I.jsx(Bw,{}),Se&&Ue]})]}),I.jsx("div",{className:"shoulder-bottom hover-action",children:k&&be&&I.jsx(px,{appClosed:v,status:l,onClick:()=>{ie||v||N({cellId:r})}})})]}),"below"===De&&Le,I.jsx(Kl,{consoleOutputs:a,stale:ce,cellName:q,onRefactorWithAI:Be,onSubmitDebugger:(e,t)=>{A({cellId:r,response:e,outputIndex:t}),ri({text:e})},cellId:r,debuggerActive:x})]}),U&&I.jsx(xI,{onClick:()=>L({cellId:r}),count:$,cellId:r})]})})})}))),EI=e=>{const t=j.c(10),{width:n}=e,{banners:r}=Zl(),{removeBanner:o}=Ql();if(0===r.length)return null;const s="columns"===n&&"sticky left-12 w-full max-w-[80vw]";let i,a,l;if(t[0]!==s?(i=In("flex flex-col gap-4 mb-5 print:hidden",s),t[0]=s,t[1]=i):i=t[1],t[2]!==r||t[3]!==o){let e;t[5]!==o?(e=e=>I.jsxs(si,{kind:e.variant||"info",className:"flex flex-col rounded p-3",children:[I.jsxs("div",{className:"flex justify-between",children:[I.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[I.jsx(ii,{className:"w-5 h-5 inline-block mr-2"}),e.title]}),I.jsx(X,{"data-testid":"remove-banner-button",variant:"text",size:"icon",onClick:()=>o(e.id),children:I.jsx(Cn,{className:"w-5 h-5"})})]}),I.jsxs("div",{className:"flex justify-between items-end",children:[I.jsx("span",{children:ai({html:e.description})}),"restart"===e.action&&I.jsx(NI,{})]})]},e.id),t[5]=o,t[6]=e):e=t[6],a=r.map(e),t[2]=r,t[3]=o,t[4]=a}else a=t[4];return t[7]!==i||t[8]!==a?(l=I.jsx("div",{className:i,children:a}),t[7]=i,t[8]=a,t[9]=l):l=t[9],l},NI=()=>{const e=j.c(3),t=Lu();let n,r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=I.jsx(wd,{className:"w-3 h-3 mr-2"}),e[0]=n):n=e[0],e[1]!==t?(r=I.jsxs(X,{"data-testid":"restart-session-button",variant:"link",size:"xs",onClick:t,children:[n,"Restart"]}),e[1]=t,e[2]=r):r=e[2],r};const jI=(e,t)=>function(e,t){const n=/^(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/,r=e=>{const t=e.match(n);if(!t)return null;const[,r,o,s,i]=t;return{major:Number.parseInt(r,10),minor:Number.parseInt(o,10),patch:Number.parseInt(s,10),preRelease:i||""}};try{const n=r(e),o=r(t);return n&&o?n.major!==o.major?n.major-o.major:n.minor!==o.minor?n.minor-o.minor:n.patch!==o.patch?n.patch-o.patch:""===n.preRelease&&""!==o.preRelease?1:""!==n.preRelease&&""===o.preRelease?-1:n.preRelease.localeCompare(o.preRelease):e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}catch{return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}}(t,e);const _I=()=>{const e=j.c(66),{packageAlert:t}=ec(),{clearPackageAlert:n}=tc(),[r]=Re();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const[i,a]=o.useState(s);if(null===t)return null;const l="pixi"!==r.package_management.manager;if(nc(t)){let o,s,c,d,u,h,f,p,m,g;if(e[1]===Symbol.for("react.memo_cache_sentinel")?(o=I.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[I.jsx(pd,{className:"w-5 h-5 inline-block mr-2"}),"Missing packages"]}),e[1]=o):o=e[1],e[2]!==n||e[3]!==t.id?(s=()=>n(t.id),e[2]=n,e[3]=t.id,e[4]=s):s=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx(Cn,{className:"w-5 h-5"}),e[5]=c):c=e[5],e[6]!==s?(d=I.jsxs("div",{className:"flex justify-between",children:[o,I.jsx(X,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:s,children:c})]}),e[6]=s,e[7]=d):d=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(u=I.jsx("p",{children:"The following packages were not found:"}),e[8]=u):u=e[8],e[9]!==i||e[10]!==l||e[11]!==t.packages){let n;e[13]!==i||e[14]!==l?(n=(e,t)=>I.jsxs("li",{className:"flex items-center gap-1 font-mono text-sm",children:[I.jsx(Dc,{size:"1rem"}),e,l&&I.jsx(MI,{value:i[e]??"latest",onChange:t=>a((n=>({...n,[e]:t}))),packageName:e})]},t),e[13]=i,e[14]=l,e[15]=n):n=e[15],h=t.packages.map(n),e[9]=i,e[10]=l,e[11]=t.packages,e[12]=h}else h=e[12];return e[16]!==h?(f=I.jsxs("div",{children:[u,I.jsx("ul",{className:"list-disc ml-4 mt-1",children:h})]}),e[16]=h,e[17]=f):f=e[17],e[18]!==n||e[19]!==i||e[20]!==t.id||e[21]!==t.isolated||e[22]!==t.packages||e[23]!==r.package_management.manager?(p=I.jsx("div",{className:"ml-auto flex flex-row items-baseline",children:t.isolated?I.jsxs(I.Fragment,{children:[I.jsx(AI,{manager:r.package_management.manager,packages:t.packages,versions:i,clearPackageAlert:()=>n(t.id)}),!_()&&I.jsxs(I.Fragment,{children:[I.jsx("span",{className:"px-2 text-sm",children:"with"})," ",I.jsx(TI,{})]})]}):I.jsxs("p",{children:["If you set up a"," ",I.jsx("a",{href:"https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments",className:"text-accent-foreground hover:underline",target:"_blank",rel:"noreferrer",children:"virtual environment"}),", marimo can install these packages for you."]})}),e[18]=n,e[19]=i,e[20]=t.id,e[21]=t.isolated,e[22]=t.packages,e[23]=r.package_management.manager,e[24]=p):p=e[24],e[25]!==f||e[26]!==p?(m=I.jsxs("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:[f,p]}),e[25]=f,e[26]=p,e[27]=m):m=e[27],e[28]!==d||e[29]!==m?(g=I.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:I.jsxs(si,{kind:"danger",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left",children:[d,m]})}),e[28]=d,e[29]=m,e[30]=g):g=e[30],g}if(rc(t)){let r;e[31]!==t.packages?(r=function(e){const t=new Set(Object.values(e)),n=t.has("queued")||t.has("installing")?"installing":t.has("failed")?"failed":"installed";if("installing"===n)return{status:"installing",title:"Installing packages",titleIcon:I.jsx(Uc,{className:"w-5 h-5 inline-block mr-2"}),description:"Installing packages:"};if("installed"===n)return{status:"installed",title:"All packages installed!",titleIcon:I.jsx(fd,{className:"w-5 h-5 inline-block mr-2"}),description:"Installed packages:"};return{status:"failed",title:"Some packages failed to install",titleIcon:I.jsx(pd,{className:"w-5 h-5 inline-block mr-2"}),description:"See terminal for error logs."}}(t.packages),e[31]=t.packages,e[32]=r):r=e[32];const{status:o,title:s,titleIcon:i,description:a}=r;"installed"===o&&setTimeout((()=>n(t.id)),1e4);const l="failed"===o?"danger":"info";let c,d,u,h,f;e[33]!==s||e[34]!==i?(c=I.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[i,s]}),e[33]=s,e[34]=i,e[35]=c):c=e[35],e[36]!==n||e[37]!==t.id?(d=()=>n(t.id),e[36]=n,e[37]=t.id,e[38]=d):d=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(u=I.jsx(Cn,{className:"w-5 h-5"}),e[39]=u):u=e[39],e[40]!==d?(h=I.jsx(X,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:d,children:u}),e[40]=d,e[41]=h):h=e[41],e[42]!==c||e[43]!==h?(f=I.jsxs("div",{className:"flex justify-between",children:[c,h]}),e[42]=c,e[43]=h,e[44]=f):f=e[44];const p="installed"===o&&"text-accent-foreground";let m,g,y,b,x,v,w;if(e[45]!==p?(m=In("flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",p),e[45]=p,e[46]=m):m=e[46],e[47]!==a?(g=I.jsx("p",{children:a}),e[47]=a,e[48]=g):g=e[48],e[49]!==t.packages||e[50]!==o){let n;e[52]!==o?(n=(e,t)=>{const[n,r]=e;return I.jsxs("li",{className:In("flex items-center gap-1 font-mono text-sm","installing"===r&&"font-semibold","failed"===r&&"text-destructive","installed"===r&&"text-accent-foreground","installed"===r&&"failed"===o&&"text-muted-foreground"),children:[I.jsx(II,{status:r}),n]},t)},e[52]=o,e[53]=n):n=e[53],y=Object.entries(t.packages).map(n),e[49]=t.packages,e[50]=o,e[51]=y}else y=e[51];return e[54]!==y?(b=I.jsx("ul",{className:"list-disc ml-4 mt-1",children:y}),e[54]=y,e[55]=b):b=e[55],e[56]!==g||e[57]!==b?(x=I.jsxs("div",{children:[g,b]}),e[56]=g,e[57]=b,e[58]=x):x=e[58],e[59]!==x||e[60]!==m?(v=I.jsx("div",{className:m,children:x}),e[59]=x,e[60]=m,e[61]=v):v=e[61],e[62]!==v||e[63]!==l||e[64]!==f?(w=I.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:I.jsxs(si,{kind:l,className:"flex flex-col rounded pt-3 pb-4 px-5",children:[f,v]})}),e[62]=v,e[63]=l,e[64]=f,e[65]=w):w=e[65],w}return C(t),null};const II=e=>{const t=j.c(4),{status:n}=e;switch(n){case"queued":{let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx(Dc,{size:"1rem"}),t[0]=e):e=t[0],e}case"installing":{let e;return t[1]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx(Uc,{size:"1rem"}),t[1]=e):e=t[1],e}case"installed":{let e;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx($t,{size:"1rem"}),t[2]=e):e=t[2],e}case"failed":{let e;return t[3]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx(Cn,{size:"1rem"}),t[3]=e):e=t[3],e}default:return C(n),null}},AI=e=>{const t=j.c(9),{manager:n,packages:r,versions:o,clearPackageAlert:s}=e;let i,a,l,c;return t[0]!==s||t[1]!==n||t[2]!==r||t[3]!==o?(i=async()=>{s();const e={...o};for(const t of r)e[t]=e[t]??"";await gi({manager:n,versions:e}).catch(DI)},t[0]=s,t[1]=n,t[2]=r,t[3]=o,t[4]=i):i=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(a=I.jsx(Uc,{className:"w-4 h-4 mr-2"}),l=I.jsx("span",{className:"font-semibold",children:"Install"}),t[5]=a,t[6]=l):(a=t[5],l=t[6]),t[7]!==i?(c=I.jsxs(X,{variant:"outline","data-testid":"install-packages-button",size:"sm",onClick:i,children:[a,l]}),t[7]=i,t[8]=c):c=t[8],c},TI=()=>{const e=j.c(16),[t,n]=Re();let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=At(li),e[0]=r):r=e[0],e[1]!==t?(o={resolver:r,defaultValues:t},e[1]=t,e[2]=o):o=e[2];const s=Tt(o);let i;e[3]!==n?(i=async e=>{await S({config:e}).then((()=>{n(e)}))},e[3]=n,e[4]=i):i=e[4];const a=i;let l,c,d,u;return e[5]!==s||e[6]!==a?(l=s.handleSubmit(a),e[5]=s,e[6]=a,e[7]=l):l=e[7],e[8]!==s.control?(c=I.jsx("div",{className:"flex flex-col gap-3",children:I.jsx(ci,{control:s.control,name:"package_management.manager",render:RI})}),e[8]=s.control,e[9]=c):c=e[9],e[10]!==l||e[11]!==c?(d=I.jsx("form",{onChange:l,className:"flex flex-col gap-5",children:c}),e[10]=l,e[11]=c,e[12]=d):d=e[12],e[13]!==s||e[14]!==d?(u=I.jsx(di,{...s,children:d}),e[13]=s,e[14]=d,e[15]=u):u=e[15],u},MI=e=>{const t=j.c(21),{value:n,onChange:r,packageName:o}=e;let s,i;t[0]!==o?(s=async()=>{const e=await fetch(`https://pypi.org/pypi/${t=o,t.replaceAll(/\[.*]/g,"").trim()}/json`,{method:"GET",signal:AbortSignal.timeout(5e3)});var t;const n=await e.json();return["latest",...Object.keys(n.releases).sort(jI).slice(0,100)]},i=[o],t[0]=o,t[1]=s,t[2]=i):(s=t[1],i=t[2]);const{data:a,loading:l,error:c}=jn(s,i);let d;t[3]!==a?(d=void 0===a?[]:a,t[3]=a,t[4]=d):d=t[4];const u=d;if(c){let e,o,s;return t[5]!==r?(e=e=>r(e.target.value),t[5]=r,t[6]=e):e=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(o=I.jsx("option",{value:"latest",children:"latest"}),t[7]=o):o=t[7],t[8]!==e||t[9]!==n?(s=I.jsx(it,{content:"Failed to fetch package versions",children:I.jsx(fi,{value:n,onChange:e,disabled:!0,className:"inline-flex ml-2",children:o})}),t[8]=e,t[9]=n,t[10]=s):s=t[10],s}let h,f,p;return t[11]!==r?(h=e=>r(e.target.value),t[11]=r,t[12]=h):h=t[12],t[13]!==u||t[14]!==l?(f=l?I.jsx("option",{value:"latest",children:"latest"}):u.map(PI),t[13]=u,t[14]=l,t[15]=f):f=t[15],t[16]!==l||t[17]!==h||t[18]!==f||t[19]!==n?(p=I.jsx(fi,{value:n,onChange:h,disabled:l,className:"inline-flex ml-2",children:f}),t[16]=l,t[17]=h,t[18]=f,t[19]=n,t[20]=p):p=t[20],p};function DI(e){w.error(e)}function OI(e){return I.jsx("option",{value:e,children:e},e)}function RI(e){const{field:t}=e;return I.jsxs(ui,{children:[I.jsx(hi,{children:I.jsx(fi,{"data-testid":"install-package-manager-select",onChange:e=>t.onChange(e.target.value),value:t.value,disabled:t.disabled,className:"inline-flex mr-2",children:pi.map(OI)})}),I.jsx(mi,{})]})}function PI(e){return I.jsx("option",{value:e,children:e},e)}const LI=e=>{let{transform:t}=e;return{...t,x:0}},zI={threshold:{x:0,y:.1}},FI=u.memo((e=>{const t=j.c(23),{children:n,multiColumn:r}=e,{dropCellOverCell:s,dropCellOverColumn:i,moveColumn:a,compactColumns:l}=U(),[c,d]=o.useState(null),[u,h]=o.useState(null),[f]=Pe();let p;e:{if("columns"===f.width){p=yi.EMPTY;break e}let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[LI],t[0]=e):e=t[0],p=e}const m=p;let g,y;t[1]===Symbol.for("react.memo_cache_sentinel")?(g={activationConstraint:{distance:8}},t[1]=g):g=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(y={coordinateGetter:Pw},t[2]=y):y=t[2];const b=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return o.useMemo((()=>[...t].filter((e=>null!=e))),[...t])}(Mx(jv,g),Mx(kv,y));let x;t[3]===Symbol.for("react.memo_cache_sentinel")?(x=e=>{d(e.active.id);const t=H();h(t.cellIds)},t[3]=x):x=t[3];const v=B(x);let w;t[4]!==u?(w=()=>{d(null),h(null)},t[4]=u,t[5]=w):w=t[5];const k=B(w);let S;t[6]!==c?(S=e=>{const t=e.droppableContainers.filter($I);if(c&&UI(c))return Bx({...e,droppableContainers:t});const n=(e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];const o=[];for(const s of t){const{id:e}=s,t=n.get(e);if(t&&Hx(r,t)){const n=Lx(t).reduce(((e,t)=>e+Ox(r,t)),0),i=Number((n/4).toFixed(4));o.push({id:e,data:{droppableContainer:s,value:i}})}}return o.sort(Rx)})({...e,droppableContainers:t}),r=zx(n.length>0?n:$x({...e,droppableContainers:t}),"id");if(!r)return[];fn(UI(r),`Expected column id. Got: ${r}`);const o=H().cellIds.get(r);if(fn(o,`Expected column. Got: ${r}`),o&&0===o.topLevelIds.length)return[{id:r}];const s=new Set(o.topLevelIds),i=Bx({...e,droppableContainers:e.droppableContainers.filter((e=>e.id!==r&&s.has(e.id)))});if(i.length>0){const e=i[0].id;return fn(BI(e),`Expected cell id. Got: ${e}`),[{id:e}]}return[]},t[6]=c,t[7]=S):S=t[7];const C=S;let E;t[8]!==s||t[9]!==i||t[10]!==a?(E=e=>{const{active:t,over:n}=e,r=null==n?void 0:n.id;if(null!=r&&t.id!==r){if(BI(t.id)){if(UI(r))return void i({cellId:t.id,columnId:r});if(BI(r))return void s({cellId:t.id,overCellId:r})}UI(t.id)&&UI(r)&&a({column:t.id,overColumn:r})}},t[8]=s,t[9]=i,t[10]=a,t[11]=E):E=t[11];const N=B(E);let _;t[12]!==l?(_=e=>{const{active:t,over:n}=e;null!==n&&t.id!==n.id&&l()},t[12]=l,t[13]=_):_=t[13];const A=B(_),T=r?C:Bx;let M;return t[14]!==n||t[15]!==k||t[16]!==A||t[17]!==N||t[18]!==v||t[19]!==m||t[20]!==b||t[21]!==T?(M=I.jsx(uw,{autoScroll:zI,sensors:b,collisionDetection:T,modifiers:m,onDragEnd:A,onDragStart:v,onDragCancel:k,onDragOver:N,children:n}),t[14]=n,t[15]=k,t[16]=A,t[17]=N,t[18]=v,t[19]=m,t[20]=b,t[21]=T,t[22]=M):M=t[22],M}));function BI(e){return"string"==typeof e&&!e.startsWith("tree_")}function UI(e){return"string"==typeof e&&e.startsWith("tree_")}function $I(e){return UI(e.id)}const HI=u.forwardRef(((e,t)=>{const n=j.c(62);let r,o,s,i,a,l;n[0]!==e?(({columnId:i,canDelete:r,canMoveLeft:o,canMoveRight:s,...a}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s,n[4]=i,n[5]=a):(r=n[1],o=n[2],s=n[3],i=n[4],a=n[5]),n[6]!==i?(l={id:i},n[6]=i,n[7]=l):l=n[7];const{attributes:c,listeners:d,setNodeRef:u,transform:h,transition:f,isDragging:p,isOver:m}=Dw(l);let g;n[8]!==h?(g=h?ls.Transform.toString({x:h.x,y:0,scaleX:1,scaleY:1}):void 0,n[8]=h,n[9]=g):g=n[9];const y=p?2:void 0;let b;n[10]!==g||n[11]!==y||n[12]!==f?(b={transform:g,transition:f,zIndex:y,position:"relative","--gutter-width":"50px"},n[10]=g,n[11]=y,n[12]=f,n[13]=b):b=n[13];const x=b,{deleteColumn:v,moveColumn:w,addColumn:k}=U();let S;n[14]===Symbol.for("react.memo_cache_sentinel")?(S=In("h-full hover:bg-muted rounded-none"),n[14]=S):S=n[14];const C=S,E=WI;let N;n[15]!==i||n[16]!==w?(N=()=>w({column:i,overColumn:"_left_"}),n[15]=i,n[16]=w,n[17]=N):N=n[17];const _=!o;let A,T,M;n[18]===Symbol.for("react.memo_cache_sentinel")?(A=I.jsx(Ce,{className:"size-4"}),n[18]=A):A=n[18],n[19]!==N||n[20]!==_?(T=I.jsx(it,{content:"Move column left",side:"top",delayDuration:300,children:I.jsx(X,{variant:"text",size:"sm",className:C,onClick:N,disabled:_,children:A})}),n[19]=N,n[20]=_,n[21]=T):T=n[21],n[22]!==i||n[23]!==w?(M=()=>w({column:i,overColumn:"_right_"}),n[22]=i,n[23]=w,n[24]=M):M=n[24];const D=!s;let O,R,P,L,z,F,B,$;n[25]===Symbol.for("react.memo_cache_sentinel")?(O=I.jsx(Ee,{className:"size-4"}),n[25]=O):O=n[25],n[26]!==M||n[27]!==D?(R=I.jsx(it,{content:"Move column right",side:"top",delayDuration:300,children:I.jsx(X,{variant:"text",size:"sm",className:C,onClick:M,disabled:D,children:O})}),n[26]=M,n[27]=D,n[28]=R):R=n[28],n[29]!==c||n[30]!==d?(P=I.jsx("div",{className:"flex gap-2 h-full flex-grow active:bg-accent cursor-grab",...c,...d,"data-testid":"column-drag-button"}),n[29]=c,n[30]=d,n[31]=P):P=n[31],n[32]!==r||n[33]!==i||n[34]!==v?(L=r&&I.jsx(it,{content:"Delete column",side:"top",delayDuration:300,children:I.jsx(X,{variant:"text",size:"sm",className:"opacity-0 group-hover:opacity-70 group-hover:hover:opacity-100 text-destructive h-full hover:bg-destructive/20 rounded-none",onClick:()=>v({columnId:i}),children:I.jsx(Cn,{className:"size-4"})})}),n[32]=r,n[33]=i,n[34]=v,n[35]=L):L=n[35],n[36]!==k||n[37]!==i?(z=()=>{k({columnId:i}),requestAnimationFrame(E)},n[36]=k,n[37]=i,n[38]=z):z=n[38],n[39]===Symbol.for("react.memo_cache_sentinel")?(F=I.jsx(Oo,{className:"size-4"}),n[39]=F):F=n[39],n[40]!==z?(B=I.jsx(it,{content:"Add column",side:"top",delayDuration:300,children:I.jsx(X,{variant:"text",size:"sm",className:C,onClick:z,children:F})}),n[40]=z,n[41]=B):B=n[41],n[42]!==R||n[43]!==P||n[44]!==L||n[45]!==B||n[46]!==T?($=I.jsxs("div",{className:"h-6 group flex items-center rounded-t-lg border hover:border-border border-[var(--slate-3)] overflow-hidden bg-[var(--slate-1)]",children:[T,R,P,L,B]}),n[42]=R,n[43]=P,n[44]=L,n[45]=B,n[46]=T,n[47]=$):$=n[47];const H=$;let V;n[48]!==t||n[49]!==u?(V=e=>{zw(t,u)(e)},n[48]=t,n[49]=u,n[50]=V):V=n[50];const W=p?"":a.className,G=p?"z-20":"z-1 hover:z-10 focus-within:z-10",q=m&&"bg-accent/20";let Y,J;return n[51]!==W||n[52]!==G||n[53]!==q?(Y=In(W,G,q),n[51]=W,n[52]=G,n[53]=q,n[54]=Y):Y=n[54],n[55]!==H||n[56]!==p||n[57]!==a||n[58]!==x||n[59]!==V||n[60]!==Y?(J=I.jsxs("div",{tabIndex:-1,ref:V,...a,style:x,"data-is-dragging":p,className:Y,children:[H,a.children]}),n[55]=H,n[56]=p,n[57]=a,n[58]=x,n[59]=V,n[60]=Y,n[61]=J):J=n[61],J}));HI.displayName="SortableColumn";const VI=o.memo(HI);function WI(){const e=document.getElementById("App");e&&e.scrollTo({left:e.scrollLeft+1e3,behavior:"smooth"})}const GI=o.memo((e=>{const t=j.c(15),n=o.useRef(null),r="columns"===e.width&&"w-contentWidth box-content min-h-[100px] px-11 py-6";let s,i;t[0]!==r?(s=In("flex flex-col gap-5",r),t[0]=r,t[1]=s):s=t[1],t[2]!==e.children||t[3]!==s?(i=I.jsx("div",{className:s,children:e.children}),t[2]=e.children,t[3]=s,t[4]=i):i=t[4];const a=i;if("columns"===e.width){let r;return t[5]!==a||t[6]!==e.canDelete||t[7]!==e.canMoveLeft||t[8]!==e.canMoveRight||t[9]!==e.columnId||t[10]!==e.footer?(r=I.jsxs(VI,{tabIndex:-1,ref:n,canDelete:e.canDelete,columnId:e.columnId,canMoveLeft:e.canMoveLeft,canMoveRight:e.canMoveRight,className:"group/column",children:[a,e.footer]}),t[5]=a,t[6]=e.canDelete,t[7]=e.canMoveLeft,t[8]=e.canMoveRight,t[9]=e.columnId,t[10]=e.footer,t[11]=r):r=t[11],r}let l;return t[12]!==a||t[13]!==e.footer?(l=I.jsxs(I.Fragment,{children:[a,e.footer]}),t[12]=a,t[13]=e.footer,t[14]=l):l=t[14],l}));GI.displayName="Column";const qI=e=>{const t=j.c(8),n=se(bi),r="columns"===e.appConfig.width;let o,s,i;return t[0]!==e?(o=I.jsx(YI,{...e}),t[0]=e,t[1]=o):o=t[1],t[2]!==n||t[3]!==o?(s=I.jsx(Nw,{id:"column-container",items:n,strategy:vw,children:o}),t[2]=n,t[3]=o,t[4]=s):s=t[4],t[5]!==r||t[6]!==s?(i=I.jsx(FI,{multiColumn:r,children:s}),t[5]=r,t[6]=s,t[7]=i):i=t[7],i},YI=e=>{const t=j.c(47),{mode:n,userConfig:r,appConfig:s,connStatus:i}=e,a=Wn(),l=U(),{theme:c}=Oe(),{toggleSidebarPanel:d}=Vu(),{invisible:u}=oc(a.cellIds.idLength,n);let h;yl("global.focusTop",l.focusTopCell),yl("global.focusBottom",l.focusBottomCell),yl("global.toggleSidebar",d),yl("global.foldCode",l.foldAll),yl("global.unfoldCode",l.unfoldAll),t[0]!==l.updateCellCode?(h=()=>{Xn(l.updateCellCode)},t[0]=l.updateCellCode,t[1]=h):h=t[1],yl("global.formatAll",h),yl("cell.hideCode",Kn.NOOP),yl("cell.format",Kn.NOOP);const f=mu(),p=l.scrollToTarget;let m,g,y,b,x,v,w,k,S,C,E,N,_,A;if(t[2]!==a.scrollKey||t[3]!==p?(m=()=>{null!==a.scrollKey&&p()},t[2]=a.scrollKey,t[3]=p,t[4]=m):m=t[4],t[5]!==a.cellIds||t[6]!==a.scrollKey||t[7]!==p?(g=[a.cellIds,a.scrollKey,p],t[5]=a.cellIds,t[6]=a.scrollKey,t[7]=p,t[8]=g):g=t[8],o.useEffect(m,g),t[9]!==l||t[10]!==s||t[11]!==i||t[12]!==u||t[13]!==n||t[14]!==a||t[15]!==f||t[16]!==c||t[17]!==r){const e=a.cellIds.getColumns();let o;t[27]!==a.cellIds?(o=a.cellIds.hasOnlyOneId(),t[27]=a.cellIds,t[28]=o):o=t[28];const d=o;y=sc,k="pb-[40vh]",S=u,C=s,E="pr-4",t[29]===Symbol.for("react.memo_cache_sentinel")?(b=I.jsx(_I,{}),t[29]=b):b=t[29],t[30]!==s.width?(x=I.jsx(EI,{width:s.width}),t[30]=s.width,t[31]=x):x=t[31];const h="columns"===s.width&&"grid grid-flow-col auto-cols-min gap-6";t[32]!==h?(v=In(h),t[32]=h,t[33]=v):v=t[33],w=e.map(((t,o)=>I.jsx(XI,{column:t,index:o,columnsLength:e.length,appConfig:s,notebook:a,mode:n,userConfig:r,connStatus:i,actions:l,theme:c,hasOnlyOneCell:d,invisible:u,onDeleteCell:f},t.id))),t[9]=l,t[10]=s,t[11]=i,t[12]=u,t[13]=n,t[14]=a,t[15]=f,t[16]=c,t[17]=r,t[18]=y,t[19]=b,t[20]=x,t[21]=v,t[22]=w,t[23]=k,t[24]=S,t[25]=C,t[26]=E}else y=t[18],b=t[19],x=t[20],v=t[21],w=t[22],k=t[23],S=t[24],C=t[25],E=t[26];return t[34]!==v||t[35]!==w?(N=I.jsx("div",{className:v,children:w}),t[34]=v,t[35]=w,t[36]=N):N=t[36],t[37]===Symbol.for("react.memo_cache_sentinel")?(_=I.jsx(ic,{}),t[37]=_):_=t[37],t[38]!==y||t[39]!==b||t[40]!==x||t[41]!==N||t[42]!==k||t[43]!==S||t[44]!==C||t[45]!==E?(A=I.jsxs(y,{className:k,invisible:S,appConfig:C,innerClassName:E,children:[b,x,N,_]}),t[38]=y,t[39]=b,t[40]=x,t[41]=N,t[42]=k,t[43]=S,t[44]=C,t[45]=E,t[46]=A):A=t[46],A},XI=e=>{const t=j.c(31),{column:n,index:r,columnsLength:o,appConfig:s,notebook:i,mode:a,userConfig:l,connStatus:c,actions:d,theme:u,hasOnlyOneCell:h,invisible:f,onDeleteCell:p}=e,m=n.id,g=r>0,y=r<o-1,b=s.width,x=o>1,v=n.id,w="columns"===s.width&&"opacity-0 group-hover/column:opacity-100";let k,S;t[0]!==w?(k=In(w),t[0]=w,t[1]=k):k=t[1],t[2]!==n.id||t[3]!==k?(S=I.jsx(JI,{columnId:v,className:k}),t[2]=n.id,t[3]=k,t[4]=S):S=t[4];const C=`column-${r+1}`,E=n.topLevelIds;let N,_,A;return t[5]!==d||t[6]!==s.width||t[7]!==n||t[8]!==c.state||t[9]!==h||t[10]!==f||t[11]!==a||t[12]!==i.cellData||t[13]!==i.cellHandles||t[14]!==i.cellRuntime||t[15]!==p||t[16]!==u||t[17]!==l?(N=n.topLevelIds.map((e=>{const t=i.cellData[e],r=i.cellRuntime[e];return I.jsx(CI,{theme:u,showPlaceholder:h,allowFocus:!f,id:t.id,code:t.code,outline:r.outline,output:r.output,consoleOutputs:r.consoleOutputs,status:r.status,edited:t.edited,interrupted:r.interrupted,errored:r.errored,stopped:r.stopped,staleInputs:r.staleInputs,runStartTimestamp:r.runStartTimestamp,lastRunStartTimestamp:r.lastRunStartTimestamp,runElapsedTimeMs:r.runElapsedTimeMs??t.lastExecutionTime,serializedEditorState:t.serializedEditorState,canDelete:!h,mode:a,appClosed:c.state!==ct.OPEN,ref:i.cellHandles[e],userConfig:l,debuggerActive:r.debuggerActive,config:t.config,name:t.name,isCollapsed:n.isCollapsed(e),collapseCount:n.getCount(e),canMoveX:"columns"===s.width,...d,deleteCell:p},t.id.toString())})),t[5]=d,t[6]=s.width,t[7]=n,t[8]=c.state,t[9]=h,t[10]=f,t[11]=a,t[12]=i.cellData,t[13]=i.cellHandles,t[14]=i.cellRuntime,t[15]=p,t[16]=u,t[17]=l,t[18]=N):N=t[18],t[19]!==n.topLevelIds||t[20]!==C||t[21]!==N?(_=I.jsx(Nw,{id:C,items:E,strategy:Sw,children:N}),t[19]=n.topLevelIds,t[20]=C,t[21]=N,t[22]=_):_=t[22],t[23]!==s.width||t[24]!==n.id||t[25]!==_||t[26]!==g||t[27]!==y||t[28]!==x||t[29]!==S?(A=I.jsx(GI,{columnId:m,canMoveLeft:g,canMoveRight:y,width:b,canDelete:x,footer:S,children:_}),t[23]=s.width,t[24]=n.id,t[25]=_,t[26]=g,t[27]=y,t[28]=x,t[29]=S,t[30]=A):A=t[30],A},JI=e=>{const t=j.c(18),{columnId:n,className:r}=e,{createNewCell:o}=U(),s=se(ce),[i,a]=xi(!1),l=se(le),c=se(vi).sql;let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=In("mb-0 rounded-none sm:px-4 md:px-5 lg:px-8 tracking-wide no-wrap whitespace-nowrap","hover:bg-accent hover:text-accent-foreground font-semibold uppercase text-xs"),t[0]=d):d=t[0];const u=d;let h;t[1]!==l||t[2]!==s||t[3]!==n||t[4]!==o||t[5]!==i||t[6]!==a.toggle||t[7]!==c?(h=()=>i?I.jsx(wi,{onClose:a.toggle}):I.jsxs(I.Fragment,{children:[I.jsxs(X,{className:u,variant:"text",size:"sm",onClick:()=>o({cellId:{type:"__end__",columnId:n},before:!1}),children:[I.jsx(jd,{className:"mr-2 size-4 flex-shrink-0"}),"Python"]}),I.jsxs(X,{className:u,variant:"text",size:"sm",onClick:()=>{yu(s,o),o({cellId:{type:"__end__",columnId:n},before:!1,code:(new Rt).defaultCode})},children:[I.jsx(Ad,{className:"mr-2 size-4 flex-shrink-0"}),"Markdown"]}),I.jsx(it,{content:c?null:I.jsxs("div",{className:"flex flex-col",children:[I.jsxs("span",{children:["Additional dependencies required:",I.jsx(vr,{className:"inline",children:"pip install 'marimo[sql]'"}),"."]}),I.jsx("span",{children:"You will need to restart the notebook after installing."})]}),delayDuration:100,asChild:!1,children:I.jsxs(X,{className:u,variant:"text",size:"sm",disabled:!c,onClick:()=>{yu(s,o),o({cellId:{type:"__end__",columnId:n},before:!1,code:(new Ro).getDefaultCode()})},children:[I.jsx(ve,{className:"mr-2 size-4 flex-shrink-0"}),"SQL"]})}),I.jsx(it,{content:l?null:I.jsx("span",{children:"Enable via settings under AI Assist"}),delayDuration:100,asChild:!1,children:I.jsxs(X,{className:u,variant:"text",size:"sm",disabled:!l,onClick:a.toggle,children:[I.jsx(he,{className:"mr-2 size-4 flex-shrink-0"}),"Generate with AI"]})})]}),t[1]=l,t[2]=s,t[3]=n,t[4]=o,t[5]=i,t[6]=a.toggle,t[7]=c,t[8]=h):h=t[8];const f=h,p=!i&&"w-fit",m=i&&"opacity-100 w-full max-w-4xl shadow-lg shadow-[var(--blue-3)]";let g,y,b;return t[9]!==r||t[10]!==p||t[11]!==m?(g=In("shadow-sm border border-border rounded transition-all duration-200 overflow-hidden divide-x divide-border flex",p,m,r),t[9]=r,t[10]=p,t[11]=m,t[12]=g):g=t[12],t[13]!==f?(y=f(),t[13]=f,t[14]=y):y=t[14],t[15]!==g||t[16]!==y?(b=I.jsx("div",{className:"flex justify-center mt-4 pt-6 pb-32 group gap-4 w-full print:hidden",children:I.jsx("div",{className:g,children:y})}),t[15]=g,t[16]=y,t[17]=b):b=t[17],b},KI=e=>{const t=j.c(60),{userConfig:n,appConfig:r}=e;ki(ji,Lf);const{setCells:s,mergeAllColumns:i}=U(),a=se(bt),l=se(Si),c=se(Ci),d=Pt(),u=ae(pf),h="edit"===a.mode,f="present"===a.mode,p=se(Ei);let m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[0]=m):m=t[0],o.useEffect(QI,m);const g=n.runtime.auto_instantiate;let y,b,x;t[1]!==s||t[2]!==u?(y=(e,t)=>{s(e);const n=e.map(eA),r=e.map(tA),o=e.map(nA);u({names:n,codes:r,configs:o,layout:t})},t[1]=s,t[2]=u,t[3]=y):y=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(b=Ps(),t[4]=b):b=t[4],t[5]!==y||t[6]!==n.runtime.auto_instantiate?(x={autoInstantiate:g,setCells:y,sessionId:b},t[5]=y,t[6]=n.runtime.auto_instantiate,t[7]=x):x=t[7];const{connection:v}=ac(x);let w,k;t[8]!==r.app_title||t[9]!==d?(w=()=>{document.title=r.app_title||kt.basename(d??"")||"Untitled Notebook"},k=[r.app_title,d],t[8]=r.app_title,t[9]=d,t[10]=w,t[11]=k):(w=t[10],k=t[11]),o.useEffect(w,k);const S=Jo(r.width);let C,E;t[12]!==r.width||t[13]!==i||t[14]!==S?(C=()=>{"columns"===S&&"columns"!==r.width&&i()},t[12]=r.width,t[13]=i,t[14]=S,t[15]=C):C=t[15],t[16]!==r.width||t[17]!==i||t[18]!==l||t[19]!==S?(E=[r.width,S,i,l],t[16]=r.width,t[17]=i,t[18]=l,t[19]=S,t[20]=E):E=t[20],o.useEffect(C,E);const N=function(){const e=j.c(2),t=lu();let n;return e[0]!==t?(n=()=>t($(H())),e[0]=t,e[1]=n):n=e[1],B(n)}(),_=au(),A=Gu();let T,M,D,O;t[21]!==N?(T=()=>{N()},t[21]=N,t[22]=T):T=t[22],yl("global.runStale",T),yl("global.interrupt",rA),t[23]!==A?(M=()=>{A()},t[23]=A,t[24]=M):M=t[24],yl("global.hideCode",M),t[25]!==_?(D=()=>{_()},t[25]=_,t[26]=D):D=t[26],yl("global.runAll",D),t[27]!==r||t[28]!==v||t[29]!==n||t[30]!==a.mode?(O=I.jsx(qI,{connStatus:v,mode:a.mode,userConfig:n,appConfig:r}),t[27]=r,t[28]=v,t[29]=n,t[30]=a.mode,t[31]=O):O=t[31];const R=O,P=r.width;let L,z,F,V,W;t[32]===Symbol.for("react.memo_cache_sentinel")?(L=In("pt-4 sm:pt-12 pb-2 mb-4 print:hidden z-50","sticky left-0"),t[32]=L):L=t[32],t[33]!==d||t[34]!==h?(z=h&&I.jsx("div",{className:"flex items-center justify-center container",children:I.jsx(Rf,{filename:d})}),t[33]=d,t[34]=h,t[35]=z):z=t[35],t[36]!==v||t[37]!==z?(F=I.jsx(dc,{connection:v,className:L,children:z}),t[36]=v,t[37]=z,t[38]=F):F=t[38],t[39]!==r||t[40]!==R||t[41]!==c||t[42]!==a.mode?(V=c&&I.jsx(lc,{appConfig:r,mode:a.mode,children:R}),t[39]=r,t[40]=R,t[41]=c,t[42]=a.mode,t[43]=V):V=t[43],t[44]!==r.width||t[45]!==v||t[46]!==p||t[47]!==F||t[48]!==V?(W=I.jsxs(uc,{connection:v,isRunning:p,width:P,children:[F,V]}),t[44]=r.width,t[45]=v,t[46]=p,t[47]=F,t[48]=V,t[49]=W):W=t[49];const G=v.state===ct.CLOSED;let q,Y;return t[50]!==r||t[51]!==f||t[52]!==p||t[53]!==N||t[54]!==G||t[55]!==A?(q=I.jsx(_i,{children:I.jsx(Af,{presenting:f,onTogglePresenting:A,onInterrupt:qs,onRun:N,closed:G,running:p,appConfig:r})}),t[50]=r,t[51]=f,t[52]=p,t[53]=N,t[54]=G,t[55]=A,t[56]=q):q=t[56],t[57]!==W||t[58]!==q?(Y=I.jsxs(I.Fragment,{children:[W,q]}),t[57]=W,t[58]=q,t[59]=Y):Y=t[59],Y};function ZI(){cc.INSTANCE.stop()}function QI(){return cc.INSTANCE.start(Ni),ZI}function eA(e){return e.name}function tA(e){return e.code}function nA(e){return e.config}function rA(){qs()}const{createElement:oA,createContext:sA,createRef:iA,forwardRef:aA,useCallback:lA,useContext:cA,useEffect:dA,useImperativeHandle:uA,useLayoutEffect:hA,useMemo:fA,useRef:pA,useState:mA}=Ii,gA=Ii[`useId${Math.random()}`.slice(0,5)],yA=hA,bA=sA(null);bA.displayName="PanelGroupContext";const xA=yA,vA="function"==typeof gA?gA:()=>null;let wA=0;function kA(e=null){const t=vA(),n=pA(e||t||null);return null===n.current&&(n.current=""+wA++),null!=e?e:n.current}function SA({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:o,forwardedRef:s,id:i,maxSize:a,minSize:l,onCollapse:c,onExpand:d,onResize:u,order:h,style:f,tagName:p="div",...m}){const g=cA(bA);if(null===g)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:b,getPanelSize:x,getPanelStyle:v,groupId:w,isPanelCollapsed:k,reevaluatePanelConstraints:S,registerPanel:C,resizePanel:E,unregisterPanel:N}=g,j=kA(i),_=pA({callbacks:{onCollapse:c,onExpand:d,onResize:u},constraints:{collapsedSize:n,collapsible:r,defaultSize:o,maxSize:a,minSize:l},id:j,idIsFromProps:void 0!==i,order:h});pA({didLogMissingDefaultSizeWarning:!1}),xA((()=>{const{callbacks:e,constraints:t}=_.current,s={...t};_.current.id=j,_.current.idIsFromProps=void 0!==i,_.current.order=h,e.onCollapse=c,e.onExpand=d,e.onResize=u,t.collapsedSize=n,t.collapsible=r,t.defaultSize=o,t.maxSize=a,t.minSize=l,s.collapsedSize===t.collapsedSize&&s.collapsible===t.collapsible&&s.maxSize===t.maxSize&&s.minSize===t.minSize||S(_.current,s)})),xA((()=>{const e=_.current;return C(e),()=>{N(e)}}),[h,j,C,N]),uA(s,(()=>({collapse:()=>{y(_.current)},expand:e=>{b(_.current,e)},getId:()=>j,getSize:()=>x(_.current),isCollapsed:()=>k(_.current),isExpanded:()=>!k(_.current),resize:e=>{E(_.current,e)}})),[y,b,x,k,j,E]);const I=v(_.current,o);return oA(p,{...m,children:e,className:t,id:i,style:{...I,...f},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":w,"data-panel-id":j,"data-panel-size":parseFloat(""+I.flexGrow).toFixed(1)})}const CA=aA(((e,t)=>oA(SA,{...e,forwardedRef:t})));SA.displayName="Panel",CA.displayName="forwardRef(Panel)";let EA=null,NA=null;function jA(e,t){const n=function(e,t){if(t){const e=!!(t&BA),n=!!(t&UA);if(t&zA)return e?"se-resize":n?"ne-resize":"e-resize";if(t&FA)return e?"sw-resize":n?"nw-resize":"w-resize";if(e)return"s-resize";if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,t);EA!==n&&(EA=n,null===NA&&(NA=document.createElement("style"),document.head.appendChild(NA)),NA.innerHTML=`*{cursor: ${n}!important;}`)}function _A(e){return"keydown"===e.type}function IA(e){return e.type.startsWith("pointer")}function AA(e){return e.type.startsWith("mouse")}function TA(e){if(IA(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(AA(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const MA=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function DA(e){const t=getComputedStyle(e);return"fixed"===t.position||(!("auto"===t.zIndex||"static"===t.position&&!function(e){var t;const n=getComputedStyle(null!==(t=LA(e))&&void 0!==t?t:e).display;return"flex"===n||"inline-flex"===n}(e))||(+t.opacity<1||("transform"in t&&"none"!==t.transform||("webkitTransform"in t&&"none"!==t.webkitTransform||("mixBlendMode"in t&&"normal"!==t.mixBlendMode||("filter"in t&&"none"!==t.filter||("webkitFilter"in t&&"none"!==t.webkitFilter||("isolation"in t&&"isolate"===t.isolation||(!!MA.test(t.willChange)||"touch"===t.webkitOverflowScrolling)))))))))}function OA(e){let t=e.length;for(;t--;){const n=e[t];if(nT(n,"Missing node"),DA(n))return n}return null}function RA(e){return e&&Number(getComputedStyle(e).zIndex)||0}function PA(e){const t=[];for(;e;)t.push(e),e=LA(e);return t}function LA(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const zA=1,FA=2,BA=4,UA=8,$A="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let HA=[],VA=!1,WA=new Map,GA=new Map;const qA=new Set;function YA(e){const{target:t}=e,{x:n,y:r}=TA(e);VA=!0,KA({target:t,x:n,y:r}),eT(),HA.length>0&&(tT("down",e),e.preventDefault(),e.stopPropagation())}function XA(e){const{x:t,y:n}=TA(e);if(VA&&0===e.buttons&&(VA=!1,tT("up",e)),!VA){const{target:r}=e;KA({target:r,x:t,y:n})}tT("move",e),QA(),HA.length>0&&e.preventDefault()}function JA(e){const{target:t}=e,{x:n,y:r}=TA(e);GA.clear(),VA=!1,HA.length>0&&e.preventDefault(),tT("up",e),KA({target:t,x:n,y:r}),QA(),eT()}function KA({target:e,x:t,y:n}){HA.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),qA.forEach((e=>{const{element:o,hitAreaMargins:s}=e,i=o.getBoundingClientRect(),{bottom:a,left:l,right:c,top:d}=i,u=$A?s.coarse:s.fine;if(t>=l-u&&t<=c+u&&n>=d-u&&n<=a+u){if(null!==r&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&function(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:PA(e),b:PA(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;nT(r,"Stacking order can only be calculated for elements with a common ancestor");const o=RA(OA(n.a)),s=RA(OA(n.b));if(o===s){const e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)};let o=e.length;for(;o--;){const n=e[o];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(o-s)}(r,o)>0){let e=r,t=!1;for(;e&&!e.contains(o);){if(h=e.getBoundingClientRect(),f=i,h.x<f.x+f.width&&h.x+h.width>f.x&&h.y<f.y+f.height&&h.y+h.height>f.y){t=!0;break}e=e.parentElement}if(t)return}HA.push(e)}var h,f}))}function ZA(e,t){GA.set(e,t)}function QA(){let e=!1,t=!1;HA.forEach((n=>{const{direction:r}=n;"horizontal"===r?e=!0:t=!0}));let n=0;GA.forEach((e=>{n|=e})),e&&t?jA("intersection",n):e?jA("horizontal",n):t?jA("vertical",n):null!==NA&&(document.head.removeChild(NA),EA=null,NA=null)}function eT(){WA.forEach(((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",JA),n.removeEventListener("pointerdown",YA),n.removeEventListener("pointerleave",XA),n.removeEventListener("pointermove",XA)})),window.removeEventListener("pointerup",JA),window.removeEventListener("pointercancel",JA),qA.size>0&&(VA?(HA.length>0&&WA.forEach(((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",JA),n.addEventListener("pointerleave",XA),n.addEventListener("pointermove",XA))})),window.addEventListener("pointerup",JA),window.addEventListener("pointercancel",JA)):WA.forEach(((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",YA,{capture:!0}),n.addEventListener("pointermove",XA))})))}function tT(e,t){qA.forEach((n=>{const{setResizeHandlerState:r}=n,o=HA.includes(n);r(e,o,t)}))}function nT(e,t){if(!e)throw console.error(t),Error(t)}function rT(e,t,n=10){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function oT(e,t,n=10){return 0===rT(e,t,n)}function sT(e,t,n){return 0===rT(e,t,n)}function iT({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];nT(null!=r,`Panel constraints not found for index ${t}`);let{collapsedSize:o=0,collapsible:s,maxSize:i=100,minSize:a=0}=r;if(rT(n,a)<0)if(s){n=rT(n,(o+a)/2)<0?o:a}else n=a;return n=Math.min(i,n),n=parseFloat(n.toFixed(10))}function aT({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:o,trigger:s}){if(sT(e,0))return t;const i=[...t],[a,l]=r;nT(null!=a,"Invalid first pivot index"),nT(null!=l,"Invalid second pivot index");let c=0;if("keyboard"===s){{const r=e<0?l:a,o=n[r];nT(o,`Panel constraints not found for index ${r}`);const{collapsedSize:s=0,collapsible:i,minSize:c=0}=o;if(i){const n=t[r];if(nT(null!=n,`Previous layout not found for panel index ${r}`),sT(n,s)){const t=c-n;rT(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{const r=e<0?a:l,o=n[r];nT(o,`No panel constraints found for index ${r}`);const{collapsedSize:s=0,collapsible:i,minSize:c=0}=o;if(i){const n=t[r];if(nT(null!=n,`Previous layout not found for panel index ${r}`),sT(n,c)){const t=n-s;rT(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}{const r=e<0?1:-1;let o=e<0?l:a,s=0;for(;;){const e=t[o];nT(null!=e,`Previous layout not found for panel index ${o}`);if(s+=iT({panelConstraints:n,panelIndex:o,size:100})-e,o+=r,o<0||o>=n.length)break}const i=Math.min(Math.abs(e),Math.abs(s));e=e<0?0-i:i}{let r=e<0?a:l;for(;r>=0&&r<n.length;){const o=Math.abs(e)-Math.abs(c),s=t[r];nT(null!=s,`Previous layout not found for panel index ${r}`);const a=iT({panelConstraints:n,panelIndex:r,size:s-o});if(!sT(s,a)&&(c+=s-a,i[r]=a,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?r--:r++}}if(function(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!sT(e[r],t[r],n))return!1;return!0}(o,i))return o;{const r=e<0?l:a,o=t[r];nT(null!=o,`Previous layout not found for panel index ${r}`);const s=o+c,d=iT({panelConstraints:n,panelIndex:r,size:s});if(i[r]=d,!sT(d,s)){let t=s-d;let r=e<0?l:a;for(;r>=0&&r<n.length;){const o=i[r];nT(null!=o,`Previous layout not found for panel index ${r}`);const s=iT({panelConstraints:n,panelIndex:r,size:o+t});if(sT(o,s)||(t-=s-o,i[r]=s),sT(t,0))break;e>0?r--:r++}}}return sT(i.reduce(((e,t)=>t+e),0),100)?i:o}function lT({layout:e,panelsArray:t,pivotIndices:n}){let r=0,o=100,s=0,i=0;const a=n[0];nT(null!=a,"No pivot index found"),t.forEach(((e,t)=>{const{constraints:n}=e,{maxSize:l=100,minSize:c=0}=n;t===a?(r=c,o=l):(s+=c,i+=l)}));return{valueMax:Math.min(o,100-s),valueMin:Math.max(r,100-i),valueNow:e[a]}}function cT(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function dT(e,t,n=document){const r=cT(e,n).findIndex((e=>e.getAttribute("data-panel-resize-handle-id")===t));return null!=r?r:null}function uT(e,t,n){const r=dT(e,t,n);return null!=r?[r,r+1]:[-1,-1]}function hT(e,t=document){var n;if(t instanceof HTMLElement&&(null==t||null===(n=t.dataset)||void 0===n?void 0:n.panelGroupId)==e)return t;const r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function fT(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function pT({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:o,panelGroupElement:s,setLayout:i}){pA({didWarnAboutMissingResizeHandle:!1}),xA((()=>{if(!s)return;const e=cT(n,s);for(let t=0;t<o.length-1;t++){const{valueMax:n,valueMin:s,valueNow:i}=lT({layout:r,panelsArray:o,pivotIndices:[t,t+1]}),a=e[t];if(null==a);else{const e=o[t];nT(e,`No panel data found for index "${t}"`),a.setAttribute("aria-controls",e.id),a.setAttribute("aria-valuemax",""+Math.round(n)),a.setAttribute("aria-valuemin",""+Math.round(s)),a.setAttribute("aria-valuenow",null!=i?""+Math.round(i):"")}}return()=>{e.forEach(((e,t)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")}))}}),[n,r,o,s]),dA((()=>{if(!s)return;const e=t.current;nT(e,"Eager values not found");const{panelDataArray:o}=e;nT(null!=hT(n,s),`No group found for id "${n}"`);const a=cT(n,s);nT(a,`No resize handles found for group id "${n}"`);const l=a.map((e=>{const t=e.getAttribute("data-panel-resize-handle-id");nT(t,"Resize handle element has no handle id attribute");const[a,l]=function(e,t,n,r=document){var o,s,i,a;const l=fT(t,r),c=cT(e,r),d=l?c.indexOf(l):-1;return[null!==(o=null===(s=n[d])||void 0===s?void 0:s.id)&&void 0!==o?o:null,null!==(i=null===(a=n[d+1])||void 0===a?void 0:a.id)&&void 0!==i?i:null]}(n,t,o,s);if(null==a||null==l)return()=>{};const c=e=>{if(!e.defaultPrevented)switch(e.key){case"Enter":{e.preventDefault();const l=o.findIndex((e=>e.id===a));if(l>=0){const e=o[l];nT(e,`No panel data found for index ${l}`);const a=r[l],{collapsedSize:c=0,collapsible:d,minSize:u=0}=e.constraints;if(null!=a&&d){const e=aT({delta:sT(a,c)?u-c:c-a,initialLayout:r,panelConstraints:o.map((e=>e.constraints)),pivotIndices:uT(n,t,s),prevLayout:r,trigger:"keyboard"});r!==e&&i(e)}}break}}};return e.addEventListener("keydown",c),()=>{e.removeEventListener("keydown",c)}}));return()=>{l.forEach((e=>e()))}}),[s,e,t,n,r,o,i])}function mT(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 gT(e,t){const n="horizontal"===e,{x:r,y:o}=TA(t);return n?r:o}function yT(e,t,n,r,o,s){if(_A(e)){const t="horizontal"===n;let r=0;r=e.shiftKey?100:null!=o?o:10;let s=0;switch(e.key){case"ArrowDown":s=t?0:r;break;case"ArrowLeft":s=t?-r:0;break;case"ArrowRight":s=t?r:0;break;case"ArrowUp":s=t?0:-r;break;case"End":s=100;break;case"Home":s=-100}return s}return null==r?0:function(e,t,n,r,o){const s="horizontal"===n,i=fT(t,o);nT(i,`No resize handle element found for id "${t}"`);const a=i.getAttribute("data-panel-group-id");nT(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=gT(n,e),d=hT(a,o);nT(d,`No group element found for id "${a}"`);const u=d.getBoundingClientRect();return(c-l)/(s?u.width:u.height)*100}(e,t,n,r,s)}function bT(e,t,n){t.forEach(((t,r)=>{const o=e[r];nT(o,`Panel data not found for index ${r}`);const{callbacks:s,constraints:i,id:a}=o,{collapsedSize:l=0,collapsible:c}=i,d=n[a];if(null==d||t!==d){n[a]=t;const{onCollapse:e,onExpand:r,onResize:o}=s;o&&o(t,d),c&&(e||r)&&(!r||null!=d&&!oT(d,l)||oT(t,l)||r(),!e||null!=d&&oT(d,l)||!oT(t,l)||e())}}))}function xT(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 vT(e){try{if("undefined"==typeof localStorage)throw new Error("localStorage not supported in this environment");e.getItem=e=>localStorage.getItem(e),e.setItem=(e,t)=>{localStorage.setItem(e,t)}}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function wT(e){return`react-resizable-panels:${e}`}function kT(e){return e.map((e=>{const{constraints:t,id:n,idIsFromProps:r,order:o}=e;return r?n:o?`${o}:${JSON.stringify(t)}`:JSON.stringify(t)})).sort(((e,t)=>e.localeCompare(t))).join(",")}function ST(e,t){try{const n=wT(e),r=t.getItem(n);if(r){const e=JSON.parse(r);if("object"==typeof e&&null!=e)return e}}catch(n){}return null}function CT(e,t,n,r,o){var s;const i=wT(e),a=kT(t),l=null!==(s=ST(e,o))&&void 0!==s?s:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{o.setItem(i,JSON.stringify(l))}catch(c){console.error(c)}}function ET({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce(((e,t)=>e+t),0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map((e=>`${e}%`)).join(", ")}`);if(!sT(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const e=n[s];nT(null!=e,`No layout data found for index ${s}`);const t=100/r*e;n[s]=t}let o=0;for(let s=0;s<t.length;s++){const e=n[s];nT(null!=e,`No layout data found for index ${s}`);const r=iT({panelConstraints:t,panelIndex:s,size:e});e!=r&&(o+=e-r,n[s]=r)}if(!sT(o,0))for(let s=0;s<t.length;s++){const e=n[s];nT(null!=e,`No layout data found for index ${s}`);const r=iT({panelConstraints:t,panelIndex:s,size:e+o});if(e!==r&&(o-=r-e,n[s]=r,sT(o,0)))break}return n}const NT={getItem:e=>(vT(NT),NT.getItem(e)),setItem:(e,t)=>{vT(NT),NT.setItem(e,t)}},jT={};function _T({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:o,id:s=null,onLayout:i=null,keyboardResizeBy:a=null,storage:l=NT,style:c,tagName:d="div",...u}){const h=kA(s),f=pA(null),[p,m]=mA(null),[g,y]=mA([]),b=function(){const[e,t]=mA(0);return lA((()=>t((e=>e+1))),[])}(),x=pA({}),v=pA(new Map),w=pA(0),k=pA({autoSaveId:e,direction:r,dragState:p,id:h,keyboardResizeBy:a,onLayout:i,storage:l}),S=pA({layout:g,panelDataArray:[],panelDataArrayChanged:!1});pA({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),uA(o,(()=>({getId:()=>k.current.id,getLayout:()=>{const{layout:e}=S.current;return e},setLayout:e=>{const{onLayout:t}=k.current,{layout:n,panelDataArray:r}=S.current,o=ET({layout:e,panelConstraints:r.map((e=>e.constraints))});mT(n,o)||(y(o),S.current.layout=o,t&&t(o),bT(r,o,x.current))}})),[]),xA((()=>{k.current.autoSaveId=e,k.current.direction=r,k.current.dragState=p,k.current.id=h,k.current.onLayout=i,k.current.storage=l})),pT({committedValuesRef:k,eagerValuesRef:S,groupId:h,layout:g,panelDataArray:S.current.panelDataArray,setLayout:y,panelGroupElement:f.current}),dA((()=>{const{panelDataArray:t}=S.current;if(e){if(0===g.length||g.length!==t.length)return;let n=jT[e];null==n&&(n=function(e,t=10){let n=null;return(...r)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>{e(...r)}),t)}}(CT,100),jT[e]=n);const r=[...t],o=new Map(v.current);n(e,r,o,g,l)}}),[e,g,l]),dA((()=>{}));const C=lA((e=>{const{onLayout:t}=k.current,{layout:n,panelDataArray:r}=S.current;if(e.constraints.collapsible){const o=r.map((e=>e.constraints)),{collapsedSize:s=0,panelSize:i,pivotIndices:a}=TT(r,e,n);if(nT(null!=i,`Panel size not found for panel "${e.id}"`),!oT(i,s)){v.current.set(e.id,i);const l=aT({delta:AT(r,e)===r.length-1?i-s:s-i,initialLayout:n,panelConstraints:o,pivotIndices:a,prevLayout:n,trigger:"imperative-api"});xT(n,l)||(y(l),S.current.layout=l,t&&t(l),bT(r,l,x.current))}}}),[]),E=lA(((e,t)=>{const{onLayout:n}=k.current,{layout:r,panelDataArray:o}=S.current;if(e.constraints.collapsible){const s=o.map((e=>e.constraints)),{collapsedSize:i=0,panelSize:a=0,minSize:l=0,pivotIndices:c}=TT(o,e,r),d=null!=t?t:l;if(oT(a,i)){const t=v.current.get(e.id),i=null!=t&&t>=d?t:d,l=aT({delta:AT(o,e)===o.length-1?a-i:i-a,initialLayout:r,panelConstraints:s,pivotIndices:c,prevLayout:r,trigger:"imperative-api"});xT(r,l)||(y(l),S.current.layout=l,n&&n(l),bT(o,l,x.current))}}}),[]),N=lA((e=>{const{layout:t,panelDataArray:n}=S.current,{panelSize:r}=TT(n,e,t);return nT(null!=r,`Panel size not found for panel "${e.id}"`),r}),[]),j=lA(((e,t)=>{const{panelDataArray:n}=S.current,r=AT(n,e);return function({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:o,precision:s=3}){const i=n[o];let a;return a=null==i?null!=e?e.toPrecision(s):"1":1===r.length?"1":i.toPrecision(s),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:null!==t?"none":void 0}}({defaultSize:t,dragState:p,layout:g,panelData:n,panelIndex:r})}),[p,g]),_=lA((e=>{const{layout:t,panelDataArray:n}=S.current,{collapsedSize:r=0,collapsible:o,panelSize:s}=TT(n,e,t);return nT(null!=s,`Panel size not found for panel "${e.id}"`),!0===o&&oT(s,r)}),[]),I=lA((e=>{const{layout:t,panelDataArray:n}=S.current,{collapsedSize:r=0,collapsible:o,panelSize:s}=TT(n,e,t);return nT(null!=s,`Panel size not found for panel "${e.id}"`),!o||rT(s,r)>0}),[]),A=lA((e=>{const{panelDataArray:t}=S.current;t.push(e),t.sort(((e,t)=>{const n=e.order,r=t.order;return null==n&&null==r?0:null==n?-1:null==r?1:n-r})),S.current.panelDataArrayChanged=!0,b()}),[b]);xA((()=>{if(S.current.panelDataArrayChanged){S.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:t,storage:n}=k.current,{layout:r,panelDataArray:o}=S.current;let s=null;if(e){const t=function(e,t,n){var r,o;return null!==(o=(null!==(r=ST(e,n))&&void 0!==r?r:{})[kT(t)])&&void 0!==o?o:null}(e,o,n);t&&(v.current=new Map(Object.entries(t.expandToSizes)),s=t.layout)}null==s&&(s=function({panelDataArray:e}){const t=Array(e.length),n=e.map((e=>e.constraints));let r=0,o=100;for(let s=0;s<e.length;s++){const e=n[s];nT(e,`Panel constraints not found for index ${s}`);const{defaultSize:i}=e;null!=i&&(r++,t[s]=i,o-=i)}for(let s=0;s<e.length;s++){const i=n[s];nT(i,`Panel constraints not found for index ${s}`);const{defaultSize:a}=i;if(null!=a)continue;const l=o/(e.length-r);r++,t[s]=l,o-=l}return t}({panelDataArray:o}));const i=ET({layout:s,panelConstraints:o.map((e=>e.constraints))});mT(r,i)||(y(i),S.current.layout=i,t&&t(i),bT(o,i,x.current))}})),xA((()=>{const e=S.current;return()=>{e.layout=[]}}),[]);const T=lA((e=>{let t=!1;const n=f.current;if(n){"rtl"===window.getComputedStyle(n,null).getPropertyValue("direction")&&(t=!0)}return function(n){n.preventDefault();const r=f.current;if(!r)return()=>null;const{direction:o,dragState:s,id:i,keyboardResizeBy:a,onLayout:l}=k.current,{layout:c,panelDataArray:d}=S.current,{initialLayout:u}=null!=s?s:{},h=uT(i,e,r);let p=yT(n,e,o,s,a,r);const m="horizontal"===o;m&&t&&(p=-p);const g=aT({delta:p,initialLayout:null!=u?u:c,panelConstraints:d.map((e=>e.constraints)),pivotIndices:h,prevLayout:c,trigger:_A(n)?"keyboard":"mouse-or-touch"}),b=!xT(c,g);(IA(n)||AA(n))&&w.current!=p&&(w.current=p,ZA(e,b||0===p?0:m?p<0?zA:FA:p<0?BA:UA)),b&&(y(g),S.current.layout=g,l&&l(g),bT(d,g,x.current))}}),[]),M=lA(((e,t)=>{const{onLayout:n}=k.current,{layout:r,panelDataArray:o}=S.current,s=o.map((e=>e.constraints)),{panelSize:i,pivotIndices:a}=TT(o,e,r);nT(null!=i,`Panel size not found for panel "${e.id}"`);const l=aT({delta:AT(o,e)===o.length-1?i-t:t-i,initialLayout:r,panelConstraints:s,pivotIndices:a,prevLayout:r,trigger:"imperative-api"});xT(r,l)||(y(l),S.current.layout=l,n&&n(l),bT(o,l,x.current))}),[]),D=lA(((e,t)=>{const{layout:n,panelDataArray:r}=S.current,{collapsedSize:o=0,collapsible:s}=t,{collapsedSize:i=0,collapsible:a,maxSize:l=100,minSize:c=0}=e.constraints,{panelSize:d}=TT(r,e,n);null!=d&&(s&&a&&oT(d,o)?oT(o,i)||M(e,i):d<c?M(e,c):d>l&&M(e,l))}),[M]),O=lA(((e,t)=>{const{direction:n}=k.current,{layout:r}=S.current;if(!f.current)return;const o=fT(e,f.current);nT(o,`Drag handle element not found for id "${e}"`);const s=gT(n,t);m({dragHandleId:e,dragHandleRect:o.getBoundingClientRect(),initialCursorPosition:s,initialLayout:r})}),[]),R=lA((()=>{m(null)}),[]),P=lA((e=>{const{panelDataArray:t}=S.current,n=AT(t,e);n>=0&&(t.splice(n,1),delete x.current[e.id],S.current.panelDataArrayChanged=!0,b())}),[b]),L=fA((()=>({collapsePanel:C,direction:r,dragState:p,expandPanel:E,getPanelSize:N,getPanelStyle:j,groupId:h,isPanelCollapsed:_,isPanelExpanded:I,reevaluatePanelConstraints:D,registerPanel:A,registerResizeHandle:T,resizePanel:M,startDragging:O,stopDragging:R,unregisterPanel:P,panelGroupElement:f.current})),[C,p,r,E,N,j,h,_,I,D,A,T,M,O,R,P]),z={display:"flex",flexDirection:"horizontal"===r?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return oA(bA.Provider,{value:L},oA(d,{...u,children:t,className:n,id:s,ref:f,style:{...z,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":h}))}const IT=aA(((e,t)=>oA(_T,{...e,forwardedRef:t})));function AT(e,t){return e.findIndex((e=>e===t||e.id===t.id))}function TT(e,t,n){const r=AT(e,t),o=r===e.length-1?[r-1,r]:[r,r+1],s=n[r];return{...t.constraints,panelSize:s,pivotIndices:o}}function MT({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:o,onBlur:s,onDragging:i,onFocus:a,style:l={},tabIndex:c=0,tagName:d="div",...u}){var h,f;const p=pA(null),m=pA({onDragging:i});dA((()=>{m.current.onDragging=i}));const g=cA(bA);if(null===g)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:b,registerResizeHandle:x,startDragging:v,stopDragging:w,panelGroupElement:k}=g,S=kA(o),[C,E]=mA("inactive"),[N,j]=mA(!1),[_,I]=mA(null),A=pA({state:C});xA((()=>{A.current.state=C})),dA((()=>{if(n)I(null);else{const e=x(S);I((()=>e))}}),[n,S,x]);const T=null!==(h=null==r?void 0:r.coarse)&&void 0!==h?h:15,M=null!==(f=null==r?void 0:r.fine)&&void 0!==f?f:5;dA((()=>{if(n||null==_)return;const e=p.current;nT(e,"Element ref not attached");return function(e,t,n,r,o){var s;const{ownerDocument:i}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:o},l=null!==(s=WA.get(i))&&void 0!==s?s:0;return WA.set(i,l+1),qA.add(a),eT(),function(){var t;GA.delete(e),qA.delete(a);const n=null!==(t=WA.get(i))&&void 0!==t?t:1;if(WA.set(i,n-1),eT(),1===n&&WA.delete(i),HA.includes(a)){const e=HA.indexOf(a);e>=0&&HA.splice(e,1),QA(),o("up",!0,null)}}}(S,e,y,{coarse:T,fine:M},((e,t,n)=>{if(t)switch(e){case"down":{E("drag"),nT(n,'Expected event to be defined for "down" action'),v(S,n);const{onDragging:e}=m.current;e&&e(!0);break}case"move":{const{state:e}=A.current;"drag"!==e&&E("hover"),nT(n,'Expected event to be defined for "move" action'),_(n);break}case"up":{E("hover"),w();const{onDragging:e}=m.current;e&&e(!1);break}}else E("inactive")}))}),[T,y,n,M,x,S,_,v,w]),function({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){dA((()=>{if(e||null==n||null==r)return;const o=fT(t,r);if(null==o)return;const s=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),n(e);break;case"F6":{e.preventDefault();const n=o.getAttribute("data-panel-group-id");nT(n,`No group element found for id "${n}"`);const s=cT(n,r),i=dT(n,t,r);nT(null!==i,`No resize element found for id "${t}"`),s[e.shiftKey?i>0?i-1:s.length-1:i+1<s.length?i+1:0].focus();break}}};return o.addEventListener("keydown",s),()=>{o.removeEventListener("keydown",s)}}),[r,e,t,n])}({disabled:n,handleId:S,resizeHandler:_,panelGroupElement:k});return oA(d,{...u,children:e,className:t,id:o,onBlur:()=>{j(!1),null==s||s()},onFocus:()=>{j(!0),null==a||a()},ref:p,role:"separator",style:{touchAction:"none",userSelect:"none",...l},tabIndex:c,"data-panel-group-direction":y,"data-panel-group-id":b,"data-resize-handle":"","data-resize-handle-active":"drag"===C?"pointer":N?"keyboard":void 0,"data-resize-handle-state":C,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":S})}_T.displayName="PanelGroup",IT.displayName="forwardRef(PanelGroup)",MT.displayName="PanelResizeHandle";const DT=e=>{const t=j.c(3);let n,r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=I.jsx("path",{d:"M205.28 31.36c14.096 14.88 20.016 35.2 22.512 63.68c6.626 0 12.805 1.47 16.976 7.152l7.792 10.56A17.55 17.55 0 0 1 256 123.2v28.688c-.008 3.704-1.843 7.315-4.832 9.504C215.885 187.222 172.35 208 128 208c-49.066 0-98.19-28.273-123.168-46.608c-2.989-2.189-4.825-5.8-4.832-9.504V123.2c0-3.776 1.2-7.424 3.424-10.464l7.792-10.544c4.173-5.657 10.38-7.152 16.992-7.152c2.496-28.48 8.4-48.8 22.512-63.68C77.331 3.165 112.567.06 127.552 0H128c14.72 0 50.4 2.88 77.28 31.36m-77.264 47.376c-3.04 0-6.544.176-10.272.544c-1.312 4.896-3.248 9.312-6.08 12.128c-11.2 11.2-24.704 12.928-31.936 12.928c-6.802 0-13.927-1.42-19.744-5.088c-5.502 1.808-10.786 4.415-11.136 10.912c-.586 12.28-.637 24.55-.688 36.824c-.026 6.16-.05 12.322-.144 18.488c.024 3.579 2.182 6.903 5.44 8.384C79.936 185.92 104.976 192 128.016 192c23.008 0 48.048-6.08 74.512-18.144c3.258-1.48 5.415-4.805 5.44-8.384c.317-18.418.062-36.912-.816-55.312h.016c-.342-6.534-5.648-9.098-11.168-10.912c-5.82 3.652-12.927 5.088-19.728 5.088c-7.232 0-20.72-1.728-31.936-12.928c-2.832-2.816-4.768-7.232-6.08-12.128a106 106 0 0 0-10.24-.544m-26.941 43.93c5.748 0 10.408 4.66 10.408 10.409v19.183c0 5.749-4.66 10.409-10.408 10.409s-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408m53.333 0c5.749 0 10.409 4.66 10.409 10.409v19.183c0 5.749-4.66 10.409-10.409 10.409c-5.748 0-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408M81.44 28.32c-11.2 1.12-20.64 4.8-25.44 9.92c-10.4 11.36-8.16 40.16-2.24 46.24c4.32 4.32 12.48 7.2 21.28 7.2c6.72 0 19.52-1.44 30.08-12.16c4.64-4.48 7.52-15.68 7.2-27.04c-.32-9.12-2.88-16.64-6.72-19.84c-4.16-3.68-13.6-5.28-24.16-4.32m68.96 4.32c-3.84 3.2-6.4 10.72-6.72 19.84c-.32 11.36 2.56 22.56 7.2 27.04c10.56 10.72 23.36 12.16 30.08 12.16c8.8 0 16.96-2.88 21.28-7.2c5.92-6.08 8.16-34.88-2.24-46.24c-4.8-5.12-14.24-8.8-25.44-9.92c-10.56-.96-20 .64-24.16 4.32M128 56c-2.56 0-5.6.16-8.96.48c.32 1.76.48 3.68.64 5.76c0 1.44 0 2.88-.16 4.48c3.2-.32 5.92-.32 8.48-.32s5.28 0 8.48.32c-.16-1.6-.16-3.04-.16-4.48c.16-2.08.32-4 .64-5.76c-3.36-.32-6.4-.48-8.96-.48"}),t[0]=n):n=t[0],t[1]!==e?(r=I.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1.24em",height:"1em",viewBox:"0 0 256 208",fill:"currentColor",...e,children:n}),t[1]=e,t[2]=r):r=t[2],r},OT=e=>{const t=j.c(17);let n,r,o,s,i;t[0]!==e?(({children:n,tooltip:i,selected:s,className:r,...o}=e),t[0]=e,t[1]=n,t[2]=r,t[3]=o,t[4]=s,t[5]=i):(n=t[1],r=t[2],o=t[3],s=t[4],i=t[5]);const a=!s&&"hover:bg-[var(--sage-3)]",l=s&&"bg-[var(--sage-4)]";let c,d;t[6]!==r||t[7]!==a||t[8]!==l?(c=In("h-full flex items-center p-2 text-sm shadow-inset font-mono cursor-pointer rounded",a,l,r),t[6]=r,t[7]=a,t[8]=l,t[9]=c):c=t[9],t[10]!==n||t[11]!==o||t[12]!==c?(d=I.jsx("div",{className:c,...o,children:n}),t[10]=n,t[11]=o,t[12]=c,t[13]=d):d=t[13];const u=d;if(i){let e;return t[14]!==u||t[15]!==i?(e=I.jsx(it,{content:i,side:"top",delayDuration:200,children:u}),t[14]=u,t[15]=i,t[16]=e):e=t[16],e}return u},RT=()=>{var e;const t=j.c(14),n=se(LT),r=se(le),o=(null==(e=null==n?void 0:n.open_ai)?void 0:e.model)||"gpt-4-turbo",{handleClick:s}=Al();if(!r){let e,n,r;return t[0]!==s?(e=()=>s("ai"),t[0]=s,t[1]=e):e=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(n=I.jsx(he,{className:"h-4 w-4 opacity-60"}),t[2]=n):n=t[2],t[3]!==e?(r=I.jsx(OT,{tooltip:"Assist is disabled",selected:!1,onClick:e,children:n}),t[3]=e,t[4]=r):r=t[4],r}let i,a,l,c,d;return t[5]===Symbol.for("react.memo_cache_sentinel")?(i=I.jsx("b",{children:"Assist model:"}),t[5]=i):i=t[5],t[6]!==o?(a=I.jsxs(I.Fragment,{children:[i," ",o]}),t[6]=o,t[7]=a):a=t[7],t[8]!==s?(l=()=>s("ai"),t[8]=s,t[9]=l):l=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx(he,{className:"h-4 w-4"}),t[10]=c):c=t[10],t[11]!==a||t[12]!==l?(d=I.jsx(OT,{tooltip:a,onClick:l,selected:!1,children:c}),t[11]=a,t[12]=l,t[13]=d):d=t[13],d},PT=q((e=>e(Ai).completion.copilot)),LT=q((e=>e(Ai).ai)),zT=()=>{const e=j.c(1);if("github"===se(PT)){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx(FT,{}),e[0]=t):t=e[0],t}return null},FT=()=>{const e=se(Tl),t=null!==se(Ml),{handleClick:n}=Al(),r=()=>n("ai"),o=e?"Ready":"Not connected",s=ae(Tl),i=ae(Dl);return Ti((()=>{const e=Cl();let t=!0;return(async()=>{try{if(await e.initializePromise.catch((t=>{throw w.error("Copilot#checkConnection: Failed to initialize",t),e.close(),t})),!t)return;const n=await e.signedIn();if(!t)return;s(n),i(n?"signedIn":"signedOut")}catch(n){if(!t)return;w.warn("Copilot#checkConnection: Connection failed",n),s(!1),i("connectionError"),ee({title:"GitHub Copilot Connection Error",description:"Failed to connect to GitHub Copilot. Check settings and try again.",variant:"danger",action:I.jsx(X,{variant:"link",onClick:r,children:"Settings"})})}})(),()=>{t=!1}})),I.jsx(OT,{tooltip:I.jsxs(I.Fragment,{children:[I.jsx("b",{children:"GitHub Copilot:"})," ",o]}),selected:!1,onClick:r,children:I.jsx("span",{children:t?I.jsx(Mi,{className:"h-4 w-4"}):I.jsx(DT,{className:In("h-4 w-4",!e&&"opacity-60")})})})},BT=e=>{const t=j.c(18),[n,r]=o.useState(0),s=se(at);let i,a,l,c;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>r(qT),a={delayMs:1e4,whenVisible:!0},t[0]=i,t[1]=a):(i=t[0],a=t[1]),bl(i,a),t[2]!==s.state?(l=async()=>_()||s.state!==ct.OPEN?null:Di(),t[2]=s.state,t[3]=l):l=t[3],t[4]!==s.state||t[5]!==n?(c=[n,s.state],t[4]=s.state,t[5]=n,t[6]=c):c=t[6];const{data:d}=jn(l,c);let u,h,f,p,m;return t[7]!==d?(u=d&&I.jsx($T,{memory:d.memory,kernel:d.kernel,server:d.server}),t[7]=d,t[8]=u):u=t[8],t[9]!==d?(h=d&&I.jsx(HT,{cpu:d.cpu}),t[9]=d,t[10]=h):h=t[10],t[11]===Symbol.for("react.memo_cache_sentinel")?(f=I.jsxs("div",{className:"flex items-center",children:[I.jsx(RT,{}),I.jsx(zT,{})]}),t[11]=f):f=t[11],t[12]!==s.state?(p=I.jsx(UT,{connection:s.state}),t[12]=s.state,t[13]=p):p=t[13],t[14]!==u||t[15]!==h||t[16]!==p?(m=I.jsxs("div",{className:"flex gap-2 items-center",children:[u,h,f,p]}),t[14]=u,t[15]=h,t[16]=p,t[17]=m):m=t[17],m},UT=e=>{const t=j.c(18),{connection:n}=e;let r,o,s,i,a,l,c;return t[0]!==n?(r=N(n.toLowerCase()),t[0]=n,t[1]=r):r=t[1],t[2]!==n?(o=n===ct.OPEN&&I.jsx(Pc,{className:"w-4 h-4"}),t[2]=n,t[3]=o):o=t[3],t[4]!==n?(s=n===ct.CLOSED&&I.jsx(Ol,{className:"w-4 h-4"}),t[4]=n,t[5]=s):s=t[5],t[6]!==n?(i=n===ct.CONNECTING&&I.jsx(Mi,{size:"small"}),t[6]=n,t[7]=i):i=t[7],t[8]!==n?(a=n===ct.CLOSING&&I.jsx(Mi,{className:"text-destructive",size:"small"}),t[8]=n,t[9]=a):a=t[9],t[10]!==o||t[11]!==s||t[12]!==i||t[13]!==a?(l=I.jsxs("div",{children:[o,s,i,a]}),t[10]=o,t[11]=s,t[12]=i,t[13]=a,t[14]=l):l=t[14],t[15]!==r||t[16]!==l?(c=I.jsx(it,{delayDuration:200,content:r,children:l}),t[15]=r,t[16]=l,t[17]=c):c=t[17],c},$T=e=>{const t=j.c(25),{memory:n,kernel:r,server:o}=e,{percent:s,total:i,used:a}=n;let l;t[0]!==s?(l=Math.round(s),t[0]=s,t[1]=l):l=t[1];const c=l;let d,u,h,f,p,m,g,y,b,x;return t[2]===Symbol.for("react.memo_cache_sentinel")?(d=I.jsx("b",{children:"computer memory:"}),t[2]=d):d=t[2],t[3]!==a?(u=GT(a),t[3]=a,t[4]=u):u=t[4],t[5]!==i?(h=GT(i),t[5]=i,t[6]=h):h=t[6],t[7]!==c||t[8]!==u||t[9]!==h?(f=I.jsxs("span",{children:[d," ",u," / ",h," GB (",c,"%)"]}),t[7]=c,t[8]=u,t[9]=h,t[10]=f):f=t[10],t[11]!==o?(p=(null==o?void 0:o.memory)&&I.jsxs("span",{children:[I.jsx("b",{children:"marimo server:"})," ",WT(o.memory)]}),t[11]=o,t[12]=p):p=t[12],t[13]!==r?(m=(null==r?void 0:r.memory)&&I.jsxs("span",{children:[I.jsx("b",{children:"kernel:"})," ",WT(r.memory)]}),t[13]=r,t[14]=m):m=t[14],t[15]!==f||t[16]!==p||t[17]!==m?(g=I.jsxs("div",{className:"flex flex-col gap-1",children:[f,p,m]}),t[15]=f,t[16]=p,t[17]=m,t[18]=g):g=t[18],t[19]===Symbol.for("react.memo_cache_sentinel")?(y=I.jsx(ld,{className:"w-4 h-4"}),t[19]=y):y=t[19],t[20]!==c?(b=I.jsxs("div",{className:"flex items-center gap-1",children:[y,I.jsx(VT,{percent:c})]}),t[20]=c,t[21]=b):b=t[21],t[22]!==b||t[23]!==g?(x=I.jsx(it,{delayDuration:200,content:g,children:b}),t[22]=b,t[23]=g,t[24]=x):x=t[24],x},HT=e=>{const t=j.c(11),{cpu:n}=e,{percent:r}=n;let o;t[0]!==r?(o=Math.round(r),t[0]=r,t[1]=o):o=t[1];const s=o;let i,a,l,c,d;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=I.jsx("b",{children:"CPU:"}),t[2]=i):i=t[2],t[3]!==s?(a=I.jsxs("span",{children:[i," ",s,"%"]}),t[3]=s,t[4]=a):a=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(l=I.jsx(Rl,{className:"w-4 h-4"}),t[5]=l):l=t[5],t[6]!==s?(c=I.jsxs("div",{className:"flex items-center gap-1",children:[l,I.jsx(VT,{percent:s})]}),t[6]=s,t[7]=c):c=t[7],t[8]!==a||t[9]!==c?(d=I.jsx(it,{delayDuration:200,content:a,children:c}),t[8]=a,t[9]=c,t[10]=d):d=t[10],d},VT=e=>{const t=j.c(2),{percent:n}=e,r=`${n}%`;let o;return t[0]!==r?(o=I.jsx("div",{className:"h-3 w-20 bg-[var(--slate-4)] rounded-lg overflow-hidden border",children:I.jsx("div",{className:"h-full bg-primary",style:{width:r}})}),t[0]=r,t[1]=o):o=t[1],o};function WT(e){return e>1073741824?`${GT(e)} GB`:`${function(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(e/1048576)}(e)} MB`}function GT(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(e/1073741824)}function qT(e){return e+1}const YT=e=>se(vi)[e.capability]?e.children:null,XT=()=>{const e=j.c(56),{selectedPanel:t,isTerminalOpen:n}=Hu(),{openApplication:r,toggleTerminal:o}=Vu(),[s,i]=Re(),a=se(Oi),l=JT,c=Wu.find(KT);let d;fn(c,"Error panel not found"),e[0]!==o?(d=()=>{o()},e[0]=o,e[1]=d):d=e[1],yl("global.toggleTerminal",d);const u=OT,h=c.tooltip,f=t===c.type,p=()=>r(c.type),m=l(c,a>0?"text-destructive":"");let g,y,b,x,v;e[2]!==a?(g=I.jsx("span",{className:"ml-1 font-mono mt-[0.125rem]",children:a}),e[2]=a,e[3]=g):g=e[3],e[4]!==u||e[5]!==c||e[6]!==f||e[7]!==p||e[8]!==m||e[9]!==g?(y=I.jsxs(u,{tooltip:h,selected:f,onClick:p,children:[m,g]}),e[4]=u,e[5]=c,e[6]=f,e[7]=p,e[8]=m,e[9]=g,e[10]=y):y=e[10],e[11]!==o?(b=()=>o(),e[11]=o,e[12]=b):b=e[12],e[13]===Symbol.for("react.memo_cache_sentinel")?(x=I.jsx(Od,{className:"h-5 w-5"}),e[13]=x):x=e[13],e[14]!==n||e[15]!==b?(v=I.jsx(YT,{capability:"terminal",children:I.jsx(OT,{tooltip:"Open terminal",selected:n,onClick:b,children:x})}),e[14]=n,e[15]=b,e[16]=v):v=e[16];const w=s.runtime.auto_instantiate?"Disable autorun on startup":"Enable autorun on startup";let k,C,E;e[17]!==s||e[18]!==i?(k=async()=>{const e={...s,runtime:{...s.runtime,auto_instantiate:!s.runtime.auto_instantiate}};await S({config:e}).then((()=>i(e)))},e[17]=s,e[18]=i,e[19]=k):k=e[19],e[20]===Symbol.for("react.memo_cache_sentinel")?(C=I.jsx("span",{children:"on startup: "}),e[20]=C):C=e[20],e[21]!==s.runtime.auto_instantiate?(E=s.runtime.auto_instantiate?I.jsx($d,{size:14}):I.jsx(Ud,{size:14}),e[21]=s.runtime.auto_instantiate,e[22]=E):E=e[22];const N=s.runtime.auto_instantiate?"autorun":"lazy";let A,T,M,D;e[23]!==N?(A=I.jsx("span",{children:N}),e[23]=N,e[24]=A):A=e[24],e[25]!==E||e[26]!==A?(T=I.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[C,E,A]}),e[25]=E,e[26]=A,e[27]=T):T=e[27],e[28]!==w||e[29]!==k||e[30]!==T?(M=I.jsx(OT,{tooltip:w,selected:!1,onClick:k,children:T}),e[28]=w,e[29]=k,e[30]=T,e[31]=M):M=e[31],e[32]===Symbol.for("react.memo_cache_sentinel")?(D=I.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[32]=D):D=e[32];const O="autorun"===s.runtime.on_cell_change?"Disable autorun":"Enable autorun";let R,P,L,z,F,B,U,$,H,V;return e[33]!==s||e[34]!==i?(R=async()=>{const e={...s,runtime:{...s.runtime,on_cell_change:"autorun"===s.runtime.on_cell_change?"lazy":"autorun"}};await S({config:e}).then((()=>i(e)))},e[33]=s,e[34]=i,e[35]=R):R=e[35],e[36]===Symbol.for("react.memo_cache_sentinel")?(P=I.jsx("span",{children:"on cell change: "}),e[36]=P):P=e[36],e[37]!==s.runtime.on_cell_change?(L=I.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[P,"autorun"===s.runtime.on_cell_change?I.jsx($d,{size:14}):I.jsx(Ud,{size:14}),I.jsx("span",{children:s.runtime.on_cell_change})]}),e[37]=s.runtime.on_cell_change,e[38]=L):L=e[38],e[39]!==O||e[40]!==R||e[41]!==L?(z=I.jsx(OT,{tooltip:O,selected:!1,onClick:R,children:L}),e[39]=O,e[40]=R,e[41]=L,e[42]=z):z=e[42],e[43]===Symbol.for("react.memo_cache_sentinel")?(F=I.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[43]=F):F=e[43],e[44]!==s||e[45]!==i?(B=!_()&&I.jsx(OT,{tooltip:null,selected:!1,children:I.jsxs(cn,{children:[I.jsxs(nn,{className:"font-prose text-sm flex items-center gap-1",children:[I.jsx("span",{children:"on module change: "}),"off"===s.runtime.auto_reload&&I.jsx(Ol,{size:14}),"lazy"===s.runtime.auto_reload&&I.jsx(Ud,{size:14}),"autorun"===s.runtime.auto_reload&&I.jsx($d,{size:14}),I.jsx("span",{children:s.runtime.auto_reload}),I.jsx(Se,{size:14})]}),I.jsx(dn,{children:["off","lazy","autorun"].map((e=>I.jsxs(tn,{onClick:async()=>{const t={...s,runtime:{...s.runtime,auto_reload:e}};await S({config:t}).then((()=>i(t)))},children:["off"===e&&I.jsx(Ol,{size:14,className:"mr-2 text-muted-foreground"}),"lazy"===e&&I.jsx(Ud,{size:14,className:"mr-2 text-muted-foreground"}),"autorun"===e&&I.jsx($d,{size:14,className:"mr-2 text-muted-foreground"}),e]},e)))})]})}),e[44]=s,e[45]=i,e[46]=B):B=e[46],e[47]===Symbol.for("react.memo_cache_sentinel")?(U=I.jsx("div",{className:"mx-auto"}),e[47]=U):U=e[47],e[48]===Symbol.for("react.memo_cache_sentinel")?($=I.jsx(df,{children:I.jsx(it,{content:I.jsx("div",{className:"w-[200px]",children:"Kiosk mode is enabled. This allows you to view the outputs of the cells without the ability to edit them."}),children:I.jsx("span",{className:"text-muted-foreground text-sm mr-4",children:"kiosk mode"})})}),H=I.jsx(BT,{}),e[48]=$,e[49]=H):($=e[48],H=e[49]),e[50]!==v||e[51]!==M||e[52]!==z||e[53]!==B||e[54]!==y?(V=I.jsxs("footer",{className:"h-10 py-2 bg-background flex items-center text-muted-foreground text-md pl-1 pr-4 border-t border-border select-none no-print text-sm shadow-[0_0_4px_1px_rgba(0,0,0,0.1)] z-50 print:hidden hide-on-fullscreen",children:[y,v,M,D,z,F,B,U,$,H]}),e[50]=v,e[51]=M,e[52]=z,e[53]=B,e[54]=y,e[55]=V):V=e[55],V};function JT(e,t){const{Icon:n}=e;return I.jsx(n,{className:In("h-5 w-5",t)})}function KT(e){return"errors"===e.type}const ZT=e=>{const t=j.c(6),{children:n}=e,{openModal:r,closeModal:o}=ie();let s,i;return t[0]!==o||t[1]!==r?(s=()=>r(I.jsx(QT,{onClose:o})),t[0]=o,t[1]=r,t[2]=s):s=t[2],t[3]!==n||t[4]!==s?(i=I.jsx(Ri,{onClick:s,children:n}),t[3]=n,t[4]=s,t[5]=i):i=t[5],i},QT=e=>{const t=j.c(9),{onClose:n}=e;let r,o,s,i,a,l,c;return t[0]!==n?(r=async e=>{e.preventDefault();const t=new FormData(e.target),r=t.get("rating"),o=t.get("message");fetch("https://marimo.io/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:r,message:o})}),n(),ee({title:"Feedback sent!",description:"Thank you for your feedback!"})},t[0]=n,t[1]=r):r=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(o=I.jsx(Te,{children:"Send Feedback"}),t[2]=o):o=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(s=I.jsx("p",{className:"my-2 prose dark:prose-invert",children:"We want to hear from you — from minor bug reports to wishlist features and everything in between. Here are some ways you can get in touch:"}),t[3]=s):s=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(i=I.jsxs("li",{className:"my-0",children:["Take our"," ",I.jsx("a",{href:Qe.feedbackForm,target:"_blank",rel:"noreferrer",className:"underline",children:"two-minute survey."})]}),t[4]=i):i=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(a=I.jsxs("li",{className:"my-0",children:["File a"," ",I.jsx("a",{href:Qe.issuesPage,target:"_blank",rel:"noreferrer",className:"underline",children:"GitHub issue."})]}),t[5]=a):a=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(l=I.jsxs(Ae,{children:[o,I.jsxs(et,{children:[s,I.jsxs("ul",{className:"list-disc ml-8 my-2 prose dark:prose-invert",children:[i,a,I.jsxs("li",{className:"my-0",children:["Chat with us on"," ",I.jsx("a",{href:Qe.discordLink,target:"_blank",rel:"noreferrer",className:"underline",children:"Discord."})]})]}),I.jsx("p",{className:"my-2 prose dark:prose-invert",children:"We're excited you're here as we build the future of Python data tooling. Thanks for being part of our community!"})]})]}),t[6]=l):l=t[6],t[7]!==r?(c=I.jsx(Ie,{className:"w-fit",children:I.jsx("form",{onSubmit:r,children:l})}),t[7]=r,t[8]=c):c=t[8],c},eM=()=>{const e=j.c(10),{selectedPanel:t}=Hu(),{openApplication:n}=Vu(),r=rM;let o,s,i,a,l,c;if(e[0]!==n||e[1]!==t){o="h-full pt-4 pb-1 px-1 flex flex-col items-start text-muted-foreground text-md select-none no-print text-sm z-50 dark:bg-background print:hidden hide-on-fullscreen",s=Wu.filter(oM).map((e=>I.jsx(nM,{tooltip:e.tooltip,selected:t===e.type,onClick:()=>n(e.type),children:r(e)},e.type))),e[0]=n,e[1]=t,e[2]=o,e[3]=s}else o=e[2],s=e[3];return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=I.jsx(ZT,{children:I.jsx(nM,{tooltip:"Send feedback!",selected:!1,children:I.jsx(cd,{className:"h-5 w-5"})})}),a=I.jsx("div",{className:"flex-1"}),l=I.jsx(tM,{}),e[4]=i,e[5]=a,e[6]=l):(i=e[4],a=e[5],l=e[6]),e[7]!==o||e[8]!==s?(c=I.jsxs("div",{className:o,children:[s,i,a,l]}),e[7]=o,e[8]=s,e[9]=c):c=e[9],c},tM=()=>{const e=j.c(9),t=se(Pi);let n,r,o,s;return e[0]!==t?(n=t>0?I.jsxs("span",{children:[t," cell",t>1?"s":""," queued or running"]}):"No cells queued or running",e[0]=t,e[1]=n):n=e[1],e[2]!==t?(r=Array.from({length:t}).map(sM),e[2]=t,e[3]=r):r=e[3],e[4]!==r?(o=I.jsx("div",{className:"flex flex-col-reverse gap-[1px] overflow-hidden",children:r}),e[4]=r,e[5]=o):o=e[5],e[6]!==n||e[7]!==o?(s=I.jsx(it,{content:n,side:"right",delayDuration:200,children:o}),e[6]=n,e[7]=o,e[8]=s):s=e[8],s},nM=e=>{const t=j.c(17);let n,r,o,s,i;t[0]!==e?(({children:n,tooltip:i,selected:s,className:r,...o}=e),t[0]=e,t[1]=n,t[2]=r,t[3]=o,t[4]=s,t[5]=i):(n=t[1],r=t[2],o=t[3],s=t[4],i=t[5]);const a=!s&&"hover:bg-[var(--sage-3)]",l=s&&"bg-[var(--sage-4)]";let c,d,u;return t[6]!==r||t[7]!==a||t[8]!==l?(c=In("flex items-center p-2 text-sm mx-[1px] shadow-inset font-mono cursor-pointer rounded",a,l,r),t[6]=r,t[7]=a,t[8]=l,t[9]=c):c=t[9],t[10]!==n||t[11]!==o||t[12]!==c?(d=I.jsx("div",{className:c,...o,children:n}),t[10]=n,t[11]=o,t[12]=c,t[13]=d):d=t[13],t[14]!==d||t[15]!==i?(u=I.jsx(it,{content:i,side:"right",delayDuration:200,children:d}),t[14]=d,t[15]=i,t[16]=u):u=t[16],u};function rM(e,t){const{Icon:n}=e;return I.jsx(n,{className:In("h-5 w-5",t)})}function oM(e){return!e.hidden&&"sidebar"===e.position}function sM(e,t){return I.jsx("div",{className:"flex-shrink-0 h-1 w-2 bg-[var(--grass-6)] border border-[var(--grass-7)]"},t.toString())}ft.record(ft.tuple([ft.number(),ft.number()]));let iM=null;const aM=e=>{const t=j.c(15),{title:n,description:r,icon:o,action:s}=e;let i,a,l,c,d,h;return t[0]!==o?(i=o&&u.cloneElement(o,{className:"text-accent-foreground"}),t[0]=o,t[1]=i):i=t[1],t[2]!==n?(a=I.jsx("span",{className:"mt-1 text-accent-foreground",children:n}),t[2]=n,t[3]=a):a=t[3],t[4]!==i||t[5]!==a?(l=I.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[i,a]}),t[4]=i,t[5]=a,t[6]=l):l=t[6],t[7]!==r?(c=I.jsx("span",{className:"text-muted-foreground text-sm",children:r}),t[7]=r,t[8]=c):c=t[8],t[9]!==s?(d=s&&I.jsx("div",{className:"mt-2",children:s}),t[9]=s,t[10]=d):d=t[10],t[11]!==l||t[12]!==c||t[13]!==d?(h=I.jsxs("div",{className:"mx-6 my-6 flex flex-col gap-2",children:[l,c,d]}),t[11]=l,t[12]=c,t[13]=d,t[14]=h):h=t[14],h},lM=()=>{const e=j.c(5),t=Li();if(0===t.length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx(aM,{title:"No errors!",icon:I.jsx(gd,{})}),e[0]=t):t=e[0],t}let n,r;return e[1]!==t?(n=t.map(cM),e[1]=t,e[2]=n):n=e[2],e[3]!==n?(r=I.jsx("div",{className:"flex flex-col overflow-auto",children:n}),e[3]=n,e[4]=r):r=e[4],r};function cM(e){return I.jsxs("div",{children:[I.jsx("div",{className:"text-xs font-mono font-semibold bg-muted border-y px-2 py-1",children:I.jsx(zi,{cellId:e.cellId})}),I.jsx("div",{className:"px-2",children:I.jsx(Fi,{errors:e.output.data,cellId:e.cellId},e.cellId)},e.cellId)]},e.cellId)}const dM=()=>{const e=j.c(6),{items:t}=se(Bi);let n,r;e[0]!==t?(r=hc(t),e[0]=t,e[1]=r):r=e[1],n=r;const o=n,{activeHeaderId:s}=fc(o);if(0===t.length){let t;return e[2]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx(aM,{title:"No outline",description:"Add markdown headings to your notebook to create an outline.",icon:I.jsx(Ed,{})}),e[2]=t):t=e[2],t}let i;return e[3]!==s||e[4]!==t?(i=I.jsx(pc,{items:t,activeHeaderId:s}),e[3]=s,e[4]=t,e[5]=i):i=e[5],i};function uM(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,r=0;r<e.length;r++)""!==(n=uM(e[r]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const{useDebugValue:hM}=u,{useSyncExternalStoreWithSelector:fM}=Ui,pM=e=>e;function mM(e,t=pM,n){const r=fM(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return hM(r),r}const gM=(e,t)=>{const n=$i(e),r=(e,r=t)=>mM(n,e,r);return Object.assign(r,n),r};function yM(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}function bM(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,[(r=r.matrixTransform(t.getScreenCTM().inverse())).x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const xM={passive:!1},vM={capture:!0,passive:!1};function wM(e){e.stopImmediatePropagation()}function kM(e){e.preventDefault(),e.stopImmediatePropagation()}function SM(e){var t=e.document.documentElement,n=bc(e).on("dragstart.drag",kM,vM);"onselectstart"in t?n.on("selectstart.drag",kM,vM):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function CM(e,t){var n=e.document.documentElement,r=bc(e).on("dragstart.drag",null);t&&(r.on("click.drag",kM,vM),setTimeout((function(){r.on("click.drag",null)}),0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const EM=e=>()=>e;function NM(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:s,x:i,y:a,dx:l,dy:c,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}function jM(e){return!e.ctrlKey&&!e.button}function _M(){return this.parentNode}function IM(e,t){return null==t?{x:e.x,y:e.y}:t}function AM(){return navigator.maxTouchPoints||"ontouchstart"in this}NM.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};const TM=e=>()=>e;function MM(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function DM(e){e.stopImmediatePropagation()}function OM(e){e.preventDefault(),e.stopImmediatePropagation()}function RM(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function PM(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function LM(){return this.__zoom||xc}function zM(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function FM(){return navigator.maxTouchPoints||"ontouchstart"in this}function BM(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}const UM=o.createContext(null),$M=UM.Provider,HM=e=>`Node type "${e}" not found. Using fallback type "default".`,VM=()=>"The React Flow parent container needs a width and a height to render the graph.",WM=()=>"Only child nodes can use a parent extent.",GM=e=>`Marker type "${e}" doesn't exist.`,qM=(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,YM=()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",XM=e=>`Edge type "${e}" not found. Using fallback type "default".`,JM=e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,KM=(()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001")();function ZM(e,t){const n=o.useContext(UM);if(null===n)throw new Error(KM);return mM(n,e,t)}const QM=()=>{const e=o.useContext(UM);if(null===e)throw new Error(KM);return o.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy})),[e])},eD=e=>e.userSelectionActive?"none":"all";function tD({position:e,children:t,className:n,style:r,...o}){const s=ZM(eD),i=`${e}`.split("-");return u.createElement("div",{className:uM(["react-flow__panel",n,...i]),style:{...r,pointerEvents:s},...o},t)}function nD({proOptions:e,position:t="bottom-right"}){return(null==e?void 0:e.hideAttribution)?null:u.createElement(tD,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},u.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}var rD=o.memo((({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:i={},labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...h})=>{const f=o.useRef(null),[p,m]=o.useState({x:0,y:0,width:0,height:0}),g=uM(["react-flow__edge-textwrapper",d]);return o.useEffect((()=>{if(f.current){const e=f.current.getBBox();m({x:e.x,y:e.y,width:e.width,height:e.height})}}),[n]),void 0!==n&&n?u.createElement("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:g,visibility:p.width?"visible":"hidden",...h},s&&u.createElement("rect",{width:p.width+2*a[0],x:-a[0],y:-a[1],height:p.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),u.createElement("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:f,style:r},n),c):null}));const oD=e=>({width:e.offsetWidth,height:e.offsetHeight}),sD=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),iD=(e={x:0,y:0},t)=>({x:sD(e.x,t[0][0],t[1][0]),y:sD(e.y,t[0][1],t[1][1])}),aD=(e,t,n)=>e<t?sD(Math.abs(e-t),1,50)/50:e>n?-sD(Math.abs(e-n),1,50)/50:0,lD=(e,t)=>[20*aD(e.x,35,t.width-35),20*aD(e.y,35,t.height-35)],cD=e=>{var t;return(null==(t=e.getRootNode)?void 0:t.call(e))||(null==window?void 0:window.document)},dD=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),uD=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),hD=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},fD=e=>!isNaN(e)&&isFinite(e),pD=Symbol.for("internals"),mD=["Enter"," ","Escape"];function gD(e){var t,n;const r=(e=>"nativeEvent"in e)(e)?e.nativeEvent:e,o=(null==(n=null==(t=r.composedPath)?void 0:t.call(r))?void 0:n[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(null==o?void 0:o.nodeName)||(null==o?void 0:o.hasAttribute("contenteditable"))||!!(null==o?void 0:o.closest(".nokey"))}const yD=e=>"clientX"in e,bD=(e,t)=>{var n,r;const o=yD(e),s=o?e.clientX:null==(n=e.touches)?void 0:n[0].clientX,i=o?e.clientY:null==(r=e.touches)?void 0:r[0].clientY;return{x:s-((null==t?void 0:t.left)??0),y:i-((null==t?void 0:t.top)??0)}},xD=()=>{var e;return"undefined"!=typeof navigator&&(null==(e=null==navigator?void 0:navigator.userAgent)?void 0:e.indexOf("Mac"))>=0},vD=({id:e,path:t,labelX:n,labelY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:p=20})=>u.createElement(u.Fragment,null,u.createElement("path",{id:e,style:d,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:f}),p&&u.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:p,className:"react-flow__edge-interaction"}),o&&fD(n)&&fD(r)?u.createElement(rD,{x:n,y:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null);function wD(e,t,n){return void 0===n?n:r=>{const o=t().edges.find((t=>t.id===e));o&&n(r,{...o})}}function kD({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,s=n<e?n+o:n-o,i=Math.abs(r-t)/2;return[s,r<t?r+i:r-i,o,i]}function SD({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:s,targetControlX:i,targetControlY:a}){const l=.125*e+.375*o+.375*i+.125*n,c=.125*t+.375*s+.375*a+.125*r;return[l,c,Math.abs(l-e),Math.abs(c-t)]}var CD,ED,ND,jD,_D,ID,AD,TD,MD,DD,OD,RD;function PD({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===OD.Left||e===OD.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function LD({sourceX:e,sourceY:t,sourcePosition:n=OD.Bottom,targetX:r,targetY:o,targetPosition:s=OD.Top}){const[i,a]=PD({pos:n,x1:e,y1:t,x2:r,y2:o}),[l,c]=PD({pos:s,x1:r,y1:o,x2:e,y2:t}),[d,u,h,f]=SD({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:i,sourceControlY:a,targetControlX:l,targetControlY:c});return[`M${e},${t} C${i},${a} ${l},${c} ${r},${o}`,d,u,h,f]}vD.displayName="BaseEdge",(ED=CD||(CD={})).Strict="strict",ED.Loose="loose",(jD=ND||(ND={})).Free="free",jD.Vertical="vertical",jD.Horizontal="horizontal",(ID=_D||(_D={})).Partial="partial",ID.Full="full",(TD=AD||(AD={})).Bezier="default",TD.Straight="straight",TD.Step="step",TD.SmoothStep="smoothstep",TD.SimpleBezier="simplebezier",(DD=MD||(MD={})).Arrow="arrow",DD.ArrowClosed="arrowclosed",(RD=OD||(OD={})).Left="left",RD.Top="top",RD.Right="right",RD.Bottom="bottom";const zD=o.memo((({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:o=OD.Bottom,targetPosition:s=OD.Top,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:g})=>{const[y,b,x]=LD({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:r,targetPosition:s});return u.createElement(vD,{path:y,labelX:b,labelY:x,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:g})}));zD.displayName="SimpleBezierEdge";const FD={[OD.Left]:{x:-1,y:0},[OD.Right]:{x:1,y:0},[OD.Top]:{x:0,y:-1},[OD.Bottom]:{x:0,y:1}},BD=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function UD({source:e,sourcePosition:t=OD.Bottom,target:n,targetPosition:r=OD.Top,center:o,offset:s}){const i=FD[t],a=FD[r],l={x:e.x+i.x*s,y:e.y+i.y*s},c={x:n.x+a.x*s,y:n.y+a.y*s},d=(({source:e,sourcePosition:t=OD.Bottom,target:n})=>t===OD.Left||t===OD.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1})({source:l,sourcePosition:t,target:c}),u=0!==d.x?"x":"y",h=d[u];let f,p,m=[];const g={x:0,y:0},y={x:0,y:0},[b,x,v,w]=kD({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[u]*a[u]==-1){f=o.x??b,p=o.y??x;const e=[{x:f,y:l.y},{x:f,y:c.y}],t=[{x:l.x,y:p},{x:c.x,y:p}];m=i[u]===h?"x"===u?e:t:"x"===u?t:e}else{const o=[{x:l.x,y:c.y}],d=[{x:c.x,y:l.y}];if(m="x"===u?i.x===h?d:o:i.y===h?o:d,t===r){const t=Math.abs(e[u]-n[u]);if(t<=s){const r=Math.min(s-1,s-t);i[u]===h?g[u]=(l[u]>e[u]?-1:1)*r:y[u]=(c[u]>n[u]?-1:1)*r}}if(t!==r){const e="x"===u?"y":"x",t=i[u]===a[e],n=l[e]>c[e],r=l[e]<c[e];(1===i[u]&&(!t&&n||t&&r)||1!==i[u]&&(!t&&r||t&&n))&&(m="x"===u?o:d)}const b={x:l.x+g.x,y:l.y+g.y},x={x:c.x+y.x,y:c.y+y.y};Math.max(Math.abs(b.x-m[0].x),Math.abs(x.x-m[0].x))>=Math.max(Math.abs(b.y-m[0].y),Math.abs(x.y-m[0].y))?(f=(b.x+x.x)/2,p=m[0].y):(f=m[0].x,p=(b.y+x.y)/2)}return[[e,{x:l.x+g.x,y:l.y+g.y},...m,{x:c.x+y.x,y:c.y+y.y},n],f,p,v,w]}function $D({sourceX:e,sourceY:t,sourcePosition:n=OD.Bottom,targetX:r,targetY:o,targetPosition:s=OD.Top,borderRadius:i=5,centerX:a,centerY:l,offset:c=20}){const[d,u,h,f,p]=UD({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:s,center:{x:a,y:l},offset:c});return[d.reduce(((e,t,n)=>{let r="";return r=n>0&&n<d.length-1?function(e,t,n,r){const o=Math.min(BD(e,t)/2,BD(t,n)/2,r),{x:s,y:i}=t;if(e.x===s&&s===n.x||e.y===i&&i===n.y)return`L${s} ${i}`;if(e.y===i)return`L ${s+o*(e.x<n.x?-1:1)},${i}Q ${s},${i} ${s},${i+o*(e.y<n.y?1:-1)}`;const a=e.x<n.x?1:-1;return`L ${s},${i+o*(e.y<n.y?-1:1)}Q ${s},${i} ${s+o*a},${i}`}(d[n-1],t,d[n+1],i):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=r}),""),u,h,f,p]}const HD=o.memo((({sourceX:e,sourceY:t,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,sourcePosition:h=OD.Bottom,targetPosition:f=OD.Top,markerEnd:p,markerStart:m,pathOptions:g,interactionWidth:y})=>{const[b,x,v]=$D({sourceX:e,sourceY:t,sourcePosition:h,targetX:n,targetY:r,targetPosition:f,borderRadius:null==g?void 0:g.borderRadius,offset:null==g?void 0:g.offset});return u.createElement(vD,{path:b,labelX:x,labelY:v,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:p,markerStart:m,interactionWidth:y})}));HD.displayName="SmoothStepEdge";const VD=o.memo((e=>{var t;return u.createElement(HD,{...e,pathOptions:o.useMemo((()=>{var t;return{borderRadius:0,offset:null==(t=e.pathOptions)?void 0:t.offset}}),[null==(t=e.pathOptions)?void 0:t.offset])})}));VD.displayName="StepEdge";const WD=o.memo((({sourceX:e,sourceY:t,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:p})=>{const[m,g,y]=function({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,s,i,a]=kD({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,s,i,a]}({sourceX:e,sourceY:t,targetX:n,targetY:r});return u.createElement(vD,{path:m,labelX:g,labelY:y,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:p})}));function GD(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function qD({pos:e,x1:t,y1:n,x2:r,y2:o,c:s}){switch(e){case OD.Left:return[t-GD(t-r,s),n];case OD.Right:return[t+GD(r-t,s),n];case OD.Top:return[t,n-GD(n-o,s)];case OD.Bottom:return[t,n+GD(o-n,s)]}}function YD({sourceX:e,sourceY:t,sourcePosition:n=OD.Bottom,targetX:r,targetY:o,targetPosition:s=OD.Top,curvature:i=.25}){const[a,l]=qD({pos:n,x1:e,y1:t,x2:r,y2:o,c:i}),[c,d]=qD({pos:s,x1:r,y1:o,x2:e,y2:t,c:i}),[u,h,f,p]=SD({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${r},${o}`,u,h,f,p]}WD.displayName="StraightEdge";const XD=o.memo((({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:o=OD.Bottom,targetPosition:s=OD.Top,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,pathOptions:g,interactionWidth:y})=>{const[b,x,v]=YD({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:r,targetPosition:s,curvature:null==g?void 0:g.curvature});return u.createElement(vD,{path:b,labelX:x,labelY:v,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:y})}));XD.displayName="BezierEdge";const JD=o.createContext(null),KD=JD.Provider;JD.Consumer;const ZD=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,QD=(e,t)=>{if(void 0===e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`},eO=({x:e,y:t},[n,r,o],s,[i,a])=>{const l={x:(e-n)/o,y:(t-r)/o};return s?{x:i*Math.round(l.x/i),y:a*Math.round(l.y/a)}:l},tO=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r}),nO=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],o={x:e.position.x-n,y:e.position.y-r};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:o}},rO=(e,t=[0,0])=>{if(0===e.length)return{x:0,y:0,width:0,height:0};return(({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}))(e.reduce(((e,n)=>{const{x:r,y:o}=nO(n,t).positionAbsolute;return s=e,i=dD({x:r,y:o,width:n.width||0,height:n.height||0}),{x:Math.min(s.x,i.x),y:Math.min(s.y,i.y),x2:Math.max(s.x2,i.x2),y2:Math.max(s.y2,i.y2)};var s,i}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0}))},oO=(e,t,[n,r,o]=[0,0,1],s=!1,i=!1,a=[0,0])=>{const l={x:(t.x-n)/o,y:(t.y-r)/o,width:t.width/o,height:t.height/o},c=[];return e.forEach((e=>{const{width:t,height:n,selectable:r=!0,hidden:o=!1}=e;if(i&&!r||o)return!1;const{positionAbsolute:d}=nO(e,a),u={x:d.x,y:d.y,width:t||0,height:n||0},h=hD(l,u);(void 0===t||void 0===n||null===t||null===n||s&&h>0||h>=(t||0)*(n||0)||e.dragging)&&c.push(e)})),c},sO=(e,t)=>{const n=e.map((e=>e.id));return t.filter((e=>n.includes(e.source)||n.includes(e.target)))},iO=(e,t,n,r,o,s=.1)=>{const i=t/(e.width*(1+s)),a=n/(e.height*(1+s)),l=Math.min(i,a),c=sD(l,r,o);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},aO=(e,t=0)=>e.transition().duration(t);function lO(e,t,n,r){return(t[n]||[]).reduce(((t,o)=>{var s,i;return`${e.id}-${o.id}-${n}`!==r&&t.push({id:o.id||null,type:n,nodeId:e.id,x:((null==(s=e.positionAbsolute)?void 0:s.x)??0)+o.x+o.width/2,y:((null==(i=e.positionAbsolute)?void 0:i.y)??0)+o.y+o.height/2}),t}),[])}const cO={source:null,target:null,sourceHandle:null,targetHandle:null},dO=()=>({handleDomNode:null,isValid:!1,connection:cO,endHandle:null});function uO(e,t,n,r,o,s,i){const a="target"===o,l=i.querySelector(`.react-flow__handle[data-id="${null==e?void 0:e.nodeId}-${null==e?void 0:e.id}-${null==e?void 0:e.type}"]`),c={...dO(),handleDomNode:l};if(l){const e=hO(void 0,l),o=l.getAttribute("data-nodeid"),i=l.getAttribute("data-handleid"),d=l.classList.contains("connectable"),u=l.classList.contains("connectableend"),h={source:a?o:n,sourceHandle:a?i:r,target:a?n:o,targetHandle:a?r:i};c.connection=h;d&&u&&(t===CD.Strict?a&&"source"===e||!a&&"target"===e:o!==n||i!==r)&&(c.endHandle={nodeId:o,handleId:i,type:e},c.isValid=s(h))}return c}function hO(e,t){return e||((null==t?void 0:t.classList.contains("target"))?"target":(null==t?void 0:t.classList.contains("source"))?"source":null)}function fO(e){null==e||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function pO(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function mO({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:o,getState:s,setState:i,isValidConnection:a,edgeUpdaterType:l,onReconnectEnd:c}){const d=cD(e.target),{connectionMode:u,domNode:h,autoPanOnConnect:f,connectionRadius:p,onConnectStart:m,panBy:g,getNodes:y,cancelConnection:b}=s();let x,v=0;const{x:w,y:k}=bD(e),S=null==d?void 0:d.elementFromPoint(w,k),C=hO(l,S),E=null==h?void 0:h.getBoundingClientRect();if(!E||!C)return;let N,j=bD(e,E),_=!1,I=null,A=!1,T=null;const M=function({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce(((e,o)=>{if(o[pD]){const{handleBounds:s}=o[pD];let i=[],a=[];s&&(i=lO(o,s,"source",`${t}-${n}-${r}`),a=lO(o,s,"target",`${t}-${n}-${r}`)),e.push(...i,...a)}return e}),[])}({nodes:y(),nodeId:n,handleId:t,handleType:C}),D=()=>{if(!f)return;const[e,t]=lD(j,E);g({x:e,y:t}),v=requestAnimationFrame(D)};function O(e){const{transform:r}=s();j=bD(e,E);const{handle:l,validHandleResult:c}=function(e,t,n,r,o,s){const{x:i,y:a}=bD(e),l=t.elementsFromPoint(i,a).find((e=>e.classList.contains("react-flow__handle")));if(l){const e=l.getAttribute("data-nodeid");if(e){const t=hO(void 0,l),r=l.getAttribute("data-handleid"),i=s({nodeId:e,id:r,type:t});if(i){const s=o.find((n=>n.nodeId===e&&n.type===t&&n.id===r));return{handle:{id:r,type:t,nodeId:e,x:(null==s?void 0:s.x)||n.x,y:(null==s?void 0:s.y)||n.y},validHandleResult:i}}}}let c=[],d=1/0;if(o.forEach((e=>{const t=Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2);if(t<=r){const n=s(e);t<=d&&(t<d?c=[{handle:e,validHandleResult:n}]:t===d&&c.push({handle:e,validHandleResult:n}),d=t)}})),!c.length)return{handle:null,validHandleResult:dO()};if(1===c.length)return c[0];const u=c.some((({validHandleResult:e})=>e.isValid)),h=c.some((({handle:e})=>"target"===e.type));return c.find((({handle:e,validHandleResult:t})=>h?"target"===e.type:!u||t.isValid))||c[0]}(e,d,eO(j,r,!1,[1,1]),p,M,(e=>uO(e,u,n,t,o?"target":"source",a,d)));if(x=l,_||(D(),_=!0),T=c.handleDomNode,I=c.connection,A=c.isValid,i({connectionPosition:x&&A?tO({x:x.x,y:x.y},r):j,connectionStatus:pO(!!x,A),connectionEndHandle:c.endHandle}),!x&&!A&&!T)return fO(N);I.source!==I.target&&T&&(fO(N),N=T,T.classList.add("connecting","react-flow__handle-connecting"),T.classList.toggle("valid",A),T.classList.toggle("react-flow__handle-valid",A))}function R(e){var t,n;(x||T)&&I&&A&&(null==r||r(I)),null==(n=(t=s()).onConnectEnd)||n.call(t,e),l&&(null==c||c(e)),fO(N),b(),cancelAnimationFrame(v),_=!1,A=!1,I=null,T=null,d.removeEventListener("mousemove",O),d.removeEventListener("mouseup",R),d.removeEventListener("touchmove",O),d.removeEventListener("touchend",R)}i({connectionPosition:j,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:C,connectionStartHandle:{nodeId:n,handleId:t,type:C},connectionEndHandle:null}),null==m||m(e,{nodeId:n,handleId:t,handleType:C}),d.addEventListener("mousemove",O),d.addEventListener("mouseup",R),d.addEventListener("touchmove",O),d.addEventListener("touchend",R)}const gO=()=>!0,yO=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),bO=o.forwardRef((({type:e="source",position:t=OD.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:c,className:d,onMouseDown:h,onTouchStart:f,...p},m)=>{var g,y;const b=a||null,x="target"===e,v=QM(),w=o.useContext(JD),{connectOnClick:k,noPanClassName:S}=ZM(yO,yM),{connecting:C,clickConnecting:E}=ZM(((e,t,n)=>r=>{const{connectionStartHandle:o,connectionEndHandle:s,connectionClickStartHandle:i}=r;return{connecting:(null==o?void 0:o.nodeId)===e&&(null==o?void 0:o.handleId)===t&&(null==o?void 0:o.type)===n||(null==s?void 0:s.nodeId)===e&&(null==s?void 0:s.handleId)===t&&(null==s?void 0:s.type)===n,clickConnecting:(null==i?void 0:i.nodeId)===e&&(null==i?void 0:i.handleId)===t&&(null==i?void 0:i.type)===n}})(w,b,e),yM);w||null==(y=(g=v.getState()).onError)||y.call(g,"010",YM());const N=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=v.getState(),o={...t,...e};if(r){const{edges:e,setEdges:t}=v.getState();t(((e,t)=>{if(!e.source||!e.target)return t;let n;var r;return n="id"in(r=e)&&"source"in r&&"target"in r?{...e}:{...e,id:ZD(e)},((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourceHandle!==e.sourceHandle&&(t.sourceHandle||e.sourceHandle)||t.targetHandle!==e.targetHandle&&(t.targetHandle||e.targetHandle)))))(n,t)?t:t.concat(n)})(o,e))}null==n||n(o),null==l||l(o)},j=e=>{if(!w)return;const t=yD(e);s&&(t&&0===e.button||!t)&&mO({event:e,handleId:b,nodeId:w,onConnect:N,isTarget:x,getState:v.getState,setState:v.setState,isValidConnection:n||v.getState().isValidConnection||gO}),t?null==h||h(e):null==f||f(e)};return u.createElement("div",{"data-handleid":b,"data-nodeid":w,"data-handlepos":t,"data-id":`${w}-${b}-${e}`,className:uM(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,d,{source:!x,target:x,connectable:r,connectablestart:s,connectableend:i,connecting:E,connectionindicator:r&&(s&&!C||i&&C)}]),onMouseDown:j,onTouchStart:j,onClick:k?t=>{const{onClickConnectStart:r,onClickConnectEnd:o,connectionClickStartHandle:i,connectionMode:a,isValidConnection:l}=v.getState();if(!w||!i&&!s)return;if(!i)return null==r||r(t,{nodeId:w,handleId:b,handleType:e}),void v.setState({connectionClickStartHandle:{nodeId:w,type:e,handleId:b}});const c=cD(t.target),d=n||l||gO,{connection:u,isValid:h}=uO({nodeId:w,id:b,type:e},a,i.nodeId,i.handleId||null,i.type,d,c);h&&N(u),null==o||o(t),v.setState({connectionClickStartHandle:null})}:void 0,ref:m,...p},c)}));bO.displayName="Handle";var xO=o.memo(bO);const vO=({data:e,isConnectable:t,targetPosition:n=OD.Top,sourcePosition:r=OD.Bottom})=>u.createElement(u.Fragment,null,u.createElement(xO,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label,u.createElement(xO,{type:"source",position:r,isConnectable:t}));vO.displayName="DefaultNode";var wO=o.memo(vO);const kO=({data:e,isConnectable:t,sourcePosition:n=OD.Bottom})=>u.createElement(u.Fragment,null,null==e?void 0:e.label,u.createElement(xO,{type:"source",position:n,isConnectable:t}));kO.displayName="InputNode";var SO=o.memo(kO);const CO=({data:e,isConnectable:t,targetPosition:n=OD.Top})=>u.createElement(u.Fragment,null,u.createElement(xO,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label);CO.displayName="OutputNode";var EO=o.memo(CO);const NO=()=>null;NO.displayName="GroupNode";const jO=e=>({selectedNodes:e.getNodes().filter((e=>e.selected)),selectedEdges:e.edges.filter((e=>e.selected)).map((e=>({...e})))}),_O=e=>e.id;function IO(e,t){return yM(e.selectedNodes.map(_O),t.selectedNodes.map(_O))&&yM(e.selectedEdges.map(_O),t.selectedEdges.map(_O))}const AO=o.memo((({onSelectionChange:e})=>{const t=QM(),{selectedNodes:n,selectedEdges:r}=ZM(jO,IO);return o.useEffect((()=>{const o={nodes:n,edges:r};null==e||e(o),t.getState().onSelectionChange.forEach((e=>e(o)))}),[n,r,e]),null}));AO.displayName="SelectionListener";const TO=e=>!!e.onSelectionChange;function MO({onSelectionChange:e}){const t=ZM(TO);return e||t?u.createElement(AO,{onSelectionChange:e}):null}const DO=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function OO(e,t){o.useEffect((()=>{void 0!==e&&t(e)}),[e])}function RO(e,t,n){o.useEffect((()=>{void 0!==t&&n({[e]:t})}),[t])}const PO=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:i,onConnectEnd:a,onClickConnectStart:l,onClickConnectEnd:c,nodesDraggable:d,nodesConnectable:u,nodesFocusable:h,edgesFocusable:f,edgesUpdatable:p,elevateNodesOnSelect:m,minZoom:g,maxZoom:y,nodeExtent:b,onNodesChange:x,onEdgesChange:v,elementsSelectable:w,connectionMode:k,snapGrid:S,snapToGrid:C,translateExtent:E,connectOnClick:N,defaultEdgeOptions:j,fitView:_,fitViewOptions:I,onNodesDelete:A,onEdgesDelete:T,onNodeDrag:M,onNodeDragStart:D,onNodeDragStop:O,onSelectionDrag:R,onSelectionDragStart:P,onSelectionDragStop:L,noPanClassName:z,nodeOrigin:F,rfId:B,autoPanOnConnect:U,autoPanOnNodeDrag:$,onError:H,connectionRadius:V,isValidConnection:W,nodeDragThreshold:G})=>{const{setNodes:q,setEdges:Y,setDefaultNodesAndEdges:X,setMinZoom:J,setMaxZoom:K,setTranslateExtent:Z,setNodeExtent:Q,reset:ee}=ZM(DO,yM),te=QM();return o.useEffect((()=>{const e=null==r?void 0:r.map((e=>({...e,...j})));return X(n,e),()=>{ee()}}),[]),RO("defaultEdgeOptions",j,te.setState),RO("connectionMode",k,te.setState),RO("onConnect",s,te.setState),RO("onConnectStart",i,te.setState),RO("onConnectEnd",a,te.setState),RO("onClickConnectStart",l,te.setState),RO("onClickConnectEnd",c,te.setState),RO("nodesDraggable",d,te.setState),RO("nodesConnectable",u,te.setState),RO("nodesFocusable",h,te.setState),RO("edgesFocusable",f,te.setState),RO("edgesUpdatable",p,te.setState),RO("elementsSelectable",w,te.setState),RO("elevateNodesOnSelect",m,te.setState),RO("snapToGrid",C,te.setState),RO("snapGrid",S,te.setState),RO("onNodesChange",x,te.setState),RO("onEdgesChange",v,te.setState),RO("connectOnClick",N,te.setState),RO("fitViewOnInit",_,te.setState),RO("fitViewOnInitOptions",I,te.setState),RO("onNodesDelete",A,te.setState),RO("onEdgesDelete",T,te.setState),RO("onNodeDrag",M,te.setState),RO("onNodeDragStart",D,te.setState),RO("onNodeDragStop",O,te.setState),RO("onSelectionDrag",R,te.setState),RO("onSelectionDragStart",P,te.setState),RO("onSelectionDragStop",L,te.setState),RO("noPanClassName",z,te.setState),RO("nodeOrigin",F,te.setState),RO("rfId",B,te.setState),RO("autoPanOnConnect",U,te.setState),RO("autoPanOnNodeDrag",$,te.setState),RO("onError",H,te.setState),RO("connectionRadius",V,te.setState),RO("isValidConnection",W,te.setState),RO("nodeDragThreshold",G,te.setState),OO(e,q),OO(t,Y),OO(g,J),OO(y,K),OO(E,Z),OO(b,Q),null},LO={display:"none"},zO={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},FO="react-flow__node-desc",BO="react-flow__edge-desc",UO=e=>e.ariaLiveMessage;function $O({rfId:e}){const t=ZM(UO);return u.createElement("div",{id:`react-flow__aria-live-${e}`,"aria-live":"assertive","aria-atomic":"true",style:zO},t)}function HO({rfId:e,disableKeyboardA11y:t}){return u.createElement(u.Fragment,null,u.createElement("div",{id:`${FO}-${e}`,style:LO},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),u.createElement("div",{id:`${BO}-${e}`,style:LO},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&u.createElement($O,{rfId:e}))}var VO=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=o.useState(!1),s=o.useRef(!1),i=o.useRef(new Set([])),[a,l]=o.useMemo((()=>{if(null!==e){const t=(Array.isArray(e)?e:[e]).filter((e=>"string"==typeof e)).map((e=>e.split("+"))),n=t.reduce(((e,t)=>e.concat(...t)),[]);return[t,n]}return[[],[]]}),[e]);return o.useEffect((()=>{const n="undefined"!=typeof document?document:null,o=(null==t?void 0:t.target)||n;if(null!==e){const e=e=>{s.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!s.current||s.current&&!t.actInsideInputWithModifier)&&gD(e))return!1;const n=GO(e.code,l);i.current.add(e[n]),WO(a,i.current,!1)&&(e.preventDefault(),r(!0))},n=e=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&gD(e))return!1;const n=GO(e.code,l);WO(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(e[n]),"Meta"===e.key&&i.current.clear(),s.current=!1},c=()=>{i.current.clear(),r(!1)};return null==o||o.addEventListener("keydown",e),null==o||o.addEventListener("keyup",n),window.addEventListener("blur",c),()=>{null==o||o.removeEventListener("keydown",e),null==o||o.removeEventListener("keyup",n),window.removeEventListener("blur",c)}}}),[e,r]),n};function WO(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function GO(e,t){return t.includes(e)?"code":"key"}function qO(e,t,n,r){var o,s;const i=e.parentNode||e.parentId;if(!i)return n;const a=t.get(i),l=nO(a,r);return qO(a,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:((null==(o=a[pD])?void 0:o.z)??0)>(n.z??0)?(null==(s=a[pD])?void 0:s.z)??0:n.z??0},r)}function YO(e,t,n){e.forEach((r=>{var o;const s=r.parentNode||r.parentId;if(s&&!e.has(s))throw new Error(`Parent node ${s} not found`);if(s||(null==n?void 0:n[r.id])){const{x:s,y:i,z:a}=qO(r,e,{...r.position,z:(null==(o=r[pD])?void 0:o.z)??0},t);r.positionAbsolute={x:s,y:i},r[pD].z=a,(null==n?void 0:n[r.id])&&(r[pD].isParent=!0)}}))}function XO(e,t,n,r){const o=new Map,s={},i=r?1e3:0;return e.forEach((e=>{var n;const r=(fD(e.zIndex)?e.zIndex:0)+(e.selected?i:0),a=t.get(e.id),l={...e,positionAbsolute:{x:e.position.x,y:e.position.y}},c=e.parentNode||e.parentId;c&&(s[c]=!0);const d=(null==a?void 0:a.type)&&(null==a?void 0:a.type)!==e.type;Object.defineProperty(l,pD,{enumerable:!1,value:{handleBounds:d||null==(n=null==a?void 0:a[pD])?void 0:n.handleBounds,z:r}}),o.set(e.id,l)})),YO(o,n,s),o}function JO(e,t={}){const{getNodes:n,width:r,height:o,minZoom:s,maxZoom:i,d3Zoom:a,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:d,nodeOrigin:u}=e(),h=t.initial&&!c&&d;if(a&&l&&(h||!t.initial)){const e=n().filter((e=>{var n;const r=t.includeHiddenNodes?e.width&&e.height:!e.hidden;return(null==(n=t.nodes)?void 0:n.length)?r&&t.nodes.some((t=>t.id===e.id)):r})),c=e.every((e=>e.width&&e.height));if(e.length>0&&c){const n=rO(e,u),{x:c,y:d,zoom:h}=iO(n,r,o,t.minZoom??s,t.maxZoom??i,t.padding??.1),f=xc.translate(c,d).scale(h);return"number"==typeof t.duration&&t.duration>0?a.transform(aO(l,t.duration),f):a.transform(l,f),!0}}return!1}function KO(e,t){return e.forEach((e=>{const n=t.get(e.id);n&&t.set(n.id,{...n,[pD]:n[pD],selected:e.selected})})),new Map(t)}function ZO(e,t){return t.map((t=>{const n=e.find((e=>e.id===t.id));return n&&(t.selected=n.selected),t}))}function QO({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:o,edges:s,onNodesChange:i,onEdgesChange:a,hasDefaultNodes:l,hasDefaultEdges:c}=n();(null==e?void 0:e.length)&&(l&&r({nodeInternals:KO(e,o)}),null==i||i(e)),(null==t?void 0:t.length)&&(c&&r({edges:ZO(t,s)}),null==a||a(t))}const eR=()=>{},tR={zoomIn:eR,zoomOut:eR,zoomTo:eR,getZoom:()=>1,setViewport:eR,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:eR,fitBounds:eR,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},nR=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection});function rR(){const e=(()=>{const e=QM(),{d3Zoom:t,d3Selection:n}=ZM(nR,yM),r=o.useMemo((()=>n&&t?{zoomIn:e=>t.scaleBy(aO(n,null==e?void 0:e.duration),1.2),zoomOut:e=>t.scaleBy(aO(n,null==e?void 0:e.duration),1/1.2),zoomTo:(e,r)=>t.scaleTo(aO(n,null==r?void 0:r.duration),e),getZoom:()=>e.getState().transform[2],setViewport:(r,o)=>{const[s,i,a]=e.getState().transform,l=xc.translate(r.x??s,r.y??i).scale(r.zoom??a);t.transform(aO(n,null==o?void 0:o.duration),l)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},fitView:t=>JO(e.getState,t),setCenter:(r,o,s)=>{const{width:i,height:a,maxZoom:l}=e.getState(),c=void 0!==(null==s?void 0:s.zoom)?s.zoom:l,d=i/2-r*c,u=a/2-o*c,h=xc.translate(d,u).scale(c);t.transform(aO(n,null==s?void 0:s.duration),h)},fitBounds:(r,o)=>{const{width:s,height:i,minZoom:a,maxZoom:l}=e.getState(),{x:c,y:d,zoom:u}=iO(r,s,i,a,l,(null==o?void 0:o.padding)??.1),h=xc.translate(c,d).scale(u);t.transform(aO(n,null==o?void 0:o.duration),h)},project:t=>{const{transform:n,snapToGrid:r,snapGrid:o}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),eO(t,n,r,o)},screenToFlowPosition:t=>{const{transform:n,snapToGrid:r,snapGrid:o,domNode:s}=e.getState();if(!s)return t;const{x:i,y:a}=s.getBoundingClientRect(),l={x:t.x-i,y:t.y-a};return eO(l,n,r,o)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:s}=r.getBoundingClientRect(),i=tO(t,n);return{x:i.x+o,y:i.y+s}},viewportInitialized:!0}:tR),[t,n]);return r})(),t=QM(),n=o.useCallback((()=>t.getState().getNodes().map((e=>({...e})))),[]),r=o.useCallback((e=>t.getState().nodeInternals.get(e)),[]),s=o.useCallback((()=>{const{edges:e=[]}=t.getState();return e.map((e=>({...e})))}),[]),i=o.useCallback((e=>{const{edges:n=[]}=t.getState();return n.find((t=>t.id===e))}),[]),a=o.useCallback((e=>{const{getNodes:n,setNodes:r,hasDefaultNodes:o,onNodesChange:s}=t.getState(),i=n(),a="function"==typeof e?e(i):e;if(o)r(a);else if(s){s(0===a.length?i.map((e=>({type:"remove",id:e.id}))):a.map((e=>({item:e,type:"reset"}))))}}),[]),l=o.useCallback((e=>{const{edges:n=[],setEdges:r,hasDefaultEdges:o,onEdgesChange:s}=t.getState(),i="function"==typeof e?e(n):e;if(o)r(i);else if(s){s(0===i.length?n.map((e=>({type:"remove",id:e.id}))):i.map((e=>({item:e,type:"reset"}))))}}),[]),c=o.useCallback((e=>{const n=Array.isArray(e)?e:[e],{getNodes:r,setNodes:o,hasDefaultNodes:s,onNodesChange:i}=t.getState();if(s){o([...r(),...n])}else if(i){i(n.map((e=>({item:e,type:"add"}))))}}),[]),d=o.useCallback((e=>{const n=Array.isArray(e)?e:[e],{edges:r=[],setEdges:o,hasDefaultEdges:s,onEdgesChange:i}=t.getState();if(s)o([...r,...n]);else if(i){i(n.map((e=>({item:e,type:"add"}))))}}),[]),u=o.useCallback((()=>{const{getNodes:e,edges:n=[],transform:r}=t.getState(),[o,s,i]=r;return{nodes:e().map((e=>({...e}))),edges:n.map((e=>({...e}))),viewport:{x:o,y:s,zoom:i}}}),[]),h=o.useCallback((({nodes:e,edges:n})=>{const{nodeInternals:r,getNodes:o,edges:s,hasDefaultNodes:i,hasDefaultEdges:a,onNodesDelete:l,onEdgesDelete:c,onNodesChange:d,onEdgesChange:u}=t.getState(),h=(e||[]).map((e=>e.id)),f=(n||[]).map((e=>e.id)),p=o().reduce(((e,t)=>{const n=t.parentNode||t.parentId,r=!h.includes(t.id)&&n&&e.find((e=>e.id===n));return("boolean"!=typeof t.deletable||t.deletable)&&(h.includes(t.id)||r)&&e.push(t),e}),[]),m=s.filter((e=>"boolean"!=typeof e.deletable||e.deletable)),g=m.filter((e=>f.includes(e.id)));if(p||g){const e=sO(p,m),n=[...g,...e],o=n.reduce(((e,t)=>(e.includes(t.id)||e.push(t.id),e)),[]);if((a||i)&&(a&&t.setState({edges:s.filter((e=>!o.includes(e.id)))}),i&&(p.forEach((e=>{r.delete(e.id)})),t.setState({nodeInternals:new Map(r)}))),o.length>0&&(null==c||c(n),u&&u(o.map((e=>({id:e,type:"remove"}))))),p.length>0&&(null==l||l(p),d)){d(p.map((e=>({id:e.id,type:"remove"}))))}}}),[]),f=o.useCallback((e=>{const n=fD((r=e).width)&&fD(r.height)&&fD(r.x)&&fD(r.y);var r;const o=n?null:t.getState().nodeInternals.get(e.id);if(!n&&!o)return[null,null,n];return[n?e:uD(o),o,n]}),[]),p=o.useCallback(((e,n=!0,r)=>{const[o,s,i]=f(e);return o?(r||t.getState().getNodes()).filter((e=>{if(!(i||e.id!==s.id&&e.positionAbsolute))return!1;const t=uD(e),r=hD(t,o);return n&&r>0||r>=o.width*o.height})):[]}),[]),m=o.useCallback(((e,t,n=!0)=>{const[r]=f(e);if(!r)return!1;const o=hD(r,t);return n&&o>0||o>=r.width*r.height}),[]);return o.useMemo((()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:i,setNodes:a,setEdges:l,addNodes:c,addEdges:d,toObject:u,deleteElements:h,getIntersectingNodes:p,isNodeIntersecting:m})),[e,n,r,s,i,a,l,c,d,u,h,p,m])}const oR={actInsideInputWithModifier:!1};const sR={position:"absolute",width:"100%",height:"100%",top:0,left:0},iR=e=>({x:e.x,y:e.y,zoom:e.k}),aR=(e,t)=>e.target.closest(`.${t}`),lR=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),cR=e=>{const t=e.ctrlKey&&xD()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t},dR=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),uR=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:i=!0,panOnScroll:a=!1,panOnScrollSpeed:l=.5,panOnScrollMode:c=ND.Free,zoomOnDoubleClick:d=!0,elementsSelectable:h,panOnDrag:f=!0,defaultViewport:p,translateExtent:m,minZoom:g,maxZoom:y,zoomActivationKeyCode:b,preventScrolling:x=!0,children:v,noWheelClassName:w,noPanClassName:k})=>{const S=o.useRef(),C=QM(),E=o.useRef(!1),N=o.useRef(!1),j=o.useRef(null),_=o.useRef({x:0,y:0,zoom:0}),{d3Zoom:I,d3Selection:A,d3ZoomHandler:T,userSelectionActive:M}=ZM(dR,yM),D=VO(b),O=o.useRef(0),R=o.useRef(!1),P=o.useRef();return function(e){const t=QM();o.useEffect((()=>{let n;const r=()=>{var n,r;if(!e.current)return;const o=oD(e.current);0!==o.height&&0!==o.width||null==(r=(n=t.getState()).onError)||r.call(n,"004",VM()),t.setState({width:o.width||500,height:o.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver((()=>r())),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}}),[])}(j),o.useEffect((()=>{if(j.current){const e=j.current.getBoundingClientRect(),t=function(){var e,t,n,r=RM,o=PM,s=BM,i=zM,a=FM,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,u=Sc,h=kc("start","zoom","end"),f=0,p=10;function m(e){e.property("__zoom",LM).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",C).filter(a).on("touchstart.zoom",E).on("touchmove.zoom",N).on("touchend.zoom touchcancel.zoom",j).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(e,t){return(t=Math.max(l[0],Math.min(l[1],t)))===e.k?e:new vc(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,o=t[1]-n[1]*e.k;return r===e.x&&o===e.y?e:new vc(e.k,r,o)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,t,n,r){e.on("start.zoom",(function(){v(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){v(this,arguments).event(r).end()})).tween("zoom",(function(){var e=this,s=arguments,i=v(e,s).event(r),a=o.apply(e,s),l=null==n?b(a):"function"==typeof n?n.apply(e,s):n,c=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),d=e.__zoom,h="function"==typeof t?t.apply(e,s):t,f=u(d.invert(l).concat(c/d.k),h.invert(l).concat(c/h.k));return function(e){if(1===e)e=h;else{var t=f(e),n=c/t[2];e=new vc(n,l[0]-t[0]*n,l[1]-t[1]*n)}i.zoom(null,e)}}))}function v(e,t,n){return!n&&e.__zooming||new w(e,t)}function w(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=o.apply(e,t),this.taps=0}function k(e,...t){if(r.apply(this,arguments)){var n=v(this,t).event(e),o=this.__zoom,a=Math.max(l[0],Math.min(l[1],o.k*Math.pow(2,i.apply(this,arguments)))),d=bM(e);if(n.wheel)n.mouse[0][0]===d[0]&&n.mouse[0][1]===d[1]||(n.mouse[1]=o.invert(n.mouse[0]=d)),clearTimeout(n.wheel);else{if(o.k===a)return;n.mouse=[d,o.invert(d)],wc(this),n.start()}OM(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),150),n.zoom("mouse",s(y(g(o,a),n.mouse[0],n.mouse[1]),n.extent,c))}}function S(e,...t){if(!n&&r.apply(this,arguments)){var o=e.currentTarget,i=v(this,t,!0).event(e),a=bc(e.view).on("mousemove.zoom",(function(e){if(OM(e),!i.moved){var t=e.clientX-d,n=e.clientY-u;i.moved=t*t+n*n>f}i.event(e).zoom("mouse",s(y(i.that.__zoom,i.mouse[0]=bM(e,o),i.mouse[1]),i.extent,c))}),!0).on("mouseup.zoom",(function(e){a.on("mousemove.zoom mouseup.zoom",null),CM(e.view,i.moved),OM(e),i.event(e).end()}),!0),l=bM(e,o),d=e.clientX,u=e.clientY;SM(e.view),DM(e),i.mouse=[l,this.__zoom.invert(l)],wc(this),i.start()}}function C(e,...t){if(r.apply(this,arguments)){var n=this.__zoom,i=bM(e.changedTouches?e.changedTouches[0]:e,this),a=n.invert(i),l=n.k*(e.shiftKey?.5:2),u=s(y(g(n,l),i,a),o.apply(this,t),c);OM(e),d>0?bc(this).transition().duration(d).call(x,u,i,e):bc(this).call(m.transform,u,i,e)}}function E(n,...o){if(r.apply(this,arguments)){var s,i,a,l,c=n.touches,d=c.length,u=v(this,o,n.changedTouches.length===d).event(n);for(DM(n),i=0;i<d;++i)l=[l=bM(a=c[i],this),this.__zoom.invert(l),a.identifier],u.touch0?u.touch1||u.touch0[2]===l[2]||(u.touch1=l,u.taps=0):(u.touch0=l,s=!0,u.taps=1+!!e);e&&(e=clearTimeout(e)),s&&(u.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),500)),wc(this),u.start())}}function N(e,...t){if(this.__zooming){var n,r,o,i,a=v(this,t).event(e),l=e.changedTouches,d=l.length;for(OM(e),n=0;n<d;++n)o=bM(r=l[n],this),a.touch0&&a.touch0[2]===r.identifier?a.touch0[0]=o:a.touch1&&a.touch1[2]===r.identifier&&(a.touch1[0]=o);if(r=a.that.__zoom,a.touch1){var u=a.touch0[0],h=a.touch0[1],f=a.touch1[0],p=a.touch1[1],m=(m=f[0]-u[0])*m+(m=f[1]-u[1])*m,b=(b=p[0]-h[0])*b+(b=p[1]-h[1])*b;r=g(r,Math.sqrt(m/b)),o=[(u[0]+f[0])/2,(u[1]+f[1])/2],i=[(h[0]+p[0])/2,(h[1]+p[1])/2]}else{if(!a.touch0)return;o=a.touch0[0],i=a.touch0[1]}a.zoom("touch",s(y(r,o,i),a.extent,c))}}function j(e,...r){if(this.__zooming){var o,s,i=v(this,r).event(e),a=e.changedTouches,l=a.length;for(DM(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),500),o=0;o<l;++o)s=a[o],i.touch0&&i.touch0[2]===s.identifier?delete i.touch0:i.touch1&&i.touch1[2]===s.identifier&&delete i.touch1;if(i.touch1&&!i.touch0&&(i.touch0=i.touch1,delete i.touch1),i.touch0)i.touch0[1]=this.__zoom.invert(i.touch0[0]);else if(i.end(),2===i.taps&&(s=bM(s,this),Math.hypot(t[0]-s[0],t[1]-s[1])<p)){var c=bc(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return m.transform=function(e,t,n,r){var o=e.selection?e.selection():e;o.property("__zoom",LM),e!==o?x(e,t,n,r):o.interrupt().each((function(){v(this,arguments).event(r).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},m.scaleBy=function(e,t,n,r){m.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,r)},m.scaleTo=function(e,t,n,r){m.transform(e,(function(){var e=o.apply(this,arguments),r=this.__zoom,i=null==n?b(e):"function"==typeof n?n.apply(this,arguments):n,a=r.invert(i),l="function"==typeof t?t.apply(this,arguments):t;return s(y(g(r,l),i,a),e,c)}),n,r)},m.translateBy=function(e,t,n,r){m.transform(e,(function(){return s(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),o.apply(this,arguments),c)}),null,r)},m.translateTo=function(e,t,n,r,i){m.transform(e,(function(){var e=o.apply(this,arguments),i=this.__zoom,a=null==r?b(e):"function"==typeof r?r.apply(this,arguments):r;return s(xc.translate(a[0],a[1]).scale(i.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,c)}),r,i)},w.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=bc(this.that).datum();h.call(e,this.that,new MM(e,{sourceEvent:this.sourceEvent,target:m,type:e,transform:this.that.__zoom,dispatch:h}),t)}},m.wheelDelta=function(e){return arguments.length?(i="function"==typeof e?e:TM(+e),m):i},m.filter=function(e){return arguments.length?(r="function"==typeof e?e:TM(!!e),m):r},m.touchable=function(e){return arguments.length?(a="function"==typeof e?e:TM(!!e),m):a},m.extent=function(e){return arguments.length?(o="function"==typeof e?e:TM([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),m):o},m.scaleExtent=function(e){return arguments.length?(l[0]=+e[0],l[1]=+e[1],m):[l[0],l[1]]},m.translateExtent=function(e){return arguments.length?(c[0][0]=+e[0][0],c[1][0]=+e[1][0],c[0][1]=+e[0][1],c[1][1]=+e[1][1],m):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},m.constrain=function(e){return arguments.length?(s=e,m):s},m.duration=function(e){return arguments.length?(d=+e,m):d},m.interpolate=function(e){return arguments.length?(u=e,m):u},m.on=function(){var e=h.on.apply(h,arguments);return e===h?m:e},m.clickDistance=function(e){return arguments.length?(f=(e=+e)*e,m):Math.sqrt(f)},m.tapDistance=function(e){return arguments.length?(p=+e,m):p},m}().scaleExtent([g,y]).translateExtent(m),n=bc(j.current).call(t),r=xc.translate(p.x,p.y).scale(sD(p.zoom,g,y)),o=[[0,0],[e.width,e.height]],s=t.constrain()(r,o,m);t.transform(n,s),t.wheelDelta(cR),C.setState({d3Zoom:t,d3Selection:n,d3ZoomHandler:n.on("wheel.zoom"),transform:[s.x,s.y,s.k],domNode:j.current.closest(".react-flow")})}}),[]),o.useEffect((()=>{A&&I&&(!a||D||M?void 0!==T&&A.on("wheel.zoom",(function(e,t){if(!x&&"wheel"===e.type&&!e.ctrlKey||aR(e,w))return null;e.preventDefault(),T.call(this,e,t)}),{passive:!1}):A.on("wheel.zoom",(r=>{if(aR(r,w))return!1;r.preventDefault(),r.stopImmediatePropagation();const o=A.property("__zoom").k||1;if(r.ctrlKey&&i){const e=bM(r),t=cR(r),n=o*Math.pow(2,t);return void I.scaleTo(A,n,e,r)}const s=1===r.deltaMode?20:1;let a=c===ND.Vertical?0:r.deltaX*s,d=c===ND.Horizontal?0:r.deltaY*s;!xD()&&r.shiftKey&&c!==ND.Vertical&&(a=r.deltaY*s,d=0),I.translateBy(A,-a/o*l,-d/o*l,{internal:!0});const u=iR(A.property("__zoom")),{onViewportChangeStart:h,onViewportChange:f,onViewportChangeEnd:p}=C.getState();clearTimeout(P.current),R.current||(R.current=!0,null==t||t(r,u),null==h||h(u)),R.current&&(null==e||e(r,u),null==f||f(u),P.current=setTimeout((()=>{null==n||n(r,u),null==p||p(u),R.current=!1}),150))}),{passive:!1}))}),[M,a,c,A,I,T,D,i,x,w,t,e,n]),o.useEffect((()=>{I&&I.on("start",(e=>{var n,r;if(!e.sourceEvent||e.sourceEvent.internal)return null;O.current=null==(n=e.sourceEvent)?void 0:n.button;const{onViewportChangeStart:o}=C.getState(),s=iR(e.transform);E.current=!0,_.current=s,"mousedown"===(null==(r=e.sourceEvent)?void 0:r.type)&&C.setState({paneDragging:!0}),null==o||o(s),null==t||t(e.sourceEvent,s)}))}),[I,t]),o.useEffect((()=>{I&&(M&&!E.current?I.on("zoom",null):M||I.on("zoom",(t=>{var n;const{onViewportChange:o}=C.getState();if(C.setState({transform:[t.transform.x,t.transform.y,t.transform.k]}),N.current=!(!r||!lR(f,O.current??0)),(e||o)&&!(null==(n=t.sourceEvent)?void 0:n.internal)){const n=iR(t.transform);null==o||o(n),null==e||e(t.sourceEvent,n)}})))}),[M,I,e,f,r]),o.useEffect((()=>{I&&I.on("end",(e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;const{onViewportChangeEnd:t}=C.getState();if(E.current=!1,C.setState({paneDragging:!1}),r&&lR(f,O.current??0)&&!N.current&&r(e.sourceEvent),N.current=!1,(n||t)&&(o=_.current,s=e.transform,o.x!==s.x||o.y!==s.y||o.zoom!==s.k)){const r=iR(e.transform);_.current=r,clearTimeout(S.current),S.current=setTimeout((()=>{null==t||t(r),null==n||n(e.sourceEvent,r)}),a?150:0)}var o,s}))}),[I,a,f,n,r]),o.useEffect((()=>{I&&I.filter((e=>{const t=D||s,n=i&&e.ctrlKey;if((!0===f||Array.isArray(f)&&f.includes(1))&&1===e.button&&"mousedown"===e.type&&(aR(e,"react-flow__node")||aR(e,"react-flow__edge")))return!0;if(!(f||t||a||d||i))return!1;if(M)return!1;if(!d&&"dblclick"===e.type)return!1;if(aR(e,w)&&"wheel"===e.type)return!1;if(aR(e,k)&&("wheel"!==e.type||a&&"wheel"===e.type&&!D))return!1;if(!i&&e.ctrlKey&&"wheel"===e.type)return!1;if(!t&&!a&&!n&&"wheel"===e.type)return!1;if(!f&&("mousedown"===e.type||"touchstart"===e.type))return!1;if(Array.isArray(f)&&!f.includes(e.button)&&"mousedown"===e.type)return!1;const r=Array.isArray(f)&&f.includes(e.button)||!e.button||e.button<=1;return(!e.ctrlKey||"wheel"===e.type)&&r}))}),[M,I,s,i,a,d,f,h,D]),u.createElement("div",{className:"react-flow__renderer",ref:j,style:sR},v)},hR=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function fR(){const{userSelectionActive:e,userSelectionRect:t}=ZM(hR,yM);return e&&t?u.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function pR(e,t){const n=t.parentNode||t.parentId,r=e.find((e=>e.id===n));if(r){const e=t.position.x+t.width-r.width,n=t.position.y+t.height-r.height;if(e>0||n>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,e>0&&(r.style.width+=e),n>0&&(r.style.height+=n),t.position.x<0){const e=Math.abs(t.position.x);r.position.x=r.position.x-e,r.style.width+=e,t.position.x=0}if(t.position.y<0){const e=Math.abs(t.position.y);r.position.y=r.position.y-e,r.style.height+=e,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function mR(e,t){if(e.some((e=>"reset"===e.type)))return e.filter((e=>"reset"===e.type)).map((e=>e.item));const n=e.filter((e=>"add"===e.type)).map((e=>e.item));return t.reduce(((t,n)=>{const r=e.filter((e=>e.id===n.id));if(0===r.length)return t.push(n),t;const o={...n};for(const e of r)if(e)switch(e.type){case"select":o.selected=e.selected;break;case"position":void 0!==e.position&&(o.position=e.position),void 0!==e.positionAbsolute&&(o.positionAbsolute=e.positionAbsolute),void 0!==e.dragging&&(o.dragging=e.dragging),o.expandParent&&pR(t,o);break;case"dimensions":void 0!==e.dimensions&&(o.width=e.dimensions.width,o.height=e.dimensions.height),void 0!==e.updateStyle&&(o.style={...o.style||{},...e.dimensions}),"boolean"==typeof e.resizing&&(o.resizing=e.resizing),o.expandParent&&pR(t,o);break;case"remove":return t}return t.push(o),t}),n)}function gR(e,t){return mR(e,t)}const yR=(e,t)=>({id:e,type:"select",selected:t});function bR(e,t){return e.reduce(((e,n)=>{const r=t.includes(n.id);return!n.selected&&r?(n.selected=!0,e.push(yR(n.id,!0))):n.selected&&!r&&(n.selected=!1,e.push(yR(n.id,!1))),e}),[])}const xR=(e,t)=>n=>{n.target===t.current&&(null==e||e(n))},vR=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),wR=o.memo((({isSelecting:e,selectionMode:t=_D.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:i,onPaneContextMenu:a,onPaneScroll:l,onPaneMouseEnter:c,onPaneMouseMove:d,onPaneMouseLeave:h,children:f})=>{const p=o.useRef(null),m=QM(),g=o.useRef(0),y=o.useRef(0),b=o.useRef(),{userSelectionActive:x,elementsSelectable:v,dragging:w}=ZM(vR,yM),k=()=>{m.setState({userSelectionActive:!1,userSelectionRect:null}),g.current=0,y.current=0},S=e=>{null==i||i(e),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},C=l?e=>l(e):void 0,E=v&&(e||x);return u.createElement("div",{className:uM(["react-flow__pane",{dragging:w,selection:e}]),onClick:E?void 0:xR(S,p),onContextMenu:xR((e=>{Array.isArray(n)&&(null==n?void 0:n.includes(2))?e.preventDefault():null==a||a(e)}),p),onWheel:xR(C,p),onMouseEnter:E?void 0:c,onMouseDown:E?t=>{const{resetSelectedElements:n,domNode:o}=m.getState();if(b.current=null==o?void 0:o.getBoundingClientRect(),!v||!e||0!==t.button||t.target!==p.current||!b.current)return;const{x:s,y:i}=bD(t,b.current);n(),m.setState({userSelectionRect:{width:0,height:0,startX:s,startY:i,x:s,y:i}}),null==r||r(t)}:void 0,onMouseMove:E?n=>{const{userSelectionRect:r,nodeInternals:o,edges:s,transform:i,onNodesChange:a,onEdgesChange:l,nodeOrigin:c,getNodes:d}=m.getState();if(!e||!b.current||!r)return;m.setState({userSelectionActive:!0,nodesSelectionActive:!1});const u=bD(n,b.current),h=r.startX??0,f=r.startY??0,p={...r,x:u.x<h?u.x:h,y:u.y<f?u.y:f,width:Math.abs(u.x-h),height:Math.abs(u.y-f)},x=d(),v=oO(o,p,i,t===_D.Partial,!0,c),w=sO(v,s).map((e=>e.id)),k=v.map((e=>e.id));if(g.current!==k.length){g.current=k.length;const e=bR(x,k);e.length&&(null==a||a(e))}if(y.current!==w.length){y.current=w.length;const e=bR(s,w);e.length&&(null==l||l(e))}m.setState({userSelectionRect:p})}:d,onMouseUp:E?e=>{if(0!==e.button)return;const{userSelectionRect:t}=m.getState();!x&&t&&e.target===p.current&&(null==S||S(e)),m.setState({nodesSelectionActive:g.current>0}),k(),null==s||s(e)}:void 0,onMouseLeave:E?e=>{x&&(m.setState({nodesSelectionActive:g.current>0}),null==s||s(e)),k()}:h,ref:p,style:sR},f,u.createElement(fR,null))}));function kR(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return!!r&&(!!r.selected||kR(r,t))}function SR(e,t,n){let r=e;do{if(null==r?void 0:r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function CR(e,t,n,r){return Array.from(e.values()).filter((n=>(n.selected||n.id===r)&&(!n.parentNode||n.parentId||!kR(n,e))&&(n.draggable||t&&void 0===n.draggable))).map((e=>{var t,r;return{id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:n.x-((null==(t=e.positionAbsolute)?void 0:t.x)??0),y:n.y-((null==(r=e.positionAbsolute)?void 0:r.y)??0)},delta:{x:0,y:0},extent:e.extent,parentNode:e.parentNode||e.parentId,parentId:e.parentNode||e.parentId,width:e.width,height:e.height,expandParent:e.expandParent}}))}function ER(e,t,n,r,o=[0,0],s){const i=function(e,t){return t&&"parent"!==t?[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]:t}(e,e.extent||r);let a=i;const l=e.parentNode||e.parentId;if("parent"!==e.extent||e.expandParent){if(e.extent&&l&&"parent"!==e.extent){const t=n.get(l),{x:r,y:s}=nO(t,o).positionAbsolute;a=[[e.extent[0][0]+r,e.extent[0][1]+s],[e.extent[1][0]+r,e.extent[1][1]+s]]}}else if(l&&e.width&&e.height){const t=n.get(l),{x:r,y:s}=nO(t,o).positionAbsolute;a=t&&fD(r)&&fD(s)&&fD(t.width)&&fD(t.height)?[[r+e.width*o[0],s+e.height*o[1]],[r+t.width-e.width+e.width*o[0],s+t.height-e.height+e.height*o[1]]]:a}else null==s||s("005",WM()),a=i;let c={x:0,y:0};if(l){const e=n.get(l);c=nO(e,o).positionAbsolute}const d=a&&"parent"!==a?iD(t,a):t;return{position:{x:d.x-c.x,y:d.y-c.y},positionAbsolute:d}}function NR({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map((e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute})));return[e?r.find((t=>t.id===e)):r[0],r]}wR.displayName="Pane";const jR=(e,t,n,r)=>{const o=t.querySelectorAll(e);if(!o||!o.length)return null;const s=Array.from(o),i=t.getBoundingClientRect(),a=i.width*r[0],l=i.height*r[1];return s.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),position:e.getAttribute("data-handlepos"),x:(t.left-i.left-a)/n,y:(t.top-i.top-l)/n,...oD(e)}}))};function _R(e,t,n){return void 0===n?n:r=>{const o=t().nodeInternals.get(e);o&&n(r,{...o})}}function IR({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:s,multiSelectionActive:i,nodeInternals:a,onError:l}=t.getState(),c=a.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&i)&&(s({nodes:[c],edges:[]}),requestAnimationFrame((()=>{var e;return null==(e=null==r?void 0:r.current)?void 0:e.blur()}))):o([e])):null==l||l("012",JM(e))}function AR(e){return(t,n,r)=>null==e?void 0:e(t,r)}function TR({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,selectNodesOnDrag:a}){const l=QM(),[c,d]=o.useState(!1),u=o.useRef([]),h=o.useRef({x:null,y:null}),f=o.useRef(0),p=o.useRef(null),m=o.useRef({x:0,y:0}),g=o.useRef(null),y=o.useRef(!1),b=o.useRef(!1),x=o.useRef(!1),v=function(){const e=QM();return o.useCallback((({sourceEvent:t})=>{const{transform:n,snapGrid:r,snapToGrid:o}=e.getState(),s=t.touches?t.touches[0].clientX:t.clientX,i=t.touches?t.touches[0].clientY:t.clientY,a={x:(s-n[0])/n[2],y:(i-n[1])/n[2]};return{xSnapped:o?r[0]*Math.round(a.x/r[0]):a.x,ySnapped:o?r[1]*Math.round(a.y/r[1]):a.y,...a}}),[])}();return o.useEffect((()=>{if(null==e?void 0:e.current){const o=bc(e.current),c=({x:e,y:t})=>{const{nodeInternals:n,onNodeDrag:r,onSelectionDrag:o,updateNodePositions:i,nodeExtent:a,snapGrid:c,snapToGrid:f,nodeOrigin:p,onError:m}=l.getState();h.current={x:e,y:t};let y=!1,b={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&a){const e=rO(u.current,p);b=dD(e)}if(u.current=u.current.map((r=>{const o={x:e-r.distance.x,y:t-r.distance.y};f&&(o.x=c[0]*Math.round(o.x/c[0]),o.y=c[1]*Math.round(o.y/c[1]));const s=[[a[0][0],a[0][1]],[a[1][0],a[1][1]]];u.current.length>1&&a&&!r.extent&&(s[0][0]=r.positionAbsolute.x-b.x+a[0][0],s[1][0]=r.positionAbsolute.x+(r.width??0)-b.x2+a[1][0],s[0][1]=r.positionAbsolute.y-b.y+a[0][1],s[1][1]=r.positionAbsolute.y+(r.height??0)-b.y2+a[1][1]);const i=ER(r,o,n,s,p,m);return y=y||r.position.x!==i.position.x||r.position.y!==i.position.y,r.position=i.position,r.positionAbsolute=i.positionAbsolute,r})),!y)return;i(u.current,!0,!0),d(!0);const x=s?r:AR(o);if(x&&g.current){const[e,t]=NR({nodeId:s,dragItems:u.current,nodeInternals:n});x(g.current,e,t)}},w=()=>{if(!p.current)return;const[e,t]=lD(m.current,p.current);if(0!==e||0!==t){const{transform:n,panBy:r}=l.getState();h.current.x=(h.current.x??0)-e/n[2],h.current.y=(h.current.y??0)-t/n[2],r({x:e,y:t})&&c(h.current)}f.current=requestAnimationFrame(w)},k=t=>{var n;const{nodeInternals:r,multiSelectionActive:o,nodesDraggable:c,unselectNodesAndEdges:d,onNodeDragStart:f,onSelectionDragStart:p}=l.getState();b.current=!0;const m=s?f:AR(p);a&&i||o||!s||(null==(n=r.get(s))?void 0:n.selected)||d(),s&&i&&a&&IR({id:s,store:l,nodeRef:e});const g=v(t);if(h.current=g,u.current=CR(r,c,g,s),m&&u.current){const[e,n]=NR({nodeId:s,dragItems:u.current,nodeInternals:r});m(t.sourceEvent,e,n)}};if(!t){const t=function(){var e,t,n,r,o=jM,s=_M,i=IM,a=AM,l={},c=kc("start","drag","end"),d=0,u=0;function h(e){e.on("mousedown.drag",f).filter(a).on("touchstart.drag",g).on("touchmove.drag",y,xM).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(i,a){if(!r&&o.call(this,i,a)){var l=x(this,s.call(this,i,a),i,a,"mouse");l&&(bc(i.view).on("mousemove.drag",p,vM).on("mouseup.drag",m,vM),SM(i.view),wM(i),n=!1,e=i.clientX,t=i.clientY,l("start",i))}}function p(r){if(kM(r),!n){var o=r.clientX-e,s=r.clientY-t;n=o*o+s*s>u}l.mouse("drag",r)}function m(e){bc(e.view).on("mousemove.drag mouseup.drag",null),CM(e.view,n),kM(e),l.mouse("end",e)}function g(e,t){if(o.call(this,e,t)){var n,r,i=e.changedTouches,a=s.call(this,e,t),l=i.length;for(n=0;n<l;++n)(r=x(this,a,e,t,i[n].identifier,i[n]))&&(wM(e),r("start",e,i[n]))}}function y(e){var t,n,r=e.changedTouches,o=r.length;for(t=0;t<o;++t)(n=l[r[t].identifier])&&(kM(e),n("drag",e,r[t]))}function b(e){var t,n,o=e.changedTouches,s=o.length;for(r&&clearTimeout(r),r=setTimeout((function(){r=null}),500),t=0;t<s;++t)(n=l[o[t].identifier])&&(wM(e),n("end",e,o[t]))}function x(e,t,n,r,o,s){var a,u,f,p=c.copy(),m=bM(s||n,t);if(null!=(f=i.call(e,new NM("beforestart",{sourceEvent:n,target:h,identifier:o,active:d,x:m[0],y:m[1],dx:0,dy:0,dispatch:p}),r)))return a=f.x-m[0]||0,u=f.y-m[1]||0,function n(s,i,c){var g,y=m;switch(s){case"start":l[o]=n,g=d++;break;case"end":delete l[o],--d;case"drag":m=bM(c||i,t),g=d}p.call(s,e,new NM(s,{sourceEvent:i,subject:f,target:h,identifier:o,active:g,x:m[0]+a,y:m[1]+u,dx:m[0]-y[0],dy:m[1]-y[1],dispatch:p}),r)}}return h.filter=function(e){return arguments.length?(o="function"==typeof e?e:EM(!!e),h):o},h.container=function(e){return arguments.length?(s="function"==typeof e?e:EM(e),h):s},h.subject=function(e){return arguments.length?(i="function"==typeof e?e:EM(e),h):i},h.touchable=function(e){return arguments.length?(a="function"==typeof e?e:EM(!!e),h):a},h.on=function(){var e=c.on.apply(c,arguments);return e===c?h:e},h.clickDistance=function(e){return arguments.length?(u=(e=+e)*e,h):Math.sqrt(u)},h}().on("start",(e=>{const{domNode:t,nodeDragThreshold:n}=l.getState();0===n&&k(e),x.current=!1;const r=v(e);h.current=r,p.current=(null==t?void 0:t.getBoundingClientRect())||null,m.current=bD(e.sourceEvent,p.current)})).on("drag",(e=>{var t,n;const r=v(e),{autoPanOnNodeDrag:o,nodeDragThreshold:s}=l.getState();if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(x.current=!0),!x.current){if(!y.current&&b.current&&o&&(y.current=!0,w()),!b.current){const o=r.xSnapped-((null==(t=null==h?void 0:h.current)?void 0:t.x)??0),i=r.ySnapped-((null==(n=null==h?void 0:h.current)?void 0:n.y)??0);Math.sqrt(o*o+i*i)>s&&k(e)}(h.current.x!==r.xSnapped||h.current.y!==r.ySnapped)&&u.current&&b.current&&(g.current=e.sourceEvent,m.current=bD(e.sourceEvent,p.current),c(r))}})).on("end",(e=>{if(b.current&&!x.current&&(d(!1),y.current=!1,b.current=!1,cancelAnimationFrame(f.current),u.current)){const{updateNodePositions:t,nodeInternals:n,onNodeDragStop:r,onSelectionDragStop:o}=l.getState(),i=s?r:AR(o);if(t(u.current,!1,!1),i){const[t,r]=NR({nodeId:s,dragItems:u.current,nodeInternals:n});i(e.sourceEvent,t,r)}}})).filter((t=>{const o=t.target;return!t.button&&(!n||!SR(o,`.${n}`,e))&&(!r||SR(o,r,e))}));return o.call(t),()=>{o.on(".drag",null)}}o.on(".drag",null)}}),[e,t,n,r,i,l,s,a,v]),c}function MR(){const e=QM();return o.useCallback((t=>{const{nodeInternals:n,nodeExtent:r,updateNodePositions:o,getNodes:s,snapToGrid:i,snapGrid:a,onError:l,nodesDraggable:c}=e.getState(),d=s().filter((e=>e.selected&&(e.draggable||c&&void 0===e.draggable))),u=i?a[0]:5,h=i?a[1]:5,f=t.isShiftPressed?4:1,p=t.x*u*f,m=t.y*h*f;o(d.map((e=>{if(e.positionAbsolute){const t={x:e.positionAbsolute.x+p,y:e.positionAbsolute.y+m};i&&(t.x=a[0]*Math.round(t.x/a[0]),t.y=a[1]*Math.round(t.y/a[1]));const{positionAbsolute:o,position:s}=ER(e,t,n,r,void 0,l);e.position=s,e.positionAbsolute=o}return e})),!0,!1)}),[])}const DR={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var OR=e=>{const t=({id:t,type:n,data:r,xPos:s,yPos:i,xPosOrigin:a,yPosOrigin:l,selected:c,onClick:d,onMouseEnter:h,onMouseMove:f,onMouseLeave:p,onContextMenu:m,onDoubleClick:g,style:y,className:b,isDraggable:x,isSelectable:v,isConnectable:w,isFocusable:k,selectNodesOnDrag:S,sourcePosition:C,targetPosition:E,hidden:N,resizeObserver:j,dragHandle:_,zIndex:I,isParent:A,noDragClassName:T,noPanClassName:M,initialized:D,disableKeyboardA11y:O,ariaLabel:R,rfId:P,hasHandleBounds:L})=>{const z=QM(),F=o.useRef(null),B=o.useRef(null),U=o.useRef(C),$=o.useRef(E),H=o.useRef(n),V=v||x||d||h||f||p,W=MR(),G=_R(t,z.getState,h),q=_R(t,z.getState,f),Y=_R(t,z.getState,p),X=_R(t,z.getState,m),J=_R(t,z.getState,g);o.useEffect((()=>()=>{B.current&&(null==j||j.unobserve(B.current),B.current=null)}),[]),o.useEffect((()=>{if(F.current&&!N){const e=F.current;D&&L&&B.current===e||(B.current&&(null==j||j.unobserve(B.current)),null==j||j.observe(e),B.current=e)}}),[N,D,L]),o.useEffect((()=>{const e=H.current!==n,r=U.current!==C,o=$.current!==E;F.current&&(e||r||o)&&(e&&(H.current=n),r&&(U.current=C),o&&($.current=E),z.getState().updateNodeDimensions([{id:t,nodeElement:F.current,forceUpdate:!0}]))}),[t,n,C,E]);const K=TR({nodeRef:F,disabled:N||!x,noDragClassName:T,handleSelector:_,nodeId:t,isSelectable:v,selectNodesOnDrag:S});return N?null:u.createElement("div",{className:uM(["react-flow__node",`react-flow__node-${n}`,{[M]:x},b,{selected:c,selectable:v,parent:A,dragging:K}]),ref:F,style:{zIndex:I,transform:`translate(${a}px,${l}px)`,pointerEvents:V?"all":"none",visibility:D?"visible":"hidden",...y},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:G,onMouseMove:q,onMouseLeave:Y,onContextMenu:X,onClick:e=>{const{nodeDragThreshold:n}=z.getState();if(v&&(!S||!x||n>0)&&IR({id:t,store:z,nodeRef:F}),d){const n=z.getState().nodeInternals.get(t);n&&d(e,{...n})}},onDoubleClick:J,onKeyDown:k?e=>{if(!gD(e)&&!O)if(mD.includes(e.key)&&v){const n="Escape"===e.key;IR({id:t,store:z,unselect:n,nodeRef:F})}else x&&c&&Object.prototype.hasOwnProperty.call(DR,e.key)&&(z.setState({ariaLiveMessage:`Moved selected node ${e.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~i}`}),W({x:DR[e.key].x,y:DR[e.key].y,isShiftPressed:e.shiftKey}))}:void 0,tabIndex:k?0:void 0,role:k?"button":void 0,"aria-describedby":O?void 0:`${FO}-${P}`,"aria-label":R},u.createElement(KD,{value:t},u.createElement(e,{id:t,data:r,type:n,xPos:s,yPos:i,selected:c,isConnectable:w,sourcePosition:C,targetPosition:E,dragging:K,dragHandle:_,zIndex:I})))};return t.displayName="NodeWrapper",o.memo(t)};const RR=e=>{const t=e.getNodes().filter((e=>e.selected));return{...rO(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};var PR=o.memo((function({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=QM(),{width:s,height:i,x:a,y:l,transformString:c,userSelectionActive:d}=ZM(RR,yM),h=MR(),f=o.useRef(null);if(o.useEffect((()=>{var e;n||null==(e=f.current)||e.focus({preventScroll:!0})}),[n]),TR({nodeRef:f}),d||!s||!i)return null;const p=e?t=>{const n=r.getState().getNodes().filter((e=>e.selected));e(t,n)}:void 0;return u.createElement("div",{className:uM(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c}},u.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(DR,e.key)&&h({x:DR[e.key].x,y:DR[e.key].y,isShiftPressed:e.shiftKey})},style:{width:s,height:i,top:l,left:a}}))}));const LR=e=>e.nodesSelectionActive,zR=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,deleteKeyCode:l,onMove:c,onMoveStart:d,onMoveEnd:h,selectionKeyCode:f,selectionOnDrag:p,selectionMode:m,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:b,panActivationKeyCode:x,zoomActivationKeyCode:v,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:S,panOnScroll:C,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:j,panOnDrag:_,defaultViewport:I,translateExtent:A,minZoom:T,maxZoom:M,preventScrolling:D,onSelectionContextMenu:O,noWheelClassName:R,noPanClassName:P,disableKeyboardA11y:L})=>{const z=ZM(LR),F=VO(f),B=VO(x),U=B||_,$=B||C,H=F||p&&!0!==U;return(({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=QM(),{deleteElements:r}=rR(),s=VO(e,oR),i=VO(t);o.useEffect((()=>{if(s){const{edges:e,getNodes:t}=n.getState(),o=t().filter((e=>e.selected)),s=e.filter((e=>e.selected));r({nodes:o,edges:s}),n.setState({nodesSelectionActive:!1})}}),[s]),o.useEffect((()=>{n.setState({multiSelectionActive:i})}),[i])})({deleteKeyCode:l,multiSelectionKeyCode:b}),u.createElement(uR,{onMove:c,onMoveStart:d,onMoveEnd:h,onPaneContextMenu:i,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:S,panOnScroll:$,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:j,panOnDrag:!F&&U,defaultViewport:I,translateExtent:A,minZoom:T,maxZoom:M,zoomActivationKeyCode:v,preventScrolling:D,noWheelClassName:R,noPanClassName:P},u.createElement(wR,{onSelectionStart:g,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:U,isSelecting:!!H,selectionMode:m},e,z&&u.createElement(PR,{onSelectionContextMenu:O,noPanClassName:P,disableKeyboardA11y:L})))};zR.displayName="FlowRenderer";var FR=o.memo(zR);function BR(e){return{...{input:OR(e.input||SO),default:OR(e.default||wO),output:OR(e.output||EO),group:OR(e.group||NO)},...Object.keys(e).filter((e=>!["input","default","output","group"].includes(e))).reduce(((t,n)=>(t[n]=OR(e[n]||wO),t)),{})}}const UR=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),$R=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:i,onError:a}=ZM(UR,yM),l=(c=e.onlyRenderVisibleElements,ZM(o.useCallback((e=>c?oO(e.nodeInternals,{x:0,y:0,width:e.width,height:e.height},e.transform,!0):e.getNodes()),[c])));var c;const d=o.useRef(),h=o.useMemo((()=>{if("undefined"==typeof ResizeObserver)return null;const e=new ResizeObserver((e=>{const t=e.map((e=>({id:e.target.getAttribute("data-id"),nodeElement:e.target,forceUpdate:!0})));i(t)}));return d.current=e,e}),[]);return o.useEffect((()=>()=>{var e;null==(e=null==d?void 0:d.current)||e.disconnect()}),[]),u.createElement("div",{className:"react-flow__nodes",style:sR},l.map((o=>{var i,l,c;let d=o.type||"default";e.nodeTypes[d]||(null==a||a("003",HM(d)),d="default");const f=e.nodeTypes[d]||e.nodeTypes.default,p=!!(o.draggable||t&&void 0===o.draggable),m=!!(o.selectable||s&&void 0===o.selectable),g=!!(o.connectable||n&&void 0===o.connectable),y=!!(o.focusable||r&&void 0===o.focusable),b=e.nodeExtent?iD(o.positionAbsolute,e.nodeExtent):o.positionAbsolute,x=(null==b?void 0:b.x)??0,v=(null==b?void 0:b.y)??0,w=(({x:e,y:t,width:n,height:r,origin:o})=>n&&r?o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:t}:{x:e-n*o[0],y:t-r*o[1]}:{x:e,y:t})({x:x,y:v,width:o.width??0,height:o.height??0,origin:e.nodeOrigin});return u.createElement(f,{key:o.id,id:o.id,className:o.className,style:o.style,type:d,data:o.data,sourcePosition:o.sourcePosition||OD.Bottom,targetPosition:o.targetPosition||OD.Top,hidden:o.hidden,xPos:x,yPos:v,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!o.selected,isDraggable:p,isSelectable:m,isConnectable:g,isFocusable:y,resizeObserver:h,dragHandle:o.dragHandle,zIndex:(null==(i=o[pD])?void 0:i.z)??0,isParent:!!(null==(l=o[pD])?void 0:l.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!o.width&&!!o.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:o.ariaLabel,hasHandleBounds:!!(null==(c=o[pD])?void 0:c.handleBounds)})})))};$R.displayName="NodeRenderer";var HR=o.memo($R);const VR=(e,t,n)=>n===OD.Left?e-t:n===OD.Right?e+t:e,WR=(e,t,n)=>n===OD.Top?e-t:n===OD.Bottom?e+t:e,GR="react-flow__edgeupdater",qR=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:s,onMouseOut:i,type:a})=>u.createElement("circle",{onMouseDown:o,onMouseEnter:s,onMouseOut:i,className:uM([GR,`${GR}-${a}`]),cx:VR(t,r,e),cy:WR(n,r,e),r:r,stroke:"transparent",fill:"transparent"}),YR=()=>!0;var XR=e=>{const t=({id:t,className:n,type:r,data:s,onClick:i,onEdgeDoubleClick:a,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:g,style:y,source:b,target:x,sourceX:v,sourceY:w,targetX:k,targetY:S,sourcePosition:C,targetPosition:E,elementsSelectable:N,hidden:j,sourceHandleId:_,targetHandleId:I,onContextMenu:A,onMouseEnter:T,onMouseMove:M,onMouseLeave:D,reconnectRadius:O,onReconnect:R,onReconnectStart:P,onReconnectEnd:L,markerEnd:z,markerStart:F,rfId:B,ariaLabel:U,isFocusable:$,isReconnectable:H,pathOptions:V,interactionWidth:W,disableKeyboardA11y:G})=>{const q=o.useRef(null),[Y,X]=o.useState(!1),[J,K]=o.useState(!1),Z=QM(),Q=o.useMemo((()=>`url('#${QD(F,B)}')`),[F,B]),ee=o.useMemo((()=>`url('#${QD(z,B)}')`),[z,B]);if(j)return null;const te=wD(t,Z.getState,a),ne=wD(t,Z.getState,A),re=wD(t,Z.getState,T),oe=wD(t,Z.getState,M),se=wD(t,Z.getState,D),ie=(e,n)=>{if(0!==e.button)return;const{edges:r,isValidConnection:o}=Z.getState(),s=n?x:b,i=(n?I:_)||null,a=n?"target":"source",l=o||YR,c=n,d=r.find((e=>e.id===t));K(!0),null==P||P(e,d,a);mO({event:e,handleId:i,nodeId:s,onConnect:e=>null==R?void 0:R(d,e),isTarget:c,getState:Z.getState,setState:Z.setState,isValidConnection:l,edgeUpdaterType:a,onReconnectEnd:e=>{K(!1),null==L||L(e,d,a)}})},ae=()=>X(!0),le=()=>X(!1),ce=!N&&!i;return u.createElement("g",{className:uM(["react-flow__edge",`react-flow__edge-${r}`,n,{selected:l,animated:c,inactive:ce,updating:Y}]),onClick:e=>{var n;const{edges:r,addSelectedEdges:o,unselectNodesAndEdges:s,multiSelectionActive:a}=Z.getState(),l=r.find((e=>e.id===t));l&&(N&&(Z.setState({nodesSelectionActive:!1}),l.selected&&a?(s({nodes:[],edges:[l]}),null==(n=q.current)||n.blur()):o([t])),i&&i(e,l))},onDoubleClick:te,onContextMenu:ne,onMouseEnter:re,onMouseMove:oe,onMouseLeave:se,onKeyDown:$?e=>{var n;if(!G&&mD.includes(e.key)&&N){const{unselectNodesAndEdges:r,addSelectedEdges:o,edges:s}=Z.getState();"Escape"===e.key?(null==(n=q.current)||n.blur(),r({edges:[s.find((e=>e.id===t))]})):o([t])}}:void 0,tabIndex:$?0:void 0,role:$?"button":"img","data-testid":`rf__edge-${t}`,"aria-label":null===U?void 0:U||`Edge from ${b} to ${x}`,"aria-describedby":$?`${BO}-${B}`:void 0,ref:q},!J&&u.createElement(e,{id:t,source:b,target:x,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:g,data:s,style:y,sourceX:v,sourceY:w,targetX:k,targetY:S,sourcePosition:C,targetPosition:E,sourceHandleId:_,targetHandleId:I,markerStart:Q,markerEnd:ee,pathOptions:V,interactionWidth:W}),H&&u.createElement(u.Fragment,null,("source"===H||!0===H)&&u.createElement(qR,{position:C,centerX:v,centerY:w,radius:O,onMouseDown:e=>ie(e,!0),onMouseEnter:ae,onMouseOut:le,type:"source"}),("target"===H||!0===H)&&u.createElement(qR,{position:E,centerX:k,centerY:S,radius:O,onMouseDown:e=>ie(e,!1),onMouseEnter:ae,onMouseOut:le,type:"target"})))};return t.displayName="EdgeWrapper",o.memo(t)};function JR(e){return{...{default:XR(e.default||XD),straight:XR(e.bezier||WD),step:XR(e.step||VD),smoothstep:XR(e.step||HD),simplebezier:XR(e.simplebezier||zD)},...Object.keys(e).filter((e=>!["default","bezier"].includes(e))).reduce(((t,n)=>(t[n]=XR(e[n]||XD),t)),{})}}function KR(e,t,n=null){const r=((null==n?void 0:n.x)||0)+t.x,o=((null==n?void 0:n.y)||0)+t.y,s=(null==n?void 0:n.width)||t.width,i=(null==n?void 0:n.height)||t.height;switch(e){case OD.Top:return{x:r+s/2,y:o};case OD.Right:return{x:r+s,y:o+i/2};case OD.Bottom:return{x:r+s/2,y:o+i};case OD.Left:return{x:r,y:o+i/2}}}function ZR(e,t){return e?1!==e.length&&t?t&&e.find((e=>e.id===t))||null:e[0]:null}function QR(e){var t,n,r,o,s;const i=(null==(t=null==e?void 0:e[pD])?void 0:t.handleBounds)||null,a=i&&(null==e?void 0:e.width)&&(null==e?void 0:e.height)&&void 0!==(null==(n=null==e?void 0:e.positionAbsolute)?void 0:n.x)&&void 0!==(null==(r=null==e?void 0:e.positionAbsolute)?void 0:r.y);return[{x:(null==(o=null==e?void 0:e.positionAbsolute)?void 0:o.x)||0,y:(null==(s=null==e?void 0:e.positionAbsolute)?void 0:s.y)||0,width:(null==e?void 0:e.width)||0,height:(null==e?void 0:e.height)||0},i,!!a]}const eP=[{level:0,isMaxLevel:!0,edges:[]}];function tP(e,t,n){return function(e,t,n=!1){let r=-1;const o=e.reduce(((e,o)=>{var s,i;const a=fD(o.zIndex);let l=a?o.zIndex:0;if(n){const e=t.get(o.target),n=t.get(o.source),r=o.selected||(null==e?void 0:e.selected)||(null==n?void 0:n.selected),c=Math.max((null==(s=null==n?void 0:n[pD])?void 0:s.z)||0,(null==(i=null==e?void 0:e[pD])?void 0:i.z)||0,1e3);l=(a?o.zIndex:0)+(r?c:0)}return e[l]?e[l].push(o):e[l]=[o],r=l>r?l:r,e}),{}),s=Object.entries(o).map((([e,t])=>{const n=+e;return{edges:t,level:n,isMaxLevel:n===r}}));return 0===s.length?eP:s}(ZM(o.useCallback((n=>e?n.edges.filter((e=>{const r=t.get(e.source),o=t.get(e.target);return(null==r?void 0:r.width)&&(null==r?void 0:r.height)&&(null==o?void 0:o.width)&&(null==o?void 0:o.height)&&function({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:o,targetHeight:s,width:i,height:a,transform:l}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+o),y2:Math.max(e.y+r,t.y+s)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const d=dD({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:i/l[2],height:a/l[2]}),u=Math.max(0,Math.min(d.x2,c.x2)-Math.max(d.x,c.x)),h=Math.max(0,Math.min(d.y2,c.y2)-Math.max(d.y,c.y));return Math.ceil(u*h)>0}({sourcePos:r.positionAbsolute||{x:0,y:0},targetPos:o.positionAbsolute||{x:0,y:0},sourceWidth:r.width,sourceHeight:r.height,targetWidth:o.width,targetHeight:o.height,width:n.width,height:n.height,transform:n.transform})})):n.edges),[e,t])),t,n)}const nP={[MD.Arrow]:({color:e="none",strokeWidth:t=1})=>u.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[MD.ArrowClosed]:({color:e="none",strokeWidth:t=1})=>u.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const rP=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const c=function(e){const t=QM();return o.useMemo((()=>{var n,r;return Object.prototype.hasOwnProperty.call(nP,e)?nP[e]:(null==(r=(n=t.getState()).onError)||r.call(n,"009",GM(e)),null)}),[e])}(t);return c?u.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0"},u.createElement(c,{color:n,strokeWidth:a})):null},oP=({defaultColor:e,rfId:t})=>{const n=ZM(o.useCallback((({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce(((n,o)=>([o.markerStart,o.markerEnd].forEach((o=>{if(o&&"object"==typeof o){const s=QD(o,t);r.includes(s)||(n.push({id:s,color:o.color||e,...o}),r.push(s))}})),n)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))})({defaultColor:e,rfId:t}),[e,t]),((e,t)=>!(e.length!==t.length||e.some(((e,n)=>e.id!==t[n].id)))));return u.createElement("defs",null,n.map((e=>u.createElement(rP,{id:e.id,key:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient}))))};oP.displayName="MarkerDefinitions";var sP=o.memo(oP);const iP=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),aP=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:o,noPanClassName:s,onEdgeContextMenu:i,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,reconnectRadius:g,children:y,disableKeyboardA11y:b})=>{const{edgesFocusable:x,edgesUpdatable:v,elementsSelectable:w,width:k,height:S,connectionMode:C,nodeInternals:E,onError:N}=ZM(iP,yM),j=tP(t,E,n);return k?u.createElement(u.Fragment,null,j.map((({level:t,edges:n,isMaxLevel:y})=>u.createElement("svg",{key:t,style:{zIndex:t},width:k,height:S,className:"react-flow__edges react-flow__container"},y&&u.createElement(sP,{defaultColor:e,rfId:r}),u.createElement("g",null,n.map((e=>{const[t,n,y]=QR(E.get(e.source)),[k,S,j]=QR(E.get(e.target));if(!y||!j)return null;let _=e.type||"default";o[_]||(null==N||N("011",XM(_)),_="default");const I=o[_]||o.default,A=C===CD.Strict?S.target:(S.target??[]).concat(S.source??[]),T=ZR(n.source,e.sourceHandle),M=ZR(A,e.targetHandle),D=(null==T?void 0:T.position)||OD.Bottom,O=(null==M?void 0:M.position)||OD.Top,R=!!(e.focusable||x&&void 0===e.focusable),P=e.reconnectable||e.updatable,L=void 0!==f&&(P||v&&void 0===P);if(!T||!M)return null==N||N("008",qM(T,e)),null;const{sourceX:z,sourceY:F,targetX:B,targetY:U}=((e,t,n,r,o,s)=>{const i=KR(n,e,t),a=KR(s,r,o);return{sourceX:i.x,sourceY:i.y,targetX:a.x,targetY:a.y}})(t,T,D,k,M,O);return u.createElement(I,{key:e.id,id:e.id,className:uM([e.className,s]),type:_,data:e.data,selected:!!e.selected,animated:!!e.animated,hidden:!!e.hidden,label:e.label,labelStyle:e.labelStyle,labelShowBg:e.labelShowBg,labelBgStyle:e.labelBgStyle,labelBgPadding:e.labelBgPadding,labelBgBorderRadius:e.labelBgBorderRadius,style:e.style,source:e.source,target:e.target,sourceHandleId:e.sourceHandle,targetHandleId:e.targetHandle,markerEnd:e.markerEnd,markerStart:e.markerStart,sourceX:z,sourceY:F,targetX:B,targetY:U,sourcePosition:D,targetPosition:O,elementsSelectable:w,onContextMenu:i,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,onClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,reconnectRadius:g,rfId:r,ariaLabel:e.ariaLabel,isFocusable:R,isReconnectable:L,pathOptions:"pathOptions"in e?e.pathOptions:void 0,interactionWidth:e.interactionWidth,disableKeyboardA11y:b})})))))),y):null};aP.displayName="EdgeRenderer";var lP=o.memo(aP);const cP=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function dP({children:e}){const t=ZM(cP);return u.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}const uP={[OD.Left]:OD.Right,[OD.Right]:OD.Left,[OD.Top]:OD.Bottom,[OD.Bottom]:OD.Top},hP=({nodeId:e,handleType:t,style:n,type:r=AD.Bezier,CustomComponent:s,connectionStatus:i})=>{var a,l,c;const{fromNode:d,handleId:h,toX:f,toY:p,connectionMode:m}=ZM(o.useCallback((t=>({fromNode:t.nodeInternals.get(e),handleId:t.connectionHandleId,toX:(t.connectionPosition.x-t.transform[0])/t.transform[2],toY:(t.connectionPosition.y-t.transform[1])/t.transform[2],connectionMode:t.connectionMode})),[e]),yM),g=null==(a=null==d?void 0:d[pD])?void 0:a.handleBounds;let y=null==g?void 0:g[t];if(m===CD.Loose&&(y=y||(null==g?void 0:g["source"===t?"target":"source"])),!d||!y)return null;const b=h?y.find((e=>e.id===h)):y[0],x=b?b.x+b.width/2:(d.width??0)/2,v=b?b.y+b.height/2:d.height??0,w=((null==(l=d.positionAbsolute)?void 0:l.x)??0)+x,k=((null==(c=d.positionAbsolute)?void 0:c.y)??0)+v,S=null==b?void 0:b.position,C=S?uP[S]:null;if(!S||!C)return null;if(s)return u.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:d,fromHandle:b,fromX:w,fromY:k,toX:f,toY:p,fromPosition:S,toPosition:C,connectionStatus:i});let E="";const N={sourceX:w,sourceY:k,sourcePosition:S,targetX:f,targetY:p,targetPosition:C};return r===AD.Bezier?[E]=YD(N):r===AD.Step?[E]=$D({...N,borderRadius:0}):r===AD.SmoothStep?[E]=$D(N):r===AD.SimpleBezier?[E]=LD(N):E=`M${w},${k} ${f},${p}`,u.createElement("path",{d:E,fill:"none",className:"react-flow__connection-path",style:n})};hP.displayName="ConnectionLine";const fP=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function pP({containerStyle:e,style:t,type:n,component:r}){const{nodeId:o,handleType:s,nodesConnectable:i,width:a,height:l,connectionStatus:c}=ZM(fP,yM);return!!(o&&s&&a&&i)?u.createElement("svg",{style:e,width:a,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},u.createElement("g",{className:uM(["react-flow__connection",c])},u.createElement(hP,{nodeId:o,handleType:s,style:t,type:n,CustomComponent:r,connectionStatus:c}))):null}function mP(e,t){o.useRef(null),QM();return o.useMemo((()=>t(e)),[e])}const gP=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:i,onNodeClick:a,onEdgeClick:l,onNodeDoubleClick:c,onEdgeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:m,onSelectionContextMenu:g,onSelectionStart:y,onSelectionEnd:b,connectionLineType:x,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:k,selectionKeyCode:S,selectionOnDrag:C,selectionMode:E,multiSelectionKeyCode:N,panActivationKeyCode:j,zoomActivationKeyCode:_,deleteKeyCode:I,onlyRenderVisibleElements:A,elementsSelectable:T,selectNodesOnDrag:M,defaultViewport:D,translateExtent:O,minZoom:R,maxZoom:P,preventScrolling:L,defaultMarkerColor:z,zoomOnScroll:F,zoomOnPinch:B,panOnScroll:U,panOnScrollSpeed:$,panOnScrollMode:H,zoomOnDoubleClick:V,panOnDrag:W,onPaneClick:G,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:X,onPaneScroll:J,onPaneContextMenu:K,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:re,onReconnectEnd:oe,reconnectRadius:se,noDragClassName:ie,noWheelClassName:ae,noPanClassName:le,elevateEdgesOnSelect:ce,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})=>{const pe=mP(e,BR),me=mP(t,JR);return function(e){const t=rR(),n=o.useRef(!1);o.useEffect((()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout((()=>e(t)),1),n.current=!0)}),[e,t.viewportInitialized])}(i),u.createElement(FR,{onPaneClick:G,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:X,onPaneContextMenu:K,onPaneScroll:J,deleteKeyCode:I,selectionKeyCode:S,selectionOnDrag:C,selectionMode:E,onSelectionStart:y,onSelectionEnd:b,multiSelectionKeyCode:N,panActivationKeyCode:j,zoomActivationKeyCode:_,elementsSelectable:T,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:F,zoomOnPinch:B,zoomOnDoubleClick:V,panOnScroll:U,panOnScrollSpeed:$,panOnScrollMode:H,panOnDrag:W,defaultViewport:D,translateExtent:O,minZoom:R,maxZoom:P,onSelectionContextMenu:g,preventScrolling:L,noDragClassName:ie,noWheelClassName:ae,noPanClassName:le,disableKeyboardA11y:de},u.createElement(dP,null,u.createElement(lP,{edgeTypes:me,onEdgeClick:l,onEdgeDoubleClick:d,onlyRenderVisibleElements:A,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:re,onReconnectEnd:oe,reconnectRadius:se,defaultMarkerColor:z,noPanClassName:le,elevateEdgesOnSelect:!!ce,disableKeyboardA11y:de,rfId:fe},u.createElement(pP,{style:v,type:x,component:w,containerStyle:k})),u.createElement("div",{className:"react-flow__edgelabel-renderer"}),u.createElement(HR,{nodeTypes:pe,onNodeClick:a,onNodeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:m,selectNodesOnDrag:M,onlyRenderVisibleElements:A,noPanClassName:le,noDragClassName:ie,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})))};gP.displayName="GraphView";var yP=o.memo(gP);const bP=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],xP={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:bP,nodeExtent:bP,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:CD.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:(e,t)=>{},isValidConnection:void 0},vP=()=>{return e=(e,t)=>({...xP,setNodes:n=>{const{nodeInternals:r,nodeOrigin:o,elevateNodesOnSelect:s}=t();e({nodeInternals:XO(n,r,o,s)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map((e=>({...r,...e})))})},setDefaultNodesAndEdges:(n,r)=>{const o=void 0!==n,s=void 0!==r,i=o?XO(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:s?r:[],hasDefaultNodes:o,hasDefaultEdges:s})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:o,fitViewOnInit:s,fitViewOnInitDone:i,fitViewOnInitOptions:a,domNode:l,nodeOrigin:c}=t(),d=null==l?void 0:l.querySelector(".react-flow__viewport");if(!d)return;const u=window.getComputedStyle(d),{m22:h}=new window.DOMMatrixReadOnly(u.transform),f=n.reduce(((e,t)=>{const n=o.get(t.id);if(null==n?void 0:n.hidden)o.set(n.id,{...n,[pD]:{...n[pD],handleBounds:void 0}});else if(n){const r=oD(t.nodeElement);r.width&&r.height&&(n.width!==r.width||n.height!==r.height||t.forceUpdate)&&(o.set(n.id,{...n,[pD]:{...n[pD],handleBounds:{source:jR(".source",t.nodeElement,h,c),target:jR(".target",t.nodeElement,h,c)}},...r}),e.push({id:n.id,type:"dimensions",dimensions:r}))}return e}),[]);YO(o,c);const p=i||s&&!i&&JO(t,{initial:!0,...a});e({nodeInternals:new Map(o),fitViewOnInitDone:p}),(null==f?void 0:f.length)>0&&(null==r||r(f))},updateNodePositions:(e,n=!0,r=!1)=>{const{triggerNodeChanges:o}=t();o(e.map((e=>{const t={id:e.id,type:"position",dragging:r};return n&&(t.positionAbsolute=e.positionAbsolute,t.position=e.position),t})))},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:o,hasDefaultNodes:s,nodeOrigin:i,getNodes:a,elevateNodesOnSelect:l}=t();if(null==n?void 0:n.length){if(s){const t=XO(gR(n,a()),o,i,l);e({nodeInternals:t})}null==r||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:o,getNodes:s}=t();let i,a=null;r?i=n.map((e=>yR(e,!0))):(i=bR(s(),n),a=bR(o,[])),QO({changedNodes:i,changedEdges:a,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:o,getNodes:s}=t();let i,a=null;r?i=n.map((e=>yR(e,!0))):(i=bR(o,n),a=bR(s(),[])),QO({changedNodes:a,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:o,getNodes:s}=t(),i=r||o;QO({changedNodes:(n||s()).map((e=>(e.selected=!1,yR(e.id,!1)))),changedEdges:i.map((e=>yR(e.id,!1))),get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:o}=t();null==r||r.scaleExtent([n,o]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:o}=t();null==r||r.scaleExtent([o,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;null==(r=t().d3Zoom)||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t();QO({changedNodes:r().filter((e=>e.selected)).map((e=>yR(e.id,!1))),changedEdges:n.filter((e=>e.selected)).map((e=>yR(e.id,!1))),get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach((e=>{e.positionAbsolute=iD(e.position,n)})),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:e=>{const{transform:n,width:r,height:o,d3Zoom:s,d3Selection:i,translateExtent:a}=t();if(!s||!i||!e.x&&!e.y)return!1;const l=xc.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),c=[[0,0],[r,o]],d=null==s?void 0:s.constrain()(l,c,a);return s.transform(i,d),n[0]!==d.x||n[1]!==d.y||n[2]!==d.k},cancelConnection:()=>e({connectionNodeId:xP.connectionNodeId,connectionHandleId:xP.connectionHandleId,connectionHandleType:xP.connectionHandleType,connectionStatus:xP.connectionStatus,connectionStartHandle:xP.connectionStartHandle,connectionEndHandle:xP.connectionEndHandle}),reset:()=>e({...xP})}),t=Object.is,e?gM(e,t):gM;var e,t},wP=({children:e})=>{const t=o.useRef(null);return t.current||(t.current=vP()),u.createElement($M,{value:t.current},e)};wP.displayName="ReactFlowProvider";const kP=({children:e})=>o.useContext(UM)?u.createElement(u.Fragment,null,e):u.createElement(wP,null,e);kP.displayName="ReactFlowWrapper";const SP={input:SO,default:wO,output:EO,group:NO},CP={default:XD,straight:WD,step:VD,smoothstep:HD,simplebezier:zD},EP=[0,0],NP=[15,15],jP={x:0,y:0,zoom:1},_P={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},IP=o.forwardRef((({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:s=SP,edgeTypes:i=CP,onNodeClick:a,onEdgeClick:l,onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:g,onClickConnectStart:y,onClickConnectEnd:b,onNodeMouseEnter:x,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:E,onNodeDragStop:N,onNodesDelete:j,onEdgesDelete:_,onSelectionChange:I,onSelectionDragStart:A,onSelectionDrag:T,onSelectionDragStop:M,onSelectionContextMenu:D,onSelectionStart:O,onSelectionEnd:R,connectionMode:P=CD.Strict,connectionLineType:L=AD.Bezier,connectionLineStyle:z,connectionLineComponent:F,connectionLineContainerStyle:B,deleteKeyCode:U="Backspace",selectionKeyCode:$="Shift",selectionOnDrag:H=!1,selectionMode:V=_D.Full,panActivationKeyCode:W="Space",multiSelectionKeyCode:G=(xD()?"Meta":"Control"),zoomActivationKeyCode:q=(xD()?"Meta":"Control"),snapToGrid:Y=!1,snapGrid:X=NP,onlyRenderVisibleElements:J=!1,selectNodesOnDrag:K=!0,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,nodeOrigin:te=EP,edgesFocusable:ne,edgesUpdatable:re,elementsSelectable:oe,defaultViewport:se=jP,minZoom:ie=.5,maxZoom:ae=2,translateExtent:le=bP,preventScrolling:ce=!0,nodeExtent:de,defaultMarkerColor:ue="#b1b1b7",zoomOnScroll:he=!0,zoomOnPinch:fe=!0,panOnScroll:pe=!1,panOnScrollSpeed:me=.5,panOnScrollMode:ge=ND.Free,zoomOnDoubleClick:ye=!0,panOnDrag:be=!0,onPaneClick:xe,onPaneMouseEnter:ve,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Se,onPaneContextMenu:Ce,children:Ee,onEdgeContextMenu:Ne,onEdgeDoubleClick:je,onEdgeMouseEnter:_e,onEdgeMouseMove:Ie,onEdgeMouseLeave:Ae,onEdgeUpdate:Te,onEdgeUpdateStart:Me,onEdgeUpdateEnd:De,onReconnect:Oe,onReconnectStart:Re,onReconnectEnd:Pe,reconnectRadius:Le=10,edgeUpdaterRadius:ze=10,onNodesChange:Fe,onEdgesChange:Be,noDragClassName:Ue="nodrag",noWheelClassName:$e="nowheel",noPanClassName:He="nopan",fitView:Ve=!1,fitViewOptions:We,connectOnClick:Ge=!0,attributionPosition:qe,proOptions:Ye,defaultEdgeOptions:Xe,elevateNodesOnSelect:Je=!0,elevateEdgesOnSelect:Ke=!1,disableKeyboardA11y:Ze=!1,autoPanOnConnect:Qe=!0,autoPanOnNodeDrag:et=!0,connectionRadius:tt=20,isValidConnection:nt,onError:rt,style:ot,id:st,nodeDragThreshold:it,...at},lt)=>{const ct=st||"1";return u.createElement("div",{...at,style:{...ot,..._P},ref:lt,className:uM(["react-flow",o]),"data-testid":"rf__wrapper",id:st},u.createElement(kP,null,u.createElement(yP,{onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:x,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:S,nodeTypes:s,edgeTypes:i,connectionLineType:L,connectionLineStyle:z,connectionLineComponent:F,connectionLineContainerStyle:B,selectionKeyCode:$,selectionOnDrag:H,selectionMode:V,deleteKeyCode:U,multiSelectionKeyCode:G,panActivationKeyCode:W,zoomActivationKeyCode:q,onlyRenderVisibleElements:J,selectNodesOnDrag:K,defaultViewport:se,translateExtent:le,minZoom:ie,maxZoom:ae,preventScrolling:ce,zoomOnScroll:he,zoomOnPinch:fe,zoomOnDoubleClick:ye,panOnScroll:pe,panOnScrollSpeed:me,panOnScrollMode:ge,panOnDrag:be,onPaneClick:xe,onPaneMouseEnter:ve,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Se,onPaneContextMenu:Ce,onSelectionContextMenu:D,onSelectionStart:O,onSelectionEnd:R,onEdgeContextMenu:Ne,onEdgeDoubleClick:je,onEdgeMouseEnter:_e,onEdgeMouseMove:Ie,onEdgeMouseLeave:Ae,onReconnect:Oe??Te,onReconnectStart:Re??Me,onReconnectEnd:Pe??De,reconnectRadius:Le??ze,defaultMarkerColor:ue,noDragClassName:Ue,noWheelClassName:$e,noPanClassName:He,elevateEdgesOnSelect:Ke,rfId:ct,disableKeyboardA11y:Ze,nodeOrigin:te,nodeExtent:de}),u.createElement(PO,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:g,onClickConnectStart:y,onClickConnectEnd:b,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,edgesFocusable:ne,edgesUpdatable:re,elementsSelectable:oe,elevateNodesOnSelect:Je,minZoom:ie,maxZoom:ae,nodeExtent:de,onNodesChange:Fe,onEdgesChange:Be,snapToGrid:Y,snapGrid:X,connectionMode:P,translateExtent:le,connectOnClick:Ge,defaultEdgeOptions:Xe,fitView:Ve,fitViewOptions:We,onNodesDelete:j,onEdgesDelete:_,onNodeDragStart:C,onNodeDrag:E,onNodeDragStop:N,onSelectionDrag:T,onSelectionDragStart:A,onSelectionDragStop:M,noPanClassName:He,nodeOrigin:te,rfId:ct,autoPanOnConnect:Qe,autoPanOnNodeDrag:et,onError:rt,connectionRadius:tt,isValidConnection:nt,nodeDragThreshold:it}),u.createElement(MO,{onSelectionChange:I}),Ee,u.createElement(nD,{proOptions:Ye,position:qe}),u.createElement(HO,{rfId:ct,disableKeyboardA11y:Ze})))}));function AP(e){return t=>{const[n,r]=o.useState(t),s=o.useCallback((t=>r((n=>e(t,n)))),[]);return[n,r,s]}}IP.displayName="ReactFlow";const TP=AP(gR),MP=AP((function(e,t){return mR(e,t)}));function DP(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},u.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function OP(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},u.createElement("path",{d:"M0 0h32v4.2H0z"}))}function RP(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},u.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function PP(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},u.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function LP(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},u.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const zP=({children:e,className:t,...n})=>u.createElement("button",{type:"button",className:uM(["react-flow__controls-button",t]),...n},e);zP.displayName="ControlButton";const FP=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),BP=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:d,children:h,position:f="bottom-left"})=>{const p=QM(),[m,g]=o.useState(!1),{isInteractive:y,minZoomReached:b,maxZoomReached:x}=ZM(FP,yM),{zoomIn:v,zoomOut:w,fitView:k}=rR();if(o.useEffect((()=>{g(!0)}),[]),!m)return null;return u.createElement(tD,{className:uM(["react-flow__controls",d]),position:f,style:e,"data-testid":"rf__controls"},t&&u.createElement(u.Fragment,null,u.createElement(zP,{onClick:()=>{v(),null==i||i()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x},u.createElement(DP,null)),u.createElement(zP,{onClick:()=>{w(),null==a||a()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b},u.createElement(OP,null))),n&&u.createElement(zP,{className:"react-flow__controls-fitview",onClick:()=>{k(s),null==l||l()},title:"fit view","aria-label":"fit view"},u.createElement(RP,null)),r&&u.createElement(zP,{className:"react-flow__controls-interactive",onClick:()=>{p.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),null==c||c(!y)},title:"toggle interactivity","aria-label":"toggle interactivity"},y?u.createElement(LP,null):u.createElement(PP,null)),h)};BP.displayName="Controls";var UP,$P,HP=o.memo(BP);function VP({color:e,dimensions:t,lineWidth:n}){return u.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function WP({color:e,radius:t}){return u.createElement("circle",{cx:t,cy:t,r:t,fill:e})}($P=UP||(UP={})).Lines="lines",$P.Dots="dots",$P.Cross="cross";const GP={[UP.Dots]:"#91919a",[UP.Lines]:"#eee",[UP.Cross]:"#e2e2e2"},qP={[UP.Dots]:1,[UP.Lines]:1,[UP.Cross]:6},YP=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function XP({id:e,variant:t=UP.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=2,color:a,style:l,className:c}){const d=o.useRef(null),{transform:h,patternId:f}=ZM(YP,yM),p=a||GP[t],m=r||qP[t],g=t===UP.Dots,y=t===UP.Cross,b=Array.isArray(n)?n:[n,n],x=[b[0]*h[2]||1,b[1]*h[2]||1],v=m*h[2],w=y?[v,v]:x,k=g?[v/i,v/i]:[w[0]/i,w[1]/i];return u.createElement("svg",{className:uM(["react-flow__background",c]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:d,"data-testid":"rf__background"},u.createElement("pattern",{id:f+e,x:h[0]%x[0],y:h[1]%x[1],width:x[0],height:x[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`},g?u.createElement(WP,{color:p,radius:v/i}):u.createElement(VP,{dimensions:w,color:p,lineWidth:s})),u.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+e})`}))}XP.displayName="Background";var JP=o.memo(XP);function KP(e){return Math.min(11*e+35,200)}const ZP=u.createContext("LR"),QP=o.memo((e=>{const t=j.c(51),{data:n,selected:r}=e,s=se(n.atom),i=Hi().inOrderIds.indexOf(s.id),a=r?"var(--gray-9)":"var(--gray-3)",l=ZM(tL),c=o.useContext(ZP);let d,u,h,f,p;if(t[0]!==s.code||t[1]!==a||t[2]!==c||t[3]!==r){const e=s.code.split("\n").length,n="LR"===c?OD.Left:OD.Top;let o;t[8]!==a?(o={background:a},t[8]=a,t[9]=o):o=t[9],t[10]!==n||t[11]!==o?(h=I.jsx(xO,{type:"target",id:"inputs",position:n,style:o}),t[10]=n,t[11]=o,t[12]=h):h=t[12];const i="LR"===c?OD.Left:OD.Top;let l;t[13]!==a?(l={background:a},t[13]=a,t[14]=l):l=t[14],t[15]!==i||t[16]!==l?(f=I.jsx(xO,{type:"source",id:"inputs",position:i,style:l}),t[15]=i,t[16]=l,t[17]=f):f=t[17];const p=r&&"border-primary";t[18]!==p?(u=In("flex flex-col bg-card border border-input/50 rounded-md mx-[2px] overflow-hidden",p),t[18]=p,t[19]=u):u=t[19],d=KP(e),t[0]=s.code,t[1]=a,t[2]=c,t[3]=r,t[4]=d,t[5]=u,t[6]=h,t[7]=f}else d=t[4],u=t[5],h=t[6],f=t[7];var m;let g;t[20]!==n.forceWidth||t[21]!==l?(p=n.forceWidth||(m=l,Math.min(Math.max(m-100,100),400)),t[20]=n.forceWidth,t[21]=l,t[22]=p):p=t[22],t[23]!==d||t[24]!==p?(g={height:d,width:p},t[23]=d,t[24]=p,t[25]=g):g=t[25];const y=Vi(s.name,i);let b,x,v;t[26]!==y?(b=I.jsx("div",{className:"text-muted-foreground font-semibold text-xs py-1 px-2 bg-muted border-b",children:y}),t[26]=y,t[27]=b):b=t[27],t[28]!==s.code?(x=I.jsx(mc,{code:s.code}),t[28]=s.code,t[29]=x):x=t[29],t[30]!==u||t[31]!==g||t[32]!==b||t[33]!==x?(v=I.jsxs("div",{className:u,style:g,children:[b,x]}),t[30]=u,t[31]=g,t[32]=b,t[33]=x,t[34]=v):v=t[34];const w="LR"===c?OD.Right:OD.Bottom;let k,S;t[35]!==a?(k={background:a},t[35]=a,t[36]=k):k=t[36],t[37]!==w||t[38]!==k?(S=I.jsx(xO,{type:"source",id:"outputs",position:w,style:k}),t[37]=w,t[38]=k,t[39]=S):S=t[39];const C="LR"===c?OD.Right:OD.Bottom;let E,N,_;return t[40]!==a?(E={background:a},t[40]=a,t[41]=E):E=t[41],t[42]!==C||t[43]!==E?(N=I.jsx(xO,{type:"target",id:"outputs",position:C,style:E}),t[42]=C,t[43]=E,t[44]=N):N=t[44],t[45]!==v||t[46]!==S||t[47]!==N||t[48]!==h||t[49]!==f?(_=I.jsxs("div",{children:[h,f,v,S,N]}),t[45]=v,t[46]=S,t[47]=N,t[48]=h,t[49]=f,t[50]=_):_=t[50],_}),((e,t)=>["data","selected","id"].every((n=>e[n]===t[n]))));QP.displayName="CustomNode";const eL={custom:QP};function tL(e){const{width:t}=e;return t}const nL=e=>{const t=j.c(18),{maxCount:n,cellIds:r,onClick:o,skipScroll:s}=e,i=Hi();let a,l,c,d;if(t[0]!==r||t[1]!==i.inOrderIds||t[2]!==n||t[3]!==o||t[4]!==s){c=Symbol.for("react.early_return_sentinel");e:{let e;t[8]!==i.inOrderIds?(e=(e,t)=>i.inOrderIds.indexOf(e)-i.inOrderIds.indexOf(t),t[8]=i.inOrderIds,t[9]=e):e=t[9];const d=[...r].sort(e);if(0===r.length){let e;t[10]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx("div",{className:"text-muted-foreground",children:"--"}),t[10]=e):e=t[10],c=e;break e}let u;t[11]!==r.length||t[12]!==o||t[13]!==s?(u=(e,t)=>I.jsxs("span",{className:"truncate",children:[I.jsx(Wi,{variant:"focus",cellId:e,skipScroll:s,className:"whitespace-nowrap",onClick:o?()=>o(e):void 0},e),t<r.length-1&&", "]},e),t[11]=r.length,t[12]=o,t[13]=s,t[14]=u):u=t[14],a=d.slice(0,n).map(u),l=r.length>n&&I.jsxs(Pn,{children:[I.jsx(hs,{asChild:!0,children:I.jsxs("span",{className:"whitespace-nowrap text-muted-foreground text-xs hover:underline cursor-pointer",children:["+",r.length-n," more"]})}),I.jsx(Dn,{className:"w-auto",children:I.jsx("div",{className:"flex flex-col gap-1 py-1",children:d.slice(n).map((e=>I.jsx(Wi,{variant:"focus",cellId:e,className:"whitespace-nowrap",onClick:o?()=>o(e):void 0},e)))})})]})}t[0]=r,t[1]=i.inOrderIds,t[2]=n,t[3]=o,t[4]=s,t[5]=a,t[6]=l,t[7]=c}else a=t[5],l=t[6],c=t[7];return c!==Symbol.for("react.early_return_sentinel")?c:(t[15]!==a||t[16]!==l?(d=I.jsxs(I.Fragment,{children:[a,l]}),t[15]=a,t[16]=l,t[17]=d):d=t[17],d)},rL=e=>{const t=j.c(15);let n,r,o,s;t[0]!==e?(({name:r,declaredBy:n,onClick:o,...s}=e),t[0]=e,t[1]=n,t[2]=r,t[3]=o,t[4]=s):(n=t[1],r=t[2],o=t[3],s=t[4]);const i=n.length>1?"destructive":"outline";let a,l,c;return t[5]!==r||t[6]!==o?(a=async e=>{o?o(e):(await nt(r),ee({title:"Copied to clipboard"}))},t[5]=r,t[6]=o,t[7]=a):a=t[7],t[8]!==r||t[9]!==i||t[10]!==a?(l=I.jsx(Gi,{title:r,variant:i,className:"rounded-sm text-ellipsis block overflow-hidden max-w-fit cursor-pointer font-medium",onClick:a,children:r}),t[8]=r,t[9]=i,t[10]=a,t[11]=l):l=t[11],t[12]!==s||t[13]!==l?(c=I.jsx("div",{className:"max-w-[130px]",...s,children:l}),t[12]=s,t[13]=l,t[14]=c):c=t[14],c},oL=o.memo((e=>{const t=j.c(38),{onChange:n,view:r,settings:o,onSettingsChange:s}=e;let i;t[0]!==s||t[1]!==o?(i=(e,t)=>{s({...o,[e]:t})},t[0]=s,t[1]=o,t[2]=i):i=t[2];const a=i;let l,c,d,u,h,f;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=I.jsx(hs,{asChild:!0,children:I.jsx(X,{variant:"text",size:"xs",children:I.jsx(Yt,{className:"w-4 h-4"})})}),t[3]=l):l=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx("div",{className:"font-semibold pb-4",children:"Settings"}),t[4]=c):c=t[4],t[5]!==a?(d=e=>a("hidePureMarkdown",Boolean(e)),t[5]=a,t[6]=d):d=t[6],t[7]!==o.hidePureMarkdown||t[8]!==d?(u=I.jsx(Ds,{"data-testid":"hide-pure-markdown-checkbox",id:"hide-pure-markdown",checked:o.hidePureMarkdown,onCheckedChange:d}),t[7]=o.hidePureMarkdown,t[8]=d,t[9]=u):u=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(h=I.jsx(Me,{htmlFor:"hide-pure-markdown",children:"Hide pure markdown"}),t[10]=h):h=t[10],t[11]!==u?(f=I.jsxs(Pn,{children:[l,I.jsxs(Dn,{className:"w-auto p-2 text-muted-foreground",children:[c,I.jsxs("div",{className:"flex items-center gap-2",children:[u,h]})]})]}),t[11]=u,t[12]=f):f=t[12];const p=f,m="_minimap_"===r;let g,y,b;t[13]!==n?(g=()=>n("_minimap_"),t[13]=n,t[14]=g):g=t[14],t[15]===Symbol.for("react.memo_cache_sentinel")?(y=I.jsx(kd,{className:"w-4 h-4 mr-1"}),t[15]=y):y=t[15],t[16]!==m||t[17]!==g?(b=I.jsxs(X,{variant:"outline",className:"bg-background","aria-selected":m,size:"xs",onClick:g,children:[y,"Mini Map"]}),t[16]=m,t[17]=g,t[18]=b):b=t[18];const x="TB"===r;let v,w,k;t[19]!==n?(v=()=>n("TB"),t[19]=n,t[20]=v):v=t[20],t[21]===Symbol.for("react.memo_cache_sentinel")?(w=I.jsx(dd,{className:"w-4 h-4 mr-1"}),t[21]=w):w=t[21],t[22]!==x||t[23]!==v?(k=I.jsxs(X,{variant:"outline",className:"bg-background","aria-selected":x,size:"xs",onClick:v,children:[w,"Vertical Tree"]}),t[22]=x,t[23]=v,t[24]=k):k=t[24];const S="LR"===r;let C,E,N,_;t[25]!==n?(C=()=>n("LR"),t[25]=n,t[26]=C):C=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(E=I.jsx(dd,{className:"w-4 h-4 mr-1 transform -rotate-90"}),t[27]=E):E=t[27],t[28]!==S||t[29]!==C?(N=I.jsxs(X,{variant:"outline",className:"bg-background","aria-selected":S,size:"xs",onClick:C,children:[E," ","Horizontal Tree"]}),t[28]=S,t[29]=C,t[30]=N):N=t[30],t[31]!==b||t[32]!==k||t[33]!==N?(_=I.jsxs("div",{className:"flex gap-2",children:[b,k,N]}),t[31]=b,t[32]=k,t[33]=N,t[34]=_):_=t[34];const A="_minimap_"!==r&&p;let T;return t[35]!==_||t[36]!==A?(T=I.jsxs(tD,{position:"top-right",className:"flex flex-col items-end gap-2",children:[_,A]}),t[35]=_,t[36]=A,t[37]=T):T=t[37],T}));oL.displayName="GraphToolbar";const sL=o.memo((e=>{const t=j.c(11),{selection:n,variables:r,onClearSelection:o}=e;if(!n)return null;const s=iL;let i;t[0]!==o||t[1]!==n.id||t[2]!==n.source||t[3]!==n.target||t[4]!==n.type||t[5]!==r?(i=()=>{if("node"===n.type){const e=Object.values(r).filter((e=>e.usedBy.includes(n.id))),t=Object.values(r).filter((e=>e.declaredBy.includes(n.id))),i=(e,t)=>I.jsxs(I.Fragment,{children:[0===e.length&&I.jsx("div",{className:"text-muted-foreground text-sm text-center",children:"--"}),I.jsx("div",{className:"grid grid-cols-5 gap-3 items-center text-sm py-1 flex-1 empty:hidden",children:e.map((e=>I.jsxs(u.Fragment,{children:[I.jsx(rL,{declaredBy:e.declaredBy,name:e.name}),I.jsxs("div",{className:"truncate col-span-2",title:e.value??"",children:[e.value,I.jsxs("span",{className:"ml-1 truncate text-foreground/60 font-mono",children:["(",e.dataType,")"]})]}),I.jsx("div",{className:"truncate col-span-2 gap-1 items-center",children:I.jsx(nL,{skipScroll:!0,onClick:()=>s("in"===t?e.declaredBy[0]:e.usedBy[0],e.name),maxCount:3,cellIds:e.usedBy})})]},e.name)))})]});return I.jsxs(I.Fragment,{children:[I.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[I.jsx(mt,{className:"w-5 h-5"}),I.jsx(Wi,{cellId:n.id}),I.jsx("div",{className:"flex-1"}),I.jsx(Vw,{cellId:n.id,children:I.jsx(X,{variant:"ghost",size:"icon",children:I.jsx(Wc,{className:"w-4 h-4"})})}),I.jsx(X,{variant:"text",size:"icon",onClick:()=>{o()},children:I.jsx(Cn,{className:"w-4 h-4"})})]}),I.jsxs("div",{className:"text-sm flex flex-col py-3 pl-2 pr-4 flex-1 justify-center",children:[I.jsxs("div",{className:"flex flex-col gap-2",children:[I.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[I.jsx(jc,{className:"w-4 h-4"}),"Outputs"]}),i(t,"out")]}),I.jsx("hr",{className:"border-divider my-3"}),I.jsxs("div",{className:"flex flex-col gap-2",children:[I.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[I.jsx(_c,{className:"w-4 h-4"}),"Inputs"]}),i(e,"in")]})]})]})}if("edge"===n.type){const e=Object.values(r).filter((e=>e.declaredBy.includes(n.source)&&e.usedBy.includes(n.target)));return I.jsxs(I.Fragment,{children:[I.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[I.jsx(Bd,{className:"w-4 h-4"}),I.jsx(Wi,{cellId:n.source}),I.jsx(Ic,{className:"w-4 h-4"}),I.jsx(Wi,{cellId:n.target})]}),I.jsx("div",{className:"grid grid-cols-4 gap-3 max-w-[350px] items-center text-sm p-3 flex-1",children:e.map((e=>I.jsxs(u.Fragment,{children:[I.jsx(rL,{declaredBy:e.declaredBy,name:e.name,onClick:()=>{s(e.declaredBy[0],e.name)}}),I.jsx("div",{className:"truncate text-foreground/60 font-mono",children:e.dataType}),I.jsx("div",{className:"truncate col-span-2",title:e.value??"",children:e.value})]},e.name)))})]})}},t[0]=o,t[1]=n.id,t[2]=n.source,t[3]=n.target,t[4]=n.type,t[5]=r,t[6]=i):i=t[6];const a=i;let l,c;return t[7]!==a?(l=a(),t[7]=a,t[8]=l):l=t[8],t[9]!==l?(c=I.jsx(tD,{position:"bottom-left",className:"max-h-[90%] flex flex-col w-[calc(100%-5rem)]",children:I.jsx("div",{className:"min-h-[100px] shadow-md rounded-md border max-w-[550px] border-primary/40 my-4 min-w-[240px] bg-[var(--slate-1)] text-muted-foreground/80 flex flex-col overflow-y-auto",children:l})}),t[9]=l,t[10]=c):c=t[10],c}));function iL(e,t){const n=oe(e);n&&qi(n,t)}function aL(){const e=j.c(7),t=rR(),n=ZM(cL),r=ZM(lL);let s;e[0]!==t?(s=()=>{t.fitView({duration:100})},e[0]=t,e[1]=s):s=e[1];const i=Yi(s,100);let a,l;e[2]!==i||e[3]!==r||e[4]!==n?(a=()=>{n&&r&&i()},l=[n,r,i],e[2]=i,e[3]=r,e[4]=n,e[5]=a,e[6]=l):(a=e[5],l=e[6]),o.useEffect(a,l)}function lL(e){const{height:t}=e;return t}function cL(e){const{width:t}=e;return t}sL.displayName="GraphSelectionPanel";const dL=new class{createEdge(e,t,n){return{type:"smoothstep",pathOptions:{offset:20,borderRadius:100},data:{direction:n},markerEnd:{type:MD.Arrow},id:`${e}-${t}-${n}`,source:e,sourceHandle:n,targetHandle:n,target:t}}createNode(e,t,n){return{id:e,data:{atom:t},width:250,type:"custom",height:KP(K.get(t).code.trim().split("\n").length),position:{x:0,y:n+20}}}createElements(e,t,n,r){let o=0;const s=[],i=[];for(const[l,c]of yi.zip(e,t)){const e=this.createNode(l,c,o);s.push(e),o=e.position.y+(e.height||0)}const a=new Set;for(const l of Object.values(n)){const{declaredBy:e,usedBy:t}=l;for(const n of e)for(const e of t){const t=`${n}-${e}`;a.has(t)||(a.add(t),i.push(this.createEdge(n,e,"inputs"),this.createEdge(n,e,"outputs")))}}return{nodes:s,edges:i}}},uL=e=>{const t=j.c(37),{cellIds:n,variables:r,cellAtoms:s,children:i}=e;let a;t[0]!==s||t[1]!==n||t[2]!==r?(a=dL.createElements(n,s,r,!1),t[0]=s,t[1]=n,t[2]=r,t[3]=a):a=t[3];const{nodes:l,edges:c}=a;let d;t[4]===Symbol.for("react.memo_cache_sentinel")?(d=[],t[4]=d):d=t[4];const[u,h]=MP(d),[f,p]=TP(l),[m,g]=o.useState(),[y,b]=o.useState(),x=o.useRef(!1);aL();const v=ZM(hL);let w;t[5]!==h||t[6]!==p?(w=e=>{p(e.nodes),h([])},t[5]=h,t[6]=p,t[7]=w):w=t[7];const k=B(w);let S,C,E,N;t[8]!==s||t[9]!==n||t[10]!==k||t[11]!==r?(S=()=>{x.current?k(dL.createElements(n,s,r,!1)):x.current=!0},C=[n,r,s,k],t[8]=s,t[9]=n,t[10]=k,t[11]=r,t[12]=S,t[13]=C):(S=t[12],C=t[13]),o.useEffect(S,C),t[14]!==c||t[15]!==m||t[16]!==h?(E=()=>{if(m){const e=c.filter((e=>{const{source:t,target:n,data:r}=e;return t===m&&"outputs"===r.direction||n===m&&"inputs"===r.direction}));h(e)}},N=[m,h,c],t[14]=c,t[15]=m,t[16]=h,t[17]=E,t[18]=N):(E=t[17],N=t[18]),o.useEffect(E,N);const _=function(e,t){const n=j.c(17);let r,o;if(n[0]!==t||n[1]!==e){let r;n[3]!==t?(r=(e,n)=>{const{position:r}=n;return Math.min(e,r.y-t/2-10)},n[3]=t,n[4]=r):r=n[4],o=e.reduce(r,Number.POSITIVE_INFINITY),n[0]=t,n[1]=e,n[2]=o}else o=n[2];const s=o;let i;if(n[5]!==t||n[6]!==e){let r;n[8]!==t?(r=(e,n)=>{const{position:r}=n;return Math.max(e,r.y+t/2+10)},n[8]=t,n[9]=r):r=n[9],i=e.reduce(r,Number.NEGATIVE_INFINITY),n[5]=t,n[6]=e,n[7]=i}else i=n[7];const a=i;let l,c,d;n[10]!==s?(l=[Number.NEGATIVE_INFINITY,s],n[10]=s,n[11]=l):l=n[11];n[12]!==a?(c=[Number.POSITIVE_INFINITY,a],n[12]=a,n[13]=c):c=n[13];n[14]!==l||n[15]!==c?(d=[l,c],n[14]=l,n[15]=c,n[16]=d):d=n[16];return r=d,r}(f,v);let A;t[19]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{g(void 0),b(void 0)},t[19]=A):A=t[19];const T=A;let M;t[20]!==u||t[21]!==y||t[22]!==m||t[23]!==r?(M=()=>y?I.jsx(sL,{selection:{type:"edge",source:y.source,target:y.target},onClearSelection:T,variables:r,edges:u}):m?I.jsx(sL,{selection:{type:"node",id:m},variables:r,edges:u,onClearSelection:T}):null,t[20]=u,t[21]=y,t[22]=m,t[23]=r,t[24]=M):M=t[24];const D=M;let O,R,P,L;return t[25]!==h?(O=(e,t)=>{const n=t.id;g(n),b(void 0),h([])},t[25]=h,t[26]=O):O=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(R=(e,t)=>{b(t)},t[27]=R):R=t[27],t[28]!==D?(P=D(),t[28]=D,t[29]=P):P=t[29],t[30]!==i||t[31]!==u||t[32]!==f||t[33]!==O||t[34]!==P||t[35]!==_?(L=I.jsxs(IP,{nodes:f,edges:u,nodeTypes:eL,translateExtent:_,onNodeClick:O,onNodeDoubleClick:fL,onEdgeClick:R,snapToGrid:!0,fitView:!0,elementsSelectable:!0,minZoom:1,maxZoom:1,draggable:!1,panOnScrollMode:ND.Vertical,zoomOnDoubleClick:!1,nodesDraggable:!1,nodesConnectable:!1,nodesFocusable:!1,edgesFocusable:!1,selectNodesOnDrag:!1,panOnDrag:!1,preventScrolling:!1,zoomOnPinch:!1,panOnScroll:!0,autoPanOnNodeDrag:!1,autoPanOnConnect:!1,children:[P,i]}),t[30]=i,t[31]=u,t[32]=f,t[33]=O,t[34]=P,t[35]=_,t[36]=L):L=t[36],L};function hL(e){const{height:t}=e;return t}function fL(e,t){Xi(t.id,"focus")}var pL="\0";function mL(e,t){e[t]?e[t]++:e[t]=1}function gL(e,t){--e[t]||delete e[t]}function yL(e,t,n,r){var o=""+t,s=""+n;if(!e&&o>s){var i=o;o=s,s=i}return o+""+s+""+(void 0===r?"\0":r)}function bL(e,t){return yL(e,t.v,t.w,t.name)}var xL=class{constructor(e){n(this,"_isDirected",!0),n(this,"_isMultigraph",!1),n(this,"_isCompound",!1),n(this,"_label"),n(this,"_defaultNodeLabelFn",(()=>{})),n(this,"_defaultEdgeLabelFn",(()=>{})),n(this,"_nodes",{}),n(this,"_in",{}),n(this,"_preds",{}),n(this,"_out",{}),n(this,"_sucs",{}),n(this,"_edgeObjs",{}),n(this,"_edgeLabels",{}),n(this,"_nodeCount",0),n(this,"_edgeCount",0),n(this,"_parent"),n(this,"_children"),e&&(this._isDirected=!Object.hasOwn(e,"directed")||e.directed,this._isMultigraph=!!Object.hasOwn(e,"multigraph")&&e.multigraph,this._isCompound=!!Object.hasOwn(e,"compound")&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[pL]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,"function"!=typeof e&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._in[t]).length))}sinks(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._out[t]).length))}setNodes(e,t){var n=arguments,r=this;return e.forEach((function(e){n.length>1?r.setNode(e,t):r.setNode(e)})),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=pL,this._children[e]={},this._children[pL][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var n=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach((function(e){t.setParent(e)})),delete this._children[e]),Object.keys(this._in[e]).forEach(n),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(void 0===t)t=pL;else{for(var n=t+="";void 0!==n;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==pL)return t}}children(e=pL){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else{if(e===pL)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){const r=new Set(t);for(var n of this.successors(e))r.add(n);return Array.from(r.values())}}isLeaf(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach((function([n,r]){e(n)&&t.setNode(n,r)})),Object.values(this._edgeObjs).forEach((function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))}));var r={};function o(e){var s=n.parent(e);return void 0===s||t.hasNode(s)?(r[e]=s,s):s in r?r[s]:o(s)}return this._isCompound&&t.nodes().forEach((e=>t.setParent(e,o(e)))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,"function"!=typeof e&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var n=this,r=arguments;return e.reduce((function(e,o){return r.length>1?n.setEdge(e,o,t):n.setEdge(e,o),o})),this}setEdge(){var e,t,n,r,o=!1,s=arguments[0];"object"==typeof s&&null!==s&&"v"in s?(e=s.v,t=s.w,n=s.name,2===arguments.length&&(r=arguments[1],o=!0)):(e=s,t=arguments[1],n=arguments[3],arguments.length>2&&(r=arguments[2],o=!0)),e=""+e,t=""+t,void 0!==n&&(n=""+n);var i=yL(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,i))return o&&(this._edgeLabels[i]=r),this;if(void 0!==n&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[i]=o?r:this._defaultEdgeLabelFn(e,t,n);var a=function(e,t,n,r){var o=""+t,s=""+n;if(!e&&o>s){var i=o;o=s,s=i}var a={v:o,w:s};r&&(a.name=r);return a}(this._isDirected,e,t,n);return e=a.v,t=a.w,Object.freeze(a),this._edgeObjs[i]=a,mL(this._preds[t],e),mL(this._sucs[e],t),this._in[t][i]=a,this._out[e][i]=a,this._edgeCount++,this}edge(e,t,n){var r=1===arguments.length?bL(this._isDirected,arguments[0]):yL(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(){const e=this.edge(...arguments);return"object"!=typeof e?{label:e}:e}hasEdge(e,t,n){var r=1===arguments.length?bL(this._isDirected,arguments[0]):yL(this._isDirected,e,t,n);return Object.hasOwn(this._edgeLabels,r)}removeEdge(e,t,n){var r=1===arguments.length?bL(this._isDirected,arguments[0]):yL(this._isDirected,e,t,n),o=this._edgeObjs[r];return o&&(e=o.v,t=o.w,delete this._edgeLabels[r],delete this._edgeObjs[r],gL(this._preds[t],e),gL(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var r=Object.values(n);return t?r.filter((e=>e.v===t)):r}}outEdges(e,t){var n=this._out[e];if(n){var r=Object.values(n);return t?r.filter((e=>e.w===t)):r}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}},vL={Graph:xL,version:"2.2.4"},wL=xL,kL={write:function(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:SL(e),edges:CL(e)};void 0!==e.graph()&&(t.value=structuredClone(e.graph()));return t},read:function(e){var t=new wL(e.options).setGraph(e.value);return e.nodes.forEach((function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)})),e.edges.forEach((function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)})),t}};function SL(e){return e.nodes().map((function(t){var n=e.node(t),r=e.parent(t),o={v:t};return void 0!==n&&(o.value=n),void 0!==r&&(o.parent=r),o}))}function CL(e){return e.edges().map((function(t){var n=e.edge(t),r={v:t.v,w:t.w};return void 0!==t.name&&(r.name=t.name),void 0!==n&&(r.value=n),r}))}var EL=function(e){var t,n={},r=[];function o(r){Object.hasOwn(n,r)||(n[r]=!0,t.push(r),e.successors(r).forEach(o),e.predecessors(r).forEach(o))}return e.nodes().forEach((function(e){t=[],o(e),t.length&&r.push(t)})),r};var NL=class{constructor(){n(this,"_arr",[]),n(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map((function(e){return e.key}))}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority}min(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key}add(e,t){var n=this._keyIndices;if(e=String(e),!Object.hasOwn(n,e)){var r=this._arr,o=r.length;return n[e]=o,r.push({key:e,priority:t}),this._decrease(o),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[n].priority+" New: "+t);this._arr[n].priority=t,this._decrease(n)}_heapify(e){var t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){for(var t,n=this._arr,r=n[e].priority;0!==e&&!(n[t=e>>1].priority<r);)this._swap(e,t),e=t}_swap(e,t){var n=this._arr,r=this._keyIndices,o=n[e],s=n[t];n[e]=s,n[t]=o,r[s.key]=e,r[o.key]=t}},jL=NL,_L=function(e,t,n,r){return function(e,t,n,r){var o,s,i={},a=new jL,l=function(e){var t=e.v!==o?e.v:e.w,r=i[t],l=n(e),c=s.distance+l;if(l<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+l);c<r.distance&&(r.distance=c,r.predecessor=o,a.decrease(t,c))};e.nodes().forEach((function(e){var n=e===t?0:Number.POSITIVE_INFINITY;i[e]={distance:n},a.add(e,n)}));for(;a.size()>0&&(o=a.removeMin(),(s=i[o]).distance!==Number.POSITIVE_INFINITY);)r(o).forEach(l);return i}(e,String(t),n||IL,r||function(t){return e.outEdges(t)})},IL=()=>1;var AL=_L,TL=function(e,t,n){return e.nodes().reduce((function(r,o){return r[o]=AL(e,o,t,n),r}),{})};var ML=function(e){var t=0,n=[],r={},o=[];function s(i){var a=r[i]={onStack:!0,lowlink:t,index:t++};if(n.push(i),e.successors(i).forEach((function(e){Object.hasOwn(r,e)?r[e].onStack&&(a.lowlink=Math.min(a.lowlink,r[e].index)):(s(e),a.lowlink=Math.min(a.lowlink,r[e].lowlink))})),a.lowlink===a.index){var l,c=[];do{l=n.pop(),r[l].onStack=!1,c.push(l)}while(i!==l);o.push(c)}}return e.nodes().forEach((function(e){Object.hasOwn(r,e)||s(e)})),o};var DL=ML,OL=function(e){return DL(e).filter((function(t){return t.length>1||1===t.length&&e.hasEdge(t[0],t[0])}))};var RL=function(e,t,n){return function(e,t,n){var r={},o=e.nodes();return o.forEach((function(e){r[e]={},r[e][e]={distance:0},o.forEach((function(t){e!==t&&(r[e][t]={distance:Number.POSITIVE_INFINITY})})),n(e).forEach((function(n){var o=n.v===e?n.w:n.v,s=t(n);r[e][o]={distance:s,predecessor:e}}))})),o.forEach((function(e){var t=r[e];o.forEach((function(n){var s=r[n];o.forEach((function(n){var r=s[e],o=t[n],i=s[n],a=r.distance+o.distance;a<i.distance&&(i.distance=a,i.predecessor=o.predecessor)}))}))})),r}(e,t||PL,n||function(t){return e.outEdges(t)})},PL=()=>1;function LL(e){var t={},n={},r=[];if(e.sinks().forEach((function o(s){if(Object.hasOwn(n,s))throw new zL;Object.hasOwn(t,s)||(n[s]=!0,t[s]=!0,e.predecessors(s).forEach(o),delete n[s],r.push(s))})),Object.keys(t).length!==e.nodeCount())throw new zL;return r}class zL extends Error{constructor(){super(...arguments)}}var FL=LL;LL.CycleException=zL;var BL=FL;var UL=function(e,t,n){Array.isArray(t)||(t=[t]);var r=e.isDirected()?t=>e.successors(t):t=>e.neighbors(t),o="post"===n?$L:HL,s=[],i={};return t.forEach((t=>{if(!e.hasNode(t))throw new Error("Graph does not have node: "+t);o(t,r,i,s)})),s};function $L(e,t,n,r){for(var o=[[e,!1]];o.length>0;){var s=o.pop();s[1]?r.push(s[0]):Object.hasOwn(n,s[0])||(n[s[0]]=!0,o.push([s[0],!0]),VL(t(s[0]),(e=>o.push([e,!1]))))}}function HL(e,t,n,r){for(var o=[e];o.length>0;){var s=o.pop();Object.hasOwn(n,s)||(n[s]=!0,r.push(s),VL(t(s),(e=>o.push(e))))}}function VL(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}var WL=UL;var GL=UL;var qL=xL,YL=NL;var XL={Graph:vL.Graph,json:kL,alg:{components:EL,dijkstra:_L,dijkstraAll:TL,findCycles:OL,floydWarshall:RL,isAcyclic:function(e){try{BL(e)}catch(iX){if(iX instanceof BL.CycleException)return!1;throw iX}return!0},postorder:function(e,t){return WL(e,t,"post")},preorder:function(e,t){return GL(e,t,"pre")},prim:function(e,t){var n,r=new qL,o={},s=new YL;function i(e){var r=e.v===n?e.w:e.v,i=s.priority(r);if(void 0!==i){var a=t(e);a<i&&(o[r]=n,s.decrease(r,a))}}if(0===e.nodeCount())return r;e.nodes().forEach((function(e){s.add(e,Number.POSITIVE_INFINITY),r.setNode(e)})),s.decrease(e.nodes()[0],0);var a=!1;for(;s.size()>0;){if(n=s.removeMin(),Object.hasOwn(o,n))r.setEdge(n,o[n]);else{if(a)throw new Error("Input graph is not connected: "+e);a=!0}e.nodeEdges(n).forEach(i)}return r},tarjan:ML,topsort:FL},version:vL.version};function JL(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function KL(e,t){if("_next"!==e&&"_prev"!==e)return t}let ZL=XL.Graph,QL=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return JL(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&JL(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,KL)),n=n._prev;return"["+e.join(", ")+"]"}};var ez=function(e,t){if(e.nodeCount()<=1)return[];let n=function(e,t){let n=new ZL,r=0,o=0;e.nodes().forEach((e=>{n.setNode(e,{v:e,in:0,out:0})})),e.edges().forEach((e=>{let s=n.edge(e.v,e.w)||0,i=t(e),a=s+i;n.setEdge(e.v,e.w,a),o=Math.max(o,n.node(e.v).out+=i),r=Math.max(r,n.node(e.w).in+=i)}));let s=function(e){const t=[];for(let n=0;n<e;n++)t.push(n);return t}(o+r+3).map((()=>new QL)),i=r+1;return n.nodes().forEach((e=>{rz(s,i,n.node(e))})),{graph:n,buckets:s,zeroIdx:i}}(e,t||tz);return function(e,t,n){let r,o=[],s=t[t.length-1],i=t[0];for(;e.nodeCount();){for(;r=i.dequeue();)nz(e,t,n,r);for(;r=s.dequeue();)nz(e,t,n,r);if(e.nodeCount())for(let s=t.length-2;s>0;--s)if(r=t[s].dequeue(),r){o=o.concat(nz(e,t,n,r,!0));break}}return o}(n.graph,n.buckets,n.zeroIdx).flatMap((t=>e.outEdges(t.v,t.w)))};let tz=()=>1;function nz(e,t,n,r,o){let s=o?[]:void 0;return e.inEdges(r.v).forEach((r=>{let i=e.edge(r),a=e.node(r.v);o&&s.push({v:r.v,w:r.w}),a.out-=i,rz(t,n,a)})),e.outEdges(r.v).forEach((r=>{let o=e.edge(r),s=r.w,i=e.node(s);i.in-=o,rz(t,n,i)})),e.removeNode(r.v),s}function rz(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}let oz=XL.Graph;var sz={addBorderNode:function(e,t,n,r){let o={width:0,height:0};arguments.length>=4&&(o.rank=n,o.order=r);return iz(e,"border",o,t)},addDummyNode:iz,applyWithChunking:lz,asNonCompoundGraph:function(e){let t=new oz({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach((n=>{e.children(n).length||t.setNode(n,e.node(n))})),e.edges().forEach((n=>{t.setEdge(n,e.edge(n))})),t},buildLayerMatrix:function(e){let t=hz(cz(e)+1).map((()=>[]));return e.nodes().forEach((n=>{let r=e.node(n),o=r.rank;void 0!==o&&(t[o][r.order]=n)})),t},intersectRect:function(e,t){let n,r,o=e.x,s=e.y,i=t.x-o,a=t.y-s,l=e.width/2,c=e.height/2;if(!i&&!a)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(a)*l>Math.abs(i)*c?(a<0&&(c=-c),n=c*i/a,r=c):(i<0&&(l=-l),n=l,r=l*a/i);return{x:o+n,y:s+r}},mapValues:function(e,t){let n=t;"string"==typeof t&&(n=e=>e[t]);return Object.entries(e).reduce(((e,[t,r])=>(e[t]=n(r,t),e)),{})},maxRank:cz,normalizeRanks:function(e){let t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MAX_VALUE:n})),n=lz(Math.min,t);e.nodes().forEach((t=>{let r=e.node(t);Object.hasOwn(r,"rank")&&(r.rank-=n)}))},notime:function(e,t){return t()},partition:function(e,t){let n={lhs:[],rhs:[]};return e.forEach((e=>{t(e)?n.lhs.push(e):n.rhs.push(e)})),n},pick:function(e,t){const n={};for(const r of t)void 0!==e[r]&&(n[r]=e[r]);return n},predecessorWeights:function(e){let t=e.nodes().map((t=>{let n={};return e.inEdges(t).forEach((t=>{n[t.v]=(n[t.v]||0)+e.edge(t).weight})),n}));return fz(e.nodes(),t)},range:hz,removeEmptyRanks:function(e){let t=e.nodes().map((t=>e.node(t).rank)),n=lz(Math.min,t),r=[];e.nodes().forEach((t=>{let o=e.node(t).rank-n;r[o]||(r[o]=[]),r[o].push(t)}));let o=0,s=e.graph().nodeRankFactor;Array.from(r).forEach(((t,n)=>{void 0===t&&n%s!=0?--o:void 0!==t&&o&&t.forEach((t=>e.node(t).rank+=o))}))},simplify:function(e){let t=(new oz).setGraph(e.graph());return e.nodes().forEach((n=>t.setNode(n,e.node(n)))),e.edges().forEach((n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})})),t},successorWeights:function(e){let t=e.nodes().map((t=>{let n={};return e.outEdges(t).forEach((t=>{n[t.w]=(n[t.w]||0)+e.edge(t).weight})),n}));return fz(e.nodes(),t)},time:function(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}},uniqueId:uz,zipObject:fz};function iz(e,t,n,r){let o;do{o=uz(r)}while(e.hasNode(o));return n.dummy=t,e.setNode(o,n),o}const az=65535;function lz(e,t){if(t.length>az){const n=function(e,t=az){const n=[];for(let r=0;r<e.length;r+=t){const o=e.slice(r,r+t);n.push(o)}return n}(t);return e.apply(null,n.map((t=>e.apply(null,t))))}return e.apply(null,t)}function cz(e){const t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MIN_VALUE:n}));return lz(Math.max,t)}let dz=0;function uz(e){var t=++dz;return toString(e)+t}function hz(e,t,n=1){null==t&&(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);const o=[];for(let s=e;r(s);s+=n)o.push(s);return o}function fz(e,t){return e.reduce(((e,n,r)=>(e[n]=t[r],e)),{})}let pz=ez,mz=sz.uniqueId;var gz={run:function(e){("greedy"===e.graph().acyclicer?pz(e,(t=e,e=>t.edge(e).weight)):function(e){let t=[],n={},r={};function o(s){Object.hasOwn(r,s)||(r[s]=!0,n[s]=!0,e.outEdges(s).forEach((e=>{Object.hasOwn(n,e.w)?t.push(e):o(e.w)})),delete n[s])}return e.nodes().forEach(o),t}(e)).forEach((t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,mz("rev"))}));var t},undo:function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}}))}};let yz=sz;var bz={run:function(e){e.graph().dummyChains=[],e.edges().forEach((t=>function(e,t){let n,r,o,s=t.v,i=e.node(s).rank,a=t.w,l=e.node(a).rank,c=t.name,d=e.edge(t),u=d.labelRank;if(l===i+1)return;for(e.removeEdge(t),o=0,++i;i<l;++o,++i)d.points=[],r={width:0,height:0,edgeLabel:d,edgeObj:t,rank:i},n=yz.addDummyNode(e,"edge",r,"_d"),i===u&&(r.width=d.width,r.height=d.height,r.dummy="edge-label",r.labelpos=d.labelpos),e.setEdge(s,n,{weight:d.weight},c),0===o&&e.graph().dummyChains.push(n),s=n;e.setEdge(s,a,{weight:d.weight},c)}(e,t)))},undo:function(e){e.graph().dummyChains.forEach((t=>{let n,r=e.node(t),o=r.edgeLabel;for(e.setEdge(r.edgeObj,o);r.dummy;)n=e.successors(t)[0],e.removeNode(t),o.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(o.x=r.x,o.y=r.y,o.width=r.width,o.height=r.height),t=n,r=e.node(t)}))}};const{applyWithChunking:xz}=sz;var vz={longestPath:function(e){var t={};e.sources().forEach((function n(r){var o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let s=e.outEdges(r).map((t=>null==t?Number.POSITIVE_INFINITY:n(t.w)-e.edge(t).minlen));var i=xz(Math.min,s);return i===Number.POSITIVE_INFINITY&&(i=0),o.rank=i}))},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}};var wz=XL.Graph,kz=vz.slack,Sz=function(e){var t,n,r=new wz({directed:!1}),o=e.nodes()[0],s=e.nodeCount();r.setNode(o,{});for(;Cz(r,e)<s;)t=Ez(r,e),n=r.hasNode(t.v)?kz(e,t):-kz(e,t),Nz(r,e,n);return r};function Cz(e,t){return e.nodes().forEach((function n(r){t.nodeEdges(r).forEach((o=>{var s=o.v,i=r===s?o.w:s;e.hasNode(i)||kz(t,o)||(e.setNode(i,{}),e.setEdge(r,i,{}),n(i))}))})),e.nodeCount()}function Ez(e,t){return t.edges().reduce(((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=kz(t,r)),o<n[0]?[o,r]:n}),[Number.POSITIVE_INFINITY,null])[1]}function Nz(e,t,n){e.nodes().forEach((e=>t.node(e).rank+=n))}var jz=Sz,_z=vz.slack,Iz=vz.longestPath,Az=XL.alg.preorder,Tz=XL.alg.postorder,Mz=sz.simplify,Dz=Oz;function Oz(e){e=Mz(e),Iz(e);var t,n=jz(e);for(Lz(n),Rz(n,e);t=Fz(n);)Uz(n,e,t,Bz(n,e,t))}function Rz(e,t){var n=Tz(e,e.nodes());(n=n.slice(0,n.length-1)).forEach((n=>function(e,t,n){var r=e.node(n),o=r.parent;e.edge(n,o).cutvalue=Pz(e,t,n)}(e,t,n)))}function Pz(e,t,n){var r=e.node(n).parent,o=!0,s=t.edge(n,r),i=0;return s||(o=!1,s=t.edge(r,n)),i=s.weight,t.nodeEdges(n).forEach((s=>{var a,l,c=s.v===n,d=c?s.w:s.v;if(d!==r){var u=c===o,h=t.edge(s).weight;if(i+=u?h:-h,a=n,l=d,e.hasEdge(a,l)){var f=e.edge(n,d).cutvalue;i+=u?-f:f}}})),i}function Lz(e,t){arguments.length<2&&(t=e.nodes()[0]),zz(e,{},1,t)}function zz(e,t,n,r,o){var s=n,i=e.node(r);return t[r]=!0,e.neighbors(r).forEach((o=>{Object.hasOwn(t,o)||(n=zz(e,t,n,o,r))})),i.low=s,i.lim=n++,o?i.parent=o:delete i.parent,n}function Fz(e){return e.edges().find((t=>e.edge(t).cutvalue<0))}function Bz(e,t,n){var r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);var s=e.node(r),i=e.node(o),a=s,l=!1;return s.lim>i.lim&&(a=i,l=!0),t.edges().filter((t=>l===$z(e,e.node(t.v),a)&&l!==$z(e,e.node(t.w),a))).reduce(((e,n)=>_z(t,n)<_z(t,e)?n:e))}function Uz(e,t,n,r){var o=n.v,s=n.w;e.removeEdge(o,s),e.setEdge(r.v,r.w,{}),Lz(e),Rz(e,t),function(e,t){var n=e.nodes().find((e=>!t.node(e).parent)),r=Az(e,n);(r=r.slice(1)).forEach((n=>{var r=e.node(n).parent,o=t.edge(n,r),s=!1;o||(o=t.edge(r,n),s=!0),t.node(n).rank=t.node(r).rank+(s?o.minlen:-o.minlen)}))}(e,t)}function $z(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}Oz.initLowLimValues=Lz,Oz.initCutValues=Rz,Oz.calcCutValue=Pz,Oz.leaveEdge=Fz,Oz.enterEdge=Bz,Oz.exchangeEdges=Uz;var Hz=vz.longestPath,Vz=Sz,Wz=Dz,Gz=function(e){switch(e.graph().ranker){case"network-simplex":default:Yz(e);break;case"tight-tree":!function(e){Hz(e),Vz(e)}(e);break;case"longest-path":qz(e)}};var qz=Hz;function Yz(e){Wz(e)}let Xz=sz;function Jz(e,t,n,r,o,s,i){let a=e.children(i);if(!a.length)return void(i!==t&&e.setEdge(t,i,{weight:0,minlen:n}));let l=Xz.addBorderNode(e,"_bt"),c=Xz.addBorderNode(e,"_bb"),d=e.node(i);e.setParent(l,i),d.borderTop=l,e.setParent(c,i),d.borderBottom=c,a.forEach((a=>{Jz(e,t,n,r,o,s,a);let d=e.node(a),u=d.borderTop?d.borderTop:a,h=d.borderBottom?d.borderBottom:a,f=d.borderTop?r:2*r,p=u!==h?1:o-s[i]+1;e.setEdge(l,u,{weight:f,minlen:p,nestingEdge:!0}),e.setEdge(h,c,{weight:f,minlen:p,nestingEdge:!0})})),e.parent(i)||e.setEdge(t,l,{weight:0,minlen:o+s[i]})}let Kz=sz;function Zz(e,t,n,r,o,s){let i={width:0,height:0,rank:s,borderType:t},a=o[t][s-1],l=Kz.addDummyNode(e,"border",i,n);o[t][s]=l,e.setParent(l,r),a&&e.setEdge(a,l,{weight:1})}function Qz(e){e.nodes().forEach((t=>eF(e.node(t)))),e.edges().forEach((t=>eF(e.edge(t))))}function eF(e){let t=e.width;e.width=e.height,e.height=t}function tF(e){e.y=-e.y}function nF(e){let t=e.x;e.x=e.y,e.y=t}let rF=sz;let oF=sz.zipObject;function sF(e,t,n){let r=oF(n,n.map(((e,t)=>t))),o=t.flatMap((t=>e.outEdges(t).map((t=>({pos:r[t.w],weight:e.edge(t).weight}))).sort(((e,t)=>e.pos-t.pos)))),s=1;for(;s<n.length;)s<<=1;let i=2*s-1;s-=1;let a=new Array(i).fill(0),l=0;return o.forEach((e=>{let t=e.pos+s;a[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=a[t+1]),t=t-1>>1,a[t]+=e.weight;l+=e.weight*n})),l}let iF=sz;let aF=sz;function lF(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}let cF=function(e,t=[]){return t.map((t=>{let n=e.inEdges(t);if(n.length){let r=n.reduce(((t,n)=>{let r=e.edge(n),o=e.node(n.v);return{sum:t.sum+r.weight*o.order,weight:t.weight+r.weight}}),{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}return{v:t}}))},dF=function(e,t){let n={};return e.forEach(((e,t)=>{let r=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};void 0!==e.barycenter&&(r.barycenter=e.barycenter,r.weight=e.weight)})),t.edges().forEach((e=>{let t=n[e.v],r=n[e.w];void 0!==t&&void 0!==r&&(r.indegree++,t.out.push(n[e.w]))})),function(e){let t=[];function n(e){return t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&function(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}function r(t){return n=>{n.in.push(t),0==--n.indegree&&e.push(n)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(n(o)),o.out.forEach(r(o))}return t.filter((e=>!e.merged)).map((e=>iF.pick(e,["vs","i","barycenter","weight"])))}(Object.values(n).filter((e=>!e.indegree)))},uF=function(e,t){let n=aF.partition(e,(e=>Object.hasOwn(e,"barycenter"))),r=n.lhs,o=n.rhs.sort(((e,t)=>t.i-e.i)),s=[],i=0,a=0,l=0;r.sort((c=!!t,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:c?t.i-e.i:e.i-t.i)),l=lF(s,o,l),r.forEach((e=>{l+=e.vs.length,s.push(e.vs),i+=e.barycenter*e.weight,a+=e.weight,l=lF(s,o,l)}));var c;let d={vs:s.flat(!0)};a&&(d.barycenter=i/a,d.weight=a);return d};var hF=function e(t,n,r,o){let s=t.children(n),i=t.node(n),a=i?i.borderLeft:void 0,l=i?i.borderRight:void 0,c={};a&&(s=s.filter((e=>e!==a&&e!==l)));let d=cF(t,s);d.forEach((n=>{if(t.children(n.v).length){let a=e(t,n.v,r,o);c[n.v]=a,Object.hasOwn(a,"barycenter")&&(i=a,void 0!==(s=n).barycenter?(s.barycenter=(s.barycenter*s.weight+i.barycenter*i.weight)/(s.weight+i.weight),s.weight+=i.weight):(s.barycenter=i.barycenter,s.weight=i.weight))}var s,i}));let u=dF(d,r);!function(e,t){e.forEach((e=>{e.vs=e.vs.flatMap((e=>t[e]?t[e].vs:e))}))}(u,c);let h=uF(u,o);if(a&&(h.vs=[a,h.vs,l].flat(!0),t.predecessors(a).length)){let e=t.node(t.predecessors(a)[0]),n=t.node(t.predecessors(l)[0]);Object.hasOwn(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+e.order+n.order)/(h.weight+2),h.weight+=2}return h};let fF=XL.Graph,pF=sz;let mF=function(e){let t={},n=e.nodes().filter((t=>!e.children(t).length)),r=n.map((t=>e.node(t).rank)),o=rF.applyWithChunking(Math.max,r),s=rF.range(o+1).map((()=>[]));return n.sort(((t,n)=>e.node(t).rank-e.node(n).rank)).forEach((function n(r){if(t[r])return;t[r]=!0;let o=e.node(r);s[o.rank].push(r),e.successors(r).forEach(n)})),s},gF=function(e,t){let n=0;for(let r=1;r<t.length;++r)n+=sF(e,t[r-1],t[r]);return n},yF=hF,bF=function(e,t,n){let r=function(e){var t;for(;e.hasNode(t=pF.uniqueId("_root")););return t}(e),o=new fF({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((t=>e.node(t)));return e.nodes().forEach((s=>{let i=e.node(s),a=e.parent(s);(i.rank===t||i.minRank<=t&&t<=i.maxRank)&&(o.setNode(s),o.setParent(s,a||r),e[n](s).forEach((t=>{let n=t.v===s?t.w:t.v,r=o.edge(n,s),i=void 0!==r?r.weight:0;o.setEdge(n,s,{weight:e.edge(t).weight+i})})),Object.hasOwn(i,"minRank")&&o.setNode(s,{borderLeft:i.borderLeft[t],borderRight:i.borderRight[t]}))})),o},xF=function(e,t,n){let r,o={};n.forEach((n=>{let s,i,a=e.parent(n);for(;a;){if(s=e.parent(a),s?(i=o[s],o[s]=a):(i=r,r=a),i&&i!==a)return void t.setEdge(i,a);a=s}}))},vF=XL.Graph,wF=sz;var kF=function e(t,n){if(n&&"function"==typeof n.customOrder)return void n.customOrder(t,e);let r=wF.maxRank(t),o=SF(t,wF.range(1,r+1),"inEdges"),s=SF(t,wF.range(r-1,-1,-1),"outEdges"),i=mF(t);if(EF(t,i),n&&n.disableOptimalOrderHeuristic)return;let a,l=Number.POSITIVE_INFINITY;for(let c=0,d=0;d<4;++c,++d){CF(c%2?o:s,c%4>=2),i=wF.buildLayerMatrix(t);let e=gF(t,i);e<l&&(d=0,a=Object.assign({},i),l=e)}EF(t,a)};function SF(e,t,n){return t.map((function(t){return bF(e,t,n)}))}function CF(e,t){let n=new vF;e.forEach((function(e){let r=e.graph().root,o=yF(e,r,n,t);o.vs.forEach(((t,n)=>e.node(t).order=n)),xF(e,n,o.vs)}))}function EF(e,t){Object.values(t).forEach((t=>t.forEach(((t,n)=>e.node(t).order=n))))}let NF=XL.Graph,jF=sz;var _F=function(e){let t,n=jF.buildLayerMatrix(e),r=Object.assign(IF(e,n),AF(e,n)),o={};["u","d"].forEach((s=>{t="u"===s?n:Object.values(n).reverse(),["l","r"].forEach((n=>{"r"===n&&(t=t.map((e=>Object.values(e).reverse())));let i=("u"===s?e.predecessors:e.successors).bind(e),a=DF(e,t,r,i),l=OF(e,t,a.root,a.align,"r"===n);"r"===n&&(l=jF.mapValues(l,(e=>-e))),o[s+n]=l}))}));let s=RF(e,o);return PF(o,s),LF(o,e.graph().align)};function IF(e,t){let n={};return t.length&&t.reduce((function(t,r){let o=0,s=0,i=t.length,a=r[r.length-1];return r.forEach(((t,l)=>{let c=function(e,t){if(e.node(t).dummy)return e.predecessors(t).find((t=>e.node(t).dummy))}(e,t),d=c?e.node(c).order:i;(c||t===a)&&(r.slice(s,l+1).forEach((t=>{e.predecessors(t).forEach((r=>{let s=e.node(r),i=s.order;!(i<o||d<i)||s.dummy&&e.node(t).dummy||TF(n,r,t)}))})),s=l+1,o=d)})),r})),n}function AF(e,t){let n={};function r(t,r,o,s,i){let a;jF.range(r,o).forEach((r=>{a=t[r],e.node(a).dummy&&e.predecessors(a).forEach((t=>{let r=e.node(t);r.dummy&&(r.order<s||r.order>i)&&TF(n,t,a)}))}))}return t.length&&t.reduce((function(t,n){let o,s=-1,i=0;return n.forEach(((a,l)=>{if("border"===e.node(a).dummy){let t=e.predecessors(a);t.length&&(o=e.node(t[0]).order,r(n,i,l,s,o),i=l,s=o)}r(n,i,n.length,o,t.length)})),n})),n}function TF(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function MF(e,t,n){if(t>n){let e=t;t=n,n=e}return!!e[t]&&Object.hasOwn(e[t],n)}function DF(e,t,n,r){let o={},s={},i={};return t.forEach((e=>{e.forEach(((e,t)=>{o[e]=e,s[e]=e,i[e]=t}))})),t.forEach((e=>{let t=-1;e.forEach((e=>{let a=r(e);if(a.length){a=a.sort(((e,t)=>i[e]-i[t]));let r=(a.length-1)/2;for(let l=Math.floor(r),c=Math.ceil(r);l<=c;++l){let r=a[l];s[e]===e&&t<i[r]&&!MF(n,e,r)&&(s[r]=e,s[e]=o[e]=o[r],t=i[r])}}}))})),{root:o,align:s}}function OF(e,t,n,r,o){let s={},i=function(e,t,n,r){let o=new NF,s=e.graph(),i=function(e,t,n){return(r,o,s)=>{let i,a=r.node(o),l=r.node(s),c=0;if(c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":i=-a.width/2;break;case"r":i=a.width/2}if(i&&(c+=n?i:-i),i=0,c+=(a.dummy?t:e)/2,c+=(l.dummy?t:e)/2,c+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":i=l.width/2;break;case"r":i=-l.width/2}return i&&(c+=n?i:-i),i=0,c}}(s.nodesep,s.edgesep,r);return t.forEach((t=>{let r;t.forEach((t=>{let s=n[t];if(o.setNode(s),r){var a=n[r],l=o.edge(a,s);o.setEdge(a,s,Math.max(i(e,t,r),l||0))}r=t}))})),o}(e,t,n,o),a=o?"borderLeft":"borderRight";function l(e,t){let n=i.nodes(),r=n.pop(),o={};for(;r;)o[r]?e(r):(o[r]=!0,n.push(r),n=n.concat(t(r))),r=n.pop()}return l((function(e){s[e]=i.inEdges(e).reduce(((e,t)=>Math.max(e,s[t.v]+i.edge(t))),0)}),i.predecessors.bind(i)),l((function(t){let n=i.outEdges(t).reduce(((e,t)=>Math.min(e,s[t.w]-i.edge(t))),Number.POSITIVE_INFINITY),r=e.node(t);n!==Number.POSITIVE_INFINITY&&r.borderType!==a&&(s[t]=Math.max(s[t],n))}),i.successors.bind(i)),Object.keys(r).forEach((e=>s[e]=s[n[e]])),s}function RF(e,t){return Object.values(t).reduce(((t,n)=>{let r=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;Object.entries(n).forEach((([t,n])=>{let s=function(e,t){return e.node(t).width}(e,t)/2;r=Math.max(n+s,r),o=Math.min(n-s,o)}));const s=r-o;return s<t[0]&&(t=[s,n]),t}),[Number.POSITIVE_INFINITY,null])[1]}function PF(e,t){let n=Object.values(t),r=jF.applyWithChunking(Math.min,n),o=jF.applyWithChunking(Math.max,n);["u","d"].forEach((n=>{["l","r"].forEach((s=>{let i=n+s,a=e[i];if(a===t)return;let l=Object.values(a),c=r-jF.applyWithChunking(Math.min,l);"l"!==s&&(c=o-jF.applyWithChunking(Math.max,l)),c&&(e[i]=jF.mapValues(a,(e=>e+c)))}))}))}function LF(e,t){return jF.mapValues(e.ul,((n,r)=>{if(t)return e[t.toLowerCase()][r];{let t=Object.values(e).map((e=>e[r])).sort(((e,t)=>e-t));return(t[1]+t[2])/2}}))}let zF=sz,FF=_F;let BF=gz,UF=bz,$F=Gz,HF=sz.normalizeRanks,VF=function(e){let t=function(e){let t={},n=0;function r(o){let s=n;e.children(o).forEach(r),t[o]={low:s,lim:n++}}return e.children().forEach(r),t}(e);e.graph().dummyChains.forEach((n=>{let r=e.node(n),o=r.edgeObj,s=function(e,t,n,r){let o,s,i=[],a=[],l=Math.min(t[n].low,t[r].low),c=Math.max(t[n].lim,t[r].lim);o=n;do{o=e.parent(o),i.push(o)}while(o&&(t[o].low>l||c>t[o].lim));s=o,o=r;for(;(o=e.parent(o))!==s;)a.push(o);return{path:i.concat(a.reverse()),lca:s}}(e,t,o.v,o.w),i=s.path,a=s.lca,l=0,c=i[l],d=!0;for(;n!==o.w;){if(r=e.node(n),d){for(;(c=i[l])!==a&&e.node(c).maxRank<r.rank;)l++;c===a&&(d=!1)}if(!d){for(;l<i.length-1&&e.node(c=i[l+1]).minRank<=r.rank;)l++;c=i[l]}e.setParent(n,c),n=e.successors(n)[0]}}))},WF=sz.removeEmptyRanks,GF={run:function(e){let t=Xz.addDummyNode(e,"root",{},"_root"),n=function(e){var t={};function n(r,o){var s=e.children(r);s&&s.length&&s.forEach((e=>n(e,o+1))),t[r]=o}return e.children().forEach((e=>n(e,1))),t}(e),r=Object.values(n),o=Xz.applyWithChunking(Math.max,r)-1,s=2*o+1;e.graph().nestingRoot=t,e.edges().forEach((t=>e.edge(t).minlen*=s));let i=function(e){return e.edges().reduce(((t,n)=>t+e.edge(n).weight),0)}(e)+1;e.children().forEach((r=>Jz(e,t,s,i,o,n,r))),e.graph().nodeRankFactor=s},cleanup:function(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach((t=>{e.edge(t).nestingEdge&&e.removeEdge(t)}))}},qF=function(e){e.children().forEach((function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let t=o.minRank,r=o.maxRank+1;t<r;++t)Zz(e,"borderLeft","_bl",n,o,t),Zz(e,"borderRight","_br",n,o,t)}}))},YF={adjust:function(e){let t=e.graph().rankdir.toLowerCase();"lr"!==t&&"rl"!==t||Qz(e)},undo:function(e){let t=e.graph().rankdir.toLowerCase();"bt"!==t&&"rl"!==t||function(e){e.nodes().forEach((t=>tF(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);n.points.forEach(tF),Object.hasOwn(n,"y")&&tF(n)}))}(e);"lr"!==t&&"rl"!==t||(!function(e){e.nodes().forEach((t=>nF(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);n.points.forEach(nF),Object.hasOwn(n,"x")&&nF(n)}))}(e),Qz(e))}},XF=kF,JF=function(e){(function(e){let t=zF.buildLayerMatrix(e),n=e.graph().ranksep,r=0;t.forEach((t=>{const o=t.reduce(((t,n)=>{const r=e.node(n).height;return t>r?t:r}),0);t.forEach((t=>e.node(t).y=r+o/2)),r+=o+n}))})(e=zF.asNonCompoundGraph(e)),Object.entries(FF(e)).forEach((([t,n])=>e.node(t).x=n))},KF=sz,ZF=XL.Graph;var QF=function(e,t){let n=t&&t.debugTiming?KF.time:KF.notime;n("layout",(()=>{let r=n(" buildLayoutGraph",(()=>function(e){let t=new ZF({multigraph:!0,compound:!0}),n=cB(e.graph());return t.setGraph(Object.assign({},tB,lB(n,eB),KF.pick(n,nB))),e.nodes().forEach((n=>{const r=lB(cB(e.node(n)),rB);Object.keys(oB).forEach((e=>{void 0===r[e]&&(r[e]=oB[e])})),t.setNode(n,r),t.setParent(n,e.parent(n))})),e.edges().forEach((n=>{let r=cB(e.edge(n));t.setEdge(n,Object.assign({},iB,lB(r,sB),KF.pick(r,aB)))})),t}(e)));n(" runLayout",(()=>function(e,t,n){t(" makeSpaceForEdgeLabels",(()=>function(e){let t=e.graph();t.ranksep/=2,e.edges().forEach((n=>{let r=e.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===t.rankdir||"BT"===t.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)}))}(e))),t(" removeSelfEdges",(()=>function(e){e.edges().forEach((t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}}))}(e))),t(" acyclic",(()=>BF.run(e))),t(" nestingGraph.run",(()=>GF.run(e))),t(" rank",(()=>$F(KF.asNonCompoundGraph(e)))),t(" injectEdgeLabelProxies",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v),r={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};KF.addDummyNode(e,"edge-proxy",r,"_ep")}}))}(e))),t(" removeEmptyRanks",(()=>WF(e))),t(" nestingGraph.cleanup",(()=>GF.cleanup(e))),t(" normalizeRanks",(()=>HF(e))),t(" assignRankMinMax",(()=>function(e){let t=0;e.nodes().forEach((n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))})),e.graph().maxRank=t}(e))),t(" removeEdgeLabelProxies",(()=>function(e){e.nodes().forEach((t=>{let n=e.node(t);"edge-proxy"===n.dummy&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))}))}(e))),t(" normalize.run",(()=>UF.run(e))),t(" parentDummyChains",(()=>VF(e))),t(" addBorderSegments",(()=>qF(e))),t(" order",(()=>XF(e,n))),t(" insertSelfEdges",(()=>function(e){var t=KF.buildLayerMatrix(e);t.forEach((t=>{var n=0;t.forEach(((t,r)=>{var o=e.node(t);o.order=r+n,(o.selfEdges||[]).forEach((t=>{KF.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:o.rank,order:r+ ++n,e:t.e,label:t.label},"_se")})),delete o.selfEdges}))}))}(e))),t(" adjustCoordinateSystem",(()=>YF.adjust(e))),t(" position",(()=>JF(e))),t(" positionSelfEdges",(()=>function(e){e.nodes().forEach((t=>{var n=e.node(t);if("selfedge"===n.dummy){var r=e.node(n.e.v),o=r.x+r.width/2,s=r.y,i=n.x-o,a=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:o+2*i/3,y:s-a},{x:o+5*i/6,y:s-a},{x:o+i,y:s},{x:o+5*i/6,y:s+a},{x:o+2*i/3,y:s+a}],n.label.x=n.x,n.label.y=n.y}}))}(e))),t(" removeBorderNodes",(()=>function(e){e.nodes().forEach((t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),s=e.node(n.borderLeft[n.borderLeft.length-1]),i=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(i.x-s.x),n.height=Math.abs(o.y-r.y),n.x=s.x+n.width/2,n.y=r.y+n.height/2}})),e.nodes().forEach((t=>{"border"===e.node(t).dummy&&e.removeNode(t)}))}(e))),t(" normalize.undo",(()=>UF.undo(e))),t(" fixupEdgeLabelCoords",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(e))),t(" undoCoordinateSystem",(()=>YF.undo(e))),t(" translateGraph",(()=>function(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,s=e.graph(),i=s.marginx||0,a=s.marginy||0;function l(e){let s=e.x,i=e.y,a=e.width,l=e.height;t=Math.min(t,s-a/2),n=Math.max(n,s+a/2),r=Math.min(r,i-l/2),o=Math.max(o,i+l/2)}e.nodes().forEach((t=>l(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);Object.hasOwn(n,"x")&&l(n)})),t-=i,r-=a,e.nodes().forEach((n=>{let o=e.node(n);o.x-=t,o.y-=r})),e.edges().forEach((n=>{let o=e.edge(n);o.points.forEach((e=>{e.x-=t,e.y-=r})),Object.hasOwn(o,"x")&&(o.x-=t),Object.hasOwn(o,"y")&&(o.y-=r)})),s.width=n-t+i,s.height=o-r+a}(e))),t(" assignNodeIntersects",(()=>function(e){e.edges().forEach((t=>{let n,r,o=e.edge(t),s=e.node(t.v),i=e.node(t.w);o.points?(n=o.points[0],r=o.points[o.points.length-1]):(o.points=[],n=i,r=s),o.points.unshift(KF.intersectRect(s,n)),o.points.push(KF.intersectRect(i,r))}))}(e))),t(" reversePoints",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);n.reversed&&n.points.reverse()}))}(e))),t(" acyclic.undo",(()=>BF.undo(e)))}(r,n,t))),n(" updateInputGraph",(()=>function(e,t){e.nodes().forEach((n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))})),e.edges().forEach((n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)})),e.graph().width=t.graph().width,e.graph().height=t.graph().height}(e,r)))}))};let eB=["nodesep","edgesep","ranksep","marginx","marginy"],tB={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},nB=["acyclicer","ranker","rankdir","align"],rB=["width","height"],oB={width:0,height:0},sB=["minlen","weight","width","height","labeloffset"],iB={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},aB=["labelpos"];function lB(e,t){return KF.mapValues(KF.pick(e,t),Number)}function cB(e){var t={};return e&&Object.entries(e).forEach((([e,n])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=n})),t}let dB=sz,uB=XL.Graph;var hB={graphlib:XL,layout:QF,debug:{debugOrdering:function(e){let t=dB.buildLayerMatrix(e),n=new uB({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach((t=>{n.setNode(t,{label:t}),n.setParent(t,"layer"+e.node(t).rank)})),e.edges().forEach((e=>n.setEdge(e.v,e.w,{},e.name))),t.forEach(((e,t)=>{let r="layer"+t;n.setNode(r,{rank:"same"}),e.reduce(((e,t)=>(n.setEdge(e,t,{style:"invis"}),t)))})),n}},util:{time:sz.time,notime:sz.notime},version:"1.1.4"};const fB=(new hB.graphlib.Graph).setDefaultEdgeLabel((()=>({}))),pB=(e,t,n)=>(fB.setGraph({rankdir:n.direction,nodesep:150,ranksep:200,ranker:"longest-path"}),t.forEach((e=>fB.setEdge(e.source,e.target))),e.forEach((e=>fB.setNode(e.id,{...e,width:e.width??0,height:e.height??0}))),hB.layout(fB),{nodes:e.map((e=>{const{x:t,y:n}=fB.node(e.id);return{...e,position:{x:t,y:n}}})),edges:t}),mB=new class{createEdge(e,t){return{animated:!0,markerEnd:{type:MD.ArrowClosed},id:`${e}-${t}`,style:{strokeWidth:2},source:e,sourceHandle:"outputs",targetHandle:"inputs",target:t}}createNode(e,t){return{id:e,data:{atom:t,forceWidth:300},width:300,type:"custom",height:KP(K.get(t).code.trim().split("\n").length),position:{x:0,y:0}}}createElements(e,t,n,r){const o=[],s=[],i=new Set,a=new Set;for(const l of Object.values(n)){if("marimo"===l.value&&"mo"===l.name)continue;const{declaredBy:e,usedBy:t}=l;for(const n of e)for(const e of t){const t=`${n}-${e}`;a.has(t)||(a.add(t),i.add(n),i.add(e),s.push(this.createEdge(n,e)))}}for(const[l,c]of yi.zip(e,t)){r||o.push(this.createNode(l,c));const e=i.has(l),t=K.get(c).code.trim().startsWith("mo.md");!e&&t||o.push(this.createNode(l,c))}return{nodes:o,edges:s}}},gB=e=>{const t=j.c(43),{cellIds:n,variables:r,cellAtoms:s,children:i,layoutDirection:a,settings:l}=e;let c;t[0]!==s||t[1]!==n||t[2]!==a||t[3]!==l.hidePureMarkdown||t[4]!==r?(c=()=>{let e=mB.createElements(n,s,r,l.hidePureMarkdown);return e=pB(e.nodes,e.edges,{direction:a}),e},t[0]=s,t[1]=n,t[2]=a,t[3]=l.hidePureMarkdown,t[4]=r,t[5]=c):c=t[5];const[d]=o.useState(c),[u,h,f]=TP(d.nodes),[p,m,g]=MP(d.edges),y=rR();let b;t[6]!==a||t[7]!==m||t[8]!==h?(b=e=>{const t=pB(e.nodes,e.edges,{direction:a});h(t.nodes),m(t.edges)},t[6]=a,t[7]=m,t[8]=h,t[9]=b):b=t[9];const x=B(b);let v,w;t[10]!==s||t[11]!==n||t[12]!==l.hidePureMarkdown||t[13]!==x||t[14]!==r?(v=()=>{x(mB.createElements(n,s,r,l.hidePureMarkdown))},w=[n,r,s,x,l.hidePureMarkdown],t[10]=s,t[11]=n,t[12]=l.hidePureMarkdown,t[13]=x,t[14]=r,t[15]=v,t[16]=w):(v=t[15],w=t[16]),o.useEffect(v,w);const[k,S]=o.useState();let C;aL(),t[17]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{S(void 0)},t[17]=C):C=t[17];const E=C;let N,_,A,T,M,D,O,R,P,L;return t[18]===Symbol.for("react.memo_cache_sentinel")?(N={minZoom:.5,maxZoom:1.5},_=(e,t)=>{S({type:"node",id:t.id})},A=(e,t)=>{const{source:n,target:r}=t;S({type:"edge",source:n,target:r})},t[18]=N,t[19]=_,t[20]=A):(N=t[18],_=t[19],A=t[20]),t[21]===Symbol.for("react.memo_cache_sentinel")?(T=I.jsx(JP,{color:"#ccc",variant:UP.Dots}),t[21]=T):T=t[21],t[22]!==y||t[23]!==u?(M=()=>{const e=K.get(Cu);if(e){const t=u.find((t=>t.id===e));t&&(y.fitView({padding:1,duration:600,nodes:[t]}),S({type:"node",id:e}))}},t[22]=y,t[23]=u,t[24]=M):M=t[24],t[25]===Symbol.for("react.memo_cache_sentinel")?(D=I.jsx(ad,{className:"size-4"}),t[25]=D):D=t[25],t[26]!==M?(O=I.jsx(HP,{position:"bottom-right",showInteractive:!1,children:I.jsx(it,{content:"Jump to focused cell",delayDuration:200,side:"left",asChild:!1,children:I.jsx(zP,{onMouseDown:ot.preventFocus,onClick:M,children:D})})}),t[26]=M,t[27]=O):O=t[27],t[28]!==p||t[29]!==k||t[30]!==r?(R=I.jsx(sL,{selection:k,variables:r,edges:p,onClearSelection:E}),t[28]=p,t[29]=k,t[30]=r,t[31]=R):R=t[31],t[32]!==i||t[33]!==p||t[34]!==u||t[35]!==g||t[36]!==f||t[37]!==O||t[38]!==R?(P=I.jsxs(IP,{nodes:u,edges:p,nodeTypes:eL,minZoom:.2,fitViewOptions:N,onNodeClick:_,onEdgeClick:A,onNodeDoubleClick:yB,fitView:!0,onNodesChange:f,onEdgesChange:g,zoomOnDoubleClick:!1,nodesConnectable:!1,children:[T,O,R,i]}),t[32]=i,t[33]=p,t[34]=u,t[35]=g,t[36]=f,t[37]=O,t[38]=R,t[39]=P):P=t[39],t[40]!==a||t[41]!==P?(L=I.jsx(ZP.Provider,{value:a,children:P}),t[40]=a,t[41]=P,t[42]=L):L=t[42],L};function yB(e,t){Xi(t.id,"focus")}const bB=q("_minimap_"),xB=q({hidePureMarkdown:!0}),vB=e=>{const t=j.c(11),[n,r]=ze(bB),[o,s]=ze(xB);let i;t[0]!==n||t[1]!==e||t[2]!==r||t[3]!==s||t[4]!==o?(i=()=>"_minimap_"===n?I.jsx(uL,{...e,children:I.jsx(oL,{settings:o,onSettingsChange:s,view:n,onChange:r})}):I.jsx(gB,{...e,settings:o,layoutDirection:n,children:I.jsx(oL,{settings:o,onSettingsChange:s,view:n,onChange:r})}),t[0]=n,t[1]=e,t[2]=r,t[3]=s,t[4]=o,t[5]=i):i=t[5];const a=i;let l,c;return t[6]!==a?(l=a(),t[6]=a,t[7]=l):l=t[7],t[8]!==n||t[9]!==l?(c=I.jsx(wP,{children:l},n),t[8]=n,t[9]=l,t[10]=c):c=t[10],c},wB=()=>{const e=j.c(5),t=Ji(),n=Hi(),[r]=Ki();let o,s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=In("w-full h-full flex-1 mx-auto -mb-4 relative"),e[0]=o):o=e[0],e[1]!==n.inOrderIds||e[2]!==r||e[3]!==t?(s=I.jsx("div",{className:o,children:I.jsx(vB,{cellAtoms:r,variables:t,cellIds:n.inOrderIds})}),e[1]=n.inOrderIds,e[2]=r,e[3]=t,e[4]=s):s=e[4],s};const kB="name",SB="type-value",CB="defs-refs",EB=[{id:kB,accessorFn:e=>[e.name,e.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>I.jsx(ha,{header:"Name",column:e}),cell:({getValue:e})=>{const[t,n]=e();return I.jsx(rL,{name:t,declaredBy:n})}},{id:SB,accessorFn:e=>[e.dataType,e.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>I.jsx(ha,{header:I.jsxs("div",{className:"flex flex-col gap-1",children:[I.jsx("span",{children:"Type"}),I.jsx("span",{children:"Value"})]}),column:e}),cell:({getValue:e})=>{const[t,n]=e();return I.jsxs("div",{className:"max-w-[150px]",children:[I.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:t}),I.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:n??"",children:n})]})}},{id:CB,accessorFn:e=>[e.declaredBy,e.usedBy,e.name,e.declaredByNames,e.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:e})=>I.jsx(ha,{header:I.jsxs("div",{className:"flex flex-col gap-1",children:[I.jsx("span",{children:"Declared By"}),I.jsx("span",{children:"Used By"})]}),column:e}),cell:({getValue:e})=>{const[t,n,r]=e(),o=e=>{const t=oe(e);t&&qi(t,r)};return I.jsxs("div",{className:"flex flex-col gap-1 py-1",children:[I.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[I.jsx("span",{title:"Declared by",children:I.jsx(Id,{className:"w-3.5 h-3.5 text-muted-foreground"})}),1===t.length?I.jsx(Wi,{variant:"focus",cellId:t[0],skipScroll:!0,onClick:()=>o(t[0])}):I.jsx("div",{className:"text-destructive flex flex-row gap-2",children:t.slice(0,3).map(((e,n)=>I.jsxs("span",{className:"flex",children:[I.jsx(Wi,{variant:"focus",cellId:e,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>o(e)},e),n<t.length-1&&", "]},e)))})]}),I.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[I.jsx("span",{title:"Used by",children:I.jsx(Bd,{className:"w-3.5 h-3.5 text-muted-foreground"})}),I.jsx(nL,{maxCount:3,cellIds:n,skipScroll:!0,onClick:o})]})]})}}];const NB=o.memo((({className:e,cellIds:t,variables:n})=>{const[r,s]=u.useState([]),[i,a]=u.useState(""),l=Zi(),c=o.useMemo((()=>{const e=e=>{const n=l[e];return ua(n)?`cell-${t.indexOf(e)}`:n??`cell-${t.indexOf(e)}`};return Object.values(n).map((t=>({...t,declaredByNames:t.declaredBy.map(e),usedByNames:t.usedBy.map(e)})))}),[n,l,t]),d=o.useMemo((()=>{const e=new Map;return t.forEach(((t,n)=>e.set(t,n))),function(e,t,n){t||(t={id:CB,desc:!1});let r=[];switch(t.id){case kB:r=Ec(e,(e=>e.name));break;case SB:r=Ec(e,(e=>e.dataType));break;case CB:r=Ec(e,(e=>n.get(e.declaredBy[0])))}return t.desc?r.reverse():r}(c,r[0],e)}),[c,r,t]),h=Qi({data:d,columns:EB,getCoreRowModel:ea(),onGlobalFilterChange:a,getFilteredRowModel:ta(),enableFilters:!0,enableGlobalFilter:!0,getColumnCanGlobalFilter:e=>e.columnDef.enableGlobalFilter??!0,globalFilterFn:"auto",manualSorting:!0,onSortingChange:s,getSortedRowModel:na(),state:{sorting:r,globalFilter:i}});return I.jsxs(I.Fragment,{children:[I.jsx(ra,{className:"w-full",placeholder:"Search",value:i,onChange:e=>a(e.target.value)}),I.jsxs(oa,{className:In("w-full text-sm flex-1 border-separate border-spacing-0",e),children:[I.jsx(sa,{children:I.jsx(ia,{className:"whitespace-nowrap text-xs",children:h.getFlatHeaders().map((e=>I.jsx(aa,{className:"sticky top-0 bg-background border-b",children:la(e.column.columnDef.header,e.getContext())},e.id)))})}),I.jsx(ca,{children:h.getRowModel().rows.map((e=>I.jsx(ia,{className:"hover:bg-accent",children:e.getVisibleCells().map((e=>I.jsx(da,{className:"border-b",children:la(e.column.columnDef.cell,e.getContext())},e.id)))},e.id)))})]})]})}));NB.displayName="VariableTable";const jB=()=>{const e=j.c(4),t=Ji(),n=Hi();if(0===Object.keys(t).length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx(aM,{title:"No variables",description:"Global variables will appear here.",icon:I.jsx(mt,{})}),e[0]=t):t=e[0],t}let r;return e[1]!==n.inOrderIds||e[2]!==t?(r=I.jsx(NB,{className:"flex-1",cellIds:n.inOrderIds,variables:t}),e[1]=n.inOrderIds,e[2]=t,e[3]=r):r=e[3],r},_B=e=>I.jsx("button",{type:"button","data-testid":e.dataTestId,className:In("text-xs font-semibold text-accent-foreground",e.className),onClick:e.onClick,children:"Clear"}),IB=()=>{const e=j.c(9),t=fa(),{clearLogs:n}=U();if(0===t.length){let t,n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx("code",{className:"border rounded px-1",children:"stdout"}),e[0]=t):t=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(n=I.jsx(aM,{title:"No logs",description:I.jsxs("span",{children:[t," and"," ",I.jsx("code",{className:"border rounded px-1",children:"stderr"})," logs will appear here."]}),icon:I.jsx(yt,{})}),e[1]=n):n=e[1],n}let r,o,s;return e[2]!==n?(r=I.jsx("div",{className:"flex flex-row justify-end px-2 py-1",children:I.jsx(_B,{dataTestId:"clear-logs-button",onClick:n})}),e[2]=n,e[3]=r):r=e[3],e[4]!==t?(o=I.jsx("div",{className:"overflow-auto flex-1",children:I.jsx(AB,{logs:t,className:"min-w-[300px]"})}),e[4]=t,e[5]=o):o=e[5],e[6]!==r||e[7]!==o?(s=I.jsxs(I.Fragment,{children:[r,o]}),e[6]=r,e[7]=o,e[8]=s):s=e[8],s},AB=e=>{const t=j.c(11),{logs:n,className:r}=e;let o,s,i,a,l;if(t[0]!==r?(o=In("flex flex-col",r),t[0]=r,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(s={whiteSpace:"pre-wrap"},t[2]=s):s=t[2],t[3]!==n){let e;t[5]===Symbol.for("react.memo_cache_sentinel")?(e=(e,t)=>I.jsxs("div",{className:"contents group",children:[I.jsx("span",{className:In("opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100","text-right col-span-1 py-1 pr-1"),children:t+1}),I.jsx("span",{className:In("opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100","px-2 flex gap-x-1.5 py-1 flex-wrap"),children:TB(e)})]},t),t[5]=e):e=t[5],i=n.map(e),t[3]=n,t[4]=i}else i=t[4];return t[6]!==i?(a=I.jsx("pre",{className:"grid text-xs font-mono gap-1 whitespace-break-spaces font-semibold align-left",children:I.jsx("div",{className:"grid grid-cols-[30px,1fr]",style:s,children:i})}),t[6]=i,t[7]=a):a=t[7],t[8]!==o||t[9]!==a?(l=I.jsx("div",{className:o,children:a}),t[8]=o,t[9]=a,t[10]=l):l=t[10],l};function TB(e){const t=pa(e.timestamp),n=MB[e.level],r=e.level.toUpperCase();return I.jsxs(I.Fragment,{children:[I.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)] dark:text-[var(--gray-11)]",children:["[",t,"]"]}),I.jsx("span",{className:In("flex-shrink-0",n),children:r}),I.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)]",children:["(",I.jsx(Wi,{cellId:e.cellId}),")"]}),e.message]})}const MB={stdout:"text-[var(--grass-9)]",stderr:"text-[var(--red-9)]"},DB=()=>{const e=j.c(5),{documentation:t}=se(ma);if(!t){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx(aM,{title:"View docs as you type",description:"Move your text cursor over a symbol to see its documentation.",icon:I.jsx(Pd,{})}),e[0]=t):t=e[0],t}let n,r;return e[1]!==t?(n=ai({html:t}),e[1]=t,e[2]=n):n=e[2],e[3]!==n?(r=I.jsx("div",{className:"p-3 overflow-y-auto overflow-x-hidden h-full docs-documentation flex flex-col gap-4",children:n}),e[3]=n,e[4]=r):r=e[4],r};function OB(e,t,n){return e[t]?e[t][0]?e[t][0][n]:e[t][n]:"contentBoxSize"===t?e.contentRect["inlineSize"===n?"width":"height"]:void 0}function RB(e){void 0===e&&(e={});var t=e.onResize,n=o.useRef(void 0);n.current=t;var r=e.round||Math.round,s=o.useRef(),i=o.useState({width:void 0,height:void 0}),a=i[0],l=i[1],c=o.useRef(!1);o.useEffect((function(){return c.current=!1,function(){c.current=!0}}),[]);var d=o.useRef({width:void 0,height:void 0}),u=function(e,t){var n=o.useRef(null),r=o.useRef(null);r.current=t;var s=o.useRef(null);o.useEffect((function(){i()}));var i=o.useCallback((function(){var t=s.current,o=r.current,i=t||(o?o instanceof Element?o:o.current:null);n.current&&n.current.element===i&&n.current.subscriber===e||(n.current&&n.current.cleanup&&n.current.cleanup(),n.current={element:i,subscriber:e,cleanup:i?e(i):void 0})}),[e]);return o.useEffect((function(){return function(){n.current&&n.current.cleanup&&(n.current.cleanup(),n.current=null)}}),[]),o.useCallback((function(e){s.current=e,i()}),[i])}(o.useCallback((function(t){return s.current&&s.current.box===e.box&&s.current.round===r||(s.current={box:e.box,round:r,instance:new ResizeObserver((function(t){var o=t[0],s="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",i=OB(o,s,"inlineSize"),a=OB(o,s,"blockSize"),u=i?r(i):void 0,h=a?r(a):void 0;if(d.current.width!==u||d.current.height!==h){var f={width:u,height:h};d.current.width=u,d.current.height=h,n.current?n.current(f):c.current||l(f)}}))}),s.current.instance.observe(t,{box:e.box}),function(){s.current&&s.current.instance.unobserve(t)}}),[e.box,r]),e.ref);return o.useMemo((function(){return{ref:u,width:a.width,height:a.height}}),[u,a.width,a.height])}const PB=new Map,LB=({file:e,onOpenNotebook:t})=>{const{theme:n}=Oe(),r=se(Fe),[s,i]=o.useState(""),{data:a,loading:l,error:c,setData:d}=jn((async()=>{const t=await ga({path:e.path}),n=t.contents||"";return i(PB.get(e.path)||n),t}),[e.path]),u=async()=>{s!==(null==a?void 0:a.contents)&&await Ca({path:e.path,contents:s}).then((e=>{e.success&&(d((e=>e?{...e,contents:s}:void 0)),i(s))}))},h=o.useRef(s);if(h.current=s,o.useEffect((()=>()=>{if(!(null==a?void 0:a.contents))return;const t=h.current;t===a.contents?PB.delete(e.path):PB.set(e.path,t)}),[e.path,null==a?void 0:a.contents]),c)return I.jsx(ya,{error:c});if(l||!a)return null;const f=a.mimeType||"text/plain",p=f in FB;if(!a.contents&&!p)return I.jsxs("div",{className:"grid grid-cols-2 gap-2 p-6",children:[I.jsx("div",{className:"font-bold text-muted-foreground",children:"Name"}),I.jsx("div",{children:a.file.name}),I.jsx("div",{className:"font-bold text-muted-foreground",children:"Type"}),I.jsx("div",{children:f})]});const m=I.jsxs("div",{className:"text-xs text-muted-foreground p-1 flex justify-end gap-2 border-b",children:[e.isMarimoFile&&!_()&&I.jsx(it,{content:"Open notebook",children:I.jsx(gl,{size:"small",onClick:e=>t(e),children:I.jsx(ba,{})})}),I.jsx(it,{content:"Download",children:I.jsx(gl,{size:"small",onClick:()=>{if(zB(f)){const e=Ea(a.contents,f);Na(e,a.file.name)}else Jt(new Blob([a.contents||s],{type:f}),a.file.name)},children:I.jsx(Wt,{})})}),!zB(f)&&I.jsxs(I.Fragment,{children:[I.jsx(it,{content:"Copy contents to clipboard",children:I.jsx(gl,{size:"small",onClick:async()=>{await nt(s)},children:I.jsx(st,{})})}),I.jsx(it,{content:Bt("global.save"),children:I.jsx(gl,{size:"small",color:s===a.contents?void 0:"green",onClick:u,disabled:s===a.contents,children:I.jsx(Sd,{})})})]})]});return f.startsWith("image/")?I.jsxs(I.Fragment,{children:[m,I.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:I.jsx(xa,{base64:a.contents,mime:f})})]}):"text/csv"===f&&a.contents?I.jsxs(I.Fragment,{children:[m,I.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:I.jsx(va,{contents:a.contents})})]}):f.startsWith("audio/")?I.jsxs(I.Fragment,{children:[m,I.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:I.jsx(wa,{base64:a.contents,mime:f})})]}):f.startsWith("video/")?I.jsxs(I.Fragment,{children:[m,I.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:I.jsx(ka,{base64:a.contents,mime:f})})]}):I.jsxs(I.Fragment,{children:[m,I.jsx("div",{className:"flex-1 overflow-auto",children:I.jsx(Sa,{theme:"dark"===n?"dark":"light",language:FB[f]||FB.default,className:"border-b",extensions:[yn.lineWrapping,er.of([{key:r.getHotkey("global.save").key,stopPropagation:!0,run:()=>s!==a.contents&&(u(),!0)}])],value:s,onChange:i})})]})},zB=e=>!!e&&(e.startsWith("image/")||e.startsWith("audio/")||e.startsWith("video/")),FB={"application/javascript":"javascript","text/markdown":"markdown","text/html":"html","text/css":"css","text/x-python":"python","application/json":"json","application/xml":"xml","text/x-yaml":"yaml","text/csv":"markdown","text/plain":"markdown",default:"markdown"};const BB=q(new class{constructor(e){this.callbacks=e,this.delegate=new Pl([]),this.rootPath="",this.onChange=Kn.NOOP,this.path=new wt("/"),this.initialize=async e=>{if(this.onChange=e,0===this.delegate.data.length)try{const e=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new Pl(e.files),this.rootPath=e.root,this.path=wt.guessDeliminator(e.root)}catch(t){ee({title:"Failed",description:Os(t)})}this.onChange(this.delegate.data)},this.refreshAll=async e=>{const t=[this.rootPath,...e.map((e=>{var t;return null==(t=this.delegate.find(e))?void 0:t.data.path}))].filter(Boolean),n=await Promise.all(t.map((e=>this.callbacks.listFiles({path:e}).catch((()=>({files:[]}))))));for(const[r,o]of t.entries()){const e=n[r];o===this.rootPath?this.delegate=new Pl(e.files):this.delegate.update({id:o,changes:{children:e.files}})}this.onChange(this.delegate.data)},this.relativeFromRoot=e=>{const t=function(e){return e.endsWith("/")?e:`${e}/`}(this.rootPath);return e.startsWith(t)?e.slice(t.length):e},this.handleResponse=e=>e.success?e:(ee({title:"Failed",description:e.message}),null)}async expand(e){const t=this.delegate.find(e);if(!t)return!1;if(!t.data.isDirectory)return!1;if(t.children&&t.children.length>0)return!0;const n=await this.callbacks.listFiles({path:t.data.path});return this.delegate.update({id:e,changes:{children:n.files}}),this.onChange(this.delegate.data),!0}async rename(e,t){const n=this.delegate.find(e);if(!n)return;const r=n.data.path,o=this.path.join(this.path.dirname(r),t);await this.callbacks.renameFileOrFolder({path:r,newPath:o}).then(this.handleResponse),this.delegate.update({id:e,changes:{name:t,path:o}}),this.onChange(this.delegate.data),await this.refreshAll([o])}async move(e,t){var n;const r=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath;await Promise.all(e.map((e=>{this.delegate.move({id:e,parentId:t,index:0});const n=this.delegate.find(e);if(!n)return Promise.resolve();const o=this.path.join(r,this.path.basename(n.data.path));return this.delegate.update({id:e,changes:{path:o}}),this.callbacks.renameFileOrFolder({path:n.data.path,newPath:o}).then(this.handleResponse)}))),this.onChange(this.delegate.data),await this.refreshAll([r])}async createFile(e,t){var n;const r=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,o=await this.callbacks.createFileOrFolder({path:r,type:"file",name:e}).then(this.handleResponse);(null==o?void 0:o.info)&&(this.delegate.create({parentId:t,index:0,data:o.info}),this.onChange(this.delegate.data),await this.refreshAll([r]))}async createFolder(e,t){var n;const r=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,o=await this.callbacks.createFileOrFolder({path:r,type:"directory",name:e}).then(this.handleResponse);(null==o?void 0:o.info)&&(this.delegate.create({parentId:t,index:0,data:o.info}),this.onChange(this.delegate.data),await this.refreshAll([r]))}async delete(e){const t=this.delegate.find(e);t&&(await this.callbacks.deleteFileOrFolder({path:t.data.path}).then(this.handleResponse),this.delegate.drop({id:e}),this.onChange(this.delegate.data))}}({listFiles:An,createFileOrFolder:ja,deleteFileOrFolder:_a,renameFileOrFolder:Ia})),UB=q({});function $B(e){return new Promise(((t,n)=>{const r=new FileReader;r.onload=e=>{var n;t(null==(n=e.target)?void 0:n.result)},r.onerror=e=>{n(new Error(`Failed to read blob: ${e.type}`))},r.readAsDataURL(e)}))}function HB(e){const t=j.c(4);let n;t[0]!==e?(n=void 0===e?{}:e,t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==r?(o={multiple:!0,maxSize:104857600,onError:YB,onDropRejected:WB,onDrop:VB,...r},t[2]=r,t[3]=o):o=t[3],Aa(o)}async function VB(e){for(const t of e){const e=(await $B(t)).split(",")[1];await ja({path:"",type:"file",name:t.name,contents:e})}await async function(){await K.get(BB).refreshAll([])}()}function WB(e){ee({title:"File upload failed",description:I.jsx("div",{className:"flex flex-col gap-1",children:e.map(GB)}),variant:"danger"})}function GB(e){return I.jsxs("div",{children:[e.file.name," (",e.errors.map(qB).join(", "),")"]},e.file.name)}function qB(e){return e.message}function YB(e){w.error(e),ee({title:"File upload failed",description:e.message,variant:"danger"})}const XB=u.createContext(null),JB=e=>{const t=j.c(60),{height:n}=e,r=o.useRef(null),[s]=ze(BB);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],t[0]=i):i=t[0];const[a,l]=o.useState(i),[c,d]=o.useState(null),{openPrompt:u}=ie(),[h,f]=ze(UB);let p,m;t[1]!==s?(p=()=>s.initialize(l),t[1]=s,t[2]=p):p=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[3]=m):m=t[3];const{loading:g,error:y}=jn(p,m);let b;t[4]!==h||t[5]!==s?(b=()=>{s.refreshAll(Object.keys(h).filter((e=>h[e])))},t[4]=h,t[5]=s,t[6]=b):b=t[6];const x=B(b);let v;t[7]!==u||t[8]!==s?(v=async()=>{u({title:"Folder name",onConfirm:async e=>{s.createFolder(e,null)}})},t[7]=u,t[8]=s,t[9]=v):v=t[9];const w=B(v);let k;t[10]!==u||t[11]!==s?(k=async()=>{u({title:"File name",onConfirm:async e=>{s.createFile(e,null)}})},t[10]=u,t[11]=s,t[12]=k):k=t[12];const S=B(k);let C;t[13]!==f?(C=()=>{var e;null==(e=r.current)||e.closeAll(),f({})},t[13]=f,t[14]=C):C=t[14];const E=B(C);if(g){let e;return t[15]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx(Mi,{size:"medium",centered:!0}),t[15]=e):e=t[15],e}if(y){let e;return t[16]!==y?(e=I.jsx(ya,{error:y}),t[16]=y,t[17]=e):e=t[17],e}if(c){let e,n,r,i,a,l;return t[18]===Symbol.for("react.memo_cache_sentinel")?(e=()=>d(null),t[18]=e):e=t[18],t[19]===Symbol.for("react.memo_cache_sentinel")?(n=I.jsx(X,{onClick:e,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:I.jsx(Nc,{size:16})}),t[19]=n):n=t[19],t[20]!==c.name?(r=I.jsxs("div",{className:"flex items-center pl-1 pr-3 flex-shrink-0 border-b justify-between",children:[n,I.jsx("span",{className:"font-bold",children:c.name})]}),t[20]=c.name,t[21]=r):r=t[21],t[22]!==c.path||t[23]!==s?(i=e=>rU(e,s.relativeFromRoot(c.path)),t[22]=c.path,t[23]=s,t[24]=i):i=t[24],t[25]!==c||t[26]!==i?(a=I.jsx(o.Suspense,{children:I.jsx(LB,{onOpenNotebook:i,file:c})}),t[25]=c,t[26]=i,t[27]=a):a=t[27],t[28]!==r||t[29]!==a?(l=I.jsxs(I.Fragment,{children:[r,a]}),t[28]=r,t[29]=a,t[30]=l):l=t[30],l}let N;t[31]!==E||t[32]!==S||t[33]!==w||t[34]!==x||t[35]!==s?(N=I.jsx(ZB,{onRefresh:x,onCreateFile:S,onCreateFolder:w,onCollapseAll:E,tree:s}),t[31]=E,t[32]=S,t[33]=w,t[34]=x,t[35]=s,t[36]=N):N=t[36];const _=n-33;let A,T,M,D,O,R,P,L;return t[37]!==s?(A=async e=>{const{ids:t}=e;for(const n of t)await s.delete(n)},T=async e=>{const{id:t,name:n}=e;await s.rename(t,n)},M=async e=>{const{dragIds:t,parentId:n}=e;await s.move(t,n)},t[37]=s,t[38]=A,t[39]=T,t[40]=M):(A=t[38],T=t[39],M=t[40]),t[41]===Symbol.for("react.memo_cache_sentinel")?(D=e=>{const t=e[0];t&&(t.data.isDirectory||d(t.data))},t[41]=D):D=t[41],t[42]!==h||t[43]!==f||t[44]!==s?(O=async e=>{if(await s.expand(e)){const t=h[e]??!1;f({...h,[e]:!t})}},t[42]=h,t[43]=f,t[44]=s,t[45]=O):O=t[45],t[46]!==a||t[47]!==h||t[48]!==A||t[49]!==T||t[50]!==M||t[51]!==O||t[52]!==_?(R=I.jsx(Ll,{width:"100%",ref:r,height:_,className:"h-full",data:a,initialOpenState:h,openByDefault:!1,renderCursor:oU,disableDrop:sU,onDelete:A,onRename:T,onMove:M,onSelect:D,onToggle:O,padding:15,rowHeight:30,indent:KB,overscanCount:1e3,disableMultiSelection:!0,children:tU}),t[46]=a,t[47]=h,t[48]=A,t[49]=T,t[50]=M,t[51]=O,t[52]=_,t[53]=R):R=t[53],t[54]!==R||t[55]!==s?(P=I.jsx(XB.Provider,{value:s,children:R}),t[54]=R,t[55]=s,t[56]=P):P=t[56],t[57]!==P||t[58]!==N?(L=I.jsxs(I.Fragment,{children:[N,P]}),t[57]=P,t[58]=N,t[59]=L):L=t[59],L},KB=15,ZB=e=>{const t=j.c(30),{onRefresh:n,onCreateFile:r,onCreateFolder:o,onCollapseAll:s}=e;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={noDrag:!0,noDragEventsBubbling:!0},t[0]=i):i=t[0];const{getRootProps:a,getInputProps:l}=HB(i);let c,d,u,h,f,p,m,g,y,b,x,v,w,k,S;return t[1]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx(Xc,{size:16}),t[1]=c):c=t[1],t[2]!==r?(d=I.jsx(it,{content:"Add file",children:I.jsx(X,{"data-testid":"file-explorer-add-file-button",onClick:r,variant:"text",size:"xs",children:c})}),t[2]=r,t[3]=d):d=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(u=I.jsx(Kc,{size:16}),t[4]=u):u=t[4],t[5]!==o?(h=I.jsx(it,{content:"Add folder",children:I.jsx(X,{"data-testid":"file-explorer-add-folder-button",onClick:o,variant:"text",size:"xs",children:u})}),t[5]=o,t[6]=h):h=t[6],t[7]!==a?(f=a({}),t[7]=a,t[8]=f):f=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(p=Ta({variant:"text",size:"xs"}),m=I.jsx(Ma,{size:16}),t[9]=p,t[10]=m):(p=t[9],m=t[10]),t[11]!==f?(g=I.jsx(it,{content:"Upload file",children:I.jsx("button",{"data-testid":"file-explorer-upload-button",...f,className:p,children:m})}),t[11]=f,t[12]=g):g=t[12],t[13]!==l?(y=l({}),t[13]=l,t[14]=y):y=t[14],t[15]!==y?(b=I.jsx("input",{...y,type:"file"}),t[15]=y,t[16]=b):b=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(x=I.jsx(Ws,{size:16}),t[17]=x):x=t[17],t[18]!==n?(v=I.jsx(it,{content:"Refresh",children:I.jsx(X,{"data-testid":"file-explorer-refresh-button",onClick:n,variant:"text",size:"xs",children:x})}),t[18]=n,t[19]=v):v=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(w=I.jsx(Vc,{size:16}),t[20]=w):w=t[20],t[21]!==s?(k=I.jsx(it,{content:"Collapse all folders",children:I.jsx(X,{"data-testid":"file-explorer-collapse-button",onClick:s,variant:"text",size:"xs",children:w})}),t[21]=s,t[22]=k):k=t[22],t[23]!==b||t[24]!==v||t[25]!==k||t[26]!==d||t[27]!==h||t[28]!==g?(S=I.jsxs("div",{className:"flex items-center justify-end px-2 flex-shrink-0 border-b",children:[d,h,g,b,v,k]}),t[23]=b,t[24]=v,t[25]=k,t[26]=d,t[27]=h,t[28]=g,t[29]=S):S=t[29],S},QB=e=>{const t=j.c(9),{node:n,onOpenMarimoFile:r}=e;let o,s,i;return t[0]!==n?(o=e=>{n.data.isDirectory||(e.stopPropagation(),n.select())},t[0]=n,t[1]=o):o=t[1],t[2]!==n.data.isMarimoFile||t[3]!==r?(s=n.data.isMarimoFile&&!_()&&I.jsxs("span",{className:"flex-shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:r,children:["open ",I.jsx(ba,{className:"inline ml-1",size:12})]}),t[2]=n.data.isMarimoFile,t[3]=r,t[4]=s):s=t[4],t[5]!==n.data.name||t[6]!==o||t[7]!==s?(i=I.jsxs("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:o,children:[n.data.name,s]}),t[5]=n.data.name,t[6]=o,t[7]=s,t[8]=i):i=t[8],i},eU=e=>{const t=j.c(10),{node:n}=e,r=o.useRef(null);let s,i,a,l,c;return t[0]!==n.data.name?(s=()=>{var e,t;null==(e=r.current)||e.focus(),null==(t=r.current)||t.setSelectionRange(0,n.data.name.lastIndexOf("."))},i=[n.data.name],t[0]=n.data.name,t[1]=s,t[2]=i):(s=t[1],i=t[2]),o.useEffect(s,i),t[3]!==n?(a=()=>n.reset(),l=e=>{"Escape"===e.key&&n.reset(),"Enter"===e.key&&n.submit(e.currentTarget.value)},t[3]=n,t[4]=a,t[5]=l):(a=t[4],l=t[5]),t[6]!==n.data.name||t[7]!==a||t[8]!==l?(c=I.jsx("input",{ref:r,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:n.data.name,onClick:iU,onBlur:a,onKeyDown:l}),t[6]=n.data.name,t[7]=a,t[8]=l,t[9]=c):c=t[9],c},tU=e=>{const t=j.c(53),{node:n,style:r,dragHandle:s}=e;let i;t[0]!==n.data.isDirectory||t[1]!==n.data.name?(i=n.data.isDirectory?"directory":_n(n.data.name),t[0]=n.data.isDirectory,t[1]=n.data.name,t[2]=i):i=t[2];const a=i,l=Tn[a],{openConfirm:c,openPrompt:d}=ie(),u=o.useContext(XB);let h;t[3]!==n.data.path||t[4]!==u?(h=async e=>{rU(e,u?u.relativeFromRoot(n.data.path):n.data.path)},t[3]=n.data.path,t[4]=u,t[5]=h):h=t[5];const f=h;let p;t[6]!==n.data.name||t[7]!==n.id||t[8]!==n.tree||t[9]!==c?(p=async e=>{e.stopPropagation(),e.preventDefault(),c({title:"Delete file",description:`Are you sure you want to delete ${n.data.name}?`,confirmAction:I.jsx(lt,{onClick:async()=>{await n.tree.delete(n.id)},"aria-label":"Confirm",children:"Delete"})})},t[6]=n.data.name,t[7]=n.id,t[8]=n.tree,t[9]=c,t[10]=p):p=t[10];const m=p;let g;t[11]!==n||t[12]!==d||t[13]!==u?(g=async()=>{n.open(),d({title:"Folder name",onConfirm:async e=>{null==u||u.createFolder(e,n.id)}})},t[11]=n,t[12]=d,t[13]=u,t[14]=g):g=t[14];const y=B(g);let b;t[15]!==n||t[16]!==d||t[17]!==u?(b=async()=>{n.open(),d({title:"File name",onConfirm:async e=>{null==u||u.createFile(e,n.id)}})},t[15]=n,t[16]=d,t[17]=u,t[18]=b):b=t[18];const x=B(b);let v;t[19]!==a||t[20]!==x||t[21]!==y||t[22]!==m||t[23]!==f||t[24]!==n||t[25]!==u?(v=()=>{const e={size:14,strokeWidth:1.5,className:"mr-2"};return I.jsxs(dn,{align:"end",className:"no-print w-[220px]",onClick:aU,onCloseAutoFocus:lU,children:[!n.data.isDirectory&&I.jsxs(tn,{onSelect:()=>n.select(),children:[I.jsx(zd,{...e}),"Open file"]}),!n.data.isDirectory&&!_()&&I.jsxs(tn,{onSelect:()=>{Da({path:n.data.path})},children:[I.jsx(ba,{...e}),"Open file in external editor"]}),n.data.isDirectory&&I.jsxs(I.Fragment,{children:[I.jsxs(tn,{onSelect:()=>x(),children:[I.jsx(Xc,{...e}),"Create file"]}),I.jsxs(tn,{onSelect:()=>y(),children:[I.jsx(Kc,{...e}),"Create folder"]}),I.jsx(ln,{})]}),I.jsxs(tn,{onSelect:()=>n.edit(),children:[I.jsx(yd,{...e}),"Rename"]}),I.jsxs(tn,{onSelect:async()=>{await nt(n.data.path),ee({title:"Copied to clipboard"})},children:[I.jsx(st,{...e}),"Copy path"]}),u&&I.jsxs(tn,{onSelect:async()=>{await nt(u.relativeFromRoot(n.data.path)),ee({title:"Copied to clipboard"})},children:[I.jsx(st,{...e}),"Copy relative path"]}),I.jsxs(tn,{onSelect:async()=>{ee({title:"Copied to clipboard",description:"Code to open the file has been copied to your clipboard. You can also drag and drop this file into the editor"});const{path:e}=n.data,t=Oa[a](e);await nt(t)},children:[I.jsx(Ra,{...e}),"Copy snippet for reading file"]}),n.data.isMarimoFile&&!_()&&I.jsxs(I.Fragment,{children:[I.jsx(ln,{}),I.jsxs(tn,{onSelect:f,children:[I.jsx(Td,{...e}),"Open notebook"]})]}),I.jsx(ln,{}),!n.data.isDirectory&&I.jsxs(I.Fragment,{children:[I.jsxs(tn,{onSelect:async()=>{const e=(await ga({path:n.data.path})).contents||"";Jt(new Blob([e]),n.data.name)},children:[I.jsx(Wt,{...e}),"Download"]}),I.jsx(ln,{})]}),I.jsxs(tn,{onSelect:m,variant:"danger",children:[I.jsx(je,{...e}),"Delete"]})]})},t[19]=a,t[20]=x,t[21]=y,t[22]=m,t[23]=f,t[24]=n,t[25]=u,t[26]=v):v=t[26];const w=v;let k,S,C;t[27]===Symbol.for("react.memo_cache_sentinel")?(k=In("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),t[27]=k):k=t[27],t[28]!==n?(S=e=>{e.stopPropagation(),n.data.isDirectory&&n.toggle()},C=I.jsx(nU,{node:n}),t[28]=n,t[29]=S,t[30]=C):(S=t[29],C=t[30]);const E=n.willReceiveDrop&&n.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground";let N,A,T,M,D,O,R;return t[31]!==E?(N=In("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",E),t[31]=E,t[32]=N):N=t[32],t[33]!==l||t[34]!==n.data.isMarimoFile?(A=n.data.isMarimoFile?I.jsx("img",{src:"./favicon.ico",className:"w-5 h-5 flex-shrink-0 mr-2 filter grayscale",alt:"Marimo"}):I.jsx(l,{className:"w-5 h-5 flex-shrink-0 mr-2",strokeWidth:1.5}),t[33]=l,t[34]=n.data.isMarimoFile,t[35]=A):A=t[35],t[36]!==f||t[37]!==n?(T=n.isEditing?I.jsx(eU,{node:n}):I.jsx(QB,{node:n,onOpenMarimoFile:f}),t[36]=f,t[37]=n,t[38]=T):T=t[38],t[39]===Symbol.for("react.memo_cache_sentinel")?(M=I.jsx(nn,{asChild:!0,tabIndex:-1,onClick:cU,children:I.jsx(X,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:I.jsx(Wc,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),t[39]=M):M=t[39],t[40]!==w?(D=I.jsxs(cn,{modal:!1,children:[M,w()]}),t[40]=w,t[41]=D):D=t[41],t[42]!==N||t[43]!==A||t[44]!==T||t[45]!==D?(O=I.jsxs("span",{className:N,children:[A,T,D]}),t[42]=N,t[43]=A,t[44]=T,t[45]=D,t[46]=O):O=t[46],t[47]!==s||t[48]!==r||t[49]!==O||t[50]!==S||t[51]!==C?(R=I.jsxs("div",{style:r,ref:s,className:k,draggable:!0,onClick:S,children:[C,O]}),t[47]=s,t[48]=r,t[49]=O,t[50]=S,t[51]=C,t[52]=R):R=t[52],R},nU=e=>{const t=j.c(3),{node:n}=e;if(!n.data.isDirectory){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx("span",{className:"w-5 h-5 flex-shrink-0"}),t[0]=e):e=t[0],e}let r;return t[1]!==n.isOpen?(r=n.isOpen?I.jsx(Se,{className:"w-5 h-5 flex-shrink-0"}):I.jsx(Ee,{className:"w-5 h-5 flex-shrink-0"}),t[1]=n.isOpen,t[2]=r):r=t[2],r};function rU(e,t){e.stopPropagation(),e.preventDefault(),window.open(`/?file=${t}`,"_blank")}function oU(){return null}function sU(e){const{parentNode:t}=e;return!t.data.isDirectory}function iU(e){return e.stopPropagation()}function aU(e){return e.stopPropagation()}function lU(e){return e.preventDefault()}function cU(e){return e.stopPropagation()}const dU=()=>{const e=j.c(20),{ref:t,height:n}=RB(),r=void 0===n?1:n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={noClick:!0,noKeyboard:!0},e[0]=o):o=e[0];const{getRootProps:s,getInputProps:i,isDragActive:a}=HB(o);let l,c,d,u,h,f,p,m;return e[1]!==s?(l=s(),e[1]=s,e[2]=l):l=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(c=In("flex flex-col flex-1 overflow-hidden relative"),e[3]=c):c=e[3],e[4]!==i?(d=i(),e[4]=i,e[5]=d):d=e[5],e[6]!==d?(u=I.jsx("input",{...d}),e[6]=d,e[7]=u):u=e[7],e[8]!==a?(h=a&&I.jsx("div",{className:"absolute inset-0 flex items-center uppercase justify-center text-xl font-bold text-primary/90 bg-accent/85 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none",children:"Drop files here"}),e[8]=a,e[9]=h):h=e[9],e[10]!==r?(f=I.jsx(JB,{height:r}),e[10]=r,e[11]=f):f=e[11],e[12]!==t||e[13]!==f?(p=I.jsx("div",{ref:t,className:"flex flex-col flex-1 overflow-hidden",children:f}),e[12]=t,e[13]=f,e[14]=p):p=e[14],e[15]!==l||e[16]!==u||e[17]!==h||e[18]!==p?(m=I.jsxs("div",{...l,className:c,children:[u,h,p]}),e[15]=l,e[16]=u,e[17]=h,e[18]=p,e[19]=m):m=e[19],m},uU=e=>{const t=j.c(6),{children:n}=e,{openModal:r,closeModal:o}=ie();let s,i;return t[0]!==o||t[1]!==r?(s=()=>r(I.jsx(fU,{onClose:o})),t[0]=o,t[1]=r,t[2]=s):s=t[2],t[3]!==n||t[4]!==s?(i=I.jsx(Ri,{onClick:s,children:n}),t[3]=n,t[4]=s,t[5]=i):i=t[5],i},hU=[yn.lineWrapping],fU=e=>{const t=j.c(23),{onClose:n}=e,[r,s]=o.useState(""),{theme:i}=Oe();let a,l,c,d,u,h;t[0]!==n?(a=async e=>{e.preventDefault();const t=new FormData(e.target),r=t.get("title"),o=t.get("description"),s=t.get("code");fetch("https://marimo.io/api/suggest-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r,description:o,code:s})}),n(),ee({title:"Snippet Submitted",description:"Thank you for contributing! We will review your snippet shortly."})},t[0]=n,t[1]=a):a=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(l=I.jsx(Te,{children:"Contribute a Snippet"}),t[2]=l):l=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsxs(Ae,{children:[l,I.jsxs(et,{children:["Have a useful snippet you want to share with the community? Submit it here or make a pull request"," ",I.jsx("a",{href:Qe.githubPage,target:"_blank",rel:"noreferrer",className:"underline",children:"on GitHub"}),"."]})]}),t[3]=c):c=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(d=I.jsx(tt,{id:"title",name:"title",autoFocus:!0,placeholder:"Title",required:!0,autoComplete:"off"}),u=I.jsx(Pa,{id:"description",name:"description",autoFocus:!0,placeholder:"Description",rows:5,required:!0,autoComplete:"off"}),t[4]=d,t[5]=u):(d=t[4],u=t[5]),t[6]!==r?(h=I.jsx("input",{type:"hidden",name:"code",value:r}),t[6]=r,t[7]=h):h=t[7];const f="dark"===i?"dark":"light";let p,m,g,y,b,x;return t[8]!==r||t[9]!==f?(p=I.jsx(Sa,{theme:f,language:"python",className:"cm border rounded overflow-hidden",extensions:hU,value:r,onChange:s}),t[8]=r,t[9]=f,t[10]=p):p=t[10],t[11]!==h||t[12]!==p?(m=I.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[d,u,h,p]}),t[11]=h,t[12]=p,t[13]=m):m=t[13],t[14]!==n?(g=I.jsx(X,{"data-testid":"snippet-cancel-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=g):g=t[15],t[16]===Symbol.for("react.memo_cache_sentinel")?(y=I.jsx(X,{"data-testid":"snippet-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"}),t[16]=y):y=t[16],t[17]!==g?(b=I.jsxs(rt,{children:[g,y]}),t[17]=g,t[18]=b):b=t[18],t[19]!==a||t[20]!==b||t[21]!==m?(x=I.jsx(Ie,{className:"w-fit",children:I.jsxs("form",{onSubmit:a,children:[c,m,b]})}),t[19]=a,t[20]=b,t[21]=m,t[22]=x):x=t[22],x},pU=[yn.lineWrapping],mU=()=>{const e=j.c(20),[t,n]=u.useState();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],e[0]=r):r=e[0];const{data:s,error:i,loading:a}=jn(bU,r);if(i){let t;return e[1]!==i?(t=I.jsx(ya,{error:i}),e[1]=i,e[2]=t):t=e[2],t}if(a||!s){let t;return e[3]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx(Mi,{size:"medium",centered:!0}),e[3]=t):t=e[3],t}const l=t?"h-1/3":"h-full";let c,d,h,f,p,m,g,y,b;return e[4]!==l?(c=In("border-b rounded-none",l),e[4]=l,e[5]=c):c=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(d=I.jsx(Xe,{placeholder:"Search snippets...",className:"h-6 m-1",rootClassName:"flex-1 border-r"}),e[6]=d):d=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(h=I.jsxs("div",{className:"flex items-center w-full",children:[d,I.jsx(uU,{children:I.jsx("button",{className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:I.jsx(Oo,{className:"h-4 w-4"})})})]}),f=I.jsx(Ke,{children:"No results"}),e[7]=h,e[8]=f):(h=e[7],f=e[8]),e[9]===Symbol.for("react.memo_cache_sentinel")?(p=e=>n(e),e[9]=p):p=e[9],e[10]!==s.snippets?(m=I.jsx(yU,{onSelect:p,snippets:s.snippets}),e[10]=s.snippets,e[11]=m):m=e[11],e[12]!==c||e[13]!==m?(g=I.jsxs(On,{className:c,children:[h,f,m]}),e[12]=c,e[13]=m,e[14]=g):g=e[14],e[15]!==t?(y=I.jsx(o.Suspense,{children:I.jsx("div",{className:"h-2/3 snippet-viewer flex flex-col",children:t?I.jsx(gU,{snippet:t},t.title):I.jsx(aM,{title:"",description:"Click on a snippet to view its content."})})}),e[15]=t,e[16]=y):y=e[16],e[17]!==g||e[18]!==y?(b=I.jsxs("div",{className:"flex-1 overflow-hidden",children:[g,y]}),e[17]=g,e[18]=y,e[19]=b):b=e[19],b},gU=e=>{const t=j.c(27),{snippet:n}=e,{theme:r}=Oe(),{createNewCell:o}=U(),s=Eu();let i;t[0]!==o||t[1]!==s||t[2]!==n.sections?(i=()=>{for(const e of[...n.sections].reverse())e.code&&o({code:e.code,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=o,t[1]=s,t[2]=n.sections,t[3]=i):i=t[3];const a=i;let l;t[4]!==o||t[5]!==s?(l=e=>{o({code:e,before:!1,cellId:s??"__end__"})},t[4]=o,t[5]=s,t[6]=l):l=t[6];const c=l;let d,u,h,f,p,m;if(t[7]!==n.title?(d=I.jsx("div",{className:"text-sm font-semibold bg-muted border-y px-2 py-1",children:n.title}),t[7]=n.title,t[8]=d):d=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(u=I.jsx(Tc,{className:"ml-2 h-4 w-4"}),t[9]=u):u=t[9],t[10]!==a?(h=I.jsx("div",{className:"flex justify-end",children:I.jsx(cf,{children:I.jsxs(X,{className:"float-right",size:"xs",variant:"outline",onClick:a,children:["Insert snippet",u]})})}),t[10]=a,t[11]=h):h=t[11],t[12]!==c||t[13]!==n.sections||t[14]!==n.title||t[15]!==r){let e;t[17]!==c||t[18]!==n.title||t[19]!==r?(e=e=>{const{code:t,html:o,id:s}=e;return o?I.jsx("div",{children:ai({html:o})},`${n.title}-${s}`):t?I.jsxs("div",{className:"relative hover-actions-parent pr-2",children:[I.jsx(cf,{children:I.jsx(it,{content:"Insert snippet",children:I.jsx(X,{className:"absolute -top-2 -right-1 z-10 hover-action px-2 bg-background",size:"sm",variant:"outline",onClick:()=>{c(t)},children:I.jsx(Tc,{className:"h-5 w-5"})})})}),I.jsx(Sa,{theme:"dark"===r?"dark":"light",language:"python",className:"cm border rounded overflow-hidden",extensions:pU,value:t,readOnly:!0},`${n.title}-${s}`)]},`${n.title}-${s}`):null},t[17]=c,t[18]=n.title,t[19]=r,t[20]=e):e=t[20],f=n.sections.map(e),t[12]=c,t[13]=n.sections,t[14]=n.title,t[15]=r,t[16]=f}else f=t[16];return t[21]!==h||t[22]!==f?(p=I.jsxs("div",{className:"px-2 py-2 space-y-4 overflow-auto flex-1",children:[h,f]}),t[21]=h,t[22]=f,t[23]=p):p=t[23],t[24]!==d||t[25]!==p?(m=I.jsxs(I.Fragment,{children:[d,p]}),t[24]=d,t[25]=p,t[26]=m):m=t[26],m},yU=e=>{const t=j.c(7),{snippets:n,onSelect:r}=e;let o,s;if(t[0]!==r||t[1]!==n){let e;t[3]!==r?(e=e=>I.jsx(We,{className:"rounded-none",onSelect:()=>r(e),children:I.jsx("div",{className:"flex flex-row gap-2 items-center",children:I.jsx("span",{className:"mt-1 text-accent-foreground",children:e.title})})},e.title),t[3]=r,t[4]=e):e=t[4],o=n.map(e),t[0]=r,t[1]=n,t[2]=o}else o=t[2];return t[5]!==o?(s=I.jsx(us,{className:"flex flex-col overflow-auto",children:o}),t[5]=o,t[6]=s):s=t[6],s};function bU(){return La()}const xU=e=>{const t=j.c(11),{value:n,className:r,tooltip:s}=e,[i,a]=o.useState(!1);let l;t[0]!==n?(l=ot.stopPropagation((async()=>{await nt(n).then((()=>{a(!0),setTimeout((()=>a(!1)),2e3)}))})),t[0]=n,t[1]=l):l=t[1];const c=l;let d,u;t[2]!==r||t[3]!==i?(d=i?I.jsx($t,{className:In(r,"text-[var(--grass-11)]")}):I.jsx(st,{className:r}),t[2]=r,t[3]=i,t[4]=d):d=t[4],t[5]!==c||t[6]!==d?(u=I.jsx("span",{onClick:c,children:d}),t[5]=c,t[6]=d,t[7]=u):u=t[7];const h=u;if(!1===s)return h;const f=i?"Copied!":s??"Copy to clipboard";let p;return t[8]!==h||t[9]!==f?(p=I.jsx(it,{content:f,delayDuration:400,children:h}),t[8]=h,t[9]=f,t[10]=p):p=t[10],p},vU=e=>{const t=j.c(8),{variableName:n,className:r}=e;let o;t[0]!==n?(o=()=>{const e=function(e){const t=K.get(te)[e];if(!t)return;return t.declaredBy[0]}(n);if(!e)return;const t=oe(e);t&&qi(t,n)},t[0]=n,t[1]=o):o=t[1];const s=o;let i,a;return t[2]!==r?(i=In("text-link opacity-80 hover:opacity-100 hover:underline",r),t[2]=r,t[3]=i):i=t[3],t[4]!==s||t[5]!==i||t[6]!==n?(a=I.jsx("button",{type:"button",onClick:s,className:i,children:n}),t[4]=s,t[5]=i,t[6]=n,t[7]=a):a=t[7],a};const wU=q((e=>{const t=e(za),n=e(te),r=e(ji);return Ec(t,(e=>{if(!e.variable_name)return-1;const t=Object.values(n).find((t=>t.name===e.variable_name));if(!t)return 0;const o=r.inOrderIds.indexOf(t.declaredBy[0]);return-1===o?0:o}))})),kU=()=>{const e=j.c(44),[t,n]=u.useState(""),r=se(ce),o=Eu(),{expandedColumns:s,expandedTables:i,columnsPreviews:a}=Ba(),{toggleTable:l,toggleColumn:c,closeAllColumns:d}=Ua(),{createNewCell:h}=U(),f=se(wU);if(0===f.length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx(aM,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:I.jsx(uh,{children:I.jsxs(X,{variant:"outline",size:"sm",children:["Add database",I.jsx(Oo,{className:"h-4 w-4 ml-2"})]})}),icon:I.jsx(ve,{})}),e[0]=t):t=e[0],t}let p;e[1]!==r||e[2]!==h||e[3]!==o?(p=e=>{e.includes("alt")&&function(e,t,n){gu("altair","alt",(r=>{const o=re.create();t({cellId:n??"__end__",before:!1,code:r,lastCodeRun:e?r:void 0,newCellId:o,autoFocus:!1}),e&&G({cellIds:[o],codes:[r]})}))}(r,h,o),h({code:e,before:!1,cellId:o??"__end__"})},e[1]=r,e[2]=h,e[3]=o,e[4]=p):p=e[4];const m=p;let g;e[5]!==r||e[6]!==h||e[7]!==o?(g=e=>{yu(r,h,o);let t="";e:switch(e.source_type){case"local":t=`mo.ui.table(${e.name})`;break e;case"duckdb":t=`_df = mo.sql(f"SELECT * FROM ${e.name} LIMIT 100")`;break e;case"connection":t=`_df = mo.sql(f"SELECT * FROM ${e.name} LIMIT 100", engine=${e.engine})`;break e;default:C(e.source_type)}h({code:t,before:!1,cellId:o??"__end__"})},e[5]=r,e[6]=h,e[7]=o,e[8]=g):g=e[8];const y=g,b=!!t.trim();let x,v,w,k,S,E,N,_,A,T,M,D;return e[9]===Symbol.for("react.memo_cache_sentinel")?(x=In("border-b bg-background rounded-none","h-full"),e[9]=x):x=e[9],e[10]!==d?(v=e=>{e.length>0&&d(),n(e)},e[10]=d,e[11]=v):v=e[11],e[12]!==t||e[13]!==v?(w=I.jsx(Xe,{placeholder:"Search tables...",className:"h-6 m-1",value:t,onValueChange:v,rootClassName:"flex-1 border-r"}),e[12]=t,e[13]=v,e[14]=w):w=e[14],e[15]!==b?(k=b&&I.jsx("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:()=>n(""),children:I.jsx(Cn,{className:"h-4 w-4"})}),e[15]=b,e[16]=k):k=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(S=I.jsx(uh,{children:I.jsx("button",{className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:I.jsx(Oo,{className:"h-4 w-4"})})}),e[17]=S):S=e[17],e[18]!==w||e[19]!==k?(E=I.jsxs("div",{className:"flex items-center w-full",children:[w,k,S]}),e[18]=w,e[19]=k,e[20]=E):E=e[20],e[21]!==a||e[22]!==c?(N=(e,t)=>{const n=`${e.name}:${t.name}`;c({table:e.name,column:t.name}),a.has(n)||$a({source:e.source,tableName:e.name,columnName:t.name,sourceType:e.source_type})},e[21]=a,e[22]=c,e[23]=N):N=e[23],e[24]!==l?(_=e=>{l(e.name)},e[24]=l,e[25]=_):_=e[25],e[26]!==i||e[27]!==b?(A=e=>!!b||i.has(e.name),e[26]=i,e[27]=b,e[28]=A):A=e[28],e[29]!==s?(T=(e,t)=>{const n=`${e.name}:${t.name}`;return s.has(n)},e[29]=s,e[30]=T):T=e[30],e[31]!==a||e[32]!==m||e[33]!==y||e[34]!==b||e[35]!==A||e[36]!==T||e[37]!==N||e[38]!==_||e[39]!==f?(M=I.jsx(SU,{onAddColumnChart:m,onAddTable:y,onExpandColumn:N,onExpandTable:_,columnPreviews:a,tables:f,isSearching:b,isTableExpanded:A,isColumnExpanded:T}),e[31]=a,e[32]=m,e[33]=y,e[34]=b,e[35]=A,e[36]=T,e[37]=N,e[38]=_,e[39]=f,e[40]=M):M=e[40],e[41]!==M||e[42]!==E?(D=I.jsx("div",{className:"flex-1 overflow-hidden",children:I.jsxs(On,{className:x,children:[E,M]})}),e[41]=M,e[42]=E,e[43]=D):D=e[43],D},SU=e=>{const t=j.c(25),{tables:n,isSearching:r,columnPreviews:o,onAddColumnChart:s,onAddTable:i,onExpandTable:a,onExpandColumn:l,isTableExpanded:c,isColumnExpanded:d}=e;let h,f,p,m;if(t[0]!==o||t[1]!==d||t[2]!==r||t[3]!==c||t[4]!==s||t[5]!==i||t[6]!==l||t[7]!==a||t[8]!==n){let e,m;e=Object.entries(Be.groupBy(n,IU,AU)),e=Ec(e,TU),t[12]!==o||t[13]!==d||t[14]!==r||t[15]!==c||t[16]!==s||t[17]!==i||t[18]!==l||t[19]!==a?(m=e=>{const t=c(e),n=[I.jsx(CU,{table:e,forceMount:r,onExpand:()=>a(e),onAddTable:()=>i(e),isExpanded:t},e.name)];return t&&n.push(...e.columns.map((t=>I.jsxs(u.Fragment,{children:[I.jsx(EU,{table:e,column:t,onExpandColumn:l,isExpanded:d(e,t)},`${e.name}.${t.name}`),d(e,t)&&I.jsx("div",{className:"pl-10 pr-2 py-2 bg-[var(--slate-1)] shadow-inner border-b",children:I.jsx(Rn,{children:I.jsx(jU,{table:e,column:t,onAddColumnChart:s,preview:o.get(`${e.name}:${t.name}`)})})})]},`${e.name}.${t.name}`)))),n},t[12]=o,t[13]=d,t[14]=r,t[15]=c,t[16]=s,t[17]=i,t[18]=l,t[19]=a,t[20]=m):m=t[20];const g=m;h=us,f="flex flex-col overflow-auto",p=(()=>{if(0===e.length)return null;if(1===e.length)return e[0][1].flatMap(g);const t=MU;return e.flatMap(((e,n)=>{const[r,o]=e;return[I.jsx("div",{className:In("font-bold px-2 py-1 text-muted-foreground bg-[var(--slate-2)] border-t text-sm flex items-center gap-1",n>0&&"border-t"),children:t(r,o)},r),...o.flatMap(g)]}))})(),t[0]=o,t[1]=d,t[2]=r,t[3]=c,t[4]=s,t[5]=i,t[6]=l,t[7]=a,t[8]=n,t[9]=h,t[10]=f,t[11]=p}else h=t[9],f=t[10],p=t[11];return t[21]!==h||t[22]!==f||t[23]!==p?(m=I.jsx(h,{className:f,children:p}),t[21]=h,t[22]=f,t[23]=p,t[24]=m):m=t[24],m},CU=e=>{const t=j.c(27),{table:n,onExpand:r,onAddTable:o,isExpanded:s}=e;let i;t[0]!==n.num_columns||t[1]!==n.num_rows?(i=()=>{const e=[];return null!=n.num_rows&&e.push(`${n.num_rows} rows`),null!=n.num_columns&&e.push(`${n.num_columns} columns`),0===e.length?null:I.jsx("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:I.jsx("span",{className:"text-xs text-muted-foreground",children:e.join(", ")})})},t[0]=n.num_columns,t[1]=n.num_rows,t[2]=i):i=t[2];const a=i,l=n.name,c=s&&"rotate-90";let d,u,h,f,p,m,g,y,b;return t[3]!==c?(d=In("h-3 w-3 transition-transform",c),t[3]=c,t[4]=d):d=t[4],t[5]!==d?(u=I.jsx(Ee,{className:d}),t[5]=d,t[6]=u):u=t[6],t[7]!==n.name?(h=I.jsx("span",{className:"text-sm",children:n.name}),t[7]=n.name,t[8]=h):h=t[8],t[9]!==u||t[10]!==h?(f=I.jsxs("div",{className:"flex gap-1 items-center flex-1",children:[u,h]}),t[9]=u,t[10]=h,t[11]=f):f=t[11],t[12]!==a?(p=a(),t[12]=a,t[13]=p):p=t[13],t[14]!==o||t[15]!==n?(m=ot.stopPropagation((()=>o(n))),t[14]=o,t[15]=n,t[16]=m):m=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(g=I.jsx(Md,{className:"h-3 w-3"}),t[17]=g):g=t[17],t[18]!==m?(y=I.jsx(it,{content:"Add table to notebook",delayDuration:400,children:I.jsx(X,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:m,children:g})}),t[18]=m,t[19]=y):y=t[19],t[20]!==s||t[21]!==r||t[22]!==y||t[23]!==f||t[24]!==p||t[25]!==n.name?(b=I.jsxs(We,{className:"rounded-none py-1 group min-h-9 border-t",value:l,"aria-selected":s,forceMount:!0,onSelect:r,children:[f,p,y]}),t[20]=s,t[21]=r,t[22]=y,t[23]=f,t[24]=p,t[25]=n.name,t[26]=b):b=t[26],b},EU=e=>{const t=j.c(22),{table:n,column:r,onExpandColumn:o}=e,s=Ha[r.type],i=`${n.name}.${r.name}`,a=`${n.name}.${r.name}`;let l,c,d,u,h,f,p;return t[0]!==r||t[1]!==o||t[2]!==n?(l=()=>o(n,r),t[0]=r,t[1]=o,t[2]=n,t[3]=l):l=t[3],t[4]!==s?(c=I.jsx(s,{className:"flex-shrink-0 h-3 w-3",strokeWidth:1.5}),t[4]=s,t[5]=c):c=t[5],t[6]!==r.name?(d=I.jsx("span",{children:r.name}),t[6]=r.name,t[7]=d):d=t[7],t[8]!==c||t[9]!==d?(u=I.jsxs("div",{className:"flex flex-row gap-2 items-center pl-6 flex-1",children:[c,d]}),t[8]=c,t[9]=d,t[10]=u):u=t[10],t[11]!==r.name?(h=I.jsx(it,{content:"Copy column name",delayDuration:400,children:I.jsx(X,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:I.jsx(xU,{tooltip:!1,value:r.name,className:"h-3 w-3"})})}),t[11]=r.name,t[12]=h):h=t[12],t[13]!==r.external_type?(f=I.jsx("span",{className:"text-xs text-muted-foreground",children:r.external_type}),t[13]=r.external_type,t[14]=f):f=t[14],t[15]!==i||t[16]!==a||t[17]!==l||t[18]!==u||t[19]!==h||t[20]!==f?(p=I.jsxs(We,{className:"rounded-none py-1 group",value:a,onSelect:l,children:[u,h,f]},i),t[15]=i,t[16]=a,t[17]=l,t[18]=u,t[19]=h,t[20]=f,t[21]=p):p=t[21],p},NU=u.lazy((()=>Fa((()=>import("./index-eUGIYQ9e.js")),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]),import.meta.url).then((e=>({default:e.VegaLite}))))),jU=e=>{const t=j.c(37),{table:n,column:r,preview:o,onAddColumnChart:s}=e,{theme:i}=Oe();if("connection"===n.source_type){const e=r.name,o=r.external_type;let i,a,l,c;return t[0]!==r||t[1]!==s||t[2]!==n?(i=ot.stopPropagation((()=>{s(_U(n,r))})),t[0]=r,t[1]=s,t[2]=n,t[3]=i):i=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(a=I.jsx(Md,{className:"h-3 w-3 mr-1"}),t[4]=a):a=t[4],t[5]!==i?(l=I.jsxs(X,{variant:"outline",size:"xs",onClick:i,children:[a," Add SQL cell"]}),t[5]=i,t[6]=l):l=t[6],t[7]!==r.external_type||t[8]!==r.name||t[9]!==l?(c=I.jsxs("span",{className:"text-xs text-muted-foreground gap-2 flex items-center justify-between",children:[e," (",o,")",l]}),t[7]=r.external_type,t[8]=r.name,t[9]=l,t[10]=c):c=t[10],c}if(!o){let e;return t[11]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading..."}),t[11]=e):e=t[11],e}let a;t[12]!==o.error?(a=o.error&&I.jsx("span",{className:"text-xs text-muted-foreground",children:o.error}),t[12]=o.error,t[13]=a):a=t[13];const l=a;let c;t[14]!==o.summary?(c=o.summary&&I.jsx("div",{className:"gap-x-16 gap-y-1 grid grid-cols-2-fit border rounded p-2 empty:hidden",children:Object.entries(o.summary).map(DU)}),t[14]=o.summary,t[15]=c):c=t[15];const d=c,u=OU;let h;t[16]!==o.chart_spec||t[17]!==i?(h=o.chart_spec&&I.jsx(NU,{spec:u(JSON.parse(o.chart_spec)),width:"container",height:100,actions:!1,theme:"dark"===i?"dark":"vox"}),t[16]=o.chart_spec,t[17]=i,t[18]=h):h=t[18];const f=h;let p;t[19]!==s||t[20]!==o.chart_code||t[21]!==n.source_type?(p=o.chart_code&&"local"===n.source_type&&I.jsx(it,{content:"Add chart to notebook",delayDuration:400,children:I.jsx(X,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:ot.stopPropagation((()=>s(o.chart_code||""))),children:I.jsx(Md,{className:"h-3 w-3"})})}),t[19]=s,t[20]=o.chart_code,t[21]=n.source_type,t[22]=p):p=t[22];const m=p;let g;t[23]!==r||t[24]!==s||t[25]!==n?(g="duckdb"===n.source_type&&I.jsx(it,{content:"Add SQL cell",delayDuration:400,children:I.jsx(X,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:ot.stopPropagation((()=>{s(_U(n,r))})),children:I.jsx(Md,{className:"h-3 w-3"})})}),t[23]=r,t[24]=s,t[25]=n,t[26]=g):g=t[26];const y=g;let b;t[27]!==o.chart_max_rows_errors?(b=o.chart_max_rows_errors&&I.jsx("span",{className:"text-xs text-muted-foreground",children:"Too many rows to render the chart."}),t[27]=o.chart_max_rows_errors,t[28]=b):b=t[28];const x=b;if(!(l||d||f||x)){let e;return t[29]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx("span",{className:"text-xs text-muted-foreground",children:"No data"}),t[29]=e):e=t[29],e}let v;return t[30]!==m||t[31]!==y||t[32]!==f||t[33]!==x||t[34]!==l||t[35]!==d?(v=I.jsxs("div",{className:"flex flex-col gap-2 relative",children:[l,m,y,x,f,d]}),t[30]=m,t[31]=y,t[32]=f,t[33]=x,t[34]=l,t[35]=d,t[36]=v):v=t[36],v};function _U(e,t){return e.engine?`_df = mo.sql(f'SELECT "${t.name}" FROM ${e.name} LIMIT 100', engine=${e.engine})`:`_df = mo.sql(f'SELECT "${t.name}" FROM ${e.name} LIMIT 100')`}function IU(e){return e.engine||e.source}function AU(e){return e}function TU(e){const[t]=e;return"memory"===t?0:1}function MU(e,t){if("memory"===e)return"In-Memory";if("duckdb"===e)return"DuckDB";const n=t[0];return n.engine?I.jsxs(I.Fragment,{children:[I.jsx(Mt,{className:"h-4 w-4 text-muted-foreground",name:n.source}),Wa(n.source),I.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",I.jsx(vU,{variableName:n.engine}),")"]})]}):e}function DU(e){const[t,n]=e;return null==n?null:I.jsxs("div",{className:"flex items-center gap-1 group",children:[I.jsx(xU,{className:"h-3 w-3 invisible group-hover:visible",value:String(n)}),I.jsx("span",{className:"text-xs min-w-[60px] uppercase",children:t}),I.jsx("span",{className:"text-xs font-bold text-muted-foreground tracking-wide",children:Va(n)})]},t)}function OU(e){return{...e,config:{...e.config,background:"transparent"}}}const RU=e=>{const t=j.c(4),{isOpen:n,children:r}=e,[o,s]=u.useState(!1);let i,a;return t[0]!==o||t[1]!==n?(i=()=>{n&&!o&&s(!0)},a=[n,o],t[0]=o,t[1]=n,t[2]=i,t[3]=a):(i=t[2],a=t[3]),u.useEffect(i,a),o?r:null},PU=Nt("marimo:scratchpadHistory:v1",[]),LU=q(!1),zU=q(null,((e,t,n)=>{if(!(n=n.trim()))return;const r=e(PU),o=[n,...r.filter((e=>e!==n))].slice(0,15);t(PU,o)})),FU={hide_code:!1,disabled:!1},BU=()=>{const e=j.c(80),t=Wn(),[n]=Re(),{theme:r}=Oe(),s=o.useRef(null),i=Eu(),{createNewCell:a,updateCellCode:l}=U(),c=t.cellRuntime[De],d=null==c?void 0:c.output,u=null==c?void 0:c.status,h=null==c?void 0:c.consoleOutputs,f=t.cellData[De],p=(null==f?void 0:f.code)??"",m=ae(zU),[g,y]=ze(LU),b=se(PU);let x;e[0]!==m||e[1]!==p?(x=()=>{Ga({code:p}),m(p)},e[0]=m,e[1]=p,e[2]=x):x=e[2];const v=B(x);let w;e[3]!==p||e[4]!==a||e[5]!==i?(w=()=>{p.trim()&&a({code:p,before:!1,cellId:i??"__end__"})},e[3]=p,e[4]=a,e[5]=i,e[6]=w):w=e[6];const k=B(w);let S;e[7]!==l?(S=()=>{l({cellId:De,code:"",formattingChange:!1}),Ga({code:""});const e=s.current;e&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:""}})},e[7]=l,e[8]=S):S=e[8];const C=B(S);let E;e[9]!==y||e[10]!==l?(E=e=>{y(!1),l({cellId:De,code:e,formattingChange:!1});const t=s.current;t&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},e[9]=y,e[10]=l,e[11]=E):E=e[11];const N=B(E),[_,A]=o.useState();let T,M,D,O,R,P,L,z;if(e[12]!==p||e[13]!==h||e[14]!==C||e[15]!==k||e[16]!==v||e[17]!==N||e[18]!==b||e[19]!==g||e[20]!==_||e[21]!==d||e[22]!==y||e[23]!==u||e[24]!==r||e[25]!==l||e[26]!==n){const t=()=>I.jsxs(I.Fragment,{children:[I.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[40%]",children:I.jsx(mI,{theme:r,allowFocus:!1,showPlaceholder:!1,id:De,code:p,config:FU,status:"idle",serializedEditorState:null,runCell:v,updateCellCode:l,createNewCell:Kn.NOOP,deleteCell:Kn.NOOP,focusCell:Kn.NOOP,moveCell:Kn.NOOP,moveToNextCell:void 0,updateCellConfig:Kn.NOOP,clearSerializedEditorState:Kn.NOOP,userConfig:n,editorViewRef:s,setEditorView:e=>{s.current=e},hidden:!1,temporarilyShowCode:Kn.NOOP,languageAdapter:_,setLanguageAdapter:A})}),I.jsx("div",{className:"flex-1 overflow-auto flex-shrink-0",children:I.jsx(Qs,{allowExpand:!1,output:d,className:"output-area",cellId:De,stale:!1})}),I.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[35%]",children:I.jsx(Kl,{consoleOutputs:h,className:"overflow-auto",stale:!1,cellName:qa,onSubmitDebugger:Kn.NOOP,cellId:De,debuggerActive:!1})})]});let o;e[33]!==N||e[34]!==b||e[35]!==g||e[36]!==r?(o=()=>g?I.jsx("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:I.jsx("div",{className:"overflow-auto flex flex-col gap-3",children:b.map(((e,t)=>I.jsx("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>N(e),children:I.jsx(Sa,{language:"python",theme:r,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:e.trim(),editable:!1,readOnly:!0})},t)))})}):null,e[33]=N,e[34]=b,e[35]=g,e[36]=r,e[37]=o):o=e[37];const i=o;let a,c,f,m,x,w,S,E,j;D="flex flex-col h-full overflow-hidden divide-y",e[38]===Symbol.for("react.memo_cache_sentinel")?(O=xt.create(De),e[38]=O):O=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(a=Bt("cell.run"),e[39]=a):a=e[39],e[40]===Symbol.for("react.memo_cache_sentinel")?(c=I.jsx(bd,{color:"var(--grass-11)",size:16}),e[40]=c):c=e[40],e[41]!==v||e[42]!==g?(f=I.jsx(it,{content:a,children:I.jsx(X,{"data-testid":"scratchpad-run-button",onClick:v,disabled:g,variant:"text",size:"xs",children:c})}),e[41]=v,e[42]=g,e[43]=f):f=e[43],e[44]===Symbol.for("react.memo_cache_sentinel")?(m=I.jsx(Gc,{size:16}),e[44]=m):m=e[44],e[45]!==C||e[46]!==g?(x=I.jsx(it,{content:"Clear code and outputs",children:I.jsx(X,{disabled:g,size:"xs",variant:"text",onClick:C,children:m})}),e[45]=C,e[46]=g,e[47]=x):x=e[47],e[48]===Symbol.for("react.memo_cache_sentinel")?(w=I.jsx(Tc,{size:16}),e[48]=w):w=e[48],e[49]!==k||e[50]!==g?(S=I.jsx(cf,{children:I.jsx(it,{content:"Insert code",children:I.jsx(X,{disabled:g,size:"xs",variant:"text",onClick:k,children:w})})}),e[49]=k,e[50]=g,e[51]=S):S=e[51],e[52]!==u?(E=("running"===u||"queued"===u)&&I.jsx(Mi,{className:"inline",size:"small"}),e[52]=u,e[53]=E):E=e[53],e[54]===Symbol.for("react.memo_cache_sentinel")?(j=I.jsx("div",{className:"flex-1"}),e[54]=j):j=e[54];const L=g&&"bg-[var(--sky-3)] rounded-none";let z,F;e[55]!==L?(z=In(L),e[55]=L,e[56]=z):z=e[56],e[57]!==g||e[58]!==y?(F=()=>y(!g),e[57]=g,e[58]=y,e[59]=F):F=e[59];const B=0===b.length;let U,$;e[60]===Symbol.for("react.memo_cache_sentinel")?(U=I.jsx(td,{size:16}),e[60]=U):U=e[60],e[61]!==z||e[62]!==F||e[63]!==B?($=I.jsx(it,{content:"Toggle history",children:I.jsx(X,{size:"xs",variant:"text",className:z,onClick:F,disabled:B,children:U})}),e[61]=z,e[62]=F,e[63]=B,e[64]=$):$=e[64],e[65]!==f||e[66]!==x||e[67]!==S||e[68]!==E||e[69]!==$?(R=I.jsxs("div",{className:"flex items-center flex-shrink-0",children:[f,x,S,E,j,$]}),e[65]=f,e[66]=x,e[67]=S,e[68]=E,e[69]=$,e[70]=R):R=e[70],T="flex-1 divide-y relative overflow-hidden flex flex-col",M=t(),P=i(),e[12]=p,e[13]=h,e[14]=C,e[15]=k,e[16]=v,e[17]=N,e[18]=b,e[19]=g,e[20]=_,e[21]=d,e[22]=y,e[23]=u,e[24]=r,e[25]=l,e[26]=n,e[27]=T,e[28]=M,e[29]=D,e[30]=O,e[31]=R,e[32]=P}else T=e[27],M=e[28],D=e[29],O=e[30],R=e[31],P=e[32];return e[71]!==T||e[72]!==M||e[73]!==P?(L=I.jsxs("div",{className:T,children:[M,P]}),e[71]=T,e[72]=M,e[73]=P,e[74]=L):L=e[74],e[75]!==L||e[76]!==D||e[77]!==O||e[78]!==R?(z=I.jsxs("div",{className:D,id:O,children:[R,L]}),e[75]=L,e[76]=D,e[77]=O,e[78]=R,e[79]=z):z=e[79],z},UU=()=>{const e=j.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx(BU,{}),e[0]=t):t=e[0],t},$U=()=>{const e=j.c(16),[t]=Re(),n=t.package_management.manager;let r;e[0]!==n?(r=[n],e[0]=n,e[1]=r):r=e[1];const{data:o,loading:s,error:i,reload:a}=jn(GU,r);if(s&&!o){let t;return e[2]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx(Mi,{size:"medium",centered:!0}),e[2]=t):t=e[2],t}if(i){let t;return e[3]!==i?(t=I.jsx(ya,{error:i}),e[3]=i,e[4]=t):t=e[4],t}let l;e[5]!==(null==o?void 0:o.packages)?(l=(null==o?void 0:o.packages)||[],e[5]=null==o?void 0:o.packages,e[6]=l):l=e[6];const c=l;let d,u,h;return e[7]!==n||e[8]!==a?(d=I.jsx(HU,{packageManager:n,onSuccess:a}),e[7]=n,e[8]=a,e[9]=d):d=e[9],e[10]!==c||e[11]!==a?(u=I.jsx(VU,{packages:c,onSuccess:a}),e[10]=c,e[11]=a,e[12]=u):u=e[12],e[13]!==d||e[14]!==u?(h=I.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[d,u]}),e[13]=d,e[14]=u,e[15]=h):h=e[15],h},HU=({onSuccess:e,packageManager:t})=>{const[n,r]=u.useState(""),[o,s]=u.useState(!1),{handleClick:i}=Al(),a=async()=>{try{s(!0);const t=await Ja({package:n});t.success?(e(),ee({title:"Package added",description:I.jsxs("span",{children:["The package ",I.jsx(vr,{className:"inline",children:n})," and its dependencies has been added to your environment."]})})):ee({title:"Failed to add package",description:t.error,variant:"danger"})}finally{r(""),s(!1)}};return I.jsxs("div",{className:"flex items-center w-full border-b",children:[I.jsx(ra,{placeholder:`Install packages with ${t}...`,id:Xy,icon:o?I.jsx(Mi,{size:"small",className:"mr-2 h-4 w-4 shrink-0 opacity-50"}):I.jsx(it,{content:"Change package manager",children:I.jsx(Dc,{onClick:()=>i("packageManagement"),className:"mr-2 h-4 w-4 shrink-0 opacity-50 hover:opacity-80 cursor-pointer"})}),rootClassName:"flex-1 border-none",value:n,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),a())},onChange:e=>r(e.target.value)}),I.jsx(it,{delayDuration:300,side:"left",align:"start",content:I.jsxs("div",{className:"text-sm flex flex-col w-full max-w-[360px]",children:["Packages are installed using the package manager specified in your user configuration. Depending on your package manager, you can install packages with various formats:",I.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[I.jsxs("div",{children:[I.jsx("span",{className:"font-bold tracking-wide",children:"Package name:"})," A package name; this will install the latest version.",I.jsx("div",{className:"text-muted-foreground",children:"Example: httpx"})]}),I.jsxs("div",{children:[I.jsx("span",{className:"font-bold tracking-wide",children:"Package and version:"})," ","A package with a specific version or version range.",I.jsx("div",{className:"text-muted-foreground",children:"Examples: httpx==0.27.0, httpx>=0.27.0"})]}),I.jsxs("div",{children:[I.jsx("span",{className:"font-bold tracking-wide",children:"Git:"})," A Git repository",I.jsx("div",{className:"text-muted-foreground",children:"Example: git+https://github.com/encode/httpx"})]}),I.jsxs("div",{children:[I.jsx("span",{className:"font-bold tracking-wide",children:"URL:"})," A remote wheel or source distribution.",I.jsx("div",{className:"text-muted-foreground",children:"Example: https://example.com/httpx-0.27.0.tar.gz"})]}),I.jsxs("div",{children:[I.jsx("span",{className:"font-bold tracking-wide",children:"Path:"})," A local wheel, source distribution, or project directory.",I.jsx("div",{className:"text-muted-foreground",children:"Example: /example/foo-0.1.0-py3-none-any.whl"})]})]})]}),children:I.jsx(Xa,{className:"h-4 w-4 cursor-help text-muted-foreground hover:text-foreground bg-transparent"})}),I.jsx("button",{type:"button",className:In("float-right px-2 m-0 h-full text-sm text-secondary-foreground ml-2",n&&"bg-accent text-accent-foreground","disabled:cursor-not-allowed disabled:opacity-50"),onClick:a,disabled:!n,children:"Add"})]})},VU=e=>{const t=j.c(9),{onSuccess:n,packages:r}=e;if(0===r.length){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=I.jsx(aM,{title:"No packages",description:"No packages are installed in this environment.",icon:I.jsx(Dc,{})}),t[0]=e):e=t[0],e}let o,s,i;if(t[1]===Symbol.for("react.memo_cache_sentinel")?(o=I.jsx(sa,{children:I.jsxs(ia,{children:[I.jsx(aa,{children:"Name"}),I.jsx(aa,{children:"Version"}),I.jsx(aa,{})]})}),t[1]=o):o=t[1],t[2]!==n||t[3]!==r){let e;t[5]!==n?(e=e=>I.jsxs(ia,{className:"group",onClick:async()=>{await nt(`${e.name}==${e.version}`),ee({title:"Copied to clipboard"})},children:[I.jsx(da,{children:e.name}),I.jsx(da,{children:e.version}),I.jsx(da,{children:I.jsx(WU,{packageName:e.name,onSuccess:n})})]},e.name),t[5]=n,t[6]=e):e=t[6],s=r.map(e),t[2]=n,t[3]=r,t[4]=s}else s=t[4];return t[7]!==s?(i=I.jsxs(oa,{className:"overflow-auto flex-1",children:[o,I.jsx(ca,{children:s})]}),t[7]=s,t[8]=i):i=t[8],i},WU=({packageName:e,onSuccess:t})=>{const[n,r]=u.useState(!1);return n?I.jsx(Mi,{size:"small",className:"float-right mr-2 h-4 w-4 shrink-0 opacity-50"}):I.jsx("button",{type:"button",className:In("float-right px-2 h-full text-xs text-muted-foreground hover:text-foreground","invisible group-hover:visible"),onClick:ot.stopPropagation((async()=>{try{r(!0);const n=await Ka({package:e});n.success?(t(),ee({title:"Package removed",description:I.jsxs("span",{children:["The package ",I.jsx(vr,{className:"inline",children:e})," has been removed from your environment."]})})):ee({title:"Failed to add package",description:n.error,variant:"danger"})}finally{r(!1)}})),children:"Remove"})};function GU(){return Ya()}var qU="ScrollArea",[YU,XU]=no(qU),[JU,KU]=YU(qU),ZU=o.forwardRef(((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:s,scrollHideDelay:i=600,...a}=e,[l,c]=o.useState(null),[d,u]=o.useState(null),[h,f]=o.useState(null),[p,m]=o.useState(null),[g,y]=o.useState(null),[b,x]=o.useState(0),[v,w]=o.useState(0),[k,S]=o.useState(!1),[C,E]=o.useState(!1),N=Za(t,(e=>c(e))),j=Qa(s);return I.jsx(JU,{scope:n,type:r,dir:j,scrollHideDelay:i,scrollArea:l,viewport:d,onViewportChange:u,content:h,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:k,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:y,scrollbarYEnabled:C,onScrollbarYEnabledChange:E,onCornerWidthChange:x,onCornerHeightChange:w,children:I.jsx(so.div,{dir:j,...a,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":v+"px",...e.style}})})}));ZU.displayName=qU;var QU="ScrollAreaViewport",e$=o.forwardRef(((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:s,...i}=e,a=KU(QU,n),l=o.useRef(null),c=Za(t,l,a.onViewportChange);return I.jsxs(I.Fragment,{children:[I.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),I.jsx(so.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:I.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})}));e$.displayName=QU;var t$="ScrollAreaScrollbar",n$=o.forwardRef(((e,t)=>{const{forceMount:n,...r}=e,s=KU(t$,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:a}=s,l="horizontal"===e.orientation;return o.useEffect((()=>(l?i(!0):a(!0),()=>{l?i(!1):a(!1)})),[l,i,a]),"hover"===s.type?I.jsx(r$,{...r,ref:t,forceMount:n}):"scroll"===s.type?I.jsx(o$,{...r,ref:t,forceMount:n}):"auto"===s.type?I.jsx(s$,{...r,ref:t,forceMount:n}):"always"===s.type?I.jsx(i$,{...r,ref:t}):null}));n$.displayName=t$;var r$=o.forwardRef(((e,t)=>{const{forceMount:n,...r}=e,s=KU(t$,e.__scopeScrollArea),[i,a]=o.useState(!1);return o.useEffect((()=>{const e=s.scrollArea;let t=0;if(e){const n=()=>{window.clearTimeout(t),a(!0)},r=()=>{t=window.setTimeout((()=>a(!1)),s.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",r),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",r)}}}),[s.scrollArea,s.scrollHideDelay]),I.jsx(el,{present:n||i,children:I.jsx(s$,{"data-state":i?"visible":"hidden",...r,ref:t})})})),o$=o.forwardRef(((e,t)=>{const{forceMount:n,...r}=e,s=KU(t$,e.__scopeScrollArea),i="horizontal"===e.orientation,a=E$((()=>c("SCROLL_END")),100),[l,c]=(d="hidden",u={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},o.useReducer(((e,t)=>u[e][t]??e),d));var d,u;return o.useEffect((()=>{if("idle"===l){const e=window.setTimeout((()=>c("HIDE")),s.scrollHideDelay);return()=>window.clearTimeout(e)}}),[l,s.scrollHideDelay,c]),o.useEffect((()=>{const e=s.viewport,t=i?"scrollLeft":"scrollTop";if(e){let n=e[t];const r=()=>{const r=e[t];n!==r&&(c("SCROLL"),a()),n=r};return e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}}),[s.viewport,i,c,a]),I.jsx(el,{present:n||"hidden"!==l,children:I.jsx(i$,{"data-state":"hidden"===l?"hidden":"visible",...r,ref:t,onPointerEnter:io(e.onPointerEnter,(()=>c("POINTER_ENTER"))),onPointerLeave:io(e.onPointerLeave,(()=>c("POINTER_LEAVE")))})})})),s$=o.forwardRef(((e,t)=>{const n=KU(t$,e.__scopeScrollArea),{forceMount:r,...s}=e,[i,a]=o.useState(!1),l="horizontal"===e.orientation,c=E$((()=>{if(n.viewport){const e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;a(l?e:t)}}),10);return N$(n.viewport,c),N$(n.content,c),I.jsx(el,{present:r||i,children:I.jsx(i$,{"data-state":i?"visible":"hidden",...s,ref:t})})})),i$=o.forwardRef(((e,t)=>{const{orientation:n="vertical",...r}=e,s=KU(t$,e.__scopeScrollArea),i=o.useRef(null),a=o.useRef(0),[l,c]=o.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=x$(l.viewport,l.content),u={...r,sizes:l,onSizesChange:c,hasThumb:Boolean(d>0&&d<1),onThumbChange:e=>i.current=e,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:e=>a.current=e};function h(e,t){return function(e,t,n,r="ltr"){const o=v$(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,u="ltr"===r?[0,d]:[-1*d,0];return k$([l,c],u)(e)}(e,a.current,l,t)}return"horizontal"===n?I.jsx(a$,{...u,ref:t,onThumbPositionChange:()=>{if(s.viewport&&i.current){const e=w$(s.viewport.scrollLeft,l,s.dir);i.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{s.viewport&&(s.viewport.scrollLeft=e)},onDragScroll:e=>{s.viewport&&(s.viewport.scrollLeft=h(e,s.dir))}}):"vertical"===n?I.jsx(l$,{...u,ref:t,onThumbPositionChange:()=>{if(s.viewport&&i.current){const e=w$(s.viewport.scrollTop,l);i.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{s.viewport&&(s.viewport.scrollTop=e)},onDragScroll:e=>{s.viewport&&(s.viewport.scrollTop=h(e))}}):null})),a$=o.forwardRef(((e,t)=>{const{sizes:n,onSizesChange:r,...s}=e,i=KU(t$,e.__scopeScrollArea),[a,l]=o.useState(),c=o.useRef(null),d=Za(t,c,i.onScrollbarXChange);return o.useEffect((()=>{c.current&&l(getComputedStyle(c.current))}),[c]),I.jsx(u$,{"data-orientation":"horizontal",...s,ref:d,sizes:n,style:{bottom:0,left:"rtl"===i.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===i.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":v$(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(i.viewport){const r=i.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),S$(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:b$(a.paddingLeft),paddingEnd:b$(a.paddingRight)}})}})})),l$=o.forwardRef(((e,t)=>{const{sizes:n,onSizesChange:r,...s}=e,i=KU(t$,e.__scopeScrollArea),[a,l]=o.useState(),c=o.useRef(null),d=Za(t,c,i.onScrollbarYChange);return o.useEffect((()=>{c.current&&l(getComputedStyle(c.current))}),[c]),I.jsx(u$,{"data-orientation":"vertical",...s,ref:d,sizes:n,style:{top:0,right:"ltr"===i.dir?0:void 0,left:"rtl"===i.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":v$(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(i.viewport){const r=i.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),S$(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:b$(a.paddingTop),paddingEnd:b$(a.paddingBottom)}})}})})),[c$,d$]=YU(t$),u$=o.forwardRef(((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:s,onThumbChange:i,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:u,onResize:h,...f}=e,p=KU(t$,n),[m,g]=o.useState(null),y=Za(t,(e=>g(e))),b=o.useRef(null),x=o.useRef(""),v=p.viewport,w=r.content-r.viewport,k=vo(u),S=vo(c),C=E$(h,10);function E(e){if(b.current){const t=e.clientX-b.current.left,n=e.clientY-b.current.top;d({x:t,y:n})}}return o.useEffect((()=>{const e=e=>{const t=e.target;(null==m?void 0:m.contains(t))&&k(e,w)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})}),[v,m,w,k]),o.useEffect(S,[r,S]),N$(m,C),N$(p.content,C),I.jsx(c$,{scope:n,scrollbar:m,hasThumb:s,onThumbChange:vo(i),onThumbPointerUp:vo(a),onThumbPositionChange:S,onThumbPointerDown:vo(l),children:I.jsx(so.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:io(e.onPointerDown,(e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),b.current=m.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),E(e)}})),onPointerMove:io(e.onPointerMove,E),onPointerUp:io(e.onPointerUp,(e=>{const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=x.current,p.viewport&&(p.viewport.style.scrollBehavior=""),b.current=null}))})})})),h$="ScrollAreaThumb",f$=o.forwardRef(((e,t)=>{const{forceMount:n,...r}=e,o=d$(h$,e.__scopeScrollArea);return I.jsx(el,{present:n||o.hasThumb,children:I.jsx(p$,{ref:t,...r})})})),p$=o.forwardRef(((e,t)=>{const{__scopeScrollArea:n,style:r,...s}=e,i=KU(h$,n),a=d$(h$,n),{onThumbPositionChange:l}=a,c=Za(t,(e=>a.onThumbChange(e))),d=o.useRef(void 0),u=E$((()=>{d.current&&(d.current(),d.current=void 0)}),100);return o.useEffect((()=>{const e=i.viewport;if(e){const t=()=>{if(u(),!d.current){const t=C$(e,l);d.current=t,l()}};return l(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}}),[i.viewport,u,l]),I.jsx(so.div,{"data-state":a.hasThumb?"visible":"hidden",...s,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:io(e.onPointerDownCapture,(e=>{const t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;a.onThumbPointerDown({x:n,y:r})})),onPointerUp:io(e.onPointerUp,a.onThumbPointerUp)})}));f$.displayName=h$;var m$="ScrollAreaCorner",g$=o.forwardRef(((e,t)=>{const n=KU(m$,e.__scopeScrollArea),r=Boolean(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&r?I.jsx(y$,{...e,ref:t}):null}));g$.displayName=m$;var y$=o.forwardRef(((e,t)=>{const{__scopeScrollArea:n,...r}=e,s=KU(m$,n),[i,a]=o.useState(0),[l,c]=o.useState(0),d=Boolean(i&&l);return N$(s.scrollbarX,(()=>{var e;const t=(null==(e=s.scrollbarX)?void 0:e.offsetHeight)||0;s.onCornerHeightChange(t),c(t)})),N$(s.scrollbarY,(()=>{var e;const t=(null==(e=s.scrollbarY)?void 0:e.offsetWidth)||0;s.onCornerWidthChange(t),a(t)})),d?I.jsx(so.div,{...r,ref:t,style:{width:i,height:l,position:"absolute",right:"ltr"===s.dir?0:void 0,left:"rtl"===s.dir?0:void 0,bottom:0,...e.style}}):null}));function b$(e){return e?parseInt(e,10):0}function x$(e,t){const n=e/t;return isNaN(n)?0:n}function v$(e){const t=x$(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function w$(e,t,n="ltr"){const r=v$(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=nl(e,"ltr"===n?[0,i]:[-1*i,0]);return k$([0,i],[0,a])(l)}function k$(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function S$(e,t){return e>0&&e<t}var C$=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function E$(e,t){const n=vo(e),r=o.useRef(0);return o.useEffect((()=>()=>window.clearTimeout(r.current)),[]),o.useCallback((()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)}),[n,t])}function N$(e,t){const n=vo(t);tl((()=>{let t=0;if(e){const r=new ResizeObserver((()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)}));return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}}),[e,n])}var j$=ZU,_$=e$,I$=g$;const A$=o.forwardRef(((e,t)=>{const n=j.c(15);let r,o,s,i,a,l,c,d;return n[0]!==e?(({className:o,children:r,...s}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]),n[4]!==o?(i=In("relative overflow-hidden",o),n[4]=o,n[5]=i):i=n[5],n[6]!==r?(a=I.jsx(_$,{className:"h-full w-full rounded-[inherit]",children:r}),n[6]=r,n[7]=a):a=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=I.jsx(T$,{}),c=I.jsx(I$,{}),n[8]=l,n[9]=c):(l=n[8],c=n[9]),n[10]!==s||n[11]!==t||n[12]!==i||n[13]!==a?(d=I.jsxs(j$,{ref:t,className:i,...s,children:[a,l,c]}),n[10]=s,n[11]=t,n[12]=i,n[13]=a,n[14]=d):d=n[14],d}));A$.displayName=j$.displayName;const T$=o.forwardRef(((e,t)=>{const n=j.c(14);let r,o,s;n[0]!==e?(({className:r,orientation:s,...o}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]);const i=void 0===s?"vertical":s,a="vertical"===i&&"h-full w-2.5 border-l border-l-transparent p-[1px]",l="horizontal"===i&&"h-2.5 flex-col border-t border-t-transparent p-[1px]";let c,d,u;return n[4]!==r||n[5]!==a||n[6]!==l?(c=In("flex touch-none select-none transition-colors",a,l,r),n[4]=r,n[5]=a,n[6]=l,n[7]=c):c=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(d=I.jsx(f$,{className:"relative flex-1 rounded-full bg-border"}),n[8]=d):d=n[8],n[9]!==i||n[10]!==o||n[11]!==t||n[12]!==c?(u=I.jsx(n$,{ref:t,orientation:i,className:c,...o,children:d}),n[9]=i,n[10]=o,n[11]=t,n[12]=c,n[13]=u):u=n[13],u}));T$.displayName=n$.displayName;const M$=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,D$=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,O$={};function R$(e,t){return(O$.jsx?D$:M$).test(e)}const P$=/[ \t\n\f\r]/g;function L$(e){return""===e.replace(P$,"")}class z${constructor(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}}function F$(e,t){const n={},r={};let o=-1;for(;++o<e.length;)Object.assign(n,e[o].property),Object.assign(r,e[o].normal);return new z$(n,r,t)}function B$(e){return e.toLowerCase()}z$.prototype.property={},z$.prototype.normal={},z$.prototype.space=null;class U${constructor(e,t){this.property=e,this.attribute=t}}U$.prototype.space=null,U$.prototype.boolean=!1,U$.prototype.booleanish=!1,U$.prototype.overloadedBoolean=!1,U$.prototype.number=!1,U$.prototype.commaSeparated=!1,U$.prototype.spaceSeparated=!1,U$.prototype.commaOrSpaceSeparated=!1,U$.prototype.mustUseProperty=!1,U$.prototype.defined=!1;let $$=0;const H$=J$(),V$=J$(),W$=J$(),G$=J$(),q$=J$(),Y$=J$(),X$=J$();function J$(){return 2**++$$}const K$=Object.freeze(Object.defineProperty({__proto__:null,boolean:H$,booleanish:V$,commaOrSpaceSeparated:X$,commaSeparated:Y$,number:G$,overloadedBoolean:W$,spaceSeparated:q$},Symbol.toStringTag,{value:"Module"})),Z$=Object.keys(K$);class Q$ extends U${constructor(e,t,n,r){let o=-1;if(super(e,t),eH(this,"space",r),"number"==typeof n)for(;++o<Z$.length;){const e=Z$[o];eH(this,Z$[o],(n&K$[e])===K$[e])}}}function eH(e,t,n){n&&(e[t]=n)}Q$.prototype.defined=!0;const tH={}.hasOwnProperty;function nH(e){const t={},n={};let r;for(r in e.properties)if(tH.call(e.properties,r)){const o=e.properties[r],s=new Q$(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[B$(r)]=r,n[B$(s.attribute)]=r}return new z$(t,n,e.space)}const rH=nH({space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase(),properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),oH=nH({space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase(),properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function sH(e,t){return t in e?e[t]:t}function iH(e,t){return sH(e,t.toLowerCase())}const aH=nH({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:iH,properties:{xmlns:null,xmlnsXLink:null}}),lH=nH({transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase(),properties:{ariaActiveDescendant:null,ariaAtomic:V$,ariaAutoComplete:null,ariaBusy:V$,ariaChecked:V$,ariaColCount:G$,ariaColIndex:G$,ariaColSpan:G$,ariaControls:q$,ariaCurrent:null,ariaDescribedBy:q$,ariaDetails:null,ariaDisabled:V$,ariaDropEffect:q$,ariaErrorMessage:null,ariaExpanded:V$,ariaFlowTo:q$,ariaGrabbed:V$,ariaHasPopup:null,ariaHidden:V$,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:q$,ariaLevel:G$,ariaLive:null,ariaModal:V$,ariaMultiLine:V$,ariaMultiSelectable:V$,ariaOrientation:null,ariaOwns:q$,ariaPlaceholder:null,ariaPosInSet:G$,ariaPressed:V$,ariaReadOnly:V$,ariaRelevant:null,ariaRequired:V$,ariaRoleDescription:q$,ariaRowCount:G$,ariaRowIndex:G$,ariaRowSpan:G$,ariaSelected:V$,ariaSetSize:G$,ariaSort:null,ariaValueMax:G$,ariaValueMin:G$,ariaValueNow:G$,ariaValueText:null,role:null}}),cH=nH({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:iH,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Y$,acceptCharset:q$,accessKey:q$,action:null,allow:null,allowFullScreen:H$,allowPaymentRequest:H$,allowUserMedia:H$,alt:null,as:null,async:H$,autoCapitalize:null,autoComplete:q$,autoFocus:H$,autoPlay:H$,blocking:q$,capture:null,charSet:null,checked:H$,cite:null,className:q$,cols:G$,colSpan:null,content:null,contentEditable:V$,controls:H$,controlsList:q$,coords:G$|Y$,crossOrigin:null,data:null,dateTime:null,decoding:null,default:H$,defer:H$,dir:null,dirName:null,disabled:H$,download:W$,draggable:V$,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:H$,formTarget:null,headers:q$,height:G$,hidden:H$,high:G$,href:null,hrefLang:null,htmlFor:q$,httpEquiv:q$,id:null,imageSizes:null,imageSrcSet:null,inert:H$,inputMode:null,integrity:null,is:null,isMap:H$,itemId:null,itemProp:q$,itemRef:q$,itemScope:H$,itemType:q$,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:H$,low:G$,manifest:null,max:null,maxLength:G$,media:null,method:null,min:null,minLength:G$,multiple:H$,muted:H$,name:null,nonce:null,noModule:H$,noValidate:H$,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:H$,optimum:G$,pattern:null,ping:q$,placeholder:null,playsInline:H$,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:H$,referrerPolicy:null,rel:q$,required:H$,reversed:H$,rows:G$,rowSpan:G$,sandbox:q$,scope:null,scoped:H$,seamless:H$,selected:H$,shadowRootClonable:H$,shadowRootDelegatesFocus:H$,shadowRootMode:null,shape:null,size:G$,sizes:null,slot:null,span:G$,spellCheck:V$,src:null,srcDoc:null,srcLang:null,srcSet:null,start:G$,step:null,style:null,tabIndex:G$,target:null,title:null,translate:null,type:null,typeMustMatch:H$,useMap:null,value:V$,width:G$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:q$,axis:null,background:null,bgColor:null,border:G$,borderColor:null,bottomMargin:G$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:H$,declare:H$,event:null,face:null,frame:null,frameBorder:null,hSpace:G$,leftMargin:G$,link:null,longDesc:null,lowSrc:null,marginHeight:G$,marginWidth:G$,noResize:H$,noHref:H$,noShade:H$,noWrap:H$,object:null,profile:null,prompt:null,rev:null,rightMargin:G$,rules:null,scheme:null,scrolling:V$,standby:null,summary:null,text:null,topMargin:G$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:G$,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:H$,disableRemotePlayback:H$,prefix:null,property:null,results:G$,security:null,unselectable:null}}),dH=nH({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",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",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",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",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",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",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:sH,properties:{about:X$,accentHeight:G$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:G$,amplitude:G$,arabicForm:null,ascent:G$,attributeName:null,attributeType:null,azimuth:G$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:G$,by:null,calcMode:null,capHeight:G$,className:q$,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:G$,diffuseConstant:G$,direction:null,display:null,dur:null,divisor:G$,dominantBaseline:null,download:H$,dx:null,dy:null,edgeMode:null,editable:null,elevation:G$,enableBackground:null,end:null,event:null,exponent:G$,externalResourcesRequired:null,fill:null,fillOpacity:G$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Y$,g2:Y$,glyphName:Y$,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:G$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:G$,horizOriginX:G$,horizOriginY:G$,id:null,ideographic:G$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:G$,k:G$,k1:G$,k2:G$,k3:G$,k4:G$,kernelMatrix:X$,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:G$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:G$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:G$,overlineThickness:G$,paintOrder:null,panose1:null,path:null,pathLength:G$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:q$,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:G$,pointsAtY:G$,pointsAtZ:G$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:X$,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:X$,rev:X$,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:X$,requiredFeatures:X$,requiredFonts:X$,requiredFormats:X$,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:G$,specularExponent:G$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:G$,strikethroughThickness:G$,string:null,stroke:null,strokeDashArray:X$,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:G$,strokeOpacity:G$,strokeWidth:null,style:null,surfaceScale:G$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:X$,tabIndex:G$,tableValues:null,target:null,targetX:G$,targetY:G$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:X$,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:G$,underlineThickness:G$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:G$,values:null,vAlphabetic:G$,vMathematical:G$,vectorEffect:null,vHanging:G$,vIdeographic:G$,version:null,vertAdvY:G$,vertOriginX:G$,vertOriginY:G$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:G$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),uH=/^data[-\w.:]+$/i,hH=/-[a-z]/g,fH=/[A-Z]/g;function pH(e){return"-"+e.toLowerCase()}function mH(e){return e.charAt(1).toUpperCase()}const gH={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},yH=F$([oH,rH,aH,lH,cH],"html"),bH=F$([oH,rH,aH,lH,dH],"svg");const xH=rl.default||rl,vH=kH("end"),wH=kH("start");function kH(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function SH(e){return e&&"object"==typeof e?"position"in e||"type"in e?EH(e.position):"start"in e||"end"in e?EH(e):"line"in e||"column"in e?CH(e):"":""}function CH(e){return NH(e&&e.line)+":"+NH(e&&e.column)}function EH(e){return CH(e&&e.start)+"-"+CH(e&&e.end)}function NH(e){return e&&"number"==typeof e?e:1}class jH extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",o={},s=!1;if(t&&(o="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!o.cause&&e&&(s=!0,r=e.message,o.cause=e),!o.ruleId&&!o.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?o.ruleId=n:(o.source=n.slice(0,e),o.ruleId=n.slice(e+1))}if(!o.place&&o.ancestors&&o.ancestors){const e=o.ancestors[o.ancestors.length-1];e&&(o.place=e.position)}const i=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file,this.message=r,this.line=i?i.line:void 0,this.name=SH(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&"string"==typeof o.cause.stack?o.cause.stack:"",this.actual,this.expected,this.note,this.url}}jH.prototype.file="",jH.prototype.name="",jH.prototype.reason="",jH.prototype.message="",jH.prototype.stack="",jH.prototype.column=void 0,jH.prototype.line=void 0,jH.prototype.ancestors=void 0,jH.prototype.cause=void 0,jH.prototype.fatal=void 0,jH.prototype.place=void 0,jH.prototype.ruleId=void 0,jH.prototype.source=void 0;const _H={}.hasOwnProperty,IH=new Map,AH=/[A-Z]/g,TH=/-([a-z])/g,MH=new Set(["table","tbody","thead","tfoot","tr"]),DH=new Set(["td","th"]),OH="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function RH(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if("function"!=typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=function(e,t){return n;function n(n,r,o,s){const i=Array.isArray(o.children),a=wH(n);return t(r,o,s,i,{columnNumber:a?a.column-1:void 0,fileName:e,lineNumber:a?a.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw new TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");r=function(e,t,n){return r;function r(e,r,o,s){const i=Array.isArray(o.children)?n:t;return s?i(r,o,s):i(r,o)}}(0,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?bH:yH,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},s=PH(o,e,void 0);return s&&"string"!=typeof s?s:o.create(e,o.Fragment,{children:s||void 0},void 0)}function PH(e,t,n){return"element"===t.type?function(e,t,n){const r=e.schema;let o=r;"svg"===t.tagName.toLowerCase()&&"html"===r.space&&(o=bH,e.schema=o);e.ancestors.push(t);const s=UH(e,t.tagName,!1),i=function(e,t){const n={};let r,o;for(o in t.properties)if("children"!==o&&_H.call(t.properties,o)){const s=BH(e,o,t.properties[o]);if(s){const[o,i]=s;e.tableCellAlignToStyle&&"align"===o&&"string"==typeof i&&DH.has(t.tagName)?r=i:n[o]=i}}if(r){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r}return n}(e,t);let a=FH(e,t);MH.has(t.tagName)&&(a=a.filter((function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&L$(t.value):L$(t));var t})));return LH(e,i,s,t),zH(i,a),e.ancestors.pop(),e.schema=r,e.create(t,s,i,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}$H(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const r=e.schema;let o=r;"svg"===t.name&&"html"===r.space&&(o=bH,e.schema=o);e.ancestors.push(t);const s=null===t.name?e.Fragment:UH(e,t.name,!0),i=function(e,t){const n={};for(const r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){const t=r.data.estree.body[0];t.type;const o=t.expression;o.type;const s=o.properties[0];s.type,Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else $H(e,t.position);else{const o=r.name;let s;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){const t=r.value.data.estree.body[0];t.type,s=e.evaluater.evaluateExpression(t.expression)}else $H(e,t.position);else s=null===r.value||r.value;n[o]=s}return n}(e,t),a=FH(e,t);return LH(e,i,s,t),zH(i,a),e.ancestors.pop(),e.schema=r,e.create(t,s,i,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);$H(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return zH(r,FH(e,t)),e.create(t,e.Fragment,r,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function LH(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function zH(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function FH(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:IH;for(;++r<t.children.length;){const s=t.children[r];let i;if(e.passKeys){const e="element"===s.type?s.tagName:"mdxJsxFlowElement"===s.type||"mdxJsxTextElement"===s.type?s.name:void 0;if(e){const t=o.get(e)||0;i=e+"-"+t,o.set(e,t+1)}}const a=PH(e,s,i);void 0!==a&&n.push(a)}return n}function BH(e,t,n){const r=function(e,t){const n=B$(t);let r=t,o=U$;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&uH.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(hH,mH);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!hH.test(e)){let n=e.replace(fH,pH);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}o=Q$}return new o(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?function(e){const t={};return(""===e[e.length-1]?[...e,""]:e).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){const n={};try{xH(t,r)}catch(o){if(!e.ignoreInvalidStyle){const t=o,n=new jH("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=OH+"#cannot-parse-style-attribute",n}}return n;function r(e,t){let r=e;"--"!==r.slice(0,2)&&("-ms-"===r.slice(0,4)&&(r="ms-"+r.slice(4)),r=r.replace(TH,VH)),n[r]=t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)_H.call(e,n)&&(t[HH(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?gH[r.property]||r.property:r.attribute,n]}}function UH(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,o=-1;for(;++o<e.length;){const t=R$(e[o])?{type:"Identifier",name:e[o]}:{type:"Literal",value:e[o]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(o&&"Literal"===t.type),optional:!1}:t}r=n}else r=R$(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){const t=r.value;return _H.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);$H(e)}function $H(e,t){const n=new jH("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=OH+"#cannot-handle-mdx-estrees-without-createevaluater",n}function HH(e){let t=e.replace(AH,WH);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function VH(e,t){return t.toUpperCase()}function WH(e){return"-"+e.toLowerCase()}const GH={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},qH={};function YH(e,t,n){if(function(e){return Boolean(e&&"object"==typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return XH(e.children,t,n)}return Array.isArray(e)?XH(e,t,n):""}function XH(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=YH(e[o],t,n);return r.join("")}const JH=document.createElement("i");function KH(e){const t="&"+e+";";JH.innerHTML=t;const n=JH.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function ZH(e,t,n,r){const o=e.length;let s,i=0;if(t=t<0?-t>o?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);i<r.length;)s=r.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function QH(e,t){return e.length>0?(ZH(e,e.length,0,t),e):t}const eV={}.hasOwnProperty;function tV(e,t){let n;for(n in t){const r=(eV.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let s;if(o)for(s in o){eV.call(r,s)||(r[s]=[]);const e=o[s];nV(r[s],Array.isArray(e)?e:e?[e]:[])}}}function nV(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);ZH(e,0,0,r)}function rV(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||65534==(65535&n)||n>1114111?"�":String.fromCodePoint(n)}function oV(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const sV=yV(/[A-Za-z]/),iV=yV(/[\dA-Za-z]/),aV=yV(/[#-'*+\--9=?A-Z^-~]/);function lV(e){return null!==e&&(e<32||127===e)}const cV=yV(/\d/),dV=yV(/[\dA-Fa-f]/),uV=yV(/[!-/:-@[-`{-~]/);function hV(e){return null!==e&&e<-2}function fV(e){return null!==e&&(e<0||32===e)}function pV(e){return-2===e||-1===e||32===e}const mV=yV(new RegExp("\\p{P}|\\p{S}","u")),gV=yV(/\s/);function yV(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function bV(e){const t=[];let n=-1,r=0,o=0;for(;++n<e.length;){const s=e.charCodeAt(n);let i="";if(37===s&&iV(e.charCodeAt(n+1))&&iV(e.charCodeAt(n+2)))o=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(i=String.fromCharCode(s));else if(s>55295&&s<57344){const t=e.charCodeAt(n+1);s<56320&&t>56319&&t<57344?(i=String.fromCharCode(s,t),o=1):i="�"}else i=String.fromCharCode(s);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+o+1,i=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function xV(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let s=0;return function(r){if(pV(r))return e.enter(n),i(r);return t(r)};function i(r){return pV(r)&&s++<o?(e.consume(r),i):(e.exit(n),t(r))}}const vV={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,(function(n){if(null===n)return void e.consume(n);return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),xV(e,t,"linePrefix")}),(function(t){return e.enter("paragraph"),r(t)}));let n;return t;function r(t){const r=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):hV(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),o)}}};const wV={tokenize:function(e){const t=this,n=[];let r,o,s,i=0;return a;function a(r){if(i<n.length){const o=n[i];return t.containerState=o[1],e.attempt(o[0].continuation,l,c)(r)}return c(r)}function l(e){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&b();const n=t.events.length;let o,s=n;for(;s--;)if("exit"===t.events[s][0]&&"chunkFlow"===t.events[s][1].type){o=t.events[s][1].end;break}y(i);let a=n;for(;a<t.events.length;)t.events[a][1].end={...o},a++;return ZH(t.events,s+1,0,t.events.slice(n)),t.events.length=a,c(e)}return a(e)}function c(o){if(i===n.length){if(!r)return h(o);if(r.currentConstruct&&r.currentConstruct.concrete)return p(o);t.interrupt=Boolean(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(kV,d,u)(o)}function d(e){return r&&b(),y(i),h(e)}function u(e){return t.parser.lazy[t.now().line]=i!==n.length,s=t.now().offset,p(e)}function h(n){return t.containerState={},e.attempt(kV,f,p)(n)}function f(e){return i++,n.push([t.currentConstruct,t.containerState]),h(e)}function p(n){return null===n?(r&&b(),y(0),void e.consume(n)):(r=r||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:o}),m(n))}function m(n){return null===n?(g(e.exit("chunkFlow"),!0),y(0),void e.consume(n)):hV(n)?(e.consume(n),g(e.exit("chunkFlow")),i=0,t.interrupt=void 0,a):(e.consume(n),m)}function g(e,n){const a=t.sliceStream(e);if(n&&a.push(null),e.previous=o,o&&(o.next=e),o=e,r.defineSkip(e.start),r.write(a),t.parser.lazy[e.start.line]){let e=r.events.length;for(;e--;)if(r.events[e][1].start.offset<s&&(!r.events[e][1].end||r.events[e][1].end.offset>s))return;const n=t.events.length;let o,a,l=n;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(o){a=t.events[l][1].end;break}o=!0}for(y(i),e=n;e<t.events.length;)t.events[e][1].end={...a},e++;ZH(t.events,l+1,0,t.events.slice(n)),t.events.length=e}}function y(r){let o=n.length;for(;o-- >r;){const r=n[o];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function b(){r.write([null]),o=void 0,r=void 0,t.containerState._closeFlow=void 0}}},kV={tokenize:function(e,t,n){return xV(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function SV(e){return null===e||fV(e)||gV(e)?1:mV(e)?2:void 0}function CV(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const s=e[o].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const EV={name:"attention",resolveAll:function(e,t){let n,r,o,s,i,a,l,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close)for(n=d;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[n][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;a=e[n][1].end.offset-e[n][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;const u={...e[n][1].end},h={...e[d][1].start};NV(u,-a),NV(h,a),s={type:a>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},i={type:a>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:h},o={type:a>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},r={type:a>1?"strong":"emphasis",start:{...s.start},end:{...i.end}},e[n][1].end={...s.start},e[d][1].start={...i.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=QH(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=QH(l,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",o,t]]),l=QH(l,CV(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),l=QH(l,[["exit",o,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,l=QH(l,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,ZH(e,n-1,d-n+3,l),d=n+l.length-c-2;break}d=-1;for(;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=SV(r);let s;return function(t){return s=t,e.enter("attentionSequence"),i(t)};function i(a){if(a===s)return e.consume(a),i;const l=e.exit("attentionSequence"),c=SV(a),d=!c||2===c&&o||n.includes(a),u=!o||2===o&&c||n.includes(r);return l._open=Boolean(42===s?d:d&&(o||!u)),l._close=Boolean(42===s?u:u&&(c||!d)),t(a)}}};function NV(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const jV={name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o};function o(t){return sV(t)?(e.consume(t),s):64===t?n(t):l(t)}function s(e){return 43===e||45===e||46===e||iV(e)?(r=1,i(e)):l(e)}function i(t){return 58===t?(e.consume(t),r=0,a):(43===t||45===t||46===t||iV(t))&&r++<32?(e.consume(t),i):(r=0,l(t))}function a(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||lV(r)?n(r):(e.consume(r),a)}function l(t){return 64===t?(e.consume(t),c):aV(t)?(e.consume(t),l):n(t)}function c(e){return iV(e)?d(e):n(e)}function d(n){return 46===n?(e.consume(n),r=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):u(n)}function u(t){if((45===t||iV(t))&&r++<63){const n=45===t?u:d;return e.consume(t),n}return n(t)}}};const _V={partial:!0,tokenize:function(e,t,n){return function(t){return pV(t)?xV(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||hV(e)?t(e):n(e)}}};const IV={continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(pV(t))return xV(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return o(t)};function o(r){return e.attempt(IV,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const r=this;return function(t){if(62===t){const n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),o}return n(t)};function o(n){return pV(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const AV={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return uV(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};const TV={name:"characterReference",tokenize:function(e,t,n){const r=this;let o,s,i=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),a};function a(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),o=31,s=iV,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,s=dV,c):(e.enter("characterReferenceValue"),o=7,s=cV,c(t))}function c(a){if(59===a&&i){const o=e.exit("characterReferenceValue");return s!==iV||KH(r.sliceSerialize(o))?(e.enter("characterReferenceMarker"),e.consume(a),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(a)}return s(a)&&i++<o?(e.consume(a),c):n(a)}}};const MV={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o};function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},DV={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const r=this,o={partial:!0,tokenize:function(e,t,n){let o=0;return i;function i(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l}function l(t){return e.enter("codeFencedFence"),pV(t)?xV(e,c,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):c(t)}function c(t){return t===s?(e.enter("codeFencedFenceSequence"),d(t)):n(t)}function d(t){return t===s?(o++,e.consume(t),d):o>=a?(e.exit("codeFencedFenceSequence"),pV(t)?xV(e,u,"whitespace")(t):u(t)):n(t)}function u(r){return null===r||hV(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}};let s,i=0,a=0;return function(t){return function(t){const n=r.events[r.events.length-1];return i=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===s?(a++,e.consume(t),l):a<3?n(t):(e.exit("codeFencedFenceSequence"),pV(t)?xV(e,c,"whitespace")(t):c(t))}function c(n){return null===n||hV(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(MV,f,b)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(n))}function d(t){return null===t||hV(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):pV(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),xV(e,u,"whitespace")(t)):96===t&&t===s?n(t):(e.consume(t),d)}function u(t){return null===t||hV(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(t))}function h(t){return null===t||hV(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===s?n(t):(e.consume(t),h)}function f(t){return e.attempt(o,b,p)(t)}function p(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),m}function m(t){return i>0&&pV(t)?xV(e,g,"linePrefix",i+1)(t):g(t)}function g(t){return null===t||hV(t)?e.check(MV,f,b)(t):(e.enter("codeFlowValue"),y(t))}function y(t){return null===t||hV(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),y)}function b(n){return e.exit("codeFenced"),t(n)}}};const OV={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),xV(e,o,"linePrefix",5)(t)};function o(e){const t=r.events[r.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?s(e):n(e)}function s(t){return null===t?a(t):hV(t)?e.attempt(RV,s,a)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||hV(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),i)}function a(n){return e.exit("codeIndented"),t(n)}}},RV={partial:!0,tokenize:function(e,t,n){const r=this;return o;function o(t){return r.parser.lazy[r.now().line]?n(t):hV(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):xV(e,s,"linePrefix",5)(t)}function s(e){const s=r.events[r.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(e):hV(e)?o(e):n(e)}}};const PV={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,o=3;if(!("lineEnding"!==e[o][1].type&&"space"!==e[o][1].type||"lineEnding"!==e[r][1].type&&"space"!==e[r][1].type))for(t=o;++t<r;)if("codeTextData"===e[t][1].type){e[o][1].type="codeTextPadding",e[r][1].type="codeTextPadding",o+=2,r-=2;break}t=o-1,r++;for(;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):t!==r&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,o,s=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),i(t)};function i(t){return 96===t?(e.consume(t),s++,i):(e.exit("codeTextSequence"),a(t))}function a(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),a):96===t?(o=e.enter("codeTextSequence"),r=0,c(t)):hV(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):(e.enter("codeTextData"),l(t))}function l(t){return null===t||32===t||96===t||hV(t)?(e.exit("codeTextData"),a(t)):(e.consume(t),l)}function c(n){return 96===n?(e.consume(n),r++,c):r===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(o.type="codeTextData",l(n))}}};class LV{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null==t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const r=t||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return n&&zV(this.left,n),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),zV(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),zV(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);zV(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);zV(this.left,t.reverse())}}}function zV(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function FV(e){const t={};let n,r,o,s,i,a,l,c=-1;const d=new LV(e);for(;++c<d.length;){for(;c in t;)c=t[c];if(n=d.get(c),c&&"chunkFlow"===n[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&(a=n[1]._tokenizer.events,o=0,o<a.length&&"lineEndingBlank"===a[o][1].type&&(o+=2),o<a.length&&"content"===a[o][1].type))for(;++o<a.length&&"content"!==a[o][1].type;)"chunkText"===a[o][1].type&&(a[o][1]._isInFirstContentOfListItem=!0,o++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,BV(d,c)),c=t[c],l=!0);else if(n[1]._container){for(o=c,r=void 0;o--&&(s=d.get(o),"lineEnding"===s[1].type||"lineEndingBlank"===s[1].type);)"enter"===s[0]&&(r&&(d.get(r)[1].type="lineEndingBlank"),s[1].type="lineEnding",r=o);r&&(n[1].end={...d.get(r)[1].start},i=d.slice(r,c),i.unshift(n),d.splice(r,c-r+1,i))}}return ZH(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function BV(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const s=[],i=n._tokenizer||r.parser[n.contentType](n.start),a=i.events,l=[],c={};let d,u,h=-1,f=n,p=0,m=0;const g=[m];for(;f;){for(;e.get(++o)[1]!==f;);s.push(o),f._tokenizer||(d=r.sliceStream(f),f.next||d.push(null),u&&i.defineSkip(f.start),f._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),f._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),u=f,f=f.next}for(f=n;++h<a.length;)"exit"===a[h][0]&&"enter"===a[h-1][0]&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(m=h+1,g.push(m),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(i.events=[],f?(f._tokenizer=void 0,f.previous=void 0):g.pop(),h=g.length;h--;){const t=a.slice(g[h],g[h+1]),n=s.pop();l.push([n,n+t.length-1]),e.splice(n,2,t)}for(l.reverse(),h=-1;++h<l.length;)c[p+l[h][0]]=p+l[h][1],p+=l[h][1]-l[h][0]-1;return c}const UV={resolve:function(e){return FV(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?o(t):hV(t)?e.check($V,s,o)(t):(e.consume(t),r)}function o(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function s(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},$V={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),xV(e,o,"linePrefix")};function o(o){if(null===o||hV(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}};function HV(e,t,n,r,o,s,i,a,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return function(t){if(60===t)return e.enter(r),e.enter(o),e.enter(s),e.consume(t),e.exit(s),u;if(null===t||32===t||41===t||lV(t))return n(t);return e.enter(r),e.enter(i),e.enter(a),e.enter("chunkString",{contentType:"string"}),p(t)};function u(n){return 62===n?(e.enter(s),e.consume(n),e.exit(s),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(a),u(t)):null===t||60===t||hV(t)?n(t):(e.consume(t),92===t?f:h)}function f(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function p(o){return d||null!==o&&41!==o&&!fV(o)?d<c&&40===o?(e.consume(o),d++,p):41===o?(e.consume(o),d--,p):null===o||32===o||40===o||lV(o)?n(o):(e.consume(o),92===o?m:p):(e.exit("chunkString"),e.exit(a),e.exit(i),e.exit(r),t(o))}function m(t){return 40===t||41===t||92===t?(e.consume(t),p):p(t)}}function VV(e,t,n,r,o,s){const i=this;let a,l=0;return function(t){return e.enter(r),e.enter(o),e.consume(t),e.exit(o),e.enter(s),c};function c(u){return l>999||null===u||91===u||93===u&&!a||94===u&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(u):93===u?(e.exit(s),e.enter(o),e.consume(u),e.exit(o),e.exit(r),t):hV(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||hV(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),a||(a=!pV(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,d):d(t)}}function WV(e,t,n,r,o,s){let i;return function(t){if(34===t||39===t||40===t)return e.enter(r),e.enter(o),e.consume(t),e.exit(o),i=40===t?41:t,a;return n(t)};function a(n){return n===i?(e.enter(o),e.consume(n),e.exit(o),e.exit(r),t):(e.enter(s),l(n))}function l(t){return t===i?(e.exit(s),a(i)):null===t?n(t):hV(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),xV(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||hV(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return t===i||92===t?(e.consume(t),c):c(t)}}function GV(e,t){let n;return function r(o){if(hV(o))return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r;if(pV(o))return xV(e,r,n?"linePrefix":"lineSuffix")(o);return t(o)}}const qV={name:"definition",tokenize:function(e,t,n){const r=this;let o;return function(t){return e.enter("definition"),function(t){return VV.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return o=oV(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),i):n(t)}function i(t){return fV(t)?GV(e,a)(t):a(t)}function a(t){return HV(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(YV,c,c)(t)}function c(t){return pV(t)?xV(e,d,"whitespace")(t):d(t)}function d(s){return null===s||hV(s)?(e.exit("definition"),r.parser.defined.push(o),t(s)):n(s)}}},YV={partial:!0,tokenize:function(e,t,n){return function(t){return fV(t)?GV(e,r)(t):n(t)};function r(t){return WV(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function o(t){return pV(t)?xV(e,s,"whitespace")(t):s(t)}function s(e){return null===e||hV(e)?t(e):n(e)}}};const XV={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return hV(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}};const JV={name:"headingAtx",resolve:function(e,t){let n,r,o=e.length-2,s=3;"whitespace"===e[s][1].type&&(s+=2);o-2>s&&"whitespace"===e[o][1].type&&(o-=2);"atxHeadingSequence"===e[o][1].type&&(s===o-1||o-4>s&&"whitespace"===e[o-2][1].type)&&(o-=s+1===o?2:4);o>s&&(n={type:"atxHeadingText",start:e[s][1].start,end:e[o][1].end},r={type:"chunkText",start:e[s][1].start,end:e[o][1].end,contentType:"text"},ZH(e,s,o-s+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let r=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),o(t)}(t)};function o(t){return 35===t&&r++<6?(e.consume(t),o):null===t||fV(t)?(e.exit("atxHeadingSequence"),s(t)):n(t)}function s(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||hV(n)?(e.exit("atxHeading"),t(n)):pV(n)?xV(e,s,"whitespace")(n):(e.enter("atxHeadingText"),a(n))}function i(t){return 35===t?(e.consume(t),i):(e.exit("atxHeadingSequence"),s(t))}function a(t){return null===t||35===t||fV(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),a)}}};const KV=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ZV=["pre","script","style","textarea"],QV={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,n){const r=this;let o,s,i,a,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(a){return 33===a?(e.consume(a),d):47===a?(e.consume(a),s=!0,f):63===a?(e.consume(a),o=3,r.interrupt?t:O):sV(a)?(e.consume(a),i=String.fromCharCode(a),p):n(a)}function d(s){return 45===s?(e.consume(s),o=2,u):91===s?(e.consume(s),o=5,a=0,h):sV(s)?(e.consume(s),o=4,r.interrupt?t:O):n(s)}function u(o){return 45===o?(e.consume(o),r.interrupt?t:O):n(o)}function h(o){const s="CDATA[";return o===s.charCodeAt(a++)?(e.consume(o),6===a?r.interrupt?t:N:h):n(o)}function f(t){return sV(t)?(e.consume(t),i=String.fromCharCode(t),p):n(t)}function p(a){if(null===a||47===a||62===a||fV(a)){const l=47===a,c=i.toLowerCase();return l||s||!ZV.includes(c)?KV.includes(i.toLowerCase())?(o=6,l?(e.consume(a),m):r.interrupt?t(a):N(a)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(a):s?g(a):y(a)):(o=1,r.interrupt?t(a):N(a))}return 45===a||iV(a)?(e.consume(a),i+=String.fromCharCode(a),p):n(a)}function m(o){return 62===o?(e.consume(o),r.interrupt?t:N):n(o)}function g(t){return pV(t)?(e.consume(t),g):C(t)}function y(t){return 47===t?(e.consume(t),C):58===t||95===t||sV(t)?(e.consume(t),b):pV(t)?(e.consume(t),y):C(t)}function b(t){return 45===t||46===t||58===t||95===t||iV(t)?(e.consume(t),b):x(t)}function x(t){return 61===t?(e.consume(t),v):pV(t)?(e.consume(t),x):y(t)}function v(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,w):pV(t)?(e.consume(t),v):k(t)}function w(t){return t===l?(e.consume(t),l=null,S):null===t||hV(t)?n(t):(e.consume(t),w)}function k(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||fV(t)?x(t):(e.consume(t),k)}function S(e){return 47===e||62===e||pV(e)?y(e):n(e)}function C(t){return 62===t?(e.consume(t),E):n(t)}function E(t){return null===t||hV(t)?N(t):pV(t)?(e.consume(t),E):n(t)}function N(t){return 45===t&&2===o?(e.consume(t),A):60===t&&1===o?(e.consume(t),T):62===t&&4===o?(e.consume(t),R):63===t&&3===o?(e.consume(t),O):93===t&&5===o?(e.consume(t),D):!hV(t)||6!==o&&7!==o?null===t||hV(t)?(e.exit("htmlFlowData"),j(t)):(e.consume(t),N):(e.exit("htmlFlowData"),e.check(eW,P,j)(t))}function j(t){return e.check(tW,_,P)(t)}function _(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),I}function I(t){return null===t||hV(t)?j(t):(e.enter("htmlFlowData"),N(t))}function A(t){return 45===t?(e.consume(t),O):N(t)}function T(t){return 47===t?(e.consume(t),i="",M):N(t)}function M(t){if(62===t){const n=i.toLowerCase();return ZV.includes(n)?(e.consume(t),R):N(t)}return sV(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),M):N(t)}function D(t){return 93===t?(e.consume(t),O):N(t)}function O(t){return 62===t?(e.consume(t),R):45===t&&2===o?(e.consume(t),O):N(t)}function R(t){return null===t||hV(t)?(e.exit("htmlFlowData"),P(t)):(e.consume(t),R)}function P(n){return e.exit("htmlFlow"),t(n)}}},eW={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(_V,t,n)}}},tW={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(hV(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o;return n(t)};function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}};const nW={name:"htmlText",tokenize:function(e,t,n){const r=this;let o,s,i;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),a};function a(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),v):63===t?(e.consume(t),b):sV(t)?(e.consume(t),S):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,f):sV(t)?(e.consume(t),y):n(t)}function c(t){return 45===t?(e.consume(t),h):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):hV(t)?(i=d,M(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),h):d(t)}function h(e){return 62===e?T(e):45===e?u(e):d(e)}function f(t){const r="CDATA[";return t===r.charCodeAt(s++)?(e.consume(t),6===s?p:f):n(t)}function p(t){return null===t?n(t):93===t?(e.consume(t),m):hV(t)?(i=p,M(t)):(e.consume(t),p)}function m(t){return 93===t?(e.consume(t),g):p(t)}function g(t){return 62===t?T(t):93===t?(e.consume(t),g):p(t)}function y(t){return null===t||62===t?T(t):hV(t)?(i=y,M(t)):(e.consume(t),y)}function b(t){return null===t?n(t):63===t?(e.consume(t),x):hV(t)?(i=b,M(t)):(e.consume(t),b)}function x(e){return 62===e?T(e):b(e)}function v(t){return sV(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||iV(t)?(e.consume(t),w):k(t)}function k(t){return hV(t)?(i=k,M(t)):pV(t)?(e.consume(t),k):T(t)}function S(t){return 45===t||iV(t)?(e.consume(t),S):47===t||62===t||fV(t)?C(t):n(t)}function C(t){return 47===t?(e.consume(t),T):58===t||95===t||sV(t)?(e.consume(t),E):hV(t)?(i=C,M(t)):pV(t)?(e.consume(t),C):T(t)}function E(t){return 45===t||46===t||58===t||95===t||iV(t)?(e.consume(t),E):N(t)}function N(t){return 61===t?(e.consume(t),j):hV(t)?(i=N,M(t)):pV(t)?(e.consume(t),N):C(t)}function j(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),o=t,_):hV(t)?(i=j,M(t)):pV(t)?(e.consume(t),j):(e.consume(t),I)}function _(t){return t===o?(e.consume(t),o=void 0,A):null===t?n(t):hV(t)?(i=_,M(t)):(e.consume(t),_)}function I(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||fV(t)?C(t):(e.consume(t),I)}function A(e){return 47===e||62===e||fV(e)?C(e):n(e)}function T(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function M(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),D}function D(t){return pV(t)?xV(e,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):O(t)}function O(t){return e.enter("htmlTextData"),i(t)}}};const rW={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){const e="labelImage"===r.type?4:2;r.type="data",t+=e}}e.length!==n.length&&ZH(e,0,e.length,n);return e},resolveTo:function(e,t){let n,r,o,s,i=e.length,a=0;for(;i--;)if(n=e[i][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[i][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(o){if("enter"===e[i][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=i,"labelLink"!==n.type)){a=2;break}}else"labelEnd"===n.type&&(o=i);const l={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[r+a+2][1].end},end:{...e[o-2][1].start}};return s=[["enter",l,t],["enter",c,t]],s=QH(s,e.slice(r+1,r+a+3)),s=QH(s,[["enter",d,t]]),s=QH(s,CV(t.parser.constructs.insideSpan.null,e.slice(r+a+4,o-3),t)),s=QH(s,[["exit",d,t],e[o-2],e[o-1],["exit",c,t]]),s=QH(s,e.slice(o+1)),s=QH(s,[["exit",l,t]]),ZH(e,r,e.length,s),e},tokenize:function(e,t,n){const r=this;let o,s,i=r.events.length;for(;i--;)if(("labelImage"===r.events[i][1].type||"labelLink"===r.events[i][1].type)&&!r.events[i][1]._balanced){o=r.events[i][1];break}return function(t){if(!o)return n(t);if(o._inactive)return d(t);return s=r.parser.defined.includes(oV(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),a};function a(t){return 40===t?e.attempt(oW,c,s?c:d)(t):91===t?e.attempt(sW,c,s?l:d)(t):s?c(t):d(t)}function l(t){return e.attempt(iW,c,d)(t)}function c(e){return t(e)}function d(e){return o._balanced=!0,n(e)}}},oW={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return fV(t)?GV(e,o)(t):o(t)}function o(t){return 41===t?c(t):HV(e,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return fV(t)?GV(e,a)(t):c(t)}function i(e){return n(e)}function a(t){return 34===t||39===t||40===t?WV(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return fV(t)?GV(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},sW={tokenize:function(e,t,n){const r=this;return function(t){return VV.call(r,e,o,s,"reference","referenceMarker","referenceString")(t)};function o(e){return r.parser.defined.includes(oV(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function s(e){return n(e)}}},iW={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}};const aW={name:"labelStartImage",resolveAll:rW.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),o};function o(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),s):n(t)}function s(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const lW={name:"labelStartLink",resolveAll:rW.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),o};function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const cW={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),xV(e,t,"linePrefix")}}};const dW={name:"thematicBreak",tokenize:function(e,t,n){let r,o=0;return function(t){return e.enter("thematicBreak"),function(e){return r=e,s(e)}(t)};function s(s){return s===r?(e.enter("thematicBreakSequence"),i(s)):o>=3&&(null===s||hV(s))?(e.exit("thematicBreak"),t(s)):n(s)}function i(t){return t===r?(e.consume(t),o++,i):(e.exit("thematicBreakSequence"),pV(t)?xV(e,s,"whitespace")(t):s(t))}}};const uW={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(_V,(function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,xV(e,t,"listItemIndent",r.containerState.size+1)(n)}),(function(n){if(r.containerState.furtherBlankLines||!pV(n))return r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n);return r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(fW,t,o)(n)}));function o(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,xV(e,e.attempt(uW,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const r=this,o=r.events[r.events.length-1];let s=o&&"linePrefix"===o[1].type?o[2].sliceSerialize(o[1],!0).length:0,i=0;return function(t){const o=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===o?!r.containerState.marker||t===r.containerState.marker:cV(t)){if(r.containerState.type||(r.containerState.type=o,e.enter(o,{_container:!0})),"listUnordered"===o)return e.enter("listItemPrefix"),42===t||45===t?e.check(dW,n,l)(t):l(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),a(t)}return n(t)};function a(t){return cV(t)&&++i<10?(e.consume(t),a):(!r.interrupt||i<2)&&(r.containerState.marker?t===r.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),l(t)):n(t)}function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(_V,r.interrupt?n:c,e.attempt(hW,u,d))}function c(e){return r.containerState.initialBlankLine=!0,s++,u(e)}function d(t){return pV(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},hW={partial:!0,tokenize:function(e,t,n){const r=this;return xV(e,(function(e){const o=r.events[r.events.length-1];return!pV(e)&&o&&"listItemPrefixWhitespace"===o[1].type?t(e):n(e)}),"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},fW={partial:!0,tokenize:function(e,t,n){const r=this;return xV(e,(function(e){const o=r.events[r.events.length-1];return o&&"listItemIndent"===o[1].type&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(e):n(e)}),"listItemIndent",r.containerState.size+1)}};const pW={name:"setextUnderline",resolveTo:function(e,t){let n,r,o,s=e.length;for(;s--;)if("enter"===e[s][0]){if("content"===e[s][1].type){n=s;break}"paragraph"===e[s][1].type&&(r=s)}else"content"===e[s][1].type&&e.splice(s,1),o||"definition"!==e[s][1].type||(o=s);const i={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};e[r][1].type="setextHeadingText",o?(e.splice(r,0,["enter",i,t]),e.splice(o+1,0,["exit",e[n][1],t]),e[n][1].end={...e[o][1].end}):e[n][1]=i;return e.push(["exit",i,t]),e},tokenize:function(e,t,n){const r=this;let o;return function(t){let i,a=r.events.length;for(;a--;)if("lineEnding"!==r.events[a][1].type&&"linePrefix"!==r.events[a][1].type&&"content"!==r.events[a][1].type){i="paragraph"===r.events[a][1].type;break}if(!r.parser.lazy[r.now().line]&&(r.interrupt||i))return e.enter("setextHeadingLine"),o=t,function(t){return e.enter("setextHeadingLineSequence"),s(t)}(t);return n(t)};function s(t){return t===o?(e.consume(t),s):(e.exit("setextHeadingLineSequence"),pV(t)?xV(e,i,"lineSuffix")(t):i(t))}function i(r){return null===r||hV(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};const mW={tokenize:function(e){const t=this,n=e.attempt(_V,(function(r){if(null===r)return void e.consume(r);return e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}),e.attempt(this.parser.constructs.flowInitial,r,xV(e,e.attempt(this.parser.constructs.flow,r,e.attempt(UV,r)),"linePrefix")));return n;function r(r){if(null!==r)return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(r)}}};const gW={resolveAll:vW()},yW=xW("string"),bW=xW("text");function xW(e){return{resolveAll:vW("text"===e?wW:void 0),tokenize:function(t){const n=this,r=this.parser.constructs[e],o=t.attempt(r,s,i);return s;function s(e){return l(e)?o(e):i(e)}function i(e){if(null!==e)return t.enter("data"),t.consume(e),a;t.consume(e)}function a(e){return l(e)?(t.exit("data"),o(e)):(t.consume(e),a)}function l(e){if(null===e)return!0;const t=r[e];let o=-1;if(t)for(;++o<t.length;){const e=t[o];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function vW(e){return function(t,n){let r,o=-1;for(;++o<=t.length;)void 0===r?t[o]&&"data"===t[o][1].type&&(r=o,o++):t[o]&&"data"===t[o][1].type||(o!==r+2&&(t[r][1].end=t[o-1][1].end,t.splice(r+2,o-r-2),o=r+2),r=void 0);return e?e(t,n):t}}function wW(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const r=e[n-1][1],o=t.sliceStream(r);let s,i=o.length,a=-1,l=0;for(;i--;){const e=o[i];if("string"==typeof e){for(a=e.length;32===e.charCodeAt(a-1);)l++,a--;if(a)break;a=-1}else if(-2===e)s=!0,l++;else if(-1!==e){i++;break}}if(l){const o={type:n===e.length||s||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...o.start},r.start.offset===r.end.offset?Object.assign(r,o):(e.splice(n,0,["enter",o,t],["exit",o,t]),n+=2)}n++}return e}const kW={42:uW,43:uW,45:uW,48:uW,49:uW,50:uW,51:uW,52:uW,53:uW,54:uW,55:uW,56:uW,57:uW,62:IV},SW={91:qV},CW={[-2]:OV,[-1]:OV,32:OV},EW={35:JV,42:dW,45:[pW,dW],60:QV,61:pW,95:dW,96:DV,126:DV},NW={38:TV,92:AV},jW={[-5]:cW,[-4]:cW,[-3]:cW,33:aW,38:TV,42:EV,60:[jV,nW],91:lW,92:[XV,AV],93:rW,95:EV,96:PV},_W={null:[EV,gW]},IW=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:SW,disable:{null:[]},document:kW,flow:EW,flowInitial:CW,insideSpan:_W,string:NW,text:jW},Symbol.toStringTag,{value:"Module"}));function AW(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},s=[];let i=[],a=[];const l={attempt:g((function(e,t){y(e,t.from)})),check:g(m),consume:function(e){hV(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,b()):-1!==e&&(r.column++,r.offset++);r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===i[r._index].length&&(r._bufferIndex=-1,r._index++));c.previous=e},enter:function(e,t){const n=t||{};return n.type=e,n.start=h(),c.events.push(["enter",n,c]),a.push(n),n},exit:function(e){const t=a.pop();return t.end=h(),c.events.push(["exit",t,c]),t},interrupt:g(m,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){o[e.line]=e.column,b()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const r=[];let o;for(;++n<e.length;){const s=e[n];let i;if("string"==typeof s)i=s;else switch(s){case-5:i="\r";break;case-4:i="\n";break;case-3:i="\r\n";break;case-2:i=t?" ":"\t";break;case-1:if(!t&&o)continue;i=" ";break;default:i=String.fromCharCode(s)}o=-2===s,r.push(i)}return r.join("")}(u(e),t)},sliceStream:u,write:function(e){if(i=QH(i,e),f(),null!==i[i.length-1])return[];return y(t,0),c.events=CV(s,c.events,c),c.events}};let d=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function u(e){return function(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,s=t.end._bufferIndex;let i;if(n===o)i=[e[n].slice(r,s)];else{if(i=e.slice(n,o),r>-1){const e=i[0];"string"==typeof e?i[0]=e.slice(r):i.shift()}s>0&&i.push(e[o].slice(0,s))}return i}(i,e)}function h(){const{_bufferIndex:e,_index:t,line:n,column:o,offset:s}=r;return{_bufferIndex:e,_index:t,line:n,column:o,offset:s}}function f(){let e;for(;r._index<i.length;){const t=i[r._index];if("string"==typeof t)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)p(t.charCodeAt(r._bufferIndex));else p(t)}}function p(e){d=d(e)}function m(e,t){t.restore()}function g(e,t){return function(n,o,s){let i,d,u,f;return Array.isArray(n)?p(n):"tokenize"in n?p([n]):function(e){return t;function t(t){const n=null!==t&&e[t],r=null!==t&&e.null;return p([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}(n);function p(e){return i=e,d=0,0===e.length?s:m(e[d])}function m(e){return function(n){f=function(){const e=h(),t=c.previous,n=c.currentConstruct,o=c.events.length,s=Array.from(a);return{from:o,restore:i};function i(){r=e,c.previous=t,c.currentConstruct=n,c.events.length=o,a=s,b()}}(),u=e,e.partial||(c.currentConstruct=e);if(e.name&&c.parser.constructs.disable.null.includes(e.name))return y();return e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,g,y)(n)}}function g(t){return e(u,f),o}function y(e){return f.restore(),++d<i.length?m(i[d]):s}}}function y(e,t){e.resolveAll&&!s.includes(e)&&s.push(e),e.resolve&&ZH(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function b(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function TW(e){const t={constructs:function(e){const t={};let n=-1;for(;++n<e.length;)tV(t,e[n]);return t}([IW,...(e||{}).extensions||[]]),content:n(vV),defined:[],document:n(wV),flow:n(mW),lazy:{},string:n(yW),text:n(bW)};return t;function n(e){return function(n){return AW(t,e,n)}}}const MW=/[\0\t\n\r]/g;const DW=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function OW(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return rV(n.slice(t?2:1),t?16:10)}return KH(n)||e}const RW={}.hasOwnProperty;function PW(e,t,n){return"string"!=typeof t&&(n=t,t=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(te),autolinkProtocol:E,autolinkEmail:E,atxHeading:s(K),blockQuote:s(G),characterEscape:E,characterReference:E,codeFenced:s(q),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:s(q,i),codeText:s(Y,i),codeTextData:E,data:E,codeFlowValue:E,definition:s(X),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:s(J),hardBreakEscape:s(Z),hardBreakTrailing:s(Z),htmlFlow:s(Q,i),htmlFlowData:E,htmlText:s(Q,i),htmlTextData:E,image:s(ee),label:i,link:s(te),listItem:s(re),listItemValue:h,listOrdered:s(ne,u),listUnordered:s(ne),paragraph:s(oe),reference:F,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:s(K),strong:s(se),thematicBreak:s(ae)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:W,autolinkProtocol:V,blockQuote:l(),characterEscapeValue:N,characterReferenceMarkerHexadecimal:U,characterReferenceMarkerNumeric:U,characterReferenceValue:$,characterReference:H,codeFenced:l(g),codeFencedFence:m,codeFencedFenceInfo:f,codeFencedFenceMeta:p,codeFlowValue:N,codeIndented:l(y),codeText:l(T),codeTextData:N,data:N,definition:l(),definitionDestinationString:v,definitionLabelString:b,definitionTitleString:x,emphasis:l(),hardBreakEscape:l(_),hardBreakTrailing:l(_),htmlFlow:l(I),htmlFlowData:N,htmlText:l(A),htmlTextData:N,image:l(D),label:R,labelText:O,lineEnding:j,link:l(M),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:B,resourceDestinationString:P,resourceTitleString:L,resource:z,setextHeading:l(C),setextHeadingLineSequence:S,setextHeadingText:k,strong:l(),thematicBreak:l()}};zW(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(e){let r={type:"root",children:[]};const s={stack:[r],tokenStack:[],config:t,enter:a,exit:c,buffer:i,resume:d,data:n},l=[];let u=-1;for(;++u<e.length;)if("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)if("enter"===e[u][0])l.push(u);else{u=o(e,l.pop(),u)}for(u=-1;++u<e.length;){const n=t[e[u][0]];RW.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},s),e[u][1])}if(s.tokenStack.length>0){const e=s.tokenStack[s.tokenStack.length-1];(e[1]||BW).call(s,void 0,e[0])}for(r.position={start:LW(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:LW(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)r=t.transforms[u](r)||r;return r}function o(e,t,n){let r,o,s,i,a=t-1,l=-1,c=!1;for(;++a<=n;){const t=e[a];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,i=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||i||l||s||(s=a),i=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:i=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let i=a;for(o=void 0;i--;){const t=e[i];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;o&&(e[o][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",o=i}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}s&&(!o||s<o)&&(r._spread=!0),r.end=Object.assign({},o?e[o][1].start:t[1].end),e.splice(o||a,0,["exit",r,t[2]]),a++,n++}if("listItemPrefix"===t[1].type){const o={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=o,e.splice(a,0,["enter",o,t[2]]),a++,n++,s=void 0,i=!0}}}return e[t][1]._spread=c,n}function s(e,t){return n;function n(n){a.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function a(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:LW(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),c.call(this,t)}}function c(e,t){const n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw new Error("Cannot close `"+e.type+"` ("+SH({start:e.start,end:e.end})+"): it’s not open");if(r[0].type!==e.type)if(t)t.call(this,e,r[0]);else{(r[1]||BW).call(this,e,r[0])}n.position.end=LW(e.end)}function d(){return function(e){return YH(e,"boolean"!=typeof qH.includeImageAlt||qH.includeImageAlt,"boolean"!=typeof qH.includeHtml||qH.includeHtml)}(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function h(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function f(){const e=this.resume();this.stack[this.stack.length-1].lang=e}function p(){const e=this.resume();this.stack[this.stack.length-1].meta=e}function m(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function b(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=oV(this.sliceSerialize(e)).toLowerCase()}function x(){const e=this.resume();this.stack[this.stack.length-1].title=e}function v(){const e=this.resume();this.stack[this.stack.length-1].url=e}function w(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function S(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function C(){this.data.setextHeadingSlurpLineEnding=void 0}function E(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n=ie(),n.position={start:LW(e.start),end:void 0},t.push(n)),this.stack.push(n)}function N(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=LW(e.end)}function j(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=LW(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(E.call(this,e),N.call(this,e))}function _(){this.data.atHardBreak=!0}function I(){const e=this.resume();this.stack[this.stack.length-1].value=e}function A(){const e=this.resume();this.stack[this.stack.length-1].value=e}function T(){const e=this.resume();this.stack[this.stack.length-1].value=e}function M(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function D(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function O(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(DW,OW)}(t),n.identifier=oV(t).toLowerCase()}function R(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function P(){const e=this.resume();this.stack[this.stack.length-1].url=e}function L(){const e=this.resume();this.stack[this.stack.length-1].title=e}function z(){this.data.inReference=void 0}function F(){this.data.referenceType="collapsed"}function B(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=oV(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function U(e){this.data.characterReferenceType=e.type}function $(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let r;if(n)r=rV(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{r=KH(t)}this.stack[this.stack.length-1].value+=r}function H(e){this.stack.pop().position.end=LW(e.end)}function V(e){N.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function W(e){N.call(this,e);this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function G(){return{type:"blockquote",children:[]}}function q(){return{type:"code",lang:null,meta:null,value:""}}function Y(){return{type:"inlineCode",value:""}}function X(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function J(){return{type:"emphasis",children:[]}}function K(){return{type:"heading",depth:0,children:[]}}function Z(){return{type:"break"}}function Q(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function ne(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function re(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function oe(){return{type:"paragraph",children:[]}}function se(){return{type:"strong",children:[]}}function ie(){return{type:"text",value:""}}function ae(){return{type:"thematicBreak"}}}(n)(function(e){for(;!FV(e););return e}(TW(n).document().write(function(){let e,t=1,n="",r=!0;return function(o,s,i){const a=[];let l,c,d,u,h;for(o=n+("string"==typeof o?o.toString():new TextDecoder(s||void 0).decode(o)),d=0,n="",r&&(65279===o.charCodeAt(0)&&d++,r=void 0);d<o.length;){if(MW.lastIndex=d,l=MW.exec(o),u=l&&void 0!==l.index?l.index:o.length,h=o.charCodeAt(u),!l){n=o.slice(d);break}if(10===h&&d===u&&e)a.push(-3),e=void 0;else switch(e&&(a.push(-5),e=void 0),d<u&&(a.push(o.slice(d,u)),t+=u-d),h){case 0:a.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),a.push(-2);t++<c;)a.push(-1);break;case 10:a.push(-4),t=1;break;default:e=!0,t=1}d=u+1}return i&&(e&&a.push(-5),n&&a.push(n),a.push(null)),a}}()(e,t,!0))))}function LW(e){return{line:e.line,column:e.column,offset:e.offset}}function zW(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?zW(e,r):FW(e,r)}}function FW(e,t){let n;for(n in t)if(RW.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function BW(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+SH({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+SH({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+SH({start:t.start,end:t.end})+") is still open")}function UW(e){const t=this;t.parser=function(n){return PW(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function $W(e,t){const n=t.referenceType;let r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];const o=e.all(t),s=o[0];s&&"text"===s.type?s.value="["+s.value:o.unshift({type:"text",value:"["});const i=o[o.length-1];return i&&"text"===i.type?i.value+=r:o.push({type:"text",value:r}),o}function HW(e){const t=e.spread;return null==t?e.children.length>1:t}function VW(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),o=0;const s=[];for(;r;)s.push(WW(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return s.push(WW(t.slice(o),o>0,!1)),s.join("")}function WW(e,t,n){let r=0,o=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(o-1);for(;9===t||32===t;)o--,t=e.codePointAt(o-1)}return o>r?e.slice(r,o):""}const GW={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",r={};t.lang&&(r.className=["language-"+t.lang]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=bV(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let i,a=e.footnoteCounts.get(r);void 0===a?(a=0,e.footnoteOrder.push(r),i=e.footnoteOrder.length):i=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+o,id:n+"fnref-"+o+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return $W(e,t);const o={src:bV(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(o.title=r.title);const s={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,s),e.applyData(t,s)},image:function(e,t){const n={src:bV(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return $W(e,t);const o={href:bV(r.url||"")};null!==r.title&&void 0!==r.title&&(o.title=r.title);const s={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)},link:function(e,t){const n={href:bV(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){const r=e.all(t),o=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=HW(n[r])}return t}(n):HW(t),s={},i=[];if("boolean"==typeof t.checked){const e=r[0];let n;e&&"element"===e.type&&"p"===e.tagName?n=e:(n={type:"element",tagName:"p",properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const e=r[a];(o||0!==a||"element"!==e.type||"p"!==e.tagName)&&i.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||o?i.push(e):i.push(...e.children)}const l=r[r.length-1];l&&(o||"element"!==l.type||"p"!==l.tagName)&&i.push({type:"text",value:"\n"});const c={type:"element",tagName:"li",properties:s,children:i};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){const n={},r=e.all(t);let o=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++o<r.length;){const e=r[o];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)},paragraph:function(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){const n=e.all(t),r=n.shift(),o=[];if(r){const n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),o.push(n)}if(n.length>0){const r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},s=wH(t.children[1]),i=vH(t.children[t.children.length-1]);s&&i&&(r.position={start:s,end:i}),o.push(r)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,s),e.applyData(t,s)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const r=n?n.children:void 0,o=0===(r?r.indexOf(t):1)?"th":"td",s=n&&"table"===n.type?n.align:void 0,i=s?s.length:t.children.length;let a=-1;const l=[];for(;++a<i;){const n=t.children[a],r={},i=s?s[a]:void 0;i&&(r.align=i);let c={type:"element",tagName:o,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}const c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){const n={type:"text",value:VW(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:qW,yaml:qW,definition:qW,footnoteDefinition:qW};function qW(){}const YW="object"==typeof self?self:globalThis,XW=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),r=o=>{if(e.has(o))return e.get(o);const[s,i]=t[o];switch(s){case 0:case-1:return n(i,o);case 1:{const e=n([],o);for(const t of i)e.push(r(t));return e}case 2:{const e=n({},o);for(const[t,n]of i)e[r(t)]=r(n);return e}case 3:return n(new Date(i),o);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),o)}case 5:{const e=n(new Map,o);for(const[t,n]of i)e.set(r(t),r(n));return e}case 6:{const e=n(new Set,o);for(const t of i)e.add(r(t));return e}case 7:{const{name:e,message:t}=i;return n(new YW[e](t),o)}case 8:return n(BigInt(i),o);case"BigInt":return n(Object(BigInt(i)),o)}return n(new YW[s](i),o)};return r})(new Map,e)(0),JW="",{toString:KW}={},{keys:ZW}=Object,QW=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=KW.call(e).slice(8,-1);switch(n){case"Array":return[1,JW];case"Object":return[2,JW];case"Date":return[3,JW];case"RegExp":return[4,JW];case"Map":return[5,JW];case"Set":return[6,JW]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},eG=([e,t])=>0===e&&("function"===t||"symbol"===t),tG=(e,{json:t,lossy:n}={})=>{const r=[];return((e,t,n,r)=>{const o=(e,t)=>{const o=r.push(e)-1;return n.set(t,o),o},s=r=>{if(n.has(r))return n.get(r);let[i,a]=QW(r);switch(i){case 0:{let t=r;switch(a){case"bigint":i=8,t=r.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+a);t=null;break;case"undefined":return o([-1],r)}return o([i,t],r)}case 1:{if(a)return o([a,[...r]],r);const e=[],t=o([i,e],r);for(const n of r)e.push(s(n));return t}case 2:{if(a)switch(a){case"BigInt":return o([a,r.toString()],r);case"Boolean":case"Number":case"String":return o([a,r.valueOf()],r)}if(t&&"toJSON"in r)return s(r.toJSON());const n=[],l=o([i,n],r);for(const t of ZW(r))!e&&eG(QW(r[t]))||n.push([s(t),s(r[t])]);return l}case 3:return o([i,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return o([i,{source:e,flags:t}],r)}case 5:{const t=[],n=o([i,t],r);for(const[o,i]of r)(e||!eG(QW(o))&&!eG(QW(i)))&&t.push([s(o),s(i)]);return n}case 6:{const t=[],n=o([i,t],r);for(const o of r)!e&&eG(QW(o))||t.push(s(o));return n}}const{message:l}=r;return o([i,{name:a,message:l}],r)};return s})(!(t||n),!!t,new Map,r)(e),r},nG="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?XW(tG(e,t)):structuredClone(e):(e,t)=>XW(tG(e,t));function rG(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function oG(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const sG=function(e){if(null==e)return aG;if("function"==typeof e)return iG(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=sG(e[n]);return iG(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}(e):function(e){const t=e;return iG(n);function n(n){const r=n;let o;for(o in e)if(r[o]!==t[o])return!1;return!0}}(e);if("string"==typeof e)return function(e){return iG(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function iG(e){return function(t,n,r){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function aG(){return!0}const lG=[],cG=!0,dG=!1;function uG(e,t,n,r){let o;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):o=t;const s=sG(o),i=r?-1:1;!function e(o,a,l){const c=o&&"object"==typeof o?o:{};if("string"==typeof c.type){const e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+o.type+(e?"<"+e+">":"")+")"})}return d;function d(){let c,d,u,h=lG;if((!t||s(o,a,l[l.length-1]||void 0))&&(h=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[cG,e];return null==e?lG:[e]}(n(o,l)),h[0]===dG))return h;if("children"in o&&o.children){const t=o;if(t.children&&"skip"!==h[0])for(d=(r?t.children.length:-1)+i,u=l.concat(t);d>-1&&d<t.children.length;){const n=t.children[d];if(c=e(n,d,u)(),c[0]===dG)return c;d="number"==typeof c[1]?c[1]:d+i}}return h}}(e,void 0,[])()}function hG(e,t,n,r){let o,s,i;"function"==typeof t?(s=void 0,i=t,o=n):(s=t,i=n,o=r),uG(e,s,(function(e,t){const n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return i(e,r,n)}),o)}const fG={}.hasOwnProperty,pG={};function mG(e,t){e.position&&(t.position=function(e){const t=wH(e),n=vH(e);if(t&&n)return{start:t,end:n}}(e))}function gG(e,t){let n=t;if(e&&e.data){const t=e.data.hName,r=e.data.hChildren,o=e.data.hProperties;if("string"==typeof t)if("element"===n.type)n.tagName=t;else{n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}}"element"===n.type&&o&&Object.assign(n.properties,nG(o)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function yG(e,t){const n=t.data||{},r=!("value"in t)||fG.call(n,"hProperties")||fG.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,r),e.applyData(t,r)}function bG(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function xG(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function vG(e,t){const n=function(e,t){const n=t||pG,r=new Map,o=new Map,s=new Map,i={...GW,...n.handlers},a={all:function(e){const t=[];if("children"in e){const n=e.children;let r=-1;for(;++r<n.length;){const o=a.one(n[r],e);if(o){if(r&&"break"===n[r-1].type&&(Array.isArray(o)||"text"!==o.type||(o.value=xG(o.value)),!Array.isArray(o)&&"element"===o.type)){const e=o.children[0];e&&"text"===e.type&&(e.value=xG(e.value))}Array.isArray(o)?t.push(...o):t.push(o)}}}return t},applyData:gG,definitionById:r,footnoteById:o,footnoteCounts:s,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,r=a.handlers[n];if(fG.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if("children"in e){const{children:t,...n}=e,r=nG(n);return r.children=a.all(e),r}return nG(e)}return(a.options.unknownHandler||yG)(a,e,t)},options:n,patch:mG,wrap:bG};return hG(e,(function(e){if("definition"===e.type||"footnoteDefinition"===e.type){const t="definition"===e.type?r:o,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}})),a}(e,t),r=n.one(e,void 0),o=function(e){const t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||rG,r=e.options.footnoteBackLabel||oG,o=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",i=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const o=e.footnoteById.get(e.footnoteOrder[l]);if(!o)continue;const s=e.all(o),i=String(o.identifier).toUpperCase(),c=bV(i.toLowerCase());let d=0;const u=[],h=e.footnoteCounts.get(i);for(;void 0!==h&&++d<=h;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const f=s[s.length-1];if(f&&"element"===f.type&&"p"===f.tagName){const e=f.children[f.children.length-1];e&&"text"===e.type?e.value+=" ":f.children.push({type:"text",value:" "}),f.children.push(...u)}else s.push(...u);const p={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(s,!0)};e.patch(o,p),a.push(p)}if(0!==a.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...nG(i),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:"\n"}]}}(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&s.children.push({type:"text",value:"\n"},o),s}function wG(e,t){return e&&"run"in e?async function(n,r){const o=vG(n,{file:r,...t});await e.run(o,r)}:function(n,r){return vG(n,{file:r,...e||t})}}function kG(e){if(e)throw e}var SG=Object.prototype.hasOwnProperty,CG=Object.prototype.toString,EG=Object.defineProperty,NG=Object.getOwnPropertyDescriptor,jG=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===CG.call(e)},_G=function(e){if(!e||"[object Object]"!==CG.call(e))return!1;var t,n=SG.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&SG.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!r)return!1;for(t in e);return void 0===t||SG.call(e,t)},IG=function(e,t){EG&&"__proto__"===t.name?EG(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},AG=function(e,t){if("__proto__"===t){if(!SG.call(e,t))return;if(NG)return NG(e,t).value}return e[t]},TG=function e(){var t,n,r,o,s,i,a=arguments[0],l=1,c=arguments.length,d=!1;for("boolean"==typeof a&&(d=a,a=arguments[1]||{},l=2),(null==a||"object"!=typeof a&&"function"!=typeof a)&&(a={});l<c;++l)if(null!=(t=arguments[l]))for(n in t)r=AG(a,n),a!==(o=AG(t,n))&&(d&&o&&(_G(o)||(s=jG(o)))?(s?(s=!1,i=r&&jG(r)?r:[]):i=r&&_G(r)?r:{},IG(a,{name:n,newValue:e(d,i,o)})):void 0!==o&&IG(a,{name:n,newValue:o}));return a};const MG=ol(TG);function DG(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}function OG(){const e=[],t={run:function(...t){let n=-1;const r=t.pop();if("function"!=typeof r)throw new TypeError("Expected function as last argument, not "+r);!function o(s,...i){const a=e[++n];let l=-1;if(s)r(s);else{for(;++l<t.length;)null!==i[l]&&void 0!==i[l]||(i[l]=t[l]);t=i,a?function(e,t){let n;return r;function r(...t){const r=e.length>t.length;let a;r&&t.push(o);try{a=e.apply(this,t)}catch(s){if(r&&n)throw s;return o(s)}r||(a&&a.then&&"function"==typeof a.then?a.then(i,o):a instanceof Error?o(a):i(a))}function o(e,...r){n||(n=!0,t(e,...r))}function i(e){o(null,e)}}(a,o)(...i):r(null,...i)}}(null,...t)},use:function(n){if("function"!=typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}const RG={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');PG(e);let n,r=0,o=-1,s=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else o<0&&(n=!0,o=s+1);return o<0?"":e.slice(r,o)}if(t===e)return"";let i=-1,a=t.length-1;for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else i<0&&(n=!0,i=s+1),a>-1&&(e.codePointAt(s)===t.codePointAt(a--)?a<0&&(o=s):(a=-1,o=i));r===o?o=i:o<0&&(o=e.length);return e.slice(r,o)},dirname:function(e){if(PG(e),0===e.length)return".";let t,n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){PG(e);let t,n=e.length,r=-1,o=0,s=-1,i=0;for(;n--;){const a=e.codePointAt(n);if(47!==a)r<0&&(t=!0,r=n+1),46===a?s<0?s=n:1!==i&&(i=1):s>-1&&(i=-1);else if(t){o=n+1;break}}if(s<0||r<0||0===i||1===i&&s===r-1&&s===o+1)return"";return e.slice(s,r)},join:function(...e){let t,n=-1;for(;++n<e.length;)PG(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){PG(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,r,o="",s=0,i=-1,a=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else{if(47===n)break;n=47}if(47===n){if(i===l-1||1===a);else if(i!==l-1&&2===a){if(o.length<2||2!==s||46!==o.codePointAt(o.length-1)||46!==o.codePointAt(o.length-2))if(o.length>2){if(r=o.lastIndexOf("/"),r!==o.length-1){r<0?(o="",s=0):(o=o.slice(0,r),s=o.length-1-o.lastIndexOf("/")),i=l,a=0;continue}}else if(o.length>0){o="",s=0,i=l,a=0;continue}t&&(o=o.length>0?o+"/..":"..",s=2)}else o.length>0?o+="/"+e.slice(i+1,l):o=e.slice(i+1,l),s=l-i-1;i=l,a=0}else 46===n&&a>-1?a++:a=-1}return o}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(t)},sep:"/"};function PG(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const LG={cwd:function(){return"/"}};function zG(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function FG(e){if("string"==typeof e)e=new URL(e);else if(!zG(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}const BG=["history","path","basename","stem","extname","dirname"];class UG{constructor(e){let t;t=e?zG(e)?{path:e}:"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":LG.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<BG.length;){const e=BG[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)BG.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?RG.basename(this.path):void 0}set basename(e){HG(e,"basename"),$G(e,"basename"),this.path=RG.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?RG.dirname(this.path):void 0}set dirname(e){VG(this.basename,"dirname"),this.path=RG.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?RG.extname(this.path):void 0}set extname(e){if($G(e,"extname"),VG(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=RG.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){zG(e)&&(e=FG(e)),HG(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?RG.basename(this.path,this.extname):void 0}set stem(e){HG(e,"stem"),$G(e,"stem"),this.path=RG.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){const r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){const r=new jH(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function $G(e,t){if(e&&e.includes(RG.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+RG.sep+"`")}function HG(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function VG(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const WG=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},GG={}.hasOwnProperty;class qG extends WG{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=OG()}copy(){const e=new qG;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(MG(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(KG("data",this.frozen),this.namespace[e]=t,this):GG.call(this.namespace,e)&&this.namespace[e]||void 0:e?(KG("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const r=t.call(e,...n);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=eq(e),n=this.parser||this.Parser;return XG("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),XG("process",this.parser||this.Parser),JG("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,o){const s=eq(e),i=n.parse(s);function a(e,n){e||!n?o(e):r?r(n):t(void 0,n)}n.run(i,s,(function(e,t,r){if(e||!t||!r)return a(e);const o=t,s=n.stringify(o,r);!function(e){return"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)}(s)?r.result=s:r.value=s,a(e,r)}))}}processSync(e){let t,n=!1;return this.freeze(),XG("processSync",this.parser||this.Parser),JG("processSync",this.compiler||this.Compiler),this.process(e,(function(e,r){n=!0,kG(e),t=r})),QG("processSync","process",n),t}run(e,t,n){ZG(e),this.freeze();const r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?o(void 0,n):new Promise(o);function o(o,s){const i=eq(t);r.run(e,i,(function(t,r,i){const a=r||e;t?s(t):o?o(a):n(void 0,a,i)}))}}runSync(e,t){let n,r=!1;return this.run(e,t,(function(e,t){kG(e),n=t,r=!0})),QG("runSync","run",r),n}stringify(e,t){this.freeze();const n=eq(t),r=this.compiler||this.Compiler;return JG("stringify",r),ZG(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(KG("use",this.frozen),null==e);else if("function"==typeof e)a(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?i(e):s(e)}return this;function o(e){if("function"==typeof e)a(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;a(t,n)}else s(e)}}function s(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(e.plugins),e.settings&&(r.settings=MG(!0,r.settings,e.settings))}function i(e){let t=-1;if(null==e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;){o(e[t])}}}function a(e,t){let r=-1,o=-1;for(;++r<n.length;)if(n[r][0]===e){o=r;break}if(-1===o)n.push([e,...t]);else if(t.length>0){let[r,...s]=t;const i=n[o][1];DG(i)&&DG(r)&&(r=MG(!0,i,r)),n[o]=[e,r,...s]}}}}const YG=(new qG).freeze();function XG(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function JG(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function KG(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ZG(e){if(!DG(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function QG(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function eq(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new UG(e)}const tq=[],nq={allowDangerousHtml:!0},rq=/^(https?|ircs?|mailto|xmpp)$/i,oq=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function sq(e){const t=e.allowedElements,n=e.allowElement,r=e.children||"",o=e.className,s=e.components,i=e.disallowedElements,a=e.rehypePlugins||tq,l=e.remarkPlugins||tq,c=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...nq}:nq,d=e.skipHtml,u=e.unwrapDisallowed,h=e.urlTransform||iq,f=YG().use(UW).use(l).use(wG,c).use(a),p=new UG;"string"==typeof r&&(p.value=r);for(const y of oq)Object.hasOwn(e,y.from)&&(y.from,y.to&&y.to,y.id);const m=f.parse(p);let g=f.runSync(m,p);return o&&(g={type:"element",tagName:"div",properties:{className:o},children:"root"===g.type?g.children:[g]}),hG(g,(function(e,r,o){if("raw"===e.type&&o&&"number"==typeof r)return d?o.children.splice(r,1):o.children[r]={type:"text",value:e.value},r;if("element"===e.type){let t;for(t in GH)if(Object.hasOwn(GH,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=GH[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=h(String(n||""),t,e))}}if("element"===e.type){let s=t?!t.includes(e.tagName):!!i&&i.includes(e.tagName);if(!s&&n&&"number"==typeof r&&(s=!n(e,r,o)),s&&o&&"number"==typeof r)return u&&e.children?o.children.splice(r,1,...e.children):o.children.splice(r,1),r}})),RH(g,{Fragment:I.Fragment,components:s,ignoreInvalidStyle:!0,jsx:I.jsx,jsxs:I.jsxs,passKeys:!0,passNode:!0})}function iq(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),o=e.indexOf("/");return-1===t||-1!==o&&t>o||-1!==n&&t>n||-1!==r&&t>r||rq.test(e.slice(0,t))?e:""}function aq(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let lq={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function cq(e){lq=e}const dq={exec:()=>null};function uq(e,t=""){let n="string"==typeof e?e:e.source;const r={replace:(e,t)=>{let o="string"==typeof t?t:t.source;return o=o.replace(hq.caret,"$1"),n=n.replace(e,o),r},getRegex:()=>new RegExp(n,t)};return r}const hq={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},fq=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,pq=/(?:[*+-]|\d{1,9}[.)])/,mq=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,gq=uq(mq).replace(/bull/g,pq).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),yq=uq(mq).replace(/bull/g,pq).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),bq=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,xq=/(?!\s*\])(?:\\.|[^\[\]\\])+/,vq=uq(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",xq).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),wq=uq(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,pq).getRegex(),kq="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Sq=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Cq=uq("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",Sq).replace("tag",kq).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Eq=uq(bq).replace("hr",fq).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",kq).getRegex(),Nq={blockquote:uq(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Eq).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:vq,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:fq,html:Cq,lheading:gq,list:wq,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Eq,table:dq,text:/^[^\n]+/},jq=uq("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",fq).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",kq).getRegex(),_q={...Nq,lheading:yq,table:jq,paragraph:uq(bq).replace("hr",fq).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",jq).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",kq).getRegex()},Iq={...Nq,html:uq("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",Sq).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:dq,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:uq(bq).replace("hr",fq).replace("heading"," *#{1,6} *[^\n]").replace("lheading",gq).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Aq=/^( {2,}|\\)\n(?!\s*$)/,Tq=/[\p{P}\p{S}]/u,Mq=/[\s\p{P}\p{S}]/u,Dq=/[^\s\p{P}\p{S}]/u,Oq=uq(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Mq).getRegex(),Rq=/(?!~)[\p{P}\p{S}]/u,Pq=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Lq=uq(Pq,"u").replace(/punct/g,Tq).getRegex(),zq=uq(Pq,"u").replace(/punct/g,Rq).getRegex(),Fq="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Bq=uq(Fq,"gu").replace(/notPunctSpace/g,Dq).replace(/punctSpace/g,Mq).replace(/punct/g,Tq).getRegex(),Uq=uq(Fq,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,Rq).getRegex(),$q=uq("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Dq).replace(/punctSpace/g,Mq).replace(/punct/g,Tq).getRegex(),Hq=uq(/\\(punct)/,"gu").replace(/punct/g,Tq).getRegex(),Vq=uq(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Wq=uq(Sq).replace("(?:--\x3e|$)","--\x3e").getRegex(),Gq=uq("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Wq).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qq=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Yq=uq(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",qq).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Xq=uq(/^!?\[(label)\]\[(ref)\]/).replace("label",qq).replace("ref",xq).getRegex(),Jq=uq(/^!?\[(ref)\](?:\[\])?/).replace("ref",xq).getRegex(),Kq={_backpedal:dq,anyPunctuation:Hq,autolink:Vq,blockSkip:/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,br:Aq,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:dq,emStrongLDelim:Lq,emStrongRDelimAst:Bq,emStrongRDelimUnd:$q,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:Yq,nolink:Jq,punctuation:Oq,reflink:Xq,reflinkSearch:uq("reflink|nolink(?!\\()","g").replace("reflink",Xq).replace("nolink",Jq).getRegex(),tag:Gq,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:dq},Zq={...Kq,link:uq(/^!?\[(label)\]\((.*?)\)/).replace("label",qq).getRegex(),reflink:uq(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qq).getRegex()},Qq={...Kq,emStrongRDelimAst:Uq,emStrongLDelim:zq,url:uq(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},eY={...Qq,br:uq(Aq).replace("{2,}","*").getRegex(),text:uq(Qq.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},tY={normal:Nq,gfm:_q,pedantic:Iq},nY={normal:Kq,gfm:Qq,breaks:eY,pedantic:Zq},rY={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},oY=e=>rY[e];function sY(e,t){if(t){if(hq.escapeTest.test(e))return e.replace(hq.escapeReplace,oY)}else if(hq.escapeTestNoEncode.test(e))return e.replace(hq.escapeReplaceNoEncode,oY);return e}function iY(e){try{e=encodeURI(e).replace(hq.percentDecode,"%")}catch{return null}return e}function aY(e,t){var n;const r=e.replace(hq.findPipe,((e,t,n)=>{let r=!1,o=t;for(;--o>=0&&"\\"===n[o];)r=!r;return r?"|":" |"})).split(hq.splitPipe);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!(null==(n=r.at(-1))?void 0:n.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(hq.slashPipe,"|");return r}function lY(e,t,n){const r=e.length;if(0===r)return"";let o=0;for(;o<r;){if(e.charAt(r-o-1)!==t)break;o++}return e.slice(0,r-o)}function cY(e,t,n,r,o){const s=t.href,i=t.title||null,a=e[1].replace(o.other.outputLinkReplace,"$1");if("!"!==e[0].charAt(0)){r.state.inLink=!0;const e={type:"link",raw:n,href:s,title:i,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,e}return{type:"image",raw:n,href:s,title:i,text:a}}class dY{constructor(e){n(this,"options"),n(this,"rules"),n(this,"lexer"),this.options=e||lq}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:lY(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t,n){const r=e.match(n.other.indentCodeCompensation);if(null===r)return t;const o=r[1];return t.split("\n").map((e=>{const t=e.match(n.other.beginningSpace);if(null===t)return e;const[r]=t;return r.length>=o.length?e.slice(o.length):e})).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){const t=lY(e,"#");this.options.pedantic?e=t.trim():t&&!this.rules.other.endingSpaceChar.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:lY(t[0],"\n")}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let e=lY(t[0],"\n").split("\n"),n="",r="";const o=[];for(;e.length>0;){let t=!1;const s=[];let i;for(i=0;i<e.length;i++)if(this.rules.other.blockquoteStart.test(e[i]))s.push(e[i]),t=!0;else{if(t)break;s.push(e[i])}e=e.slice(i);const a=s.join("\n"),l=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,r=r?`${r}\n${l}`:l;const c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,o,!0),this.lexer.state.top=c,0===e.length)break;const d=o.at(-1);if("code"===(null==d?void 0:d.type))break;if("blockquote"===(null==d?void 0:d.type)){const t=d,s=t.raw+"\n"+e.join("\n"),i=this.blockquote(s);o[o.length-1]=i,n=n.substring(0,n.length-t.raw.length)+i.raw,r=r.substring(0,r.length-t.text.length)+i.text;break}if("list"!==(null==d?void 0:d.type));else{const t=d,s=t.raw+"\n"+e.join("\n"),i=this.list(s);o[o.length-1]=i,n=n.substring(0,n.length-d.raw.length)+i.raw,r=r.substring(0,r.length-t.raw.length)+i.raw,e=s.substring(o.at(-1).raw.length).split("\n")}}return{type:"blockquote",raw:n,tokens:o,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");const s=this.rules.other.listItemRegex(n);let i=!1;for(;e;){let n=!1,r="",a="";if(!(t=s.exec(e)))break;if(this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let l=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,(e=>" ".repeat(3*e.length))),c=e.split("\n",1)[0],d=!l.trim(),u=0;if(this.options.pedantic?(u=2,a=l.trimStart()):d?u=t[1].length+1:(u=t[2].search(this.rules.other.nonSpaceChar),u=u>4?1:u,a=l.slice(u),u+=t[1].length),d&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=this.rules.other.nextBulletRegex(u),n=this.rules.other.hrRegex(u),o=this.rules.other.fencesBeginRegex(u),s=this.rules.other.headingBeginRegex(u),i=this.rules.other.htmlBeginRegex(u);for(;e;){const h=e.split("\n",1)[0];let f;if(c=h,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),f=c):f=c.replace(this.rules.other.tabCharGlobal," "),o.test(c))break;if(s.test(c))break;if(i.test(c))break;if(t.test(c))break;if(n.test(c))break;if(f.search(this.rules.other.nonSpaceChar)>=u||!c.trim())a+="\n"+f.slice(u);else{if(d)break;if(l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4)break;if(o.test(l))break;if(s.test(l))break;if(n.test(l))break;a+="\n"+c}d||c.trim()||(d=!0),r+=h+"\n",e=e.substring(h.length+1),l=f.slice(u)}}o.loose||(i?o.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(i=!0));let h,f=null;this.options.gfm&&(f=this.rules.other.listIsTask.exec(a),f&&(h="[ ] "!==f[0],a=a.replace(this.rules.other.listReplaceTask,""))),o.items.push({type:"list_item",raw:r,task:!!f,checked:h,loose:!1,text:a,tokens:[]}),o.raw+=r}const a=o.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),o.raw=o.raw.trimEnd();for(let e=0;e<o.items.length;e++)if(this.lexer.state.top=!1,o.items[e].tokens=this.lexer.blockTokens(o.items[e].text,[]),!o.loose){const t=o.items[e].tokens.filter((e=>"space"===e.type)),n=t.length>0&&t.some((e=>this.rules.other.anyLine.test(e.raw)));o.loose=n}if(o.loose)for(let e=0;e<o.items.length;e++)o.items[e].loose=!0;return o}}html(e){const t=this.rules.block.html.exec(e);if(t){return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:r}}}table(e){var t;const n=this.rules.block.table.exec(e);if(!n)return;if(!this.rules.other.tableDelimiter.test(n[2]))return;const r=aY(n[1]),o=n[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(null==(t=n[3])?void 0:t.trim())?n[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],i={type:"table",raw:n[0],header:[],align:[],rows:[]};if(r.length===o.length){for(const e of o)this.rules.other.tableAlignRight.test(e)?i.align.push("right"):this.rules.other.tableAlignCenter.test(e)?i.align.push("center"):this.rules.other.tableAlignLeft.test(e)?i.align.push("left"):i.align.push(null);for(let e=0;e<r.length;e++)i.header.push({text:r[e],tokens:this.lexer.inline(r[e]),header:!0,align:i.align[e]});for(const e of s)i.rows.push(aY(e,i.header.length).map(((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:i.align[t]}))));return i}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;const t=lY(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return-1}(t[2],"()");if(e>-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){const e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),cY(t,{href:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n,title:r?r.replace(this.rules.inline.anyPunctuation,"$1"):r},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return cY(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r)return;if(r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const n=[...r[0]].length-1;let o,s,i=n,a=0;const l="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+n);null!=(r=l.exec(t));){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(s=[...o].length,r[3]||r[4]){i+=s;continue}if((r[5]||r[6])&&n%3&&!((n+s)%3)){a+=s;continue}if(i-=s,i>0)continue;s=Math.min(s,s+i+a);const t=[...r[0]][0].length,l=e.slice(0,n+r.index+t+s);if(Math.min(n,s)%2){const e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}const c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," ");const n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){var t;let n;if(n=this.rules.inline.url.exec(e)){let e,r;if("@"===n[2])e=n[0],r="mailto:"+e;else{let o;do{o=n[0],n[0]=(null==(t=this.rules.inline._backpedal.exec(n[0]))?void 0:t[0])??""}while(o!==n[0]);e=n[0],r="www."===n[1]?"http://"+n[0]:n[0]}return{type:"link",raw:n[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){const e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}}class uY{constructor(e){n(this,"tokens"),n(this,"options"),n(this,"state"),n(this,"tokenizer"),n(this,"inlineQueue"),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||lq,this.options.tokenizer=this.options.tokenizer||new dY,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={other:hq,block:tY.normal,inline:nY.normal};this.options.pedantic?(t.block=tY.pedantic,t.inline=nY.pedantic):this.options.gfm&&(t.block=tY.gfm,this.options.breaks?t.inline=nY.breaks:t.inline=nY.gfm),this.tokenizer.rules=t}static get rules(){return{block:tY,inline:nY}}static lex(e,t){return new uY(t).lex(e)}static lexInline(e,t){return new uY(t).inlineTokens(e)}lex(e){e=e.replace(hq.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){var r,o,s;for(this.options.pedantic&&(e=e.replace(hq.tabCharGlobal," ").replace(hq.spaceLine,""));e;){let i;if(null==(o=null==(r=this.options.extensions)?void 0:r.block)?void 0:o.some((n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0))))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);const n=t.at(-1);1===i.raw.length&&void 0!==n?n.raw+="\n":t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);const n=t.at(-1);"paragraph"===(null==n?void 0:n.type)||"text"===(null==n?void 0:n.type)?(n.raw+="\n"+i.raw,n.text+="\n"+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);const n=t.at(-1);"paragraph"===(null==n?void 0:n.type)||"text"===(null==n?void 0:n.type)?(n.raw+="\n"+i.raw,n.text+="\n"+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title});continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(null==(s=this.options.extensions)?void 0:s.startBlock){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startBlock.forEach((e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))})),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){const r=t.at(-1);n&&"paragraph"===(null==r?void 0:r.type)?(r.raw+="\n"+i.raw,r.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length)}else if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);const n=t.at(-1);"text"===(null==n?void 0:n.type)?(n.raw+="\n"+i.raw,n.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i)}else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var n,r,o;let s=e,i=null;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(s));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(s));)s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(s));)s=s.slice(0,i.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let a=!1,l="";for(;e;){let i;if(a||(l=""),a=!1,null==(r=null==(n=this.options.extensions)?void 0:n.inline)?void 0:r.some((n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0))))continue;if(i=this.tokenizer.escape(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.tag(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.link(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(i.raw.length);const n=t.at(-1);"text"===i.type&&"text"===(null==n?void 0:n.type)?(n.raw+=i.raw,n.text+=i.text):t.push(i);continue}if(i=this.tokenizer.emStrong(e,s,l)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.codespan(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.br(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.del(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.autolink(e)){e=e.substring(i.raw.length),t.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(e))){e=e.substring(i.raw.length),t.push(i);continue}let c=e;if(null==(o=this.options.extensions)?void 0:o.startInline){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startInline.forEach((e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))})),t<1/0&&t>=0&&(c=e.substring(0,t+1))}if(i=this.tokenizer.inlineText(c)){e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(l=i.raw.slice(-1)),a=!0;const n=t.at(-1);"text"===(null==n?void 0:n.type)?(n.raw+=i.raw,n.text+=i.text):t.push(i)}else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}}class hY{constructor(e){n(this,"options"),n(this,"parser"),this.options=e||lq}space(e){return""}code({text:e,lang:t,escaped:n}){var r;const o=null==(r=(t||"").match(hq.notSpaceStart))?void 0:r[0],s=e.replace(hq.endingNewline,"")+"\n";return o?'<pre><code class="language-'+sY(o)+'">'+(n?s:sY(s,!0))+"</code></pre>\n":"<pre><code>"+(n?s:sY(s,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){const t=e.ordered,n=e.start;let r="";for(let s=0;s<e.items.length;s++){const t=e.items[s];r+=this.listitem(t)}const o=t?"ol":"ul";return"<"+o+(t&&1!==n?' start="'+n+'"':"")+">\n"+r+"</"+o+">\n"}listitem(e){var t;let n="";if(e.task){const r=this.checkbox({checked:!!e.checked});e.loose?"paragraph"===(null==(t=e.tokens[0])?void 0:t.type)?(e.tokens[0].text=r+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&"text"===e.tokens[0].tokens[0].type&&(e.tokens[0].tokens[0].text=r+" "+sY(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):n+=r+" "}return n+=this.parser.parse(e.tokens,!!e.loose),`<li>${n}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let o=0;o<e.header.length;o++)n+=this.tablecell(e.header[o]);t+=this.tablerow({text:n});let r="";for(let o=0;o<e.rows.length;o++){const t=e.rows[o];n="";for(let e=0;e<t.length;e++)n+=this.tablecell(t[e]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){const t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${sY(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){const r=this.parser.parseInline(n),o=iY(e);if(null===o)return r;let s='<a href="'+(e=o)+'"';return t&&(s+=' title="'+sY(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n}){const r=iY(e);if(null===r)return sY(n);let o=`<img src="${e=r}" alt="${n}"`;return t&&(o+=` title="${sY(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:sY(e.text)}}class fY{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}}class pY{constructor(e){n(this,"options"),n(this,"renderer"),n(this,"textRenderer"),this.options=e||lq,this.options.renderer=this.options.renderer||new hY,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new fY}static parse(e,t){return new pY(t).parse(e)}static parseInline(e,t){return new pY(t).parseInline(e)}parse(e,t=!0){var n,r;let o="";for(let s=0;s<e.length;s++){const i=e[s];if(null==(r=null==(n=this.options.extensions)?void 0:n.renderers)?void 0:r[i.type]){const e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){o+=t||"";continue}}const a=i;switch(a.type){case"space":o+=this.renderer.space(a);continue;case"hr":o+=this.renderer.hr(a);continue;case"heading":o+=this.renderer.heading(a);continue;case"code":o+=this.renderer.code(a);continue;case"table":o+=this.renderer.table(a);continue;case"blockquote":o+=this.renderer.blockquote(a);continue;case"list":o+=this.renderer.list(a);continue;case"html":o+=this.renderer.html(a);continue;case"paragraph":o+=this.renderer.paragraph(a);continue;case"text":{let n=a,r=this.renderer.text(n);for(;s+1<e.length&&"text"===e[s+1].type;)n=e[++s],r+="\n"+this.renderer.text(n);o+=t?this.renderer.paragraph({type:"paragraph",raw:r,text:r,tokens:[{type:"text",raw:r,text:r,escaped:!0}]}):r;continue}default:{const e='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return o}parseInline(e,t=this.renderer){var n,r;let o="";for(let s=0;s<e.length;s++){const i=e[s];if(null==(r=null==(n=this.options.extensions)?void 0:n.renderers)?void 0:r[i.type]){const e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){o+=e||"";continue}}const a=i;switch(a.type){case"escape":case"text":o+=t.text(a);break;case"html":o+=t.html(a);break;case"link":o+=t.link(a);break;case"image":o+=t.image(a);break;case"strong":o+=t.strong(a);break;case"em":o+=t.em(a);break;case"codespan":o+=t.codespan(a);break;case"br":o+=t.br(a);break;case"del":o+=t.del(a);break;default:{const e='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return o}}class mY{constructor(e){n(this,"options"),n(this,"block"),this.options=e||lq}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?uY.lex:uY.lexInline}provideParser(){return this.block?pY.parse:pY.parseInline}}n(mY,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));const gY=new class{constructor(...e){n(this,"defaults",{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}),n(this,"options",this.setOptions),n(this,"parse",this.parseMarkdown(!0)),n(this,"parseInline",this.parseMarkdown(!1)),n(this,"Parser",pY),n(this,"Renderer",hY),n(this,"TextRenderer",fY),n(this,"Lexer",uY),n(this,"Tokenizer",dY),n(this,"Hooks",mY),this.use(...e)}walkTokens(e,t){var n,r;let o=[];for(const s of e)switch(o=o.concat(t.call(this,s)),s.type){case"table":{const e=s;for(const n of e.header)o=o.concat(this.walkTokens(n.tokens,t));for(const n of e.rows)for(const e of n)o=o.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=s;o=o.concat(this.walkTokens(e.items,t));break}default:{const e=s;(null==(r=null==(n=this.defaults.extensions)?void 0:n.childTokens)?void 0:r[e.type])?this.defaults.extensions.childTokens[e.type].forEach((n=>{const r=e[n].flat(1/0);o=o.concat(this.walkTokens(r,t))})):e.tokens&&(o=o.concat(this.walkTokens(e.tokens,t)))}}return o}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){const t=this.defaults.renderer||new hY(this.defaults);for(const n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;const r=n,o=e.renderer[r],s=t[r];t[r]=(...e)=>{let n=o.apply(t,e);return!1===n&&(n=s.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new dY(this.defaults);for(const n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const r=n,o=e.tokenizer[r],s=t[r];t[r]=(...e)=>{let n=o.apply(t,e);return!1===n&&(n=s.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new mY;for(const n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;const r=n,o=e.hooks[r],s=t[r];mY.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(o.call(t,e)).then((e=>s.call(t,e)));const n=o.call(t,e);return s.call(t,n)}:t[r]=(...e)=>{let n=o.apply(t,e);return!1===n&&(n=s.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return uY.lex(e,t??this.defaults)}parser(e,t){return pY.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{const r={...n},o={...this.defaults,...r},s=this.onError(!!o.silent,!!o.async);if(!0===this.defaults.async&&!1===r.async)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(null==t)return s(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));o.hooks&&(o.hooks.options=o,o.hooks.block=e);const i=o.hooks?o.hooks.provideLexer():e?uY.lex:uY.lexInline,a=o.hooks?o.hooks.provideParser():e?pY.parse:pY.parseInline;if(o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(t):t).then((e=>i(e,o))).then((e=>o.hooks?o.hooks.processAllTokens(e):e)).then((e=>o.walkTokens?Promise.all(this.walkTokens(e,o.walkTokens)).then((()=>e)):e)).then((e=>a(e,o))).then((e=>o.hooks?o.hooks.postprocess(e):e)).catch(s);try{o.hooks&&(t=o.hooks.preprocess(t));let e=i(t,o);o.hooks&&(e=o.hooks.processAllTokens(e)),o.walkTokens&&this.walkTokens(e,o.walkTokens);let n=a(e,o);return o.hooks&&(n=o.hooks.postprocess(n)),n}catch(iX){return s(iX)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="<p>An error occurred:</p><pre>"+sY(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function yY(e,t){return gY.parse(e,t)}yY.options=yY.setOptions=function(e){return gY.setOptions(e),yY.defaults=gY.defaults,cq(yY.defaults),yY},yY.getDefaults=aq,yY.defaults=lq,yY.use=function(...e){return gY.use(...e),yY.defaults=gY.defaults,cq(yY.defaults),yY},yY.walkTokens=function(e,t){return gY.walkTokens(e,t)},yY.parseInline=gY.parseInline,yY.Parser=pY,yY.parser=pY.parse,yY.Renderer=hY,yY.TextRenderer=fY,yY.Lexer=uY,yY.lexer=uY.lex,yY.Tokenizer=dY,yY.Hooks=mY,yY.parse=yY,yY.options,yY.setOptions,yY.use,yY.walkTokens,yY.parseInline,pY.parse,uY.lex;const bY=[yn.lineWrapping],xY=new Set(["python","markdown","sql","json","yaml","toml","shell","javascript","typescript","jsx","tsx","css","html"]);const vY=e=>{const t=j.c(26),{code:n,language:r}=e,{theme:s}=Oe(),{createNewCell:i}=U(),a=Eu(),l=se(ce),[c,d]=o.useState(n);let u,h,f;t[0]!==n?(u=()=>{d(n)},h=[n],t[0]=n,t[1]=u,t[2]=h):(u=t[1],h=t[2]),o.useEffect(u,h),t[3]!==l||t[4]!==i||t[5]!==r||t[6]!==a||t[7]!==c?(f=()=>{const e=function(e,t){return e?"python"===e?{language:e,code:t}:"sql"===e?{language:"python",code:Ro.fromQuery(t)}:"markdown"===e?{language:"python",code:Rt.fromMarkdown(t)}:"shell"===e||"bash"===e?{language:"python",code:`import subprocess\nsubprocess.run("${t}")`}:{language:"python",code:`_${e} = """\n${t}\n"""`}:{language:"python",code:t}}(r,c);"sql"===r&&yu(l,i,a),i({code:e.code,before:!1,cellId:a??"__end__"})},t[3]=l,t[4]=i,t[5]=r,t[6]=a,t[7]=c,t[8]=f):f=t[8];const p=f;let m;t[9]!==c?(m=async()=>{await nt(c)},t[9]=c,t[10]=m):m=t[10];const g=m,y="dark"===s?"dark":"light",b=r&&xY.has(r)?r:void 0;let x,v,w,k,S,C;return t[11]!==y||t[12]!==b||t[13]!==c?(x=I.jsx(Sa,{theme:y,language:b,className:"cm border rounded overflow-hidden",extensions:bY,value:c,onChange:d}),t[11]=y,t[12]=b,t[13]=c,t[14]=x):x=t[14],t[15]!==g?(v=I.jsx(X,{size:"xs",variant:"outline",onClick:g,children:"Copy"}),t[15]=g,t[16]=v):v=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(w=I.jsx(Tc,{className:"ml-2 h-4 w-4"}),t[17]=w):w=t[17],t[18]!==p?(k=I.jsxs(X,{size:"xs",variant:"outline",onClick:p,children:["Add to Notebook",w]}),t[18]=p,t[19]=k):k=t[19],t[20]!==k||t[21]!==v?(S=I.jsxs("div",{className:"flex justify-end mt-2 space-x-2",children:[v,k]}),t[20]=k,t[21]=v,t[22]=S):S=t[22],t[23]!==S||t[24]!==x?(C=I.jsxs("div",{className:"relative",children:[x,S]}),t[23]=S,t[24]=x,t[25]=C):C=t[25],C},wY={code:({children:e,className:t})=>{const n=null==t?void 0:t.replace("language-","");return n&&"string"==typeof e?I.jsxs("div",{children:[I.jsx("div",{className:"text-xs text-muted-foreground pl-1",children:n}),I.jsx(vY,{code:e.trim(),language:n})]}):I.jsx("code",{className:t,children:e})}};const kY=o.memo((e=>{const t=j.c(2),{content:n}=e;let r;return t[0]!==n?(r=I.jsx(sq,{components:wY,className:"prose dark:prose-invert max-w-none prose-pre:pl-0",children:n}),t[0]=n,t[1]=r):r=t[1],r}),((e,t)=>e.content===t.content));kY.displayName="MemoizedMarkdownBlock";const SY=o.memo((({content:e})=>{const t=o.useMemo((()=>{return t=e,yY.lexer(t).map((e=>e.raw));var t}),[e]);return I.jsx(I.Fragment,{children:t.map(((e,t)=>I.jsx(kY,{content:e},`markdown-block-${t}`)))})}));SY.displayName="MarkdownRenderer";const CY=(e,t,n,r)=>t?{...e,chats:e.chats.map((e=>e.id===t?{...e,messages:[...e.messages,{role:n,content:r,timestamp:Date.now()}],updatedAt:Date.now()}:e))}:e,EY=({onNewChat:e,activeChatId:t,setActiveChat:n,chats:r,setMessages:o})=>I.jsxs("div",{className:"flex border-b px-2 py-1 justify-between flex-shrink-0",children:[I.jsx(it,{content:"New chat",children:I.jsx(X,{variant:"text",size:"icon",onClick:e,children:I.jsx(Oo,{className:"h-4 w-4"})})}),I.jsxs(Pn,{children:[I.jsx(it,{content:"Previous chats",children:I.jsx(hs,{asChild:!0,children:I.jsx(X,{variant:"text",size:"icon",children:I.jsx(il,{className:"h-4 w-4"})})})}),I.jsx(Dn,{className:"w-[520px] p-0",align:"start",side:"right",children:I.jsx(A$,{className:"h-[500px] p-4",children:I.jsx("div",{className:"space-y-4",children:r.map((e=>I.jsxs("div",{className:In("p-3 rounded-md cursor-pointer hover:bg-accent",e.id===t&&"bg-accent"),onClick:()=>{n(e.id),o(e.messages.map((({role:e,content:t,timestamp:n})=>({role:e,content:t,id:n.toString()}))))},children:[I.jsx("div",{className:"font-medium",children:e.title}),I.jsx("div",{className:"text-sm text-muted-foreground",children:new Date(e.updatedAt).toLocaleString()})]},e.id)))})})})]})]}),NY=o.memo((e=>{const t=j.c(14),{message:n,index:r,theme:o,onEdit:s,setChatState:i,chatState:a}=e,l="user"===n.role?"justify-end":"justify-start";let c,d,u;return t[0]!==l?(c=In("flex",l),t[0]=l,t[1]=c):c=t[1],t[2]!==a||t[3]!==r||t[4]!==n.content||t[5]!==n.id||t[6]!==n.role||t[7]!==s||t[8]!==i||t[9]!==o?(d="user"===n.role?I.jsx("div",{className:"w-[95%] bg-background border p-1 rounded-sm",children:I.jsx(As,{value:n.content,theme:o,placeholder:"Type your message...",onChange:IY,onSubmit:(e,t)=>{t.trim()&&(s(r,t),a.activeChatId&&i((e=>CY(e,a.activeChatId,"user",t))))},onClose:AY},n.id)}):I.jsx("div",{className:"w-[95%]",children:I.jsx(SY,{content:n.content})}),t[2]=a,t[3]=r,t[4]=n.content,t[5]=n.id,t[6]=n.role,t[7]=s,t[8]=i,t[9]=o,t[10]=d):d=t[10],t[11]!==c||t[12]!==d?(u=I.jsx("div",{className:c,children:d}),t[11]=c,t[12]=d,t[13]=u):u=t[13],u}));NY.displayName="ChatMessage";const jY=o.memo((e=>{var t,n;const r=j.c(8),{input:o,setInput:s,onSubmit:i,theme:a,inputRef:l}=e;let c,d;return r[0]!==(null==(t=l.current)?void 0:t.editor)?(c=()=>{var e,t;return null==(t=null==(e=l.current)?void 0:e.editor)?void 0:t.blur()},r[0]=null==(n=l.current)?void 0:n.editor,r[1]=c):c=r[1],r[2]!==o||r[3]!==i||r[4]!==s||r[5]!==c||r[6]!==a?(d=I.jsx("div",{className:"px-2 py-3 border-t relative flex-shrink-0 min-h-[80px]",children:I.jsx(As,{value:o,onChange:s,onSubmit:i,onClose:c,theme:a,placeholder:"Type your message..."})}),r[2]=o,r[3]=i,r[4]=s,r[5]=c,r[6]=a,r[7]=d):d=r[7],d}));jY.displayName="ChatInput";const _Y=()=>{var e;const t=j.c(78),[n,r]=ze(hu),[s,i]=ze(fu),[a,l]=o.useState(""),c=o.useRef(null),d=o.useRef(null),u=o.useRef(null),{theme:h}=Oe();let f,p,m;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=Sr("api/ai/chat").toString(),p=Cr.headers(),t[0]=f,t[1]=p):(f=t[0],p=t[1]),t[2]!==n.activeChatId||t[3]!==r?(m={keepLastMessageOnError:!0,experimental_throttle:100,api:f,headers:p,experimental_prepareRequestBody:MY,streamProtocol:"text",onFinish:e=>{n.activeChatId?r((t=>CY(t,t.activeChatId,"assistant",e.content))):w.warn("No active chat")},onError:DY,onResponse:OY},t[2]=n.activeChatId,t[3]=r,t[4]=m):m=t[4];const{messages:g,input:y,setInput:b,setMessages:x,append:v,handleSubmit:k,error:S,isLoading:C,reload:E}=sl(m);let N;t[5]!==g?(N=null==(e=g.at(-1))?void 0:e.content,t[5]=g,t[6]=N):N=t[6];const _=N;let A,T,M;t[7]!==C?(A=()=>{var e,t;if(C){const n=null==(e=u.current)?void 0:e.parentElement;if(!n)return;n.scrollHeight-n.scrollTop-n.clientHeight<150&&(null==(t=u.current)||t.scrollIntoView({behavior:"smooth"}))}},t[7]=C,t[8]=A):A=t[8],t[9]!==C||t[10]!==_||t[11]!==g?(T=[g,C,_],t[9]=C,t[10]=_,t[11]=g,t[12]=T):T=t[12],o.useEffect(A,T),t[13]!==v||t[14]!==r||t[15]!==b||t[16]!==x?(M=e=>{const t={id:al(),title:`${e.slice(0,30)}...`,messages:[{role:"user",content:e,timestamp:Date.now()}],createdAt:Date.now(),updatedAt:Date.now()};r((e=>({chats:[...e.chats,t],activeChatId:t.id}))),x([]),b(""),v({role:"user",content:e})},t[13]=v,t[14]=r,t[15]=b,t[16]=x,t[17]=M):M=t[17];const D=M;let O;t[18]!==i||t[19]!==b||t[20]!==x?(O=()=>{i(null),x([]),b(""),l("")},t[18]=i,t[19]=b,t[20]=x,t[21]=O):O=t[21];const R=O;let P;t[22]!==v||t[23]!==x?(P=(e,t)=>{x((t=>t.slice(0,e))),v({role:"user",content:t})},t[22]=v,t[23]=x,t[24]=P):P=t[24];const L=P;let z;t[25]!==n.activeChatId||t[26]!==k||t[27]!==r?(z=(e,t)=>{t.trim()&&(k(e),n.activeChatId&&r((e=>CY(e,n.activeChatId,"user",t))))},t[25]=n.activeChatId,t[26]=k,t[27]=r,t[28]=z):z=t[28];const F=z;let B;t[29]!==E?(B=()=>{E()},t[29]=E,t[30]=B):B=t[30];const U=B;let $;t[31]!==D||t[32]!==a?($=()=>{a.trim()&&D(a.trim())},t[31]=D,t[32]=a,t[33]=$):$=t[33];const H=$;let V;t[34]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{var e,t;return null==(t=null==(e=c.current)?void 0:e.editor)?void 0:t.blur()},t[34]=V):V=t[34];const W=V,G=null==s?void 0:s.id;let q,Y,J,K,Z,Q,ee,te,ne;if(t[35]!==n.chats||t[36]!==R||t[37]!==i||t[38]!==x||t[39]!==G?(q=I.jsx(EY,{onNewChat:R,activeChatId:G,setActiveChat:i,chats:n.chats,setMessages:x}),t[35]=n.chats,t[36]=R,t[37]=i,t[38]=x,t[39]=G,t[40]=q):q=t[40],t[41]!==H||t[42]!==g||t[43]!==a||t[44]!==h?(Y=(!g||0===g.length)&&I.jsx("div",{className:"flex rounded-md border px-1 bg-background",children:I.jsx(As,{value:a,placeholder:"Ask anything, @ to include context",theme:h,onClose:W,onChange:l,onSubmit:H},"new-thread-input")}),t[41]=H,t[42]=g,t[43]=a,t[44]=h,t[45]=Y):Y=t[45],t[46]!==n||t[47]!==L||t[48]!==g||t[49]!==r||t[50]!==h){let e;t[52]!==n||t[53]!==L||t[54]!==r||t[55]!==h?(e=(e,t)=>I.jsx(NY,{message:e,index:t,theme:h,onEdit:L,setChatState:r,chatState:n},t),t[52]=n,t[53]=L,t[54]=r,t[55]=h,t[56]=e):e=t[56],J=g.map(e),t[46]=n,t[47]=L,t[48]=g,t[49]=r,t[50]=h,t[51]=J}else J=t[51];return t[57]!==C?(K=C&&I.jsx("div",{className:"flex justify-center py-4",children:I.jsx(Ms,{className:"h-4 w-4 animate-spin"})}),t[57]=C,t[58]=K):K=t[58],t[59]!==S||t[60]!==U?(Z=S&&I.jsxs("div",{className:"flex items-center justify-center space-x-2 mb-4",children:[I.jsx(ya,{error:S}),I.jsx(X,{variant:"outline",size:"sm",onClick:U,children:"Retry"})]}),t[59]=S,t[60]=U,t[61]=Z):Z=t[61],t[62]===Symbol.for("react.memo_cache_sentinel")?(Q=I.jsx("div",{ref:u}),t[62]=Q):Q=t[62],t[63]!==Y||t[64]!==J||t[65]!==K||t[66]!==Z?(ee=I.jsxs("div",{className:"flex-1 px-3 bg-[var(--slate-1)] gap-4 py-3 flex flex-col overflow-y-auto",children:[Y,J,K,Z,Q]}),t[63]=Y,t[64]=J,t[65]=K,t[66]=Z,t[67]=ee):ee=t[67],t[68]!==F||t[69]!==y||t[70]!==g||t[71]!==b||t[72]!==h?(te=g&&g.length>0&&I.jsx(jY,{input:y,setInput:b,onSubmit:F,theme:h,inputRef:d}),t[68]=F,t[69]=y,t[70]=g,t[71]=b,t[72]=h,t[73]=te):te=t[73],t[74]!==q||t[75]!==ee||t[76]!==te?(ne=I.jsxs("div",{className:"flex flex-col h-[calc(100%-53px)]",children:[q,ee,te]}),t[74]=q,t[75]=ee,t[76]=te,t[77]=ne):ne=t[77],ne};function IY(){}function AY(){}function TY(e){return e.content}function MY(e){return{...e,...Ts(e.messages.map(TY).join("\n")),includeOtherCode:hr("")}}function DY(e){w.error("An error occurred:",e)}function OY(e){w.debug("Received HTTP response from server:",e)}const RY="hoveredCellId",PY="cellHover",LY="cellNum",zY="startTimestamp",FY="endTimestamp";const BY=q(new Map),UY=()=>{const e=j.c(28),{runIds:t,runMap:n}=se(gc),r=se(BY),{clearRuns:s}=yc(),{theme:i}=Oe(),[a,l]=o.useState("above");let c;e[0]!==a?(c=()=>{l("above"===a?"sideBySide":"above")},e[0]=a,e[1]=c):c=e[1];const d=c;if(0===t.length){let t;return e[2]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx(aM,{title:"No traces",description:I.jsx("span",{children:"Cells that have ran will appear here."}),icon:I.jsx(fl,{})}),e[2]=t):t=e[2],t}let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=I.jsx("label",{htmlFor:"chartPosition",className:"text-xs",children:"Inline chart"}),e[3]=u):u=e[3];const h="sideBySide"===a;let f,p,m,g,y,b;if(e[4]!==h||e[5]!==d?(f=I.jsxs("div",{className:"flex flex-row gap-1 items-center",children:[u,I.jsx("input",{type:"checkbox",name:"chartPosition",id:"chartPosition",onClick:d,defaultChecked:h,className:"h-3 cursor-pointer"})]}),e[4]=h,e[5]=d,e[6]=f):f=e[6],e[7]!==s?(p=I.jsx(_B,{dataTestId:"clear-traces-button",onClick:s}),e[7]=s,e[8]=p):p=e[8],e[9]!==f||e[10]!==p?(m=I.jsxs("div",{className:"flex flex-row justify-end gap-3",children:[f,p]}),e[9]=f,e[10]=p,e[11]=m):m=e[11],e[12]!==a||e[13]!==r||e[14]!==t||e[15]!==n||e[16]!==i){let o;e[18]!==a||e[19]!==r||e[20]!==n||e[21]!==i?(o=(e,t)=>{const o=n.get(e);if(o)return I.jsx(VY,{run:o,isExpanded:r.get(o.runId),isMostRecentRun:0===t,chartPosition:a,theme:i},o.runId)},e[18]=a,e[19]=r,e[20]=n,e[21]=i,e[22]=o):o=e[22],g=t.map(o),e[12]=a,e[13]=r,e[14]=t,e[15]=n,e[16]=i,e[17]=g}else g=e[17];return e[23]!==g?(y=I.jsx("div",{className:"flex flex-col gap-3",children:g}),e[23]=g,e[24]=y):y=e[24],e[25]!==m||e[26]!==y?(b=I.jsxs("div",{className:"py-1 px-2 overflow-y-scroll",children:[m,y]}),e[25]=m,e[26]=y,e[27]=b):b=e[27],b},$Y=u.lazy((()=>Fa((()=>import("./index-eUGIYQ9e.js")),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]),import.meta.url).then((e=>({default:e.Vega}))))),HY=e=>{const t=j.c(10),{ref:n,width:r}=RB(),o=void 0===r?300:r,s="dark"===e.theme?"dark":void 0,i=o-50;let a,l;return t[0]!==e.height||t[1]!==e.signalListeners||t[2]!==e.vegaSpec||t[3]!==s||t[4]!==i?(a=I.jsx($Y,{spec:e.vegaSpec,theme:s,width:i,height:e.height,signalListeners:e.signalListeners,actions:!1}),t[0]=e.height,t[1]=e.signalListeners,t[2]=e.vegaSpec,t[3]=s,t[4]=i,t[5]=a):a=t[5],t[6]!==e.className||t[7]!==n||t[8]!==a?(l=I.jsx("div",{className:e.className,ref:n,children:a}),t[6]=e.className,t[7]=n,t[8]=a,t[9]=l):l=t[9],l},VY=({run:e,isMostRecentRun:t,chartPosition:n,isExpanded:r,theme:o})=>{const s=ae(BY),i=(r=r??t)?Se:Ee,a=I.jsx(i,{height:16,className:"inline"}),l=I.jsxs("span",{className:"text-sm cursor-pointer",onClick:()=>{s((t=>{const n=new Map(t);return n.set(e.runId,!r),n}))},children:["Run - ",pa(e.runStartTime),a]});return r?I.jsx(WY,{run:e,chartPosition:n,theme:o,title:l},e.runId):I.jsx("div",{className:"flex flex-col",children:I.jsx("pre",{className:"font-mono font-semibold",children:l})},e.runId)},WY=e=>{const t=j.c(32),{run:n,chartPosition:r,theme:s,title:i}=e,[a,l]=o.useState();let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c={[PY]:(e,t)=>{var n;const r=null==(n=t.cell)?void 0:n[0];l(r??null)}},t[0]=c):c=t[0];const d=c,u=Hi();let h,f;if(t[1]!==u.inOrderIds||t[2]!==r||t[3]!==n.cellRuns||t[4]!==n.runId||t[5]!==s){const e=[...n.cellRuns.values()].map((e=>{const t=e.elapsedTime??0;return{cell:e.cellId,cellNum:u.inOrderIds.indexOf(e.cellId),startTimestamp:XY(e.startTime),endTimestamp:XY(e.startTime+t),elapsedTime:vx(1e3*t),status:e.status}}));h=`hiddenInputElement-${n.runId}`,f=Cc(function(e,t,n,r){return{$schema:"https://vega.github.io/schema/vega-lite/v5.json",background:"dark"===r?"black":void 0,mark:{type:"bar",cornerRadius:2},params:[{name:RY,bind:{element:`#${t}`}},{name:PY,select:{type:"point",on:"mouseover",fields:["cell"],clear:"mouseout"}}],height:{step:23},encoding:{y:{field:LY,scale:{paddingInner:.2},sort:{field:LY},title:"cell",axis:"sideBySide"===n?null:void 0},x:{field:zY,type:"temporal",axis:{orient:"top",title:null}},x2:{field:FY,type:"temporal"},tooltip:[{field:zY,type:"temporal",timeUnit:"dayhoursminutesseconds",title:"Start"},{field:FY,type:"temporal",timeUnit:"dayhoursminutesseconds",title:"End"}],size:{value:{expr:`${RY} == toString(datum.cell) ? 19.5 : 18`}},color:{field:"status",scale:{domain:["success","error"],range:["#37BE5F","red"]},legend:null}},data:{values:e},config:{view:{stroke:"transparent"}}}}(e,h,r,s)),t[1]=u.inOrderIds,t[2]=r,t[3]=n.cellRuns,t[4]=n.runId,t[5]=s,t[6]=h,t[7]=f}else h=t[6],f=t[7];const p=f.spec;let m;t[8]!==h||t[9]!==a||t[10]!==n?(m=I.jsx(GY,{run:n,hoveredCellId:a,hiddenInputElementId:h}),t[8]=h,t[9]=a,t[10]=n,t[11]=m):m=t[11];const g=m;if("above"===r){let e,r,o;return t[12]!==s||t[13]!==p?(e=I.jsx(HY,{vegaSpec:p,height:120,signalListeners:d,theme:s}),t[12]=s,t[13]=p,t[14]=e):e=t[14],t[15]!==e||t[16]!==i||t[17]!==g?(r=I.jsxs("pre",{className:"font-mono font-semibold",children:[i,e,g]}),t[15]=e,t[16]=i,t[17]=g,t[18]=r):r=t[18],t[19]!==n.runId||t[20]!==r?(o=I.jsx("div",{className:"flex flex-col",children:r},n.runId),t[19]=n.runId,t[20]=r,t[21]=o):o=t[21],o}let y,b,x;return t[22]!==i||t[23]!==g?(y=I.jsxs("pre",{className:"font-mono font-semibold",children:[i,g]}),t[22]=i,t[23]=g,t[24]=y):y=t[24],t[25]!==s||t[26]!==p?(b=I.jsx(HY,{className:"-mt-0.5 flex-1",vegaSpec:p,height:100,signalListeners:d,theme:s}),t[25]=s,t[26]=p,t[27]=b):b=t[27],t[28]!==n.runId||t[29]!==y||t[30]!==b?(x=I.jsxs("div",{className:"flex flex-row",children:[y,b]},n.runId),t[28]=n.runId,t[29]=y,t[30]=b,t[31]=x):x=t[31],x},GY=e=>{const t=j.c(14),{run:n,hoveredCellId:r,hiddenInputElementId:s}=e,i=o.useRef(null);let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=e=>{i.current&&(i.current.value=String(e),i.current.dispatchEvent(new Event("input",{bubbles:!0})))},t[0]=a):a=t[0];const l=a,c=r||"";let d,u,h,f,p;return t[1]!==s||t[2]!==c?(d=I.jsx("input",{type:"text",id:s,defaultValue:c,hidden:!0,ref:i}),t[1]=s,t[2]=c,t[3]=d):d=t[3],t[4]!==n.cellRuns?(u=n.cellRuns.values(),t[4]=n.cellRuns,t[5]=u):u=t[5],t[6]!==u?(h=[...u],t[6]=u,t[7]=h):h=t[7],t[8]!==r||t[9]!==h?(f=h.map((e=>I.jsx(YY,{cellRun:e,hovered:e.cellId===r,dispatchHoverEvent:l},e.cellId))),t[8]=r,t[9]=h,t[10]=f):f=t[10],t[11]!==d||t[12]!==f?(p=I.jsxs("div",{className:"text-xs mt-0.5 ml-3 flex flex-col gap-0.5",children:[d,f]}),t[11]=d,t[12]=f,t[13]=p):p=t[13],p},qY={success:I.jsx(Pc,{color:"green",size:14}),running:I.jsx(zl,{color:"var(--blue-10)",size:14}),error:I.jsx(be,{color:"red",size:14}),queued:I.jsx(Lc,{color:"grey",size:14})},YY=e=>{const t=j.c(39),{cellRun:n,hovered:r,dispatchHoverEvent:o}=e;let s;t[0]!==n.elapsedTime?(s=n.elapsedTime?vx(1e3*n.elapsedTime):"-",t[0]=n.elapsedTime,t[1]=s):s=t[1];const i=s;let a;t[2]!==n.elapsedTime||t[3]!==i?(a=n.elapsedTime?I.jsxs("span",{children:["This cell took ",I.jsx(bx,{elapsedTime:i})," to run"]}):I.jsx("span",{children:"This cell has not been run"}),t[2]=n.elapsedTime,t[3]=i,t[4]=a):a=t[4];const l=a;let c;t[5]!==n.cellId||t[6]!==o?(c=()=>{o(n.cellId)},t[5]=n.cellId,t[6]=o,t[7]=c):c=t[7];const d=c;let u;t[8]!==o?(u=()=>{o(null)},t[8]=o,t[9]=u):u=t[9];const h=u,f=r&&"bg-[var(--gray-3)] opacity-100";let p,m,g,y,b,x,v;t[10]!==f?(p=In("flex flex-row gap-2 py-1 px-1 opacity-70 hover:bg-[var(--gray-3)] hover:opacity-100",f),t[10]=f,t[11]=p):p=t[11],t[12]!==n.startTime?(m=pa(n.startTime),t[12]=n.startTime,t[13]=m):m=t[13],t[14]!==m?(g=I.jsxs("span",{className:"text-[var(--gray-10)] dark:text-[var(--gray-11)]",children:["[",m,"]"]}),t[14]=m,t[15]=g):g=t[15],t[16]!==n.cellId?(y=I.jsxs("span",{className:"text-[var(--gray-10)] w-16",children:["(",I.jsx(Wi,{cellId:n.cellId}),")"]}),t[16]=n.cellId,t[17]=y):y=t[17],t[18]!==n.code?(b=I.jsx("span",{className:"w-40 truncate -ml-1",children:n.code}),t[18]=n.code,t[19]=b):b=t[19],t[20]!==i?(x=I.jsx("span",{className:"text-[var(--gray-10)] dark:text-[var(--gray-11)]",children:i}),t[20]=i,t[21]=x):x=t[21],t[22]!==l||t[23]!==x?(v=I.jsx(it,{content:l,children:x}),t[22]=l,t[23]=x,t[24]=v):v=t[24];const w=qY[n.status];let k,S,C;return t[25]!==n.status||t[26]!==w?(k=I.jsx(it,{content:n.status,children:w}),t[25]=n.status,t[26]=w,t[27]=k):k=t[27],t[28]!==v||t[29]!==k?(S=I.jsxs("div",{className:"flex flex-row gap-1 w-16 justify-end -ml-2",children:[v,k]}),t[28]=v,t[29]=k,t[30]=S):S=t[30],t[31]!==d||t[32]!==h||t[33]!==b||t[34]!==S||t[35]!==p||t[36]!==g||t[37]!==y?(C=I.jsxs("div",{className:p,onMouseEnter:d,onMouseLeave:h,children:[g,y,b,S]}),t[31]=d,t[32]=h,t[33]=b,t[34]=S,t[35]=p,t[36]=g,t[37]=y,t[38]=C):C=t[38],C};function XY(e){try{const t=new Date(1e3*e),n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0");return`${n}-${r}-${o} ${s}:${i}:${a}.${String(t.getMilliseconds()).padStart(3,"0")}`}catch{return""}}const JY=()=>{const e=j.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=I.jsx(UY,{}),e[0]=t):t=e[0],t},KY=u.lazy((()=>Fa((()=>import("./terminal-DCpCpEop.js")),__vite__mapDeps([14,2,3,15,16]),import.meta.url))),ZY=e=>{const t=j.c(116),{children:n}=e,{isSidebarOpen:r,isTerminalOpen:s,selectedPanel:i}=Hu(),{setIsSidebarOpen:a,setIsTerminalOpen:l}=Vu(),c=u.useRef(null),d=u.useRef(null);let h,f,p,m,g;t[0]!==r?(h=()=>{if(!c.current)return;const e=c.current.isCollapsed();r&&e&&c.current.expand(),r||e||c.current.collapse(),requestAnimationFrame(eX)},f=[r],t[0]=r,t[1]=h,t[2]=f):(h=t[1],f=t[2]),o.useEffect(h,f),t[3]!==s?(p=()=>{if(!d.current)return;const e=d.current.isCollapsed();s&&e&&d.current.expand(),s||e||d.current.collapse(),requestAnimationFrame(nX)},m=[s],t[3]=s,t[4]=p,t[5]=m):(p=t[4],m=t[5]),o.useEffect(p,m),t[6]!==n?(g=I.jsx(CA,{id:"app",className:"relative h-full",children:I.jsx(o.Suspense,{children:n})},"app"),t[6]=n,t[7]=g):g=t[7];const y=g,b=rX,x=r?"resize-handle":"resize-handle-collapsed";let v,w;t[8]!==x?(v=In("border-border no-print z-10",x,"vertical"),t[8]=x,t[9]=v):v=t[9],t[10]!==v?(w=I.jsx(MT,{onDragging:b,className:v}),t[10]=v,t[11]=w):w=t[11];const k=w,S=s?"resize-handle":"resize-handle-collapsed";let C,E;t[12]!==S?(C=In("border-border no-print z-20",S,"horizontal"),t[12]=S,t[13]=C):C=t[13],t[14]!==C?(E=I.jsx(MT,{onDragging:b,className:C}),t[14]=C,t[15]=E):E=t[15];const N=E;let _,A,T,M,D,O,R,P,L,z,F,B,U,$,H,V,W,G,q,Y;t[16]!==i?(_=I.jsx("div",{className:"text-sm text-[var(--slate-11)] uppercase tracking-wide font-semibold flex-1",children:i}),t[16]=i,t[17]=_):_=t[17],t[18]!==a?(A=()=>a(!1),t[18]=a,t[19]=A):A=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(T=I.jsx(Cn,{className:"w-4 h-4"}),t[20]=T):T=t[20],t[21]!==A?(M=I.jsx(X,{"data-testid":"close-helper-pane",className:"m-0",size:"xs",variant:"text",onClick:A,children:T}),t[21]=A,t[22]=M):M=t[22],t[23]!==_||t[24]!==M?(D=I.jsxs("div",{className:"p-3 border-b flex justify-between items-center",children:[_,M]}),t[23]=_,t[24]=M,t[25]=D):D=t[25],t[26]!==i?(O="files"===i&&I.jsx(dU,{}),t[26]=i,t[27]=O):O=t[27],t[28]!==i?(R="errors"===i&&I.jsx(lM,{}),t[28]=i,t[29]=R):R=t[29],t[30]!==i?(P="variables"===i&&I.jsx(jB,{}),t[30]=i,t[31]=P):P=t[31],t[32]!==i?(L="dependencies"===i&&I.jsx(wB,{}),t[32]=i,t[33]=L):L=t[33],t[34]!==i?(z="packages"===i&&I.jsx($U,{}),t[34]=i,t[35]=z):z=t[35],t[36]!==i?(F="outline"===i&&I.jsx(dM,{}),t[36]=i,t[37]=F):F=t[37],t[38]!==i?(B="datasources"===i&&I.jsx(kU,{}),t[38]=i,t[39]=B):B=t[39],t[40]!==i?(U="documentation"===i&&I.jsx(DB,{}),t[40]=i,t[41]=U):U=t[41],t[42]!==i?($="snippets"===i&&I.jsx(mU,{}),t[42]=i,t[43]=$):$=t[43],t[44]!==i?(H="scratchpad"===i&&I.jsx(UU,{}),t[44]=i,t[45]=H):H=t[45],t[46]!==i?(V="chat"===i&&I.jsx(_Y,{}),t[46]=i,t[47]=V):V=t[47],t[48]!==i?(W="logs"===i&&I.jsx(IB,{}),t[48]=i,t[49]=W):W=t[49],t[50]!==i?(G="tracing"===i&&I.jsx(JY,{}),t[50]=i,t[51]=G):G=t[51],t[52]!==O||t[53]!==R||t[54]!==P||t[55]!==L||t[56]!==z||t[57]!==F||t[58]!==B||t[59]!==U||t[60]!==$||t[61]!==H||t[62]!==V||t[63]!==W||t[64]!==G?(q=I.jsxs(_i,{children:[O,R,P,L,z,F,B,U,$,H,V,W,G]}),t[52]=O,t[53]=R,t[54]=P,t[55]=L,t[56]=z,t[57]=F,t[58]=B,t[59]=U,t[60]=$,t[61]=H,t[62]=V,t[63]=W,t[64]=G,t[65]=q):q=t[65],t[66]!==D||t[67]!==q?(Y=I.jsx(Rn,{children:I.jsx(o.Suspense,{children:I.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden mr-[-4px]",children:[D,q]})})}),t[66]=D,t[67]=q,t[68]=Y):Y=t[68];const J=Y,K=r&&"border-r border-l border-[var(--slate-7)]";let Z,Q,ee,te,ne,re;t[69]!==K?(Z=In("dark:bg-[var(--slate-1)] no-print print:hidden hide-on-fullscreen",K),t[69]=K,t[70]=Z):Z=t[70],t[71]===Symbol.for("react.memo_cache_sentinel")?(Q=(e,t)=>{var n;0===t&&10===e&&(null==(n=c.current)||n.resize(30))},t[71]=Q):Q=t[71],t[72]!==a?(ee=()=>a(!1),te=()=>a(!0),t[72]=a,t[73]=ee,t[74]=te):(ee=t[73],te=t[74]),t[75]!==J||t[76]!==k?(ne=I.jsxs("span",{className:"flex flex-row h-full",children:[J," ",k]}),t[75]=J,t[76]=k,t[77]=ne):ne=t[77],t[78]!==Z||t[79]!==ee||t[80]!==te||t[81]!==ne?(re=I.jsx(CA,{ref:c,id:"helper",collapsedSize:0,collapsible:!0,className:Z,minSize:10,defaultSize:0,maxSize:75,onResize:Q,onCollapse:ee,onExpand:te,children:ne},"helper"),t[78]=Z,t[79]=ee,t[80]=te,t[81]=ne,t[82]=re):re=t[82];const oe=re,se=s&&"border-[var(--slate-7)]";let ie,ae,le,ce,de,ue,he,fe;t[83]!==se?(ie=In("dark:bg-[var(--slate-1)] no-print print:hidden hide-on-fullscreen",se),t[83]=se,t[84]=ie):ie=t[84],t[85]===Symbol.for("react.memo_cache_sentinel")?(ae=(e,t)=>{var n;0===t&&10===e&&(null==(n=d.current)||n.resize(30))},t[85]=ae):ae=t[85],t[86]!==l?(le=()=>l(!1),ce=()=>l(!0),t[86]=l,t[87]=le,t[88]=ce):(le=t[87],ce=t[88]),t[89]!==l?(de=()=>l(!1),t[89]=l,t[90]=de):de=t[90],t[91]!==s||t[92]!==de?(ue=I.jsx(KY,{visible:s,onClose:de}),t[91]=s,t[92]=de,t[93]=ue):ue=t[93],t[94]!==s||t[95]!==ue?(he=I.jsx(RU,{isOpen:s,children:ue}),t[94]=s,t[95]=ue,t[96]=he):he=t[96],t[97]!==ie||t[98]!==le||t[99]!==ce||t[100]!==he||t[101]!==N?(fe=I.jsxs(CA,{ref:d,id:"terminal",collapsedSize:0,collapsible:!0,className:ie,minSize:10,defaultSize:0,maxSize:75,onResize:ae,onCollapse:le,onExpand:ce,children:[N,he]},"terminal"),t[97]=ie,t[98]=le,t[99]=ce,t[100]=he,t[101]=N,t[102]=fe):fe=t[102];const pe=fe;let me,ge,ye,be,xe,ve,we;return t[103]===Symbol.for("react.memo_cache_sentinel")?(me={getItem:e=>iM||(iM??null),setItem(e,t){iM=t||null}},t[103]=me):me=t[103],t[104]===Symbol.for("react.memo_cache_sentinel")?(ge=I.jsx(_i,{children:I.jsx(eM,{})}),t[104]=ge):ge=t[104],t[105]!==pe?(ye=I.jsx(YT,{capability:"terminal",children:pe}),t[105]=pe,t[106]=ye):ye=t[106],t[107]!==y||t[108]!==ye?(be=I.jsx(CA,{children:I.jsxs(IT,{autoSaveId:"marimo:chrome:v1:l1",direction:"vertical",children:[y,ye]})}),t[107]=y,t[108]=ye,t[109]=be):be=t[109],t[110]!==oe||t[111]!==be?(xe=I.jsxs(IT,{autoSaveId:"marimo:chrome:v1:l2",direction:"horizontal",storage:me,children:[ge,oe,be]}),t[110]=oe,t[111]=be,t[112]=xe):xe=t[112],t[113]===Symbol.for("react.memo_cache_sentinel")?(ve=I.jsx(Rn,{children:I.jsx(_i,{children:I.jsx(XT,{})})}),t[113]=ve):ve=t[113],t[114]!==xe?(we=I.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden absolute inset-0 print:relative",children:[xe,ve]}),t[114]=xe,t[115]=we):we=t[115],we};function QY(){window.dispatchEvent(new Event("resize"))}function eX(){requestAnimationFrame(QY)}function tX(){window.dispatchEvent(new Event("resize"))}function nX(){requestAnimationFrame(tX)}function rX(e){e||window.dispatchEvent(new Event("resize"))}const oX=e=>{const t=j.c(5);let n,r,o;return t[0]!==e?(n=I.jsx(KI,{...e}),t[0]=e,t[1]=n):n=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=I.jsx(Au,{}),t[2]=r):r=t[2],t[3]!==n?(o=I.jsxs(ZY,{children:[n,r]}),t[3]=n,t[4]=o):o=t[4],o};export{oX as default};