@marimo-team/islands 0.25.3-dev98 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1005) hide show
  1. package/dist/{ConnectedDataExplorerComponent-Dhf5EGs5.js → ConnectedDataExplorerComponent-DtwVgVpX.js} +190 -214
  2. package/dist/ErrorBoundary-j49HcVvR.js +213 -0
  3. package/dist/{ImageComparisonComponent-uU8FSKZE.js → ImageComparisonComponent-CoiwlCwG.js} +20 -20
  4. package/dist/{Plot-DdYOe1UK.js → Plot-BHJLG4xm.js} +2474 -3107
  5. package/dist/_baseSet-Bd5zh2yg.js +327 -0
  6. package/dist/{abnfDiagram-VCTEODGH-Di400kYu.js → abnfDiagram-VCTEODGH-BbZOIueZ.js} +5 -5
  7. package/dist/{any-language-editor-k2B8YI3Y.js → any-language-editor-yG-YmLaK.js} +9 -9
  8. package/dist/{apl-GEW9-ZP1.js → apl-stFrI2NB.js} +1 -1
  9. package/dist/{arc-7ra3iNdN.js → arc-4W6H62B5.js} +1 -1
  10. package/dist/architecture-7GRP2DOG-GlkXha5_.js +2 -0
  11. package/dist/{architectureDiagram-5GKGNRK7-BdTJcsNJ.js → architectureDiagram-5GKGNRK7-qjLjxapm.js} +48 -64
  12. package/dist/{arrays-R6JsImiT.js → arrays-DoQ-AILx.js} +7 -27
  13. package/dist/{asciiarmor-BWNxzkG7.js → asciiarmor-DHwFuaIC.js} +1 -1
  14. package/dist/{asn1-Bcn2QutK.js → asn1-KIH4fwAq.js} +1 -1
  15. package/dist/assertNever-DywGMo-S.js +507 -0
  16. package/dist/assets/__vite-browser-external-DZv_7F5P.js +1 -0
  17. package/dist/assets/worker-cHYZNFD4.js +171 -0
  18. package/dist/{blockDiagram-I7D4REHJ-Cg25UrxT.js → blockDiagram-I7D4REHJ-BoCyD5KO.js} +28 -39
  19. package/dist/{brainfuck-BQCYDheZ.js → brainfuck-UPAij4U9.js} +1 -1
  20. package/dist/{button-BxB3RDjN.js → button-qQhINE7z.js} +63 -63
  21. package/dist/{c4Diagram-7LVT6UL2-BxFgrnNV.js → c4Diagram-7LVT6UL2-DmcTtm4p.js} +8 -8
  22. package/dist/{capabilities-BgR0osfN.js → capabilities-DKqMqBzm.js} +2 -2
  23. package/dist/{channel-CPObtJXj.js → channel-B9eaiezW.js} +1 -1
  24. package/dist/{chat-ui-BIgPxfPP.js → chat-ui-D5YPIONI.js} +3110 -2917
  25. package/dist/{check-P35dc2dH.js → check-jchHMCfs.js} +1 -1
  26. package/dist/{chunk-4HAMMTFA-D4eFPyFh.js → chunk-4HAMMTFA-qKgadZwy.js} +6 -6
  27. package/dist/{chunk-75Z2AOVW-D7gxIs2Q.js → chunk-75Z2AOVW-76L6My3P.js} +4 -4
  28. package/dist/{chunk-YOKDWASO-DKplTrBY.js → chunk-7TTQLYRW-DBSfUUe5.js} +6253 -5835
  29. package/dist/{chunk-DU6HZSFF-BwiyaNpg.js → chunk-DU6HZSFF-4SDIhUTY.js} +14 -22
  30. package/dist/{chunk-F27PBJKO-ufseIn5y.js → chunk-F27PBJKO-COH2t-FO.js} +3 -3
  31. package/dist/{chunk-FOHPRMQF-BpYR8RqP.js → chunk-FOHPRMQF-ezmr_yWy.js} +49 -58
  32. package/dist/{chunk-GMAD6QVW-BhaJx0X3.js → chunk-GMAD6QVW-BJGF8QZL.js} +16 -75
  33. package/dist/{chunk-GVQU2GXP-Cwbt-lF0.js → chunk-GVQU2GXP-BkolpSXU.js} +3 -3
  34. package/dist/{chunk-IMKFNOWR-mtD7aJBw.js → chunk-IMKFNOWR-BzDY1_I7.js} +8 -8
  35. package/dist/{chunk-L3NEJ4N5-n-zgIVSy.js → chunk-L3NEJ4N5-B-BFQp9t.js} +6 -6
  36. package/dist/{chunk-OSK3NFVY-DXa-Cxbn.js → chunk-OSK3NFVY-BzfZ4VBG.js} +8 -8
  37. package/dist/{chunk-P2QGCYS3-B_Zd3-X0.js → chunk-P2QGCYS3-DJApLVdt.js} +1 -1
  38. package/dist/{chunk-POPQ4Y6H-hYOXbYH_.js → chunk-POPQ4Y6H-BFSZel4w.js} +2 -2
  39. package/dist/{chunk-PWAF6VOD-CQw5qATZ.js → chunk-PWAF6VOD-CRu_RGP2.js} +2 -2
  40. package/dist/{chunk-SHT3W25Y-DybB1ShH.js → chunk-SHT3W25Y-DbHsMKdo.js} +10 -10
  41. package/dist/{chunk-SVP7TREG-DNhhdCex.js → chunk-SVP7TREG-CtwnwAE6.js} +3 -3
  42. package/dist/{chunk-TICWLB2K-NhAQhlDf.js → chunk-TICWLB2K-C5Z5QMbO.js} +10 -10
  43. package/dist/{chunk-XXDRQBXY-Dnl5VBqG.js → chunk-XXDRQBXY-BM-YIt-_.js} +1 -1
  44. package/dist/classDiagram-ZZMXUADV-B8E5Hn78.js +30 -0
  45. package/dist/classDiagram-v2-VYDZK3BY-DeGsK9bT.js +30 -0
  46. package/dist/{clike-CxK9W55Z.js → clike-xU8sCVU1.js} +2 -6
  47. package/dist/{clojure-Dzcvwpxk.js → clojure-psoSEo36.js} +1 -1
  48. package/dist/{cmake-DYr-71zp.js → cmake-DDHBwlE7.js} +1 -1
  49. package/dist/{cobol-DC3g37Kq.js → cobol-C4qjDcIq.js} +1 -1
  50. package/dist/code-visibility-DE4l3OCD.js +130 -0
  51. package/dist/{coffeescript-C-eFwH5N.js → coffeescript-D6UgrGgo.js} +1 -1
  52. package/dist/{common-B3KZnxiH.js → common-C0gNagW9.js} +10975 -10314
  53. package/dist/{commonlisp-CyaNXrJR.js → commonlisp-B0ChVjnu.js} +1 -1
  54. package/dist/{compiler-runtime-CldRdSsv.js → compiler-runtime-C5KHtL5D.js} +3 -3
  55. package/dist/{toDate-DKH0_kMo.js → config-qTaTHnpE.js} +96 -180
  56. package/dist/{copy-icon-CPoxUG7G.js → copy-icon-BI7vZHEW.js} +46 -41
  57. package/dist/{cose-bilkent-JH36ORCC-_LyRKVqm.js → cose-bilkent-JH36ORCC-B_Oz4vMP.js} +58 -71
  58. package/dist/createReducer-DdSLRfBT.js +67 -0
  59. package/dist/{crystal-ih5ax5tQ.js → crystal-DZsc9Ue0.js} +1 -1
  60. package/dist/{css-CN_wP7_R.js → css-DkYRnQ9U.js} +1 -1
  61. package/dist/{cubic-OaEBhQPK.js → cubic-CA80xY_e.js} +6 -7
  62. package/dist/cynefin-OW5HDTMX-0-HehVvH.js +2 -0
  63. package/dist/{cynefinDiagram-5FMLGOSQ-CX22wa7c.js → cynefinDiagram-5FMLGOSQ-NDedRwsw.js} +5 -5
  64. package/dist/{cypher-CqGRcmZo.js → cypher-CpWPqgvy.js} +1 -1
  65. package/dist/{cytoscape.esm-jJhXJpLB.js → cytoscape.esm-BbeMznK5.js} +411 -512
  66. package/dist/{d-Cj0sOW2z.js → d-Bx2ggfYO.js} +1 -1
  67. package/dist/{dagre-BGSfXNEb.js → dagre-CpjuekF1.js} +550 -700
  68. package/dist/{dagre-GXQ25YYZ-Df6Pp-cl.js → dagre-GXQ25YYZ-De0sSZO7.js} +14 -16
  69. package/dist/{data-grid-overlay-editor-wb2J7aj-.js → data-grid-overlay-editor-c9kODieo.js} +8 -8
  70. package/dist/{data-grid-types-0PJ-9N5n.js → data-grid-types-DIX_pCco.js} +2 -2
  71. package/dist/{debounce-C3jyATpc.js → debounce-DrhhziJv.js} +2 -2
  72. package/dist/{diagram-S7CK7UJ4-CctU9kVx.js → diagram-S7CK7UJ4-wBtVl61y.js} +7 -15
  73. package/dist/{diagram-UQ7AKVKN-FVHjCF9j.js → diagram-UQ7AKVKN-CKWE3c1T.js} +5 -5
  74. package/dist/{diagram-VSXAHHWV-BJWcVVJY.js → diagram-VSXAHHWV-LXjisZoM.js} +6 -6
  75. package/dist/{diagram-VX7I27RA-BSDbwFFv.js → diagram-VX7I27RA-D2Ac5198.js} +7 -7
  76. package/dist/{diagram-Z3DM3KII-BX8kW7Nc.js → diagram-Z3DM3KII-CYaFOQcI.js} +5 -5
  77. package/dist/{dialog-C1PcpCqX.js → dialog-Ic6dh09m.js} +25 -25
  78. package/dist/{diff-B_hUkiat.js → diff-DNXaJS8v.js} +1 -1
  79. package/dist/{dist-Bvs24R_E.js → dist-B1qu3Bez.js} +55 -54
  80. package/dist/{dist-D-wwqlzJ.js → dist-BEcpQbZa.js} +78 -77
  81. package/dist/{dist-CrSP_H1M.js → dist-BMz__bo5.js} +317 -317
  82. package/dist/{dist-Cg7gzw-a.js → dist-BagHbFqG.js} +70 -69
  83. package/dist/{dist-C8fAKSH1.js → dist-BdUitvVW.js} +65 -64
  84. package/dist/{dist-BuaRHxOc.js → dist-BfrgytDR.js} +45 -44
  85. package/dist/{dist-CSJ0MDRw.js → dist-BozTF_gH.js} +56 -55
  86. package/dist/{dist-DiDibOYr.js → dist-BreKIQqQ.js} +149 -148
  87. package/dist/{dist-CN8zI-XC.js → dist-BsE4gQHj.js} +555 -555
  88. package/dist/{dist-F8Ep36rk.js → dist-BunZKA_9.js} +60 -59
  89. package/dist/dist-BvZpdAuG.js +850 -0
  90. package/dist/{dist-DUAh96QY.js → dist-CB9MzCXv.js} +1 -1
  91. package/dist/{dist-BK4Oj99o.js → dist-CDVvitRS.js} +18 -17
  92. package/dist/{dist-CN_BeG2I.js → dist-CEomphG1.js} +59 -58
  93. package/dist/{dist-BMQf5zIS.js → dist-ChcBm3jk.js} +166 -165
  94. package/dist/{dist-Lm-D-Vr6.js → dist-CiSkXlAO.js} +3 -3
  95. package/dist/{dist-D6d86eNJ.js → dist-Cshl6jBw.js} +46 -45
  96. package/dist/{dist-DBtSl3sf.js → dist-D1D56-GS.js} +54 -56
  97. package/dist/{dist-DoE4XJBC.js → dist-D92tYjLc.js} +9845 -10688
  98. package/dist/{dist-OR1OnN-y.js → dist-D95Cd4xm.js} +53 -52
  99. package/dist/{dist-BorMD-uX.js → dist-DNkrY12t.js} +94 -93
  100. package/dist/{dist-BLfKmR-l.js → dist-DneeBk3K.js} +18 -17
  101. package/dist/{dist-diIx5qJW.js → dist-DpYpG8Yc.js} +37 -36
  102. package/dist/{dist-CkTTIdBe.js → dist-MggMo7OR.js} +243 -243
  103. package/dist/{dist-PXYI_yuP.js → dist-ObeTgSmf.js} +27 -26
  104. package/dist/{dist-CLdpGQVr.js → dist-OmeAz0fR.js} +114 -116
  105. package/dist/{dist-CSbh1PNP.js → dist-TGSwzj8a.js} +26 -25
  106. package/dist/dropdown-menu-Dhv4fcNl.js +5982 -0
  107. package/dist/{dtd-B8FGSWWe.js → dtd-D1YZQCVT.js} +1 -1
  108. package/dist/duckdb-keywords-CdzX4o33.js +3 -0
  109. package/dist/{dylan-DbIBYIrw.js → dylan-CxbG-PUm.js} +2 -2
  110. package/dist/{ebnfDiagram-PWID7BFC-DtapdLet.js → ebnfDiagram-PWID7BFC-Ds7f42dj.js} +5 -5
  111. package/dist/{ecl-DBmkdWAd.js → ecl-DIXH6vul.js} +1 -1
  112. package/dist/{eiffel-CcWSDDzK.js → eiffel-D0de-eQr.js} +1 -1
  113. package/dist/{elm-MC-b8a6C.js → elm-DrQrn4VD.js} +1 -1
  114. package/dist/{erDiagram-RLTQ6QDP-BAru9jHt.js → erDiagram-RLTQ6QDP-b58Sz2Mc.js} +14 -14
  115. package/dist/{erlang-AdO1-xtV.js → erlang-2KpKpfC7.js} +1 -1
  116. package/dist/{error-banner-Sl2FlSJ4.js → error-banner-CJVLr5_a.js} +147 -147
  117. package/dist/error-entries-BKlEsuk4.js +3255 -0
  118. package/dist/{esm-D2gTsXEV.js → esm-B9n0caHs.js} +643 -644
  119. package/dist/{esm-AMFssoNp.js → esm-Bwp_FHP0.js} +331 -331
  120. package/dist/{esm-G4Fhsgng.js → esm-DQtHTnHn.js} +640 -660
  121. package/dist/eventmodeling-NTZA5JFV-DoBvB4Lj.js +2 -0
  122. package/dist/{factor-Ys-13HOP.js → factor-Bwu3ZGOk.js} +1 -1
  123. package/dist/feedback-button-CGsCufLe.js +370 -0
  124. package/dist/flowDiagram-HODETNUW-BH9U7VZK.js +15 -0
  125. package/dist/{formats-V8ifA0Bk.js → formats-BLNFWWhV.js} +9 -9
  126. package/dist/{forth-DiMuIXFe.js → forth-DYatDpr6.js} +2 -3
  127. package/dist/{fortran-hkrF2eM4.js → fortran-n8mcQPkL.js} +1 -1
  128. package/dist/{ganttDiagram-EL5Y4UJY-Dh_4cBJZ.js → ganttDiagram-EL5Y4UJY-YzTghq1V.js} +17 -17
  129. package/dist/{gas-DlhqN9k8.js → gas-BUZOHBVw.js} +1 -1
  130. package/dist/{gherkin-0SlhEZ3t.js → gherkin-CrSjX26K.js} +1 -1
  131. package/dist/gitGraph-4MIJSDKK-Ch7kj-d2.js +2 -0
  132. package/dist/{gitGraphDiagram-WWUBYQGX-D5nSIzdE.js → gitGraphDiagram-WWUBYQGX-CK66dT35.js} +4 -4
  133. package/dist/{glide-data-editor-BBDo3Rj6.js → glide-data-editor-BkGI_Mj6.js} +6717 -2965
  134. package/dist/{glide-utils-Bt8_pBa2.js → glide-utils-Cn2_NadX.js} +109 -78
  135. package/dist/{globals-C7_iz22d.js → globals-DFJad_Ry.js} +3 -3
  136. package/dist/{graphlib-BmY_CCV9.js → graphlib-nlwT3Wvy.js} +177 -220
  137. package/dist/{groovy-YhcTMyvX.js → groovy-IgGNjeU9.js} +1 -1
  138. package/dist/hasIn-C20JsQ2m.js +28 -0
  139. package/dist/{haskell-CodLxrtT.js → haskell-Bs1k3a9s.js} +1 -1
  140. package/dist/{haxe-CiRWNFkH.js → haxe-CQ8Yb3XF.js} +1 -1
  141. package/dist/highlighted-body-JLMTFACH-yt0ZZn80.js +42 -0
  142. package/dist/{error-entries-TAO6kEhF.js → html-to-image-CNM0ZSFD.js} +26321 -26406
  143. package/dist/{idl-DZgBq75I.js → idl-DjnxoAWx.js} +1 -1
  144. package/dist/info-A6RAGUB7-DCz_Egh9.js +2 -0
  145. package/dist/{infoDiagram-27XIBGKW-B1hmUggC.js → infoDiagram-27XIBGKW-xbjwrcNi.js} +4 -4
  146. package/dist/isArrayLikeObject-B-HXCsex.js +626 -0
  147. package/dist/isEmpty-CdX7MTE1.js +14 -0
  148. package/dist/{ishikawaDiagram-5VMMS53U-DUeT3t-d.js → ishikawaDiagram-5VMMS53U-DKtukhGS.js} +5 -7
  149. package/dist/{javascript-BfNytHiM.js → javascript-BQtCoAFy.js} +2 -2
  150. package/dist/{journeyDiagram-3NMN7TZE-BaLqn-dZ.js → journeyDiagram-3NMN7TZE-CYXsL3IE.js} +4 -4
  151. package/dist/{jsx-runtime-3BD1kT0s.js → jsx-runtime-D8btoEHk.js} +2 -2
  152. package/dist/{julia--tLIAG7q.js → julia-BfgtHJE5.js} +1 -1
  153. package/dist/{kanban-definition-UXKFOSKX-DEUnNNgc.js → kanban-definition-UXKFOSKX-BEhlkZBb.js} +10 -10
  154. package/dist/{katex-BIdZGsyO.js → katex-wAapZGrX.js} +793 -724
  155. package/dist/linear-TJTTbHM9.js +203 -0
  156. package/dist/{livescript-CVPfYnY_.js → livescript-gIdRPKtg.js} +1 -1
  157. package/dist/{loader-Bm8cy3e8.js → loader-Bin_dutt.js} +12 -12
  158. package/dist/lru-0OWJJMrW.js +41 -0
  159. package/dist/{lua-4Fa-T-qq.js → lua-CxFpWvnv.js} +2 -2
  160. package/dist/main.js +11758 -9367
  161. package/dist/{mathematica-CtYAy6GG.js → mathematica-QSveeEoW.js} +1 -1
  162. package/dist/{mbox-D0w9Ah1C.js → mbox-2JtaCPNT.js} +1 -1
  163. package/dist/{mermaid-B0fXpsNP.js → mermaid-D1CZDNoB.js} +1195 -1182
  164. package/dist/mermaid-WFAXDIZX-DHB2z13u.js +1 -0
  165. package/dist/{mermaid-parser.core-DxuSfYwJ.js → mermaid-parser.core-DtOnl7m4.js} +19 -25
  166. package/dist/{mhchem-CdWPJK6g.js → mhchem-CX8M7Ktl.js} +1 -1
  167. package/dist/{micromark-factory-space-DGxAzmw8.js → micromark-factory-space-C5soVmaM.js} +1 -1
  168. package/dist/{mindmap-definition-YA3MSWOX-CPexlhDQ.js → mindmap-definition-YA3MSWOX-DQcnJPcV.js} +13 -13
  169. package/dist/{mirc-De9aSAZM.js → mirc-BqD6ade4.js} +1 -1
  170. package/dist/{mllike-BbugeaY_.js → mllike-CT0hgEOO.js} +1 -1
  171. package/dist/{modelica-BjJwWw1F.js → modelica-DKKebcvq.js} +1 -1
  172. package/dist/{mscgen-DwiRH5ma.js → mscgen-BJCCsWjR.js} +1 -1
  173. package/dist/{mumps--plbDM9o.js → mumps-DVQAXZkU.js} +1 -1
  174. package/dist/{nginx-C4Df7REc.js → nginx-AP4LH2NN.js} +1 -1
  175. package/dist/{node-sql-parser-BiZOJ-FS.js → node-sql-parser-C9dndbfr.js} +7184 -7195
  176. package/dist/{now-jM8-M7IR.js → now-BKZCLE5P.js} +12 -13
  177. package/dist/{nsis-fiiOqLc3.js → nsis-Cah9xkdT.js} +1 -1
  178. package/dist/{ntriples-jV77I4k8.js → ntriples-CQoaLOV6.js} +2 -2
  179. package/dist/{number-overlay-editor-CDufNBLN.js → number-overlay-editor-Cfam2fQW.js} +17 -22
  180. package/dist/{octave-Cztd01tF.js → octave-CeDj2bTn.js} +1 -1
  181. package/dist/{once-eG8Vmvjd.js → once-NnpX_HnX.js} +1 -1
  182. package/dist/{oz-Bl8o3BDl.js → oz-BksQrg3k.js} +1 -1
  183. package/dist/packet-AYTQ26CC-DEMHgLPq.js +2 -0
  184. package/dist/{pascal-BO5JqysR.js → pascal-BKL17mpl.js} +1 -1
  185. package/dist/{pegDiagram-XKGWAZYB-CMpp1OOQ.js → pegDiagram-XKGWAZYB-BFQuPYfI.js} +5 -5
  186. package/dist/pencil-DVYzq-iR.js +10 -0
  187. package/dist/{perl-Drlh9s6m.js → perl-CacqJ-Ss.js} +1 -1
  188. package/dist/pick-DgpAbcwP.js +35 -0
  189. package/dist/pie-WAS4IAKB-DMjTEeHd.js +2 -0
  190. package/dist/{pieDiagram-E7YTZNPT-DlMWg5t1.js → pieDiagram-E7YTZNPT-l7aqNrem.js} +7 -7
  191. package/dist/{pig-BWGR8wZw.js → pig-CXSGZ_K9.js} +1 -1
  192. package/dist/{powershell-DT99xlz_.js → powershell-DY_yIxBM.js} +3 -6
  193. package/dist/precisionRound-DMIVQrt2.js +97 -0
  194. package/dist/{process-output-DD-oSvZk.js → process-output-DthYR2Te.js} +19 -30
  195. package/dist/{properties-Q-rkxld0.js → properties-Om0IDE07.js} +1 -1
  196. package/dist/{protobuf-DKyWZbs7.js → protobuf-B8nxxb4Q.js} +1 -1
  197. package/dist/{pug-42ZJUbEC.js → pug-lkUBPvVS.js} +3 -7
  198. package/dist/{puppet-B4UozHhh.js → puppet-DMkXsi4d.js} +1 -1
  199. package/dist/purify.es-DmnrIjg4.js +877 -0
  200. package/dist/{python-DREjAV__.js → python-JQVycMgr.js} +1 -1
  201. package/dist/{q-Bi63IpBO.js → q-DqE__nNB.js} +1 -1
  202. package/dist/{quadrantDiagram-AXDQQJYC-Blrm7V7_.js → quadrantDiagram-AXDQQJYC-nGFBFig7.js} +3 -3
  203. package/dist/{r-DSwXWKMR.js → r-Cbliap7Q.js} +1 -1
  204. package/dist/radar-RG4KPBEZ-9PwdCvai.js +2 -0
  205. package/dist/railroad-74A4TZTK-8N9kF5jl.js +2 -0
  206. package/dist/railroad-abnf-HS5TGJTU-Sg6YmzlR.js +2 -0
  207. package/dist/railroad-ebnf-LZEXJU2U-CYwp2Oee.js +2 -0
  208. package/dist/railroad-peg-WCYAUIDC-BfDkAuQ3.js +2 -0
  209. package/dist/{railroadDiagram-O6MQD6OU-DBJfseeO.js → railroadDiagram-O6MQD6OU-6R3C1lwQ.js} +5 -5
  210. package/dist/{react-sHtZdjeP.js → react-Bgs_wQh3.js} +3 -3
  211. package/dist/{react-dom-DUmH0GXv.js → react-dom-DdqGVp5N.js} +5 -5
  212. package/dist/{react-vega-C4T9Rb_w.js → react-vega-CGgQEf0O.js} +13800 -17236
  213. package/dist/{requirementDiagram-BXWQKSXE-BC7V639r.js → requirementDiagram-BXWQKSXE-DdWYu8fn.js} +13 -13
  214. package/dist/{reveal-component-BTMViKBQ.js → reveal-component-CfIt-nJV.js} +1003 -1117
  215. package/dist/{rolldown-runtime-Cb76FRpK.js → rolldown-runtime-BPCzCO3I.js} +1 -1
  216. package/dist/{rpm-DPb1DeKM.js → rpm-DmT_LNpE.js} +1 -1
  217. package/dist/{ruby-U7fZA4DP.js → ruby-BHVZTtLW.js} +1 -1
  218. package/dist/{sankeyDiagram-P5KCCOFB-ELvOcnZH.js → sankeyDiagram-P5KCCOFB-CrOfyc2n.js} +2 -2
  219. package/dist/{sas-CLk1JpTn.js → sas-CrG5N1he.js} +1 -1
  220. package/dist/{scheme-CT-2k2Tl.js → scheme-BHUnz-IB.js} +1 -1
  221. package/dist/select-CDUxhHZg.js +1198 -0
  222. package/dist/{sequenceDiagram-WJ2MYXX4-CgesU6F-.js → sequenceDiagram-WJ2MYXX4-Dzp0dgRc.js} +6 -6
  223. package/dist/{shell-BLO7fcsk.js → shell-C5IBmRU5.js} +1 -1
  224. package/dist/{sieve-nG3C7WNH.js → sieve-BzCnt_E6.js} +2 -2
  225. package/dist/{sizeCapture-INFHLROL-Dx5SpkQF.js → sizeCapture-INFHLROL-DBeZ20mI.js} +1 -1
  226. package/dist/{smalltalk-BROcZybA.js → smalltalk-DQFAQul3.js} +1 -1
  227. package/dist/{solr-mVltHNc5.js → solr-BiapYPCk.js} +1 -1
  228. package/dist/{sparql-Cv1Ksr4v.js → sparql-BcUKO1is.js} +1 -1
  229. package/dist/{spec-CcT0slVc.js → spec-ZAt4P01J.js} +84 -57
  230. package/dist/{src-CA_m4ONl.js → src-D5uZaZib.js} +8 -14
  231. package/dist/{stateDiagram-D77RDMKH-lH_BUhs3.js → stateDiagram-D77RDMKH-BGnTUhFJ.js} +18 -18
  232. package/dist/stateDiagram-v2-MP3YSRHH-DsJbmDf1.js +30 -0
  233. package/dist/static-state-C4bAlKTU.js +68 -0
  234. package/dist/{stex-Btf3omL8.js → stex-CQ_aCGTF.js} +1 -1
  235. package/dist/style.css +1 -1
  236. package/dist/{stylus-Dt4VvLXL.js → stylus-D4gHF5lg.js} +1 -1
  237. package/dist/{swift-DHsn_CVI.js → swift-CnvIBnbt.js} +1 -1
  238. package/dist/{swimlanes-42K2YHIH-Cuf9B9kE.js → swimlanes-42K2YHIH-Bd4Bzh9r.js} +37 -59
  239. package/dist/swimlanesDiagram-VR7AAH4N-BlY12Jf6.js +30 -0
  240. package/dist/{swiper-component-DfhRvAFi.js → swiper-component-DTdNB9wg.js} +45 -78
  241. package/dist/{tcl-CV0OLBOl.js → tcl-DkOjjZYO.js} +1 -1
  242. package/dist/{textile-D320oKVM.js → textile-DgzBVSEW.js} +1 -1
  243. package/dist/{tiki-BF2aDPlB.js → tiki-MighF8A_.js} +1 -1
  244. package/dist/{time-BaMbJs4z.js → time-BlOl70lB.js} +19 -19
  245. package/dist/{timeline-definition-24CTP7MA-yzzw4TF4.js → timeline-definition-24CTP7MA-m0LanyCH.js} +5 -5
  246. package/dist/toast-U3NpO2x3.js +491 -0
  247. package/dist/{toml-CaUN7UHo.js → toml-B0B7UAba.js} +1 -1
  248. package/dist/{tooltip-CKO1pHJo.js → tooltip-UzJukb3F.js} +336 -312
  249. package/dist/treeView-Q6P3EWNA-BQywp0E1.js +2 -0
  250. package/dist/treemap-WGGIJYW6-P2ZJnldw.js +2 -0
  251. package/dist/{troff-DQUFcClZ.js → troff-B4IRX71y.js} +1 -1
  252. package/dist/{ttcn-CQL1duJS.js → ttcn-B4tpvdJD.js} +1 -1
  253. package/dist/{ttcn-cfg-BMmEFJPu.js → ttcn-cfg-pfE-1FV8.js} +1 -1
  254. package/dist/{turtle-C3esgsRr.js → turtle-Bc97ufp6.js} +1 -1
  255. package/dist/use-restore-focus-DaTVz6S6.js +7672 -0
  256. package/dist/{use-vega-container-remeasure-Bz4PZMtt.js → use-vega-container-remeasure-BrUpWQfF.js} +4 -8
  257. package/dist/{useAsyncData-D0mLJstx.js → useAsyncData-P5-Oovhq.js} +7 -7
  258. package/dist/{useDateFormatter-c_yJtkAe.js → useDateFormatter-LQNtoXyh.js} +5 -5
  259. package/dist/useDeepCompareMemoize-CmNbQ9TT.js +53 -0
  260. package/dist/useEvent-BoN7U38T.js +19 -0
  261. package/dist/{useIframeCapabilities-BkdeVdXC.js → useIframeCapabilities-HTZiVlGV.js} +2 -2
  262. package/dist/useLifecycle-DTMczKkf.js +112 -0
  263. package/dist/{vb-RK1eDXRl.js → vb-C5kpOY_q.js} +1 -1
  264. package/dist/{vbscript-BCOeM0de.js → vbscript-Ck0hgOg5.js} +1 -1
  265. package/dist/{vega-component-DgytCKrL.js → vega-component-ZTdbCcwI.js} +221 -227
  266. package/dist/{vega-embed-container--LYZqguO.js → vega-embed-container-DgpACsCB.js} +7 -7
  267. package/dist/{vega-loader.browser-B9Pz0EGP.js → vega-loader.browser-Co9gYE8Z.js} +637 -294
  268. package/dist/{velocity-CZKOFbOI.js → velocity-2Doc6dgJ.js} +1 -1
  269. package/dist/{vennDiagram-4TSXK5OY-eJOrTqqC.js → vennDiagram-4TSXK5OY-BJ7vqDmn.js} +4 -4
  270. package/dist/{verilog-DqQTzVn8.js → verilog-CmZmYe4R.js} +2 -2
  271. package/dist/{vhdl-vQr2bfmi.js → vhdl-esMnUHZm.js} +1 -1
  272. package/dist/wardley-WFR3VGLG-CIBJ6O2G.js +2 -0
  273. package/dist/{wardleyDiagram-VM6X3IG4-TILPvee6.js → wardleyDiagram-VM6X3IG4-D5kWacsn.js} +5 -5
  274. package/dist/{webidl-DzX7N40e.js → webidl-G_RlXG7G.js} +1 -1
  275. package/dist/{xquery-Cw_Q_hGR.js → xquery-IUQpMoMl.js} +1 -1
  276. package/dist/{xychartDiagram-S5SC5T6Z-DUPvRwwJ.js → xychartDiagram-S5SC5T6Z-gr15Ws_z.js} +8 -8
  277. package/dist/{yacas-DiC4jJBE.js → yacas-ObL0t2h9.js} +1 -1
  278. package/dist/{z80-CUOQDEJO.js → z80-jyuJhy0k.js} +1 -1
  279. package/package.json +38 -42
  280. package/src/__mocks__/document.tsx +64 -0
  281. package/src/__mocks__/executions.ts +301 -0
  282. package/src/__mocks__/notebook.ts +39 -46
  283. package/src/__mocks__/partial.ts +26 -0
  284. package/src/__mocks__/requests.ts +2 -8
  285. package/src/__tests__/CellStatus.test.tsx +25 -26
  286. package/src/__tests__/fixtures/pair-config.ts +1 -1
  287. package/src/__tests__/main.test.tsx +24 -1
  288. package/src/__tests__/module-entry.test.ts +44 -0
  289. package/src/__tests__/mount.test.ts +17 -58
  290. package/src/__tests__/{host-imports.test.ts → replica-imports.test.ts} +11 -11
  291. package/src/components/ai/__tests__/ai-model-dropdown.test.tsx +63 -0
  292. package/src/components/ai/__tests__/ai-utils.test.ts +8 -0
  293. package/src/components/ai/ai-model-dropdown.tsx +11 -6
  294. package/src/components/app-config/__tests__/add-model-discovery.test.tsx +255 -0
  295. package/src/components/app-config/__tests__/model-discovery.test.tsx +183 -0
  296. package/src/components/app-config/__tests__/state.test.tsx +50 -0
  297. package/src/components/app-config/ai-config.tsx +200 -187
  298. package/src/components/app-config/app-config-button.tsx +6 -5
  299. package/src/components/app-config/app-config-form.tsx +5 -9
  300. package/src/components/app-config/common.tsx +7 -9
  301. package/src/components/app-config/data-form.tsx +113 -116
  302. package/src/components/app-config/get-dirty-values.ts +4 -4
  303. package/src/components/app-config/mcp-config.tsx +30 -53
  304. package/src/components/app-config/model-discovery.tsx +157 -0
  305. package/src/components/app-config/model-provider-config.ts +25 -0
  306. package/src/components/app-config/state.ts +2 -0
  307. package/src/components/app-config/user-config-form.css +91 -0
  308. package/src/components/app-config/user-config-form.tsx +278 -350
  309. package/src/components/chat/__tests__/capabilities-popover.test.tsx +0 -1
  310. package/src/components/chat/__tests__/chat-display.test.tsx +196 -0
  311. package/src/components/chat/__tests__/chat-markdown.test.tsx +43 -0
  312. package/src/components/chat/__tests__/chat-utils.test.ts +141 -1
  313. package/src/components/chat/__tests__/message-queue.test.tsx +94 -1
  314. package/src/components/chat/__tests__/notebook-access-selector.test.tsx +64 -0
  315. package/src/components/chat/__tests__/notebook-context.test.ts +199 -0
  316. package/src/components/chat/__tests__/pending-chat-prompt.test.tsx +568 -0
  317. package/src/components/chat/__tests__/turn-timing.test.ts +84 -0
  318. package/src/components/chat/__tests__/use-assistant-turn.test.ts +95 -0
  319. package/src/components/chat/__tests__/useFileState.test.tsx +176 -15
  320. package/src/components/chat/__tests__/user-message.test.tsx +27 -0
  321. package/src/components/chat/acp/__tests__/agent-panel-initialization.test.tsx +1 -1
  322. package/src/components/chat/acp/__tests__/agent-panel.test.tsx +22 -17
  323. package/src/components/chat/acp/__tests__/session-tabs.test.tsx +43 -0
  324. package/src/components/chat/acp/agent-panel.tsx +6 -3
  325. package/src/components/chat/acp/blocks.tsx +11 -10
  326. package/src/components/chat/acp/common.tsx +4 -5
  327. package/src/components/chat/acp/model-selector.tsx +1 -1
  328. package/src/components/chat/acp/session-tabs.tsx +8 -3
  329. package/src/components/chat/agent-activity.tsx +132 -0
  330. package/src/components/chat/capabilities-popover.tsx +2 -11
  331. package/src/components/chat/chat-components.tsx +10 -6
  332. package/src/components/chat/chat-display.tsx +131 -57
  333. package/src/components/chat/chat-history-popover.tsx +6 -1
  334. package/src/components/chat/chat-markdown.tsx +15 -0
  335. package/src/components/chat/chat-panel.tsx +422 -358
  336. package/src/components/chat/chat-typography.css +108 -0
  337. package/src/components/chat/chat-utils.ts +168 -61
  338. package/src/components/chat/notebook-access-selector.stories.tsx +22 -0
  339. package/src/components/chat/notebook-access-selector.tsx +100 -0
  340. package/src/components/chat/notebook-context.ts +80 -0
  341. package/src/components/chat/tool-call/__tests__/tool-labels.test.ts +76 -0
  342. package/src/components/chat/tool-call/__tests__/tool-step.test.tsx +57 -0
  343. package/src/components/chat/tool-call/shared.ts +6 -0
  344. package/src/components/chat/tool-call/tool-call-view.tsx +22 -76
  345. package/src/components/chat/tool-call/tool-labels.ts +172 -0
  346. package/src/components/chat/tool-call/tool-result.tsx +1 -1
  347. package/src/components/chat/tool-call/tool-step.tsx +145 -0
  348. package/src/components/chat/turn-timing.ts +73 -0
  349. package/src/components/chat/use-assistant-turn.ts +65 -0
  350. package/src/components/chat/use-chat-generation.ts +20 -0
  351. package/src/components/chat/user-message.tsx +154 -0
  352. package/src/components/data-table/TableBottomBar.tsx +4 -1
  353. package/src/components/data-table/TableTopBar.tsx +2 -0
  354. package/src/components/data-table/__tests__/chart-spec-model.test.ts +195 -195
  355. package/src/components/data-table/__tests__/data-table.test.tsx +1 -0
  356. package/src/components/data-table/__tests__/keyboard-selection.test.tsx +188 -0
  357. package/src/components/data-table/__tests__/pagination.test.tsx +28 -1
  358. package/src/components/data-table/charts/__tests__/altair-generator.test.ts +42 -27
  359. package/src/components/data-table/charts/__tests__/spec-snapshot.test.ts +20 -20
  360. package/src/components/data-table/charts/__tests__/spec.test.ts +78 -52
  361. package/src/components/data-table/charts/chart-spec/altair-generator.ts +2 -6
  362. package/src/components/data-table/charts/chart-spec/spec.ts +68 -43
  363. package/src/components/data-table/charts/charts.tsx +5 -5
  364. package/src/components/data-table/column-formatting/types.ts +1 -2
  365. package/src/components/data-table/column-summary/chart-spec-model.tsx +23 -16
  366. package/src/components/data-table/data-table.tsx +10 -0
  367. package/src/components/data-table/pagination.tsx +44 -33
  368. package/src/components/data-table/range-focus/atoms.ts +4 -6
  369. package/src/components/data-table/range-focus/use-cell-range-selection.ts +65 -38
  370. package/src/components/data-table/range-focus/use-scroll-into-view.ts +21 -2
  371. package/src/components/data-table/renderers.tsx +16 -7
  372. package/src/components/data-table/row-viewer-panel/__tests__/row-viewer.test.tsx +24 -1
  373. package/src/components/data-table/row-viewer-panel/row-viewer.tsx +2 -2
  374. package/src/components/datasources/__tests__/column-preview.test.tsx +41 -11
  375. package/src/components/datasources/__tests__/datasources-interactions.test.tsx +334 -0
  376. package/src/components/datasources/__tests__/table-list.test.tsx +51 -1
  377. package/src/components/datasources/__tests__/utils.test.ts +117 -7
  378. package/src/components/datasources/column-preview.tsx +9 -10
  379. package/src/components/datasources/datasources.tsx +22 -22
  380. package/src/components/datasources/utils.ts +41 -27
  381. package/src/components/dependency-graph/__tests__/elements.test.ts +20 -11
  382. package/src/components/dependency-graph/custom-node.tsx +1 -1
  383. package/src/components/dependency-graph/dependency-graph-tree.tsx +23 -9
  384. package/src/components/dependency-graph/elements.ts +34 -44
  385. package/src/components/dependency-graph/minimap-content.tsx +15 -20
  386. package/src/components/dependency-graph/panels.tsx +2 -1
  387. package/src/components/dependency-graph/utils/__tests__/layout.test.ts +18 -11
  388. package/src/components/editor/Output.tsx +5 -4
  389. package/src/components/editor/__tests__/Output.test.tsx +50 -32
  390. package/src/{core/attachments/__tests__/toast.test.tsx → components/editor/__tests__/agent-toast.test.tsx} +1 -1
  391. package/src/components/editor/__tests__/data-attributes.test.tsx +39 -32
  392. package/src/components/editor/__tests__/dynamic-favicon.test.tsx +11 -16
  393. package/src/components/editor/__tests__/output-persistence.test.tsx +33 -32
  394. package/src/components/editor/__tests__/package-alert.test.tsx +22 -1
  395. package/src/components/editor/actions/__tests__/name-cell-input.test.tsx +70 -0
  396. package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +21 -40
  397. package/src/components/editor/actions/__tests__/pair-with-agent-modal.test.tsx +40 -14
  398. package/src/components/editor/actions/__tests__/pair-with-agent.test.tsx +6 -24
  399. package/src/components/editor/actions/__tests__/useCellActionButton.test.tsx +132 -0
  400. package/src/components/editor/actions/__tests__/useSetOutputsExpanded.test.ts +8 -9
  401. package/src/components/editor/actions/name-cell-input.tsx +4 -3
  402. package/src/components/editor/actions/pair-with-agent-commands.ts +10 -7
  403. package/src/components/editor/actions/pair-with-agent-modal.tsx +15 -18
  404. package/src/components/editor/actions/pair-with-agent.tsx +16 -39
  405. package/src/components/editor/actions/useCellActionButton.tsx +47 -35
  406. package/src/components/editor/actions/useConfigActions.tsx +3 -4
  407. package/src/components/editor/actions/useNotebookActions.tsx +25 -29
  408. package/src/components/editor/actions/useRestartKernel.tsx +0 -5
  409. package/src/components/editor/actions/useSetCodeVisibility.ts +11 -12
  410. package/src/components/editor/actions/useSetOutputsExpanded.ts +24 -24
  411. package/src/components/editor/ai/ai-completion-editor.tsx +1 -1
  412. package/src/components/editor/ai/completion-handlers.tsx +0 -37
  413. package/src/components/editor/ai/prompt-input.tsx +189 -0
  414. package/src/components/editor/alerts/__tests__/connection-notice.test.tsx +1 -1
  415. package/src/components/editor/alerts/connection-notice.tsx +1 -1
  416. package/src/components/editor/app-container.tsx +1 -1
  417. package/src/components/editor/boundary/ErrorBoundary.tsx +6 -2
  418. package/src/components/editor/boundary/__tests__/ErrorBoundary.test.tsx +5 -1
  419. package/src/components/editor/cell/CellStatus.tsx +47 -57
  420. package/src/components/editor/cell/CreateCellButton.tsx +7 -11
  421. package/src/components/editor/cell/DeleteButton.tsx +4 -4
  422. package/src/components/editor/cell/ReusableDefinitionBadge.tsx +62 -0
  423. package/src/components/editor/cell/RunButton.tsx +18 -8
  424. package/src/components/editor/cell/StagedAICell.tsx +52 -137
  425. package/src/components/editor/cell/StopButton.tsx +7 -7
  426. package/src/components/editor/cell/__tests__/useRunCells.test.tsx +149 -0
  427. package/src/components/editor/cell/cell-actions.tsx +12 -1
  428. package/src/components/editor/cell/cell-context-menu.tsx +24 -4
  429. package/src/components/editor/cell/code/__tests__/language-toggle.test.tsx +38 -1
  430. package/src/components/editor/cell/code/cell-editor.tsx +66 -169
  431. package/src/components/editor/cell/code/language-toggle.tsx +6 -4
  432. package/src/components/editor/cell/collapse.tsx +16 -6
  433. package/src/components/editor/cell/useAddCell.ts +4 -8
  434. package/src/components/editor/cell/useDeleteCell.tsx +10 -36
  435. package/src/components/editor/cell/useRunCells.ts +70 -59
  436. package/src/components/editor/cell/useSplitCell.tsx +10 -6
  437. package/src/components/editor/chrome/components/__tests__/feedback-button.test.tsx +1 -1
  438. package/src/components/editor/chrome/components/feedback-button.tsx +2 -8
  439. package/src/components/editor/chrome/panels/__tests__/packages-panel.test.tsx +1 -1
  440. package/src/components/editor/chrome/panels/__tests__/runtime-details.test.tsx +1 -1
  441. package/src/components/editor/chrome/panels/__tests__/sandbox-recovery.test.tsx +1 -1
  442. package/src/components/editor/chrome/panels/dependency-graph-panel.tsx +1 -1
  443. package/src/components/editor/chrome/panels/logs-panel.tsx +2 -1
  444. package/src/components/editor/chrome/panels/outline/__tests__/outline-keyboard.test.tsx +84 -0
  445. package/src/components/editor/chrome/panels/outline/floating-outline.tsx +39 -14
  446. package/src/components/editor/chrome/panels/outline/useActiveOutline.tsx +3 -2
  447. package/src/components/editor/chrome/panels/panel-header.tsx +13 -0
  448. package/src/components/editor/chrome/panels/secrets-panel.tsx +1 -0
  449. package/src/components/editor/chrome/panels/session-panel.tsx +1 -1
  450. package/src/components/editor/chrome/panels/snippets-panel.tsx +10 -12
  451. package/src/components/editor/chrome/panels/variable-panel.tsx +1 -5
  452. package/src/components/editor/chrome/types.ts +1 -1
  453. package/src/components/editor/chrome/wrapper/__tests__/attachment-status.test.tsx +8 -10
  454. package/src/components/editor/chrome/wrapper/__tests__/document-sync-status.test.tsx +97 -0
  455. package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +230 -59
  456. package/src/components/editor/chrome/wrapper/__tests__/useAskAiAboutCell.test.tsx +58 -0
  457. package/src/components/editor/chrome/wrapper/app-chrome.tsx +91 -74
  458. package/src/components/editor/chrome/wrapper/footer-items/attachment-status.tsx +5 -5
  459. package/src/components/editor/chrome/wrapper/footer-items/backend-status.tsx +3 -17
  460. package/src/components/editor/chrome/wrapper/footer-items/document-sync-status.tsx +54 -0
  461. package/src/components/editor/chrome/wrapper/footer-items/lsp-status.tsx +1 -1
  462. package/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsx +1 -1
  463. package/src/components/editor/chrome/wrapper/footer.tsx +2 -2
  464. package/src/components/editor/chrome/wrapper/minimap-state.ts +1 -1
  465. package/src/components/editor/chrome/wrapper/pending-ai-cells.tsx +143 -82
  466. package/src/components/editor/chrome/wrapper/pending-ai-changes-badge.tsx +25 -0
  467. package/src/components/editor/chrome/wrapper/sidebar.tsx +8 -4
  468. package/src/components/editor/chrome/wrapper/useAskAiAboutCell.ts +36 -0
  469. package/src/components/editor/columns/__tests__/cell-column.test.tsx +1 -1
  470. package/src/components/editor/columns/cell-column.tsx +1 -1
  471. package/src/components/editor/columns/sortable-column.tsx +2 -2
  472. package/src/components/editor/connections/components.tsx +4 -9
  473. package/src/components/editor/controls/Controls.tsx +9 -6
  474. package/src/components/editor/controls/__tests__/keyboard-shortcuts.test.tsx +61 -0
  475. package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +10 -4
  476. package/src/components/editor/controls/keyboard-shortcuts.tsx +14 -5
  477. package/src/components/editor/documentation.css +34 -11
  478. package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +106 -79
  479. package/src/components/editor/errors/auto-fix.tsx +4 -8
  480. package/src/components/editor/errors/send-error-report-button.tsx +3 -6
  481. package/src/components/editor/file-tree/__tests__/file-explorer-navigation.test.tsx +47 -0
  482. package/src/components/editor/file-tree/file-explorer.tsx +38 -10
  483. package/src/components/editor/file-tree/file-name-input.tsx +1 -0
  484. package/src/components/editor/header/__tests__/filename-form.test.tsx +1 -4
  485. package/src/components/editor/header/__tests__/status.test.tsx +5 -3
  486. package/src/components/editor/header/app-header.tsx +1 -1
  487. package/src/components/editor/header/filename-form.tsx +1 -1
  488. package/src/components/editor/header/status.tsx +44 -22
  489. package/src/components/editor/links/__tests__/cell-link.test.tsx +148 -0
  490. package/src/components/editor/links/cell-link-list.tsx +1 -1
  491. package/src/components/editor/links/cell-link.tsx +21 -11
  492. package/src/components/editor/navigation/__tests__/clipboard.test.ts +60 -38
  493. package/src/components/editor/navigation/__tests__/navigation.test.ts +109 -85
  494. package/src/components/editor/navigation/__tests__/selection.test.ts +43 -21
  495. package/src/components/editor/navigation/clipboard.ts +17 -14
  496. package/src/components/editor/navigation/focus-utils.ts +23 -4
  497. package/src/components/editor/navigation/multi-cell-action-toolbar.tsx +17 -33
  498. package/src/components/editor/navigation/navigation.ts +74 -72
  499. package/src/components/editor/navigation/selection.ts +30 -29
  500. package/src/components/editor/notebook-cell.tsx +143 -256
  501. package/src/components/editor/output/MarimoErrorOutput.tsx +41 -4
  502. package/src/components/editor/output/MarimoTracebackOutput.tsx +17 -15
  503. package/src/components/editor/output/Outputs.css +8 -0
  504. package/src/components/editor/output/VideoOutput.tsx +6 -0
  505. package/src/components/editor/output/__tests__/VideoOutput.test.tsx +131 -0
  506. package/src/components/editor/output/__tests__/traceback.test.tsx +27 -1
  507. package/src/components/editor/output/ansi-reduce.ts +126 -49
  508. package/src/components/editor/output/console/ConsoleOutput.tsx +34 -26
  509. package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +162 -102
  510. package/src/components/editor/output/console/process-output.ts +4 -2
  511. package/src/components/editor/package-alert.tsx +8 -3
  512. package/src/components/editor/renderers/__tests__/add-cell-buttons.test.tsx +18 -0
  513. package/src/components/editor/renderers/cell-array.tsx +38 -103
  514. package/src/components/editor/renderers/cells-renderer.tsx +2 -3
  515. package/src/components/editor/renderers/grid-layout/__tests__/grid-layout.test.tsx +69 -0
  516. package/src/components/editor/renderers/grid-layout/grid-layout.tsx +30 -28
  517. package/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts +0 -4
  518. package/src/components/editor/renderers/slides-layout/slides-layout.tsx +1 -1
  519. package/src/components/editor/renderers/types.ts +2 -2
  520. package/src/components/editor/renderers/vertical-layout/__tests__/useFocusFirstEditor.test.ts +47 -4
  521. package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +9 -1
  522. package/src/components/editor/renderers/vertical-layout/utils.ts +4 -4
  523. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +20 -46
  524. package/src/components/editor/stdin-blocking-alert.tsx +19 -16
  525. package/src/components/icons/__tests__/copy-icon.test.tsx +63 -0
  526. package/src/components/icons/copy-icon.tsx +9 -2
  527. package/src/components/markdown/__tests__/markdown-renderer.test.tsx +32 -2
  528. package/src/components/markdown/markdown-renderer.tsx +43 -28
  529. package/src/components/mcp/mcp-status-indicator.tsx +18 -14
  530. package/src/components/pages/edit-page.tsx +18 -17
  531. package/src/components/scratchpad/scratchpad.test.tsx +89 -0
  532. package/src/components/scratchpad/scratchpad.tsx +54 -37
  533. package/src/components/scratchpad/state.ts +7 -0
  534. package/src/components/slides/__tests__/cell-output-block.test.tsx +8 -9
  535. package/src/components/slides/__tests__/minimap-actions.test.tsx +25 -32
  536. package/src/components/slides/__tests__/minimap.test.ts +38 -19
  537. package/src/components/slides/__tests__/slide-cell-view.test.tsx +3 -2
  538. package/src/components/slides/__tests__/slide-scroll-hint.test.tsx +37 -0
  539. package/src/components/slides/minimap.tsx +21 -14
  540. package/src/components/slides/reveal-component.tsx +68 -34
  541. package/src/components/slides/reveal-slides.css +5 -4
  542. package/src/components/slides/slide-cell-view.tsx +36 -41
  543. package/src/components/slides/slide-scroll-hint.tsx +3 -1
  544. package/src/components/slides/slide.tsx +4 -5
  545. package/src/components/sort/SortableCellsProvider.tsx +8 -25
  546. package/src/components/static-html/__tests__/static-banner.test.tsx +1 -1
  547. package/src/components/tracing/tracing-keyboard.test.tsx +85 -0
  548. package/src/components/tracing/tracing-spec.ts +11 -1
  549. package/src/components/tracing/tracing.tsx +48 -40
  550. package/src/components/ui/__tests__/draggable-popover.test.tsx +24 -0
  551. package/src/components/ui/__tests__/fullscreen.test.tsx +99 -2
  552. package/src/components/ui/__tests__/range-slider.test.tsx +165 -0
  553. package/src/components/ui/__tests__/select.test.tsx +80 -0
  554. package/src/components/ui/draggable-popover.tsx +24 -2
  555. package/src/components/ui/fullscreen.tsx +43 -3
  556. package/src/components/ui/range-slider.tsx +22 -9
  557. package/src/components/ui/select.tsx +17 -15
  558. package/src/components/ui/slider.tsx +6 -2
  559. package/src/components/ui/toast.tsx +1 -1
  560. package/src/components/variables/__tests__/variables-table.test.tsx +75 -0
  561. package/src/components/variables/variables-table.tsx +18 -10
  562. package/src/core/MarimoApp.tsx +3 -1
  563. package/src/core/ai/__tests__/attachments.test.ts +153 -0
  564. package/src/core/ai/__tests__/staged-cells.test.ts +90 -609
  565. package/src/core/ai/attachments.ts +80 -0
  566. package/src/core/ai/context/__tests__/registry.test.ts +7 -11
  567. package/src/core/ai/context/context.ts +2 -0
  568. package/src/core/ai/context/providers/__tests__/cell-output.test.ts +116 -52
  569. package/src/core/ai/context/providers/__tests__/cell.test.ts +49 -0
  570. package/src/core/ai/context/providers/__tests__/error.test.ts +76 -219
  571. package/src/core/ai/context/providers/cell-output.ts +17 -20
  572. package/src/core/ai/context/providers/cell.ts +54 -0
  573. package/src/core/ai/staged-cells.ts +56 -323
  574. package/src/core/ai/state.ts +3 -0
  575. package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +47 -93
  576. package/src/core/ai/tools/__tests__/registry.test.ts +17 -0
  577. package/src/core/ai/tools/base.ts +18 -15
  578. package/src/core/ai/tools/edit-notebook-tool.ts +86 -80
  579. package/src/core/ai/tools/registry.ts +13 -10
  580. package/src/core/ai/tools/sample-tool.ts +6 -7
  581. package/src/core/cells/__tests__/actions.test.ts +623 -35
  582. package/src/core/cells/__tests__/add-missing-import.test.ts +7 -8
  583. package/src/core/cells/__tests__/arrange.test.ts +432 -0
  584. package/src/core/cells/__tests__/cell.test.ts +56 -308
  585. package/src/core/cells/__tests__/cells.test.ts +327 -3808
  586. package/src/core/cells/__tests__/clear-outputs.test.ts +156 -0
  587. package/src/core/cells/__tests__/collapseConsoleOutputs.test.ts +86 -2
  588. package/src/core/cells/__tests__/document.test.ts +158 -0
  589. package/src/core/cells/__tests__/editor.test.ts +57 -0
  590. package/src/core/cells/__tests__/flush-document.test.ts +42 -0
  591. package/src/core/cells/__tests__/harness.ts +113 -0
  592. package/src/core/cells/__tests__/layout.test.ts +186 -0
  593. package/src/core/cells/__tests__/logs.test.ts +18 -42
  594. package/src/core/cells/__tests__/notebook-outline.test.ts +72 -57
  595. package/src/core/cells/__tests__/outputs.test.tsx +71 -53
  596. package/src/core/cells/__tests__/pending-delete-service.test.tsx +11 -20
  597. package/src/core/cells/__tests__/runs.test.ts +127 -430
  598. package/src/core/cells/__tests__/session.test.ts +560 -336
  599. package/src/core/cells/__tests__/utils.test.ts +166 -338
  600. package/src/core/cells/actions.ts +738 -6
  601. package/src/core/cells/add-missing-import.ts +48 -47
  602. package/src/core/cells/arrange.ts +529 -0
  603. package/src/core/cells/cell.ts +36 -225
  604. package/src/core/cells/cells.ts +245 -1549
  605. package/src/core/cells/collapseConsoleOutputs.tsx +71 -40
  606. package/src/core/cells/columns.ts +38 -0
  607. package/src/core/cells/command-console.ts +46 -0
  608. package/src/core/cells/document.ts +167 -0
  609. package/src/core/cells/edit.ts +30 -0
  610. package/src/core/cells/editor.ts +82 -0
  611. package/src/core/cells/execution-console.ts +236 -0
  612. package/src/core/cells/focus.ts +20 -14
  613. package/src/core/cells/layout.ts +228 -0
  614. package/src/core/cells/logs.ts +10 -2
  615. package/src/core/cells/outputs.ts +14 -30
  616. package/src/core/cells/pending-delete-service.ts +6 -8
  617. package/src/core/cells/reusable-definition.ts +25 -0
  618. package/src/core/cells/runs.ts +70 -118
  619. package/src/core/cells/scrollCellIntoView.ts +6 -0
  620. package/src/core/cells/session.ts +176 -101
  621. package/src/core/cells/types.ts +32 -64
  622. package/src/core/cells/useAnswerPrompt.ts +29 -0
  623. package/src/core/cells/utils.ts +113 -102
  624. package/src/core/codemirror/__tests__/format.test.ts +4 -36
  625. package/src/core/codemirror/__tests__/setup.test.ts +66 -33
  626. package/src/core/codemirror/ai/__tests__/resources.test.ts +113 -0
  627. package/src/core/codemirror/ai/resources.ts +1 -1
  628. package/src/core/codemirror/cells/__tests__/debugger-state.test.ts +0 -20
  629. package/src/core/codemirror/cells/__tests__/extensions.test.ts +2 -6
  630. package/src/core/codemirror/cells/debugger-state.ts +7 -11
  631. package/src/core/codemirror/cells/extensions.ts +18 -30
  632. package/src/core/codemirror/cells/state.ts +2 -6
  633. package/src/core/codemirror/cm.ts +5 -1
  634. package/src/core/codemirror/config/types.ts +1 -1
  635. package/src/core/codemirror/copilot/__tests__/completion-integration.test.ts +4 -0
  636. package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +13 -12
  637. package/src/core/codemirror/copilot/extension.ts +0 -26
  638. package/src/core/codemirror/copilot/getCodes.ts +3 -3
  639. package/src/core/codemirror/format.ts +6 -23
  640. package/src/core/codemirror/keymaps/vim.ts +2 -2
  641. package/src/core/codemirror/language/__tests__/extension.test.ts +9 -7
  642. package/src/core/codemirror/language/__tests__/markdown.test.ts +7 -7
  643. package/src/core/codemirror/language/__tests__/sql-literals.test.ts +588 -0
  644. package/src/core/codemirror/language/__tests__/sql.test.ts +123 -28
  645. package/src/core/codemirror/language/__tests__/utils.test.ts +194 -19
  646. package/src/core/codemirror/language/cell-code.ts +114 -0
  647. package/src/core/codemirror/language/extension.ts +52 -35
  648. package/src/core/codemirror/language/languages/markdown.ts +8 -6
  649. package/src/core/codemirror/language/languages/python.ts +16 -10
  650. package/src/core/codemirror/language/languages/sql/completion-builder.ts +31 -14
  651. package/src/core/codemirror/language/languages/sql/completion-context.ts +197 -0
  652. package/src/core/codemirror/language/languages/sql/completion-sources.tsx +109 -0
  653. package/src/core/codemirror/language/languages/sql/sql.ts +21 -28
  654. package/src/core/codemirror/language/types.ts +7 -7
  655. package/src/core/codemirror/language/utils.ts +9 -39
  656. package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +1 -2
  657. package/src/core/codemirror/lsp/notebook-lsp.ts +6 -5
  658. package/src/core/codemirror/lsp/utils.ts +1 -1
  659. package/src/core/codemirror/misc/__tests__/paste.test.ts +3 -1
  660. package/src/core/codemirror/misc/paste.ts +1 -1
  661. package/src/core/codemirror/placeholder/__tests__/extensions.test.ts +75 -0
  662. package/src/core/codemirror/placeholder/extensions.ts +80 -19
  663. package/src/core/codemirror/readonly/__tests__/extension.test.ts +1 -1
  664. package/src/core/codemirror/readonly/extension.ts +2 -2
  665. package/src/core/codemirror/utils.ts +1 -0
  666. package/src/core/config/__tests__/app-config.test.ts +64 -0
  667. package/src/core/config/__tests__/config-schema.test.ts +195 -17
  668. package/src/core/config/config-schema.ts +138 -20
  669. package/src/core/config/config.ts +69 -20
  670. package/src/core/config/feature-flag.tsx +0 -2
  671. package/src/core/datasets/__tests__/data-source-discovery.test.ts +1 -1
  672. package/src/core/documentation/doc-lookup.ts +1 -1
  673. package/src/core/dom/__tests__/outline.test.ts +23 -0
  674. package/src/core/dom/outline.ts +4 -1
  675. package/src/core/edit-app.tsx +28 -38
  676. package/src/core/errors/__tests__/error-entries.test.ts +74 -1
  677. package/src/core/errors/error-entries.ts +28 -16
  678. package/src/core/executions/__tests__/atoms.test.ts +218 -0
  679. package/src/core/executions/__tests__/freshness.test.ts +503 -0
  680. package/src/core/executions/__tests__/hooks.test.tsx +198 -0
  681. package/src/core/executions/__tests__/input.test.ts +86 -0
  682. package/src/core/executions/__tests__/interrupt.test.ts +206 -0
  683. package/src/core/executions/__tests__/output-lifecycle.test.ts +260 -0
  684. package/src/core/executions/__tests__/output.test.ts +336 -0
  685. package/src/core/executions/__tests__/run.test.ts +396 -0
  686. package/src/core/executions/__tests__/select.test.ts +409 -0
  687. package/src/core/executions/atoms.ts +399 -0
  688. package/src/core/executions/freshness.ts +174 -0
  689. package/src/core/executions/hooks.ts +119 -0
  690. package/src/core/executions/index.ts +58 -0
  691. package/src/core/executions/input.ts +56 -0
  692. package/src/core/executions/interrupt.ts +49 -0
  693. package/src/core/executions/output.ts +337 -0
  694. package/src/core/executions/run.ts +107 -0
  695. package/src/core/executions/select.ts +271 -0
  696. package/src/core/export/__tests__/hooks.test.ts +18 -34
  697. package/src/core/export/hooks.ts +8 -10
  698. package/src/core/export/layout.ts +2 -2
  699. package/src/core/hotkeys/hotkeys.ts +2 -1
  700. package/src/core/islands/__tests__/bootstrap.test.ts +69 -17
  701. package/src/core/islands/__tests__/bridge.test.ts +163 -65
  702. package/src/core/islands/__tests__/iframe-resizer.test.ts +91 -0
  703. package/src/core/islands/__tests__/main.test.ts +17 -0
  704. package/src/core/islands/bootstrap.ts +70 -65
  705. package/src/core/islands/bridge.ts +156 -54
  706. package/src/core/islands/components/IslandControls.tsx +15 -7
  707. package/src/core/islands/components/__tests__/IslandControls.test.tsx +36 -51
  708. package/src/core/islands/components/__tests__/web-components.test.tsx +76 -15
  709. package/src/core/islands/components/output-wrapper.tsx +19 -24
  710. package/src/core/islands/components/web-components.tsx +12 -1
  711. package/src/core/islands/iframe-resizer.ts +38 -0
  712. package/src/core/islands/main.ts +3 -0
  713. package/src/core/islands/stubs/slide-cell-view.tsx +2 -5
  714. package/src/core/islands/worker/__tests__/controller.test.ts +62 -4
  715. package/src/core/islands/worker/controller.ts +4 -10
  716. package/src/core/islands/worker/worker.tsx +84 -52
  717. package/src/core/kernel/__tests__/handlers.test.ts +7 -159
  718. package/src/core/kernel/handlers.ts +12 -141
  719. package/src/core/kernel/messages.ts +0 -1
  720. package/src/core/kernel/state.ts +0 -15
  721. package/src/core/lifecycle/render-policy.ts +16 -27
  722. package/src/core/meta/__tests__/code-visibility.test.tsx +78 -70
  723. package/src/core/meta/code-visibility.ts +18 -9
  724. package/src/core/network/__tests__/ai.test.ts +41 -0
  725. package/src/core/network/__tests__/connection.test.ts +1 -1
  726. package/src/core/network/__tests__/requests-network.test.ts +0 -16
  727. package/src/core/network/__tests__/requests-toasting.test.tsx +7 -7
  728. package/src/core/network/ai.ts +12 -0
  729. package/src/core/network/connection-notice.ts +1 -1
  730. package/src/core/network/connection.ts +1 -6
  731. package/src/core/network/requests-network.ts +10 -64
  732. package/src/core/network/requests-static.ts +2 -11
  733. package/src/core/network/requests-toasting.tsx +3 -57
  734. package/src/core/network/resolve.ts +1 -5
  735. package/src/core/network/types.ts +7 -22
  736. package/src/core/notebook/__tests__/operations.test.ts +51 -0
  737. package/src/core/notebook/attachments.ts +38 -0
  738. package/src/core/notebook/document/__tests__/codemirror.test.ts +768 -0
  739. package/src/core/{document → notebook/document}/__tests__/draft.test.ts +71 -31
  740. package/src/core/{document → notebook/document}/__tests__/fixtures.ts +2 -2
  741. package/src/core/notebook/document/__tests__/hooks.test.tsx +392 -0
  742. package/src/core/notebook/document/__tests__/lifecycle-scenarios.test.ts +61 -0
  743. package/src/core/notebook/document/__tests__/model.test.ts +252 -0
  744. package/src/core/notebook/document/__tests__/protocol-fixtures.ts +38 -0
  745. package/src/core/notebook/document/__tests__/recovery-scenarios.test.ts +259 -0
  746. package/src/core/notebook/document/__tests__/scenario-fixture.ts +44 -0
  747. package/src/core/notebook/document/__tests__/scenarios.test.ts +279 -0
  748. package/src/core/{document/__tests__/model.test.ts → notebook/document/__tests__/state.test.ts} +48 -24
  749. package/src/core/notebook/document/__tests__/submission.test.ts +204 -0
  750. package/src/core/notebook/document/__tests__/test-host.test.ts +92 -0
  751. package/src/core/notebook/document/__tests__/test-host.ts +223 -0
  752. package/src/core/notebook/document/__tests__/test-notebook.ts +162 -0
  753. package/src/core/notebook/document/__tests__/user.ts +62 -0
  754. package/src/core/notebook/document/codemirror.ts +216 -0
  755. package/src/core/{document → notebook/document}/draft.ts +53 -30
  756. package/src/core/notebook/document/hooks.tsx +123 -0
  757. package/src/core/notebook/document/index.ts +25 -0
  758. package/src/core/notebook/document/model.ts +105 -0
  759. package/src/core/notebook/document/select.ts +41 -0
  760. package/src/core/{document/model.ts → notebook/document/state.ts} +77 -71
  761. package/src/core/notebook/document/sync.ts +378 -0
  762. package/src/core/notebook/index.ts +19 -0
  763. package/src/core/notebook/operations.ts +30 -0
  764. package/src/core/notebook/replica/AGENTS.md +11 -0
  765. package/src/core/{host → notebook/replica}/__tests__/document.test.ts +13 -8
  766. package/src/core/notebook/replica/__tests__/executions.test.ts +272 -0
  767. package/src/core/notebook/replica/__tests__/fixtures.ts +103 -0
  768. package/src/core/{host/__tests__/notebook-client.test.ts → notebook/replica/__tests__/replica.test.ts} +268 -25
  769. package/src/core/notebook/replica/__tests__/results.test.ts +232 -0
  770. package/src/core/notebook/replica/__tests__/runtime.test.ts +77 -0
  771. package/src/core/notebook/replica/backend.ts +21 -0
  772. package/src/core/{host → notebook/replica}/connection.ts +1 -5
  773. package/src/core/notebook/replica/execution-state.ts +43 -0
  774. package/src/core/notebook/replica/index.ts +31 -0
  775. package/src/core/notebook/replica/replica.ts +569 -0
  776. package/src/core/notebook/replica/resources/analysis.ts +9 -0
  777. package/src/core/{host → notebook/replica}/resources/document.ts +1 -1
  778. package/src/core/notebook/replica/resources/executions.ts +348 -0
  779. package/src/core/notebook/replica/resources/results.ts +66 -0
  780. package/src/core/notebook/replica/resources/runtime.ts +14 -0
  781. package/src/core/packages/__tests__/useSandboxController.test.tsx +1 -1
  782. package/src/core/packages/useSandboxController.ts +1 -1
  783. package/src/core/run-app.tsx +49 -52
  784. package/src/core/runtime/__tests__/adapter.test.ts +4 -4
  785. package/src/core/runtime/__tests__/createWsUrl.test.ts +5 -17
  786. package/src/core/runtime/__tests__/runtime.test.ts +68 -141
  787. package/src/core/runtime/adapter.ts +6 -13
  788. package/src/core/runtime/config.ts +4 -24
  789. package/src/core/runtime/runtime.ts +11 -16
  790. package/src/core/runtime/types.ts +0 -5
  791. package/src/core/saving/__tests__/document.test.tsx +113 -0
  792. package/src/core/saving/__tests__/state.test.ts +111 -0
  793. package/src/core/saving/__tests__/useAutoSave.test.tsx +67 -0
  794. package/src/core/saving/__tests__/useSaveNotebook.test.tsx +69 -0
  795. package/src/core/saving/document.ts +33 -0
  796. package/src/core/saving/filename.ts +1 -1
  797. package/src/core/saving/save-component.tsx +68 -60
  798. package/src/core/saving/state.ts +42 -37
  799. package/src/core/saving/useAutoSave.ts +17 -53
  800. package/src/core/session/__tests__/backend.test.ts +244 -0
  801. package/src/core/session/__tests__/useNotebookReplica.hook.test.tsx +187 -0
  802. package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +1552 -0
  803. package/src/core/session/active-notebook.ts +35 -0
  804. package/src/core/session/backend.ts +125 -0
  805. package/src/core/{websocket → session}/connection-utils.ts +2 -14
  806. package/src/core/session/embedded.ts +7 -0
  807. package/src/core/{websocket → session}/types.ts +2 -2
  808. package/src/core/session/useNotebookReplica.ts +91 -0
  809. package/src/core/{websocket → session}/useNotebookSession.tsx +178 -106
  810. package/src/core/static/__tests__/files.test.ts +38 -10
  811. package/src/core/static/virtual-file-tracker.ts +41 -10
  812. package/src/core/{websocket → transports}/__tests__/connection-state.test.ts +1 -1
  813. package/src/core/{websocket/transports/__tests__/notebook.test.ts → transports/__tests__/server.test.ts} +29 -119
  814. package/src/core/transports/__tests__/static.test.ts +357 -0
  815. package/src/core/transports/__tests__/wasm.test.ts +166 -0
  816. package/src/core/{websocket → transports}/connection-state.ts +9 -6
  817. package/src/core/{websocket/transports/notebook.ts → transports/server.ts} +15 -76
  818. package/src/core/transports/static.ts +188 -0
  819. package/src/core/transports/wasm.ts +95 -0
  820. package/src/core/vscode/__tests__/vscode-bindings.test.ts +125 -0
  821. package/src/core/vscode/vscode-bindings.ts +14 -2
  822. package/src/core/wasm/PyodideLoader.tsx +2 -1
  823. package/src/core/wasm/__tests__/PyodideLoader.test.tsx +100 -0
  824. package/src/core/wasm/__tests__/bridge.test.ts +346 -64
  825. package/src/core/wasm/__tests__/worker.test.ts +191 -0
  826. package/src/core/wasm/bridge.ts +167 -85
  827. package/src/core/wasm/errors.ts +8 -0
  828. package/src/core/wasm/rpc.ts +15 -3
  829. package/src/core/wasm/worker/bootstrap.ts +54 -50
  830. package/src/core/wasm/worker/save-worker.ts +9 -10
  831. package/src/core/wasm/worker/types.ts +32 -19
  832. package/src/core/wasm/worker/worker.ts +126 -72
  833. package/src/css/app/Cell.css +7 -36
  834. package/src/css/app/codemirror.css +1 -32
  835. package/src/css/common.css +1 -1
  836. package/src/css/globals.css +67 -24
  837. package/src/css/katex.min.css +1 -1
  838. package/src/hooks/useDebounce.ts +1 -2
  839. package/src/hooks/useEventListener.ts +1 -2
  840. package/src/mount.tsx +22 -19
  841. package/src/plugins/__tests__/plugin-object-schemas.test.ts +104 -0
  842. package/src/plugins/core/RenderHTML.tsx +3 -5
  843. package/src/plugins/core/__test__/PluginSlot.test.tsx +202 -0
  844. package/src/plugins/core/__test__/RenderHTML-copy.test.tsx +60 -0
  845. package/src/plugins/core/__test__/registerReactComponent.test.ts +45 -0
  846. package/src/plugins/core/__test__/sanitize.test.ts +35 -0
  847. package/src/plugins/core/registerReactComponent.tsx +28 -28
  848. package/src/plugins/core/sanitize-html.ts +8 -1
  849. package/src/plugins/impl/DataEditorPlugin.tsx +60 -28
  850. package/src/plugins/impl/DataTablePlugin.tsx +55 -22
  851. package/src/plugins/impl/RangeSliderPlugin.tsx +17 -2
  852. package/src/plugins/impl/SliderPlugin.tsx +35 -3
  853. package/src/plugins/impl/__test__/slider-labels.test.tsx +30 -0
  854. package/src/plugins/impl/__tests__/DataEditorPlugin.test.ts +190 -10
  855. package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +270 -0
  856. package/src/plugins/impl/__tests__/RangeSliderPlugin.test.tsx +109 -0
  857. package/src/plugins/impl/__tests__/SliderPlugin.test.tsx +40 -0
  858. package/src/plugins/impl/anywidget/__tests__/registry.test.ts +151 -0
  859. package/src/plugins/impl/anywidget/model.ts +3 -1
  860. package/src/plugins/impl/anywidget/registry.ts +18 -14
  861. package/src/plugins/impl/chat/__tests__/chat-prompts.test.tsx +1 -1
  862. package/src/plugins/impl/chat/chat-ui.tsx +5 -5
  863. package/src/plugins/impl/common/error-banner.tsx +5 -3
  864. package/src/plugins/impl/data-editor/__tests__/column-types.test.ts +42 -0
  865. package/src/plugins/impl/data-editor/__tests__/editor-state.test.ts +52 -1
  866. package/src/plugins/impl/data-editor/__tests__/glide-data-editor.test.tsx +278 -7
  867. package/src/plugins/impl/data-editor/__tests__/glide-utils.test.ts +116 -0
  868. package/src/plugins/impl/data-editor/column-types.ts +55 -0
  869. package/src/plugins/impl/data-editor/editor-state.ts +18 -2
  870. package/src/plugins/impl/data-editor/glide-data-editor.tsx +97 -18
  871. package/src/plugins/impl/data-editor/glide-portal.tsx +5 -3
  872. package/src/plugins/impl/data-editor/glide-utils.ts +36 -37
  873. package/src/plugins/impl/data-editor/types.ts +5 -0
  874. package/src/plugins/impl/data-explorer/components/column-summary.tsx +4 -2
  875. package/src/plugins/impl/data-explorer/functions/types.ts +1 -5
  876. package/src/plugins/impl/data-frames/DataFramePlugin.tsx +1 -1
  877. package/src/plugins/impl/data-frames/__tests__/sidebar.test.tsx +160 -0
  878. package/src/plugins/impl/data-frames/forms/__tests__/__snapshots__/form.test.tsx.snap +66 -66
  879. package/src/plugins/impl/data-frames/panel.tsx +44 -16
  880. package/src/plugins/impl/plotly/PlotlyPlugin.tsx +2 -5
  881. package/src/plugins/impl/plotly/selection.ts +25 -19
  882. package/src/plugins/impl/vega/VegaPlugin.tsx +2 -3
  883. package/src/plugins/layout/AccordionPlugin.tsx +2 -1
  884. package/src/plugins/layout/DownloadPlugin.tsx +7 -11
  885. package/src/plugins/layout/LazyPlugin.tsx +7 -4
  886. package/src/plugins/layout/TexPlugin.tsx +0 -1
  887. package/src/plugins/layout/__test__/DownloadPlugin.test.tsx +205 -0
  888. package/src/plugins/layout/__test__/mermaid.test.tsx +256 -0
  889. package/src/plugins/layout/__tests__/AccordionPlugin.test.tsx +21 -0
  890. package/src/plugins/layout/__tests__/LazyPlugin.test.tsx +98 -0
  891. package/src/plugins/layout/mermaid/mermaid.tsx +63 -17
  892. package/src/stories/cell-status.stories.tsx +29 -24
  893. package/src/stories/cell.stories.tsx +72 -57
  894. package/src/stories/data-table.stories.tsx +31 -0
  895. package/src/stories/editor.stories.tsx +4 -1
  896. package/src/stories/layout/vertical/one-column.stories.tsx +60 -60
  897. package/src/stories/runtime-story.tsx +23 -17
  898. package/src/stories/theme.stories.tsx +4 -2
  899. package/src/theme/__tests__/islands-theme.test.tsx +276 -0
  900. package/src/theme/namespace.tsx +4 -3
  901. package/src/theme/useTheme.ts +71 -41
  902. package/src/utils/__tests__/{createReducer.test.ts → createReducer.test.tsx} +127 -1
  903. package/src/utils/__tests__/download.test.tsx +183 -23
  904. package/src/utils/__tests__/numbers.test.ts +57 -0
  905. package/src/utils/arrays.ts +1 -2
  906. package/src/utils/createReducer.ts +115 -79
  907. package/src/utils/download.ts +67 -6
  908. package/src/utils/errors.ts +0 -7
  909. package/src/utils/maps.ts +0 -3
  910. package/src/utils/numbers.ts +59 -9
  911. package/src/utils/objects.ts +1 -2
  912. package/src/utils/python-poet/poet.ts +12 -2
  913. package/src/utils/time.ts +10 -0
  914. package/src/utils/tracer.ts +9 -5
  915. package/dist/ErrorBoundary-D5HXg9iP.js +0 -200
  916. package/dist/_baseMerge-BiGRwuqv.js +0 -165
  917. package/dist/architecture-7GRP2DOG-BWLylgiA.js +0 -3
  918. package/dist/assets/__vite-browser-external-35VXYmnw.js +0 -1
  919. package/dist/assets/worker-Dq8y-WM5.js +0 -114
  920. package/dist/classDiagram-ZZMXUADV-GTL0l5xS.js +0 -30
  921. package/dist/classDiagram-v2-VYDZK3BY-BWrM2ruI.js +0 -30
  922. package/dist/code-visibility-gnf5rA6s.js +0 -138
  923. package/dist/cynefin-OW5HDTMX-obq-i80l.js +0 -3
  924. package/dist/dropdown-menu-B_7xD2X4.js +0 -4686
  925. package/dist/duckdb-keywords-BGArYVVK.js +0 -3
  926. package/dist/eventmodeling-NTZA5JFV-D7nP7Uyu.js +0 -3
  927. package/dist/feedback-button-B9M0GGjm.js +0 -379
  928. package/dist/flowDiagram-HODETNUW-CjaeFeea.js +0 -16
  929. package/dist/gitGraph-4MIJSDKK-Dy9uQXGh.js +0 -3
  930. package/dist/hasIn-o2Us0uVx.js +0 -132
  931. package/dist/highlighted-body-KPVGNVTW-3Ziwfz-V.js +0 -38
  932. package/dist/html-to-image-CWdayGZU.js +0 -3251
  933. package/dist/info-A6RAGUB7-DKoayiHY.js +0 -3
  934. package/dist/isArrayLikeObject-BZl-15ir.js +0 -450
  935. package/dist/isEmpty-BSZ1LaUo.js +0 -35
  936. package/dist/isSymbol-kQcfYbNX.js +0 -8
  937. package/dist/label-BRnUC0NX.js +0 -281
  938. package/dist/linear-DWERh7eI.js +0 -252
  939. package/dist/mermaid-HWGCJPDP-Du3-HPQA.js +0 -2
  940. package/dist/packet-AYTQ26CC-Yw7ajchJ.js +0 -3
  941. package/dist/pick-CJeoxYOS.js +0 -51
  942. package/dist/pie-WAS4IAKB-BKdKOAkL.js +0 -3
  943. package/dist/precisionRound-DhAzeRcm.js +0 -49
  944. package/dist/purify.es-DMv5zIkJ.js +0 -866
  945. package/dist/radar-RG4KPBEZ-ScR_D_Ts.js +0 -3
  946. package/dist/railroad-74A4TZTK-DQvPSdo5.js +0 -3
  947. package/dist/railroad-abnf-HS5TGJTU-CsJQG2O8.js +0 -3
  948. package/dist/railroad-ebnf-LZEXJU2U-BgEobkSn.js +0 -3
  949. package/dist/railroad-peg-WCYAUIDC-DjLAjofI.js +0 -3
  950. package/dist/select-B0LRDH0g.js +0 -1344
  951. package/dist/semaphore-89jsoHtS.js +0 -44
  952. package/dist/stateDiagram-v2-MP3YSRHH-8LL6FrBe.js +0 -30
  953. package/dist/swimlanesDiagram-VR7AAH4N-BoMMtOPh.js +0 -30
  954. package/dist/toast-CFWpihJU.js +0 -1830
  955. package/dist/treeView-Q6P3EWNA-DuRV97YF.js +0 -3
  956. package/dist/treemap-WGGIJYW6-AsLq-uwC.js +0 -3
  957. package/dist/use-restore-focus-DBCITLeF.js +0 -6369
  958. package/dist/useDeepCompareMemoize-BpPWi3G3.js +0 -11
  959. package/dist/useLifecycle-Dum8WSXq.js +0 -169
  960. package/dist/useTheme-CfeaVw5D.js +0 -904
  961. package/dist/wardley-WFR3VGLG-Na-tFhQJ.js +0 -3
  962. package/src/components/chat/reasoning-accordion.tsx +0 -61
  963. package/src/components/chat/tool-call/tool-error-card.tsx +0 -81
  964. package/src/components/chat/tool-call/tool-history-row.tsx +0 -174
  965. package/src/components/editor/ai/__tests__/staged-cell-submission.test.ts +0 -106
  966. package/src/components/editor/ai/add-cell-with-ai.tsx +0 -506
  967. package/src/components/editor/ai/staged-cell-submission.ts +0 -46
  968. package/src/components/editor/alerts/connecting-alert.tsx +0 -27
  969. package/src/components/editor/alerts/stdin-blocking-alert.tsx +0 -61
  970. package/src/components/editor/cell/__tests__/StagedAICell.test.tsx +0 -64
  971. package/src/components/editor/cell/code/__tests__/rtc-editor-config.test.ts +0 -50
  972. package/src/components/editor/chrome/wrapper/footer-items/rtc-status.tsx +0 -65
  973. package/src/components/editor/navigation/__tests__/state.test.ts +0 -81
  974. package/src/components/editor/navigation/state.ts +0 -65
  975. package/src/components/icons/loading-ellipsis.tsx +0 -46
  976. package/src/core/ai/tools/__tests__/run-cells-tool.test.ts +0 -656
  977. package/src/core/ai/tools/run-cells-tool.ts +0 -303
  978. package/src/core/attachments/state.ts +0 -18
  979. package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +0 -1325
  980. package/src/core/cells/__tests__/apply-transaction.test.ts +0 -991
  981. package/src/core/cells/__tests__/document-changes.test.ts +0 -1140
  982. package/src/core/cells/__tests__/document-roundtrip.test.ts +0 -392
  983. package/src/core/cells/document-changes.ts +0 -944
  984. package/src/core/codemirror/rtc/extension.ts +0 -453
  985. package/src/core/codemirror/rtc/loro/__tests__/sync.test.ts +0 -52
  986. package/src/core/codemirror/rtc/loro/awareness.ts +0 -531
  987. package/src/core/codemirror/rtc/loro/colors.ts +0 -38
  988. package/src/core/codemirror/rtc/loro/sync.ts +0 -168
  989. package/src/core/document/__tests__/submission.test.ts +0 -334
  990. package/src/core/host/AGENTS.md +0 -16
  991. package/src/core/host/__tests__/fixtures.ts +0 -41
  992. package/src/core/host/notebook-client.ts +0 -259
  993. package/src/core/network/__tests__/requests-lazy.test.ts +0 -334
  994. package/src/core/network/requests-lazy.ts +0 -226
  995. package/src/core/rtc/state.ts +0 -34
  996. package/src/core/wasm/worker/message-buffer.ts +0 -33
  997. package/src/core/websocket/__tests__/useNotebookClient.hook.test.tsx +0 -223
  998. package/src/core/websocket/__tests__/useNotebookSession.hook.test.tsx +0 -606
  999. package/src/core/websocket/state.ts +0 -7
  1000. package/src/core/websocket/useNotebookClient.ts +0 -89
  1001. package/src/utils/__tests__/id-tree.test.ts +0 -2145
  1002. package/src/utils/id-tree.tsx +0 -1134
  1003. /package/src/{core/attachments/toast.ts → components/editor/agent-toast.ts} +0 -0
  1004. /package/src/core/{host → notebook/replica}/__tests__/attachments.test.ts +0 -0
  1005. /package/src/core/{host → notebook/replica}/resources/attachments.ts +0 -0
