@marimo-team/frontend 0.14.18-dev1 → 0.14.18-dev2

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 (97) hide show
  1. package/dist/assets/{ConnectedDataExplorerComponent-lbQxd8jz.js → ConnectedDataExplorerComponent-BT0xl502.js} +1 -1
  2. package/dist/assets/{ImageComparisonComponent-BJeoNaPX.js → ImageComparisonComponent-CyD_BM3x.js} +1 -1
  3. package/dist/assets/{VegaLite-CTkLkkZP.js → VegaLite-hnjov9BB.js} +1 -1
  4. package/dist/assets/{_baseEach-Z8e7apxp.js → _baseEach-C_3O_UIK.js} +1 -1
  5. package/dist/assets/_baseMap-ejDdVnUU.js +1 -0
  6. package/dist/assets/{_baseUniq-BdtmJOZM.js → _baseUniq-G59-tGC4.js} +1 -1
  7. package/dist/assets/{_createAggregator-DvN_9uLC.js → _createAggregator-CYM_3WAb.js} +1 -1
  8. package/dist/assets/{any-language-editor-CGtu0DAR.js → any-language-editor-B_KRwSpy.js} +1 -1
  9. package/dist/assets/{architectureDiagram-SUXI7LT5-DTlATSwP.js → architectureDiagram-SUXI7LT5-Cp-u2npp.js} +1 -1
  10. package/dist/assets/{blockDiagram-6J76NXCF-BgUE0IVr.js → blockDiagram-6J76NXCF-B1eF_YTU.js} +1 -1
  11. package/dist/assets/{c4Diagram-6F6E4RAY-pb246yfI.js → c4Diagram-6F6E4RAY-D3Co9dhJ.js} +1 -1
  12. package/dist/assets/channel-PLmZB-8M.js +1 -0
  13. package/dist/assets/{chunk-353BL4L5-ChOGU7Et.js → chunk-353BL4L5-BNPOylnE.js} +1 -1
  14. package/dist/assets/{chunk-67H74DCK-BBtNpYqQ.js → chunk-67H74DCK-6tJ94Bg0.js} +1 -1
  15. package/dist/assets/{chunk-AACKK3MU-BQMbP_Vt.js → chunk-AACKK3MU-46UGfeGc.js} +1 -1
  16. package/dist/assets/{chunk-BFAMUDN2-e-cjn3-W.js → chunk-BFAMUDN2-CNdKrd4t.js} +1 -1
  17. package/dist/assets/{chunk-E2GYISFI-D1ADxOOn.js → chunk-E2GYISFI-0jprAmfg.js} +1 -1
  18. package/dist/assets/{chunk-OW32GOEJ-9lctnMIz.js → chunk-OW32GOEJ-Dq-4mco2.js} +1 -1
  19. package/dist/assets/{chunk-SKB7J2MH-ErUT6F4L.js → chunk-SKB7J2MH-BFb7Z7j2.js} +1 -1
  20. package/dist/assets/{chunk-SZ463SBG-yMNaAUAq.js → chunk-SZ463SBG-BEsy1Bnk.js} +1 -1
  21. package/dist/assets/{circle-play-DZltiUnT.js → circle-play-chxJxn_k.js} +1 -1
  22. package/dist/assets/classDiagram-M3E45YP4-Bl6D-lo6.js +1 -0
  23. package/dist/assets/classDiagram-v2-YAWTLIQI-Bl6D-lo6.js +1 -0
  24. package/dist/assets/clone-BllYssjv.js +1 -0
  25. package/dist/assets/{compile-BnHv8iHN.js → compile-CrDOzGvF.js} +1 -1
  26. package/dist/assets/{dagre-JOIXM2OF-l1r1BJ0F.js → dagre-JOIXM2OF-CgxEy6Ti.js} +1 -1
  27. package/dist/assets/{data-grid-overlay-editor-Ba_kq_S3.js → data-grid-overlay-editor-Bt-ru6j6.js} +1 -1
  28. package/dist/assets/{diagram-5UYTHUR4-BUzIkwrO.js → diagram-5UYTHUR4-Cv4YqP4A.js} +1 -1
  29. package/dist/assets/{diagram-VMROVX33-D7iI3hZW.js → diagram-VMROVX33-UJqJ2Qh7.js} +1 -1
  30. package/dist/assets/{diagram-ZTM2IBQH-Tlys7Qa7.js → diagram-ZTM2IBQH-wfhUdi9M.js} +1 -1
  31. package/dist/assets/edit-page-Bh3hotqJ.js +163 -0
  32. package/dist/assets/{erDiagram-3M52JZNH-D-LB2D6A.js → erDiagram-3M52JZNH-Bt4OzYYB.js} +1 -1
  33. package/dist/assets/{flowDiagram-KYDEHFYC-zfLOC9xq.js → flowDiagram-KYDEHFYC-BE_JMKNj.js} +1 -1
  34. package/dist/assets/{ganttDiagram-EK5VF46D-D9CUdOwx.js → ganttDiagram-EK5VF46D-DEt-Ih6b.js} +1 -1
  35. package/dist/assets/{gitGraphDiagram-GW3U2K7C-D-XNvTd9.js → gitGraphDiagram-GW3U2K7C-CGO98bua.js} +1 -1
  36. package/dist/assets/{glide-data-editor-Iz1f1NOi.js → glide-data-editor-Btj-XKB9.js} +4 -4
  37. package/dist/assets/{graph-Chedk9vv.js → graph-DeU2Xth1.js} +1 -1
  38. package/dist/assets/{home-page-CBaSMfGu.js → home-page-IxuRGcj-.js} +1 -1
  39. package/dist/assets/{index-COKnXZm2.js → index-54cg5P1s.js} +1 -1
  40. package/dist/assets/{index-P2Ifc_U7.js → index-B464Wlvo.js} +1 -1
  41. package/dist/assets/{index-D7DYgZ9E.js → index-B72QAiSc.js} +1 -1
  42. package/dist/assets/{index-CPVCa2dz.js → index-B7daay03.js} +11 -11
  43. package/dist/assets/{index-CdPZmS8N.js → index-BU4GASnK.js} +1 -1
  44. package/dist/assets/{index-BYoIq3fA.js → index-BYPCZUa6.js} +1 -1
  45. package/dist/assets/{index-C7oqh1GT.js → index-CRkNsusV.js} +1 -1
  46. package/dist/assets/{index-B_2y4SIt.js → index-CVNzfFlx.js} +1 -1
  47. package/dist/assets/{index-CIooWgUc.js → index-D4QA5nNz.js} +1 -1
  48. package/dist/assets/{index-CBjJLxgV.js → index-DEVD2idU.js} +1 -1
  49. package/dist/assets/{index-CkVqTmEZ.js → index-DFLmyJLh.js} +1 -1
  50. package/dist/assets/{index-DnIAY6gI.js → index-DRnyprVw.js} +1 -1
  51. package/dist/assets/{index-DfeBSlHy.js → index-DbFWJ4Qa.js} +1 -1
  52. package/dist/assets/{index-D6KtMooK.js → index-Dniw7sSM.js} +1 -1
  53. package/dist/assets/{index-DFrRn7CA.js → index-Dql2NySh.js} +1 -1
  54. package/dist/assets/{index-Bz7AXBQe.js → index-_jAr8NM_.js} +1 -1
  55. package/dist/assets/{index-x6nviym0.js → index-g62sB8uq.js} +1 -1
  56. package/dist/assets/{index-8S_1Bwak.js → index-heFumldU.js} +1 -1
  57. package/dist/assets/{index-DWnLMMAM.js → index-vGk4nE_d.js} +1 -1
  58. package/dist/assets/infoDiagram-LHK5PUON-sVWflOQg.js +2 -0
  59. package/dist/assets/{journeyDiagram-EWQZEKCU-86jmDxYR.js → journeyDiagram-EWQZEKCU-DzQqkIOA.js} +1 -1
  60. package/dist/assets/{kanban-definition-ZSS6B67P-CcV25jlk.js → kanban-definition-ZSS6B67P-Cv0lpMrD.js} +1 -1
  61. package/dist/assets/{layout-CFbJTwF1.js → layout-CO5ebI-Y.js} +1 -1
  62. package/dist/assets/{linear-BtOHrJPM.js → linear-CvcTdG5r.js} +1 -1
  63. package/dist/assets/{links-BOMsu5GD.js → links-DAdFQ7bg.js} +1 -1
  64. package/dist/assets/{mermaid-Bo_iqjdJ.js → mermaid-CymwcI3a.js} +4 -4
  65. package/dist/assets/{min-C9AfBTFv.js → min-CTcwszLX.js} +1 -1
  66. package/dist/assets/{mindmap-definition-6CBA2TL7-CtNvR4hi.js → mindmap-definition-6CBA2TL7-B0mxrKt3.js} +1 -1
  67. package/dist/assets/{number-overlay-editor-BBgpgzMw.js → number-overlay-editor-CJPAXVuf.js} +1 -1
  68. package/dist/assets/{pieDiagram-NIOCPIFQ-jmTd3pkw.js → pieDiagram-NIOCPIFQ-C-2hdQUk.js} +1 -1
  69. package/dist/assets/{quadrantDiagram-2OG54O6I-C1AhHMJ4.js → quadrantDiagram-2OG54O6I-CL2YGs4R.js} +1 -1
  70. package/dist/assets/{react-plotly-CmEOpLH4.js → react-plotly-BsLWiFjm.js} +1 -1
  71. package/dist/assets/{requirementDiagram-QOLK2EJ7-cHmpzUIu.js → requirementDiagram-QOLK2EJ7-DQ4L9v8q.js} +1 -1
  72. package/dist/assets/{run-page-Dvdm4kWL.js → run-page-Bx99bWZ3.js} +1 -1
  73. package/dist/assets/{sankeyDiagram-4UZDY2LN-C9gKD1CM.js → sankeyDiagram-4UZDY2LN-BCeK9LuM.js} +1 -1
  74. package/dist/assets/{sequenceDiagram-SKLFT4DO-DzrJkOMo.js → sequenceDiagram-SKLFT4DO-2hUcwiWi.js} +1 -1
  75. package/dist/assets/{slides-component-CK0heWx4.js → slides-component-C4hf0v_2.js} +1 -1
  76. package/dist/assets/{sortBy-CADHTxpN.js → sortBy-DSGu1kis.js} +1 -1
  77. package/dist/assets/{stateDiagram-MI5ZYTHO-D7eKWYt_.js → stateDiagram-MI5ZYTHO-B-C8-fsa.js} +1 -1
  78. package/dist/assets/stateDiagram-v2-5AN5P6BG-Bv5ynAxn.js +1 -0
  79. package/dist/assets/{storage-BnZ6tGDt.js → storage-CssK1tjQ.js} +3 -3
  80. package/dist/assets/{terminal-BertI5HS.js → terminal-BHiJua_p.js} +1 -1
  81. package/dist/assets/{time-DYoBYo9P.js → time-Dq0rcdwf.js} +1 -1
  82. package/dist/assets/{timeline-definition-MYPXXCX6-BQkC8vYS.js → timeline-definition-MYPXXCX6-BwdXyFVw.js} +1 -1
  83. package/dist/assets/{tracing-Ci_pZpdF.js → tracing-erwDcbAl.js} +2 -2
  84. package/dist/assets/{trash-tg_SetZb.js → trash-DEAtdWrd.js} +1 -1
  85. package/dist/assets/{treemap-75Q7IDZK-DDj8-IIS.js → treemap-75Q7IDZK-BoFrERFR.js} +1 -1
  86. package/dist/assets/{vega-component-C6Rt6Z9w.js → vega-component-XnrlJ16r.js} +1 -1
  87. package/dist/assets/{xychartDiagram-H2YORKM3-CgHaR4ZP.js → xychartDiagram-H2YORKM3-BRGXUZ-C.js} +1 -1
  88. package/dist/index.html +1 -1
  89. package/package.json +2 -1
  90. package/dist/assets/_baseMap-BRZYvb4q.js +0 -1
  91. package/dist/assets/channel-zR7-RW0y.js +0 -1
  92. package/dist/assets/classDiagram-M3E45YP4-Cy0TkS9q.js +0 -1
  93. package/dist/assets/classDiagram-v2-YAWTLIQI-Cy0TkS9q.js +0 -1
  94. package/dist/assets/clone-ENI3TzRj.js +0 -1
  95. package/dist/assets/edit-page-BA6CA_l4.js +0 -148
  96. package/dist/assets/infoDiagram-LHK5PUON-DpVArEui.js +0 -2
  97. package/dist/assets/stateDiagram-v2-5AN5P6BG-CrZHhHaw.js +0 -1
@@ -0,0 +1,163 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./tracing-erwDcbAl.js","./index-B7daay03.js","./index-BlxPam9h.css","./compile-CrDOzGvF.js","./time-Dq0rcdwf.js","./timer-BwIYMJWC.js","./linear-CvcTdG5r.js","./init-DLRA0X12.js","./range-CtcPcB_L.js","./zoom-COrs4lFh.js","./ordinal-DDUp3AbE.js","./colors-bszWmPJw.js","./step-BwsUM5iJ.js","./arc-ZB5pDULS.js","./index-BEQfoZiP.js","./storage-CssK1tjQ.js","./index-vGk4nE_d.js","./index-BU4GASnK.js","./index-DbFWJ4Qa.js","./index-DRnyprVw.js","./index-D4QA5nNz.js","./index-_jAr8NM_.js","./index-DEVD2idU.js","./index-CRkNsusV.js","./index-g62sB8uq.js","./index-CVNzfFlx.js","./index-DFLmyJLh.js","./index-B72QAiSc.js","./index-Dniw7sSM.js","./apl-CXdQSnD-.js","./asciiarmor-D5V0T9Cu.js","./asterisk-B46aRdXb.js","./brainfuck-CtZaYBKt.js","./clike-BgBwzOhw.js","./cmake-DXn5xaP-.js","./cobol-stawOqaz.js","./coffeescript-BTDxI-eT.js","./commonlisp-vq6DHwts.js","./crystal-CRzZ78HM.js","./cypher-gJDei3ni.js","./d-BShv7fp-.js","./diff-UJJ5BM9S.js","./dockerfile-knGOOxt4.js","./simple-mode-C3vEBAcb.js","./dtd-DI9Herc-.js","./dylan-DkEP81N9.js","./ebnf-B-Df8AvO.js","./ecl-DPFc0Uaf.js","./eiffel-DR5c0IrL.js","./elm-DompmV0j.js","./erlang-BuqgqA5h.js","./factor-CFXhaUWb.js","./fcl-CVaBTCzQ.js","./forth-POgR1ypr.js","./fortran-DL7KluxX.js","./gas-bV0CklSb.js","./gherkin-B6X1vGSW.js","./groovy-DnIzCrpZ.js","./haskell-CLQs6EAM.js","./haxe-D25e-2l-.js","./http-BKJkqRj4.js","./idl-pcmmZuaN.js","./jinja2-DhgKlfW7.js","./julia-DjdwvFuI.js","./livescript-HO6ttBFx.js","./lua-8DXOpKDz.js","./mathematica-IIbmv7SK.js","./mbox-z_N2Mo3d.js","./mirc-DkvFAiy5.js","./modelica-DSrSSXCg.js","./mscgen-B2igx18G.js","./mumps-zvxmGV4l.js","./nginx-B4hAVlXN.js","./nsis-BvKfQ9lQ.js","./ntriples-BSwWqoLa.js","./octave-C4hdQ5Hf.js","./oz-qQq7irPq.js","./pascal-CafrKXZF.js","./perl-tdMlh9QA.js","./pig-CwGJVRC4.js","./powershell-D1ly3AHC.js","./properties-_nPj978X.js","./protobuf-B4y9do6W.js","./puppet-Bc-yJKzi.js","./q-B0kTJ4cI.js","./r-BA4EbLKE.js","./ruby-CR-u2WLS.js","./sas-Bqaci40L.js","./scheme-qjP0V5Ag.js","./shell-BLav31RL.js","./sieve-r025o_jW.js","./smalltalk-C7J3IyEP.js","./solr-78MBEUkU.js","./sparql-BRLJFz69.js","./spreadsheet-CGlWr0eM.js","./stylus-Bdo_Aemu.js","./swift-B_XXVlXX.js","./tcl-B2fODqDH.js","./textile-BuVhTOzU.js","./tiddlywiki-BgR6AEZu.js","./tiki-CI-ztowC.js","./toml-wcPdHu67.js","./troff-Ce85hlLp.js","./ttcn-BxnYHtq8.js","./turtle-BkSuIpt-.js","./vb-BHgjm0DN.js","./vbscript-Dawdd5GZ.js","./velocity-BdD_26Jv.js","./verilog-B4LBqg_1.js","./vhdl-CWWH2SUo.js","./webidl-CGwyPRYs.js","./xquery-CVDBqZPY.js","./yacas-I8QjZlxf.js","./z80-D8p3gKXp.js","./trash-DEAtdWrd.js","./storage-B6yZpgAI.css","./links-DAdFQ7bg.js","./index-B464Wlvo.js","./links-Dn1Stwqz.css","./circle-play-chxJxn_k.js","./_createAggregator-CYM_3WAb.js","./_baseEach-C_3O_UIK.js","./loro_wasm_bg-C3hKWL9L.js","./transform-B8bpuzxV.js","./sortBy-DSGu1kis.js","./_baseMap-ejDdVnUU.js","./terminal-BHiJua_p.js","./terminal-B3isKKSk.css"])))=>i.map(i=>d[i]);
2
+ var TO=Object.defineProperty;var a3=Mt=>{throw TypeError(Mt)};var MO=(Mt,kt,nn)=>kt in Mt?TO(Mt,kt,{enumerable:!0,configurable:!0,writable:!0,value:nn}):Mt[kt]=nn;var Z=(Mt,kt,nn)=>MO(Mt,typeof kt!="symbol"?kt+"":kt,nn),OO=(Mt,kt,nn)=>kt.has(Mt)||a3("Cannot "+nn);var l3=(Mt,kt,nn)=>(OO(Mt,kt,"read from private field"),nn?nn.call(Mt):kt.get(Mt)),c3=(Mt,kt,nn)=>kt.has(Mt)?a3("Cannot add the same private member more than once"):kt instanceof WeakSet?kt.add(Mt):kt.set(Mt,nn);import{c as Ee,is as pr,it as DO,iu as am,iv as RO,iw as PO,ix as d3,iy as u3,iz as ec,U as M,iA as LO,iB as FO,iC as h3,iD as zO,dH as BO,dK as UO,b as q,dF as lm,a as H,T as tt,ac as Je,j as u,a1 as Fn,a9 as Wo,a8 as cs,aa as ds,bn as qo,a6 as ve,ab as sn,iE as Oi,a7 as Go,aS as zn,ad as Di,at as Ne,ao as jt,dY as cm,eM as Ri,iF as $O,aN as Le,S as lt,iG as VO,e_ as bn,iH as f3,iI as m3,iJ as tc,iK as p3,L as mt,dx as nc,aX as Yo,iL as oc,aZ as dm,ag as tn,iM as HO,aw as Pi,iN as WO,iO as g3,eZ as x3,al as vt,b4 as b3,iP as y3,cA as rc,iQ as qO,dP as Qe,iR as sc,dW as In,iS as Li,V as je,b9 as An,iT as ic,iU as ac,eP as us,iV as GO,iW as Fi,iX as v3,eX as w3,iY as um,iZ as hm,ep as fm,i_ as Jn,i$ as gr,aV as lc,j0 as YO,j1 as cc,j2 as dc,au as No,ed as k3,av as zi,j3 as KO,j4 as uc,bp as xr,eQ as br,ft as C3,bd as Dt,j5 as XO,j6 as JO,ga as hc,aP as fc,j7 as mm,j8 as ZO,j9 as j3,ja as pm,jb as QO,jc as gm,jd as Zn,je as S3,gc as xm,jf as Bi,jg as mc,eu as ht,ew as hs,jh as gt,ji as ze,jj as at,jk as bm,jl as eD,jm as ym,jn as xt,jo as N3,dr as Ui,dm as $i,dn as Vi,dp as Hi,dl as fs,fG as vm,b3 as Bn,aJ as Tn,fw as E3,fy as _3,fz as tD,fE as nD,fA as I3,jp as A3,ar as xe,eo as oD,b1 as Eo,a$ as _o,b2 as Io,a_ as At,eY as an,jq as T3,fC as M3,jr as rD,js as sD,fu as O3,fv as D3,jt as ms,dq as R3,ju as P3,jv as iD,jw as aD,a5 as lD,a4 as cD,jx as wm,du as dD,dw as km,fh as pc,jy as gc,jz as xc,bs as yn,eT as Wi,fe as ln,bi as L3,dZ as Bt,ej as uD,a2 as Cm,jA as qi,jB as bc,jC as hD,jD as fD,jE as F3,a3 as mD,ae as Gi,eJ as z3,jF as Gt,aW as pD,af as jm,gf as B3,eq as yc,jG as gD,gz as Sm,bh as vc,bk as xD,jH as bD,jI as U3,gJ as yD,gH as vD,gK as wD,gL as kD,jJ as Nm,ds as Un,jK as CD,jL as wc,jM as ps,q as Qn,o as We,fX as $n,jN as vn,jO as ot,jP as gs,jQ as Tt,gb as Rt,jR as Em,et as wn,jS as jD,jT as _m,bf as $3,bg as V3,jU as SD,gB as xs,jV as kc,bc as Cc,gC as yr,e$ as Im,jW as ND,jX as H3,jY as Yi,jZ as W3,j_ as Am,j$ as q3,k0 as G3,k1 as Y3,k2 as K3,f0 as Tm,k3 as ED,k4 as eo,k5 as jc,k6 as X3,dt as J3,k7 as Sc,gw as Mm,k8 as Ki,k9 as Xi,ka as Ji,kb as Nc,kc as Ko,kd as Z3,ke as Ao,kf as bs,kg as Om,kh as Zi,ki as ys,kj as Dm,kk as Rm,kl as Q3,km as Ec,kn as _D,ay as Qi,ko as ea,kp as ID,dV as _c,kq as AD,kr as Pm,ks as TD,kt as MD,ku as Ic,e2 as OD,kv as vr,kw as Ac,kx as vs,fW as Mn,g4 as To,fS as eC,cl as tC,ky as Lm,fF as nC,eI as oC,kz as rC,kA as ta,kB as sC,kC as Tc,kD as Fm,kE as ws,kF as na,kG as oa,kH as DD,fO as Mc,kI as zm,kJ as Oc,ei as RD,fP as PD,kK as LD,kL as FD,kM as zD,kN as BD,u as UD,kO as $D,kP as VD,kQ as HD,f_ as WD,kR as qD,kS as iC,t as F,kT as GD,kU as YD,kV as KD,kW as XD,kX as JD,kY as ZD,kZ as QD,k_ as eR,k$ as tR,l0 as nR,l1 as oR,l2 as rR,l3 as sR,l4 as iR,l5 as aR,l6 as lR,l7 as cR,l8 as dR,l9 as uR,la as hR,lb as fR,lc as mR,ld as ra,le as pR,lf as gR,lg as xR,lh as bR,li as yR,lj as vR,lk as wR,ll as kR,lm as Bm,ln as Dc,lo as aC,lp as CR,lq as jR,lr as lC,ls as SR,lt as ks,lu as On,lv as NR,lw as ER,lx as _R,ly as IR,lz as AR,lA as TR,lB as MR,lC as OR,lD as DR,lE as RR,lF as Xo,lG as PR,lH as LR,lI as FR,lJ as zR,d$ as BR,lK as UR,lL as cC,e3 as $R,lM as Rc,lN as VR,lO as HR,lP as WR,lQ as qR,gM as Jo,lR as Pc,lS as GR,lT as YR,lU as dC,lV as Um,gA as Cs,lW as KR,lX as XR,lY as JR,lZ as sa,l_ as ia,eW as $m,l$ as ZR,g3 as QR,bm as eP,an as Vm,m0 as uC,m1 as tP,m2 as nP,m3 as Hm,m4 as Wm,m5 as oP,m6 as hC,m7 as fC,m8 as Lc,fR as rP,Y as mC,dN as sP,m9 as pC,fr as wt,ma as aa,mb as js,mc as iP,md as aP,me as lP,mf as cP,ck as qm,mg as dP,am as Zo,be as gC,mh as uP,mi as hP,mj as fP,mk as Fc,ml as xC,dL as zc,bo as bC,ev as mP,mm as yC,mn as vC,mo as wC,mp as pP,mq as kC,mr as CC,ms as la,mt as gP,mu as jC,mv as xP,mw as bP,mx as SC,Z as Bc,my as yP,bq as NC,mz as vP,as as Mo,mA as wP,mB as ca,mC as kP,mD as EC,eV as _C,fI as Uc,mE as Gm,aU as Ym,en as $c,em as Km,mF as CP,eS as IC,mG as jP,mH as AC,fq as SP,mI as NP,gr as EP,fx as _P,fB as Xm,gu as IP,bl as da,mJ as TC,mK as Jm,mL as AP,mM as TP,mN as MP,_ as kn,er as OP,mO as DP,mP as RP,mQ as MC,fj as Zm,dz as OC,mR as PP,aq as wr,mS as LP,mT as FP,mU as zP,aO as BP,mV as UP,mW as $P,mX as VP,W as HP,mY as Vc,ff as WP,mZ as DC,fM as qP,gj as GP,m_ as YP,m$ as RC,n0 as KP,n1 as Ss,n2 as XP,n3 as Hc,n4 as JP,n5 as ZP,n6 as QP,z as PC,gF as eL,n7 as ua,n8 as LC,n9 as FC,na as zC,nb as BC,nc as tL,C as UC,nd as nL,ne as oL,nf as rL,E as kr,f5 as $C,bb as sL,b8 as iL,ng as aL,nh as lL,ni as cL,dC as VC,nj as Qm,nk as dL,dX as HC,nl as uL,nm as ep,nn as hL,no as fL,np as mL,nq as WC,nr as qC,ns as GC,fd as YC,nt as pL,nu as gL,nv as KC,nw as XC,nx as Wc,ny as JC,nz as ZC,nA as QC,nB as xL,nC as bL,nD as ej,nE as yL,nF as vL,nG as wL,nH as kL,nI as CL,nJ as jL,dU as SL,nK as NL,nL as EL,nM as _L,nN as IL,nO as AL,nP as TL,nQ as ML,nR as OL,nS as DL,nT as RL,nU as PL,fU as LL,nV as FL,nW as zL,nX as tj,nY as BL,ax as UL,nZ as $L,ap as VL,eL as HL,n_ as WL,gm as tp,gk as Ns,gn as Cr,gl as jr,go as np,gp as op,n$ as nj,o0 as oj,o1 as rj,o2 as Qo,gt as qL,o3 as GL,o4 as YL,o5 as KL,o6 as XL,o7 as JL,o8 as sj,eA as ZL,o9 as rp,oa as QL,ah as qc,ob as ij,oc as aj,aj as lj,ai as eF,dT as tF,__tla as nF}from"./index-B7daay03.js";import{b as Es,A as oF,L as cj,g as rF,G as sF,o as dj,s as iF,k as aF,B as uj,a as lF,M as cF,Y as dF,c as cn,u as ha,C as uF,S as hF,K as fF,d as mF,i as pF,e as hj,f as gF,h as xF,j as fa,P as ma,l as fj,m as bF,n as yF,p as vF,D as _s,q as wF,r as mj,t as sp,T as kF}from"./links-DAdFQ7bg.js";import{V as pj,d as Sr,I as ip,N as gj,S as xj,e as bj,f as yj,L as vj,g as wj,F as kj,M as CF,l as Cj,h as jF,E as Gc,i as SF,j as ap,k as lp,n as NF,o as EF,p as _F,q as IF,s as AF,t as TF,v as MF,w as OF,u as DF,C as RF,R as jj,A as PF,a as LF,T as FF,x as zF,y as BF,m as UF,z as $F,B as VF,O as HF,c as WF,P as qF,__tla as GF}from"./storage-CssK1tjQ.js";import{c as YF}from"./_createAggregator-CYM_3WAb.js";import{_ as Sj,a as Nj,i as KF,w as XF,L as Ej,A as JF,C as _j,b as cp,c as Ij,__tla as ZF}from"./loro_wasm_bg-C3hKWL9L.js";import{s as Vn,i as er,T as dp,a as up}from"./transform-B8bpuzxV.js";import{g as Aj}from"./timer-BwIYMJWC.js";import{i as QF}from"./zoom-COrs4lFh.js";import{s as pa}from"./sortBy-DSGu1kis.js";let hp,Yc,dn,Kc,Tj,Is,ez=Promise.all([(()=>{try{return nF}catch{}})(),(()=>{try{return GF}catch{}})(),(()=>{try{return ZF}catch{}})()]).then(async()=>{var Ql,r3;var Mt=YF(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]});let kt,nn,fp,Xc,As,Nr,Jc,Zc,mp,pp,ga,Qc,gp,xa,xp,ed,bp,yp,td,vp,wp,kp,ba,Cp,nd,jp,Sp,Np,Ep,_p,Ip,od,Ap,rd,sd,Tp,Mp,Op,Dp,Rp,Pp,ya,Lp,Fp,id,zp,Bp,Up,ad,$p,Vp,Hp,va,ld,cd,Wp,qp,Gp,Yp,Kp,Xp,Jp,Zp,Qp,dd,ud,eg,tg,ng,wa,un,hn;kt=Ee("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),nn=Ee("arrow-right-to-line",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]),fp=Ee("arrow-right-from-line",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M21 12H7",key:"13ipq5"}],["path",{d:"m15 18 6-6-6-6",key:"6tx3qv"}]]),Xc=Ee("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),As=Ee("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]),Nr=Ee("between-horizontal-start",[["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"}]]),Jc=Ee("chevrons-down",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]),Zc=Ee("chevrons-up",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]),Kc=Ee("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),mp=Ee("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),pp=Ee("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),ga=Ee("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Qc=Ee("clipboard-copy",[["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"}]]),gp=Ee("clipboard-paste",[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]),xa=Ee("cloud-download",[["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"}]]),xp=Ee("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),ed=Ee("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"}]]),bp=Ee("copy-minus",[["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"}]]),yp=Ee("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),td=Ee("ellipsis-vertical",[["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"}]]),vp=Ee("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),wp=Ee("fast-forward",[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]]),kp=Ee("file-pen",[["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"}]]),ba=Ee("file-plus-2",[["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"}]]),Cp=Ee("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"}]]),nd=Ee("folder-plus",[["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"}]]),jp=Ee("folder-tree",[["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"}]]),Sp=Ee("grip-vertical",[["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"}]]),Np=Ee("hard-drive-download",[["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"}]]),Ep=Ee("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"}]]),_p=Ee("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"}]]),Ip=Ee("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),od=Ee("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),Ap=Ee("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"}]]),rd=Ee("layout-template",[["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=Ee("list-tree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]),Tp=Ee("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"}]]),Mp=Ee("map-pin",[["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"}]]),Op=Ee("map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]),Dp=Ee("memory-stick",[["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"}]]),Rp=Ee("message-circle-question-mark",[["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"}]]),Pp=Ee("microchip",[["path",{d:"M18 12h2",key:"quuxs7"}],["path",{d:"M18 16h2",key:"zsn3lv"}],["path",{d:"M18 20h2",key:"9x5y9y"}],["path",{d:"M18 4h2",key:"1luxfb"}],["path",{d:"M18 8h2",key:"nxqzg"}],["path",{d:"M4 12h2",key:"1ltxp0"}],["path",{d:"M4 16h2",key:"8a5zha"}],["path",{d:"M4 20h2",key:"27dk57"}],["path",{d:"M4 4h2",key:"10groj"}],["path",{d:"M4 8h2",key:"18vq6w"}],["path",{d:"M8 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-1.5c-.276 0-.494.227-.562.495a2 2 0 0 1-3.876 0C9.994 2.227 9.776 2 9.5 2z",key:"1681fp"}]]),ya=Ee("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"}]]),Lp=Ee("octagon-alert",[["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"}]]),Fp=Ee("package-check",[["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"}]]),id=Ee("package-x",[["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"}]]),zp=Ee("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Bp=Ee("party-popper",[["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"}]]),Up=Ee("pen-line",[["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"}]]),ad=Ee("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"}]]),$p=Ee("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"}]]),Vp=Ee("rotate-ccw",[["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"}]]),Hp=Ee("rows-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]),va=Ee("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"}]]),ld=Ee("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"}]]),cd=Ee("scroll-text",[["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"}]]),Wp=Ee("share-2",[["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"}]]),qp=Ee("square-code",[["path",{d:"m10 9-3 3 3 3",key:"1oro0q"}],["path",{d:"m14 15 3-3-3-3",key:"bz13h7"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Gp=Ee("square-dashed-bottom-code",[["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"}]]),Yp=Ee("square-equal",[["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"}]]),Kp=Ee("square-m",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]),Xp=Ee("square-play",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 8 6 4-6 4Z",key:"f1r3lt"}]]),Jp=Ee("square-power",[["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"}]]),Zp=Ee("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),Qp=Ee("text-cursor-input",[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]]),dd=Ee("text-search",[["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"}]]),ud=Ee("undo-2",[["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"}]]),eg=Ee("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),tg=Ee("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"}]]),ng=Ee("whole-word",[["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"}]]),wa=Ee("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"}]]),un=Ee("zap-off",[["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"}]]),hn=Ee("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"}]]);function ka(t,e){const n=+pr(t)-+pr(e);return n<0?-1:n>0?1:n}function Mj(t,e){const n=pr(t,e==null?void 0:e.in);return+function(o,r){const s=pr(o,r==null?void 0:r.in);return s.setHours(23,59,59,999),s}(n,e)==+function(o,r){const s=pr(o,r==null?void 0:r.in),i=s.getMonth();return s.setFullYear(s.getFullYear(),i+1,0),s.setHours(23,59,59,999),s}(n,e)}function Oj(t,e,n){const[o,r,s]=am(n==null?void 0:n.in,t,t,e),i=ka(r,s),a=Math.abs(function(d,h,f){const[m,g]=am(f==null?void 0:f.in,d,h);return 12*(m.getFullYear()-g.getFullYear())+(m.getMonth()-g.getMonth())}(r,s));if(a<1)return 0;r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-i*a);let l=ka(r,s)===-i;Mj(o)&&a===1&&ka(o,s)===1&&(l=!1);const c=i*(a-+l);return c===0?0:c}function Dj(t,e,n){const o=function(r,s){return+pr(r)-+pr(s)}(t,e)/1e3;return(r=>{const s=(0,Math.trunc)(r);return s===0?0:s})(o)}function Rj(t,e){return function(n,o,r){const s=RO(),i=(r==null?void 0:r.locale)??s.locale??PO,a=ka(n,o);if(isNaN(a))throw new RangeError("Invalid time value");const l=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:a}),[c,d]=am(r==null?void 0:r.in,...a>0?[o,n]:[n,o]),h=Dj(d,c),f=(d3(d)-d3(c))/1e3,m=Math.round((h-f)/60);let g;if(m<2)return m===0?i.formatDistance("lessThanXMinutes",1,l):i.formatDistance("xMinutes",m,l);if(m<45)return i.formatDistance("xMinutes",m,l);if(m<90)return i.formatDistance("aboutXHours",1,l);if(m<u3){const x=Math.round(m/60);return i.formatDistance("aboutXHours",x,l)}if(m<2520)return i.formatDistance("xDays",1,l);if(m<ec){const x=Math.round(m/u3);return i.formatDistance("xDays",x,l)}if(m<2*ec)return g=Math.round(m/ec),i.formatDistance("aboutXMonths",g,l);if(g=Oj(d,c),g<12){const x=Math.round(m/ec);return i.formatDistance("xMonths",x,l)}{const x=g%12,p=Math.trunc(g/12);return x<3?i.formatDistance("aboutXYears",p,l):x<9?i.formatDistance("overXYears",p,l):i.formatDistance("almostXYears",p+1,l)}}(t,function(n){return DO(n,Date.now())}(t),e)}const Pj=M.createContext({}),Lj=M.forwardRef(function(t,e){[t,e]=BO(t,e,Pj);let{toolbarProps:n}=function(s,i){const{"aria-label":a,"aria-labelledby":l,orientation:c="horizontal"}=s;let[d,h]=M.useState(!1);LO(()=>{var p;h(!(!i.current||!(!((p=i.current.parentElement)===null||p===void 0)&&p.closest('[role="toolbar"]'))))});const{direction:f}=FO(),m=f==="rtl"&&c==="horizontal";let g=zO(i);const x=M.useRef(null);return{toolbarProps:{...h3(s,{labelable:!0}),role:d?"group":"toolbar","aria-orientation":c,"aria-label":a,"aria-labelledby":a==null?l:void 0,onKeyDownCapture:d?void 0:p=>{if(p.currentTarget.contains(p.target)){if(c==="horizontal"&&p.key==="ArrowRight"||c==="vertical"&&p.key==="ArrowDown")m?g.focusPrevious():g.focusNext();else{if(!(c==="horizontal"&&p.key==="ArrowLeft"||c==="vertical"&&p.key==="ArrowUp"))return p.key==="Tab"?(p.stopPropagation(),x.current=document.activeElement,void(p.shiftKey?g.focusFirst():g.focusLast())):void 0;m?g.focusNext():g.focusPrevious()}p.stopPropagation(),p.preventDefault()}},onFocusCapture:d?void 0:p=>{var b,y;x.current&&!p.currentTarget.contains(p.relatedTarget)&&(!((b=i.current)===null||b===void 0)&&b.contains(p.target))&&((y=x.current)===null||y===void 0||y.focus(),x.current=null)},onBlurCapture:d?void 0:p=>{p.currentTarget.contains(p.relatedTarget)||x.current||(x.current=p.target)}}}}(t,e),o=UO({...t,values:{orientation:t.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),r=h3(t);return delete r.id,q.createElement("div",{...lm(n,r),...o,ref:e,slot:t.slot||void 0,"data-orientation":t.orientation||"horizontal"},o.children)}),Ca="https://static.marimo.app",Fj=t=>{const e=H.c(25),{onClose:n}=t,[o,r]=M.useState(""),{exportAsHTML:s}=tt();let i;i=Math.random().toString(36).slice(2,6);const a=`${o}-${i}`,l=`${Ca}/static/${a}`;let c,d,h,f,m,g,x,p,b,y,v;return e[0]!==s||e[1]!==n||e[2]!==a?(c=async w=>{w.preventDefault(),n();const S=await s({download:!1,includeCode:!0,files:pj.INSTANCE.filenames()}),C=Je({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Ca}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:S,path:a})}).catch(()=>{C.dismiss(),Je({title:"Error uploading static page",description:u.jsxs("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",u.jsx("a",{href:Fn.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),C.dismiss(),Je({title:"Static page uploaded!",description:u.jsxs("div",{children:["The URL has been copied to your clipboard.",u.jsx("br",{}),"You can share it with anyone."]})})},e[0]=s,e[1]=n,e[2]=a,e[3]=c):c=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx(Wo,{children:"Share static notebook"}),e[4]=d):d=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(h=u.jsxs(cs,{children:[d,u.jsxs(ds,{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"," ",u.jsx("a",{href:Ca,target:"_blank",children:Ca}),"."]})]}),e[5]=h):h=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(f=w=>{const S=w.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,"");r(S)},e[6]=f):f=e[6],e[7]!==o?(m=u.jsx(qo,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:f,required:!0,autoComplete:"off"}),e[7]=o,e[8]=m):m=e[8],e[9]!==l?(g=u.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:",u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(zj,{text:l}),u.jsx("span",{className:"text-primary",children:l})]})]}),e[9]=l,e[10]=g):g=e[10],e[11]!==m||e[12]!==g?(x=u.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[m,g]}),e[11]=m,e[12]=g,e[13]=x):x=e[13],e[14]!==n?(p=u.jsx(ve,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),e[14]=n,e[15]=p):p=e[15],e[16]!==l?(b=u.jsx(ve,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await sn(l)},children:"Create"}),e[16]=l,e[17]=b):b=e[17],e[18]!==b||e[19]!==p?(y=u.jsxs(Oi,{children:[p,b]}),e[18]=b,e[19]=p,e[20]=y):y=e[20],e[21]!==y||e[22]!==c||e[23]!==x?(v=u.jsx(Go,{className:"w-fit",children:u.jsxs("form",{onSubmit:c,children:[h,x,y]})}),e[21]=y,e[22]=c,e[23]=x,e[24]=v):v=e[24],v},zj=t=>{const e=H.c(8),[n,o]=q.useState(!1);let r;e[0]!==t.text?(r=zn.stopPropagation(async c=>{c.preventDefault(),await sn(t.text),o(!0),setTimeout(()=>o(!1),2e3)}),e[0]=t.text,e[1]=r):r=e[1];const s=r;let i,a,l;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=u.jsx(Di,{size:14,strokeWidth:1.5}),e[2]=i):i=e[2],e[3]!==s?(a=u.jsx(ve,{"data-testid":"copy-static-notebook-url-button",onClick:s,size:"xs",variant:"secondary",children:i}),e[3]=s,e[4]=a):a=e[4],e[5]!==n||e[6]!==a?(l=u.jsx(Ne,{content:"Copied!",open:n,children:a}),e[5]=n,e[6]=a,e[7]=l):l=e[7],l};function og(){const t=H.c(2),e=jt(cm);let n;return t[0]!==e?(n=()=>{const o=document.getElementsByClassName("output-area"),r=window.innerHeight||document.documentElement.clientHeight;let s=null;for(const i of Array.from(o)){const a=i.getBoundingClientRect();if(a.top>=0&&a.top<=r||a.bottom>=0&&a.bottom<=r){s=Ri.parse(i.parentNode.id);break}}e(i=>({mode:$O(i.mode),cellAnchor:s})),requestAnimationFrame(()=>{var i;s!==null&&((i=document.getElementById(Ri.create(s)))==null||i.scrollIntoView())})},t[0]=e,t[1]=n):n=t[1],n}function hd(t){const e=H.c(3),n=Ts();let o;return e[0]!==t||e[1]!==n?(o=()=>{t!==void 0&&n([t])},e[0]=t,e[1]=n,e[2]=o):o=e[2],Le(o)}function rg(){const t=H.c(2),e=Ts();let n;return t[0]!==e?(n=()=>e(f3(bn())),t[0]=e,t[1]=n):n=t[1],Le(n)}function Ts(){const t=H.c(3),{prepareForRun:e}=lt(),{sendRun:n}=tt();let o;return t[0]!==e||t[1]!==n?(o=async r=>{var l,c;if(r.length===0)return;const{cellHandles:s,cellData:i}=bn(),a=[];for(const d of r){const h=s[d],f=(l=h==null?void 0:h.current)==null?void 0:l.editorView;let m;f?(m3(f)!=="markdown"&&tc(f),m=p3(f)):m=((c=i[d])==null?void 0:c.code)||"",a.push(m),e({cellId:d})}await n({cellIds:r,codes:a}).catch(Bj)},t[0]=e,t[1]=n,t[2]=o):o=t[2],Le(o)}function Bj(t){mt.error(t)}const fd=[{type:"files",Icon:jp,tooltip:"View files",position:"sidebar"},{type:"variables",Icon:nc,tooltip:"Explore variables",position:"sidebar"},{type:"datasources",Icon:Yo,tooltip:"Explore data sources",position:"sidebar"},{type:"dependencies",Icon:ya,tooltip:"Explore dependencies",position:"sidebar"},{type:"packages",Icon:Es,tooltip:"Manage packages",position:"sidebar"},{type:"outline",Icon:cd,tooltip:"View outline",position:"sidebar"},{type:"chat",Icon:oc,tooltip:"Chat with AI",position:"sidebar"},{type:"documentation",Icon:dd,tooltip:"View live docs",position:"sidebar"},{type:"logs",Icon:dm,tooltip:"Notebook logs",position:"sidebar"},{type:"tracing",Icon:oF,tooltip:"Tracing",position:"sidebar"},{type:"snippets",Icon:Gp,tooltip:"Snippets",position:"sidebar"},{type:"secrets",Icon:Ip,tooltip:"Secrets",hidden:tn(),position:"sidebar"},{type:"scratchpad",Icon:HO,tooltip:"Scratchpad",position:"sidebar"},{type:"errors",Icon:Pi,tooltip:"View errors",position:"footer"}];function Uj(){const t=H.c(7);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];const[n,o]=function(i,a){const l=H.c(11);let c;l[0]!==a?(c=new WO(a),l[0]=a,l[1]=c):c=l[1];const d=c;let h;l[2]!==i||l[3]!==d?(h=()=>d.get(i),l[2]=i,l[3]=d,l[4]=h):h=l[4];const[f,m]=M.useState(h);let g;l[5]!==i||l[6]!==d?(g=b=>{m(b),d.set(i,b)},l[5]=i,l[6]=d,l[7]=g):g=l[7];const x=g;let p;return l[8]!==x||l[9]!==f?(p=[f,x],l[8]=x,l[9]=f,l[10]=p):p=l[10],p}("marimo:commands",e);let r,s;return t[1]!==n||t[2]!==o?(r=i=>{const a=(l=[i,...n],[...new Set(l)]);var l;o(a.slice(0,3))},t[1]=n,t[2]=o,t[3]=r):r=t[3],t[4]!==n||t[5]!==r?(s={recentCommands:n,addRecentCommand:r},t[4]=n,t[5]=r,t[6]=s):s=t[6],s}function sg(t){return t.dropdown!==void 0}function ja(t,e=""){return t.flatMap(n=>n.label?sg(n)?ja(n.dropdown,`${e+n.label} > `):{...n,label:e+n.label}:[])}const Ms=t=>{const e=H.c(8),{children:n,layerTop:o}=t,r=o!==void 0&&o;let s;e[0]!==n?(s=q.Children.toArray(n),e[0]=n,e[1]=s):s=e[1];const[i,a]=s,l=`second-icon absolute ${r?"top-[-2px] left-[-2px]":"bottom-[-2px] right-[-2px]"} rounded-full`;let c,d;return e[2]!==a||e[3]!==l?(c=u.jsx("div",{className:l,children:a}),e[2]=a,e[3]=l,e[4]=c):c=e[4],e[5]!==i||e[6]!==c?(d=u.jsxs("div",{className:"multi-icon relative w-fit",children:[i,c]}),e[5]=i,e[6]=c,e[7]=d):d=e[7],d},Os=vt(null),$j=vt(!1),md=b3("marimo:ai:chatState:v3",{chats:[],activeChatId:null}),Vj=vt(t=>{const e=t(md);return e.chats.find(n=>n.id===e.activeChatId)},(t,e,n)=>{e(md,o=>({...o,activeChatId:n}))});function ig(t){return t!==y3&&!!(t&&t.trim().length>0)}const Sa=t=>{const e=H.c(7);let n,o;e[0]!==t?(n=a=>{var l;(a.ctrlKey||a.metaKey)&&a.key==="z"&&(a.preventDefault(),a.stopPropagation(),(l=t.onClick)==null||l.call(t,a))},e[0]=t,e[1]=n):n=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(o={capture:!0},e[2]=o):o=e[2],rc(window,"keydown",n,o);const r=t.children??"Undo";let s,i;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=u.jsx(qO,{className:"ml-2",shortcut:"cmd-z"}),e[3]=s):s=e[3],e[4]!==r||e[5]!==t?(i=u.jsxs(ve,{"data-testid":"undo-button",size:"sm",variant:"outline",...t,children:[r," ",s]}),e[4]=r,e[5]=t,e[6]=i):i=e[6],i};function Ds(){const t=H.c(4),{deleteCell:e,undoDeleteCell:n}=lt(),{sendDeleteCell:o}=tt();let r;return t[0]!==e||t[1]!==o||t[2]!==n?(r=s=>{var c;if(Qe.get(sc))return;const{cellId:i}=s,a=Qe.get(In),l=(((c=a.cellData[i])==null?void 0:c.code)??"").trim()==="";if(e({cellId:i}),o({cellId:i}).catch(()=>{n()}),!l){const{dismiss:d}=Je({title:"Cell deleted",description:"You can bring it back by clicking undo or through the command palette.",action:u.jsx(Sa,{"data-testid":"undo-delete-button",onClick:()=>{n(),h()}})}),h=d}},t[0]=e,t[1]=o,t[2]=n,t[3]=r):r=t[3],Le(r)}function Rs(){const t=H.c(4),{deleteCell:e,undoDeleteCell:n}=lt(),{sendDeleteCell:o}=tt();let r;return t[0]!==e||t[1]!==o||t[2]!==n?(r=async s=>{if(Qe.get(sc))return;const{cellIds:i}=s;for(const c of i)await o({cellId:c}).then(()=>{e({cellId:c})});const{dismiss:a}=Je({title:"Cells deleted",action:u.jsx(Sa,{"data-testid":"undo-delete-button",onClick:()=>{for(const c of i)n();l()}})}),l=a},t[0]=e,t[1]=o,t[2]=n,t[3]=r):r=t[3],Le(r)}function ag(){const t=H.c(3),{splitCell:e,undoSplitCell:n}=lt();let o;return t[0]!==e||t[1]!==n?(o=r=>{const s=Li(r.cellId);if(!s)return;const i=p3(s);e(r);const{dismiss:a}=Je({title:"Cell split",action:u.jsx(Sa,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{n({...r,snapshot:i}),l()},children:"Undo"})}),l=a},t[0]=e,t[1]=n,t[2]=o):o=t[2],Le(o)}function pd(t){const e=H.c(51),{cell:n}=t,{createNewCell:o,updateCellConfig:r,updateCellName:s,moveCell:i,sendToTop:a,sendToBottom:l,addColumnBreakpoint:c,clearCellOutput:d}=lt(),h=ag(),f=hd(n==null?void 0:n.cellId),m=!je(sc),g=Ds(),{openModal:x}=An(),p=jt(Os),b=je(ic),y=je(ac),v=je(us),w=je(GO),{saveCellConfig:S}=tt();if(!n||v){let U;return e[0]===Symbol.for("react.memo_cache_sentinel")?(U=[],e[0]=U):U=e[0],U}const{cellId:C,config:N,getEditorView:j,name:E,hasOutput:T,hasConsoleOutput:I,status:O}=n;let L;e[1]!==C||e[2]!==N.disabled||e[3]!==S||e[4]!==r?(L=async()=>{const U={disabled:!N.disabled};await S({configs:{[C]:U}}),r({cellId:C,config:U})},e[1]=C,e[2]=N.disabled,e[3]=S,e[4]=r,e[5]=L):L=e[5];const D=L;let R;e[6]!==C||e[7]!==N.hide_code||e[8]!==j||e[9]!==S||e[10]!==r?(R=async()=>{const U={hide_code:!N.hide_code};await S({configs:{[C]:U}}),r({cellId:C,config:U});const $=j();$&&(U.hide_code?$.contentDOM.blur():$.focus())},e[6]=C,e[7]=N.hide_code,e[8]=j,e[9]=S,e[10]=r,e[11]=R):R=e[11];const P=R;let z,_,k,B,A;return e[12]===Symbol.for("react.memo_cache_sentinel")?(z=u.jsx(Qp,{size:13,strokeWidth:1.5}),e[12]=z):z=e[12],e[13]!==C||e[14]!==E||e[15]!==x||e[16]!==s?(_=()=>{x(u.jsxs(Go,{children:[u.jsx(cs,{children:u.jsx(Wo,{children:"Rename cell"})}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(xr,{htmlFor:"cell-name",children:"Cell name"}),u.jsx(gj,{placeholder:"cell name",value:E,onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),U.stopPropagation(),x(null))},onChange:U=>s({cellId:C,name:U})})]})]}))},e[13]=C,e[14]=E,e[15]=x,e[16]=s,e[17]=_):_=e[17],e[18]!==C||e[19]!==s?(k=U=>s({cellId:C,name:U}),e[18]=C,e[19]=s,e[20]=k):k=e[20],e[21]!==E||e[22]!==k?(B=u.jsx(gj,{placeholder:"cell name",value:E,onChange:k}),e[21]=E,e[22]=k,e[23]=B):B=e[23],e[24]!==c||e[25]!==b||e[26]!==w||e[27]!==y||e[28]!==m||e[29]!==C||e[30]!==d||e[31]!==N.disabled||e[32]!==N.hide_code||e[33]!==o||e[34]!==g||e[35]!==j||e[36]!==I||e[37]!==T||e[38]!==i||e[39]!==E||e[40]!==f||e[41]!==l||e[42]!==a||e[43]!==p||e[44]!==h||e[45]!==O||e[46]!==_||e[47]!==B||e[48]!==D||e[49]!==P?(A=[[{icon:z,label:"Name",disableClick:!0,handle:Gj,handleHeadless:_,rightElement:B},{icon:u.jsx(Sr,{size:13,strokeWidth:1.5}),label:"Run cell",hotkey:"cell.run",hidden:O==="running"||O==="queued"||O==="disabled-transitively"||N.disabled,handle:()=>f()},{icon:u.jsx(Fi,{size:13,strokeWidth:1.5}),label:"AI completion",hidden:!b,handle:()=>{p(U=>(U==null?void 0:U.cellId)===C?null:{cellId:C})},hotkey:"cell.aiCompletion"},{icon:u.jsx(ld,{size:13,strokeWidth:1.5}),label:"Split cell",hotkey:"cell.splitCell",handle:()=>h({cellId:C})},{icon:u.jsx(ip,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!T,handle:()=>function(U){const $=document.getElementById(g3.create(U));$&&($.classList.add("printing-output"),x3($,"result.png").finally(()=>{$.classList.remove("printing-output")}))}(C)},{icon:u.jsx(w3,{size:13,strokeWidth:1.5}),label:"Format cell",hotkey:"cell.format",handle:()=>{const U=j();U&&v3({[C]:U})}},{icon:N.hide_code?u.jsx(um,{size:13,strokeWidth:1.5}):u.jsx(hm,{size:13,strokeWidth:1.5}),label:N.hide_code?"Show code":"Hide code",handle:P,hotkey:"cell.hideCode"},{icon:N.disabled?u.jsx(un,{size:13,strokeWidth:1.5}):u.jsx(hn,{size:13,strokeWidth:1.5}),label:"Reactive execution",rightElement:u.jsx(fm,{"data-testid":"cell-disable-switch",checked:!N.disabled,size:"sm",onCheckedChange:D}),handle:D},{icon:u.jsx(Pi,{size:13,strokeWidth:1.5}),label:"Clear output",hidden:!(T||I),handle:()=>{d({cellId:C})}}],[{icon:u.jsx(lc,{}),label:"Convert to Markdown",hotkey:"cell.viewAsMarkdown",handle:()=>{const U=j();U&&(Jn({autoInstantiate:y,createNewCell:o}),gr(U,{language:"markdown",keepCodeAsIs:!1}))}},{icon:u.jsx(Yo,{size:13,strokeWidth:1.5}),label:"Convert to SQL",handle:()=>{const U=j();U&&(Jn({autoInstantiate:y,createNewCell:o}),gr(U,{language:"sql",keepCodeAsIs:!1}))}},{icon:u.jsx(cc,{}),label:"Toggle as Python",handle:()=>{const U=j();U&&(Jn({autoInstantiate:y,createNewCell:o}),YO(U,"python",{force:!0}))}}],[{icon:u.jsxs(Ms,{children:[u.jsx(ga,{size:13,strokeWidth:1.5}),u.jsx(dc,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>o({cellId:C,before:!0})},{icon:u.jsxs(Ms,{children:[u.jsx(ga,{size:13,strokeWidth:1.5}),u.jsx(No,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>o({cellId:C,before:!1})},{icon:u.jsx(dc,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>i({cellId:C,before:!0})},{icon:u.jsx(No,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>i({cellId:C,before:!1})},{icon:u.jsx(k3,{size:13,strokeWidth:1.5}),label:"Move cell left",hotkey:"cell.moveLeft",handle:()=>i({cellId:C,direction:"left"}),hidden:w!=="columns"},{icon:u.jsx(zi,{size:13,strokeWidth:1.5}),label:"Move cell right",hotkey:"cell.moveRight",handle:()=>i({cellId:C,direction:"right"}),hidden:w!=="columns"},{icon:u.jsx(Zc,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>a({cellId:C,scroll:!1})},{icon:u.jsx(Jc,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>l({cellId:C,scroll:!1})},{icon:u.jsx(KO,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",hidden:w!=="columns",handle:()=>c({cellId:C})}],[{icon:u.jsx(cj,{size:13,strokeWidth:1.5}),label:"Copy link to cell",disabled:!ig(E),tooltip:ig(E)?void 0:"Only named cells can be linked to",handle:async()=>{await sn(function(U){const $=new URL(window.location.href);return $.hash=`scrollTo=${encodeURIComponent(U)}`,$.toString()}(E)),Je({description:"Link copied to clipboard"})}}],[{label:"Delete",hidden:!m,variant:"danger",icon:u.jsx(uc,{size:13,strokeWidth:1.5}),handle:()=>{g({cellId:C})}}]].map(Wj).filter(Hj),e[24]=c,e[25]=b,e[26]=w,e[27]=y,e[28]=m,e[29]=C,e[30]=d,e[31]=N.disabled,e[32]=N.hide_code,e[33]=o,e[34]=g,e[35]=j,e[36]=I,e[37]=T,e[38]=i,e[39]=E,e[40]=f,e[41]=l,e[42]=a,e[43]=p,e[44]=h,e[45]=O,e[46]=_,e[47]=B,e[48]=D,e[49]=P,e[50]=A):A=e[50],A}function Hj(t){return t.length>0}function Wj(t){return t.filter(qj)}function qj(t){return!t.hidden}function Gj(t){t==null||t.stopPropagation(),t==null||t.preventDefault()}function Yj(t){return!t.hidden}const gd=vt(!1),lg=()=>{const t=H.c(37),[e,n]=Dt(gd),o=XO(),r=je(JO),s=je(hc);let i;t[0]!==r?(i={cell:r},t[0]=r,t[1]=i):i=t[1];let a=pd(i).flat();a=ja(a);const l=function(){const _=H.c(75),[k,B]=br(),[A,U]=C3(),{saveAppConfig:$,saveUserConfig:X}=tt();let Y;_[0]!==X||_[1]!==B?(Y=async re=>{await X({config:re}).then(()=>{B(re)})},_[0]=X,_[1]=B,_[2]=Y):Y=_[2];const G=Y;let W;_[3]!==$||_[4]!==U?(W=async re=>{await $({config:re}).then(()=>{U(re)})},_[3]=$,_[4]=U,_[5]=W):W=_[5];const J=W;let V;if(_[6]!==A||_[7]!==k||_[8]!==J||_[9]!==G){let re,ne,ie,se,ae;_[11]!==A?(re=He=>He!==A.width,_[11]=A,_[12]=re):re=_[12],_[13]!==A||_[14]!==J?(ne=He=>({label:`App config > Set width=${He}`,handle:()=>{J({...A,width:He})}}),_[13]=A,_[14]=J,_[15]=ne):ne=_[15],_[16]!==k||_[17]!==G?(ie={label:"Config > Set theme: dark",handle:()=>{G({...k,display:{...k.display,theme:"dark"}})}},_[16]=k,_[17]=G,_[18]=ie):ie=_[18],_[19]!==k||_[20]!==G?(se={label:"Config > Set theme: light",handle:()=>{G({...k,display:{...k.display,theme:"light"}})}},_[19]=k,_[20]=G,_[21]=se):se=_[21],_[22]!==k||_[23]!==G?(ae={label:"Config > Set theme: system",handle:()=>{G({...k,display:{...k.display,theme:"system"}})}},_[22]=k,_[23]=G,_[24]=ae):ae=_[24];const ge=k.keymap.preset==="vim";let oe,ue;_[25]!==k||_[26]!==G?(oe=()=>{G({...k,keymap:{...k.keymap,preset:"vim"}})},_[25]=k,_[26]=G,_[27]=oe):oe=_[27],_[28]!==ge||_[29]!==oe?(ue={label:"Config > Switch keymap to VIM",hidden:ge,handle:oe},_[28]=ge,_[29]=oe,_[30]=ue):ue=_[30];const de=k.keymap.preset==="default";let Se,Te,Fe;_[31]!==k||_[32]!==G?(Se=()=>{G({...k,keymap:{...k.keymap,preset:"default"}})},_[31]=k,_[32]=G,_[33]=Se):Se=_[33],_[34]!==de||_[35]!==Se?(Te={label:"Config > Switch keymap to default (current: VIM)",hidden:de,handle:Se},_[34]=de,_[35]=Se,_[36]=Te):Te=_[36],_[37]!==k||_[38]!==G?(Fe=()=>{G({...k,completion:{...k.completion,copilot:!1}})},_[37]=k,_[38]=G,_[39]=Fe):Fe=_[39];const _e=k.completion.copilot!=="github";let ke,Ye;_[40]!==Fe||_[41]!==_e?(ke={label:"Config > Disable GitHub Copilot",handle:Fe,hidden:_e},_[40]=Fe,_[41]=_e,_[42]=ke):ke=_[42],_[43]!==k||_[44]!==G?(Ye=()=>{G({...k,completion:{...k.completion,copilot:"github"}})},_[43]=k,_[44]=G,_[45]=Ye):Ye=_[45];const Ve=k.completion.copilot==="github";let Ke;_[46]!==Ye||_[47]!==Ve?(Ke={label:"Config > Enable GitHub Copilot",handle:Ye,hidden:Ve},_[46]=Ye,_[47]=Ve,_[48]=Ke):Ke=_[48];const ee=!k.display.reference_highlighting;let ye,we,Ie,K;_[49]!==k||_[50]!==G?(ye=()=>{G({...k,display:{...k.display,reference_highlighting:!1}})},_[49]=k,_[50]=G,_[51]=ye):ye=_[51],_[52]!==ee||_[53]!==ye?(we={label:"Config > Disable reference highlighting",hidden:ee,handle:ye},_[52]=ee,_[53]=ye,_[54]=we):we=_[54],_[55]!==k||_[56]!==G?(Ie=()=>{G({...k,display:{...k.display,reference_highlighting:!0}})},_[55]=k,_[56]=G,_[57]=Ie):Ie=_[57],_[58]!==k.display.reference_highlighting||_[59]!==Ie?(K={label:"Config > Enable reference highlighting",hidden:k.display.reference_highlighting,handle:Ie},_[58]=k.display.reference_highlighting,_[59]=Ie,_[60]=K):K=_[60];const me=k.display.cell_output==="above";let pe,he;_[61]!==k||_[62]!==G?(pe=()=>{G({...k,display:{...k.display,cell_output:"above"}})},_[61]=k,_[62]=G,_[63]=pe):pe=_[63],_[64]!==me||_[65]!==pe?(he={label:"Config > Set cell output area: above",hidden:me,handle:pe},_[64]=me,_[65]=pe,_[66]=he):he=_[66];const Ce=k.display.cell_output==="below";let Re,Pe;_[67]!==k||_[68]!==G?(Re=()=>{G({...k,display:{...k.display,cell_output:"below"}})},_[67]=k,_[68]=G,_[69]=Re):Re=_[69],_[70]!==Ce||_[71]!==Re?(Pe={label:"Config > Set cell output area: below",hidden:Ce,handle:Re},_[70]=Ce,_[71]=Re,_[72]=Pe):Pe=_[72],V=[...rF().filter(re).map(ne),ie,se,ae,ue,Te,ke,Ke,we,K,he,Pe],_[6]=A,_[7]=k,_[8]=J,_[9]=G,_[10]=V}else V=_[10];const Q=V;let te;return _[73]!==Q?(te=Q.filter(Yj),_[73]=Q,_[74]=te):te=_[74],te}();let c=Fg();c=[...ja(c),...ja(l)];const d=c.filter(Kj),h=fc.keyBy(d,Xj),{recentCommands:f,addRecentCommand:m}=Uj();let g;t[2]!==f?(g=new Set(f),t[2]=f,t[3]=g):g=t[3];const x=g;let p,b;t[4]!==s||t[5]!==n?(p=_=>{gm(s.getHotkey("global.commandPalette").key)(_)&&(_.preventDefault(),n(Jj))},t[4]=s,t[5]=n,t[6]=p):p=t[6],rc(document,"keydown",p),t[7]!==m||t[8]!==s||t[9]!==o||t[10]!==n?(b=(_,k)=>{const B=o[_];if(!B)return null;const A=s.getHotkey(_);return u.jsxs(Zn,{disabled:k.disabled,onSelect:()=>{m(_),n(!1),requestAnimationFrame(()=>{B()})},value:A.name,children:[u.jsxs("span",{children:[A.name,k.tooltip&&u.jsx("span",{className:"ml-2",children:k.tooltip})]}),u.jsx(S3,{children:u.jsx(xm,{shortcut:A.key})})]},_)},t[7]=m,t[8]=s,t[9]=o,t[10]=n,t[11]=b):b=t[11];const y=b;let v;t[12]!==m||t[13]!==s||t[14]!==n?(v=_=>{const{label:k,handle:B,props:A,hotkey:U}=_,$=A===void 0?{}:A;return u.jsxs(Zn,{disabled:$.disabled,onSelect:()=>{m(k),n(!1),requestAnimationFrame(()=>{B()})},value:k,children:[u.jsxs("span",{children:[k,$.tooltip&&u.jsxs("span",{className:"ml-2",children:["(",$.tooltip,")"]})]}),U&&u.jsx(S3,{children:u.jsx(xm,{shortcut:s.getHotkey(U).key})})]},k)},t[12]=m,t[13]=s,t[14]=n,t[15]=v):v=t[15];const w=v,S=QO;let C;t[16]===Symbol.for("react.memo_cache_sentinel")?(C=u.jsx(Bi,{placeholder:"Type to search..."}),t[16]=C):C=t[16];const N=pm;let j;t[17]===Symbol.for("react.memo_cache_sentinel")?(j=u.jsx(mc,{children:"No results found."}),t[17]=j):j=t[17];const E=f.length>0&&u.jsxs(u.Fragment,{children:[u.jsx(mm,{heading:"Recently Used",children:f.map(_=>{const k=h[_];return ZO(_)?y(_,{disabled:k==null?void 0:k.disabled,tooltip:k==null?void 0:k.tooltip}):k&&!sg(k)?w({label:k.label,handle:k.handleHeadless||k.handle,props:{disabled:k.disabled,tooltip:k.tooltip}}):null})}),u.jsx(j3,{})]}),T=mm,I=s.iterate().map(_=>{if(x.has(_))return null;const k=h[_];return y(_,{disabled:k==null?void 0:k.disabled,tooltip:k==null?void 0:k.tooltip})}),O=d.map(_=>x.has(_.label)?null:w({label:_.label,handle:_.handleHeadless||_.handle,props:{disabled:_.disabled,tooltip:_.tooltip}}));let L;t[18]!==x||t[19]!==w?(L=_=>x.has(_.label)?null:w({label:`Cell > ${_.label}`,handle:_.handleHeadless||_.handle,props:{disabled:_.disabled,tooltip:_.tooltip}}),t[18]=x,t[19]=w,t[20]=L):L=t[20];const D=a.map(L);let R,P,z;return t[21]!==T||t[22]!==O||t[23]!==D||t[24]!==I?(R=u.jsxs(T,{heading:"Commands",children:[I,O,D]}),t[21]=T,t[22]=O,t[23]=D,t[24]=I,t[25]=R):R=t[25],t[26]!==N||t[27]!==R||t[28]!==j||t[29]!==E?(P=u.jsxs(N,{children:[j,E,R]}),t[26]=N,t[27]=R,t[28]=j,t[29]=E,t[30]=P):P=t[30],t[31]!==S||t[32]!==e||t[33]!==n||t[34]!==P||t[35]!==C?(z=u.jsxs(S,{open:e,onOpenChange:n,children:[C,P]}),t[31]=S,t[32]=e,t[33]=n,t[34]=P,t[35]=C,t[36]=z):z=t[36],z};function Kj(t){return!t.hotkey}function Xj(t){return t.label}function Jj(t){return!t}function tr(){return at().optional().describe(ze.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function cg(){return at().optional().describe(ze.of({label:"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"}))}function Na(){return at().optional().describe(ze.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function dg(){return at().optional().describe(ze.of({label:"URI",optionRegex:".*uri.*"}))}function nr(){return at().nonempty().describe(ze.of({label:"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function to(){return at().describe(ze.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function or(){return at().nonempty().describe(ze.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function rr(t){const e=eD.string().describe(ze.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(n=>n>=0&&n<=65535,{message:"Port must be between 0 and 65535"});return t!==void 0?e.default(t.toString()):e}function ug(){return hs().default(!1).describe(ze.of({label:"Read Only"}))}const hg=ht({type:gt("postgres"),host:nr(),port:rr(5432).optional(),database:to(),username:or(),password:tr(),ssl:hs().default(!1).describe(ze.of({label:"Use SSL"}))}).describe(ze.of({direction:"two-columns"})),fg=ht({type:gt("mysql"),host:nr(),port:rr(3306),database:to(),username:or(),password:tr(),ssl:hs().default(!1).describe(ze.of({label:"Use SSL"}))}).describe(ze.of({direction:"two-columns"})),mg=ht({type:gt("sqlite"),database:to().describe(ze.of({label:"Database Path"}))}).describe(ze.of({direction:"two-columns"})),pg=ht({type:gt("duckdb"),database:to().describe(ze.of({label:"Database Path"})),read_only:ug()}).describe(ze.of({direction:"two-columns"})),gg=ht({type:gt("motherduck"),database:to().default("my_db").describe(ze.of({label:"Database Name"})),token:cg()}).describe(ze.of({direction:"two-columns"})),xg=ht({type:gt("snowflake"),account:at().nonempty().describe(ze.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:at().optional().describe(ze.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:to(),schema:at().optional().describe(ze.of({label:"Schema",optionRegex:".*snowflake.*"})),username:or(),password:tr(),role:at().optional().describe(ze.of({label:"Role"}))}).describe(ze.of({direction:"two-columns"})),bg=ht({type:gt("bigquery"),project:at().nonempty().describe(ze.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:at().nonempty().describe(ze.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:at().describe(ze.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(ze.of({direction:"two-columns"})),yg=ht({type:gt("clickhouse_connect"),host:nr(),port:rr(8123).optional(),username:or(),password:tr(),secure:hs().default(!1).describe(ze.of({label:"Use HTTPs"}))}).describe(ze.of({direction:"two-columns"})),vg=ht({type:gt("timeplus"),host:nr().default("localhost"),port:rr(8123).optional(),username:or().default("default"),password:tr().default("")}).describe(ze.of({direction:"two-columns"})),wg=ht({type:gt("chdb"),database:to().describe(ze.of({label:"Database Path"})),read_only:ug()}).describe(ze.of({direction:"two-columns"})),kg=ht({type:gt("trino"),host:nr(),port:rr(8080),database:to(),schema:at().describe(ze.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"})).optional(),username:or(),password:tr(),async_support:hs().default(!1).describe(ze.of({label:"Async Support"}))}).describe(ze.of({direction:"two-columns"})),Cg=ht({type:gt("iceberg"),name:at().describe(ze.of({label:"Catalog Name"})),catalog:bm("type",[ht({type:gt("REST"),warehouse:Na(),uri:at().optional().describe(ze.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:cg()}),ht({type:gt("SQL"),warehouse:Na(),uri:at().optional().describe(ze.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),ht({type:gt("Hive"),warehouse:Na(),uri:dg()}),ht({type:gt("Glue"),warehouse:Na(),uri:dg()}),ht({type:gt("DynamoDB"),"dynamodb.profile-name":at().optional().describe(ze.of({label:"Profile Name"})),"dynamodb.region":at().optional().describe(ze.of({label:"Region"})),"dynamodb.access-key-id":at().optional().describe(ze.of({label:"Access Key ID"})),"dynamodb.secret-access-key":at().optional().describe(ze.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":at().optional().describe(ze.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST"}).describe(ze.of({special:"tabs"}))}),jg=ht({type:gt("datafusion"),sessionContext:hs().optional().describe(ze.of({label:"Use Session Context"}))}),Sg=ht({type:gt("pyspark"),host:nr().optional(),port:rr().optional()}),Ng=ht({type:gt("redshift"),host:nr(),port:rr(5439),connectionType:bm("type",[ht({type:gt("IAM credentials"),region:at().describe(ze.of({label:"Region"})),aws_access_key_id:at().nonempty().describe(ze.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:at().nonempty().describe(ze.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:at().optional().describe(ze.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),ht({type:gt("DB credentials"),user:or(),password:tr()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:to()}).describe(ze.of({direction:"two-columns"})),Zj=bm("type",[hg,fg,mg,pg,gg,xg,bg,yg,vg,wg,kg,Cg,jg,Sg,Ng]),xd="env:";function Ea(t){return typeof t=="string"&&t.startsWith(xd)}function bd(t){return`${xd}${t}`}const Eg={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift"};class Yt{constructor(e,n,o){this.connection=void 0,this.orm=void 0,this.secrets=void 0,this.connection=e,this.orm=n,this.secrets=o}get imports(){const e=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":e.add("import sqlalchemy");break;case"sqlmodel":e.add("import sqlmodel");break;case"duckdb":e.add("import duckdb")}return e}}class Qj{constructor(){this.secrets={}}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(e,n,o){if(e=(r=>`_${r}`)(e),Ea(n)){const r=n.replace(xd,""),s=o?`os.environ.get("${r}", "${o}")`:`os.environ.get("${r}")`;return this.secrets[e]=s,e}if(o!=null){const r=`os.environ.get("${n}", "${o}")`;return this.secrets[e]=r,e}return typeof n=="number"||typeof n=="number"?`${n}`:typeof n=="boolean"?Er(n):n?`"${n}"`:""}printInFString(e,n,o){if(n===void 0)return"";if(typeof n=="number")return`${n}`;if(typeof n=="boolean")return Er(n);const r=this.print(e,n,o);return r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):`{${r}}`}printPassword(e,n,o){const r=o?this.printInFString.bind(this):this.print.bind(this);return Ea(e)?r("password",e):r("password",n,e)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([e,n])=>`${e} = ${n}`).join(`
3
+ `)}}class eS extends Yt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.ssl?", connect_args={'sslmode': 'require'}":"",n=this.secrets.printPassword(this.connection.password,"POSTGRES_PASSWORD",!0),o=this.secrets.printInFString("username",this.connection.username),r=this.secrets.printInFString("host",this.connection.host),s=this.secrets.printInFString("port",this.connection.port),i=this.secrets.printInFString("database",this.connection.database);return xt(`
4
+ DATABASE_URL = f"postgresql://${o}:${n}@${r}:${s}/${i}"
5
+ engine = ${this.orm}.create_engine(DATABASE_URL${e})
6
+ `)}}class tS extends Yt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.ssl?", connect_args={'ssl': {'ssl-mode': 'preferred'}}":"",n=this.secrets.printPassword(this.connection.password,"MYSQL_PASSWORD",!0),o=this.secrets.printInFString("database",this.connection.database),r=this.secrets.printInFString("username",this.connection.username),s=this.secrets.printInFString("host",this.connection.host),i=this.secrets.printInFString("port",this.connection.port);return xt(`
7
+ DATABASE_URL = f"mysql+pymysql://${r}:${n}@${s}:${i}/${o}"
8
+ engine = ${this.orm}.create_engine(DATABASE_URL${e})
9
+ `)}}class nS extends Yt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.database?this.secrets.printInFString("database",this.connection.database):"",n=e.startsWith("{")&&e.endsWith("}")?`DATABASE_URL = f"sqlite:///${e}"`:`DATABASE_URL = "sqlite:///${e}"`;return xt(`
10
+ ${n}
11
+ engine = ${this.orm}.create_engine(DATABASE_URL)
12
+ `)}}class oS extends Yt{generateImports(){return["from snowflake.sqlalchemy import URL"]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"SNOWFLAKE_PASSWORD",!1),n={account:this.secrets.print("account",this.connection.account),user:this.secrets.print("user",this.connection.username),database:this.secrets.print("database",this.connection.database),warehouse:this.connection.warehouse?this.secrets.print("warehouse",this.connection.warehouse):void 0,schema:this.connection.schema?this.secrets.print("schema",this.connection.schema):void 0,role:this.connection.role?this.secrets.print("role",this.connection.role):void 0,password:e};return xt(`
13
+ engine = ${this.orm}.create_engine(
14
+ URL(
15
+ ${_a(n,o=>` ${o}`)},
16
+ )
17
+ )
18
+ `)}}class rS extends Yt{generateImports(){return["import json"]}generateConnectionCode(){const e=this.secrets.printInFString("project",this.connection.project),n=this.secrets.printInFString("dataset",this.connection.dataset);return xt(`
19
+ credentials = json.loads("""${this.connection.credentials_json}""")
20
+ engine = ${this.orm}.create_engine(f"bigquery://${e}/${n}", credentials_info=credentials)
21
+ `)}}class sS extends Yt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printInFString("database",this.connection.database||":memory:");return xt(`
22
+ DATABASE_URL = "${e}"
23
+ engine = ${this.orm}.connect(DATABASE_URL, read_only=${Er(this.connection.read_only)})
24
+ `)}}class iS extends Yt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printInFString("database",this.connection.database);if(!this.connection.token)return xt(`
25
+ conn = duckdb.connect("md:${e}")
26
+ `);const n=this.secrets.printPassword(this.connection.token,"MOTHERDUCK_TOKEN",!1);return xt(`
27
+ conn = duckdb.connect("md:${e}", config={"motherduck_token": ${n}})
28
+ `)}}class aS extends Yt{generateImports(){return["import clickhouse_connect"]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"CLICKHOUSE_PASSWORD",!1),n={host:this.secrets.print("host",this.connection.host),user:this.secrets.print("user",this.connection.username),secure:this.secrets.print("secure",this.connection.secure),port:this.connection.port?this.secrets.print("port",this.connection.port):void 0,password:this.connection.password?e:void 0};return xt(`
29
+ engine = ${this.orm}.get_client(
30
+ ${_a(n,o=>` ${o}`)},
31
+ )
32
+ `)}}class lS extends Yt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"TIMEPLUS_PASSWORD",!0),n=this.secrets.printInFString("username",this.connection.username),o=this.secrets.printInFString("host",this.connection.host),r=this.secrets.printInFString("port",this.connection.port);return xt(`
33
+ DATABASE_URL = f"timeplus://${n}:${e}@${o}:${r}"
34
+ engine = ${this.orm}.create_engine(DATABASE_URL)
35
+ `)}}class cS extends Yt{generateImports(){return["import chdb"]}generateConnectionCode(){const e=this.secrets.print("database",this.connection.database)||'""';return xt(`
36
+ engine = ${this.orm}.connect(${e}, read_only=${Er(this.connection.read_only)})
37
+ `)}}class dS extends Yt{generateImports(){return this.connection.async_support?["import aiotrino"]:["import trino.sqlalchemy"]}generateConnectionCode(){const e=this.connection.async_support?"aiotrino":"trino",n=this.connection.schema?`/${this.connection.schema}`:"",o=this.secrets.printInFString("username",this.connection.username),r=this.secrets.printInFString("host",this.connection.host),s=this.secrets.printInFString("port",this.connection.port),i=this.secrets.printInFString("database",this.connection.database),a=this.secrets.printPassword(this.connection.password,"TRINO_PASSWORD",!0);return xt(`
38
+ engine = ${this.orm}.create_engine(f"${e}://${o}:${a}@${r}:${s}/${i}${n}")
39
+ `)}}class uS extends Yt{generateImports(){switch(this.connection.catalog.type){case"REST":return["from pyiceberg.catalog.rest import RestCatalog"];case"SQL":return["from pyiceberg.catalog.sql import SqlCatalog"];case"Hive":return["from pyiceberg.catalog.hive import HiveCatalog"];case"Glue":return["from pyiceberg.catalog.glue import GlueCatalog"];case"DynamoDB":return["from pyiceberg.catalog.dynamodb import DynamoDBCatalog"];default:ym(this.connection.catalog)}}generateConnectionCode(){let e={...this.connection.catalog};e=Object.fromEntries(Object.entries(e).filter(([i,a])=>a!=null&&a!==""&&i!=="type"));for(const[i,a]of Object.entries(e))Ea(a)?e[i]=this.secrets.print(i,a):typeof a=="string"&&(e[i]=`"${a}"`);const n=(o=e,r=i=>` ${i}`,Object.entries(o).filter(([,i])=>i!=null&&i!=="").map(([i,a])=>{const l=`"${i}"`;return r(typeof a=="boolean"?`${l}: ${Er(a)}`:`${l}: ${a}`)}).join(`,
40
+ `));var o,r;const s=`"${this.connection.name}"`;switch(this.connection.catalog.type){case"REST":return xt(`
41
+ catalog = RestCatalog(
42
+ ${s},
43
+ **{
44
+ ${n}
45
+ },
46
+ )
47
+ `);case"SQL":return xt(`
48
+ catalog = SqlCatalog(
49
+ ${s},
50
+ **{
51
+ ${n}
52
+ },
53
+ )
54
+ `);case"Hive":return xt(`
55
+ catalog = HiveCatalog(
56
+ ${s},
57
+ **{
58
+ ${n}
59
+ },
60
+ )
61
+ `);case"Glue":return xt(`
62
+ catalog = GlueCatalog(
63
+ ${s},
64
+ **{
65
+ ${n}
66
+ },
67
+ )
68
+ `);case"DynamoDB":return xt(`
69
+ catalog = DynamoDBCatalog(
70
+ ${s},
71
+ **{
72
+ ${n}
73
+ },
74
+ )
75
+ `);default:ym(this.connection.catalog)}}}class hS extends Yt{generateImports(){return["import ibis","from datafusion import SessionContext"]}generateConnectionCode(){return this.connection.sessionContext?xt(`
76
+ ctx = SessionContext()
77
+ # Sample table
78
+ _ = ctx.from_pydict({"a": [1, 2, 3]}, "my_table")
79
+
80
+ con = ibis.datafusion.connect(ctx)
81
+ `):xt(`
82
+ con = ibis.datafusion.connect()
83
+ `)}}class fS extends Yt{generateImports(){return["import ibis","from pyspark.sql import SparkSession"]}generateConnectionCode(){if(this.connection.host||this.connection.port){const e=this.secrets.printInFString("host",this.connection.host),n=this.secrets.printInFString("port",this.connection.port);return xt(`
84
+ session = SparkSession.builder.remote(f"sc://${e}:${n}").getOrCreate()
85
+ con = ibis.pyspark.connect(session)
86
+ `)}return xt(`
87
+ con = ibis.pyspark.connect()
88
+ `)}}class mS extends Yt{generateImports(){return["import redshift_connector"]}generateConnectionCode(){const e=this.secrets.print("host",this.connection.host),n=this.secrets.print("port",this.connection.port),o=this.secrets.print("database",this.connection.database);if(this.connection.connectionType.type==="IAM credentials"){const a=this.secrets.print("aws_access_key_id",this.connection.connectionType.aws_access_key_id),l=this.secrets.print("aws_secret_access_key",this.connection.connectionType.aws_secret_access_key),c=this.connection.connectionType.aws_session_token?this.secrets.print("aws_session_token",this.connection.connectionType.aws_session_token):void 0,d={iam:!0,host:e,port:n,region:`"${this.connection.connectionType.region}"`,database:o,access_key_id:a,secret_access_key:l,...c&&{session_token:c}};return xt(`
89
+ con = redshift_connector.connect(
90
+ ${_a(d,h=>` ${h}`)},
91
+ )
92
+ `)}const r=this.connection.connectionType.user?this.secrets.print("user",this.connection.connectionType.user):void 0,s=this.connection.connectionType.password?this.secrets.printPassword(this.connection.connectionType.password,"REDSHIFT_PASSWORD",!1):void 0,i={host:e,port:n,database:o,...r&&{user:r},...s&&{password:s}};return xt(`
93
+ con = redshift_connector.connect(
94
+ ${_a(i,a=>` ${a}`)},
95
+ )
96
+ `)}}class pS{constructor(){this.secrets=new Qj}createGenerator(e,n){switch(e.type){case"postgres":return new eS(e,n,this.secrets);case"mysql":return new tS(e,n,this.secrets);case"sqlite":return new nS(e,n,this.secrets);case"snowflake":return new oS(e,n,this.secrets);case"bigquery":return new rS(e,n,this.secrets);case"duckdb":return new sS(e,n,this.secrets);case"motherduck":return new iS(e,n,this.secrets);case"clickhouse_connect":return new aS(e,n,this.secrets);case"timeplus":return new lS(e,n,this.secrets);case"chdb":return new cS(e,n,this.secrets);case"trino":return new dS(e,n,this.secrets);case"iceberg":return new uS(e,n,this.secrets);case"datafusion":return new hS(e,n,this.secrets);case"pyspark":return new fS(e,n,this.secrets);case"redshift":return new mS(e,n,this.secrets);default:ym(e)}}}function Er(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function _a(t,e){return Object.entries(t).filter(([,n])=>n!=null&&n!=="").map(([n,o])=>e(typeof o=="boolean"?`${n}=${Er(o)}`:`${n}=${o}`)).join(`,
97
+ `)}function _g(t){return t.sort((e,n)=>e.provider==="env"?1:n.provider==="env"?-1:0)}const Ig=t=>{const e=H.c(43),{providerNames:n,onClose:o,onSuccess:r}=t,{writeSecret:s}=tt(),[i,a]=q.useState(""),[l,c]=q.useState(""),[d,h]=q.useState(n[0]);let f;e[0]!==i||e[1]!==d||e[2]!==r||e[3]!==l||e[4]!==s?(f=async _=>{if(_.preventDefault(),d)if(i&&l&&d)try{await s({key:i,value:l,provider:"dotenv",name:d}),Je({title:"Secret created",description:"The secret has been created successfully."}),r(i)}catch{Je({title:"Error",description:"Failed to create secret. Please try again.",variant:"danger"})}else Je({title:"Error",description:"Please fill in all fields.",variant:"danger"});else Je({title:"Error",description:"No location selected for the secret.",variant:"danger"})},e[0]=i,e[1]=d,e[2]=r,e[3]=l,e[4]=s,e[5]=f):f=e[5];const m=f;let g,x,p,b,y,v,w,S,C,N,j,E,T,I,O,L;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=u.jsxs(cs,{children:[u.jsx(Wo,{children:"Add Secret"}),u.jsx(ds,{children:"Add a new secret to your environment variables."})]}),e[6]=g):g=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx(xr,{htmlFor:"key",children:"Key"}),e[7]=x):x=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(p=_=>{a(_.target.value.replaceAll(/\W/g,"_"))},e[8]=p):p=e[8],e[9]!==i?(b=u.jsxs("div",{className:"grid gap-2",children:[x,u.jsx(qo,{id:"key",value:i,onChange:p,placeholder:"MY_SECRET_KEY",required:!0})]}),e[9]=i,e[10]=b):b=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(y=u.jsx(xr,{htmlFor:"value",children:"Value"}),e[11]=y):y=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(v=_=>c(_.target.value),e[12]=v):v=e[12],e[13]!==l?(w=u.jsx(qo,{id:"value",type:"text",value:l,onChange:v,required:!0,autoComplete:"off"}),e[13]=l,e[14]=w):w=e[14],e[15]===Symbol.for("react.memo_cache_sentinel")?(S=window.location.href.startsWith("http://")&&u.jsx(N3,{children:"Note: You are sending this key over http."}),e[15]=S):S=e[15],e[16]!==w?(C=u.jsxs("div",{className:"grid gap-2",children:[y,w,S]}),e[16]=w,e[17]=C):C=e[17],e[18]===Symbol.for("react.memo_cache_sentinel")?(N=u.jsx(xr,{htmlFor:"location",children:"Location"}),e[18]=N):N=e[18],e[19]!==n.length?(j=n.length===0&&u.jsx("p",{className:"text-sm text-muted-foreground",children:"No dotenv locations configured."}),e[19]=n.length,e[20]=j):j=e[20],e[21]!==d||e[22]!==n?(E=n.length>0&&u.jsxs(Ui,{value:d,onValueChange:_=>h(_),children:[u.jsx($i,{children:u.jsx(Vi,{placeholder:"Select a provider"})}),u.jsx(Hi,{children:n.map(gS)})]}),e[21]=d,e[22]=n,e[23]=E):E=e[23],e[24]===Symbol.for("react.memo_cache_sentinel")?(T=u.jsxs(N3,{children:["You can configure the location by setting the"," ",u.jsx(vm,{href:"https://links.marimo.app/dotenv",children:"dotenv configuration"}),"."]}),e[24]=T):T=e[24],e[25]!==j||e[26]!==E?(I=u.jsxs("div",{className:"grid gap-2",children:[N,j,E,T]}),e[25]=j,e[26]=E,e[27]=I):I=e[27],e[28]!==C||e[29]!==I||e[30]!==b?(O=u.jsxs("div",{className:"grid gap-4 py-4",children:[b,C,I]}),e[28]=C,e[29]=I,e[30]=b,e[31]=O):O=e[31],e[32]!==o?(L=u.jsx(ve,{type:"button",variant:"outline",onClick:o,children:"Cancel"}),e[32]=o,e[33]=L):L=e[33];const D=!i||!l||!d;let R,P,z;return e[34]!==D?(R=u.jsx(ve,{type:"submit",disabled:D,children:"Add Secret"}),e[34]=D,e[35]=R):R=e[35],e[36]!==L||e[37]!==R?(P=u.jsxs(Oi,{children:[L,R]}),e[36]=L,e[37]=R,e[38]=P):P=e[38],e[39]!==m||e[40]!==O||e[41]!==P?(z=u.jsx(Go,{children:u.jsxs("form",{onSubmit:m,children:[g,O,P]})}),e[39]=m,e[40]=O,e[41]=P,e[42]=z):z=e[42],z};function gS(t){return u.jsx(fs,{value:t,children:t},t)}const Ag=M.createContext({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:Bn.NOOP}),xS=t=>{const e=H.c(14),{children:n}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const{data:r,isPending:s,error:i,refetch:a}=Tn(kS,o);let l,c,d,h;return e[1]!==(r==null?void 0:r.secretKeys)?(l=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=l):l=e[2],e[3]!==(r==null?void 0:r.providerNames)?(c=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=c):c=e[4],e[5]!==i||e[6]!==s||e[7]!==a||e[8]!==l||e[9]!==c?(d={secretKeys:l,providerNames:c,loading:s,error:i,refreshSecrets:a},e[5]=i,e[6]=s,e[7]=a,e[8]=l,e[9]=c,e[10]=d):d=e[10],e[11]!==n||e[12]!==d?(h=u.jsx(Ag,{value:d,children:n}),e[11]=n,e[12]=d,e[13]=h):h=e[13],h},bS={isMatch:t=>{if(t instanceof A3||t instanceof rD){const{optionRegex:e}=ze.parse(t._def.description||"");return!!e}return!1},Component:({schema:t,form:e,path:n})=>{const{secretKeys:o,providerNames:r,refreshSecrets:s}=M.use(Ag),{openModal:i,closeModal:a}=An(),{label:l,description:c,optionRegex:d=""}=ze.parse(t._def.description||""),[h,f]=Mt(o,m=>new RegExp(d,"i").test(m));return u.jsx(E3,{control:e.control,name:n,render:({field:m})=>u.jsxs(_3,{children:[u.jsx(tD,{children:l}),u.jsx(nD,{children:c}),u.jsx(I3,{children:u.jsxs("div",{className:"flex gap-2",children:[t instanceof A3?u.jsx(qo,{...m,value:m.value,onChange:m.onChange,className:xe("flex-1")}):u.jsx(oD,{...m,value:m.value,onChange:m.onChange,className:"flex-1"}),u.jsxs(Eo,{children:[u.jsx(_o,{asChild:!0,children:u.jsx(ve,{variant:"outline",size:"icon",className:xe(Ea(m.value)&&"bg-accent"),children:u.jsx(od,{className:"h-3 w-3"})})}),u.jsxs(Io,{align:"end",className:"max-h-60 overflow-y-auto",children:[u.jsxs(At,{onSelect:()=>{i(u.jsx(Ig,{providerNames:r,onSuccess:g=>{s(),m.onChange(bd(g)),a()},onClose:a}))},children:[u.jsx(ga,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),h.length>0&&u.jsxs(u.Fragment,{children:[u.jsx(an,{}),u.jsx(T3,{children:"Recommended"})]}),h.map(g=>u.jsx(At,{onSelect:()=>m.onChange(bd(g)),children:g},g)),f.length>0&&u.jsx(an,{}),f.map(g=>u.jsx(At,{onSelect:()=>m.onChange(bd(g)),children:g},g))]})]})]})}),u.jsx(M3,{})]})})}};function yS(t){return t.provider!=="env"}function vS(t){return t.name}function wS(t){return t.keys}async function kS(){const t=await xj.request({}),e=_g(t.secrets).filter(yS).map(vS);return{secretKeys:t.secrets.flatMap(wS).sort(),providerNames:e}}const Tg=[{name:"PostgreSQL",schema:hg,color:"#336791",logo:"postgres",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"MySQL",schema:fg,color:"#00758F",logo:"mysql",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"SQLite",schema:mg,color:"#003B57",logo:"sqlite",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DuckDB",schema:pg,color:"#FFD700",logo:"duckdb",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"MotherDuck",schema:gg,color:"#ff9538",logo:"motherduck",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"Snowflake",schema:xg,color:"#29B5E8",logo:"snowflake",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse",schema:yg,color:"#2C2C1D",logo:"clickhouse",connectionLibraries:{libraries:["clickhouse_connect"],preferred:"clickhouse_connect"}},{name:"Timeplus",schema:vg,color:"#B83280",logo:"timeplus",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"BigQuery",schema:bg,color:"#4285F4",logo:"bigquery",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse Embedded",schema:wg,color:"#f2b611",logo:"clickhouse",connectionLibraries:{libraries:["chdb"],preferred:"chdb"}},{name:"Trino",schema:kg,color:"#d466b6",logo:"trino",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DataFusion",schema:jg,color:"#202A37",logo:"datafusion",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"PySpark",schema:Sg,color:"#1C5162",logo:"pyspark",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"Redshift",schema:Ng,color:"#522BAE",logo:"redshift",connectionLibraries:{libraries:["redshift"],preferred:"redshift"}}],Mg=[{name:"Iceberg",schema:Cg,color:"#000000",logo:"iceberg",connectionLibraries:{libraries:["pyiceberg"],preferred:"pyiceberg"}}],CS=t=>{const e=H.c(14),{onSelect:n}=t;let o;e[0]!==n?(o=h=>{const{name:f,schema:m,color:g,logo:x}=h;return u.jsxs("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:{backgroundColor:g},onClick:()=>n(m),children:[u.jsx(P3,{name:x,className:"w-8 h-8 text-white brightness-0 invert dark:invert"}),u.jsx("span",{className:"text-white font-medium text-lg",children:f})]},f)},e[0]=n,e[1]=o):o=e[1];const r=o;let s,i,a,l,c,d;return e[2]!==r?(s=Tg.map(r),e[2]=r,e[3]=s):s=e[3],e[4]!==s?(i=u.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[4]=s,e[5]=i):i=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(a=u.jsxs("h4",{className:"font-semibold text-muted-foreground text-lg flex items-center gap-4",children:["Data Catalogs",u.jsx("hr",{className:"flex-1"})]}),e[6]=a):a=e[6],e[7]!==r?(l=Mg.map(r),e[7]=r,e[8]=l):l=e[8],e[9]!==l?(c=u.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:l}),e[9]=l,e[10]=c):c=e[10],e[11]!==i||e[12]!==c?(d=u.jsxs(u.Fragment,{children:[i,a,c]}),e[11]=i,e[12]=c,e[13]=d):d=e[13],d},jS=[bS],SS=t=>{var B;const e=H.c(49),{schema:n,onSubmit:o,onBack:r}=t;let s,i,a;e[0]!==n?(s=sD(n),e[0]=n,e[1]=s):s=e[1],e[2]!==n?(i=O3(n),e[2]=n,e[3]=i):i=e[3],e[4]!==s||e[5]!==i?(a={defaultValues:s,resolver:i,reValidateMode:"onChange"},e[4]=s,e[5]=i,e[6]=a):a=e[6];const l=D3(a),c=(B=[...Tg,...Mg].find(A=>A.schema===n))==null?void 0:B.connectionLibraries,[d,h]=M.useState((c==null?void 0:c.preferred)??"sqlalchemy"),{createNewCell:f}=lt(),m=ms();let g;e[7]!==f||e[8]!==m?(g=A=>{f({code:A,before:!1,cellId:m??"__end__",skipIfCodeExists:!0})},e[7]=f,e[8]=m,e[9]=g):g=e[9];const x=g;let p;e[10]!==x||e[11]!==o||e[12]!==d?(p=A=>{x(function(U,$){if(!($ in Eg))throw new Error(`Unsupported library: ${$}`);Zj.parse(U);const X=new pS,Y=X.createGenerator(U,$),G=Y.generateConnectionCode(),W=X.secrets,J=[...new Set([...W.imports,...Y.imports])].sort();J.push("");const V=W.formatSecrets();return V&&J.push(V),J.push(G.trim()),J.join(`
98
+ `)}(A,d)),o()},e[10]=x,e[11]=o,e[12]=d,e[13]=p):p=e[13];const b=p;let y;e[14]!==l||e[15]!==b?(y=l.handleSubmit(b),e[14]=l,e[15]=b,e[16]=y):y=e[16];let v,w;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=u.jsx(iD,{}),e[17]=v):v=e[17],e[18]!==l||e[19]!==n?(w=u.jsx(xS,{children:u.jsx(aD,{schema:n,form:l,renderers:jS,children:v})}),e[18]=l,e[19]=n,e[20]=w):w=e[20];let S;e[21]!==r?(S=u.jsx(ve,{type:"button",variant:"outline",onClick:r,children:"Back"}),e[21]=r,e[22]=S):S=e[22];const C=!l.formState.isValid;let N,j;e[23]!==C?(N=u.jsx(ve,{type:"submit",disabled:C,children:"Add"}),e[23]=C,e[24]=N):N=e[24],e[25]!==S||e[26]!==N?(j=u.jsxs("div",{className:"flex gap-2",children:[S,N]}),e[25]=S,e[26]=N,e[27]=j):j=e[27];const E=Ui;let T,I;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=A=>h(A),e[28]=T):T=e[28],e[29]===Symbol.for("react.memo_cache_sentinel")?(I=u.jsxs("div",{className:"flex flex-col gap-1 items-end",children:[u.jsx($i,{children:u.jsx(Vi,{placeholder:"Select a library"})}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"Preferred connection library"})]}),e[29]=I):I=e[29];const O=Hi,L=R3,D=c==null?void 0:c.libraries.map(ES);let R,P,z,_,k;return e[30]!==L||e[31]!==D?(R=u.jsx(L,{children:D}),e[30]=L,e[31]=D,e[32]=R):R=e[32],e[33]!==O||e[34]!==R?(P=u.jsx(O,{children:R}),e[33]=O,e[34]=R,e[35]=P):P=e[35],e[36]!==E||e[37]!==d||e[38]!==T||e[39]!==I||e[40]!==P?(z=u.jsx("div",{children:u.jsxs(E,{value:d,onValueChange:T,children:[I,P]})}),e[36]=E,e[37]=d,e[38]=T,e[39]=I,e[40]=P,e[41]=z):z=e[41],e[42]!==j||e[43]!==z?(_=u.jsxs("div",{className:"flex gap-2 justify-between",children:[j,z]}),e[42]=j,e[43]=z,e[44]=_):_=e[44],e[45]!==_||e[46]!==y||e[47]!==w?(k=u.jsxs("form",{onSubmit:y,className:"space-y-4",children:[w,_]}),e[45]=_,e[46]=y,e[47]=w,e[48]=k):k=e[48],k},NS=t=>{const e=H.c(5),{onSubmit:n}=t,[o,r]=M.useState(null);if(!o){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=u.jsx(CS,{onSelect:r}),e[0]=a):a=e[0],a}let s,i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=()=>r(null),e[1]=s):s=e[1],e[2]!==n||e[3]!==o?(i=u.jsx(SS,{schema:o,onSubmit:n,onBack:s}),e[2]=n,e[3]=o,e[4]=i):i=e[4],i},Og=t=>{const e=H.c(6),{children:n}=t,[o,r]=M.useState(!1);let s,i,a;return e[0]!==n?(s=u.jsx(lD,{asChild:!0,children:n}),e[0]=n,e[1]=s):s=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(i=u.jsx(Dg,{onClose:()=>r(!1)}),e[2]=i):i=e[2],e[3]!==o||e[4]!==s?(a=u.jsxs(cD,{open:o,onOpenChange:r,children:[s,i]}),e[3]=o,e[4]=s,e[5]=a):a=e[5],a},Dg=t=>{const e=H.c(4),{onClose:n}=t;let o,r,s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=u.jsx(Wo,{children:"Add Connection"}),e[0]=o):o=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(r=u.jsxs(cs,{className:"mb-4",children:[o,u.jsxs(ds,{children:["Connect to your database or data catalog to query data directly from your notebook. Learn more about how to connect to your database in our"," ",u.jsx(vm,{href:"https://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database",children:"docs."})]})]}),e[1]=r):r=e[1],e[2]!==n?(s=u.jsxs(Go,{className:"max-h-[75vh] overflow-y-auto",children:[r,u.jsx(NS,{onSubmit:()=>n()})]}),e[2]=n,e[3]=s):s=e[3],s};function ES(t){return u.jsx(fs,{value:t,children:Eg[t]},t)}const _S=()=>{const t=H.c(7),{selectedLayout:e}=bj(),{setLayoutView:n}=yj();if(tn()&&!wm("wasm_layouts"))return null;let o,r,s,i;return t[0]!==n?(o=a=>n(a),t[0]=n,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=u.jsx($i,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:u.jsx(Vi,{placeholder:"Select a view"})}),t[2]=r):r=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(s=u.jsx(Hi,{children:u.jsxs(R3,{children:[u.jsx(dD,{children:"View as"}),vj.map(AS)]})}),t[3]=s):s=t[3],t[4]!==e||t[5]!==o?(i=u.jsxs(Ui,{"data-testid":"layout-select",value:e,onValueChange:o,children:[r,s]}),t[4]=e,t[5]=o,t[6]=i):i=t[6],i};function IS(t){const e=Rg(t);return u.jsx(e,{className:"h-4 w-4"})}function Rg(t){switch(t){case"vertical":return Tp;case"grid":return sF;case"slides":return ad;default:return pc(t),gc}}function Pg(t){return km(t)}function AS(t){return u.jsx(fs,{value:t,children:u.jsxs("div",{className:"flex items-center gap-1.5 leading-5",children:[IS(t),u.jsx("span",{children:Pg(t)})]})},t)}const TS=()=>{const{updateCellConfig:t}=lt(),{saveCellConfig:e}=tt();return M.useCallback(async()=>{const n=new Wi,o=bn(),r=o.cellIds.inOrderIds,s={};for(const a of r){if(o.cellData[a]===void 0)continue;const{code:l,config:c}=o.cellData[a];c.hide_code||n.isSupported(l)&&(s[a]={hide_code:!0})}const i=fc.entries(s);if(i.length!==0){await e({configs:s});for(const[a,l]of i)t({cellId:a,config:l})}},[t])};function Lg(){const t=H.c(4),{openConfirm:e}=An(),n=jt(ln),{sendRestart:o}=tt();let r;return t[0]!==e||t[1]!==o||t[2]!==n?(r=()=>{e({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:u.jsx(L3,{onClick:async()=>{n({state:Bt.CLOSING}),await o(),uD()},"aria-label":"Confirm Restart",children:"Restart"})})},t[0]=e,t[1]=o,t[2]=n,t[3]=r):r=t[3],r}const Ps=t=>{t==null||t.preventDefault(),t==null||t.stopPropagation()};function Fg(){var X,Y;const t=H.c(39),e=Cm(),{openModal:n,closeModal:o}=An(),{toggleApplication:r}=qi(),{selectedPanel:s}=bc(),[i]=Dt(cm),a=je(us),l=TS(),[c]=br(),{updateCellConfig:d,undoDeleteCell:h,clearAllCellOutputs:f,upsertSetupCell:m,collapseAllCells:g,expandAllCells:x}=lt(),p=Lg(),b=rg(),y=function(G){const W=H.c(5),{openPrompt:J,closeModal:V}=An(),{sendCopy:Q}=tt();let te;return W[0]!==V||W[1]!==J||W[2]!==Q||W[3]!==G?(te=()=>{if(!G)return null;const re=xc.guessDeliminator(G),ne=yn.basename(G);J({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${ne}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:ie=>{const se=re.join(yn.dirname(G),ie);Q({source:G,destination:se}).then(()=>{V(),Je({title:"Notebook copied",description:"A copy of the notebook has been created."}),dj(se)})}})},W[0]=V,W[1]=J,W[2]=Q,W[3]=G,W[4]=te):te=W[4],te}(e),v=jt(gd),w=jt(iF),S=jt(aF),{exportAsMarkdown:C,readCode:N,saveCellConfig:j}=tt(),E=je(hD),T=je(fD),I=je(F3),{selectedLayout:O}=bj(),{setLayoutView:L}=yj(),D=og(),R=((X=c.sharing)==null?void 0:X.html)??!0,P=((Y=c.sharing)==null?void 0:Y.wasm)??!0,z=JS;let _;t[0]===Symbol.for("react.memo_cache_sentinel")?(_=u.jsx(Wp,{size:14,strokeWidth:1.5}),t[0]=_):_=t[0];const k=!R&&!P;let B;t[1]===Symbol.for("react.memo_cache_sentinel")?(B=u.jsx(bD,{size:14,strokeWidth:1.5}),t[1]=B):B=t[1];const A=!R;let U,$;return t[2]!==o||t[3]!==n?(U=async()=>{n(u.jsx(Fj,{onClose:o}))},t[2]=o,t[3]=n,t[4]=U):U=t[4],t[5]!==I||t[6]!==f||t[7]!==o||t[8]!==g||t[9]!==y||t[10]!==x||t[11]!==C||t[12]!==e||t[13]!==E||t[14]!==T||t[15]!==l||t[16]!==a||t[17]!==n||t[18]!==N||t[19]!==p||t[20]!==b||t[21]!==j||t[22]!==O||t[23]!==s||t[24]!==v||t[25]!==S||t[26]!==L||t[27]!==w||t[28]!==P||t[29]!==k||t[30]!==A||t[31]!==U||t[32]!==r||t[33]!==D||t[34]!==h||t[35]!==d||t[36]!==m||t[37]!==i.mode?($=[{icon:_,label:"Share",handle:Ps,hidden:k,dropdown:[{icon:B,label:"Publish HTML to web",hidden:A,handle:U},{icon:u.jsx(cj,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!P,handle:async()=>{const W=await N(),J=mD({code:W.contents});await sn(J),Je({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:u.jsx(jm,{size:14,strokeWidth:1.5}),label:"Download",handle:Ps,dropdown:[{icon:u.jsx(kj,{size:14,strokeWidth:1.5}),label:"Download as HTML",handle:async()=>{e?await wj({filename:e,includeCode:!0}):Je({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:u.jsx(kj,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{e?await wj({filename:e,includeCode:!1}):Je({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:u.jsx(lc,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{const W=await C({download:!1});Gi(new Blob([W],{type:"text/plain"}),z3.toMarkdown(document.title))}},{icon:u.jsx(xp,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{const W=await N();Gi(new Blob([W.contents],{type:"text/plain"}),z3.toPY(document.title))}},{divider:!0,icon:u.jsx(ip,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:i.mode!=="present",tooltip:i.mode==="present"?void 0:u.jsxs("span",{children:["Only available in app view. ",u.jsx("br",{}),"Toggle with: ",Gt("global.hideCode",!1)]}),handle:XS},{icon:u.jsx(pD,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:i.mode!=="present",tooltip:i.mode==="present"?void 0:u.jsxs("span",{children:["Only available in app view. ",u.jsx("br",{}),"Toggle with: ",Gt("global.hideCode",!1)]}),handle:YS}]},{divider:!0,icon:u.jsx(zp,{size:14,strokeWidth:1.5}),label:"Helper panel",handle:Ps,dropdown:fd.flatMap(W=>{const{type:J,Icon:V,hidden:Q}=W;return Q?[]:{label:km(J),rightElement:z(s===J),icon:u.jsx(V,{size:14,strokeWidth:1.5}),handle:()=>r(J)}})},{icon:u.jsx(ad,{size:14,strokeWidth:1.5}),label:"Present as",handle:Ps,dropdown:[{icon:i.mode==="present"?u.jsx(B3,{size:14,strokeWidth:1.5}):u.jsx(rd,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{D()}},...vj.map((W,J)=>{const V=Rg(W);return{divider:J===0,label:Pg(W),icon:u.jsx(V,{size:14,strokeWidth:1.5}),rightElement:u.jsx("div",{className:"w-8 flex justify-end",children:O===W&&u.jsx(yc,{size:14})}),handle:()=>{L(W),i.mode==="edit"&&D()}}})]},{icon:u.jsx(Cp,{size:14,strokeWidth:1.5}),label:"Create notebook copy",hidden:!e||tn(),handle:y},{icon:u.jsx(Qc,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!e,handle:async()=>{const W=await N();await sn(W.contents),Je({title:"Copied",description:"Code copied to clipboard."})}},{icon:u.jsx(hn,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!E||a,handle:async()=>{const W=bn(),J=gD(W),V=fc.fromEntries(J.map(GS));await j({configs:V});for(const Q of J)d({cellId:Q,config:{disabled:!1}})}},{icon:u.jsx(un,{size:14,strokeWidth:1.5}),label:"Disable all cells",hidden:!T||a,handle:async()=>{const W=bn(),J=f3(W),V=fc.fromEntries(J.map(qS));await j({configs:V});for(const Q of J)d({cellId:Q,config:{disabled:!0}})}},{icon:u.jsx(hm,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:l},{icon:u.jsx(pp,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:g},{icon:u.jsx(mp,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:x},{icon:u.jsx(yp,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{m({code:"# Initialization code that runs before all other cells"})}},{icon:u.jsx(Pi,{size:14,strokeWidth:1.5}),label:"Clear all outputs",handle:()=>{f()}},{icon:u.jsx(wp,{size:14,strokeWidth:1.5}),label:"Re-run all cells",hotkey:"global.runAll",handle:async()=>{b()}},{icon:u.jsx(ud,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!I||a,handle:()=>{h()}},{icon:u.jsx(Yo,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n(u.jsx(Dg,{onClose:o}))}},{divider:!0,icon:u.jsx(ed,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(WS)},{icon:u.jsx(Sm,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>w(HS)},{icon:u.jsx(Ap,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>S(VS)},{icon:u.jsx(uj,{size:14,strokeWidth:1.5}),label:"Open documentation",handle:$S},{icon:u.jsx(vc,{size:14,strokeWidth:1.5}),label:"Resources",handle:Ps,dropdown:[{icon:u.jsx(uj,{size:14,strokeWidth:1.5}),label:"Documentation",handle:US},{icon:u.jsx(lF,{size:14,strokeWidth:1.5}),label:"GitHub",handle:BS},{icon:u.jsx(cF,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:zS},{icon:u.jsx(dF,{size:14,strokeWidth:1.5}),label:"YouTube",handle:FS},{icon:u.jsx(dm,{size:14,strokeWidth:1.5}),label:"Changelog",handle:LS}]},{divider:!0,icon:u.jsx(_p,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:PS},{icon:u.jsx(ba,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:RS},{icon:u.jsx(Jp,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:p}].filter(DS).map(MS),t[5]=I,t[6]=f,t[7]=o,t[8]=g,t[9]=y,t[10]=x,t[11]=C,t[12]=e,t[13]=E,t[14]=T,t[15]=l,t[16]=a,t[17]=n,t[18]=N,t[19]=p,t[20]=b,t[21]=j,t[22]=O,t[23]=s,t[24]=v,t[25]=S,t[26]=L,t[27]=w,t[28]=P,t[29]=k,t[30]=A,t[31]=U,t[32]=r,t[33]=D,t[34]=h,t[35]=d,t[36]=m,t[37]=i.mode,t[38]=$):$=t[38],$}function MS(t){return t.dropdown?{...t,dropdown:t.dropdown.filter(OS)}:t}function OS(t){return!t.hidden}function DS(t){return!t.hidden}function RS(){const t=xD();window.open(t,"_blank")}function PS(){const t=document.baseURI.split("?")[0];window.open(t,"_self")}function LS(){window.open(Fn.releasesPage,"_blank")}function FS(){window.open(Fn.youtube,"_blank")}function zS(){window.open(Fn.discordLink,"_blank")}function BS(){window.open(Fn.githubPage,"_blank")}function US(){window.open(Fn.docsPage,"_blank")}function $S(){window.open(Fn.docsPage,"_blank")}function VS(t){return!t}function HS(t){return!t}function WS(t){return!t}function qS(t){return[t,{disabled:!0}]}function GS(t){return[t,{disabled:!1}]}async function YS(){const t=new Event("export-beforeprint"),e=new Event("export-afterprint");window.dispatchEvent(t),setTimeout(KS,0),setTimeout(()=>window.dispatchEvent(e),0)}function KS(){return window.print()}async function XS(){const t=document.getElementById("App");t&&await x3(t,document.title)}function JS(t){return u.jsx("div",{className:"w-8 flex justify-end",children:t&&u.jsx(yc,{size:14})})}const ZS=t=>{const e=H.c(28),{disabled:n,tooltip:o}=t,r=n!==void 0&&n,s=o===void 0?"Actions":o,i=Fg();let a,l,c;e[0]!==s?(a=u.jsx("div",{children:s}),e[0]=s,e[1]=a):a=e[1],e[2]!==r?(l=!r&&u.jsxs("div",{className:"text-xs text-muted-foreground font-medium pt-1 -mt-2 border-t border-border flex items-center gap-2",children:[u.jsx("span",{children:"Open command palette"}),Gt("global.commandPalette",!1)]}),e[2]=r,e[3]=l):l=e[3],e[4]!==a||e[5]!==l?(c=u.jsxs("div",{className:"flex flex-col gap-2",children:[a,l]}),e[4]=a,e[5]=l,e[6]=c):c=e[6];const d=c,h=r?"disabled":"hint-green";let f,m,g;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=u.jsx(CF,{strokeWidth:1.8}),e[7]=f):f=e[7],e[8]!==d?(m=u.jsx(Ne,{content:d,children:f}),e[8]=d,e[9]=m):m=e[9],e[10]!==r||e[11]!==h||e[12]!==m?(g=u.jsx(cn,{"aria-label":"Config",shape:"circle",size:"small",className:"h-[27px] w-[27px]","data-testid":"notebook-menu-dropdown",disabled:r,color:h,children:m}),e[10]=r,e[11]=h,e[12]=m,e[13]=g):g=e[13];const x=g,p=QS;let b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=E=>{const T=u.jsx(At,{variant:E.variant,disabled:E.disabled,onSelect:I=>E.handle(I),"data-testid":`notebook-menu-dropdown-${E.label}`,children:p(E)},E.label);return E.tooltip?u.jsx(Ne,{content:E.tooltip,side:"left",delayDuration:100,children:u.jsx("span",{children:T})},E.label):T},e[14]=b):b=e[14];const y=b;let v,w,S,C,N,j;if(e[15]!==x||e[16]!==r?(v=u.jsx(_o,{asChild:!0,disabled:r,children:x}),e[15]=x,e[16]=r,e[17]=v):v=e[17],e[18]!==i){let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=T=>T.hidden?null:T.dropdown?u.jsxs(yD,{children:[u.jsx(vD,{"data-testid":`notebook-menu-dropdown-${T.label}`,children:p(T)}),u.jsx(wD,{children:u.jsx(kD,{children:T.dropdown.map(I=>u.jsxs(q.Fragment,{children:[I.divider&&u.jsx(an,{}),y(I)]},I.label))})})]},T.label):u.jsxs(q.Fragment,{children:[T.divider&&u.jsx(an,{}),y(T)]},T.label),e[20]=E):E=e[20],w=i.map(E),e[18]=i,e[19]=w}else w=e[19];return e[21]===Symbol.for("react.memo_cache_sentinel")?(S=u.jsx(an,{}),e[21]=S):S=e[21],e[22]===Symbol.for("react.memo_cache_sentinel")?(C=u.jsx("div",{className:"flex-1 px-2 text-xs text-muted-foreground",children:u.jsxs("span",{children:["Version: ",U3()]})}),e[22]=C):C=e[22],e[23]!==w?(N=u.jsxs(Io,{align:"end",className:"no-print w-[240px]",children:[w,S,C]}),e[23]=w,e[24]=N):N=e[24],e[25]!==v||e[26]!==N?(j=u.jsxs(Eo,{modal:!1,children:[v,N]}),e[25]=v,e[26]=N,e[27]=j):j=e[27],j};function QS(t){return u.jsxs(u.Fragment,{children:[t.icon&&u.jsx("span",{className:"flex-0 mr-2",children:t.icon}),u.jsx("span",{className:"flex-1",children:t.labelElement||t.label}),t.hotkey&&u.jsx(Nm,{shortcut:t.hotkey,className:"ml-4"}),t.rightElement]})}function yd(t){return Un("create"in t,'Expected query to have a "create" method'),t}const $t=CD({findText:"",replaceText:"",caseSensitive:!1,wholeWord:!1,regexp:!1,isOpen:!1,currentView:void 0},(t,e)=>{if(e===void 0)return t;switch(e.type){case"setFind":return{...t,findText:e.find};case"setReplace":return{...t,replaceText:e.replace};case"setCaseSensitive":return{...t,caseSensitive:e.caseSensitive};case"setWholeWord":return{...t,wholeWord:e.wholeWord};case"setRegex":return{...t,regexp:e.regexp};case"setIsOpen":return{...t,isOpen:e.isOpen};case"setCurrentView":return{...t,currentView:{view:e.view,range:e.range}};case"clearCurrentView":return{...t,currentView:void 0}}});function zg(t){if([...document.querySelectorAll('[role="dialog"][data-state="open"]')].some(e=>e instanceof HTMLElement&&e.childNodes.length>0))return!1;if(t){const e=t.state.selection.main,n=t.state.sliceDoc(e.from,e.to);n?(Qe.set($t,{type:"setFind",find:n}),Qe.set($t,{type:"setCurrentView",view:t,range:{from:e.from,to:e.to}})):Qe.set($t,{type:"setCurrentView",view:t,range:{from:0,to:0}})}return Qe.get($t).isOpen?(Qe.set($t,{type:"setIsOpen",isOpen:!1}),requestAnimationFrame(()=>{Qe.set($t,{type:"setIsOpen",isOpen:!0})}),!0):(Qe.set($t,{type:"setIsOpen",isOpen:!0}),!0)}function e4(){return!!Qe.get($t).isOpen&&(Qe.set($t,{type:"setIsOpen",isOpen:!1}),!0)}function Ia(t){return()=>{const e=Qe.get($t),n=new wc({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord});return!!n.valid&&t({query:yd(n).create(),search:n})}}const Bg=t=>Ia(({query:e})=>{const n=ps(),o=Qe.get($t).currentView||{view:n[0],range:{from:0,to:0}};let r=o.range.to;t==="prev"&&(n.reverse(),r=o.range.from);let s=n.indexOf(o.view);s<0&&(s=0);const i=[...n,...n].slice(s);for(const a of i){const l=t==="next"?e.nextMatch(a.state,0,r??0):e.prevMatch(a.state,r??a.state.doc.length,a.state.doc.length);if(!l){r=null,a.dispatch({selection:Qn.single(0)});continue}const c=Qn.single(l.from,l.to);return a.dispatch({selection:c,effects:[We.scrollIntoView(c.main,{y:"center"})],userEvent:"select.search"}),Qe.set($t,{type:"setCurrentView",view:a,range:{from:l.from,to:l.to}}),l}return!1}),vd=Bg("next"),Ug=Bg("prev"),t4=Ia(({query:t})=>{var o;const e=ps(),n=[];for(const r of e){if(r.state.readOnly)continue;const s=(o=t.matchAll(r.state,1e9))==null?void 0:o.map(a=>{const{from:l,to:c}=a;return{from:l,to:c,insert:t.getReplacement(a)}});if(!s||s.length===0)continue;const i=r.state.doc.toString();n.push(()=>{r.dispatch({changes:[{from:0,to:r.state.doc.length,insert:i}],userEvent:"input.replace.all"})}),r.dispatch({changes:s,userEvent:"input.replace.all"})}return()=>{for(const r of n)r()}}),n4=Ia(({query:t})=>{const e=ps(),n=Qe.get($t).currentView||{view:e[0],range:{from:0}};let o=n.range.from,r=e.indexOf(n.view);r<0&&(r=0);const s=[...e,...e].slice(r);for(const i of s){const a=t.nextMatch(i.state,0,o??0);if(!a){o=null,i.dispatch({selection:Qn.single(0)});continue}const l=i.state.toText(t.getReplacement(a));return i.dispatch({changes:[{from:a.from,to:a.to,insert:l}],userEvent:"input.replace"}),vd()}return!1}),o4=Ia(({query:t})=>{const e=ps();let n=0;const o=new Map;for(const r of e){const s=t.matchAll(r.state,1e9)||[];for(const i of s){const{from:a,to:l}=i,c=o.get(r)||new Map;c.set(`${a}:${l}`,n++),o.set(r,c)}}return{count:n,position:o}}),wd=Tt.define();function $g(){const t=ps();for(const e of t)e.state.readOnly||e.dispatch({effects:wd.of(new wc({search:""}))})}const Aa=vn.define({create(){const t=Qe.get($t);return yd(new wc({search:t.findText,caseSensitive:t.caseSensitive,regexp:t.regexp,replace:t.replaceText,wholeWord:t.wholeWord})).create()},update(t,e){for(const n of e.effects)n.is(wd)&&(t=yd(n.value).create());return t}}),r4=ot.mark({class:"cm-searchMatch"}),s4=ot.mark({class:"cm-searchMatch cm-searchMatch-selected"}),i4=$n.fromClass(class{constructor(t){this.view=t,this.decorations=void 0,this.decorations=this.highlight(t.state.field(Aa))}update(t){const e=t.state.field(Aa);(e!==t.startState.field(Aa)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight(t){if(!t.spec.valid)return ot.none;const{view:e}=this,n=new gs,o=e.visibleRanges,r=o.length;for(let s=0;s<r;s++){let{to:i}=o[s];const{from:a}=o[s];for(;s<r-1&&i>o[s+1].from-500;)i=o[++s].to;t.highlight(e.state,a,i,(l,c)=>{const d=e.state.selection.ranges.some(h=>h.from===l&&h.to===c);n.add(l,c,d?s4:r4)})}return n.finish()}},{decorations:t=>t.decorations}),a4=We.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"}}),l4=()=>{var _e;const t=H.c(102),[e,n]=M.useState(!1),[o,r]=Dt($t),[s,i]=M.useState(),a=M.useRef(null),l=je(hc);let c,d;t[0]!==e||t[1]!==o.isOpen?(c=()=>(!e||!o.isOpen)&&zg(),t[0]=e,t[1]=o.isOpen,t[2]=c):c=t[2],Rt("cell.findAndReplace",c),t[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const ke=o4();i(ke===!1?void 0:ke)},t[3]=d):d=t[3];const h=d;let f,m,g,x;if(t[4]!==o.isOpen?(f=()=>{o.isOpen&&a.current&&(a.current.focus(),a.current.select())},m=[o.isOpen],t[4]=o.isOpen,t[5]=f,t[6]=m):(f=t[5],m=t[6]),M.useEffect(f,m),t[7]!==o.findText||t[8]!==o.isOpen?(g=()=>{if(o.isOpen){if(o.findText==="")return i(void 0),void $g();h(),function(){const ke=Qe.get($t),Ye=ps();for(const Ve of Ye)Ve.state.readOnly||Ve.dispatch({effects:wd.of(new wc({search:ke.findText,caseSensitive:ke.caseSensitive,regexp:ke.regexp,replace:ke.replaceText,wholeWord:ke.wholeWord}))})}()}else $g()},t[7]=o.findText,t[8]=o.isOpen,t[9]=g):g=t[9],t[10]!==o.caseSensitive||t[11]!==o.findText||t[12]!==o.isOpen||t[13]!==o.regexp||t[14]!==o.wholeWord?(x=[o.findText,o.isOpen,o.caseSensitive,o.regexp,o.wholeWord],t[10]=o.caseSensitive,t[11]=o.findText,t[12]=o.isOpen,t[13]=o.regexp,t[14]=o.wholeWord,t[15]=x):x=t[15],M.useEffect(g,x),!o.isOpen)return null;const p=o.currentView;let b;t[16]!==s||t[17]!==p?(b=p&&s?(_e=s.position.get(p.view))==null?void 0:_e.get(`${p.range.from}:${p.range.to}`):void 0,t[16]=s,t[17]=p,t[18]=b):b=t[18];const y=b;let v,w,S,C,N,j,E,T,I,O,L;t[19]===Symbol.for("react.memo_cache_sentinel")?(v=()=>n(!0),t[19]=v):v=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(w=()=>n(!1),t[20]=w):w=t[20],t[21]!==r?(S=ke=>{ke.key==="Escape"&&r({type:"setIsOpen",isOpen:!1})},t[21]=r,t[22]=S):S=t[22],t[23]!==r?(C=()=>r({type:"setIsOpen",isOpen:!1}),t[23]=r,t[24]=C):C=t[24],t[25]===Symbol.for("react.memo_cache_sentinel")?(N=u.jsx(wn,{className:"w-4 h-4"}),t[25]=N):N=t[25],t[26]!==C?(j=u.jsx("div",{className:"absolute top-0 right-0",children:u.jsx(ve,{"data-testid":"close-find-replace-button",onClick:C,size:"xs",variant:"text",children:N})}),t[26]=C,t[27]=j):j=t[27],t[28]!==r?(E=ke=>{r({type:"setFind",find:ke.target.value})},t[28]=r,t[29]=E):E=t[29],t[30]!==o.findText||t[31]!==E?(T=u.jsx(qo,{ref:a,"data-testid":"find-input",value:o.findText,autoFocus:!0,className:"mr-2 mb-0",placeholder:"Find",onKeyDown:d4,onChange:E}),t[30]=o.findText,t[31]=E,t[32]=T):T=t[32],t[33]!==r?(I=ke=>{r({type:"setReplace",replace:ke.target.value})},t[33]=r,t[34]=I):I=t[34],t[35]!==o.replaceText||t[36]!==I?(O=u.jsx(qo,{"data-testid":"replace-input",value:o.replaceText,placeholder:"Replace",onChange:I}),t[35]=o.replaceText,t[36]=I,t[37]=O):O=t[37],t[38]!==T||t[39]!==O?(L=u.jsxs("div",{className:"flex flex-col flex-2 gap-2 w-[55%]",children:[T,O]}),t[38]=T,t[39]=O,t[40]=L):L=t[40];const D=o.caseSensitive?"on":"off";let R,P,z;t[41]!==r?(R=ke=>r({type:"setCaseSensitive",caseSensitive:ke}),t[41]=r,t[42]=R):R=t[42],t[43]===Symbol.for("react.memo_cache_sentinel")?(P=u.jsx(jD,{className:"w-4 h-4"}),t[43]=P):P=t[43],t[44]!==o.caseSensitive||t[45]!==D||t[46]!==R?(z=u.jsx(Ne,{content:"Case Sensitive",children:u.jsx(Em,{size:"sm",pressed:o.caseSensitive,"data-state":D,onPressedChange:R,children:P})}),t[44]=o.caseSensitive,t[45]=D,t[46]=R,t[47]=z):z=t[47];const _=o.wholeWord?"on":"off";let k,B,A;t[48]!==r?(k=ke=>r({type:"setWholeWord",wholeWord:ke}),t[48]=r,t[49]=k):k=t[49],t[50]===Symbol.for("react.memo_cache_sentinel")?(B=u.jsx(ng,{className:"w-4 h-4"}),t[50]=B):B=t[50],t[51]!==o.wholeWord||t[52]!==_||t[53]!==k?(A=u.jsx(Ne,{content:"Match Whole Word",children:u.jsx(Em,{size:"sm",pressed:o.wholeWord,"data-state":_,onPressedChange:k,children:B})}),t[51]=o.wholeWord,t[52]=_,t[53]=k,t[54]=A):A=t[54];const U=o.regexp?"on":"off";let $,X,Y,G,W;t[55]!==r?($=ke=>r({type:"setRegex",regexp:ke}),t[55]=r,t[56]=$):$=t[56],t[57]===Symbol.for("react.memo_cache_sentinel")?(X=u.jsx($p,{className:"w-4 h-4"}),t[57]=X):X=t[57],t[58]!==o.regexp||t[59]!==U||t[60]!==$?(Y=u.jsx(Ne,{content:"Use Regular Expression",children:u.jsx(Em,{size:"sm",pressed:o.regexp,"data-state":U,onPressedChange:$,children:X})}),t[58]=o.regexp,t[59]=U,t[60]=$,t[61]=Y):Y=t[61],t[62]!==z||t[63]!==A||t[64]!==Y?(G=u.jsxs("div",{className:"flex items-center gap-[2px]",children:[z,A,Y]}),t[62]=z,t[63]=A,t[64]=Y,t[65]=G):G=t[65],t[66]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{n4()&&h()},t[66]=W):W=t[66];const J=o.findText==="";let V,Q;t[67]!==J?(V=u.jsx(ve,{"data-testid":"replace-next-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:W,disabled:J,children:"Replace Next"}),t[67]=J,t[68]=V):V=t[68],t[69]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>{const ke=t4();if(!ke)return;h();const{dismiss:Ye}=Je({title:"Replaced all occurrences",action:u.jsx(Sa,{"data-testid":"undo-replace-all-button",onClick:()=>{ke(),Ve()}})}),Ve=Ye},t[69]=Q):Q=t[69];const te=o.findText==="";let re,ne,ie,se,ae,ge,oe,ue,de,Se,Te,Fe;return t[70]!==te?(re=u.jsx(ve,{"data-testid":"replace-all-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:Q,disabled:te,children:"Replace All"}),t[70]=te,t[71]=re):re=t[71],t[72]!==V||t[73]!==re?(ne=u.jsxs("div",{className:"flex items-center gap-[2px]",children:[V,re]}),t[72]=V,t[73]=re,t[74]=ne):ne=t[74],t[75]!==G||t[76]!==ne?(ie=u.jsxs("div",{className:"flex flex-col gap-2",children:[G,ne]}),t[75]=G,t[76]=ne,t[77]=ie):ie=t[77],t[78]!==L||t[79]!==ie?(se=u.jsxs("div",{className:"flex items-center gap-3",children:[L,ie]}),t[78]=L,t[79]=ie,t[80]=se):se=t[80],t[81]===Symbol.for("react.memo_cache_sentinel")?(ae=u.jsx(Ne,{content:"Find Previous",children:u.jsx(ve,{"data-testid":"find-prev-button",size:"xs",variant:"secondary",onClick:u4,children:u.jsx(kt,{className:"w-4 h-4"})})}),t[81]=ae):ae=t[81],t[82]===Symbol.for("react.memo_cache_sentinel")?(ge=u.jsx(Ne,{content:"Find Next",children:u.jsx(ve,{"data-testid":"find-next-button",size:"xs",variant:"secondary",onClick:h4,children:u.jsx(Xc,{className:"w-4 h-4"})})}),t[82]=ge):ge=t[82],t[83]!==y||t[84]!==s?(oe=s!=null&&y==null&&u.jsxs("span",{className:"text-sm",children:[s.count," matches"]}),t[83]=y,t[84]=s,t[85]=oe):oe=t[85],t[86]!==y||t[87]!==s?(ue=s!=null&&y!=null&&u.jsxs("span",{className:"text-sm",children:[y+1," of ",s.count]}),t[86]=y,t[87]=s,t[88]=ue):ue=t[88],t[89]!==oe||t[90]!==ue?(de=u.jsxs("div",{className:"flex items-center gap-2",children:[ae,ge,oe,ue]}),t[89]=oe,t[90]=ue,t[91]=de):de=t[91],t[92]!==l?(Se=l.getHotkey("cell.findAndReplace"),t[92]=l,t[93]=Se):Se=t[93],t[94]!==Se.key?(Te=u.jsxs("div",{className:"text-xs text-muted-foreground flex gap-1 mt-2",children:["Press"," ",u.jsx(xm,{shortcut:Se.key})," ","again to open the native browser search."]}),t[94]=Se.key,t[95]=Te):Te=t[95],t[96]!==j||t[97]!==se||t[98]!==de||t[99]!==Te||t[100]!==S?(Fe=u.jsx(_m,{restoreFocus:!0,autoFocus:!0,children:u.jsxs("div",{onFocus:v,onClick:c4,onBlur:w,className:"fixed top-0 right-0 w-[500px] flex flex-col bg-(--sage-1) p-4 z-50 mt-2 mr-3 rounded-md shadow-lg border gap-2 print:hidden",onKeyDown:S,children:[j,se,de,Te]})}),t[96]=j,t[97]=se,t[98]=de,t[99]=Te,t[100]=S,t[101]=Fe):Fe=t[101],Fe};function c4(t){t.stopPropagation(),t.preventDefault()}function d4(t){t.key==="Enter"&&(t.shiftKey?Ug():vd())}function u4(){return Ug()}function h4(){return vd()}const Vg=t=>{const e=H.c(41),{resetOnBlur:n,placeholderText:o,initialValue:r,flexibleWidth:s,onNameChange:i,className:a}=t,l=n!==void 0&&n,c=r===void 0?null:r,d=s!==void 0&&s,{sendListFiles:h}=tt(),[f,m]=M.useState(c);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=[],e[0]=g):g=e[0];const[x,p]=M.useState(g),[b,y]=M.useState(!1),v=M.useRef(null),w=M.useRef(!1);let S,C,N;e[1]!==c?(S=()=>{m(c)},C=[c],e[1]=c,e[2]=S,e[3]=C):(S=e[2],C=e[3]),M.useEffect(S,C),e[4]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{y(!0)},e[4]=N):N=e[4];const j=N;let E;e[5]!==c||e[6]!==l?(E=te=>{var re;(re=te.relatedTarget)!=null&&re.closest(".filename-input")||(y(!1),l&&m(c))},e[5]=c,e[6]=l,e[7]=E):E=e[7];const T=E;let I;e[8]!==f?(I=yn.dirname(f||""),e[8]=f,e[9]=I):I=e[9];const O=I,L=yn.basename(f||""),D=x.filter(te=>yn.basename(te.path).startsWith(L));let R,P;e[10]!==O||e[11]!==b||e[12]!==h?(R=async()=>{if(!b)return void p([]);const te=await h({path:O});p(te.files)},e[10]=O,e[11]=b,e[12]=h,e[13]=R):R=e[13],e[14]!==O||e[15]!==b?(P=[O,b],e[14]=O,e[15]=b,e[16]=P):P=e[16];const{isPending:z}=Tn(R,P),_=function(te,re,ne){if(te&&!te.endsWith("/")&&((wm("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(yn.extension(te))||(te=te.endsWith(".")?`${te}py`:te.endsWith(".p")?`${te}y`:`${te}.py`),!re.some(ie=>ie.path===te||yn.basename(ie.path)===te)&&!(ne&&(ne===te||yn.basename(ne)===te))))return te}(f,x,c),k=(_||D.length>0)&&u.jsxs(pm,{className:"font-mono",children:[!z&&u.jsx(mc,{children:"No files"}),_&&u.jsxs(Zn,{variant:"success",className:"py-2 px-3",onSelect:()=>{var te;_&&(w.current=!0,i(_),(te=v.current)==null||te.blur())},children:[u.jsx(kp,{className:"w-4 h-4 mr-2"})," ",u.jsxs("span",{className:"text-sm",children:[c?"Rename to: ":"Save as: ",u.jsx("span",{className:"font-medium text-sm",children:yn.basename(_)})]})]},"_rename_"),D.map(te=>{const re=te.isDirectory?"directory":$3(te.path),ne=V3[re];return u.jsxs(Zn,{variant:te.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{te.isDirectory?m(`${te.path}/`):m(te.path)},children:[u.jsx(ne,{className:"w-4 h-4 mr-2"})," ",yn.basename(te.path)]},te.path)})]}),B=10*Math.max(20,(f==null?void 0:f.length)||(o==null?void 0:o.length)||0),A=b?f||"":c||"";let U,$,X;e[17]!==d||e[18]!==B?(U=d?{maxWidth:B}:void 0,e[17]=d,e[18]=B,e[19]=U):U=e[19],e[20]!==a?($=xe(a,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60"),e[20]=a,e[21]=$):$=e[21],e[22]!==o||e[23]!==A||e[24]!==U||e[25]!==$?(X=u.jsx(SD,{children:u.jsx(Bi,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:A,onKeyDown:f4,icon:null,ref:v,onValueChange:m,placeholder:o,autoComplete:"off",style:U,className:$})}),e[22]=o,e[23]=A,e[24]=U,e[25]=$,e[26]=X):X=e[26];const Y=k&&"group-focus-within:block";let G,W,J,V,Q;return e[27]!==Y?(G=xe("p-0 w-full min-w-80 max-w-80vw hidden",Y),e[27]=Y,e[28]=G):G=e[28],e[29]!==k||e[30]!==G?(W=u.jsx(xs,{side:"bottom",className:G,portal:!1,children:k}),e[29]=k,e[30]=G,e[31]=W):W=e[31],e[32]!==X||e[33]!==W?(J=u.jsxs(pm,{children:[X,W]}),e[32]=X,e[33]=W,e[34]=J):J=e[34],e[35]!==T||e[36]!==J?(V=u.jsx(kc,{onFocus:j,onBlur:T,shouldFilter:!1,id:"filename-input",className:"bg-transparent group filename-input",children:J}),e[35]=T,e[36]=J,e[37]=V):V=e[37],e[38]!==b||e[39]!==V?(Q=u.jsx(Cc,{children:u.jsx(yr,{open:b,modal:!1,children:V})}),e[38]=b,e[39]=V,e[40]=Q):Q=e[40],Q};function f4(t){t.key==="Escape"&&t.currentTarget.blur()}const m4=t=>{const e=H.c(33),n=()=>{Gi(new Blob([o()],{type:"text/plain"}),`${t.proposedName}.json`)},o=Le(x4);let r,s,i,a,l,c,d,h,f,m,g,x,p,b,y,v,w;return e[0]!==n||e[1]!==t?(r=S=>{S.preventDefault(),n(),t.closeModal()},e[0]=n,e[1]=t,e[2]=r):r=e[2],e[3]!==t?(s=S=>{S.key==="Escape"&&t.closeModal()},e[3]=t,e[4]=s):s=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(i=u.jsx(Wo,{className:"text-accent-foreground mb-6",children:"Download unsaved changes?"}),e[5]=i):i=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(a={wordBreak:"break-word"},e[6]=a):a=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx("p",{children:"This app has unsaved changes. To recover:"}),c={paddingBottom:"10px"},e[7]=l,e[8]=c):(l=e[7],c=e[8]),e[9]!==t.proposedName?(d=u.jsxs("li",{style:c,children:['Click the "Download" button. This will download a file called\xA0',u.jsxs("code",{children:[t.proposedName,".json"]}),". This file contains your code."]}),e[9]=t.proposedName,e[10]=d):d=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(h={paddingBottom:"10px"},e[11]=h):h=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(f={display:"block",padding:"10px"},e[12]=f):f=e[12],e[13]!==t.proposedName?(m=u.jsxs("code",{style:f,children:["marimo recover ",t.proposedName,".json ",">"," ",t.proposedName,".py"]}),e[13]=t.proposedName,e[14]=m):m=e[14],e[15]!==t.proposedName?(g=u.jsxs("code",{children:[t.proposedName,".py"]}),e[15]=t.proposedName,e[16]=g):g=e[16],e[17]!==g||e[18]!==m?(x=u.jsxs("li",{style:h,children:["In your terminal, type",m,"to overwrite ",g," with the recovered changes."]}),e[17]=g,e[18]=m,e[19]=x):x=e[19],e[20]!==x||e[21]!==d?(p=u.jsx(ds,{className:"markdown break-words",style:a,children:u.jsxs("div",{className:"prose dark:prose-invert",children:[l,u.jsxs("ol",{children:[d,x]})]})}),e[20]=x,e[21]=d,e[22]=p):p=e[22],e[23]!==t.closeModal?(b=u.jsx(ve,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:t.closeModal,children:"Cancel"}),e[23]=t.closeModal,e[24]=b):b=e[24],e[25]===Symbol.for("react.memo_cache_sentinel")?(y=u.jsx(ve,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"}),e[25]=y):y=e[25],e[26]!==b?(v=u.jsxs(Oi,{children:[b,y]}),e[26]=b,e[27]=v):v=e[27],e[28]!==r||e[29]!==s||e[30]!==p||e[31]!==v?(w=u.jsx(Go,{className:"w-fit",children:u.jsxs("form",{onSubmit:r,onKeyDown:s,children:[i,p,v]})}),e[28]=r,e[29]=s,e[30]=p,e[31]=v,e[32]=w):w=e[32],w},p4=t=>{const e=H.c(12),{filename:n,needsSave:o}=t,{openModal:r,closeModal:s}=An();let i;e[0]!==n?(i=n===null?"app":yn.basename(n).split(".")[0],e[0]=n,e[1]=i):i=e[1];const a=i;let l;e[2]!==s||e[3]!==o||e[4]!==r||e[5]!==a?(l=()=>{o&&r(u.jsx(m4,{proposedName:a,closeModal:s}))},e[2]=s,e[3]=o,e[4]=r,e[5]=a,e[6]=l):l=e[6];const c=l;let d;Rt("global.save",c),e[7]===Symbol.for("react.memo_cache_sentinel")?(d=Gt("global.save"),e[7]=d):d=e[7];const h=o?"yellow":"gray";let f,m;return e[8]===Symbol.for("react.memo_cache_sentinel")?(f=u.jsx(va,{strokeWidth:1.5,size:18}),e[8]=f):f=e[8],e[9]!==c||e[10]!==h?(m=u.jsx(Ne,{content:d,children:u.jsx(cn,{onClick:c,id:"save-button","aria-label":"Save",className:"rectangle",color:h,children:f})}),e[9]=c,e[10]=h,e[11]=m):m=e[11],m};function g4(t){return{id:t.id,name:t.name,code:t.code,code_hash:null,config:{column:0,...t.config}}}function x4(){const t=bn(),e=Im(t),n={version:"1",metadata:{marimo_version:U3()},cells:e.map(g4)};return JSON.stringify(n,null,2)}const kd=5e3,Cd=vt(void 0),Hg=vt(t=>{const e=t(Cd);return function({state:n,layout:o,lastSavedNotebook:r}){if(!r)return!1;const{cellIds:s,cellData:i}=n,a=s.inOrderIds.map(h=>i[h]),l=a.map(h=>h.code),c=a.map(h=>h.config),d=a.map(h=>h.name);return!(H3(l,r.codes)&&H3(d,r.names)&&Yi(c,r.configs)&&Yi(o.selectedLayout,r.layout.selectedLayout)&&Yi(o.layoutData,r.layout.layoutData))}({state:t(In),layout:t(Cj),lastSavedNotebook:e})});function b4(t){return JSON.stringify(t)}const y4=t=>{const e=H.c(15),{kioskMode:n}=t,o=Cm(),r=je(Hg),s=je(ln).state===Bt.CLOSED,{saveOrNameNotebook:i,saveIfNotebookIsPersistent:a}=jd();let l,c,d;e[0]!==n||e[1]!==a?(l={onSave:a,kioskMode:n},e[0]=n,e[1]=a,e[2]=l):l=e[2],function(p){const b=H.c(14),y=je(G3),v=Tm(),[w]=Dt(ln),S=je(Hg);let C,N;if(b[0]!==v){const O=Im(v);C=O.map(j4),N=O.map(C4),b[0]=v,b[1]=C,b[2]=N}else C=b[1],N=b[2];const j=N;let E;b[3]!==v?(E=q3(v),b[3]=v,b[4]=E):E=b[4];const T=E;let I;b[5]!==y||b[6]!==j||b[7]!==C||b[8]!==T||b[9]!==w||b[10]!==S||b[11]!==p.kioskMode||b[12]!==p.onSave?(I={onSave:p.onSave,needsSave:S,codes:C,cellConfigs:T,cellNames:j,connStatus:w,config:y,kioskMode:p.kioskMode},b[5]=y,b[6]=j,b[7]=C,b[8]=T,b[9]=w,b[10]=S,b[11]=p.kioskMode,b[12]=p.onSave,b[13]=I):I=b[13],function(O){const L=H.c(21),{codes:D,cellConfigs:R,config:P,connStatus:z,cellNames:_,needsSave:k,kioskMode:B,onSave:A}=O,U=M.useRef(null);let $;L[0]!==D?($=D.join(":"),L[0]=D,L[1]=$):$=L[1];const X=$;let Y;L[2]!==R?(Y=R.map(b4).join(":"),L[2]=R,L[3]=Y):Y=L[3];const G=Y;let W;L[4]!==_?(W=_.join(":"),L[4]=_,L[5]=W):W=L[5];const J=W;let V,Q;L[6]!==P||L[7]!==z.state||L[8]!==B||L[9]!==k||L[10]!==A?(V=()=>{if(!B)return P.autosave==="after_delay"&&(U.current!==null&&clearTimeout(U.current),k&&z.state===Bt.OPEN&&(U.current=setTimeout(A,P.autosave_delay))),()=>{U.current!==null&&clearTimeout(U.current)}},L[6]=P,L[7]=z.state,L[8]=B,L[9]=k,L[10]=A,L[11]=V):V=L[11],L[12]!==G||L[13]!==J||L[14]!==X||L[15]!==P||L[16]!==z.state||L[17]!==B||L[18]!==k||L[19]!==A?(Q=[X,G,J,P,z.state,A,B,k],L[12]=G,L[13]=J,L[14]=X,L[15]=P,L[16]=z.state,L[17]=B,L[18]=k,L[19]=A,L[20]=Q):Q=L[20],M.useEffect(V,Q)}(I)}(l),function(){const p=H.c(12),b=je(ND),{state:y}=je(ln),v=b.auto_download.includes("markdown"),w=b.auto_download.includes("html"),S=b.auto_download.includes("ipynb"),C=!v||y!==Bt.OPEN,N=!w||y!==Bt.OPEN,j=!S||y!==Bt.OPEN,{autoExportAsHTML:E,autoExportAsIPYNB:T,autoExportAsMarkdown:I}=tt();let O,L,D,R,P,z;p[0]!==I?(O=async()=>{await I({download:!1})},p[0]=I,p[1]=O):O=p[1],p[2]!==C?(L={delayMs:kd,whenVisible:!0,disabled:C},p[2]=C,p[3]=L):L=p[3],ha(O,L),p[4]!==E?(D=async()=>{await E({download:!1,includeCode:!0,files:pj.INSTANCE.filenames()})},p[4]=E,p[5]=D):D=p[5],p[6]!==N?(R={delayMs:kd,whenVisible:!0,disabled:N},p[6]=N,p[7]=R):R=p[7],ha(D,R),p[8]!==T?(P=async()=>{await T({download:!1})},p[8]=T,p[9]=P):P=p[9],p[10]!==j?(z={delayMs:kd,whenVisible:!0,disabled:j},p[10]=j,p[11]=z):z=p[11],ha(P,z)}(),e[3]!==r?(c=p=>{if(r)return p.preventDefault(),p.returnValue="You have unsaved changes. Are you sure you want to leave?",p.returnValue},e[3]=r,e[4]=c):c=e[4],rc(window,"beforeunload",c),e[5]!==i?(d=p=>{p.preventDefault(),p.stopPropagation(),i()},e[5]=i,e[6]=d):d=e[6];const h=d;if(Rt("global.save",i),s){let p;return e[7]!==o||e[8]!==r?(p=u.jsx(p4,{filename:o,needsSave:r}),e[7]=o,e[8]=r,e[9]=p):p=e[9],p}let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=Gt("global.save"),e[10]=f):f=e[10];const m=r?"yellow":"hint-green";let g,x;return e[11]===Symbol.for("react.memo_cache_sentinel")?(g=u.jsx(va,{strokeWidth:1.5,size:18}),e[11]=g):g=e[11],e[12]!==h||e[13]!==m?(x=u.jsx(Ne,{content:f,children:u.jsx(cn,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:m,onClick:h,children:g})}),e[12]=h,e[13]=m,e[14]=x):x=e[14],x};function jd(){const t=H.c(20),{sendSave:e}=tt(),{openModal:n,closeModal:o,openAlert:r}=An(),s=jt(Cd),i=W3(),a=Am();let l;t[0]!==r||t[1]!==e||t[2]!==s||t[3]!==a?(l=(b,y)=>{const v=bn(),w=Im(v),S=w.map(k4),C=w.map(w4),N=w.map(v4),j=q3(v),E=a.get(ln),T=a.get(G3),I=a.get(Cj);a.get(us)||C.length!==0&&(E.state===Bt.OPEN?(mt.log("saving to ",b),e({cellIds:S,codes:C,names:N,filename:b,configs:j,layout:jF(),persist:!0}).then(()=>{y&&T.format_on_save&&Y3(),s({names:N,codes:C,configs:j,layout:I})})):r("Failed to save notebook: not connected to a kernel."))},t[0]=r,t[1]=e,t[2]=s,t[3]=a,t[4]=l):l=t[4];const c=Le(l);let d;t[5]!==c||t[6]!==a?(d=b=>{const y=b!==void 0&&b,v=a.get(K3),w=a.get(ln);Wg(v)&&w.state===Bt.OPEN&&c(v,y)},t[5]=c,t[6]=a,t[7]=d):d=t[7];const h=Le(d);let f;t[8]!==c||t[9]!==i?(f=b=>{i(b).then(y=>{y!==null&&c(y,!0)})},t[8]=c,t[9]=i,t[10]=f):f=t[10];const m=f;let g;t[11]!==o||t[12]!==m||t[13]!==n||t[14]!==h||t[15]!==a?(g=()=>{const b=a.get(K3),y=a.get(ln);h(!0),Wg(b)||y.state===Bt.CLOSED||n(u.jsx(S4,{onClose:o,onSave:m}))},t[11]=o,t[12]=m,t[13]=n,t[14]=h,t[15]=a,t[16]=g):g=t[16];const x=Le(g);let p;return t[17]!==h||t[18]!==x?(p={saveOrNameNotebook:x,saveIfNotebookIsPersistent:h},t[17]=h,t[18]=x,t[19]=p):p=t[19],p}function v4(t){return t.name}function w4(t){return t.code}function k4(t){return t.id}function Wg(t){return t!==null&&!t.startsWith("/tmp")&&!t.startsWith("/var/folders")&&!t.includes("AppData\\Local\\Temp")}function C4(t){return t.name}function j4(t){return t.code}const S4=t=>{const e=H.c(17),{onClose:n,onSave:o}=t,[r,s]=M.useState();let i;e[0]!==n||e[1]!==o?(i=p=>{s(p),p.trim()&&(o(p),n())},e[0]=n,e[1]=o,e[2]=i):i=e[2];const a=i;let l,c,d,h;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx(Wo,{children:"Save notebook"}),e[3]=l):l=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(c=u.jsx(xr,{className:"text-md pt-6 px-1",children:"Save as"}),e[4]=c):c=e[4],e[5]!==a?(d=u.jsxs("div",{className:"flex flex-col",children:[c,u.jsx(Vg,{onNameChange:a,placeholderText:"filename",className:"missing-filename"})]}),e[5]=a,e[6]=d):d=e[6],e[7]!==n?(h=u.jsx(ve,{"data-testid":"cancel-save-dialog-button","aria-label":"Cancel",variant:"secondary",onClick:n,children:"Cancel"}),e[7]=n,e[8]=h):h=e[8];const f=!r;let m,g,x;return e[9]!==f?(m=u.jsx(ve,{"data-testid":"submit-save-dialog-button","aria-label":"Save",variant:"default",disabled:f,type:"submit",children:"Save"}),e[9]=f,e[10]=m):m=e[10],e[11]!==h||e[12]!==m?(g=u.jsxs(Oi,{children:[h,m]}),e[11]=h,e[12]=m,e[13]=g):g=e[13],e[14]!==d||e[15]!==g?(x=u.jsxs(Go,{children:[l,d,g]}),e[14]=d,e[15]=g,e[16]=x):x=e[16],x};function qg(t){const e=H.c(3),[n,o]=M.useState(!1);let r,s;return e[0]!==t?(r=()=>{if(!t)return;o(!1);const i=setTimeout(()=>{o(!0)},200);return()=>clearTimeout(i)},s=[t],e[0]=t,e[1]=r,e[2]=s):(r=e[1],s=e[2]),M.useEffect(r,s),t&&n}const Ls=t=>{const{children:e}=t;return je(us)?null:e},N4=t=>{const{children:e}=t;return je(us)?e:null},E4=()=>{const t=H.c(6),e=jt(gd);let n;t[0]!==e?(n=()=>e(_4),t[0]=e,t[1]=n):n=t[1];const o=n;let r,s,i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=Gt("global.commandPalette"),t[2]=r):r=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(s=u.jsx(ed,{strokeWidth:1.5,size:18}),t[3]=s):s=t[3],t[4]!==o?(i=u.jsx(Ne,{content:r,children:u.jsx(cn,{"data-testid":"command-palette-button",onClick:o,shape:"rectangle",color:"hint-green",children:s})}),t[4]=o,t[5]=i):i=t[5],i};function _4(t){return!t}const I4=t=>{const e=H.c(47),{presenting:n,onTogglePresenting:o,onInterrupt:r,onRun:s,connectionState:i,running:a,appConfig:l}=t,c=l.width,d=je(F3),h=je(ED),{undoDeleteCell:f}=lt(),m=i===Bt.CLOSED;let g,x=null;if(!m&&d){let k,B;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=u.jsx(ud,{size:16,strokeWidth:1.5}),e[0]=k):k=e[0],e[1]!==f?(B=u.jsx(Ne,{content:"Undo cell deletion",children:u.jsx(cn,{"data-testid":"undo-delete-cell",size:"medium",color:"hint-green",shape:"circle",onClick:f,children:k})}),e[1]=f,e[2]=B):B=e[2],x=B}e[3]!==i?(g=eo(i),e[3]=i,e[4]=g):g=e[4];const p=g;let b;e[5]!==i||e[6]!==p?(b=p?jc(i):void 0,e[5]=i,e[6]=p,e[7]=b):b=e[7];const y=b;let v,w;e[8]!==n?(v=!n&&u.jsx(l4,{}),e[8]=n,e[9]=v):v=e[9],e[10]!==m||e[11]!==y||e[12]!==p||e[13]!==n?(w=!m&&u.jsxs("div",{className:M4,children:[n&&u.jsx(_S,{}),u.jsx(ZS,{disabled:p,tooltip:y}),u.jsx(uF,{disabled:p,tooltip:y}),u.jsx(hF,{description:"This will terminate the Python kernel. You'll lose all data that's in memory.",disabled:p,tooltip:y})]}),e[10]=m,e[11]=y,e[12]=p,e[13]=n,e[14]=w):w=e[14];const S=c==="compact"&&"xl:flex-row items-end";let C,N,j,E,T,I,O,L,D,R,P,z,_;return e[15]!==S?(C=xe(O4,S),e[15]=S,e[16]=C):C=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(N=u.jsx(Ls,{children:u.jsx(y4,{kioskMode:!1})}),e[17]=N):N=e[17],e[18]===Symbol.for("react.memo_cache_sentinel")?(j=Gt("global.hideCode"),e[18]=j):j=e[18],e[19]!==n?(E=n?u.jsx(B3,{strokeWidth:1.5,size:18}):u.jsx(rd,{strokeWidth:1.5,size:18}),e[19]=n,e[20]=E):E=e[20],e[21]!==o||e[22]!==E?(T=u.jsx(Ne,{content:j,children:u.jsx(cn,{"data-testid":"hide-code-button",id:"preview-button",shape:"rectangle",color:"hint-green",onClick:o,children:E})}),e[21]=o,e[22]=E,e[23]=T):T=e[23],e[24]===Symbol.for("react.memo_cache_sentinel")?(I=u.jsx(E4,{}),O=u.jsx(fF,{}),L=u.jsx("div",{}),e[24]=I,e[25]=O,e[26]=L):(I=e[24],O=e[25],L=e[26]),e[27]!==m||e[28]!==r||e[29]!==a?(D=!m&&u.jsx(T4,{running:a,onInterrupt:r}),e[27]=m,e[28]=r,e[29]=a,e[30]=D):D=e[30],e[31]!==m||e[32]!==h||e[33]!==s?(R=!m&&u.jsx(A4,{needsRun:h,onRun:s}),e[31]=m,e[32]=h,e[33]=s,e[34]=R):R=e[34],e[35]!==D||e[36]!==R||e[37]!==x?(P=u.jsx(Ls,{children:u.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[x,D,R]})}),e[35]=D,e[36]=R,e[37]=x,e[38]=P):P=e[38],e[39]!==T||e[40]!==P||e[41]!==C?(z=u.jsxs("div",{className:C,children:[N,T,I,O,L,P]}),e[39]=T,e[40]=P,e[41]=C,e[42]=z):z=e[42],e[43]!==z||e[44]!==v||e[45]!==w?(_=u.jsxs(u.Fragment,{children:[v,w,z]}),e[43]=z,e[44]=v,e[45]=w,e[46]=_):_=e[46],_},A4=t=>{const e=H.c(8),{needsRun:n,onRun:o}=t,r=je(X3);if(n){let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=Gt("global.runStale"),e[0]=l):l=e[0];const c=r?o:void 0,d=!r;let h,f;return e[1]===Symbol.for("react.memo_cache_sentinel")?(h=u.jsx(Sr,{strokeWidth:1.5,size:16}),e[1]=h):h=e[1],e[2]!==c||e[3]!==d?(f=u.jsx(Ne,{content:l,children:u.jsx(cn,{"data-testid":"run-button",size:"medium",color:"yellow",shape:"circle",onClick:c,disabled:d,children:h})}),e[2]=c,e[3]=d,e[4]=f):f=e[4],f}const s=!r;let i,a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(i=u.jsx(Sr,{strokeWidth:1.5,size:16}),e[5]=i):i=e[5],e[6]!==s?(a=u.jsx(Ne,{content:"Nothing to run",children:u.jsx(cn,{"data-testid":"run-button",className:"inactive-button",color:"disabled",size:"medium",shape:"circle",disabled:s,children:i})}),e[6]=s,e[7]=a):a=e[7],a},T4=t=>{const e=H.c(8),{running:n,onInterrupt:o}=t,r=qg(n);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=Gt("global.interrupt"),e[0]=s):s=e[0];const i=!r&&"inactive-button active:shadow-xs-solid";let a;e[1]!==i?(a=xe(i),e[1]=i,e[2]=a):a=e[2];const l=r?"yellow":"disabled",c=r?o:Bn.NOOP;let d,h;return e[3]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx(gc,{strokeWidth:1.5,size:16}),e[3]=d):d=e[3],e[4]!==a||e[5]!==l||e[6]!==c?(h=u.jsx(Ne,{content:s,children:u.jsx(cn,{className:a,"data-testid":"interrupt-button",size:"medium",color:l,shape:"circle",onClick:c,children:d})}),e[4]=a,e[5]=l,e[6]=c,e[7]=h):h=e[7],h},M4="absolute top-3 right-5 m-0 flex items-center gap-2 min-h-[28px] no-print pointer-events-auto z-30 print:hidden",O4="absolute bottom-5 right-5 flex flex-col gap-2 items-center no-print pointer-events-auto z-30 print:hidden",D4=t=>{const e=H.c(7),{filename:n}=t,o=W3();let r;e[0]!==n?(r=n?yn.basename(n):"untitled marimo notebook",e[0]=n,e[1]=r):r=e[1];const s=n===null?"missing-filename":"filename";let i;return e[2]!==n||e[3]!==o||e[4]!==r||e[5]!==s?(i=u.jsx(Vg,{placeholderText:r,initialValue:n,onNameChange:o,flexibleWidth:!0,resetOnBlur:!0,"data-testid":"filename-input",className:s}),e[2]=n,e[3]=o,e[4]=r,e[5]=s,e[6]=i):i=e[6],i},Sd=()=>({entries:new Map}),{valueAtom:Gg,useActions:Yg}=J3(Sd,{submit:(t,e)=>{const{cellIds:n,deleteCell:o,deleteManyCells:r,store:s}=e,i=s.get(In),a=s.get(Sc),l=new Set(i.cellIds.inOrderIds.filter(h=>i.cellData[h].code.trim()==="")),c=new Map;for(const h of n){if(l.has(h)){c.set(h,{cellId:h,type:"simple"});continue}const f=i.cellRuntime[h],m=new Map;for(const x of Object.values(a)){const p=x.declaredBy.includes(h),b=x.usedBy.some(y=>!l.has(y));p&&b&&m.set(x.name,x.usedBy)}let g;f!=null&&f.runElapsedTimeMs&&f.runElapsedTimeMs>2e3&&(g=f.runElapsedTimeMs),m.size===0&&g===void 0?c.set(h,{cellId:h,type:"simple"}):c.set(h,{cellId:h,type:"expensive",executionDurationMs:g,defs:m})}const d=[...c.values()].every(h=>h.type==="simple");return c.size>0&&d?(c.size===1?o({cellId:[...c.values()][0].cellId}):r({cellIds:[...c.values()].map(h=>h.cellId)}),Sd()):{...t,entries:c}},clear:()=>Sd()});function Fs(){const t=Am(),{submit:e,clear:n}=Yg(),{entries:o}=je(Gg),r=Ds(),s=Rs();return M.useMemo(()=>({submit:i=>{e({cellIds:i,deleteCell:r,deleteManyCells:s,store:t})},clear:n,get idle(){return o.size===0},get shouldConfirmDelete(){return o.size>1}}),[t,e,n,o,r,s])}function R4(t){return t.cellId}function Kg(){return{selectionStart:null,selectionEnd:null,selected:new Set}}const{valueAtom:Nd,useActions:P4}=J3(Kg,{select:(t,e)=>({selectionStart:e.cellId,selectionEnd:e.cellId,selected:new Set([e.cellId])}),extend:(t,e)=>{if(!t.selectionStart)return{selectionStart:e.cellId,selectionEnd:e.cellId,selected:new Set([e.cellId])};const{cellId:n,allCellIds:o}=e;try{const r=o.findWithId(t.selectionStart),s=r.indexOfOrThrow(t.selectionStart),i=r.indexOfOrThrow(n),[a,l]=s<i?[s,i]:[i,s],c=r.slice(a,l+1);return{selectionStart:t.selectionStart,selectionEnd:n,selected:new Set(c)}}catch{return{selectionStart:n,selectionEnd:n,selected:new Set([n])}}},clear:t=>t.selected.size===0?t:Kg()});function Ta(){return P4()}const L4=t=>{const e=H.c(14),{actions:n,cellIds:o,disabled:r}=t;let s,i,a,l,c;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(s=u.jsx(Gc,{size:13,strokeWidth:1.5}),e[0]=s):s=e[0],e[1]!==r?(i=u.jsx(_o,{asChild:!0,children:u.jsx(ve,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",title:"More actions",disabled:r,children:s})}),e[1]=r,e[2]=i):i=e[2],e[3]!==n||e[4]!==o){let d;e[6]!==n.length||e[7]!==o?(d=(h,f)=>{const m=h.map(g=>u.jsx(At,{onSelect:()=>g.handle(o),className:"flex items-center gap-2",children:u.jsxs("div",{className:"flex items-center flex-1",children:[g.icon&&u.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:g.icon}),u.jsx("div",{className:"flex-1",children:g.label}),g.hotkey&&u.jsx(Nm,{shortcut:g.hotkey,className:"ml-4"})]})},g.label));return u.jsxs(q.Fragment,{children:[m,f<n.length-1&&u.jsx(an,{})]},f)},e[6]=n.length,e[7]=o,e[8]=d):d=e[8],a=n.flatMap(d),e[3]=n,e[4]=o,e[5]=a}else a=e[5];return e[9]!==a?(l=u.jsx(Io,{align:"start","data-keep-cell-selection":!0,children:a}),e[9]=a,e[10]=l):l=e[10],e[11]!==i||e[12]!==l?(c=u.jsxs(Eo,{children:[i,l]}),e[11]=i,e[12]=l,e[13]=c):c=e[13],c};function F4(t){return t.length>0}function z4(t){return t.filter(B4)}function B4(t){return!t.hidden}function U4(t){return t.length>0}function $4(t){return t.filter(V4)}function V4(t){return!t.hidden}function H4(t){const e={};t.forEach(n=>{const o=Li(n);o&&(e[n]=o)}),v3(e)}const W4=()=>{const t=H.c(4),e=je(Nd);let n;t[0]!==e.selected?(n=[...e.selected],t[0]=e.selected,t[1]=n):n=t[1];const o=n;if(o.length<2)return null;let r;return t[2]!==o?(r=u.jsxs(u.Fragment,{children:[u.jsx(G4,{cellIds:o}),u.jsx(q4,{cellIds:o})]}),t[2]=o,t[3]=r):r=t[3],r},Ed=()=>{const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=u.jsx("div",{className:"h-4 w-px bg-border mx-1"}),t[0]=e):e=t[0],e},q4=t=>{const e=H.c(12),{cellIds:n}=t,o=Fs(),r=Rs(),s=Ta();if(!o.shouldConfirmDelete)return null;let i,a,l,c,d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=u.jsx(Mm,{className:"w-4 h-4 text-(--amber-11) mt-0.5 shrink-0"}),e[0]=i):i=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(a=u.jsxs("div",{className:"font-code text-sm text-[0.84375rem]",children:[u.jsx("p",{className:"text-(--amber-11) font-medium",children:"Some cells in selection may contain expensive operations."}),u.jsx("p",{className:"text-(--amber-11) mt-1",children:"Are you sure you want to delete?"})]}),e[1]=a):a=e[1],e[2]!==o?(l=u.jsx(ve,{size:"xs",variant:"ghost",onClick:()=>o.clear(),className:"text-(--amber-11) hover:bg-(--amber-4) hover:text-(--amber-11)",children:"Cancel"}),e[2]=o,e[3]=l):l=e[3],e[4]!==n||e[5]!==r||e[6]!==o||e[7]!==s?(c=u.jsx(ve,{size:"xs",variant:"secondary",onClick:()=>{r({cellIds:n}),o.clear(),s.clear()},className:"bg-(--amber-11) hover:bg-(--amber-12) text-white border-(--amber-11)",children:"Delete"}),e[4]=n,e[5]=r,e[6]=o,e[7]=s,e[8]=c):c=e[8],e[9]!==l||e[10]!==c?(d=u.jsx("div",{className:"absolute top-12 justify-center flex w-full left-0 right-0 z-50","data-keep-cell-selection":!0,children:u.jsx("div",{className:"mx-20",children:u.jsx("div",{className:"bg-(--amber-2) border border-(--amber-6) rounded-lg shadow-lg mt-14 px-4 py-3 animate-in slide-in-from-top-2 duration-200",children:u.jsxs("div",{className:"flex items-start gap-3",children:[i,u.jsxs("div",{className:"flex-1",children:[a,u.jsx(_m,{restoreFocus:!0,autoFocus:!0,children:u.jsxs("div",{className:"flex items-center gap-2 mt-3",onKeyDown:Y4,children:[l,c]})})]})]})})})}),e[9]=l,e[10]=c,e[11]=d):d=e[11],d},G4=t=>{const e=H.c(23),{cellIds:n}=t,o=Ta(),r=Fs(),{actions:s,moreActions:i}=function(p){const b=H.c(31),{updateCellConfig:y,moveCell:v,clearCellOutput:w,sendToTop:S,sendToBottom:C}=lt(),N=Rs(),j=je(sc),E=Ta(),T=Ts(),I=Fs(),O=je(Ki),{saveCellConfig:L}=tt(),D=p.length,R=!j||D<p.length;let P;b[0]!==N||b[1]!==I||b[2]!==E||b[3]!==O?(P=re=>{I.idle&&O.keymap.destructive_delete?I.submit(re):(N({cellIds:re}),I.clear(),E.clear())},b[0]=N,b[1]=I,b[2]=E,b[3]=O,b[4]=P):P=b[4];const z=Le(P);let _;b[5]!==v?(_=(re,ne)=>{if(ne==="down"){const ie=re[re.length-1];if(Qe.get(In).cellIds.findWithId(ie).last()===ie)return}if(ne==="up"){const ie=re[0];if(Qe.get(In).cellIds.findWithId(ie).first()===ie)return}(ne==="up"?re:[...re].reverse()).forEach(ie=>{v({cellId:ie,before:ne==="up"})})},b[5]=v,b[6]=_):_=b[6];const k=Le(_);let B;b[7]!==S?(B=re=>{[...re].reverse().forEach(ne=>{S({cellId:ne})})},b[7]=S,b[8]=B):B=b[8];const A=Le(B);let U;b[9]!==C?(U=re=>{re.forEach(ne=>{C({cellId:ne})})},b[9]=C,b[10]=U):U=b[10];const $=Le(U),X=Le(H4);let Y;b[11]!==w?(Y=re=>{re.forEach(ne=>{w({cellId:ne})})},b[11]=w,b[12]=Y):Y=b[12];const G=Le(Y);let W;b[13]!==L||b[14]!==y?(W=async(re,ne,ie)=>{const se={};re.forEach(ae=>{se[ae]={[ne]:ie}}),await L({configs:se}),re.forEach(ae=>{y({cellId:ae,config:se[ae]})})},b[13]=L,b[14]=y,b[15]=W):W=b[15];const J=Le(W);let V,Q,te;if(b[16]===Symbol.for("react.memo_cache_sentinel")?(V=u.jsx(Sr,{size:13,strokeWidth:1.5}),b[16]=V):V=b[16],b[17]!==T?(Q=re=>T(re),b[17]=T,b[18]=Q):Q=b[18],b[19]!==R||b[20]!==G||b[21]!==z||b[22]!==X||b[23]!==k||b[24]!==$||b[25]!==A||b[26]!==Q||b[27]!==J){const re=[[{icon:V,label:"Run cells",handle:Q,hotkey:"cell.run"}],[{icon:u.jsx(dc,{size:13,strokeWidth:1.5}),label:"Move up",handle:ae=>k(ae,"up"),hotkey:"cell.moveUp"},{icon:u.jsx(No,{size:13,strokeWidth:1.5}),label:"Move down",handle:ae=>k(ae,"down"),hotkey:"cell.moveDown"}],[{icon:u.jsx(uc,{size:13,strokeWidth:1.5}),label:"Delete cells",variant:"danger",hidden:!R,handle:z}]],ne=[[{icon:u.jsx(w3,{size:13,strokeWidth:1.5}),label:"Format cells",handle:X,hotkey:"cell.format"},{icon:u.jsx(Pi,{size:13,strokeWidth:1.5}),label:"Clear outputs",handle:G}],[{icon:u.jsx(hm,{size:13,strokeWidth:1.5}),label:"Hide code",handle:ae=>J(ae,"hide_code",!0),hotkey:"cell.hideCode"},{icon:u.jsx(um,{size:13,strokeWidth:1.5}),label:"Show code",handle:ae=>J(ae,"hide_code",!1),hotkey:"cell.hideCode"}],[{icon:u.jsx(dc,{size:13,strokeWidth:1.5}),label:"Move up",handle:ae=>k(ae,"up"),hotkey:"cell.moveUp"},{icon:u.jsx(No,{size:13,strokeWidth:1.5}),label:"Move down",handle:ae=>k(ae,"down"),hotkey:"cell.moveDown"},{icon:u.jsx(Zc,{size:13,strokeWidth:1.5}),label:"Send to top",handle:A,hotkey:"cell.sendToTop"},{icon:u.jsx(Jc,{size:13,strokeWidth:1.5}),label:"Send to bottom",handle:$,hotkey:"cell.sendToBottom"}],[{icon:u.jsx(un,{size:13,strokeWidth:1.5}),label:"Disable cells",handle:ae=>J(ae,"disabled",!0)},{icon:u.jsx(hn,{size:13,strokeWidth:1.5}),label:"Enable cells",handle:ae=>J(ae,"disabled",!1)}]],ie=re.map($4);let se;b[29]!==ie?(se=ie.filter(U4),b[29]=ie,b[30]=se):se=b[30],te={actions:se,moreActions:ne.map(z4).filter(F4)},b[19]=R,b[20]=G,b[21]=z,b[22]=X,b[23]=k,b[24]=$,b[25]=A,b[26]=Q,b[27]=J,b[28]=te}else te=b[28];return te}(n),a=n.length;let l;e[0]!==r||e[1]!==o?(l=p=>{(p.target instanceof HTMLElement||p.target instanceof SVGElement)&&p.target.closest("[data-keep-cell-selection]")!==null||p.target instanceof HTMLHtmlElement||(r.clear(),o.clear())},e[0]=r,e[1]=o,e[2]=l):l=e[2],rc(window,"mousedown",l);const c=!r.idle;let d,h,f,m,g,x;if(e[3]!==a?(d=u.jsxs("span",{className:"text-sm font-medium text-muted-foreground px-2 shrink-0",children:[a," cells selected"]}),e[3]=a,e[4]=d):d=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(h=u.jsx(Ed,{}),e[5]=h):h=e[5],e[6]!==s||e[7]!==n||e[8]!==c){let p;e[10]!==s.length||e[11]!==n||e[12]!==c?(p=(b,y)=>u.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[b.map(v=>u.jsxs(ve,{variant:v.variant==="danger"?"linkDestructive":"ghost",size:"sm",onClick:()=>v.handle(n),className:"h-8 px-2 gap-1 shrink-0 flex items-center",title:v.label,disabled:c&&v.label!=="Delete cells",children:[v.icon,u.jsx("span",{className:"text-xs",children:v.label}),v.hotkey&&u.jsx("div",{className:"ml-1 border bg-muted rounded-md px-1",children:u.jsx(Nm,{shortcut:v.hotkey})})]},v.label)),y<s.length-1&&u.jsx(Ed,{})]},y),e[10]=s.length,e[11]=n,e[12]=c,e[13]=p):p=e[13],f=s.map(p),e[6]=s,e[7]=n,e[8]=c,e[9]=f}else f=e[9];return e[14]===Symbol.for("react.memo_cache_sentinel")?(m=u.jsx(Ed,{}),e[14]=m):m=e[14],e[15]!==n||e[16]!==c||e[17]!==i?(g=u.jsx(L4,{actions:i,cellIds:n,disabled:c}),e[15]=n,e[16]=c,e[17]=i,e[18]=g):g=e[18],e[19]!==d||e[20]!==f||e[21]!==g?(x=u.jsx("div",{className:"absolute top-12 justify-center flex w-full left-0 right-0 z-50","data-keep-cell-selection":!0,children:u.jsx("div",{className:"bg-background/95 backdrop-blur-sm supports-backdrop-filter:bg-background/60 border border-(--slate-7) rounded-lg shadow-lg p-2 overflow-x-auto overflow-y-hidden mx-20 scrollbar-thin",children:u.jsxs("div",{className:"flex items-center gap-1",children:[d,h,f,m,g]})})}),e[19]=d,e[20]=f,e[21]=g,e[22]=x):x=e[22],x};function Y4(t){t.stopPropagation()}const K4={display:"none"};function X4(t){let{id:e,value:n}=t;return q.createElement("div",{id:e,style:K4},n)}function J4(t){let{id:e,announcement:n,ariaLiveType:o="assertive"}=t;return q.createElement("div",{id:e,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":o,"aria-atomic":!0},n)}const Xg=M.createContext(null),Z4={draggable:`
99
+ To pick up a draggable item, press the space bar.
100
+ While dragging, use the arrow keys to move the item.
101
+ Press space again to drop the item in its new position, or press escape to cancel.
102
+ `},Q4={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function eN(t){let{announcements:e=Q4,container:n,hiddenTextDescribedById:o,screenReaderInstructions:r=Z4}=t;const{announce:s,announcement:i}=function(){const[h,f]=M.useState("");return{announce:M.useCallback(m=>{m!=null&&f(m)},[]),announcement:h}}(),a=Xi("DndLiveRegion"),[l,c]=M.useState(!1);if(M.useEffect(()=>{c(!0)},[]),function(h){const f=M.useContext(Xg);M.useEffect(()=>{if(!f)throw new Error("useDndMonitor must be used within a children of <DndContext>");return f(h)},[h,f])}(M.useMemo(()=>({onDragStart(h){let{active:f}=h;s(e.onDragStart({active:f}))},onDragMove(h){let{active:f,over:m}=h;e.onDragMove&&s(e.onDragMove({active:f,over:m}))},onDragOver(h){let{active:f,over:m}=h;s(e.onDragOver({active:f,over:m}))},onDragEnd(h){let{active:f,over:m}=h;s(e.onDragEnd({active:f,over:m}))},onDragCancel(h){let{active:f,over:m}=h;s(e.onDragCancel({active:f,over:m}))}}),[s,e])),!l)return null;const d=q.createElement(q.Fragment,null,q.createElement(X4,{id:o,value:r.draggable}),q.createElement(J4,{id:a,announcement:i}));return n?Qi.createPortal(d,n):d}var Ot;function Ma(){}function Jg(t,e){return M.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Ot||(Ot={}));const Dn=Object.freeze({x:0,y:0});function _d(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Id(t,e){let{data:{value:n}}=t,{data:{value:o}}=e;return n-o}function tN(t,e){let{data:{value:n}}=t,{data:{value:o}}=e;return o-n}function Ad(t){let{left:e,top:n,height:o,width:r}=t;return[{x:e,y:n},{x:e+r,y:n},{x:e,y:n+o},{x:e+r,y:n+o}]}function Td(t,e){if(!t||t.length===0)return null;const[n]=t;return e?n[e]:n}function Zg(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+.5*t.width,y:n+.5*t.height}}const Md=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:o}=t;const r=Zg(e,e.left,e.top),s=[];for(const i of o){const{id:a}=i,l=n.get(a);if(l){const c=_d(Zg(l),r);s.push({id:a,data:{droppableContainer:i,value:c}})}}return s.sort(Id)};function nN(t,e){const n=Math.max(e.top,t.top),o=Math.max(e.left,t.left),r=Math.min(e.left+e.width,t.left+t.width),s=Math.min(e.top+e.height,t.top+t.height),i=r-o,a=s-n;if(o<r&&n<s){const l=e.width*e.height,c=t.width*t.height,d=i*a;return Number((d/(l+c-d)).toFixed(4))}return 0}const Qg=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:o}=t;const r=[];for(const s of o){const{id:i}=s,a=n.get(i);if(a){const l=nN(a,e);l>0&&r.push({id:i,data:{droppableContainer:s,value:l}})}}return r.sort(tN)};function oN(t,e){const{top:n,left:o,bottom:r,right:s}=e;return n<=t.y&&t.y<=r&&o<=t.x&&t.x<=s}function e1(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Dn}function rN(t){return function(e){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return o.reduce((s,i)=>({...s,top:s.top+t*i.y,bottom:s.bottom+t*i.y,left:s.left+t*i.x,right:s.right+t*i.x}),{...e})}}const sN=rN(1),iN={ignoreTransform:!1};function _r(t,e){e===void 0&&(e=iN);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:d}=Ao(t).getComputedStyle(t);c&&(n=function(h,f,m){const g=function(N){if(N.startsWith("matrix3d(")){const j=N.slice(9,-1).split(/, /);return{x:+j[12],y:+j[13],scaleX:+j[0],scaleY:+j[5]}}if(N.startsWith("matrix(")){const j=N.slice(7,-1).split(/, /);return{x:+j[4],y:+j[5],scaleX:+j[0],scaleY:+j[3]}}return null}(f);if(!g)return h;const{scaleX:x,scaleY:p,x:b,y}=g,v=h.left-b-(1-x)*parseFloat(m),w=h.top-y-(1-p)*parseFloat(m.slice(m.indexOf(" ")+1)),S=x?h.width/x:h.width,C=p?h.height/p:h.height;return{width:S,height:C,top:w,right:v+S,bottom:w+C,left:v}}(n,c,d))}const{top:o,left:r,width:s,height:i,bottom:a,right:l}=n;return{top:o,left:r,width:s,height:i,bottom:a,right:l}}function t1(t){return _r(t,{ignoreTransform:!0})}function Oa(t,e){const n=[];return t?function o(r){if(e!=null&&n.length>=e||!r)return n;if(Q3(r)&&r.scrollingElement!=null&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!Ec(r)||_D(r)||n.includes(r))return n;const s=Ao(t).getComputedStyle(r);return r!==t&&function(i,a){a===void 0&&(a=Ao(i).getComputedStyle(i));const l=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(c=>{const d=a[c];return typeof d=="string"&&l.test(d)})}(r,s)&&n.push(r),function(i,a){return a===void 0&&(a=Ao(i).getComputedStyle(i)),a.position==="fixed"}(r,s)?n:o(r.parentNode)}(t):n}function n1(t){const[e]=Oa(t,1);return e??null}function Od(t){return Rm&&t?Pm(t)?t:TD(t)?Q3(t)||t===bs(t).scrollingElement?window:Ec(t)?t:null:null:null}function o1(t){return Pm(t)?t.scrollX:t.scrollLeft}function r1(t){return Pm(t)?t.scrollY:t.scrollTop}function Dd(t){return{x:o1(t),y:r1(t)}}var Pt;function s1(t){return!(!Rm||!t)&&t===document.scrollingElement}function i1(t){const e={x:0,y:0},n=s1(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},o={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height};return{isTop:t.scrollTop<=e.y,isLeft:t.scrollLeft<=e.x,isBottom:t.scrollTop>=o.y,isRight:t.scrollLeft>=o.x,maxScroll:o,minScroll:e}}(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Pt||(Pt={}));const aN={x:.2,y:.2};function lN(t,e,n,o,r){let{top:s,left:i,right:a,bottom:l}=n;o===void 0&&(o=10),r===void 0&&(r=aN);const{isTop:c,isBottom:d,isLeft:h,isRight:f}=i1(t),m={x:0,y:0},g={x:0,y:0},x=e.height*r.y,p=e.width*r.x;return!c&&s<=e.top+x?(m.y=Pt.Backward,g.y=o*Math.abs((e.top+x-s)/x)):!d&&l>=e.bottom-x&&(m.y=Pt.Forward,g.y=o*Math.abs((e.bottom-x-l)/x)),!f&&a>=e.right-p?(m.x=Pt.Forward,g.x=o*Math.abs((e.right-p-a)/p)):!h&&i<=e.left+p&&(m.x=Pt.Backward,g.x=o*Math.abs((e.left+p-i)/p)),{direction:m,speed:g}}function cN(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:i}=window;return{top:0,left:0,right:s,bottom:i,width:s,height:i}}const{top:e,left:n,right:o,bottom:r}=t.getBoundingClientRect();return{top:e,left:n,right:o,bottom:r,width:t.clientWidth,height:t.clientHeight}}function a1(t){return t.reduce((e,n)=>ys(e,Dd(n)),Dn)}const dN=[["x",["left","right"],function(t){return t.reduce((e,n)=>e+o1(n),0)}],["y",["top","bottom"],function(t){return t.reduce((e,n)=>e+r1(n),0)}]];class Rd{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=Oa(n),r=a1(o);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,i,a]of dN)for(const l of i)Object.defineProperty(this,l,{get:()=>{const c=a(o),d=r[s]-c;return this.rect[l]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class zs{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...n)})},this.target=e}add(e,n,o){var r;(r=this.target)==null||r.addEventListener(e,n,o),this.listeners.push([e,n,o])}}function Pd(t,e){const n=Math.abs(t.x),o=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+o**2)>e:"x"in e&&"y"in e?n>e.x&&o>e.y:"x"in e?n>e.x:"y"in e&&o>e.y}var Cn,nt;function l1(t){t.preventDefault()}function uN(t){t.stopPropagation()}(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Cn||(Cn={})),function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"}(nt||(nt={}));const c1={start:[nt.Space,nt.Enter],cancel:[nt.Esc],end:[nt.Space,nt.Enter,nt.Tab]},hN=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case nt.Right:return{...n,x:n.x+25};case nt.Left:return{...n,x:n.x-25};case nt.Down:return{...n,y:n.y+25};case nt.Up:return{...n,y:n.y-25}}};class Ld{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:n}}=e;this.props=e,this.listeners=new zs(bs(n)),this.windowListeners=new zs(Ao(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Cn.Resize,this.handleCancel),this.windowListeners.add(Cn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Cn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,o=e.node.current;o&&function(r,s){if(s===void 0&&(s=_r),!r)return;const{top:i,left:a,bottom:l,right:c}=s(r);n1(r)&&(l<=0||c<=0||i>=window.innerHeight||a>=window.innerWidth)&&r.scrollIntoView({block:"center",inline:"center"})}(o),n(Dn)}handleKeyDown(e){if(Om(e)){const{active:n,context:o,options:r}=this.props,{keyboardCodes:s=c1,coordinateGetter:i=hN,scrollBehavior:a="smooth"}=r,{code:l}=e;if(s.end.includes(l))return void this.handleEnd(e);if(s.cancel.includes(l))return void this.handleCancel(e);const{collisionRect:c}=o.current,d=c?{x:c.left,y:c.top}:Dn;this.referenceCoordinates||(this.referenceCoordinates=d);const h=i(e,{active:n,context:o.current,currentCoordinates:d});if(h){const f=Zi(h,d),m={x:0,y:0},{scrollableAncestors:g}=o.current;for(const x of g){const p=e.code,{isTop:b,isRight:y,isLeft:v,isBottom:w,maxScroll:S,minScroll:C}=i1(x),N=cN(x),j={x:Math.min(p===nt.Right?N.right-N.width/2:N.right,Math.max(p===nt.Right?N.left:N.left+N.width/2,h.x)),y:Math.min(p===nt.Down?N.bottom-N.height/2:N.bottom,Math.max(p===nt.Down?N.top:N.top+N.height/2,h.y))},E=p===nt.Right&&!y||p===nt.Left&&!v,T=p===nt.Down&&!w||p===nt.Up&&!b;if(E&&j.x!==h.x){const I=x.scrollLeft+f.x,O=p===nt.Right&&I<=S.x||p===nt.Left&&I>=C.x;if(O&&!f.y)return void x.scrollTo({left:I,behavior:a});m.x=O?x.scrollLeft-I:p===nt.Right?x.scrollLeft-S.x:x.scrollLeft-C.x,m.x&&x.scrollBy({left:-m.x,behavior:a});break}if(T&&j.y!==h.y){const I=x.scrollTop+f.y,O=p===nt.Down&&I<=S.y||p===nt.Up&&I>=C.y;if(O&&!f.x)return void x.scrollTo({top:I,behavior:a});m.y=O?x.scrollTop-I:p===nt.Down?x.scrollTop-S.y:x.scrollTop-C.y,m.y&&x.scrollBy({top:-m.y,behavior:a});break}}this.handleMove(e,ys(Zi(h,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:o}=this.props;e.preventDefault(),o(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function d1(t){return!!(t&&"distance"in t)}function u1(t){return!!(t&&"delay"in t)}Ld.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:o=c1,onActivation:r}=e,{active:s}=n;const{code:i}=t.nativeEvent;if(o.start.includes(i)){const a=s.activatorNode.current;return(!a||t.target===a)&&(t.preventDefault(),r==null||r({event:t.nativeEvent}),!0)}return!1}}];class Fd{constructor(e,n,o){var r;o===void 0&&(o=function(a){const{EventTarget:l}=Ao(a);return a instanceof l?a:bs(a)}(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=n;const{event:s}=e,{target:i}=s;this.props=e,this.events=n,this.document=bs(i),this.documentListeners=new zs(this.document),this.listeners=new zs(o),this.windowListeners=new zs(Ao(i)),this.initialCoordinates=(r=Dm(s))!=null?r:Dn,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:n,bypassActivationConstraint:o}}}=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(Cn.Resize,this.handleCancel),this.windowListeners.add(Cn.DragStart,l1),this.windowListeners.add(Cn.VisibilityChange,this.handleCancel),this.windowListeners.add(Cn.ContextMenu,l1),this.documentListeners.add(Cn.Keydown,this.handleKeydown),n){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(u1(n))return this.timeoutId=setTimeout(this.handleStart,n.delay),void this.handlePending(n);if(d1(n))return void this.handlePending(n)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:o,onPending:r}=this.props;r(o,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(Cn.Click,uN,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Cn.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:o,initialCoordinates:r,props:s}=this,{onMove:i,options:{activationConstraint:a}}=s;if(!r)return;const l=(n=Dm(e))!=null?n:Dn,c=Zi(r,l);if(!o&&a){if(d1(a)){if(a.tolerance!=null&&Pd(c,a.tolerance))return this.handleCancel();if(Pd(c,a.distance))return this.handleStart()}return u1(a)&&Pd(c,a.tolerance)?this.handleCancel():void this.handlePending(a,c)}e.cancelable&&e.preventDefault(),i(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===nt.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const fN={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class zd extends Fd{constructor(e){const{event:n}=e,o=bs(n.target);super(e,fN,o)}}zd.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;return!(!n.isPrimary||n.button!==0)&&(o==null||o({event:n}),!0)}}];const mN={move:{name:"mousemove"},end:{name:"mouseup"}};var Bd;(function(t){t[t.RightClick=2]="RightClick"})(Bd||(Bd={})),(class extends Fd{constructor(t){super(t,mN,bs(t.event.target))}}).activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;return n.button!==Bd.RightClick&&(o==null||o({event:n}),!0)}}];const Ud={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var Bs,Da;function pN(t){let{acceleration:e,activator:n=Bs.Pointer,canScroll:o,draggingRect:r,enabled:s,interval:i=5,order:a=Da.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:d,delta:h,threshold:f}=t;const m=function(C){let{delta:N,disabled:j}=C;const E=_c(N);return ea(T=>{if(j||!E||!T)return gN;const I={x:Math.sign(N.x-E.x),y:Math.sign(N.y-E.y)};return{x:{[Pt.Backward]:T.x[Pt.Backward]||I.x===-1,[Pt.Forward]:T.x[Pt.Forward]||I.x===1},y:{[Pt.Backward]:T.y[Pt.Backward]||I.y===-1,[Pt.Forward]:T.y[Pt.Forward]||I.y===1}}},[j,N,E])}({delta:h,disabled:!s}),[g,x]=ID(),p=M.useRef({x:0,y:0}),b=M.useRef({x:0,y:0}),y=M.useMemo(()=>{switch(n){case Bs.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Bs.DraggableRect:return r}},[n,r,l]),v=M.useRef(null),w=M.useCallback(()=>{const C=v.current;if(!C)return;const N=p.current.x*b.current.x,j=p.current.y*b.current.y;C.scrollBy(N,j)},[]),S=M.useMemo(()=>a===Da.TreeOrder?[...c].reverse():c,[a,c]);M.useEffect(()=>{if(s&&c.length&&y){for(const C of S){if((o==null?void 0:o(C))===!1)continue;const N=c.indexOf(C),j=d[N];if(!j)continue;const{direction:E,speed:T}=lN(C,j,y,e,f);for(const I of["x","y"])m[I][E[I]]||(T[I]=0,E[I]=0);if(T.x>0||T.y>0)return x(),v.current=C,g(w,i),p.current=T,void(b.current=E)}p.current={x:0,y:0},b.current={x:0,y:0},x()}else x()},[e,w,o,x,s,i,JSON.stringify(y),JSON.stringify(m),g,c,S,d,JSON.stringify(f)])}(class extends Fd{constructor(t){super(t,Ud)}static setup(){return window.addEventListener(Ud.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Ud.move.name,t)};function t(){}}}).activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;const{touches:r}=n;return!(r.length>1)&&(o==null||o({event:n}),!0)}}],function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"}(Bs||(Bs={})),function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"}(Da||(Da={}));const gN={x:{[Pt.Backward]:!1,[Pt.Forward]:!1},y:{[Pt.Backward]:!1,[Pt.Forward]:!1}};var Us,$d;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Us||(Us={})),function(t){t.Optimized="optimized"}($d||($d={}));const h1=new Map;function f1(t,e){return ea(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function Ra(t){let{callback:e,disabled:n}=t;const o=Z3(e),r=M.useMemo(()=>{if(n||typeof window>"u"||window.ResizeObserver===void 0)return;const{ResizeObserver:s}=window;return new s(o)},[n]);return M.useEffect(()=>()=>r==null?void 0:r.disconnect(),[r]),r}function xN(t){return new Rd(_r(t),t)}function m1(t,e,n){e===void 0&&(e=xN);const[o,r]=M.useState(null);function s(){r(l=>{if(!t)return null;var c;if(t.isConnected===!1)return(c=l??n)!=null?c:null;const d=e(t);return JSON.stringify(l)===JSON.stringify(d)?l:d})}const i=function(l){let{callback:c,disabled:d}=l;const h=Z3(c),f=M.useMemo(()=>{if(d||typeof window>"u"||window.MutationObserver===void 0)return;const{MutationObserver:m}=window;return new m(h)},[h,d]);return M.useEffect(()=>()=>f==null?void 0:f.disconnect(),[f]),f}({callback(l){if(t)for(const c of l){const{type:d,target:h}=c;if(d==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),a=Ra({callback:s});return Ko(()=>{s(),t?(a==null||a.observe(t),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),i==null||i.disconnect())},[t]),o}const p1=[];function g1(t,e){e===void 0&&(e=[]);const n=M.useRef(null);return M.useEffect(()=>{n.current=null},e),M.useEffect(()=>{const o=t!==Dn;o&&!n.current&&(n.current=t),!o&&n.current&&(n.current=null)},[t]),n.current?Zi(t,n.current):Dn}function x1(t){return M.useMemo(()=>t?function(e){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}}(t):null,[t])}const b1=[];function bN(t){let{measure:e}=t;const[n,o]=M.useState(null),r=M.useCallback(c=>{for(const{target:d}of c)if(Ec(d)){o(h=>{const f=e(d);return h?{...h,width:f.width,height:f.height}:f});break}},[e]),s=Ra({callback:r}),i=M.useCallback(c=>{const d=function(h){if(!h)return null;if(h.children.length>1)return h;const f=h.children[0];return Ec(f)?f:h}(c);s==null||s.disconnect(),d&&(s==null||s.observe(d)),o(d?e(d):null)},[e,s]),[a,l]=Nc(i);return M.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const yN=[{sensor:zd,options:{}},{sensor:Ld,options:{}}],vN={current:{}},Pa={draggable:{measure:t1},droppable:{measure:t1,strategy:Us.WhileDragging,frequency:$d.Optimized},dragOverlay:{measure:_r}};class $s extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,o;return(n=(o=this.get(e))==null?void 0:o.node.current)!=null?n:void 0}}const wN={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new $s,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ma},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Pa,measureDroppableContainers:Ma,windowRect:null,measuringScheduled:!1},kN={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ma,draggableNodes:new Map,over:null,measureDroppableContainers:Ma},La=M.createContext(kN),y1=M.createContext(wN);function CN(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new $s}}}function jN(t,e){switch(e.type){case Ot.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Ot.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case Ot.DragEnd:case Ot.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ot.RegisterDroppable:{const{element:n}=e,{id:o}=n,r=new $s(t.droppable.containers);return r.set(o,n),{...t,droppable:{...t.droppable,containers:r}}}case Ot.SetDroppableDisabled:{const{id:n,key:o,disabled:r}=e,s=t.droppable.containers.get(n);if(!s||o!==s.key)return t;const i=new $s(t.droppable.containers);return i.set(n,{...s,disabled:r}),{...t,droppable:{...t.droppable,containers:i}}}case Ot.UnregisterDroppable:{const{id:n,key:o}=e,r=t.droppable.containers.get(n);if(!r||o!==r.key)return t;const s=new $s(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function SN(t){let{disabled:e}=t;const{active:n,activatorEvent:o,draggableNodes:r}=M.useContext(La),s=_c(o),i=_c(n==null?void 0:n.id);return M.useEffect(()=>{if(!e&&!o&&s&&i!=null){if(!Om(s)||document.activeElement===s.target)return;const a=r.get(i);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const d of[l.current,c.current]){if(!d)continue;const h=AD(d);if(h){h.focus();break}}})}},[o,e,r,i,s]),null}const v1=M.createContext({...Dn,scaleX:1,scaleY:1});var Oo;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Oo||(Oo={}));const NN=M.memo(function(t){var e,n,o,r;let{id:s,accessibility:i,autoScroll:a=!0,children:l,sensors:c=yN,collisionDetection:d=Qg,measuring:h,modifiers:f,...m}=t;const g=M.useReducer(jN,void 0,CN),[x,p]=g,[b,y]=function(){const[le]=M.useState(()=>new Set),Ae=M.useCallback(Me=>(le.add(Me),()=>le.delete(Me)),[le]);return[M.useCallback(Me=>{let{type:Ue,event:qe}=Me;le.forEach(De=>{var $e;return($e=De[Ue])==null?void 0:$e.call(De,qe)})},[le]),Ae]}(),[v,w]=M.useState(Oo.Uninitialized),S=v===Oo.Initialized,{draggable:{active:C,nodes:N,translate:j},droppable:{containers:E}}=x,T=C!=null?N.get(C):null,I=M.useRef({initial:null,translated:null}),O=M.useMemo(()=>{var le;return C!=null?{id:C,data:(le=T==null?void 0:T.data)!=null?le:vN,rect:I}:null},[C,T]),L=M.useRef(null),[D,R]=M.useState(null),[P,z]=M.useState(null),_=Ji(m,Object.values(m)),k=Xi("DndDescribedBy",s),B=M.useMemo(()=>E.getEnabled(),[E]),A=(U=h,M.useMemo(()=>({draggable:{...Pa.draggable,...U==null?void 0:U.draggable},droppable:{...Pa.droppable,...U==null?void 0:U.droppable},dragOverlay:{...Pa.dragOverlay,...U==null?void 0:U.dragOverlay}}),[U==null?void 0:U.draggable,U==null?void 0:U.droppable,U==null?void 0:U.dragOverlay]));var U;const{droppableRects:$,measureDroppableContainers:X,measuringScheduled:Y}=function(le,Ae){let{dragging:Me,dependencies:Ue,config:qe}=Ae;const[De,$e]=M.useState(null),{frequency:st,measure:Xe,strategy:it}=qe,Ut=M.useRef(le),qt=function(){switch(it){case Us.Always:return!1;case Us.BeforeDragging:return Me;default:return!Me}}(),xn=Ji(qt),en=M.useCallback(function(Xn){Xn===void 0&&(Xn=[]),xn.current||$e(So=>So===null?Xn:So.concat(Xn.filter(_n=>!So.includes(_n))))},[xn]),Ln=M.useRef(null),as=ea(Xn=>{if(qt&&!Me)return h1;if(!Xn||Xn===h1||Ut.current!==le||De!=null){const So=new Map;for(let _n of le){if(!_n)continue;if(De&&De.length>0&&!De.includes(_n.id)&&_n.rect.current){So.set(_n.id,_n.rect.current);continue}const ls=_n.node.current,Mi=ls?new Rd(Xe(ls),ls):null;_n.rect.current=Mi,Mi&&So.set(_n.id,Mi)}return So}return Xn},[le,De,Me,qt,Xe]);return M.useEffect(()=>{Ut.current=le},[le]),M.useEffect(()=>{qt||en()},[Me,qt]),M.useEffect(()=>{De&&De.length>0&&$e(null)},[JSON.stringify(De)]),M.useEffect(()=>{qt||typeof st!="number"||Ln.current!==null||(Ln.current=setTimeout(()=>{en(),Ln.current=null},st))},[st,qt,en,...Ue]),{droppableRects:as,measureDroppableContainers:en,measuringScheduled:De!=null}}(B,{dragging:S,dependencies:[j.x,j.y],config:A.droppable}),G=function(le,Ae){const Me=Ae!=null?le.get(Ae):void 0,Ue=Me?Me.node.current:null;return ea(qe=>{var De;return Ae==null?null:(De=Ue??qe)!=null?De:null},[Ue,Ae])}(N,C),W=M.useMemo(()=>P?Dm(P):null,[P]),J=function(){const le=(D==null?void 0:D.autoScrollEnabled)===!1,Ae=typeof a=="object"?a.enabled===!1:a===!1,Me=S&&!le&&!Ae;return typeof a=="object"?{...a,enabled:Me}:{enabled:Me}}(),V=function(le,Ae){return f1(le,Ae)}(G,A.draggable.measure);(function(le){let{activeNode:Ae,measure:Me,initialRect:Ue,config:qe=!0}=le;const De=M.useRef(!1),{x:$e,y:st}=typeof qe=="boolean"?{x:qe,y:qe}:qe;Ko(()=>{if(!$e&&!st||!Ae)return void(De.current=!1);if(De.current||!Ue)return;const Xe=Ae==null?void 0:Ae.node.current;if(!Xe||Xe.isConnected===!1)return;const it=e1(Me(Xe),Ue);if($e||(it.x=0),st||(it.y=0),De.current=!0,Math.abs(it.x)>0||Math.abs(it.y)>0){const Ut=n1(Xe);Ut&&Ut.scrollBy({top:it.y,left:it.x})}},[Ae,$e,st,Ue,Me])})({activeNode:C!=null?N.get(C):null,config:J.layoutShiftCompensation,initialRect:V,measure:A.draggable.measure});const Q=m1(G,A.draggable.measure,V),te=m1(G?G.parentElement:null),re=M.useRef({activatorEvent:null,active:null,activeNode:G,collisionRect:null,collisions:null,droppableRects:$,draggableNodes:N,draggingNode:null,draggingNodeRect:null,droppableContainers:E,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ne=E.getNodeFor((e=re.current.over)==null?void 0:e.id),ie=bN({measure:A.dragOverlay.measure}),se=(n=ie.nodeRef.current)!=null?n:G,ae=S?(o=ie.rect)!=null?o:Q:null,ge=!!(ie.nodeRef.current&&ie.rect),oe=e1(ue=ge?null:Q,f1(ue));var ue;const de=x1(se?Ao(se):null),Se=function(le){const Ae=M.useRef(le),Me=ea(Ue=>le?Ue&&Ue!==p1&&le&&Ae.current&&le.parentNode===Ae.current.parentNode?Ue:Oa(le):p1,[le]);return M.useEffect(()=>{Ae.current=le},[le]),Me}(S?ne??G:null),Te=function(le,Ae){Ae===void 0&&(Ae=_r);const[Me]=le,Ue=x1(Me?Ao(Me):null),[qe,De]=M.useState(b1);function $e(){De(()=>le.length?le.map(Xe=>s1(Xe)?Ue:new Rd(Ae(Xe),Xe)):b1)}const st=Ra({callback:$e});return Ko(()=>{st==null||st.disconnect(),$e(),le.forEach(Xe=>st==null?void 0:st.observe(Xe))},[le]),qe}(Se),Fe=function(le,Ae){let{transform:Me,...Ue}=Ae;return le!=null&&le.length?le.reduce((qe,De)=>De({transform:qe,...Ue}),Me):Me}(f,{transform:{x:j.x-oe.x,y:j.y-oe.y,scaleX:1,scaleY:1},activatorEvent:P,active:O,activeNodeRect:Q,containerNodeRect:te,draggingNodeRect:ae,over:re.current.over,overlayNodeRect:ie.rect,scrollableAncestors:Se,scrollableAncestorRects:Te,windowRect:de}),_e=W?ys(W,j):null,ke=function(le){const[Ae,Me]=M.useState(null),Ue=M.useRef(le),qe=M.useCallback(De=>{const $e=Od(De.target);$e&&Me(st=>st?(st.set($e,Dd($e)),new Map(st)):null)},[]);return M.useEffect(()=>{const De=Ue.current;if(le!==De){$e(De);const st=le.map(Xe=>{const it=Od(Xe);return it?(it.addEventListener("scroll",qe,{passive:!0}),[it,Dd(it)]):null}).filter(Xe=>Xe!=null);Me(st.length?new Map(st):null),Ue.current=le}return()=>{$e(le),$e(De)};function $e(st){st.forEach(Xe=>{const it=Od(Xe);it==null||it.removeEventListener("scroll",qe)})}},[qe,le]),M.useMemo(()=>le.length?Ae?Array.from(Ae.values()).reduce((De,$e)=>ys(De,$e),Dn):a1(le):Dn,[le,Ae])}(Se),Ye=g1(ke),Ve=g1(ke,[Q]),Ke=ys(Fe,Ye),ee=ae?sN(ae,Fe):null,ye=O&&ee?d({active:O,collisionRect:ee,droppableRects:$,droppableContainers:B,pointerCoordinates:_e}):null,we=Td(ye,"id"),[Ie,K]=M.useState(null),me=function(le,Ae,Me){return{...le,scaleX:Ae&&Me?Ae.width/Me.width:1,scaleY:Ae&&Me?Ae.height/Me.height:1}}(ge?Fe:ys(Fe,Ve),(r=Ie==null?void 0:Ie.rect)!=null?r:null,Q),pe=M.useRef(null),he=M.useCallback((le,Ae)=>{let{sensor:Me,options:Ue}=Ae;if(L.current==null)return;const qe=N.get(L.current);if(!qe)return;const De=le.nativeEvent,$e=new Me({active:L.current,activeNode:qe,event:De,options:Ue,context:re,onAbort(Xe){if(!N.get(Xe))return;const{onDragAbort:it}=_.current,Ut={id:Xe};it==null||it(Ut),b({type:"onDragAbort",event:Ut})},onPending(Xe,it,Ut,qt){if(!N.get(Xe))return;const{onDragPending:xn}=_.current,en={id:Xe,constraint:it,initialCoordinates:Ut,offset:qt};xn==null||xn(en),b({type:"onDragPending",event:en})},onStart(Xe){const it=L.current;if(it==null)return;const Ut=N.get(it);if(!Ut)return;const{onDragStart:qt}=_.current,xn={activatorEvent:De,active:{id:it,data:Ut.data,rect:I}};Qi.unstable_batchedUpdates(()=>{qt==null||qt(xn),w(Oo.Initializing),p({type:Ot.DragStart,initialCoordinates:Xe,active:it}),b({type:"onDragStart",event:xn}),R(pe.current),z(De)})},onMove(Xe){p({type:Ot.DragMove,coordinates:Xe})},onEnd:st(Ot.DragEnd),onCancel:st(Ot.DragCancel)});function st(Xe){return async function(){const{active:it,collisions:Ut,over:qt,scrollAdjustedTranslate:xn}=re.current;let en=null;if(it&&xn){const{cancelDrop:Ln}=_.current;en={activatorEvent:De,active:it,collisions:Ut,delta:xn,over:qt},Xe===Ot.DragEnd&&typeof Ln=="function"&&await Promise.resolve(Ln(en))&&(Xe=Ot.DragCancel)}L.current=null,Qi.unstable_batchedUpdates(()=>{p({type:Xe}),w(Oo.Uninitialized),K(null),R(null),z(null),pe.current=null;const Ln=Xe===Ot.DragEnd?"onDragEnd":"onDragCancel";if(en){const as=_.current[Ln];as==null||as(en),b({type:Ln,event:en})}})}}pe.current=$e},[N]),Ce=M.useCallback((le,Ae)=>(Me,Ue)=>{const qe=Me.nativeEvent,De=N.get(Ue);if(L.current!==null||!De||qe.dndKit||qe.defaultPrevented)return;const $e={active:De};le(Me,Ae.options,$e)===!0&&(qe.dndKit={capturedBy:Ae.sensor},L.current=Ue,he(Me,Ae))},[N,he]),Re=function(le,Ae){return M.useMemo(()=>le.reduce((Me,Ue)=>{const{sensor:qe}=Ue;return[...Me,...qe.activators.map(De=>({eventName:De.eventName,handler:Ae(De.handler,Ue)}))]},[]),[le,Ae])}(c,Ce);(function(le){M.useEffect(()=>{if(!Rm)return;const Ae=le.map(Me=>{let{sensor:Ue}=Me;return Ue.setup==null?void 0:Ue.setup()});return()=>{for(const Me of Ae)Me==null||Me()}},le.map(Ae=>{let{sensor:Me}=Ae;return Me}))})(c),Ko(()=>{Q&&v===Oo.Initializing&&w(Oo.Initialized)},[Q,v]),M.useEffect(()=>{const{onDragMove:le}=_.current,{active:Ae,activatorEvent:Me,collisions:Ue,over:qe}=re.current;if(!Ae||!Me)return;const De={active:Ae,activatorEvent:Me,collisions:Ue,delta:{x:Ke.x,y:Ke.y},over:qe};Qi.unstable_batchedUpdates(()=>{le==null||le(De),b({type:"onDragMove",event:De})})},[Ke.x,Ke.y]),M.useEffect(()=>{const{active:le,activatorEvent:Ae,collisions:Me,droppableContainers:Ue,scrollAdjustedTranslate:qe}=re.current;if(!le||L.current==null||!Ae||!qe)return;const{onDragOver:De}=_.current,$e=Ue.get(we),st=$e&&$e.rect.current?{id:$e.id,rect:$e.rect.current,data:$e.data,disabled:$e.disabled}:null,Xe={active:le,activatorEvent:Ae,collisions:Me,delta:{x:qe.x,y:qe.y},over:st};Qi.unstable_batchedUpdates(()=>{K(st),De==null||De(Xe),b({type:"onDragOver",event:Xe})})},[we]),Ko(()=>{re.current={activatorEvent:P,active:O,activeNode:G,collisionRect:ee,collisions:ye,droppableRects:$,draggableNodes:N,draggingNode:se,draggingNodeRect:ae,droppableContainers:E,over:Ie,scrollableAncestors:Se,scrollAdjustedTranslate:Ke},I.current={initial:ae,translated:ee}},[O,G,ye,ee,N,se,ae,$,E,Ie,Se,Ke]),pN({...J,delta:j,draggingRect:ee,pointerCoordinates:_e,scrollableAncestors:Se,scrollableAncestorRects:Te});const Pe=M.useMemo(()=>({active:O,activeNode:G,activeNodeRect:Q,activatorEvent:P,collisions:ye,containerNodeRect:te,dragOverlay:ie,draggableNodes:N,droppableContainers:E,droppableRects:$,over:Ie,measureDroppableContainers:X,scrollableAncestors:Se,scrollableAncestorRects:Te,measuringConfiguration:A,measuringScheduled:Y,windowRect:de}),[O,G,Q,P,ye,te,ie,N,E,$,Ie,X,Se,Te,A,Y,de]),He=M.useMemo(()=>({activatorEvent:P,activators:Re,active:O,activeNodeRect:Q,ariaDescribedById:{draggable:k},dispatch:p,draggableNodes:N,over:Ie,measureDroppableContainers:X}),[P,Re,O,Q,p,k,N,Ie,X]);return q.createElement(Xg.Provider,{value:y},q.createElement(La.Provider,{value:He},q.createElement(y1.Provider,{value:Pe},q.createElement(v1.Provider,{value:me},l)),q.createElement(SN,{disabled:(i==null?void 0:i.restoreFocus)===!1})),q.createElement(eN,{...i,hiddenTextDescribedById:k}))}),EN=M.createContext(null),w1="button";function _N(t){let{id:e,data:n,disabled:o=!1,attributes:r}=t;const s=Xi("Draggable"),{activators:i,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:d,draggableNodes:h,over:f}=M.useContext(La),{role:m=w1,roleDescription:g="draggable",tabIndex:x=0}=r??{},p=(l==null?void 0:l.id)===e,b=M.useContext(p?v1:EN),[y,v]=Nc(),[w,S]=Nc(),C=function(j,E){return M.useMemo(()=>j.reduce((T,I)=>{let{eventName:O,handler:L}=I;return T[O]=D=>{L(D,E)},T},{}),[j,E])}(i,e),N=Ji(n);return Ko(()=>(h.set(e,{id:e,key:s,node:y,activatorNode:w,data:N}),()=>{const j=h.get(e);j&&j.key===s&&h.delete(e)}),[h,e]),{active:l,activatorEvent:a,activeNodeRect:c,attributes:M.useMemo(()=>({role:m,tabIndex:x,"aria-disabled":o,"aria-pressed":!(!p||m!==w1)||void 0,"aria-roledescription":g,"aria-describedby":d.draggable}),[o,m,x,p,g,d.draggable]),isDragging:p,listeners:o?void 0:C,node:y,over:f,setNodeRef:v,setActivatorNodeRef:S,transform:b}}const IN={timeout:25};function k1(t,e,n){const o=t.slice();return o.splice(n<0?o.length+n:n,0,o.splice(e,1)[0]),o}function AN(t,e){return t.reduce((n,o,r)=>{const s=e.get(o);return s&&(n[r]=s),n},Array(t.length))}function Fa(t){return t!==null&&t>=0}const za={scaleX:1,scaleY:1},TN=t=>{var e;let{rects:n,activeNodeRect:o,activeIndex:r,overIndex:s,index:i}=t;const a=(e=n[r])!=null?e:o;if(!a)return null;const l=function(c,d,h){const f=c[d],m=c[d-1],g=c[d+1];return!f||!m&&!g?0:h<d?m?f.left-(m.left+m.width):g.left-(f.left+f.width):g?g.left-(f.left+f.width):f.left-(m.left+m.width)}(n,i,r);if(i===r){const c=n[s];return c?{x:r<s?c.left+c.width-(a.left+a.width):c.left-a.left,y:0,...za}:null}return i>r&&i<=s?{x:-a.width-l,y:0,...za}:i<r&&i>=s?{x:a.width+l,y:0,...za}:{x:0,y:0,...za}},C1=t=>{let{rects:e,activeIndex:n,overIndex:o,index:r}=t;const s=k1(e,o,n),i=e[r],a=s[r];return a&&i?{x:a.left-i.left,y:a.top-i.top,scaleX:a.width/i.width,scaleY:a.height/i.height}:null},Ba={scaleX:1,scaleY:1},MN=t=>{var e;let{activeIndex:n,activeNodeRect:o,index:r,rects:s,overIndex:i}=t;const a=(e=s[n])!=null?e:o;if(!a)return null;if(r===n){const c=s[i];return c?{x:0,y:n<i?c.top+c.height-(a.top+a.height):c.top-a.top,...Ba}:null}const l=function(c,d,h){const f=c[d],m=c[d-1],g=c[d+1];return f?h<d?m?f.top-(m.top+m.height):g?g.top-(f.top+f.height):0:g?g.top-(f.top+f.height):m?f.top-(m.top+m.height):0:0}(s,r,n);return r>n&&r<=i?{x:0,y:-a.height-l,...Ba}:r<n&&r>=i?{x:0,y:a.height+l,...Ba}:{x:0,y:0,...Ba}},j1="Sortable",S1=q.createContext({activeIndex:-1,containerId:j1,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:C1,disabled:{draggable:!1,droppable:!1}});function N1(t){let{children:e,id:n,items:o,strategy:r=C1,disabled:s=!1}=t;const{active:i,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:d}=M.useContext(y1),h=Xi(j1,n),f=a.rect!==null,m=M.useMemo(()=>o.map(C=>typeof C=="object"&&"id"in C?C.id:C),[o]),g=i!=null,x=i?m.indexOf(i.id):-1,p=c?m.indexOf(c.id):-1,b=M.useRef(m),y=!function(C,N){if(C===N)return!0;if(C.length!==N.length)return!1;for(let j=0;j<C.length;j++)if(C[j]!==N[j])return!1;return!0}(m,b.current),v=p!==-1&&x===-1||y,w=function(C){return typeof C=="boolean"?{draggable:C,droppable:C}:C}(s);Ko(()=>{y&&g&&d(m)},[y,m,g,d]),M.useEffect(()=>{b.current=m},[m]);const S=M.useMemo(()=>({activeIndex:x,containerId:h,disabled:w,disableTransforms:v,items:m,overIndex:p,useDragOverlay:f,sortedRects:AN(m,l),strategy:r}),[x,h,w.draggable,w.droppable,v,m,p,l,f,r]);return q.createElement(S1.Provider,{value:S},e)}const ON=t=>{let{id:e,items:n,activeIndex:o,overIndex:r}=t;return k1(n,o,r).indexOf(e)},DN=t=>{let{containerId:e,isSorting:n,wasDragging:o,index:r,items:s,newIndex:i,previousItems:a,previousContainerId:l,transition:c}=t;return!(!c||!o)&&(a===s||r!==i)&&(!!n||i!==r&&e===l)},RN={duration:200,easing:"ease"},E1="transform",PN=Ic.Transition.toString({property:E1,duration:0,easing:"linear"}),LN={roleDescription:"sortable"};function _1(t){let{animateLayoutChanges:e=DN,attributes:n,disabled:o,data:r,getNewIndex:s=ON,id:i,strategy:a,resizeObserverConfig:l,transition:c=RN}=t;const{items:d,containerId:h,activeIndex:f,disabled:m,disableTransforms:g,sortedRects:x,overIndex:p,useDragOverlay:b,strategy:y}=M.useContext(S1),v=function(ne,ie){var se,ae;return typeof ne=="boolean"?{draggable:ne,droppable:!1}:{draggable:(se=ne==null?void 0:ne.draggable)!=null?se:ie.draggable,droppable:(ae=ne==null?void 0:ne.droppable)!=null?ae:ie.droppable}}(o,m),w=d.indexOf(i),S=M.useMemo(()=>({sortable:{containerId:h,index:w,items:d},...r}),[h,r,w,d]),C=M.useMemo(()=>d.slice(d.indexOf(i)),[d,i]),{rect:N,node:j,isOver:E,setNodeRef:T}=function(ne){let{data:ie,disabled:se=!1,id:ae,resizeObserverConfig:ge}=ne;const oe=Xi("Droppable"),{active:ue,dispatch:de,over:Se,measureDroppableContainers:Te}=M.useContext(La),Fe=M.useRef({disabled:se}),_e=M.useRef(!1),ke=M.useRef(null),Ye=M.useRef(null),{disabled:Ve,updateMeasurementsFor:Ke,timeout:ee}={...IN,...ge},ye=Ji(Ke??ae),we=Ra({callback:M.useCallback(()=>{_e.current?(Ye.current!=null&&clearTimeout(Ye.current),Ye.current=setTimeout(()=>{Te(Array.isArray(ye.current)?ye.current:[ye.current]),Ye.current=null},ee)):_e.current=!0},[ee]),disabled:Ve||!ue}),Ie=M.useCallback((he,Ce)=>{we&&(Ce&&(we.unobserve(Ce),_e.current=!1),he&&we.observe(he))},[we]),[K,me]=Nc(Ie),pe=Ji(ie);return M.useEffect(()=>{we&&K.current&&(we.disconnect(),_e.current=!1,we.observe(K.current))},[K,we]),M.useEffect(()=>(de({type:Ot.RegisterDroppable,element:{id:ae,key:oe,disabled:se,node:K,rect:ke,data:pe}}),()=>de({type:Ot.UnregisterDroppable,key:oe,id:ae})),[ae]),M.useEffect(()=>{se!==Fe.current.disabled&&(de({type:Ot.SetDroppableDisabled,id:ae,key:oe,disabled:se}),Fe.current.disabled=se)},[ae,oe,se,de]),{active:ue,rect:ke,isOver:(Se==null?void 0:Se.id)===ae,node:K,over:Se,setNodeRef:me}}({id:i,data:S,disabled:v.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...l}}),{active:I,activatorEvent:O,activeNodeRect:L,attributes:D,setNodeRef:R,listeners:P,isDragging:z,over:_,setActivatorNodeRef:k,transform:B}=_N({id:i,data:S,attributes:{...LN,...n},disabled:v.draggable}),A=MD(T,R),U=!!I,$=U&&!g&&Fa(f)&&Fa(p),X=!b&&z,Y=X&&$?B:null,G=$?Y??(a??y)({rects:x,activeNodeRect:L,activeIndex:f,overIndex:p,index:w}):null,W=Fa(f)&&Fa(p)?s({id:i,items:d,activeIndex:f,overIndex:p}):w,J=I==null?void 0:I.id,V=M.useRef({activeId:J,items:d,newIndex:W,containerId:h}),Q=d!==V.current.items,te=e({active:I,containerId:h,isDragging:z,isSorting:U,id:i,index:w,items:d,newIndex:V.current.newIndex,previousItems:V.current.items,previousContainerId:V.current.containerId,transition:c,wasDragging:V.current.activeId!=null}),re=function(ne){let{disabled:ie,index:se,node:ae,rect:ge}=ne;const[oe,ue]=M.useState(null),de=M.useRef(se);return Ko(()=>{if(!ie&&se!==de.current&&ae.current){const Se=ge.current;if(Se){const Te=_r(ae.current,{ignoreTransform:!0}),Fe={x:Se.left-Te.left,y:Se.top-Te.top,scaleX:Se.width/Te.width,scaleY:Se.height/Te.height};(Fe.x||Fe.y)&&ue(Fe)}}se!==de.current&&(de.current=se)},[ie,se,ae,ge]),M.useEffect(()=>{oe&&ue(null)},[oe]),oe}({disabled:!te,index:w,node:j,rect:N});return M.useEffect(()=>{U&&V.current.newIndex!==W&&(V.current.newIndex=W),h!==V.current.containerId&&(V.current.containerId=h),d!==V.current.items&&(V.current.items=d)},[U,W,h,d]),M.useEffect(()=>{if(J===V.current.activeId)return;if(J!=null&&V.current.activeId==null)return void(V.current.activeId=J);const ne=setTimeout(()=>{V.current.activeId=J},50);return()=>clearTimeout(ne)},[J]),{active:I,activeIndex:f,attributes:D,data:S,rect:N,index:w,newIndex:W,items:d,isOver:E,isSorting:U,isDragging:z,listeners:P,node:j,overIndex:p,over:_,setNodeRef:A,setActivatorNodeRef:k,setDroppableNodeRef:T,setDraggableNodeRef:R,transform:re??G,transition:function(){if(re||Q&&V.current.newIndex===w)return PN;if(!(X&&!Om(O)||!c)&&(U||te))return Ic.Transition.toString({...c,property:E1})}()}}function Ua(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const FN=[nt.Down,nt.Right,nt.Up,nt.Left],zN=(t,e)=>{let{context:{active:n,collisionRect:o,droppableRects:r,droppableContainers:s,over:i,scrollableAncestors:a}}=e;if(FN.includes(t.code)){if(t.preventDefault(),!n||!o)return;const l=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const f=r.get(h.id);if(f)switch(t.code){case nt.Down:o.top<f.top&&l.push(h);break;case nt.Up:o.top>f.top&&l.push(h);break;case nt.Left:o.left>f.left&&l.push(h);break;case nt.Right:o.left<f.left&&l.push(h)}});const c=(h=>{let{collisionRect:f,droppableRects:m,droppableContainers:g}=h;const x=Ad(f),p=[];for(const b of g){const{id:y}=b,v=m.get(y);if(v){const w=Ad(v),S=x.reduce((N,j,E)=>N+_d(w[E],j),0),C=Number((S/4).toFixed(4));p.push({id:y,data:{droppableContainer:b,value:C}})}}return p.sort(Id)})({collisionRect:o,droppableRects:r,droppableContainers:l});let d=Td(c,"id");if(d===(i==null?void 0:i.id)&&c.length>1&&(d=c[1].id),d!=null){const h=s.get(n.id),f=s.get(d),m=f?r.get(f.id):null,g=f==null?void 0:f.node.current;if(g&&m&&h&&f){const x=Oa(g).some((w,S)=>a[S]!==w),p=I1(h,f),b=function(w,S){return!Ua(w)||!Ua(S)||!I1(w,S)?!1:w.data.current.sortable.index<S.data.current.sortable.index}(h,f),y=x||!p?{x:0,y:0}:{x:b?o.width-m.width:0,y:b?o.height-m.height:0},v={x:m.left,y:m.top};return y.x&&y.y?v:Zi(v,y)}}}};function I1(t,e){return!(!Ua(t)||!Ua(e))&&t.data.current.sortable.containerId===e.data.current.sortable.containerId}const BN=OD("rounded-full shadow-xs-solid border p-[5px] transition-colors focus:outline-hidden 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-(--yellow-3) hover:bg-(--yellow-4) text-(--yellow-11)",green:"hover:bg-(--grass-2) hover:text-(--grass-11) hover:border-[var(--grass-7)],",disabled:"opacity-50 cursor-not-allowed",danger:"hover:bg-(--red-3) hover:text-(--red-11)"}},defaultVariants:{variant:"default"}}),Vs=t=>{const e=H.c(21);let n,o,r,s,i;e[0]!==t?({children:n,tooltip:s,disabled:r,variant:i,...o}=t,e[0]=t,e[1]=n,e[2]=o,e[3]=r,e[4]=s,e[5]=i):(n=e[1],o=e[2],r=e[3],s=e[4],i=e[5]);const a=r!==void 0&&r;let l,c,d;e[6]!==a||e[7]!==o?(l=f=>{var m;a||((m=o.onClick)==null||m.call(o,f))},e[6]=a,e[7]=o,e[8]=l):l=e[8],e[9]!==o.className||e[10]!==i?(c=xe(BN({variant:i}),o.className),e[9]=o.className,e[10]=i,e[11]=c):c=e[11],e[12]!==n||e[13]!==a||e[14]!==o||e[15]!==l||e[16]!==c?(d=u.jsx("button",{disabled:a,...o,onClick:l,onMouseDown:zn.preventFocus,className:c,children:n}),e[12]=n,e[13]=a,e[14]=o,e[15]=l,e[16]=c,e[17]=d):d=e[17];const h=d;if(s){let f;return e[18]!==h||e[19]!==s?(f=u.jsx(Ne,{content:s,side:"top",delayDuration:200,usePortal:!1,children:h}),e[18]=h,e[19]=s,e[20]=f):f=e[20],f}return h},UN=t=>{const e=H.c(5),{children:n,className:o}=t;let r,s;return e[0]!==o?(r=xe("flex items-center gap-1 bg-background m-[2px] rounded-full",o),e[0]=o,e[1]=r):r=e[1],e[2]!==n||e[3]!==r?(s=u.jsx(Lj,{className:r,children:n}),e[2]=n,e[3]=r,e[4]=s):s=e[4],s},$N=t=>{const e=H.c(9),{connectionState:n,status:o}=t,{sendInterrupt:r}=tt(),s=qg(o==="running");let i,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Gt("global.interrupt"),e[0]=i):i=e[0],e[1]!==n||e[2]!==s?(a=eo(n)||!s,e[1]=n,e[2]=s,e[3]=a):a=e[3];const l=s?r:Bn.NOOP,c=s?"stale":"disabled";let d,h;return e[4]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx(gc,{strokeWidth:1.5}),e[4]=d):d=e[4],e[5]!==a||e[6]!==l||e[7]!==c?(h=u.jsx(Vs,{tooltip:i,disabled:a,onClick:l,variant:c,"data-testid":"run-button",children:d}),e[5]=a,e[6]=l,e[7]=c,e[8]=h):h=e[8],h},Ir={showInput:"Mod-l",acceptEdit:"Mod-y",rejectEdit:"Mod-u"},Hs=vr.define({combine:t=>Ac(t,{onError:console.error,inputDebounceTime:300,keymaps:Ir},{onError:(e,n)=>e&&n,inputDebounceTime:(e,n)=>e&&n,keymaps:(e,n)=>e&&n})}),sr=Tt.define(),ir=vn.define({create:()=>({show:!1,lineFrom:0,lineTo:0}),update(t,e){for(const n of e.effects)if(n.is(sr))return n.value;return t}}),Ws=Tt.define(),qs=Tt.define(),A1=vn.define({create:()=>({shouldFocus:!1,inputValue:""}),update(t,e){let n=t;for(const o of e.effects)o.is(Ws)&&(n={...n,inputValue:o.value}),o.is(qs)&&(n={...n,shouldFocus:o.value});return n}}),$a=Tt.define(),Gs=vn.define({create:()=>null,update(t,e){for(const n of e.effects)if(n.is($a))return n.value;return t}}),Ar=Tt.define(),T1=vn.define({create:()=>!1,update(t,e){for(const n of e.effects)if(n.is(Ar))return n.value;return t}}),M1=t=>{const{state:e}=t,n=e.selection.main;if(n.empty)return!1;const o=e.doc,r=o.lineAt(n.from),s=o.lineAt(n.to);if(e.sliceDoc(r.from,s.to).trim().length<1)return!1;const i=Math.max(1,Math.min(r.number,o.lines)),a=Math.max(1,Math.min(s.number,o.lines));return t.dispatch({effects:[sr.of({show:!0,lineFrom:i,lineTo:a}),qs.of(!0),Ws.of("")],selection:Qn.cursor(r.from)}),!0},O1=t=>!!t.state.field(Gs)&&(t.dispatch({effects:[$a.of(null),sr.of({show:!1,lineFrom:0,lineTo:0}),qs.of(!1),Ws.of(""),Ar.of(!1)]}),!0),D1=t=>{const e=t.state.field(Gs);return!!e&&(t.dispatch({changes:{from:e.from,to:e.to,insert:e.oldCode},effects:[$a.of(null),sr.of({show:!1,lineFrom:0,lineTo:0}),qs.of(!1),Ws.of(""),Ar.of(!1)]}),!0)},VN=We.baseTheme({".cm-ai-input-container":{display:"flex",flexDirection:"column",gap:"4px",width:"min(calc(100% + 7px), 500px)",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-button":{fontSize:"10px",paddingLeft:"10px",height:"18px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",display:"block",marginRight:"auto"},".cm-ai-help-info-button:hover":{color:"light-dark(rgb(89, 97, 105), rgb(190, 190, 190))"},".cm-ai-generate-button":{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",paddingTop:"0",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",top:"-20px",left:"5px",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",color:"white",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".cm-floating-reject":{backgroundColor:"light-dark(rgb(220, 53, 69), rgb(180, 40, 50))",color:"white",borderTopRightRadius:"5px",borderBottomRightRadius:"5px",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".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-button":{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"}}),HN="\u2318",WN="\u229E Win",qN="Ctrl";function Vd(t){return t.replace("Mod",navigator.platform.startsWith("Mac")?HN:navigator.platform.startsWith("Win")?WN:qN).replace("-"," ").toUpperCase()}function Kt(t,e){const n=document.createElement(t);return n.className=e,n}function GN(t){var r,s;const e=t.state.facet(Hs),n={...Ir,...e.keymaps},o=Kt("div","cm-ai-tooltip").appendChild(Kt("div","cm-ai-tooltip-button"));return o.innerHTML=`<span>Edit <span class="hotkey">${Vd(n.showInput)}</span></span>`,(r=o.querySelector("span"))==null||r.addEventListener("mousedown",i=>{i.stopPropagation()}),(s=o.querySelector("span"))==null||s.addEventListener("click",i=>{i.preventDefault(),M1(t)}),o}const YN=vr.define({combine:t=>Ac(t,{render:GN})}),KN=$n.fromClass((r3=class{constructor(t){Z(this,"view");Z(this,"suppress");Z(this,"dom");Z(this,"mousedown",()=>{this.suppress=!0});Z(this,"mouseup",()=>{this.suppress=!1,this.display(this.view)});c3(this,Ql,t=>{var n;const e=t.state.selection.ranges.find(o=>!o.empty);if(e&&!this.suppress){const o=t.coordsAtPos(e.from);if(!o)return;this.dom.style.display="flex";const r=this.dom.getBoundingClientRect(),s=t.dom.getBoundingClientRect(),i=(n=t.dom.parentElement)==null?void 0:n.getBoundingClientRect(),a=s.width-r.width,l=Math.min(o.left,a);let c=o.top-r.height;c=i?Math.max(i.y,c):c,this.dom.style.left=`${l}px`,this.dom.style.top=`${c}px`,requestAnimationFrame(()=>{this.dom&&(this.dom.ariaHidden="false")})}else this.dom.style.display="none",this.dom.ariaHidden="true"});this.view=t;const e=t.state.facet(YN);this.suppress=!1,document.addEventListener("mousedown",this.mousedown),document.addEventListener("mouseup",this.mouseup);const n=e.render(t);t.dom.appendChild(n),this.dom=n}update(t){this.display(t.view)}docViewUpdate(t){this.display(t)}display(t){t.state.field(ir).show?this.dom.style.display="none":t.requestMeasure({read:l3(this,Ql)})}destroy(){document.removeEventListener("mousedown",this.mousedown),document.removeEventListener("mouseup",this.mouseup),this.dom.remove()}},Ql=new WeakMap,r3)),XN=We.baseTheme({".cm-ai-tooltip-button":{userSelect:"none",fontFamily:"system-ui, -apple-system, sans-serif",position:"fixed",display:"flex",boxSizing:"border-box",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",transition:"opacity 0.5s","&[aria-hidden='true']":{opacity:"0"},"&[aria-hidden='false']":{opacity:"1"},"& > span":{pointerEvents:"auto",cursor:"pointer",display:"inline-block",padding:"2px"},"&:hover":{backgroundColor:"#1177bb"}}});class JN extends vs{constructor(n){super();Z(this,"oldCode");this.oldCode=n}toDOM(n){const o=Kt("div","cm-old-code-container");o.setAttribute("role","region"),o.setAttribute("aria-label","Previous code version");const r=Kt("div","cm-old-code cm-line");r.textContent=this.oldCode;const s=Kt("div","cm-floating-buttons"),i=n.state.facet(Hs),a={...Ir,...i.keymaps},l=Kt("button","cm-floating-button cm-floating-accept");l.innerHTML=`<span class="hotkey">${Vd(a.acceptEdit)}</span> Accept`,l.setAttribute("aria-label","Accept changes"),l.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),n.focus(),O1(n)});const c=Kt("button","cm-floating-button cm-floating-reject");return c.innerHTML=`<span class="hotkey">${Vd(a.rejectEdit)}</span> Reject`,c.setAttribute("aria-label","Reject changes"),c.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),n.focus(),D1(n)}),s.append(l,c),o.append(r,s),o}updateDOM(n,o){return!0}}class ZN extends vs{constructor(n){super();Z(this,"complete");Z(this,"abortController",null);Z(this,"dom",null);Z(this,"input",null);Z(this,"loadingContainer",null);Z(this,"helpInfo",null);Z(this,"inputContainer",null);Z(this,"form",null);Z(this,"view",null);Z(this,"onKeyDown",async n=>{n.key!=="Enter"||n.shiftKey?n.key==="Escape"&&this.onCancel():(n.preventDefault(),await this.handleSubmit())});Z(this,"onCancel",()=>{this.cleanup();const n=this.view;n&&(n.dispatch({effects:[sr.of({show:!1,lineFrom:0,lineTo:0}),Ar.of(!1)]}),n.focus())});Z(this,"handleSubmit",async n=>{var x;const o=this.view;if(!o)return;const r=o.state.facet(Hs);n==null||n.stopPropagation();const s=o.state.field(ir),{input:i}=this;if(!i)return;const a=i.value.trim();if(!s.show||!a)return;const l=o.state.doc.line(s.lineFrom),c=o.state.doc.line(s.lineTo),d=l.from,h=c.to,f=o.state.sliceDoc(d,h),m=o.state.sliceDoc(0,d),g=o.state.sliceDoc(h);this.abortController=new AbortController,o.dispatch({effects:Ar.of(!0)}),this.toggleLoading(!0);try{const p=await this.complete({prompt:a,selection:f,codeBefore:m,codeAfter:g,editorView:o,signal:this.abortController.signal});if(!o.state.field(ir).show)return;if(!p||typeof p!="string")throw new Error("Invalid completion result");o.dispatch({changes:{from:d,to:h,insert:p},effects:[sr.of({show:!1,lineFrom:0,lineTo:0}),$a.of({from:d,to:d+p.length,oldCode:f,newCode:p}),Ar.of(!1)]})}catch(p){if(p instanceof DOMException&&p.name==="AbortError")return;(x=r.onError)==null||x.call(r,p)}finally{this.cleanup(),this.toggleLoading(!1),o.focus()}});this.complete=n}toDOM(n){if(this.dom)return this.dom;this.view=n;const o=n.state.field(A1),r=n.state.field(T1),s=Kt("div","cm-ai-input-container");this.inputContainer=s,this.dom=s;const i=Kt("form","cm-ai-input-form");this.form=i,i.setAttribute("role","search"),i.setAttribute("aria-label","AI editing instructions"),i.addEventListener("submit",p=>p.preventDefault());const a=Kt("input","cm-ai-input");this.input=a,i.append(a),a.placeholder="Editing instructions...",a.setAttribute("aria-label","AI editing instructions"),a.setAttribute("autocomplete","off"),a.setAttribute("spellcheck","true"),a.value=o.inputValue;const l=Kt("div","cm-ai-loading-container");this.loadingContainer=l;const c=Kt("div","cm-ai-loading-indicator");c.setAttribute("role","status"),c.setAttribute("aria-live","polite"),c.textContent="Generating";const d=Kt("button","cm-ai-cancel-button");d.textContent="Cancel",d.setAttribute("aria-label","Cancel code generation"),d.addEventListener("click",this.onCancel),l.append(d,c);const h=Kt("div","cm-ai-help-info");this.helpInfo=h;const f=h.appendChild(document.createElement("button"));f.className="cm-ai-help-info-button",f.textContent="Esc to close",f.addEventListener("click",this.onCancel);const m=Kt("button","cm-ai-generate-button");function g(p){h.replaceChildren(p?m:f)}m.textContent="\u23CE Generate",m.setAttribute("aria-label","Generate code"),m.addEventListener("click",this.handleSubmit),this.toggleLoading(r),o.shouldFocus&&requestAnimationFrame(()=>{a.value=o.inputValue,a.focus(),n.dispatch({effects:qs.of(!1)})}),g(a.value),a.addEventListener("input",function(){n.dispatch({effects:Ws.of(a.value)});const p=a.value.trim();p!==x&&(x=p,g(p))}),a.addEventListener("keydown",this.onKeyDown);let x="";return s}toggleLoading(n){var o;this.inputContainer&&this.form&&this.loadingContainer&&this.helpInfo&&((o=this.inputContainer)==null||o.replaceChildren(this.form,n?this.loadingContainer:this.helpInfo))}updateDOM(n,o){return this.dom=n,this.input=n.querySelector(".cm-ai-input"),!0}cleanup(){var n,o,r;(n=this.abortController)==null||n.abort(),this.abortController=null,(o=this.dom)==null||o.remove(),(r=this.input)==null||r.remove(),this.dom=null,this.input=null}destroy(){this.cleanup()}}function QN(t){if(!t.prompt)throw new Error("prompt function is required");return[Hs.of(t),ir,A1,Gs,T1,[KN,XN],VN,Mn.of([{key:Ir.showInput,run:M1}]),To.highest([Mn.of([{key:Ir.acceptEdit,run:O1},{key:Ir.rejectEdit,run:D1}])]),eE,tE,nE,oE]}const eE=We.updateListener.of(t=>{const e=t.state.field(ir);if(!e.show||!t.docChanged)return;let{lineFrom:n,lineTo:o}=e,r=!1;t.changes.iterChanges((s,i,a,l)=>{const c=t.state.doc.lineAt(s).number;if(c<n){const d=t.state.doc.lineAt(l).number-t.state.doc.lineAt(a).number;n+=d,o+=d,r=!0}else if(c<=o){const d=t.state.doc.lineAt(l).number-t.state.doc.lineAt(a).number;o+=d,r=!0}}),r&&t.view.dispatch({effects:[sr.of({show:!0,lineFrom:n,lineTo:o})]})}),tE=We.decorations.of(t=>{const e=t.state.field(Gs);return e?ot.set([ot.mark({class:"cm-new-code-line"}).range(e.from,e.to)]):ot.none}),nE=We.decorations.compute([ir],t=>{const e=t.field(ir),n=t.facet(Hs),o=[];if(e.show){const r=e.lineFrom,s=e.lineTo;for(let i=r;i<=s;i++){const a=t.doc.line(i).from;o.push(ot.line({class:"cm-ai-selection"}).range(a)),i===r&&o.push(ot.widget({widget:new ZN(n.prompt),side:-1}).range(a))}}return ot.set(o)}),oE=vn.define({create:t=>ot.none,update(t,e){const n=e.state.field(Gs);return n?ot.set([ot.widget({widget:new JN(n.oldCode),block:!0}).range(n.from)]):ot.none},provide:t=>We.decorations.from(t)}),Va=vn.define({create:()=>({suggestion:null}),update(t,e){const n=e.effects.find(o=>o.is(Ha));return e.docChanged||n||e.selection?n&&e.state.doc===n.value.doc?{suggestion:n.value.text}:{suggestion:null}:t}}),Ha=Tt.define();class rE extends vs{constructor(n){super();Z(this,"suggestion");this.suggestion=n}toDOM(){const n=document.createElement("span");return n.style.opacity="0.4",n.className="cm-inline-suggestion",n.textContent=this.suggestion,n.setAttribute("role","suggestion"),n.setAttribute("aria-label",`Suggestion: ${this.suggestion}`),n}get lineBreaks(){return this.suggestion.split(`
103
+ `).length-1}}class sE{constructor(e){Z(this,"cache",new Map);Z(this,"timeout");this.timeout=e}get(e){const n=this.cache.get(e);return n?Date.now()-n.timestamp>this.timeout?(this.cache.delete(e),null):n.result:null}set(e,n){this.cache.set(e,{result:n,timestamp:Date.now()})}}const iE=(t,e)=>$n.fromClass(class{constructor(){Z(this,"abortController",null);Z(this,"cache");this.cache=new sE(e.cacheTimeout??1e3)}async update(n){var i,a,l,c,d;if(!n.docChanged||((a=(i=e.events)==null?void 0:i.beforeSuggestionFetch)==null?void 0:a.call(i,n.view))===!1)return;(l=this.abortController)==null||l.abort(),this.abortController=new AbortController;const o=n.state.doc,r=o.toString(),s=this.cache.get(r);if(s)n.view.dispatch({effects:Ha.of({text:s,doc:o})});else try{const h=await t(n.state,this.abortController.signal);if(this.abortController.signal.aborted||((d=(c=e.events)==null?void 0:c.shouldShowSuggestion)==null?void 0:d.call(c,n.view,h))===!1)return;this.cache.set(r,h),n.view.dispatch({effects:Ha.of({text:h,doc:o})})}catch(h){h instanceof Error&&h.name!=="AbortError"&&console.error("Suggestion fetch error:",h)}}destroy(){var n;(n=this.abortController)==null||n.abort()}}),aE=$n.fromClass(class{constructor(){Z(this,"decorations");this.decorations=ot.none}update(t){var n;const e=(n=t.state.field(Va))==null?void 0:n.suggestion;this.decorations=e?function(o,r){const s=o.state.selection.main.head,i=[],a=ot.widget({widget:new rE(r),side:1});return i.push(a.range(s)),ot.set(i)}(t.view,e):ot.none}},{decorations:t=>t.decorations});function lE(t,e,n,o){return{...t.changeByRange(r=>{if(r===t.selection.main)return{changes:{from:n,to:o,insert:e},range:Qn.cursor(n+e.length)};const s=o-n;return!r.empty||s&&t.sliceDoc(r.from-s,r.from)!==t.sliceDoc(n,o)?{range:r}:{changes:{from:r.from-s,to:r.from,insert:e},range:Qn.cursor(r.from-s+e.length)}}),userEvent:"input.complete"}}const R1=t=>{var o,r,s;const e=(o=t.state.field(Va))==null?void 0:o.suggestion;if(!e)return!1;const n=t.state.facet(Hd);return t.dispatch({effects:Ha.of({text:null,doc:t.state.doc})}),(s=(r=n.events)==null?void 0:r.onSuggestionRejected)==null||s.call(r,t,e),!0},cE=Mn.of([{key:"Tab",run:t=>{var o,r,s;const e=(o=t.state.field(Va))==null?void 0:o.suggestion;if(!e)return!1;const n=t.state.facet(Hd);return t.dispatch({...lE(t.state,e,t.state.selection.main.head,t.state.selection.main.head)}),(s=(r=n.events)==null?void 0:r.onSuggestionAccepted)==null||s.call(r,t,e),!0}},{key:"Escape",run:R1}]),Hd=vr.define({combine:t=>t.at(-1)});function P1(t){const{delay:e=500,includeKeymap:n=!0}=t,o=function(r,s,i){let a=()=>{};return(...l)=>(a(),new Promise((c,d)=>{const h=setTimeout(()=>c(r(...l)),s);a=()=>{clearTimeout(h),i!==void 0&&d(i)}}))}(t.fetchFn,e);return[Va,Hd.of(t),iE(o,t),aE,n?cE:[]]}const L1="packages-install-input",dE=["%alias","%cd","%clear","%debug","%env","%load","%load_ext","%lsmagic","%matplotlib","%pwd","%who_ls","%system","%%time","%%timeit","%%writefile","%%capture","%%html","%%latex"];let Wd;function uE(){const t=async r=>{const s=Qe.get(Ki),{saveUserConfig:i}=oC(),a={...s,runtime:{...s.runtime,auto_reload:r}};await i({config:a}).then(()=>Qe.set(Ki,a))},e=()=>{requestAnimationFrame(()=>{const r=document.getElementById(L1);r&&r.focus()})},n=[{match:"!pip install",onMatch:()=>{Qe.set(Lm,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:u.jsxs(u.Fragment,{children:["The package manager sidebar has been opened.",u.jsx("br",{}),"Install packages directly from there instead."]})},{match:"!uv pip install",onMatch:()=>{Qe.set(Lm,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:u.jsxs(u.Fragment,{children:["The package manager sidebar has been opened.",u.jsx("br",{}),"Install packages directly from there instead."]})},{match:"!uv add",onMatch:()=>{Qe.set(Lm,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:u.jsxs(u.Fragment,{children:["The package manager sidebar has been opened.",u.jsx("br",{}),"Install packages directly from there instead."]})},{match:"%autoreload 2",onMatch:async()=>{await t("autorun")},title:"Module reload",description:u.jsxs(u.Fragment,{children:["Module reload mode set to ",u.jsx("b",{children:"autorun"})," - module changes will re-run the cells that import them."]})},{match:"%autoreload 1",onMatch:async()=>{await t("lazy")},title:"Module reload",description:u.jsxs(u.Fragment,{children:["Module reload mode set to ",u.jsx("b",{children:"lazy"})," - module changes will mark the cells that import them as stale."]})},{match:"%autoreload 0",onMatch:async()=>{await t("off")},title:"Module reload",description:u.jsx(u.Fragment,{children:"Module reload disabled - module changes will not be detected."})},{match:"!ls",onMatch:()=>{},title:"Listing files",description:u.jsxs(u.Fragment,{children:["Shell commands are not directly supported.",u.jsx("br",{}),"Use ",u.jsx("code",{children:"import subprocess; subprocess.run(['ls'])"})," instead."]})},...dE.map(r=>({match:r,onMatch:()=>{},title:u.jsx(nC,{className:"inline",children:r}),description:u.jsxs(u.Fragment,{children:["Magic commands are not supported in marimo. Read more about replacements in the"," ",u.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"}),"."]})}))],o=new Map(n.map(r=>[r.match,r]));return We.updateListener.of(r=>{if(r.docChanged){const s=r.state.selection.main,i=r.state.doc,a=i.lineAt(s.head),l=i.sliceString(a.from,s.anchor).trim(),c=o.get(l);c&&(c.onMatch(),Wd?Wd.upsert({title:c.title,description:c.description}):Wd=Je({title:c.title,description:c.description}))}})}const hE=new Set(["Escape","Alt-`"]);function fE(){const t=rC.filter(e=>!hE.has(e.key));return To.highest(Mn.of([...t,{key:"Escape",run:e=>{const n=tc(e);return!ta(e)&&n}},{key:"Ctrl-y",run:e=>!!ta(e)&&sC(e)},{key:"Ctrl-n",run:e=>!!ta(e)&&Tc(!0)(e)},{key:"Ctrl-p",run:e=>!!ta(e)&&Tc(!1)(e)}]))}const qd=Tt.define(),Gd=Tt.define(),Yd=Tt.define();function bt(t,e){if(!t)throw new Error(e)}function Wa(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>2147483647||t<-2147483648)throw new Error("invalid int 32: "+t)}function Kd(t){if(typeof t!="number")throw new Error("invalid uint 32: "+typeof t);if(!Number.isInteger(t)||t>4294967295||t<0)throw new Error("invalid uint 32: "+t)}function F1(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(Number.isFinite(t)&&(t>3402823466385289e23||t<-3402823466385289e23))throw new Error("invalid float 32: "+t)}const z1=Symbol("@bufbuild/protobuf/enum-type");function mE(t){const e=t[z1];return bt(e,"missing enum type on enum object"),e}function B1(t,e,n,o){t[z1]=U1(e,n.map(r=>({no:r.no,name:r.name,localName:t[r.no]})))}function U1(t,e,n){const o=Object.create(null),r=Object.create(null),s=[];for(const i of e){const a=$1(i);s.push(a),o[i.name]=a,r[i.no]=a}return{typeName:t,values:s,findName:i=>o[i],findNumber:i=>r[i]}}function pE(t,e,n){const o={};for(const r of e){const s=$1(r);o[s.localName]=s.no,o[s.no]=s.localName}return B1(o,t,e),o}function $1(t){return"localName"in t?t:Object.assign(Object.assign({},t),{localName:t.name})}class St{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){const o=this.getType().runtime.bin,r=o.makeReadOptions(n);return o.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,n){const o=this.getType(),r=o.runtime.json,s=r.makeReadOptions(n);return r.readMessage(o,e,s,this),this}fromJsonString(e,n){let o;try{o=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(o,n)}toBinary(e){const n=this.getType().runtime.bin,o=n.makeWriteOptions(e),r=o.writerFactory();return n.writeMessage(this,r,o),r.finish()}toJson(e){const n=this.getType().runtime.json,o=n.makeWriteOptions(e);return n.writeMessage(this,o)}toJsonString(e){var n;const o=this.toJson(e);return JSON.stringify(o,null,(n=e==null?void 0:e.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function gE(){let t=0,e=0;for(let o=0;o<28;o+=7){let r=this.buf[this.pos++];if(t|=(127&r)<<o,!(128&r))return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(15&n)<<28,e=(112&n)>>4,!(128&n))return this.assertBounds(),[t,e];for(let o=3;o<=31;o+=7){let r=this.buf[this.pos++];if(e|=(127&r)<<o,!(128&r))return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Xd(t,e,n){for(let s=0;s<28;s+=7){const i=t>>>s,a=!(!(i>>>7)&&e==0),l=255&(a?128|i:i);if(n.push(l),!a)return}const o=t>>>28&15|(7&e)<<4,r=!!(e>>3);if(n.push(255&(r?128|o:o)),r){for(let s=3;s<31;s+=7){const i=e>>>s,a=!!(i>>>7),l=255&(a?128|i:i);if(n.push(l),!a)return}n.push(e>>>31&1)}}const qa=4294967296;function V1(t){const e=t[0]==="-";e&&(t=t.slice(1));const n=1e6;let o=0,r=0;function s(i,a){const l=Number(t.slice(i,a));r*=n,o=o*n+l,o>=qa&&(r+=o/qa|0,o%=qa)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?W1(o,r):Jd(o,r)}function H1(t,e){if({lo:t,hi:e}=function(l,c){return{lo:l>>>0,hi:c>>>0}}(t,e),e<=2097151)return String(qa*e+t);const n=16777215&(t>>>24|e<<8),o=e>>16&65535;let r=(16777215&t)+6777216*n+6710656*o,s=n+8147497*o,i=2*o;const a=1e7;return r>=a&&(s+=Math.floor(r/a),r%=a),s>=a&&(i+=Math.floor(s/a),s%=a),i.toString()+q1(s)+q1(r)}function Jd(t,e){return{lo:0|t,hi:0|e}}function W1(t,e){return e=~e,t?t=1+~t:e+=1,Jd(t,e)}const q1=t=>{const e=String(t);return"0000000".slice(e.length)+e};function G1(t,e){if(t>=0){for(;t>127;)e.push(127&t|128),t>>>=7;e.push(t)}else{for(let n=0;n<9;n++)e.push(127&t|128),t>>=7;e.push(1)}}function xE(){let t=this.buf[this.pos++],e=127&t;if(!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<7,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<14,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<21,!(128&t))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(15&t)<<28;for(let n=5;128&t&&n<10;n++)t=this.buf[this.pos++];if(128&t)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var bE={};const pt=function(){const t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(typeof process!="object"||bE.BUF_BIGINT_DISABLE!=="1")){const o=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),s=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(a){const l=typeof a=="bigint"?a:BigInt(a);if(l>r||l<o)throw new Error(`int64 invalid: ${a}`);return l},uParse(a){const l=typeof a=="bigint"?a:BigInt(a);if(l>i||l<s)throw new Error(`uint64 invalid: ${a}`);return l},enc(a){return t.setBigInt64(0,this.parse(a),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(a){return t.setBigInt64(0,this.uParse(a),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec:(a,l)=>(t.setInt32(0,a,!0),t.setInt32(4,l,!0),t.getBigInt64(0,!0)),uDec:(a,l)=>(t.setInt32(0,a,!0),t.setInt32(4,l,!0),t.getBigUint64(0,!0))}}const e=o=>bt(/^-?[0-9]+$/.test(o),`int64 invalid: ${o}`),n=o=>bt(/^[0-9]+$/.test(o),`uint64 invalid: ${o}`);return{zero:"0",supported:!1,parse:o=>(typeof o!="string"&&(o=o.toString()),e(o),o),uParse:o=>(typeof o!="string"&&(o=o.toString()),n(o),o),enc:o=>(typeof o!="string"&&(o=o.toString()),e(o),V1(o)),uEnc:o=>(typeof o!="string"&&(o=o.toString()),n(o),V1(o)),dec:(o,r)=>function(s,i){let a=Jd(s,i);const l=2147483648&a.hi;l&&(a=W1(a.lo,a.hi));const c=H1(a.lo,a.hi);return l?"-"+c:c}(o,r),uDec:(o,r)=>H1(o,r)}}();var ce,Do,Ct;function Ro(t,e,n){if(e===n)return!0;if(t==ce.BYTES){if(!(e instanceof Uint8Array&&n instanceof Uint8Array)||e.length!==n.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==n[o])return!1;return!0}switch(t){case ce.UINT64:case ce.FIXED64:case ce.INT64:case ce.SFIXED64:case ce.SINT64:return e==n}return!1}function Tr(t,e){switch(t){case ce.BOOL:return!1;case ce.UINT64:case ce.FIXED64:case ce.INT64:case ce.SFIXED64:case ce.SINT64:return e==0?pt.zero:"0";case ce.DOUBLE:case ce.FLOAT:return 0;case ce.BYTES:return new Uint8Array(0);case ce.STRING:return"";default:return 0}}function Y1(t,e){switch(t){case ce.BOOL:return e===!1;case ce.STRING:return e==="";case ce.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(ce||(ce={})),function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING"}(Do||(Do={})),function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"}(Ct||(Ct={}));class yE{constructor(e){this.stack=[],this.textEncoder=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 n=new Uint8Array(e),o=0;for(let r=0;r<this.chunks.length;r++)n.set(this.chunks[r],o),o+=this.chunks[r].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Kd(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return Wa(e),G1(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 n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){F1(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){Kd(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){Wa(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return Wa(e),G1(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let n=new Uint8Array(8),o=new DataView(n.buffer),r=pt.enc(e);return o.setInt32(0,r.lo,!0),o.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),o=new DataView(n.buffer),r=pt.uEnc(e);return o.setInt32(0,r.lo,!0),o.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=pt.enc(e);return Xd(n.lo,n.hi,this.buf),this}sint64(e){let n=pt.enc(e),o=n.hi>>31;return Xd(n.lo<<1^o,(n.hi<<1|n.lo>>>31)^o,this.buf),this}uint64(e){let n=pt.uEnc(e);return Xd(n.lo,n.hi,this.buf),this}}class vE{constructor(e,n){this.varint64=gE,this.uint32=xE,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n??new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,o=7&e;if(n<=0||o<0||o>5)throw new Error("illegal tag: field no "+n+" wire type "+o);return[n,o]}skip(e,n){let o=this.pos;switch(e){case Ct.Varint:for(;128&this.buf[this.pos++];);break;case Ct.Bit64:this.pos+=4;case Ct.Bit32:this.pos+=4;break;case Ct.LengthDelimited:let r=this.uint32();this.pos+=r;break;case Ct.StartGroup:for(;;){const[s,i]=this.tag();if(i===Ct.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(i,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(o,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 pt.dec(...this.varint64())}uint64(){return pt.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),o=-(1&e);return e=(e>>>1|(1&n)<<31)^o,n=n>>>1^o,pt.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return pt.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return pt.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(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}}function K1(t){const e=t.field.localName,n=Object.create(null);return n[e]=function(o){const r=o.field;if(r.repeated)return[];if(r.default!==void 0)return r.default;switch(r.kind){case"enum":return r.T.values[0].no;case"scalar":return Tr(r.T,r.L);case"message":const s=r.T,i=new s;return s.fieldWrapper?s.fieldWrapper.unwrapField(i):i;case"map":throw"map fields are not allowed to be extensions"}}(t),[n,()=>n[e]]}let no="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Ga=[];for(let t=0;t<no.length;t++)Ga[no[t].charCodeAt(0)]=t;Ga[45]=no.indexOf("+"),Ga[95]=no.indexOf("/");const Ya={dec(t){let e=3*t.length/4;t[t.length-2]=="="?e-=2:t[t.length-1]=="="&&(e-=1);let n,o=new Uint8Array(e),r=0,s=0,i=0;for(let a=0;a<t.length;a++){if(n=Ga[t.charCodeAt(a)],n===void 0)switch(t[a]){case"=":s=0;case`
104
+ `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(s){case 0:i=n,s=1;break;case 1:o[r++]=i<<2|(48&n)>>4,i=n,s=2;break;case 2:o[r++]=(15&i)<<4|(60&n)>>2,i=n,s=3;break;case 3:o[r++]=(3&i)<<6|n,s=0}}if(s==1)throw Error("invalid base64 string.");return o.subarray(0,r)},enc(t){let e,n="",o=0,r=0;for(let s=0;s<t.length;s++)switch(e=t[s],o){case 0:n+=no[e>>2],r=(3&e)<<4,o=1;break;case 1:n+=no[r|e>>4],r=(15&e)<<2,o=2;break;case 2:n+=no[r|e>>6],n+=no[63&e],o=0}return o&&(n+=no[r],n+="=",o==1&&(n+="=")),n}};function wE(t,e,n){J1(e,t);const o=e.runtime.bin.makeReadOptions(n),r=function(a,l){if(!l.repeated&&(l.kind=="enum"||l.kind=="scalar")){for(let c=a.length-1;c>=0;--c)if(a[c].no==l.no)return[a[c]];return[]}return a.filter(c=>c.no===l.no)}(t.getType().runtime.bin.listUnknownFields(t),e.field),[s,i]=K1(e);for(const a of r)e.runtime.bin.readField(s,o.readerFactory(a.data),e.field,a.wireType,o);return i()}function kE(t,e,n,o){J1(e,t);const r=e.runtime.bin.makeReadOptions(o),s=e.runtime.bin.makeWriteOptions(o);if(X1(t,e)){const c=t.getType().runtime.bin.listUnknownFields(t).filter(d=>d.no!=e.field.no);t.getType().runtime.bin.discardUnknownFields(t);for(const d of c)t.getType().runtime.bin.onUnknownField(t,d.no,d.wireType,d.data)}const i=s.writerFactory();let a=e.field;a.opt||a.repeated||a.kind!="enum"&&a.kind!="scalar"||(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,n,i,s);const l=r.readerFactory(i.finish());for(;l.pos<l.len;){const[c,d]=l.tag(),h=l.skip(d,c);t.getType().runtime.bin.onUnknownField(t,c,d,h)}}function X1(t,e){const n=t.getType();return e.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(t).find(o=>o.no==e.field.no)}function J1(t,e){bt(t.extendee.typeName==e.getType().typeName,`extension ${t.typeName} can only be applied to message ${t.extendee.typeName}`)}function Z1(t,e){const n=t.localName;if(t.repeated)return e[n].length>0;if(t.oneof)return e[t.oneof.localName].case===n;switch(t.kind){case"enum":case"scalar":return t.opt||t.req?e[n]!==void 0:t.kind=="enum"?e[n]!==t.T.values[0].no:!Y1(t.T,e[n]);case"message":return e[n]!==void 0;case"map":return Object.keys(e[n]).length>0}}function Q1(t,e){const n=t.localName,o=!t.opt&&!t.req;if(t.repeated)e[n]=[];else if(t.oneof)e[t.oneof.localName]={case:void 0};else switch(t.kind){case"map":e[n]={};break;case"enum":e[n]=o?t.T.values[0].no:void 0;break;case"scalar":e[n]=o?Tr(t.T,t.L):void 0;break;case"message":e[n]=void 0}}function oo(t,e){if(t===null||typeof t!="object"||!Object.getOwnPropertyNames(St.prototype).every(o=>o in t&&typeof t[o]=="function"))return!1;const n=t.getType();return n!==null&&typeof n=="function"&&"typeName"in n&&typeof n.typeName=="string"&&(e===void 0||n.typeName==e.typeName)}function e0(t,e){return oo(e)||!t.fieldWrapper?e:t.fieldWrapper.wrapField(e)}ce.DOUBLE,ce.FLOAT,ce.INT64,ce.UINT64,ce.INT32,ce.UINT32,ce.BOOL,ce.STRING,ce.BYTES;const t0={ignoreUnknownFields:!1},n0={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function CE(t){return t?Object.assign(Object.assign({},t0),t):t0}function jE(t){return t?Object.assign(Object.assign({},n0),t):n0}const Ka=Symbol(),Xa=Symbol();function Hn(t){if(t===null)return"null";switch(typeof t){case"object":return Array.isArray(t)?"array":"object";case"string":return t.length>100?"string":`"${t.split('"').join('\\"')}"`;default:return String(t)}}function o0(t,e,n,o,r){let s=n.localName;if(n.repeated){if(bt(n.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${Hn(e)}`);const i=t[s];for(const a of e){if(a===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${Hn(a)}`);switch(n.kind){case"message":i.push(n.T.fromJson(a,o));break;case"enum":const l=Zd(n.T,a,o.ignoreUnknownFields,!0);l!==Xa&&i.push(l);break;case"scalar":try{i.push(Ys(n.T,a,n.L,!0))}catch(c){let d=`cannot decode field ${r.typeName}.${n.name} from JSON: ${Hn(a)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),new Error(d)}}}}else if(n.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${Hn(e)}`);const i=t[s];for(const[a,l]of Object.entries(e)){if(l===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let c;try{c=SE(n.K,a)}catch(d){let h=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${Hn(e)}`;throw d instanceof Error&&d.message.length>0&&(h+=`: ${d.message}`),new Error(h)}switch(n.V.kind){case"message":i[c]=n.V.T.fromJson(l,o);break;case"enum":const d=Zd(n.V.T,l,o.ignoreUnknownFields,!0);d!==Xa&&(i[c]=d);break;case"scalar":try{i[c]=Ys(n.V.T,l,Do.BIGINT,!0)}catch(h){let f=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${Hn(e)}`;throw h instanceof Error&&h.message.length>0&&(f+=`: ${h.message}`),new Error(f)}}}}else switch(n.oneof&&(t=t[n.oneof.localName]={case:s},s="value"),n.kind){case"message":const i=n.T;if(e===null&&i.typeName!="google.protobuf.Value")return;let a=t[s];oo(a)?a.fromJson(e,o):(t[s]=a=i.fromJson(e,o),i.fieldWrapper&&!n.oneof&&(t[s]=i.fieldWrapper.unwrapField(a)));break;case"enum":const l=Zd(n.T,e,o.ignoreUnknownFields,!1);switch(l){case Ka:Q1(n,t);break;case Xa:break;default:t[s]=l}break;case"scalar":try{const c=Ys(n.T,e,n.L,!1);c===Ka?Q1(n,t):t[s]=c}catch(c){let d=`cannot decode field ${r.typeName}.${n.name} from JSON: ${Hn(e)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),new Error(d)}}}function SE(t,e){if(t===ce.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1}return Ys(t,e,Do.BIGINT,!0).toString()}function Ys(t,e,n,o){if(e===null)return o?Tr(t,n):Ka;switch(t){case ce.DOUBLE:case ce.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return t==ce.FLOAT&&F1(r),r;case ce.INT32:case ce.FIXED32:case ce.SFIXED32:case ce.SINT32:case ce.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return t==ce.UINT32||t==ce.FIXED32?Kd(s):Wa(s),s;case ce.INT64:case ce.SFIXED64:case ce.SINT64:if(typeof e!="number"&&typeof e!="string")break;const i=pt.parse(e);return n?i.toString():i;case ce.FIXED64:case ce.UINT64:if(typeof e!="number"&&typeof e!="string")break;const a=pt.uParse(e);return n?a.toString():a;case ce.BOOL:if(typeof e!="boolean")break;return e;case ce.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case ce.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return Ya.dec(e)}throw new Error}function Zd(t,e,n,o){if(e===null)return t.typeName=="google.protobuf.NullValue"?0:o?t.values[0].no:Ka;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const r=t.findName(e);if(r!==void 0)return r.no;if(n)return Xa}throw new Error(`cannot decode enum ${t.typeName} from JSON: ${Hn(e)}`)}function NE(t){return!(!t.repeated&&t.kind!="map")||!t.oneof&&t.kind!="message"&&!t.opt&&!t.req}function r0(t,e,n){if(t.kind=="map"){bt(typeof e=="object"&&e!=null);const o={},r=Object.entries(e);switch(t.V.kind){case"scalar":for(const[i,a]of r)o[i.toString()]=Ja(t.V.T,a);break;case"message":for(const[i,a]of r)o[i.toString()]=a.toJson(n);break;case"enum":const s=t.V.T;for(const[i,a]of r)o[i.toString()]=Qd(s,a,n.enumAsInteger)}return n.emitDefaultValues||r.length>0?o:void 0}if(t.repeated){bt(Array.isArray(e));const o=[];switch(t.kind){case"scalar":for(let r=0;r<e.length;r++)o.push(Ja(t.T,e[r]));break;case"enum":for(let r=0;r<e.length;r++)o.push(Qd(t.T,e[r],n.enumAsInteger));break;case"message":for(let r=0;r<e.length;r++)o.push(e[r].toJson(n))}return n.emitDefaultValues||o.length>0?o:void 0}switch(t.kind){case"scalar":return Ja(t.T,e);case"enum":return Qd(t.T,e,n.enumAsInteger);case"message":return e0(t.T,e).toJson(n)}}function Qd(t,e,n){var o;if(bt(typeof e=="number"),t.typeName=="google.protobuf.NullValue")return null;if(n)return e;const r=t.findNumber(e);return(o=r==null?void 0:r.name)!==null&&o!==void 0?o:e}function Ja(t,e){switch(t){case ce.INT32:case ce.SFIXED32:case ce.SINT32:case ce.FIXED32:case ce.UINT32:return bt(typeof e=="number"),e;case ce.FLOAT:case ce.DOUBLE:return bt(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case ce.STRING:return bt(typeof e=="string"),e;case ce.BOOL:return bt(typeof e=="boolean"),e;case ce.UINT64:case ce.FIXED64:case ce.INT64:case ce.SFIXED64:case ce.SINT64:return bt(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case ce.BYTES:return bt(e instanceof Uint8Array),Ya.enc(e)}}const Mr=Symbol("@bufbuild/protobuf/unknown-fields"),s0={readUnknownFields:!0,readerFactory:t=>new vE(t)},i0={writeUnknownFields:!0,writerFactory:()=>new yE};function EE(t){return t?Object.assign(Object.assign({},s0),t):s0}function _E(t){return t?Object.assign(Object.assign({},i0),t):i0}function a0(t,e,n,o,r){let{repeated:s,localName:i}=n;switch(n.oneof&&((t=t[n.oneof.localName]).case!=i&&delete t.value,t.case=i,i="value"),n.kind){case"scalar":case"enum":const a=n.kind=="enum"?ce.INT32:n.T;let l=Qa;if(n.kind=="scalar"&&n.L>0&&(l=IE),s){let f=t[i];if(o==Ct.LengthDelimited&&a!=ce.STRING&&a!=ce.BYTES){let m=e.uint32()+e.pos;for(;e.pos<m;)f.push(l(e,a))}else f.push(l(e,a))}else t[i]=l(e,a);break;case"message":const c=n.T;s?t[i].push(Za(e,new c,r,n)):oo(t[i])?Za(e,t[i],r,n):(t[i]=Za(e,new c,r,n),!c.fieldWrapper||n.oneof||n.repeated||(t[i]=c.fieldWrapper.unwrapField(t[i])));break;case"map":let[d,h]=function(f,m,g){const x=m.uint32(),p=m.pos+x;let b,y;for(;m.pos<p;){const[v]=m.tag();switch(v){case 1:b=Qa(m,f.K);break;case 2:switch(f.V.kind){case"scalar":y=Qa(m,f.V.T);break;case"enum":y=m.int32();break;case"message":y=Za(m,new f.V.T,g,void 0)}}}if(b===void 0&&(b=Tr(f.K,Do.BIGINT)),typeof b!="string"&&typeof b!="number"&&(b=b.toString()),y===void 0)switch(f.V.kind){case"scalar":y=Tr(f.V.T,Do.BIGINT);break;case"enum":y=f.V.T.values[0].no;break;case"message":y=new f.V.T}return[b,y]}(n,e,r);t[i][d]=h}}function Za(t,e,n,o){const r=e.getType().runtime.bin,s=o==null?void 0:o.delimited;return r.readMessage(e,t,s?o.no:t.uint32(),n,s),e}function IE(t,e){const n=Qa(t,e);return typeof n=="bigint"?n.toString():n}function Qa(t,e){switch(e){case ce.STRING:return t.string();case ce.BOOL:return t.bool();case ce.DOUBLE:return t.double();case ce.FLOAT:return t.float();case ce.INT32:return t.int32();case ce.INT64:return t.int64();case ce.UINT64:return t.uint64();case ce.FIXED64:return t.fixed64();case ce.BYTES:return t.bytes();case ce.FIXED32:return t.fixed32();case ce.SFIXED32:return t.sfixed32();case ce.SFIXED64:return t.sfixed64();case ce.SINT64:return t.sint64();case ce.UINT32:return t.uint32();case ce.SINT32:return t.sint32()}}function l0(t,e,n,o){bt(e!==void 0);const r=t.repeated;switch(t.kind){case"scalar":case"enum":let s=t.kind=="enum"?ce.INT32:t.T;if(r)if(bt(Array.isArray(e)),t.packed)(function(i,a,l,c){if(!c.length)return;i.tag(l,Ct.LengthDelimited).fork();let[,d]=d0(a);for(let h=0;h<c.length;h++)i[d](c[h]);i.join()})(n,s,t.no,e);else for(const i of e)Ks(n,s,t.no,i);else Ks(n,s,t.no,e);break;case"message":if(r){bt(Array.isArray(e));for(const i of e)c0(n,o,t,i)}else c0(n,o,t,e);break;case"map":bt(typeof e=="object"&&e!=null);for(const[i,a]of Object.entries(e))AE(n,o,t,i,a)}}function AE(t,e,n,o,r){t.tag(n.no,Ct.LengthDelimited),t.fork();let s=o;switch(n.K){case ce.INT32:case ce.FIXED32:case ce.UINT32:case ce.SFIXED32:case ce.SINT32:s=Number.parseInt(o);break;case ce.BOOL:bt(o=="true"||o=="false"),s=o=="true"}switch(Ks(t,n.K,1,s),n.V.kind){case"scalar":Ks(t,n.V.T,2,r);break;case"enum":Ks(t,ce.INT32,2,r);break;case"message":bt(r!==void 0),t.tag(2,Ct.LengthDelimited).bytes(r.toBinary(e))}t.join()}function c0(t,e,n,o){const r=e0(n.T,o);n.delimited?t.tag(n.no,Ct.StartGroup).raw(r.toBinary(e)).tag(n.no,Ct.EndGroup):t.tag(n.no,Ct.LengthDelimited).bytes(r.toBinary(e))}function Ks(t,e,n,o){bt(o!==void 0);let[r,s]=d0(e);t.tag(n,r)[s](o)}function d0(t){let e=Ct.Varint;switch(t){case ce.BYTES:case ce.STRING:e=Ct.LengthDelimited;break;case ce.DOUBLE:case ce.FIXED64:case ce.SFIXED64:e=Ct.Bit64;break;case ce.FIXED32:case ce.SFIXED32:case ce.FLOAT:e=Ct.Bit32}return[e,ce[t].toLowerCase()]}function el(t){if(t===void 0)return t;if(oo(t))return t.clone();if(t instanceof Uint8Array){const e=new Uint8Array(t.byteLength);return e.set(t),e}return t}function Xs(t){return t instanceof Uint8Array?t:new Uint8Array(t)}class TE{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){const n={};for(const o of this.list())n[o.jsonName]=n[o.name]=o;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){const n={};for(const o of this.list())n[o.no]=o;this.numbers=n}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,n)=>e.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let n;for(const o of this.list())o.oneof?o.oneof!==n&&(n=o.oneof,e.push(n)):e.push(o)}return this.members}}function u0(t,e){const n=h0(t);return e?n:PE(RE(n))}const ME=h0;function h0(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){let r=t.charAt(o);switch(r){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(r),e=!1;break;default:e&&(e=!1,r=r.toUpperCase()),n.push(r)}}return n.join("")}const OE=new Set(["constructor","toString","toJSON","valueOf"]),DE=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),f0=t=>`${t}$`,RE=t=>DE.has(t)?f0(t):t,PE=t=>OE.has(t)?f0(t):t;class LE{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=u0(e,!1)}addField(e){bt(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 n=0;n<this.fields.length;n++)this._lookup[this.fields[n].localName]=this.fields[n]}return this._lookup[e]}}const be=(m0=t=>new TE(t,e=>function(n){var o,r,s,i,a,l;const c=[];let d;for(const h of typeof n=="function"?n():n){const f=h;if(f.localName=u0(h.name,h.oneof!==void 0),f.jsonName=(o=h.jsonName)!==null&&o!==void 0?o:ME(h.name),f.repeated=(r=h.repeated)!==null&&r!==void 0&&r,h.kind=="scalar"&&(f.L=(s=h.L)!==null&&s!==void 0?s:Do.BIGINT),f.delimited=(i=h.delimited)!==null&&i!==void 0&&i,f.req=(a=h.req)!==null&&a!==void 0&&a,f.opt=(l=h.opt)!==null&&l!==void 0&&l,h.packed===void 0&&(f.packed=h.kind=="enum"||h.kind=="scalar"&&h.T!=ce.BYTES&&h.T!=ce.STRING),h.oneof!==void 0){const m=typeof h.oneof=="string"?h.oneof:h.oneof.name;d&&d.name==m||(d=new LE(m)),f.oneof=d,d.addField(f)}c.push(f)}return c}(e)),p0=t=>{for(const e of t.getType().fields.byMember()){if(e.opt)continue;const n=e.localName,o=t;if(e.repeated)o[n]=[];else switch(e.kind){case"oneof":o[n]={case:void 0};break;case"enum":o[n]=0;break;case"map":o[n]={};break;case"scalar":o[n]=Tr(e.T,e.L)}}},{syntax:"proto3",json:{makeReadOptions:CE,makeWriteOptions:jE,readMessage(t,e,n,o){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${t.typeName} from JSON: ${Hn(e)}`);o=o??new t;const r=new Map,s=n.typeRegistry;for(const[i,a]of Object.entries(e)){const l=t.fields.findJsonName(i);if(l){if(l.oneof){if(a===null&&l.kind=="scalar")continue;const c=r.get(l.oneof);if(c!==void 0)throw new Error(`cannot decode message ${t.typeName} from JSON: multiple keys for oneof "${l.oneof.name}" present: "${c}", "${i}"`);r.set(l.oneof,i)}o0(o,a,l,n,t)}else{let c=!1;if(s!=null&&s.findExtension&&i.startsWith("[")&&i.endsWith("]")){const d=s.findExtension(i.substring(1,i.length-1));if(d&&d.extendee.typeName==t.typeName){c=!0;const[h,f]=K1(d);o0(h,a,d.field,n,d),kE(o,d,f(),n)}}if(!c&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${t.typeName} from JSON: key "${i}" is unknown`)}}return o},writeMessage(t,e){const n=t.getType(),o={};let r;try{for(r of n.fields.byNumber()){if(!Z1(r,t)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!NE(r))continue}const i=r0(r,r.oneof?t[r.oneof.localName].value:t[r.localName],e);i!==void 0&&(o[e.useProtoFieldName?r.name:r.jsonName]=i)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const i of n.runtime.bin.listUnknownFields(t)){const a=s.findExtensionFor(n.typeName,i.no);if(a&&X1(t,a)){const l=wE(t,a,e),c=r0(a.field,l,e);c!==void 0&&(o[a.field.jsonName]=c)}}}catch(s){const i=r?`cannot encode field ${n.typeName}.${r.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,a=s instanceof Error?s.message:String(s);throw new Error(i+(a.length>0?`: ${a}`:""))}return o},readScalar:(t,e,n)=>Ys(t,e,n??Do.BIGINT,!0),writeScalar(t,e,n){if(e!==void 0)return n||Y1(t,e)?Ja(t,e):void 0},debug:Hn},bin:{makeReadOptions:EE,makeWriteOptions:_E,listUnknownFields(t){var e;return(e=t[Mr])!==null&&e!==void 0?e:[]},discardUnknownFields(t){delete t[Mr]},writeUnknownFields(t,e){const n=t[Mr];if(n)for(const o of n)e.tag(o.no,o.wireType).raw(o.data)},onUnknownField(t,e,n,o){const r=t;Array.isArray(r[Mr])||(r[Mr]=[]),r[Mr].push({no:e,wireType:n,data:o})},readMessage(t,e,n,o,r){const s=t.getType(),i=r?e.len:e.pos+n;let a,l;for(;e.pos<i&&([a,l]=e.tag(),r!==!0||l!=Ct.EndGroup);){const c=s.fields.find(a);if(!c){const d=e.skip(l,a);o.readUnknownFields&&this.onUnknownField(t,a,l,d);continue}a0(t,e,c,l,o)}if(r&&(l!=Ct.EndGroup||a!==n))throw new Error("invalid end group tag")},readField:a0,writeMessage(t,e,n){const o=t.getType();for(const r of o.fields.byNumber())if(Z1(r,t))l0(r,r.oneof?t[r.oneof.localName].value:t[r.localName],e,n);else if(r.req)throw new Error(`cannot encode field ${o.typeName}.${r.name} to binary: required field not set`);return n.writeUnknownFields&&this.writeUnknownFields(t,e),e},writeField(t,e,n,o){e!==void 0&&l0(t,e,n,o)}},util:Object.assign(Object.assign({},{setEnumType:B1,initPartial(t,e){if(t===void 0)return;const n=e.getType();for(const o of n.fields.byMember()){const r=o.localName,s=e,i=t;if(i[r]!=null)switch(o.kind){case"oneof":const a=i[r].case;if(a===void 0)continue;const l=o.findField(a);let c=i[r].value;l&&l.kind=="message"&&!oo(c,l.T)?c=new l.T(c):l&&l.kind==="scalar"&&l.T===ce.BYTES&&(c=Xs(c)),s[r]={case:a,value:c};break;case"scalar":case"enum":let d=i[r];o.T===ce.BYTES&&(d=o.repeated?d.map(Xs):Xs(d)),s[r]=d;break;case"map":switch(o.V.kind){case"scalar":case"enum":if(o.V.T===ce.BYTES)for(const[m,g]of Object.entries(i[r]))s[r][m]=Xs(g);else Object.assign(s[r],i[r]);break;case"message":const f=o.V.T;for(const m of Object.keys(i[r])){let g=i[r][m];f.fieldWrapper||(g=new f(g)),s[r][m]=g}}break;case"message":const h=o.T;if(o.repeated)s[r]=i[r].map(f=>oo(f,h)?f:new h(f));else{const f=i[r];h.fieldWrapper?h.typeName==="google.protobuf.BytesValue"?s[r]=Xs(f):s[r]=f:s[r]=oo(f,h)?f:new h(f)}}}},equals:(t,e,n)=>e===n||!(!e||!n)&&t.fields.byMember().every(o=>{const r=e[o.localName],s=n[o.localName];if(o.repeated){if(r.length!==s.length)return!1;switch(o.kind){case"message":return r.every((i,a)=>o.T.equals(i,s[a]));case"scalar":return r.every((i,a)=>Ro(o.T,i,s[a]));case"enum":return r.every((i,a)=>Ro(ce.INT32,i,s[a]))}throw new Error(`repeated cannot contain ${o.kind}`)}switch(o.kind){case"message":let i=r,a=s;return o.T.fieldWrapper&&(i===void 0||oo(i)||(i=o.T.fieldWrapper.wrapField(i)),a===void 0||oo(a)||(a=o.T.fieldWrapper.wrapField(a))),o.T.equals(i,a);case"enum":return Ro(ce.INT32,r,s);case"scalar":return Ro(o.T,r,s);case"oneof":if(r.case!==s.case)return!1;const l=o.findField(r.case);if(l===void 0)return!0;switch(l.kind){case"message":return l.T.equals(r.value,s.value);case"enum":return Ro(ce.INT32,r.value,s.value);case"scalar":return Ro(l.T,r.value,s.value)}throw new Error(`oneof cannot contain ${l.kind}`);case"map":const c=Object.keys(r).concat(Object.keys(s));switch(o.V.kind){case"message":const d=o.V.T;return c.every(f=>d.equals(r[f],s[f]));case"enum":return c.every(f=>Ro(ce.INT32,r[f],s[f]));case"scalar":const h=o.V.T;return c.every(f=>Ro(h,r[f],s[f]))}}}),clone(t){const e=t.getType(),n=new e,o=n;for(const r of e.fields.byMember()){const s=t[r.localName];let i;if(r.repeated)i=s.map(el);else if(r.kind=="map"){i=o[r.localName];for(const[a,l]of Object.entries(s))i[a]=el(l)}else i=r.kind=="oneof"?r.findField(s.case)?{case:s.case,value:el(s.value)}:{case:void 0}:el(s);o[r.localName]=i}for(const r of e.runtime.bin.listUnknownFields(t))e.runtime.bin.onUnknownField(o,r.no,r.wireType,r.data);return n}}),{newFieldList:m0,initFields:p0}),makeMessageType(t,e,n){return function(o,r,s,i){var a;const l=(a=i==null?void 0:i.localName)!==null&&a!==void 0?a:r.substring(r.lastIndexOf(".")+1),c={[l]:function(d){o.util.initFields(this),o.util.initPartial(d,this)}}[l];return Object.setPrototypeOf(c.prototype,new St),Object.assign(c,{runtime:o,typeName:r,fields:o.util.newFieldList(s),fromBinary:(d,h)=>new c().fromBinary(d,h),fromJson:(d,h)=>new c().fromJson(d,h),fromJsonString:(d,h)=>new c().fromJsonString(d,h),equals:(d,h)=>o.util.equals(c,d,h)}),c}(this,t,e,n)},makeEnum:pE,makeEnumType:U1,getEnumType:mE,makeExtension(t,e,n){return function(o,r,s,i){let a;return{typeName:r,extendee:s,get field(){if(!a){const l=typeof i=="function"?i():i;l.name=r.split(".").pop(),l.jsonName=`[${r}]`,a=o.util.newFieldList([l]).list()[0]}return a},runtime:o}}(this,t,e,n)}});var m0,p0,fn,eu,tl,Js,nl,Zs,Po;(function(t){t[t.Unary=0]="Unary",t[t.ServerStreaming=1]="ServerStreaming",t[t.ClientStreaming=2]="ClientStreaming",t[t.BiDiStreaming=3]="BiDiStreaming"})(fn||(fn={})),function(t){t[t.NoSideEffects=1]="NoSideEffects",t[t.Idempotent=2]="Idempotent"}(eu||(eu={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.JUPYTER_FORMAT=77]="JUPYTER_FORMAT"}(tl||(tl={})),be.util.setEnumType(tl,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]),function(t){t[t.CODEIUM=0]="CODEIUM"}(Js||(Js={})),be.util.setEnumType(Js,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",t[t.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",t[t.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",t[t.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION"}(nl||(nl={})),be.util.setEnumType(nl,"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"}]),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",t[t.CACHE=2]="CACHE",t[t.NETWORK=3]="NETWORK"}(Zs||(Zs={})),be.util.setEnumType(Zs,"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"}]),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.C=1]="C",t[t.CLOJURE=2]="CLOJURE",t[t.COFFEESCRIPT=3]="COFFEESCRIPT",t[t.CPP=4]="CPP",t[t.CSHARP=5]="CSHARP",t[t.CSS=6]="CSS",t[t.CUDACPP=7]="CUDACPP",t[t.DOCKERFILE=8]="DOCKERFILE",t[t.GO=9]="GO",t[t.GROOVY=10]="GROOVY",t[t.HANDLEBARS=11]="HANDLEBARS",t[t.HASKELL=12]="HASKELL",t[t.HCL=13]="HCL",t[t.HTML=14]="HTML",t[t.INI=15]="INI",t[t.JAVA=16]="JAVA",t[t.JAVASCRIPT=17]="JAVASCRIPT",t[t.JSON=18]="JSON",t[t.JULIA=19]="JULIA",t[t.KOTLIN=20]="KOTLIN",t[t.LATEX=21]="LATEX",t[t.LESS=22]="LESS",t[t.LUA=23]="LUA",t[t.MAKEFILE=24]="MAKEFILE",t[t.MARKDOWN=25]="MARKDOWN",t[t.OBJECTIVEC=26]="OBJECTIVEC",t[t.OBJECTIVECPP=27]="OBJECTIVECPP",t[t.PERL=28]="PERL",t[t.PHP=29]="PHP",t[t.PLAINTEXT=30]="PLAINTEXT",t[t.PROTOBUF=31]="PROTOBUF",t[t.PBTXT=32]="PBTXT",t[t.PYTHON=33]="PYTHON",t[t.R=34]="R",t[t.RUBY=35]="RUBY",t[t.RUST=36]="RUST",t[t.SASS=37]="SASS",t[t.SCALA=38]="SCALA",t[t.SCSS=39]="SCSS",t[t.SHELL=40]="SHELL",t[t.SQL=41]="SQL",t[t.STARLARK=42]="STARLARK",t[t.SWIFT=43]="SWIFT",t[t.TSX=44]="TSX",t[t.TYPESCRIPT=45]="TYPESCRIPT",t[t.VISUALBASIC=46]="VISUALBASIC",t[t.VUE=47]="VUE",t[t.XML=48]="XML",t[t.XSL=49]="XSL",t[t.YAML=50]="YAML",t[t.SVELTE=51]="SVELTE",t[t.TOML=52]="TOML",t[t.DART=53]="DART",t[t.RST=54]="RST",t[t.OCAML=55]="OCAML",t[t.CMAKE=56]="CMAKE",t[t.PASCAL=57]="PASCAL",t[t.ELIXIR=58]="ELIXIR",t[t.FSHARP=59]="FSHARP",t[t.LISP=60]="LISP",t[t.MATLAB=61]="MATLAB",t[t.POWERSHELL=62]="POWERSHELL",t[t.SOLIDITY=63]="SOLIDITY",t[t.ADA=64]="ADA",t[t.OCAML_INTERFACE=65]="OCAML_INTERFACE"}(Po||(Po={})),be.util.setEnumType(Po,"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 io=class io extends St{constructor(n){super();Z(this,"completionId","");Z(this,"text","");Z(this,"prefix","");Z(this,"stop","");Z(this,"score",0);Z(this,"tokens",[]);Z(this,"decodedTokens",[]);Z(this,"probabilities",[]);Z(this,"adjustedProbabilities",[]);Z(this,"generatedLength",pt.zero);be.util.initPartial(n,this)}static fromBinary(n,o){return new io().fromBinary(n,o)}static fromJson(n,o){return new io().fromJson(n,o)}static fromJsonString(n,o){return new io().fromJsonString(n,o)}static equals(n,o){return be.util.equals(io,n,o)}};Z(io,"runtime",be),Z(io,"typeName","exa.codeium_common_pb.Completion"),Z(io,"fields",be.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 tu=io;const ao=class ao extends St{constructor(n){super();Z(this,"ideName","");Z(this,"ideVersion","");Z(this,"extensionName","");Z(this,"extensionVersion","");Z(this,"apiKey","");Z(this,"locale","");Z(this,"sessionId","");Z(this,"requestId",pt.zero);Z(this,"userAgent","");Z(this,"url","");Z(this,"authSource",Js.CODEIUM);be.util.initPartial(n,this)}static fromBinary(n,o){return new ao().fromBinary(n,o)}static fromJson(n,o){return new ao().fromJson(n,o)}static fromJsonString(n,o){return new ao().fromJsonString(n,o)}static equals(n,o){return be.util.equals(ao,n,o)}};Z(ao,"runtime",be),Z(ao,"typeName","exa.codeium_common_pb.Metadata"),Z(ao,"fields",be.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:be.getEnumType(Js)}]));let ol=ao;const lo=class lo extends St{constructor(n){super();Z(this,"tabSize",pt.zero);Z(this,"insertSpaces",!1);be.util.initPartial(n,this)}static fromBinary(n,o){return new lo().fromBinary(n,o)}static fromJson(n,o){return new lo().fromJson(n,o)}static fromJsonString(n,o){return new lo().fromJsonString(n,o)}static equals(n,o){return be.util.equals(lo,n,o)}};Z(lo,"runtime",be),Z(lo,"typeName","exa.codeium_common_pb.EditorOptions"),Z(lo,"fields",be.util.newFieldList(()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}]));let nu=lo;be.util.newFieldList(()=>[{no:1,name:"event_type",kind:"enum",T:be.getEnumType(nl)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}]);class FE extends vs{constructor(n,o){super();Z(this,"index");Z(this,"total");this.index=n,this.total=o}toDOM(){const n=document.createElement("span");n.setAttribute("aria-hidden","true"),n.className="cm-codeium-cycle";const o=n.appendChild(document.createElement("span"));o.className="cm-codeium-cycle-explanation",o.innerText=`${this.index+1}/${this.total}`;const r=n.appendChild(document.createElement("button"));return r.className="cm-codeium-cycle-key",r.innerText="\u2192 (Ctrl ])",r.dataset.action="codeium-cycle",n}ignoreEvent(){return!1}}const rl=vr.define({combine:t=>Ac(t,{language:Po.TYPESCRIPT,timeout:150,widgetClass:FE,alwaysOn:!0},{})}),g0=vr.define({combine:t=>Ac(t,{override:()=>[]},{})}),zE=ot.mark({class:"cm-ghostText"}),ar=vn.define({create:t=>null,update(t,e){var o;const n=e.state.facet(rl);for(const r of e.effects){if(r.is(qd)){const{changeSpecs:s,index:i}=r.value,a=s[i].map(c=>zE.range(c.absoluteStartPos,c.absoluteEndPos)),l=(o=a.at(-1))==null?void 0:o.to;return{index:i,decorations:ot.set([...a,...l!==void 0&&s.length>1&&n.widgetClass?[ot.widget({widget:new n.widgetClass(i,s.length),side:1}).range(l)]:[]]),changeSpecs:s,reverseChangeSet:r.value.reverseChangeSet}}if(r.is(Gd)||r.is(Yd))return null}return t&&{...t,decorations:t.decorations.map(e.changes),reverseChangeSet:t.reverseChangeSet.map(e.changes)}},provide:t=>We.decorations.from(t,e=>(e==null?void 0:e.decorations)||ot.none)}),Or=Fm.define(),sl=Fm.define();var ft;function ou(t){const e=ft[t];return typeof e!="string"?t.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,n=>"_"+n.toLowerCase())}let il;(function(t){t[t.Canceled=1]="Canceled",t[t.Unknown=2]="Unknown",t[t.InvalidArgument=3]="InvalidArgument",t[t.DeadlineExceeded=4]="DeadlineExceeded",t[t.NotFound=5]="NotFound",t[t.AlreadyExists=6]="AlreadyExists",t[t.PermissionDenied=7]="PermissionDenied",t[t.ResourceExhausted=8]="ResourceExhausted",t[t.FailedPrecondition=9]="FailedPrecondition",t[t.Aborted=10]="Aborted",t[t.OutOfRange=11]="OutOfRange",t[t.Unimplemented=12]="Unimplemented",t[t.Internal=13]="Internal",t[t.Unavailable=14]="Unavailable",t[t.DataLoss=15]="DataLoss",t[t.Unauthenticated=16]="Unauthenticated"})(ft||(ft={}));class Nt extends Error{constructor(e,n=ft.Unknown,o,r,s){super(function(i,a){return i.length?`[${ou(a)}] ${i}`:`[${ou(a)}]`}(e,n)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=n,this.metadata=new Headers(o??{}),this.details=r??[],this.cause=s}static from(e,n=ft.Unknown){return e instanceof Nt?e:e instanceof Error?e.name=="AbortError"?new Nt(e.message,ft.Canceled):new Nt(e.message,n,void 0,void 0,e):new Nt(String(e),n,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error&&(Object.getPrototypeOf(e)===Nt.prototype||e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e)}findDetails(e){const n="typeName"in e?{findMessage:r=>r===e.typeName?e:void 0}:e,o=[];for(const r of this.details){if("getType"in r){n.findMessage(r.getType().typeName)&&o.push(r);continue}const s=n.findMessage(r.type);if(s)try{o.push(s.fromBinary(r.value))}catch{}}return o}}var BE=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(r){e[r]=t[r]&&function(s){return new Promise(function(i,a){(function(l,c,d,h){Promise.resolve(h).then(function(f){l({value:f,done:d})},c)})(i,a,(s=t[r](s)).done,s.value)})}}},Qs=function(t){return this instanceof Qs?(this.v=t,this):new Qs(t)},UE=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},i("next"),i("throw"),i("return",function(h){return function(f){return Promise.resolve(f).then(h,c)}}),o[Symbol.asyncIterator]=function(){return this},o;function i(h,f){r[h]&&(o[h]=function(m){return new Promise(function(g,x){s.push([h,m,g,x])>1||a(h,m)})},f&&(o[h]=f(o[h])))}function a(h,f){try{(m=r[h](f)).value instanceof Qs?Promise.resolve(m.value.v).then(l,c):d(s[0][2],m)}catch(g){d(s[0][3],g)}var m}function l(h){a("next",h)}function c(h){a("throw",h)}function d(h,f){h(f),s.shift(),s.length&&a(s[0][0],s[0][1])}},$E=function(t){var e,n;return e={},o("next"),o("throw",function(r){throw r}),o("return"),e[Symbol.iterator]=function(){return this},e;function o(r,s){e[r]=t[r]?function(i){return(n=!n)?{value:Qs(t[r](i)),done:!1}:s?s(i):i}:s}},x0=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(r){e[r]=t[r]&&function(s){return new Promise(function(i,a){(function(l,c,d,h){Promise.resolve(h).then(function(f){l({value:f,done:d})},c)})(i,a,(s=t[r](s)).done,s.value)})}}},Dr=function(t){return this instanceof Dr?(this.v=t,this):new Dr(t)},VE=function(t){var e,n;return e={},o("next"),o("throw",function(r){throw r}),o("return"),e[Symbol.iterator]=function(){return this},e;function o(r,s){e[r]=t[r]?function(i){return(n=!n)?{value:Dr(t[r](i)),done:!1}:s?s(i):i}:s}},HE=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},i("next"),i("throw"),i("return",function(h){return function(f){return Promise.resolve(f).then(h,c)}}),o[Symbol.asyncIterator]=function(){return this},o;function i(h,f){r[h]&&(o[h]=function(m){return new Promise(function(g,x){s.push([h,m,g,x])>1||a(h,m)})},f&&(o[h]=f(o[h])))}function a(h,f){try{(m=r[h](f)).value instanceof Dr?Promise.resolve(m.value.v).then(l,c):d(s[0][2],m)}catch(g){d(s[0][3],g)}var m}function l(h){a("next",h)}function c(h){a("throw",h)}function d(h,f){h(f),s.shift(),s.length&&a(s[0][0],s[0][1])}};function WE(t,e){return function(n,o){const r={};for(const[s,i]of Object.entries(n.methods)){const a=o(Object.assign(Object.assign({},i),{localName:s,service:n}));a!=null&&(r[s]=a)}return r}(t,n=>{switch(n.kind){case fn.Unary:return function(o,r,s){return async function(i,a){var l,c;const d=await o.unary(r,s,a==null?void 0:a.signal,a==null?void 0:a.timeoutMs,a==null?void 0:a.headers,i,a==null?void 0:a.contextValues);return(l=a==null?void 0:a.onHeader)===null||l===void 0||l.call(a,d.header),(c=a==null?void 0:a.onTrailer)===null||c===void 0||c.call(a,d.trailer),d.message}}(e,t,n);case fn.ServerStreaming:return function(o,r,s){return function(i,a){return b0(o.stream(r,s,a==null?void 0:a.signal,a==null?void 0:a.timeoutMs,a==null?void 0:a.headers,function(l){return UE(this,arguments,function*(){yield Qs(yield*$E(BE(l)))})}([i]),a==null?void 0:a.contextValues),a)}}(e,t,n);case fn.ClientStreaming:return function(o,r,s){return async function(i,a){var l,c,d,h,f,m;const g=await o.stream(r,s,a==null?void 0:a.signal,a==null?void 0:a.timeoutMs,a==null?void 0:a.headers,i,a==null?void 0:a.contextValues);let x;(f=a==null?void 0:a.onHeader)===null||f===void 0||f.call(a,g.header);let p=0;try{for(var b,y=!0,v=x0(g.message);!(l=(b=await v.next()).done);y=!0)h=b.value,y=!1,x=h,p++}catch(w){c={error:w}}finally{try{y||l||!(d=v.return)||await d.call(v)}finally{if(c)throw c.error}}if(!x)throw new Nt("protocol error: missing response message",ft.Unimplemented);if(p>1)throw new Nt("protocol error: received extra messages for client streaming method",ft.Unimplemented);return(m=a==null?void 0:a.onTrailer)===null||m===void 0||m.call(a,g.trailer),x}}(e,t,n);case fn.BiDiStreaming:return function(o,r,s){return function(i,a){return b0(o.stream(r,s,a==null?void 0:a.signal,a==null?void 0:a.timeoutMs,a==null?void 0:a.headers,i,a==null?void 0:a.contextValues),a)}}(e,t,n);default:return null}})}function b0(t,e){const n=function(){return HE(this,arguments,function*(){var o,r;const s=yield Dr(t);(o=e==null?void 0:e.onHeader)===null||o===void 0||o.call(e,s.header),yield Dr(yield*VE(x0(s.message))),(r=e==null?void 0:e.onTrailer)===null||r===void 0||r.call(e,s.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function y0(t){if(!t.aborted)return;if(t.reason!==void 0)return t.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function v0(){return{get(t){return t.id in this?this[t.id]:t.defaultValue},set(t,e){return this[t.id]=e,this},delete(t){return delete this[t.id],this}}}function w0(t,e,n){const o=typeof e=="string"?e:e.typeName,r=typeof n=="string"?n:n.name;return t.toString().replace(/\/?$/,`/${o}/${r}`)}function k0(t,e){return e instanceof t?e:new t(e)}function qE(t,e){function n(o){return o.done===!0?o:{done:o.done,value:k0(t,o.value)}}return{[Symbol.asyncIterator](){const o=e[Symbol.asyncIterator](),r={next:()=>o.next().then(n)};return o.throw!==void 0&&(r.throw=s=>o.throw(s).then(n)),o.return!==void 0&&(r.return=s=>o.return(s).then(n)),r}}}function C0(t,e){var n;return(n=e==null?void 0:e.concat().reverse().reduce((o,r)=>r(o),t))!==null&&n!==void 0?n:t}function j0(t){var e;const n=Object.assign({},t);return(e=n.ignoreUnknownFields)!==null&&e!==void 0||(n.ignoreUnknownFields=!0),n}function S0(t,e,n,o){const r=e?N0(t.I,o):E0(t.I,n);return{parse:(e?N0(t.O,o):E0(t.O,n)).parse,serialize:r.serialize}}function N0(t,e){return{parse(n){try{return t.fromBinary(n,e)}catch(o){const r=o instanceof Error?o.message:String(o);throw new Nt(`parse binary: ${r}`,ft.Internal)}},serialize(n){try{return n.toBinary(e)}catch(o){const r=o instanceof Error?o.message:String(o);throw new Nt(`serialize binary: ${r}`,ft.Internal)}}}}function E0(t,e){var n,o;const r=(n=e==null?void 0:e.textEncoder)!==null&&n!==void 0?n:new TextEncoder,s=(o=e==null?void 0:e.textDecoder)!==null&&o!==void 0?o:new TextDecoder,i=j0(e);return{parse(a){try{const l=s.decode(a);return t.fromJsonString(l,i)}catch(l){throw Nt.from(l,ft.InvalidArgument)}},serialize(a){try{const l=a.toJsonString(i);return r.encode(l)}catch(l){throw Nt.from(l,ft.Internal)}}}}const GE=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function _0(t,e,n){var o;if(e&&new Headers(e).forEach((a,l)=>n.metadata.append(l,a)),typeof t!="object"||t==null||Array.isArray(t))throw n;let r=n.code;"code"in t&&typeof t.code=="string"&&(r=(o=function(a){if(!il){il={};for(const l of Object.values(ft))typeof l!="string"&&(il[ou(l)]=l)}return il[a]}(t.code))!==null&&o!==void 0?o:r);const s=t.message;if(s!=null&&typeof s!="string")throw n;const i=new Nt(s??"",r,e);if("details"in t&&Array.isArray(t.details))for(const a of t.details){if(a===null||typeof a!="object"||Array.isArray(a)||typeof a.type!="string"||typeof a.value!="string")throw n;try{i.details.push({type:a.type,value:Ya.dec(a.value),debug:a.debug})}catch{throw n}}return i}function YE(t){const e=new Nt("invalid end stream",ft.Unknown);let n;try{n=JSON.parse(typeof t=="string"?t:new TextDecoder().decode(t))}catch{throw e}if(typeof n!="object"||n==null||Array.isArray(n))throw e;const o=new Headers;if("metadata"in n){if(typeof n.metadata!="object"||n.metadata==null||Array.isArray(n.metadata))throw e;for(const[r,s]of Object.entries(n.metadata)){if(!Array.isArray(s)||s.some(i=>typeof i!="string"))throw e;for(const i of s)o.append(r,i)}}return{metadata:o,error:"error"in n&&n.error!=null?_0(n.error,o,e):void 0}}const al="Content-Type",KE="Content-Length",I0="Content-Encoding",XE="Accept-Encoding",A0="Connect-Protocol-Version";function T0(t){const e=new Headers,n=new Headers;return t.forEach((o,r)=>{r.toLowerCase().startsWith("trailer-")?n.append(r.substring(8),o):e.append(r,o)}),[e,n]}function M0(t,e,n,o,r){const s=new Headers(o??{});return n!==void 0&&s.set("Connect-Timeout-Ms",`${n}`),s.set(al,t==fn.Unary?e?"application/proto":"application/json":e?"application/connect+proto":"application/connect+json"),s.set(A0,"1"),s}function O0(t,e,n,o){const r=o.get(al),s=function(l){const c=l==null?void 0:l.match(GE);if(c)return{stream:!!c[1],binary:!!c[3]}}(r);if(n!==200){const l=new Nt(`HTTP ${n}`,function(c){switch(c){case 400:return ft.Internal;case 401:return ft.Unauthenticated;case 403:return ft.PermissionDenied;case 404:return ft.Unimplemented;case 429:case 502:case 503:case 504:return ft.Unavailable;default:return ft.Unknown}}(n),o);if(t==fn.Unary&&s&&!s.binary)return{isUnaryError:!0,unaryError:l};throw l}const i=e,a=t!==fn.Unary;if((s==null?void 0:s.binary)!==i||s.stream!==a)throw new Nt(`unsupported content type ${r}`,s===void 0?ft.Unknown:ft.Internal,o);return{isUnaryError:!1}}const JE="application/";function ZE(t,e,n){let o="?connect=v1";const r=t.header.get(al);(r==null?void 0:r.indexOf(JE))===0&&(o+="&encoding="+encodeURIComponent(r.slice(12)));const s=t.header.get(I0);s!==null&&s!=="identity"&&(o+="&compression="+encodeURIComponent(s),n=!0),n&&(o+="&base64=1"),o+="&message="+function(l,c){return c?Ya.enc(l).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent(new TextDecoder().decode(l))}(e,n);const i=t.url+o,a=new Headers(t.header);return[A0,al,KE,I0,XE].forEach(l=>a.delete(l)),Object.assign(Object.assign({},t),{init:Object.assign(Object.assign({},t.init),{method:"GET"}),url:i,header:a})}function D0(t){const{signal:e,cleanup:n}=function(r){const s=new AbortController,i=()=>{s.abort(new Nt("the operation timed out",ft.DeadlineExceeded))};let a;return r!==void 0&&(r<=0?i():a=setTimeout(i,r)),{signal:s.signal,cleanup:()=>clearTimeout(a)}}(t.timeoutMs),o=function(...r){const s=new AbortController,i=r.filter(l=>l!==void 0).concat(s.signal);for(const l of i){if(l.aborted){a.apply(l);break}l.addEventListener("abort",a)}function a(){s.signal.aborted||s.abort(y0(this));for(const l of i)l.removeEventListener("abort",a)}return s}(t.signal,e);return[o.signal,function(r){const s=Nt.from(e.aborted?y0(e):r);return o.abort(s),n(),Promise.reject(s)},function(){n(),o.abort()}]}var ei,ru,ti;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.INACTIVE=1]="INACTIVE",t[t.PROCESSING=2]="PROCESSING",t[t.SUCCESS=3]="SUCCESS",t[t.WARNING=4]="WARNING",t[t.ERROR=5]="ERROR"})(ei||(ei={})),be.util.setEnumType(ei,"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"}]),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SINGLE=1]="SINGLE",t[t.MULTI=2]="MULTI"}(ru||(ru={})),be.util.setEnumType(ru,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.INLINE=1]="INLINE",t[t.BLOCK=2]="BLOCK",t[t.INLINE_MASK=3]="INLINE_MASK"}(ti||(ti={})),be.util.setEnumType(ti,"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 co=class co extends St{constructor(n){super();Z(this,"threshold",0);be.util.initPartial(n,this)}static fromBinary(n,o){return new co().fromBinary(n,o)}static fromJson(n,o){return new co().fromJson(n,o)}static fromJsonString(n,o){return new co().fromJsonString(n,o)}static equals(n,o){return be.util.equals(co,n,o)}};Z(co,"runtime",be),Z(co,"typeName","exa.language_server_pb.MultilineConfig"),Z(co,"fields",be.util.newFieldList(()=>[{no:1,name:"threshold",kind:"scalar",T:2}]));let su=co;const uo=class uo extends St{constructor(n){super();Z(this,"metadata");Z(this,"document");Z(this,"editorOptions");Z(this,"otherDocuments",[]);Z(this,"experimentConfig");Z(this,"modelName","");Z(this,"multilineConfig");be.util.initPartial(n,this)}static fromBinary(n,o){return new uo().fromBinary(n,o)}static fromJson(n,o){return new uo().fromJson(n,o)}static fromJsonString(n,o){return new uo().fromJsonString(n,o)}static equals(n,o){return be.util.equals(uo,n,o)}};Z(uo,"runtime",be),Z(uo,"typeName","exa.language_server_pb.GetCompletionsRequest"),Z(uo,"fields",be.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:ol},{no:2,name:"document",kind:"message",T:ll},{no:3,name:"editor_options",kind:"message",T:nu},{no:5,name:"other_documents",kind:"message",T:ll,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:hu},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:su}]));let iu=uo;const ho=class ho extends St{constructor(n){super();Z(this,"state");Z(this,"completionItems",[]);be.util.initPartial(n,this)}static fromBinary(n,o){return new ho().fromBinary(n,o)}static fromJson(n,o){return new ho().fromJson(n,o)}static fromJsonString(n,o){return new ho().fromJsonString(n,o)}static equals(n,o){return be.util.equals(ho,n,o)}};Z(ho,"runtime",be),Z(ho,"typeName","exa.language_server_pb.GetCompletionsResponse"),Z(ho,"fields",be.util.newFieldList(()=>[{no:1,name:"state",kind:"message",T:fu},{no:2,name:"completion_items",kind:"message",T:xu,repeated:!0}]));let au=ho;const fo=class fo extends St{constructor(n){super();Z(this,"metadata");Z(this,"completionId","");be.util.initPartial(n,this)}static fromBinary(n,o){return new fo().fromBinary(n,o)}static fromJson(n,o){return new fo().fromJson(n,o)}static fromJsonString(n,o){return new fo().fromJsonString(n,o)}static equals(n,o){return be.util.equals(fo,n,o)}};Z(fo,"runtime",be),Z(fo,"typeName","exa.language_server_pb.AcceptCompletionRequest"),Z(fo,"fields",be.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:ol},{no:2,name:"completion_id",kind:"scalar",T:9}]));let lu=fo;const mo=class mo extends St{constructor(e){super(),be.util.initPartial(e,this)}static fromBinary(e,n){return new mo().fromBinary(e,n)}static fromJson(e,n){return new mo().fromJson(e,n)}static fromJsonString(e,n){return new mo().fromJsonString(e,n)}static equals(e,n){return be.util.equals(mo,e,n)}};Z(mo,"runtime",be),Z(mo,"typeName","exa.language_server_pb.AcceptCompletionResponse"),Z(mo,"fields",be.util.newFieldList(()=>[]));let cu=mo;const po=class po extends St{constructor(e){super(),be.util.initPartial(e,this)}static fromBinary(e,n){return new po().fromBinary(e,n)}static fromJson(e,n){return new po().fromJson(e,n)}static fromJsonString(e,n){return new po().fromJsonString(e,n)}static equals(e,n){return be.util.equals(po,e,n)}};Z(po,"runtime",be),Z(po,"typeName","exa.language_server_pb.GetAuthTokenRequest"),Z(po,"fields",be.util.newFieldList(()=>[]));let du=po;const go=class go extends St{constructor(n){super();Z(this,"authToken","");Z(this,"uuid","");be.util.initPartial(n,this)}static fromBinary(n,o){return new go().fromBinary(n,o)}static fromJson(n,o){return new go().fromJson(n,o)}static fromJsonString(n,o){return new go().fromJsonString(n,o)}static equals(n,o){return be.util.equals(go,n,o)}};Z(go,"runtime",be),Z(go,"typeName","exa.language_server_pb.GetAuthTokenResponse"),Z(go,"fields",be.util.newFieldList(()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}]));let uu=go;const xo=class xo extends St{constructor(n){super();Z(this,"row",pt.zero);Z(this,"col",pt.zero);be.util.initPartial(n,this)}static fromBinary(n,o){return new xo().fromBinary(n,o)}static fromJson(n,o){return new xo().fromJson(n,o)}static fromJsonString(n,o){return new xo().fromJsonString(n,o)}static equals(n,o){return be.util.equals(xo,n,o)}};Z(xo,"runtime",be),Z(xo,"typeName","exa.language_server_pb.DocumentPosition"),Z(xo,"fields",be.util.newFieldList(()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}]));let ni=xo;const bo=class bo extends St{constructor(n){super();Z(this,"absolutePath","");Z(this,"relativePath","");Z(this,"text","");Z(this,"editorLanguage","");Z(this,"language",Po.UNSPECIFIED);Z(this,"cursorOffset",pt.zero);Z(this,"cursorPosition");Z(this,"lineEnding","");be.util.initPartial(n,this)}static fromBinary(n,o){return new bo().fromBinary(n,o)}static fromJson(n,o){return new bo().fromJson(n,o)}static fromJsonString(n,o){return new bo().fromJsonString(n,o)}static equals(n,o){return be.util.equals(bo,n,o)}};Z(bo,"runtime",be),Z(bo,"typeName","exa.language_server_pb.Document"),Z(bo,"fields",be.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:be.getEnumType(Po)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:ni},{no:7,name:"line_ending",kind:"scalar",T:9}]));let ll=bo;const yo=class yo extends St{constructor(n){super();Z(this,"forceEnableExperiments",[]);be.util.initPartial(n,this)}static fromBinary(n,o){return new yo().fromBinary(n,o)}static fromJson(n,o){return new yo().fromJson(n,o)}static fromJsonString(n,o){return new yo().fromJsonString(n,o)}static equals(n,o){return be.util.equals(yo,n,o)}};Z(yo,"runtime",be),Z(yo,"typeName","exa.language_server_pb.ExperimentConfig"),Z(yo,"fields",be.util.newFieldList(()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:be.getEnumType(tl),repeated:!0}]));let hu=yo;const vo=class vo extends St{constructor(n){super();Z(this,"state",ei.UNSPECIFIED);Z(this,"message","");be.util.initPartial(n,this)}static fromBinary(n,o){return new vo().fromBinary(n,o)}static fromJson(n,o){return new vo().fromJson(n,o)}static fromJsonString(n,o){return new vo().fromJsonString(n,o)}static equals(n,o){return be.util.equals(vo,n,o)}};Z(vo,"runtime",be),Z(vo,"typeName","exa.language_server_pb.State"),Z(vo,"fields",be.util.newFieldList(()=>[{no:1,name:"state",kind:"enum",T:be.getEnumType(ei)},{no:2,name:"message",kind:"scalar",T:9}]));let fu=vo;const wo=class wo extends St{constructor(n){super();Z(this,"startOffset",pt.zero);Z(this,"endOffset",pt.zero);Z(this,"startPosition");Z(this,"endPosition");be.util.initPartial(n,this)}static fromBinary(n,o){return new wo().fromBinary(n,o)}static fromJson(n,o){return new wo().fromJson(n,o)}static fromJsonString(n,o){return new wo().fromJsonString(n,o)}static equals(n,o){return be.util.equals(wo,n,o)}};Z(wo,"runtime",be),Z(wo,"typeName","exa.language_server_pb.Range"),Z(wo,"fields",be.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:ni},{no:4,name:"end_position",kind:"message",T:ni}]));let mu=wo;const ko=class ko extends St{constructor(n){super();Z(this,"text","");Z(this,"deltaCursorOffset",pt.zero);be.util.initPartial(n,this)}static fromBinary(n,o){return new ko().fromBinary(n,o)}static fromJson(n,o){return new ko().fromJson(n,o)}static fromJsonString(n,o){return new ko().fromJsonString(n,o)}static equals(n,o){return be.util.equals(ko,n,o)}};Z(ko,"runtime",be),Z(ko,"typeName","exa.language_server_pb.Suffix"),Z(ko,"fields",be.util.newFieldList(()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}]));let pu=ko;const Co=class Co extends St{constructor(n){super();Z(this,"text","");Z(this,"offset",pt.zero);Z(this,"type",ti.UNSPECIFIED);Z(this,"prefix","");Z(this,"line",pt.zero);be.util.initPartial(n,this)}static fromBinary(n,o){return new Co().fromBinary(n,o)}static fromJson(n,o){return new Co().fromJson(n,o)}static fromJsonString(n,o){return new Co().fromJsonString(n,o)}static equals(n,o){return be.util.equals(Co,n,o)}};Z(Co,"runtime",be),Z(Co,"typeName","exa.language_server_pb.CompletionPart"),Z(Co,"fields",be.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:be.getEnumType(ti)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}]));let gu=Co;const jo=class jo extends St{constructor(n){super();Z(this,"completion");Z(this,"suffix");Z(this,"range");Z(this,"source",Zs.UNSPECIFIED);Z(this,"completionParts",[]);be.util.initPartial(n,this)}static fromBinary(n,o){return new jo().fromBinary(n,o)}static fromJson(n,o){return new jo().fromJson(n,o)}static fromJsonString(n,o){return new jo().fromJsonString(n,o)}static equals(n,o){return be.util.equals(jo,n,o)}};Z(jo,"runtime",be),Z(jo,"typeName","exa.language_server_pb.CompletionItem"),Z(jo,"fields",be.util.newFieldList(()=>[{no:1,name:"completion",kind:"message",T:tu},{no:5,name:"suffix",kind:"message",T:pu},{no:2,name:"range",kind:"message",T:mu},{no:3,name:"source",kind:"enum",T:be.getEnumType(Zs)},{no:8,name:"completion_parts",kind:"message",T:gu,repeated:!0}]));let xu=jo;const QE={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:iu,O:au,kind:fn.Unary},acceptCompletion:{name:"AcceptCompletion",I:lu,O:cu,kind:fn.Unary},getAuthToken:{name:"GetAuthToken",I:du,O:uu,kind:fn.Unary}}};var oi=function(t){return this instanceof oi?(this.v=t,this):new oi(t)},e5=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},i("next"),i("throw"),i("return",function(h){return function(f){return Promise.resolve(f).then(h,c)}}),o[Symbol.asyncIterator]=function(){return this},o;function i(h,f){r[h]&&(o[h]=function(m){return new Promise(function(g,x){s.push([h,m,g,x])>1||a(h,m)})},f&&(o[h]=f(o[h])))}function a(h,f){try{(m=r[h](f)).value instanceof oi?Promise.resolve(m.value.v).then(l,c):d(s[0][2],m)}catch(g){d(s[0][3],g)}var m}function l(h){a("next",h)}function c(h){a("throw",h)}function d(h,f){h(f),s.shift(),s.length&&a(s[0][0],s[0][1])}};const t5=function(t){var e;(function(){try{new Headers}catch{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=(e=t.useBinaryFormat)!==null&&e!==void 0&&e;return{async unary(o,r,s,i,a,l,c){var d;const{serialize:h,parse:f}=S0(r,n,t.jsonOptions,t.binaryOptions);return i=i===void 0?t.defaultTimeoutMs:i<=0?void 0:i,await function(m){const g=C0(m.next,m.interceptors),[x,p,b]=D0(m);return g(Object.assign(Object.assign({},m.req),{message:k0(m.req.method.I,m.req.message),signal:x})).then(y=>(b(),y),p)}({interceptors:t.interceptors,signal:s,timeoutMs:i,req:{stream:!1,service:o,method:r,url:w0(t.baseUrl,o,r),init:{method:"POST",credentials:(d=t.credentials)!==null&&d!==void 0?d:"same-origin",redirect:"error",mode:"cors"},header:M0(r.kind,n,i,a),contextValues:c??v0(),message:l},next:async m=>{var g;let x=null;t.useHttpGet===!0&&r.idempotency===eu.NoSideEffects?m=ZE(m,h(m.message),n):x=h(m.message);const p=(g=t.fetch)!==null&&g!==void 0?g:globalThis.fetch,b=await p(m.url,Object.assign(Object.assign({},m.init),{headers:m.header,signal:m.signal,body:x})),{isUnaryError:y,unaryError:v}=O0(r.kind,n,b.status,b.headers);if(y)throw _0(await b.json(),function(...C){const N=new Headers;for(const j of C)j.forEach((E,T)=>{N.append(T,E)});return N}(...T0(b.headers)),v);const[w,S]=T0(b.headers);return{stream:!1,service:o,method:r,header:w,message:n?f(new Uint8Array(await b.arrayBuffer())):r.O.fromJson(await b.json(),j0(t.jsonOptions)),trailer:S}}})},async stream(o,r,s,i,a,l,c){var d;const{serialize:h,parse:f}=S0(r,n,t.jsonOptions,t.binaryOptions);function m(x,p,b,y){return e5(this,arguments,function*(){const v=function(S){let C,N=new Uint8Array(0);function j(E){const T=new Uint8Array(N.length+E.length);T.set(N),T.set(E,N.length),N=T}return new ReadableStream({start(){C=S.getReader()},async pull(E){let T;for(;;){if(T===void 0&&N.byteLength>=5){let L=0;for(let D=1;D<5;D++)L=(L<<8)+N[D];T={flags:N[0],length:L}}if(T!==void 0&&N.byteLength>=T.length+5)break;const O=await C.read();if(O.done)break;j(O.value)}if(T===void 0)return N.byteLength==0?void E.close():void E.error(new Nt("premature end of stream",ft.DataLoss));const I=N.subarray(5,5+T.length);N=N.subarray(5+T.length),E.enqueue({flags:T.flags,data:I})}})}(x).getReader();let w=!1;for(;;){const S=yield oi(v.read());if(S.done)break;const{flags:C,data:N}=S.value;if(!(1&~C))throw new Nt("protocol error: received unsupported compressed output",ft.Internal);if(!(2&~C)){w=!0;const j=YE(N);if(j.error){const E=j.error;throw b.forEach((T,I)=>{E.metadata.append(I,T)}),E}j.metadata.forEach((E,T)=>p.set(T,E));continue}yield yield oi(f(N))}if("throwIfAborted"in y&&y.throwIfAborted(),!w)throw"missing EndStreamResponse"})}async function g(x){if(r.kind!=fn.ServerStreaming)throw"The fetch API does not support streaming request bodies";const p=await x[Symbol.asyncIterator]().next();if(p.done==1)throw"missing request message";return function(b,y){const v=new Uint8Array(y.length+5);v.set(y,5);const w=new DataView(v.buffer,v.byteOffset,v.byteLength);return w.setUint8(0,b),w.setUint32(1,y.length),v}(0,h(p.value))}return i=i===void 0?t.defaultTimeoutMs:i<=0?void 0:i,await function(x){const p=C0(x.next,x.interceptors),[b,y,v]=D0(x),w=Object.assign(Object.assign({},x.req),{message:qE(x.req.method.I,x.req.message),signal:b});let S=!1;return b.addEventListener("abort",function(){var C,N;const j=x.req.message[Symbol.asyncIterator]();S||(C=j.throw)===null||C===void 0||C.call(j,this.reason).catch(()=>{}),(N=j.return)===null||N===void 0||N.call(j).catch(()=>{})}),p(w).then(C=>Object.assign(Object.assign({},C),{message:{[Symbol.asyncIterator](){const N=C.message[Symbol.asyncIterator]();return{next:()=>N.next().then(j=>(j.done==1&&(S=!0,v()),j),y)}}}}),y)}({interceptors:t.interceptors,timeoutMs:i,signal:s,req:{stream:!0,service:o,method:r,url:w0(t.baseUrl,o,r),init:{method:"POST",credentials:(d=t.credentials)!==null&&d!==void 0?d:"same-origin",redirect:"error",mode:"cors"},header:M0(r.kind,n,i,a),contextValues:c??v0(),message:l},next:async x=>{var p;const b=(p=t.fetch)!==null&&p!==void 0?p:globalThis.fetch,y=await b(x.url,Object.assign(Object.assign({},x.init),{headers:x.header,signal:x.signal,body:await g(x.message)}));if(O0(r.kind,n,y.status,y.headers),y.body===null)throw"missing response body";const v=new Headers;return Object.assign(Object.assign({},x),{header:y.headers,trailer:v,message:m(y.body,v,y.headers,x.signal)})}})}}}({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}),n5=function(t,e){return WE(t,e)}(QE,t5);let cl;try{cl=crypto.randomUUID()}catch{cl="10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^(crypto.getRandomValues(new Uint8Array(1))[0]??0)&15>>+t/4).toString(16))}async function o5(t,e){const n=t.state.facet(rl),{override:o}=t.state.facet(g0),r=await o(),s=t.state,i=s.selection.main.head,a=s.doc.toString();try{const l=await async function({text:g,cursorOffset:x,config:p,otherDocuments:b}){return await n5.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:p.apiKey,sessionId:cl,authSource:p.authSource},document:{text:g,cursorOffset:BigInt(x),language:p.language,editorLanguage:"typescript",lineEnding:`
105
+ `},editorOptions:{tabSize:2n,insertSpaces:!0},otherDocuments:b,multilineConfig:void 0},{headers:{Authorization:`Basic ${p.apiKey}-${cl}`}})}({text:a,cursorOffset:i,config:n,otherDocuments:r});if(!l||l.completionItems.length===0||e!==void 0&&i!==e||ws(t.state)==="active"||!t.hasFocus)return;const c=l.completionItems.map(g=>{let x=0;return g.completionParts.filter(p=>p.type!==3).map(p=>{const b=Number(p.offset),y=p.type===2?`
106
+ ${p.text}`:p.text,v={absoluteStartPos:x+b,absoluteEndPos:x+b+y.length,from:b,to:b,insert:y};return x+=y.length,v})}),d=0,h=c.at(d);if(!h)return;const f=na.of(h,s.doc.length),m=f.invert(s.doc);t.dispatch({changes:f,effects:qd.of({index:d,reverseChangeSet:m,changeSpecs:c}),annotations:[sl.of(null),Or.of(null),oa.addToHistory.of(!1)]})}catch(l){console.warn("copilot completion failed",l),await new Promise(c=>setTimeout(c,300))}}function r5(){let t=null,e=0;return We.updateListener.of(n=>{const o=n.view.state.facet(rl);if(!o.alwaysOn||!function(s){return s.docChanged&&!s.transactions.some(i=>i.effects.some(a=>a.is(Gd)||a.is(Yd)))}(n)||(t&&clearTimeout(t),function(s){if(!s.view.hasFocus||s.state.field(ar)||ws(s.state)==="active")return!0;for(const i of s.transactions)if(i.annotation(Or)!==void 0)return!0}(n)))return;const r=n.state.selection.main.head;o.shouldComplete&&!o.shouldComplete(new DD(n.view.state,r,!1))||(t=setTimeout(async()=>{r===e&&await o5(n.view,e)},o.timeout),e=r)})}function R0(t){var r;const e=t.state.field(ar);if(!e)return!1;const n=(r=e.reverseChangeSet)==null?void 0:r.invert(t.state.doc);t.dispatch({changes:e.reverseChangeSet,effects:Gd.of(null),annotations:[sl.of(null),Or.of(null),oa.addToHistory.of(!1)]});let o=0;return n==null||n.iterChangedRanges((s,i,a,l)=>{o=l}),t.dispatch({changes:n,selection:Qn.cursor(o),annotations:[Or.of(null),oa.addToHistory.of(!0)]}),!0}const P0=t=>{const{state:e}=t,n=e.field(ar);if(!n)return!1;const{changeSpecs:o}=n;if(o.length<2)return!1;const r=(n.index+1)%o.length,s=o.at(r);if(!s)return!1;const i=n.reverseChangeSet.apply(e.doc),a=na.of(n.reverseChangeSet,e.doc.length).compose(na.of(s,i.length)),l=na.of(s,i.length).invert(i);return t.dispatch({changes:a,effects:qd.of({index:r,reverseChangeSet:l,changeSpecs:o}),annotations:[sl.of(null),Or.of(null),oa.addToHistory.of(!1)]}),!0};function bu(t){const e=t.state.field(ar);return!!e&&(t.dispatch({changes:e.reverseChangeSet,effects:Yd.of(null),annotations:[sl.of(null),Or.of(null),oa.addToHistory.of(!1)]}),!1)}function s5(){return We.domEventHandlers({keydown:(t,e)=>(t.key!=="]"||!t.ctrlKey)&&t.key!=="Shift"&&t.key!=="Control"&&t.key!=="Alt"&&t.key!=="Meta"&&function(n,o){return!!n.state.field(ar)&&(o==="Tab"?R0(n):bu(n))}(e,t.key),mouseup(t,e){const n=t.target;return n.nodeName==="BUTTON"&&n.dataset.action==="codeium-cycle"?(P0(e),t.stopPropagation(),t.preventDefault(),!0):function(o){var a,l;let r=!1;const s=(a=o.state.selection.asSingle().ranges.at(0))==null?void 0:a.head,i=o.state.field(ar);return!(s===void 0||!i)&&((l=i.decorations)==null||l.between(s,s,()=>{r=!0}),r)}(e)?R0(e):bu(e)}})}const i5=new zm,yu=mt.get("@github/copilot-language-server"),L0={delay:500,includeKeymap:!0,events:{shouldShowSuggestion:t=>t.hasFocus,beforeSuggestionFetch:t=>t.hasFocus}},a5=t=>{const e=[];return t.copilot==="codeium"&&t.codeium_api_key&&e.push(function(n){return[rl.of(n),ar,To.highest(Mn.of([{key:"Ctrl-]",run:P0}])),To.highest(We.updateListener.of(o=>{o.focusChanged&&bu(o.view)})),To.high(s5()),r5()]}({apiKey:t.codeium_api_key,language:Po.PYTHON}),g0.of({override:async()=>[{text:Mc(""),language:Po.PYTHON,editorLanguage:"python"}]})),t.copilot==="github"&&e.push(P1({...L0,fetchFn:async n=>{if(!pF()||n.doc.length===0)return"";await new Promise(i=>setTimeout(i,20));const o=n.doc.toString(),r=function(i,a){const l=i.doc.toString(),c=a.split(`
107
+ `).length-l.split(`
108
+ `).length,d=function(h,f){const m=h.lineAt(f);return{line:m.number-1,character:f-m.from}}(i.doc,i.selection.main.head);return d.line+=c,{textDocument:{uri:`file://${gF}`,version:"replace_me"},position:d,context:{triggerKind:PD.InlineCompletionTriggerKind.Automatic},formattingOptions:{tabSize:i.tabSize,insertSpaces:!0}}}(n,Mc(o));return function(i,a,l){if(!i)return yu.debug("No response from copilot"),"";const c=Array.isArray(i)?i[0]:i.items[0];if(!c)return yu.debug("No response from copilot"),"";const{insertText:d,range:h}=c,f=String(d);if(!h)return yu.error("No range from copilot"),f;const m=h.start.character-a.character,g=m<0?f.slice(-m):f,x=l.doc.sliceString(l.selection.main.head,l.doc.length);for(let p=0;p<g.length;p++){const b=g.slice(p);if(x.startsWith(b))return g.slice(0,p)}return g}(await hj().getCompletion(r),r.position,n)}})),t.copilot==="custom"&&e.push(P1({...L0,fetchFn:async n=>{if(n.doc.length===0)return"";const o=n.doc.sliceString(0,n.selection.main.head),r=n.doc.sliceString(n.selection.main.head,n.doc.length);if(o.length===0)return"";const s=n.field(Oc).type;let i=await RD.post("/ai/inline_completion",{prefix:o,suffix:r,language:s});return o&&i.startsWith(o)&&(i=i.slice(o.length)),r&&i.endsWith(r)&&(i=i.slice(0,-r.length)),i}})),[...e,To.highest(Mn.of([{key:"Escape",run:n=>{const o=R1(n);return!ta(n)&&o}}])),i5.of(mF())]};function l5(t){return[Mn.of([{key:"Escape",preventDefault:!1,run:e4},{key:t.getHotkey("cell.selectNextOccurrence").key,preventDefault:!0,run:FD},{key:t.getHotkey("cell.findAndReplace").key,preventDefault:!0,run:zg}]),LD(),i4,Aa,a4]}const c5=ot.mark({class:"underline"}),F0=Tt.define(),z0=Tt.define(),B0=Tt.define(),d5=vn.define({create:()=>ot.none,update(t,e){let n=t.map(e.changes);for(const o of e.effects)o.is(F0)?n=t.update({add:[c5.range(o.value.from,o.value.to)]}):o.is(z0)?n=t.update({add:[zD.range(o.value.from,o.value.to)]}):o.is(B0)&&(n=ot.none);return n},provide:t=>We.decorations.from(t)});class u5{constructor(e,n){this.view=void 0,this.commandClickMode=void 0,this.hoveredRange=void 0,this.onClick=void 0,this.keydown=o=>{o.key!=="Meta"&&o.key!=="Control"||(this.commandClickMode=!0,this.view.dom.addEventListener("mousemove",this.mousemove),this.view.dom.addEventListener("click",this.click))},this.keyup=o=>{o.key!=="Meta"&&o.key!=="Control"||this.exitCommandClickMode()},this.windowBlur=()=>{this.commandClickMode&&this.exitCommandClickMode()},this.mousemove=o=>{if(!o.metaKey&&!o.ctrlKey)return void this.exitCommandClickMode();if(!this.commandClickMode)return void this.clearUnderline();const r=this.view.posAtCoords({x:o.clientX,y:o.clientY});if(r==null)return void this.clearUnderline();const s=this.view.state.field(BD,!1),i=s==null?void 0:s.ranges.find(l=>r>=l.from&&r<=l.to);if(i){const{from:l,to:c}=i;return this.hoveredRange&&this.hoveredRange.from===l&&this.hoveredRange.to===c?void 0:(this.clearUnderline(),this.hoveredRange={from:l,to:c,position:r},void this.view.dispatch({effects:z0.of(this.hoveredRange)}))}const a=UD(this.view.state).cursorAt(r);if(a.name==="VariableName"){const{from:l,to:c}=a;if(this.hoveredRange&&this.hoveredRange.from===l&&this.hoveredRange.to===c)return;this.clearUnderline(),this.hoveredRange={from:l,to:c,position:r},this.view.dispatch({effects:F0.of(this.hoveredRange)})}else this.clearUnderline()},this.click=o=>{if(this.hoveredRange){const r=this.view.state.doc.sliceString(this.hoveredRange.from,this.hoveredRange.to);o.preventDefault(),o.stopPropagation(),this.onClick(this.view,r),this.view.dispatch({selection:{head:this.hoveredRange.position,anchor:this.hoveredRange.position}})}},this.view=e,this.commandClickMode=!1,this.hoveredRange=null,this.onClick=n,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:B0.of(null)}),this.hoveredRange=null)}}function h5(){return[We.domEventHandlers({paste:(t,e)=>{var r;const n=(r=t.clipboardData)==null?void 0:r.getData("text/plain");if(!(n!=null&&n.includes("@app.cell")))return!1;const o=function(s){if(!s.includes("@app.cell"))return[];const i=[],a=s.split(`
109
+ `);let l=[],c=!1,d=0,h=!1,f=!1,m=0;const g=/\(/g,x=/\)/g,p=new Set(["@"]);function b(v){return(v.match(g)||[]).length-(v.match(x)||[]).length}function y(){if(l.length!==0){for(;l.length>0&&l[l.length-1].trim().startsWith("return");)l.pop();l.some(v=>v.trim()!=="")&&i.push(function(v){const w=v.split(`
110
+ `);if(w.length===0)return"";const S=w.filter(j=>j.trim().length>0);if(S.length===0)return"";const C=/^\s*/,N=Math.min(...S.map(j=>{var E;return((E=j.match(C))==null?void 0:E[0].length)??Number.POSITIVE_INFINITY}));return N===0?v.trim():w.map(j=>j.slice(N)).join(`
111
+ `).trim()}(l.join(`
112
+ `))),l=[]}}for(const v of a){const w=v.trim();(w||c)&&(w.startsWith("@app.cell")?(y(),c=!0,d=1):d>0?(w.startsWith("def")&&w.includes("(")&&!w.includes("):")&&(h=!0,m=b(w)),d--):h?(m+=b(w),m===0&&(h=!1)):c&&(p.has(w[0])||w.startsWith("if __name__")?(y(),c=w.startsWith("@")):w.startsWith("return")?w.includes("(")&&!w.endsWith(")")&&(f=!0,m=b(w)):f?(m+=b(w),m===0&&(f=!1)):l.push(v)))}return y(),i}(n);return o.length===0?!1:(e.state.facet(WD).createManyBelow(o),!0)}})]}const Lt=({variant:t,settings:e,styles:n})=>{const o=We.theme({"&":{backgroundColor:e.background,color:e.foreground},".cm-content":{caretColor:e.caret},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.caret},"&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection":{backgroundColor:e.selection},".cm-activeLine":{backgroundColor:e.lineHighlight},".cm-gutters":{backgroundColor:e.gutterBackground,color:e.gutterForeground},".cm-activeLineGutter":{backgroundColor:e.lineHighlight}},{dark:t==="dark"}),r=qD.define(n);return[o,iC(r)]};Lt({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:F.comment,color:"#404080"},{tag:[F.string,F.regexp],color:"#999999"},{tag:F.number,color:"#7090B0"},{tag:[F.bool,F.null],color:"#8080A0"},{tag:[F.punctuation,F.derefOperator],color:"#805080"},{tag:F.keyword,color:"#60B0FF"},{tag:F.definitionKeyword,color:"#B0FFF0"},{tag:F.moduleKeyword,color:"#60B0FF"},{tag:F.operator,color:"#A0A0FF"},{tag:[F.variableName,F.self],color:"#008080"},{tag:F.operatorKeyword,color:"#A0A0FF"},{tag:F.controlKeyword,color:"#80A0FF"},{tag:F.className,color:"#70E080"},{tag:[F.function(F.propertyName),F.propertyName],color:"#50A0A0"},{tag:F.tagName,color:"#009090"},{tag:F.modifier,color:"#B0FFF0"},{tag:[F.squareBracket,F.attributeName],color:"#D0D0FF"}]}),Lt({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:F.comment,color:"#787b8099"},{tag:F.string,color:"#86b300"},{tag:F.regexp,color:"#4cbf99"},{tag:[F.number,F.bool,F.null],color:"#ffaa33"},{tag:F.variableName,color:"#5c6166"},{tag:[F.definitionKeyword,F.modifier],color:"#fa8d3e"},{tag:[F.keyword,F.special(F.brace)],color:"#fa8d3e"},{tag:F.operator,color:"#ed9366"},{tag:F.separator,color:"#5c6166b3"},{tag:F.punctuation,color:"#5c6166"},{tag:[F.definition(F.propertyName),F.function(F.variableName)],color:"#f2ae49"},{tag:[F.className,F.definition(F.typeName)],color:"#22a4e6"},{tag:[F.tagName,F.typeName,F.self,F.labelName],color:"#55b4d4"},{tag:F.angleBracket,color:"#55b4d480"},{tag:F.attributeName,color:"#f2ae49"}]}),Lt({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:F.comment,color:"#6E6E6E"},{tag:[F.string,F.regexp,F.special(F.brace)],color:"#5C81B3"},{tag:F.number,color:"#C1E1B8"},{tag:F.bool,color:"#53667D"},{tag:[F.definitionKeyword,F.modifier,F.function(F.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[F.keyword,F.moduleKeyword,F.operatorKeyword,F.operator],color:"#697A8E",fontWeight:"bold"},{tag:[F.variableName,F.attributeName],color:"#708E67"},{tag:[F.function(F.variableName),F.definition(F.propertyName),F.derefOperator],color:"#fff"},{tag:F.tagName,color:"#A3D295"}]}),Lt({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:F.comment,color:"#666666"},{tag:[F.string,F.special(F.brace)],color:"#54BE0D"},{tag:F.regexp,color:"#E9C062"},{tag:F.number,color:"#CF6A4C"},{tag:[F.keyword,F.operator],color:"#5EA6EA"},{tag:F.variableName,color:"#7587A6"},{tag:[F.definitionKeyword,F.modifier],color:"#F9EE98"},{tag:[F.propertyName,F.function(F.variableName)],color:"#937121"},{tag:[F.typeName,F.angleBracket,F.tagName],color:"#9B859D"}]}),Lt({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:F.comment,color:"#6B4E32"},{tag:[F.keyword,F.operator,F.derefOperator],color:"#EF5D32"},{tag:F.className,color:"#EFAC32",fontWeight:"bold"},{tag:[F.typeName,F.propertyName,F.function(F.variableName),F.definition(F.variableName)],color:"#EFAC32"},{tag:F.definition(F.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:F.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[F.number,F.bool],color:"#6C99BB"},{tag:[F.variableName,F.self],color:"#7DAF9C"},{tag:[F.string,F.special(F.brace),F.regexp],color:"#D9D762"},{tag:[F.angleBracket,F.tagName,F.attributeName],color:"#EFCB43"}]}),Lt({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:F.comment,color:"#404040"},{tag:[F.string,F.special(F.brace),F.regexp],color:"#00D8FF"},{tag:F.number,color:"#E62286"},{tag:[F.variableName,F.attributeName,F.self],color:"#E62286",fontWeight:"bold"},{tag:F.function(F.variableName),color:"#fff",fontWeight:"bold"}]}),Lt({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:F.comment,color:"#BCC8BA"},{tag:[F.string,F.special(F.brace),F.regexp],color:"#5D90CD"},{tag:[F.number,F.bool,F.null],color:"#46A609"},{tag:F.keyword,color:"#AF956F"},{tag:[F.definitionKeyword,F.modifier],color:"#C52727"},{tag:[F.angleBracket,F.tagName,F.attributeName],color:"#606060"},{tag:F.self,color:"#000"}]}),Lt({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:F.comment,color:"#0088FF"},{tag:F.string,color:"#3AD900"},{tag:F.regexp,color:"#80FFC2"},{tag:[F.number,F.bool,F.null],color:"#FF628C"},{tag:[F.definitionKeyword,F.modifier],color:"#FFEE80"},{tag:F.variableName,color:"#CCCCCC"},{tag:F.self,color:"#FF80E1"},{tag:[F.className,F.definition(F.propertyName),F.function(F.variableName),F.definition(F.typeName),F.labelName],color:"#FFDD00"},{tag:[F.keyword,F.operator],color:"#FF9D00"},{tag:[F.propertyName,F.typeName],color:"#80FFBB"},{tag:F.special(F.brace),color:"#EDEF7D"},{tag:F.attributeName,color:"#9EFFFF"},{tag:F.derefOperator,color:"#fff"}]}),Lt({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:F.comment,color:"#AEAEAE"},{tag:[F.string,F.special(F.brace),F.regexp],color:"#8DFF8E"},{tag:[F.className,F.definition(F.propertyName),F.function(F.variableName),F.function(F.definition(F.variableName)),F.definition(F.typeName)],color:"#A3EBFF"},{tag:[F.number,F.bool,F.null],color:"#62E9BD"},{tag:[F.keyword,F.operator],color:"#2BF1DC"},{tag:[F.definitionKeyword,F.modifier],color:"#F8FBB1"},{tag:[F.variableName,F.self],color:"#B683CA"},{tag:[F.angleBracket,F.tagName,F.typeName,F.propertyName],color:"#60A4F1"},{tag:F.derefOperator,color:"#E0E0E0"},{tag:F.attributeName,color:"#7BACCA"}]}),Lt({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:F.comment,color:"#6272a4"},{tag:[F.string,F.special(F.brace)],color:"#f1fa8c"},{tag:[F.number,F.self,F.bool,F.null],color:"#bd93f9"},{tag:[F.keyword,F.operator],color:"#ff79c6"},{tag:[F.definitionKeyword,F.typeName],color:"#8be9fd"},{tag:F.definition(F.typeName),color:"#f8f8f2"},{tag:[F.className,F.definition(F.propertyName),F.function(F.variableName),F.attributeName],color:"#50fa7b"}]}),Lt({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:F.comment,color:"#AAAAAA"},{tag:[F.keyword,F.operator,F.typeName,F.tagName,F.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[F.attributeName,F.definition(F.propertyName)],color:"#4F9FD0"},{tag:[F.className,F.string,F.special(F.brace)],color:"#CF4F5F"},{tag:F.number,color:"#CF4F5F",fontWeight:"bold"},{tag:F.variableName,fontWeight:"bold"}]}),Lt({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:F.comment,color:"#9995b7"},{tag:F.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[F.definitionKeyword,F.modifier],color:"#ff5792"},{tag:[F.className,F.tagName,F.definition(F.typeName)],color:"#0094f0"},{tag:[F.number,F.bool,F.null,F.special(F.brace)],color:"#5842ff"},{tag:[F.definition(F.propertyName),F.function(F.variableName)],color:"#0095a8"},{tag:F.typeName,color:"#b3694d"},{tag:[F.propertyName,F.variableName],color:"#fa8900"},{tag:F.operator,color:"#ff5792"},{tag:F.self,color:"#e64100"},{tag:[F.string,F.regexp],color:"#00b368"},{tag:[F.paren,F.bracket],color:"#0431fa"},{tag:F.labelName,color:"#00bdd6"},{tag:F.attributeName,color:"#e64100"},{tag:F.angleBracket,color:"#9995b7"}]}),Lt({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:F.comment,color:"#9893a5"},{tag:[F.bool,F.null],color:"#286983"},{tag:F.number,color:"#d7827e"},{tag:F.className,color:"#d7827e"},{tag:[F.angleBracket,F.tagName,F.typeName],color:"#56949f"},{tag:F.attributeName,color:"#907aa9"},{tag:F.punctuation,color:"#797593"},{tag:[F.keyword,F.modifier],color:"#286983"},{tag:[F.string,F.regexp],color:"#ea9d34"},{tag:F.variableName,color:"#d7827e"}]}),Lt({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:F.comment,color:"#CFCFCF"},{tag:[F.number,F.bool,F.null],color:"#E66C29"},{tag:[F.className,F.definition(F.propertyName),F.function(F.variableName),F.labelName,F.definition(F.typeName)],color:"#2EB43B"},{tag:F.keyword,color:"#D8B229"},{tag:F.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[F.definitionKeyword,F.modifier],color:"#925A47"},{tag:F.string,color:"#704D3D"},{tag:F.typeName,color:"#2F8996"},{tag:[F.variableName,F.propertyName],color:"#77ACB0"},{tag:F.self,color:"#77ACB0",fontWeight:"bold"},{tag:F.regexp,color:"#E3965E"},{tag:[F.tagName,F.angleBracket],color:"#BAA827"},{tag:F.attributeName,color:"#B06520"},{tag:F.derefOperator,color:"#000"}]}),Lt({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:F.comment,color:"#93A1A1"},{tag:F.string,color:"#2AA198"},{tag:F.regexp,color:"#D30102"},{tag:F.number,color:"#D33682"},{tag:F.variableName,color:"#268BD2"},{tag:[F.keyword,F.operator,F.punctuation],color:"#859900"},{tag:[F.definitionKeyword,F.modifier],color:"#073642",fontWeight:"bold"},{tag:[F.className,F.self,F.definition(F.propertyName)],color:"#268BD2"},{tag:F.function(F.variableName),color:"#268BD2"},{tag:[F.bool,F.null],color:"#B58900"},{tag:F.tagName,color:"#268BD2",fontWeight:"bold"},{tag:F.angleBracket,color:"#93A1A1"},{tag:F.attributeName,color:"#93A1A1"},{tag:F.typeName,color:"#859900"}]}),Lt({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:F.comment,color:"#8E908C"},{tag:[F.variableName,F.self,F.propertyName,F.attributeName,F.regexp],color:"#C82829"},{tag:[F.number,F.bool,F.null],color:"#F5871F"},{tag:[F.className,F.typeName,F.definition(F.typeName)],color:"#C99E00"},{tag:[F.string,F.special(F.brace)],color:"#718C00"},{tag:F.operator,color:"#3E999F"},{tag:[F.definition(F.propertyName),F.function(F.variableName)],color:"#4271AE"},{tag:F.keyword,color:"#8959A8"},{tag:F.derefOperator,color:"#4D4D4C"}]});const f5=[Lt({variant:"dark",settings:{background:"#282c34",foreground:"#abb2bf",caret:"#528bff",selection:"#3E4451",lineHighlight:"#2c313c",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:F.comment,color:"#5c6370"},{tag:F.variableName,color:"#abb2bf"},{tag:[F.string,F.special(F.brace)],color:"#98c379"},{tag:F.number,color:"#d19a66"},{tag:F.bool,color:"#d19a66"},{tag:F.null,color:"#d19a66"},{tag:F.keyword,color:"#c678dd",fontWeight:500},{tag:F.className,color:"#61afef"},{tag:F.definition(F.typeName),color:"#61afef"},{tag:F.typeName,color:"#56b6c2"},{tag:F.angleBracket,color:"#abb2bf"},{tag:F.tagName,color:"#e06c75"},{tag:F.attributeName,color:"#d19a66"},{tag:F.operator,color:"#56b6c2",fontWeight:500},{tag:[F.function(F.variableName)],color:"#61afef"},{tag:[F.propertyName],color:"#e5c07b"}]}),We.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#2a7aa5",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px",borderBottomColor:"#4a90a5"}})],m5=[Lt({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#cceeff44",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:F.comment,color:"#708090"},{tag:F.variableName,color:"#000000"},{tag:[F.string,F.special(F.brace)],color:"#a11"},{tag:F.number,color:"#164"},{tag:F.bool,color:"#219"},{tag:F.null,color:"#219"},{tag:F.keyword,color:"#708",fontWeight:500},{tag:F.className,color:"#00f"},{tag:F.definition(F.typeName),color:"#00f"},{tag:F.typeName,color:"#085"},{tag:F.angleBracket,color:"#000000"},{tag:F.tagName,color:"#170"},{tag:F.attributeName,color:"#00c"},{tag:F.operator,color:"#a2f",fontWeight:500},{tag:[F.function(F.variableName)],color:"#00c"},{tag:[F.propertyName],color:"#05a"}]}),We.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#005f87",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px"}})];function U0(t){const{showPlaceholder:e,enableAI:n}=t;return e?"marimo-import":n?"ai":"none"}const p5=t=>{const{cellId:e,keymapConfig:n,hotkeys:o,enableAI:r,cellActions:s,completionConfig:i,lspConfig:a,diagnosticsConfig:l,displayConfig:c}=t,d=U0(t);return[xF(n,o),[We.domEventHandlers({drop:(f,m)=>{var p,b;const g=(p=f.dataTransfer)==null?void 0:p.files[0];if(g!=null&&g.type.startsWith("text/"))return f.preventDefault(),VD(m,g),!0;if(g!=null&&g.type.startsWith("image/"))return f.preventDefault(),HD(m,g),!0;const x=(b=f.dataTransfer)==null?void 0:b.getData("text/plain");if(x){f.preventDefault();const y=m.posAtCoords({x:f.clientX,y:f.clientY});return y!==null&&m.dispatch({changes:{from:y,to:y,insert:x},scrollIntoView:!0}),!0}return!1},dragover:f=>{f.preventDefault()}})],h5(),uE(),GD({completionConfig:i,hotkeys:o,placeholderType:d,lspConfig:a,diagnosticsConfig:l}),YD({cellId:e,hotkeys:o,cellActions:s}),g5(t),[d5,(h=(f,m)=>{$D(f,m)},$n.define(f=>new u5(f,h))),We.baseTheme({".underline":{textDecoration:"underline",cursor:"pointer",color:"var(--link)"}})],l!=null&&l.enabled?KD():[],r&&wm("inline_ai_tooltip")?QN({prompt:f=>async function(m){var w,S;const g=`
113
+ ${m.codeBefore}
114
+ <rewrite_this>
115
+ ${m.selection}
116
+ </rewrite_this>
117
+ ${m.codeAfter}
118
+ `.trim(),x=eC();await tC();const p=await fetch(x.getAiURL("completion").toString(),{method:"POST",headers:x.headers(),body:JSON.stringify({prompt:m.prompt,code:g,selectedText:m.selection,includeOtherCode:"",language:m.language})}),b=((w=m.selection.match(/^\s*/))==null?void 0:w[0])||"",y=(S=p.body)==null?void 0:S.getReader();if(!y)throw new Error("Failed to get response reader");let v="";for(;;){const{done:C,value:N}=await y.read();if(C)break;v+=new TextDecoder().decode(N)}return v.startsWith(b)||(v=b+v),v}({prompt:f.prompt,selection:f.selection,codeBefore:f.codeBefore,codeAfter:f.codeAfter,language:m3(f.editorView)})}):[],XD(Qe),JD(e,c.reference_highlighting??!1)];var h},g5=t=>{const{theme:e,hotkeys:n,completionConfig:o,cellId:r,lspConfig:s,diagnosticsConfig:i}=t,a=U0(t);return[We.lineWrapping,ZD(),QD(),eR(),tR(),nR(),oR(),rR(),sR({position:"fixed",parent:document.querySelector("#App")??void 0}),iR(),e==="dark"?f5:m5,aR(s),a5(o),lR(),cR(),fE(),To.high(Mn.of(pR)),dR(),uR(),hR.of(" "),iC(gR,{fallback:!0}),Mn.of(xR),fR({placeholderType:a,completionConfig:o,hotkeys:n,cellId:r,lspConfig:{...s,diagnostics:i}}),mR.of(bR()),ra.allowMultipleSelections.of(!0),l5(n),Mn.of([{key:"Tab",run:l=>sC(l)||(c=>{const{from:d,to:h}=c.state.selection.main;if(d!==h)return!1;const f=c.state.doc.lineAt(h);return f.text.slice(0,h-f.from).trim()!==""&&kR(c)})(l)||yR(l),preventDefault:!0},{key:n.getHotkey("completion.moveDown").key,run:l=>ws(l.state)!==null&&(Tc(!0)(l),!0),preventDefault:!0},{key:n.getHotkey("completion.moveUp").key,run:l=>ws(l.state)!==null&&(Tc(!1)(l),!0),preventDefault:!0}]),Mn.of([...vR,wR])]},x5={width:void 0,height:void 0};function $0(t,e,n){return t[e]?Array.isArray(t[e])?t[e][0][n]:t[e][n]:e==="contentBoxSize"?t.contentRect[n==="inlineSize"?"width":"height"]:void 0}let V0,H0,W0,q0;V0=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),H0=new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),W0=t=>{const e=H.c(79),{editing:n,status:o,disabled:r,staleInputs:s,edited:i,interrupted:a,elapsedTime:l,runStartTimestamp:c,lastRunStartTimestamp:d,uninstantiated:h}=t;if(!n)return null;const f=c??d;let m;e[0]!==f?(m=f?u.jsx(q0,{lastRanTime:f}):null,e[0]=f,e[1]=m):m=e[1];const g=m;if(r&&o==="running")return mt.error("CellStatusComponent: disabled and running"),null;if(r&&s){let x,p,b,y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx("span",{children:"This cell is stale, but it's disabled and can't be run"}),e[2]=x):x=e[2],e[3]!==g?(p=u.jsxs("div",{className:"flex flex-col gap-1",children:[x,g]}),e[3]=g,e[4]=p):p=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:u.jsxs(Ms,{children:[u.jsx(As,{className:"h-5 w-5",strokeWidth:1.5}),u.jsx(Dc,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[5]=b):b=e[5],e[6]!==p?(y=u.jsx(Ne,{content:p,usePortal:!0,children:b}),e[6]=p,e[7]=y):y=e[7],y}if(r){let x,p,b,y;return e[8]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx("span",{children:"This cell is disabled"}),e[8]=x):x=e[8],e[9]!==g?(p=u.jsxs("div",{className:"flex flex-col gap-1",children:[x,g]}),e[9]=g,e[10]=p):p=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx("div",{className:"cell-status-icon cell-status-disabled","data-testid":"cell-status","data-status":"disabled",children:u.jsx(As,{className:"h-5 w-5",strokeWidth:1.5})}),e[11]=b):b=e[11],e[12]!==p?(y=u.jsx(Ne,{content:p,usePortal:!0,children:b}),e[12]=p,e[13]=y):y=e[13],y}if(!s&&o==="disabled-transitively"){let x,p,b,y;return e[14]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx("span",{children:"An ancestor of this cell is disabled, so it can't be run"}),e[14]=x):x=e[14],e[15]!==g?(p=u.jsxs("div",{className:"flex flex-col gap-1",children:[x,g]}),e[15]=g,e[16]=p):p=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"disabled-transitively",children:u.jsxs(Ms,{layerTop:!0,children:[u.jsx(wa,{className:"h-5 w-5",strokeWidth:1.5}),u.jsx(As,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[17]=b):b=e[17],e[18]!==p?(y=u.jsx(Ne,{content:p,usePortal:!0,children:b}),e[18]=p,e[19]=y):y=e[19],y}if(s&&o==="disabled-transitively"){let x,p,b,y;return e[20]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx("span",{children:"This cell is stale, but an ancestor is disabled so it can't be run"}),e[20]=x):x=e[20],e[21]!==g?(p=u.jsxs("div",{className:"flex flex-col gap-1",children:[x,g]}),e[21]=g,e[22]=p):p=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:u.jsxs(Ms,{children:[u.jsx(Dc,{className:"h-5 w-5",strokeWidth:1}),u.jsx(As,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[23]=b):b=e[23],e[24]!==p?(y=u.jsx(Ne,{content:p,usePortal:!0,children:b}),e[24]=p,e[25]=y):y=e[25],y}if(o==="running"){let x,p,b,y,v;return e[26]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx("span",{children:"This cell is running"}),e[26]=x):x=e[26],e[27]!==g?(p=u.jsxs("div",{className:"flex flex-col gap-1",children:[x,g]}),e[27]=g,e[28]=p):p=e[28],e[29]!==c?(b=Bm.fromSeconds(c)||Bm.now(),e[29]=c,e[30]=b):b=e[30],e[31]!==b?(y=u.jsx("div",{className:"cell-status-icon elapsed-time running","data-testid":"cell-status","data-status":"running",children:u.jsx(b5,{startTime:b})}),e[31]=b,e[32]=y):y=e[32],e[33]!==p||e[34]!==y?(v=u.jsx(Ne,{content:p,usePortal:!0,children:y}),e[33]=p,e[34]=y,e[35]=v):v=e[35],v}if(o==="queued"){let x,p,b,y;return e[36]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx("span",{children:"This cell is queued to run"}),e[36]=x):x=e[36],e[37]!==g?(p=u.jsxs("div",{className:"flex flex-col gap-1",children:[x,g]}),e[37]=g,e[38]=p):p=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx("div",{className:"cell-status-icon cell-status-queued","data-testid":"cell-status","data-status":"queued",children:u.jsx(Gc,{className:"h-5 w-5",strokeWidth:1.5})}),e[39]=b):b=e[39],e[40]!==p?(y=u.jsx(Ne,{content:p,usePortal:!0,children:b}),e[40]=p,e[41]=y):y=e[41],y}if(i||a||s||h){let x;e[42]!==l?(x=Is(l),e[42]=l,e[43]=x):x=e[43];const p=x;let b;e[44]!==l||e[45]!==p?(b=l?u.jsx(Yc,{elapsedTime:p}):null,e[44]=l,e[45]=p,e[46]=b):b=e[46];const y=b;let v,w,S,C,N,j="";if(h)v="This cell has not yet been run";else if(a){let E;v="This cell was interrupted when it was last run",e[47]!==y?(E=u.jsxs("span",{children:["This cell ran for ",y," before being interrupted"]}),e[47]=y,e[48]=E):E=e[48],j=E}else if(i){let E;v="This cell has been modified since it was last run",e[49]!==y?(E=u.jsxs("span",{children:["This cell took ",y," to run"]}),e[49]=y,e[50]=E):E=e[50],j=E}else{let E;v="This cell has not been run with the latest inputs",e[51]!==y?(E=u.jsxs("span",{children:["This cell took ",y," to run"]}),e[51]=y,e[52]=E):E=e[52],j=E}return e[53]===Symbol.for("react.memo_cache_sentinel")?(w=u.jsx("div",{className:"cell-status-stale","data-testid":"cell-status","data-status":"outdated",children:u.jsx(Dc,{className:"h-5 w-5",strokeWidth:1.5})}),e[53]=w):w=e[53],e[54]!==v?(S=u.jsx(Ne,{content:v,usePortal:!0,children:w}),e[54]=v,e[55]=S):S=e[55],e[56]!==l||e[57]!==p||e[58]!==g||e[59]!==j?(C=l&&u.jsx(Ne,{content:u.jsxs("div",{className:"flex flex-col gap-1",children:[j,g]}),usePortal:!0,children:u.jsx("div",{className:"elapsed-time hover-action","data-testid":"cell-status","data-status":"outdated",children:u.jsx("span",{children:p})})}),e[56]=l,e[57]=p,e[58]=g,e[59]=j,e[60]=C):C=e[60],e[61]!==S||e[62]!==C?(N=u.jsxs("div",{className:"cell-status-icon flex items-center gap-2",children:[S,C]}),e[61]=S,e[62]=C,e[63]=N):N=e[63],N}if(l!==null){let x;e[64]!==l?(x=Is(l),e[64]=l,e[65]=x):x=e[65];const p=x;let b;e[66]!==l||e[67]!==p?(b=l?u.jsx(Yc,{elapsedTime:p}):null,e[66]=l,e[67]=p,e[68]=b):b=e[68];const y=b;let v,w,S,C;return e[69]!==y?(v=u.jsxs("span",{children:["This cell took ",y," to run"]}),e[69]=y,e[70]=v):v=e[70],e[71]!==g||e[72]!==v?(w=u.jsxs("div",{className:"flex flex-col gap-1",children:[v,g]}),e[71]=g,e[72]=v,e[73]=w):w=e[73],e[74]!==p?(S=u.jsx("div",{className:"cell-status-icon elapsed-time hover-action","data-testid":"cell-status","data-status":"idle",children:u.jsx("span",{children:p})}),e[74]=p,e[75]=S):S=e[75],e[76]!==w||e[77]!==S?(C=u.jsx(Ne,{content:w,usePortal:!0,children:S}),e[76]=w,e[77]=S,e[78]=C):C=e[78],C}return null},Yc=t=>{const e=H.c(2);let n;return e[0]!==t.elapsedTime?(n=u.jsx("span",{className:"tracking-wide font-semibold",children:t.elapsedTime}),e[0]=t.elapsedTime,e[1]=n):n=e[1],n},q0=t=>{const e=H.c(18),n=1e3*t.lastRanTime;let o,r,s,i,a,l,c,d,h;if(e[0]!==n){const f=new Date(n),m=new Date,g=f.toDateString()===m.toDateString()?V0:H0;i="Ran at",a=" ",l=u.jsx("strong",{className:"tracking-wide font-semibold",children:g.format(f)}),c=" ",o="text-muted-foreground",r="(",s=Rj(f),e[0]=n,e[1]=o,e[2]=r,e[3]=s,e[4]=i,e[5]=a,e[6]=l,e[7]=c}else o=e[1],r=e[2],s=e[3],i=e[4],a=e[5],l=e[6],c=e[7];return e[8]!==o||e[9]!==r||e[10]!==s?(d=u.jsxs("span",{className:o,children:[r,s," ago)"]}),e[8]=o,e[9]=r,e[10]=s,e[11]=d):d=e[11],e[12]!==i||e[13]!==a||e[14]!==l||e[15]!==c||e[16]!==d?(h=u.jsxs("span",{children:[i,a,l,c,d]}),e[12]=i,e[13]=a,e[14]=l,e[15]=c,e[16]=d,e[17]=h):h=e[17],h},Is=function(t){if(t===null)return"";const e=t,n=e/1e3;return n>=60?`${Math.floor(n/60)}m${Math.floor(n%60)}s`:n>=1?`${n.toFixed(2).toString()}s`:`${e.toFixed(0).toString()}ms`};const b5=t=>{const e=H.c(6);let n;e[0]!==t.startTime?(n=t.startTime.toMilliseconds(),e[0]=t.startTime,e[1]=n):n=e[1];const o=function(i){const a=M.useRef(i),[l,c]=M.useState(i);return M.useEffect(()=>{const d=setInterval(()=>{c(Bm.now().toMilliseconds())},17);return()=>clearInterval(d)},[]),l-a.current}(n);let r,s;return e[2]!==o?(r=Is(o),e[2]=o,e[3]=r):r=e[3],e[4]!==r?(s=u.jsx("span",{children:r}),e[4]=r,e[5]=s):s=e[5],s};var vu="ContextMenu",[y5,tz]=lC(vu,[aC]),Xt=aC(),[v5,G0]=y5(vu),Y0=t=>{const{__scopeContextMenu:e,children:n,onOpenChange:o,dir:r,modal:s=!0}=t,[i,a]=M.useState(!1),l=Xt(e),c=Xo(o),d=M.useCallback(h=>{a(h),c(h)},[c]);return u.jsx(v5,{scope:e,open:i,onOpenChange:d,modal:s,children:u.jsx(PR,{...l,dir:r,open:i,onOpenChange:d,modal:s,children:n})})};Y0.displayName=vu;var K0="ContextMenuTrigger",X0=M.forwardRef((t,e)=>{const{__scopeContextMenu:n,disabled:o=!1,...r}=t,s=G0(K0,n),i=Xt(n),a=M.useRef({x:0,y:0}),l=M.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),c=M.useRef(0),d=M.useCallback(()=>window.clearTimeout(c.current),[]),h=f=>{a.current={x:f.clientX,y:f.clientY},s.onOpenChange(!0)};return M.useEffect(()=>d,[d]),M.useEffect(()=>{o&&d()},[o,d]),u.jsxs(u.Fragment,{children:[u.jsx(SR,{...i,virtualRef:l}),u.jsx(ks.span,{"data-state":s.open?"open":"closed","data-disabled":o?"":void 0,...r,ref:e,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:o?t.onContextMenu:On(t.onContextMenu,f=>{d(),h(f),f.preventDefault()}),onPointerDown:o?t.onPointerDown:On(t.onPointerDown,dl(f=>{d(),c.current=window.setTimeout(()=>h(f),700)})),onPointerMove:o?t.onPointerMove:On(t.onPointerMove,dl(d)),onPointerCancel:o?t.onPointerCancel:On(t.onPointerCancel,dl(d)),onPointerUp:o?t.onPointerUp:On(t.onPointerUp,dl(d))})]})});X0.displayName=K0;var J0=t=>{const{__scopeContextMenu:e,...n}=t,o=Xt(e);return u.jsx(LR,{...o,...n})};J0.displayName="ContextMenuPortal";var Z0="ContextMenuContent",Q0=M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=G0(Z0,n),s=Xt(n),i=M.useRef(!1);return u.jsx(NR,{...s,...o,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var l;(l=t.onCloseAutoFocus)==null||l.call(t,a),!a.defaultPrevented&&i.current&&a.preventDefault(),i.current=!1},onInteractOutside:a=>{var l;(l=t.onInteractOutside)==null||l.call(t,a),a.defaultPrevented||r.modal||(i.current=!0)},style:{...t.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)"}})});Q0.displayName=Z0,M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Xt(n);return u.jsx(ER,{...r,...o,ref:e})}).displayName="ContextMenuGroup";var ex=M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Xt(n);return u.jsx(_R,{...r,...o,ref:e})});ex.displayName="ContextMenuLabel";var tx=M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Xt(n);return u.jsx(jR,{...r,...o,ref:e})});tx.displayName="ContextMenuItem";var nx=M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Xt(n);return u.jsx(IR,{...r,...o,ref:e})});nx.displayName="ContextMenuCheckboxItem",M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Xt(n);return u.jsx(AR,{...r,...o,ref:e})}).displayName="ContextMenuRadioGroup";var ox=M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Xt(n);return u.jsx(TR,{...r,...o,ref:e})});ox.displayName="ContextMenuRadioItem";var rx=M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Xt(n);return u.jsx(MR,{...r,...o,ref:e})});rx.displayName="ContextMenuItemIndicator";var sx=M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Xt(n);return u.jsx(CR,{...r,...o,ref:e})});sx.displayName="ContextMenuSeparator",M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Xt(n);return u.jsx(OR,{...r,...o,ref:e})}).displayName="ContextMenuArrow";var ix=M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Xt(n);return u.jsx(DR,{...r,...o,ref:e})});ix.displayName="ContextMenuSubTrigger";var ax=M.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Xt(n);return u.jsx(RR,{...r,...o,ref:e,style:{...t.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 dl(t){return e=>e.pointerType!=="mouse"?t(e):void 0}ax.displayName="ContextMenuSubContent";var lx=Q0,cx=ex,dx=tx,ux=nx,hx=ox,fx=rx,mx=sx,px=ix,gx=ax;const xx=Y0,bx=X0,w5=BR(J0);M.forwardRef((t,e)=>{const n=H.c(14);let o,r,s,i,a,l,c;return n[0]!==t?({className:r,inset:s,children:o,...i}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=i):(o=n[1],r=n[2],s=n[3],i=n[4]),n[5]!==r||n[6]!==s?(a=UR({className:r,inset:s}),n[5]=r,n[6]=s,n[7]=a):a=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx(HR,{className:"ml-auto h-4 w-4"}),n[8]=l):l=n[8],n[9]!==o||n[10]!==i||n[11]!==e||n[12]!==a?(c=u.jsxs(px,{ref:e,className:a,...i,children:[o,l]}),n[9]=o,n[10]=i,n[11]=e,n[12]=a,n[13]=c):c=n[13],c}).displayName=px.displayName;const yx="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";M.forwardRef((t,e)=>{const n=H.c(9);let o,r,s,i;return n[0]!==t?({className:o,...r}=t,n[0]=t,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(s=xe(cC({subcontent:!0}),yx,o),n[3]=o,n[4]=s):s=n[4],n[5]!==r||n[6]!==e||n[7]!==s?(i=u.jsx(gx,{ref:e,className:s,...r}),n[5]=r,n[6]=e,n[7]=s,n[8]=i):i=n[8],i}).displayName=gx.displayName;const wu=M.forwardRef((t,e)=>{const n=H.c(15);let o,r,s;n[0]!==t?({className:o,scrollable:s,...r}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]);const i=s===void 0||s;let a;n[4]!==o||n[5]!==i?(a=xe(cC(),yx,i&&"overflow-auto",o),n[4]=o,n[5]=i,n[6]=a):a=n[6];const l=i?"calc(var(--radix-context-menu-content-available-height) - 30px)":void 0;let c,d;return n[7]!==r.style||n[8]!==l?(c={...r.style,maxHeight:l},n[7]=r.style,n[8]=l,n[9]=c):c=n[9],n[10]!==r||n[11]!==e||n[12]!==a||n[13]!==c?(d=u.jsx(w5,{children:u.jsx($R,{children:u.jsx(lx,{ref:e,className:a,style:c,...r})})}),n[10]=r,n[11]=e,n[12]=a,n[13]=c,n[14]=d):d=n[14],d});wu.displayName=lx.displayName;const ri=M.forwardRef((t,e)=>{const n=H.c(13);let o,r,s,i,a,l;return n[0]!==t?({className:o,inset:r,variant:i,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=i):(o=n[1],r=n[2],s=n[3],i=n[4]),n[5]!==o||n[6]!==r||n[7]!==i?(a=zR({className:o,inset:r,variant:i}),n[5]=o,n[6]=r,n[7]=i,n[8]=a):a=n[8],n[9]!==s||n[10]!==e||n[11]!==a?(l=u.jsx(dx,{ref:e,className:a,...s}),n[9]=s,n[10]=e,n[11]=a,n[12]=l):l=n[12],l});ri.displayName=dx.displayName,M.forwardRef((t,e)=>{const n=H.c(15);let o,r,s,i,a,l,c,d;return n[0]!==t?({className:s,children:r,checked:o,...i}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=i):(o=n[1],r=n[2],s=n[3],i=n[4]),n[5]!==s?(a=Rc({className:s}),n[5]=s,n[6]=a):a=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=Rc(),n[7]=l):l=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(c=u.jsx("span",{className:l,children:u.jsx(fx,{children:u.jsx(WR,{className:"h-4 w-4"})})}),n[8]=c):c=n[8],n[9]!==o||n[10]!==r||n[11]!==i||n[12]!==e||n[13]!==a?(d=u.jsxs(ux,{ref:e,className:a,checked:o,...i,children:[c,r]}),n[9]=o,n[10]=r,n[11]=i,n[12]=e,n[13]=a,n[14]=d):d=n[14],d}).displayName=ux.displayName,M.forwardRef((t,e)=>{const n=H.c(13);let o,r,s,i,a,l,c;return n[0]!==t?({className:r,children:o,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==r?(i=Rc({className:r}),n[4]=r,n[5]=i):i=n[5],n[6]===Symbol.for("react.memo_cache_sentinel")?(a=Rc(),n[6]=a):a=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx("span",{className:a,children:u.jsx(fx,{children:u.jsx(qR,{className:"h-4 w-4 fill-current"})})}),n[7]=l):l=n[7],n[8]!==o||n[9]!==s||n[10]!==e||n[11]!==i?(c=u.jsxs(hx,{ref:e,className:i,...s,children:[l,o]}),n[8]=o,n[9]=s,n[10]=e,n[11]=i,n[12]=c):c=n[12],c}).displayName=hx.displayName,M.forwardRef((t,e)=>{const n=H.c(11);let o,r,s,i,a;return n[0]!==t?({className:o,inset:r,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==o||n[5]!==r?(i=VR({className:o,inset:r}),n[4]=o,n[5]=r,n[6]=i):i=n[6],n[7]!==s||n[8]!==e||n[9]!==i?(a=u.jsx(cx,{ref:e,className:i,...s}),n[7]=s,n[8]=e,n[9]=i,n[10]=a):a=n[10],a}).displayName=cx.displayName;const vx=M.forwardRef((t,e)=>{const n=H.c(9);let o,r,s,i;return n[0]!==t?({className:o,...r}=t,n[0]=t,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(s=xe(FR({className:o})),n[3]=o,n[4]=s):s=n[4],n[5]!==r||n[6]!==e||n[7]!==s?(i=u.jsx(mx,{ref:e,className:s,...r}),n[5]=r,n[6]=e,n[7]=s,n[8]=i):i=n[8],i});vx.displayName=mx.displayName;const wx=t=>{const e=H.c(20),{connectionState:n,onClick:o,tooltipContent:r}=t;let s;e[0]!==n||e[1]!==r?(s=jc(n)||r,e[0]=n,e[1]=r,e[2]=s):s=e[2];const i=s;let a;e[3]!==i||e[4]!==n?(a=eo(n)?i:u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsx("div",{children:i}),u.jsx("div",{className:"text-xs text-muted-foreground font-medium pt-1 -mt-2 border-t border-border",children:"Right-click for cell types"})]}),e[3]=i,e[4]=n,e[5]=a):a=e[5];const l=a;let c,d,h,f,m,g;return e[6]!==o?(c=()=>o==null?void 0:o({code:""}),e[6]=o,e[7]=c):c=e[7],e[8]!==n?(d=xe("shoulder-button hover-action",eo(n)&&" inactive-button"),e[8]=n,e[9]=d):d=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(h=u.jsx(Jo,{strokeWidth:1.8}),e[10]=h):h=e[10],e[11]!==c||e[12]!==d?(f=u.jsx(cn,{onClick:c,className:d,onMouseDown:zn.preventFocus,shape:"circle",size:"small",color:"hint-green","data-testid":"create-cell-button",children:h}),e[11]=c,e[12]=d,e[13]=f):f=e[13],e[14]!==l||e[15]!==f?(m=u.jsx(Ne,{content:l,children:f}),e[14]=l,e[15]=f,e[16]=m):m=e[16],e[17]!==o||e[18]!==m?(g=u.jsx(k5,{onClick:o,children:m}),e[17]=o,e[18]=m,e[19]=g):g=e[19],g},k5=t=>{const e=H.c(26),{children:n,onClick:o}=t,{createNewCell:r}=lt();if(!o)return n;let s,i,a,l,c,d,h,f,m,g,x,p;return e[0]!==n?(s=u.jsx(bx,{children:n}),e[0]=n,e[1]=s):s=e[1],e[2]!==o?(i=b=>{b.stopPropagation(),o({code:""})},e[2]=o,e[3]=i):i=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(a=u.jsx("div",{className:"mr-3 text-muted-foreground",children:u.jsx(cc,{})}),e[4]=a):a=e[4],e[5]!==i?(l=u.jsxs(ri,{onSelect:i,children:[a,"Python cell"]},"python"),e[5]=i,e[6]=l):l=e[6],e[7]!==r||e[8]!==o?(c=b=>{b.stopPropagation(),Jn({autoInstantiate:!0,createNewCell:r}),o({code:new Wi().defaultCode,hideCode:!0})},e[7]=r,e[8]=o,e[9]=c):c=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx("div",{className:"mr-3 text-muted-foreground",children:u.jsx(lc,{})}),e[10]=d):d=e[10],e[11]!==c?(h=u.jsxs(ri,{onSelect:c,children:[d,"Markdown cell"]},"markdown"),e[11]=c,e[12]=h):h=e[12],e[13]!==r||e[14]!==o?(f=b=>{b.stopPropagation(),Jn({autoInstantiate:!0,createNewCell:r}),o({code:new Pc().defaultCode})},e[13]=r,e[14]=o,e[15]=f):f=e[15],e[16]===Symbol.for("react.memo_cache_sentinel")?(m=u.jsx("div",{className:"mr-3 text-muted-foreground",children:u.jsx(Yo,{size:13,strokeWidth:1.5})}),e[16]=m):m=e[16],e[17]!==f?(g=u.jsxs(ri,{onSelect:f,children:[m,"SQL cell"]},"sql"),e[17]=f,e[18]=g):g=e[18],e[19]!==l||e[20]!==h||e[21]!==g?(x=u.jsxs(wu,{children:[l,h,g]}),e[19]=l,e[20]=h,e[21]=g,e[22]=x):x=e[22],e[23]!==s||e[24]!==x?(p=u.jsxs(xx,{children:[s,x]}),e[23]=s,e[24]=x,e[25]=p):p=e[25],p},kx=q.memo(q.forwardRef((t,e)=>{const n=H.c(34);let o,r,s;n[0]!==t?({children:o,showTooltip:s,...r}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]);const i=s===void 0||s,[a,l]=M.useState(!1);let c;n[4]!==r?(c={cell:r},n[4]=r,n[5]=c):c=n[5];const d=pd(c),h=YR();let f,m,g,x,p,b;if(n[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>({toggle:()=>l(C5)}),n[6]=f):f=n[6],M.useImperativeHandle(e,f),n[7]===Symbol.for("react.memo_cache_sentinel")?(m=u.jsx(Bi,{placeholder:"Search actions...",className:"h-6 m-1"}),n[7]=m):m=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(g=u.jsx(mc,{children:"No results"}),n[8]=g):g=n[8],n[9]!==d){let j;n[11]!==d.length?(j=(E,T)=>u.jsxs(M.Fragment,{children:[u.jsx(mm,{children:E.map(I=>{let O=u.jsxs("div",{className:"flex items-center flex-1",children:[I.icon&&u.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:I.icon}),u.jsx("div",{className:"flex-1",children:I.label}),u.jsxs("div",{className:"shrink-0 text-sm",children:[I.hotkey&&dC(I.hotkey),I.rightElement]})]});return I.tooltip&&(O=u.jsx(Ne,{content:I.tooltip,delayDuration:100,children:O})),u.jsx(Zn,{className:xe(I.disabled&&"opacity-50!"),onSelect:()=>{I.disableClick||I.disabled||(I.handle(),l(!1))},variant:I.variant,children:O},I.label)})},T),T<d.length-1&&u.jsx(j3,{})]},T),n[11]=d.length,n[12]=j):j=n[12],x=d.map(j),n[9]=d,n[10]=x}else x=n[10];n[13]!==x?(p=u.jsxs(kc,{children:[m,u.jsxs(Um,{children:[g,x]})]}),n[13]=x,n[14]=p):p=n[14],n[15]!==h||n[16]!==p?(b=u.jsx(xs,{className:"w-[300px] p-0 pt-1 overflow-auto",scrollable:!0,...h,children:p}),n[15]=h,n[16]=p,n[17]=b):b=n[17];const y=b;if(!i){let j,E;return n[18]!==o?(j=u.jsx(Cs,{asChild:!0,children:o}),n[18]=o,n[19]=j):j=n[19],n[20]!==y||n[21]!==a||n[22]!==j?(E=u.jsxs(yr,{open:a,onOpenChange:l,children:[j,y]}),n[20]=y,n[21]=a,n[22]=j,n[23]=E):E=n[23],E}let v;n[24]===Symbol.for("react.memo_cache_sentinel")?(v=u.jsx(KR,{tabIndex:-1,children:Gt("cell.cellActions")}),n[24]=v):v=n[24];const w=!a&&v;let S,C,N;return n[25]!==o?(S=u.jsx(XR,{children:u.jsx(Cs,{className:"flex",children:o})}),n[25]=o,n[26]=S):S=n[26],n[27]!==w||n[28]!==S?(C=u.jsxs(JR,{delayDuration:200,disableHoverableContent:!0,children:[w,S]}),n[27]=w,n[28]=S,n[29]=C):C=n[29],n[30]!==y||n[31]!==a||n[32]!==C?(N=u.jsxs(yr,{open:a,onOpenChange:l,children:[C,y]}),n[30]=y,n[31]=a,n[32]=C,n[33]=N):N=n[33],N})),Cx=q.memo(t=>{const e=H.c(5),{children:n,cellId:o}=t;let r,s;e[0]!==o?(s=GR(o),e[0]=o,e[1]=s):s=e[1],r=s;const i=je(r);if(!i)return null;let a;return e[2]!==n||e[3]!==i?(a=u.jsx(kx,{showTooltip:!1,...i,children:n}),e[2]=n,e[3]=i,e[4]=a):a=e[4],a});function C5(t){return!t}Cx.displayName="ConnectionCellActionsDropdown";const jx=t=>{const e=H.c(35),{children:n,cellId:o,getEditorView:r}=t,s=sa(o),i=ia(o),a=!$m(i.output),l=i.consoleOutputs.length>0;let c;e[0]!==s.config||e[1]!==s.name||e[2]!==o||e[3]!==i.status||e[4]!==r||e[5]!==a||e[6]!==l?(c={cell:{cellId:o,name:s.name,config:s.config,status:i.status,hasOutput:a,hasConsoleOutput:l,getEditorView:r}},e[0]=s.config,e[1]=s.name,e[2]=o,e[3]=i.status,e[4]=r,e[5]=a,e[6]=l,e[7]=c):c=e[7];const d=pd(c),[h,f]=q.useState(),m=!!h;let g,x,p,b,y,v,w,S,C,N;if(e[8]===Symbol.for("react.memo_cache_sentinel")?(g=u.jsx(Di,{size:13,strokeWidth:1.5}),e[8]=g):g=e[8],e[9]!==o?(x=async()=>{var T;if((T=window.getSelection())==null?void 0:T.toString())return void document.execCommand("copy");const E=document.getElementById(g3.create(o));E?await sn(E.textContent??""):mt.warn("cell-context-menu: output not found")},e[9]=o,e[10]=x):x=e[10],e[11]!==d||e[12]!==n||e[13]!==r||e[14]!==h||e[15]!==m||e[16]!==x){const j=[{label:"Copy",hidden:m,icon:g,handle:x},{label:"Cut",hidden:!!h,icon:u.jsx(ld,{size:13,strokeWidth:1.5}),handle:j5},{label:"Paste",hidden:!!h,icon:u.jsx(gp,{size:13,strokeWidth:1.5}),handle:async()=>{const I=r();if(I)try{const O=await navigator.clipboard.readText();if(O){const{from:L,to:D}=I.state.selection.main,R=I.state.update({changes:{from:L,to:D,insert:O}});I.dispatch(R)}}catch(O){const L=O;mt.error("Failed to paste from clipboard",L),ZR({command:"paste"})}}},{label:"Copy image",hidden:!h,icon:u.jsx(Qc,{size:13,strokeWidth:1.5}),handle:async()=>{if(h){const I=await fetch(h.src),O=await I.blob(),L=new ClipboardItem({[O.type]:O});await navigator.clipboard.write([L]).then(S5).catch(N5)}}},{icon:u.jsx(ip,{size:13,strokeWidth:1.5}),label:"Download image",hidden:!h,handle:()=>{if(h){const I=document.createElement("a");I.download="image.png",I.href=h.src,I.click()}}},{label:"Go to Definition",icon:u.jsx(eP,{size:13,strokeWidth:1.5}),handle:()=>{const I=r();I&&QR(I)}}],E=[j,...d];let T;b=xx,e[23]===Symbol.for("react.memo_cache_sentinel")?(T=I=>{I.target instanceof HTMLImageElement?f(I.target):f(void 0)},e[23]=T):T=e[23],e[24]!==n?(y=u.jsx(bx,{onContextMenu:T,asChild:!0,children:n}),e[24]=n,e[25]=y):y=e[25],p=wu,v="w-[300px]",w=!0,S=E.map((I,O)=>u.jsxs(M.Fragment,{children:[I.map(E5),O<E.length-1&&u.jsx(vx,{})]},O)),e[11]=d,e[12]=n,e[13]=r,e[14]=h,e[15]=m,e[16]=x,e[17]=p,e[18]=b,e[19]=y,e[20]=v,e[21]=w,e[22]=S}else p=e[17],b=e[18],y=e[19],v=e[20],w=e[21],S=e[22];return e[26]!==p||e[27]!==v||e[28]!==w||e[29]!==S?(C=u.jsx(p,{className:v,scrollable:w,children:S}),e[26]=p,e[27]=v,e[28]=w,e[29]=S,e[30]=C):C=e[30],e[31]!==b||e[32]!==y||e[33]!==C?(N=u.jsxs(b,{children:[y,C]}),e[31]=b,e[32]=y,e[33]=C,e[34]=N):N=e[34],N};function j5(){document.execCommand("cut")}function S5(){Je({title:"Copied image to clipboard"})}function N5(t){Je({title:"Failed to copy image to clipboard. Try downloading instead.",description:t.message}),mt.error("Failed to copy image to clipboard",t)}function E5(t){if(t.hidden)return null;let e=u.jsxs("div",{className:"flex items-center flex-1",children:[t.icon&&u.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:t.icon}),u.jsx("div",{className:"flex-1",children:t.label}),u.jsxs("div",{className:"shrink-0 text-sm",children:[t.hotkey&&dC(t.hotkey),t.rightElement]})]});return t.tooltip&&(e=u.jsx(Ne,{delayDuration:100,content:t.tooltip,children:e})),u.jsx(ri,{className:t.disabled?"opacity-50!":"",onSelect:n=>{t.disableClick||t.disabled||t.handle(n)},variant:t.variant,children:e},t.label)}if(Sj)Nj(XF),Sj();else{const t=await Vm(()=>import("./loro_wasm_bg-C3hKWL9L.js").then(async e=>(await e.__tla,e)).then(e=>e.w),[],import.meta.url);Nj(new WebAssembly.Instance(t.default,{"./loro_wasm_bg.js":KF}).exports)}const _5=["Map","Text","List","Tree","MovableList","Counter"];function Sx(t){if(typeof t!="object"||t==null)return!1;const e=Object.getPrototypeOf(t);return e!=null&&typeof e=="object"&&typeof e.kind=="function"&&_5.includes(t.kind())}Ej.prototype.toJsonWithReplacer=function(t){const e=new Set,n=this,o=(i,a)=>{if(typeof a=="string"&&a.startsWith("cid:")&&!e.has(a)){e.add(a);const c=n.getContainerById(a);if(c==null)throw new Error(`ContainerID not found: ${a}`);const d=t(i,c);if(d===c){const h=c.getShallowValue();return typeof h=="object"?r(h):h}if(Sx(d))throw new Error("Using new container is not allowed in toJsonWithReplacer");return typeof d=="object"&&d!=null?r(d):d}if(typeof a=="object"&&a!=null)return r(a);const l=t(i,a);if(Sx(l))throw new Error("Using new container is not allowed in toJsonWithReplacer");return l},r=i=>{if(Array.isArray(i))return i.map((l,c)=>o(c,l)).filter(l=>l!==void 0);const a={};for(const[l,c]of Object.entries(i)){const d=o(l,c);d!==void 0&&(a[l]=d)}return a},s=n.getShallowValue();return r(s)};const I5=We.baseTheme({".loro-cursor":{position:"absolute",width:"2px",display:"inline-block",height:"1.2em"},".loro-cursor::before":{position:"absolute",top:"1.3em",left:"0",content:"var(--rtc-name)",padding:"2px 6px",fontSize:"12px",borderRadius:"3px",whiteSpace:"nowrap",userSelect:"none",backgroundColor:"inherit",opacity:"0.7"},".loro-selection":{opacity:"0.5"}}),si=Tt.define(),ku=vn.define({create:()=>({remoteCursors:new Map,isCheckout:!1}),update(t,e){for(const n of e.effects)if(n.is(si))switch(n.value.type){case"update":{const{peer:o,user:r,cursor:s}=n.value;t.remoteCursors.set(o,{uid:o,cursor:s,user:r});break}case"delete":t.remoteCursors.delete(n.value.peer);break;case"checkout":t.isCheckout=n.value.checkout}return t}}),Nx=t=>{const e=t.transactions.flatMap(n=>n.effects).filter(n=>n.is(si));return t.docChanged||t.viewportChanged||e.length>0};class ul{constructor(e,n,o,r,s){this.left=e,this.top=n,this.height=o,this.name=r,this.colorClassName=s}draw(){const e=document.createElement("div");return this.adjust(e),e}update(e){return this.adjust(e),!0}adjust(e){e.style.left=`${this.left}px`,e.style.top=`${this.top}px`,e.style.height=`${this.height}px`,e.className=`loro-cursor ${this.colorClassName}`,e.style.setProperty("--rtc-name",`"${this.name}"`)}eq(e){return this.left===e.left&&this.top===e.top&&this.height===e.height&&this.name===e.name}static createCursor(e,n,o,r){const s=ul.calculateAbsoluteCursorPosition(n,e);if(!s)return[];const i=e.scrollDOM.getBoundingClientRect(),a=(e.textDirection===nP.LTR?i.left:i.right-e.scrollDOM.clientWidth)-e.scrollDOM.scrollLeft,l=i.top-e.scrollDOM.scrollTop;return[new ul(s.left-a,s.top-l,s.bottom-s.top,o,r)]}static calculateAbsoluteCursorPosition(e,n){const o=Math.max(0,Math.min(n.state.doc.length,e.anchor));return n.coordsAtPos(o,e.assoc||1)}}const A5=(t,e,n,o)=>{const r=[],{updated:s,added:i}=n;for(const a of[...s,...i]){const l=Ex(t,e,a,o);l&&r.push(l)}return r},Ex=(t,e,n,o)=>{const r=e.getAllStates()[n];if(!r||n===t.peerIdStr||r.scopeId!==o)return;if(r.type==="delete")return si.of({type:"delete",peer:r.uid,scopeId:r.scopeId});const s=_j.decode(r.cursor.anchor),i=t.getCursorPos(s).offset;let a=i;if(r.cursor.head){const l=_j.decode(r.cursor.head);a=t.getCursorPos(l).offset}return si.of({type:"update",peer:r.uid,scopeId:r.scopeId,cursor:{anchor:i,head:a},user:r.user})};class T5{constructor(e,n,o,r,s,i,a){this.view=e,this.doc=n,this.user=o,this.awareness=r,this.getTextFromDoc=s,this.scopeId=i,this.getUserId=a,this.sub=void 0,this.sub=this.doc.subscribe(l=>{if(l.by==="local"){const c=[];for(const d of this.awareness.peers()){const h=Ex(this.doc,this.awareness,d,this.scopeId);h&&c.push(h)}this.view.dispatch({effects:c})}else l.by==="checkout"&&this.view.dispatch({effects:[si.of({type:"checkout",checkout:this.doc.isDetached()})]})})}update(e){if(!e.selectionSet&&!e.focusChanged&&!e.docChanged)return;const n=e.state.selection.main;if(this.view.hasFocus&&!this.doc.isDetached()){const o=O5({doc:this.doc,getTextFromDoc:this.getTextFromDoc,anchor:n.anchor,head:n.head});this.awareness.setLocalState({type:"update",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId,cursor:o,user:this.user})}else this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}destroy(){var e;(e=this.sub)==null||e.call(this),this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}}class M5{constructor(e,n,o,r){this.view=e,this.doc=n,this.awareness=o,this.scopeId=r,this._awarenessListener=void 0;const s=async(i,a)=>{a!=="local"&&this.view.dispatch({effects:A5(this.doc,this.awareness,i,this.scopeId)})};this._awarenessListener=s,this.awareness.addListener(s)}destroy(){this._awarenessListener&&this.awareness.removeListener(this._awarenessListener)}}const O5=({doc:t,getTextFromDoc:e,anchor:n,head:o})=>{var i,a;n===o&&(o=void 0);const r=(i=e(t).getCursor(n))==null?void 0:i.encode();if(!r)throw new Error("cursor head not found");let s;return o!==void 0&&(s=(a=e(t).getCursor(o))==null?void 0:a.encode()),{anchor:r,head:s}},hl=["bg-(--amber-6)","bg-(--blue-6)","bg-(--crimson-6)","bg-(--cyan-6)","bg-(--grass-6)","bg-(--gray-6)","bg-(--green-6)","bg-(--lime-6)","bg-(--orange-6)","bg-(--purple-6)","bg-(--red-6)","bg-(--sage-6)","bg-(--sky-6)","bg-(--slate-6)"],D5=(t,e,n)=>$n.define(o=>new R5(o,t,e,n)),Rr=Fm.define();class R5{constructor(e,n,o,r){this.view=e,this.doc=n,this.docPath=o,this.getTextFromDoc=r,this.sub=void 0,this.isInitDispatch=!1,this.onRemoteUpdate=s=>{if(s.by!=="local")if(s.by!=="checkout"){if(s.by==="import"){const i=[];let a=0;for(const{diff:l,path:c}of s.events){if(c.join("/")!==this.docPath.join("/")||l.type!=="text")continue;const d=l.diff;for(const h of d)h.insert?i.push({from:a,to:a,insert:h.insert}):h.delete?(i.push({from:a,to:a+h.delete}),a+=h.delete):h.retain!=null&&(a+=h.retain);i.length>0&&this.view.dispatch({changes:i,annotations:[Rr.of(this)]})}}}else this.view.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:this.getTextFromDoc(this.doc).toString()}],annotations:[Rr.of(this)]})},this.sub=n.subscribe(this.onRemoteUpdate),Promise.resolve().then(()=>{this.isInitDispatch=!0;const s=this.view.state.doc.toString(),i=this.getTextFromDoc(this.doc);s!==i.toString()&&e.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:i.toString()}]})})}update(e){if(this.isInitDispatch)return void(this.isInitDispatch=!1);if(!e.docChanged||e.transactions.length>0&&(e.transactions[0].annotation(Rr)===this||e.transactions[0].annotation(Rr)==="undo"))return;let n=0;e.changes.iterChanges((o,r,s,i,a)=>{const l=a.sliceString(0,a.length,`
119
+ `);o!==r&&this.getTextFromDoc(this.doc).delete(o+n,r-o),l.length>0&&this.getTextFromDoc(this.doc).insert(o+n,l),n+=l.length-(r-o)}),this.doc.commit()}destroy(){var e;(e=this.sub)==null||e.call(this),this.sub=void 0}}const Jt=mt.get("rtc"),_x=Jt.get("awareness").disabled(),Cu="awareness:",Pr=vt(void 0),Ft=new Ej,fl=new class{constructor(t,e=3e4){this.listeners=new Set,this.inner=new JF(t,e),this.peer=t,this.timeout=e}apply(t,e="remote"){const{updated:n,added:o}=this.inner.apply(t);this.listeners.forEach(r=>{r({updated:n,added:o,removed:[]},e)}),this.startTimerIfNotEmpty()}setLocalState(t){const e=this.inner.getState(this.peer)==null;this.inner.setLocalState(t),e?this.listeners.forEach(n=>{n({updated:[],added:[this.inner.peer()],removed:[]},"local")}):this.listeners.forEach(n=>{n({updated:[this.inner.peer()],added:[],removed:[]},"local")}),this.startTimerIfNotEmpty()}getLocalState(){return this.inner.getState(this.peer)}getAllStates(){return this.inner.getAllStates()}encode(t){return this.inner.encode(t)}encodeAll(){return this.inner.encodeAll()}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}peers(){return this.inner.peers()}destroy(){clearInterval(this.timer),this.listeners.clear()}startTimerIfNotEmpty(){this.inner.isEmpty()||this.timer!=null||(this.timer=setInterval(()=>{const t=this.inner.removeOutdated();t.length>0&&this.listeners.forEach(e=>{e({updated:[],added:[],removed:t},"timeout")}),this.inner.isEmpty()&&(clearInterval(this.timer),this.timer=void 0)},this.timeout/2))}}(Ft.peerIdStr),ju=rP(()=>{Jt.debug("creating websocket");const t=eC().getWsSyncURL(mC()).toString(),e=new SF(t,void 0,{maxRetries:10,debug:!1,startClosed:!0,connectionTimeout:1e4});return Promise.resolve().then(async()=>{await tC(),sP()==="edit"&&e.reconnect()}),e.addEventListener("message",async n=>{const o=n.data,r=await o.arrayBuffer(),s=new Uint8Array(r);if(function(i,a){return new TextDecoder().decode(i.slice(0,a.length))===a}(s,Cu)){const i=function(a,l){return a.slice(l.length)}(s,Cu);return fl.apply(i),void _x.debug("applied awareness update")}Ft.import(s),Jt.debug("imported doc change. new doc:",Ft.toJSON()),Qe.get(Pr)!==Ft&&Qe.set(Pr,Ft)}),e.addEventListener("open",()=>{Jt.debug("websocket open")}),e.addEventListener("close",n=>{Jt.warn("websocket close",n),Qe.get(Pr)===Ft&&Qe.set(Pr,void 0)}),e});function Su(t,e,n=""){if(tn())return{extension:[],code:n};const o=Ft.getByPath(`codes/${t}`)!==void 0,r=Ft.getMap("codes").getOrCreateContainer(t,new cp);o||(Jt.log("initializing code for new cell",n),r.insert(0,n));const s={get name(){return Qe.get(pC)||"Anonymous"},get colorClassName(){return(i=>{if(typeof i=="string"){let a=0;for(let l=0;l<i.length;l++)a=(a<<5)-a+i.charCodeAt(l),a=Math.trunc(a);return hl[Math.abs(a)%hl.length]}return hl[i%hl.length]})(this.name)}};return{code:n.toString(),extension:[P5(t),L5(t),F5(Ft,fl,s,()=>r,t),D5(Ft,["codes",t],()=>r)]}}function P5(t){const e=(o,r)=>{const s=o.state.field(Oc).type,i=r.toString();i&&i!==s&&(Jt.debug(`[incoming] setting language type: ${s} -> ${i}`),gr(o,{language:i,keepCodeAsIs:!0}))},n=(o,r)=>{const s=o.state.field(Wm),i=r.toJSON();Yi(s,i)||o.dispatch({effects:[hC.of(i)],annotations:[Rr.of(!0)]})};return $n.define(o=>{let r;return Promise.resolve().then(()=>{const s=Ft.getByPath(`languages/${t}`);if(!s)return void Jt.error("no language container found for cell",t);Un(s instanceof cp,"language type is not a LoroText");const i=Ft.getByPath(`language_metadata/${t}`);i?(Un(i instanceof Ij,"language metadata is not a LoroMap"),e(o,s),n(o,i),r=Ft.subscribe(a=>{if(a.origin==="local")return;const l=a.events.some(d=>d.target===s.id),c=a.events.some(d=>d.target===i.id);l&&e(o,s),c&&n(o,i)})):Jt.error("no language metadata container found for cell",t)}),{destroy(){r()}}})}function L5(t){const e=Ft.getMap("languages").getOrCreateContainer(t,new cp),n=Ft.getMap("language_metadata").getOrCreateContainer(t,new Ij);return We.updateListener.of(o=>{const r=e.toString()!=="";if(!o.docChanged&&r)return;if(!r){const i=Hm(o.state).type;gr(o.view,{language:i}),Jt.debug("no initial language, setting default to",i),e.delete(0,e.length),e.insert(0,i),Jt.debug("no initial language metadata, setting default to",o.state.field(Wm));const a=o.state.field(Wm);for(const l of Object.keys(a))n.set(l,a[l]);return void Ft.commit()}let s=!1;for(const i of o.transactions)if(!i.annotation(Rr)){for(const a of i.effects)if(a.is(oP)&&e.toString()!==a.value.type&&(Jt.debug(`[outgoing] language change: ${e} -> ${a.value.type}`),e.delete(0,e.length),e.insert(0,a.value.type),s=!0),a.is(hC)||a.is(fC)){const l=a.value;a.is(fC)?(Jt.debug("[outgoing] setting language metadata: ",l),n.clear()):Jt.debug("[outgoing] updating language metadata: ",l);for(const c of Object.keys(l))n.set(c,l[c]);s=!0}}s&&Ft.commit()})}function F5(t,e,n,o,r,s){const i=`loro:cell:${r}`;return[ku,uC({above:!0,class:"loro-cursor-layer",update:Nx,markers:a=>{const{remoteCursors:l,isCheckout:c}=a.state.field(ku);return c?[]:[...l.values()].flatMap(d=>{var f,m;const h=Qn.cursor(d.cursor.anchor);return ul.createCursor(a,h,((f=d.user)==null?void 0:f.name)||"unknown",((m=d.user)==null?void 0:m.colorClassName)||"")})}}),uC({above:!1,class:"loro-selection-layer",update:Nx,markers:a=>{const{remoteCursors:l,isCheckout:c}=a.state.field(ku);return c?[]:[...l.entries()].filter(([,d])=>d.cursor.head!==void 0&&d.cursor.anchor!==d.cursor.head).flatMap(([,d])=>{var f;const h=Qn.range(d.cursor.anchor,d.cursor.head);return tP.forRange(a,`loro-selection ${((f=d.user)==null?void 0:f.colorClassName)||""}`,h)})}}),$n.define(a=>new T5(a,t,n,e,o,i,s)),$n.define(a=>new M5(a,t,e,i)),I5]}function ml(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}Lc()&&ju(),Ft.subscribeLocalUpdates(t=>{Jt.debug("local update, sending to server"),ju().send(t)}),fl.addListener((t,e)=>{const n=[...t.added,...t.removed,...t.updated];e==="local"&&(_x.debug("awareness changes",n),ju().send(function(o,r){const s=new TextEncoder().encode(o);return new Uint8Array([...s,...r])}(Cu,fl.encode(n))))});var Ix={modified:{doc:""},original:{doc:""}},Ax=M.createContext(Ix);function z5(t,e){return wt({},t,e,{modified:wt({},t.modified,e.modified),original:wt({},t.original,e.original)})}var Nu=()=>M.useContext(Ax),B5=t=>{var{children:e,theme:n}=t,[o,r]=M.useReducer(z5,wt({},Ix,{theme:n}));return M.useEffect(()=>r({theme:n}),[n]),u.jsx(Ax.Provider,{value:wt({},o,{dispatch:r}),children:e})},U5=["extensions","value","selection","onChange"],Tx=t=>{var{extensions:e=[],value:n,selection:o,onChange:r}=t,s=aa(t,U5),{theme:i,dispatch:a}=Nu(),l=js(wt({},s,{theme:i}));return M.useEffect(()=>a({original:{doc:n,selection:o,extensions:[...l,...e]},originalExtension:{onChange:r,option:s,extension:[e]}}),[t]),null};Tx.displayName="CodeMirrorMerge.Original";var $5=["extensions","value","selection","onChange"],Mx=t=>{var{extensions:e=[],value:n,selection:o,onChange:r}=t,s=aa(t,$5),{theme:i,dispatch:a}=Nu(),l=js(wt({},s,{theme:i}));return M.useEffect(()=>{a({modified:{doc:n,selection:o,extensions:[...l,...e]},modifiedExtension:{onChange:r,option:s,extension:[e]}})},[t]),null};Mx.displayName="CodeMirrorMerge.Modified";class Et{constructor(e,n,o,r){this.fromA=e,this.toA=n,this.fromB=o,this.toB=r}offset(e,n=e){return new Et(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function lr(t,e,n,o,r,s){if(t==o)return[];let i=Au(t,e,n,o,r,s),a=Tu(t,e+i,n,o,r+i,s),l=(n-=a)-(e+=i),c=(s-=a)-(r+=i);if(!l||!c)return[new Et(e,n,r,s)];if(l>c){let h=t.slice(e,n).indexOf(o.slice(r,s));if(h>-1)return[new Et(e,e+h,r,r),new Et(e+h+c,n,s,s)]}else if(c>l){let h=o.slice(r,s).indexOf(t.slice(e,n));if(h>-1)return[new Et(e,e,r,r+h),new Et(n,n,r+h+l,s)]}if(l==1||c==1)return[new Et(e,n,r,s)];let d=Rx(t,e,n,o,r,s);if(d){let[h,f,m]=d;return lr(t,e,h,o,r,f).concat(lr(t,h+m,n,o,f+m,s))}return function(h,f,m,g,x,p){let b=m-f,y=p-x;if(ii<1e9&&Math.min(b,y)>16*ii||ai>0&&Date.now()>ai)return Math.min(b,y)>64*ii?[new Et(f,m,x,p)]:Px(h,f,m,g,x,p);let v=Math.ceil((b+y)/2);_u.reset(v),Iu.reset(v);let w=(j,E)=>h.charCodeAt(f+j)==g.charCodeAt(x+E),S=(j,E)=>h.charCodeAt(m-j-1)==g.charCodeAt(p-E-1),C=(b-y)%2!=0?Iu:null,N=C?null:_u;for(let j=0;j<v;j++){if(j>ii||ai>0&&!(63&j)&&Date.now()>ai)return Px(h,f,m,g,x,p);let E=_u.advance(j,b,y,v,C,!1,w)||Iu.advance(j,b,y,v,N,!0,S);if(E)return V5(h,f,m,f+E[0],g,x,p,x+E[1])}return[new Et(f,m,x,p)]}(t,e,n,o,r,s)}let ii=1e9,ai=0,Eu=!1;class Ox{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,o,r,s,i,a){for(let l=-e+this.start;l<=e-this.end;l+=2){let c=r+l,d=l==-e||l!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,h=d-l;for(;d<n&&h<o&&a(d,h);)d++,h++;if(this.vec[c]=d,d>n)this.end+=2;else if(h>o)this.start+=2;else if(s){let f=r+(n-o)-l;if(f>=0&&f<this.len&&s.vec[f]!=-1){if(i){let m=s.vec[f];if(m>=n-d)return[m,r+m-f]}else if(d>=n-s.vec[f])return[d,h]}}}return null}}const _u=new Ox,Iu=new Ox;function V5(t,e,n,o,r,s,i,a){let l=!1;return Lr(t,o)||++o!=n||(l=!0),Lr(r,a)||++a!=i||(l=!0),l?[new Et(e,n,s,i)]:lr(t,e,o,r,s,a).concat(lr(t,o,n,r,a,i))}function Dx(t,e){let n=1,o=Math.min(t,e);for(;n<o;)n<<=1;return n}function Au(t,e,n,o,r,s){if(e==n||e==s||t.charCodeAt(e)!=o.charCodeAt(r))return 0;let i=Dx(n-e,s-r);for(let a=e,l=r;;){let c=a+i,d=l+i;if(c>n||d>s||t.slice(a,c)!=o.slice(l,d)){if(i==1)return a-e-(Lr(t,a)?0:1);i>>=1}else{if(c==n||d==s)return c-e;a=c,l=d}}}function Tu(t,e,n,o,r,s){if(e==n||r==s||t.charCodeAt(n-1)!=o.charCodeAt(s-1))return 0;let i=Dx(n-e,s-r);for(let a=n,l=s;;){let c=a-i,d=l-i;if(c<e||d<r||t.slice(c,a)!=o.slice(d,l)){if(i==1)return n-a-(Lr(t,a)?0:1);i>>=1}else{if(c==e||d==r)return n-c;a=c,l=d}}}function Mu(t,e,n,o,r,s,i,a){let l=o.slice(r,s),c=null;for(;;){if(c||i<a)return c;for(let d=e+i;;){Lr(t,d)||d++;let h=d+i;if(Lr(t,h)||(h+=h==d+1?1:-1),h>=n)break;let f=t.slice(d,h),m=-1;for(;(m=l.indexOf(f,m+1))!=-1;){let g=Au(t,h,n,o,r+m+f.length,s),x=Tu(t,e,d,o,r,r+m),p=f.length+g+x;(!c||c[2]<p)&&(c=[d-x,r+m-x,p])}d=h}if(a<0)return c;i>>=1}}function Rx(t,e,n,o,r,s){let i=n-e,a=s-r;if(i<a){let l=Rx(o,r,s,t,e,n);return l&&[l[1],l[0],l[2]]}return i<4||2*a<i?null:Mu(t,e,n,o,r,s,Math.floor(i/4),-1)}function Px(t,e,n,o,r,s){Eu=!0;let i,a=n-e,l=s-r;if(a<l){let f=Mu(o,r,s,t,e,n,Math.floor(a/6),50);i=f&&[f[1],f[0],f[2]]}else i=Mu(t,e,n,o,r,s,Math.floor(l/6),50);if(!i)return[new Et(e,n,r,s)];let[c,d,h]=i;return lr(t,e,c,o,r,d).concat(lr(t,c+h,n,o,d+h,s))}function Lx(t,e){for(let n=1;n<t.length;n++){let o=t[n-1],r=t[n];o.toA>r.fromA-e&&o.toB>r.fromB-e&&(t[n-1]=new Et(o.fromA,r.toA,o.fromB,r.toB),t.splice(n--,1))}}let cr;try{cr=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Fx(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function zx(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?Fx(n)?1:0:cr?qx(n)&&e!=t.length-1?cr.test(t.slice(e,e+2))?2:0:cr.test(String.fromCharCode(n))?1:0:0}function Bx(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?Fx(n)?1:0:cr?Gx(n)&&e!=1?cr.test(t.slice(e-2,e))?2:0:cr.test(String.fromCharCode(n))?1:0:0}const Ux=8;function $x(t,e,n){if(e==t.length||!Bx(t,e))return e;for(let o=e,r=e+n,s=0;s<Ux;s++){let i=zx(t,o);if(!i||o+i>r)return o;o+=i}return e}function Vx(t,e,n){if(!e||!zx(t,e))return e;for(let o=e,r=e-n,s=0;s<Ux;s++){let i=Bx(t,o);if(!i||o-i<r)return o;o-=i}return e}function Hx(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function Wx(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const qx=t=>t>=55296&&t<=56319,Gx=t=>t>=56320&&t<=57343;function Lr(t,e){return!e||e==t.length||!qx(t.charCodeAt(e-1))||!Gx(t.charCodeAt(e))}function H5(t,e,n){var o;return ii=((o=n==null?void 0:n.scanLimit)!==null&&o!==void 0?o:1e9)>>1,ai=n!=null&&n.timeout?Date.now()+n.timeout:0,Eu=!1,function(r,s,i){for(;;){Lx(i,1);let a=!1;for(let l=0;l<i.length;l++){let c,d,h=i[l];(c=Au(r,h.fromA,h.toA,s,h.fromB,h.toB))&&(h=i[l]=new Et(h.fromA+c,h.toA,h.fromB+c,h.toB)),(d=Tu(r,h.fromA,h.toA,s,h.fromB,h.toB))&&(h=i[l]=new Et(h.fromA,h.toA-d,h.fromB,h.toB-d));let f=h.toA-h.fromA,m=h.toB-h.fromB;if(f&&m)continue;let g=h.fromA-(l?i[l-1].toA:0),x=(l<i.length-1?i[l+1].fromA:r.length)-h.toA;if(!g||!x)continue;let p=f?r.slice(h.fromA,h.toA):s.slice(h.fromB,h.toB);g<=p.length&&r.slice(h.fromA-g,h.fromA)==p.slice(p.length-g)?(i[l]=new Et(h.fromA-g,h.toA-g,h.fromB-g,h.toB-g),a=!0):x<=p.length&&r.slice(h.toA,h.toA+x)==p.slice(0,x)&&(i[l]=new Et(h.fromA+x,h.toA+x,h.fromB+x,h.toB+x),a=!0)}if(!a)break}return i}(t,e,lr(t,0,t.length,e,0,e.length))}function Yx(){return!Eu}function Kx(t,e,n){return function(o,r,s){for(let i=0,a=0;a<o.length;a++){let l=o[a],c=l.toA-l.fromA,d=l.toB-l.fromB;if(c&&d||c>3||d>3){let h=a==o.length-1?r.length:o[a+1].fromA,f=l.fromA-i,m=h-l.toA,g=Vx(r,l.fromA,f),x=$x(r,l.toA,m),p=l.fromA-g,b=x-l.toA;if((!c||!d)&&p&&b){let y=Math.max(c,d),[v,w,S]=c?[r,l.fromA,l.toA]:[s,l.fromB,l.toB];y>p&&r.slice(g,l.fromA)==v.slice(S-p,S)?(l=o[a]=new Et(g,g+c,l.fromB-p,l.toB-p),g=l.fromA,x=$x(r,l.toA,h-l.toA)):y>b&&r.slice(l.toA,x)==v.slice(w,w+b)&&(l=o[a]=new Et(x-c,x,l.fromB+b,l.toB+b),x=l.toA,g=Vx(r,l.fromA,l.fromA-i)),p=l.fromA-g,b=x-l.toA}if(p||b)l=o[a]=new Et(l.fromA-p,l.toA+b,l.fromB-p,l.toB+b);else if(c){if(!d){let y,v=Wx(r,l.fromA,l.toA),w=v<0?-1:Hx(r,l.toA,l.fromA);v>-1&&(y=v-l.fromA)<=m&&r.slice(l.fromA,v)==r.slice(l.toA,l.toA+y)?l=o[a]=l.offset(y):w>-1&&(y=l.toA-w)<=f&&r.slice(l.fromA-y,l.fromA)==r.slice(w,l.toA)&&(l=o[a]=l.offset(-y))}}else{let y,v=Wx(s,l.fromB,l.toB),w=v<0?-1:Hx(s,l.toB,l.fromB);v>-1&&(y=v-l.fromB)<=m&&s.slice(l.fromB,v)==s.slice(l.toB,l.toB+y)?l=o[a]=l.offset(y):w>-1&&(y=l.toB-w)<=f&&s.slice(l.fromB-y,l.fromB)==s.slice(w,l.toB)&&(l=o[a]=l.offset(-y))}}i=l.toA}return Lx(o,3),o}(H5(t,e,n),t,e)}const Wn=vr.define({combine:t=>t[0]}),Ou=Tt.define(),W5=vr.define(),Fr=vn.define({create:t=>null,update(t,e){for(let n of e.effects)n.is(Ou)&&(t=n.value);for(let n of e.state.facet(W5))t=n(t,e);return t}});class zr{constructor(e,n,o,r,s,i=!0){this.changes=e,this.fromA=n,this.toA=o,this.fromB=r,this.toB=s,this.precise=i}offset(e,n){return e||n?new zr(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,o){return Zx(Kx(e.toString(),n.toString(),o),e,n,0,0,Yx())}static updateA(e,n,o,r,s){return tb(eb(e,r,!0,o.length),e,n,o,s)}static updateB(e,n,o,r,s){return tb(eb(e,r,!1,n.length),e,n,o,s)}}function Xx(t,e,n,o){let r=n.lineAt(t),s=o.lineAt(e);return r.to==t&&s.to==e&&t<n.length&&e<o.length?[t+1,e+1]:[r.from,s.from]}function Jx(t,e,n,o){let r=n.lineAt(t),s=o.lineAt(e);return r.from==t&&s.from==e?[t,e]:[r.to+1,s.to+1]}function Zx(t,e,n,o,r,s){let i=[];for(let a=0;a<t.length;a++){let l=t[a],[c,d]=Xx(l.fromA+o,l.fromB+r,e,n),[h,f]=Jx(l.toA+o,l.toB+r,e,n),m=[l.offset(-c+o,-d+r)];for(;a<t.length-1;){let g=t[a+1],[x,p]=Xx(g.fromA+o,g.fromB+r,e,n);if(x>h+1&&p>f+1)break;m.push(g.offset(-c+o,-d+r)),[h,f]=Jx(g.toA+o,g.toB+r,e,n),a++}i.push(new zr(m,c,Math.max(c,h),d,Math.max(d,f),s))}return i}const pl=1e3;function Qx(t,e,n,o){let r=0,s=t.length;for(;;){if(r==s){let d=0,h=0;r&&({toA:d,toB:h}=t[r-1]);let f=e-(n?d:h);return[d+f,h+f]}let i=r+s>>1,a=t[i],[l,c]=n?[a.fromA,a.toA]:[a.fromB,a.toB];if(l>e)s=i;else{if(!(c<=e))return o?[a.fromA,a.fromB]:[a.toA,a.toB];r=i+1}}}function eb(t,e,n,o){let r=[];return e.iterChangedRanges((s,i,a,l)=>{let c=0,d=n?e.length:o,h=0,f=n?o:e.length;s>pl&&([c,h]=Qx(t,s-pl,n,!0)),i<e.length-pl&&([d,f]=Qx(t,i+pl,n,!1));let m,g=l-a-(i-s),[x,p]=n?[g,0]:[0,g];r.length&&(m=r[r.length-1]).toA>=c?r[r.length-1]={fromA:m.fromA,fromB:m.fromB,toA:d,toB:f,diffA:m.diffA+x,diffB:m.diffB+p}:r.push({fromA:c,toA:d,fromB:h,toB:f,diffA:x,diffB:p})}),r}function tb(t,e,n,o,r){if(!t.length)return e;let s=[];for(let i=0,a=0,l=0,c=0;;i++){let d=i==t.length?null:t[i],h=d?d.fromA+a:n.length,f=d?d.fromB+l:o.length;for(;c<e.length;){let p=e[c];if(p.toA+a>h||p.toB+l>f)break;s.push(p.offset(a,l)),c++}if(!d)break;let m=d.toA+a+d.diffA,g=d.toB+l+d.diffB,x=Kx(n.sliceString(h,m),o.sliceString(f,g),r);for(let p of Zx(x,n,o,h,f,Yx()))s.push(p);for(a+=d.diffA,l+=d.diffB;c<e.length;){let p=e[c];if(p.fromA+a>m&&p.fromB+l>g)break;c++}}return s}const q5={scanLimit:500},nb=$n.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=sb(t))}update(t){var e,n;(t.docChanged||t.viewportChanged||(e=t.startState,n=t.state,e.field(Fr,!1)!=n.field(Fr,!1))||function(o,r){return o.facet(Wn)!=r.facet(Wn)}(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=sb(t.view))}},{decorations:t=>t.deco}),gl=To.low(aP({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(nb))===null||e===void 0?void 0:e.gutter)||lP.empty}})),ob=ot.line({class:"cm-changedLine"}),G5=ot.mark({class:"cm-changedText"}),Y5=ot.mark({tagName:"ins",class:"cm-insertedLine"}),K5=ot.mark({tagName:"del",class:"cm-deletedLine"}),rb=new class extends cP{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function X5(t,e,n,o,r,s){let i=n?t.fromA:t.fromB,a=n?t.toA:t.toB,l=0;if(i!=a){r.add(i,i,ob),r.add(i,a,n?K5:Y5),s&&s.add(i,i,rb);for(let c=e.iterRange(i,a-1),d=i;!c.next().done;){if(c.lineBreak){d++,r.add(d,d,ob),s&&s.add(d,d,rb);continue}let h=d+c.value.length;if(o)for(;l<t.changes.length;){let f=t.changes[l],m=i+(n?f.fromA:f.fromB),g=i+(n?f.toA:f.toB),x=Math.max(d,m),p=Math.min(h,g);if(x<p&&r.add(x,p,G5),!(g<h))break;l++}d=h}}}function sb(t){let e=t.state.field(Fr),{side:n,highlightChanges:o,markGutter:r,overrideChunk:s}=t.state.facet(Wn),i=n=="a",a=new gs,l=r?new gs:null,{from:c,to:d}=t.viewport;for(let h of e){if((i?h.fromA:h.fromB)>=d)break;(i?h.toA:h.toB)>c&&(s&&s(t.state,h,a,l)||X5(h,t.state.doc,i,o,a,l))}return{deco:a.finish(),gutter:l&&l.finish()}}class xl extends vs{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 bl=Tt.define({map:(t,e)=>t.map(e)}),li=vn.define({create:()=>ot.none,update:(t,e)=>{for(let n of e.effects)if(n.is(bl))return n.value;return t.map(e.changes)},provide:t=>We.decorations.from(t)}),Du=.01;function ib(t,e){if(t.size!=e.size)return!1;let n=t.iter(),o=e.iter();for(;n.value;){if(n.from!=o.from||Math.abs(n.value.spec.widget.height-o.value.spec.widget.height)>1)return!1;n.next(),o.next()}return!0}const Ru=Tt.define({map:(t,e)=>e.mapPos(t)});class J5 extends vs{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",o=>{let r=e.posAtDOM(o.target);e.dispatch({effects:Ru.of(r)});let{side:s,sibling:i}=e.state.facet(Wn);i&&i().dispatch({effects:Ru.of(Z5(r,e.state.field(Fr),s=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function Z5(t,e,n){let o=0,r=0;for(let s=0;;s++){let i=s<e.length?e[s]:null;if(!i||(n?i.fromA:i.fromB)>=t)return r+(t-o);[o,r]=n?[i.toA,i.toB]:[i.toB,i.toA]}}const Q5=vn.define({create:t=>ot.none,update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is(Ru)&&(t=t.update({filter:o=>o!=n.value}));return t},provide:t=>We.decorations.from(t)});function ab({margin:t=3,minSize:e=4}){return Q5.init(n=>function(o,r,s){let i=new gs,a=o.facet(Wn).side=="a",l=o.field(Fr),c=1;for(let d=0;;d++){let h=d<l.length?l[d]:null,f=d?c+r:1,m=h?o.doc.lineAt(a?h.fromA:h.fromB).number-1-r:o.doc.lines,g=m-f+1;if(g>=s&&i.add(o.doc.line(f).from,o.doc.line(m).to,ot.replace({widget:new J5(g),block:!0})),!h)break;c=o.doc.lineAt(Math.min(o.doc.length,a?h.toA:h.toB)).number}return i.finish()}(n,t,e))}const e_=We.styleModule.of(new iP({".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"}})),t_=We.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, .cm-inlineChangedLine":{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(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{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","&:before":{content:'"\u299A"',marginInlineEnd:"7px"},"&:after":{content:'"\u299A"',marginInlineStart:"7px"}},"&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"},".cm-inlineChangedLineGutter":{background:"#75d"}}),lb=new zm,yl=new zm;class cb{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||q5;let n=[To.low(nb),t_,e_,li,We.updateListener.of(h=>{this.measuring<0&&(h.heightChanged||h.viewportChanged)&&!h.transactions.some(f=>f.effects.some(m=>m.is(bl)))&&this.measure()})],o=[Wn.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&o.push(gl);let r=ra.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],We.editorAttributes.of({class:"cm-merge-a"}),yl.of(o),n]}),s=[Wn.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&s.push(gl);let i=ra.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],We.editorAttributes.of({class:"cm-merge-b"}),yl.of(s),n]});this.chunks=zr.build(r.doc,i.doc,this.diffConf);let a=[Fr.init(()=>this.chunks),lb.of(e.collapseUnchanged?ab(e.collapseUnchanged):[])];r=r.update({effects:Tt.appendConfig.of(a)}).state,i=i.update({effects:Tt.appendConfig.of(a)}).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 l=e.orientation||"a-b",c=document.createElement("div");c.className="cm-mergeViewEditor";let d=document.createElement("div");d.className="cm-mergeViewEditor",this.editorDOM.appendChild(l=="a-b"?c:d),this.editorDOM.appendChild(l=="a-b"?d:c),this.a=new We({state:r,parent:c,root:e.root,dispatchTransactions:h=>this.dispatch(h,this.a)}),this.b=new We({state:i,parent:d,root:e.root,dispatchTransactions:h=>this.dispatch(h,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,n){if(e.some(o=>o.docChanged)){let o=e[e.length-1],r=e.reduce((i,a)=>i.compose(a.changes),na.empty(e[0].startState.doc.length));this.chunks=n==this.a?zr.updateA(this.chunks,o.newDoc,this.b.state.doc,r,this.diffConf):zr.updateB(this.chunks,this.a.state.doc,o.newDoc,r,this.diffConf),n.update([...e,o.state.update({effects:Ou.of(this.chunks)})]);let s=n==this.a?this.b:this.a;s.update([s.state.update({effects:Ou.of(this.chunks)})]),this.scheduleMeasure()}else n.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let s=e.orientation!="b-a";if(s!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let i=this.a.dom.parentNode,a=this.b.dom.parentNode;i.remove(),a.remove(),this.editorDOM.insertBefore(s?i:a,this.editorDOM.firstChild),this.editorDOM.appendChild(s?a:i),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let s=!!this.revertDOM,i=this.revertToA,a=this.renderRevert;"revertControls"in e&&(s=!!e.revertControls,i=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(a=e.renderRevertControl),this.setupRevertControls(s,i,a)}let n="highlightChanges"in e,o="gutter"in e,r="collapseUnchanged"in e;if(n||o||r){let s=[],i=[];if(n||o){let a=this.a.state.facet(Wn),l=o?e.gutter!==!1:a.markGutter,c=n?e.highlightChanges!==!1:a.highlightChanges;s.push(yl.reconfigure([Wn.of({side:"a",sibling:()=>this.b,highlightChanges:c,markGutter:l}),l?gl:[]])),i.push(yl.reconfigure([Wn.of({side:"b",sibling:()=>this.a,highlightChanges:c,markGutter:l}),l?gl:[]]))}if(r){let a=lb.reconfigure(e.collapseUnchanged?ab(e.collapseUnchanged):[]);s.push(a),i.push(a)}this.a.dispatch({effects:s}),this.b.dispatch({effects:i})}this.scheduleMeasure()}setupRevertControls(e,n,o){this.revertToA=n,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=o,!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",r=>this.revertClicked(r)),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,n,o){let r=new gs,s=new gs,i=e.state.field(li).iter(),a=n.state.field(li).iter(),l=0,c=0,d=0,h=0,f=e.viewport,m=n.viewport;for(let b=0;;b++){let y=b<o.length?o[b]:null,v=y?y.fromA:e.state.doc.length,w=y?y.fromB:n.state.doc.length;if(l<v){let S=e.lineBlockAt(l).top+d-(n.lineBlockAt(c).top+h);S<-.01?(d-=S,r.add(l,l,ot.widget({widget:new xl(-S),block:!0,side:-1}))):S>Du&&(h+=S,s.add(c,c,ot.widget({widget:new xl(S),block:!0,side:-1})))}if(v>l+1e3&&l<f.from&&v>f.from&&c<m.from&&w>m.from){let S=Math.min(f.from-l,m.from-c);l+=S,c+=S,b--}else{if(!y)break;l=y.toA,c=y.toB}for(;i.value&&i.from<l;)d-=i.value.spec.widget.height,i.next();for(;a.value&&a.from<c;)h-=a.value.spec.widget.height,a.next()}for(;i.value;)d-=i.value.spec.widget.height,i.next();for(;a.value;)h-=a.value.spec.widget.height,a.next();let g=e.contentHeight+d-(n.contentHeight+h);g<Du?r.add(e.state.doc.length,e.state.doc.length,ot.widget({widget:new xl(-g),block:!0,side:1})):g>Du&&s.add(n.state.doc.length,n.state.doc.length,ot.widget({widget:new xl(g),block:!0,side:1}));let x=r.finish(),p=s.finish();ib(x,e.state.field(li))||e.dispatch({effects:bl.of(x)}),ib(p,n.state.field(li))||n.dispatch({effects:bl.of(p)})})(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,n=e.firstChild,o=this.a.viewport,r=this.b.viewport;for(let s=0;s<this.chunks.length;s++){let i=this.chunks[s];if(i.fromA>o.to||i.fromB>r.to)break;if(i.fromA<o.from||i.fromB<r.from)continue;let a=this.a.lineBlockAt(i.fromA).top+"px";for(;n&&+n.dataset.chunk<s;)n=db(n);n&&n.dataset.chunk==String(s)?(n.style.top!=a&&(n.style.top=a),n=n.nextSibling):e.insertBefore(this.renderRevertButton(a,s),n)}for(;n;)n=db(n)}renderRevertButton(e,n){let o;if(this.renderRevert)o=this.renderRevert();else{o=document.createElement("button");let r=this.a.state.phrase("Revert this chunk");o.setAttribute("aria-label",r),o.setAttribute("title",r),o.textContent=this.revertToLeft?"\u21DC":"\u21DD"}return o.style.top=e,o.setAttribute("data-chunk",String(n)),o}revertClicked(e){let n,o=e.target;for(;o&&o.parentNode!=this.revertDOM;)o=o.parentNode;if(o&&(n=this.chunks[o.dataset.chunk])){let[r,s,i,a,l,c]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],d=r.state.sliceDoc(i,Math.max(i,a-1));i!=a&&c<=s.state.doc.length&&(d+=r.state.lineBreak),s.dispatch({changes:{from:l,to:Math.min(s.state.doc.length,c),insert:d},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 db(t){let e=t.nextSibling;return t.remove(),e}var n_=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl","diffConfig","root"],o_=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],ub=q.forwardRef((t,e)=>{var{className:n,children:o,orientation:r,revertControls:s,highlightChanges:i,gutter:a,collapseUnchanged:l,destroyRerender:c=!0,renderRevertControl:d,diffConfig:h,root:f}=t,m=aa(t,n_),g=Nu(),{modified:x,modifiedExtension:p,original:b,originalExtension:y,theme:v,dispatch:w}=g,S=aa(g,o_),C=M.useRef(null),N=M.useRef(),j={orientation:r,revertControls:s,highlightChanges:i,gutter:a,collapseUnchanged:l,renderRevertControl:d,diffConfig:h,root:f};M.useImperativeHandle(e,()=>({container:C.current,view:N.current,modified:x,original:b,config:wt({a:b,b:x,parent:C.current},j)}),[C,N,x,b,j]);var E=We.updateListener.of(I=>{if(I.docChanged&&typeof(y==null?void 0:y.onChange)=="function"){var O=I.state.doc.toString();y==null||y.onChange(O,I)}}),T=We.updateListener.of(I=>{if(I.docChanged&&typeof(p==null?void 0:p.onChange)=="function"){var O=I.state.doc.toString();p==null||p.onChange(O,I)}});return M.useEffect(()=>{!N.current&&C.current&&y&&p&&(N.current=new cb(wt({a:wt({},b,{extensions:[...(y==null?void 0:y.extension)||[],...js(wt({},y==null?void 0:y.option,{theme:v})),E]}),b:wt({},x,{extensions:[...(p==null?void 0:p.extension)||[],...js(wt({},p==null?void 0:p.option,{theme:v})),T]}),parent:C.current},j)),w({view:N.current}))},[N,C,y,p]),M.useEffect(()=>{if(b&&b.doc&&N.current){var I,O,L=(I=N.current)==null?void 0:I.a.state.doc.toString();L!==b.doc&&((O=N.current)==null||O.a.dispatch({changes:{from:0,to:L.length,insert:b.doc||""}}))}if(x&&x.doc&&N.current){var D,R,P=(D=N.current)==null?void 0:D.b.state.doc.toString();P!==x.doc&&((R=N.current)==null||R.b.dispatch({changes:{from:0,to:P.length,insert:x.doc||""}}))}if(c&&N.current){var z=N.current.a.state.selection.ranges[0].from,_=N.current.b.state.selection.ranges[0].from;N.current.destroy(),N.current=new cb(wt({a:wt({},b,{extensions:[...(y==null?void 0:y.extension)||[],...js(wt({},y==null?void 0:y.option,{theme:v}))]}),b:wt({},x,{extensions:[...(p==null?void 0:p.extension)||[],...js(wt({},p==null?void 0:p.option,{theme:v}))]}),parent:C.current},j)),z&&(N.current.a.focus(),N.current.a.dispatch({selection:{anchor:z,head:z}})),_&&(N.current.b.focus(),N.current.b.dispatch({selection:{anchor:_,head:_}}))}},[N,v,C.current,b,x,y,p,c]),M.useEffect(()=>()=>N.current&&N.current.destroy(),[]),M.useEffect(()=>{if(N.current){var I={};S.orientation!==r&&(I.orientation=r),S.revertControls!==s&&(I.revertControls=s),S.highlightChanges!==i&&(I.highlightChanges=i),S.gutter!==a&&(I.gutter=a),S.collapseUnchanged!==l&&(I.collapseUnchanged=l),S.renderRevertControl!==d&&(I.collapseUnchanged=l),Object.keys(I).length&&w&&N.current&&(N.current.reconfigure(wt({},I)),w(wt({},I)))}},[w,N,r,s,i,a,l,d]),u.jsx("div",wt({ref:C,className:"cm-merge-theme"+(n?" "+n:"")},m,{children:o}))});ub.displayName="CodeMirrorMerge.Internal";var r_=["theme"],Br=q.forwardRef((t,e)=>{var{theme:n}=t,o=aa(t,r_);return u.jsx(B5,{theme:n,children:u.jsx(ub,wt({},o,{ref:e}))})});Br.Original=Tx,Br.Modified=Mx,Br.displayName="CodeMirrorMerge";const s_=Br.Original,i_=Br.Modified,hb=[uP(),We.lineWrapping],a_=t=>{const e=H.c(44),{className:n,onChange:o,initialPrompt:r,currentLanguageAdapter:s,currentCode:i,declineChange:a,acceptChange:l,enabled:c,children:d}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={},e[0]=h):h=e[0];const[f,m]=M.useState(h),[g,x]=Dt($j),p=qm(),{completion:b,input:y,stop:v,isLoading:w,setCompletion:S,setInput:C,handleSubmit:N}=dP({api:p.getAiURL("completion").toString(),headers:p.headers(),initialInput:r,streamProtocol:"text",experimental_throttle:100,body:{...f,includeOtherCode:g?Mc(i):"",code:i,language:s},onError:l_,onFinish:(G,W)=>{j(W.trimEnd())}}),j=S,E=q.useRef(null);let T;e[1]!==b?(T=b.trimEnd(),e[1]=b,e[2]=T):T=e[2];const I=T;let O,L,D,R;e[3]!==c?(O=()=>{var G;c&&(hP(()=>{const W=E.current;return!!(W!=null&&W.view)&&(W.view.focus(),!0)},{retries:3,delay:100,initialDelay:100}),fP((G=E.current)==null?void 0:G.view))},L=[c],e[3]=c,e[4]=O,e[5]=L):(O=e[4],L=e[5]),M.useEffect(O,L),e[6]!==c||e[7]!==r||e[8]!==C?(D=()=>{c&&C(r||"")},R=[c,r,C],e[6]=c,e[7]=r,e[8]=C,e[9]=D,e[10]=R):(D=e[9],R=e[10]),M.useEffect(D,R);const{theme:P}=Zo();let z;e[11]!==n?(z=xe("flex flex-col w-full rounded-[inherit]",n),e[11]=n,e[12]=z):z=e[12];const _=c&&"max-h-[400px] min-h-11 visible",k=!c&&"max-h-0 min-h-0 invisible";let B,A,U,$;e[13]!==k||e[14]!==_?(B=xe("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300",_,k),e[13]=k,e[14]=_,e[15]=B):B=e[15],e[16]!==l||e[17]!==I||e[18]!==a||e[19]!==c||e[20]!==N||e[21]!==g||e[22]!==y||e[23]!==w||e[24]!==j||e[25]!==x||e[26]!==C||e[27]!==v||e[28]!==P?(A=c&&u.jsxs(u.Fragment,{children:[u.jsx(Fi,{className:"text-(--blue-10) shrink-0",size:16}),u.jsx(Fc,{inputRef:E,theme:P,onClose:()=>{a(),j("")},value:y,onChange:G=>{C(G),m(xC({input:G}))},onSubmit:()=>{w||N()}}),w&&u.jsxs(ve,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:v,children:[u.jsx(zc,{className:"animate-spin mr-1",size:14}),"Stop"]}),!w&&I&&u.jsx(ve,{"data-testid":"accept-completion-button",variant:"text",size:"xs",className:"mb-0",disabled:w,onClick:()=>{l(I),j("")},children:u.jsx("span",{className:"text-(--grass-11) opacity-100",children:"Accept"})}),u.jsx("div",{className:"h-full w-px bg-border mx-2"}),u.jsx(Ne,{content:"Include code from other cells",children:u.jsxs("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[u.jsx(bC,{"data-testid":"include-other-cells-checkbox",id:"include-other-cells",checked:g,onCheckedChange:G=>x(!!G)}),u.jsx(xr,{htmlFor:"include-other-cells",className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),u.jsx(ve,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:w,onClick:()=>{v(),a(),j("")},children:u.jsx(wn,{className:"text-(--red-10)",size:16})})]}),e[16]=l,e[17]=I,e[18]=a,e[19]=c,e[20]=N,e[21]=g,e[22]=y,e[23]=w,e[24]=j,e[25]=x,e[26]=C,e[27]=v,e[28]=P,e[29]=A):A=e[29],e[30]!==B||e[31]!==A?(U=u.jsx("div",{className:B,children:A}),e[30]=B,e[31]=A,e[32]=U):U=e[32],e[33]!==I||e[34]!==i||e[35]!==c||e[36]!==o||e[37]!==P?($=I&&c&&u.jsxs(Br,{className:"cm",theme:P,children:[u.jsx(s_,{onChange:o,value:i,extensions:hb}),u.jsx(i_,{value:I,editable:!1,readOnly:!0,extensions:hb})]}),e[33]=I,e[34]=i,e[35]=c,e[36]=o,e[37]=P,e[38]=$):$=e[38];const X=(!I||!c)&&d;let Y;return e[39]!==U||e[40]!==$||e[41]!==X||e[42]!==z?(Y=u.jsxs("div",{className:z,children:[U,$,X]}),e[39]=U,e[40]=$,e[41]=X,e[42]=z,e[43]=Y):Y=e[43],Y};function l_(t){Je({title:"Completion failed",description:gC(t)})}const Pu="web application/x-marimo-cell",c_=ht({cells:mP(ht({code:at()})),version:gt("1.0")}),fb=t=>{const e=t===1?"Cell":`${t} cells`;Je({title:`${e} copied`,description:`${e} ${t===1?"has":"have"} been copied to clipboard.`})},d_=()=>{Je({title:"Copy failed",description:"Failed to copy cells to clipboard.",variant:"danger"})},u_=()=>{Je({title:"Nothing to paste",description:"No cell or text found in clipboard.",variant:"danger"})},h_=()=>{Je({title:"Paste failed",description:"Failed to read from clipboard",variant:"danger"})};class f_{constructor(){this.items={}}add(e,n){return ClipboardItem.supports(e)?typeof n=="string"?(this.items[e]=new Blob([n],{type:e}),this):(this.items[e]=new Blob([JSON.stringify(n)],{type:e}),this):(mt.warn(`ClipboardItem does not support ${e}`),this)}build(){return new ClipboardItem(this.items)}}const ci=vt(!1),di=new WeakMap;function mb(t){return{handle:e=>t(e),bulkHandle:e=>{let n=!0;try{for(const o of e)n=n&&t(o);return n}catch{return!1}}}}function ro(t){return{handle:e=>t([e]),bulkHandle:e=>t(e)}}function pb(t,e){const n=H.c(30),{canMoveX:o,editorView:r,cellActionDropdownRef:s}=e,{saveOrNameNotebook:i}=jd(),{saveCellConfig:a}=tt(),l=jt(Os),c=lt(),d=Am(),h=jt(ci),f=Ts(),m=je(yC),{copyCells:g,pasteAtCell:x}=function(){const D=lt(),R=Le(async z=>{const _=bn(),k=z.map(B=>_.cellData[B]).filter(Boolean);if(k.length!==0)try{const B={cells:k.map($=>({code:$.code})),version:"1.0"},A=k.map($=>$.code).join(`
120
+
121
+ `),U=new f_().add(Pu,B).add("text/plain",A).build();await navigator.clipboard.write([U]),fb(k.length)}catch(B){mt.error("Failed to copy cells to clipboard",B);try{const A=k.map(U=>U.code).join(`
122
+
123
+ `);await navigator.clipboard.writeText(A),fb(k.length)}catch{d_()}}}),P=Le(async(z,_)=>{const{before:k=!1}=_??{};try{const B=await navigator.clipboard.read();for(const U of B)if(U.types.includes(Pu)){const $=await U.getType(Pu),X=await $.text();try{const Y=c_.parse(JSON.parse(X));if(Y.cells.length===0)break;const G=z,W=Y.cells.reverse();for(const J of W)D.createNewCell({cellId:G,before:k,code:J.code,autoFocus:!0});return}catch(Y){mt.warn("Failed to parse clipboard cell data",Y)}}const A=await navigator.clipboard.readText();A.trim()?D.createNewCell({cellId:z,before:k,code:A,autoFocus:!0}):u_()}catch(B){mt.error("Failed to paste from clipboard",B),h_()}});return{copyCells:R,pasteAtCell:P}}(),p=Ta(),b=function(D){const R=H.c(2);let P,z;return R[0]!==D?(z=vt(_=>_(Nd).selected.has(D)),R[0]=D,R[1]=z):z=R[1],P=z,je(P)}(t),y=Fs(),v=Rs(),w=je(Ki);let S;n[0]!==y||n[1]!==p?(S={clear:()=>{y.clear(),p.clear()},extend:D=>{y.clear(),p.extend(D)},select:D=>{y.clear(),p.select(D)}},n[0]=y,n[1]=p,n[2]=S):S=n[2];const C=S,N=je(hc);let j;n[3]!==N?(j=(D,R)=>gm(N.getHotkey(D).key)(R.nativeEvent||R),n[3]=N,n[4]=j):j=n[4];const E=j,T=function(D){const R=H.c(11),P=wC(),z=lt(),_=jt(ci);let k,B,A;R[0]!==D||R[1]!==P?(k=()=>{P.focusCell({cellId:D})},R[0]=D,R[1]=P,R[2]=k):k=R[2],R[3]!==z||R[4]!==D||R[5]!==P||R[6]!==_?(B=()=>{_(!1),z.markTouched({cellId:D}),P.blurCell()},R[3]=z,R[4]=D,R[5]=P,R[6]=_,R[7]=B):B=R[7],R[8]!==k||R[9]!==B?(A={onFocusWithin:k,onBlurWithin:B},R[8]=k,R[9]=B,R[10]=A):A=R[10];const{focusWithinProps:U}=pP(A);return U}(t);let I;n[5]!==c||n[6]!==o||n[7]!==s||n[8]!==t||n[9]!==g||n[10]!==v||n[11]!==r||n[12]!==b||n[13]!==E||n[14]!==m||n[15]!==x||n[16]!==y||n[17]!==f||n[18]!==a||n[19]!==i||n[20]!==C||n[21]!==l||n[22]!==h||n[23]!==d||n[24]!==w?(I={onKeyDown:D=>{if(zn.fromInput(D))return void D.continuePropagation();const R={"Mod+ArrowUp":()=>(c.focusTopCell(),C.clear(),!0),"Mod+ArrowDown":()=>(c.focusBottomCell(),C.clear(),!0),ArrowUp:()=>(c.focusCell({cellId:t,where:"before"}),C.clear(),!0),ArrowDown:()=>(c.focusCell({cellId:t,where:"after"}),C.clear(),!0),ArrowLeft:()=>{if(o){const _=d.get(In),k=_.cellIds.findWithId(t),B=_.cellIds.indexOf(k),A=_.cellIds.at(B-1);if(A&&A.length>0){const U=gb(t,A);return c.focusCell({cellId:U,where:"exact"}),C.clear(),!0}}return!1},ArrowRight:()=>{if(o){const _=d.get(In),k=_.cellIds.findWithId(t),B=_.cellIds.indexOf(k),A=_.cellIds.at(B+1);if(A&&A.length>0){const U=gb(t,A);return c.focusCell({cellId:U,where:"exact"}),C.clear(),!0}}return!1},"Shift+ArrowUp":()=>{const _=d.get(la);C.extend({cellId:t,allCellIds:_});const k=_.findWithId(t).before(t);return k&&C.extend({cellId:k,allCellIds:_}),c.focusCell({cellId:t,where:"before"}),!0},"Shift+ArrowDown":()=>{const _=d.get(la);C.extend({cellId:t,allCellIds:_});const k=_.findWithId(t).after(t);return k&&C.extend({cellId:k,allCellIds:_}),c.focusCell({cellId:t,where:"after"}),!0},Escape:()=>!!b&&(C.clear(),!0),Enter:()=>(h(!0),CC(d,t),C.clear(),!0),s:()=>(i(),!0)};for(const[_,k]of Object.entries(R))if(gm(_)(D)&&k())return void D.preventDefault();const P={"cell.run":ro(_=>(f(_),!0)),"cell.runAndNewBelow":ro(_=>{f(_);const k=_[_.length-1];return c.moveToNextCell({cellId:k,before:!1}),!0}),"cell.runAndNewAbove":ro(_=>{f(_);const k=_[0];return c.moveToNextCell({cellId:k,before:!0}),!0}),"cell.createAbove":_=>(c.createNewCell({cellId:_,before:!0}),!0),"cell.createBelow":_=>(c.createNewCell({cellId:_,before:!1}),!0),"cell.moveUp":ro(_=>{const k=_[0];return d.get(In).cellIds.findWithId(k).first()!==k&&(_.forEach(B=>{c.moveCell({cellId:B,before:!0})}),!0)}),"cell.moveDown":ro(_=>{const k=_[_.length-1];return d.get(In).cellIds.findWithId(k).last()!==k&&([..._].reverse().forEach(B=>{c.moveCell({cellId:B,before:!1})}),!0)}),"cell.moveLeft":mb(_=>!!o&&(c.moveCell({cellId:_,direction:"left"}),!0)),"cell.moveRight":mb(_=>!!o&&(c.moveCell({cellId:_,direction:"right"}),!0)),"cell.hideCode":ro(_=>{var B;const k=!_.map(A=>{var $;return(($=d.get(In).cellData[A])==null?void 0:$.config)||null}).every(m_);a({configs:Object.fromEntries(_.map(A=>[A,{hide_code:k}]))});for(const A of _)c.updateCellConfig({cellId:A,config:{hide_code:k}});if(_.length===1){const A=_[0];c.focusCell({cellId:A,where:"after"}),k?((B=r.current)==null||B.contentDOM.blur(),kC(A)):CC(d,A)}return!0}),"cell.focusDown":_=>(c.focusCell({cellId:_,where:"after"}),!0),"cell.focusUp":_=>(c.focusCell({cellId:_,where:"before"}),!0),"cell.sendToBottom":ro(_=>(_.forEach(k=>{c.sendToBottom({cellId:k})}),!0)),"cell.sendToTop":ro(_=>([..._].reverse().forEach(k=>{c.sendToTop({cellId:k})}),!0)),"cell.aiCompletion":_=>{var B;let k=!1;return l(A=>(A==null?void 0:A.cellId)===_?(k=!0,null):{cellId:_}),k&&((B=r.current)==null||B.focus()),!0},"cell.cellActions":()=>{var _;return(_=s.current)==null||_.toggle(),!0},"command.copyCell":ro(_=>(g(_),!0)),"command.pasteCell":_=>(x(_),!0),"command.createCellBefore":_=>!zn.hasModifier(D)&&(c.createNewCell({cellId:_,before:!0,autoFocus:!0}),!0),"command.createCellAfter":_=>!zn.hasModifier(D)&&(c.createNewCell({cellId:_,before:!1,autoFocus:!0}),!0),"cell.delete":()=>{if(!w.keymap.destructive_delete)return!1;const _=z.size>=2?[...z]:[t],k=d.get(In);return!_.some(B=>{const{status:A}=k.cellRuntime[B];return A==="running"||A==="queued"})&&(y.idle?(y.submit(_),!0):(v({cellIds:_}),y.clear(),!0))}},z=function(_){return _.get(Nd).selected}(d);if(m==="vim"&&function(_,k){const B=function(Y){if(Y.ctrlKey||Y.metaKey||Y.altKey)return"";const G=Y.key.toLowerCase();return Y.shiftKey?`shift+${G}`:G}(_),A=_.target;if(!B||!A)return!1;const U=di.get(A);let $=B;U!=null&&U.timeout&&clearTimeout(U.timeout),U&&($=`${U.sequence} ${B}`);const X=k[$];if(X)return di.delete(A),X();if(!U){const Y=k[B];if(Y)return Y()}if(Object.keys(k).some(Y=>Y.startsWith(`${$} `))){const Y=window.setTimeout(()=>{di.delete(A)},500);return di.set(A,{sequence:$,timeout:Y}),!0}return di.delete(A),!1}(D.nativeEvent||D,{j:R.ArrowDown,k:R.ArrowUp,h:R.ArrowLeft,l:R.ArrowRight,i:R.Enter,"shift+j":R["Shift+ArrowDown"],"shift+k":R["Shift+ArrowUp"],"g g":R["Mod+ArrowUp"],"shift+g":R["Mod+ArrowDown"],"d d":()=>P["cell.delete"](),"y y":()=>(g(z.size>=2?[...z]:[t]),!0),p:()=>(x(t,{before:!1}),!0),"shift+p":()=>(x(t,{before:!0}),!0),o:()=>(c.createNewCell({cellId:t,before:!1,autoFocus:!0}),!0),"shift+o":()=>(c.createNewCell({cellId:t,before:!0,autoFocus:!0}),!0),u:()=>(c.undoDeleteCell(),!0)}))D.preventDefault();else{for(const[_,k]of Object.entries(P))if(E(_,D)){if(k instanceof Function){if(k(t))return void D.preventDefault()}else if(z.size>=2?k.bulkHandle([...z]):k.handle(t))return void D.preventDefault();return}D.continuePropagation()}}},n[5]=c,n[6]=o,n[7]=s,n[8]=t,n[9]=g,n[10]=v,n[11]=r,n[12]=b,n[13]=E,n[14]=m,n[15]=x,n[16]=y,n[17]=f,n[18]=a,n[19]=i,n[20]=C,n[21]=l,n[22]=h,n[23]=d,n[24]=w,n[25]=I):I=n[25];const{keyboardProps:O}=vC(I);let L;return n[26]!==T||n[27]!==b||n[28]!==O?(L=lm(T,O,{"data-selected":b,className:"data-[selected=true]:ring-1 data-[selected=true]:ring-(--blue-8) data-[selected=true]:ring-offset-1"}),n[26]=T,n[27]=b,n[28]=O,n[29]=L):L=n[29],L}function m_(t){return t==null?void 0:t.hide_code}function gb(t,e){const n=document.getElementById(Ri.create(t));if(!n)return e.first();const o=n.getBoundingClientRect();for(const r of e.topLevelIds){const s=document.getElementById(Ri.create(r));if(s){const i=s.getBoundingClientRect();if(o.top<=i.bottom&&o.bottom>=i.top)return r}}return e.last()}const p_=t=>{const e=H.c(24),{editorView:n,code:o,currentLanguageAdapter:r,onAfterToggle:s}=t;let i,a;e[0]!==o?(a=new Wi().isSupported(o)||o.trim()==="",e[0]=o,e[1]=a):a=e[1],i=a;const l=i;let c,d;e[2]!==o?(d=new Pc().isSupported(o)||o.trim()==="",e[2]=o,e[3]=d):d=e[3],c=d;const h=c&&r==="python";let f,m;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=u.jsx(Yo,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),e[4]=f):f=e[4],e[5]!==r||e[6]!==n||e[7]!==s||e[8]!==h?(m=u.jsx(Lu,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:h,icon:f,toType:"sql",displayName:"SQL",onAfterToggle:s}),e[5]=r,e[6]=n,e[7]=s,e[8]=h,e[9]=m):m=e[9];const g=l&&r==="python";let x,p,b,y,v;return e[10]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx(lc,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),e[10]=x):x=e[10],e[11]!==r||e[12]!==n||e[13]!==s||e[14]!==g?(p=u.jsx(Lu,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:g,icon:x,toType:"markdown",displayName:"Markdown",onAfterToggle:s}),e[11]=r,e[12]=n,e[13]=s,e[14]=g,e[15]=p):p=e[15],e[16]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(cc,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),e[16]=b):b=e[16],e[17]!==r||e[18]!==n?(y=u.jsx(Lu,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:!0,icon:b,toType:"python",displayName:"Python",onAfterToggle:Bn.NOOP}),e[17]=r,e[18]=n,e[19]=y):y=e[19],e[20]!==p||e[21]!==y||e[22]!==m?(v=u.jsxs("div",{className:"absolute right-3 top-2 z-20 flex hover-action gap-1",children:[m,p,y]}),e[20]=p,e[21]=y,e[22]=m,e[23]=v):v=e[23],v},Lu=t=>{const e=H.c(10),{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:r,icon:s,toType:i,displayName:a,onAfterToggle:l}=t;let c;e[0]!==n||e[1]!==l||e[2]!==i?(c=()=>{n&&(gr(n,{language:i}),l())},e[0]=n,e[1]=l,e[2]=i,e[3]=c):c=e[3];const d=c;if(!r||o===i)return null;const h=`View as ${a}`;let f,m;return e[4]!==d||e[5]!==s?(f=u.jsx(ve,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:d,children:s}),e[4]=d,e[5]=s,e[6]=f):f=e[6],e[7]!==h||e[8]!==f?(m=u.jsx(Ne,{content:h,children:f}),e[7]=h,e[8]=f,e[9]=m):m=e[9],m},xb=({theme:t,showPlaceholder:e,id:n,config:o,code:r,status:s,serializedEditorState:i,setEditorView:a,runCell:l,userConfig:c,editorViewRef:d,editorViewParentRef:h,hidden:f,hasOutput:m,showHiddenCode:g,languageAdapter:x,setLanguageAdapter:p,showLanguageToggles:b=!0})=>{var G;const[y,v]=Dt(Os),w=Ds(),{saveOrNameNotebook:S}=jd(),C=Fs(),{saveCellConfig:N}=tt(),j=s==="running"||s==="queued",E=lt(),T=ag(),I=x==="markdown",O=Le(()=>!j&&(C.idle&&c.keymap.destructive_delete?(C.submit([n]),!0):(w({cellId:n}),!0))),L=Le(()=>!j&&(l(),!0)),D=Le(()=>{const W=!o.hide_code;return N({configs:{[n]:{hide_code:W}}}),E.updateCellConfig({cellId:n,config:{hide_code:W}}),W}),R=je(ac),P=Le(()=>{Jn({autoInstantiate:R,createNewCell:E.createNewCell})}),z=gP(c),_=M.useMemo(()=>{const W=p5({cellId:n,showPlaceholder:e,enableAI:z,cellActions:{...E,afterToggleMarkdown:P,onRun:L,deleteCell:O,saveNotebook:S,createManyBelow:J=>{for(const V of[...J].reverse())E.createNewCell({code:V,before:!1,cellId:n,skipIfCodeExists:!0})},splitCell:T,toggleHideCode:D,aiCellCompletion:()=>{let J=!1;return v(V=>(V==null?void 0:V.cellId)===n?(J=!0,null):{cellId:n}),J}},completionConfig:c.completion,keymapConfig:c.keymap,lspConfig:c.language_servers,theme:t,hotkeys:new jC(c.keymap.overrides??{}),diagnosticsConfig:c.diagnostics,displayConfig:c.display});return W.push($n.define(J=>{const V=J.state.field(Oc);return p(V.type),{update(Q){const te=Q.state.field(Oc);p(te.type)}}}),We.updateListener.of(J=>{J.selectionSet&&J.state.selection.ranges.some(V=>V.from!==V.to)&&g({focus:!1})}),We.domEventHandlers({focus:()=>{g({focus:!1})}})),W},[n,c.keymap,c.completion,c.language_servers,c.display,c.diagnostics,z,t,e,E,T,D,O,L,v,P,p,g,S]),k=Lc(),B=Le(()=>{if(k){const J=Su(n,0,r);_.push(J.extension),r=J.code}const W=new We({state:ra.create({doc:r,extensions:_})});a(W),k||gr(W,{language:Hm(W.state).type})}),A=Le(()=>{if(Un(d.current!==null,"Editor view is not initialized"),k){const W=Su(n);_.push(W.extension)}d.current.dispatch({effects:[Tt.reconfigure.of([_]),xP(d.current,{completionConfig:c.completion,hotkeysProvider:new jC(c.keymap.overrides??{}),lspConfig:{...c.language_servers,diagnostics:c.diagnostics}})]})}),U=Le(()=>{if(Un(i,"Editor view is not initialized"),k){const J=Su(n,0,r);_.push(J.extension),r=J.code}const W=new We({state:ra.fromJSON(i,{doc:r,extensions:_},{history:bP})});k||gr(W,{language:Hm(W.state).type}),a(W),E.clearSerializedEditorState({cellId:n})});M.useEffect(()=>{i===null?d.current===null?B():A():U(),d.current!==null&&h&&h.current!==null&&h.current.replaceChildren(d.current.dom)},[B,A,U,d,h,i,_]),M.useEffect(()=>{const W=d.current;return()=>{W==null||W.destroy()}},[d]);const $=function(W,J){const V=H.c(9),Q=jt(ci),te=je(yC);let re;V[0]!==W||V[1]!==Q?(re=()=>{Q(!1),kC(W)},V[0]=W,V[1]=Q,V[2]=re):re=V[2];const ne=re;let ie;V[3]!==J||V[4]!==ne?(ie=()=>{if(!J.current)return void ne();const oe=J.current,ue=oe.state;ue.selection.main.from===ue.selection.main.to?ws(ue)!==null?tc(oe):ne():oe.dispatch({selection:Qn.single(ue.selection.main.from)})},V[3]=J,V[4]=ne,V[5]=ie):ie=V[5];const se=ie;let ae;V[6]!==se||V[7]!==te?(ae={onKeyDown:oe=>{te==="vim"?oe.key==="Escape"&&(oe.ctrlKey||oe.metaKey)&&se():oe.key==="Escape"&&se(),oe.continuePropagation()}},V[6]=se,V[7]=te,V[8]=ae):ae=V[8];const{keyboardProps:ge}=vC(ae);return ge}(n,d),X=f&&!I||f&&I&&!m;let Y="";return I&&f&&m?Y="h-0 overflow-hidden":f&&(Y="opacity-20 h-8 [&>div.cm-editor]:h-full [&>div.cm-editor]:overflow-hidden [&_.cm-panels]:hidden"),u.jsx(a_,{enabled:(y==null?void 0:y.cellId)===n,initialPrompt:y==null?void 0:y.initialPrompt,currentCode:((G=d.current)==null?void 0:G.state.doc.toString())??r,currentLanguageAdapter:x,declineChange:Le(()=>{var W;v(null),(W=d.current)==null||W.focus()}),onChange:Le(W=>{var J;(J=d.current)==null||J.dispatch({changes:{from:0,to:d.current.state.doc.length,insert:W}})}),acceptChange:Le(W=>{var J,V;(J=d.current)==null||J.dispatch({changes:{from:0,to:d.current.state.doc.length,insert:W}}),(V=d.current)==null||V.focus(),v(null)}),children:u.jsxs("div",{className:"relative w-full",...$,children:[X&&u.jsx(SC,{tooltip:"Edit code",className:"absolute inset-0 z-10",onClick:g}),u.jsx(bb,{className:Y,editorView:d.current,ref:h}),!f&&b&&u.jsx("div",{className:"absolute top-1 right-5",children:u.jsx(p_,{code:r,editorView:d.current,currentLanguageAdapter:x,onAfterToggle:P})})]})})},bb=q.forwardRef((t,e)=>{const n=H.c(10),{className:o,editorView:r}=t,s=M.useRef(null);let i,a,l,c,d;return n[0]!==r?(i=()=>{r!==null&&s.current!==null&&s.current.children.length===0&&s.current.append(r.dom)},a=[r,s],n[0]=r,n[1]=i,n[2]=a):(i=n[1],a=n[2]),M.useEffect(i,a),n[3]!==o?(l=xe("cm mathjax_ignore",o),n[3]=o,n[4]=l):l=n[4],n[5]!==e?(c=h=>{e?ml(e,s)(h):ml(s)(h)},n[5]=e,n[6]=c):c=n[6],n[7]!==l||n[8]!==c?(d=u.jsx("div",{className:l,ref:c,"data-testid":"cell-editor"}),n[7]=l,n[8]=c,n[9]=d):d=n[9],d});bb.displayName="CellCodeMirrorEditor";const Fu=Lc()?function(t){const e=n=>{const o=H.c(5),r=je(ln),[s,i]=Dt(Pr);if(r.state===Bt.CONNECTING||s===void 0){let l,c;return o[0]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx("span",{children:"Waiting for real-time collaboration connection..."}),o[0]=l):l=o[0],o[1]!==i?(c=u.jsx("div",{className:"flex h-full w-full items-baseline p-4",children:u.jsxs(Bc,{milliseconds:1e3,fallback:null,children:[l,u.jsx(ve,{variant:"link",onClick:()=>{i("disabled")},children:"Turn off real-time collaboration"})]})}),o[1]=i,o[2]=c):c=o[2],c}let a;return o[3]!==n?(a=u.jsx(t,{...n}),o[3]=n,o[4]=a):a=o[4],a};return e.displayName=`WithWaitUntilConnected(${t.displayName})`,e}(M.memo(xb)):M.memo(xb),g_=t=>{const e=H.c(10);let n,o,r,s;return e[0]!==t.left?(n=u.jsx("div",{className:"flex-1 flex item-center gap-2",children:t.left}),e[0]=t.left,e[1]=n):n=e[1],e[2]!==t.center?(o=u.jsx("div",{className:"flex-1 flex item-center gap-2 justify-center",children:t.center}),e[2]=t.center,e[3]=o):o=e[3],e[4]!==t.right?(r=u.jsx("div",{className:"flex-1 flex item-center gap-2 justify-end",children:t.right}),e[4]=t.right,e[5]=r):r=e[5],e[6]!==n||e[7]!==o||e[8]!==r?(s=u.jsxs("div",{className:"flex items-center gap-2 w-full px-3",children:[n,o,r]}),e[6]=n,e[7]=o,e[8]=r,e[9]=s):s=e[9],s},x_=t=>{const e=H.c(8);if(!t.canCollapse&&!t.isCollapsed)return null;const n=t.isCollapsed?"Expand":"Collapse";let o,r,s;return e[0]!==t.isCollapsed?(o=u.jsx("span",{children:u.jsx(b_,{isCollapsed:t.isCollapsed})}),e[0]=t.isCollapsed,e[1]=o):o=e[1],e[2]!==n||e[3]!==o?(r=u.jsx(Ne,{content:n,children:o}),e[2]=n,e[3]=o,e[4]=r):r=e[4],e[5]!==t.onClick||e[6]!==r?(s=u.jsx(ve,{variant:"text",size:"icon",onClick:t.onClick,children:r}),e[5]=t.onClick,e[6]=r,e[7]=s):s=e[7],s},b_=t=>{const e=H.c(2),{isCollapsed:n}=t;let o;return e[0]!==n?(o=n?u.jsx(zi,{className:"w-5 h-5 shrink-0"}):u.jsx(No,{className:"w-5 h-5 shrink-0"}),e[0]=n,e[1]=o):o=e[1],o},yb=M.memo(t=>{const e=H.c(24),{onClick:n,count:o,cellId:r}=t,s=Tm();let i;e[0]!==r||e[1]!==s?(i=yP(s,r),e[0]=r,e[1]=s,e[2]=i):i=e[2];const a=i;let l,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=xe("flex items-center justify-between w-[calc(100%-2rem)] h-9 bg-muted rounded-b mx-4 opacity-80 hover:opacity-100 cursor-pointer"),e[3]=l):l=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(c=u.jsx(vP,{className:"w-4 h-4 shrink-0"}),e[4]=c):c=e[4];const d=o===1?"cell":"cells";let h,f,m,g,x,p,b;return e[5]!==o||e[6]!==d?(h=u.jsxs(u.Fragment,{children:[c,u.jsxs("span",{className:"text-sm text-gray-500",children:[o," ",d," collapsed"]})]}),e[5]=o,e[6]=d,e[7]=h):h=e[7],e[8]!==a.errored?(f=a.errored&&u.jsx(Ne,{content:"Has errors",delayDuration:100,children:u.jsx(Lp,{className:"w-4 h-4 shrink-0 text-destructive"})}),e[8]=a.errored,e[9]=f):f=e[9],e[10]!==a.stale?(m=a.stale&&u.jsx(Ne,{content:"Has stale cells",delayDuration:100,children:u.jsx(NC,{className:"w-4 h-4 shrink-0 text-(--yellow-11)"})}),e[10]=a.stale,e[11]=m):m=e[11],e[12]!==a.runningOrQueued?(g=a.runningOrQueued&&u.jsx(Ne,{content:"Running",delayDuration:100,children:u.jsx(zc,{className:"w-4 h-4 shrink-0 animate-spin"})}),e[12]=a.runningOrQueued,e[13]=g):g=e[13],e[14]!==f||e[15]!==m||e[16]!==g?(x=u.jsxs(u.Fragment,{children:[f,m,g]}),e[14]=f,e[15]=m,e[16]=g,e[17]=x):x=e[17],e[18]!==h||e[19]!==x?(p=u.jsx(g_,{center:h,right:x}),e[18]=h,e[19]=x,e[20]=p):p=e[20],e[21]!==n||e[22]!==p?(b=u.jsx("div",{onClick:n,className:l,children:p}),e[21]=n,e[22]=p,e[23]=b):b=e[23],b});yb.displayName="CollapsedCellBanner";const vb=t=>{const e=H.c(31),{status:n,connectionState:o,onClick:r}=t,s=n==="running"||n==="queued";let i,a,l,c,d,h,f,m,g,x,p,b,y,v;if(e[0]!==o||e[1]!==s||e[2]!==r||e[3]!==n){const w=eo(o);let S;if(w){let C;e[14]!==o?(C=jc(o),e[14]=o,e[15]=C):C=e[15],S=C}else S=n==="running"?"A cell can't be deleted when it's running":n==="queued"?"A cell can't be deleted when it's queued to run":"Delete";a=Ne,g=S,x=!1,i=ve,l="ghost",c="icon",d=r,h="delete-button",f=zn.preventFocus,m=xe("hover:bg-transparent text-destructive/60 hover:text-destructive",(w||s)&&"inactive-button"),e[0]=o,e[1]=s,e[2]=r,e[3]=n,e[4]=i,e[5]=a,e[6]=l,e[7]=c,e[8]=d,e[9]=h,e[10]=f,e[11]=m,e[12]=g,e[13]=x}else i=e[4],a=e[5],l=e[6],c=e[7],d=e[8],h=e[9],f=e[10],m=e[11],g=e[12],x=e[13];return e[16]===Symbol.for("react.memo_cache_sentinel")?(p={boxShadow:"none"},b=u.jsx(uc,{size:14}),e[16]=p,e[17]=b):(p=e[16],b=e[17]),e[18]!==i||e[19]!==l||e[20]!==c||e[21]!==d||e[22]!==h||e[23]!==f||e[24]!==m?(y=u.jsx(i,{variant:l,size:c,onClick:d,"data-testid":h,onMouseDown:f,className:m,style:p,children:b}),e[18]=i,e[19]=l,e[20]=c,e[21]=d,e[22]=h,e[23]=f,e[24]=m,e[25]=y):y=e[25],e[26]!==a||e[27]!==y||e[28]!==g||e[29]!==x?(v=u.jsx(a,{content:g,usePortal:x,children:y}),e[26]=a,e[27]=y,e[28]=g,e[29]=x,e[30]=v):v=e[30],v},y_=t=>{const e=H.c(22),{cellId:n}=t,o=function(b){const y=H.c(16),v=je(Gg),w=Yg(),S=Rs();let C;y[0]!==b||y[1]!==v.entries?(C=v.entries.get(b),y[0]=b,y[1]=v.entries,y[2]=C):C=y[2];const N=C;if(!N){let I;return y[3]===Symbol.for("react.memo_cache_sentinel")?(I={isPending:!1},y[3]=I):I=y[3],I}if(v.entries.size!==1){let I;return y[4]!==N?(I={isPending:!0,shouldConfirmDelete:!1,...N},y[4]=N,y[5]=I):I=y[5],I}let j,E,T;return y[6]!==w||y[7]!==S||y[8]!==v.entries?(j=()=>{S({cellIds:[...v.entries.values()].map(R4)}),w.clear()},y[6]=w,y[7]=S,y[8]=v.entries,y[9]=j):j=y[9],y[10]!==w?(E=()=>w.clear(),y[10]=w,y[11]=E):E=y[11],y[12]!==N||y[13]!==j||y[14]!==E?(T={isPending:!0,...N,shouldConfirmDelete:!0,confirm:j,cancel:E},y[12]=N,y[13]=j,y[14]=E,y[15]=T):T=y[15],T}(n);if(!o.isPending)return null;if(o.type==="simple"){let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=xe("px-3 py-1.5","bg-(--amber-2) border-t border-(--amber-6)","animate-in slide-in-from-top-2 duration-200"),e[0]=b):b=e[0];const y=`pending-delete-${n}`;let v,w;return e[1]===Symbol.for("react.memo_cache_sentinel")?(v=u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Mm,{className:"w-3 h-3 text-(--amber-11) shrink-0"}),u.jsx("span",{className:"text-(--amber-11) text-xs",children:"Pending deletion"})]}),e[1]=v):v=e[1],e[2]!==y?(w=u.jsx("div",{className:b,"data-testid":y,children:v}),e[2]=y,e[3]=w):w=e[3],w}const r=o.executionDurationMs!==void 0,s=o.defs.size>0,i=Is(o.executionDurationMs??0);let a,l="Pending deletion";r&&s?l=`This cell took ${i} to run and contains variables referenced by other cells.`:r?l=`This cell took ${i} to run.`:s&&(l="This cell contains variables referenced by other cells."),e[4]===Symbol.for("react.memo_cache_sentinel")?(a=xe("px-4 py-3","bg-(--amber-2) border-t border-(--amber-6)","animate-in slide-in-from-top-2 duration-200"),e[4]=a):a=e[4];const c=`pending-delete-${n}`;let d,h,f,m,g,x,p;return e[5]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx(Mm,{className:"w-4 h-4 text-(--amber-11) mt-0.5 shrink-0"}),e[5]=d):d=e[5],e[6]!==l?(h=u.jsx("p",{className:"text-(--amber-11) font-medium",children:l}),e[6]=l,e[7]=h):h=e[7],e[8]!==s||e[9]!==o.defs?(f=s&&[...o.defs.entries()].map(w_),e[8]=s,e[9]=o.defs,e[10]=f):f=e[10],e[11]!==h||e[12]!==f?(m=u.jsxs("div",{className:"font-code text-sm text-[0.84375rem]",children:[h,f]}),e[11]=h,e[12]=f,e[13]=m):m=e[13],e[14]!==o?(g=o.shouldConfirmDelete&&u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"text-(--amber-11) mt-2 mb-3",children:"Are you sure you want to delete?"}),u.jsx(_m,{autoFocus:!0,children:u.jsxs("div",{className:"flex items-center gap-2",onKeyDown:k_,children:[u.jsx(ve,{size:"xs",variant:"ghost",onClick:()=>o.cancel(),className:"text-(--amber-11) hover:bg-(--amber-4) hover:text-(--amber-11)",children:"Cancel"}),u.jsx(ve,{size:"xs",variant:"secondary",onClick:()=>o.confirm(),className:"bg-(--amber-11) hover:bg-(--amber-12) text-white border-(--amber-11)",children:"Delete"})]})})]}),e[14]=o,e[15]=g):g=e[15],e[16]!==m||e[17]!==g?(x=u.jsxs("div",{className:"flex items-start gap-3",children:[d,u.jsxs("div",{className:"flex-1",children:[m,g]})]}),e[16]=m,e[17]=g,e[18]=x):x=e[18],e[19]!==c||e[20]!==x?(p=u.jsx("div",{className:a,"data-testid":c,children:x}),e[19]=c,e[20]=x,e[21]=p):p=e[21],p};function v_(t){return u.jsx("li",{className:"my-0.5 ml-8 text-(--amber-11)/60",children:u.jsx(Mo,{cellId:t})},t)}function w_(t){const[e,n]=t;return u.jsxs("div",{children:[u.jsxs("p",{className:"text-(--amber-11) mt-2",children:["'",u.jsx("span",{className:"font-mono",children:e}),"' is referenced by:"]}),u.jsx("ul",{className:"list-disc",children:n.map(v_)})]},e)}function k_(t){t.stopPropagation()}const C_=t=>{const e=H.c(27),{onClick:n,connectionState:o,needsRun:r,status:s,config:i,edited:a}=t,l=s==="disabled-transitively",c=s==="running"||s==="queued";let d,h;e[0]!==l||e[1]!==i.disabled||e[2]!==o||e[3]!==a||e[4]!==c||e[5]!==r?(d=eo(o)||c||!i.disabled&&l&&!a,h=function({connectionState:p,needsRun:b,loading:y,inactive:v}){return eo(p)?"disabled":b&&!y?"stale":y||v?"disabled":"green"}({connectionState:o,needsRun:r,loading:c,inactive:d}),e[0]=l,e[1]=i.disabled,e[2]=o,e[3]=a,e[4]=c,e[5]=r,e[6]=d,e[7]=h):(d=e[6],h=e[7]);const f=h;if(i.disabled){let p,b;return e[8]===Symbol.for("react.memo_cache_sentinel")?(p=u.jsx(Np,{}),e[8]=p):p=e[8],e[9]!==d||e[10]!==n||e[11]!==f?(b=u.jsx(Vs,{tooltip:"Add code to notebook",disabled:d,onClick:n,variant:f,"data-testid":"run-button",children:p}),e[9]=d,e[10]=n,e[11]=f,e[12]=b):b=e[12],b}if(!i.disabled&&l&&!a){let p,b;return e[13]===Symbol.for("react.memo_cache_sentinel")?(p=u.jsx(Sr,{strokeWidth:1.2}),e[13]=p):p=e[13],e[14]!==d||e[15]!==n||e[16]!==f?(b=u.jsx(Vs,{disabled:d,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:n,variant:f,"data-testid":"run-button",children:p}),e[14]=d,e[15]=n,e[16]=f,e[17]=b):b=e[17],b}let m,g,x;if(eo(o)){let p;e[18]!==o?(p=jc(o),e[18]=o,e[19]=p):p=e[19],m=p}else if(s==="queued")m="This cell is already queued to run";else if(s==="running")m="This cell is already running.";else{let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=Gt("cell.run"),e[20]=p):p=e[20],m=p}return e[21]===Symbol.for("react.memo_cache_sentinel")?(g=u.jsx(Sr,{strokeWidth:1.2}),e[21]=g):g=e[21],e[22]!==d||e[23]!==n||e[24]!==m||e[25]!==f?(x=u.jsx(Vs,{tooltip:m,disabled:d,onClick:n,variant:f,"data-testid":"run-button",children:g}),e[22]=d,e[23]=n,e[24]=m,e[25]=f,e[26]=x):x=e[26],x},wb=q.createContext(null),kb=M.memo(()=>M.use(wb));kb.displayName="DragHandle";const Cb=q.forwardRef((t,e)=>{const n=H.c(21);let o,r,s,i,a;n[0]!==t?({cellId:r,canMoveX:o,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==r?(i=r.toString(),n[4]=r,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:h,transition:f,isDragging:m}=_1(a);let g;n[8]!==h?(g=function(y){return!y||y.x===0&&y.y===0&&y.scaleX===1&&y.scaleY===1}(h)?null:h,n[8]=h,n[9]=g):g=n[9];const x=g,p=x==null?void 0:f;let b;return n[10]!==l||n[11]!==o||n[12]!==r||n[13]!==m||n[14]!==c||n[15]!==s||n[16]!==e||n[17]!==d||n[18]!==x||n[19]!==p?(b=u.jsx(jb,{ref:e,cellId:r,canMoveX:o,...s,attributes:l,listeners:c,setNodeRef:d,transform:x,transition:p,isDragging:m}),n[10]=l,n[11]=o,n[12]=r,n[13]=m,n[14]=c,n[15]=s,n[16]=e,n[17]=d,n[18]=x,n[19]=p,n[20]=b):b=n[20],b});Cb.displayName="SortableCell";const jb=q.forwardRef((t,e)=>{const n=H.c(37);let o,r,s,i,a,l,c,d,h,f;if(n[0]!==t){const{cellId:E,canMoveX:T,children:I,attributes:O,listeners:L,setNodeRef:D,transform:R,transition:P,isDragging:z,..._}=t;r=T,s=I,o=O,a=L,c=D,d=R,h=P,i=z,l=_,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=i,n[5]=a,n[6]=l,n[7]=c,n[8]=d,n[9]=h}else o=n[1],r=n[2],s=n[3],i=n[4],a=n[5],l=n[6],c=n[7],d=n[8],h=n[9];n[10]!==r||n[11]!==d?(f=d?Ic.Transform.toString({x:r?d.x:0,y:d.y,scaleX:1,scaleY:1}):void 0,n[10]=r,n[11]=d,n[12]=f):f=n[12];const m=i?2:void 0;let g;n[13]!==f||n[14]!==m||n[15]!==h?(g={transform:f,transition:h,zIndex:m,position:"relative"},n[13]=f,n[14]=m,n[15]=h,n[16]=g):g=n[16];const x=g;let p,b;n[17]===Symbol.for("react.memo_cache_sentinel")?(p=u.jsx(Sp,{strokeWidth:1,size:20}),n[17]=p):p=n[17],n[18]!==o||n[19]!==a?(b=u.jsx("div",{...o,...a,onMouseDown:zn.preventFocus,"data-testid":"drag-button",className:"py-px cursor-grab opacity-50 hover:opacity-100 hover-action hover:bg-muted rounded border border-transparent hover:border-border active:bg-accent",children:p}),n[18]=o,n[19]=a,n[20]=b):b=n[20];const y=b,v=!!d;let w;n[21]!==e||n[22]!==c?(w=E=>{ml(e,c)(E)},n[21]=e,n[22]=c,n[23]=w):w=n[23];const S=v&&"is-moving";let C,N,j;return n[24]!==l.className||n[25]!==S?(C=xe(l.className,S,"outline-hidden rounded-lg"),n[24]=l.className,n[25]=S,n[26]=C):C=n[26],n[27]!==s||n[28]!==y?(N=u.jsx(wb.Provider,{value:y,children:s}),n[27]=s,n[28]=y,n[29]=N):N=n[29],n[30]!==i||n[31]!==l||n[32]!==x||n[33]!==w||n[34]!==C||n[35]!==N?(j=u.jsx("div",{tabIndex:-1,ref:w,...l,"data-is-dragging":i,className:C,style:x,children:N}),n[30]=i,n[31]=l,n[32]=x,n[33]=w,n[34]=C,n[35]=N,n[36]=j):j=n[36],j});function Sb(t,e){const n=H.c(9);let o;n[0]!==t.current||n[1]!==e?(o=l=>{t.current===null||t.current.contains(l.relatedTarget)||e.current===null||tc(e.current)},n[0]=t.current,n[1]=e,n[2]=o):o=n[2];const r=Le(o);let s;n[3]!==t.current||n[4]!==e?(s=l=>{if(t.current===document.activeElement&&e.current!==null&&ws(e.current.state)==="active"){for(const c of rC)if(l.key===c.key&&c.run){c.run(e.current),l.preventDefault(),l.stopPropagation();break}e.current.focus()}},n[3]=t.current,n[4]=e,n[5]=s):s=n[5];const i=Le(s);let a;return n[6]!==r||n[7]!==i?(a={closeCompletionHandler:r,resumeCompletionHandler:i},n[6]=r,n[7]=i,n[8]=a):a=n[8],a}function Nb(t){const e=H.c(15),{cellId:n,cellConfig:o,languageAdapter:r,editorView:s}=t,[i,a]=Dt(ci);let l,c;e[0]!==n?(c=jP(n),e[0]=n,e[1]=c):c=e[1],l=c;const d=je(l),h=!o.hide_code||i||d,f=r==="markdown",m=f&&!h;let g;e[2]!==s||e[3]!==h||e[4]!==a?(g=v=>{var S;if(h)return;const w=(v==null?void 0:v.focus)??!0;a(!0),w&&((S=s.current)==null||S.focus())},e[2]=s,e[3]=h,e[4]=a,e[5]=g):g=e[5];const x=Le(g);let p;e[6]!==m||e[7]!==x?(p=()=>{m&&x({focus:!0})},e[6]=m,e[7]=x,e[8]=p):p=e[8];const b=Le(p);let y;return e[9]!==h||e[10]!==f||e[11]!==m||e[12]!==x||e[13]!==b?(y={isCellCodeShown:h,isMarkdown:f,isMarkdownCodeHidden:m,showHiddenCode:x,showHiddenCodeIfMarkdown:b},e[9]=h,e[10]=f,e[11]=m,e[12]=x,e[13]=b,e[14]=y):y=e[14],y}jb.displayName="SortableCellInternal";const Eb=M.forwardRef((t,e)=>{var x;const n=H.c(18),{cellId:o}=t,r=sa(o),s=ia(o);let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=Uc("marimo-cell","hover-actions-parent z-10",{published:!0}),n[0]=i):i=n[0];const a=i,l=_C((x=s.output)==null?void 0:x.mimetype);if(s.errored||s.interrupted||s.stopped||l)return null;let c;n[1]!==r.name||n[2]!==o?(c=ap(o,r.name),n[1]=r.name,n[2]=o,n[3]=c):c=n[3];const d=s.output;let h,f,m,g;return n[4]!==r.edited||n[5]!==s?(h=IC(s,r.edited),n[4]=r.edited,n[5]=s,n[6]=h):h=n[6],n[7]!==s.status?(f=Km(s.status),n[7]=s.status,n[8]=f):f=n[8],n[9]!==o||n[10]!==s.output||n[11]!==h||n[12]!==f?(m=u.jsx($c,{allowExpand:!1,forceExpand:!0,className:"output-area",cellId:o,output:d,stale:h,loading:f}),n[9]=o,n[10]=s.output,n[11]=h,n[12]=f,n[13]=m):m=n[13],n[14]!==e||n[15]!==c||n[16]!==m?(g=u.jsx("div",{tabIndex:-1,ref:e,className:a,...c,children:m}),n[14]=e,n[15]=c,n[16]=m,n[17]=g):g=n[17],g});Eb.displayName="ReadonlyCellComponent";const j_=({theme:t,showPlaceholder:e,cellId:n,canDelete:o,userConfig:r,isCollapsed:s,collapseCount:i,canMoveX:a,editorView:l,setEditorView:c})=>{var ge;const d=M.useRef(null),h=sa(n),f=ia(n),m=M.useRef(null),g=M.useRef(null),x=M.useRef(null),p=lt(),b=je(ln),y=jt(Os),v=Ds(),w=hd(n),{sendStdin:S}=tt(),[C,N]=M.useState(),j=h.config.disabled||f.status==="disabled-transitively",E=EC({executionTime:f.runElapsedTimeMs??h.lastExecutionTime,status:f.status,errored:f.errored,interrupted:f.interrupted,stopped:f.stopped}),T=h.edited||f.interrupted||f.staleInputs&&!j,I=Km(f.status),O=(f.status==="queued"||h.edited||f.staleInputs)&&!f.interrupted,L=M.useCallback(()=>l.current,[l]),{closeCompletionHandler:D,resumeCompletionHandler:R}=Sb(d,l),{isCellCodeShown:P,isMarkdown:z,isMarkdownCodeHidden:_,showHiddenCode:k,showHiddenCodeIfMarkdown:B}=Nb({cellId:n,cellConfig:h.config,languageAdapter:C,editorView:l}),A=pb(n,{canMoveX:a,editorView:l,cellActionDropdownRef:m}),U=CP(f.outline),$=!$m(f.output),X=f.consoleOutputs.length>0,Y=r.display.cell_output,G=$&&Y==="above",W=$&&Y==="below",[J,V]=M.useState(!1),[Q,te]=M.useState(!1);(function(oe){const{ref:ue,box:de="content-box",skip:Se}=oe,Te=M.useRef({...x5}),Fe=M.useRef(void 0);Fe.current=oe.onResize,M.useEffect(()=>{if(!ue.current||Se||typeof window>"u"||!("ResizeObserver"in window))return;const _e=new ResizeObserver(([ke])=>{const Ye=de==="border-box"?"borderBoxSize":de==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",Ve=$0(ke,Ye,"inlineSize"),Ke=$0(ke,Ye,"blockSize");if(Te.current.width!==Ve||Te.current.height!==Ke){const ee={width:Ve,height:Ke};Te.current.width=Ve,Te.current.height=Ke,Fe.current&&Fe.current(ee)}});return _e.observe(ue.current,{box:de}),()=>{_e.disconnect()}},[de,ue,Se])})({ref:x,skip:!z,onResize:oe=>{const ue=oe.height&&oe.height<68,de=_&&(ue||Y==="below");V(de),U&&de?te(!0):Q&&te(!1)}});const re=oe=>u.jsx(SC,{tooltip:"Edit markdown",className:xe("z-20 relative",oe),onClick:k}),ne=$&&u.jsxs("div",{className:"relative",onDoubleClick:B,children:[u.jsx("div",{className:"absolute top-5 -left-8 z-10 print:hidden",children:u.jsx(x_,{isCollapsed:s,onClick:()=>{s?p.expandCell({cellId:n}):p.collapseCell({cellId:n})},canCollapse:U})}),_&&W&&re("top-3"),u.jsx($c,{allowExpand:!0,forceExpand:_,className:"output-area",cellId:n,output:f.output,stale:IC(f,h.edited),loading:Km(f.status)}),_&&G&&re("bottom-3")]}),ie=Uc("marimo-cell","hover-actions-parent z-10",{interactive:!0,"needs-run":T,"has-error":f.errored,stopped:f.stopped,disabled:h.config.disabled,stale:f.status==="disabled-transitively",borderless:_&&$&&!A["data-selected"]}),se=Le(oe=>{y({cellId:n,initialPrompt:oe.prompt})}),ae=((ge=f.serialization)==null?void 0:ge.toLowerCase())==="valid";return u.jsx(Gm,{children:u.jsx(jx,{cellId:n,getEditorView:L,children:u.jsxs(Cb,{tabIndex:-1,ref:d,"data-status":f.status,onBlur:D,onKeyDown:R,cellId:n,canMoveX:a,title:h.config.disabled?"This cell is disabled":f.status==="disabled-transitively"?"This cell has a disabled ancestor":void 0,children:[u.jsxs("div",{tabIndex:-1,...A,className:xe(ie,A.className,"focus:ring-1 focus:ring-(--blue-7) focus:ring-offset-0"),ref:x,...ap(n,h.name),children:[Y==="above"&&ne,u.jsxs("div",{className:xe("tray"),"data-hidden":_,children:[u.jsx("div",{className:"absolute right-2 -top-4 z-10",children:u.jsx(Bu,{edited:h.edited,status:f.status,cellConfig:h.config,needsRun:T,hasOutput:$,hasConsoleOutput:X,cellActionDropdownRef:m,cellId:n,name:h.name,getEditorView:L,onRun:w})}),u.jsx(_b,{cellId:n,className:xe(_&&G&&"-top-7",_&&W&&"-bottom-8",_&&Q&&"-left-[3.8rem]"),actions:p}),u.jsx(Fu,{theme:t,showPlaceholder:e,id:n,code:h.code,config:h.config,status:f.status,serializedEditorState:h.serializedEditorState,runCell:w,setEditorView:c,userConfig:r,editorViewRef:l,editorViewParentRef:g,hidden:!P,hasOutput:$,showHiddenCode:k,languageAdapter:C,setLanguageAdapter:N}),u.jsx(zu,{className:xe(_&&Y==="below"&&"top-14"),edited:h.edited,status:f.status,isCellStatusInline:J,uninstantiated:E,disabled:h.config.disabled,runElapsedTimeMs:f.runElapsedTimeMs,runStartTimestamp:f.runStartTimestamp,lastRunStartTimestamp:f.lastRunStartTimestamp,staleInputs:f.staleInputs,interrupted:f.interrupted}),u.jsx("div",{className:"shoulder-bottom hover-action",children:o&&P&&u.jsx(vb,{status:f.status,connectionState:b.state,onClick:()=>{I||eo(b.state)||v({cellId:n})}})})]}),Y==="below"&&ne,f.serialization&&u.jsxs("div",{className:"py-1 px-2 flex items-center justify-end gap-2 last:rounded-b",children:[ae&&u.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",className:"hover:underline text-muted-foreground text-xs font-bold",rel:"noopener",children:"reusable"}),u.jsx(Ne,{content:u.jsx("span",{className:"max-w-16 text-xs",children:ae?"This function or class can be imported into other Python notebooks or modules.":u.jsxs(u.Fragment,{children:["This definition can't be reused in other Python modules:",u.jsx("br",{}),u.jsx("br",{}),u.jsx("pre",{children:f.serialization}),u.jsx("br",{}),"Click this icon to learn more."]})}),children:ae?u.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",rel:"noopener",children:u.jsx(nc,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})}):u.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",rel:"noopener",children:u.jsx(Ym,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})})})]}),u.jsx(lp,{consoleOutputs:f.consoleOutputs,stale:O,cellName:f.serialization?"_":h.name,onRefactorWithAI:se,onClear:()=>{p.clearCellConsoleOutput({cellId:n})},onSubmitDebugger:(oe,ue)=>{p.setStdinResponse({cellId:n,response:oe,outputIndex:ue}),S({text:oe})},cellId:n,debuggerActive:f.debuggerActive}),u.jsx(y_,{cellId:n})]}),s&&u.jsx(yb,{onClick:()=>p.expandCell({cellId:n}),count:i,cellId:n})]})})})},zu=M.memo(t=>{const e=H.c(19),{className:n,disabled:o,edited:r,interrupted:s,isCellStatusInline:i,lastRunStartTimestamp:a,runElapsedTimeMs:l,runStartTimestamp:c,staleInputs:d,status:h,uninstantiated:f}=t,m=o!==void 0&&o;let g;e[0]!==m||e[1]!==r||e[2]!==s||e[3]!==a||e[4]!==l||e[5]!==c||e[6]!==d||e[7]!==h||e[8]!==f?(g=u.jsx(W0,{status:h,staleInputs:d,interrupted:s,editing:!0,edited:r,disabled:m,elapsedTime:l,runStartTimestamp:c,uninstantiated:f,lastRunStartTimestamp:a}),e[0]=m,e[1]=r,e[2]=s,e[3]=a,e[4]=l,e[5]=c,e[6]=d,e[7]=h,e[8]=f,e[9]=g):g=e[9];const x=g;let p;e[10]!==n?(p=xe("shoulder-right z-20",n),e[10]=n,e[11]=p):p=e[11];const b=!i&&x;let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=u.jsx(kb,{}),e[12]=y):y=e[12];const v=i&&x;let w,S;return e[13]!==v?(w=u.jsxs("div",{className:"flex gap-2 items-end",children:[y,v]}),e[13]=v,e[14]=w):w=e[14],e[15]!==p||e[16]!==b||e[17]!==w?(S=u.jsxs("div",{className:p,children:[b,w]}),e[15]=p,e[16]=b,e[17]=w,e[18]=S):S=e[18],S});zu.displayName="CellRightSideActions";const _b=M.memo(t=>{const e=H.c(21),n=je(ln),{className:o,actions:r,cellId:s}=t;let i;e[0]!==r||e[1]!==s?(i=w=>{const S=w===void 0?{}:w;return r.createNewCell({cellId:s,before:!1,...S})},e[0]=r,e[1]=s,e[2]=i):i=e[2];const a=Le(i);let l;e[3]!==r||e[4]!==s?(l=w=>{const S=w===void 0?{}:w;return r.createNewCell({cellId:s,before:!0,...S})},e[3]=r,e[4]=s,e[5]=l):l=e[5];const c=Le(l),d=AC(n.state);let h,f;e[6]!==o?(h=xe("absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-20",o),e[6]=o,e[7]=h):h=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(f=Gt("cell.createAbove"),e[8]=f):f=e[8];const m=d?c:void 0;let g,x,p;e[9]!==n.state||e[10]!==m?(g=u.jsx(wx,{tooltipContent:f,connectionState:n.state,onClick:m}),e[9]=n.state,e[10]=m,e[11]=g):g=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx("div",{className:"flex-1"}),e[12]=x):x=e[12],e[13]===Symbol.for("react.memo_cache_sentinel")?(p=Gt("cell.createBelow"),e[13]=p):p=e[13];const b=d?a:void 0;let y,v;return e[14]!==n.state||e[15]!==b?(y=u.jsx(wx,{tooltipContent:p,connectionState:n.state,onClick:b}),e[14]=n.state,e[15]=b,e[16]=y):y=e[16],e[17]!==h||e[18]!==g||e[19]!==y?(v=u.jsxs("div",{className:h,children:[g,x,y]}),e[17]=h,e[18]=g,e[19]=y,e[20]=v):v=e[20],v});_b.displayName="CellLeftSideActions";const Bu=M.memo(t=>{const e=H.c(27),{edited:n,status:o,cellConfig:r,needsRun:s,hasOutput:i,hasConsoleOutput:a,onRun:l,cellActionDropdownRef:c,cellId:d,getEditorView:h,name:f,includeCellActions:m}=t,g=m===void 0||m,x=je(ln),p=AC(x.state),b=!s&&"hover-action";let y;e[0]!==b?(y=xe(b),e[0]=b,e[1]=y):y=e[1];const v=p?l:Bn.NOOP;let w,S,C,N;return e[2]!==r||e[3]!==x.state||e[4]!==n||e[5]!==s||e[6]!==o||e[7]!==v?(w=u.jsx(C_,{edited:n,onClick:v,connectionState:x.state,status:o,config:r,needsRun:s}),e[2]=r,e[3]=x.state,e[4]=n,e[5]=s,e[6]=o,e[7]=v,e[8]=w):w=e[8],e[9]!==x.state||e[10]!==o?(S=u.jsx($N,{status:o,connectionState:x.state}),e[9]=x.state,e[10]=o,e[11]=S):S=e[11],e[12]!==c||e[13]!==r||e[14]!==d||e[15]!==h||e[16]!==a||e[17]!==i||e[18]!==g||e[19]!==f||e[20]!==o?(C=g&&u.jsx(kx,{ref:c,cellId:d,status:o,getEditorView:h,name:f,config:r,hasOutput:i,hasConsoleOutput:a,children:u.jsx(Vs,{variant:"green",tooltip:null,"data-testid":"cell-actions-button",children:u.jsx(Gc,{strokeWidth:1.5})})}),e[12]=c,e[13]=r,e[14]=d,e[15]=h,e[16]=a,e[17]=i,e[18]=g,e[19]=f,e[20]=o,e[21]=C):C=e[21],e[22]!==y||e[23]!==w||e[24]!==S||e[25]!==C?(N=u.jsxs(UN,{className:y,children:[w,S,C]}),e[22]=y,e[23]=w,e[24]=S,e[25]=C,e[26]=N):N=e[26],N});Bu.displayName="CellToolbar";const S_=({theme:t,showPlaceholder:e,cellId:n,canDelete:o,userConfig:r,canMoveX:s,editorView:i,setEditorView:a})=>{var k;const l=M.useRef(null),c=sa(n),d=ia(n),h=M.useRef(null),f=M.useRef(null),m=je(ln),g=lt(),x=tt(),p=Ds(),b=jt(Os),y=hd(n),v=c.config.disabled||d.status==="disabled-transitively",w=EC({executionTime:d.runElapsedTimeMs??c.lastExecutionTime,status:d.status,errored:d.errored,interrupted:d.interrupted,stopped:d.stopped}),S=c.edited||d.interrupted||d.staleInputs&&!v,C=d.status==="running"||d.status==="queued",N=(d.status==="queued"||c.edited||d.staleInputs)&&!d.interrupted,j=M.useCallback(()=>i.current,[i]),{isCellCodeShown:E,showHiddenCode:T}=Nb({cellId:n,cellConfig:c.config,languageAdapter:"python",editorView:i}),{closeCompletionHandler:I,resumeCompletionHandler:O}=Sb(l,i),L=pb(n,{canMoveX:s,editorView:i,cellActionDropdownRef:h}),D=!$m(d.output),R=d.consoleOutputs.length>0,P=_C((k=d.output)==null?void 0:k.mimetype),z=Uc("marimo-cell","hover-actions-parent z-10 border shadow-sm","border-(--blue-5)! rounded-sm!",{"needs-run":S,"has-error":d.errored,stopped:d.stopped}),_=Le(B=>{b({cellId:n,initialPrompt:B.prompt})});return u.jsx(Gm,{children:u.jsx(jx,{cellId:n,getEditorView:j,children:u.jsxs("div",{"data-status":d.status,ref:l,...lm(L,{className:z,onBlur:I,onKeyDown:O}),...ap(n,c.name),title:c.config.disabled?"This cell is disabled":d.status==="disabled-transitively"?"This cell has a disabled ancestor":void 0,"data-setup-cell":!0,children:[u.jsxs("div",{className:xe("tray"),"data-hidden":!E,children:[u.jsx("div",{className:"absolute right-2 -top-4 z-10",children:u.jsx(Bu,{edited:c.edited,status:d.status,cellConfig:c.config,needsRun:S,hasOutput:D,hasConsoleOutput:R,cellActionDropdownRef:h,cellId:n,name:c.name,getEditorView:j,onRun:y,includeCellActions:!0})}),u.jsx(Fu,{theme:t,showPlaceholder:e,id:n,code:c.code,config:c.config,status:d.status,serializedEditorState:c.serializedEditorState,runCell:y,setEditorView:a,userConfig:r,editorViewRef:i,editorViewParentRef:f,hidden:!E,hasOutput:D,showHiddenCode:T,languageAdapter:"python",setLanguageAdapter:Bn.NOOP,showLanguageToggles:!1}),u.jsx(zu,{edited:c.edited,status:d.status,isCellStatusInline:!1,uninstantiated:w,disabled:c.config.disabled,runElapsedTimeMs:d.runElapsedTimeMs,runStartTimestamp:d.runStartTimestamp,lastRunStartTimestamp:d.lastRunStartTimestamp,staleInputs:d.staleInputs,interrupted:d.interrupted}),u.jsx("div",{className:"shoulder-bottom hover-action",children:o&&u.jsx(vb,{connectionState:m.state,status:d.status,onClick:()=>{C||eo(m.state)||p({cellId:n})}})})]}),u.jsxs("div",{className:"py-1 px-2 flex justify-end gap-2 last:rounded-b",children:[u.jsx("span",{className:"text-muted-foreground text-xs font-bold",children:"setup cell"}),u.jsx(Ne,{content:u.jsxs("span",{className:"max-w-16",children:["This ",u.jsx("b",{children:"setup cell"})," is guaranteed to run before all other cells. Include ",u.jsx("br",{}),"initialization or imports and constants required by top-level functions."]}),children:u.jsx(Ym,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})})]}),P&&u.jsx($c,{allowExpand:!0,forceExpand:!0,className:"output-area",cellId:n,output:d.output,stale:!1,loading:C}),u.jsx(lp,{consoleOutputs:d.consoleOutputs,stale:N,cellName:"_",onRefactorWithAI:_,onClear:()=>{g.clearCellConsoleOutput({cellId:n})},onSubmitDebugger:(B,A)=>{g.setStdinResponse({cellId:n,response:B,outputIndex:A}),x.sendStdin({text:B})},cellId:n,debuggerActive:d.debuggerActive})]})})})},Ib=M.memo(t=>{const{cellId:e,mode:n}=t,o=wP(e);mt.debug("Rendering Cell",e);const r=M.useRef(null);return M.useImperativeHandle(o,()=>({get editorView(){return function(s){const i=s.current;if(i===null)throw new ReferenceError("Attempting to dereference null object.");return i}(r)},get editorViewOrNull(){return r.current}}),[r]),e===ca?u.jsx(S_,{...t,cellId:e,editorView:r,setEditorView:s=>{r.current=s}}):n==="edit"?u.jsx(kP,{atoms:[ci],children:u.jsx(j_,{...t,cellId:e,editorView:r,setEditorView:s=>{r.current=s}})}):u.jsx(Eb,{cellId:e})}),N_=(t,e)=>function(n,o){const r=/^(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/,s=i=>{const a=i.match(r);if(!a)return null;const[,l,c,d,h]=a;return{major:Number.parseInt(l,10),minor:Number.parseInt(c,10),patch:Number.parseInt(d,10),preRelease:h||""}};try{const i=s(n),a=s(o);return i&&a?i.major!==a.major?i.major-a.major:i.minor!==a.minor?i.minor-a.minor:i.patch!==a.patch?i.patch-a.patch:i.preRelease===""&&a.preRelease!==""?1:i.preRelease!==""&&a.preRelease===""?-1:i.preRelease.localeCompare(a.preRelease):n.localeCompare(o,void 0,{numeric:!0,sensitivity:"base"})}catch{return n.localeCompare(o,void 0,{numeric:!0,sensitivity:"base"})}}(e,t),Ab=new class{constructor(t){this.ttl=void 0,this.cache=new Map,this.ttl=t.ttl}cleanupExpiredEntries(){const t=Date.now();for(const[e,n]of this.cache.entries())t-n.timestamp>this.ttl&&this.cache.delete(e)}get(t){this.cleanupExpiredEntries();const e=this.cache.get(t);if(e){if(!(Date.now()-e.timestamp>this.ttl))return e.data;this.cache.delete(t)}}set(t,e){this.cache.set(t,{data:e,timestamp:Date.now()})}clear(){this.cache.clear()}}({ttl:3e5}),E_=ht({info:ht({provides_extra:at().array().nullable()}),releases:SP(at(),NP())});function Tb(t){const e=H.c(5);let n;e[0]!==t?(n=function(i){return i.replaceAll(/\[.*]/g,"").trim()}(t),e[0]=t,e[1]=n):n=e[1];const o=n;let r,s;return e[2]!==o?(r=async()=>{const i=Ab.get(o);if(i)return i;const a=await fetch(`https://pypi.org/pypi/${o}/json`,{method:"GET"});if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const l=E_.transform(__).parse(await a.json());return Ab.set(o,l),l},s=[o],e[2]=o,e[3]=r,e[4]=s):(r=e[3],s=e[4]),Tn(r,s)}function __(t){return{versions:Object.keys(t.releases).toSorted(N_),extras:t.info.provides_extra??[]}}function Mb(t){const e=t.match(/^([^[]+)(?:\[([^\]]+)])?$/);if(!e)return{name:t,extras:[]};const[,n,o]=e;return{name:n,extras:o?o.split(",").map(r=>r.trim()):[]}}const I_=()=>{const t=H.c(70),{packageAlert:e}=NF(),{clearPackageAlert:n}=EF(),[o]=br();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[s,i]=M.useState(r);let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a={},t[1]=a):a=t[1];const[l,c]=M.useState(a);if(e===null)return null;const d=o.package_management.manager!=="pixi";if(_F(e)){let h,f,m,g,x,p,b,y,v,w;if(t[2]===Symbol.for("react.memo_cache_sentinel")?(h=u.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[u.jsx(id,{className:"w-5 h-5 inline-block mr-2"}),"Missing packages"]}),t[2]=h):h=t[2],t[3]!==n||t[4]!==e.id?(f=()=>n(e.id),t[3]=n,t[4]=e.id,t[5]=f):f=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(m=u.jsx(wn,{className:"w-5 h-5"}),t[6]=m):m=t[6],t[7]!==f?(g=u.jsxs("div",{className:"flex justify-between",children:[h,u.jsx(ve,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:f,children:m})]}),t[7]=f,t[8]=g):g=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx("p",{children:"The following packages were not found:"}),t[9]=x):x=t[9],t[10]!==s||t[11]!==d||t[12]!==e.packages||t[13]!==l){let S;t[15]!==s||t[16]!==d||t[17]!==l?(S=(C,N)=>{const j=Mb(C),E=l[C]||j.extras;return u.jsxs("li",{className:"flex items-center gap-2 font-mono text-sm",children:[u.jsx(Es,{size:"1rem"}),u.jsx(O_,{packageName:j.name,selectedExtras:E,onExtrasChange:T=>c(I=>({...I,[C]:T}))}),d&&u.jsx(D_,{value:s[C]??"latest",onChange:T=>i(I=>({...I,[C]:T})),packageName:j.name})]},N)},t[15]=s,t[16]=d,t[17]=l,t[18]=S):S=t[18],p=e.packages.map(S),t[10]=s,t[11]=d,t[12]=e.packages,t[13]=l,t[14]=p}else p=t[14];return t[19]!==p?(b=u.jsxs("div",{children:[x,u.jsx("ul",{className:"list-disc ml-4 mt-1",children:p})]}),t[19]=p,t[20]=b):b=t[20],t[21]!==n||t[22]!==s||t[23]!==e.id||t[24]!==e.isolated||t[25]!==e.packages||t[26]!==l||t[27]!==o.package_management.manager?(y=u.jsx("div",{className:"ml-auto flex flex-row items-baseline",children:e.isolated?u.jsxs(u.Fragment,{children:[u.jsx(T_,{manager:o.package_management.manager,packages:e.packages.map(S=>{const C=Mb(S),N=l[S]||C.extras;return function(j,E){return E.length===0?j:`${j}[${E.join(",")}]`}(C.name,N)}),versions:s,clearPackageAlert:()=>n(e.id)}),!tn()&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"px-2 text-sm",children:"with"})," ",u.jsx(M_,{})]})]}):u.jsxs("p",{children:["If you set up a"," ",u.jsx(vm,{href:"https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments",children:"virtual environment"}),", marimo can install these packages for you."]})}),t[21]=n,t[22]=s,t[23]=e.id,t[24]=e.isolated,t[25]=e.packages,t[26]=l,t[27]=o.package_management.manager,t[28]=y):y=t[28],t[29]!==b||t[30]!==y?(v=u.jsxs("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:[b,y]}),t[29]=b,t[30]=y,t[31]=v):v=t[31],t[32]!==v||t[33]!==g?(w=u.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-200 opacity-95",children:u.jsxs(da,{kind:"danger",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left",children:[g,v]})}),t[32]=v,t[33]=g,t[34]=w):w=t[34],w}if(IF(e)){let h;t[35]!==e.packages?(h=function(D){const R=new Set(Object.values(D)),P=R.has("queued")||R.has("installing")?"installing":R.has("failed")?"failed":"installed";return P==="installing"?{status:"installing",title:"Installing packages",titleIcon:u.jsx(xa,{className:"w-5 h-5 inline-block mr-2"}),description:"Installing packages:"}:P==="installed"?{status:"installed",title:"All packages installed!",titleIcon:u.jsx(Fp,{className:"w-5 h-5 inline-block mr-2"}),description:"Installed packages:"}:{status:"failed",title:"Some packages failed to install",titleIcon:u.jsx(id,{className:"w-5 h-5 inline-block mr-2"}),description:"See terminal for error logs."}}(e.packages),t[35]=e.packages,t[36]=h):h=t[36];const{status:f,title:m,titleIcon:g,description:x}=h;f==="installed"&&setTimeout(()=>n(e.id),1e4);const p=f==="failed"?"danger":"info";let b,y,v,w,S;t[37]!==m||t[38]!==g?(b=u.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[g,m]}),t[37]=m,t[38]=g,t[39]=b):b=t[39],t[40]!==n||t[41]!==e.id?(y=()=>n(e.id),t[40]=n,t[41]=e.id,t[42]=y):y=t[42],t[43]===Symbol.for("react.memo_cache_sentinel")?(v=u.jsx(wn,{className:"w-5 h-5"}),t[43]=v):v=t[43],t[44]!==y?(w=u.jsx(ve,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:y,children:v}),t[44]=y,t[45]=w):w=t[45],t[46]!==b||t[47]!==w?(S=u.jsxs("div",{className:"flex justify-between",children:[b,w]}),t[46]=b,t[47]=w,t[48]=S):S=t[48];const C=f==="installed"&&"text-accent-foreground";let N,j,E,T,I,O,L;if(t[49]!==C?(N=xe("flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",C),t[49]=C,t[50]=N):N=t[50],t[51]!==x?(j=u.jsx("p",{children:x}),t[51]=x,t[52]=j):j=t[52],t[53]!==e.packages||t[54]!==f){let D;t[56]!==f?(D=(R,P)=>{const[z,_]=R;return u.jsxs("li",{className:xe("flex items-center gap-1 font-mono text-sm",_==="installing"&&"font-semibold",_==="failed"&&"text-destructive",_==="installed"&&"text-accent-foreground",_==="installed"&&f==="failed"&&"text-muted-foreground"),children:[u.jsx(A_,{status:_}),z]},P)},t[56]=f,t[57]=D):D=t[57],E=Object.entries(e.packages).map(D),t[53]=e.packages,t[54]=f,t[55]=E}else E=t[55];return t[58]!==E?(T=u.jsx("ul",{className:"list-disc ml-4 mt-1",children:E}),t[58]=E,t[59]=T):T=t[59],t[60]!==j||t[61]!==T?(I=u.jsxs("div",{children:[j,T]}),t[60]=j,t[61]=T,t[62]=I):I=t[62],t[63]!==N||t[64]!==I?(O=u.jsx("div",{className:N,children:I}),t[63]=N,t[64]=I,t[65]=O):O=t[65],t[66]!==O||t[67]!==p||t[68]!==S?(L=u.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-200 opacity-95",children:u.jsxs(da,{kind:p,className:"flex flex-col rounded pt-3 pb-4 px-5",children:[S,O]})}),t[66]=O,t[67]=p,t[68]=S,t[69]=L):L=t[69],L}return pc(e),null},A_=t=>{const e=H.c(4),{status:n}=t;switch(n){case"queued":{let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=u.jsx(Es,{size:"1rem"}),e[0]=o):o=e[0],o}case"installing":{let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=u.jsx(xa,{size:"1rem"}),e[1]=o):o=e[1],o}case"installed":{let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=u.jsx(yc,{size:"1rem"}),e[2]=o):o=e[2],o}case"failed":{let o;return e[3]===Symbol.for("react.memo_cache_sentinel")?(o=u.jsx(wn,{size:"1rem"}),e[3]=o):o=e[3],o}default:return pc(n),null}},T_=t=>{const e=H.c(10),{manager:n,packages:o,versions:r,clearPackageAlert:s}=t,{sendInstallMissingPackages:i}=tt();let a,l,c,d;return e[0]!==s||e[1]!==n||e[2]!==o||e[3]!==i||e[4]!==r?(a=async()=>{s();const h={...r};for(const f of o)h[f]=h[f]??"";await i({manager:n,versions:h}).catch(R_)},e[0]=s,e[1]=n,e[2]=o,e[3]=i,e[4]=r,e[5]=a):a=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx(xa,{className:"w-4 h-4 mr-2"}),c=u.jsx("span",{className:"font-semibold",children:"Install"}),e[6]=l,e[7]=c):(l=e[6],c=e[7]),e[8]!==a?(d=u.jsxs(ve,{variant:"outline","data-testid":"install-packages-button",size:"sm",onClick:a,children:[l,c]}),e[8]=a,e[9]=d):d=e[9],d},M_=()=>{const t=H.c(17),[e,n]=br(),{saveUserConfig:o}=tt();let r,s;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=O3(EP),t[0]=r):r=t[0],t[1]!==e?(s={resolver:r,defaultValues:e},t[1]=e,t[2]=s):s=t[2];const i=D3(s);let a;t[3]!==o||t[4]!==n?(a=async m=>{await o({config:m}).then(()=>{n(m)})},t[3]=o,t[4]=n,t[5]=a):a=t[5];const l=a;let c,d,h,f;return t[6]!==i||t[7]!==l?(c=i.handleSubmit(l),t[6]=i,t[7]=l,t[8]=c):c=t[8],t[9]!==i.control?(d=u.jsx("div",{className:"flex flex-col gap-3",children:u.jsx(E3,{control:i.control,name:"package_management.manager",render:L_})}),t[9]=i.control,t[10]=d):d=t[10],t[11]!==c||t[12]!==d?(h=u.jsx("form",{onChange:c,className:"flex flex-col gap-5",children:d}),t[11]=c,t[12]=d,t[13]=h):h=t[13],t[14]!==i||t[15]!==h?(f=u.jsx(_P,{...i,children:h}),t[14]=i,t[15]=h,t[16]=f):f=t[16],f},O_=t=>{const e=H.c(14),{packageName:n,selectedExtras:o,onExtrasChange:r}=t,[s,i]=M.useState(!1),{isPending:a,error:l,data:c}=Tb(n);let d;e[0]!==r||e[1]!==o?(d=(x,p)=>{r(p?[...o,x]:o.filter(b=>b!==x))},e[0]=r,e[1]=o,e[2]=d):d=e[2];const h=d,f=!a&&!l;let m,g;if(e[3]!==(c==null?void 0:c.extras)?(m=(c==null?void 0:c.extras)??[],e[3]=c==null?void 0:c.extras,e[4]=m):m=e[4],e[5]!==f||e[6]!==h||e[7]!==s||e[8]!==n||e[9]!==o||e[10]!==m){const x=m.filter(F_);let p;e[12]!==n?(p=u.jsx("span",{className:"shrink-0",children:n}),e[12]=n,e[13]=p):p=e[13],g=u.jsxs("div",{className:"flex items-center max-w-72",children:[p,o.length>0?u.jsxs("span",{className:"flex items-center min-w-0 flex-1",children:[u.jsx("span",{className:"shrink-0",children:"["}),u.jsxs(Eo,{open:s&&f,onOpenChange:b=>{f&&i(b)},children:[u.jsx(_o,{asChild:!0,children:u.jsx("button",{className:"hover:bg-muted/50 rounded text-sm px-1 transition-colors border border-muted-foreground/30 hover:border-muted-foreground/60 min-w-0 flex-1 truncate text-left",title:`Selected extras: ${o.join(", ")}`,children:o.join(",")})}),u.jsxs(Io,{align:"start",className:"w-64 p-0 max-h-96 flex flex-col",children:[o.length>0&&u.jsx("div",{className:"p-2 bg-popover border-b border-border",children:u.jsx("div",{className:"flex flex-wrap gap-1 p-1 min-h-[24px]",children:o.map(b=>u.jsxs("span",{className:"inline-flex items-center gap-1 px-1 py-0.5 text-sm font-mono border border-muted-foreground/30 hover:border-muted-foreground/60 rounded-sm cursor-pointer group transition-colors",onClick:()=>h(b,!1),children:[b,u.jsx(wn,{className:"w-3 h-3 opacity-60 group-hover:opacity-100"})]},b))})}),u.jsx("div",{className:"overflow-y-auto flex-1",children:x.map(b=>u.jsx(TC,{checked:o.includes(b),onCheckedChange:y=>{h(b,y)},className:"font-mono text-sm",onSelect:z_,children:b},b))})]})]}),u.jsx("span",{className:"shrink-0",children:"]"})]}):x.length>0?u.jsxs(Eo,{open:s&&f,onOpenChange:b=>{f&&i(b)},children:[u.jsx(_o,{asChild:!0,children:u.jsx("button",{disabled:!f,className:xe("hover:bg-muted/50 rounded text-sm ml-2 transition-colors border border-muted-foreground/30 hover:border-muted-foreground/60 h-5 w-5 flex items-center justify-center p-0",!f&&"opacity-50 cursor-not-allowed"),title:f?"Add extras":"Loading extras...",children:u.jsx(Jo,{className:"w-3 h-3 shrink-0"})})}),u.jsxs(Io,{align:"start",className:"w-64 p-0 max-h-96 flex flex-col",children:[u.jsx("div",{className:"p-2 bg-popover border-b border-border",children:u.jsx("span",{className:"text-muted-foreground italic text-sm",children:"Package extras"})}),u.jsx("div",{className:"overflow-y-auto flex-1",children:x.map(b=>u.jsx(TC,{checked:o.includes(b),onCheckedChange:y=>{h(b,y)},className:"font-mono text-sm",onSelect:B_,children:b},b))})]})]}):null]}),e[5]=f,e[6]=h,e[7]=s,e[8]=n,e[9]=o,e[10]=m,e[11]=g}else g=e[11];return g},D_=t=>{const e=H.c(16),{value:n,onChange:o,packageName:r}=t,{error:s,isPending:i,data:a}=Tb(r);if(s){let h,f,m;return e[0]!==o?(h=g=>o(g.target.value),e[0]=o,e[1]=h):h=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(f=u.jsx("option",{value:"latest",children:"latest"}),e[2]=f):f=e[2],e[3]!==h||e[4]!==n?(m=u.jsx(Ne,{content:"Failed to fetch package versions",children:u.jsx(Xm,{value:n,onChange:h,disabled:!0,className:"inline-flex ml-2 w-24 text-ellipsis",children:f})}),e[3]=h,e[4]=n,e[5]=m):m=e[5],m}let l,c,d;return e[6]!==o?(l=h=>o(h.target.value),e[6]=o,e[7]=l):l=e[7],e[8]!==i||e[9]!==a?(c=i?u.jsx("option",{value:"latest",children:"latest"}):["latest",...a.versions.slice(0,100)].map(U_),e[8]=i,e[9]=a,e[10]=c):c=e[10],e[11]!==i||e[12]!==l||e[13]!==c||e[14]!==n?(d=u.jsx(Xm,{value:n,onChange:l,disabled:i,className:"inline-flex ml-2 w-24 text-ellipsis",children:c}),e[11]=i,e[12]=l,e[13]=c,e[14]=n,e[15]=d):d=e[15],d};function R_(t){mt.error(t)}function P_(t){return u.jsx("option",{value:t,children:t},t)}function L_(t){const{field:e}=t;return u.jsxs(_3,{children:[u.jsx(I3,{children:u.jsx(Xm,{"data-testid":"install-package-manager-select",onChange:n=>e.onChange(n.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:IP.map(P_)})}),u.jsx(M3,{})]})}function F_(t){return!/^(dev|test|testing)$/i.test(t)}function z_(t){return t.preventDefault()}function B_(t){return t.preventDefault()}function U_(t){return u.jsx("option",{value:t,children:t},t)}const $_=t=>{let{transform:e}=t;return{...e,x:0}},V_={threshold:{x:0,y:.1}},H_=q.memo(t=>{const e=H.c(23),{children:n,multiColumn:o}=t,{dropCellOverCell:r,dropCellOverColumn:s,moveColumn:i,compactColumns:a}=lt(),[l,c]=M.useState(null),[d,h]=M.useState(null),[f]=C3();let m;e:{if(f.width==="columns"){m=Jm.EMPTY;break e}let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D=[$_],e[0]=D):D=e[0],m=D}const g=m;let x,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(x={activationConstraint:{distance:8}},e[1]=x):x=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(p={coordinateGetter:zN},e[2]=p):p=e[2];const b=function(){for(var D=arguments.length,R=new Array(D),P=0;P<D;P++)R[P]=arguments[P];return M.useMemo(()=>[...R].filter(z=>z!=null),[...R])}(Jg(zd,x),Jg(Ld,p));let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=D=>{c(D.active.id);const R=bn();h(R.cellIds)},e[3]=y):y=e[3];const v=Le(y);let w;e[4]!==d?(w=()=>{c(null),h(null)},e[4]=d,e[5]=w):w=e[5];const S=Le(w);let C;e[6]!==l?(C=D=>{const R=D.droppableContainers.filter(W_);if(l&&Ur(l))return Md({...D,droppableContainers:R});const P=(A=>{let{droppableContainers:U,droppableRects:$,pointerCoordinates:X}=A;if(!X)return[];const Y=[];for(const G of U){const{id:W}=G,J=$.get(W);if(J&&oN(X,J)){const V=Ad(J).reduce((te,re)=>te+_d(X,re),0),Q=Number((V/4).toFixed(4));Y.push({id:W,data:{droppableContainer:G,value:Q}})}}return Y.sort(Id)})({...D,droppableContainers:R}),z=Td(P.length>0?P:Qg({...D,droppableContainers:R}),"id");if(!z)return[];Un(Ur(z),`Expected column id. Got: ${z}`);const _=bn().cellIds.get(z);if(Un(_,`Expected column. Got: ${z}`),_&&_.topLevelIds.length===0)return[{id:z}];const k=new Set(_.topLevelIds),B=Md({...D,droppableContainers:D.droppableContainers.filter(A=>A.id!==z&&k.has(A.id))});if(B.length>0){const A=B[0].id;return Un(Uu(A),`Expected cell id. Got: ${A}`),[{id:A}]}return[]},e[6]=l,e[7]=C):C=e[7];const N=C;let j;e[8]!==r||e[9]!==s||e[10]!==i?(j=D=>{const{active:R,over:P}=D,z=P==null?void 0:P.id;if(z!=null&&R.id!==z){if(Uu(R.id)){if(Ur(z))return void s({cellId:R.id,columnId:z});if(Uu(z))return void r({cellId:R.id,overCellId:z})}Ur(R.id)&&Ur(z)&&i({column:R.id,overColumn:z})}},e[8]=r,e[9]=s,e[10]=i,e[11]=j):j=e[11];const E=Le(j);let T;e[12]!==a?(T=D=>{const{active:R,over:P}=D;P!==null&&R.id!==P.id&&a()},e[12]=a,e[13]=T):T=e[13];const I=Le(T),O=o?N:Md;let L;return e[14]!==n||e[15]!==S||e[16]!==I||e[17]!==E||e[18]!==v||e[19]!==g||e[20]!==b||e[21]!==O?(L=u.jsx(NN,{autoScroll:V_,sensors:b,collisionDetection:O,modifiers:g,onDragEnd:I,onDragStart:v,onDragCancel:S,onDragOver:E,children:n}),e[14]=n,e[15]=S,e[16]=I,e[17]=E,e[18]=v,e[19]=g,e[20]=b,e[21]=O,e[22]=L):L=e[22],L});function Uu(t){return typeof t=="string"&&!t.startsWith("tree_")}function Ur(t){return typeof t=="string"&&t.startsWith("tree_")}function W_(t){return Ur(t.id)}const q_=t=>{const e=H.c(13),{className:n,size:o,gap:r,durationMs:s}=t,i=o===void 0?8:o,a=r===void 0?"gap-1":r,l=s===void 0?1200:s,c=`${l}ms`;let d;e[0]!==c?(d={animationDuration:c},e[0]=c,e[1]=d):d=e[1];const h=d;let f,m,g,x;return e[2]!==n||e[3]!==a?(f=Uc("flex",a,n),e[2]=n,e[3]=a,e[4]=f):f=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(m=[0,1,2],e[5]=m):m=e[5],e[6]!==h||e[7]!==l||e[8]!==i?(g=m.map(p=>u.jsx(AP,{width:i,height:i,className:"fill-current text-current animate-ellipsis-dot",style:{...h,animationDelay:l/3*p+"ms"}},p)),e[6]=h,e[7]=l,e[8]=i,e[9]=g):g=e[9],e[10]!==f||e[11]!==g?(x=u.jsx("div",{className:f,"aria-label":"Loading",children:g}),e[10]=f,e[11]=g,e[12]=x):x=e[12],x},Ob=t=>{const e=H.c(11),{title:n,children:o,show:r,delayMs:s,kind:i}=t,a=s===void 0?2e3:s,l=i===void 0?"info":i;if(!r)return null;let c,d,h;e[0]!==n?(c=n&&u.jsx("div",{className:"flex justify-between",children:u.jsx("span",{className:"font-bold text-lg flex items-center mb-1",children:n})}),e[0]=n,e[1]=c):c=e[1],e[2]!==o?(d=u.jsx("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:u.jsx("div",{children:o})}),e[2]=o,e[3]=d):d=e[3],e[4]!==l||e[5]!==c||e[6]!==d?(h=u.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-1/2 transform -translate-x-1/2 z-200 opacity-95",children:u.jsxs(da,{kind:l,className:"flex flex-col rounded py-2 px-4 animate-in slide-in-from-top w-fit",children:[c,d]})}),e[4]=l,e[5]=c,e[6]=d,e[7]=h):h=e[7];const f=h;let m;return e[8]!==f||e[9]!==a?(m=u.jsx(Bc,{milliseconds:a,children:f}),e[8]=f,e[9]=a,e[10]=m):m=e[10],m},G_=()=>{const t=H.c(3),e=je(TP),n=je(MP);let o;return t[0]!==n||t[1]!==e?(o=e&&u.jsxs(u.Fragment,{children:[u.jsx(Bc,{milliseconds:1e3,children:u.jsx("div",{className:"absolute top-4 m-0 flex items-center min-h-[28px] left-1/2 transform -translate-x-1/2 z-200 ",children:u.jsx(Ne,{content:"Connecting to a marimo runtime",children:u.jsx("div",{className:"flex items-center",children:u.jsx(q_,{size:5,className:"text-yellow-500"})})})})}),u.jsx(Ob,{show:e,delayMs:5e3,children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(kn,{className:"h-4 w-4"}),u.jsx("p",{children:"Connecting to a marimo runtime ..."})]})})]})||n&&u.jsx(Ob,{show:n,kind:"danger",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("p",{children:"Failed to connect."})})}),t[0]=n,t[1]=e,t[2]=o):o=t[2],o},Db=q.forwardRef((t,e)=>{const n=H.c(71);let o,r,s,i,a,l,c;n[0]!==t?({columnId:i,canDelete:o,canMoveLeft:r,canMoveRight:s,footer:a,...l}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=i,n[5]=a,n[6]=l):(o=n[1],r=n[2],s=n[3],i=n[4],a=n[5],l=n[6]),n[7]!==i?(c={id:i},n[7]=i,n[8]=c):c=n[8];const{attributes:d,listeners:h,setNodeRef:f,transform:m,transition:g,isDragging:x,isOver:p}=_1(c);let b;n[9]!==m?(b=m?Ic.Transform.toString({x:m.x,y:0,scaleX:1,scaleY:1}):void 0,n[9]=m,n[10]=b):b=n[10];const y=x?2:void 0;let v;n[11]!==b||n[12]!==y||n[13]!==g?(v={transform:b,transition:g,zIndex:y,position:"relative","--gutter-width":"50px"},n[11]=b,n[12]=y,n[13]=g,n[14]=v):v=n[14];const w=v,{deleteColumn:S,moveColumn:C,addColumn:N}=lt(),j=K_;let E;n[15]!==i||n[16]!==C?(E=()=>C({column:i,overColumn:"_left_"}),n[15]=i,n[16]=C,n[17]=E):E=n[17];const T=!r;let I,O,L;n[18]===Symbol.for("react.memo_cache_sentinel")?(I=u.jsx(k3,{className:"size-4"}),n[18]=I):I=n[18],n[19]!==E||n[20]!==T?(O=u.jsx(Ne,{content:"Move column left",side:"top",delayDuration:300,children:u.jsx(ve,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",onClick:E,disabled:T,children:I})}),n[19]=E,n[20]=T,n[21]=O):O=n[21],n[22]!==i||n[23]!==C?(L=()=>C({column:i,overColumn:"_right_"}),n[22]=i,n[23]=C,n[24]=L):L=n[24];const D=!s;let R,P,z,_,k,B;n[25]===Symbol.for("react.memo_cache_sentinel")?(R=u.jsx(zi,{className:"size-4"}),n[25]=R):R=n[25],n[26]!==D||n[27]!==L?(P=u.jsx(Ne,{content:"Move column right",side:"top",delayDuration:300,children:u.jsx(ve,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",onClick:L,disabled:D,children:R})}),n[26]=D,n[27]=L,n[28]=P):P=n[28],n[29]===Symbol.for("react.memo_cache_sentinel")?(z=u.jsx(OP,{className:"size-4 opacity-0 group-hover:opacity-50 transition-opacity duration-200"}),n[29]=z):z=n[29],n[30]!==d||n[31]!==h?(_=u.jsx("div",{className:"flex gap-2 h-full grow cursor-grab active:cursor-grabbing items-center justify-center","data-testid":"column-drag-spacer",...d,...h,children:z}),n[30]=d,n[31]=h,n[32]=_):_=n[32],n[33]===Symbol.for("react.memo_cache_sentinel")?(k=u.jsx(_o,{asChild:!0,children:u.jsx(ve,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",children:u.jsx(Gc,{className:"size-4"})})}),n[33]=k):k=n[33],n[34]!==i||n[35]!==S?(B=()=>S({columnId:i}),n[34]=i,n[35]=S,n[36]=B):B=n[36];const A=!o;let U,$,X,Y,G,W;n[37]===Symbol.for("react.memo_cache_sentinel")?(U=u.jsx(wn,{className:"mr-2 size-4"}),n[37]=U):U=n[37],n[38]!==B||n[39]!==A?($=u.jsxs(Eo,{children:[k,u.jsx(Io,{align:"end",children:u.jsxs(At,{onClick:B,disabled:A,children:[U,"Delete column"]})})]}),n[38]=B,n[39]=A,n[40]=$):$=n[40],n[41]!==N||n[42]!==i?(X=()=>{N({columnId:i}),requestAnimationFrame(j)},n[41]=N,n[42]=i,n[43]=X):X=n[43],n[44]===Symbol.for("react.memo_cache_sentinel")?(Y=u.jsx(Jo,{className:"size-4"}),n[44]=Y):Y=n[44],n[45]!==X?(G=u.jsx(Ne,{content:"Add column",side:"top",delayDuration:300,children:u.jsx(ve,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",onClick:X,children:Y})}),n[45]=X,n[46]=G):G=n[46],n[47]!==P||n[48]!==_||n[49]!==$||n[50]!==G||n[51]!==O?(W=u.jsxs("div",{className:"px-2 pt-3 pb-0 group flex items-center rounded-t-lg overflow-hidden",children:[O,P,_,$,G]}),n[47]=P,n[48]=_,n[49]=$,n[50]=G,n[51]=O,n[52]=W):W=n[52];const J=W;let V;n[53]!==e||n[54]!==f?(V=ae=>{ml(e,f)(ae)},n[53]=e,n[54]=f,n[55]=V):V=n[55];const Q=x?"":l.className,te=x?"z-20":"z-1 hover:z-10 focus-within:z-10",re=p&&"bg-accent/20";let ne,ie,se;return n[56]!==Q||n[57]!==te||n[58]!==re?(ne=xe(Q,te,re),n[56]=Q,n[57]=te,n[58]=re,n[59]=ne):ne=n[59],n[60]!==J||n[61]!==l.children?(ie=u.jsxs("div",{className:"bg-(--slate-1) rounded-lg",children:[J,l.children]}),n[60]=J,n[61]=l.children,n[62]=ie):ie=n[62],n[63]!==a||n[64]!==x||n[65]!==l||n[66]!==w||n[67]!==V||n[68]!==ne||n[69]!==ie?(se=u.jsxs("div",{tabIndex:-1,ref:V,...l,style:w,"data-is-dragging":x,className:ne,children:[ie,a]}),n[63]=a,n[64]=x,n[65]=l,n[66]=w,n[67]=V,n[68]=ne,n[69]=ie,n[70]=se):se=n[70],se});Db.displayName="SortableColumn";const Y_=M.memo(Db);function K_(){const t=document.getElementById("App");t&&t.scrollTo({left:t.scrollLeft+1e3,behavior:"smooth"})}const{getColumnWidth:X_,saveColumnWidth:J_}=DP,Rb=M.memo(t=>{const e=H.c(20),n=M.useRef(null);if(t.width==="columns"){const s=t.canDelete,i=t.columnId,a=t.canMoveLeft,l=t.canMoveRight,c=t.footer;let d,h,f,m;return e[0]!==t.index?(d=X_(t.index),e[0]=t.index,e[1]=d):d=e[1],e[2]!==t.index?(h=g=>{J_(t.index,g)},e[2]=t.index,e[3]=h):h=e[3],e[4]!==t.children||e[5]!==d||e[6]!==h?(f=u.jsx(Z_,{startingWidth:d,onResize:h,children:t.children}),e[4]=t.children,e[5]=d,e[6]=h,e[7]=f):f=e[7],e[8]!==t.canDelete||e[9]!==t.canMoveLeft||e[10]!==t.canMoveRight||e[11]!==t.columnId||e[12]!==t.footer||e[13]!==f?(m=u.jsx(Y_,{tabIndex:-1,ref:n,canDelete:s,columnId:i,canMoveLeft:a,canMoveRight:l,className:"group/column",footer:c,children:f}),e[8]=t.canDelete,e[9]=t.canMoveLeft,e[10]=t.canMoveRight,e[11]=t.columnId,e[12]=t.footer,e[13]=f,e[14]=m):m=e[14],m}let o,r;return e[15]!==t.children?(o=u.jsx("div",{"data-testid":"cell-column",className:"flex flex-col gap-5",children:t.children}),e[15]=t.children,e[16]=o):o=e[16],e[17]!==t.footer||e[18]!==o?(r=u.jsxs(u.Fragment,{children:[o,t.footer]}),e[17]=t.footer,e[18]=o,e[19]=r):r=e[19],r});Rb.displayName="Column";const Z_=t=>{const e=H.c(15),{startingWidth:n,onResize:o,children:r}=t;let s;e[0]!==o||e[1]!==n?(s={startingWidth:n,onResize:o},e[0]=o,e[1]=n,e[2]=s):s=e[2];const{resizableDivRef:i,handleRefs:a,style:l}=RP(s),c=Q_;let d,h,f,m;return e[3]!==a.left?(d=c(a.left),e[3]=a.left,e[4]=d):d=e[4],e[5]!==r||e[6]!==i||e[7]!==l?(h=u.jsx("div",{ref:i,className:"flex flex-col gap-5 box-content min-h-[100px] px-11 pt-3 pb-6 min-w-[500px] z-1",style:l,children:r}),e[5]=r,e[6]=i,e[7]=l,e[8]=h):h=e[8],e[9]!==a.right?(f=c(a.right),e[9]=a.right,e[10]=f):f=e[10],e[11]!==d||e[12]!==h||e[13]!==f?(m=u.jsxs("div",{className:"flex flex-row",children:[d,h,f]}),e[11]=d,e[12]=h,e[13]=f,e[14]=m):m=e[14],m};function Q_(t){return u.jsx("div",{ref:t,className:`w-[3px] cursor-col-resize transition-colors duration-200 z-100
124
+ relative before:content-[''] before:absolute before:inset-y-0 before:-left-[3px]
125
+ before:right-[-3px] before:w-[9px] before:z-[-1]
126
+ hover/column:bg-[var(--slate-3)] dark:hover/column:bg-[var(--slate-5)]
127
+ hover/column:hover:bg-primary/60 dark:hover/column:hover:bg-primary/60`})}const e6=t=>{const e=H.c(10),{width:n}=t,{banners:o}=AF(),{removeBanner:r}=TF();if(o.length===0)return null;const s=n==="columns"&&"sticky left-12 w-full max-w-[80vw]";let i,a,l;if(e[0]!==s?(i=xe("flex flex-col gap-4 mb-5 print:hidden",s),e[0]=s,e[1]=i):i=e[1],e[2]!==o||e[3]!==r){let c;e[5]!==r?(c=d=>u.jsxs(da,{kind:d.variant||"info",className:"flex flex-col rounded p-3",children:[u.jsxs("div",{className:"flex justify-between",children:[u.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[u.jsx(MC,{className:"w-5 h-5 inline-block mr-2"}),d.title]}),u.jsx(ve,{"data-testid":"remove-banner-button",variant:"text",size:"icon",onClick:()=>r(d.id),children:u.jsx(wn,{className:"w-5 h-5"})})]}),u.jsxs("div",{className:"flex justify-between items-end",children:[u.jsx("span",{children:Zm({html:d.description})}),d.action==="restart"&&u.jsx(t6,{})]})]},d.id),e[5]=r,e[6]=c):c=e[6],a=o.map(c),e[2]=o,e[3]=r,e[4]=a}else a=e[4];return e[7]!==i||e[8]!==a?(l=u.jsx("div",{className:i,children:a}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l},t6=()=>{const t=H.c(3),e=Lg();let n,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=u.jsx(Vp,{className:"w-3 h-3 mr-2"}),t[0]=n):n=t[0],t[1]!==e?(o=u.jsxs(ve,{"data-testid":"restart-session-button",variant:"link",size:"xs",onClick:e,children:[n,"Restart"]}),t[1]=e,t[2]=o):o=t[2],o},n6=vt(t=>{const e=t(In);for(const n of e.cellIds.inOrderIds){const o=e.cellRuntime[n];if(o.status==="idle"&&o.consoleOutputs.some(r=>r.channel==="stdin"&&r.response===void 0))return!0}return!1}),o6=()=>{const t=H.c(3),e=r6;if(!je(n6))return null;let n,o,r;if(t[0]===Symbol.for("react.memo_cache_sentinel")?(n=u.jsx("div",{className:"flex justify-between",children:u.jsx("span",{className:"font-bold text-lg flex items-center mb-1",children:"Program waiting for input"})}),t[0]=n):n=t[0],t[1]===Symbol.for("react.memo_cache_sentinel")?(o=u.jsx(nC,{className:"inline",children:"stdin"}),t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")){const s=u.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-1/2 transform -translate-x-1/2 z-200 opacity-95",children:u.jsxs(da,{kind:"info",className:"flex flex-col rounded py-2 px-4 animate-in slide-in-from-top w-fit",children:[n,u.jsx("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:u.jsx("div",{children:u.jsxs("p",{children:["The program is still running, but blocked on"," ",o,".",u.jsx(ve,{variant:"link",className:"h-auto font-normal",onClick:e,children:"Jump to the cell"})]})})})]})});r=u.jsx(Bc,{milliseconds:2e3,children:s}),t[2]=r}else r=t[2];return r};function r6(){const t=document.querySelector("[data-stdin-blocking]");t?(t.scrollIntoView({behavior:"smooth",block:"center"}),requestAnimationFrame(()=>{t.focus()})):mt.error("No element with data-stdin-blocking found")}function s6(){const t=setTimeout(i6,100);return()=>clearTimeout(t)}function i6(){requestAnimationFrame(a6)}function a6(){const t=function(e){const n=e.match(/scrollTo=([^&]+)/),o=n==null?void 0:n[1];return o?decodeURIComponent(o.split("&")[0]):null}(window.location.hash);if(t)(function(e){var o,r;if(Lb)return;const n=document.querySelector(`[data-cell-name="${e}"]`);if(n){if(n.scrollIntoView({behavior:"smooth",block:"start"}),Lb=!0,n instanceof HTMLElement){n.focus();const{cellHandles:s}=bn(),i=n.dataset.cellId;if(!i)return void mt.error(`Missing cellId for cell with name ${e}`);const a=(r=(o=s[i])==null?void 0:o.current)==null?void 0:r.editorView;a&&a.focus()}}else mt.warn(`Cannot focus cell with name ${e} because it was not found`),Pb()})(t);else try{Pb()}catch(e){const n=e;mt.warn("Error focusing first editor",n)}}function Pb(){var o,r;const{cellIds:t,cellData:e,cellHandles:n}=bn();for(const s of t.iterateTopLevelIds){const i=n[s];if(!((o=e[s])==null?void 0:o.config.hide_code)&&((r=i==null?void 0:i.current)!=null&&r.editorView))return void i.current.editorView.focus()}}let Lb=!1;const l6=t=>{const e=H.c(8),n=je(PP),o=t.appConfig.width==="columns";let r,s,i;return e[0]!==t?(r=u.jsx(c6,{...t}),e[0]=t,e[1]=r):r=e[1],e[2]!==n||e[3]!==r?(s=u.jsx(N1,{id:"column-container",items:n,strategy:TN,children:r}),e[2]=n,e[3]=r,e[4]=s):s=e[4],e[5]!==o||e[6]!==s?(i=u.jsx(H_,{multiColumn:o,children:s}),e[5]=o,e[6]=s,e[7]=i):i=e[7],i},c6=t=>{const e=H.c(26),{mode:n,userConfig:o,appConfig:r}=t,s=lt(),{theme:i}=Zo(),{toggleSidebarPanel:a}=qi();OC(s6),Rt("global.focusTop",s.focusTopCell),Rt("global.focusBottom",s.focusBottomCell),Rt("global.toggleSidebar",a),Rt("global.foldCode",s.foldAll),Rt("global.unfoldCode",s.unfoldAll),Rt("global.formatAll",h6),Rt("cell.hideCode",Bn.NOOP),Rt("cell.format",Bn.NOOP);const l=wr(),c=LP(),d=l.getColumnIds(),h=s.scrollToTarget;let f,m;e[0]!==c||e[1]!==h?(f=()=>{c!==null&&h()},e[0]=c,e[1]=h,e[2]=f):f=e[2],e[3]!==l||e[4]!==c||e[5]!==h?(m=[l,c,h],e[3]=l,e[4]=c,e[5]=h,e[6]=m):m=e[6],M.useEffect(f,m);const g=MF;let x,p,b,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx(I_,{}),p=u.jsx(o6,{}),b=u.jsx(G_,{}),e[7]=x,e[8]=p,e[9]=b):(x=e[7],p=e[8],b=e[9]),e[10]!==r.width?(y=u.jsx(e6,{width:r.width}),e[10]=r.width,e[11]=y):y=e[11];const v=r.width==="columns"&&"grid grid-flow-col auto-cols-min gap-6";let w;e[12]!==v?(w=xe(v),e[12]=v,e[13]=w):w=e[13];const S=d.map((E,T)=>u.jsx(d6,{columnId:E,index:T,columnsLength:d.length,appConfig:r,mode:n,userConfig:o,theme:i},E));let C,N,j;return e[14]!==w||e[15]!==S?(C=u.jsx("div",{className:w,children:S}),e[14]=w,e[15]=S,e[16]=C):C=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(N=u.jsx(OF,{}),e[17]=N):N=e[17],e[18]!==g||e[19]!==r||e[20]!==C||e[21]!==x||e[22]!==p||e[23]!==b||e[24]!==y?(j=u.jsxs(g,{className:"pb-[40vh]",invisible:!1,appConfig:r,innerClassName:"pr-4",children:[x,p,b,y,C,N]}),e[18]=g,e[19]=r,e[20]=C,e[21]=x,e[22]=p,e[23]=b,e[24]=y,e[25]=j):j=e[25],j},d6=t=>{const e=H.c(54),{columnId:n,index:o,columnsLength:r,appConfig:s,mode:i,userConfig:a,theme:l}=t,c=wr();let d,h,f,m,g,x,p,b,y,v,w,S,C,N,j,E;if(e[0]!==s.width||e[1]!==c||e[2]!==n||e[3]!==r||e[4]!==o||e[5]!==i||e[6]!==l||e[7]!==a){const T=c.get(n);let I;Un(T,`Expected column for: ${n}`),e[22]!==c?(I=c.hasOnlyOneId(),e[22]=c,e[23]=I):I=e[23];const O=I;let L;e[24]!==c.inOrderIds?(L=c.inOrderIds.includes(ca),e[24]=c.inOrderIds,e[25]=L):L=e[25];const D=L;h=Rb,w=n,S=o,C=o>0,N=o<r-1,m=s.width,g=r>1;const R=s.width==="columns"&&"opacity-0 group-hover/column:opacity-100";let P;e[26]!==R?(P=xe(R),e[26]=R,e[27]=P):P=e[27],e[28]!==n||e[29]!==P?(x=u.jsx(u6,{columnId:n,className:P}),e[28]=n,e[29]=P,e[30]=x):x=e[30],d=N1,f=`column-${o+1}`,p=T.topLevelIds,b=MN,e[31]!==D||e[32]!==o||e[33]!==i||e[34]!==l||e[35]!==a?(y=o===0&&D&&u.jsx(Ib,{cellId:ca,theme:l,showPlaceholder:!1,canDelete:!0,mode:i,userConfig:a,isCollapsed:!1,collapseCount:0,canMoveX:!1},ca),e[31]=D,e[32]=o,e[33]=i,e[34]=l,e[35]=a,e[36]=y):y=e[36],v=T.topLevelIds.map(z=>z===ca?null:u.jsx(Ib,{cellId:z,theme:l,showPlaceholder:O,canDelete:!O,mode:i,userConfig:a,isCollapsed:T.isCollapsed(z),collapseCount:T.getCount(z),canMoveX:s.width==="columns"},z)),e[0]=s.width,e[1]=c,e[2]=n,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=a,e[8]=d,e[9]=h,e[10]=f,e[11]=m,e[12]=g,e[13]=x,e[14]=p,e[15]=b,e[16]=y,e[17]=v,e[18]=w,e[19]=S,e[20]=C,e[21]=N}else d=e[8],h=e[9],f=e[10],m=e[11],g=e[12],x=e[13],p=e[14],b=e[15],y=e[16],v=e[17],w=e[18],S=e[19],C=e[20],N=e[21];return e[37]!==d||e[38]!==f||e[39]!==p||e[40]!==b||e[41]!==y||e[42]!==v?(j=u.jsxs(d,{id:f,items:p,strategy:b,children:[y,v]}),e[37]=d,e[38]=f,e[39]=p,e[40]=b,e[41]=y,e[42]=v,e[43]=j):j=e[43],e[44]!==h||e[45]!==m||e[46]!==g||e[47]!==x||e[48]!==j||e[49]!==w||e[50]!==S||e[51]!==C||e[52]!==N?(E=u.jsx(h,{columnId:w,index:S,canMoveLeft:C,canMoveRight:N,width:m,canDelete:g,footer:x,children:j}),e[44]=h,e[45]=m,e[46]=g,e[47]=x,e[48]=j,e[49]=w,e[50]=S,e[51]=C,e[52]=N,e[53]=E):E=e[53],E},u6=t=>{const e=H.c(17),{columnId:n,className:o}=t,{createNewCell:r}=lt(),[s,i]=FP(!1),a=je(ic),l=je(X3);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=xe("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"),e[0]=c):c=e[0];const d=c;let h;e[1]!==a||e[2]!==n||e[3]!==r||e[4]!==s||e[5]!==i.toggle||e[6]!==l?(h=()=>s?u.jsx(zP,{onClose:i.toggle}):u.jsxs(u.Fragment,{children:[u.jsxs(ve,{className:d,variant:"text",size:"sm",disabled:!l,onClick:()=>r({cellId:{type:"__end__",columnId:n},before:!1}),children:[u.jsx(qp,{className:"mr-2 size-4 shrink-0"}),"Python"]}),u.jsxs(ve,{className:d,variant:"text",size:"sm",disabled:!l,onClick:()=>{Jn({autoInstantiate:!0,createNewCell:r}),r({cellId:{type:"__end__",columnId:n},before:!1,code:new Wi().defaultCode,hideCode:!0})},children:[u.jsx(Kp,{className:"mr-2 size-4 shrink-0"}),"Markdown"]}),u.jsxs(ve,{className:d,variant:"text",size:"sm",disabled:!l,onClick:()=>{Jn({autoInstantiate:!0,createNewCell:r}),r({cellId:{type:"__end__",columnId:n},before:!1,code:new Pc().defaultCode})},children:[u.jsx(Yo,{className:"mr-2 size-4 shrink-0"}),"SQL"]}),u.jsx(Ne,{content:a?null:u.jsx("span",{children:"Enable via settings under AI Assist"}),delayDuration:100,asChild:!1,children:u.jsxs(ve,{className:d,variant:"text",size:"sm",disabled:!a||!l,onClick:i.toggle,children:[u.jsx(Fi,{className:"mr-2 size-4 shrink-0"}),"Generate with AI"]})})]}),e[1]=a,e[2]=n,e[3]=r,e[4]=s,e[5]=i.toggle,e[6]=l,e[7]=h):h=e[7];const f=h,m=!s&&"w-fit",g=s&&"opacity-100 w-full max-w-4xl shadow-lg shadow-(--blue-3)";let x,p,b;return e[8]!==o||e[9]!==m||e[10]!==g?(x=xe("shadow-sm border border-border rounded transition-all duration-200 overflow-hidden divide-x divide-border flex",m,g,o),e[8]=o,e[9]=m,e[10]=g,e[11]=x):x=e[11],e[12]!==f?(p=f(),e[12]=f,e[13]=p):p=e[13],e[14]!==x||e[15]!==p?(b=u.jsx("div",{className:"flex justify-center mt-4 pt-6 pb-32 group gap-4 w-full print:hidden",children:u.jsx("div",{className:x,children:p})}),e[14]=x,e[15]=p,e[16]=b):b=e[16],b};function h6(){Y3()}const f6=BP(t=>{oC().syncCellIds(t)},400),m6=(t,e)=>{Qe.get(us)||t.isEmpty()||e.isEmpty()||Yi(t.inOrderIds,e.inOrderIds)||f6({cell_ids:t.inOrderIds})},Fb=t=>{const e=H.c(70),{userConfig:n,appConfig:o,hideControls:r}=t,s=r!==void 0&&r;UP(la,m6);const{setCells:i,mergeAllColumns:a,collapseAllCells:l,expandAllCells:c}=lt(),d=je(cm),h=je($P),f=je(VP),m=Cm(),g=jt(Cd),{sendComponentValues:x,sendInterrupt:p}=tt(),b=d.mode==="edit",y=d.mode==="present",v=je(HP);let w,S;e[0]!==x?(w=()=>(jj.INSTANCE.start(x),p6),e[0]=x,e[1]=w):w=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[2]=S):S=e[2],M.useEffect(w,S);const C=n.runtime.auto_instantiate;let N,j,E;e[3]!==i||e[4]!==g?(N=(ae,ge)=>{i(ae);const oe=ae.map(g6),ue=ae.map(x6),de=ae.map(b6);g({names:oe,codes:ue,configs:de,layout:ge})},e[3]=i,e[4]=g,e[5]=N):N=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(j=mC(),e[6]=j):j=e[6],e[7]!==N||e[8]!==n.runtime.auto_instantiate?(E={autoInstantiate:C,setCells:N,sessionId:j},e[7]=N,e[8]=n.runtime.auto_instantiate,e[9]=E):E=e[9];const{connection:T}=DF(E);let I,O;e[10]!==o.app_title||e[11]!==m?(I=()=>{document.title=o.app_title||yn.basename(m??"")||"Untitled Notebook"},O=[o.app_title,m],e[10]=o.app_title,e[11]=m,e[12]=I,e[13]=O):(I=e[12],O=e[13]),M.useEffect(I,O);const L=_c(o.width);let D,R;e[14]!==o.width||e[15]!==a||e[16]!==L?(D=()=>{L==="columns"&&o.width!=="columns"&&a()},e[14]=o.width,e[15]=a,e[16]=L,e[17]=D):D=e[17],e[18]!==o.width||e[19]!==a||e[20]!==h||e[21]!==L?(R=[o.width,L,a,h],e[18]=o.width,e[19]=a,e[20]=h,e[21]=L,e[22]=R):R=e[22],M.useEffect(D,R);const P=function(){const ae=H.c(2),ge=Ts();let oe;return ae[0]!==ge?(oe=()=>ge(VO(bn())),ae[0]=ge,ae[1]=oe):oe=ae[1],Le(oe)}(),z=rg(),_=og();let k,B,A,U,$,X,Y;e[23]!==P?(k=()=>{P()},e[23]=P,e[24]=k):k=e[24],Rt("global.runStale",k),e[25]!==p?(B=()=>{p()},e[25]=p,e[26]=B):B=e[26],Rt("global.interrupt",B),e[27]!==_?(A=()=>{_()},e[27]=_,e[28]=A):A=e[28],Rt("global.hideCode",A),e[29]!==z?(U=()=>{z()},e[29]=z,e[30]=U):U=e[30],Rt("global.runAll",U),e[31]!==l?($=()=>{l()},e[31]=l,e[32]=$):$=e[32],Rt("global.collapseAllSections",$),e[33]!==c?(X=()=>{c()},e[33]=c,e[34]=X):X=e[34],Rt("global.expandAllSections",X),e[35]!==o||e[36]!==n||e[37]!==d.mode?(Y=u.jsx(l6,{mode:d.mode,userConfig:n,appConfig:o}),e[35]=o,e[36]=n,e[37]=d.mode,e[38]=Y):Y=e[38];const G=Y,W=o.width;let J,V,Q,te,re,ne,ie,se;return e[39]===Symbol.for("react.memo_cache_sentinel")?(J=xe("pt-4 sm:pt-12 pb-2 mb-4 print:hidden z-50","sticky left-0"),e[39]=J):J=e[39],e[40]!==m||e[41]!==b?(V=b&&u.jsx("div",{className:"flex items-center justify-center container",children:u.jsx(D4,{filename:m})}),e[40]=m,e[41]=b,e[42]=V):V=e[42],e[43]!==T||e[44]!==V?(Q=u.jsx(PF,{connection:T,className:J,children:V}),e[43]=T,e[44]=V,e[45]=Q):Q=e[45],e[46]!==o||e[47]!==G||e[48]!==f||e[49]!==d.mode?(te=f&&u.jsx(RF,{appConfig:o,mode:d.mode,children:G}),e[46]=o,e[47]=G,e[48]=f,e[49]=d.mode,e[50]=te):te=e[50],e[51]!==o.width||e[52]!==T||e[53]!==v||e[54]!==Q||e[55]!==te?(re=u.jsxs(LF,{connection:T,isRunning:v,width:W,children:[Q,te]}),e[51]=o.width,e[52]=T,e[53]=v,e[54]=Q,e[55]=te,e[56]=re):re=e[56],e[57]===Symbol.for("react.memo_cache_sentinel")?(ne=u.jsx(W4,{}),e[57]=ne):ne=e[57],e[58]!==o||e[59]!==T||e[60]!==s||e[61]!==y||e[62]!==v||e[63]!==P||e[64]!==p||e[65]!==_?(ie=!s&&u.jsx(Vc,{children:u.jsx(I4,{presenting:y,onTogglePresenting:_,onInterrupt:p,onRun:P,connectionState:T.state,running:v,appConfig:o})}),e[58]=o,e[59]=T,e[60]=s,e[61]=y,e[62]=v,e[63]=P,e[64]=p,e[65]=_,e[66]=ie):ie=e[66],e[67]!==re||e[68]!==ie?(se=u.jsxs(u.Fragment,{children:[re,ne,ie]}),e[67]=re,e[68]=ie,e[69]=se):se=e[69],se};function p6(){jj.INSTANCE.stop()}function g6(t){return t.name}function x6(t){return t.code}function b6(t){return t.config}const zb=t=>je(WP)[t.capability]?t.children:null,mn=M.forwardRef((t,e)=>{const n=H.c(18);let o,r,s,i,a;n[0]!==t?({children:o,tooltip:a,selected:i,className:r,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=i,n[5]=a):(o=n[1],r=n[2],s=n[3],i=n[4],a=n[5]);const l=!i&&"hover:bg-(--sage-3)",c=i&&"bg-(--sage-4)";let d,h;n[6]!==r||n[7]!==l||n[8]!==c?(d=xe("h-full flex items-center p-2 text-sm shadow-inset font-mono cursor-pointer rounded",l,c,r),n[6]=r,n[7]=l,n[8]=c,n[9]=d):d=n[9],n[10]!==o||n[11]!==e||n[12]!==s||n[13]!==d?(h=u.jsx("div",{ref:e,className:d,...s,children:o}),n[10]=o,n[11]=e,n[12]=s,n[13]=d,n[14]=h):h=n[14];const f=h;if(a){let m;return n[15]!==f||n[16]!==a?(m=u.jsx(Ne,{content:a,side:"top",delayDuration:200,children:f}),n[15]=f,n[16]=a,n[17]=m):m=n[17],m}return f});mn.displayName="FooterItem";const y6=()=>{var d;const t=H.c(14),e=je(DC),n=je(ic),o=((d=e==null?void 0:e.open_ai)==null?void 0:d.model)||"gpt-4-turbo",{handleClick:r}=fa();if(!n){let h,f,m;return t[0]!==r?(h=()=>r("ai"),t[0]=r,t[1]=h):h=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(f=u.jsx(Fi,{className:"h-4 w-4 opacity-60"}),t[2]=f):f=t[2],t[3]!==h?(m=u.jsx(mn,{tooltip:"Assist is disabled",selected:!1,onClick:h,"data-testid":"footer-ai-disabled",children:f}),t[3]=h,t[4]=m):m=t[4],m}let s,i,a,l,c;return t[5]===Symbol.for("react.memo_cache_sentinel")?(s=u.jsx("b",{children:"Assist model:"}),t[5]=s):s=t[5],t[6]!==o?(i=u.jsxs(u.Fragment,{children:[s," ",o]}),t[6]=o,t[7]=i):i=t[7],t[8]!==r?(a=()=>r("ai"),t[8]=r,t[9]=a):a=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx(Fi,{className:"h-4 w-4"}),t[10]=l):l=t[10],t[11]!==i||t[12]!==a?(c=u.jsx(mn,{tooltip:i,onClick:a,selected:!1,"data-testid":"footer-ai-enabled",children:l}),t[11]=i,t[12]=a,t[13]=c):c=t[13],c},v6=()=>{const t=H.c(26),e=je(ln).state,n=qm();let o,r;t[0]!==e||t[1]!==n?(o=async()=>{if(e===Bt.OPEN){if(tn())return{isHealthy:!0,lastChecked:new Date,error:void 0};try{return{isHealthy:await n.isHealthy(),lastChecked:new Date,error:void 0}}catch(w){const S=w;return{isHealthy:!1,lastChecked:new Date,error:S instanceof Error?S.message:"Unknown error"}}}},r=[n,e],t[0]=e,t[1]=n,t[2]=o,t[3]=r):(o=t[2],r=t[3]);const{isFetching:s,error:i,data:a,refetch:l}=Tn(o,r),c=e===Bt.OPEN?3e4:null;let d,h;t[4]!==c?(d={delayMs:c,whenVisible:!0},t[4]=c,t[5]=d):d=t[5],ha(l,d),t[6]!==e||t[7]!==a||t[8]!==i?(h=()=>[km(e.toLowerCase()),a!=null&&a.lastChecked?a.isHealthy?"\u2713 Healthy":"\u2717 Unhealthy":"Health: Unknown",i?`Error: ${i}`:""].filter(Boolean).join(`
128
+ `),t[6]=e,t[7]=a,t[8]=i,t[9]=h):h=t[9];const f=h;let m;t[10]!==e||t[11]!==(a==null?void 0:a.isHealthy)||t[12]!==(a==null?void 0:a.lastChecked)||t[13]!==s?(m=()=>s||e===Bt.CONNECTING?u.jsx(kn,{size:"small"}):e===Bt.CLOSING?u.jsx(kn,{className:"text-destructive",size:"small"}):e===Bt.OPEN?a!=null&&a.isHealthy?u.jsx(Kc,{className:"w-4 h-4 text-(--green-9)"}):a!=null&&a.lastChecked?u.jsx(MC,{className:"w-4 h-4 text-(--yellow-9)"}):u.jsx(Kc,{className:"w-4 h-4"}):u.jsx(ma,{className:"w-4 h-4 text-red-500"}),t[10]=e,t[11]=a==null?void 0:a.isHealthy,t[12]=a==null?void 0:a.lastChecked,t[13]=s,t[14]=m):m=t[14];const g=m,x=f();let p,b,y,v;return t[15]!==e?(p=e===Bt.OPEN&&u.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Click to refresh health status"}),t[15]=e,t[16]=p):p=t[16],t[17]!==x||t[18]!==p?(b=u.jsxs("div",{className:"text-sm whitespace-pre-line",children:[x,p]}),t[17]=x,t[18]=p,t[19]=b):b=t[19],t[20]!==g?(y=g(),t[20]=g,t[21]=y):y=t[21],t[22]!==l||t[23]!==b||t[24]!==y?(v=u.jsx(mn,{tooltip:b,selected:!1,onClick:l,"data-testid":"footer-backend-status",children:y}),t[22]=l,t[23]=b,t[24]=y,t[25]=v):v=t[25],v},w6=t=>{const e=H.c(3);let n,o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=u.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"}),e[0]=n):n=e[0],e[1]!==t?(o=u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1.24em",height:"1em",viewBox:"0 0 256 208",fill:"currentColor",...t,children:n}),e[1]=t,e[2]=o):o=e[2],o},k6=vt(t=>t(qP).completion.copilot),C6=()=>{const t=H.c(1);if(je(k6)==="github"){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=u.jsx(j6,{}),t[0]=e):e=t[0],e}return null},Bb=mt.get("[copilot-status-bar]"),j6=()=>{const t=je(fj),e=je(bF)!==null,{handleClick:n}=fa(),o=()=>n("ai"),r=t?"Ready":"Not connected",s=jt(fj),i=jt(yF);return OC(()=>{const a=hj();let l=!0;return(async()=>{try{if(await a.initializePromise.catch(d=>{throw Bb.error("Failed to initialize",d),a.close(),d}),!l)return;const c=await a.signedIn();if(!l)return;s(c),i(c?"signedIn":"signedOut")}catch(c){if(!l)return;Bb.warn("Connection failed",c),s(!1),i("connectionError"),Je({title:"GitHub Copilot Connection Error",description:"Failed to connect to GitHub Copilot. Check settings and try again.",variant:"danger",action:u.jsx(ve,{variant:"link",onClick:o,children:"Settings"})})}})(),()=>{l=!1}}),u.jsx(mn,{tooltip:u.jsxs(u.Fragment,{children:[u.jsx("b",{children:"GitHub Copilot:"})," ",r]}),selected:!1,onClick:o,"data-testid":"footer-copilot-status",children:u.jsx("span",{children:e?u.jsx(kn,{className:"h-4 w-4"}):u.jsx(w6,{className:xe("h-4 w-4",!t&&"opacity-60")})})})},S6=()=>{const t=H.c(18),[e,n]=M.useState(0),o=je(ln),{getUsageStats:r}=tt();let s,i,a,l;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>n(I6),i={delayMs:1e4,whenVisible:!0},t[0]=s,t[1]=i):(s=t[0],i=t[1]),ha(s,i),t[2]!==o.state||t[3]!==r?(a=async()=>tn()||o.state!==Bt.OPEN?null:r(),t[2]=o.state,t[3]=r,t[4]=a):a=t[4],t[5]!==o.state||t[6]!==e?(l=[e,o.state],t[5]=o.state,t[6]=e,t[7]=l):l=t[7];const{data:c}=Tn(a,l);let d,h,f,m;return t[8]!==c?(d=(c==null?void 0:c.gpu)&&c.gpu.length>0&&u.jsx(_6,{gpus:c.gpu}),t[8]=c,t[9]=d):d=t[9],t[10]!==c?(h=c&&u.jsx(N6,{memory:c.memory,kernel:c.kernel,server:c.server}),t[10]=c,t[11]=h):h=t[11],t[12]!==c?(f=c&&u.jsx(E6,{cpu:c.cpu}),t[12]=c,t[13]=f):f=t[13],t[14]!==d||t[15]!==h||t[16]!==f?(m=u.jsxs("div",{className:"flex gap-2 items-center px-1",children:[d,h,f]}),t[14]=d,t[15]=h,t[16]=f,t[17]=m):m=t[17],m},N6=t=>{const e=H.c(25),{memory:n,kernel:o,server:r}=t,{percent:s,total:i,available:a}=n;let l;e[0]!==s?(l=Math.round(s),e[0]=s,e[1]=l):l=e[1];const c=l;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx("b",{children:"computer memory:"}),e[2]=d):d=e[2];const h=i-a;let f,m,g,x,p,b,y,v,w;return e[3]!==h?(f=Vu(h),e[3]=h,e[4]=f):f=e[4],e[5]!==i?(m=Vu(i),e[5]=i,e[6]=m):m=e[6],e[7]!==c||e[8]!==f||e[9]!==m?(g=u.jsxs("span",{children:[d," ",f," / ",m," GB (",c,"%)"]}),e[7]=c,e[8]=f,e[9]=m,e[10]=g):g=e[10],e[11]!==r?(x=(r==null?void 0:r.memory)&&u.jsxs("span",{children:[u.jsx("b",{children:"marimo server:"})," ",vl(r.memory)]}),e[11]=r,e[12]=x):x=e[12],e[13]!==o?(p=(o==null?void 0:o.memory)&&u.jsxs("span",{children:[u.jsx("b",{children:"kernel:"})," ",vl(o.memory)]}),e[13]=o,e[14]=p):p=e[14],e[15]!==g||e[16]!==x||e[17]!==p?(b=u.jsxs("div",{className:"flex flex-col gap-1",children:[g,x,p]}),e[15]=g,e[16]=x,e[17]=p,e[18]=b):b=e[18],e[19]===Symbol.for("react.memo_cache_sentinel")?(y=u.jsx(Dp,{className:"w-4 h-4"}),e[19]=y):y=e[19],e[20]!==c?(v=u.jsxs("div",{className:"flex items-center gap-1","data-testid":"memory-usage-bar",children:[y,u.jsx($u,{percent:c,colorClassName:"bg-primary"})]}),e[20]=c,e[21]=v):v=e[21],e[22]!==v||e[23]!==b?(w=u.jsx(Ne,{delayDuration:200,content:b,children:v}),e[22]=v,e[23]=b,e[24]=w):w=e[24],w},E6=t=>{const e=H.c(11),{cpu:n}=t,{percent:o}=n;let r;e[0]!==o?(r=Math.round(o),e[0]=o,e[1]=r):r=e[1];const s=r;let i,a,l,c,d;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=u.jsx("b",{children:"CPU:"}),e[2]=i):i=e[2],e[3]!==s?(a=u.jsxs("span",{children:[i," ",s,"%"]}),e[3]=s,e[4]=a):a=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx(vF,{className:"w-4 h-4"}),e[5]=l):l=e[5],e[6]!==s?(c=u.jsxs("div",{className:"flex items-center gap-1","data-testid":"cpu-bar",children:[l,u.jsx($u,{percent:s,colorClassName:"bg-primary"})]}),e[6]=s,e[7]=c):c=e[7],e[8]!==a||e[9]!==c?(d=u.jsx(Ne,{delayDuration:200,content:a,children:c}),e[8]=a,e[9]=c,e[10]=d):d=e[10],d},_6=t=>{const e=H.c(12),{gpus:n}=t;let o;e[0]!==n?(o=Math.round(n.reduce(A6,0)/n.length),e[0]=n,e[1]=o):o=e[1];const r=o;let s,i,a,l,c;return e[2]!==n?(s=n.map(T6),e[2]=n,e[3]=s):s=e[3],e[4]!==s?(i=u.jsx("div",{className:"flex flex-col gap-1",children:s}),e[4]=s,e[5]=i):i=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(a=u.jsx(Pp,{className:"w-4 h-4"}),e[6]=a):a=e[6],e[7]!==r?(l=u.jsxs("div",{className:"flex items-center gap-1","data-testid":"gpu-bar",children:[a,u.jsx($u,{percent:r,colorClassName:"bg-(--grass-9)"})]}),e[7]=r,e[8]=l):l=e[8],e[9]!==i||e[10]!==l?(c=u.jsx(Ne,{delayDuration:200,content:i,children:l}),e[9]=i,e[10]=l,e[11]=c):c=e[11],c},$u=t=>{const e=H.c(7),{percent:n,colorClassName:o}=t;let r;e[0]!==o?(r=xe("h-full bg-primary",o),e[0]=o,e[1]=r):r=e[1];const s=`${n}%`;let i,a;return e[2]!==s?(i={width:s},e[2]=s,e[3]=i):i=e[3],e[4]!==r||e[5]!==i?(a=u.jsx("div",{className:"h-3 w-20 bg-(--slate-4) rounded-lg overflow-hidden border",children:u.jsx("div",{className:r,style:i})}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a};function vl(t){return t>1073741824?`${Vu(t)} GB`:`${function(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(e/1048576)}(t)} MB`}function Vu(t){return new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(t/1073741824)}function I6(t){return t+1}function A6(t,e){return t+e.memory.percent}function T6(t){return u.jsxs("span",{children:[u.jsxs("b",{children:["GPU ",t.index," (",t.name,"):"]})," ",vl(t.memory.used)," / ",vl(t.memory.total)," GB (",Math.round(t.memory.percent),"%)"]},t.index)}const Ub=vt(!1);function Hu(t,e,n=new Set){if(n.has(t))return new Set;n.add(t);const o=new Set;for(const r of e(t)){o.add(r);for(const s of Hu(r,e,n))o.add(s)}return o}const M6=vt(t=>{const e=t(la),n=t(Sc);return function(o,r){var a,l,c;const s=new Map;for(const d of o)s.set(d,{variables:new Set,parents:new Set,children:new Set});for(const d of Object.values(r))if(d.dataType!=="module")for(const h of d.declaredBy){(a=s.get(h))==null||a.variables.add(d.name);for(const f of d.usedBy)h!==f&&((l=s.get(f))==null||l.parents.add(h),(c=s.get(h))==null||c.children.add(f))}const i={};for(const[d,h]of s.entries())i[d]={parents:h.parents,children:h.children,variables:[...h.variables],ancestors:Hu(d,f=>{var m;return((m=s.get(f))==null?void 0:m.parents)??new Set}),descendants:Hu(d,f=>{var m;return((m=s.get(f))==null?void 0:m.children)??new Set})};return i}(e.inOrderIds,n)});function O6(t,e){return e?t.usedBy.includes(e.id)||t.declaredBy.includes(e.id)?!0:t.declaredBy.some(n=>e.graph.parents.has(n))?t.usedBy.some(n=>e.graph.parents.has(n)):!!t.declaredBy.some(n=>e.graph.children.has(n)):!1}const D6=()=>{const t=H.c(6),[e,n]=Dt(Ub);let o,r,s;return t[0]!==n?(o=()=>n(R6),t[0]=n,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=u.jsx(Op,{className:"h-4 w-4"}),t[2]=r):r=t[2],t[3]!==e||t[4]!==o?(s=u.jsx(mn,{tooltip:"Toggle Minimap",selected:e,onClick:o,"data-testid":"footer-minimap",children:r}),t[3]=e,t[4]=o,t[5]=s):s=t[5],s};function R6(t){return!t}const P6=()=>{const t=H.c(13),e=je(Pr),[n,o]=Dt(pC),[r,s]=M.useState(!1);if(!Lc()||e==="disabled")return null;const i=e?"Real-time collaboration active":"Connecting to real-time collaboration";let a,l,c,d,h,f;return t[0]===Symbol.for("react.memo_cache_sentinel")?(a=u.jsx(eg,{className:"w-4 h-4"}),t[0]=a):a=t[0],t[1]!==i?(l=u.jsx(Cs,{asChild:!0,children:u.jsx(mn,{tooltip:i,selected:!1,"data-testid":"footer-rtc-status",children:a})}),t[1]=i,t[2]=l):l=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(c=u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"font-medium leading-none",children:"Username"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Set your username for real-time collaboration"})]}),t[3]=c):c=t[3],t[4]!==o?(d=m=>o(m.target.value),t[4]=o,t[5]=d):d=t[5],t[6]!==d||t[7]!==n?(h=u.jsx(xs,{className:"w-80",children:u.jsxs("div",{className:"space-y-4",children:[c,u.jsx(qo,{value:n,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",onChange:d,placeholder:"Enter your username"})]})}),t[6]=d,t[7]=n,t[8]=h):h=t[8],t[9]!==r||t[10]!==l||t[11]!==h?(f=u.jsxs(yr,{open:r,onOpenChange:s,children:[l,h]}),t[9]=r,t[10]=l,t[11]=h,t[12]=f):f=t[12],f},L6=t=>{const e=H.c(104),{className:n}=t,{saveUserConfig:o}=tt(),[r,s]=GP(),i=br()[0],[a,l]=M.useState(!1);let c,d,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{const _e=window.matchMedia("(min-width: 768px)"),ke=()=>{_e.matches&&l(!1)};return _e.addEventListener("change",ke),()=>_e.removeEventListener("change",ke)},d=[],e[0]=c,e[1]=d):(c=e[0],d=e[1]),M.useEffect(c,d),e[2]!==i||e[3]!==o||e[4]!==s?(h=async _e=>{const ke={...i,runtime:{...i.runtime,auto_instantiate:_e}};await o({config:ke}).then(()=>s(ke))},e[2]=i,e[3]=o,e[4]=s,e[5]=h):h=e[5];const f=h;let m;e[6]!==o||e[7]!==s||e[8]!==r?(m=async _e=>{const ke={...r,runtime:{...r.runtime,on_cell_change:_e?"autorun":"lazy"}};await o({config:ke}).then(()=>s(ke))},e[6]=o,e[7]=s,e[8]=r,e[9]=m):m=e[9];const g=m;let x;e[10]!==o||e[11]!==s||e[12]!==r?(x=async _e=>{const ke={...r,runtime:{...r.runtime,auto_reload:_e}};await o({config:ke}).then(()=>s(ke))},e[10]=o,e[11]=s,e[12]=r,e[13]=x):x=e[13];const p=x;let b;e[14]!==i.runtime.auto_instantiate||e[15]!==i.runtime.auto_reload||e[16]!==i.runtime.on_cell_change?(b=!i.runtime.auto_instantiate&&i.runtime.on_cell_change==="lazy"&&(tn()||i.runtime.auto_reload!=="autorun"),e[14]=i.runtime.auto_instantiate,e[15]=i.runtime.auto_reload,e[16]=i.runtime.on_cell_change,e[17]=b):b=e[17];const y=b;let v;e[18]!==n?(v=xe("flex items-center",n),e[18]=n,e[19]=v):v=e[19];const w=i.runtime.auto_instantiate?"Disable autorun on startup":"Enable autorun on startup";let S,C,N;e[20]!==i.runtime.auto_instantiate||e[21]!==f?(S=()=>f(!i.runtime.auto_instantiate),e[20]=i.runtime.auto_instantiate,e[21]=f,e[22]=S):S=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(C=u.jsx("span",{children:"on startup: "}),e[23]=C):C=e[23],e[24]!==i.runtime.auto_instantiate?(N=i.runtime.auto_instantiate?u.jsx(hn,{size:14}):u.jsx(un,{size:14}),e[24]=i.runtime.auto_instantiate,e[25]=N):N=e[25];const j=i.runtime.auto_instantiate?"autorun":"lazy";let E,T,I,O;e[26]!==j?(E=u.jsx("span",{children:j}),e[26]=j,e[27]=E):E=e[27],e[28]!==N||e[29]!==E?(T=u.jsxs("div",{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[C,N,E]}),e[28]=N,e[29]=E,e[30]=T):T=e[30],e[31]!==T||e[32]!==w||e[33]!==S?(I=u.jsx(_s,{name:"runtime.auto_instantiate",children:u.jsx(mn,{tooltip:w,selected:!1,onClick:S,"data-testid":"footer-autorun-startup",children:T})}),e[31]=T,e[32]=w,e[33]=S,e[34]=I):I=e[34],e[35]===Symbol.for("react.memo_cache_sentinel")?(O=u.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[35]=O):O=e[35];const L=i.runtime.on_cell_change==="autorun"?"Disable autorun":"Enable autorun";let D,R,P,z,_,k,B,A,U,$,X,Y,G;e[36]!==i.runtime.on_cell_change||e[37]!==g?(D=()=>g(i.runtime.on_cell_change!=="autorun"),e[36]=i.runtime.on_cell_change,e[37]=g,e[38]=D):D=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(R=u.jsx("span",{children:"on cell change: "}),e[39]=R):R=e[39],e[40]!==i.runtime.on_cell_change?(P=u.jsxs("div",{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[R,i.runtime.on_cell_change==="autorun"?u.jsx(hn,{size:14}):u.jsx(un,{size:14}),u.jsx("span",{children:i.runtime.on_cell_change})]}),e[40]=i.runtime.on_cell_change,e[41]=P):P=e[41],e[42]!==L||e[43]!==D||e[44]!==P?(z=u.jsx(_s,{name:"runtime.on_cell_change",children:u.jsx(mn,{tooltip:L,selected:!1,onClick:D,"data-testid":"footer-autorun-cell-change",children:P})}),e[42]=L,e[43]=D,e[44]=P,e[45]=z):z=e[45],e[46]!==i.runtime.auto_reload||e[47]!==p?(_=!tn()&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"border-r border-border h-6 mx-1"}),u.jsx(_s,{name:"runtime.auto_reload",children:u.jsx(mn,{tooltip:null,selected:!1,"data-testid":"footer-module-reload",children:u.jsxs(Eo,{children:[u.jsxs(_o,{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[u.jsx("span",{children:"on module change: "}),i.runtime.auto_reload==="off"&&u.jsx(ma,{size:14}),i.runtime.auto_reload==="lazy"&&u.jsx(un,{size:14}),i.runtime.auto_reload==="autorun"&&u.jsx(hn,{size:14}),u.jsx("span",{children:i.runtime.auto_reload}),u.jsx(No,{size:14})]}),u.jsx(Io,{children:["off","lazy","autorun"].map(_e=>u.jsxs(At,{onClick:()=>p(_e),children:[_e==="off"&&u.jsx(ma,{size:14,className:"mr-2 text-muted-foreground"}),_e==="lazy"&&u.jsx(un,{size:14,className:"mr-2 text-muted-foreground"}),_e==="autorun"&&u.jsx(hn,{size:14,className:"mr-2 text-muted-foreground"}),_e]},_e))})]})})})]}),e[46]=i.runtime.auto_reload,e[47]=p,e[48]=_):_=e[48],e[49]!==I||e[50]!==z||e[51]!==_?(k=u.jsxs("div",{className:"hidden md:flex md:items-center",children:[I,O,z,_]}),e[49]=I,e[50]=z,e[51]=_,e[52]=k):k=e[52],e[53]!==y?(B=y?u.jsx(un,{size:16,className:"text-muted-foreground"}):u.jsx(hn,{size:16,className:"text-amber-500"}),e[53]=y,e[54]=B):B=e[54],e[55]===Symbol.for("react.memo_cache_sentinel")?(A=u.jsx(No,{size:14}),e[55]=A):A=e[55],e[56]!==B?(U=u.jsx(_o,{asChild:!0,children:u.jsx(mn,{tooltip:"Runtime reactivity",selected:!1,"data-testid":"footer-runtime-settings",children:u.jsxs("div",{className:"flex items-center gap-1",children:[B,A]})})}),e[56]=B,e[57]=U):U=e[57],e[58]===Symbol.for("react.memo_cache_sentinel")?($=u.jsx(T3,{children:"Runtime reactivity"}),X=u.jsx(an,{}),e[58]=$,e[59]=X):($=e[58],X=e[59]),e[60]!==i.runtime.auto_instantiate?(Y=i.runtime.auto_instantiate?u.jsx(hn,{size:14,className:"text-amber-500"}):u.jsx(un,{size:14,className:"text-muted-foreground"}),e[60]=i.runtime.auto_instantiate,e[61]=Y):Y=e[61],e[62]===Symbol.for("react.memo_cache_sentinel")?(G=u.jsx("div",{className:"text-sm font-medium",children:"On startup"}),e[62]=G):G=e[62];const W=i.runtime.auto_instantiate?"autorun":"lazy";let J,V,Q,te,re,ne,ie,se,ae;e[63]!==W?(J=u.jsxs("div",{children:[G,u.jsx("div",{className:"text-xs text-muted-foreground",children:W})]}),e[63]=W,e[64]=J):J=e[64],e[65]!==Y||e[66]!==J?(V=u.jsxs("div",{className:"flex items-center space-x-2",children:[Y,J]}),e[65]=Y,e[66]=J,e[67]=V):V=e[67],e[68]!==i.runtime.auto_instantiate||e[69]!==f?(Q=u.jsx(fm,{checked:i.runtime.auto_instantiate,onCheckedChange:f,size:"sm"}),e[68]=i.runtime.auto_instantiate,e[69]=f,e[70]=Q):Q=e[70],e[71]!==V||e[72]!==Q?(te=u.jsx(_s,{name:"runtime.auto_instantiate",children:u.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[V,Q]})}),e[71]=V,e[72]=Q,e[73]=te):te=e[73],e[74]===Symbol.for("react.memo_cache_sentinel")?(re=u.jsx(an,{}),e[74]=re):re=e[74],e[75]!==i.runtime.on_cell_change?(ne=i.runtime.on_cell_change==="autorun"?u.jsx(hn,{size:14,className:"text-amber-500"}):u.jsx(un,{size:14,className:"text-muted-foreground"}),e[75]=i.runtime.on_cell_change,e[76]=ne):ne=e[76],e[77]===Symbol.for("react.memo_cache_sentinel")?(ie=u.jsx("div",{className:"text-sm font-medium",children:"On cell change"}),e[77]=ie):ie=e[77],e[78]!==i.runtime.on_cell_change?(se=u.jsxs("div",{children:[ie,u.jsx("div",{className:"text-xs text-muted-foreground",children:i.runtime.on_cell_change})]}),e[78]=i.runtime.on_cell_change,e[79]=se):se=e[79],e[80]!==ne||e[81]!==se?(ae=u.jsxs("div",{className:"flex items-center space-x-2",children:[ne,se]}),e[80]=ne,e[81]=se,e[82]=ae):ae=e[82];const ge=i.runtime.on_cell_change==="autorun";let oe,ue,de,Se,Te,Fe;return e[83]!==g||e[84]!==ge?(oe=u.jsx(fm,{checked:ge,onCheckedChange:g,size:"sm"}),e[83]=g,e[84]=ge,e[85]=oe):oe=e[85],e[86]!==ae||e[87]!==oe?(ue=u.jsx(_s,{name:"runtime.on_cell_change",children:u.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[ae,oe]})}),e[86]=ae,e[87]=oe,e[88]=ue):ue=e[88],e[89]!==i.runtime.auto_reload||e[90]!==p?(de=!tn()&&u.jsxs(u.Fragment,{children:[u.jsx(an,{}),u.jsx(_s,{name:"runtime.auto_reload",children:u.jsxs("div",{className:"px-2 py-1",children:[u.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[i.runtime.auto_reload==="off"&&u.jsx(ma,{size:14,className:"text-muted-foreground"}),i.runtime.auto_reload==="lazy"&&u.jsx(un,{size:14,className:"text-muted-foreground"}),i.runtime.auto_reload==="autorun"&&u.jsx(hn,{size:14,className:"text-amber-500"}),u.jsxs("div",{children:[u.jsx("div",{className:"text-sm font-medium",children:"On module change"}),u.jsx("div",{className:"text-xs text-muted-foreground",children:i.runtime.auto_reload})]})]}),u.jsx("div",{className:"space-y-1",children:["off","lazy","autorun"].map(_e=>u.jsxs("button",{onClick:()=>p(_e),className:xe("w-full flex items-center px-2 py-1 text-sm rounded hover:bg-accent",_e===i.runtime.auto_reload&&"bg-accent"),children:[_e==="off"&&u.jsx(ma,{size:12,className:"mr-2"}),_e==="lazy"&&u.jsx(un,{size:12,className:"mr-2"}),_e==="autorun"&&u.jsx(hn,{size:12,className:"mr-2"}),u.jsx("span",{className:"capitalize",children:_e}),_e===i.runtime.auto_reload&&u.jsx("span",{className:"ml-auto",children:"\u2713"})]},_e))})]})})]}),e[89]=i.runtime.auto_reload,e[90]=p,e[91]=de):de=e[91],e[92]!==te||e[93]!==ue||e[94]!==de?(Se=u.jsxs(Io,{align:"start",className:"w-64",children:[$,X,te,re,ue,de]}),e[92]=te,e[93]=ue,e[94]=de,e[95]=Se):Se=e[95],e[96]!==a||e[97]!==U||e[98]!==Se?(Te=u.jsx("div",{className:"flex md:hidden",children:u.jsxs(Eo,{open:a,onOpenChange:l,children:[U,Se]})}),e[96]=a,e[97]=U,e[98]=Se,e[99]=Te):Te=e[99],e[100]!==k||e[101]!==Te||e[102]!==v?(Fe=u.jsxs("div",{className:v,children:[k,Te]}),e[100]=k,e[101]=Te,e[102]=v,e[103]=Fe):Fe=e[103],Fe},F6=()=>{const t=H.c(24),{selectedPanel:e,isTerminalOpen:n}=bc(),{toggleApplication:o,toggleTerminal:r}=qi(),s=je(YP),i=z6,a=fd.find(B6);let l;Un(a,"Error panel not found"),t[0]!==r?(l=()=>{r()},t[0]=r,t[1]=l):l=t[1],Rt("global.toggleTerminal",l);const c=mn,d=a.tooltip,h=e===a.type,f=()=>o(a.type),m=i(a,s>0?"text-destructive":"");let g,x,p,b,y,v,w,S,C,N;return t[2]!==s?(g=u.jsx("span",{className:"ml-1 font-mono mt-0.5",children:s}),t[2]=s,t[3]=g):g=t[3],t[4]!==c||t[5]!==a||t[6]!==h||t[7]!==f||t[8]!==m||t[9]!==g?(x=u.jsxs(c,{tooltip:d,selected:h,onClick:f,"data-testid":"footer-errors",children:[m,g]}),t[4]=c,t[5]=a,t[6]=h,t[7]=f,t[8]=m,t[9]=g,t[10]=x):x=t[10],t[11]!==r?(p=()=>r(),t[11]=r,t[12]=p):p=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(Zp,{className:"h-5 w-5"}),t[13]=b):b=t[13],t[14]!==n||t[15]!==p?(y=u.jsx(zb,{capability:"terminal",children:u.jsx(mn,{tooltip:"Open terminal",selected:n,onClick:p,"data-testid":"footer-terminal",children:b})}),t[14]=n,t[15]=p,t[16]=y):y=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(v=u.jsx(L6,{}),w=u.jsx("div",{className:"mx-auto"}),t[17]=v,t[18]=w):(v=t[17],w=t[18]),t[19]===Symbol.for("react.memo_cache_sentinel")?(S=u.jsx(N4,{children:u.jsx(Ne,{content:u.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:u.jsx("span",{className:"text-muted-foreground text-sm mr-4",children:"kiosk mode"})})}),t[19]=S):S=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(C=u.jsxs("div",{className:"flex items-center shrink-0 min-w-0",children:[u.jsx(S6,{}),u.jsx(D6,{}),u.jsx(y6,{}),u.jsx(C6,{}),u.jsx(P6,{}),u.jsx(v6,{})]}),t[20]=C):C=t[20],t[21]!==y||t[22]!==x?(N=u.jsxs("footer",{className:"h-10 py-2 bg-background flex items-center text-muted-foreground text-md px-1 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 overflow-x-auto overflow-y-hidden scrollbar-thin",children:[x,y,v,w,S,C]}),t[21]=y,t[22]=x,t[23]=N):N=t[23],N};function z6(t,e){const{Icon:n}=t;return u.jsx(n,{className:xe("h-5 w-5",e)})}function B6(t){return t.type==="errors"}const U6=t=>{const e=H.c(6),{children:n}=t,{openModal:o,closeModal:r}=An();let s,i;return e[0]!==r||e[1]!==o?(s=()=>o(u.jsx($6,{onClose:r})),e[0]=r,e[1]=o,e[2]=s):s=e[2],e[3]!==n||e[4]!==s?(i=u.jsx(RC,{onClick:s,children:n}),e[3]=n,e[4]=s,e[5]=i):i=e[5],i},$6=t=>{const e=H.c(9),{onClose:n}=t;let o,r,s,i,a,l,c;return e[0]!==n?(o=async d=>{d.preventDefault();const h=new FormData(d.target),f=h.get("rating"),m=h.get("message");fetch("https://marimo.io/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:f,message:m})}),n(),Je({title:"Feedback sent!",description:"Thank you for your feedback!"})},e[0]=n,e[1]=o):o=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(r=u.jsx(Wo,{children:"Send Feedback"}),e[2]=r):r=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(s=u.jsx("p",{className:"my-2 prose dark:prose-invert",children:"We want to hear from you \u2014 from minor bug reports to wishlist features and everything in between. Here are some ways you can get in touch:"}),e[3]=s):s=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(i=u.jsxs("li",{className:"my-0",children:["Take our"," ",u.jsx("a",{href:Fn.feedbackForm,target:"_blank",className:"underline",children:"two-minute survey."})]}),e[4]=i):i=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(a=u.jsxs("li",{className:"my-0",children:["File a"," ",u.jsx("a",{href:Fn.issuesPage,target:"_blank",className:"underline",children:"GitHub issue."})]}),e[5]=a):a=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsxs(cs,{children:[r,u.jsxs(ds,{children:[s,u.jsxs("ul",{className:"list-disc ml-8 my-2 prose dark:prose-invert",children:[i,a,u.jsxs("li",{className:"my-0",children:["Chat with us on"," ",u.jsx("a",{href:Fn.discordLink,target:"_blank",className:"underline",children:"Discord."})]})]}),u.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!"})]})]}),e[6]=l):l=e[6],e[7]!==o?(c=u.jsx(Go,{className:"w-fit",children:u.jsx("form",{onSubmit:o,children:l})}),e[7]=o,e[8]=c):c=e[8],c},V6=()=>{const t=H.c(10),{selectedPanel:e}=bc(),{toggleApplication:n}=qi(),o=W6;let r,s,i,a,l,c;return t[0]!==e||t[1]!==n?(r="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=fd.filter(q6).map(d=>u.jsx($b,{tooltip:d.tooltip,selected:e===d.type,onClick:()=>n(d.type),children:o(d)},d.type)),t[0]=e,t[1]=n,t[2]=r,t[3]=s):(r=t[2],s=t[3]),t[4]===Symbol.for("react.memo_cache_sentinel")?(i=u.jsx(U6,{children:u.jsx($b,{tooltip:"Send feedback!",selected:!1,children:u.jsx(Rp,{className:"h-5 w-5"})})}),a=u.jsx("div",{className:"flex-1"}),l=u.jsx(H6,{}),t[4]=i,t[5]=a,t[6]=l):(i=t[4],a=t[5],l=t[6]),t[7]!==r||t[8]!==s?(c=u.jsxs("div",{className:r,children:[s,i,a,l]}),t[7]=r,t[8]=s,t[9]=c):c=t[9],c},H6=()=>{const t=H.c(7),e=je(KP);let n,o,r;return t[0]!==e?(n=e>0?u.jsxs("span",{children:[e," cell",e>1?"s":""," queued or running"]}):"No cells queued or running",t[0]=e,t[1]=n):n=t[1],t[2]!==e?(o=u.jsx("div",{className:"flex flex-col-reverse gap-px overflow-hidden",children:Array.from({length:e}).map(G6)}),t[2]=e,t[3]=o):o=t[3],t[4]!==n||t[5]!==o?(r=u.jsx(Ne,{content:n,side:"right",delayDuration:200,children:o}),t[4]=n,t[5]=o,t[6]=r):r=t[6],r},$b=t=>{const e=H.c(17);let n,o,r,s,i;e[0]!==t?({children:n,tooltip:i,selected:s,className:o,...r}=t,e[0]=t,e[1]=n,e[2]=o,e[3]=r,e[4]=s,e[5]=i):(n=e[1],o=e[2],r=e[3],s=e[4],i=e[5]);const a=!s&&"hover:bg-(--sage-3)",l=s&&"bg-(--sage-4)";let c,d,h;return e[6]!==o||e[7]!==a||e[8]!==l?(c=xe("flex items-center p-2 text-sm mx-px shadow-inset font-mono cursor-pointer rounded",a,l,o),e[6]=o,e[7]=a,e[8]=l,e[9]=c):c=e[9],e[10]!==n||e[11]!==r||e[12]!==c?(d=u.jsx("button",{className:c,...r,children:n}),e[10]=n,e[11]=r,e[12]=c,e[13]=d):d=e[13],e[14]!==d||e[15]!==i?(h=u.jsx(Ne,{content:i,side:"right",delayDuration:200,children:d}),e[14]=d,e[15]=i,e[16]=h):h=e[16],h};function W6(t,e){const{Icon:n}=t;return u.jsx(n,{className:xe("h-5 w-5",e)})}function q6(t){return!t.hidden&&t.position==="sidebar"}function G6(t,e){return u.jsx("div",{className:"shrink-0 h-1 w-2 bg-(--grass-6) border border-(--grass-7)"},e.toString())}var Wu="ScrollArea",[Vb,nz]=lC(Wu),[Y6,jn]=Vb(Wu),Hb=M.forwardRef((t,e)=>{const{__scopeScrollArea:n,type:o="hover",dir:r,scrollHideDelay:s=600,...i}=t,[a,l]=M.useState(null),[c,d]=M.useState(null),[h,f]=M.useState(null),[m,g]=M.useState(null),[x,p]=M.useState(null),[b,y]=M.useState(0),[v,w]=M.useState(0),[S,C]=M.useState(!1),[N,j]=M.useState(!1),E=Ss(e,I=>l(I)),T=XP(r);return u.jsx(Y6,{scope:n,type:o,dir:T,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:f,scrollbarX:m,onScrollbarXChange:g,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:x,onScrollbarYChange:p,scrollbarYEnabled:N,onScrollbarYEnabledChange:j,onCornerWidthChange:y,onCornerHeightChange:w,children:u.jsx(ks.div,{dir:T,...i,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":v+"px",...t.style}})})});Hb.displayName=Wu;var Wb="ScrollAreaViewport",qb=M.forwardRef((t,e)=>{const{__scopeScrollArea:n,children:o,nonce:r,...s}=t,i=jn(Wb,n),a=M.useRef(null),l=Ss(e,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.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:r}),u.jsx(ks.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...t.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});qb.displayName=Wb;var qn="ScrollAreaScrollbar",qu=M.forwardRef((t,e)=>{const{forceMount:n,...o}=t,r=jn(qn,t.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=r,a=t.orientation==="horizontal";return M.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),r.type==="hover"?u.jsx(K6,{...o,ref:e,forceMount:n}):r.type==="scroll"?u.jsx(X6,{...o,ref:e,forceMount:n}):r.type==="auto"?u.jsx(Gb,{...o,ref:e,forceMount:n}):r.type==="always"?u.jsx(Gu,{...o,ref:e}):null});qu.displayName=qn;var K6=M.forwardRef((t,e)=>{const{forceMount:n,...o}=t,r=jn(qn,t.__scopeScrollArea),[s,i]=M.useState(!1);return M.useEffect(()=>{const a=r.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),r.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[r.scrollArea,r.scrollHideDelay]),u.jsx(Hc,{present:n||s,children:u.jsx(Gb,{"data-state":s?"visible":"hidden",...o,ref:e})})}),X6=M.forwardRef((t,e)=>{const{forceMount:n,...o}=t,r=jn(qn,t.__scopeScrollArea),s=t.orientation==="horizontal",i=jl(()=>l("SCROLL_END"),100),[a,l]=function(c,d){return M.useReducer((h,f)=>d[h][f]??h,c)}("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return M.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),r.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,r.scrollHideDelay,l]),M.useEffect(()=>{const c=r.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const f=()=>{const m=c[d];h!==m&&(l("SCROLL"),i()),h=m};return c.addEventListener("scroll",f),()=>c.removeEventListener("scroll",f)}},[r.viewport,s,l,i]),u.jsx(Hc,{present:n||a!=="hidden",children:u.jsx(Gu,{"data-state":a==="hidden"?"hidden":"visible",...o,ref:e,onPointerEnter:On(t.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:On(t.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Gb=M.forwardRef((t,e)=>{const n=jn(qn,t.__scopeScrollArea),{forceMount:o,...r}=t,[s,i]=M.useState(!1),a=t.orientation==="horizontal",l=jl(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return $r(n.viewport,l),$r(n.content,l),u.jsx(Hc,{present:o||s,children:u.jsx(Gu,{"data-state":s?"visible":"hidden",...r,ref:e})})}),Gu=M.forwardRef((t,e)=>{const{orientation:n="vertical",...o}=t,r=jn(qn,t.__scopeScrollArea),s=M.useRef(null),i=M.useRef(0),[a,l]=M.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Zb(a.viewport,a.content),d={...o,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:f=>s.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function h(f,m){return function(g,x,p,b="ltr"){const y=Cl(p),v=y/2,w=x||v,S=y-w,C=p.scrollbar.paddingStart+w,N=p.scrollbar.size-p.scrollbar.paddingEnd-S,j=p.content-p.viewport,E=b==="ltr"?[0,j]:[-1*j,0];return ey([C,N],E)(g)}(f,i.current,a,m)}return n==="horizontal"?u.jsx(J6,{...d,ref:e,onThumbPositionChange:()=>{if(r.viewport&&s.current){const f=Qb(r.viewport.scrollLeft,a,r.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:f=>{r.viewport&&(r.viewport.scrollLeft=f)},onDragScroll:f=>{r.viewport&&(r.viewport.scrollLeft=h(f,r.dir))}}):n==="vertical"?u.jsx(Z6,{...d,ref:e,onThumbPositionChange:()=>{if(r.viewport&&s.current){const f=Qb(r.viewport.scrollTop,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:f=>{r.viewport&&(r.viewport.scrollTop=f)},onDragScroll:f=>{r.viewport&&(r.viewport.scrollTop=h(f))}}):null}),J6=M.forwardRef((t,e)=>{const{sizes:n,onSizesChange:o,...r}=t,s=jn(qn,t.__scopeScrollArea),[i,a]=M.useState(),l=M.useRef(null),c=Ss(e,l,s.onScrollbarXChange);return M.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Kb,{"data-orientation":"horizontal",...r,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Cl(n)+"px",...t.style},onThumbPointerDown:d=>t.onThumbPointerDown(d.x),onDragScroll:d=>t.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(s.viewport){const f=s.viewport.scrollLeft+d.deltaX;t.onWheelScroll(f),ty(f,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&o({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:kl(i.paddingLeft),paddingEnd:kl(i.paddingRight)}})}})}),Z6=M.forwardRef((t,e)=>{const{sizes:n,onSizesChange:o,...r}=t,s=jn(qn,t.__scopeScrollArea),[i,a]=M.useState(),l=M.useRef(null),c=Ss(e,l,s.onScrollbarYChange);return M.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Kb,{"data-orientation":"vertical",...r,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Cl(n)+"px",...t.style},onThumbPointerDown:d=>t.onThumbPointerDown(d.y),onDragScroll:d=>t.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(s.viewport){const f=s.viewport.scrollTop+d.deltaY;t.onWheelScroll(f),ty(f,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&o({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:kl(i.paddingTop),paddingEnd:kl(i.paddingBottom)}})}})}),[Q6,Yb]=Vb(qn),Kb=M.forwardRef((t,e)=>{const{__scopeScrollArea:n,sizes:o,hasThumb:r,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...f}=t,m=jn(qn,n),[g,x]=M.useState(null),p=Ss(e,E=>x(E)),b=M.useRef(null),y=M.useRef(""),v=m.viewport,w=o.content-o.viewport,S=Xo(d),C=Xo(l),N=jl(h,10);function j(E){if(b.current){const T=E.clientX-b.current.left,I=E.clientY-b.current.top;c({x:T,y:I})}}return M.useEffect(()=>{const E=T=>{const I=T.target;(g==null?void 0:g.contains(I))&&S(T,w)};return document.addEventListener("wheel",E,{passive:!1}),()=>document.removeEventListener("wheel",E,{passive:!1})},[v,g,w,S]),M.useEffect(C,[o,C]),$r(g,N),$r(m.content,N),u.jsx(Q6,{scope:n,scrollbar:g,hasThumb:r,onThumbChange:Xo(s),onThumbPointerUp:Xo(i),onThumbPositionChange:C,onThumbPointerDown:Xo(a),children:u.jsx(ks.div,{...f,ref:p,style:{position:"absolute",...f.style},onPointerDown:On(t.onPointerDown,E=>{E.button===0&&(E.target.setPointerCapture(E.pointerId),b.current=g.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),j(E))}),onPointerMove:On(t.onPointerMove,j),onPointerUp:On(t.onPointerUp,E=>{const T=E.target;T.hasPointerCapture(E.pointerId)&&T.releasePointerCapture(E.pointerId),document.body.style.webkitUserSelect=y.current,m.viewport&&(m.viewport.style.scrollBehavior=""),b.current=null})})})}),wl="ScrollAreaThumb",Xb=M.forwardRef((t,e)=>{const{forceMount:n,...o}=t,r=Yb(wl,t.__scopeScrollArea);return u.jsx(Hc,{present:n||r.hasThumb,children:u.jsx(eI,{ref:e,...o})})}),eI=M.forwardRef((t,e)=>{const{__scopeScrollArea:n,style:o,...r}=t,s=jn(wl,n),i=Yb(wl,n),{onThumbPositionChange:a}=i,l=Ss(e,h=>i.onThumbChange(h)),c=M.useRef(void 0),d=jl(()=>{c.current&&(c.current(),c.current=void 0)},100);return M.useEffect(()=>{const h=s.viewport;if(h){const f=()=>{if(d(),!c.current){const m=nI(h,a);c.current=m,a()}};return a(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[s.viewport,d,a]),u.jsx(ks.div,{"data-state":i.hasThumb?"visible":"hidden",...r,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:On(t.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),m=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:m,y:g})}),onPointerUp:On(t.onPointerUp,i.onThumbPointerUp)})});Xb.displayName=wl;var Yu="ScrollAreaCorner",Jb=M.forwardRef((t,e)=>{const n=jn(Yu,t.__scopeScrollArea),o=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&o?u.jsx(tI,{...t,ref:e}):null});Jb.displayName=Yu;var tI=M.forwardRef((t,e)=>{const{__scopeScrollArea:n,...o}=t,r=jn(Yu,n),[s,i]=M.useState(0),[a,l]=M.useState(0),c=!!(s&&a);return $r(r.scrollbarX,()=>{var h;const d=((h=r.scrollbarX)==null?void 0:h.offsetHeight)||0;r.onCornerHeightChange(d),l(d)}),$r(r.scrollbarY,()=>{var h;const d=((h=r.scrollbarY)==null?void 0:h.offsetWidth)||0;r.onCornerWidthChange(d),i(d)}),c?u.jsx(ks.div,{...o,ref:e,style:{width:s,height:a,position:"absolute",right:r.dir==="ltr"?0:void 0,left:r.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function kl(t){return t?parseInt(t,10):0}function Zb(t,e){const n=t/e;return isNaN(n)?0:n}function Cl(t){const e=Zb(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,o=(t.scrollbar.size-n)*e;return Math.max(o,18)}function Qb(t,e,n="ltr"){const o=Cl(e),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=e.scrollbar.size-r,i=e.content-e.viewport,a=s-o,l=ZP(t,n==="ltr"?[0,i]:[-1*i,0]);return ey([0,i],[0,a])(l)}function ey(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const o=(e[1]-e[0])/(t[1]-t[0]);return e[0]+o*(n-t[0])}}function ty(t,e){return t>0&&t<e}var nI=(t,e=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},o=0;return function r(){const s={left:t.scrollLeft,top:t.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&e(),n=s,o=window.requestAnimationFrame(r)}(),()=>window.cancelAnimationFrame(o)};function jl(t,e){const n=Xo(t),o=M.useRef(0);return M.useEffect(()=>()=>window.clearTimeout(o.current),[]),M.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(n,e)},[n,e])}function $r(t,e){const n=Xo(e);JP(()=>{let o=0;if(t){const r=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(n)});return r.observe(t),()=>{window.cancelAnimationFrame(o),r.unobserve(t)}}},[t,n])}var ny=Hb,oI=qb,rI=Jb;const oy=M.forwardRef((t,e)=>{const n=H.c(15);let o,r,s,i,a,l,c,d;return n[0]!==t?({className:r,children:o,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==r?(i=xe("relative overflow-hidden",r),n[4]=r,n[5]=i):i=n[5],n[6]!==o?(a=u.jsx(oI,{className:"h-full w-full rounded-[inherit]",children:o}),n[6]=o,n[7]=a):a=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx(ry,{}),c=u.jsx(rI,{}),n[8]=l,n[9]=c):(l=n[8],c=n[9]),n[10]!==s||n[11]!==e||n[12]!==i||n[13]!==a?(d=u.jsxs(ny,{ref:e,className:i,...s,children:[a,l,c]}),n[10]=s,n[11]=e,n[12]=i,n[13]=a,n[14]=d):d=n[14],d});oy.displayName=ny.displayName;const ry=M.forwardRef((t,e)=>{const n=H.c(14);let o,r,s;n[0]!==t?({className:o,orientation:s,...r}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]);const i=s===void 0?"vertical":s,a=i==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-px",l=i==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-px";let c,d,h;return n[4]!==o||n[5]!==a||n[6]!==l?(c=xe("flex touch-none select-none transition-colors",a,l,o),n[4]=o,n[5]=a,n[6]=l,n[7]=c):c=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx(Xb,{className:"relative flex-1 rounded-full bg-border"}),n[8]=d):d=n[8],n[9]!==i||n[10]!==r||n[11]!==e||n[12]!==c?(h=u.jsx(qu,{ref:e,orientation:i,className:c,...r,children:d}),n[9]=i,n[10]=r,n[11]=e,n[12]=c,n[13]=h):h=n[13],h});ry.displayName=qu.displayName;let Ku;Ku=(t,e,n,o,r,s)=>{if(!e)return mt.warn("No active chat"),t;const i=t.chats.findIndex(h=>h.id===e);if(i===-1)return mt.warn("No active chat"),t;const a=t.chats[i],l=a.messages.findIndex(h=>h.id===n),c=[...t.chats],d=Date.now();if(l===-1)c[i]={...a,messages:[...a.messages,{id:n,role:o,content:r,timestamp:d,parts:s}],updatedAt:d};else{const h=[...a.messages];h[l]={...h[l],content:r,parts:s},c[i]={...a,messages:h,updatedAt:d}}return{...t,chats:c}},dn=t=>{const e=H.c(15),{title:n,description:o,icon:r,action:s}=t;let i,a,l,c,d,h;return e[0]!==r?(i=r&&q.cloneElement(r,{className:"text-accent-foreground"}),e[0]=r,e[1]=i):i=e[1],e[2]!==n?(a=u.jsx("span",{className:"mt-1 text-accent-foreground",children:n}),e[2]=n,e[3]=a):a=e[3],e[4]!==i||e[5]!==a?(l=u.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[i,a]}),e[4]=i,e[5]=a,e[6]=l):l=e[6],e[7]!==o?(c=u.jsx("span",{className:"text-muted-foreground text-sm",children:o}),e[7]=o,e[8]=c):c=e[8],e[9]!==s?(d=s&&u.jsx("div",{className:"mt-2",children:s}),e[9]=s,e[10]=d):d=e[10],e[11]!==l||e[12]!==c||e[13]!==d?(h=u.jsxs("div",{className:"mx-6 my-6 flex flex-col gap-2",children:[l,c,d]}),e[11]=l,e[12]=c,e[13]=d,e[14]=h):h=e[14],h};function oz(){}function rz(){}const sI=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,iI=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,aI={};function sy(t,e){return(aI.jsx?iI:sI).test(t)}const lI=/[ \t\n\f\r]/g;function iy(t){return t.replace(lI,"")===""}class ui{constructor(e,n,o){this.normal=n,this.property=e,o&&(this.space=o)}}function ay(t,e){const n={},o={};for(const r of t)Object.assign(n,r.property),Object.assign(o,r.normal);return new ui(n,o,e)}function Xu(t){return t.toLowerCase()}ui.prototype.normal={},ui.prototype.property={},ui.prototype.space=void 0;class on{constructor(e,n){this.attribute=n,this.property=e}}on.prototype.attribute="",on.prototype.booleanish=!1,on.prototype.boolean=!1,on.prototype.commaOrSpaceSeparated=!1,on.prototype.commaSeparated=!1,on.prototype.defined=!1,on.prototype.mustUseProperty=!1,on.prototype.number=!1,on.prototype.overloadedBoolean=!1,on.prototype.property="",on.prototype.spaceSeparated=!1,on.prototype.space=void 0;let cI=0;const Ge=dr(),_t=dr(),Ju=dr(),fe=dr(),ut=dr(),Vr=dr(),pn=dr();function dr(){return 2**++cI}const Zu=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ge,booleanish:_t,commaOrSpaceSeparated:pn,commaSeparated:Vr,number:fe,overloadedBoolean:Ju,spaceSeparated:ut},Symbol.toStringTag,{value:"Module"})),Qu=Object.keys(Zu);class eh extends on{constructor(e,n,o,r){let s=-1;if(super(e,n),ly(this,"space",r),typeof o=="number")for(;++s<Qu.length;){const i=Qu[s];ly(this,Qu[s],(o&Zu[i])===Zu[i])}}}function ly(t,e,n){n&&(t[e]=n)}function Hr(t){const e={},n={};for(const[o,r]of Object.entries(t.properties)){const s=new eh(o,t.transform(t.attributes||{},o),r,t.space);t.mustUseProperty&&t.mustUseProperty.includes(o)&&(s.mustUseProperty=!0),e[o]=s,n[Xu(o)]=o,n[Xu(s.attribute)]=o}return new ui(e,n,t.space)}eh.prototype.defined=!0;const cy=Hr({properties:{ariaActiveDescendant:null,ariaAtomic:_t,ariaAutoComplete:null,ariaBusy:_t,ariaChecked:_t,ariaColCount:fe,ariaColIndex:fe,ariaColSpan:fe,ariaControls:ut,ariaCurrent:null,ariaDescribedBy:ut,ariaDetails:null,ariaDisabled:_t,ariaDropEffect:ut,ariaErrorMessage:null,ariaExpanded:_t,ariaFlowTo:ut,ariaGrabbed:_t,ariaHasPopup:null,ariaHidden:_t,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ut,ariaLevel:fe,ariaLive:null,ariaModal:_t,ariaMultiLine:_t,ariaMultiSelectable:_t,ariaOrientation:null,ariaOwns:ut,ariaPlaceholder:null,ariaPosInSet:fe,ariaPressed:_t,ariaReadOnly:_t,ariaRelevant:null,ariaRequired:_t,ariaRoleDescription:ut,ariaRowCount:fe,ariaRowIndex:fe,ariaRowSpan:fe,ariaSelected:_t,ariaSetSize:fe,ariaSort:null,ariaValueMax:fe,ariaValueMin:fe,ariaValueNow:fe,ariaValueText:null,role:null},transform:(t,e)=>e==="role"?e:"aria-"+e.slice(4).toLowerCase()});function dy(t,e){return e in t?t[e]:e}function uy(t,e){return dy(t,e.toLowerCase())}const dI=Hr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Vr,acceptCharset:ut,accessKey:ut,action:null,allow:null,allowFullScreen:Ge,allowPaymentRequest:Ge,allowUserMedia:Ge,alt:null,as:null,async:Ge,autoCapitalize:null,autoComplete:ut,autoFocus:Ge,autoPlay:Ge,blocking:ut,capture:null,charSet:null,checked:Ge,cite:null,className:ut,cols:fe,colSpan:null,content:null,contentEditable:_t,controls:Ge,controlsList:ut,coords:fe|Vr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ge,defer:Ge,dir:null,dirName:null,disabled:Ge,download:Ju,draggable:_t,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ge,formTarget:null,headers:ut,height:fe,hidden:Ju,high:fe,href:null,hrefLang:null,htmlFor:ut,httpEquiv:ut,id:null,imageSizes:null,imageSrcSet:null,inert:Ge,inputMode:null,integrity:null,is:null,isMap:Ge,itemId:null,itemProp:ut,itemRef:ut,itemScope:Ge,itemType:ut,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ge,low:fe,manifest:null,max:null,maxLength:fe,media:null,method:null,min:null,minLength:fe,multiple:Ge,muted:Ge,name:null,nonce:null,noModule:Ge,noValidate:Ge,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:Ge,optimum:fe,pattern:null,ping:ut,placeholder:null,playsInline:Ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ge,referrerPolicy:null,rel:ut,required:Ge,reversed:Ge,rows:fe,rowSpan:fe,sandbox:ut,scope:null,scoped:Ge,seamless:Ge,selected:Ge,shadowRootClonable:Ge,shadowRootDelegatesFocus:Ge,shadowRootMode:null,shape:null,size:fe,sizes:null,slot:null,span:fe,spellCheck:_t,src:null,srcDoc:null,srcLang:null,srcSet:null,start:fe,step:null,style:null,tabIndex:fe,target:null,title:null,translate:null,type:null,typeMustMatch:Ge,useMap:null,value:_t,width:fe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ut,axis:null,background:null,bgColor:null,border:fe,borderColor:null,bottomMargin:fe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ge,declare:Ge,event:null,face:null,frame:null,frameBorder:null,hSpace:fe,leftMargin:fe,link:null,longDesc:null,lowSrc:null,marginHeight:fe,marginWidth:fe,noResize:Ge,noHref:Ge,noShade:Ge,noWrap:Ge,object:null,profile:null,prompt:null,rev:null,rightMargin:fe,rules:null,scheme:null,scrolling:_t,standby:null,summary:null,text:null,topMargin:fe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:fe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ge,disableRemotePlayback:Ge,prefix:null,property:null,results:fe,security:null,unselectable:null},space:"html",transform:uy}),uI=Hr({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"},properties:{about:pn,accentHeight:fe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:fe,amplitude:fe,arabicForm:null,ascent:fe,attributeName:null,attributeType:null,azimuth:fe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:fe,by:null,calcMode:null,capHeight:fe,className:ut,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:fe,diffuseConstant:fe,direction:null,display:null,dur:null,divisor:fe,dominantBaseline:null,download:Ge,dx:null,dy:null,edgeMode:null,editable:null,elevation:fe,enableBackground:null,end:null,event:null,exponent:fe,externalResourcesRequired:null,fill:null,fillOpacity:fe,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:Vr,g2:Vr,glyphName:Vr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:fe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:fe,horizOriginX:fe,horizOriginY:fe,id:null,ideographic:fe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:fe,k:fe,k1:fe,k2:fe,k3:fe,k4:fe,kernelMatrix:pn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:fe,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:fe,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:fe,overlineThickness:fe,paintOrder:null,panose1:null,path:null,pathLength:fe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ut,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:fe,pointsAtY:fe,pointsAtZ:fe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pn,rev:pn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pn,requiredFeatures:pn,requiredFonts:pn,requiredFormats:pn,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:fe,specularExponent:fe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:fe,strikethroughThickness:fe,string:null,stroke:null,strokeDashArray:pn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:fe,strokeOpacity:fe,strokeWidth:null,style:null,surfaceScale:fe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pn,tabIndex:fe,tableValues:null,target:null,targetX:fe,targetY:fe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:fe,underlineThickness:fe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:fe,values:null,vAlphabetic:fe,vMathematical:fe,vectorEffect:null,vHanging:fe,vIdeographic:fe,version:null,vertAdvY:fe,vertOriginX:fe,vertOriginY:fe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:fe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:dy}),hy=Hr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(t,e)=>"xlink:"+e.slice(5).toLowerCase()}),fy=Hr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:uy}),my=Hr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(t,e)=>"xml:"+e.slice(3).toLowerCase()}),hI={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"},fI=/[A-Z]/g,py=/-[a-z]/g,mI=/^data[-\w.:]+$/i;function pI(t){return"-"+t.toLowerCase()}function gI(t){return t.charAt(1).toUpperCase()}const xI=ay([cy,dI,hy,fy,my],"html"),th=ay([cy,uI,hy,fy,my],"svg");var gy,Wr={},xy,Sl,by,hi={};function bI(){if(xy)return hi;xy=1,Object.defineProperty(hi,"__esModule",{value:!0}),hi.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,n=/^[^-]+$/,o=/^-(webkit|moz|ms|o|khtml)-/,r=/^-(ms)-/,s=function(a,l){return l.toUpperCase()},i=function(a,l){return"".concat(l,"-")};return hi.camelCase=function(a,l){return l===void 0&&(l={}),function(c){return!c||n.test(c)||t.test(c)}(a)?a:(a=a.toLowerCase(),(a=l.reactCompat?a.replace(r,i):a.replace(o,i)).replace(e,s))},hi}var yI=function(){if(by)return Sl;by=1;var t=(Sl&&Sl.__importDefault||function(o){return o&&o.__esModule?o:{default:o}})(function(){if(gy)return Wr;gy=1;var o=Wr&&Wr.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.default=function(s,i){var a=null;if(!s||typeof s!="string")return a;var l=(0,r.default)(s),c=typeof i=="function";return l.forEach(function(d){if(d.type==="declaration"){var h=d.property,f=d.value;c?i(h,f,d):f&&((a=a||{})[h]=f)}}),a};var r=o(QP());return Wr}()),e=bI();function n(o,r){var s={};return o&&typeof o=="string"&&(0,t.default)(o,function(i,a){i&&a&&(s[(0,e.camelCase)(i,r)]=a)}),s}return n.default=n,Sl=n}();const vI=PC(yI),yy=vy("end"),nh=vy("start");function vy(t){return function(e){const n=e&&e.position&&e.position[t]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function fi(t){return t&&typeof t=="object"?"position"in t||"type"in t?wy(t.position):"start"in t||"end"in t?wy(t):"line"in t||"column"in t?oh(t):"":""}function oh(t){return ky(t&&t.line)+":"+ky(t&&t.column)}function wy(t){return oh(t&&t.start)+"-"+oh(t&&t.end)}function ky(t){return t&&typeof t=="number"?t:1}class Vt extends Error{constructor(e,n,o){super(),typeof n=="string"&&(o=n,n=void 0);let r="",s={},i=!1;if(n&&(s="line"in n&&"column"in n||"start"in n&&"end"in n?{place:n}:"type"in n?{ancestors:[n],place:n.position}:{...n}),typeof e=="string"?r=e:!s.cause&&e&&(i=!0,r=e.message,s.cause=e),!s.ruleId&&!s.source&&typeof o=="string"){const l=o.indexOf(":");l===-1?s.ruleId=o:(s.source=o.slice(0,l),s.ruleId=o.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file,this.message=r,this.line=a?a.line:void 0,this.name=fi(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=i&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual,this.expected,this.note,this.url}}Vt.prototype.file="",Vt.prototype.name="",Vt.prototype.reason="",Vt.prototype.message="",Vt.prototype.stack="",Vt.prototype.column=void 0,Vt.prototype.line=void 0,Vt.prototype.ancestors=void 0,Vt.prototype.cause=void 0,Vt.prototype.fatal=void 0,Vt.prototype.place=void 0,Vt.prototype.ruleId=void 0,Vt.prototype.source=void 0;const rh={}.hasOwnProperty,wI=new Map,kI=/[A-Z]/g,CI=new Set(["table","tbody","thead","tfoot","tr"]),jI=new Set(["td","th"]),Cy="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function SI(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=e.filePath||void 0;let o;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");o=function(i,a){return l;function l(c,d,h,f){const m=Array.isArray(h.children),g=nh(c);return a(d,h,f,m,{columnNumber:g?g.column-1:void 0,fileName:i,lineNumber:g?g.line:void 0},void 0)}}(n,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");o=function(i,a,l){return c;function c(d,h,f,m){const g=Array.isArray(f.children)?l:a;return m?g(h,f,m):g(h,f)}}(0,e.jsx,e.jsxs)}const r={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:o,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?th:xI,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},s=jy(r,t,void 0);return s&&typeof s!="string"?s:r.create(t,r.Fragment,{children:s||void 0},void 0)}function jy(t,e,n){return e.type==="element"?function(o,r,s){const i=o.schema;let a=i;r.tagName.toLowerCase()==="svg"&&i.space==="html"&&(a=th,o.schema=a),o.ancestors.push(r);const l=Ny(o,r.tagName,!1),c=function(h,f){const m={};let g,x;for(x in f.properties)if(x!=="children"&&rh.call(f.properties,x)){const p=NI(h,x,f.properties[x]);if(p){const[b,y]=p;h.tableCellAlignToStyle&&b==="align"&&typeof y=="string"&&jI.has(f.tagName)?g=y:m[b]=y}}return g&&((m.style||(m.style={}))[h.stylePropertyNameCase==="css"?"text-align":"textAlign"]=g),m}(o,r);let d=ih(o,r);return CI.has(r.tagName)&&(d=d.filter(function(h){return typeof h!="string"||!(typeof(f=h)=="object"?f.type==="text"&&iy(f.value):iy(f));var f})),Sy(o,c,l,r),sh(c,d),o.ancestors.pop(),o.schema=i,o.create(r,l,c,s)}(t,e,n):e.type==="mdxFlowExpression"||e.type==="mdxTextExpression"?function(o,r){if(r.data&&r.data.estree&&o.evaluater){const s=r.data.estree.body[0];return s.type,o.evaluater.evaluateExpression(s.expression)}mi(o,r.position)}(t,e):e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement"?function(o,r,s){const i=o.schema;let a=i;r.name==="svg"&&i.space==="html"&&(a=th,o.schema=a),o.ancestors.push(r);const l=r.name===null?o.Fragment:Ny(o,r.name,!0),c=function(h,f){const m={};for(const g of f.attributes)if(g.type==="mdxJsxExpressionAttribute")if(g.data&&g.data.estree&&h.evaluater){const x=g.data.estree.body[0];x.type;const p=x.expression;p.type;const b=p.properties[0];b.type,Object.assign(m,h.evaluater.evaluateExpression(b.argument))}else mi(h,f.position);else{const x=g.name;let p;if(g.value&&typeof g.value=="object")if(g.value.data&&g.value.data.estree&&h.evaluater){const b=g.value.data.estree.body[0];b.type,p=h.evaluater.evaluateExpression(b.expression)}else mi(h,f.position);else p=g.value===null||g.value;m[x]=p}return m}(o,r),d=ih(o,r);return Sy(o,c,l,r),sh(c,d),o.ancestors.pop(),o.schema=i,o.create(r,l,c,s)}(t,e,n):e.type==="mdxjsEsm"?function(o,r){if(r.data&&r.data.estree&&o.evaluater)return o.evaluater.evaluateProgram(r.data.estree);mi(o,r.position)}(t,e):e.type==="root"?function(o,r,s){const i={};return sh(i,ih(o,r)),o.create(r,o.Fragment,i,s)}(t,e,n):e.type==="text"?function(o,r){return r.value}(0,e):void 0}function Sy(t,e,n,o){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=o)}function sh(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function ih(t,e){const n=[];let o=-1;const r=t.passKeys?new Map:wI;for(;++o<e.children.length;){const s=e.children[o];let i;if(t.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=r.get(l)||0;i=l+"-"+c,r.set(l,c+1)}}const a=jy(t,s,i);a!==void 0&&n.push(a)}return n}function NI(t,e,n){const o=function(r,s){const i=Xu(s);let a=s,l=on;if(i in r.normal)return r.property[r.normal[i]];if(i.length>4&&i.slice(0,4)==="data"&&mI.test(s)){if(s.charAt(4)==="-"){const c=s.slice(5).replace(py,gI);a="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=s.slice(4);if(!py.test(c)){let d=c.replace(fI,pI);d.charAt(0)!=="-"&&(d="-"+d),s="data"+d}}l=eh}return new l(a,s)}(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=o.commaSeparated?function(r){const s={};return(r[r.length-1]===""?[...r,""]:r).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}(n):n.join(" ").trim()),o.property==="style"){let r=typeof n=="object"?n:function(s,i){try{return vI(i,{reactCompat:!0})}catch(a){if(s.ignoreInvalidStyle)return{};const l=a,c=new Vt("Cannot parse `style` attribute",{ancestors:s.ancestors,cause:l,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw c.file=s.filePath||void 0,c.url=Cy+"#cannot-parse-style-attribute",c}}(t,String(n));return t.stylePropertyNameCase==="css"&&(r=function(s){const i={};let a;for(a in s)rh.call(s,a)&&(i[EI(a)]=s[a]);return i}(r)),["style",r]}return[t.elementAttributeNameCase==="react"&&o.space?hI[o.property]||o.property:o.attribute,n]}}function Ny(t,e,n){let o;if(n)if(e.includes(".")){const r=e.split(".");let s,i=-1;for(;++i<r.length;){const a=sy(r[i])?{type:"Identifier",name:r[i]}:{type:"Literal",value:r[i]};s=s?{type:"MemberExpression",object:s,property:a,computed:!!(i&&a.type==="Literal"),optional:!1}:a}o=s}else o=sy(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};else o={type:"Literal",value:e};if(o.type==="Literal"){const r=o.value;return rh.call(t.components,r)?t.components[r]:r}if(t.evaluater)return t.evaluater.evaluateExpression(o);mi(t)}function mi(t,e){const n=new Vt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=t.filePath||void 0,n.url=Cy+"#cannot-handle-mdx-estrees-without-createevaluater",n}function EI(t){let e=t.replace(kI,_I);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function _I(t){return"-"+t.toLowerCase()}const ah={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"]},Nl={};function lh(t,e){return Ey(t,typeof Nl.includeImageAlt!="boolean"||Nl.includeImageAlt,typeof Nl.includeHtml!="boolean"||Nl.includeHtml)}function Ey(t,e,n){if(function(o){return!!(o&&typeof o=="object")}(t)){if("value"in t)return t.type!=="html"||n?t.value:"";if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return _y(t.children,e,n)}return Array.isArray(t)?_y(t,e,n):""}function _y(t,e,n){const o=[];let r=-1;for(;++r<t.length;)o[r]=Ey(t[r],e,n);return o.join("")}const Iy=document.createElement("i");function ch(t){const e="&"+t+";";Iy.innerHTML=e;const n=Iy.textContent;return(n.charCodeAt(n.length-1)!==59||t==="semi")&&n!==e&&n}function gn(t,e,n,o){const r=t.length;let s,i=0;if(e=e<0?-e>r?0:r+e:e>r?r:e,n=n>0?n:0,o.length<1e4)s=Array.from(o),s.unshift(e,n),t.splice(...s);else for(n&&t.splice(e,n);i<o.length;)s=o.slice(i,i+1e4),s.unshift(e,0),t.splice(...s),i+=1e4,e+=1e4}function Sn(t,e){return t.length>0?(gn(t,t.length,0,e),t):e}const Ay={}.hasOwnProperty;function Ty(t){const e={};let n=-1;for(;++n<t.length;)II(e,t[n]);return e}function II(t,e){let n;for(n in e){const o=(Ay.call(t,n)?t[n]:void 0)||(t[n]={}),r=e[n];let s;if(r)for(s in r){Ay.call(o,s)||(o[s]=[]);const i=r[s];AI(o[s],Array.isArray(i)?i:i?[i]:[])}}}function AI(t,e){let n=-1;const o=[];for(;++n<e.length;)(e[n].add==="after"?t:o).push(e[n]);gn(t,0,0,o)}function My(t,e){const n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||(65535&n)==65534||n>1114111?"\uFFFD":String.fromCodePoint(n)}function Rn(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Zt=Lo(/[A-Za-z]/),Ht=Lo(/[\dA-Za-z]/),TI=Lo(/[#-'*+\--9=?A-Z^-~]/);function El(t){return t!==null&&(t<32||t===127)}const dh=Lo(/\d/),MI=Lo(/[\dA-Fa-f]/),OI=Lo(/[!-/:-@[-`{-~]/);function Be(t){return t!==null&&t<-2}function ct(t){return t!==null&&(t<0||t===32)}function et(t){return t===-2||t===-1||t===32}const _l=Lo(new RegExp("\\p{P}|\\p{S}","u")),ur=Lo(/\s/);function Lo(t){return function(e){return e!==null&&e>-1&&t.test(String.fromCharCode(e))}}function qr(t){const e=[];let n=-1,o=0,r=0;for(;++n<t.length;){const s=t.charCodeAt(n);let i="";if(s===37&&Ht(t.charCodeAt(n+1))&&Ht(t.charCodeAt(n+2)))r=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(i=String.fromCharCode(s));else if(s>55295&&s<57344){const a=t.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(i=String.fromCharCode(s,a),r=1):i="\uFFFD"}else i=String.fromCharCode(s);i&&(e.push(t.slice(o,n),encodeURIComponent(i)),o=n+r+1,i=""),r&&(n+=r,r=0)}return e.join("")+t.slice(o)}function rt(t,e,n,o){const r=o?o-1:Number.POSITIVE_INFINITY;let s=0;return function(a){return et(a)?(t.enter(n),i(a)):e(a)};function i(a){return et(a)&&s++<r?(t.consume(a),i):(t.exit(n),e(a))}}const DI={tokenize:function(t){const e=t.attempt(this.parser.constructs.contentInitial,function(s){return s===null?void t.consume(s):(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),rt(t,e,"linePrefix"))},function(s){return t.enter("paragraph"),o(s)});let n;return e;function o(s){const i=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=i),n=i,r(s)}function r(s){return s===null?(t.exit("chunkText"),t.exit("paragraph"),void t.consume(s)):Be(s)?(t.consume(s),t.exit("chunkText"),o):(t.consume(s),r)}}},RI={tokenize:function(t){const e=this,n=[];let o,r,s,i=0;return a;function a(v){if(i<n.length){const w=n[i];return e.containerState=w[1],t.attempt(w[0].continuation,l,c)(v)}return c(v)}function l(v){if(i++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,o&&y();const w=e.events.length;let S,C=w;for(;C--;)if(e.events[C][0]==="exit"&&e.events[C][1].type==="chunkFlow"){S=e.events[C][1].end;break}b(i);let N=w;for(;N<e.events.length;)e.events[N][1].end={...S},N++;return gn(e.events,C+1,0,e.events.slice(w)),e.events.length=N,c(v)}return a(v)}function c(v){if(i===n.length){if(!o)return f(v);if(o.currentConstruct&&o.currentConstruct.concrete)return g(v);e.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(Oy,d,h)(v)}function d(v){return o&&y(),b(i),f(v)}function h(v){return e.parser.lazy[e.now().line]=i!==n.length,s=e.now().offset,g(v)}function f(v){return e.containerState={},t.attempt(Oy,m,g)(v)}function m(v){return i++,n.push([e.currentConstruct,e.containerState]),f(v)}function g(v){return v===null?(o&&y(),b(0),void t.consume(v)):(o=o||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:r}),x(v))}function x(v){return v===null?(p(t.exit("chunkFlow"),!0),b(0),void t.consume(v)):Be(v)?(t.consume(v),p(t.exit("chunkFlow")),i=0,e.interrupt=void 0,a):(t.consume(v),x)}function p(v,w){const S=e.sliceStream(v);if(w&&S.push(null),v.previous=r,r&&(r.next=v),r=v,o.defineSkip(v.start),o.write(S),e.parser.lazy[v.start.line]){let C=o.events.length;for(;C--;)if(o.events[C][1].start.offset<s&&(!o.events[C][1].end||o.events[C][1].end.offset>s))return;const N=e.events.length;let j,E,T=N;for(;T--;)if(e.events[T][0]==="exit"&&e.events[T][1].type==="chunkFlow"){if(j){E=e.events[T][1].end;break}j=!0}for(b(i),C=N;C<e.events.length;)e.events[C][1].end={...E},C++;gn(e.events,T+1,0,e.events.slice(N)),e.events.length=C}}function b(v){let w=n.length;for(;w-- >v;){const S=n[w];e.containerState=S[1],S[0].exit.call(e,t)}n.length=v}function y(){o.write([null]),r=void 0,o=void 0,e.containerState._closeFlow=void 0}}},Oy={tokenize:function(t,e,n){return rt(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function Gr(t){return t===null||ct(t)||ur(t)?1:_l(t)?2:void 0}function Il(t,e,n){const o=[];let r=-1;for(;++r<t.length;){const s=t[r].resolveAll;s&&!o.includes(s)&&(e=s(e,n),o.push(s))}return e}const uh={name:"attention",resolveAll:function(t,e){let n,o,r,s,i,a,l,c,d=-1;for(;++d<t.length;)if(t[d][0]==="enter"&&t[d][1].type==="attentionSequence"&&t[d][1]._close){for(n=d;n--;)if(t[n][0]==="exit"&&t[n][1].type==="attentionSequence"&&t[n][1]._open&&e.sliceSerialize(t[n][1]).charCodeAt(0)===e.sliceSerialize(t[d][1]).charCodeAt(0)){if((t[n][1]._close||t[d][1]._open)&&(t[d][1].end.offset-t[d][1].start.offset)%3&&!((t[n][1].end.offset-t[n][1].start.offset+t[d][1].end.offset-t[d][1].start.offset)%3))continue;a=t[n][1].end.offset-t[n][1].start.offset>1&&t[d][1].end.offset-t[d][1].start.offset>1?2:1;const h={...t[n][1].end},f={...t[d][1].start};Dy(h,-a),Dy(f,a),s={type:a>1?"strongSequence":"emphasisSequence",start:h,end:{...t[n][1].end}},i={type:a>1?"strongSequence":"emphasisSequence",start:{...t[d][1].start},end:f},r={type:a>1?"strongText":"emphasisText",start:{...t[n][1].end},end:{...t[d][1].start}},o={type:a>1?"strong":"emphasis",start:{...s.start},end:{...i.end}},t[n][1].end={...s.start},t[d][1].start={...i.end},l=[],t[n][1].end.offset-t[n][1].start.offset&&(l=Sn(l,[["enter",t[n][1],e],["exit",t[n][1],e]])),l=Sn(l,[["enter",o,e],["enter",s,e],["exit",s,e],["enter",r,e]]),l=Sn(l,Il(e.parser.constructs.insideSpan.null,t.slice(n+1,d),e)),l=Sn(l,[["exit",r,e],["enter",i,e],["exit",i,e],["exit",o,e]]),t[d][1].end.offset-t[d][1].start.offset?(c=2,l=Sn(l,[["enter",t[d][1],e],["exit",t[d][1],e]])):c=0,gn(t,n-1,d-n+3,l),d=n+l.length-c-2;break}}for(d=-1;++d<t.length;)t[d][1].type==="attentionSequence"&&(t[d][1].type="data");return t},tokenize:function(t,e){const n=this.parser.constructs.attentionMarkers.null,o=this.previous,r=Gr(o);let s;return function(a){return s=a,t.enter("attentionSequence"),i(a)};function i(a){if(a===s)return t.consume(a),i;const l=t.exit("attentionSequence"),c=Gr(a),d=!c||c===2&&r||n.includes(a),h=!r||r===2&&c||n.includes(o);return l._open=!!(s===42?d:d&&(r||!h)),l._close=!!(s===42?h:h&&(c||!d)),e(a)}}};function Dy(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const PI={name:"autolink",tokenize:function(t,e,n){let o=0;return function(f){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),r};function r(f){return Zt(f)?(t.consume(f),s):f===64?n(f):l(f)}function s(f){return f===43||f===45||f===46||Ht(f)?(o=1,i(f)):l(f)}function i(f){return f===58?(t.consume(f),o=0,a):(f===43||f===45||f===46||Ht(f))&&o++<32?(t.consume(f),i):(o=0,l(f))}function a(f){return f===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):f===null||f===32||f===60||El(f)?n(f):(t.consume(f),a)}function l(f){return f===64?(t.consume(f),c):TI(f)?(t.consume(f),l):n(f)}function c(f){return Ht(f)?d(f):n(f)}function d(f){return f===46?(t.consume(f),o=0,c):f===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):h(f)}function h(f){if((f===45||Ht(f))&&o++<63){const m=f===45?h:d;return t.consume(f),m}return n(f)}}},pi={partial:!0,tokenize:function(t,e,n){return function(r){return et(r)?rt(t,o,"linePrefix")(r):o(r)};function o(r){return r===null||Be(r)?e(r):n(r)}}},Ry={continuation:{tokenize:function(t,e,n){const o=this;return function(s){return et(s)?rt(t,r,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):r(s)};function r(s){return t.attempt(Ry,e,n)(s)}}},exit:function(t){t.exit("blockQuote")},name:"blockQuote",tokenize:function(t,e,n){const o=this;return function(s){if(s===62){const i=o.containerState;return i.open||(t.enter("blockQuote",{_container:!0}),i.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(s),t.exit("blockQuoteMarker"),r}return n(s)};function r(s){return et(s)?(t.enter("blockQuotePrefixWhitespace"),t.consume(s),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(s))}}},Py={name:"characterEscape",tokenize:function(t,e,n){return function(r){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(r),t.exit("escapeMarker"),o};function o(r){return OI(r)?(t.enter("characterEscapeValue"),t.consume(r),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(r)}}},Ly={name:"characterReference",tokenize:function(t,e,n){const o=this;let r,s,i=0;return function(d){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(d),t.exit("characterReferenceMarker"),a};function a(d){return d===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(d),t.exit("characterReferenceMarkerNumeric"),l):(t.enter("characterReferenceValue"),r=31,s=Ht,c(d))}function l(d){return d===88||d===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(d),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),r=6,s=MI,c):(t.enter("characterReferenceValue"),r=7,s=dh,c(d))}function c(d){if(d===59&&i){const h=t.exit("characterReferenceValue");return s!==Ht||ch(o.sliceSerialize(h))?(t.enter("characterReferenceMarker"),t.consume(d),t.exit("characterReferenceMarker"),t.exit("characterReference"),e):n(d)}return s(d)&&i++<r?(t.consume(d),c):n(d)}}},Fy={partial:!0,tokenize:function(t,e,n){const o=this;return function(s){return s===null?n(s):(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),r)};function r(s){return o.parser.lazy[o.now().line]?n(s):e(s)}}},zy={concrete:!0,name:"codeFenced",tokenize:function(t,e,n){const o=this,r={partial:!0,tokenize:function(v,w,S){let C=0;return N;function N(O){return v.enter("lineEnding"),v.consume(O),v.exit("lineEnding"),j}function j(O){return v.enter("codeFencedFence"),et(O)?rt(v,E,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):E(O)}function E(O){return O===s?(v.enter("codeFencedFenceSequence"),T(O)):S(O)}function T(O){return O===s?(C++,v.consume(O),T):C>=a?(v.exit("codeFencedFenceSequence"),et(O)?rt(v,I,"whitespace")(O):I(O)):S(O)}function I(O){return O===null||Be(O)?(v.exit("codeFencedFence"),w(O)):S(O)}}};let s,i=0,a=0;return function(v){return function(w){const S=o.events[o.events.length-1];return i=S&&S[1].type==="linePrefix"?S[2].sliceSerialize(S[1],!0).length:0,s=w,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),l(w)}(v)};function l(v){return v===s?(a++,t.consume(v),l):a<3?n(v):(t.exit("codeFencedFenceSequence"),et(v)?rt(t,c,"whitespace")(v):c(v))}function c(v){return v===null||Be(v)?(t.exit("codeFencedFence"),o.interrupt?e(v):t.check(Fy,m,y)(v)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),d(v))}function d(v){return v===null||Be(v)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),c(v)):et(v)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),rt(t,h,"whitespace")(v)):v===96&&v===s?n(v):(t.consume(v),d)}function h(v){return v===null||Be(v)?c(v):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),f(v))}function f(v){return v===null||Be(v)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),c(v)):v===96&&v===s?n(v):(t.consume(v),f)}function m(v){return t.attempt(r,y,g)(v)}function g(v){return t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),x}function x(v){return i>0&&et(v)?rt(t,p,"linePrefix",i+1)(v):p(v)}function p(v){return v===null||Be(v)?t.check(Fy,m,y)(v):(t.enter("codeFlowValue"),b(v))}function b(v){return v===null||Be(v)?(t.exit("codeFlowValue"),p(v)):(t.consume(v),b)}function y(v){return t.exit("codeFenced"),e(v)}}},hh={name:"codeIndented",tokenize:function(t,e,n){const o=this;return function(l){return t.enter("codeIndented"),rt(t,r,"linePrefix",5)(l)};function r(l){const c=o.events[o.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?s(l):n(l)}function s(l){return l===null?a(l):Be(l)?t.attempt(LI,s,a)(l):(t.enter("codeFlowValue"),i(l))}function i(l){return l===null||Be(l)?(t.exit("codeFlowValue"),s(l)):(t.consume(l),i)}function a(l){return t.exit("codeIndented"),e(l)}}},LI={partial:!0,tokenize:function(t,e,n){const o=this;return r;function r(i){return o.parser.lazy[o.now().line]?n(i):Be(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),r):rt(t,s,"linePrefix",5)(i)}function s(i){const a=o.events[o.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(i):Be(i)?r(i):n(i)}}},FI={name:"codeText",previous:function(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"},resolve:function(t){let e,n,o=t.length-4,r=3;if(!(t[r][1].type!=="lineEnding"&&t[r][1].type!=="space"||t[o][1].type!=="lineEnding"&&t[o][1].type!=="space")){for(e=r;++e<o;)if(t[e][1].type==="codeTextData"){t[r][1].type="codeTextPadding",t[o][1].type="codeTextPadding",r+=2,o-=2;break}}for(e=r-1,o++;++e<=o;)n===void 0?e!==o&&t[e][1].type!=="lineEnding"&&(n=e):e!==o&&t[e][1].type!=="lineEnding"||(t[n][1].type="codeTextData",e!==n+2&&(t[n][1].end=t[e-1][1].end,t.splice(n+2,e-n-2),o-=e-n-2,e=n+2),n=void 0);return t},tokenize:function(t,e,n){let o,r,s=0;return function(d){return t.enter("codeText"),t.enter("codeTextSequence"),i(d)};function i(d){return d===96?(t.consume(d),s++,i):(t.exit("codeTextSequence"),a(d))}function a(d){return d===null?n(d):d===32?(t.enter("space"),t.consume(d),t.exit("space"),a):d===96?(r=t.enter("codeTextSequence"),o=0,c(d)):Be(d)?(t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),a):(t.enter("codeTextData"),l(d))}function l(d){return d===null||d===32||d===96||Be(d)?(t.exit("codeTextData"),a(d)):(t.consume(d),l)}function c(d){return d===96?(t.consume(d),o++,c):o===s?(t.exit("codeTextSequence"),t.exit("codeText"),e(d)):(r.type="codeTextData",l(d))}}};class zI{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,n){const o=n??Number.POSITIVE_INFINITY;return o<this.left.length?this.left.slice(e,o):e>this.left.length?this.right.slice(this.right.length-o+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-o+this.left.length).reverse())}splice(e,n,o){const r=n||0;this.setCursor(Math.trunc(e));const s=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return o&&gi(this.left,o),s.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),gi(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),gi(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const n=this.left.splice(e,Number.POSITIVE_INFINITY);gi(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);gi(this.left,n.reverse())}}}function gi(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function By(t){const e={};let n,o,r,s,i,a,l,c=-1;const d=new zI(t);for(;++c<d.length;){for(;c in e;)c=e[c];if(n=d.get(c),c&&n[1].type==="chunkFlow"&&d.get(c-1)[1].type==="listItemPrefix"&&(a=n[1]._tokenizer.events,r=0,r<a.length&&a[r][1].type==="lineEndingBlank"&&(r+=2),r<a.length&&a[r][1].type==="content"))for(;++r<a.length&&a[r][1].type!=="content";)a[r][1].type==="chunkText"&&(a[r][1]._isInFirstContentOfListItem=!0,r++);if(n[0]==="enter")n[1].contentType&&(Object.assign(e,BI(d,c)),c=e[c],l=!0);else if(n[1]._container){for(r=c,o=void 0;r--;)if(s=d.get(r),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(o&&(d.get(o)[1].type="lineEndingBlank"),s[1].type="lineEnding",o=r);else if(s[1].type!=="linePrefix"&&s[1].type!=="listItemIndent")break;o&&(n[1].end={...d.get(o)[1].start},i=d.slice(o,c),i.unshift(n),d.splice(o,c-o+1,i))}}return gn(t,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function BI(t,e){const n=t.get(e)[1],o=t.get(e)[2];let r=e-1;const s=[];let i=n._tokenizer;i||(i=o.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const a=i.events,l=[],c={};let d,h,f=-1,m=n,g=0,x=0;const p=[x];for(;m;){for(;t.get(++r)[1]!==m;);s.push(r),m._tokenizer||(d=o.sliceStream(m),m.next||d.push(null),h&&i.defineSkip(m.start),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),h=m,m=m.next}for(m=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(x=f+1,p.push(x),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(i.events=[],m?(m._tokenizer=void 0,m.previous=void 0):p.pop(),f=p.length;f--;){const b=a.slice(p[f],p[f+1]),y=s.pop();l.push([y,y+b.length-1]),t.splice(y,2,b)}for(l.reverse(),f=-1;++f<l.length;)c[g+l[f][0]]=g+l[f][1],g+=l[f][1]-l[f][0]-1;return c}const UI={resolve:function(t){return By(t),t},tokenize:function(t,e){let n;return function(i){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),o(i)};function o(i){return i===null?r(i):Be(i)?t.check($I,s,r)(i):(t.consume(i),o)}function r(i){return t.exit("chunkContent"),t.exit("content"),e(i)}function s(i){return t.consume(i),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}},$I={partial:!0,tokenize:function(t,e,n){const o=this;return function(s){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),rt(t,r,"linePrefix")};function r(s){if(s===null||Be(s))return n(s);const i=o.events[o.events.length-1];return!o.parser.constructs.disable.null.includes("codeIndented")&&i&&i[1].type==="linePrefix"&&i[2].sliceSerialize(i[1],!0).length>=4?e(s):t.interrupt(o.parser.constructs.flow,n,e)(s)}}};function Uy(t,e,n,o,r,s,i,a,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return function(p){return p===60?(t.enter(o),t.enter(r),t.enter(s),t.consume(p),t.exit(s),h):p===null||p===32||p===41||El(p)?n(p):(t.enter(o),t.enter(i),t.enter(a),t.enter("chunkString",{contentType:"string"}),g(p))};function h(p){return p===62?(t.enter(s),t.consume(p),t.exit(s),t.exit(r),t.exit(o),e):(t.enter(a),t.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===62?(t.exit("chunkString"),t.exit(a),h(p)):p===null||p===60||Be(p)?n(p):(t.consume(p),p===92?m:f)}function m(p){return p===60||p===62||p===92?(t.consume(p),f):f(p)}function g(p){return d||p!==null&&p!==41&&!ct(p)?d<c&&p===40?(t.consume(p),d++,g):p===41?(t.consume(p),d--,g):p===null||p===32||p===40||El(p)?n(p):(t.consume(p),p===92?x:g):(t.exit("chunkString"),t.exit(a),t.exit(i),t.exit(o),e(p))}function x(p){return p===40||p===41||p===92?(t.consume(p),g):g(p)}}function $y(t,e,n,o,r,s){const i=this;let a,l=0;return function(f){return t.enter(o),t.enter(r),t.consume(f),t.exit(r),t.enter(s),c};function c(f){return l>999||f===null||f===91||f===93&&!a||f===94&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(f):f===93?(t.exit(s),t.enter(r),t.consume(f),t.exit(r),t.exit(o),e):Be(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),c):(t.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===null||f===91||f===93||Be(f)||l++>999?(t.exit("chunkString"),c(f)):(t.consume(f),a||(a=!et(f)),f===92?h:d)}function h(f){return f===91||f===92||f===93?(t.consume(f),l++,d):d(f)}}function Vy(t,e,n,o,r,s){let i;return function(h){return h===34||h===39||h===40?(t.enter(o),t.enter(r),t.consume(h),t.exit(r),i=h===40?41:h,a):n(h)};function a(h){return h===i?(t.enter(r),t.consume(h),t.exit(r),t.exit(o),e):(t.enter(s),l(h))}function l(h){return h===i?(t.exit(s),a(i)):h===null?n(h):Be(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),rt(t,l,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),c(h))}function c(h){return h===i||h===null||Be(h)?(t.exit("chunkString"),l(h)):(t.consume(h),h===92?d:c)}function d(h){return h===i||h===92?(t.consume(h),c):c(h)}}function xi(t,e){let n;return function o(r){return Be(r)?(t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),n=!0,o):et(r)?rt(t,o,n?"linePrefix":"lineSuffix")(r):e(r)}}const VI={name:"definition",tokenize:function(t,e,n){const o=this;let r;return function(h){return t.enter("definition"),function(f){return $y.call(o,t,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}(h)};function s(h){return r=Rn(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)),h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),i):n(h)}function i(h){return ct(h)?xi(t,a)(h):a(h)}function a(h){return Uy(t,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function l(h){return t.attempt(HI,c,c)(h)}function c(h){return et(h)?rt(t,d,"whitespace")(h):d(h)}function d(h){return h===null||Be(h)?(t.exit("definition"),o.parser.defined.push(r),e(h)):n(h)}}},HI={partial:!0,tokenize:function(t,e,n){return function(i){return ct(i)?xi(t,o)(i):n(i)};function o(i){return Vy(t,r,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(i)}function r(i){return et(i)?rt(t,s,"whitespace")(i):s(i)}function s(i){return i===null||Be(i)?e(i):n(i)}}},WI={name:"hardBreakEscape",tokenize:function(t,e,n){return function(r){return t.enter("hardBreakEscape"),t.consume(r),o};function o(r){return Be(r)?(t.exit("hardBreakEscape"),e(r)):n(r)}}},qI={name:"headingAtx",resolve:function(t,e){let n,o,r=t.length-2,s=3;return t[s][1].type==="whitespace"&&(s+=2),r-2>s&&t[r][1].type==="whitespace"&&(r-=2),t[r][1].type==="atxHeadingSequence"&&(s===r-1||r-4>s&&t[r-2][1].type==="whitespace")&&(r-=s+1===r?2:4),r>s&&(n={type:"atxHeadingText",start:t[s][1].start,end:t[r][1].end},o={type:"chunkText",start:t[s][1].start,end:t[r][1].end,contentType:"text"},gn(t,s,r-s+1,[["enter",n,e],["enter",o,e],["exit",o,e],["exit",n,e]])),t},tokenize:function(t,e,n){let o=0;return function(l){return t.enter("atxHeading"),function(c){return t.enter("atxHeadingSequence"),r(c)}(l)};function r(l){return l===35&&o++<6?(t.consume(l),r):l===null||ct(l)?(t.exit("atxHeadingSequence"),s(l)):n(l)}function s(l){return l===35?(t.enter("atxHeadingSequence"),i(l)):l===null||Be(l)?(t.exit("atxHeading"),e(l)):et(l)?rt(t,s,"whitespace")(l):(t.enter("atxHeadingText"),a(l))}function i(l){return l===35?(t.consume(l),i):(t.exit("atxHeadingSequence"),s(l))}function a(l){return l===null||l===35||ct(l)?(t.exit("atxHeadingText"),s(l)):(t.consume(l),a)}}},GI=["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"],Hy=["pre","script","style","textarea"],YI={concrete:!0,name:"htmlFlow",resolveTo:function(t){let e=t.length;for(;e--&&(t[e][0]!=="enter"||t[e][1].type!=="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t},tokenize:function(t,e,n){const o=this;let r,s,i,a,l;return function(A){return function(U){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(U),c}(A)};function c(A){return A===33?(t.consume(A),d):A===47?(t.consume(A),s=!0,m):A===63?(t.consume(A),r=3,o.interrupt?e:_):Zt(A)?(t.consume(A),i=String.fromCharCode(A),g):n(A)}function d(A){return A===45?(t.consume(A),r=2,h):A===91?(t.consume(A),r=5,a=0,f):Zt(A)?(t.consume(A),r=4,o.interrupt?e:_):n(A)}function h(A){return A===45?(t.consume(A),o.interrupt?e:_):n(A)}function f(A){return A==="CDATA[".charCodeAt(a++)?(t.consume(A),a===6?o.interrupt?e:T:f):n(A)}function m(A){return Zt(A)?(t.consume(A),i=String.fromCharCode(A),g):n(A)}function g(A){if(A===null||A===47||A===62||ct(A)){const U=A===47,$=i.toLowerCase();return U||s||!Hy.includes($)?GI.includes(i.toLowerCase())?(r=6,U?(t.consume(A),x):o.interrupt?e(A):T(A)):(r=7,o.interrupt&&!o.parser.lazy[o.now().line]?n(A):s?p(A):b(A)):(r=1,o.interrupt?e(A):T(A))}return A===45||Ht(A)?(t.consume(A),i+=String.fromCharCode(A),g):n(A)}function x(A){return A===62?(t.consume(A),o.interrupt?e:T):n(A)}function p(A){return et(A)?(t.consume(A),p):j(A)}function b(A){return A===47?(t.consume(A),j):A===58||A===95||Zt(A)?(t.consume(A),y):et(A)?(t.consume(A),b):j(A)}function y(A){return A===45||A===46||A===58||A===95||Ht(A)?(t.consume(A),y):v(A)}function v(A){return A===61?(t.consume(A),w):et(A)?(t.consume(A),v):b(A)}function w(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(t.consume(A),l=A,S):et(A)?(t.consume(A),w):C(A)}function S(A){return A===l?(t.consume(A),l=null,N):A===null||Be(A)?n(A):(t.consume(A),S)}function C(A){return A===null||A===34||A===39||A===47||A===60||A===61||A===62||A===96||ct(A)?v(A):(t.consume(A),C)}function N(A){return A===47||A===62||et(A)?b(A):n(A)}function j(A){return A===62?(t.consume(A),E):n(A)}function E(A){return A===null||Be(A)?T(A):et(A)?(t.consume(A),E):n(A)}function T(A){return A===45&&r===2?(t.consume(A),D):A===60&&r===1?(t.consume(A),R):A===62&&r===4?(t.consume(A),k):A===63&&r===3?(t.consume(A),_):A===93&&r===5?(t.consume(A),z):!Be(A)||r!==6&&r!==7?A===null||Be(A)?(t.exit("htmlFlowData"),I(A)):(t.consume(A),T):(t.exit("htmlFlowData"),t.check(KI,B,I)(A))}function I(A){return t.check(XI,O,B)(A)}function O(A){return t.enter("lineEnding"),t.consume(A),t.exit("lineEnding"),L}function L(A){return A===null||Be(A)?I(A):(t.enter("htmlFlowData"),T(A))}function D(A){return A===45?(t.consume(A),_):T(A)}function R(A){return A===47?(t.consume(A),i="",P):T(A)}function P(A){if(A===62){const U=i.toLowerCase();return Hy.includes(U)?(t.consume(A),k):T(A)}return Zt(A)&&i.length<8?(t.consume(A),i+=String.fromCharCode(A),P):T(A)}function z(A){return A===93?(t.consume(A),_):T(A)}function _(A){return A===62?(t.consume(A),k):A===45&&r===2?(t.consume(A),_):T(A)}function k(A){return A===null||Be(A)?(t.exit("htmlFlowData"),B(A)):(t.consume(A),k)}function B(A){return t.exit("htmlFlow"),e(A)}}},KI={partial:!0,tokenize:function(t,e,n){return function(o){return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),t.attempt(pi,e,n)}}},XI={partial:!0,tokenize:function(t,e,n){const o=this;return function(s){return Be(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),r):n(s)};function r(s){return o.parser.lazy[o.now().line]?n(s):e(s)}}},JI={name:"htmlText",tokenize:function(t,e,n){const o=this;let r,s,i;return function(k){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(k),a};function a(k){return k===33?(t.consume(k),l):k===47?(t.consume(k),w):k===63?(t.consume(k),y):Zt(k)?(t.consume(k),N):n(k)}function l(k){return k===45?(t.consume(k),c):k===91?(t.consume(k),s=0,m):Zt(k)?(t.consume(k),b):n(k)}function c(k){return k===45?(t.consume(k),f):n(k)}function d(k){return k===null?n(k):k===45?(t.consume(k),h):Be(k)?(i=d,P(k)):(t.consume(k),d)}function h(k){return k===45?(t.consume(k),f):d(k)}function f(k){return k===62?R(k):k===45?h(k):d(k)}function m(k){return k==="CDATA[".charCodeAt(s++)?(t.consume(k),s===6?g:m):n(k)}function g(k){return k===null?n(k):k===93?(t.consume(k),x):Be(k)?(i=g,P(k)):(t.consume(k),g)}function x(k){return k===93?(t.consume(k),p):g(k)}function p(k){return k===62?R(k):k===93?(t.consume(k),p):g(k)}function b(k){return k===null||k===62?R(k):Be(k)?(i=b,P(k)):(t.consume(k),b)}function y(k){return k===null?n(k):k===63?(t.consume(k),v):Be(k)?(i=y,P(k)):(t.consume(k),y)}function v(k){return k===62?R(k):y(k)}function w(k){return Zt(k)?(t.consume(k),S):n(k)}function S(k){return k===45||Ht(k)?(t.consume(k),S):C(k)}function C(k){return Be(k)?(i=C,P(k)):et(k)?(t.consume(k),C):R(k)}function N(k){return k===45||Ht(k)?(t.consume(k),N):k===47||k===62||ct(k)?j(k):n(k)}function j(k){return k===47?(t.consume(k),R):k===58||k===95||Zt(k)?(t.consume(k),E):Be(k)?(i=j,P(k)):et(k)?(t.consume(k),j):R(k)}function E(k){return k===45||k===46||k===58||k===95||Ht(k)?(t.consume(k),E):T(k)}function T(k){return k===61?(t.consume(k),I):Be(k)?(i=T,P(k)):et(k)?(t.consume(k),T):j(k)}function I(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(t.consume(k),r=k,O):Be(k)?(i=I,P(k)):et(k)?(t.consume(k),I):(t.consume(k),L)}function O(k){return k===r?(t.consume(k),r=void 0,D):k===null?n(k):Be(k)?(i=O,P(k)):(t.consume(k),O)}function L(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||ct(k)?j(k):(t.consume(k),L)}function D(k){return k===47||k===62||ct(k)?j(k):n(k)}function R(k){return k===62?(t.consume(k),t.exit("htmlTextData"),t.exit("htmlText"),e):n(k)}function P(k){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),z}function z(k){return et(k)?rt(t,_,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):_(k)}function _(k){return t.enter("htmlTextData"),i(k)}}},fh={name:"labelEnd",resolveAll:function(t){let e=-1;const n=[];for(;++e<t.length;){const o=t[e][1];if(n.push(t[e]),o.type==="labelImage"||o.type==="labelLink"||o.type==="labelEnd"){const r=o.type==="labelImage"?4:2;o.type="data",e+=r}}return t.length!==n.length&&gn(t,0,t.length,n),t},resolveTo:function(t,e){let n,o,r,s,i=t.length,a=0;for(;i--;)if(n=t[i][1],o){if(n.type==="link"||n.type==="labelLink"&&n._inactive)break;t[i][0]==="enter"&&n.type==="labelLink"&&(n._inactive=!0)}else if(r){if(t[i][0]==="enter"&&(n.type==="labelImage"||n.type==="labelLink")&&!n._balanced&&(o=i,n.type!=="labelLink")){a=2;break}}else n.type==="labelEnd"&&(r=i);const l={type:t[o][1].type==="labelLink"?"link":"image",start:{...t[o][1].start},end:{...t[t.length-1][1].end}},c={type:"label",start:{...t[o][1].start},end:{...t[r][1].end}},d={type:"labelText",start:{...t[o+a+2][1].end},end:{...t[r-2][1].start}};return s=[["enter",l,e],["enter",c,e]],s=Sn(s,t.slice(o+1,o+a+3)),s=Sn(s,[["enter",d,e]]),s=Sn(s,Il(e.parser.constructs.insideSpan.null,t.slice(o+a+4,r-3),e)),s=Sn(s,[["exit",d,e],t[r-2],t[r-1],["exit",c,e]]),s=Sn(s,t.slice(r+1)),s=Sn(s,[["exit",l,e]]),gn(t,o,t.length,s),t},tokenize:function(t,e,n){const o=this;let r,s,i=o.events.length;for(;i--;)if((o.events[i][1].type==="labelImage"||o.events[i][1].type==="labelLink")&&!o.events[i][1]._balanced){r=o.events[i][1];break}return function(h){return r?r._inactive?d(h):(s=o.parser.defined.includes(Rn(o.sliceSerialize({start:r.end,end:o.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(h),t.exit("labelMarker"),t.exit("labelEnd"),a):n(h)};function a(h){return h===40?t.attempt(ZI,c,s?c:d)(h):h===91?t.attempt(QI,c,s?l:d)(h):s?c(h):d(h)}function l(h){return t.attempt(e8,c,d)(h)}function c(h){return e(h)}function d(h){return r._balanced=!0,n(h)}}},ZI={tokenize:function(t,e,n){return function(d){return t.enter("resource"),t.enter("resourceMarker"),t.consume(d),t.exit("resourceMarker"),o};function o(d){return ct(d)?xi(t,r)(d):r(d)}function r(d){return d===41?c(d):Uy(t,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function s(d){return ct(d)?xi(t,a)(d):c(d)}function i(d){return n(d)}function a(d){return d===34||d===39||d===40?Vy(t,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):c(d)}function l(d){return ct(d)?xi(t,c)(d):c(d)}function c(d){return d===41?(t.enter("resourceMarker"),t.consume(d),t.exit("resourceMarker"),t.exit("resource"),e):n(d)}}},QI={tokenize:function(t,e,n){const o=this;return function(i){return $y.call(o,t,r,s,"reference","referenceMarker","referenceString")(i)};function r(i){return o.parser.defined.includes(Rn(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)))?e(i):n(i)}function s(i){return n(i)}}},e8={tokenize:function(t,e,n){return function(r){return t.enter("reference"),t.enter("referenceMarker"),t.consume(r),t.exit("referenceMarker"),o};function o(r){return r===93?(t.enter("referenceMarker"),t.consume(r),t.exit("referenceMarker"),t.exit("reference"),e):n(r)}}},t8={name:"labelStartImage",resolveAll:fh.resolveAll,tokenize:function(t,e,n){const o=this;return function(i){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(i),t.exit("labelImageMarker"),r};function r(i){return i===91?(t.enter("labelMarker"),t.consume(i),t.exit("labelMarker"),t.exit("labelImage"),s):n(i)}function s(i){return i===94&&"_hiddenFootnoteSupport"in o.parser.constructs?n(i):e(i)}}},n8={name:"labelStartLink",resolveAll:fh.resolveAll,tokenize:function(t,e,n){const o=this;return function(s){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(s),t.exit("labelMarker"),t.exit("labelLink"),r};function r(s){return s===94&&"_hiddenFootnoteSupport"in o.parser.constructs?n(s):e(s)}}},mh={name:"lineEnding",tokenize:function(t,e){return function(n){return t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),rt(t,e,"linePrefix")}}},Al={name:"thematicBreak",tokenize:function(t,e,n){let o,r=0;return function(a){return t.enter("thematicBreak"),function(l){return o=l,s(l)}(a)};function s(a){return a===o?(t.enter("thematicBreakSequence"),i(a)):r>=3&&(a===null||Be(a))?(t.exit("thematicBreak"),e(a)):n(a)}function i(a){return a===o?(t.consume(a),r++,i):(t.exit("thematicBreakSequence"),et(a)?rt(t,s,"whitespace")(a):s(a))}}},rn={continuation:{tokenize:function(t,e,n){const o=this;return o.containerState._closeFlow=void 0,t.check(pi,r,s);function r(a){return o.containerState.furtherBlankLines=o.containerState.furtherBlankLines||o.containerState.initialBlankLine,rt(t,e,"listItemIndent",o.containerState.size+1)(a)}function s(a){return o.containerState.furtherBlankLines||!et(a)?(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,i(a)):(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,t.attempt(r8,e,i)(a))}function i(a){return o.containerState._closeFlow=!0,o.interrupt=void 0,rt(t,t.attempt(rn,e,n),"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}},exit:function(t){t.exit(this.containerState.type)},name:"list",tokenize:function(t,e,n){const o=this,r=o.events[o.events.length-1];let s=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0,i=0;return function(f){const m=o.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!o.containerState.marker||f===o.containerState.marker:dh(f)){if(o.containerState.type||(o.containerState.type=m,t.enter(m,{_container:!0})),m==="listUnordered")return t.enter("listItemPrefix"),f===42||f===45?t.check(Al,n,l)(f):l(f);if(!o.interrupt||f===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),a(f)}return n(f)};function a(f){return dh(f)&&++i<10?(t.consume(f),a):(!o.interrupt||i<2)&&(o.containerState.marker?f===o.containerState.marker:f===41||f===46)?(t.exit("listItemValue"),l(f)):n(f)}function l(f){return t.enter("listItemMarker"),t.consume(f),t.exit("listItemMarker"),o.containerState.marker=o.containerState.marker||f,t.check(pi,o.interrupt?n:c,t.attempt(o8,h,d))}function c(f){return o.containerState.initialBlankLine=!0,s++,h(f)}function d(f){return et(f)?(t.enter("listItemPrefixWhitespace"),t.consume(f),t.exit("listItemPrefixWhitespace"),h):n(f)}function h(f){return o.containerState.size=s+o.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(f)}}},o8={partial:!0,tokenize:function(t,e,n){const o=this;return rt(t,function(r){const s=o.events[o.events.length-1];return!et(r)&&s&&s[1].type==="listItemPrefixWhitespace"?e(r):n(r)},"listItemPrefixWhitespace",o.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},r8={partial:!0,tokenize:function(t,e,n){const o=this;return rt(t,function(r){const s=o.events[o.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===o.containerState.size?e(r):n(r)},"listItemIndent",o.containerState.size+1)}},Wy={name:"setextUnderline",resolveTo:function(t,e){let n,o,r,s=t.length;for(;s--;)if(t[s][0]==="enter"){if(t[s][1].type==="content"){n=s;break}t[s][1].type==="paragraph"&&(o=s)}else t[s][1].type==="content"&&t.splice(s,1),r||t[s][1].type!=="definition"||(r=s);const i={type:"setextHeading",start:{...t[n][1].start},end:{...t[t.length-1][1].end}};return t[o][1].type="setextHeadingText",r?(t.splice(o,0,["enter",i,e]),t.splice(r+1,0,["exit",t[n][1],e]),t[n][1].end={...t[r][1].end}):t[n][1]=i,t.push(["exit",i,e]),t},tokenize:function(t,e,n){const o=this;let r;return function(a){let l,c=o.events.length;for(;c--;)if(o.events[c][1].type!=="lineEnding"&&o.events[c][1].type!=="linePrefix"&&o.events[c][1].type!=="content"){l=o.events[c][1].type==="paragraph";break}return!o.parser.lazy[o.now().line]&&(o.interrupt||l)?(t.enter("setextHeadingLine"),r=a,function(d){return t.enter("setextHeadingLineSequence"),s(d)}(a)):n(a)};function s(a){return a===r?(t.consume(a),s):(t.exit("setextHeadingLineSequence"),et(a)?rt(t,i,"lineSuffix")(a):i(a))}function i(a){return a===null||Be(a)?(t.exit("setextHeadingLine"),e(a)):n(a)}}},s8={tokenize:function(t){const e=this,n=t.attempt(pi,function(r){return r===null?void t.consume(r):(t.enter("lineEndingBlank"),t.consume(r),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n)},t.attempt(this.parser.constructs.flowInitial,o,rt(t,t.attempt(this.parser.constructs.flow,o,t.attempt(UI,o)),"linePrefix")));return n;function o(r){if(r!==null)return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),e.currentConstruct=void 0,n;t.consume(r)}}},i8={resolveAll:Gy()},a8=qy("string"),l8=qy("text");function qy(t){return{resolveAll:Gy(t==="text"?c8:void 0),tokenize:function(e){const n=this,o=this.parser.constructs[t],r=e.attempt(o,s,i);return s;function s(c){return l(c)?r(c):i(c)}function i(c){if(c!==null)return e.enter("data"),e.consume(c),a;e.consume(c)}function a(c){return l(c)?(e.exit("data"),r(c)):(e.consume(c),a)}function l(c){if(c===null)return!0;const d=o[c];let h=-1;if(d)for(;++h<d.length;){const f=d[h];if(!f.previous||f.previous.call(n,n.previous))return!0}return!1}}}}function Gy(t){return function(e,n){let o,r=-1;for(;++r<=e.length;)o===void 0?e[r]&&e[r][1].type==="data"&&(o=r,r++):e[r]&&e[r][1].type==="data"||(r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),r=o+2),o=void 0);return t?t(e,n):e}}function c8(t,e){let n=0;for(;++n<=t.length;)if((n===t.length||t[n][1].type==="lineEnding")&&t[n-1][1].type==="data"){const o=t[n-1][1],r=e.sliceStream(o);let s,i=r.length,a=-1,l=0;for(;i--;){const c=r[i];if(typeof c=="string"){for(a=c.length;c.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(c===-2)s=!0,l++;else if(c!==-1){i++;break}}if(e._contentTypeTextTrailing&&n===t.length&&(l=0),l){const c={type:n===t.length||s||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:o.start._bufferIndex+a,_index:o.start._index+i,line:o.end.line,column:o.end.column-l,offset:o.end.offset-l},end:{...o.end}};o.end={...c.start},o.start.offset===o.end.offset?Object.assign(o,c):(t.splice(n,0,["enter",c,e],["exit",c,e]),n+=2)}n++}return t}const d8={42:rn,43:rn,45:rn,48:rn,49:rn,50:rn,51:rn,52:rn,53:rn,54:rn,55:rn,56:rn,57:rn,62:Ry},u8={91:VI},h8={[-2]:hh,[-1]:hh,32:hh},f8={35:qI,42:Al,45:[Wy,Al],60:YI,61:Wy,95:Al,96:zy,126:zy},m8={38:Ly,92:Py},p8={[-5]:mh,[-4]:mh,[-3]:mh,33:t8,38:Ly,42:uh,60:[PI,JI],91:n8,92:[WI,Py],93:fh,95:uh,96:FI},g8={null:[uh,i8]},x8=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:u8,disable:{null:[]},document:d8,flow:f8,flowInitial:h8,insideSpan:g8,string:m8,text:p8},Symbol.toStringTag,{value:"Module"}));function b8(t,e,n){let o={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const r={},s=[];let i=[],a=[];const l={attempt:p(function(v,w){b(v,w.from)}),check:p(x),consume:function(v){Be(v)?(o.line++,o.column=1,o.offset+=v===-3?2:1,y()):v!==-1&&(o.column++,o.offset++),o._bufferIndex<0?o._index++:(o._bufferIndex++,o._bufferIndex===i[o._index].length&&(o._bufferIndex=-1,o._index++)),c.previous=v},enter:function(v,w){const S=w||{};return S.type=v,S.start=f(),c.events.push(["enter",S,c]),a.push(S),S},exit:function(v){const w=a.pop();return w.end=f(),c.events.push(["exit",w,c]),w},interrupt:p(x,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(v){r[v.line]=v.column,y()},events:[],now:f,parser:t,previous:null,sliceSerialize:function(v,w){return function(S,C){let N=-1;const j=[];let E;for(;++N<S.length;){const T=S[N];let I;if(typeof T=="string")I=T;else switch(T){case-5:I="\r";break;case-4:I=`
129
+ `;break;case-3:I=`\r
130
+ `;break;case-2:I=C?" ":" ";break;case-1:if(!C&&E)continue;I=" ";break;default:I=String.fromCharCode(T)}E=T===-2,j.push(I)}return j.join("")}(h(v),w)},sliceStream:h,write:function(v){return i=Sn(i,v),m(),i[i.length-1]!==null?[]:(b(e,0),c.events=Il(s,c.events,c),c.events)}};let d=e.tokenize.call(c,l);return e.resolveAll&&s.push(e),c;function h(v){return function(w,S){const C=S.start._index,N=S.start._bufferIndex,j=S.end._index,E=S.end._bufferIndex;let T;if(C===j)T=[w[C].slice(N,E)];else{if(T=w.slice(C,j),N>-1){const I=T[0];typeof I=="string"?T[0]=I.slice(N):T.shift()}E>0&&T.push(w[j].slice(0,E))}return T}(i,v)}function f(){const{_bufferIndex:v,_index:w,line:S,column:C,offset:N}=o;return{_bufferIndex:v,_index:w,line:S,column:C,offset:N}}function m(){let v;for(;o._index<i.length;){const w=i[o._index];if(typeof w=="string")for(v=o._index,o._bufferIndex<0&&(o._bufferIndex=0);o._index===v&&o._bufferIndex<w.length;)g(w.charCodeAt(o._bufferIndex));else g(w)}}function g(v){d=d(v)}function x(v,w){w.restore()}function p(v,w){return function(S,C,N){let j,E,T,I;return Array.isArray(S)?O(S):"tokenize"in S?O([S]):function(P){return z;function z(_){const k=_!==null&&P[_],B=_!==null&&P.null;return O([...Array.isArray(k)?k:k?[k]:[],...Array.isArray(B)?B:B?[B]:[]])(_)}}(S);function O(P){return j=P,E=0,P.length===0?N:L(P[E])}function L(P){return function(z){return I=function(){const _=f(),k=c.previous,B=c.currentConstruct,A=c.events.length,U=Array.from(a);return{from:A,restore:$};function $(){o=_,c.previous=k,c.currentConstruct=B,c.events.length=A,a=U,y()}}(),T=P,P.partial||(c.currentConstruct=P),P.name&&c.parser.constructs.disable.null.includes(P.name)?R():P.tokenize.call(w?Object.assign(Object.create(c),w):c,l,D,R)(z)}}function D(P){return v(T,I),C}function R(P){return I.restore(),++E<j.length?L(j[E]):N}}}function b(v,w){v.resolveAll&&!s.includes(v)&&s.push(v),v.resolve&&gn(c.events,w,c.events.length-w,v.resolve(c.events.slice(w),c)),v.resolveTo&&(c.events=v.resolveTo(c.events,c))}function y(){o.line in r&&o.column<2&&(o.column=r[o.line],o.offset+=r[o.line]-1)}}const Yy=/[\0\t\n\r]/g,y8=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function v8(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const o=n.charCodeAt(1),r=o===120||o===88;return My(n.slice(r?2:1),r?16:10)}return ch(n)||t}const Ky={}.hasOwnProperty;function w8(t,e,n){return typeof e!="string"&&(n=e,e=void 0),function(o){const r={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Te),autolinkProtocol:O,autolinkEmail:O,atxHeading:l(oe),blockQuote:l(ne),characterEscape:O,characterReference:O,codeFenced:l(ie),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:l(ie,c),codeText:l(se,c),codeTextData:O,data:O,codeFlowValue:O,definition:l(ae),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:l(ge),hardBreakEscape:l(ue),hardBreakTrailing:l(ue),htmlFlow:l(de,c),htmlFlowData:O,htmlText:l(de,c),htmlTextData:O,image:l(Se),label:c,link:l(Te),listItem:l(_e),listItemValue:x,listOrdered:l(Fe,g),listUnordered:l(Fe),paragraph:l(ke),reference:G,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:l(oe),strong:l(Ye),thematicBreak:l(Ke)},exit:{atxHeading:h(),atxHeadingSequence:j,autolink:h(),autolinkEmail:re,autolinkProtocol:te,blockQuote:h(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:J,characterReferenceMarkerNumeric:J,characterReferenceValue:V,characterReference:Q,codeFenced:h(v),codeFencedFence:y,codeFencedFenceInfo:p,codeFencedFenceMeta:b,codeFlowValue:L,codeIndented:h(w),codeText:h(_),codeTextData:L,data:L,definition:h(),definitionDestinationString:N,definitionLabelString:S,definitionTitleString:C,emphasis:h(),hardBreakEscape:h(R),hardBreakTrailing:h(R),htmlFlow:h(P),htmlFlowData:L,htmlText:h(z),htmlTextData:L,image:h(B),label:U,labelText:A,lineEnding:D,link:h(k),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:W,resourceDestinationString:$,resourceTitleString:X,resource:Y,setextHeading:h(I),setextHeadingLineSequence:T,setextHeadingText:E,strong:h(),thematicBreak:h()}};Xy(r,(o||{}).mdastExtensions||[]);const s={};return i;function i(ee){let ye={type:"root",children:[]};const we={stack:[ye],tokenStack:[],config:r,enter:d,exit:f,buffer:c,resume:m,data:s},Ie=[];let K=-1;for(;++K<ee.length;)(ee[K][1].type==="listOrdered"||ee[K][1].type==="listUnordered")&&(ee[K][0]==="enter"?Ie.push(K):K=a(ee,Ie.pop(),K));for(K=-1;++K<ee.length;){const me=r[ee[K][0]];Ky.call(me,ee[K][1].type)&&me[ee[K][1].type].call(Object.assign({sliceSerialize:ee[K][2].sliceSerialize},we),ee[K][1])}if(we.tokenStack.length>0){const me=we.tokenStack[we.tokenStack.length-1];(me[1]||Jy).call(we,void 0,me[0])}for(ye.position={start:Fo(ee.length>0?ee[0][1].start:{line:1,column:1,offset:0}),end:Fo(ee.length>0?ee[ee.length-2][1].end:{line:1,column:1,offset:0})},K=-1;++K<r.transforms.length;)ye=r.transforms[K](ye)||ye;return ye}function a(ee,ye,we){let Ie,K,me,pe,he=ye-1,Ce=-1,Re=!1;for(;++he<=we;){const Pe=ee[he];switch(Pe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":Pe[0]==="enter"?Ce++:Ce--,pe=void 0;break;case"lineEndingBlank":Pe[0]==="enter"&&(!Ie||pe||Ce||me||(me=he),pe=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:pe=void 0}if(!Ce&&Pe[0]==="enter"&&Pe[1].type==="listItemPrefix"||Ce===-1&&Pe[0]==="exit"&&(Pe[1].type==="listUnordered"||Pe[1].type==="listOrdered")){if(Ie){let He=he;for(K=void 0;He--;){const le=ee[He];if(le[1].type==="lineEnding"||le[1].type==="lineEndingBlank"){if(le[0]==="exit")continue;K&&(ee[K][1].type="lineEndingBlank",Re=!0),le[1].type="lineEnding",K=He}else if(le[1].type!=="linePrefix"&&le[1].type!=="blockQuotePrefix"&&le[1].type!=="blockQuotePrefixWhitespace"&&le[1].type!=="blockQuoteMarker"&&le[1].type!=="listItemIndent")break}me&&(!K||me<K)&&(Ie._spread=!0),Ie.end=Object.assign({},K?ee[K][1].start:Pe[1].end),ee.splice(K||he,0,["exit",Ie,Pe[2]]),he++,we++}if(Pe[1].type==="listItemPrefix"){const He={type:"listItem",_spread:!1,start:Object.assign({},Pe[1].start),end:void 0};Ie=He,ee.splice(he,0,["enter",He,Pe[2]]),he++,we++,me=void 0,pe=!0}}}return ee[ye][1]._spread=Re,we}function l(ee,ye){return we;function we(Ie){d.call(this,ee(Ie),Ie),ye&&ye.call(this,Ie)}}function c(){this.stack.push({type:"fragment",children:[]})}function d(ee,ye,we){this.stack[this.stack.length-1].children.push(ee),this.stack.push(ee),this.tokenStack.push([ye,we||void 0]),ee.position={start:Fo(ye.start),end:void 0}}function h(ee){return ye;function ye(we){ee&&ee.call(this,we),f.call(this,we)}}function f(ee,ye){const we=this.stack.pop(),Ie=this.tokenStack.pop();if(!Ie)throw new Error("Cannot close `"+ee.type+"` ("+fi({start:ee.start,end:ee.end})+"): it\u2019s not open");Ie[0].type!==ee.type&&(ye?ye.call(this,ee,Ie[0]):(Ie[1]||Jy).call(this,ee,Ie[0])),we.position.end=Fo(ee.end)}function m(){return lh(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function x(ee){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(ee),10),this.data.expectingFirstListItemValue=void 0)}function p(){const ee=this.resume();this.stack[this.stack.length-1].lang=ee}function b(){const ee=this.resume();this.stack[this.stack.length-1].meta=ee}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const ee=this.resume();this.stack[this.stack.length-1].value=ee.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function w(){const ee=this.resume();this.stack[this.stack.length-1].value=ee.replace(/(\r?\n|\r)$/g,"")}function S(ee){const ye=this.resume(),we=this.stack[this.stack.length-1];we.label=ye,we.identifier=Rn(this.sliceSerialize(ee)).toLowerCase()}function C(){const ee=this.resume();this.stack[this.stack.length-1].title=ee}function N(){const ee=this.resume();this.stack[this.stack.length-1].url=ee}function j(ee){const ye=this.stack[this.stack.length-1];if(!ye.depth){const we=this.sliceSerialize(ee).length;ye.depth=we}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function T(ee){this.stack[this.stack.length-1].depth=this.sliceSerialize(ee).codePointAt(0)===61?1:2}function I(){this.data.setextHeadingSlurpLineEnding=void 0}function O(ee){const ye=this.stack[this.stack.length-1].children;let we=ye[ye.length-1];we&&we.type==="text"||(we=Ve(),we.position={start:Fo(ee.start),end:void 0},ye.push(we)),this.stack.push(we)}function L(ee){const ye=this.stack.pop();ye.value+=this.sliceSerialize(ee),ye.position.end=Fo(ee.end)}function D(ee){const ye=this.stack[this.stack.length-1];if(this.data.atHardBreak)return ye.children[ye.children.length-1].position.end=Fo(ee.end),void(this.data.atHardBreak=void 0);!this.data.setextHeadingSlurpLineEnding&&r.canContainEols.includes(ye.type)&&(O.call(this,ee),L.call(this,ee))}function R(){this.data.atHardBreak=!0}function P(){const ee=this.resume();this.stack[this.stack.length-1].value=ee}function z(){const ee=this.resume();this.stack[this.stack.length-1].value=ee}function _(){const ee=this.resume();this.stack[this.stack.length-1].value=ee}function k(){const ee=this.stack[this.stack.length-1];if(this.data.inReference){const ye=this.data.referenceType||"shortcut";ee.type+="Reference",ee.referenceType=ye,delete ee.url,delete ee.title}else delete ee.identifier,delete ee.label;this.data.referenceType=void 0}function B(){const ee=this.stack[this.stack.length-1];if(this.data.inReference){const ye=this.data.referenceType||"shortcut";ee.type+="Reference",ee.referenceType=ye,delete ee.url,delete ee.title}else delete ee.identifier,delete ee.label;this.data.referenceType=void 0}function A(ee){const ye=this.sliceSerialize(ee),we=this.stack[this.stack.length-2];we.label=function(Ie){return Ie.replace(y8,v8)}(ye),we.identifier=Rn(ye).toLowerCase()}function U(){const ee=this.stack[this.stack.length-1],ye=this.resume(),we=this.stack[this.stack.length-1];if(this.data.inReference=!0,we.type==="link"){const Ie=ee.children;we.children=Ie}else we.alt=ye}function $(){const ee=this.resume();this.stack[this.stack.length-1].url=ee}function X(){const ee=this.resume();this.stack[this.stack.length-1].title=ee}function Y(){this.data.inReference=void 0}function G(){this.data.referenceType="collapsed"}function W(ee){const ye=this.resume(),we=this.stack[this.stack.length-1];we.label=ye,we.identifier=Rn(this.sliceSerialize(ee)).toLowerCase(),this.data.referenceType="full"}function J(ee){this.data.characterReferenceType=ee.type}function V(ee){const ye=this.sliceSerialize(ee),we=this.data.characterReferenceType;let Ie;we?(Ie=My(ye,we==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ie=ch(ye),this.stack[this.stack.length-1].value+=Ie}function Q(ee){this.stack.pop().position.end=Fo(ee.end)}function te(ee){L.call(this,ee),this.stack[this.stack.length-1].url=this.sliceSerialize(ee)}function re(ee){L.call(this,ee),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(ee)}function ne(){return{type:"blockquote",children:[]}}function ie(){return{type:"code",lang:null,meta:null,value:""}}function se(){return{type:"inlineCode",value:""}}function ae(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ge(){return{type:"emphasis",children:[]}}function oe(){return{type:"heading",depth:0,children:[]}}function ue(){return{type:"break"}}function de(){return{type:"html",value:""}}function Se(){return{type:"image",title:null,url:"",alt:null}}function Te(){return{type:"link",title:null,url:"",children:[]}}function Fe(ee){return{type:"list",ordered:ee.type==="listOrdered",start:null,spread:ee._spread,children:[]}}function _e(ee){return{type:"listItem",spread:ee._spread,checked:null,children:[]}}function ke(){return{type:"paragraph",children:[]}}function Ye(){return{type:"strong",children:[]}}function Ve(){return{type:"text",value:""}}function Ke(){return{type:"thematicBreak"}}}(n)(function(o){for(;!By(o););return o}(function(o){const r={constructs:Ty([x8,...(o||{}).extensions||[]]),content:s(DI),defined:[],document:s(RI),flow:s(s8),lazy:{},string:s(a8),text:s(l8)};return r;function s(i){return function(a){return b8(r,i,a)}}}(n).document().write(function(){let o,r=1,s="",i=!0;return function(a,l,c){const d=[];let h,f,m,g,x;for(a=s+(typeof a=="string"?a.toString():new TextDecoder(l||void 0).decode(a)),m=0,s="",i&&(a.charCodeAt(0)===65279&&m++,i=void 0);m<a.length;){if(Yy.lastIndex=m,h=Yy.exec(a),g=h&&h.index!==void 0?h.index:a.length,x=a.charCodeAt(g),!h){s=a.slice(m);break}if(x===10&&m===g&&o)d.push(-3),o=void 0;else switch(o&&(d.push(-5),o=void 0),m<g&&(d.push(a.slice(m,g)),r+=g-m),x){case 0:d.push(65533),r++;break;case 9:for(f=4*Math.ceil(r/4),d.push(-2);r++<f;)d.push(-1);break;case 10:d.push(-4),r=1;break;default:o=!0,r=1}m=g+1}return c&&(o&&d.push(-5),s&&d.push(s),d.push(null)),d}}()(t,e,!0))))}function Fo(t){return{line:t.line,column:t.column,offset:t.offset}}function Xy(t,e){let n=-1;for(;++n<e.length;){const o=e[n];Array.isArray(o)?Xy(t,o):k8(t,o)}}function k8(t,e){let n;for(n in e)if(Ky.call(e,n))switch(n){case"canContainEols":{const o=e[n];o&&t[n].push(...o);break}case"transforms":{const o=e[n];o&&t[n].push(...o);break}case"enter":case"exit":{const o=e[n];o&&Object.assign(t[n],o);break}}}function Jy(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+fi({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+fi({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+fi({start:e.start,end:e.end})+") is still open")}function C8(t){const e=this;e.parser=function(n){return w8(n,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function Zy(t,e){const n=e.referenceType;let o="]";if(n==="collapsed"?o+="[]":n==="full"&&(o+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+o}];const r=t.all(e),s=r[0];s&&s.type==="text"?s.value="["+s.value:r.unshift({type:"text",value:"["});const i=r[r.length-1];return i&&i.type==="text"?i.value+=o:r.push({type:"text",value:o}),r}function Qy(t){const e=t.spread;return e??t.children.length>1}function j8(t){const e=String(t),n=/\r?\n|\r/g;let o=n.exec(e),r=0;const s=[];for(;o;)s.push(ev(e.slice(r,o.index),r>0,!0),o[0]),r=o.index+o[0].length,o=n.exec(e);return s.push(ev(e.slice(r),r>0,!1)),s.join("")}function ev(t,e,n){let o=0,r=t.length;if(e){let s=t.codePointAt(o);for(;s===9||s===32;)o++,s=t.codePointAt(o)}if(n){let s=t.codePointAt(r-1);for(;s===9||s===32;)r--,s=t.codePointAt(r-1)}return r>o?t.slice(o,r):""}const S8={blockquote:function(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)},break:function(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
131
+ `}]},code:function(t,e){const n=e.value?e.value+`
132
+ `:"",o={};e.lang&&(o.className=["language-"+e.lang]);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:n}]};return e.meta&&(r.data={meta:e.meta}),t.patch(e,r),r=t.applyData(e,r),r={type:"element",tagName:"pre",properties:{},children:[r]},t.patch(e,r),r},delete:function(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},emphasis:function(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},footnoteReference:function(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",o=String(e.identifier).toUpperCase(),r=qr(o.toLowerCase()),s=t.footnoteOrder.indexOf(o);let i,a=t.footnoteCounts.get(o);a===void 0?(a=0,t.footnoteOrder.push(o),i=t.footnoteOrder.length):i=s+1,a+=1,t.footnoteCounts.set(o,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};t.patch(e,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return t.patch(e,c),t.applyData(e,c)},heading:function(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},html:function(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}},imageReference:function(t,e){const n=String(e.identifier).toUpperCase(),o=t.definitionById.get(n);if(!o)return Zy(t,e);const r={src:qr(o.url||""),alt:e.alt};o.title!==null&&o.title!==void 0&&(r.title=o.title);const s={type:"element",tagName:"img",properties:r,children:[]};return t.patch(e,s),t.applyData(e,s)},image:function(t,e){const n={src:qr(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const o={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,o),t.applyData(e,o)},inlineCode:function(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const o={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,o),t.applyData(e,o)},linkReference:function(t,e){const n=String(e.identifier).toUpperCase(),o=t.definitionById.get(n);if(!o)return Zy(t,e);const r={href:qr(o.url||"")};o.title!==null&&o.title!==void 0&&(r.title=o.title);const s={type:"element",tagName:"a",properties:r,children:t.all(e)};return t.patch(e,s),t.applyData(e,s)},link:function(t,e){const n={href:qr(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const o={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,o),t.applyData(e,o)},listItem:function(t,e,n){const o=t.all(e),r=n?function(d){let h=!1;if(d.type==="list"){h=d.spread||!1;const f=d.children;let m=-1;for(;!h&&++m<f.length;)h=Qy(f[m])}return h}(n):Qy(e),s={},i=[];if(typeof e.checked=="boolean"){const d=o[0];let h;d&&d.type==="element"&&d.tagName==="p"?h=d:(h={type:"element",tagName:"p",properties:{},children:[]},o.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<o.length;){const d=o[a];(r||a!==0||d.type!=="element"||d.tagName!=="p")&&i.push({type:"text",value:`
133
+ `}),d.type!=="element"||d.tagName!=="p"||r?i.push(d):i.push(...d.children)}const l=o[o.length-1];l&&(r||l.type!=="element"||l.tagName!=="p")&&i.push({type:"text",value:`
134
+ `});const c={type:"element",tagName:"li",properties:s,children:i};return t.patch(e,c),t.applyData(e,c)},list:function(t,e){const n={},o=t.all(e);let r=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++r<o.length;){const i=o[r];if(i.type==="element"&&i.tagName==="li"&&i.properties&&Array.isArray(i.properties.className)&&i.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:e.ordered?"ol":"ul",properties:n,children:t.wrap(o,!0)};return t.patch(e,s),t.applyData(e,s)},paragraph:function(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},root:function(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)},strong:function(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},table:function(t,e){const n=t.all(e),o=n.shift(),r=[];if(o){const i={type:"element",tagName:"thead",properties:{},children:t.wrap([o],!0)};t.patch(e.children[0],i),r.push(i)}if(n.length>0){const i={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},a=nh(e.children[1]),l=yy(e.children[e.children.length-1]);a&&l&&(i.position={start:a,end:l}),r.push(i)}const s={type:"element",tagName:"table",properties:{},children:t.wrap(r,!0)};return t.patch(e,s),t.applyData(e,s)},tableCell:function(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},tableRow:function(t,e,n){const o=n?n.children:void 0,r=(o?o.indexOf(e):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,i=s?s.length:e.children.length;let a=-1;const l=[];for(;++a<i;){const d=e.children[a],h={},f=s?s[a]:void 0;f&&(h.align=f);let m={type:"element",tagName:r,properties:h,children:[]};d&&(m.children=t.all(d),t.patch(d,m),m=t.applyData(d,m)),l.push(m)}const c={type:"element",tagName:"tr",properties:{},children:t.wrap(l,!0)};return t.patch(e,c),t.applyData(e,c)},text:function(t,e){const n={type:"text",value:j8(String(e.value))};return t.patch(e,n),t.applyData(e,n)},thematicBreak:function(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)},toml:Tl,yaml:Tl,definition:Tl,footnoteDefinition:Tl};function Tl(){}const tv=typeof self=="object"?self:globalThis,nv=t=>((e,n)=>{const o=(s,i)=>(e.set(i,s),s),r=s=>{if(e.has(s))return e.get(s);const[i,a]=n[s];switch(i){case 0:case-1:return o(a,s);case 1:{const l=o([],s);for(const c of a)l.push(r(c));return l}case 2:{const l=o({},s);for(const[c,d]of a)l[r(c)]=r(d);return l}case 3:return o(new Date(a),s);case 4:{const{source:l,flags:c}=a;return o(new RegExp(l,c),s)}case 5:{const l=o(new Map,s);for(const[c,d]of a)l.set(r(c),r(d));return l}case 6:{const l=o(new Set,s);for(const c of a)l.add(r(c));return l}case 7:{const{name:l,message:c}=a;return o(new tv[l](c),s)}case 8:return o(BigInt(a),s);case"BigInt":return o(Object(BigInt(a)),s);case"ArrayBuffer":return o(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:l}=new Uint8Array(a);return o(new DataView(l),a)}}return o(new tv[i](a),s)};return r})(new Map,t)(0),Yr="",{toString:N8}={},{keys:E8}=Object,bi=t=>{const e=typeof t;if(e!=="object"||!t)return[0,e];const n=N8.call(t).slice(8,-1);switch(n){case"Array":return[1,Yr];case"Object":return[2,Yr];case"Date":return[3,Yr];case"RegExp":return[4,Yr];case"Map":return[5,Yr];case"Set":return[6,Yr];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Ml=([t,e])=>t===0&&(e==="function"||e==="symbol"),ov=(t,{json:e,lossy:n}={})=>{const o=[];return((r,s,i,a)=>{const l=(d,h)=>{const f=a.push(d)-1;return i.set(h,f),f},c=d=>{if(i.has(d))return i.get(d);let[h,f]=bi(d);switch(h){case 0:{let g=d;switch(f){case"bigint":h=8,g=d.toString();break;case"function":case"symbol":if(r)throw new TypeError("unable to serialize "+f);g=null;break;case"undefined":return l([-1],d)}return l([h,g],d)}case 1:{if(f){let p=d;return f==="DataView"?p=new Uint8Array(d.buffer):f==="ArrayBuffer"&&(p=new Uint8Array(d)),l([f,[...p]],d)}const g=[],x=l([h,g],d);for(const p of d)g.push(c(p));return x}case 2:{if(f)switch(f){case"BigInt":return l([f,d.toString()],d);case"Boolean":case"Number":case"String":return l([f,d.valueOf()],d)}if(s&&"toJSON"in d)return c(d.toJSON());const g=[],x=l([h,g],d);for(const p of E8(d))!r&&Ml(bi(d[p]))||g.push([c(p),c(d[p])]);return x}case 3:return l([h,d.toISOString()],d);case 4:{const{source:g,flags:x}=d;return l([h,{source:g,flags:x}],d)}case 5:{const g=[],x=l([h,g],d);for(const[p,b]of d)(r||!Ml(bi(p))&&!Ml(bi(b)))&&g.push([c(p),c(b)]);return x}case 6:{const g=[],x=l([h,g],d);for(const p of d)!r&&Ml(bi(p))||g.push(c(p));return x}}const{message:m}=d;return l([h,{name:f,message:m}],d)};return c})(!(e||n),!!e,new Map,o)(t),o},Ol=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?nv(ov(t,e)):structuredClone(t):(t,e)=>nv(ov(t,e));function _8(t,e){const n=[{type:"text",value:"\u21A9"}];return e>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),n}function I8(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}const Dl=function(t){if(t==null)return A8;if(typeof t=="function")return Rl(t);if(typeof t=="object")return Array.isArray(t)?function(e){const n=[];let o=-1;for(;++o<e.length;)n[o]=Dl(e[o]);return Rl(r);function r(...s){let i=-1;for(;++i<n.length;)if(n[i].apply(this,s))return!0;return!1}}(t):function(e){const n=e;return Rl(o);function o(r){const s=r;let i;for(i in e)if(s[i]!==n[i])return!1;return!0}}(t);if(typeof t=="string")return function(e){return Rl(n);function n(o){return o&&o.type===e}}(t);throw new Error("Expected function, string, or object as test")};function Rl(t){return function(e,n,o){return!!(function(r){return r!==null&&typeof r=="object"&&"type"in r}(e)&&t.call(this,e,typeof n=="number"?n:void 0,o||void 0))}}function A8(){return!0}const rv=[],T8=!0,ph=!1;function sv(t,e,n,o){let r;typeof e=="function"&&typeof n!="function"?(o=n,n=e):r=e;const s=Dl(r),i=o?-1:1;(function a(l,c,d){const h=l&&typeof l=="object"?l:{};if(typeof h.type=="string"){const m=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(f,"name",{value:"node ("+l.type+(m?"<"+m+">":"")+")"})}return f;function f(){let m,g,x,p=rv;if((!e||s(l,c,d[d.length-1]||void 0))&&(p=function(b){return Array.isArray(b)?b:typeof b=="number"?[T8,b]:b==null?rv:[b]}(n(l,d)),p[0]===ph))return p;if("children"in l&&l.children){const b=l;if(b.children&&p[0]!=="skip")for(g=(o?b.children.length:-1)+i,x=d.concat(b);g>-1&&g<b.children.length;){const y=b.children[g];if(m=a(y,g,x)(),m[0]===ph)return m;g=typeof m[1]=="number"?m[1]:g+i}}return p}})(t,void 0,[])()}function gh(t,e,n,o){let r,s,i;typeof e=="function"&&typeof n!="function"?(s=void 0,i=e,r=n):(s=e,i=n,r=o),sv(t,s,function(a,l){const c=l[l.length-1],d=c?c.children.indexOf(a):void 0;return i(a,d,c)},r)}const xh={}.hasOwnProperty,M8={};function O8(t,e){t.position&&(e.position=function(n){const o=nh(n),r=yy(n);if(o&&r)return{start:o,end:r}}(t))}function D8(t,e){let n=e;if(t&&t.data){const o=t.data.hName,r=t.data.hChildren,s=t.data.hProperties;typeof o=="string"&&(n.type==="element"?n.tagName=o:n={type:"element",tagName:o,properties:{},children:"children"in n?n.children:[n]}),n.type==="element"&&s&&Object.assign(n.properties,Ol(s)),"children"in n&&n.children&&r!=null&&(n.children=r)}return n}function R8(t,e){const n=e.data||{},o=!("value"in e)||xh.call(n,"hProperties")||xh.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:t.all(e)}:{type:"text",value:e.value};return t.patch(e,o),t.applyData(e,o)}function P8(t,e){const n=[];let o=-1;for(e&&n.push({type:"text",value:`
135
+ `});++o<t.length;)o&&n.push({type:"text",value:`
136
+ `}),n.push(t[o]);return e&&t.length>0&&n.push({type:"text",value:`
137
+ `}),n}function iv(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function av(t,e){const n=function(i,a){const l=a||M8,c=new Map,d=new Map,h=new Map,f={...S8,...l.handlers},m={all:function(g){const x=[];if("children"in g){const p=g.children;let b=-1;for(;++b<p.length;){const y=m.one(p[b],g);if(y){if(b&&p[b-1].type==="break"&&(Array.isArray(y)||y.type!=="text"||(y.value=iv(y.value)),!Array.isArray(y)&&y.type==="element")){const v=y.children[0];v&&v.type==="text"&&(v.value=iv(v.value))}Array.isArray(y)?x.push(...y):x.push(y)}}}return x},applyData:D8,definitionById:c,footnoteById:d,footnoteCounts:h,footnoteOrder:[],handlers:f,one:function(g,x){const p=g.type,b=m.handlers[p];if(xh.call(m.handlers,p)&&b)return b(m,g,x);if(m.options.passThrough&&m.options.passThrough.includes(p)){if("children"in g){const{children:y,...v}=g,w=Ol(v);return w.children=m.all(g),w}return Ol(g)}return(m.options.unknownHandler||R8)(m,g,x)},options:l,patch:O8,wrap:P8};return gh(i,function(g){if(g.type==="definition"||g.type==="footnoteDefinition"){const x=g.type==="definition"?c:d,p=String(g.identifier).toUpperCase();x.has(p)||x.set(p,g)}}),m}(t,e),o=n.one(t,void 0),r=function(i){const a=typeof i.options.clobberPrefix=="string"?i.options.clobberPrefix:"user-content-",l=i.options.footnoteBackContent||_8,c=i.options.footnoteBackLabel||I8,d=i.options.footnoteLabel||"Footnotes",h=i.options.footnoteLabelTagName||"h2",f=i.options.footnoteLabelProperties||{className:["sr-only"]},m=[];let g=-1;for(;++g<i.footnoteOrder.length;){const x=i.footnoteById.get(i.footnoteOrder[g]);if(!x)continue;const p=i.all(x),b=String(x.identifier).toUpperCase(),y=qr(b.toLowerCase());let v=0;const w=[],S=i.footnoteCounts.get(b);for(;S!==void 0&&++v<=S;){w.length>0&&w.push({type:"text",value:" "});let j=typeof l=="string"?l:l(g,v);typeof j=="string"&&(j={type:"text",value:j}),w.push({type:"element",tagName:"a",properties:{href:"#"+a+"fnref-"+y+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof c=="string"?c:c(g,v),className:["data-footnote-backref"]},children:Array.isArray(j)?j:[j]})}const C=p[p.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const j=C.children[C.children.length-1];j&&j.type==="text"?j.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...w)}else p.push(...w);const N={type:"element",tagName:"li",properties:{id:a+"fn-"+y},children:i.wrap(p,!0)};i.patch(x,N),m.push(N)}if(m.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:h,properties:{...Ol(f),id:"footnote-label"},children:[{type:"text",value:d}]},{type:"text",value:`
138
+ `},{type:"element",tagName:"ol",properties:{},children:i.wrap(m,!0)},{type:"text",value:`
139
+ `}]}}(n),s=Array.isArray(o)?{type:"root",children:o}:o||{type:"root",children:[]};return r&&s.children.push({type:"text",value:`
140
+ `},r),s}function L8(t,e){return t&&"run"in t?async function(n,o){const r=av(n,{file:o,...e});await t.run(r,o)}:function(n,o){return av(n,{file:o,...t||e})}}function lv(t){if(t)throw t}var bh,cv,F8=function(){if(cv)return bh;cv=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=function(l){return typeof Array.isArray=="function"?Array.isArray(l):e.call(l)==="[object Array]"},s=function(l){if(!l||e.call(l)!=="[object Object]")return!1;var c,d=t.call(l,"constructor"),h=l.constructor&&l.constructor.prototype&&t.call(l.constructor.prototype,"isPrototypeOf");if(l.constructor&&!d&&!h)return!1;for(c in l);return c===void 0||t.call(l,c)},i=function(l,c){n&&c.name==="__proto__"?n(l,c.name,{enumerable:!0,configurable:!0,value:c.newValue,writable:!0}):l[c.name]=c.newValue},a=function(l,c){if(c==="__proto__"){if(!t.call(l,c))return;if(o)return o(l,c).value}return l[c]};return bh=function l(){var c,d,h,f,m,g,x=arguments[0],p=1,b=arguments.length,y=!1;for(typeof x=="boolean"&&(y=x,x=arguments[1]||{},p=2),(x==null||typeof x!="object"&&typeof x!="function")&&(x={});p<b;++p)if((c=arguments[p])!=null)for(d in c)h=a(x,d),x!==(f=a(c,d))&&(y&&f&&(s(f)||(m=r(f)))?(m?(m=!1,g=h&&r(h)?h:[]):g=h&&s(h)?h:{},i(x,{name:d,newValue:l(y,g,f)})):f!==void 0&&i(x,{name:d,newValue:f}));return x},bh}();const yh=PC(F8);function vh(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return!(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null||Symbol.toStringTag in t||Symbol.iterator in t)}function z8(){const t=[],e={run:function(...n){let o=-1;const r=n.pop();if(typeof r!="function")throw new TypeError("Expected function as last argument, not "+r);(function s(i,...a){const l=t[++o];let c=-1;if(i)r(i);else{for(;++c<n.length;)a[c]!==null&&a[c]!==void 0||(a[c]=n[c]);n=a,l?function(d,h){let f;return m;function m(...p){const b=d.length>p.length;let y;b&&p.push(g);try{y=d.apply(this,p)}catch(v){if(b&&f)throw v;return g(v)}b||(y&&y.then&&typeof y.then=="function"?y.then(x,g):y instanceof Error?g(y):x(y))}function g(p,...b){f||(f=!0,h(p,...b))}function x(p){g(null,p)}}(l,s)(...a):r(null,...a)}})(null,...n)},use:function(n){if(typeof n!="function")throw new TypeError("Expected `middelware` to be a function, not "+n);return t.push(n),e}};return e}const Gn={basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');yi(t);let n,o=0,r=-1,s=t.length;if(e===void 0||e.length===0||e.length>t.length){for(;s--;)if(t.codePointAt(s)===47){if(n){o=s+1;break}}else r<0&&(n=!0,r=s+1);return r<0?"":t.slice(o,r)}if(e===t)return"";let i=-1,a=e.length-1;for(;s--;)if(t.codePointAt(s)===47){if(n){o=s+1;break}}else i<0&&(n=!0,i=s+1),a>-1&&(t.codePointAt(s)===e.codePointAt(a--)?a<0&&(r=s):(a=-1,r=i));return o===r?r=i:r<0&&(r=t.length),t.slice(o,r)},dirname:function(t){if(yi(t),t.length===0)return".";let e,n=-1,o=t.length;for(;--o;)if(t.codePointAt(o)===47){if(e){n=o;break}}else e||(e=!0);return n<0?t.codePointAt(0)===47?"/":".":n===1&&t.codePointAt(0)===47?"//":t.slice(0,n)},extname:function(t){yi(t);let e,n=t.length,o=-1,r=0,s=-1,i=0;for(;n--;){const a=t.codePointAt(n);if(a!==47)o<0&&(e=!0,o=n+1),a===46?s<0?s=n:i!==1&&(i=1):s>-1&&(i=-1);else if(e){r=n+1;break}}return s<0||o<0||i===0||i===1&&s===o-1&&s===r+1?"":t.slice(s,o)},join:function(...t){let e,n=-1;for(;++n<t.length;)yi(t[n]),t[n]&&(e=e===void 0?t[n]:e+"/"+t[n]);return e===void 0?".":function(o){yi(o);const r=o.codePointAt(0)===47;let s=function(i,a){let l,c,d="",h=0,f=-1,m=0,g=-1;for(;++g<=i.length;){if(g<i.length)l=i.codePointAt(g);else{if(l===47)break;l=47}if(l===47){if(!(f===g-1||m===1))if(f!==g-1&&m===2){if(d.length<2||h!==2||d.codePointAt(d.length-1)!==46||d.codePointAt(d.length-2)!==46){if(d.length>2){if(c=d.lastIndexOf("/"),c!==d.length-1){c<0?(d="",h=0):(d=d.slice(0,c),h=d.length-1-d.lastIndexOf("/")),f=g,m=0;continue}}else if(d.length>0){d="",h=0,f=g,m=0;continue}}a&&(d=d.length>0?d+"/..":"..",h=2)}else d.length>0?d+="/"+i.slice(f+1,g):d=i.slice(f+1,g),h=g-f-1;f=g,m=0}else l===46&&m>-1?m++:m=-1}return d}(o,!r);return s.length!==0||r||(s="."),s.length>0&&o.codePointAt(o.length-1)===47&&(s+="/"),r?"/"+s:s}(e)},sep:"/"};function yi(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const B8={cwd:function(){return"/"}};function wh(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function U8(t){if(typeof t=="string")t=new URL(t);else if(!wh(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){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 r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const n=e.pathname;let o=-1;for(;++o<n.length;)if(n.codePointAt(o)===37&&n.codePointAt(o+1)===50){const r=n.codePointAt(o+2);if(r===70||r===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(n)}(t)}const kh=["history","path","basename","stem","extname","dirname"];class dv{constructor(e){let n;n=e?wh(e)?{path:e}:typeof e=="string"||function(s){return!!(s&&typeof s=="object"&&"byteLength"in s&&"byteOffset"in s)}(e)?{value:e}:e:{},this.cwd="cwd"in n?"":B8.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let o,r=-1;for(;++r<kh.length;){const s=kh[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}for(o in n)kh.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Gn.basename(this.path):void 0}set basename(e){jh(e,"basename"),Ch(e,"basename"),this.path=Gn.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Gn.dirname(this.path):void 0}set dirname(e){uv(this.basename,"dirname"),this.path=Gn.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Gn.extname(this.path):void 0}set extname(e){if(Ch(e,"extname"),uv(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Gn.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){wh(e)&&(e=U8(e)),jh(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Gn.basename(this.path,this.extname):void 0}set stem(e){jh(e,"stem"),Ch(e,"stem"),this.path=Gn.join(this.dirname||"",e+(this.extname||""))}fail(e,n,o){const r=this.message(e,n,o);throw r.fatal=!0,r}info(e,n,o){const r=this.message(e,n,o);return r.fatal=void 0,r}message(e,n,o){const r=new Vt(e,n,o);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function Ch(t,e){if(t&&t.includes(Gn.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Gn.sep+"`")}function jh(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function uv(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}const $8=function(t){const e=this.constructor.prototype,n=e[t],o=function(){return n.apply(o,arguments)};return Object.setPrototypeOf(o,e),o},V8={}.hasOwnProperty;class Sh extends $8{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=z8()}copy(){const e=new Sh;let n=-1;for(;++n<this.attachers.length;){const o=this.attachers[n];e.use(...o)}return e.data(yh(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(_h("data",this.frozen),this.namespace[e]=n,this):V8.call(this.namespace,e)&&this.namespace[e]||void 0:e?(_h("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[n,...o]=this.attachers[this.freezeIndex];if(o[0]===!1)continue;o[0]===!0&&(o[0]=void 0);const r=n.call(e,...o);typeof r=="function"&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=Pl(e),o=this.parser||this.Parser;return Nh("parse",o),o(String(n),n)}process(e,n){const o=this;return this.freeze(),Nh("process",this.parser||this.Parser),Eh("process",this.compiler||this.Compiler),n?r(void 0,n):new Promise(r);function r(s,i){const a=Pl(e),l=o.parse(a);function c(d,h){d||!h?i(d):s?s(h):n(void 0,h)}o.run(l,a,function(d,h,f){if(d||!h||!f)return c(d);const m=h,g=o.stringify(m,f);var x;typeof(x=g)=="string"||function(p){return!!(p&&typeof p=="object"&&"byteLength"in p&&"byteOffset"in p)}(x)?f.value=g:f.result=g,c(d,f)})}}processSync(e){let n,o=!1;return this.freeze(),Nh("processSync",this.parser||this.Parser),Eh("processSync",this.compiler||this.Compiler),this.process(e,function(r,s){o=!0,lv(r),n=s}),fv("processSync","process",o),n}run(e,n,o){hv(e),this.freeze();const r=this.transformers;return o||typeof n!="function"||(o=n,n=void 0),o?s(void 0,o):new Promise(s);function s(i,a){const l=Pl(n);r.run(e,l,function(c,d,h){const f=d||e;c?a(c):i?i(f):o(void 0,f,h)})}}runSync(e,n){let o,r=!1;return this.run(e,n,function(s,i){lv(s),o=i,r=!0}),fv("runSync","run",r),o}stringify(e,n){this.freeze();const o=Pl(n),r=this.compiler||this.Compiler;return Eh("stringify",r),hv(e),r(e,o)}use(e,...n){const o=this.attachers,r=this.namespace;if(_h("use",this.frozen),e!=null)if(typeof e=="function")l(e,n);else{if(typeof e!="object")throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?a(e):i(e)}return this;function s(c){if(typeof c=="function")l(c,[]);else{if(typeof c!="object")throw new TypeError("Expected usable value, not `"+c+"`");if(Array.isArray(c)){const[d,...h]=c;l(d,h)}else i(c)}}function i(c){if(!("plugins"in c)&&!("settings"in c))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");a(c.plugins),c.settings&&(r.settings=yh(!0,r.settings,c.settings))}function a(c){let d=-1;if(c!=null){if(!Array.isArray(c))throw new TypeError("Expected a list of plugins, not `"+c+"`");for(;++d<c.length;)s(c[d])}}function l(c,d){let h=-1,f=-1;for(;++h<o.length;)if(o[h][0]===c){f=h;break}if(f===-1)o.push([c,...d]);else if(d.length>0){let[m,...g]=d;const x=o[f][1];vh(x)&&vh(m)&&(m=yh(!0,x,m)),o[f]=[c,m,...g]}}}}const H8=new Sh().freeze();function Nh(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function Eh(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function _h(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function hv(t){if(!vh(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function fv(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Pl(t){return function(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}(t)?t:new dv(t)}const mv=[],pv={allowDangerousHtml:!0},W8=/^(https?|ircs?|mailto|xmpp)$/i,q8=[{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 G8(t){const e=function(o){const r=o.rehypePlugins||mv,s=o.remarkPlugins||mv,i=o.remarkRehypeOptions?{...o.remarkRehypeOptions,...pv}:pv;return H8().use(C8).use(s).use(L8,i).use(r)}(t),n=function(o){const r=o.children||"",s=new dv;return typeof r=="string"&&(s.value=r),s}(t);return function(o,r){const s=r.allowedElements,i=r.allowElement,a=r.components,l=r.disallowedElements,c=r.skipHtml,d=r.unwrapDisallowed,h=r.urlTransform||Y8;for(const m of q8)Object.hasOwn(r,m.from)&&(m.from,m.to&&m.to,m.id,void 0);return r.className&&(o={type:"element",tagName:"div",properties:{className:r.className},children:o.type==="root"?o.children:[o]}),gh(o,f),SI(o,{Fragment:u.Fragment,components:a,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0});function f(m,g,x){if(m.type==="raw"&&x&&typeof g=="number")return c?x.children.splice(g,1):x.children[g]={type:"text",value:m.value},g;if(m.type==="element"){let p;for(p in ah)if(Object.hasOwn(ah,p)&&Object.hasOwn(m.properties,p)){const b=m.properties[p],y=ah[p];(y===null||y.includes(m.tagName))&&(m.properties[p]=h(String(b||""),p,m))}}if(m.type==="element"){let p=s?!s.includes(m.tagName):!!l&&l.includes(m.tagName);if(!p&&i&&typeof g=="number"&&(p=!i(m,g,x)),p&&x&&typeof g=="number")return d&&m.children?x.children.splice(g,1,...m.children):x.children.splice(g,1),g}}}(e.runSync(e.parse(n),n),t)}function Y8(t){const e=t.indexOf(":"),n=t.indexOf("?"),o=t.indexOf("#"),r=t.indexOf("/");return e===-1||r!==-1&&e>r||n!==-1&&e>n||o!==-1&&e>o||W8.test(t.slice(0,e))?t:""}function gv(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let o=0,r=n.indexOf(e);for(;r!==-1;)o++,r=n.indexOf(e,r+e.length);return o}function K8(t,e,n){const o=Dl((n||{}).ignore||[]),r=function(a){const l=[];if(!Array.isArray(a))throw new TypeError("Expected find and replace tuple or list of tuples");const c=!a[0]||Array.isArray(a[0])?a:[a];let d=-1;for(;++d<c.length;){const h=c[d];l.push([X8(h[0]),J8(h[1])])}return l}(e);let s=-1;for(;++s<r.length;)sv(t,"text",i);function i(a,l){let c,d=-1;for(;++d<l.length;){const h=l[d],f=c?c.children:void 0;if(o(h,f?f.indexOf(h):void 0,c))return;c=h}if(c)return function(h,f){const m=f[f.length-1],g=r[s][0],x=r[s][1];let p=0;const b=m.children.indexOf(h);let y=!1,v=[];g.lastIndex=0;let w=g.exec(h.value);for(;w;){const S=w.index,C={index:w.index,input:w.input,stack:[...f,h]};let N=x(...w,C);if(typeof N=="string"&&(N=N.length>0?{type:"text",value:N}:void 0),N===!1?g.lastIndex=S+1:(p!==S&&v.push({type:"text",value:h.value.slice(p,S)}),Array.isArray(N)?v.push(...N):N&&v.push(N),p=S+w[0].length,y=!0),!g.global)break;w=g.exec(h.value)}return y?(p<h.value.length&&v.push({type:"text",value:h.value.slice(p)}),m.children.splice(b,1,...v)):v=[h],b+v.length}(a,l)}}function X8(t){return typeof t=="string"?new RegExp(function(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(t),"g"):t}function J8(t){return typeof t=="function"?t:function(){return t}}const Ih="phrasing",Ah=["autolink","link","image","label"];function Z8(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function Th(t){this.config.enter.autolinkProtocol.call(this,t)}function Q8(t){this.config.exit.autolinkProtocol.call(this,t)}function eA(t){this.config.exit.data.call(this,t);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function tA(t){this.config.exit.autolinkEmail.call(this,t)}function nA(t){this.exit(t)}function oA(t){K8(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,rA],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),sA]],{ignore:["link","linkReference"]})}function rA(t,e,n,o,r){let s="";if(!xv(r)||(/^w/i.test(e)&&(n=e+n,e="",s="http://"),!function(l){const c=l.split(".");return!(c.length<2||c[c.length-1]&&(/_/.test(c[c.length-1])||!/[a-zA-Z\d]/.test(c[c.length-1]))||c[c.length-2]&&(/_/.test(c[c.length-2])||!/[a-zA-Z\d]/.test(c[c.length-2])))}(n)))return!1;const i=function(l){const c=/[!"&'),.:;<>?\]}]+$/.exec(l);if(!c)return[l,void 0];l=l.slice(0,c.index);let d=c[0],h=d.indexOf(")");const f=gv(l,"(");let m=gv(l,")");for(;h!==-1&&f>m;)l+=d.slice(0,h+1),d=d.slice(h+1),h=d.indexOf(")"),m++;return[l,d]}(n+o);if(!i[0])return!1;const a={type:"link",title:null,url:s+e+i[0],children:[{type:"text",value:e+i[0]}]};return i[1]?[a,{type:"text",value:i[1]}]:a}function sA(t,e,n,o){return!(!xv(o,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function xv(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||ur(n)||_l(n))&&(!e||n!==47)}function iA(){this.buffer()}function aA(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function lA(){this.buffer()}function cA(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function dA(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Rn(this.sliceSerialize(t)).toLowerCase(),n.label=e}function uA(t){this.exit(t)}function hA(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Rn(this.sliceSerialize(t)).toLowerCase(),n.label=e}function fA(t){this.exit(t)}function bv(t,e,n,o){const r=n.createTracker(o);let s=r.move("[^");const i=n.enter("footnoteReference"),a=n.enter("reference");return s+=r.move(n.safe(n.associationId(t),{after:"]",before:s})),a(),i(),s+=r.move("]"),s}function mA(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:function(n,o,r,s){const i=r.createTracker(s);let a=i.move("[^");const l=r.enter("footnoteDefinition"),c=r.enter("label");return a+=i.move(r.safe(r.associationId(n),{before:a,after:"]"})),c(),a+=i.move("]:"),n.children&&n.children.length>0&&(i.shift(4),a+=i.move((e?`
141
+ `:" ")+r.indentLines(r.containerFlow(n,i.current()),e?yv:pA))),l(),a},footnoteReference:bv},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function pA(t,e,n){return e===0?t:yv(t,e,n)}function yv(t,e,n){return(n?"":" ")+t}bv.peek=function(){return"["};const gA=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function xA(t){this.enter({type:"delete",children:[]},t)}function bA(t){this.exit(t)}function vv(t,e,n,o){const r=n.createTracker(o),s=n.enter("strikethrough");let i=r.move("~~");return i+=n.containerPhrasing(t,{...r.current(),before:i,after:"~"}),i+=r.move("~~"),s(),i}function yA(t){return t.length}function vA(t){return t==null?"":String(t)}function wv(t){const e=typeof t=="string"?t.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}function wA(t,e,n){return">"+(n?"":" ")+t}function kA(t,e){return kv(t,e.inConstruct,!0)&&!kv(t,e.notInConstruct,!1)}function kv(t,e,n){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return n;let o=-1;for(;++o<e.length;)if(t.includes(e[o]))return!0;return!1}function Cv(t,e,n,o){let r=-1;for(;++r<n.unsafe.length;)if(n.unsafe[r].character===`
142
+ `&&kA(n.stack,n.unsafe[r]))return/[ \t]/.test(o.before)?"":" ";return`\\
143
+ `}function CA(t,e,n){return(n?"":" ")+t}function Mh(t){const e=t.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function vi(t){return"&#x"+t.toString(16).toUpperCase()+";"}function Ll(t,e,n){const o=Gr(t),r=Gr(e);return o===void 0?r===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:o===1?r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function jv(t,e,n,o){const r=function(g){const x=g.options.emphasis||"*";if(x!=="*"&&x!=="_")throw new Error("Cannot serialize emphasis with `"+x+"` for `options.emphasis`, expected `*`, or `_`");return x}(n),s=n.enter("emphasis"),i=n.createTracker(o),a=i.move(r);let l=i.move(n.containerPhrasing(t,{after:r,before:a,...i.current()}));const c=l.charCodeAt(0),d=Ll(o.before.charCodeAt(o.before.length-1),c,r);d.inside&&(l=vi(c)+l.slice(1));const h=l.charCodeAt(l.length-1),f=Ll(o.after.charCodeAt(0),h,r);f.inside&&(l=l.slice(0,-1)+vi(h));const m=i.move(r);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},a+l+m}function Sv(t){return t.value||""}function Nv(t,e,n,o){const r=Mh(n),s=r==='"'?"Quote":"Apostrophe",i=n.enter("image");let a=n.enter("label");const l=n.createTracker(o);let c=l.move("![");return c+=l.move(n.safe(t.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),a(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(t.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(t.url,{before:c,after:t.title?" ":")",...l.current()}))),a(),t.title&&(a=n.enter(`title${s}`),c+=l.move(" "+r),c+=l.move(n.safe(t.title,{before:c,after:r,...l.current()})),c+=l.move(r),a()),c+=l.move(")"),i(),c}function Ev(t,e,n,o){const r=t.referenceType,s=n.enter("imageReference");let i=n.enter("label");const a=n.createTracker(o);let l=a.move("![");const c=n.safe(t.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const h=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return i(),n.stack=d,s(),r!=="full"&&c&&c===h?r==="shortcut"?l=l.slice(0,-1):l+=a.move("]"):l+=a.move(h+"]"),l}function _v(t,e,n){let o=t.value||"",r="`",s=-1;for(;new RegExp("(^|[^`])"+r+"([^`]|$)").test(o);)r+="`";for(/[^ \r\n]/.test(o)&&(/^[ \r\n]/.test(o)&&/[ \r\n]$/.test(o)||/^`|`$/.test(o))&&(o=" "+o+" ");++s<n.unsafe.length;){const i=n.unsafe[s],a=n.compilePattern(i);let l;if(i.atBreak)for(;l=a.exec(o);){let c=l.index;o.charCodeAt(c)===10&&o.charCodeAt(c-1)===13&&c--,o=o.slice(0,c)+" "+o.slice(l.index+1)}}return r+o+r}function Iv(t,e){const n=lh(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}function Av(t,e,n,o){const r=Mh(n),s=r==='"'?"Quote":"Apostrophe",i=n.createTracker(o);let a,l;if(Iv(t,n)){const d=n.stack;n.stack=[],a=n.enter("autolink");let h=i.move("<");return h+=i.move(n.containerPhrasing(t,{before:h,after:">",...i.current()})),h+=i.move(">"),a(),n.stack=d,h}a=n.enter("link"),l=n.enter("label");let c=i.move("[");return c+=i.move(n.containerPhrasing(t,{before:c,after:"](",...i.current()})),c+=i.move("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),c+=i.move("<"),c+=i.move(n.safe(t.url,{before:c,after:">",...i.current()})),c+=i.move(">")):(l=n.enter("destinationRaw"),c+=i.move(n.safe(t.url,{before:c,after:t.title?" ":")",...i.current()}))),l(),t.title&&(l=n.enter(`title${s}`),c+=i.move(" "+r),c+=i.move(n.safe(t.title,{before:c,after:r,...i.current()})),c+=i.move(r),l()),c+=i.move(")"),a(),c}function Tv(t,e,n,o){const r=t.referenceType,s=n.enter("linkReference");let i=n.enter("label");const a=n.createTracker(o);let l=a.move("[");const c=n.containerPhrasing(t,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const h=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return i(),n.stack=d,s(),r!=="full"&&c&&c===h?r==="shortcut"?l=l.slice(0,-1):l+=a.move("]"):l+=a.move(h+"]"),l}function Oh(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Mv(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}vv.peek=function(){return"~"},jv.peek=function(t,e,n){return n.options.emphasis||"*"},Sv.peek=function(){return"<"},Nv.peek=function(){return"!"},Ev.peek=function(){return"!"},_v.peek=function(){return"`"},Av.peek=function(t,e,n){return Iv(t,n)?"<":"["},Tv.peek=function(){return"["};const jA=Dl(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Ov(t,e,n,o){const r=function(g){const x=g.options.strong||"*";if(x!=="*"&&x!=="_")throw new Error("Cannot serialize strong with `"+x+"` for `options.strong`, expected `*`, or `_`");return x}(n),s=n.enter("strong"),i=n.createTracker(o),a=i.move(r+r);let l=i.move(n.containerPhrasing(t,{after:r,before:a,...i.current()}));const c=l.charCodeAt(0),d=Ll(o.before.charCodeAt(o.before.length-1),c,r);d.inside&&(l=vi(c)+l.slice(1));const h=l.charCodeAt(l.length-1),f=Ll(o.after.charCodeAt(0),h,r);f.inside&&(l=l.slice(0,-1)+vi(h));const m=i.move(r+r);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},a+l+m}Ov.peek=function(t,e,n){return n.options.strong||"*"};const Dv={blockquote:function(t,e,n,o){const r=n.enter("blockquote"),s=n.createTracker(o);s.move("> "),s.shift(2);const i=n.indentLines(n.containerFlow(t,s.current()),wA);return r(),i},break:Cv,code:function(t,e,n,o){const r=function(h){const f=h.options.fence||"`";if(f!=="`"&&f!=="~")throw new Error("Cannot serialize code with `"+f+"` for `options.fence`, expected `` ` `` or `~`");return f}(n),s=t.value||"",i=r==="`"?"GraveAccent":"Tilde";if(function(h,f){return!!(f.options.fences===!1&&h.value&&!h.lang&&/[^ \r\n]/.test(h.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(h.value))}(t,n)){const h=n.enter("codeIndented"),f=n.indentLines(s,CA);return h(),f}const a=n.createTracker(o),l=r.repeat(Math.max(function(h,f){const m=String(h);let g=m.indexOf(f),x=g,p=0,b=0;if(typeof f!="string")throw new TypeError("Expected substring");for(;g!==-1;)g===x?++p>b&&(b=p):p=1,x=g+f.length,g=m.indexOf(f,x);return b}(s,r)+1,3)),c=n.enter("codeFenced");let d=a.move(l);if(t.lang){const h=n.enter(`codeFencedLang${i}`);d+=a.move(n.safe(t.lang,{before:d,after:" ",encode:["`"],...a.current()})),h()}if(t.lang&&t.meta){const h=n.enter(`codeFencedMeta${i}`);d+=a.move(" "),d+=a.move(n.safe(t.meta,{before:d,after:`
144
+ `,encode:["`"],...a.current()})),h()}return d+=a.move(`
145
+ `),s&&(d+=a.move(s+`
146
+ `)),d+=a.move(l),c(),d},definition:function(t,e,n,o){const r=Mh(n),s=r==='"'?"Quote":"Apostrophe",i=n.enter("definition");let a=n.enter("label");const l=n.createTracker(o);let c=l.move("[");return c+=l.move(n.safe(n.associationId(t),{before:c,after:"]",...l.current()})),c+=l.move("]: "),a(),!t.url||/[\0- \u007F]/.test(t.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(t.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(t.url,{before:c,after:t.title?" ":`
147
+ `,...l.current()}))),a(),t.title&&(a=n.enter(`title${s}`),c+=l.move(" "+r),c+=l.move(n.safe(t.title,{before:c,after:r,...l.current()})),c+=l.move(r),a()),i(),c},emphasis:jv,hardBreak:Cv,heading:function(t,e,n,o){const r=Math.max(Math.min(6,t.depth||1),1),s=n.createTracker(o);if(function(d,h){let f=!1;return gh(d,function(m){if("value"in m&&/\r?\n|\r/.test(m.value)||m.type==="break")return f=!0,ph}),!!((!d.depth||d.depth<3)&&lh(d)&&(h.options.setext||f))}(t,n)){const d=n.enter("headingSetext"),h=n.enter("phrasing"),f=n.containerPhrasing(t,{...s.current(),before:`
148
+ `,after:`
149
+ `});return h(),d(),f+`
150
+ `+(r===1?"=":"-").repeat(f.length-(Math.max(f.lastIndexOf("\r"),f.lastIndexOf(`
151
+ `))+1))}const i="#".repeat(r),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(i+" ");let c=n.containerPhrasing(t,{before:"# ",after:`
152
+ `,...s.current()});return/^[\t ]/.test(c)&&(c=vi(c.charCodeAt(0))+c.slice(1)),c=c?i+" "+c:i,n.options.closeAtx&&(c+=" "+i),l(),a(),c},html:Sv,image:Nv,imageReference:Ev,inlineCode:_v,link:Av,linkReference:Tv,list:function(t,e,n,o){const r=n.enter("list"),s=n.bulletCurrent;let i=t.ordered?function(d){const h=d.options.bulletOrdered||".";if(h!=="."&&h!==")")throw new Error("Cannot serialize items with `"+h+"` for `options.bulletOrdered`, expected `.` or `)`");return h}(n):Oh(n);const a=t.ordered?i==="."?")":".":function(d){const h=Oh(d),f=d.options.bulletOther;if(!f)return h==="*"?"-":"*";if(f!=="*"&&f!=="+"&&f!=="-")throw new Error("Cannot serialize items with `"+f+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(f===h)throw new Error("Expected `bullet` (`"+h+"`) and `bulletOther` (`"+f+"`) to be different");return f}(n);let l=!(!e||!n.bulletLastUsed)&&i===n.bulletLastUsed;if(!t.ordered){const d=t.children?t.children[0]:void 0;if(i!=="*"&&i!=="-"||!d||d.children&&d.children[0]||n.stack[n.stack.length-1]!=="list"||n.stack[n.stack.length-2]!=="listItem"||n.stack[n.stack.length-3]!=="list"||n.stack[n.stack.length-4]!=="listItem"||n.indexStack[n.indexStack.length-1]!==0||n.indexStack[n.indexStack.length-2]!==0||n.indexStack[n.indexStack.length-3]!==0||(l=!0),Mv(n)===i&&d){let h=-1;for(;++h<t.children.length;){const f=t.children[h];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(i=a),n.bulletCurrent=i;const c=n.containerFlow(t,o);return n.bulletLastUsed=i,n.bulletCurrent=s,r(),c},listItem:function(t,e,n,o){const r=function(d){const h=d.options.listItemIndent||"one";if(h!=="tab"&&h!=="one"&&h!=="mixed")throw new Error("Cannot serialize items with `"+h+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return h}(n);let s=n.bulletCurrent||Oh(n);e&&e.type==="list"&&e.ordered&&(s=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+s);let i=s.length+1;(r==="tab"||r==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(i=4*Math.ceil(i/4));const a=n.createTracker(o);a.move(s+" ".repeat(i-s.length)),a.shift(i);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(t,a.current()),function(d,h,f){return h?(f?"":" ".repeat(i))+d:(f?s:s+" ".repeat(i-s.length))+d});return l(),c},paragraph:function(t,e,n,o){const r=n.enter("paragraph"),s=n.enter("phrasing"),i=n.containerPhrasing(t,o);return s(),r(),i},root:function(t,e,n,o){return(t.children.some(function(r){return jA(r)})?n.containerPhrasing:n.containerFlow).call(n,t,o)},strong:Ov,text:function(t,e,n,o){return n.safe(t.value,o)},thematicBreak:function(t,e,n){const o=(Mv(n)+(n.options.ruleSpaces?" ":"")).repeat(function(r){const s=r.options.ruleRepetition||3;if(s<3)throw new Error("Cannot serialize rules with repetition `"+s+"` for `options.ruleRepetition`, expected `3` or more");return s}(n));return n.options.ruleSpaces?o.slice(0,-1):o}};function SA(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function NA(t){this.exit(t),this.data.inTable=void 0}function EA(t){this.enter({type:"tableRow",children:[]},t)}function Dh(t){this.exit(t)}function Rv(t){this.enter({type:"tableCell",children:[]},t)}function _A(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,IA));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function IA(t,e){return e==="|"?e:t}function AA(t){const e=t||{},n=e.tableCellPadding,o=e.tablePipeAlign,r=e.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
153
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(c,d,h){let f=Dv.inlineCode(c,d,h);return h.stack.includes("tableCell")&&(f=f.replace(/\|/g,"\\$&")),f},table:function(c,d,h,f){return a(function(m,g,x){const p=m.children;let b=-1;const y=[],v=g.enter("table");for(;++b<p.length;)y[b]=l(p[b],g,x);return v(),y}(c,h,f),c.align)},tableCell:i,tableRow:function(c,d,h,f){const m=l(c,h,f),g=a([m]);return g.slice(0,g.indexOf(`
154
+ `))}}};function i(c,d,h,f){const m=h.enter("tableCell"),g=h.enter("phrasing"),x=h.containerPhrasing(c,{...f,before:s,after:s});return g(),m(),x}function a(c,d){return function(h,f){const m=f||{},g=(m.align||[]).concat(),x=m.stringLength||yA,p=[],b=[],y=[],v=[];let w=0,S=-1;for(;++S<h.length;){const T=[],I=[];let O=-1;for(h[S].length>w&&(w=h[S].length);++O<h[S].length;){const L=vA(h[S][O]);if(m.alignDelimiters!==!1){const D=x(L);I[O]=D,(v[O]===void 0||D>v[O])&&(v[O]=D)}T.push(L)}b[S]=T,y[S]=I}let C=-1;if(typeof g=="object"&&"length"in g)for(;++C<w;)p[C]=wv(g[C]);else{const T=wv(g);for(;++C<w;)p[C]=T}C=-1;const N=[],j=[];for(;++C<w;){const T=p[C];let I="",O="";T===99?(I=":",O=":"):T===108?I=":":T===114&&(O=":");let L=m.alignDelimiters===!1?1:Math.max(1,v[C]-I.length-O.length);const D=I+"-".repeat(L)+O;m.alignDelimiters!==!1&&(L=I.length+L+O.length,L>v[C]&&(v[C]=L),j[C]=L),N[C]=D}b.splice(1,0,N),y.splice(1,0,j),S=-1;const E=[];for(;++S<b.length;){const T=b[S],I=y[S];C=-1;const O=[];for(;++C<w;){const L=T[C]||"";let D="",R="";if(m.alignDelimiters!==!1){const P=v[C]-(I[C]||0),z=p[C];z===114?D=" ".repeat(P):z===99?P%2?(D=" ".repeat(P/2+.5),R=" ".repeat(P/2-.5)):(D=" ".repeat(P/2),R=D):R=" ".repeat(P)}m.delimiterStart===!1||C||O.push("|"),m.padding===!1||m.alignDelimiters===!1&&L===""||m.delimiterStart===!1&&!C||O.push(" "),m.alignDelimiters!==!1&&O.push(D),O.push(L),m.alignDelimiters!==!1&&O.push(R),m.padding!==!1&&O.push(" "),m.delimiterEnd===!1&&C===w-1||O.push("|")}E.push(m.delimiterEnd===!1?O.join("").replace(/ +$/,""):O.join(""))}return E.join(`
155
+ `)}(c,{align:d,alignDelimiters:o,padding:n,stringLength:r})}function l(c,d,h){const f=c.children;let m=-1;const g=[],x=d.enter("tableRow");for(;++m<f.length;)g[m]=i(f[m],0,d,h);return x(),g}}function Pv(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function TA(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const o=n.children[0];if(o&&o.type==="text"){const r=e.children;let s,i=-1;for(;++i<r.length;){const a=r[i];if(a.type==="paragraph"){s=a;break}}s===n&&(o.value=o.value.slice(1),o.value.length===0?n.children.shift():n.position&&o.position&&typeof o.position.start.offset=="number"&&(o.position.start.column++,o.position.start.offset++,n.position.start=Object.assign({},o.position.start)))}}this.exit(t)}function MA(t,e,n,o){const r=t.children[0],s=typeof t.checked=="boolean"&&r&&r.type==="paragraph",i="["+(t.checked?"x":" ")+"] ",a=n.createTracker(o);s&&a.move(i);let l=Dv.listItem(t,e,n,{...o,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(c){return c+i})),l}const OA={tokenize:function(t,e,n){let o=0;return function s(i){return(i===87||i===119)&&o<3?(o++,t.consume(i),s):i===46&&o===3?(t.consume(i),r):n(i)};function r(s){return s===null?n(s):e(s)}},partial:!0},Lv={tokenize:function(t,e,n){let o,r,s;return i;function i(c){return c===46||c===95?t.check(zv,l,a)(c):c===null||ct(c)||ur(c)||c!==45&&_l(c)?l(c):(s=!0,t.consume(c),i)}function a(c){return c===95?o=!0:(r=o,o=void 0),t.consume(c),i}function l(c){return r||o||!s?n(c):e(c)}},partial:!0},Fv={tokenize:function(t,e){let n=0,o=0;return r;function r(i){return i===40?(n++,t.consume(i),r):i===41&&o<n?s(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?t.check(zv,e,s)(i):i===null||ct(i)||ur(i)?e(i):(t.consume(i),r)}function s(i){return i===41&&o++,t.consume(i),r}},partial:!0},zv={tokenize:function(t,e,n){return o;function o(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(t.consume(a),o):a===38?(t.consume(a),s):a===93?(t.consume(a),r):a===60||a===null||ct(a)||ur(a)?e(a):n(a)}function r(a){return a===null||a===40||a===91||ct(a)||ur(a)?e(a):o(a)}function s(a){return Zt(a)?i(a):n(a)}function i(a){return a===59?(t.consume(a),o):Zt(a)?(t.consume(a),i):n(a)}},partial:!0},DA={tokenize:function(t,e,n){return function(r){return t.consume(r),o};function o(r){return Ht(r)?n(r):e(r)}},partial:!0},Bv={name:"wwwAutolink",tokenize:function(t,e,n){const o=this;return function(s){return s!==87&&s!==119||!$v.call(o,o.previous)||Ph(o.events)?n(s):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(OA,t.attempt(Lv,t.attempt(Fv,r),n),n)(s))};function r(s){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(s)}},previous:$v},Uv={name:"protocolAutolink",tokenize:function(t,e,n){const o=this;let r="",s=!1;return function(d){return(d===72||d===104)&&Vv.call(o,o.previous)&&!Ph(o.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),r+=String.fromCodePoint(d),t.consume(d),i):n(d)};function i(d){if(Zt(d)&&r.length<5)return r+=String.fromCodePoint(d),t.consume(d),i;if(d===58){const h=r.toLowerCase();if(h==="http"||h==="https")return t.consume(d),a}return n(d)}function a(d){return d===47?(t.consume(d),s?l:(s=!0,a)):n(d)}function l(d){return d===null||El(d)||ct(d)||ur(d)||_l(d)?n(d):t.attempt(Lv,t.attempt(Fv,c),n)(d)}function c(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}},previous:Vv},so={name:"emailAutolink",tokenize:function(t,e,n){const o=this;let r,s;return function(d){return!Rh(d)||!Hv.call(o,o.previous)||Ph(o.events)?n(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),i(d))};function i(d){return Rh(d)?(t.consume(d),i):d===64?(t.consume(d),a):n(d)}function a(d){return d===46?t.check(DA,c,l)(d):d===45||d===95||Ht(d)?(s=!0,t.consume(d),a):c(d)}function l(d){return t.consume(d),r=!0,a}function c(d){return s&&r&&Zt(o.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):n(d)}},previous:Hv},Yn={};let hr=48;for(;hr<123;)Yn[hr]=so,hr++,hr===58?hr=65:hr===91&&(hr=97);function $v(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||ct(t)}function Vv(t){return!Zt(t)}function Hv(t){return!(t===47||Rh(t))}function Rh(t){return t===43||t===45||t===46||t===95||Ht(t)}function Ph(t){let e=t.length,n=!1;for(;e--;){const o=t[e][1];if((o.type==="labelLink"||o.type==="labelImage")&&!o._balanced){n=!0;break}if(o._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}Yn[43]=so,Yn[45]=so,Yn[46]=so,Yn[95]=so,Yn[72]=[so,Uv],Yn[104]=[so,Uv],Yn[87]=[so,Bv],Yn[119]=[so,Bv];const RA={tokenize:function(t,e,n){const o=this;return rt(t,function(r){const s=o.events[o.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?e(r):n(r)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function PA(t,e,n){const o=this;let r=o.events.length;const s=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let i;for(;r--;){const a=o.events[r][1];if(a.type==="labelImage"){i=a;break}if(a.type==="gfmFootnoteCall"||a.type==="labelLink"||a.type==="label"||a.type==="image"||a.type==="link")break}return function(a){if(!i||!i._balanced)return n(a);const l=Rn(o.sliceSerialize({start:i.end,end:o.now()}));return l.codePointAt(0)!==94||!s.includes(l.slice(1))?n(a):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(a),t.exit("gfmFootnoteCallLabelMarker"),e(a))}}function LA(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const o={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},r={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};r.end.column++,r.end.offset++,r.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},r.end),end:Object.assign({},t[t.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[t[n+1],t[n+2],["enter",o,e],t[n+3],t[n+4],["enter",r,e],["exit",r,e],["enter",s,e],["enter",i,e],["exit",i,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",o,e]];return t.splice(n,t.length-n+1,...a),t}function FA(t,e,n){const o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let s,i=0;return function(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),a};function a(d){return d!==94?n(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",l)}function l(d){if(i>999||d===93&&!s||d===null||d===91||ct(d))return n(d);if(d===93){t.exit("chunkString");const h=t.exit("gfmFootnoteCallString");return r.includes(Rn(o.sliceSerialize(h)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(d)}return ct(d)||(s=!0),i++,t.consume(d),d===92?c:l}function c(d){return d===91||d===92||d===93?(t.consume(d),i++,l):l(d)}}function zA(t,e,n){const o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let s,i,a=0;return function(m){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(m),t.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(m){return m===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(m),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",c):n(m)}function c(m){if(a>999||m===93&&!i||m===null||m===91||ct(m))return n(m);if(m===93){t.exit("chunkString");const g=t.exit("gfmFootnoteDefinitionLabelString");return s=Rn(o.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(m),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),h}return ct(m)||(i=!0),a++,t.consume(m),m===92?d:c}function d(m){return m===91||m===92||m===93?(t.consume(m),a++,c):c(m)}function h(m){return m===58?(t.enter("definitionMarker"),t.consume(m),t.exit("definitionMarker"),r.includes(s)||r.push(s),rt(t,f,"gfmFootnoteDefinitionWhitespace")):n(m)}function f(m){return e(m)}}function BA(t,e,n){return t.check(pi,e,t.attempt(RA,e,n))}function UA(t){t.exit("gfmFootnoteDefinition")}function $A(t){let e=(t||{}).singleTilde;const n={name:"strikethrough",tokenize:function(o,r,s){const i=this.previous,a=this.events;let l=0;return function(d){return i===126&&a[a.length-1][1].type!=="characterEscape"?s(d):(o.enter("strikethroughSequenceTemporary"),c(d))};function c(d){const h=Gr(i);if(d===126)return l>1?s(d):(o.consume(d),l++,c);if(l<2&&!e)return s(d);const f=o.exit("strikethroughSequenceTemporary"),m=Gr(d);return f._open=!m||m===2&&!!h,f._close=!h||h===2&&!!m,r(d)}},resolveAll:function(o,r){let s=-1;for(;++s<o.length;)if(o[s][0]==="enter"&&o[s][1].type==="strikethroughSequenceTemporary"&&o[s][1]._close){let i=s;for(;i--;)if(o[i][0]==="exit"&&o[i][1].type==="strikethroughSequenceTemporary"&&o[i][1]._open&&o[s][1].end.offset-o[s][1].start.offset===o[i][1].end.offset-o[i][1].start.offset){o[s][1].type="strikethroughSequence",o[i][1].type="strikethroughSequence";const a={type:"strikethrough",start:Object.assign({},o[i][1].start),end:Object.assign({},o[s][1].end)},l={type:"strikethroughText",start:Object.assign({},o[i][1].end),end:Object.assign({},o[s][1].start)},c=[["enter",a,r],["enter",o[i][1],r],["exit",o[i][1],r],["enter",l,r]],d=r.parser.constructs.insideSpan.null;d&&gn(c,c.length,0,Il(d,o.slice(i+1,s),r)),gn(c,c.length,0,[["exit",l,r],["enter",o[s][1],r],["exit",o[s][1],r],["exit",a,r]]),gn(o,i-1,s-i+3,c),s=i+c.length-2;break}}for(s=-1;++s<o.length;)o[s][1].type==="strikethroughSequenceTemporary"&&(o[s][1].type="data");return o}};return e==null&&(e=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}}class VA{constructor(){this.map=[]}add(e,n,o){(function(r,s,i,a){let l=0;if(!(i===0&&a.length===0)){for(;l<r.map.length;){if(r.map[l][0]===s)return r.map[l][1]+=i,void r.map[l][2].push(...a);l+=1}r.map.push([s,i,a])}})(this,e,n,o)}consume(e){if(this.map.sort(function(s,i){return s[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const o=[];for(;n>0;)n-=1,o.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];o.push(e.slice()),e.length=0;let r=o.pop();for(;r;){for(const s of r)e.push(s);r=o.pop()}this.map.length=0}}function HA(t,e){let n=!1;const o=[];for(;e<t.length;){const r=t[e];if(n){if(r[0]==="enter")r[1].type==="tableContent"&&o.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(r[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const s=o.length-1;o[s]=o[s]==="left"?"center":"right"}}else if(r[1].type==="tableDelimiterRow")break}else r[0]==="enter"&&r[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return o}function WA(t,e,n){const o=this;let r,s=0,i=0;return function(j){let E=o.events.length-1;for(;E>-1;){const O=o.events[E][1].type;if(O!=="lineEnding"&&O!=="linePrefix")break;E--}const T=E>-1?o.events[E][1].type:null,I=T==="tableHead"||T==="tableRow"?w:a;return I===w&&o.parser.lazy[o.now().line]?n(j):I(j)};function a(j){return t.enter("tableHead"),t.enter("tableRow"),function(E){return E===124||(r=!0,i+=1),l(E)}(j)}function l(j){return j===null?n(j):Be(j)?i>1?(i=0,o.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(j),t.exit("lineEnding"),h):n(j):et(j)?rt(t,l,"whitespace")(j):(i+=1,r&&(r=!1,s+=1),j===124?(t.enter("tableCellDivider"),t.consume(j),t.exit("tableCellDivider"),r=!0,l):(t.enter("data"),c(j)))}function c(j){return j===null||j===124||ct(j)?(t.exit("data"),l(j)):(t.consume(j),j===92?d:c)}function d(j){return j===92||j===124?(t.consume(j),c):c(j)}function h(j){return o.interrupt=!1,o.parser.lazy[o.now().line]?n(j):(t.enter("tableDelimiterRow"),r=!1,et(j)?rt(t,f,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):f(j))}function f(j){return j===45||j===58?g(j):j===124?(r=!0,t.enter("tableCellDivider"),t.consume(j),t.exit("tableCellDivider"),m):v(j)}function m(j){return et(j)?rt(t,g,"whitespace")(j):g(j)}function g(j){return j===58?(i+=1,r=!0,t.enter("tableDelimiterMarker"),t.consume(j),t.exit("tableDelimiterMarker"),x):j===45?(i+=1,x(j)):j===null||Be(j)?y(j):v(j)}function x(j){return j===45?(t.enter("tableDelimiterFiller"),p(j)):v(j)}function p(j){return j===45?(t.consume(j),p):j===58?(r=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(j),t.exit("tableDelimiterMarker"),b):(t.exit("tableDelimiterFiller"),b(j))}function b(j){return et(j)?rt(t,y,"whitespace")(j):y(j)}function y(j){return j===124?f(j):(j===null||Be(j))&&r&&s===i?(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(j)):v(j)}function v(j){return n(j)}function w(j){return t.enter("tableRow"),S(j)}function S(j){return j===124?(t.enter("tableCellDivider"),t.consume(j),t.exit("tableCellDivider"),S):j===null||Be(j)?(t.exit("tableRow"),e(j)):et(j)?rt(t,S,"whitespace")(j):(t.enter("data"),C(j))}function C(j){return j===null||j===124||ct(j)?(t.exit("data"),S(j)):(t.consume(j),j===92?N:C)}function N(j){return j===92||j===124?(t.consume(j),C):C(j)}}function qA(t,e){let n,o,r,s=-1,i=!0,a=0,l=[0,0,0,0],c=[0,0,0,0],d=!1,h=0;const f=new VA;for(;++s<t.length;){const m=t[s],g=m[1];m[0]==="enter"?g.type==="tableHead"?(d=!1,h!==0&&(Wv(f,e,h,n,o),o=void 0,h=0),n={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(s,0,[["enter",n,e]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(i=!0,r=void 0,l=[0,0,0,0],c=[0,s+1,0,0],d&&(d=!1,o={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(s,0,[["enter",o,e]])),a=g.type==="tableDelimiterRow"?2:o?3:1):!a||g.type!=="data"&&g.type!=="tableDelimiterMarker"&&g.type!=="tableDelimiterFiller"?g.type==="tableCellDivider"&&(i?i=!1:(l[1]!==0&&(c[0]=c[1],r=Fl(f,e,l,a,void 0,r)),l=c,c=[l[1],s,0,0])):(i=!1,c[2]===0&&(l[1]!==0&&(c[0]=c[1],r=Fl(f,e,l,a,void 0,r),l=[0,0,0,0]),c[2]=s)):g.type==="tableHead"?(d=!0,h=s):g.type==="tableRow"||g.type==="tableDelimiterRow"?(h=s,l[1]!==0?(c[0]=c[1],r=Fl(f,e,l,a,s,r)):c[1]!==0&&(r=Fl(f,e,c,a,s,r)),a=0):!a||g.type!=="data"&&g.type!=="tableDelimiterMarker"&&g.type!=="tableDelimiterFiller"||(c[3]=s)}for(h!==0&&Wv(f,e,h,n,o),f.consume(e.events),s=-1;++s<e.events.length;){const m=e.events[s];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=HA(e.events,s))}return t}function Fl(t,e,n,o,r,s){const i=o===1?"tableHeader":o===2?"tableDelimiter":"tableData";n[0]!==0&&(s.end=Object.assign({},Kr(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const a=Kr(e.events,n[1]);if(s={type:i,start:Object.assign({},a),end:Object.assign({},a)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const l=Kr(e.events,n[2]),c=Kr(e.events,n[3]),d={type:"tableContent",start:Object.assign({},l),end:Object.assign({},c)};if(t.add(n[2],0,[["enter",d,e]]),o!==2){const h=e.events[n[2]],f=e.events[n[3]];if(h[1].end=Object.assign({},f[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,g=n[3]-n[2]-1;t.add(m,g,[])}}t.add(n[3]+1,0,[["exit",d,e]])}return r!==void 0&&(s.end=Object.assign({},Kr(e.events,r)),t.add(r,0,[["exit",s,e]]),s=void 0),s}function Wv(t,e,n,o,r){const s=[],i=Kr(e.events,n);r&&(r.end=Object.assign({},i),s.push(["exit",r,e])),o.end=Object.assign({},i),s.push(["exit",o,e]),t.add(n+1,0,s)}function Kr(t,e){const n=t[e],o=n[0]==="enter"?"start":"end";return n[1][o]}const GA={name:"tasklistCheck",tokenize:function(t,e,n){const o=this;return function(a){return o.previous!==null||!o._gfmTasklistFirstContentOfListItem?n(a):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(a),t.exit("taskListCheckMarker"),r)};function r(a){return ct(a)?(t.enter("taskListCheckValueUnchecked"),t.consume(a),t.exit("taskListCheckValueUnchecked"),s):a===88||a===120?(t.enter("taskListCheckValueChecked"),t.consume(a),t.exit("taskListCheckValueChecked"),s):n(a)}function s(a){return a===93?(t.enter("taskListCheckMarker"),t.consume(a),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),i):n(a)}function i(a){return Be(a)?e(a):et(a)?t.check({tokenize:YA},e,n)(a):n(a)}}};function YA(t,e,n){return rt(t,function(o){return o===null?n(o):e(o)},"whitespace")}const KA={};function XA(t){const e=t||KA,n=this.data(),o=n.micromarkExtensions||(n.micromarkExtensions=[]),r=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);o.push(function(i){return Ty([{text:Yn},{document:{91:{name:"gfmFootnoteDefinition",tokenize:zA,continuation:{tokenize:BA},exit:UA}},text:{91:{name:"gfmFootnoteCall",tokenize:FA},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:PA,resolveTo:LA}}},$A(i),{flow:{null:{name:"table",tokenize:WA,resolveAll:qA}}},{text:{91:GA}}])}(e)),r.push([{transforms:[oA],enter:{literalAutolink:Z8,literalAutolinkEmail:Th,literalAutolinkHttp:Th,literalAutolinkWww:Th},exit:{literalAutolink:nA,literalAutolinkEmail:tA,literalAutolinkHttp:Q8,literalAutolinkWww:eA}},{enter:{gfmFootnoteCallString:iA,gfmFootnoteCall:aA,gfmFootnoteDefinitionLabelString:lA,gfmFootnoteDefinition:cA},exit:{gfmFootnoteCallString:dA,gfmFootnoteCall:uA,gfmFootnoteDefinitionLabelString:hA,gfmFootnoteDefinition:fA}},{canContainEols:["delete"],enter:{strikethrough:xA},exit:{strikethrough:bA}},{enter:{table:SA,tableData:Rv,tableHeader:Rv,tableRow:EA},exit:{codeText:_A,table:NA,tableData:Dh,tableHeader:Dh,tableRow:Dh}},{exit:{taskListCheckValueChecked:Pv,taskListCheckValueUnchecked:Pv,paragraph:TA}}]),s.push(function(i){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Ih,notInConstruct:Ah},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Ih,notInConstruct:Ah},{character:":",before:"[ps]",after:"\\/",inConstruct:Ih,notInConstruct:Ah}]},mA(i),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:gA}],handlers:{delete:vv}},AA(i),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:MA}}]}}(e))}const JA=[We.lineWrapping],ZA=new Set(["python","markdown","sql","json","yaml","toml","shell","javascript","typescript","jsx","tsx","css","html"]),QA=t=>{const e=H.c(26),{code:n,language:o}=t,{theme:r}=Zo(),{createNewCell:s}=lt(),i=ms(),a=je(ac),[l,c]=M.useState(n);let d,h,f;e[0]!==n?(d=()=>{c(n)},h=[n],e[0]=n,e[1]=d,e[2]=h):(d=e[1],h=e[2]),M.useEffect(d,h),e[3]!==a||e[4]!==s||e[5]!==o||e[6]!==i||e[7]!==l?(f=()=>{const j=function(E,T){return E?E==="python"?{language:E,code:T}:E==="sql"?{language:"python",code:Pc.fromQuery(T)}:E==="markdown"?{language:"python",code:Wi.fromMarkdown(T)}:E==="shell"||E==="bash"?{language:"python",code:`import subprocess
156
+ subprocess.run("${T}")`}:{language:"python",code:`_${E} = """
157
+ ${T}
158
+ """`}:{language:"python",code:T}}(o,l);o==="sql"&&Jn({autoInstantiate:a,createNewCell:s,fromCellId:i}),s({code:j.code,before:!1,cellId:i??"__end__"})},e[3]=a,e[4]=s,e[5]=o,e[6]=i,e[7]=l,e[8]=f):f=e[8];const m=f;let g;e[9]!==l?(g=async()=>{await sn(l)},e[9]=l,e[10]=g):g=e[10];const x=g,p=r==="dark"?"dark":"light",b=o&&ZA.has(o)?o:void 0;let y,v,w,S,C,N;return e[11]!==p||e[12]!==b||e[13]!==l?(y=u.jsx(M.Suspense,{children:u.jsx(ua,{theme:p,language:b,className:"cm border rounded overflow-hidden",extensions:JA,value:l,onChange:c})}),e[11]=p,e[12]=b,e[13]=l,e[14]=y):y=e[14],e[15]!==x?(v=u.jsx(eT,{size:"xs",variant:"outline",onClick:x,children:"Copy"}),e[15]=x,e[16]=v):v=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(w=u.jsx(Nr,{className:"ml-2 h-4 w-4"}),e[17]=w):w=e[17],e[18]!==m?(S=u.jsxs(ve,{size:"xs",variant:"outline",onClick:m,children:["Add to Notebook",w]}),e[18]=m,e[19]=S):S=e[19],e[20]!==S||e[21]!==v?(C=u.jsxs("div",{className:"flex justify-end mt-2 space-x-2",children:[v,S]}),e[20]=S,e[21]=v,e[22]=C):C=e[22],e[23]!==C||e[24]!==y?(N=u.jsxs("div",{className:"relative",children:[y,C]}),e[23]=C,e[24]=y,e[25]=N):N=e[25],N},eT=t=>{const e=H.c(12);let n,o;e[0]!==t?({onClick:n,...o}=t,e[0]=t,e[1]=n,e[2]=o):(n=e[1],o=e[2]);const[r,s]=M.useState(!1);let i,a,l;e[3]!==r?(i=()=>{r&&setTimeout(()=>s(!1),1e3)},a=[r],e[3]=r,e[4]=i,e[5]=a):(i=e[4],a=e[5]),M.useEffect(i,a),e[6]!==n?(l=h=>{n==null||n(h),s(!0)},e[6]=n,e[7]=l):l=e[7];const c=r?"Copied":"Copy";let d;return e[8]!==o||e[9]!==l||e[10]!==c?(d=u.jsx(ve,{...o,onClick:l,children:c}),e[8]=o,e[9]=l,e[10]=c,e[11]=d):d=e[11],d},tT={code:({children:t,className:e})=>{const n=e==null?void 0:e.replace("language-","");return n&&typeof t=="string"?u.jsxs("div",{children:[u.jsx("div",{className:"text-xs text-muted-foreground pl-1",children:n}),u.jsx(QA,{code:t.trim(),language:n})]}):u.jsx("code",{className:e,children:t})}},qv=M.memo(t=>{const e=H.c(3),{content:n}=t;let o,r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[XA],e[0]=o):o=e[0],e[1]!==n?(r=u.jsx(G8,{components:tT,remarkPlugins:o,className:"prose dark:prose-invert max-w-none prose-pre:pl-0",children:n}),e[1]=n,e[2]=r):r=e[2],r},(t,e)=>t.content===e.content);qv.displayName="MemoizedMarkdownBlock";const Lh=M.memo(({content:t})=>{const e=M.useMemo(()=>{return n=t,eL.lexer(n).map(o=>o.raw);var n},[t]);return u.jsx(u.Fragment,{children:e.map((n,o)=>u.jsx(qv,{content:n},`markdown-block-${o}`))})});Lh.displayName="MarkdownRenderer";const nT=t=>{const e=H.c(13),{reasoning:n,index:o,isStreaming:r}=t,s=o===void 0?0:o,i=r!==void 0&&r,a=i?"reasoning":void 0;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx(oc,{className:"h-3 w-3"}),e[0]=l):l=e[0];const c=i?"Thinking":"View reasoning";let d,h,f,m;return e[1]!==n.length||e[2]!==c?(d=u.jsx(LC,{className:"text-xs text-muted-foreground hover:bg-muted/50 px-2 py-1 h-auto rounded-sm [&[data-state=open]>svg]:rotate-180",children:u.jsxs("span",{className:"flex items-center gap-2",children:[l,c," (",n.length," ","chars)"]})}),e[1]=n.length,e[2]=c,e[3]=d):d=e[3],e[4]!==n?(h=u.jsx(FC,{className:"pb-2 px-2",children:u.jsx("div",{className:"bg-muted/30 border border-muted/50 rounded-md p-3 italic text-muted-foreground/90 relative",children:u.jsx("div",{className:"pr-6",children:u.jsx(Lh,{content:n})})})}),e[4]=n,e[5]=h):h=e[5],e[6]!==d||e[7]!==h?(f=u.jsxs(zC,{value:"reasoning",className:"border-0",children:[d,h]}),e[6]=d,e[7]=h,e[8]=f):f=e[8],e[9]!==s||e[10]!==a||e[11]!==f?(m=u.jsx(BC,{type:"single",collapsible:!0,className:"w-full mb-2",value:a,children:f},s),e[9]=s,e[10]=a,e[11]=f,e[12]=m):m=e[12],m},oT=t=>{const e=H.c(32),{toolName:n,result:o,error:r,index:s,state:i}=t,a=s===void 0?0:s,l=i==="result"&&(o||r),c=r?"error":l?"success":"loading";let d;e[0]!==c?(d=()=>{switch(c){case"loading":return u.jsx(zc,{className:"h-3 w-3 animate-spin"});case"error":return u.jsx(Pi,{className:"h-3 w-3 text-destructive"});case"success":return u.jsx(wF,{className:"h-3 w-3 text-green-600"});default:return u.jsx(tL,{className:"h-3 w-3"})}},e[0]=c,e[1]=d):d=e[1];const h=d;let f;e[2]!==r||e[3]!==l||e[4]!==c?(f=()=>c==="loading"?"Running: ":r?"Failed: ":l?"Done: ":"Tool call",e[2]=r,e[3]=l,e[4]=c,e[5]=f):f=e[5];const m=f,g=`tool-${a}`,x=c==="error"&&"text-destructive/80",p=c==="success"&&"text-green-600/80";let b,y;e[6]!==x||e[7]!==p?(b=xe("h-6 text-xs border-border shadow-none! ring-0! bg-muted hover:bg-muted/30 py-0 px-2 gap-1 rounded-sm [&[data-state=open]>svg]:rotate-180",x,p),e[6]=x,e[7]=p,e[8]=b):b=e[8],e[9]!==h?(y=h(),e[9]=h,e[10]=y):y=e[10];const v=m();let w,S,C,N,j,E,T;return e[11]!==n?(w=u.jsx("code",{className:"font-mono text-xs",children:n}),e[11]=n,e[12]=w):w=e[12],e[13]!==w||e[14]!==y||e[15]!==v?(S=u.jsxs("span",{className:"flex items-center gap-1",children:[y,v,":"," ",w]}),e[13]=w,e[14]=y,e[15]=v,e[16]=S):S=e[16],e[17]!==S||e[18]!==b?(C=u.jsx(LC,{className:b,children:S}),e[17]=S,e[18]=b,e[19]=C):C=e[19],e[20]!==r||e[21]!==l||e[22]!==o?(N=l&&u.jsxs("div",{className:"space-y-3",children:[o&&u.jsxs("div",{children:[u.jsx("div",{className:"text-xs font-medium text-muted-foreground mt-2 mb-1",children:"Result:"}),u.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:typeof o=="string"?o:JSON.stringify(o,null,2)})]}),r&&u.jsxs("div",{children:[u.jsx("div",{className:"text-xs font-medium text-destructive mb-1",children:"Error:"}),u.jsx("div",{className:"bg-destructive/10 border border-destructive/20 rounded-md p-3 text-sm text-destructive",children:r})]})]}),e[20]=r,e[21]=l,e[22]=o,e[23]=N):N=e[23],e[24]!==N?(j=u.jsx(FC,{className:"pb-2 px-2",children:N}),e[24]=N,e[25]=j):j=e[25],e[26]!==C||e[27]!==j?(E=u.jsxs(zC,{value:"tool-call",className:"border-0",children:[C,j]}),e[26]=C,e[27]=j,e[28]=E):E=e[28],e[29]!==E||e[30]!==g?(T=u.jsx(BC,{type:"single",collapsible:!0,className:"w-full my-4",children:E},g),e[29]=E,e[30]=g,e[31]=T):T=e[31],T},rT=t=>{const e=H.c(27),{onNewChat:n,activeChatId:o,setActiveChat:r,chats:s}=t,{handleClick:i}=fa();let a,l,c,d,h,f,m,g,x,p,b;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(a=u.jsx(Jo,{className:"h-4 w-4"}),e[0]=a):a=e[0],e[1]!==n?(l=u.jsx(Ne,{content:"New chat",children:u.jsx(ve,{variant:"text",size:"icon",onClick:n,children:a})}),e[1]=n,e[2]=l):l=e[2],e[3]!==i?(c=()=>i("ai"),e[3]=i,e[4]=c):c=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx(Sm,{className:"h-4 w-4"}),e[5]=d):d=e[5],e[6]!==c?(h=u.jsx(Ne,{content:"AI Settings",children:u.jsx(ve,{variant:"text",size:"xs",className:"hover:bg-foreground/10 py-2",onClick:c,children:d})}),e[6]=c,e[7]=h):h=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(f=u.jsx(Ne,{content:"Previous chats",children:u.jsx(Cs,{asChild:!0,children:u.jsx(ve,{variant:"text",size:"icon",children:u.jsx(sL,{className:"h-4 w-4"})})})}),e[8]=f):f=e[8],e[9]!==s.length?(m=s.length===0&&u.jsx(dn,{title:"No chats yet",description:"Start a new chat to get started",icon:u.jsx(oc,{})}),e[9]=s.length,e[10]=m):m=e[10],e[11]!==o||e[12]!==s||e[13]!==r){let y;e[15]!==o||e[16]!==r?(y=v=>u.jsxs("button",{className:xe("w-full p-3 rounded-md cursor-pointer hover:bg-accent text-left",v.id===o&&"bg-accent"),onClick:()=>{r(v.id)},type:"button",children:[u.jsx("div",{className:"font-medium",children:v.title}),u.jsx("div",{className:"text-sm text-muted-foreground",children:iL(v.updatedAt)})]},v.id),e[15]=o,e[16]=r,e[17]=y):y=e[17],g=s.map(y),e[11]=o,e[12]=s,e[13]=r,e[14]=g}else g=e[14];return e[18]!==m||e[19]!==g?(x=u.jsxs(yr,{children:[f,u.jsx(xs,{className:"w-[520px] p-0",align:"start",side:"right",children:u.jsx(oy,{className:"h-[500px] p-4",children:u.jsxs("div",{className:"space-y-4",children:[m,g]})})})]}),e[18]=m,e[19]=g,e[20]=x):x=e[20],e[21]!==h||e[22]!==x?(p=u.jsxs("div",{className:"flex items-center gap-2",children:[h,x]}),e[21]=h,e[22]=x,e[23]=p):p=e[23],e[24]!==p||e[25]!==l?(b=u.jsxs("div",{className:"flex border-b px-2 py-1 justify-between shrink-0 items-center",children:[l,p]}),e[24]=p,e[25]=l,e[26]=b):b=e[26],b},Gv=M.memo(t=>{var f;const e=H.c(15),{message:n,index:o,theme:r,onEdit:s,isStreamingReasoning:i,totalMessages:a}=t,l=n.role==="user"?"justify-end":"justify-start";let c,d,h;return e[0]!==l?(c=xe("flex group relative",l),e[0]=l,e[1]=c):c=e[1],e[2]!==o||e[3]!==i||e[4]!==n.content||e[5]!==n.id||e[6]!==n.parts||e[7]!==n.role||e[8]!==s||e[9]!==r||e[10]!==a?(d=n.role==="user"?u.jsx("div",{className:"w-[95%] bg-background border p-1 rounded-sm",children:u.jsx(Fc,{value:n.content,theme:r,placeholder:"Type your message...",onChange:aT,onSubmit:(m,g)=>{g.trim()&&s(o,g)},onClose:lT},n.id)}):u.jsxs("div",{className:"w-[95%] break-words",children:[u.jsx("div",{className:"absolute right-1 top-1 opacity-0 group-hover:opacity-100 transition-opacity",children:u.jsx(UC,{className:"h-3 w-3",value:n.content})}),(f=n.parts)==null?void 0:f.map((m,g)=>{var x;switch(m.type){case"text":return u.jsx(Lh,{content:m.text},g);case"reasoning":return u.jsx(nT,{reasoning:m.reasoning,index:g,isStreaming:o===a-1&&i&&g===(((x=n.parts)==null?void 0:x.length)||0)-1},g);case"tool-invocation":return u.jsx(oT,{index:g,toolName:m.toolInvocation.toolName,result:m.toolInvocation.state==="result"?m.toolInvocation.result:null,state:m.toolInvocation.state},g);default:return null}})]}),e[2]=o,e[3]=i,e[4]=n.content,e[5]=n.id,e[6]=n.parts,e[7]=n.role,e[8]=s,e[9]=r,e[10]=a,e[11]=d):d=e[11],e[12]!==c||e[13]!==d?(h=u.jsx("div",{className:c,children:d}),e[12]=c,e[13]=d,e[14]=h):h=e[14],h});Gv.displayName="ChatMessage";const Fh=M.memo(t=>{var D;const e=H.c(33),{input:n,onSendClick:o,isLoading:r,onStop:s}=t,i=je(DC),[a,l]=Dt(Ki),c=(i==null?void 0:i.mode)||"manual",d=((D=i==null?void 0:i.open_ai)==null?void 0:D.model)||"o4-mini",{saveUserConfig:h}=tt();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=[{value:"ask",label:"Ask",subtitle:"Read-only tools"},{value:"manual",label:"Manual",subtitle:"No tools"}],e[0]=f):f=e[0];const m=f;let g,x,p,b,y,v,w,S,C,N,j;if(e[1]!==h||e[2]!==l||e[3]!==a){g=async P=>{const z={...a,ai:{...a.ai,mode:P}};R(z)},x=async P=>{var _;const z={...a,ai:{...a.ai,open_ai:{...(_=a.ai)==null?void 0:_.open_ai,model:P}}};R(z)};const R=async P=>{await h({config:P}).then(()=>{l(P)})};e[1]=h,e[2]=l,e[3]=a,e[4]=g,e[5]=x}else g=e[4],x=e[5];e[6]===Symbol.for("react.memo_cache_sentinel")?(p=u.jsx($i,{className:"h-6 text-xs border-border shadow-none! ring-0! bg-muted hover:bg-muted/30 py-0 px-2 gap-1",children:u.jsx(Vi,{placeholder:"manual"})}),e[6]=p):p=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(Hi,{children:m.map(cT)}),e[7]=b):b=e[7],e[8]!==c||e[9]!==g?(y=u.jsx(nL,{feature:"mcp_docs",children:u.jsxs(Ui,{value:c,onValueChange:g,children:[p,b]})}),e[8]=c,e[9]=g,e[10]=y):y=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(v=u.jsx($i,{className:"h-6 text-xs border-border shadow-none! ring-0! bg-muted hover:bg-muted/30 py-0 px-2 gap-1",children:u.jsx(Vi,{placeholder:"Model"})}),e[11]=v):v=e[11],e[12]!==d?(w=!mj.includes(d)&&u.jsx(fs,{value:d,className:"text-sm",children:d},d),e[12]=d,e[13]=w):w=e[13],e[14]===Symbol.for("react.memo_cache_sentinel")?(S=mj.map(dT),e[14]=S):S=e[14],e[15]!==w?(C=u.jsxs(Hi,{children:[w,S]}),e[15]=w,e[16]=C):C=e[16],e[17]!==d||e[18]!==x||e[19]!==C?(N=u.jsxs(Ui,{value:d,onValueChange:x,children:[v,C]}),e[17]=d,e[18]=x,e[19]=C,e[20]=N):N=e[20],e[21]!==y||e[22]!==N?(j=u.jsxs("div",{className:"flex items-center gap-2",children:[y,N]}),e[21]=y,e[22]=N,e[23]=j):j=e[23];const E=r?s:o,T=!r&&!n.trim();let I,O,L;return e[24]!==r?(I=r?u.jsx(gc,{className:"h-3 w-3 fill-current"}):u.jsx(oL,{className:"h-3 w-3"}),e[24]=r,e[25]=I):I=e[25],e[26]!==E||e[27]!==T||e[28]!==I?(O=u.jsx(ve,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-muted/30",onClick:E,disabled:T,children:I}),e[26]=E,e[27]=T,e[28]=I,e[29]=O):O=e[29],e[30]!==j||e[31]!==O?(L=u.jsxs("div",{className:"px-3 py-2 border-t border-border/20 flex items-center justify-between",children:[j,O]}),e[30]=j,e[31]=O,e[32]=L):L=e[32],L});Fh.displayName="ChatInputFooter";const Yv=M.memo(t=>{var x,p;const e=H.c(19),{input:n,setInput:o,onSubmit:r,theme:s,inputRef:i,isLoading:a,onStop:l}=t;let c;e[0]!==n||e[1]!==r?(c=()=>{n.trim()&&r(void 0,n)},e[0]=n,e[1]=r,e[2]=c):c=e[2];const d=c;let h,f,m,g;return e[3]!==((x=i.current)==null?void 0:x.editor)?(h=()=>{var b,y;return(y=(b=i.current)==null?void 0:b.editor)==null?void 0:y.blur()},e[3]=(p=i.current)==null?void 0:p.editor,e[4]=h):h=e[4],e[5]!==n||e[6]!==r||e[7]!==o||e[8]!==h||e[9]!==s?(f=u.jsx("div",{className:"px-2 py-3 flex-1",children:u.jsx(Fc,{value:n,onChange:o,onSubmit:r,onClose:h,theme:s,placeholder:"Type your message..."})}),e[5]=n,e[6]=r,e[7]=o,e[8]=h,e[9]=s,e[10]=f):f=e[10],e[11]!==d||e[12]!==n||e[13]!==a||e[14]!==l?(m=u.jsx(Fh,{input:n,onSendClick:d,isLoading:a,onStop:l}),e[11]=d,e[12]=n,e[13]=a,e[14]=l,e[15]=m):m=e[15],e[16]!==f||e[17]!==m?(g=u.jsxs("div",{className:"border-t relative shrink-0 min-h-[80px] flex flex-col",children:[f,m]}),e[16]=f,e[17]=m,e[18]=g):g=e[18],g});Yv.displayName="ChatInput";const sT=()=>{const t=H.c(6),e=je(ic),{handleClick:n}=fa();if(!e){let r,s,i;return t[0]!==n?(r=u.jsx(ve,{variant:"outline",size:"sm",onClick:()=>n("ai"),children:"Edit AI settings"}),t[0]=n,t[1]=r):r=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(s=u.jsx(oc,{}),t[2]=s):s=t[2],t[3]!==r?(i=u.jsx(dn,{title:"Chat with AI",description:"AI is currently disabled. Add your API key to enable.",action:r,icon:s}),t[3]=r,t[4]=i):i=t[4],i}let o;return t[5]===Symbol.for("react.memo_cache_sentinel")?(o=u.jsx(iT,{}),t[5]=o):o=t[5],o},iT=()=>{const[t,e]=Dt(md),[n,o]=Dt(Vj),[r,s]=M.useState(""),i=M.useRef(null),a=M.useRef(null),l=M.useRef(null),c=M.useRef(null),{theme:d}=Zo(),h=qm(),{invokeAiTool:f}=tt(),{messages:m,input:g,setInput:x,setMessages:p,append:b,handleSubmit:y,error:v,status:w,reload:S,stop:C}=rL({id:n==null?void 0:n.id,maxSteps:10,initialMessages:(n==null?void 0:n.messages)||[],keepLastMessageOnError:!0,api:h.getAiURL("chat").toString(),headers:h.headers(),experimental_prepareRequestBody:I=>({...I,...xC({input:I.messages.map(O=>O.content).join(`
159
+ `)}),includeOtherCode:Mc("")}),onFinish:I=>{e(O=>Ku(O,O.activeChatId,I.id,"assistant",I.content,I.parts))},onToolCall:async({toolCall:I})=>{try{const O=await f({toolName:I.toolName,arguments:I.args});return O.result||O.error}catch(O){return mt.error("Tool call failed:",O),`Error: ${O instanceof Error?O.message:String(O)}`}},onError:I=>{mt.error("An error occurred:",I)},onResponse:I=>{mt.debug("Received HTTP response from server:",I)}}),N=w==="submitted"||w==="streaming";M.useEffect(()=>{if(!t.activeChatId||m.length===0)return;const I=m[m.length-1];if((I==null?void 0:I.role)!=="user")return;const O=t.chats.find(R=>R.id===t.activeChatId);if(!O)return;const L=new Set(O.messages.map(R=>R.id)),D=m.filter(R=>R.role==="user"&&!L.has(R.id));D.length>0&&e(R=>{let P=R;for(const z of D)P=Ku(P,R.activeChatId,z.id,"user",z.content);return P})},[m,t.activeChatId,t.chats,e]);const j=N&&m.length>0&&(I=>{if(I.length===0)return!1;const O=I.at(-1);if(!O||O.role!=="assistant"||!O.parts)return!1;const L=O.parts;return L.length===0?!1:L[L.length-1].type==="reasoning"})(m);M.useEffect(()=>{requestAnimationFrame(()=>{if(l.current){const I=l.current;I.scrollTop=I.scrollHeight}})},[t.activeChatId]);const E=(I,O)=>{p(L=>L.slice(0,I)),t.activeChatId&&e(L=>({...L,chats:L.chats.map(D=>D.id===t.activeChatId?{...D,messages:D.messages.slice(0,I),updatedAt:Date.now()}:D)})),b({role:"user",content:O})},T=()=>{r.trim()&&(I=>{const O=Date.now(),L={id:$C(),title:I.length>50?`${I.slice(0,50)}...`:I,messages:[],createdAt:O,updatedAt:O};e(R=>({...R,chats:[...R.chats,L],activeChatId:L.id}));const D=$C();b({id:D,role:"user",content:I}),x("")})(r.trim())};return u.jsxs("div",{className:"flex flex-col h-[calc(100%-53px)]",children:[u.jsx(Gm,{children:u.jsx(rT,{onNewChat:()=>{o(null),x(""),s("")},activeChatId:n==null?void 0:n.id,setActiveChat:o,chats:[...t.chats].sort((I,O)=>O.updatedAt-I.updatedAt)})}),u.jsxs("div",{className:"flex-1 px-3 bg-(--slate-1) gap-4 py-3 flex flex-col overflow-y-auto",ref:l,children:[(!m||m.length===0)&&u.jsxs("div",{className:"flex flex-col rounded-md border bg-background",children:[u.jsx("div",{className:"px-1",children:u.jsx(Fc,{value:r,placeholder:"Ask anything, @ to include context about tables or dataframes",theme:d,onClose:()=>{var I,O;return(O=(I=i.current)==null?void 0:I.editor)==null?void 0:O.blur()},onChange:s,onSubmit:T},"new-thread-input")}),u.jsx(Fh,{input:r,onSendClick:T,isLoading:N,onStop:C})]}),m.map((I,O)=>u.jsx(Gv,{message:I,index:O,theme:d,onEdit:E,setChatState:e,chatState:t,isStreamingReasoning:j,totalMessages:m.length},O)),N&&u.jsx("div",{className:"flex justify-center py-4",children:u.jsx(zc,{className:"h-4 w-4 animate-spin"})}),v&&u.jsxs("div",{className:"flex items-center justify-center space-x-2 mb-4",children:[u.jsx(kr,{error:v}),u.jsx(ve,{variant:"outline",size:"sm",onClick:()=>{S()},children:"Retry"})]}),u.jsx("div",{ref:c})]}),N&&u.jsx("div",{className:"w-full flex justify-center items-center z-20 border-t",children:u.jsx(ve,{variant:"linkDestructive",size:"sm",onClick:C,children:"Stop"})}),m&&m.length>0&&u.jsx(Yv,{input:g,setInput:x,onSubmit:(I,O)=>{O.trim()&&y(I)},theme:d,inputRef:a,isLoading:N,onStop:C})]})};function aT(){}function lT(){}function cT(t){return u.jsx(fs,{value:t.value,className:"text-xs",subtitle:u.jsx("div",{className:"text-muted-foreground text-xs pl-2",children:t.subtitle}),children:t.label},t.value)}function dT(t){return u.jsx(fs,{value:t,className:"text-sm",children:t},t)}function Qt(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n,o=0;o<t.length;o++)(n=Qt(t[o]))!==""&&(e+=(e&&" ")+n);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}const{useDebugValue:uT}=q,{useSyncExternalStoreWithSelector:hT}=aL,fT=t=>t;function Kv(t,e=fT,n){const o=hT(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return uT(o),o}const Xv=(t,e)=>{const n=lL(t),o=(r,s=e)=>Kv(n,r,s);return Object.assign(o,n),o};function Wt(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[o,r]of t)if(!Object.is(r,e.get(o)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const o of t)if(!e.has(o))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(e,o)||!Object.is(t[o],e[o]))return!1;return!0}function Kn(t,e){if(t=function(s){let i;for(;i=s.sourceEvent;)s=i;return s}(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=t.clientX,o.y=t.clientY,[(o=o.matrixTransform(e.getScreenCTM().inverse())).x,o.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}const mT={passive:!1},wi={capture:!0,passive:!1};function zh(t){t.stopImmediatePropagation()}function Xr(t){t.preventDefault(),t.stopImmediatePropagation()}function Jv(t){var e=t.document.documentElement,n=Vn(t).on("dragstart.drag",Xr,wi);"onselectstart"in e?n.on("selectstart.drag",Xr,wi):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Zv(t,e){var n=t.document.documentElement,o=Vn(t).on("dragstart.drag",null);e&&(o.on("click.drag",Xr,wi),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const zl=t=>()=>t;function Bh(t,{sourceEvent:e,subject:n,target:o,identifier:r,active:s,x:i,y:a,dx:l,dy:c,dispatch:d}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,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 pT(t){return!t.ctrlKey&&!t.button}function gT(){return this.parentNode}function xT(t,e){return e??{x:t.x,y:t.y}}function bT(){return navigator.maxTouchPoints||"ontouchstart"in this}Bh.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};const Bl=t=>()=>t;function yT(t,{sourceEvent:e,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Uh(t){t.stopImmediatePropagation()}function ki(t){t.preventDefault(),t.stopImmediatePropagation()}function vT(t){return!(t.ctrlKey&&t.type!=="wheel"||t.button)}function wT(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function Qv(){return this.__zoom||er}function kT(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function CT(){return navigator.maxTouchPoints||"ontouchstart"in this}function jT(t,e,n){var o=t.invertX(e[0][0])-n[0][0],r=t.invertX(e[1][0])-n[1][0],s=t.invertY(e[0][1])-n[0][1],i=t.invertY(e[1][1])-n[1][1];return t.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}const Ul=M.createContext(null),ST=Ul.Provider,NT=t=>`Node type "${t}" not found. Using fallback type "default".`,ET=()=>"The React Flow parent container needs a width and a height to render the graph.",_T=()=>"Only child nodes can use a parent extent.",IT=t=>`Marker type "${t}" doesn't exist.`,AT=(t,e)=>`Couldn't create edge for ${t?"target":"source"} handle id: "${t?e.targetHandle:e.sourceHandle}", edge id: ${e.id}.`,TT=()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",MT=t=>`Edge type "${t}" not found. Using fallback type "default".`,OT=t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,e2="[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001";function dt(t,e){const n=M.useContext(Ul);if(n===null)throw new Error(e2);return Kv(n,t,e)}const zt=()=>{const t=M.useContext(Ul);if(t===null)throw new Error(e2);return M.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy}),[t])},DT=t=>t.userSelectionActive?"none":"all";function $l({position:t,children:e,className:n,style:o,...r}){const s=dt(DT),i=`${t}`.split("-");return q.createElement("div",{className:Qt(["react-flow__panel",n,...i]),style:{...o,pointerEvents:s},...r},e)}function RT({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:q.createElement($l,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},q.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}var PT=M.memo(({x:t,y:e,label:n,labelStyle:o={},labelShowBg:r=!0,labelBgStyle:s={},labelBgPadding:i=[2,4],labelBgBorderRadius:a=2,children:l,className:c,...d})=>{const h=M.useRef(null),[f,m]=M.useState({x:0,y:0,width:0,height:0}),g=Qt(["react-flow__edge-textwrapper",c]);return M.useEffect(()=>{if(h.current){const x=h.current.getBBox();m({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),n!==void 0&&n?q.createElement("g",{transform:`translate(${t-f.width/2} ${e-f.height/2})`,className:g,visibility:f.width?"visible":"hidden",...d},r&&q.createElement("rect",{width:f.width+2*i[0],x:-i[0],y:-i[1],height:f.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:a,ry:a}),q.createElement("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:h,style:o},n),l):null});const $h=t=>({width:t.offsetWidth,height:t.offsetHeight}),Jr=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),Vh=(t={x:0,y:0},e)=>({x:Jr(t.x,e[0][0],e[1][0]),y:Jr(t.y,e[0][1],e[1][1])}),t2=(t,e,n)=>t<e?Jr(Math.abs(t-e),1,50)/50:t>n?-Jr(Math.abs(t-n),1,50)/50:0,n2=(t,e)=>[20*t2(t.x,35,e.width-35),20*t2(t.y,35,e.height-35)],o2=t=>{var e;return((e=t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},Hh=({x:t,y:e,width:n,height:o})=>({x:t,y:e,x2:t+n,y2:e+o}),r2=t=>({...t.positionAbsolute||{x:0,y:0},width:t.width||0,height:t.height||0}),Wh=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),o=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*o)},Nn=t=>!isNaN(t)&&isFinite(t),yt=Symbol.for("internals"),s2=["Enter"," ","Escape"];function qh(t){var o,r;const e=(s=>"nativeEvent"in s)(t)?t.nativeEvent:t,n=((r=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:r[0])||t.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const i2=t=>"clientX"in t,zo=(t,e)=>{var s,i;const n=i2(t),o=n?t.clientX:(s=t.touches)==null?void 0:s[0].clientX,r=n?t.clientY:(i=t.touches)==null?void 0:i[0].clientY;return{x:o-((e==null?void 0:e.left)??0),y:r-((e==null?void 0:e.top)??0)}},Vl=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0},Ci=({id:t,path:e,labelX:n,labelY:o,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m=20})=>q.createElement(q.Fragment,null,q.createElement("path",{id:t,style:d,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:f}),m&&q.createElement("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),r&&Nn(n)&&Nn(o)?q.createElement(PT,{x:n,y:o,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null);function ji(t,e,n){return n===void 0?n:o=>{const r=e().edges.find(s=>s.id===t);r&&n(o,{...r})}}function a2({sourceX:t,sourceY:e,targetX:n,targetY:o}){const r=Math.abs(n-t)/2,s=n<t?n+r:n-r,i=Math.abs(o-e)/2;return[s,o<e?o+i:o-i,r,i]}function l2({sourceX:t,sourceY:e,targetX:n,targetY:o,sourceControlX:r,sourceControlY:s,targetControlX:i,targetControlY:a}){const l=.125*t+.375*r+.375*i+.125*n,c=.125*e+.375*s+.375*a+.125*o;return[l,c,Math.abs(l-t),Math.abs(c-e)]}var fr,c2,Bo,Gh,Si,d2,Uo,Ni,Zr,u2,Oe,Hl;function h2({pos:t,x1:e,y1:n,x2:o,y2:r}){return t===Oe.Left||t===Oe.Right?[.5*(e+o),n]:[e,.5*(n+r)]}function f2({sourceX:t,sourceY:e,sourcePosition:n=Oe.Bottom,targetX:o,targetY:r,targetPosition:s=Oe.Top}){const[i,a]=h2({pos:n,x1:t,y1:e,x2:o,y2:r}),[l,c]=h2({pos:s,x1:o,y1:r,x2:t,y2:e}),[d,h,f,m]=l2({sourceX:t,sourceY:e,targetX:o,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:l,targetControlY:c});return[`M${t},${e} C${i},${a} ${l},${c} ${o},${r}`,d,h,f,m]}Ci.displayName="BaseEdge",(c2=fr||(fr={})).Strict="strict",c2.Loose="loose",(Gh=Bo||(Bo={})).Free="free",Gh.Vertical="vertical",Gh.Horizontal="horizontal",(d2=Si||(Si={})).Partial="partial",d2.Full="full",(Ni=Uo||(Uo={})).Bezier="default",Ni.Straight="straight",Ni.Step="step",Ni.SmoothStep="smoothstep",Ni.SimpleBezier="simplebezier",(u2=Zr||(Zr={})).Arrow="arrow",u2.ArrowClosed="arrowclosed",(Hl=Oe||(Oe={})).Left="left",Hl.Top="top",Hl.Right="right",Hl.Bottom="bottom";const Yh=M.memo(({sourceX:t,sourceY:e,targetX:n,targetY:o,sourcePosition:r=Oe.Bottom,targetPosition:s=Oe.Top,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:g,interactionWidth:x})=>{const[p,b,y]=f2({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:o,targetPosition:s});return q.createElement(Ci,{path:p,labelX:b,labelY:y,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:g,interactionWidth:x})});Yh.displayName="SimpleBezierEdge";const m2={[Oe.Left]:{x:-1,y:0},[Oe.Right]:{x:1,y:0},[Oe.Top]:{x:0,y:-1},[Oe.Bottom]:{x:0,y:1}},p2=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function LT({source:t,sourcePosition:e=Oe.Bottom,target:n,targetPosition:o=Oe.Top,center:r,offset:s}){const i=m2[e],a=m2[o],l={x:t.x+i.x*s,y:t.y+i.y*s},c={x:n.x+a.x*s,y:n.y+a.y*s},d=(({source:C,sourcePosition:N=Oe.Bottom,target:j})=>N===Oe.Left||N===Oe.Right?C.x<j.x?{x:1,y:0}:{x:-1,y:0}:C.y<j.y?{x:0,y:1}:{x:0,y:-1})({source:l,sourcePosition:e,target:c}),h=d.x!==0?"x":"y",f=d[h];let m,g,x=[];const p={x:0,y:0},b={x:0,y:0},[y,v,w,S]=a2({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(i[h]*a[h]===-1){m=r.x??y,g=r.y??v;const C=[{x:m,y:l.y},{x:m,y:c.y}],N=[{x:l.x,y:g},{x:c.x,y:g}];x=i[h]===f?h==="x"?C:N:h==="x"?N:C}else{const C=[{x:l.x,y:c.y}],N=[{x:c.x,y:l.y}];if(x=h==="x"?i.x===f?N:C:i.y===f?C:N,e===o){const T=Math.abs(t[h]-n[h]);if(T<=s){const I=Math.min(s-1,s-T);i[h]===f?p[h]=(l[h]>t[h]?-1:1)*I:b[h]=(c[h]>n[h]?-1:1)*I}}if(e!==o){const T=h==="x"?"y":"x",I=i[h]===a[T],O=l[T]>c[T],L=l[T]<c[T];(i[h]===1&&(!I&&O||I&&L)||i[h]!==1&&(!I&&L||I&&O))&&(x=h==="x"?C:N)}const j={x:l.x+p.x,y:l.y+p.y},E={x:c.x+b.x,y:c.y+b.y};Math.max(Math.abs(j.x-x[0].x),Math.abs(E.x-x[0].x))>=Math.max(Math.abs(j.y-x[0].y),Math.abs(E.y-x[0].y))?(m=(j.x+E.x)/2,g=x[0].y):(m=x[0].x,g=(j.y+E.y)/2)}return[[t,{x:l.x+p.x,y:l.y+p.y},...x,{x:c.x+b.x,y:c.y+b.y},n],m,g,w,S]}function Kh({sourceX:t,sourceY:e,sourcePosition:n=Oe.Bottom,targetX:o,targetY:r,targetPosition:s=Oe.Top,borderRadius:i=5,centerX:a,centerY:l,offset:c=20}){const[d,h,f,m,g]=LT({source:{x:t,y:e},sourcePosition:n,target:{x:o,y:r},targetPosition:s,center:{x:a,y:l},offset:c});return[d.reduce((x,p,b)=>{let y="";return y=b>0&&b<d.length-1?function(v,w,S,C){const N=Math.min(p2(v,w)/2,p2(w,S)/2,C),{x:j,y:E}=w;if(v.x===j&&j===S.x||v.y===E&&E===S.y)return`L${j} ${E}`;if(v.y===E)return`L ${j+N*(v.x<S.x?-1:1)},${E}Q ${j},${E} ${j},${E+N*(v.y<S.y?1:-1)}`;const T=v.x<S.x?1:-1;return`L ${j},${E+N*(v.y<S.y?-1:1)}Q ${j},${E} ${j+N*T},${E}`}(d[b-1],p,d[b+1],i):`${b===0?"M":"L"}${p.x} ${p.y}`,x+=y},""),h,f,m,g]}const Wl=M.memo(({sourceX:t,sourceY:e,targetX:n,targetY:o,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,sourcePosition:h=Oe.Bottom,targetPosition:f=Oe.Top,markerEnd:m,markerStart:g,pathOptions:x,interactionWidth:p})=>{const[b,y,v]=Kh({sourceX:t,sourceY:e,sourcePosition:h,targetX:n,targetY:o,targetPosition:f,borderRadius:x==null?void 0:x.borderRadius,offset:x==null?void 0:x.offset});return q.createElement(Ci,{path:b,labelX:y,labelY:v,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:m,markerStart:g,interactionWidth:p})});Wl.displayName="SmoothStepEdge";const Xh=M.memo(t=>{var e;return q.createElement(Wl,{...t,pathOptions:M.useMemo(()=>{var n;return{borderRadius:0,offset:(n=t.pathOptions)==null?void 0:n.offset}},[(e=t.pathOptions)==null?void 0:e.offset])})});Xh.displayName="StepEdge";const Jh=M.memo(({sourceX:t,sourceY:e,targetX:n,targetY:o,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m})=>{const[g,x,p]=function({sourceX:b,sourceY:y,targetX:v,targetY:w}){const[S,C,N,j]=a2({sourceX:b,sourceY:y,targetX:v,targetY:w});return[`M ${b},${y}L ${v},${w}`,S,C,N,j]}({sourceX:t,sourceY:e,targetX:n,targetY:o});return q.createElement(Ci,{path:g,labelX:x,labelY:p,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m})});function ql(t,e){return t>=0?.5*t:25*e*Math.sqrt(-t)}function g2({pos:t,x1:e,y1:n,x2:o,y2:r,c:s}){switch(t){case Oe.Left:return[e-ql(e-o,s),n];case Oe.Right:return[e+ql(o-e,s),n];case Oe.Top:return[e,n-ql(n-r,s)];case Oe.Bottom:return[e,n+ql(r-n,s)]}}function x2({sourceX:t,sourceY:e,sourcePosition:n=Oe.Bottom,targetX:o,targetY:r,targetPosition:s=Oe.Top,curvature:i=.25}){const[a,l]=g2({pos:n,x1:t,y1:e,x2:o,y2:r,c:i}),[c,d]=g2({pos:s,x1:o,y1:r,x2:t,y2:e,c:i}),[h,f,m,g]=l2({sourceX:t,sourceY:e,targetX:o,targetY:r,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${t},${e} C${a},${l} ${c},${d} ${o},${r}`,h,f,m,g]}Jh.displayName="StraightEdge";const Gl=M.memo(({sourceX:t,sourceY:e,targetX:n,targetY:o,sourcePosition:r=Oe.Bottom,targetPosition:s=Oe.Top,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:g,pathOptions:x,interactionWidth:p})=>{const[b,y,v]=x2({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:o,targetPosition:s,curvature:x==null?void 0:x.curvature});return q.createElement(Ci,{path:b,labelX:y,labelY:v,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:g,interactionWidth:p})});Gl.displayName="BezierEdge";const Zh=M.createContext(null),FT=Zh.Provider;Zh.Consumer;const zT=({source:t,sourceHandle:e,target:n,targetHandle:o})=>`reactflow__edge-${t}${e||""}-${n}${o||""}`,Qh=(t,e)=>t===void 0?"":typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(n=>`${n}=${t[n]}`).join("&")}`,ef=({x:t,y:e},[n,o,r],s,[i,a])=>{const l={x:(t-n)/r,y:(e-o)/r};return s?{x:i*Math.round(l.x/i),y:a*Math.round(l.y/a)}:l},b2=({x:t,y:e},[n,o,r])=>({x:t*r+n,y:e*r+o}),Qr=(t,e=[0,0])=>{if(!t)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(t.width??0)*e[0],o=(t.height??0)*e[1],r={x:t.position.x-n,y:t.position.y-o};return{...r,positionAbsolute:t.positionAbsolute?{x:t.positionAbsolute.x-n,y:t.positionAbsolute.y-o}:r}},tf=(t,e=[0,0])=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((o,r)=>{const{x:s,y:i}=Qr(r,e).positionAbsolute;return a=o,l=Hh({x:s,y:i,width:r.width||0,height:r.height||0}),{x:Math.min(a.x,l.x),y:Math.min(a.y,l.y),x2:Math.max(a.x2,l.x2),y2:Math.max(a.y2,l.y2)};var a,l},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return(({x:o,y:r,x2:s,y2:i})=>({x:o,y:r,width:s-o,height:i-r}))(n)},y2=(t,e,[n,o,r]=[0,0,1],s=!1,i=!1,a=[0,0])=>{const l={x:(e.x-n)/r,y:(e.y-o)/r,width:e.width/r,height:e.height/r},c=[];return t.forEach(d=>{const{width:h,height:f,selectable:m=!0,hidden:g=!1}=d;if(i&&!m||g)return!1;const{positionAbsolute:x}=Qr(d,a),p={x:x.x,y:x.y,width:h||0,height:f||0},b=Wh(l,p);(h===void 0||f===void 0||h===null||f===null||s&&b>0||b>=(h||0)*(f||0)||d.dragging)&&c.push(d)}),c},v2=(t,e)=>{const n=t.map(o=>o.id);return e.filter(o=>n.includes(o.source)||n.includes(o.target))},w2=(t,e,n,o,r,s=.1)=>{const i=e/(t.width*(1+s)),a=n/(t.height*(1+s)),l=Math.min(i,a),c=Jr(l,o,r);return{x:e/2-(t.x+t.width/2)*c,y:n/2-(t.y+t.height/2)*c,zoom:c}},mr=(t,e=0)=>t.transition().duration(e);function k2(t,e,n,o){return(e[n]||[]).reduce((r,s)=>{var i,a;return`${t.id}-${s.id}-${n}`!==o&&r.push({id:s.id||null,type:n,nodeId:t.id,x:(((i=t.positionAbsolute)==null?void 0:i.x)??0)+s.x+s.width/2,y:(((a=t.positionAbsolute)==null?void 0:a.y)??0)+s.y+s.height/2}),r},[])}const BT={source:null,target:null,sourceHandle:null,targetHandle:null},C2=()=>({handleDomNode:null,isValid:!1,connection:BT,endHandle:null});function j2(t,e,n,o,r,s,i){const a=r==="target",l=i.querySelector(`.react-flow__handle[data-id="${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`),c={...C2(),handleDomNode:l};if(l){const d=nf(void 0,l),h=l.getAttribute("data-nodeid"),f=l.getAttribute("data-handleid"),m=l.classList.contains("connectable"),g=l.classList.contains("connectableend"),x={source:a?h:n,sourceHandle:a?f:o,target:a?n:h,targetHandle:a?o:f};c.connection=x,m&&g&&(e===fr.Strict?a&&d==="source"||!a&&d==="target":h!==n||f!==o)&&(c.endHandle={nodeId:h,handleId:f,type:d},c.isValid=s(x))}return c}function nf(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function of(t){t==null||t.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function UT(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}function S2({event:t,handleId:e,nodeId:n,onConnect:o,isTarget:r,getState:s,setState:i,isValidConnection:a,edgeUpdaterType:l,onReconnectEnd:c}){const d=o2(t.target),{connectionMode:h,domNode:f,autoPanOnConnect:m,connectionRadius:g,onConnectStart:x,panBy:p,getNodes:b,cancelConnection:y}=s();let v,w=0;const{x:S,y:C}=zo(t),N=d==null?void 0:d.elementFromPoint(S,C),j=nf(l,N),E=f==null?void 0:f.getBoundingClientRect();if(!E||!j)return;let T,I=zo(t,E),O=!1,L=null,D=!1,R=null;const P=function({nodes:B,nodeId:A,handleId:U,handleType:$}){return B.reduce((X,Y)=>{if(Y[yt]){const{handleBounds:G}=Y[yt];let W=[],J=[];G&&(W=k2(Y,G,"source",`${A}-${U}-${$}`),J=k2(Y,G,"target",`${A}-${U}-${$}`)),X.push(...W,...J)}return X},[])}({nodes:b(),nodeId:n,handleId:e,handleType:j}),z=()=>{if(!m)return;const[B,A]=n2(I,E);p({x:B,y:A}),w=requestAnimationFrame(z)};function _(B){const{transform:A}=s();I=zo(B,E);const{handle:U,validHandleResult:$}=function(X,Y,G,W,J,V){const{x:Q,y:te}=zo(X),re=Y.elementsFromPoint(Q,te).find(ge=>ge.classList.contains("react-flow__handle"));if(re){const ge=re.getAttribute("data-nodeid");if(ge){const oe=nf(void 0,re),ue=re.getAttribute("data-handleid"),de=V({nodeId:ge,id:ue,type:oe});if(de){const Se=J.find(Te=>Te.nodeId===ge&&Te.type===oe&&Te.id===ue);return{handle:{id:ue,type:oe,nodeId:ge,x:(Se==null?void 0:Se.x)||G.x,y:(Se==null?void 0:Se.y)||G.y},validHandleResult:de}}}}let ne=[],ie=1/0;if(J.forEach(ge=>{const oe=Math.sqrt((ge.x-G.x)**2+(ge.y-G.y)**2);if(oe<=W){const ue=V(ge);oe<=ie&&(oe<ie?ne=[{handle:ge,validHandleResult:ue}]:oe===ie&&ne.push({handle:ge,validHandleResult:ue}),ie=oe)}}),!ne.length)return{handle:null,validHandleResult:C2()};if(ne.length===1)return ne[0];const se=ne.some(({validHandleResult:ge})=>ge.isValid),ae=ne.some(({handle:ge})=>ge.type==="target");return ne.find(({handle:ge,validHandleResult:oe})=>ae?ge.type==="target":!se||oe.isValid)||ne[0]}(B,d,ef(I,A,!1,[1,1]),g,P,X=>j2(X,h,n,e,r?"target":"source",a,d));if(v=U,O||(z(),O=!0),R=$.handleDomNode,L=$.connection,D=$.isValid,i({connectionPosition:v&&D?b2({x:v.x,y:v.y},A):I,connectionStatus:UT(!!v,D),connectionEndHandle:$.endHandle}),!v&&!D&&!R)return of(T);L.source!==L.target&&R&&(of(T),T=R,R.classList.add("connecting","react-flow__handle-connecting"),R.classList.toggle("valid",D),R.classList.toggle("react-flow__handle-valid",D))}function k(B){var A,U;(v||R)&&L&&D&&(o==null||o(L)),(U=(A=s()).onConnectEnd)==null||U.call(A,B),l&&(c==null||c(B)),of(T),y(),cancelAnimationFrame(w),O=!1,D=!1,L=null,R=null,d.removeEventListener("mousemove",_),d.removeEventListener("mouseup",k),d.removeEventListener("touchmove",_),d.removeEventListener("touchend",k)}i({connectionPosition:I,connectionStatus:null,connectionNodeId:n,connectionHandleId:e,connectionHandleType:j,connectionStartHandle:{nodeId:n,handleId:e,type:j},connectionEndHandle:null}),x==null||x(t,{nodeId:n,handleId:e,handleType:j}),d.addEventListener("mousemove",_),d.addEventListener("mouseup",k),d.addEventListener("touchmove",_),d.addEventListener("touchend",k)}const N2=()=>!0,$T=t=>({connectionStartHandle:t.connectionStartHandle,connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName}),E2=M.forwardRef(({type:t="source",position:e=Oe.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:s=!0,id:i,onConnect:a,children:l,className:c,onMouseDown:d,onTouchStart:h,...f},m)=>{var j,E;const g=i||null,x=t==="target",p=zt(),b=M.useContext(Zh),{connectOnClick:y,noPanClassName:v}=dt($T,Wt),{connecting:w,clickConnecting:S}=dt(((T,I,O)=>L=>{const{connectionStartHandle:D,connectionEndHandle:R,connectionClickStartHandle:P}=L;return{connecting:(D==null?void 0:D.nodeId)===T&&(D==null?void 0:D.handleId)===I&&(D==null?void 0:D.type)===O||(R==null?void 0:R.nodeId)===T&&(R==null?void 0:R.handleId)===I&&(R==null?void 0:R.type)===O,clickConnecting:(P==null?void 0:P.nodeId)===T&&(P==null?void 0:P.handleId)===I&&(P==null?void 0:P.type)===O}})(b,g,t),Wt);b||((E=(j=p.getState()).onError)==null||E.call(j,"010",TT()));const C=T=>{const{defaultEdgeOptions:I,onConnect:O,hasDefaultEdges:L}=p.getState(),D={...I,...T};if(L){const{edges:R,setEdges:P}=p.getState();P(((z,_)=>{if(!z.source||!z.target)return _;let k;return k=(B=>"id"in B&&"source"in B&&"target"in B)(z)?{...z}:{...z,id:zT(z)},((B,A)=>A.some(U=>!(U.source!==B.source||U.target!==B.target||U.sourceHandle!==B.sourceHandle&&(U.sourceHandle||B.sourceHandle)||U.targetHandle!==B.targetHandle&&(U.targetHandle||B.targetHandle))))(k,_)?_:_.concat(k)})(D,R))}O==null||O(D),a==null||a(D)},N=T=>{if(!b)return;const I=i2(T);r&&(I&&T.button===0||!I)&&S2({event:T,handleId:g,nodeId:b,onConnect:C,isTarget:x,getState:p.getState,setState:p.setState,isValidConnection:n||p.getState().isValidConnection||N2}),I?d==null||d(T):h==null||h(T)};return q.createElement("div",{"data-handleid":g,"data-nodeid":b,"data-handlepos":e,"data-id":`${b}-${g}-${t}`,className:Qt(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",v,c,{source:!x,target:x,connectable:o,connectablestart:r,connectableend:s,connecting:S,connectionindicator:o&&(r&&!w||s&&w)}]),onMouseDown:N,onTouchStart:N,onClick:y?T=>{const{onClickConnectStart:I,onClickConnectEnd:O,connectionClickStartHandle:L,connectionMode:D,isValidConnection:R}=p.getState();if(!b||!L&&!r)return;if(!L)return I==null||I(T,{nodeId:b,handleId:g,handleType:t}),void p.setState({connectionClickStartHandle:{nodeId:b,type:t,handleId:g}});const P=o2(T.target),z=n||R||N2,{connection:_,isValid:k}=j2({nodeId:b,id:g,type:t},D,L.nodeId,L.handleId||null,L.type,z,P);k&&C(_),O==null||O(T),p.setState({connectionClickStartHandle:null})}:void 0,ref:m,...f},l)});E2.displayName="Handle";var $o=M.memo(E2);const _2=({data:t,isConnectable:e,targetPosition:n=Oe.Top,sourcePosition:o=Oe.Bottom})=>q.createElement(q.Fragment,null,q.createElement($o,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,q.createElement($o,{type:"source",position:o,isConnectable:e}));_2.displayName="DefaultNode";var rf=M.memo(_2);const I2=({data:t,isConnectable:e,sourcePosition:n=Oe.Bottom})=>q.createElement(q.Fragment,null,t==null?void 0:t.label,q.createElement($o,{type:"source",position:n,isConnectable:e}));I2.displayName="InputNode";var A2=M.memo(I2);const T2=({data:t,isConnectable:e,targetPosition:n=Oe.Top})=>q.createElement(q.Fragment,null,q.createElement($o,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label);T2.displayName="OutputNode";var M2=M.memo(T2);const sf=()=>null;sf.displayName="GroupNode";const VT=t=>({selectedNodes:t.getNodes().filter(e=>e.selected),selectedEdges:t.edges.filter(e=>e.selected).map(e=>({...e}))}),Yl=t=>t.id;function HT(t,e){return Wt(t.selectedNodes.map(Yl),e.selectedNodes.map(Yl))&&Wt(t.selectedEdges.map(Yl),e.selectedEdges.map(Yl))}const O2=M.memo(({onSelectionChange:t})=>{const e=zt(),{selectedNodes:n,selectedEdges:o}=dt(VT,HT);return M.useEffect(()=>{const r={nodes:n,edges:o};t==null||t(r),e.getState().onSelectionChange.forEach(s=>s(r))},[n,o,t]),null});O2.displayName="SelectionListener";const WT=t=>!!t.onSelectionChange;function qT({onSelectionChange:t}){const e=dt(WT);return t||e?q.createElement(O2,{onSelectionChange:t}):null}const GT=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset});function es(t,e){M.useEffect(()=>{t!==void 0&&e(t)},[t])}function Ze(t,e,n){M.useEffect(()=>{e!==void 0&&n({[t]:e})},[e])}const YT=({nodes:t,edges:e,defaultNodes:n,defaultEdges:o,onConnect:r,onConnectStart:s,onConnectEnd:i,onClickConnectStart:a,onClickConnectEnd:l,nodesDraggable:c,nodesConnectable:d,nodesFocusable:h,edgesFocusable:f,edgesUpdatable:m,elevateNodesOnSelect:g,minZoom:x,maxZoom:p,nodeExtent:b,onNodesChange:y,onEdgesChange:v,elementsSelectable:w,connectionMode:S,snapGrid:C,snapToGrid:N,translateExtent:j,connectOnClick:E,defaultEdgeOptions:T,fitView:I,fitViewOptions:O,onNodesDelete:L,onEdgesDelete:D,onNodeDrag:R,onNodeDragStart:P,onNodeDragStop:z,onSelectionDrag:_,onSelectionDragStart:k,onSelectionDragStop:B,noPanClassName:A,nodeOrigin:U,rfId:$,autoPanOnConnect:X,autoPanOnNodeDrag:Y,onError:G,connectionRadius:W,isValidConnection:J,nodeDragThreshold:V})=>{const{setNodes:Q,setEdges:te,setDefaultNodesAndEdges:re,setMinZoom:ne,setMaxZoom:ie,setTranslateExtent:se,setNodeExtent:ae,reset:ge}=dt(GT,Wt),oe=zt();return M.useEffect(()=>{const ue=o==null?void 0:o.map(de=>({...de,...T}));return re(n,ue),()=>{ge()}},[]),Ze("defaultEdgeOptions",T,oe.setState),Ze("connectionMode",S,oe.setState),Ze("onConnect",r,oe.setState),Ze("onConnectStart",s,oe.setState),Ze("onConnectEnd",i,oe.setState),Ze("onClickConnectStart",a,oe.setState),Ze("onClickConnectEnd",l,oe.setState),Ze("nodesDraggable",c,oe.setState),Ze("nodesConnectable",d,oe.setState),Ze("nodesFocusable",h,oe.setState),Ze("edgesFocusable",f,oe.setState),Ze("edgesUpdatable",m,oe.setState),Ze("elementsSelectable",w,oe.setState),Ze("elevateNodesOnSelect",g,oe.setState),Ze("snapToGrid",N,oe.setState),Ze("snapGrid",C,oe.setState),Ze("onNodesChange",y,oe.setState),Ze("onEdgesChange",v,oe.setState),Ze("connectOnClick",E,oe.setState),Ze("fitViewOnInit",I,oe.setState),Ze("fitViewOnInitOptions",O,oe.setState),Ze("onNodesDelete",L,oe.setState),Ze("onEdgesDelete",D,oe.setState),Ze("onNodeDrag",R,oe.setState),Ze("onNodeDragStart",P,oe.setState),Ze("onNodeDragStop",z,oe.setState),Ze("onSelectionDrag",_,oe.setState),Ze("onSelectionDragStart",k,oe.setState),Ze("onSelectionDragStop",B,oe.setState),Ze("noPanClassName",A,oe.setState),Ze("nodeOrigin",U,oe.setState),Ze("rfId",$,oe.setState),Ze("autoPanOnConnect",X,oe.setState),Ze("autoPanOnNodeDrag",Y,oe.setState),Ze("onError",G,oe.setState),Ze("connectionRadius",W,oe.setState),Ze("isValidConnection",J,oe.setState),Ze("nodeDragThreshold",V,oe.setState),es(t,Q),es(e,te),es(x,ne),es(p,ie),es(j,se),es(b,ae),null},D2={display:"none"},KT={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},R2="react-flow__node-desc",P2="react-flow__edge-desc",XT=t=>t.ariaLiveMessage;function JT({rfId:t}){const e=dt(XT);return q.createElement("div",{id:`react-flow__aria-live-${t}`,"aria-live":"assertive","aria-atomic":"true",style:KT},e)}function ZT({rfId:t,disableKeyboardA11y:e}){return q.createElement(q.Fragment,null,q.createElement("div",{id:`${R2}-${t}`,style:D2},"Press enter or space to select a node.",!e&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),q.createElement("div",{id:`${P2}-${t}`,style:D2},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!e&&q.createElement(JT,{rfId:t}))}var Ei=(t=null,e={actInsideInputWithModifier:!0})=>{const[n,o]=M.useState(!1),r=M.useRef(!1),s=M.useRef(new Set([])),[i,a]=M.useMemo(()=>{if(t!==null){const l=(Array.isArray(t)?t:[t]).filter(d=>typeof d=="string").map(d=>d.split("+")),c=l.reduce((d,h)=>d.concat(...h),[]);return[l,c]}return[[],[]]},[t]);return M.useEffect(()=>{const l=typeof document<"u"?document:null,c=(e==null?void 0:e.target)||l;if(t!==null){const d=m=>{if(r.current=m.ctrlKey||m.metaKey||m.shiftKey,(!r.current||r.current&&!e.actInsideInputWithModifier)&&qh(m))return!1;const g=F2(m.code,a);s.current.add(m[g]),L2(i,s.current,!1)&&(m.preventDefault(),o(!0))},h=m=>{if((!r.current||r.current&&!e.actInsideInputWithModifier)&&qh(m))return!1;const g=F2(m.code,a);L2(i,s.current,!0)?(o(!1),s.current.clear()):s.current.delete(m[g]),m.key==="Meta"&&s.current.clear(),r.current=!1},f=()=>{s.current.clear(),o(!1)};return c==null||c.addEventListener("keydown",d),c==null||c.addEventListener("keyup",h),window.addEventListener("blur",f),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",h),window.removeEventListener("blur",f)}}},[t,o]),n};function L2(t,e,n){return t.filter(o=>n||o.length===e.size).some(o=>o.every(r=>e.has(r)))}function F2(t,e){return e.includes(t)?"code":"key"}function z2(t,e,n,o){var a,l;const r=t.parentNode||t.parentId;if(!r)return n;const s=e.get(r),i=Qr(s,o);return z2(s,e,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((a=s[yt])==null?void 0:a.z)??0)>(n.z??0)?((l=s[yt])==null?void 0:l.z)??0:n.z??0},o)}function B2(t,e,n){t.forEach(o=>{var s;const r=o.parentNode||o.parentId;if(r&&!t.has(r))throw new Error(`Parent node ${r} not found`);if(r||n!=null&&n[o.id]){const{x:i,y:a,z:l}=z2(o,t,{...o.position,z:((s=o[yt])==null?void 0:s.z)??0},e);o.positionAbsolute={x:i,y:a},o[yt].z=l,n!=null&&n[o.id]&&(o[yt].isParent=!0)}})}function af(t,e,n,o){const r=new Map,s={},i=o?1e3:0;return t.forEach(a=>{var m;const l=(Nn(a.zIndex)?a.zIndex:0)+(a.selected?i:0),c=e.get(a.id),d={...a,positionAbsolute:{x:a.position.x,y:a.position.y}},h=a.parentNode||a.parentId;h&&(s[h]=!0);const f=(c==null?void 0:c.type)&&(c==null?void 0:c.type)!==a.type;Object.defineProperty(d,yt,{enumerable:!1,value:{handleBounds:f||(m=c==null?void 0:c[yt])==null?void 0:m.handleBounds,z:l}}),r.set(a.id,d)}),B2(r,n,s),r}function U2(t,e={}){const{getNodes:n,width:o,height:r,minZoom:s,maxZoom:i,d3Zoom:a,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:d,nodeOrigin:h}=t(),f=e.initial&&!c&&d;if(a&&l&&(f||!e.initial)){const m=n().filter(x=>{var b;const p=e.includeHiddenNodes?x.width&&x.height:!x.hidden;return(b=e.nodes)!=null&&b.length?p&&e.nodes.some(y=>y.id===x.id):p}),g=m.every(x=>x.width&&x.height);if(m.length>0&&g){const x=tf(m,h),{x:p,y:b,zoom:y}=w2(x,o,r,e.minZoom??s,e.maxZoom??i,e.padding??.1),v=er.translate(p,b).scale(y);return typeof e.duration=="number"&&e.duration>0?a.transform(mr(l,e.duration),v):a.transform(l,v),!0}}return!1}function QT(t,e){return t.forEach(n=>{const o=e.get(n.id);o&&e.set(o.id,{...o,[yt]:o[yt],selected:n.selected})}),new Map(e)}function eM(t,e){return e.map(n=>{const o=t.find(r=>r.id===n.id);return o&&(n.selected=o.selected),n})}function Kl({changedNodes:t,changedEdges:e,get:n,set:o}){const{nodeInternals:r,edges:s,onNodesChange:i,onEdgesChange:a,hasDefaultNodes:l,hasDefaultEdges:c}=n();t!=null&&t.length&&(l&&o({nodeInternals:QT(t,r)}),i==null||i(t)),e!=null&&e.length&&(c&&o({edges:eM(e,s)}),a==null||a(e))}const ts=()=>{},tM={zoomIn:ts,zoomOut:ts,zoomTo:ts,getZoom:()=>1,setViewport:ts,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:ts,fitBounds:ts,project:t=>t,screenToFlowPosition:t=>t,flowToScreenPosition:t=>t,viewportInitialized:!1},nM=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection});function _i(){const t=(()=>{const x=zt(),{d3Zoom:p,d3Selection:b}=dt(nM,Wt);return M.useMemo(()=>b&&p?{zoomIn:v=>p.scaleBy(mr(b,v==null?void 0:v.duration),1.2),zoomOut:v=>p.scaleBy(mr(b,v==null?void 0:v.duration),1/1.2),zoomTo:(v,w)=>p.scaleTo(mr(b,w==null?void 0:w.duration),v),getZoom:()=>x.getState().transform[2],setViewport:(v,w)=>{const[S,C,N]=x.getState().transform,j=er.translate(v.x??S,v.y??C).scale(v.zoom??N);p.transform(mr(b,w==null?void 0:w.duration),j)},getViewport:()=>{const[v,w,S]=x.getState().transform;return{x:v,y:w,zoom:S}},fitView:v=>U2(x.getState,v),setCenter:(v,w,S)=>{const{width:C,height:N,maxZoom:j}=x.getState(),E=(S==null?void 0:S.zoom)!==void 0?S.zoom:j,T=C/2-v*E,I=N/2-w*E,O=er.translate(T,I).scale(E);p.transform(mr(b,S==null?void 0:S.duration),O)},fitBounds:(v,w)=>{const{width:S,height:C,minZoom:N,maxZoom:j}=x.getState(),{x:E,y:T,zoom:I}=w2(v,S,C,N,j,(w==null?void 0:w.padding)??.1),O=er.translate(E,T).scale(I);p.transform(mr(b,w==null?void 0:w.duration),O)},project:v=>{const{transform:w,snapToGrid:S,snapGrid:C}=x.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"),ef(v,w,S,C)},screenToFlowPosition:v=>{const{transform:w,snapToGrid:S,snapGrid:C,domNode:N}=x.getState();if(!N)return v;const{x:j,y:E}=N.getBoundingClientRect(),T={x:v.x-j,y:v.y-E};return ef(T,w,S,C)},flowToScreenPosition:v=>{const{transform:w,domNode:S}=x.getState();if(!S)return v;const{x:C,y:N}=S.getBoundingClientRect(),j=b2(v,w);return{x:j.x+C,y:j.y+N}},viewportInitialized:!0}:tM,[p,b])})(),e=zt(),n=M.useCallback(()=>e.getState().getNodes().map(x=>({...x})),[]),o=M.useCallback(x=>e.getState().nodeInternals.get(x),[]),r=M.useCallback(()=>{const{edges:x=[]}=e.getState();return x.map(p=>({...p}))},[]),s=M.useCallback(x=>{const{edges:p=[]}=e.getState();return p.find(b=>b.id===x)},[]),i=M.useCallback(x=>{const{getNodes:p,setNodes:b,hasDefaultNodes:y,onNodesChange:v}=e.getState(),w=p(),S=typeof x=="function"?x(w):x;if(y)b(S);else if(v){const C=S.length===0?w.map(N=>({type:"remove",id:N.id})):S.map(N=>({item:N,type:"reset"}));v(C)}},[]),a=M.useCallback(x=>{const{edges:p=[],setEdges:b,hasDefaultEdges:y,onEdgesChange:v}=e.getState(),w=typeof x=="function"?x(p):x;y?b(w):v&&v(w.length===0?p.map(S=>({type:"remove",id:S.id})):w.map(S=>({item:S,type:"reset"})))},[]),l=M.useCallback(x=>{const p=Array.isArray(x)?x:[x],{getNodes:b,setNodes:y,hasDefaultNodes:v,onNodesChange:w}=e.getState();if(v)y([...b(),...p]);else if(w){const S=p.map(C=>({item:C,type:"add"}));w(S)}},[]),c=M.useCallback(x=>{const p=Array.isArray(x)?x:[x],{edges:b=[],setEdges:y,hasDefaultEdges:v,onEdgesChange:w}=e.getState();v?y([...b,...p]):w&&w(p.map(S=>({item:S,type:"add"})))},[]),d=M.useCallback(()=>{const{getNodes:x,edges:p=[],transform:b}=e.getState(),[y,v,w]=b;return{nodes:x().map(S=>({...S})),edges:p.map(S=>({...S})),viewport:{x:y,y:v,zoom:w}}},[]),h=M.useCallback(({nodes:x,edges:p})=>{const{nodeInternals:b,getNodes:y,edges:v,hasDefaultNodes:w,hasDefaultEdges:S,onNodesDelete:C,onEdgesDelete:N,onNodesChange:j,onEdgesChange:E}=e.getState(),T=(x||[]).map(R=>R.id),I=(p||[]).map(R=>R.id),O=y().reduce((R,P)=>{const z=P.parentNode||P.parentId,_=!T.includes(P.id)&&z&&R.find(k=>k.id===z);return(typeof P.deletable!="boolean"||P.deletable)&&(T.includes(P.id)||_)&&R.push(P),R},[]),L=v.filter(R=>typeof R.deletable!="boolean"||R.deletable),D=L.filter(R=>I.includes(R.id));if(O||D){const R=v2(O,L),P=[...D,...R],z=P.reduce((_,k)=>(_.includes(k.id)||_.push(k.id),_),[]);(S||w)&&(S&&e.setState({edges:v.filter(_=>!z.includes(_.id))}),w&&(O.forEach(_=>{b.delete(_.id)}),e.setState({nodeInternals:new Map(b)}))),z.length>0&&(N==null||N(P),E&&E(z.map(_=>({id:_,type:"remove"})))),O.length>0&&(C==null||C(O),j)&&j(O.map(_=>({id:_.id,type:"remove"})))}},[]),f=M.useCallback(x=>{const p=Nn((b=x).width)&&Nn(b.height)&&Nn(b.x)&&Nn(b.y);var b;const y=p?null:e.getState().nodeInternals.get(x.id);return!p&&!y?[null,null,p]:[p?x:r2(y),y,p]},[]),m=M.useCallback((x,p=!0,b)=>{const[y,v,w]=f(x);return y?(b||e.getState().getNodes()).filter(S=>{if(!(w||S.id!==v.id&&S.positionAbsolute))return!1;const C=r2(S),N=Wh(C,y);return p&&N>0||N>=y.width*y.height}):[]},[]),g=M.useCallback((x,p,b=!0)=>{const[y]=f(x);if(!y)return!1;const v=Wh(y,p);return b&&v>0||v>=y.width*y.height},[]);return M.useMemo(()=>({...t,getNodes:n,getNode:o,getEdges:r,getEdge:s,setNodes:i,setEdges:a,addNodes:l,addEdges:c,toObject:d,deleteElements:h,getIntersectingNodes:m,isNodeIntersecting:g}),[t,n,o,r,s,i,a,l,c,d,h,m,g])}const oM={actInsideInputWithModifier:!1},lf={position:"absolute",width:"100%",height:"100%",top:0,left:0},Xl=t=>({x:t.x,y:t.y,zoom:t.k}),ns=(t,e)=>t.target.closest(`.${e}`),$2=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),V2=t=>{const e=t.ctrlKey&&Vl()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e},rM=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection,d3ZoomHandler:t.d3ZoomHandler,userSelectionActive:t.userSelectionActive}),sM=({onMove:t,onMoveStart:e,onMoveEnd:n,onPaneContextMenu:o,zoomOnScroll:r=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:a=.5,panOnScrollMode:l=Bo.Free,zoomOnDoubleClick:c=!0,elementsSelectable:d,panOnDrag:h=!0,defaultViewport:f,translateExtent:m,minZoom:g,maxZoom:x,zoomActivationKeyCode:p,preventScrolling:b=!0,children:y,noWheelClassName:v,noPanClassName:w})=>{const S=M.useRef(),C=zt(),N=M.useRef(!1),j=M.useRef(!1),E=M.useRef(null),T=M.useRef({x:0,y:0,zoom:0}),{d3Zoom:I,d3Selection:O,d3ZoomHandler:L,userSelectionActive:D}=dt(rM,Wt),R=Ei(p),P=M.useRef(0),z=M.useRef(!1),_=M.useRef();return function(k){const B=zt();M.useEffect(()=>{let A;const U=()=>{var X,Y;if(!k.current)return;const $=$h(k.current);$.height!==0&&$.width!==0||((Y=(X=B.getState()).onError)==null||Y.call(X,"004",ET())),B.setState({width:$.width||500,height:$.height||500})};return U(),window.addEventListener("resize",U),k.current&&(A=new ResizeObserver(()=>U()),A.observe(k.current)),()=>{window.removeEventListener("resize",U),A&&k.current&&A.unobserve(k.current)}},[])}(E),M.useEffect(()=>{if(E.current){const k=E.current.getBoundingClientRect(),B=function(){var Y,G,W,J=vT,V=wT,Q=jT,te=kT,re=CT,ne=[0,1/0],ie=[[-1/0,-1/0],[1/0,1/0]],se=250,ae=QF,ge=Aj("start","zoom","end"),oe=0,ue=10;function de(K){K.property("__zoom",Qv).on("wheel.zoom",Ve,{passive:!1}).on("mousedown.zoom",Ke).on("dblclick.zoom",ee).filter(re).on("touchstart.zoom",ye).on("touchmove.zoom",we).on("touchend.zoom touchcancel.zoom",Ie).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function Se(K,me){return(me=Math.max(ne[0],Math.min(ne[1],me)))===K.k?K:new dp(me,K.x,K.y)}function Te(K,me,pe){var he=me[0]-pe[0]*K.k,Ce=me[1]-pe[1]*K.k;return he===K.x&&Ce===K.y?K:new dp(K.k,he,Ce)}function Fe(K){return[(+K[0][0]+ +K[1][0])/2,(+K[0][1]+ +K[1][1])/2]}function _e(K,me,pe,he){K.on("start.zoom",function(){ke(this,arguments).event(he).start()}).on("interrupt.zoom end.zoom",function(){ke(this,arguments).event(he).end()}).tween("zoom",function(){var Ce=this,Re=arguments,Pe=ke(Ce,Re).event(he),He=V.apply(Ce,Re),le=pe==null?Fe(He):typeof pe=="function"?pe.apply(Ce,Re):pe,Ae=Math.max(He[1][0]-He[0][0],He[1][1]-He[0][1]),Me=Ce.__zoom,Ue=typeof me=="function"?me.apply(Ce,Re):me,qe=ae(Me.invert(le).concat(Ae/Me.k),Ue.invert(le).concat(Ae/Ue.k));return function(De){if(De===1)De=Ue;else{var $e=qe(De),st=Ae/$e[2];De=new dp(st,le[0]-$e[0]*st,le[1]-$e[1]*st)}Pe.zoom(null,De)}})}function ke(K,me,pe){return!pe&&K.__zooming||new Ye(K,me)}function Ye(K,me){this.that=K,this.args=me,this.active=0,this.sourceEvent=null,this.extent=V.apply(K,me),this.taps=0}function Ve(K,...me){if(J.apply(this,arguments)){var pe=ke(this,me).event(K),he=this.__zoom,Ce=Math.max(ne[0],Math.min(ne[1],he.k*Math.pow(2,te.apply(this,arguments)))),Re=Kn(K);if(pe.wheel)pe.mouse[0][0]===Re[0]&&pe.mouse[0][1]===Re[1]||(pe.mouse[1]=he.invert(pe.mouse[0]=Re)),clearTimeout(pe.wheel);else{if(he.k===Ce)return;pe.mouse=[Re,he.invert(Re)],up(this),pe.start()}ki(K),pe.wheel=setTimeout(function(){pe.wheel=null,pe.end()},150),pe.zoom("mouse",Q(Te(Se(he,Ce),pe.mouse[0],pe.mouse[1]),pe.extent,ie))}}function Ke(K,...me){if(!W&&J.apply(this,arguments)){var pe=K.currentTarget,he=ke(this,me,!0).event(K),Ce=Vn(K.view).on("mousemove.zoom",function(le){if(ki(le),!he.moved){var Ae=le.clientX-Pe,Me=le.clientY-He;he.moved=Ae*Ae+Me*Me>oe}he.event(le).zoom("mouse",Q(Te(he.that.__zoom,he.mouse[0]=Kn(le,pe),he.mouse[1]),he.extent,ie))},!0).on("mouseup.zoom",function(le){Ce.on("mousemove.zoom mouseup.zoom",null),Zv(le.view,he.moved),ki(le),he.event(le).end()},!0),Re=Kn(K,pe),Pe=K.clientX,He=K.clientY;Jv(K.view),Uh(K),he.mouse=[Re,this.__zoom.invert(Re)],up(this),he.start()}}function ee(K,...me){if(J.apply(this,arguments)){var pe=this.__zoom,he=Kn(K.changedTouches?K.changedTouches[0]:K,this),Ce=pe.invert(he),Re=pe.k*(K.shiftKey?.5:2),Pe=Q(Te(Se(pe,Re),he,Ce),V.apply(this,me),ie);ki(K),se>0?Vn(this).transition().duration(se).call(_e,Pe,he,K):Vn(this).call(de.transform,Pe,he,K)}}function ye(K,...me){if(J.apply(this,arguments)){var pe,he,Ce,Re,Pe=K.touches,He=Pe.length,le=ke(this,me,K.changedTouches.length===He).event(K);for(Uh(K),he=0;he<He;++he)Re=[Re=Kn(Ce=Pe[he],this),this.__zoom.invert(Re),Ce.identifier],le.touch0?le.touch1||le.touch0[2]===Re[2]||(le.touch1=Re,le.taps=0):(le.touch0=Re,pe=!0,le.taps=1+!!Y);Y&&(Y=clearTimeout(Y)),pe&&(le.taps<2&&(G=Re[0],Y=setTimeout(function(){Y=null},500)),up(this),le.start())}}function we(K,...me){if(this.__zooming){var pe,he,Ce,Re,Pe=ke(this,me).event(K),He=K.changedTouches,le=He.length;for(ki(K),pe=0;pe<le;++pe)Ce=Kn(he=He[pe],this),Pe.touch0&&Pe.touch0[2]===he.identifier?Pe.touch0[0]=Ce:Pe.touch1&&Pe.touch1[2]===he.identifier&&(Pe.touch1[0]=Ce);if(he=Pe.that.__zoom,Pe.touch1){var Ae=Pe.touch0[0],Me=Pe.touch0[1],Ue=Pe.touch1[0],qe=Pe.touch1[1],De=(De=Ue[0]-Ae[0])*De+(De=Ue[1]-Ae[1])*De,$e=($e=qe[0]-Me[0])*$e+($e=qe[1]-Me[1])*$e;he=Se(he,Math.sqrt(De/$e)),Ce=[(Ae[0]+Ue[0])/2,(Ae[1]+Ue[1])/2],Re=[(Me[0]+qe[0])/2,(Me[1]+qe[1])/2]}else{if(!Pe.touch0)return;Ce=Pe.touch0[0],Re=Pe.touch0[1]}Pe.zoom("touch",Q(Te(he,Ce,Re),Pe.extent,ie))}}function Ie(K,...me){if(this.__zooming){var pe,he,Ce=ke(this,me).event(K),Re=K.changedTouches,Pe=Re.length;for(Uh(K),W&&clearTimeout(W),W=setTimeout(function(){W=null},500),pe=0;pe<Pe;++pe)he=Re[pe],Ce.touch0&&Ce.touch0[2]===he.identifier?delete Ce.touch0:Ce.touch1&&Ce.touch1[2]===he.identifier&&delete Ce.touch1;if(Ce.touch1&&!Ce.touch0&&(Ce.touch0=Ce.touch1,delete Ce.touch1),Ce.touch0)Ce.touch0[1]=this.__zoom.invert(Ce.touch0[0]);else if(Ce.end(),Ce.taps===2&&(he=Kn(he,this),Math.hypot(G[0]-he[0],G[1]-he[1])<ue)){var He=Vn(this).on("dblclick.zoom");He&&He.apply(this,arguments)}}}return de.transform=function(K,me,pe,he){var Ce=K.selection?K.selection():K;Ce.property("__zoom",Qv),K!==Ce?_e(K,me,pe,he):Ce.interrupt().each(function(){ke(this,arguments).event(he).start().zoom(null,typeof me=="function"?me.apply(this,arguments):me).end()})},de.scaleBy=function(K,me,pe,he){de.scaleTo(K,function(){return this.__zoom.k*(typeof me=="function"?me.apply(this,arguments):me)},pe,he)},de.scaleTo=function(K,me,pe,he){de.transform(K,function(){var Ce=V.apply(this,arguments),Re=this.__zoom,Pe=pe==null?Fe(Ce):typeof pe=="function"?pe.apply(this,arguments):pe,He=Re.invert(Pe),le=typeof me=="function"?me.apply(this,arguments):me;return Q(Te(Se(Re,le),Pe,He),Ce,ie)},pe,he)},de.translateBy=function(K,me,pe,he){de.transform(K,function(){return Q(this.__zoom.translate(typeof me=="function"?me.apply(this,arguments):me,typeof pe=="function"?pe.apply(this,arguments):pe),V.apply(this,arguments),ie)},null,he)},de.translateTo=function(K,me,pe,he,Ce){de.transform(K,function(){var Re=V.apply(this,arguments),Pe=this.__zoom,He=he==null?Fe(Re):typeof he=="function"?he.apply(this,arguments):he;return Q(er.translate(He[0],He[1]).scale(Pe.k).translate(typeof me=="function"?-me.apply(this,arguments):-me,typeof pe=="function"?-pe.apply(this,arguments):-pe),Re,ie)},he,Ce)},Ye.prototype={event:function(K){return K&&(this.sourceEvent=K),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(K,me){return this.mouse&&K!=="mouse"&&(this.mouse[1]=me.invert(this.mouse[0])),this.touch0&&K!=="touch"&&(this.touch0[1]=me.invert(this.touch0[0])),this.touch1&&K!=="touch"&&(this.touch1[1]=me.invert(this.touch1[0])),this.that.__zoom=me,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(K){var me=Vn(this.that).datum();ge.call(K,this.that,new yT(K,{sourceEvent:this.sourceEvent,target:de,transform:this.that.__zoom,dispatch:ge}),me)}},de.wheelDelta=function(K){return arguments.length?(te=typeof K=="function"?K:Bl(+K),de):te},de.filter=function(K){return arguments.length?(J=typeof K=="function"?K:Bl(!!K),de):J},de.touchable=function(K){return arguments.length?(re=typeof K=="function"?K:Bl(!!K),de):re},de.extent=function(K){return arguments.length?(V=typeof K=="function"?K:Bl([[+K[0][0],+K[0][1]],[+K[1][0],+K[1][1]]]),de):V},de.scaleExtent=function(K){return arguments.length?(ne[0]=+K[0],ne[1]=+K[1],de):[ne[0],ne[1]]},de.translateExtent=function(K){return arguments.length?(ie[0][0]=+K[0][0],ie[1][0]=+K[1][0],ie[0][1]=+K[0][1],ie[1][1]=+K[1][1],de):[[ie[0][0],ie[0][1]],[ie[1][0],ie[1][1]]]},de.constrain=function(K){return arguments.length?(Q=K,de):Q},de.duration=function(K){return arguments.length?(se=+K,de):se},de.interpolate=function(K){return arguments.length?(ae=K,de):ae},de.on=function(){var K=ge.on.apply(ge,arguments);return K===ge?de:K},de.clickDistance=function(K){return arguments.length?(oe=(K=+K)*K,de):Math.sqrt(oe)},de.tapDistance=function(K){return arguments.length?(ue=+K,de):ue},de}().scaleExtent([g,x]).translateExtent(m),A=Vn(E.current).call(B),U=er.translate(f.x,f.y).scale(Jr(f.zoom,g,x)),$=[[0,0],[k.width,k.height]],X=B.constrain()(U,$,m);B.transform(A,X),B.wheelDelta(V2),C.setState({d3Zoom:B,d3Selection:A,d3ZoomHandler:A.on("wheel.zoom"),transform:[X.x,X.y,X.k],domNode:E.current.closest(".react-flow")})}},[]),M.useEffect(()=>{O&&I&&(!i||R||D?L!==void 0&&O.on("wheel.zoom",function(k,B){if(!b&&k.type==="wheel"&&!k.ctrlKey||ns(k,v))return null;k.preventDefault(),L.call(this,k,B)},{passive:!1}):O.on("wheel.zoom",k=>{if(ns(k,v))return!1;k.preventDefault(),k.stopImmediatePropagation();const B=O.property("__zoom").k||1;if(k.ctrlKey&&s){const J=Kn(k),V=V2(k),Q=B*Math.pow(2,V);return void I.scaleTo(O,Q,J,k)}const A=k.deltaMode===1?20:1;let U=l===Bo.Vertical?0:k.deltaX*A,$=l===Bo.Horizontal?0:k.deltaY*A;!Vl()&&k.shiftKey&&l!==Bo.Vertical&&(U=k.deltaY*A,$=0),I.translateBy(O,-U/B*a,-$/B*a,{internal:!0});const X=Xl(O.property("__zoom")),{onViewportChangeStart:Y,onViewportChange:G,onViewportChangeEnd:W}=C.getState();clearTimeout(_.current),z.current||(z.current=!0,e==null||e(k,X),Y==null||Y(X)),z.current&&(t==null||t(k,X),G==null||G(X),_.current=setTimeout(()=>{n==null||n(k,X),W==null||W(X),z.current=!1},150))},{passive:!1}))},[D,i,l,O,I,L,R,s,b,v,e,t,n]),M.useEffect(()=>{I&&I.on("start",k=>{var U,$;if(!k.sourceEvent||k.sourceEvent.internal)return null;P.current=(U=k.sourceEvent)==null?void 0:U.button;const{onViewportChangeStart:B}=C.getState(),A=Xl(k.transform);N.current=!0,T.current=A,(($=k.sourceEvent)==null?void 0:$.type)==="mousedown"&&C.setState({paneDragging:!0}),B==null||B(A),e==null||e(k.sourceEvent,A)})},[I,e]),M.useEffect(()=>{I&&(D&&!N.current?I.on("zoom",null):D||I.on("zoom",k=>{var A;const{onViewportChange:B}=C.getState();if(C.setState({transform:[k.transform.x,k.transform.y,k.transform.k]}),j.current=!(!o||!$2(h,P.current??0)),(t||B)&&!((A=k.sourceEvent)!=null&&A.internal)){const U=Xl(k.transform);B==null||B(U),t==null||t(k.sourceEvent,U)}}))},[D,I,t,h,o]),M.useEffect(()=>{I&&I.on("end",k=>{if(!k.sourceEvent||k.sourceEvent.internal)return null;const{onViewportChangeEnd:B}=C.getState();if(N.current=!1,C.setState({paneDragging:!1}),o&&$2(h,P.current??0)&&!j.current&&o(k.sourceEvent),j.current=!1,(n||B)&&(A=T.current,U=k.transform,A.x!==U.x||A.y!==U.y||A.zoom!==U.k)){const $=Xl(k.transform);T.current=$,clearTimeout(S.current),S.current=setTimeout(()=>{B==null||B($),n==null||n(k.sourceEvent,$)},i?150:0)}var A,U})},[I,i,h,n,o]),M.useEffect(()=>{I&&I.filter(k=>{const B=R||r,A=s&&k.ctrlKey;if((h===!0||Array.isArray(h)&&h.includes(1))&&k.button===1&&k.type==="mousedown"&&(ns(k,"react-flow__node")||ns(k,"react-flow__edge")))return!0;if(!(h||B||i||c||s)||D||!c&&k.type==="dblclick"||ns(k,v)&&k.type==="wheel"||ns(k,w)&&(k.type!=="wheel"||i&&k.type==="wheel"&&!R)||!s&&k.ctrlKey&&k.type==="wheel"||!B&&!i&&!A&&k.type==="wheel"||!h&&(k.type==="mousedown"||k.type==="touchstart")||Array.isArray(h)&&!h.includes(k.button)&&k.type==="mousedown")return!1;const U=Array.isArray(h)&&h.includes(k.button)||!k.button||k.button<=1;return(!k.ctrlKey||k.type==="wheel")&&U})},[D,I,r,s,i,c,h,d,R]),q.createElement("div",{className:"react-flow__renderer",ref:E,style:lf},y)},iM=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function aM(){const{userSelectionActive:t,userSelectionRect:e}=dt(iM,Wt);return t&&e?q.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}function H2(t,e){const n=e.parentNode||e.parentId,o=t.find(r=>r.id===n);if(o){const r=e.position.x+e.width-o.width,s=e.position.y+e.height-o.height;if(r>0||s>0||e.position.x<0||e.position.y<0){if(o.style={...o.style},o.style.width=o.style.width??o.width,o.style.height=o.style.height??o.height,r>0&&(o.style.width+=r),s>0&&(o.style.height+=s),e.position.x<0){const i=Math.abs(e.position.x);o.position.x=o.position.x-i,o.style.width+=i,e.position.x=0}if(e.position.y<0){const i=Math.abs(e.position.y);o.position.y=o.position.y-i,o.style.height+=i,e.position.y=0}o.width=o.style.width,o.height=o.style.height}}}function W2(t,e){if(t.some(o=>o.type==="reset"))return t.filter(o=>o.type==="reset").map(o=>o.item);const n=t.filter(o=>o.type==="add").map(o=>o.item);return e.reduce((o,r)=>{const s=t.filter(a=>a.id===r.id);if(s.length===0)return o.push(r),o;const i={...r};for(const a of s)if(a)switch(a.type){case"select":i.selected=a.selected;break;case"position":a.position!==void 0&&(i.position=a.position),a.positionAbsolute!==void 0&&(i.positionAbsolute=a.positionAbsolute),a.dragging!==void 0&&(i.dragging=a.dragging),i.expandParent&&H2(o,i);break;case"dimensions":a.dimensions!==void 0&&(i.width=a.dimensions.width,i.height=a.dimensions.height),a.updateStyle!==void 0&&(i.style={...i.style||{},...a.dimensions}),typeof a.resizing=="boolean"&&(i.resizing=a.resizing),i.expandParent&&H2(o,i);break;case"remove":return o}return o.push(i),o},n)}function q2(t,e){return W2(t,e)}const Vo=(t,e)=>({id:t,type:"select",selected:e});function os(t,e){return t.reduce((n,o)=>{const r=e.includes(o.id);return!o.selected&&r?(o.selected=!0,n.push(Vo(o.id,!0))):o.selected&&!r&&(o.selected=!1,n.push(Vo(o.id,!1))),n},[])}const cf=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},lM=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging}),G2=M.memo(({isSelecting:t,selectionMode:e=Si.Full,panOnDrag:n,onSelectionStart:o,onSelectionEnd:r,onPaneClick:s,onPaneContextMenu:i,onPaneScroll:a,onPaneMouseEnter:l,onPaneMouseMove:c,onPaneMouseLeave:d,children:h})=>{const f=M.useRef(null),m=zt(),g=M.useRef(0),x=M.useRef(0),p=M.useRef(),{userSelectionActive:b,elementsSelectable:y,dragging:v}=dt(lM,Wt),w=()=>{m.setState({userSelectionActive:!1,userSelectionRect:null}),g.current=0,x.current=0},S=j=>{s==null||s(j),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},C=a?j=>a(j):void 0,N=y&&(t||b);return q.createElement("div",{className:Qt(["react-flow__pane",{dragging:v,selection:t}]),onClick:N?void 0:cf(S,f),onContextMenu:cf(j=>{Array.isArray(n)&&(n!=null&&n.includes(2))?j.preventDefault():i==null||i(j)},f),onWheel:cf(C,f),onMouseEnter:N?void 0:l,onMouseDown:N?j=>{const{resetSelectedElements:E,domNode:T}=m.getState();if(p.current=T==null?void 0:T.getBoundingClientRect(),!y||!t||j.button!==0||j.target!==f.current||!p.current)return;const{x:I,y:O}=zo(j,p.current);E(),m.setState({userSelectionRect:{width:0,height:0,startX:I,startY:O,x:I,y:O}}),o==null||o(j)}:void 0,onMouseMove:N?j=>{const{userSelectionRect:E,nodeInternals:T,edges:I,transform:O,onNodesChange:L,onEdgesChange:D,nodeOrigin:R,getNodes:P}=m.getState();if(!t||!p.current||!E)return;m.setState({userSelectionActive:!0,nodesSelectionActive:!1});const z=zo(j,p.current),_=E.startX??0,k=E.startY??0,B={...E,x:z.x<_?z.x:_,y:z.y<k?z.y:k,width:Math.abs(z.x-_),height:Math.abs(z.y-k)},A=P(),U=y2(T,B,O,e===Si.Partial,!0,R),$=v2(U,I).map(Y=>Y.id),X=U.map(Y=>Y.id);if(g.current!==X.length){g.current=X.length;const Y=os(A,X);Y.length&&(L==null||L(Y))}if(x.current!==$.length){x.current=$.length;const Y=os(I,$);Y.length&&(D==null||D(Y))}m.setState({userSelectionRect:B})}:c,onMouseUp:N?j=>{if(j.button!==0)return;const{userSelectionRect:E}=m.getState();!b&&E&&j.target===f.current&&(S==null||S(j)),m.setState({nodesSelectionActive:g.current>0}),w(),r==null||r(j)}:void 0,onMouseLeave:N?j=>{b&&(m.setState({nodesSelectionActive:g.current>0}),r==null||r(j)),w()}:d,ref:f,style:lf},h,q.createElement(aM,null))});function Y2(t,e){const n=t.parentNode||t.parentId;if(!n)return!1;const o=e.get(n);return!!o&&(!!o.selected||Y2(o,e))}function K2(t,e,n){let o=t;do{if(o!=null&&o.matches(e))return!0;if(o===n.current)return!1;o=o.parentElement}while(o);return!1}function cM(t,e,n,o){return Array.from(t.values()).filter(r=>(r.selected||r.id===o)&&(!r.parentNode||r.parentId||!Y2(r,t))&&(r.draggable||e&&r.draggable===void 0)).map(r=>{var s,i;return{id:r.id,position:r.position||{x:0,y:0},positionAbsolute:r.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((s=r.positionAbsolute)==null?void 0:s.x)??0),y:n.y-(((i=r.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:r.extent,parentNode:r.parentNode||r.parentId,parentId:r.parentNode||r.parentId,width:r.width,height:r.height,expandParent:r.expandParent}})}function X2(t,e,n,o,r=[0,0],s){const i=function(h,f){return f&&f!=="parent"?[f[0],[f[1][0]-(h.width||0),f[1][1]-(h.height||0)]]:f}(t,t.extent||o);let a=i;const l=t.parentNode||t.parentId;if(t.extent!=="parent"||t.expandParent){if(t.extent&&l&&t.extent!=="parent"){const h=n.get(l),{x:f,y:m}=Qr(h,r).positionAbsolute;a=[[t.extent[0][0]+f,t.extent[0][1]+m],[t.extent[1][0]+f,t.extent[1][1]+m]]}}else if(l&&t.width&&t.height){const h=n.get(l),{x:f,y:m}=Qr(h,r).positionAbsolute;a=h&&Nn(f)&&Nn(m)&&Nn(h.width)&&Nn(h.height)?[[f+t.width*r[0],m+t.height*r[1]],[f+h.width-t.width+t.width*r[0],m+h.height-t.height+t.height*r[1]]]:a}else s==null||s("005",_T()),a=i;let c={x:0,y:0};if(l){const h=n.get(l);c=Qr(h,r).positionAbsolute}const d=a&&a!=="parent"?Vh(e,a):e;return{position:{x:d.x-c.x,y:d.y-c.y},positionAbsolute:d}}function df({nodeId:t,dragItems:e,nodeInternals:n}){const o=e.map(r=>({...n.get(r.id),position:r.position,positionAbsolute:r.positionAbsolute}));return[t?o.find(r=>r.id===t):o[0],o]}G2.displayName="Pane";const J2=(t,e,n,o)=>{const r=e.querySelectorAll(t);if(!r||!r.length)return null;const s=Array.from(r),i=e.getBoundingClientRect(),a=i.width*o[0],l=i.height*o[1];return s.map(c=>{const d=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),position:c.getAttribute("data-handlepos"),x:(d.left-i.left-a)/n,y:(d.top-i.top-l)/n,...$h(c)}})};function Ii(t,e,n){return n===void 0?n:o=>{const r=e().nodeInternals.get(t);r&&n(o,{...r})}}function uf({id:t,store:e,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:s,multiSelectionActive:i,nodeInternals:a,onError:l}=e.getState(),c=a.get(t);c?(e.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&i)&&(s({nodes:[c],edges:[]}),requestAnimationFrame(()=>{var d;return(d=o==null?void 0:o.current)==null?void 0:d.blur()})):r([t])):l==null||l("012",OT(t))}function hf(t){return(e,n,o)=>t==null?void 0:t(e,o)}function Z2({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:s,selectNodesOnDrag:i}){const a=zt(),[l,c]=M.useState(!1),d=M.useRef([]),h=M.useRef({x:null,y:null}),f=M.useRef(0),m=M.useRef(null),g=M.useRef({x:0,y:0}),x=M.useRef(null),p=M.useRef(!1),b=M.useRef(!1),y=M.useRef(!1),v=function(){const w=zt();return M.useCallback(({sourceEvent:C})=>{const{transform:N,snapGrid:j,snapToGrid:E}=w.getState(),T=C.touches?C.touches[0].clientX:C.clientX,I=C.touches?C.touches[0].clientY:C.clientY,O={x:(T-N[0])/N[2],y:(I-N[1])/N[2]};return{xSnapped:E?j[0]*Math.round(O.x/j[0]):O.x,ySnapped:E?j[1]*Math.round(O.y/j[1]):O.y,...O}},[])}();return M.useEffect(()=>{if(t!=null&&t.current){const w=Vn(t.current),S=({x:j,y:E})=>{const{nodeInternals:T,onNodeDrag:I,onSelectionDrag:O,updateNodePositions:L,nodeExtent:D,snapGrid:R,snapToGrid:P,nodeOrigin:z,onError:_}=a.getState();h.current={x:j,y:E};let k=!1,B={x:0,y:0,x2:0,y2:0};if(d.current.length>1&&D){const U=tf(d.current,z);B=Hh(U)}if(d.current=d.current.map(U=>{const $={x:j-U.distance.x,y:E-U.distance.y};P&&($.x=R[0]*Math.round($.x/R[0]),$.y=R[1]*Math.round($.y/R[1]));const X=[[D[0][0],D[0][1]],[D[1][0],D[1][1]]];d.current.length>1&&D&&!U.extent&&(X[0][0]=U.positionAbsolute.x-B.x+D[0][0],X[1][0]=U.positionAbsolute.x+(U.width??0)-B.x2+D[1][0],X[0][1]=U.positionAbsolute.y-B.y+D[0][1],X[1][1]=U.positionAbsolute.y+(U.height??0)-B.y2+D[1][1]);const Y=X2(U,$,T,X,z,_);return k=k||U.position.x!==Y.position.x||U.position.y!==Y.position.y,U.position=Y.position,U.positionAbsolute=Y.positionAbsolute,U}),!k)return;L(d.current,!0,!0),c(!0);const A=r?I:hf(O);if(A&&x.current){const[U,$]=df({nodeId:r,dragItems:d.current,nodeInternals:T});A(x.current,U,$)}},C=()=>{if(!m.current)return;const[j,E]=n2(g.current,m.current);if(j!==0||E!==0){const{transform:T,panBy:I}=a.getState();h.current.x=(h.current.x??0)-j/T[2],h.current.y=(h.current.y??0)-E/T[2],I({x:j,y:E})&&S(h.current)}f.current=requestAnimationFrame(C)},N=j=>{var z;const{nodeInternals:E,multiSelectionActive:T,nodesDraggable:I,unselectNodesAndEdges:O,onNodeDragStart:L,onSelectionDragStart:D}=a.getState();b.current=!0;const R=r?L:hf(D);i&&s||T||!r||(z=E.get(r))!=null&&z.selected||O(),r&&s&&i&&uf({id:r,store:a,nodeRef:t});const P=v(j);if(h.current=P,d.current=cM(E,I,P,r),R&&d.current){const[_,k]=df({nodeId:r,dragItems:d.current,nodeInternals:E});R(j.sourceEvent,_,k)}};if(!e){const j=function(){var E,T,I,O,L=pT,D=gT,R=xT,P=bT,z={},_=Aj("start","drag","end"),k=0,B=0;function A(V){V.on("mousedown.drag",U).filter(P).on("touchstart.drag",Y).on("touchmove.drag",G,mT).on("touchend.drag touchcancel.drag",W).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function U(V,Q){if(!O&&L.call(this,V,Q)){var te=J(this,D.call(this,V,Q),V,Q,"mouse");te&&(Vn(V.view).on("mousemove.drag",$,wi).on("mouseup.drag",X,wi),Jv(V.view),zh(V),I=!1,E=V.clientX,T=V.clientY,te("start",V))}}function $(V){if(Xr(V),!I){var Q=V.clientX-E,te=V.clientY-T;I=Q*Q+te*te>B}z.mouse("drag",V)}function X(V){Vn(V.view).on("mousemove.drag mouseup.drag",null),Zv(V.view,I),Xr(V),z.mouse("end",V)}function Y(V,Q){if(L.call(this,V,Q)){var te,re,ne=V.changedTouches,ie=D.call(this,V,Q),se=ne.length;for(te=0;te<se;++te)(re=J(this,ie,V,Q,ne[te].identifier,ne[te]))&&(zh(V),re("start",V,ne[te]))}}function G(V){var Q,te,re=V.changedTouches,ne=re.length;for(Q=0;Q<ne;++Q)(te=z[re[Q].identifier])&&(Xr(V),te("drag",V,re[Q]))}function W(V){var Q,te,re=V.changedTouches,ne=re.length;for(O&&clearTimeout(O),O=setTimeout(function(){O=null},500),Q=0;Q<ne;++Q)(te=z[re[Q].identifier])&&(zh(V),te("end",V,re[Q]))}function J(V,Q,te,re,ne,ie){var se,ae,ge,oe=_.copy(),ue=Kn(ie||te,Q);if((ge=R.call(V,new Bh("beforestart",{sourceEvent:te,target:A,identifier:ne,active:k,x:ue[0],y:ue[1],dx:0,dy:0,dispatch:oe}),re))!=null)return se=ge.x-ue[0]||0,ae=ge.y-ue[1]||0,function de(Se,Te,Fe){var _e,ke=ue;switch(Se){case"start":z[ne]=de,_e=k++;break;case"end":delete z[ne],--k;case"drag":ue=Kn(Fe||Te,Q),_e=k}oe.call(Se,V,new Bh(Se,{sourceEvent:Te,subject:ge,target:A,identifier:ne,active:_e,x:ue[0]+se,y:ue[1]+ae,dx:ue[0]-ke[0],dy:ue[1]-ke[1],dispatch:oe}),re)}}return A.filter=function(V){return arguments.length?(L=typeof V=="function"?V:zl(!!V),A):L},A.container=function(V){return arguments.length?(D=typeof V=="function"?V:zl(V),A):D},A.subject=function(V){return arguments.length?(R=typeof V=="function"?V:zl(V),A):R},A.touchable=function(V){return arguments.length?(P=typeof V=="function"?V:zl(!!V),A):P},A.on=function(){var V=_.on.apply(_,arguments);return V===_?A:V},A.clickDistance=function(V){return arguments.length?(B=(V=+V)*V,A):Math.sqrt(B)},A}().on("start",E=>{const{domNode:T,nodeDragThreshold:I}=a.getState();I===0&&N(E),y.current=!1;const O=v(E);h.current=O,m.current=(T==null?void 0:T.getBoundingClientRect())||null,g.current=zo(E.sourceEvent,m.current)}).on("drag",E=>{var L,D;const T=v(E),{autoPanOnNodeDrag:I,nodeDragThreshold:O}=a.getState();if(E.sourceEvent.type==="touchmove"&&E.sourceEvent.touches.length>1&&(y.current=!0),!y.current){if(!p.current&&b.current&&I&&(p.current=!0,C()),!b.current){const R=T.xSnapped-(((L=h==null?void 0:h.current)==null?void 0:L.x)??0),P=T.ySnapped-(((D=h==null?void 0:h.current)==null?void 0:D.y)??0);Math.sqrt(R*R+P*P)>O&&N(E)}(h.current.x!==T.xSnapped||h.current.y!==T.ySnapped)&&d.current&&b.current&&(x.current=E.sourceEvent,g.current=zo(E.sourceEvent,m.current),S(T))}}).on("end",E=>{if(b.current&&!y.current&&(c(!1),p.current=!1,b.current=!1,cancelAnimationFrame(f.current),d.current)){const{updateNodePositions:T,nodeInternals:I,onNodeDragStop:O,onSelectionDragStop:L}=a.getState(),D=r?O:hf(L);if(T(d.current,!1,!1),D){const[R,P]=df({nodeId:r,dragItems:d.current,nodeInternals:I});D(E.sourceEvent,R,P)}}}).filter(E=>{const T=E.target;return!E.button&&(!n||!K2(T,`.${n}`,t))&&(!o||K2(T,o,t))});return w.call(j),()=>{w.on(".drag",null)}}w.on(".drag",null)}},[t,e,n,o,s,a,r,i,v]),l}function Q2(){const t=zt();return M.useCallback(n=>{const{nodeInternals:o,nodeExtent:r,updateNodePositions:s,getNodes:i,snapToGrid:a,snapGrid:l,onError:c,nodesDraggable:d}=t.getState(),h=i().filter(y=>y.selected&&(y.draggable||d&&y.draggable===void 0)),f=a?l[0]:5,m=a?l[1]:5,g=n.isShiftPressed?4:1,x=n.x*f*g,p=n.y*m*g,b=h.map(y=>{if(y.positionAbsolute){const v={x:y.positionAbsolute.x+x,y:y.positionAbsolute.y+p};a&&(v.x=l[0]*Math.round(v.x/l[0]),v.y=l[1]*Math.round(v.y/l[1]));const{positionAbsolute:w,position:S}=X2(y,v,o,r,void 0,c);y.position=S,y.positionAbsolute=w}return y});s(b,!0,!1)},[])}const rs={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Ai=t=>{const e=({id:n,type:o,data:r,xPos:s,yPos:i,xPosOrigin:a,yPosOrigin:l,selected:c,onClick:d,onMouseEnter:h,onMouseMove:f,onMouseLeave:m,onContextMenu:g,onDoubleClick:x,style:p,className:b,isDraggable:y,isSelectable:v,isConnectable:w,isFocusable:S,selectNodesOnDrag:C,sourcePosition:N,targetPosition:j,hidden:E,resizeObserver:T,dragHandle:I,zIndex:O,isParent:L,noDragClassName:D,noPanClassName:R,initialized:P,disableKeyboardA11y:z,ariaLabel:_,rfId:k,hasHandleBounds:B})=>{const A=zt(),U=M.useRef(null),$=M.useRef(null),X=M.useRef(N),Y=M.useRef(j),G=M.useRef(o),W=v||y||d||h||f||m,J=Q2(),V=Ii(n,A.getState,h),Q=Ii(n,A.getState,f),te=Ii(n,A.getState,m),re=Ii(n,A.getState,g),ne=Ii(n,A.getState,x);M.useEffect(()=>()=>{$.current&&(T==null||T.unobserve($.current),$.current=null)},[]),M.useEffect(()=>{if(U.current&&!E){const se=U.current;P&&B&&$.current===se||($.current&&(T==null||T.unobserve($.current)),T==null||T.observe(se),$.current=se)}},[E,P,B]),M.useEffect(()=>{const se=G.current!==o,ae=X.current!==N,ge=Y.current!==j;U.current&&(se||ae||ge)&&(se&&(G.current=o),ae&&(X.current=N),ge&&(Y.current=j),A.getState().updateNodeDimensions([{id:n,nodeElement:U.current,forceUpdate:!0}]))},[n,o,N,j]);const ie=Z2({nodeRef:U,disabled:E||!y,noDragClassName:D,handleSelector:I,nodeId:n,isSelectable:v,selectNodesOnDrag:C});return E?null:q.createElement("div",{className:Qt(["react-flow__node",`react-flow__node-${o}`,{[R]:y},b,{selected:c,selectable:v,parent:L,dragging:ie}]),ref:U,style:{zIndex:O,transform:`translate(${a}px,${l}px)`,pointerEvents:W?"all":"none",visibility:P?"visible":"hidden",...p},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:V,onMouseMove:Q,onMouseLeave:te,onContextMenu:re,onClick:se=>{const{nodeDragThreshold:ae}=A.getState();if(v&&(!C||!y||ae>0)&&uf({id:n,store:A,nodeRef:U}),d){const ge=A.getState().nodeInternals.get(n);ge&&d(se,{...ge})}},onDoubleClick:ne,onKeyDown:S?se=>{if(!qh(se)&&!z)if(s2.includes(se.key)&&v){const ae=se.key==="Escape";uf({id:n,store:A,unselect:ae,nodeRef:U})}else y&&c&&Object.prototype.hasOwnProperty.call(rs,se.key)&&(A.setState({ariaLiveMessage:`Moved selected node ${se.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~i}`}),J({x:rs[se.key].x,y:rs[se.key].y,isShiftPressed:se.shiftKey}))}:void 0,tabIndex:S?0:void 0,role:S?"button":void 0,"aria-describedby":z?void 0:`${R2}-${k}`,"aria-label":_},q.createElement(FT,{value:n},q.createElement(t,{id:n,data:r,type:o,xPos:s,yPos:i,selected:c,isConnectable:w,sourcePosition:N,targetPosition:j,dragging:ie,dragHandle:I,zIndex:O})))};return e.displayName="NodeWrapper",M.memo(e)};const dM=t=>{const e=t.getNodes().filter(n=>n.selected);return{...tf(e,t.nodeOrigin),transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`,userSelectionActive:t.userSelectionActive}};var uM=M.memo(function({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const o=zt(),{width:r,height:s,x:i,y:a,transformString:l,userSelectionActive:c}=dt(dM,Wt),d=Q2(),h=M.useRef(null);if(M.useEffect(()=>{var m;n||((m=h.current)==null||m.focus({preventScroll:!0}))},[n]),Z2({nodeRef:h}),c||!r||!s)return null;const f=t?m=>{const g=o.getState().getNodes().filter(x=>x.selected);t(m,g)}:void 0;return q.createElement("div",{className:Qt(["react-flow__nodesselection","react-flow__container",e]),style:{transform:l}},q.createElement("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:m=>{Object.prototype.hasOwnProperty.call(rs,m.key)&&d({x:rs[m.key].x,y:rs[m.key].y,isShiftPressed:m.shiftKey})},style:{width:r,height:s,top:a,left:i}}))});const hM=t=>t.nodesSelectionActive,ew=({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:i,deleteKeyCode:a,onMove:l,onMoveStart:c,onMoveEnd:d,selectionKeyCode:h,selectionOnDrag:f,selectionMode:m,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:p,panActivationKeyCode:b,zoomActivationKeyCode:y,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:S,panOnScroll:C,panOnScrollSpeed:N,panOnScrollMode:j,zoomOnDoubleClick:E,panOnDrag:T,defaultViewport:I,translateExtent:O,minZoom:L,maxZoom:D,preventScrolling:R,onSelectionContextMenu:P,noWheelClassName:z,noPanClassName:_,disableKeyboardA11y:k})=>{const B=dt(hM),A=Ei(h),U=Ei(b),$=U||T,X=U||C,Y=A||f&&$!==!0;return(({deleteKeyCode:G,multiSelectionKeyCode:W})=>{const J=zt(),{deleteElements:V}=_i(),Q=Ei(G,oM),te=Ei(W);M.useEffect(()=>{if(Q){const{edges:re,getNodes:ne}=J.getState(),ie=ne().filter(ae=>ae.selected),se=re.filter(ae=>ae.selected);V({nodes:ie,edges:se}),J.setState({nodesSelectionActive:!1})}},[Q]),M.useEffect(()=>{J.setState({multiSelectionActive:te})},[te])})({deleteKeyCode:a,multiSelectionKeyCode:p}),q.createElement(sM,{onMove:l,onMoveStart:c,onMoveEnd:d,onPaneContextMenu:s,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:S,panOnScroll:X,panOnScrollSpeed:N,panOnScrollMode:j,zoomOnDoubleClick:E,panOnDrag:!A&&$,defaultViewport:I,translateExtent:O,minZoom:L,maxZoom:D,zoomActivationKeyCode:y,preventScrolling:R,noWheelClassName:z,noPanClassName:_},q.createElement(G2,{onSelectionStart:g,onSelectionEnd:x,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:$,isSelecting:!!Y,selectionMode:m},t,B&&q.createElement(uM,{onSelectionContextMenu:P,noPanClassName:_,disableKeyboardA11y:k})))};ew.displayName="FlowRenderer";var fM=M.memo(ew);function mM(t){return{input:Ai(t.input||A2),default:Ai(t.default||rf),output:Ai(t.output||M2),group:Ai(t.group||sf),...Object.keys(t).filter(e=>!["input","default","output","group"].includes(e)).reduce((e,n)=>(e[n]=Ai(t[n]||rf),e),{})}}const pM=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,updateNodeDimensions:t.updateNodeDimensions,onError:t.onError}),tw=t=>{const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,updateNodeDimensions:s,onError:i}=dt(pM,Wt),a=(l=t.onlyRenderVisibleElements,dt(M.useCallback(h=>l?y2(h.nodeInternals,{x:0,y:0,width:h.width,height:h.height},h.transform,!0):h.getNodes(),[l])));var l;const c=M.useRef(),d=M.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const h=new ResizeObserver(f=>{const m=f.map(g=>({id:g.target.getAttribute("data-id"),nodeElement:g.target,forceUpdate:!0}));s(m)});return c.current=h,h},[]);return M.useEffect(()=>()=>{var h;(h=c==null?void 0:c.current)==null||h.disconnect()},[]),q.createElement("div",{className:"react-flow__nodes",style:lf},a.map(h=>{var C,N,j;let f=h.type||"default";t.nodeTypes[f]||(i==null||i("003",NT(f)),f="default");const m=t.nodeTypes[f]||t.nodeTypes.default,g=!!(h.draggable||e&&h.draggable===void 0),x=!!(h.selectable||r&&h.selectable===void 0),p=!!(h.connectable||n&&h.connectable===void 0),b=!!(h.focusable||o&&h.focusable===void 0),y=t.nodeExtent?Vh(h.positionAbsolute,t.nodeExtent):h.positionAbsolute,v=(y==null?void 0:y.x)??0,w=(y==null?void 0:y.y)??0,S=(({x:E,y:T,width:I,height:O,origin:L})=>I&&O?L[0]<0||L[1]<0||L[0]>1||L[1]>1?{x:E,y:T}:{x:E-I*L[0],y:T-O*L[1]}:{x:E,y:T})({x:v,y:w,width:h.width??0,height:h.height??0,origin:t.nodeOrigin});return q.createElement(m,{key:h.id,id:h.id,className:h.className,style:h.style,type:f,data:h.data,sourcePosition:h.sourcePosition||Oe.Bottom,targetPosition:h.targetPosition||Oe.Top,hidden:h.hidden,xPos:v,yPos:w,xPosOrigin:S.x,yPosOrigin:S.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!h.selected,isDraggable:g,isSelectable:x,isConnectable:p,isFocusable:b,resizeObserver:d,dragHandle:h.dragHandle,zIndex:((C=h[yt])==null?void 0:C.z)??0,isParent:!!((N=h[yt])!=null&&N.isParent),noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!h.width&&!!h.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:h.ariaLabel,hasHandleBounds:!!((j=h[yt])!=null&&j.handleBounds)})}))};tw.displayName="NodeRenderer";var gM=M.memo(tw);const xM=(t,e,n)=>n===Oe.Left?t-e:n===Oe.Right?t+e:t,bM=(t,e,n)=>n===Oe.Top?t-e:n===Oe.Bottom?t+e:t,nw="react-flow__edgeupdater",ow=({position:t,centerX:e,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:s,onMouseOut:i,type:a})=>q.createElement("circle",{onMouseDown:r,onMouseEnter:s,onMouseOut:i,className:Qt([nw,`${nw}-${a}`]),cx:xM(e,o,t),cy:bM(n,o,t),r:o,stroke:"transparent",fill:"transparent"}),yM=()=>!0;var ss=t=>{const e=({id:n,className:o,type:r,data:s,onClick:i,onEdgeDoubleClick:a,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:x,style:p,source:b,target:y,sourceX:v,sourceY:w,targetX:S,targetY:C,sourcePosition:N,targetPosition:j,elementsSelectable:E,hidden:T,sourceHandleId:I,targetHandleId:O,onContextMenu:L,onMouseEnter:D,onMouseMove:R,onMouseLeave:P,reconnectRadius:z,onReconnect:_,onReconnectStart:k,onReconnectEnd:B,markerEnd:A,markerStart:U,rfId:$,ariaLabel:X,isFocusable:Y,isReconnectable:G,pathOptions:W,interactionWidth:J,disableKeyboardA11y:V})=>{const Q=M.useRef(null),[te,re]=M.useState(!1),[ne,ie]=M.useState(!1),se=zt(),ae=M.useMemo(()=>`url('#${Qh(U,$)}')`,[U,$]),ge=M.useMemo(()=>`url('#${Qh(A,$)}')`,[A,$]);if(T)return null;const oe=ji(n,se.getState,a),ue=ji(n,se.getState,L),de=ji(n,se.getState,D),Se=ji(n,se.getState,R),Te=ji(n,se.getState,P),Fe=(Ve,Ke)=>{if(Ve.button!==0)return;const{edges:ee,isValidConnection:ye}=se.getState(),we=Ke?y:b,Ie=(Ke?O:I)||null,K=Ke?"target":"source",me=ye||yM,pe=Ke,he=ee.find(Ce=>Ce.id===n);ie(!0),k==null||k(Ve,he,K),S2({event:Ve,handleId:Ie,nodeId:we,onConnect:Ce=>_==null?void 0:_(he,Ce),isTarget:pe,getState:se.getState,setState:se.setState,isValidConnection:me,edgeUpdaterType:K,onReconnectEnd:Ce=>{ie(!1),B==null||B(Ce,he,K)}})},_e=()=>re(!0),ke=()=>re(!1),Ye=!E&&!i;return q.createElement("g",{className:Qt(["react-flow__edge",`react-flow__edge-${r}`,o,{selected:l,animated:c,inactive:Ye,updating:te}]),onClick:Ve=>{var K;const{edges:Ke,addSelectedEdges:ee,unselectNodesAndEdges:ye,multiSelectionActive:we}=se.getState(),Ie=Ke.find(me=>me.id===n);Ie&&(E&&(se.setState({nodesSelectionActive:!1}),Ie.selected&&we?(ye({nodes:[],edges:[Ie]}),(K=Q.current)==null||K.blur()):ee([n])),i&&i(Ve,Ie))},onDoubleClick:oe,onContextMenu:ue,onMouseEnter:de,onMouseMove:Se,onMouseLeave:Te,onKeyDown:Y?Ve=>{var Ke;if(!V&&s2.includes(Ve.key)&&E){const{unselectNodesAndEdges:ee,addSelectedEdges:ye,edges:we}=se.getState();Ve.key==="Escape"?((Ke=Q.current)==null||Ke.blur(),ee({edges:[we.find(Ie=>Ie.id===n)]})):ye([n])}}:void 0,tabIndex:Y?0:void 0,role:Y?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":X===null?void 0:X||`Edge from ${b} to ${y}`,"aria-describedby":Y?`${P2}-${$}`:void 0,ref:Q},!ne&&q.createElement(t,{id:n,source:b,target:y,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:x,data:s,style:p,sourceX:v,sourceY:w,targetX:S,targetY:C,sourcePosition:N,targetPosition:j,sourceHandleId:I,targetHandleId:O,markerStart:ae,markerEnd:ge,pathOptions:W,interactionWidth:J}),G&&q.createElement(q.Fragment,null,(G==="source"||G===!0)&&q.createElement(ow,{position:N,centerX:v,centerY:w,radius:z,onMouseDown:Ve=>Fe(Ve,!0),onMouseEnter:_e,onMouseOut:ke,type:"source"}),(G==="target"||G===!0)&&q.createElement(ow,{position:j,centerX:S,centerY:C,radius:z,onMouseDown:Ve=>Fe(Ve,!1),onMouseEnter:_e,onMouseOut:ke,type:"target"})))};return e.displayName="EdgeWrapper",M.memo(e)};function vM(t){return{default:ss(t.default||Gl),straight:ss(t.bezier||Jh),step:ss(t.step||Xh),smoothstep:ss(t.step||Wl),simplebezier:ss(t.simplebezier||Yh),...Object.keys(t).filter(e=>!["default","bezier"].includes(e)).reduce((e,n)=>(e[n]=ss(t[n]||Gl),e),{})}}function rw(t,e,n=null){const o=((n==null?void 0:n.x)||0)+e.x,r=((n==null?void 0:n.y)||0)+e.y,s=(n==null?void 0:n.width)||e.width,i=(n==null?void 0:n.height)||e.height;switch(t){case Oe.Top:return{x:o+s/2,y:r};case Oe.Right:return{x:o+s,y:r+i/2};case Oe.Bottom:return{x:o+s/2,y:r+i};case Oe.Left:return{x:o,y:r+i/2}}}function sw(t,e){return t?t.length!==1&&e?e&&t.find(n=>n.id===e)||null:t[0]:null}function iw(t){var o,r,s,i,a;const e=((o=t==null?void 0:t[yt])==null?void 0:o.handleBounds)||null,n=e&&(t==null?void 0:t.width)&&(t==null?void 0:t.height)&&((r=t==null?void 0:t.positionAbsolute)==null?void 0:r.x)!==void 0&&((s=t==null?void 0:t.positionAbsolute)==null?void 0:s.y)!==void 0;return[{x:((i=t==null?void 0:t.positionAbsolute)==null?void 0:i.x)||0,y:((a=t==null?void 0:t.positionAbsolute)==null?void 0:a.y)||0,width:(t==null?void 0:t.width)||0,height:(t==null?void 0:t.height)||0},e,!!n]}const wM=[{level:0,isMaxLevel:!0,edges:[]}];function kM(t,e,n){return function(o,r,s=!1){let i=-1;const a=o.reduce((c,d)=>{var m,g;const h=Nn(d.zIndex);let f=h?d.zIndex:0;if(s){const x=r.get(d.target),p=r.get(d.source),b=d.selected||(x==null?void 0:x.selected)||(p==null?void 0:p.selected),y=Math.max(((m=p==null?void 0:p[yt])==null?void 0:m.z)||0,((g=x==null?void 0:x[yt])==null?void 0:g.z)||0,1e3);f=(h?d.zIndex:0)+(b?y:0)}return c[f]?c[f].push(d):c[f]=[d],i=f>i?f:i,c},{}),l=Object.entries(a).map(([c,d])=>{const h=+c;return{edges:d,level:h,isMaxLevel:h===i}});return l.length===0?wM:l}(dt(M.useCallback(o=>t?o.edges.filter(r=>{const s=e.get(r.source),i=e.get(r.target);return(s==null?void 0:s.width)&&(s==null?void 0:s.height)&&(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&function({sourcePos:a,targetPos:l,sourceWidth:c,sourceHeight:d,targetWidth:h,targetHeight:f,width:m,height:g,transform:x}){const p={x:Math.min(a.x,l.x),y:Math.min(a.y,l.y),x2:Math.max(a.x+c,l.x+h),y2:Math.max(a.y+d,l.y+f)};p.x===p.x2&&(p.x2+=1),p.y===p.y2&&(p.y2+=1);const b=Hh({x:(0-x[0])/x[2],y:(0-x[1])/x[2],width:m/x[2],height:g/x[2]}),y=Math.max(0,Math.min(b.x2,p.x2)-Math.max(b.x,p.x)),v=Math.max(0,Math.min(b.y2,p.y2)-Math.max(b.y,p.y));return Math.ceil(y*v)>0}({sourcePos:s.positionAbsolute||{x:0,y:0},targetPos:i.positionAbsolute||{x:0,y:0},sourceWidth:s.width,sourceHeight:s.height,targetWidth:i.width,targetHeight:i.height,width:o.width,height:o.height,transform:o.transform})}):o.edges,[t,e])),e,n)}const aw={[Zr.Arrow]:({color:t="none",strokeWidth:e=1})=>q.createElement("polyline",{style:{stroke:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[Zr.ArrowClosed]:({color:t="none",strokeWidth:e=1})=>q.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},CM=({id:t,type:e,color:n,width:o=12.5,height:r=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:a="auto-start-reverse"})=>{const l=function(c){const d=zt();return M.useMemo(()=>{var h,f;return Object.prototype.hasOwnProperty.call(aw,c)?aw[c]:((f=(h=d.getState()).onError)==null||f.call(h,"009",IT(c)),null)},[c])}(e);return l?q.createElement("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:a,refX:"0",refY:"0"},q.createElement(l,{color:n,strokeWidth:i})):null},lw=({defaultColor:t,rfId:e})=>{const n=dt(M.useCallback((({defaultColor:o,rfId:r})=>s=>{const i=[];return s.edges.reduce((a,l)=>([l.markerStart,l.markerEnd].forEach(c=>{if(c&&typeof c=="object"){const d=Qh(c,r);i.includes(d)||(a.push({id:d,color:c.color||o,...c}),i.push(d))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))})({defaultColor:t,rfId:e}),[t,e]),(o,r)=>!(o.length!==r.length||o.some((s,i)=>s.id!==r[i].id)));return q.createElement("defs",null,n.map(o=>q.createElement(CM,{id:o.id,key:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient})))};lw.displayName="MarkerDefinitions";var jM=M.memo(lw);const SM=t=>({nodesConnectable:t.nodesConnectable,edgesFocusable:t.edgesFocusable,edgesUpdatable:t.edgesUpdatable,elementsSelectable:t.elementsSelectable,width:t.width,height:t.height,connectionMode:t.connectionMode,nodeInternals:t.nodeInternals,onError:t.onError}),cw=({defaultMarkerColor:t,onlyRenderVisibleElements:e,elevateEdgesOnSelect:n,rfId:o,edgeTypes:r,noPanClassName:s,onEdgeContextMenu:i,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:g,reconnectRadius:x,children:p,disableKeyboardA11y:b})=>{const{edgesFocusable:y,edgesUpdatable:v,elementsSelectable:w,width:S,height:C,connectionMode:N,nodeInternals:j,onError:E}=dt(SM,Wt),T=kM(e,j,n);return S?q.createElement(q.Fragment,null,T.map(({level:I,edges:O,isMaxLevel:L})=>q.createElement("svg",{key:I,style:{zIndex:I},width:S,height:C,className:"react-flow__edges react-flow__container"},L&&q.createElement(jM,{defaultColor:t,rfId:o}),q.createElement("g",null,O.map(D=>{const[R,P,z]=iw(j.get(D.source)),[_,k,B]=iw(j.get(D.target));if(!z||!B)return null;let A=D.type||"default";r[A]||(E==null||E("011",MT(A)),A="default");const U=r[A]||r.default,$=N===fr.Strict?k.target:(k.target??[]).concat(k.source??[]),X=sw(P.source,D.sourceHandle),Y=sw($,D.targetHandle),G=(X==null?void 0:X.position)||Oe.Bottom,W=(Y==null?void 0:Y.position)||Oe.Top,J=!!(D.focusable||y&&D.focusable===void 0),V=D.reconnectable||D.updatable,Q=f!==void 0&&(V||v&&V===void 0);if(!X||!Y)return E==null||E("008",AT(X,D)),null;const{sourceX:te,sourceY:re,targetX:ne,targetY:ie}=((se,ae,ge,oe,ue,de)=>{const Se=rw(ge,se,ae),Te=rw(de,oe,ue);return{sourceX:Se.x,sourceY:Se.y,targetX:Te.x,targetY:Te.y}})(R,X,G,_,Y,W);return q.createElement(U,{key:D.id,id:D.id,className:Qt([D.className,s]),type:A,data:D.data,selected:!!D.selected,animated:!!D.animated,hidden:!!D.hidden,label:D.label,labelStyle:D.labelStyle,labelShowBg:D.labelShowBg,labelBgStyle:D.labelBgStyle,labelBgPadding:D.labelBgPadding,labelBgBorderRadius:D.labelBgBorderRadius,style:D.style,source:D.source,target:D.target,sourceHandleId:D.sourceHandle,targetHandleId:D.targetHandle,markerEnd:D.markerEnd,markerStart:D.markerStart,sourceX:te,sourceY:re,targetX:ne,targetY:ie,sourcePosition:G,targetPosition:W,elementsSelectable:w,onContextMenu:i,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,onClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:g,reconnectRadius:x,rfId:o,ariaLabel:D.ariaLabel,isFocusable:J,isReconnectable:Q,pathOptions:"pathOptions"in D?D.pathOptions:void 0,interactionWidth:D.interactionWidth,disableKeyboardA11y:b})})))),p):null};cw.displayName="EdgeRenderer";var NM=M.memo(cw);const EM=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function _M({children:t}){const e=dt(EM);return q.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:e}},t)}const IM={[Oe.Left]:Oe.Right,[Oe.Right]:Oe.Left,[Oe.Top]:Oe.Bottom,[Oe.Bottom]:Oe.Top},dw=({nodeId:t,handleType:e,style:n,type:o=Uo.Bezier,CustomComponent:r,connectionStatus:s})=>{var C,N,j;const{fromNode:i,handleId:a,toX:l,toY:c,connectionMode:d}=dt(M.useCallback(E=>({fromNode:E.nodeInternals.get(t),handleId:E.connectionHandleId,toX:(E.connectionPosition.x-E.transform[0])/E.transform[2],toY:(E.connectionPosition.y-E.transform[1])/E.transform[2],connectionMode:E.connectionMode}),[t]),Wt),h=(C=i==null?void 0:i[yt])==null?void 0:C.handleBounds;let f=h==null?void 0:h[e];if(d===fr.Loose&&(f=f||(h==null?void 0:h[e==="source"?"target":"source"])),!i||!f)return null;const m=a?f.find(E=>E.id===a):f[0],g=m?m.x+m.width/2:(i.width??0)/2,x=m?m.y+m.height/2:i.height??0,p=(((N=i.positionAbsolute)==null?void 0:N.x)??0)+g,b=(((j=i.positionAbsolute)==null?void 0:j.y)??0)+x,y=m==null?void 0:m.position,v=y?IM[y]:null;if(!y||!v)return null;if(r)return q.createElement(r,{connectionLineType:o,connectionLineStyle:n,fromNode:i,fromHandle:m,fromX:p,fromY:b,toX:l,toY:c,fromPosition:y,toPosition:v,connectionStatus:s});let w="";const S={sourceX:p,sourceY:b,sourcePosition:y,targetX:l,targetY:c,targetPosition:v};return o===Uo.Bezier?[w]=x2(S):o===Uo.Step?[w]=Kh({...S,borderRadius:0}):o===Uo.SmoothStep?[w]=Kh(S):o===Uo.SimpleBezier?[w]=f2(S):w=`M${p},${b} ${l},${c}`,q.createElement("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};dw.displayName="ConnectionLine";const AM=t=>({nodeId:t.connectionNodeId,handleType:t.connectionHandleType,nodesConnectable:t.nodesConnectable,connectionStatus:t.connectionStatus,width:t.width,height:t.height});function TM({containerStyle:t,style:e,type:n,component:o}){const{nodeId:r,handleType:s,nodesConnectable:i,width:a,height:l,connectionStatus:c}=dt(AM,Wt);return r&&s&&a&&i?q.createElement("svg",{style:t,width:a,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},q.createElement("g",{className:Qt(["react-flow__connection",c])},q.createElement(dw,{nodeId:r,handleType:s,style:e,type:n,CustomComponent:o,connectionStatus:c}))):null}function uw(t,e){return M.useRef(null),zt(),M.useMemo(()=>e(t),[t])}const hw=({nodeTypes:t,edgeTypes:e,onMove:n,onMoveStart:o,onMoveEnd:r,onInit:s,onNodeClick:i,onEdgeClick:a,onNodeDoubleClick:l,onEdgeDoubleClick:c,onNodeMouseEnter:d,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:m,onSelectionContextMenu:g,onSelectionStart:x,onSelectionEnd:p,connectionLineType:b,connectionLineStyle:y,connectionLineComponent:v,connectionLineContainerStyle:w,selectionKeyCode:S,selectionOnDrag:C,selectionMode:N,multiSelectionKeyCode:j,panActivationKeyCode:E,zoomActivationKeyCode:T,deleteKeyCode:I,onlyRenderVisibleElements:O,elementsSelectable:L,selectNodesOnDrag:D,defaultViewport:R,translateExtent:P,minZoom:z,maxZoom:_,preventScrolling:k,defaultMarkerColor:B,zoomOnScroll:A,zoomOnPinch:U,panOnScroll:$,panOnScrollSpeed:X,panOnScrollMode:Y,zoomOnDoubleClick:G,panOnDrag:W,onPaneClick:J,onPaneMouseEnter:V,onPaneMouseMove:Q,onPaneMouseLeave:te,onPaneScroll:re,onPaneContextMenu:ne,onEdgeContextMenu:ie,onEdgeMouseEnter:se,onEdgeMouseMove:ae,onEdgeMouseLeave:ge,onReconnect:oe,onReconnectStart:ue,onReconnectEnd:de,reconnectRadius:Se,noDragClassName:Te,noWheelClassName:Fe,noPanClassName:_e,elevateEdgesOnSelect:ke,disableKeyboardA11y:Ye,nodeOrigin:Ve,nodeExtent:Ke,rfId:ee})=>{const ye=uw(t,mM),we=uw(e,vM);return function(Ie){const K=_i(),me=M.useRef(!1);M.useEffect(()=>{!me.current&&K.viewportInitialized&&Ie&&(setTimeout(()=>Ie(K),1),me.current=!0)},[Ie,K.viewportInitialized])}(s),q.createElement(fM,{onPaneClick:J,onPaneMouseEnter:V,onPaneMouseMove:Q,onPaneMouseLeave:te,onPaneContextMenu:ne,onPaneScroll:re,deleteKeyCode:I,selectionKeyCode:S,selectionOnDrag:C,selectionMode:N,onSelectionStart:x,onSelectionEnd:p,multiSelectionKeyCode:j,panActivationKeyCode:E,zoomActivationKeyCode:T,elementsSelectable:L,onMove:n,onMoveStart:o,onMoveEnd:r,zoomOnScroll:A,zoomOnPinch:U,zoomOnDoubleClick:G,panOnScroll:$,panOnScrollSpeed:X,panOnScrollMode:Y,panOnDrag:W,defaultViewport:R,translateExtent:P,minZoom:z,maxZoom:_,onSelectionContextMenu:g,preventScrolling:k,noDragClassName:Te,noWheelClassName:Fe,noPanClassName:_e,disableKeyboardA11y:Ye},q.createElement(_M,null,q.createElement(NM,{edgeTypes:we,onEdgeClick:a,onEdgeDoubleClick:c,onlyRenderVisibleElements:O,onEdgeContextMenu:ie,onEdgeMouseEnter:se,onEdgeMouseMove:ae,onEdgeMouseLeave:ge,onReconnect:oe,onReconnectStart:ue,onReconnectEnd:de,reconnectRadius:Se,defaultMarkerColor:B,noPanClassName:_e,elevateEdgesOnSelect:!!ke,disableKeyboardA11y:Ye,rfId:ee},q.createElement(TM,{style:y,type:b,component:v,containerStyle:w})),q.createElement("div",{className:"react-flow__edgelabel-renderer"}),q.createElement(gM,{nodeTypes:ye,onNodeClick:i,onNodeDoubleClick:l,onNodeMouseEnter:d,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:m,selectNodesOnDrag:D,onlyRenderVisibleElements:O,noPanClassName:_e,noDragClassName:Te,disableKeyboardA11y:Ye,nodeOrigin:Ve,nodeExtent:Ke,rfId:ee})))};hw.displayName="GraphView";var MM=M.memo(hw);const ff=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ho={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:ff,nodeExtent:ff,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:fr.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:(t,e)=>{},isValidConnection:void 0},OM=()=>((t,e)=>t?Xv(t,e):Xv)((t,e)=>({...Ho,setNodes:n=>{const{nodeInternals:o,nodeOrigin:r,elevateNodesOnSelect:s}=e();t({nodeInternals:af(n,o,r,s)})},getNodes:()=>Array.from(e().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=e();t({edges:n.map(r=>({...o,...r}))})},setDefaultNodesAndEdges:(n,o)=>{const r=n!==void 0,s=o!==void 0,i=r?af(n,new Map,e().nodeOrigin,e().elevateNodesOnSelect):new Map;t({nodeInternals:i,edges:s?o:[],hasDefaultNodes:r,hasDefaultEdges:s})},updateNodeDimensions:n=>{const{onNodesChange:o,nodeInternals:r,fitViewOnInit:s,fitViewOnInitDone:i,fitViewOnInitOptions:a,domNode:l,nodeOrigin:c}=e(),d=l==null?void 0:l.querySelector(".react-flow__viewport");if(!d)return;const h=window.getComputedStyle(d),{m22:f}=new window.DOMMatrixReadOnly(h.transform),m=n.reduce((x,p)=>{const b=r.get(p.id);if(b!=null&&b.hidden)r.set(b.id,{...b,[yt]:{...b[yt],handleBounds:void 0}});else if(b){const y=$h(p.nodeElement);!(!y.width||!y.height||b.width===y.width&&b.height===y.height&&!p.forceUpdate)&&(r.set(b.id,{...b,[yt]:{...b[yt],handleBounds:{source:J2(".source",p.nodeElement,f,c),target:J2(".target",p.nodeElement,f,c)}},...y}),x.push({id:b.id,type:"dimensions",dimensions:y}))}return x},[]);B2(r,c);const g=i||s&&!i&&U2(e,{initial:!0,...a});t({nodeInternals:new Map(r),fitViewOnInitDone:g}),(m==null?void 0:m.length)>0&&(o==null||o(m))},updateNodePositions:(n,o=!0,r=!1)=>{const{triggerNodeChanges:s}=e(),i=n.map(a=>{const l={id:a.id,type:"position",dragging:r};return o&&(l.positionAbsolute=a.positionAbsolute,l.position=a.position),l});s(i)},triggerNodeChanges:n=>{const{onNodesChange:o,nodeInternals:r,hasDefaultNodes:s,nodeOrigin:i,getNodes:a,elevateNodesOnSelect:l}=e();if(n!=null&&n.length){if(s){const c=af(q2(n,a()),r,i,l);t({nodeInternals:c})}o==null||o(n)}},addSelectedNodes:n=>{const{multiSelectionActive:o,edges:r,getNodes:s}=e();let i,a=null;o?i=n.map(l=>Vo(l,!0)):(i=os(s(),n),a=os(r,[])),Kl({changedNodes:i,changedEdges:a,get:e,set:t})},addSelectedEdges:n=>{const{multiSelectionActive:o,edges:r,getNodes:s}=e();let i,a=null;o?i=n.map(l=>Vo(l,!0)):(i=os(r,n),a=os(s(),[])),Kl({changedNodes:a,changedEdges:i,get:e,set:t})},unselectNodesAndEdges:({nodes:n,edges:o}={})=>{const{edges:r,getNodes:s}=e(),i=o||r;Kl({changedNodes:(n||s()).map(a=>(a.selected=!1,Vo(a.id,!1))),changedEdges:i.map(a=>Vo(a.id,!1)),get:e,set:t})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:r}=e();o==null||o.scaleExtent([n,r]),t({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:r}=e();o==null||o.scaleExtent([r,n]),t({maxZoom:n})},setTranslateExtent:n=>{var o;(o=e().d3Zoom)==null||o.translateExtent(n),t({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:o}=e();Kl({changedNodes:o().filter(r=>r.selected).map(r=>Vo(r.id,!1)),changedEdges:n.filter(r=>r.selected).map(r=>Vo(r.id,!1)),get:e,set:t})},setNodeExtent:n=>{const{nodeInternals:o}=e();o.forEach(r=>{r.positionAbsolute=Vh(r.position,n)}),t({nodeExtent:n,nodeInternals:new Map(o)})},panBy:n=>{const{transform:o,width:r,height:s,d3Zoom:i,d3Selection:a,translateExtent:l}=e();if(!i||!a||!n.x&&!n.y)return!1;const c=er.translate(o[0]+n.x,o[1]+n.y).scale(o[2]),d=[[0,0],[r,s]],h=i==null?void 0:i.constrain()(c,d,l);return i.transform(a,h),o[0]!==h.x||o[1]!==h.y||o[2]!==h.k},cancelConnection:()=>t({connectionNodeId:Ho.connectionNodeId,connectionHandleId:Ho.connectionHandleId,connectionHandleType:Ho.connectionHandleType,connectionStatus:Ho.connectionStatus,connectionStartHandle:Ho.connectionStartHandle,connectionEndHandle:Ho.connectionEndHandle}),reset:()=>t({...Ho})}),Object.is),mf=({children:t})=>{const e=M.useRef(null);return e.current||(e.current=OM()),q.createElement(ST,{value:e.current},t)};mf.displayName="ReactFlowProvider";const fw=({children:t})=>M.useContext(Ul)?q.createElement(q.Fragment,null,t):q.createElement(mf,null,t);fw.displayName="ReactFlowWrapper";const DM={input:A2,default:rf,output:M2,group:sf},RM={default:Gl,straight:Jh,step:Xh,smoothstep:Wl,simplebezier:Yh},PM=[0,0],LM=[15,15],FM={x:0,y:0,zoom:1},zM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},pf=M.forwardRef(({nodes:t,edges:e,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:s=DM,edgeTypes:i=RM,onNodeClick:a,onEdgeClick:l,onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onConnect:m,onConnectStart:g,onConnectEnd:x,onClickConnectStart:p,onClickConnectEnd:b,onNodeMouseEnter:y,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:C,onNodeDragStart:N,onNodeDrag:j,onNodeDragStop:E,onNodesDelete:T,onEdgesDelete:I,onSelectionChange:O,onSelectionDragStart:L,onSelectionDrag:D,onSelectionDragStop:R,onSelectionContextMenu:P,onSelectionStart:z,onSelectionEnd:_,connectionMode:k=fr.Strict,connectionLineType:B=Uo.Bezier,connectionLineStyle:A,connectionLineComponent:U,connectionLineContainerStyle:$,deleteKeyCode:X="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:G=!1,selectionMode:W=Si.Full,panActivationKeyCode:J="Space",multiSelectionKeyCode:V=Vl()?"Meta":"Control",zoomActivationKeyCode:Q=Vl()?"Meta":"Control",snapToGrid:te=!1,snapGrid:re=LM,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:ie=!0,nodesDraggable:se,nodesConnectable:ae,nodesFocusable:ge,nodeOrigin:oe=PM,edgesFocusable:ue,edgesUpdatable:de,elementsSelectable:Se,defaultViewport:Te=FM,minZoom:Fe=.5,maxZoom:_e=2,translateExtent:ke=ff,preventScrolling:Ye=!0,nodeExtent:Ve,defaultMarkerColor:Ke="#b1b1b7",zoomOnScroll:ee=!0,zoomOnPinch:ye=!0,panOnScroll:we=!1,panOnScrollSpeed:Ie=.5,panOnScrollMode:K=Bo.Free,zoomOnDoubleClick:me=!0,panOnDrag:pe=!0,onPaneClick:he,onPaneMouseEnter:Ce,onPaneMouseMove:Re,onPaneMouseLeave:Pe,onPaneScroll:He,onPaneContextMenu:le,children:Ae,onEdgeContextMenu:Me,onEdgeDoubleClick:Ue,onEdgeMouseEnter:qe,onEdgeMouseMove:De,onEdgeMouseLeave:$e,onEdgeUpdate:st,onEdgeUpdateStart:Xe,onEdgeUpdateEnd:it,onReconnect:Ut,onReconnectStart:qt,onReconnectEnd:xn,reconnectRadius:en=10,edgeUpdaterRadius:Ln=10,onNodesChange:as,onEdgesChange:Xn,noDragClassName:So="nodrag",noWheelClassName:_n="nowheel",noPanClassName:ls="nopan",fitView:Mi=!1,fitViewOptions:pO,connectOnClick:gO=!0,attributionPosition:xO,proOptions:bO,defaultEdgeOptions:yO,elevateNodesOnSelect:vO=!0,elevateEdgesOnSelect:wO=!1,disableKeyboardA11y:s3=!1,autoPanOnConnect:kO=!0,autoPanOnNodeDrag:CO=!0,connectionRadius:jO=20,isValidConnection:SO,onError:NO,style:EO,id:i3,nodeDragThreshold:_O,...IO},AO)=>{const im=i3||"1";return q.createElement("div",{...IO,style:{...EO,...zM},ref:AO,className:Qt(["react-flow",r]),"data-testid":"rf__wrapper",id:i3},q.createElement(fw,null,q.createElement(MM,{onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:y,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:C,nodeTypes:s,edgeTypes:i,connectionLineType:B,connectionLineStyle:A,connectionLineComponent:U,connectionLineContainerStyle:$,selectionKeyCode:Y,selectionOnDrag:G,selectionMode:W,deleteKeyCode:X,multiSelectionKeyCode:V,panActivationKeyCode:J,zoomActivationKeyCode:Q,onlyRenderVisibleElements:ne,selectNodesOnDrag:ie,defaultViewport:Te,translateExtent:ke,minZoom:Fe,maxZoom:_e,preventScrolling:Ye,zoomOnScroll:ee,zoomOnPinch:ye,zoomOnDoubleClick:me,panOnScroll:we,panOnScrollSpeed:Ie,panOnScrollMode:K,panOnDrag:pe,onPaneClick:he,onPaneMouseEnter:Ce,onPaneMouseMove:Re,onPaneMouseLeave:Pe,onPaneScroll:He,onPaneContextMenu:le,onSelectionContextMenu:P,onSelectionStart:z,onSelectionEnd:_,onEdgeContextMenu:Me,onEdgeDoubleClick:Ue,onEdgeMouseEnter:qe,onEdgeMouseMove:De,onEdgeMouseLeave:$e,onReconnect:Ut??st,onReconnectStart:qt??Xe,onReconnectEnd:xn??it,reconnectRadius:en??Ln,defaultMarkerColor:Ke,noDragClassName:So,noWheelClassName:_n,noPanClassName:ls,elevateEdgesOnSelect:wO,rfId:im,disableKeyboardA11y:s3,nodeOrigin:oe,nodeExtent:Ve}),q.createElement(YT,{nodes:t,edges:e,defaultNodes:n,defaultEdges:o,onConnect:m,onConnectStart:g,onConnectEnd:x,onClickConnectStart:p,onClickConnectEnd:b,nodesDraggable:se,nodesConnectable:ae,nodesFocusable:ge,edgesFocusable:ue,edgesUpdatable:de,elementsSelectable:Se,elevateNodesOnSelect:vO,minZoom:Fe,maxZoom:_e,nodeExtent:Ve,onNodesChange:as,onEdgesChange:Xn,snapToGrid:te,snapGrid:re,connectionMode:k,translateExtent:ke,connectOnClick:gO,defaultEdgeOptions:yO,fitView:Mi,fitViewOptions:pO,onNodesDelete:T,onEdgesDelete:I,onNodeDragStart:N,onNodeDrag:j,onNodeDragStop:E,onSelectionDrag:D,onSelectionDragStart:L,onSelectionDragStop:R,noPanClassName:ls,nodeOrigin:oe,rfId:im,autoPanOnConnect:kO,autoPanOnNodeDrag:CO,onError:NO,connectionRadius:jO,isValidConnection:SO,nodeDragThreshold:_O}),q.createElement(qT,{onSelectionChange:O}),Ae,q.createElement(RT,{proOptions:bO,position:xO}),q.createElement(ZT,{rfId:im,disableKeyboardA11y:s3})))});function mw(t){return e=>{const[n,o]=M.useState(e),r=M.useCallback(s=>o(i=>t(s,i)),[]);return[n,o,r]}}pf.displayName="ReactFlow";const pw=mw(q2),gw=mw(function(t,e){return W2(t,e)});function BM(){return q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},q.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function UM(){return q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},q.createElement("path",{d:"M0 0h32v4.2H0z"}))}function $M(){return q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},q.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 VM(){return q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},q.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 HM(){return q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},q.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 is=({children:t,className:e,...n})=>q.createElement("button",{type:"button",className:Qt(["react-flow__controls-button",e]),...n},t);is.displayName="ControlButton";const WM=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom}),xw=({style:t,showZoom:e=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:s,onZoomOut:i,onFitView:a,onInteractiveChange:l,className:c,children:d,position:h="bottom-left"})=>{const f=zt(),[m,g]=M.useState(!1),{isInteractive:x,minZoomReached:p,maxZoomReached:b}=dt(WM,Wt),{zoomIn:y,zoomOut:v,fitView:w}=_i();return M.useEffect(()=>{g(!0)},[]),m?q.createElement($l,{className:Qt(["react-flow__controls",c]),position:h,style:t,"data-testid":"rf__controls"},e&&q.createElement(q.Fragment,null,q.createElement(is,{onClick:()=>{y(),s==null||s()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:b},q.createElement(BM,null)),q.createElement(is,{onClick:()=>{v(),i==null||i()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:p},q.createElement(UM,null))),n&&q.createElement(is,{className:"react-flow__controls-fitview",onClick:()=>{w(r),a==null||a()},title:"fit view","aria-label":"fit view"},q.createElement($M,null)),o&&q.createElement(is,{className:"react-flow__controls-interactive",onClick:()=>{f.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),l==null||l(!x)},title:"toggle interactivity","aria-label":"toggle interactivity"},x?q.createElement(HM,null):q.createElement(VM,null)),d):null};xw.displayName="Controls";var En,qM=M.memo(xw);function GM({color:t,dimensions:e,lineWidth:n}){return q.createElement("path",{stroke:t,strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`})}function YM({color:t,radius:e}){return q.createElement("circle",{cx:e,cy:e,r:e,fill:t})}(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(En||(En={}));const KM={[En.Dots]:"#91919a",[En.Lines]:"#eee",[En.Cross]:"#e2e2e2"},XM={[En.Dots]:1,[En.Lines]:1,[En.Cross]:6},JM=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function bw({id:t,variant:e=En.Dots,gap:n=20,size:o,lineWidth:r=1,offset:s=2,color:i,style:a,className:l}){const c=M.useRef(null),{transform:d,patternId:h}=dt(JM,Wt),f=i||KM[e],m=o||XM[e],g=e===En.Dots,x=e===En.Cross,p=Array.isArray(n)?n:[n,n],b=[p[0]*d[2]||1,p[1]*d[2]||1],y=m*d[2],v=x?[y,y]:b,w=g?[y/s,y/s]:[v[0]/s,v[1]/s];return q.createElement("svg",{className:Qt(["react-flow__background",l]),style:{...a,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:c,"data-testid":"rf__background"},q.createElement("pattern",{id:h+t,x:d[0]%b[0],y:d[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${w[0]},-${w[1]})`},g?q.createElement(YM,{color:f,radius:y/s}):q.createElement(GM,{dimensions:v,color:f,lineWidth:r})),q.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${h+t})`}))}bw.displayName="Background";var ZM=M.memo(bw);function gf(t){return Math.min(11*t+35,200)}const yw=q.createContext("LR"),vw=M.memo(t=>{const e=H.c(51),{data:n,selected:o}=t,r=je(n.atom),s=wr().inOrderIds.indexOf(r.id),i=o?"var(--gray-9)":"var(--gray-3)",a=dt(QM),l=M.use(yw);let c,d,h,f,m;if(e[0]!==r.code||e[1]!==i||e[2]!==l||e[3]!==o){const I=r.code.split(`
160
+ `).length,O=l==="LR"?Oe.Left:Oe.Top;let L;e[8]!==i?(L={background:i},e[8]=i,e[9]=L):L=e[9],e[10]!==O||e[11]!==L?(h=u.jsx($o,{type:"target",id:"inputs",position:O,style:L}),e[10]=O,e[11]=L,e[12]=h):h=e[12];const D=l==="LR"?Oe.Left:Oe.Top;let R;e[13]!==i?(R={background:i},e[13]=i,e[14]=R):R=e[14],e[15]!==D||e[16]!==R?(f=u.jsx($o,{type:"source",id:"inputs",position:D,style:R}),e[15]=D,e[16]=R,e[17]=f):f=e[17];const P=o&&"border-primary";e[18]!==P?(d=xe("flex flex-col bg-card border border-input/50 rounded-md mx-[2px] overflow-hidden",P),e[18]=P,e[19]=d):d=e[19],c=gf(I),e[0]=r.code,e[1]=i,e[2]=l,e[3]=o,e[4]=c,e[5]=d,e[6]=h,e[7]=f}else c=e[4],d=e[5],h=e[6],f=e[7];var g;let x;e[20]!==n.forceWidth||e[21]!==a?(m=n.forceWidth||(g=a,Math.min(Math.max(g-100,100),400)),e[20]=n.forceWidth,e[21]=a,e[22]=m):m=e[22],e[23]!==c||e[24]!==m?(x={height:c,width:m},e[23]=c,e[24]=m,e[25]=x):x=e[25];const p=cL(r.name,s);let b,y,v;e[26]!==p?(b=u.jsx("div",{className:"text-muted-foreground font-semibold text-xs py-1 px-2 bg-muted border-b",children:p}),e[26]=p,e[27]=b):b=e[27],e[28]!==r.code?(y=u.jsx(FF,{code:r.code}),e[28]=r.code,e[29]=y):y=e[29],e[30]!==d||e[31]!==x||e[32]!==b||e[33]!==y?(v=u.jsxs("div",{className:d,style:x,children:[b,y]}),e[30]=d,e[31]=x,e[32]=b,e[33]=y,e[34]=v):v=e[34];const w=l==="LR"?Oe.Right:Oe.Bottom;let S,C;e[35]!==i?(S={background:i},e[35]=i,e[36]=S):S=e[36],e[37]!==w||e[38]!==S?(C=u.jsx($o,{type:"source",id:"outputs",position:w,style:S}),e[37]=w,e[38]=S,e[39]=C):C=e[39];const N=l==="LR"?Oe.Right:Oe.Bottom;let j,E,T;return e[40]!==i?(j={background:i},e[40]=i,e[41]=j):j=e[41],e[42]!==N||e[43]!==j?(E=u.jsx($o,{type:"target",id:"outputs",position:N,style:j}),e[42]=N,e[43]=j,e[44]=E):E=e[44],e[45]!==v||e[46]!==C||e[47]!==E||e[48]!==h||e[49]!==f?(T=u.jsxs("div",{children:[h,f,v,C,E]}),e[45]=v,e[46]=C,e[47]=E,e[48]=h,e[49]=f,e[50]=T):T=e[50],T},(t,e)=>["data","selected","id"].every(n=>t[n]===e[n]));vw.displayName="CustomNode";const ww={custom:vw};function QM(t){const{width:e}=t;return e}const kw=t=>{const e=H.c(18),{maxCount:n,cellIds:o,onClick:r,skipScroll:s}=t,i=wr();let a,l,c,d;if(e[0]!==o||e[1]!==i||e[2]!==n||e[3]!==r||e[4]!==s){c=Symbol.for("react.early_return_sentinel");e:{let h;e[8]!==i?(h=(g,x)=>i.inOrderIds.indexOf(g)-i.inOrderIds.indexOf(x),e[8]=i,e[9]=h):h=e[9];const f=[...o].sort(h);if(o.length===0){let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=u.jsx("div",{className:"text-muted-foreground",children:"--"}),e[10]=g):g=e[10],c=g;break e}let m;e[11]!==o.length||e[12]!==r||e[13]!==s?(m=(g,x)=>u.jsxs("span",{className:"truncate",children:[u.jsx(Mo,{variant:"focus",cellId:g,skipScroll:s,className:"whitespace-nowrap",onClick:r?()=>r(g):void 0},g),x<o.length-1&&", "]},g),e[11]=o.length,e[12]=r,e[13]=s,e[14]=m):m=e[14],a=f.slice(0,n).map(m),l=o.length>n&&u.jsxs(yr,{children:[u.jsx(Cs,{asChild:!0,children:u.jsxs("span",{className:"whitespace-nowrap text-muted-foreground text-xs hover:underline cursor-pointer",children:["+",o.length-n," more"]})}),u.jsx(xs,{className:"w-auto",children:u.jsx("div",{className:"flex flex-col gap-1 py-1",children:f.slice(n).map(g=>u.jsx(Mo,{variant:"focus",cellId:g,className:"whitespace-nowrap",onClick:r?()=>r(g):void 0},g))})})]})}e[0]=o,e[1]=i,e[2]=n,e[3]=r,e[4]=s,e[5]=a,e[6]=l,e[7]=c}else a=e[5],l=e[6],c=e[7];return c!==Symbol.for("react.early_return_sentinel")?c:(e[15]!==a||e[16]!==l?(d=u.jsxs(u.Fragment,{children:[a,l]}),e[15]=a,e[16]=l,e[17]=d):d=e[17],d)},xf=t=>{const e=H.c(15);let n,o,r,s;e[0]!==t?({name:o,declaredBy:n,onClick:r,...s}=t,e[0]=t,e[1]=n,e[2]=o,e[3]=r,e[4]=s):(n=e[1],o=e[2],r=e[3],s=e[4]);const i=n.length>1?"destructive":"outline";let a,l,c;return e[5]!==o||e[6]!==r?(a=async d=>{r?r(d):(await sn(o),Je({title:"Copied to clipboard"}))},e[5]=o,e[6]=r,e[7]=a):a=e[7],e[8]!==o||e[9]!==i||e[10]!==a?(l=u.jsx(VC,{title:o,variant:i,className:"rounded-sm text-ellipsis block overflow-hidden max-w-fit cursor-pointer font-medium",onClick:a,children:o}),e[8]=o,e[9]=i,e[10]=a,e[11]=l):l=e[11],e[12]!==s||e[13]!==l?(c=u.jsx("div",{className:"max-w-[130px]",...s,children:l}),e[12]=s,e[13]=l,e[14]=c):c=e[14],c},bf=M.memo(t=>{const e=H.c(38),{onChange:n,view:o,settings:r,onSettingsChange:s}=t;let i;e[0]!==s||e[1]!==r?(i=(D,R)=>{s({...r,[D]:R})},e[0]=s,e[1]=r,e[2]=i):i=e[2];const a=i;let l,c,d,h,f,m;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx(Cs,{asChild:!0,children:u.jsx(ve,{variant:"text",size:"xs",children:u.jsx(Sm,{className:"w-4 h-4"})})}),e[3]=l):l=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(c=u.jsx("div",{className:"font-semibold pb-4",children:"Settings"}),e[4]=c):c=e[4],e[5]!==a?(d=D=>a("hidePureMarkdown",!!D),e[5]=a,e[6]=d):d=e[6],e[7]!==r.hidePureMarkdown||e[8]!==d?(h=u.jsx(bC,{"data-testid":"hide-pure-markdown-checkbox",id:"hide-pure-markdown",checked:r.hidePureMarkdown,onCheckedChange:d}),e[7]=r.hidePureMarkdown,e[8]=d,e[9]=h):h=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(f=u.jsx(xr,{htmlFor:"hide-pure-markdown",children:"Hide pure markdown"}),e[10]=f):f=e[10],e[11]!==h?(m=u.jsxs(yr,{children:[l,u.jsxs(xs,{className:"w-auto p-2 text-muted-foreground",children:[c,u.jsxs("div",{className:"flex items-center gap-2",children:[h,f]})]})]}),e[11]=h,e[12]=m):m=e[12];const g=m,x=o==="_minimap_";let p,b,y;e[13]!==n?(p=()=>n("_minimap_"),e[13]=n,e[14]=p):p=e[14],e[15]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(Hp,{className:"w-4 h-4 mr-1"}),e[15]=b):b=e[15],e[16]!==x||e[17]!==p?(y=u.jsxs(ve,{variant:"outline",className:"bg-background","aria-selected":x,size:"xs",onClick:p,children:[b,"Mini Map"]}),e[16]=x,e[17]=p,e[18]=y):y=e[18];const v=o==="TB";let w,S,C;e[19]!==n?(w=()=>n("TB"),e[19]=n,e[20]=w):w=e[20],e[21]===Symbol.for("react.memo_cache_sentinel")?(S=u.jsx(ya,{className:"w-4 h-4 mr-1"}),e[21]=S):S=e[21],e[22]!==v||e[23]!==w?(C=u.jsxs(ve,{variant:"outline",className:"bg-background","aria-selected":v,size:"xs",onClick:w,children:[S,"Vertical Tree"]}),e[22]=v,e[23]=w,e[24]=C):C=e[24];const N=o==="LR";let j,E,T,I;e[25]!==n?(j=()=>n("LR"),e[25]=n,e[26]=j):j=e[26],e[27]===Symbol.for("react.memo_cache_sentinel")?(E=u.jsx(ya,{className:"w-4 h-4 mr-1 transform -rotate-90"}),e[27]=E):E=e[27],e[28]!==N||e[29]!==j?(T=u.jsxs(ve,{variant:"outline",className:"bg-background","aria-selected":N,size:"xs",onClick:j,children:[E," ","Horizontal Tree"]}),e[28]=N,e[29]=j,e[30]=T):T=e[30],e[31]!==y||e[32]!==C||e[33]!==T?(I=u.jsxs("div",{className:"flex gap-2",children:[y,C,T]}),e[31]=y,e[32]=C,e[33]=T,e[34]=I):I=e[34];const O=o!=="_minimap_"&&g;let L;return e[35]!==I||e[36]!==O?(L=u.jsxs($l,{position:"top-right",className:"flex flex-col items-end gap-2",children:[I,O]}),e[35]=I,e[36]=O,e[37]=L):L=e[37],L});bf.displayName="GraphToolbar";const Jl=M.memo(t=>{const e=H.c(11),{selection:n,variables:o,onClearSelection:r}=t;if(!n)return null;const s=e7;let i;e[0]!==r||e[1]!==n.id||e[2]!==n.source||e[3]!==n.target||e[4]!==n.type||e[5]!==o?(i=()=>{if(n.type==="node"){const d=Object.values(o).filter(m=>m.usedBy.includes(n.id)),h=Object.values(o).filter(m=>m.declaredBy.includes(n.id)),f=(m,g)=>u.jsxs(u.Fragment,{children:[m.length===0&&u.jsx("div",{className:"text-muted-foreground text-sm text-center",children:"--"}),u.jsx("div",{className:"grid grid-cols-5 gap-3 items-center text-sm py-1 flex-1 empty:hidden",children:m.map(x=>u.jsxs(q.Fragment,{children:[u.jsx(xf,{declaredBy:x.declaredBy,name:x.name}),u.jsxs("div",{className:"truncate col-span-2",title:x.value??"",children:[x.value,u.jsxs("span",{className:"ml-1 truncate text-foreground/60 font-mono",children:["(",x.dataType,")"]})]}),u.jsx("div",{className:"truncate col-span-2 gap-1 items-center",children:u.jsx(kw,{skipScroll:!0,onClick:()=>s(g==="in"?x.declaredBy[0]:x.usedBy[0],x.name),maxCount:3,cellIds:x.usedBy})})]},x.name))})]});return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[u.jsx(nc,{className:"w-5 h-5"}),u.jsx(Mo,{cellId:n.id}),u.jsx("div",{className:"flex-1"}),u.jsx(Cx,{cellId:n.id,children:u.jsx(ve,{variant:"ghost",size:"icon",children:u.jsx(td,{className:"w-4 h-4"})})}),u.jsx(ve,{variant:"text",size:"icon",onClick:()=>{r()},children:u.jsx(wn,{className:"w-4 h-4"})})]}),u.jsxs("div",{className:"text-sm flex flex-col py-3 pl-2 pr-4 flex-1 justify-center",children:[u.jsxs("div",{className:"flex flex-col gap-2",children:[u.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[u.jsx(fp,{className:"w-4 h-4"}),"Outputs"]}),f(h,"out")]}),u.jsx("hr",{className:"border-divider my-3"}),u.jsxs("div",{className:"flex flex-col gap-2",children:[u.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[u.jsx(nn,{className:"w-4 h-4"}),"Inputs"]}),f(d,"in")]})]})]})}if(n.type==="edge"){const d=Object.values(o).filter(h=>h.declaredBy.includes(n.source)&&h.usedBy.includes(n.target));return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[u.jsx(wa,{className:"w-4 h-4"}),u.jsx(Mo,{cellId:n.source}),u.jsx(Xc,{className:"w-4 h-4"}),u.jsx(Mo,{cellId:n.target})]}),u.jsx("div",{className:"grid grid-cols-4 gap-3 max-w-[350px] items-center text-sm p-3 flex-1",children:d.map(h=>u.jsxs(q.Fragment,{children:[u.jsx(xf,{declaredBy:h.declaredBy,name:h.name,onClick:()=>{s(h.declaredBy[0],h.name)}}),u.jsx("div",{className:"truncate text-foreground/60 font-mono",children:h.dataType}),u.jsx("div",{className:"truncate col-span-2",title:h.value??"",children:h.value})]},h.name))})]})}},e[0]=r,e[1]=n.id,e[2]=n.source,e[3]=n.target,e[4]=n.type,e[5]=o,e[6]=i):i=e[6];const a=i;let l,c;return e[7]!==a?(l=a(),e[7]=a,e[8]=l):l=e[8],e[9]!==l?(c=u.jsx($l,{position:"bottom-left",className:"max-h-[90%] flex flex-col w-[calc(100%-5rem)]",children:u.jsx("div",{className:"min-h-[100px] shadow-md rounded-md border max-w-[550px] border-primary/40 my-4 min-w-[240px] bg-(--slate-1) text-muted-foreground/80 flex flex-col overflow-y-auto",children:l})}),e[9]=l,e[10]=c):c=e[10],c});function e7(t,e){const n=Li(t);n&&Qm(n,e)}function Cw(){const t=H.c(7),e=_i(),n=dt(n7),o=dt(t7);let r;t[0]!==e?(r=()=>{e.fitView({duration:100})},t[0]=e,t[1]=r):r=t[1];const s=dL(r,100);let i,a;t[2]!==s||t[3]!==o||t[4]!==n?(i=()=>{n&&o&&s()},a=[n,o,s],t[2]=s,t[3]=o,t[4]=n,t[5]=i,t[6]=a):(i=t[5],a=t[6]),M.useEffect(i,a)}function t7(t){const{height:e}=t;return e}function n7(t){const{width:e}=t;return e}Jl.displayName="GraphSelectionPanel";const jw=new class{createEdge(t,e,n){return{type:"smoothstep",pathOptions:{offset:20,borderRadius:100},data:{direction:n},markerEnd:{type:Zr.Arrow},id:`${t}-${e}-${n}`,source:t,sourceHandle:n,targetHandle:n,target:e}}createNode(t,e,n){return{id:t,data:{atom:e},width:250,type:"custom",height:gf(Qe.get(e).code.trim().split(`
161
+ `).length),position:{x:0,y:n+20}}}createElements(t,e,n,o){let r=0;const s=[],i=[];for(const[l,c]of Jm.zip(t,e)){const d=this.createNode(l,c,r);s.push(d),r=d.position.y+(d.height||0)}const a=new Set;for(const l of Object.values(n)){const{declaredBy:c,usedBy:d}=l;for(const h of c)for(const f of d){const m=`${h}-${f}`;a.has(m)||(a.add(m),i.push(this.createEdge(h,f,"inputs"),this.createEdge(h,f,"outputs")))}}return{nodes:s,edges:i}}},o7=t=>{const e=H.c(37),{cellIds:n,variables:o,cellAtoms:r,children:s}=t;let i;e[0]!==r||e[1]!==n||e[2]!==o?(i=jw.createElements(n,r,o,!1),e[0]=r,e[1]=n,e[2]=o,e[3]=i):i=e[3];const{nodes:a,edges:l}=i;let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[4]=c):c=e[4];const[d,h]=gw(c),[f,m]=pw(a),[g,x]=M.useState(),[p,b]=M.useState(),y=M.useRef(!1);Cw();const v=dt(r7);let w;e[5]!==h||e[6]!==m?(w=k=>{m(k.nodes),h([])},e[5]=h,e[6]=m,e[7]=w):w=e[7];const S=Le(w);let C,N,j,E;e[8]!==r||e[9]!==n||e[10]!==S||e[11]!==o?(C=()=>{y.current?S(jw.createElements(n,r,o,!1)):y.current=!0},N=[n,o,r,S],e[8]=r,e[9]=n,e[10]=S,e[11]=o,e[12]=C,e[13]=N):(C=e[12],N=e[13]),M.useEffect(C,N),e[14]!==l||e[15]!==g||e[16]!==h?(j=()=>{if(g){const k=l.filter(B=>{const{source:A,target:U,data:$}=B;return A===g&&$.direction==="outputs"||U===g&&$.direction==="inputs"});h(k)}},E=[g,h,l],e[14]=l,e[15]=g,e[16]=h,e[17]=j,e[18]=E):(j=e[17],E=e[18]),M.useEffect(j,E);const T=function(k,B){const A=H.c(17);let U,$;if(A[0]!==B||A[1]!==k){let Q;A[3]!==B?(Q=(te,re)=>{const{position:ne}=re;return Math.min(te,ne.y-B/2-10)},A[3]=B,A[4]=Q):Q=A[4],$=k.reduce(Q,Number.POSITIVE_INFINITY),A[0]=B,A[1]=k,A[2]=$}else $=A[2];const X=$;let Y;if(A[5]!==B||A[6]!==k){let Q;A[8]!==B?(Q=(te,re)=>{const{position:ne}=re;return Math.max(te,ne.y+B/2+10)},A[8]=B,A[9]=Q):Q=A[9],Y=k.reduce(Q,Number.NEGATIVE_INFINITY),A[5]=B,A[6]=k,A[7]=Y}else Y=A[7];const G=Y;let W,J,V;return A[10]!==X?(W=[Number.NEGATIVE_INFINITY,X],A[10]=X,A[11]=W):W=A[11],A[12]!==G?(J=[Number.POSITIVE_INFINITY,G],A[12]=G,A[13]=J):J=A[13],A[14]!==W||A[15]!==J?(V=[W,J],A[14]=W,A[15]=J,A[16]=V):V=A[16],U=V,U}(f,v);let I;e[19]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{x(void 0),b(void 0)},e[19]=I):I=e[19];const O=I;let L;e[20]!==d||e[21]!==p||e[22]!==g||e[23]!==o?(L=()=>p?u.jsx(Jl,{selection:{type:"edge",source:p.source,target:p.target},onClearSelection:O,variables:o,edges:d}):g?u.jsx(Jl,{selection:{type:"node",id:g},variables:o,edges:d,onClearSelection:O}):null,e[20]=d,e[21]=p,e[22]=g,e[23]=o,e[24]=L):L=e[24];const D=L;let R,P,z,_;return e[25]!==h?(R=(k,B)=>{const A=B.id;x(A),b(void 0),h([])},e[25]=h,e[26]=R):R=e[26],e[27]===Symbol.for("react.memo_cache_sentinel")?(P=(k,B)=>{b(B)},e[27]=P):P=e[27],e[28]!==D?(z=D(),e[28]=D,e[29]=z):z=e[29],e[30]!==s||e[31]!==d||e[32]!==f||e[33]!==R||e[34]!==z||e[35]!==T?(_=u.jsxs(pf,{nodes:f,edges:d,nodeTypes:ww,translateExtent:T,onNodeClick:R,onNodeDoubleClick:s7,onEdgeClick:P,snapToGrid:!0,fitView:!0,elementsSelectable:!0,minZoom:1,maxZoom:1,draggable:!1,panOnScrollMode:Bo.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:[z,s]}),e[30]=s,e[31]=d,e[32]=f,e[33]=R,e[34]=z,e[35]=T,e[36]=_):_=e[36],_};function r7(t){const{height:e}=t;return e}function s7(t,e){HC(e.id,"focus")}var yf,Sw,Nw,Ew,_w,Iw,vf,Aw,wf,Tw,kf,Mw,Cf,Ow,jf,Dw,Sf,Rw,Nf,Pw,Ef,Lw,_f,Fw,If,zw,Af,Bw,Tf,Uw,Mf,$w,Of,Vw,Hw,Ww,qw,Gw,Yw,Kw,Df,Xw,Rf,Jw,Pf,Zw,Lf,Qw,Ff,ek,zf,tk,Bf,nk,Uf,ok,$f,rk,Vf,sk,Hf,ik,Wf,ak,qf,lk,Gf,ck,dk,uk,hk,fk,mk,pk,Yf,gk,Kf,xk,bk,yk,Xf,vk,Jf,wk,Zf,kk,Qf,Ck,em,jk,Sk,Nk,Ek,_k;function tm(){if(Sw)return yf;Sw=1;var t="\0";function e(s,i){s[i]?s[i]++:s[i]=1}function n(s,i){--s[i]||delete s[i]}function o(s,i,a,l){var c=""+i,d=""+a;if(!s&&c>d){var h=c;c=d,d=h}return c+""+d+""+(l===void 0?"\0":l)}function r(s,i){return o(s,i.v,i.w,i.name)}return yf=class{constructor(s){Z(this,"_isDirected",!0);Z(this,"_isMultigraph",!1);Z(this,"_isCompound",!1);Z(this,"_label");Z(this,"_defaultNodeLabelFn",()=>{});Z(this,"_defaultEdgeLabelFn",()=>{});Z(this,"_nodes",{});Z(this,"_in",{});Z(this,"_preds",{});Z(this,"_out",{});Z(this,"_sucs",{});Z(this,"_edgeObjs",{});Z(this,"_edgeLabels",{});Z(this,"_nodeCount",0);Z(this,"_edgeCount",0);Z(this,"_parent");Z(this,"_children");s&&(this._isDirected=!Object.hasOwn(s,"directed")||s.directed,this._isMultigraph=!!Object.hasOwn(s,"multigraph")&&s.multigraph,this._isCompound=!!Object.hasOwn(s,"compound")&&s.compound),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(s){return this._label=s,this}graph(){return this._label}setDefaultNodeLabel(s){return this._defaultNodeLabelFn=s,typeof s!="function"&&(this._defaultNodeLabelFn=()=>s),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var s=this;return this.nodes().filter(i=>Object.keys(s._in[i]).length===0)}sinks(){var s=this;return this.nodes().filter(i=>Object.keys(s._out[i]).length===0)}setNodes(s,i){var a=arguments,l=this;return s.forEach(function(c){a.length>1?l.setNode(c,i):l.setNode(c)}),this}setNode(s,i){return Object.hasOwn(this._nodes,s)?(arguments.length>1&&(this._nodes[s]=i),this):(this._nodes[s]=arguments.length>1?i:this._defaultNodeLabelFn(s),this._isCompound&&(this._parent[s]=t,this._children[s]={},this._children[t][s]=!0),this._in[s]={},this._preds[s]={},this._out[s]={},this._sucs[s]={},++this._nodeCount,this)}node(s){return this._nodes[s]}hasNode(s){return Object.hasOwn(this._nodes,s)}removeNode(s){var i=this;if(Object.hasOwn(this._nodes,s)){var a=l=>i.removeEdge(i._edgeObjs[l]);delete this._nodes[s],this._isCompound&&(this._removeFromParentsChildList(s),delete this._parent[s],this.children(s).forEach(function(l){i.setParent(l)}),delete this._children[s]),Object.keys(this._in[s]).forEach(a),delete this._in[s],delete this._preds[s],Object.keys(this._out[s]).forEach(a),delete this._out[s],delete this._sucs[s],--this._nodeCount}return this}setParent(s,i){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(i===void 0)i=t;else{for(var a=i+="";a!==void 0;a=this.parent(a))if(a===s)throw new Error("Setting "+i+" as parent of "+s+" would create a cycle");this.setNode(i)}return this.setNode(s),this._removeFromParentsChildList(s),this._parent[s]=i,this._children[i][s]=!0,this}_removeFromParentsChildList(s){delete this._children[this._parent[s]][s]}parent(s){if(this._isCompound){var i=this._parent[s];if(i!==t)return i}}children(s=t){if(this._isCompound){var i=this._children[s];if(i)return Object.keys(i)}else{if(s===t)return this.nodes();if(this.hasNode(s))return[]}}predecessors(s){var i=this._preds[s];if(i)return Object.keys(i)}successors(s){var i=this._sucs[s];if(i)return Object.keys(i)}neighbors(s){var i=this.predecessors(s);if(i){const l=new Set(i);for(var a of this.successors(s))l.add(a);return Array.from(l.values())}}isLeaf(s){return(this.isDirected()?this.successors(s):this.neighbors(s)).length===0}filterNodes(s){var i=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});i.setGraph(this.graph());var a=this;Object.entries(this._nodes).forEach(function([d,h]){s(d)&&i.setNode(d,h)}),Object.values(this._edgeObjs).forEach(function(d){i.hasNode(d.v)&&i.hasNode(d.w)&&i.setEdge(d,a.edge(d))});var l={};function c(d){var h=a.parent(d);return h===void 0||i.hasNode(h)?(l[d]=h,h):h in l?l[h]:c(h)}return this._isCompound&&i.nodes().forEach(d=>i.setParent(d,c(d))),i}setDefaultEdgeLabel(s){return this._defaultEdgeLabelFn=s,typeof s!="function"&&(this._defaultEdgeLabelFn=()=>s),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(s,i){var a=this,l=arguments;return s.reduce(function(c,d){return l.length>1?a.setEdge(c,d,i):a.setEdge(c,d),d}),this}setEdge(){var s,i,a,l,c=!1,d=arguments[0];typeof d=="object"&&d!==null&&"v"in d?(s=d.v,i=d.w,a=d.name,arguments.length===2&&(l=arguments[1],c=!0)):(s=d,i=arguments[1],a=arguments[3],arguments.length>2&&(l=arguments[2],c=!0)),s=""+s,i=""+i,a!==void 0&&(a=""+a);var h=o(this._isDirected,s,i,a);if(Object.hasOwn(this._edgeLabels,h))return c&&(this._edgeLabels[h]=l),this;if(a!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(s),this.setNode(i),this._edgeLabels[h]=c?l:this._defaultEdgeLabelFn(s,i,a);var f=function(m,g,x,p){var b=""+g,y=""+x;if(!m&&b>y){var v=b;b=y,y=v}var w={v:b,w:y};return p&&(w.name=p),w}(this._isDirected,s,i,a);return s=f.v,i=f.w,Object.freeze(f),this._edgeObjs[h]=f,e(this._preds[i],s),e(this._sucs[s],i),this._in[i][h]=f,this._out[s][h]=f,this._edgeCount++,this}edge(s,i,a){var l=arguments.length===1?r(this._isDirected,arguments[0]):o(this._isDirected,s,i,a);return this._edgeLabels[l]}edgeAsObj(){const s=this.edge(...arguments);return typeof s!="object"?{label:s}:s}hasEdge(s,i,a){var l=arguments.length===1?r(this._isDirected,arguments[0]):o(this._isDirected,s,i,a);return Object.hasOwn(this._edgeLabels,l)}removeEdge(s,i,a){var l=arguments.length===1?r(this._isDirected,arguments[0]):o(this._isDirected,s,i,a),c=this._edgeObjs[l];return c&&(s=c.v,i=c.w,delete this._edgeLabels[l],delete this._edgeObjs[l],n(this._preds[i],s),n(this._sucs[s],i),delete this._in[i][l],delete this._out[s][l],this._edgeCount--),this}inEdges(s,i){var a=this._in[s];if(a){var l=Object.values(a);return i?l.filter(c=>c.v===i):l}}outEdges(s,i){var a=this._out[s];if(a){var l=Object.values(a);return i?l.filter(c=>c.w===i):l}}nodeEdges(s,i){var a=this.inEdges(s,i);if(a)return a.concat(this.outEdges(s,i))}},yf}function i7(){return Iw?_w:(Iw=1,_w={Graph:tm(),version:Ew?Nw:(Ew=1,Nw="2.2.4")})}function a7(){if(Aw)return vf;Aw=1;var t=tm();function e(o){return o.nodes().map(function(r){var s=o.node(r),i=o.parent(r),a={v:r};return s!==void 0&&(a.value=s),i!==void 0&&(a.parent=i),a})}function n(o){return o.edges().map(function(r){var s=o.edge(r),i={v:r.v,w:r.w};return r.name!==void 0&&(i.name=r.name),s!==void 0&&(i.value=s),i})}return vf={write:function(o){var r={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:e(o),edges:n(o)};return o.graph()!==void 0&&(r.value=structuredClone(o.graph())),r},read:function(o){var r=new t(o.options).setGraph(o.value);return o.nodes.forEach(function(s){r.setNode(s.v,s.value),s.parent&&r.setParent(s.v,s.parent)}),o.edges.forEach(function(s){r.setEdge({v:s.v,w:s.w,name:s.name},s.value)}),r}},vf}function l7(){return Tw||(Tw=1,wf=function(t){var e,n={},o=[];function r(s){Object.hasOwn(n,s)||(n[s]=!0,e.push(s),t.successors(s).forEach(r),t.predecessors(s).forEach(r))}return t.nodes().forEach(function(s){e=[],r(s),e.length&&o.push(e)}),o}),wf}function Ik(){return Mw?kf:(Mw=1,kf=class{constructor(){Z(this,"_arr",[]);Z(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(t){return t.key})}has(t){return Object.hasOwn(this._keyIndices,t)}priority(t){var e=this._keyIndices[t];if(e!==void 0)return this._arr[e].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(t,e){var n=this._keyIndices;if(t=String(t),!Object.hasOwn(n,t)){var o=this._arr,r=o.length;return n[t]=r,o.push({key:t,priority:e}),this._decrease(r),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key}decrease(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)}_heapify(t){var e=this._arr,n=2*t,o=n+1,r=t;n<e.length&&(r=e[n].priority<e[r].priority?n:r,o<e.length&&(r=e[o].priority<e[r].priority?o:r),r!==t&&(this._swap(t,r),this._heapify(r)))}_decrease(t){for(var e,n=this._arr,o=n[t].priority;t!==0&&!(n[e=t>>1].priority<o);)this._swap(t,e),t=e}_swap(t,e){var n=this._arr,o=this._keyIndices,r=n[t],s=n[e];n[t]=s,n[e]=r,o[s.key]=t,o[r.key]=e}},kf)}function Ak(){if(Ow)return Cf;Ow=1;var t=Ik();Cf=function(n,o,r,s){return function(i,a,l,c){var d,h,f={},m=new t,g=function(x){var p=x.v!==d?x.v:x.w,b=f[p],y=l(x),v=h.distance+y;if(y<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+x+" Weight: "+y);v<b.distance&&(b.distance=v,b.predecessor=d,m.decrease(p,v))};for(i.nodes().forEach(function(x){var p=x===a?0:Number.POSITIVE_INFINITY;f[x]={distance:p},m.add(x,p)});m.size()>0&&(d=m.removeMin(),(h=f[d]).distance!==Number.POSITIVE_INFINITY);)c(d).forEach(g);return f}(n,String(o),r||e,s||function(i){return n.outEdges(i)})};var e=()=>1;return Cf}function c7(){if(Dw)return jf;Dw=1;var t=Ak();return jf=function(e,n,o){return e.nodes().reduce(function(r,s){return r[s]=t(e,s,n,o),r},{})},jf}function Tk(){return Rw||(Rw=1,Sf=function(t){var e=0,n=[],o={},r=[];function s(i){var a=o[i]={onStack:!0,lowlink:e,index:e++};if(n.push(i),t.successors(i).forEach(function(d){Object.hasOwn(o,d)?o[d].onStack&&(a.lowlink=Math.min(a.lowlink,o[d].index)):(s(d),a.lowlink=Math.min(a.lowlink,o[d].lowlink))}),a.lowlink===a.index){var l,c=[];do l=n.pop(),o[l].onStack=!1,c.push(l);while(i!==l);r.push(c)}}return t.nodes().forEach(function(i){Object.hasOwn(o,i)||s(i)}),r}),Sf}function d7(){if(Pw)return Nf;Pw=1;var t=Tk();return Nf=function(e){return t(e).filter(function(n){return n.length>1||n.length===1&&e.hasEdge(n[0],n[0])})},Nf}function u7(){if(Lw)return Ef;Lw=1,Ef=function(e,n,o){return function(r,s,i){var a={},l=r.nodes();return l.forEach(function(c){a[c]={},a[c][c]={distance:0},l.forEach(function(d){c!==d&&(a[c][d]={distance:Number.POSITIVE_INFINITY})}),i(c).forEach(function(d){var h=d.v===c?d.w:d.v,f=s(d);a[c][h]={distance:f,predecessor:c}})}),l.forEach(function(c){var d=a[c];l.forEach(function(h){var f=a[h];l.forEach(function(m){var g=f[c],x=d[m],p=f[m],b=g.distance+x.distance;b<p.distance&&(p.distance=b,p.predecessor=x.predecessor)})})}),a}(e,n||t,o||function(r){return e.outEdges(r)})};var t=()=>1;return Ef}function Mk(){if(Fw)return _f;function t(n){var o={},r={},s=[];if(n.sinks().forEach(function i(a){if(Object.hasOwn(r,a))throw new e;Object.hasOwn(o,a)||(r[a]=!0,o[a]=!0,n.predecessors(a).forEach(i),delete r[a],s.push(a))}),Object.keys(o).length!==n.nodeCount())throw new e;return s}Fw=1;class e extends Error{constructor(){super(...arguments)}}return _f=t,t.CycleException=e,_f}function h7(){if(zw)return If;zw=1;var t=Mk();return If=function(e){try{t(e)}catch(n){if(n instanceof t.CycleException)return!1;throw n}return!0},If}function Ok(){if(Bw)return Af;function t(o,r,s,i){for(var a=[[o,!1]];a.length>0;){var l=a.pop();l[1]?i.push(l[0]):Object.hasOwn(s,l[0])||(s[l[0]]=!0,a.push([l[0],!0]),n(r(l[0]),c=>a.push([c,!1])))}}function e(o,r,s,i){for(var a=[o];a.length>0;){var l=a.pop();Object.hasOwn(s,l)||(s[l]=!0,i.push(l),n(r(l),c=>a.push(c)))}}function n(o,r){for(var s=o.length;s--;)r(o[s],s,o);return o}return Bw=1,Af=function(o,r,s){Array.isArray(r)||(r=[r]);var i=o.isDirected()?d=>o.successors(d):d=>o.neighbors(d),a=s==="post"?t:e,l=[],c={};return r.forEach(d=>{if(!o.hasNode(d))throw new Error("Graph does not have node: "+d);a(d,i,c,l)}),l},Af}function f7(){if(Uw)return Tf;Uw=1;var t=Ok();return Tf=function(e,n){return t(e,n,"post")},Tf}function m7(){if($w)return Mf;$w=1;var t=Ok();return Mf=function(e,n){return t(e,n,"pre")},Mf}function p7(){if(Vw)return Of;Vw=1;var t=tm(),e=Ik();return Of=function(n,o){var r,s=new t,i={},a=new e;function l(d){var h=d.v===r?d.w:d.v,f=a.priority(h);if(f!==void 0){var m=o(d);m<f&&(i[h]=r,a.decrease(h,m))}}if(n.nodeCount()===0)return s;n.nodes().forEach(function(d){a.add(d,Number.POSITIVE_INFINITY),s.setNode(d)}),a.decrease(n.nodes()[0],0);for(var c=!1;a.size()>0;){if(r=a.removeMin(),Object.hasOwn(i,r))s.setEdge(r,i[r]);else{if(c)throw new Error("Input graph is not connected: "+n);c=!0}n.nodeEdges(r).forEach(l)}return s},Of}function Pn(){if(Gw)return qw;Gw=1;var t=i7();return qw={Graph:t.Graph,json:a7(),alg:Ww?Hw:(Ww=1,Hw={components:l7(),dijkstra:Ak(),dijkstraAll:c7(),findCycles:d7(),floydWarshall:u7(),isAcyclic:h7(),postorder:f7(),preorder:m7(),prim:p7(),tarjan:Tk(),topsort:Mk()}),version:t.version}}function g7(){if(Xw)return Df;Xw=1;let t=Pn().Graph,e=function(){if(Kw)return Yw;function s(a){a._prev._next=a._next,a._next._prev=a._prev,delete a._next,delete a._prev}function i(a,l){if(a!=="_next"&&a!=="_prev")return l}return Kw=1,Yw=class{constructor(){let a={};a._next=a._prev=a,this._sentinel=a}dequeue(){let a=this._sentinel,l=a._prev;if(l!==a)return s(l),l}enqueue(a){let l=this._sentinel;a._prev&&a._next&&s(a),a._next=l._next,l._next._prev=a,l._next=a,a._prev=l}toString(){let a=[],l=this._sentinel,c=l._prev;for(;c!==l;)a.push(JSON.stringify(c,i)),c=c._prev;return"["+a.join(", ")+"]"}}}();Df=function(s,i){if(s.nodeCount()<=1)return[];let a=function(l,c){let d=new t,h=0,f=0;l.nodes().forEach(x=>{d.setNode(x,{v:x,in:0,out:0})}),l.edges().forEach(x=>{let p=d.edge(x.v,x.w)||0,b=c(x),y=p+b;d.setEdge(x.v,x.w,y),f=Math.max(f,d.node(x.v).out+=b),h=Math.max(h,d.node(x.w).in+=b)});let m=function(x){const p=[];for(let b=0;b<x;b++)p.push(b);return p}(f+h+3).map(()=>new e),g=h+1;return d.nodes().forEach(x=>{r(m,g,d.node(x))}),{graph:d,buckets:m,zeroIdx:g}}(s,i||n);return function(l,c,d){let h,f=[],m=c[c.length-1],g=c[0];for(;l.nodeCount();){for(;h=g.dequeue();)o(l,c,d,h);for(;h=m.dequeue();)o(l,c,d,h);if(l.nodeCount()){for(let x=c.length-2;x>0;--x)if(h=c[x].dequeue(),h){f=f.concat(o(l,c,d,h,!0));break}}}return f}(a.graph,a.buckets,a.zeroIdx).flatMap(l=>s.outEdges(l.v,l.w))};let n=()=>1;function o(s,i,a,l,c){let d=c?[]:void 0;return s.inEdges(l.v).forEach(h=>{let f=s.edge(h),m=s.node(h.v);c&&d.push({v:h.v,w:h.w}),m.out-=f,r(i,a,m)}),s.outEdges(l.v).forEach(h=>{let f=s.edge(h),m=h.w,g=s.node(m);g.in-=f,r(i,a,g)}),s.removeNode(l.v),d}function r(s,i,a){a.out?a.in?s[a.out-a.in+i].enqueue(a):s[s.length-1].enqueue(a):s[0].enqueue(a)}return Df}function It(){if(Jw)return Rf;Jw=1;let t=Pn().Graph;function e(c,d,h,f){for(var m=f;c.hasNode(m);)m=i(f);return h.dummy=d,c.setNode(m,h),m}Rf={addBorderNode:function(c,d,h,f){let m={width:0,height:0};return arguments.length>=4&&(m.rank=h,m.order=f),e(c,"border",m,d)},addDummyNode:e,applyWithChunking:o,asNonCompoundGraph:function(c){let d=new t({multigraph:c.isMultigraph()}).setGraph(c.graph());return c.nodes().forEach(h=>{c.children(h).length||d.setNode(h,c.node(h))}),c.edges().forEach(h=>{d.setEdge(h,c.edge(h))}),d},buildLayerMatrix:function(c){let d=a(r(c)+1).map(()=>[]);return c.nodes().forEach(h=>{let f=c.node(h),m=f.rank;m!==void 0&&(d[m][f.order]=h)}),d},intersectRect:function(c,d){let h,f,m=c.x,g=c.y,x=d.x-m,p=d.y-g,b=c.width/2,y=c.height/2;if(!x&&!p)throw new Error("Not possible to find intersection inside of the rectangle");return Math.abs(p)*b>Math.abs(x)*y?(p<0&&(y=-y),h=y*x/p,f=y):(x<0&&(b=-b),h=b,f=b*p/x),{x:m+h,y:g+f}},mapValues:function(c,d){let h=d;return typeof d=="string"&&(h=f=>f[d]),Object.entries(c).reduce((f,[m,g])=>(f[m]=h(g,m),f),{})},maxRank:r,normalizeRanks:function(c){let d=c.nodes().map(f=>{let m=c.node(f).rank;return m===void 0?Number.MAX_VALUE:m}),h=o(Math.min,d);c.nodes().forEach(f=>{let m=c.node(f);Object.hasOwn(m,"rank")&&(m.rank-=h)})},notime:function(c,d){return d()},partition:function(c,d){let h={lhs:[],rhs:[]};return c.forEach(f=>{d(f)?h.lhs.push(f):h.rhs.push(f)}),h},pick:function(c,d){const h={};for(const f of d)c[f]!==void 0&&(h[f]=c[f]);return h},predecessorWeights:function(c){let d=c.nodes().map(h=>{let f={};return c.inEdges(h).forEach(m=>{f[m.v]=(f[m.v]||0)+c.edge(m).weight}),f});return l(c.nodes(),d)},range:a,removeEmptyRanks:function(c){let d=c.nodes().map(x=>c.node(x).rank),h=o(Math.min,d),f=[];c.nodes().forEach(x=>{let p=c.node(x).rank-h;f[p]||(f[p]=[]),f[p].push(x)});let m=0,g=c.graph().nodeRankFactor;Array.from(f).forEach((x,p)=>{x===void 0&&p%g!==0?--m:x!==void 0&&m&&x.forEach(b=>c.node(b).rank+=m)})},simplify:function(c){let d=new t().setGraph(c.graph());return c.nodes().forEach(h=>d.setNode(h,c.node(h))),c.edges().forEach(h=>{let f=d.edge(h.v,h.w)||{weight:0,minlen:1},m=c.edge(h);d.setEdge(h.v,h.w,{weight:f.weight+m.weight,minlen:Math.max(f.minlen,m.minlen)})}),d},successorWeights:function(c){let d=c.nodes().map(h=>{let f={};return c.outEdges(h).forEach(m=>{f[m.w]=(f[m.w]||0)+c.edge(m).weight}),f});return l(c.nodes(),d)},time:function(c,d){let h=Date.now();try{return d()}finally{console.log(c+" time: "+(Date.now()-h)+"ms")}},uniqueId:i,zipObject:l};const n=65535;function o(c,d){if(d.length>n){const h=function(f,m=n){const g=[];for(let x=0;x<f.length;x+=m){const p=f.slice(x,x+m);g.push(p)}return g}(d);return c.apply(null,h.map(f=>c.apply(null,f)))}return c.apply(null,d)}function r(c){const d=c.nodes().map(h=>{let f=c.node(h).rank;return f===void 0?Number.MIN_VALUE:f});return o(Math.max,d)}let s=0;function i(c){return c+""+ ++s}function a(c,d,h=1){d==null&&(d=c,c=0);let f=g=>g<d;h<0&&(f=g=>d<g);const m=[];for(let g=c;f(g);g+=h)m.push(g);return m}function l(c,d){return c.reduce((h,f,m)=>(h[f]=d[m],h),{})}return Rf}function x7(){if(Zw)return Pf;Zw=1;let t=g7(),e=It().uniqueId;return Pf={run:function(n){(n.graph().acyclicer==="greedy"?t(n,function(r){return s=>r.edge(s).weight}(n)):function(r){let s=[],i={},a={};function l(c){Object.hasOwn(a,c)||(a[c]=!0,i[c]=!0,r.outEdges(c).forEach(d=>{Object.hasOwn(i,d.w)?s.push(d):l(d.w)}),delete i[c])}return r.nodes().forEach(l),s}(n)).forEach(r=>{let s=n.edge(r);n.removeEdge(r),s.forwardName=r.name,s.reversed=!0,n.setEdge(r.w,r.v,s,e("rev"))})},undo:function(n){n.edges().forEach(o=>{let r=n.edge(o);if(r.reversed){n.removeEdge(o);let s=r.forwardName;delete r.reversed,delete r.forwardName,n.setEdge(o.w,o.v,r,s)}})}},Pf}function b7(){if(Qw)return Lf;Qw=1;let t=It();return Lf={run:function(e){e.graph().dummyChains=[],e.edges().forEach(n=>function(o,r){let s,i,a,l=r.v,c=o.node(l).rank,d=r.w,h=o.node(d).rank,f=r.name,m=o.edge(r),g=m.labelRank;if(h!==c+1){for(o.removeEdge(r),a=0,++c;c<h;++a,++c)m.points=[],i={width:0,height:0,edgeLabel:m,edgeObj:r,rank:c},s=t.addDummyNode(o,"edge",i,"_d"),c===g&&(i.width=m.width,i.height=m.height,i.dummy="edge-label",i.labelpos=m.labelpos),o.setEdge(l,s,{weight:m.weight},f),a===0&&o.graph().dummyChains.push(s),l=s;o.setEdge(l,d,{weight:m.weight},f)}}(e,n))},undo:function(e){e.graph().dummyChains.forEach(n=>{let o,r=e.node(n),s=r.edgeLabel;for(e.setEdge(r.edgeObj,s);r.dummy;)o=e.successors(n)[0],e.removeNode(n),s.points.push({x:r.x,y:r.y}),r.dummy==="edge-label"&&(s.x=r.x,s.y=r.y,s.width=r.width,s.height=r.height),n=o,r=e.node(n)})}},Lf}function Zl(){if(ek)return Ff;ek=1;const{applyWithChunking:t}=It();return Ff={longestPath:function(e){var n={};e.sources().forEach(function o(r){var s=e.node(r);if(Object.hasOwn(n,r))return s.rank;n[r]=!0;let i=e.outEdges(r).map(l=>l==null?Number.POSITIVE_INFINITY:o(l.w)-e.edge(l).minlen);var a=t(Math.min,i);return a===Number.POSITIVE_INFINITY&&(a=0),s.rank=a})},slack:function(e,n){return e.node(n.w).rank-e.node(n.v).rank-e.edge(n).minlen}},Ff}function Dk(){if(tk)return zf;tk=1;var t=Pn().Graph,e=Zl().slack;function n(s,i){return s.nodes().forEach(function a(l){i.nodeEdges(l).forEach(c=>{var d=c.v,h=l===d?c.w:d;s.hasNode(h)||e(i,c)||(s.setNode(h,{}),s.setEdge(l,h,{}),a(h))})}),s.nodeCount()}function o(s,i){return i.edges().reduce((a,l)=>{let c=Number.POSITIVE_INFINITY;return s.hasNode(l.v)!==s.hasNode(l.w)&&(c=e(i,l)),c<a[0]?[c,l]:a},[Number.POSITIVE_INFINITY,null])[1]}function r(s,i,a){s.nodes().forEach(l=>i.node(l).rank+=a)}return zf=function(s){var i,a,l=new t({directed:!1}),c=s.nodes()[0],d=s.nodeCount();for(l.setNode(c,{});n(l,s)<d;)i=o(l,s),a=l.hasNode(i.v)?e(s,i):-e(s,i),r(l,s,a);return l},zf}function y7(){if(nk)return Bf;nk=1;var t=Dk(),e=Zl().slack,n=Zl().longestPath,o=Pn().alg.preorder,r=Pn().alg.postorder,s=It().simplify;function i(x){x=s(x),n(x);var p,b=t(x);for(c(b),a(b,x);p=h(b);)m(b,x,p,f(b,x,p))}function a(x,p){var b=r(x,x.nodes());(b=b.slice(0,b.length-1)).forEach(y=>function(v,w,S){var C=v.node(S),N=C.parent;v.edge(S,N).cutvalue=l(v,w,S)}(x,p,y))}function l(x,p,b){var y=x.node(b).parent,v=!0,w=p.edge(b,y),S=0;return w||(v=!1,w=p.edge(y,b)),S=w.weight,p.nodeEdges(b).forEach(C=>{var N,j,E=C.v===b,T=E?C.w:C.v;if(T!==y){var I=E===v,O=p.edge(C).weight;if(S+=I?O:-O,N=b,j=T,x.hasEdge(N,j)){var L=x.edge(b,T).cutvalue;S+=I?-L:L}}}),S}function c(x,p){arguments.length<2&&(p=x.nodes()[0]),d(x,{},1,p)}function d(x,p,b,y,v){var w=b,S=x.node(y);return p[y]=!0,x.neighbors(y).forEach(C=>{Object.hasOwn(p,C)||(b=d(x,p,b,C,y))}),S.low=w,S.lim=b++,v?S.parent=v:delete S.parent,b}function h(x){return x.edges().find(p=>x.edge(p).cutvalue<0)}function f(x,p,b){var y=b.v,v=b.w;p.hasEdge(y,v)||(y=b.w,v=b.v);var w=x.node(y),S=x.node(v),C=w,N=!1;w.lim>S.lim&&(C=S,N=!0);var j=p.edges().filter(E=>N===g(x,x.node(E.v),C)&&N!==g(x,x.node(E.w),C));return j.reduce((E,T)=>e(p,T)<e(p,E)?T:E)}function m(x,p,b,y){var v=b.v,w=b.w;x.removeEdge(v,w),x.setEdge(y.v,y.w,{}),c(x),a(x,p),function(S,C){var N=S.nodes().find(E=>!C.node(E).parent),j=o(S,N);(j=j.slice(1)).forEach(E=>{var T=S.node(E).parent,I=C.edge(E,T),O=!1;I||(I=C.edge(T,E),O=!0),C.node(E).rank=C.node(T).rank+(O?I.minlen:-I.minlen)})}(x,p)}function g(x,p,b){return b.low<=p.lim&&p.lim<=b.lim}return Bf=i,i.initLowLimValues=c,i.initCutValues=a,i.calcCutValue=l,i.leaveEdge=h,i.enterEdge=f,i.exchangeEdges=m,Bf}function v7(){if(ok)return Uf;ok=1;var t=Zl().longestPath,e=Dk(),n=y7();Uf=function(s){var i=s.graph().ranker;if(i instanceof Function)return i(s);switch(s.graph().ranker){case"network-simplex":default:r(s);break;case"tight-tree":(function(a){t(a),e(a)})(s);break;case"longest-path":o(s);case"none":}};var o=t;function r(s){n(s)}return Uf}function w7(){return rk||(rk=1,$f=function(t){let e=function(n){let o={},r=0;function s(i){let a=r;n.children(i).forEach(s),o[i]={low:a,lim:r++}}return n.children().forEach(s),o}(t);t.graph().dummyChains.forEach(n=>{let o=t.node(n),r=o.edgeObj,s=function(h,f,m,g){let x,p,b=[],y=[],v=Math.min(f[m].low,f[g].low),w=Math.max(f[m].lim,f[g].lim);x=m;do x=h.parent(x),b.push(x);while(x&&(f[x].low>v||w>f[x].lim));for(p=x,x=g;(x=h.parent(x))!==p;)y.push(x);return{path:b.concat(y.reverse()),lca:p}}(t,e,r.v,r.w),i=s.path,a=s.lca,l=0,c=i[l],d=!0;for(;n!==r.w;){if(o=t.node(n),d){for(;(c=i[l])!==a&&t.node(c).maxRank<o.rank;)l++;c===a&&(d=!1)}if(!d){for(;l<i.length-1&&t.node(c=i[l+1]).minRank<=o.rank;)l++;c=i[l]}t.setParent(n,c),n=t.successors(n)[0]}})}),$f}function k7(){if(sk)return Vf;sk=1;let t=It();function e(n,o,r,s,i,a,l){let c=n.children(l);if(!c.length)return void(l!==o&&n.setEdge(o,l,{weight:0,minlen:r}));let d=t.addBorderNode(n,"_bt"),h=t.addBorderNode(n,"_bb"),f=n.node(l);n.setParent(d,l),f.borderTop=d,n.setParent(h,l),f.borderBottom=h,c.forEach(m=>{e(n,o,r,s,i,a,m);let g=n.node(m),x=g.borderTop?g.borderTop:m,p=g.borderBottom?g.borderBottom:m,b=g.borderTop?s:2*s,y=x!==p?1:i-a[l]+1;n.setEdge(d,x,{weight:b,minlen:y,nestingEdge:!0}),n.setEdge(p,h,{weight:b,minlen:y,nestingEdge:!0})}),n.parent(l)||n.setEdge(o,d,{weight:0,minlen:i+a[l]})}return Vf={run:function(n){let o=t.addDummyNode(n,"root",{},"_root"),r=function(c){var d={};function h(f,m){var g=c.children(f);g&&g.length&&g.forEach(x=>h(x,m+1)),d[f]=m}return c.children().forEach(f=>h(f,1)),d}(n),s=Object.values(r),i=t.applyWithChunking(Math.max,s)-1,a=2*i+1;n.graph().nestingRoot=o,n.edges().forEach(c=>n.edge(c).minlen*=a);let l=function(c){return c.edges().reduce((d,h)=>d+c.edge(h).weight,0)}(n)+1;n.children().forEach(c=>e(n,o,a,l,i,r,c)),n.graph().nodeRankFactor=a},cleanup:function(n){var o=n.graph();n.removeNode(o.nestingRoot),delete o.nestingRoot,n.edges().forEach(r=>{n.edge(r).nestingEdge&&n.removeEdge(r)})}},Vf}function C7(){if(ak)return Wf;function t(r){r.nodes().forEach(s=>e(r.node(s))),r.edges().forEach(s=>e(r.edge(s)))}function e(r){let s=r.width;r.width=r.height,r.height=s}function n(r){r.y=-r.y}function o(r){let s=r.x;r.x=r.y,r.y=s}return ak=1,Wf={adjust:function(r){let s=r.graph().rankdir.toLowerCase();s!=="lr"&&s!=="rl"||t(r)},undo:function(r){let s=r.graph().rankdir.toLowerCase();s!=="bt"&&s!=="rl"||function(i){i.nodes().forEach(a=>n(i.node(a))),i.edges().forEach(a=>{let l=i.edge(a);l.points.forEach(n),Object.hasOwn(l,"y")&&n(l)})}(r),s!=="lr"&&s!=="rl"||(function(i){i.nodes().forEach(a=>o(i.node(a))),i.edges().forEach(a=>{let l=i.edge(a);l.points.forEach(o),Object.hasOwn(l,"x")&&o(l)})}(r),t(r))}},Wf}function j7(){if(fk)return hk;fk=1;let t=It();return hk=function(e,n){let o={};return e.forEach((r,s)=>{let i=o[r.v]={indegree:0,in:[],out:[],vs:[r.v],i:s};r.barycenter!==void 0&&(i.barycenter=r.barycenter,i.weight=r.weight)}),n.edges().forEach(r=>{let s=o[r.v],i=o[r.w];s!==void 0&&i!==void 0&&(i.indegree++,s.out.push(o[r.w]))}),function(r){let s=[];function i(l){return c=>{c.merged||(c.barycenter===void 0||l.barycenter===void 0||c.barycenter>=l.barycenter)&&function(d,h){let f=0,m=0;d.weight&&(f+=d.barycenter*d.weight,m+=d.weight),h.weight&&(f+=h.barycenter*h.weight,m+=h.weight),d.vs=h.vs.concat(d.vs),d.barycenter=f/m,d.weight=m,d.i=Math.min(h.i,d.i),h.merged=!0}(l,c)}}function a(l){return c=>{c.in.push(l),--c.indegree===0&&r.push(c)}}for(;r.length;){let l=r.pop();s.push(l),l.in.reverse().forEach(i(l)),l.out.forEach(a(l))}return s.filter(l=>!l.merged).map(l=>t.pick(l,["vs","i","barycenter","weight"]))}(Object.values(o).filter(r=>!r.indegree))}}function S7(){if(gk)return Yf;gk=1;let t=(uk||(uk=1,dk=function(o,r=[]){return r.map(s=>{let i=o.inEdges(s);if(i.length){let a=i.reduce((l,c)=>{let d=o.edge(c),h=o.node(c.v);return{sum:l.sum+d.weight*h.order,weight:l.weight+d.weight}},{sum:0,weight:0});return{v:s,barycenter:a.sum/a.weight,weight:a.weight}}return{v:s}})}),dk),e=j7(),n=function(){if(pk)return mk;pk=1;let o=It();function r(s,i,a){let l;for(;i.length&&(l=i[i.length-1]).i<=a;)i.pop(),s.push(l.vs),a++;return a}return mk=function(s,i){let a=o.partition(s,p=>Object.hasOwn(p,"barycenter")),l=a.lhs,c=a.rhs.sort((p,b)=>b.i-p.i),d=[],h=0,f=0,m=0;var g;l.sort((g=!!i,(p,b)=>p.barycenter<b.barycenter?-1:p.barycenter>b.barycenter?1:g?b.i-p.i:p.i-b.i)),m=r(d,c,m),l.forEach(p=>{m+=p.vs.length,d.push(p.vs),h+=p.barycenter*p.weight,f+=p.weight,m=r(d,c,m)});let x={vs:d.flat(!0)};return f&&(x.barycenter=h/f,x.weight=f),x}}();return Yf=function o(r,s,i,a){let l=r.children(s),c=r.node(s),d=c?c.borderLeft:void 0,h=c?c.borderRight:void 0,f={};d&&(l=l.filter(p=>p!==d&&p!==h));let m=t(r,l);m.forEach(p=>{if(r.children(p.v).length){let v=o(r,p.v,i,a);f[p.v]=v,Object.hasOwn(v,"barycenter")&&(y=v,(b=p).barycenter!==void 0?(b.barycenter=(b.barycenter*b.weight+y.barycenter*y.weight)/(b.weight+y.weight),b.weight+=y.weight):(b.barycenter=y.barycenter,b.weight=y.weight))}var b,y});let g=e(m,i);(function(p,b){p.forEach(y=>{y.vs=y.vs.flatMap(v=>b[v]?b[v].vs:v)})})(g,f);let x=n(g,a);if(d&&(x.vs=[d,x.vs,h].flat(!0),r.predecessors(d).length)){let p=r.node(r.predecessors(d)[0]),b=r.node(r.predecessors(h)[0]);Object.hasOwn(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+p.order+b.order)/(x.weight+2),x.weight+=2}return x},Yf}function N7(){if(xk)return Kf;xk=1;let t=Pn().Graph,e=It();return Kf=function(n,o,r){let s=function(a){for(var l;a.hasNode(l=e.uniqueId("_root")););return l}(n),i=new t({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(a=>n.node(a));return n.nodes().forEach(a=>{let l=n.node(a),c=n.parent(a);(l.rank===o||l.minRank<=o&&o<=l.maxRank)&&(i.setNode(a),i.setParent(a,c||s),n[r](a).forEach(d=>{let h=d.v===a?d.w:d.v,f=i.edge(h,a),m=f!==void 0?f.weight:0;i.setEdge(h,a,{weight:n.edge(d).weight+m})}),Object.hasOwn(l,"minRank")&&i.setNode(a,{borderLeft:l.borderLeft[o],borderRight:l.borderRight[o]}))}),i},Kf}function E7(){if(vk)return Xf;vk=1;let t=function(){if(lk)return qf;lk=1;let d=It();return qf=function(h){let f={},m=h.nodes().filter(y=>!h.children(y).length),g=m.map(y=>h.node(y).rank),x=d.applyWithChunking(Math.max,g),p=d.range(x+1).map(()=>[]);function b(y){if(f[y])return;f[y]=!0;let v=h.node(y);p[v.rank].push(y),h.successors(y).forEach(b)}return m.sort((y,v)=>h.node(y).rank-h.node(v).rank).forEach(b),p},qf}(),e=function(){if(ck)return Gf;ck=1;let d=It().zipObject;function h(f,m,g){let x=d(g,g.map((S,C)=>C)),p=m.flatMap(S=>f.outEdges(S).map(C=>({pos:x[C.w],weight:f.edge(C).weight})).sort((C,N)=>C.pos-N.pos)),b=1;for(;b<g.length;)b<<=1;let y=2*b-1;b-=1;let v=new Array(y).fill(0),w=0;return p.forEach(S=>{let C=S.pos+b;v[C]+=S.weight;let N=0;for(;C>0;)C%2&&(N+=v[C+1]),C=C-1>>1,v[C]+=S.weight;w+=S.weight*N}),w}return Gf=function(f,m){let g=0;for(let x=1;x<m.length;++x)g+=h(f,m[x-1],m[x]);return g},Gf}(),n=S7(),o=N7(),r=(yk||(yk=1,bk=function(d,h,f){let m,g={};f.forEach(x=>{let p,b,y=d.parent(x);for(;y;){if(p=d.parent(y),p?(b=g[p],g[p]=y):(b=m,m=y),b&&b!==y)return void h.setEdge(b,y);y=p}})}),bk),s=Pn().Graph,i=It();function a(d,h,f){return h.map(function(m){return o(d,m,f)})}function l(d,h){let f=new s;d.forEach(function(m){let g=m.graph().root,x=n(m,g,f,h);x.vs.forEach((p,b)=>m.node(p).order=b),r(m,f,x.vs)})}function c(d,h){Object.values(h).forEach(f=>f.forEach((m,g)=>d.node(m).order=g))}return Xf=function d(h,f){if(f&&typeof f.customOrder=="function")return void f.customOrder(h,d);let m=i.maxRank(h),g=a(h,i.range(1,m+1),"inEdges"),x=a(h,i.range(m-1,-1,-1),"outEdges"),p=t(h);if(c(h,p),f&&f.disableOptimalOrderHeuristic)return;let b,y=Number.POSITIVE_INFINITY;for(let v=0,w=0;w<4;++v,++w){l(v%2?g:x,v%4>=2),p=i.buildLayerMatrix(h);let S=e(h,p);S<y&&(w=0,b=Object.assign({},p),y=S)}c(h,b)},Xf}function _7(){if(wk)return Jf;wk=1;let t=Pn().Graph,e=It();function n(h,f){let m={};return f.length&&f.reduce(function(g,x){let p=0,b=0,y=g.length,v=x[x.length-1];return x.forEach((w,S)=>{let C=function(j,E){if(j.node(E).dummy)return j.predecessors(E).find(T=>j.node(T).dummy)}(h,w),N=C?h.node(C).order:y;(C||w===v)&&(x.slice(b,S+1).forEach(j=>{h.predecessors(j).forEach(E=>{let T=h.node(E),I=T.order;!(I<p||N<I)||T.dummy&&h.node(j).dummy||r(m,E,j)})}),b=S+1,p=N)}),x}),m}function o(h,f){let m={};function g(x,p,b,y,v){let w;e.range(p,b).forEach(S=>{w=x[S],h.node(w).dummy&&h.predecessors(w).forEach(C=>{let N=h.node(C);N.dummy&&(N.order<y||N.order>v)&&r(m,C,w)})})}return f.length&&f.reduce(function(x,p){let b,y=-1,v=0;return p.forEach((w,S)=>{if(h.node(w).dummy==="border"){let C=h.predecessors(w);C.length&&(b=h.node(C[0]).order,g(p,v,S,y,b),v=S,y=b)}g(p,v,p.length,b,x.length)}),p}),m}function r(h,f,m){if(f>m){let x=f;f=m,m=x}let g=h[f];g||(h[f]=g={}),g[m]=!0}function s(h,f,m){if(f>m){let g=f;f=m,m=g}return!!h[f]&&Object.hasOwn(h[f],m)}function i(h,f,m,g){let x={},p={},b={};return f.forEach(y=>{y.forEach((v,w)=>{x[v]=v,p[v]=v,b[v]=w})}),f.forEach(y=>{let v=-1;y.forEach(w=>{let S=g(w);if(S.length){S=S.sort((N,j)=>b[N]-b[j]);let C=(S.length-1)/2;for(let N=Math.floor(C),j=Math.ceil(C);N<=j;++N){let E=S[N];p[w]===w&&v<b[E]&&!s(m,w,E)&&(p[E]=w,p[w]=x[w]=x[E],v=b[E])}}})}),{root:x,align:p}}function a(h,f,m,g,x){let p={},b=function(w,S,C,N){let j=new t,E=w.graph(),T=function(I,O,L){return(D,R,P)=>{let z,_=D.node(R),k=D.node(P),B=0;if(B+=_.width/2,Object.hasOwn(_,"labelpos"))switch(_.labelpos.toLowerCase()){case"l":z=-_.width/2;break;case"r":z=_.width/2}if(z&&(B+=L?z:-z),z=0,B+=(_.dummy?O:I)/2,B+=(k.dummy?O:I)/2,B+=k.width/2,Object.hasOwn(k,"labelpos"))switch(k.labelpos.toLowerCase()){case"l":z=k.width/2;break;case"r":z=-k.width/2}return z&&(B+=L?z:-z),z=0,B}}(E.nodesep,E.edgesep,N);return S.forEach(I=>{let O;I.forEach(L=>{let D=C[L];if(j.setNode(D),O){var R=C[O],P=j.edge(R,D);j.setEdge(R,D,Math.max(T(w,L,O),P||0))}O=L})}),j}(h,f,m,x),y=x?"borderLeft":"borderRight";function v(w,S){let C=b.nodes(),N=C.pop(),j={};for(;N;)j[N]?w(N):(j[N]=!0,C.push(N),C=C.concat(S(N))),N=C.pop()}return v(function(w){p[w]=b.inEdges(w).reduce((S,C)=>Math.max(S,p[C.v]+b.edge(C)),0)},b.predecessors.bind(b)),v(function(w){let S=b.outEdges(w).reduce((N,j)=>Math.min(N,p[j.w]-b.edge(j)),Number.POSITIVE_INFINITY),C=h.node(w);S!==Number.POSITIVE_INFINITY&&C.borderType!==y&&(p[w]=Math.max(p[w],S))},b.successors.bind(b)),Object.keys(g).forEach(w=>p[w]=p[m[w]]),p}function l(h,f){return Object.values(f).reduce((m,g)=>{let x=Number.NEGATIVE_INFINITY,p=Number.POSITIVE_INFINITY;Object.entries(g).forEach(([y,v])=>{let w=function(S,C){return S.node(C).width}(h,y)/2;x=Math.max(v+w,x),p=Math.min(v-w,p)});const b=x-p;return b<m[0]&&(m=[b,g]),m},[Number.POSITIVE_INFINITY,null])[1]}function c(h,f){let m=Object.values(f),g=e.applyWithChunking(Math.min,m),x=e.applyWithChunking(Math.max,m);["u","d"].forEach(p=>{["l","r"].forEach(b=>{let y=p+b,v=h[y];if(v===f)return;let w=Object.values(v),S=g-e.applyWithChunking(Math.min,w);b!=="l"&&(S=x-e.applyWithChunking(Math.max,w)),S&&(h[y]=e.mapValues(v,C=>C+S))})})}function d(h,f){return e.mapValues(h.ul,(m,g)=>{if(f)return h[f.toLowerCase()][g];{let x=Object.values(h).map(p=>p[g]).sort((p,b)=>p-b);return(x[1]+x[2])/2}})}return Jf={positionX:function(h){let f,m=e.buildLayerMatrix(h),g=Object.assign(n(h,m),o(h,m)),x={};["u","d"].forEach(b=>{f=b==="u"?m:Object.values(m).reverse(),["l","r"].forEach(y=>{y==="r"&&(f=f.map(C=>Object.values(C).reverse()));let v=(b==="u"?h.predecessors:h.successors).bind(h),w=i(h,f,g,v),S=a(h,f,w.root,w.align,y==="r");y==="r"&&(S=e.mapValues(S,C=>-C)),x[b+y]=S})});let p=l(h,x);return c(x,p),d(x,h.graph().align)},findType1Conflicts:n,findType2Conflicts:o,addConflict:r,hasConflict:s,verticalAlignment:i,horizontalCompaction:a,alignCoordinates:c,findSmallestWidthAlignment:l,balance:d},Jf}function I7(){if(kk)return Zf;kk=1;let t=It(),e=_7().positionX;return Zf=function(n){n=t.asNonCompoundGraph(n),function(o){let r=t.buildLayerMatrix(o),s=o.graph().ranksep,i=0;r.forEach(a=>{const l=a.reduce((c,d)=>{const h=o.node(d).height;return c>h?c:h},0);a.forEach(c=>o.node(c).y=i+l/2),i+=l+s})}(n),Object.entries(e(n)).forEach(([o,r])=>n.node(o).x=r)},Zf}function A7(){if(Ck)return Qf;Ck=1;let t=x7(),e=b7(),n=v7(),o=It().normalizeRanks,r=w7(),s=It().removeEmptyRanks,i=k7(),a=function(){if(ik)return Hf;ik=1;let N=It();function j(E,T,I,O,L,D){let R={width:0,height:0,rank:D,borderType:T},P=L[T][D-1],z=N.addDummyNode(E,"border",R,I);L[T][D]=z,E.setParent(z,O),P&&E.setEdge(P,z,{weight:1})}return Hf=function(E){E.children().forEach(function T(I){let O=E.children(I),L=E.node(I);if(O.length&&O.forEach(T),Object.hasOwn(L,"minRank")){L.borderLeft=[],L.borderRight=[];for(let D=L.minRank,R=L.maxRank+1;D<R;++D)j(E,"borderLeft","_bl",I,L,D),j(E,"borderRight","_br",I,L,D)}})},Hf}(),l=C7(),c=E7(),d=I7(),h=It(),f=Pn().Graph;Qf=function(N,j){let E=j&&j.debugTiming?h.time:h.notime;E("layout",()=>{let T=E(" buildLayoutGraph",()=>function(I){let O=new f({multigraph:!0,compound:!0}),L=C(I.graph());return O.setGraph(Object.assign({},g,S(L,m),h.pick(L,x))),I.nodes().forEach(D=>{const R=S(C(I.node(D)),p);Object.keys(b).forEach(P=>{R[P]===void 0&&(R[P]=b[P])}),O.setNode(D,R),O.setParent(D,I.parent(D))}),I.edges().forEach(D=>{let R=C(I.edge(D));O.setEdge(D,Object.assign({},v,S(R,y),h.pick(R,w)))}),O}(N));E(" runLayout",()=>function(I,O,L){O(" makeSpaceForEdgeLabels",()=>function(D){let R=D.graph();R.ranksep/=2,D.edges().forEach(P=>{let z=D.edge(P);z.minlen*=2,z.labelpos.toLowerCase()!=="c"&&(R.rankdir==="TB"||R.rankdir==="BT"?z.width+=z.labeloffset:z.height+=z.labeloffset)})}(I)),O(" removeSelfEdges",()=>function(D){D.edges().forEach(R=>{if(R.v===R.w){var P=D.node(R.v);P.selfEdges||(P.selfEdges=[]),P.selfEdges.push({e:R,label:D.edge(R)}),D.removeEdge(R)}})}(I)),O(" acyclic",()=>t.run(I)),O(" nestingGraph.run",()=>i.run(I)),O(" rank",()=>n(h.asNonCompoundGraph(I))),O(" injectEdgeLabelProxies",()=>function(D){D.edges().forEach(R=>{let P=D.edge(R);if(P.width&&P.height){let z=D.node(R.v),_={rank:(D.node(R.w).rank-z.rank)/2+z.rank,e:R};h.addDummyNode(D,"edge-proxy",_,"_ep")}})}(I)),O(" removeEmptyRanks",()=>s(I)),O(" nestingGraph.cleanup",()=>i.cleanup(I)),O(" normalizeRanks",()=>o(I)),O(" assignRankMinMax",()=>function(D){let R=0;D.nodes().forEach(P=>{let z=D.node(P);z.borderTop&&(z.minRank=D.node(z.borderTop).rank,z.maxRank=D.node(z.borderBottom).rank,R=Math.max(R,z.maxRank))}),D.graph().maxRank=R}(I)),O(" removeEdgeLabelProxies",()=>function(D){D.nodes().forEach(R=>{let P=D.node(R);P.dummy==="edge-proxy"&&(D.edge(P.e).labelRank=P.rank,D.removeNode(R))})}(I)),O(" normalize.run",()=>e.run(I)),O(" parentDummyChains",()=>r(I)),O(" addBorderSegments",()=>a(I)),O(" order",()=>c(I,L)),O(" insertSelfEdges",()=>function(D){var R=h.buildLayerMatrix(D);R.forEach(P=>{var z=0;P.forEach((_,k)=>{var B=D.node(_);B.order=k+z,(B.selfEdges||[]).forEach(A=>{h.addDummyNode(D,"selfedge",{width:A.label.width,height:A.label.height,rank:B.rank,order:k+ ++z,e:A.e,label:A.label},"_se")}),delete B.selfEdges})})}(I)),O(" adjustCoordinateSystem",()=>l.adjust(I)),O(" position",()=>d(I)),O(" positionSelfEdges",()=>function(D){D.nodes().forEach(R=>{var P=D.node(R);if(P.dummy==="selfedge"){var z=D.node(P.e.v),_=z.x+z.width/2,k=z.y,B=P.x-_,A=z.height/2;D.setEdge(P.e,P.label),D.removeNode(R),P.label.points=[{x:_+2*B/3,y:k-A},{x:_+5*B/6,y:k-A},{x:_+B,y:k},{x:_+5*B/6,y:k+A},{x:_+2*B/3,y:k+A}],P.label.x=P.x,P.label.y=P.y}})}(I)),O(" removeBorderNodes",()=>function(D){D.nodes().forEach(R=>{if(D.children(R).length){let P=D.node(R),z=D.node(P.borderTop),_=D.node(P.borderBottom),k=D.node(P.borderLeft[P.borderLeft.length-1]),B=D.node(P.borderRight[P.borderRight.length-1]);P.width=Math.abs(B.x-k.x),P.height=Math.abs(_.y-z.y),P.x=k.x+P.width/2,P.y=z.y+P.height/2}}),D.nodes().forEach(R=>{D.node(R).dummy==="border"&&D.removeNode(R)})}(I)),O(" normalize.undo",()=>e.undo(I)),O(" fixupEdgeLabelCoords",()=>function(D){D.edges().forEach(R=>{let P=D.edge(R);if(Object.hasOwn(P,"x"))switch(P.labelpos!=="l"&&P.labelpos!=="r"||(P.width-=P.labeloffset),P.labelpos){case"l":P.x-=P.width/2+P.labeloffset;break;case"r":P.x+=P.width/2+P.labeloffset}})}(I)),O(" undoCoordinateSystem",()=>l.undo(I)),O(" translateGraph",()=>function(D){let R=Number.POSITIVE_INFINITY,P=0,z=Number.POSITIVE_INFINITY,_=0,k=D.graph(),B=k.marginx||0,A=k.marginy||0;function U($){let X=$.x,Y=$.y,G=$.width,W=$.height;R=Math.min(R,X-G/2),P=Math.max(P,X+G/2),z=Math.min(z,Y-W/2),_=Math.max(_,Y+W/2)}D.nodes().forEach($=>U(D.node($))),D.edges().forEach($=>{let X=D.edge($);Object.hasOwn(X,"x")&&U(X)}),R-=B,z-=A,D.nodes().forEach($=>{let X=D.node($);X.x-=R,X.y-=z}),D.edges().forEach($=>{let X=D.edge($);X.points.forEach(Y=>{Y.x-=R,Y.y-=z}),Object.hasOwn(X,"x")&&(X.x-=R),Object.hasOwn(X,"y")&&(X.y-=z)}),k.width=P-R+B,k.height=_-z+A}(I)),O(" assignNodeIntersects",()=>function(D){D.edges().forEach(R=>{let P,z,_=D.edge(R),k=D.node(R.v),B=D.node(R.w);_.points?(P=_.points[0],z=_.points[_.points.length-1]):(_.points=[],P=B,z=k),_.points.unshift(h.intersectRect(k,P)),_.points.push(h.intersectRect(B,z))})}(I)),O(" reversePoints",()=>function(D){D.edges().forEach(R=>{let P=D.edge(R);P.reversed&&P.points.reverse()})}(I)),O(" acyclic.undo",()=>t.undo(I))}(T,E,j)),E(" updateInputGraph",()=>function(I,O){I.nodes().forEach(L=>{let D=I.node(L),R=O.node(L);D&&(D.x=R.x,D.y=R.y,D.rank=R.rank,O.children(L).length&&(D.width=R.width,D.height=R.height))}),I.edges().forEach(L=>{let D=I.edge(L),R=O.edge(L);D.points=R.points,Object.hasOwn(R,"x")&&(D.x=R.x,D.y=R.y)}),I.graph().width=O.graph().width,I.graph().height=O.graph().height}(N,T))})};let m=["nodesep","edgesep","ranksep","marginx","marginy"],g={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},x=["acyclicer","ranker","rankdir","align"],p=["width","height","rank"],b={width:0,height:0},y=["minlen","weight","width","height","labeloffset"],v={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},w=["labelpos"];function S(N,j){return h.mapValues(h.pick(N,j),Number)}function C(N){var j={};return N&&Object.entries(N).forEach(([E,T])=>{typeof E=="string"&&(E=E.toLowerCase()),j[E]=T}),j}return Qf}function T7(){if(jk)return em;jk=1;let t=It(),e=Pn().Graph;return em={debugOrdering:function(n){let o=t.buildLayerMatrix(n),r=new e({compound:!0,multigraph:!0}).setGraph({});return n.nodes().forEach(s=>{r.setNode(s,{label:s}),r.setParent(s,"layer"+n.node(s).rank)}),n.edges().forEach(s=>r.setEdge(s.v,s.w,{},s.name)),o.forEach((s,i)=>{let a="layer"+i;r.setNode(a,{rank:"same"}),s.reduce((l,c)=>(r.setEdge(l,c,{style:"invis"}),c))}),r}},em}var Rk=_k?Ek:(_k=1,Ek={graphlib:Pn(),layout:A7(),debug:T7(),util:{time:It().time,notime:It().notime},version:Nk?Sk:(Nk=1,Sk="1.1.5")});const Ti=new Rk.graphlib.Graph().setDefaultEdgeLabel(()=>({})),Pk=({nodes:t,edges:e,direction:n})=>(Ti.setGraph({rankdir:n,nodesep:150,ranksep:200,ranker:"longest-path"}),e.forEach(o=>Ti.setEdge(o.source,o.target)),t.forEach(o=>Ti.setNode(o.id,{...o,width:o.width??0,height:o.height??0})),Rk.layout(Ti),{nodes:t.map(o=>{const{x:r,y:s}=Ti.node(o.id);return{...o,position:{x:r,y:s}}}),edges:e}),Lk=new class{createEdge(t,e){return{animated:!0,markerEnd:{type:Zr.ArrowClosed},id:`${t}-${e}`,style:{strokeWidth:2},source:t,sourceHandle:"outputs",targetHandle:"inputs",target:e}}createNode(t,e){return{id:t,data:{atom:e,forceWidth:300},width:300,type:"custom",height:gf(Qe.get(e).code.trim().split(`
162
+ `).length),position:{x:0,y:0}}}createElements(t,e,n,o){const r=[],s=[],i=new Set,a=new Set;for(const l of Object.values(n)){if(l.value==="marimo"&&l.name==="mo")continue;const{declaredBy:c,usedBy:d}=l;for(const h of c)for(const f of d){const m=`${h}-${f}`;a.has(m)||(a.add(m),i.add(h),i.add(f),s.push(this.createEdge(h,f)))}}for(const[l,c]of Jm.zip(t,e)){o||r.push(this.createNode(l,c));const d=i.has(l),h=Qe.get(c).code.trim().startsWith("mo.md");!d&&h||r.push(this.createNode(l,c))}return{nodes:r,edges:s}}},M7=t=>{const e=H.c(43),{cellIds:n,variables:o,cellAtoms:r,children:s,layoutDirection:i,settings:a}=t;let l;e[0]!==r||e[1]!==n||e[2]!==i||e[3]!==a.hidePureMarkdown||e[4]!==o?(l=()=>{let k=Lk.createElements(n,r,o,a.hidePureMarkdown);return k=Pk({nodes:k.nodes,edges:k.edges,direction:i}),k},e[0]=r,e[1]=n,e[2]=i,e[3]=a.hidePureMarkdown,e[4]=o,e[5]=l):l=e[5];const[c]=M.useState(l),[d,h,f]=pw(c.nodes),[m,g,x]=gw(c.edges),p=_i();let b;e[6]!==i||e[7]!==g||e[8]!==h?(b=k=>{const B=Pk({nodes:k.nodes,edges:k.edges,direction:i});h(B.nodes),g(B.edges)},e[6]=i,e[7]=g,e[8]=h,e[9]=b):b=e[9];const y=Le(b);let v,w;e[10]!==r||e[11]!==n||e[12]!==a.hidePureMarkdown||e[13]!==y||e[14]!==o?(v=()=>{y(Lk.createElements(n,r,o,a.hidePureMarkdown))},w=[n,o,r,y,a.hidePureMarkdown],e[10]=r,e[11]=n,e[12]=a.hidePureMarkdown,e[13]=y,e[14]=o,e[15]=v,e[16]=w):(v=e[15],w=e[16]),M.useEffect(v,w);const[S,C]=M.useState();let N;Cw(),e[17]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{C(void 0)},e[17]=N):N=e[17];const j=N;let E,T,I,O,L,D,R,P,z,_;return e[18]===Symbol.for("react.memo_cache_sentinel")?(E={minZoom:.5,maxZoom:1.5},T=(k,B)=>{C({type:"node",id:B.id})},I=(k,B)=>{const{source:A,target:U}=B;C({type:"edge",source:A,target:U})},e[18]=E,e[19]=T,e[20]=I):(E=e[18],T=e[19],I=e[20]),e[21]===Symbol.for("react.memo_cache_sentinel")?(O=u.jsx(ZM,{color:"#ccc",variant:En.Dots}),e[21]=O):O=e[21],e[22]!==p||e[23]!==d?(L=()=>{const k=Qe.get(uL);if(k){const B=d.find(A=>A.id===k);B&&(p.fitView({padding:1,duration:600,nodes:[B]}),C({type:"node",id:k}))}},e[22]=p,e[23]=d,e[24]=L):L=e[24],e[25]===Symbol.for("react.memo_cache_sentinel")?(D=u.jsx(Mp,{className:"size-4"}),e[25]=D):D=e[25],e[26]!==L?(R=u.jsx(qM,{position:"bottom-right",showInteractive:!1,children:u.jsx(Ne,{content:"Jump to focused cell",delayDuration:200,side:"left",asChild:!1,children:u.jsx(is,{onMouseDown:zn.preventFocus,onClick:L,children:D})})}),e[26]=L,e[27]=R):R=e[27],e[28]!==m||e[29]!==S||e[30]!==o?(P=u.jsx(Jl,{selection:S,variables:o,edges:m,onClearSelection:j}),e[28]=m,e[29]=S,e[30]=o,e[31]=P):P=e[31],e[32]!==s||e[33]!==m||e[34]!==d||e[35]!==x||e[36]!==f||e[37]!==R||e[38]!==P?(z=u.jsxs(pf,{nodes:d,edges:m,nodeTypes:ww,minZoom:.2,fitViewOptions:E,onNodeClick:T,onEdgeClick:I,onNodeDoubleClick:O7,fitView:!0,onNodesChange:f,onEdgesChange:x,zoomOnDoubleClick:!1,nodesConnectable:!1,children:[O,R,P,s]}),e[32]=s,e[33]=m,e[34]=d,e[35]=x,e[36]=f,e[37]=R,e[38]=P,e[39]=z):z=e[39],e[40]!==i||e[41]!==z?(_=u.jsx(yw,{value:i,children:z}),e[40]=i,e[41]=z,e[42]=_):_=e[42],_};function O7(t,e){HC(e.id,"focus")}const D7=vt("_minimap_"),R7=vt({hidePureMarkdown:!0}),P7=t=>{const e=H.c(11),[n,o]=Dt(D7),[r,s]=Dt(R7);let i;e[0]!==n||e[1]!==t||e[2]!==o||e[3]!==s||e[4]!==r?(i=()=>n==="_minimap_"?u.jsx(o7,{...t,children:u.jsx(bf,{settings:r,onSettingsChange:s,view:n,onChange:o})}):u.jsx(M7,{...t,settings:r,layoutDirection:n,children:u.jsx(bf,{settings:r,onSettingsChange:s,view:n,onChange:o})}),e[0]=n,e[1]=t,e[2]=o,e[3]=s,e[4]=r,e[5]=i):i=e[5];const a=i;let l,c;return e[6]!==a?(l=a(),e[6]=a,e[7]=l):l=e[7],e[8]!==n||e[9]!==l?(c=u.jsx(mf,{children:l},n),e[8]=n,e[9]=l,e[10]=c):c=e[10],c},L7=()=>{const t=H.c(5),e=ep(),n=wr(),[o]=hL();let r,s;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=xe("w-full h-full flex-1 mx-auto -mb-4 relative"),t[0]=r):r=t[0],t[1]!==n.inOrderIds||t[2]!==o||t[3]!==e?(s=u.jsx("div",{className:r,children:u.jsx(P7,{cellAtoms:o,variables:e,cellIds:n.inOrderIds})}),t[1]=n.inOrderIds,t[2]=o,t[3]=e,t[4]=s):s=t[4],s},F7=t=>{const e=H.c(4),{isOpen:n,children:o}=t,[r,s]=q.useState(!1);let i,a;return e[0]!==r||e[1]!==n?(i=()=>{n&&!r&&s(!0)},a=[n,r],e[0]=r,e[1]=n,e[2]=i,e[3]=a):(i=e[2],a=e[3]),q.useEffect(i,a),r?o:null},z7=t=>{const e=H.c(8),{variableName:n,className:o}=t;let r;e[0]!==n?(r=()=>{const l=function(d){const h=Qe.get(Sc)[d];if(h)return h.declaredBy[0]}(n);if(!l)return;const c=Li(l);c&&Qm(c,n)},e[0]=n,e[1]=r):r=e[1];const s=r;let i,a;return e[2]!==o?(i=xe("text-link opacity-80 hover:opacity-100 hover:underline",o),e[2]=o,e[3]=i):i=e[3],e[4]!==s||e[5]!==i||e[6]!==n?(a=u.jsx("button",{type:"button",onClick:s,className:i,children:n}),e[4]=s,e[5]=i,e[6]=n,e[7]=a):a=e[7],a},B7=vt(t=>{const e=t(fL),n=t(Sc),o=t(la);return pa(e,r=>{if(!r.variable_name)return-1;const s=Object.values(n).find(a=>a.name===r.variable_name);if(!s)return 0;const i=o.inOrderIds.indexOf(s.declaredBy[0]);return i===-1?0:i})}),U7=vt(t=>{const e=new Map(t(mL));for(const n of WC){const o=e.get(n);o&&o.databases.length===0&&e.delete(n)}return pa([...e.values()],n=>WC.has(n.name)?1:0)}),$7=()=>{const t=H.c(32),[e,n]=q.useState(""),o=jt(qC),r=je(B7),s=je(U7);if(r.length===0&&s.length===0){let b;return t[0]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(dn,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:u.jsx(Og,{children:u.jsxs(ve,{variant:"outline",size:"sm",children:["Add database or catalog",u.jsx(Jo,{className:"h-4 w-4 ml-2"})]})}),icon:u.jsx(Yo,{})}),t[0]=b):b=t[0],b}const i=!!e.trim();let a,l,c,d,h,f,m,g,x,p;if(t[1]!==o?(a=b=>{o(b.length>0),n(b)},t[1]=o,t[2]=a):a=t[2],t[3]!==e||t[4]!==a?(l=u.jsx(Bi,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:a,rootClassName:"flex-1 border-r"}),t[3]=e,t[4]=a,t[5]=l):l=t[5],t[6]!==i?(c=i&&u.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:u.jsx(wn,{className:"h-4 w-4"})}),t[6]=i,t[7]=c):c=t[7],t[8]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx(Og,{children:u.jsx("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:u.jsx(Jo,{className:"h-4 w-4"})})}),t[8]=d):d=t[8],t[9]!==l||t[10]!==c?(h=u.jsxs("div",{className:"flex items-center w-full",children:[l,c,d]}),t[9]=l,t[10]=c,t[11]=h):h=t[11],t[12]!==s||t[13]!==i||t[14]!==e){let b;t[16]!==i||t[17]!==e?(b=y=>u.jsx(V7,{connection:y,hasChildren:y.databases.length>0,children:y.databases.map(v=>u.jsx(H7,{engineName:y.name,database:v,hasSearch:i,children:u.jsx(W7,{schemas:v.schemas,defaultSchema:y.default_schema,defaultDatabase:y.default_database,engineName:y.name,databaseName:v.name,hasSearch:i,searchValue:e})},v.name))},y.name),t[16]=i,t[17]=e,t[18]=b):b=t[18],f=s.map(b),t[12]=s,t[13]=i,t[14]=e,t[15]=f}else f=t[15];return t[19]!==s.length||t[20]!==r.length?(m=s.length>0&&r.length>0&&u.jsxs(GC,{children:[u.jsx(cc,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-xs",children:"Python"})]}),t[19]=s.length,t[20]=r.length,t[21]=m):m=t[21],t[22]!==e||t[23]!==r?(g=r.length>0&&u.jsx(Fk,{tables:r,searchValue:e}),t[22]=e,t[23]=r,t[24]=g):g=t[24],t[25]!==f||t[26]!==m||t[27]!==g?(x=u.jsxs(Um,{className:"flex flex-col",children:[f,m,g]}),t[25]=f,t[26]=m,t[27]=g,t[28]=x):x=t[28],t[29]!==h||t[30]!==x?(p=u.jsxs(kc,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden",shouldFilter:!1,children:[h,x]}),t[29]=h,t[30]=x,t[31]=p):p=t[31],p},V7=t=>{const e=H.c(26),{connection:n,children:o,hasChildren:r}=t,s=n.name===pL,i=s?"In-Memory":n.name,{previewDataSourceConnection:a}=tt(),[l,c]=q.useState(!1);let d;e[0]!==n.name||e[1]!==a?(d=async()=>{c(!0),await a({engine:n.name}),setTimeout(()=>c(!1),500)},e[0]=n.name,e[1]=a,e[2]=d):d=e[2];const h=d;let f,m,g;e[3]!==n.dialect?(f=u.jsx(P3,{className:"h-4 w-4 text-muted-foreground",name:n.dialect}),e[3]=n.dialect,e[4]=f):f=e[4],e[5]!==n.dialect?(m=gL(n.dialect),e[5]=n.dialect,e[6]=m):m=e[6],e[7]!==m?(g=u.jsx("span",{className:"text-xs",children:m}),e[7]=m,e[8]=g):g=e[8];const x=i;let p,b,y,v,w;return e[9]!==x?(p=u.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",u.jsx(z7,{variableName:x}),")"]}),e[9]=x,e[10]=p):p=e[10],e[11]!==h||e[12]!==s||e[13]!==l?(b=!s&&u.jsx(Ne,{content:"Refresh connection",children:u.jsx(ve,{variant:"ghost",size:"icon",className:"ml-auto hover:bg-transparent hover:shadow-none",onClick:h,children:u.jsx(Dc,{className:xe("h-4 w-4 text-muted-foreground hover:text-foreground",l&&"animate-[spin_0.5s]")})})}),e[11]=h,e[12]=s,e[13]=l,e[14]=b):b=e[14],e[15]!==f||e[16]!==g||e[17]!==p||e[18]!==b?(y=u.jsxs(GC,{children:[f,g,p,b]}),e[15]=f,e[16]=g,e[17]=p,e[18]=b,e[19]=y):y=e[19],e[20]!==o||e[21]!==r?(v=r?o:u.jsx(Wc,{content:"No databases available",className:"pl-2"}),e[20]=o,e[21]=r,e[22]=v):v=e[22],e[23]!==y||e[24]!==v?(w=u.jsxs(u.Fragment,{children:[y,v]}),e[23]=y,e[24]=v,e[25]=w):w=e[25],w},H7=t=>{const e=H.c(28),{hasSearch:n,engineName:o,database:r,children:s}=t,[i,a]=q.useState(!1),[l,c]=q.useState(!1);let d,h,f;e[0]!==n?(d=()=>{a(n)},h=[n],e[0]=n,e[1]=d,e[2]=h):(d=e[1],h=e[2]),q.useEffect(d,h),e[3]!==i||e[4]!==l?(f=()=>{a(!i),c(!l)},e[3]=i,e[4]=l,e[5]=f):f=e[5];const m=`${o}:${r.name}`;let g;e[6]!==i?(g=u.jsx(QC,{isExpanded:i}),e[6]=i,e[7]=g):g=e[7];const x=l&&i?"text-foreground":"text-muted-foreground";let p,b;e[8]!==x?(p=xe("h-4 w-4",x),e[8]=x,e[9]=p):p=e[9],e[10]!==p?(b=u.jsx(Yo,{className:p}),e[10]=p,e[11]=b):b=e[11];const y=l&&i&&"font-semibold";let v,w,S,C;e[12]!==y?(v=xe(y),e[12]=y,e[13]=v):v=e[13],e[14]!==r.name?(w=r.name===""?u.jsx("i",{children:"Not connected"}):r.name,e[14]=r.name,e[15]=w):w=e[15],e[16]!==v||e[17]!==w?(S=u.jsx("span",{className:v,children:w}),e[16]=v,e[17]=w,e[18]=S):S=e[18],e[19]!==S||e[20]!==f||e[21]!==m||e[22]!==g||e[23]!==b?(C=u.jsxs(Zn,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",onSelect:f,value:m,children:[g,b,S]}),e[19]=S,e[20]=f,e[21]=m,e[22]=g,e[23]=b,e[24]=C):C=e[24];const N=i&&s;let j;return e[25]!==C||e[26]!==N?(j=u.jsxs(u.Fragment,{children:[C,N]}),e[25]=C,e[26]=N,e[27]=j):j=e[27],j},W7=t=>{const e=H.c(20),{schemas:n,defaultSchema:o,defaultDatabase:r,engineName:s,databaseName:i,hasSearch:a,searchValue:l}=t;if(n.length===0){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=u.jsx(Wc,{content:"No schemas available",className:"pl-6"}),e[0]=h):h=e[0],h}let c,d;if(e[1]!==i||e[2]!==r||e[3]!==o||e[4]!==s||e[5]!==a||e[6]!==n||e[7]!==l){let h;e[9]!==l?(h=g=>!l||g.tables.some(x=>x.name.toLowerCase().includes(l.toLowerCase())),e[9]=l,e[10]=h):h=e[10];const f=n.filter(h);let m;e[11]!==i||e[12]!==r||e[13]!==o||e[14]!==s||e[15]!==a||e[16]!==l?(m=g=>u.jsx(q7,{databaseName:i,schema:g,hasSearch:a,children:u.jsx(Fk,{tables:g.tables,searchValue:l,sqlTableContext:{engine:s,database:i,schema:g.name,defaultSchema:o,defaultDatabase:r}})},g.name),e[11]=i,e[12]=r,e[13]=o,e[14]=s,e[15]=a,e[16]=l,e[17]=m):m=e[17],c=f.map(m),e[1]=i,e[2]=r,e[3]=o,e[4]=s,e[5]=a,e[6]=n,e[7]=l,e[8]=c}else c=e[8];return e[18]!==c?(d=u.jsx(u.Fragment,{children:c}),e[18]=c,e[19]=d):d=e[19],d},q7=t=>{const e=H.c(26),{databaseName:n,schema:o,children:r,hasSearch:s}=t,[i,a]=q.useState(!1),[l,c]=q.useState(!1),d=`${n}:${o.name}`;let h,f,m,g;if(e[0]!==s?(h=()=>{a(s)},f=[s],e[0]=s,e[1]=h,e[2]=f):(h=e[1],f=e[2]),q.useEffect(h,f),ZC(o.name))return r;e[3]!==i||e[4]!==l?(m=()=>{a(!i),c(!l)},e[3]=i,e[4]=l,e[5]=m):m=e[5],e[6]!==i?(g=u.jsx(QC,{isExpanded:i}),e[6]=i,e[7]=g):g=e[7];const x=l&&i&&"text-foreground";let p,b;e[8]!==x?(p=xe("h-4 w-4 text-muted-foreground",x),e[8]=x,e[9]=p):p=e[9],e[10]!==p?(b=u.jsx(CL,{className:p}),e[10]=p,e[11]=b):b=e[11];const y=l&&i&&"font-semibold";let v,w,S;e[12]!==y?(v=xe(y),e[12]=y,e[13]=v):v=e[13],e[14]!==o.name||e[15]!==v?(w=u.jsx("span",{className:v,children:o.name}),e[14]=o.name,e[15]=v,e[16]=w):w=e[16],e[17]!==w||e[18]!==m||e[19]!==g||e[20]!==b||e[21]!==d?(S=u.jsxs(Zn,{className:"text-sm flex flex-row gap-1 items-center pl-5 cursor-pointer rounded-none",onSelect:m,value:d,children:[g,b,w]}),e[17]=w,e[18]=m,e[19]=g,e[20]=b,e[21]=d,e[22]=S):S=e[22];const C=i&&r;let N;return e[23]!==S||e[24]!==C?(N=u.jsxs(u.Fragment,{children:[S,C]}),e[23]=S,e[24]=C,e[25]=N):N=e[25],N},Fk=t=>{const e=H.c(24),{tables:n,sqlTableContext:o,searchValue:r}=t,{addTableList:s}=YC(),[i,a]=q.useState(!1),[l,c]=q.useState(!1);let d,h;e[0]!==s||e[1]!==o||e[2]!==n.length||e[3]!==i?(d=async()=>{if(n.length===0&&o&&!i){a(!0),c(!0);const{engine:p,database:b,schema:y}=o,v=await zF.request({engine:p,database:b,schema:y});if(!(v!=null&&v.tables))throw c(!1),new Error("No tables available");s({tables:v.tables,sqlTableContext:o}),c(!1)}},e[0]=s,e[1]=o,e[2]=n.length,e[3]=i,e[4]=d):d=e[4],e[5]!==o||e[6]!==n.length||e[7]!==i?(h=[n.length,o,i],e[5]=o,e[6]=n.length,e[7]=i,e[8]=h):h=e[8];const{isPending:f,error:m}=Tn(d,h);if(f||l){let p;return e[9]===Symbol.for("react.memo_cache_sentinel")?(p=u.jsx(KC,{message:"Loading tables...",className:"pl-12"}),e[9]=p):p=e[9],p}if(m){let p;return e[10]!==m?(p=u.jsx(XC,{error:m,className:"pl-12"}),e[10]=m,e[11]=p):p=e[11],p}if(n.length===0){let p;return e[12]===Symbol.for("react.memo_cache_sentinel")?(p=u.jsx(Wc,{content:"No tables found",className:"pl-9"}),e[12]=p):p=e[12],p}let g,x;if(e[13]!==r||e[14]!==o||e[15]!==n){let p;e[17]!==r?(p=v=>!r||v.name.toLowerCase().includes(r.toLowerCase()),e[17]=r,e[18]=p):p=e[18];const b=n.filter(p);let y;e[19]!==r||e[20]!==o?(y=v=>u.jsx(G7,{table:v,sqlTableContext:o,isSearching:!!r},v.name),e[19]=r,e[20]=o,e[21]=y):y=e[21],g=b.map(y),e[13]=r,e[14]=o,e[15]=n,e[16]=g}else g=e[16];return e[22]!==g?(x=u.jsx(u.Fragment,{children:g}),e[22]=g,e[23]=x):x=e[23],x},G7=t=>{const e=H.c(64),{table:n,sqlTableContext:o,isSearching:r}=t,{addTable:s}=YC(),[i,a]=q.useState(!1),[l,c]=q.useState(!1),d=n.columns.length>0;let h,f;e[0]!==s||e[1]!==i||e[2]!==o||e[3]!==n.name||e[4]!==d||e[5]!==l?(h=async()=>{if(i&&!d&&o&&!l){c(!0);const{engine:W,database:J,schema:V}=o,Q=await BF.request({engine:W,database:J,schema:V,tableName:n.name});if(!(Q!=null&&Q.table))throw new Error("No table details available");s({table:Q.table,sqlTableContext:o})}},e[0]=s,e[1]=i,e[2]=o,e[3]=n.name,e[4]=d,e[5]=l,e[6]=h):h=e[6],e[7]!==i||e[8]!==d?(f=[i,d],e[7]=i,e[8]=d,e[9]=f):f=e[9];const{isFetching:m,isPending:g,error:x}=Tn(h,f),p=je(ac),b=ms(),{createNewCell:y}=lt(),v=JC();let w;e[10]!==v||e[11]!==p||e[12]!==y||e[13]!==b||e[14]!==o||e[15]!==n?(w=()=>{Jn({autoInstantiate:p,createNewCell:y,fromCellId:b}),v((()=>{if(n.source_type==="catalog"){const W=o!=null&&o.database?`${o.database}.${n.name}`:n.name;return`${n.engine}.load_table("${W}")`}if(o)return ej({table:n,columnName:"*",sqlTableContext:o});switch(n.source_type){case"local":return`mo.ui.table(${n.name})`;case"duckdb":case"connection":return ej({table:n,columnName:"*",sqlTableContext:o});default:return pc(n.source_type),""}})())},e[10]=v,e[11]=p,e[12]=y,e[13]=b,e[14]=o,e[15]=n,e[16]=w):w=e[16];const S=w;let C;e[17]!==n.num_columns||e[18]!==n.num_rows?(C=()=>{const W=[];return n.num_rows!=null&&W.push(`${n.num_rows} rows`),n.num_columns!=null&&W.push(`${n.num_columns} columns`),W.length===0?null:u.jsx("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:u.jsx("span",{className:"text-xs text-muted-foreground",children:W.join(", ")})})},e[17]=n.num_columns,e[18]=n.num_rows,e[19]=C):C=e[19];const N=C;let j;e[20]!==x||e[21]!==m||e[22]!==g||e[23]!==o||e[24]!==n?(j=()=>{if(g||m)return u.jsx(KC,{message:"Loading columns...",className:"pl-12"});if(x)return u.jsx(XC,{error:x,className:"pl-12"});const W=n.columns;return W.length===0?u.jsx(Wc,{content:"No columns found",className:"pl-12"}):W.map(J=>u.jsx(Y7,{table:n,column:J,sqlTableContext:o},J.name))},e[20]=x,e[21]=m,e[22]=g,e[23]=o,e[24]=n,e[25]=j):j=e[25];const E=j;let T;e[26]!==i||e[27]!==r||e[28]!==n.source_type||e[29]!==n.type?(T=()=>{if(n.source_type==="local")return;const W=n.type==="table"?xL:um;return u.jsx(W,{className:"h-3 w-3",strokeWidth:i||r?2.5:void 0})},e[26]=i,e[27]=r,e[28]=n.source_type,e[29]=n.type,e[30]=T):T=e[30];const I=T,O=o?`${o.database}.${o.schema}.${n.name}`:n.name,L=o&&(ZC(o.schema)?"pl-9":"pl-12"),D=(i||r)&&"font-semibold";let R,P,z,_,k,B,A,U,$,X,Y,G;return e[31]!==L||e[32]!==D?(R=xe("rounded-none group h-8 cursor-pointer",L,D),e[31]=L,e[32]=D,e[33]=R):R=e[33],e[34]!==i?(P=()=>a(!i),e[34]=i,e[35]=P):P=e[35],e[36]!==I?(z=I(),e[36]=I,e[37]=z):z=e[37],e[38]!==n.name?(_=u.jsx("span",{className:"text-sm",children:n.name}),e[38]=n.name,e[39]=_):_=e[39],e[40]!==z||e[41]!==_?(k=u.jsxs("div",{className:"flex gap-2 items-center flex-1",children:[z,_]}),e[40]=z,e[41]=_,e[42]=k):k=e[42],e[43]!==N?(B=N(),e[43]=N,e[44]=B):B=e[44],e[45]!==S?(A=zn.stopPropagation(()=>S()),e[45]=S,e[46]=A):A=e[46],e[47]===Symbol.for("react.memo_cache_sentinel")?(U=u.jsx(bL,{className:"h-3 w-3"}),e[47]=U):U=e[47],e[48]!==A?($=u.jsx(Ne,{content:"Add table to notebook",delayDuration:400,children:u.jsx(ve,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:A,children:U})}),e[48]=A,e[49]=$):$=e[49],e[50]!==i||e[51]!==P||e[52]!==k||e[53]!==B||e[54]!==$||e[55]!==R||e[56]!==O?(X=u.jsxs(Zn,{className:R,value:O,"aria-selected":i,forceMount:!0,onSelect:P,children:[k,B,$]}),e[50]=i,e[51]=P,e[52]=k,e[53]=B,e[54]=$,e[55]=R,e[56]=O,e[57]=X):X=e[57],e[58]!==i||e[59]!==E?(Y=i&&E(),e[58]=i,e[59]=E,e[60]=Y):Y=e[60],e[61]!==X||e[62]!==Y?(G=u.jsxs(u.Fragment,{children:[X,Y]}),e[61]=X,e[62]=Y,e[63]=G):G=e[63],G},Y7=t=>{var A,U;const e=H.c(51),{table:n,column:o,sqlTableContext:r}=t,[s,i]=q.useState(!1),a=je(qC),l=jt(yL);let c,d;e[0]!==a?(c=()=>{a&&i(!1)},d=[a],e[0]=a,e[1]=c,e[2]=d):(c=e[1],d=e[2]),q.useEffect(c,d),l(s?$=>new Set([...$,`${n.name}:${o.name}`]):$=>($.delete(`${n.name}:${o.name}`),new Set($)));const h=JC(),{columnsPreviews:f}=vL();let m;e[3]!==o.name||e[4]!==n.primary_keys?(m=((A=n.primary_keys)==null?void 0:A.includes(o.name))||!1,e[3]=o.name,e[4]=n.primary_keys,e[5]=m):m=e[5];const g=m;let x;e[6]!==o.name||e[7]!==n.indexes?(x=((U=n.indexes)==null?void 0:U.includes(o.name))||!1,e[6]=o.name,e[7]=n.indexes,e[8]=x):x=e[8];const p=x;let b;e[9]!==h?(b=$=>{h($)},e[9]=h,e[10]=b):b=e[10];const y=b,v=K7,w=s?"font-semibold":"";let S;e[11]!==o.name||e[12]!==w?(S=u.jsx("span",{className:w,children:o.name}),e[11]=o.name,e[12]=w,e[13]=S):S=e[13];const C=S,N=`${n.name}.${o.name}`,j=`${n.name}.${o.name}`;let E;e[14]!==s?(E=()=>i(!s),e[14]=s,e[15]=E):E=e[15];const T=r?"pl-14":"pl-7";let I,O,L,D,R,P,z,_,k,B;return e[16]!==T?(I=xe("flex flex-row gap-2 items-center flex-1",T),e[16]=T,e[17]=I):I=e[17],e[18]!==o.type||e[19]!==C?(O=u.jsx(wL,{columnName:C,dataType:o.type}),e[18]=o.type,e[19]=C,e[20]=O):O=e[20],e[21]!==g?(L=g&&v({tooltipContent:"Primary key",content:"PK"}),e[21]=g,e[22]=L):L=e[22],e[23]!==p?(D=p&&v({tooltipContent:"Indexed",content:"IDX"}),e[23]=p,e[24]=D):D=e[24],e[25]!==I||e[26]!==O||e[27]!==L||e[28]!==D?(R=u.jsxs("div",{className:I,children:[O,L,D]}),e[25]=I,e[26]=O,e[27]=L,e[28]=D,e[29]=R):R=e[29],e[30]!==o.name?(P=u.jsx(Ne,{content:"Copy column name",delayDuration:400,children:u.jsx(ve,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:u.jsx(UC,{tooltip:!1,value:o.name,className:"h-3 w-3"})})}),e[30]=o.name,e[31]=P):P=e[31],e[32]!==o.external_type?(z=u.jsx("span",{className:"text-xs text-muted-foreground",children:o.external_type}),e[32]=o.external_type,e[33]=z):z=e[33],e[34]!==E||e[35]!==R||e[36]!==P||e[37]!==z||e[38]!==N||e[39]!==j?(_=u.jsxs(Zn,{className:"rounded-none py-1 group cursor-pointer",value:j,onSelect:E,children:[R,P,z]},N),e[34]=E,e[35]=R,e[36]=P,e[37]=z,e[38]=N,e[39]=j,e[40]=_):_=e[40],e[41]!==o||e[42]!==f||e[43]!==y||e[44]!==s||e[45]!==r||e[46]!==n?(k=s&&u.jsx("div",{className:"pl-10 pr-2 py-2 bg-(--slate-1) shadow-inner border-b",children:u.jsx(Cc,{children:u.jsx(kL,{table:n,column:o,onAddColumnChart:y,preview:f.get(r?`${r.database}.${r.schema}.${n.name}:${o.name}`:`${n.name}:${o.name}`),sqlTableContext:r})})}),e[41]=o,e[42]=f,e[43]=y,e[44]=s,e[45]=r,e[46]=n,e[47]=k):k=e[47],e[48]!==_||e[49]!==k?(B=u.jsxs(u.Fragment,{children:[_,k]}),e[48]=_,e[49]=k,e[50]=B):B=e[50],B};function K7(t){const{tooltipContent:e,content:n}=t;return u.jsx(Ne,{content:e,delayDuration:100,children:u.jsx("span",{className:"text-xs text-black bg-gray-100 dark:invert rounded px-1",children:n})})}const X7=()=>{const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=u.jsx($7,{}),t[0]=e):e=t[0],e},J7=()=>{const t=H.c(5),{documentation:e}=je(jL);if(!e){let r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=u.jsx(dn,{title:"View docs as you type",description:"Move your text cursor over a symbol to see its documentation.",icon:u.jsx(dd,{})}),t[0]=r):r=t[0],r}let n,o;return t[1]!==e?(n=Zm({html:e}),t[1]=e,t[2]=n):n=t[2],t[3]!==n?(o=u.jsx("div",{className:"p-3 overflow-y-auto overflow-x-hidden h-full docs-documentation flex flex-col gap-4",children:n}),t[3]=n,t[4]=o):o=t[4],o},Z7=()=>{const t=H.c(5),e=SL();if(e.length===0){let r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=u.jsx(dn,{title:"No errors!",icon:u.jsx(Bp,{})}),t[0]=r):r=t[0],r}let n,o;return t[1]!==e?(n=e.map(Q7),t[1]=e,t[2]=n):n=t[2],t[3]!==n?(o=u.jsx("div",{className:"flex flex-col overflow-auto",children:n}),t[3]=n,t[4]=o):o=t[4],o};function Q7(t){return u.jsxs("div",{children:[u.jsx("div",{className:"text-xs font-mono font-semibold bg-muted border-y px-2 py-1",children:u.jsx(NL,{cellId:t.cellId})}),u.jsx("div",{className:"px-2",children:u.jsx(EL,{errors:t.output.data,cellId:t.cellId},t.cellId)},t.cellId)]},t.cellId)}const nm=new Map,e9=({file:t,onOpenNotebook:e})=>{const{theme:n}=Zo(),{sendFileDetails:o,sendUpdateFile:r}=tt(),s=je(hc),[i,a]=M.useState(""),{data:l,isPending:c,error:d,setData:h}=Tn(async()=>{const b=await o({path:t.path}),y=b.contents||"";return a(nm.get(t.path)||y),b},[t.path]),f=async()=>{i!==(l==null?void 0:l.contents)&&await r({path:t.path,contents:i}).then(b=>{b.success&&(h(y=>({...y,contents:i})),a(i))})},m=M.useRef(i);if(m.current=i,M.useEffect(()=>()=>{if(!(l!=null&&l.contents))return;const b=m.current;b===l.contents?nm.delete(t.path):nm.set(t.path,b)},[t.path,l==null?void 0:l.contents]),d)return u.jsx(kr,{error:d});if(c||!l)return null;const g=l.mimeType||"text/plain",x=g in om;if(!l.contents&&!x)return u.jsxs("div",{className:"grid grid-cols-2 gap-2 p-6",children:[u.jsx("div",{className:"font-bold text-muted-foreground",children:"Name"}),u.jsx("div",{children:l.file.name}),u.jsx("div",{className:"font-bold text-muted-foreground",children:"Type"}),u.jsx("div",{children:g})]});const p=u.jsxs("div",{className:"text-xs text-muted-foreground p-1 flex justify-end gap-2 border-b",children:[t.isMarimoFile&&!tn()&&u.jsx(Ne,{content:"Open notebook",children:u.jsx(cn,{size:"small",onClick:b=>e(b),children:u.jsx(vc,{})})}),u.jsx(Ne,{content:"Download",children:u.jsx(cn,{size:"small",onClick:()=>{if(zk(g)){const b=OL(l.contents,g);return void DL(b,l.file.name)}Gi(new Blob([l.contents||i],{type:g}),l.file.name)},children:u.jsx(jm,{})})}),!zk(g)&&u.jsxs(u.Fragment,{children:[u.jsx(Ne,{content:"Copy contents to clipboard",children:u.jsx(cn,{size:"small",onClick:async()=>{await sn(i)},children:u.jsx(Di,{})})}),u.jsx(Ne,{content:Gt("global.save"),children:u.jsx(cn,{size:"small",color:i===l.contents?void 0:"green",onClick:f,disabled:i===l.contents,children:u.jsx(va,{})})})]})]});return g.startsWith("image/")?u.jsxs(u.Fragment,{children:[p,u.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:u.jsx(_L,{base64:l.contents,mime:g})})]}):g==="text/csv"&&l.contents?u.jsxs(u.Fragment,{children:[p,u.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:u.jsx(IL,{contents:l.contents})})]}):g.startsWith("audio/")?u.jsxs(u.Fragment,{children:[p,u.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:u.jsx(AL,{base64:l.contents,mime:g})})]}):g.startsWith("video/")?u.jsxs(u.Fragment,{children:[p,u.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:u.jsx(TL,{base64:l.contents,mime:g})})]}):g.startsWith("application/pdf")?u.jsxs(u.Fragment,{children:[p,u.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:u.jsx(ML,{base64:l.contents,mime:g})})]}):u.jsxs(u.Fragment,{children:[p,u.jsx("div",{className:"flex-1 overflow-auto",children:u.jsx(M.Suspense,{children:u.jsx(ua,{theme:n==="dark"?"dark":"light",language:om[g]||om.default,className:"border-b",extensions:[We.lineWrapping,Mn.of([{key:s.getHotkey("global.save").key,stopPropagation:!0,run:()=>i!==l.contents&&(f(),!0)}])],value:i,onChange:a})})})]})},zk=t=>t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t.startsWith("application/pdf"),om={"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"};class t9{constructor(e){this.callbacks=e,this.delegate=new sp([]),this.rootPath="",this.onChange=Bn.NOOP,this.path=new xc("/"),this.initialize=async n=>{if(this.onChange=n,this.delegate.data.length===0)try{const o=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new sp(o.files),this.rootPath=o.root,this.path=xc.guessDeliminator(o.root)}catch(o){Je({title:"Failed",description:gC(o)})}this.onChange(this.delegate.data)},this.refreshAll=async n=>{const o=[this.rootPath,...n.map(s=>{var i;return(i=this.delegate.find(s))==null?void 0:i.data.path})].filter(Boolean),r=await Promise.all(o.map(s=>this.callbacks.listFiles({path:s}).catch(()=>({files:[]}))));for(const[s,i]of o.entries()){const a=r[s];i===this.rootPath?this.delegate=new sp(a.files):this.delegate.update({id:i,changes:{children:a.files}})}this.onChange(this.delegate.data)},this.relativeFromRoot=n=>{const o=this.rootPath.endsWith(this.path.deliminator)?this.rootPath:`${this.rootPath}${this.path.deliminator}`;return n.startsWith(o)?n.slice(o.length):n},this.handleResponse=n=>n.success?n:(Je({title:"Failed",description:n.message}),null)}async expand(e){const n=this.delegate.find(e);if(!n||!n.data.isDirectory)return!1;if(n.children&&n.children.length>0)return!0;const o=await this.callbacks.listFiles({path:n.data.path});return this.delegate.update({id:e,changes:{children:o.files}}),this.onChange(this.delegate.data),!0}async rename(e,n){const o=this.delegate.find(e);if(!o)return;const r=o.data.path,s=this.path.join(this.path.dirname(r),n);await this.callbacks.renameFileOrFolder({path:r,newPath:s}).then(this.handleResponse),this.delegate.update({id:e,changes:{name:n,path:s}}),this.onChange(this.delegate.data),await this.refreshAll([s])}async move(e,n){var r;const o=n?((r=this.delegate.find(n))==null?void 0:r.data.path)??n:this.rootPath;await Promise.all(e.map(s=>{this.delegate.move({id:s,parentId:n,index:0});const i=this.delegate.find(s);if(!i)return Promise.resolve();const a=this.path.join(o,this.path.basename(i.data.path));return this.delegate.update({id:s,changes:{path:a}}),this.callbacks.renameFileOrFolder({path:i.data.path,newPath:a}).then(this.handleResponse)})),this.onChange(this.delegate.data),await this.refreshAll([o])}async createFile(e,n){var s;const o=n?((s=this.delegate.find(n))==null?void 0:s.data.path)??n:this.rootPath,r=await this.callbacks.createFileOrFolder({path:o,type:"file",name:e}).then(this.handleResponse);r!=null&&r.info&&(this.delegate.create({parentId:n,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([o]))}async createFolder(e,n){var s;const o=n?((s=this.delegate.find(n))==null?void 0:s.data.path)??n:this.rootPath,r=await this.callbacks.createFileOrFolder({path:o,type:"directory",name:e}).then(this.handleResponse);r!=null&&r.info&&(this.delegate.create({parentId:n,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([o]))}async delete(e){const n=this.delegate.find(e);n&&(await this.callbacks.deleteFileOrFolder({path:n.data.path}).then(this.handleResponse),this.delegate.drop({id:e}),this.onChange(this.delegate.data))}}const Bk=vt(t=>{const e=t(RL);return Un(e,"no requestClientAtom set"),new t9({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),n9=vt({});function o9(t){return new Promise((e,n)=>{const o=new FileReader;o.onload=r=>{var s;e((s=r.target)==null?void 0:s.result)},o.onerror=r=>{n(new Error(`Failed to read blob: ${r.type}`))},o.readAsDataURL(t)})}function Uk(t){const e=H.c(7);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const o=n,{sendCreateFileOrFolder:r}=tt();let s,i;return e[2]!==r?(s=async a=>{for(const l of a){const c=c9(l9(l));let d="";c&&(d=xc.guessDeliminator(c).dirname(c));const h=(await o9(l)).split(",")[1];await r({path:d,type:"file",name:l.name,contents:h})}await async function(){await Qe.get(Bk).refreshAll([])}()},e[2]=r,e[3]=s):s=e[3],e[4]!==o||e[5]!==s?(i={multiple:!0,maxSize:104857600,onError:a9,onDropRejected:r9,onDrop:s,...o},e[4]=o,e[5]=s,e[6]=i):i=e[6],PL(i)}function r9(t){Je({title:"File upload failed",description:u.jsx("div",{className:"flex flex-col gap-1",children:t.map(s9)}),variant:"danger"})}function s9(t){return u.jsxs("div",{children:[t.file.name," (",t.errors.map(i9).join(", "),")"]},t.file.name)}function i9(t){return t.message}function a9(t){mt.error(t),Je({title:"File upload failed",description:t.message,variant:"danger"})}function l9(t){return t.webkitRelativePath?t.webkitRelativePath:"path"in t&&typeof t.path=="string"?t.path:"relativePath"in t&&typeof t.relativePath=="string"?t.relativePath:void 0}function c9(t){if(t)return t.replace(/^\/+/,"")}const $k=q.createContext(null),d9=t=>{const e=H.c(60),{height:n}=t,o=M.useRef(null),[r]=Dt(Bk);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],e[0]=s):s=e[0];const[i,a]=M.useState(s),[l,c]=M.useState(null),{openPrompt:d}=An(),[h,f]=Dt(n9);let m,g;e[1]!==r?(m=()=>r.initialize(a),e[1]=r,e[2]=m):m=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(g=[],e[3]=g):g=e[3];const{isPending:x,error:p}=Tn(m,g);let b;e[4]!==h||e[5]!==r?(b=()=>{r.refreshAll(Object.keys(h).filter(k=>h[k]))},e[4]=h,e[5]=r,e[6]=b):b=e[6];const y=Le(b);let v;e[7]!==d||e[8]!==r?(v=async()=>{d({title:"Folder name",onConfirm:async k=>{r.createFolder(k,null)}})},e[7]=d,e[8]=r,e[9]=v):v=e[9];const w=Le(v);let S;e[10]!==d||e[11]!==r?(S=async()=>{d({title:"File name",onConfirm:async k=>{r.createFile(k,null)}})},e[10]=d,e[11]=r,e[12]=S):S=e[12];const C=Le(S);let N;e[13]!==f?(N=()=>{var k;(k=o.current)==null||k.closeAll(),f({})},e[13]=f,e[14]=N):N=e[14];const j=Le(N);if(x){let k;return e[15]===Symbol.for("react.memo_cache_sentinel")?(k=u.jsx(kn,{size:"medium",centered:!0}),e[15]=k):k=e[15],k}if(p){let k;return e[16]!==p?(k=u.jsx(kr,{error:p}),e[16]=p,e[17]=k):k=e[17],k}if(l){let k,B,A,U,$,X;return e[18]===Symbol.for("react.memo_cache_sentinel")?(k=()=>c(null),e[18]=k):k=e[18],e[19]===Symbol.for("react.memo_cache_sentinel")?(B=u.jsx(ve,{onClick:k,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:u.jsx(kt,{size:16})}),e[19]=B):B=e[19],e[20]!==l.name?(A=u.jsxs("div",{className:"flex items-center pl-1 pr-3 shrink-0 border-b justify-between",children:[B,u.jsx("span",{className:"font-bold",children:l.name})]}),e[20]=l.name,e[21]=A):A=e[21],e[22]!==l.path||e[23]!==r?(U=Y=>Vk(Y,r.relativeFromRoot(l.path)),e[22]=l.path,e[23]=r,e[24]=U):U=e[24],e[25]!==l||e[26]!==U?($=u.jsx(M.Suspense,{children:u.jsx(e9,{onOpenNotebook:U,file:l})}),e[25]=l,e[26]=U,e[27]=$):$=e[27],e[28]!==A||e[29]!==$?(X=u.jsxs(u.Fragment,{children:[A,$]}),e[28]=A,e[29]=$,e[30]=X):X=e[30],X}let E;e[31]!==j||e[32]!==C||e[33]!==w||e[34]!==y||e[35]!==r?(E=u.jsx(h9,{onRefresh:y,onCreateFile:C,onCreateFolder:w,onCollapseAll:j,tree:r}),e[31]=j,e[32]=C,e[33]=w,e[34]=y,e[35]=r,e[36]=E):E=e[36];const T=n-33;let I,O,L,D,R,P,z,_;return e[37]!==r?(I=async k=>{const{ids:B}=k;for(const A of B)await r.delete(A)},O=async k=>{const{id:B,name:A}=k;await r.rename(B,A)},L=async k=>{const{dragIds:B,parentId:A}=k;await r.move(B,A)},e[37]=r,e[38]=I,e[39]=O,e[40]=L):(I=e[38],O=e[39],L=e[40]),e[41]===Symbol.for("react.memo_cache_sentinel")?(D=k=>{const B=k[0];B&&(B.data.isDirectory||c(B.data))},e[41]=D):D=e[41],e[42]!==h||e[43]!==f||e[44]!==r?(R=async k=>{if(await r.expand(k)){const B=h[k]??!1;f({...h,[k]:!B})}},e[42]=h,e[43]=f,e[44]=r,e[45]=R):R=e[45],e[46]!==i||e[47]!==h||e[48]!==I||e[49]!==O||e[50]!==L||e[51]!==R||e[52]!==T?(P=u.jsx(kF,{width:"100%",ref:o,height:T,className:"h-full",data:i,initialOpenState:h,openByDefault:!1,renderCursor:x9,disableDrop:b9,onDelete:I,onRename:O,onMove:L,onSelect:D,onToggle:R,padding:15,rowHeight:30,indent:u9,overscanCount:1e3,disableMultiSelection:!0,children:p9}),e[46]=i,e[47]=h,e[48]=I,e[49]=O,e[50]=L,e[51]=R,e[52]=T,e[53]=P):P=e[53],e[54]!==P||e[55]!==r?(z=u.jsx($k,{value:r,children:P}),e[54]=P,e[55]=r,e[56]=z):z=e[56],e[57]!==z||e[58]!==E?(_=u.jsxs(u.Fragment,{children:[E,z]}),e[57]=z,e[58]=E,e[59]=_):_=e[59],_},u9=15,h9=t=>{const e=H.c(30),{onRefresh:n,onCreateFile:o,onCreateFolder:r,onCollapseAll:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={noDrag:!0,noDragEventsBubbling:!0},e[0]=i):i=e[0];const{getRootProps:a,getInputProps:l}=Uk(i);let c,d,h,f,m,g,x,p,b,y,v,w,S,C,N;return e[1]===Symbol.for("react.memo_cache_sentinel")?(c=u.jsx(ba,{size:16}),e[1]=c):c=e[1],e[2]!==o?(d=u.jsx(Ne,{content:"Add file",children:u.jsx(ve,{"data-testid":"file-explorer-add-file-button",onClick:o,variant:"text",size:"xs",children:c})}),e[2]=o,e[3]=d):d=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(h=u.jsx(nd,{size:16}),e[4]=h):h=e[4],e[5]!==r?(f=u.jsx(Ne,{content:"Add folder",children:u.jsx(ve,{"data-testid":"file-explorer-add-folder-button",onClick:r,variant:"text",size:"xs",children:h})}),e[5]=r,e[6]=f):f=e[6],e[7]!==a?(m=a({}),e[7]=a,e[8]=m):m=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(g=LL({variant:"text",size:"xs"}),x=u.jsx(zL,{size:16}),e[9]=g,e[10]=x):(g=e[9],x=e[10]),e[11]!==m?(p=u.jsx(Ne,{content:"Upload file",children:u.jsx("button",{"data-testid":"file-explorer-upload-button",...m,className:g,children:x})}),e[11]=m,e[12]=p):p=e[12],e[13]!==l?(b=l({}),e[13]=l,e[14]=b):b=e[14],e[15]!==b?(y=u.jsx("input",{...b,type:"file"}),e[15]=b,e[16]=y):y=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(v=u.jsx(NC,{size:16}),e[17]=v):v=e[17],e[18]!==n?(w=u.jsx(Ne,{content:"Refresh",children:u.jsx(ve,{"data-testid":"file-explorer-refresh-button",onClick:n,variant:"text",size:"xs",children:v})}),e[18]=n,e[19]=w):w=e[19],e[20]===Symbol.for("react.memo_cache_sentinel")?(S=u.jsx(bp,{size:16}),e[20]=S):S=e[20],e[21]!==s?(C=u.jsx(Ne,{content:"Collapse all folders",children:u.jsx(ve,{"data-testid":"file-explorer-collapse-button",onClick:s,variant:"text",size:"xs",children:S})}),e[21]=s,e[22]=C):C=e[22],e[23]!==y||e[24]!==w||e[25]!==C||e[26]!==d||e[27]!==f||e[28]!==p?(N=u.jsxs("div",{className:"flex items-center justify-end px-2 shrink-0 border-b",children:[d,f,p,y,w,C]}),e[23]=y,e[24]=w,e[25]=C,e[26]=d,e[27]=f,e[28]=p,e[29]=N):N=e[29],N},f9=t=>{const e=H.c(9),{node:n,onOpenMarimoFile:o}=t;let r,s,i;return e[0]!==n?(r=a=>{n.data.isDirectory||(a.stopPropagation(),n.select())},e[0]=n,e[1]=r):r=e[1],e[2]!==n.data.isMarimoFile||e[3]!==o?(s=n.data.isMarimoFile&&!tn()&&u.jsxs("span",{className:"shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:o,children:["open ",u.jsx(vc,{className:"inline ml-1",size:12})]}),e[2]=n.data.isMarimoFile,e[3]=o,e[4]=s):s=e[4],e[5]!==n.data.name||e[6]!==r||e[7]!==s?(i=u.jsxs("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:r,children:[n.data.name,s]}),e[5]=n.data.name,e[6]=r,e[7]=s,e[8]=i):i=e[8],i},m9=t=>{const e=H.c(10),{node:n}=t,o=M.useRef(null);let r,s,i,a,l;return e[0]!==n.data.name?(r=()=>{var c,d;(c=o.current)==null||c.focus(),(d=o.current)==null||d.setSelectionRange(0,n.data.name.lastIndexOf("."))},s=[n.data.name],e[0]=n.data.name,e[1]=r,e[2]=s):(r=e[1],s=e[2]),M.useEffect(r,s),e[3]!==n?(i=()=>n.reset(),a=c=>{c.key==="Escape"&&n.reset(),c.key==="Enter"&&n.submit(c.currentTarget.value)},e[3]=n,e[4]=i,e[5]=a):(i=e[4],a=e[5]),e[6]!==n.data.name||e[7]!==i||e[8]!==a?(l=u.jsx("input",{ref:o,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:n.data.name,onClick:y9,onBlur:i,onKeyDown:a}),e[6]=n.data.name,e[7]=i,e[8]=a,e[9]=l):l=e[9],l},p9=({node:t,style:e,dragHandle:n})=>{const{openFile:o,sendCreateFileOrFolder:r,sendFileDetails:s}=tt(),i=t.data.isDirectory?"directory":$3(t.data.name),a=V3[i],{openConfirm:l,openPrompt:c}=An(),{createNewCell:d}=lt(),h=ms(),f=M.use($k),m=async y=>{Vk(y,f?f.relativeFromRoot(t.data.path):t.data.path)},g=async y=>{y.stopPropagation(),y.preventDefault(),l({title:"Delete file",description:`Are you sure you want to delete ${t.data.name}?`,confirmAction:u.jsx(L3,{onClick:async()=>{await t.tree.delete(t.id)},"aria-label":"Confirm",children:"Delete"})})},x=Le(async()=>{t.open(),c({title:"Folder name",onConfirm:async y=>{f==null||f.createFolder(y,t.id)}})}),p=Le(async()=>{t.open(),c({title:"File name",onConfirm:async y=>{f==null||f.createFile(y,t.id)}})}),b=Le(async()=>{var S;if(!f||t.data.isDirectory)return;const[y,v]=FL(t.data.name),w=`${y}_copy${v}`;try{const C=await s({path:t.data.path}),N=((S=t.parent)==null?void 0:S.data.path)||"";await r({path:N,type:"file",name:w,contents:C.contents?btoa(C.contents):void 0}),await f.refreshAll([N])}catch{Je({title:"Failed to duplicate file",description:"Unable to create a duplicate of the file",variant:"danger"})}});return u.jsxs("div",{style:e,ref:n,className:xe("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),draggable:!0,onClick:y=>{y.stopPropagation(),t.data.isDirectory&&t.toggle()},children:[u.jsx(g9,{node:t}),u.jsxs("span",{className:xe("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",t.willReceiveDrop&&t.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground"),children:[t.data.isMarimoFile?u.jsx("img",{src:UF,className:"w-5 h-5 shrink-0 mr-2 filter grayscale",alt:"Marimo"}):u.jsx(a,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}),t.isEditing?u.jsx(m9,{node:t}):u.jsx(f9,{node:t,onOpenMarimoFile:m}),u.jsxs(Eo,{modal:!1,children:[u.jsx(_o,{asChild:!0,tabIndex:-1,onClick:y=>y.stopPropagation(),children:u.jsx(ve,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:u.jsx(td,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),(()=>{const y={size:14,strokeWidth:1.5,className:"mr-2"};return u.jsxs(Io,{align:"end",className:"no-print w-[220px]",onClick:v=>v.stopPropagation(),onCloseAutoFocus:v=>v.preventDefault(),children:[!t.data.isDirectory&&u.jsxs(At,{onSelect:()=>t.select(),children:[u.jsx(tg,{...y}),"Open file"]}),!t.data.isDirectory&&!tn()&&u.jsxs(At,{onSelect:()=>{o({path:t.data.path})},children:[u.jsx(vc,{...y}),"Open file in external editor"]}),t.data.isDirectory&&u.jsxs(u.Fragment,{children:[u.jsxs(At,{onSelect:()=>p(),children:[u.jsx(ba,{...y}),"Create file"]}),u.jsxs(At,{onSelect:()=>x(),children:[u.jsx(nd,{...y}),"Create folder"]}),u.jsx(an,{})]}),u.jsxs(At,{onSelect:()=>t.edit(),children:[u.jsx(Up,{...y}),"Rename"]}),!t.data.isDirectory&&u.jsxs(At,{onSelect:b,children:[u.jsx(Di,{...y}),"Duplicate"]}),u.jsxs(At,{onSelect:async()=>{await sn(t.data.path),Je({title:"Copied to clipboard"})},children:[u.jsx(sd,{...y}),"Copy path"]}),f&&u.jsxs(At,{onSelect:async()=>{await sn(f.relativeFromRoot(t.data.path)),Je({title:"Copied to clipboard"})},children:[u.jsx(sd,{...y}),"Copy relative path"]}),u.jsx(an,{}),u.jsxs(At,{onSelect:()=>{const{path:v}=t.data;(w=>{d({code:w,before:!1,cellId:h??"__end__"})})(tj[i](v))},children:[u.jsx(Nr,{...y}),"Insert snippet for reading file"]}),u.jsxs(At,{onSelect:async()=>{Je({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:v}=t.data,w=tj[i](v);await sn(w)},children:[u.jsx(BL,{...y}),"Copy snippet for reading file"]}),t.data.isMarimoFile&&!tn()&&u.jsxs(u.Fragment,{children:[u.jsx(an,{}),u.jsxs(At,{onSelect:m,children:[u.jsx(Xp,{...y}),"Open notebook"]})]}),u.jsx(an,{}),!t.data.isDirectory&&u.jsxs(u.Fragment,{children:[u.jsxs(At,{onSelect:async()=>{const v=(await s({path:t.data.path})).contents||"";Gi(new Blob([v]),t.data.name)},children:[u.jsx(jm,{...y}),"Download"]}),u.jsx(an,{})]}),u.jsxs(At,{onSelect:g,variant:"danger",children:[u.jsx(uc,{...y}),"Delete"]})]})})()]})]})]})},g9=t=>{const e=H.c(3),{node:n}=t;if(!n.data.isDirectory){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=u.jsx("span",{className:"w-5 h-5 shrink-0"}),e[0]=r):r=e[0],r}let o;return e[1]!==n.isOpen?(o=n.isOpen?u.jsx(No,{className:"w-5 h-5 shrink-0"}):u.jsx(zi,{className:"w-5 h-5 shrink-0"}),e[1]=n.isOpen,e[2]=o):o=e[2],o};function Vk(t,e){t.stopPropagation(),t.preventDefault(),dj(e)}function x9(){return null}function b9(t){const{parentNode:e}=t;return!e.data.isDirectory}function y9(t){return t.stopPropagation()}let Hk,Wk,qk;Hk=()=>{const t=H.c(20),{ref:e,height:n}=UL(),o=n===void 0?1:n;let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={noClick:!0,noKeyboard:!0},t[0]=r):r=t[0];const{getRootProps:s,getInputProps:i,isDragActive:a}=Uk(r);let l,c,d,h,f,m,g,x;return t[1]!==s?(l=s(),t[1]=s,t[2]=l):l=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(c=xe("flex flex-col flex-1 overflow-hidden relative"),t[3]=c):c=t[3],t[4]!==i?(d=i(),t[4]=i,t[5]=d):d=t[5],t[6]!==d?(h=u.jsx("input",{...d}),t[6]=d,t[7]=h):h=t[7],t[8]!==a?(f=a&&u.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"}),t[8]=a,t[9]=f):f=t[9],t[10]!==o?(m=u.jsx(d9,{height:o}),t[10]=o,t[11]=m):m=t[11],t[12]!==e||t[13]!==m?(g=u.jsx("div",{ref:e,className:"flex flex-col flex-1 overflow-hidden",children:m}),t[12]=e,t[13]=m,t[14]=g):g=t[14],t[15]!==l||t[16]!==h||t[17]!==f||t[18]!==g?(x=u.jsxs("div",{...l,className:c,children:[h,f,g]}),t[15]=l,t[16]=h,t[17]=f,t[18]=g,t[19]=x):x=t[19],x},hp=t=>{const e=H.c(6),n=t.dataTestId;let o,r;return e[0]!==t.className?(o=xe("text-xs font-semibold text-accent-foreground",t.className),e[0]=t.className,e[1]=o):o=e[1],e[2]!==t.dataTestId||e[3]!==t.onClick||e[4]!==o?(r=u.jsx("button",{type:"button","data-testid":n,className:o,onClick:t.onClick,children:"Clear"}),e[2]=t.dataTestId,e[3]=t.onClick,e[4]=o,e[5]=r):r=e[5],r},Wk=()=>{const t=H.c(9),e=$L(),{clearLogs:n}=lt();if(e.length===0){let i,a;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=u.jsx("code",{className:"border rounded px-1",children:"stdout"}),t[0]=i):i=t[0],t[1]===Symbol.for("react.memo_cache_sentinel")?(a=u.jsx(dn,{title:"No logs",description:u.jsxs("span",{children:[i," and"," ",u.jsx("code",{className:"border rounded px-1",children:"stderr"})," logs will appear here."]}),icon:u.jsx(dm,{})}),t[1]=a):a=t[1],a}let o,r,s;return t[2]!==n?(o=u.jsx("div",{className:"flex flex-row justify-end px-2 py-1",children:u.jsx(hp,{dataTestId:"clear-logs-button",onClick:n})}),t[2]=n,t[3]=o):o=t[3],t[4]!==e?(r=u.jsx("div",{className:"overflow-auto flex-1",children:u.jsx(qk,{logs:e,className:"min-w-[300px]"})}),t[4]=e,t[5]=r):r=t[5],t[6]!==o||t[7]!==r?(s=u.jsxs(u.Fragment,{children:[o,r]}),t[6]=o,t[7]=r,t[8]=s):s=t[8],s},qk=t=>{const e=H.c(10),{logs:n,className:o}=t;let r,s,i,a,l;return e[0]!==o?(r=xe("flex flex-col",o),e[0]=o,e[1]=r):r=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(s={whiteSpace:"pre-wrap"},e[2]=s):s=e[2],e[3]!==n?(i=n.map(k9),e[3]=n,e[4]=i):i=e[4],e[5]!==i?(a=u.jsx("pre",{className:"grid text-xs font-mono gap-1 whitespace-break-spaces font-semibold align-left",children:u.jsx("div",{className:"grid grid-cols-[30px_1fr]",style:s,children:i})}),e[5]=i,e[6]=a):a=e[6],e[7]!==r||e[8]!==a?(l=u.jsx("div",{className:r,children:a}),e[7]=r,e[8]=a,e[9]=l):l=e[9],l};function v9(t){const e=VL(t.timestamp),n=w9[t.level],o=t.level.toUpperCase();return u.jsxs(u.Fragment,{children:[u.jsxs("span",{className:"shrink-0 text-(--gray-10) dark:text-(--gray-11)",children:["[",e,"]"]}),u.jsx("span",{className:xe("shrink-0",n),children:o}),u.jsxs("span",{className:"shrink-0 text-(--gray-10)",children:["(",u.jsx(Mo,{cellId:t.cellId}),")"]}),t.message]})}const w9={stdout:"text-(--grass-9)",stderr:"text-(--red-9)"};function k9(t,e){return u.jsxs("div",{className:"contents group",children:[u.jsx("span",{className:xe("opacity-70 group-hover:bg-(--gray-3) group-hover:opacity-100","text-right col-span-1 py-1 pr-1"),children:e+1}),u.jsx("span",{className:xe("opacity-70 group-hover:bg-(--gray-3) group-hover:opacity-100","px-2 flex gap-x-1.5 py-1 flex-wrap"),children:v9(t)})]},e)}const C9=()=>{const t=H.c(7),{items:e}=je(HL);let n,o;t[0]!==e?(o=$F(e),t[0]=e,t[1]=o):o=t[1],n=o;const r=n,{activeHeaderId:s,activeOccurrences:i}=VF(r);if(e.length===0){let l;return t[2]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsx(dn,{title:"No outline-solid",description:"Add markdown headings to your notebook to create an outline.",icon:u.jsx(cd,{})}),t[2]=l):l=t[2],l}let a;return t[3]!==s||t[4]!==i||t[5]!==e?(a=u.jsx(HF,{items:e,activeHeaderId:s,activeOccurrences:i}),t[3]=s,t[4]=i,t[5]=e,t[6]=a):a=t[6],a},Gk=vt(null),Yk=t=>{const e=H.c(9),{onClick:n,loading:o,children:r,className:s}=t;if(o){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=u.jsx(kn,{size:"small",className:"h-4 w-4 shrink-0 opacity-50"}),e[0]=c):c=e[0],c}let i,a,l;return e[1]!==s?(i=xe("px-2 h-full text-xs text-muted-foreground hover:text-foreground","invisible group-hover:visible",s),e[1]=s,e[2]=i):i=e[2],e[3]!==n?(a=zn.stopPropagation(n),e[3]=n,e[4]=a):a=e[4],e[5]!==r||e[6]!==i||e[7]!==a?(l=u.jsx("button",{type:"button",className:i,onClick:a,children:r}),e[5]=r,e[6]=i,e[7]=a,e[8]=l):l=e[8],l},j9=()=>{var N,j;const t=H.c(30),[e]=br(),n=e.package_management.manager,{getDependencyTree:o,getPackageList:r}=tt(),[s,i]=q.useState(null);let a,l;t[0]!==o||t[1]!==r?(a=async()=>{const[E,T]=await Promise.all([r(),o()]);return{list:E.packages,tree:T.tree}},t[0]=o,t[1]=r,t[2]=a):a=t[2],t[3]!==n?(l=[n],t[3]=n,t[4]=l):l=t[4];const{data:c,error:d,refetch:h,isPending:f}=Tn(a,l);if(f){let E;return t[5]===Symbol.for("react.memo_cache_sentinel")?(E=u.jsx(kn,{size:"medium",centered:!0}),t[5]=E):E=t[5],E}if(d){let E;return t[6]!==d?(E=u.jsx(kr,{error:d}),t[6]=d,t[7]=E):E=t[7],E}const m=c.tree!=null;let g;t[8]!==m||t[9]!==s?(g=function(E,T){return E==="list"?"list":T?E||"tree":"list"}(s,m),t[8]=m,t[9]=s,t[10]=g):g=t[10];const x=g,p=(N=c.tree)==null?void 0:N.name,b=(j=c==null?void 0:c.tree)==null?void 0:j.version,y=p==="<root>";let v,w,S,C;return t[11]!==n||t[12]!==h?(v=u.jsx(S9,{packageManager:n,onSuccess:h}),t[11]=n,t[12]=h,t[13]=v):v=t[13],t[14]!==y||t[15]!==m||t[16]!==p||t[17]!==b||t[18]!==x?(w=m&&u.jsxs("div",{className:"flex items-center justify-between px-2 py-1 border-b",children:[u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{type:"button",className:xe("px-2 py-1 text-xs rounded",x==="list"?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i("list"),children:"List"}),u.jsx("button",{type:"button",className:xe("px-2 py-1 text-xs rounded",x==="tree"?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i("tree"),children:"Tree"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"items-center border px-2 py-0.5 text-xs transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 text-foreground rounded-sm text-ellipsis block overflow-hidden max-w-fit font-medium",title:y?"sandbox":"project",children:y?"sandbox":"project"}),p&&!y&&u.jsxs("span",{className:"text-xs text-muted-foreground",children:[p,b&&` v${b}`]})]})]}),t[14]=y,t[15]=m,t[16]=p,t[17]=b,t[18]=x,t[19]=w):w=t[19],t[20]!==c.list||t[21]!==c.tree||t[22]!==d||t[23]!==h||t[24]!==x?(S=x==="list"?u.jsx(N9,{packages:c.list,onSuccess:h}):u.jsx(E9,{tree:c.tree,error:d,onSuccess:h}),t[20]=c.list,t[21]=c.tree,t[22]=d,t[23]=h,t[24]=x,t[25]=S):S=t[25],t[26]!==v||t[27]!==w||t[28]!==S?(C=u.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[v,w,S]}),t[26]=v,t[27]=w,t[28]=S,t[29]=C):C=t[29],C},S9=t=>{const e=H.c(40),{onSuccess:n,packageManager:o}=t,[r,s]=q.useState(""),{handleClick:i}=fa(),a=je(Gk),l=jt(Gk);let c,d;e[0]!==a||e[1]!==l?(c=()=>{a&&(s(a),l(null))},d=[a,l],e[0]=a,e[1]=l,e[2]=c,e[3]=d):(c=e[2],d=e[3]),q.useEffect(c,d);const{loading:h,handleInstallPackages:f}=WL();let m;e[4]!==n?(m=()=>{n(),s("")},e[4]=n,e[5]=m):m=e[5];const g=m;let x;e[6]!==f||e[7]!==r||e[8]!==g?(x=()=>{f(r.split(",").map(_9),g)},e[6]=f,e[7]=r,e[8]=g,e[9]=x):x=e[9];const p=x,b=`Install packages with ${o}...`;let y,v,w,S,C,N,j,E,T,I,O,L,D,R;e[10]!==h||e[11]!==i?(y=h?u.jsx(kn,{size:"small",className:"mr-2 h-4 w-4 shrink-0 opacity-50"}):u.jsx(Ne,{content:"Change package manager",children:u.jsx(Es,{onClick:()=>i("packageManagement"),className:"mr-2 h-4 w-4 shrink-0 opacity-50 hover:opacity-80 cursor-pointer"})}),e[10]=h,e[11]=i,e[12]=y):y=e[12],e[13]!==p?(v=A=>{A.key==="Enter"&&(A.preventDefault(),p())},e[13]=p,e[14]=v):v=e[14],e[15]===Symbol.for("react.memo_cache_sentinel")?(w=A=>s(A.target.value),e[15]=w):w=e[15],e[16]!==r||e[17]!==b||e[18]!==y||e[19]!==v?(S=u.jsx(nj,{placeholder:b,id:L1,icon:y,rootClassName:"flex-1 border-none",value:r,onKeyDown:v,onChange:w}),e[16]=r,e[17]=b,e[18]=y,e[19]=v,e[20]=S):S=e[20],e[21]===Symbol.for("react.memo_cache_sentinel")?(C=u.jsx("span",{className:"font-bold tracking-wide",children:"Package name:"}),e[21]=C):C=e[21],e[22]===Symbol.for("react.memo_cache_sentinel")?(N=u.jsxs("div",{children:[C," A package name; this will install the latest version.",u.jsx("div",{className:"text-muted-foreground",children:"Example: httpx"})]}),j=u.jsx("span",{className:"font-bold tracking-wide",children:"Package and version:"}),e[22]=N,e[23]=j):(N=e[22],j=e[23]),e[24]===Symbol.for("react.memo_cache_sentinel")?(E=u.jsxs("div",{children:[j," ","A package with a specific version or version range.",u.jsx("div",{className:"text-muted-foreground",children:"Examples: httpx==0.27.0, httpx>=0.27.0"})]}),T=u.jsx("span",{className:"font-bold tracking-wide",children:"Git:"}),e[24]=E,e[25]=T):(E=e[24],T=e[25]),e[26]===Symbol.for("react.memo_cache_sentinel")?(I=u.jsxs("div",{children:[T," A Git repository",u.jsx("div",{className:"text-muted-foreground",children:"Example: git+https://github.com/encode/httpx"})]}),O=u.jsx("span",{className:"font-bold tracking-wide",children:"URL:"}),e[26]=I,e[27]=O):(I=e[26],O=e[27]),e[28]===Symbol.for("react.memo_cache_sentinel")?(L=u.jsxs("div",{children:[O," A remote wheel or source distribution.",u.jsx("div",{className:"text-muted-foreground",children:"Example: https://example.com/httpx-0.27.0.tar.gz"})]}),D=u.jsx("span",{className:"font-bold tracking-wide",children:"Path:"}),e[28]=L,e[29]=D):(L=e[28],D=e[29]),e[30]===Symbol.for("react.memo_cache_sentinel")?(R=u.jsx(Ne,{delayDuration:300,side:"left",align:"start",content:u.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:",u.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[N,E,I,L,u.jsxs("div",{children:[D," A local wheel, source distribution, or project directory.",u.jsx("div",{className:"text-muted-foreground",children:"Example: /example/foo-0.1.0-py3-none-any.whl"})]})]})]}),children:u.jsx(Ym,{className:"h-4 w-4 cursor-help text-muted-foreground hover:text-foreground bg-transparent"})}),e[30]=R):R=e[30];const P=r&&"bg-accent text-accent-foreground";let z;e[31]!==P?(z=xe("float-right px-2 m-0 h-full text-sm text-secondary-foreground ml-2",P,"disabled:cursor-not-allowed disabled:opacity-50"),e[31]=P,e[32]=z):z=e[32];const _=!r;let k,B;return e[33]!==p||e[34]!==z||e[35]!==_?(k=u.jsx("button",{type:"button",className:z,onClick:p,disabled:_,children:"Add"}),e[33]=p,e[34]=z,e[35]=_,e[36]=k):k=e[36],e[37]!==k||e[38]!==S?(B=u.jsxs("div",{className:"flex items-center w-full border-b",children:[S,R,k]}),e[37]=k,e[38]=S,e[39]=B):B=e[39],B},N9=t=>{const e=H.c(9),{onSuccess:n,packages:o}=t;if(o.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=u.jsx(dn,{title:"No packages",description:"No packages are installed in this environment.",icon:u.jsx(Es,{})}),e[0]=a):a=e[0],a}let r,s,i;if(e[1]===Symbol.for("react.memo_cache_sentinel")?(r=u.jsx(tp,{children:u.jsxs(Ns,{children:[u.jsx(Cr,{children:"Name"}),u.jsx(Cr,{children:"Version"}),u.jsx(Cr,{})]})}),e[1]=r):r=e[1],e[2]!==n||e[3]!==o){let a;e[5]!==n?(a=l=>u.jsxs(Ns,{className:"group",onClick:async()=>{await sn(`${l.name}==${l.version}`),Je({title:"Copied to clipboard"})},children:[u.jsx(jr,{children:l.name}),u.jsx(jr,{children:l.version}),u.jsxs(jr,{className:"flex justify-end",children:[u.jsx(Kk,{packageName:l.name,onSuccess:n}),u.jsx(Xk,{packageName:l.name,onSuccess:n})]})]},l.name),e[5]=n,e[6]=a):a=e[6],s=o.map(a),e[2]=n,e[3]=o,e[4]=s}else s=e[4];return e[7]!==s?(i=u.jsxs(np,{className:"overflow-auto flex-1",children:[r,u.jsx(op,{children:s})]}),e[7]=s,e[8]=i):i=e[8],i},Kk=({packageName:t,onSuccess:e})=>{const[n,o]=q.useState(!1),{addPackage:r}=tt();return tn()?null:u.jsx(Yk,{onClick:async()=>{try{o(!0);const s=await r({package:t,upgrade:!0});s.success?(e(),oj(t)):oj(t,s.error)}finally{o(!1)}},loading:n,children:"Upgrade"})},Xk=({packageName:t,onSuccess:e})=>{const[n,o]=q.useState(!1),{removePackage:r}=tt();return u.jsx(Yk,{onClick:async()=>{try{o(!0);const s=await r({package:t});s.success?(e(),rj(t)):rj(t,s.error)}finally{o(!1)}},loading:n,children:"Remove"})},E9=t=>{const e=H.c(18),{tree:n,error:o,onSuccess:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=new Set,e[0]=s):s=e[0];const[i,a]=q.useState(s);let l,c,d;if(e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{a(new Set)},e[1]=l):l=e[1],e[2]!==n?(c=[n],e[2]=n,e[3]=c):c=e[3],q.useEffect(l,c),o){let g;return e[4]!==o?(g=u.jsx(kr,{error:o}),e[4]=o,e[5]=g):g=e[5],g}if(!n){let g;return e[6]===Symbol.for("react.memo_cache_sentinel")?(g=u.jsx(kn,{size:"medium",centered:!0}),e[6]=g):g=e[6],g}if(n.dependencies.length===0){let g;return e[7]===Symbol.for("react.memo_cache_sentinel")?(g=u.jsx(dn,{title:"No dependencies",description:"No package dependencies found in this environment.",icon:u.jsx(Es,{})}),e[7]=g):g=e[7],g}e[8]===Symbol.for("react.memo_cache_sentinel")?(d=g=>{a(x=>{const p=new Set(x);return p.has(g)?p.delete(g):p.add(g),p})},e[8]=d):d=e[8];const h=d;let f,m;if(e[9]!==i||e[10]!==r||e[11]!==n.dependencies){let g;e[13]!==i||e[14]!==r?(g=(x,p)=>u.jsx("div",{className:"border-b",children:u.jsx(Jk,{nodeId:`root-${p}`,node:x,level:0,isTopLevel:!0,expandedNodes:i,onToggle:h,onSuccess:r})},`${x.name}-${p}`),e[13]=i,e[14]=r,e[15]=g):g=e[15],f=n.dependencies.map(g),e[9]=i,e[10]=r,e[11]=n.dependencies,e[12]=f}else f=e[12];return e[16]!==f?(m=u.jsx("div",{className:"flex-1 overflow-auto",children:u.jsx("div",{children:f})}),e[16]=f,e[17]=m):m=e[17],m},Jk=t=>{const e=H.c(57),{nodeId:n,node:o,level:r,isTopLevel:s,expandedNodes:i,onToggle:a,onSuccess:l}=t,c=s!==void 0&&s,d=o.dependencies.length>0;let h;e[0]!==i||e[1]!==n?(h=i.has(n),e[0]=i,e[1]=n,e[2]=h):h=e[2];const f=h,m=c?0:16+16*r;let g;e[3]!==d||e[4]!==n||e[5]!==a?(g=z=>{z.key!=="Enter"&&z.key!==" "||(z.preventDefault(),d&&a(n))},e[3]=d,e[4]=n,e[5]=a,e[6]=g):g=e[6];const x=g;let p;e[7]!==d||e[8]!==n||e[9]!==a?(p=z=>{z.stopPropagation(),d&&a(n)},e[7]=d,e[8]=n,e[9]=a,e[10]=p):p=e[10];const b=p,y=d&&"select-none",v=c?"px-2 py-0.5":"";let w,S;e[11]!==y||e[12]!==v?(w=xe("flex items-center group cursor-pointer text-sm whitespace-nowrap","hover:bg-(--slate-2) focus:bg-(--slate-2) focus:outline-hidden",y,v),e[11]=y,e[12]=v,e[13]=w):w=e[13],e[14]!==m||e[15]!==c?(S=c?{}:{paddingLeft:`${m}px`},e[14]=m,e[15]=c,e[16]=S):S=e[16];const C=d?f:void 0;let N,j,E,T,I,O,L,D,R,P;return e[17]!==d||e[18]!==f?(N=d?f?u.jsx(No,{className:"w-4 h-4 mr-2 shrink-0"}):u.jsx(zi,{className:"w-4 h-4 mr-2 shrink-0"}):u.jsx("div",{className:"w-4 mr-2 shrink-0"}),e[17]=d,e[18]=f,e[19]=N):N=e[19],e[20]!==o.name?(j=u.jsx("span",{className:"font-medium truncate",children:o.name}),e[20]=o.name,e[21]=j):j=e[21],e[22]!==o.version?(E=o.version&&u.jsxs("span",{className:"text-muted-foreground text-xs",children:["v",o.version]}),e[22]=o.version,e[23]=E):E=e[23],e[24]!==j||e[25]!==E?(T=u.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 py-1.5",children:[j,E]}),e[24]=j,e[25]=E,e[26]=T):T=e[26],e[27]!==o.tags?(I=o.tags.map(I9),e[27]=o.tags,e[28]=I):I=e[28],e[29]!==I?(O=u.jsx("div",{className:"flex items-center gap-1 ml-2",children:I}),e[29]=I,e[30]=O):O=e[30],e[31]!==c||e[32]!==o.name||e[33]!==l?(L=c&&u.jsxs("div",{className:"flex gap-1 invisible group-hover:visible",children:[u.jsx(Kk,{packageName:o.name,onSuccess:l}),u.jsx(Xk,{packageName:o.name,onSuccess:l})]}),e[31]=c,e[32]=o.name,e[33]=l,e[34]=L):L=e[34],e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==T||e[39]!==O||e[40]!==L||e[41]!==w||e[42]!==S||e[43]!==C?(D=u.jsxs("div",{className:w,style:S,onClick:b,onKeyDown:x,tabIndex:0,role:"treeitem","aria-selected":!1,"aria-expanded":C,children:[N,T,O,L]}),e[35]=b,e[36]=x,e[37]=N,e[38]=T,e[39]=O,e[40]=L,e[41]=w,e[42]=S,e[43]=C,e[44]=D):D=e[44],e[45]!==i||e[46]!==d||e[47]!==f||e[48]!==r||e[49]!==o.dependencies||e[50]!==n||e[51]!==l||e[52]!==a?(R=d&&f&&u.jsx("div",{role:"group",children:o.dependencies.map((z,_)=>u.jsx(Jk,{nodeId:`${n}-${_}`,node:z,level:r+1,isTopLevel:!1,expandedNodes:i,onToggle:a,onSuccess:l},`${z.name}-${_}`))}),e[45]=i,e[46]=d,e[47]=f,e[48]=r,e[49]=o.dependencies,e[50]=n,e[51]=l,e[52]=a,e[53]=R):R=e[53],e[54]!==D||e[55]!==R?(P=u.jsxs("div",{children:[D,R]}),e[54]=D,e[55]=R,e[56]=P):P=e[56],P};function _9(t){return t.trim()}function I9(t,e){return t.kind==="cycle"?u.jsx("div",{className:"items-center border px-2 py-0.5 text-xs transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 text-foreground rounded-sm text-ellipsis block overflow-hidden max-w-fit font-medium border-orange-300 dark:border-orange-700 text-orange-700 dark:text-orange-300",title:"cycle",children:"cycle"},e):t.kind==="extra"?u.jsx("div",{className:"items-center border px-2 py-0.5 text-xs transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 text-foreground rounded-sm text-ellipsis block overflow-hidden max-w-fit font-medium border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300",title:t.value,children:t.value},e):t.kind==="group"?u.jsx("div",{className:"items-center border px-2 py-0.5 text-xs transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 text-foreground rounded-sm text-ellipsis block overflow-hidden max-w-fit font-medium border-green-300 dark:border-green-700 text-green-700 dark:text-green-300",title:t.value,children:t.value},e):null}const rm=b3("marimo:scratchpadHistory:v1",[]),A9=vt(!1),T9=vt(null,(t,e,n)=>{if(!(n=n.trim()))return;const o=t(rm),r=[n,...o.filter(s=>s!==n)].slice(0,15);e(rm,r)}),M9={hide_code:!1,disabled:!1},O9=()=>{const t=H.c(71),e=Tm(),[n]=br(),{theme:o}=Zo(),r=M.useRef(null),s=ms(),{createNewCell:i,updateCellCode:a}=lt(),{sendRunScratchpad:l}=tt(),c=e.cellRuntime[Qo],d=c==null?void 0:c.output,h=c==null?void 0:c.status,f=c==null?void 0:c.consoleOutputs,m=e.cellData[Qo],g=(m==null?void 0:m.code)??"",x=jt(T9),[p,b]=Dt(A9),y=je(rm);let v;t[0]!==x||t[1]!==g||t[2]!==l?(v=()=>{l({code:g}),x(g)},t[0]=x,t[1]=g,t[2]=l,t[3]=v):v=t[3];const w=Le(v);let S;t[4]!==g||t[5]!==i||t[6]!==s?(S=()=>{g.trim()&&i({code:g,before:!1,cellId:s??"__end__"})},t[4]=g,t[5]=i,t[6]=s,t[7]=S):S=t[7];const C=Le(S);let N;t[8]!==l||t[9]!==a?(N=()=>{a({cellId:Qo,code:"",formattingChange:!1}),l({code:""});const ue=r.current;ue&&ue.dispatch({changes:{from:0,to:ue.state.doc.length,insert:""}})},t[8]=l,t[9]=a,t[10]=N):N=t[10];const j=Le(N);let E;t[11]!==b||t[12]!==a?(E=ue=>{b(!1),a({cellId:Qo,code:ue,formattingChange:!1});const de=r.current;de&&de.dispatch({changes:{from:0,to:de.state.doc.length,insert:ue}})},t[11]=b,t[12]=a,t[13]=E):E=t[13];const T=Le(E),[I,O]=M.useState();let L;t[14]!==g||t[15]!==f||t[16]!==w||t[17]!==I||t[18]!==d||t[19]!==o||t[20]!==n?(L=()=>u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"overflow-auto shrink-0 max-h-[40%]",children:u.jsx(Fu,{theme:o,showPlaceholder:!1,id:Qo,code:g,config:M9,status:"idle",serializedEditorState:null,runCell:w,userConfig:n,editorViewRef:r,setEditorView:ue=>{r.current=ue},hidden:!1,showHiddenCode:Bn.NOOP,languageAdapter:I,setLanguageAdapter:O})}),u.jsx("div",{className:"flex-1 overflow-auto shrink-0",children:u.jsx($c,{allowExpand:!1,output:d,className:"output-area",cellId:Qo,stale:!1,loading:!1})}),u.jsx("div",{className:"overflow-auto shrink-0 max-h-[35%]",children:u.jsx(lp,{consoleOutputs:f,className:"overflow-auto",stale:!1,cellName:y3,onSubmitDebugger:Bn.NOOP,cellId:Qo,debuggerActive:!1})})]}),t[14]=g,t[15]=f,t[16]=w,t[17]=I,t[18]=d,t[19]=o,t[20]=n,t[21]=L):L=t[21];const D=L;let R;t[22]!==T||t[23]!==y||t[24]!==p||t[25]!==o?(R=()=>p?u.jsx("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:u.jsx("div",{className:"overflow-auto flex flex-col gap-3",children:y.map((ue,de)=>u.jsx("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>T(ue),children:u.jsx(M.Suspense,{children:u.jsx(ua,{language:"python",theme:o,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:ue.trim(),editable:!1,readOnly:!0})})},de))})}):null,t[22]=T,t[23]=y,t[24]=p,t[25]=o,t[26]=R):R=t[26];const P=R;let z,_,k,B,A,U,$,X,Y,G,W;t[27]===Symbol.for("react.memo_cache_sentinel")?(z=Ri.create(Qo),_=u.jsx("p",{className:"mx-2 my-2 text-muted-foreground text-sm",children:"Use this scratchpad cell to experiment with code without restrictions on variable names. Scratchpad code is ephemeral: variables defined in the scratchpad aren't saved to notebook memory, and the code is not saved in the notebook file."}),t[27]=z,t[28]=_):(z=t[27],_=t[28]),t[29]===Symbol.for("react.memo_cache_sentinel")?(k=Gt("cell.run"),t[29]=k):k=t[29],t[30]===Symbol.for("react.memo_cache_sentinel")?(B=u.jsx(Sr,{color:"var(--grass-11)",size:16}),t[30]=B):B=t[30],t[31]!==w||t[32]!==p?(A=u.jsx(Ne,{content:k,children:u.jsx(ve,{"data-testid":"scratchpad-run-button",onClick:w,disabled:p,variant:"text",size:"xs",children:B})}),t[31]=w,t[32]=p,t[33]=A):A=t[33],t[34]===Symbol.for("react.memo_cache_sentinel")?(U=u.jsx(vp,{size:16}),t[34]=U):U=t[34],t[35]!==j||t[36]!==p?($=u.jsx(Ne,{content:"Clear code and outputs",children:u.jsx(ve,{disabled:p,size:"xs",variant:"text",onClick:j,children:U})}),t[35]=j,t[36]=p,t[37]=$):$=t[37],t[38]===Symbol.for("react.memo_cache_sentinel")?(X=u.jsx(Nr,{size:16}),t[38]=X):X=t[38],t[39]!==C||t[40]!==p?(Y=u.jsx(Ls,{children:u.jsx(Ne,{content:"Insert code",children:u.jsx(ve,{disabled:p,size:"xs",variant:"text",onClick:C,children:X})})}),t[39]=C,t[40]=p,t[41]=Y):Y=t[41],t[42]!==h?(G=(h==="running"||h==="queued")&&u.jsx(kn,{className:"inline",size:"small"}),t[42]=h,t[43]=G):G=t[43],t[44]===Symbol.for("react.memo_cache_sentinel")?(W=u.jsx("div",{className:"flex-1"}),t[44]=W):W=t[44];const J=p&&"bg-(--sky-3) rounded-none";let V,Q;t[45]!==J?(V=xe(J),t[45]=J,t[46]=V):V=t[46],t[47]!==p||t[48]!==b?(Q=()=>b(!p),t[47]=p,t[48]=b,t[49]=Q):Q=t[49];const te=y.length===0;let re,ne,ie,se,ae,ge,oe;return t[50]===Symbol.for("react.memo_cache_sentinel")?(re=u.jsx(Ep,{size:16}),t[50]=re):re=t[50],t[51]!==V||t[52]!==Q||t[53]!==te?(ne=u.jsx(Ne,{content:"Toggle history",children:u.jsx(ve,{size:"xs",variant:"text",className:V,onClick:Q,disabled:te,children:re})}),t[51]=V,t[52]=Q,t[53]=te,t[54]=ne):ne=t[54],t[55]!==A||t[56]!==$||t[57]!==Y||t[58]!==G||t[59]!==ne?(ie=u.jsxs("div",{className:"flex items-center shrink-0",children:[A,$,Y,G,W,ne]}),t[55]=A,t[56]=$,t[57]=Y,t[58]=G,t[59]=ne,t[60]=ie):ie=t[60],t[61]!==D?(se=D(),t[61]=D,t[62]=se):se=t[62],t[63]!==P?(ae=P(),t[63]=P,t[64]=ae):ae=t[64],t[65]!==se||t[66]!==ae?(ge=u.jsxs("div",{className:"flex-1 divide-y relative overflow-hidden flex flex-col",children:[se,ae]}),t[65]=se,t[66]=ae,t[67]=ge):ge=t[67],t[68]!==ie||t[69]!==ge?(oe=u.jsxs("div",{className:"flex flex-col h-full overflow-hidden divide-y",id:z,children:[_,ie,ge]}),t[68]=ie,t[69]=ge,t[70]=oe):oe=t[70],oe},D9=()=>{const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=u.jsx(O9,{}),t[0]=e):e=t[0],e},R9=()=>{const t=H.c(23),{openModal:e,closeModal:n}=An();let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],t[0]=o):o=t[0];const{data:r,isPending:s,error:i,refetch:a}=Tn(L9,o);if(s){let b;return t[1]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(kn,{size:"medium",centered:!0}),t[1]=b):b=t[1],b}if(i){let b;return t[2]!==i?(b=u.jsx(kr,{error:i}),t[2]=i,t[3]=b):b=t[3],b}let l;t[4]!==r?(l=r.filter(F9).map(z9),t[4]=r,t[5]=l):l=t[5];const c=l;if(r.length===0){let b;return t[6]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(dn,{title:"No environment variables",description:"No environment variables are available in this notebook.",icon:u.jsx(od,{})}),t[6]=b):b=t[6],b}let d,h,f,m,g,x,p;return t[7]!==n||t[8]!==e||t[9]!==c||t[10]!==a?(d=()=>e(u.jsx(Ig,{providerNames:c,onSuccess:()=>{a(),n()},onClose:n})),t[7]=n,t[8]=e,t[9]=c,t[10]=a,t[11]=d):d=t[11],t[12]===Symbol.for("react.memo_cache_sentinel")?(h=u.jsx(Jo,{className:"h-4 w-4"}),t[12]=h):h=t[12],t[13]!==d?(f=u.jsx("div",{className:"flex justify-end h-8 border-b",children:u.jsx("button",{type:"button",className:"float-right border-l px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:d,children:h})}),t[13]=d,t[14]=f):f=t[14],t[15]===Symbol.for("react.memo_cache_sentinel")?(m=u.jsx(tp,{children:u.jsxs(Ns,{children:[u.jsx(Cr,{children:"Environment Variable"}),u.jsx(Cr,{children:"Source"}),u.jsx(Cr,{})]})}),t[15]=m):m=t[15],t[16]!==r?(g=r.map(B9),t[16]=r,t[17]=g):g=t[17],t[18]!==g?(x=u.jsxs(np,{className:"overflow-auto flex-1 mb-16",children:[m,u.jsx(op,{children:g})]}),t[18]=g,t[19]=x):x=t[19],t[20]!==f||t[21]!==x?(p=u.jsxs("div",{className:"flex flex-col h-full",children:[f,x]}),t[20]=f,t[21]=x,t[22]=p):p=t[22],p},P9=t=>{const e=H.c(9),{className:n,ariaLabel:o,onCopy:r}=t,[s,i]=q.useState(!1);let a;e[0]!==r?(a=()=>{r(),i(!0),setTimeout(()=>i(!1),1e3)},e[0]=r,e[1]=a):a=e[1];const l=a;let c,d;return e[2]!==s?(c=s?u.jsx(yc,{className:"w-3 h-3 text-green-700 rounded"}):u.jsx(Di,{className:"w-3 h-3 hover:bg-muted rounded"}),e[2]=s,e[3]=c):c=e[3],e[4]!==o||e[5]!==n||e[6]!==l||e[7]!==c?(d=u.jsx("button",{type:"button",className:n,onClick:l,"aria-label":o,children:c}),e[4]=o,e[5]=n,e[6]=l,e[7]=c,e[8]=d):d=e[8],d};async function L9(){return _g((await xj.request({})).secrets)}function F9(t){return t.provider!=="env"}function z9(t){return t.name}function B9(t){return t.keys.map(e=>u.jsxs(Ns,{className:"group",children:[u.jsx(jr,{children:e}),u.jsx(jr,{children:t.provider!=="env"&&u.jsx(VC,{variant:"outline",className:"select-none",children:t.name})}),u.jsx(jr,{children:u.jsx(P9,{ariaLabel:`Copy ${e}`,onCopy:async()=>{await sn(`os.environ["${e}"]`),Je({title:"Copied to clipboard",description:`os.environ["${e}"] has been copied to your clipboard.`})},className:xe("float-right px-2 h-full text-xs text-muted-foreground hover:text-foreground","invisible group-hover:visible")})})]},`${t.name}-${e}`))}const U9=t=>{const e=H.c(6),{children:n}=t,{openModal:o,closeModal:r}=An();let s,i;return e[0]!==r||e[1]!==o?(s=()=>o(u.jsx(V9,{onClose:r})),e[0]=r,e[1]=o,e[2]=s):s=e[2],e[3]!==n||e[4]!==s?(i=u.jsx(RC,{onClick:s,children:n}),e[3]=n,e[4]=s,e[5]=i):i=e[5],i},$9=[We.lineWrapping],V9=t=>{const e=H.c(23),{onClose:n}=t,[o,r]=M.useState(""),{theme:s}=Zo();let i,a,l,c,d,h;e[0]!==n?(i=async v=>{v.preventDefault();const w=new FormData(v.target),S=w.get("title"),C=w.get("description"),N=w.get("code");fetch("https://marimo.io/api/suggest-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:S,description:C,code:N})}),n(),Je({title:"Snippet Submitted",description:"Thank you for contributing! We will review your snippet shortly."})},e[0]=n,e[1]=i):i=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(a=u.jsx(Wo,{children:"Contribute a Snippet"}),e[2]=a):a=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(l=u.jsxs(cs,{children:[a,u.jsxs(ds,{children:["Have a useful snippet you want to share with the community? Submit it here or make a pull request"," ",u.jsx("a",{href:Fn.githubPage,target:"_blank",className:"underline",children:"on GitHub"}),"."]})]}),e[3]=l):l=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(c=u.jsx(qo,{id:"title",name:"title",autoFocus:!0,placeholder:"Title",required:!0,autoComplete:"off"}),d=u.jsx(qL,{id:"description",name:"description",autoFocus:!0,placeholder:"Description",rows:5,required:!0,autoComplete:"off"}),e[4]=c,e[5]=d):(c=e[4],d=e[5]),e[6]!==o?(h=u.jsx("input",{type:"hidden",name:"code",value:o}),e[6]=o,e[7]=h):h=e[7];const f=s==="dark"?"dark":"light";let m,g,x,p,b,y;return e[8]!==o||e[9]!==f?(m=u.jsx(ua,{theme:f,language:"python",className:"cm border rounded overflow-hidden",extensions:$9,value:o,onChange:r}),e[8]=o,e[9]=f,e[10]=m):m=e[10],e[11]!==h||e[12]!==m?(g=u.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[c,d,h,m]}),e[11]=h,e[12]=m,e[13]=g):g=e[13],e[14]!==n?(x=u.jsx(ve,{"data-testid":"snippet-cancel-button",variant:"secondary",onClick:n,children:"Cancel"}),e[14]=n,e[15]=x):x=e[15],e[16]===Symbol.for("react.memo_cache_sentinel")?(p=u.jsx(ve,{"data-testid":"snippet-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"}),e[16]=p):p=e[16],e[17]!==x?(b=u.jsxs(Oi,{children:[x,p]}),e[17]=x,e[18]=b):b=e[18],e[19]!==i||e[20]!==b||e[21]!==g?(y=u.jsx(Go,{className:"w-fit",children:u.jsxs("form",{onSubmit:i,children:[l,g,b]})}),e[19]=i,e[20]=b,e[21]=g,e[22]=y):y=e[22],y},H9=[We.lineWrapping],W9=()=>{const t=H.c(22),{readSnippets:e}=tt(),[n,o]=q.useState();let r,s;t[0]!==e?(r=()=>e(),t[0]=e,t[1]=r):r=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(s=[],t[2]=s):s=t[2];const{data:i,error:a,isPending:l}=Tn(r,s);if(a){let v;return t[3]!==a?(v=u.jsx(kr,{error:a}),t[3]=a,t[4]=v):v=t[4],v}if(l||!i){let v;return t[5]===Symbol.for("react.memo_cache_sentinel")?(v=u.jsx(kn,{size:"medium",centered:!0}),t[5]=v):v=t[5],v}const c=n?"h-1/3":"h-full";let d,h,f,m,g,x,p,b,y;return t[6]!==c?(d=xe("border-b rounded-none",c),t[6]=c,t[7]=d):d=t[7],t[8]===Symbol.for("react.memo_cache_sentinel")?(h=u.jsx(Bi,{placeholder:"Search snippets...",className:"h-6 m-1",rootClassName:"flex-1 border-r"}),t[8]=h):h=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(f=u.jsxs("div",{className:"flex items-center w-full",children:[h,u.jsx(U9,{children:u.jsx("button",{className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:u.jsx(Jo,{className:"h-4 w-4"})})})]}),m=u.jsx(mc,{children:"No results"}),t[9]=f,t[10]=m):(f=t[9],m=t[10]),t[11]===Symbol.for("react.memo_cache_sentinel")?(g=v=>o(v),t[11]=g):g=t[11],t[12]!==i.snippets?(x=u.jsx(G9,{onSelect:g,snippets:i.snippets}),t[12]=i.snippets,t[13]=x):x=t[13],t[14]!==d||t[15]!==x?(p=u.jsxs(kc,{className:d,children:[f,m,x]}),t[14]=d,t[15]=x,t[16]=p):p=t[16],t[17]!==n?(b=u.jsx(M.Suspense,{children:u.jsx("div",{className:"h-2/3 snippet-viewer flex flex-col",children:n?u.jsx(q9,{snippet:n,onClose:()=>o(void 0)},n.title):u.jsx(dn,{title:"",description:"Click on a snippet to view its content."})})}),t[17]=n,t[18]=b):b=t[18],t[19]!==b||t[20]!==p?(y=u.jsxs("div",{className:"flex-1 overflow-hidden",children:[p,b]}),t[19]=b,t[20]=p,t[21]=y):y=t[21],y},q9=t=>{const e=H.c(33),{snippet:n,onClose:o}=t,{theme:r}=Zo(),{createNewCell:s}=lt(),i=ms();let a;e[0]!==s||e[1]!==i||e[2]!==n.sections?(a=()=>{for(const w of[...n.sections].reverse())w.code&&s({code:w.code,before:!1,cellId:i??"__end__",skipIfCodeExists:!0})},e[0]=s,e[1]=i,e[2]=n.sections,e[3]=a):a=e[3];const l=a;let c;e[4]!==s||e[5]!==i?(c=w=>{s({code:w,before:!1,cellId:i??"__end__"})},e[4]=s,e[5]=i,e[6]=c):c=e[6];const d=c;let h,f,m,g,x,p,b,y,v;if(e[7]!==n.title?(h=u.jsx("span",{children:n.title}),e[7]=n.title,e[8]=h):h=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(f=u.jsx(wn,{className:"h-4 w-4"}),e[9]=f):f=e[9],e[10]!==o?(m=u.jsx(ve,{size:"sm",variant:"ghost",onClick:o,className:"h-6 w-6 p-0 hover:bg-muted-foreground/10",children:f}),e[10]=o,e[11]=m):m=e[11],e[12]!==h||e[13]!==m?(g=u.jsxs("div",{className:"text-sm font-semibold bg-muted border-y px-2 py-1 flex justify-between items-center",children:[h,m]}),e[12]=h,e[13]=m,e[14]=g):g=e[14],e[15]===Symbol.for("react.memo_cache_sentinel")?(x=u.jsx(Nr,{className:"ml-2 h-4 w-4"}),e[15]=x):x=e[15],e[16]!==l?(p=u.jsx("div",{className:"flex justify-end",children:u.jsx(Ls,{children:u.jsxs(ve,{className:"float-right",size:"xs",variant:"outline",onClick:l,children:["Insert snippet",x]})})}),e[16]=l,e[17]=p):p=e[17],e[18]!==d||e[19]!==n.sections||e[20]!==n.title||e[21]!==r){let w;e[23]!==d||e[24]!==n.title||e[25]!==r?(w=S=>{const{code:C,html:N,id:j}=S;return N?u.jsx("div",{children:Zm({html:N})},`${n.title}-${j}`):C?u.jsxs("div",{className:"relative hover-actions-parent pr-2",children:[u.jsx(Ls,{children:u.jsx(Ne,{content:"Insert snippet",children:u.jsx(ve,{className:"absolute -top-2 -right-1 z-10 hover-action px-2 bg-background",size:"sm",variant:"outline",onClick:()=>{d(C)},children:u.jsx(Nr,{className:"h-5 w-5"})})})}),u.jsx(M.Suspense,{children:u.jsx(ua,{theme:r==="dark"?"dark":"light",language:"python",className:"cm border rounded overflow-hidden",extensions:H9,value:C,readOnly:!0},`${n.title}-${j}`)})]},`${n.title}-${j}`):null},e[23]=d,e[24]=n.title,e[25]=r,e[26]=w):w=e[26],b=n.sections.map(w),e[18]=d,e[19]=n.sections,e[20]=n.title,e[21]=r,e[22]=b}else b=e[22];return e[27]!==p||e[28]!==b?(y=u.jsxs("div",{className:"px-2 py-2 space-y-4 overflow-auto flex-1",children:[p,b]}),e[27]=p,e[28]=b,e[29]=y):y=e[29],e[30]!==y||e[31]!==g?(v=u.jsxs(u.Fragment,{children:[g,y]}),e[30]=y,e[31]=g,e[32]=v):v=e[32],v},G9=t=>{const e=H.c(7),{snippets:n,onSelect:o}=t;let r,s;if(e[0]!==o||e[1]!==n){let i;e[3]!==o?(i=a=>u.jsx(Zn,{className:"rounded-none",onSelect:()=>o(a),children:u.jsx("div",{className:"flex flex-row gap-2 items-center",children:u.jsx("span",{className:"mt-1 text-accent-foreground",children:a.title})})},a.title),e[3]=o,e[4]=i):i=e[4],r=n.map(i),e[0]=o,e[1]=n,e[2]=r}else r=e[2];return e[5]!==r?(s=u.jsx(Um,{className:"flex flex-col overflow-auto",children:r}),e[5]=r,e[6]=s):s=e[6],s},Y9=q.lazy(()=>Vm(()=>import("./tracing-erwDcbAl.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125]),import.meta.url).then(t=>({default:t.Tracing}))),K9=()=>{const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=u.jsx(q.Suspense,{fallback:u.jsx(X9,{}),children:u.jsx(Y9,{})}),t[0]=e):e=t[0],e},X9=()=>{const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=u.jsx("div",{className:"flex flex-col items-center justify-center h-full",children:u.jsx(kn,{})}),t[0]=e):e=t[0],e},Zk="name",Qk="type-value",sm="defs-refs",J9=[{id:Zk,accessorFn:t=>[t.name,t.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:t})=>u.jsx(rp,{header:"Name",column:t}),cell:({getValue:t})=>{const[e,n]=t();return u.jsx(xf,{name:e,declaredBy:n})}},{id:Qk,accessorFn:t=>[t.dataType,t.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:t})=>u.jsx(rp,{header:u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("span",{children:"Type"}),u.jsx("span",{children:"Value"})]}),column:t}),cell:({getValue:t})=>{const[e,n]=t();return u.jsxs("div",{className:"max-w-[150px]",children:[u.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:e}),u.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:n??"",children:n})]})}},{id:sm,accessorFn:t=>[t.declaredBy,t.usedBy,t.name,t.declaredByNames,t.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:t})=>u.jsx(rp,{header:u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("span",{children:"Declared By"}),u.jsx("span",{children:"Used By"})]}),column:t}),cell:({getValue:t})=>{const[e,n,o]=t(),r=s=>{const i=Li(s);i&&Qm(i,o)};return u.jsxs("div",{className:"flex flex-col gap-1 py-1",children:[u.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[u.jsx("span",{title:"Declared by",children:u.jsx(Yp,{className:"w-3.5 h-3.5 text-muted-foreground"})}),e.length===1?u.jsx(Mo,{variant:"focus",cellId:e[0],skipScroll:!0,onClick:()=>r(e[0])}):u.jsx("div",{className:"text-destructive flex flex-row gap-2",children:e.slice(0,3).map((s,i)=>u.jsxs("span",{className:"flex",children:[u.jsx(Mo,{variant:"focus",cellId:s,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(s)},s),i<e.length-1&&", "]},s))})]}),u.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[u.jsx("span",{title:"Used by",children:u.jsx(wa,{className:"w-3.5 h-3.5 text-muted-foreground"})}),u.jsx(kw,{maxCount:3,cellIds:n,skipScroll:!0,onClick:r})]})]})}}],e3=M.memo(({className:t,cellIds:e,variables:n})=>{const[o,r]=q.useState([]),[s,i]=q.useState(""),a=GL(),l=M.useMemo(()=>{const h=f=>{const m=a[f];return ZL(m)?`cell-${e.indexOf(f)}`:m??`cell-${e.indexOf(f)}`};return Object.values(n).map(f=>({...f,declaredByNames:f.declaredBy.map(h),usedByNames:f.usedBy.map(h)}))},[n,a,e]),c=M.useMemo(()=>{const h=new Map;return e.forEach((f,m)=>h.set(f,m)),function({variables:f,sort:m,cellIdToIndex:g}){m||(m={id:sm,desc:!1});let x=[];switch(m.id){case Zk:x=pa(f,p=>p.name);break;case Qk:x=pa(f,p=>p.dataType);break;case sm:x=pa(f,p=>g.get(p.declaredBy[0]))}return m.desc?x.reverse():x}({variables:l,sort:o[0],cellIdToIndex:h})},[l,o,e]),d=YL({data:c,columns:J9,getCoreRowModel:JL(),onGlobalFilterChange:i,getFilteredRowModel:XL(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter:h=>h.columnDef.enableGlobalFilter??!0,globalFilterFn:"auto",manualSorting:!0,onSortingChange:r,getSortedRowModel:KL(),state:{sorting:o,globalFilter:s}});return u.jsxs(u.Fragment,{children:[u.jsx(nj,{className:"w-full",placeholder:"Search",value:s,onChange:h=>i(h.target.value)}),u.jsxs(np,{className:xe("w-full text-sm flex-1 border-separate border-spacing-0",t),children:[u.jsx(tp,{children:u.jsx(Ns,{className:"whitespace-nowrap text-xs",children:d.getFlatHeaders().map(h=>u.jsx(Cr,{className:"sticky top-0 bg-background border-b",children:sj(h.column.columnDef.header,h.getContext())},h.id))})}),u.jsx(op,{children:d.getRowModel().rows.map(h=>u.jsx(Ns,{className:"hover:bg-accent",children:h.getVisibleCells().map(f=>u.jsx(jr,{className:"border-b",children:sj(f.column.columnDef.cell,f.getContext())},f.id))},h.id))})]})]})});e3.displayName="VariableTable";const Z9=()=>{const t=H.c(4),e=ep(),n=wr();if(Object.keys(e).length===0){let r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=u.jsx(dn,{title:"No variables",description:"Global variables will appear here.",icon:u.jsx(nc,{})}),t[0]=r):r=t[0],r}let o;return t[1]!==n.inOrderIds||t[2]!==e?(o=u.jsx(e3,{className:"flex-1",cellIds:n.inOrderIds,variables:e}),t[1]=n.inOrderIds,t[2]=e,t[3]=o):o=t[3],o},Q9=t=>{const e=H.c(54),n=je(QL),o=je(M6),r=lt(),s=wC(),i=t.cellId,a=o[t.cellId],l=sa(t.cellId),c=l.code,d=ia(t.cellId);let h,f,m,g,x,p,b,y,v,w,S,C,N,j;if(e[0]!==r||e[1]!==s||e[2]!==n.focusedCellId||e[3]!==o||e[4]!==t.cellId||e[5]!==a||e[6]!==l.code||e[7]!==d.errored){if(h={id:i,graph:a,code:c,hasError:d.errored},n.focusedCellId&&o[n.focusedCellId]){const z=o[n.focusedCellId];let _;e[20]!==n.focusedCellId||e[21]!==z?(_={id:n.focusedCellId,graph:z},e[20]=n.focusedCellId,e[21]=z,e[22]=_):_=e[22],g=_}m=(g==null?void 0:g.id)===h.id,f=n3(h.graph)?1.5:3;const D=()=>{m?s.blurCell():(r.focusCell({cellId:h.id,where:"exact"}),s.focusCell({cellId:h.id}))};C=h.id;const R=m?"text-primary-foreground":"text-(--gray-8) hover:text-(--gray-9)";e[23]!==R?(x=xe("group bg-transparent text-left w-full flex relative justify-between items-center","border-none rounded cursor-pointer","h-[21px] pl-[51px] font-inherit",R),e[23]=R,e[24]=x):x=e[24],p=D,b=iO;const P=m&&"bg-primary group-hover:bg-primary";e[25]!==P?(S=xe("group-hover:bg-(--gray-2) flex h-full w-full px-0.5 items-center rounded",P),e[25]=P,e[26]=S):S=e[26],y="truncate px-1 font-mono text-sm flex gap-1",v=h.code,w=h.graph.variables.length>0?u.jsx(oO,{cell:h,selectedCell:g}):u.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap max-w-full",children:nO(h.code)??u.jsx("span",{className:"italic",children:"empty"})}),e[0]=r,e[1]=s,e[2]=n.focusedCellId,e[3]=o,e[4]=t.cellId,e[5]=a,e[6]=l.code,e[7]=d.errored,e[8]=h,e[9]=f,e[10]=m,e[11]=g,e[12]=x,e[13]=p,e[14]=b,e[15]=y,e[16]=v,e[17]=w,e[18]=S,e[19]=C}else h=e[8],f=e[9],m=e[10],g=e[11],x=e[12],p=e[13],b=e[14],y=e[15],v=e[16],w=e[17],S=e[18],C=e[19];e[27]!==y||e[28]!==v||e[29]!==w?(N=u.jsx("div",{className:y,title:v,children:w}),e[27]=y,e[28]=v,e[29]=w,e[30]=N):N=e[30],e[31]!==N||e[32]!==S?(j=u.jsx("div",{className:S,children:N}),e[31]=N,e[32]=S,e[33]=j):j=e[33];const E=m?"z-30":"z-20";let T,I,O,L;return e[34]!==h||e[35]!==g||e[36]!==E?(T=xe("absolute overflow-visible top-[10.5px] left-[calc(var(--spacing-extra-small,8px)+17px)] pointer-events-none",E,function({cell:D,selectedCell:R}){return D.hasError?"text-destructive":!R&&!n3(D.graph)?"text-foreground":(R==null?void 0:R.id)===D.id||R!=null&&R.graph.parents.has(D.id)||R!=null&&R.graph.children.has(D.id)?"text-primary":"text-(--gray-8)"}({cell:h,selectedCell:g})),e[34]=h,e[35]=g,e[36]=E,e[37]=T):T=e[37],e[38]!==h||e[39]!==f||e[40]!==m||e[41]!==t.cellPositions||e[42]!==g?(I=m?u.jsx(rO,{cell:h,cellPositions:t.cellPositions,circleRadius:f}):u.jsx(sO,{cell:h,selectedCell:g,circleRadius:f}),e[38]=h,e[39]=f,e[40]=m,e[41]=t.cellPositions,e[42]=g,e[43]=I):I=e[43],e[44]!==T||e[45]!==I?(O=u.jsx("svg",{className:T,width:"1",height:"1",children:I}),e[44]=T,e[45]=I,e[46]=O):O=e[46],e[47]!==x||e[48]!==p||e[49]!==b||e[50]!==j||e[51]!==O||e[52]!==C?(L=u.jsxs("button",{"data-node-id":C,className:x,onClick:p,onMouseDown:b,children:[j,O]}),e[47]=x,e[48]=p,e[49]=b,e[50]=j,e[51]=O,e[52]=C,e[53]=L):L=e[53],L},eO=t=>{const e=H.c(28),{open:n,setOpen:o}=t,r=wr();let s;e[0]!==r.inOrderIds?(s=Object.fromEntries(r.inOrderIds.map(aO)),e[0]=r.inOrderIds,e[1]=s):s=e[1];const i=s;let a;if(e[2]!==r){a=[];let v=0;for(const[w,S]of r.getColumns().entries())w>0&&a.push(v),v+=S.inOrderIds.length;e[2]=r,e[3]=a}else a=e[3];const l=n?"translate-x-0":"translate-x-[calc(100%+20px)]";let c,d,h,f,m,g,x,p,b,y;if(e[4]!==l?(c=xe("fixed top-14 right-5 z-50 bg-background/95 backdrop-blur-sm supports-backdrop-filter:bg-background/60 rounded-lg border shadow-lg w-64 flex flex-col max-h-[58vh]","motion-safe:transition-transform motion-safe:duration-200 motion-safe:ease-in-out",l),e[4]=l,e[5]=c):c=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx("span",{className:"text-sm font-semibold",children:"Minimap"}),e[6]=d):d=e[6],e[7]!==o?(h=()=>o(!1),e[7]=o,e[8]=h):h=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(f=u.jsx(wn,{className:"h-4 w-4"}),e[9]=f):f=e[9],e[10]!==h?(m=u.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[d,u.jsx(ve,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:h,children:f})]}),e[10]=h,e[11]=m):m=e[11],e[12]!==r.inOrderIds||e[13]!==i||e[14]!==a){let v;e[16]!==i||e[17]!==a?(v=(w,S)=>{const C=a.includes(S);return u.jsxs(M.Fragment,{children:[C&&u.jsx("div",{className:"absolute left-5 w-[36px] h-px bg-(--gray-4) pointer-events-none","aria-hidden":"true"}),u.jsx(Q9,{cellId:w,cellPositions:i})]},w)},e[16]=i,e[17]=a,e[18]=v):v=e[18],g=r.inOrderIds.map(v),e[12]=r.inOrderIds,e[13]=i,e[14]=a,e[15]=g}else g=e[15];return e[19]!==g?(x=u.jsx("div",{className:"py-3 pl-3 pr-4 relative min-h-full",children:g}),e[19]=g,e[20]=x):x=e[20],e[21]===Symbol.for("react.memo_cache_sentinel")?(p=u.jsx("div",{className:"h-0 overflow-hidden","aria-hidden":"true"}),e[21]=p):p=e[21],e[22]!==x?(b=u.jsxs("div",{className:"overflow-y-auto overflow-x-hidden flex-1 scrollbar-none",children:[x,p]}),e[22]=x,e[23]=b):b=e[23],e[24]!==b||e[25]!==c||e[26]!==m?(y=u.jsxs("div",{className:c,children:[m,b]}),e[24]=b,e[25]=c,e[26]=m,e[27]=y):y=e[27],y},tO=()=>{const t=H.c(5),[e,n]=Dt(Ub);let o,r;return t[0]!==n?(o=()=>n(lO),t[0]=n,t[1]=o):o=t[1],Rt("global.toggleMinimap",o),t[2]!==e||t[3]!==n?(r=u.jsx(eO,{open:e,setOpen:n}),t[2]=e,t[3]=n,t[4]=r):r=t[4],r};function nO(t){return t.split(`
163
+ `)[0].trim()||void 0}const oO=t=>{const e=H.c(11),{cell:n,selectedCell:o}=t,r=ep(),s=n.id===(o==null?void 0:o.id);let i,a;if(e[0]!==n.graph.variables||e[1]!==s||e[2]!==o||e[3]!==r){let l;e[5]!==s||e[6]!==o||e[7]!==r?(l=(c,d)=>{const h=r[c];return u.jsxs(M.Fragment,{children:[d>0&&", ",u.jsx("span",{className:xe({"font-bold":s,"text-foreground":o===void 0,"text-primary font-medium":!s&&O6(h,o)}),children:c})]},c)},e[5]=s,e[6]=o,e[7]=r,e[8]=l):l=e[8],i=n.graph.variables.map(l),e[0]=n.graph.variables,e[1]=s,e[2]=o,e[3]=r,e[4]=i}else i=e[4];return e[9]!==i?(a=u.jsx(u.Fragment,{children:i}),e[9]=i,e[10]=a):a=e[10],a},rO=t=>{const e=H.c(12),{cell:n,cellPositions:o,circleRadius:r}=t;let s,i,a,l;if(e[0]!==n.graph.children||e[1]!==n.graph.parents||e[2]!==n.id||e[3]!==o){s=[];const c=o[n.id]??0,d=new Set;for(const h of n.graph.parents)n.graph.children.has(h)&&d.add(h);for(const h of d){const f=o[h];if(f!==void 0){const m=21*(f-c);s.push(u.jsx("path",{d:`M -3 0 H -7 v ${m} h 14 v ${-m} H 3`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-cycle-${h}`))}}for(const h of n.graph.parents){if(d.has(h))continue;const f=o[h];if(f!==void 0){const m=21*(f-c);s.push(u.jsx("path",{d:`M -3 0 H -7 v ${m} h -4`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-up-${h}`))}}for(const h of n.graph.children){if(d.has(h))continue;const f=o[h];if(f!==void 0){const m=21*(f-c);s.push(u.jsx("path",{d:`M 3 0 H 7 v ${m} h 4`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-down-${h}`))}}e[0]=n.graph.children,e[1]=n.graph.parents,e[2]=n.id,e[3]=o,e[4]=s}else s=e[4];return e[5]!==r?(i=u.jsx("circle",{r,fill:"currentColor",className:"pointer-events-auto"}),e[5]=r,e[6]=i):i=e[6],e[7]!==s?(a=u.jsx("g",{className:"pen pointer-events-auto",children:s}),e[7]=s,e[8]=a):a=e[8],e[9]!==i||e[10]!==a?(l=u.jsxs("g",{transform:"translate(0, 0)",children:[i,a]}),e[9]=i,e[10]=a,e[11]=l):l=e[11],l};function sO(t){const{cell:e,selectedCell:n,circleRadius:o}=t,r=e.graph.ancestors.size>0,s=e.graph.descendants.size>0;if(!n)return t3({circleRadius:o,leftWisker:r,rightWisker:s});const i=n.graph.ancestors.has(e.id),a=n.graph.descendants.has(e.id);return t3(i||a?{circleRadius:o,leftWisker:r,rightWisker:s,shift:i&&a?void 0:i?"left":"right"}:{circleRadius:o,leftWisker:!1,rightWisker:!1})}function t3(t){const{circleRadius:e,leftWisker:n,rightWisker:o,shift:r}=t,s=r===void 0?0:r==="left"?-14:14;return u.jsxs("g",{transform:`translate(${s}, 0)`,children:[u.jsxs("g",{children:[n&&u.jsx("path",{d:"M 0 0 h -8",fill:"none",strokeWidth:"2",stroke:"currentColor"}),o&&u.jsx("path",{d:"M 0 0 h 8",fill:"none",strokeWidth:"2",stroke:"currentColor"})]}),u.jsx("circle",{r:e,fill:"currentColor",className:"pointer-events-auto"})]})}function n3(t){return t.variables.length===0&&t.ancestors.size===0&&t.descendants.size===0}function iO(t){return t.preventDefault()}function aO(t,e){return[t,e]}function lO(t){return!t}const cO=q.lazy(()=>Vm(()=>import("./terminal-BHiJua_p.js"),__vite__mapDeps([126,1,2,127]),import.meta.url)),dO=t=>{const e=H.c(122),{children:n}=t,{isSidebarOpen:o,isTerminalOpen:r,selectedPanel:s}=bc(),{setIsSidebarOpen:i,setIsTerminalOpen:a}=qi(),l=q.useRef(null),c=q.useRef(null);let d,h,f,m,g;e[0]!==o?(d=()=>{if(!l.current)return;const Re=l.current.isCollapsed();o&&Re&&l.current.expand(),o||Re||l.current.collapse(),requestAnimationFrame(hO)},h=[o],e[0]=o,e[1]=d,e[2]=h):(d=e[1],h=e[2]),M.useEffect(d,h),e[3]!==r?(f=()=>{if(!c.current)return;const Re=c.current.isCollapsed();r&&Re&&c.current.expand(),r||Re||c.current.collapse(),requestAnimationFrame(mO)},m=[r],e[3]=r,e[4]=f,e[5]=m):(f=e[4],m=e[5]),M.useEffect(f,m),e[6]!==n?(g=u.jsx(qc,{id:"app",className:"relative h-full",children:u.jsx(M.Suspense,{children:n})},"app"),e[6]=n,e[7]=g):g=e[7];const x=g,p=o?"resize-handle":"resize-handle-collapsed";let b,y;e[8]!==p?(b=xe("border-border no-print z-10",p,"vertical"),e[8]=p,e[9]=b):b=e[9],e[10]!==b?(y=u.jsx(ij,{onDragging:aj,className:b}),e[10]=b,e[11]=y):y=e[11];const v=y,w=r?"resize-handle":"resize-handle-collapsed";let S,C;e[12]!==w?(S=xe("border-border no-print z-20",w,"horizontal"),e[12]=w,e[13]=S):S=e[13],e[14]!==S?(C=u.jsx(ij,{onDragging:aj,className:S}),e[14]=S,e[15]=C):C=e[15];const N=C;let j,E,T,I,O,L,D,R,P,z,_,k,B,A,U,$,X,Y,G,W,J;e[16]!==s?(j=u.jsx("div",{className:"text-sm text-(--slate-11) uppercase tracking-wide font-semibold flex-1",children:s}),e[16]=s,e[17]=j):j=e[17],e[18]!==i?(E=()=>i(!1),e[18]=i,e[19]=E):E=e[19],e[20]===Symbol.for("react.memo_cache_sentinel")?(T=u.jsx(wn,{className:"w-4 h-4"}),e[20]=T):T=e[20],e[21]!==E?(I=u.jsx(ve,{"data-testid":"close-helper-pane",className:"m-0",size:"xs",variant:"text",onClick:E,children:T}),e[21]=E,e[22]=I):I=e[22],e[23]!==j||e[24]!==I?(O=u.jsxs("div",{className:"p-3 border-b flex justify-between items-center",children:[j,I]}),e[23]=j,e[24]=I,e[25]=O):O=e[25],e[26]!==s?(L=s==="files"&&u.jsx(Hk,{}),e[26]=s,e[27]=L):L=e[27],e[28]!==s?(D=s==="errors"&&u.jsx(Z7,{}),e[28]=s,e[29]=D):D=e[29],e[30]!==s?(R=s==="variables"&&u.jsx(Z9,{}),e[30]=s,e[31]=R):R=e[31],e[32]!==s?(P=s==="dependencies"&&u.jsx(L7,{}),e[32]=s,e[33]=P):P=e[33],e[34]!==s?(z=s==="packages"&&u.jsx(j9,{}),e[34]=s,e[35]=z):z=e[35],e[36]!==s?(_=s==="outline"&&u.jsx(C9,{}),e[36]=s,e[37]=_):_=e[37],e[38]!==s?(k=s==="datasources"&&u.jsx(X7,{}),e[38]=s,e[39]=k):k=e[39],e[40]!==s?(B=s==="documentation"&&u.jsx(J7,{}),e[40]=s,e[41]=B):B=e[41],e[42]!==s?(A=s==="snippets"&&u.jsx(W9,{}),e[42]=s,e[43]=A):A=e[43],e[44]!==s?(U=s==="scratchpad"&&u.jsx(D9,{}),e[44]=s,e[45]=U):U=e[45],e[46]!==s?($=s==="chat"&&u.jsx(sT,{}),e[46]=s,e[47]=$):$=e[47],e[48]!==s?(X=s==="logs"&&u.jsx(Wk,{}),e[48]=s,e[49]=X):X=e[49],e[50]!==s?(Y=s==="tracing"&&u.jsx(K9,{}),e[50]=s,e[51]=Y):Y=e[51],e[52]!==s?(G=s==="secrets"&&u.jsx(R9,{}),e[52]=s,e[53]=G):G=e[53],e[54]!==L||e[55]!==D||e[56]!==R||e[57]!==P||e[58]!==z||e[59]!==_||e[60]!==k||e[61]!==B||e[62]!==A||e[63]!==U||e[64]!==$||e[65]!==X||e[66]!==Y||e[67]!==G?(W=u.jsx(M.Suspense,{children:u.jsxs(Vc,{children:[L,D,R,P,z,_,k,B,A,U,$,X,Y,G]})}),e[54]=L,e[55]=D,e[56]=R,e[57]=P,e[58]=z,e[59]=_,e[60]=k,e[61]=B,e[62]=A,e[63]=U,e[64]=$,e[65]=X,e[66]=Y,e[67]=G,e[68]=W):W=e[68],e[69]!==O||e[70]!==W?(J=u.jsx(Cc,{children:u.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden mr-[-4px]",children:[O,W]})}),e[69]=O,e[70]=W,e[71]=J):J=e[71];const V=J,Q=o&&"border-r border-l border-(--slate-7)";let te,re,ne,ie,se,ae;e[72]!==Q?(te=xe("dark:bg-(--slate-1) no-print print:hidden hide-on-fullscreen",Q),e[72]=Q,e[73]=te):te=e[73],e[74]===Symbol.for("react.memo_cache_sentinel")?(re=(Re,Pe)=>{var He;Pe===0&&Re===10&&((He=l.current)==null||He.resize(30))},e[74]=re):re=e[74],e[75]!==i?(ne=()=>i(!1),ie=()=>i(!0),e[75]=i,e[76]=ne,e[77]=ie):(ne=e[76],ie=e[77]),e[78]!==V||e[79]!==v?(se=u.jsxs("span",{className:"flex flex-row h-full",children:[V," ",v]}),e[78]=V,e[79]=v,e[80]=se):se=e[80],e[81]!==te||e[82]!==ne||e[83]!==ie||e[84]!==se?(ae=u.jsx(qc,{ref:l,id:"helper",collapsedSize:0,collapsible:!0,className:te,minSize:10,defaultSize:0,maxSize:75,onResize:re,onCollapse:ne,onExpand:ie,children:se},"helper"),e[81]=te,e[82]=ne,e[83]=ie,e[84]=se,e[85]=ae):ae=e[85];const ge=ae,oe=r&&"border-(--slate-7)";let ue,de,Se,Te,Fe,_e,ke,Ye,Ve;e[86]!==oe?(ue=xe("dark:bg-(--slate-1) no-print print:hidden hide-on-fullscreen",oe),e[86]=oe,e[87]=ue):ue=e[87],e[88]===Symbol.for("react.memo_cache_sentinel")?(de=(Re,Pe)=>{var He;Pe===0&&Re===10&&((He=c.current)==null||He.resize(30))},e[88]=de):de=e[88],e[89]!==a?(Se=()=>a(!1),Te=()=>a(!0),e[89]=a,e[90]=Se,e[91]=Te):(Se=e[90],Te=e[91]),e[92]===Symbol.for("react.memo_cache_sentinel")?(Fe=u.jsx("div",{}),e[92]=Fe):Fe=e[92],e[93]!==a?(_e=()=>a(!1),e[93]=a,e[94]=_e):_e=e[94],e[95]!==r||e[96]!==_e?(ke=u.jsx(M.Suspense,{fallback:Fe,children:u.jsx(cO,{visible:r,onClose:_e})}),e[95]=r,e[96]=_e,e[97]=ke):ke=e[97],e[98]!==r||e[99]!==ke?(Ye=u.jsx(F7,{isOpen:r,children:ke}),e[98]=r,e[99]=ke,e[100]=Ye):Ye=e[100],e[101]!==ue||e[102]!==Se||e[103]!==Te||e[104]!==Ye||e[105]!==N?(Ve=u.jsxs(qc,{ref:c,id:"terminal",collapsedSize:0,collapsible:!0,className:ue,minSize:10,defaultSize:0,maxSize:75,onResize:de,onCollapse:Se,onExpand:Te,children:[N,Ye]},"terminal"),e[101]=ue,e[102]=Se,e[103]=Te,e[104]=Ye,e[105]=N,e[106]=Ve):Ve=e[106];const Ke=Ve;let ee,ye,we,Ie,K,me,pe,he,Ce;return e[107]===Symbol.for("react.memo_cache_sentinel")?(ee=WF(),e[107]=ee):ee=e[107],e[108]===Symbol.for("react.memo_cache_sentinel")?(ye=u.jsx(Vc,{children:u.jsx(V6,{})}),e[108]=ye):ye=e[108],e[109]!==Ke?(we=u.jsx(zb,{capability:"terminal",children:Ke}),e[109]=Ke,e[110]=we):we=e[110],e[111]!==x||e[112]!==we?(Ie=u.jsx(qc,{children:u.jsxs(lj,{autoSaveId:"marimo:chrome:v1:l1",direction:"vertical",children:[x,we]})}),e[111]=x,e[112]=we,e[113]=Ie):Ie=e[113],e[114]===Symbol.for("react.memo_cache_sentinel")?(K=u.jsx(eF,{}),e[114]=K):K=e[114],e[115]!==ge||e[116]!==Ie?(me=u.jsxs(lj,{autoSaveId:"marimo:chrome:v1:l2",direction:"horizontal",storage:ee,children:[ye,ge,Ie,K]}),e[115]=ge,e[116]=Ie,e[117]=me):me=e[117],e[118]===Symbol.for("react.memo_cache_sentinel")?(pe=u.jsx(tO,{}),e[118]=pe):pe=e[118],e[119]===Symbol.for("react.memo_cache_sentinel")?(he=u.jsx(Cc,{children:u.jsx(Vc,{children:u.jsx(F6,{})})}),e[119]=he):he=e[119],e[120]!==me?(Ce=u.jsxs(qF,{children:[me,pe,he]}),e[120]=me,e[121]=Ce):Ce=e[121],Ce};function uO(){window.dispatchEvent(new Event("resize"))}function hO(){requestAnimationFrame(uO)}function fO(){window.dispatchEvent(new Event("resize"))}function mO(){requestAnimationFrame(fO)}let o3;o3=new URL(window.location.href).searchParams.get(tF.showChrome)==="false",Tj=Object.freeze(Object.defineProperty({__proto__:null,default:t=>{const e=H.c(10);if(o3){let s,i,a;return e[0]!==t?(s=u.jsx(Fb,{hideControls:!0,...t}),e[0]=t,e[1]=s):s=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(i=u.jsx(lg,{}),e[2]=i):i=e[2],e[3]!==s?(a=u.jsxs(u.Fragment,{children:[s,i]}),e[3]=s,e[4]=a):a=e[4],a}let n,o,r;return e[5]!==t?(n=u.jsx(Fb,{...t}),e[5]=t,e[6]=n):n=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(o=u.jsx(lg,{}),e[7]=o):o=e[7],e[8]!==n?(r=u.jsxs(dO,{children:[n,o]}),e[8]=n,e[9]=r):r=e[9],r}},Symbol.toStringTag,{value:"Module"}))});export{hp as C,Yc as E,dn as P,ez as __tla,Kc as a,Tj as e,Is as f};