@@ -0,0 +1,3255 @@
1
+ import { a as e } from "./rolldown-runtime-BPCzCO3I.js";
2
+ import { g as t, h as n, p as r } from "./button-qQhINE7z.js";
3
+ import { t as i } from "./react-Bgs_wQh3.js";
4
+ import { t as a } from "./compiler-runtime-C5KHtL5D.js";
5
+ import { i as o } from "./copy-icon-BI7vZHEW.js";
6
+ import { f as s, h as c } from "./tooltip-UzJukb3F.js";
7
+ import { t as l } from "./check-jchHMCfs.js";
8
+ import { n as u, r as d } from "./assertNever-DywGMo-S.js";
9
+ import { t as f } from "./jsx-runtime-D8btoEHk.js";
10
+ import { At as p, Ct as m, Dt as h, Et as g, Ft as _, Ht as v, It as y, Ot as ee, Pt as b, St as x, Tt as te, _n as ne, f as re, hn as ie, jt as ae, mn as oe, pn as se, vn as ce, zt as le } from "./use-restore-focus-DaTVz6S6.js";
11
+ import { n as ue } from "./toast-U3NpO2x3.js";
12
+ import { t as de } from "./objects-DCmMvZtn.js";
13
+ import { t as S } from "./invariant-DLmrl-hA.js";
14
+ import { t as fe } from "./purify.es-DmnrIjg4.js";
15
+ import { t as pe } from "./createReducer-DdSLRfBT.js";
16
+ import { H as me, N as he, P as ge, _ as _e } from "./dist-D92tYjLc.js";
17
+ import { a as ve, i as ye, l as be, m as xe, u as Se } from "./static-state-C4bAlKTU.js";
18
+ import { t as Ce } from "./capabilities-DKqMqBzm.js";
19
+ var we = c("external-link", [
20
+ ["path", {
21
+ d: "M15 3h6v6",
22
+ key: "1q9fwt"
23
+ }],
24
+ ["path", {
25
+ d: "M10 14 21 3",
26
+ key: "gplh6r"
27
+ }],
28
+ ["path", {
29
+ d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",
30
+ key: "a6xqqp"
31
+ }]
32
+ ]), Te = c("minus", [["path", {
33
+ d: "M5 12h14",
34
+ key: "1ays0h"
35
+ }]]), C = /* @__PURE__ */ e(i(), 1), w = f(), Ee = Object.defineProperty, T = (e, t) => Ee(e, "name", {
36
+ value: t,
37
+ configurable: !0
38
+ }), De = "Checkbox", [Oe, ke] = ne(De), [Ae, je] = Oe(De);
39
+ function Me(e) {
40
+ let { __scopeCheckbox: t, checked: n, children: r, defaultChecked: i, disabled: a, form: o, name: s, onCheckedChange: c, required: l, value: u = "on", internal_do_not_use_render: d } = e, [f, p] = oe({
41
+ prop: n,
42
+ defaultProp: i ?? !1,
43
+ onChange: c,
44
+ caller: De
45
+ }), [m, h] = C.useState(null), [g, _] = C.useState(null), [v, y] = C.useState(null), ee = !m || !!o || !!m.closest("form"), b = {
46
+ checked: f,
47
+ disabled: a,
48
+ setChecked: p,
49
+ control: m,
50
+ setControl: h,
51
+ name: s,
52
+ form: o,
53
+ value: u,
54
+ userClick: v,
55
+ onUserClick: y,
56
+ required: l,
57
+ defaultChecked: !E(i) && i,
58
+ isFormControl: ee,
59
+ bubbleInput: g,
60
+ setBubbleInput: _
61
+ };
62
+ return /* @__PURE__ */ (0, w.jsx)(Ae, {
63
+ scope: t,
64
+ ...b,
65
+ children: Be(d) ? d(b) : r
66
+ });
67
+ }
68
+ T(Me, "CheckboxProvider");
69
+ var Ne = "CheckboxTrigger", Pe = /* @__PURE__ */ C.forwardRef(/* @__PURE__ */ T(function({ __scopeCheckbox: e, onKeyDown: t, onClick: n, ...i }, a) {
70
+ let { control: o, value: s, disabled: c, checked: l, required: u, setControl: d, setChecked: f, onUserClick: p, isFormControl: m, bubbleInput: h } = je(Ne, e), g = r(a, d), _ = C.useRef(l);
71
+ return C.useEffect(() => {
72
+ let e = o?.form;
73
+ if (e) {
74
+ let t = /* @__PURE__ */ T(() => f(_.current), "reset");
75
+ return e.addEventListener("reset", t), () => e.removeEventListener("reset", t);
76
+ }
77
+ }, [o, f]), /* @__PURE__ */ (0, w.jsx)(ce.button, {
78
+ type: "button",
79
+ role: "checkbox",
80
+ "aria-checked": E(l) ? "mixed" : l,
81
+ "aria-required": u,
82
+ "data-state": Ve(l),
83
+ "data-disabled": c ? "" : void 0,
84
+ disabled: c,
85
+ value: s,
86
+ ...i,
87
+ ref: g,
88
+ onKeyDown: ie(t, (e) => {
89
+ e.key === "Enter" && e.preventDefault();
90
+ }),
91
+ onClick: ie(n, (e) => {
92
+ let t = e.isPropagationStopped();
93
+ p({
94
+ requestedChecked: E(l) ? !0 : !l,
95
+ hasConsumerStoppedPropagation: t
96
+ }), f((e) => E(e) ? !0 : !e), h && m && (t || e.stopPropagation());
97
+ })
98
+ });
99
+ }, "CheckboxTrigger")), Fe = /* @__PURE__ */ C.forwardRef(/* @__PURE__ */ T(function(e, t) {
100
+ let { __scopeCheckbox: n, name: r, checked: i, defaultChecked: a, required: o, disabled: s, value: c, onCheckedChange: l, form: u, ...d } = e;
101
+ return /* @__PURE__ */ (0, w.jsx)(Me, {
102
+ __scopeCheckbox: n,
103
+ checked: i,
104
+ defaultChecked: a,
105
+ disabled: s,
106
+ required: o,
107
+ onCheckedChange: l,
108
+ name: r,
109
+ form: u,
110
+ value: c,
111
+ internal_do_not_use_render: ({ isFormControl: e }) => /* @__PURE__ */ (0, w.jsxs)(w.Fragment, { children: [/* @__PURE__ */ (0, w.jsx)(Pe, {
112
+ ...d,
113
+ ref: t,
114
+ __scopeCheckbox: n
115
+ }), e && /* @__PURE__ */ (0, w.jsx)(ze, { __scopeCheckbox: n })] })
116
+ });
117
+ }, "Checkbox")), Ie = "CheckboxIndicator", Le = /* @__PURE__ */ C.forwardRef(/* @__PURE__ */ T(function(e, t) {
118
+ let { __scopeCheckbox: n, forceMount: r, ...i } = e, a = je(Ie, n);
119
+ return /* @__PURE__ */ (0, w.jsx)(se, {
120
+ present: r || E(a.checked) || a.checked === !0,
121
+ children: /* @__PURE__ */ (0, w.jsx)(ce.span, {
122
+ "data-state": Ve(a.checked),
123
+ "data-disabled": a.disabled ? "" : void 0,
124
+ ...i,
125
+ ref: t,
126
+ style: {
127
+ pointerEvents: "none",
128
+ ...e.style
129
+ }
130
+ })
131
+ });
132
+ }, "CheckboxIndicator")), Re = "CheckboxBubbleInput", ze = /* @__PURE__ */ C.forwardRef(/* @__PURE__ */ T(function({ __scopeCheckbox: e, onClick: t, ...n }, i) {
133
+ let { control: a, userClick: o, checked: c, defaultChecked: l, required: u, disabled: d, name: f, value: p, form: m, bubbleInput: h, setBubbleInput: g } = je(Re, e), _ = r(i, g), v = s(a), y = C.useRef(!1), ee = C.useRef(c), b = C.useRef(o), x = C.useRef(null);
134
+ C.useEffect(() => {
135
+ let e = h;
136
+ if (!e) return;
137
+ let t = window.HTMLInputElement.prototype, n = Object.getOwnPropertyDescriptor(t, "checked").set;
138
+ if (!n) return;
139
+ let r = ee.current !== c;
140
+ ee.current = c;
141
+ let i = o !== null && o !== b.current;
142
+ if (b.current = o, i) x.current = r ? null : o, r && (e.indeterminate = E(c), n.call(e, !E(c) && c)), e.dispatchEvent(new Event("click", { bubbles: !o.hasConsumerStoppedPropagation }));
143
+ else if (r) {
144
+ let t = x.current;
145
+ x.current = null;
146
+ let r = t?.requestedChecked === c;
147
+ y.current = !0, e.indeterminate = E(c), n.call(e, !E(c) && c), e.dispatchEvent(new Event("click", { bubbles: !(r && t.hasConsumerStoppedPropagation) })), y.current = !1;
148
+ }
149
+ }, [
150
+ h,
151
+ c,
152
+ o
153
+ ]);
154
+ let te = C.useRef(!E(c) && c);
155
+ return /* @__PURE__ */ (0, w.jsx)(ce.input, {
156
+ type: "checkbox",
157
+ "aria-hidden": !0,
158
+ defaultChecked: l ?? te.current,
159
+ required: u,
160
+ disabled: d,
161
+ name: f,
162
+ value: p,
163
+ form: m,
164
+ ...n,
165
+ tabIndex: -1,
166
+ ref: _,
167
+ onClick: ie(t, (e) => {
168
+ y.current && e.stopPropagation();
169
+ }),
170
+ style: {
171
+ ...n.style,
172
+ ...v,
173
+ position: "absolute",
174
+ pointerEvents: "none",
175
+ opacity: 0,
176
+ margin: 0,
177
+ transform: "translateX(-100%)"
178
+ }
179
+ });
180
+ }, "CheckboxBubbleInput"));
181
+ function Be(e) {
182
+ return typeof e == "function";
183
+ }
184
+ T(Be, "isFunction");
185
+ function E(e) {
186
+ return e === "indeterminate";
187
+ }
188
+ T(E, "isIndeterminate");
189
+ function Ve(e) {
190
+ return E(e) ? "indeterminate" : e ? "checked" : "unchecked";
191
+ }
192
+ T(Ve, "getState");
193
+ //#endregion
194
+ //#region src/plugins/core/sanitize-html.ts
195
+ var He = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix|zotero):|[^a-z]|[-a-z+.]+(?:[^-a-z+.:]|$))/i;
196
+ if (typeof document < "u") {
197
+ let e = "data-temp-href-target";
198
+ fe.addHook("beforeSanitizeAttributes", (t) => {
199
+ t.tagName === "A" && (t.hasAttribute("target") || t.setAttribute("target", "_self"), t.hasAttribute("target") && t.setAttribute(e, t.getAttribute("target") || ""));
200
+ }), fe.addHook("afterSanitizeAttributes", (t) => {
201
+ t.tagName === "A" && t.hasAttribute(e) && (t.setAttribute("target", t.getAttribute(e) || ""), t.removeAttribute(e), t.getAttribute("target") === "_blank" && t.setAttribute("rel", "noopener noreferrer"));
202
+ });
203
+ }
204
+ function Ue(e) {
205
+ let t = {
206
+ USE_PROFILES: {
207
+ html: !0,
208
+ svg: !0,
209
+ mathMl: !0
210
+ },
211
+ ADD_TAGS: ["use"],
212
+ ADD_ATTR: ["href", "xlink:href"],
213
+ ALLOWED_URI_REGEXP: He,
214
+ FORCE_BODY: !0,
215
+ CUSTOM_ELEMENT_HANDLING: {
216
+ tagNameCheck: /^(marimo-[A-Za-z][\w-]*|iconify-icon)$/,
217
+ attributeNameCheck: (e) => !/^on/i.test(e) && /^[A-Za-z][\w-]*$/.test(e)
218
+ },
219
+ SAFE_FOR_XML: !e.includes("marimo-mermaid")
220
+ };
221
+ return fe.sanitize(e, t);
222
+ }
223
+ //#endregion
224
+ //#region src/core/dom/outline.ts
225
+ var We = [
226
+ "marimo-carousel",
227
+ "marimo-tabs",
228
+ "marimo-accordion",
229
+ "marimo-sidebar"
230
+ ], Ge = "h1, h2, h3, h4, h5, h6";
231
+ function Ke(e) {
232
+ if (typeof DOMParser > "u") return null;
233
+ let t = [], n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(Ge);
234
+ for (let e of Array.from(n)) {
235
+ let n = e.textContent;
236
+ if (We.some((t) => e.closest(t)) || !n) continue;
237
+ let r = Number.parseInt(e.tagName[1], 10), i = e.innerHTML, a = {
238
+ name: n,
239
+ level: r,
240
+ by: Je(e)
241
+ };
242
+ i !== n && (a.html = Ue(i)), t.push(a);
243
+ }
244
+ return { items: t };
245
+ }
246
+ function qe(e) {
247
+ if (!e.includes("\"")) return `"${e}"`;
248
+ if (!e.includes("'")) return `'${e}'`;
249
+ let t = e.split("\""), n = [];
250
+ for (let [e, r] of t.entries()) r && n.push(`"${r}"`), e < t.length - 1 && n.push("'\"'");
251
+ return `concat(${n.join(", ")})`;
252
+ }
253
+ function Je(e) {
254
+ let t = e.id;
255
+ if (t) return { id: t };
256
+ let n = e.textContent ?? "";
257
+ return { path: `//${e.tagName}[contains(., ${qe(n)})]` };
258
+ }
259
+ function Ye(e) {
260
+ return { items: e.filter(Boolean).flatMap((e) => e.items) };
261
+ }
262
+ function Xe(e) {
263
+ if (e == null || e.mimetype !== "text/html" && e.mimetype !== "text/markdown" || e.data == null) return null;
264
+ try {
265
+ return S(typeof e.data == "string", "expected string"), Ke(e.data);
266
+ } catch {
267
+ return t.error("Failed to parse outline"), null;
268
+ }
269
+ }
270
+ function Ze(e) {
271
+ return e != null && e.items.some((e) => e.level <= 3);
272
+ }
273
+ function Qe(e, n) {
274
+ let r = (e) => e.items.length === 0 ? 7 : Math.min(...e.items.map((e) => e.level)), i = n[e];
275
+ if (i == null || i.items.length === 0) return t.warn("Failed to find a starting outline"), null;
276
+ let a = r(i), o = e + 1;
277
+ for (; o < n.length;) {
278
+ let t = n[o];
279
+ if (t && r(t) <= a) return [e, o - 1];
280
+ o++;
281
+ }
282
+ return [e, n.length - 1];
283
+ }
284
+ //#endregion
285
+ //#region src/core/notebook/replica/connection.ts
286
+ var D = {
287
+ NOT_STARTED: "NOT_STARTED",
288
+ CONNECTING: "CONNECTING",
289
+ OPEN: "OPEN",
290
+ CLOSED: "CLOSED"
291
+ }, $e = {
292
+ KERNEL_DISCONNECTED: "KERNEL_DISCONNECTED",
293
+ KERNEL_STARTUP_ERROR: "KERNEL_STARTUP_ERROR"
294
+ };
295
+ //#endregion
296
+ //#region src/core/notebook/replica/execution-state.ts
297
+ function O(e) {
298
+ let { state: t } = e.record;
299
+ return t.status === "completed" && t.outcome.kind !== "succeeded" ? t.outcome : e.output === null ? t.status === "completed" ? {
300
+ kind: "output",
301
+ media: null
302
+ } : null : {
303
+ kind: "output",
304
+ media: e.output.media
305
+ };
306
+ }
307
+ function k(e) {
308
+ return e.state.status === "queued" ? null : e.state.started_at;
309
+ }
310
+ function A(e) {
311
+ return e.state.status === "completed" ? e.state.completed_at : null;
312
+ }
313
+ function et(e) {
314
+ return e.state.status === "completed" ? e.state.depends_on : {};
315
+ }
316
+ //#endregion
317
+ //#region src/core/notebook/replica/resources/results.ts
318
+ function tt(e, t) {
319
+ let { record: n, output: r, outputVersion: i } = t, a = n.cell_id;
320
+ return a === null || n.state.status !== "completed" || !e.has(a) || n.state.outcome.kind === "skipped" && n.state.outcome.reason === "superseded" ? e : new Map(e).set(a, {
321
+ record: n,
322
+ output: r,
323
+ outputVersion: i
324
+ });
325
+ }
326
+ function nt(e, t) {
327
+ let { record: n, output: r, outputVersion: i } = t;
328
+ if (n.cell_id !== null || O(t) === null) return e;
329
+ let a = (e) => Date.parse(A(e) ?? k(e) ?? "1970-01-01T00:00:00Z");
330
+ return e !== null && a(e.record) > a(n) ? e : {
331
+ record: n,
332
+ output: r,
333
+ outputVersion: i
334
+ };
335
+ }
336
+ //#endregion
337
+ //#region src/core/notebook/replica/resources/executions.ts
338
+ function rt(e) {
339
+ let { state: t } = e;
340
+ return t.status === "completed" && t.outcome.kind === "failed" && t.outcome.message !== null ? {
341
+ runId: e.id,
342
+ message: t.outcome.message,
343
+ completedAt: t.completed_at
344
+ } : void 0;
345
+ }
346
+ function it(e) {
347
+ return [...e.items.values()].toSorted((e, t) => e.seq - t.seq);
348
+ }
349
+ function j(e, t) {
350
+ if (!e.has(t)) return e;
351
+ let n = new Map(e);
352
+ return n.delete(t), n;
353
+ }
354
+ function at(e, t) {
355
+ let n = e.scratchConsole, { id: r, cell_id: i } = t.record, a = k(t.record);
356
+ if (i !== null || a === null) return n;
357
+ if (!n || n.record.id === r) return t;
358
+ let o = e.executions.get(r);
359
+ return o && k(o.record) !== null ? n : Date.parse(a) >= Date.parse(k(n.record) ?? "") ? t : n;
360
+ }
361
+ function M(e, t) {
362
+ let { id: n, cell_id: r } = t.record;
363
+ return {
364
+ ...e,
365
+ executions: new Map(e.executions).set(n, t),
366
+ scratchConsole: at(e, t),
367
+ latest: r === null || e.latest.get(r) === n ? e.latest : new Map(e.latest).set(r, n)
368
+ };
369
+ }
370
+ function ot(e, t) {
371
+ let n = e.executions.get(t);
372
+ if (n === void 0) return e;
373
+ let r = n.record.cell_id;
374
+ return {
375
+ ...e,
376
+ executions: j(e.executions, t),
377
+ scratchConsole: e.scratchConsole?.record.id === t ? void 0 : e.scratchConsole,
378
+ latest: r !== null && e.latest.get(r) === t ? j(e.latest, r) : e.latest
379
+ };
380
+ }
381
+ function st(e, t) {
382
+ let n = e.executions.get(t.execution_id);
383
+ if (n === void 0) return e;
384
+ let r = n.items.get(t.id);
385
+ return r && (t = {
386
+ ...t,
387
+ time: r.time
388
+ }), M(e, {
389
+ ...n,
390
+ append: !r && t.seq > (n.lastSeq ?? -1) ? {
391
+ before: new WeakRef(n.items),
392
+ item: t
393
+ } : void 0,
394
+ lastSeq: Math.max(n.lastSeq ?? -1, t.seq),
395
+ items: new Map(n.items).set(t.id, t)
396
+ });
397
+ }
398
+ function ct(e, t) {
399
+ for (let n of e.executions.values()) if (n.items.has(t)) return M(e, {
400
+ ...n,
401
+ append: void 0,
402
+ items: j(n.items, t)
403
+ });
404
+ return e;
405
+ }
406
+ function lt(e, t) {
407
+ let n = e.executions.get(t.execution_id);
408
+ return n === void 0 ? e : M(e, {
409
+ ...n,
410
+ variables: new Map(n.variables).set(t.id, t)
411
+ });
412
+ }
413
+ function ut(e, t) {
414
+ for (let n of e.executions.values()) if (n.variables.has(t)) return M(e, {
415
+ ...n,
416
+ variables: j(n.variables, t)
417
+ });
418
+ return e;
419
+ }
420
+ function dt(e, t) {
421
+ return JSON.stringify(O(e)) === JSON.stringify(O(t));
422
+ }
423
+ function ft(e, t) {
424
+ return {
425
+ ...M(e, t),
426
+ results: tt(e.results, t),
427
+ scratch: nt(e.scratch, t)
428
+ };
429
+ }
430
+ function pt(e, t, n) {
431
+ let r = new Map(e.executions);
432
+ for (let [e, n] of r) {
433
+ let i = n.record.cell_id === null ? t.scratch : t.results.get(n.record.cell_id), a = t.executions.get(e) ?? (i?.record.id === e ? i : void 0);
434
+ a !== void 0 && r.set(e, {
435
+ ...n,
436
+ outputVersion: a.outputVersion + +!dt(a, n)
437
+ });
438
+ }
439
+ let i = new Map(e.results);
440
+ for (let [e, n] of i) {
441
+ let a = n === null ? void 0 : r.get(n.record.id);
442
+ i.set(e, a === void 0 ? t.results.get(e) ?? null : {
443
+ record: a.record,
444
+ output: a.output,
445
+ outputVersion: a.outputVersion
446
+ });
447
+ }
448
+ let a = e.scratch === null ? null : r.get(e.scratch.record.id);
449
+ return {
450
+ ...e,
451
+ executions: r,
452
+ results: i,
453
+ scratchConsole: e.scratchConsole ?? (t.scratchConsole?.record.state.status === "completed" && t.scratchConsole.record.runtime_id === n ? t.scratchConsole : void 0),
454
+ scratch: a == null ? t.scratch : nt(t.scratch, a)
455
+ };
456
+ }
457
+ var mt = {
458
+ initial: {
459
+ runs: /* @__PURE__ */ new Map(),
460
+ executions: /* @__PURE__ */ new Map(),
461
+ latest: /* @__PURE__ */ new Map(),
462
+ results: /* @__PURE__ */ new Map(),
463
+ scratch: null
464
+ },
465
+ on: {
466
+ cell: (e, { data: t }) => e.results.has(t.cell.id) ? e : {
467
+ ...e,
468
+ results: new Map(e.results).set(t.cell.id, null)
469
+ },
470
+ "cell.removed": (e, { data: t }) => ({
471
+ ...e,
472
+ results: j(e.results, t.id)
473
+ }),
474
+ run: (e, { data: t }) => ({
475
+ ...e,
476
+ runs: new Map(e.runs).set(t.run.id, t.run),
477
+ scratchFailure: t.run.origin.kind === "code" ? rt(t.run) : e.scratchFailure
478
+ }),
479
+ "run.removed": (e, { data: t }) => e.runs.has(t.id) ? {
480
+ ...e,
481
+ runs: j(e.runs, t.id)
482
+ } : e,
483
+ execution: (e, { data: { execution: t } }) => {
484
+ let n = e.executions.get(t.id), r = {
485
+ record: t,
486
+ output: n?.output ?? null
487
+ };
488
+ return ft(e, {
489
+ ...r,
490
+ outputVersion: n === void 0 ? 0 : n.outputVersion + +!dt(n, r),
491
+ append: n?.append,
492
+ lastSeq: n?.lastSeq,
493
+ items: n?.items ?? /* @__PURE__ */ new Map(),
494
+ variables: n?.variables ?? /* @__PURE__ */ new Map()
495
+ });
496
+ },
497
+ "execution.removed": (e, { data: t }) => ot(e, t.id),
498
+ output: (e, { data: { output: t } }) => {
499
+ let n = e.executions.get(t.execution_id);
500
+ if (n === void 0) return e;
501
+ let r = {
502
+ ...n,
503
+ output: t
504
+ };
505
+ return ft(e, {
506
+ ...r,
507
+ outputVersion: n.outputVersion + +!dt(n, r)
508
+ });
509
+ },
510
+ "output.removed": (e) => e,
511
+ console: (e, { data: t }) => st(e, {
512
+ ...t.console,
513
+ kind: "console",
514
+ time: t.time
515
+ }),
516
+ "console.removed": (e, { data: t }) => ct(e, t.id),
517
+ input: (e, { data: t }) => st(e, {
518
+ ...t.input,
519
+ kind: "input",
520
+ time: t.time
521
+ }),
522
+ variable: (e, { data: t }) => lt(e, t.variable),
523
+ "variable.removed": (e, { data: t }) => ut(e, t.id)
524
+ }
525
+ }, ht = {
526
+ sourceChanged: !1,
527
+ inputsChanged: !1
528
+ };
529
+ function gt(e) {
530
+ let t = /* @__PURE__ */ new Map();
531
+ for (let n of e.executions.values()) for (let e of n.variables.values()) {
532
+ let n = t.get(e.name);
533
+ n === void 0 ? t.set(e.name, [e]) : n.push(e);
534
+ }
535
+ return t;
536
+ }
537
+ function _t(e) {
538
+ let t = gt(e.executions), n = /* @__PURE__ */ new Map(), r = (t) => e.executions.executions.get(t)?.record;
539
+ function i(e, n) {
540
+ let i = new Set(n).add(e.id);
541
+ for (let [n, a] of Object.entries(et(e))) {
542
+ let s = t.get(n) ?? [];
543
+ if (a === null) {
544
+ if (s.some((t) => {
545
+ let n = r(t.execution_id);
546
+ if (n === void 0) return !1;
547
+ if (n.runtime_id === e.runtime_id) return !0;
548
+ let i = A(n) ?? k(n), a = A(e);
549
+ return i !== null && a !== null && Date.parse(i) > Date.parse(a);
550
+ })) return !0;
551
+ continue;
552
+ }
553
+ let c = s.find((e) => e.revision.execution_id === a.execution_id);
554
+ if (c === void 0 || c.revision.update !== a.update) return !0;
555
+ let l = r(c.execution_id);
556
+ if (l === void 0 || !i.has(l.id) && o(l, i).inputsChanged) return !0;
557
+ }
558
+ return !1;
559
+ }
560
+ function a(t, n) {
561
+ let i = e.executions.latest.get(t.id), a = i === void 0 ? void 0 : r(i), o = a !== void 0 && a.state.status !== "completed" ? a : n;
562
+ return t.code_fingerprint !== o.code_fingerprint;
563
+ }
564
+ function o(t, r) {
565
+ let o = n.get(t.id);
566
+ if (o !== void 0) return o;
567
+ let s = t.cell_id === null ? void 0 : e.cells.get(t.cell_id), c = {
568
+ sourceChanged: s === void 0 || a(s, t),
569
+ inputsChanged: i(t, r)
570
+ };
571
+ return n.set(t.id, c), c;
572
+ }
573
+ return (t) => {
574
+ let n = e.results.get(t)?.record;
575
+ return n == null ? ht : o(n, /* @__PURE__ */ new Set());
576
+ };
577
+ }
578
+ //#endregion
579
+ //#region src/core/executions/output.ts
580
+ var vt = /* @__PURE__ */ new Map(), yt = "application/vnd.marimo+error";
581
+ function N(e) {
582
+ return e;
583
+ }
584
+ function bt(e) {
585
+ return e.map(({ cell_id: e, message: t }) => ({
586
+ cell_id: N(e),
587
+ message: t
588
+ }));
589
+ }
590
+ function xt(e) {
591
+ return e === null ? 0 : Date.parse(e) / 1e3;
592
+ }
593
+ function St(e) {
594
+ return xt(A(e) ?? k(e));
595
+ }
596
+ function Ct(e, t) {
597
+ return {
598
+ channel: "output",
599
+ mimetype: t.mimetype,
600
+ data: t.data,
601
+ timestamp: St(e)
602
+ };
603
+ }
604
+ function P(e, t) {
605
+ return {
606
+ channel: "marimo-error",
607
+ mimetype: yt,
608
+ data: t,
609
+ timestamp: St(e)
610
+ };
611
+ }
612
+ function wt(e) {
613
+ let t = e.related.at(0);
614
+ return t === void 0 ? null : N(t.cell_id);
615
+ }
616
+ function Tt(e) {
617
+ switch (e.kind) {
618
+ case "exception": return {
619
+ type: "exception",
620
+ exception_type: e.name ?? "Exception",
621
+ msg: e.message,
622
+ raising_cell: wt(e),
623
+ traceback: e.traceback?.data ?? null
624
+ };
625
+ case "invalid-syntax": return {
626
+ type: "syntax",
627
+ msg: e.message,
628
+ lineno: e.range === null ? null : e.range.start.line + 1
629
+ };
630
+ case "internal": return {
631
+ type: "unknown",
632
+ msg: e.message,
633
+ error_type: e.name
634
+ };
635
+ default: return {
636
+ type: "diagnostic",
637
+ kind: e.kind,
638
+ msg: e.message,
639
+ related: bt(e.related)
640
+ };
641
+ }
642
+ }
643
+ function Et(e, t) {
644
+ let n = t.related[0];
645
+ if (n !== void 0 && t.reason === "upstream-stopped") return P(e, [{
646
+ type: "ancestor-stopped",
647
+ msg: t.message,
648
+ raising_cell: N(n.cell_id)
649
+ }]);
650
+ if (n !== void 0 && t.reason === "upstream-failed") {
651
+ let r = t.related.slice(1).find((t) => t.cell_id !== e.cell_id);
652
+ return P(e, [{
653
+ type: "ancestor-prevented",
654
+ msg: t.message,
655
+ raising_cell: N(n.cell_id),
656
+ blamed_cell: r === void 0 ? null : N(r.cell_id)
657
+ }]);
658
+ }
659
+ return P(e, [{
660
+ type: "diagnostic",
661
+ kind: t.reason,
662
+ msg: t.message,
663
+ related: bt(t.related)
664
+ }]);
665
+ }
666
+ function Dt(e, t = vt) {
667
+ let n = e.cell_id === null ? void 0 : t.get(e.cell_id);
668
+ return n !== void 0 && n.code !== null && n.code_fingerprint === e.code_fingerprint ? n.code : void 0;
669
+ }
670
+ function Ot(e, t = vt) {
671
+ let n = kt(e), r = Dt(e.record, t);
672
+ return n === null || r === void 0 ? n : {
673
+ ...n,
674
+ code: r
675
+ };
676
+ }
677
+ function kt(e) {
678
+ let { record: t } = e, n = O(e);
679
+ if (n === null) return null;
680
+ switch (n.kind) {
681
+ case "output": return n.media === null ? null : Ct(t, n.media);
682
+ case "failed": return P(t, [Tt(n.error)]);
683
+ case "cancelled": return P(t, [{ type: "interruption" }]);
684
+ case "skipped": return Et(t, n);
685
+ }
686
+ }
687
+ function At(e, t) {
688
+ let n = e.executions.latest.get(t), r = n === void 0 ? void 0 : e.executions.executions.get(n);
689
+ if (r !== void 0 && O(r) !== null && r.record.state.status !== "completed") return r;
690
+ let i = e.results.get(t) ?? null;
691
+ return r?.record.state.status === "running" && i !== null && O(i)?.kind === "skipped" ? null : i;
692
+ }
693
+ function jt(e, t) {
694
+ return e?.execution === t.record.id && e.version === t.outputVersion;
695
+ }
696
+ function Mt(e, t) {
697
+ let n = At(e, t);
698
+ return n === null || jt(e.cleared.get(t), n) ? null : Ot(n, e.cells);
699
+ }
700
+ function Nt(e) {
701
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set([...e.results.keys(), ...e.executions.latest.keys()]);
702
+ for (let r of n) {
703
+ let n = Mt(e, r);
704
+ n !== null && t.set(N(r), n);
705
+ }
706
+ return t;
707
+ }
708
+ //#endregion
709
+ //#region src/utils/time.ts
710
+ var Pt = class e {
711
+ ms;
712
+ static fromMilliseconds(t) {
713
+ return t == null ? null : new e(t);
714
+ }
715
+ static fromSeconds(t) {
716
+ return t == null ? null : new e(t * 1e3);
717
+ }
718
+ static now() {
719
+ return new e(Date.now());
720
+ }
721
+ static parse(t) {
722
+ return new e(Date.parse(t));
723
+ }
724
+ constructor(e) {
725
+ this.ms = e;
726
+ }
727
+ toMilliseconds() {
728
+ return this.ms;
729
+ }
730
+ since(e) {
731
+ return this.ms - e.ms;
732
+ }
733
+ toSeconds() {
734
+ return this.ms / 1e3;
735
+ }
736
+ };
737
+ //#endregion
738
+ //#region src/core/executions/select.ts
739
+ function Ft(e) {
740
+ return e.state.status === "completed" ? e.state.outcome.kind : null;
741
+ }
742
+ function It(e) {
743
+ return e === null ? null : Pt.parse(e).toMilliseconds();
744
+ }
745
+ function Lt(e, t) {
746
+ let n = e.latest.get(t);
747
+ return n === void 0 ? null : e.executions.get(n) ?? null;
748
+ }
749
+ function Rt(e, t) {
750
+ let n = /* @__PURE__ */ new Set(), r = [...t].filter((e) => e.config.disabled);
751
+ if (r.length === 0) return n;
752
+ let i = /* @__PURE__ */ new Map();
753
+ for (let t of Object.keys(e.cells)) i.set(t, []);
754
+ for (let [t, { parents: r }] of Object.entries(e.cells)) {
755
+ if (r === void 0) return n;
756
+ for (let e of r) i.get(e)?.push(t);
757
+ }
758
+ let a = /* @__PURE__ */ new Map();
759
+ for (let e of r) {
760
+ let t = /* @__PURE__ */ new Set([e.id]);
761
+ for (let r of t) {
762
+ r !== e.id && n.add(r);
763
+ let o = a.get(r) ?? 0;
764
+ if (o !== 2) {
765
+ a.set(r, o + 1);
766
+ for (let e of i.get(r) ?? []) t.add(e);
767
+ }
768
+ }
769
+ }
770
+ return n;
771
+ }
772
+ function zt(e, t) {
773
+ let n = e.cells.get(t);
774
+ return n !== void 0 && !n.config.disabled && !e.blocked.has(t);
775
+ }
776
+ function Bt(e, t) {
777
+ if (!zt(e, t)) return !1;
778
+ if (e.requested.has(t)) return !0;
779
+ let n = Lt(e.executions, t)?.record.run_id ?? e.results.get(t)?.record.run_id;
780
+ for (let r of e.executions.runs.values()) if (r.state.status !== "completed" && r.id !== n && r.origin.kind === "cells" && r.origin.cell_ids.includes(t)) return !0;
781
+ return !1;
782
+ }
783
+ function Vt(e, t) {
784
+ let n = Lt(e.executions, t), r = e.results.get(t)?.record ?? null, i = "idle", a = r === null ? null : k(r), o = r === null ? null : A(r), s = It(a);
785
+ n !== null && n.record.state.status !== "completed" ? (i = n.record.state.status, s = It(k(n.record)) ?? s) : Bt(e, t) && (i = "queued");
786
+ let c = i === "idle", l = c && a !== null && o !== null ? Pt.parse(o).since(Pt.parse(a)) : null, u = e.blocked.has(t);
787
+ return {
788
+ status: i,
789
+ blocked: u,
790
+ shownBlock: u ? "current" : e.shownBlocked.has(t) ? "stale" : null,
791
+ outcome: c && r !== null ? Ft(r) : null,
792
+ live: r === null || e.runtimeId === null || r.runtime_id === e.runtimeId,
793
+ startedAt: s,
794
+ duration: l
795
+ };
796
+ }
797
+ function Ht(e) {
798
+ return [...e.executions.values()].filter((e) => e.record.state.status !== "completed");
799
+ }
800
+ function Ut(e) {
801
+ return Ht(e).some((e) => e.record.state.status === "running");
802
+ }
803
+ function Wt(e) {
804
+ let t = Ht(e.executions), n = new Set(t.flatMap((e) => e.record.cell_id === null ? [] : [e.record.cell_id])), r = new Set(e.requested);
805
+ for (let t of e.executions.runs.values()) if (t.state.status !== "completed" && t.origin.kind === "cells") for (let e of t.origin.cell_ids) r.add(e);
806
+ let i = 0;
807
+ for (let t of r) !n.has(t) && Bt(e, t) && (i += 1);
808
+ return t.length + i;
809
+ }
810
+ //#endregion
811
+ //#region src/core/executions/atoms.ts
812
+ var Gt = {
813
+ runs: /* @__PURE__ */ new Map(),
814
+ executions: /* @__PURE__ */ new Map(),
815
+ latest: /* @__PURE__ */ new Map(),
816
+ results: /* @__PURE__ */ new Map(),
817
+ scratch: null
818
+ }, Kt = /* @__PURE__ */ new Map(), qt = /* @__PURE__ */ new Map(), Jt = /* @__PURE__ */ new Set(), Yt = /* @__PURE__ */ new Set(), Xt = /* @__PURE__ */ new Set(), Zt = /* @__PURE__ */ new Map(), F = v(null);
819
+ function Qt(e, t) {
820
+ return t !== null && e.replica === t.replica && e.id === t.id && e.generation === t.generation;
821
+ }
822
+ function $t(e, t, n) {
823
+ return e !== null && Qt(e.notebook, t) ? e.value : n;
824
+ }
825
+ var en = v((e) => {
826
+ let t = e(h), n = t === null ? null : e(t.notebookAtom);
827
+ return t === null || n === null ? null : {
828
+ replica: t,
829
+ id: n.id,
830
+ generation: e(t.generationAtom)
831
+ };
832
+ });
833
+ function tn(e, t) {
834
+ return Qt(t.notebook, e.get(en));
835
+ }
836
+ var nn = v((e) => {
837
+ let t = $t(e(F), e(en), Jt);
838
+ return t.size === 0 ? Yt : new Set([...t].flatMap((e) => e.cells));
839
+ }), rn = v((e) => {
840
+ let t = e(h), n = t && e(t.analysisAtom), r = n ? Rt(n.analysis, n.document.cells.values()) : Xt;
841
+ return {
842
+ shownBlocked: r,
843
+ blocked: n?.freshness === "current" ? r : Xt
844
+ };
845
+ }), an = v((e) => {
846
+ let t = e(h), n = t === null ? null : e(t.shownDocumentAtom);
847
+ return {
848
+ executions: t === null ? Gt : e(t.executionsAtom),
849
+ results: t === null ? Kt : e(t.resultsAtom),
850
+ cells: n?.cells ?? qt,
851
+ requested: e(nn),
852
+ ...e(rn),
853
+ runtimeId: t === null ? null : e(t.runtimeAtom)?.id ?? null
854
+ };
855
+ }), on = v((e) => {
856
+ let t = e(h), n = t === null ? null : e(t.shownDocumentAtom);
857
+ return t === null || n === null ? {
858
+ cells: qt,
859
+ executions: Gt,
860
+ results: Kt
861
+ } : {
862
+ cells: n.cells,
863
+ executions: e(t.executionsAtom),
864
+ results: e(t.resultsAtom)
865
+ };
866
+ }), sn = v((e) => _t(e(on))), cn = v(null), ln = v((e) => {
867
+ let t = e(h), n = t === null ? null : e(t.shownDocumentAtom);
868
+ return t === null || n === null ? null : {
869
+ replica: t,
870
+ id: n.revision.notebook_id,
871
+ generation: e(t.generationAtom)
872
+ };
873
+ }), un = v((e) => {
874
+ let t = e(h);
875
+ return {
876
+ executions: t === null ? Gt : e(t.executionsAtom),
877
+ results: t === null ? Kt : e(t.resultsAtom),
878
+ cleared: $t(e(cn), e(ln), Zt),
879
+ cells: t === null ? qt : e(t.documentAtom)?.cells ?? qt
880
+ };
881
+ }), dn = v((e) => Nt(e(un))), I = p((e) => b(dn, (t) => t.get(e) ?? null, y)), L = p((e) => v((t) => Xe(t(I(e)))));
882
+ function fn(e) {
883
+ I.remove(e), L.remove(e);
884
+ }
885
+ function pn(e, t) {
886
+ let n = e.get(un), r = new Map(n.cleared);
887
+ for (let e of t) {
888
+ let t = At(n, e);
889
+ t != null && O(t) !== null && r.set(e, {
890
+ execution: t.record.id,
891
+ version: t.outputVersion
892
+ });
893
+ }
894
+ let i = e.get(ln);
895
+ e.set(cn, i === null ? null : {
896
+ notebook: i,
897
+ value: r
898
+ });
899
+ }
900
+ var mn = v((e) => {
901
+ let t = e(h);
902
+ return t === null ? null : e(t.runtimeAtom)?.state.status ?? null;
903
+ });
904
+ v((e) => Ut(e(an).executions)), v((e) => Wt(e(an)));
905
+ var hn = v((e) => {
906
+ let t = e(h);
907
+ if (t === null) return { refused: "No notebook is connected" };
908
+ if (e(t.connectionAtom).state === D.CLOSED) return { refused: "The notebook is disconnected" };
909
+ if (e(t.notebookAtom) === null) return "waiting";
910
+ let n = e(t.runtimeAtom);
911
+ if (n === null) return { refused: "The notebook has no runtime" };
912
+ switch (n.state.status) {
913
+ case "ready": return "running";
914
+ case "ended": {
915
+ let { outcome: e } = n.state;
916
+ return { refused: e.kind === "failed" ? e.message ?? "The runtime failed" : "The notebook has no runtime" };
917
+ }
918
+ default: return "waiting";
919
+ }
920
+ });
921
+ function gn(e) {
922
+ return new Promise((t, n) => {
923
+ let r = e.sub(hn, i);
924
+ function i() {
925
+ let i = e.get(hn);
926
+ i !== "waiting" && (r(), i === "running" ? t() : n(Error(i.refused)));
927
+ }
928
+ i();
929
+ });
930
+ }
931
+ function _n(e, t) {
932
+ let n = e.get(en);
933
+ if (n === null) return null;
934
+ let r = {
935
+ notebook: n,
936
+ cells: [...t]
937
+ }, i = $t(e.get(F), n, Jt);
938
+ return e.set(F, {
939
+ notebook: n,
940
+ value: new Set(i).add(r)
941
+ }), r;
942
+ }
943
+ function vn(e, t) {
944
+ let n = e.get(F);
945
+ if (n === null || !n.value.has(t)) return;
946
+ let r = new Set(n.value);
947
+ r.delete(t), e.set(F, {
948
+ notebook: n.notebook,
949
+ value: r
950
+ });
951
+ }
952
+ function yn(e, t, n) {
953
+ let r = v((e) => Qt(t.notebook, e(en)) && !e(t.notebook.replica.executionsAtom).runs.has(n.id)), i = e.sub(r, a);
954
+ function a() {
955
+ e.get(r) || (i(), vn(e, t));
956
+ }
957
+ a();
958
+ }
959
+ //#endregion
960
+ //#region src/core/codemirror/editing/commands.ts
961
+ var bn = a();
962
+ function xn(e) {
963
+ return (t) => {
964
+ let n = !1;
965
+ for (let r of t) r && (n = e(r) || n);
966
+ return n;
967
+ };
968
+ }
969
+ var Sn = xn(_e), Cn = xn(ge);
970
+ //#endregion
971
+ //#region src/utils/schedule-task.ts
972
+ function wn() {
973
+ let e = globalThis.scheduler;
974
+ if (typeof e?.postTask == "function") return (t) => {
975
+ e.postTask(t, { priority: "user-visible" }).catch((e) => {
976
+ setTimeout(() => {
977
+ throw e;
978
+ });
979
+ });
980
+ };
981
+ if (typeof MessageChannel == "function") {
982
+ let e = [], t = new MessageChannel();
983
+ return t.port1.onmessage = () => {
984
+ e.shift()?.();
985
+ }, (n) => {
986
+ e.push(n), t.port2.postMessage(null);
987
+ };
988
+ }
989
+ return (e) => {
990
+ setTimeout(e, 0);
991
+ };
992
+ }
993
+ var Tn = wn();
994
+ //#endregion
995
+ //#region src/core/codemirror/editor-mount-scheduler.ts
996
+ function En(e = Tn) {
997
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1;
998
+ function i() {
999
+ r || t.size === 0 || (r = !0, e(o));
1000
+ }
1001
+ function a() {
1002
+ for (let e of n) {
1003
+ if (t.has(e)) return e;
1004
+ n.delete(e);
1005
+ }
1006
+ return t.keys().next().value;
1007
+ }
1008
+ function o() {
1009
+ r = !1;
1010
+ try {
1011
+ let e = a();
1012
+ if (e !== void 0) {
1013
+ let r = t.get(e);
1014
+ t.delete(e), n.delete(e), r?.();
1015
+ }
1016
+ } finally {
1017
+ i();
1018
+ }
1019
+ }
1020
+ return {
1021
+ request(e, n) {
1022
+ t.set(e, n), i();
1023
+ },
1024
+ promote(e) {
1025
+ let r = t.get(e);
1026
+ r && (t.delete(e), n.delete(e), r());
1027
+ },
1028
+ prioritize(e) {
1029
+ t.has(e) && n.add(e);
1030
+ },
1031
+ deprioritize(e) {
1032
+ n.delete(e);
1033
+ },
1034
+ cancel(e) {
1035
+ t.delete(e), n.delete(e);
1036
+ }
1037
+ };
1038
+ }
1039
+ var Dn = En();
1040
+ //#endregion
1041
+ //#region src/core/mime.ts
1042
+ function On(e) {
1043
+ return e === "application/vnd.marimo+error";
1044
+ }
1045
+ function kn(e) {
1046
+ return e === "application/vnd.marimo+traceback";
1047
+ }
1048
+ function R(e) {
1049
+ return On(e) || kn(e);
1050
+ }
1051
+ //#endregion
1052
+ //#region src/core/cells/command-console.ts
1053
+ function An(e, { op: t, entries: n, replace: r, after_seq: i }, a) {
1054
+ if (t === "callback-output" && !r && n.length === 0) return { entries: [] };
1055
+ let o = r || n.length === 0, s = e?.entries ?? [], c = r && a !== void 0 ? n.findIndex((e) => e.command_id === a) : -1, l = n.slice(c + 1).map((e, n) => ({
1056
+ ...e,
1057
+ source: t,
1058
+ afterSeq: i?.[c + 1 + n]
1059
+ }));
1060
+ return { entries: [...o ? s.filter((e) => e.source !== t) : s, ...l] };
1061
+ }
1062
+ //#endregion
1063
+ //#region src/core/dom/ui-element-constants.ts
1064
+ var jn = "object-id", Mn = "random-id", Nn = "abcdefghijklmnopqrstuvwxyz", Pn = Nn + Nn.toUpperCase(), Fn = /* @__PURE__ */ new Set(), z = "__scratch__", In = "setup", Ln = { create() {
1065
+ let e = 0, t;
1066
+ do {
1067
+ let n = "";
1068
+ for (let e = 0; e < 4; e++) n += Pn[Math.floor(Math.random() * 52)];
1069
+ t = n, e++;
1070
+ } while (Fn.has(t) && e < 100);
1071
+ if (e >= 100) throw Error("Failed to generate unique CellId after 100 attempts");
1072
+ return Fn.add(t), t;
1073
+ } }, B = {
1074
+ create(e) {
1075
+ return S(e != null, "cellId is required"), `cell-${e}`;
1076
+ },
1077
+ parse(e) {
1078
+ return e.slice(5);
1079
+ },
1080
+ findElement(e) {
1081
+ return e.closest("div[id^=\"cell-\"]");
1082
+ },
1083
+ findElementThroughShadowDOMs(e) {
1084
+ let t = e;
1085
+ for (; t;) {
1086
+ let e = B.findElement(t);
1087
+ if (e) return e;
1088
+ let n = t.getRootNode();
1089
+ if (t = n instanceof ShadowRoot ? n.host : t.parentElement, t === n) break;
1090
+ }
1091
+ return null;
1092
+ }
1093
+ };
1094
+ function Rn(e) {
1095
+ let t = null, n = B.findElementThroughShadowDOMs(e);
1096
+ return n && (t = B.parse(n.id)), t;
1097
+ }
1098
+ var zn = {
1099
+ parse(e) {
1100
+ return e.getAttribute(jn);
1101
+ },
1102
+ parseOrThrow(e) {
1103
+ let t = zn.parse(e);
1104
+ return S(t, "<marimo-ui-element/> missing object-id attribute"), t;
1105
+ }
1106
+ }, Bn = { create(e) {
1107
+ return `output-${e}`;
1108
+ } }, Vn = /\/@file\/([^\s"&'/]+)\.([\dA-Za-z]+)/g, Hn = class e {
1109
+ static get INSTANCE() {
1110
+ let t = "_marimo_private_VirtualFileTracker";
1111
+ return window[t] || (window[t] = new e()), window[t];
1112
+ }
1113
+ virtualFiles = /* @__PURE__ */ new Map();
1114
+ callbackFiles = /* @__PURE__ */ new Map();
1115
+ constructor() {}
1116
+ track(e) {
1117
+ this.trackValue(e.cell_id, e.output);
1118
+ }
1119
+ trackOutput(e, t) {
1120
+ e.media && this.trackValue(t.cell_id ?? "__scratch__", e.media);
1121
+ }
1122
+ trackCallbackOutput(e) {
1123
+ (e.replace || e.entries.length === 0) && this.callbackFiles.delete(e.cell_id);
1124
+ for (let t of e.entries) this.trackValue(e.cell_id, t, this.callbackFiles);
1125
+ }
1126
+ trackValue(e, t, n = this.virtualFiles) {
1127
+ switch (t.mimetype) {
1128
+ case "application/json":
1129
+ case "text/html": {
1130
+ let r = n.get(e), i = Un(t.data);
1131
+ r?.forEach((e) => i.add(e)), n.set(e, i);
1132
+ return;
1133
+ }
1134
+ default: return;
1135
+ }
1136
+ }
1137
+ filenames() {
1138
+ let e = /* @__PURE__ */ new Set();
1139
+ for (let t of [...this.virtualFiles.values(), ...this.callbackFiles.values()]) t.forEach((t) => e.add(t));
1140
+ return [...e];
1141
+ }
1142
+ removeForCellId(e) {
1143
+ this.virtualFiles.delete(e), this.callbackFiles.delete(e);
1144
+ }
1145
+ };
1146
+ function Un(e) {
1147
+ if (!e) return /* @__PURE__ */ new Set();
1148
+ let t = /* @__PURE__ */ new Set(), n = (typeof e == "string" ? e : JSON.stringify(e)).match(Vn);
1149
+ if (n) for (let e of n) t.add(e);
1150
+ return t;
1151
+ }
1152
+ //#endregion
1153
+ //#region src/components/editor/output/ansi-reduce.ts
1154
+ var Wn = class e {
1155
+ lines = [""];
1156
+ cursor = {
1157
+ row: 0,
1158
+ col: 0
1159
+ };
1160
+ firstRow;
1161
+ constructor(e = 0) {
1162
+ this.firstRow = e;
1163
+ }
1164
+ copy(t = 0) {
1165
+ let n = new e(this.firstRow + t);
1166
+ return n.lines = this.lines.slice(t), n.cursor = {
1167
+ row: this.cursor.row - t,
1168
+ col: this.cursor.col
1169
+ }, n;
1170
+ }
1171
+ static ESCAPE_REGEX = new RegExp(String.raw`\u001B\[([0-9;]*)([A-DJKH])`, "u");
1172
+ ensureLine(e) {
1173
+ for (; this.lines.length <= e;) this.lines.push("");
1174
+ }
1175
+ moveCursor(e, t) {
1176
+ this.cursor.row = Math.max(-this.firstRow, this.cursor.row + e), this.cursor.col = Math.max(0, this.cursor.col + t), this.ensureLine(this.cursor.row);
1177
+ }
1178
+ setCursor(e, t) {
1179
+ this.cursor.row = Math.max(0, e) - this.firstRow, this.cursor.col = Math.max(0, t), this.ensureLine(this.cursor.row);
1180
+ }
1181
+ writeChar(e) {
1182
+ this.writeString(e);
1183
+ }
1184
+ writeString(e) {
1185
+ if (this.cursor.row < 0 || e.length === 0) {
1186
+ this.cursor.col += e.length;
1187
+ return;
1188
+ }
1189
+ this.ensureLine(this.cursor.row);
1190
+ let t = this.lines[this.cursor.row].padEnd(this.cursor.col, " ");
1191
+ this.lines[this.cursor.row] = t.slice(0, this.cursor.col) + e + t.slice(this.cursor.col + e.length), this.cursor.col += e.length;
1192
+ }
1193
+ control(e) {
1194
+ switch (e) {
1195
+ case "\n":
1196
+ this.cursor.row++, this.cursor.col = 0, this.ensureLine(this.cursor.row);
1197
+ break;
1198
+ case "\r":
1199
+ this.cursor.col = 0;
1200
+ break;
1201
+ case " ":
1202
+ this.writeChar(" ");
1203
+ break;
1204
+ case "\b":
1205
+ this.cursor.col = Math.max(0, this.cursor.col - 1);
1206
+ break;
1207
+ case "\v": this.cursor.row++, this.ensureLine(this.cursor.row);
1208
+ }
1209
+ }
1210
+ handleEscape(t) {
1211
+ let n = e.ESCAPE_REGEX.exec(t);
1212
+ if (!n) {
1213
+ this.writeString(t);
1214
+ return;
1215
+ }
1216
+ let r = n[1].split(";").map((e) => e === "" ? 1 : Number.parseInt(e, 10));
1217
+ switch (n[2]) {
1218
+ case "A":
1219
+ this.moveCursor(-r[0], 0);
1220
+ break;
1221
+ case "B":
1222
+ this.moveCursor(r[0], 0);
1223
+ break;
1224
+ case "C":
1225
+ this.moveCursor(0, r[0]);
1226
+ break;
1227
+ case "D":
1228
+ this.moveCursor(0, -r[0]);
1229
+ break;
1230
+ case "H":
1231
+ this.setCursor(r[0] - 1 || 0, r[1] - 1 || 0);
1232
+ break;
1233
+ case "J":
1234
+ r[0] === 2 && (this.lines = [""], this.firstRow = 0, this.setCursor(0, 0));
1235
+ break;
1236
+ case "K":
1237
+ if (this.cursor.row < 0) break;
1238
+ switch (this.ensureLine(this.cursor.row), r[0]) {
1239
+ case 0:
1240
+ this.lines[this.cursor.row] = this.lines[this.cursor.row].slice(0, this.cursor.col);
1241
+ break;
1242
+ case 1: {
1243
+ let e = this.lines[this.cursor.row].length;
1244
+ this.lines[this.cursor.row] = " ".repeat(this.cursor.col) + this.lines[this.cursor.row].slice(this.cursor.col, e);
1245
+ break;
1246
+ }
1247
+ case 2: this.lines[this.cursor.row] = "";
1248
+ }
1249
+ break;
1250
+ default: this.writeString(t);
1251
+ }
1252
+ }
1253
+ render() {
1254
+ return this.lines.join("\n");
1255
+ }
1256
+ }, Gn = class {
1257
+ ESC_REGEX = new RegExp(String.raw`\u001B(?:\[[0-9;]*[A-Za-z]|\([0-9A-Za-z])`, "gu");
1258
+ parse(e) {
1259
+ let t = [], n = 0;
1260
+ for (let r of e.matchAll(this.ESC_REGEX)) {
1261
+ let i = r.index ?? 0;
1262
+ i > n && t.push({
1263
+ type: "text",
1264
+ value: e.slice(n, i)
1265
+ }), t.push({
1266
+ type: "escape",
1267
+ value: r[0]
1268
+ }), n = i + r[0].length;
1269
+ }
1270
+ return n < e.length && t.push({
1271
+ type: "text",
1272
+ value: e.slice(n)
1273
+ }), t;
1274
+ }
1275
+ }, Kn = class e {
1276
+ parser = new Gn();
1277
+ buffer;
1278
+ incompleteEscape = "";
1279
+ static INCOMPLETE_ESCAPE = new RegExp(String.raw`\u001B(?:\[[0-9;]*|\()?$`, "u");
1280
+ constructor(e = 0) {
1281
+ this.buffer = new Wn(e);
1282
+ }
1283
+ copy(t = 0) {
1284
+ let n = new e();
1285
+ return n.buffer = this.buffer.copy(t), n.incompleteEscape = this.incompleteEscape, n;
1286
+ }
1287
+ reduce(e) {
1288
+ return this.reset(), this.append(e), this.render();
1289
+ }
1290
+ append(t) {
1291
+ t = this.incompleteEscape + t;
1292
+ let n = e.INCOMPLETE_ESCAPE.exec(t);
1293
+ this.incompleteEscape = n?.[0] ?? "", n && (t = t.slice(0, n.index));
1294
+ let r = this.parser.parse(t);
1295
+ if (r.length === 1 && r[0].type === "text") {
1296
+ let e = r[0].value;
1297
+ if (!this.hasControlChars(e)) {
1298
+ this.buffer.writeString(e);
1299
+ return;
1300
+ }
1301
+ }
1302
+ for (let e of r) e.type === "text" ? this.processText(e.value) : this.buffer.handleEscape(e.value);
1303
+ }
1304
+ reset() {
1305
+ this.buffer = new Wn(), this.incompleteEscape = "";
1306
+ }
1307
+ render() {
1308
+ return this.buffer.render();
1309
+ }
1310
+ hasControlChars(e) {
1311
+ for (let t of e) if (t < " ") return !0;
1312
+ return !1;
1313
+ }
1314
+ processText(e) {
1315
+ let t = 0, n = e.length;
1316
+ for (let r = 0; r < n; r++) {
1317
+ let n = e[r];
1318
+ if (n === "\n" || n === "\r" || n === " " || n === "\b" || n === "\v") {
1319
+ if (r > t) {
1320
+ let n = e.slice(t, r), i = this.filterControlChars(n);
1321
+ i.length > 0 && this.buffer.writeString(i);
1322
+ }
1323
+ this.buffer.control(n), t = r + 1;
1324
+ } else if (n < " ") {
1325
+ if (r > t) {
1326
+ let n = e.slice(t, r);
1327
+ n.length > 0 && this.buffer.writeString(n);
1328
+ }
1329
+ t = r + 1;
1330
+ }
1331
+ }
1332
+ if (t < n) {
1333
+ let n = e.slice(t), r = this.filterControlChars(n);
1334
+ r.length > 0 && this.buffer.writeString(r);
1335
+ }
1336
+ }
1337
+ filterControlChars(e) {
1338
+ let t = !1;
1339
+ for (let n of e) if (n < " ") {
1340
+ t = !0;
1341
+ break;
1342
+ }
1343
+ if (!t) return e;
1344
+ let n = "";
1345
+ for (let t of e) t >= " " && (n += t);
1346
+ return n;
1347
+ }
1348
+ };
1349
+ function qn(e) {
1350
+ let t = 1;
1351
+ for (let n = 0; n < e.length; n++) {
1352
+ let r = e.charCodeAt(n);
1353
+ if (r === 10) t++;
1354
+ else if (r < 32) return;
1355
+ }
1356
+ return t;
1357
+ }
1358
+ var V = class e {
1359
+ mimetype;
1360
+ channel;
1361
+ timestamp;
1362
+ code;
1363
+ id;
1364
+ input_id;
1365
+ data;
1366
+ lineCount;
1367
+ terminal;
1368
+ firstPlainRow;
1369
+ constructor(e, t) {
1370
+ this.data = t.data, this.lineCount = t.lineCount, this.terminal = t.terminal, this.firstPlainRow = t.firstPlainRow ?? 0, this.mimetype = e.mimetype, this.channel = e.channel, this.timestamp = e.timestamp, this.code = e.code, this.id = e.id, this.input_id = e.input_id;
1371
+ }
1372
+ static create(t) {
1373
+ return new e(t, {
1374
+ data: "",
1375
+ lineCount: 1
1376
+ }).appendData(t.data);
1377
+ }
1378
+ appendData(t) {
1379
+ if (!this.terminal) {
1380
+ let n = qn(t);
1381
+ if (n !== void 0) return new e(this, {
1382
+ data: this.data + t,
1383
+ lineCount: this.lineCount + n - 1,
1384
+ firstPlainRow: this.firstPlainRow
1385
+ });
1386
+ }
1387
+ let n = this.terminal?.copy() ?? new Kn(this.firstPlainRow);
1388
+ this.terminal || n.append(this.data), n.append(t);
1389
+ let r = n.render();
1390
+ return new e(this, {
1391
+ data: r,
1392
+ lineCount: r.split("\n").length,
1393
+ terminal: n
1394
+ });
1395
+ }
1396
+ dropFirstLines(t) {
1397
+ if (t === 0) return this;
1398
+ let n = this.terminal?.copy(t);
1399
+ return new e(this, {
1400
+ data: n?.render() ?? this.data.split("\n").slice(t).join("\n"),
1401
+ lineCount: this.lineCount - t,
1402
+ terminal: n,
1403
+ firstPlainRow: this.firstPlainRow + t
1404
+ });
1405
+ }
1406
+ toJSON() {
1407
+ return {
1408
+ mimetype: this.mimetype,
1409
+ channel: this.channel,
1410
+ timestamp: this.timestamp,
1411
+ data: this.data,
1412
+ ...this.code === void 0 ? {} : { code: this.code }
1413
+ };
1414
+ }
1415
+ }, Jn = 5e3;
1416
+ function Yn(e, t = Jn) {
1417
+ let n = e.slice(0, -1), r = e.at(-1);
1418
+ return r && Zn(n, r), nr(n, t);
1419
+ }
1420
+ function Xn(e) {
1421
+ let t = [];
1422
+ for (let n = 0; n < e.length;) {
1423
+ let r = e[n], i = n + 1;
1424
+ for (; i < e.length && Qn(r, e[i]);) i++;
1425
+ if (i === n + 1) Zn(t, r);
1426
+ else {
1427
+ let a = e.slice(n, i).map((e) => (tr(e), e.data));
1428
+ t.push(V.create({
1429
+ ...r,
1430
+ data: a.join("")
1431
+ }));
1432
+ }
1433
+ n = i;
1434
+ }
1435
+ return nr(t, Jn);
1436
+ }
1437
+ function Zn(e, t) {
1438
+ let n = e.at(-1);
1439
+ n && Qn(n, t) ? (tr(n), tr(t), e[e.length - 1] = er(n, t)) : e.push($n(t));
1440
+ }
1441
+ function Qn(e, t) {
1442
+ let n = e.mimetype === "text/plain" && t.mimetype === "text/plain";
1443
+ if (!n) return !1;
1444
+ let r = e.channel === t.channel, i = e.channel !== "stdin";
1445
+ return n && r && i;
1446
+ }
1447
+ function $n(e) {
1448
+ return e instanceof V ? e : e.mimetype === "text/plain" && e.channel !== "stdin" && typeof e.data == "string" ? V.create(e) : e;
1449
+ }
1450
+ function er(e, t) {
1451
+ return e instanceof V ? e.appendData(t.data) : V.create(e).appendData(t.data);
1452
+ }
1453
+ function tr(e) {
1454
+ S(typeof e.data == "string", "expected string output");
1455
+ }
1456
+ function nr(e, t) {
1457
+ let n = 0, r;
1458
+ for (r = e.length - 1; r >= 0 && n < t; r--) {
1459
+ let t = e[r];
1460
+ t.mimetype === "text/plain" ? (S(typeof t.data == "string", "expected string"), n += t instanceof V ? t.lineCount : t.data.split("\n").length) : n++;
1461
+ }
1462
+ if (n < t) return e;
1463
+ let i = r + 1, a = [{
1464
+ channel: "stderr",
1465
+ mimetype: "text/html",
1466
+ data: `<pre>Streaming output truncated to last ${t} lines.\n</pre>`,
1467
+ timestamp: -1
1468
+ }, ...e.slice(0, i).filter((e) => e.channel === "stdin" && e.response === void 0)], o = e[i];
1469
+ if (o?.channel === "stdin" && o.response === void 0) return [...a, ...e.slice(i)];
1470
+ if (o?.mimetype === "text/plain") {
1471
+ S(typeof o.data == "string", "expected string");
1472
+ let r = n - t, s = o instanceof V ? o.dropFirstLines(r) : {
1473
+ ...o,
1474
+ data: o.data.split("\n").slice(r).join("\n")
1475
+ };
1476
+ return [
1477
+ ...a,
1478
+ s,
1479
+ ...e.slice(i + 1)
1480
+ ];
1481
+ }
1482
+ return [...a, ...e.slice(i + 1)];
1483
+ }
1484
+ //#endregion
1485
+ //#region ../node_modules/.pnpm/date-fns@4.4.0/node_modules/date-fns/fromUnixTime.js
1486
+ function rr(e, t) {
1487
+ return Se(e * 1e3, t?.in);
1488
+ }
1489
+ //#endregion
1490
+ //#region ../node_modules/.pnpm/ansi_up@6.0.6/node_modules/ansi_up/ansi_up.js
1491
+ var ir = function(e, t) {
1492
+ return Object.defineProperty ? Object.defineProperty(e, "raw", { value: t }) : e.raw = t, e;
1493
+ }, H;
1494
+ (function(e) {
1495
+ e[e.EOS = 0] = "EOS", e[e.Text = 1] = "Text", e[e.Incomplete = 2] = "Incomplete", e[e.ESC = 3] = "ESC", e[e.Unknown = 4] = "Unknown", e[e.SGR = 5] = "SGR", e[e.OSCURL = 6] = "OSCURL";
1496
+ })(H ||= {});
1497
+ var ar = class {
1498
+ constructor() {
1499
+ this.VERSION = "6.0.6", this.setup_palettes(), this._use_classes = !1, this.bold = !1, this.faint = !1, this.italic = !1, this.underline = !1, this.fg = this.bg = null, this._buffer = "", this._url_allowlist = {
1500
+ http: 1,
1501
+ https: 1
1502
+ }, this._escape_html = !0, this.boldStyle = "font-weight:bold", this.faintStyle = "opacity:0.7", this.italicStyle = "font-style:italic", this.underlineStyle = "text-decoration:underline";
1503
+ }
1504
+ set use_classes(e) {
1505
+ this._use_classes = e;
1506
+ }
1507
+ get use_classes() {
1508
+ return this._use_classes;
1509
+ }
1510
+ set url_allowlist(e) {
1511
+ this._url_allowlist = e;
1512
+ }
1513
+ get url_allowlist() {
1514
+ return this._url_allowlist;
1515
+ }
1516
+ set escape_html(e) {
1517
+ this._escape_html = e;
1518
+ }
1519
+ get escape_html() {
1520
+ return this._escape_html;
1521
+ }
1522
+ set boldStyle(e) {
1523
+ this._boldStyle = e;
1524
+ }
1525
+ get boldStyle() {
1526
+ return this._boldStyle;
1527
+ }
1528
+ set faintStyle(e) {
1529
+ this._faintStyle = e;
1530
+ }
1531
+ get faintStyle() {
1532
+ return this._faintStyle;
1533
+ }
1534
+ set italicStyle(e) {
1535
+ this._italicStyle = e;
1536
+ }
1537
+ get italicStyle() {
1538
+ return this._italicStyle;
1539
+ }
1540
+ set underlineStyle(e) {
1541
+ this._underlineStyle = e;
1542
+ }
1543
+ get underlineStyle() {
1544
+ return this._underlineStyle;
1545
+ }
1546
+ setup_palettes() {
1547
+ this.ansi_colors = [[
1548
+ {
1549
+ rgb: [
1550
+ 0,
1551
+ 0,
1552
+ 0
1553
+ ],
1554
+ class_name: "ansi-black"
1555
+ },
1556
+ {
1557
+ rgb: [
1558
+ 187,
1559
+ 0,
1560
+ 0
1561
+ ],
1562
+ class_name: "ansi-red"
1563
+ },
1564
+ {
1565
+ rgb: [
1566
+ 0,
1567
+ 187,
1568
+ 0
1569
+ ],
1570
+ class_name: "ansi-green"
1571
+ },
1572
+ {
1573
+ rgb: [
1574
+ 187,
1575
+ 187,
1576
+ 0
1577
+ ],
1578
+ class_name: "ansi-yellow"
1579
+ },
1580
+ {
1581
+ rgb: [
1582
+ 0,
1583
+ 0,
1584
+ 187
1585
+ ],
1586
+ class_name: "ansi-blue"
1587
+ },
1588
+ {
1589
+ rgb: [
1590
+ 187,
1591
+ 0,
1592
+ 187
1593
+ ],
1594
+ class_name: "ansi-magenta"
1595
+ },
1596
+ {
1597
+ rgb: [
1598
+ 0,
1599
+ 187,
1600
+ 187
1601
+ ],
1602
+ class_name: "ansi-cyan"
1603
+ },
1604
+ {
1605
+ rgb: [
1606
+ 255,
1607
+ 255,
1608
+ 255
1609
+ ],
1610
+ class_name: "ansi-white"
1611
+ }
1612
+ ], [
1613
+ {
1614
+ rgb: [
1615
+ 85,
1616
+ 85,
1617
+ 85
1618
+ ],
1619
+ class_name: "ansi-bright-black"
1620
+ },
1621
+ {
1622
+ rgb: [
1623
+ 255,
1624
+ 85,
1625
+ 85
1626
+ ],
1627
+ class_name: "ansi-bright-red"
1628
+ },
1629
+ {
1630
+ rgb: [
1631
+ 0,
1632
+ 255,
1633
+ 0
1634
+ ],
1635
+ class_name: "ansi-bright-green"
1636
+ },
1637
+ {
1638
+ rgb: [
1639
+ 255,
1640
+ 255,
1641
+ 85
1642
+ ],
1643
+ class_name: "ansi-bright-yellow"
1644
+ },
1645
+ {
1646
+ rgb: [
1647
+ 85,
1648
+ 85,
1649
+ 255
1650
+ ],
1651
+ class_name: "ansi-bright-blue"
1652
+ },
1653
+ {
1654
+ rgb: [
1655
+ 255,
1656
+ 85,
1657
+ 255
1658
+ ],
1659
+ class_name: "ansi-bright-magenta"
1660
+ },
1661
+ {
1662
+ rgb: [
1663
+ 85,
1664
+ 255,
1665
+ 255
1666
+ ],
1667
+ class_name: "ansi-bright-cyan"
1668
+ },
1669
+ {
1670
+ rgb: [
1671
+ 255,
1672
+ 255,
1673
+ 255
1674
+ ],
1675
+ class_name: "ansi-bright-white"
1676
+ }
1677
+ ]], this.palette_256 = [], this.ansi_colors.forEach((e) => {
1678
+ e.forEach((e) => {
1679
+ this.palette_256.push(e);
1680
+ });
1681
+ });
1682
+ let e = [
1683
+ 0,
1684
+ 95,
1685
+ 135,
1686
+ 175,
1687
+ 215,
1688
+ 255
1689
+ ];
1690
+ for (let t = 0; t < 6; ++t) for (let n = 0; n < 6; ++n) for (let r = 0; r < 6; ++r) {
1691
+ let i = {
1692
+ rgb: [
1693
+ e[t],
1694
+ e[n],
1695
+ e[r]
1696
+ ],
1697
+ class_name: "truecolor"
1698
+ };
1699
+ this.palette_256.push(i);
1700
+ }
1701
+ let t = 8;
1702
+ for (let e = 0; e < 24; ++e, t += 10) {
1703
+ let e = {
1704
+ rgb: [
1705
+ t,
1706
+ t,
1707
+ t
1708
+ ],
1709
+ class_name: "truecolor"
1710
+ };
1711
+ this.palette_256.push(e);
1712
+ }
1713
+ }
1714
+ escape_txt_for_html(e) {
1715
+ return this._escape_html ? e.replace(/[&<>"']/gm, (e) => {
1716
+ if (e === "&") return "&amp;";
1717
+ if (e === "<") return "&lt;";
1718
+ if (e === ">") return "&gt;";
1719
+ if (e === "\"") return "&quot;";
1720
+ if (e === "'") return "&#x27;";
1721
+ }) : e;
1722
+ }
1723
+ append_buffer(e) {
1724
+ var t = this._buffer + e;
1725
+ this._buffer = t;
1726
+ }
1727
+ get_next_packet() {
1728
+ var e = {
1729
+ kind: H.EOS,
1730
+ text: "",
1731
+ url: ""
1732
+ }, t = this._buffer.length;
1733
+ if (t == 0) return e;
1734
+ var n = this._buffer.indexOf("\x1B");
1735
+ if (n == -1) return e.kind = H.Text, e.text = this._buffer, this._buffer = "", e;
1736
+ if (n > 0) return e.kind = H.Text, e.text = this._buffer.slice(0, n), this._buffer = this._buffer.slice(n), e;
1737
+ if (n == 0) {
1738
+ if (t < 3) return e.kind = H.Incomplete, e;
1739
+ var r = this._buffer.charAt(1);
1740
+ if (r != "[" && r != "]" && r != "(") return e.kind = H.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
1741
+ if (r == "[") {
1742
+ this._csi_regex ||= or(cr ||= ir(["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \x1B[ # CSI\n ([<-?]?) # private-mode char\n ([d;]*) # any digits or semicolons\n ([ -/]? # an intermediate modifier\n [@-~]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \x1B[ # CSI\n [ -~]* # anything legal\n ([\0-:]) # anything illegal\n )\n "], ["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \\x1b\\[ # CSI\n ([\\x3c-\\x3f]?) # private-mode char\n ([\\d;]*) # any digits or semicolons\n ([\\x20-\\x2f]? # an intermediate modifier\n [\\x40-\\x7e]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \\x1b\\[ # CSI\n [\\x20-\\x7e]* # anything legal\n ([\\x00-\\x1f:]) # anything illegal\n )\n "]));
1743
+ let t = this._buffer.match(this._csi_regex);
1744
+ if (t === null) return e.kind = H.Incomplete, e;
1745
+ if (t[4]) return e.kind = H.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
1746
+ e.kind = t[1] != "" || t[3] != "m" ? H.Unknown : H.SGR, e.text = t[2];
1747
+ var i = t[0].length;
1748
+ return this._buffer = this._buffer.slice(i), e;
1749
+ }
1750
+ if (r == "]") {
1751
+ if (t < 4) return e.kind = H.Incomplete, e;
1752
+ if (this._buffer.charAt(2) != "8" || this._buffer.charAt(3) != ";") return e.kind = H.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
1753
+ this._osc_st ||= sr(lr ||= ir(["\n (?: # legal sequence\n (\x1B\\) # ESC | # alternate\n (\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\0-] # anything illegal\n | # alternate\n [\b-] # anything illegal\n | # alternate\n [-] # anything illegal\n )\n "], ["\n (?: # legal sequence\n (\\x1b\\\\) # ESC \\\n | # alternate\n (\\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\\x00-\\x06] # anything illegal\n | # alternate\n [\\x08-\\x1a] # anything illegal\n | # alternate\n [\\x1c-\\x1f] # anything illegal\n )\n "])), this._osc_st.lastIndex = 0;
1754
+ {
1755
+ let t = this._osc_st.exec(this._buffer);
1756
+ if (t === null) return e.kind = H.Incomplete, e;
1757
+ if (t[3]) return e.kind = H.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
1758
+ }
1759
+ {
1760
+ let t = this._osc_st.exec(this._buffer);
1761
+ if (t === null) return e.kind = H.Incomplete, e;
1762
+ if (t[3]) return e.kind = H.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
1763
+ }
1764
+ this._osc_regex ||= or(ur ||= ir(["\n ^ # beginning of line\n #\n \x1B]8; # OSC Hyperlink\n [ -:<-~]* # params (excluding ;)\n ; # end of params\n ([!-~]{0,512}) # URL capture\n (?: # ST\n (?:\x1B\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n ([ -~]+) # TEXT capture\n \x1B]8;; # OSC Hyperlink End\n (?: # ST\n (?:\x1B\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n "], ["\n ^ # beginning of line\n #\n \\x1b\\]8; # OSC Hyperlink\n [\\x20-\\x3a\\x3c-\\x7e]* # params (excluding ;)\n ; # end of params\n ([\\x21-\\x7e]{0,512}) # URL capture\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n ([\\x20-\\x7e]+) # TEXT capture\n \\x1b\\]8;; # OSC Hyperlink End\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n "]));
1765
+ let n = this._buffer.match(this._osc_regex);
1766
+ if (n === null) return e.kind = H.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
1767
+ e.kind = H.OSCURL, e.url = n[1], e.text = n[2];
1768
+ var i = n[0].length;
1769
+ return this._buffer = this._buffer.slice(i), e;
1770
+ }
1771
+ if (r == "(") return e.kind = H.Unknown, this._buffer = this._buffer.slice(3), e;
1772
+ }
1773
+ }
1774
+ ansi_to_html(e) {
1775
+ this.append_buffer(e);
1776
+ for (var t = [];;) {
1777
+ var n = this.get_next_packet();
1778
+ if (n.kind == H.EOS || n.kind == H.Incomplete) break;
1779
+ n.kind != H.ESC && n.kind != H.Unknown && (n.kind == H.Text ? t.push(this.transform_to_html(this.with_state(n))) : n.kind == H.SGR ? this.process_ansi(n) : n.kind == H.OSCURL && t.push(this.process_hyperlink(n)));
1780
+ }
1781
+ return t.join("");
1782
+ }
1783
+ with_state(e) {
1784
+ return {
1785
+ bold: this.bold,
1786
+ faint: this.faint,
1787
+ italic: this.italic,
1788
+ underline: this.underline,
1789
+ fg: this.fg,
1790
+ bg: this.bg,
1791
+ text: e.text
1792
+ };
1793
+ }
1794
+ process_ansi(e) {
1795
+ let t = e.text.split(";");
1796
+ for (; t.length > 0;) {
1797
+ let e = t.shift(), n = parseInt(e, 10);
1798
+ if (isNaN(n) || n === 0) this.fg = null, this.bg = null, this.bold = !1, this.faint = !1, this.italic = !1, this.underline = !1;
1799
+ else if (n === 1) this.bold = !0;
1800
+ else if (n === 2) this.faint = !0;
1801
+ else if (n === 3) this.italic = !0;
1802
+ else if (n === 4) this.underline = !0;
1803
+ else if (n === 21) this.bold = !1;
1804
+ else if (n === 22) this.faint = !1, this.bold = !1;
1805
+ else if (n === 23) this.italic = !1;
1806
+ else if (n === 24) this.underline = !1;
1807
+ else if (n === 39) this.fg = null;
1808
+ else if (n === 49) this.bg = null;
1809
+ else if (n >= 30 && n < 38) this.fg = this.ansi_colors[0][n - 30];
1810
+ else if (n >= 40 && n < 48) this.bg = this.ansi_colors[0][n - 40];
1811
+ else if (n >= 90 && n < 98) this.fg = this.ansi_colors[1][n - 90];
1812
+ else if (n >= 100 && n < 108) this.bg = this.ansi_colors[1][n - 100];
1813
+ else if ((n === 38 || n === 48) && t.length > 0) {
1814
+ let e = n === 38, r = t.shift();
1815
+ if (r === "5" && t.length > 0) {
1816
+ let n = parseInt(t.shift(), 10);
1817
+ n >= 0 && n <= 255 && (e ? this.fg = this.palette_256[n] : this.bg = this.palette_256[n]);
1818
+ }
1819
+ if (r === "2" && t.length > 2) {
1820
+ let n = parseInt(t.shift(), 10), r = parseInt(t.shift(), 10), i = parseInt(t.shift(), 10);
1821
+ if (n >= 0 && n <= 255 && r >= 0 && r <= 255 && i >= 0 && i <= 255) {
1822
+ let t = {
1823
+ rgb: [
1824
+ n,
1825
+ r,
1826
+ i
1827
+ ],
1828
+ class_name: "truecolor"
1829
+ };
1830
+ e ? this.fg = t : this.bg = t;
1831
+ }
1832
+ }
1833
+ }
1834
+ }
1835
+ }
1836
+ transform_to_html(e) {
1837
+ let t = e.text;
1838
+ if (t.length === 0 || (t = this.escape_txt_for_html(t), !e.bold && !e.italic && !e.faint && !e.underline && e.fg === null && e.bg === null)) return t;
1839
+ let n = [], r = [], i = e.fg, a = e.bg;
1840
+ e.bold && n.push(this._boldStyle), e.faint && n.push(this._faintStyle), e.italic && n.push(this._italicStyle), e.underline && n.push(this._underlineStyle), this._use_classes ? (i && (i.class_name === "truecolor" ? n.push(`color:rgb(${i.rgb.join(",")})`) : r.push(`${i.class_name}-fg`)), a && (a.class_name === "truecolor" ? n.push(`background-color:rgb(${a.rgb.join(",")})`) : r.push(`${a.class_name}-bg`))) : (i && n.push(`color:rgb(${i.rgb.join(",")})`), a && n.push(`background-color:rgb(${a.rgb})`));
1841
+ let o = "", s = "";
1842
+ return r.length && (o = ` class="${r.join(" ")}"`), n.length && (s = ` style="${n.join(";")}"`), `<span${s}${o}>${t}</span>`;
1843
+ }
1844
+ process_hyperlink(e) {
1845
+ let t = e.url.split(":");
1846
+ return t.length < 1 || !this._url_allowlist[t[0]] ? "" : `<a href="${this.escape_txt_for_html(e.url)}">${this.escape_txt_for_html(e.text)}</a>`;
1847
+ }
1848
+ };
1849
+ function or(e, ...t) {
1850
+ let n = e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm, "");
1851
+ return new RegExp(n);
1852
+ }
1853
+ function sr(e, ...t) {
1854
+ let n = e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm, "");
1855
+ return new RegExp(n, "g");
1856
+ }
1857
+ var cr, lr, ur, dr = new ar();
1858
+ function U(e) {
1859
+ try {
1860
+ let t = document.createElement("div");
1861
+ return t.innerHTML = e, (t.textContent || t.innerText || "").split("\n").map((e) => e.trimEnd()).join("\n");
1862
+ } catch (n) {
1863
+ return t.error("Error parsing HTML content:", n), e;
1864
+ }
1865
+ }
1866
+ function fr(e) {
1867
+ if (!e) return "";
1868
+ try {
1869
+ return U(dr.ansi_to_html(e));
1870
+ } catch (n) {
1871
+ return t.error("Error converting ANSI to plain text:", n), e;
1872
+ }
1873
+ }
1874
+ //#endregion
1875
+ //#region src/core/errors/traceback-atom.ts
1876
+ var pr = v(null);
1877
+ //#endregion
1878
+ //#region src/core/cells/logs.ts
1879
+ function mr(e) {
1880
+ return e.type === "cell" ? e.cellId : `lsp:${e.name}`;
1881
+ }
1882
+ var hr = !1;
1883
+ function gr(e) {
1884
+ let t = [], n = [e.console].filter(Boolean).flat();
1885
+ for (let r of n) {
1886
+ let n = r.mimetype === "text/plain", i = r.mimetype === "text/html" || r.mimetype === "application/vnd.marimo+traceback";
1887
+ if (n || i) {
1888
+ let n = r.channel === "stderr" || r.channel === "marimo-error";
1889
+ switch (r.channel) {
1890
+ case "stdout":
1891
+ case "stderr":
1892
+ case "marimo-error": {
1893
+ let a = d.asString(r.data), o = i ? U(a) : a;
1894
+ t.push({
1895
+ timestamp: r.timestamp || Date.now(),
1896
+ level: n ? "stderr" : "stdout",
1897
+ message: o,
1898
+ source: {
1899
+ type: "cell",
1900
+ cellId: e.cell_id
1901
+ }
1902
+ });
1903
+ break;
1904
+ }
1905
+ }
1906
+ }
1907
+ }
1908
+ if (t.forEach(_r.log), n.length === 0 && R(e.output?.mimetype) && Array.isArray(e.output.data)) {
1909
+ e.output.data.forEach((t) => {
1910
+ _r.log({
1911
+ level: "stderr",
1912
+ source: {
1913
+ type: "cell",
1914
+ cellId: e.cell_id
1915
+ },
1916
+ timestamp: e.timestamp ?? 0,
1917
+ message: JSON.stringify(t)
1918
+ });
1919
+ });
1920
+ let t = e.output.data.filter((e) => "type" in e && e.type === "exception" || e.type === "internal"), n = m.get(ye) === "read";
1921
+ if (t.length > 0 && !hr && n) {
1922
+ hr = !0;
1923
+ let e = t.find((e) => e.traceback);
1924
+ o(e ? {
1925
+ title: "An internal error occurred",
1926
+ description: e.msg || "Click 'View' to see traceback",
1927
+ variant: "danger",
1928
+ action: C.createElement(ue, {
1929
+ altText: "View traceback",
1930
+ onClick: () => {
1931
+ m.set(pr, {
1932
+ traceback: e.traceback,
1933
+ errorMessage: e.msg || "An internal error occurred"
1934
+ });
1935
+ }
1936
+ }, "View")
1937
+ } : {
1938
+ title: "An internal error occurred",
1939
+ description: "See console for details.",
1940
+ variant: "danger"
1941
+ });
1942
+ }
1943
+ }
1944
+ return t;
1945
+ }
1946
+ var _r = { log: (e) => {
1947
+ let t = e.level === "stdout" ? "gray" : e.level === "stderr" ? "red" : "orange", n = e.level.toUpperCase();
1948
+ console.log(`%c[${n}]`, `color:${t}; padding:2px 0; border-radius:2px; font-weight:bold`, `[${vr(e.timestamp)}]`, `(${mr(e.source)}) ${e.message}`);
1949
+ } };
1950
+ function vr(e) {
1951
+ try {
1952
+ return rr(e).toLocaleTimeString(void 0, {
1953
+ hour12: !0,
1954
+ hour: "numeric",
1955
+ minute: "numeric",
1956
+ second: "numeric"
1957
+ });
1958
+ } catch {
1959
+ return "";
1960
+ }
1961
+ }
1962
+ var yr = /* @__PURE__ */ new Set(/* @__PURE__ */ "__*.marimo.app.False.None.True.__peg_parser__.and.as.assert.async.await.break.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.nonlocal.not.or.pass.raise.return.try.while.with.yield.None.setup".split("."));
1963
+ function br(e, t = !0) {
1964
+ return e = e.trim(), e ? (/^\d/.test(e) && (e = `_${e}`), e = e.replaceAll(/\W/g, "_"), t ? e.toLowerCase() : e) : "_";
1965
+ }
1966
+ function xr(e, t) {
1967
+ let n = new Set(t), r = e, i = (e) => !n.has(e) && !yr.has(e);
1968
+ if (i(e)) return e;
1969
+ let a = 1;
1970
+ for (; !i(r);) r = `${e}_${a}`, a++;
1971
+ return r;
1972
+ }
1973
+ function Sr(e, t) {
1974
+ return Cr(e) ? `cell-${t}` : e;
1975
+ }
1976
+ function Cr(e) {
1977
+ return !e || e === "_" || e === "__";
1978
+ }
1979
+ //#endregion
1980
+ //#region src/core/cells/types.ts
1981
+ function wr({ id: e, name: t = "_", code: n = "", config: r }) {
1982
+ return {
1983
+ id: e,
1984
+ config: r || {
1985
+ hide_code: !1,
1986
+ disabled: !1,
1987
+ column: null,
1988
+ expand_output: !1
1989
+ },
1990
+ name: t,
1991
+ code: n
1992
+ };
1993
+ }
1994
+ function Tr(e) {
1995
+ return {
1996
+ hide_code: !1,
1997
+ disabled: !1,
1998
+ column: null,
1999
+ expand_output: !1,
2000
+ ...e
2001
+ };
2002
+ }
2003
+ function Er(e) {
2004
+ return {
2005
+ embeddedConsole: [],
2006
+ ...e
2007
+ };
2008
+ }
2009
+ //#endregion
2010
+ //#region src/core/cells/execution-console.ts
2011
+ function Dr(e, t, n) {
2012
+ let r = e.time === void 0 ? t : Date.parse(e.time) / 1e3, i = e.seq + 1;
2013
+ switch (e.kind) {
2014
+ case "console":
2015
+ if (e.content.kind === "text") return {
2016
+ id: i,
2017
+ channel: e.content.stream,
2018
+ data: e.content.text,
2019
+ mimetype: "text/plain",
2020
+ timestamp: r
2021
+ };
2022
+ let { media: t } = e.content;
2023
+ return {
2024
+ id: i,
2025
+ channel: t.mimetype === "application/vnd.marimo+traceback" ? "stderr" : "media",
2026
+ mimetype: t.mimetype,
2027
+ data: t.data,
2028
+ code: t.mimetype === "application/vnd.marimo+traceback" ? n : void 0,
2029
+ timestamp: r
2030
+ };
2031
+ case "input": return {
2032
+ id: i,
2033
+ channel: "stdin",
2034
+ mimetype: e.password ? "text/password" : "text/plain",
2035
+ input_id: e.id,
2036
+ data: e.prompt,
2037
+ timestamp: r,
2038
+ response: e.status === "pending" ? void 0 : null
2039
+ };
2040
+ }
2041
+ }
2042
+ function Or(e, t) {
2043
+ return {
2044
+ onOutput(e, t) {
2045
+ Hn.INSTANCE.trackOutput(e, t);
2046
+ },
2047
+ onExecution(n, r) {
2048
+ r && (n.state.status === "running" && e.startCellConsole({ cellId: n.cell_id ?? "__scratch__" }), t?.(n));
2049
+ },
2050
+ onItem(t, n, r) {
2051
+ let i = t.cell_id ?? "__scratch__", a = k(t), o = Dr(n, a ? Date.parse(a) / 1e3 : 0);
2052
+ o.channel === "media" && Hn.INSTANCE.track({
2053
+ cell_id: i,
2054
+ output: o
2055
+ }), r && (o.channel === "stdout" || o.channel === "stderr") && e.addLogs({ logs: gr({
2056
+ cell_id: i,
2057
+ console: o
2058
+ }) });
2059
+ }
2060
+ };
2061
+ }
2062
+ function kr(e, t) {
2063
+ let n = e(h);
2064
+ if (!n) return;
2065
+ let r = e(n.executionsAtom);
2066
+ if (t === "__scratch__") return r.scratchConsole;
2067
+ let i = r.latest.get(t);
2068
+ return i === void 0 ? void 0 : r.executions.get(i);
2069
+ }
2070
+ function Ar(e, t) {
2071
+ let { local: n, execution: r, code: i } = e;
2072
+ if (t && t.local === n && t.code === i && t.execution?.items === r?.items) return t;
2073
+ let a = r?.record, o = n.clearedConsole, s = n.clearedConsoleInputs, c = a && k(a), l = c ? Date.parse(c) / 1e3 : 0, u = (e) => {
2074
+ if (o && o.executionId === a?.id && e.seq <= o.seq && !(e.kind === "input" && o.prompts.has(e.id)) || e.kind === "input" && s?.executionId === e.execution_id && s.ids.has(e.id)) return;
2075
+ let t = Dr(e, l, i);
2076
+ return e.kind === "input" && !e.password && n.answers?.has(e.id) && (t.response = n.answers.get(e.id)), t;
2077
+ }, d = n.commandConsole?.entries, f = r?.append;
2078
+ if (t && t.local === n && t.code === i && t.execution && f && f.before.deref() === t.execution.items && (!d?.length || d.every((e) => e.afterSeq !== void 0 && e.afterSeq < f.item.seq))) {
2079
+ let n = u(f.item), r = t.rendered.consoleOutputs;
2080
+ return {
2081
+ ...e,
2082
+ rendered: { consoleOutputs: n ? Yn([...r, n]) : r }
2083
+ };
2084
+ }
2085
+ let p = !r || a?.runtime_id === "embedded" && !r.items.size ? n.embeddedConsole : it(r).flatMap((e) => u(e) ?? []);
2086
+ if (d?.length) {
2087
+ let e = d.every((e) => e.afterSeq !== void 0) && p.every((e) => e.id !== void 0), t = (e) => e.afterSeq === void 0 ? e.id ?? 0 : e.afterSeq + 1.5;
2088
+ p = [...p, ...d.map((e, t) => ({
2089
+ ...e,
2090
+ id: -1 - t
2091
+ }))].toSorted((n, r) => (e ? t(n) - t(r) : 0) || (n.timestamp ?? 0) - (r.timestamp ?? 0));
2092
+ }
2093
+ return {
2094
+ ...e,
2095
+ rendered: { consoleOutputs: Xn(p) }
2096
+ };
2097
+ }
2098
+ //#endregion
2099
+ //#region src/core/cells/columns.ts
2100
+ function jr(e) {
2101
+ let t = /* @__PURE__ */ new Map(), n = 0;
2102
+ for (let r of e.order) {
2103
+ let i = e.cells.get(r)?.config.column;
2104
+ i != null && i >= 0 && (n = i), t.set(r, n);
2105
+ }
2106
+ return t;
2107
+ }
2108
+ function Mr(e) {
2109
+ let t = [[]];
2110
+ for (let [n, r] of jr(e)) {
2111
+ for (; t.length <= r;) t.push([]);
2112
+ t[r].push(n);
2113
+ }
2114
+ return t;
2115
+ }
2116
+ //#endregion
2117
+ //#region src/core/cells/layout.ts
2118
+ var Nr = v(/* @__PURE__ */ new Set()), Pr = v([]), Fr = v([]);
2119
+ function Ir() {
2120
+ return `column-${Ln.create()}`;
2121
+ }
2122
+ var Lr = v(null, (e, t, n) => {
2123
+ let r = Mr(n).length, i = e(Pr);
2124
+ if (i.length === r) return;
2125
+ let a = e(Fr), o = [...i, ...a].slice(0, r);
2126
+ for (; o.length < r;) o.push(Ir());
2127
+ t(Pr, o), t(Fr, a.slice(Math.max(0, r - i.length)));
2128
+ }), Rr = b(v((e) => {
2129
+ let t = e(g);
2130
+ return t === null ? null : e(t.documentAtom);
2131
+ }), (e) => e === null ? [[]] : Mr(e), y), zr = v((e) => {
2132
+ let t = e(Rr), n = e(Pr), r = e(Fr);
2133
+ return [...t.map((e, t) => ({
2134
+ id: n[t] ?? `column-${t}`,
2135
+ ids: e
2136
+ })), ...r.map((e) => ({
2137
+ id: e,
2138
+ ids: []
2139
+ }))];
2140
+ });
2141
+ function Br(e, t, n) {
2142
+ let r = /* @__PURE__ */ new Map();
2143
+ return e.forEach((i, a) => {
2144
+ let o = t[a];
2145
+ if (!n.has(i) || !o || o.items.length === 0) return;
2146
+ let s = Qe(a, t);
2147
+ s !== null && r.set(i, e.slice(a + 1, s[1] + 1));
2148
+ }), r;
2149
+ }
2150
+ function Vr(e, t, n) {
2151
+ return { columns: e.map(({ id: e, ids: r }) => {
2152
+ let i = Br(r, r.map(t), n), a = new Set([...i.values()].flat());
2153
+ return {
2154
+ id: e,
2155
+ ids: r,
2156
+ visible: r.filter((e) => !a.has(e)),
2157
+ folds: i
2158
+ };
2159
+ }) };
2160
+ }
2161
+ var Hr = v((e) => {
2162
+ let t = e(ba);
2163
+ return Vr(e(zr), (e) => t[e] ?? null, e(Nr));
2164
+ }), Ur = () => le(Hr), Wr = v((e) => e(Hr).columns.length);
2165
+ function Gr(e, t) {
2166
+ return e.columns.find((e) => e.id === t);
2167
+ }
2168
+ function Kr(e, t) {
2169
+ let n = e.columns.find((e) => e.ids.includes(t));
2170
+ if (n === void 0) throw Error(`Cell ${t} is not in the layout`);
2171
+ return n;
2172
+ }
2173
+ function qr(e, t) {
2174
+ for (let n of e.columns) {
2175
+ let e = n.folds.get(t);
2176
+ if (e !== void 0) return e;
2177
+ }
2178
+ }
2179
+ function Jr(e, t) {
2180
+ let n = e.columns.find((e) => e.ids.includes(t));
2181
+ return n === void 0 ? [] : [...n.folds].filter(([, e]) => e.includes(t)).map(([e]) => e);
2182
+ }
2183
+ function Yr(e, t) {
2184
+ let n = Jr(e, t);
2185
+ return qr(e, t) === void 0 ? n : [...n, t];
2186
+ }
2187
+ //#endregion
2188
+ //#region src/core/cells/document.ts
2189
+ function Xr(e, t) {
2190
+ let n = t.code ?? e.code, r = y(e.config, t.config) ? e.config : Tr(t.config);
2191
+ return n === e.code && t.name === e.name && r === e.config ? e : n === e.code ? {
2192
+ ...e,
2193
+ name: t.name,
2194
+ config: r
2195
+ } : {
2196
+ ...e,
2197
+ code: n,
2198
+ name: t.name,
2199
+ config: r
2200
+ };
2201
+ }
2202
+ function Zr(e, t) {
2203
+ let n = y(t.order, e.cellIds) ? e.cellIds : [...t.order], { cellData: r, cellRuntime: i, cellHandles: a } = e;
2204
+ for (let o of n) {
2205
+ let n = t.cells.get(o), s = e.cellData[o];
2206
+ if (n === void 0) continue;
2207
+ if (s === void 0) {
2208
+ r = {
2209
+ ...r,
2210
+ [o]: wr({
2211
+ id: o,
2212
+ code: n.code ?? "",
2213
+ name: n.name,
2214
+ config: Tr(n.config)
2215
+ })
2216
+ }, i = {
2217
+ ...i,
2218
+ [o]: i[o] ?? Er()
2219
+ }, a = {
2220
+ ...a,
2221
+ [o]: (0, C.createRef)()
2222
+ };
2223
+ continue;
2224
+ }
2225
+ let c = Xr(s, n);
2226
+ c !== s && (r = {
2227
+ ...r,
2228
+ [o]: c
2229
+ });
2230
+ }
2231
+ let o = new Set(n), s = e.cellIds.filter((e) => !o.has(e));
2232
+ if (s.length > 0) {
2233
+ let e = new Set(s), t = (t) => Object.fromEntries(Object.entries(t).filter(([t]) => !e.has(t)));
2234
+ r = t(r), i = t(i), a = t(a);
2235
+ }
2236
+ return n === e.cellIds && r === e.cellData && s.length === 0 ? e : {
2237
+ ...e,
2238
+ cellIds: n,
2239
+ cellData: r,
2240
+ cellRuntime: i,
2241
+ cellHandles: a
2242
+ };
2243
+ }
2244
+ function Qr({ store: e, model: t, reconcile: n, signal: r }) {
2245
+ let i = () => {
2246
+ let r = e.get(t.documentAtom);
2247
+ r !== null && (n(r), e.set(Lr, r));
2248
+ }, a = e.sub(t.documentAtom, i);
2249
+ r.addEventListener("abort", a, { once: !0 }), i();
2250
+ }
2251
+ async function $r() {
2252
+ let e = m.get(g);
2253
+ e !== null && m.get(e.syncStatusAtom).status !== "unavailable" && await e.flush();
2254
+ }
2255
+ //#endregion
2256
+ //#region src/core/cells/editor.ts
2257
+ var W = v(/* @__PURE__ */ new Set());
2258
+ function ei(e, t, n) {
2259
+ return !!e && !t.has(n);
2260
+ }
2261
+ v(null, (e, t, { cellId: n }) => {
2262
+ t(W, (e) => /* @__PURE__ */ new Set([...e, n]));
2263
+ }), v(null, (e, t, { cellId: n }) => e(W).has(n) ? (t(W, (e) => {
2264
+ let t = new Set(e);
2265
+ return t.delete(n), t;
2266
+ }), !0) : !1);
2267
+ var ti = v(/* @__PURE__ */ new Map());
2268
+ v(null, (e, t, { cellId: n }) => {
2269
+ t(ti, (e) => {
2270
+ let t = new Map(e);
2271
+ return t.delete(n), t;
2272
+ });
2273
+ });
2274
+ //#endregion
2275
+ //#region src/components/editor/navigation/focus-utils.ts
2276
+ function ni(e, n) {
2277
+ let r = document.getElementById(B.create(e));
2278
+ r ? ii(r, n) : t.warn(`[CellFocusManager] focusCell: element not found: ${e}`);
2279
+ }
2280
+ function ri() {
2281
+ return document.activeElement instanceof HTMLElement && document.activeElement.classList.contains("marimo-cell");
2282
+ }
2283
+ function ii(e, n) {
2284
+ try {
2285
+ e.focus(n);
2286
+ } catch {
2287
+ t.warn("[CellFocusManager] element may not be focusable", e);
2288
+ }
2289
+ }
2290
+ //#endregion
2291
+ //#region src/utils/timeout.ts
2292
+ function ai(e, n) {
2293
+ let { retries: r, delay: i, initialDelay: a = 0 } = n, o = 0, s = () => {
2294
+ if (o < r) {
2295
+ try {
2296
+ if (e()) return;
2297
+ } catch (e) {
2298
+ t.error(`Error executing function on attempt ${o + 1}, retrying`, { error: e });
2299
+ }
2300
+ o++, setTimeout(s, i);
2301
+ }
2302
+ };
2303
+ a > 0 ? setTimeout(s, a) : s();
2304
+ }
2305
+ //#endregion
2306
+ //#region src/core/cells/utils.ts
2307
+ function oi(e) {
2308
+ return e.cellIds.map((t) => e.cellData[t]);
2309
+ }
2310
+ function si(e) {
2311
+ let { cellIds: t, cellData: n } = e, r = [];
2312
+ for (let e of t) n[e].config.disabled && r.push(e);
2313
+ return r;
2314
+ }
2315
+ function ci(e) {
2316
+ let { cellIds: t, cellData: n } = e, r = [];
2317
+ for (let e of t) n[e].config.disabled || r.push(e);
2318
+ return r;
2319
+ }
2320
+ function li(e) {
2321
+ return e.history.length > 0;
2322
+ }
2323
+ function ui(e) {
2324
+ let t = e.history[e.history.length - 1];
2325
+ return t && t.type === "move" ? "Undo move" : "Undo cell deletion";
2326
+ }
2327
+ function di(e, t, n) {
2328
+ return e.status === "idle" ? hi(e) && n.code.trim() ? "not-run" : t.sourceChanged ? "source" : e.outcome === "cancelled" ? "interrupted" : t.inputsChanged && !n.config.disabled && !e.blocked ? "inputs" : null : null;
2329
+ }
2330
+ function* fi(e, t, n) {
2331
+ for (let r of e.cellIds) {
2332
+ let i = Vt(t, r), a = n(r), o = di(i, a, e.cellData[r]);
2333
+ o === null ? a.sourceChanged && mi(t.executions, r) && (yield [r, "source"]) : yield [r, o];
2334
+ }
2335
+ }
2336
+ function pi(e, t, n) {
2337
+ let r = null;
2338
+ for (let [, i] of fi(e, t, n)) {
2339
+ if (i !== "inputs") return i;
2340
+ r = i;
2341
+ }
2342
+ return r;
2343
+ }
2344
+ function mi(e, t) {
2345
+ let n = e.latest.get(t), r = n === void 0 ? void 0 : e.executions.get(n)?.record;
2346
+ return r !== void 0 && r.state.status !== "completed";
2347
+ }
2348
+ function hi({ status: e, outcome: t, live: n }) {
2349
+ return (t === null || !n) && e !== "queued" && e !== "running";
2350
+ }
2351
+ function gi({ errored: e, stopped: t }) {
2352
+ return {
2353
+ published: !0,
2354
+ "has-error": e,
2355
+ stopped: t
2356
+ };
2357
+ }
2358
+ function _i({ errored: e, interrupted: t, stopped: n, output: r, showErrorTracebacks: i }) {
2359
+ let a = R(r?.mimetype), o = i && a && Array.isArray(r?.data) && r.data.some((e) => e.type === "exception" && "traceback" in e && e.traceback);
2360
+ return (e || t || n || a) && !o;
2361
+ }
2362
+ //#endregion
2363
+ //#region src/core/network/requests.ts
2364
+ var vi = v(null);
2365
+ function yi() {
2366
+ let e = le(vi);
2367
+ return S(e, "useRequestClient() requires setting requestClientAtom."), e;
2368
+ }
2369
+ function bi() {
2370
+ let e = m.get(vi);
2371
+ return S(e, "getRequestClient() requires requestClientAtom to be set."), e;
2372
+ }
2373
+ //#endregion
2374
+ //#region src/utils/storage/storage.ts
2375
+ var xi = class {
2376
+ store = /* @__PURE__ */ new Map();
2377
+ get length() {
2378
+ return this.store.size;
2379
+ }
2380
+ clear() {
2381
+ this.store.clear();
2382
+ }
2383
+ getItem(e) {
2384
+ return this.store.get(e) || null;
2385
+ }
2386
+ key(e) {
2387
+ return [...this.store.keys()][e] || null;
2388
+ }
2389
+ removeItem(e) {
2390
+ this.store.delete(e);
2391
+ }
2392
+ setItem(e, t) {
2393
+ this.store.set(e, t);
2394
+ }
2395
+ };
2396
+ function Si() {
2397
+ let { hasLocalStorage: e, hasSessionStorage: t } = Ce();
2398
+ return e ? window.localStorage : t ? window.sessionStorage : new xi();
2399
+ }
2400
+ var Ci = Si(), wi = /(https?:\/\/[^\s"<>`{}|\\^]+)/, Ti = /\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i, Ei = /^data:image\//i, Di = ["avatars.githubusercontent.com"];
2401
+ function Oi(e) {
2402
+ return Ei.test(e) ? [{
2403
+ type: "image",
2404
+ url: e
2405
+ }] : e.split(wi).filter((e) => e !== "").map((e) => wi.test(e) ? Ti.test(e) || Ei.test(e) || Di.some((t) => e.includes(t)) ? {
2406
+ type: "image",
2407
+ url: e
2408
+ } : {
2409
+ type: "url",
2410
+ url: e
2411
+ } : {
2412
+ type: "text",
2413
+ value: e
2414
+ });
2415
+ }
2416
+ //#endregion
2417
+ //#region src/utils/json/json-parser.ts
2418
+ var ki = new RegExp(wi.source, "g");
2419
+ BigInt.prototype.toJSON = function() {
2420
+ return JSON.rawJSON(this.toString());
2421
+ };
2422
+ function Ai(e) {
2423
+ try {
2424
+ return JSON.parse(e, (e, t) => Pi(t));
2425
+ } catch {}
2426
+ if (e == null || e === "") return {};
2427
+ try {
2428
+ return e ??= "", e = e.replaceAll(/(?<=\s|^|\[|,|:)(NaN|-Infinity|Infinity)(?=(?:[^"'\\]*(\\.|'([^'\\]*\\.)*[^'\\]*'|"([^"\\]*\\.)*[^"\\]*"))*[^"']*$)/g, "\"◐$1◐\""), JSON.parse(e, (e, t) => typeof t == "string" ? t === "◐NaN◐" ? NaN : t === "◐Infinity◐" ? Infinity : t === "◐-Infinity◐" ? -Infinity : Pi(t) : Pi(t));
2429
+ } catch {
2430
+ return {};
2431
+ }
2432
+ }
2433
+ function ji(e) {
2434
+ if (e.length === 0) return "";
2435
+ let t = Object.keys(e[0]);
2436
+ return [
2437
+ `| ${t.join(" | ")} |`,
2438
+ `|${t.map(() => "---").join("|")}|`,
2439
+ ...e.map((e) => `| ${t.map((t) => Mi(e[t])).join(" | ")} |`)
2440
+ ].join("\n");
2441
+ }
2442
+ function Mi(e) {
2443
+ if (e == null) return "";
2444
+ if (Array.isArray(e) || typeof e == "object") return Ni(JSON.stringify(e));
2445
+ let t = String(e), n = /\[([^\]]+)]\((https?:\/\/[^)]+)\)/g, r = /* @__PURE__ */ new Map(), i = 0;
2446
+ t = t.replaceAll(n, (e) => {
2447
+ let t = `__MDLINK_${i++}__`;
2448
+ return r.set(t, e), t;
2449
+ }), t = t.replaceAll(ki, "[$1]($1)");
2450
+ for (let [e, n] of r) t = t.replace(e, n);
2451
+ return Ni(t);
2452
+ }
2453
+ function Ni(e) {
2454
+ return e.replaceAll("\\", "\\\\").replaceAll("|", "\\|").replaceAll("\n", " ").replaceAll("\r", "");
2455
+ }
2456
+ function Pi(e) {
2457
+ return typeof e == "object" && e && "$bigint" in e && typeof e.$bigint == "string" ? BigInt(e.$bigint) : e;
2458
+ }
2459
+ var Fi = new class {
2460
+ getFilename() {
2461
+ return this.getSearchParam("filename");
2462
+ }
2463
+ setFilename(e) {
2464
+ this.setSearchParam("filename", e);
2465
+ }
2466
+ getCodeFromSearchParam() {
2467
+ return this.getSearchParam("code");
2468
+ }
2469
+ getCodeFromHash() {
2470
+ let e = window.location.hash;
2471
+ return e.startsWith("#code/") ? e.slice(6) : null;
2472
+ }
2473
+ setCodeForHash(e) {
2474
+ window.location.hash = `#code/${e}`;
2475
+ }
2476
+ setSearchParam(e, t) {
2477
+ let n = new URL(window.location.href);
2478
+ n.searchParams.set(e, t), window.history.replaceState({}, "", n.toString());
2479
+ }
2480
+ getSearchParam(e) {
2481
+ return new URL(window.location.href).searchParams.get(e);
2482
+ }
2483
+ }();
2484
+ //#endregion
2485
+ //#region src/core/dom/htmlUtils.ts
2486
+ function Ii(e) {
2487
+ return Ai(e ?? "");
2488
+ }
2489
+ function Li(e) {
2490
+ return de.mapValues(e.dataset, (e) => typeof e == "string" ? Ii(e) : e);
2491
+ }
2492
+ function Ri(e, t) {
2493
+ let n = e.parentElement ? zn.parse(e.parentElement) : void 0;
2494
+ return n && t.has(n) ? t.lookupValue(n) : Ii(e.dataset.initialValue);
2495
+ }
2496
+ function zi() {
2497
+ if (re()) return document.title || null;
2498
+ if (xe()) {
2499
+ let e = Fi.getFilename();
2500
+ if (e) return e;
2501
+ }
2502
+ let e = document.querySelector("marimo-filename");
2503
+ be(e, "marimo-filename tag not found");
2504
+ let t = e.innerHTML;
2505
+ return t.length === 0 ? null : t;
2506
+ }
2507
+ //#endregion
2508
+ //#region src/core/saving/file-state.ts
2509
+ var G = v(zi());
2510
+ v(null);
2511
+ var Bi = v(null);
2512
+ v(void 0);
2513
+ //#endregion
2514
+ //#region src/utils/storage/typed.ts
2515
+ var Vi = class {
2516
+ defaultValue;
2517
+ storage;
2518
+ constructor(e, t = Ci) {
2519
+ this.defaultValue = e, this.storage = t;
2520
+ }
2521
+ get(e) {
2522
+ try {
2523
+ let t = this.storage.getItem(e);
2524
+ return t ? JSON.parse(t) : this.defaultValue;
2525
+ } catch {
2526
+ return this.defaultValue;
2527
+ }
2528
+ }
2529
+ set(e, t) {
2530
+ this.storage.setItem(e, JSON.stringify(t));
2531
+ }
2532
+ remove(e) {
2533
+ this.storage.removeItem(e);
2534
+ }
2535
+ }, Hi = class {
2536
+ schema;
2537
+ getDefaultValue;
2538
+ storage;
2539
+ constructor(e, t, n = Ci) {
2540
+ this.schema = e, this.getDefaultValue = t, this.storage = n;
2541
+ }
2542
+ get(e) {
2543
+ try {
2544
+ let n = this.storage.getItem(e);
2545
+ if (n == null) return this.getDefaultValue();
2546
+ let r = this.schema.safeParse(JSON.parse(n));
2547
+ return r.success ? r.data : (t.warn("Error parsing zod local storage", r.error), this.getDefaultValue());
2548
+ } catch (e) {
2549
+ return t.warn("Error getting zod local storage", e), this.getDefaultValue();
2550
+ }
2551
+ }
2552
+ set(e, t) {
2553
+ this.storage.setItem(e, JSON.stringify(t));
2554
+ }
2555
+ remove(e) {
2556
+ this.storage.removeItem(e);
2557
+ }
2558
+ }, Ui = class extends Hi {
2559
+ filename;
2560
+ unsubscribeFromFilename;
2561
+ constructor(e, t, n) {
2562
+ let r = m.get(G);
2563
+ super(t, n), this.filename = r;
2564
+ try {
2565
+ this.unsubscribeFromFilename = m.sub(G, () => {
2566
+ let t = m.get(G);
2567
+ this.handleFilenameChange(e, t);
2568
+ });
2569
+ } catch {
2570
+ this.unsubscribeFromFilename = null;
2571
+ }
2572
+ }
2573
+ get(e) {
2574
+ return super.get(this.createScopedKey(e, this.filename));
2575
+ }
2576
+ set(e, t) {
2577
+ super.set(this.createScopedKey(e, this.filename), t);
2578
+ }
2579
+ remove(e) {
2580
+ super.remove(this.createScopedKey(e, this.filename));
2581
+ }
2582
+ createScopedKey(e, t) {
2583
+ return t ? `${e}:${t}` : e;
2584
+ }
2585
+ handleFilenameChange(e, t) {
2586
+ if (t && t !== this.filename) {
2587
+ let n = this.get(e);
2588
+ this.remove(e), this.filename = t, this.set(e, n);
2589
+ }
2590
+ }
2591
+ dispose() {
2592
+ this.unsubscribeFromFilename &&= (this.unsubscribeFromFilename(), null);
2593
+ }
2594
+ }, K = {
2595
+ VariableName: "VariableName",
2596
+ FunctionDefinition: "FunctionDefinition",
2597
+ ClassDefinition: "ClassDefinition",
2598
+ LambdaExpression: "LambdaExpression",
2599
+ ParamList: "ParamList",
2600
+ Decorator: "Decorator",
2601
+ AssignStatement: "AssignStatement",
2602
+ ForStatement: "ForStatement",
2603
+ ImportStatement: "ImportStatement",
2604
+ TryStatement: "TryStatement",
2605
+ WithStatement: "WithStatement",
2606
+ TupleExpression: "TupleExpression",
2607
+ ArrayExpression: "ArrayExpression",
2608
+ ParenthesizedExpression: "ParenthesizedExpression",
2609
+ CallExpression: "CallExpression",
2610
+ ArgList: "ArgList",
2611
+ AssignOp: "AssignOp",
2612
+ ArrayComprehensionExpression: "ArrayComprehensionExpression",
2613
+ SetComprehensionExpression: "SetComprehensionExpression",
2614
+ DictionaryComprehensionExpression: "DictionaryComprehensionExpression",
2615
+ ComprehensionExpression: "ComprehensionExpression",
2616
+ Comment: "Comment",
2617
+ String: "String",
2618
+ FormatString: "FormatString"
2619
+ }, q = {
2620
+ For: "for",
2621
+ In: "in",
2622
+ As: "as",
2623
+ Import: "import"
2624
+ }, Wi = /* @__PURE__ */ new Set([
2625
+ K.FunctionDefinition,
2626
+ K.LambdaExpression,
2627
+ K.ArrayComprehensionExpression,
2628
+ K.SetComprehensionExpression,
2629
+ K.DictionaryComprehensionExpression,
2630
+ K.ComprehensionExpression,
2631
+ K.ClassDefinition
2632
+ ]);
2633
+ K.Comment, K.String, K.FormatString;
2634
+ //#endregion
2635
+ //#region src/core/codemirror/utils.ts
2636
+ function Gi(e) {
2637
+ e && e.dispatch({ selection: {
2638
+ anchor: e.state.doc.length,
2639
+ head: e.state.doc.length
2640
+ } });
2641
+ }
2642
+ function Ki(e) {
2643
+ let t = e.dom.closest(".marimo-cell");
2644
+ t && requestAnimationFrame(() => {
2645
+ t.scrollIntoView({
2646
+ behavior: "instant",
2647
+ block: "nearest",
2648
+ inline: "nearest"
2649
+ });
2650
+ });
2651
+ }
2652
+ //#endregion
2653
+ //#region src/core/codemirror/go-to-definition/commands.ts
2654
+ var qi = /* @__PURE__ */ new Set([K.ClassDefinition]);
2655
+ function Ji(e, t) {
2656
+ requestAnimationFrame(() => {
2657
+ e.focus(), e.dispatch({
2658
+ selection: {
2659
+ anchor: t,
2660
+ head: t
2661
+ },
2662
+ effects: me.scrollIntoView(t, { y: "center" })
2663
+ });
2664
+ }), Ki(e);
2665
+ }
2666
+ function Yi(e, t) {
2667
+ let n = he(e), r = null;
2668
+ return n.iterate({ enter: (n) => {
2669
+ if (r !== null) return !1;
2670
+ if (n.name === K.VariableName && e.doc.sliceString(n.from, n.to) === t) return r = n.from, !1;
2671
+ if (n.name === K.Comment || n.name === K.String) return !1;
2672
+ } }), r;
2673
+ }
2674
+ function Xi(e, t) {
2675
+ let n = [], r = e.resolveInner(t, 0);
2676
+ for (; r;) Wi.has(r.name) && (n.some((e) => e.type === K.FunctionDefinition || e.type === K.LambdaExpression) && r.name === K.ClassDefinition || n.push({
2677
+ id: r.from,
2678
+ type: r.name
2679
+ })), r = r.parent;
2680
+ return n.push({
2681
+ id: -1,
2682
+ type: "global"
2683
+ }), n;
2684
+ }
2685
+ function J(e, t, n) {
2686
+ e.push({
2687
+ scopeId: t,
2688
+ from: n
2689
+ });
2690
+ }
2691
+ function Zi(e, t) {
2692
+ if (e.firstChild()) do
2693
+ t(e.node);
2694
+ while (e.nextSibling());
2695
+ }
2696
+ function Qi(e, t) {
2697
+ let { state: n, variableName: r, scopeId: i, declarations: a } = t;
2698
+ switch (e.name) {
2699
+ case K.VariableName:
2700
+ n.doc.sliceString(e.from, e.to) === r && J(a, i, e.from);
2701
+ break;
2702
+ case K.TupleExpression:
2703
+ case K.ArrayExpression: {
2704
+ let n = e.node.cursor();
2705
+ n.firstChild();
2706
+ do
2707
+ Qi(n, t);
2708
+ while (n.nextSibling());
2709
+ break;
2710
+ }
2711
+ }
2712
+ }
2713
+ function $i(e, t) {
2714
+ let { state: n, variableName: r, scopeId: i, declarations: a } = t, o = e.cursor();
2715
+ o.firstChild();
2716
+ do {
2717
+ if (o.name !== K.ParamList) continue;
2718
+ let e = o.node.cursor();
2719
+ e.firstChild();
2720
+ do
2721
+ e.name === K.VariableName && n.doc.sliceString(e.from, e.to) === r && J(a, i, e.from);
2722
+ while (e.nextSibling());
2723
+ } while (o.nextSibling());
2724
+ }
2725
+ function ea(e, t) {
2726
+ let n = e.cursor();
2727
+ n.firstChild();
2728
+ let r = !1;
2729
+ do
2730
+ if (n.name === q.For) r = !0;
2731
+ else if (r && n.name === q.In) break;
2732
+ else r && Qi(n, t);
2733
+ while (n.nextSibling());
2734
+ }
2735
+ function ta(e, t) {
2736
+ let { state: n, variableName: r, scopeStack: i, declarations: a } = t, o = e.cursor(), s = o.name, c = o.from, l = Wi.has(s) ? [...i, c] : i, u = l[l.length - 1] ?? -1;
2737
+ switch (s) {
2738
+ case K.FunctionDefinition:
2739
+ case K.ClassDefinition: {
2740
+ let t = e.cursor();
2741
+ t.firstChild();
2742
+ do
2743
+ if (t.name === K.VariableName && n.doc.sliceString(t.from, t.to) === r) {
2744
+ J(a, i[i.length - 1] ?? -1, t.from);
2745
+ break;
2746
+ }
2747
+ while (t.nextSibling());
2748
+ s === K.FunctionDefinition && $i(e, {
2749
+ state: n,
2750
+ variableName: r,
2751
+ scopeId: c,
2752
+ declarations: a
2753
+ });
2754
+ break;
2755
+ }
2756
+ case K.LambdaExpression:
2757
+ $i(e, {
2758
+ state: n,
2759
+ variableName: r,
2760
+ scopeId: c,
2761
+ declarations: a
2762
+ });
2763
+ break;
2764
+ case K.ArrayComprehensionExpression:
2765
+ case K.DictionaryComprehensionExpression:
2766
+ case K.SetComprehensionExpression:
2767
+ case K.ComprehensionExpression:
2768
+ case K.ForStatement:
2769
+ ea(e, {
2770
+ state: n,
2771
+ variableName: r,
2772
+ scopeId: u,
2773
+ declarations: a
2774
+ });
2775
+ break;
2776
+ case K.AssignStatement: {
2777
+ let t = [], i = e.cursor();
2778
+ i.firstChild();
2779
+ do
2780
+ i.name === K.AssignOp && t.push(i.from);
2781
+ while (i.nextSibling());
2782
+ let o = t[t.length - 1];
2783
+ if (o === void 0) break;
2784
+ let s = e.cursor();
2785
+ s.firstChild();
2786
+ do
2787
+ s.from < o && Qi(s, {
2788
+ state: n,
2789
+ variableName: r,
2790
+ scopeId: u,
2791
+ declarations: a
2792
+ });
2793
+ while (s.nextSibling());
2794
+ break;
2795
+ }
2796
+ case K.ImportStatement: {
2797
+ let t = e.cursor();
2798
+ t.firstChild();
2799
+ let i = !1, o = null, s = () => {
2800
+ o?.matches && J(a, u, o.from), o = null;
2801
+ };
2802
+ do
2803
+ t.name === q.Import ? i = !0 : i && (t.name === q.As ? o = null : t.name === K.VariableName ? (s(), o = {
2804
+ from: t.from,
2805
+ matches: n.doc.sliceString(t.from, t.to) === r
2806
+ }) : t.name === "," && s());
2807
+ while (t.nextSibling());
2808
+ s();
2809
+ break;
2810
+ }
2811
+ case K.TryStatement:
2812
+ case K.WithStatement: {
2813
+ let t = e.cursor();
2814
+ t.firstChild();
2815
+ let i = !1;
2816
+ do
2817
+ t.name === q.As ? i = !0 : i && t.name === K.VariableName && n.doc.sliceString(t.from, t.to) === r && (J(a, u, t.from), i = !1);
2818
+ while (t.nextSibling());
2819
+ break;
2820
+ }
2821
+ }
2822
+ Zi(o, (e) => {
2823
+ ta(e, {
2824
+ state: n,
2825
+ variableName: r,
2826
+ scopeStack: l,
2827
+ declarations: a
2828
+ });
2829
+ });
2830
+ }
2831
+ function na(e, t, n) {
2832
+ let r = he(e), i = [];
2833
+ ta(r, {
2834
+ state: e,
2835
+ variableName: t,
2836
+ scopeStack: [],
2837
+ declarations: i
2838
+ });
2839
+ let a = Math.max(0, Math.min(n, e.doc.length));
2840
+ for (let e of Xi(r, a)) {
2841
+ let t = i.filter((t) => t.scopeId === e.id).filter((t) => !qi.has(e.type) || t.from <= a).toSorted((e, t) => e.from - t.from)[0];
2842
+ if (t) return t.from;
2843
+ }
2844
+ return null;
2845
+ }
2846
+ function ra(e, t, n) {
2847
+ let { state: r } = e, i = n === void 0 ? Yi(r, t) : na(r, t, n);
2848
+ return i !== null && (Ji(e, i), !0);
2849
+ }
2850
+ function ia(e, t) {
2851
+ return Ji(e, e.state.doc.line(t).from), !0;
2852
+ }
2853
+ //#endregion
2854
+ //#region src/core/network/connection.ts
2855
+ var Y = v({ state: D.NOT_STARTED });
2856
+ ae(null, (e, t) => t === null ? null : {
2857
+ phase: t.phase,
2858
+ logs: t.log_mode === "append" && e?.phase === t.phase ? e.logs + t.logs : t.logs
2859
+ });
2860
+ function aa() {
2861
+ return te(Y, (e) => e.state === D.OPEN);
2862
+ }
2863
+ function oa() {
2864
+ return ve() ? aa() : Promise.resolve();
2865
+ }
2866
+ v((e) => e(Y).state === D.CONNECTING), v((e) => e(Y).state === D.OPEN), v((e) => {
2867
+ let t = e(Y);
2868
+ return t.state === D.OPEN || t.state === D.NOT_STARTED;
2869
+ }), v((e) => e(Y).state === D.CLOSED);
2870
+ //#endregion
2871
+ //#region src/components/ui/checkbox.tsx
2872
+ var sa = C.forwardRef((e, t) => {
2873
+ let r = (0, bn.c)(13), i, a;
2874
+ r[0] === e ? (i = r[1], a = r[2]) : ({className: i, ...a} = e, r[0] = e, r[1] = i, r[2] = a);
2875
+ let o;
2876
+ r[3] === i ? o = r[4] : (o = n("flex items-center justify-center peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground", i), r[3] = i, r[4] = o);
2877
+ let s;
2878
+ r[5] === Symbol.for("react.memo_cache_sentinel") ? (s = n("flex items-center justify-center text-current max-h-[14px] overflow-hidden"), r[5] = s) : s = r[5];
2879
+ let c;
2880
+ r[6] === a.checked ? c = r[7] : (c = /* @__PURE__ */ (0, w.jsx)(Le, {
2881
+ className: s,
2882
+ children: a.checked === "indeterminate" ? /* @__PURE__ */ (0, w.jsx)(Te, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, w.jsx)(l, { className: "h-4 w-4" })
2883
+ }), r[6] = a.checked, r[7] = c);
2884
+ let u;
2885
+ return r[8] !== a || r[9] !== t || r[10] !== o || r[11] !== c ? (u = /* @__PURE__ */ (0, w.jsx)(Fe, {
2886
+ ref: t,
2887
+ className: o,
2888
+ ...a,
2889
+ children: c
2890
+ }), r[8] = a, r[9] = t, r[10] = o, r[11] = c, r[12] = u) : u = r[12], u;
2891
+ });
2892
+ sa.displayName = Fe.displayName;
2893
+ //#endregion
2894
+ //#region src/core/cells/scrollCellIntoView.ts
2895
+ function ca({ cellId: e, cell: n, isCodeHidden: r, codeFocus: i, variableName: a }) {
2896
+ if (!n) return;
2897
+ let o = document.getElementById(B.create(e));
2898
+ if (!o) t.warn("scrollCellIntoView: element not found");
2899
+ else if (ri()) ii(o);
2900
+ else {
2901
+ if (r) ii(o);
2902
+ else {
2903
+ Dn.promote(e);
2904
+ let r = n.current?.editorView;
2905
+ if (!r) {
2906
+ t.warn("scrollCellIntoView: editor not found", e);
2907
+ return;
2908
+ }
2909
+ if (r.hasFocus || !document.hasFocus()) return;
2910
+ if (ai(() => (r.focus(), r.hasFocus), {
2911
+ retries: 5,
2912
+ delay: 20
2913
+ }), i === "top") r.dispatch({ selection: {
2914
+ anchor: 0,
2915
+ head: 0
2916
+ } });
2917
+ else if (i === "bottom") {
2918
+ let e = r.state.doc.line(r.state.doc.lines);
2919
+ r.dispatch({ selection: {
2920
+ anchor: e.from,
2921
+ head: e.from
2922
+ } });
2923
+ } else a && ra(r, a);
2924
+ }
2925
+ o.scrollIntoView({
2926
+ behavior: "smooth",
2927
+ block: "nearest"
2928
+ });
2929
+ }
2930
+ }
2931
+ function la() {
2932
+ let e = document.getElementById("App");
2933
+ e?.scrollTo({
2934
+ top: e.scrollHeight,
2935
+ behavior: "smooth"
2936
+ });
2937
+ }
2938
+ function ua() {
2939
+ document.getElementById("App")?.scrollTo({
2940
+ top: 0,
2941
+ behavior: "smooth"
2942
+ });
2943
+ }
2944
+ function da(e) {
2945
+ let t = document.getElementById(B.create(e));
2946
+ return t?.scrollIntoView({
2947
+ behavior: "smooth",
2948
+ block: "center"
2949
+ }), t;
2950
+ }
2951
+ //#endregion
2952
+ //#region src/core/cells/cells.ts
2953
+ function fa(e) {
2954
+ let t = {
2955
+ column: 0,
2956
+ hide_code: !1,
2957
+ disabled: !1,
2958
+ expand_output: !1
2959
+ };
2960
+ return {
2961
+ ...e,
2962
+ cellData: {
2963
+ [z]: wr({
2964
+ id: z,
2965
+ config: t
2966
+ }),
2967
+ ...e.cellData
2968
+ },
2969
+ cellRuntime: {
2970
+ [z]: Er(),
2971
+ ...e.cellRuntime
2972
+ },
2973
+ cellHandles: {
2974
+ [z]: (0, C.createRef)(),
2975
+ ...e.cellHandles
2976
+ }
2977
+ };
2978
+ }
2979
+ function pa() {
2980
+ return fa({
2981
+ cellIds: [],
2982
+ cellData: {},
2983
+ cellRuntime: {},
2984
+ cellHandles: {},
2985
+ history: [],
2986
+ scrollKey: null,
2987
+ cellLogs: []
2988
+ });
2989
+ }
2990
+ var { reducer: ma, createActions: ha, useActions: ga, valueAtom: X } = pe(pa, {
2991
+ startCellConsole: (e, { cellId: t }) => Z({
2992
+ state: e,
2993
+ cellId: t,
2994
+ cellReducer: (e) => ({
2995
+ ...e,
2996
+ embeddedConsole: [],
2997
+ commandConsole: void 0,
2998
+ answers: void 0,
2999
+ clearedConsoleInputs: void 0
3000
+ })
3001
+ }),
3002
+ showCommandOutput: (e, t) => {
3003
+ let { cell_id: n, entries: r, replace: i } = t, a = Z({
3004
+ state: e,
3005
+ cellId: n,
3006
+ cellReducer: (e) => ({
3007
+ ...e,
3008
+ commandConsole: An(e.commandConsole, t, e.clearedCommandIds?.[t.op])
3009
+ })
3010
+ });
3011
+ return i || t.op === "pdb-output" ? a : {
3012
+ ...a,
3013
+ cellLogs: [...a.cellLogs, ...gr({
3014
+ cell_id: n,
3015
+ console: r
3016
+ })]
3017
+ };
3018
+ },
3019
+ hideConsoleInputs: (e, { cellId: t, executionId: n, inputIds: r }) => {
3020
+ let i = new Set(r);
3021
+ return Z({
3022
+ state: e,
3023
+ cellId: t,
3024
+ cellReducer: (e) => ({
3025
+ ...e,
3026
+ clearedConsoleInputs: {
3027
+ executionId: n,
3028
+ ids: i
3029
+ }
3030
+ })
3031
+ });
3032
+ },
3033
+ clearDebuggerOutput: (e) => {
3034
+ let t = { ...e.cellRuntime };
3035
+ for (let e of Object.keys(t)) {
3036
+ let n = t[e];
3037
+ n.commandConsole?.entries.some((e) => e.source === "pdb-output") && (t[e] = {
3038
+ ...n,
3039
+ commandConsole: An(n.commandConsole, {
3040
+ op: "pdb-output",
3041
+ cell_id: e,
3042
+ entries: [],
3043
+ replace: !0
3044
+ })
3045
+ });
3046
+ }
3047
+ return {
3048
+ ...e,
3049
+ cellRuntime: t
3050
+ };
3051
+ },
3052
+ addLogs: (e, t) => ({
3053
+ ...e,
3054
+ cellLogs: [...e.cellLogs, ...t.logs]
3055
+ }),
3056
+ reconcileDocument: (e, t) => {
3057
+ let n = Zr(e, t);
3058
+ for (let t of e.cellIds) t in n.cellData || ja(t);
3059
+ return n;
3060
+ },
3061
+ setStdinResponse: (e, t) => {
3062
+ let { cellId: n, response: r, inputId: i } = t;
3063
+ return Z({
3064
+ state: e,
3065
+ cellId: n,
3066
+ cellReducer: (e) => ({
3067
+ ...e,
3068
+ answers: new Map(e.answers).set(i, r)
3069
+ })
3070
+ });
3071
+ },
3072
+ resetCellRuntimes: (e, t) => {
3073
+ let n = xe(), r = { ...e.cellRuntime };
3074
+ for (let i of [...e.cellIds, z]) {
3075
+ let a = e.cellRuntime[i];
3076
+ r[i] = n && a !== void 0 && a.embeddedConsole.length > 0 ? a : Er({
3077
+ clearedConsole: t ? a?.clearedConsole : void 0,
3078
+ clearedCommandIds: t ? a?.clearedCommandIds : void 0
3079
+ });
3080
+ }
3081
+ return {
3082
+ ...e,
3083
+ cellRuntime: r
3084
+ };
3085
+ },
3086
+ scrollToTarget: (e) => {
3087
+ let t = e.scrollKey;
3088
+ if (t === null) return e;
3089
+ let n = t;
3090
+ return ca({
3091
+ cellId: n,
3092
+ cell: e.cellHandles[n],
3093
+ isCodeHidden: ei(e.cellData[n]?.config.hide_code, m.get(W), n),
3094
+ codeFocus: void 0,
3095
+ variableName: void 0
3096
+ }), {
3097
+ ...e,
3098
+ scrollKey: null
3099
+ };
3100
+ },
3101
+ foldAll: (e) => (Sn(Object.values(e.cellHandles).map((e) => e.current?.editorView)), e),
3102
+ unfoldAll: (e) => (Cn(Object.values(e.cellHandles).map((e) => e.current?.editorView)), e),
3103
+ clearLogs: (e) => ({
3104
+ ...e,
3105
+ cellLogs: []
3106
+ }),
3107
+ clearCellConsole: (e, t) => Z({
3108
+ state: e,
3109
+ cellId: t.cellId,
3110
+ cellReducer: (e) => {
3111
+ let n = { ...e.clearedCommandIds };
3112
+ for (let t of e.commandConsole?.entries ?? []) t.command_id !== void 0 && (n[t.source] = t.command_id);
3113
+ return {
3114
+ ...e,
3115
+ commandConsole: void 0,
3116
+ clearedCommandIds: n,
3117
+ clearedConsole: t.clearedConsole,
3118
+ embeddedConsole: e.embeddedConsole.filter((e) => e.channel === "stdin" && e.response === void 0)
3119
+ };
3120
+ }
3121
+ })
3122
+ });
3123
+ function Z({ state: e, cellId: n, cellReducer: r }) {
3124
+ return n in e.cellRuntime ? {
3125
+ ...e,
3126
+ cellRuntime: {
3127
+ ...e.cellRuntime,
3128
+ [n]: r(e.cellRuntime[n])
3129
+ }
3130
+ } : (t.warn(`Cell ${n} not found in state`), e);
3131
+ }
3132
+ var _a = ha((e) => {
3133
+ m.set(X, (t) => ma(t, e));
3134
+ }).addLogs, Q = v((e) => e(X).cellIds);
3135
+ v((e) => e(Q).length === 1), v((e) => si(e(X)).length > 0), v((e) => ci(e(X)).length > 0), v((e) => li(e(X))), v((e) => ui(e(X)));
3136
+ var va = v((e) => pi(e(X), e(an), e(sn)));
3137
+ v((e) => e(va) !== null);
3138
+ var ya = v((e) => {
3139
+ let { cellIds: t, cellData: n } = e(X);
3140
+ return t.map((t) => {
3141
+ let r = e(I(t)), { name: i } = n[t];
3142
+ if (r !== null && R(r.mimetype)) {
3143
+ S(Array.isArray(r.data), "Expected array data");
3144
+ let e = r.data.filter((e) => !e.type.includes("ancestor"));
3145
+ if (e.length > 0) return {
3146
+ output: {
3147
+ ...r,
3148
+ data: e
3149
+ },
3150
+ cellId: t,
3151
+ cellName: i
3152
+ };
3153
+ }
3154
+ return null;
3155
+ }).filter(Boolean);
3156
+ }), ba = x(v((e) => {
3157
+ let t = {};
3158
+ for (let n of e(Q)) {
3159
+ let r = e(L(n));
3160
+ r !== null && r.items.length > 0 && (t[n] = r);
3161
+ }
3162
+ return t;
3163
+ })), xa = v((e) => Ye(e(Q).map((t) => e(L(t)))));
3164
+ v((e) => e(ya).length);
3165
+ var Sa = x(v((e) => {
3166
+ let { cellIds: t, cellData: n } = e(X);
3167
+ return de.fromEntries(t.map((e) => [e, n[e]?.name]));
3168
+ }));
3169
+ v((e) => e(X).scrollKey);
3170
+ var Ca = () => le(Q), wa = () => le(Sa), Ta = () => m.get(X), Ea = () => m.get(X).cellIds, Da = () => {
3171
+ let { cellIds: e, cellData: t } = m.get(X);
3172
+ return e.map((e) => t[e]?.name).filter(Boolean);
3173
+ };
3174
+ _(b(X, (e) => e.cellIds.map((t) => e.cellData[t]))), v((e) => e(X).cellIds.length > 0);
3175
+ var Oa = p((e) => v((t) => t(X).cellData[e])), ka = Er(), $ = p((e) => {
3176
+ let t = v((t) => {
3177
+ let n = kr(t, e), r = t(ee)?.cells;
3178
+ return {
3179
+ local: t(X).cellRuntime[e] ?? ka,
3180
+ execution: n,
3181
+ code: n && Dt(n.record, r)
3182
+ };
3183
+ }), n = b(t, Ar);
3184
+ return v((e) => e(n).rendered);
3185
+ }), Aa = p((e) => v((t) => t(X).cellHandles[e]));
3186
+ function ja(e) {
3187
+ Oa.remove(e), $.remove(e), Aa.remove(e), fn(e);
3188
+ }
3189
+ var Ma = (e) => {
3190
+ let { cellHandles: t } = m.get(X);
3191
+ return t[e].current?.editorView;
3192
+ }, Na = (e) => (Dn.promote(e), Ma(e));
3193
+ v((e) => e(Q).map((t) => ({
3194
+ ...e(Oa(t)),
3195
+ ...e($(t)),
3196
+ output: e(I(t))
3197
+ })));
3198
+ function Pa() {
3199
+ return ga();
3200
+ }
3201
+ //#endregion
3202
+ //#region src/core/errors/error-entries.ts
3203
+ function Fa(e) {
3204
+ if (On(e.mimetype)) {
3205
+ if (!Array.isArray(e.data)) return null;
3206
+ let t = e.data.filter((e) => !e.type.includes("ancestor"));
3207
+ return t.length === 0 ? null : { errorData: t };
3208
+ }
3209
+ return kn(e.mimetype) ? typeof e.data != "string" || e.data.length === 0 ? null : {
3210
+ errorData: [],
3211
+ tracebackHtml: e.data
3212
+ } : null;
3213
+ }
3214
+ function Ia(e) {
3215
+ return e.some((e) => "traceback" in e && e.traceback);
3216
+ }
3217
+ function La(e) {
3218
+ let t = e?.find((e) => kn(e.mimetype));
3219
+ if (t && typeof t.data == "string" && t.data.length !== 0) return t.data;
3220
+ }
3221
+ function Ra(e, t) {
3222
+ if (e.tracebackHtml) return e.tracebackHtml;
3223
+ if (!Ia(e.errorData)) return La(t);
3224
+ }
3225
+ function za(e) {
3226
+ let { cellIds: t, cellData: n } = e.get(X), r = [];
3227
+ for (let [i, a] of t.entries()) {
3228
+ let t = e.get(I(a));
3229
+ if (t === null || !R(t.mimetype)) continue;
3230
+ let o = Fa(t);
3231
+ if (!o) continue;
3232
+ let s = Sr(n[a].name, i), c = t.code ?? n[a].code;
3233
+ r.push({
3234
+ cellId: a,
3235
+ cellName: s,
3236
+ cellCode: c,
3237
+ errorData: o.errorData,
3238
+ tracebackHtml: Ra(o, e.get($(a)).consoleOutputs)
3239
+ });
3240
+ }
3241
+ return r;
3242
+ }
3243
+ function Ba(e) {
3244
+ return e.type === "diagnostic" ? e.msg : e.type === "setup-refs" ? "The setup cell cannot have references" : e.type === "cycle" ? "This cell is in a cycle" : e.type === "multiple-defs" ? `The variable '${e.name}' was defined by another cell` : e.type === "import-star" || e.type === "lazy-import" || e.type === "ancestor-stopped" || e.type === "ancestor-prevented" || e.type === "exception" || e.type === "strict-exception" ? e.msg : e.type === "interruption" ? "This cell was interrupted and needs to be re-run" : e.type === "syntax" || e.type === "unknown" || e.type === "sql-error" ? e.msg : e.type === "internal" ? e.msg || "An internal error occurred" : (u(e), "Unknown error");
3245
+ }
3246
+ function Va(e) {
3247
+ let t = Ba(e);
3248
+ return "traceback" in e && e.traceback && (t += `\n\nTraceback:\n${U(e.traceback)}`), t;
3249
+ }
3250
+ function Ha(e) {
3251
+ let t = [e.cellName];
3252
+ return e.tracebackHtml && t.push(U(e.tracebackHtml)), e.errorData.length > 0 && t.push(e.errorData.map(Va).join("\n\n")), t.join("\n\n");
3253
+ }
3254
+ //#endregion
3255
+ export { ei as $, D as $t, oa as A, B as At, Ri as B, L as Bt, ca as C, gr as Ct, sa as D, Hn as Dt, ua as E, ar as Et, Hi as F, jn as Ft, bi as G, _n as Gt, ji as H, un as Ht, G as I, Mn as It, hi as J, vn as Jt, vi as K, mn as Kt, Bi as L, yn as Lt, Gi as M, In as Mt, Ui as N, zn as Nt, Y as O, Ln as Ot, Vi as P, Rn as Pt, ni as Q, $e as Qt, Ii as R, an as Rt, Pa as S, br as St, da as T, U as Tt, Oi as U, pn as Ut, Ai as V, I as Vt, Ci as W, tn as Wt, gi as X, mt as Xt, oi as Y, Vt as Yt, _i as Z, pt as Zt, xa as _, kr as _t, _a as a, Pr as at, Ca as b, xr as bt, $ as c, Gr as ct, Ma as d, Jr as dt, Ze as en, ti as et, Da as f, Hr as ft, X as g, jr as gt, pa as h, Ur as ht, za as i, we as in, Nr as it, ia as j, z as jt, aa as k, Bn as kt, ha as l, qr as lt, Ta as m, Wr as mt, Ha as n, Ue as nn, $r as nt, Oa as o, Kr as ot, Ea as p, Ir as pt, yi as q, gn as qt, Va as r, Te as rn, Qr as rt, Q as s, Fr as st, Ba as t, Je as tn, W as tt, Na as u, Yr as ut, ma as v, Or as vt, la as w, fr as wt, wa as x, Cr as xt, ja as y, Sr as yt, Li as z, sn as zt };