@marimo-team/frontend 0.16.1 → 0.16.3

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 (310) hide show
  1. package/dist/assets/{ConnectedDataExplorerComponent-2wVcyvDj.js → ConnectedDataExplorerComponent-Brtw1DxF.js} +1 -1
  2. package/dist/assets/{ImageComparisonComponent-D2j6i0hv.js → ImageComparisonComponent-Dxl-PbZX.js} +1 -1
  3. package/dist/assets/{VegaLite-BckFaf2D.js → VegaLite-BXQF0Cx_.js} +1 -1
  4. package/dist/assets/_baseEach-BjSm9ht3.js +1 -0
  5. package/dist/assets/_baseMap-CV4Ezmtf.js +1 -0
  6. package/dist/assets/_baseUniq-Ci9yZGxz.js +1 -0
  7. package/dist/assets/{_createAggregator-C5CVY-0t.js → _createAggregator-VFK9K2d9.js} +1 -1
  8. package/dist/assets/{agent-panel-RGLNjkYe.js → agent-panel-BoscVLCT.js} +7 -7
  9. package/dist/assets/{any-language-editor-DjuXwGCA.js → any-language-editor-ChaY_VUU.js} +1 -1
  10. package/dist/assets/{architectureDiagram-W76B3OCA-Dyj4ds_R.js → architectureDiagram-W76B3OCA-CueUUFYd.js} +1 -1
  11. package/dist/assets/{between-horizontal-start-Dt2aKpPf.js → between-horizontal-start-DAHqmLYT.js} +1 -1
  12. package/dist/assets/{blockDiagram-QIGZ2CNN-o-i7DDvN.js → blockDiagram-QIGZ2CNN-BYYygyWn.js} +1 -1
  13. package/dist/assets/{c4Diagram-FPNF74CW-DGHEwWrx.js → c4Diagram-FPNF74CW-DAz3xEh1.js} +1 -1
  14. package/dist/assets/channel-6SqQ2U_X.js +1 -0
  15. package/dist/assets/chat-panel-DJkOLrw9.js +3 -0
  16. package/dist/assets/{chunk-4BX2VUAB-BJecb-Ri.js → chunk-4BX2VUAB-8g-RyHdt.js} +1 -1
  17. package/dist/assets/{chunk-55IACEB6-CAATkc4w.js → chunk-55IACEB6-iWZZ8Mt6.js} +1 -1
  18. package/dist/assets/{chunk-FMBD7UC4-DPuNbQ-f.js → chunk-FMBD7UC4-knjss4wk.js} +1 -1
  19. package/dist/assets/{chunk-K7UQS3LO-C8TWVLiH.js → chunk-K7UQS3LO-DVIwPBgZ.js} +1 -1
  20. package/dist/assets/{chunk-QN33PNHL-DiZZ09q4.js → chunk-QN33PNHL-CBU8pN6I.js} +1 -1
  21. package/dist/assets/{chunk-QZHKN3VN-BIUM7usu.js → chunk-QZHKN3VN-5ljElUF4.js} +1 -1
  22. package/dist/assets/{chunk-TVAH2DTR-vGTArPBG.js → chunk-TVAH2DTR-DkIdGINc.js} +1 -1
  23. package/dist/assets/{chunk-TZMSLE5B-D2KRqp_x.js → chunk-TZMSLE5B-CIFOSTqh.js} +1 -1
  24. package/dist/assets/{circle-play-cjeNez0N.js → circle-play-BOdsbq5u.js} +1 -1
  25. package/dist/assets/classDiagram-KNZD7YFC-DVqXcTYf.js +1 -0
  26. package/dist/assets/classDiagram-v2-RKCZMP56-DVqXcTYf.js +1 -0
  27. package/dist/assets/{clear-button-C97JtAez.js → clear-button-GAjXl0CQ.js} +1 -1
  28. package/dist/assets/clone-DSDb0xen.js +1 -0
  29. package/dist/assets/command-palette-BUXkqoLh.js +1 -0
  30. package/dist/assets/{common-Du9rSOwD.js → common-DahoYqdi.js} +1 -1
  31. package/dist/assets/{compile-CZXqyOxa.js → compile-Bg8uJ7vm.js} +1 -1
  32. package/dist/assets/{cose-bilkent-S5V4N54A-CqUN5Y9b.js → cose-bilkent-S5V4N54A-z_0gqD9K.js} +1 -1
  33. package/dist/assets/{dagre-5GWH7T2D-RJqTI9DM.js → dagre-5GWH7T2D-BMt7CNXL.js} +1 -1
  34. package/dist/assets/{data-grid-overlay-editor-DZN0q1LV.js → data-grid-overlay-editor-Ctn4XtXx.js} +1 -1
  35. package/dist/assets/datasources-panel-C7sqRIHs.js +1 -0
  36. package/dist/assets/{dependency-graph-panel-CEog_O7V.js → dependency-graph-panel-DNajptzv.js} +4 -4
  37. package/dist/assets/{diagram-N5W7TBWH-D-l4zZ9d.js → diagram-N5W7TBWH-BzwvLvAy.js} +1 -1
  38. package/dist/assets/{diagram-QEK2KX5R-CCOmBUt-.js → diagram-QEK2KX5R-DRLJ56FS.js} +1 -1
  39. package/dist/assets/{diagram-S2PKOQOG-C_I_9jnZ.js → diagram-S2PKOQOG-Bf8x4KTU.js} +1 -1
  40. package/dist/assets/{documentation-panel-C1BtMZ3M.js → documentation-panel-Dm6Ozl67.js} +1 -1
  41. package/dist/assets/{edit-page-B-oevUZ9.js → edit-page-CGc9EjuG.js} +53 -42
  42. package/dist/assets/{ellipsis-vertical-BEb-J8z6.js → ellipsis-vertical-Bj1YXvZe.js} +1 -1
  43. package/dist/assets/{empty-state-C99UyDE3.js → empty-state-CYev-D31.js} +1 -1
  44. package/dist/assets/{erDiagram-AWTI2OKA-BePOLi5M.js → erDiagram-AWTI2OKA-DmgzgN_I.js} +1 -1
  45. package/dist/assets/{error-panel-Bs34jXFh.js → error-panel-BYG4twCa.js} +1 -1
  46. package/dist/assets/{file-explorer-panel-Ck6UL861.js → file-explorer-panel-BSMiOApi.js} +1 -1
  47. package/dist/assets/{flowDiagram-PVAE7QVJ-BgjFu5l7.js → flowDiagram-PVAE7QVJ-BdRKkajr.js} +1 -1
  48. package/dist/assets/{ganttDiagram-OWAHRB6G-YOPb3XSV.js → ganttDiagram-OWAHRB6G-lfRAMnq_.js} +5 -5
  49. package/dist/assets/{gitGraphDiagram-NY62KEGX-CGhqaDTy.js → gitGraphDiagram-NY62KEGX-CQVTIrHF.js} +1 -1
  50. package/dist/assets/{glide-data-editor-9QUH6iso.js → glide-data-editor-D5A4pou7.js} +4 -4
  51. package/dist/assets/{graph-DQQFGrho.js → graph-CBNo279v.js} +1 -1
  52. package/dist/assets/{home-page-DRKpPCrF.js → home-page-CmdznBJR.js} +2 -2
  53. package/dist/assets/{index-SGLNXrGP.js → index-0dfGh-Gj.js} +1 -1
  54. package/dist/assets/{index-aE43R74q.js → index-BDYVSSzB.js} +1 -1
  55. package/dist/assets/{index-BJNCMUmG.js → index-B_KyDZ94.js} +1 -1
  56. package/dist/assets/{index-BjgnbONl.js → index-Bfy-I_lW.js} +1 -1
  57. package/dist/assets/{index-CUFv_thQ.js → index-Bh98Tp-z.js} +1 -1
  58. package/dist/assets/{index-C2MD0vgD.js → index-BhroIwBL.js} +1 -1
  59. package/dist/assets/{index-DdnKZNxM.js → index-BtQtesaI.js} +1 -1
  60. package/dist/assets/index-C0iXCvyY.css +1 -0
  61. package/dist/assets/index-C1SHFMCp.js +581 -0
  62. package/dist/assets/{index-C_tkBKNO.js → index-C6DWtSls.js} +1 -1
  63. package/dist/assets/{index-Aeo6WiK7.js → index-C71cdkH-.js} +1 -1
  64. package/dist/assets/{index-G5QZppK2.js → index-CT_FTqvK.js} +1 -1
  65. package/dist/assets/{index-B8jXZ12t.js → index-CU5rRr66.js} +1 -1
  66. package/dist/assets/{index-BAbIIxHU.js → index-Cb6duXQm.js} +1 -1
  67. package/dist/assets/{index-BW3k9Gss.js → index-D23e9zQj.js} +1 -1
  68. package/dist/assets/index-DUGecC2Z.js +68 -0
  69. package/dist/assets/{index-CFKO7WXI.js → index-DcGIOAQi.js} +1 -1
  70. package/dist/assets/{index-ClzeQrN7.js → index-PJfa9qXY.js} +1 -1
  71. package/dist/assets/{index-C1ez98sk.js → index-SPslPC2B.js} +1 -1
  72. package/dist/assets/{index-BprjMYH5.js → index-VPQlo4Uz.js} +1 -1
  73. package/dist/assets/{index-CfaDbEdi.js → index-qbTLKWyG.js} +1 -1
  74. package/dist/assets/infoDiagram-STP46IZ2-DBu8p9gd.js +2 -0
  75. package/dist/assets/{isEmpty-D-4c7sMv.js → isEmpty-CnOLuQIv.js} +1 -1
  76. package/dist/assets/{journeyDiagram-BIP6EPQ6-C94u3Mv3.js → journeyDiagram-BIP6EPQ6-6U_vHJBH.js} +1 -1
  77. package/dist/assets/{kanban-definition-6OIFK2YF-BEXYFzz7.js → kanban-definition-6OIFK2YF-DgnR14ys.js} +1 -1
  78. package/dist/assets/{layout-Bz2BJ2ru.js → layout-RHmq4fP9.js} +1 -1
  79. package/dist/assets/{linear-D8s7K76e.js → linear-CLdOVPGV.js} +1 -1
  80. package/dist/assets/links-Dd1icsEk.js +7 -0
  81. package/dist/assets/{logs-panel-DC7wpmPz.js → logs-panel-CjbuhBLx.js} +1 -1
  82. package/dist/assets/{markdown-renderer-DRdSWR9X.js → markdown-renderer-X5YJvAZq.js} +3 -3
  83. package/dist/assets/{mermaid-Y3x4hmD0.js → mermaid-Bl2T5oEC.js} +1 -1
  84. package/dist/assets/{mermaid.core-DzthE35Y.js → mermaid.core-CfukBvGI.js} +4 -4
  85. package/dist/assets/min-BXIes1Za.js +1 -0
  86. package/dist/assets/{mindmap-definition-Q6HEUPPD-DktvuLe1.js → mindmap-definition-Q6HEUPPD-BXCjP4Lu.js} +1 -1
  87. package/dist/assets/{number-overlay-editor-BEfwI1IT.js → number-overlay-editor-BUyqkSes.js} +1 -1
  88. package/dist/assets/{outline-panel-CdsnAy2w.js → outline-panel-BvGcPKdd.js} +1 -1
  89. package/dist/assets/{packages-panel-DiTA-d_D.js → packages-panel-BichDQWG.js} +1 -1
  90. package/dist/assets/{pieDiagram-ADFJNKIX-DQDNQ-de.js → pieDiagram-ADFJNKIX-CMzJFIJM.js} +1 -1
  91. package/dist/assets/{quadrantDiagram-LMRXKWRM-0kgIXc2-.js → quadrantDiagram-LMRXKWRM-CfGssUlO.js} +1 -1
  92. package/dist/assets/{react-plotly-DJqqfM7c.js → react-plotly-DR3hV0HW.js} +1 -1
  93. package/dist/assets/{requirementDiagram-4UW4RH46-B5rb0ypd.js → requirementDiagram-4UW4RH46-CfrFolth.js} +1 -1
  94. package/dist/assets/{run-page-CFmLrv1R.js → run-page-Bqd_4ePD.js} +1 -1
  95. package/dist/assets/{sankeyDiagram-GR3RE2ED-Dom7IlnF.js → sankeyDiagram-GR3RE2ED-D_UttKU0.js} +1 -1
  96. package/dist/assets/{scratchpad-panel-CuHWpHO8.js → scratchpad-panel-D5N15ji1.js} +1 -1
  97. package/dist/assets/secrets-panel-BpbnAO4R.js +1 -0
  98. package/dist/assets/{sequenceDiagram-C3RYC4MD-PNJWXQbw.js → sequenceDiagram-C3RYC4MD-MdfQQApP.js} +1 -1
  99. package/dist/assets/{slides-component-CJgaTRZ0.js → slides-component-C0z7rXmk.js} +1 -1
  100. package/dist/assets/{snippets-panel-B2EC1txM.js → snippets-panel-wlpZ_Wzx.js} +1 -1
  101. package/dist/assets/sortBy-BW_zNHP6.js +1 -0
  102. package/dist/assets/{state-CWict9RU.js → state-CDooX-dk.js} +1 -1
  103. package/dist/assets/{stateDiagram-KXAO66HF-BE58aJnr.js → stateDiagram-KXAO66HF-H7kfw3ot.js} +1 -1
  104. package/dist/assets/stateDiagram-v2-UMBNRL4Z-YMeb9qMR.js +1 -0
  105. package/dist/assets/{storage-DRaR04wR.js → storage-b1QCapTq.js} +6 -6
  106. package/dist/assets/{terminal-BX3Su5q7.js → terminal-CPV44BXz.js} +1 -1
  107. package/dist/assets/{time-hUzZfpNE.js → time-DDy3xv5Y.js} +1 -1
  108. package/dist/assets/{timeline-definition-XQNQX7LJ-CqQP9t51.js → timeline-definition-XQNQX7LJ-J-cPRT2_.js} +1 -1
  109. package/dist/assets/{tracing-B10Q1n-L.js → tracing-3eHHRUiJ.js} +2 -2
  110. package/dist/assets/{tracing-panel-Du8WCnno.js → tracing-panel-BMgy3D7d.js} +2 -2
  111. package/dist/assets/{trash-B81GTiv6.js → trash--tonOuDe.js} +1 -1
  112. package/dist/assets/{tree-6vW2ogkh.js → tree-ouIGEsVg.js} +1 -1
  113. package/dist/assets/{treemap-75Q7IDZK-CdwDwwsz.js → treemap-75Q7IDZK-CzJTJ_3R.js} +20 -20
  114. package/dist/assets/{variable-panel-D5qgJI7k.js → variable-panel-sFTn4Oih.js} +1 -1
  115. package/dist/assets/{vega-component-DJaJWMJM.js → vega-component-BkPkzX9r.js} +1 -1
  116. package/dist/assets/{xychartDiagram-6GGTOJPD-WFtXqaM9.js → xychartDiagram-6GGTOJPD-BZ8WOb_8.js} +1 -1
  117. package/dist/index.html +10 -3
  118. package/package.json +8 -8
  119. package/src/__mocks__/common.ts +5 -3
  120. package/src/__mocks__/notebook.ts +2 -2
  121. package/src/__mocks__/requests.ts +1 -0
  122. package/src/__tests__/main.test.tsx +2 -2
  123. package/src/components/ai/ai-provider-icon.tsx +2 -0
  124. package/src/components/app-config/ai-config.tsx +32 -1
  125. package/src/components/app-config/common.tsx +2 -2
  126. package/src/components/app-config/user-config-form.tsx +26 -0
  127. package/src/components/audio/audio-recorder.tsx +0 -1
  128. package/src/components/chat/acp/blocks.tsx +2 -2
  129. package/src/components/chat/acp/thread.tsx +3 -5
  130. package/src/components/chat/acp/utils.ts +5 -5
  131. package/src/components/chat/chat-panel.tsx +1 -1
  132. package/src/components/data-table/__tests__/columns.test.tsx +38 -0
  133. package/src/components/data-table/__tests__/data-table.test.tsx +2 -2
  134. package/src/components/data-table/cell-hover-template/feature.ts +1 -1
  135. package/src/components/data-table/cell-hover-template/types.ts +1 -1
  136. package/src/components/data-table/charts/__tests__/altair-generator.test.ts +1 -1
  137. package/src/components/data-table/charts/chart-spec/tooltips.ts +3 -3
  138. package/src/components/data-table/charts/components/chart-items.tsx +1 -1
  139. package/src/components/data-table/charts/components/form-fields.tsx +2 -2
  140. package/src/components/data-table/charts/constants.ts +1 -1
  141. package/src/components/data-table/column-explorer-panel/column-explorer.tsx +1 -1
  142. package/src/components/data-table/column-summary/chart-spec-model.tsx +2 -2
  143. package/src/components/data-table/columns.tsx +22 -3
  144. package/src/components/data-table/data-table.tsx +35 -3
  145. package/src/components/data-table/date-popover.tsx +1 -1
  146. package/src/components/data-table/download-actions.tsx +1 -1
  147. package/src/components/data-table/range-focus/__tests__/utils.test.ts +5 -5
  148. package/src/components/data-table/renderers.tsx +22 -13
  149. package/src/components/data-table/row-viewer-panel/row-viewer.tsx +1 -1
  150. package/src/components/data-table/schemas.ts +16 -0
  151. package/src/components/data-table/types.ts +4 -3
  152. package/src/components/datasources/column-preview.tsx +9 -6
  153. package/src/components/debugger/debugger-code.tsx +1 -1
  154. package/src/components/dependency-graph/custom-node.tsx +15 -6
  155. package/src/components/dependency-graph/dependency-graph-minimap.tsx +2 -2
  156. package/src/components/dependency-graph/dependency-graph-tree.tsx +2 -2
  157. package/src/components/dependency-graph/dependency-graph.tsx +1 -1
  158. package/src/components/dependency-graph/elements.ts +7 -7
  159. package/src/components/dependency-graph/utils/changes.ts +4 -4
  160. package/src/components/editor/Cell.tsx +7 -1
  161. package/src/components/editor/ai/transport/chat-transport.tsx +1 -1
  162. package/src/components/editor/chrome/panels/outline/useActiveOutline.tsx +1 -1
  163. package/src/components/editor/chrome/panels/packages-panel.tsx +1 -1
  164. package/src/components/editor/columns/storage.ts +1 -1
  165. package/src/components/editor/database/__tests__/__snapshots__/as-code.test.ts.snap +36 -0
  166. package/src/components/editor/database/__tests__/as-code.test.ts +30 -7
  167. package/src/components/editor/database/add-database-form.tsx +11 -0
  168. package/src/components/editor/database/as-code.ts +104 -5
  169. package/src/components/editor/database/schemas.ts +36 -18
  170. package/src/components/editor/errors/auto-fix.tsx +12 -2
  171. package/src/components/editor/errors/sql-validation-errors.tsx +40 -0
  172. package/src/components/editor/navigation/clipboard.ts +2 -2
  173. package/src/components/editor/output/ConsoleOutput.tsx +14 -2
  174. package/src/components/editor/output/JsonOutput.tsx +1 -1
  175. package/src/components/editor/output/MarimoErrorOutput.tsx +60 -1
  176. package/src/components/editor/output/MarimoTracebackOutput.tsx +17 -2
  177. package/src/components/editor/renderers/grid-layout/types.ts +2 -2
  178. package/src/components/editor/renderers/plugins.ts +1 -1
  179. package/src/components/editor/renderers/types.ts +1 -1
  180. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +7 -7
  181. package/src/components/forms/form.tsx +5 -5
  182. package/src/components/ui/links.tsx +1 -0
  183. package/src/core/ai/__tests__/model-registry.test.ts +0 -10
  184. package/src/core/ai/context/providers/cell-output.ts +1 -18
  185. package/src/core/ai/context/providers/error.ts +2 -2
  186. package/src/core/ai/ids/ids.ts +1 -0
  187. package/src/core/ai/model-registry.ts +2 -1
  188. package/src/core/cells/cells.ts +5 -5
  189. package/src/core/cells/logs.ts +1 -1
  190. package/src/core/cells/types.ts +1 -1
  191. package/src/core/codemirror/__tests__/format.test.ts +6 -0
  192. package/src/core/codemirror/cells/traceback-decorations.ts +1 -1
  193. package/src/core/codemirror/editing/commands.ts +2 -2
  194. package/src/core/codemirror/find-replace/navigate.ts +1 -1
  195. package/src/core/codemirror/language/__tests__/extension.test.ts +24 -0
  196. package/src/core/codemirror/language/__tests__/sql-validation.test.ts +133 -0
  197. package/src/core/codemirror/language/__tests__/sql.test.ts +764 -79
  198. package/src/core/codemirror/language/languages/markdown.ts +4 -1
  199. package/src/core/codemirror/language/languages/sql/banner-validation-errors.ts +85 -0
  200. package/src/core/codemirror/language/languages/sql/completion-builder.ts +160 -0
  201. package/src/core/codemirror/language/languages/sql/completion-sources.tsx +9 -3
  202. package/src/core/codemirror/language/languages/sql/completion-store.ts +46 -50
  203. package/src/core/codemirror/language/languages/sql/renderers.tsx +485 -0
  204. package/src/core/codemirror/language/languages/sql/sql-mode.ts +20 -0
  205. package/src/core/codemirror/language/languages/sql/sql.ts +218 -4
  206. package/src/core/codemirror/language/languages/sql/utils.ts +4 -1
  207. package/src/core/codemirror/language/panel/panel.tsx +8 -2
  208. package/src/core/codemirror/language/panel/sql.tsx +86 -4
  209. package/src/core/codemirror/language/utils/ast.ts +3 -3
  210. package/src/core/codemirror/lsp/federated-lsp.ts +4 -4
  211. package/src/core/codemirror/lsp/lens.ts +4 -4
  212. package/src/core/codemirror/lsp/notebook-lsp.ts +1 -1
  213. package/src/core/codemirror/lsp/types.ts +1 -1
  214. package/src/core/codemirror/markdown/completions.ts +1 -1
  215. package/src/core/codemirror/reactive-references/analyzer.ts +2 -2
  216. package/src/core/codemirror/rtc/loro/awareness.ts +1 -1
  217. package/src/core/config/config-schema.ts +1 -0
  218. package/src/core/config/feature-flag.tsx +6 -2
  219. package/src/core/datasets/request-registry.ts +24 -1
  220. package/src/core/dom/events.ts +1 -1
  221. package/src/core/dom/outline.ts +2 -2
  222. package/src/core/dom/uiregistry.ts +2 -8
  223. package/src/core/errors/__tests__/errors.test.ts +22 -4
  224. package/src/core/errors/errors.ts +29 -1
  225. package/src/core/errors/state.ts +1 -1
  226. package/src/core/islands/bridge.ts +1 -0
  227. package/src/core/islands/main.ts +3 -2
  228. package/src/core/islands/parse.ts +1 -3
  229. package/src/core/kernel/messages.ts +2 -1
  230. package/src/core/network/CachingRequestRegistry.ts +74 -0
  231. package/src/core/network/DeferredRequestRegistry.ts +3 -1
  232. package/src/core/network/__tests__/CachingRequestRegistry.test.ts +73 -0
  233. package/src/core/network/requests-network.ts +7 -0
  234. package/src/core/network/requests-static.ts +1 -0
  235. package/src/core/network/requests-toasting.ts +1 -0
  236. package/src/core/network/types.ts +3 -1
  237. package/src/core/variables/state.ts +2 -2
  238. package/src/core/wasm/__tests__/state.test.ts +1 -1
  239. package/src/core/wasm/bridge.ts +5 -0
  240. package/src/core/websocket/useMarimoWebSocket.tsx +9 -2
  241. package/src/custom.d.ts +1 -1
  242. package/src/hooks/useCellRenderCount.ts +1 -0
  243. package/src/hooks/useResizeHandle.ts +4 -1
  244. package/src/plugins/core/RenderHTML.tsx +1 -2
  245. package/src/plugins/core/registerReactComponent.tsx +23 -19
  246. package/src/plugins/impl/DataTablePlugin.tsx +18 -6
  247. package/src/plugins/impl/FileUploadPlugin.tsx +1 -1
  248. package/src/plugins/impl/RefreshPlugin.tsx +1 -1
  249. package/src/plugins/impl/SliderPlugin.tsx +4 -0
  250. package/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx +27 -9
  251. package/src/plugins/impl/anywidget/__tests__/AnyWidgetPlugin.test.tsx +58 -2
  252. package/src/plugins/impl/anywidget/__tests__/model.test.ts +3 -4
  253. package/src/plugins/impl/anywidget/model.ts +2 -3
  254. package/src/plugins/impl/data-editor/types.ts +1 -1
  255. package/src/plugins/impl/data-explorer/components/query-form.tsx +1 -1
  256. package/src/plugins/impl/data-frames/DataFramePlugin.tsx +17 -5
  257. package/src/plugins/impl/data-frames/types.ts +1 -1
  258. package/src/plugins/impl/panel/PanelPlugin.tsx +2 -2
  259. package/src/plugins/impl/plotly/PlotlyPlugin.tsx +3 -3
  260. package/src/plugins/impl/vega/__tests__/loader.test.ts +2 -2
  261. package/src/plugins/impl/vega/loader.ts +1 -1
  262. package/src/plugins/impl/vega/vega-component.tsx +1 -1
  263. package/src/plugins/impl/vega/vega-loader.ts +2 -2
  264. package/src/plugins/layout/NavigationMenuPlugin.tsx +1 -1
  265. package/src/plugins/layout/RoutesPlugin.tsx +1 -2
  266. package/src/plugins/plugins.ts +2 -2
  267. package/src/stories/dataframe.stories.tsx +2 -0
  268. package/src/utils/Logger.ts +1 -1
  269. package/src/utils/__tests__/data-views.test.ts +30 -68
  270. package/src/utils/__tests__/dom.test.ts +167 -0
  271. package/src/utils/__tests__/id-tree.test.ts +49 -1
  272. package/src/utils/__tests__/storage.test.ts +1 -1
  273. package/src/utils/__tests__/traceback.test.ts +13 -2
  274. package/src/utils/arrays.ts +1 -1
  275. package/src/utils/createReducer.ts +1 -5
  276. package/src/utils/data-views.ts +6 -19
  277. package/src/utils/dom.ts +55 -0
  278. package/src/utils/edit-distance.ts +1 -1
  279. package/src/utils/fileToBase64.ts +1 -1
  280. package/src/utils/id-tree.tsx +20 -18
  281. package/src/utils/json/base64.ts +13 -0
  282. package/src/utils/json/json-parser.ts +2 -2
  283. package/src/utils/lru.ts +4 -0
  284. package/src/utils/mergeRefs.ts +1 -1
  285. package/src/utils/objects.ts +3 -3
  286. package/src/utils/pluralize.ts +1 -1
  287. package/src/utils/routes.ts +2 -2
  288. package/src/utils/sets.ts +1 -1
  289. package/src/utils/traceback.ts +45 -15
  290. package/src/utils/tracer.ts +11 -9
  291. package/dist/assets/_baseEach-CvTX9w0Y.js +0 -1
  292. package/dist/assets/_baseMap-CtlwA90f.js +0 -1
  293. package/dist/assets/_baseUniq-BKktIGQ1.js +0 -1
  294. package/dist/assets/channel-Co6iMgWq.js +0 -1
  295. package/dist/assets/chat-panel-9alr8FS4.js +0 -3
  296. package/dist/assets/classDiagram-KNZD7YFC-BbJ0rY3y.js +0 -1
  297. package/dist/assets/classDiagram-v2-RKCZMP56-BbJ0rY3y.js +0 -1
  298. package/dist/assets/clone-BMP0PsTa.js +0 -1
  299. package/dist/assets/command-palette-B93Pjcky.js +0 -1
  300. package/dist/assets/datasources-panel-v7H3cR0p.js +0 -1
  301. package/dist/assets/index-2252nrk6.js +0 -68
  302. package/dist/assets/index-C7CoaNFb.js +0 -578
  303. package/dist/assets/index-DadI618h.css +0 -1
  304. package/dist/assets/infoDiagram-STP46IZ2-CJLOpSAf.js +0 -2
  305. package/dist/assets/links-BpXlz1GG.js +0 -7
  306. package/dist/assets/min-BBO3-1Hg.js +0 -1
  307. package/dist/assets/secrets-panel-CfHc5YD0.js +0 -1
  308. package/dist/assets/sortBy-DZnlX29-.js +0 -1
  309. package/dist/assets/stateDiagram-v2-UMBNRL4Z-CdThjimL.js +0 -1
  310. package/src/__tests__/lru.test.ts +0 -74
@@ -1,129 +1,140 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./terminal-BX3Su5q7.js","./index-C7CoaNFb.js","./index-DadI618h.css","./state-CWict9RU.js","./links-BpXlz1GG.js","./links-5Ym3a_OV.css","./storage-DRaR04wR.js","./index-Aeo6WiK7.js","./index-CfaDbEdi.js","./index-BjgnbONl.js","./index-CUFv_thQ.js","./index-DdnKZNxM.js","./index-C_tkBKNO.js","./index-BJNCMUmG.js","./index-CFKO7WXI.js","./index-aE43R74q.js","./index-BAbIIxHU.js","./index-ClzeQrN7.js","./index-G5QZppK2.js","./index-C2MD0vgD.js","./apl-CXdQSnD-.js","./asciiarmor-D5V0T9Cu.js","./asn1-DWPaVWf6.js","./brainfuck-CtZaYBKt.js","./cobol-stawOqaz.js","./clike-BgBwzOhw.js","./clojure-DiuoqK-z.js","./css-ZjFoif2m.js","./cmake-DXn5xaP-.js","./coffeescript-BTDxI-eT.js","./commonlisp-vq6DHwts.js","./cypher-gJDei3ni.js","./python-DD-Q2bae.js","./crystal-CRzZ78HM.js","./d-BShv7fp-.js","./diff-UJJ5BM9S.js","./dtd-DI9Herc-.js","./dylan-DkEP81N9.js","./ecl-DPFc0Uaf.js","./eiffel-DR5c0IrL.js","./elm-DompmV0j.js","./erlang-BuqgqA5h.js","./factor-CFXhaUWb.js","./simple-mode-C3vEBAcb.js","./forth-POgR1ypr.js","./fortran-DL7KluxX.js","./mllike-3c2dg9RT.js","./gas-bV0CklSb.js","./gherkin-B6X1vGSW.js","./groovy-DnIzCrpZ.js","./haskell-CLQs6EAM.js","./haxe-D25e-2l-.js","./idl-pcmmZuaN.js","./javascript-BpzJj0-u.js","./jinja2-DhgKlfW7.js","./julia-DjdwvFuI.js","./livescript-HO6ttBFx.js","./lua-8DXOpKDz.js","./mirc-DkvFAiy5.js","./mathematica-IIbmv7SK.js","./modelica-DSrSSXCg.js","./mumps-zvxmGV4l.js","./mbox-z_N2Mo3d.js","./nsis-BvKfQ9lQ.js","./ntriples-BSwWqoLa.js","./octave-C4hdQ5Hf.js","./oz-qQq7irPq.js","./pascal-CafrKXZF.js","./perl-tdMlh9QA.js","./pig-CwGJVRC4.js","./powershell-D1ly3AHC.js","./properties-_nPj978X.js","./protobuf-B4y9do6W.js","./pug-BTvK5tSS.js","./puppet-Bc-yJKzi.js","./q-B0kTJ4cI.js","./r-BA4EbLKE.js","./rpm-DI_rRufH.js","./ruby-CR-u2WLS.js","./sas-Bqaci40L.js","./scheme-qjP0V5Ag.js","./shell-BLav31RL.js","./sieve-r025o_jW.js","./smalltalk-C7J3IyEP.js","./sparql-BRLJFz69.js","./stylus-Bdo_Aemu.js","./swift-B_XXVlXX.js","./verilog-B4LBqg_1.js","./tcl-B2fODqDH.js","./textile-BuVhTOzU.js","./toml-wcPdHu67.js","./troff-Ce85hlLp.js","./ttcn-BxnYHtq8.js","./ttcn-cfg-CKJxb-l2.js","./turtle-BkSuIpt-.js","./webidl-CGwyPRYs.js","./vb-BHgjm0DN.js","./vbscript-Dawdd5GZ.js","./velocity-BdD_26Jv.js","./vhdl-CWWH2SUo.js","./xquery-CVDBqZPY.js","./yacas-I8QjZlxf.js","./z80-D8p3gKXp.js","./mscgen-B2igx18G.js","./index-C1ez98sk.js","./trash-B81GTiv6.js","./storage-B3Gax9mZ.css","./_createAggregator-C5CVY-0t.js","./_baseEach-CvTX9w0Y.js","./loro_wasm_bg-C1ks32Vm.js","./terminal-B3isKKSk.css","./chat-panel-9alr8FS4.js","./empty-state-C99UyDE3.js","./markdown-renderer-DRdSWR9X.js","./katex-LV4FpwlL.js","./between-horizontal-start-Dt2aKpPf.js","./markdown-renderer-ClyzDMmG.css","./isEmpty-D-4c7sMv.js","./agent-panel-RGLNjkYe.js","./agent-panel-D92Mfy1i.css","./dependency-graph-panel-CEog_O7V.js","./transform-D9VCJYws.js","./timer-Bqd5yn_a.js","./zoom-COrs4lFh.js","./common-Du9rSOwD.js","./ellipsis-vertical-BEb-J8z6.js","./dependency-graph-panel-YfRlmuld.css","./datasources-panel-v7H3cR0p.js","./sortBy-DZnlX29-.js","./_baseMap-CtlwA90f.js","./documentation-panel-C1BtMZ3M.js","./error-panel-Bs34jXFh.js","./file-explorer-panel-Ck6UL861.js","./icon-32x32-DHZerVul.js","./tree-6vW2ogkh.js","./index-B8jXZ12t.js","./logs-panel-DC7wpmPz.js","./clear-button-C97JtAez.js","./outline-panel-CdsnAy2w.js","./outline-panel-CJw2eR3G.css","./packages-panel-DiTA-d_D.js","./scratchpad-panel-CuHWpHO8.js","./secrets-panel-CfHc5YD0.js","./snippets-panel-B2EC1txM.js","./snippets-panel-B4N-3dTw.css","./tracing-panel-Du8WCnno.js","./variable-panel-D5qgJI7k.js","./command-palette-B93Pjcky.js"])))=>i.map(i=>d[i]);
2
- var Xw=Object.defineProperty;var ap=nt=>{throw TypeError(nt)};var Qw=(nt,We,gt)=>We in nt?Xw(nt,We,{enumerable:!0,configurable:!0,writable:!0,value:gt}):nt[We]=gt;var B=(nt,We,gt)=>Qw(nt,typeof We!="symbol"?We+"":We,gt),Zw=(nt,We,gt)=>We.has(nt)||ap("Cannot "+gt);var ip=(nt,We,gt)=>(Zw(nt,We,"read from private field"),gt?gt.call(nt):We.get(nt)),lp=(nt,We,gt)=>We.has(nt)?ap("Cannot add the same private member more than once"):We instanceof WeakSet?We.add(nt):We.set(nt,gt);import{c as de,k3 as oo,k4 as ek,k5 as Cl,k6 as tk,k7 as nk,k8 as cp,k9 as dp,ka as Gs,r as S,i9 as ok,bW as up,gR as hp,kb as rk,gN as sk,gQ as ak,d as me,gL as Nl,kc as ro,kd as Dt,ke as qs,kf as tt,v as Yt,j4 as Wt,eZ as $t,kg as Te,kh as So,p as Se,je as Sn,a as P,ax as qe,a0 as ze,j as i,aV as Xt,b1 as so,b0 as yr,b2 as vr,bQ as ao,a_ as ye,$ as Eo,bT as Hs,a$ as io,aI as Fn,a8 as mp,aB as pe,ay as Ct,g$ as Sl,cN as Js,ki as ik,cM as Ce,S as Ye,kj as lk,hP as Mt,kk as fp,kl as pp,km as El,kn as gp,L as He,c3 as bp,bl as _o,d1 as ck,W as xp,aA as Qt,ko as dk,c5 as Ks,kp as Ys,av as Bt,d5 as Be,d8 as Io,fU as $e,kq as fe,d6 as Me,kr as _l,ks as uk,kt as Il,ku as Ve,kv as yp,dw as Al,dt as Tl,gA as Dl,dh as Ml,dp as Ol,ef as Ao,i$ as Rl,cP as Bn,b as wr,X as Pn,iR as vp,iT as wp,iU as hk,iZ as mk,iV as kp,kw as jp,T as ue,hq as fk,d$ as zn,dZ as Un,e0 as Wn,dY as lo,f8 as En,kx as Cp,iX as Np,ky as pk,aZ as gk,aY as bk,kz as xk,iP as Sp,iQ as Ep,by as yk,di as _p,br as vk,jJ as wk,kA as kk,du as jk,gC as Ll,bI as Fl,dA as Bl,f0 as Ck,ei as Ot,hJ as Nk,ct as Pl,i0 as Nt,e9 as Sk,h0 as ht,hm as Ek,aW as zl,g0 as kr,kB as Xs,cp as _n,K as ie,hF as To,aw as Qs,kC as _k,kD as Ik,kE as Ip,aX as Ak,b3 as Ul,hD as Ap,dV as Zs,cO as St,dW as Tk,b4 as Dk,jp as Tp,a7 as Wl,kF as Mk,kG as $l,dI as Ok,e8 as Rk,hO as Dp,eb as Lk,kH as Fk,kI as Mp,jX as Bk,jV as Pk,jY as zk,jZ as Uk,kJ as Vl,f2 as Zt,kK as Wk,ba as Le,kL as ea,kM as Do,kN as Mo,cs as Gl,jk as st,kO as ql,cC as $k,bn as Vt,kP as Vk,kQ as Op,iI as Hl,cy as Rp,bU as Lp,bC as Jl,e6 as Gk,e7 as qk,kR as Hk,bm as Fp,an as Kl,bp as Bp,bM as Yl,al as ta,hQ as Xl,kS as Jk,g_ as Gt,kT as Pp,kU as jr,kV as zp,kW as na,kX as Up,kY as Wp,kZ as $p,g5 as Vp,cu as Gp,cK as qp,k_ as Kk,k$ as en,l0 as oa,l1 as Hp,M as Ql,l2 as Cr,l3 as Nr,bb as Jp,jS as Zl,l4 as Kp,l5 as ra,b8 as Yp,l6 as Xp,l7 as sa,aG as $n,fb as ec,hN as Qp,bF as Zp,l8 as Sr,l9 as Er,la as aa,lb as Vn,lc as e1,ld as In,le as Oo,lf as tc,lg as _r,lh as Ro,li as nc,lj as oc,lk as t1,ll as ia,lm as Yk,c4 as Ir,ln as Ar,lo as Xk,gZ as la,lp as Qk,lq as rc,lr as Zk,ls as e4,lt as ca,ec as Lo,h5 as t4,cJ as n1,lu as n4,jx as o1,fr as r1,lv as sc,i_ as s1,hC as a1,lw as i1,lx as da,ly as l1,lz as ua,lA as ac,lB as Fo,lC as Tr,lD as Dr,lE as o4,ju as ic,lF as lc,lG as ha,hl as r4,jv as s4,lH as a4,lI as i4,lJ as l4,lK as c4,x as d4,lL as u4,lM as h4,lN as m4,j7 as f4,lO as p4,lP as c1,t as v,lQ as g4,lR as b4,lS as x4,lT as y4,lU as v4,lV as w4,lW as k4,lX as j4,lY as C4,lZ as N4,l_ as S4,l$ as E4,m0 as _4,m1 as I4,m2 as A4,m3 as T4,m4 as D4,m5 as M4,m6 as O4,m7 as R4,m8 as L4,m9 as F4,ma as Mr,mb as B4,mc as P4,md as z4,me as U4,mf as W4,mg as $4,mh as V4,mi as G4,mj as cc,bt as dc,gz as d1,mk as u1,ml as q4,mm as H4,cV as J4,mn as K4,cW as Y4,cY as Or,mo as X4,mp as Q4,mq as Z4,mr as e3,ms as t3,mt as n3,mu as o3,mv as r3,mw as s3,mx as a3,cZ as i3,my as l3,mz as c3,mA as d3,mB as h1,h2 as u3,mC as h3,mD as m1,h6 as m3,mE as ma,mF as f3,mG as p3,mH as g3,mI as b3,a2 as uc,bj as hc,bD as Gn,mJ as Bo,mK as f1,cR as x3,dc as mc,bx as p1,mL as y3,mM as Rr,hr as fc,mN as co,mO as v3,hg as g1,aH as fa,mP as w3,mQ as k3,mR as j3,cv as C3,mS as b1,cx as N3,bo as S3,am as pc,mT as E3,mU as _3,mV as I3,mW as Lr,mX as Fr,hM as gc,mY as A3,jc as T3,ed as D3,a9 as mt,mZ as x1,m_ as M3,m$ as O3,n0 as bc,n1 as xc,n2 as R3,n3 as y1,n4 as v1,n5 as pa,j3 as L3,aR as w1,gT as F3,n6 as k1,gH as Je,n7 as Br,n8 as Po,n9 as B3,na as P3,nb as z3,nc as U3,dj as j1,nd as W3,u as C1,ds as $3,ne as V3,dG as G3,nf as q3,da as N1,dD as H3,dy as J3,dx as K3,ng as Y3,ee as X3,e5 as Q3,nh as Z3,ni as ej,nj as tj,fS as nj,nk as S1,nl as E1,nm as _1,nn as oj,cA as yc,no as I1,np as A1,bd as ga,nq as rj,nr as T1,ns as sj,nt as aj,nu as D1,aS as ba,nv as ij,eg as lj,nw as cj,V as dj,nx as M1,ny as uj,nz as hj,nA as mj,nB as Pr,nC as O1,hL as R1,j1 as xa,dC as L1,aD as F1,cQ as vc,hp as wc,nD as fj,hI as B1,nE as pj,nF as P1,fP as gj,fQ as bj,jP as xj,iS as yj,iW as kc,jQ as vj,nG as z1,co as wj,gg as kj,nH as jj,nI as Cj,nJ as Nj,a1 as ya,hs as Sj,nK as Ej,nL as _j,nM as U1,P as Ij,gE as W1,nN as Aj,ak as jc,nO as Tj,hH as Dj,nP as Mj,nQ as Oj,dR as Rj,nR as Lj,nS as Fj,nT as Bj,aP as Pj,nU as va,g1 as zj,dd as Uj,de as Wj,jd as $j,gy as wa,jA as Vj,nV as Gj,bP as qj,nW as Hj,nX as Jj,c2 as Kj,b5 as ka,nY as $1,nZ as V1,b7 as G1,b6 as Yj,gY as Xj,__tla as Qj}from"./index-C7CoaNFb.js";import{B as ja,A as Zj,G as eC,o as tC,s as nC,k as oC,L as q1,a as H1,b as rC,M as sC,Y as aC,e as tn,c as zr,d as iC,S as lC,K as cC,f as dC,i as uC,h as J1,j as hC,l as mC,u as K1,P as Ur,m as Y1,n as fC,p as pC,q as gC,D as zo}from"./links-BpXlz1GG.js";import{V as X1,S as bC,h as Q1,i as Z1,L as eg,j as tg,F as ng,I as Cc,M as xC,l as og,k as yC,f as Uo,E as Ca,m as rg,n as sg,N as ag,o as vC,p as Nc,g as ig,q as wC,s as kC,t as jC,v as CC,w as NC,u as SC,C as EC,R as lg,A as _C,a as IC,c as AC,P as TC,__tla as DC}from"./storage-DRaR04wR.js";import{c as MC}from"./_createAggregator-C5CVY-0t.js";import{_ as cg,a as dg,i as OC,w as RC,L as ug,A as LC,C as hg,b as Sc,c as mg,__tla as FC}from"./loro_wasm_bg-C1ks32Vm.js";let fg,Na,Sa,Ec,Ea,_c,Ic,Ac,Tc,Dc,Mc,Oc,Rc,Lc,_a,Ia,Aa,Wo,pg,Ta,Fc,Bc,Pc,zc,Uc,gg,Wc,Da,BC=Promise.all([(()=>{try{return Qj}catch{}})(),(()=>{try{return DC}catch{}})(),(()=>{try{return FC}catch{}})()]).then(async()=>{var $s,sp;var nt=MC(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]});let We,gt,Ma,$c,Vc,Wr,Oa,$r,Gc,Ra,qc,Hc,Jc,Kc,Yc,Xc,Qc,Zc,ed,td,nd,La,od,rd,sd,ad,id,ld,cd,Fa,dd,Ba,ud,Pa,hd,md,fd,pd,gd,bd,za,xd,yd,Et,_t;Fc=de("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),Uc=de("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),We=de("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),gt=de("chevrons-down",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]),Ma=de("chevrons-up",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]),Na=de("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),$c=de("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Vc=de("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Wr=de("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Oa=de("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Bc=de("clipboard-paste",[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]),$r=de("cloud-download",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]),Gc=de("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),Ra=de("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),qc=de("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),Hc=de("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),Jc=de("file-pen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]),Ec=de("file-plus-2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]),Kc=de("files",[["path",{d:"M15 2a2 2 0 0 1 1.414.586l4 4A2 2 0 0 1 21 8v7a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z",key:"1vo8kb"}],["path",{d:"M15 2v4a2 2 0 0 0 2 2h4",key:"sud9ri"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),Yc=de("folder-tree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]),Xc=de("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),Qc=de("hard-drive-download",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]),Zc=de("hat-glasses",[["path",{d:"M14 18a2 2 0 0 0-4 0",key:"1v8fkw"}],["path",{d:"m19 11-2.11-6.657a2 2 0 0 0-2.752-1.148l-1.276.61A2 2 0 0 1 12 4H8.5a2 2 0 0 0-1.925 1.456L5 11",key:"1fkr7p"}],["path",{d:"M2 11h20",key:"3eubbj"}],["circle",{cx:"17",cy:"18",r:"3",key:"82mm0e"}],["circle",{cx:"7",cy:"18",r:"3",key:"lvkj7j"}]]),ed=de("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]),td=de("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),_c=de("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),nd=de("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),La=de("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),od=de("list",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]),rd=de("map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]),sd=de("memory-stick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]),ad=de("message-circle-question-mark",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),id=de("microchip",[["path",{d:"M18 12h2",key:"quuxs7"}],["path",{d:"M18 16h2",key:"zsn3lv"}],["path",{d:"M18 20h2",key:"9x5y9y"}],["path",{d:"M18 4h2",key:"1luxfb"}],["path",{d:"M18 8h2",key:"nxqzg"}],["path",{d:"M4 12h2",key:"1ltxp0"}],["path",{d:"M4 16h2",key:"8a5zha"}],["path",{d:"M4 20h2",key:"27dk57"}],["path",{d:"M4 4h2",key:"10groj"}],["path",{d:"M4 8h2",key:"18vq6w"}],["path",{d:"M8 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-1.5c-.276 0-.494.227-.562.495a2 2 0 0 1-3.876 0C9.994 2.227 9.776 2 9.5 2z",key:"1681fp"}]]),Ic=de("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),ld=de("octagon-alert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]),cd=de("package-check",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]),Fa=de("package-x",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["path",{d:"m17 13 5 5m-5 0 5-5",key:"im3w4b"}]]),dd=de("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ba=de("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),ud=de("regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]),Tc=de("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),Ta=de("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),Pa=de("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]),Dc=de("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),hd=de("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),md=de("square-code",[["path",{d:"m10 9-3 3 3 3",key:"1oro0q"}],["path",{d:"m14 15 3-3-3-3",key:"bz13h7"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),fd=de("square-dashed-bottom-code",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}]]),pd=de("square-m",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]),gd=de("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Pc=de("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),bd=de("text-cursor-input",[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]]),Mc=de("text-search",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]),za=de("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),xd=de("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),yd=de("whole-word",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]),Rc=de("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),Et=de("zap-off",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),_t=de("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function Vr(t,e){const n=+oo(t)-+oo(e);return n<0?-1:n>0?1:n}function bg(t,e){const n=oo(t,e==null?void 0:e.in);return+(function(o,r){const s=oo(o,r==null?void 0:r.in);return s.setHours(23,59,59,999),s})(n,e)==+(function(o,r){const s=oo(o,r==null?void 0:r.in),a=s.getMonth();return s.setFullYear(s.getFullYear(),a+1,0),s.setHours(23,59,59,999),s})(n,e)}function xg(t,e,n){const[o,r,s]=Cl(n==null?void 0:n.in,t,t,e),a=Vr(r,s),l=Math.abs((function(u,h,m){const[p,b]=Cl(m==null?void 0:m.in,u,h);return 12*(p.getFullYear()-b.getFullYear())+(p.getMonth()-b.getMonth())})(r,s));if(l<1)return 0;r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-a*l);let c=Vr(r,s)===-a;bg(o)&&l===1&&Vr(o,s)===1&&(c=!1);const d=a*(l-+c);return d===0?0:d}function yg(t,e,n){const o=(function(r,s){return+oo(r)-+oo(s)})(t,e)/1e3;return(r=>{const s=(0,Math.trunc)(r);return s===0?0:s})(o)}function vg(t,e){return(function(n,o,r){const s=tk().locale??nk,a=Vr(n,o);if(isNaN(a))throw new RangeError("Invalid time value");const l=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:a}),[c,d]=Cl(r==null?void 0:r.in,...a>0?[o,n]:[n,o]),u=yg(d,c),h=(cp(d)-cp(c))/1e3,m=Math.round((u-h)/60);let p;if(m<2)return m===0?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",m,l);if(m<45)return s.formatDistance("xMinutes",m,l);if(m<90)return s.formatDistance("aboutXHours",1,l);if(m<dp){const b=Math.round(m/60);return s.formatDistance("aboutXHours",b,l)}if(m<2520)return s.formatDistance("xDays",1,l);if(m<Gs){const b=Math.round(m/dp);return s.formatDistance("xDays",b,l)}if(m<2*Gs)return p=Math.round(m/Gs),s.formatDistance("aboutXMonths",p,l);if(p=xg(d,c),p<12){const b=Math.round(m/Gs);return s.formatDistance("xMonths",b,l)}{const b=p%12,x=Math.trunc(p/12);return b<3?s.formatDistance("aboutXYears",x,l):b<9?s.formatDistance("overXYears",x,l):s.formatDistance("almostXYears",x+1,l)}})(t,(function(n){return ek(n,Date.now())})(t),e)}const wg=S.createContext({}),kg=S.forwardRef(function(t,e){[t,e]=sk(t,e,wg);let{toolbarProps:n}=(function(s,a){const{"aria-label":l,"aria-labelledby":c,orientation:d="horizontal"}=s;let[u,h]=S.useState(!1);ok(()=>{var f;h(!(!a.current||!(!((f=a.current.parentElement)===null||f===void 0)&&f.closest('[role="toolbar"]'))))});const{direction:m}=up(),p=m==="rtl"&&d==="horizontal";let b=rk(a);const x=S.useRef(null);return{toolbarProps:{...hp(s,{labelable:!0}),role:u?"group":"toolbar","aria-orientation":d,"aria-label":l,"aria-labelledby":l==null?c:void 0,onKeyDownCapture:u?void 0:f=>{if(f.currentTarget.contains(f.target)){if(d==="horizontal"&&f.key==="ArrowRight"||d==="vertical"&&f.key==="ArrowDown")p?b.focusPrevious():b.focusNext();else{if(!(d==="horizontal"&&f.key==="ArrowLeft"||d==="vertical"&&f.key==="ArrowUp"))return f.key==="Tab"?(f.stopPropagation(),x.current=document.activeElement,void(f.shiftKey?b.focusFirst():b.focusLast())):void 0;p?b.focusNext():b.focusPrevious()}f.stopPropagation(),f.preventDefault()}},onFocusCapture:u?void 0:f=>{var g,y;x.current&&!f.currentTarget.contains(f.relatedTarget)&&(!((g=a.current)===null||g===void 0)&&g.contains(f.target))&&((y=x.current)===null||y===void 0||y.focus(),x.current=null)},onBlurCapture:u?void 0:f=>{f.currentTarget.contains(f.relatedTarget)||x.current||(x.current=f.target)}}}})(t,e),o=ak({...t,values:{orientation:t.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),r=hp(t,{global:!0});return delete r.id,me.createElement("div",{...Nl(r,o,n),ref:e,slot:t.slot||void 0,"data-orientation":t.orientation||"horizontal"},o.children)}),Gr={showInput:"Mod-l",acceptEdit:"Mod-y",rejectEdit:"Mod-u"},$o=ro.define({combine:t=>qs(t,{onError:console.error,inputDebounceTime:300,keymaps:Gr},{onError:(e,n)=>e&&n,inputDebounceTime:(e,n)=>e&&n,keymaps:(e,n)=>e&&n})}),qn=tt.define(),Hn=Dt.define({create:()=>({show:!1,lineFrom:0,lineTo:0}),update(t,e){for(const n of e.effects)if(n.is(qn))return n.value;return t}}),Vo=tt.define(),Go=tt.define(),vd=Dt.define({create:()=>({shouldFocus:!1,inputValue:""}),update(t,e){let n=t;for(const o of e.effects)o.is(Vo)&&(n={...n,inputValue:o.value}),o.is(Go)&&(n={...n,shouldFocus:o.value});return n}}),qr=tt.define(),qo=Dt.define({create:()=>null,update(t,e){for(const n of e.effects)if(n.is(qr))return n.value;return t}}),uo=tt.define(),wd=Dt.define({create:()=>!1,update(t,e){for(const n of e.effects)if(n.is(uo))return n.value;return t}}),kd=t=>{const{state:e}=t,n=e.selection.main;if(n.empty)return!1;const o=e.doc,r=o.lineAt(n.from),s=o.lineAt(n.to);if(e.sliceDoc(r.from,s.to).trim().length<1)return!1;const a=Math.max(1,Math.min(r.number,o.lines)),l=Math.max(1,Math.min(s.number,o.lines));return t.dispatch({effects:[qn.of({show:!0,lineFrom:a,lineTo:l}),Go.of(!0),Vo.of("")],selection:Yt.cursor(r.from)}),!0},jd=t=>!!t.state.field(qo)&&(t.dispatch({effects:[qr.of(null),qn.of({show:!1,lineFrom:0,lineTo:0}),Go.of(!1),Vo.of(""),uo.of(!1)]}),!0),Cd=t=>{const e=t.state.field(qo);return!!e&&(t.dispatch({changes:{from:e.from,to:e.to,insert:e.oldCode},effects:[qr.of(null),qn.of({show:!1,lineFrom:0,lineTo:0}),Go.of(!1),Vo.of(""),uo.of(!1)]}),!0)},jg="\u2318",Cg="\u229E Win",Ng="Ctrl";function Ua(t){return t.replace("Mod",navigator.platform.startsWith("Mac")?jg:navigator.platform.startsWith("Win")?Cg:Ng).replace("-"," ").toUpperCase()}function bt(t,e){const n=document.createElement(t);return n.className=e,n}const Hr=Dt.define({create:()=>({suggestion:null}),update(t,e){const n=e.effects.find(o=>o.is(Jr));return e.docChanged||n||e.selection?n&&e.state.doc===n.value.doc?{suggestion:n.value.text}:{suggestion:null}:t}}),Jr=tt.define();class Sg extends So{constructor(n){super();B(this,"suggestion");this.suggestion=n}toDOM(){const n=document.createElement("span");return n.style.opacity="0.4",n.className="cm-inline-suggestion",n.textContent=this.suggestion,n.setAttribute("role","suggestion"),n.setAttribute("aria-label",`Suggestion: ${this.suggestion}`),n}get lineBreaks(){return this.suggestion.split(`
3
- `).length-1}}class Eg{constructor(e){B(this,"cache",new Map);B(this,"timeout");this.timeout=e}get(e){const n=this.cache.get(e);return n?Date.now()-n.timestamp>this.timeout?(this.cache.delete(e),null):n.result:null}set(e,n){this.cache.set(e,{result:n,timestamp:Date.now()})}}const _g=(t,e)=>Wt.fromClass(class{constructor(){B(this,"abortController",null);B(this,"cache");this.cache=new Eg(e.cacheTimeout??1e3)}async update(n){var a,l,c,d,u;if(!n.docChanged||((l=(a=e.events)==null?void 0:a.beforeSuggestionFetch)==null?void 0:l.call(a,n.view))===!1)return;(c=this.abortController)==null||c.abort(),this.abortController=new AbortController;const o=n.state.doc,r=o.toString(),s=this.cache.get(r);if(s)n.view.dispatch({effects:Jr.of({text:s,doc:o})});else try{const h=await t(n.state,this.abortController.signal,n.view);if(this.abortController.signal.aborted||((u=(d=e.events)==null?void 0:d.shouldShowSuggestion)==null?void 0:u.call(d,n.view,h))===!1)return;this.cache.set(r,h),n.view.dispatch({effects:Jr.of({text:h,doc:o})})}catch(h){h instanceof Error&&h.name!=="AbortError"&&console.error("Suggestion fetch error:",h)}}destroy(){var n;(n=this.abortController)==null||n.abort()}}),Ig=Wt.fromClass(class{constructor(){B(this,"decorations");this.decorations=Te.none}update(t){var n;const e=(n=t.state.field(Hr))==null?void 0:n.suggestion;this.decorations=e?(function(o,r){const s=o.state.selection.main.head,a=[],l=Te.widget({widget:new Sg(r),side:1});return a.push(l.range(s)),Te.set(a)})(t.view,e):Te.none}},{decorations:t=>t.decorations}),Nd=t=>{var o,r,s;const e=(o=t.state.field(Hr))==null?void 0:o.suggestion;if(!e)return!1;const n=t.state.facet(Wa);return t.dispatch({effects:Jr.of({text:null,doc:t.state.doc})}),(s=(r=n.events)==null?void 0:r.onSuggestionRejected)==null||s.call(r,t,e),!0},Ag=$t.of([{key:"Tab",run:t=>{var l,c,d;const e=(l=t.state.field(Hr))==null?void 0:l.suggestion;if(!e)return!1;const n=t.state.facet(Wa);var o,r,s,a;return t.dispatch({...(o=t.state,r=e,s=t.state.selection.main.head,a=t.state.selection.main.head,{...o.changeByRange(u=>{if(u===o.selection.main)return{changes:{from:s,to:a,insert:r},range:Yt.cursor(s+r.length)};const h=a-s;return!u.empty||h&&o.sliceDoc(u.from-h,u.from)!==o.sliceDoc(s,a)?{range:u}:{changes:{from:u.from-h,to:u.from,insert:r},range:Yt.cursor(u.from-h+r.length)}}),userEvent:"input.complete"})}),(d=(c=n.events)==null?void 0:c.onSuggestionAccepted)==null||d.call(c,t,e),!0}},{key:"Escape",run:Nd}]),Wa=ro.define({combine:t=>t.at(-1)});function Sd(t){const{delay:e=500,includeKeymap:n=!0}=t,o=(function(r,s,a){let l=()=>{};return(...c)=>(l(),new Promise((d,u)=>{const h=setTimeout(()=>d(r(...c)),s);l=()=>{clearTimeout(h),a!==void 0&&u(a)}}))})(t.fetchFn,e);return[Hr,Wa.of(t),_g(o,t),Ig,n?Ag:[]]}const Tg=Se.baseTheme({".cm-ai-input-container":{display:"flex",flexDirection:"column",gap:"4px",width:"min(calc(100% + 7px), 500px)",padding:"5px 5px",margin:"0 -6px",backgroundColor:"light-dark(rgb(241, 243, 245), rgb(40, 40, 40))"},".cm-ai-input":{display:"block",width:"100%",padding:"3px 8px",border:"2px solid rgb(51, 154, 240)",borderRadius:"5px",fontSize:"12px"},".cm-ai-help-info-button":{fontSize:"10px",paddingLeft:"10px",height:"18px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",display:"block",marginRight:"auto"},".cm-ai-help-info-button:hover":{color:"light-dark(rgb(89, 97, 105), rgb(190, 190, 190))"},".cm-ai-generate-button":{background:"#0E639C",border:"none",padding:"2px 6px",color:"#ffffff",cursor:"pointer",font:"inherit",borderRadius:"4px","&:hover":{backgroundColor:"#1177bb"}},".cm-line.cm-ai-selection, .cm-line.cm-ai-selection.cm-active-line":{backgroundColor:"light-dark(color-mix(in srgb, rgb(223, 227, 232) 50%, transparent), color-mix(in srgb, rgb(50, 50, 50) 50%, transparent)) !important"},".cm-line:has(.cm-new-code-line)":{backgroundColor:"light-dark(color-mix(in srgb, rgb(183, 235, 143) 50%, transparent), color-mix(in srgb, rgb(40, 100, 40) 50%, transparent)) !important"},".cm-old-code-container":{backgroundColor:"light-dark(rgb(255, 205, 205), rgb(100, 40, 40))",position:"relative",display:"flex",paddingTop:"0",width:"100%",alignItems:"center"},".cm-code-button":{position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"16px"},".cm-floating-buttons":{fontFamily:"sans-serif",position:"absolute",top:"-20px",left:"5px",display:"flex"},".cm-floating-button":{fontFamily:"sans-serif",padding:"2px 5px",fontSize:"10px",cursor:"pointer",fontWeight:"700"},".cm-floating-accept":{backgroundColor:"light-dark(rgb(55, 125, 34), rgb(40, 80, 25))",borderTopLeftRadius:"5px",borderBottomLeftRadius:"5px",color:"white",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".cm-floating-reject":{backgroundColor:"light-dark(rgb(220, 53, 69), rgb(180, 40, 50))",color:"white",borderTopRightRadius:"5px",borderBottomRightRadius:"5px",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".hotkey":{display:"inline-block",padding:"0 4px",borderRadius:"3px",backgroundColor:"rgba(255, 255, 255, 0.1)",fontSize:"90%"},".cm-ai-loading-indicator":{fontStyle:"italic",fontSize:"10px",paddingLeft:"12px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",opacity:"0",transition:"opacity 0.3s ease-in-out","&::after":{content:'""',display:"inline-block",animation:"ellipsis-pulse 1.5s steps(4, end) infinite"},"&:not(:empty)":{opacity:"1"}},".cm-ai-input:disabled":{opacity:"0.5"},"@keyframes ellipsis-pulse":{"0%":{content:"'.'"},"25%":{content:"'..'"},"50%":{content:"'...'"},"75%":{content:"''"}},".cm-ai-loading-container":{display:"flex",alignItems:"center",padding:"0 8px"},".cm-ai-cancel-button":{padding:"2px 8px",fontSize:"10px",borderRadius:"4px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",cursor:"pointer","&:hover":{background:"light-dark(rgb(223, 227, 232), rgb(50, 50, 50))"}},".hidden":{display:"none"}});function Dg(t){var r,s;const e=t.state.facet($o),n={...Gr,...e.keymaps},o=bt("div","cm-ai-tooltip").appendChild(bt("div","cm-ai-tooltip-button"));return o.innerHTML=`<span>Edit <span class="hotkey">${Ua(n.showInput)}</span></span>`,(r=o.querySelector("span"))==null||r.addEventListener("mousedown",a=>{a.stopPropagation(),a.button===0&&a.preventDefault()}),(s=o.querySelector("span"))==null||s.addEventListener("click",a=>{a.preventDefault(),kd(t)}),o}const $a=ro.define({combine:t=>qs(t,{render:Dg,hideOnBlur:!1})}),Mg=Wt.fromClass((sp=class{constructor(t){B(this,"view");B(this,"suppress");B(this,"dom");B(this,"mousedown",()=>{this.suppress=!0});B(this,"mouseup",()=>{this.suppress=!1,this.display(this.view)});B(this,"scroll",()=>{this.display(this.view)});B(this,"windowScroll",()=>{this.display(this.view)});lp(this,$s,t=>{var n;const e=t.state.selection.ranges.find(o=>!o.empty);if(e&&!this.suppress){const o=t.coordsAtPos(e.from);if(!o)return;const r=t.dom.getBoundingClientRect(),s=(n=t.dom.parentElement)==null?void 0:n.getBoundingClientRect(),a=o.top>=r.top&&o.top<=r.bottom&&o.left>=r.left&&o.left<=r.right,l=!s||o.top>=s.top&&o.top<=s.bottom&&o.left>=s.left&&o.left<=s.right;if(!a||!l)return this.dom.style.display="none",void this.dom.setAttribute("aria-hidden","true");this.dom.style.display="flex",this.dom.setAttribute("aria-hidden","false");const c=this.dom.getBoundingClientRect(),d=r.width-c.width,u=Math.min(o.left,d);let h=o.top-c.height;h=s?Math.max(s.y,h):h,this.dom.style.left=`${u}px`,this.dom.style.top=`${h}px`,requestAnimationFrame(()=>{this.dom&&this.dom.setAttribute("aria-hidden","false")})}else this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true")});this.view=t;const e=t.state.facet($a);this.suppress=!1,document.addEventListener("mousedown",this.mousedown),document.addEventListener("mouseup",this.mouseup),t.scrollDOM.addEventListener("scroll",this.scroll),window.addEventListener("scroll",this.windowScroll,!0);const n=e.render(t);t.dom.appendChild(n),this.dom=n}update(t){this.display(t.view)}docViewUpdate(t){this.display(t)}display(t){if(t.state.field(Hn).show)return void(this.dom.style.display="none");if(t.state.facet($a).hideOnBlur&&!t.hasFocus)return this.dom.style.display="none",void this.dom.setAttribute("aria-hidden","true");t.requestMeasure({read:ip(this,$s)})}destroy(){document.removeEventListener("mousedown",this.mousedown),document.removeEventListener("mouseup",this.mouseup),this.view.scrollDOM.removeEventListener("scroll",this.scroll),window.removeEventListener("scroll",this.windowScroll,!0),this.dom.remove()}},$s=new WeakMap,sp)),Og=Se.baseTheme({".cm-ai-tooltip-button":{userSelect:"none",fontFamily:"system-ui, -apple-system, sans-serif",position:"fixed",display:"flex",boxSizing:"border-box",padding:"2px 6px",borderRadius:"4px",fontSize:"12px",backgroundColor:"#0E639C",color:"#ffffff",border:"1px solid transparent",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",zIndex:"999",transition:"opacity 0.5s","&[aria-hidden='true']":{opacity:"0"},"&[aria-hidden='false']":{opacity:"1"},"& > span":{pointerEvents:"auto",cursor:"pointer",display:"inline-block",padding:"2px"},"&:hover":{backgroundColor:"#1177bb"}}});class Rg extends So{constructor(n){super();B(this,"oldCode");this.oldCode=n}toDOM(n){const o=bt("div","cm-old-code-container");o.setAttribute("role","region"),o.setAttribute("aria-label","Previous code version");const r=bt("div","cm-old-code cm-line");r.textContent=this.oldCode;const s=bt("div","cm-floating-buttons"),a=n.state.facet($o),l={...Gr,...a.keymaps},c=bt("button","cm-floating-button cm-floating-accept");c.innerHTML=`<span class="hotkey">${Ua(l.acceptEdit)}</span> Accept`,c.setAttribute("aria-label","Accept changes"),c.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),n.focus(),jd(n)});const d=bt("button","cm-floating-button cm-floating-reject");return d.innerHTML=`<span class="hotkey">${Ua(l.rejectEdit)}</span> Reject`,d.setAttribute("aria-label","Reject changes"),d.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),n.focus(),Cd(n)}),s.append(c,d),o.append(r,s),o}updateDOM(n,o){return!0}}class Lg extends So{constructor(n){super();B(this,"complete");B(this,"abortController",null);B(this,"dom",null);B(this,"input",null);B(this,"loadingContainer",null);B(this,"helpInfo",null);B(this,"inputContainer",null);B(this,"form",null);B(this,"view",null);B(this,"onKeyDown",async n=>{n.key!=="Enter"||n.shiftKey?n.key==="Escape"&&this.onCancel():(n.preventDefault(),await this.handleSubmit())});B(this,"onCancel",()=>{this.cleanup();const n=this.view;n&&(n.dispatch({effects:[qn.of({show:!1,lineFrom:0,lineTo:0}),uo.of(!1)]}),n.focus())});B(this,"handleSubmit",async n=>{var x;const o=this.view;if(!o)return;const r=o.state.facet($o);n==null||n.stopPropagation();const s=o.state.field(Hn),{input:a}=this;if(!a)return;const l=a.value.trim();if(!s.show||!l)return;const c=o.state.doc.line(s.lineFrom),d=o.state.doc.line(s.lineTo),u=c.from,h=d.to,m=o.state.sliceDoc(u,h),p=o.state.sliceDoc(0,u),b=o.state.sliceDoc(h);this.abortController=new AbortController,o.dispatch({effects:uo.of(!0)}),this.toggleLoading(!0);try{const f=await this.complete({prompt:l,selection:m,codeBefore:p,codeAfter:b,editorView:o,signal:this.abortController.signal});if(!o.state.field(Hn).show)return;if(!f||typeof f!="string")throw new Error("Invalid completion result");o.dispatch({changes:{from:u,to:h,insert:f},effects:[qn.of({show:!1,lineFrom:0,lineTo:0}),qr.of({from:u,to:u+f.length,oldCode:m,newCode:f}),uo.of(!1)]})}catch(f){if(f instanceof DOMException&&f.name==="AbortError")return;(x=r.onError)==null||x.call(r,f)}finally{this.cleanup(),this.toggleLoading(!1),o.focus()}});this.complete=n}toDOM(n){if(this.dom)return this.dom;this.view=n;const o=n.state.field(vd),r=n.state.field(wd),s=bt("div","cm-ai-input-container");this.inputContainer=s,this.dom=s;const a=bt("form","cm-ai-input-form");this.form=a,a.setAttribute("role","search"),a.setAttribute("aria-label","AI editing instructions"),a.addEventListener("submit",f=>f.preventDefault());const l=bt("input","cm-ai-input");this.input=l,a.append(l),l.placeholder="Editing instructions...",l.setAttribute("aria-label","AI editing instructions"),l.setAttribute("autocomplete","off"),l.setAttribute("spellcheck","true"),l.value=o.inputValue;const c=bt("div","cm-ai-loading-container");this.loadingContainer=c;const d=bt("div","cm-ai-loading-indicator");d.setAttribute("role","status"),d.setAttribute("aria-live","polite"),d.textContent="Generating";const u=bt("button","cm-ai-cancel-button");u.textContent="Cancel",u.setAttribute("aria-label","Cancel code generation"),u.addEventListener("click",this.onCancel),c.append(u,d);const h=bt("div","cm-ai-help-info");this.helpInfo=h;const m=h.appendChild(document.createElement("button"));m.className="cm-ai-help-info-button",m.textContent="Esc to close",m.addEventListener("click",this.onCancel);const p=bt("button","cm-ai-generate-button");function b(f){h.replaceChildren(f?p:m)}p.textContent="\u23CE Generate",p.setAttribute("aria-label","Generate code"),p.addEventListener("click",this.handleSubmit),this.toggleLoading(r),o.shouldFocus&&requestAnimationFrame(()=>{l.value=o.inputValue,l.focus(),n.dispatch({effects:Go.of(!1)})}),b(l.value),l.addEventListener("input",function(){n.dispatch({effects:Vo.of(l.value)});const f=l.value.trim();f!==x&&(x=f,b(f))}),l.addEventListener("keydown",this.onKeyDown);let x="";return s}toggleLoading(n){var o;this.inputContainer&&this.form&&this.loadingContainer&&this.helpInfo&&((o=this.inputContainer)==null||o.replaceChildren(this.form,n?this.loadingContainer:this.helpInfo))}updateDOM(n,o){return this.dom=n,this.input=n.querySelector(".cm-ai-input"),!0}cleanup(){var n,o,r;(n=this.abortController)==null||n.abort(),this.abortController=null,(o=this.dom)==null||o.remove(),(r=this.input)==null||r.remove(),this.dom=null,this.input=null}destroy(){this.cleanup()}}function Fg(t){if(!t.prompt)throw new Error("prompt function is required");const e={...Gr,...t.keymaps};return[$o.of(t),Hn,vd,qo,wd,[Mg,Og],Tg,$t.of([{key:e.showInput,run:kd}]),Sn.highest([$t.of([{key:e.acceptEdit,run:jd},{key:e.rejectEdit,run:Cd}])]),Bg,Pg,zg,Ug]}const Bg=Se.updateListener.of(t=>{const e=t.state.field(Hn);if(!e.show||!t.docChanged)return;let{lineFrom:n,lineTo:o}=e,r=!1;t.changes.iterChanges((s,a,l,c)=>{const d=t.state.doc.lineAt(s).number;if(d<n){const u=t.state.doc.lineAt(c).number-t.state.doc.lineAt(l).number;n+=u,o+=u,r=!0}else if(d<=o){const u=t.state.doc.lineAt(c).number-t.state.doc.lineAt(l).number;o+=u,r=!0}}),r&&t.view.dispatch({effects:[qn.of({show:!0,lineFrom:n,lineTo:o})]})}),Pg=Se.decorations.of(t=>{const e=t.state.field(qo);return e?Te.set([Te.mark({class:"cm-new-code-line"}).range(e.from,e.to)]):Te.none}),zg=Se.decorations.compute([Hn],t=>{const e=t.field(Hn),n=t.facet($o),o=[];if(e.show){const r=e.lineFrom,s=e.lineTo;for(let a=r;a<=s;a++){const l=t.doc.line(a).from;o.push(Te.line({class:"cm-ai-selection"}).range(l)),a===r&&o.push(Te.widget({widget:new Lg(n.prompt),side:-1}).range(l))}}return Te.set(o)}),Ug=Dt.define({create:t=>Te.none,update(t,e){const n=e.state.field(qo);return n?Te.set([Te.widget({widget:new Rg(n.oldCode),block:!0}).range(n.from)]):Te.none},provide:t=>Se.decorations.from(t)}),Kr="https://static.marimo.app",Wg=t=>{const e=P.c(25),{onClose:n}=t,[o,r]=S.useState(""),{exportAsHTML:s}=qe(),a=`${o}-${Math.random().toString(36).slice(2,6)}`,l=`${Kr}/static/${a}`;let c,d,u,h,m,p,b,x,f,g,y;return e[0]!==s||e[1]!==n||e[2]!==a?(c=async w=>{w.preventDefault(),n();const j=await s({download:!1,includeCode:!0,files:X1.INSTANCE.filenames()}),C=ze({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Kr}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:j,path:a})}).catch(()=>{C.dismiss(),ze({title:"Error uploading static page",description:i.jsxs("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",i.jsx("a",{href:Xt.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),C.dismiss(),ze({title:"Static page uploaded!",description:i.jsxs("div",{children:["The URL has been copied to your clipboard.",i.jsx("br",{}),"You can share it with anyone."]})})},e[0]=s,e[1]=n,e[2]=a,e[3]=c):c=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(so,{children:"Share static notebook"}),e[4]=d):d=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsxs(yr,{children:[d,i.jsxs(vr,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",i.jsx("a",{href:Kr,target:"_blank",children:Kr}),"."]})]}),e[5]=u):u=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(h=w=>{const j=w.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,"");r(j)},e[6]=h):h=e[6],e[7]!==o?(m=i.jsx(ao,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:h,required:!0,autoComplete:"off"}),e[7]=o,e[8]=m):m=e[8],e[9]!==l?(p=i.jsxs("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx($g,{text:l}),i.jsx("span",{className:"text-primary",children:l})]})]}),e[9]=l,e[10]=p):p=e[10],e[11]!==m||e[12]!==p?(b=i.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[m,p]}),e[11]=m,e[12]=p,e[13]=b):b=e[13],e[14]!==n?(x=i.jsx(ye,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),e[14]=n,e[15]=x):x=e[15],e[16]!==l?(f=i.jsx(ye,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await Eo(l)},children:"Create"}),e[16]=l,e[17]=f):f=e[17],e[18]!==x||e[19]!==f?(g=i.jsxs(Hs,{children:[x,f]}),e[18]=x,e[19]=f,e[20]=g):g=e[20],e[21]!==c||e[22]!==g||e[23]!==b?(y=i.jsx(io,{className:"w-fit",children:i.jsxs("form",{onSubmit:c,children:[u,b,g]})}),e[21]=c,e[22]=g,e[23]=b,e[24]=y):y=e[24],y},$g=t=>{const e=P.c(8),[n,o]=me.useState(!1);let r;e[0]!==t.text?(r=Fn.stopPropagation(async d=>{d.preventDefault(),await Eo(t.text),o(!0),setTimeout(()=>o(!1),2e3)}),e[0]=t.text,e[1]=r):r=e[1];const s=r;let a,l,c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(mp,{size:14,strokeWidth:1.5}),e[2]=a):a=e[2],e[3]!==s?(l=i.jsx(ye,{"data-testid":"copy-static-notebook-url-button",onClick:s,size:"xs",variant:"secondary",children:a}),e[3]=s,e[4]=l):l=e[4],e[5]!==n||e[6]!==l?(c=i.jsx(pe,{content:"Copied!",open:n,children:l}),e[5]=n,e[6]=l,e[7]=c):c=e[7],c};function Ed(){const t=P.c(2),e=Ct(Sl);let n;return t[0]!==e?(n=()=>{const o=document.getElementsByClassName("output-area"),r=window.innerHeight||document.documentElement.clientHeight;let s=null;for(const a of Array.from(o)){const l=a.getBoundingClientRect();if(l.top>=0&&l.top<=r||l.bottom>=0&&l.bottom<=r){s=Js.parse(a.parentNode.id);break}}e(a=>({mode:ik(a.mode),cellAnchor:s})),requestAnimationFrame(()=>{var a;s!==null&&((a=document.getElementById(Js.create(s)))==null||a.scrollIntoView())})},t[0]=e,t[1]=n):n=t[1],n}function Va(t){const e=P.c(3),n=Ho();let o;return e[0]!==t||e[1]!==n?(o=()=>{t!==void 0&&n([t])},e[0]=t,e[1]=n,e[2]=o):o=e[2],Ce(o)}function _d(){const t=P.c(2),e=Ho();let n;return t[0]!==e?(n=()=>e(fp(Mt())),t[0]=e,t[1]=n):n=t[1],Ce(n)}function Ho(){const t=P.c(3),{prepareForRun:e}=Ye(),{sendRun:n}=qe();let o;return t[0]!==e||t[1]!==n?(o=async r=>{var c,d;if(r.length===0)return;const{cellHandles:s,cellData:a}=Mt(),l=[];for(const u of r){const h=s[u],m=(c=h==null?void 0:h.current)==null?void 0:c.editorView;let p;m?(pp(m)!=="markdown"&&El(m),p=gp(m)):p=((d=a[u])==null?void 0:d.code)||"",l.push(p),e({cellId:u})}await n({cellIds:r,codes:l}).catch(Vg)},t[0]=e,t[1]=n,t[2]=o):o=t[2],Ce(o)}function Vg(t){He.error(t)}let Yr;Yr=[{type:"files",Icon:Yc,tooltip:"View files",position:"sidebar"},{type:"variables",Icon:bp,tooltip:"Explore variables",position:"sidebar"},{type:"datasources",Icon:_o,tooltip:"Explore data sources",position:"sidebar"},{type:"dependencies",Icon:Ic,tooltip:"Explore dependencies",position:"sidebar"},{type:"packages",Icon:ja,tooltip:"Manage packages",position:"sidebar"},{type:"outline",Icon:Dc,tooltip:"View outline",position:"sidebar"},{type:"chat",Icon:ck,tooltip:"Chat with AI",position:"sidebar"},{type:"agents",Icon:Zc,tooltip:"Agents",position:"sidebar",hidden:!Ys("external_agents")},{type:"documentation",Icon:Mc,tooltip:"View live docs",position:"sidebar"},{type:"logs",Icon:xp,tooltip:"Notebook logs",position:"sidebar"},{type:"tracing",Icon:Zj,tooltip:"Tracing",position:"sidebar"},{type:"snippets",Icon:fd,tooltip:"Snippets",position:"sidebar"},{type:"secrets",Icon:td,tooltip:"Secrets",hidden:Qt(),position:"sidebar"},{type:"scratchpad",Icon:dk,tooltip:"Scratchpad",position:"sidebar"},{type:"errors",Icon:Ks,tooltip:"View errors",position:"footer"}],_a=Bt(!1);function Jn(){return Me().optional().describe(fe.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function Id(){return Me().optional().describe(fe.of({label:"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"}))}function Xr(){return Me().optional().describe(fe.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function Ad(){return Me().optional().describe(fe.of({label:"URI",optionRegex:".*uri.*"}))}function Kn(){return Me().nonempty().describe(fe.of({label:"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function nn(){return Me().describe(fe.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function Yn(){return Me().nonempty().describe(fe.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function Xn(t){const e=uk.string().describe(fe.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(n=>n>=0&&n<=65535,{message:"Port must be between 0 and 65535"});return t!==void 0?e.default(t.toString()):e}function Td(){return Io().default(!1).describe(fe.of({label:"Read Only"}))}const Dd=Be({type:$e("postgres"),host:Kn(),port:Xn(5432).optional(),database:nn(),username:Yn(),password:Jn(),ssl:Io().default(!1).describe(fe.of({label:"Use SSL"}))}).describe(fe.of({direction:"two-columns"})),Md=Be({type:$e("mysql"),host:Kn(),port:Xn(3306),database:nn(),username:Yn(),password:Jn(),ssl:Io().default(!1).describe(fe.of({label:"Use SSL"}))}).describe(fe.of({direction:"two-columns"})),Od=Be({type:$e("sqlite"),database:nn().describe(fe.of({label:"Database Path"}))}).describe(fe.of({direction:"two-columns"})),Rd=Be({type:$e("duckdb"),database:nn().describe(fe.of({label:"Database Path"})),read_only:Td()}).describe(fe.of({direction:"two-columns"})),Ld=Be({type:$e("motherduck"),database:nn().default("my_db").describe(fe.of({label:"Database Name"})),token:Id()}).describe(fe.of({direction:"two-columns"})),Fd=Be({type:$e("snowflake"),account:Me().nonempty().describe(fe.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:Me().optional().describe(fe.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:nn(),schema:Me().optional().describe(fe.of({label:"Schema",optionRegex:".*snowflake.*"})),username:Yn(),password:Jn(),role:Me().optional().describe(fe.of({label:"Role"}))}).describe(fe.of({direction:"two-columns"})),Bd=Be({type:$e("bigquery"),project:Me().nonempty().describe(fe.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:Me().nonempty().describe(fe.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:Me().describe(fe.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(fe.of({direction:"two-columns"})),Pd=Be({type:$e("clickhouse_connect"),host:Kn(),port:Xn(8123).optional(),username:Yn(),password:Jn(),secure:Io().default(!1).describe(fe.of({label:"Use HTTPs"}))}).describe(fe.of({direction:"two-columns"})),zd=Be({type:$e("timeplus"),host:Kn().default("localhost"),port:Xn(8123).optional(),username:Yn().default("default"),password:Jn().default("")}).describe(fe.of({direction:"two-columns"})),Ud=Be({type:$e("chdb"),database:nn().describe(fe.of({label:"Database Path"})),read_only:Td()}).describe(fe.of({direction:"two-columns"})),Wd=Be({type:$e("trino"),host:Kn(),port:Xn(8080),database:nn(),schema:Me().describe(fe.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"})).optional(),username:Yn(),password:Jn(),async_support:Io().default(!1).describe(fe.of({label:"Async Support"}))}).describe(fe.of({direction:"two-columns"})),$d=Be({type:$e("iceberg"),name:Me().describe(fe.of({label:"Catalog Name"})),catalog:_l("type",[Be({type:$e("REST"),warehouse:Xr(),uri:Me().optional().describe(fe.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:Id()}),Be({type:$e("SQL"),warehouse:Xr(),uri:Me().optional().describe(fe.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),Be({type:$e("Hive"),warehouse:Xr(),uri:Ad()}),Be({type:$e("Glue"),warehouse:Xr(),uri:Ad()}),Be({type:$e("DynamoDB"),"dynamodb.profile-name":Me().optional().describe(fe.of({label:"Profile Name"})),"dynamodb.region":Me().optional().describe(fe.of({label:"Region"})),"dynamodb.access-key-id":Me().optional().describe(fe.of({label:"Access Key ID"})),"dynamodb.secret-access-key":Me().optional().describe(fe.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":Me().optional().describe(fe.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST"}).describe(fe.of({special:"tabs"}))}),Vd=Be({type:$e("datafusion"),sessionContext:Io().optional().describe(fe.of({label:"Use Session Context"}))}),Gd=Be({type:$e("pyspark"),host:Kn().optional(),port:Xn().optional()}),qd=Be({type:$e("redshift"),host:Kn(),port:Xn(5439),connectionType:_l("type",[Be({type:$e("IAM credentials"),region:Me().describe(fe.of({label:"Region"})),aws_access_key_id:Me().nonempty().describe(fe.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:Me().nonempty().describe(fe.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:Me().optional().describe(fe.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),Be({type:$e("DB credentials"),user:Yn(),password:Jn()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:nn()}).describe(fe.of({direction:"two-columns"})),Gg=_l("type",[Dd,Md,Od,Rd,Ld,Fd,Bd,Pd,zd,Ud,Wd,$d,Vd,Gd,qd]),Ga="env:";function Qr(t){return typeof t=="string"&&t.startsWith(Ga)}function qa(t){return`${Ga}${t}`}const Hd={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift"};class xt{constructor(e,n,o){this.connection=void 0,this.orm=void 0,this.secrets=void 0,this.connection=e,this.orm=n,this.secrets=o}get imports(){const e=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":e.add("import sqlalchemy");break;case"sqlmodel":e.add("import sqlmodel");break;case"duckdb":e.add("import duckdb")}return e}}class qg{constructor(){this.secrets={}}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(e,n,o){if(e=`_${e}`,Qr(n)){const r=n.replace(Ga,""),s=o?`os.environ.get("${r}", "${o}")`:`os.environ.get("${r}")`;return this.secrets[e]=s,e}if(o!=null){const r=`os.environ.get("${n}", "${o}")`;return this.secrets[e]=r,e}return typeof n=="number"||typeof n=="number"?`${n}`:typeof n=="boolean"?ho(n):n?`"${n}"`:""}printInFString(e,n,o){if(n===void 0)return"";if(typeof n=="number")return`${n}`;if(typeof n=="boolean")return ho(n);const r=this.print(e,n,o);return r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):`{${r}}`}printPassword(e,n,o){const r=o?this.printInFString.bind(this):this.print.bind(this);return Qr(e)?r("password",e):r("password",n,e)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([e,n])=>`${e} = ${n}`).join(`
4
- `)}}class Hg extends xt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.ssl?", connect_args={'sslmode': 'require'}":"",n=this.secrets.printPassword(this.connection.password,"POSTGRES_PASSWORD",!0),o=this.secrets.printInFString("username",this.connection.username),r=this.secrets.printInFString("host",this.connection.host),s=this.secrets.printInFString("port",this.connection.port),a=this.secrets.printInFString("database",this.connection.database);return Ve(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./terminal-CPV44BXz.js","./index-C1SHFMCp.js","./index-C0iXCvyY.css","./state-CDooX-dk.js","./links-Dd1icsEk.js","./links-5Ym3a_OV.css","./storage-b1QCapTq.js","./index-C71cdkH-.js","./index-qbTLKWyG.js","./index-Bfy-I_lW.js","./index-Bh98Tp-z.js","./index-BtQtesaI.js","./index-C6DWtSls.js","./index-B_KyDZ94.js","./index-DcGIOAQi.js","./index-BDYVSSzB.js","./index-Cb6duXQm.js","./index-PJfa9qXY.js","./index-CT_FTqvK.js","./index-BhroIwBL.js","./apl-CXdQSnD-.js","./asciiarmor-D5V0T9Cu.js","./asn1-DWPaVWf6.js","./brainfuck-CtZaYBKt.js","./cobol-stawOqaz.js","./clike-BgBwzOhw.js","./clojure-DiuoqK-z.js","./css-ZjFoif2m.js","./cmake-DXn5xaP-.js","./coffeescript-BTDxI-eT.js","./commonlisp-vq6DHwts.js","./cypher-gJDei3ni.js","./python-DD-Q2bae.js","./crystal-CRzZ78HM.js","./d-BShv7fp-.js","./diff-UJJ5BM9S.js","./dtd-DI9Herc-.js","./dylan-DkEP81N9.js","./ecl-DPFc0Uaf.js","./eiffel-DR5c0IrL.js","./elm-DompmV0j.js","./erlang-BuqgqA5h.js","./factor-CFXhaUWb.js","./simple-mode-C3vEBAcb.js","./forth-POgR1ypr.js","./fortran-DL7KluxX.js","./mllike-3c2dg9RT.js","./gas-bV0CklSb.js","./gherkin-B6X1vGSW.js","./groovy-DnIzCrpZ.js","./haskell-CLQs6EAM.js","./haxe-D25e-2l-.js","./idl-pcmmZuaN.js","./javascript-BpzJj0-u.js","./jinja2-DhgKlfW7.js","./julia-DjdwvFuI.js","./livescript-HO6ttBFx.js","./lua-8DXOpKDz.js","./mirc-DkvFAiy5.js","./mathematica-IIbmv7SK.js","./modelica-DSrSSXCg.js","./mumps-zvxmGV4l.js","./mbox-z_N2Mo3d.js","./nsis-BvKfQ9lQ.js","./ntriples-BSwWqoLa.js","./octave-C4hdQ5Hf.js","./oz-qQq7irPq.js","./pascal-CafrKXZF.js","./perl-tdMlh9QA.js","./pig-CwGJVRC4.js","./powershell-D1ly3AHC.js","./properties-_nPj978X.js","./protobuf-B4y9do6W.js","./pug-BTvK5tSS.js","./puppet-Bc-yJKzi.js","./q-B0kTJ4cI.js","./r-BA4EbLKE.js","./rpm-DI_rRufH.js","./ruby-CR-u2WLS.js","./sas-Bqaci40L.js","./scheme-qjP0V5Ag.js","./shell-BLav31RL.js","./sieve-r025o_jW.js","./smalltalk-C7J3IyEP.js","./sparql-BRLJFz69.js","./stylus-Bdo_Aemu.js","./swift-B_XXVlXX.js","./verilog-B4LBqg_1.js","./tcl-B2fODqDH.js","./textile-BuVhTOzU.js","./toml-wcPdHu67.js","./troff-Ce85hlLp.js","./ttcn-BxnYHtq8.js","./ttcn-cfg-CKJxb-l2.js","./turtle-BkSuIpt-.js","./webidl-CGwyPRYs.js","./vb-BHgjm0DN.js","./vbscript-Dawdd5GZ.js","./velocity-BdD_26Jv.js","./vhdl-CWWH2SUo.js","./xquery-CVDBqZPY.js","./yacas-I8QjZlxf.js","./z80-D8p3gKXp.js","./mscgen-B2igx18G.js","./index-SPslPC2B.js","./trash--tonOuDe.js","./storage-B3Gax9mZ.css","./_createAggregator-VFK9K2d9.js","./_baseEach-BjSm9ht3.js","./loro_wasm_bg-C1ks32Vm.js","./terminal-B3isKKSk.css","./chat-panel-DJkOLrw9.js","./empty-state-CYev-D31.js","./markdown-renderer-X5YJvAZq.js","./katex-LV4FpwlL.js","./between-horizontal-start-DAHqmLYT.js","./markdown-renderer-ClyzDMmG.css","./isEmpty-CnOLuQIv.js","./agent-panel-BoscVLCT.js","./agent-panel-D92Mfy1i.css","./dependency-graph-panel-DNajptzv.js","./transform-D9VCJYws.js","./timer-Bqd5yn_a.js","./zoom-COrs4lFh.js","./common-DahoYqdi.js","./ellipsis-vertical-Bj1YXvZe.js","./dependency-graph-panel-YfRlmuld.css","./datasources-panel-C7sqRIHs.js","./sortBy-BW_zNHP6.js","./_baseMap-CV4Ezmtf.js","./documentation-panel-Dm6Ozl67.js","./error-panel-BYG4twCa.js","./file-explorer-panel-BSMiOApi.js","./icon-32x32-DHZerVul.js","./tree-ouIGEsVg.js","./index-CU5rRr66.js","./logs-panel-CjbuhBLx.js","./clear-button-GAjXl0CQ.js","./outline-panel-BvGcPKdd.js","./outline-panel-CJw2eR3G.css","./packages-panel-BichDQWG.js","./scratchpad-panel-D5N15ji1.js","./secrets-panel-BpbnAO4R.js","./snippets-panel-wlpZ_Wzx.js","./snippets-panel-B4N-3dTw.css","./tracing-panel-BMgy3D7d.js","./variable-panel-sFTn4Oih.js","./command-palette-BUXkqoLh.js"])))=>i.map(i=>d[i]);
2
+ var Hw=Object.defineProperty;var sp=ot=>{throw TypeError(ot)};var Jw=(ot,Ve,bt)=>Ve in ot?Hw(ot,Ve,{enumerable:!0,configurable:!0,writable:!0,value:bt}):ot[Ve]=bt;var B=(ot,Ve,bt)=>Jw(ot,typeof Ve!="symbol"?Ve+"":Ve,bt),Kw=(ot,Ve,bt)=>Ve.has(ot)||sp("Cannot "+bt);var ap=(ot,Ve,bt)=>(Kw(ot,Ve,"read from private field"),bt?bt.call(ot):Ve.get(ot)),ip=(ot,Ve,bt)=>Ve.has(ot)?sp("Cannot add the same private member more than once"):Ve instanceof WeakSet?Ve.add(ot):Ve.set(ot,bt);import{c as ue,kd as oo,ke as Yw,kf as Cl,kg as Xw,kh as Qw,ki as lp,kj as cp,kk as Gs,r as S,ik as Zw,bZ as dp,gW as up,kl as ek,gS as tk,gV as nk,d as he,gQ as Nl,km as ro,kn as Dt,ko as qs,kp as nt,v as Kt,je as Ut,f2 as Wt,kq as Te,kr as So,p as Se,jo as Sn,a as z,ay as qe,a0 as ze,j as i,aW as Yt,b2 as so,b1 as xr,b3 as yr,bT as ao,a$ as ye,$ as Eo,bW as Hs,b0 as io,aJ as Bn,a9 as hp,aC as pe,az as Ct,h4 as Sl,cQ as Js,ks as ok,cP as Ce,S as Ke,kt as rk,hX as Mt,ku as mp,kv as fp,kw as El,kx as pp,L as Ye,c6 as gp,bm as _o,d4 as sk,W as bp,aB as Xt,ky as ak,c8 as Ks,kz as Ys,aw as Qt,d8 as Be,db as Io,fZ as $e,kA as me,d9 as Me,kB as _l,kC as ik,kD as Il,kE as Ue,kF as xp,dB as Al,dy as Tl,gF as Dl,dk as Ml,du as Ol,ek as Ao,j9 as Rl,cS as Pn,b as vr,X as zn,i$ as yp,j1 as vp,j2 as lk,j7 as ck,j3 as wp,kG as kp,T as de,hv as dk,e4 as Un,e2 as Wn,a2 as uk,e5 as $n,e1 as lo,fd as En,kH as jp,j5 as Cp,kI as hk,a_ as mk,aZ as fk,kJ as pk,iZ as Np,i_ as Sp,bA as gk,dl as Ep,bs as bk,jT as xk,kK as yk,dz as vk,gH as Ll,bL as Fl,dF as Bl,f5 as wk,en as Ot,hR as kk,cw as Pl,i8 as Nt,ee as jk,h5 as mt,hr as Ck,aX as zl,g5 as wr,kL as Xs,cs as _n,K as ie,hN as To,ax as Qs,kM as Nk,kN as Sk,kO as _p,aY as Ek,b4 as Ul,hL as Ip,d_ as Zs,cR as St,d$ as _k,b5 as Ik,jz as Ap,a8 as Wl,kP as Ak,kQ as $l,dN as Tk,ed as Dk,hW as Tp,eg as Mk,kR as Ok,kS as Dp,k5 as Rk,k3 as Lk,k6 as Fk,k7 as Bk,kT as Vl,f7 as Zt,kU as Pk,bb as Le,kV as ea,kW as Do,kX as Mo,cv as Gl,ju as st,kY as ql,cF as zk,bo as $t,kZ as Uk,k_ as Mp,iS as Hl,cB as Op,bX as Rp,bE as Jl,eb as Wk,ec as $k,k$ as Vk,bn as Lp,ao as Kl,bq as Fp,bP as Yl,am as ta,hY as Xl,l0 as Gk,h3 as Vt,l1 as Bp,l2 as kr,l3 as Pp,l4 as na,l5 as zp,l6 as Up,l7 as Wp,ga as $p,cx as Vp,cN as Gp,l8 as qk,l9 as en,la as oa,lb as qp,M as Ql,lc as jr,ld as Cr,bc as Hp,k0 as Zl,le as Jp,lf as ra,b9 as Kp,lg as Yp,lh as sa,aH as Vn,fg as ec,hV as Xp,bI as Qp,li as Nr,lj as Sr,lk as aa,ll as Gn,lm as Zp,ln as In,lo as Oo,lp as tc,lq as Er,lr as Ro,ls as nc,lt as oc,lu as e1,lv as ia,lw as Hk,c7 as _r,lx as Ir,ly as Jk,h2 as la,lz as Kk,lA as rc,lB as Yk,lC as Xk,lD as ca,eh as Lo,ha as Qk,jH as t1,fw as n1,lE as sc,j8 as o1,hK as r1,lF as s1,lG as da,lH as a1,lI as ua,lJ as ac,lK as Fo,lL as Ar,lM as Tr,lN as Zk,jE as ic,lO as lc,lP as ha,hq as e4,jF as t4,lQ as n4,lR as o4,lS as r4,lT as s4,x as a4,lU as i4,lV as l4,lW as c4,jh as d4,lX as u4,lY as i1,t as v,lZ as h4,l_ as m4,l$ as f4,m0 as p4,m1 as g4,m2 as b4,m3 as x4,m4 as y4,m5 as v4,m6 as w4,m7 as k4,m8 as j4,m9 as C4,ma as N4,mb as S4,mc as E4,md as _4,me as I4,mf as A4,mg as T4,mh as D4,mi as M4,mj as Dr,mk as O4,ml as R4,mm as L4,mn as F4,mo as B4,mp as P4,mq as z4,mr as U4,ms as cc,bu as dc,gE as l1,mt as c1,mu as W4,mv as $4,cY as V4,mw as G4,cZ as q4,c$ as Mr,mx as H4,my as J4,mz as K4,mA as Y4,mB as X4,mC as Q4,mD as Z4,mE as e3,mF as t3,mG as n3,d0 as o3,mH as r3,mI as s3,mJ as a3,mK as d1,h7 as i3,mL as l3,mM as u1,hb as c3,mN as ma,mO as d3,mP as u3,mQ as h3,mR as m3,a3 as uc,bk as hc,bG as qn,mS as Bo,mT as h1,cU as f3,mU as Or,df as mc,bz as m1,mV as p3,mW as Rr,hw as fc,mX as co,mY as g3,hl as f1,aI as fa,mZ as b3,m_ as x3,m$ as y3,cy as v3,n0 as p1,cA as w3,bp as k3,an as pc,n1 as j3,n2 as C3,n3 as N3,n4 as Lr,n5 as Fr,hU as gc,n6 as S3,jm as E3,ei as _3,aa as ft,n7 as g1,n8 as I3,n9 as A3,na as bc,nb as xc,nc as T3,nd as b1,ne as x1,nf as pa,jd as D3,aS as y1,gY as M3,ng as v1,gM as He,nh as Br,ni as Po,nj as O3,nk as R3,nl as L3,nm as F3,nn as B3,dp as w1,no as P3,u as k1,dx as z3,np as U3,dL as W3,nq as $3,dd as j1,dI as V3,dD as G3,dC as q3,nr as H3,ej as J3,ea as K3,ns as Y3,nt as X3,nu as Q3,fX as Z3,nv as C1,nw as N1,nx as S1,ny as ej,cD as yc,nz as E1,nA as _1,be as ga,nB as tj,nC as I1,nD as nj,nE as oj,nF as A1,aT as ba,nG as rj,el as sj,nH as aj,V as ij,nI as T1,nJ as lj,nK as cj,nL as dj,nM as vc,nN as uj,nO as Pr,nP as D1,hT as M1,jb as xa,dH as O1,aE as R1,cT as wc,hu as kc,nQ as hj,hQ as L1,nR as mj,nS as F1,fU as fj,fV as pj,jZ as gj,j0 as bj,j4 as jc,j_ as xj,nT as B1,cr as yj,gl as vj,nU as wj,nV as kj,nW as jj,a1 as ya,hx as Cj,nX as Nj,nY as Sj,P as Ej,gJ as P1,nZ as _j,al as Cc,n_ as Ij,hP as Aj,n$ as Tj,o0 as Dj,dW as Mj,o1 as Oj,o2 as Rj,o3 as Lj,aQ as Fj,o4 as va,g6 as Bj,dg as Pj,dh as zj,jn as Uj,gD as wa,jK as Wj,o5 as $j,bS as Vj,o6 as Gj,o7 as qj,c5 as Hj,b6 as ka,o8 as z1,o9 as U1,b8 as W1,b7 as Jj,h1 as Kj,__tla as Yj}from"./index-C1SHFMCp.js";import{B as ja,A as Xj,G as Qj,o as Zj,s as eC,k as tC,L as $1,a as V1,b as nC,M as oC,Y as rC,e as tn,c as zr,d as sC,S as aC,K as iC,f as lC,i as cC,h as G1,j as dC,l as uC,u as q1,P as Ur,m as H1,n as hC,p as mC,q as fC,D as zo}from"./links-Dd1icsEk.js";import{V as J1,S as pC,f as K1,g as Y1,L as X1,h as Q1,F as Z1,I as Nc,M as gC,l as eg,i as bC,d as Uo,E as Ca,j as tg,k as ng,N as og,m as xC,n as Sc,e as rg,o as yC,p as vC,q as wC,s as kC,t as jC,u as CC,C as NC,R as sg,A as SC,a as EC,c as _C,P as IC,__tla as AC}from"./storage-b1QCapTq.js";import{c as TC}from"./_createAggregator-VFK9K2d9.js";import{_ as ag,a as ig,i as DC,w as MC,L as lg,A as OC,C as cg,b as Ec,c as dg,__tla as RC}from"./loro_wasm_bg-C1ks32Vm.js";let ug,Na,Sa,_c,Ea,Ic,Ac,Tc,Dc,Mc,Oc,Rc,Lc,_a,Ia,Aa,Wo,Fc,Bc,Pc,zc,Uc,hg,Wc,Ta,LC=Promise.all([(()=>{try{return Yj}catch{}})(),(()=>{try{return AC}catch{}})(),(()=>{try{return RC}catch{}})()]).then(async()=>{var $s,rp;var ot=TC(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]});let Ve,bt,Da,$c,Vc,Wr,Ma,$r,Gc,Oa,qc,Hc,Jc,Kc,Yc,Xc,Qc,Zc,ed,td,nd,Ra,od,rd,sd,ad,id,ld,cd,La,dd,Fa,ud,Ba,hd,md,fd,pd,gd,bd,Pa,xd,yd,Et,_t;Fc=ue("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),Uc=ue("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),Ve=ue("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),bt=ue("chevrons-down",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]),Da=ue("chevrons-up",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]),Na=ue("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),$c=ue("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Vc=ue("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Wr=ue("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Ma=ue("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Bc=ue("clipboard-paste",[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]),$r=ue("cloud-download",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]),Gc=ue("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),Oa=ue("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),qc=ue("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),Hc=ue("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),Jc=ue("file-pen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]),_c=ue("file-plus-2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]),Kc=ue("files",[["path",{d:"M15 2a2 2 0 0 1 1.414.586l4 4A2 2 0 0 1 21 8v7a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z",key:"1vo8kb"}],["path",{d:"M15 2v4a2 2 0 0 0 2 2h4",key:"sud9ri"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),Yc=ue("folder-tree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]),Xc=ue("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),Qc=ue("hard-drive-download",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]),Zc=ue("hat-glasses",[["path",{d:"M14 18a2 2 0 0 0-4 0",key:"1v8fkw"}],["path",{d:"m19 11-2.11-6.657a2 2 0 0 0-2.752-1.148l-1.276.61A2 2 0 0 1 12 4H8.5a2 2 0 0 0-1.925 1.456L5 11",key:"1fkr7p"}],["path",{d:"M2 11h20",key:"3eubbj"}],["circle",{cx:"17",cy:"18",r:"3",key:"82mm0e"}],["circle",{cx:"7",cy:"18",r:"3",key:"lvkj7j"}]]),ed=ue("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]),td=ue("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),nd=ue("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Ra=ue("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),od=ue("list",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]),rd=ue("map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]),sd=ue("memory-stick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]),ad=ue("message-circle-question-mark",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),id=ue("microchip",[["path",{d:"M18 12h2",key:"quuxs7"}],["path",{d:"M18 16h2",key:"zsn3lv"}],["path",{d:"M18 20h2",key:"9x5y9y"}],["path",{d:"M18 4h2",key:"1luxfb"}],["path",{d:"M18 8h2",key:"nxqzg"}],["path",{d:"M4 12h2",key:"1ltxp0"}],["path",{d:"M4 16h2",key:"8a5zha"}],["path",{d:"M4 20h2",key:"27dk57"}],["path",{d:"M4 4h2",key:"10groj"}],["path",{d:"M4 8h2",key:"18vq6w"}],["path",{d:"M8 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-1.5c-.276 0-.494.227-.562.495a2 2 0 0 1-3.876 0C9.994 2.227 9.776 2 9.5 2z",key:"1681fp"}]]),Ic=ue("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),ld=ue("octagon-alert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]),cd=ue("package-check",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]),La=ue("package-x",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["path",{d:"m17 13 5 5m-5 0 5-5",key:"im3w4b"}]]),dd=ue("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Fa=ue("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),ud=ue("regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]),Tc=ue("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),Aa=ue("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),Ba=ue("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]),Dc=ue("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),hd=ue("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),md=ue("square-code",[["path",{d:"m10 9-3 3 3 3",key:"1oro0q"}],["path",{d:"m14 15 3-3-3-3",key:"bz13h7"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),fd=ue("square-dashed-bottom-code",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}]]),pd=ue("square-m",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]),gd=ue("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Pc=ue("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),bd=ue("text-cursor-input",[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]]),Mc=ue("text-search",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]),Pa=ue("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),xd=ue("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),yd=ue("whole-word",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]),Rc=ue("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),Et=ue("zap-off",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),_t=ue("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function Vr(t,e){const n=+oo(t)-+oo(e);return n<0?-1:n>0?1:n}function mg(t,e){const n=oo(t,e==null?void 0:e.in);return+(function(o,r){const s=oo(o,r==null?void 0:r.in);return s.setHours(23,59,59,999),s})(n,e)==+(function(o,r){const s=oo(o,r==null?void 0:r.in),a=s.getMonth();return s.setFullYear(s.getFullYear(),a+1,0),s.setHours(23,59,59,999),s})(n,e)}function fg(t,e,n){const[o,r,s]=Cl(n==null?void 0:n.in,t,t,e),a=Vr(r,s),l=Math.abs((function(u,h,m){const[p,b]=Cl(m==null?void 0:m.in,u,h);return 12*(p.getFullYear()-b.getFullYear())+(p.getMonth()-b.getMonth())})(r,s));if(l<1)return 0;r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-a*l);let c=Vr(r,s)===-a;mg(o)&&l===1&&Vr(o,s)===1&&(c=!1);const d=a*(l-+c);return d===0?0:d}function pg(t,e,n){const o=(function(r,s){return+oo(r)-+oo(s)})(t,e)/1e3;return(r=>{const s=(0,Math.trunc)(r);return s===0?0:s})(o)}function gg(t,e){return(function(n,o,r){const s=Xw().locale??Qw,a=Vr(n,o);if(isNaN(a))throw new RangeError("Invalid time value");const l=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:a}),[c,d]=Cl(r==null?void 0:r.in,...a>0?[o,n]:[n,o]),u=pg(d,c),h=(lp(d)-lp(c))/1e3,m=Math.round((u-h)/60);let p;if(m<2)return m===0?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",m,l);if(m<45)return s.formatDistance("xMinutes",m,l);if(m<90)return s.formatDistance("aboutXHours",1,l);if(m<cp){const b=Math.round(m/60);return s.formatDistance("aboutXHours",b,l)}if(m<2520)return s.formatDistance("xDays",1,l);if(m<Gs){const b=Math.round(m/cp);return s.formatDistance("xDays",b,l)}if(m<2*Gs)return p=Math.round(m/Gs),s.formatDistance("aboutXMonths",p,l);if(p=fg(d,c),p<12){const b=Math.round(m/Gs);return s.formatDistance("xMonths",b,l)}{const b=p%12,x=Math.trunc(p/12);return b<3?s.formatDistance("aboutXYears",x,l):b<9?s.formatDistance("overXYears",x,l):s.formatDistance("almostXYears",x+1,l)}})(t,(function(n){return Yw(n,Date.now())})(t),e)}const bg=S.createContext({}),xg=S.forwardRef(function(t,e){[t,e]=tk(t,e,bg);let{toolbarProps:n}=(function(s,a){const{"aria-label":l,"aria-labelledby":c,orientation:d="horizontal"}=s;let[u,h]=S.useState(!1);Zw(()=>{var f;h(!(!a.current||!(!((f=a.current.parentElement)===null||f===void 0)&&f.closest('[role="toolbar"]'))))});const{direction:m}=dp(),p=m==="rtl"&&d==="horizontal";let b=ek(a);const x=S.useRef(null);return{toolbarProps:{...up(s,{labelable:!0}),role:u?"group":"toolbar","aria-orientation":d,"aria-label":l,"aria-labelledby":l==null?c:void 0,onKeyDownCapture:u?void 0:f=>{if(f.currentTarget.contains(f.target)){if(d==="horizontal"&&f.key==="ArrowRight"||d==="vertical"&&f.key==="ArrowDown")p?b.focusPrevious():b.focusNext();else{if(!(d==="horizontal"&&f.key==="ArrowLeft"||d==="vertical"&&f.key==="ArrowUp"))return f.key==="Tab"?(f.stopPropagation(),x.current=document.activeElement,void(f.shiftKey?b.focusFirst():b.focusLast())):void 0;p?b.focusNext():b.focusPrevious()}f.stopPropagation(),f.preventDefault()}},onFocusCapture:u?void 0:f=>{var g,y;x.current&&!f.currentTarget.contains(f.relatedTarget)&&(!((g=a.current)===null||g===void 0)&&g.contains(f.target))&&((y=x.current)===null||y===void 0||y.focus(),x.current=null)},onBlurCapture:u?void 0:f=>{f.currentTarget.contains(f.relatedTarget)||x.current||(x.current=f.target)}}}})(t,e),o=nk({...t,values:{orientation:t.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),r=up(t,{global:!0});return delete r.id,he.createElement("div",{...Nl(r,o,n),ref:e,slot:t.slot||void 0,"data-orientation":t.orientation||"horizontal"},o.children)}),Gr={showInput:"Mod-l",acceptEdit:"Mod-y",rejectEdit:"Mod-u"},$o=ro.define({combine:t=>qs(t,{onError:console.error,inputDebounceTime:300,keymaps:Gr},{onError:(e,n)=>e&&n,inputDebounceTime:(e,n)=>e&&n,keymaps:(e,n)=>e&&n})}),Hn=nt.define(),Jn=Dt.define({create:()=>({show:!1,lineFrom:0,lineTo:0}),update(t,e){for(const n of e.effects)if(n.is(Hn))return n.value;return t}}),Vo=nt.define(),Go=nt.define(),vd=Dt.define({create:()=>({shouldFocus:!1,inputValue:""}),update(t,e){let n=t;for(const o of e.effects)o.is(Vo)&&(n={...n,inputValue:o.value}),o.is(Go)&&(n={...n,shouldFocus:o.value});return n}}),qr=nt.define(),qo=Dt.define({create:()=>null,update(t,e){for(const n of e.effects)if(n.is(qr))return n.value;return t}}),uo=nt.define(),wd=Dt.define({create:()=>!1,update(t,e){for(const n of e.effects)if(n.is(uo))return n.value;return t}}),kd=t=>{const{state:e}=t,n=e.selection.main;if(n.empty)return!1;const o=e.doc,r=o.lineAt(n.from),s=o.lineAt(n.to);if(e.sliceDoc(r.from,s.to).trim().length<1)return!1;const a=Math.max(1,Math.min(r.number,o.lines)),l=Math.max(1,Math.min(s.number,o.lines));return t.dispatch({effects:[Hn.of({show:!0,lineFrom:a,lineTo:l}),Go.of(!0),Vo.of("")],selection:Kt.cursor(r.from)}),!0},jd=t=>!!t.state.field(qo)&&(t.dispatch({effects:[qr.of(null),Hn.of({show:!1,lineFrom:0,lineTo:0}),Go.of(!1),Vo.of(""),uo.of(!1)]}),!0),Cd=t=>{const e=t.state.field(qo);return!!e&&(t.dispatch({changes:{from:e.from,to:e.to,insert:e.oldCode},effects:[qr.of(null),Hn.of({show:!1,lineFrom:0,lineTo:0}),Go.of(!1),Vo.of(""),uo.of(!1)]}),!0)},yg="\u2318",vg="\u229E Win",wg="Ctrl";function za(t){return t.replace("Mod",navigator.platform.startsWith("Mac")?yg:navigator.platform.startsWith("Win")?vg:wg).replace("-"," ").toUpperCase()}function xt(t,e){const n=document.createElement(t);return n.className=e,n}const Hr=Dt.define({create:()=>({suggestion:null}),update(t,e){const n=e.effects.find(o=>o.is(Jr));return e.docChanged||n||e.selection?n&&e.state.doc===n.value.doc?{suggestion:n.value.text}:{suggestion:null}:t}}),Jr=nt.define();class kg extends So{constructor(n){super();B(this,"suggestion");this.suggestion=n}toDOM(){const n=document.createElement("span");return n.style.opacity="0.4",n.className="cm-inline-suggestion",n.textContent=this.suggestion,n.setAttribute("role","suggestion"),n.setAttribute("aria-label",`Suggestion: ${this.suggestion}`),n}get lineBreaks(){return this.suggestion.split(`
3
+ `).length-1}}class jg{constructor(e){B(this,"cache",new Map);B(this,"timeout");this.timeout=e}get(e){const n=this.cache.get(e);return n?Date.now()-n.timestamp>this.timeout?(this.cache.delete(e),null):n.result:null}set(e,n){this.cache.set(e,{result:n,timestamp:Date.now()})}}const Cg=(t,e)=>Ut.fromClass(class{constructor(){B(this,"abortController",null);B(this,"cache");this.cache=new jg(e.cacheTimeout??1e3)}async update(n){var a,l,c,d,u;if(!n.docChanged||((l=(a=e.events)==null?void 0:a.beforeSuggestionFetch)==null?void 0:l.call(a,n.view))===!1)return;(c=this.abortController)==null||c.abort(),this.abortController=new AbortController;const o=n.state.doc,r=o.toString(),s=this.cache.get(r);if(s)n.view.dispatch({effects:Jr.of({text:s,doc:o})});else try{const h=await t(n.state,this.abortController.signal,n.view);if(this.abortController.signal.aborted||((u=(d=e.events)==null?void 0:d.shouldShowSuggestion)==null?void 0:u.call(d,n.view,h))===!1)return;this.cache.set(r,h),n.view.dispatch({effects:Jr.of({text:h,doc:o})})}catch(h){h instanceof Error&&h.name!=="AbortError"&&console.error("Suggestion fetch error:",h)}}destroy(){var n;(n=this.abortController)==null||n.abort()}}),Ng=Ut.fromClass(class{constructor(){B(this,"decorations");this.decorations=Te.none}update(t){var n;const e=(n=t.state.field(Hr))==null?void 0:n.suggestion;this.decorations=e?(function(o,r){const s=o.state.selection.main.head,a=[],l=Te.widget({widget:new kg(r),side:1});return a.push(l.range(s)),Te.set(a)})(t.view,e):Te.none}},{decorations:t=>t.decorations}),Nd=t=>{var o,r,s;const e=(o=t.state.field(Hr))==null?void 0:o.suggestion;if(!e)return!1;const n=t.state.facet(Ua);return t.dispatch({effects:Jr.of({text:null,doc:t.state.doc})}),(s=(r=n.events)==null?void 0:r.onSuggestionRejected)==null||s.call(r,t,e),!0},Sg=Wt.of([{key:"Tab",run:t=>{var l,c,d;const e=(l=t.state.field(Hr))==null?void 0:l.suggestion;if(!e)return!1;const n=t.state.facet(Ua);var o,r,s,a;return t.dispatch({...(o=t.state,r=e,s=t.state.selection.main.head,a=t.state.selection.main.head,{...o.changeByRange(u=>{if(u===o.selection.main)return{changes:{from:s,to:a,insert:r},range:Kt.cursor(s+r.length)};const h=a-s;return!u.empty||h&&o.sliceDoc(u.from-h,u.from)!==o.sliceDoc(s,a)?{range:u}:{changes:{from:u.from-h,to:u.from,insert:r},range:Kt.cursor(u.from-h+r.length)}}),userEvent:"input.complete"})}),(d=(c=n.events)==null?void 0:c.onSuggestionAccepted)==null||d.call(c,t,e),!0}},{key:"Escape",run:Nd}]),Ua=ro.define({combine:t=>t.at(-1)});function Sd(t){const{delay:e=500,includeKeymap:n=!0}=t,o=(function(r,s,a){let l=()=>{};return(...c)=>(l(),new Promise((d,u)=>{const h=setTimeout(()=>d(r(...c)),s);l=()=>{clearTimeout(h),a!==void 0&&u(a)}}))})(t.fetchFn,e);return[Hr,Ua.of(t),Cg(o,t),Ng,n?Sg:[]]}const Eg=Se.baseTheme({".cm-ai-input-container":{display:"flex",flexDirection:"column",gap:"4px",width:"min(calc(100% + 7px), 500px)",padding:"5px 5px",margin:"0 -6px",backgroundColor:"light-dark(rgb(241, 243, 245), rgb(40, 40, 40))"},".cm-ai-input":{display:"block",width:"100%",padding:"3px 8px",border:"2px solid rgb(51, 154, 240)",borderRadius:"5px",fontSize:"12px"},".cm-ai-help-info-button":{fontSize:"10px",paddingLeft:"10px",height:"18px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",display:"block",marginRight:"auto"},".cm-ai-help-info-button:hover":{color:"light-dark(rgb(89, 97, 105), rgb(190, 190, 190))"},".cm-ai-generate-button":{background:"#0E639C",border:"none",padding:"2px 6px",color:"#ffffff",cursor:"pointer",font:"inherit",borderRadius:"4px","&:hover":{backgroundColor:"#1177bb"}},".cm-line.cm-ai-selection, .cm-line.cm-ai-selection.cm-active-line":{backgroundColor:"light-dark(color-mix(in srgb, rgb(223, 227, 232) 50%, transparent), color-mix(in srgb, rgb(50, 50, 50) 50%, transparent)) !important"},".cm-line:has(.cm-new-code-line)":{backgroundColor:"light-dark(color-mix(in srgb, rgb(183, 235, 143) 50%, transparent), color-mix(in srgb, rgb(40, 100, 40) 50%, transparent)) !important"},".cm-old-code-container":{backgroundColor:"light-dark(rgb(255, 205, 205), rgb(100, 40, 40))",position:"relative",display:"flex",paddingTop:"0",width:"100%",alignItems:"center"},".cm-code-button":{position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"16px"},".cm-floating-buttons":{fontFamily:"sans-serif",position:"absolute",top:"-20px",left:"5px",display:"flex"},".cm-floating-button":{fontFamily:"sans-serif",padding:"2px 5px",fontSize:"10px",cursor:"pointer",fontWeight:"700"},".cm-floating-accept":{backgroundColor:"light-dark(rgb(55, 125, 34), rgb(40, 80, 25))",borderTopLeftRadius:"5px",borderBottomLeftRadius:"5px",color:"white",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".cm-floating-reject":{backgroundColor:"light-dark(rgb(220, 53, 69), rgb(180, 40, 50))",color:"white",borderTopRightRadius:"5px",borderBottomRightRadius:"5px",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".hotkey":{display:"inline-block",padding:"0 4px",borderRadius:"3px",backgroundColor:"rgba(255, 255, 255, 0.1)",fontSize:"90%"},".cm-ai-loading-indicator":{fontStyle:"italic",fontSize:"10px",paddingLeft:"12px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",opacity:"0",transition:"opacity 0.3s ease-in-out","&::after":{content:'""',display:"inline-block",animation:"ellipsis-pulse 1.5s steps(4, end) infinite"},"&:not(:empty)":{opacity:"1"}},".cm-ai-input:disabled":{opacity:"0.5"},"@keyframes ellipsis-pulse":{"0%":{content:"'.'"},"25%":{content:"'..'"},"50%":{content:"'...'"},"75%":{content:"''"}},".cm-ai-loading-container":{display:"flex",alignItems:"center",padding:"0 8px"},".cm-ai-cancel-button":{padding:"2px 8px",fontSize:"10px",borderRadius:"4px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",cursor:"pointer","&:hover":{background:"light-dark(rgb(223, 227, 232), rgb(50, 50, 50))"}},".hidden":{display:"none"}});function _g(t){var r,s;const e=t.state.facet($o),n={...Gr,...e.keymaps},o=xt("div","cm-ai-tooltip").appendChild(xt("div","cm-ai-tooltip-button"));return o.innerHTML=`<span>Edit <span class="hotkey">${za(n.showInput)}</span></span>`,(r=o.querySelector("span"))==null||r.addEventListener("mousedown",a=>{a.stopPropagation(),a.button===0&&a.preventDefault()}),(s=o.querySelector("span"))==null||s.addEventListener("click",a=>{a.preventDefault(),kd(t)}),o}const Wa=ro.define({combine:t=>qs(t,{render:_g,hideOnBlur:!1})}),Ig=Ut.fromClass((rp=class{constructor(t){B(this,"view");B(this,"suppress");B(this,"dom");B(this,"mousedown",()=>{this.suppress=!0});B(this,"mouseup",()=>{this.suppress=!1,this.display(this.view)});B(this,"scroll",()=>{this.display(this.view)});B(this,"windowScroll",()=>{this.display(this.view)});ip(this,$s,t=>{var n;const e=t.state.selection.ranges.find(o=>!o.empty);if(e&&!this.suppress){const o=t.coordsAtPos(e.from);if(!o)return;const r=t.dom.getBoundingClientRect(),s=(n=t.dom.parentElement)==null?void 0:n.getBoundingClientRect(),a=o.top>=r.top&&o.top<=r.bottom&&o.left>=r.left&&o.left<=r.right,l=!s||o.top>=s.top&&o.top<=s.bottom&&o.left>=s.left&&o.left<=s.right;if(!a||!l)return this.dom.style.display="none",void this.dom.setAttribute("aria-hidden","true");this.dom.style.display="flex",this.dom.setAttribute("aria-hidden","false");const c=this.dom.getBoundingClientRect(),d=r.width-c.width,u=Math.min(o.left,d);let h=o.top-c.height;h=s?Math.max(s.y,h):h,this.dom.style.left=`${u}px`,this.dom.style.top=`${h}px`,requestAnimationFrame(()=>{this.dom&&this.dom.setAttribute("aria-hidden","false")})}else this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true")});this.view=t;const e=t.state.facet(Wa);this.suppress=!1,document.addEventListener("mousedown",this.mousedown),document.addEventListener("mouseup",this.mouseup),t.scrollDOM.addEventListener("scroll",this.scroll),window.addEventListener("scroll",this.windowScroll,!0);const n=e.render(t);t.dom.appendChild(n),this.dom=n}update(t){this.display(t.view)}docViewUpdate(t){this.display(t)}display(t){if(t.state.field(Jn).show)return void(this.dom.style.display="none");if(t.state.facet(Wa).hideOnBlur&&!t.hasFocus)return this.dom.style.display="none",void this.dom.setAttribute("aria-hidden","true");t.requestMeasure({read:ap(this,$s)})}destroy(){document.removeEventListener("mousedown",this.mousedown),document.removeEventListener("mouseup",this.mouseup),this.view.scrollDOM.removeEventListener("scroll",this.scroll),window.removeEventListener("scroll",this.windowScroll,!0),this.dom.remove()}},$s=new WeakMap,rp)),Ag=Se.baseTheme({".cm-ai-tooltip-button":{userSelect:"none",fontFamily:"system-ui, -apple-system, sans-serif",position:"fixed",display:"flex",boxSizing:"border-box",padding:"2px 6px",borderRadius:"4px",fontSize:"12px",backgroundColor:"#0E639C",color:"#ffffff",border:"1px solid transparent",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",zIndex:"999",transition:"opacity 0.5s","&[aria-hidden='true']":{opacity:"0"},"&[aria-hidden='false']":{opacity:"1"},"& > span":{pointerEvents:"auto",cursor:"pointer",display:"inline-block",padding:"2px"},"&:hover":{backgroundColor:"#1177bb"}}});class Tg extends So{constructor(n){super();B(this,"oldCode");this.oldCode=n}toDOM(n){const o=xt("div","cm-old-code-container");o.setAttribute("role","region"),o.setAttribute("aria-label","Previous code version");const r=xt("div","cm-old-code cm-line");r.textContent=this.oldCode;const s=xt("div","cm-floating-buttons"),a=n.state.facet($o),l={...Gr,...a.keymaps},c=xt("button","cm-floating-button cm-floating-accept");c.innerHTML=`<span class="hotkey">${za(l.acceptEdit)}</span> Accept`,c.setAttribute("aria-label","Accept changes"),c.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),n.focus(),jd(n)});const d=xt("button","cm-floating-button cm-floating-reject");return d.innerHTML=`<span class="hotkey">${za(l.rejectEdit)}</span> Reject`,d.setAttribute("aria-label","Reject changes"),d.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),n.focus(),Cd(n)}),s.append(c,d),o.append(r,s),o}updateDOM(n,o){return!0}}class Dg extends So{constructor(n){super();B(this,"complete");B(this,"abortController",null);B(this,"dom",null);B(this,"input",null);B(this,"loadingContainer",null);B(this,"helpInfo",null);B(this,"inputContainer",null);B(this,"form",null);B(this,"view",null);B(this,"onKeyDown",async n=>{n.key!=="Enter"||n.shiftKey?n.key==="Escape"&&this.onCancel():(n.preventDefault(),await this.handleSubmit())});B(this,"onCancel",()=>{this.cleanup();const n=this.view;n&&(n.dispatch({effects:[Hn.of({show:!1,lineFrom:0,lineTo:0}),uo.of(!1)]}),n.focus())});B(this,"handleSubmit",async n=>{var x;const o=this.view;if(!o)return;const r=o.state.facet($o);n==null||n.stopPropagation();const s=o.state.field(Jn),{input:a}=this;if(!a)return;const l=a.value.trim();if(!s.show||!l)return;const c=o.state.doc.line(s.lineFrom),d=o.state.doc.line(s.lineTo),u=c.from,h=d.to,m=o.state.sliceDoc(u,h),p=o.state.sliceDoc(0,u),b=o.state.sliceDoc(h);this.abortController=new AbortController,o.dispatch({effects:uo.of(!0)}),this.toggleLoading(!0);try{const f=await this.complete({prompt:l,selection:m,codeBefore:p,codeAfter:b,editorView:o,signal:this.abortController.signal});if(!o.state.field(Jn).show)return;if(!f||typeof f!="string")throw new Error("Invalid completion result");o.dispatch({changes:{from:u,to:h,insert:f},effects:[Hn.of({show:!1,lineFrom:0,lineTo:0}),qr.of({from:u,to:u+f.length,oldCode:m,newCode:f}),uo.of(!1)]})}catch(f){if(f instanceof DOMException&&f.name==="AbortError")return;(x=r.onError)==null||x.call(r,f)}finally{this.cleanup(),this.toggleLoading(!1),o.focus()}});this.complete=n}toDOM(n){if(this.dom)return this.dom;this.view=n;const o=n.state.field(vd),r=n.state.field(wd),s=xt("div","cm-ai-input-container");this.inputContainer=s,this.dom=s;const a=xt("form","cm-ai-input-form");this.form=a,a.setAttribute("role","search"),a.setAttribute("aria-label","AI editing instructions"),a.addEventListener("submit",f=>f.preventDefault());const l=xt("input","cm-ai-input");this.input=l,a.append(l),l.placeholder="Editing instructions...",l.setAttribute("aria-label","AI editing instructions"),l.setAttribute("autocomplete","off"),l.setAttribute("spellcheck","true"),l.value=o.inputValue;const c=xt("div","cm-ai-loading-container");this.loadingContainer=c;const d=xt("div","cm-ai-loading-indicator");d.setAttribute("role","status"),d.setAttribute("aria-live","polite"),d.textContent="Generating";const u=xt("button","cm-ai-cancel-button");u.textContent="Cancel",u.setAttribute("aria-label","Cancel code generation"),u.addEventListener("click",this.onCancel),c.append(u,d);const h=xt("div","cm-ai-help-info");this.helpInfo=h;const m=h.appendChild(document.createElement("button"));m.className="cm-ai-help-info-button",m.textContent="Esc to close",m.addEventListener("click",this.onCancel);const p=xt("button","cm-ai-generate-button");function b(f){h.replaceChildren(f?p:m)}p.textContent="\u23CE Generate",p.setAttribute("aria-label","Generate code"),p.addEventListener("click",this.handleSubmit),this.toggleLoading(r),o.shouldFocus&&requestAnimationFrame(()=>{l.value=o.inputValue,l.focus(),n.dispatch({effects:Go.of(!1)})}),b(l.value),l.addEventListener("input",function(){n.dispatch({effects:Vo.of(l.value)});const f=l.value.trim();f!==x&&(x=f,b(f))}),l.addEventListener("keydown",this.onKeyDown);let x="";return s}toggleLoading(n){var o;this.inputContainer&&this.form&&this.loadingContainer&&this.helpInfo&&((o=this.inputContainer)==null||o.replaceChildren(this.form,n?this.loadingContainer:this.helpInfo))}updateDOM(n,o){return this.dom=n,this.input=n.querySelector(".cm-ai-input"),!0}cleanup(){var n,o,r;(n=this.abortController)==null||n.abort(),this.abortController=null,(o=this.dom)==null||o.remove(),(r=this.input)==null||r.remove(),this.dom=null,this.input=null}destroy(){this.cleanup()}}function Mg(t){if(!t.prompt)throw new Error("prompt function is required");const e={...Gr,...t.keymaps};return[$o.of(t),Jn,vd,qo,wd,[Ig,Ag],Eg,Wt.of([{key:e.showInput,run:kd}]),Sn.highest([Wt.of([{key:e.acceptEdit,run:jd},{key:e.rejectEdit,run:Cd}])]),Og,Rg,Lg,Fg]}const Og=Se.updateListener.of(t=>{const e=t.state.field(Jn);if(!e.show||!t.docChanged)return;let{lineFrom:n,lineTo:o}=e,r=!1;t.changes.iterChanges((s,a,l,c)=>{const d=t.state.doc.lineAt(s).number;if(d<n){const u=t.state.doc.lineAt(c).number-t.state.doc.lineAt(l).number;n+=u,o+=u,r=!0}else if(d<=o){const u=t.state.doc.lineAt(c).number-t.state.doc.lineAt(l).number;o+=u,r=!0}}),r&&t.view.dispatch({effects:[Hn.of({show:!0,lineFrom:n,lineTo:o})]})}),Rg=Se.decorations.of(t=>{const e=t.state.field(qo);return e?Te.set([Te.mark({class:"cm-new-code-line"}).range(e.from,e.to)]):Te.none}),Lg=Se.decorations.compute([Jn],t=>{const e=t.field(Jn),n=t.facet($o),o=[];if(e.show){const r=e.lineFrom,s=e.lineTo;for(let a=r;a<=s;a++){const l=t.doc.line(a).from;o.push(Te.line({class:"cm-ai-selection"}).range(l)),a===r&&o.push(Te.widget({widget:new Dg(n.prompt),side:-1}).range(l))}}return Te.set(o)}),Fg=Dt.define({create:t=>Te.none,update(t,e){const n=e.state.field(qo);return n?Te.set([Te.widget({widget:new Tg(n.oldCode),block:!0}).range(n.from)]):Te.none},provide:t=>Se.decorations.from(t)}),Kr="https://static.marimo.app",Bg=t=>{const e=z.c(25),{onClose:n}=t,[o,r]=S.useState(""),{exportAsHTML:s}=qe(),a=`${o}-${Math.random().toString(36).slice(2,6)}`,l=`${Kr}/static/${a}`;let c,d,u,h,m,p,b,x,f,g,y;return e[0]!==s||e[1]!==n||e[2]!==a?(c=async w=>{w.preventDefault(),n();const j=await s({download:!1,includeCode:!0,files:J1.INSTANCE.filenames()}),C=ze({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Kr}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:j,path:a})}).catch(()=>{C.dismiss(),ze({title:"Error uploading static page",description:i.jsxs("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",i.jsx("a",{href:Yt.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),C.dismiss(),ze({title:"Static page uploaded!",description:i.jsxs("div",{children:["The URL has been copied to your clipboard.",i.jsx("br",{}),"You can share it with anyone."]})})},e[0]=s,e[1]=n,e[2]=a,e[3]=c):c=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(so,{children:"Share static notebook"}),e[4]=d):d=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsxs(xr,{children:[d,i.jsxs(yr,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",i.jsx("a",{href:Kr,target:"_blank",children:Kr}),"."]})]}),e[5]=u):u=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(h=w=>{const j=w.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,"");r(j)},e[6]=h):h=e[6],e[7]!==o?(m=i.jsx(ao,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:h,required:!0,autoComplete:"off"}),e[7]=o,e[8]=m):m=e[8],e[9]!==l?(p=i.jsxs("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Pg,{text:l}),i.jsx("span",{className:"text-primary",children:l})]})]}),e[9]=l,e[10]=p):p=e[10],e[11]!==m||e[12]!==p?(b=i.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[m,p]}),e[11]=m,e[12]=p,e[13]=b):b=e[13],e[14]!==n?(x=i.jsx(ye,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),e[14]=n,e[15]=x):x=e[15],e[16]!==l?(f=i.jsx(ye,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await Eo(l)},children:"Create"}),e[16]=l,e[17]=f):f=e[17],e[18]!==x||e[19]!==f?(g=i.jsxs(Hs,{children:[x,f]}),e[18]=x,e[19]=f,e[20]=g):g=e[20],e[21]!==c||e[22]!==g||e[23]!==b?(y=i.jsx(io,{className:"w-fit",children:i.jsxs("form",{onSubmit:c,children:[u,b,g]})}),e[21]=c,e[22]=g,e[23]=b,e[24]=y):y=e[24],y},Pg=t=>{const e=z.c(8),[n,o]=he.useState(!1);let r;e[0]!==t.text?(r=Bn.stopPropagation(async d=>{d.preventDefault(),await Eo(t.text),o(!0),setTimeout(()=>o(!1),2e3)}),e[0]=t.text,e[1]=r):r=e[1];const s=r;let a,l,c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(hp,{size:14,strokeWidth:1.5}),e[2]=a):a=e[2],e[3]!==s?(l=i.jsx(ye,{"data-testid":"copy-static-notebook-url-button",onClick:s,size:"xs",variant:"secondary",children:a}),e[3]=s,e[4]=l):l=e[4],e[5]!==n||e[6]!==l?(c=i.jsx(pe,{content:"Copied!",open:n,children:l}),e[5]=n,e[6]=l,e[7]=c):c=e[7],c};function Ed(){const t=z.c(2),e=Ct(Sl);let n;return t[0]!==e?(n=()=>{const o=document.getElementsByClassName("output-area"),r=window.innerHeight||document.documentElement.clientHeight;let s=null;for(const a of Array.from(o)){const l=a.getBoundingClientRect();if(l.top>=0&&l.top<=r||l.bottom>=0&&l.bottom<=r){s=Js.parse(a.parentNode.id);break}}e(a=>({mode:ok(a.mode),cellAnchor:s})),requestAnimationFrame(()=>{var a;s!==null&&((a=document.getElementById(Js.create(s)))==null||a.scrollIntoView())})},t[0]=e,t[1]=n):n=t[1],n}function $a(t){const e=z.c(3),n=Ho();let o;return e[0]!==t||e[1]!==n?(o=()=>{t!==void 0&&n([t])},e[0]=t,e[1]=n,e[2]=o):o=e[2],Ce(o)}function _d(){const t=z.c(2),e=Ho();let n;return t[0]!==e?(n=()=>e(mp(Mt())),t[0]=e,t[1]=n):n=t[1],Ce(n)}function Ho(){const t=z.c(3),{prepareForRun:e}=Ke(),{sendRun:n}=qe();let o;return t[0]!==e||t[1]!==n?(o=async r=>{var c,d;if(r.length===0)return;const{cellHandles:s,cellData:a}=Mt(),l=[];for(const u of r){const h=s[u],m=(c=h==null?void 0:h.current)==null?void 0:c.editorView;let p;m?(fp(m)!=="markdown"&&El(m),p=pp(m)):p=((d=a[u])==null?void 0:d.code)||"",l.push(p),e({cellId:u})}await n({cellIds:r,codes:l}).catch(zg)},t[0]=e,t[1]=n,t[2]=o):o=t[2],Ce(o)}function zg(t){Ye.error(t)}let Yr;Yr=[{type:"files",Icon:Yc,tooltip:"View files",position:"sidebar"},{type:"variables",Icon:gp,tooltip:"Explore variables",position:"sidebar"},{type:"datasources",Icon:_o,tooltip:"Explore data sources",position:"sidebar"},{type:"dependencies",Icon:Ic,tooltip:"Explore dependencies",position:"sidebar"},{type:"packages",Icon:ja,tooltip:"Manage packages",position:"sidebar"},{type:"outline",Icon:Dc,tooltip:"View outline",position:"sidebar"},{type:"chat",Icon:sk,tooltip:"Chat with AI",position:"sidebar"},{type:"agents",Icon:Zc,tooltip:"Agents",position:"sidebar",hidden:!Ys("external_agents")},{type:"documentation",Icon:Mc,tooltip:"View live docs",position:"sidebar"},{type:"logs",Icon:bp,tooltip:"Notebook logs",position:"sidebar"},{type:"tracing",Icon:Xj,tooltip:"Tracing",position:"sidebar"},{type:"snippets",Icon:fd,tooltip:"Snippets",position:"sidebar"},{type:"secrets",Icon:td,tooltip:"Secrets",hidden:Xt(),position:"sidebar"},{type:"scratchpad",Icon:ak,tooltip:"Scratchpad",position:"sidebar"},{type:"errors",Icon:Ks,tooltip:"View errors",position:"footer"}],_a=Qt(!1);function Kn(){return Me().optional().describe(me.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function Va(t,e){const n=Me().describe(me.of({label:t||"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"}));return e?n.nonempty():n.optional()}function Xr(){return Me().optional().describe(me.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function Ga(t,e){const n=Me().describe(me.of({label:t||"URI",optionRegex:".*uri.*"}));return e?n.nonempty():n.optional()}function An(t){return Me().nonempty().describe(me.of({label:t||"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function nn(){return Me().describe(me.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function Yn(){return Me().nonempty().describe(me.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function Xn(t){const e=ik.string().describe(me.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(n=>n>=0&&n<=65535,{message:"Port must be between 0 and 65535"});return t!==void 0?e.default(t.toString()):e}function Id(){return Io().default(!1).describe(me.of({label:"Read Only"}))}const Ad=Be({type:$e("postgres"),host:An(),port:Xn(5432).optional(),database:nn(),username:Yn(),password:Kn(),ssl:Io().default(!1).describe(me.of({label:"Use SSL"}))}).describe(me.of({direction:"two-columns"})),Td=Be({type:$e("mysql"),host:An(),port:Xn(3306),database:nn(),username:Yn(),password:Kn(),ssl:Io().default(!1).describe(me.of({label:"Use SSL"}))}).describe(me.of({direction:"two-columns"})),Dd=Be({type:$e("sqlite"),database:nn().describe(me.of({label:"Database Path"}))}).describe(me.of({direction:"two-columns"})),Md=Be({type:$e("duckdb"),database:nn().describe(me.of({label:"Database Path"})),read_only:Id()}).describe(me.of({direction:"two-columns"})),Od=Be({type:$e("motherduck"),database:nn().default("my_db").describe(me.of({label:"Database Name"})),token:Va()}).describe(me.of({direction:"two-columns"})),Rd=Be({type:$e("snowflake"),account:Me().nonempty().describe(me.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:Me().optional().describe(me.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:nn(),schema:Me().optional().describe(me.of({label:"Schema",optionRegex:".*snowflake.*"})),username:Yn(),password:Kn(),role:Me().optional().describe(me.of({label:"Role"}))}).describe(me.of({direction:"two-columns"})),Ld=Be({type:$e("bigquery"),project:Me().nonempty().describe(me.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:Me().nonempty().describe(me.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:Me().describe(me.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(me.of({direction:"two-columns"})),Fd=Be({type:$e("clickhouse_connect"),host:An(),port:Xn(8123).optional(),username:Yn(),password:Kn(),secure:Io().default(!1).describe(me.of({label:"Use HTTPs"}))}).describe(me.of({direction:"two-columns"})),Bd=Be({type:$e("timeplus"),host:An().default("localhost"),port:Xn(8123).optional(),username:Yn().default("default"),password:Kn().default("")}).describe(me.of({direction:"two-columns"})),Pd=Be({type:$e("chdb"),database:nn().describe(me.of({label:"Database Path"})),read_only:Id()}).describe(me.of({direction:"two-columns"})),zd=Be({type:$e("trino"),host:An(),port:Xn(8080),database:nn(),schema:Me().describe(me.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"})).optional(),username:Yn(),password:Kn(),async_support:Io().default(!1).describe(me.of({label:"Async Support"}))}).describe(me.of({direction:"two-columns"})),Ud=Be({type:$e("iceberg"),name:Me().describe(me.of({label:"Catalog Name"})),catalog:_l("type",[Be({type:$e("REST"),warehouse:Xr(),uri:Me().optional().describe(me.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:Va()}),Be({type:$e("SQL"),warehouse:Xr(),uri:Me().optional().describe(me.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),Be({type:$e("Hive"),warehouse:Xr(),uri:Ga()}),Be({type:$e("Glue"),warehouse:Xr(),uri:Ga()}),Be({type:$e("DynamoDB"),"dynamodb.profile-name":Me().optional().describe(me.of({label:"Profile Name"})),"dynamodb.region":Me().optional().describe(me.of({label:"Region"})),"dynamodb.access-key-id":Me().optional().describe(me.of({label:"Access Key ID"})),"dynamodb.secret-access-key":Me().optional().describe(me.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":Me().optional().describe(me.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST"}).describe(me.of({special:"tabs"}))}),Wd=Be({type:$e("datafusion"),sessionContext:Io().optional().describe(me.of({label:"Use Session Context"}))}),$d=Be({type:$e("pyspark"),host:An().optional(),port:Xn().optional()}),Vd=Be({type:$e("redshift"),host:An(),port:Xn(5439),connectionType:_l("type",[Be({type:$e("IAM credentials"),region:Me().describe(me.of({label:"Region"})),aws_access_key_id:Me().nonempty().describe(me.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:Me().nonempty().describe(me.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:Me().optional().describe(me.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),Be({type:$e("DB credentials"),user:Yn(),password:Kn()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:nn()}).describe(me.of({direction:"two-columns"})),Gd=Be({type:$e("databricks"),access_token:Va("Access Token",!0),server_hostname:An("Server Hostname"),http_path:Ga("HTTP Path",!0),catalog:Me().optional().describe(me.of({label:"Catalog"})),schema:Me().optional().describe(me.of({label:"Schema"}))}).describe(me.of({direction:"two-columns"})),Ug=_l("type",[Ad,Td,Dd,Md,Od,Rd,Ld,Fd,Bd,Pd,zd,Ud,Wd,$d,Vd,Gd]),qa="env:";function Qr(t){return typeof t=="string"&&t.startsWith(qa)}function Ha(t){return`${qa}${t}`}const qd={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift",databricks:"Databricks"};class pt{constructor(e,n,o){this.connection=void 0,this.orm=void 0,this.secrets=void 0,this.connection=e,this.orm=n,this.secrets=o}get imports(){const e=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":e.add("import sqlalchemy");break;case"sqlmodel":e.add("import sqlmodel");break;case"duckdb":e.add("import duckdb");break;case"ibis":e.add("import ibis")}return e}}class Wg{constructor(){this.secrets={}}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(e,n,o){if(e=`_${e}`,Qr(n)){const r=n.replace(qa,""),s=o?`os.environ.get("${r}", "${o}")`:`os.environ.get("${r}")`;return this.secrets[e]=s,e}if(o!=null){const r=`os.environ.get("${n}", "${o}")`;return this.secrets[e]=r,e}return typeof n=="number"||typeof n=="number"?`${n}`:typeof n=="boolean"?ho(n):n?`"${n}"`:""}printInFString(e,n,o){if(n===void 0)return"";if(typeof n=="number")return`${n}`;if(typeof n=="boolean")return ho(n);const r=this.print(e,n,o);return r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):`{${r}}`}printPassword(e,n,o,r){const s=o?this.printInFString.bind(this):this.print.bind(this);return Qr(e)?s(r||"password",e):s(r||"password",n,e)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([e,n])=>`${e} = ${n}`).join(`
4
+ `)}}class $g extends pt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.ssl?", connect_args={'sslmode': 'require'}":"",n=this.secrets.printPassword(this.connection.password,"POSTGRES_PASSWORD",!0),o=this.secrets.printInFString("username",this.connection.username),r=this.secrets.printInFString("host",this.connection.host),s=this.secrets.printInFString("port",this.connection.port),a=this.secrets.printInFString("database",this.connection.database);return Ue(`
5
5
  DATABASE_URL = f"postgresql://${o}:${n}@${r}:${s}/${a}"
6
6
  engine = ${this.orm}.create_engine(DATABASE_URL${e})
7
- `)}}class Jg extends xt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.ssl?", connect_args={'ssl': {'ssl-mode': 'preferred'}}":"",n=this.secrets.printPassword(this.connection.password,"MYSQL_PASSWORD",!0),o=this.secrets.printInFString("database",this.connection.database),r=this.secrets.printInFString("username",this.connection.username),s=this.secrets.printInFString("host",this.connection.host),a=this.secrets.printInFString("port",this.connection.port);return Ve(`
7
+ `)}}class Vg extends pt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.ssl?", connect_args={'ssl': {'ssl-mode': 'preferred'}}":"",n=this.secrets.printPassword(this.connection.password,"MYSQL_PASSWORD",!0),o=this.secrets.printInFString("database",this.connection.database),r=this.secrets.printInFString("username",this.connection.username),s=this.secrets.printInFString("host",this.connection.host),a=this.secrets.printInFString("port",this.connection.port);return Ue(`
8
8
  DATABASE_URL = f"mysql+pymysql://${r}:${n}@${s}:${a}/${o}"
9
9
  engine = ${this.orm}.create_engine(DATABASE_URL${e})
10
- `)}}class Kg extends xt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.database?this.secrets.printInFString("database",this.connection.database):"",n=e.startsWith("{")&&e.endsWith("}")?`DATABASE_URL = f"sqlite:///${e}"`:`DATABASE_URL = "sqlite:///${e}"`;return Ve(`
10
+ `)}}class Gg extends pt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.database?this.secrets.printInFString("database",this.connection.database):"",n=e.startsWith("{")&&e.endsWith("}")?`DATABASE_URL = f"sqlite:///${e}"`:`DATABASE_URL = "sqlite:///${e}"`;return Ue(`
11
11
  ${n}
12
12
  engine = ${this.orm}.create_engine(DATABASE_URL)
13
- `)}}class Yg extends xt{generateImports(){return["from snowflake.sqlalchemy import URL"]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"SNOWFLAKE_PASSWORD",!1),n={account:this.secrets.print("account",this.connection.account),user:this.secrets.print("user",this.connection.username),database:this.secrets.print("database",this.connection.database),warehouse:this.connection.warehouse?this.secrets.print("warehouse",this.connection.warehouse):void 0,schema:this.connection.schema?this.secrets.print("schema",this.connection.schema):void 0,role:this.connection.role?this.secrets.print("role",this.connection.role):void 0,password:e};return Ve(`
13
+ `)}}class qg extends pt{generateImports(){return["from snowflake.sqlalchemy import URL"]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"SNOWFLAKE_PASSWORD",!1),n={account:this.secrets.print("account",this.connection.account),user:this.secrets.print("user",this.connection.username),database:this.secrets.print("database",this.connection.database),warehouse:this.connection.warehouse?this.secrets.print("warehouse",this.connection.warehouse):void 0,schema:this.connection.schema?this.secrets.print("schema",this.connection.schema):void 0,role:this.connection.role?this.secrets.print("role",this.connection.role):void 0,password:e};return Ue(`
14
14
  engine = ${this.orm}.create_engine(
15
15
  URL(
16
16
  ${Zr(n,o=>` ${o}`)},
17
17
  )
18
18
  )
19
- `)}}class Xg extends xt{generateImports(){return["import json"]}generateConnectionCode(){const e=this.secrets.printInFString("project",this.connection.project),n=this.secrets.printInFString("dataset",this.connection.dataset);return Ve(`
19
+ `)}}class Hg extends pt{generateImports(){return["import json"]}generateConnectionCode(){const e=this.secrets.printInFString("project",this.connection.project),n=this.secrets.printInFString("dataset",this.connection.dataset);return Ue(`
20
20
  credentials = json.loads("""${this.connection.credentials_json}""")
21
21
  engine = ${this.orm}.create_engine(f"bigquery://${e}/${n}", credentials_info=credentials)
22
- `)}}class Qg extends xt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printInFString("database",this.connection.database||":memory:");return Ve(`
22
+ `)}}class Jg extends pt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printInFString("database",this.connection.database||":memory:");return Ue(`
23
23
  DATABASE_URL = "${e}"
24
24
  engine = ${this.orm}.connect(DATABASE_URL, read_only=${ho(this.connection.read_only)})
25
- `)}}class Zg extends xt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printInFString("database",this.connection.database);if(!this.connection.token)return Ve(`
25
+ `)}}class Kg extends pt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printInFString("database",this.connection.database);if(!this.connection.token)return Ue(`
26
26
  conn = duckdb.connect("md:${e}")
27
- `);const n=this.secrets.printPassword(this.connection.token,"MOTHERDUCK_TOKEN",!1);return Ve(`
27
+ `);const n=this.secrets.printPassword(this.connection.token,"MOTHERDUCK_TOKEN",!1);return Ue(`
28
28
  conn = duckdb.connect("md:${e}", config={"motherduck_token": ${n}})
29
- `)}}class e0 extends xt{generateImports(){return["import clickhouse_connect"]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"CLICKHOUSE_PASSWORD",!1),n={host:this.secrets.print("host",this.connection.host),user:this.secrets.print("user",this.connection.username),secure:this.secrets.print("secure",this.connection.secure),port:this.connection.port?this.secrets.print("port",this.connection.port):void 0,password:this.connection.password?e:void 0};return Ve(`
29
+ `)}}class Yg extends pt{generateImports(){return["import clickhouse_connect"]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"CLICKHOUSE_PASSWORD",!1),n={host:this.secrets.print("host",this.connection.host),user:this.secrets.print("user",this.connection.username),secure:this.secrets.print("secure",this.connection.secure),port:this.connection.port?this.secrets.print("port",this.connection.port):void 0,password:this.connection.password?e:void 0};return Ue(`
30
30
  engine = ${this.orm}.get_client(
31
31
  ${Zr(n,o=>` ${o}`)},
32
32
  )
33
- `)}}class t0 extends xt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"TIMEPLUS_PASSWORD",!0),n=this.secrets.printInFString("username",this.connection.username),o=this.secrets.printInFString("host",this.connection.host),r=this.secrets.printInFString("port",this.connection.port);return Ve(`
33
+ `)}}class Xg extends pt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"TIMEPLUS_PASSWORD",!0),n=this.secrets.printInFString("username",this.connection.username),o=this.secrets.printInFString("host",this.connection.host),r=this.secrets.printInFString("port",this.connection.port);return Ue(`
34
34
  DATABASE_URL = f"timeplus://${n}:${e}@${o}:${r}"
35
35
  engine = ${this.orm}.create_engine(DATABASE_URL)
36
- `)}}class n0 extends xt{generateImports(){return["import chdb"]}generateConnectionCode(){const e=this.secrets.print("database",this.connection.database)||'""';return Ve(`
36
+ `)}}class Qg extends pt{generateImports(){return["import chdb"]}generateConnectionCode(){const e=this.secrets.print("database",this.connection.database)||'""';return Ue(`
37
37
  engine = ${this.orm}.connect(${e}, read_only=${ho(this.connection.read_only)})
38
- `)}}class o0 extends xt{generateImports(){return this.connection.async_support?["import aiotrino"]:["import trino.sqlalchemy"]}generateConnectionCode(){const e=this.connection.async_support?"aiotrino":"trino",n=this.connection.schema?`/${this.connection.schema}`:"",o=this.secrets.printInFString("username",this.connection.username),r=this.secrets.printInFString("host",this.connection.host),s=this.secrets.printInFString("port",this.connection.port),a=this.secrets.printInFString("database",this.connection.database),l=this.secrets.printPassword(this.connection.password,"TRINO_PASSWORD",!0);return Ve(`
38
+ `)}}class Zg extends pt{generateImports(){return this.connection.async_support?["import aiotrino"]:["import trino.sqlalchemy"]}generateConnectionCode(){const e=this.connection.async_support?"aiotrino":"trino",n=this.connection.schema?`/${this.connection.schema}`:"",o=this.secrets.printInFString("username",this.connection.username),r=this.secrets.printInFString("host",this.connection.host),s=this.secrets.printInFString("port",this.connection.port),a=this.secrets.printInFString("database",this.connection.database),l=this.secrets.printPassword(this.connection.password,"TRINO_PASSWORD",!0);return Ue(`
39
39
  engine = ${this.orm}.create_engine(f"${e}://${o}:${l}@${r}:${s}/${a}${n}")
40
- `)}}class r0 extends xt{generateImports(){switch(this.connection.catalog.type){case"REST":return["from pyiceberg.catalog.rest import RestCatalog"];case"SQL":return["from pyiceberg.catalog.sql import SqlCatalog"];case"Hive":return["from pyiceberg.catalog.hive import HiveCatalog"];case"Glue":return["from pyiceberg.catalog.glue import GlueCatalog"];case"DynamoDB":return["from pyiceberg.catalog.dynamodb import DynamoDBCatalog"];default:Il(this.connection.catalog)}}generateConnectionCode(){let e={...this.connection.catalog};e=Object.fromEntries(Object.entries(e).filter(([a,l])=>l!=null&&l!==""&&a!=="type"));for(const[a,l]of Object.entries(e))Qr(l)?e[a]=this.secrets.print(a,l):typeof l=="string"&&(e[a]=`"${l}"`);const n=(o=e,r=a=>` ${a}`,Object.entries(o).filter(([,a])=>a!=null&&a!=="").map(([a,l])=>{const c=`"${a}"`;return r(typeof l=="boolean"?`${c}: ${ho(l)}`:`${c}: ${l}`)}).join(`,
41
- `));var o,r;const s=`"${this.connection.name}"`;switch(this.connection.catalog.type){case"REST":return Ve(`
40
+ `)}}class e0 extends pt{generateImports(){switch(this.connection.catalog.type){case"REST":return["from pyiceberg.catalog.rest import RestCatalog"];case"SQL":return["from pyiceberg.catalog.sql import SqlCatalog"];case"Hive":return["from pyiceberg.catalog.hive import HiveCatalog"];case"Glue":return["from pyiceberg.catalog.glue import GlueCatalog"];case"DynamoDB":return["from pyiceberg.catalog.dynamodb import DynamoDBCatalog"];default:Il(this.connection.catalog)}}generateConnectionCode(){let e={...this.connection.catalog};e=Object.fromEntries(Object.entries(e).filter(([a,l])=>l!=null&&l!==""&&a!=="type"));for(const[a,l]of Object.entries(e))Qr(l)?e[a]=this.secrets.print(a,l):typeof l=="string"&&(e[a]=`"${l}"`);const n=(o=e,r=a=>` ${a}`,Object.entries(o).filter(([,a])=>a!=null&&a!=="").map(([a,l])=>{const c=`"${a}"`;return r(typeof l=="boolean"?`${c}: ${ho(l)}`:`${c}: ${l}`)}).join(`,
41
+ `));var o,r;const s=`"${this.connection.name}"`;switch(this.connection.catalog.type){case"REST":return Ue(`
42
42
  catalog = RestCatalog(
43
43
  ${s},
44
44
  **{
45
45
  ${n}
46
46
  },
47
47
  )
48
- `);case"SQL":return Ve(`
48
+ `);case"SQL":return Ue(`
49
49
  catalog = SqlCatalog(
50
50
  ${s},
51
51
  **{
52
52
  ${n}
53
53
  },
54
54
  )
55
- `);case"Hive":return Ve(`
55
+ `);case"Hive":return Ue(`
56
56
  catalog = HiveCatalog(
57
57
  ${s},
58
58
  **{
59
59
  ${n}
60
60
  },
61
61
  )
62
- `);case"Glue":return Ve(`
62
+ `);case"Glue":return Ue(`
63
63
  catalog = GlueCatalog(
64
64
  ${s},
65
65
  **{
66
66
  ${n}
67
67
  },
68
68
  )
69
- `);case"DynamoDB":return Ve(`
69
+ `);case"DynamoDB":return Ue(`
70
70
  catalog = DynamoDBCatalog(
71
71
  ${s},
72
72
  **{
73
73
  ${n}
74
74
  },
75
75
  )
76
- `);default:Il(this.connection.catalog)}}}class s0 extends xt{generateImports(){return["import ibis","from datafusion import SessionContext"]}generateConnectionCode(){return this.connection.sessionContext?Ve(`
76
+ `);default:Il(this.connection.catalog)}}}class t0 extends pt{generateImports(){return["from datafusion import SessionContext"]}generateConnectionCode(){return this.connection.sessionContext?Ue(`
77
77
  ctx = SessionContext()
78
78
  # Sample table
79
79
  _ = ctx.from_pydict({"a": [1, 2, 3]}, "my_table")
80
80
 
81
81
  con = ibis.datafusion.connect(ctx)
82
- `):Ve(`
82
+ `):Ue(`
83
83
  con = ibis.datafusion.connect()
84
- `)}}class a0 extends xt{generateImports(){return["import ibis","from pyspark.sql import SparkSession"]}generateConnectionCode(){if(this.connection.host||this.connection.port){const e=this.secrets.printInFString("host",this.connection.host),n=this.secrets.printInFString("port",this.connection.port);return Ve(`
84
+ `)}}class n0 extends pt{generateImports(){return["from pyspark.sql import SparkSession"]}generateConnectionCode(){if(this.connection.host||this.connection.port){const e=this.secrets.printInFString("host",this.connection.host),n=this.secrets.printInFString("port",this.connection.port);return Ue(`
85
85
  session = SparkSession.builder.remote(f"sc://${e}:${n}").getOrCreate()
86
86
  con = ibis.pyspark.connect(session)
87
- `)}return Ve(`
87
+ `)}return Ue(`
88
88
  con = ibis.pyspark.connect()
89
- `)}}class i0 extends xt{generateImports(){return["import redshift_connector"]}generateConnectionCode(){const e=this.secrets.print("host",this.connection.host),n=this.secrets.print("port",this.connection.port),o=this.secrets.print("database",this.connection.database);if(this.connection.connectionType.type==="IAM credentials"){const l=this.secrets.print("aws_access_key_id",this.connection.connectionType.aws_access_key_id),c=this.secrets.print("aws_secret_access_key",this.connection.connectionType.aws_secret_access_key),d=this.connection.connectionType.aws_session_token?this.secrets.print("aws_session_token",this.connection.connectionType.aws_session_token):void 0,u={iam:!0,host:e,port:n,region:`"${this.connection.connectionType.region}"`,database:o,access_key_id:l,secret_access_key:c,...d&&{session_token:d}};return Ve(`
89
+ `)}}class o0 extends pt{generateImports(){return["import redshift_connector"]}generateConnectionCode(){const e=this.secrets.print("host",this.connection.host),n=this.secrets.print("port",this.connection.port),o=this.secrets.print("database",this.connection.database);if(this.connection.connectionType.type==="IAM credentials"){const l=this.secrets.print("aws_access_key_id",this.connection.connectionType.aws_access_key_id),c=this.secrets.print("aws_secret_access_key",this.connection.connectionType.aws_secret_access_key),d=this.connection.connectionType.aws_session_token?this.secrets.print("aws_session_token",this.connection.connectionType.aws_session_token):void 0,u={iam:!0,host:e,port:n,region:`"${this.connection.connectionType.region}"`,database:o,access_key_id:l,secret_access_key:c,...d&&{session_token:d}};return Ue(`
90
90
  con = redshift_connector.connect(
91
91
  ${Zr(u,h=>` ${h}`)},
92
92
  )
93
- `)}const r=this.connection.connectionType.user?this.secrets.print("user",this.connection.connectionType.user):void 0,s=this.connection.connectionType.password?this.secrets.printPassword(this.connection.connectionType.password,"REDSHIFT_PASSWORD",!1):void 0,a={host:e,port:n,database:o,...r&&{user:r},...s&&{password:s}};return Ve(`
93
+ `)}const r=this.connection.connectionType.user?this.secrets.print("user",this.connection.connectionType.user):void 0,s=this.connection.connectionType.password?this.secrets.printPassword(this.connection.connectionType.password,"REDSHIFT_PASSWORD",!1):void 0,a={host:e,port:n,database:o,...r&&{user:r},...s&&{password:s}};return Ue(`
94
94
  con = redshift_connector.connect(
95
95
  ${Zr(a,l=>` ${l}`)},
96
96
  )
97
- `)}}class l0{constructor(){this.secrets=new qg}createGenerator(e,n){switch(e.type){case"postgres":return new Hg(e,n,this.secrets);case"mysql":return new Jg(e,n,this.secrets);case"sqlite":return new Kg(e,n,this.secrets);case"snowflake":return new Yg(e,n,this.secrets);case"bigquery":return new Xg(e,n,this.secrets);case"duckdb":return new Qg(e,n,this.secrets);case"motherduck":return new Zg(e,n,this.secrets);case"clickhouse_connect":return new e0(e,n,this.secrets);case"timeplus":return new t0(e,n,this.secrets);case"chdb":return new n0(e,n,this.secrets);case"trino":return new o0(e,n,this.secrets);case"iceberg":return new r0(e,n,this.secrets);case"datafusion":return new s0(e,n,this.secrets);case"pyspark":return new a0(e,n,this.secrets);case"redshift":return new i0(e,n,this.secrets);default:Il(e)}}}function ho(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function Zr(t,e){return Object.entries(t).filter(([,n])=>n!=null&&n!=="").map(([n,o])=>e(typeof o=="boolean"?`${n}=${ho(o)}`:`${n}=${o}`)).join(`,
98
- `)}Wc=function(t){return t.sort((e,n)=>e.provider==="env"?1:n.provider==="env"?-1:0)},Oc=t=>{const e=P.c(43),{providerNames:n,onClose:o,onSuccess:r}=t,{writeSecret:s}=qe(),[a,l]=me.useState(""),[c,d]=me.useState(""),[u,h]=me.useState(n[0]);let m;e[0]!==a||e[1]!==u||e[2]!==r||e[3]!==c||e[4]!==s?(m=async T=>{if(T.preventDefault(),u)if(a&&c&&u)try{await s({key:a,value:c,provider:"dotenv",name:u}),ze({title:"Secret created",description:"The secret has been created successfully."}),r(a)}catch{ze({title:"Error",description:"Failed to create secret. Please try again.",variant:"danger"})}else ze({title:"Error",description:"Please fill in all fields.",variant:"danger"});else ze({title:"Error",description:"No location selected for the secret.",variant:"danger"})},e[0]=a,e[1]=u,e[2]=r,e[3]=c,e[4]=s,e[5]=m):m=e[5];const p=m;let b,x,f,g,y,w,j,C,N,k,E,_,I,A,O,D;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsxs(yr,{children:[i.jsx(so,{children:"Add Secret"}),i.jsx(vr,{children:"Add a new secret to your environment variables."})]}),e[6]=b):b=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Ao,{htmlFor:"key",children:"Key"}),e[7]=x):x=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(f=T=>{l(T.target.value.replaceAll(/\W/g,"_"))},e[8]=f):f=e[8],e[9]!==a?(g=i.jsxs("div",{className:"grid gap-2",children:[x,i.jsx(ao,{id:"key",value:a,onChange:f,placeholder:"MY_SECRET_KEY",required:!0})]}),e[9]=a,e[10]=g):g=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(Ao,{htmlFor:"value",children:"Value"}),e[11]=y):y=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(w=T=>d(T.target.value),e[12]=w):w=e[12],e[13]!==c?(j=i.jsx(ao,{id:"value",type:"text",value:c,onChange:w,required:!0,autoComplete:"off"}),e[13]=c,e[14]=j):j=e[14],e[15]===Symbol.for("react.memo_cache_sentinel")?(C=window.location.href.startsWith("http://")&&i.jsx(yp,{children:"Note: You are sending this key over http."}),e[15]=C):C=e[15],e[16]!==j?(N=i.jsxs("div",{className:"grid gap-2",children:[y,j,C]}),e[16]=j,e[17]=N):N=e[17],e[18]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx(Ao,{htmlFor:"location",children:"Location"}),e[18]=k):k=e[18],e[19]!==n.length?(E=n.length===0&&i.jsx("p",{className:"text-sm text-muted-foreground",children:"No dotenv locations configured."}),e[19]=n.length,e[20]=E):E=e[20],e[21]!==u||e[22]!==n?(_=n.length>0&&i.jsxs(Al,{value:u,onValueChange:T=>h(T),children:[i.jsx(Tl,{children:i.jsx(Dl,{placeholder:"Select a provider"})}),i.jsx(Ml,{children:n.map(c0)})]}),e[21]=u,e[22]=n,e[23]=_):_=e[23],e[24]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsxs(yp,{children:["You can configure the location by setting the"," ",i.jsx(Rl,{href:"https://links.marimo.app/dotenv",children:"dotenv configuration"}),"."]}),e[24]=I):I=e[24],e[25]!==E||e[26]!==_?(A=i.jsxs("div",{className:"grid gap-2",children:[k,E,_,I]}),e[25]=E,e[26]=_,e[27]=A):A=e[27],e[28]!==N||e[29]!==A||e[30]!==g?(O=i.jsxs("div",{className:"grid gap-4 py-4",children:[g,N,A]}),e[28]=N,e[29]=A,e[30]=g,e[31]=O):O=e[31],e[32]!==o?(D=i.jsx(ye,{type:"button",variant:"outline",onClick:o,children:"Cancel"}),e[32]=o,e[33]=D):D=e[33];const M=!a||!c||!u;let R,L,z;return e[34]!==M?(R=i.jsx(ye,{type:"submit",disabled:M,children:"Add Secret"}),e[34]=M,e[35]=R):R=e[35],e[36]!==D||e[37]!==R?(L=i.jsxs(Hs,{children:[D,R]}),e[36]=D,e[37]=R,e[38]=L):L=e[38],e[39]!==p||e[40]!==O||e[41]!==L?(z=i.jsx(io,{children:i.jsxs("form",{onSubmit:p,children:[b,O,L]})}),e[39]=p,e[40]=O,e[41]=L,e[42]=z):z=e[42],z};function c0(t){return i.jsx(Ol,{value:t,children:t},t)}const Jd=S.createContext({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:Bn.NOOP}),d0=t=>{const e=P.c(14),{children:n}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const{data:r,isPending:s,error:a,refetch:l}=wr(f0,o);let c,d,u,h;return e[1]!==(r==null?void 0:r.secretKeys)?(c=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=c):c=e[2],e[3]!==(r==null?void 0:r.providerNames)?(d=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=d):d=e[4],e[5]!==a||e[6]!==s||e[7]!==l||e[8]!==c||e[9]!==d?(u={secretKeys:c,providerNames:d,loading:s,error:a,refreshSecrets:l},e[5]=a,e[6]=s,e[7]=l,e[8]=c,e[9]=d,e[10]=u):u=e[10],e[11]!==n||e[12]!==u?(h=i.jsx(Jd,{value:u,children:n}),e[11]=n,e[12]=u,e[13]=h):h=e[13],h};function u0(t){return t.provider!=="env"}function h0(t){return t.name}function m0(t){return t.keys}async function f0(){const t=await bC.request({}),e=Wc(t.secrets).filter(u0).map(h0);return{secretKeys:t.secrets.flatMap(m0).sort(),providerNames:e}}let Ha,Ja,Kd,Yd,Xd,Qd,Ka;Ha=[{name:"PostgreSQL",schema:Dd,color:"#336791",logo:"postgres",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"MySQL",schema:Md,color:"#00758F",logo:"mysql",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"SQLite",schema:Od,color:"#003B57",logo:"sqlite",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DuckDB",schema:Rd,color:"#FFD700",logo:"duckdb",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"MotherDuck",schema:Ld,color:"#ff9538",logo:"motherduck",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"Snowflake",schema:Fd,color:"#29B5E8",logo:"snowflake",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse",schema:Pd,color:"#2C2C1D",logo:"clickhouse",connectionLibraries:{libraries:["clickhouse_connect"],preferred:"clickhouse_connect"}},{name:"Timeplus",schema:zd,color:"#B83280",logo:"timeplus",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"BigQuery",schema:Bd,color:"#4285F4",logo:"bigquery",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse Embedded",schema:Ud,color:"#f2b611",logo:"clickhouse",connectionLibraries:{libraries:["chdb"],preferred:"chdb"}},{name:"Trino",schema:Wd,color:"#d466b6",logo:"trino",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DataFusion",schema:Vd,color:"#202A37",logo:"datafusion",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"PySpark",schema:Gd,color:"#1C5162",logo:"pyspark",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"Redshift",schema:qd,color:"#522BAE",logo:"redshift",connectionLibraries:{libraries:["redshift"],preferred:"redshift"}}],Ja=[{name:"Iceberg",schema:$d,color:"#000000",logo:"iceberg",connectionLibraries:{libraries:["pyiceberg"],preferred:"pyiceberg"}}],Kd=t=>{const e=P.c(14),{onSelect:n}=t;let o;e[0]!==n?(o=h=>{const{name:m,schema:p,color:b,logo:x}=h;return i.jsxs("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:{backgroundColor:b},onClick:()=>n(p),children:[i.jsx(vk,{name:x,className:"w-8 h-8 text-white brightness-0 invert dark:invert"}),i.jsx("span",{className:"text-white font-medium text-lg",children:m})]},m)},e[0]=n,e[1]=o):o=e[1];const r=o;let s,a,l,c,d,u;return e[2]!==r?(s=Ha.map(r),e[2]=r,e[3]=s):s=e[3],e[4]!==s?(a=i.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[4]=s,e[5]=a):a=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("h4",{className:"font-semibold text-muted-foreground text-lg flex items-center gap-4",children:["Data Catalogs",i.jsx("hr",{className:"flex-1"})]}),e[6]=l):l=e[6],e[7]!==r?(c=Ja.map(r),e[7]=r,e[8]=c):c=e[8],e[9]!==c?(d=i.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:c}),e[9]=c,e[10]=d):d=e[10],e[11]!==a||e[12]!==d?(u=i.jsxs(i.Fragment,{children:[a,l,d]}),e[11]=a,e[12]=d,e[13]=u):u=e[13],u},Yd=[{isMatch:t=>{if(t instanceof jp||t instanceof pk){const{optionRegex:e}=fe.parse(t._def.description||"");return!!e}return!1},Component:({schema:t,form:e,path:n})=>{const{secretKeys:o,providerNames:r,refreshSecrets:s}=S.use(Jd),{openModal:a,closeModal:l}=Pn(),{label:c,description:d,optionRegex:u=""}=fe.parse(t._def.description||""),[h,m]=nt(o,p=>new RegExp(u,"i").test(p));return i.jsx(vp,{control:e.control,name:n,render:({field:p})=>i.jsxs(wp,{children:[i.jsx(hk,{children:c}),i.jsx(mk,{children:d}),i.jsx(kp,{children:i.jsxs("div",{className:"flex gap-2",children:[t instanceof jp?i.jsx(ao,{...p,value:p.value,onChange:p.onChange,className:ue("flex-1")}):i.jsx(fk,{...p,value:p.value,onChange:p.onChange,className:"flex-1"}),i.jsxs(zn,{children:[i.jsx(Un,{asChild:!0,children:i.jsx(ye,{variant:"outline",size:"icon",className:ue(Qr(p.value)&&"bg-accent"),children:i.jsx(_c,{className:"h-3 w-3"})})}),i.jsxs(Wn,{align:"end",className:"max-h-60 overflow-y-auto",children:[i.jsxs(lo,{onSelect:()=>{a(i.jsx(Oc,{providerNames:r,onSuccess:b=>{s(),p.onChange(qa(b)),l()},onClose:l}))},children:[i.jsx(Wr,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),h.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(En,{}),i.jsx(Cp,{children:"Recommended"})]}),h.map(b=>i.jsx(lo,{onSelect:()=>p.onChange(qa(b)),children:b},b)),m.length>0&&i.jsx(En,{}),m.map(b=>i.jsx(lo,{onSelect:()=>p.onChange(qa(b)),children:b},b))]})]})]})}),i.jsx(Np,{})]})})}}],Xd=t=>{var $;const e=P.c(49),{schema:n,onSubmit:o,onBack:r}=t;let s,a,l;e[0]!==n?(s=xk(n),e[0]=n,e[1]=s):s=e[1],e[2]!==n?(a=Sp(n),e[2]=n,e[3]=a):a=e[3],e[4]!==s||e[5]!==a?(l={defaultValues:s,resolver:a,reValidateMode:"onChange"},e[4]=s,e[5]=a,e[6]=l):l=e[6];const c=Ep(l),d=($=[...Ha,...Ja].find(W=>W.schema===n))==null?void 0:$.connectionLibraries,[u,h]=S.useState((d==null?void 0:d.preferred)??"sqlalchemy"),{createNewCell:m}=Ye(),p=yk();let b;e[7]!==m||e[8]!==p?(b=W=>{m({code:W,before:!1,cellId:p??"__end__",skipIfCodeExists:!0})},e[7]=m,e[8]=p,e[9]=b):b=e[9];const x=b;let f;e[10]!==x||e[11]!==o||e[12]!==u?(f=W=>{x((function(G,X){if(!(X in Hd))throw new Error(`Unsupported library: ${X}`);Gg.parse(G);const H=new l0,Y=H.createGenerator(G,X),K=Y.generateConnectionCode(),V=H.secrets,q=[...new Set([...V.imports,...Y.imports])].sort();q.push("");const U=V.formatSecrets();return U&&q.push(U),q.push(K.trim()),q.join(`
99
- `)})(W,u)),o()},e[10]=x,e[11]=o,e[12]=u,e[13]=f):f=e[13];const g=f;let y;e[14]!==c||e[15]!==g?(y=c.handleSubmit(g),e[14]=c,e[15]=g,e[16]=y):y=e[16];let w,j;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(wk,{}),e[17]=w):w=e[17],e[18]!==c||e[19]!==n?(j=i.jsx(d0,{children:i.jsx(kk,{schema:n,form:c,renderers:Yd,children:w})}),e[18]=c,e[19]=n,e[20]=j):j=e[20];let C;e[21]!==r?(C=i.jsx(ye,{type:"button",variant:"outline",onClick:r,children:"Back"}),e[21]=r,e[22]=C):C=e[22];const N=!c.formState.isValid;let k,E;e[23]!==N?(k=i.jsx(ye,{type:"submit",disabled:N,children:"Add"}),e[23]=N,e[24]=k):k=e[24],e[25]!==C||e[26]!==k?(E=i.jsxs("div",{className:"flex gap-2",children:[C,k]}),e[25]=C,e[26]=k,e[27]=E):E=e[27];const _=Al;let I,A;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=W=>h(W),e[28]=I):I=e[28],e[29]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsxs("div",{className:"flex flex-col gap-1 items-end",children:[i.jsx(Tl,{children:i.jsx(Dl,{placeholder:"Select a library"})}),i.jsx("span",{className:"text-xs text-muted-foreground",children:"Preferred connection library"})]}),e[29]=A):A=e[29];const O=Ml,D=_p,M=d==null?void 0:d.libraries.map(p0);let R,L,z,T,F;return e[30]!==D||e[31]!==M?(R=i.jsx(D,{children:M}),e[30]=D,e[31]=M,e[32]=R):R=e[32],e[33]!==O||e[34]!==R?(L=i.jsx(O,{children:R}),e[33]=O,e[34]=R,e[35]=L):L=e[35],e[36]!==_||e[37]!==u||e[38]!==I||e[39]!==A||e[40]!==L?(z=i.jsx("div",{children:i.jsxs(_,{value:u,onValueChange:I,children:[A,L]})}),e[36]=_,e[37]=u,e[38]=I,e[39]=A,e[40]=L,e[41]=z):z=e[41],e[42]!==E||e[43]!==z?(T=i.jsxs("div",{className:"flex gap-2 justify-between",children:[E,z]}),e[42]=E,e[43]=z,e[44]=T):T=e[44],e[45]!==T||e[46]!==y||e[47]!==j?(F=i.jsxs("form",{onSubmit:y,className:"space-y-4",children:[j,T]}),e[45]=T,e[46]=y,e[47]=j,e[48]=F):F=e[48],F},Qd=t=>{const e=P.c(5),{onSubmit:n}=t,[o,r]=S.useState(null);if(!o){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(Kd,{onSelect:r}),e[0]=l):l=e[0],l}let s,a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=()=>r(null),e[1]=s):s=e[1],e[2]!==n||e[3]!==o?(a=i.jsx(Xd,{schema:o,onSubmit:n,onBack:s}),e[2]=n,e[3]=o,e[4]=a):a=e[4],a},fg=t=>{const e=P.c(6),{children:n}=t,[o,r]=S.useState(!1);let s,a,l;return e[0]!==n?(s=i.jsx(gk,{asChild:!0,children:n}),e[0]=n,e[1]=s):s=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(Ka,{onClose:()=>r(!1)}),e[2]=a):a=e[2],e[3]!==o||e[4]!==s?(l=i.jsxs(bk,{open:o,onOpenChange:r,children:[s,a]}),e[3]=o,e[4]=s,e[5]=l):l=e[5],l},Ka=t=>{const e=P.c(4),{onClose:n}=t;let o,r,s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(so,{children:"Add Connection"}),e[0]=o):o=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsxs(yr,{className:"mb-4",children:[o,i.jsxs(vr,{children:["Connect to your database or data catalog to query data directly from your notebook. Learn more about how to connect to your database in our"," ",i.jsx(Rl,{href:"https://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database",children:"docs."})]})]}),e[1]=r):r=e[1],e[2]!==n?(s=i.jsxs(io,{className:"max-h-[75vh] overflow-y-auto",children:[r,i.jsx(Qd,{onSubmit:()=>n()})]}),e[2]=n,e[3]=s):s=e[3],s};function p0(t){return i.jsx(Ol,{value:t,children:Hd[t]},t)}const g0=()=>{const t=P.c(7),{selectedLayout:e}=Q1(),{setLayoutView:n}=Z1();if(Qt()&&!Ys("wasm_layouts"))return null;let o,r,s,a;return t[0]!==n?(o=l=>n(l),t[0]=n,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(Tl,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:i.jsx(Dl,{placeholder:"Select a view"})}),t[2]=r):r=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(Ml,{children:i.jsxs(_p,{children:[i.jsx(jk,{children:"View as"}),eg.map(x0)]})}),t[3]=s):s=t[3],t[4]!==e||t[5]!==o?(a=i.jsxs(Al,{"data-testid":"layout-select",value:e,onValueChange:o,children:[r,s]}),t[4]=e,t[5]=o,t[6]=a):a=t[6],a};function b0(t){const e=Zd(t);return i.jsx(e,{className:"h-4 w-4"})}function Zd(t){switch(t){case"vertical":return od;case"grid":return eC;case"slides":return Ba;default:return Fl(t),Bl}}function eu(t){return Ll(t)}function x0(t){return i.jsx(Ol,{value:t,children:i.jsxs("div",{className:"flex items-center gap-1.5 leading-5",children:[b0(t),i.jsx("span",{children:eu(t)})]})},t)}function tu(){const t=P.c(4),{openConfirm:e}=Pn(),n=Ct(Nt),{sendRestart:o}=qe();let r;return t[0]!==e||t[1]!==o||t[2]!==n?(r=()=>{e({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:i.jsx(Sk,{onClick:async()=>{n({state:ht.CLOSING}),await o(),Ek()},"aria-label":"Confirm Restart",children:"Restart"})})},t[0]=e,t[1]=o,t[2]=n,t[3]=r):r=t[3],r}const Jo=t=>{t==null||t.preventDefault(),t==null||t.stopPropagation()};Lc=function(){var H,Y;const t=P.c(39),e=zl(),{openModal:n,closeModal:o}=Pn(),{toggleApplication:r}=kr(),{selectedPanel:s}=Xs(),[a]=_n(Sl),l=ie(To),c=(()=>{const{updateCellConfig:K}=Ye(),{saveCellConfig:V}=qe();return S.useCallback(async()=>{const q=new Nk,U=Mt(),ne=U.cellIds.inOrderIds,Q={};for(const oe of ne){if(U.cellData[oe]===void 0)continue;const{code:se,config:ae}=U.cellData[oe];ae.hide_code||q.isSupported(se)&&(Q[oe]={hide_code:!0})}const ee=Pl.entries(Q);if(ee.length!==0){await V({configs:Q});for(const[oe,se]of ee)K({cellId:oe,config:se})}},[K])})(),[d]=Qs(),{updateCellConfig:u,undoDeleteCell:h,clearAllCellOutputs:m,upsertSetupCell:p,collapseAllCells:b,expandAllCells:x}=Ye(),f=tu(),g=_d(),y=(function(K){const V=P.c(5),{openPrompt:q,closeModal:U}=Pn(),{sendCopy:ne}=qe();let Q;return V[0]!==U||V[1]!==q||V[2]!==ne||V[3]!==K?(Q=()=>{if(!K)return null;const ee=Ck.guessDeliminator(K),oe=Ot.basename(K);q({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${oe}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:se=>{const ae=ee.join(Ot.dirname(K),se);ne({source:K,destination:ae}).then(()=>{U(),ze({title:"Notebook copied",description:"A copy of the notebook has been created."}),tC(ae)})}})},V[0]=U,V[1]=q,V[2]=ne,V[3]=K,V[4]=Q):Q=V[4],Q})(e),w=Ct(_a),j=Ct(nC),C=Ct(oC),{exportAsMarkdown:N,readCode:k,saveCellConfig:E}=qe(),_=ie(_k),I=ie(Ik),A=ie(Ip),{selectedLayout:O}=Q1(),{setLayoutView:D}=Z1(),M=Ed(),R=((H=d.sharing)==null?void 0:H.html)??!0,L=((Y=d.sharing)==null?void 0:Y.wasm)??!0,z=B0;let T;t[0]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx(hd,{size:14,strokeWidth:1.5}),t[0]=T):T=t[0];const F=!R&&!L;let $;t[1]===Symbol.for("react.memo_cache_sentinel")?($=i.jsx(Fk,{size:14,strokeWidth:1.5}),t[1]=$):$=t[1];const W=!R;let G,X;return t[2]!==o||t[3]!==n?(G=async()=>{n(i.jsx(Wg,{onClose:o}))},t[2]=o,t[3]=n,t[4]=G):G=t[4],t[5]!==A||t[6]!==m||t[7]!==o||t[8]!==b||t[9]!==y||t[10]!==x||t[11]!==N||t[12]!==e||t[13]!==_||t[14]!==I||t[15]!==c||t[16]!==l||t[17]!==n||t[18]!==k||t[19]!==f||t[20]!==g||t[21]!==E||t[22]!==O||t[23]!==s||t[24]!==w||t[25]!==C||t[26]!==D||t[27]!==j||t[28]!==L||t[29]!==F||t[30]!==W||t[31]!==G||t[32]!==r||t[33]!==M||t[34]!==h||t[35]!==u||t[36]!==p||t[37]!==a.mode?(X=[{icon:T,label:"Share",handle:Jo,hidden:F,dropdown:[{icon:$,label:"Publish HTML to web",hidden:W,handle:G},{icon:i.jsx(q1,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!L,handle:async()=>{const K=await k(),V=Ak({code:K.contents});await Eo(V),ze({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:i.jsx(Dk,{size:14,strokeWidth:1.5}),label:"Download",handle:Jo,dropdown:[{icon:i.jsx(ng,{size:14,strokeWidth:1.5}),label:"Download as HTML",handle:async()=>{e?await tg({filename:e,includeCode:!0}):ze({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:i.jsx(ng,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{e?await tg({filename:e,includeCode:!1}):ze({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:i.jsx(Zs,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{const K=await N({download:!1});Ul(new Blob([K],{type:"text/plain"}),Ap.toMarkdown(document.title))}},{icon:i.jsx(Gc,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{const K=await k();Ul(new Blob([K.contents],{type:"text/plain"}),Ap.toPY(document.title))}},{divider:!0,icon:i.jsx(Cc,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:a.mode!=="present",tooltip:a.mode==="present"?void 0:i.jsxs("span",{children:["Only available in app view. ",i.jsx("br",{}),"Toggle with: ",St("global.hideCode",!1)]}),handle:F0},{icon:i.jsx(Tk,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:a.mode!=="present",tooltip:a.mode==="present"?void 0:i.jsxs("span",{children:["Only available in app view. ",i.jsx("br",{}),"Toggle with: ",St("global.hideCode",!1)]}),handle:R0}]},{divider:!0,icon:i.jsx(dd,{size:14,strokeWidth:1.5}),label:"Helper panel",handle:Jo,dropdown:Yr.flatMap(K=>{const{type:V,Icon:q,hidden:U}=K;return U?[]:{label:Ll(V),rightElement:z(s===V),icon:i.jsx(q,{size:14,strokeWidth:1.5}),handle:()=>r(V)}})},{icon:i.jsx(Ba,{size:14,strokeWidth:1.5}),label:"Present as",handle:Jo,dropdown:[{icon:a.mode==="present"?i.jsx(Tp,{size:14,strokeWidth:1.5}):i.jsx(La,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{M()}},...eg.map((K,V)=>{const q=Zd(K);return{divider:V===0,label:eu(K),icon:i.jsx(q,{size:14,strokeWidth:1.5}),rightElement:i.jsx("div",{className:"w-8 flex justify-end",children:O===K&&i.jsx(Wl,{size:14})}),handle:()=>{D(K),a.mode==="edit"&&M()}}})]},{icon:i.jsx(Kc,{size:14,strokeWidth:1.5}),label:"Create notebook copy",hidden:!e||Qt(),handle:y},{icon:i.jsx(Oa,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!e,handle:async()=>{const K=await k();await Eo(K.contents),ze({title:"Copied",description:"Code copied to clipboard."})}},{icon:i.jsx(_t,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!_||l,handle:async()=>{const K=Mt(),V=Mk(K),q=Pl.fromEntries(V.map(O0));await E({configs:q});for(const U of V)u({cellId:U,config:{disabled:!1}})}},{icon:i.jsx(Et,{size:14,strokeWidth:1.5}),label:"Disable all cells",hidden:!I||l,handle:async()=>{const K=Mt(),V=fp(K),q=Pl.fromEntries(V.map(M0));await E({configs:q});for(const U of V)u({cellId:U,config:{disabled:!0}})}},{icon:i.jsx($l,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:c},{icon:i.jsx(Vc,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:b},{icon:i.jsx($c,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:x},{icon:i.jsx(qc,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{p({code:"# Initialization code that runs before all other cells"})}},{icon:i.jsx(Ks,{size:14,strokeWidth:1.5}),label:"Clear all outputs",handle:()=>{m()}},{icon:i.jsx(Hc,{size:14,strokeWidth:1.5}),label:"Re-run all cells",hotkey:"global.runAll",handle:async()=>{g()}},{icon:i.jsx(za,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!A||l,handle:()=>{h()}},{icon:i.jsx(_o,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n(i.jsx(Ka,{onClose:o}))}},{divider:!0,icon:i.jsx(Ra,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>w(D0)},{icon:i.jsx(Ok,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>j(T0)},{icon:i.jsx(nd,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>C(A0)},{icon:i.jsx(H1,{size:14,strokeWidth:1.5}),label:"Open documentation",handle:I0},{icon:i.jsx(Rk,{size:14,strokeWidth:1.5}),label:"Resources",handle:Jo,dropdown:[{icon:i.jsx(H1,{size:14,strokeWidth:1.5}),label:"Documentation",handle:_0},{icon:i.jsx(rC,{size:14,strokeWidth:1.5}),label:"GitHub",handle:E0},{icon:i.jsx(sC,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:S0},{icon:i.jsx(aC,{size:14,strokeWidth:1.5}),label:"YouTube",handle:N0},{icon:i.jsx(xp,{size:14,strokeWidth:1.5}),label:"Changelog",handle:C0}]},{divider:!0,icon:i.jsx(ed,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:j0},{icon:i.jsx(Ec,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:k0},{icon:i.jsx(gd,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:f}].filter(w0).map(y0),t[5]=A,t[6]=m,t[7]=o,t[8]=b,t[9]=y,t[10]=x,t[11]=N,t[12]=e,t[13]=_,t[14]=I,t[15]=c,t[16]=l,t[17]=n,t[18]=k,t[19]=f,t[20]=g,t[21]=E,t[22]=O,t[23]=s,t[24]=w,t[25]=C,t[26]=D,t[27]=j,t[28]=L,t[29]=F,t[30]=W,t[31]=G,t[32]=r,t[33]=M,t[34]=h,t[35]=u,t[36]=p,t[37]=a.mode,t[38]=X):X=t[38],X};function y0(t){return t.dropdown?{...t,dropdown:t.dropdown.filter(v0)}:t}function v0(t){return!t.hidden}function w0(t){return!t.hidden}function k0(){const t=Lk();window.open(t,"_blank")}function j0(){const t=document.baseURI.split("?")[0];window.open(t,"_self")}function C0(){window.open(Xt.releasesPage,"_blank")}function N0(){window.open(Xt.youtube,"_blank")}function S0(){window.open(Xt.discordLink,"_blank")}function E0(){window.open(Xt.githubPage,"_blank")}function _0(){window.open(Xt.docsPage,"_blank")}function I0(){window.open(Xt.docsPage,"_blank")}function A0(t){return!t}function T0(t){return!t}function D0(t){return!t}function M0(t){return[t,{disabled:!0}]}function O0(t){return[t,{disabled:!1}]}async function R0(){const t=new Event("export-beforeprint"),e=new Event("export-afterprint");window.dispatchEvent(t),setTimeout(L0,0),setTimeout(()=>window.dispatchEvent(e),0)}function L0(){return window.print()}async function F0(){const t=document.getElementById("App");t&&await Dp(t,document.title)}function B0(t){return i.jsx("div",{className:"w-8 flex justify-end",children:t&&i.jsx(Wl,{size:14})})}const P0=t=>{const e=P.c(33),{disabled:n,tooltip:o}=t,r=n!==void 0&&n,s=o===void 0?"Actions":o,a=Lc(),{locale:l}=up();let c,d,u;e[0]!==s?(c=i.jsx("div",{children:s}),e[0]=s,e[1]=c):c=e[1],e[2]!==r?(d=!r&&i.jsxs("div",{className:"text-xs text-muted-foreground font-medium pt-1 -mt-2 border-t border-border flex items-center gap-2",children:[i.jsx("span",{children:"Open command palette"}),St("global.commandPalette",!1)]}),e[2]=r,e[3]=d):d=e[3],e[4]!==c||e[5]!==d?(u=i.jsxs("div",{className:"flex flex-col gap-2",children:[c,d]}),e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=u,m=r?"disabled":"hint-green";let p,b,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(xC,{strokeWidth:1.8}),e[7]=p):p=e[7],e[8]!==h?(b=i.jsx(pe,{content:h,children:p}),e[8]=h,e[9]=b):b=e[9],e[10]!==r||e[11]!==m||e[12]!==b?(x=i.jsx(tn,{"aria-label":"Config",shape:"circle",size:"small",className:"h-[27px] w-[27px]","data-testid":"notebook-menu-dropdown",disabled:r,color:m,children:b}),e[10]=r,e[11]=m,e[12]=b,e[13]=x):x=e[13];const f=x,g=z0;let y;e[14]===Symbol.for("react.memo_cache_sentinel")?(y=O=>{const D=i.jsx(lo,{variant:O.variant,disabled:O.disabled,onSelect:M=>O.handle(M),"data-testid":`notebook-menu-dropdown-${O.label}`,children:g(O)},O.label);return O.tooltip?i.jsx(pe,{content:O.tooltip,side:"left",delayDuration:100,children:i.jsx("span",{children:D})},O.label):D},e[14]=y):y=e[14];const w=y;let j,C,N,k,E,_,I,A;if(e[15]!==f||e[16]!==r?(j=i.jsx(Un,{asChild:!0,disabled:r,children:f}),e[15]=f,e[16]=r,e[17]=j):j=e[17],e[18]!==a){let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=D=>D.hidden?null:D.dropdown?i.jsxs(Bk,{children:[i.jsx(Pk,{"data-testid":`notebook-menu-dropdown-${D.label}`,children:g(D)}),i.jsx(zk,{children:i.jsx(Uk,{children:D.dropdown.map(M=>i.jsxs(me.Fragment,{children:[M.divider&&i.jsx(En,{}),w(M)]},M.label))})})]},D.label):i.jsxs(me.Fragment,{children:[D.divider&&i.jsx(En,{}),w(D)]},D.label),e[20]=O):O=e[20],C=a.map(O),e[18]=a,e[19]=C}else C=e[19];return e[21]===Symbol.for("react.memo_cache_sentinel")?(N=i.jsx(En,{}),e[21]=N):N=e[21],e[22]!==l?(k=i.jsxs("span",{children:["Locale: ",l]}),e[22]=l,e[23]=k):k=e[23],e[24]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsxs("span",{children:["Version: ",Mp()]}),e[24]=E):E=e[24],e[25]!==k?(_=i.jsxs("div",{className:"flex-1 px-2 text-xs text-muted-foreground flex flex-col gap-1",children:[k,E]}),e[25]=k,e[26]=_):_=e[26],e[27]!==C||e[28]!==_?(I=i.jsxs(Wn,{align:"end",className:"no-print w-[240px]",children:[C,N,_]}),e[27]=C,e[28]=_,e[29]=I):I=e[29],e[30]!==j||e[31]!==I?(A=i.jsxs(zn,{modal:!1,children:[j,I]}),e[30]=j,e[31]=I,e[32]=A):A=e[32],A};function z0(t){return i.jsxs(i.Fragment,{children:[t.icon&&i.jsx("span",{className:"flex-0 mr-2",children:t.icon}),i.jsx("span",{className:"flex-1",children:t.labelElement||t.label}),t.hotkey&&i.jsx(Vl,{shortcut:t.hotkey,className:"ml-4"}),t.rightElement]})}function Ya(t){return Zt("create"in t,'Expected query to have a "create" method'),t}const ft=Wk({findText:"",replaceText:"",caseSensitive:!1,wholeWord:!1,regexp:!1,isOpen:!1,currentView:void 0},(t,e)=>{if(e===void 0)return t;switch(e.type){case"setFind":return{...t,findText:e.find};case"setReplace":return{...t,replaceText:e.replace};case"setCaseSensitive":return{...t,caseSensitive:e.caseSensitive};case"setWholeWord":return{...t,wholeWord:e.wholeWord};case"setRegex":return{...t,regexp:e.regexp};case"setIsOpen":return{...t,isOpen:e.isOpen};case"setCurrentView":return{...t,currentView:{view:e.view,range:e.range}};case"clearCurrentView":return{...t,currentView:void 0}}});function nu(t){if([...document.querySelectorAll('[role="dialog"][data-state="open"]')].some(e=>e instanceof HTMLElement&&e.childNodes.length>0))return!1;if(t){const e=t.state.selection.main,n=t.state.sliceDoc(e.from,e.to);n?(Le.set(ft,{type:"setFind",find:n}),Le.set(ft,{type:"setCurrentView",view:t,range:{from:e.from,to:e.to}})):Le.set(ft,{type:"setCurrentView",view:t,range:{from:0,to:0}})}return Le.get(ft).isOpen?(Le.set(ft,{type:"setIsOpen",isOpen:!1}),requestAnimationFrame(()=>{Le.set(ft,{type:"setIsOpen",isOpen:!0})}),!0):(Le.set(ft,{type:"setIsOpen",isOpen:!0}),!0)}function U0(){return!!Le.get(ft).isOpen&&(Le.set(ft,{type:"setIsOpen",isOpen:!1}),!0)}function es(t){return()=>{const e=Le.get(ft),n=new ea({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord});return!!n.valid&&t({query:Ya(n).create(),search:n})}}const ou=t=>es(({query:e})=>{const n=Do(),o=Le.get(ft).currentView||{view:n[0],range:{from:0,to:0}};let r=o.range.to;t==="prev"&&(n.reverse(),r=o.range.from);let s=n.indexOf(o.view);s<0&&(s=0);const a=[...n,...n].slice(s);for(const l of a){const c=t==="next"?e.nextMatch(l.state,0,r??0):e.prevMatch(l.state,r??l.state.doc.length,l.state.doc.length);if(!c){r=null,l.dispatch({selection:Yt.single(0)});continue}const d=Yt.single(c.from,c.to);return l.dispatch({selection:d,effects:[Se.scrollIntoView(d.main,{y:"center"})],userEvent:"select.search"}),Le.set(ft,{type:"setCurrentView",view:l,range:{from:c.from,to:c.to}}),c}return!1}),Xa=ou("next"),ru=ou("prev"),W0=es(({query:t})=>{var o;const e=Do(),n=[];for(const r of e){if(r.state.readOnly)continue;const s=(o=t.matchAll(r.state,1e9))==null?void 0:o.map(l=>{const{from:c,to:d}=l;return{from:c,to:d,insert:t.getReplacement(l)}});if(!s||s.length===0)continue;const a=r.state.doc.toString();n.push(()=>{r.dispatch({changes:[{from:0,to:r.state.doc.length,insert:a}],userEvent:"input.replace.all"})}),r.dispatch({changes:s,userEvent:"input.replace.all"})}return()=>{for(const r of n)r()}}),$0=es(({query:t})=>{const e=Do(),n=Le.get(ft).currentView||{view:e[0],range:{from:0}};let o=n.range.from,r=e.indexOf(n.view);r<0&&(r=0);const s=[...e,...e].slice(r);for(const a of s){const l=t.nextMatch(a.state,0,o??0);if(!l){o=null,a.dispatch({selection:Yt.single(0)});continue}const c=a.state.toText(t.getReplacement(l));return a.dispatch({changes:[{from:l.from,to:l.to,insert:c}],userEvent:"input.replace"}),Xa()}return!1}),V0=es(({query:t})=>{const e=Do();let n=0;const o=new Map;for(const r of e){const s=t.matchAll(r.state,1e9)||[];for(const a of s){const{from:l,to:c}=a,d=o.get(r)||new Map;d.set(`${l}:${c}`,n++),o.set(r,d)}}return{count:n,position:o}}),Qa=tt.define();function su(){const t=Do();for(const e of t)e.state.readOnly||e.dispatch({effects:Qa.of(new ea({search:""}))})}const ts=Dt.define({create(){const t=Le.get(ft);return Ya(new ea({search:t.findText,caseSensitive:t.caseSensitive,regexp:t.regexp,replace:t.replaceText,wholeWord:t.wholeWord})).create()},update(t,e){for(const n of e.effects)n.is(Qa)&&(t=Ya(n.value).create());return t}}),G0=Te.mark({class:"cm-searchMatch"}),q0=Te.mark({class:"cm-searchMatch cm-searchMatch-selected"}),H0=Wt.fromClass(class{constructor(t){this.decorations=void 0,this.view=void 0,this.view=t,this.decorations=this.highlight(t.state.field(ts))}update(t){const e=t.state.field(ts);(e!==t.startState.field(ts)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight(t){if(!t.spec.valid)return Te.none;const{view:e}=this,n=new Mo,o=e.visibleRanges,r=o.length;for(let s=0;s<r;s++){let{to:a}=o[s];const{from:l}=o[s];for(;s<r-1&&a>o[s+1].from-500;)a=o[++s].to;t.highlight(e.state,l,a,(c,d)=>{const u=e.state.selection.ranges.some(h=>h.from===c&&h.to===d);n.add(c,d,u?q0:G0)})}return n.finish()}},{decorations:t=>t.decorations}),J0=Se.baseTheme({"&light .cm-searchMatch":{backgroundColor:"#99ff7780"},"&dark .cm-searchMatch":{backgroundColor:"#22bb0070"},"&light .cm-searchMatch-selected":{backgroundColor:"transparent"},"&dark .cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff88 !important"}}),K0=()=>{var ve;const t=P.c(102),[e,n]=S.useState(!1),[o,r]=_n(ft),[s,a]=S.useState(),l=S.useRef(null),c=ie(Gl);let d,u;t[0]!==e||t[1]!==o.isOpen?(d=()=>(!e||!o.isOpen)&&nu(),t[0]=e,t[1]=o.isOpen,t[2]=d):d=t[2],st("cell.findAndReplace",d),t[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const be=V0();a(be===!1?void 0:be)},t[3]=u):u=t[3];const h=u;let m,p,b,x;if(t[4]!==o.isOpen?(m=()=>{o.isOpen&&l.current&&(l.current.focus(),l.current.select())},p=[o.isOpen],t[4]=o.isOpen,t[5]=m,t[6]=p):(m=t[5],p=t[6]),S.useEffect(m,p),t[7]!==o.findText||t[8]!==o.isOpen?(b=()=>{if(o.isOpen){if(o.findText==="")return a(void 0),void su();h(),(function(){const be=Le.get(ft),et=Do();for(const rt of et)rt.state.readOnly||rt.dispatch({effects:Qa.of(new ea({search:be.findText,caseSensitive:be.caseSensitive,regexp:be.regexp,replace:be.replaceText,wholeWord:be.wholeWord}))})})()}else su()},t[7]=o.findText,t[8]=o.isOpen,t[9]=b):b=t[9],t[10]!==o.caseSensitive||t[11]!==o.findText||t[12]!==o.isOpen||t[13]!==o.regexp||t[14]!==o.wholeWord?(x=[o.findText,o.isOpen,o.caseSensitive,o.regexp,o.wholeWord],t[10]=o.caseSensitive,t[11]=o.findText,t[12]=o.isOpen,t[13]=o.regexp,t[14]=o.wholeWord,t[15]=x):x=t[15],S.useEffect(b,x),!o.isOpen)return null;const f=o.currentView;let g;t[16]!==s||t[17]!==f?(g=f&&s?(ve=s.position.get(f.view))==null?void 0:ve.get(`${f.range.from}:${f.range.to}`):void 0,t[16]=s,t[17]=f,t[18]=g):g=t[18];const y=g;let w,j,C,N,k,E,_,I,A,O,D;t[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>n(!0),t[19]=w):w=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(j=()=>n(!1),t[20]=j):j=t[20],t[21]!==r?(C=be=>{be.key==="Escape"&&r({type:"setIsOpen",isOpen:!1})},t[21]=r,t[22]=C):C=t[22],t[23]!==r?(N=()=>r({type:"setIsOpen",isOpen:!1}),t[23]=r,t[24]=N):N=t[24],t[25]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx(Vt,{className:"w-4 h-4"}),t[25]=k):k=t[25],t[26]!==N?(E=i.jsx("div",{className:"absolute top-0 right-0",children:i.jsx(ye,{"data-testid":"close-find-replace-button",onClick:N,size:"xs",variant:"text",children:k})}),t[26]=N,t[27]=E):E=t[27],t[28]!==r?(_=be=>{r({type:"setFind",find:be.target.value})},t[28]=r,t[29]=_):_=t[29],t[30]!==o.findText||t[31]!==_?(I=i.jsx(ao,{ref:l,"data-testid":"find-input",value:o.findText,autoFocus:!0,className:"mr-2 mb-0",placeholder:"Find",onKeyDown:X0,onChange:_}),t[30]=o.findText,t[31]=_,t[32]=I):I=t[32],t[33]!==r?(A=be=>{r({type:"setReplace",replace:be.target.value})},t[33]=r,t[34]=A):A=t[34],t[35]!==o.replaceText||t[36]!==A?(O=i.jsx(ao,{"data-testid":"replace-input",value:o.replaceText,placeholder:"Replace",onChange:A}),t[35]=o.replaceText,t[36]=A,t[37]=O):O=t[37],t[38]!==I||t[39]!==O?(D=i.jsxs("div",{className:"flex flex-col flex-2 gap-2 w-[55%]",children:[I,O]}),t[38]=I,t[39]=O,t[40]=D):D=t[40];const M=o.caseSensitive?"on":"off";let R,L,z;t[41]!==r?(R=be=>r({type:"setCaseSensitive",caseSensitive:be}),t[41]=r,t[42]=R):R=t[42],t[43]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(Vk,{className:"w-4 h-4"}),t[43]=L):L=t[43],t[44]!==o.caseSensitive||t[45]!==M||t[46]!==R?(z=i.jsx(pe,{content:"Case Sensitive",children:i.jsx(ql,{size:"sm",pressed:o.caseSensitive,"data-state":M,onPressedChange:R,children:L})}),t[44]=o.caseSensitive,t[45]=M,t[46]=R,t[47]=z):z=t[47];const T=o.wholeWord?"on":"off";let F,$,W;t[48]!==r?(F=be=>r({type:"setWholeWord",wholeWord:be}),t[48]=r,t[49]=F):F=t[49],t[50]===Symbol.for("react.memo_cache_sentinel")?($=i.jsx(yd,{className:"w-4 h-4"}),t[50]=$):$=t[50],t[51]!==o.wholeWord||t[52]!==T||t[53]!==F?(W=i.jsx(pe,{content:"Match Whole Word",children:i.jsx(ql,{size:"sm",pressed:o.wholeWord,"data-state":T,onPressedChange:F,children:$})}),t[51]=o.wholeWord,t[52]=T,t[53]=F,t[54]=W):W=t[54];const G=o.regexp?"on":"off";let X,H,Y,K,V;t[55]!==r?(X=be=>r({type:"setRegex",regexp:be}),t[55]=r,t[56]=X):X=t[56],t[57]===Symbol.for("react.memo_cache_sentinel")?(H=i.jsx(ud,{className:"w-4 h-4"}),t[57]=H):H=t[57],t[58]!==o.regexp||t[59]!==G||t[60]!==X?(Y=i.jsx(pe,{content:"Use Regular Expression",children:i.jsx(ql,{size:"sm",pressed:o.regexp,"data-state":G,onPressedChange:X,children:H})}),t[58]=o.regexp,t[59]=G,t[60]=X,t[61]=Y):Y=t[61],t[62]!==z||t[63]!==W||t[64]!==Y?(K=i.jsxs("div",{className:"flex items-center gap-[2px]",children:[z,W,Y]}),t[62]=z,t[63]=W,t[64]=Y,t[65]=K):K=t[65],t[66]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{$0()&&h()},t[66]=V):V=t[66];const q=o.findText==="";let U,ne;t[67]!==q?(U=i.jsx(ye,{"data-testid":"replace-next-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:V,disabled:q,children:"Replace Next"}),t[67]=q,t[68]=U):U=t[68],t[69]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{const be=W0();if(!be)return;h();const{dismiss:et}=ze({title:"Replaced all occurrences",action:i.jsx(Op,{"data-testid":"undo-replace-all-button",onClick:()=>{be(),rt()}})}),rt=et},t[69]=ne):ne=t[69];const Q=o.findText==="";let ee,oe,se,ae,te,_e,he,we,ke,ge,Ee,Oe;return t[70]!==Q?(ee=i.jsx(ye,{"data-testid":"replace-all-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:ne,disabled:Q,children:"Replace All"}),t[70]=Q,t[71]=ee):ee=t[71],t[72]!==U||t[73]!==ee?(oe=i.jsxs("div",{className:"flex items-center gap-[2px]",children:[U,ee]}),t[72]=U,t[73]=ee,t[74]=oe):oe=t[74],t[75]!==K||t[76]!==oe?(se=i.jsxs("div",{className:"flex flex-col gap-2",children:[K,oe]}),t[75]=K,t[76]=oe,t[77]=se):se=t[77],t[78]!==D||t[79]!==se?(ae=i.jsxs("div",{className:"flex items-center gap-3",children:[D,se]}),t[78]=D,t[79]=se,t[80]=ae):ae=t[80],t[81]===Symbol.for("react.memo_cache_sentinel")?(te=i.jsx(pe,{content:"Find Previous",children:i.jsx(ye,{"data-testid":"find-prev-button",size:"xs",variant:"secondary",onClick:Q0,children:i.jsx(Fc,{className:"w-4 h-4"})})}),t[81]=te):te=t[81],t[82]===Symbol.for("react.memo_cache_sentinel")?(_e=i.jsx(pe,{content:"Find Next",children:i.jsx(ye,{"data-testid":"find-next-button",size:"xs",variant:"secondary",onClick:Z0,children:i.jsx(Uc,{className:"w-4 h-4"})})}),t[82]=_e):_e=t[82],t[83]!==y||t[84]!==s?(he=s!=null&&y==null&&i.jsxs("span",{className:"text-sm",children:[s.count," matches"]}),t[83]=y,t[84]=s,t[85]=he):he=t[85],t[86]!==y||t[87]!==s?(we=s!=null&&y!=null&&i.jsxs("span",{className:"text-sm",children:[y+1," of ",s.count]}),t[86]=y,t[87]=s,t[88]=we):we=t[88],t[89]!==he||t[90]!==we?(ke=i.jsxs("div",{className:"flex items-center gap-2",children:[te,_e,he,we]}),t[89]=he,t[90]=we,t[91]=ke):ke=t[91],t[92]!==c?(ge=c.getHotkey("cell.findAndReplace"),t[92]=c,t[93]=ge):ge=t[93],t[94]!==ge.key?(Ee=i.jsxs("div",{className:"text-xs text-muted-foreground flex gap-1 mt-2",children:["Press"," ",i.jsx($k,{shortcut:ge.key})," ","again to open the native browser search."]}),t[94]=ge.key,t[95]=Ee):Ee=t[95],t[96]!==E||t[97]!==ae||t[98]!==ke||t[99]!==Ee||t[100]!==C?(Oe=i.jsx(Hl,{restoreFocus:!0,autoFocus:!0,children:i.jsxs("div",{onFocus:w,onClick:Y0,onBlur:j,className:"fixed top-0 right-0 w-[500px] flex flex-col bg-(--sage-1) p-4 z-50 mt-2 mr-3 rounded-md shadow-lg border gap-2 print:hidden",onKeyDown:C,children:[E,ae,ke,Ee]})}),t[96]=E,t[97]=ae,t[98]=ke,t[99]=Ee,t[100]=C,t[101]=Oe):Oe=t[101],Oe};function Y0(t){t.stopPropagation(),t.preventDefault()}function X0(t){t.key==="Enter"&&(t.shiftKey?ru():Xa())}function Q0(){return ru()}function Z0(){return Xa()}const au=t=>{const e=P.c(41),{resetOnBlur:n,placeholderText:o,initialValue:r,flexibleWidth:s,onNameChange:a,className:l}=t,c=n!==void 0&&n,d=r===void 0?null:r,u=s!==void 0&&s,{sendListFiles:h}=qe(),[m,p]=S.useState(d);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=[],e[0]=b):b=e[0];const[x,f]=S.useState(b),[g,y]=S.useState(!1),w=S.useRef(null),j=S.useRef(!1);let C,N,k;e[1]!==d?(C=()=>{p(d)},N=[d],e[1]=d,e[2]=C,e[3]=N):(C=e[2],N=e[3]),S.useEffect(C,N),e[4]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{y(!0)},e[4]=k):k=e[4];const E=k;let _;e[5]!==d||e[6]!==c?(_=Q=>{var ee;(ee=Q.relatedTarget)!=null&&ee.closest(".filename-input")||(y(!1),c&&p(d))},e[5]=d,e[6]=c,e[7]=_):_=e[7];const I=_;let A;e[8]!==m?(A=Ot.dirname(m||""),e[8]=m,e[9]=A):A=e[9];const O=A,D=Ot.basename(m||""),M=x.filter(Q=>Ot.basename(Q.path).startsWith(D));let R,L;e[10]!==O||e[11]!==g||e[12]!==h?(R=async()=>{if(!g)return void f([]);const Q=await h({path:O});f(Q.files)},e[10]=O,e[11]=g,e[12]=h,e[13]=R):R=e[13],e[14]!==O||e[15]!==g?(L=[O,g],e[14]=O,e[15]=g,e[16]=L):L=e[16];const{isPending:z}=wr(R,L),T=(function(Q,ee,oe){if(Q&&!Q.endsWith("/")&&((Ys("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(Ot.extension(Q))||(Q=Q.endsWith(".")?`${Q}py`:Q.endsWith(".p")?`${Q}y`:`${Q}.py`),!ee.some(se=>se.path===Q||Ot.basename(se.path)===Q)&&!(oe&&(oe===Q||Ot.basename(oe)===Q))))return Q})(m,x,d),F=(T||M.length>0)&&i.jsxs(Rp,{className:"font-mono",children:[!z&&i.jsx(Lp,{children:"No files"}),T&&i.jsxs(Jl,{variant:"success",className:"py-2 px-3",onSelect:()=>{var Q;T&&(j.current=!0,a(T),(Q=w.current)==null||Q.blur())},children:[i.jsx(Jc,{className:"w-4 h-4 mr-2"})," ",i.jsxs("span",{className:"text-sm",children:[d?"Rename to: ":"Save as: ",i.jsx("span",{className:"font-medium text-sm",children:Ot.basename(T)})]})]},"_rename_"),M.map(Q=>{const ee=Q.isDirectory?"directory":Gk(Q.path),oe=qk[ee];return i.jsxs(Jl,{variant:Q.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{Q.isDirectory?p(`${Q.path}/`):p(Q.path)},children:[i.jsx(oe,{className:"w-4 h-4 mr-2"})," ",Ot.basename(Q.path)]},Q.path)})]}),$=10*Math.max(20,(m==null?void 0:m.length)||(o==null?void 0:o.length)||0),W=g?m||"":d||"";let G,X,H;e[17]!==u||e[18]!==$?(G=u?{maxWidth:$}:void 0,e[17]=u,e[18]=$,e[19]=G):G=e[19],e[20]!==l?(X=ue(l,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60"),e[20]=l,e[21]=X):X=e[21],e[22]!==o||e[23]!==W||e[24]!==G||e[25]!==X?(H=i.jsx(Hk,{children:i.jsx(Fp,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:W,onKeyDown:eb,icon:null,ref:w,onValueChange:p,placeholder:o,autoComplete:"off",style:G,className:X})}),e[22]=o,e[23]=W,e[24]=G,e[25]=X,e[26]=H):H=e[26];const Y=F&&"group-focus-within:block";let K,V,q,U,ne;return e[27]!==Y?(K=ue("p-0 w-full min-w-80 max-w-80vw hidden",Y),e[27]=Y,e[28]=K):K=e[28],e[29]!==F||e[30]!==K?(V=i.jsx(Kl,{side:"bottom",className:K,portal:!1,children:F}),e[29]=F,e[30]=K,e[31]=V):V=e[31],e[32]!==H||e[33]!==V?(q=i.jsxs(Rp,{children:[H,V]}),e[32]=H,e[33]=V,e[34]=q):q=e[34],e[35]!==I||e[36]!==q?(U=i.jsx(Bp,{onFocus:E,onBlur:I,shouldFilter:!1,id:"filename-input",className:"bg-transparent group filename-input",children:q}),e[35]=I,e[36]=q,e[37]=U):U=e[37],e[38]!==g||e[39]!==U?(ne=i.jsx(Yl,{children:i.jsx(ta,{open:g,modal:!1,children:U})}),e[38]=g,e[39]=U,e[40]=ne):ne=e[40],ne};function eb(t){t.key==="Escape"&&t.currentTarget.blur()}const tb=t=>{const e=P.c(33),n=()=>{Ul(new Blob([o()],{type:"text/plain"}),`${t.proposedName}.json`)},o=Ce(rb);let r,s,a,l,c,d,u,h,m,p,b,x,f,g,y,w,j;return e[0]!==n||e[1]!==t?(r=C=>{C.preventDefault(),n(),t.closeModal()},e[0]=n,e[1]=t,e[2]=r):r=e[2],e[3]!==t?(s=C=>{C.key==="Escape"&&t.closeModal()},e[3]=t,e[4]=s):s=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(so,{className:"text-accent-foreground mb-6",children:"Download unsaved changes?"}),e[5]=a):a=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(l={wordBreak:"break-word"},e[6]=l):l=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("p",{children:"This app has unsaved changes. To recover:"}),d={paddingBottom:"10px"},e[7]=c,e[8]=d):(c=e[7],d=e[8]),e[9]!==t.proposedName?(u=i.jsxs("li",{style:d,children:['Click the "Download" button. This will download a file called\xA0',i.jsxs("code",{children:[t.proposedName,".json"]}),". This file contains your code."]}),e[9]=t.proposedName,e[10]=u):u=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(h={paddingBottom:"10px"},e[11]=h):h=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(m={display:"block",padding:"10px"},e[12]=m):m=e[12],e[13]!==t.proposedName?(p=i.jsxs("code",{style:m,children:["marimo recover ",t.proposedName,".json ",">"," ",t.proposedName,".py"]}),e[13]=t.proposedName,e[14]=p):p=e[14],e[15]!==t.proposedName?(b=i.jsxs("code",{children:[t.proposedName,".py"]}),e[15]=t.proposedName,e[16]=b):b=e[16],e[17]!==b||e[18]!==p?(x=i.jsxs("li",{style:h,children:["In your terminal, type",p,"to overwrite ",b," with the recovered changes."]}),e[17]=b,e[18]=p,e[19]=x):x=e[19],e[20]!==x||e[21]!==u?(f=i.jsx(vr,{className:"markdown break-words",style:l,children:i.jsxs("div",{className:"prose dark:prose-invert",children:[c,i.jsxs("ol",{children:[u,x]})]})}),e[20]=x,e[21]=u,e[22]=f):f=e[22],e[23]!==t.closeModal?(g=i.jsx(ye,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:t.closeModal,children:"Cancel"}),e[23]=t.closeModal,e[24]=g):g=e[24],e[25]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(ye,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"}),e[25]=y):y=e[25],e[26]!==g?(w=i.jsxs(Hs,{children:[g,y]}),e[26]=g,e[27]=w):w=e[27],e[28]!==r||e[29]!==s||e[30]!==f||e[31]!==w?(j=i.jsx(io,{className:"w-fit",children:i.jsxs("form",{onSubmit:r,onKeyDown:s,children:[a,f,w]})}),e[28]=r,e[29]=s,e[30]=f,e[31]=w,e[32]=j):j=e[32],j},nb=t=>{const e=P.c(12),{filename:n,needsSave:o}=t,{openModal:r,closeModal:s}=Pn();let a;e[0]!==n?(a=n===null?"app":Ot.basename(n).split(".")[0],e[0]=n,e[1]=a):a=e[1];const l=a;let c;e[2]!==s||e[3]!==o||e[4]!==r||e[5]!==l?(c=()=>{o&&r(i.jsx(tb,{proposedName:l,closeModal:s}))},e[2]=s,e[3]=o,e[4]=r,e[5]=l,e[6]=c):c=e[6];const d=c;let u;st("global.save",d),e[7]===Symbol.for("react.memo_cache_sentinel")?(u=St("global.save"),e[7]=u):u=e[7];const h=o?"yellow":"gray";let m,p;return e[8]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Ta,{strokeWidth:1.5,size:18}),e[8]=m):m=e[8],e[9]!==d||e[10]!==h?(p=i.jsx(pe,{content:u,children:i.jsx(tn,{onClick:d,id:"save-button","aria-label":"Save",className:"rectangle",color:h,children:m})}),e[9]=d,e[10]=h,e[11]=p):p=e[11],p};function ob(t){return{id:t.id,name:t.name,code:t.code,code_hash:null,config:{column:0,...t.config}}}function rb(){const t=Mt(),e=Xl(t),n={version:"1",metadata:{marimo_version:Mp()},cells:e.map(ob)};return JSON.stringify(n,null,2)}const Za=5e3,ei=Bt(void 0),iu=Bt(t=>{const e=t(ei);return(function({state:n,layout:o,lastSavedNotebook:r}){if(!r)return!1;const{cellIds:s,cellData:a}=n,l=s.inOrderIds.map(h=>a[h]),c=l.map(h=>h.code),d=l.map(h=>h.config),u=l.map(h=>h.name);return!(Pp(c,r.codes)&&Pp(u,r.names)&&jr(d,r.configs)&&jr(o.selectedLayout,r.layout.selectedLayout)&&jr(o.layoutData,r.layout.layoutData))})({state:t(Gt),layout:t(og),lastSavedNotebook:e})});function sb(t){return JSON.stringify(t)}const ab=t=>{const e=P.c(15),{kioskMode:n}=t,o=zl(),r=ie(iu),s=ie(Nt).state===ht.CLOSED,{saveOrNameNotebook:a,saveIfNotebookIsPersistent:l}=ti();let c,d,u;e[0]!==n||e[1]!==l?(c={onSave:l,kioskMode:n},e[0]=n,e[1]=l,e[2]=c):c=e[2],(function(f){const g=P.c(14),y=ie(Wp),w=qp(),[j]=_n(Nt),C=ie(iu);let N,k;if(g[0]!==w){const O=Xl(w);N=O.map(ub),k=O.map(db),g[0]=w,g[1]=N,g[2]=k}else N=g[1],k=g[2];const E=k;let _;g[3]!==w?(_=Up(w),g[3]=w,g[4]=_):_=g[4];const I=_;let A;g[5]!==y||g[6]!==E||g[7]!==N||g[8]!==I||g[9]!==j||g[10]!==C||g[11]!==f.kioskMode||g[12]!==f.onSave?(A={onSave:f.onSave,needsSave:C,codes:N,cellConfigs:I,cellNames:E,connStatus:j,config:y,kioskMode:f.kioskMode},g[5]=y,g[6]=E,g[7]=N,g[8]=I,g[9]=j,g[10]=C,g[11]=f.kioskMode,g[12]=f.onSave,g[13]=A):A=g[13],(function(O){const D=P.c(21),{codes:M,cellConfigs:R,config:L,connStatus:z,cellNames:T,needsSave:F,kioskMode:$,onSave:W}=O,G=S.useRef(null);let X;D[0]!==M?(X=M.join(":"),D[0]=M,D[1]=X):X=D[1];const H=X;let Y;D[2]!==R?(Y=R.map(sb).join(":"),D[2]=R,D[3]=Y):Y=D[3];const K=Y;let V;D[4]!==T?(V=T.join(":"),D[4]=T,D[5]=V):V=D[5];const q=V;let U,ne;D[6]!==L||D[7]!==z.state||D[8]!==$||D[9]!==F||D[10]!==W?(U=()=>{if(!$)return L.autosave==="after_delay"&&(G.current!==null&&clearTimeout(G.current),F&&z.state===ht.OPEN&&(G.current=setTimeout(W,L.autosave_delay))),()=>{G.current!==null&&clearTimeout(G.current)}},D[6]=L,D[7]=z.state,D[8]=$,D[9]=F,D[10]=W,D[11]=U):U=D[11],D[12]!==K||D[13]!==q||D[14]!==H||D[15]!==L||D[16]!==z.state||D[17]!==$||D[18]!==F||D[19]!==W?(ne=[H,K,q,L,z.state,W,$,F],D[12]=K,D[13]=q,D[14]=H,D[15]=L,D[16]=z.state,D[17]=$,D[18]=F,D[19]=W,D[20]=ne):ne=D[20],S.useEffect(U,ne)})(A)})(c),(function(){const f=P.c(12),g=ie(Jk),{state:y}=ie(Nt),w=g.auto_download.includes("markdown"),j=g.auto_download.includes("html"),C=g.auto_download.includes("ipynb"),N=!w||y!==ht.OPEN,k=!j||y!==ht.OPEN,E=!C||y!==ht.OPEN,{autoExportAsHTML:_,autoExportAsIPYNB:I,autoExportAsMarkdown:A}=qe();let O,D,M,R,L,z;f[0]!==A?(O=async()=>{await A({download:!1})},f[0]=A,f[1]=O):O=f[1],f[2]!==N?(D={delayMs:Za,whenVisible:!0,disabled:N},f[2]=N,f[3]=D):D=f[3],zr(O,D),f[4]!==_?(M=async()=>{await _({download:!1,includeCode:!0,files:X1.INSTANCE.filenames()})},f[4]=_,f[5]=M):M=f[5],f[6]!==k?(R={delayMs:Za,whenVisible:!0,disabled:k},f[6]=k,f[7]=R):R=f[7],zr(M,R),f[8]!==I?(L=async()=>{await I({download:!1})},f[8]=I,f[9]=L):L=f[9],f[10]!==E?(z={delayMs:Za,whenVisible:!0,disabled:E},f[10]=E,f[11]=z):z=f[11],zr(L,z)})(),e[3]!==r?(d=f=>{if(r)return f.preventDefault(),f.returnValue="You have unsaved changes. Are you sure you want to leave?",f.returnValue},e[3]=r,e[4]=d):d=e[4],Gp(window,"beforeunload",d),e[5]!==a?(u=f=>{f.preventDefault(),f.stopPropagation(),a()},e[5]=a,e[6]=u):u=e[6];const h=u;if(st("global.save",a),s){let f;return e[7]!==o||e[8]!==r?(f=i.jsx(nb,{filename:o,needsSave:r}),e[7]=o,e[8]=r,e[9]=f):f=e[9],f}let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=St("global.save"),e[10]=m):m=e[10];const p=r?"yellow":"hint-green";let b,x;return e[11]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(Ta,{strokeWidth:1.5,size:18}),e[11]=b):b=e[11],e[12]!==h||e[13]!==p?(x=i.jsx(pe,{content:m,children:i.jsx(tn,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:p,onClick:h,children:b})}),e[12]=h,e[13]=p,e[14]=x):x=e[14],x};function ti(){const t=P.c(20),{sendSave:e}=qe(),{openModal:n,closeModal:o,openAlert:r}=Pn(),s=Ct(ei),a=zp(),l=na();let c;t[0]!==r||t[1]!==e||t[2]!==s||t[3]!==l?(c=(g,y)=>{const w=Mt(),j=Xl(w),C=j.map(cb),N=j.map(lb),k=j.map(ib),E=Up(w),_=l.get(Nt),I=l.get(Wp),A=l.get(og);l.get(To)||N.length!==0&&(_.state===ht.OPEN?(He.log("saving to ",g),e({cellIds:C,codes:N,names:k,filename:g,configs:E,layout:yC(),persist:!0}).then(()=>{y&&I.format_on_save&&$p(),s({names:k,codes:N,configs:E,layout:A})})):r("Failed to save notebook: not connected to a kernel."))},t[0]=r,t[1]=e,t[2]=s,t[3]=l,t[4]=c):c=t[4];const d=Ce(c);let u;t[5]!==d||t[6]!==l?(u=g=>{const y=g!==void 0&&g,w=l.get(Vp),j=l.get(Nt);lu(w)&&j.state===ht.OPEN&&d(w,y)},t[5]=d,t[6]=l,t[7]=u):u=t[7];const h=Ce(u);let m;t[8]!==d||t[9]!==a?(m=g=>{a(g).then(y=>{y!==null&&d(y,!0)})},t[8]=d,t[9]=a,t[10]=m):m=t[10];const p=m;let b;t[11]!==o||t[12]!==p||t[13]!==n||t[14]!==h||t[15]!==l?(b=()=>{const g=l.get(Vp),y=l.get(Nt);h(!0),lu(g)||y.state===ht.CLOSED||n(i.jsx(hb,{onClose:o,onSave:p}))},t[11]=o,t[12]=p,t[13]=n,t[14]=h,t[15]=l,t[16]=b):b=t[16];const x=Ce(b);let f;return t[17]!==h||t[18]!==x?(f={saveOrNameNotebook:x,saveIfNotebookIsPersistent:h},t[17]=h,t[18]=x,t[19]=f):f=t[19],f}function ib(t){return t.name}function lb(t){return t.code}function cb(t){return t.id}function lu(t){return t!==null&&!t.startsWith("/tmp")&&!t.startsWith("/var/folders")&&!t.includes("AppData\\Local\\Temp")}function db(t){return t.name}function ub(t){return t.code}const hb=t=>{const e=P.c(17),{onClose:n,onSave:o}=t,[r,s]=S.useState();let a;e[0]!==n||e[1]!==o?(a=f=>{s(f),f.trim()&&(o(f),n())},e[0]=n,e[1]=o,e[2]=a):a=e[2];const l=a;let c,d,u,h;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(so,{children:"Save notebook"}),e[3]=c):c=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Ao,{className:"text-md pt-6 px-1",children:"Save as"}),e[4]=d):d=e[4],e[5]!==l?(u=i.jsxs("div",{className:"flex flex-col",children:[d,i.jsx(au,{onNameChange:l,placeholderText:"filename",className:"missing-filename"})]}),e[5]=l,e[6]=u):u=e[6],e[7]!==n?(h=i.jsx(ye,{"data-testid":"cancel-save-dialog-button","aria-label":"Cancel",variant:"secondary",onClick:n,children:"Cancel"}),e[7]=n,e[8]=h):h=e[8];const m=!r;let p,b,x;return e[9]!==m?(p=i.jsx(ye,{"data-testid":"submit-save-dialog-button","aria-label":"Save",variant:"default",disabled:m,type:"submit",children:"Save"}),e[9]=m,e[10]=p):p=e[10],e[11]!==h||e[12]!==p?(b=i.jsxs(Hs,{children:[h,p]}),e[11]=h,e[12]=p,e[13]=b):b=e[13],e[14]!==u||e[15]!==b?(x=i.jsxs(io,{children:[c,u,b]}),e[14]=u,e[15]=b,e[16]=x):x=e[16],x};function cu(t){const e=P.c(3),[n,o]=S.useState(!1);let r,s;return e[0]!==t?(r=()=>{if(!t)return;o(!1);const a=setTimeout(()=>{o(!0)},200);return()=>clearTimeout(a)},s=[t],e[0]=t,e[1]=r,e[2]=s):(r=e[1],s=e[2]),S.useEffect(r,s),t&&n}let du,uu;Ea=t=>{const{children:e}=t;return ie(To)?null:e},du=t=>{const{children:e}=t;return ie(To)?e:null},uu=()=>{const t=P.c(6),e=Ct(_a);let n;t[0]!==e?(n=()=>e(mb),t[0]=e,t[1]=n):n=t[1];const o=n;let r,s,a;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=St("global.commandPalette"),t[2]=r):r=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(Ra,{strokeWidth:1.5,size:18}),t[3]=s):s=t[3],t[4]!==o?(a=i.jsx(pe,{content:r,children:i.jsx(tn,{"data-testid":"command-palette-button",onClick:o,shape:"rectangle",color:"hint-green",children:s})}),t[4]=o,t[5]=a):a=t[5],a};function mb(t){return!t}const fb=t=>{const e=P.c(47),{presenting:n,onTogglePresenting:o,onInterrupt:r,onRun:s,connectionState:a,running:l,appConfig:c}=t,d=c.width,u=ie(Ip),h=ie(Kk),{undoDeleteCell:m}=Ye(),p=a===ht.CLOSED;let b,x=null;if(!p&&u){let F,$;e[0]===Symbol.for("react.memo_cache_sentinel")?(F=i.jsx(za,{size:16,strokeWidth:1.5}),e[0]=F):F=e[0],e[1]!==m?($=i.jsx(pe,{content:"Undo cell deletion",children:i.jsx(tn,{"data-testid":"undo-delete-cell",size:"medium",color:"hint-green",shape:"circle",onClick:m,children:F})}),e[1]=m,e[2]=$):$=e[2],x=$}e[3]!==a?(b=en(a),e[3]=a,e[4]=b):b=e[4];const f=b;let g;e[5]!==a||e[6]!==f?(g=f?oa(a):void 0,e[5]=a,e[6]=f,e[7]=g):g=e[7];const y=g;let w,j;e[8]!==n?(w=!n&&i.jsx(K0,{}),e[8]=n,e[9]=w):w=e[9],e[10]!==p||e[11]!==y||e[12]!==f||e[13]!==n?(j=!p&&i.jsxs("div",{className:bb,children:[n&&i.jsx(g0,{}),i.jsx(P0,{disabled:f,tooltip:y}),i.jsx(iC,{disabled:f,tooltip:y}),i.jsx(lC,{description:"This will terminate the Python kernel. You'll lose all data that's in memory.",disabled:f,tooltip:y})]}),e[10]=p,e[11]=y,e[12]=f,e[13]=n,e[14]=j):j=e[14];const C=d==="compact"&&"xl:flex-row items-end";let N,k,E,_,I,A,O,D,M,R,L,z,T;return e[15]!==C?(N=ue(xb,C),e[15]=C,e[16]=N):N=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx(Ea,{children:i.jsx(ab,{kioskMode:!1})}),e[17]=k):k=e[17],e[18]===Symbol.for("react.memo_cache_sentinel")?(E=St("global.hideCode"),e[18]=E):E=e[18],e[19]!==n?(_=n?i.jsx(Tp,{strokeWidth:1.5,size:18}):i.jsx(La,{strokeWidth:1.5,size:18}),e[19]=n,e[20]=_):_=e[20],e[21]!==o||e[22]!==_?(I=i.jsx(pe,{content:E,children:i.jsx(tn,{"data-testid":"hide-code-button",id:"preview-button",shape:"rectangle",color:"hint-green",onClick:o,children:_})}),e[21]=o,e[22]=_,e[23]=I):I=e[23],e[24]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsx(uu,{}),O=i.jsx(cC,{}),D=i.jsx("div",{}),e[24]=A,e[25]=O,e[26]=D):(A=e[24],O=e[25],D=e[26]),e[27]!==p||e[28]!==r||e[29]!==l?(M=!p&&i.jsx(gb,{running:l,onInterrupt:r}),e[27]=p,e[28]=r,e[29]=l,e[30]=M):M=e[30],e[31]!==p||e[32]!==h||e[33]!==s?(R=!p&&i.jsx(pb,{needsRun:h,onRun:s}),e[31]=p,e[32]=h,e[33]=s,e[34]=R):R=e[34],e[35]!==M||e[36]!==R||e[37]!==x?(L=i.jsx(Ea,{children:i.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[x,M,R]})}),e[35]=M,e[36]=R,e[37]=x,e[38]=L):L=e[38],e[39]!==I||e[40]!==L||e[41]!==N?(z=i.jsxs("div",{className:N,children:[k,I,A,O,D,L]}),e[39]=I,e[40]=L,e[41]=N,e[42]=z):z=e[42],e[43]!==z||e[44]!==w||e[45]!==j?(T=i.jsxs(i.Fragment,{children:[w,j,z]}),e[43]=z,e[44]=w,e[45]=j,e[46]=T):T=e[46],T},pb=t=>{const e=P.c(8),{needsRun:n,onRun:o}=t,r=ie(Hp);if(n){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=St("global.runStale"),e[0]=c):c=e[0];const d=r?o:void 0,u=!r;let h,m;return e[1]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Uo,{strokeWidth:1.5,size:16}),e[1]=h):h=e[1],e[2]!==d||e[3]!==u?(m=i.jsx(pe,{content:c,children:i.jsx(tn,{"data-testid":"run-button",size:"medium",color:"yellow",shape:"circle",onClick:d,disabled:u,children:h})}),e[2]=d,e[3]=u,e[4]=m):m=e[4],m}const s=!r;let a,l;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(Uo,{strokeWidth:1.5,size:16}),e[5]=a):a=e[5],e[6]!==s?(l=i.jsx(pe,{content:"Nothing to run",children:i.jsx(tn,{"data-testid":"run-button",className:"inactive-button",color:"disabled",size:"medium",shape:"circle",disabled:s,children:a})}),e[6]=s,e[7]=l):l=e[7],l},gb=t=>{const e=P.c(8),{running:n,onInterrupt:o}=t,r=cu(n);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=St("global.interrupt"),e[0]=s):s=e[0];const a=!r&&"inactive-button active:shadow-xs-solid";let l;e[1]!==a?(l=ue(a),e[1]=a,e[2]=l):l=e[2];const c=r?"yellow":"disabled",d=r?o:Bn.NOOP;let u,h;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Bl,{strokeWidth:1.5,size:16}),e[3]=u):u=e[3],e[4]!==l||e[5]!==c||e[6]!==d?(h=i.jsx(pe,{content:s,children:i.jsx(tn,{className:l,"data-testid":"interrupt-button",size:"medium",color:c,shape:"circle",onClick:d,children:u})}),e[4]=l,e[5]=c,e[6]=d,e[7]=h):h=e[7],h},bb="absolute top-3 right-5 m-0 flex items-center gap-2 min-h-[28px] no-print pointer-events-auto z-30 print:hidden",xb="absolute bottom-5 right-5 flex flex-col gap-2 items-center no-print pointer-events-auto z-30 print:hidden",yb=t=>{const e=P.c(7),{filename:n}=t,o=zp();let r;e[0]!==n?(r=n?Ot.basename(n):"untitled marimo notebook",e[0]=n,e[1]=r):r=e[1];const s=n===null?"missing-filename":"filename";let a;return e[2]!==n||e[3]!==o||e[4]!==r||e[5]!==s?(a=i.jsx(au,{placeholderText:r,initialValue:n,onNameChange:o,flexibleWidth:!0,resetOnBlur:!0,"data-testid":"filename-input",className:s}),e[2]=n,e[3]=o,e[4]=r,e[5]=s,e[6]=a):a=e[6],a},ni=()=>({entries:new Map}),{valueAtom:hu,useActions:mu}=Ql(ni,{submit:(t,e)=>{const{cellIds:n,deleteCell:o,deleteManyCells:r,store:s}=e,a=s.get(Gt),l=s.get(Jp),c=new Set(a.cellIds.inOrderIds.filter(h=>a.cellData[h].code.trim()==="")),d=new Map;for(const h of n){if(c.has(h)){d.set(h,{cellId:h,type:"simple"});continue}const m=a.cellRuntime[h],p=new Map;for(const x of Object.values(l)){const f=x.declaredBy.includes(h),g=x.usedBy.some(y=>!c.has(y));f&&g&&p.set(x.name,x.usedBy)}let b;m!=null&&m.runElapsedTimeMs&&m.runElapsedTimeMs>2e3&&(b=m.runElapsedTimeMs),p.size===0&&b===void 0?d.set(h,{cellId:h,type:"simple"}):d.set(h,{cellId:h,type:"expensive",executionDurationMs:b,defs:p})}const u=[...d.values()].every(h=>h.type==="simple");return d.size>0&&u?(d.size===1?o({cellId:[...d.values()][0].cellId}):r({cellIds:[...d.values()].map(h=>h.cellId)}),ni()):{...t,entries:d}},clear:()=>ni()});function Ko(){const t=na(),{submit:e,clear:n}=mu(),{entries:o}=ie(hu),r=Cr(),s=Nr();return S.useMemo(()=>({submit:a=>{e({cellIds:a,deleteCell:r,deleteManyCells:s,store:t})},clear:n,get idle(){return o.size===0},get shouldConfirmDelete(){return o.size>1}}),[t,e,n,o,r,s])}function vb(t){return t.cellId}function fu(){return{selectionStart:null,selectionEnd:null,selected:new Set}}const{valueAtom:oi,useActions:wb}=Ql(fu,{select:(t,e)=>({selectionStart:e.cellId,selectionEnd:e.cellId,selected:new Set([e.cellId])}),extend:(t,e)=>{if(!t.selectionStart)return{selectionStart:e.cellId,selectionEnd:e.cellId,selected:new Set([e.cellId])};const{cellId:n,allCellIds:o}=e;try{const r=o.findWithId(t.selectionStart),s=r.indexOfOrThrow(t.selectionStart),a=r.indexOfOrThrow(n),[l,c]=s<a?[s,a]:[a,s],d=r.slice(l,c+1);return{selectionStart:t.selectionStart,selectionEnd:n,selected:new Set(d)}}catch{return{selectionStart:n,selectionEnd:n,selected:new Set([n])}}},clear:t=>t.selected.size===0?t:fu()});function ns(){return wb()}const kb=t=>{const e=P.c(14),{actions:n,cellIds:o,disabled:r}=t;let s,a,l,c,d;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(Ca,{size:13,strokeWidth:1.5}),e[0]=s):s=e[0],e[1]!==r?(a=i.jsx(Un,{asChild:!0,children:i.jsx(ye,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",title:"More actions",disabled:r,children:s})}),e[1]=r,e[2]=a):a=e[2],e[3]!==n||e[4]!==o){let u;e[6]!==n.length||e[7]!==o?(u=(h,m)=>{const p=h.map(b=>i.jsx(lo,{onSelect:()=>b.handle(o),className:"flex items-center gap-2",children:i.jsxs("div",{className:"flex items-center flex-1",children:[b.icon&&i.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:b.icon}),i.jsx("div",{className:"flex-1",children:b.label}),b.hotkey&&i.jsx(Vl,{shortcut:b.hotkey,className:"ml-4"})]})},b.label));return i.jsxs(me.Fragment,{children:[p,m<n.length-1&&i.jsx(En,{})]},m)},e[6]=n.length,e[7]=o,e[8]=u):u=e[8],l=n.flatMap(u),e[3]=n,e[4]=o,e[5]=l}else l=e[5];return e[9]!==l?(c=i.jsx(Wn,{align:"start","data-keep-cell-selection":!0,children:l}),e[9]=l,e[10]=c):c=e[10],e[11]!==a||e[12]!==c?(d=i.jsxs(zn,{children:[a,c]}),e[11]=a,e[12]=c,e[13]=d):d=e[13],d};function jb(t){return t.length>0}function Cb(t){return t.filter(Nb)}function Nb(t){return!t.hidden}function Sb(t){return t.length>0}function Eb(t){return t.filter(_b)}function _b(t){return!t.hidden}function Ib(t){const e={};t.forEach(n=>{const o=Yp(n);o&&(e[n]=o)}),Xp(e)}const Ab=()=>{const t=P.c(4),e=ie(oi);let n;t[0]!==e.selected?(n=[...e.selected],t[0]=e.selected,t[1]=n):n=t[1];const o=n;if(o.length<2)return null;let r;return t[2]!==o?(r=i.jsxs(i.Fragment,{children:[i.jsx(Db,{cellIds:o}),i.jsx(Tb,{cellIds:o})]}),t[2]=o,t[3]=r):r=t[3],r},ri=()=>{const t=P.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"h-4 w-px bg-border mx-1"}),t[0]=e):e=t[0],e},Tb=t=>{const e=P.c(12),{cellIds:n}=t,o=Ko(),r=Nr(),s=ns();if(!o.shouldConfirmDelete)return null;let a,l,c,d,u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(Zl,{className:"w-4 h-4 text-(--amber-11) mt-0.5 shrink-0"}),e[0]=a):a=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("div",{className:"font-code text-sm text-[0.84375rem]",children:[i.jsx("p",{className:"text-(--amber-11) font-medium",children:"Some cells in selection may contain expensive operations."}),i.jsx("p",{className:"text-(--amber-11) mt-1",children:"Are you sure you want to delete?"})]}),e[1]=l):l=e[1],e[2]!==o?(c=i.jsx(ye,{size:"xs",variant:"ghost",onClick:()=>o.clear(),className:"text-(--amber-11) hover:bg-(--amber-4) hover:text-(--amber-11)",children:"Cancel"}),e[2]=o,e[3]=c):c=e[3],e[4]!==n||e[5]!==r||e[6]!==o||e[7]!==s?(d=i.jsx(ye,{size:"xs",variant:"secondary",onClick:()=>{r({cellIds:n}),o.clear(),s.clear()},className:"bg-(--amber-11) hover:bg-(--amber-12) text-white border-(--amber-11)",children:"Delete"}),e[4]=n,e[5]=r,e[6]=o,e[7]=s,e[8]=d):d=e[8],e[9]!==c||e[10]!==d?(u=i.jsx("div",{className:"absolute top-12 justify-center flex w-full left-0 right-0 z-50","data-keep-cell-selection":!0,children:i.jsx("div",{className:"mx-20",children:i.jsx("div",{className:"bg-(--amber-2) border border-(--amber-6) rounded-lg shadow-lg mt-14 px-4 py-3 animate-in slide-in-from-top-2 duration-200",children:i.jsxs("div",{className:"flex items-start gap-3",children:[a,i.jsxs("div",{className:"flex-1",children:[l,i.jsx(Hl,{restoreFocus:!0,autoFocus:!0,children:i.jsxs("div",{className:"flex items-center gap-2 mt-3",onKeyDown:Mb,children:[c,d]})})]})]})})})}),e[9]=c,e[10]=d,e[11]=u):u=e[11],u},Db=t=>{const e=P.c(23),{cellIds:n}=t,o=ns(),r=Ko(),{actions:s,moreActions:a}=(function(f){const g=P.c(31),{updateCellConfig:y,moveCell:w,clearCellOutput:j,sendToTop:C,sendToBottom:N}=Ye(),k=Nr(),E=ie(Kp),_=ns(),I=Ho(),A=Ko(),O=ie(ra),{saveCellConfig:D}=qe(),M=f.length,R=!E||M<f.length;let L;g[0]!==k||g[1]!==A||g[2]!==_||g[3]!==O?(L=ee=>{A.idle&&O.keymap.destructive_delete?A.submit(ee):(k({cellIds:ee}),A.clear(),_.clear())},g[0]=k,g[1]=A,g[2]=_,g[3]=O,g[4]=L):L=g[4];const z=Ce(L);let T;g[5]!==w?(T=(ee,oe)=>{if(oe==="down"){const se=ee[ee.length-1];if(Le.get(Gt).cellIds.findWithId(se).last()===se)return}if(oe==="up"){const se=ee[0];if(Le.get(Gt).cellIds.findWithId(se).first()===se)return}(oe==="up"?ee:[...ee].reverse()).forEach(se=>{w({cellId:se,before:oe==="up"})})},g[5]=w,g[6]=T):T=g[6];const F=Ce(T);let $;g[7]!==C?($=ee=>{[...ee].reverse().forEach(oe=>{C({cellId:oe})})},g[7]=C,g[8]=$):$=g[8];const W=Ce($);let G;g[9]!==N?(G=ee=>{ee.forEach(oe=>{N({cellId:oe})})},g[9]=N,g[10]=G):G=g[10];const X=Ce(G),H=Ce(Ib);let Y;g[11]!==j?(Y=ee=>{ee.forEach(oe=>{j({cellId:oe})})},g[11]=j,g[12]=Y):Y=g[12];const K=Ce(Y);let V;g[13]!==D||g[14]!==y?(V=async(ee,oe,se)=>{const ae={};ee.forEach(te=>{ae[te]={[oe]:se}}),await D({configs:ae}),ee.forEach(te=>{y({cellId:te,config:ae[te]})})},g[13]=D,g[14]=y,g[15]=V):V=g[15];const q=Ce(V);let U,ne,Q;if(g[16]===Symbol.for("react.memo_cache_sentinel")?(U=i.jsx(Uo,{size:13,strokeWidth:1.5}),g[16]=U):U=g[16],g[17]!==I?(ne=ee=>I(ee),g[17]=I,g[18]=ne):ne=g[18],g[19]!==R||g[20]!==K||g[21]!==z||g[22]!==H||g[23]!==F||g[24]!==X||g[25]!==W||g[26]!==ne||g[27]!==q){const ee=[[{icon:U,label:"Run cells",handle:ne,hotkey:"cell.run"}],[{icon:i.jsx(sa,{size:13,strokeWidth:1.5}),label:"Move up",handle:te=>F(te,"up"),hotkey:"cell.moveUp"},{icon:i.jsx($n,{size:13,strokeWidth:1.5}),label:"Move down",handle:te=>F(te,"down"),hotkey:"cell.moveDown"}],[{icon:i.jsx(ec,{size:13,strokeWidth:1.5}),label:"Delete cells",variant:"danger",hidden:!R,handle:z}]],oe=[[{icon:i.jsx(Qp,{size:13,strokeWidth:1.5}),label:"Format cells",handle:H,hotkey:"cell.format"},{icon:i.jsx(Ks,{size:13,strokeWidth:1.5}),label:"Clear outputs",handle:K}],[{icon:i.jsx($l,{size:13,strokeWidth:1.5}),label:"Hide code",handle:te=>q(te,"hide_code",!0),hotkey:"cell.hideCode"},{icon:i.jsx(Zp,{size:13,strokeWidth:1.5}),label:"Show code",handle:te=>q(te,"hide_code",!1),hotkey:"cell.hideCode"}],[{icon:i.jsx(sa,{size:13,strokeWidth:1.5}),label:"Move up",handle:te=>F(te,"up"),hotkey:"cell.moveUp"},{icon:i.jsx($n,{size:13,strokeWidth:1.5}),label:"Move down",handle:te=>F(te,"down"),hotkey:"cell.moveDown"},{icon:i.jsx(Ma,{size:13,strokeWidth:1.5}),label:"Send to top",handle:W,hotkey:"cell.sendToTop"},{icon:i.jsx(gt,{size:13,strokeWidth:1.5}),label:"Send to bottom",handle:X,hotkey:"cell.sendToBottom"}],[{icon:i.jsx(Et,{size:13,strokeWidth:1.5}),label:"Disable cells",handle:te=>q(te,"disabled",!0)},{icon:i.jsx(_t,{size:13,strokeWidth:1.5}),label:"Enable cells",handle:te=>q(te,"disabled",!1)}]],se=ee.map(Eb);let ae;g[29]!==se?(ae=se.filter(Sb),g[29]=se,g[30]=ae):ae=g[30],Q={actions:ae,moreActions:oe.map(Cb).filter(jb)},g[19]=R,g[20]=K,g[21]=z,g[22]=H,g[23]=F,g[24]=X,g[25]=W,g[26]=ne,g[27]=q,g[28]=Q}else Q=g[28];return Q})(n),l=n.length;let c;e[0]!==r||e[1]!==o?(c=f=>{(f.target instanceof HTMLElement||f.target instanceof SVGElement)&&f.target.closest("[data-keep-cell-selection]")!==null||f.target instanceof HTMLHtmlElement||(r.clear(),o.clear())},e[0]=r,e[1]=o,e[2]=c):c=e[2],Gp(window,"mousedown",c);const d=!r.idle;let u,h,m,p,b,x;if(e[3]!==l?(u=i.jsxs("span",{className:"text-sm font-medium text-muted-foreground px-2 shrink-0",children:[l," cells selected"]}),e[3]=l,e[4]=u):u=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(ri,{}),e[5]=h):h=e[5],e[6]!==s||e[7]!==n||e[8]!==d){let f;e[10]!==s.length||e[11]!==n||e[12]!==d?(f=(g,y)=>i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[g.map(w=>i.jsxs(ye,{variant:w.variant==="danger"?"linkDestructive":"ghost",size:"sm",onClick:()=>w.handle(n),className:"h-8 px-2 gap-1 shrink-0 flex items-center",title:w.label,disabled:d&&w.label!=="Delete cells",children:[w.icon,i.jsx("span",{className:"text-xs",children:w.label}),w.hotkey&&i.jsx("div",{className:"ml-1 border bg-muted rounded-md px-1",children:i.jsx(Vl,{shortcut:w.hotkey})})]},w.label)),y<s.length-1&&i.jsx(ri,{})]},y),e[10]=s.length,e[11]=n,e[12]=d,e[13]=f):f=e[13],m=s.map(f),e[6]=s,e[7]=n,e[8]=d,e[9]=m}else m=e[9];return e[14]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(ri,{}),e[14]=p):p=e[14],e[15]!==n||e[16]!==d||e[17]!==a?(b=i.jsx(kb,{actions:a,cellIds:n,disabled:d}),e[15]=n,e[16]=d,e[17]=a,e[18]=b):b=e[18],e[19]!==u||e[20]!==m||e[21]!==b?(x=i.jsx("div",{className:"absolute top-12 justify-center flex w-full left-0 right-0 z-50","data-keep-cell-selection":!0,children:i.jsx("div",{className:"bg-background/95 backdrop-blur-sm supports-backdrop-filter:bg-background/60 border border-(--slate-7) rounded-lg shadow-lg p-2 overflow-x-auto overflow-y-hidden mx-20 scrollbar-thin",children:i.jsxs("div",{className:"flex items-center gap-1",children:[u,h,m,p,b]})})}),e[19]=u,e[20]=m,e[21]=b,e[22]=x):x=e[22],x};function Mb(t){t.stopPropagation()}const Ob={display:"none"};function Rb(t){let{id:e,value:n}=t;return me.createElement("div",{id:e,style:Ob},n)}function Lb(t){let{id:e,announcement:n,ariaLiveType:o="assertive"}=t;return me.createElement("div",{id:e,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":o,"aria-atomic":!0},n)}const pu=S.createContext(null),Fb={draggable:`
97
+ `)}}class r0 extends pt{generateImports(){return[]}generateConnectionCode(){const e=this.orm!=="ibis",n=this.secrets.printPassword(this.connection.access_token,"DATABRICKS_ACCESS_TOKEN",e,"access_token"),o=this.secrets.printPassword(this.connection.server_hostname,"DATABRICKS_SERVER_HOSTNAME",e,"server_hostname"),r=this.secrets.printPassword(this.connection.http_path,"DATABRICKS_HTTP_PATH",e,"http_path"),s=this.connection.catalog?this.secrets.printInFString("catalog",this.connection.catalog):void 0,a=this.connection.schema?this.secrets.printInFString("schema",this.connection.schema):void 0;let l=`databricks://token:${n}@${o}?http_path=${r}`;return s&&(l+=`&catalog=${s}`),a&&(l+=`&schema=${a}`),this.orm==="ibis"?Ue(`
98
+ engine = ibis.databricks.connect(
99
+ server_hostname=${o},
100
+ http_path=${r},${s?`
101
+ catalog=${s},`:""}${a?`
102
+ schema=${a},`:""}
103
+ access_token=${n}
104
+ )
105
+ `):Ue(`
106
+ DATABASE_URL = f"${l}"
107
+ engine = ${this.orm}.create_engine(DATABASE_URL)
108
+ `)}}class s0{constructor(){this.secrets=new Wg}createGenerator(e,n){switch(e.type){case"postgres":return new $g(e,n,this.secrets);case"mysql":return new Vg(e,n,this.secrets);case"sqlite":return new Gg(e,n,this.secrets);case"snowflake":return new qg(e,n,this.secrets);case"bigquery":return new Hg(e,n,this.secrets);case"duckdb":return new Jg(e,n,this.secrets);case"motherduck":return new Kg(e,n,this.secrets);case"clickhouse_connect":return new Yg(e,n,this.secrets);case"timeplus":return new Xg(e,n,this.secrets);case"chdb":return new Qg(e,n,this.secrets);case"trino":return new Zg(e,n,this.secrets);case"iceberg":return new e0(e,n,this.secrets);case"datafusion":return new t0(e,n,this.secrets);case"pyspark":return new n0(e,n,this.secrets);case"redshift":return new o0(e,n,this.secrets);case"databricks":return new r0(e,n,this.secrets);default:Il(e)}}}function ho(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function Zr(t,e){return Object.entries(t).filter(([,n])=>n!=null&&n!=="").map(([n,o])=>e(typeof o=="boolean"?`${n}=${ho(o)}`:`${n}=${o}`)).join(`,
109
+ `)}Wc=function(t){return t.sort((e,n)=>e.provider==="env"?1:n.provider==="env"?-1:0)},Oc=t=>{const e=z.c(43),{providerNames:n,onClose:o,onSuccess:r}=t,{writeSecret:s}=qe(),[a,l]=he.useState(""),[c,d]=he.useState(""),[u,h]=he.useState(n[0]);let m;e[0]!==a||e[1]!==u||e[2]!==r||e[3]!==c||e[4]!==s?(m=async T=>{if(T.preventDefault(),u)if(a&&c&&u)try{await s({key:a,value:c,provider:"dotenv",name:u}),ze({title:"Secret created",description:"The secret has been created successfully."}),r(a)}catch{ze({title:"Error",description:"Failed to create secret. Please try again.",variant:"danger"})}else ze({title:"Error",description:"Please fill in all fields.",variant:"danger"});else ze({title:"Error",description:"No location selected for the secret.",variant:"danger"})},e[0]=a,e[1]=u,e[2]=r,e[3]=c,e[4]=s,e[5]=m):m=e[5];const p=m;let b,x,f,g,y,w,j,C,N,k,E,_,I,A,O,D;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsxs(xr,{children:[i.jsx(so,{children:"Add Secret"}),i.jsx(yr,{children:"Add a new secret to your environment variables."})]}),e[6]=b):b=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Ao,{htmlFor:"key",children:"Key"}),e[7]=x):x=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(f=T=>{l(T.target.value.replaceAll(/\W/g,"_"))},e[8]=f):f=e[8],e[9]!==a?(g=i.jsxs("div",{className:"grid gap-2",children:[x,i.jsx(ao,{id:"key",value:a,onChange:f,placeholder:"MY_SECRET_KEY",required:!0})]}),e[9]=a,e[10]=g):g=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(Ao,{htmlFor:"value",children:"Value"}),e[11]=y):y=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(w=T=>d(T.target.value),e[12]=w):w=e[12],e[13]!==c?(j=i.jsx(ao,{id:"value",type:"text",value:c,onChange:w,required:!0,autoComplete:"off"}),e[13]=c,e[14]=j):j=e[14],e[15]===Symbol.for("react.memo_cache_sentinel")?(C=window.location.href.startsWith("http://")&&i.jsx(xp,{children:"Note: You are sending this key over http."}),e[15]=C):C=e[15],e[16]!==j?(N=i.jsxs("div",{className:"grid gap-2",children:[y,j,C]}),e[16]=j,e[17]=N):N=e[17],e[18]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx(Ao,{htmlFor:"location",children:"Location"}),e[18]=k):k=e[18],e[19]!==n.length?(E=n.length===0&&i.jsx("p",{className:"text-sm text-muted-foreground",children:"No dotenv locations configured."}),e[19]=n.length,e[20]=E):E=e[20],e[21]!==u||e[22]!==n?(_=n.length>0&&i.jsxs(Al,{value:u,onValueChange:T=>h(T),children:[i.jsx(Tl,{children:i.jsx(Dl,{placeholder:"Select a provider"})}),i.jsx(Ml,{children:n.map(a0)})]}),e[21]=u,e[22]=n,e[23]=_):_=e[23],e[24]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsxs(xp,{children:["You can configure the location by setting the"," ",i.jsx(Rl,{href:"https://links.marimo.app/dotenv",children:"dotenv configuration"}),"."]}),e[24]=I):I=e[24],e[25]!==E||e[26]!==_?(A=i.jsxs("div",{className:"grid gap-2",children:[k,E,_,I]}),e[25]=E,e[26]=_,e[27]=A):A=e[27],e[28]!==N||e[29]!==A||e[30]!==g?(O=i.jsxs("div",{className:"grid gap-4 py-4",children:[g,N,A]}),e[28]=N,e[29]=A,e[30]=g,e[31]=O):O=e[31],e[32]!==o?(D=i.jsx(ye,{type:"button",variant:"outline",onClick:o,children:"Cancel"}),e[32]=o,e[33]=D):D=e[33];const M=!a||!c||!u;let R,L,P;return e[34]!==M?(R=i.jsx(ye,{type:"submit",disabled:M,children:"Add Secret"}),e[34]=M,e[35]=R):R=e[35],e[36]!==D||e[37]!==R?(L=i.jsxs(Hs,{children:[D,R]}),e[36]=D,e[37]=R,e[38]=L):L=e[38],e[39]!==p||e[40]!==O||e[41]!==L?(P=i.jsx(io,{children:i.jsxs("form",{onSubmit:p,children:[b,O,L]})}),e[39]=p,e[40]=O,e[41]=L,e[42]=P):P=e[42],P};function a0(t){return i.jsx(Ol,{value:t,children:t},t)}const Hd=S.createContext({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:Pn.NOOP}),i0=t=>{const e=z.c(14),{children:n}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const{data:r,isPending:s,error:a,refetch:l}=vr(u0,o);let c,d,u,h;return e[1]!==(r==null?void 0:r.secretKeys)?(c=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=c):c=e[2],e[3]!==(r==null?void 0:r.providerNames)?(d=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=d):d=e[4],e[5]!==a||e[6]!==s||e[7]!==l||e[8]!==c||e[9]!==d?(u={secretKeys:c,providerNames:d,loading:s,error:a,refreshSecrets:l},e[5]=a,e[6]=s,e[7]=l,e[8]=c,e[9]=d,e[10]=u):u=e[10],e[11]!==n||e[12]!==u?(h=i.jsx(Hd,{value:u,children:n}),e[11]=n,e[12]=u,e[13]=h):h=e[13],h};function l0(t){return t.provider!=="env"}function c0(t){return t.name}function d0(t){return t.keys}async function u0(){const t=await pC.request({}),e=Wc(t.secrets).filter(l0).map(c0);return{secretKeys:t.secrets.flatMap(d0).sort(),providerNames:e}}let Ja,Ka,Jd,Kd,Yd,Xd,Ya;Ja=[{name:"PostgreSQL",schema:Ad,color:"#336791",logo:"postgres",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"MySQL",schema:Td,color:"#00758F",logo:"mysql",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"SQLite",schema:Dd,color:"#003B57",logo:"sqlite",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DuckDB",schema:Md,color:"#FFD700",logo:"duckdb",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"MotherDuck",schema:Od,color:"#ff9538",logo:"motherduck",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"Snowflake",schema:Rd,color:"#29B5E8",logo:"snowflake",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse",schema:Fd,color:"#2C2C1D",logo:"clickhouse",connectionLibraries:{libraries:["clickhouse_connect"],preferred:"clickhouse_connect"}},{name:"Timeplus",schema:Bd,color:"#B83280",logo:"timeplus",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"BigQuery",schema:Ld,color:"#4285F4",logo:"bigquery",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse Embedded",schema:Pd,color:"#f2b611",logo:"clickhouse",connectionLibraries:{libraries:["chdb"],preferred:"chdb"}},{name:"Trino",schema:zd,color:"#d466b6",logo:"trino",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DataFusion",schema:Wd,color:"#202A37",logo:"datafusion",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"PySpark",schema:$d,color:"#1C5162",logo:"pyspark",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"Redshift",schema:Vd,color:"#522BAE",logo:"redshift",connectionLibraries:{libraries:["redshift"],preferred:"redshift"}},{name:"Databricks",schema:Gd,color:"#c41e0c",logo:"databricks",connectionLibraries:{libraries:["sqlalchemy","sqlmodel","ibis"],preferred:"sqlalchemy"}}],Ka=[{name:"Iceberg",schema:Ud,color:"#000000",logo:"iceberg",connectionLibraries:{libraries:["pyiceberg"],preferred:"pyiceberg"}}],Jd=t=>{const e=z.c(14),{onSelect:n}=t;let o;e[0]!==n?(o=h=>{const{name:m,schema:p,color:b,logo:x}=h;return i.jsxs("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:{backgroundColor:b},onClick:()=>n(p),children:[i.jsx(bk,{name:x,className:"w-8 h-8 text-white brightness-0 invert dark:invert"}),i.jsx("span",{className:"text-white font-medium text-lg",children:m})]},m)},e[0]=n,e[1]=o):o=e[1];const r=o;let s,a,l,c,d,u;return e[2]!==r?(s=Ja.map(r),e[2]=r,e[3]=s):s=e[3],e[4]!==s?(a=i.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[4]=s,e[5]=a):a=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("h4",{className:"font-semibold text-muted-foreground text-lg flex items-center gap-4",children:["Data Catalogs",i.jsx("hr",{className:"flex-1"})]}),e[6]=l):l=e[6],e[7]!==r?(c=Ka.map(r),e[7]=r,e[8]=c):c=e[8],e[9]!==c?(d=i.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:c}),e[9]=c,e[10]=d):d=e[10],e[11]!==a||e[12]!==d?(u=i.jsxs(i.Fragment,{children:[a,l,d]}),e[11]=a,e[12]=d,e[13]=u):u=e[13],u},Kd=[{isMatch:t=>{if(t instanceof kp||t instanceof hk){const{optionRegex:e}=me.parse(t._def.description||"");return!!e}return!1},Component:({schema:t,form:e,path:n})=>{const{secretKeys:o,providerNames:r,refreshSecrets:s}=S.use(Hd),{openModal:a,closeModal:l}=zn(),{label:c,description:d,optionRegex:u=""}=me.parse(t._def.description||""),[h,m]=ot(o,p=>new RegExp(u,"i").test(p));return i.jsx(yp,{control:e.control,name:n,render:({field:p})=>i.jsxs(vp,{children:[i.jsx(lk,{children:c}),i.jsx(ck,{children:d}),i.jsx(wp,{children:i.jsxs("div",{className:"flex gap-2",children:[t instanceof kp?i.jsx(ao,{...p,value:p.value,onChange:p.onChange,className:de("flex-1")}):i.jsx(dk,{...p,value:p.value,onChange:p.onChange,className:"flex-1"}),i.jsxs(Un,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(ye,{variant:"outline",size:"icon",className:de(Qr(p.value)&&"bg-accent"),children:i.jsx(uk,{className:"h-3 w-3"})})}),i.jsxs($n,{align:"end",className:"max-h-60 overflow-y-auto",children:[i.jsxs(lo,{onSelect:()=>{a(i.jsx(Oc,{providerNames:r,onSuccess:b=>{s(),p.onChange(Ha(b)),l()},onClose:l}))},children:[i.jsx(Wr,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),h.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(En,{}),i.jsx(jp,{children:"Recommended"})]}),h.map(b=>i.jsx(lo,{onSelect:()=>p.onChange(Ha(b)),children:b},b)),m.length>0&&i.jsx(En,{}),m.map(b=>i.jsx(lo,{onSelect:()=>p.onChange(Ha(b)),children:b},b))]})]})]})}),i.jsx(Cp,{})]})})}}],Yd=t=>{var $;const e=z.c(49),{schema:n,onSubmit:o,onBack:r}=t;let s,a,l;e[0]!==n?(s=pk(n),e[0]=n,e[1]=s):s=e[1],e[2]!==n?(a=Np(n),e[2]=n,e[3]=a):a=e[3],e[4]!==s||e[5]!==a?(l={defaultValues:s,resolver:a,reValidateMode:"onChange"},e[4]=s,e[5]=a,e[6]=l):l=e[6];const c=Sp(l),d=($=[...Ja,...Ka].find(W=>W.schema===n))==null?void 0:$.connectionLibraries,[u,h]=S.useState((d==null?void 0:d.preferred)??"sqlalchemy"),{createNewCell:m}=Ke(),p=gk();let b;e[7]!==m||e[8]!==p?(b=W=>{m({code:W,before:!1,cellId:p??"__end__",skipIfCodeExists:!0})},e[7]=m,e[8]=p,e[9]=b):b=e[9];const x=b;let f;e[10]!==x||e[11]!==o||e[12]!==u?(f=W=>{x((function(H,X){if(!(X in qd))throw new Error(`Unsupported library: ${X}`);Ug.parse(H);const q=new s0,Y=q.createGenerator(H,X),J=Y.generateConnectionCode(),V=q.secrets,G=[...new Set([...V.imports,...Y.imports])].sort();G.push("");const U=V.formatSecrets();return U&&G.push(U),G.push(J.trim()),G.join(`
110
+ `)})(W,u)),o()},e[10]=x,e[11]=o,e[12]=u,e[13]=f):f=e[13];const g=f;let y;e[14]!==c||e[15]!==g?(y=c.handleSubmit(g),e[14]=c,e[15]=g,e[16]=y):y=e[16];let w,j;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(xk,{}),e[17]=w):w=e[17],e[18]!==c||e[19]!==n?(j=i.jsx(i0,{children:i.jsx(yk,{schema:n,form:c,renderers:Kd,children:w})}),e[18]=c,e[19]=n,e[20]=j):j=e[20];let C;e[21]!==r?(C=i.jsx(ye,{type:"button",variant:"outline",onClick:r,children:"Back"}),e[21]=r,e[22]=C):C=e[22];const N=!c.formState.isValid;let k,E;e[23]!==N?(k=i.jsx(ye,{type:"submit",disabled:N,children:"Add"}),e[23]=N,e[24]=k):k=e[24],e[25]!==C||e[26]!==k?(E=i.jsxs("div",{className:"flex gap-2",children:[C,k]}),e[25]=C,e[26]=k,e[27]=E):E=e[27];const _=Al;let I,A;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=W=>h(W),e[28]=I):I=e[28],e[29]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsxs("div",{className:"flex flex-col gap-1 items-end",children:[i.jsx(Tl,{children:i.jsx(Dl,{placeholder:"Select a library"})}),i.jsx("span",{className:"text-xs text-muted-foreground",children:"Preferred connection library"})]}),e[29]=A):A=e[29];const O=Ml,D=Ep,M=d==null?void 0:d.libraries.map(h0);let R,L,P,T,F;return e[30]!==D||e[31]!==M?(R=i.jsx(D,{children:M}),e[30]=D,e[31]=M,e[32]=R):R=e[32],e[33]!==O||e[34]!==R?(L=i.jsx(O,{children:R}),e[33]=O,e[34]=R,e[35]=L):L=e[35],e[36]!==_||e[37]!==u||e[38]!==I||e[39]!==A||e[40]!==L?(P=i.jsx("div",{children:i.jsxs(_,{value:u,onValueChange:I,children:[A,L]})}),e[36]=_,e[37]=u,e[38]=I,e[39]=A,e[40]=L,e[41]=P):P=e[41],e[42]!==E||e[43]!==P?(T=i.jsxs("div",{className:"flex gap-2 justify-between",children:[E,P]}),e[42]=E,e[43]=P,e[44]=T):T=e[44],e[45]!==T||e[46]!==y||e[47]!==j?(F=i.jsxs("form",{onSubmit:y,className:"space-y-4",children:[j,T]}),e[45]=T,e[46]=y,e[47]=j,e[48]=F):F=e[48],F},Xd=t=>{const e=z.c(5),{onSubmit:n}=t,[o,r]=S.useState(null);if(!o){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(Jd,{onSelect:r}),e[0]=l):l=e[0],l}let s,a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=()=>r(null),e[1]=s):s=e[1],e[2]!==n||e[3]!==o?(a=i.jsx(Yd,{schema:o,onSubmit:n,onBack:s}),e[2]=n,e[3]=o,e[4]=a):a=e[4],a},ug=t=>{const e=z.c(6),{children:n}=t,[o,r]=S.useState(!1);let s,a,l;return e[0]!==n?(s=i.jsx(mk,{asChild:!0,children:n}),e[0]=n,e[1]=s):s=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(Ya,{onClose:()=>r(!1)}),e[2]=a):a=e[2],e[3]!==o||e[4]!==s?(l=i.jsxs(fk,{open:o,onOpenChange:r,children:[s,a]}),e[3]=o,e[4]=s,e[5]=l):l=e[5],l},Ya=t=>{const e=z.c(4),{onClose:n}=t;let o,r,s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(so,{children:"Add Connection"}),e[0]=o):o=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsxs(xr,{className:"mb-4",children:[o,i.jsxs(yr,{children:["Connect to your database or data catalog to query data directly from your notebook. Learn more about how to connect to your database in our"," ",i.jsx(Rl,{href:"https://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database",children:"docs."})]})]}),e[1]=r):r=e[1],e[2]!==n?(s=i.jsxs(io,{className:"max-h-[75vh] overflow-y-auto",children:[r,i.jsx(Xd,{onSubmit:()=>n()})]}),e[2]=n,e[3]=s):s=e[3],s};function h0(t){return i.jsx(Ol,{value:t,children:qd[t]},t)}const m0=()=>{const t=z.c(7),{selectedLayout:e}=K1(),{setLayoutView:n}=Y1();if(Xt()&&!Ys("wasm_layouts"))return null;let o,r,s,a;return t[0]!==n?(o=l=>n(l),t[0]=n,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(Tl,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:i.jsx(Dl,{placeholder:"Select a view"})}),t[2]=r):r=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(Ml,{children:i.jsxs(Ep,{children:[i.jsx(vk,{children:"View as"}),X1.map(p0)]})}),t[3]=s):s=t[3],t[4]!==e||t[5]!==o?(a=i.jsxs(Al,{"data-testid":"layout-select",value:e,onValueChange:o,children:[r,s]}),t[4]=e,t[5]=o,t[6]=a):a=t[6],a};function f0(t){const e=Qd(t);return i.jsx(e,{className:"h-4 w-4"})}function Qd(t){switch(t){case"vertical":return od;case"grid":return Qj;case"slides":return Fa;default:return Fl(t),Bl}}function Zd(t){return Ll(t)}function p0(t){return i.jsx(Ol,{value:t,children:i.jsxs("div",{className:"flex items-center gap-1.5 leading-5",children:[f0(t),i.jsx("span",{children:Zd(t)})]})},t)}function eu(){const t=z.c(4),{openConfirm:e}=zn(),n=Ct(Nt),{sendRestart:o}=qe();let r;return t[0]!==e||t[1]!==o||t[2]!==n?(r=()=>{e({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:i.jsx(jk,{onClick:async()=>{n({state:mt.CLOSING}),await o(),Ck()},"aria-label":"Confirm Restart",children:"Restart"})})},t[0]=e,t[1]=o,t[2]=n,t[3]=r):r=t[3],r}const Jo=t=>{t==null||t.preventDefault(),t==null||t.stopPropagation()};Lc=function(){var q,Y;const t=z.c(39),e=zl(),{openModal:n,closeModal:o}=zn(),{toggleApplication:r}=wr(),{selectedPanel:s}=Xs(),[a]=_n(Sl),l=ie(To),c=(()=>{const{updateCellConfig:J}=Ke(),{saveCellConfig:V}=qe();return S.useCallback(async()=>{const G=new kk,U=Mt(),ne=U.cellIds.inOrderIds,Q={};for(const te of ne){if(U.cellData[te]===void 0)continue;const{code:se,config:ae}=U.cellData[te];ae.hide_code||G.isSupported(se)&&(Q[te]={hide_code:!0})}const ee=Pl.entries(Q);if(ee.length!==0){await V({configs:Q});for(const[te,se]of ee)J({cellId:te,config:se})}},[J])})(),[d]=Qs(),{updateCellConfig:u,undoDeleteCell:h,clearAllCellOutputs:m,upsertSetupCell:p,collapseAllCells:b,expandAllCells:x}=Ke(),f=eu(),g=_d(),y=(function(J){const V=z.c(5),{openPrompt:G,closeModal:U}=zn(),{sendCopy:ne}=qe();let Q;return V[0]!==U||V[1]!==G||V[2]!==ne||V[3]!==J?(Q=()=>{if(!J)return null;const ee=wk.guessDeliminator(J),te=Ot.basename(J);G({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${te}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:se=>{const ae=ee.join(Ot.dirname(J),se);ne({source:J,destination:ae}).then(()=>{U(),ze({title:"Notebook copied",description:"A copy of the notebook has been created."}),Zj(ae)})}})},V[0]=U,V[1]=G,V[2]=ne,V[3]=J,V[4]=Q):Q=V[4],Q})(e),w=Ct(_a),j=Ct(eC),C=Ct(tC),{exportAsMarkdown:N,readCode:k,saveCellConfig:E}=qe(),_=ie(Nk),I=ie(Sk),A=ie(_p),{selectedLayout:O}=K1(),{setLayoutView:D}=Y1(),M=Ed(),R=((q=d.sharing)==null?void 0:q.html)??!0,L=((Y=d.sharing)==null?void 0:Y.wasm)??!0,P=R0;let T;t[0]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx(hd,{size:14,strokeWidth:1.5}),t[0]=T):T=t[0];const F=!R&&!L;let $;t[1]===Symbol.for("react.memo_cache_sentinel")?($=i.jsx(Ok,{size:14,strokeWidth:1.5}),t[1]=$):$=t[1];const W=!R;let H,X;return t[2]!==o||t[3]!==n?(H=async()=>{n(i.jsx(Bg,{onClose:o}))},t[2]=o,t[3]=n,t[4]=H):H=t[4],t[5]!==A||t[6]!==m||t[7]!==o||t[8]!==b||t[9]!==y||t[10]!==x||t[11]!==N||t[12]!==e||t[13]!==_||t[14]!==I||t[15]!==c||t[16]!==l||t[17]!==n||t[18]!==k||t[19]!==f||t[20]!==g||t[21]!==E||t[22]!==O||t[23]!==s||t[24]!==w||t[25]!==C||t[26]!==D||t[27]!==j||t[28]!==L||t[29]!==F||t[30]!==W||t[31]!==H||t[32]!==r||t[33]!==M||t[34]!==h||t[35]!==u||t[36]!==p||t[37]!==a.mode?(X=[{icon:T,label:"Share",handle:Jo,hidden:F,dropdown:[{icon:$,label:"Publish HTML to web",hidden:W,handle:H},{icon:i.jsx($1,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!L,handle:async()=>{const J=await k(),V=Ek({code:J.contents});await Eo(V),ze({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:i.jsx(Ik,{size:14,strokeWidth:1.5}),label:"Download",handle:Jo,dropdown:[{icon:i.jsx(Z1,{size:14,strokeWidth:1.5}),label:"Download as HTML",handle:async()=>{e?await Q1({filename:e,includeCode:!0}):ze({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:i.jsx(Z1,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{e?await Q1({filename:e,includeCode:!1}):ze({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:i.jsx(Zs,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{const J=await N({download:!1});Ul(new Blob([J],{type:"text/plain"}),Ip.toMarkdown(document.title))}},{icon:i.jsx(Gc,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{const J=await k();Ul(new Blob([J.contents],{type:"text/plain"}),Ip.toPY(document.title))}},{divider:!0,icon:i.jsx(Nc,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:a.mode!=="present",tooltip:a.mode==="present"?void 0:i.jsxs("span",{children:["Only available in app view. ",i.jsx("br",{}),"Toggle with: ",St("global.hideCode",!1)]}),handle:O0},{icon:i.jsx(_k,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:a.mode!=="present",tooltip:a.mode==="present"?void 0:i.jsxs("span",{children:["Only available in app view. ",i.jsx("br",{}),"Toggle with: ",St("global.hideCode",!1)]}),handle:D0}]},{divider:!0,icon:i.jsx(dd,{size:14,strokeWidth:1.5}),label:"Helper panel",handle:Jo,dropdown:Yr.flatMap(J=>{const{type:V,Icon:G,hidden:U}=J;return U?[]:{label:Ll(V),rightElement:P(s===V),icon:i.jsx(G,{size:14,strokeWidth:1.5}),handle:()=>r(V)}})},{icon:i.jsx(Fa,{size:14,strokeWidth:1.5}),label:"Present as",handle:Jo,dropdown:[{icon:a.mode==="present"?i.jsx(Ap,{size:14,strokeWidth:1.5}):i.jsx(Ra,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{M()}},...X1.map((J,V)=>{const G=Qd(J);return{divider:V===0,label:Zd(J),icon:i.jsx(G,{size:14,strokeWidth:1.5}),rightElement:i.jsx("div",{className:"w-8 flex justify-end",children:O===J&&i.jsx(Wl,{size:14})}),handle:()=>{D(J),a.mode==="edit"&&M()}}})]},{icon:i.jsx(Kc,{size:14,strokeWidth:1.5}),label:"Create notebook copy",hidden:!e||Xt(),handle:y},{icon:i.jsx(Ma,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!e,handle:async()=>{const J=await k();await Eo(J.contents),ze({title:"Copied",description:"Code copied to clipboard."})}},{icon:i.jsx(_t,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!_||l,handle:async()=>{const J=Mt(),V=Ak(J),G=Pl.fromEntries(V.map(T0));await E({configs:G});for(const U of V)u({cellId:U,config:{disabled:!1}})}},{icon:i.jsx(Et,{size:14,strokeWidth:1.5}),label:"Disable all cells",hidden:!I||l,handle:async()=>{const J=Mt(),V=mp(J),G=Pl.fromEntries(V.map(A0));await E({configs:G});for(const U of V)u({cellId:U,config:{disabled:!0}})}},{icon:i.jsx($l,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:c},{icon:i.jsx(Vc,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:b},{icon:i.jsx($c,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:x},{icon:i.jsx(qc,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{p({code:"# Initialization code that runs before all other cells"})}},{icon:i.jsx(Ks,{size:14,strokeWidth:1.5}),label:"Clear all outputs",handle:()=>{m()}},{icon:i.jsx(Hc,{size:14,strokeWidth:1.5}),label:"Re-run all cells",hotkey:"global.runAll",handle:async()=>{g()}},{icon:i.jsx(Pa,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!A||l,handle:()=>{h()}},{icon:i.jsx(_o,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n(i.jsx(Ya,{onClose:o}))}},{divider:!0,icon:i.jsx(Oa,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>w(I0)},{icon:i.jsx(Tk,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>j(_0)},{icon:i.jsx(nd,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>C(E0)},{icon:i.jsx(V1,{size:14,strokeWidth:1.5}),label:"Open documentation",handle:S0},{icon:i.jsx(Dk,{size:14,strokeWidth:1.5}),label:"Resources",handle:Jo,dropdown:[{icon:i.jsx(V1,{size:14,strokeWidth:1.5}),label:"Documentation",handle:N0},{icon:i.jsx(nC,{size:14,strokeWidth:1.5}),label:"GitHub",handle:C0},{icon:i.jsx(oC,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:j0},{icon:i.jsx(rC,{size:14,strokeWidth:1.5}),label:"YouTube",handle:k0},{icon:i.jsx(bp,{size:14,strokeWidth:1.5}),label:"Changelog",handle:w0}]},{divider:!0,icon:i.jsx(ed,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:v0},{icon:i.jsx(_c,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:y0},{icon:i.jsx(gd,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:f}].filter(x0).map(g0),t[5]=A,t[6]=m,t[7]=o,t[8]=b,t[9]=y,t[10]=x,t[11]=N,t[12]=e,t[13]=_,t[14]=I,t[15]=c,t[16]=l,t[17]=n,t[18]=k,t[19]=f,t[20]=g,t[21]=E,t[22]=O,t[23]=s,t[24]=w,t[25]=C,t[26]=D,t[27]=j,t[28]=L,t[29]=F,t[30]=W,t[31]=H,t[32]=r,t[33]=M,t[34]=h,t[35]=u,t[36]=p,t[37]=a.mode,t[38]=X):X=t[38],X};function g0(t){return t.dropdown?{...t,dropdown:t.dropdown.filter(b0)}:t}function b0(t){return!t.hidden}function x0(t){return!t.hidden}function y0(){const t=Mk();window.open(t,"_blank")}function v0(){const t=document.baseURI.split("?")[0];window.open(t,"_self")}function w0(){window.open(Yt.releasesPage,"_blank")}function k0(){window.open(Yt.youtube,"_blank")}function j0(){window.open(Yt.discordLink,"_blank")}function C0(){window.open(Yt.githubPage,"_blank")}function N0(){window.open(Yt.docsPage,"_blank")}function S0(){window.open(Yt.docsPage,"_blank")}function E0(t){return!t}function _0(t){return!t}function I0(t){return!t}function A0(t){return[t,{disabled:!0}]}function T0(t){return[t,{disabled:!1}]}async function D0(){const t=new Event("export-beforeprint"),e=new Event("export-afterprint");window.dispatchEvent(t),setTimeout(M0,0),setTimeout(()=>window.dispatchEvent(e),0)}function M0(){return window.print()}async function O0(){const t=document.getElementById("App");t&&await Tp(t,document.title)}function R0(t){return i.jsx("div",{className:"w-8 flex justify-end",children:t&&i.jsx(Wl,{size:14})})}const L0=t=>{const e=z.c(33),{disabled:n,tooltip:o}=t,r=n!==void 0&&n,s=o===void 0?"Actions":o,a=Lc(),{locale:l}=dp();let c,d,u;e[0]!==s?(c=i.jsx("div",{children:s}),e[0]=s,e[1]=c):c=e[1],e[2]!==r?(d=!r&&i.jsxs("div",{className:"text-xs text-muted-foreground font-medium pt-1 -mt-2 border-t border-border flex items-center gap-2",children:[i.jsx("span",{children:"Open command palette"}),St("global.commandPalette",!1)]}),e[2]=r,e[3]=d):d=e[3],e[4]!==c||e[5]!==d?(u=i.jsxs("div",{className:"flex flex-col gap-2",children:[c,d]}),e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=u,m=r?"disabled":"hint-green";let p,b,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(gC,{strokeWidth:1.8}),e[7]=p):p=e[7],e[8]!==h?(b=i.jsx(pe,{content:h,children:p}),e[8]=h,e[9]=b):b=e[9],e[10]!==r||e[11]!==m||e[12]!==b?(x=i.jsx(tn,{"aria-label":"Config",shape:"circle",size:"small",className:"h-[27px] w-[27px]","data-testid":"notebook-menu-dropdown",disabled:r,color:m,children:b}),e[10]=r,e[11]=m,e[12]=b,e[13]=x):x=e[13];const f=x,g=F0;let y;e[14]===Symbol.for("react.memo_cache_sentinel")?(y=O=>{const D=i.jsx(lo,{variant:O.variant,disabled:O.disabled,onSelect:M=>O.handle(M),"data-testid":`notebook-menu-dropdown-${O.label}`,children:g(O)},O.label);return O.tooltip?i.jsx(pe,{content:O.tooltip,side:"left",delayDuration:100,children:i.jsx("span",{children:D})},O.label):D},e[14]=y):y=e[14];const w=y;let j,C,N,k,E,_,I,A;if(e[15]!==f||e[16]!==r?(j=i.jsx(Wn,{asChild:!0,disabled:r,children:f}),e[15]=f,e[16]=r,e[17]=j):j=e[17],e[18]!==a){let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=D=>D.hidden?null:D.dropdown?i.jsxs(Rk,{children:[i.jsx(Lk,{"data-testid":`notebook-menu-dropdown-${D.label}`,children:g(D)}),i.jsx(Fk,{children:i.jsx(Bk,{children:D.dropdown.map(M=>i.jsxs(he.Fragment,{children:[M.divider&&i.jsx(En,{}),w(M)]},M.label))})})]},D.label):i.jsxs(he.Fragment,{children:[D.divider&&i.jsx(En,{}),w(D)]},D.label),e[20]=O):O=e[20],C=a.map(O),e[18]=a,e[19]=C}else C=e[19];return e[21]===Symbol.for("react.memo_cache_sentinel")?(N=i.jsx(En,{}),e[21]=N):N=e[21],e[22]!==l?(k=i.jsxs("span",{children:["Locale: ",l]}),e[22]=l,e[23]=k):k=e[23],e[24]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsxs("span",{children:["Version: ",Dp()]}),e[24]=E):E=e[24],e[25]!==k?(_=i.jsxs("div",{className:"flex-1 px-2 text-xs text-muted-foreground flex flex-col gap-1",children:[k,E]}),e[25]=k,e[26]=_):_=e[26],e[27]!==C||e[28]!==_?(I=i.jsxs($n,{align:"end",className:"no-print w-[240px]",children:[C,N,_]}),e[27]=C,e[28]=_,e[29]=I):I=e[29],e[30]!==j||e[31]!==I?(A=i.jsxs(Un,{modal:!1,children:[j,I]}),e[30]=j,e[31]=I,e[32]=A):A=e[32],A};function F0(t){return i.jsxs(i.Fragment,{children:[t.icon&&i.jsx("span",{className:"flex-0 mr-2",children:t.icon}),i.jsx("span",{className:"flex-1",children:t.labelElement||t.label}),t.hotkey&&i.jsx(Vl,{shortcut:t.hotkey,className:"ml-4"}),t.rightElement]})}function Xa(t){return Zt("create"in t,'Expected query to have a "create" method'),t}const gt=Pk({findText:"",replaceText:"",caseSensitive:!1,wholeWord:!1,regexp:!1,isOpen:!1,currentView:void 0},(t,e)=>{if(e===void 0)return t;switch(e.type){case"setFind":return{...t,findText:e.find};case"setReplace":return{...t,replaceText:e.replace};case"setCaseSensitive":return{...t,caseSensitive:e.caseSensitive};case"setWholeWord":return{...t,wholeWord:e.wholeWord};case"setRegex":return{...t,regexp:e.regexp};case"setIsOpen":return{...t,isOpen:e.isOpen};case"setCurrentView":return{...t,currentView:{view:e.view,range:e.range}};case"clearCurrentView":return{...t,currentView:void 0}}});function tu(t){if([...document.querySelectorAll('[role="dialog"][data-state="open"]')].some(e=>e instanceof HTMLElement&&e.childNodes.length>0))return!1;if(t){const e=t.state.selection.main,n=t.state.sliceDoc(e.from,e.to);n?(Le.set(gt,{type:"setFind",find:n}),Le.set(gt,{type:"setCurrentView",view:t,range:{from:e.from,to:e.to}})):Le.set(gt,{type:"setCurrentView",view:t,range:{from:0,to:0}})}return Le.get(gt).isOpen?(Le.set(gt,{type:"setIsOpen",isOpen:!1}),requestAnimationFrame(()=>{Le.set(gt,{type:"setIsOpen",isOpen:!0})}),!0):(Le.set(gt,{type:"setIsOpen",isOpen:!0}),!0)}function B0(){return!!Le.get(gt).isOpen&&(Le.set(gt,{type:"setIsOpen",isOpen:!1}),!0)}function es(t){return()=>{const e=Le.get(gt),n=new ea({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord});return!!n.valid&&t({query:Xa(n).create(),search:n})}}const nu=t=>es(({query:e})=>{const n=Do(),o=Le.get(gt).currentView||{view:n[0],range:{from:0,to:0}};let r=o.range.to;t==="prev"&&(n.reverse(),r=o.range.from);let s=n.indexOf(o.view);s<0&&(s=0);const a=[...n,...n].slice(s);for(const l of a){const c=t==="next"?e.nextMatch(l.state,0,r??0):e.prevMatch(l.state,r??l.state.doc.length,l.state.doc.length);if(!c){r=null,l.dispatch({selection:Kt.single(0)});continue}const d=Kt.single(c.from,c.to);return l.dispatch({selection:d,effects:[Se.scrollIntoView(d.main,{y:"center"})],userEvent:"select.search"}),Le.set(gt,{type:"setCurrentView",view:l,range:{from:c.from,to:c.to}}),c}return!1}),Qa=nu("next"),ou=nu("prev"),P0=es(({query:t})=>{var o;const e=Do(),n=[];for(const r of e){if(r.state.readOnly)continue;const s=(o=t.matchAll(r.state,1e9))==null?void 0:o.map(l=>{const{from:c,to:d}=l;return{from:c,to:d,insert:t.getReplacement(l)}});if(!s||s.length===0)continue;const a=r.state.doc.toString();n.push(()=>{r.dispatch({changes:[{from:0,to:r.state.doc.length,insert:a}],userEvent:"input.replace.all"})}),r.dispatch({changes:s,userEvent:"input.replace.all"})}return()=>{for(const r of n)r()}}),z0=es(({query:t})=>{const e=Do(),n=Le.get(gt).currentView||{view:e[0],range:{from:0}};let o=n.range.from,r=e.indexOf(n.view);r<0&&(r=0);const s=[...e,...e].slice(r);for(const a of s){const l=t.nextMatch(a.state,0,o??0);if(!l){o=null,a.dispatch({selection:Kt.single(0)});continue}const c=a.state.toText(t.getReplacement(l));return a.dispatch({changes:[{from:l.from,to:l.to,insert:c}],userEvent:"input.replace"}),Qa()}return!1}),U0=es(({query:t})=>{const e=Do();let n=0;const o=new Map;for(const r of e){const s=t.matchAll(r.state,1e9)||[];for(const a of s){const{from:l,to:c}=a,d=o.get(r)||new Map;d.set(`${l}:${c}`,n++),o.set(r,d)}}return{count:n,position:o}}),Za=nt.define();function ru(){const t=Do();for(const e of t)e.state.readOnly||e.dispatch({effects:Za.of(new ea({search:""}))})}const ts=Dt.define({create(){const t=Le.get(gt);return Xa(new ea({search:t.findText,caseSensitive:t.caseSensitive,regexp:t.regexp,replace:t.replaceText,wholeWord:t.wholeWord})).create()},update(t,e){for(const n of e.effects)n.is(Za)&&(t=Xa(n.value).create());return t}}),W0=Te.mark({class:"cm-searchMatch"}),$0=Te.mark({class:"cm-searchMatch cm-searchMatch-selected"}),V0=Ut.fromClass(class{constructor(t){this.decorations=void 0,this.view=void 0,this.view=t,this.decorations=this.highlight(t.state.field(ts))}update(t){const e=t.state.field(ts);(e!==t.startState.field(ts)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight(t){if(!t.spec.valid)return Te.none;const{view:e}=this,n=new Mo,o=e.visibleRanges,r=o.length;for(let s=0;s<r;s++){let{to:a}=o[s];const{from:l}=o[s];for(;s<r-1&&a>o[s+1].from-500;)a=o[++s].to;t.highlight(e.state,l,a,(c,d)=>{const u=e.state.selection.ranges.some(h=>h.from===c&&h.to===d);n.add(c,d,u?$0:W0)})}return n.finish()}},{decorations:t=>t.decorations}),G0=Se.baseTheme({"&light .cm-searchMatch":{backgroundColor:"#99ff7780"},"&dark .cm-searchMatch":{backgroundColor:"#22bb0070"},"&light .cm-searchMatch-selected":{backgroundColor:"transparent"},"&dark .cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff88 !important"}}),q0=()=>{var we;const t=z.c(102),[e,n]=S.useState(!1),[o,r]=_n(gt),[s,a]=S.useState(),l=S.useRef(null),c=ie(Gl);let d,u;t[0]!==e||t[1]!==o.isOpen?(d=()=>(!e||!o.isOpen)&&tu(),t[0]=e,t[1]=o.isOpen,t[2]=d):d=t[2],st("cell.findAndReplace",d),t[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const be=U0();a(be===!1?void 0:be)},t[3]=u):u=t[3];const h=u;let m,p,b,x;if(t[4]!==o.isOpen?(m=()=>{o.isOpen&&l.current&&(l.current.focus(),l.current.select())},p=[o.isOpen],t[4]=o.isOpen,t[5]=m,t[6]=p):(m=t[5],p=t[6]),S.useEffect(m,p),t[7]!==o.findText||t[8]!==o.isOpen?(b=()=>{if(o.isOpen){if(o.findText==="")return a(void 0),void ru();h(),(function(){const be=Le.get(gt),et=Do();for(const ct of et)ct.state.readOnly||ct.dispatch({effects:Za.of(new ea({search:be.findText,caseSensitive:be.caseSensitive,regexp:be.regexp,replace:be.replaceText,wholeWord:be.wholeWord}))})})()}else ru()},t[7]=o.findText,t[8]=o.isOpen,t[9]=b):b=t[9],t[10]!==o.caseSensitive||t[11]!==o.findText||t[12]!==o.isOpen||t[13]!==o.regexp||t[14]!==o.wholeWord?(x=[o.findText,o.isOpen,o.caseSensitive,o.regexp,o.wholeWord],t[10]=o.caseSensitive,t[11]=o.findText,t[12]=o.isOpen,t[13]=o.regexp,t[14]=o.wholeWord,t[15]=x):x=t[15],S.useEffect(b,x),!o.isOpen)return null;const f=o.currentView;let g;t[16]!==s||t[17]!==f?(g=f&&s?(we=s.position.get(f.view))==null?void 0:we.get(`${f.range.from}:${f.range.to}`):void 0,t[16]=s,t[17]=f,t[18]=g):g=t[18];const y=g;let w,j,C,N,k,E,_,I,A,O,D;t[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>n(!0),t[19]=w):w=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(j=()=>n(!1),t[20]=j):j=t[20],t[21]!==r?(C=be=>{be.key==="Escape"&&r({type:"setIsOpen",isOpen:!1})},t[21]=r,t[22]=C):C=t[22],t[23]!==r?(N=()=>r({type:"setIsOpen",isOpen:!1}),t[23]=r,t[24]=N):N=t[24],t[25]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx($t,{className:"w-4 h-4"}),t[25]=k):k=t[25],t[26]!==N?(E=i.jsx("div",{className:"absolute top-0 right-0",children:i.jsx(ye,{"data-testid":"close-find-replace-button",onClick:N,size:"xs",variant:"text",children:k})}),t[26]=N,t[27]=E):E=t[27],t[28]!==r?(_=be=>{r({type:"setFind",find:be.target.value})},t[28]=r,t[29]=_):_=t[29],t[30]!==o.findText||t[31]!==_?(I=i.jsx(ao,{ref:l,"data-testid":"find-input",value:o.findText,autoFocus:!0,className:"mr-2 mb-0",placeholder:"Find",onKeyDown:J0,onChange:_}),t[30]=o.findText,t[31]=_,t[32]=I):I=t[32],t[33]!==r?(A=be=>{r({type:"setReplace",replace:be.target.value})},t[33]=r,t[34]=A):A=t[34],t[35]!==o.replaceText||t[36]!==A?(O=i.jsx(ao,{"data-testid":"replace-input",value:o.replaceText,placeholder:"Replace",onChange:A}),t[35]=o.replaceText,t[36]=A,t[37]=O):O=t[37],t[38]!==I||t[39]!==O?(D=i.jsxs("div",{className:"flex flex-col flex-2 gap-2 w-[55%]",children:[I,O]}),t[38]=I,t[39]=O,t[40]=D):D=t[40];const M=o.caseSensitive?"on":"off";let R,L,P;t[41]!==r?(R=be=>r({type:"setCaseSensitive",caseSensitive:be}),t[41]=r,t[42]=R):R=t[42],t[43]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(Uk,{className:"w-4 h-4"}),t[43]=L):L=t[43],t[44]!==o.caseSensitive||t[45]!==M||t[46]!==R?(P=i.jsx(pe,{content:"Case Sensitive",children:i.jsx(ql,{size:"sm",pressed:o.caseSensitive,"data-state":M,onPressedChange:R,children:L})}),t[44]=o.caseSensitive,t[45]=M,t[46]=R,t[47]=P):P=t[47];const T=o.wholeWord?"on":"off";let F,$,W;t[48]!==r?(F=be=>r({type:"setWholeWord",wholeWord:be}),t[48]=r,t[49]=F):F=t[49],t[50]===Symbol.for("react.memo_cache_sentinel")?($=i.jsx(yd,{className:"w-4 h-4"}),t[50]=$):$=t[50],t[51]!==o.wholeWord||t[52]!==T||t[53]!==F?(W=i.jsx(pe,{content:"Match Whole Word",children:i.jsx(ql,{size:"sm",pressed:o.wholeWord,"data-state":T,onPressedChange:F,children:$})}),t[51]=o.wholeWord,t[52]=T,t[53]=F,t[54]=W):W=t[54];const H=o.regexp?"on":"off";let X,q,Y,J,V;t[55]!==r?(X=be=>r({type:"setRegex",regexp:be}),t[55]=r,t[56]=X):X=t[56],t[57]===Symbol.for("react.memo_cache_sentinel")?(q=i.jsx(ud,{className:"w-4 h-4"}),t[57]=q):q=t[57],t[58]!==o.regexp||t[59]!==H||t[60]!==X?(Y=i.jsx(pe,{content:"Use Regular Expression",children:i.jsx(ql,{size:"sm",pressed:o.regexp,"data-state":H,onPressedChange:X,children:q})}),t[58]=o.regexp,t[59]=H,t[60]=X,t[61]=Y):Y=t[61],t[62]!==P||t[63]!==W||t[64]!==Y?(J=i.jsxs("div",{className:"flex items-center gap-[2px]",children:[P,W,Y]}),t[62]=P,t[63]=W,t[64]=Y,t[65]=J):J=t[65],t[66]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{z0()&&h()},t[66]=V):V=t[66];const G=o.findText==="";let U,ne;t[67]!==G?(U=i.jsx(ye,{"data-testid":"replace-next-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:V,disabled:G,children:"Replace Next"}),t[67]=G,t[68]=U):U=t[68],t[69]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{const be=P0();if(!be)return;h();const{dismiss:et}=ze({title:"Replaced all occurrences",action:i.jsx(Mp,{"data-testid":"undo-replace-all-button",onClick:()=>{be(),ct()}})}),ct=et},t[69]=ne):ne=t[69];const Q=o.findText==="";let ee,te,se,ae,oe,Ee,ve,ge,ke,fe,Ie,Oe;return t[70]!==Q?(ee=i.jsx(ye,{"data-testid":"replace-all-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:ne,disabled:Q,children:"Replace All"}),t[70]=Q,t[71]=ee):ee=t[71],t[72]!==U||t[73]!==ee?(te=i.jsxs("div",{className:"flex items-center gap-[2px]",children:[U,ee]}),t[72]=U,t[73]=ee,t[74]=te):te=t[74],t[75]!==J||t[76]!==te?(se=i.jsxs("div",{className:"flex flex-col gap-2",children:[J,te]}),t[75]=J,t[76]=te,t[77]=se):se=t[77],t[78]!==D||t[79]!==se?(ae=i.jsxs("div",{className:"flex items-center gap-3",children:[D,se]}),t[78]=D,t[79]=se,t[80]=ae):ae=t[80],t[81]===Symbol.for("react.memo_cache_sentinel")?(oe=i.jsx(pe,{content:"Find Previous",children:i.jsx(ye,{"data-testid":"find-prev-button",size:"xs",variant:"secondary",onClick:K0,children:i.jsx(Fc,{className:"w-4 h-4"})})}),t[81]=oe):oe=t[81],t[82]===Symbol.for("react.memo_cache_sentinel")?(Ee=i.jsx(pe,{content:"Find Next",children:i.jsx(ye,{"data-testid":"find-next-button",size:"xs",variant:"secondary",onClick:Y0,children:i.jsx(Uc,{className:"w-4 h-4"})})}),t[82]=Ee):Ee=t[82],t[83]!==y||t[84]!==s?(ve=s!=null&&y==null&&i.jsxs("span",{className:"text-sm",children:[s.count," matches"]}),t[83]=y,t[84]=s,t[85]=ve):ve=t[85],t[86]!==y||t[87]!==s?(ge=s!=null&&y!=null&&i.jsxs("span",{className:"text-sm",children:[y+1," of ",s.count]}),t[86]=y,t[87]=s,t[88]=ge):ge=t[88],t[89]!==ve||t[90]!==ge?(ke=i.jsxs("div",{className:"flex items-center gap-2",children:[oe,Ee,ve,ge]}),t[89]=ve,t[90]=ge,t[91]=ke):ke=t[91],t[92]!==c?(fe=c.getHotkey("cell.findAndReplace"),t[92]=c,t[93]=fe):fe=t[93],t[94]!==fe.key?(Ie=i.jsxs("div",{className:"text-xs text-muted-foreground flex gap-1 mt-2",children:["Press"," ",i.jsx(zk,{shortcut:fe.key})," ","again to open the native browser search."]}),t[94]=fe.key,t[95]=Ie):Ie=t[95],t[96]!==E||t[97]!==ae||t[98]!==ke||t[99]!==Ie||t[100]!==C?(Oe=i.jsx(Hl,{restoreFocus:!0,autoFocus:!0,children:i.jsxs("div",{onFocus:w,onClick:H0,onBlur:j,className:"fixed top-0 right-0 w-[500px] flex flex-col bg-(--sage-1) p-4 z-50 mt-2 mr-3 rounded-md shadow-lg border gap-2 print:hidden",onKeyDown:C,children:[E,ae,ke,Ie]})}),t[96]=E,t[97]=ae,t[98]=ke,t[99]=Ie,t[100]=C,t[101]=Oe):Oe=t[101],Oe};function H0(t){t.stopPropagation(),t.preventDefault()}function J0(t){t.key==="Enter"&&(t.shiftKey?ou():Qa())}function K0(){return ou()}function Y0(){return Qa()}const su=t=>{const e=z.c(41),{resetOnBlur:n,placeholderText:o,initialValue:r,flexibleWidth:s,onNameChange:a,className:l}=t,c=n!==void 0&&n,d=r===void 0?null:r,u=s!==void 0&&s,{sendListFiles:h}=qe(),[m,p]=S.useState(d);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=[],e[0]=b):b=e[0];const[x,f]=S.useState(b),[g,y]=S.useState(!1),w=S.useRef(null),j=S.useRef(!1);let C,N,k;e[1]!==d?(C=()=>{p(d)},N=[d],e[1]=d,e[2]=C,e[3]=N):(C=e[2],N=e[3]),S.useEffect(C,N),e[4]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{y(!0)},e[4]=k):k=e[4];const E=k;let _;e[5]!==d||e[6]!==c?(_=Q=>{var ee;(ee=Q.relatedTarget)!=null&&ee.closest(".filename-input")||(y(!1),c&&p(d))},e[5]=d,e[6]=c,e[7]=_):_=e[7];const I=_;let A;e[8]!==m?(A=Ot.dirname(m||""),e[8]=m,e[9]=A):A=e[9];const O=A,D=Ot.basename(m||""),M=x.filter(Q=>Ot.basename(Q.path).startsWith(D));let R,L;e[10]!==O||e[11]!==g||e[12]!==h?(R=async()=>{if(!g)return void f([]);const Q=await h({path:O});f(Q.files)},e[10]=O,e[11]=g,e[12]=h,e[13]=R):R=e[13],e[14]!==O||e[15]!==g?(L=[O,g],e[14]=O,e[15]=g,e[16]=L):L=e[16];const{isPending:P}=vr(R,L),T=(function(Q,ee,te){if(Q&&!Q.endsWith("/")&&((Ys("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(Ot.extension(Q))||(Q=Q.endsWith(".")?`${Q}py`:Q.endsWith(".p")?`${Q}y`:`${Q}.py`),!ee.some(se=>se.path===Q||Ot.basename(se.path)===Q)&&!(te&&(te===Q||Ot.basename(te)===Q))))return Q})(m,x,d),F=(T||M.length>0)&&i.jsxs(Op,{className:"font-mono",children:[!P&&i.jsx(Rp,{children:"No files"}),T&&i.jsxs(Jl,{variant:"success",className:"py-2 px-3",onSelect:()=>{var Q;T&&(j.current=!0,a(T),(Q=w.current)==null||Q.blur())},children:[i.jsx(Jc,{className:"w-4 h-4 mr-2"})," ",i.jsxs("span",{className:"text-sm",children:[d?"Rename to: ":"Save as: ",i.jsx("span",{className:"font-medium text-sm",children:Ot.basename(T)})]})]},"_rename_"),M.map(Q=>{const ee=Q.isDirectory?"directory":Wk(Q.path),te=$k[ee];return i.jsxs(Jl,{variant:Q.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{Q.isDirectory?p(`${Q.path}/`):p(Q.path)},children:[i.jsx(te,{className:"w-4 h-4 mr-2"})," ",Ot.basename(Q.path)]},Q.path)})]}),$=10*Math.max(20,(m==null?void 0:m.length)||(o==null?void 0:o.length)||0),W=g?m||"":d||"";let H,X,q;e[17]!==u||e[18]!==$?(H=u?{maxWidth:$}:void 0,e[17]=u,e[18]=$,e[19]=H):H=e[19],e[20]!==l?(X=de(l,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60"),e[20]=l,e[21]=X):X=e[21],e[22]!==o||e[23]!==W||e[24]!==H||e[25]!==X?(q=i.jsx(Vk,{children:i.jsx(Lp,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:W,onKeyDown:X0,icon:null,ref:w,onValueChange:p,placeholder:o,autoComplete:"off",style:H,className:X})}),e[22]=o,e[23]=W,e[24]=H,e[25]=X,e[26]=q):q=e[26];const Y=F&&"group-focus-within:block";let J,V,G,U,ne;return e[27]!==Y?(J=de("p-0 w-full min-w-80 max-w-80vw hidden",Y),e[27]=Y,e[28]=J):J=e[28],e[29]!==F||e[30]!==J?(V=i.jsx(Kl,{side:"bottom",className:J,portal:!1,children:F}),e[29]=F,e[30]=J,e[31]=V):V=e[31],e[32]!==q||e[33]!==V?(G=i.jsxs(Op,{children:[q,V]}),e[32]=q,e[33]=V,e[34]=G):G=e[34],e[35]!==I||e[36]!==G?(U=i.jsx(Fp,{onFocus:E,onBlur:I,shouldFilter:!1,id:"filename-input",className:"bg-transparent group filename-input",children:G}),e[35]=I,e[36]=G,e[37]=U):U=e[37],e[38]!==g||e[39]!==U?(ne=i.jsx(Yl,{children:i.jsx(ta,{open:g,modal:!1,children:U})}),e[38]=g,e[39]=U,e[40]=ne):ne=e[40],ne};function X0(t){t.key==="Escape"&&t.currentTarget.blur()}const Q0=t=>{const e=z.c(33),n=()=>{Ul(new Blob([o()],{type:"text/plain"}),`${t.proposedName}.json`)},o=Ce(tb);let r,s,a,l,c,d,u,h,m,p,b,x,f,g,y,w,j;return e[0]!==n||e[1]!==t?(r=C=>{C.preventDefault(),n(),t.closeModal()},e[0]=n,e[1]=t,e[2]=r):r=e[2],e[3]!==t?(s=C=>{C.key==="Escape"&&t.closeModal()},e[3]=t,e[4]=s):s=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(so,{className:"text-accent-foreground mb-6",children:"Download unsaved changes?"}),e[5]=a):a=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(l={wordBreak:"break-word"},e[6]=l):l=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("p",{children:"This app has unsaved changes. To recover:"}),d={paddingBottom:"10px"},e[7]=c,e[8]=d):(c=e[7],d=e[8]),e[9]!==t.proposedName?(u=i.jsxs("li",{style:d,children:['Click the "Download" button. This will download a file called\xA0',i.jsxs("code",{children:[t.proposedName,".json"]}),". This file contains your code."]}),e[9]=t.proposedName,e[10]=u):u=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(h={paddingBottom:"10px"},e[11]=h):h=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(m={display:"block",padding:"10px"},e[12]=m):m=e[12],e[13]!==t.proposedName?(p=i.jsxs("code",{style:m,children:["marimo recover ",t.proposedName,".json ",">"," ",t.proposedName,".py"]}),e[13]=t.proposedName,e[14]=p):p=e[14],e[15]!==t.proposedName?(b=i.jsxs("code",{children:[t.proposedName,".py"]}),e[15]=t.proposedName,e[16]=b):b=e[16],e[17]!==b||e[18]!==p?(x=i.jsxs("li",{style:h,children:["In your terminal, type",p,"to overwrite ",b," with the recovered changes."]}),e[17]=b,e[18]=p,e[19]=x):x=e[19],e[20]!==x||e[21]!==u?(f=i.jsx(yr,{className:"markdown break-words",style:l,children:i.jsxs("div",{className:"prose dark:prose-invert",children:[c,i.jsxs("ol",{children:[u,x]})]})}),e[20]=x,e[21]=u,e[22]=f):f=e[22],e[23]!==t.closeModal?(g=i.jsx(ye,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:t.closeModal,children:"Cancel"}),e[23]=t.closeModal,e[24]=g):g=e[24],e[25]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(ye,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"}),e[25]=y):y=e[25],e[26]!==g?(w=i.jsxs(Hs,{children:[g,y]}),e[26]=g,e[27]=w):w=e[27],e[28]!==r||e[29]!==s||e[30]!==f||e[31]!==w?(j=i.jsx(io,{className:"w-fit",children:i.jsxs("form",{onSubmit:r,onKeyDown:s,children:[a,f,w]})}),e[28]=r,e[29]=s,e[30]=f,e[31]=w,e[32]=j):j=e[32],j},Z0=t=>{const e=z.c(12),{filename:n,needsSave:o}=t,{openModal:r,closeModal:s}=zn();let a;e[0]!==n?(a=n===null?"app":Ot.basename(n).split(".")[0],e[0]=n,e[1]=a):a=e[1];const l=a;let c;e[2]!==s||e[3]!==o||e[4]!==r||e[5]!==l?(c=()=>{o&&r(i.jsx(Q0,{proposedName:l,closeModal:s}))},e[2]=s,e[3]=o,e[4]=r,e[5]=l,e[6]=c):c=e[6];const d=c;let u;st("global.save",d),e[7]===Symbol.for("react.memo_cache_sentinel")?(u=St("global.save"),e[7]=u):u=e[7];const h=o?"yellow":"gray";let m,p;return e[8]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Aa,{strokeWidth:1.5,size:18}),e[8]=m):m=e[8],e[9]!==d||e[10]!==h?(p=i.jsx(pe,{content:u,children:i.jsx(tn,{onClick:d,id:"save-button","aria-label":"Save",className:"rectangle",color:h,children:m})}),e[9]=d,e[10]=h,e[11]=p):p=e[11],p};function eb(t){return{id:t.id,name:t.name,code:t.code,code_hash:null,config:{column:0,...t.config}}}function tb(){const t=Mt(),e=Xl(t),n={version:"1",metadata:{marimo_version:Dp()},cells:e.map(eb)};return JSON.stringify(n,null,2)}const ei=5e3,ti=Qt(void 0),au=Qt(t=>{const e=t(ti);return(function({state:n,layout:o,lastSavedNotebook:r}){if(!r)return!1;const{cellIds:s,cellData:a}=n,l=s.inOrderIds.map(h=>a[h]),c=l.map(h=>h.code),d=l.map(h=>h.config),u=l.map(h=>h.name);return!(Bp(c,r.codes)&&Bp(u,r.names)&&kr(d,r.configs)&&kr(o.selectedLayout,r.layout.selectedLayout)&&kr(o.layoutData,r.layout.layoutData))})({state:t(Vt),layout:t(eg),lastSavedNotebook:e})});function nb(t){return JSON.stringify(t)}const ob=t=>{const e=z.c(15),{kioskMode:n}=t,o=zl(),r=ie(au),s=ie(Nt).state===mt.CLOSED,{saveOrNameNotebook:a,saveIfNotebookIsPersistent:l}=ni();let c,d,u;e[0]!==n||e[1]!==l?(c={onSave:l,kioskMode:n},e[0]=n,e[1]=l,e[2]=c):c=e[2],(function(f){const g=z.c(14),y=ie(Up),w=Gp(),[j]=_n(Nt),C=ie(au);let N,k;if(g[0]!==w){const O=Xl(w);N=O.map(lb),k=O.map(ib),g[0]=w,g[1]=N,g[2]=k}else N=g[1],k=g[2];const E=k;let _;g[3]!==w?(_=zp(w),g[3]=w,g[4]=_):_=g[4];const I=_;let A;g[5]!==y||g[6]!==E||g[7]!==N||g[8]!==I||g[9]!==j||g[10]!==C||g[11]!==f.kioskMode||g[12]!==f.onSave?(A={onSave:f.onSave,needsSave:C,codes:N,cellConfigs:I,cellNames:E,connStatus:j,config:y,kioskMode:f.kioskMode},g[5]=y,g[6]=E,g[7]=N,g[8]=I,g[9]=j,g[10]=C,g[11]=f.kioskMode,g[12]=f.onSave,g[13]=A):A=g[13],(function(O){const D=z.c(21),{codes:M,cellConfigs:R,config:L,connStatus:P,cellNames:T,needsSave:F,kioskMode:$,onSave:W}=O,H=S.useRef(null);let X;D[0]!==M?(X=M.join(":"),D[0]=M,D[1]=X):X=D[1];const q=X;let Y;D[2]!==R?(Y=R.map(nb).join(":"),D[2]=R,D[3]=Y):Y=D[3];const J=Y;let V;D[4]!==T?(V=T.join(":"),D[4]=T,D[5]=V):V=D[5];const G=V;let U,ne;D[6]!==L||D[7]!==P.state||D[8]!==$||D[9]!==F||D[10]!==W?(U=()=>{if(!$)return L.autosave==="after_delay"&&(H.current!==null&&clearTimeout(H.current),F&&P.state===mt.OPEN&&(H.current=setTimeout(W,L.autosave_delay))),()=>{H.current!==null&&clearTimeout(H.current)}},D[6]=L,D[7]=P.state,D[8]=$,D[9]=F,D[10]=W,D[11]=U):U=D[11],D[12]!==J||D[13]!==G||D[14]!==q||D[15]!==L||D[16]!==P.state||D[17]!==$||D[18]!==F||D[19]!==W?(ne=[q,J,G,L,P.state,W,$,F],D[12]=J,D[13]=G,D[14]=q,D[15]=L,D[16]=P.state,D[17]=$,D[18]=F,D[19]=W,D[20]=ne):ne=D[20],S.useEffect(U,ne)})(A)})(c),(function(){const f=z.c(12),g=ie(Gk),{state:y}=ie(Nt),w=g.auto_download.includes("markdown"),j=g.auto_download.includes("html"),C=g.auto_download.includes("ipynb"),N=!w||y!==mt.OPEN,k=!j||y!==mt.OPEN,E=!C||y!==mt.OPEN,{autoExportAsHTML:_,autoExportAsIPYNB:I,autoExportAsMarkdown:A}=qe();let O,D,M,R,L,P;f[0]!==A?(O=async()=>{await A({download:!1})},f[0]=A,f[1]=O):O=f[1],f[2]!==N?(D={delayMs:ei,whenVisible:!0,disabled:N},f[2]=N,f[3]=D):D=f[3],zr(O,D),f[4]!==_?(M=async()=>{await _({download:!1,includeCode:!0,files:J1.INSTANCE.filenames()})},f[4]=_,f[5]=M):M=f[5],f[6]!==k?(R={delayMs:ei,whenVisible:!0,disabled:k},f[6]=k,f[7]=R):R=f[7],zr(M,R),f[8]!==I?(L=async()=>{await I({download:!1})},f[8]=I,f[9]=L):L=f[9],f[10]!==E?(P={delayMs:ei,whenVisible:!0,disabled:E},f[10]=E,f[11]=P):P=f[11],zr(L,P)})(),e[3]!==r?(d=f=>{if(r)return f.preventDefault(),f.returnValue="You have unsaved changes. Are you sure you want to leave?",f.returnValue},e[3]=r,e[4]=d):d=e[4],Vp(window,"beforeunload",d),e[5]!==a?(u=f=>{f.preventDefault(),f.stopPropagation(),a()},e[5]=a,e[6]=u):u=e[6];const h=u;if(st("global.save",a),s){let f;return e[7]!==o||e[8]!==r?(f=i.jsx(Z0,{filename:o,needsSave:r}),e[7]=o,e[8]=r,e[9]=f):f=e[9],f}let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=St("global.save"),e[10]=m):m=e[10];const p=r?"yellow":"hint-green";let b,x;return e[11]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(Aa,{strokeWidth:1.5,size:18}),e[11]=b):b=e[11],e[12]!==h||e[13]!==p?(x=i.jsx(pe,{content:m,children:i.jsx(tn,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:p,onClick:h,children:b})}),e[12]=h,e[13]=p,e[14]=x):x=e[14],x};function ni(){const t=z.c(20),{sendSave:e}=qe(),{openModal:n,closeModal:o,openAlert:r}=zn(),s=Ct(ti),a=Pp(),l=na();let c;t[0]!==r||t[1]!==e||t[2]!==s||t[3]!==l?(c=(g,y)=>{const w=Mt(),j=Xl(w),C=j.map(ab),N=j.map(sb),k=j.map(rb),E=zp(w),_=l.get(Nt),I=l.get(Up),A=l.get(eg);l.get(To)||N.length!==0&&(_.state===mt.OPEN?(Ye.log("saving to ",g),e({cellIds:C,codes:N,names:k,filename:g,configs:E,layout:bC(),persist:!0}).then(()=>{y&&I.format_on_save&&Wp(),s({names:k,codes:N,configs:E,layout:A})})):r("Failed to save notebook: not connected to a kernel."))},t[0]=r,t[1]=e,t[2]=s,t[3]=l,t[4]=c):c=t[4];const d=Ce(c);let u;t[5]!==d||t[6]!==l?(u=g=>{const y=g!==void 0&&g,w=l.get($p),j=l.get(Nt);iu(w)&&j.state===mt.OPEN&&d(w,y)},t[5]=d,t[6]=l,t[7]=u):u=t[7];const h=Ce(u);let m;t[8]!==d||t[9]!==a?(m=g=>{a(g).then(y=>{y!==null&&d(y,!0)})},t[8]=d,t[9]=a,t[10]=m):m=t[10];const p=m;let b;t[11]!==o||t[12]!==p||t[13]!==n||t[14]!==h||t[15]!==l?(b=()=>{const g=l.get($p),y=l.get(Nt);h(!0),iu(g)||y.state===mt.CLOSED||n(i.jsx(cb,{onClose:o,onSave:p}))},t[11]=o,t[12]=p,t[13]=n,t[14]=h,t[15]=l,t[16]=b):b=t[16];const x=Ce(b);let f;return t[17]!==h||t[18]!==x?(f={saveOrNameNotebook:x,saveIfNotebookIsPersistent:h},t[17]=h,t[18]=x,t[19]=f):f=t[19],f}function rb(t){return t.name}function sb(t){return t.code}function ab(t){return t.id}function iu(t){return t!==null&&!t.startsWith("/tmp")&&!t.startsWith("/var/folders")&&!t.includes("AppData\\Local\\Temp")}function ib(t){return t.name}function lb(t){return t.code}const cb=t=>{const e=z.c(17),{onClose:n,onSave:o}=t,[r,s]=S.useState();let a;e[0]!==n||e[1]!==o?(a=f=>{s(f),f.trim()&&(o(f),n())},e[0]=n,e[1]=o,e[2]=a):a=e[2];const l=a;let c,d,u,h;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(so,{children:"Save notebook"}),e[3]=c):c=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Ao,{className:"text-md pt-6 px-1",children:"Save as"}),e[4]=d):d=e[4],e[5]!==l?(u=i.jsxs("div",{className:"flex flex-col",children:[d,i.jsx(su,{onNameChange:l,placeholderText:"filename",className:"missing-filename"})]}),e[5]=l,e[6]=u):u=e[6],e[7]!==n?(h=i.jsx(ye,{"data-testid":"cancel-save-dialog-button","aria-label":"Cancel",variant:"secondary",onClick:n,children:"Cancel"}),e[7]=n,e[8]=h):h=e[8];const m=!r;let p,b,x;return e[9]!==m?(p=i.jsx(ye,{"data-testid":"submit-save-dialog-button","aria-label":"Save",variant:"default",disabled:m,type:"submit",children:"Save"}),e[9]=m,e[10]=p):p=e[10],e[11]!==h||e[12]!==p?(b=i.jsxs(Hs,{children:[h,p]}),e[11]=h,e[12]=p,e[13]=b):b=e[13],e[14]!==u||e[15]!==b?(x=i.jsxs(io,{children:[c,u,b]}),e[14]=u,e[15]=b,e[16]=x):x=e[16],x};function lu(t){const e=z.c(3),[n,o]=S.useState(!1);let r,s;return e[0]!==t?(r=()=>{if(!t)return;o(!1);const a=setTimeout(()=>{o(!0)},200);return()=>clearTimeout(a)},s=[t],e[0]=t,e[1]=r,e[2]=s):(r=e[1],s=e[2]),S.useEffect(r,s),t&&n}let cu,du;Ea=t=>{const{children:e}=t;return ie(To)?null:e},cu=t=>{const{children:e}=t;return ie(To)?e:null},du=()=>{const t=z.c(6),e=Ct(_a);let n;t[0]!==e?(n=()=>e(db),t[0]=e,t[1]=n):n=t[1];const o=n;let r,s,a;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=St("global.commandPalette"),t[2]=r):r=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(Oa,{strokeWidth:1.5,size:18}),t[3]=s):s=t[3],t[4]!==o?(a=i.jsx(pe,{content:r,children:i.jsx(tn,{"data-testid":"command-palette-button",onClick:o,shape:"rectangle",color:"hint-green",children:s})}),t[4]=o,t[5]=a):a=t[5],a};function db(t){return!t}const ub=t=>{const e=z.c(47),{presenting:n,onTogglePresenting:o,onInterrupt:r,onRun:s,connectionState:a,running:l,appConfig:c}=t,d=c.width,u=ie(_p),h=ie(qk),{undoDeleteCell:m}=Ke(),p=a===mt.CLOSED;let b,x=null;if(!p&&u){let F,$;e[0]===Symbol.for("react.memo_cache_sentinel")?(F=i.jsx(Pa,{size:16,strokeWidth:1.5}),e[0]=F):F=e[0],e[1]!==m?($=i.jsx(pe,{content:"Undo cell deletion",children:i.jsx(tn,{"data-testid":"undo-delete-cell",size:"medium",color:"hint-green",shape:"circle",onClick:m,children:F})}),e[1]=m,e[2]=$):$=e[2],x=$}e[3]!==a?(b=en(a),e[3]=a,e[4]=b):b=e[4];const f=b;let g;e[5]!==a||e[6]!==f?(g=f?oa(a):void 0,e[5]=a,e[6]=f,e[7]=g):g=e[7];const y=g;let w,j;e[8]!==n?(w=!n&&i.jsx(q0,{}),e[8]=n,e[9]=w):w=e[9],e[10]!==p||e[11]!==y||e[12]!==f||e[13]!==n?(j=!p&&i.jsxs("div",{className:fb,children:[n&&i.jsx(m0,{}),i.jsx(L0,{disabled:f,tooltip:y}),i.jsx(sC,{disabled:f,tooltip:y}),i.jsx(aC,{description:"This will terminate the Python kernel. You'll lose all data that's in memory.",disabled:f,tooltip:y})]}),e[10]=p,e[11]=y,e[12]=f,e[13]=n,e[14]=j):j=e[14];const C=d==="compact"&&"xl:flex-row items-end";let N,k,E,_,I,A,O,D,M,R,L,P,T;return e[15]!==C?(N=de(pb,C),e[15]=C,e[16]=N):N=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx(Ea,{children:i.jsx(ob,{kioskMode:!1})}),e[17]=k):k=e[17],e[18]===Symbol.for("react.memo_cache_sentinel")?(E=St("global.hideCode"),e[18]=E):E=e[18],e[19]!==n?(_=n?i.jsx(Ap,{strokeWidth:1.5,size:18}):i.jsx(Ra,{strokeWidth:1.5,size:18}),e[19]=n,e[20]=_):_=e[20],e[21]!==o||e[22]!==_?(I=i.jsx(pe,{content:E,children:i.jsx(tn,{"data-testid":"hide-code-button",id:"preview-button",shape:"rectangle",color:"hint-green",onClick:o,children:_})}),e[21]=o,e[22]=_,e[23]=I):I=e[23],e[24]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsx(du,{}),O=i.jsx(iC,{}),D=i.jsx("div",{}),e[24]=A,e[25]=O,e[26]=D):(A=e[24],O=e[25],D=e[26]),e[27]!==p||e[28]!==r||e[29]!==l?(M=!p&&i.jsx(mb,{running:l,onInterrupt:r}),e[27]=p,e[28]=r,e[29]=l,e[30]=M):M=e[30],e[31]!==p||e[32]!==h||e[33]!==s?(R=!p&&i.jsx(hb,{needsRun:h,onRun:s}),e[31]=p,e[32]=h,e[33]=s,e[34]=R):R=e[34],e[35]!==M||e[36]!==R||e[37]!==x?(L=i.jsx(Ea,{children:i.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[x,M,R]})}),e[35]=M,e[36]=R,e[37]=x,e[38]=L):L=e[38],e[39]!==I||e[40]!==L||e[41]!==N?(P=i.jsxs("div",{className:N,children:[k,I,A,O,D,L]}),e[39]=I,e[40]=L,e[41]=N,e[42]=P):P=e[42],e[43]!==P||e[44]!==w||e[45]!==j?(T=i.jsxs(i.Fragment,{children:[w,j,P]}),e[43]=P,e[44]=w,e[45]=j,e[46]=T):T=e[46],T},hb=t=>{const e=z.c(8),{needsRun:n,onRun:o}=t,r=ie(qp);if(n){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=St("global.runStale"),e[0]=c):c=e[0];const d=r?o:void 0,u=!r;let h,m;return e[1]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Uo,{strokeWidth:1.5,size:16}),e[1]=h):h=e[1],e[2]!==d||e[3]!==u?(m=i.jsx(pe,{content:c,children:i.jsx(tn,{"data-testid":"run-button",size:"medium",color:"yellow",shape:"circle",onClick:d,disabled:u,children:h})}),e[2]=d,e[3]=u,e[4]=m):m=e[4],m}const s=!r;let a,l;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(Uo,{strokeWidth:1.5,size:16}),e[5]=a):a=e[5],e[6]!==s?(l=i.jsx(pe,{content:"Nothing to run",children:i.jsx(tn,{"data-testid":"run-button",className:"inactive-button",color:"disabled",size:"medium",shape:"circle",disabled:s,children:a})}),e[6]=s,e[7]=l):l=e[7],l},mb=t=>{const e=z.c(8),{running:n,onInterrupt:o}=t,r=lu(n);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=St("global.interrupt"),e[0]=s):s=e[0];const a=!r&&"inactive-button active:shadow-xs-solid";let l;e[1]!==a?(l=de(a),e[1]=a,e[2]=l):l=e[2];const c=r?"yellow":"disabled",d=r?o:Pn.NOOP;let u,h;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Bl,{strokeWidth:1.5,size:16}),e[3]=u):u=e[3],e[4]!==l||e[5]!==c||e[6]!==d?(h=i.jsx(pe,{content:s,children:i.jsx(tn,{className:l,"data-testid":"interrupt-button",size:"medium",color:c,shape:"circle",onClick:d,children:u})}),e[4]=l,e[5]=c,e[6]=d,e[7]=h):h=e[7],h},fb="absolute top-3 right-5 m-0 flex items-center gap-2 min-h-[28px] no-print pointer-events-auto z-30 print:hidden",pb="absolute bottom-5 right-5 flex flex-col gap-2 items-center no-print pointer-events-auto z-30 print:hidden",gb=t=>{const e=z.c(7),{filename:n}=t,o=Pp();let r;e[0]!==n?(r=n?Ot.basename(n):"untitled marimo notebook",e[0]=n,e[1]=r):r=e[1];const s=n===null?"missing-filename":"filename";let a;return e[2]!==n||e[3]!==o||e[4]!==r||e[5]!==s?(a=i.jsx(su,{placeholderText:r,initialValue:n,onNameChange:o,flexibleWidth:!0,resetOnBlur:!0,"data-testid":"filename-input",className:s}),e[2]=n,e[3]=o,e[4]=r,e[5]=s,e[6]=a):a=e[6],a},oi=()=>({entries:new Map}),{valueAtom:uu,useActions:hu}=Ql(oi,{submit:(t,e)=>{const{cellIds:n,deleteCell:o,deleteManyCells:r,store:s}=e,a=s.get(Vt),l=s.get(Hp),c=new Set(a.cellIds.inOrderIds.filter(h=>a.cellData[h].code.trim()==="")),d=new Map;for(const h of n){if(c.has(h)){d.set(h,{cellId:h,type:"simple"});continue}const m=a.cellRuntime[h],p=new Map;for(const x of Object.values(l)){const f=x.declaredBy.includes(h),g=x.usedBy.some(y=>!c.has(y));f&&g&&p.set(x.name,x.usedBy)}let b;m!=null&&m.runElapsedTimeMs&&m.runElapsedTimeMs>2e3&&(b=m.runElapsedTimeMs),p.size===0&&b===void 0?d.set(h,{cellId:h,type:"simple"}):d.set(h,{cellId:h,type:"expensive",executionDurationMs:b,defs:p})}const u=[...d.values()].every(h=>h.type==="simple");return d.size>0&&u?(d.size===1?o({cellId:[...d.values()][0].cellId}):r({cellIds:[...d.values()].map(h=>h.cellId)}),oi()):{...t,entries:d}},clear:()=>oi()});function Ko(){const t=na(),{submit:e,clear:n}=hu(),{entries:o}=ie(uu),r=jr(),s=Cr();return S.useMemo(()=>({submit:a=>{e({cellIds:a,deleteCell:r,deleteManyCells:s,store:t})},clear:n,get idle(){return o.size===0},get shouldConfirmDelete(){return o.size>1}}),[t,e,n,o,r,s])}function bb(t){return t.cellId}function mu(){return{selectionStart:null,selectionEnd:null,selected:new Set}}const{valueAtom:ri,useActions:xb}=Ql(mu,{select:(t,e)=>({selectionStart:e.cellId,selectionEnd:e.cellId,selected:new Set([e.cellId])}),extend:(t,e)=>{if(!t.selectionStart)return{selectionStart:e.cellId,selectionEnd:e.cellId,selected:new Set([e.cellId])};const{cellId:n,allCellIds:o}=e;try{const r=o.findWithId(t.selectionStart),s=r.indexOfOrThrow(t.selectionStart),a=r.indexOfOrThrow(n),[l,c]=s<a?[s,a]:[a,s],d=r.slice(l,c+1);return{selectionStart:t.selectionStart,selectionEnd:n,selected:new Set(d)}}catch{return{selectionStart:n,selectionEnd:n,selected:new Set([n])}}},clear:t=>t.selected.size===0?t:mu()});function ns(){return xb()}const yb=t=>{const e=z.c(14),{actions:n,cellIds:o,disabled:r}=t;let s,a,l,c,d;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(Ca,{size:13,strokeWidth:1.5}),e[0]=s):s=e[0],e[1]!==r?(a=i.jsx(Wn,{asChild:!0,children:i.jsx(ye,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",title:"More actions",disabled:r,children:s})}),e[1]=r,e[2]=a):a=e[2],e[3]!==n||e[4]!==o){let u;e[6]!==n.length||e[7]!==o?(u=(h,m)=>{const p=h.map(b=>i.jsx(lo,{onSelect:()=>b.handle(o),className:"flex items-center gap-2",children:i.jsxs("div",{className:"flex items-center flex-1",children:[b.icon&&i.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:b.icon}),i.jsx("div",{className:"flex-1",children:b.label}),b.hotkey&&i.jsx(Vl,{shortcut:b.hotkey,className:"ml-4"})]})},b.label));return i.jsxs(he.Fragment,{children:[p,m<n.length-1&&i.jsx(En,{})]},m)},e[6]=n.length,e[7]=o,e[8]=u):u=e[8],l=n.flatMap(u),e[3]=n,e[4]=o,e[5]=l}else l=e[5];return e[9]!==l?(c=i.jsx($n,{align:"start","data-keep-cell-selection":!0,children:l}),e[9]=l,e[10]=c):c=e[10],e[11]!==a||e[12]!==c?(d=i.jsxs(Un,{children:[a,c]}),e[11]=a,e[12]=c,e[13]=d):d=e[13],d};function vb(t){return t.length>0}function wb(t){return t.filter(kb)}function kb(t){return!t.hidden}function jb(t){return t.length>0}function Cb(t){return t.filter(Nb)}function Nb(t){return!t.hidden}function Sb(t){const e={};t.forEach(n=>{const o=Kp(n);o&&(e[n]=o)}),Yp(e)}const Eb=()=>{const t=z.c(4),e=ie(ri);let n;t[0]!==e.selected?(n=[...e.selected],t[0]=e.selected,t[1]=n):n=t[1];const o=n;if(o.length<2)return null;let r;return t[2]!==o?(r=i.jsxs(i.Fragment,{children:[i.jsx(Ib,{cellIds:o}),i.jsx(_b,{cellIds:o})]}),t[2]=o,t[3]=r):r=t[3],r},si=()=>{const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"h-4 w-px bg-border mx-1"}),t[0]=e):e=t[0],e},_b=t=>{const e=z.c(12),{cellIds:n}=t,o=Ko(),r=Cr(),s=ns();if(!o.shouldConfirmDelete)return null;let a,l,c,d,u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(Zl,{className:"w-4 h-4 text-(--amber-11) mt-0.5 shrink-0"}),e[0]=a):a=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("div",{className:"font-code text-sm text-[0.84375rem]",children:[i.jsx("p",{className:"text-(--amber-11) font-medium",children:"Some cells in selection may contain expensive operations."}),i.jsx("p",{className:"text-(--amber-11) mt-1",children:"Are you sure you want to delete?"})]}),e[1]=l):l=e[1],e[2]!==o?(c=i.jsx(ye,{size:"xs",variant:"ghost",onClick:()=>o.clear(),className:"text-(--amber-11) hover:bg-(--amber-4) hover:text-(--amber-11)",children:"Cancel"}),e[2]=o,e[3]=c):c=e[3],e[4]!==n||e[5]!==r||e[6]!==o||e[7]!==s?(d=i.jsx(ye,{size:"xs",variant:"secondary",onClick:()=>{r({cellIds:n}),o.clear(),s.clear()},className:"bg-(--amber-11) hover:bg-(--amber-12) text-white border-(--amber-11)",children:"Delete"}),e[4]=n,e[5]=r,e[6]=o,e[7]=s,e[8]=d):d=e[8],e[9]!==c||e[10]!==d?(u=i.jsx("div",{className:"absolute top-12 justify-center flex w-full left-0 right-0 z-50","data-keep-cell-selection":!0,children:i.jsx("div",{className:"mx-20",children:i.jsx("div",{className:"bg-(--amber-2) border border-(--amber-6) rounded-lg shadow-lg mt-14 px-4 py-3 animate-in slide-in-from-top-2 duration-200",children:i.jsxs("div",{className:"flex items-start gap-3",children:[a,i.jsxs("div",{className:"flex-1",children:[l,i.jsx(Hl,{restoreFocus:!0,autoFocus:!0,children:i.jsxs("div",{className:"flex items-center gap-2 mt-3",onKeyDown:Ab,children:[c,d]})})]})]})})})}),e[9]=c,e[10]=d,e[11]=u):u=e[11],u},Ib=t=>{const e=z.c(23),{cellIds:n}=t,o=ns(),r=Ko(),{actions:s,moreActions:a}=(function(f){const g=z.c(31),{updateCellConfig:y,moveCell:w,clearCellOutput:j,sendToTop:C,sendToBottom:N}=Ke(),k=Cr(),E=ie(Jp),_=ns(),I=Ho(),A=Ko(),O=ie(ra),{saveCellConfig:D}=qe(),M=f.length,R=!E||M<f.length;let L;g[0]!==k||g[1]!==A||g[2]!==_||g[3]!==O?(L=ee=>{A.idle&&O.keymap.destructive_delete?A.submit(ee):(k({cellIds:ee}),A.clear(),_.clear())},g[0]=k,g[1]=A,g[2]=_,g[3]=O,g[4]=L):L=g[4];const P=Ce(L);let T;g[5]!==w?(T=(ee,te)=>{if(te==="down"){const se=ee[ee.length-1];if(Le.get(Vt).cellIds.findWithId(se).last()===se)return}if(te==="up"){const se=ee[0];if(Le.get(Vt).cellIds.findWithId(se).first()===se)return}(te==="up"?ee:[...ee].reverse()).forEach(se=>{w({cellId:se,before:te==="up"})})},g[5]=w,g[6]=T):T=g[6];const F=Ce(T);let $;g[7]!==C?($=ee=>{[...ee].reverse().forEach(te=>{C({cellId:te})})},g[7]=C,g[8]=$):$=g[8];const W=Ce($);let H;g[9]!==N?(H=ee=>{ee.forEach(te=>{N({cellId:te})})},g[9]=N,g[10]=H):H=g[10];const X=Ce(H),q=Ce(Sb);let Y;g[11]!==j?(Y=ee=>{ee.forEach(te=>{j({cellId:te})})},g[11]=j,g[12]=Y):Y=g[12];const J=Ce(Y);let V;g[13]!==D||g[14]!==y?(V=async(ee,te,se)=>{const ae={};ee.forEach(oe=>{ae[oe]={[te]:se}}),await D({configs:ae}),ee.forEach(oe=>{y({cellId:oe,config:ae[oe]})})},g[13]=D,g[14]=y,g[15]=V):V=g[15];const G=Ce(V);let U,ne,Q;if(g[16]===Symbol.for("react.memo_cache_sentinel")?(U=i.jsx(Uo,{size:13,strokeWidth:1.5}),g[16]=U):U=g[16],g[17]!==I?(ne=ee=>I(ee),g[17]=I,g[18]=ne):ne=g[18],g[19]!==R||g[20]!==J||g[21]!==P||g[22]!==q||g[23]!==F||g[24]!==X||g[25]!==W||g[26]!==ne||g[27]!==G){const ee=[[{icon:U,label:"Run cells",handle:ne,hotkey:"cell.run"}],[{icon:i.jsx(sa,{size:13,strokeWidth:1.5}),label:"Move up",handle:oe=>F(oe,"up"),hotkey:"cell.moveUp"},{icon:i.jsx(Vn,{size:13,strokeWidth:1.5}),label:"Move down",handle:oe=>F(oe,"down"),hotkey:"cell.moveDown"}],[{icon:i.jsx(ec,{size:13,strokeWidth:1.5}),label:"Delete cells",variant:"danger",hidden:!R,handle:P}]],te=[[{icon:i.jsx(Xp,{size:13,strokeWidth:1.5}),label:"Format cells",handle:q,hotkey:"cell.format"},{icon:i.jsx(Ks,{size:13,strokeWidth:1.5}),label:"Clear outputs",handle:J}],[{icon:i.jsx($l,{size:13,strokeWidth:1.5}),label:"Hide code",handle:oe=>G(oe,"hide_code",!0),hotkey:"cell.hideCode"},{icon:i.jsx(Qp,{size:13,strokeWidth:1.5}),label:"Show code",handle:oe=>G(oe,"hide_code",!1),hotkey:"cell.hideCode"}],[{icon:i.jsx(sa,{size:13,strokeWidth:1.5}),label:"Move up",handle:oe=>F(oe,"up"),hotkey:"cell.moveUp"},{icon:i.jsx(Vn,{size:13,strokeWidth:1.5}),label:"Move down",handle:oe=>F(oe,"down"),hotkey:"cell.moveDown"},{icon:i.jsx(Da,{size:13,strokeWidth:1.5}),label:"Send to top",handle:W,hotkey:"cell.sendToTop"},{icon:i.jsx(bt,{size:13,strokeWidth:1.5}),label:"Send to bottom",handle:X,hotkey:"cell.sendToBottom"}],[{icon:i.jsx(Et,{size:13,strokeWidth:1.5}),label:"Disable cells",handle:oe=>G(oe,"disabled",!0)},{icon:i.jsx(_t,{size:13,strokeWidth:1.5}),label:"Enable cells",handle:oe=>G(oe,"disabled",!1)}]],se=ee.map(Cb);let ae;g[29]!==se?(ae=se.filter(jb),g[29]=se,g[30]=ae):ae=g[30],Q={actions:ae,moreActions:te.map(wb).filter(vb)},g[19]=R,g[20]=J,g[21]=P,g[22]=q,g[23]=F,g[24]=X,g[25]=W,g[26]=ne,g[27]=G,g[28]=Q}else Q=g[28];return Q})(n),l=n.length;let c;e[0]!==r||e[1]!==o?(c=f=>{(f.target instanceof HTMLElement||f.target instanceof SVGElement)&&f.target.closest("[data-keep-cell-selection]")!==null||f.target instanceof HTMLHtmlElement||(r.clear(),o.clear())},e[0]=r,e[1]=o,e[2]=c):c=e[2],Vp(window,"mousedown",c);const d=!r.idle;let u,h,m,p,b,x;if(e[3]!==l?(u=i.jsxs("span",{className:"text-sm font-medium text-muted-foreground px-2 shrink-0",children:[l," cells selected"]}),e[3]=l,e[4]=u):u=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(si,{}),e[5]=h):h=e[5],e[6]!==s||e[7]!==n||e[8]!==d){let f;e[10]!==s.length||e[11]!==n||e[12]!==d?(f=(g,y)=>i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[g.map(w=>i.jsxs(ye,{variant:w.variant==="danger"?"linkDestructive":"ghost",size:"sm",onClick:()=>w.handle(n),className:"h-8 px-2 gap-1 shrink-0 flex items-center",title:w.label,disabled:d&&w.label!=="Delete cells",children:[w.icon,i.jsx("span",{className:"text-xs",children:w.label}),w.hotkey&&i.jsx("div",{className:"ml-1 border bg-muted rounded-md px-1",children:i.jsx(Vl,{shortcut:w.hotkey})})]},w.label)),y<s.length-1&&i.jsx(si,{})]},y),e[10]=s.length,e[11]=n,e[12]=d,e[13]=f):f=e[13],m=s.map(f),e[6]=s,e[7]=n,e[8]=d,e[9]=m}else m=e[9];return e[14]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(si,{}),e[14]=p):p=e[14],e[15]!==n||e[16]!==d||e[17]!==a?(b=i.jsx(yb,{actions:a,cellIds:n,disabled:d}),e[15]=n,e[16]=d,e[17]=a,e[18]=b):b=e[18],e[19]!==u||e[20]!==m||e[21]!==b?(x=i.jsx("div",{className:"absolute top-12 justify-center flex w-full left-0 right-0 z-50","data-keep-cell-selection":!0,children:i.jsx("div",{className:"bg-background/95 backdrop-blur-sm supports-backdrop-filter:bg-background/60 border border-(--slate-7) rounded-lg shadow-lg p-2 overflow-x-auto overflow-y-hidden mx-20 scrollbar-thin",children:i.jsxs("div",{className:"flex items-center gap-1",children:[u,h,m,p,b]})})}),e[19]=u,e[20]=m,e[21]=b,e[22]=x):x=e[22],x};function Ab(t){t.stopPropagation()}const Tb={display:"none"};function Db(t){let{id:e,value:n}=t;return he.createElement("div",{id:e,style:Tb},n)}function Mb(t){let{id:e,announcement:n,ariaLiveType:o="assertive"}=t;return he.createElement("div",{id:e,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":o,"aria-atomic":!0},n)}const fu=S.createContext(null),Ob={draggable:`
100
111
  To pick up a draggable item, press the space bar.
101
112
  While dragging, use the arrow keys to move the item.
102
113
  Press space again to drop the item in its new position, or press escape to cancel.
103
- `},Bb={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function Pb(t){let{announcements:e=Bb,container:n,hiddenTextDescribedById:o,screenReaderInstructions:r=Fb}=t;const{announce:s,announcement:a}=(function(){const[h,m]=S.useState("");return{announce:S.useCallback(p=>{p!=null&&m(p)},[]),announcement:h}})(),l=Sr("DndLiveRegion"),[c,d]=S.useState(!1);if(S.useEffect(()=>{d(!0)},[]),(function(h){const m=S.useContext(pu);S.useEffect(()=>{if(!m)throw new Error("useDndMonitor must be used within a children of <DndContext>");return m(h)},[h,m])})(S.useMemo(()=>({onDragStart(h){let{active:m}=h;s(e.onDragStart({active:m}))},onDragMove(h){let{active:m,over:p}=h;e.onDragMove&&s(e.onDragMove({active:m,over:p}))},onDragOver(h){let{active:m,over:p}=h;s(e.onDragOver({active:m,over:p}))},onDragEnd(h){let{active:m,over:p}=h;s(e.onDragEnd({active:m,over:p}))},onDragCancel(h){let{active:m,over:p}=h;s(e.onDragCancel({active:m,over:p}))}}),[s,e])),!c)return null;const u=me.createElement(me.Fragment,null,me.createElement(Rb,{id:o,value:r.draggable}),me.createElement(Lb,{id:l,announcement:a}));return n?Ir.createPortal(u,n):u}var ot;function os(){}function gu(t,e){return S.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(ot||(ot={}));const Pt=Object.freeze({x:0,y:0});function si(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function ai(t,e){let{data:{value:n}}=t,{data:{value:o}}=e;return n-o}function zb(t,e){let{data:{value:n}}=t,{data:{value:o}}=e;return o-n}function ii(t){let{left:e,top:n,height:o,width:r}=t;return[{x:e,y:n},{x:e+r,y:n},{x:e,y:n+o},{x:e+r,y:n+o}]}function li(t,e){if(!t||t.length===0)return null;const[n]=t;return e?n[e]:n}function bu(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+.5*t.width,y:n+.5*t.height}}const ci=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:o}=t;const r=bu(e,e.left,e.top),s=[];for(const a of o){const{id:l}=a,c=n.get(l);if(c){const d=si(bu(c),r);s.push({id:l,data:{droppableContainer:a,value:d}})}}return s.sort(ai)};function Ub(t,e){const n=Math.max(e.top,t.top),o=Math.max(e.left,t.left),r=Math.min(e.left+e.width,t.left+t.width),s=Math.min(e.top+e.height,t.top+t.height),a=r-o,l=s-n;if(o<r&&n<s){const c=e.width*e.height,d=t.width*t.height,u=a*l;return Number((u/(c+d-u)).toFixed(4))}return 0}const xu=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:o}=t;const r=[];for(const s of o){const{id:a}=s,l=n.get(a);if(l){const c=Ub(l,e);c>0&&r.push({id:a,data:{droppableContainer:s,value:c}})}}return r.sort(zb)};function Wb(t,e){const{top:n,left:o,bottom:r,right:s}=e;return n<=t.y&&t.y<=r&&o<=t.x&&t.x<=s}function yu(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Pt}function $b(t){return function(e){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return o.reduce((s,a)=>({...s,top:s.top+t*a.y,bottom:s.bottom+t*a.y,left:s.left+t*a.x,right:s.right+t*a.x}),{...e})}}const Vb=$b(1),Gb={ignoreTransform:!1};function mo(t,e){e===void 0&&(e=Gb);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:d,transformOrigin:u}=In(t).getComputedStyle(t);d&&(n=(function(h,m,p){const b=(function(k){if(k.startsWith("matrix3d(")){const E=k.slice(9,-1).split(/, /);return{x:+E[12],y:+E[13],scaleX:+E[0],scaleY:+E[5]}}if(k.startsWith("matrix(")){const E=k.slice(7,-1).split(/, /);return{x:+E[4],y:+E[5],scaleX:+E[0],scaleY:+E[3]}}return null})(m);if(!b)return h;const{scaleX:x,scaleY:f,x:g,y}=b,w=h.left-g-(1-x)*parseFloat(p),j=h.top-y-(1-f)*parseFloat(p.slice(p.indexOf(" ")+1)),C=x?h.width/x:h.width,N=f?h.height/f:h.height;return{width:C,height:N,top:j,right:w+C,bottom:j+N,left:w}})(n,d,u))}const{top:o,left:r,width:s,height:a,bottom:l,right:c}=n;return{top:o,left:r,width:s,height:a,bottom:l,right:c}}function vu(t){return mo(t,{ignoreTransform:!0})}function rs(t,e){const n=[];return t?(function o(r){if(e!=null&&n.length>=e||!r)return n;if(t1(r)&&r.scrollingElement!=null&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!ia(r)||Yk(r)||n.includes(r))return n;const s=In(t).getComputedStyle(r);return r!==t&&(function(a,l){l===void 0&&(l=In(a).getComputedStyle(a));const c=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(d=>{const u=l[d];return typeof u=="string"&&c.test(u)})})(r,s)&&n.push(r),(function(a,l){return l===void 0&&(l=In(a).getComputedStyle(a)),l.position==="fixed"})(r,s)?n:o(r.parentNode)})(t):n}function wu(t){const[e]=rs(t,1);return e??null}function di(t){return oc&&t?rc(t)?t:Zk(t)?t1(t)||t===Oo(t).scrollingElement?window:ia(t)?t:null:null:null}function ku(t){return rc(t)?t.scrollX:t.scrollLeft}function ju(t){return rc(t)?t.scrollY:t.scrollTop}function ui(t){return{x:ku(t),y:ju(t)}}var at;function Cu(t){return!(!oc||!t)&&t===document.scrollingElement}function Nu(t){const e={x:0,y:0},n=Cu(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},o={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height};return{isTop:t.scrollTop<=e.y,isLeft:t.scrollLeft<=e.x,isBottom:t.scrollTop>=o.y,isRight:t.scrollLeft>=o.x,maxScroll:o,minScroll:e}}(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(at||(at={}));const qb={x:.2,y:.2};function Hb(t,e,n,o,r){let{top:s,left:a,right:l,bottom:c}=n;o===void 0&&(o=10),r===void 0&&(r=qb);const{isTop:d,isBottom:u,isLeft:h,isRight:m}=Nu(t),p={x:0,y:0},b={x:0,y:0},x=e.height*r.y,f=e.width*r.x;return!d&&s<=e.top+x?(p.y=at.Backward,b.y=o*Math.abs((e.top+x-s)/x)):!u&&c>=e.bottom-x&&(p.y=at.Forward,b.y=o*Math.abs((e.bottom-x-c)/x)),!m&&l>=e.right-f?(p.x=at.Forward,b.x=o*Math.abs((e.right-f-l)/f)):!h&&a<=e.left+f&&(p.x=at.Backward,b.x=o*Math.abs((e.left+f-a)/f)),{direction:p,speed:b}}function Jb(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:a}=window;return{top:0,left:0,right:s,bottom:a,width:s,height:a}}const{top:e,left:n,right:o,bottom:r}=t.getBoundingClientRect();return{top:e,left:n,right:o,bottom:r,width:t.clientWidth,height:t.clientHeight}}function Su(t){return t.reduce((e,n)=>Ro(e,ui(n)),Pt)}const Kb=[["x",["left","right"],function(t){return t.reduce((e,n)=>e+ku(n),0)}],["y",["top","bottom"],function(t){return t.reduce((e,n)=>e+ju(n),0)}]];class hi{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=rs(n),r=Su(o);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,a,l]of Kb)for(const c of a)Object.defineProperty(this,c,{get:()=>{const d=l(o),u=r[s]-d;return this.rect[c]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Yo{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...n)})},this.target=e}add(e,n,o){var r;(r=this.target)==null||r.addEventListener(e,n,o),this.listeners.push([e,n,o])}}function mi(t,e){const n=Math.abs(t.x),o=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+o**2)>e:"x"in e&&"y"in e?n>e.x&&o>e.y:"x"in e?n>e.x:"y"in e&&o>e.y}var Rt,Ae;function Eu(t){t.preventDefault()}function Yb(t){t.stopPropagation()}(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Rt||(Rt={})),(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Ae||(Ae={}));const _u={start:[Ae.Space,Ae.Enter],cancel:[Ae.Esc],end:[Ae.Space,Ae.Enter,Ae.Tab]},Xb=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Ae.Right:return{...n,x:n.x+25};case Ae.Left:return{...n,x:n.x-25};case Ae.Down:return{...n,y:n.y+25};case Ae.Up:return{...n,y:n.y-25}}};class fi{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new Yo(Oo(n)),this.windowListeners=new Yo(In(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,o=e.node.current;o&&(function(r,s){if(s===void 0&&(s=mo),!r)return;const{top:a,left:l,bottom:c,right:d}=s(r);wu(r)&&(c<=0||d<=0||a>=window.innerHeight||l>=window.innerWidth)&&r.scrollIntoView({block:"center",inline:"center"})})(o),n(Pt)}handleKeyDown(e){if(tc(e)){const{active:n,context:o,options:r}=this.props,{keyboardCodes:s=_u,coordinateGetter:a=Xb,scrollBehavior:l="smooth"}=r,{code:c}=e;if(s.end.includes(c))return void this.handleEnd(e);if(s.cancel.includes(c))return void this.handleCancel(e);const{collisionRect:d}=o.current,u=d?{x:d.left,y:d.top}:Pt;this.referenceCoordinates||(this.referenceCoordinates=u);const h=a(e,{active:n,context:o.current,currentCoordinates:u});if(h){const m=_r(h,u),p={x:0,y:0},{scrollableAncestors:b}=o.current;for(const x of b){const f=e.code,{isTop:g,isRight:y,isLeft:w,isBottom:j,maxScroll:C,minScroll:N}=Nu(x),k=Jb(x),E={x:Math.min(f===Ae.Right?k.right-k.width/2:k.right,Math.max(f===Ae.Right?k.left:k.left+k.width/2,h.x)),y:Math.min(f===Ae.Down?k.bottom-k.height/2:k.bottom,Math.max(f===Ae.Down?k.top:k.top+k.height/2,h.y))},_=f===Ae.Right&&!y||f===Ae.Left&&!w,I=f===Ae.Down&&!j||f===Ae.Up&&!g;if(_&&E.x!==h.x){const A=x.scrollLeft+m.x,O=f===Ae.Right&&A<=C.x||f===Ae.Left&&A>=N.x;if(O&&!m.y)return void x.scrollTo({left:A,behavior:l});p.x=O?x.scrollLeft-A:f===Ae.Right?x.scrollLeft-C.x:x.scrollLeft-N.x,p.x&&x.scrollBy({left:-p.x,behavior:l});break}if(I&&E.y!==h.y){const A=x.scrollTop+m.y,O=f===Ae.Down&&A<=C.y||f===Ae.Up&&A>=N.y;if(O&&!m.x)return void x.scrollTo({top:A,behavior:l});p.y=O?x.scrollTop-A:f===Ae.Down?x.scrollTop-C.y:x.scrollTop-N.y,p.y&&x.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,Ro(_r(h,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:o}=this.props;e.preventDefault(),o(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function Iu(t){return!!(t&&"distance"in t)}function Au(t){return!!(t&&"delay"in t)}fi.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:o=_u,onActivation:r}=e,{active:s}=n;const{code:a}=t.nativeEvent;if(o.start.includes(a)){const l=s.activatorNode.current;return(!l||t.target===l)&&(t.preventDefault(),r==null||r({event:t.nativeEvent}),!0)}return!1}}];class pi{constructor(e,n,o){var r;o===void 0&&(o=(function(l){const{EventTarget:c}=In(l);return l instanceof c?l:Oo(l)})(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:s}=e,{target:a}=s;this.props=e,this.events=n,this.document=Oo(a),this.documentListeners=new Yo(this.document),this.listeners=new Yo(o),this.windowListeners=new Yo(In(a)),this.initialCoordinates=(r=nc(s))!=null?r:Pt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:o}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.DragStart,Eu),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),this.windowListeners.add(Rt.ContextMenu,Eu),this.documentListeners.add(Rt.Keydown,this.handleKeydown),n){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Au(n))return this.timeoutId=setTimeout(this.handleStart,n.delay),void this.handlePending(n);if(Iu(n))return void this.handlePending(n)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:o,onPending:r}=this.props;r(o,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(Rt.Click,Yb,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rt.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:o,initialCoordinates:r,props:s}=this,{onMove:a,options:{activationConstraint:l}}=s;if(!r)return;const c=(n=nc(e))!=null?n:Pt,d=_r(r,c);if(!o&&l){if(Iu(l)){if(l.tolerance!=null&&mi(d,l.tolerance))return this.handleCancel();if(mi(d,l.distance))return this.handleStart()}return Au(l)&&mi(d,l.tolerance)?this.handleCancel():void this.handlePending(l,d)}e.cancelable&&e.preventDefault(),a(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Ae.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const Qb={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class gi extends pi{constructor(e){const{event:n}=e,o=Oo(n.target);super(e,Qb,o)}}gi.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;return!(!n.isPrimary||n.button!==0)&&(o==null||o({event:n}),!0)}}];const Zb={move:{name:"mousemove"},end:{name:"mouseup"}};var bi;(function(t){t[t.RightClick=2]="RightClick"})(bi||(bi={})),(class extends pi{constructor(t){super(t,Zb,Oo(t.event.target))}}).activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;return n.button!==bi.RightClick&&(o==null||o({event:n}),!0)}}];const xi={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var Xo,ss;function ex(t){let{acceleration:e,activator:n=Xo.Pointer,canScroll:o,draggingRect:r,enabled:s,interval:a=5,order:l=ss.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:m}=t;const p=(function(N){let{delta:k,disabled:E}=N;const _=la(k);return Ar(I=>{if(E||!_||!I)return tx;const A={x:Math.sign(k.x-_.x),y:Math.sign(k.y-_.y)};return{x:{[at.Backward]:I.x[at.Backward]||A.x===-1,[at.Forward]:I.x[at.Forward]||A.x===1},y:{[at.Backward]:I.y[at.Backward]||A.y===-1,[at.Forward]:I.y[at.Forward]||A.y===1}}},[E,k,_])})({delta:h,disabled:!s}),[b,x]=Xk(),f=S.useRef({x:0,y:0}),g=S.useRef({x:0,y:0}),y=S.useMemo(()=>{switch(n){case Xo.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Xo.DraggableRect:return r}},[n,r,c]),w=S.useRef(null),j=S.useCallback(()=>{const N=w.current;if(!N)return;const k=f.current.x*g.current.x,E=f.current.y*g.current.y;N.scrollBy(k,E)},[]),C=S.useMemo(()=>l===ss.TreeOrder?[...d].reverse():d,[l,d]);S.useEffect(()=>{if(s&&d.length&&y){for(const N of C){if((o==null?void 0:o(N))===!1)continue;const k=d.indexOf(N),E=u[k];if(!E)continue;const{direction:_,speed:I}=Hb(N,E,y,e,m);for(const A of["x","y"])p[A][_[A]]||(I[A]=0,_[A]=0);if(I.x>0||I.y>0)return x(),w.current=N,b(j,a),f.current=I,void(g.current=_)}f.current={x:0,y:0},g.current={x:0,y:0},x()}else x()},[e,j,o,x,s,a,JSON.stringify(y),JSON.stringify(p),b,d,C,u,JSON.stringify(m)])}(class extends pi{constructor(t){super(t,xi)}static setup(){return window.addEventListener(xi.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(xi.move.name,t)};function t(){}}}).activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;const{touches:r}=n;return!(r.length>1)&&(o==null||o({event:n}),!0)}}],(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Xo||(Xo={})),(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(ss||(ss={}));const tx={x:{[at.Backward]:!1,[at.Forward]:!1},y:{[at.Backward]:!1,[at.Forward]:!1}};var Qo,yi;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Qo||(Qo={})),(function(t){t.Optimized="optimized"})(yi||(yi={}));const Tu=new Map;function Du(t,e){return Ar(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function as(t){let{callback:e,disabled:n}=t;const o=e1(e),r=S.useMemo(()=>{if(n||typeof window>"u"||window.ResizeObserver===void 0)return;const{ResizeObserver:s}=window;return new s(o)},[n]);return S.useEffect(()=>()=>r==null?void 0:r.disconnect(),[r]),r}function nx(t){return new hi(mo(t),t)}function Mu(t,e,n){e===void 0&&(e=nx);const[o,r]=S.useState(null);function s(){r(c=>{if(!t)return null;var d;if(t.isConnected===!1)return(d=c??n)!=null?d:null;const u=e(t);return JSON.stringify(c)===JSON.stringify(u)?c:u})}const a=(function(c){let{callback:d,disabled:u}=c;const h=e1(d),m=S.useMemo(()=>{if(u||typeof window>"u"||window.MutationObserver===void 0)return;const{MutationObserver:p}=window;return new p(h)},[h,u]);return S.useEffect(()=>()=>m==null?void 0:m.disconnect(),[m]),m})({callback(c){if(t)for(const d of c){const{type:u,target:h}=d;if(u==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),l=as({callback:s});return Vn(()=>{s(),t?(l==null||l.observe(t),a==null||a.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),a==null||a.disconnect())},[t]),o}const Ou=[];function Ru(t,e){e===void 0&&(e=[]);const n=S.useRef(null);return S.useEffect(()=>{n.current=null},e),S.useEffect(()=>{const o=t!==Pt;o&&!n.current&&(n.current=t),!o&&n.current&&(n.current=null)},[t]),n.current?_r(t,n.current):Pt}function Lu(t){return S.useMemo(()=>t?(function(e){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}})(t):null,[t])}const Fu=[];function ox(t){let{measure:e}=t;const[n,o]=S.useState(null),r=S.useCallback(d=>{for(const{target:u}of d)if(ia(u)){o(h=>{const m=e(u);return h?{...h,width:m.width,height:m.height}:m});break}},[e]),s=as({callback:r}),a=S.useCallback(d=>{const u=(function(h){if(!h)return null;if(h.children.length>1)return h;const m=h.children[0];return ia(m)?m:h})(d);s==null||s.disconnect(),u&&(s==null||s.observe(u)),o(u?e(u):null)},[e,s]),[l,c]=aa(a);return S.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const rx=[{sensor:gi,options:{}},{sensor:fi,options:{}}],sx={current:{}},is={draggable:{measure:vu},droppable:{measure:vu,strategy:Qo.WhileDragging,frequency:yi.Optimized},dragOverlay:{measure:mo}};class Zo extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,o;return(n=(o=this.get(e))==null?void 0:o.node.current)!=null?n:void 0}}const ax={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Zo,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:os},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:is,measureDroppableContainers:os,windowRect:null,measuringScheduled:!1},ix={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:os,draggableNodes:new Map,over:null,measureDroppableContainers:os},ls=S.createContext(ix),Bu=S.createContext(ax);function lx(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Zo}}}function cx(t,e){switch(e.type){case ot.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ot.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case ot.DragEnd:case ot.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ot.RegisterDroppable:{const{element:n}=e,{id:o}=n,r=new Zo(t.droppable.containers);return r.set(o,n),{...t,droppable:{...t.droppable,containers:r}}}case ot.SetDroppableDisabled:{const{id:n,key:o,disabled:r}=e,s=t.droppable.containers.get(n);if(!s||o!==s.key)return t;const a=new Zo(t.droppable.containers);return a.set(n,{...s,disabled:r}),{...t,droppable:{...t.droppable,containers:a}}}case ot.UnregisterDroppable:{const{id:n,key:o}=e,r=t.droppable.containers.get(n);if(!r||o!==r.key)return t;const s=new Zo(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function dx(t){let{disabled:e}=t;const{active:n,activatorEvent:o,draggableNodes:r}=S.useContext(ls),s=la(o),a=la(n==null?void 0:n.id);return S.useEffect(()=>{if(!e&&!o&&s&&a!=null){if(!tc(s)||document.activeElement===s.target)return;const l=r.get(a);if(!l)return;const{activatorNode:c,node:d}=l;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const u of[c.current,d.current]){if(!u)continue;const h=Qk(u);if(h){h.focus();break}}})}},[o,e,r,a,s]),null}const Pu=S.createContext({...Pt,scaleX:1,scaleY:1});var An;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(An||(An={}));const ux=S.memo(function(t){var e,n,o,r;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:d=rx,collisionDetection:u=xu,measuring:h,modifiers:m,...p}=t;const b=S.useReducer(cx,void 0,lx),[x,f]=b,[g,y]=(function(){const[re]=S.useState(()=>new Set),ce=S.useCallback(le=>(re.add(le),()=>re.delete(le)),[re]);return[S.useCallback(le=>{let{type:je,event:Ne}=le;re.forEach(xe=>{var De;return(De=xe[je])==null?void 0:De.call(xe,Ne)})},[re]),ce]})(),[w,j]=S.useState(An.Uninitialized),C=w===An.Initialized,{draggable:{active:N,nodes:k,translate:E},droppable:{containers:_}}=x,I=N!=null?k.get(N):null,A=S.useRef({initial:null,translated:null}),O=S.useMemo(()=>{var re;return N!=null?{id:N,data:(re=I==null?void 0:I.data)!=null?re:sx,rect:A}:null},[N,I]),D=S.useRef(null),[M,R]=S.useState(null),[L,z]=S.useState(null),T=Er(p,Object.values(p)),F=Sr("DndDescribedBy",s),$=S.useMemo(()=>_.getEnabled(),[_]),W=(G=h,S.useMemo(()=>({draggable:{...is.draggable,...G==null?void 0:G.draggable},droppable:{...is.droppable,...G==null?void 0:G.droppable},dragOverlay:{...is.dragOverlay,...G==null?void 0:G.dragOverlay}}),[G==null?void 0:G.draggable,G==null?void 0:G.droppable,G==null?void 0:G.dragOverlay]));var G;const{droppableRects:X,measureDroppableContainers:H,measuringScheduled:Y}=(function(re,ce){let{dragging:le,dependencies:je,config:Ne}=ce;const[xe,De]=S.useState(null),{frequency:Fe,measure:Ie,strategy:Re}=Ne,kt=S.useRef(re),jt=(function(){switch(Re){case Qo.Always:return!1;case Qo.BeforeDragging:return le;default:return!le}})(),Ut=Er(jt),Tt=S.useCallback(function(Ln){Ln===void 0&&(Ln=[]),Ut.current||De(no=>no===null?Ln:no.concat(Ln.filter(Kt=>!no.includes(Kt))))},[Ut]),Nn=S.useRef(null),Vs=Ar(Ln=>{if(jt&&!le)return Tu;if(!Ln||Ln===Tu||kt.current!==re||xe!=null){const no=new Map;for(let Kt of re){if(!Kt)continue;if(xe&&xe.length>0&&!xe.includes(Kt.id)&&Kt.rect.current){no.set(Kt.id,Kt.rect.current);continue}const kl=Kt.node.current,jl=kl?new hi(Ie(kl),kl):null;Kt.rect.current=jl,jl&&no.set(Kt.id,jl)}return no}return Ln},[re,xe,le,jt,Ie]);return S.useEffect(()=>{kt.current=re},[re]),S.useEffect(()=>{jt||Tt()},[le,jt]),S.useEffect(()=>{xe&&xe.length>0&&De(null)},[JSON.stringify(xe)]),S.useEffect(()=>{jt||typeof Fe!="number"||Nn.current!==null||(Nn.current=setTimeout(()=>{Tt(),Nn.current=null},Fe))},[Fe,jt,Tt,...je]),{droppableRects:Vs,measureDroppableContainers:Tt,measuringScheduled:xe!=null}})($,{dragging:C,dependencies:[E.x,E.y],config:W.droppable}),K=(function(re,ce){const le=ce!=null?re.get(ce):void 0,je=le?le.node.current:null;return Ar(Ne=>{var xe;return ce==null?null:(xe=je??Ne)!=null?xe:null},[je,ce])})(k,N),V=S.useMemo(()=>L?nc(L):null,[L]),q=(function(){const re=(M==null?void 0:M.autoScrollEnabled)===!1,ce=typeof l=="object"?l.enabled===!1:l===!1,le=C&&!re&&!ce;return typeof l=="object"?{...l,enabled:le}:{enabled:le}})(),U=(function(re,ce){return Du(re,ce)})(K,W.draggable.measure);(function(re){let{activeNode:ce,measure:le,initialRect:je,config:Ne=!0}=re;const xe=S.useRef(!1),{x:De,y:Fe}=typeof Ne=="boolean"?{x:Ne,y:Ne}:Ne;Vn(()=>{if(!De&&!Fe||!ce)return void(xe.current=!1);if(xe.current||!je)return;const Ie=ce==null?void 0:ce.node.current;if(!Ie||Ie.isConnected===!1)return;const Re=yu(le(Ie),je);if(De||(Re.x=0),Fe||(Re.y=0),xe.current=!0,Math.abs(Re.x)>0||Math.abs(Re.y)>0){const kt=wu(Ie);kt&&kt.scrollBy({top:Re.y,left:Re.x})}},[ce,De,Fe,je,le])})({activeNode:N!=null?k.get(N):null,config:q.layoutShiftCompensation,initialRect:U,measure:W.draggable.measure});const ne=Mu(K,W.draggable.measure,U),Q=Mu(K?K.parentElement:null),ee=S.useRef({activatorEvent:null,active:null,activeNode:K,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:k,draggingNode:null,draggingNodeRect:null,droppableContainers:_,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=_.getNodeFor((e=ee.current.over)==null?void 0:e.id),se=ox({measure:W.dragOverlay.measure}),ae=(n=se.nodeRef.current)!=null?n:K,te=C?(o=se.rect)!=null?o:ne:null,_e=!!(se.nodeRef.current&&se.rect),he=yu(we=_e?null:ne,Du(we));var we;const ke=Lu(ae?In(ae):null),ge=(function(re){const ce=S.useRef(re),le=Ar(je=>re?je&&je!==Ou&&re&&ce.current&&re.parentNode===ce.current.parentNode?je:rs(re):Ou,[re]);return S.useEffect(()=>{ce.current=re},[re]),le})(C?oe??K:null),Ee=(function(re,ce){ce===void 0&&(ce=mo);const[le]=re,je=Lu(le?In(le):null),[Ne,xe]=S.useState(Fu);function De(){xe(()=>re.length?re.map(Ie=>Cu(Ie)?je:new hi(ce(Ie),Ie)):Fu)}const Fe=as({callback:De});return Vn(()=>{Fe==null||Fe.disconnect(),De(),re.forEach(Ie=>Fe==null?void 0:Fe.observe(Ie))},[re]),Ne})(ge),Oe=(function(re,ce){let{transform:le,...je}=ce;return re!=null&&re.length?re.reduce((Ne,xe)=>xe({transform:Ne,...je}),le):le})(m,{transform:{x:E.x-he.x,y:E.y-he.y,scaleX:1,scaleY:1},activatorEvent:L,active:O,activeNodeRect:ne,containerNodeRect:Q,draggingNodeRect:te,over:ee.current.over,overlayNodeRect:se.rect,scrollableAncestors:ge,scrollableAncestorRects:Ee,windowRect:ke}),ve=V?Ro(V,E):null,be=(function(re){const[ce,le]=S.useState(null),je=S.useRef(re),Ne=S.useCallback(xe=>{const De=di(xe.target);De&&le(Fe=>Fe?(Fe.set(De,ui(De)),new Map(Fe)):null)},[]);return S.useEffect(()=>{const xe=je.current;if(re!==xe){De(xe);const Fe=re.map(Ie=>{const Re=di(Ie);return Re?(Re.addEventListener("scroll",Ne,{passive:!0}),[Re,ui(Re)]):null}).filter(Ie=>Ie!=null);le(Fe.length?new Map(Fe):null),je.current=re}return()=>{De(re),De(xe)};function De(Fe){Fe.forEach(Ie=>{const Re=di(Ie);Re==null||Re.removeEventListener("scroll",Ne)})}},[Ne,re]),S.useMemo(()=>re.length?ce?Array.from(ce.values()).reduce((xe,De)=>Ro(xe,De),Pt):Su(re):Pt,[re,ce])})(ge),et=Ru(be),rt=Ru(be,[ne]),ct=Ro(Oe,et),dt=te?Vb(te,Oe):null,pt=O&&dt?u({active:O,collisionRect:dt,droppableRects:X,droppableContainers:$,pointerCoordinates:ve}):null,ut=li(pt,"id"),[wt,Lt]=S.useState(null),On=(function(re,ce,le){return{...re,scaleX:ce&&le?ce.width/le.width:1,scaleY:ce&&le?ce.height/le.height:1}})(_e?Oe:Ro(Oe,rt),(r=wt==null?void 0:wt.rect)!=null?r:null,ne),Jt=S.useRef(null),Ft=S.useCallback((re,ce)=>{let{sensor:le,options:je}=ce;if(D.current==null)return;const Ne=k.get(D.current);if(!Ne)return;const xe=re.nativeEvent,De=new le({active:D.current,activeNode:Ne,event:xe,options:je,context:ee,onAbort(Ie){if(!k.get(Ie))return;const{onDragAbort:Re}=T.current,kt={id:Ie};Re==null||Re(kt),g({type:"onDragAbort",event:kt})},onPending(Ie,Re,kt,jt){if(!k.get(Ie))return;const{onDragPending:Ut}=T.current,Tt={id:Ie,constraint:Re,initialCoordinates:kt,offset:jt};Ut==null||Ut(Tt),g({type:"onDragPending",event:Tt})},onStart(Ie){const Re=D.current;if(Re==null)return;const kt=k.get(Re);if(!kt)return;const{onDragStart:jt}=T.current,Ut={activatorEvent:xe,active:{id:Re,data:kt.data,rect:A}};Ir.unstable_batchedUpdates(()=>{jt==null||jt(Ut),j(An.Initializing),f({type:ot.DragStart,initialCoordinates:Ie,active:Re}),g({type:"onDragStart",event:Ut}),R(Jt.current),z(xe)})},onMove(Ie){f({type:ot.DragMove,coordinates:Ie})},onEnd:Fe(ot.DragEnd),onCancel:Fe(ot.DragCancel)});function Fe(Ie){return async function(){const{active:Re,collisions:kt,over:jt,scrollAdjustedTranslate:Ut}=ee.current;let Tt=null;if(Re&&Ut){const{cancelDrop:Nn}=T.current;Tt={activatorEvent:xe,active:Re,collisions:kt,delta:Ut,over:jt},Ie===ot.DragEnd&&typeof Nn=="function"&&await Promise.resolve(Nn(Tt))&&(Ie=ot.DragCancel)}D.current=null,Ir.unstable_batchedUpdates(()=>{f({type:Ie}),j(An.Uninitialized),Lt(null),R(null),z(null),Jt.current=null;const Nn=Ie===ot.DragEnd?"onDragEnd":"onDragCancel";if(Tt){const Vs=T.current[Nn];Vs==null||Vs(Tt),g({type:Nn,event:Tt})}})}}Jt.current=De},[k]),zt=S.useCallback((re,ce)=>(le,je)=>{const Ne=le.nativeEvent,xe=k.get(je);if(D.current!==null||!xe||Ne.dndKit||Ne.defaultPrevented)return;const De={active:xe};re(le,ce.options,De)===!0&&(Ne.dndKit={capturedBy:ce.sensor},D.current=je,Ft(le,ce))},[k,Ft]),to=(function(re,ce){return S.useMemo(()=>re.reduce((le,je)=>{const{sensor:Ne}=je;return[...le,...Ne.activators.map(xe=>({eventName:xe.eventName,handler:ce(xe.handler,je)}))]},[]),[re,ce])})(d,zt);(function(re){S.useEffect(()=>{if(!oc)return;const ce=re.map(le=>{let{sensor:je}=le;return je.setup==null?void 0:je.setup()});return()=>{for(const le of ce)le==null||le()}},re.map(ce=>{let{sensor:le}=ce;return le}))})(d),Vn(()=>{ne&&w===An.Initializing&&j(An.Initialized)},[ne,w]),S.useEffect(()=>{const{onDragMove:re}=T.current,{active:ce,activatorEvent:le,collisions:je,over:Ne}=ee.current;if(!ce||!le)return;const xe={active:ce,activatorEvent:le,collisions:je,delta:{x:ct.x,y:ct.y},over:Ne};Ir.unstable_batchedUpdates(()=>{re==null||re(xe),g({type:"onDragMove",event:xe})})},[ct.x,ct.y]),S.useEffect(()=>{const{active:re,activatorEvent:ce,collisions:le,droppableContainers:je,scrollAdjustedTranslate:Ne}=ee.current;if(!re||D.current==null||!ce||!Ne)return;const{onDragOver:xe}=T.current,De=je.get(ut),Fe=De&&De.rect.current?{id:De.id,rect:De.rect.current,data:De.data,disabled:De.disabled}:null,Ie={active:re,activatorEvent:ce,collisions:le,delta:{x:Ne.x,y:Ne.y},over:Fe};Ir.unstable_batchedUpdates(()=>{Lt(Fe),xe==null||xe(Ie),g({type:"onDragOver",event:Ie})})},[ut]),Vn(()=>{ee.current={activatorEvent:L,active:O,activeNode:K,collisionRect:dt,collisions:pt,droppableRects:X,draggableNodes:k,draggingNode:ae,draggingNodeRect:te,droppableContainers:_,over:wt,scrollableAncestors:ge,scrollAdjustedTranslate:ct},A.current={initial:te,translated:dt}},[O,K,pt,dt,k,ae,te,X,_,wt,ge,ct]),ex({...q,delta:E,draggingRect:dt,pointerCoordinates:ve,scrollableAncestors:ge,scrollableAncestorRects:Ee});const Rn=S.useMemo(()=>({active:O,activeNode:K,activeNodeRect:ne,activatorEvent:L,collisions:pt,containerNodeRect:Q,dragOverlay:se,draggableNodes:k,droppableContainers:_,droppableRects:X,over:wt,measureDroppableContainers:H,scrollableAncestors:ge,scrollableAncestorRects:Ee,measuringConfiguration:W,measuringScheduled:Y,windowRect:ke}),[O,K,ne,L,pt,Q,se,k,_,X,wt,H,ge,Ee,W,Y,ke]),No=S.useMemo(()=>({activatorEvent:L,activators:to,active:O,activeNodeRect:ne,ariaDescribedById:{draggable:F},dispatch:f,draggableNodes:k,over:wt,measureDroppableContainers:H}),[L,to,O,ne,f,F,k,wt,H]);return me.createElement(pu.Provider,{value:y},me.createElement(ls.Provider,{value:No},me.createElement(Bu.Provider,{value:Rn},me.createElement(Pu.Provider,{value:On},c)),me.createElement(dx,{disabled:(a==null?void 0:a.restoreFocus)===!1})),me.createElement(Pb,{...a,hiddenTextDescribedById:F}))}),hx=S.createContext(null),zu="button";function mx(t){let{id:e,data:n,disabled:o=!1,attributes:r}=t;const s=Sr("Draggable"),{activators:a,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:m}=S.useContext(ls),{role:p=zu,roleDescription:b="draggable",tabIndex:x=0}=r??{},f=(c==null?void 0:c.id)===e,g=S.useContext(f?Pu:hx),[y,w]=aa(),[j,C]=aa(),N=(function(E,_){return S.useMemo(()=>E.reduce((I,A)=>{let{eventName:O,handler:D}=A;return I[O]=M=>{D(M,_)},I},{}),[E,_])})(a,e),k=Er(n);return Vn(()=>(h.set(e,{id:e,key:s,node:y,activatorNode:j,data:k}),()=>{const E=h.get(e);E&&E.key===s&&h.delete(e)}),[h,e]),{active:c,activatorEvent:l,activeNodeRect:d,attributes:S.useMemo(()=>({role:p,tabIndex:x,"aria-disabled":o,"aria-pressed":!(!f||p!==zu)||void 0,"aria-roledescription":b,"aria-describedby":u.draggable}),[o,p,x,f,b,u.draggable]),isDragging:f,listeners:o?void 0:N,node:y,over:m,setNodeRef:w,setActivatorNodeRef:C,transform:g}}const fx={timeout:25};function Uu(t,e,n){const o=t.slice();return o.splice(n<0?o.length+n:n,0,o.splice(e,1)[0]),o}function px(t,e){return t.reduce((n,o,r)=>{const s=e.get(o);return s&&(n[r]=s),n},Array(t.length))}function cs(t){return t!==null&&t>=0}const ds={scaleX:1,scaleY:1},gx=t=>{var e;let{rects:n,activeNodeRect:o,activeIndex:r,overIndex:s,index:a}=t;const l=(e=n[r])!=null?e:o;if(!l)return null;const c=(function(d,u,h){const m=d[u],p=d[u-1],b=d[u+1];return!m||!p&&!b?0:h<u?p?m.left-(p.left+p.width):b.left-(m.left+m.width):b?b.left-(m.left+m.width):m.left-(p.left+p.width)})(n,a,r);if(a===r){const d=n[s];return d?{x:r<s?d.left+d.width-(l.left+l.width):d.left-l.left,y:0,...ds}:null}return a>r&&a<=s?{x:-l.width-c,y:0,...ds}:a<r&&a>=s?{x:l.width+c,y:0,...ds}:{x:0,y:0,...ds}},Wu=t=>{let{rects:e,activeIndex:n,overIndex:o,index:r}=t;const s=Uu(e,o,n),a=e[r],l=s[r];return l&&a?{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}:null},us={scaleX:1,scaleY:1},bx=t=>{var e;let{activeIndex:n,activeNodeRect:o,index:r,rects:s,overIndex:a}=t;const l=(e=s[n])!=null?e:o;if(!l)return null;if(r===n){const d=s[a];return d?{x:0,y:n<a?d.top+d.height-(l.top+l.height):d.top-l.top,...us}:null}const c=(function(d,u,h){const m=d[u],p=d[u-1],b=d[u+1];return m?h<u?p?m.top-(p.top+p.height):b?b.top-(m.top+m.height):0:b?b.top-(m.top+m.height):p?m.top-(p.top+p.height):0:0})(s,r,n);return r>n&&r<=a?{x:0,y:-l.height-c,...us}:r<n&&r>=a?{x:0,y:l.height+c,...us}:{x:0,y:0,...us}},$u="Sortable",Vu=me.createContext({activeIndex:-1,containerId:$u,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Wu,disabled:{draggable:!1,droppable:!1}});function Gu(t){let{children:e,id:n,items:o,strategy:r=Wu,disabled:s=!1}=t;const{active:a,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:u}=S.useContext(Bu),h=Sr($u,n),m=l.rect!==null,p=S.useMemo(()=>o.map(N=>typeof N=="object"&&"id"in N?N.id:N),[o]),b=a!=null,x=a?p.indexOf(a.id):-1,f=d?p.indexOf(d.id):-1,g=S.useRef(p),y=!(function(N,k){if(N===k)return!0;if(N.length!==k.length)return!1;for(let E=0;E<N.length;E++)if(N[E]!==k[E])return!1;return!0})(p,g.current),w=f!==-1&&x===-1||y,j=(function(N){return typeof N=="boolean"?{draggable:N,droppable:N}:N})(s);Vn(()=>{y&&b&&u(p)},[y,p,b,u]),S.useEffect(()=>{g.current=p},[p]);const C=S.useMemo(()=>({activeIndex:x,containerId:h,disabled:j,disableTransforms:w,items:p,overIndex:f,useDragOverlay:m,sortedRects:px(p,c),strategy:r}),[x,h,j.draggable,j.droppable,w,p,f,c,m,r]);return me.createElement(Vu.Provider,{value:C},e)}const xx=t=>{let{id:e,items:n,activeIndex:o,overIndex:r}=t;return Uu(n,o,r).indexOf(e)},yx=t=>{let{containerId:e,isSorting:n,wasDragging:o,index:r,items:s,newIndex:a,previousItems:l,previousContainerId:c,transition:d}=t;return!(!d||!o)&&(l===s||r!==a)&&(!!n||a!==r&&e===c)},vx={duration:200,easing:"ease"},qu="transform",wx=ca.Transition.toString({property:qu,duration:0,easing:"linear"}),kx={roleDescription:"sortable"};function Hu(t){let{animateLayoutChanges:e=yx,attributes:n,disabled:o,data:r,getNewIndex:s=xx,id:a,strategy:l,resizeObserverConfig:c,transition:d=vx}=t;const{items:u,containerId:h,activeIndex:m,disabled:p,disableTransforms:b,sortedRects:x,overIndex:f,useDragOverlay:g,strategy:y}=S.useContext(Vu),w=(function(oe,se){var ae,te;return typeof oe=="boolean"?{draggable:oe,droppable:!1}:{draggable:(ae=oe==null?void 0:oe.draggable)!=null?ae:se.draggable,droppable:(te=oe==null?void 0:oe.droppable)!=null?te:se.droppable}})(o,p),j=u.indexOf(a),C=S.useMemo(()=>({sortable:{containerId:h,index:j,items:u},...r}),[h,r,j,u]),N=S.useMemo(()=>u.slice(u.indexOf(a)),[u,a]),{rect:k,node:E,isOver:_,setNodeRef:I}=(function(oe){let{data:se,disabled:ae=!1,id:te,resizeObserverConfig:_e}=oe;const he=Sr("Droppable"),{active:we,dispatch:ke,over:ge,measureDroppableContainers:Ee}=S.useContext(ls),Oe=S.useRef({disabled:ae}),ve=S.useRef(!1),be=S.useRef(null),et=S.useRef(null),{disabled:rt,updateMeasurementsFor:ct,timeout:dt}={...fx,..._e},pt=Er(ct??te),ut=as({callback:S.useCallback(()=>{ve.current?(et.current!=null&&clearTimeout(et.current),et.current=setTimeout(()=>{Ee(Array.isArray(pt.current)?pt.current:[pt.current]),et.current=null},dt)):ve.current=!0},[dt]),disabled:rt||!we}),wt=S.useCallback((Ft,zt)=>{ut&&(zt&&(ut.unobserve(zt),ve.current=!1),Ft&&ut.observe(Ft))},[ut]),[Lt,On]=aa(wt),Jt=Er(se);return S.useEffect(()=>{ut&&Lt.current&&(ut.disconnect(),ve.current=!1,ut.observe(Lt.current))},[Lt,ut]),S.useEffect(()=>(ke({type:ot.RegisterDroppable,element:{id:te,key:he,disabled:ae,node:Lt,rect:be,data:Jt}}),()=>ke({type:ot.UnregisterDroppable,key:he,id:te})),[te]),S.useEffect(()=>{ae!==Oe.current.disabled&&(ke({type:ot.SetDroppableDisabled,id:te,key:he,disabled:ae}),Oe.current.disabled=ae)},[te,he,ae,ke]),{active:we,rect:be,isOver:(ge==null?void 0:ge.id)===te,node:Lt,over:ge,setNodeRef:On}})({id:a,data:C,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...c}}),{active:A,activatorEvent:O,activeNodeRect:D,attributes:M,setNodeRef:R,listeners:L,isDragging:z,over:T,setActivatorNodeRef:F,transform:$}=mx({id:a,data:C,attributes:{...kx,...n},disabled:w.draggable}),W=e4(I,R),G=!!A,X=G&&!b&&cs(m)&&cs(f),H=!g&&z,Y=H&&X?$:null,K=X?Y??(l??y)({rects:x,activeNodeRect:D,activeIndex:m,overIndex:f,index:j}):null,V=cs(m)&&cs(f)?s({id:a,items:u,activeIndex:m,overIndex:f}):j,q=A==null?void 0:A.id,U=S.useRef({activeId:q,items:u,newIndex:V,containerId:h}),ne=u!==U.current.items,Q=e({active:A,containerId:h,isDragging:z,isSorting:G,id:a,index:j,items:u,newIndex:U.current.newIndex,previousItems:U.current.items,previousContainerId:U.current.containerId,transition:d,wasDragging:U.current.activeId!=null}),ee=(function(oe){let{disabled:se,index:ae,node:te,rect:_e}=oe;const[he,we]=S.useState(null),ke=S.useRef(ae);return Vn(()=>{if(!se&&ae!==ke.current&&te.current){const ge=_e.current;if(ge){const Ee=mo(te.current,{ignoreTransform:!0}),Oe={x:ge.left-Ee.left,y:ge.top-Ee.top,scaleX:ge.width/Ee.width,scaleY:ge.height/Ee.height};(Oe.x||Oe.y)&&we(Oe)}}ae!==ke.current&&(ke.current=ae)},[se,ae,te,_e]),S.useEffect(()=>{he&&we(null)},[he]),he})({disabled:!Q,index:j,node:E,rect:k});return S.useEffect(()=>{G&&U.current.newIndex!==V&&(U.current.newIndex=V),h!==U.current.containerId&&(U.current.containerId=h),u!==U.current.items&&(U.current.items=u)},[G,V,h,u]),S.useEffect(()=>{if(q===U.current.activeId)return;if(q!=null&&U.current.activeId==null)return void(U.current.activeId=q);const oe=setTimeout(()=>{U.current.activeId=q},50);return()=>clearTimeout(oe)},[q]),{active:A,activeIndex:m,attributes:M,data:C,rect:k,index:j,newIndex:V,items:u,isOver:_,isSorting:G,isDragging:z,listeners:L,node:E,overIndex:f,over:T,setNodeRef:W,setActivatorNodeRef:F,setDroppableNodeRef:I,setDraggableNodeRef:R,transform:ee??K,transition:(function(){if(ee||ne&&U.current.newIndex===j)return wx;if(!(H&&!tc(O)||!d)&&(G||Q))return ca.Transition.toString({...d,property:qu})})()}}function hs(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const jx=[Ae.Down,Ae.Right,Ae.Up,Ae.Left],Cx=(t,e)=>{let{context:{active:n,collisionRect:o,droppableRects:r,droppableContainers:s,over:a,scrollableAncestors:l}}=e;if(jx.includes(t.code)){if(t.preventDefault(),!n||!o)return;const c=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const m=r.get(h.id);if(m)switch(t.code){case Ae.Down:o.top<m.top&&c.push(h);break;case Ae.Up:o.top>m.top&&c.push(h);break;case Ae.Left:o.left>m.left&&c.push(h);break;case Ae.Right:o.left<m.left&&c.push(h)}});const d=(h=>{let{collisionRect:m,droppableRects:p,droppableContainers:b}=h;const x=ii(m),f=[];for(const g of b){const{id:y}=g,w=p.get(y);if(w){const j=ii(w),C=x.reduce((k,E,_)=>k+si(j[_],E),0),N=Number((C/4).toFixed(4));f.push({id:y,data:{droppableContainer:g,value:N}})}}return f.sort(ai)})({collisionRect:o,droppableRects:r,droppableContainers:c});let u=li(d,"id");if(u===(a==null?void 0:a.id)&&d.length>1&&(u=d[1].id),u!=null){const h=s.get(n.id),m=s.get(u),p=m?r.get(m.id):null,b=m==null?void 0:m.node.current;if(b&&p&&h&&m){const x=rs(b).some((j,C)=>l[C]!==j),f=Ju(h,m),g=(function(j,C){return!hs(j)||!hs(C)||!Ju(j,C)?!1:j.data.current.sortable.index<C.data.current.sortable.index})(h,m),y=x||!f?{x:0,y:0}:{x:g?o.width-p.width:0,y:g?o.height-p.height:0},w={x:p.left,y:p.top};return y.x&&y.y?w:_r(w,y)}}}};function Ju(t,e){return!(!hs(t)||!hs(e))&&t.data.current.sortable.containerId===e.data.current.sortable.containerId}const Nx=()=>{const t=P.c(21),{startupLogsAlert:e}=rg(),{clearStartupLogsAlert:n}=sg(),[o,r]=S.useState(!1),s=e==null?void 0:e.status;let a;t[0]!==n?(a=()=>{n(),r(!0)},t[0]=n,t[1]=a):a=t[1];const l=Ce(a),c=s==="done",d=s==="start"||s==="append";let u,h,m;if(t[2]!==l||t[3]!==c?(u=()=>{let C;return c&&(C=window.setTimeout(()=>l(),5e3)),()=>{C&&window.clearTimeout(C)}},t[2]=l,t[3]=c,t[4]=u):u=t[4],t[5]!==c?(h=[c],t[5]=c,t[6]=h):h=t[6],S.useEffect(u,h),e===null||o)return null;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(ja,{className:"w-5 h-5 inline-block mr-2"}),t[7]=m):m=t[7];const p=d?"Initializing...":"Initialized";let b,x,f,g;t[8]!==p?(b=i.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[m,p]}),t[8]=p,t[9]=b):b=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Vt,{className:"w-5 h-5"}),t[10]=x):x=t[10],t[11]!==l?(f=i.jsx(ye,{variant:"text","data-testid":"remove-startup-logs-button",size:"icon",onClick:l,children:x}),t[11]=l,t[12]=f):f=t[12],t[13]!==b||t[14]!==f?(g=i.jsxs("div",{className:"flex justify-between",children:[b,f]}),t[13]=b,t[14]=f,t[15]=g):g=t[15];const y=e.content||"Starting startup script...";let w,j;return t[16]!==y?(w=i.jsx("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:i.jsx("div",{className:"w-full",children:i.jsx("pre",{className:"bg-muted p-3 rounded text-sm font-mono overflow-auto max-h-64 whitespace-pre-wrap",children:y})})}),t[16]=y,t[17]=w):w=t[17],t[18]!==w||t[19]!==g?(j=i.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] max-w-[600px] z-200 opacity-95",children:i.jsxs(Lo,{kind:"info",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left",children:[g,w]})}),t[18]=w,t[19]=g,t[20]=j):j=t[20],j},Sx=t4("rounded-full shadow-xs-solid border p-[5px] transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 active:shadow-none bg-background",{variants:{variant:{default:"hover:bg-accent hover:text-accent-foreground",stale:"bg-(--yellow-3) hover:bg-(--yellow-4) text-(--yellow-11)",green:"hover:bg-(--grass-2) hover:text-(--grass-11) hover:border-[var(--grass-7)],",disabled:"opacity-50 cursor-not-allowed",danger:"hover:bg-(--red-3) hover:text-(--red-11)"}},defaultVariants:{variant:"default"}}),er=t=>{const e=P.c(18);let n,o,r,s,a,l,c,d;if(e[0]!==t){const{children:h,tooltip:m,disabled:p,variant:b,...x}=t;n=h,c=m;const f=p!==void 0&&p;o=f,r=x,s=g=>{var y;f||((y=x.onClick)==null||y.call(x,g))},a=Fn.preventFocus,l=ue(Sx({variant:b}),x.className),e[0]=t,e[1]=n,e[2]=o,e[3]=r,e[4]=s,e[5]=a,e[6]=l,e[7]=c}else n=e[1],o=e[2],r=e[3],s=e[4],a=e[5],l=e[6],c=e[7];e[8]!==n||e[9]!==o||e[10]!==r||e[11]!==s||e[12]!==a||e[13]!==l?(d=i.jsx("button",{disabled:o,...r,onClick:s,onMouseDown:a,className:l,children:n}),e[8]=n,e[9]=o,e[10]=r,e[11]=s,e[12]=a,e[13]=l,e[14]=d):d=e[14];const u=d;if(c){let h;return e[15]!==u||e[16]!==c?(h=i.jsx(pe,{content:c,side:"top",delayDuration:200,usePortal:!1,children:u}),e[15]=u,e[16]=c,e[17]=h):h=e[17],h}return u},Ex=t=>{const e=P.c(5),{children:n,className:o}=t;let r,s;return e[0]!==o?(r=ue("flex items-center gap-1 bg-background m-[2px] rounded-full",o),e[0]=o,e[1]=r):r=e[1],e[2]!==n||e[3]!==r?(s=i.jsx(kg,{className:r,children:n}),e[2]=n,e[3]=r,e[4]=s):s=e[4],s},_x=t=>{const e=P.c(9),{connectionState:n,status:o}=t,{sendInterrupt:r}=qe(),s=cu(o==="running");let a,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=St("global.interrupt"),e[0]=a):a=e[0],e[1]!==n||e[2]!==s?(l=en(n)||!s,e[1]=n,e[2]=s,e[3]=l):l=e[3];const c=s?r:Bn.NOOP,d=s?"stale":"disabled";let u,h;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Bl,{strokeWidth:1.5}),e[4]=u):u=e[4],e[5]!==l||e[6]!==c||e[7]!==d?(h=i.jsx(er,{tooltip:a,disabled:l,onClick:c,variant:d,"data-testid":"run-button",children:u}),e[5]=l,e[6]=c,e[7]=d,e[8]=h):h=e[8],h},tr=Bt(null),Ix=n1("marimo:ai:includeOtherCells",!0);function Ax(t){const e=new Map;for(const[n,o]of t.entries()){if(o.messages.length===0)continue;const r=n4(o.messages,s=>s.id);e.set(n,{...o,messages:r})}return e}Aa=n1("marimo:ai:chatState:v5",{chats:new Map,activeChatId:null},(vi={toSerializable:t=>({chats:[...Ax(t.chats).entries()],activeChatId:t.activeChatId}),fromSerializable:t=>({chats:new Map(t.chats),activeChatId:t.activeChatId})},{getItem(t,e){try{const n=localStorage.getItem(t);if(!n)return e;const o=JSON.parse(n);return vi.fromSerializable(o)}catch(n){return He.warn(`Error getting ${t} from storage`,n),e}},setItem:(t,e)=>{localStorage.setItem(t,JSON.stringify(vi.toSerializable(e)))},removeItem:t=>{localStorage.removeItem(t)}}));var vi;pg=Bt(t=>{const e=t(Aa);return e.activeChatId?e.chats.get(e.activeChatId):null},(t,e,n)=>{e(Aa,o=>({...o,activeChatId:n}))});let Ku;Ac="packages-install-input",Ku=["%alias","%cd","%clear","%debug","%env","%load","%load_ext","%lsmagic","%matplotlib","%pwd","%who_ls","%system","%%time","%%timeit","%%writefile","%%capture","%%html","%%latex"];let wi;function Tx(){const t=async r=>{const s=Le.get(ra),{saveUserConfig:a}=a1(),l={...s,runtime:{...s.runtime,auto_reload:r}};await a({config:l}).then(()=>Le.set(ra,l))},e=()=>{requestAnimationFrame(()=>{const r=document.getElementById(Ac);r&&r.focus()})},n=[{match:"!pip install",onMatch:()=>{Le.set(sc,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:i.jsxs(i.Fragment,{children:["The package manager sidebar has been opened.",i.jsx("br",{}),"Install packages directly from there instead."]})},{match:"!uv pip install",onMatch:()=>{Le.set(sc,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:i.jsxs(i.Fragment,{children:["The package manager sidebar has been opened.",i.jsx("br",{}),"Install packages directly from there instead."]})},{match:"!uv add",onMatch:()=>{Le.set(sc,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:i.jsxs(i.Fragment,{children:["The package manager sidebar has been opened.",i.jsx("br",{}),"Install packages directly from there instead."]})},{match:"%autoreload 2",onMatch:async()=>{await t("autorun")},title:"Module reload",description:i.jsxs(i.Fragment,{children:["Module reload mode set to ",i.jsx("b",{children:"autorun"})," - module changes will re-run the cells that import them."]})},{match:"%autoreload 1",onMatch:async()=>{await t("lazy")},title:"Module reload",description:i.jsxs(i.Fragment,{children:["Module reload mode set to ",i.jsx("b",{children:"lazy"})," - module changes will mark the cells that import them as stale."]})},{match:"%autoreload 0",onMatch:async()=>{await t("off")},title:"Module reload",description:i.jsx(i.Fragment,{children:"Module reload disabled - module changes will not be detected."})},{match:"!ls",onMatch:()=>{},title:"Listing files",description:i.jsxs(i.Fragment,{children:["Shell commands are not directly supported.",i.jsx("br",{}),"Use ",i.jsx("code",{children:"import subprocess; subprocess.run(['ls'])"})," instead."]})},...Ku.map(r=>({match:r,onMatch:()=>{},title:i.jsx(s1,{className:"inline",children:r}),description:i.jsxs(i.Fragment,{children:["Magic commands are not supported in marimo. Read more about replacements in the"," ",i.jsx("a",{href:"https://docs.marimo.io/guides/coming_from/jupyter/#adapting-to-the-absence-of-magic-commands",target:"_blank",className:"text-link underline cursor-pointer",rel:"noopener noreferrer",children:"documentation"}),"."]})}))],o=new Map(n.map(r=>[r.match,r]));return Se.updateListener.of(r=>{if(r.docChanged){const s=r.state.selection.main,a=r.state.doc,l=a.lineAt(s.head),c=a.sliceString(l.from,s.anchor).trim(),d=o.get(c);d&&(d.onMatch(),wi?wi.upsert({title:d.title,description:d.description}):wi=ze({title:d.title,description:d.description}))}})}const Dx=new Set(["Escape","Alt-`"]);function Mx(){const t=i1.filter(e=>!Dx.has(e.key));return Sn.highest($t.of([...t,{key:"Ctrl-y",run:e=>!!da(e)&&l1(e)},{key:"Ctrl-n",run:e=>!!da(e)&&ua(!0)(e)},{key:"Ctrl-p",run:e=>!!da(e)&&ua(!1)(e)}]))}const ki=tt.define(),ji=tt.define(),Ci=tt.define();function Ge(t,e){if(!t)throw new Error(e)}function ms(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>2147483647||t<-2147483648)throw new Error("invalid int 32: "+t)}function Ni(t){if(typeof t!="number")throw new Error("invalid uint 32: "+typeof t);if(!Number.isInteger(t)||t>4294967295||t<0)throw new Error("invalid uint 32: "+t)}function Yu(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(Number.isFinite(t)&&(t>3402823466385289e23||t<-3402823466385289e23))throw new Error("invalid float 32: "+t)}const Xu=Symbol("@bufbuild/protobuf/enum-type");function Ox(t){const e=t[Xu];return Ge(e,"missing enum type on enum object"),e}function Qu(t,e,n,o){t[Xu]=Zu(e,n.map(r=>({no:r.no,name:r.name,localName:t[r.no]})))}function Zu(t,e,n){const o=Object.create(null),r=Object.create(null),s=[];for(const a of e){const l=eh(a);s.push(l),o[a.name]=l,r[a.no]=l}return{typeName:t,values:s,findName:a=>o[a],findNumber:a=>r[a]}}function Rx(t,e,n){const o={};for(const r of e){const s=eh(r);o[s.localName]=s.no,o[s.no]=s.localName}return Qu(o,t,e),o}function eh(t){return"localName"in t?t:Object.assign(Object.assign({},t),{localName:t.name})}class Xe{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){const o=this.getType().runtime.bin,r=o.makeReadOptions(n);return o.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,n){const o=this.getType(),r=o.runtime.json,s=r.makeReadOptions(n);return r.readMessage(o,e,s,this),this}fromJsonString(e,n){let o;try{o=JSON.parse(e)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(o,n)}toBinary(e){const n=this.getType().runtime.bin,o=n.makeWriteOptions(e),r=o.writerFactory();return n.writeMessage(this,r,o),r.finish()}toJson(e){const n=this.getType().runtime.json,o=n.makeWriteOptions(e);return n.writeMessage(this,o)}toJsonString(e){var n;const o=this.toJson(e);return JSON.stringify(o,null,(n=e==null?void 0:e.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Lx(){let t=0,e=0;for(let o=0;o<28;o+=7){let r=this.buf[this.pos++];if(t|=(127&r)<<o,!(128&r))return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(15&n)<<28,e=(112&n)>>4,!(128&n))return this.assertBounds(),[t,e];for(let o=3;o<=31;o+=7){let r=this.buf[this.pos++];if(e|=(127&r)<<o,!(128&r))return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Si(t,e,n){for(let s=0;s<28;s+=7){const a=t>>>s,l=!(!(a>>>7)&&e==0),c=255&(l?128|a:a);if(n.push(c),!l)return}const o=t>>>28&15|(7&e)<<4,r=!!(e>>3);if(n.push(255&(r?128|o:o)),r){for(let s=3;s<31;s+=7){const a=e>>>s,l=!!(a>>>7),c=255&(l?128|a:a);if(n.push(c),!l)return}n.push(e>>>31&1)}}const fs=4294967296;function th(t){const e=t[0]==="-";e&&(t=t.slice(1));const n=1e6;let o=0,r=0;function s(a,l){const c=Number(t.slice(a,l));r*=n,o=o*n+c,o>=fs&&(r+=o/fs|0,o%=fs)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?oh(o,r):Ei(o,r)}function nh(t,e){if({lo:t,hi:e}=(function(c,d){return{lo:c>>>0,hi:d>>>0}})(t,e),e<=2097151)return String(fs*e+t);const n=16777215&(t>>>24|e<<8),o=e>>16&65535;let r=(16777215&t)+6777216*n+6710656*o,s=n+8147497*o,a=2*o;const l=1e7;return r>=l&&(s+=Math.floor(r/l),r%=l),s>=l&&(a+=Math.floor(s/l),s%=l),a.toString()+rh(s)+rh(r)}function Ei(t,e){return{lo:0|t,hi:0|e}}function oh(t,e){return e=~e,t?t=1+~t:e+=1,Ei(t,e)}const rh=t=>{const e=String(t);return"0000000".slice(e.length)+e};function sh(t,e){if(t>=0){for(;t>127;)e.push(127&t|128),t>>>=7;e.push(t)}else{for(let n=0;n<9;n++)e.push(127&t|128),t>>=7;e.push(1)}}function Fx(){let t=this.buf[this.pos++],e=127&t;if(!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<7,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<14,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<21,!(128&t))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(15&t)<<28;for(let n=5;128&t&&n<10;n++)t=this.buf[this.pos++];if(128&t)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var Bx={};const Ue=(function(){const t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(typeof process!="object"||Bx.BUF_BIGINT_DISABLE!=="1")){const o=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),s=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(l){const c=typeof l=="bigint"?l:BigInt(l);if(c>r||c<o)throw new Error(`int64 invalid: ${l}`);return c},uParse(l){const c=typeof l=="bigint"?l:BigInt(l);if(c>a||c<s)throw new Error(`uint64 invalid: ${l}`);return c},enc(l){return t.setBigInt64(0,this.parse(l),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(l){return t.setBigInt64(0,this.uParse(l),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec:(l,c)=>(t.setInt32(0,l,!0),t.setInt32(4,c,!0),t.getBigInt64(0,!0)),uDec:(l,c)=>(t.setInt32(0,l,!0),t.setInt32(4,c,!0),t.getBigUint64(0,!0))}}const e=o=>Ge(/^-?[0-9]+$/.test(o),`int64 invalid: ${o}`),n=o=>Ge(/^[0-9]+$/.test(o),`uint64 invalid: ${o}`);return{zero:"0",supported:!1,parse:o=>(typeof o!="string"&&(o=o.toString()),e(o),o),uParse:o=>(typeof o!="string"&&(o=o.toString()),n(o),o),enc:o=>(typeof o!="string"&&(o=o.toString()),e(o),th(o)),uEnc:o=>(typeof o!="string"&&(o=o.toString()),n(o),th(o)),dec:(o,r)=>(function(s,a){let l=Ei(s,a);const c=2147483648&l.hi;c&&(l=oh(l.lo,l.hi));const d=nh(l.lo,l.hi);return c?"-"+d:d})(o,r),uDec:(o,r)=>nh(o,r)}})();var J,Tn,Ke;function Dn(t,e,n){if(e===n)return!0;if(t==J.BYTES){if(!(e instanceof Uint8Array&&n instanceof Uint8Array)||e.length!==n.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==n[o])return!1;return!0}switch(t){case J.UINT64:case J.FIXED64:case J.INT64:case J.SFIXED64:case J.SINT64:return e==n}return!1}function fo(t,e){switch(t){case J.BOOL:return!1;case J.UINT64:case J.FIXED64:case J.INT64:case J.SFIXED64:case J.SINT64:return e==0?Ue.zero:"0";case J.DOUBLE:case J.FLOAT:return 0;case J.BYTES:return new Uint8Array(0);case J.STRING:return"";default:return 0}}function ah(t,e){switch(t){case J.BOOL:return e===!1;case J.STRING:return e==="";case J.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(J||(J={})),(function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING"})(Tn||(Tn={})),(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(Ke||(Ke={}));class Px{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let n=new Uint8Array(e),o=0;for(let r=0;r<this.chunks.length;r++)n.set(this.chunks[r],o),o+=this.chunks[r].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Ni(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return ms(e),sh(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){Yu(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){Ni(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){ms(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return ms(e),sh(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let n=new Uint8Array(8),o=new DataView(n.buffer),r=Ue.enc(e);return o.setInt32(0,r.lo,!0),o.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),o=new DataView(n.buffer),r=Ue.uEnc(e);return o.setInt32(0,r.lo,!0),o.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=Ue.enc(e);return Si(n.lo,n.hi,this.buf),this}sint64(e){let n=Ue.enc(e),o=n.hi>>31;return Si(n.lo<<1^o,(n.hi<<1|n.lo>>>31)^o,this.buf),this}uint64(e){let n=Ue.uEnc(e);return Si(n.lo,n.hi,this.buf),this}}class zx{constructor(e,n){this.varint64=Lx,this.uint32=Fx,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n??new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,o=7&e;if(n<=0||o<0||o>5)throw new Error("illegal tag: field no "+n+" wire type "+o);return[n,o]}skip(e,n){let o=this.pos;switch(e){case Ke.Varint:for(;128&this.buf[this.pos++];);break;case Ke.Bit64:this.pos+=4;case Ke.Bit32:this.pos+=4;break;case Ke.LengthDelimited:let r=this.uint32();this.pos+=r;break;case Ke.StartGroup:for(;;){const[s,a]=this.tag();if(a===Ke.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(a,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(o,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return Ue.dec(...this.varint64())}uint64(){return Ue.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),o=-(1&e);return e=(e>>>1|(1&n)<<31)^o,n=n>>>1^o,Ue.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Ue.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Ue.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}}function ih(t){const e=t.field.localName,n=Object.create(null);return n[e]=(function(o){const r=o.field;if(r.repeated)return[];if(r.default!==void 0)return r.default;switch(r.kind){case"enum":return r.T.values[0].no;case"scalar":return fo(r.T,r.L);case"message":const s=r.T,a=new s;return s.fieldWrapper?s.fieldWrapper.unwrapField(a):a;case"map":throw"map fields are not allowed to be extensions"}})(t),[n,()=>n[e]]}let on="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),ps=[];for(let t=0;t<on.length;t++)ps[on[t].charCodeAt(0)]=t;ps[45]=on.indexOf("+"),ps[95]=on.indexOf("/");const gs={dec(t){let e=3*t.length/4;t[t.length-2]=="="?e-=2:t[t.length-1]=="="&&(e-=1);let n,o=new Uint8Array(e),r=0,s=0,a=0;for(let l=0;l<t.length;l++){if(n=ps[t.charCodeAt(l)],n===void 0)switch(t[l]){case"=":s=0;case`
104
- `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(s){case 0:a=n,s=1;break;case 1:o[r++]=a<<2|(48&n)>>4,a=n,s=2;break;case 2:o[r++]=(15&a)<<4|(60&n)>>2,a=n,s=3;break;case 3:o[r++]=(3&a)<<6|n,s=0}}if(s==1)throw Error("invalid base64 string.");return o.subarray(0,r)},enc(t){let e,n="",o=0,r=0;for(let s=0;s<t.length;s++)switch(e=t[s],o){case 0:n+=on[e>>2],r=(3&e)<<4,o=1;break;case 1:n+=on[r|e>>4],r=(15&e)<<2,o=2;break;case 2:n+=on[r|e>>6],n+=on[63&e],o=0}return o&&(n+=on[r],n+="=",o==1&&(n+="=")),n}};function Ux(t,e,n){ch(e,t);const o=e.runtime.bin.makeReadOptions(n),r=(function(l,c){if(!c.repeated&&(c.kind=="enum"||c.kind=="scalar")){for(let d=l.length-1;d>=0;--d)if(l[d].no==c.no)return[l[d]];return[]}return l.filter(d=>d.no===c.no)})(t.getType().runtime.bin.listUnknownFields(t),e.field),[s,a]=ih(e);for(const l of r)e.runtime.bin.readField(s,o.readerFactory(l.data),e.field,l.wireType,o);return a()}function Wx(t,e,n,o){ch(e,t);const r=e.runtime.bin.makeReadOptions(o),s=e.runtime.bin.makeWriteOptions(o);if(lh(t,e)){const d=t.getType().runtime.bin.listUnknownFields(t).filter(u=>u.no!=e.field.no);t.getType().runtime.bin.discardUnknownFields(t);for(const u of d)t.getType().runtime.bin.onUnknownField(t,u.no,u.wireType,u.data)}const a=s.writerFactory();let l=e.field;l.opt||l.repeated||l.kind!="enum"&&l.kind!="scalar"||(l=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(l,n,a,s);const c=r.readerFactory(a.finish());for(;c.pos<c.len;){const[d,u]=c.tag(),h=c.skip(u,d);t.getType().runtime.bin.onUnknownField(t,d,u,h)}}function lh(t,e){const n=t.getType();return e.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(t).find(o=>o.no==e.field.no)}function ch(t,e){Ge(t.extendee.typeName==e.getType().typeName,`extension ${t.typeName} can only be applied to message ${t.extendee.typeName}`)}function dh(t,e){const n=t.localName;if(t.repeated)return e[n].length>0;if(t.oneof)return e[t.oneof.localName].case===n;switch(t.kind){case"enum":case"scalar":return t.opt||t.req?e[n]!==void 0:t.kind=="enum"?e[n]!==t.T.values[0].no:!ah(t.T,e[n]);case"message":return e[n]!==void 0;case"map":return Object.keys(e[n]).length>0}}function uh(t,e){const n=t.localName,o=!t.opt&&!t.req;if(t.repeated)e[n]=[];else if(t.oneof)e[t.oneof.localName]={case:void 0};else switch(t.kind){case"map":e[n]={};break;case"enum":e[n]=o?t.T.values[0].no:void 0;break;case"scalar":e[n]=o?fo(t.T,t.L):void 0;break;case"message":e[n]=void 0}}function rn(t,e){if(t===null||typeof t!="object"||!Object.getOwnPropertyNames(Xe.prototype).every(o=>o in t&&typeof t[o]=="function"))return!1;const n=t.getType();return n!==null&&typeof n=="function"&&"typeName"in n&&typeof n.typeName=="string"&&(e===void 0||n.typeName==e.typeName)}function hh(t,e){return rn(e)||!t.fieldWrapper?e:t.fieldWrapper.wrapField(e)}J.DOUBLE,J.FLOAT,J.INT64,J.UINT64,J.INT32,J.UINT32,J.BOOL,J.STRING,J.BYTES;const mh={ignoreUnknownFields:!1},fh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function $x(t){return t?Object.assign(Object.assign({},mh),t):mh}function Vx(t){return t?Object.assign(Object.assign({},fh),t):fh}const bs=Symbol(),xs=Symbol();function qt(t){if(t===null)return"null";switch(typeof t){case"object":return Array.isArray(t)?"array":"object";case"string":return t.length>100?"string":`"${t.split('"').join('\\"')}"`;default:return String(t)}}function ph(t,e,n,o,r){let s=n.localName;if(n.repeated){if(Ge(n.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${qt(e)}`);const a=t[s];for(const l of e){if(l===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${qt(l)}`);switch(n.kind){case"message":a.push(n.T.fromJson(l,o));break;case"enum":const c=_i(n.T,l,o.ignoreUnknownFields,!0);c!==xs&&a.push(c);break;case"scalar":try{a.push(nr(n.T,l,n.L,!0))}catch(d){let u=`cannot decode field ${r.typeName}.${n.name} from JSON: ${qt(l)}`;throw d instanceof Error&&d.message.length>0&&(u+=`: ${d.message}`),new Error(u)}}}}else if(n.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${qt(e)}`);const a=t[s];for(const[l,c]of Object.entries(e)){if(c===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let d;try{d=Gx(n.K,l)}catch(u){let h=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${qt(e)}`;throw u instanceof Error&&u.message.length>0&&(h+=`: ${u.message}`),new Error(h)}switch(n.V.kind){case"message":a[d]=n.V.T.fromJson(c,o);break;case"enum":const u=_i(n.V.T,c,o.ignoreUnknownFields,!0);u!==xs&&(a[d]=u);break;case"scalar":try{a[d]=nr(n.V.T,c,Tn.BIGINT,!0)}catch(h){let m=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${qt(e)}`;throw h instanceof Error&&h.message.length>0&&(m+=`: ${h.message}`),new Error(m)}}}}else switch(n.oneof&&(t=t[n.oneof.localName]={case:s},s="value"),n.kind){case"message":const a=n.T;if(e===null&&a.typeName!="google.protobuf.Value")return;let l=t[s];rn(l)?l.fromJson(e,o):(t[s]=l=a.fromJson(e,o),a.fieldWrapper&&!n.oneof&&(t[s]=a.fieldWrapper.unwrapField(l)));break;case"enum":const c=_i(n.T,e,o.ignoreUnknownFields,!1);switch(c){case bs:uh(n,t);break;case xs:break;default:t[s]=c}break;case"scalar":try{const d=nr(n.T,e,n.L,!1);d===bs?uh(n,t):t[s]=d}catch(d){let u=`cannot decode field ${r.typeName}.${n.name} from JSON: ${qt(e)}`;throw d instanceof Error&&d.message.length>0&&(u+=`: ${d.message}`),new Error(u)}}}function Gx(t,e){if(t===J.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1}return nr(t,e,Tn.BIGINT,!0).toString()}function nr(t,e,n,o){if(e===null)return o?fo(t,n):bs;switch(t){case J.DOUBLE:case J.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return t==J.FLOAT&&Yu(r),r;case J.INT32:case J.FIXED32:case J.SFIXED32:case J.SINT32:case J.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return t==J.UINT32||t==J.FIXED32?Ni(s):ms(s),s;case J.INT64:case J.SFIXED64:case J.SINT64:if(typeof e!="number"&&typeof e!="string")break;const a=Ue.parse(e);return n?a.toString():a;case J.FIXED64:case J.UINT64:if(typeof e!="number"&&typeof e!="string")break;const l=Ue.uParse(e);return n?l.toString():l;case J.BOOL:if(typeof e!="boolean")break;return e;case J.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case J.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return gs.dec(e)}throw new Error}function _i(t,e,n,o){if(e===null)return t.typeName=="google.protobuf.NullValue"?0:o?t.values[0].no:bs;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const r=t.findName(e);if(r!==void 0)return r.no;if(n)return xs}throw new Error(`cannot decode enum ${t.typeName} from JSON: ${qt(e)}`)}function qx(t){return!(!t.repeated&&t.kind!="map")||!t.oneof&&t.kind!="message"&&!t.opt&&!t.req}function gh(t,e,n){if(t.kind=="map"){Ge(typeof e=="object"&&e!=null);const o={},r=Object.entries(e);switch(t.V.kind){case"scalar":for(const[a,l]of r)o[a.toString()]=ys(t.V.T,l);break;case"message":for(const[a,l]of r)o[a.toString()]=l.toJson(n);break;case"enum":const s=t.V.T;for(const[a,l]of r)o[a.toString()]=Ii(s,l,n.enumAsInteger)}return n.emitDefaultValues||r.length>0?o:void 0}if(t.repeated){Ge(Array.isArray(e));const o=[];switch(t.kind){case"scalar":for(let r=0;r<e.length;r++)o.push(ys(t.T,e[r]));break;case"enum":for(let r=0;r<e.length;r++)o.push(Ii(t.T,e[r],n.enumAsInteger));break;case"message":for(let r=0;r<e.length;r++)o.push(e[r].toJson(n))}return n.emitDefaultValues||o.length>0?o:void 0}switch(t.kind){case"scalar":return ys(t.T,e);case"enum":return Ii(t.T,e,n.enumAsInteger);case"message":return hh(t.T,e).toJson(n)}}function Ii(t,e,n){var o;if(Ge(typeof e=="number"),t.typeName=="google.protobuf.NullValue")return null;if(n)return e;const r=t.findNumber(e);return(o=r==null?void 0:r.name)!==null&&o!==void 0?o:e}function ys(t,e){switch(t){case J.INT32:case J.SFIXED32:case J.SINT32:case J.FIXED32:case J.UINT32:return Ge(typeof e=="number"),e;case J.FLOAT:case J.DOUBLE:return Ge(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case J.STRING:return Ge(typeof e=="string"),e;case J.BOOL:return Ge(typeof e=="boolean"),e;case J.UINT64:case J.FIXED64:case J.INT64:case J.SFIXED64:case J.SINT64:return Ge(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case J.BYTES:return Ge(e instanceof Uint8Array),gs.enc(e)}}const po=Symbol("@bufbuild/protobuf/unknown-fields"),bh={readUnknownFields:!0,readerFactory:t=>new zx(t)},xh={writeUnknownFields:!0,writerFactory:()=>new Px};function Hx(t){return t?Object.assign(Object.assign({},bh),t):bh}function Jx(t){return t?Object.assign(Object.assign({},xh),t):xh}function yh(t,e,n,o,r){let{repeated:s,localName:a}=n;switch(n.oneof&&((t=t[n.oneof.localName]).case!=a&&delete t.value,t.case=a,a="value"),n.kind){case"scalar":case"enum":const l=n.kind=="enum"?J.INT32:n.T;let c=ws;if(n.kind=="scalar"&&n.L>0&&(c=Kx),s){let m=t[a];if(o==Ke.LengthDelimited&&l!=J.STRING&&l!=J.BYTES){let p=e.uint32()+e.pos;for(;e.pos<p;)m.push(c(e,l))}else m.push(c(e,l))}else t[a]=c(e,l);break;case"message":const d=n.T;s?t[a].push(vs(e,new d,r,n)):rn(t[a])?vs(e,t[a],r,n):(t[a]=vs(e,new d,r,n),!d.fieldWrapper||n.oneof||n.repeated||(t[a]=d.fieldWrapper.unwrapField(t[a])));break;case"map":let[u,h]=(function(m,p,b){const x=p.uint32(),f=p.pos+x;let g,y;for(;p.pos<f;){const[w]=p.tag();switch(w){case 1:g=ws(p,m.K);break;case 2:switch(m.V.kind){case"scalar":y=ws(p,m.V.T);break;case"enum":y=p.int32();break;case"message":y=vs(p,new m.V.T,b,void 0)}}}if(g===void 0&&(g=fo(m.K,Tn.BIGINT)),typeof g!="string"&&typeof g!="number"&&(g=g.toString()),y===void 0)switch(m.V.kind){case"scalar":y=fo(m.V.T,Tn.BIGINT);break;case"enum":y=m.V.T.values[0].no;break;case"message":y=new m.V.T}return[g,y]})(n,e,r);t[a][u]=h}}function vs(t,e,n,o){const r=e.getType().runtime.bin,s=o==null?void 0:o.delimited;return r.readMessage(e,t,s?o.no:t.uint32(),n,s),e}function Kx(t,e){const n=ws(t,e);return typeof n=="bigint"?n.toString():n}function ws(t,e){switch(e){case J.STRING:return t.string();case J.BOOL:return t.bool();case J.DOUBLE:return t.double();case J.FLOAT:return t.float();case J.INT32:return t.int32();case J.INT64:return t.int64();case J.UINT64:return t.uint64();case J.FIXED64:return t.fixed64();case J.BYTES:return t.bytes();case J.FIXED32:return t.fixed32();case J.SFIXED32:return t.sfixed32();case J.SFIXED64:return t.sfixed64();case J.SINT64:return t.sint64();case J.UINT32:return t.uint32();case J.SINT32:return t.sint32()}}function vh(t,e,n,o){Ge(e!==void 0);const r=t.repeated;switch(t.kind){case"scalar":case"enum":let s=t.kind=="enum"?J.INT32:t.T;if(r)if(Ge(Array.isArray(e)),t.packed)(function(a,l,c,d){if(!d.length)return;a.tag(c,Ke.LengthDelimited).fork();let[,u]=kh(l);for(let h=0;h<d.length;h++)a[u](d[h]);a.join()})(n,s,t.no,e);else for(const a of e)or(n,s,t.no,a);else or(n,s,t.no,e);break;case"message":if(r){Ge(Array.isArray(e));for(const a of e)wh(n,o,t,a)}else wh(n,o,t,e);break;case"map":Ge(typeof e=="object"&&e!=null);for(const[a,l]of Object.entries(e))Yx(n,o,t,a,l)}}function Yx(t,e,n,o,r){t.tag(n.no,Ke.LengthDelimited),t.fork();let s=o;switch(n.K){case J.INT32:case J.FIXED32:case J.UINT32:case J.SFIXED32:case J.SINT32:s=Number.parseInt(o);break;case J.BOOL:Ge(o=="true"||o=="false"),s=o=="true"}switch(or(t,n.K,1,s),n.V.kind){case"scalar":or(t,n.V.T,2,r);break;case"enum":or(t,J.INT32,2,r);break;case"message":Ge(r!==void 0),t.tag(2,Ke.LengthDelimited).bytes(r.toBinary(e))}t.join()}function wh(t,e,n,o){const r=hh(n.T,o);n.delimited?t.tag(n.no,Ke.StartGroup).raw(r.toBinary(e)).tag(n.no,Ke.EndGroup):t.tag(n.no,Ke.LengthDelimited).bytes(r.toBinary(e))}function or(t,e,n,o){Ge(o!==void 0);let[r,s]=kh(e);t.tag(n,r)[s](o)}function kh(t){let e=Ke.Varint;switch(t){case J.BYTES:case J.STRING:e=Ke.LengthDelimited;break;case J.DOUBLE:case J.FIXED64:case J.SFIXED64:e=Ke.Bit64;break;case J.FIXED32:case J.SFIXED32:case J.FLOAT:e=Ke.Bit32}return[e,J[t].toLowerCase()]}function ks(t){if(t===void 0)return t;if(rn(t))return t.clone();if(t instanceof Uint8Array){const e=new Uint8Array(t.byteLength);return e.set(t),e}return t}function rr(t){return t instanceof Uint8Array?t:new Uint8Array(t)}class Xx{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){const n={};for(const o of this.list())n[o.jsonName]=n[o.name]=o;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){const n={};for(const o of this.list())n[o.no]=o;this.numbers=n}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,n)=>e.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let n;for(const o of this.list())o.oneof?o.oneof!==n&&(n=o.oneof,e.push(n)):e.push(o)}return this.members}}function jh(t,e){const n=Ch(t);return e?n:n2(t2(n))}const Qx=Ch;function Ch(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){let r=t.charAt(o);switch(r){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(r),e=!1;break;default:e&&(e=!1,r=r.toUpperCase()),n.push(r)}}return n.join("")}const Zx=new Set(["constructor","toString","toJSON","valueOf"]),e2=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Nh=t=>`${t}$`,t2=t=>e2.has(t)?Nh(t):t,n2=t=>Zx.has(t)?Nh(t):t;class o2{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=jh(e,!1)}addField(e){Ge(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let n=0;n<this.fields.length;n++)this._lookup[this.fields[n].localName]=this.fields[n]}return this._lookup[e]}}const Z=(Sh=t=>new Xx(t,e=>(function(n){var o,r,s,a,l,c;const d=[];let u;for(const h of typeof n=="function"?n():n){const m=h;if(m.localName=jh(h.name,h.oneof!==void 0),m.jsonName=(o=h.jsonName)!==null&&o!==void 0?o:Qx(h.name),m.repeated=(r=h.repeated)!==null&&r!==void 0&&r,h.kind=="scalar"&&(m.L=(s=h.L)!==null&&s!==void 0?s:Tn.BIGINT),m.delimited=(a=h.delimited)!==null&&a!==void 0&&a,m.req=(l=h.req)!==null&&l!==void 0&&l,m.opt=(c=h.opt)!==null&&c!==void 0&&c,h.packed===void 0&&(m.packed=h.kind=="enum"||h.kind=="scalar"&&h.T!=J.BYTES&&h.T!=J.STRING),h.oneof!==void 0){const p=typeof h.oneof=="string"?h.oneof:h.oneof.name;u&&u.name==p||(u=new o2(p)),m.oneof=u,u.addField(m)}d.push(m)}return d})(e)),Eh=t=>{for(const e of t.getType().fields.byMember()){if(e.opt)continue;const n=e.localName,o=t;if(e.repeated)o[n]=[];else switch(e.kind){case"oneof":o[n]={case:void 0};break;case"enum":o[n]=0;break;case"map":o[n]={};break;case"scalar":o[n]=fo(e.T,e.L)}}},{syntax:"proto3",json:{makeReadOptions:$x,makeWriteOptions:Vx,readMessage(t,e,n,o){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${t.typeName} from JSON: ${qt(e)}`);o=o??new t;const r=new Map,s=n.typeRegistry;for(const[a,l]of Object.entries(e)){const c=t.fields.findJsonName(a);if(c){if(c.oneof){if(l===null&&c.kind=="scalar")continue;const d=r.get(c.oneof);if(d!==void 0)throw new Error(`cannot decode message ${t.typeName} from JSON: multiple keys for oneof "${c.oneof.name}" present: "${d}", "${a}"`);r.set(c.oneof,a)}ph(o,l,c,n,t)}else{let d=!1;if(s!=null&&s.findExtension&&a.startsWith("[")&&a.endsWith("]")){const u=s.findExtension(a.substring(1,a.length-1));if(u&&u.extendee.typeName==t.typeName){d=!0;const[h,m]=ih(u);ph(h,l,u.field,n,u),Wx(o,u,m(),n)}}if(!d&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${t.typeName} from JSON: key "${a}" is unknown`)}}return o},writeMessage(t,e){const n=t.getType(),o={};let r;try{for(r of n.fields.byNumber()){if(!dh(r,t)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!qx(r))continue}const a=gh(r,r.oneof?t[r.oneof.localName].value:t[r.localName],e);a!==void 0&&(o[e.useProtoFieldName?r.name:r.jsonName]=a)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const a of n.runtime.bin.listUnknownFields(t)){const l=s.findExtensionFor(n.typeName,a.no);if(l&&lh(t,l)){const c=Ux(t,l,e),d=gh(l.field,c,e);d!==void 0&&(o[l.field.jsonName]=d)}}}catch(s){const a=r?`cannot encode field ${n.typeName}.${r.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,l=s instanceof Error?s.message:String(s);throw new Error(a+(l.length>0?`: ${l}`:""))}return o},readScalar:(t,e,n)=>nr(t,e,n??Tn.BIGINT,!0),writeScalar(t,e,n){if(e!==void 0)return n||ah(t,e)?ys(t,e):void 0},debug:qt},bin:{makeReadOptions:Hx,makeWriteOptions:Jx,listUnknownFields(t){var e;return(e=t[po])!==null&&e!==void 0?e:[]},discardUnknownFields(t){delete t[po]},writeUnknownFields(t,e){const n=t[po];if(n)for(const o of n)e.tag(o.no,o.wireType).raw(o.data)},onUnknownField(t,e,n,o){const r=t;Array.isArray(r[po])||(r[po]=[]),r[po].push({no:e,wireType:n,data:o})},readMessage(t,e,n,o,r){const s=t.getType(),a=r?e.len:e.pos+n;let l,c;for(;e.pos<a&&([l,c]=e.tag(),r!==!0||c!=Ke.EndGroup);){const d=s.fields.find(l);if(!d){const u=e.skip(c,l);o.readUnknownFields&&this.onUnknownField(t,l,c,u);continue}yh(t,e,d,c,o)}if(r&&(c!=Ke.EndGroup||l!==n))throw new Error("invalid end group tag")},readField:yh,writeMessage(t,e,n){const o=t.getType();for(const r of o.fields.byNumber())if(dh(r,t))vh(r,r.oneof?t[r.oneof.localName].value:t[r.localName],e,n);else if(r.req)throw new Error(`cannot encode field ${o.typeName}.${r.name} to binary: required field not set`);return n.writeUnknownFields&&this.writeUnknownFields(t,e),e},writeField(t,e,n,o){e!==void 0&&vh(t,e,n,o)}},util:Object.assign(Object.assign({},{setEnumType:Qu,initPartial(t,e){if(t===void 0)return;const n=e.getType();for(const o of n.fields.byMember()){const r=o.localName,s=e,a=t;if(a[r]!=null)switch(o.kind){case"oneof":const l=a[r].case;if(l===void 0)continue;const c=o.findField(l);let d=a[r].value;c&&c.kind=="message"&&!rn(d,c.T)?d=new c.T(d):c&&c.kind==="scalar"&&c.T===J.BYTES&&(d=rr(d)),s[r]={case:l,value:d};break;case"scalar":case"enum":let u=a[r];o.T===J.BYTES&&(u=o.repeated?u.map(rr):rr(u)),s[r]=u;break;case"map":switch(o.V.kind){case"scalar":case"enum":if(o.V.T===J.BYTES)for(const[p,b]of Object.entries(a[r]))s[r][p]=rr(b);else Object.assign(s[r],a[r]);break;case"message":const m=o.V.T;for(const p of Object.keys(a[r])){let b=a[r][p];m.fieldWrapper||(b=new m(b)),s[r][p]=b}}break;case"message":const h=o.T;if(o.repeated)s[r]=a[r].map(m=>rn(m,h)?m:new h(m));else{const m=a[r];h.fieldWrapper?h.typeName==="google.protobuf.BytesValue"?s[r]=rr(m):s[r]=m:s[r]=rn(m,h)?m:new h(m)}}}},equals:(t,e,n)=>e===n||!(!e||!n)&&t.fields.byMember().every(o=>{const r=e[o.localName],s=n[o.localName];if(o.repeated){if(r.length!==s.length)return!1;switch(o.kind){case"message":return r.every((a,l)=>o.T.equals(a,s[l]));case"scalar":return r.every((a,l)=>Dn(o.T,a,s[l]));case"enum":return r.every((a,l)=>Dn(J.INT32,a,s[l]))}throw new Error(`repeated cannot contain ${o.kind}`)}switch(o.kind){case"message":let a=r,l=s;return o.T.fieldWrapper&&(a===void 0||rn(a)||(a=o.T.fieldWrapper.wrapField(a)),l===void 0||rn(l)||(l=o.T.fieldWrapper.wrapField(l))),o.T.equals(a,l);case"enum":return Dn(J.INT32,r,s);case"scalar":return Dn(o.T,r,s);case"oneof":if(r.case!==s.case)return!1;const c=o.findField(r.case);if(c===void 0)return!0;switch(c.kind){case"message":return c.T.equals(r.value,s.value);case"enum":return Dn(J.INT32,r.value,s.value);case"scalar":return Dn(c.T,r.value,s.value)}throw new Error(`oneof cannot contain ${c.kind}`);case"map":const d=Object.keys(r).concat(Object.keys(s));switch(o.V.kind){case"message":const u=o.V.T;return d.every(m=>u.equals(r[m],s[m]));case"enum":return d.every(m=>Dn(J.INT32,r[m],s[m]));case"scalar":const h=o.V.T;return d.every(m=>Dn(h,r[m],s[m]))}}}),clone(t){const e=t.getType(),n=new e,o=n;for(const r of e.fields.byMember()){const s=t[r.localName];let a;if(r.repeated)a=s.map(ks);else if(r.kind=="map"){a=o[r.localName];for(const[l,c]of Object.entries(s))a[l]=ks(c)}else a=r.kind=="oneof"?r.findField(s.case)?{case:s.case,value:ks(s.value)}:{case:void 0}:ks(s);o[r.localName]=a}for(const r of e.runtime.bin.listUnknownFields(t))e.runtime.bin.onUnknownField(o,r.no,r.wireType,r.data);return n}}),{newFieldList:Sh,initFields:Eh}),makeMessageType(t,e,n){return(function(o,r,s,a){var l;const c=(l=a==null?void 0:a.localName)!==null&&l!==void 0?l:r.substring(r.lastIndexOf(".")+1),d={[c]:function(u){o.util.initFields(this),o.util.initPartial(u,this)}}[c];return Object.setPrototypeOf(d.prototype,new Xe),Object.assign(d,{runtime:o,typeName:r,fields:o.util.newFieldList(s),fromBinary:(u,h)=>new d().fromBinary(u,h),fromJson:(u,h)=>new d().fromJson(u,h),fromJsonString:(u,h)=>new d().fromJsonString(u,h),equals:(u,h)=>o.util.equals(d,u,h)}),d})(this,t,e,n)},makeEnum:Rx,makeEnumType:Zu,getEnumType:Ox,makeExtension(t,e,n){return(function(o,r,s,a){let l;return{typeName:r,extendee:s,get field(){if(!l){const c=typeof a=="function"?a():a;c.name=r.split(".").pop(),c.jsonName=`[${r}]`,l=o.util.newFieldList([c]).list()[0]}return l},runtime:o}})(this,t,e,n)}});var Sh,Eh,It,Ai,js,sr,Cs,ar,Mn;(function(t){t[t.Unary=0]="Unary",t[t.ServerStreaming=1]="ServerStreaming",t[t.ClientStreaming=2]="ClientStreaming",t[t.BiDiStreaming=3]="BiDiStreaming"})(It||(It={})),(function(t){t[t.NoSideEffects=1]="NoSideEffects",t[t.Idempotent=2]="Idempotent"})(Ai||(Ai={})),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.JUPYTER_FORMAT=77]="JUPYTER_FORMAT"})(js||(js={})),Z.util.setEnumType(js,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]),(function(t){t[t.CODEIUM=0]="CODEIUM"})(sr||(sr={})),Z.util.setEnumType(sr,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",t[t.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",t[t.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",t[t.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION"})(Cs||(Cs={})),Z.util.setEnumType(Cs,"exa.codeium_common_pb.EventType",[{no:0,name:"EVENT_TYPE_UNSPECIFIED"},{no:1,name:"EVENT_TYPE_ENABLE_CODEIUM"},{no:2,name:"EVENT_TYPE_DISABLE_CODEIUM"},{no:3,name:"EVENT_TYPE_SHOW_PREVIOUS_COMPLETION"},{no:4,name:"EVENT_TYPE_SHOW_NEXT_COMPLETION"}]),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",t[t.CACHE=2]="CACHE",t[t.NETWORK=3]="NETWORK"})(ar||(ar={})),Z.util.setEnumType(ar,"exa.codeium_common_pb.CompletionSource",[{no:0,name:"COMPLETION_SOURCE_UNSPECIFIED"},{no:1,name:"COMPLETION_SOURCE_TYPING_AS_SUGGESTED"},{no:2,name:"COMPLETION_SOURCE_CACHE"},{no:3,name:"COMPLETION_SOURCE_NETWORK"}]),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.C=1]="C",t[t.CLOJURE=2]="CLOJURE",t[t.COFFEESCRIPT=3]="COFFEESCRIPT",t[t.CPP=4]="CPP",t[t.CSHARP=5]="CSHARP",t[t.CSS=6]="CSS",t[t.CUDACPP=7]="CUDACPP",t[t.DOCKERFILE=8]="DOCKERFILE",t[t.GO=9]="GO",t[t.GROOVY=10]="GROOVY",t[t.HANDLEBARS=11]="HANDLEBARS",t[t.HASKELL=12]="HASKELL",t[t.HCL=13]="HCL",t[t.HTML=14]="HTML",t[t.INI=15]="INI",t[t.JAVA=16]="JAVA",t[t.JAVASCRIPT=17]="JAVASCRIPT",t[t.JSON=18]="JSON",t[t.JULIA=19]="JULIA",t[t.KOTLIN=20]="KOTLIN",t[t.LATEX=21]="LATEX",t[t.LESS=22]="LESS",t[t.LUA=23]="LUA",t[t.MAKEFILE=24]="MAKEFILE",t[t.MARKDOWN=25]="MARKDOWN",t[t.OBJECTIVEC=26]="OBJECTIVEC",t[t.OBJECTIVECPP=27]="OBJECTIVECPP",t[t.PERL=28]="PERL",t[t.PHP=29]="PHP",t[t.PLAINTEXT=30]="PLAINTEXT",t[t.PROTOBUF=31]="PROTOBUF",t[t.PBTXT=32]="PBTXT",t[t.PYTHON=33]="PYTHON",t[t.R=34]="R",t[t.RUBY=35]="RUBY",t[t.RUST=36]="RUST",t[t.SASS=37]="SASS",t[t.SCALA=38]="SCALA",t[t.SCSS=39]="SCSS",t[t.SHELL=40]="SHELL",t[t.SQL=41]="SQL",t[t.STARLARK=42]="STARLARK",t[t.SWIFT=43]="SWIFT",t[t.TSX=44]="TSX",t[t.TYPESCRIPT=45]="TYPESCRIPT",t[t.VISUALBASIC=46]="VISUALBASIC",t[t.VUE=47]="VUE",t[t.XML=48]="XML",t[t.XSL=49]="XSL",t[t.YAML=50]="YAML",t[t.SVELTE=51]="SVELTE",t[t.TOML=52]="TOML",t[t.DART=53]="DART",t[t.RST=54]="RST",t[t.OCAML=55]="OCAML",t[t.CMAKE=56]="CMAKE",t[t.PASCAL=57]="PASCAL",t[t.ELIXIR=58]="ELIXIR",t[t.FSHARP=59]="FSHARP",t[t.LISP=60]="LISP",t[t.MATLAB=61]="MATLAB",t[t.POWERSHELL=62]="POWERSHELL",t[t.SOLIDITY=63]="SOLIDITY",t[t.ADA=64]="ADA",t[t.OCAML_INTERFACE=65]="OCAML_INTERFACE"})(Mn||(Mn={})),Z.util.setEnumType(Mn,"exa.codeium_common_pb.Language",[{no:0,name:"LANGUAGE_UNSPECIFIED"},{no:1,name:"LANGUAGE_C"},{no:2,name:"LANGUAGE_CLOJURE"},{no:3,name:"LANGUAGE_COFFEESCRIPT"},{no:4,name:"LANGUAGE_CPP"},{no:5,name:"LANGUAGE_CSHARP"},{no:6,name:"LANGUAGE_CSS"},{no:7,name:"LANGUAGE_CUDACPP"},{no:8,name:"LANGUAGE_DOCKERFILE"},{no:9,name:"LANGUAGE_GO"},{no:10,name:"LANGUAGE_GROOVY"},{no:11,name:"LANGUAGE_HANDLEBARS"},{no:12,name:"LANGUAGE_HASKELL"},{no:13,name:"LANGUAGE_HCL"},{no:14,name:"LANGUAGE_HTML"},{no:15,name:"LANGUAGE_INI"},{no:16,name:"LANGUAGE_JAVA"},{no:17,name:"LANGUAGE_JAVASCRIPT"},{no:18,name:"LANGUAGE_JSON"},{no:19,name:"LANGUAGE_JULIA"},{no:20,name:"LANGUAGE_KOTLIN"},{no:21,name:"LANGUAGE_LATEX"},{no:22,name:"LANGUAGE_LESS"},{no:23,name:"LANGUAGE_LUA"},{no:24,name:"LANGUAGE_MAKEFILE"},{no:25,name:"LANGUAGE_MARKDOWN"},{no:26,name:"LANGUAGE_OBJECTIVEC"},{no:27,name:"LANGUAGE_OBJECTIVECPP"},{no:28,name:"LANGUAGE_PERL"},{no:29,name:"LANGUAGE_PHP"},{no:30,name:"LANGUAGE_PLAINTEXT"},{no:31,name:"LANGUAGE_PROTOBUF"},{no:32,name:"LANGUAGE_PBTXT"},{no:33,name:"LANGUAGE_PYTHON"},{no:34,name:"LANGUAGE_R"},{no:35,name:"LANGUAGE_RUBY"},{no:36,name:"LANGUAGE_RUST"},{no:37,name:"LANGUAGE_SASS"},{no:38,name:"LANGUAGE_SCALA"},{no:39,name:"LANGUAGE_SCSS"},{no:40,name:"LANGUAGE_SHELL"},{no:41,name:"LANGUAGE_SQL"},{no:42,name:"LANGUAGE_STARLARK"},{no:43,name:"LANGUAGE_SWIFT"},{no:44,name:"LANGUAGE_TSX"},{no:45,name:"LANGUAGE_TYPESCRIPT"},{no:46,name:"LANGUAGE_VISUALBASIC"},{no:47,name:"LANGUAGE_VUE"},{no:48,name:"LANGUAGE_XML"},{no:49,name:"LANGUAGE_XSL"},{no:50,name:"LANGUAGE_YAML"},{no:51,name:"LANGUAGE_SVELTE"},{no:52,name:"LANGUAGE_TOML"},{no:53,name:"LANGUAGE_DART"},{no:54,name:"LANGUAGE_RST"},{no:55,name:"LANGUAGE_OCAML"},{no:56,name:"LANGUAGE_CMAKE"},{no:57,name:"LANGUAGE_PASCAL"},{no:58,name:"LANGUAGE_ELIXIR"},{no:59,name:"LANGUAGE_FSHARP"},{no:60,name:"LANGUAGE_LISP"},{no:61,name:"LANGUAGE_MATLAB"},{no:62,name:"LANGUAGE_POWERSHELL"},{no:63,name:"LANGUAGE_SOLIDITY"},{no:64,name:"LANGUAGE_ADA"},{no:65,name:"LANGUAGE_OCAML_INTERFACE"}]);const an=class an extends Xe{constructor(n){super();B(this,"completionId","");B(this,"text","");B(this,"prefix","");B(this,"stop","");B(this,"score",0);B(this,"tokens",[]);B(this,"decodedTokens",[]);B(this,"probabilities",[]);B(this,"adjustedProbabilities",[]);B(this,"generatedLength",Ue.zero);Z.util.initPartial(n,this)}static fromBinary(n,o){return new an().fromBinary(n,o)}static fromJson(n,o){return new an().fromJson(n,o)}static fromJsonString(n,o){return new an().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(an,n,o)}};B(an,"runtime",Z),B(an,"typeName","exa.codeium_common_pb.Completion"),B(an,"fields",Z.util.newFieldList(()=>[{no:1,name:"completion_id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"prefix",kind:"scalar",T:9},{no:4,name:"stop",kind:"scalar",T:9},{no:5,name:"score",kind:"scalar",T:1},{no:6,name:"tokens",kind:"scalar",T:4,repeated:!0},{no:7,name:"decoded_tokens",kind:"scalar",T:9,repeated:!0},{no:8,name:"probabilities",kind:"scalar",T:1,repeated:!0},{no:9,name:"adjusted_probabilities",kind:"scalar",T:1,repeated:!0},{no:10,name:"generated_length",kind:"scalar",T:4}]));let Ti=an;const ln=class ln extends Xe{constructor(n){super();B(this,"ideName","");B(this,"ideVersion","");B(this,"extensionName","");B(this,"extensionVersion","");B(this,"apiKey","");B(this,"locale","");B(this,"sessionId","");B(this,"requestId",Ue.zero);B(this,"userAgent","");B(this,"url","");B(this,"authSource",sr.CODEIUM);Z.util.initPartial(n,this)}static fromBinary(n,o){return new ln().fromBinary(n,o)}static fromJson(n,o){return new ln().fromJson(n,o)}static fromJsonString(n,o){return new ln().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(ln,n,o)}};B(ln,"runtime",Z),B(ln,"typeName","exa.codeium_common_pb.Metadata"),B(ln,"fields",Z.util.newFieldList(()=>[{no:1,name:"ide_name",kind:"scalar",T:9},{no:7,name:"ide_version",kind:"scalar",T:9},{no:12,name:"extension_name",kind:"scalar",T:9},{no:2,name:"extension_version",kind:"scalar",T:9},{no:3,name:"api_key",kind:"scalar",T:9},{no:4,name:"locale",kind:"scalar",T:9},{no:10,name:"session_id",kind:"scalar",T:9},{no:9,name:"request_id",kind:"scalar",T:4},{no:13,name:"user_agent",kind:"scalar",T:9},{no:14,name:"url",kind:"scalar",T:9},{no:15,name:"auth_source",kind:"enum",T:Z.getEnumType(sr)}]));let Ns=ln;const cn=class cn extends Xe{constructor(n){super();B(this,"tabSize",Ue.zero);B(this,"insertSpaces",!1);Z.util.initPartial(n,this)}static fromBinary(n,o){return new cn().fromBinary(n,o)}static fromJson(n,o){return new cn().fromJson(n,o)}static fromJsonString(n,o){return new cn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(cn,n,o)}};B(cn,"runtime",Z),B(cn,"typeName","exa.codeium_common_pb.EditorOptions"),B(cn,"fields",Z.util.newFieldList(()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}]));let Di=cn;Z.util.newFieldList(()=>[{no:1,name:"event_type",kind:"enum",T:Z.getEnumType(Cs)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}]);class r2 extends So{constructor(n,o){super();B(this,"index");B(this,"total");this.index=n,this.total=o}toDOM(){const n=document.createElement("span");n.setAttribute("aria-hidden","true"),n.className="cm-codeium-cycle";const o=n.appendChild(document.createElement("span"));o.className="cm-codeium-cycle-explanation",o.innerText=`${this.index+1}/${this.total}`;const r=n.appendChild(document.createElement("button"));return r.className="cm-codeium-cycle-key",r.innerText="\u2192 (Ctrl ])",r.dataset.action="codeium-cycle",n}ignoreEvent(){return!1}}const Ss=ro.define({combine:t=>qs(t,{language:Mn.TYPESCRIPT,timeout:150,widgetClass:r2,alwaysOn:!0},{})}),_h=ro.define({combine:t=>qs(t,{override:()=>[]},{})}),s2=Te.mark({class:"cm-ghostText"}),Qn=Dt.define({create:t=>null,update(t,e){var o;const n=e.state.facet(Ss);for(const r of e.effects){if(r.is(ki)){const{changeSpecs:s,index:a}=r.value,l=s[a].map(d=>s2.range(d.absoluteStartPos,d.absoluteEndPos)),c=(o=l.at(-1))==null?void 0:o.to;return{index:a,decorations:Te.set([...l,...c!==void 0&&s.length>1&&n.widgetClass?[Te.widget({widget:new n.widgetClass(a,s.length),side:1}).range(c)]:[]]),changeSpecs:s,reverseChangeSet:r.value.reverseChangeSet}}if(r.is(ji)||r.is(Ci))return null}return t&&{...t,decorations:t.decorations.map(e.changes),reverseChangeSet:t.reverseChangeSet.map(e.changes)}},provide:t=>Se.decorations.from(t,e=>(e==null?void 0:e.decorations)||Te.none)}),go=ac.define(),Es=ac.define();var Pe;function Mi(t){const e=Pe[t];return typeof e!="string"?t.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,n=>"_"+n.toLowerCase())}let _s;(function(t){t[t.Canceled=1]="Canceled",t[t.Unknown=2]="Unknown",t[t.InvalidArgument=3]="InvalidArgument",t[t.DeadlineExceeded=4]="DeadlineExceeded",t[t.NotFound=5]="NotFound",t[t.AlreadyExists=6]="AlreadyExists",t[t.PermissionDenied=7]="PermissionDenied",t[t.ResourceExhausted=8]="ResourceExhausted",t[t.FailedPrecondition=9]="FailedPrecondition",t[t.Aborted=10]="Aborted",t[t.OutOfRange=11]="OutOfRange",t[t.Unimplemented=12]="Unimplemented",t[t.Internal=13]="Internal",t[t.Unavailable=14]="Unavailable",t[t.DataLoss=15]="DataLoss",t[t.Unauthenticated=16]="Unauthenticated"})(Pe||(Pe={}));class Qe extends Error{constructor(e,n=Pe.Unknown,o,r,s){super((function(a,l){return a.length?`[${Mi(l)}] ${a}`:`[${Mi(l)}]`})(e,n)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=n,this.metadata=new Headers(o??{}),this.details=r??[],this.cause=s}static from(e,n=Pe.Unknown){return e instanceof Qe?e:e instanceof Error?e.name=="AbortError"?new Qe(e.message,Pe.Canceled):new Qe(e.message,n,void 0,void 0,e):new Qe(String(e),n,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error&&(Object.getPrototypeOf(e)===Qe.prototype||e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e)}findDetails(e){const n="typeName"in e?{findMessage:r=>r===e.typeName?e:void 0}:e,o=[];for(const r of this.details){if("getType"in r){n.findMessage(r.getType().typeName)&&o.push(r);continue}const s=n.findMessage(r.type);if(s)try{o.push(s.fromBinary(r.value))}catch{}}return o}}var a2=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(r){e[r]=t[r]&&function(s){return new Promise(function(a,l){(function(c,d,u,h){Promise.resolve(h).then(function(m){c({value:m,done:u})},d)})(a,l,(s=t[r](s)).done,s.value)})}}},ir=function(t){return this instanceof ir?(this.v=t,this):new ir(t)},i2=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},a("next"),a("throw"),a("return",function(h){return function(m){return Promise.resolve(m).then(h,d)}}),o[Symbol.asyncIterator]=function(){return this},o;function a(h,m){r[h]&&(o[h]=function(p){return new Promise(function(b,x){s.push([h,p,b,x])>1||l(h,p)})},m&&(o[h]=m(o[h])))}function l(h,m){try{(p=r[h](m)).value instanceof ir?Promise.resolve(p.value.v).then(c,d):u(s[0][2],p)}catch(b){u(s[0][3],b)}var p}function c(h){l("next",h)}function d(h){l("throw",h)}function u(h,m){h(m),s.shift(),s.length&&l(s[0][0],s[0][1])}},l2=function(t){var e,n;return e={},o("next"),o("throw",function(r){throw r}),o("return"),e[Symbol.iterator]=function(){return this},e;function o(r,s){e[r]=t[r]?function(a){return(n=!n)?{value:ir(t[r](a)),done:!1}:s?s(a):a}:s}},Ih=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(r){e[r]=t[r]&&function(s){return new Promise(function(a,l){(function(c,d,u,h){Promise.resolve(h).then(function(m){c({value:m,done:u})},d)})(a,l,(s=t[r](s)).done,s.value)})}}},bo=function(t){return this instanceof bo?(this.v=t,this):new bo(t)},c2=function(t){var e,n;return e={},o("next"),o("throw",function(r){throw r}),o("return"),e[Symbol.iterator]=function(){return this},e;function o(r,s){e[r]=t[r]?function(a){return(n=!n)?{value:bo(t[r](a)),done:!1}:s?s(a):a}:s}},d2=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},a("next"),a("throw"),a("return",function(h){return function(m){return Promise.resolve(m).then(h,d)}}),o[Symbol.asyncIterator]=function(){return this},o;function a(h,m){r[h]&&(o[h]=function(p){return new Promise(function(b,x){s.push([h,p,b,x])>1||l(h,p)})},m&&(o[h]=m(o[h])))}function l(h,m){try{(p=r[h](m)).value instanceof bo?Promise.resolve(p.value.v).then(c,d):u(s[0][2],p)}catch(b){u(s[0][3],b)}var p}function c(h){l("next",h)}function d(h){l("throw",h)}function u(h,m){h(m),s.shift(),s.length&&l(s[0][0],s[0][1])}};function u2(t,e){return(function(n,o){const r={};for(const[s,a]of Object.entries(n.methods)){const l=o(Object.assign(Object.assign({},a),{localName:s,service:n}));l!=null&&(r[s]=l)}return r})(t,n=>{switch(n.kind){case It.Unary:return(function(o,r,s){return async function(a,l){var c,d;const u=await o.unary(r,s,l==null?void 0:l.signal,l==null?void 0:l.timeoutMs,l==null?void 0:l.headers,a,l==null?void 0:l.contextValues);return(c=l==null?void 0:l.onHeader)===null||c===void 0||c.call(l,u.header),(d=l==null?void 0:l.onTrailer)===null||d===void 0||d.call(l,u.trailer),u.message}})(e,t,n);case It.ServerStreaming:return(function(o,r,s){return function(a,l){return Ah(o.stream(r,s,l==null?void 0:l.signal,l==null?void 0:l.timeoutMs,l==null?void 0:l.headers,(function(c){return i2(this,arguments,function*(){yield ir(yield*l2(a2(c)))})})([a]),l==null?void 0:l.contextValues),l)}})(e,t,n);case It.ClientStreaming:return(function(o,r,s){return async function(a,l){var c,d,u,h,m,p;const b=await o.stream(r,s,l==null?void 0:l.signal,l==null?void 0:l.timeoutMs,l==null?void 0:l.headers,a,l==null?void 0:l.contextValues);let x;(m=l==null?void 0:l.onHeader)===null||m===void 0||m.call(l,b.header);let f=0;try{for(var g,y=!0,w=Ih(b.message);!(c=(g=await w.next()).done);y=!0)h=g.value,y=!1,x=h,f++}catch(j){d={error:j}}finally{try{y||c||!(u=w.return)||await u.call(w)}finally{if(d)throw d.error}}if(!x)throw new Qe("protocol error: missing response message",Pe.Unimplemented);if(f>1)throw new Qe("protocol error: received extra messages for client streaming method",Pe.Unimplemented);return(p=l==null?void 0:l.onTrailer)===null||p===void 0||p.call(l,b.trailer),x}})(e,t,n);case It.BiDiStreaming:return(function(o,r,s){return function(a,l){return Ah(o.stream(r,s,l==null?void 0:l.signal,l==null?void 0:l.timeoutMs,l==null?void 0:l.headers,a,l==null?void 0:l.contextValues),l)}})(e,t,n);default:return null}})}function Ah(t,e){const n=(function(){return d2(this,arguments,function*(){var o,r;const s=yield bo(t);(o=e==null?void 0:e.onHeader)===null||o===void 0||o.call(e,s.header),yield bo(yield*c2(Ih(s.message))),(r=e==null?void 0:e.onTrailer)===null||r===void 0||r.call(e,s.trailer)})})()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function Th(t){if(!t.aborted)return;if(t.reason!==void 0)return t.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function Dh(){return{get(t){return t.id in this?this[t.id]:t.defaultValue},set(t,e){return this[t.id]=e,this},delete(t){return delete this[t.id],this}}}function Mh(t,e,n){const o=typeof e=="string"?e:e.typeName,r=typeof n=="string"?n:n.name;return t.toString().replace(/\/?$/,`/${o}/${r}`)}function Oh(t,e){return e instanceof t?e:new t(e)}function h2(t,e){function n(o){return o.done===!0?o:{done:o.done,value:Oh(t,o.value)}}return{[Symbol.asyncIterator](){const o=e[Symbol.asyncIterator](),r={next:()=>o.next().then(n)};return o.throw!==void 0&&(r.throw=s=>o.throw(s).then(n)),o.return!==void 0&&(r.return=s=>o.return(s).then(n)),r}}}function Rh(t,e){var n;return(n=e==null?void 0:e.concat().reverse().reduce((o,r)=>r(o),t))!==null&&n!==void 0?n:t}function Lh(t){var e;const n=Object.assign({},t);return(e=n.ignoreUnknownFields)!==null&&e!==void 0||(n.ignoreUnknownFields=!0),n}function Fh(t,e,n,o){const r=e?Bh(t.I,o):Ph(t.I,n);return{parse:(e?Bh(t.O,o):Ph(t.O,n)).parse,serialize:r.serialize}}function Bh(t,e){return{parse(n){try{return t.fromBinary(n,e)}catch(o){const r=o instanceof Error?o.message:String(o);throw new Qe(`parse binary: ${r}`,Pe.Internal)}},serialize(n){try{return n.toBinary(e)}catch(o){const r=o instanceof Error?o.message:String(o);throw new Qe(`serialize binary: ${r}`,Pe.Internal)}}}}function Ph(t,e){var n,o;const r=(n=e==null?void 0:e.textEncoder)!==null&&n!==void 0?n:new TextEncoder,s=(o=e==null?void 0:e.textDecoder)!==null&&o!==void 0?o:new TextDecoder,a=Lh(e);return{parse(l){try{const c=s.decode(l);return t.fromJsonString(c,a)}catch(c){throw Qe.from(c,Pe.InvalidArgument)}},serialize(l){try{const c=l.toJsonString(a);return r.encode(c)}catch(c){throw Qe.from(c,Pe.Internal)}}}}const m2=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function zh(t,e,n){var o;if(e&&new Headers(e).forEach((l,c)=>n.metadata.append(c,l)),typeof t!="object"||t==null||Array.isArray(t))throw n;let r=n.code;"code"in t&&typeof t.code=="string"&&(r=(o=(function(l){if(!_s){_s={};for(const c of Object.values(Pe))typeof c!="string"&&(_s[Mi(c)]=c)}return _s[l]})(t.code))!==null&&o!==void 0?o:r);const s=t.message;if(s!=null&&typeof s!="string")throw n;const a=new Qe(s??"",r,e);if("details"in t&&Array.isArray(t.details))for(const l of t.details){if(l===null||typeof l!="object"||Array.isArray(l)||typeof l.type!="string"||typeof l.value!="string")throw n;try{a.details.push({type:l.type,value:gs.dec(l.value),debug:l.debug})}catch{throw n}}return a}function f2(t){const e=new Qe("invalid end stream",Pe.Unknown);let n;try{n=JSON.parse(typeof t=="string"?t:new TextDecoder().decode(t))}catch{throw e}if(typeof n!="object"||n==null||Array.isArray(n))throw e;const o=new Headers;if("metadata"in n){if(typeof n.metadata!="object"||n.metadata==null||Array.isArray(n.metadata))throw e;for(const[r,s]of Object.entries(n.metadata)){if(!Array.isArray(s)||s.some(a=>typeof a!="string"))throw e;for(const a of s)o.append(r,a)}}return{metadata:o,error:"error"in n&&n.error!=null?zh(n.error,o,e):void 0}}const Is="Content-Type",p2="Content-Length",Uh="Content-Encoding",g2="Accept-Encoding",Wh="Connect-Protocol-Version";function $h(t){const e=new Headers,n=new Headers;return t.forEach((o,r)=>{r.toLowerCase().startsWith("trailer-")?n.append(r.substring(8),o):e.append(r,o)}),[e,n]}function Vh(t,e,n,o,r){const s=new Headers(o??{});return n!==void 0&&s.set("Connect-Timeout-Ms",`${n}`),s.set(Is,t==It.Unary?e?"application/proto":"application/json":e?"application/connect+proto":"application/connect+json"),s.set(Wh,"1"),s}function Gh(t,e,n,o){const r=o.get(Is),s=(function(c){const d=c==null?void 0:c.match(m2);if(d)return{stream:!!d[1],binary:!!d[3]}})(r);if(n!==200){const c=new Qe(`HTTP ${n}`,(function(d){switch(d){case 400:return Pe.Internal;case 401:return Pe.Unauthenticated;case 403:return Pe.PermissionDenied;case 404:return Pe.Unimplemented;case 429:case 502:case 503:case 504:return Pe.Unavailable;default:return Pe.Unknown}})(n),o);if(t==It.Unary&&s&&!s.binary)return{isUnaryError:!0,unaryError:c};throw c}const a=e,l=t!==It.Unary;if((s==null?void 0:s.binary)!==a||s.stream!==l)throw new Qe(`unsupported content type ${r}`,s===void 0?Pe.Unknown:Pe.Internal,o);return{isUnaryError:!1}}const b2="application/";function x2(t,e,n){let o="?connect=v1";const r=t.header.get(Is);(r==null?void 0:r.indexOf(b2))===0&&(o+="&encoding="+encodeURIComponent(r.slice(12)));const s=t.header.get(Uh);s!==null&&s!=="identity"&&(o+="&compression="+encodeURIComponent(s),n=!0),n&&(o+="&base64=1"),o+="&message="+(function(c,d){return d?gs.enc(c).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent(new TextDecoder().decode(c))})(e,n);const a=t.url+o,l=new Headers(t.header);return[Wh,Is,p2,Uh,g2].forEach(c=>l.delete(c)),Object.assign(Object.assign({},t),{init:Object.assign(Object.assign({},t.init),{method:"GET"}),url:a,header:l})}function qh(t){const{signal:e,cleanup:n}=(function(r){const s=new AbortController,a=()=>{s.abort(new Qe("the operation timed out",Pe.DeadlineExceeded))};let l;return r!==void 0&&(r<=0?a():l=setTimeout(a,r)),{signal:s.signal,cleanup:()=>clearTimeout(l)}})(t.timeoutMs),o=(function(...r){const s=new AbortController,a=r.filter(c=>c!==void 0).concat(s.signal);for(const c of a){if(c.aborted){l.apply(c);break}c.addEventListener("abort",l)}function l(){s.signal.aborted||s.abort(Th(this));for(const c of a)c.removeEventListener("abort",l)}return s})(t.signal,e);return[o.signal,function(r){const s=Qe.from(e.aborted?Th(e):r);return o.abort(s),n(),Promise.reject(s)},function(){n(),o.abort()}]}var lr,Oi,cr;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.INACTIVE=1]="INACTIVE",t[t.PROCESSING=2]="PROCESSING",t[t.SUCCESS=3]="SUCCESS",t[t.WARNING=4]="WARNING",t[t.ERROR=5]="ERROR"})(lr||(lr={})),Z.util.setEnumType(lr,"exa.language_server_pb.CodeiumState",[{no:0,name:"CODEIUM_STATE_UNSPECIFIED"},{no:1,name:"CODEIUM_STATE_INACTIVE"},{no:2,name:"CODEIUM_STATE_PROCESSING"},{no:3,name:"CODEIUM_STATE_SUCCESS"},{no:4,name:"CODEIUM_STATE_WARNING"},{no:5,name:"CODEIUM_STATE_ERROR"}]),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SINGLE=1]="SINGLE",t[t.MULTI=2]="MULTI"})(Oi||(Oi={})),Z.util.setEnumType(Oi,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.INLINE=1]="INLINE",t[t.BLOCK=2]="BLOCK",t[t.INLINE_MASK=3]="INLINE_MASK"})(cr||(cr={})),Z.util.setEnumType(cr,"exa.language_server_pb.CompletionPartType",[{no:0,name:"COMPLETION_PART_TYPE_UNSPECIFIED"},{no:1,name:"COMPLETION_PART_TYPE_INLINE"},{no:2,name:"COMPLETION_PART_TYPE_BLOCK"},{no:3,name:"COMPLETION_PART_TYPE_INLINE_MASK"}]);const dn=class dn extends Xe{constructor(n){super();B(this,"threshold",0);Z.util.initPartial(n,this)}static fromBinary(n,o){return new dn().fromBinary(n,o)}static fromJson(n,o){return new dn().fromJson(n,o)}static fromJsonString(n,o){return new dn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(dn,n,o)}};B(dn,"runtime",Z),B(dn,"typeName","exa.language_server_pb.MultilineConfig"),B(dn,"fields",Z.util.newFieldList(()=>[{no:1,name:"threshold",kind:"scalar",T:2}]));let Ri=dn;const un=class un extends Xe{constructor(n){super();B(this,"metadata");B(this,"document");B(this,"editorOptions");B(this,"otherDocuments",[]);B(this,"experimentConfig");B(this,"modelName","");B(this,"multilineConfig");Z.util.initPartial(n,this)}static fromBinary(n,o){return new un().fromBinary(n,o)}static fromJson(n,o){return new un().fromJson(n,o)}static fromJsonString(n,o){return new un().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(un,n,o)}};B(un,"runtime",Z),B(un,"typeName","exa.language_server_pb.GetCompletionsRequest"),B(un,"fields",Z.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:Ns},{no:2,name:"document",kind:"message",T:As},{no:3,name:"editor_options",kind:"message",T:Di},{no:5,name:"other_documents",kind:"message",T:As,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:Wi},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:Ri}]));let Li=un;const hn=class hn extends Xe{constructor(n){super();B(this,"state");B(this,"completionItems",[]);Z.util.initPartial(n,this)}static fromBinary(n,o){return new hn().fromBinary(n,o)}static fromJson(n,o){return new hn().fromJson(n,o)}static fromJsonString(n,o){return new hn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(hn,n,o)}};B(hn,"runtime",Z),B(hn,"typeName","exa.language_server_pb.GetCompletionsResponse"),B(hn,"fields",Z.util.newFieldList(()=>[{no:1,name:"state",kind:"message",T:$i},{no:2,name:"completion_items",kind:"message",T:Hi,repeated:!0}]));let Fi=hn;const mn=class mn extends Xe{constructor(n){super();B(this,"metadata");B(this,"completionId","");Z.util.initPartial(n,this)}static fromBinary(n,o){return new mn().fromBinary(n,o)}static fromJson(n,o){return new mn().fromJson(n,o)}static fromJsonString(n,o){return new mn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(mn,n,o)}};B(mn,"runtime",Z),B(mn,"typeName","exa.language_server_pb.AcceptCompletionRequest"),B(mn,"fields",Z.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:Ns},{no:2,name:"completion_id",kind:"scalar",T:9}]));let Bi=mn;const fn=class fn extends Xe{constructor(e){super(),Z.util.initPartial(e,this)}static fromBinary(e,n){return new fn().fromBinary(e,n)}static fromJson(e,n){return new fn().fromJson(e,n)}static fromJsonString(e,n){return new fn().fromJsonString(e,n)}static equals(e,n){return Z.util.equals(fn,e,n)}};B(fn,"runtime",Z),B(fn,"typeName","exa.language_server_pb.AcceptCompletionResponse"),B(fn,"fields",Z.util.newFieldList(()=>[]));let Pi=fn;const pn=class pn extends Xe{constructor(e){super(),Z.util.initPartial(e,this)}static fromBinary(e,n){return new pn().fromBinary(e,n)}static fromJson(e,n){return new pn().fromJson(e,n)}static fromJsonString(e,n){return new pn().fromJsonString(e,n)}static equals(e,n){return Z.util.equals(pn,e,n)}};B(pn,"runtime",Z),B(pn,"typeName","exa.language_server_pb.GetAuthTokenRequest"),B(pn,"fields",Z.util.newFieldList(()=>[]));let zi=pn;const gn=class gn extends Xe{constructor(n){super();B(this,"authToken","");B(this,"uuid","");Z.util.initPartial(n,this)}static fromBinary(n,o){return new gn().fromBinary(n,o)}static fromJson(n,o){return new gn().fromJson(n,o)}static fromJsonString(n,o){return new gn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(gn,n,o)}};B(gn,"runtime",Z),B(gn,"typeName","exa.language_server_pb.GetAuthTokenResponse"),B(gn,"fields",Z.util.newFieldList(()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}]));let Ui=gn;const bn=class bn extends Xe{constructor(n){super();B(this,"row",Ue.zero);B(this,"col",Ue.zero);Z.util.initPartial(n,this)}static fromBinary(n,o){return new bn().fromBinary(n,o)}static fromJson(n,o){return new bn().fromJson(n,o)}static fromJsonString(n,o){return new bn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(bn,n,o)}};B(bn,"runtime",Z),B(bn,"typeName","exa.language_server_pb.DocumentPosition"),B(bn,"fields",Z.util.newFieldList(()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}]));let dr=bn;const xn=class xn extends Xe{constructor(n){super();B(this,"absolutePath","");B(this,"relativePath","");B(this,"text","");B(this,"editorLanguage","");B(this,"language",Mn.UNSPECIFIED);B(this,"cursorOffset",Ue.zero);B(this,"cursorPosition");B(this,"lineEnding","");Z.util.initPartial(n,this)}static fromBinary(n,o){return new xn().fromBinary(n,o)}static fromJson(n,o){return new xn().fromJson(n,o)}static fromJsonString(n,o){return new xn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(xn,n,o)}};B(xn,"runtime",Z),B(xn,"typeName","exa.language_server_pb.Document"),B(xn,"fields",Z.util.newFieldList(()=>[{no:1,name:"absolute_path",kind:"scalar",T:9},{no:2,name:"relative_path",kind:"scalar",T:9},{no:3,name:"text",kind:"scalar",T:9},{no:4,name:"editor_language",kind:"scalar",T:9},{no:5,name:"language",kind:"enum",T:Z.getEnumType(Mn)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:dr},{no:7,name:"line_ending",kind:"scalar",T:9}]));let As=xn;const yn=class yn extends Xe{constructor(n){super();B(this,"forceEnableExperiments",[]);Z.util.initPartial(n,this)}static fromBinary(n,o){return new yn().fromBinary(n,o)}static fromJson(n,o){return new yn().fromJson(n,o)}static fromJsonString(n,o){return new yn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(yn,n,o)}};B(yn,"runtime",Z),B(yn,"typeName","exa.language_server_pb.ExperimentConfig"),B(yn,"fields",Z.util.newFieldList(()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:Z.getEnumType(js),repeated:!0}]));let Wi=yn;const vn=class vn extends Xe{constructor(n){super();B(this,"state",lr.UNSPECIFIED);B(this,"message","");Z.util.initPartial(n,this)}static fromBinary(n,o){return new vn().fromBinary(n,o)}static fromJson(n,o){return new vn().fromJson(n,o)}static fromJsonString(n,o){return new vn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(vn,n,o)}};B(vn,"runtime",Z),B(vn,"typeName","exa.language_server_pb.State"),B(vn,"fields",Z.util.newFieldList(()=>[{no:1,name:"state",kind:"enum",T:Z.getEnumType(lr)},{no:2,name:"message",kind:"scalar",T:9}]));let $i=vn;const wn=class wn extends Xe{constructor(n){super();B(this,"startOffset",Ue.zero);B(this,"endOffset",Ue.zero);B(this,"startPosition");B(this,"endPosition");Z.util.initPartial(n,this)}static fromBinary(n,o){return new wn().fromBinary(n,o)}static fromJson(n,o){return new wn().fromJson(n,o)}static fromJsonString(n,o){return new wn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(wn,n,o)}};B(wn,"runtime",Z),B(wn,"typeName","exa.language_server_pb.Range"),B(wn,"fields",Z.util.newFieldList(()=>[{no:1,name:"start_offset",kind:"scalar",T:4},{no:2,name:"end_offset",kind:"scalar",T:4},{no:3,name:"start_position",kind:"message",T:dr},{no:4,name:"end_position",kind:"message",T:dr}]));let Vi=wn;const kn=class kn extends Xe{constructor(n){super();B(this,"text","");B(this,"deltaCursorOffset",Ue.zero);Z.util.initPartial(n,this)}static fromBinary(n,o){return new kn().fromBinary(n,o)}static fromJson(n,o){return new kn().fromJson(n,o)}static fromJsonString(n,o){return new kn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(kn,n,o)}};B(kn,"runtime",Z),B(kn,"typeName","exa.language_server_pb.Suffix"),B(kn,"fields",Z.util.newFieldList(()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}]));let Gi=kn;const jn=class jn extends Xe{constructor(n){super();B(this,"text","");B(this,"offset",Ue.zero);B(this,"type",cr.UNSPECIFIED);B(this,"prefix","");B(this,"line",Ue.zero);Z.util.initPartial(n,this)}static fromBinary(n,o){return new jn().fromBinary(n,o)}static fromJson(n,o){return new jn().fromJson(n,o)}static fromJsonString(n,o){return new jn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(jn,n,o)}};B(jn,"runtime",Z),B(jn,"typeName","exa.language_server_pb.CompletionPart"),B(jn,"fields",Z.util.newFieldList(()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"offset",kind:"scalar",T:4},{no:3,name:"type",kind:"enum",T:Z.getEnumType(cr)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}]));let qi=jn;const Cn=class Cn extends Xe{constructor(n){super();B(this,"completion");B(this,"suffix");B(this,"range");B(this,"source",ar.UNSPECIFIED);B(this,"completionParts",[]);Z.util.initPartial(n,this)}static fromBinary(n,o){return new Cn().fromBinary(n,o)}static fromJson(n,o){return new Cn().fromJson(n,o)}static fromJsonString(n,o){return new Cn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(Cn,n,o)}};B(Cn,"runtime",Z),B(Cn,"typeName","exa.language_server_pb.CompletionItem"),B(Cn,"fields",Z.util.newFieldList(()=>[{no:1,name:"completion",kind:"message",T:Ti},{no:5,name:"suffix",kind:"message",T:Gi},{no:2,name:"range",kind:"message",T:Vi},{no:3,name:"source",kind:"enum",T:Z.getEnumType(ar)},{no:8,name:"completion_parts",kind:"message",T:qi,repeated:!0}]));let Hi=Cn;const y2={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:Li,O:Fi,kind:It.Unary},acceptCompletion:{name:"AcceptCompletion",I:Bi,O:Pi,kind:It.Unary},getAuthToken:{name:"GetAuthToken",I:zi,O:Ui,kind:It.Unary}}};var ur=function(t){return this instanceof ur?(this.v=t,this):new ur(t)},v2=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},a("next"),a("throw"),a("return",function(h){return function(m){return Promise.resolve(m).then(h,d)}}),o[Symbol.asyncIterator]=function(){return this},o;function a(h,m){r[h]&&(o[h]=function(p){return new Promise(function(b,x){s.push([h,p,b,x])>1||l(h,p)})},m&&(o[h]=m(o[h])))}function l(h,m){try{(p=r[h](m)).value instanceof ur?Promise.resolve(p.value.v).then(c,d):u(s[0][2],p)}catch(b){u(s[0][3],b)}var p}function c(h){l("next",h)}function d(h){l("throw",h)}function u(h,m){h(m),s.shift(),s.length&&l(s[0][0],s[0][1])}};const w2=(function(t,e){return u2(t,e)})(y2,(function(t){var e;(function(){try{new Headers}catch{throw new Error("connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.")}})();const n=(e=t.useBinaryFormat)!==null&&e!==void 0&&e;return{async unary(o,r,s,a,l,c,d){var u;const{serialize:h,parse:m}=Fh(r,n,t.jsonOptions,t.binaryOptions);return a=a===void 0?t.defaultTimeoutMs:a<=0?void 0:a,await(function(p){const b=Rh(p.next,p.interceptors),[x,f,g]=qh(p);return b(Object.assign(Object.assign({},p.req),{message:Oh(p.req.method.I,p.req.message),signal:x})).then(y=>(g(),y),f)})({interceptors:t.interceptors,signal:s,timeoutMs:a,req:{stream:!1,service:o,method:r,url:Mh(t.baseUrl,o,r),init:{method:"POST",credentials:(u=t.credentials)!==null&&u!==void 0?u:"same-origin",redirect:"error",mode:"cors"},header:Vh(r.kind,n,a,l),contextValues:d??Dh(),message:c},next:async p=>{var b;let x=null;t.useHttpGet===!0&&r.idempotency===Ai.NoSideEffects?p=x2(p,h(p.message),n):x=h(p.message);const f=(b=t.fetch)!==null&&b!==void 0?b:globalThis.fetch,g=await f(p.url,Object.assign(Object.assign({},p.init),{headers:p.header,signal:p.signal,body:x})),{isUnaryError:y,unaryError:w}=Gh(r.kind,n,g.status,g.headers);if(y)throw zh(await g.json(),(function(...N){const k=new Headers;for(const E of N)E.forEach((_,I)=>{k.append(I,_)});return k})(...$h(g.headers)),w);const[j,C]=$h(g.headers);return{stream:!1,service:o,method:r,header:j,message:n?m(new Uint8Array(await g.arrayBuffer())):r.O.fromJson(await g.json(),Lh(t.jsonOptions)),trailer:C}}})},async stream(o,r,s,a,l,c,d){var u;const{serialize:h,parse:m}=Fh(r,n,t.jsonOptions,t.binaryOptions);function p(x,f,g,y){return v2(this,arguments,function*(){const w=(function(C){let N,k=new Uint8Array(0);function E(_){const I=new Uint8Array(k.length+_.length);I.set(k),I.set(_,k.length),k=I}return new ReadableStream({start(){N=C.getReader()},async pull(_){let I;for(;;){if(I===void 0&&k.byteLength>=5){let D=0;for(let M=1;M<5;M++)D=(D<<8)+k[M];I={flags:k[0],length:D}}if(I!==void 0&&k.byteLength>=I.length+5)break;const O=await N.read();if(O.done)break;E(O.value)}if(I===void 0)return k.byteLength==0?void _.close():void _.error(new Qe("premature end of stream",Pe.DataLoss));const A=k.subarray(5,5+I.length);k=k.subarray(5+I.length),_.enqueue({flags:I.flags,data:A})}})})(x).getReader();let j=!1;for(;;){const C=yield ur(w.read());if(C.done)break;const{flags:N,data:k}=C.value;if(!(1&~N))throw new Qe("protocol error: received unsupported compressed output",Pe.Internal);if(!(2&~N)){j=!0;const E=f2(k);if(E.error){const _=E.error;throw g.forEach((I,A)=>{_.metadata.append(A,I)}),_}E.metadata.forEach((_,I)=>f.set(I,_));continue}yield yield ur(m(k))}if("throwIfAborted"in y&&y.throwIfAborted(),!j)throw"missing EndStreamResponse"})}async function b(x){if(r.kind!=It.ServerStreaming)throw"The fetch API does not support streaming request bodies";const f=await x[Symbol.asyncIterator]().next();if(f.done==1)throw"missing request message";return(function(g,y){const w=new Uint8Array(y.length+5);w.set(y,5);const j=new DataView(w.buffer,w.byteOffset,w.byteLength);return j.setUint8(0,g),j.setUint32(1,y.length),w})(0,h(f.value))}return a=a===void 0?t.defaultTimeoutMs:a<=0?void 0:a,await(function(x){const f=Rh(x.next,x.interceptors),[g,y,w]=qh(x),j=Object.assign(Object.assign({},x.req),{message:h2(x.req.method.I,x.req.message),signal:g});let C=!1;return g.addEventListener("abort",function(){var N,k;const E=x.req.message[Symbol.asyncIterator]();C||(N=E.throw)===null||N===void 0||N.call(E,this.reason).catch(()=>{}),(k=E.return)===null||k===void 0||k.call(E).catch(()=>{})}),f(j).then(N=>Object.assign(Object.assign({},N),{message:{[Symbol.asyncIterator](){const k=N.message[Symbol.asyncIterator]();return{next:()=>k.next().then(E=>(E.done==1&&(C=!0,w()),E),y)}}}}),y)})({interceptors:t.interceptors,timeoutMs:a,signal:s,req:{stream:!0,service:o,method:r,url:Mh(t.baseUrl,o,r),init:{method:"POST",credentials:(u=t.credentials)!==null&&u!==void 0?u:"same-origin",redirect:"error",mode:"cors"},header:Vh(r.kind,n,a,l),contextValues:d??Dh(),message:c},next:async x=>{var f;const g=(f=t.fetch)!==null&&f!==void 0?f:globalThis.fetch,y=await g(x.url,Object.assign(Object.assign({},x.init),{headers:x.header,signal:x.signal,body:await b(x.message)}));if(Gh(r.kind,n,y.status,y.headers),y.body===null)throw"missing response body";const w=new Headers;return Object.assign(Object.assign({},x),{header:y.headers,trailer:w,message:p(y.body,w,y.headers,x.signal)})}})}}})({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}));let Ts;try{Ts=crypto.randomUUID()}catch{Ts="10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^(crypto.getRandomValues(new Uint8Array(1))[0]??0)&15>>+t/4).toString(16))}async function k2(t,e){const n=t.state.facet(Ss),{override:o}=t.state.facet(_h),r=await o(),s=t.state,a=s.selection.main.head,l=s.doc.toString();try{const c=await(async function({text:b,cursorOffset:x,config:f,otherDocuments:g}){return await w2.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:f.apiKey,sessionId:Ts,authSource:f.authSource},document:{text:b,cursorOffset:BigInt(x),language:f.language,editorLanguage:"typescript",lineEnding:`
114
+ `},Rb={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function Lb(t){let{announcements:e=Rb,container:n,hiddenTextDescribedById:o,screenReaderInstructions:r=Ob}=t;const{announce:s,announcement:a}=(function(){const[h,m]=S.useState("");return{announce:S.useCallback(p=>{p!=null&&m(p)},[]),announcement:h}})(),l=Nr("DndLiveRegion"),[c,d]=S.useState(!1);if(S.useEffect(()=>{d(!0)},[]),(function(h){const m=S.useContext(fu);S.useEffect(()=>{if(!m)throw new Error("useDndMonitor must be used within a children of <DndContext>");return m(h)},[h,m])})(S.useMemo(()=>({onDragStart(h){let{active:m}=h;s(e.onDragStart({active:m}))},onDragMove(h){let{active:m,over:p}=h;e.onDragMove&&s(e.onDragMove({active:m,over:p}))},onDragOver(h){let{active:m,over:p}=h;s(e.onDragOver({active:m,over:p}))},onDragEnd(h){let{active:m,over:p}=h;s(e.onDragEnd({active:m,over:p}))},onDragCancel(h){let{active:m,over:p}=h;s(e.onDragCancel({active:m,over:p}))}}),[s,e])),!c)return null;const u=he.createElement(he.Fragment,null,he.createElement(Db,{id:o,value:r.draggable}),he.createElement(Mb,{id:l,announcement:a}));return n?_r.createPortal(u,n):u}var rt;function os(){}function pu(t,e){return S.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(rt||(rt={}));const Bt=Object.freeze({x:0,y:0});function ai(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function ii(t,e){let{data:{value:n}}=t,{data:{value:o}}=e;return n-o}function Fb(t,e){let{data:{value:n}}=t,{data:{value:o}}=e;return o-n}function li(t){let{left:e,top:n,height:o,width:r}=t;return[{x:e,y:n},{x:e+r,y:n},{x:e,y:n+o},{x:e+r,y:n+o}]}function ci(t,e){if(!t||t.length===0)return null;const[n]=t;return e?n[e]:n}function gu(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+.5*t.width,y:n+.5*t.height}}const di=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:o}=t;const r=gu(e,e.left,e.top),s=[];for(const a of o){const{id:l}=a,c=n.get(l);if(c){const d=ai(gu(c),r);s.push({id:l,data:{droppableContainer:a,value:d}})}}return s.sort(ii)};function Bb(t,e){const n=Math.max(e.top,t.top),o=Math.max(e.left,t.left),r=Math.min(e.left+e.width,t.left+t.width),s=Math.min(e.top+e.height,t.top+t.height),a=r-o,l=s-n;if(o<r&&n<s){const c=e.width*e.height,d=t.width*t.height,u=a*l;return Number((u/(c+d-u)).toFixed(4))}return 0}const bu=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:o}=t;const r=[];for(const s of o){const{id:a}=s,l=n.get(a);if(l){const c=Bb(l,e);c>0&&r.push({id:a,data:{droppableContainer:s,value:c}})}}return r.sort(Fb)};function Pb(t,e){const{top:n,left:o,bottom:r,right:s}=e;return n<=t.y&&t.y<=r&&o<=t.x&&t.x<=s}function xu(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Bt}function zb(t){return function(e){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return o.reduce((s,a)=>({...s,top:s.top+t*a.y,bottom:s.bottom+t*a.y,left:s.left+t*a.x,right:s.right+t*a.x}),{...e})}}const Ub=zb(1),Wb={ignoreTransform:!1};function mo(t,e){e===void 0&&(e=Wb);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:d,transformOrigin:u}=In(t).getComputedStyle(t);d&&(n=(function(h,m,p){const b=(function(k){if(k.startsWith("matrix3d(")){const E=k.slice(9,-1).split(/, /);return{x:+E[12],y:+E[13],scaleX:+E[0],scaleY:+E[5]}}if(k.startsWith("matrix(")){const E=k.slice(7,-1).split(/, /);return{x:+E[4],y:+E[5],scaleX:+E[0],scaleY:+E[3]}}return null})(m);if(!b)return h;const{scaleX:x,scaleY:f,x:g,y}=b,w=h.left-g-(1-x)*parseFloat(p),j=h.top-y-(1-f)*parseFloat(p.slice(p.indexOf(" ")+1)),C=x?h.width/x:h.width,N=f?h.height/f:h.height;return{width:C,height:N,top:j,right:w+C,bottom:j+N,left:w}})(n,d,u))}const{top:o,left:r,width:s,height:a,bottom:l,right:c}=n;return{top:o,left:r,width:s,height:a,bottom:l,right:c}}function yu(t){return mo(t,{ignoreTransform:!0})}function rs(t,e){const n=[];return t?(function o(r){if(e!=null&&n.length>=e||!r)return n;if(e1(r)&&r.scrollingElement!=null&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!ia(r)||Hk(r)||n.includes(r))return n;const s=In(t).getComputedStyle(r);return r!==t&&(function(a,l){l===void 0&&(l=In(a).getComputedStyle(a));const c=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(d=>{const u=l[d];return typeof u=="string"&&c.test(u)})})(r,s)&&n.push(r),(function(a,l){return l===void 0&&(l=In(a).getComputedStyle(a)),l.position==="fixed"})(r,s)?n:o(r.parentNode)})(t):n}function vu(t){const[e]=rs(t,1);return e??null}function ui(t){return oc&&t?rc(t)?t:Yk(t)?e1(t)||t===Oo(t).scrollingElement?window:ia(t)?t:null:null:null}function wu(t){return rc(t)?t.scrollX:t.scrollLeft}function ku(t){return rc(t)?t.scrollY:t.scrollTop}function hi(t){return{x:wu(t),y:ku(t)}}var at;function ju(t){return!(!oc||!t)&&t===document.scrollingElement}function Cu(t){const e={x:0,y:0},n=ju(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},o={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height};return{isTop:t.scrollTop<=e.y,isLeft:t.scrollLeft<=e.x,isBottom:t.scrollTop>=o.y,isRight:t.scrollLeft>=o.x,maxScroll:o,minScroll:e}}(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(at||(at={}));const $b={x:.2,y:.2};function Vb(t,e,n,o,r){let{top:s,left:a,right:l,bottom:c}=n;o===void 0&&(o=10),r===void 0&&(r=$b);const{isTop:d,isBottom:u,isLeft:h,isRight:m}=Cu(t),p={x:0,y:0},b={x:0,y:0},x=e.height*r.y,f=e.width*r.x;return!d&&s<=e.top+x?(p.y=at.Backward,b.y=o*Math.abs((e.top+x-s)/x)):!u&&c>=e.bottom-x&&(p.y=at.Forward,b.y=o*Math.abs((e.bottom-x-c)/x)),!m&&l>=e.right-f?(p.x=at.Forward,b.x=o*Math.abs((e.right-f-l)/f)):!h&&a<=e.left+f&&(p.x=at.Backward,b.x=o*Math.abs((e.left+f-a)/f)),{direction:p,speed:b}}function Gb(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:a}=window;return{top:0,left:0,right:s,bottom:a,width:s,height:a}}const{top:e,left:n,right:o,bottom:r}=t.getBoundingClientRect();return{top:e,left:n,right:o,bottom:r,width:t.clientWidth,height:t.clientHeight}}function Nu(t){return t.reduce((e,n)=>Ro(e,hi(n)),Bt)}const qb=[["x",["left","right"],function(t){return t.reduce((e,n)=>e+wu(n),0)}],["y",["top","bottom"],function(t){return t.reduce((e,n)=>e+ku(n),0)}]];class mi{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=rs(n),r=Nu(o);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,a,l]of qb)for(const c of a)Object.defineProperty(this,c,{get:()=>{const d=l(o),u=r[s]-d;return this.rect[c]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Yo{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...n)})},this.target=e}add(e,n,o){var r;(r=this.target)==null||r.addEventListener(e,n,o),this.listeners.push([e,n,o])}}function fi(t,e){const n=Math.abs(t.x),o=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+o**2)>e:"x"in e&&"y"in e?n>e.x&&o>e.y:"x"in e?n>e.x:"y"in e&&o>e.y}var Rt,Ae;function Su(t){t.preventDefault()}function Hb(t){t.stopPropagation()}(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Rt||(Rt={})),(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Ae||(Ae={}));const Eu={start:[Ae.Space,Ae.Enter],cancel:[Ae.Esc],end:[Ae.Space,Ae.Enter,Ae.Tab]},Jb=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Ae.Right:return{...n,x:n.x+25};case Ae.Left:return{...n,x:n.x-25};case Ae.Down:return{...n,y:n.y+25};case Ae.Up:return{...n,y:n.y-25}}};class pi{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new Yo(Oo(n)),this.windowListeners=new Yo(In(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,o=e.node.current;o&&(function(r,s){if(s===void 0&&(s=mo),!r)return;const{top:a,left:l,bottom:c,right:d}=s(r);vu(r)&&(c<=0||d<=0||a>=window.innerHeight||l>=window.innerWidth)&&r.scrollIntoView({block:"center",inline:"center"})})(o),n(Bt)}handleKeyDown(e){if(tc(e)){const{active:n,context:o,options:r}=this.props,{keyboardCodes:s=Eu,coordinateGetter:a=Jb,scrollBehavior:l="smooth"}=r,{code:c}=e;if(s.end.includes(c))return void this.handleEnd(e);if(s.cancel.includes(c))return void this.handleCancel(e);const{collisionRect:d}=o.current,u=d?{x:d.left,y:d.top}:Bt;this.referenceCoordinates||(this.referenceCoordinates=u);const h=a(e,{active:n,context:o.current,currentCoordinates:u});if(h){const m=Er(h,u),p={x:0,y:0},{scrollableAncestors:b}=o.current;for(const x of b){const f=e.code,{isTop:g,isRight:y,isLeft:w,isBottom:j,maxScroll:C,minScroll:N}=Cu(x),k=Gb(x),E={x:Math.min(f===Ae.Right?k.right-k.width/2:k.right,Math.max(f===Ae.Right?k.left:k.left+k.width/2,h.x)),y:Math.min(f===Ae.Down?k.bottom-k.height/2:k.bottom,Math.max(f===Ae.Down?k.top:k.top+k.height/2,h.y))},_=f===Ae.Right&&!y||f===Ae.Left&&!w,I=f===Ae.Down&&!j||f===Ae.Up&&!g;if(_&&E.x!==h.x){const A=x.scrollLeft+m.x,O=f===Ae.Right&&A<=C.x||f===Ae.Left&&A>=N.x;if(O&&!m.y)return void x.scrollTo({left:A,behavior:l});p.x=O?x.scrollLeft-A:f===Ae.Right?x.scrollLeft-C.x:x.scrollLeft-N.x,p.x&&x.scrollBy({left:-p.x,behavior:l});break}if(I&&E.y!==h.y){const A=x.scrollTop+m.y,O=f===Ae.Down&&A<=C.y||f===Ae.Up&&A>=N.y;if(O&&!m.x)return void x.scrollTo({top:A,behavior:l});p.y=O?x.scrollTop-A:f===Ae.Down?x.scrollTop-C.y:x.scrollTop-N.y,p.y&&x.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,Ro(Er(h,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:o}=this.props;e.preventDefault(),o(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function _u(t){return!!(t&&"distance"in t)}function Iu(t){return!!(t&&"delay"in t)}pi.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:o=Eu,onActivation:r}=e,{active:s}=n;const{code:a}=t.nativeEvent;if(o.start.includes(a)){const l=s.activatorNode.current;return(!l||t.target===l)&&(t.preventDefault(),r==null||r({event:t.nativeEvent}),!0)}return!1}}];class gi{constructor(e,n,o){var r;o===void 0&&(o=(function(l){const{EventTarget:c}=In(l);return l instanceof c?l:Oo(l)})(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:s}=e,{target:a}=s;this.props=e,this.events=n,this.document=Oo(a),this.documentListeners=new Yo(this.document),this.listeners=new Yo(o),this.windowListeners=new Yo(In(a)),this.initialCoordinates=(r=nc(s))!=null?r:Bt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:o}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.DragStart,Su),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),this.windowListeners.add(Rt.ContextMenu,Su),this.documentListeners.add(Rt.Keydown,this.handleKeydown),n){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Iu(n))return this.timeoutId=setTimeout(this.handleStart,n.delay),void this.handlePending(n);if(_u(n))return void this.handlePending(n)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:o,onPending:r}=this.props;r(o,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(Rt.Click,Hb,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rt.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:o,initialCoordinates:r,props:s}=this,{onMove:a,options:{activationConstraint:l}}=s;if(!r)return;const c=(n=nc(e))!=null?n:Bt,d=Er(r,c);if(!o&&l){if(_u(l)){if(l.tolerance!=null&&fi(d,l.tolerance))return this.handleCancel();if(fi(d,l.distance))return this.handleStart()}return Iu(l)&&fi(d,l.tolerance)?this.handleCancel():void this.handlePending(l,d)}e.cancelable&&e.preventDefault(),a(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Ae.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const Kb={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class bi extends gi{constructor(e){const{event:n}=e,o=Oo(n.target);super(e,Kb,o)}}bi.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;return!(!n.isPrimary||n.button!==0)&&(o==null||o({event:n}),!0)}}];const Yb={move:{name:"mousemove"},end:{name:"mouseup"}};var xi;(function(t){t[t.RightClick=2]="RightClick"})(xi||(xi={})),(class extends gi{constructor(t){super(t,Yb,Oo(t.event.target))}}).activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;return n.button!==xi.RightClick&&(o==null||o({event:n}),!0)}}];const yi={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var Xo,ss;function Xb(t){let{acceleration:e,activator:n=Xo.Pointer,canScroll:o,draggingRect:r,enabled:s,interval:a=5,order:l=ss.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:m}=t;const p=(function(N){let{delta:k,disabled:E}=N;const _=la(k);return Ir(I=>{if(E||!_||!I)return Qb;const A={x:Math.sign(k.x-_.x),y:Math.sign(k.y-_.y)};return{x:{[at.Backward]:I.x[at.Backward]||A.x===-1,[at.Forward]:I.x[at.Forward]||A.x===1},y:{[at.Backward]:I.y[at.Backward]||A.y===-1,[at.Forward]:I.y[at.Forward]||A.y===1}}},[E,k,_])})({delta:h,disabled:!s}),[b,x]=Jk(),f=S.useRef({x:0,y:0}),g=S.useRef({x:0,y:0}),y=S.useMemo(()=>{switch(n){case Xo.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Xo.DraggableRect:return r}},[n,r,c]),w=S.useRef(null),j=S.useCallback(()=>{const N=w.current;if(!N)return;const k=f.current.x*g.current.x,E=f.current.y*g.current.y;N.scrollBy(k,E)},[]),C=S.useMemo(()=>l===ss.TreeOrder?[...d].reverse():d,[l,d]);S.useEffect(()=>{if(s&&d.length&&y){for(const N of C){if((o==null?void 0:o(N))===!1)continue;const k=d.indexOf(N),E=u[k];if(!E)continue;const{direction:_,speed:I}=Vb(N,E,y,e,m);for(const A of["x","y"])p[A][_[A]]||(I[A]=0,_[A]=0);if(I.x>0||I.y>0)return x(),w.current=N,b(j,a),f.current=I,void(g.current=_)}f.current={x:0,y:0},g.current={x:0,y:0},x()}else x()},[e,j,o,x,s,a,JSON.stringify(y),JSON.stringify(p),b,d,C,u,JSON.stringify(m)])}(class extends gi{constructor(t){super(t,yi)}static setup(){return window.addEventListener(yi.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(yi.move.name,t)};function t(){}}}).activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;const{touches:r}=n;return!(r.length>1)&&(o==null||o({event:n}),!0)}}],(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Xo||(Xo={})),(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(ss||(ss={}));const Qb={x:{[at.Backward]:!1,[at.Forward]:!1},y:{[at.Backward]:!1,[at.Forward]:!1}};var Qo,vi;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Qo||(Qo={})),(function(t){t.Optimized="optimized"})(vi||(vi={}));const Au=new Map;function Tu(t,e){return Ir(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function as(t){let{callback:e,disabled:n}=t;const o=Zp(e),r=S.useMemo(()=>{if(n||typeof window>"u"||window.ResizeObserver===void 0)return;const{ResizeObserver:s}=window;return new s(o)},[n]);return S.useEffect(()=>()=>r==null?void 0:r.disconnect(),[r]),r}function Zb(t){return new mi(mo(t),t)}function Du(t,e,n){e===void 0&&(e=Zb);const[o,r]=S.useState(null);function s(){r(c=>{if(!t)return null;var d;if(t.isConnected===!1)return(d=c??n)!=null?d:null;const u=e(t);return JSON.stringify(c)===JSON.stringify(u)?c:u})}const a=(function(c){let{callback:d,disabled:u}=c;const h=Zp(d),m=S.useMemo(()=>{if(u||typeof window>"u"||window.MutationObserver===void 0)return;const{MutationObserver:p}=window;return new p(h)},[h,u]);return S.useEffect(()=>()=>m==null?void 0:m.disconnect(),[m]),m})({callback(c){if(t)for(const d of c){const{type:u,target:h}=d;if(u==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),l=as({callback:s});return Gn(()=>{s(),t?(l==null||l.observe(t),a==null||a.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),a==null||a.disconnect())},[t]),o}const Mu=[];function Ou(t,e){e===void 0&&(e=[]);const n=S.useRef(null);return S.useEffect(()=>{n.current=null},e),S.useEffect(()=>{const o=t!==Bt;o&&!n.current&&(n.current=t),!o&&n.current&&(n.current=null)},[t]),n.current?Er(t,n.current):Bt}function Ru(t){return S.useMemo(()=>t?(function(e){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}})(t):null,[t])}const Lu=[];function ex(t){let{measure:e}=t;const[n,o]=S.useState(null),r=S.useCallback(d=>{for(const{target:u}of d)if(ia(u)){o(h=>{const m=e(u);return h?{...h,width:m.width,height:m.height}:m});break}},[e]),s=as({callback:r}),a=S.useCallback(d=>{const u=(function(h){if(!h)return null;if(h.children.length>1)return h;const m=h.children[0];return ia(m)?m:h})(d);s==null||s.disconnect(),u&&(s==null||s.observe(u)),o(u?e(u):null)},[e,s]),[l,c]=aa(a);return S.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const tx=[{sensor:bi,options:{}},{sensor:pi,options:{}}],nx={current:{}},is={draggable:{measure:yu},droppable:{measure:yu,strategy:Qo.WhileDragging,frequency:vi.Optimized},dragOverlay:{measure:mo}};class Zo extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,o;return(n=(o=this.get(e))==null?void 0:o.node.current)!=null?n:void 0}}const ox={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Zo,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:os},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:is,measureDroppableContainers:os,windowRect:null,measuringScheduled:!1},rx={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:os,draggableNodes:new Map,over:null,measureDroppableContainers:os},ls=S.createContext(rx),Fu=S.createContext(ox);function sx(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Zo}}}function ax(t,e){switch(e.type){case rt.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case rt.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case rt.DragEnd:case rt.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case rt.RegisterDroppable:{const{element:n}=e,{id:o}=n,r=new Zo(t.droppable.containers);return r.set(o,n),{...t,droppable:{...t.droppable,containers:r}}}case rt.SetDroppableDisabled:{const{id:n,key:o,disabled:r}=e,s=t.droppable.containers.get(n);if(!s||o!==s.key)return t;const a=new Zo(t.droppable.containers);return a.set(n,{...s,disabled:r}),{...t,droppable:{...t.droppable,containers:a}}}case rt.UnregisterDroppable:{const{id:n,key:o}=e,r=t.droppable.containers.get(n);if(!r||o!==r.key)return t;const s=new Zo(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function ix(t){let{disabled:e}=t;const{active:n,activatorEvent:o,draggableNodes:r}=S.useContext(ls),s=la(o),a=la(n==null?void 0:n.id);return S.useEffect(()=>{if(!e&&!o&&s&&a!=null){if(!tc(s)||document.activeElement===s.target)return;const l=r.get(a);if(!l)return;const{activatorNode:c,node:d}=l;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const u of[c.current,d.current]){if(!u)continue;const h=Kk(u);if(h){h.focus();break}}})}},[o,e,r,a,s]),null}const Bu=S.createContext({...Bt,scaleX:1,scaleY:1});var Tn;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Tn||(Tn={}));const lx=S.memo(function(t){var e,n,o,r;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:d=tx,collisionDetection:u=bu,measuring:h,modifiers:m,...p}=t;const b=S.useReducer(ax,void 0,sx),[x,f]=b,[g,y]=(function(){const[re]=S.useState(()=>new Set),ce=S.useCallback(le=>(re.add(le),()=>re.delete(le)),[re]);return[S.useCallback(le=>{let{type:je,event:Ne}=le;re.forEach(xe=>{var De;return(De=xe[je])==null?void 0:De.call(xe,Ne)})},[re]),ce]})(),[w,j]=S.useState(Tn.Uninitialized),C=w===Tn.Initialized,{draggable:{active:N,nodes:k,translate:E},droppable:{containers:_}}=x,I=N!=null?k.get(N):null,A=S.useRef({initial:null,translated:null}),O=S.useMemo(()=>{var re;return N!=null?{id:N,data:(re=I==null?void 0:I.data)!=null?re:nx,rect:A}:null},[N,I]),D=S.useRef(null),[M,R]=S.useState(null),[L,P]=S.useState(null),T=Sr(p,Object.values(p)),F=Nr("DndDescribedBy",s),$=S.useMemo(()=>_.getEnabled(),[_]),W=(H=h,S.useMemo(()=>({draggable:{...is.draggable,...H==null?void 0:H.draggable},droppable:{...is.droppable,...H==null?void 0:H.droppable},dragOverlay:{...is.dragOverlay,...H==null?void 0:H.dragOverlay}}),[H==null?void 0:H.draggable,H==null?void 0:H.droppable,H==null?void 0:H.dragOverlay]));var H;const{droppableRects:X,measureDroppableContainers:q,measuringScheduled:Y}=(function(re,ce){let{dragging:le,dependencies:je,config:Ne}=ce;const[xe,De]=S.useState(null),{frequency:Fe,measure:_e,strategy:Re}=Ne,kt=S.useRef(re),jt=(function(){switch(Re){case Qo.Always:return!1;case Qo.BeforeDragging:return le;default:return!le}})(),zt=Sr(jt),Tt=S.useCallback(function(Fn){Fn===void 0&&(Fn=[]),zt.current||De(no=>no===null?Fn:no.concat(Fn.filter(Jt=>!no.includes(Jt))))},[zt]),Nn=S.useRef(null),Vs=Ir(Fn=>{if(jt&&!le)return Au;if(!Fn||Fn===Au||kt.current!==re||xe!=null){const no=new Map;for(let Jt of re){if(!Jt)continue;if(xe&&xe.length>0&&!xe.includes(Jt.id)&&Jt.rect.current){no.set(Jt.id,Jt.rect.current);continue}const kl=Jt.node.current,jl=kl?new mi(_e(kl),kl):null;Jt.rect.current=jl,jl&&no.set(Jt.id,jl)}return no}return Fn},[re,xe,le,jt,_e]);return S.useEffect(()=>{kt.current=re},[re]),S.useEffect(()=>{jt||Tt()},[le,jt]),S.useEffect(()=>{xe&&xe.length>0&&De(null)},[JSON.stringify(xe)]),S.useEffect(()=>{jt||typeof Fe!="number"||Nn.current!==null||(Nn.current=setTimeout(()=>{Tt(),Nn.current=null},Fe))},[Fe,jt,Tt,...je]),{droppableRects:Vs,measureDroppableContainers:Tt,measuringScheduled:xe!=null}})($,{dragging:C,dependencies:[E.x,E.y],config:W.droppable}),J=(function(re,ce){const le=ce!=null?re.get(ce):void 0,je=le?le.node.current:null;return Ir(Ne=>{var xe;return ce==null?null:(xe=je??Ne)!=null?xe:null},[je,ce])})(k,N),V=S.useMemo(()=>L?nc(L):null,[L]),G=(function(){const re=(M==null?void 0:M.autoScrollEnabled)===!1,ce=typeof l=="object"?l.enabled===!1:l===!1,le=C&&!re&&!ce;return typeof l=="object"?{...l,enabled:le}:{enabled:le}})(),U=(function(re,ce){return Tu(re,ce)})(J,W.draggable.measure);(function(re){let{activeNode:ce,measure:le,initialRect:je,config:Ne=!0}=re;const xe=S.useRef(!1),{x:De,y:Fe}=typeof Ne=="boolean"?{x:Ne,y:Ne}:Ne;Gn(()=>{if(!De&&!Fe||!ce)return void(xe.current=!1);if(xe.current||!je)return;const _e=ce==null?void 0:ce.node.current;if(!_e||_e.isConnected===!1)return;const Re=xu(le(_e),je);if(De||(Re.x=0),Fe||(Re.y=0),xe.current=!0,Math.abs(Re.x)>0||Math.abs(Re.y)>0){const kt=vu(_e);kt&&kt.scrollBy({top:Re.y,left:Re.x})}},[ce,De,Fe,je,le])})({activeNode:N!=null?k.get(N):null,config:G.layoutShiftCompensation,initialRect:U,measure:W.draggable.measure});const ne=Du(J,W.draggable.measure,U),Q=Du(J?J.parentElement:null),ee=S.useRef({activatorEvent:null,active:null,activeNode:J,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:k,draggingNode:null,draggingNodeRect:null,droppableContainers:_,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),te=_.getNodeFor((e=ee.current.over)==null?void 0:e.id),se=ex({measure:W.dragOverlay.measure}),ae=(n=se.nodeRef.current)!=null?n:J,oe=C?(o=se.rect)!=null?o:ne:null,Ee=!!(se.nodeRef.current&&se.rect),ve=xu(ge=Ee?null:ne,Tu(ge));var ge;const ke=Ru(ae?In(ae):null),fe=(function(re){const ce=S.useRef(re),le=Ir(je=>re?je&&je!==Mu&&re&&ce.current&&re.parentNode===ce.current.parentNode?je:rs(re):Mu,[re]);return S.useEffect(()=>{ce.current=re},[re]),le})(C?te??J:null),Ie=(function(re,ce){ce===void 0&&(ce=mo);const[le]=re,je=Ru(le?In(le):null),[Ne,xe]=S.useState(Lu);function De(){xe(()=>re.length?re.map(_e=>ju(_e)?je:new mi(ce(_e),_e)):Lu)}const Fe=as({callback:De});return Gn(()=>{Fe==null||Fe.disconnect(),De(),re.forEach(_e=>Fe==null?void 0:Fe.observe(_e))},[re]),Ne})(fe),Oe=(function(re,ce){let{transform:le,...je}=ce;return re!=null&&re.length?re.reduce((Ne,xe)=>xe({transform:Ne,...je}),le):le})(m,{transform:{x:E.x-ve.x,y:E.y-ve.y,scaleX:1,scaleY:1},activatorEvent:L,active:O,activeNodeRect:ne,containerNodeRect:Q,draggingNodeRect:oe,over:ee.current.over,overlayNodeRect:se.rect,scrollableAncestors:fe,scrollableAncestorRects:Ie,windowRect:ke}),we=V?Ro(V,E):null,be=(function(re){const[ce,le]=S.useState(null),je=S.useRef(re),Ne=S.useCallback(xe=>{const De=ui(xe.target);De&&le(Fe=>Fe?(Fe.set(De,hi(De)),new Map(Fe)):null)},[]);return S.useEffect(()=>{const xe=je.current;if(re!==xe){De(xe);const Fe=re.map(_e=>{const Re=ui(_e);return Re?(Re.addEventListener("scroll",Ne,{passive:!0}),[Re,hi(Re)]):null}).filter(_e=>_e!=null);le(Fe.length?new Map(Fe):null),je.current=re}return()=>{De(re),De(xe)};function De(Fe){Fe.forEach(_e=>{const Re=ui(_e);Re==null||Re.removeEventListener("scroll",Ne)})}},[Ne,re]),S.useMemo(()=>re.length?ce?Array.from(ce.values()).reduce((xe,De)=>Ro(xe,De),Bt):Nu(re):Bt,[re,ce])})(fe),et=Ou(be),ct=Ou(be,[ne]),dt=Ro(Oe,et),tt=oe?Ub(oe,Oe):null,ut=O&&tt?u({active:O,collisionRect:tt,droppableRects:X,droppableContainers:$,pointerCoordinates:we}):null,ht=ci(ut,"id"),[wt,Lt]=S.useState(null),Rn=(function(re,ce,le){return{...re,scaleX:ce&&le?ce.width/le.width:1,scaleY:ce&&le?ce.height/le.height:1}})(Ee?Oe:Ro(Oe,ct),(r=wt==null?void 0:wt.rect)!=null?r:null,ne),Ht=S.useRef(null),Ft=S.useCallback((re,ce)=>{let{sensor:le,options:je}=ce;if(D.current==null)return;const Ne=k.get(D.current);if(!Ne)return;const xe=re.nativeEvent,De=new le({active:D.current,activeNode:Ne,event:xe,options:je,context:ee,onAbort(_e){if(!k.get(_e))return;const{onDragAbort:Re}=T.current,kt={id:_e};Re==null||Re(kt),g({type:"onDragAbort",event:kt})},onPending(_e,Re,kt,jt){if(!k.get(_e))return;const{onDragPending:zt}=T.current,Tt={id:_e,constraint:Re,initialCoordinates:kt,offset:jt};zt==null||zt(Tt),g({type:"onDragPending",event:Tt})},onStart(_e){const Re=D.current;if(Re==null)return;const kt=k.get(Re);if(!kt)return;const{onDragStart:jt}=T.current,zt={activatorEvent:xe,active:{id:Re,data:kt.data,rect:A}};_r.unstable_batchedUpdates(()=>{jt==null||jt(zt),j(Tn.Initializing),f({type:rt.DragStart,initialCoordinates:_e,active:Re}),g({type:"onDragStart",event:zt}),R(Ht.current),P(xe)})},onMove(_e){f({type:rt.DragMove,coordinates:_e})},onEnd:Fe(rt.DragEnd),onCancel:Fe(rt.DragCancel)});function Fe(_e){return async function(){const{active:Re,collisions:kt,over:jt,scrollAdjustedTranslate:zt}=ee.current;let Tt=null;if(Re&&zt){const{cancelDrop:Nn}=T.current;Tt={activatorEvent:xe,active:Re,collisions:kt,delta:zt,over:jt},_e===rt.DragEnd&&typeof Nn=="function"&&await Promise.resolve(Nn(Tt))&&(_e=rt.DragCancel)}D.current=null,_r.unstable_batchedUpdates(()=>{f({type:_e}),j(Tn.Uninitialized),Lt(null),R(null),P(null),Ht.current=null;const Nn=_e===rt.DragEnd?"onDragEnd":"onDragCancel";if(Tt){const Vs=T.current[Nn];Vs==null||Vs(Tt),g({type:Nn,event:Tt})}})}}Ht.current=De},[k]),Pt=S.useCallback((re,ce)=>(le,je)=>{const Ne=le.nativeEvent,xe=k.get(je);if(D.current!==null||!xe||Ne.dndKit||Ne.defaultPrevented)return;const De={active:xe};re(le,ce.options,De)===!0&&(Ne.dndKit={capturedBy:ce.sensor},D.current=je,Ft(le,ce))},[k,Ft]),to=(function(re,ce){return S.useMemo(()=>re.reduce((le,je)=>{const{sensor:Ne}=je;return[...le,...Ne.activators.map(xe=>({eventName:xe.eventName,handler:ce(xe.handler,je)}))]},[]),[re,ce])})(d,Pt);(function(re){S.useEffect(()=>{if(!oc)return;const ce=re.map(le=>{let{sensor:je}=le;return je.setup==null?void 0:je.setup()});return()=>{for(const le of ce)le==null||le()}},re.map(ce=>{let{sensor:le}=ce;return le}))})(d),Gn(()=>{ne&&w===Tn.Initializing&&j(Tn.Initialized)},[ne,w]),S.useEffect(()=>{const{onDragMove:re}=T.current,{active:ce,activatorEvent:le,collisions:je,over:Ne}=ee.current;if(!ce||!le)return;const xe={active:ce,activatorEvent:le,collisions:je,delta:{x:dt.x,y:dt.y},over:Ne};_r.unstable_batchedUpdates(()=>{re==null||re(xe),g({type:"onDragMove",event:xe})})},[dt.x,dt.y]),S.useEffect(()=>{const{active:re,activatorEvent:ce,collisions:le,droppableContainers:je,scrollAdjustedTranslate:Ne}=ee.current;if(!re||D.current==null||!ce||!Ne)return;const{onDragOver:xe}=T.current,De=je.get(ht),Fe=De&&De.rect.current?{id:De.id,rect:De.rect.current,data:De.data,disabled:De.disabled}:null,_e={active:re,activatorEvent:ce,collisions:le,delta:{x:Ne.x,y:Ne.y},over:Fe};_r.unstable_batchedUpdates(()=>{Lt(Fe),xe==null||xe(_e),g({type:"onDragOver",event:_e})})},[ht]),Gn(()=>{ee.current={activatorEvent:L,active:O,activeNode:J,collisionRect:tt,collisions:ut,droppableRects:X,draggableNodes:k,draggingNode:ae,draggingNodeRect:oe,droppableContainers:_,over:wt,scrollableAncestors:fe,scrollAdjustedTranslate:dt},A.current={initial:oe,translated:tt}},[O,J,ut,tt,k,ae,oe,X,_,wt,fe,dt]),Xb({...G,delta:E,draggingRect:tt,pointerCoordinates:we,scrollableAncestors:fe,scrollableAncestorRects:Ie});const Ln=S.useMemo(()=>({active:O,activeNode:J,activeNodeRect:ne,activatorEvent:L,collisions:ut,containerNodeRect:Q,dragOverlay:se,draggableNodes:k,droppableContainers:_,droppableRects:X,over:wt,measureDroppableContainers:q,scrollableAncestors:fe,scrollableAncestorRects:Ie,measuringConfiguration:W,measuringScheduled:Y,windowRect:ke}),[O,J,ne,L,ut,Q,se,k,_,X,wt,q,fe,Ie,W,Y,ke]),No=S.useMemo(()=>({activatorEvent:L,activators:to,active:O,activeNodeRect:ne,ariaDescribedById:{draggable:F},dispatch:f,draggableNodes:k,over:wt,measureDroppableContainers:q}),[L,to,O,ne,f,F,k,wt,q]);return he.createElement(fu.Provider,{value:y},he.createElement(ls.Provider,{value:No},he.createElement(Fu.Provider,{value:Ln},he.createElement(Bu.Provider,{value:Rn},c)),he.createElement(ix,{disabled:(a==null?void 0:a.restoreFocus)===!1})),he.createElement(Lb,{...a,hiddenTextDescribedById:F}))}),cx=S.createContext(null),Pu="button";function dx(t){let{id:e,data:n,disabled:o=!1,attributes:r}=t;const s=Nr("Draggable"),{activators:a,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:m}=S.useContext(ls),{role:p=Pu,roleDescription:b="draggable",tabIndex:x=0}=r??{},f=(c==null?void 0:c.id)===e,g=S.useContext(f?Bu:cx),[y,w]=aa(),[j,C]=aa(),N=(function(E,_){return S.useMemo(()=>E.reduce((I,A)=>{let{eventName:O,handler:D}=A;return I[O]=M=>{D(M,_)},I},{}),[E,_])})(a,e),k=Sr(n);return Gn(()=>(h.set(e,{id:e,key:s,node:y,activatorNode:j,data:k}),()=>{const E=h.get(e);E&&E.key===s&&h.delete(e)}),[h,e]),{active:c,activatorEvent:l,activeNodeRect:d,attributes:S.useMemo(()=>({role:p,tabIndex:x,"aria-disabled":o,"aria-pressed":!(!f||p!==Pu)||void 0,"aria-roledescription":b,"aria-describedby":u.draggable}),[o,p,x,f,b,u.draggable]),isDragging:f,listeners:o?void 0:N,node:y,over:m,setNodeRef:w,setActivatorNodeRef:C,transform:g}}const ux={timeout:25};function zu(t,e,n){const o=t.slice();return o.splice(n<0?o.length+n:n,0,o.splice(e,1)[0]),o}function hx(t,e){return t.reduce((n,o,r)=>{const s=e.get(o);return s&&(n[r]=s),n},Array(t.length))}function cs(t){return t!==null&&t>=0}const ds={scaleX:1,scaleY:1},mx=t=>{var e;let{rects:n,activeNodeRect:o,activeIndex:r,overIndex:s,index:a}=t;const l=(e=n[r])!=null?e:o;if(!l)return null;const c=(function(d,u,h){const m=d[u],p=d[u-1],b=d[u+1];return!m||!p&&!b?0:h<u?p?m.left-(p.left+p.width):b.left-(m.left+m.width):b?b.left-(m.left+m.width):m.left-(p.left+p.width)})(n,a,r);if(a===r){const d=n[s];return d?{x:r<s?d.left+d.width-(l.left+l.width):d.left-l.left,y:0,...ds}:null}return a>r&&a<=s?{x:-l.width-c,y:0,...ds}:a<r&&a>=s?{x:l.width+c,y:0,...ds}:{x:0,y:0,...ds}},Uu=t=>{let{rects:e,activeIndex:n,overIndex:o,index:r}=t;const s=zu(e,o,n),a=e[r],l=s[r];return l&&a?{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}:null},us={scaleX:1,scaleY:1},fx=t=>{var e;let{activeIndex:n,activeNodeRect:o,index:r,rects:s,overIndex:a}=t;const l=(e=s[n])!=null?e:o;if(!l)return null;if(r===n){const d=s[a];return d?{x:0,y:n<a?d.top+d.height-(l.top+l.height):d.top-l.top,...us}:null}const c=(function(d,u,h){const m=d[u],p=d[u-1],b=d[u+1];return m?h<u?p?m.top-(p.top+p.height):b?b.top-(m.top+m.height):0:b?b.top-(m.top+m.height):p?m.top-(p.top+p.height):0:0})(s,r,n);return r>n&&r<=a?{x:0,y:-l.height-c,...us}:r<n&&r>=a?{x:0,y:l.height+c,...us}:{x:0,y:0,...us}},Wu="Sortable",$u=he.createContext({activeIndex:-1,containerId:Wu,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Uu,disabled:{draggable:!1,droppable:!1}});function Vu(t){let{children:e,id:n,items:o,strategy:r=Uu,disabled:s=!1}=t;const{active:a,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:u}=S.useContext(Fu),h=Nr(Wu,n),m=l.rect!==null,p=S.useMemo(()=>o.map(N=>typeof N=="object"&&"id"in N?N.id:N),[o]),b=a!=null,x=a?p.indexOf(a.id):-1,f=d?p.indexOf(d.id):-1,g=S.useRef(p),y=!(function(N,k){if(N===k)return!0;if(N.length!==k.length)return!1;for(let E=0;E<N.length;E++)if(N[E]!==k[E])return!1;return!0})(p,g.current),w=f!==-1&&x===-1||y,j=(function(N){return typeof N=="boolean"?{draggable:N,droppable:N}:N})(s);Gn(()=>{y&&b&&u(p)},[y,p,b,u]),S.useEffect(()=>{g.current=p},[p]);const C=S.useMemo(()=>({activeIndex:x,containerId:h,disabled:j,disableTransforms:w,items:p,overIndex:f,useDragOverlay:m,sortedRects:hx(p,c),strategy:r}),[x,h,j.draggable,j.droppable,w,p,f,c,m,r]);return he.createElement($u.Provider,{value:C},e)}const px=t=>{let{id:e,items:n,activeIndex:o,overIndex:r}=t;return zu(n,o,r).indexOf(e)},gx=t=>{let{containerId:e,isSorting:n,wasDragging:o,index:r,items:s,newIndex:a,previousItems:l,previousContainerId:c,transition:d}=t;return!(!d||!o)&&(l===s||r!==a)&&(!!n||a!==r&&e===c)},bx={duration:200,easing:"ease"},Gu="transform",xx=ca.Transition.toString({property:Gu,duration:0,easing:"linear"}),yx={roleDescription:"sortable"};function qu(t){let{animateLayoutChanges:e=gx,attributes:n,disabled:o,data:r,getNewIndex:s=px,id:a,strategy:l,resizeObserverConfig:c,transition:d=bx}=t;const{items:u,containerId:h,activeIndex:m,disabled:p,disableTransforms:b,sortedRects:x,overIndex:f,useDragOverlay:g,strategy:y}=S.useContext($u),w=(function(te,se){var ae,oe;return typeof te=="boolean"?{draggable:te,droppable:!1}:{draggable:(ae=te==null?void 0:te.draggable)!=null?ae:se.draggable,droppable:(oe=te==null?void 0:te.droppable)!=null?oe:se.droppable}})(o,p),j=u.indexOf(a),C=S.useMemo(()=>({sortable:{containerId:h,index:j,items:u},...r}),[h,r,j,u]),N=S.useMemo(()=>u.slice(u.indexOf(a)),[u,a]),{rect:k,node:E,isOver:_,setNodeRef:I}=(function(te){let{data:se,disabled:ae=!1,id:oe,resizeObserverConfig:Ee}=te;const ve=Nr("Droppable"),{active:ge,dispatch:ke,over:fe,measureDroppableContainers:Ie}=S.useContext(ls),Oe=S.useRef({disabled:ae}),we=S.useRef(!1),be=S.useRef(null),et=S.useRef(null),{disabled:ct,updateMeasurementsFor:dt,timeout:tt}={...ux,...Ee},ut=Sr(dt??oe),ht=as({callback:S.useCallback(()=>{we.current?(et.current!=null&&clearTimeout(et.current),et.current=setTimeout(()=>{Ie(Array.isArray(ut.current)?ut.current:[ut.current]),et.current=null},tt)):we.current=!0},[tt]),disabled:ct||!ge}),wt=S.useCallback((Ft,Pt)=>{ht&&(Pt&&(ht.unobserve(Pt),we.current=!1),Ft&&ht.observe(Ft))},[ht]),[Lt,Rn]=aa(wt),Ht=Sr(se);return S.useEffect(()=>{ht&&Lt.current&&(ht.disconnect(),we.current=!1,ht.observe(Lt.current))},[Lt,ht]),S.useEffect(()=>(ke({type:rt.RegisterDroppable,element:{id:oe,key:ve,disabled:ae,node:Lt,rect:be,data:Ht}}),()=>ke({type:rt.UnregisterDroppable,key:ve,id:oe})),[oe]),S.useEffect(()=>{ae!==Oe.current.disabled&&(ke({type:rt.SetDroppableDisabled,id:oe,key:ve,disabled:ae}),Oe.current.disabled=ae)},[oe,ve,ae,ke]),{active:ge,rect:be,isOver:(fe==null?void 0:fe.id)===oe,node:Lt,over:fe,setNodeRef:Rn}})({id:a,data:C,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...c}}),{active:A,activatorEvent:O,activeNodeRect:D,attributes:M,setNodeRef:R,listeners:L,isDragging:P,over:T,setActivatorNodeRef:F,transform:$}=dx({id:a,data:C,attributes:{...yx,...n},disabled:w.draggable}),W=Xk(I,R),H=!!A,X=H&&!b&&cs(m)&&cs(f),q=!g&&P,Y=q&&X?$:null,J=X?Y??(l??y)({rects:x,activeNodeRect:D,activeIndex:m,overIndex:f,index:j}):null,V=cs(m)&&cs(f)?s({id:a,items:u,activeIndex:m,overIndex:f}):j,G=A==null?void 0:A.id,U=S.useRef({activeId:G,items:u,newIndex:V,containerId:h}),ne=u!==U.current.items,Q=e({active:A,containerId:h,isDragging:P,isSorting:H,id:a,index:j,items:u,newIndex:U.current.newIndex,previousItems:U.current.items,previousContainerId:U.current.containerId,transition:d,wasDragging:U.current.activeId!=null}),ee=(function(te){let{disabled:se,index:ae,node:oe,rect:Ee}=te;const[ve,ge]=S.useState(null),ke=S.useRef(ae);return Gn(()=>{if(!se&&ae!==ke.current&&oe.current){const fe=Ee.current;if(fe){const Ie=mo(oe.current,{ignoreTransform:!0}),Oe={x:fe.left-Ie.left,y:fe.top-Ie.top,scaleX:fe.width/Ie.width,scaleY:fe.height/Ie.height};(Oe.x||Oe.y)&&ge(Oe)}}ae!==ke.current&&(ke.current=ae)},[se,ae,oe,Ee]),S.useEffect(()=>{ve&&ge(null)},[ve]),ve})({disabled:!Q,index:j,node:E,rect:k});return S.useEffect(()=>{H&&U.current.newIndex!==V&&(U.current.newIndex=V),h!==U.current.containerId&&(U.current.containerId=h),u!==U.current.items&&(U.current.items=u)},[H,V,h,u]),S.useEffect(()=>{if(G===U.current.activeId)return;if(G!=null&&U.current.activeId==null)return void(U.current.activeId=G);const te=setTimeout(()=>{U.current.activeId=G},50);return()=>clearTimeout(te)},[G]),{active:A,activeIndex:m,attributes:M,data:C,rect:k,index:j,newIndex:V,items:u,isOver:_,isSorting:H,isDragging:P,listeners:L,node:E,overIndex:f,over:T,setNodeRef:W,setActivatorNodeRef:F,setDroppableNodeRef:I,setDraggableNodeRef:R,transform:ee??J,transition:(function(){if(ee||ne&&U.current.newIndex===j)return xx;if(!(q&&!tc(O)||!d)&&(H||Q))return ca.Transition.toString({...d,property:Gu})})()}}function hs(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const vx=[Ae.Down,Ae.Right,Ae.Up,Ae.Left],wx=(t,e)=>{let{context:{active:n,collisionRect:o,droppableRects:r,droppableContainers:s,over:a,scrollableAncestors:l}}=e;if(vx.includes(t.code)){if(t.preventDefault(),!n||!o)return;const c=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const m=r.get(h.id);if(m)switch(t.code){case Ae.Down:o.top<m.top&&c.push(h);break;case Ae.Up:o.top>m.top&&c.push(h);break;case Ae.Left:o.left>m.left&&c.push(h);break;case Ae.Right:o.left<m.left&&c.push(h)}});const d=(h=>{let{collisionRect:m,droppableRects:p,droppableContainers:b}=h;const x=li(m),f=[];for(const g of b){const{id:y}=g,w=p.get(y);if(w){const j=li(w),C=x.reduce((k,E,_)=>k+ai(j[_],E),0),N=Number((C/4).toFixed(4));f.push({id:y,data:{droppableContainer:g,value:N}})}}return f.sort(ii)})({collisionRect:o,droppableRects:r,droppableContainers:c});let u=ci(d,"id");if(u===(a==null?void 0:a.id)&&d.length>1&&(u=d[1].id),u!=null){const h=s.get(n.id),m=s.get(u),p=m?r.get(m.id):null,b=m==null?void 0:m.node.current;if(b&&p&&h&&m){const x=rs(b).some((j,C)=>l[C]!==j),f=Hu(h,m),g=(function(j,C){return!hs(j)||!hs(C)||!Hu(j,C)?!1:j.data.current.sortable.index<C.data.current.sortable.index})(h,m),y=x||!f?{x:0,y:0}:{x:g?o.width-p.width:0,y:g?o.height-p.height:0},w={x:p.left,y:p.top};return y.x&&y.y?w:Er(w,y)}}}};function Hu(t,e){return!(!hs(t)||!hs(e))&&t.data.current.sortable.containerId===e.data.current.sortable.containerId}const kx=()=>{const t=z.c(21),{startupLogsAlert:e}=tg(),{clearStartupLogsAlert:n}=ng(),[o,r]=S.useState(!1),s=e==null?void 0:e.status;let a;t[0]!==n?(a=()=>{n(),r(!0)},t[0]=n,t[1]=a):a=t[1];const l=Ce(a),c=s==="done",d=s==="start"||s==="append";let u,h,m;if(t[2]!==l||t[3]!==c?(u=()=>{let C;return c&&(C=window.setTimeout(()=>l(),5e3)),()=>{C&&window.clearTimeout(C)}},t[2]=l,t[3]=c,t[4]=u):u=t[4],t[5]!==c?(h=[c],t[5]=c,t[6]=h):h=t[6],S.useEffect(u,h),e===null||o)return null;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(ja,{className:"w-5 h-5 inline-block mr-2"}),t[7]=m):m=t[7];const p=d?"Initializing...":"Initialized";let b,x,f,g;t[8]!==p?(b=i.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[m,p]}),t[8]=p,t[9]=b):b=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx($t,{className:"w-5 h-5"}),t[10]=x):x=t[10],t[11]!==l?(f=i.jsx(ye,{variant:"text","data-testid":"remove-startup-logs-button",size:"icon",onClick:l,children:x}),t[11]=l,t[12]=f):f=t[12],t[13]!==b||t[14]!==f?(g=i.jsxs("div",{className:"flex justify-between",children:[b,f]}),t[13]=b,t[14]=f,t[15]=g):g=t[15];const y=e.content||"Starting startup script...";let w,j;return t[16]!==y?(w=i.jsx("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:i.jsx("div",{className:"w-full",children:i.jsx("pre",{className:"bg-muted p-3 rounded text-sm font-mono overflow-auto max-h-64 whitespace-pre-wrap",children:y})})}),t[16]=y,t[17]=w):w=t[17],t[18]!==w||t[19]!==g?(j=i.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] max-w-[600px] z-200 opacity-95",children:i.jsxs(Lo,{kind:"info",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left",children:[g,w]})}),t[18]=w,t[19]=g,t[20]=j):j=t[20],j},jx=Qk("rounded-full shadow-xs-solid border p-[5px] transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 active:shadow-none bg-background",{variants:{variant:{default:"hover:bg-accent hover:text-accent-foreground",stale:"bg-(--yellow-3) hover:bg-(--yellow-4) text-(--yellow-11)",green:"hover:bg-(--grass-2) hover:text-(--grass-11) hover:border-[var(--grass-7)],",disabled:"opacity-50 cursor-not-allowed",danger:"hover:bg-(--red-3) hover:text-(--red-11)"}},defaultVariants:{variant:"default"}}),er=t=>{const e=z.c(18);let n,o,r,s,a,l,c,d;if(e[0]!==t){const{children:h,tooltip:m,disabled:p,variant:b,...x}=t;n=h,c=m;const f=p!==void 0&&p;o=f,r=x,s=g=>{var y;f||((y=x.onClick)==null||y.call(x,g))},a=Bn.preventFocus,l=de(jx({variant:b}),x.className),e[0]=t,e[1]=n,e[2]=o,e[3]=r,e[4]=s,e[5]=a,e[6]=l,e[7]=c}else n=e[1],o=e[2],r=e[3],s=e[4],a=e[5],l=e[6],c=e[7];e[8]!==n||e[9]!==o||e[10]!==r||e[11]!==s||e[12]!==a||e[13]!==l?(d=i.jsx("button",{disabled:o,...r,onClick:s,onMouseDown:a,className:l,children:n}),e[8]=n,e[9]=o,e[10]=r,e[11]=s,e[12]=a,e[13]=l,e[14]=d):d=e[14];const u=d;if(c){let h;return e[15]!==u||e[16]!==c?(h=i.jsx(pe,{content:c,side:"top",delayDuration:200,usePortal:!1,children:u}),e[15]=u,e[16]=c,e[17]=h):h=e[17],h}return u},Cx=t=>{const e=z.c(5),{children:n,className:o}=t;let r,s;return e[0]!==o?(r=de("flex items-center gap-1 bg-background m-[2px] rounded-full",o),e[0]=o,e[1]=r):r=e[1],e[2]!==n||e[3]!==r?(s=i.jsx(xg,{className:r,children:n}),e[2]=n,e[3]=r,e[4]=s):s=e[4],s},Nx=t=>{const e=z.c(9),{connectionState:n,status:o}=t,{sendInterrupt:r}=qe(),s=lu(o==="running");let a,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=St("global.interrupt"),e[0]=a):a=e[0],e[1]!==n||e[2]!==s?(l=en(n)||!s,e[1]=n,e[2]=s,e[3]=l):l=e[3];const c=s?r:Pn.NOOP,d=s?"stale":"disabled";let u,h;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Bl,{strokeWidth:1.5}),e[4]=u):u=e[4],e[5]!==l||e[6]!==c||e[7]!==d?(h=i.jsx(er,{tooltip:a,disabled:l,onClick:c,variant:d,"data-testid":"run-button",children:u}),e[5]=l,e[6]=c,e[7]=d,e[8]=h):h=e[8],h};let Ju;Ac="packages-install-input",Ju=["%alias","%cd","%clear","%debug","%env","%load","%load_ext","%lsmagic","%matplotlib","%pwd","%who_ls","%system","%%time","%%timeit","%%writefile","%%capture","%%html","%%latex"];let wi;function Sx(){const t=async r=>{const s=Le.get(ra),{saveUserConfig:a}=r1(),l={...s,runtime:{...s.runtime,auto_reload:r}};await a({config:l}).then(()=>Le.set(ra,l))},e=()=>{requestAnimationFrame(()=>{const r=document.getElementById(Ac);r&&r.focus()})},n=[{match:"!pip install",onMatch:()=>{Le.set(sc,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:i.jsxs(i.Fragment,{children:["The package manager sidebar has been opened.",i.jsx("br",{}),"Install packages directly from there instead."]})},{match:"!uv pip install",onMatch:()=>{Le.set(sc,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:i.jsxs(i.Fragment,{children:["The package manager sidebar has been opened.",i.jsx("br",{}),"Install packages directly from there instead."]})},{match:"!uv add",onMatch:()=>{Le.set(sc,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:i.jsxs(i.Fragment,{children:["The package manager sidebar has been opened.",i.jsx("br",{}),"Install packages directly from there instead."]})},{match:"%autoreload 2",onMatch:async()=>{await t("autorun")},title:"Module reload",description:i.jsxs(i.Fragment,{children:["Module reload mode set to ",i.jsx("b",{children:"autorun"})," - module changes will re-run the cells that import them."]})},{match:"%autoreload 1",onMatch:async()=>{await t("lazy")},title:"Module reload",description:i.jsxs(i.Fragment,{children:["Module reload mode set to ",i.jsx("b",{children:"lazy"})," - module changes will mark the cells that import them as stale."]})},{match:"%autoreload 0",onMatch:async()=>{await t("off")},title:"Module reload",description:i.jsx(i.Fragment,{children:"Module reload disabled - module changes will not be detected."})},{match:"!ls",onMatch:()=>{},title:"Listing files",description:i.jsxs(i.Fragment,{children:["Shell commands are not directly supported.",i.jsx("br",{}),"Use ",i.jsx("code",{children:"import subprocess; subprocess.run(['ls'])"})," instead."]})},...Ju.map(r=>({match:r,onMatch:()=>{},title:i.jsx(o1,{className:"inline",children:r}),description:i.jsxs(i.Fragment,{children:["Magic commands are not supported in marimo. Read more about replacements in the"," ",i.jsx("a",{href:"https://docs.marimo.io/guides/coming_from/jupyter/#adapting-to-the-absence-of-magic-commands",target:"_blank",className:"text-link underline cursor-pointer",rel:"noopener noreferrer",children:"documentation"}),"."]})}))],o=new Map(n.map(r=>[r.match,r]));return Se.updateListener.of(r=>{if(r.docChanged){const s=r.state.selection.main,a=r.state.doc,l=a.lineAt(s.head),c=a.sliceString(l.from,s.anchor).trim(),d=o.get(c);d&&(d.onMatch(),wi?wi.upsert({title:d.title,description:d.description}):wi=ze({title:d.title,description:d.description}))}})}const Ex=new Set(["Escape","Alt-`"]);function _x(){const t=s1.filter(e=>!Ex.has(e.key));return Sn.highest(Wt.of([...t,{key:"Ctrl-y",run:e=>!!da(e)&&a1(e)},{key:"Ctrl-n",run:e=>!!da(e)&&ua(!0)(e)},{key:"Ctrl-p",run:e=>!!da(e)&&ua(!1)(e)}]))}const ki=nt.define(),ji=nt.define(),Ci=nt.define();function Ge(t,e){if(!t)throw new Error(e)}function ms(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>2147483647||t<-2147483648)throw new Error("invalid int 32: "+t)}function Ni(t){if(typeof t!="number")throw new Error("invalid uint 32: "+typeof t);if(!Number.isInteger(t)||t>4294967295||t<0)throw new Error("invalid uint 32: "+t)}function Ku(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(Number.isFinite(t)&&(t>3402823466385289e23||t<-3402823466385289e23))throw new Error("invalid float 32: "+t)}const Yu=Symbol("@bufbuild/protobuf/enum-type");function Ix(t){const e=t[Yu];return Ge(e,"missing enum type on enum object"),e}function Xu(t,e,n,o){t[Yu]=Qu(e,n.map(r=>({no:r.no,name:r.name,localName:t[r.no]})))}function Qu(t,e,n){const o=Object.create(null),r=Object.create(null),s=[];for(const a of e){const l=Zu(a);s.push(l),o[a.name]=l,r[a.no]=l}return{typeName:t,values:s,findName:a=>o[a],findNumber:a=>r[a]}}function Ax(t,e,n){const o={};for(const r of e){const s=Zu(r);o[s.localName]=s.no,o[s.no]=s.localName}return Xu(o,t,e),o}function Zu(t){return"localName"in t?t:Object.assign(Object.assign({},t),{localName:t.name})}class Xe{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){const o=this.getType().runtime.bin,r=o.makeReadOptions(n);return o.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,n){const o=this.getType(),r=o.runtime.json,s=r.makeReadOptions(n);return r.readMessage(o,e,s,this),this}fromJsonString(e,n){let o;try{o=JSON.parse(e)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(o,n)}toBinary(e){const n=this.getType().runtime.bin,o=n.makeWriteOptions(e),r=o.writerFactory();return n.writeMessage(this,r,o),r.finish()}toJson(e){const n=this.getType().runtime.json,o=n.makeWriteOptions(e);return n.writeMessage(this,o)}toJsonString(e){var n;const o=this.toJson(e);return JSON.stringify(o,null,(n=e==null?void 0:e.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Tx(){let t=0,e=0;for(let o=0;o<28;o+=7){let r=this.buf[this.pos++];if(t|=(127&r)<<o,!(128&r))return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(15&n)<<28,e=(112&n)>>4,!(128&n))return this.assertBounds(),[t,e];for(let o=3;o<=31;o+=7){let r=this.buf[this.pos++];if(e|=(127&r)<<o,!(128&r))return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Si(t,e,n){for(let s=0;s<28;s+=7){const a=t>>>s,l=!(!(a>>>7)&&e==0),c=255&(l?128|a:a);if(n.push(c),!l)return}const o=t>>>28&15|(7&e)<<4,r=!!(e>>3);if(n.push(255&(r?128|o:o)),r){for(let s=3;s<31;s+=7){const a=e>>>s,l=!!(a>>>7),c=255&(l?128|a:a);if(n.push(c),!l)return}n.push(e>>>31&1)}}const fs=4294967296;function eh(t){const e=t[0]==="-";e&&(t=t.slice(1));const n=1e6;let o=0,r=0;function s(a,l){const c=Number(t.slice(a,l));r*=n,o=o*n+c,o>=fs&&(r+=o/fs|0,o%=fs)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?nh(o,r):Ei(o,r)}function th(t,e){if({lo:t,hi:e}=(function(c,d){return{lo:c>>>0,hi:d>>>0}})(t,e),e<=2097151)return String(fs*e+t);const n=16777215&(t>>>24|e<<8),o=e>>16&65535;let r=(16777215&t)+6777216*n+6710656*o,s=n+8147497*o,a=2*o;const l=1e7;return r>=l&&(s+=Math.floor(r/l),r%=l),s>=l&&(a+=Math.floor(s/l),s%=l),a.toString()+oh(s)+oh(r)}function Ei(t,e){return{lo:0|t,hi:0|e}}function nh(t,e){return e=~e,t?t=1+~t:e+=1,Ei(t,e)}const oh=t=>{const e=String(t);return"0000000".slice(e.length)+e};function rh(t,e){if(t>=0){for(;t>127;)e.push(127&t|128),t>>>=7;e.push(t)}else{for(let n=0;n<9;n++)e.push(127&t|128),t>>=7;e.push(1)}}function Dx(){let t=this.buf[this.pos++],e=127&t;if(!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<7,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<14,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<21,!(128&t))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(15&t)<<28;for(let n=5;128&t&&n<10;n++)t=this.buf[this.pos++];if(128&t)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var Mx={};const We=(function(){const t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(typeof process!="object"||Mx.BUF_BIGINT_DISABLE!=="1")){const o=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),s=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(l){const c=typeof l=="bigint"?l:BigInt(l);if(c>r||c<o)throw new Error(`int64 invalid: ${l}`);return c},uParse(l){const c=typeof l=="bigint"?l:BigInt(l);if(c>a||c<s)throw new Error(`uint64 invalid: ${l}`);return c},enc(l){return t.setBigInt64(0,this.parse(l),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(l){return t.setBigInt64(0,this.uParse(l),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec:(l,c)=>(t.setInt32(0,l,!0),t.setInt32(4,c,!0),t.getBigInt64(0,!0)),uDec:(l,c)=>(t.setInt32(0,l,!0),t.setInt32(4,c,!0),t.getBigUint64(0,!0))}}const e=o=>Ge(/^-?[0-9]+$/.test(o),`int64 invalid: ${o}`),n=o=>Ge(/^[0-9]+$/.test(o),`uint64 invalid: ${o}`);return{zero:"0",supported:!1,parse:o=>(typeof o!="string"&&(o=o.toString()),e(o),o),uParse:o=>(typeof o!="string"&&(o=o.toString()),n(o),o),enc:o=>(typeof o!="string"&&(o=o.toString()),e(o),eh(o)),uEnc:o=>(typeof o!="string"&&(o=o.toString()),n(o),eh(o)),dec:(o,r)=>(function(s,a){let l=Ei(s,a);const c=2147483648&l.hi;c&&(l=nh(l.lo,l.hi));const d=th(l.lo,l.hi);return c?"-"+d:d})(o,r),uDec:(o,r)=>th(o,r)}})();var K,Dn,Je;function Mn(t,e,n){if(e===n)return!0;if(t==K.BYTES){if(!(e instanceof Uint8Array&&n instanceof Uint8Array)||e.length!==n.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==n[o])return!1;return!0}switch(t){case K.UINT64:case K.FIXED64:case K.INT64:case K.SFIXED64:case K.SINT64:return e==n}return!1}function fo(t,e){switch(t){case K.BOOL:return!1;case K.UINT64:case K.FIXED64:case K.INT64:case K.SFIXED64:case K.SINT64:return e==0?We.zero:"0";case K.DOUBLE:case K.FLOAT:return 0;case K.BYTES:return new Uint8Array(0);case K.STRING:return"";default:return 0}}function sh(t,e){switch(t){case K.BOOL:return e===!1;case K.STRING:return e==="";case K.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(K||(K={})),(function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING"})(Dn||(Dn={})),(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(Je||(Je={}));class Ox{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let n=new Uint8Array(e),o=0;for(let r=0;r<this.chunks.length;r++)n.set(this.chunks[r],o),o+=this.chunks[r].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Ni(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return ms(e),rh(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){Ku(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){Ni(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){ms(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return ms(e),rh(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let n=new Uint8Array(8),o=new DataView(n.buffer),r=We.enc(e);return o.setInt32(0,r.lo,!0),o.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),o=new DataView(n.buffer),r=We.uEnc(e);return o.setInt32(0,r.lo,!0),o.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=We.enc(e);return Si(n.lo,n.hi,this.buf),this}sint64(e){let n=We.enc(e),o=n.hi>>31;return Si(n.lo<<1^o,(n.hi<<1|n.lo>>>31)^o,this.buf),this}uint64(e){let n=We.uEnc(e);return Si(n.lo,n.hi,this.buf),this}}class Rx{constructor(e,n){this.varint64=Tx,this.uint32=Dx,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n??new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,o=7&e;if(n<=0||o<0||o>5)throw new Error("illegal tag: field no "+n+" wire type "+o);return[n,o]}skip(e,n){let o=this.pos;switch(e){case Je.Varint:for(;128&this.buf[this.pos++];);break;case Je.Bit64:this.pos+=4;case Je.Bit32:this.pos+=4;break;case Je.LengthDelimited:let r=this.uint32();this.pos+=r;break;case Je.StartGroup:for(;;){const[s,a]=this.tag();if(a===Je.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(a,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(o,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return We.dec(...this.varint64())}uint64(){return We.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),o=-(1&e);return e=(e>>>1|(1&n)<<31)^o,n=n>>>1^o,We.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return We.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return We.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}}function ah(t){const e=t.field.localName,n=Object.create(null);return n[e]=(function(o){const r=o.field;if(r.repeated)return[];if(r.default!==void 0)return r.default;switch(r.kind){case"enum":return r.T.values[0].no;case"scalar":return fo(r.T,r.L);case"message":const s=r.T,a=new s;return s.fieldWrapper?s.fieldWrapper.unwrapField(a):a;case"map":throw"map fields are not allowed to be extensions"}})(t),[n,()=>n[e]]}let on="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),ps=[];for(let t=0;t<on.length;t++)ps[on[t].charCodeAt(0)]=t;ps[45]=on.indexOf("+"),ps[95]=on.indexOf("/");const gs={dec(t){let e=3*t.length/4;t[t.length-2]=="="?e-=2:t[t.length-1]=="="&&(e-=1);let n,o=new Uint8Array(e),r=0,s=0,a=0;for(let l=0;l<t.length;l++){if(n=ps[t.charCodeAt(l)],n===void 0)switch(t[l]){case"=":s=0;case`
115
+ `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(s){case 0:a=n,s=1;break;case 1:o[r++]=a<<2|(48&n)>>4,a=n,s=2;break;case 2:o[r++]=(15&a)<<4|(60&n)>>2,a=n,s=3;break;case 3:o[r++]=(3&a)<<6|n,s=0}}if(s==1)throw Error("invalid base64 string.");return o.subarray(0,r)},enc(t){let e,n="",o=0,r=0;for(let s=0;s<t.length;s++)switch(e=t[s],o){case 0:n+=on[e>>2],r=(3&e)<<4,o=1;break;case 1:n+=on[r|e>>4],r=(15&e)<<2,o=2;break;case 2:n+=on[r|e>>6],n+=on[63&e],o=0}return o&&(n+=on[r],n+="=",o==1&&(n+="=")),n}};function Lx(t,e,n){lh(e,t);const o=e.runtime.bin.makeReadOptions(n),r=(function(l,c){if(!c.repeated&&(c.kind=="enum"||c.kind=="scalar")){for(let d=l.length-1;d>=0;--d)if(l[d].no==c.no)return[l[d]];return[]}return l.filter(d=>d.no===c.no)})(t.getType().runtime.bin.listUnknownFields(t),e.field),[s,a]=ah(e);for(const l of r)e.runtime.bin.readField(s,o.readerFactory(l.data),e.field,l.wireType,o);return a()}function Fx(t,e,n,o){lh(e,t);const r=e.runtime.bin.makeReadOptions(o),s=e.runtime.bin.makeWriteOptions(o);if(ih(t,e)){const d=t.getType().runtime.bin.listUnknownFields(t).filter(u=>u.no!=e.field.no);t.getType().runtime.bin.discardUnknownFields(t);for(const u of d)t.getType().runtime.bin.onUnknownField(t,u.no,u.wireType,u.data)}const a=s.writerFactory();let l=e.field;l.opt||l.repeated||l.kind!="enum"&&l.kind!="scalar"||(l=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(l,n,a,s);const c=r.readerFactory(a.finish());for(;c.pos<c.len;){const[d,u]=c.tag(),h=c.skip(u,d);t.getType().runtime.bin.onUnknownField(t,d,u,h)}}function ih(t,e){const n=t.getType();return e.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(t).find(o=>o.no==e.field.no)}function lh(t,e){Ge(t.extendee.typeName==e.getType().typeName,`extension ${t.typeName} can only be applied to message ${t.extendee.typeName}`)}function ch(t,e){const n=t.localName;if(t.repeated)return e[n].length>0;if(t.oneof)return e[t.oneof.localName].case===n;switch(t.kind){case"enum":case"scalar":return t.opt||t.req?e[n]!==void 0:t.kind=="enum"?e[n]!==t.T.values[0].no:!sh(t.T,e[n]);case"message":return e[n]!==void 0;case"map":return Object.keys(e[n]).length>0}}function dh(t,e){const n=t.localName,o=!t.opt&&!t.req;if(t.repeated)e[n]=[];else if(t.oneof)e[t.oneof.localName]={case:void 0};else switch(t.kind){case"map":e[n]={};break;case"enum":e[n]=o?t.T.values[0].no:void 0;break;case"scalar":e[n]=o?fo(t.T,t.L):void 0;break;case"message":e[n]=void 0}}function rn(t,e){if(t===null||typeof t!="object"||!Object.getOwnPropertyNames(Xe.prototype).every(o=>o in t&&typeof t[o]=="function"))return!1;const n=t.getType();return n!==null&&typeof n=="function"&&"typeName"in n&&typeof n.typeName=="string"&&(e===void 0||n.typeName==e.typeName)}function uh(t,e){return rn(e)||!t.fieldWrapper?e:t.fieldWrapper.wrapField(e)}K.DOUBLE,K.FLOAT,K.INT64,K.UINT64,K.INT32,K.UINT32,K.BOOL,K.STRING,K.BYTES;const hh={ignoreUnknownFields:!1},mh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Bx(t){return t?Object.assign(Object.assign({},hh),t):hh}function Px(t){return t?Object.assign(Object.assign({},mh),t):mh}const bs=Symbol(),xs=Symbol();function Gt(t){if(t===null)return"null";switch(typeof t){case"object":return Array.isArray(t)?"array":"object";case"string":return t.length>100?"string":`"${t.split('"').join('\\"')}"`;default:return String(t)}}function fh(t,e,n,o,r){let s=n.localName;if(n.repeated){if(Ge(n.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${Gt(e)}`);const a=t[s];for(const l of e){if(l===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${Gt(l)}`);switch(n.kind){case"message":a.push(n.T.fromJson(l,o));break;case"enum":const c=_i(n.T,l,o.ignoreUnknownFields,!0);c!==xs&&a.push(c);break;case"scalar":try{a.push(tr(n.T,l,n.L,!0))}catch(d){let u=`cannot decode field ${r.typeName}.${n.name} from JSON: ${Gt(l)}`;throw d instanceof Error&&d.message.length>0&&(u+=`: ${d.message}`),new Error(u)}}}}else if(n.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${Gt(e)}`);const a=t[s];for(const[l,c]of Object.entries(e)){if(c===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let d;try{d=zx(n.K,l)}catch(u){let h=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${Gt(e)}`;throw u instanceof Error&&u.message.length>0&&(h+=`: ${u.message}`),new Error(h)}switch(n.V.kind){case"message":a[d]=n.V.T.fromJson(c,o);break;case"enum":const u=_i(n.V.T,c,o.ignoreUnknownFields,!0);u!==xs&&(a[d]=u);break;case"scalar":try{a[d]=tr(n.V.T,c,Dn.BIGINT,!0)}catch(h){let m=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${Gt(e)}`;throw h instanceof Error&&h.message.length>0&&(m+=`: ${h.message}`),new Error(m)}}}}else switch(n.oneof&&(t=t[n.oneof.localName]={case:s},s="value"),n.kind){case"message":const a=n.T;if(e===null&&a.typeName!="google.protobuf.Value")return;let l=t[s];rn(l)?l.fromJson(e,o):(t[s]=l=a.fromJson(e,o),a.fieldWrapper&&!n.oneof&&(t[s]=a.fieldWrapper.unwrapField(l)));break;case"enum":const c=_i(n.T,e,o.ignoreUnknownFields,!1);switch(c){case bs:dh(n,t);break;case xs:break;default:t[s]=c}break;case"scalar":try{const d=tr(n.T,e,n.L,!1);d===bs?dh(n,t):t[s]=d}catch(d){let u=`cannot decode field ${r.typeName}.${n.name} from JSON: ${Gt(e)}`;throw d instanceof Error&&d.message.length>0&&(u+=`: ${d.message}`),new Error(u)}}}function zx(t,e){if(t===K.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1}return tr(t,e,Dn.BIGINT,!0).toString()}function tr(t,e,n,o){if(e===null)return o?fo(t,n):bs;switch(t){case K.DOUBLE:case K.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return t==K.FLOAT&&Ku(r),r;case K.INT32:case K.FIXED32:case K.SFIXED32:case K.SINT32:case K.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return t==K.UINT32||t==K.FIXED32?Ni(s):ms(s),s;case K.INT64:case K.SFIXED64:case K.SINT64:if(typeof e!="number"&&typeof e!="string")break;const a=We.parse(e);return n?a.toString():a;case K.FIXED64:case K.UINT64:if(typeof e!="number"&&typeof e!="string")break;const l=We.uParse(e);return n?l.toString():l;case K.BOOL:if(typeof e!="boolean")break;return e;case K.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case K.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return gs.dec(e)}throw new Error}function _i(t,e,n,o){if(e===null)return t.typeName=="google.protobuf.NullValue"?0:o?t.values[0].no:bs;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const r=t.findName(e);if(r!==void 0)return r.no;if(n)return xs}throw new Error(`cannot decode enum ${t.typeName} from JSON: ${Gt(e)}`)}function Ux(t){return!(!t.repeated&&t.kind!="map")||!t.oneof&&t.kind!="message"&&!t.opt&&!t.req}function ph(t,e,n){if(t.kind=="map"){Ge(typeof e=="object"&&e!=null);const o={},r=Object.entries(e);switch(t.V.kind){case"scalar":for(const[a,l]of r)o[a.toString()]=ys(t.V.T,l);break;case"message":for(const[a,l]of r)o[a.toString()]=l.toJson(n);break;case"enum":const s=t.V.T;for(const[a,l]of r)o[a.toString()]=Ii(s,l,n.enumAsInteger)}return n.emitDefaultValues||r.length>0?o:void 0}if(t.repeated){Ge(Array.isArray(e));const o=[];switch(t.kind){case"scalar":for(let r=0;r<e.length;r++)o.push(ys(t.T,e[r]));break;case"enum":for(let r=0;r<e.length;r++)o.push(Ii(t.T,e[r],n.enumAsInteger));break;case"message":for(let r=0;r<e.length;r++)o.push(e[r].toJson(n))}return n.emitDefaultValues||o.length>0?o:void 0}switch(t.kind){case"scalar":return ys(t.T,e);case"enum":return Ii(t.T,e,n.enumAsInteger);case"message":return uh(t.T,e).toJson(n)}}function Ii(t,e,n){var o;if(Ge(typeof e=="number"),t.typeName=="google.protobuf.NullValue")return null;if(n)return e;const r=t.findNumber(e);return(o=r==null?void 0:r.name)!==null&&o!==void 0?o:e}function ys(t,e){switch(t){case K.INT32:case K.SFIXED32:case K.SINT32:case K.FIXED32:case K.UINT32:return Ge(typeof e=="number"),e;case K.FLOAT:case K.DOUBLE:return Ge(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case K.STRING:return Ge(typeof e=="string"),e;case K.BOOL:return Ge(typeof e=="boolean"),e;case K.UINT64:case K.FIXED64:case K.INT64:case K.SFIXED64:case K.SINT64:return Ge(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case K.BYTES:return Ge(e instanceof Uint8Array),gs.enc(e)}}const po=Symbol("@bufbuild/protobuf/unknown-fields"),gh={readUnknownFields:!0,readerFactory:t=>new Rx(t)},bh={writeUnknownFields:!0,writerFactory:()=>new Ox};function Wx(t){return t?Object.assign(Object.assign({},gh),t):gh}function $x(t){return t?Object.assign(Object.assign({},bh),t):bh}function xh(t,e,n,o,r){let{repeated:s,localName:a}=n;switch(n.oneof&&((t=t[n.oneof.localName]).case!=a&&delete t.value,t.case=a,a="value"),n.kind){case"scalar":case"enum":const l=n.kind=="enum"?K.INT32:n.T;let c=ws;if(n.kind=="scalar"&&n.L>0&&(c=Vx),s){let m=t[a];if(o==Je.LengthDelimited&&l!=K.STRING&&l!=K.BYTES){let p=e.uint32()+e.pos;for(;e.pos<p;)m.push(c(e,l))}else m.push(c(e,l))}else t[a]=c(e,l);break;case"message":const d=n.T;s?t[a].push(vs(e,new d,r,n)):rn(t[a])?vs(e,t[a],r,n):(t[a]=vs(e,new d,r,n),!d.fieldWrapper||n.oneof||n.repeated||(t[a]=d.fieldWrapper.unwrapField(t[a])));break;case"map":let[u,h]=(function(m,p,b){const x=p.uint32(),f=p.pos+x;let g,y;for(;p.pos<f;){const[w]=p.tag();switch(w){case 1:g=ws(p,m.K);break;case 2:switch(m.V.kind){case"scalar":y=ws(p,m.V.T);break;case"enum":y=p.int32();break;case"message":y=vs(p,new m.V.T,b,void 0)}}}if(g===void 0&&(g=fo(m.K,Dn.BIGINT)),typeof g!="string"&&typeof g!="number"&&(g=g.toString()),y===void 0)switch(m.V.kind){case"scalar":y=fo(m.V.T,Dn.BIGINT);break;case"enum":y=m.V.T.values[0].no;break;case"message":y=new m.V.T}return[g,y]})(n,e,r);t[a][u]=h}}function vs(t,e,n,o){const r=e.getType().runtime.bin,s=o==null?void 0:o.delimited;return r.readMessage(e,t,s?o.no:t.uint32(),n,s),e}function Vx(t,e){const n=ws(t,e);return typeof n=="bigint"?n.toString():n}function ws(t,e){switch(e){case K.STRING:return t.string();case K.BOOL:return t.bool();case K.DOUBLE:return t.double();case K.FLOAT:return t.float();case K.INT32:return t.int32();case K.INT64:return t.int64();case K.UINT64:return t.uint64();case K.FIXED64:return t.fixed64();case K.BYTES:return t.bytes();case K.FIXED32:return t.fixed32();case K.SFIXED32:return t.sfixed32();case K.SFIXED64:return t.sfixed64();case K.SINT64:return t.sint64();case K.UINT32:return t.uint32();case K.SINT32:return t.sint32()}}function yh(t,e,n,o){Ge(e!==void 0);const r=t.repeated;switch(t.kind){case"scalar":case"enum":let s=t.kind=="enum"?K.INT32:t.T;if(r)if(Ge(Array.isArray(e)),t.packed)(function(a,l,c,d){if(!d.length)return;a.tag(c,Je.LengthDelimited).fork();let[,u]=wh(l);for(let h=0;h<d.length;h++)a[u](d[h]);a.join()})(n,s,t.no,e);else for(const a of e)nr(n,s,t.no,a);else nr(n,s,t.no,e);break;case"message":if(r){Ge(Array.isArray(e));for(const a of e)vh(n,o,t,a)}else vh(n,o,t,e);break;case"map":Ge(typeof e=="object"&&e!=null);for(const[a,l]of Object.entries(e))Gx(n,o,t,a,l)}}function Gx(t,e,n,o,r){t.tag(n.no,Je.LengthDelimited),t.fork();let s=o;switch(n.K){case K.INT32:case K.FIXED32:case K.UINT32:case K.SFIXED32:case K.SINT32:s=Number.parseInt(o);break;case K.BOOL:Ge(o=="true"||o=="false"),s=o=="true"}switch(nr(t,n.K,1,s),n.V.kind){case"scalar":nr(t,n.V.T,2,r);break;case"enum":nr(t,K.INT32,2,r);break;case"message":Ge(r!==void 0),t.tag(2,Je.LengthDelimited).bytes(r.toBinary(e))}t.join()}function vh(t,e,n,o){const r=uh(n.T,o);n.delimited?t.tag(n.no,Je.StartGroup).raw(r.toBinary(e)).tag(n.no,Je.EndGroup):t.tag(n.no,Je.LengthDelimited).bytes(r.toBinary(e))}function nr(t,e,n,o){Ge(o!==void 0);let[r,s]=wh(e);t.tag(n,r)[s](o)}function wh(t){let e=Je.Varint;switch(t){case K.BYTES:case K.STRING:e=Je.LengthDelimited;break;case K.DOUBLE:case K.FIXED64:case K.SFIXED64:e=Je.Bit64;break;case K.FIXED32:case K.SFIXED32:case K.FLOAT:e=Je.Bit32}return[e,K[t].toLowerCase()]}function ks(t){if(t===void 0)return t;if(rn(t))return t.clone();if(t instanceof Uint8Array){const e=new Uint8Array(t.byteLength);return e.set(t),e}return t}function or(t){return t instanceof Uint8Array?t:new Uint8Array(t)}class qx{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){const n={};for(const o of this.list())n[o.jsonName]=n[o.name]=o;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){const n={};for(const o of this.list())n[o.no]=o;this.numbers=n}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,n)=>e.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let n;for(const o of this.list())o.oneof?o.oneof!==n&&(n=o.oneof,e.push(n)):e.push(o)}return this.members}}function kh(t,e){const n=jh(t);return e?n:Xx(Yx(n))}const Hx=jh;function jh(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){let r=t.charAt(o);switch(r){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(r),e=!1;break;default:e&&(e=!1,r=r.toUpperCase()),n.push(r)}}return n.join("")}const Jx=new Set(["constructor","toString","toJSON","valueOf"]),Kx=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Ch=t=>`${t}$`,Yx=t=>Kx.has(t)?Ch(t):t,Xx=t=>Jx.has(t)?Ch(t):t;class Qx{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=kh(e,!1)}addField(e){Ge(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let n=0;n<this.fields.length;n++)this._lookup[this.fields[n].localName]=this.fields[n]}return this._lookup[e]}}const Z=(Nh=t=>new qx(t,e=>(function(n){var o,r,s,a,l,c;const d=[];let u;for(const h of typeof n=="function"?n():n){const m=h;if(m.localName=kh(h.name,h.oneof!==void 0),m.jsonName=(o=h.jsonName)!==null&&o!==void 0?o:Hx(h.name),m.repeated=(r=h.repeated)!==null&&r!==void 0&&r,h.kind=="scalar"&&(m.L=(s=h.L)!==null&&s!==void 0?s:Dn.BIGINT),m.delimited=(a=h.delimited)!==null&&a!==void 0&&a,m.req=(l=h.req)!==null&&l!==void 0&&l,m.opt=(c=h.opt)!==null&&c!==void 0&&c,h.packed===void 0&&(m.packed=h.kind=="enum"||h.kind=="scalar"&&h.T!=K.BYTES&&h.T!=K.STRING),h.oneof!==void 0){const p=typeof h.oneof=="string"?h.oneof:h.oneof.name;u&&u.name==p||(u=new Qx(p)),m.oneof=u,u.addField(m)}d.push(m)}return d})(e)),Sh=t=>{for(const e of t.getType().fields.byMember()){if(e.opt)continue;const n=e.localName,o=t;if(e.repeated)o[n]=[];else switch(e.kind){case"oneof":o[n]={case:void 0};break;case"enum":o[n]=0;break;case"map":o[n]={};break;case"scalar":o[n]=fo(e.T,e.L)}}},{syntax:"proto3",json:{makeReadOptions:Bx,makeWriteOptions:Px,readMessage(t,e,n,o){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${t.typeName} from JSON: ${Gt(e)}`);o=o??new t;const r=new Map,s=n.typeRegistry;for(const[a,l]of Object.entries(e)){const c=t.fields.findJsonName(a);if(c){if(c.oneof){if(l===null&&c.kind=="scalar")continue;const d=r.get(c.oneof);if(d!==void 0)throw new Error(`cannot decode message ${t.typeName} from JSON: multiple keys for oneof "${c.oneof.name}" present: "${d}", "${a}"`);r.set(c.oneof,a)}fh(o,l,c,n,t)}else{let d=!1;if(s!=null&&s.findExtension&&a.startsWith("[")&&a.endsWith("]")){const u=s.findExtension(a.substring(1,a.length-1));if(u&&u.extendee.typeName==t.typeName){d=!0;const[h,m]=ah(u);fh(h,l,u.field,n,u),Fx(o,u,m(),n)}}if(!d&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${t.typeName} from JSON: key "${a}" is unknown`)}}return o},writeMessage(t,e){const n=t.getType(),o={};let r;try{for(r of n.fields.byNumber()){if(!ch(r,t)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!Ux(r))continue}const a=ph(r,r.oneof?t[r.oneof.localName].value:t[r.localName],e);a!==void 0&&(o[e.useProtoFieldName?r.name:r.jsonName]=a)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const a of n.runtime.bin.listUnknownFields(t)){const l=s.findExtensionFor(n.typeName,a.no);if(l&&ih(t,l)){const c=Lx(t,l,e),d=ph(l.field,c,e);d!==void 0&&(o[l.field.jsonName]=d)}}}catch(s){const a=r?`cannot encode field ${n.typeName}.${r.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,l=s instanceof Error?s.message:String(s);throw new Error(a+(l.length>0?`: ${l}`:""))}return o},readScalar:(t,e,n)=>tr(t,e,n??Dn.BIGINT,!0),writeScalar(t,e,n){if(e!==void 0)return n||sh(t,e)?ys(t,e):void 0},debug:Gt},bin:{makeReadOptions:Wx,makeWriteOptions:$x,listUnknownFields(t){var e;return(e=t[po])!==null&&e!==void 0?e:[]},discardUnknownFields(t){delete t[po]},writeUnknownFields(t,e){const n=t[po];if(n)for(const o of n)e.tag(o.no,o.wireType).raw(o.data)},onUnknownField(t,e,n,o){const r=t;Array.isArray(r[po])||(r[po]=[]),r[po].push({no:e,wireType:n,data:o})},readMessage(t,e,n,o,r){const s=t.getType(),a=r?e.len:e.pos+n;let l,c;for(;e.pos<a&&([l,c]=e.tag(),r!==!0||c!=Je.EndGroup);){const d=s.fields.find(l);if(!d){const u=e.skip(c,l);o.readUnknownFields&&this.onUnknownField(t,l,c,u);continue}xh(t,e,d,c,o)}if(r&&(c!=Je.EndGroup||l!==n))throw new Error("invalid end group tag")},readField:xh,writeMessage(t,e,n){const o=t.getType();for(const r of o.fields.byNumber())if(ch(r,t))yh(r,r.oneof?t[r.oneof.localName].value:t[r.localName],e,n);else if(r.req)throw new Error(`cannot encode field ${o.typeName}.${r.name} to binary: required field not set`);return n.writeUnknownFields&&this.writeUnknownFields(t,e),e},writeField(t,e,n,o){e!==void 0&&yh(t,e,n,o)}},util:Object.assign(Object.assign({},{setEnumType:Xu,initPartial(t,e){if(t===void 0)return;const n=e.getType();for(const o of n.fields.byMember()){const r=o.localName,s=e,a=t;if(a[r]!=null)switch(o.kind){case"oneof":const l=a[r].case;if(l===void 0)continue;const c=o.findField(l);let d=a[r].value;c&&c.kind=="message"&&!rn(d,c.T)?d=new c.T(d):c&&c.kind==="scalar"&&c.T===K.BYTES&&(d=or(d)),s[r]={case:l,value:d};break;case"scalar":case"enum":let u=a[r];o.T===K.BYTES&&(u=o.repeated?u.map(or):or(u)),s[r]=u;break;case"map":switch(o.V.kind){case"scalar":case"enum":if(o.V.T===K.BYTES)for(const[p,b]of Object.entries(a[r]))s[r][p]=or(b);else Object.assign(s[r],a[r]);break;case"message":const m=o.V.T;for(const p of Object.keys(a[r])){let b=a[r][p];m.fieldWrapper||(b=new m(b)),s[r][p]=b}}break;case"message":const h=o.T;if(o.repeated)s[r]=a[r].map(m=>rn(m,h)?m:new h(m));else{const m=a[r];h.fieldWrapper?h.typeName==="google.protobuf.BytesValue"?s[r]=or(m):s[r]=m:s[r]=rn(m,h)?m:new h(m)}}}},equals:(t,e,n)=>e===n||!(!e||!n)&&t.fields.byMember().every(o=>{const r=e[o.localName],s=n[o.localName];if(o.repeated){if(r.length!==s.length)return!1;switch(o.kind){case"message":return r.every((a,l)=>o.T.equals(a,s[l]));case"scalar":return r.every((a,l)=>Mn(o.T,a,s[l]));case"enum":return r.every((a,l)=>Mn(K.INT32,a,s[l]))}throw new Error(`repeated cannot contain ${o.kind}`)}switch(o.kind){case"message":let a=r,l=s;return o.T.fieldWrapper&&(a===void 0||rn(a)||(a=o.T.fieldWrapper.wrapField(a)),l===void 0||rn(l)||(l=o.T.fieldWrapper.wrapField(l))),o.T.equals(a,l);case"enum":return Mn(K.INT32,r,s);case"scalar":return Mn(o.T,r,s);case"oneof":if(r.case!==s.case)return!1;const c=o.findField(r.case);if(c===void 0)return!0;switch(c.kind){case"message":return c.T.equals(r.value,s.value);case"enum":return Mn(K.INT32,r.value,s.value);case"scalar":return Mn(c.T,r.value,s.value)}throw new Error(`oneof cannot contain ${c.kind}`);case"map":const d=Object.keys(r).concat(Object.keys(s));switch(o.V.kind){case"message":const u=o.V.T;return d.every(m=>u.equals(r[m],s[m]));case"enum":return d.every(m=>Mn(K.INT32,r[m],s[m]));case"scalar":const h=o.V.T;return d.every(m=>Mn(h,r[m],s[m]))}}}),clone(t){const e=t.getType(),n=new e,o=n;for(const r of e.fields.byMember()){const s=t[r.localName];let a;if(r.repeated)a=s.map(ks);else if(r.kind=="map"){a=o[r.localName];for(const[l,c]of Object.entries(s))a[l]=ks(c)}else a=r.kind=="oneof"?r.findField(s.case)?{case:s.case,value:ks(s.value)}:{case:void 0}:ks(s);o[r.localName]=a}for(const r of e.runtime.bin.listUnknownFields(t))e.runtime.bin.onUnknownField(o,r.no,r.wireType,r.data);return n}}),{newFieldList:Nh,initFields:Sh}),makeMessageType(t,e,n){return(function(o,r,s,a){var l;const c=(l=a==null?void 0:a.localName)!==null&&l!==void 0?l:r.substring(r.lastIndexOf(".")+1),d={[c]:function(u){o.util.initFields(this),o.util.initPartial(u,this)}}[c];return Object.setPrototypeOf(d.prototype,new Xe),Object.assign(d,{runtime:o,typeName:r,fields:o.util.newFieldList(s),fromBinary:(u,h)=>new d().fromBinary(u,h),fromJson:(u,h)=>new d().fromJson(u,h),fromJsonString:(u,h)=>new d().fromJsonString(u,h),equals:(u,h)=>o.util.equals(d,u,h)}),d})(this,t,e,n)},makeEnum:Ax,makeEnumType:Qu,getEnumType:Ix,makeExtension(t,e,n){return(function(o,r,s,a){let l;return{typeName:r,extendee:s,get field(){if(!l){const c=typeof a=="function"?a():a;c.name=r.split(".").pop(),c.jsonName=`[${r}]`,l=o.util.newFieldList([c]).list()[0]}return l},runtime:o}})(this,t,e,n)}});var Nh,Sh,It,Ai,js,rr,Cs,sr,On;(function(t){t[t.Unary=0]="Unary",t[t.ServerStreaming=1]="ServerStreaming",t[t.ClientStreaming=2]="ClientStreaming",t[t.BiDiStreaming=3]="BiDiStreaming"})(It||(It={})),(function(t){t[t.NoSideEffects=1]="NoSideEffects",t[t.Idempotent=2]="Idempotent"})(Ai||(Ai={})),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.JUPYTER_FORMAT=77]="JUPYTER_FORMAT"})(js||(js={})),Z.util.setEnumType(js,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]),(function(t){t[t.CODEIUM=0]="CODEIUM"})(rr||(rr={})),Z.util.setEnumType(rr,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",t[t.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",t[t.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",t[t.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION"})(Cs||(Cs={})),Z.util.setEnumType(Cs,"exa.codeium_common_pb.EventType",[{no:0,name:"EVENT_TYPE_UNSPECIFIED"},{no:1,name:"EVENT_TYPE_ENABLE_CODEIUM"},{no:2,name:"EVENT_TYPE_DISABLE_CODEIUM"},{no:3,name:"EVENT_TYPE_SHOW_PREVIOUS_COMPLETION"},{no:4,name:"EVENT_TYPE_SHOW_NEXT_COMPLETION"}]),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",t[t.CACHE=2]="CACHE",t[t.NETWORK=3]="NETWORK"})(sr||(sr={})),Z.util.setEnumType(sr,"exa.codeium_common_pb.CompletionSource",[{no:0,name:"COMPLETION_SOURCE_UNSPECIFIED"},{no:1,name:"COMPLETION_SOURCE_TYPING_AS_SUGGESTED"},{no:2,name:"COMPLETION_SOURCE_CACHE"},{no:3,name:"COMPLETION_SOURCE_NETWORK"}]),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.C=1]="C",t[t.CLOJURE=2]="CLOJURE",t[t.COFFEESCRIPT=3]="COFFEESCRIPT",t[t.CPP=4]="CPP",t[t.CSHARP=5]="CSHARP",t[t.CSS=6]="CSS",t[t.CUDACPP=7]="CUDACPP",t[t.DOCKERFILE=8]="DOCKERFILE",t[t.GO=9]="GO",t[t.GROOVY=10]="GROOVY",t[t.HANDLEBARS=11]="HANDLEBARS",t[t.HASKELL=12]="HASKELL",t[t.HCL=13]="HCL",t[t.HTML=14]="HTML",t[t.INI=15]="INI",t[t.JAVA=16]="JAVA",t[t.JAVASCRIPT=17]="JAVASCRIPT",t[t.JSON=18]="JSON",t[t.JULIA=19]="JULIA",t[t.KOTLIN=20]="KOTLIN",t[t.LATEX=21]="LATEX",t[t.LESS=22]="LESS",t[t.LUA=23]="LUA",t[t.MAKEFILE=24]="MAKEFILE",t[t.MARKDOWN=25]="MARKDOWN",t[t.OBJECTIVEC=26]="OBJECTIVEC",t[t.OBJECTIVECPP=27]="OBJECTIVECPP",t[t.PERL=28]="PERL",t[t.PHP=29]="PHP",t[t.PLAINTEXT=30]="PLAINTEXT",t[t.PROTOBUF=31]="PROTOBUF",t[t.PBTXT=32]="PBTXT",t[t.PYTHON=33]="PYTHON",t[t.R=34]="R",t[t.RUBY=35]="RUBY",t[t.RUST=36]="RUST",t[t.SASS=37]="SASS",t[t.SCALA=38]="SCALA",t[t.SCSS=39]="SCSS",t[t.SHELL=40]="SHELL",t[t.SQL=41]="SQL",t[t.STARLARK=42]="STARLARK",t[t.SWIFT=43]="SWIFT",t[t.TSX=44]="TSX",t[t.TYPESCRIPT=45]="TYPESCRIPT",t[t.VISUALBASIC=46]="VISUALBASIC",t[t.VUE=47]="VUE",t[t.XML=48]="XML",t[t.XSL=49]="XSL",t[t.YAML=50]="YAML",t[t.SVELTE=51]="SVELTE",t[t.TOML=52]="TOML",t[t.DART=53]="DART",t[t.RST=54]="RST",t[t.OCAML=55]="OCAML",t[t.CMAKE=56]="CMAKE",t[t.PASCAL=57]="PASCAL",t[t.ELIXIR=58]="ELIXIR",t[t.FSHARP=59]="FSHARP",t[t.LISP=60]="LISP",t[t.MATLAB=61]="MATLAB",t[t.POWERSHELL=62]="POWERSHELL",t[t.SOLIDITY=63]="SOLIDITY",t[t.ADA=64]="ADA",t[t.OCAML_INTERFACE=65]="OCAML_INTERFACE"})(On||(On={})),Z.util.setEnumType(On,"exa.codeium_common_pb.Language",[{no:0,name:"LANGUAGE_UNSPECIFIED"},{no:1,name:"LANGUAGE_C"},{no:2,name:"LANGUAGE_CLOJURE"},{no:3,name:"LANGUAGE_COFFEESCRIPT"},{no:4,name:"LANGUAGE_CPP"},{no:5,name:"LANGUAGE_CSHARP"},{no:6,name:"LANGUAGE_CSS"},{no:7,name:"LANGUAGE_CUDACPP"},{no:8,name:"LANGUAGE_DOCKERFILE"},{no:9,name:"LANGUAGE_GO"},{no:10,name:"LANGUAGE_GROOVY"},{no:11,name:"LANGUAGE_HANDLEBARS"},{no:12,name:"LANGUAGE_HASKELL"},{no:13,name:"LANGUAGE_HCL"},{no:14,name:"LANGUAGE_HTML"},{no:15,name:"LANGUAGE_INI"},{no:16,name:"LANGUAGE_JAVA"},{no:17,name:"LANGUAGE_JAVASCRIPT"},{no:18,name:"LANGUAGE_JSON"},{no:19,name:"LANGUAGE_JULIA"},{no:20,name:"LANGUAGE_KOTLIN"},{no:21,name:"LANGUAGE_LATEX"},{no:22,name:"LANGUAGE_LESS"},{no:23,name:"LANGUAGE_LUA"},{no:24,name:"LANGUAGE_MAKEFILE"},{no:25,name:"LANGUAGE_MARKDOWN"},{no:26,name:"LANGUAGE_OBJECTIVEC"},{no:27,name:"LANGUAGE_OBJECTIVECPP"},{no:28,name:"LANGUAGE_PERL"},{no:29,name:"LANGUAGE_PHP"},{no:30,name:"LANGUAGE_PLAINTEXT"},{no:31,name:"LANGUAGE_PROTOBUF"},{no:32,name:"LANGUAGE_PBTXT"},{no:33,name:"LANGUAGE_PYTHON"},{no:34,name:"LANGUAGE_R"},{no:35,name:"LANGUAGE_RUBY"},{no:36,name:"LANGUAGE_RUST"},{no:37,name:"LANGUAGE_SASS"},{no:38,name:"LANGUAGE_SCALA"},{no:39,name:"LANGUAGE_SCSS"},{no:40,name:"LANGUAGE_SHELL"},{no:41,name:"LANGUAGE_SQL"},{no:42,name:"LANGUAGE_STARLARK"},{no:43,name:"LANGUAGE_SWIFT"},{no:44,name:"LANGUAGE_TSX"},{no:45,name:"LANGUAGE_TYPESCRIPT"},{no:46,name:"LANGUAGE_VISUALBASIC"},{no:47,name:"LANGUAGE_VUE"},{no:48,name:"LANGUAGE_XML"},{no:49,name:"LANGUAGE_XSL"},{no:50,name:"LANGUAGE_YAML"},{no:51,name:"LANGUAGE_SVELTE"},{no:52,name:"LANGUAGE_TOML"},{no:53,name:"LANGUAGE_DART"},{no:54,name:"LANGUAGE_RST"},{no:55,name:"LANGUAGE_OCAML"},{no:56,name:"LANGUAGE_CMAKE"},{no:57,name:"LANGUAGE_PASCAL"},{no:58,name:"LANGUAGE_ELIXIR"},{no:59,name:"LANGUAGE_FSHARP"},{no:60,name:"LANGUAGE_LISP"},{no:61,name:"LANGUAGE_MATLAB"},{no:62,name:"LANGUAGE_POWERSHELL"},{no:63,name:"LANGUAGE_SOLIDITY"},{no:64,name:"LANGUAGE_ADA"},{no:65,name:"LANGUAGE_OCAML_INTERFACE"}]);const an=class an extends Xe{constructor(n){super();B(this,"completionId","");B(this,"text","");B(this,"prefix","");B(this,"stop","");B(this,"score",0);B(this,"tokens",[]);B(this,"decodedTokens",[]);B(this,"probabilities",[]);B(this,"adjustedProbabilities",[]);B(this,"generatedLength",We.zero);Z.util.initPartial(n,this)}static fromBinary(n,o){return new an().fromBinary(n,o)}static fromJson(n,o){return new an().fromJson(n,o)}static fromJsonString(n,o){return new an().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(an,n,o)}};B(an,"runtime",Z),B(an,"typeName","exa.codeium_common_pb.Completion"),B(an,"fields",Z.util.newFieldList(()=>[{no:1,name:"completion_id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"prefix",kind:"scalar",T:9},{no:4,name:"stop",kind:"scalar",T:9},{no:5,name:"score",kind:"scalar",T:1},{no:6,name:"tokens",kind:"scalar",T:4,repeated:!0},{no:7,name:"decoded_tokens",kind:"scalar",T:9,repeated:!0},{no:8,name:"probabilities",kind:"scalar",T:1,repeated:!0},{no:9,name:"adjusted_probabilities",kind:"scalar",T:1,repeated:!0},{no:10,name:"generated_length",kind:"scalar",T:4}]));let Ti=an;const ln=class ln extends Xe{constructor(n){super();B(this,"ideName","");B(this,"ideVersion","");B(this,"extensionName","");B(this,"extensionVersion","");B(this,"apiKey","");B(this,"locale","");B(this,"sessionId","");B(this,"requestId",We.zero);B(this,"userAgent","");B(this,"url","");B(this,"authSource",rr.CODEIUM);Z.util.initPartial(n,this)}static fromBinary(n,o){return new ln().fromBinary(n,o)}static fromJson(n,o){return new ln().fromJson(n,o)}static fromJsonString(n,o){return new ln().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(ln,n,o)}};B(ln,"runtime",Z),B(ln,"typeName","exa.codeium_common_pb.Metadata"),B(ln,"fields",Z.util.newFieldList(()=>[{no:1,name:"ide_name",kind:"scalar",T:9},{no:7,name:"ide_version",kind:"scalar",T:9},{no:12,name:"extension_name",kind:"scalar",T:9},{no:2,name:"extension_version",kind:"scalar",T:9},{no:3,name:"api_key",kind:"scalar",T:9},{no:4,name:"locale",kind:"scalar",T:9},{no:10,name:"session_id",kind:"scalar",T:9},{no:9,name:"request_id",kind:"scalar",T:4},{no:13,name:"user_agent",kind:"scalar",T:9},{no:14,name:"url",kind:"scalar",T:9},{no:15,name:"auth_source",kind:"enum",T:Z.getEnumType(rr)}]));let Ns=ln;const cn=class cn extends Xe{constructor(n){super();B(this,"tabSize",We.zero);B(this,"insertSpaces",!1);Z.util.initPartial(n,this)}static fromBinary(n,o){return new cn().fromBinary(n,o)}static fromJson(n,o){return new cn().fromJson(n,o)}static fromJsonString(n,o){return new cn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(cn,n,o)}};B(cn,"runtime",Z),B(cn,"typeName","exa.codeium_common_pb.EditorOptions"),B(cn,"fields",Z.util.newFieldList(()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}]));let Di=cn;Z.util.newFieldList(()=>[{no:1,name:"event_type",kind:"enum",T:Z.getEnumType(Cs)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}]);class Zx extends So{constructor(n,o){super();B(this,"index");B(this,"total");this.index=n,this.total=o}toDOM(){const n=document.createElement("span");n.setAttribute("aria-hidden","true"),n.className="cm-codeium-cycle";const o=n.appendChild(document.createElement("span"));o.className="cm-codeium-cycle-explanation",o.innerText=`${this.index+1}/${this.total}`;const r=n.appendChild(document.createElement("button"));return r.className="cm-codeium-cycle-key",r.innerText="\u2192 (Ctrl ])",r.dataset.action="codeium-cycle",n}ignoreEvent(){return!1}}const Ss=ro.define({combine:t=>qs(t,{language:On.TYPESCRIPT,timeout:150,widgetClass:Zx,alwaysOn:!0},{})}),Eh=ro.define({combine:t=>qs(t,{override:()=>[]},{})}),e2=Te.mark({class:"cm-ghostText"}),Qn=Dt.define({create:t=>null,update(t,e){var o;const n=e.state.facet(Ss);for(const r of e.effects){if(r.is(ki)){const{changeSpecs:s,index:a}=r.value,l=s[a].map(d=>e2.range(d.absoluteStartPos,d.absoluteEndPos)),c=(o=l.at(-1))==null?void 0:o.to;return{index:a,decorations:Te.set([...l,...c!==void 0&&s.length>1&&n.widgetClass?[Te.widget({widget:new n.widgetClass(a,s.length),side:1}).range(c)]:[]]),changeSpecs:s,reverseChangeSet:r.value.reverseChangeSet}}if(r.is(ji)||r.is(Ci))return null}return t&&{...t,decorations:t.decorations.map(e.changes),reverseChangeSet:t.reverseChangeSet.map(e.changes)}},provide:t=>Se.decorations.from(t,e=>(e==null?void 0:e.decorations)||Te.none)}),go=ac.define(),Es=ac.define();var Pe;function Mi(t){const e=Pe[t];return typeof e!="string"?t.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,n=>"_"+n.toLowerCase())}let _s;(function(t){t[t.Canceled=1]="Canceled",t[t.Unknown=2]="Unknown",t[t.InvalidArgument=3]="InvalidArgument",t[t.DeadlineExceeded=4]="DeadlineExceeded",t[t.NotFound=5]="NotFound",t[t.AlreadyExists=6]="AlreadyExists",t[t.PermissionDenied=7]="PermissionDenied",t[t.ResourceExhausted=8]="ResourceExhausted",t[t.FailedPrecondition=9]="FailedPrecondition",t[t.Aborted=10]="Aborted",t[t.OutOfRange=11]="OutOfRange",t[t.Unimplemented=12]="Unimplemented",t[t.Internal=13]="Internal",t[t.Unavailable=14]="Unavailable",t[t.DataLoss=15]="DataLoss",t[t.Unauthenticated=16]="Unauthenticated"})(Pe||(Pe={}));class Qe extends Error{constructor(e,n=Pe.Unknown,o,r,s){super((function(a,l){return a.length?`[${Mi(l)}] ${a}`:`[${Mi(l)}]`})(e,n)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=n,this.metadata=new Headers(o??{}),this.details=r??[],this.cause=s}static from(e,n=Pe.Unknown){return e instanceof Qe?e:e instanceof Error?e.name=="AbortError"?new Qe(e.message,Pe.Canceled):new Qe(e.message,n,void 0,void 0,e):new Qe(String(e),n,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error&&(Object.getPrototypeOf(e)===Qe.prototype||e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e)}findDetails(e){const n="typeName"in e?{findMessage:r=>r===e.typeName?e:void 0}:e,o=[];for(const r of this.details){if("getType"in r){n.findMessage(r.getType().typeName)&&o.push(r);continue}const s=n.findMessage(r.type);if(s)try{o.push(s.fromBinary(r.value))}catch{}}return o}}var t2=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(r){e[r]=t[r]&&function(s){return new Promise(function(a,l){(function(c,d,u,h){Promise.resolve(h).then(function(m){c({value:m,done:u})},d)})(a,l,(s=t[r](s)).done,s.value)})}}},ar=function(t){return this instanceof ar?(this.v=t,this):new ar(t)},n2=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},a("next"),a("throw"),a("return",function(h){return function(m){return Promise.resolve(m).then(h,d)}}),o[Symbol.asyncIterator]=function(){return this},o;function a(h,m){r[h]&&(o[h]=function(p){return new Promise(function(b,x){s.push([h,p,b,x])>1||l(h,p)})},m&&(o[h]=m(o[h])))}function l(h,m){try{(p=r[h](m)).value instanceof ar?Promise.resolve(p.value.v).then(c,d):u(s[0][2],p)}catch(b){u(s[0][3],b)}var p}function c(h){l("next",h)}function d(h){l("throw",h)}function u(h,m){h(m),s.shift(),s.length&&l(s[0][0],s[0][1])}},o2=function(t){var e,n;return e={},o("next"),o("throw",function(r){throw r}),o("return"),e[Symbol.iterator]=function(){return this},e;function o(r,s){e[r]=t[r]?function(a){return(n=!n)?{value:ar(t[r](a)),done:!1}:s?s(a):a}:s}},_h=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(r){e[r]=t[r]&&function(s){return new Promise(function(a,l){(function(c,d,u,h){Promise.resolve(h).then(function(m){c({value:m,done:u})},d)})(a,l,(s=t[r](s)).done,s.value)})}}},bo=function(t){return this instanceof bo?(this.v=t,this):new bo(t)},r2=function(t){var e,n;return e={},o("next"),o("throw",function(r){throw r}),o("return"),e[Symbol.iterator]=function(){return this},e;function o(r,s){e[r]=t[r]?function(a){return(n=!n)?{value:bo(t[r](a)),done:!1}:s?s(a):a}:s}},s2=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},a("next"),a("throw"),a("return",function(h){return function(m){return Promise.resolve(m).then(h,d)}}),o[Symbol.asyncIterator]=function(){return this},o;function a(h,m){r[h]&&(o[h]=function(p){return new Promise(function(b,x){s.push([h,p,b,x])>1||l(h,p)})},m&&(o[h]=m(o[h])))}function l(h,m){try{(p=r[h](m)).value instanceof bo?Promise.resolve(p.value.v).then(c,d):u(s[0][2],p)}catch(b){u(s[0][3],b)}var p}function c(h){l("next",h)}function d(h){l("throw",h)}function u(h,m){h(m),s.shift(),s.length&&l(s[0][0],s[0][1])}};function a2(t,e){return(function(n,o){const r={};for(const[s,a]of Object.entries(n.methods)){const l=o(Object.assign(Object.assign({},a),{localName:s,service:n}));l!=null&&(r[s]=l)}return r})(t,n=>{switch(n.kind){case It.Unary:return(function(o,r,s){return async function(a,l){var c,d;const u=await o.unary(r,s,l==null?void 0:l.signal,l==null?void 0:l.timeoutMs,l==null?void 0:l.headers,a,l==null?void 0:l.contextValues);return(c=l==null?void 0:l.onHeader)===null||c===void 0||c.call(l,u.header),(d=l==null?void 0:l.onTrailer)===null||d===void 0||d.call(l,u.trailer),u.message}})(e,t,n);case It.ServerStreaming:return(function(o,r,s){return function(a,l){return Ih(o.stream(r,s,l==null?void 0:l.signal,l==null?void 0:l.timeoutMs,l==null?void 0:l.headers,(function(c){return n2(this,arguments,function*(){yield ar(yield*o2(t2(c)))})})([a]),l==null?void 0:l.contextValues),l)}})(e,t,n);case It.ClientStreaming:return(function(o,r,s){return async function(a,l){var c,d,u,h,m,p;const b=await o.stream(r,s,l==null?void 0:l.signal,l==null?void 0:l.timeoutMs,l==null?void 0:l.headers,a,l==null?void 0:l.contextValues);let x;(m=l==null?void 0:l.onHeader)===null||m===void 0||m.call(l,b.header);let f=0;try{for(var g,y=!0,w=_h(b.message);!(c=(g=await w.next()).done);y=!0)h=g.value,y=!1,x=h,f++}catch(j){d={error:j}}finally{try{y||c||!(u=w.return)||await u.call(w)}finally{if(d)throw d.error}}if(!x)throw new Qe("protocol error: missing response message",Pe.Unimplemented);if(f>1)throw new Qe("protocol error: received extra messages for client streaming method",Pe.Unimplemented);return(p=l==null?void 0:l.onTrailer)===null||p===void 0||p.call(l,b.trailer),x}})(e,t,n);case It.BiDiStreaming:return(function(o,r,s){return function(a,l){return Ih(o.stream(r,s,l==null?void 0:l.signal,l==null?void 0:l.timeoutMs,l==null?void 0:l.headers,a,l==null?void 0:l.contextValues),l)}})(e,t,n);default:return null}})}function Ih(t,e){const n=(function(){return s2(this,arguments,function*(){var o,r;const s=yield bo(t);(o=e==null?void 0:e.onHeader)===null||o===void 0||o.call(e,s.header),yield bo(yield*r2(_h(s.message))),(r=e==null?void 0:e.onTrailer)===null||r===void 0||r.call(e,s.trailer)})})()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function Ah(t){if(!t.aborted)return;if(t.reason!==void 0)return t.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function Th(){return{get(t){return t.id in this?this[t.id]:t.defaultValue},set(t,e){return this[t.id]=e,this},delete(t){return delete this[t.id],this}}}function Dh(t,e,n){const o=typeof e=="string"?e:e.typeName,r=typeof n=="string"?n:n.name;return t.toString().replace(/\/?$/,`/${o}/${r}`)}function Mh(t,e){return e instanceof t?e:new t(e)}function i2(t,e){function n(o){return o.done===!0?o:{done:o.done,value:Mh(t,o.value)}}return{[Symbol.asyncIterator](){const o=e[Symbol.asyncIterator](),r={next:()=>o.next().then(n)};return o.throw!==void 0&&(r.throw=s=>o.throw(s).then(n)),o.return!==void 0&&(r.return=s=>o.return(s).then(n)),r}}}function Oh(t,e){var n;return(n=e==null?void 0:e.concat().reverse().reduce((o,r)=>r(o),t))!==null&&n!==void 0?n:t}function Rh(t){var e;const n=Object.assign({},t);return(e=n.ignoreUnknownFields)!==null&&e!==void 0||(n.ignoreUnknownFields=!0),n}function Lh(t,e,n,o){const r=e?Fh(t.I,o):Bh(t.I,n);return{parse:(e?Fh(t.O,o):Bh(t.O,n)).parse,serialize:r.serialize}}function Fh(t,e){return{parse(n){try{return t.fromBinary(n,e)}catch(o){const r=o instanceof Error?o.message:String(o);throw new Qe(`parse binary: ${r}`,Pe.Internal)}},serialize(n){try{return n.toBinary(e)}catch(o){const r=o instanceof Error?o.message:String(o);throw new Qe(`serialize binary: ${r}`,Pe.Internal)}}}}function Bh(t,e){var n,o;const r=(n=e==null?void 0:e.textEncoder)!==null&&n!==void 0?n:new TextEncoder,s=(o=e==null?void 0:e.textDecoder)!==null&&o!==void 0?o:new TextDecoder,a=Rh(e);return{parse(l){try{const c=s.decode(l);return t.fromJsonString(c,a)}catch(c){throw Qe.from(c,Pe.InvalidArgument)}},serialize(l){try{const c=l.toJsonString(a);return r.encode(c)}catch(c){throw Qe.from(c,Pe.Internal)}}}}const l2=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function Ph(t,e,n){var o;if(e&&new Headers(e).forEach((l,c)=>n.metadata.append(c,l)),typeof t!="object"||t==null||Array.isArray(t))throw n;let r=n.code;"code"in t&&typeof t.code=="string"&&(r=(o=(function(l){if(!_s){_s={};for(const c of Object.values(Pe))typeof c!="string"&&(_s[Mi(c)]=c)}return _s[l]})(t.code))!==null&&o!==void 0?o:r);const s=t.message;if(s!=null&&typeof s!="string")throw n;const a=new Qe(s??"",r,e);if("details"in t&&Array.isArray(t.details))for(const l of t.details){if(l===null||typeof l!="object"||Array.isArray(l)||typeof l.type!="string"||typeof l.value!="string")throw n;try{a.details.push({type:l.type,value:gs.dec(l.value),debug:l.debug})}catch{throw n}}return a}function c2(t){const e=new Qe("invalid end stream",Pe.Unknown);let n;try{n=JSON.parse(typeof t=="string"?t:new TextDecoder().decode(t))}catch{throw e}if(typeof n!="object"||n==null||Array.isArray(n))throw e;const o=new Headers;if("metadata"in n){if(typeof n.metadata!="object"||n.metadata==null||Array.isArray(n.metadata))throw e;for(const[r,s]of Object.entries(n.metadata)){if(!Array.isArray(s)||s.some(a=>typeof a!="string"))throw e;for(const a of s)o.append(r,a)}}return{metadata:o,error:"error"in n&&n.error!=null?Ph(n.error,o,e):void 0}}const Is="Content-Type",d2="Content-Length",zh="Content-Encoding",u2="Accept-Encoding",Uh="Connect-Protocol-Version";function Wh(t){const e=new Headers,n=new Headers;return t.forEach((o,r)=>{r.toLowerCase().startsWith("trailer-")?n.append(r.substring(8),o):e.append(r,o)}),[e,n]}function $h(t,e,n,o,r){const s=new Headers(o??{});return n!==void 0&&s.set("Connect-Timeout-Ms",`${n}`),s.set(Is,t==It.Unary?e?"application/proto":"application/json":e?"application/connect+proto":"application/connect+json"),s.set(Uh,"1"),s}function Vh(t,e,n,o){const r=o.get(Is),s=(function(c){const d=c==null?void 0:c.match(l2);if(d)return{stream:!!d[1],binary:!!d[3]}})(r);if(n!==200){const c=new Qe(`HTTP ${n}`,(function(d){switch(d){case 400:return Pe.Internal;case 401:return Pe.Unauthenticated;case 403:return Pe.PermissionDenied;case 404:return Pe.Unimplemented;case 429:case 502:case 503:case 504:return Pe.Unavailable;default:return Pe.Unknown}})(n),o);if(t==It.Unary&&s&&!s.binary)return{isUnaryError:!0,unaryError:c};throw c}const a=e,l=t!==It.Unary;if((s==null?void 0:s.binary)!==a||s.stream!==l)throw new Qe(`unsupported content type ${r}`,s===void 0?Pe.Unknown:Pe.Internal,o);return{isUnaryError:!1}}const h2="application/";function m2(t,e,n){let o="?connect=v1";const r=t.header.get(Is);(r==null?void 0:r.indexOf(h2))===0&&(o+="&encoding="+encodeURIComponent(r.slice(12)));const s=t.header.get(zh);s!==null&&s!=="identity"&&(o+="&compression="+encodeURIComponent(s),n=!0),n&&(o+="&base64=1"),o+="&message="+(function(c,d){return d?gs.enc(c).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent(new TextDecoder().decode(c))})(e,n);const a=t.url+o,l=new Headers(t.header);return[Uh,Is,d2,zh,u2].forEach(c=>l.delete(c)),Object.assign(Object.assign({},t),{init:Object.assign(Object.assign({},t.init),{method:"GET"}),url:a,header:l})}function Gh(t){const{signal:e,cleanup:n}=(function(r){const s=new AbortController,a=()=>{s.abort(new Qe("the operation timed out",Pe.DeadlineExceeded))};let l;return r!==void 0&&(r<=0?a():l=setTimeout(a,r)),{signal:s.signal,cleanup:()=>clearTimeout(l)}})(t.timeoutMs),o=(function(...r){const s=new AbortController,a=r.filter(c=>c!==void 0).concat(s.signal);for(const c of a){if(c.aborted){l.apply(c);break}c.addEventListener("abort",l)}function l(){s.signal.aborted||s.abort(Ah(this));for(const c of a)c.removeEventListener("abort",l)}return s})(t.signal,e);return[o.signal,function(r){const s=Qe.from(e.aborted?Ah(e):r);return o.abort(s),n(),Promise.reject(s)},function(){n(),o.abort()}]}var ir,Oi,lr;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.INACTIVE=1]="INACTIVE",t[t.PROCESSING=2]="PROCESSING",t[t.SUCCESS=3]="SUCCESS",t[t.WARNING=4]="WARNING",t[t.ERROR=5]="ERROR"})(ir||(ir={})),Z.util.setEnumType(ir,"exa.language_server_pb.CodeiumState",[{no:0,name:"CODEIUM_STATE_UNSPECIFIED"},{no:1,name:"CODEIUM_STATE_INACTIVE"},{no:2,name:"CODEIUM_STATE_PROCESSING"},{no:3,name:"CODEIUM_STATE_SUCCESS"},{no:4,name:"CODEIUM_STATE_WARNING"},{no:5,name:"CODEIUM_STATE_ERROR"}]),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SINGLE=1]="SINGLE",t[t.MULTI=2]="MULTI"})(Oi||(Oi={})),Z.util.setEnumType(Oi,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]),(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.INLINE=1]="INLINE",t[t.BLOCK=2]="BLOCK",t[t.INLINE_MASK=3]="INLINE_MASK"})(lr||(lr={})),Z.util.setEnumType(lr,"exa.language_server_pb.CompletionPartType",[{no:0,name:"COMPLETION_PART_TYPE_UNSPECIFIED"},{no:1,name:"COMPLETION_PART_TYPE_INLINE"},{no:2,name:"COMPLETION_PART_TYPE_BLOCK"},{no:3,name:"COMPLETION_PART_TYPE_INLINE_MASK"}]);const dn=class dn extends Xe{constructor(n){super();B(this,"threshold",0);Z.util.initPartial(n,this)}static fromBinary(n,o){return new dn().fromBinary(n,o)}static fromJson(n,o){return new dn().fromJson(n,o)}static fromJsonString(n,o){return new dn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(dn,n,o)}};B(dn,"runtime",Z),B(dn,"typeName","exa.language_server_pb.MultilineConfig"),B(dn,"fields",Z.util.newFieldList(()=>[{no:1,name:"threshold",kind:"scalar",T:2}]));let Ri=dn;const un=class un extends Xe{constructor(n){super();B(this,"metadata");B(this,"document");B(this,"editorOptions");B(this,"otherDocuments",[]);B(this,"experimentConfig");B(this,"modelName","");B(this,"multilineConfig");Z.util.initPartial(n,this)}static fromBinary(n,o){return new un().fromBinary(n,o)}static fromJson(n,o){return new un().fromJson(n,o)}static fromJsonString(n,o){return new un().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(un,n,o)}};B(un,"runtime",Z),B(un,"typeName","exa.language_server_pb.GetCompletionsRequest"),B(un,"fields",Z.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:Ns},{no:2,name:"document",kind:"message",T:As},{no:3,name:"editor_options",kind:"message",T:Di},{no:5,name:"other_documents",kind:"message",T:As,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:Wi},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:Ri}]));let Li=un;const hn=class hn extends Xe{constructor(n){super();B(this,"state");B(this,"completionItems",[]);Z.util.initPartial(n,this)}static fromBinary(n,o){return new hn().fromBinary(n,o)}static fromJson(n,o){return new hn().fromJson(n,o)}static fromJsonString(n,o){return new hn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(hn,n,o)}};B(hn,"runtime",Z),B(hn,"typeName","exa.language_server_pb.GetCompletionsResponse"),B(hn,"fields",Z.util.newFieldList(()=>[{no:1,name:"state",kind:"message",T:$i},{no:2,name:"completion_items",kind:"message",T:Hi,repeated:!0}]));let Fi=hn;const mn=class mn extends Xe{constructor(n){super();B(this,"metadata");B(this,"completionId","");Z.util.initPartial(n,this)}static fromBinary(n,o){return new mn().fromBinary(n,o)}static fromJson(n,o){return new mn().fromJson(n,o)}static fromJsonString(n,o){return new mn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(mn,n,o)}};B(mn,"runtime",Z),B(mn,"typeName","exa.language_server_pb.AcceptCompletionRequest"),B(mn,"fields",Z.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:Ns},{no:2,name:"completion_id",kind:"scalar",T:9}]));let Bi=mn;const fn=class fn extends Xe{constructor(e){super(),Z.util.initPartial(e,this)}static fromBinary(e,n){return new fn().fromBinary(e,n)}static fromJson(e,n){return new fn().fromJson(e,n)}static fromJsonString(e,n){return new fn().fromJsonString(e,n)}static equals(e,n){return Z.util.equals(fn,e,n)}};B(fn,"runtime",Z),B(fn,"typeName","exa.language_server_pb.AcceptCompletionResponse"),B(fn,"fields",Z.util.newFieldList(()=>[]));let Pi=fn;const pn=class pn extends Xe{constructor(e){super(),Z.util.initPartial(e,this)}static fromBinary(e,n){return new pn().fromBinary(e,n)}static fromJson(e,n){return new pn().fromJson(e,n)}static fromJsonString(e,n){return new pn().fromJsonString(e,n)}static equals(e,n){return Z.util.equals(pn,e,n)}};B(pn,"runtime",Z),B(pn,"typeName","exa.language_server_pb.GetAuthTokenRequest"),B(pn,"fields",Z.util.newFieldList(()=>[]));let zi=pn;const gn=class gn extends Xe{constructor(n){super();B(this,"authToken","");B(this,"uuid","");Z.util.initPartial(n,this)}static fromBinary(n,o){return new gn().fromBinary(n,o)}static fromJson(n,o){return new gn().fromJson(n,o)}static fromJsonString(n,o){return new gn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(gn,n,o)}};B(gn,"runtime",Z),B(gn,"typeName","exa.language_server_pb.GetAuthTokenResponse"),B(gn,"fields",Z.util.newFieldList(()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}]));let Ui=gn;const bn=class bn extends Xe{constructor(n){super();B(this,"row",We.zero);B(this,"col",We.zero);Z.util.initPartial(n,this)}static fromBinary(n,o){return new bn().fromBinary(n,o)}static fromJson(n,o){return new bn().fromJson(n,o)}static fromJsonString(n,o){return new bn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(bn,n,o)}};B(bn,"runtime",Z),B(bn,"typeName","exa.language_server_pb.DocumentPosition"),B(bn,"fields",Z.util.newFieldList(()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}]));let cr=bn;const xn=class xn extends Xe{constructor(n){super();B(this,"absolutePath","");B(this,"relativePath","");B(this,"text","");B(this,"editorLanguage","");B(this,"language",On.UNSPECIFIED);B(this,"cursorOffset",We.zero);B(this,"cursorPosition");B(this,"lineEnding","");Z.util.initPartial(n,this)}static fromBinary(n,o){return new xn().fromBinary(n,o)}static fromJson(n,o){return new xn().fromJson(n,o)}static fromJsonString(n,o){return new xn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(xn,n,o)}};B(xn,"runtime",Z),B(xn,"typeName","exa.language_server_pb.Document"),B(xn,"fields",Z.util.newFieldList(()=>[{no:1,name:"absolute_path",kind:"scalar",T:9},{no:2,name:"relative_path",kind:"scalar",T:9},{no:3,name:"text",kind:"scalar",T:9},{no:4,name:"editor_language",kind:"scalar",T:9},{no:5,name:"language",kind:"enum",T:Z.getEnumType(On)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:cr},{no:7,name:"line_ending",kind:"scalar",T:9}]));let As=xn;const yn=class yn extends Xe{constructor(n){super();B(this,"forceEnableExperiments",[]);Z.util.initPartial(n,this)}static fromBinary(n,o){return new yn().fromBinary(n,o)}static fromJson(n,o){return new yn().fromJson(n,o)}static fromJsonString(n,o){return new yn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(yn,n,o)}};B(yn,"runtime",Z),B(yn,"typeName","exa.language_server_pb.ExperimentConfig"),B(yn,"fields",Z.util.newFieldList(()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:Z.getEnumType(js),repeated:!0}]));let Wi=yn;const vn=class vn extends Xe{constructor(n){super();B(this,"state",ir.UNSPECIFIED);B(this,"message","");Z.util.initPartial(n,this)}static fromBinary(n,o){return new vn().fromBinary(n,o)}static fromJson(n,o){return new vn().fromJson(n,o)}static fromJsonString(n,o){return new vn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(vn,n,o)}};B(vn,"runtime",Z),B(vn,"typeName","exa.language_server_pb.State"),B(vn,"fields",Z.util.newFieldList(()=>[{no:1,name:"state",kind:"enum",T:Z.getEnumType(ir)},{no:2,name:"message",kind:"scalar",T:9}]));let $i=vn;const wn=class wn extends Xe{constructor(n){super();B(this,"startOffset",We.zero);B(this,"endOffset",We.zero);B(this,"startPosition");B(this,"endPosition");Z.util.initPartial(n,this)}static fromBinary(n,o){return new wn().fromBinary(n,o)}static fromJson(n,o){return new wn().fromJson(n,o)}static fromJsonString(n,o){return new wn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(wn,n,o)}};B(wn,"runtime",Z),B(wn,"typeName","exa.language_server_pb.Range"),B(wn,"fields",Z.util.newFieldList(()=>[{no:1,name:"start_offset",kind:"scalar",T:4},{no:2,name:"end_offset",kind:"scalar",T:4},{no:3,name:"start_position",kind:"message",T:cr},{no:4,name:"end_position",kind:"message",T:cr}]));let Vi=wn;const kn=class kn extends Xe{constructor(n){super();B(this,"text","");B(this,"deltaCursorOffset",We.zero);Z.util.initPartial(n,this)}static fromBinary(n,o){return new kn().fromBinary(n,o)}static fromJson(n,o){return new kn().fromJson(n,o)}static fromJsonString(n,o){return new kn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(kn,n,o)}};B(kn,"runtime",Z),B(kn,"typeName","exa.language_server_pb.Suffix"),B(kn,"fields",Z.util.newFieldList(()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}]));let Gi=kn;const jn=class jn extends Xe{constructor(n){super();B(this,"text","");B(this,"offset",We.zero);B(this,"type",lr.UNSPECIFIED);B(this,"prefix","");B(this,"line",We.zero);Z.util.initPartial(n,this)}static fromBinary(n,o){return new jn().fromBinary(n,o)}static fromJson(n,o){return new jn().fromJson(n,o)}static fromJsonString(n,o){return new jn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(jn,n,o)}};B(jn,"runtime",Z),B(jn,"typeName","exa.language_server_pb.CompletionPart"),B(jn,"fields",Z.util.newFieldList(()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"offset",kind:"scalar",T:4},{no:3,name:"type",kind:"enum",T:Z.getEnumType(lr)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}]));let qi=jn;const Cn=class Cn extends Xe{constructor(n){super();B(this,"completion");B(this,"suffix");B(this,"range");B(this,"source",sr.UNSPECIFIED);B(this,"completionParts",[]);Z.util.initPartial(n,this)}static fromBinary(n,o){return new Cn().fromBinary(n,o)}static fromJson(n,o){return new Cn().fromJson(n,o)}static fromJsonString(n,o){return new Cn().fromJsonString(n,o)}static equals(n,o){return Z.util.equals(Cn,n,o)}};B(Cn,"runtime",Z),B(Cn,"typeName","exa.language_server_pb.CompletionItem"),B(Cn,"fields",Z.util.newFieldList(()=>[{no:1,name:"completion",kind:"message",T:Ti},{no:5,name:"suffix",kind:"message",T:Gi},{no:2,name:"range",kind:"message",T:Vi},{no:3,name:"source",kind:"enum",T:Z.getEnumType(sr)},{no:8,name:"completion_parts",kind:"message",T:qi,repeated:!0}]));let Hi=Cn;const f2={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:Li,O:Fi,kind:It.Unary},acceptCompletion:{name:"AcceptCompletion",I:Bi,O:Pi,kind:It.Unary},getAuthToken:{name:"GetAuthToken",I:zi,O:Ui,kind:It.Unary}}};var dr=function(t){return this instanceof dr?(this.v=t,this):new dr(t)},p2=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},a("next"),a("throw"),a("return",function(h){return function(m){return Promise.resolve(m).then(h,d)}}),o[Symbol.asyncIterator]=function(){return this},o;function a(h,m){r[h]&&(o[h]=function(p){return new Promise(function(b,x){s.push([h,p,b,x])>1||l(h,p)})},m&&(o[h]=m(o[h])))}function l(h,m){try{(p=r[h](m)).value instanceof dr?Promise.resolve(p.value.v).then(c,d):u(s[0][2],p)}catch(b){u(s[0][3],b)}var p}function c(h){l("next",h)}function d(h){l("throw",h)}function u(h,m){h(m),s.shift(),s.length&&l(s[0][0],s[0][1])}};const g2=(function(t,e){return a2(t,e)})(f2,(function(t){var e;(function(){try{new Headers}catch{throw new Error("connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.")}})();const n=(e=t.useBinaryFormat)!==null&&e!==void 0&&e;return{async unary(o,r,s,a,l,c,d){var u;const{serialize:h,parse:m}=Lh(r,n,t.jsonOptions,t.binaryOptions);return a=a===void 0?t.defaultTimeoutMs:a<=0?void 0:a,await(function(p){const b=Oh(p.next,p.interceptors),[x,f,g]=Gh(p);return b(Object.assign(Object.assign({},p.req),{message:Mh(p.req.method.I,p.req.message),signal:x})).then(y=>(g(),y),f)})({interceptors:t.interceptors,signal:s,timeoutMs:a,req:{stream:!1,service:o,method:r,url:Dh(t.baseUrl,o,r),init:{method:"POST",credentials:(u=t.credentials)!==null&&u!==void 0?u:"same-origin",redirect:"error",mode:"cors"},header:$h(r.kind,n,a,l),contextValues:d??Th(),message:c},next:async p=>{var b;let x=null;t.useHttpGet===!0&&r.idempotency===Ai.NoSideEffects?p=m2(p,h(p.message),n):x=h(p.message);const f=(b=t.fetch)!==null&&b!==void 0?b:globalThis.fetch,g=await f(p.url,Object.assign(Object.assign({},p.init),{headers:p.header,signal:p.signal,body:x})),{isUnaryError:y,unaryError:w}=Vh(r.kind,n,g.status,g.headers);if(y)throw Ph(await g.json(),(function(...N){const k=new Headers;for(const E of N)E.forEach((_,I)=>{k.append(I,_)});return k})(...Wh(g.headers)),w);const[j,C]=Wh(g.headers);return{stream:!1,service:o,method:r,header:j,message:n?m(new Uint8Array(await g.arrayBuffer())):r.O.fromJson(await g.json(),Rh(t.jsonOptions)),trailer:C}}})},async stream(o,r,s,a,l,c,d){var u;const{serialize:h,parse:m}=Lh(r,n,t.jsonOptions,t.binaryOptions);function p(x,f,g,y){return p2(this,arguments,function*(){const w=(function(C){let N,k=new Uint8Array(0);function E(_){const I=new Uint8Array(k.length+_.length);I.set(k),I.set(_,k.length),k=I}return new ReadableStream({start(){N=C.getReader()},async pull(_){let I;for(;;){if(I===void 0&&k.byteLength>=5){let D=0;for(let M=1;M<5;M++)D=(D<<8)+k[M];I={flags:k[0],length:D}}if(I!==void 0&&k.byteLength>=I.length+5)break;const O=await N.read();if(O.done)break;E(O.value)}if(I===void 0)return k.byteLength==0?void _.close():void _.error(new Qe("premature end of stream",Pe.DataLoss));const A=k.subarray(5,5+I.length);k=k.subarray(5+I.length),_.enqueue({flags:I.flags,data:A})}})})(x).getReader();let j=!1;for(;;){const C=yield dr(w.read());if(C.done)break;const{flags:N,data:k}=C.value;if(!(1&~N))throw new Qe("protocol error: received unsupported compressed output",Pe.Internal);if(!(2&~N)){j=!0;const E=c2(k);if(E.error){const _=E.error;throw g.forEach((I,A)=>{_.metadata.append(A,I)}),_}E.metadata.forEach((_,I)=>f.set(I,_));continue}yield yield dr(m(k))}if("throwIfAborted"in y&&y.throwIfAborted(),!j)throw"missing EndStreamResponse"})}async function b(x){if(r.kind!=It.ServerStreaming)throw"The fetch API does not support streaming request bodies";const f=await x[Symbol.asyncIterator]().next();if(f.done==1)throw"missing request message";return(function(g,y){const w=new Uint8Array(y.length+5);w.set(y,5);const j=new DataView(w.buffer,w.byteOffset,w.byteLength);return j.setUint8(0,g),j.setUint32(1,y.length),w})(0,h(f.value))}return a=a===void 0?t.defaultTimeoutMs:a<=0?void 0:a,await(function(x){const f=Oh(x.next,x.interceptors),[g,y,w]=Gh(x),j=Object.assign(Object.assign({},x.req),{message:i2(x.req.method.I,x.req.message),signal:g});let C=!1;return g.addEventListener("abort",function(){var N,k;const E=x.req.message[Symbol.asyncIterator]();C||(N=E.throw)===null||N===void 0||N.call(E,this.reason).catch(()=>{}),(k=E.return)===null||k===void 0||k.call(E).catch(()=>{})}),f(j).then(N=>Object.assign(Object.assign({},N),{message:{[Symbol.asyncIterator](){const k=N.message[Symbol.asyncIterator]();return{next:()=>k.next().then(E=>(E.done==1&&(C=!0,w()),E),y)}}}}),y)})({interceptors:t.interceptors,timeoutMs:a,signal:s,req:{stream:!0,service:o,method:r,url:Dh(t.baseUrl,o,r),init:{method:"POST",credentials:(u=t.credentials)!==null&&u!==void 0?u:"same-origin",redirect:"error",mode:"cors"},header:$h(r.kind,n,a,l),contextValues:d??Th(),message:c},next:async x=>{var f;const g=(f=t.fetch)!==null&&f!==void 0?f:globalThis.fetch,y=await g(x.url,Object.assign(Object.assign({},x.init),{headers:x.header,signal:x.signal,body:await b(x.message)}));if(Vh(r.kind,n,y.status,y.headers),y.body===null)throw"missing response body";const w=new Headers;return Object.assign(Object.assign({},x),{header:y.headers,trailer:w,message:p(y.body,w,y.headers,x.signal)})}})}}})({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}));let Ts;try{Ts=crypto.randomUUID()}catch{Ts="10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^(crypto.getRandomValues(new Uint8Array(1))[0]??0)&15>>+t/4).toString(16))}async function b2(t,e){const n=t.state.facet(Ss),{override:o}=t.state.facet(Eh),r=await o(),s=t.state,a=s.selection.main.head,l=s.doc.toString();try{const c=await(async function({text:b,cursorOffset:x,config:f,otherDocuments:g}){return await g2.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:f.apiKey,sessionId:Ts,authSource:f.authSource},document:{text:b,cursorOffset:BigInt(x),language:f.language,editorLanguage:"typescript",lineEnding:`
105
116
  `},editorOptions:{tabSize:2n,insertSpaces:!0},otherDocuments:g,multilineConfig:void 0},{headers:{Authorization:`Basic ${f.apiKey}-${Ts}`}})})({text:l,cursorOffset:a,config:n,otherDocuments:r});if(!c||c.completionItems.length===0||e!==void 0&&a!==e||Fo(t.state)==="active"||!t.hasFocus)return;const d=c.completionItems.map(b=>{let x=0;return b.completionParts.filter(f=>f.type!==3).map(f=>{const g=Number(f.offset),y=f.type===2?`
106
- ${f.text}`:f.text,w={absoluteStartPos:x+g,absoluteEndPos:x+g+y.length,from:g,to:g,insert:y};return x+=y.length,w})}),u=0,h=d.at(u);if(!h)return;const m=Tr.of(h,s.doc.length),p=m.invert(s.doc);t.dispatch({changes:m,effects:ki.of({index:u,reverseChangeSet:p,changeSpecs:d}),annotations:[Es.of(null),go.of(null),Dr.addToHistory.of(!1)]})}catch(c){console.warn("copilot completion failed",c),await new Promise(d=>setTimeout(d,300))}}function j2(){let t=null,e=0;return Se.updateListener.of(n=>{const o=n.view.state.facet(Ss);if(!o.alwaysOn||!(function(s){return s.docChanged&&!s.transactions.some(a=>a.effects.some(l=>l.is(ji)||l.is(Ci)))})(n)||(t&&clearTimeout(t),(function(s){if(!s.view.hasFocus||s.state.field(Qn)||Fo(s.state)==="active")return!0;for(const a of s.transactions)if(a.annotation(go)!==void 0)return!0})(n)))return;const r=n.state.selection.main.head;o.shouldComplete&&!o.shouldComplete(new o4(n.view.state,r,!1))||(t=setTimeout(async()=>{r===e&&await k2(n.view,e)},o.timeout),e=r)})}function Hh(t){var r;const e=t.state.field(Qn);if(!e)return!1;const n=(r=e.reverseChangeSet)==null?void 0:r.invert(t.state.doc);t.dispatch({changes:e.reverseChangeSet,effects:ji.of(null),annotations:[Es.of(null),go.of(null),Dr.addToHistory.of(!1)]});let o=0;return n==null||n.iterChangedRanges((s,a,l,c)=>{o=c}),t.dispatch({changes:n,selection:Yt.cursor(o),annotations:[go.of(null),Dr.addToHistory.of(!0)]}),!0}const Jh=t=>{const{state:e}=t,n=e.field(Qn);if(!n)return!1;const{changeSpecs:o}=n;if(o.length<2)return!1;const r=(n.index+1)%o.length,s=o.at(r);if(!s)return!1;const a=n.reverseChangeSet.apply(e.doc),l=Tr.of(n.reverseChangeSet,e.doc.length).compose(Tr.of(s,a.length)),c=Tr.of(s,a.length).invert(a);return t.dispatch({changes:l,effects:ki.of({index:r,reverseChangeSet:c,changeSpecs:o}),annotations:[Es.of(null),go.of(null),Dr.addToHistory.of(!1)]}),!0};function Ji(t){const e=t.state.field(Qn);return!!e&&(t.dispatch({changes:e.reverseChangeSet,effects:Ci.of(null),annotations:[Es.of(null),go.of(null),Dr.addToHistory.of(!1)]}),!1)}function C2(){return Se.domEventHandlers({keydown:(t,e)=>(t.key!=="]"||!t.ctrlKey)&&t.key!=="Shift"&&t.key!=="Control"&&t.key!=="Alt"&&t.key!=="Meta"&&(function(n,o){return!!n.state.field(Qn)&&(o==="Tab"?Hh(n):Ji(n))})(e,t.key),mouseup(t,e){const n=t.target;return n.nodeName==="BUTTON"&&n.dataset.action==="codeium-cycle"?(Jh(e),t.stopPropagation(),t.preventDefault(),!0):(function(o){var l,c;let r=!1;const s=(l=o.state.selection.asSingle().ranges.at(0))==null?void 0:l.head,a=o.state.field(Qn);return!(s===void 0||!a)&&((c=a.decorations)==null||c.between(s,s,()=>{r=!0}),r)})(e)?Hh(e):Ji(e)}})}const N2=new lc,Ki=He.get("@github/copilot-language-server"),Kh={delay:300,includeKeymap:!0,events:{shouldShowSuggestion:t=>t.hasFocus,beforeSuggestionFetch:t=>t.hasFocus}},S2=t=>{const e=[];return t.copilot==="codeium"&&t.codeium_api_key&&e.push((function(n){return[Ss.of(n),Qn,Sn.highest($t.of([{key:"Ctrl-]",run:Jh}])),Sn.highest(Se.updateListener.of(o=>{o.focusChanged&&Ji(o.view)})),Sn.high(C2()),j2()]})({apiKey:t.codeium_api_key,language:Mn.PYTHON}),_h.of({override:async()=>[{text:ic(""),language:Mn.PYTHON,editorLanguage:"python"}]})),t.copilot==="github"&&e.push(Sd({...Kh,fetchFn:async(n,o,r)=>{const s=n.selection.main.head;if(!uC()||!r.hasFocus||n.doc.length===0)return"";await new Promise(u=>setTimeout(u,20));const a=n.doc.toString(),l=(function(u,h){const m=u.doc.toString(),p=h.split(`
117
+ ${f.text}`:f.text,w={absoluteStartPos:x+g,absoluteEndPos:x+g+y.length,from:g,to:g,insert:y};return x+=y.length,w})}),u=0,h=d.at(u);if(!h)return;const m=Ar.of(h,s.doc.length),p=m.invert(s.doc);t.dispatch({changes:m,effects:ki.of({index:u,reverseChangeSet:p,changeSpecs:d}),annotations:[Es.of(null),go.of(null),Tr.addToHistory.of(!1)]})}catch(c){console.warn("copilot completion failed",c),await new Promise(d=>setTimeout(d,300))}}function x2(){let t=null,e=0;return Se.updateListener.of(n=>{const o=n.view.state.facet(Ss);if(!o.alwaysOn||!(function(s){return s.docChanged&&!s.transactions.some(a=>a.effects.some(l=>l.is(ji)||l.is(Ci)))})(n)||(t&&clearTimeout(t),(function(s){if(!s.view.hasFocus||s.state.field(Qn)||Fo(s.state)==="active")return!0;for(const a of s.transactions)if(a.annotation(go)!==void 0)return!0})(n)))return;const r=n.state.selection.main.head;o.shouldComplete&&!o.shouldComplete(new Zk(n.view.state,r,!1))||(t=setTimeout(async()=>{r===e&&await b2(n.view,e)},o.timeout),e=r)})}function qh(t){var r;const e=t.state.field(Qn);if(!e)return!1;const n=(r=e.reverseChangeSet)==null?void 0:r.invert(t.state.doc);t.dispatch({changes:e.reverseChangeSet,effects:ji.of(null),annotations:[Es.of(null),go.of(null),Tr.addToHistory.of(!1)]});let o=0;return n==null||n.iterChangedRanges((s,a,l,c)=>{o=c}),t.dispatch({changes:n,selection:Kt.cursor(o),annotations:[go.of(null),Tr.addToHistory.of(!0)]}),!0}const Hh=t=>{const{state:e}=t,n=e.field(Qn);if(!n)return!1;const{changeSpecs:o}=n;if(o.length<2)return!1;const r=(n.index+1)%o.length,s=o.at(r);if(!s)return!1;const a=n.reverseChangeSet.apply(e.doc),l=Ar.of(n.reverseChangeSet,e.doc.length).compose(Ar.of(s,a.length)),c=Ar.of(s,a.length).invert(a);return t.dispatch({changes:l,effects:ki.of({index:r,reverseChangeSet:c,changeSpecs:o}),annotations:[Es.of(null),go.of(null),Tr.addToHistory.of(!1)]}),!0};function Ji(t){const e=t.state.field(Qn);return!!e&&(t.dispatch({changes:e.reverseChangeSet,effects:Ci.of(null),annotations:[Es.of(null),go.of(null),Tr.addToHistory.of(!1)]}),!1)}function y2(){return Se.domEventHandlers({keydown:(t,e)=>(t.key!=="]"||!t.ctrlKey)&&t.key!=="Shift"&&t.key!=="Control"&&t.key!=="Alt"&&t.key!=="Meta"&&(function(n,o){return!!n.state.field(Qn)&&(o==="Tab"?qh(n):Ji(n))})(e,t.key),mouseup(t,e){const n=t.target;return n.nodeName==="BUTTON"&&n.dataset.action==="codeium-cycle"?(Hh(e),t.stopPropagation(),t.preventDefault(),!0):(function(o){var l,c;let r=!1;const s=(l=o.state.selection.asSingle().ranges.at(0))==null?void 0:l.head,a=o.state.field(Qn);return!(s===void 0||!a)&&((c=a.decorations)==null||c.between(s,s,()=>{r=!0}),r)})(e)?qh(e):Ji(e)}})}const v2=new lc,Ki=Ye.get("@github/copilot-language-server"),Jh={delay:300,includeKeymap:!0,events:{shouldShowSuggestion:t=>t.hasFocus,beforeSuggestionFetch:t=>t.hasFocus}},w2=t=>{const e=[];return t.copilot==="codeium"&&t.codeium_api_key&&e.push((function(n){return[Ss.of(n),Qn,Sn.highest(Wt.of([{key:"Ctrl-]",run:Hh}])),Sn.highest(Se.updateListener.of(o=>{o.focusChanged&&Ji(o.view)})),Sn.high(y2()),x2()]})({apiKey:t.codeium_api_key,language:On.PYTHON}),Eh.of({override:async()=>[{text:ic(""),language:On.PYTHON,editorLanguage:"python"}]})),t.copilot==="github"&&e.push(Sd({...Jh,fetchFn:async(n,o,r)=>{const s=n.selection.main.head;if(!cC()||!r.hasFocus||n.doc.length===0)return"";await new Promise(u=>setTimeout(u,20));const a=n.doc.toString(),l=(function(u,h){const m=u.doc.toString(),p=h.split(`
107
118
  `).length-m.split(`
108
- `).length,b=(function(x,f){const g=x.lineAt(f);return{line:g.number-1,character:f-g.from}})(u.doc,u.selection.main.head);return b.line+=p,{textDocument:{uri:`file://${hC}`,version:"replace_me"},position:b,context:{triggerKind:s4.InlineCompletionTriggerKind.Automatic},formattingOptions:{tabSize:u.tabSize,insertSpaces:!0}}})(n,ic(a)),c=await J1().getCompletion(l);return s!==r.state.selection.main.head?(He.debug("ignoring response because of new position"),""):(function(u,h,m){if(!u)return Ki.debug("No response from copilot"),"";const p=Array.isArray(u)?u[0]:u.items[0];if(!p)return Ki.debug("No response from copilot"),"";const{insertText:b,range:x}=p,f=String(b);if(!x)return Ki.error("No range from copilot"),f;const g=x.start.character-h.character,y=g<0?f.slice(-g):f,w=m.doc.sliceString(m.selection.main.head,m.doc.length);for(let j=0;j<y.length;j++){const C=y.slice(j);if(w.startsWith(C))return y.slice(0,j)}return y})(c,l.position,n)}})),t.copilot==="custom"&&e.push(Sd({...Kh,fetchFn:async(n,o,r)=>{const s=n.selection.main.head;if(n.doc.length===0||!r.hasFocus)return"";const a=n.doc.sliceString(0,n.selection.main.head),l=n.doc.sliceString(n.selection.main.head,n.doc.length);if(a.length===0)return"";const c=n.field(ha).type;let d=await r4.post("/ai/inline_completion",{prefix:a,suffix:l,language:c});return s!==r.state.selection.main.head?(He.debug("ignoring response because of new position"),""):(d=(function({response:u,prefix:h,suffix:m}){if(!u)return u;let p=u;return h&&p.startsWith(h)&&(p=p.slice(h.length)),m&&p.endsWith(m)&&(p=p.slice(0,-m.length)),p})({response:d,prefix:a,suffix:l}),d)}})),[...e,Sn.highest($t.of([{key:"Escape",run:n=>{const o=Nd(n);return!da(n)&&o}}])),N2.of(dC())]};function E2(t){return[$t.of([{key:"Escape",preventDefault:!1,run:U0},{key:t.getHotkey("cell.selectNextOccurrence").key,preventDefault:!0,run:i4},{key:t.getHotkey("cell.findAndReplace").key,preventDefault:!0,run:nu}]),a4(),H0,ts,J0]}const _2=Te.mark({class:"underline"}),Yh=tt.define(),Xh=tt.define(),Qh=tt.define(),I2=Dt.define({create:()=>Te.none,update(t,e){let n=t.map(e.changes);for(const o of e.effects)o.is(Yh)?n=t.update({add:[_2.range(o.value.from,o.value.to)]}):o.is(Xh)?n=t.update({add:[l4.range(o.value.from,o.value.to)]}):o.is(Qh)&&(n=Te.none);return n},provide:t=>Se.decorations.from(t)});class A2{constructor(e,n){this.view=void 0,this.commandClickMode=void 0,this.hoveredRange=void 0,this.onClick=void 0,this.keydown=o=>{o.key!=="Meta"&&o.key!=="Control"||(this.commandClickMode=!0,this.view.dom.addEventListener("mousemove",this.mousemove),this.view.dom.addEventListener("click",this.click))},this.keyup=o=>{o.key!=="Meta"&&o.key!=="Control"||this.exitCommandClickMode()},this.windowBlur=()=>{this.commandClickMode&&this.exitCommandClickMode()},this.mousemove=o=>{if(!o.metaKey&&!o.ctrlKey)return void this.exitCommandClickMode();if(!this.commandClickMode)return void this.clearUnderline();const r=this.view.posAtCoords({x:o.clientX,y:o.clientY});if(r==null)return void this.clearUnderline();const s=this.view.state.field(c4,!1),a=s==null?void 0:s.ranges.find(c=>r>=c.from&&r<=c.to);if(a){const{from:c,to:d}=a;return this.hoveredRange&&this.hoveredRange.from===c&&this.hoveredRange.to===d?void 0:(this.clearUnderline(),this.hoveredRange={from:c,to:d,position:r},void this.view.dispatch({effects:Xh.of(this.hoveredRange)}))}const l=d4(this.view.state).cursorAt(r);if(l.name==="VariableName"){const{from:c,to:d}=l;if(this.hoveredRange&&this.hoveredRange.from===c&&this.hoveredRange.to===d)return;this.clearUnderline(),this.hoveredRange={from:c,to:d,position:r},this.view.dispatch({effects:Yh.of(this.hoveredRange)})}else this.clearUnderline()},this.click=o=>{if(this.hoveredRange){const r=this.view.state.doc.sliceString(this.hoveredRange.from,this.hoveredRange.to);o.preventDefault(),o.stopPropagation(),this.onClick(this.view,r),this.view.dispatch({selection:{head:this.hoveredRange.position,anchor:this.hoveredRange.position}})}},this.view=e,this.commandClickMode=!1,this.hoveredRange=null,this.onClick=n,window.addEventListener("keydown",this.keydown),window.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.windowBlur),window.addEventListener("mouseleave",this.windowBlur)}update(e){}destroy(){window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),window.removeEventListener("blur",this.windowBlur),window.removeEventListener("mouseleave",this.windowBlur),this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click)}exitCommandClickMode(){this.commandClickMode=!1,this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click),this.clearUnderline()}clearUnderline(){this.hoveredRange&&(this.view.dispatch({effects:Qh.of(null)}),this.hoveredRange=null)}}function T2(){return[Se.domEventHandlers({paste:(t,e)=>{var r;const n=(r=t.clipboardData)==null?void 0:r.getData("text/plain");if(!(n!=null&&n.includes("@app.cell")))return!1;const o=(function(s){if(!s.includes("@app.cell"))return[];const a=[],l=s.split(`
119
+ `).length,b=(function(x,f){const g=x.lineAt(f);return{line:g.number-1,character:f-g.from}})(u.doc,u.selection.main.head);return b.line+=p,{textDocument:{uri:`file://${dC}`,version:"replace_me"},position:b,context:{triggerKind:t4.InlineCompletionTriggerKind.Automatic},formattingOptions:{tabSize:u.tabSize,insertSpaces:!0}}})(n,ic(a)),c=await G1().getCompletion(l);return s!==r.state.selection.main.head?(Ye.debug("ignoring response because of new position"),""):(function(u,h,m){if(!u)return Ki.debug("No response from copilot"),"";const p=Array.isArray(u)?u[0]:u.items[0];if(!p)return Ki.debug("No response from copilot"),"";const{insertText:b,range:x}=p,f=String(b);if(!x)return Ki.error("No range from copilot"),f;const g=x.start.character-h.character,y=g<0?f.slice(-g):f,w=m.doc.sliceString(m.selection.main.head,m.doc.length);for(let j=0;j<y.length;j++){const C=y.slice(j);if(w.startsWith(C))return y.slice(0,j)}return y})(c,l.position,n)}})),t.copilot==="custom"&&e.push(Sd({...Jh,fetchFn:async(n,o,r)=>{const s=n.selection.main.head;if(n.doc.length===0||!r.hasFocus)return"";const a=n.doc.sliceString(0,n.selection.main.head),l=n.doc.sliceString(n.selection.main.head,n.doc.length);if(a.length===0)return"";const c=n.field(ha).type;let d=await e4.post("/ai/inline_completion",{prefix:a,suffix:l,language:c});return s!==r.state.selection.main.head?(Ye.debug("ignoring response because of new position"),""):(d=(function({response:u,prefix:h,suffix:m}){if(!u)return u;let p=u;return h&&p.startsWith(h)&&(p=p.slice(h.length)),m&&p.endsWith(m)&&(p=p.slice(0,-m.length)),p})({response:d,prefix:a,suffix:l}),d)}})),[...e,Sn.highest(Wt.of([{key:"Escape",run:n=>{const o=Nd(n);return!da(n)&&o}}])),v2.of(lC())]};function k2(t){return[Wt.of([{key:"Escape",preventDefault:!1,run:B0},{key:t.getHotkey("cell.selectNextOccurrence").key,preventDefault:!0,run:o4},{key:t.getHotkey("cell.findAndReplace").key,preventDefault:!0,run:tu}]),n4(),V0,ts,G0]}const j2=Te.mark({class:"underline"}),Kh=nt.define(),Yh=nt.define(),Xh=nt.define(),C2=Dt.define({create:()=>Te.none,update(t,e){let n=t.map(e.changes);for(const o of e.effects)o.is(Kh)?n=t.update({add:[j2.range(o.value.from,o.value.to)]}):o.is(Yh)?n=t.update({add:[r4.range(o.value.from,o.value.to)]}):o.is(Xh)&&(n=Te.none);return n},provide:t=>Se.decorations.from(t)});class N2{constructor(e,n){this.view=void 0,this.commandClickMode=void 0,this.hoveredRange=void 0,this.onClick=void 0,this.keydown=o=>{o.key!=="Meta"&&o.key!=="Control"||(this.commandClickMode=!0,this.view.dom.addEventListener("mousemove",this.mousemove),this.view.dom.addEventListener("click",this.click))},this.keyup=o=>{o.key!=="Meta"&&o.key!=="Control"||this.exitCommandClickMode()},this.windowBlur=()=>{this.commandClickMode&&this.exitCommandClickMode()},this.mousemove=o=>{if(!o.metaKey&&!o.ctrlKey)return void this.exitCommandClickMode();if(!this.commandClickMode)return void this.clearUnderline();const r=this.view.posAtCoords({x:o.clientX,y:o.clientY});if(r==null)return void this.clearUnderline();const s=this.view.state.field(s4,!1),a=s==null?void 0:s.ranges.find(c=>r>=c.from&&r<=c.to);if(a){const{from:c,to:d}=a;return this.hoveredRange&&this.hoveredRange.from===c&&this.hoveredRange.to===d?void 0:(this.clearUnderline(),this.hoveredRange={from:c,to:d,position:r},void this.view.dispatch({effects:Yh.of(this.hoveredRange)}))}const l=a4(this.view.state).cursorAt(r);if(l.name==="VariableName"){const{from:c,to:d}=l;if(this.hoveredRange&&this.hoveredRange.from===c&&this.hoveredRange.to===d)return;this.clearUnderline(),this.hoveredRange={from:c,to:d,position:r},this.view.dispatch({effects:Kh.of(this.hoveredRange)})}else this.clearUnderline()},this.click=o=>{if(this.hoveredRange){const r=this.view.state.doc.sliceString(this.hoveredRange.from,this.hoveredRange.to);o.preventDefault(),o.stopPropagation(),this.onClick(this.view,r),this.view.dispatch({selection:{head:this.hoveredRange.position,anchor:this.hoveredRange.position}})}},this.view=e,this.commandClickMode=!1,this.hoveredRange=null,this.onClick=n,window.addEventListener("keydown",this.keydown),window.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.windowBlur),window.addEventListener("mouseleave",this.windowBlur)}update(e){}destroy(){window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),window.removeEventListener("blur",this.windowBlur),window.removeEventListener("mouseleave",this.windowBlur),this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click)}exitCommandClickMode(){this.commandClickMode=!1,this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click),this.clearUnderline()}clearUnderline(){this.hoveredRange&&(this.view.dispatch({effects:Xh.of(null)}),this.hoveredRange=null)}}function S2(){return[Se.domEventHandlers({paste:(t,e)=>{var r;const n=(r=t.clipboardData)==null?void 0:r.getData("text/plain");if(!(n!=null&&n.includes("@app.cell")))return!1;const o=(function(s){if(!s.includes("@app.cell"))return[];const a=[],l=s.split(`
109
120
  `);let c=[],d=!1,u=0,h=!1,m=!1,p=0;const b=/\(/g,x=/\)/g,f=new Set(["@"]);function g(w){return(w.match(b)||[]).length-(w.match(x)||[]).length}function y(){if(c.length!==0){for(;c.length>0&&c[c.length-1].trim().startsWith("return");)c.pop();c.some(w=>w.trim()!=="")&&a.push((function(w){const j=w.split(`
110
121
  `);if(j.length===0)return"";const C=j.filter(E=>E.trim().length>0);if(C.length===0)return"";const N=/^\s*/,k=Math.min(...C.map(E=>{var _;return((_=E.match(N))==null?void 0:_[0].length)??Number.POSITIVE_INFINITY}));return k===0?w.trim():j.map(E=>E.slice(k)).join(`
111
122
  `).trim()})(c.join(`
112
- `))),c=[]}}for(const w of l){const j=w.trim();(j||d)&&(j.startsWith("@app.cell")?(y(),d=!0,u=1):u>0?(j.startsWith("def")&&j.includes("(")&&!j.includes("):")&&(h=!0,p=g(j)),u--):h?(p+=g(j),p===0&&(h=!1)):d&&(f.has(j[0])||j.startsWith("if __name__")?(y(),d=j.startsWith("@")):j.startsWith("return")?j.includes("(")&&!j.endsWith(")")&&(m=!0,p=g(j)):m?(p+=g(j),p===0&&(m=!1)):c.push(w)))}return y(),a})(n);return o.length===0?!1:(e.state.facet(f4).createManyBelow(o),!0)}})]}const it=({variant:t,settings:e,styles:n})=>{const o=Se.theme({"&":{backgroundColor:e.background,color:e.foreground},".cm-content":{caretColor:e.caret},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.caret},"&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection":{backgroundColor:e.selection},".cm-activeLine":{backgroundColor:e.lineHighlight},".cm-gutters":{backgroundColor:e.gutterBackground,color:e.gutterForeground},".cm-activeLineGutter":{backgroundColor:e.lineHighlight}},{dark:t==="dark"}),r=p4.define(n);return[o,c1(r)]};it({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:v.comment,color:"#404080"},{tag:[v.string,v.regexp],color:"#999999"},{tag:v.number,color:"#7090B0"},{tag:[v.bool,v.null],color:"#8080A0"},{tag:[v.punctuation,v.derefOperator],color:"#805080"},{tag:v.keyword,color:"#60B0FF"},{tag:v.definitionKeyword,color:"#B0FFF0"},{tag:v.moduleKeyword,color:"#60B0FF"},{tag:v.operator,color:"#A0A0FF"},{tag:[v.variableName,v.self],color:"#008080"},{tag:v.operatorKeyword,color:"#A0A0FF"},{tag:v.controlKeyword,color:"#80A0FF"},{tag:v.className,color:"#70E080"},{tag:[v.function(v.propertyName),v.propertyName],color:"#50A0A0"},{tag:v.tagName,color:"#009090"},{tag:v.modifier,color:"#B0FFF0"},{tag:[v.squareBracket,v.attributeName],color:"#D0D0FF"}]}),it({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:v.comment,color:"#787b8099"},{tag:v.string,color:"#86b300"},{tag:v.regexp,color:"#4cbf99"},{tag:[v.number,v.bool,v.null],color:"#ffaa33"},{tag:v.variableName,color:"#5c6166"},{tag:[v.definitionKeyword,v.modifier],color:"#fa8d3e"},{tag:[v.keyword,v.special(v.brace)],color:"#fa8d3e"},{tag:v.operator,color:"#ed9366"},{tag:v.separator,color:"#5c6166b3"},{tag:v.punctuation,color:"#5c6166"},{tag:[v.definition(v.propertyName),v.function(v.variableName)],color:"#f2ae49"},{tag:[v.className,v.definition(v.typeName)],color:"#22a4e6"},{tag:[v.tagName,v.typeName,v.self,v.labelName],color:"#55b4d4"},{tag:v.angleBracket,color:"#55b4d480"},{tag:v.attributeName,color:"#f2ae49"}]}),it({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:v.comment,color:"#6E6E6E"},{tag:[v.string,v.regexp,v.special(v.brace)],color:"#5C81B3"},{tag:v.number,color:"#C1E1B8"},{tag:v.bool,color:"#53667D"},{tag:[v.definitionKeyword,v.modifier,v.function(v.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[v.keyword,v.moduleKeyword,v.operatorKeyword,v.operator],color:"#697A8E",fontWeight:"bold"},{tag:[v.variableName,v.attributeName],color:"#708E67"},{tag:[v.function(v.variableName),v.definition(v.propertyName),v.derefOperator],color:"#fff"},{tag:v.tagName,color:"#A3D295"}]}),it({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:v.comment,color:"#666666"},{tag:[v.string,v.special(v.brace)],color:"#54BE0D"},{tag:v.regexp,color:"#E9C062"},{tag:v.number,color:"#CF6A4C"},{tag:[v.keyword,v.operator],color:"#5EA6EA"},{tag:v.variableName,color:"#7587A6"},{tag:[v.definitionKeyword,v.modifier],color:"#F9EE98"},{tag:[v.propertyName,v.function(v.variableName)],color:"#937121"},{tag:[v.typeName,v.angleBracket,v.tagName],color:"#9B859D"}]}),it({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:v.comment,color:"#6B4E32"},{tag:[v.keyword,v.operator,v.derefOperator],color:"#EF5D32"},{tag:v.className,color:"#EFAC32",fontWeight:"bold"},{tag:[v.typeName,v.propertyName,v.function(v.variableName),v.definition(v.variableName)],color:"#EFAC32"},{tag:v.definition(v.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:v.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[v.number,v.bool],color:"#6C99BB"},{tag:[v.variableName,v.self],color:"#7DAF9C"},{tag:[v.string,v.special(v.brace),v.regexp],color:"#D9D762"},{tag:[v.angleBracket,v.tagName,v.attributeName],color:"#EFCB43"}]}),it({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:v.comment,color:"#404040"},{tag:[v.string,v.special(v.brace),v.regexp],color:"#00D8FF"},{tag:v.number,color:"#E62286"},{tag:[v.variableName,v.attributeName,v.self],color:"#E62286",fontWeight:"bold"},{tag:v.function(v.variableName),color:"#fff",fontWeight:"bold"}]}),it({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:v.comment,color:"#BCC8BA"},{tag:[v.string,v.special(v.brace),v.regexp],color:"#5D90CD"},{tag:[v.number,v.bool,v.null],color:"#46A609"},{tag:v.keyword,color:"#AF956F"},{tag:[v.definitionKeyword,v.modifier],color:"#C52727"},{tag:[v.angleBracket,v.tagName,v.attributeName],color:"#606060"},{tag:v.self,color:"#000"}]}),it({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:v.comment,color:"#0088FF"},{tag:v.string,color:"#3AD900"},{tag:v.regexp,color:"#80FFC2"},{tag:[v.number,v.bool,v.null],color:"#FF628C"},{tag:[v.definitionKeyword,v.modifier],color:"#FFEE80"},{tag:v.variableName,color:"#CCCCCC"},{tag:v.self,color:"#FF80E1"},{tag:[v.className,v.definition(v.propertyName),v.function(v.variableName),v.definition(v.typeName),v.labelName],color:"#FFDD00"},{tag:[v.keyword,v.operator],color:"#FF9D00"},{tag:[v.propertyName,v.typeName],color:"#80FFBB"},{tag:v.special(v.brace),color:"#EDEF7D"},{tag:v.attributeName,color:"#9EFFFF"},{tag:v.derefOperator,color:"#fff"}]}),it({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:v.comment,color:"#AEAEAE"},{tag:[v.string,v.special(v.brace),v.regexp],color:"#8DFF8E"},{tag:[v.className,v.definition(v.propertyName),v.function(v.variableName),v.function(v.definition(v.variableName)),v.definition(v.typeName)],color:"#A3EBFF"},{tag:[v.number,v.bool,v.null],color:"#62E9BD"},{tag:[v.keyword,v.operator],color:"#2BF1DC"},{tag:[v.definitionKeyword,v.modifier],color:"#F8FBB1"},{tag:[v.variableName,v.self],color:"#B683CA"},{tag:[v.angleBracket,v.tagName,v.typeName,v.propertyName],color:"#60A4F1"},{tag:v.derefOperator,color:"#E0E0E0"},{tag:v.attributeName,color:"#7BACCA"}]}),it({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:v.comment,color:"#6272a4"},{tag:[v.string,v.special(v.brace)],color:"#f1fa8c"},{tag:[v.number,v.self,v.bool,v.null],color:"#bd93f9"},{tag:[v.keyword,v.operator],color:"#ff79c6"},{tag:[v.definitionKeyword,v.typeName],color:"#8be9fd"},{tag:v.definition(v.typeName),color:"#f8f8f2"},{tag:[v.className,v.definition(v.propertyName),v.function(v.variableName),v.attributeName],color:"#50fa7b"}]}),it({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:v.comment,color:"#AAAAAA"},{tag:[v.keyword,v.operator,v.typeName,v.tagName,v.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[v.attributeName,v.definition(v.propertyName)],color:"#4F9FD0"},{tag:[v.className,v.string,v.special(v.brace)],color:"#CF4F5F"},{tag:v.number,color:"#CF4F5F",fontWeight:"bold"},{tag:v.variableName,fontWeight:"bold"}]}),it({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:v.comment,color:"#9995b7"},{tag:v.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[v.definitionKeyword,v.modifier],color:"#ff5792"},{tag:[v.className,v.tagName,v.definition(v.typeName)],color:"#0094f0"},{tag:[v.number,v.bool,v.null,v.special(v.brace)],color:"#5842ff"},{tag:[v.definition(v.propertyName),v.function(v.variableName)],color:"#0095a8"},{tag:v.typeName,color:"#b3694d"},{tag:[v.propertyName,v.variableName],color:"#fa8900"},{tag:v.operator,color:"#ff5792"},{tag:v.self,color:"#e64100"},{tag:[v.string,v.regexp],color:"#00b368"},{tag:[v.paren,v.bracket],color:"#0431fa"},{tag:v.labelName,color:"#00bdd6"},{tag:v.attributeName,color:"#e64100"},{tag:v.angleBracket,color:"#9995b7"}]}),it({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:v.comment,color:"#9893a5"},{tag:[v.bool,v.null],color:"#286983"},{tag:v.number,color:"#d7827e"},{tag:v.className,color:"#d7827e"},{tag:[v.angleBracket,v.tagName,v.typeName],color:"#56949f"},{tag:v.attributeName,color:"#907aa9"},{tag:v.punctuation,color:"#797593"},{tag:[v.keyword,v.modifier],color:"#286983"},{tag:[v.string,v.regexp],color:"#ea9d34"},{tag:v.variableName,color:"#d7827e"}]}),it({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:v.comment,color:"#CFCFCF"},{tag:[v.number,v.bool,v.null],color:"#E66C29"},{tag:[v.className,v.definition(v.propertyName),v.function(v.variableName),v.labelName,v.definition(v.typeName)],color:"#2EB43B"},{tag:v.keyword,color:"#D8B229"},{tag:v.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[v.definitionKeyword,v.modifier],color:"#925A47"},{tag:v.string,color:"#704D3D"},{tag:v.typeName,color:"#2F8996"},{tag:[v.variableName,v.propertyName],color:"#77ACB0"},{tag:v.self,color:"#77ACB0",fontWeight:"bold"},{tag:v.regexp,color:"#E3965E"},{tag:[v.tagName,v.angleBracket],color:"#BAA827"},{tag:v.attributeName,color:"#B06520"},{tag:v.derefOperator,color:"#000"}]}),it({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:v.comment,color:"#93A1A1"},{tag:v.string,color:"#2AA198"},{tag:v.regexp,color:"#D30102"},{tag:v.number,color:"#D33682"},{tag:v.variableName,color:"#268BD2"},{tag:[v.keyword,v.operator,v.punctuation],color:"#859900"},{tag:[v.definitionKeyword,v.modifier],color:"#073642",fontWeight:"bold"},{tag:[v.className,v.self,v.definition(v.propertyName)],color:"#268BD2"},{tag:v.function(v.variableName),color:"#268BD2"},{tag:[v.bool,v.null],color:"#B58900"},{tag:v.tagName,color:"#268BD2",fontWeight:"bold"},{tag:v.angleBracket,color:"#93A1A1"},{tag:v.attributeName,color:"#93A1A1"},{tag:v.typeName,color:"#859900"}]}),it({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:v.comment,color:"#8E908C"},{tag:[v.variableName,v.self,v.propertyName,v.attributeName,v.regexp],color:"#C82829"},{tag:[v.number,v.bool,v.null],color:"#F5871F"},{tag:[v.className,v.typeName,v.definition(v.typeName)],color:"#C99E00"},{tag:[v.string,v.special(v.brace)],color:"#718C00"},{tag:v.operator,color:"#3E999F"},{tag:[v.definition(v.propertyName),v.function(v.variableName)],color:"#4271AE"},{tag:v.keyword,color:"#8959A8"},{tag:v.derefOperator,color:"#4D4D4C"}]});const D2=[it({variant:"dark",settings:{background:"var(--cm-background)",foreground:"#abb2bf",caret:"#528bff",selection:"#3E4451",lineHighlight:"#2c313c",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:v.comment,color:"#5c6370"},{tag:v.variableName,color:"#abb2bf"},{tag:[v.string,v.special(v.brace)],color:"#98c379"},{tag:v.number,color:"#d19a66"},{tag:v.bool,color:"#d19a66"},{tag:v.null,color:"#d19a66"},{tag:v.keyword,color:"#c678dd",fontWeight:500},{tag:v.className,color:"#61afef"},{tag:v.definition(v.typeName),color:"#61afef"},{tag:v.typeName,color:"#56b6c2"},{tag:v.angleBracket,color:"#abb2bf"},{tag:v.tagName,color:"#e06c75"},{tag:v.attributeName,color:"#d19a66"},{tag:v.operator,color:"#56b6c2",fontWeight:500},{tag:[v.function(v.variableName)],color:"#61afef"},{tag:[v.propertyName],color:"#e5c07b"}]}),Se.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#2a7aa5",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px",borderBottomColor:"#4a90a5"}})],M2=[it({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#cceeff44",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:v.comment,color:"#708090"},{tag:v.variableName,color:"#000000"},{tag:[v.string,v.special(v.brace)],color:"#a11"},{tag:v.number,color:"#164"},{tag:v.bool,color:"#219"},{tag:v.null,color:"#219"},{tag:v.keyword,color:"#708",fontWeight:500},{tag:v.className,color:"#00f"},{tag:v.definition(v.typeName),color:"#00f"},{tag:v.typeName,color:"#085"},{tag:v.angleBracket,color:"#000000"},{tag:v.tagName,color:"#170"},{tag:v.attributeName,color:"#00c"},{tag:v.operator,color:"#a2f",fontWeight:500},{tag:[v.function(v.variableName)],color:"#00c"},{tag:[v.propertyName],color:"#05a"}]}),Se.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#005f87",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px"}})];function Zh(t){const{showPlaceholder:e,enableAI:n}=t;return e?"marimo-import":n?"ai":"none"}const O2=t=>{const{cellId:e,keymapConfig:n,hotkeys:o,enableAI:r,cellActions:s,completionConfig:a,lspConfig:l,diagnosticsConfig:c,displayConfig:d}=t,u=Zh(t);return[mC(n,o),[Se.domEventHandlers({drop:(m,p)=>{var f,g;const b=(f=m.dataTransfer)==null?void 0:f.files[0];if(b!=null&&b.type.startsWith("text/"))return m.preventDefault(),h4(p,b),!0;if(b!=null&&b.type.startsWith("image/"))return m.preventDefault(),m4(p,b),!0;const x=(g=m.dataTransfer)==null?void 0:g.getData("text/plain");if(x){m.preventDefault();const y=p.posAtCoords({x:m.clientX,y:m.clientY});return y!==null&&p.dispatch({changes:{from:y,to:y,insert:x},scrollIntoView:!0}),!0}return!1},dragover:m=>{m.preventDefault()}})],T2(),Tx(),g4({completionConfig:a,hotkeys:o,placeholderType:u,lspConfig:l,diagnosticsConfig:c}),b4({cellId:e,hotkeys:o,cellActions:s}),R2(t),[I2,(h=(m,p)=>{u4(m,p)},Wt.define(m=>new A2(m,h))),Se.baseTheme({".underline":{textDecoration:"underline",cursor:"pointer",color:"var(--link)"}})],c!=null&&c.enabled?x4():[],r&&Ys("inline_ai_tooltip")?[Fg({prompt:m=>(async function(p){var j,C;const b=`
123
+ `))),c=[]}}for(const w of l){const j=w.trim();(j||d)&&(j.startsWith("@app.cell")?(y(),d=!0,u=1):u>0?(j.startsWith("def")&&j.includes("(")&&!j.includes("):")&&(h=!0,p=g(j)),u--):h?(p+=g(j),p===0&&(h=!1)):d&&(f.has(j[0])||j.startsWith("if __name__")?(y(),d=j.startsWith("@")):j.startsWith("return")?j.includes("(")&&!j.endsWith(")")&&(m=!0,p=g(j)):m?(p+=g(j),p===0&&(m=!1)):c.push(w)))}return y(),a})(n);return o.length===0?!1:(e.state.facet(d4).createManyBelow(o),!0)}})]}const it=({variant:t,settings:e,styles:n})=>{const o=Se.theme({"&":{backgroundColor:e.background,color:e.foreground},".cm-content":{caretColor:e.caret},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.caret},"&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection":{backgroundColor:e.selection},".cm-activeLine":{backgroundColor:e.lineHighlight},".cm-gutters":{backgroundColor:e.gutterBackground,color:e.gutterForeground},".cm-activeLineGutter":{backgroundColor:e.lineHighlight}},{dark:t==="dark"}),r=u4.define(n);return[o,i1(r)]};it({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:v.comment,color:"#404080"},{tag:[v.string,v.regexp],color:"#999999"},{tag:v.number,color:"#7090B0"},{tag:[v.bool,v.null],color:"#8080A0"},{tag:[v.punctuation,v.derefOperator],color:"#805080"},{tag:v.keyword,color:"#60B0FF"},{tag:v.definitionKeyword,color:"#B0FFF0"},{tag:v.moduleKeyword,color:"#60B0FF"},{tag:v.operator,color:"#A0A0FF"},{tag:[v.variableName,v.self],color:"#008080"},{tag:v.operatorKeyword,color:"#A0A0FF"},{tag:v.controlKeyword,color:"#80A0FF"},{tag:v.className,color:"#70E080"},{tag:[v.function(v.propertyName),v.propertyName],color:"#50A0A0"},{tag:v.tagName,color:"#009090"},{tag:v.modifier,color:"#B0FFF0"},{tag:[v.squareBracket,v.attributeName],color:"#D0D0FF"}]}),it({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:v.comment,color:"#787b8099"},{tag:v.string,color:"#86b300"},{tag:v.regexp,color:"#4cbf99"},{tag:[v.number,v.bool,v.null],color:"#ffaa33"},{tag:v.variableName,color:"#5c6166"},{tag:[v.definitionKeyword,v.modifier],color:"#fa8d3e"},{tag:[v.keyword,v.special(v.brace)],color:"#fa8d3e"},{tag:v.operator,color:"#ed9366"},{tag:v.separator,color:"#5c6166b3"},{tag:v.punctuation,color:"#5c6166"},{tag:[v.definition(v.propertyName),v.function(v.variableName)],color:"#f2ae49"},{tag:[v.className,v.definition(v.typeName)],color:"#22a4e6"},{tag:[v.tagName,v.typeName,v.self,v.labelName],color:"#55b4d4"},{tag:v.angleBracket,color:"#55b4d480"},{tag:v.attributeName,color:"#f2ae49"}]}),it({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:v.comment,color:"#6E6E6E"},{tag:[v.string,v.regexp,v.special(v.brace)],color:"#5C81B3"},{tag:v.number,color:"#C1E1B8"},{tag:v.bool,color:"#53667D"},{tag:[v.definitionKeyword,v.modifier,v.function(v.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[v.keyword,v.moduleKeyword,v.operatorKeyword,v.operator],color:"#697A8E",fontWeight:"bold"},{tag:[v.variableName,v.attributeName],color:"#708E67"},{tag:[v.function(v.variableName),v.definition(v.propertyName),v.derefOperator],color:"#fff"},{tag:v.tagName,color:"#A3D295"}]}),it({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:v.comment,color:"#666666"},{tag:[v.string,v.special(v.brace)],color:"#54BE0D"},{tag:v.regexp,color:"#E9C062"},{tag:v.number,color:"#CF6A4C"},{tag:[v.keyword,v.operator],color:"#5EA6EA"},{tag:v.variableName,color:"#7587A6"},{tag:[v.definitionKeyword,v.modifier],color:"#F9EE98"},{tag:[v.propertyName,v.function(v.variableName)],color:"#937121"},{tag:[v.typeName,v.angleBracket,v.tagName],color:"#9B859D"}]}),it({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:v.comment,color:"#6B4E32"},{tag:[v.keyword,v.operator,v.derefOperator],color:"#EF5D32"},{tag:v.className,color:"#EFAC32",fontWeight:"bold"},{tag:[v.typeName,v.propertyName,v.function(v.variableName),v.definition(v.variableName)],color:"#EFAC32"},{tag:v.definition(v.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:v.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[v.number,v.bool],color:"#6C99BB"},{tag:[v.variableName,v.self],color:"#7DAF9C"},{tag:[v.string,v.special(v.brace),v.regexp],color:"#D9D762"},{tag:[v.angleBracket,v.tagName,v.attributeName],color:"#EFCB43"}]}),it({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:v.comment,color:"#404040"},{tag:[v.string,v.special(v.brace),v.regexp],color:"#00D8FF"},{tag:v.number,color:"#E62286"},{tag:[v.variableName,v.attributeName,v.self],color:"#E62286",fontWeight:"bold"},{tag:v.function(v.variableName),color:"#fff",fontWeight:"bold"}]}),it({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:v.comment,color:"#BCC8BA"},{tag:[v.string,v.special(v.brace),v.regexp],color:"#5D90CD"},{tag:[v.number,v.bool,v.null],color:"#46A609"},{tag:v.keyword,color:"#AF956F"},{tag:[v.definitionKeyword,v.modifier],color:"#C52727"},{tag:[v.angleBracket,v.tagName,v.attributeName],color:"#606060"},{tag:v.self,color:"#000"}]}),it({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:v.comment,color:"#0088FF"},{tag:v.string,color:"#3AD900"},{tag:v.regexp,color:"#80FFC2"},{tag:[v.number,v.bool,v.null],color:"#FF628C"},{tag:[v.definitionKeyword,v.modifier],color:"#FFEE80"},{tag:v.variableName,color:"#CCCCCC"},{tag:v.self,color:"#FF80E1"},{tag:[v.className,v.definition(v.propertyName),v.function(v.variableName),v.definition(v.typeName),v.labelName],color:"#FFDD00"},{tag:[v.keyword,v.operator],color:"#FF9D00"},{tag:[v.propertyName,v.typeName],color:"#80FFBB"},{tag:v.special(v.brace),color:"#EDEF7D"},{tag:v.attributeName,color:"#9EFFFF"},{tag:v.derefOperator,color:"#fff"}]}),it({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:v.comment,color:"#AEAEAE"},{tag:[v.string,v.special(v.brace),v.regexp],color:"#8DFF8E"},{tag:[v.className,v.definition(v.propertyName),v.function(v.variableName),v.function(v.definition(v.variableName)),v.definition(v.typeName)],color:"#A3EBFF"},{tag:[v.number,v.bool,v.null],color:"#62E9BD"},{tag:[v.keyword,v.operator],color:"#2BF1DC"},{tag:[v.definitionKeyword,v.modifier],color:"#F8FBB1"},{tag:[v.variableName,v.self],color:"#B683CA"},{tag:[v.angleBracket,v.tagName,v.typeName,v.propertyName],color:"#60A4F1"},{tag:v.derefOperator,color:"#E0E0E0"},{tag:v.attributeName,color:"#7BACCA"}]}),it({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:v.comment,color:"#6272a4"},{tag:[v.string,v.special(v.brace)],color:"#f1fa8c"},{tag:[v.number,v.self,v.bool,v.null],color:"#bd93f9"},{tag:[v.keyword,v.operator],color:"#ff79c6"},{tag:[v.definitionKeyword,v.typeName],color:"#8be9fd"},{tag:v.definition(v.typeName),color:"#f8f8f2"},{tag:[v.className,v.definition(v.propertyName),v.function(v.variableName),v.attributeName],color:"#50fa7b"}]}),it({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:v.comment,color:"#AAAAAA"},{tag:[v.keyword,v.operator,v.typeName,v.tagName,v.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[v.attributeName,v.definition(v.propertyName)],color:"#4F9FD0"},{tag:[v.className,v.string,v.special(v.brace)],color:"#CF4F5F"},{tag:v.number,color:"#CF4F5F",fontWeight:"bold"},{tag:v.variableName,fontWeight:"bold"}]}),it({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:v.comment,color:"#9995b7"},{tag:v.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[v.definitionKeyword,v.modifier],color:"#ff5792"},{tag:[v.className,v.tagName,v.definition(v.typeName)],color:"#0094f0"},{tag:[v.number,v.bool,v.null,v.special(v.brace)],color:"#5842ff"},{tag:[v.definition(v.propertyName),v.function(v.variableName)],color:"#0095a8"},{tag:v.typeName,color:"#b3694d"},{tag:[v.propertyName,v.variableName],color:"#fa8900"},{tag:v.operator,color:"#ff5792"},{tag:v.self,color:"#e64100"},{tag:[v.string,v.regexp],color:"#00b368"},{tag:[v.paren,v.bracket],color:"#0431fa"},{tag:v.labelName,color:"#00bdd6"},{tag:v.attributeName,color:"#e64100"},{tag:v.angleBracket,color:"#9995b7"}]}),it({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:v.comment,color:"#9893a5"},{tag:[v.bool,v.null],color:"#286983"},{tag:v.number,color:"#d7827e"},{tag:v.className,color:"#d7827e"},{tag:[v.angleBracket,v.tagName,v.typeName],color:"#56949f"},{tag:v.attributeName,color:"#907aa9"},{tag:v.punctuation,color:"#797593"},{tag:[v.keyword,v.modifier],color:"#286983"},{tag:[v.string,v.regexp],color:"#ea9d34"},{tag:v.variableName,color:"#d7827e"}]}),it({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:v.comment,color:"#CFCFCF"},{tag:[v.number,v.bool,v.null],color:"#E66C29"},{tag:[v.className,v.definition(v.propertyName),v.function(v.variableName),v.labelName,v.definition(v.typeName)],color:"#2EB43B"},{tag:v.keyword,color:"#D8B229"},{tag:v.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[v.definitionKeyword,v.modifier],color:"#925A47"},{tag:v.string,color:"#704D3D"},{tag:v.typeName,color:"#2F8996"},{tag:[v.variableName,v.propertyName],color:"#77ACB0"},{tag:v.self,color:"#77ACB0",fontWeight:"bold"},{tag:v.regexp,color:"#E3965E"},{tag:[v.tagName,v.angleBracket],color:"#BAA827"},{tag:v.attributeName,color:"#B06520"},{tag:v.derefOperator,color:"#000"}]}),it({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:v.comment,color:"#93A1A1"},{tag:v.string,color:"#2AA198"},{tag:v.regexp,color:"#D30102"},{tag:v.number,color:"#D33682"},{tag:v.variableName,color:"#268BD2"},{tag:[v.keyword,v.operator,v.punctuation],color:"#859900"},{tag:[v.definitionKeyword,v.modifier],color:"#073642",fontWeight:"bold"},{tag:[v.className,v.self,v.definition(v.propertyName)],color:"#268BD2"},{tag:v.function(v.variableName),color:"#268BD2"},{tag:[v.bool,v.null],color:"#B58900"},{tag:v.tagName,color:"#268BD2",fontWeight:"bold"},{tag:v.angleBracket,color:"#93A1A1"},{tag:v.attributeName,color:"#93A1A1"},{tag:v.typeName,color:"#859900"}]}),it({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:v.comment,color:"#8E908C"},{tag:[v.variableName,v.self,v.propertyName,v.attributeName,v.regexp],color:"#C82829"},{tag:[v.number,v.bool,v.null],color:"#F5871F"},{tag:[v.className,v.typeName,v.definition(v.typeName)],color:"#C99E00"},{tag:[v.string,v.special(v.brace)],color:"#718C00"},{tag:v.operator,color:"#3E999F"},{tag:[v.definition(v.propertyName),v.function(v.variableName)],color:"#4271AE"},{tag:v.keyword,color:"#8959A8"},{tag:v.derefOperator,color:"#4D4D4C"}]});const E2=[it({variant:"dark",settings:{background:"var(--cm-background)",foreground:"#abb2bf",caret:"#528bff",selection:"#3E4451",lineHighlight:"#2c313c",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:v.comment,color:"#5c6370"},{tag:v.variableName,color:"#abb2bf"},{tag:[v.string,v.special(v.brace)],color:"#98c379"},{tag:v.number,color:"#d19a66"},{tag:v.bool,color:"#d19a66"},{tag:v.null,color:"#d19a66"},{tag:v.keyword,color:"#c678dd",fontWeight:500},{tag:v.className,color:"#61afef"},{tag:v.definition(v.typeName),color:"#61afef"},{tag:v.typeName,color:"#56b6c2"},{tag:v.angleBracket,color:"#abb2bf"},{tag:v.tagName,color:"#e06c75"},{tag:v.attributeName,color:"#d19a66"},{tag:v.operator,color:"#56b6c2",fontWeight:500},{tag:[v.function(v.variableName)],color:"#61afef"},{tag:[v.propertyName],color:"#e5c07b"}]}),Se.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#2a7aa5",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px",borderBottomColor:"#4a90a5"}})],_2=[it({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#cceeff44",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:v.comment,color:"#708090"},{tag:v.variableName,color:"#000000"},{tag:[v.string,v.special(v.brace)],color:"#a11"},{tag:v.number,color:"#164"},{tag:v.bool,color:"#219"},{tag:v.null,color:"#219"},{tag:v.keyword,color:"#708",fontWeight:500},{tag:v.className,color:"#00f"},{tag:v.definition(v.typeName),color:"#00f"},{tag:v.typeName,color:"#085"},{tag:v.angleBracket,color:"#000000"},{tag:v.tagName,color:"#170"},{tag:v.attributeName,color:"#00c"},{tag:v.operator,color:"#a2f",fontWeight:500},{tag:[v.function(v.variableName)],color:"#00c"},{tag:[v.propertyName],color:"#05a"}]}),Se.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#005f87",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px"}})];function Qh(t){const{showPlaceholder:e,enableAI:n}=t;return e?"marimo-import":n?"ai":"none"}const I2=t=>{const{cellId:e,keymapConfig:n,hotkeys:o,enableAI:r,cellActions:s,completionConfig:a,lspConfig:l,diagnosticsConfig:c,displayConfig:d}=t,u=Qh(t);return[uC(n,o),[Se.domEventHandlers({drop:(m,p)=>{var f,g;const b=(f=m.dataTransfer)==null?void 0:f.files[0];if(b!=null&&b.type.startsWith("text/"))return m.preventDefault(),l4(p,b),!0;if(b!=null&&b.type.startsWith("image/"))return m.preventDefault(),c4(p,b),!0;const x=(g=m.dataTransfer)==null?void 0:g.getData("text/plain");if(x){m.preventDefault();const y=p.posAtCoords({x:m.clientX,y:m.clientY});return y!==null&&p.dispatch({changes:{from:y,to:y,insert:x},scrollIntoView:!0}),!0}return!1},dragover:m=>{m.preventDefault()}})],S2(),Sx(),h4({completionConfig:a,hotkeys:o,placeholderType:u,lspConfig:l,diagnosticsConfig:c}),m4({cellId:e,hotkeys:o,cellActions:s}),A2(t),[C2,(h=(m,p)=>{i4(m,p)},Ut.define(m=>new N2(m,h))),Se.baseTheme({".underline":{textDecoration:"underline",cursor:"pointer",color:"var(--link)"}})],c!=null&&c.enabled?f4():[],r&&Ys("inline_ai_tooltip")?[Mg({prompt:m=>(async function(p){var j,C;const b=`
113
124
  ${p.codeBefore}
114
125
  <rewrite_this>
115
126
  ${p.selection}
116
127
  </rewrite_this>
117
128
  ${p.codeAfter}
118
- `.trim(),x=o1();await r1();const f=await fetch(x.getAiURL("completion").toString(),{method:"POST",headers:x.headers(),body:JSON.stringify({prompt:p.prompt,code:b,selectedText:p.selection,includeOtherCode:"",language:p.language})}),g=((j=p.selection.match(/^\s*/))==null?void 0:j[0])||"",y=(C=f.body)==null?void 0:C.getReader();if(!y)throw new Error("Failed to get response reader");let w="";for(;;){const{done:N,value:k}=await y.read();if(N)break;w+=new TextDecoder().decode(k)}return w.startsWith(g)||(w=g+w),w})({prompt:m.prompt,selection:m.selection,codeBefore:m.codeBefore,codeAfter:m.codeAfter,language:pp(m.editorView)})}),$a.of({hideOnBlur:!0})]:[],y4(Le),v4(e,d.reference_highlighting??!1)];var h},R2=t=>{const{theme:e,hotkeys:n,completionConfig:o,cellId:r,lspConfig:s,diagnosticsConfig:a}=t,l=Zh(t);return[Se.lineWrapping,w4(),k4(),j4(),C4(),N4(),S4(),E4(),_4({position:"fixed",parent:document.querySelector("#App")??void 0}),I4(),e==="dark"?D2:M2,A4(s),S2(o),T4(),D4(),Mx(),Sn.high($t.of(B4)),M4(),O4(),R4.of(" "),c1(P4,{fallback:!0}),$t.of(z4),L4({placeholderType:l,completionConfig:o,hotkeys:n,cellId:r,lspConfig:{...s,diagnostics:a}}),F4.of(U4()),Mr.allowMultipleSelections.of(!0),E2(n),$t.of([{key:"Tab",run:c=>l1(c)||(d=>{const{from:u,to:h}=d.state.selection.main;if(u!==h)return!1;const m=d.state.doc.lineAt(h);return m.text.slice(0,h-m.from).trim()!==""&&G4(d)})(c)||W4(c),preventDefault:!0},{key:n.getHotkey("completion.moveDown").key,run:c=>Fo(c.state)!==null&&(ua(!0)(c),!0),preventDefault:!0},{key:n.getHotkey("completion.moveUp").key,run:c=>Fo(c.state)!==null&&(ua(!1)(c),!0),preventDefault:!0}]),$t.of([...$4,V4])]},L2={width:void 0,height:void 0};function em(t,e,n){return t[e]?Array.isArray(t[e])?t[e][0][n]:t[e][n]:e==="contentBoxSize"?t.contentRect[n==="inlineSize"?"width":"height"]:void 0}const hr=t=>{const e=P.c(8),{children:n,layerTop:o}=t,r=o!==void 0&&o;let s;e[0]!==n?(s=me.Children.toArray(n),e[0]=n,e[1]=s):s=e[1];const[a,l]=s,c=`second-icon absolute ${r?"top-[-2px] left-[-2px]":"bottom-[-2px] right-[-2px]"} rounded-full`;let d,u;return e[2]!==l||e[3]!==c?(d=i.jsx("div",{className:c,children:l}),e[2]=l,e[3]=c,e[4]=d):d=e[4],e[5]!==a||e[6]!==d?(u=i.jsxs("div",{className:"multi-icon relative w-fit",children:[a,d]}),e[5]=a,e[6]=d,e[7]=u):u=e[7],u};let tm,nm;tm=t=>{const e=P.c(79),{editing:n,status:o,disabled:r,staleInputs:s,edited:a,interrupted:l,elapsedTime:c,runStartTimestamp:d,lastRunStartTimestamp:u,uninstantiated:h}=t;if(!n)return null;const m=d??u;let p;e[0]!==m?(p=m?i.jsx(nm,{lastRanTime:m}):null,e[0]=m,e[1]=p):p=e[1];const b=p;if(r&&o==="running")return He.error("CellStatusComponent: disabled and running"),null;if(r&&s){let x,f,g,y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"This cell is stale, but it's disabled and can't be run"}),e[2]=x):x=e[2],e[3]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[3]=b,e[4]=f):f=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:i.jsxs(hr,{children:[i.jsx(We,{className:"h-5 w-5",strokeWidth:1.5}),i.jsx(dc,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[5]=g):g=e[5],e[6]!==f?(y=i.jsx(pe,{content:f,usePortal:!0,children:g}),e[6]=f,e[7]=y):y=e[7],y}if(r){let x,f,g,y;return e[8]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"This cell is disabled"}),e[8]=x):x=e[8],e[9]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[9]=b,e[10]=f):f=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("div",{className:"cell-status-icon cell-status-disabled","data-testid":"cell-status","data-status":"disabled",children:i.jsx(We,{className:"h-5 w-5",strokeWidth:1.5})}),e[11]=g):g=e[11],e[12]!==f?(y=i.jsx(pe,{content:f,usePortal:!0,children:g}),e[12]=f,e[13]=y):y=e[13],y}if(!s&&o==="disabled-transitively"){let x,f,g,y;return e[14]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"An ancestor of this cell is disabled, so it can't be run"}),e[14]=x):x=e[14],e[15]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[15]=b,e[16]=f):f=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"disabled-transitively",children:i.jsxs(hr,{layerTop:!0,children:[i.jsx(Rc,{className:"h-5 w-5",strokeWidth:1.5}),i.jsx(We,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[17]=g):g=e[17],e[18]!==f?(y=i.jsx(pe,{content:f,usePortal:!0,children:g}),e[18]=f,e[19]=y):y=e[19],y}if(s&&o==="disabled-transitively"){let x,f,g,y;return e[20]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"This cell is stale, but an ancestor is disabled so it can't be run"}),e[20]=x):x=e[20],e[21]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[21]=b,e[22]=f):f=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:i.jsxs(hr,{children:[i.jsx(dc,{className:"h-5 w-5",strokeWidth:1}),i.jsx(We,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[23]=g):g=e[23],e[24]!==f?(y=i.jsx(pe,{content:f,usePortal:!0,children:g}),e[24]=f,e[25]=y):y=e[25],y}if(o==="running"){let x,f,g,y,w;return e[26]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"This cell is running"}),e[26]=x):x=e[26],e[27]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[27]=b,e[28]=f):f=e[28],e[29]!==d?(g=cc.fromSeconds(d)||cc.now(),e[29]=d,e[30]=g):g=e[30],e[31]!==g?(y=i.jsx("div",{className:"cell-status-icon elapsed-time running","data-testid":"cell-status","data-status":"running",children:i.jsx(F2,{startTime:g})}),e[31]=g,e[32]=y):y=e[32],e[33]!==f||e[34]!==y?(w=i.jsx(pe,{content:f,usePortal:!0,children:y}),e[33]=f,e[34]=y,e[35]=w):w=e[35],w}if(o==="queued"){let x,f,g,y;return e[36]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"This cell is queued to run"}),e[36]=x):x=e[36],e[37]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[37]=b,e[38]=f):f=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("div",{className:"cell-status-icon cell-status-queued","data-testid":"cell-status","data-status":"queued",children:i.jsx(Ca,{className:"h-5 w-5",strokeWidth:1.5})}),e[39]=g):g=e[39],e[40]!==f?(y=i.jsx(pe,{content:f,usePortal:!0,children:g}),e[40]=f,e[41]=y):y=e[41],y}if(a||l||s||h){let x;e[42]!==c?(x=Wo(c),e[42]=c,e[43]=x):x=e[43];const f=x;let g;e[44]!==c||e[45]!==f?(g=c?i.jsx(Sa,{elapsedTime:f}):null,e[44]=c,e[45]=f,e[46]=g):g=e[46];const y=g;let w,j,C,N,k,E="";if(h)w="This cell has not yet been run";else if(l){let _;w="This cell was interrupted when it was last run",e[47]!==y?(_=i.jsxs("span",{children:["This cell ran for ",y," before being interrupted"]}),e[47]=y,e[48]=_):_=e[48],E=_}else if(a){let _;w="This cell has been modified since it was last run",e[49]!==y?(_=i.jsxs("span",{children:["This cell took ",y," to run"]}),e[49]=y,e[50]=_):_=e[50],E=_}else{let _;w="This cell has not been run with the latest inputs",e[51]!==y?(_=i.jsxs("span",{children:["This cell took ",y," to run"]}),e[51]=y,e[52]=_):_=e[52],E=_}return e[53]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx("div",{className:"cell-status-stale","data-testid":"cell-status","data-status":"outdated",children:i.jsx(dc,{className:"h-5 w-5",strokeWidth:1.5})}),e[53]=j):j=e[53],e[54]!==w?(C=i.jsx(pe,{content:w,usePortal:!0,children:j}),e[54]=w,e[55]=C):C=e[55],e[56]!==c||e[57]!==f||e[58]!==b||e[59]!==E?(N=c&&i.jsx(pe,{content:i.jsxs("div",{className:"flex flex-col gap-1",children:[E,b]}),usePortal:!0,children:i.jsx("div",{className:"elapsed-time hover-action","data-testid":"cell-status","data-status":"outdated",children:i.jsx("span",{children:f})})}),e[56]=c,e[57]=f,e[58]=b,e[59]=E,e[60]=N):N=e[60],e[61]!==C||e[62]!==N?(k=i.jsxs("div",{className:"cell-status-icon flex items-center gap-2",children:[C,N]}),e[61]=C,e[62]=N,e[63]=k):k=e[63],k}if(c!==null){let x;e[64]!==c?(x=Wo(c),e[64]=c,e[65]=x):x=e[65];const f=x;let g;e[66]!==c||e[67]!==f?(g=c?i.jsx(Sa,{elapsedTime:f}):null,e[66]=c,e[67]=f,e[68]=g):g=e[68];const y=g;let w,j,C,N;return e[69]!==y?(w=i.jsxs("span",{children:["This cell took ",y," to run"]}),e[69]=y,e[70]=w):w=e[70],e[71]!==b||e[72]!==w?(j=i.jsxs("div",{className:"flex flex-col gap-1",children:[w,b]}),e[71]=b,e[72]=w,e[73]=j):j=e[73],e[74]!==f?(C=i.jsx("div",{className:"cell-status-icon elapsed-time hover-action","data-testid":"cell-status","data-status":"idle",children:i.jsx("span",{children:f})}),e[74]=f,e[75]=C):C=e[75],e[76]!==j||e[77]!==C?(N=i.jsx(pe,{content:j,usePortal:!0,children:C}),e[76]=j,e[77]=C,e[78]=N):N=e[78],N}return null},Sa=t=>{const e=P.c(2);let n;return e[0]!==t.elapsedTime?(n=i.jsx("span",{className:"tracking-wide font-semibold",children:t.elapsedTime}),e[0]=t.elapsedTime,e[1]=n):n=e[1],n},nm=t=>{const e=P.c(4),n=new Date(1e3*t.lastRanTime),o=new Date;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0},e[0]=r):r=e[0];const s=d1(r);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0},e[1]=a):a=e[1];const l=d1(a),c=n.toDateString()===o.toDateString()?s:l,d=vg(n);let u;return e[2]!==d?(u=i.jsxs("span",{className:"text-muted-foreground",children:["(",d," ago)"]}),e[2]=d,e[3]=u):u=e[3],i.jsxs("span",{children:["Ran at"," ",i.jsx("strong",{className:"tracking-wide font-semibold",children:c.format(n)})," ",u]})},Wo=function(t){if(t===null)return"";const e=t,n=e/1e3;return n>=60?`${Math.floor(n/60)}m${Math.floor(n%60)}s`:n>=1?`${n.toFixed(2).toString()}s`:`${e.toFixed(0).toString()}ms`};const F2=t=>{const e=P.c(6);let n;e[0]!==t.startTime?(n=t.startTime.toMilliseconds(),e[0]=t.startTime,e[1]=n):n=e[1];const o=(function(a){const l=S.useRef(a),[c,d]=S.useState(a);return S.useEffect(()=>{const u=setInterval(()=>{d(cc.now().toMilliseconds())},17);return()=>clearInterval(u)},[]),c-l.current})(n);let r,s;return e[2]!==o?(r=Wo(o),e[2]=o,e[3]=r):r=e[3],e[4]!==r?(s=i.jsx("span",{children:r}),e[4]=r,e[5]=s):s=e[5],s};var Yi="ContextMenu",[B2,PC]=J4(Yi,[u1]),yt=u1(),[P2,om]=B2(Yi),rm=t=>{const{__scopeContextMenu:e,children:n,onOpenChange:o,dir:r,modal:s=!0}=t,[a,l]=S.useState(!1),c=yt(e),d=i3(o),u=S.useCallback(h=>{l(h),d(h)},[d]);return i.jsx(P2,{scope:e,open:a,onOpenChange:u,modal:s,children:i.jsx(l3,{...c,dir:r,open:a,onOpenChange:u,modal:s,children:n})})};rm.displayName=Yi;var sm="ContextMenuTrigger",am=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,disabled:o=!1,...r}=t,s=om(sm,n),a=yt(n),l=S.useRef({x:0,y:0}),c=S.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=S.useRef(0),u=S.useCallback(()=>window.clearTimeout(d.current),[]),h=m=>{l.current={x:m.clientX,y:m.clientY},s.onOpenChange(!0)};return S.useEffect(()=>u,[u]),S.useEffect(()=>{o&&u()},[o,u]),i.jsxs(i.Fragment,{children:[i.jsx(K4,{...a,virtualRef:c}),i.jsx(Y4.span,{"data-state":s.open?"open":"closed","data-disabled":o?"":void 0,...r,ref:e,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:o?t.onContextMenu:Or(t.onContextMenu,m=>{u(),h(m),m.preventDefault()}),onPointerDown:o?t.onPointerDown:Or(t.onPointerDown,Ds(m=>{u(),d.current=window.setTimeout(()=>h(m),700)})),onPointerMove:o?t.onPointerMove:Or(t.onPointerMove,Ds(u)),onPointerCancel:o?t.onPointerCancel:Or(t.onPointerCancel,Ds(u)),onPointerUp:o?t.onPointerUp:Or(t.onPointerUp,Ds(u))})]})});am.displayName=sm;var im=t=>{const{__scopeContextMenu:e,...n}=t,o=yt(e);return i.jsx(c3,{...o,...n})};im.displayName="ContextMenuPortal";var lm="ContextMenuContent",cm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=om(lm,n),s=yt(n),a=S.useRef(!1);return i.jsx(X4,{...s,...o,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{var c;(c=t.onCloseAutoFocus)==null||c.call(t,l),!l.defaultPrevented&&a.current&&l.preventDefault(),a.current=!1},onInteractOutside:l=>{var c;(c=t.onInteractOutside)==null||c.call(t,l),l.defaultPrevented||r.modal||(a.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});cm.displayName=lm,S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(Q4,{...r,...o,ref:e})}).displayName="ContextMenuGroup";var dm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(Z4,{...r,...o,ref:e})});dm.displayName="ContextMenuLabel";var um=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(H4,{...r,...o,ref:e})});um.displayName="ContextMenuItem";var hm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(e3,{...r,...o,ref:e})});hm.displayName="ContextMenuCheckboxItem",S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(t3,{...r,...o,ref:e})}).displayName="ContextMenuRadioGroup";var mm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(n3,{...r,...o,ref:e})});mm.displayName="ContextMenuRadioItem";var fm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(o3,{...r,...o,ref:e})});fm.displayName="ContextMenuItemIndicator";var pm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(q4,{...r,...o,ref:e})});pm.displayName="ContextMenuSeparator",S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(r3,{...r,...o,ref:e})}).displayName="ContextMenuArrow";var gm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(s3,{...r,...o,ref:e})});gm.displayName="ContextMenuSubTrigger";var bm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(a3,{...r,...o,ref:e,style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});function Ds(t){return e=>e.pointerType!=="mouse"?t(e):void 0}bm.displayName="ContextMenuSubContent";var xm=cm,ym=dm,vm=um,wm=hm,km=mm,jm=fm,Cm=pm,Nm=gm,Sm=bm;const Em=rm,_m=am,z2=u3(im);S.forwardRef((t,e)=>{const n=P.c(14);let o,r,s,a,l,c,d;return n[0]!==t?({className:r,inset:s,children:o,...a}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a):(o=n[1],r=n[2],s=n[3],a=n[4]),n[5]!==r||n[6]!==s?(l=h3({className:r,inset:s}),n[5]=r,n[6]=s,n[7]=l):l=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(p3,{className:"ml-auto h-4 w-4"}),n[8]=c):c=n[8],n[9]!==o||n[10]!==a||n[11]!==e||n[12]!==l?(d=i.jsxs(Nm,{ref:e,className:l,...a,children:[o,c]}),n[9]=o,n[10]=a,n[11]=e,n[12]=l,n[13]=d):d=n[13],d}).displayName=Nm.displayName;const Im="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2";S.forwardRef((t,e)=>{const n=P.c(9);let o,r,s,a;return n[0]!==t?({className:o,...r}=t,n[0]=t,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(s=ue(m1({subcontent:!0}),Im,o),n[3]=o,n[4]=s):s=n[4],n[5]!==r||n[6]!==e||n[7]!==s?(a=i.jsx(Sm,{ref:e,className:s,...r}),n[5]=r,n[6]=e,n[7]=s,n[8]=a):a=n[8],a}).displayName=Sm.displayName;const Xi=S.forwardRef((t,e)=>{const n=P.c(15);let o,r,s;n[0]!==t?({className:o,scrollable:s,...r}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]);const a=s===void 0||s;let l;n[4]!==o||n[5]!==a?(l=ue(m1(),Im,a&&"overflow-auto",o),n[4]=o,n[5]=a,n[6]=l):l=n[6];const c=a?"calc(var(--radix-context-menu-content-available-height) - 30px)":void 0;let d,u;return n[7]!==r.style||n[8]!==c?(d={...r.style,maxHeight:c},n[7]=r.style,n[8]=c,n[9]=d):d=n[9],n[10]!==r||n[11]!==e||n[12]!==l||n[13]!==d?(u=i.jsx(z2,{children:i.jsx(m3,{children:i.jsx(xm,{ref:e,className:l,style:d,...r})})}),n[10]=r,n[11]=e,n[12]=l,n[13]=d,n[14]=u):u=n[14],u});Xi.displayName=xm.displayName;const mr=S.forwardRef((t,e)=>{const n=P.c(13);let o,r,s,a,l,c;return n[0]!==t?({className:o,inset:r,variant:a,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a):(o=n[1],r=n[2],s=n[3],a=n[4]),n[5]!==o||n[6]!==r||n[7]!==a?(l=h1({className:o,inset:r,variant:a}),n[5]=o,n[6]=r,n[7]=a,n[8]=l):l=n[8],n[9]!==s||n[10]!==e||n[11]!==l?(c=i.jsx(vm,{ref:e,className:l,...s}),n[9]=s,n[10]=e,n[11]=l,n[12]=c):c=n[12],c});mr.displayName=vm.displayName,S.forwardRef((t,e)=>{const n=P.c(15);let o,r,s,a,l,c,d,u;return n[0]!==t?({className:s,children:r,checked:o,...a}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a):(o=n[1],r=n[2],s=n[3],a=n[4]),n[5]!==s?(l=ma({className:s}),n[5]=s,n[6]=l):l=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(c=ma(),n[7]=c):c=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("span",{className:c,children:i.jsx(jm,{children:i.jsx(g3,{className:"h-4 w-4"})})}),n[8]=d):d=n[8],n[9]!==o||n[10]!==r||n[11]!==a||n[12]!==e||n[13]!==l?(u=i.jsxs(wm,{ref:e,className:l,checked:o,...a,children:[d,r]}),n[9]=o,n[10]=r,n[11]=a,n[12]=e,n[13]=l,n[14]=u):u=n[14],u}).displayName=wm.displayName,S.forwardRef((t,e)=>{const n=P.c(13);let o,r,s,a,l,c,d;return n[0]!==t?({className:r,children:o,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==r?(a=ma({className:r}),n[4]=r,n[5]=a):a=n[5],n[6]===Symbol.for("react.memo_cache_sentinel")?(l=ma(),n[6]=l):l=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{className:l,children:i.jsx(jm,{children:i.jsx(b3,{className:"h-4 w-4 fill-current"})})}),n[7]=c):c=n[7],n[8]!==o||n[9]!==s||n[10]!==e||n[11]!==a?(d=i.jsxs(km,{ref:e,className:a,...s,children:[c,o]}),n[8]=o,n[9]=s,n[10]=e,n[11]=a,n[12]=d):d=n[12],d}).displayName=km.displayName,S.forwardRef((t,e)=>{const n=P.c(11);let o,r,s,a,l;return n[0]!==t?({className:o,inset:r,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==o||n[5]!==r?(a=f3({className:o,inset:r}),n[4]=o,n[5]=r,n[6]=a):a=n[6],n[7]!==s||n[8]!==e||n[9]!==a?(l=i.jsx(ym,{ref:e,className:a,...s}),n[7]=s,n[8]=e,n[9]=a,n[10]=l):l=n[10],l}).displayName=ym.displayName;const Am=S.forwardRef((t,e)=>{const n=P.c(9);let o,r,s,a;return n[0]!==t?({className:o,...r}=t,n[0]=t,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(s=ue(d3({className:o})),n[3]=o,n[4]=s):s=n[4],n[5]!==r||n[6]!==e||n[7]!==s?(a=i.jsx(Cm,{ref:e,className:s,...r}),n[5]=r,n[6]=e,n[7]=s,n[8]=a):a=n[8],a});Am.displayName=Cm.displayName;const Tm=t=>{const e=P.c(20),{connectionState:n,onClick:o,tooltipContent:r}=t;let s;e[0]!==n||e[1]!==r?(s=oa(n)||r,e[0]=n,e[1]=r,e[2]=s):s=e[2];const a=s;let l;e[3]!==a||e[4]!==n?(l=en(n)?a:i.jsxs("div",{className:"flex flex-col gap-4",children:[i.jsx("div",{children:a}),i.jsx("div",{className:"text-xs text-muted-foreground font-medium pt-1 -mt-2 border-t border-border",children:"Right-click for cell types"})]}),e[3]=a,e[4]=n,e[5]=l):l=e[5];const c=l;let d,u,h,m,p,b;return e[6]!==o?(d=()=>o==null?void 0:o({code:""}),e[6]=o,e[7]=d):d=e[7],e[8]!==n?(u=ue("shoulder-button hover-action",en(n)&&" inactive-button"),e[8]=n,e[9]=u):u=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(uc,{strokeWidth:1.8}),e[10]=h):h=e[10],e[11]!==d||e[12]!==u?(m=i.jsx(tn,{onClick:d,className:u,onMouseDown:Fn.preventFocus,shape:"circle",size:"small",color:"hint-green","data-testid":"create-cell-button",children:h}),e[11]=d,e[12]=u,e[13]=m):m=e[13],e[14]!==c||e[15]!==m?(p=i.jsx(pe,{content:c,children:m}),e[14]=c,e[15]=m,e[16]=p):p=e[16],e[17]!==o||e[18]!==p?(b=i.jsx(U2,{onClick:o,children:p}),e[17]=o,e[18]=p,e[19]=b):b=e[19],b},U2=t=>{const e=P.c(26),{children:n,onClick:o}=t,{createNewCell:r}=Ye();if(!o)return n;let s,a,l,c,d,u,h,m,p,b,x,f;return e[0]!==n?(s=i.jsx(_m,{children:n}),e[0]=n,e[1]=s):s=e[1],e[2]!==o?(a=g=>{g.stopPropagation(),o({code:""})},e[2]=o,e[3]=a):a=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("div",{className:"mr-3 text-muted-foreground",children:i.jsx(hc,{})}),e[4]=l):l=e[4],e[5]!==a?(c=i.jsxs(mr,{onSelect:a,children:[l,"Python cell"]},"python"),e[5]=a,e[6]=c):c=e[6],e[7]!==r||e[8]!==o?(d=g=>{g.stopPropagation(),Gn({autoInstantiate:!0,createNewCell:r}),o({code:Bo.markdown.defaultCode,hideCode:!0})},e[7]=r,e[8]=o,e[9]=d):d=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx("div",{className:"mr-3 text-muted-foreground",children:i.jsx(Zs,{})}),e[10]=u):u=e[10],e[11]!==d?(h=i.jsxs(mr,{onSelect:d,children:[u,"Markdown cell"]},"markdown"),e[11]=d,e[12]=h):h=e[12],e[13]!==r||e[14]!==o?(m=g=>{g.stopPropagation(),Gn({autoInstantiate:!0,createNewCell:r}),o({code:Bo.sql.defaultCode})},e[13]=r,e[14]=o,e[15]=m):m=e[15],e[16]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx("div",{className:"mr-3 text-muted-foreground",children:i.jsx(_o,{size:13,strokeWidth:1.5})}),e[16]=p):p=e[16],e[17]!==m?(b=i.jsxs(mr,{onSelect:m,children:[p,"SQL cell"]},"sql"),e[17]=m,e[18]=b):b=e[18],e[19]!==c||e[20]!==h||e[21]!==b?(x=i.jsxs(Xi,{children:[c,h,b]}),e[19]=c,e[20]=h,e[21]=b,e[22]=x):x=e[22],e[23]!==s||e[24]!==x?(f=i.jsxs(Em,{children:[s,x]}),e[23]=s,e[24]=x,e[25]=f):f=e[25],f};function Dm(t){return t!==x3&&!!(t&&t.trim().length>0)}function Mm(){const t=P.c(3),{splitCell:e,undoSplitCell:n}=Ye();let o;return t[0]!==e||t[1]!==n?(o=r=>{const s=Yp(r.cellId);if(!s)return;const a=gp(s);e(r);const{dismiss:l}=ze({title:"Cell split",action:i.jsx(Op,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{n({...r,snapshot:a}),c()},children:"Undo"})}),c=l},t[0]=e,t[1]=n,t[2]=o):o=t[2],Ce(o)}Da=function(t){const e=P.c(54),{cell:n,closePopover:o}=t,{createNewCell:r,updateCellConfig:s,updateCellName:a,moveCell:l,sendToTop:c,sendToBottom:d,addColumnBreakpoint:u,clearCellOutput:h}=Ye(),m=Mm(),p=Va(n==null?void 0:n.cellId),b=!ie(Kp),x=Cr(),{openModal:f}=Pn(),g=Ct(tr),y=ie(mc),w=ie(p1),j=ie(To),C=ie(y3),{saveCellConfig:N}=qe();if(!n||j){let H;return e[0]===Symbol.for("react.memo_cache_sentinel")?(H=[],e[0]=H):H=e[0],H}const{cellId:k,config:E,getEditorView:_,name:I,hasOutput:A,hasConsoleOutput:O,status:D}=n;let M;e[1]!==k||e[2]!==E.disabled||e[3]!==N||e[4]!==s?(M=async()=>{const H={disabled:!E.disabled};await N({configs:{[k]:H}}),s({cellId:k,config:H})},e[1]=k,e[2]=E.disabled,e[3]=N,e[4]=s,e[5]=M):M=e[5];const R=M;let L;e[6]!==k||e[7]!==E.hide_code||e[8]!==_||e[9]!==N||e[10]!==s?(L=async()=>{const H={hide_code:!E.hide_code};await N({configs:{[k]:H}}),s({cellId:k,config:H});const Y=_();Y&&(H.hide_code?Y.contentDOM.blur():Y.focus())},e[6]=k,e[7]=E.hide_code,e[8]=_,e[9]=N,e[10]=s,e[11]=L):L=e[11];const z=L;let T,F,$,W,G,X;return e[12]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx(bd,{size:13,strokeWidth:1.5}),e[12]=T):T=e[12],e[13]!==k||e[14]!==I||e[15]!==f||e[16]!==a?(F=()=>{f(i.jsxs(io,{children:[i.jsx(yr,{children:i.jsx(so,{children:"Rename cell"})}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Ao,{htmlFor:"cell-name",children:"Cell name"}),i.jsx(ag,{placeholder:"cell name",value:I,onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),H.stopPropagation(),f(null))},onChange:H=>a({cellId:k,name:H})})]})]}))},e[13]=k,e[14]=I,e[15]=f,e[16]=a,e[17]=F):F=e[17],e[18]!==k||e[19]!==a?($=H=>a({cellId:k,name:H}),e[18]=k,e[19]=a,e[20]=$):$=e[20],e[21]!==o?(W=()=>o==null?void 0:o(),e[21]=o,e[22]=W):W=e[22],e[23]!==I||e[24]!==$||e[25]!==W?(G=i.jsx(ag,{placeholder:"cell name",value:I,onChange:$,onEnterKey:W}),e[23]=I,e[24]=$,e[25]=W,e[26]=G):G=e[26],e[27]!==u||e[28]!==y||e[29]!==C||e[30]!==w||e[31]!==b||e[32]!==k||e[33]!==h||e[34]!==E.disabled||e[35]!==E.hide_code||e[36]!==r||e[37]!==x||e[38]!==_||e[39]!==O||e[40]!==A||e[41]!==l||e[42]!==I||e[43]!==p||e[44]!==d||e[45]!==c||e[46]!==g||e[47]!==m||e[48]!==D||e[49]!==F||e[50]!==G||e[51]!==R||e[52]!==z?(X=[[{icon:T,label:"Name",disableClick:!0,handle:G2,handleHeadless:F,rightElement:G},{icon:i.jsx(Uo,{size:13,strokeWidth:1.5}),label:"Run cell",hotkey:"cell.run",hidden:D==="running"||D==="queued"||D==="disabled-transitively"||E.disabled,handle:()=>p()},{icon:i.jsx(Rr,{size:13,strokeWidth:1.5}),label:"AI completion",hidden:!y,handle:()=>{g(H=>(H==null?void 0:H.cellId)===k?null:{cellId:k})},hotkey:"cell.aiCompletion"},{icon:i.jsx(Pa,{size:13,strokeWidth:1.5}),label:"Split cell",hotkey:"cell.splitCell",handle:()=>m({cellId:k})},{icon:i.jsx(Cc,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!A,handle:()=>(function(H){const Y=document.getElementById(f1.create(H));Y&&(Y.classList.add("printing-output"),Dp(Y,"result.png").finally(()=>{Y.classList.remove("printing-output")}))})(k)},{icon:i.jsx(Qp,{size:13,strokeWidth:1.5}),label:"Format cell",hotkey:"cell.format",handle:()=>{const H=_();H&&Xp({[k]:H})}},{icon:E.hide_code?i.jsx(Zp,{size:13,strokeWidth:1.5}):i.jsx($l,{size:13,strokeWidth:1.5}),label:E.hide_code?"Show code":"Hide code",handle:z,hotkey:"cell.hideCode"},{icon:E.disabled?i.jsx(Et,{size:13,strokeWidth:1.5}):i.jsx(_t,{size:13,strokeWidth:1.5}),label:"Reactive execution",rightElement:i.jsx(fc,{"data-testid":"cell-disable-switch",checked:!E.disabled,size:"sm",onCheckedChange:R}),handle:R},{icon:i.jsx(Ks,{size:13,strokeWidth:1.5}),label:"Clear output",hidden:!(A||O),handle:()=>{h({cellId:k})}}],[{icon:i.jsx(Zs,{}),label:"Convert to Markdown",hotkey:"cell.viewAsMarkdown",handle:()=>{const H=_();H&&(Gn({autoInstantiate:w,createNewCell:r}),co(H,{language:"markdown",keepCodeAsIs:!1}))}},{icon:i.jsx(_o,{size:13,strokeWidth:1.5}),label:"Convert to SQL",handle:()=>{const H=_();H&&(Gn({autoInstantiate:w,createNewCell:r}),co(H,{language:"sql",keepCodeAsIs:!1}))}},{icon:i.jsx(hc,{}),label:"Toggle as Python",handle:()=>{const H=_();H&&(Gn({autoInstantiate:w,createNewCell:r}),v3(H,"python",{force:!0}))}}],[{icon:i.jsxs(hr,{children:[i.jsx(Wr,{size:13,strokeWidth:1.5}),i.jsx(sa,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>r({cellId:k,before:!0})},{icon:i.jsxs(hr,{children:[i.jsx(Wr,{size:13,strokeWidth:1.5}),i.jsx($n,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>r({cellId:k,before:!1})},{icon:i.jsx(sa,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>l({cellId:k,before:!0})},{icon:i.jsx($n,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>l({cellId:k,before:!1})},{icon:i.jsx(g1,{size:13,strokeWidth:1.5}),label:"Move cell left",hotkey:"cell.moveLeft",handle:()=>l({cellId:k,direction:"left"}),hidden:C!=="columns"},{icon:i.jsx(fa,{size:13,strokeWidth:1.5}),label:"Move cell right",hotkey:"cell.moveRight",handle:()=>l({cellId:k,direction:"right"}),hidden:C!=="columns"},{icon:i.jsx(Ma,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>c({cellId:k,scroll:!1})},{icon:i.jsx(gt,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>d({cellId:k,scroll:!1})},{icon:i.jsx(w3,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",hidden:C!=="columns",handle:()=>u({cellId:k})}],[{icon:i.jsx(q1,{size:13,strokeWidth:1.5}),label:"Copy link to cell",disabled:!Dm(I),tooltip:Dm(I)?void 0:"Only named cells can be linked to",handle:async()=>{await Eo((function(H){const Y=new URL(window.location.href);return Y.hash=`scrollTo=${encodeURIComponent(H)}`,Y.toString()})(I)),ze({description:"Link copied to clipboard"})}}],[{label:"Delete",hidden:!b,variant:"danger",icon:i.jsx(ec,{size:13,strokeWidth:1.5}),handle:()=>{x({cellId:k})}}]].map($2).filter(W2),e[27]=u,e[28]=y,e[29]=C,e[30]=w,e[31]=b,e[32]=k,e[33]=h,e[34]=E.disabled,e[35]=E.hide_code,e[36]=r,e[37]=x,e[38]=_,e[39]=O,e[40]=A,e[41]=l,e[42]=I,e[43]=p,e[44]=d,e[45]=c,e[46]=g,e[47]=m,e[48]=D,e[49]=F,e[50]=G,e[51]=R,e[52]=z,e[53]=X):X=e[53],X};function W2(t){return t.length>0}function $2(t){return t.filter(V2)}function V2(t){return!t.hidden}function G2(t){t==null||t.stopPropagation(),t==null||t.preventDefault()}let Qi;Qi=me.memo(me.forwardRef((t,e)=>{const n=P.c(35);let o,r,s;n[0]!==t?({children:o,showTooltip:s,...r}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]);const a=s===void 0||s,[l,c]=S.useState(!1);let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=()=>c(!1),n[4]=d):d=n[4];const u=d;let h;n[5]!==r?(h={cell:r,closePopover:u},n[5]=r,n[6]=h):h=n[6];const m=Da(h),p=j3();let b,x,f,g,y,w;if(n[7]===Symbol.for("react.memo_cache_sentinel")?(b=()=>({toggle:()=>c(q2)}),n[7]=b):b=n[7],S.useImperativeHandle(e,b),n[8]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Fp,{placeholder:"Search actions...",className:"h-6 m-1"}),n[8]=x):x=n[8],n[9]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Lp,{children:"No results"}),n[9]=f):f=n[9],n[10]!==m){let I;n[12]!==m.length?(I=(A,O)=>i.jsxs(S.Fragment,{children:[i.jsx(C3,{children:A.map(D=>{let M=i.jsxs("div",{className:"flex items-center flex-1",children:[D.icon&&i.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:D.icon}),i.jsx("div",{className:"flex-1",children:D.label}),i.jsxs("div",{className:"shrink-0 text-sm",children:[D.hotkey&&b1(D.hotkey),D.rightElement]})]});return D.tooltip&&(M=i.jsx(pe,{content:D.tooltip,delayDuration:100,children:M})),i.jsx(Jl,{className:ue(D.disabled&&"opacity-50!"),onSelect:()=>{D.disableClick||D.disabled||(D.handle(),c(!1))},variant:D.variant,children:M},D.label)})},O),O<m.length-1&&i.jsx(N3,{})]},O),n[12]=m.length,n[13]=I):I=n[13],g=m.map(I),n[10]=m,n[11]=g}else g=n[11];n[14]!==g?(y=i.jsxs(Bp,{children:[x,i.jsxs(S3,{children:[f,g]})]}),n[14]=g,n[15]=y):y=n[15],n[16]!==p||n[17]!==y?(w=i.jsx(Kl,{className:"w-[300px] p-0 pt-1 overflow-auto",scrollable:!0,...p,children:y}),n[16]=p,n[17]=y,n[18]=w):w=n[18];const j=w;if(!a){let I,A;return n[19]!==o?(I=i.jsx(pc,{asChild:!0,children:o}),n[19]=o,n[20]=I):I=n[20],n[21]!==j||n[22]!==l||n[23]!==I?(A=i.jsxs(ta,{open:l,onOpenChange:c,children:[I,j]}),n[21]=j,n[22]=l,n[23]=I,n[24]=A):A=n[24],A}let C;n[25]===Symbol.for("react.memo_cache_sentinel")?(C=i.jsx(E3,{tabIndex:-1,children:St("cell.cellActions")}),n[25]=C):C=n[25];const N=!l&&C;let k,E,_;return n[26]!==o?(k=i.jsx(_3,{children:i.jsx(pc,{className:"flex",children:o})}),n[26]=o,n[27]=k):k=n[27],n[28]!==N||n[29]!==k?(E=i.jsxs(I3,{delayDuration:200,disableHoverableContent:!0,children:[N,k]}),n[28]=N,n[29]=k,n[30]=E):E=n[30],n[31]!==j||n[32]!==l||n[33]!==E?(_=i.jsxs(ta,{open:l,onOpenChange:c,children:[E,j]}),n[31]=j,n[32]=l,n[33]=E,n[34]=_):_=n[34],_})),zc=me.memo(t=>{const e=P.c(5),{children:n,cellId:o}=t;let r;e[0]!==o?(r=k3(o),e[0]=o,e[1]=r):r=e[1];const s=ie(r);if(!s)return null;let a;return e[2]!==n||e[3]!==s?(a=i.jsx(Qi,{showTooltip:!1,...s,children:n}),e[2]=n,e[3]=s,e[4]=a):a=e[4],a});function q2(t){return!t}zc.displayName="ConnectionCellActionsDropdown";const Om=t=>{const e=P.c(35),{children:n,cellId:o,getEditorView:r}=t,s=Lr(o),a=Fr(o),l=!gc(a.output),c=a.consoleOutputs.length>0;let d;e[0]!==s.config||e[1]!==s.name||e[2]!==o||e[3]!==a.status||e[4]!==r||e[5]!==l||e[6]!==c?(d={cell:{cellId:o,name:s.name,config:s.config,status:a.status,hasOutput:l,hasConsoleOutput:c,getEditorView:r}},e[0]=s.config,e[1]=s.name,e[2]=o,e[3]=a.status,e[4]=r,e[5]=l,e[6]=c,e[7]=d):d=e[7];const u=Da(d),[h,m]=me.useState(),p=!!h;let b,x,f,g,y,w,j,C,N,k;if(e[8]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(mp,{size:13,strokeWidth:1.5}),e[8]=b):b=e[8],e[9]!==o?(x=async()=>{var I;if((I=window.getSelection())==null?void 0:I.toString())return void document.execCommand("copy");const _=document.getElementById(f1.create(o));_?await Eo(_.textContent??""):He.warn("cell-context-menu: output not found")},e[9]=o,e[10]=x):x=e[10],e[11]!==u||e[12]!==n||e[13]!==r||e[14]!==h||e[15]!==p||e[16]!==x){const E=[[{label:"Copy",hidden:p,icon:b,handle:x},{label:"Cut",hidden:!!h,icon:i.jsx(Pa,{size:13,strokeWidth:1.5}),handle:H2},{label:"Paste",hidden:!!h,icon:i.jsx(Bc,{size:13,strokeWidth:1.5}),handle:async()=>{const I=r();if(I)try{const A=await navigator.clipboard.readText();if(A){const{from:O,to:D}=I.state.selection.main,M=I.state.update({changes:{from:O,to:D,insert:A}});I.dispatch(M)}}catch(A){const O=A;He.error("Failed to paste from clipboard",O),A3({command:"paste"})}}},{label:"Copy image",hidden:!h,icon:i.jsx(Oa,{size:13,strokeWidth:1.5}),handle:async()=>{if(h){const I=await fetch(h.src),A=await I.blob(),O=new ClipboardItem({[A.type]:A});await navigator.clipboard.write([O]).then(J2).catch(K2)}}},{icon:i.jsx(Cc,{size:13,strokeWidth:1.5}),label:"Download image",hidden:!h,handle:()=>{if(h){const I=document.createElement("a");I.download="image.png",I.href=h.src,I.click()}}},{label:"Go to Definition",icon:i.jsx(D3,{size:13,strokeWidth:1.5}),handle:()=>{const I=r();I&&T3(I)}}],...u];let _;g=Em,e[23]===Symbol.for("react.memo_cache_sentinel")?(_=I=>{I.target instanceof HTMLImageElement?m(I.target):m(void 0)},e[23]=_):_=e[23],e[24]!==n?(y=i.jsx(_m,{onContextMenu:_,asChild:!0,children:n}),e[24]=n,e[25]=y):y=e[25],f=Xi,w="w-[300px]",j=!0,C=E.map((I,A)=>i.jsxs(S.Fragment,{children:[I.map(X2),A<E.length-1&&i.jsx(Am,{})]},A)),e[11]=u,e[12]=n,e[13]=r,e[14]=h,e[15]=p,e[16]=x,e[17]=f,e[18]=g,e[19]=y,e[20]=w,e[21]=j,e[22]=C}else f=e[17],g=e[18],y=e[19],w=e[20],j=e[21],C=e[22];return e[26]!==f||e[27]!==w||e[28]!==j||e[29]!==C?(N=i.jsx(f,{className:w,scrollable:j,children:C}),e[26]=f,e[27]=w,e[28]=j,e[29]=C,e[30]=N):N=e[30],e[31]!==g||e[32]!==y||e[33]!==N?(k=i.jsxs(g,{children:[y,N]}),e[31]=g,e[32]=y,e[33]=N,e[34]=k):k=e[34],k};function H2(){document.execCommand("cut")}function J2(){ze({title:"Copied image to clipboard"})}function K2(t){ze({title:"Failed to copy image to clipboard. Try downloading instead.",description:t.message}),He.error("Failed to copy image to clipboard",t)}function Y2(t){t.stopPropagation()}function X2(t){if(t.hidden)return null;let e=i.jsxs("div",{className:"flex items-center flex-1",children:[t.icon&&i.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:t.icon}),i.jsx("div",{className:"flex-1",children:t.label}),i.jsxs("div",{className:"shrink-0 text-sm",children:[t.hotkey&&b1(t.hotkey),t.rightElement]})]});return t.tooltip&&(e=i.jsx(pe,{delayDuration:100,content:t.tooltip,children:e})),i.jsx(S.Fragment,{children:t.disableClick?i.jsx("div",{className:h1({className:t.disabled?"opacity-50!":"",variant:t.variant}),onKeyDown:Y2,children:e}):i.jsx(mr,{className:t.disabled?"opacity-50!":"",onSelect:n=>{t.disableClick||t.disabled||t.handle(n)},variant:t.variant,children:e})},t.label)}if(cg)dg(RC),cg();else if(!("Bun"in globalThis)){const t=await mt(()=>import("./loro_wasm_bg-C1ks32Vm.js").then(async e=>(await e.__tla,e)).then(e=>e.w),[],import.meta.url);dg(new WebAssembly.Instance(t.default,{"./loro_wasm_bg.js":OC}).exports)}const Q2=["Map","Text","List","Tree","MovableList","Counter"];function Rm(t){if(typeof t!="object"||t==null)return!1;const e=Object.getPrototypeOf(t);return e!=null&&typeof e=="object"&&typeof e.kind=="function"&&Q2.includes(t.kind())}ug.prototype.toJsonWithReplacer=function(t){const e=new Set,n=this,o=(a,l)=>{if(typeof l=="string"&&l.startsWith("cid:")&&!e.has(l)){e.add(l);const d=n.getContainerById(l);if(d==null)throw new Error(`ContainerID not found: ${l}`);const u=t(a,d);if(u===d){const h=d.getShallowValue();return typeof h=="object"?r(h):h}if(Rm(u))throw new Error("Using new container is not allowed in toJsonWithReplacer");return typeof u=="object"&&u!=null?r(u):u}if(typeof l=="object"&&l!=null)return r(l);const c=t(a,l);if(Rm(c))throw new Error("Using new container is not allowed in toJsonWithReplacer");return c},r=a=>{if(Array.isArray(a))return a.map((c,d)=>o(d,c)).filter(c=>c!==void 0);const l={};for(const[c,d]of Object.entries(a)){const u=o(c,d);u!==void 0&&(l[c]=u)}return l},s=n.getShallowValue();return r(s)};const Z2=Se.baseTheme({".loro-cursor":{position:"absolute",width:"2px",display:"inline-block",height:"1.2em"},".loro-cursor::before":{position:"absolute",top:"1.3em",left:"0",content:"var(--rtc-name)",padding:"2px 6px",fontSize:"12px",borderRadius:"3px",whiteSpace:"nowrap",userSelect:"none",backgroundColor:"inherit",opacity:"0.7"},".loro-selection":{opacity:"0.5"}}),fr=tt.define(),Zi=Dt.define({create:()=>({remoteCursors:new Map,isCheckout:!1}),update(t,e){for(const n of e.effects)if(n.is(fr))switch(n.value.type){case"update":{const{peer:o,user:r,cursor:s}=n.value;t.remoteCursors.set(o,{uid:o,cursor:s,user:r});break}case"delete":t.remoteCursors.delete(n.value.peer);break;case"checkout":t.isCheckout=n.value.checkout}return t}}),Lm=t=>{const e=t.transactions.flatMap(n=>n.effects).filter(n=>n.is(fr));return t.docChanged||t.viewportChanged||e.length>0};class Ms{constructor(e,n,o,r,s){this.left=void 0,this.top=void 0,this.height=void 0,this.name=void 0,this.colorClassName=void 0,this.left=e,this.top=n,this.height=o,this.name=r,this.colorClassName=s}draw(){const e=document.createElement("div");return this.adjust(e),e}update(e){return this.adjust(e),!0}adjust(e){e.style.left=`${this.left}px`,e.style.top=`${this.top}px`,e.style.height=`${this.height}px`,e.className=`loro-cursor ${this.colorClassName}`,e.style.setProperty("--rtc-name",`"${this.name}"`)}eq(e){return this.left===e.left&&this.top===e.top&&this.height===e.height&&this.name===e.name}static createCursor(e,n,o,r){const s=Ms.calculateAbsoluteCursorPosition(n,e);if(!s)return[];const a=e.scrollDOM.getBoundingClientRect(),l=(e.textDirection===O3.LTR?a.left:a.right-e.scrollDOM.clientWidth)-e.scrollDOM.scrollLeft,c=a.top-e.scrollDOM.scrollTop;return[new Ms(s.left-l,s.top-c,s.bottom-s.top,o,r)]}static calculateAbsoluteCursorPosition(e,n){const o=Math.max(0,Math.min(n.state.doc.length,e.anchor));return n.coordsAtPos(o,e.assoc||1)}}const ey=(t,e,n,o)=>{const r=[],{updated:s,added:a}=n;for(const l of[...s,...a]){const c=Fm(t,e,l,o);c&&r.push(c)}return r},Fm=(t,e,n,o)=>{const r=e.getAllStates()[n];if(!r||n===t.peerIdStr||r.scopeId!==o)return;if(r.type==="delete")return fr.of({type:"delete",peer:r.uid,scopeId:r.scopeId});const s=hg.decode(r.cursor.anchor),a=t.getCursorPos(s).offset;let l=a;if(r.cursor.head){const c=hg.decode(r.cursor.head);l=t.getCursorPos(c).offset}return fr.of({type:"update",peer:r.uid,scopeId:r.scopeId,cursor:{anchor:a,head:l},user:r.user})};class ty{constructor(e,n,o,r,s,a,l){this.sub=void 0,this.view=void 0,this.doc=void 0,this.user=void 0,this.awareness=void 0,this.getTextFromDoc=void 0,this.scopeId=void 0,this.getUserId=void 0,this.view=e,this.doc=n,this.user=o,this.awareness=r,this.getTextFromDoc=s,this.scopeId=a,this.getUserId=l,this.sub=this.doc.subscribe(c=>{if(c.by==="local"){const d=[];for(const u of this.awareness.peers()){const h=Fm(this.doc,this.awareness,u,this.scopeId);h&&d.push(h)}this.view.dispatch({effects:d})}else c.by==="checkout"&&this.view.dispatch({effects:[fr.of({type:"checkout",checkout:this.doc.isDetached()})]})})}update(e){if(!e.selectionSet&&!e.focusChanged&&!e.docChanged)return;const n=e.state.selection.main;if(this.view.hasFocus&&!this.doc.isDetached()){const o=oy({doc:this.doc,getTextFromDoc:this.getTextFromDoc,anchor:n.anchor,head:n.head});this.awareness.setLocalState({type:"update",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId,cursor:o,user:this.user})}else this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}destroy(){var e;(e=this.sub)==null||e.call(this),this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}}class ny{constructor(e,n,o,r){this._awarenessListener=void 0,this.view=void 0,this.doc=void 0,this.awareness=void 0,this.scopeId=void 0,this.view=e,this.doc=n,this.awareness=o,this.scopeId=r;const s=async(a,l)=>{l!=="local"&&this.view.dispatch({effects:ey(this.doc,this.awareness,a,this.scopeId)})};this._awarenessListener=s,this.awareness.addListener(s)}destroy(){this._awarenessListener&&this.awareness.removeListener(this._awarenessListener)}}const oy=({doc:t,getTextFromDoc:e,anchor:n,head:o})=>{var a,l;n===o&&(o=void 0);const r=(a=e(t).getCursor(n))==null?void 0:a.encode();if(!r)throw new Error("cursor head not found");let s;return o!==void 0&&(s=(l=e(t).getCursor(o))==null?void 0:l.encode()),{anchor:r,head:s}},Os=["bg-(--amber-6)","bg-(--blue-6)","bg-(--crimson-6)","bg-(--cyan-6)","bg-(--grass-6)","bg-(--gray-6)","bg-(--green-6)","bg-(--lime-6)","bg-(--orange-6)","bg-(--purple-6)","bg-(--red-6)","bg-(--sage-6)","bg-(--sky-6)","bg-(--slate-6)"],ry=(t,e,n)=>Wt.define(o=>new sy(o,t,e,n)),xo=ac.define();class sy{constructor(e,n,o,r){this.sub=void 0,this.isInitDispatch=!1,this.view=void 0,this.doc=void 0,this.docPath=void 0,this.getTextFromDoc=void 0,this.onRemoteUpdate=s=>{if(s.by!=="local")if(s.by!=="checkout"){if(s.by==="import"){const a=[];let l=0;for(const{diff:c,path:d}of s.events){if(d.join("/")!==this.docPath.join("/")||c.type!=="text")continue;const u=c.diff;for(const h of u)h.insert?a.push({from:l,to:l,insert:h.insert}):h.delete?(a.push({from:l,to:l+h.delete}),l+=h.delete):h.retain!=null&&(l+=h.retain);a.length>0&&this.view.dispatch({changes:a,annotations:[xo.of(this)]})}}}else this.view.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:this.getTextFromDoc(this.doc).toString()}],annotations:[xo.of(this)]})},this.view=e,this.doc=n,this.docPath=o,this.getTextFromDoc=r,this.sub=n.subscribe(this.onRemoteUpdate),Promise.resolve().then(()=>{this.isInitDispatch=!0;const s=this.view.state.doc.toString(),a=this.getTextFromDoc(this.doc);s!==a.toString()&&e.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:a.toString()}]})})}update(e){if(this.isInitDispatch)return void(this.isInitDispatch=!1);if(!e.docChanged||e.transactions.length>0&&(e.transactions[0].annotation(xo)===this||e.transactions[0].annotation(xo)==="undo"))return;let n=0;e.changes.iterChanges((o,r,s,a,l)=>{const c=l.sliceString(0,l.length,`
119
- `);o!==r&&this.getTextFromDoc(this.doc).delete(o+n,r-o),c.length>0&&this.getTextFromDoc(this.doc).insert(o+n,c),n+=c.length-(r-o)}),this.doc.commit()}destroy(){var e;(e=this.sub)==null||e.call(this),this.sub=void 0}}const vt=He.get("rtc"),Bm=vt.get("awareness").disabled(),el="awareness:",yo=Bt(void 0),lt=new ug,Rs=new class{constructor(t,e=3e4){this.listeners=new Set,this.inner=new LC(t,e),this.peer=t,this.timeout=e}apply(t,e="remote"){const{updated:n,added:o}=this.inner.apply(t);this.listeners.forEach(r=>{r({updated:n,added:o,removed:[]},e)}),this.startTimerIfNotEmpty()}setLocalState(t){const e=this.inner.getState(this.peer)==null;this.inner.setLocalState(t),e?this.listeners.forEach(n=>{n({updated:[],added:[this.inner.peer()],removed:[]},"local")}):this.listeners.forEach(n=>{n({updated:[this.inner.peer()],added:[],removed:[]},"local")}),this.startTimerIfNotEmpty()}getLocalState(){return this.inner.getState(this.peer)}getAllStates(){return this.inner.getAllStates()}encode(t){return this.inner.encode(t)}encodeAll(){return this.inner.encodeAll()}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}peers(){return this.inner.peers()}destroy(){clearInterval(this.timer),this.listeners.clear()}startTimerIfNotEmpty(){this.inner.isEmpty()||this.timer!=null||(this.timer=setInterval(()=>{const t=this.inner.removeOutdated();t.length>0&&this.listeners.forEach(e=>{e({updated:[],added:[],removed:t},"timeout")}),this.inner.isEmpty()&&(clearInterval(this.timer),this.timer=void 0)},this.timeout/2))}}(lt.peerIdStr),tl=L3(()=>{vt.debug("creating websocket");const t=o1().getWsSyncURL(w1()).toString(),e=new vC(t,void 0,{maxRetries:10,debug:!1,startClosed:!0,connectionTimeout:1e4});return Promise.resolve().then(async()=>{await r1(),F3()==="edit"&&e.reconnect()}),e.addEventListener("message",async n=>{const o=n.data,r=await o.arrayBuffer(),s=new Uint8Array(r);if((function(a,l){return new TextDecoder().decode(a.slice(0,l.length))===l})(s,el)){const a=(function(l,c){return l.slice(c.length)})(s,el);return Rs.apply(a),void Bm.debug("applied awareness update")}lt.import(s),vt.debug("imported doc change. new doc:",lt.toJSON()),Le.get(yo)!==lt&&Le.set(yo,lt)}),e.addEventListener("open",()=>{vt.debug("websocket open")}),e.addEventListener("close",n=>{vt.warn("websocket close",n),Le.get(yo)===lt&&Le.set(yo,void 0)}),e});function nl(t,e,n=""){if(Qt())return{extension:[],code:n};const o=lt.getByPath(`codes/${t}`)!==void 0,r=lt.getMap("codes").getOrCreateContainer(t,new Sc);o||(vt.log("initializing code for new cell",n),r.insert(0,n));const s={get name(){return Le.get(k1)||"Anonymous"},get colorClassName(){return(a=>{if(typeof a=="string"){let l=0;for(let c=0;c<a.length;c++)l=(l<<5)-l+a.charCodeAt(c),l=Math.trunc(l);return Os[Math.abs(l)%Os.length]}return Os[a%Os.length]})(this.name)}};return{code:n.toString(),extension:[ay(t),iy(t),ly(lt,Rs,s,()=>r,t),ry(lt,["codes",t],()=>r)]}}function ay(t){const e=(o,r)=>{const s=o.state.field(ha).type,a=r.toString();a&&a!==s&&(vt.debug(`[incoming] setting language type: ${s} -> ${a}`),co(o,{language:a,keepCodeAsIs:!0}))},n=(o,r)=>{const s=o.state.field(xc),a=r.toJSON();jr(s,a)||o.dispatch({effects:[y1.of(a)],annotations:[xo.of(!0)]})};return Wt.define(o=>{let r;return Promise.resolve().then(()=>{const s=lt.getByPath(`languages/${t}`);if(!s)return void vt.error("no language container found for cell",t);Zt(s instanceof Sc,"language type is not a LoroText");const a=lt.getByPath(`language_metadata/${t}`);a?(Zt(a instanceof mg,"language metadata is not a LoroMap"),e(o,s),n(o,a),r=lt.subscribe(l=>{if(l.origin==="local")return;const c=l.events.some(u=>u.target===s.id),d=l.events.some(u=>u.target===a.id);c&&e(o,s),d&&n(o,a)})):vt.error("no language metadata container found for cell",t)}),{destroy(){r()}}})}function iy(t){const e=lt.getMap("languages").getOrCreateContainer(t,new Sc),n=lt.getMap("language_metadata").getOrCreateContainer(t,new mg);return Se.updateListener.of(o=>{const r=e.toString()!=="";if(!o.docChanged&&r)return;if(!r){const a=bc(o.state).type;co(o.view,{language:a}),vt.debug("no initial language, setting default to",a),e.delete(0,e.length),e.insert(0,a),vt.debug("no initial language metadata, setting default to",o.state.field(xc));const l=o.state.field(xc);for(const c of Object.keys(l))n.set(c,l[c]);return void lt.commit()}let s=!1;for(const a of o.transactions)if(!a.annotation(xo)){for(const l of a.effects)if(l.is(R3)&&e.toString()!==l.value.type&&(vt.debug(`[outgoing] language change: ${e} -> ${l.value.type}`),e.delete(0,e.length),e.insert(0,l.value.type),s=!0),l.is(y1)||l.is(v1)){const c=l.value;l.is(v1)?(vt.debug("[outgoing] setting language metadata: ",c),n.clear()):vt.debug("[outgoing] updating language metadata: ",c);for(const d of Object.keys(c))n.set(d,c[d]);s=!0}}s&&lt.commit()})}function ly(t,e,n,o,r,s){const a=`loro:cell:${r}`;return[Zi,x1({above:!0,class:"loro-cursor-layer",update:Lm,markers:l=>{const{remoteCursors:c,isCheckout:d}=l.state.field(Zi);return d?[]:[...c.values()].flatMap(u=>{var m,p;const h=Yt.cursor(u.cursor.anchor);return Ms.createCursor(l,h,((m=u.user)==null?void 0:m.name)||"unknown",((p=u.user)==null?void 0:p.colorClassName)||"")})}}),x1({above:!1,class:"loro-selection-layer",update:Lm,markers:l=>{const{remoteCursors:c,isCheckout:d}=l.state.field(Zi);return d?[]:[...c.entries()].filter(([,u])=>u.cursor.head!==void 0&&u.cursor.anchor!==u.cursor.head).flatMap(([,u])=>{var m;const h=Yt.range(u.cursor.anchor,u.cursor.head);return M3.forRange(l,`loro-selection ${((m=u.user)==null?void 0:m.colorClassName)||""}`,h)})}}),Wt.define(l=>new ty(l,t,n,e,o,a,s)),Wt.define(l=>new ny(l,t,e,a)),Z2]}function Ls(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}pa()&&tl(),lt.subscribeLocalUpdates(t=>{vt.debug("local update, sending to server"),tl().send(t)}),Rs.addListener((t,e)=>{const n=[...t.added,...t.removed,...t.updated];e==="local"&&(Bm.debug("awareness changes",n),tl().send((function(o,r){const s=new TextEncoder().encode(o);return new Uint8Array([...s,...r])})(el,Rs.encode(n))))});var Pm={modified:{doc:""},original:{doc:""}},zm=S.createContext(Pm);function cy(t,e){return Je({},t,e,{modified:Je({},t.modified,e.modified),original:Je({},t.original,e.original)})}var ol=()=>S.useContext(zm),dy=t=>{var{children:e,theme:n}=t,[o,r]=S.useReducer(cy,Je({},Pm,{theme:n}));return S.useEffect(()=>r({theme:n}),[n]),i.jsx(zm.Provider,{value:Je({},o,{dispatch:r}),children:e})},uy=["extensions","value","selection","onChange"],Um=t=>{var{extensions:e=[],value:n,selection:o,onChange:r}=t,s=Br(t,uy),{theme:a,dispatch:l}=ol(),c=Po(Je({},s,{theme:a}));return S.useEffect(()=>l({original:{doc:n,selection:o,extensions:[...c,...e]},originalExtension:{onChange:r,option:s,extension:[e]}}),[t]),null};Um.displayName="CodeMirrorMerge.Original";var hy=["extensions","value","selection","onChange"],Wm=t=>{var{extensions:e=[],value:n,selection:o,onChange:r}=t,s=Br(t,hy),{theme:a,dispatch:l}=ol(),c=Po(Je({},s,{theme:a}));return S.useEffect(()=>{l({modified:{doc:n,selection:o,extensions:[...c,...e]},modifiedExtension:{onChange:r,option:s,extension:[e]}})},[t]),null};Wm.displayName="CodeMirrorMerge.Modified";class Ze{constructor(e,n,o,r){this.fromA=e,this.toA=n,this.fromB=o,this.toB=r}offset(e,n=e){return new Ze(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function Zn(t,e,n,o,r,s){if(t==o)return[];let a=il(t,e,n,o,r,s),l=ll(t,e+a,n,o,r+a,s),c=(n-=l)-(e+=a),d=(s-=l)-(r+=a);if(!c||!d)return[new Ze(e,n,r,s)];if(c>d){let h=t.slice(e,n).indexOf(o.slice(r,s));if(h>-1)return[new Ze(e,e+h,r,r),new Ze(e+h+d,n,s,s)]}else if(d>c){let h=o.slice(r,s).indexOf(t.slice(e,n));if(h>-1)return[new Ze(e,e,r,r+h),new Ze(n,n,r+h+c,s)]}if(c==1||d==1)return[new Ze(e,n,r,s)];let u=Gm(t,e,n,o,r,s);if(u){let[h,m,p]=u;return Zn(t,e,h,o,r,m).concat(Zn(t,h+p,n,o,m+p,s))}return(function(h,m,p,b,x,f){let g=p-m,y=f-x;if(pr<1e9&&Math.min(g,y)>16*pr||gr>0&&Date.now()>gr)return Math.min(g,y)>64*pr?[new Ze(m,p,x,f)]:qm(h,m,p,b,x,f);let w=Math.ceil((g+y)/2);sl.reset(w),al.reset(w);let j=(E,_)=>h.charCodeAt(m+E)==b.charCodeAt(x+_),C=(E,_)=>h.charCodeAt(p-E-1)==b.charCodeAt(f-_-1),N=(g-y)%2!=0?al:null,k=N?null:sl;for(let E=0;E<w;E++){if(E>pr||gr>0&&!(63&E)&&Date.now()>gr)return qm(h,m,p,b,x,f);let _=sl.advance(E,g,y,w,N,!1,j)||al.advance(E,g,y,w,k,!0,C);if(_)return my(h,m,p,m+_[0],b,x,f,x+_[1])}return[new Ze(m,p,x,f)]})(t,e,n,o,r,s)}let pr=1e9,gr=0,rl=!1;class $m{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,o,r,s,a,l){for(let c=-e+this.start;c<=e-this.end;c+=2){let d=r+c,u=c==-e||c!=e&&this.vec[d-1]<this.vec[d+1]?this.vec[d+1]:this.vec[d-1]+1,h=u-c;for(;u<n&&h<o&&l(u,h);)u++,h++;if(this.vec[d]=u,u>n)this.end+=2;else if(h>o)this.start+=2;else if(s){let m=r+(n-o)-c;if(m>=0&&m<this.len&&s.vec[m]!=-1){if(a){let p=s.vec[m];if(p>=n-u)return[p,r+p-m]}else if(u>=n-s.vec[m])return[u,h]}}}return null}}const sl=new $m,al=new $m;function my(t,e,n,o,r,s,a,l){let c=!1;return vo(t,o)||++o!=n||(c=!0),vo(r,l)||++l!=a||(c=!0),c?[new Ze(e,n,s,a)]:Zn(t,e,o,r,s,l).concat(Zn(t,o,n,r,l,a))}function Vm(t,e){let n=1,o=Math.min(t,e);for(;n<o;)n<<=1;return n}function il(t,e,n,o,r,s){if(e==n||e==s||t.charCodeAt(e)!=o.charCodeAt(r))return 0;let a=Vm(n-e,s-r);for(let l=e,c=r;;){let d=l+a,u=c+a;if(d>n||u>s||t.slice(l,d)!=o.slice(c,u)){if(a==1)return l-e-(vo(t,l)?0:1);a>>=1}else{if(d==n||u==s)return d-e;l=d,c=u}}}function ll(t,e,n,o,r,s){if(e==n||r==s||t.charCodeAt(n-1)!=o.charCodeAt(s-1))return 0;let a=Vm(n-e,s-r);for(let l=n,c=s;;){let d=l-a,u=c-a;if(d<e||u<r||t.slice(d,l)!=o.slice(u,c)){if(a==1)return n-l-(vo(t,l)?0:1);a>>=1}else{if(d==e||u==r)return n-d;l=d,c=u}}}function cl(t,e,n,o,r,s,a,l){let c=o.slice(r,s),d=null;for(;;){if(d||a<l)return d;for(let u=e+a;;){vo(t,u)||u++;let h=u+a;if(vo(t,h)||(h+=h==u+1?1:-1),h>=n)break;let m=t.slice(u,h),p=-1;for(;(p=c.indexOf(m,p+1))!=-1;){let b=il(t,h,n,o,r+p+m.length,s),x=ll(t,e,u,o,r,r+p),f=m.length+b+x;(!d||d[2]<f)&&(d=[u-x,r+p-x,f])}u=h}if(l<0)return d;a>>=1}}function Gm(t,e,n,o,r,s){let a=n-e,l=s-r;if(a<l){let c=Gm(o,r,s,t,e,n);return c&&[c[1],c[0],c[2]]}return a<4||2*l<a?null:cl(t,e,n,o,r,s,Math.floor(a/4),-1)}function qm(t,e,n,o,r,s){rl=!0;let a,l=n-e,c=s-r;if(l<c){let m=cl(o,r,s,t,e,n,Math.floor(l/6),50);a=m&&[m[1],m[0],m[2]]}else a=cl(t,e,n,o,r,s,Math.floor(c/6),50);if(!a)return[new Ze(e,n,r,s)];let[d,u,h]=a;return Zn(t,e,d,o,r,u).concat(Zn(t,d+h,n,o,u+h,s))}function Hm(t,e){for(let n=1;n<t.length;n++){let o=t[n-1],r=t[n];o.toA>r.fromA-e&&o.toB>r.fromB-e&&(t[n-1]=new Ze(o.fromA,r.toA,o.fromB,r.toB),t.splice(n--,1))}}let eo;try{eo=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Jm(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function Km(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?Jm(n)?1:0:eo?nf(n)&&e!=t.length-1?eo.test(t.slice(e,e+2))?2:0:eo.test(String.fromCharCode(n))?1:0:0}function Ym(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?Jm(n)?1:0:eo?of(n)&&e!=1?eo.test(t.slice(e-2,e))?2:0:eo.test(String.fromCharCode(n))?1:0:0}const Xm=8;function Qm(t,e,n){if(e==t.length||!Ym(t,e))return e;for(let o=e,r=e+n,s=0;s<Xm;s++){let a=Km(t,o);if(!a||o+a>r)return o;o+=a}return e}function Zm(t,e,n){if(!e||!Km(t,e))return e;for(let o=e,r=e-n,s=0;s<Xm;s++){let a=Ym(t,o);if(!a||o-a<r)return o;o-=a}return e}function ef(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function tf(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const nf=t=>t>=55296&&t<=56319,of=t=>t>=56320&&t<=57343;function vo(t,e){return!e||e==t.length||!nf(t.charCodeAt(e-1))||!of(t.charCodeAt(e))}function fy(t,e,n){var o;return pr=((o=n==null?void 0:n.scanLimit)!==null&&o!==void 0?o:1e9)>>1,gr=n!=null&&n.timeout?Date.now()+n.timeout:0,rl=!1,(function(r,s,a){for(;;){Hm(a,1);let l=!1;for(let c=0;c<a.length;c++){let d,u,h=a[c];(d=il(r,h.fromA,h.toA,s,h.fromB,h.toB))&&(h=a[c]=new Ze(h.fromA+d,h.toA,h.fromB+d,h.toB)),(u=ll(r,h.fromA,h.toA,s,h.fromB,h.toB))&&(h=a[c]=new Ze(h.fromA,h.toA-u,h.fromB,h.toB-u));let m=h.toA-h.fromA,p=h.toB-h.fromB;if(m&&p)continue;let b=h.fromA-(c?a[c-1].toA:0),x=(c<a.length-1?a[c+1].fromA:r.length)-h.toA;if(!b||!x)continue;let f=m?r.slice(h.fromA,h.toA):s.slice(h.fromB,h.toB);b<=f.length&&r.slice(h.fromA-b,h.fromA)==f.slice(f.length-b)?(a[c]=new Ze(h.fromA-b,h.toA-b,h.fromB-b,h.toB-b),l=!0):x<=f.length&&r.slice(h.toA,h.toA+x)==f.slice(0,x)&&(a[c]=new Ze(h.fromA+x,h.toA+x,h.fromB+x,h.toB+x),l=!0)}if(!l)break}return a})(t,e,Zn(t,0,t.length,e,0,e.length))}function rf(){return!rl}function sf(t,e,n){return(function(o,r,s){for(let a=0,l=0;l<o.length;l++){let c=o[l],d=c.toA-c.fromA,u=c.toB-c.fromB;if(d&&u||d>3||u>3){let h=l==o.length-1?r.length:o[l+1].fromA,m=c.fromA-a,p=h-c.toA,b=Zm(r,c.fromA,m),x=Qm(r,c.toA,p),f=c.fromA-b,g=x-c.toA;if((!d||!u)&&f&&g){let y=Math.max(d,u),[w,j,C]=d?[r,c.fromA,c.toA]:[s,c.fromB,c.toB];y>f&&r.slice(b,c.fromA)==w.slice(C-f,C)?(c=o[l]=new Ze(b,b+d,c.fromB-f,c.toB-f),b=c.fromA,x=Qm(r,c.toA,h-c.toA)):y>g&&r.slice(c.toA,x)==w.slice(j,j+g)&&(c=o[l]=new Ze(x-d,x,c.fromB+g,c.toB+g),x=c.toA,b=Zm(r,c.fromA,c.fromA-a)),f=c.fromA-b,g=x-c.toA}if(f||g)c=o[l]=new Ze(c.fromA-f,c.toA+g,c.fromB-f,c.toB+g);else if(d){if(!u){let y,w=tf(r,c.fromA,c.toA),j=w<0?-1:ef(r,c.toA,c.fromA);w>-1&&(y=w-c.fromA)<=p&&r.slice(c.fromA,w)==r.slice(c.toA,c.toA+y)?c=o[l]=c.offset(y):j>-1&&(y=c.toA-j)<=m&&r.slice(c.fromA-y,c.fromA)==r.slice(j,c.toA)&&(c=o[l]=c.offset(-y))}}else{let y,w=tf(s,c.fromB,c.toB),j=w<0?-1:ef(s,c.toB,c.fromB);w>-1&&(y=w-c.fromB)<=p&&s.slice(c.fromB,w)==s.slice(c.toB,c.toB+y)?c=o[l]=c.offset(y):j>-1&&(y=c.toB-j)<=m&&s.slice(c.fromB-y,c.fromB)==s.slice(j,c.toB)&&(c=o[l]=c.offset(-y))}}a=c.toA}return Hm(o,3),o})(fy(t,e,n),t,e)}const Ht=ro.define({combine:t=>t[0]}),dl=tt.define(),py=ro.define(),wo=Dt.define({create:t=>null,update(t,e){for(let n of e.effects)n.is(dl)&&(t=n.value);for(let n of e.state.facet(py))t=n(t,e);return t}});class ko{constructor(e,n,o,r,s,a=!0){this.changes=e,this.fromA=n,this.toA=o,this.fromB=r,this.toB=s,this.precise=a}offset(e,n){return e||n?new ko(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,o){return cf(sf(e.toString(),n.toString(),o),e,n,0,0,rf())}static updateA(e,n,o,r,s){return hf(uf(e,r,!0,o.length),e,n,o,s)}static updateB(e,n,o,r,s){return hf(uf(e,r,!1,n.length),e,n,o,s)}}function af(t,e,n,o){let r=n.lineAt(t),s=o.lineAt(e);return r.to==t&&s.to==e&&t<n.length&&e<o.length?[t+1,e+1]:[r.from,s.from]}function lf(t,e,n,o){let r=n.lineAt(t),s=o.lineAt(e);return r.from==t&&s.from==e?[t,e]:[r.to+1,s.to+1]}function cf(t,e,n,o,r,s){let a=[];for(let l=0;l<t.length;l++){let c=t[l],[d,u]=af(c.fromA+o,c.fromB+r,e,n),[h,m]=lf(c.toA+o,c.toB+r,e,n),p=[c.offset(-d+o,-u+r)];for(;l<t.length-1;){let b=t[l+1],[x,f]=af(b.fromA+o,b.fromB+r,e,n);if(x>h+1&&f>m+1)break;p.push(b.offset(-d+o,-u+r)),[h,m]=lf(b.toA+o,b.toB+r,e,n),l++}a.push(new ko(p,d,Math.max(d,h),u,Math.max(u,m),s))}return a}const Fs=1e3;function df(t,e,n,o){let r=0,s=t.length;for(;;){if(r==s){let u=0,h=0;r&&({toA:u,toB:h}=t[r-1]);let m=e-(n?u:h);return[u+m,h+m]}let a=r+s>>1,l=t[a],[c,d]=n?[l.fromA,l.toA]:[l.fromB,l.toB];if(c>e)s=a;else{if(!(d<=e))return o?[l.fromA,l.fromB]:[l.toA,l.toB];r=a+1}}}function uf(t,e,n,o){let r=[];return e.iterChangedRanges((s,a,l,c)=>{let d=0,u=n?e.length:o,h=0,m=n?o:e.length;s>Fs&&([d,h]=df(t,s-Fs,n,!0)),a<e.length-Fs&&([u,m]=df(t,a+Fs,n,!1));let p,b=c-l-(a-s),[x,f]=n?[b,0]:[0,b];r.length&&(p=r[r.length-1]).toA>=d?r[r.length-1]={fromA:p.fromA,fromB:p.fromB,toA:u,toB:m,diffA:p.diffA+x,diffB:p.diffB+f}:r.push({fromA:d,toA:u,fromB:h,toB:m,diffA:x,diffB:f})}),r}function hf(t,e,n,o,r){if(!t.length)return e;let s=[];for(let a=0,l=0,c=0,d=0;;a++){let u=a==t.length?null:t[a],h=u?u.fromA+l:n.length,m=u?u.fromB+c:o.length;for(;d<e.length;){let f=e[d];if(f.toA+l>h||f.toB+c>m)break;s.push(f.offset(l,c)),d++}if(!u)break;let p=u.toA+l+u.diffA,b=u.toB+c+u.diffB,x=sf(n.sliceString(h,p),o.sliceString(m,b),r);for(let f of cf(x,n,o,h,m,rf()))s.push(f);for(l+=u.diffA,c+=u.diffB;d<e.length;){let f=e[d];if(f.fromA+l>p&&f.fromB+c>b)break;d++}}return s}const gy={scanLimit:500},mf=Wt.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=gf(t))}update(t){var e,n;(t.docChanged||t.viewportChanged||(e=t.startState,n=t.state,e.field(wo,!1)!=n.field(wo,!1))||(function(o,r){return o.facet(Ht)!=r.facet(Ht)})(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=gf(t.view))}},{decorations:t=>t.deco}),Bs=Sn.low(P3({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(mf))===null||e===void 0?void 0:e.gutter)||z3.empty}})),ff=Te.line({class:"cm-changedLine"}),by=Te.mark({class:"cm-changedText"}),xy=Te.mark({tagName:"ins",class:"cm-insertedLine"}),yy=Te.mark({tagName:"del",class:"cm-deletedLine"}),pf=new class extends U3{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function vy(t,e,n,o,r,s){let a=n?t.fromA:t.fromB,l=n?t.toA:t.toB,c=0;if(a!=l){r.add(a,a,ff),r.add(a,l,n?yy:xy),s&&s.add(a,a,pf);for(let d=e.iterRange(a,l-1),u=a;!d.next().done;){if(d.lineBreak){u++,r.add(u,u,ff),s&&s.add(u,u,pf);continue}let h=u+d.value.length;if(o)for(;c<t.changes.length;){let m=t.changes[c],p=a+(n?m.fromA:m.fromB),b=a+(n?m.toA:m.toB),x=Math.max(u,p),f=Math.min(h,b);if(x<f&&r.add(x,f,by),!(b<h))break;c++}u=h}}}function gf(t){let e=t.state.field(wo),{side:n,highlightChanges:o,markGutter:r,overrideChunk:s}=t.state.facet(Ht),a=n=="a",l=new Mo,c=r?new Mo:null,{from:d,to:u}=t.viewport;for(let h of e){if((a?h.fromA:h.fromB)>=u)break;(a?h.toA:h.toB)>d&&(s&&s(t.state,h,l,c)||vy(h,t.state.doc,a,o,l,c))}return{deco:l.finish(),gutter:c&&c.finish()}}class Ps extends So{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const zs=tt.define({map:(t,e)=>t.map(e)}),br=Dt.define({create:()=>Te.none,update:(t,e)=>{for(let n of e.effects)if(n.is(zs))return n.value;return t.map(e.changes)},provide:t=>Se.decorations.from(t)}),ul=.01;function bf(t,e){if(t.size!=e.size)return!1;let n=t.iter(),o=e.iter();for(;n.value;){if(n.from!=o.from||Math.abs(n.value.spec.widget.height-o.value.spec.widget.height)>1)return!1;n.next(),o.next()}return!0}const hl=tt.define({map:(t,e)=>e.mapPos(t)});class wy extends So{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",o=>{let r=e.posAtDOM(o.target);e.dispatch({effects:hl.of(r)});let{side:s,sibling:a}=e.state.facet(Ht);a&&a().dispatch({effects:hl.of(ky(r,e.state.field(wo),s=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function ky(t,e,n){let o=0,r=0;for(let s=0;;s++){let a=s<e.length?e[s]:null;if(!a||(n?a.fromA:a.fromB)>=t)return r+(t-o);[o,r]=n?[a.toA,a.toB]:[a.toB,a.toA]}}const jy=Dt.define({create:t=>Te.none,update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is(hl)&&(t=t.update({filter:o=>o!=n.value}));return t},provide:t=>Se.decorations.from(t)});function xf({margin:t=3,minSize:e=4}){return jy.init(n=>(function(o,r,s){let a=new Mo,l=o.facet(Ht).side=="a",c=o.field(wo),d=1;for(let u=0;;u++){let h=u<c.length?c[u]:null,m=u?d+r:1,p=h?o.doc.lineAt(l?h.fromA:h.fromB).number-1-r:o.doc.lines,b=p-m+1;if(b>=s&&a.add(o.doc.line(m).from,o.doc.line(p).to,Te.replace({widget:new wy(b),block:!0})),!h)break;d=o.doc.lineAt(Math.min(o.doc.length,l?h.toA:h.toB)).number}return a.finish()})(n,t,e))}const Cy=Se.styleModule.of(new B3({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),Ny=Se.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"\u299A"',marginInlineEnd:"7px"},"&:after":{content:'"\u299A"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),yf=new lc,Us=new lc;class vf{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||gy;let n=[Sn.low(mf),Ny,Cy,br,Se.updateListener.of(h=>{this.measuring<0&&(h.heightChanged||h.viewportChanged)&&!h.transactions.some(m=>m.effects.some(p=>p.is(zs)))&&this.measure()})],o=[Ht.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&o.push(Bs);let r=Mr.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Se.editorAttributes.of({class:"cm-merge-a"}),Us.of(o),n]}),s=[Ht.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&s.push(Bs);let a=Mr.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Se.editorAttributes.of({class:"cm-merge-b"}),Us.of(s),n]});this.chunks=ko.build(r.doc,a.doc,this.diffConf);let l=[wo.init(()=>this.chunks),yf.of(e.collapseUnchanged?xf(e.collapseUnchanged):[])];r=r.update({effects:tt.appendConfig.of(l)}).state,a=a.update({effects:tt.appendConfig.of(l)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let c=e.orientation||"a-b",d=document.createElement("div");d.className="cm-mergeViewEditor";let u=document.createElement("div");u.className="cm-mergeViewEditor",this.editorDOM.appendChild(c=="a-b"?d:u),this.editorDOM.appendChild(c=="a-b"?u:d),this.a=new Se({state:r,parent:d,root:e.root,dispatchTransactions:h=>this.dispatch(h,this.a)}),this.b=new Se({state:a,parent:u,root:e.root,dispatchTransactions:h=>this.dispatch(h,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,n){if(e.some(o=>o.docChanged)){let o=e[e.length-1],r=e.reduce((a,l)=>a.compose(l.changes),Tr.empty(e[0].startState.doc.length));this.chunks=n==this.a?ko.updateA(this.chunks,o.newDoc,this.b.state.doc,r,this.diffConf):ko.updateB(this.chunks,this.a.state.doc,o.newDoc,r,this.diffConf),n.update([...e,o.state.update({effects:dl.of(this.chunks)})]);let s=n==this.a?this.b:this.a;s.update([s.state.update({effects:dl.of(this.chunks)})]),this.scheduleMeasure()}else n.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let s=e.orientation!="b-a";if(s!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let a=this.a.dom.parentNode,l=this.b.dom.parentNode;a.remove(),l.remove(),this.editorDOM.insertBefore(s?a:l,this.editorDOM.firstChild),this.editorDOM.appendChild(s?l:a),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let s=!!this.revertDOM,a=this.revertToA,l=this.renderRevert;"revertControls"in e&&(s=!!e.revertControls,a=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(l=e.renderRevertControl),this.setupRevertControls(s,a,l)}let n="highlightChanges"in e,o="gutter"in e,r="collapseUnchanged"in e;if(n||o||r){let s=[],a=[];if(n||o){let l=this.a.state.facet(Ht),c=o?e.gutter!==!1:l.markGutter,d=n?e.highlightChanges!==!1:l.highlightChanges;s.push(Us.reconfigure([Ht.of({side:"a",sibling:()=>this.b,highlightChanges:d,markGutter:c}),c?Bs:[]])),a.push(Us.reconfigure([Ht.of({side:"b",sibling:()=>this.a,highlightChanges:d,markGutter:c}),c?Bs:[]]))}if(r){let l=yf.reconfigure(e.collapseUnchanged?xf(e.collapseUnchanged):[]);s.push(l),a.push(l)}this.a.dispatch({effects:s}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,n,o){this.revertToA=n,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=o,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",r=>this.revertClicked(r)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){(function(e,n,o){let r=new Mo,s=new Mo,a=e.state.field(br).iter(),l=n.state.field(br).iter(),c=0,d=0,u=0,h=0,m=e.viewport,p=n.viewport;for(let g=0;;g++){let y=g<o.length?o[g]:null,w=y?y.fromA:e.state.doc.length,j=y?y.fromB:n.state.doc.length;if(c<w){let C=e.lineBlockAt(c).top+u-(n.lineBlockAt(d).top+h);C<-.01?(u-=C,r.add(c,c,Te.widget({widget:new Ps(-C),block:!0,side:-1}))):C>ul&&(h+=C,s.add(d,d,Te.widget({widget:new Ps(C),block:!0,side:-1})))}if(w>c+1e3&&c<m.from&&w>m.from&&d<p.from&&j>p.from){let C=Math.min(m.from-c,p.from-d);c+=C,d+=C,g--}else{if(!y)break;c=y.toA,d=y.toB}for(;a.value&&a.from<c;)u-=a.value.spec.widget.height,a.next();for(;l.value&&l.from<d;)h-=l.value.spec.widget.height,l.next()}for(;a.value;)u-=a.value.spec.widget.height,a.next();for(;l.value;)h-=l.value.spec.widget.height,l.next();let b=e.contentHeight+u-(n.contentHeight+h);b<ul?r.add(e.state.doc.length,e.state.doc.length,Te.widget({widget:new Ps(-b),block:!0,side:1})):b>ul&&s.add(n.state.doc.length,n.state.doc.length,Te.widget({widget:new Ps(b),block:!0,side:1}));let x=r.finish(),f=s.finish();bf(x,e.state.field(br))||e.dispatch({effects:zs.of(x)}),bf(f,n.state.field(br))||n.dispatch({effects:zs.of(f)})})(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,n=e.firstChild,o=this.a.viewport,r=this.b.viewport;for(let s=0;s<this.chunks.length;s++){let a=this.chunks[s];if(a.fromA>o.to||a.fromB>r.to)break;if(a.fromA<o.from||a.fromB<r.from)continue;let l=this.a.lineBlockAt(a.fromA).top+"px";for(;n&&+n.dataset.chunk<s;)n=wf(n);n&&n.dataset.chunk==String(s)?(n.style.top!=l&&(n.style.top=l),n=n.nextSibling):e.insertBefore(this.renderRevertButton(l,s),n)}for(;n;)n=wf(n)}renderRevertButton(e,n){let o;if(this.renderRevert)o=this.renderRevert();else{o=document.createElement("button");let r=this.a.state.phrase("Revert this chunk");o.setAttribute("aria-label",r),o.setAttribute("title",r),o.textContent=this.revertToLeft?"\u21DC":"\u21DD"}return o.style.top=e,o.setAttribute("data-chunk",String(n)),o}revertClicked(e){let n,o=e.target;for(;o&&o.parentNode!=this.revertDOM;)o=o.parentNode;if(o&&(n=this.chunks[o.dataset.chunk])){let[r,s,a,l,c,d]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],u=r.state.sliceDoc(a,Math.max(a,l-1));a!=l&&d<=s.state.doc.length&&(u+=r.state.lineBreak),s.dispatch({changes:{from:c,to:Math.min(s.state.doc.length,d),insert:u},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function wf(t){let e=t.nextSibling;return t.remove(),e}var Sy=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl","diffConfig","root"],Ey=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],kf=me.forwardRef((t,e)=>{var{className:n,children:o,orientation:r,revertControls:s,highlightChanges:a,gutter:l,collapseUnchanged:c,destroyRerender:d=!0,renderRevertControl:u,diffConfig:h,root:m}=t,p=Br(t,Sy),b=ol(),{modified:x,modifiedExtension:f,original:g,originalExtension:y,theme:w,dispatch:j}=b,C=Br(b,Ey),N=S.useRef(null),k=S.useRef(),E={orientation:r,revertControls:s,highlightChanges:a,gutter:l,collapseUnchanged:c,renderRevertControl:u,diffConfig:h,root:m};S.useImperativeHandle(e,()=>({container:N.current,view:k.current,modified:x,original:g,config:Je({a:g,b:x,parent:N.current},E)}),[N,k,x,g,E]);var _=Se.updateListener.of(A=>{if(A.docChanged&&typeof(y==null?void 0:y.onChange)=="function"){var O=A.state.doc.toString();y==null||y.onChange(O,A)}}),I=Se.updateListener.of(A=>{if(A.docChanged&&typeof(f==null?void 0:f.onChange)=="function"){var O=A.state.doc.toString();f==null||f.onChange(O,A)}});return S.useEffect(()=>{!k.current&&N.current&&y&&f&&(k.current=new vf(Je({a:Je({},g,{extensions:[...(y==null?void 0:y.extension)||[],...Po(Je({},y==null?void 0:y.option,{theme:w})),_]}),b:Je({},x,{extensions:[...(f==null?void 0:f.extension)||[],...Po(Je({},f==null?void 0:f.option,{theme:w})),I]}),parent:N.current},E)),j({view:k.current}))},[k,N,y,f]),S.useEffect(()=>{if(g&&g.doc&&k.current){var A,O,D=(A=k.current)==null?void 0:A.a.state.doc.toString();D!==g.doc&&((O=k.current)==null||O.a.dispatch({changes:{from:0,to:D.length,insert:g.doc||""}}))}if(x&&x.doc&&k.current){var M,R,L=(M=k.current)==null?void 0:M.b.state.doc.toString();L!==x.doc&&((R=k.current)==null||R.b.dispatch({changes:{from:0,to:L.length,insert:x.doc||""}}))}if(d&&k.current){var z=k.current.a.state.selection.ranges[0].from,T=k.current.b.state.selection.ranges[0].from;k.current.destroy(),k.current=new vf(Je({a:Je({},g,{extensions:[...(y==null?void 0:y.extension)||[],...Po(Je({},y==null?void 0:y.option,{theme:w}))]}),b:Je({},x,{extensions:[...(f==null?void 0:f.extension)||[],...Po(Je({},f==null?void 0:f.option,{theme:w}))]}),parent:N.current},E)),z&&(k.current.a.focus(),k.current.a.dispatch({selection:{anchor:z,head:z}})),T&&(k.current.b.focus(),k.current.b.dispatch({selection:{anchor:T,head:T}}))}},[k,w,N.current,g,x,y,f,d]),S.useEffect(()=>()=>k.current&&k.current.destroy(),[]),S.useEffect(()=>{if(k.current){var A={};C.orientation!==r&&(A.orientation=r),C.revertControls!==s&&(A.revertControls=s),C.highlightChanges!==a&&(A.highlightChanges=a),C.gutter!==l&&(A.gutter=l),C.collapseUnchanged!==c&&(A.collapseUnchanged=c),C.renderRevertControl!==u&&(A.collapseUnchanged=c),Object.keys(A).length&&j&&k.current&&(k.current.reconfigure(Je({},A)),j(Je({},A)))}},[j,k,r,s,a,l,c,u]),i.jsx("div",Je({ref:N,className:"cm-merge-theme"+(n?" "+n:"")},p,{children:o}))});kf.displayName="CodeMirrorMerge.Internal";var _y=["theme"],jo=me.forwardRef((t,e)=>{var{theme:n}=t,o=Br(t,_y);return i.jsx(dy,{theme:n,children:i.jsx(kf,Je({},o,{ref:e}))})});jo.Original=Um,jo.Modified=Wm,jo.displayName="CodeMirrorMerge";const Iy=jo.Original,Ay=jo.Modified,jf=[Z3(),Se.lineWrapping],Ty=t=>{const e=P.c(28),{className:n,onChange:o,initialPrompt:r,currentLanguageAdapter:s,currentCode:a,declineChange:l,acceptChange:c,enabled:d,children:u}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={},e[0]=h):h=e[0];const[m,p]=S.useState(h),[b,x]=_n(Ix),f=S.useId(),g=j1(),{completion:y,input:w,stop:j,isLoading:C,setCompletion:N,setInput:k,handleSubmit:E}=W3({api:g.getAiURL("completion").toString(),headers:g.headers(),initialInput:r,streamProtocol:"text",experimental_throttle:100,body:{...m,includeOtherCode:b?ic(a):"",code:a,language:s},onError:Dy,onFinish:(q,U)=>{_(U.trimEnd())}}),_=N,I=me.useRef(null),A=y.trimEnd();let O,D,M,R;e[1]!==d?(O=()=>{var q;d&&(ej(()=>{const U=I.current;return!!(U!=null&&U.view)&&(U.view.focus(),!0)},{retries:3,delay:100,initialDelay:100}),tj((q=I.current)==null?void 0:q.view))},D=[d],e[1]=d,e[2]=O,e[3]=D):(O=e[2],D=e[3]),S.useEffect(O,D),e[4]!==d||e[5]!==r||e[6]!==k?(M=()=>{d&&k(r||"")},R=[d,r,k],e[4]=d,e[5]=r,e[6]=k,e[7]=M,e[8]=R):(M=e[7],R=e[8]),S.useEffect(M,R);const{theme:L}=C1(),z=()=>{c(A),_("")},T=()=>{_("")};let F;e[9]!==n?(F=ue("flex flex-col w-full rounded-[inherit]",n),e[9]=n,e[10]=F):F=e[10];const $=d&&"max-h-[400px] min-h-11 visible",W=!d&&"max-h-0 min-h-0 invisible";let G;e[11]!==$||e[12]!==W?(G=ue("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300",$,W),e[11]=$,e[12]=W,e[13]=G):G=e[13];const X=d&&i.jsxs(i.Fragment,{children:[i.jsx(Rr,{className:"text-(--blue-10) shrink-0",size:16}),i.jsx($3,{inputRef:I,className:"h-full my-0 py-2 flex items-center",onClose:()=>{l(),_("")},value:w,onChange:q=>{k(q),p(q3({input:q}))},onSubmit:()=>{var q;C||((q=I.current)!=null&&q.view&&G3(I.current.view),E())},onKeyDown:V3({handleAcceptCompletion:z,handleDeclineCompletion:T,isLoading:C,hasCompletion:A.trim().length>0})}),C&&i.jsxs(ye,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:j,children:[i.jsx(N1,{className:"animate-spin mr-1",size:14}),"Stop"]}),i.jsxs("div",{className:"-mr-1.5 py-1.5",children:[i.jsxs("div",{className:"flex flex-row items-center justify-end gap-0.5",children:[i.jsx(pe,{content:"Add context",children:i.jsx(ye,{variant:"text",size:"icon",onClick:()=>H3(I),children:i.jsx(J3,{className:"h-3 w-3"})})}),i.jsx(K3,{triggerClassName:"h-7 text-xs w-24",iconSize:"small",forRole:"edit"})]}),A&&i.jsx("div",{className:"-mb-1.5",children:i.jsx(Y3,{isLoading:C,onAccept:z,onDecline:T,size:"xs"})})]}),i.jsx("div",{className:"h-full w-px bg-border mx-2"}),i.jsx(pe,{content:"Include code from other cells",children:i.jsxs("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[i.jsx(X3,{"data-testid":"include-other-cells-checkbox",id:f,checked:b,onCheckedChange:q=>x(!!q)}),i.jsx(Ao,{htmlFor:f,className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),i.jsx(ye,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:C,onClick:()=>{j(),l(),_("")},children:i.jsx(Vt,{className:"text-(--red-10)",size:16})})]});let H,Y;e[14]!==G||e[15]!==X?(H=i.jsx("div",{className:G,children:X}),e[14]=G,e[15]=X,e[16]=H):H=e[16],e[17]!==A||e[18]!==a||e[19]!==d||e[20]!==o||e[21]!==L?(Y=A&&d&&i.jsxs(jo,{className:"cm",theme:L,children:[i.jsx(Iy,{onChange:o,value:a,extensions:jf}),i.jsx(Ay,{value:A,editable:!1,readOnly:!0,extensions:jf})]}),e[17]=A,e[18]=a,e[19]=d,e[20]=o,e[21]=L,e[22]=Y):Y=e[22];const K=(!A||!d)&&u;let V;return e[23]!==H||e[24]!==Y||e[25]!==K||e[26]!==F?(V=i.jsxs("div",{className:F,children:[H,Y,K]}),e[23]=H,e[24]=Y,e[25]=K,e[26]=F,e[27]=V):V=e[27],V};function Dy(t){ze({title:"Completion failed",description:Q3(t)})}const ml="web application/x-marimo-cell",My=Be({cells:nj(Be({code:Me()})),version:$e("1.0")}),Cf=t=>{const e=t===1?"Cell":`${t} cells`;ze({title:`${e} copied`,description:`${e} ${t===1?"has":"have"} been copied to clipboard.`})},Oy=()=>{ze({title:"Copy failed",description:"Failed to copy cells to clipboard.",variant:"danger"})},Ry=()=>{ze({title:"Nothing to paste",description:"No cell or text found in clipboard.",variant:"danger"})},Ly=()=>{ze({title:"Paste failed",description:"Failed to read from clipboard",variant:"danger"})};class Fy{constructor(){this.items={}}add(e,n){return ClipboardItem.supports(e)?typeof n=="string"?(this.items[e]=new Blob([n],{type:e}),this):(this.items[e]=new Blob([JSON.stringify(n)],{type:e}),this):(He.warn(`ClipboardItem does not support ${e}`),this)}build(){return new ClipboardItem(this.items)}}const{valueAtom:By,useActions:Ws}=Ql(()=>new Set,{add:(t,e)=>{const n=new Set(t);return n.add(e),n},remove:(t,e)=>{const n=new Set(t);return n.delete(e),n}});function Py(t){const e=P.c(2);let n;return e[0]!==t?(n=(o=>Bt(r=>r(By).has(o)))(t),e[0]=t,e[1]=n):n=e[1],ie(n)}const xr=new WeakMap;function Nf(t){return{handle:e=>t(e),bulkHandle:e=>{let n=!0;try{for(const o of e)n=n&&t(o);return n}catch{return!1}}}}function sn(t){return{handle:e=>t([e]),bulkHandle:e=>t(e)}}function Sf(t,e){const n=P.c(30),{canMoveX:o,editorView:r,cellActionDropdownRef:s}=e,{saveOrNameNotebook:a}=ti(),{saveCellConfig:l}=qe(),c=Ct(tr),d=Ye(),u=na(),h=Ws(),m=Ho(),p=ie(S1),{copyCells:b,pasteAtCell:x}=(function(){const M=Ye(),R=Ce(async z=>{const T=Mt(),F=z.map($=>T.cellData[$]).filter(Boolean);if(F.length!==0)try{const $={cells:F.map(X=>({code:X.code})),version:"1.0"},W=F.map(X=>X.code).join(`
129
+ `.trim(),x=t1();await n1();const f=await fetch(x.getAiURL("completion").toString(),{method:"POST",headers:x.headers(),body:JSON.stringify({prompt:p.prompt,code:b,selectedText:p.selection,includeOtherCode:"",language:p.language})}),g=((j=p.selection.match(/^\s*/))==null?void 0:j[0])||"",y=(C=f.body)==null?void 0:C.getReader();if(!y)throw new Error("Failed to get response reader");let w="";for(;;){const{done:N,value:k}=await y.read();if(N)break;w+=new TextDecoder().decode(k)}return w.startsWith(g)||(w=g+w),w})({prompt:m.prompt,selection:m.selection,codeBefore:m.codeBefore,codeAfter:m.codeAfter,language:fp(m.editorView)})}),Wa.of({hideOnBlur:!0})]:[],p4(Le),g4(e,d.reference_highlighting??!1)];var h},A2=t=>{const{theme:e,hotkeys:n,completionConfig:o,cellId:r,lspConfig:s,diagnosticsConfig:a}=t,l=Qh(t);return[Se.lineWrapping,b4(),x4(),y4(),v4(),w4(),k4(),j4(),C4({position:"fixed",parent:document.querySelector("#App")??void 0}),N4(),e==="dark"?E2:_2,S4(s),w2(o),E4(),_4(),_x(),Sn.high(Wt.of(O4)),I4(),A4(),T4.of(" "),i1(R4,{fallback:!0}),Wt.of(L4),D4({placeholderType:l,completionConfig:o,hotkeys:n,cellId:r,lspConfig:{...s,diagnostics:a}}),M4.of(F4()),Dr.allowMultipleSelections.of(!0),k2(n),Wt.of([{key:"Tab",run:c=>a1(c)||(d=>{const{from:u,to:h}=d.state.selection.main;if(u!==h)return!1;const m=d.state.doc.lineAt(h);return m.text.slice(0,h-m.from).trim()!==""&&U4(d)})(c)||B4(c),preventDefault:!0},{key:n.getHotkey("completion.moveDown").key,run:c=>Fo(c.state)!==null&&(ua(!0)(c),!0),preventDefault:!0},{key:n.getHotkey("completion.moveUp").key,run:c=>Fo(c.state)!==null&&(ua(!1)(c),!0),preventDefault:!0}]),Wt.of([...P4,z4])]},T2={width:void 0,height:void 0};function Zh(t,e,n){return t[e]?Array.isArray(t[e])?t[e][0][n]:t[e][n]:e==="contentBoxSize"?t.contentRect[n==="inlineSize"?"width":"height"]:void 0}const ur=t=>{const e=z.c(8),{children:n,layerTop:o}=t,r=o!==void 0&&o;let s;e[0]!==n?(s=he.Children.toArray(n),e[0]=n,e[1]=s):s=e[1];const[a,l]=s,c=`second-icon absolute ${r?"top-[-2px] left-[-2px]":"bottom-[-2px] right-[-2px]"} rounded-full`;let d,u;return e[2]!==l||e[3]!==c?(d=i.jsx("div",{className:c,children:l}),e[2]=l,e[3]=c,e[4]=d):d=e[4],e[5]!==a||e[6]!==d?(u=i.jsxs("div",{className:"multi-icon relative w-fit",children:[a,d]}),e[5]=a,e[6]=d,e[7]=u):u=e[7],u};let em,tm;em=t=>{const e=z.c(79),{editing:n,status:o,disabled:r,staleInputs:s,edited:a,interrupted:l,elapsedTime:c,runStartTimestamp:d,lastRunStartTimestamp:u,uninstantiated:h}=t;if(!n)return null;const m=d??u;let p;e[0]!==m?(p=m?i.jsx(tm,{lastRanTime:m}):null,e[0]=m,e[1]=p):p=e[1];const b=p;if(r&&o==="running")return Ye.error("CellStatusComponent: disabled and running"),null;if(r&&s){let x,f,g,y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"This cell is stale, but it's disabled and can't be run"}),e[2]=x):x=e[2],e[3]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[3]=b,e[4]=f):f=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:i.jsxs(ur,{children:[i.jsx(Ve,{className:"h-5 w-5",strokeWidth:1.5}),i.jsx(dc,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[5]=g):g=e[5],e[6]!==f?(y=i.jsx(pe,{content:f,usePortal:!0,children:g}),e[6]=f,e[7]=y):y=e[7],y}if(r){let x,f,g,y;return e[8]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"This cell is disabled"}),e[8]=x):x=e[8],e[9]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[9]=b,e[10]=f):f=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("div",{className:"cell-status-icon cell-status-disabled","data-testid":"cell-status","data-status":"disabled",children:i.jsx(Ve,{className:"h-5 w-5",strokeWidth:1.5})}),e[11]=g):g=e[11],e[12]!==f?(y=i.jsx(pe,{content:f,usePortal:!0,children:g}),e[12]=f,e[13]=y):y=e[13],y}if(!s&&o==="disabled-transitively"){let x,f,g,y;return e[14]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"An ancestor of this cell is disabled, so it can't be run"}),e[14]=x):x=e[14],e[15]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[15]=b,e[16]=f):f=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"disabled-transitively",children:i.jsxs(ur,{layerTop:!0,children:[i.jsx(Rc,{className:"h-5 w-5",strokeWidth:1.5}),i.jsx(Ve,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[17]=g):g=e[17],e[18]!==f?(y=i.jsx(pe,{content:f,usePortal:!0,children:g}),e[18]=f,e[19]=y):y=e[19],y}if(s&&o==="disabled-transitively"){let x,f,g,y;return e[20]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"This cell is stale, but an ancestor is disabled so it can't be run"}),e[20]=x):x=e[20],e[21]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[21]=b,e[22]=f):f=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:i.jsxs(ur,{children:[i.jsx(dc,{className:"h-5 w-5",strokeWidth:1}),i.jsx(Ve,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[23]=g):g=e[23],e[24]!==f?(y=i.jsx(pe,{content:f,usePortal:!0,children:g}),e[24]=f,e[25]=y):y=e[25],y}if(o==="running"){let x,f,g,y,w;return e[26]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"This cell is running"}),e[26]=x):x=e[26],e[27]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[27]=b,e[28]=f):f=e[28],e[29]!==d?(g=cc.fromSeconds(d)||cc.now(),e[29]=d,e[30]=g):g=e[30],e[31]!==g?(y=i.jsx("div",{className:"cell-status-icon elapsed-time running","data-testid":"cell-status","data-status":"running",children:i.jsx(D2,{startTime:g})}),e[31]=g,e[32]=y):y=e[32],e[33]!==f||e[34]!==y?(w=i.jsx(pe,{content:f,usePortal:!0,children:y}),e[33]=f,e[34]=y,e[35]=w):w=e[35],w}if(o==="queued"){let x,f,g,y;return e[36]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{children:"This cell is queued to run"}),e[36]=x):x=e[36],e[37]!==b?(f=i.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[37]=b,e[38]=f):f=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("div",{className:"cell-status-icon cell-status-queued","data-testid":"cell-status","data-status":"queued",children:i.jsx(Ca,{className:"h-5 w-5",strokeWidth:1.5})}),e[39]=g):g=e[39],e[40]!==f?(y=i.jsx(pe,{content:f,usePortal:!0,children:g}),e[40]=f,e[41]=y):y=e[41],y}if(a||l||s||h){let x;e[42]!==c?(x=Wo(c),e[42]=c,e[43]=x):x=e[43];const f=x;let g;e[44]!==c||e[45]!==f?(g=c?i.jsx(Sa,{elapsedTime:f}):null,e[44]=c,e[45]=f,e[46]=g):g=e[46];const y=g;let w,j,C,N,k,E="";if(h)w="This cell has not yet been run";else if(l){let _;w="This cell was interrupted when it was last run",e[47]!==y?(_=i.jsxs("span",{children:["This cell ran for ",y," before being interrupted"]}),e[47]=y,e[48]=_):_=e[48],E=_}else if(a){let _;w="This cell has been modified since it was last run",e[49]!==y?(_=i.jsxs("span",{children:["This cell took ",y," to run"]}),e[49]=y,e[50]=_):_=e[50],E=_}else{let _;w="This cell has not been run with the latest inputs",e[51]!==y?(_=i.jsxs("span",{children:["This cell took ",y," to run"]}),e[51]=y,e[52]=_):_=e[52],E=_}return e[53]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx("div",{className:"cell-status-stale","data-testid":"cell-status","data-status":"outdated",children:i.jsx(dc,{className:"h-5 w-5",strokeWidth:1.5})}),e[53]=j):j=e[53],e[54]!==w?(C=i.jsx(pe,{content:w,usePortal:!0,children:j}),e[54]=w,e[55]=C):C=e[55],e[56]!==c||e[57]!==f||e[58]!==b||e[59]!==E?(N=c&&i.jsx(pe,{content:i.jsxs("div",{className:"flex flex-col gap-1",children:[E,b]}),usePortal:!0,children:i.jsx("div",{className:"elapsed-time hover-action","data-testid":"cell-status","data-status":"outdated",children:i.jsx("span",{children:f})})}),e[56]=c,e[57]=f,e[58]=b,e[59]=E,e[60]=N):N=e[60],e[61]!==C||e[62]!==N?(k=i.jsxs("div",{className:"cell-status-icon flex items-center gap-2",children:[C,N]}),e[61]=C,e[62]=N,e[63]=k):k=e[63],k}if(c!==null){let x;e[64]!==c?(x=Wo(c),e[64]=c,e[65]=x):x=e[65];const f=x;let g;e[66]!==c||e[67]!==f?(g=c?i.jsx(Sa,{elapsedTime:f}):null,e[66]=c,e[67]=f,e[68]=g):g=e[68];const y=g;let w,j,C,N;return e[69]!==y?(w=i.jsxs("span",{children:["This cell took ",y," to run"]}),e[69]=y,e[70]=w):w=e[70],e[71]!==b||e[72]!==w?(j=i.jsxs("div",{className:"flex flex-col gap-1",children:[w,b]}),e[71]=b,e[72]=w,e[73]=j):j=e[73],e[74]!==f?(C=i.jsx("div",{className:"cell-status-icon elapsed-time hover-action","data-testid":"cell-status","data-status":"idle",children:i.jsx("span",{children:f})}),e[74]=f,e[75]=C):C=e[75],e[76]!==j||e[77]!==C?(N=i.jsx(pe,{content:j,usePortal:!0,children:C}),e[76]=j,e[77]=C,e[78]=N):N=e[78],N}return null},Sa=t=>{const e=z.c(2);let n;return e[0]!==t.elapsedTime?(n=i.jsx("span",{className:"tracking-wide font-semibold",children:t.elapsedTime}),e[0]=t.elapsedTime,e[1]=n):n=e[1],n},tm=t=>{const e=z.c(4),n=new Date(1e3*t.lastRanTime),o=new Date;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0},e[0]=r):r=e[0];const s=l1(r);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0},e[1]=a):a=e[1];const l=l1(a),c=n.toDateString()===o.toDateString()?s:l,d=gg(n);let u;return e[2]!==d?(u=i.jsxs("span",{className:"text-muted-foreground",children:["(",d," ago)"]}),e[2]=d,e[3]=u):u=e[3],i.jsxs("span",{children:["Ran at"," ",i.jsx("strong",{className:"tracking-wide font-semibold",children:c.format(n)})," ",u]})},Wo=function(t){if(t===null)return"";const e=t,n=e/1e3;return n>=60?`${Math.floor(n/60)}m${Math.floor(n%60)}s`:n>=1?`${n.toFixed(2).toString()}s`:`${e.toFixed(0).toString()}ms`};const D2=t=>{const e=z.c(6);let n;e[0]!==t.startTime?(n=t.startTime.toMilliseconds(),e[0]=t.startTime,e[1]=n):n=e[1];const o=(function(a){const l=S.useRef(a),[c,d]=S.useState(a);return S.useEffect(()=>{const u=setInterval(()=>{d(cc.now().toMilliseconds())},17);return()=>clearInterval(u)},[]),c-l.current})(n);let r,s;return e[2]!==o?(r=Wo(o),e[2]=o,e[3]=r):r=e[3],e[4]!==r?(s=i.jsx("span",{children:r}),e[4]=r,e[5]=s):s=e[5],s};var Yi="ContextMenu",[M2,FC]=V4(Yi,[c1]),yt=c1(),[O2,nm]=M2(Yi),om=t=>{const{__scopeContextMenu:e,children:n,onOpenChange:o,dir:r,modal:s=!0}=t,[a,l]=S.useState(!1),c=yt(e),d=o3(o),u=S.useCallback(h=>{l(h),d(h)},[d]);return i.jsx(O2,{scope:e,open:a,onOpenChange:u,modal:s,children:i.jsx(r3,{...c,dir:r,open:a,onOpenChange:u,modal:s,children:n})})};om.displayName=Yi;var rm="ContextMenuTrigger",sm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,disabled:o=!1,...r}=t,s=nm(rm,n),a=yt(n),l=S.useRef({x:0,y:0}),c=S.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=S.useRef(0),u=S.useCallback(()=>window.clearTimeout(d.current),[]),h=m=>{l.current={x:m.clientX,y:m.clientY},s.onOpenChange(!0)};return S.useEffect(()=>u,[u]),S.useEffect(()=>{o&&u()},[o,u]),i.jsxs(i.Fragment,{children:[i.jsx(G4,{...a,virtualRef:c}),i.jsx(q4.span,{"data-state":s.open?"open":"closed","data-disabled":o?"":void 0,...r,ref:e,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:o?t.onContextMenu:Mr(t.onContextMenu,m=>{u(),h(m),m.preventDefault()}),onPointerDown:o?t.onPointerDown:Mr(t.onPointerDown,Ds(m=>{u(),d.current=window.setTimeout(()=>h(m),700)})),onPointerMove:o?t.onPointerMove:Mr(t.onPointerMove,Ds(u)),onPointerCancel:o?t.onPointerCancel:Mr(t.onPointerCancel,Ds(u)),onPointerUp:o?t.onPointerUp:Mr(t.onPointerUp,Ds(u))})]})});sm.displayName=rm;var am=t=>{const{__scopeContextMenu:e,...n}=t,o=yt(e);return i.jsx(s3,{...o,...n})};am.displayName="ContextMenuPortal";var im="ContextMenuContent",lm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=nm(im,n),s=yt(n),a=S.useRef(!1);return i.jsx(H4,{...s,...o,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{var c;(c=t.onCloseAutoFocus)==null||c.call(t,l),!l.defaultPrevented&&a.current&&l.preventDefault(),a.current=!1},onInteractOutside:l=>{var c;(c=t.onInteractOutside)==null||c.call(t,l),l.defaultPrevented||r.modal||(a.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});lm.displayName=im,S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(J4,{...r,...o,ref:e})}).displayName="ContextMenuGroup";var cm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(K4,{...r,...o,ref:e})});cm.displayName="ContextMenuLabel";var dm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx($4,{...r,...o,ref:e})});dm.displayName="ContextMenuItem";var um=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(Y4,{...r,...o,ref:e})});um.displayName="ContextMenuCheckboxItem",S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(X4,{...r,...o,ref:e})}).displayName="ContextMenuRadioGroup";var hm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(Q4,{...r,...o,ref:e})});hm.displayName="ContextMenuRadioItem";var mm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(Z4,{...r,...o,ref:e})});mm.displayName="ContextMenuItemIndicator";var fm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(W4,{...r,...o,ref:e})});fm.displayName="ContextMenuSeparator",S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(e3,{...r,...o,ref:e})}).displayName="ContextMenuArrow";var pm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(t3,{...r,...o,ref:e})});pm.displayName="ContextMenuSubTrigger";var gm=S.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=yt(n);return i.jsx(n3,{...r,...o,ref:e,style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});function Ds(t){return e=>e.pointerType!=="mouse"?t(e):void 0}gm.displayName="ContextMenuSubContent";var bm=lm,xm=cm,ym=dm,vm=um,wm=hm,km=mm,jm=fm,Cm=pm,Nm=gm;const Sm=om,Em=sm,R2=i3(am);S.forwardRef((t,e)=>{const n=z.c(14);let o,r,s,a,l,c,d;return n[0]!==t?({className:r,inset:s,children:o,...a}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a):(o=n[1],r=n[2],s=n[3],a=n[4]),n[5]!==r||n[6]!==s?(l=l3({className:r,inset:s}),n[5]=r,n[6]=s,n[7]=l):l=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(u3,{className:"ml-auto h-4 w-4"}),n[8]=c):c=n[8],n[9]!==o||n[10]!==a||n[11]!==e||n[12]!==l?(d=i.jsxs(Cm,{ref:e,className:l,...a,children:[o,c]}),n[9]=o,n[10]=a,n[11]=e,n[12]=l,n[13]=d):d=n[13],d}).displayName=Cm.displayName;const _m="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2";S.forwardRef((t,e)=>{const n=z.c(9);let o,r,s,a;return n[0]!==t?({className:o,...r}=t,n[0]=t,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(s=de(u1({subcontent:!0}),_m,o),n[3]=o,n[4]=s):s=n[4],n[5]!==r||n[6]!==e||n[7]!==s?(a=i.jsx(Nm,{ref:e,className:s,...r}),n[5]=r,n[6]=e,n[7]=s,n[8]=a):a=n[8],a}).displayName=Nm.displayName;const Xi=S.forwardRef((t,e)=>{const n=z.c(15);let o,r,s;n[0]!==t?({className:o,scrollable:s,...r}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]);const a=s===void 0||s;let l;n[4]!==o||n[5]!==a?(l=de(u1(),_m,a&&"overflow-auto",o),n[4]=o,n[5]=a,n[6]=l):l=n[6];const c=a?"calc(var(--radix-context-menu-content-available-height) - 30px)":void 0;let d,u;return n[7]!==r.style||n[8]!==c?(d={...r.style,maxHeight:c},n[7]=r.style,n[8]=c,n[9]=d):d=n[9],n[10]!==r||n[11]!==e||n[12]!==l||n[13]!==d?(u=i.jsx(R2,{children:i.jsx(c3,{children:i.jsx(bm,{ref:e,className:l,style:d,...r})})}),n[10]=r,n[11]=e,n[12]=l,n[13]=d,n[14]=u):u=n[14],u});Xi.displayName=bm.displayName;const hr=S.forwardRef((t,e)=>{const n=z.c(13);let o,r,s,a,l,c;return n[0]!==t?({className:o,inset:r,variant:a,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a):(o=n[1],r=n[2],s=n[3],a=n[4]),n[5]!==o||n[6]!==r||n[7]!==a?(l=d1({className:o,inset:r,variant:a}),n[5]=o,n[6]=r,n[7]=a,n[8]=l):l=n[8],n[9]!==s||n[10]!==e||n[11]!==l?(c=i.jsx(ym,{ref:e,className:l,...s}),n[9]=s,n[10]=e,n[11]=l,n[12]=c):c=n[12],c});hr.displayName=ym.displayName,S.forwardRef((t,e)=>{const n=z.c(15);let o,r,s,a,l,c,d,u;return n[0]!==t?({className:s,children:r,checked:o,...a}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a):(o=n[1],r=n[2],s=n[3],a=n[4]),n[5]!==s?(l=ma({className:s}),n[5]=s,n[6]=l):l=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(c=ma(),n[7]=c):c=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("span",{className:c,children:i.jsx(km,{children:i.jsx(h3,{className:"h-4 w-4"})})}),n[8]=d):d=n[8],n[9]!==o||n[10]!==r||n[11]!==a||n[12]!==e||n[13]!==l?(u=i.jsxs(vm,{ref:e,className:l,checked:o,...a,children:[d,r]}),n[9]=o,n[10]=r,n[11]=a,n[12]=e,n[13]=l,n[14]=u):u=n[14],u}).displayName=vm.displayName,S.forwardRef((t,e)=>{const n=z.c(13);let o,r,s,a,l,c,d;return n[0]!==t?({className:r,children:o,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==r?(a=ma({className:r}),n[4]=r,n[5]=a):a=n[5],n[6]===Symbol.for("react.memo_cache_sentinel")?(l=ma(),n[6]=l):l=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{className:l,children:i.jsx(km,{children:i.jsx(m3,{className:"h-4 w-4 fill-current"})})}),n[7]=c):c=n[7],n[8]!==o||n[9]!==s||n[10]!==e||n[11]!==a?(d=i.jsxs(wm,{ref:e,className:a,...s,children:[c,o]}),n[8]=o,n[9]=s,n[10]=e,n[11]=a,n[12]=d):d=n[12],d}).displayName=wm.displayName,S.forwardRef((t,e)=>{const n=z.c(11);let o,r,s,a,l;return n[0]!==t?({className:o,inset:r,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==o||n[5]!==r?(a=d3({className:o,inset:r}),n[4]=o,n[5]=r,n[6]=a):a=n[6],n[7]!==s||n[8]!==e||n[9]!==a?(l=i.jsx(xm,{ref:e,className:a,...s}),n[7]=s,n[8]=e,n[9]=a,n[10]=l):l=n[10],l}).displayName=xm.displayName;const Im=S.forwardRef((t,e)=>{const n=z.c(9);let o,r,s,a;return n[0]!==t?({className:o,...r}=t,n[0]=t,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(s=de(a3({className:o})),n[3]=o,n[4]=s):s=n[4],n[5]!==r||n[6]!==e||n[7]!==s?(a=i.jsx(jm,{ref:e,className:s,...r}),n[5]=r,n[6]=e,n[7]=s,n[8]=a):a=n[8],a});Im.displayName=jm.displayName;const Am=t=>{const e=z.c(20),{connectionState:n,onClick:o,tooltipContent:r}=t;let s;e[0]!==n||e[1]!==r?(s=oa(n)||r,e[0]=n,e[1]=r,e[2]=s):s=e[2];const a=s;let l;e[3]!==a||e[4]!==n?(l=en(n)?a:i.jsxs("div",{className:"flex flex-col gap-4",children:[i.jsx("div",{children:a}),i.jsx("div",{className:"text-xs text-muted-foreground font-medium pt-1 -mt-2 border-t border-border",children:"Right-click for cell types"})]}),e[3]=a,e[4]=n,e[5]=l):l=e[5];const c=l;let d,u,h,m,p,b;return e[6]!==o?(d=()=>o==null?void 0:o({code:""}),e[6]=o,e[7]=d):d=e[7],e[8]!==n?(u=de("shoulder-button hover-action",en(n)&&" inactive-button"),e[8]=n,e[9]=u):u=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(uc,{strokeWidth:1.8}),e[10]=h):h=e[10],e[11]!==d||e[12]!==u?(m=i.jsx(tn,{onClick:d,className:u,onMouseDown:Bn.preventFocus,shape:"circle",size:"small",color:"hint-green","data-testid":"create-cell-button",children:h}),e[11]=d,e[12]=u,e[13]=m):m=e[13],e[14]!==c||e[15]!==m?(p=i.jsx(pe,{content:c,children:m}),e[14]=c,e[15]=m,e[16]=p):p=e[16],e[17]!==o||e[18]!==p?(b=i.jsx(L2,{onClick:o,children:p}),e[17]=o,e[18]=p,e[19]=b):b=e[19],b},L2=t=>{const e=z.c(26),{children:n,onClick:o}=t,{createNewCell:r}=Ke();if(!o)return n;let s,a,l,c,d,u,h,m,p,b,x,f;return e[0]!==n?(s=i.jsx(Em,{children:n}),e[0]=n,e[1]=s):s=e[1],e[2]!==o?(a=g=>{g.stopPropagation(),o({code:""})},e[2]=o,e[3]=a):a=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("div",{className:"mr-3 text-muted-foreground",children:i.jsx(hc,{})}),e[4]=l):l=e[4],e[5]!==a?(c=i.jsxs(hr,{onSelect:a,children:[l,"Python cell"]},"python"),e[5]=a,e[6]=c):c=e[6],e[7]!==r||e[8]!==o?(d=g=>{g.stopPropagation(),qn({autoInstantiate:!0,createNewCell:r}),o({code:Bo.markdown.defaultCode,hideCode:!0})},e[7]=r,e[8]=o,e[9]=d):d=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx("div",{className:"mr-3 text-muted-foreground",children:i.jsx(Zs,{})}),e[10]=u):u=e[10],e[11]!==d?(h=i.jsxs(hr,{onSelect:d,children:[u,"Markdown cell"]},"markdown"),e[11]=d,e[12]=h):h=e[12],e[13]!==r||e[14]!==o?(m=g=>{g.stopPropagation(),qn({autoInstantiate:!0,createNewCell:r}),o({code:Bo.sql.defaultCode})},e[13]=r,e[14]=o,e[15]=m):m=e[15],e[16]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx("div",{className:"mr-3 text-muted-foreground",children:i.jsx(_o,{size:13,strokeWidth:1.5})}),e[16]=p):p=e[16],e[17]!==m?(b=i.jsxs(hr,{onSelect:m,children:[p,"SQL cell"]},"sql"),e[17]=m,e[18]=b):b=e[18],e[19]!==c||e[20]!==h||e[21]!==b?(x=i.jsxs(Xi,{children:[c,h,b]}),e[19]=c,e[20]=h,e[21]=b,e[22]=x):x=e[22],e[23]!==s||e[24]!==x?(f=i.jsxs(Sm,{children:[s,x]}),e[23]=s,e[24]=x,e[25]=f):f=e[25],f};function Tm(t){return t!==f3&&!!(t&&t.trim().length>0)}function Dm(){const t=z.c(3),{splitCell:e,undoSplitCell:n}=Ke();let o;return t[0]!==e||t[1]!==n?(o=r=>{const s=Kp(r.cellId);if(!s)return;const a=pp(s);e(r);const{dismiss:l}=ze({title:"Cell split",action:i.jsx(Mp,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{n({...r,snapshot:a}),c()},children:"Undo"})}),c=l},t[0]=e,t[1]=n,t[2]=o):o=t[2],Ce(o)}Ta=function(t){const e=z.c(54),{cell:n,closePopover:o}=t,{createNewCell:r,updateCellConfig:s,updateCellName:a,moveCell:l,sendToTop:c,sendToBottom:d,addColumnBreakpoint:u,clearCellOutput:h}=Ke(),m=Dm(),p=$a(n==null?void 0:n.cellId),b=!ie(Jp),x=jr(),{openModal:f}=zn(),g=Ct(Or),y=ie(mc),w=ie(m1),j=ie(To),C=ie(p3),{saveCellConfig:N}=qe();if(!n||j){let q;return e[0]===Symbol.for("react.memo_cache_sentinel")?(q=[],e[0]=q):q=e[0],q}const{cellId:k,config:E,getEditorView:_,name:I,hasOutput:A,hasConsoleOutput:O,status:D}=n;let M;e[1]!==k||e[2]!==E.disabled||e[3]!==N||e[4]!==s?(M=async()=>{const q={disabled:!E.disabled};await N({configs:{[k]:q}}),s({cellId:k,config:q})},e[1]=k,e[2]=E.disabled,e[3]=N,e[4]=s,e[5]=M):M=e[5];const R=M;let L;e[6]!==k||e[7]!==E.hide_code||e[8]!==_||e[9]!==N||e[10]!==s?(L=async()=>{const q={hide_code:!E.hide_code};await N({configs:{[k]:q}}),s({cellId:k,config:q});const Y=_();Y&&(q.hide_code?Y.contentDOM.blur():Y.focus())},e[6]=k,e[7]=E.hide_code,e[8]=_,e[9]=N,e[10]=s,e[11]=L):L=e[11];const P=L;let T,F,$,W,H,X;return e[12]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx(bd,{size:13,strokeWidth:1.5}),e[12]=T):T=e[12],e[13]!==k||e[14]!==I||e[15]!==f||e[16]!==a?(F=()=>{f(i.jsxs(io,{children:[i.jsx(xr,{children:i.jsx(so,{children:"Rename cell"})}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Ao,{htmlFor:"cell-name",children:"Cell name"}),i.jsx(og,{placeholder:"cell name",value:I,onKeyDown:q=>{q.key==="Enter"&&(q.preventDefault(),q.stopPropagation(),f(null))},onChange:q=>a({cellId:k,name:q})})]})]}))},e[13]=k,e[14]=I,e[15]=f,e[16]=a,e[17]=F):F=e[17],e[18]!==k||e[19]!==a?($=q=>a({cellId:k,name:q}),e[18]=k,e[19]=a,e[20]=$):$=e[20],e[21]!==o?(W=()=>o==null?void 0:o(),e[21]=o,e[22]=W):W=e[22],e[23]!==I||e[24]!==$||e[25]!==W?(H=i.jsx(og,{placeholder:"cell name",value:I,onChange:$,onEnterKey:W}),e[23]=I,e[24]=$,e[25]=W,e[26]=H):H=e[26],e[27]!==u||e[28]!==y||e[29]!==C||e[30]!==w||e[31]!==b||e[32]!==k||e[33]!==h||e[34]!==E.disabled||e[35]!==E.hide_code||e[36]!==r||e[37]!==x||e[38]!==_||e[39]!==O||e[40]!==A||e[41]!==l||e[42]!==I||e[43]!==p||e[44]!==d||e[45]!==c||e[46]!==g||e[47]!==m||e[48]!==D||e[49]!==F||e[50]!==H||e[51]!==R||e[52]!==P?(X=[[{icon:T,label:"Name",disableClick:!0,handle:z2,handleHeadless:F,rightElement:H},{icon:i.jsx(Uo,{size:13,strokeWidth:1.5}),label:"Run cell",hotkey:"cell.run",hidden:D==="running"||D==="queued"||D==="disabled-transitively"||E.disabled,handle:()=>p()},{icon:i.jsx(Rr,{size:13,strokeWidth:1.5}),label:"AI completion",hidden:!y,handle:()=>{g(q=>(q==null?void 0:q.cellId)===k?null:{cellId:k})},hotkey:"cell.aiCompletion"},{icon:i.jsx(Ba,{size:13,strokeWidth:1.5}),label:"Split cell",hotkey:"cell.splitCell",handle:()=>m({cellId:k})},{icon:i.jsx(Nc,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!A,handle:()=>(function(q){const Y=document.getElementById(h1.create(q));Y&&(Y.classList.add("printing-output"),Tp(Y,"result.png").finally(()=>{Y.classList.remove("printing-output")}))})(k)},{icon:i.jsx(Xp,{size:13,strokeWidth:1.5}),label:"Format cell",hotkey:"cell.format",handle:()=>{const q=_();q&&Yp({[k]:q})}},{icon:E.hide_code?i.jsx(Qp,{size:13,strokeWidth:1.5}):i.jsx($l,{size:13,strokeWidth:1.5}),label:E.hide_code?"Show code":"Hide code",handle:P,hotkey:"cell.hideCode"},{icon:E.disabled?i.jsx(Et,{size:13,strokeWidth:1.5}):i.jsx(_t,{size:13,strokeWidth:1.5}),label:"Reactive execution",rightElement:i.jsx(fc,{"data-testid":"cell-disable-switch",checked:!E.disabled,size:"sm",onCheckedChange:R}),handle:R},{icon:i.jsx(Ks,{size:13,strokeWidth:1.5}),label:"Clear output",hidden:!(A||O),handle:()=>{h({cellId:k})}}],[{icon:i.jsx(Zs,{}),label:"Convert to Markdown",hotkey:"cell.viewAsMarkdown",handle:()=>{const q=_();q&&(qn({autoInstantiate:w,createNewCell:r}),co(q,{language:"markdown",keepCodeAsIs:!1}))}},{icon:i.jsx(_o,{size:13,strokeWidth:1.5}),label:"Convert to SQL",handle:()=>{const q=_();q&&(qn({autoInstantiate:w,createNewCell:r}),co(q,{language:"sql",keepCodeAsIs:!1}))}},{icon:i.jsx(hc,{}),label:"Toggle as Python",handle:()=>{const q=_();q&&(qn({autoInstantiate:w,createNewCell:r}),g3(q,"python",{force:!0}))}}],[{icon:i.jsxs(ur,{children:[i.jsx(Wr,{size:13,strokeWidth:1.5}),i.jsx(sa,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>r({cellId:k,before:!0})},{icon:i.jsxs(ur,{children:[i.jsx(Wr,{size:13,strokeWidth:1.5}),i.jsx(Vn,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>r({cellId:k,before:!1})},{icon:i.jsx(sa,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>l({cellId:k,before:!0})},{icon:i.jsx(Vn,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>l({cellId:k,before:!1})},{icon:i.jsx(f1,{size:13,strokeWidth:1.5}),label:"Move cell left",hotkey:"cell.moveLeft",handle:()=>l({cellId:k,direction:"left"}),hidden:C!=="columns"},{icon:i.jsx(fa,{size:13,strokeWidth:1.5}),label:"Move cell right",hotkey:"cell.moveRight",handle:()=>l({cellId:k,direction:"right"}),hidden:C!=="columns"},{icon:i.jsx(Da,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>c({cellId:k,scroll:!1})},{icon:i.jsx(bt,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>d({cellId:k,scroll:!1})},{icon:i.jsx(b3,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",hidden:C!=="columns",handle:()=>u({cellId:k})}],[{icon:i.jsx($1,{size:13,strokeWidth:1.5}),label:"Copy link to cell",disabled:!Tm(I),tooltip:Tm(I)?void 0:"Only named cells can be linked to",handle:async()=>{await Eo((function(q){const Y=new URL(window.location.href);return Y.hash=`scrollTo=${encodeURIComponent(q)}`,Y.toString()})(I)),ze({description:"Link copied to clipboard"})}}],[{label:"Delete",hidden:!b,variant:"danger",icon:i.jsx(ec,{size:13,strokeWidth:1.5}),handle:()=>{x({cellId:k})}}]].map(B2).filter(F2),e[27]=u,e[28]=y,e[29]=C,e[30]=w,e[31]=b,e[32]=k,e[33]=h,e[34]=E.disabled,e[35]=E.hide_code,e[36]=r,e[37]=x,e[38]=_,e[39]=O,e[40]=A,e[41]=l,e[42]=I,e[43]=p,e[44]=d,e[45]=c,e[46]=g,e[47]=m,e[48]=D,e[49]=F,e[50]=H,e[51]=R,e[52]=P,e[53]=X):X=e[53],X};function F2(t){return t.length>0}function B2(t){return t.filter(P2)}function P2(t){return!t.hidden}function z2(t){t==null||t.stopPropagation(),t==null||t.preventDefault()}let Qi;Qi=he.memo(he.forwardRef((t,e)=>{const n=z.c(35);let o,r,s;n[0]!==t?({children:o,showTooltip:s,...r}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]);const a=s===void 0||s,[l,c]=S.useState(!1);let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=()=>c(!1),n[4]=d):d=n[4];const u=d;let h;n[5]!==r?(h={cell:r,closePopover:u},n[5]=r,n[6]=h):h=n[6];const m=Ta(h),p=y3();let b,x,f,g,y,w;if(n[7]===Symbol.for("react.memo_cache_sentinel")?(b=()=>({toggle:()=>c(U2)}),n[7]=b):b=n[7],S.useImperativeHandle(e,b),n[8]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Lp,{placeholder:"Search actions...",className:"h-6 m-1"}),n[8]=x):x=n[8],n[9]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Rp,{children:"No results"}),n[9]=f):f=n[9],n[10]!==m){let I;n[12]!==m.length?(I=(A,O)=>i.jsxs(S.Fragment,{children:[i.jsx(v3,{children:A.map(D=>{let M=i.jsxs("div",{className:"flex items-center flex-1",children:[D.icon&&i.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:D.icon}),i.jsx("div",{className:"flex-1",children:D.label}),i.jsxs("div",{className:"shrink-0 text-sm",children:[D.hotkey&&p1(D.hotkey),D.rightElement]})]});return D.tooltip&&(M=i.jsx(pe,{content:D.tooltip,delayDuration:100,children:M})),i.jsx(Jl,{className:de(D.disabled&&"opacity-50!"),onSelect:()=>{D.disableClick||D.disabled||(D.handle(),c(!1))},variant:D.variant,children:M},D.label)})},O),O<m.length-1&&i.jsx(w3,{})]},O),n[12]=m.length,n[13]=I):I=n[13],g=m.map(I),n[10]=m,n[11]=g}else g=n[11];n[14]!==g?(y=i.jsxs(Fp,{children:[x,i.jsxs(k3,{children:[f,g]})]}),n[14]=g,n[15]=y):y=n[15],n[16]!==p||n[17]!==y?(w=i.jsx(Kl,{className:"w-[300px] p-0 pt-1 overflow-auto",scrollable:!0,...p,children:y}),n[16]=p,n[17]=y,n[18]=w):w=n[18];const j=w;if(!a){let I,A;return n[19]!==o?(I=i.jsx(pc,{asChild:!0,children:o}),n[19]=o,n[20]=I):I=n[20],n[21]!==j||n[22]!==l||n[23]!==I?(A=i.jsxs(ta,{open:l,onOpenChange:c,children:[I,j]}),n[21]=j,n[22]=l,n[23]=I,n[24]=A):A=n[24],A}let C;n[25]===Symbol.for("react.memo_cache_sentinel")?(C=i.jsx(j3,{tabIndex:-1,children:St("cell.cellActions")}),n[25]=C):C=n[25];const N=!l&&C;let k,E,_;return n[26]!==o?(k=i.jsx(C3,{children:i.jsx(pc,{className:"flex",children:o})}),n[26]=o,n[27]=k):k=n[27],n[28]!==N||n[29]!==k?(E=i.jsxs(N3,{delayDuration:200,disableHoverableContent:!0,children:[N,k]}),n[28]=N,n[29]=k,n[30]=E):E=n[30],n[31]!==j||n[32]!==l||n[33]!==E?(_=i.jsxs(ta,{open:l,onOpenChange:c,children:[E,j]}),n[31]=j,n[32]=l,n[33]=E,n[34]=_):_=n[34],_})),zc=he.memo(t=>{const e=z.c(5),{children:n,cellId:o}=t;let r;e[0]!==o?(r=x3(o),e[0]=o,e[1]=r):r=e[1];const s=ie(r);if(!s)return null;let a;return e[2]!==n||e[3]!==s?(a=i.jsx(Qi,{showTooltip:!1,...s,children:n}),e[2]=n,e[3]=s,e[4]=a):a=e[4],a});function U2(t){return!t}zc.displayName="ConnectionCellActionsDropdown";const Mm=t=>{const e=z.c(35),{children:n,cellId:o,getEditorView:r}=t,s=Lr(o),a=Fr(o),l=!gc(a.output),c=a.consoleOutputs.length>0;let d;e[0]!==s.config||e[1]!==s.name||e[2]!==o||e[3]!==a.status||e[4]!==r||e[5]!==l||e[6]!==c?(d={cell:{cellId:o,name:s.name,config:s.config,status:a.status,hasOutput:l,hasConsoleOutput:c,getEditorView:r}},e[0]=s.config,e[1]=s.name,e[2]=o,e[3]=a.status,e[4]=r,e[5]=l,e[6]=c,e[7]=d):d=e[7];const u=Ta(d),[h,m]=he.useState(),p=!!h;let b,x,f,g,y,w,j,C,N,k;if(e[8]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(hp,{size:13,strokeWidth:1.5}),e[8]=b):b=e[8],e[9]!==o?(x=async()=>{var I;if((I=window.getSelection())==null?void 0:I.toString())return void document.execCommand("copy");const _=document.getElementById(h1.create(o));_?await Eo(_.textContent??""):Ye.warn("cell-context-menu: output not found")},e[9]=o,e[10]=x):x=e[10],e[11]!==u||e[12]!==n||e[13]!==r||e[14]!==h||e[15]!==p||e[16]!==x){const E=[[{label:"Copy",hidden:p,icon:b,handle:x},{label:"Cut",hidden:!!h,icon:i.jsx(Ba,{size:13,strokeWidth:1.5}),handle:W2},{label:"Paste",hidden:!!h,icon:i.jsx(Bc,{size:13,strokeWidth:1.5}),handle:async()=>{const I=r();if(I)try{const A=await navigator.clipboard.readText();if(A){const{from:O,to:D}=I.state.selection.main,M=I.state.update({changes:{from:O,to:D,insert:A}});I.dispatch(M)}}catch(A){const O=A;Ye.error("Failed to paste from clipboard",O),S3({command:"paste"})}}},{label:"Copy image",hidden:!h,icon:i.jsx(Ma,{size:13,strokeWidth:1.5}),handle:async()=>{if(h){const I=await fetch(h.src),A=await I.blob(),O=new ClipboardItem({[A.type]:A});await navigator.clipboard.write([O]).then($2).catch(V2)}}},{icon:i.jsx(Nc,{size:13,strokeWidth:1.5}),label:"Download image",hidden:!h,handle:()=>{if(h){const I=document.createElement("a");I.download="image.png",I.href=h.src,I.click()}}},{label:"Go to Definition",icon:i.jsx(_3,{size:13,strokeWidth:1.5}),handle:()=>{const I=r();I&&E3(I)}}],...u];let _;g=Sm,e[23]===Symbol.for("react.memo_cache_sentinel")?(_=I=>{I.target instanceof HTMLImageElement?m(I.target):m(void 0)},e[23]=_):_=e[23],e[24]!==n?(y=i.jsx(Em,{onContextMenu:_,asChild:!0,children:n}),e[24]=n,e[25]=y):y=e[25],f=Xi,w="w-[300px]",j=!0,C=E.map((I,A)=>i.jsxs(S.Fragment,{children:[I.map(q2),A<E.length-1&&i.jsx(Im,{})]},A)),e[11]=u,e[12]=n,e[13]=r,e[14]=h,e[15]=p,e[16]=x,e[17]=f,e[18]=g,e[19]=y,e[20]=w,e[21]=j,e[22]=C}else f=e[17],g=e[18],y=e[19],w=e[20],j=e[21],C=e[22];return e[26]!==f||e[27]!==w||e[28]!==j||e[29]!==C?(N=i.jsx(f,{className:w,scrollable:j,children:C}),e[26]=f,e[27]=w,e[28]=j,e[29]=C,e[30]=N):N=e[30],e[31]!==g||e[32]!==y||e[33]!==N?(k=i.jsxs(g,{children:[y,N]}),e[31]=g,e[32]=y,e[33]=N,e[34]=k):k=e[34],k};function W2(){document.execCommand("cut")}function $2(){ze({title:"Copied image to clipboard"})}function V2(t){ze({title:"Failed to copy image to clipboard. Try downloading instead.",description:t.message}),Ye.error("Failed to copy image to clipboard",t)}function G2(t){t.stopPropagation()}function q2(t){if(t.hidden)return null;let e=i.jsxs("div",{className:"flex items-center flex-1",children:[t.icon&&i.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:t.icon}),i.jsx("div",{className:"flex-1",children:t.label}),i.jsxs("div",{className:"shrink-0 text-sm",children:[t.hotkey&&p1(t.hotkey),t.rightElement]})]});return t.tooltip&&(e=i.jsx(pe,{delayDuration:100,content:t.tooltip,children:e})),i.jsx(S.Fragment,{children:t.disableClick?i.jsx("div",{className:d1({className:t.disabled?"opacity-50!":"",variant:t.variant}),onKeyDown:G2,children:e}):i.jsx(hr,{className:t.disabled?"opacity-50!":"",onSelect:n=>{t.disableClick||t.disabled||t.handle(n)},variant:t.variant,children:e})},t.label)}if(ag)ig(MC),ag();else if(!("Bun"in globalThis)){const t=await ft(()=>import("./loro_wasm_bg-C1ks32Vm.js").then(async e=>(await e.__tla,e)).then(e=>e.w),[],import.meta.url);ig(new WebAssembly.Instance(t.default,{"./loro_wasm_bg.js":DC}).exports)}const H2=["Map","Text","List","Tree","MovableList","Counter"];function Om(t){if(typeof t!="object"||t==null)return!1;const e=Object.getPrototypeOf(t);return e!=null&&typeof e=="object"&&typeof e.kind=="function"&&H2.includes(t.kind())}lg.prototype.toJsonWithReplacer=function(t){const e=new Set,n=this,o=(a,l)=>{if(typeof l=="string"&&l.startsWith("cid:")&&!e.has(l)){e.add(l);const d=n.getContainerById(l);if(d==null)throw new Error(`ContainerID not found: ${l}`);const u=t(a,d);if(u===d){const h=d.getShallowValue();return typeof h=="object"?r(h):h}if(Om(u))throw new Error("Using new container is not allowed in toJsonWithReplacer");return typeof u=="object"&&u!=null?r(u):u}if(typeof l=="object"&&l!=null)return r(l);const c=t(a,l);if(Om(c))throw new Error("Using new container is not allowed in toJsonWithReplacer");return c},r=a=>{if(Array.isArray(a))return a.map((c,d)=>o(d,c)).filter(c=>c!==void 0);const l={};for(const[c,d]of Object.entries(a)){const u=o(c,d);u!==void 0&&(l[c]=u)}return l},s=n.getShallowValue();return r(s)};const J2=Se.baseTheme({".loro-cursor":{position:"absolute",width:"2px",display:"inline-block",height:"1.2em"},".loro-cursor::before":{position:"absolute",top:"1.3em",left:"0",content:"var(--rtc-name)",padding:"2px 6px",fontSize:"12px",borderRadius:"3px",whiteSpace:"nowrap",userSelect:"none",backgroundColor:"inherit",opacity:"0.7"},".loro-selection":{opacity:"0.5"}}),mr=nt.define(),Zi=Dt.define({create:()=>({remoteCursors:new Map,isCheckout:!1}),update(t,e){for(const n of e.effects)if(n.is(mr))switch(n.value.type){case"update":{const{peer:o,user:r,cursor:s}=n.value;t.remoteCursors.set(o,{uid:o,cursor:s,user:r});break}case"delete":t.remoteCursors.delete(n.value.peer);break;case"checkout":t.isCheckout=n.value.checkout}return t}}),Rm=t=>{const e=t.transactions.flatMap(n=>n.effects).filter(n=>n.is(mr));return t.docChanged||t.viewportChanged||e.length>0};class Ms{constructor(e,n,o,r,s){this.left=void 0,this.top=void 0,this.height=void 0,this.name=void 0,this.colorClassName=void 0,this.left=e,this.top=n,this.height=o,this.name=r,this.colorClassName=s}draw(){const e=document.createElement("div");return this.adjust(e),e}update(e){return this.adjust(e),!0}adjust(e){e.style.left=`${this.left}px`,e.style.top=`${this.top}px`,e.style.height=`${this.height}px`,e.className=`loro-cursor ${this.colorClassName}`,e.style.setProperty("--rtc-name",`"${this.name}"`)}eq(e){return this.left===e.left&&this.top===e.top&&this.height===e.height&&this.name===e.name}static createCursor(e,n,o,r){const s=Ms.calculateAbsoluteCursorPosition(n,e);if(!s)return[];const a=e.scrollDOM.getBoundingClientRect(),l=(e.textDirection===A3.LTR?a.left:a.right-e.scrollDOM.clientWidth)-e.scrollDOM.scrollLeft,c=a.top-e.scrollDOM.scrollTop;return[new Ms(s.left-l,s.top-c,s.bottom-s.top,o,r)]}static calculateAbsoluteCursorPosition(e,n){const o=Math.max(0,Math.min(n.state.doc.length,e.anchor));return n.coordsAtPos(o,e.assoc||1)}}const K2=(t,e,n,o)=>{const r=[],{updated:s,added:a}=n;for(const l of[...s,...a]){const c=Lm(t,e,l,o);c&&r.push(c)}return r},Lm=(t,e,n,o)=>{const r=e.getAllStates()[n];if(!r||n===t.peerIdStr||r.scopeId!==o)return;if(r.type==="delete")return mr.of({type:"delete",peer:r.uid,scopeId:r.scopeId});const s=cg.decode(r.cursor.anchor),a=t.getCursorPos(s).offset;let l=a;if(r.cursor.head){const c=cg.decode(r.cursor.head);l=t.getCursorPos(c).offset}return mr.of({type:"update",peer:r.uid,scopeId:r.scopeId,cursor:{anchor:a,head:l},user:r.user})};class Y2{constructor(e,n,o,r,s,a,l){this.sub=void 0,this.view=void 0,this.doc=void 0,this.user=void 0,this.awareness=void 0,this.getTextFromDoc=void 0,this.scopeId=void 0,this.getUserId=void 0,this.view=e,this.doc=n,this.user=o,this.awareness=r,this.getTextFromDoc=s,this.scopeId=a,this.getUserId=l,this.sub=this.doc.subscribe(c=>{if(c.by==="local"){const d=[];for(const u of this.awareness.peers()){const h=Lm(this.doc,this.awareness,u,this.scopeId);h&&d.push(h)}this.view.dispatch({effects:d})}else c.by==="checkout"&&this.view.dispatch({effects:[mr.of({type:"checkout",checkout:this.doc.isDetached()})]})})}update(e){if(!e.selectionSet&&!e.focusChanged&&!e.docChanged)return;const n=e.state.selection.main;if(this.view.hasFocus&&!this.doc.isDetached()){const o=Q2({doc:this.doc,getTextFromDoc:this.getTextFromDoc,anchor:n.anchor,head:n.head});this.awareness.setLocalState({type:"update",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId,cursor:o,user:this.user})}else this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}destroy(){var e;(e=this.sub)==null||e.call(this),this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}}class X2{constructor(e,n,o,r){this._awarenessListener=void 0,this.view=void 0,this.doc=void 0,this.awareness=void 0,this.scopeId=void 0,this.view=e,this.doc=n,this.awareness=o,this.scopeId=r;const s=async(a,l)=>{l!=="local"&&this.view.dispatch({effects:K2(this.doc,this.awareness,a,this.scopeId)})};this._awarenessListener=s,this.awareness.addListener(s)}destroy(){this._awarenessListener&&this.awareness.removeListener(this._awarenessListener)}}const Q2=({doc:t,getTextFromDoc:e,anchor:n,head:o})=>{var a,l;n===o&&(o=void 0);const r=(a=e(t).getCursor(n))==null?void 0:a.encode();if(!r)throw new Error("cursor head not found");let s;return o!==void 0&&(s=(l=e(t).getCursor(o))==null?void 0:l.encode()),{anchor:r,head:s}},Os=["bg-(--amber-6)","bg-(--blue-6)","bg-(--crimson-6)","bg-(--cyan-6)","bg-(--grass-6)","bg-(--gray-6)","bg-(--green-6)","bg-(--lime-6)","bg-(--orange-6)","bg-(--purple-6)","bg-(--red-6)","bg-(--sage-6)","bg-(--sky-6)","bg-(--slate-6)"],Z2=(t,e,n)=>Ut.define(o=>new ey(o,t,e,n)),xo=ac.define();class ey{constructor(e,n,o,r){this.sub=void 0,this.isInitDispatch=!1,this.view=void 0,this.doc=void 0,this.docPath=void 0,this.getTextFromDoc=void 0,this.onRemoteUpdate=s=>{if(s.by!=="local")if(s.by!=="checkout"){if(s.by==="import"){const a=[];let l=0;for(const{diff:c,path:d}of s.events){if(d.join("/")!==this.docPath.join("/")||c.type!=="text")continue;const u=c.diff;for(const h of u)h.insert?a.push({from:l,to:l,insert:h.insert}):h.delete?(a.push({from:l,to:l+h.delete}),l+=h.delete):h.retain!=null&&(l+=h.retain);a.length>0&&this.view.dispatch({changes:a,annotations:[xo.of(this)]})}}}else this.view.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:this.getTextFromDoc(this.doc).toString()}],annotations:[xo.of(this)]})},this.view=e,this.doc=n,this.docPath=o,this.getTextFromDoc=r,this.sub=n.subscribe(this.onRemoteUpdate),Promise.resolve().then(()=>{this.isInitDispatch=!0;const s=this.view.state.doc.toString(),a=this.getTextFromDoc(this.doc);s!==a.toString()&&e.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:a.toString()}]})})}update(e){if(this.isInitDispatch)return void(this.isInitDispatch=!1);if(!e.docChanged||e.transactions.length>0&&(e.transactions[0].annotation(xo)===this||e.transactions[0].annotation(xo)==="undo"))return;let n=0;e.changes.iterChanges((o,r,s,a,l)=>{const c=l.sliceString(0,l.length,`
130
+ `);o!==r&&this.getTextFromDoc(this.doc).delete(o+n,r-o),c.length>0&&this.getTextFromDoc(this.doc).insert(o+n,c),n+=c.length-(r-o)}),this.doc.commit()}destroy(){var e;(e=this.sub)==null||e.call(this),this.sub=void 0}}const vt=Ye.get("rtc"),Fm=vt.get("awareness").disabled(),el="awareness:",yo=Qt(void 0),lt=new lg,Rs=new class{constructor(t,e=3e4){this.listeners=new Set,this.inner=new OC(t,e),this.peer=t,this.timeout=e}apply(t,e="remote"){const{updated:n,added:o}=this.inner.apply(t);this.listeners.forEach(r=>{r({updated:n,added:o,removed:[]},e)}),this.startTimerIfNotEmpty()}setLocalState(t){const e=this.inner.getState(this.peer)==null;this.inner.setLocalState(t),e?this.listeners.forEach(n=>{n({updated:[],added:[this.inner.peer()],removed:[]},"local")}):this.listeners.forEach(n=>{n({updated:[this.inner.peer()],added:[],removed:[]},"local")}),this.startTimerIfNotEmpty()}getLocalState(){return this.inner.getState(this.peer)}getAllStates(){return this.inner.getAllStates()}encode(t){return this.inner.encode(t)}encodeAll(){return this.inner.encodeAll()}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}peers(){return this.inner.peers()}destroy(){clearInterval(this.timer),this.listeners.clear()}startTimerIfNotEmpty(){this.inner.isEmpty()||this.timer!=null||(this.timer=setInterval(()=>{const t=this.inner.removeOutdated();t.length>0&&this.listeners.forEach(e=>{e({updated:[],added:[],removed:t},"timeout")}),this.inner.isEmpty()&&(clearInterval(this.timer),this.timer=void 0)},this.timeout/2))}}(lt.peerIdStr),tl=D3(()=>{vt.debug("creating websocket");const t=t1().getWsSyncURL(y1()).toString(),e=new xC(t,void 0,{maxRetries:10,debug:!1,startClosed:!0,connectionTimeout:1e4});return Promise.resolve().then(async()=>{await n1(),M3()==="edit"&&e.reconnect()}),e.addEventListener("message",async n=>{const o=n.data,r=await o.arrayBuffer(),s=new Uint8Array(r);if((function(a,l){return new TextDecoder().decode(a.slice(0,l.length))===l})(s,el)){const a=(function(l,c){return l.slice(c.length)})(s,el);return Rs.apply(a),void Fm.debug("applied awareness update")}lt.import(s),vt.debug("imported doc change. new doc:",lt.toJSON()),Le.get(yo)!==lt&&Le.set(yo,lt)}),e.addEventListener("open",()=>{vt.debug("websocket open")}),e.addEventListener("close",n=>{vt.warn("websocket close",n),Le.get(yo)===lt&&Le.set(yo,void 0)}),e});function nl(t,e,n=""){if(Xt())return{extension:[],code:n};const o=lt.getByPath(`codes/${t}`)!==void 0,r=lt.getMap("codes").getOrCreateContainer(t,new Ec);o||(vt.log("initializing code for new cell",n),r.insert(0,n));const s={get name(){return Le.get(v1)||"Anonymous"},get colorClassName(){return(a=>{if(typeof a=="string"){let l=0;for(let c=0;c<a.length;c++)l=(l<<5)-l+a.charCodeAt(c),l=Math.trunc(l);return Os[Math.abs(l)%Os.length]}return Os[a%Os.length]})(this.name)}};return{code:n.toString(),extension:[ty(t),ny(t),oy(lt,Rs,s,()=>r,t),Z2(lt,["codes",t],()=>r)]}}function ty(t){const e=(o,r)=>{const s=o.state.field(ha).type,a=r.toString();a&&a!==s&&(vt.debug(`[incoming] setting language type: ${s} -> ${a}`),co(o,{language:a,keepCodeAsIs:!0}))},n=(o,r)=>{const s=o.state.field(xc),a=r.toJSON();kr(s,a)||o.dispatch({effects:[b1.of(a)],annotations:[xo.of(!0)]})};return Ut.define(o=>{let r;return Promise.resolve().then(()=>{const s=lt.getByPath(`languages/${t}`);if(!s)return void vt.error("no language container found for cell",t);Zt(s instanceof Ec,"language type is not a LoroText");const a=lt.getByPath(`language_metadata/${t}`);a?(Zt(a instanceof dg,"language metadata is not a LoroMap"),e(o,s),n(o,a),r=lt.subscribe(l=>{if(l.origin==="local")return;const c=l.events.some(u=>u.target===s.id),d=l.events.some(u=>u.target===a.id);c&&e(o,s),d&&n(o,a)})):vt.error("no language metadata container found for cell",t)}),{destroy(){r()}}})}function ny(t){const e=lt.getMap("languages").getOrCreateContainer(t,new Ec),n=lt.getMap("language_metadata").getOrCreateContainer(t,new dg);return Se.updateListener.of(o=>{const r=e.toString()!=="";if(!o.docChanged&&r)return;if(!r){const a=bc(o.state).type;co(o.view,{language:a}),vt.debug("no initial language, setting default to",a),e.delete(0,e.length),e.insert(0,a),vt.debug("no initial language metadata, setting default to",o.state.field(xc));const l=o.state.field(xc);for(const c of Object.keys(l))n.set(c,l[c]);return void lt.commit()}let s=!1;for(const a of o.transactions)if(!a.annotation(xo)){for(const l of a.effects)if(l.is(T3)&&e.toString()!==l.value.type&&(vt.debug(`[outgoing] language change: ${e} -> ${l.value.type}`),e.delete(0,e.length),e.insert(0,l.value.type),s=!0),l.is(b1)||l.is(x1)){const c=l.value;l.is(x1)?(vt.debug("[outgoing] setting language metadata: ",c),n.clear()):vt.debug("[outgoing] updating language metadata: ",c);for(const d of Object.keys(c))n.set(d,c[d]);s=!0}}s&&lt.commit()})}function oy(t,e,n,o,r,s){const a=`loro:cell:${r}`;return[Zi,g1({above:!0,class:"loro-cursor-layer",update:Rm,markers:l=>{const{remoteCursors:c,isCheckout:d}=l.state.field(Zi);return d?[]:[...c.values()].flatMap(u=>{var m,p;const h=Kt.cursor(u.cursor.anchor);return Ms.createCursor(l,h,((m=u.user)==null?void 0:m.name)||"unknown",((p=u.user)==null?void 0:p.colorClassName)||"")})}}),g1({above:!1,class:"loro-selection-layer",update:Rm,markers:l=>{const{remoteCursors:c,isCheckout:d}=l.state.field(Zi);return d?[]:[...c.entries()].filter(([,u])=>u.cursor.head!==void 0&&u.cursor.anchor!==u.cursor.head).flatMap(([,u])=>{var m;const h=Kt.range(u.cursor.anchor,u.cursor.head);return I3.forRange(l,`loro-selection ${((m=u.user)==null?void 0:m.colorClassName)||""}`,h)})}}),Ut.define(l=>new Y2(l,t,n,e,o,a,s)),Ut.define(l=>new X2(l,t,e,a)),J2]}function Ls(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}pa()&&tl(),lt.subscribeLocalUpdates(t=>{vt.debug("local update, sending to server"),tl().send(t)}),Rs.addListener((t,e)=>{const n=[...t.added,...t.removed,...t.updated];e==="local"&&(Fm.debug("awareness changes",n),tl().send((function(o,r){const s=new TextEncoder().encode(o);return new Uint8Array([...s,...r])})(el,Rs.encode(n))))});var Bm={modified:{doc:""},original:{doc:""}},Pm=S.createContext(Bm);function ry(t,e){return He({},t,e,{modified:He({},t.modified,e.modified),original:He({},t.original,e.original)})}var ol=()=>S.useContext(Pm),sy=t=>{var{children:e,theme:n}=t,[o,r]=S.useReducer(ry,He({},Bm,{theme:n}));return S.useEffect(()=>r({theme:n}),[n]),i.jsx(Pm.Provider,{value:He({},o,{dispatch:r}),children:e})},ay=["extensions","value","selection","onChange"],zm=t=>{var{extensions:e=[],value:n,selection:o,onChange:r}=t,s=Br(t,ay),{theme:a,dispatch:l}=ol(),c=Po(He({},s,{theme:a}));return S.useEffect(()=>l({original:{doc:n,selection:o,extensions:[...c,...e]},originalExtension:{onChange:r,option:s,extension:[e]}}),[t]),null};zm.displayName="CodeMirrorMerge.Original";var iy=["extensions","value","selection","onChange"],Um=t=>{var{extensions:e=[],value:n,selection:o,onChange:r}=t,s=Br(t,iy),{theme:a,dispatch:l}=ol(),c=Po(He({},s,{theme:a}));return S.useEffect(()=>{l({modified:{doc:n,selection:o,extensions:[...c,...e]},modifiedExtension:{onChange:r,option:s,extension:[e]}})},[t]),null};Um.displayName="CodeMirrorMerge.Modified";class Ze{constructor(e,n,o,r){this.fromA=e,this.toA=n,this.fromB=o,this.toB=r}offset(e,n=e){return new Ze(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function Zn(t,e,n,o,r,s){if(t==o)return[];let a=il(t,e,n,o,r,s),l=ll(t,e+a,n,o,r+a,s),c=(n-=l)-(e+=a),d=(s-=l)-(r+=a);if(!c||!d)return[new Ze(e,n,r,s)];if(c>d){let h=t.slice(e,n).indexOf(o.slice(r,s));if(h>-1)return[new Ze(e,e+h,r,r),new Ze(e+h+d,n,s,s)]}else if(d>c){let h=o.slice(r,s).indexOf(t.slice(e,n));if(h>-1)return[new Ze(e,e,r,r+h),new Ze(n,n,r+h+c,s)]}if(c==1||d==1)return[new Ze(e,n,r,s)];let u=Vm(t,e,n,o,r,s);if(u){let[h,m,p]=u;return Zn(t,e,h,o,r,m).concat(Zn(t,h+p,n,o,m+p,s))}return(function(h,m,p,b,x,f){let g=p-m,y=f-x;if(fr<1e9&&Math.min(g,y)>16*fr||pr>0&&Date.now()>pr)return Math.min(g,y)>64*fr?[new Ze(m,p,x,f)]:Gm(h,m,p,b,x,f);let w=Math.ceil((g+y)/2);sl.reset(w),al.reset(w);let j=(E,_)=>h.charCodeAt(m+E)==b.charCodeAt(x+_),C=(E,_)=>h.charCodeAt(p-E-1)==b.charCodeAt(f-_-1),N=(g-y)%2!=0?al:null,k=N?null:sl;for(let E=0;E<w;E++){if(E>fr||pr>0&&!(63&E)&&Date.now()>pr)return Gm(h,m,p,b,x,f);let _=sl.advance(E,g,y,w,N,!1,j)||al.advance(E,g,y,w,k,!0,C);if(_)return ly(h,m,p,m+_[0],b,x,f,x+_[1])}return[new Ze(m,p,x,f)]})(t,e,n,o,r,s)}let fr=1e9,pr=0,rl=!1;class Wm{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,o,r,s,a,l){for(let c=-e+this.start;c<=e-this.end;c+=2){let d=r+c,u=c==-e||c!=e&&this.vec[d-1]<this.vec[d+1]?this.vec[d+1]:this.vec[d-1]+1,h=u-c;for(;u<n&&h<o&&l(u,h);)u++,h++;if(this.vec[d]=u,u>n)this.end+=2;else if(h>o)this.start+=2;else if(s){let m=r+(n-o)-c;if(m>=0&&m<this.len&&s.vec[m]!=-1){if(a){let p=s.vec[m];if(p>=n-u)return[p,r+p-m]}else if(u>=n-s.vec[m])return[u,h]}}}return null}}const sl=new Wm,al=new Wm;function ly(t,e,n,o,r,s,a,l){let c=!1;return vo(t,o)||++o!=n||(c=!0),vo(r,l)||++l!=a||(c=!0),c?[new Ze(e,n,s,a)]:Zn(t,e,o,r,s,l).concat(Zn(t,o,n,r,l,a))}function $m(t,e){let n=1,o=Math.min(t,e);for(;n<o;)n<<=1;return n}function il(t,e,n,o,r,s){if(e==n||e==s||t.charCodeAt(e)!=o.charCodeAt(r))return 0;let a=$m(n-e,s-r);for(let l=e,c=r;;){let d=l+a,u=c+a;if(d>n||u>s||t.slice(l,d)!=o.slice(c,u)){if(a==1)return l-e-(vo(t,l)?0:1);a>>=1}else{if(d==n||u==s)return d-e;l=d,c=u}}}function ll(t,e,n,o,r,s){if(e==n||r==s||t.charCodeAt(n-1)!=o.charCodeAt(s-1))return 0;let a=$m(n-e,s-r);for(let l=n,c=s;;){let d=l-a,u=c-a;if(d<e||u<r||t.slice(d,l)!=o.slice(u,c)){if(a==1)return n-l-(vo(t,l)?0:1);a>>=1}else{if(d==e||u==r)return n-d;l=d,c=u}}}function cl(t,e,n,o,r,s,a,l){let c=o.slice(r,s),d=null;for(;;){if(d||a<l)return d;for(let u=e+a;;){vo(t,u)||u++;let h=u+a;if(vo(t,h)||(h+=h==u+1?1:-1),h>=n)break;let m=t.slice(u,h),p=-1;for(;(p=c.indexOf(m,p+1))!=-1;){let b=il(t,h,n,o,r+p+m.length,s),x=ll(t,e,u,o,r,r+p),f=m.length+b+x;(!d||d[2]<f)&&(d=[u-x,r+p-x,f])}u=h}if(l<0)return d;a>>=1}}function Vm(t,e,n,o,r,s){let a=n-e,l=s-r;if(a<l){let c=Vm(o,r,s,t,e,n);return c&&[c[1],c[0],c[2]]}return a<4||2*l<a?null:cl(t,e,n,o,r,s,Math.floor(a/4),-1)}function Gm(t,e,n,o,r,s){rl=!0;let a,l=n-e,c=s-r;if(l<c){let m=cl(o,r,s,t,e,n,Math.floor(l/6),50);a=m&&[m[1],m[0],m[2]]}else a=cl(t,e,n,o,r,s,Math.floor(c/6),50);if(!a)return[new Ze(e,n,r,s)];let[d,u,h]=a;return Zn(t,e,d,o,r,u).concat(Zn(t,d+h,n,o,u+h,s))}function qm(t,e){for(let n=1;n<t.length;n++){let o=t[n-1],r=t[n];o.toA>r.fromA-e&&o.toB>r.fromB-e&&(t[n-1]=new Ze(o.fromA,r.toA,o.fromB,r.toB),t.splice(n--,1))}}let eo;try{eo=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Hm(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function Jm(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?Hm(n)?1:0:eo?tf(n)&&e!=t.length-1?eo.test(t.slice(e,e+2))?2:0:eo.test(String.fromCharCode(n))?1:0:0}function Km(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?Hm(n)?1:0:eo?nf(n)&&e!=1?eo.test(t.slice(e-2,e))?2:0:eo.test(String.fromCharCode(n))?1:0:0}const Ym=8;function Xm(t,e,n){if(e==t.length||!Km(t,e))return e;for(let o=e,r=e+n,s=0;s<Ym;s++){let a=Jm(t,o);if(!a||o+a>r)return o;o+=a}return e}function Qm(t,e,n){if(!e||!Jm(t,e))return e;for(let o=e,r=e-n,s=0;s<Ym;s++){let a=Km(t,o);if(!a||o-a<r)return o;o-=a}return e}function Zm(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function ef(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const tf=t=>t>=55296&&t<=56319,nf=t=>t>=56320&&t<=57343;function vo(t,e){return!e||e==t.length||!tf(t.charCodeAt(e-1))||!nf(t.charCodeAt(e))}function cy(t,e,n){var o;return fr=((o=n==null?void 0:n.scanLimit)!==null&&o!==void 0?o:1e9)>>1,pr=n!=null&&n.timeout?Date.now()+n.timeout:0,rl=!1,(function(r,s,a){for(;;){qm(a,1);let l=!1;for(let c=0;c<a.length;c++){let d,u,h=a[c];(d=il(r,h.fromA,h.toA,s,h.fromB,h.toB))&&(h=a[c]=new Ze(h.fromA+d,h.toA,h.fromB+d,h.toB)),(u=ll(r,h.fromA,h.toA,s,h.fromB,h.toB))&&(h=a[c]=new Ze(h.fromA,h.toA-u,h.fromB,h.toB-u));let m=h.toA-h.fromA,p=h.toB-h.fromB;if(m&&p)continue;let b=h.fromA-(c?a[c-1].toA:0),x=(c<a.length-1?a[c+1].fromA:r.length)-h.toA;if(!b||!x)continue;let f=m?r.slice(h.fromA,h.toA):s.slice(h.fromB,h.toB);b<=f.length&&r.slice(h.fromA-b,h.fromA)==f.slice(f.length-b)?(a[c]=new Ze(h.fromA-b,h.toA-b,h.fromB-b,h.toB-b),l=!0):x<=f.length&&r.slice(h.toA,h.toA+x)==f.slice(0,x)&&(a[c]=new Ze(h.fromA+x,h.toA+x,h.fromB+x,h.toB+x),l=!0)}if(!l)break}return a})(t,e,Zn(t,0,t.length,e,0,e.length))}function of(){return!rl}function rf(t,e,n){return(function(o,r,s){for(let a=0,l=0;l<o.length;l++){let c=o[l],d=c.toA-c.fromA,u=c.toB-c.fromB;if(d&&u||d>3||u>3){let h=l==o.length-1?r.length:o[l+1].fromA,m=c.fromA-a,p=h-c.toA,b=Qm(r,c.fromA,m),x=Xm(r,c.toA,p),f=c.fromA-b,g=x-c.toA;if((!d||!u)&&f&&g){let y=Math.max(d,u),[w,j,C]=d?[r,c.fromA,c.toA]:[s,c.fromB,c.toB];y>f&&r.slice(b,c.fromA)==w.slice(C-f,C)?(c=o[l]=new Ze(b,b+d,c.fromB-f,c.toB-f),b=c.fromA,x=Xm(r,c.toA,h-c.toA)):y>g&&r.slice(c.toA,x)==w.slice(j,j+g)&&(c=o[l]=new Ze(x-d,x,c.fromB+g,c.toB+g),x=c.toA,b=Qm(r,c.fromA,c.fromA-a)),f=c.fromA-b,g=x-c.toA}if(f||g)c=o[l]=new Ze(c.fromA-f,c.toA+g,c.fromB-f,c.toB+g);else if(d){if(!u){let y,w=ef(r,c.fromA,c.toA),j=w<0?-1:Zm(r,c.toA,c.fromA);w>-1&&(y=w-c.fromA)<=p&&r.slice(c.fromA,w)==r.slice(c.toA,c.toA+y)?c=o[l]=c.offset(y):j>-1&&(y=c.toA-j)<=m&&r.slice(c.fromA-y,c.fromA)==r.slice(j,c.toA)&&(c=o[l]=c.offset(-y))}}else{let y,w=ef(s,c.fromB,c.toB),j=w<0?-1:Zm(s,c.toB,c.fromB);w>-1&&(y=w-c.fromB)<=p&&s.slice(c.fromB,w)==s.slice(c.toB,c.toB+y)?c=o[l]=c.offset(y):j>-1&&(y=c.toB-j)<=m&&s.slice(c.fromB-y,c.fromB)==s.slice(j,c.toB)&&(c=o[l]=c.offset(-y))}}a=c.toA}return qm(o,3),o})(cy(t,e,n),t,e)}const qt=ro.define({combine:t=>t[0]}),dl=nt.define(),dy=ro.define(),wo=Dt.define({create:t=>null,update(t,e){for(let n of e.effects)n.is(dl)&&(t=n.value);for(let n of e.state.facet(dy))t=n(t,e);return t}});class ko{constructor(e,n,o,r,s,a=!0){this.changes=e,this.fromA=n,this.toA=o,this.fromB=r,this.toB=s,this.precise=a}offset(e,n){return e||n?new ko(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,o){return lf(rf(e.toString(),n.toString(),o),e,n,0,0,of())}static updateA(e,n,o,r,s){return uf(df(e,r,!0,o.length),e,n,o,s)}static updateB(e,n,o,r,s){return uf(df(e,r,!1,n.length),e,n,o,s)}}function sf(t,e,n,o){let r=n.lineAt(t),s=o.lineAt(e);return r.to==t&&s.to==e&&t<n.length&&e<o.length?[t+1,e+1]:[r.from,s.from]}function af(t,e,n,o){let r=n.lineAt(t),s=o.lineAt(e);return r.from==t&&s.from==e?[t,e]:[r.to+1,s.to+1]}function lf(t,e,n,o,r,s){let a=[];for(let l=0;l<t.length;l++){let c=t[l],[d,u]=sf(c.fromA+o,c.fromB+r,e,n),[h,m]=af(c.toA+o,c.toB+r,e,n),p=[c.offset(-d+o,-u+r)];for(;l<t.length-1;){let b=t[l+1],[x,f]=sf(b.fromA+o,b.fromB+r,e,n);if(x>h+1&&f>m+1)break;p.push(b.offset(-d+o,-u+r)),[h,m]=af(b.toA+o,b.toB+r,e,n),l++}a.push(new ko(p,d,Math.max(d,h),u,Math.max(u,m),s))}return a}const Fs=1e3;function cf(t,e,n,o){let r=0,s=t.length;for(;;){if(r==s){let u=0,h=0;r&&({toA:u,toB:h}=t[r-1]);let m=e-(n?u:h);return[u+m,h+m]}let a=r+s>>1,l=t[a],[c,d]=n?[l.fromA,l.toA]:[l.fromB,l.toB];if(c>e)s=a;else{if(!(d<=e))return o?[l.fromA,l.fromB]:[l.toA,l.toB];r=a+1}}}function df(t,e,n,o){let r=[];return e.iterChangedRanges((s,a,l,c)=>{let d=0,u=n?e.length:o,h=0,m=n?o:e.length;s>Fs&&([d,h]=cf(t,s-Fs,n,!0)),a<e.length-Fs&&([u,m]=cf(t,a+Fs,n,!1));let p,b=c-l-(a-s),[x,f]=n?[b,0]:[0,b];r.length&&(p=r[r.length-1]).toA>=d?r[r.length-1]={fromA:p.fromA,fromB:p.fromB,toA:u,toB:m,diffA:p.diffA+x,diffB:p.diffB+f}:r.push({fromA:d,toA:u,fromB:h,toB:m,diffA:x,diffB:f})}),r}function uf(t,e,n,o,r){if(!t.length)return e;let s=[];for(let a=0,l=0,c=0,d=0;;a++){let u=a==t.length?null:t[a],h=u?u.fromA+l:n.length,m=u?u.fromB+c:o.length;for(;d<e.length;){let f=e[d];if(f.toA+l>h||f.toB+c>m)break;s.push(f.offset(l,c)),d++}if(!u)break;let p=u.toA+l+u.diffA,b=u.toB+c+u.diffB,x=rf(n.sliceString(h,p),o.sliceString(m,b),r);for(let f of lf(x,n,o,h,m,of()))s.push(f);for(l+=u.diffA,c+=u.diffB;d<e.length;){let f=e[d];if(f.fromA+l>p&&f.fromB+c>b)break;d++}}return s}const uy={scanLimit:500},hf=Ut.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=pf(t))}update(t){var e,n;(t.docChanged||t.viewportChanged||(e=t.startState,n=t.state,e.field(wo,!1)!=n.field(wo,!1))||(function(o,r){return o.facet(qt)!=r.facet(qt)})(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=pf(t.view))}},{decorations:t=>t.deco}),Bs=Sn.low(R3({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(hf))===null||e===void 0?void 0:e.gutter)||L3.empty}})),mf=Te.line({class:"cm-changedLine"}),hy=Te.mark({class:"cm-changedText"}),my=Te.mark({tagName:"ins",class:"cm-insertedLine"}),fy=Te.mark({tagName:"del",class:"cm-deletedLine"}),ff=new class extends F3{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function py(t,e,n,o,r,s){let a=n?t.fromA:t.fromB,l=n?t.toA:t.toB,c=0;if(a!=l){r.add(a,a,mf),r.add(a,l,n?fy:my),s&&s.add(a,a,ff);for(let d=e.iterRange(a,l-1),u=a;!d.next().done;){if(d.lineBreak){u++,r.add(u,u,mf),s&&s.add(u,u,ff);continue}let h=u+d.value.length;if(o)for(;c<t.changes.length;){let m=t.changes[c],p=a+(n?m.fromA:m.fromB),b=a+(n?m.toA:m.toB),x=Math.max(u,p),f=Math.min(h,b);if(x<f&&r.add(x,f,hy),!(b<h))break;c++}u=h}}}function pf(t){let e=t.state.field(wo),{side:n,highlightChanges:o,markGutter:r,overrideChunk:s}=t.state.facet(qt),a=n=="a",l=new Mo,c=r?new Mo:null,{from:d,to:u}=t.viewport;for(let h of e){if((a?h.fromA:h.fromB)>=u)break;(a?h.toA:h.toB)>d&&(s&&s(t.state,h,l,c)||py(h,t.state.doc,a,o,l,c))}return{deco:l.finish(),gutter:c&&c.finish()}}class Ps extends So{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const zs=nt.define({map:(t,e)=>t.map(e)}),gr=Dt.define({create:()=>Te.none,update:(t,e)=>{for(let n of e.effects)if(n.is(zs))return n.value;return t.map(e.changes)},provide:t=>Se.decorations.from(t)}),ul=.01;function gf(t,e){if(t.size!=e.size)return!1;let n=t.iter(),o=e.iter();for(;n.value;){if(n.from!=o.from||Math.abs(n.value.spec.widget.height-o.value.spec.widget.height)>1)return!1;n.next(),o.next()}return!0}const hl=nt.define({map:(t,e)=>e.mapPos(t)});class gy extends So{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",o=>{let r=e.posAtDOM(o.target);e.dispatch({effects:hl.of(r)});let{side:s,sibling:a}=e.state.facet(qt);a&&a().dispatch({effects:hl.of(by(r,e.state.field(wo),s=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function by(t,e,n){let o=0,r=0;for(let s=0;;s++){let a=s<e.length?e[s]:null;if(!a||(n?a.fromA:a.fromB)>=t)return r+(t-o);[o,r]=n?[a.toA,a.toB]:[a.toB,a.toA]}}const xy=Dt.define({create:t=>Te.none,update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is(hl)&&(t=t.update({filter:o=>o!=n.value}));return t},provide:t=>Se.decorations.from(t)});function bf({margin:t=3,minSize:e=4}){return xy.init(n=>(function(o,r,s){let a=new Mo,l=o.facet(qt).side=="a",c=o.field(wo),d=1;for(let u=0;;u++){let h=u<c.length?c[u]:null,m=u?d+r:1,p=h?o.doc.lineAt(l?h.fromA:h.fromB).number-1-r:o.doc.lines,b=p-m+1;if(b>=s&&a.add(o.doc.line(m).from,o.doc.line(p).to,Te.replace({widget:new gy(b),block:!0})),!h)break;d=o.doc.lineAt(Math.min(o.doc.length,l?h.toA:h.toB)).number}return a.finish()})(n,t,e))}const yy=Se.styleModule.of(new O3({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),vy=Se.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"\u299A"',marginInlineEnd:"7px"},"&:after":{content:'"\u299A"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),xf=new lc,Us=new lc;class yf{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||uy;let n=[Sn.low(hf),vy,yy,gr,Se.updateListener.of(h=>{this.measuring<0&&(h.heightChanged||h.viewportChanged)&&!h.transactions.some(m=>m.effects.some(p=>p.is(zs)))&&this.measure()})],o=[qt.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&o.push(Bs);let r=Dr.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Se.editorAttributes.of({class:"cm-merge-a"}),Us.of(o),n]}),s=[qt.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&s.push(Bs);let a=Dr.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Se.editorAttributes.of({class:"cm-merge-b"}),Us.of(s),n]});this.chunks=ko.build(r.doc,a.doc,this.diffConf);let l=[wo.init(()=>this.chunks),xf.of(e.collapseUnchanged?bf(e.collapseUnchanged):[])];r=r.update({effects:nt.appendConfig.of(l)}).state,a=a.update({effects:nt.appendConfig.of(l)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let c=e.orientation||"a-b",d=document.createElement("div");d.className="cm-mergeViewEditor";let u=document.createElement("div");u.className="cm-mergeViewEditor",this.editorDOM.appendChild(c=="a-b"?d:u),this.editorDOM.appendChild(c=="a-b"?u:d),this.a=new Se({state:r,parent:d,root:e.root,dispatchTransactions:h=>this.dispatch(h,this.a)}),this.b=new Se({state:a,parent:u,root:e.root,dispatchTransactions:h=>this.dispatch(h,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,n){if(e.some(o=>o.docChanged)){let o=e[e.length-1],r=e.reduce((a,l)=>a.compose(l.changes),Ar.empty(e[0].startState.doc.length));this.chunks=n==this.a?ko.updateA(this.chunks,o.newDoc,this.b.state.doc,r,this.diffConf):ko.updateB(this.chunks,this.a.state.doc,o.newDoc,r,this.diffConf),n.update([...e,o.state.update({effects:dl.of(this.chunks)})]);let s=n==this.a?this.b:this.a;s.update([s.state.update({effects:dl.of(this.chunks)})]),this.scheduleMeasure()}else n.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let s=e.orientation!="b-a";if(s!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let a=this.a.dom.parentNode,l=this.b.dom.parentNode;a.remove(),l.remove(),this.editorDOM.insertBefore(s?a:l,this.editorDOM.firstChild),this.editorDOM.appendChild(s?l:a),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let s=!!this.revertDOM,a=this.revertToA,l=this.renderRevert;"revertControls"in e&&(s=!!e.revertControls,a=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(l=e.renderRevertControl),this.setupRevertControls(s,a,l)}let n="highlightChanges"in e,o="gutter"in e,r="collapseUnchanged"in e;if(n||o||r){let s=[],a=[];if(n||o){let l=this.a.state.facet(qt),c=o?e.gutter!==!1:l.markGutter,d=n?e.highlightChanges!==!1:l.highlightChanges;s.push(Us.reconfigure([qt.of({side:"a",sibling:()=>this.b,highlightChanges:d,markGutter:c}),c?Bs:[]])),a.push(Us.reconfigure([qt.of({side:"b",sibling:()=>this.a,highlightChanges:d,markGutter:c}),c?Bs:[]]))}if(r){let l=xf.reconfigure(e.collapseUnchanged?bf(e.collapseUnchanged):[]);s.push(l),a.push(l)}this.a.dispatch({effects:s}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,n,o){this.revertToA=n,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=o,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",r=>this.revertClicked(r)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){(function(e,n,o){let r=new Mo,s=new Mo,a=e.state.field(gr).iter(),l=n.state.field(gr).iter(),c=0,d=0,u=0,h=0,m=e.viewport,p=n.viewport;for(let g=0;;g++){let y=g<o.length?o[g]:null,w=y?y.fromA:e.state.doc.length,j=y?y.fromB:n.state.doc.length;if(c<w){let C=e.lineBlockAt(c).top+u-(n.lineBlockAt(d).top+h);C<-.01?(u-=C,r.add(c,c,Te.widget({widget:new Ps(-C),block:!0,side:-1}))):C>ul&&(h+=C,s.add(d,d,Te.widget({widget:new Ps(C),block:!0,side:-1})))}if(w>c+1e3&&c<m.from&&w>m.from&&d<p.from&&j>p.from){let C=Math.min(m.from-c,p.from-d);c+=C,d+=C,g--}else{if(!y)break;c=y.toA,d=y.toB}for(;a.value&&a.from<c;)u-=a.value.spec.widget.height,a.next();for(;l.value&&l.from<d;)h-=l.value.spec.widget.height,l.next()}for(;a.value;)u-=a.value.spec.widget.height,a.next();for(;l.value;)h-=l.value.spec.widget.height,l.next();let b=e.contentHeight+u-(n.contentHeight+h);b<ul?r.add(e.state.doc.length,e.state.doc.length,Te.widget({widget:new Ps(-b),block:!0,side:1})):b>ul&&s.add(n.state.doc.length,n.state.doc.length,Te.widget({widget:new Ps(b),block:!0,side:1}));let x=r.finish(),f=s.finish();gf(x,e.state.field(gr))||e.dispatch({effects:zs.of(x)}),gf(f,n.state.field(gr))||n.dispatch({effects:zs.of(f)})})(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,n=e.firstChild,o=this.a.viewport,r=this.b.viewport;for(let s=0;s<this.chunks.length;s++){let a=this.chunks[s];if(a.fromA>o.to||a.fromB>r.to)break;if(a.fromA<o.from||a.fromB<r.from)continue;let l=this.a.lineBlockAt(a.fromA).top+"px";for(;n&&+n.dataset.chunk<s;)n=vf(n);n&&n.dataset.chunk==String(s)?(n.style.top!=l&&(n.style.top=l),n=n.nextSibling):e.insertBefore(this.renderRevertButton(l,s),n)}for(;n;)n=vf(n)}renderRevertButton(e,n){let o;if(this.renderRevert)o=this.renderRevert();else{o=document.createElement("button");let r=this.a.state.phrase("Revert this chunk");o.setAttribute("aria-label",r),o.setAttribute("title",r),o.textContent=this.revertToLeft?"\u21DC":"\u21DD"}return o.style.top=e,o.setAttribute("data-chunk",String(n)),o}revertClicked(e){let n,o=e.target;for(;o&&o.parentNode!=this.revertDOM;)o=o.parentNode;if(o&&(n=this.chunks[o.dataset.chunk])){let[r,s,a,l,c,d]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],u=r.state.sliceDoc(a,Math.max(a,l-1));a!=l&&d<=s.state.doc.length&&(u+=r.state.lineBreak),s.dispatch({changes:{from:c,to:Math.min(s.state.doc.length,d),insert:u},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function vf(t){let e=t.nextSibling;return t.remove(),e}var wy=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl","diffConfig","root"],ky=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],wf=he.forwardRef((t,e)=>{var{className:n,children:o,orientation:r,revertControls:s,highlightChanges:a,gutter:l,collapseUnchanged:c,destroyRerender:d=!0,renderRevertControl:u,diffConfig:h,root:m}=t,p=Br(t,wy),b=ol(),{modified:x,modifiedExtension:f,original:g,originalExtension:y,theme:w,dispatch:j}=b,C=Br(b,ky),N=S.useRef(null),k=S.useRef(),E={orientation:r,revertControls:s,highlightChanges:a,gutter:l,collapseUnchanged:c,renderRevertControl:u,diffConfig:h,root:m};S.useImperativeHandle(e,()=>({container:N.current,view:k.current,modified:x,original:g,config:He({a:g,b:x,parent:N.current},E)}),[N,k,x,g,E]);var _=Se.updateListener.of(A=>{if(A.docChanged&&typeof(y==null?void 0:y.onChange)=="function"){var O=A.state.doc.toString();y==null||y.onChange(O,A)}}),I=Se.updateListener.of(A=>{if(A.docChanged&&typeof(f==null?void 0:f.onChange)=="function"){var O=A.state.doc.toString();f==null||f.onChange(O,A)}});return S.useEffect(()=>{!k.current&&N.current&&y&&f&&(k.current=new yf(He({a:He({},g,{extensions:[...(y==null?void 0:y.extension)||[],...Po(He({},y==null?void 0:y.option,{theme:w})),_]}),b:He({},x,{extensions:[...(f==null?void 0:f.extension)||[],...Po(He({},f==null?void 0:f.option,{theme:w})),I]}),parent:N.current},E)),j({view:k.current}))},[k,N,y,f]),S.useEffect(()=>{if(g&&g.doc&&k.current){var A,O,D=(A=k.current)==null?void 0:A.a.state.doc.toString();D!==g.doc&&((O=k.current)==null||O.a.dispatch({changes:{from:0,to:D.length,insert:g.doc||""}}))}if(x&&x.doc&&k.current){var M,R,L=(M=k.current)==null?void 0:M.b.state.doc.toString();L!==x.doc&&((R=k.current)==null||R.b.dispatch({changes:{from:0,to:L.length,insert:x.doc||""}}))}if(d&&k.current){var P=k.current.a.state.selection.ranges[0].from,T=k.current.b.state.selection.ranges[0].from;k.current.destroy(),k.current=new yf(He({a:He({},g,{extensions:[...(y==null?void 0:y.extension)||[],...Po(He({},y==null?void 0:y.option,{theme:w}))]}),b:He({},x,{extensions:[...(f==null?void 0:f.extension)||[],...Po(He({},f==null?void 0:f.option,{theme:w}))]}),parent:N.current},E)),P&&(k.current.a.focus(),k.current.a.dispatch({selection:{anchor:P,head:P}})),T&&(k.current.b.focus(),k.current.b.dispatch({selection:{anchor:T,head:T}}))}},[k,w,N.current,g,x,y,f,d]),S.useEffect(()=>()=>k.current&&k.current.destroy(),[]),S.useEffect(()=>{if(k.current){var A={};C.orientation!==r&&(A.orientation=r),C.revertControls!==s&&(A.revertControls=s),C.highlightChanges!==a&&(A.highlightChanges=a),C.gutter!==l&&(A.gutter=l),C.collapseUnchanged!==c&&(A.collapseUnchanged=c),C.renderRevertControl!==u&&(A.collapseUnchanged=c),Object.keys(A).length&&j&&k.current&&(k.current.reconfigure(He({},A)),j(He({},A)))}},[j,k,r,s,a,l,c,u]),i.jsx("div",He({ref:N,className:"cm-merge-theme"+(n?" "+n:"")},p,{children:o}))});wf.displayName="CodeMirrorMerge.Internal";var jy=["theme"],jo=he.forwardRef((t,e)=>{var{theme:n}=t,o=Br(t,jy);return i.jsx(sy,{theme:n,children:i.jsx(wf,He({},o,{ref:e}))})});jo.Original=zm,jo.Modified=Um,jo.displayName="CodeMirrorMerge";const Cy=jo.Original,Ny=jo.Modified,kf=[Y3(),Se.lineWrapping],Sy=t=>{const e=z.c(28),{className:n,onChange:o,initialPrompt:r,currentLanguageAdapter:s,currentCode:a,declineChange:l,acceptChange:c,enabled:d,children:u}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={},e[0]=h):h=e[0];const[m,p]=S.useState(h),[b,x]=_n(B3),f=S.useId(),g=w1(),{completion:y,input:w,stop:j,isLoading:C,setCompletion:N,setInput:k,handleSubmit:E}=P3({api:g.getAiURL("completion").toString(),headers:g.headers(),initialInput:r,streamProtocol:"text",experimental_throttle:100,body:{...m,includeOtherCode:b?ic(a):"",code:a,language:s},onError:Ey,onFinish:(G,U)=>{_(U.trimEnd())}}),_=N,I=he.useRef(null),A=y.trimEnd();let O,D,M,R;e[1]!==d?(O=()=>{var G;d&&(X3(()=>{const U=I.current;return!!(U!=null&&U.view)&&(U.view.focus(),!0)},{retries:3,delay:100,initialDelay:100}),Q3((G=I.current)==null?void 0:G.view))},D=[d],e[1]=d,e[2]=O,e[3]=D):(O=e[2],D=e[3]),S.useEffect(O,D),e[4]!==d||e[5]!==r||e[6]!==k?(M=()=>{d&&k(r||"")},R=[d,r,k],e[4]=d,e[5]=r,e[6]=k,e[7]=M,e[8]=R):(M=e[7],R=e[8]),S.useEffect(M,R);const{theme:L}=k1(),P=()=>{c(A),_("")},T=()=>{_("")};let F;e[9]!==n?(F=de("flex flex-col w-full rounded-[inherit]",n),e[9]=n,e[10]=F):F=e[10];const $=d&&"max-h-[400px] min-h-11 visible",W=!d&&"max-h-0 min-h-0 invisible";let H;e[11]!==$||e[12]!==W?(H=de("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300",$,W),e[11]=$,e[12]=W,e[13]=H):H=e[13];const X=d&&i.jsxs(i.Fragment,{children:[i.jsx(Rr,{className:"text-(--blue-10) shrink-0",size:16}),i.jsx(z3,{inputRef:I,className:"h-full my-0 py-2 flex items-center",onClose:()=>{l(),_("")},value:w,onChange:G=>{k(G),p($3({input:G}))},onSubmit:()=>{var G;C||((G=I.current)!=null&&G.view&&W3(I.current.view),E())},onKeyDown:U3({handleAcceptCompletion:P,handleDeclineCompletion:T,isLoading:C,hasCompletion:A.trim().length>0})}),C&&i.jsxs(ye,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:j,children:[i.jsx(j1,{className:"animate-spin mr-1",size:14}),"Stop"]}),i.jsxs("div",{className:"-mr-1.5 py-1.5",children:[i.jsxs("div",{className:"flex flex-row items-center justify-end gap-0.5",children:[i.jsx(pe,{content:"Add context",children:i.jsx(ye,{variant:"text",size:"icon",onClick:()=>V3(I),children:i.jsx(G3,{className:"h-3 w-3"})})}),i.jsx(q3,{triggerClassName:"h-7 text-xs w-24",iconSize:"small",forRole:"edit"})]}),A&&i.jsx("div",{className:"-mb-1.5",children:i.jsx(H3,{isLoading:C,onAccept:P,onDecline:T,size:"xs"})})]}),i.jsx("div",{className:"h-full w-px bg-border mx-2"}),i.jsx(pe,{content:"Include code from other cells",children:i.jsxs("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[i.jsx(J3,{"data-testid":"include-other-cells-checkbox",id:f,checked:b,onCheckedChange:G=>x(!!G)}),i.jsx(Ao,{htmlFor:f,className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),i.jsx(ye,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:C,onClick:()=>{j(),l(),_("")},children:i.jsx($t,{className:"text-(--red-10)",size:16})})]});let q,Y;e[14]!==H||e[15]!==X?(q=i.jsx("div",{className:H,children:X}),e[14]=H,e[15]=X,e[16]=q):q=e[16],e[17]!==A||e[18]!==a||e[19]!==d||e[20]!==o||e[21]!==L?(Y=A&&d&&i.jsxs(jo,{className:"cm",theme:L,children:[i.jsx(Cy,{onChange:o,value:a,extensions:kf}),i.jsx(Ny,{value:A,editable:!1,readOnly:!0,extensions:kf})]}),e[17]=A,e[18]=a,e[19]=d,e[20]=o,e[21]=L,e[22]=Y):Y=e[22];const J=(!A||!d)&&u;let V;return e[23]!==q||e[24]!==Y||e[25]!==J||e[26]!==F?(V=i.jsxs("div",{className:F,children:[q,Y,J]}),e[23]=q,e[24]=Y,e[25]=J,e[26]=F,e[27]=V):V=e[27],V};function Ey(t){ze({title:"Completion failed",description:K3(t)})}const ml="web application/x-marimo-cell",_y=Be({cells:Z3(Be({code:Me()})),version:$e("1.0")}),jf=t=>{const e=t===1?"Cell":`${t} cells`;ze({title:`${e} copied`,description:`${e} ${t===1?"has":"have"} been copied to clipboard.`})},Iy=()=>{ze({title:"Copy failed",description:"Failed to copy cells to clipboard.",variant:"danger"})},Ay=()=>{ze({title:"Nothing to paste",description:"No cell or text found in clipboard.",variant:"danger"})},Ty=()=>{ze({title:"Paste failed",description:"Failed to read from clipboard",variant:"danger"})};class Dy{constructor(){this.items={}}add(e,n){return ClipboardItem.supports(e)?typeof n=="string"?(this.items[e]=new Blob([n],{type:e}),this):(this.items[e]=new Blob([JSON.stringify(n)],{type:e}),this):(Ye.warn(`ClipboardItem does not support ${e}`),this)}build(){return new ClipboardItem(this.items)}}const{valueAtom:My,useActions:Ws}=Ql(()=>new Set,{add:(t,e)=>{const n=new Set(t);return n.add(e),n},remove:(t,e)=>{const n=new Set(t);return n.delete(e),n}});function Oy(t){const e=z.c(2);let n;return e[0]!==t?(n=(o=>Qt(r=>r(My).has(o)))(t),e[0]=t,e[1]=n):n=e[1],ie(n)}const br=new WeakMap;function Cf(t){return{handle:e=>t(e),bulkHandle:e=>{let n=!0;try{for(const o of e)n=n&&t(o);return n}catch{return!1}}}}function sn(t){return{handle:e=>t([e]),bulkHandle:e=>t(e)}}function Nf(t,e){const n=z.c(30),{canMoveX:o,editorView:r,cellActionDropdownRef:s}=e,{saveOrNameNotebook:a}=ni(),{saveCellConfig:l}=qe(),c=Ct(Or),d=Ke(),u=na(),h=Ws(),m=Ho(),p=ie(C1),{copyCells:b,pasteAtCell:x}=(function(){const M=Ke();return{copyCells:Ce(async R=>{const L=Mt(),P=R.map(T=>L.cellData[T]).filter(Boolean);if(P.length!==0)try{const T={cells:P.map(W=>({code:W.code})),version:"1.0"},F=P.map(W=>W.code).join(`
120
131
 
121
- `),G=new Fy().add(ml,$).add("text/plain",W).build();await navigator.clipboard.write([G]),Cf(F.length)}catch($){He.error("Failed to copy cells to clipboard",$);try{const W=F.map(G=>G.code).join(`
132
+ `),$=new Dy().add(ml,T).add("text/plain",F).build();await navigator.clipboard.write([$]),jf(P.length)}catch(T){Ye.error("Failed to copy cells to clipboard",T);try{const F=P.map($=>$.code).join(`
122
133
 
123
- `);await navigator.clipboard.writeText(W),Cf(F.length)}catch{Oy()}}}),L=Ce(async(z,T)=>{const{before:F=!1}=T??{};try{const $=await navigator.clipboard.read();for(const G of $)if(G.types.includes(ml)){const X=await G.getType(ml),H=await X.text();try{const Y=My.parse(JSON.parse(H));if(Y.cells.length===0)break;const K=z,V=Y.cells.reverse();for(const q of V)M.createNewCell({cellId:K,before:F,code:q.code,autoFocus:!0});return}catch(Y){He.warn("Failed to parse clipboard cell data",Y)}}const W=await navigator.clipboard.readText();W.trim()?M.createNewCell({cellId:z,before:F,code:W,autoFocus:!0}):Ry()}catch($){He.error("Failed to paste from clipboard",$),Ly()}});return{copyCells:R,pasteAtCell:L}})(),f=ns(),g=(function(M){const R=P.c(2);let L;return R[0]!==M?(L=Bt(z=>z(oi).selected.has(M)),R[0]=M,R[1]=L):L=R[1],ie(L)})(t),y=Ko(),w=Nr(),j=ie(ra);let C;n[0]!==y||n[1]!==f?(C={clear:()=>{y.clear(),f.clear()},extend:M=>{y.clear(),f.extend(M)},select:M=>{y.clear(),f.select(M)}},n[0]=y,n[1]=f,n[2]=C):C=n[2];const N=C,k=ie(Gl);let E;n[3]!==k?(E=(M,R)=>yc(k.getHotkey(M).key)(R.nativeEvent||R),n[3]=k,n[4]=E):E=n[4];const _=E,I=(function(M){const R=P.c(11),L=_1(),z=Ye(),T=Ws();let F,$,W;R[0]!==M||R[1]!==L?(F=()=>{L.focusCell({cellId:M})},R[0]=M,R[1]=L,R[2]=F):F=R[2],R[3]!==z||R[4]!==M||R[5]!==L||R[6]!==T?($=()=>{T.remove(M),z.markTouched({cellId:M}),L.blurCell()},R[3]=z,R[4]=M,R[5]=L,R[6]=T,R[7]=$):$=R[7],R[8]!==F||R[9]!==$?(W={onFocusWithin:F,onBlurWithin:$},R[8]=F,R[9]=$,R[10]=W):W=R[10];const{focusWithinProps:G}=oj(W);return G})(t);let A;n[5]!==d||n[6]!==o||n[7]!==s||n[8]!==t||n[9]!==b||n[10]!==w||n[11]!==r||n[12]!==g||n[13]!==_||n[14]!==p||n[15]!==x||n[16]!==y||n[17]!==m||n[18]!==l||n[19]!==a||n[20]!==N||n[21]!==c||n[22]!==u||n[23]!==h||n[24]!==j?(A={onKeyDown:M=>{if(Fn.fromInput(M))return void M.continuePropagation();const R={"Mod+ArrowUp":()=>(d.focusTopCell(),N.clear(),!0),"Mod+ArrowDown":()=>(d.focusBottomCell(),N.clear(),!0),ArrowUp:()=>(d.focusCell({cellId:t,where:"before"}),N.clear(),!0),ArrowDown:()=>(d.focusCell({cellId:t,where:"after"}),N.clear(),!0),ArrowLeft:()=>{if(o){const T=u.get(Gt),F=T.cellIds.findWithId(t),$=T.cellIds.indexOf(F),W=T.cellIds.at($-1);if(W&&W.length>0){const G=Ef(t,W);return d.focusCell({cellId:G,where:"exact"}),N.clear(),!0}}return!1},ArrowRight:()=>{if(o){const T=u.get(Gt),F=T.cellIds.findWithId(t),$=T.cellIds.indexOf(F),W=T.cellIds.at($+1);if(W&&W.length>0){const G=Ef(t,W);return d.focusCell({cellId:G,where:"exact"}),N.clear(),!0}}return!1},"Shift+ArrowUp":()=>{const T=u.get(ga);N.extend({cellId:t,allCellIds:T});const F=T.findWithId(t).before(t);return F&&N.extend({cellId:F,allCellIds:T}),d.focusCell({cellId:t,where:"before"}),!0},"Shift+ArrowDown":()=>{const T=u.get(ga);N.extend({cellId:t,allCellIds:T});const F=T.findWithId(t).after(t);return F&&N.extend({cellId:F,allCellIds:T}),d.focusCell({cellId:t,where:"after"}),!0},Escape:()=>!!g&&(N.clear(),!0),Enter:()=>(h.add(t),A1(u,t),N.clear(),!0),s:()=>(a(),!0)};for(const[T,F]of Object.entries(R))if(yc(T)(M)&&F())return void M.preventDefault();const L={"cell.run":sn(T=>(m(T),!0)),"cell.runAndNewBelow":sn(T=>{m(T);const F=T[T.length-1];return d.moveToNextCell({cellId:F,before:!1}),!0}),"cell.runAndNewAbove":sn(T=>{m(T);const F=T[0];return d.moveToNextCell({cellId:F,before:!0}),!0}),"cell.createAbove":T=>(d.createNewCell({cellId:T,before:!0}),!0),"cell.createBelow":T=>(d.createNewCell({cellId:T,before:!1}),!0),"cell.moveUp":sn(T=>{const F=T[0];return u.get(Gt).cellIds.findWithId(F).first()!==F&&(T.forEach($=>{d.moveCell({cellId:$,before:!0})}),!0)}),"cell.moveDown":sn(T=>{const F=T[T.length-1];return u.get(Gt).cellIds.findWithId(F).last()!==F&&([...T].reverse().forEach($=>{d.moveCell({cellId:$,before:!1})}),!0)}),"cell.moveLeft":Nf(T=>!!o&&(d.moveCell({cellId:T,direction:"left"}),!0)),"cell.moveRight":Nf(T=>!!o&&(d.moveCell({cellId:T,direction:"right"}),!0)),"cell.hideCode":sn(T=>{var $;const F=!T.map(W=>{var X;return((X=u.get(Gt).cellData[W])==null?void 0:X.config)||null}).every(zy);l({configs:Object.fromEntries(T.map(W=>[W,{hide_code:F}]))});for(const W of T)d.updateCellConfig({cellId:W,config:{hide_code:F}});if(T.length===1){const W=T[0];d.focusCell({cellId:W,where:"after"}),F?(($=r.current)==null||$.contentDOM.blur(),I1(W)):A1(u,W)}return!0}),"cell.focusDown":T=>(d.focusCell({cellId:T,where:"after"}),!0),"cell.focusUp":T=>(d.focusCell({cellId:T,where:"before"}),!0),"cell.sendToBottom":sn(T=>(T.forEach(F=>{d.sendToBottom({cellId:F})}),!0)),"cell.sendToTop":sn(T=>([...T].reverse().forEach(F=>{d.sendToTop({cellId:F})}),!0)),"cell.aiCompletion":T=>{var $;let F=!1;return c(W=>(W==null?void 0:W.cellId)===T?(F=!0,null):{cellId:T}),F&&(($=r.current)==null||$.focus()),!0},"cell.cellActions":()=>{var T;return(T=s.current)==null||T.toggle(),!0},"command.copyCell":sn(T=>(b(T),!0)),"command.pasteCell":T=>(x(T),!0),"command.createCellBefore":T=>!Fn.hasModifier(M)&&(d.createNewCell({cellId:T,before:!0,autoFocus:!0}),!0),"command.createCellAfter":T=>!Fn.hasModifier(M)&&(d.createNewCell({cellId:T,before:!1,autoFocus:!0}),!0),"cell.delete":()=>{if(!j.keymap.destructive_delete)return!1;const T=z.size>=2?[...z]:[t],F=u.get(Gt);return!T.some($=>{const{status:W}=F.cellRuntime[$];return W==="running"||W==="queued"})&&(y.idle?(y.submit(T),!0):(w({cellIds:T}),y.clear(),!0))}},z=(function(T){return T.get(oi).selected})(u);if(p==="vim"&&(function(T,F){const $=(function(Y){if(Y.ctrlKey||Y.metaKey||Y.altKey)return"";const K=Y.key.toLowerCase();return Y.shiftKey?`shift+${K}`:K})(T),W=T.target;if(!$||!W)return!1;const G=xr.get(W);let X=$;G!=null&&G.timeout&&clearTimeout(G.timeout),G&&(X=`${G.sequence} ${$}`);const H=F[X];if(H)return xr.delete(W),H();if(!G){const Y=F[$];if(Y)return Y()}if(Object.keys(F).some(Y=>Y.startsWith(`${X} `))){const Y=window.setTimeout(()=>{xr.delete(W)},500);return xr.set(W,{sequence:X,timeout:Y}),!0}return xr.delete(W),!1})(M.nativeEvent||M,{j:R.ArrowDown,k:R.ArrowUp,h:R.ArrowLeft,l:R.ArrowRight,i:R.Enter,"shift+j":R["Shift+ArrowDown"],"shift+k":R["Shift+ArrowUp"],"g g":R["Mod+ArrowUp"],"shift+g":R["Mod+ArrowDown"],"d d":()=>L["cell.delete"](),"y y":()=>(b(z.size>=2?[...z]:[t]),!0),p:()=>(x(t,{before:!1}),!0),"shift+p":()=>(x(t,{before:!0}),!0),o:()=>(d.createNewCell({cellId:t,before:!1,autoFocus:!0}),!0),"shift+o":()=>(d.createNewCell({cellId:t,before:!0,autoFocus:!0}),!0),u:()=>(d.undoDeleteCell(),!0)}))M.preventDefault();else{for(const[T,F]of Object.entries(L))if(_(T,M)){if(F instanceof Function){if(F(t))return void M.preventDefault()}else if(z.size>=2?F.bulkHandle([...z]):F.handle(t))return void M.preventDefault();return}M.continuePropagation()}}},n[5]=d,n[6]=o,n[7]=s,n[8]=t,n[9]=b,n[10]=w,n[11]=r,n[12]=g,n[13]=_,n[14]=p,n[15]=x,n[16]=y,n[17]=m,n[18]=l,n[19]=a,n[20]=N,n[21]=c,n[22]=u,n[23]=h,n[24]=j,n[25]=A):A=n[25];const{keyboardProps:O}=E1(A);let D;return n[26]!==I||n[27]!==g||n[28]!==O?(D=Nl(I,O,{"data-selected":g,className:"data-[selected=true]:ring-1 data-[selected=true]:ring-(--blue-8) data-[selected=true]:ring-offset-1"}),n[26]=I,n[27]=g,n[28]=O,n[29]=D):D=n[29],D}function zy(t){return t==null?void 0:t.hide_code}function Ef(t,e){const n=document.getElementById(Js.create(t));if(!n)return e.first();const o=n.getBoundingClientRect();for(const r of e.topLevelIds){const s=document.getElementById(Js.create(r));if(s){const a=s.getBoundingClientRect();if(o.top<=a.bottom&&o.bottom>=a.top)return r}}return e.last()}const Uy=t=>{const e=P.c(24),{editorView:n,code:o,currentLanguageAdapter:r,onAfterToggle:s}=t;let a;e[0]!==o?(a=Bo.markdown.isSupported(o)||o.trim()==="",e[0]=o,e[1]=a):a=e[1];const l=a;let c;e[2]!==o?(c=Bo.sql.isSupported(o)||o.trim()==="",e[2]=o,e[3]=c):c=e[3];const d=c&&r==="python";let u,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(_o,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),e[4]=u):u=e[4],e[5]!==r||e[6]!==n||e[7]!==s||e[8]!==d?(h=i.jsx(fl,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:d,icon:u,toType:"sql",displayName:"SQL",onAfterToggle:s}),e[5]=r,e[6]=n,e[7]=s,e[8]=d,e[9]=h):h=e[9];const m=l&&r==="python";let p,b,x,f,g;return e[10]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Zs,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),e[10]=p):p=e[10],e[11]!==r||e[12]!==n||e[13]!==s||e[14]!==m?(b=i.jsx(fl,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:m,icon:p,toType:"markdown",displayName:"Markdown",onAfterToggle:s}),e[11]=r,e[12]=n,e[13]=s,e[14]=m,e[15]=b):b=e[15],e[16]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(hc,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),e[16]=x):x=e[16],e[17]!==r||e[18]!==n?(f=i.jsx(fl,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:!0,icon:x,toType:"python",displayName:"Python",onAfterToggle:Bn.NOOP}),e[17]=r,e[18]=n,e[19]=f):f=e[19],e[20]!==f||e[21]!==h||e[22]!==b?(g=i.jsxs("div",{className:"absolute right-3 top-2 z-20 flex hover-action gap-1",children:[h,b,f]}),e[20]=f,e[21]=h,e[22]=b,e[23]=g):g=e[23],g},fl=t=>{const e=P.c(10),{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:r,icon:s,toType:a,displayName:l,onAfterToggle:c}=t;let d;e[0]!==n||e[1]!==c||e[2]!==a?(d=()=>{n&&(co(n,{language:a}),c())},e[0]=n,e[1]=c,e[2]=a,e[3]=d):d=e[3];const u=d;if(!r||o===a)return null;const h=`View as ${l}`;let m,p;return e[4]!==u||e[5]!==s?(m=i.jsx(ye,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:u,children:s}),e[4]=u,e[5]=s,e[6]=m):m=e[6],e[7]!==h||e[8]!==m?(p=i.jsx(pe,{content:h,children:m}),e[7]=h,e[8]=m,e[9]=p):p=e[9],p},_f=({theme:t,showPlaceholder:e,id:n,config:o,code:r,status:s,serializedEditorState:a,setEditorView:l,runCell:c,userConfig:d,editorViewRef:u,editorViewParentRef:h,hidden:m,hasOutput:p,showHiddenCode:b,languageAdapter:x,setLanguageAdapter:f,showLanguageToggles:g=!0})=>{var K;const[y,w]=_n(tr),j=Cr(),{saveOrNameNotebook:C}=ti(),N=Ko(),{saveCellConfig:k}=qe(),E=s==="running"||s==="queued",_=Ye(),I=Mm(),A=x==="markdown",O=Ce(()=>!E&&(N.idle&&d.keymap.destructive_delete?(N.submit([n]),!0):(j({cellId:n}),!0))),D=Ce(()=>!E&&(c(),!0)),M=Ce(()=>{const V=!o.hide_code;return k({configs:{[n]:{hide_code:V}}}),_.updateCellConfig({cellId:n,config:{hide_code:V}}),V}),R=ie(p1),L=Ce(()=>{Gn({autoInstantiate:R,createNewCell:_.createNewCell})}),z=rj(d),T=S.useMemo(()=>{const V=O2({cellId:n,showPlaceholder:e,enableAI:z,cellActions:{..._,afterToggleMarkdown:L,onRun:D,deleteCell:O,saveNotebook:C,createManyBelow:q=>{for(const U of[...q].reverse())_.createNewCell({code:U,before:!1,cellId:n,skipIfCodeExists:!0})},splitCell:I,toggleHideCode:M,aiCellCompletion:()=>{let q=!1;return w(U=>(U==null?void 0:U.cellId)===n?(q=!0,null):{cellId:n}),q}},completionConfig:d.completion,keymapConfig:d.keymap,lspConfig:d.language_servers,theme:t,hotkeys:new T1(d.keymap.overrides??{}),diagnosticsConfig:d.diagnostics,displayConfig:d.display});return V.push(Wt.define(q=>{const U=q.state.field(ha);return f(U.type),{update(ne){const Q=ne.state.field(ha);f(Q.type)}}}),Se.updateListener.of(q=>{q.selectionSet&&q.state.selection.ranges.some(U=>U.from!==U.to)&&b({focus:!1})}),Se.domEventHandlers({focus:()=>{b({focus:!1})}})),V},[n,d.keymap,d.completion,d.language_servers,d.display,d.diagnostics,z,t,e,_,I,M,O,D,w,L,f,b,C]),F=pa(),$=Ce(()=>{if(F){const q=nl(n,0,r);T.push(q.extension),r=q.code}const V=new Se({state:Mr.create({doc:r,extensions:T})});l(V),F||co(V,{language:bc(V.state).type})}),W=Ce(()=>{if(Zt(u.current!==null,"Editor view is not initialized"),F){const V=nl(n);T.push(V.extension)}u.current.dispatch({effects:[tt.reconfigure.of([T]),sj(u.current,{completionConfig:d.completion,hotkeysProvider:new T1(d.keymap.overrides??{}),lspConfig:{...d.language_servers,diagnostics:d.diagnostics}})]})}),G=Ce(()=>{if(Zt(a,"Editor view is not initialized"),F){const q=nl(n,0,r);T.push(q.extension),r=q.code}const V=new Se({state:Mr.fromJSON(a,{doc:r,extensions:T},{history:aj})});F||co(V,{language:bc(V.state).type}),l(V),_.clearSerializedEditorState({cellId:n})});S.useEffect(()=>{a===null?u.current===null?$():W():G(),u.current!==null&&h&&h.current!==null&&h.current.replaceChildren(u.current.dom)},[$,W,G,u,h,a,T]),S.useEffect(()=>{const V=u.current;return()=>{V==null||V.destroy()}},[u]);const X=(function(V,q){const U=P.c(12),ne=Ws(),Q=ie(S1),ee=ie(Gl);let oe;if(U[0]!==ee){const ge=ee.getHotkey("command.vimEnterCommandMode");oe=yc(ge.key),U[0]=ee,U[1]=oe}else oe=U[1];const se=oe;let ae;U[2]!==V||U[3]!==ne?(ae=()=>{ne.remove(V),I1(V)},U[2]=V,U[3]=ne,U[4]=ae):ae=U[4];const te=ae;let _e;U[5]!==q||U[6]!==te?(_e=()=>{if(!q.current)return void te();const ge=q.current,Ee=ge.state;Ee.selection.main.empty?Fo(Ee)!==null?El(ge):te():ge.dispatch({selection:Yt.single(Ee.selection.main.from)})},U[5]=q,U[6]=te,U[7]=_e):_e=U[7];const he=_e;let we;U[8]!==he||U[9]!==Q||U[10]!==se?(we={onKeyDown:ge=>{Q==="vim"?se(ge)&&he():ge.key==="Escape"&&he(),ge.continuePropagation()}},U[8]=he,U[9]=Q,U[10]=se,U[11]=we):we=U[11];const{keyboardProps:ke}=E1(we);return ke})(n,u),H=m&&!A||m&&A&&!p;let Y="";return A&&m&&p?Y="h-0 overflow-hidden":m&&(Y="opacity-20 h-8 [&>div.cm-editor]:h-full [&>div.cm-editor]:overflow-hidden [&_.cm-panels]:hidden"),i.jsx(Ty,{enabled:(y==null?void 0:y.cellId)===n,initialPrompt:y==null?void 0:y.initialPrompt,currentCode:((K=u.current)==null?void 0:K.state.doc.toString())??r,currentLanguageAdapter:x,declineChange:Ce(()=>{var V;w(null),(V=u.current)==null||V.focus()}),onChange:Ce(V=>{var q;(q=u.current)==null||q.dispatch({changes:{from:0,to:u.current.state.doc.length,insert:V}})}),acceptChange:Ce(V=>{var q,U;(q=u.current)==null||q.dispatch({changes:{from:0,to:u.current.state.doc.length,insert:V}}),(U=u.current)==null||U.focus(),w(null)}),children:i.jsxs("div",{className:"relative w-full",...X,children:[H&&i.jsx(D1,{tooltip:"Edit code",className:"absolute inset-0 z-10",onClick:b}),i.jsx(If,{className:Y,editorView:u.current,ref:h}),!m&&g&&i.jsx("div",{className:"absolute top-1 right-5",children:i.jsx(Uy,{code:r,editorView:u.current,currentLanguageAdapter:x,onAfterToggle:L})})]})})},If=me.forwardRef((t,e)=>{const n=P.c(10),{className:o,editorView:r}=t,s=S.useRef(null);let a,l,c,d,u;return n[0]!==r?(a=()=>{r!==null&&s.current!==null&&s.current.children.length===0&&s.current.append(r.dom)},l=[r,s],n[0]=r,n[1]=a,n[2]=l):(a=n[1],l=n[2]),S.useEffect(a,l),n[3]!==o?(c=ue("cm mathjax_ignore",o),n[3]=o,n[4]=c):c=n[4],n[5]!==e?(d=h=>{e?Ls(e,s)(h):Ls(s)(h)},n[5]=e,n[6]=d):d=n[6],n[7]!==c||n[8]!==d?(u=i.jsx("div",{className:c,ref:d,"data-testid":"cell-editor"}),n[7]=c,n[8]=d,n[9]=u):u=n[9],u});If.displayName="CellCodeMirrorEditor";let Af,Tf,Df,pl;Ia=pa()?(function(t){const e=n=>{const o=P.c(5),r=ie(Nt),[s,a]=_n(yo);if(r.state===ht.CONNECTING||s===void 0){let c,d;return o[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{children:"Waiting for real-time collaboration connection..."}),o[0]=c):c=o[0],o[1]!==a?(d=i.jsx("div",{className:"flex h-full w-full items-baseline p-4",children:i.jsxs(ba,{milliseconds:1e3,fallback:null,children:[c,i.jsx(ye,{variant:"link",onClick:()=>{a("disabled")},children:"Turn off real-time collaboration"})]})}),o[1]=a,o[2]=d):d=o[2],d}let l;return o[3]!==n?(l=i.jsx(t,{...n}),o[3]=n,o[4]=l):l=o[4],l};return e.displayName=`WithWaitUntilConnected(${t.displayName})`,e})(S.memo(_f)):S.memo(_f),Af=t=>{const e=P.c(10);let n,o,r,s;return e[0]!==t.left?(n=i.jsx("div",{className:"flex-1 flex item-center gap-2",children:t.left}),e[0]=t.left,e[1]=n):n=e[1],e[2]!==t.center?(o=i.jsx("div",{className:"flex-1 flex item-center gap-2 justify-center",children:t.center}),e[2]=t.center,e[3]=o):o=e[3],e[4]!==t.right?(r=i.jsx("div",{className:"flex-1 flex item-center gap-2 justify-end",children:t.right}),e[4]=t.right,e[5]=r):r=e[5],e[6]!==n||e[7]!==o||e[8]!==r?(s=i.jsxs("div",{className:"flex items-center gap-2 w-full px-3",children:[n,o,r]}),e[6]=n,e[7]=o,e[8]=r,e[9]=s):s=e[9],s},Tf=t=>{const e=P.c(8);if(!t.canCollapse&&!t.isCollapsed)return null;const n=t.isCollapsed?"Expand":"Collapse";let o,r,s;return e[0]!==t.isCollapsed?(o=i.jsx("span",{children:i.jsx(Df,{isCollapsed:t.isCollapsed})}),e[0]=t.isCollapsed,e[1]=o):o=e[1],e[2]!==n||e[3]!==o?(r=i.jsx(pe,{content:n,children:o}),e[2]=n,e[3]=o,e[4]=r):r=e[4],e[5]!==t.onClick||e[6]!==r?(s=i.jsx(ye,{variant:"text",size:"icon",onClick:t.onClick,children:r}),e[5]=t.onClick,e[6]=r,e[7]=s):s=e[7],s},Df=t=>{const e=P.c(2),{isCollapsed:n}=t;let o;return e[0]!==n?(o=n?i.jsx(fa,{className:"w-5 h-5 shrink-0"}):i.jsx($n,{className:"w-5 h-5 shrink-0"}),e[0]=n,e[1]=o):o=e[1],o},pl=S.memo(t=>{const e=P.c(24),{onClick:n,count:o,cellId:r}=t,s=qp();let a;e[0]!==r||e[1]!==s?(a=ij(s,r),e[0]=r,e[1]=s,e[2]=a):a=e[2];const l=a;let c,d;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=ue("flex items-center justify-between w-[calc(100%-2rem)] h-9 bg-muted rounded-b mx-4 opacity-80 hover:opacity-100 cursor-pointer"),e[3]=c):c=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(cj,{className:"w-4 h-4 shrink-0"}),e[4]=d):d=e[4];const u=o===1?"cell":"cells";let h,m,p,b,x,f,g;return e[5]!==o||e[6]!==u?(h=i.jsxs(i.Fragment,{children:[d,i.jsxs("span",{className:"text-sm text-gray-500",children:[o," ",u," collapsed"]})]}),e[5]=o,e[6]=u,e[7]=h):h=e[7],e[8]!==l.errored?(m=l.errored&&i.jsx(pe,{content:"Has errors",delayDuration:100,children:i.jsx(ld,{className:"w-4 h-4 shrink-0 text-destructive"})}),e[8]=l.errored,e[9]=m):m=e[9],e[10]!==l.stale?(p=l.stale&&i.jsx(pe,{content:"Has stale cells",delayDuration:100,children:i.jsx(lj,{className:"w-4 h-4 shrink-0 text-(--yellow-11)"})}),e[10]=l.stale,e[11]=p):p=e[11],e[12]!==l.runningOrQueued?(b=l.runningOrQueued&&i.jsx(pe,{content:"Running",delayDuration:100,children:i.jsx(N1,{className:"w-4 h-4 shrink-0 animate-spin"})}),e[12]=l.runningOrQueued,e[13]=b):b=e[13],e[14]!==m||e[15]!==p||e[16]!==b?(x=i.jsxs(i.Fragment,{children:[m,p,b]}),e[14]=m,e[15]=p,e[16]=b,e[17]=x):x=e[17],e[18]!==h||e[19]!==x?(f=i.jsx(Af,{center:h,right:x}),e[18]=h,e[19]=x,e[20]=f):f=e[20],e[21]!==n||e[22]!==f?(g=i.jsx("div",{onClick:n,className:c,children:f}),e[21]=n,e[22]=f,e[23]=g):g=e[23],g}),pl.displayName="CollapsedCellBanner";const Mf=t=>{const e=P.c(31),{status:n,connectionState:o,onClick:r}=t,s=n==="running"||n==="queued";let a,l,c,d,u,h,m,p,b,x,f,g,y,w;if(e[0]!==o||e[1]!==s||e[2]!==r||e[3]!==n){const j=en(o);let C;if(j){let N;e[14]!==o?(N=oa(o),e[14]=o,e[15]=N):N=e[15],C=N}else C=n==="running"?"A cell can't be deleted when it's running":n==="queued"?"A cell can't be deleted when it's queued to run":"Delete";l=pe,b=C,x=!1,a=ye,c="ghost",d="icon",u=r,h="delete-button",m=Fn.preventFocus,p=ue("hover:bg-transparent text-destructive/60 hover:text-destructive",(j||s)&&"inactive-button"),e[0]=o,e[1]=s,e[2]=r,e[3]=n,e[4]=a,e[5]=l,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=m,e[11]=p,e[12]=b,e[13]=x}else a=e[4],l=e[5],c=e[6],d=e[7],u=e[8],h=e[9],m=e[10],p=e[11],b=e[12],x=e[13];return e[16]===Symbol.for("react.memo_cache_sentinel")?(f={boxShadow:"none"},g=i.jsx(ec,{size:14}),e[16]=f,e[17]=g):(f=e[16],g=e[17]),e[18]!==a||e[19]!==c||e[20]!==d||e[21]!==u||e[22]!==h||e[23]!==m||e[24]!==p?(y=i.jsx(a,{variant:c,size:d,onClick:u,"data-testid":h,onMouseDown:m,className:p,style:f,children:g}),e[18]=a,e[19]=c,e[20]=d,e[21]=u,e[22]=h,e[23]=m,e[24]=p,e[25]=y):y=e[25],e[26]!==l||e[27]!==y||e[28]!==b||e[29]!==x?(w=i.jsx(l,{content:b,usePortal:x,children:y}),e[26]=l,e[27]=y,e[28]=b,e[29]=x,e[30]=w):w=e[30],w},Wy=t=>{const e=P.c(22),{cellId:n}=t,o=(function(g){const y=P.c(16),w=ie(hu),j=mu(),C=Nr();let N;y[0]!==g||y[1]!==w.entries?(N=w.entries.get(g),y[0]=g,y[1]=w.entries,y[2]=N):N=y[2];const k=N;if(!k){let A;return y[3]===Symbol.for("react.memo_cache_sentinel")?(A={isPending:!1},y[3]=A):A=y[3],A}if(w.entries.size!==1){let A;return y[4]!==k?(A={isPending:!0,shouldConfirmDelete:!1,...k},y[4]=k,y[5]=A):A=y[5],A}let E,_,I;return y[6]!==j||y[7]!==C||y[8]!==w.entries?(E=()=>{C({cellIds:[...w.entries.values()].map(vb)}),j.clear()},y[6]=j,y[7]=C,y[8]=w.entries,y[9]=E):E=y[9],y[10]!==j?(_=()=>j.clear(),y[10]=j,y[11]=_):_=y[11],y[12]!==k||y[13]!==E||y[14]!==_?(I={isPending:!0,...k,shouldConfirmDelete:!0,confirm:E,cancel:_},y[12]=k,y[13]=E,y[14]=_,y[15]=I):I=y[15],I})(n);if(!o.isPending)return null;if(o.type==="simple"){let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=ue("px-3 py-1.5","bg-(--amber-2) border-t border-(--amber-6)","animate-in slide-in-from-top-2 duration-200"),e[0]=g):g=e[0];const y=`pending-delete-${n}`;let w,j;return e[1]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Zl,{className:"w-3 h-3 text-(--amber-11) shrink-0"}),i.jsx("span",{className:"text-(--amber-11) text-xs",children:"Pending deletion"})]}),e[1]=w):w=e[1],e[2]!==y?(j=i.jsx("div",{className:g,"data-testid":y,children:w}),e[2]=y,e[3]=j):j=e[3],j}const r=o.executionDurationMs!==void 0,s=o.defs.size>0,a=Wo(o.executionDurationMs??0);let l,c="Pending deletion";r&&s?c=`This cell took ${a} to run and contains variables referenced by other cells.`:r?c=`This cell took ${a} to run.`:s&&(c="This cell contains variables referenced by other cells."),e[4]===Symbol.for("react.memo_cache_sentinel")?(l=ue("px-4 py-3","bg-(--amber-2) border-t border-(--amber-6)","animate-in slide-in-from-top-2 duration-200"),e[4]=l):l=e[4];const d=`pending-delete-${n}`;let u,h,m,p,b,x,f;return e[5]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Zl,{className:"w-4 h-4 text-(--amber-11) mt-0.5 shrink-0"}),e[5]=u):u=e[5],e[6]!==c?(h=i.jsx("p",{className:"text-(--amber-11) font-medium",children:c}),e[6]=c,e[7]=h):h=e[7],e[8]!==s||e[9]!==o.defs?(m=s&&[...o.defs.entries()].map(Vy),e[8]=s,e[9]=o.defs,e[10]=m):m=e[10],e[11]!==h||e[12]!==m?(p=i.jsxs("div",{className:"font-code text-sm text-[0.84375rem]",children:[h,m]}),e[11]=h,e[12]=m,e[13]=p):p=e[13],e[14]!==o?(b=o.shouldConfirmDelete&&i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-(--amber-11) mt-2 mb-3",children:"Are you sure you want to delete?"}),i.jsx(Hl,{autoFocus:!0,children:i.jsxs("div",{className:"flex items-center gap-2",onKeyDown:Gy,children:[i.jsx(ye,{size:"xs",variant:"ghost",onClick:()=>o.cancel(),className:"text-(--amber-11) hover:bg-(--amber-4) hover:text-(--amber-11)",children:"Cancel"}),i.jsx(ye,{size:"xs",variant:"secondary",onClick:()=>o.confirm(),className:"bg-(--amber-11) hover:bg-(--amber-12) text-white border-(--amber-11)",children:"Delete"})]})})]}),e[14]=o,e[15]=b):b=e[15],e[16]!==p||e[17]!==b?(x=i.jsxs("div",{className:"flex items-start gap-3",children:[u,i.jsxs("div",{className:"flex-1",children:[p,b]})]}),e[16]=p,e[17]=b,e[18]=x):x=e[18],e[19]!==d||e[20]!==x?(f=i.jsx("div",{className:l,"data-testid":d,children:x}),e[19]=d,e[20]=x,e[21]=f):f=e[21],f};function $y(t){return i.jsx("li",{className:"my-0.5 ml-8 text-(--amber-11)/60",children:i.jsx(dj,{cellId:t})},t)}function Vy(t){const[e,n]=t;return i.jsxs("div",{children:[i.jsxs("p",{className:"text-(--amber-11) mt-2",children:["'",i.jsx("span",{className:"font-mono",children:e}),"' is referenced by:"]}),i.jsx("ul",{className:"list-disc",children:n.map($y)})]},e)}function Gy(t){t.stopPropagation()}const qy=t=>{const e=P.c(27),{onClick:n,connectionState:o,needsRun:r,status:s,config:a,edited:l}=t,c=s==="disabled-transitively",d=s==="running"||s==="queued";let u,h;e[0]!==c||e[1]!==a.disabled||e[2]!==o||e[3]!==l||e[4]!==d||e[5]!==r?(u=en(o)||d||!a.disabled&&c&&!l,h=(function({connectionState:f,needsRun:g,loading:y,inactive:w}){return en(f)?"disabled":g&&!y?"stale":y||w?"disabled":"green"})({connectionState:o,needsRun:r,loading:d,inactive:u}),e[0]=c,e[1]=a.disabled,e[2]=o,e[3]=l,e[4]=d,e[5]=r,e[6]=u,e[7]=h):(u=e[6],h=e[7]);const m=h;if(a.disabled){let f,g;return e[8]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Qc,{}),e[8]=f):f=e[8],e[9]!==u||e[10]!==n||e[11]!==m?(g=i.jsx(er,{tooltip:"Add code to notebook",disabled:u,onClick:n,variant:m,"data-testid":"run-button",children:f}),e[9]=u,e[10]=n,e[11]=m,e[12]=g):g=e[12],g}if(!a.disabled&&c&&!l){let f,g;return e[13]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Uo,{strokeWidth:1.2}),e[13]=f):f=e[13],e[14]!==u||e[15]!==n||e[16]!==m?(g=i.jsx(er,{disabled:u,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:n,variant:m,"data-testid":"run-button",children:f}),e[14]=u,e[15]=n,e[16]=m,e[17]=g):g=e[17],g}let p,b,x;if(en(o)){let f;e[18]!==o?(f=oa(o),e[18]=o,e[19]=f):f=e[19],p=f}else if(s==="queued")p="This cell is already queued to run";else if(s==="running")p="This cell is already running.";else{let f;e[20]===Symbol.for("react.memo_cache_sentinel")?(f=St("cell.run"),e[20]=f):f=e[20],p=f}return e[21]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(Uo,{strokeWidth:1.2}),e[21]=b):b=e[21],e[22]!==u||e[23]!==n||e[24]!==p||e[25]!==m?(x=i.jsx(er,{tooltip:p,disabled:u,onClick:n,variant:m,"data-testid":"run-button",children:b}),e[22]=u,e[23]=n,e[24]=p,e[25]=m,e[26]=x):x=e[26],x},Hy=t=>{const e=P.c(4),{cellId:n,className:o}=t;if(!ie(M1).has(n))return null;let r,s;return e[0]!==o?(r=ue("mo-ai-generated-cell",o),e[0]=o,e[1]=r):r=e[1],e[2]!==r?(s=i.jsx("div",{className:r}),e[2]=r,e[3]=s):s=e[3],s},Jy=t=>{const e=P.c(9),{cellId:n}=t,o=na(),r=ie(M1),{deleteStagedCell:s,removeStagedCell:a}=uj(o);if(!r.has(n))return null;let l;e[0]!==n||e[1]!==a?(l=()=>{a(n)},e[0]=n,e[1]=a,e[2]=l):l=e[2];const c=l;let d;e[3]!==n||e[4]!==s?(d=()=>{s(n)},e[3]=n,e[4]=s,e[5]=d):d=e[5];const u=d;let h;return e[6]!==c||e[7]!==u?(h=i.jsx("div",{className:"flex items-center justify-end gap-1.5 w-full pb-1 pt-2",children:i.jsx(hj,{isLoading:!1,onAccept:c,onDecline:u,size:"xs"})}),e[6]=c,e[7]=u,e[8]=h):h=e[8],h},Of=me.createContext(null),Rf=S.memo(()=>S.use(Of));Rf.displayName="DragHandle";const Lf=me.forwardRef((t,e)=>{const n=P.c(21);let o,r,s,a,l;n[0]!==t?({cellId:r,canMoveX:o,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==r?(a=r.toString(),n[4]=r,n[5]=a):a=n[5],n[6]!==a?(l={id:a},n[6]=a,n[7]=l):l=n[7];const{attributes:c,listeners:d,setNodeRef:u,transform:h,transition:m,isDragging:p}=Hu(l);let b;n[8]!==h?(b=(function(y){return!y||y.x===0&&y.y===0&&y.scaleX===1&&y.scaleY===1})(h)?null:h,n[8]=h,n[9]=b):b=n[9];const x=b,f=x==null?void 0:m;let g;return n[10]!==c||n[11]!==o||n[12]!==r||n[13]!==p||n[14]!==d||n[15]!==s||n[16]!==e||n[17]!==u||n[18]!==x||n[19]!==f?(g=i.jsx(Ff,{ref:e,cellId:r,canMoveX:o,...s,attributes:c,listeners:d,setNodeRef:u,transform:x,transition:f,isDragging:p}),n[10]=c,n[11]=o,n[12]=r,n[13]=p,n[14]=d,n[15]=s,n[16]=e,n[17]=u,n[18]=x,n[19]=f,n[20]=g):g=n[20],g});Lf.displayName="SortableCell";const Ff=me.forwardRef((t,e)=>{const n=P.c(35);let o,r,s,a,l,c,d,u,h,m;if(n[0]!==e||n[1]!==t){const{cellId:p,canMoveX:b,children:x,attributes:f,listeners:g,setNodeRef:y,transform:w,transition:j,isDragging:C,...N}=t;let k;o=x,n[10]!==b||n[11]!==w?(k=w?ca.Transform.toString({x:b?w.x:0,y:w.y,scaleX:1,scaleY:1}):void 0,n[10]=b,n[11]=w,n[12]=k):k=n[12];const E=C?2:void 0;let _,I,A;n[13]!==k||n[14]!==E||n[15]!==j?(_={transform:k,transition:j,zIndex:E,position:"relative"},n[13]=k,n[14]=E,n[15]=j,n[16]=_):_=n[16],s=_,n[17]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(Xc,{strokeWidth:1,size:20}),n[17]=I):I=n[17],n[18]!==f||n[19]!==g?(A=i.jsx("div",{...f,...g,onMouseDown:Fn.preventFocus,"data-testid":"drag-button",className:"py-px cursor-grab opacity-50 hover:opacity-100 hover-action hover:bg-muted rounded border border-transparent hover:border-border active:bg-accent",children:I}),n[18]=f,n[19]=g,n[20]=A):A=n[20],r=A;const O=!!w;a=-1,n[21]!==e||n[22]!==y?(l=D=>{Ls(e,y)(D)},n[21]=e,n[22]=y,n[23]=l):l=n[23],c=N,d=C,u=ue(N.className,O&&"is-moving","outline-hidden rounded-lg"),n[0]=e,n[1]=t,n[2]=o,n[3]=r,n[4]=s,n[5]=a,n[6]=l,n[7]=c,n[8]=d,n[9]=u}else o=n[2],r=n[3],s=n[4],a=n[5],l=n[6],c=n[7],d=n[8],u=n[9];return n[24]!==o||n[25]!==r?(h=i.jsx(Of.Provider,{value:r,children:o}),n[24]=o,n[25]=r,n[26]=h):h=n[26],n[27]!==s||n[28]!==a||n[29]!==l||n[30]!==c||n[31]!==d||n[32]!==u||n[33]!==h?(m=i.jsx("div",{tabIndex:a,ref:l,...c,"data-is-dragging":d,className:u,style:s,children:h}),n[27]=s,n[28]=a,n[29]=l,n[30]=c,n[31]=d,n[32]=u,n[33]=h,n[34]=m):m=n[34],m});function Bf(t,e){const n=P.c(9);let o;n[0]!==t||n[1]!==e?(o=c=>{t.current===null||t.current.contains(c.relatedTarget)||e.current===null||El(e.current)},n[0]=t,n[1]=e,n[2]=o):o=n[2];const r=Ce(o);let s;n[3]!==t||n[4]!==e?(s=c=>{if(t.current===document.activeElement&&e.current!==null&&Fo(e.current.state)==="active"){for(const d of i1)if(c.key===d.key&&d.run){d.run(e.current),c.preventDefault(),c.stopPropagation();break}e.current.focus()}},n[3]=t,n[4]=e,n[5]=s):s=n[5];const a=Ce(s);let l;return n[6]!==r||n[7]!==a?(l={closeCompletionHandler:r,resumeCompletionHandler:a},n[6]=r,n[7]=a,n[8]=l):l=n[8],l}function Pf(t){const e=P.c(16),{cellId:n,cellConfig:o,languageAdapter:r,editorView:s}=t,a=Py(n),l=Ws();let c;e[0]!==n?(c=pj(n),e[0]=n,e[1]=c):c=e[1];const d=ie(c),u=!o.hide_code||a||d,h=r==="markdown",m=h&&!u;let p;e[2]!==n||e[3]!==s||e[4]!==u||e[5]!==l?(p=y=>{var j;if(u)return;const w=(y==null?void 0:y.focus)??!0;l.add(n),w&&((j=s.current)==null||j.focus())},e[2]=n,e[3]=s,e[4]=u,e[5]=l,e[6]=p):p=e[6];const b=Ce(p);let x;e[7]!==m||e[8]!==b?(x=()=>{m&&b({focus:!0})},e[7]=m,e[8]=b,e[9]=x):x=e[9];const f=Ce(x);let g;return e[10]!==u||e[11]!==h||e[12]!==m||e[13]!==b||e[14]!==f?(g={isCellCodeShown:u,isMarkdown:h,isMarkdownCodeHidden:m,showHiddenCode:b,showHiddenCodeIfMarkdown:f},e[10]=u,e[11]=h,e[12]=m,e[13]=b,e[14]=f,e[15]=g):g=e[15],g}Ff.displayName="SortableCellInternal";const zf=S.forwardRef((t,e)=>{var x;const n=P.c(18),{cellId:o}=t,r=Lr(o),s=Fr(o);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=xa("marimo-cell","hover-actions-parent z-10",{published:!0}),n[0]=a):a=n[0];const l=a,c=R1((x=s.output)==null?void 0:x.mimetype);if(s.errored||s.interrupted||s.stopped||c)return null;let d;n[1]!==r.name||n[2]!==o?(d=Nc(o,r.name),n[1]=r.name,n[2]=o,n[3]=d):d=n[3];const u=s.output;let h,m,p,b;return n[4]!==r.edited||n[5]!==s?(h=B1(s,r.edited),n[4]=r.edited,n[5]=s,n[6]=h):h=n[6],n[7]!==s.status?(m=wc(s.status),n[7]=s.status,n[8]=m):m=n[8],n[9]!==o||n[10]!==s.output||n[11]!==h||n[12]!==m?(p=i.jsx(vc,{allowExpand:!1,forceExpand:!0,className:"output-area",cellId:o,output:u,stale:h,loading:m}),n[9]=o,n[10]=s.output,n[11]=h,n[12]=m,n[13]=p):p=n[13],n[14]!==e||n[15]!==d||n[16]!==p?(b=i.jsx("div",{tabIndex:-1,ref:e,className:l,...d,children:p}),n[14]=e,n[15]=d,n[16]=p,n[17]=b):b=n[17],b});zf.displayName="ReadonlyCellComponent";const Ky=({theme:t,showPlaceholder:e,cellId:n,canDelete:o,userConfig:r,isCollapsed:s,collapseCount:a,canMoveX:l,editorView:c,setEditorView:d})=>{var _e;const u=S.useRef(null),h=Lr(n),m=Fr(n),p=S.useRef(null),b=S.useRef(null),x=S.useRef(null),f=Ye(),g=ie(Nt),y=Ct(tr),w=Cr(),j=Va(n),{sendStdin:C}=qe(),[N,k]=S.useState(),E=h.config.disabled||m.status==="disabled-transitively",_=O1({executionTime:m.runElapsedTimeMs??h.lastExecutionTime,status:m.status,errored:m.errored,interrupted:m.interrupted,stopped:m.stopped}),I=h.edited||m.interrupted||m.staleInputs&&!E,A=wc(m.status),O=(m.status==="queued"||h.edited||m.staleInputs)&&!m.interrupted,D=S.useCallback(()=>c.current,[c]),{closeCompletionHandler:M,resumeCompletionHandler:R}=Bf(u,c),{isCellCodeShown:L,isMarkdown:z,isMarkdownCodeHidden:T,showHiddenCode:F,showHiddenCodeIfMarkdown:$}=Pf({cellId:n,cellConfig:h.config,languageAdapter:N,editorView:c}),W=Sf(n,{canMoveX:l,editorView:c,cellActionDropdownRef:p}),G=fj(m.outline),X=!gc(m.output),H=m.consoleOutputs.length>0,Y=r.display.cell_output,K=X&&Y==="above",V=X&&Y==="below",[q,U]=S.useState(!1),[ne,Q]=S.useState(!1);(function(he){const{ref:we,box:ke="content-box",skip:ge}=he,Ee=S.useRef({...L2}),Oe=S.useRef(void 0);Oe.current=he.onResize,S.useEffect(()=>{if(!we.current||ge||typeof window>"u"||!("ResizeObserver"in window))return;const ve=new ResizeObserver(([be])=>{const et=ke==="border-box"?"borderBoxSize":ke==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",rt=em(be,et,"inlineSize"),ct=em(be,et,"blockSize");if(Ee.current.width!==rt||Ee.current.height!==ct){const dt={width:rt,height:ct};Ee.current.width=rt,Ee.current.height=ct,Oe.current&&Oe.current(dt)}});return ve.observe(we.current,{box:ke}),()=>{ve.disconnect()}},[ke,we,ge])})({ref:x,skip:!z,onResize:he=>{const we=he.height&&he.height<68,ke=T&&(we||Y==="below");U(ke),G&&ke?Q(!0):ne&&Q(!1)}});const ee=he=>i.jsx(D1,{tooltip:"Edit markdown",className:ue("z-20 relative",he),onClick:F}),oe=X&&i.jsxs("div",{className:"relative",onDoubleClick:$,children:[i.jsx("div",{className:"absolute top-5 -left-8 z-10 print:hidden",children:i.jsx(Tf,{isCollapsed:s,onClick:()=>{s?f.expandCell({cellId:n}):f.collapseCell({cellId:n})},canCollapse:G})}),T&&V&&ee("top-3"),i.jsx(vc,{allowExpand:!0,forceExpand:T,className:"output-area",cellId:n,output:m.output,stale:B1(m,h.edited),loading:wc(m.status)}),T&&K&&ee("bottom-3")]}),se=xa("marimo-cell","hover-actions-parent z-10",{interactive:!0,"needs-run":I,"has-error":m.errored,stopped:m.stopped,disabled:h.config.disabled,stale:m.status==="disabled-transitively",borderless:T&&X&&!W["data-selected"]}),ae=Ce(he=>{y({cellId:n,initialPrompt:he.prompt})}),te=((_e=m.serialization)==null?void 0:_e.toLowerCase())==="valid";return i.jsx(L1,{children:i.jsx(Om,{cellId:n,getEditorView:D,children:i.jsxs(Lf,{tabIndex:-1,ref:u,"data-status":m.status,onBlur:M,onKeyDown:R,cellId:n,canMoveX:l,title:h.config.disabled?"This cell is disabled":m.status==="disabled-transitively"?"This cell has a disabled ancestor":void 0,children:[i.jsxs("div",{tabIndex:-1,...W,className:ue(se,W.className,"focus:ring-1 focus:ring-(--blue-7) focus:ring-offset-0"),ref:x,...Nc(n,h.name),children:[Y==="above"&&oe,i.jsxs("div",{className:ue("tray"),"data-hidden":T,children:[i.jsx(Hy,{cellId:n}),i.jsx("div",{className:"absolute right-2 -top-4 z-10",children:i.jsx(bl,{edited:h.edited,status:m.status,cellConfig:h.config,needsRun:I,hasOutput:X,hasConsoleOutput:H,cellActionDropdownRef:p,cellId:n,name:h.name,getEditorView:D,onRun:j})}),i.jsx(Uf,{cellId:n,className:ue(T&&K&&"-top-7",T&&V&&"-bottom-8",T&&ne&&"-left-[3.8rem]"),actions:f}),i.jsx(Ia,{theme:t,showPlaceholder:e,id:n,code:h.code,config:h.config,status:m.status,serializedEditorState:h.serializedEditorState,runCell:j,setEditorView:d,userConfig:r,editorViewRef:c,editorViewParentRef:b,hidden:!L,hasOutput:X,showHiddenCode:F,languageAdapter:N,setLanguageAdapter:k}),i.jsx(gl,{className:ue(T&&Y==="below"&&"top-14"),edited:h.edited,status:m.status,isCellStatusInline:q,uninstantiated:_,disabled:h.config.disabled,runElapsedTimeMs:m.runElapsedTimeMs,runStartTimestamp:m.runStartTimestamp,lastRunStartTimestamp:m.lastRunStartTimestamp,staleInputs:m.staleInputs,interrupted:m.interrupted}),i.jsx("div",{className:"shoulder-bottom hover-action",children:o&&L&&i.jsx(Mf,{status:m.status,connectionState:g.state,onClick:()=>{A||en(g.state)||w({cellId:n})}})})]}),Y==="below"&&oe,m.serialization&&i.jsxs("div",{className:"py-1 px-2 flex items-center justify-end gap-2 last:rounded-b",children:[te&&i.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",className:"hover:underline text-muted-foreground text-xs font-bold",rel:"noopener",children:"reusable"}),i.jsx(pe,{content:i.jsx("span",{className:"max-w-16 text-xs",children:te?"This function or class can be imported into other Python notebooks or modules.":i.jsxs(i.Fragment,{children:["This definition can't be reused in other Python modules:",i.jsx("br",{}),i.jsx("br",{}),i.jsx("pre",{children:m.serialization}),i.jsx("br",{}),"Click this icon to learn more."]})}),children:te?i.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",rel:"noopener",children:i.jsx(bp,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})}):i.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",rel:"noopener",children:i.jsx(F1,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})})})]}),i.jsx(ig,{consoleOutputs:m.consoleOutputs,stale:O,cellName:m.serialization?"_":h.name,onRefactorWithAI:ae,onClear:()=>{f.clearCellConsoleOutput({cellId:n})},onSubmitDebugger:(he,we)=>{f.setStdinResponse({cellId:n,response:he,outputIndex:we}),C({text:he})},cellId:n,debuggerActive:m.debuggerActive}),i.jsx(Wy,{cellId:n})]}),i.jsx(Jy,{cellId:n}),s&&i.jsx(pl,{onClick:()=>f.expandCell({cellId:n}),count:a,cellId:n})]})})})},gl=S.memo(t=>{const e=P.c(19),{className:n,disabled:o,edited:r,interrupted:s,isCellStatusInline:a,lastRunStartTimestamp:l,runElapsedTimeMs:c,runStartTimestamp:d,staleInputs:u,status:h,uninstantiated:m}=t,p=o!==void 0&&o;let b;e[0]!==p||e[1]!==r||e[2]!==s||e[3]!==l||e[4]!==c||e[5]!==d||e[6]!==u||e[7]!==h||e[8]!==m?(b=i.jsx(tm,{status:h,staleInputs:u,interrupted:s,editing:!0,edited:r,disabled:p,elapsedTime:c,runStartTimestamp:d,uninstantiated:m,lastRunStartTimestamp:l}),e[0]=p,e[1]=r,e[2]=s,e[3]=l,e[4]=c,e[5]=d,e[6]=u,e[7]=h,e[8]=m,e[9]=b):b=e[9];const x=b;let f;e[10]!==n?(f=ue("shoulder-right z-20",n),e[10]=n,e[11]=f):f=e[11];const g=!a&&x;let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(Rf,{}),e[12]=y):y=e[12];const w=a&&x;let j,C;return e[13]!==w?(j=i.jsxs("div",{className:"flex gap-2 items-end",children:[y,w]}),e[13]=w,e[14]=j):j=e[14],e[15]!==f||e[16]!==g||e[17]!==j?(C=i.jsxs("div",{className:f,children:[g,j]}),e[15]=f,e[16]=g,e[17]=j,e[18]=C):C=e[18],C});gl.displayName="CellRightSideActions";const Uf=S.memo(t=>{const e=P.c(21),n=ie(Nt),{className:o,actions:r,cellId:s}=t;let a;e[0]!==r||e[1]!==s?(a=j=>{const C=j===void 0?{}:j;return r.createNewCell({cellId:s,before:!1,...C})},e[0]=r,e[1]=s,e[2]=a):a=e[2];const l=Ce(a);let c;e[3]!==r||e[4]!==s?(c=j=>{const C=j===void 0?{}:j;return r.createNewCell({cellId:s,before:!0,...C})},e[3]=r,e[4]=s,e[5]=c):c=e[5];const d=Ce(c),u=P1(n.state);let h,m;e[6]!==o?(h=ue("absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-20",o),e[6]=o,e[7]=h):h=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(m=St("cell.createAbove"),e[8]=m):m=e[8];const p=u?d:void 0;let b,x,f;e[9]!==n.state||e[10]!==p?(b=i.jsx(Tm,{tooltipContent:m,connectionState:n.state,onClick:p}),e[9]=n.state,e[10]=p,e[11]=b):b=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("div",{className:"flex-1"}),e[12]=x):x=e[12],e[13]===Symbol.for("react.memo_cache_sentinel")?(f=St("cell.createBelow"),e[13]=f):f=e[13];const g=u?l:void 0;let y,w;return e[14]!==n.state||e[15]!==g?(y=i.jsx(Tm,{tooltipContent:f,connectionState:n.state,onClick:g}),e[14]=n.state,e[15]=g,e[16]=y):y=e[16],e[17]!==h||e[18]!==b||e[19]!==y?(w=i.jsxs("div",{className:h,children:[b,x,y]}),e[17]=h,e[18]=b,e[19]=y,e[20]=w):w=e[20],w});Uf.displayName="CellLeftSideActions";const bl=S.memo(t=>{const e=P.c(27),{edited:n,status:o,cellConfig:r,needsRun:s,hasOutput:a,hasConsoleOutput:l,onRun:c,cellActionDropdownRef:d,cellId:u,getEditorView:h,name:m,includeCellActions:p}=t,b=p===void 0||p,x=ie(Nt),f=P1(x.state),g=!s&&"hover-action";let y;e[0]!==g?(y=ue(g),e[0]=g,e[1]=y):y=e[1];const w=f?c:Bn.NOOP;let j,C,N,k;return e[2]!==r||e[3]!==x.state||e[4]!==n||e[5]!==s||e[6]!==o||e[7]!==w?(j=i.jsx(qy,{edited:n,onClick:w,connectionState:x.state,status:o,config:r,needsRun:s}),e[2]=r,e[3]=x.state,e[4]=n,e[5]=s,e[6]=o,e[7]=w,e[8]=j):j=e[8],e[9]!==x.state||e[10]!==o?(C=i.jsx(_x,{status:o,connectionState:x.state}),e[9]=x.state,e[10]=o,e[11]=C):C=e[11],e[12]!==d||e[13]!==r||e[14]!==u||e[15]!==h||e[16]!==l||e[17]!==a||e[18]!==b||e[19]!==m||e[20]!==o?(N=b&&i.jsx(Qi,{ref:d,cellId:u,status:o,getEditorView:h,name:m,config:r,hasOutput:a,hasConsoleOutput:l,children:i.jsx(er,{variant:"green",tooltip:null,"data-testid":"cell-actions-button",children:i.jsx(Ca,{strokeWidth:1.5})})}),e[12]=d,e[13]=r,e[14]=u,e[15]=h,e[16]=l,e[17]=a,e[18]=b,e[19]=m,e[20]=o,e[21]=N):N=e[21],e[22]!==y||e[23]!==j||e[24]!==C||e[25]!==N?(k=i.jsxs(Ex,{className:y,children:[j,C,N]}),e[22]=y,e[23]=j,e[24]=C,e[25]=N,e[26]=k):k=e[26],k});bl.displayName="CellToolbar";const Yy=({theme:t,showPlaceholder:e,cellId:n,canDelete:o,userConfig:r,canMoveX:s,editorView:a,setEditorView:l})=>{var F;const c=S.useRef(null),d=Lr(n),u=Fr(n),h=S.useRef(null),m=S.useRef(null),p=ie(Nt),b=Ye(),x=qe(),f=Cr(),g=Ct(tr),y=Va(n),w=d.config.disabled||u.status==="disabled-transitively",j=O1({executionTime:u.runElapsedTimeMs??d.lastExecutionTime,status:u.status,errored:u.errored,interrupted:u.interrupted,stopped:u.stopped}),C=d.edited||u.interrupted||u.staleInputs&&!w,N=u.status==="running"||u.status==="queued",k=(u.status==="queued"||d.edited||u.staleInputs)&&!u.interrupted,E=S.useCallback(()=>a.current,[a]),{isCellCodeShown:_,showHiddenCode:I}=Pf({cellId:n,cellConfig:d.config,languageAdapter:"python",editorView:a}),{closeCompletionHandler:A,resumeCompletionHandler:O}=Bf(c,a),D=Sf(n,{canMoveX:s,editorView:a,cellActionDropdownRef:h}),M=!gc(u.output),R=u.consoleOutputs.length>0,L=R1((F=u.output)==null?void 0:F.mimetype),z=xa("marimo-cell","hover-actions-parent z-10 border shadow-sm","border-(--blue-5)! rounded-sm!",{"needs-run":C,"has-error":u.errored,stopped:u.stopped}),T=Ce($=>{g({cellId:n,initialPrompt:$.prompt})});return i.jsx(L1,{children:i.jsx(Om,{cellId:n,getEditorView:E,children:i.jsxs("div",{"data-status":u.status,ref:c,...Nl(D,{className:z,onBlur:A,onKeyDown:O}),...Nc(n,d.name),title:d.config.disabled?"This cell is disabled":u.status==="disabled-transitively"?"This cell has a disabled ancestor":void 0,"data-setup-cell":!0,children:[i.jsxs("div",{className:ue("tray"),"data-hidden":!_,children:[i.jsx("div",{className:"absolute right-2 -top-4 z-10",children:i.jsx(bl,{edited:d.edited,status:u.status,cellConfig:d.config,needsRun:C,hasOutput:M,hasConsoleOutput:R,cellActionDropdownRef:h,cellId:n,name:d.name,getEditorView:E,onRun:y,includeCellActions:!0})}),i.jsx(Ia,{theme:t,showPlaceholder:e,id:n,code:d.code,config:d.config,status:u.status,serializedEditorState:d.serializedEditorState,runCell:y,setEditorView:l,userConfig:r,editorViewRef:a,editorViewParentRef:m,hidden:!_,hasOutput:M,showHiddenCode:I,languageAdapter:"python",setLanguageAdapter:Bn.NOOP,showLanguageToggles:!1}),i.jsx(gl,{edited:d.edited,status:u.status,isCellStatusInline:!1,uninstantiated:j,disabled:d.config.disabled,runElapsedTimeMs:u.runElapsedTimeMs,runStartTimestamp:u.runStartTimestamp,lastRunStartTimestamp:u.lastRunStartTimestamp,staleInputs:u.staleInputs,interrupted:u.interrupted}),i.jsx("div",{className:"shoulder-bottom hover-action",children:o&&i.jsx(Mf,{connectionState:p.state,status:u.status,onClick:()=>{N||en(p.state)||f({cellId:n})}})})]}),i.jsxs("div",{className:"py-1 px-2 flex justify-end gap-2 last:rounded-b",children:[i.jsx("span",{className:"text-muted-foreground text-xs font-bold",children:"setup cell"}),i.jsx(pe,{content:i.jsxs("span",{className:"max-w-16",children:["This ",i.jsx("b",{children:"setup cell"})," is guaranteed to run before all other cells. Include ",i.jsx("br",{}),"initialization or imports and constants required by top-level functions."]}),children:i.jsx(F1,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})})]}),L&&i.jsx(vc,{allowExpand:!0,forceExpand:!0,className:"output-area",cellId:n,output:u.output,stale:!1,loading:N}),i.jsx(ig,{consoleOutputs:u.consoleOutputs,stale:k,cellName:"_",onRefactorWithAI:T,onClear:()=>{b.clearCellConsoleOutput({cellId:n})},onSubmitDebugger:($,W)=>{b.setStdinResponse({cellId:n,response:$,outputIndex:W}),x.sendStdin({text:$})},cellId:n,debuggerActive:u.debuggerActive})]})})})},Wf=S.memo(t=>{const{cellId:e,mode:n}=t,o=mj(e);He.debug("Rendering Cell",e);const r=S.useRef(null);return S.useImperativeHandle(o,()=>({get editorView(){return(function(s){const a=s.current;if(a===null)throw new ReferenceError("Attempting to dereference null object.");return a})(r)},get editorViewOrNull(){return r.current}}),[r]),e===Pr?i.jsx(Yy,{...t,cellId:e,editorView:r,setEditorView:s=>{r.current=s}}):n==="edit"?i.jsx(Ky,{...t,cellId:e,editorView:r,setEditorView:s=>{r.current=s}}):i.jsx(zf,{cellId:e})}),Xy=(t,e)=>(function(n,o){const r=/^(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/,s=a=>{const l=a.match(r);if(!l)return null;const[,c,d,u,h]=l;return{major:Number.parseInt(c,10),minor:Number.parseInt(d,10),patch:Number.parseInt(u,10),preRelease:h||""}};try{const a=s(n),l=s(o);return a&&l?a.major!==l.major?a.major-l.major:a.minor!==l.minor?a.minor-l.minor:a.patch!==l.patch?a.patch-l.patch:a.preRelease===""&&l.preRelease!==""?1:a.preRelease!==""&&l.preRelease===""?-1:a.preRelease.localeCompare(l.preRelease):n.localeCompare(o,void 0,{numeric:!0,sensitivity:"base"})}catch{return n.localeCompare(o,void 0,{numeric:!0,sensitivity:"base"})}})(e,t),$f=new class{constructor(t){this.ttl=void 0,this.cache=new Map,this.ttl=t.ttl}cleanupExpiredEntries(){const t=Date.now();for(const[e,n]of this.cache.entries())t-n.timestamp>this.ttl&&this.cache.delete(e)}get(t){this.cleanupExpiredEntries();const e=this.cache.get(t);if(e){if(!(Date.now()-e.timestamp>this.ttl))return e.data;this.cache.delete(t)}}set(t,e){this.cache.set(t,{data:e,timestamp:Date.now()})}clear(){this.cache.clear()}}({ttl:3e5}),Qy=Be({info:Be({provides_extra:Me().array().nullable()}),releases:gj(Me(),bj())});function Vf(t){const e=P.c(5);let n;e[0]!==t?(n=t.replaceAll(/\[.*]/g,"").trim(),e[0]=t,e[1]=n):n=e[1];const o=n;let r,s;return e[2]!==o?(r=async()=>{const a=$f.get(o);if(a)return a;const l=await fetch(`https://pypi.org/pypi/${o}/json`,{method:"GET"});if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);const c=Qy.transform(Zy).parse(await l.json());return $f.set(o,c),c},s=[o],e[2]=o,e[3]=r,e[4]=s):(r=e[3],s=e[4]),wr(r,s)}function Zy(t){return{versions:Object.keys(t.releases).toSorted(Xy),extras:t.info.provides_extra??[]}}function Gf(t){const e=t.match(/^([^[]+)(?:\[([^\]]+)])?$/);if(!e)return{name:t,extras:[]};const[,n,o]=e;return{name:n,extras:o?o.split(",").map(r=>r.trim()):[]}}const ev=()=>{const t=P.c(69),{packageAlert:e,packageLogs:n}=rg(),{clearPackageAlert:o}=sg(),[r]=Qs();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={},t[0]=s):s=t[0];const[a,l]=S.useState(s);let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={},t[1]=c):c=t[1];const[d,u]=S.useState(c);if(e===null)return null;const h=r.package_management.manager!=="pixi";if(wC(e)){let m,p,b,x,f,g,y,w,j,C;if(t[2]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[i.jsx(Fa,{className:"w-5 h-5 inline-block mr-2"}),"Missing packages"]}),t[2]=m):m=t[2],t[3]!==o||t[4]!==e.id?(p=()=>o(e.id),t[3]=o,t[4]=e.id,t[5]=p):p=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(Vt,{className:"w-5 h-5"}),t[6]=b):b=t[6],t[7]!==p?(x=i.jsxs("div",{className:"flex justify-between",children:[m,i.jsx(ye,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:p,children:b})]}),t[7]=p,t[8]=x):x=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("p",{children:"The following packages were not found:"}),t[9]=f):f=t[9],t[10]!==a||t[11]!==h||t[12]!==e.packages||t[13]!==d){let N;t[15]!==a||t[16]!==h||t[17]!==d?(N=(k,E)=>{const _=Gf(k),I=d[k]||_.extras;return i.jsxs("tr",{className:"font-mono text-sm",children:[i.jsx("td",{className:"pr-2 py-1 align-middle",children:i.jsx(ja,{size:"1rem"})}),i.jsx("td",{className:"pr-2 py-1 align-middle",children:i.jsx(rv,{packageName:_.name,selectedExtras:I,onExtrasChange:A=>u(O=>({...O,[k]:A}))})}),h&&i.jsx("td",{className:"pr-2 py-1 align-middle",children:i.jsx(sv,{value:a[k]??"latest",onChange:A=>l(O=>({...O,[k]:A})),packageName:_.name})})]},E)},t[15]=a,t[16]=h,t[17]=d,t[18]=N):N=t[18],g=e.packages.map(N),t[10]=a,t[11]=h,t[12]=e.packages,t[13]=d,t[14]=g}else g=t[14];return t[19]!==g?(y=i.jsxs("div",{children:[f,i.jsx("table",{className:"list-disc ml-2 mt-1",children:g})]}),t[19]=g,t[20]=y):y=t[20],t[21]!==o||t[22]!==a||t[23]!==e.id||t[24]!==e.isolated||t[25]!==e.packages||t[26]!==d||t[27]!==r.package_management.manager?(w=i.jsx("div",{className:"ml-auto flex flex-row items-baseline",children:e.isolated?i.jsxs(i.Fragment,{children:[i.jsx(nv,{manager:r.package_management.manager,packages:e.packages.map(N=>{const k=Gf(N),E=d[N]||k.extras;return _=k.name,(I=E).length===0?_:`${_}[${I.join(",")}]`;var _,I}),versions:a,clearPackageAlert:()=>o(e.id)}),!Qt()&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"px-2 text-sm",children:"with"})," ",i.jsx(ov,{})]})]}):i.jsxs("p",{children:["If you set up a"," ",i.jsx(Rl,{href:"https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments",children:"virtual environment"}),", marimo can install these packages for you."]})}),t[21]=o,t[22]=a,t[23]=e.id,t[24]=e.isolated,t[25]=e.packages,t[26]=d,t[27]=r.package_management.manager,t[28]=w):w=t[28],t[29]!==y||t[30]!==w?(j=i.jsxs("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:[y,w]}),t[29]=y,t[30]=w,t[31]=j):j=t[31],t[32]!==j||t[33]!==x?(C=i.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-200 opacity-95 max-w-[600px]",children:i.jsxs(Lo,{kind:"danger",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left overflow-auto max-h-[80vh] scrollbar-thin",children:[x,j]})}),t[32]=j,t[33]=x,t[34]=C):C=t[34],C}if(kC(e)){let m;t[35]!==e.packages?(m=(function(R){const L=new Set(Object.values(R)),z=L.has("queued")||L.has("installing")?"installing":L.has("failed")?"failed":"installed";return z==="installing"?{status:"installing",title:"Installing packages",titleIcon:i.jsx($r,{className:"w-5 h-5 inline-block mr-2"}),description:"Installing packages:"}:z==="installed"?{status:"installed",title:"All packages installed!",titleIcon:i.jsx(cd,{className:"w-5 h-5 inline-block mr-2"}),description:"Installed packages:"}:{status:"failed",title:"Some packages failed to install",titleIcon:i.jsx(Fa,{className:"w-5 h-5 inline-block mr-2"}),description:"See error logs."}})(e.packages),t[35]=e.packages,t[36]=m):m=t[36];const{status:p,title:b,titleIcon:x,description:f}=m;p==="installed"&&setTimeout(()=>o(e.id),1e4);const g=p==="failed"?"danger":"info";let y,w,j,C,N;t[37]!==b||t[38]!==x?(y=i.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[x,b]}),t[37]=b,t[38]=x,t[39]=y):y=t[39],t[40]!==o||t[41]!==e.id?(w=()=>o(e.id),t[40]=o,t[41]=e.id,t[42]=w):w=t[42],t[43]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(Vt,{className:"w-5 h-5"}),t[43]=j):j=t[43],t[44]!==w?(C=i.jsx(ye,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:w,children:j}),t[44]=w,t[45]=C):C=t[45],t[46]!==y||t[47]!==C?(N=i.jsxs("div",{className:"flex justify-between",children:[y,C]}),t[46]=y,t[47]=C,t[48]=N):N=t[48];const k=p==="installed"&&"text-accent-foreground";let E,_,I,A,O,D,M;return t[49]!==k?(E=ue("flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",k),t[49]=k,t[50]=E):E=t[50],t[51]!==f?(_=i.jsx("p",{children:f}),t[51]=f,t[52]=_):_=t[52],t[53]!==e.packages?(I=Object.entries(e.packages),t[53]=e.packages,t[54]=I):I=t[54],t[55]!==p||t[56]!==I?(A=i.jsx("ul",{className:"list-disc ml-2 mt-1",children:I.map((R,L)=>{const[z,T]=R;return i.jsxs("li",{className:ue("flex items-center gap-1 font-mono text-sm",T==="installing"&&"font-semibold",T==="failed"&&"text-destructive",T==="installed"&&"text-accent-foreground",T==="installed"&&p==="failed"&&"text-muted-foreground"),children:[i.jsx(tv,{status:T}),z]},L)})}),t[55]=p,t[56]=I,t[57]=A):A=t[57],t[58]!==n?(O=Object.keys(n).length>0&&i.jsx(av,{packageLogs:n}),t[58]=n,t[59]=O):O=t[59],t[60]!==E||t[61]!==_||t[62]!==A||t[63]!==O?(D=i.jsxs("div",{className:E,children:[_,A,O]}),t[60]=E,t[61]=_,t[62]=A,t[63]=O,t[64]=D):D=t[64],t[65]!==D||t[66]!==g||t[67]!==N?(M=i.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-200 opacity-95 max-w-[600px] ",children:i.jsxs(Lo,{kind:g,className:"flex flex-col rounded pt-3 pb-4 px-5 overflow-auto max-h-[80vh] scrollbar-thin",children:[N,D]})}),t[65]=D,t[66]=g,t[67]=N,t[68]=M):M=t[68],M}return Fl(e),null},tv=t=>{const e=P.c(4),{status:n}=t;switch(n){case"queued":{let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(ja,{size:"1rem"}),e[0]=o):o=e[0],o}case"installing":{let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx($r,{size:"1rem"}),e[1]=o):o=e[1],o}case"installed":{let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(Wl,{size:"1rem"}),e[2]=o):o=e[2],o}case"failed":{let o;return e[3]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(Vt,{size:"1rem"}),e[3]=o):o=e[3],o}default:return Fl(n),null}},nv=t=>{const e=P.c(10),{manager:n,packages:o,versions:r,clearPackageAlert:s}=t,{sendInstallMissingPackages:a}=qe();let l,c,d,u;return e[0]!==s||e[1]!==n||e[2]!==o||e[3]!==a||e[4]!==r?(l=async()=>{s();const h={...r};for(const m of o)h[m]=h[m]??"";await a({manager:n,versions:h}).catch(iv)},e[0]=s,e[1]=n,e[2]=o,e[3]=a,e[4]=r,e[5]=l):l=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx($r,{className:"w-4 h-4 mr-2"}),d=i.jsx("span",{className:"font-semibold",children:"Install"}),e[6]=c,e[7]=d):(c=e[6],d=e[7]),e[8]!==l?(u=i.jsxs(ye,{variant:"outline","data-testid":"install-packages-button",size:"sm",onClick:l,children:[c,d]}),e[8]=l,e[9]=u):u=e[9],u},ov=()=>{const t=P.c(17),[e,n]=Qs(),{saveUserConfig:o}=qe();let r,s;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=Sp(xj),t[0]=r):r=t[0],t[1]!==e?(s={resolver:r,defaultValues:e},t[1]=e,t[2]=s):s=t[2];const a=Ep(s);let l;t[3]!==o||t[4]!==n?(l=async p=>{await o({config:p}).then(()=>{n(p)})},t[3]=o,t[4]=n,t[5]=l):l=t[5];const c=l;let d,u,h,m;return t[6]!==a||t[7]!==c?(d=a.handleSubmit(c),t[6]=a,t[7]=c,t[8]=d):d=t[8],t[9]!==a.control?(u=i.jsx("div",{className:"flex flex-col gap-3",children:i.jsx(vp,{control:a.control,name:"package_management.manager",render:cv})}),t[9]=a.control,t[10]=u):u=t[10],t[11]!==d||t[12]!==u?(h=i.jsx("form",{onChange:d,className:"flex flex-col gap-5",children:u}),t[11]=d,t[12]=u,t[13]=h):h=t[13],t[14]!==a||t[15]!==h?(m=i.jsx(yj,{...a,children:h}),t[14]=a,t[15]=h,t[16]=m):m=t[16],m},rv=t=>{const e=P.c(12),{packageName:n,selectedExtras:o,onExtrasChange:r}=t,[s,a]=S.useState(!1),{isPending:l,error:c,data:d}=Vf(n);let u;e[0]!==r||e[1]!==o?(u=(b,x)=>{r(x?[...o,b]:o.filter(f=>f!==b))},e[0]=r,e[1]=o,e[2]=u):u=e[2];const h=u,m=!l&&!c;let p;if(e[3]!==m||e[4]!==h||e[5]!==s||e[6]!==n||e[7]!==(d==null?void 0:d.extras)||e[8]!==o){const b=((d==null?void 0:d.extras)??[]).filter(dv);let x;e[10]!==n?(x=i.jsx("span",{className:"shrink-0 flex-1",children:n}),e[10]=n,e[11]=x):x=e[11],p=i.jsxs("div",{className:"flex items-center max-w-72",children:[x,o.length>0?i.jsxs("span",{className:"flex items-center min-w-0 flex-1",children:[i.jsx("span",{className:"shrink-0",children:"["}),i.jsxs(zn,{open:s&&m,onOpenChange:f=>{m&&a(f)},children:[i.jsx(Un,{asChild:!0,children:i.jsx("button",{className:"hover:bg-muted/50 rounded text-sm px-1 transition-colors border border-muted-foreground/30 hover:border-muted-foreground/60 min-w-0 flex-1 truncate text-left",title:`Selected extras: ${o.join(", ")}`,children:o.join(",")})}),i.jsxs(Wn,{align:"start",className:"w-64 p-0 max-h-96 flex flex-col",children:[o.length>0&&i.jsx("div",{className:"p-2 bg-popover border-b border-border",children:i.jsx("div",{className:"flex flex-wrap gap-1 p-1 min-h-[24px]",children:o.map(f=>i.jsxs("span",{className:"inline-flex items-center gap-1 px-1 py-0.5 text-sm font-mono border border-muted-foreground/30 hover:border-muted-foreground/60 rounded-sm cursor-pointer group transition-colors",onClick:()=>h(f,!1),children:[f,i.jsx(Vt,{className:"w-3 h-3 opacity-60 group-hover:opacity-100"})]},f))})}),i.jsx("div",{className:"overflow-y-auto flex-1",children:b.map(f=>i.jsx(z1,{checked:o.includes(f),onCheckedChange:g=>{h(f,g)},className:"font-mono text-sm",onSelect:uv,children:f},f))})]})]}),i.jsx("span",{className:"shrink-0",children:"]"})]}):b.length>0?i.jsxs(zn,{open:s&&m,onOpenChange:f=>{m&&a(f)},children:[i.jsx(Un,{asChild:!0,children:i.jsx("button",{disabled:!m,className:ue("hover:bg-muted/50 rounded text-sm ml-2 transition-colors border border-muted-foreground/30 hover:border-muted-foreground/60 h-5 w-5 flex items-center justify-center p-0",!m&&"opacity-50 cursor-not-allowed"),title:m?"Add extras":"Loading extras...",children:i.jsx(uc,{className:"w-3 h-3 shrink-0"})})}),i.jsxs(Wn,{align:"start",className:"w-64 p-0 max-h-96 flex flex-col",children:[i.jsx("div",{className:"p-2 bg-popover border-b border-border",children:i.jsx("span",{className:"text-muted-foreground italic text-sm",children:"Package extras"})}),i.jsx("div",{className:"overflow-y-auto flex-1",children:b.map(f=>i.jsx(z1,{checked:o.includes(f),onCheckedChange:g=>{h(f,g)},className:"font-mono text-sm",onSelect:hv,children:f},f))})]})]}):null]}),e[3]=m,e[4]=h,e[5]=s,e[6]=n,e[7]=d==null?void 0:d.extras,e[8]=o,e[9]=p}else p=e[9];return p},sv=t=>{const e=P.c(16),{value:n,onChange:o,packageName:r}=t,{error:s,isPending:a,data:l}=Vf(r);if(s){let h,m,p;return e[0]!==o?(h=b=>o(b.target.value),e[0]=o,e[1]=h):h=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx("option",{value:"latest",children:"latest"}),e[2]=m):m=e[2],e[3]!==h||e[4]!==n?(p=i.jsx(pe,{content:"Failed to fetch package versions",children:i.jsx(kc,{value:n,onChange:h,disabled:!0,className:"inline-flex ml-2 w-24 text-ellipsis",children:m})}),e[3]=h,e[4]=n,e[5]=p):p=e[5],p}let c,d,u;return e[6]!==o?(c=h=>o(h.target.value),e[6]=o,e[7]=c):c=e[7],e[8]!==a||e[9]!==l?(d=a?i.jsx("option",{value:"latest",children:"latest"}):["latest",...l.versions.slice(0,100)].map(mv),e[8]=a,e[9]=l,e[10]=d):d=e[10],e[11]!==a||e[12]!==c||e[13]!==d||e[14]!==n?(u=i.jsx(kc,{value:n,onChange:c,disabled:a,className:"inline-flex ml-2 w-24 text-ellipsis",children:d}),e[11]=a,e[12]=c,e[13]=d,e[14]=n,e[15]=u):u=e[15],u},av=t=>{const e=P.c(13),{packageLogs:n}=t,[o,r]=S.useState(!0);if(Object.keys(n).length===0)return null;let s,a,l,c,d;return e[0]!==o?(s=()=>r(!o),e[0]=o,e[1]=s):s=e[1],e[2]!==o?(a=o?i.jsx($n,{className:"w-4 h-4"}):i.jsx(fa,{className:"w-4 h-4"}),e[2]=o,e[3]=a):a=e[3],e[4]!==s||e[5]!==a?(l=i.jsxs("button",{onClick:s,className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",children:[a,"Installation logs"]}),e[4]=s,e[5]=a,e[6]=l):l=e[6],e[7]!==o||e[8]!==n?(c=o&&i.jsx("div",{className:"mt-3 space-y-3 w-full",children:Object.entries(n).map(fv)}),e[7]=o,e[8]=n,e[9]=c):c=e[9],e[10]!==l||e[11]!==c?(d=i.jsxs("div",{className:"mt-4 border-t border-border pt-4 w-full",children:[l,c]}),e[10]=l,e[11]=c,e[12]=d):d=e[12],d};function iv(t){He.error(t)}function lv(t){return i.jsx("option",{value:t,children:t},t)}function cv(t){const{field:e}=t;return i.jsxs(wp,{children:[i.jsx(kp,{children:i.jsx(kc,{"data-testid":"install-package-manager-select",onChange:n=>e.onChange(n.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:vj.map(lv)})}),i.jsx(Np,{})]})}function dv(t){return!/^(dev|test|testing)$/i.test(t)}function uv(t){return t.preventDefault()}function hv(t){return t.preventDefault()}function mv(t){return i.jsx("option",{value:t,children:t},t)}function fv(t){const[e,n]=t;return i.jsxs("div",{className:"w-full",children:[i.jsx("h4",{className:"font-mono text-sm font-medium mb-2 text-foreground",children:e}),i.jsx("div",{className:"border border-border rounded w-full",children:i.jsx("pre",{className:"p-3 text-xs font-mono bg-background max-h-64 overflow-y-auto text-muted-foreground whitespace-pre-wrap scrollbar-thin",children:n||"No logs available"})})]},e)}const pv=t=>{let{transform:e}=t;return{...e,x:0}},gv={threshold:{x:0,y:.1}},bv=me.memo(t=>{const e=P.c(23),{children:n,multiColumn:o}=t,{dropCellOverCell:r,dropCellOverColumn:s,moveColumn:a,compactColumns:l}=Ye(),[c,d]=S.useState(null),[u,h]=S.useState(null),[m]=wj();let p;e:{if(m.width==="columns"){p=kj.EMPTY;break e}let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M=[pv],e[0]=M):M=e[0],p=M}const b=p;let x,f;e[1]===Symbol.for("react.memo_cache_sentinel")?(x={activationConstraint:{distance:8}},e[1]=x):x=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(f={coordinateGetter:Cx},e[2]=f):f=e[2];const g=(function(){for(var M=arguments.length,R=new Array(M),L=0;L<M;L++)R[L]=arguments[L];return S.useMemo(()=>[...R].filter(z=>z!=null),[...R])})(gu(gi,x),gu(fi,f));let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=M=>{d(M.active.id);const R=Mt();h(R.cellIds)},e[3]=y):y=e[3];const w=Ce(y);let j;e[4]!==u?(j=()=>{d(null),h(null)},e[4]=u,e[5]=j):j=e[5];const C=Ce(j);let N;e[6]!==c?(N=M=>{const R=M.droppableContainers.filter(xv);if(c&&Co(c))return ci({...M,droppableContainers:R});const L=(W=>{let{droppableContainers:G,droppableRects:X,pointerCoordinates:H}=W;if(!H)return[];const Y=[];for(const K of G){const{id:V}=K,q=X.get(V);if(q&&Wb(H,q)){const U=ii(q).reduce((Q,ee)=>Q+si(H,ee),0),ne=Number((U/4).toFixed(4));Y.push({id:V,data:{droppableContainer:K,value:ne}})}}return Y.sort(ai)})({...M,droppableContainers:R}),z=li(L.length>0?L:xu({...M,droppableContainers:R}),"id");if(!z)return[];Zt(Co(z),`Expected column id. Got: ${z}`);const T=Mt().cellIds.get(z);if(Zt(T,`Expected column. Got: ${z}`),T&&T.topLevelIds.length===0)return[{id:z}];const F=new Set(T.topLevelIds),$=ci({...M,droppableContainers:M.droppableContainers.filter(W=>W.id!==z&&F.has(W.id))});if($.length>0){const W=$[0].id;return Zt(xl(W),`Expected cell id. Got: ${W}`),[{id:W}]}return[]},e[6]=c,e[7]=N):N=e[7];const k=N;let E;e[8]!==r||e[9]!==s||e[10]!==a?(E=M=>{const{active:R,over:L}=M,z=L==null?void 0:L.id;if(z!=null&&R.id!==z){if(xl(R.id)){if(Co(z))return void s({cellId:R.id,columnId:z});if(xl(z))return void r({cellId:R.id,overCellId:z})}Co(R.id)&&Co(z)&&a({column:R.id,overColumn:z})}},e[8]=r,e[9]=s,e[10]=a,e[11]=E):E=e[11];const _=Ce(E);let I;e[12]!==l?(I=M=>{const{active:R,over:L}=M;L!==null&&R.id!==L.id&&l()},e[12]=l,e[13]=I):I=e[13];const A=Ce(I),O=o?k:ci;let D;return e[14]!==n||e[15]!==C||e[16]!==A||e[17]!==_||e[18]!==w||e[19]!==b||e[20]!==g||e[21]!==O?(D=i.jsx(ux,{autoScroll:gv,sensors:g,collisionDetection:O,modifiers:b,onDragEnd:A,onDragStart:w,onDragCancel:C,onDragOver:_,children:n}),e[14]=n,e[15]=C,e[16]=A,e[17]=_,e[18]=w,e[19]=b,e[20]=g,e[21]=O,e[22]=D):D=e[22],D});function xl(t){return typeof t=="string"&&!t.startsWith("tree_")}function Co(t){return typeof t=="string"&&t.startsWith("tree_")}function xv(t){return Co(t.id)}const yv=t=>{const e=P.c(13),{className:n,size:o,gap:r,durationMs:s}=t,a=o===void 0?8:o,l=r===void 0?"gap-1":r,c=s===void 0?1200:s,d=`${c}ms`;let u;e[0]!==d?(u={animationDuration:d},e[0]=d,e[1]=u):u=e[1];const h=u;let m,p,b,x;return e[2]!==n||e[3]!==l?(m=xa("flex",l,n),e[2]=n,e[3]=l,e[4]=m):m=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(p=[0,1,2],e[5]=p):p=e[5],e[6]!==h||e[7]!==c||e[8]!==a?(b=p.map(f=>i.jsx(jj,{width:a,height:a,className:"fill-current text-current animate-ellipsis-dot",style:{...h,animationDelay:c/3*f+"ms"}},f)),e[6]=h,e[7]=c,e[8]=a,e[9]=b):b=e[9],e[10]!==m||e[11]!==b?(x=i.jsx("div",{className:m,"aria-label":"Loading",children:b}),e[10]=m,e[11]=b,e[12]=x):x=e[12],x},qf=t=>{const e=P.c(11),{title:n,children:o,show:r,delayMs:s,kind:a}=t,l=s===void 0?2e3:s,c=a===void 0?"info":a;if(!r)return null;let d,u,h;e[0]!==n?(d=n&&i.jsx("div",{className:"flex justify-between",children:i.jsx("span",{className:"font-bold text-lg flex items-center mb-1",children:n})}),e[0]=n,e[1]=d):d=e[1],e[2]!==o?(u=i.jsx("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:i.jsx("div",{children:o})}),e[2]=o,e[3]=u):u=e[3],e[4]!==c||e[5]!==d||e[6]!==u?(h=i.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-1/2 transform -translate-x-1/2 z-200 opacity-95",children:i.jsxs(Lo,{kind:c,className:"flex flex-col rounded py-2 px-4 animate-in slide-in-from-top w-fit",children:[d,u]})}),e[4]=c,e[5]=d,e[6]=u,e[7]=h):h=e[7];const m=h;let p;return e[8]!==m||e[9]!==l?(p=i.jsx(ba,{milliseconds:l,children:m}),e[8]=m,e[9]=l,e[10]=p):p=e[10],p},vv=()=>{const t=P.c(3),e=ie(Cj),n=ie(Nj);let o;return t[0]!==n||t[1]!==e?(o=e&&i.jsxs(i.Fragment,{children:[i.jsx(ba,{milliseconds:1e3,children:i.jsx("div",{className:"absolute top-4 m-0 flex items-center min-h-[28px] left-1/2 transform -translate-x-1/2 z-200 ",children:i.jsx(pe,{content:"Connecting to a marimo runtime",children:i.jsx("div",{className:"flex items-center",children:i.jsx(yv,{size:5,className:"text-yellow-500"})})})})}),i.jsx(qf,{show:e,delayMs:5e3,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ya,{className:"h-4 w-4"}),i.jsx("p",{children:"Connecting to a marimo runtime ..."})]})})]})||n&&i.jsx(qf,{show:n,kind:"danger",children:i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("p",{children:"Failed to connect."})})}),t[0]=n,t[1]=e,t[2]=o):o=t[2],o},Hf=me.forwardRef((t,e)=>{const n=P.c(60),{columnId:o,canDelete:r,canMoveLeft:s,canMoveRight:a,footer:l,...c}=t;let d;n[0]!==o?(d={id:o},n[0]=o,n[1]=d):d=n[1];const{attributes:u,listeners:h,setNodeRef:m,transform:p,transition:b,isDragging:x,isOver:f}=Hu(d);let g;n[2]!==p?(g=p?ca.Transform.toString({x:p.x,y:0,scaleX:1,scaleY:1}):void 0,n[2]=p,n[3]=g):g=n[3];const y=x?2:void 0;let w;n[4]!==g||n[5]!==y||n[6]!==b?(w={transform:g,transition:b,zIndex:y,position:"relative","--gutter-width":"50px"},n[4]=g,n[5]=y,n[6]=b,n[7]=w):w=n[7];const j=w,{deleteColumn:C,moveColumn:N,addColumn:k}=Ye(),E=kv;let _;n[8]!==o||n[9]!==N?(_=()=>N({column:o,overColumn:"_left_"}),n[8]=o,n[9]=N,n[10]=_):_=n[10];const I=!s;let A,O,D;n[11]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsx(g1,{className:"size-4"}),n[11]=A):A=n[11],n[12]!==_||n[13]!==I?(O=i.jsx(pe,{content:"Move column left",side:"top",delayDuration:300,children:i.jsx(ye,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",onClick:_,disabled:I,children:A})}),n[12]=_,n[13]=I,n[14]=O):O=n[14],n[15]!==o||n[16]!==N?(D=()=>N({column:o,overColumn:"_right_"}),n[15]=o,n[16]=N,n[17]=D):D=n[17];const M=!a;let R,L,z,T,F,$;n[18]===Symbol.for("react.memo_cache_sentinel")?(R=i.jsx(fa,{className:"size-4"}),n[18]=R):R=n[18],n[19]!==M||n[20]!==D?(L=i.jsx(pe,{content:"Move column right",side:"top",delayDuration:300,children:i.jsx(ye,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",onClick:D,disabled:M,children:R})}),n[19]=M,n[20]=D,n[21]=L):L=n[21],n[22]===Symbol.for("react.memo_cache_sentinel")?(z=i.jsx(Sj,{className:"size-4 opacity-0 group-hover:opacity-50 transition-opacity duration-200"}),n[22]=z):z=n[22],n[23]!==u||n[24]!==h?(T=i.jsx("div",{className:"flex gap-2 h-full grow cursor-grab active:cursor-grabbing items-center justify-center","data-testid":"column-drag-spacer",...u,...h,children:z}),n[23]=u,n[24]=h,n[25]=T):T=n[25],n[26]===Symbol.for("react.memo_cache_sentinel")?(F=i.jsx(Un,{asChild:!0,children:i.jsx(ye,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",children:i.jsx(Ca,{className:"size-4"})})}),n[26]=F):F=n[26],n[27]!==o||n[28]!==C?($=()=>C({columnId:o}),n[27]=o,n[28]=C,n[29]=$):$=n[29];const W=!r;let G,X,H,Y,K,V;n[30]===Symbol.for("react.memo_cache_sentinel")?(G=i.jsx(Vt,{className:"mr-2 size-4"}),n[30]=G):G=n[30],n[31]!==$||n[32]!==W?(X=i.jsxs(zn,{children:[F,i.jsx(Wn,{align:"end",children:i.jsxs(lo,{onClick:$,disabled:W,children:[G,"Delete column"]})})]}),n[31]=$,n[32]=W,n[33]=X):X=n[33],n[34]!==k||n[35]!==o?(H=()=>{k({columnId:o}),requestAnimationFrame(E)},n[34]=k,n[35]=o,n[36]=H):H=n[36],n[37]===Symbol.for("react.memo_cache_sentinel")?(Y=i.jsx(uc,{className:"size-4"}),n[37]=Y):Y=n[37],n[38]!==H?(K=i.jsx(pe,{content:"Add column",side:"top",delayDuration:300,children:i.jsx(ye,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",onClick:H,children:Y})}),n[38]=H,n[39]=K):K=n[39],n[40]!==L||n[41]!==T||n[42]!==X||n[43]!==K||n[44]!==O?(V=i.jsxs("div",{className:"px-2 pt-3 pb-0 group flex items-center rounded-t-lg overflow-hidden",children:[O,L,T,X,K]}),n[40]=L,n[41]=T,n[42]=X,n[43]=K,n[44]=O,n[45]=V):V=n[45];const q=V;let U;n[46]!==e||n[47]!==m?(U=oe=>{Ls(e,m)(oe)},n[46]=e,n[47]=m,n[48]=U):U=n[48];const ne=ue(x?"":c.className,x?"z-20":"z-1 hover:z-10 focus-within:z-10",f&&"bg-accent/20");let Q,ee;return n[49]!==q||n[50]!==c.children?(Q=i.jsxs("div",{className:"bg-(--slate-1) rounded-lg",children:[q,c.children]}),n[49]=q,n[50]=c.children,n[51]=Q):Q=n[51],n[52]!==l||n[53]!==x||n[54]!==c||n[55]!==j||n[56]!==U||n[57]!==ne||n[58]!==Q?(ee=i.jsxs("div",{tabIndex:-1,ref:U,...c,style:j,"data-is-dragging":x,className:ne,children:[Q,l]}),n[52]=l,n[53]=x,n[54]=c,n[55]=j,n[56]=U,n[57]=ne,n[58]=Q,n[59]=ee):ee=n[59],ee});Hf.displayName="SortableColumn";const wv=S.memo(Hf);function kv(){const t=document.getElementById("App");t&&t.scrollTo({left:t.scrollLeft+1e3,behavior:"smooth"})}const{getColumnWidth:jv,saveColumnWidth:Cv}=Ej,Jf=S.memo(t=>{const e=P.c(20),n=S.useRef(null);if(t.width==="columns"){const s=t.canDelete,a=t.columnId,l=t.canMoveLeft,c=t.canMoveRight,d=t.footer;let u,h,m,p;return e[0]!==t.index?(u=jv(t.index),e[0]=t.index,e[1]=u):u=e[1],e[2]!==t.index?(h=b=>{Cv(t.index,b)},e[2]=t.index,e[3]=h):h=e[3],e[4]!==t.children||e[5]!==u||e[6]!==h?(m=i.jsx(Nv,{startingWidth:u,onResize:h,children:t.children}),e[4]=t.children,e[5]=u,e[6]=h,e[7]=m):m=e[7],e[8]!==t.canDelete||e[9]!==t.canMoveLeft||e[10]!==t.canMoveRight||e[11]!==t.columnId||e[12]!==t.footer||e[13]!==m?(p=i.jsx(wv,{tabIndex:-1,ref:n,canDelete:s,columnId:a,canMoveLeft:l,canMoveRight:c,className:"group/column",footer:d,children:m}),e[8]=t.canDelete,e[9]=t.canMoveLeft,e[10]=t.canMoveRight,e[11]=t.columnId,e[12]=t.footer,e[13]=m,e[14]=p):p=e[14],p}let o,r;return e[15]!==t.children?(o=i.jsx("div",{"data-testid":"cell-column",className:"flex flex-col gap-5",children:t.children}),e[15]=t.children,e[16]=o):o=e[16],e[17]!==t.footer||e[18]!==o?(r=i.jsxs(i.Fragment,{children:[o,t.footer]}),e[17]=t.footer,e[18]=o,e[19]=r):r=e[19],r});Jf.displayName="Column";const Nv=t=>{const e=P.c(15),{startingWidth:n,onResize:o,children:r}=t;let s;e[0]!==o||e[1]!==n?(s={startingWidth:n,onResize:o},e[0]=o,e[1]=n,e[2]=s):s=e[2];const{resizableDivRef:a,handleRefs:l,style:c}=_j(s),d=Sv;let u,h,m,p;return e[3]!==l.left?(u=d(l.left),e[3]=l.left,e[4]=u):u=e[4],e[5]!==r||e[6]!==a||e[7]!==c?(h=i.jsx("div",{ref:a,className:"flex flex-col gap-5 box-content min-h-[100px] px-11 pt-3 pb-6 min-w-[500px] z-1",style:c,children:r}),e[5]=r,e[6]=a,e[7]=c,e[8]=h):h=e[8],e[9]!==l.right?(m=d(l.right),e[9]=l.right,e[10]=m):m=e[10],e[11]!==u||e[12]!==h||e[13]!==m?(p=i.jsxs("div",{className:"flex flex-row",children:[u,h,m]}),e[11]=u,e[12]=h,e[13]=m,e[14]=p):p=e[14],p};function Sv(t){return i.jsx("div",{ref:t,className:`w-[3px] cursor-col-resize transition-colors duration-200 z-100
134
+ `);await navigator.clipboard.writeText(F),jf(P.length)}catch{Iy()}}}),pasteAtCell:Ce(async(R,L)=>{const{before:P=!1}=L??{};try{const T=await navigator.clipboard.read();for(const $ of T)if($.types.includes(ml)){const W=await $.getType(ml),H=await W.text();try{const X=_y.parse(JSON.parse(H));if(X.cells.length===0)break;const q=R,Y=X.cells.reverse();for(const J of Y)M.createNewCell({cellId:q,before:P,code:J.code,autoFocus:!0});return}catch(X){Ye.warn("Failed to parse clipboard cell data",X)}}const F=await navigator.clipboard.readText();F.trim()?M.createNewCell({cellId:R,before:P,code:F,autoFocus:!0}):Ay()}catch(T){Ye.error("Failed to paste from clipboard",T),Ty()}})}})(),f=ns(),g=(function(M){const R=z.c(2);let L;return R[0]!==M?(L=Qt(P=>P(ri).selected.has(M)),R[0]=M,R[1]=L):L=R[1],ie(L)})(t),y=Ko(),w=Cr(),j=ie(ra);let C;n[0]!==y||n[1]!==f?(C={clear:()=>{y.clear(),f.clear()},extend:M=>{y.clear(),f.extend(M)},select:M=>{y.clear(),f.select(M)}},n[0]=y,n[1]=f,n[2]=C):C=n[2];const N=C,k=ie(Gl);let E;n[3]!==k?(E=(M,R)=>yc(k.getHotkey(M).key)(R.nativeEvent||R),n[3]=k,n[4]=E):E=n[4];const _=E,I=(function(M){const R=z.c(11),L=S1(),P=Ke(),T=Ws();let F,$,W;R[0]!==M||R[1]!==L?(F=()=>{L.focusCell({cellId:M})},R[0]=M,R[1]=L,R[2]=F):F=R[2],R[3]!==P||R[4]!==M||R[5]!==L||R[6]!==T?($=()=>{T.remove(M),P.markTouched({cellId:M}),L.blurCell()},R[3]=P,R[4]=M,R[5]=L,R[6]=T,R[7]=$):$=R[7],R[8]!==F||R[9]!==$?(W={onFocusWithin:F,onBlurWithin:$},R[8]=F,R[9]=$,R[10]=W):W=R[10];const{focusWithinProps:H}=ej(W);return H})(t);let A;n[5]!==d||n[6]!==o||n[7]!==s||n[8]!==t||n[9]!==b||n[10]!==w||n[11]!==r||n[12]!==g||n[13]!==_||n[14]!==p||n[15]!==x||n[16]!==y||n[17]!==m||n[18]!==l||n[19]!==a||n[20]!==N||n[21]!==c||n[22]!==u||n[23]!==h||n[24]!==j?(A={onKeyDown:M=>{if(Bn.fromInput(M))return void M.continuePropagation();const R={"Mod+ArrowUp":()=>(d.focusTopCell(),N.clear(),!0),"Mod+ArrowDown":()=>(d.focusBottomCell(),N.clear(),!0),ArrowUp:()=>(d.focusCell({cellId:t,where:"before"}),N.clear(),!0),ArrowDown:()=>(d.focusCell({cellId:t,where:"after"}),N.clear(),!0),ArrowLeft:()=>{if(o){const T=u.get(Vt),F=T.cellIds.findWithId(t),$=T.cellIds.indexOf(F),W=T.cellIds.at($-1);if(W&&W.length>0){const H=Sf(t,W);return d.focusCell({cellId:H,where:"exact"}),N.clear(),!0}}return!1},ArrowRight:()=>{if(o){const T=u.get(Vt),F=T.cellIds.findWithId(t),$=T.cellIds.indexOf(F),W=T.cellIds.at($+1);if(W&&W.length>0){const H=Sf(t,W);return d.focusCell({cellId:H,where:"exact"}),N.clear(),!0}}return!1},"Shift+ArrowUp":()=>{const T=u.get(ga);N.extend({cellId:t,allCellIds:T});const F=T.findWithId(t).before(t);return F&&N.extend({cellId:F,allCellIds:T}),d.focusCell({cellId:t,where:"before"}),!0},"Shift+ArrowDown":()=>{const T=u.get(ga);N.extend({cellId:t,allCellIds:T});const F=T.findWithId(t).after(t);return F&&N.extend({cellId:F,allCellIds:T}),d.focusCell({cellId:t,where:"after"}),!0},Escape:()=>!!g&&(N.clear(),!0),Enter:()=>(h.add(t),_1(u,t),N.clear(),!0),s:()=>(a(),!0)};for(const[T,F]of Object.entries(R))if(yc(T)(M)&&F())return void M.preventDefault();const L={"cell.run":sn(T=>(m(T),!0)),"cell.runAndNewBelow":sn(T=>{m(T);const F=T[T.length-1];return d.moveToNextCell({cellId:F,before:!1}),!0}),"cell.runAndNewAbove":sn(T=>{m(T);const F=T[0];return d.moveToNextCell({cellId:F,before:!0}),!0}),"cell.createAbove":T=>(d.createNewCell({cellId:T,before:!0}),!0),"cell.createBelow":T=>(d.createNewCell({cellId:T,before:!1}),!0),"cell.moveUp":sn(T=>{const F=T[0];return u.get(Vt).cellIds.findWithId(F).first()!==F&&(T.forEach($=>{d.moveCell({cellId:$,before:!0})}),!0)}),"cell.moveDown":sn(T=>{const F=T[T.length-1];return u.get(Vt).cellIds.findWithId(F).last()!==F&&([...T].reverse().forEach($=>{d.moveCell({cellId:$,before:!1})}),!0)}),"cell.moveLeft":Cf(T=>!!o&&(d.moveCell({cellId:T,direction:"left"}),!0)),"cell.moveRight":Cf(T=>!!o&&(d.moveCell({cellId:T,direction:"right"}),!0)),"cell.hideCode":sn(T=>{var $;const F=!T.map(W=>{var X;return((X=u.get(Vt).cellData[W])==null?void 0:X.config)||null}).every(Ry);l({configs:Object.fromEntries(T.map(W=>[W,{hide_code:F}]))});for(const W of T)d.updateCellConfig({cellId:W,config:{hide_code:F}});if(T.length===1){const W=T[0];d.focusCell({cellId:W,where:"after"}),F?(($=r.current)==null||$.contentDOM.blur(),E1(W)):_1(u,W)}return!0}),"cell.focusDown":T=>(d.focusCell({cellId:T,where:"after"}),!0),"cell.focusUp":T=>(d.focusCell({cellId:T,where:"before"}),!0),"cell.sendToBottom":sn(T=>(T.forEach(F=>{d.sendToBottom({cellId:F})}),!0)),"cell.sendToTop":sn(T=>([...T].reverse().forEach(F=>{d.sendToTop({cellId:F})}),!0)),"cell.aiCompletion":T=>{var $;let F=!1;return c(W=>(W==null?void 0:W.cellId)===T?(F=!0,null):{cellId:T}),F&&(($=r.current)==null||$.focus()),!0},"cell.cellActions":()=>{var T;return(T=s.current)==null||T.toggle(),!0},"command.copyCell":sn(T=>(b(T),!0)),"command.pasteCell":T=>(x(T),!0),"command.createCellBefore":T=>!Bn.hasModifier(M)&&(d.createNewCell({cellId:T,before:!0,autoFocus:!0}),!0),"command.createCellAfter":T=>!Bn.hasModifier(M)&&(d.createNewCell({cellId:T,before:!1,autoFocus:!0}),!0),"cell.delete":()=>{if(!j.keymap.destructive_delete)return!1;const T=P.size>=2?[...P]:[t],F=u.get(Vt);return!T.some($=>{const{status:W}=F.cellRuntime[$];return W==="running"||W==="queued"})&&(y.idle?(y.submit(T),!0):(w({cellIds:T}),y.clear(),!0))}},P=(function(T){return T.get(ri).selected})(u);if(p==="vim"&&(function(T,F){const $=(function(Y){if(Y.ctrlKey||Y.metaKey||Y.altKey)return"";const J=Y.key.toLowerCase();return Y.shiftKey?`shift+${J}`:J})(T),W=T.target;if(!$||!W)return!1;const H=br.get(W);let X=$;H!=null&&H.timeout&&clearTimeout(H.timeout),H&&(X=`${H.sequence} ${$}`);const q=F[X];if(q)return br.delete(W),q();if(!H){const Y=F[$];if(Y)return Y()}if(Object.keys(F).some(Y=>Y.startsWith(`${X} `))){const Y=window.setTimeout(()=>{br.delete(W)},500);return br.set(W,{sequence:X,timeout:Y}),!0}return br.delete(W),!1})(M.nativeEvent||M,{j:R.ArrowDown,k:R.ArrowUp,h:R.ArrowLeft,l:R.ArrowRight,i:R.Enter,"shift+j":R["Shift+ArrowDown"],"shift+k":R["Shift+ArrowUp"],"g g":R["Mod+ArrowUp"],"shift+g":R["Mod+ArrowDown"],"d d":()=>L["cell.delete"](),"y y":()=>(b(P.size>=2?[...P]:[t]),!0),p:()=>(x(t,{before:!1}),!0),"shift+p":()=>(x(t,{before:!0}),!0),o:()=>(d.createNewCell({cellId:t,before:!1,autoFocus:!0}),!0),"shift+o":()=>(d.createNewCell({cellId:t,before:!0,autoFocus:!0}),!0),u:()=>(d.undoDeleteCell(),!0)}))M.preventDefault();else{for(const[T,F]of Object.entries(L))if(_(T,M)){if(F instanceof Function){if(F(t))return void M.preventDefault()}else if(P.size>=2?F.bulkHandle([...P]):F.handle(t))return void M.preventDefault();return}M.continuePropagation()}}},n[5]=d,n[6]=o,n[7]=s,n[8]=t,n[9]=b,n[10]=w,n[11]=r,n[12]=g,n[13]=_,n[14]=p,n[15]=x,n[16]=y,n[17]=m,n[18]=l,n[19]=a,n[20]=N,n[21]=c,n[22]=u,n[23]=h,n[24]=j,n[25]=A):A=n[25];const{keyboardProps:O}=N1(A);let D;return n[26]!==I||n[27]!==g||n[28]!==O?(D=Nl(I,O,{"data-selected":g,className:"data-[selected=true]:ring-1 data-[selected=true]:ring-(--blue-8) data-[selected=true]:ring-offset-1"}),n[26]=I,n[27]=g,n[28]=O,n[29]=D):D=n[29],D}function Ry(t){return t==null?void 0:t.hide_code}function Sf(t,e){const n=document.getElementById(Js.create(t));if(!n)return e.first();const o=n.getBoundingClientRect();for(const r of e.topLevelIds){const s=document.getElementById(Js.create(r));if(s){const a=s.getBoundingClientRect();if(o.top<=a.bottom&&o.bottom>=a.top)return r}}return e.last()}const Ly=t=>{const e=z.c(24),{editorView:n,code:o,currentLanguageAdapter:r,onAfterToggle:s}=t;let a;e[0]!==o?(a=Bo.markdown.isSupported(o)||o.trim()==="",e[0]=o,e[1]=a):a=e[1];const l=a;let c;e[2]!==o?(c=Bo.sql.isSupported(o)||o.trim()==="",e[2]=o,e[3]=c):c=e[3];const d=c&&r==="python";let u,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(_o,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),e[4]=u):u=e[4],e[5]!==r||e[6]!==n||e[7]!==s||e[8]!==d?(h=i.jsx(fl,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:d,icon:u,toType:"sql",displayName:"SQL",onAfterToggle:s}),e[5]=r,e[6]=n,e[7]=s,e[8]=d,e[9]=h):h=e[9];const m=l&&r==="python";let p,b,x,f,g;return e[10]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Zs,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),e[10]=p):p=e[10],e[11]!==r||e[12]!==n||e[13]!==s||e[14]!==m?(b=i.jsx(fl,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:m,icon:p,toType:"markdown",displayName:"Markdown",onAfterToggle:s}),e[11]=r,e[12]=n,e[13]=s,e[14]=m,e[15]=b):b=e[15],e[16]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(hc,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),e[16]=x):x=e[16],e[17]!==r||e[18]!==n?(f=i.jsx(fl,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:!0,icon:x,toType:"python",displayName:"Python",onAfterToggle:Pn.NOOP}),e[17]=r,e[18]=n,e[19]=f):f=e[19],e[20]!==f||e[21]!==h||e[22]!==b?(g=i.jsxs("div",{className:"absolute right-3 top-2 z-20 flex hover-action gap-1",children:[h,b,f]}),e[20]=f,e[21]=h,e[22]=b,e[23]=g):g=e[23],g},fl=t=>{const e=z.c(10),{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:r,icon:s,toType:a,displayName:l,onAfterToggle:c}=t;let d;e[0]!==n||e[1]!==c||e[2]!==a?(d=()=>{n&&(co(n,{language:a}),c())},e[0]=n,e[1]=c,e[2]=a,e[3]=d):d=e[3];const u=d;if(!r||o===a)return null;const h=`View as ${l}`;let m,p;return e[4]!==u||e[5]!==s?(m=i.jsx(ye,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:u,children:s}),e[4]=u,e[5]=s,e[6]=m):m=e[6],e[7]!==h||e[8]!==m?(p=i.jsx(pe,{content:h,children:m}),e[7]=h,e[8]=m,e[9]=p):p=e[9],p},Ef=({theme:t,showPlaceholder:e,id:n,config:o,code:r,status:s,serializedEditorState:a,setEditorView:l,runCell:c,userConfig:d,editorViewRef:u,editorViewParentRef:h,hidden:m,hasOutput:p,showHiddenCode:b,languageAdapter:x,setLanguageAdapter:f,showLanguageToggles:g=!0})=>{var J;const[y,w]=_n(Or),j=jr(),{saveOrNameNotebook:C}=ni(),N=Ko(),{saveCellConfig:k}=qe(),E=s==="running"||s==="queued",_=Ke(),I=Dm(),A=x==="markdown",O=Ce(()=>!E&&(N.idle&&d.keymap.destructive_delete?(N.submit([n]),!0):(j({cellId:n}),!0))),D=Ce(()=>!E&&(c(),!0)),M=Ce(()=>{const V=!o.hide_code;return k({configs:{[n]:{hide_code:V}}}),_.updateCellConfig({cellId:n,config:{hide_code:V}}),V}),R=ie(m1),L=Ce(()=>{qn({autoInstantiate:R,createNewCell:_.createNewCell})}),P=tj(d),T=S.useMemo(()=>{const V=I2({cellId:n,showPlaceholder:e,enableAI:P,cellActions:{..._,afterToggleMarkdown:L,onRun:D,deleteCell:O,saveNotebook:C,createManyBelow:G=>{for(const U of[...G].reverse())_.createNewCell({code:U,before:!1,cellId:n,skipIfCodeExists:!0})},splitCell:I,toggleHideCode:M,aiCellCompletion:()=>{let G=!1;return w(U=>(U==null?void 0:U.cellId)===n?(G=!0,null):{cellId:n}),G}},completionConfig:d.completion,keymapConfig:d.keymap,lspConfig:d.language_servers,theme:t,hotkeys:new I1(d.keymap.overrides??{}),diagnosticsConfig:d.diagnostics,displayConfig:d.display});return V.push(Ut.define(G=>{const U=G.state.field(ha);return f(U.type),{update(ne){const Q=ne.state.field(ha);f(Q.type)}}}),Se.updateListener.of(G=>{G.selectionSet&&G.state.selection.ranges.some(U=>U.from!==U.to)&&b({focus:!1})}),Se.domEventHandlers({focus:()=>{b({focus:!1})}})),V},[n,d.keymap,d.completion,d.language_servers,d.display,d.diagnostics,P,t,e,_,I,M,O,D,w,L,f,b,C]),F=pa(),$=Ce(()=>{if(F){const G=nl(n,0,r);T.push(G.extension),r=G.code}const V=new Se({state:Dr.create({doc:r,extensions:T})});l(V),F||co(V,{language:bc(V.state).type})}),W=Ce(()=>{if(Zt(u.current!==null,"Editor view is not initialized"),F){const V=nl(n);T.push(V.extension)}u.current.dispatch({effects:[nt.reconfigure.of([T]),nj(u.current,{completionConfig:d.completion,hotkeysProvider:new I1(d.keymap.overrides??{}),lspConfig:{...d.language_servers,diagnostics:d.diagnostics}})]})}),H=Ce(()=>{if(Zt(a,"Editor view is not initialized"),F){const G=nl(n,0,r);T.push(G.extension),r=G.code}const V=new Se({state:Dr.fromJSON(a,{doc:r,extensions:T},{history:oj})});F||co(V,{language:bc(V.state).type}),l(V),_.clearSerializedEditorState({cellId:n})});S.useEffect(()=>{a===null?u.current===null?$():W():H(),u.current!==null&&h&&h.current!==null&&h.current.replaceChildren(u.current.dom)},[$,W,H,u,h,a,T]),S.useEffect(()=>{const V=u.current;return()=>{V==null||V.destroy()}},[u]);const X=(function(V,G){const U=z.c(12),ne=Ws(),Q=ie(C1),ee=ie(Gl);let te;if(U[0]!==ee){const fe=ee.getHotkey("command.vimEnterCommandMode");te=yc(fe.key),U[0]=ee,U[1]=te}else te=U[1];const se=te;let ae;U[2]!==V||U[3]!==ne?(ae=()=>{ne.remove(V),E1(V)},U[2]=V,U[3]=ne,U[4]=ae):ae=U[4];const oe=ae;let Ee;U[5]!==G||U[6]!==oe?(Ee=()=>{if(!G.current)return void oe();const fe=G.current,Ie=fe.state;Ie.selection.main.empty?Fo(Ie)!==null?El(fe):oe():fe.dispatch({selection:Kt.single(Ie.selection.main.from)})},U[5]=G,U[6]=oe,U[7]=Ee):Ee=U[7];const ve=Ee;let ge;U[8]!==ve||U[9]!==Q||U[10]!==se?(ge={onKeyDown:fe=>{Q==="vim"?se(fe)&&ve():fe.key==="Escape"&&ve(),fe.continuePropagation()}},U[8]=ve,U[9]=Q,U[10]=se,U[11]=ge):ge=U[11];const{keyboardProps:ke}=N1(ge);return ke})(n,u),q=m&&!A||m&&A&&!p;let Y="";return A&&m&&p?Y="h-0 overflow-hidden":m&&(Y="opacity-20 h-8 [&>div.cm-editor]:h-full [&>div.cm-editor]:overflow-hidden [&_.cm-panels]:hidden"),i.jsx(Sy,{enabled:(y==null?void 0:y.cellId)===n,initialPrompt:y==null?void 0:y.initialPrompt,currentCode:((J=u.current)==null?void 0:J.state.doc.toString())??r,currentLanguageAdapter:x,declineChange:Ce(()=>{var V;w(null),(V=u.current)==null||V.focus()}),onChange:Ce(V=>{var G;(G=u.current)==null||G.dispatch({changes:{from:0,to:u.current.state.doc.length,insert:V}})}),acceptChange:Ce(V=>{var G,U;(G=u.current)==null||G.dispatch({changes:{from:0,to:u.current.state.doc.length,insert:V}}),(U=u.current)==null||U.focus(),w(null)}),children:i.jsxs("div",{className:"relative w-full",...X,children:[q&&i.jsx(A1,{tooltip:"Edit code",className:"absolute inset-0 z-10",onClick:b}),i.jsx(_f,{className:Y,editorView:u.current,ref:h}),!m&&g&&i.jsx("div",{className:"absolute top-1 right-5",children:i.jsx(Ly,{code:r,editorView:u.current,currentLanguageAdapter:x,onAfterToggle:L})})]})})},_f=he.forwardRef((t,e)=>{const n=z.c(10),{className:o,editorView:r}=t,s=S.useRef(null);let a,l,c,d,u;return n[0]!==r?(a=()=>{r!==null&&s.current!==null&&s.current.children.length===0&&s.current.append(r.dom)},l=[r,s],n[0]=r,n[1]=a,n[2]=l):(a=n[1],l=n[2]),S.useEffect(a,l),n[3]!==o?(c=de("cm mathjax_ignore",o),n[3]=o,n[4]=c):c=n[4],n[5]!==e?(d=h=>{e?Ls(e,s)(h):Ls(s)(h)},n[5]=e,n[6]=d):d=n[6],n[7]!==c||n[8]!==d?(u=i.jsx("div",{className:c,ref:d,"data-testid":"cell-editor"}),n[7]=c,n[8]=d,n[9]=u):u=n[9],u});_f.displayName="CellCodeMirrorEditor";let If,Af,Tf,pl;Ia=pa()?(function(t){const e=n=>{const o=z.c(5),r=ie(Nt),[s,a]=_n(yo);if(r.state===mt.CONNECTING||s===void 0){let c,d;return o[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{children:"Waiting for real-time collaboration connection..."}),o[0]=c):c=o[0],o[1]!==a?(d=i.jsx("div",{className:"flex h-full w-full items-baseline p-4",children:i.jsxs(ba,{milliseconds:1e3,fallback:null,children:[c,i.jsx(ye,{variant:"link",onClick:()=>{a("disabled")},children:"Turn off real-time collaboration"})]})}),o[1]=a,o[2]=d):d=o[2],d}let l;return o[3]!==n?(l=i.jsx(t,{...n}),o[3]=n,o[4]=l):l=o[4],l};return e.displayName=`WithWaitUntilConnected(${t.displayName})`,e})(S.memo(Ef)):S.memo(Ef),If=t=>{const e=z.c(10);let n,o,r,s;return e[0]!==t.left?(n=i.jsx("div",{className:"flex-1 flex item-center gap-2",children:t.left}),e[0]=t.left,e[1]=n):n=e[1],e[2]!==t.center?(o=i.jsx("div",{className:"flex-1 flex item-center gap-2 justify-center",children:t.center}),e[2]=t.center,e[3]=o):o=e[3],e[4]!==t.right?(r=i.jsx("div",{className:"flex-1 flex item-center gap-2 justify-end",children:t.right}),e[4]=t.right,e[5]=r):r=e[5],e[6]!==n||e[7]!==o||e[8]!==r?(s=i.jsxs("div",{className:"flex items-center gap-2 w-full px-3",children:[n,o,r]}),e[6]=n,e[7]=o,e[8]=r,e[9]=s):s=e[9],s},Af=t=>{const e=z.c(8);if(!t.canCollapse&&!t.isCollapsed)return null;const n=t.isCollapsed?"Expand":"Collapse";let o,r,s;return e[0]!==t.isCollapsed?(o=i.jsx("span",{children:i.jsx(Tf,{isCollapsed:t.isCollapsed})}),e[0]=t.isCollapsed,e[1]=o):o=e[1],e[2]!==n||e[3]!==o?(r=i.jsx(pe,{content:n,children:o}),e[2]=n,e[3]=o,e[4]=r):r=e[4],e[5]!==t.onClick||e[6]!==r?(s=i.jsx(ye,{variant:"text",size:"icon",onClick:t.onClick,children:r}),e[5]=t.onClick,e[6]=r,e[7]=s):s=e[7],s},Tf=t=>{const e=z.c(2),{isCollapsed:n}=t;let o;return e[0]!==n?(o=n?i.jsx(fa,{className:"w-5 h-5 shrink-0"}):i.jsx(Vn,{className:"w-5 h-5 shrink-0"}),e[0]=n,e[1]=o):o=e[1],o},pl=S.memo(t=>{const e=z.c(24),{onClick:n,count:o,cellId:r}=t,s=Gp();let a;e[0]!==r||e[1]!==s?(a=rj(s,r),e[0]=r,e[1]=s,e[2]=a):a=e[2];const l=a;let c,d;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=de("flex items-center justify-between w-[calc(100%-2rem)] h-9 bg-muted rounded-b mx-4 opacity-80 hover:opacity-100 cursor-pointer"),e[3]=c):c=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(aj,{className:"w-4 h-4 shrink-0"}),e[4]=d):d=e[4];const u=o===1?"cell":"cells";let h,m,p,b,x,f,g;return e[5]!==o||e[6]!==u?(h=i.jsxs(i.Fragment,{children:[d,i.jsxs("span",{className:"text-sm text-gray-500",children:[o," ",u," collapsed"]})]}),e[5]=o,e[6]=u,e[7]=h):h=e[7],e[8]!==l.errored?(m=l.errored&&i.jsx(pe,{content:"Has errors",delayDuration:100,children:i.jsx(ld,{className:"w-4 h-4 shrink-0 text-destructive"})}),e[8]=l.errored,e[9]=m):m=e[9],e[10]!==l.stale?(p=l.stale&&i.jsx(pe,{content:"Has stale cells",delayDuration:100,children:i.jsx(sj,{className:"w-4 h-4 shrink-0 text-(--yellow-11)"})}),e[10]=l.stale,e[11]=p):p=e[11],e[12]!==l.runningOrQueued?(b=l.runningOrQueued&&i.jsx(pe,{content:"Running",delayDuration:100,children:i.jsx(j1,{className:"w-4 h-4 shrink-0 animate-spin"})}),e[12]=l.runningOrQueued,e[13]=b):b=e[13],e[14]!==m||e[15]!==p||e[16]!==b?(x=i.jsxs(i.Fragment,{children:[m,p,b]}),e[14]=m,e[15]=p,e[16]=b,e[17]=x):x=e[17],e[18]!==h||e[19]!==x?(f=i.jsx(If,{center:h,right:x}),e[18]=h,e[19]=x,e[20]=f):f=e[20],e[21]!==n||e[22]!==f?(g=i.jsx("div",{onClick:n,className:c,children:f}),e[21]=n,e[22]=f,e[23]=g):g=e[23],g}),pl.displayName="CollapsedCellBanner";const Df=t=>{const e=z.c(31),{status:n,connectionState:o,onClick:r}=t,s=n==="running"||n==="queued";let a,l,c,d,u,h,m,p,b,x,f,g,y,w;if(e[0]!==o||e[1]!==s||e[2]!==r||e[3]!==n){const j=en(o);let C;if(j){let N;e[14]!==o?(N=oa(o),e[14]=o,e[15]=N):N=e[15],C=N}else C=n==="running"?"A cell can't be deleted when it's running":n==="queued"?"A cell can't be deleted when it's queued to run":"Delete";l=pe,b=C,x=!1,a=ye,c="ghost",d="icon",u=r,h="delete-button",m=Bn.preventFocus,p=de("hover:bg-transparent text-destructive/60 hover:text-destructive",(j||s)&&"inactive-button"),e[0]=o,e[1]=s,e[2]=r,e[3]=n,e[4]=a,e[5]=l,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=m,e[11]=p,e[12]=b,e[13]=x}else a=e[4],l=e[5],c=e[6],d=e[7],u=e[8],h=e[9],m=e[10],p=e[11],b=e[12],x=e[13];return e[16]===Symbol.for("react.memo_cache_sentinel")?(f={boxShadow:"none"},g=i.jsx(ec,{size:14}),e[16]=f,e[17]=g):(f=e[16],g=e[17]),e[18]!==a||e[19]!==c||e[20]!==d||e[21]!==u||e[22]!==h||e[23]!==m||e[24]!==p?(y=i.jsx(a,{variant:c,size:d,onClick:u,"data-testid":h,onMouseDown:m,className:p,style:f,children:g}),e[18]=a,e[19]=c,e[20]=d,e[21]=u,e[22]=h,e[23]=m,e[24]=p,e[25]=y):y=e[25],e[26]!==l||e[27]!==y||e[28]!==b||e[29]!==x?(w=i.jsx(l,{content:b,usePortal:x,children:y}),e[26]=l,e[27]=y,e[28]=b,e[29]=x,e[30]=w):w=e[30],w},Fy=t=>{const e=z.c(22),{cellId:n}=t,o=(function(g){const y=z.c(16),w=ie(uu),j=hu(),C=Cr();let N;y[0]!==g||y[1]!==w.entries?(N=w.entries.get(g),y[0]=g,y[1]=w.entries,y[2]=N):N=y[2];const k=N;if(!k){let A;return y[3]===Symbol.for("react.memo_cache_sentinel")?(A={isPending:!1},y[3]=A):A=y[3],A}if(w.entries.size!==1){let A;return y[4]!==k?(A={isPending:!0,shouldConfirmDelete:!1,...k},y[4]=k,y[5]=A):A=y[5],A}let E,_,I;return y[6]!==j||y[7]!==C||y[8]!==w.entries?(E=()=>{C({cellIds:[...w.entries.values()].map(bb)}),j.clear()},y[6]=j,y[7]=C,y[8]=w.entries,y[9]=E):E=y[9],y[10]!==j?(_=()=>j.clear(),y[10]=j,y[11]=_):_=y[11],y[12]!==k||y[13]!==E||y[14]!==_?(I={isPending:!0,...k,shouldConfirmDelete:!0,confirm:E,cancel:_},y[12]=k,y[13]=E,y[14]=_,y[15]=I):I=y[15],I})(n);if(!o.isPending)return null;if(o.type==="simple"){let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=de("px-3 py-1.5","bg-(--amber-2) border-t border-(--amber-6)","animate-in slide-in-from-top-2 duration-200"),e[0]=g):g=e[0];const y=`pending-delete-${n}`;let w,j;return e[1]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Zl,{className:"w-3 h-3 text-(--amber-11) shrink-0"}),i.jsx("span",{className:"text-(--amber-11) text-xs",children:"Pending deletion"})]}),e[1]=w):w=e[1],e[2]!==y?(j=i.jsx("div",{className:g,"data-testid":y,children:w}),e[2]=y,e[3]=j):j=e[3],j}const r=o.executionDurationMs!==void 0,s=o.defs.size>0,a=Wo(o.executionDurationMs??0);let l,c="Pending deletion";r&&s?c=`This cell took ${a} to run and contains variables referenced by other cells.`:r?c=`This cell took ${a} to run.`:s&&(c="This cell contains variables referenced by other cells."),e[4]===Symbol.for("react.memo_cache_sentinel")?(l=de("px-4 py-3","bg-(--amber-2) border-t border-(--amber-6)","animate-in slide-in-from-top-2 duration-200"),e[4]=l):l=e[4];const d=`pending-delete-${n}`;let u,h,m,p,b,x,f;return e[5]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Zl,{className:"w-4 h-4 text-(--amber-11) mt-0.5 shrink-0"}),e[5]=u):u=e[5],e[6]!==c?(h=i.jsx("p",{className:"text-(--amber-11) font-medium",children:c}),e[6]=c,e[7]=h):h=e[7],e[8]!==s||e[9]!==o.defs?(m=s&&[...o.defs.entries()].map(Py),e[8]=s,e[9]=o.defs,e[10]=m):m=e[10],e[11]!==h||e[12]!==m?(p=i.jsxs("div",{className:"font-code text-sm text-[0.84375rem]",children:[h,m]}),e[11]=h,e[12]=m,e[13]=p):p=e[13],e[14]!==o?(b=o.shouldConfirmDelete&&i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-(--amber-11) mt-2 mb-3",children:"Are you sure you want to delete?"}),i.jsx(Hl,{autoFocus:!0,children:i.jsxs("div",{className:"flex items-center gap-2",onKeyDown:zy,children:[i.jsx(ye,{size:"xs",variant:"ghost",onClick:()=>o.cancel(),className:"text-(--amber-11) hover:bg-(--amber-4) hover:text-(--amber-11)",children:"Cancel"}),i.jsx(ye,{size:"xs",variant:"secondary",onClick:()=>o.confirm(),className:"bg-(--amber-11) hover:bg-(--amber-12) text-white border-(--amber-11)",children:"Delete"})]})})]}),e[14]=o,e[15]=b):b=e[15],e[16]!==p||e[17]!==b?(x=i.jsxs("div",{className:"flex items-start gap-3",children:[u,i.jsxs("div",{className:"flex-1",children:[p,b]})]}),e[16]=p,e[17]=b,e[18]=x):x=e[18],e[19]!==d||e[20]!==x?(f=i.jsx("div",{className:l,"data-testid":d,children:x}),e[19]=d,e[20]=x,e[21]=f):f=e[21],f};function By(t){return i.jsx("li",{className:"my-0.5 ml-8 text-(--amber-11)/60",children:i.jsx(ij,{cellId:t})},t)}function Py(t){const[e,n]=t;return i.jsxs("div",{children:[i.jsxs("p",{className:"text-(--amber-11) mt-2",children:["'",i.jsx("span",{className:"font-mono",children:e}),"' is referenced by:"]}),i.jsx("ul",{className:"list-disc",children:n.map(By)})]},e)}function zy(t){t.stopPropagation()}const Uy=t=>{const e=z.c(27),{onClick:n,connectionState:o,needsRun:r,status:s,config:a,edited:l}=t,c=s==="disabled-transitively",d=s==="running"||s==="queued";let u,h;e[0]!==c||e[1]!==a.disabled||e[2]!==o||e[3]!==l||e[4]!==d||e[5]!==r?(u=en(o)||d||!a.disabled&&c&&!l,h=(function({connectionState:f,needsRun:g,loading:y,inactive:w}){return en(f)?"disabled":g&&!y?"stale":y||w?"disabled":"green"})({connectionState:o,needsRun:r,loading:d,inactive:u}),e[0]=c,e[1]=a.disabled,e[2]=o,e[3]=l,e[4]=d,e[5]=r,e[6]=u,e[7]=h):(u=e[6],h=e[7]);const m=h;if(a.disabled){let f,g;return e[8]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Qc,{}),e[8]=f):f=e[8],e[9]!==u||e[10]!==n||e[11]!==m?(g=i.jsx(er,{tooltip:"Add code to notebook",disabled:u,onClick:n,variant:m,"data-testid":"run-button",children:f}),e[9]=u,e[10]=n,e[11]=m,e[12]=g):g=e[12],g}if(!a.disabled&&c&&!l){let f,g;return e[13]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Uo,{strokeWidth:1.2}),e[13]=f):f=e[13],e[14]!==u||e[15]!==n||e[16]!==m?(g=i.jsx(er,{disabled:u,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:n,variant:m,"data-testid":"run-button",children:f}),e[14]=u,e[15]=n,e[16]=m,e[17]=g):g=e[17],g}let p,b,x;if(en(o)){let f;e[18]!==o?(f=oa(o),e[18]=o,e[19]=f):f=e[19],p=f}else if(s==="queued")p="This cell is already queued to run";else if(s==="running")p="This cell is already running.";else{let f;e[20]===Symbol.for("react.memo_cache_sentinel")?(f=St("cell.run"),e[20]=f):f=e[20],p=f}return e[21]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(Uo,{strokeWidth:1.2}),e[21]=b):b=e[21],e[22]!==u||e[23]!==n||e[24]!==p||e[25]!==m?(x=i.jsx(er,{tooltip:p,disabled:u,onClick:n,variant:m,"data-testid":"run-button",children:b}),e[22]=u,e[23]=n,e[24]=p,e[25]=m,e[26]=x):x=e[26],x},Wy=t=>{const e=z.c(4),{cellId:n,className:o}=t;if(!ie(T1).has(n))return null;let r,s;return e[0]!==o?(r=de("mo-ai-generated-cell",o),e[0]=o,e[1]=r):r=e[1],e[2]!==r?(s=i.jsx("div",{className:r}),e[2]=r,e[3]=s):s=e[3],s},$y=t=>{const e=z.c(9),{cellId:n}=t,o=na(),r=ie(T1),{deleteStagedCell:s,removeStagedCell:a}=lj(o);if(!r.has(n))return null;let l;e[0]!==n||e[1]!==a?(l=()=>{a(n)},e[0]=n,e[1]=a,e[2]=l):l=e[2];const c=l;let d;e[3]!==n||e[4]!==s?(d=()=>{s(n)},e[3]=n,e[4]=s,e[5]=d):d=e[5];const u=d;let h;return e[6]!==c||e[7]!==u?(h=i.jsx("div",{className:"flex items-center justify-end gap-1.5 w-full pb-1 pt-2",children:i.jsx(cj,{isLoading:!1,onAccept:c,onDecline:u,size:"xs"})}),e[6]=c,e[7]=u,e[8]=h):h=e[8],h},Vy=t=>{const e=z.c(13),{cellId:n,hide:o}=t,r=dj(n);if(!r||o)return;let s,a,l,c,d,u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(vc,{size:13,className:"mt-[3px] text-destructive"}),e[0]=s):s=e[0],e[1]!==r.errorType?(a=i.jsxs("span",{className:"font-bold text-destructive",children:[r.errorType,":"]}),e[1]=r.errorType,e[2]=a):a=e[2],e[3]!==r.errorMessage?(l=i.jsx("span",{className:"whitespace-pre-wrap",children:r.errorMessage}),e[3]=r.errorMessage,e[4]=l):l=e[4],e[5]!==a||e[6]!==l?(c=i.jsxs("div",{className:"flex items-start gap-1.5",children:[s,i.jsxs("p",{children:[a," ",l]})]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],e[8]!==r.codeblock?(d=r.codeblock&&i.jsx("pre",{lang:"sql",className:"text-xs bg-muted/80 rounded p-2 pb-0 mx-3 font-medium whitespace-pre-wrap",children:r.codeblock}),e[8]=r.codeblock,e[9]=d):d=e[9],e[10]!==c||e[11]!==d?(u=i.jsxs("div",{className:"p-3 text-sm flex flex-col text-muted-foreground gap-1.5 bg-destructive/4",children:[c,d]}),e[10]=c,e[11]=d,e[12]=u):u=e[12],u},Mf=he.createContext(null),Of=S.memo(()=>S.use(Mf));Of.displayName="DragHandle";const Rf=he.forwardRef((t,e)=>{const n=z.c(21);let o,r,s,a,l;n[0]!==t?({cellId:r,canMoveX:o,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==r?(a=r.toString(),n[4]=r,n[5]=a):a=n[5],n[6]!==a?(l={id:a},n[6]=a,n[7]=l):l=n[7];const{attributes:c,listeners:d,setNodeRef:u,transform:h,transition:m,isDragging:p}=qu(l);let b;n[8]!==h?(b=(function(y){return!y||y.x===0&&y.y===0&&y.scaleX===1&&y.scaleY===1})(h)?null:h,n[8]=h,n[9]=b):b=n[9];const x=b,f=x==null?void 0:m;let g;return n[10]!==c||n[11]!==o||n[12]!==r||n[13]!==p||n[14]!==d||n[15]!==s||n[16]!==e||n[17]!==u||n[18]!==x||n[19]!==f?(g=i.jsx(Lf,{ref:e,cellId:r,canMoveX:o,...s,attributes:c,listeners:d,setNodeRef:u,transform:x,transition:f,isDragging:p}),n[10]=c,n[11]=o,n[12]=r,n[13]=p,n[14]=d,n[15]=s,n[16]=e,n[17]=u,n[18]=x,n[19]=f,n[20]=g):g=n[20],g});Rf.displayName="SortableCell";const Lf=he.forwardRef((t,e)=>{const n=z.c(35);let o,r,s,a,l,c,d,u,h,m;if(n[0]!==e||n[1]!==t){const{cellId:p,canMoveX:b,children:x,attributes:f,listeners:g,setNodeRef:y,transform:w,transition:j,isDragging:C,...N}=t;let k;o=x,n[10]!==b||n[11]!==w?(k=w?ca.Transform.toString({x:b?w.x:0,y:w.y,scaleX:1,scaleY:1}):void 0,n[10]=b,n[11]=w,n[12]=k):k=n[12];const E=C?2:void 0;let _,I,A;n[13]!==k||n[14]!==E||n[15]!==j?(_={transform:k,transition:j,zIndex:E,position:"relative"},n[13]=k,n[14]=E,n[15]=j,n[16]=_):_=n[16],s=_,n[17]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(Xc,{strokeWidth:1,size:20}),n[17]=I):I=n[17],n[18]!==f||n[19]!==g?(A=i.jsx("div",{...f,...g,onMouseDown:Bn.preventFocus,"data-testid":"drag-button",className:"py-px cursor-grab opacity-50 hover:opacity-100 hover-action hover:bg-muted rounded border border-transparent hover:border-border active:bg-accent",children:I}),n[18]=f,n[19]=g,n[20]=A):A=n[20],r=A;const O=!!w;a=-1,n[21]!==e||n[22]!==y?(l=D=>{Ls(e,y)(D)},n[21]=e,n[22]=y,n[23]=l):l=n[23],c=N,d=C,u=de(N.className,O&&"is-moving","outline-hidden rounded-lg"),n[0]=e,n[1]=t,n[2]=o,n[3]=r,n[4]=s,n[5]=a,n[6]=l,n[7]=c,n[8]=d,n[9]=u}else o=n[2],r=n[3],s=n[4],a=n[5],l=n[6],c=n[7],d=n[8],u=n[9];return n[24]!==o||n[25]!==r?(h=i.jsx(Mf.Provider,{value:r,children:o}),n[24]=o,n[25]=r,n[26]=h):h=n[26],n[27]!==s||n[28]!==a||n[29]!==l||n[30]!==c||n[31]!==d||n[32]!==u||n[33]!==h?(m=i.jsx("div",{tabIndex:a,ref:l,...c,"data-is-dragging":d,className:u,style:s,children:h}),n[27]=s,n[28]=a,n[29]=l,n[30]=c,n[31]=d,n[32]=u,n[33]=h,n[34]=m):m=n[34],m});function Ff(t,e){const n=z.c(9);let o;n[0]!==t||n[1]!==e?(o=c=>{t.current===null||t.current.contains(c.relatedTarget)||e.current===null||El(e.current)},n[0]=t,n[1]=e,n[2]=o):o=n[2];const r=Ce(o);let s;n[3]!==t||n[4]!==e?(s=c=>{if(t.current===document.activeElement&&e.current!==null&&Fo(e.current.state)==="active"){for(const d of s1)if(c.key===d.key&&d.run){d.run(e.current),c.preventDefault(),c.stopPropagation();break}e.current.focus()}},n[3]=t,n[4]=e,n[5]=s):s=n[5];const a=Ce(s);let l;return n[6]!==r||n[7]!==a?(l={closeCompletionHandler:r,resumeCompletionHandler:a},n[6]=r,n[7]=a,n[8]=l):l=n[8],l}function Bf(t){const e=z.c(16),{cellId:n,cellConfig:o,languageAdapter:r,editorView:s}=t,a=Oy(n),l=Ws();let c;e[0]!==n?(c=mj(n),e[0]=n,e[1]=c):c=e[1];const d=ie(c),u=!o.hide_code||a||d,h=r==="markdown",m=h&&!u;let p;e[2]!==n||e[3]!==s||e[4]!==u||e[5]!==l?(p=y=>{var j;if(u)return;const w=(y==null?void 0:y.focus)??!0;l.add(n),w&&((j=s.current)==null||j.focus())},e[2]=n,e[3]=s,e[4]=u,e[5]=l,e[6]=p):p=e[6];const b=Ce(p);let x;e[7]!==m||e[8]!==b?(x=()=>{m&&b({focus:!0})},e[7]=m,e[8]=b,e[9]=x):x=e[9];const f=Ce(x);let g;return e[10]!==u||e[11]!==h||e[12]!==m||e[13]!==b||e[14]!==f?(g={isCellCodeShown:u,isMarkdown:h,isMarkdownCodeHidden:m,showHiddenCode:b,showHiddenCodeIfMarkdown:f},e[10]=u,e[11]=h,e[12]=m,e[13]=b,e[14]=f,e[15]=g):g=e[15],g}Lf.displayName="SortableCellInternal";const Pf=S.forwardRef((t,e)=>{var x;const n=z.c(18),{cellId:o}=t,r=Lr(o),s=Fr(o);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=xa("marimo-cell","hover-actions-parent z-10",{published:!0}),n[0]=a):a=n[0];const l=a,c=M1((x=s.output)==null?void 0:x.mimetype);if(s.errored||s.interrupted||s.stopped||c)return null;let d;n[1]!==r.name||n[2]!==o?(d=Sc(o,r.name),n[1]=r.name,n[2]=o,n[3]=d):d=n[3];const u=s.output;let h,m,p,b;return n[4]!==r.edited||n[5]!==s?(h=L1(s,r.edited),n[4]=r.edited,n[5]=s,n[6]=h):h=n[6],n[7]!==s.status?(m=kc(s.status),n[7]=s.status,n[8]=m):m=n[8],n[9]!==o||n[10]!==s.output||n[11]!==h||n[12]!==m?(p=i.jsx(wc,{allowExpand:!1,forceExpand:!0,className:"output-area",cellId:o,output:u,stale:h,loading:m}),n[9]=o,n[10]=s.output,n[11]=h,n[12]=m,n[13]=p):p=n[13],n[14]!==e||n[15]!==d||n[16]!==p?(b=i.jsx("div",{tabIndex:-1,ref:e,className:l,...d,children:p}),n[14]=e,n[15]=d,n[16]=p,n[17]=b):b=n[17],b});Pf.displayName="ReadonlyCellComponent";const Gy=({theme:t,showPlaceholder:e,cellId:n,canDelete:o,userConfig:r,isCollapsed:s,collapseCount:a,canMoveX:l,editorView:c,setEditorView:d})=>{var ve;const u=S.useRef(null),h=Lr(n),m=Fr(n),p=S.useRef(null),b=S.useRef(null),x=S.useRef(null),f=Ke(),g=ie(Nt),y=Ct(Or),w=jr(),j=$a(n),{sendStdin:C}=qe(),[N,k]=S.useState(),E=h.config.disabled||m.status==="disabled-transitively",_=D1({executionTime:m.runElapsedTimeMs??h.lastExecutionTime,status:m.status,errored:m.errored,interrupted:m.interrupted,stopped:m.stopped}),I=h.edited||m.interrupted||m.staleInputs&&!E,A=kc(m.status),O=(m.status==="queued"||h.edited||m.staleInputs)&&!m.interrupted,D=S.useCallback(()=>c.current,[c]),{closeCompletionHandler:M,resumeCompletionHandler:R}=Ff(u,c),{isCellCodeShown:L,isMarkdown:P,isMarkdownCodeHidden:T,showHiddenCode:F,showHiddenCodeIfMarkdown:$}=Bf({cellId:n,cellConfig:h.config,languageAdapter:N,editorView:c}),W=Nf(n,{canMoveX:l,editorView:c,cellActionDropdownRef:p}),H=hj(m.outline),X=!gc(m.output),q=L1(m,h.edited),Y=m.consoleOutputs.length>0,J=r.display.cell_output,V=X&&J==="above",G=X&&J==="below",[U,ne]=S.useState(!1),[Q,ee]=S.useState(!1);(function(ge){const{ref:ke,box:fe="content-box",skip:Ie}=ge,Oe=S.useRef({...T2}),we=S.useRef(void 0);we.current=ge.onResize,S.useEffect(()=>{if(!ke.current||Ie||typeof window>"u"||!("ResizeObserver"in window))return;const be=new ResizeObserver(([et])=>{const ct=fe==="border-box"?"borderBoxSize":fe==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",dt=Zh(et,ct,"inlineSize"),tt=Zh(et,ct,"blockSize");if(Oe.current.width!==dt||Oe.current.height!==tt){const ut={width:dt,height:tt};Oe.current.width=dt,Oe.current.height=tt,we.current&&we.current(ut)}});return be.observe(ke.current,{box:fe}),()=>{be.disconnect()}},[fe,ke,Ie])})({ref:x,skip:!P,onResize:ge=>{const ke=ge.height&&ge.height<68,fe=T&&(ke||J==="below");ne(fe),H&&fe?ee(!0):Q&&ee(!1)}});const te=ge=>i.jsx(A1,{tooltip:"Edit markdown",className:de("z-20 relative",ge),onClick:F}),se=X&&i.jsxs("div",{className:"relative",onDoubleClick:$,children:[i.jsx("div",{className:"absolute top-5 -left-8 z-10 print:hidden",children:i.jsx(Af,{isCollapsed:s,onClick:()=>{s?f.expandCell({cellId:n}):f.collapseCell({cellId:n})},canCollapse:H})}),T&&G&&te("top-3"),i.jsx(wc,{allowExpand:!0,forceExpand:T,className:"output-area",cellId:n,output:m.output,stale:q,loading:kc(m.status)}),T&&V&&te("bottom-3")]}),ae=xa("marimo-cell","hover-actions-parent z-10",{interactive:!0,"needs-run":I,"has-error":m.errored,stopped:m.stopped,disabled:h.config.disabled,stale:m.status==="disabled-transitively",borderless:T&&X&&!W["data-selected"]}),oe=Ce(ge=>{y({cellId:n,initialPrompt:ge.prompt})}),Ee=((ve=m.serialization)==null?void 0:ve.toLowerCase())==="valid";return i.jsx(O1,{children:i.jsx(Mm,{cellId:n,getEditorView:D,children:i.jsxs(Rf,{tabIndex:-1,ref:u,"data-status":m.status,onBlur:M,onKeyDown:R,cellId:n,canMoveX:l,title:h.config.disabled?"This cell is disabled":m.status==="disabled-transitively"?"This cell has a disabled ancestor":void 0,children:[i.jsxs("div",{tabIndex:-1,...W,className:de(ae,W.className,"focus:ring-1 focus:ring-(--blue-7) focus:ring-offset-0"),ref:x,...Sc(n,h.name),children:[J==="above"&&se,i.jsxs("div",{className:de("tray"),"data-hidden":T,children:[i.jsx(Wy,{cellId:n}),i.jsx("div",{className:"absolute right-2 -top-4 z-10",children:i.jsx(bl,{edited:h.edited,status:m.status,cellConfig:h.config,needsRun:I,hasOutput:X,hasConsoleOutput:Y,cellActionDropdownRef:p,cellId:n,name:h.name,getEditorView:D,onRun:j})}),i.jsx(zf,{cellId:n,className:de(T&&V&&"-top-7",T&&G&&"-bottom-8",T&&Q&&"-left-[3.8rem]"),actions:f}),i.jsx(Ia,{theme:t,showPlaceholder:e,id:n,code:h.code,config:h.config,status:m.status,serializedEditorState:h.serializedEditorState,runCell:j,setEditorView:d,userConfig:r,editorViewRef:c,editorViewParentRef:b,hidden:!L,hasOutput:X,showHiddenCode:F,languageAdapter:N,setLanguageAdapter:k}),i.jsx(gl,{className:de(T&&J==="below"&&"top-14"),edited:h.edited,status:m.status,isCellStatusInline:U,uninstantiated:_,disabled:h.config.disabled,runElapsedTimeMs:m.runElapsedTimeMs,runStartTimestamp:m.runStartTimestamp,lastRunStartTimestamp:m.lastRunStartTimestamp,staleInputs:m.staleInputs,interrupted:m.interrupted}),i.jsx("div",{className:"shoulder-bottom hover-action",children:o&&L&&i.jsx(Df,{status:m.status,connectionState:g.state,onClick:()=>{A||en(g.state)||w({cellId:n})}})})]}),i.jsx(Vy,{cellId:n,hide:m.errored&&!q}),J==="below"&&se,m.serialization&&i.jsxs("div",{className:"py-1 px-2 flex items-center justify-end gap-2 last:rounded-b",children:[Ee&&i.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",className:"hover:underline text-muted-foreground text-xs font-bold",rel:"noopener",children:"reusable"}),i.jsx(pe,{content:i.jsx("span",{className:"max-w-16 text-xs",children:Ee?"This function or class can be imported into other Python notebooks or modules.":i.jsxs(i.Fragment,{children:["This definition can't be reused in other Python modules:",i.jsx("br",{}),i.jsx("br",{}),i.jsx("pre",{children:m.serialization}),i.jsx("br",{}),"Click this icon to learn more."]})}),children:Ee?i.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",rel:"noopener",children:i.jsx(gp,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})}):i.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",rel:"noopener",children:i.jsx(R1,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})})})]}),i.jsx(rg,{consoleOutputs:m.consoleOutputs,stale:O,cellName:m.serialization?"_":h.name,onRefactorWithAI:oe,onClear:()=>{f.clearCellConsoleOutput({cellId:n})},onSubmitDebugger:(ge,ke)=>{f.setStdinResponse({cellId:n,response:ge,outputIndex:ke}),C({text:ge})},cellId:n,debuggerActive:m.debuggerActive}),i.jsx(Fy,{cellId:n})]}),i.jsx($y,{cellId:n}),s&&i.jsx(pl,{onClick:()=>f.expandCell({cellId:n}),count:a,cellId:n})]})})})},gl=S.memo(t=>{const e=z.c(19),{className:n,disabled:o,edited:r,interrupted:s,isCellStatusInline:a,lastRunStartTimestamp:l,runElapsedTimeMs:c,runStartTimestamp:d,staleInputs:u,status:h,uninstantiated:m}=t,p=o!==void 0&&o;let b;e[0]!==p||e[1]!==r||e[2]!==s||e[3]!==l||e[4]!==c||e[5]!==d||e[6]!==u||e[7]!==h||e[8]!==m?(b=i.jsx(em,{status:h,staleInputs:u,interrupted:s,editing:!0,edited:r,disabled:p,elapsedTime:c,runStartTimestamp:d,uninstantiated:m,lastRunStartTimestamp:l}),e[0]=p,e[1]=r,e[2]=s,e[3]=l,e[4]=c,e[5]=d,e[6]=u,e[7]=h,e[8]=m,e[9]=b):b=e[9];const x=b;let f;e[10]!==n?(f=de("shoulder-right z-20",n),e[10]=n,e[11]=f):f=e[11];const g=!a&&x;let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(Of,{}),e[12]=y):y=e[12];const w=a&&x;let j,C;return e[13]!==w?(j=i.jsxs("div",{className:"flex gap-2 items-end",children:[y,w]}),e[13]=w,e[14]=j):j=e[14],e[15]!==f||e[16]!==g||e[17]!==j?(C=i.jsxs("div",{className:f,children:[g,j]}),e[15]=f,e[16]=g,e[17]=j,e[18]=C):C=e[18],C});gl.displayName="CellRightSideActions";const zf=S.memo(t=>{const e=z.c(21),n=ie(Nt),{className:o,actions:r,cellId:s}=t;let a;e[0]!==r||e[1]!==s?(a=j=>{const C=j===void 0?{}:j;return r.createNewCell({cellId:s,before:!1,...C})},e[0]=r,e[1]=s,e[2]=a):a=e[2];const l=Ce(a);let c;e[3]!==r||e[4]!==s?(c=j=>{const C=j===void 0?{}:j;return r.createNewCell({cellId:s,before:!0,...C})},e[3]=r,e[4]=s,e[5]=c):c=e[5];const d=Ce(c),u=F1(n.state);let h,m;e[6]!==o?(h=de("absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-20",o),e[6]=o,e[7]=h):h=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(m=St("cell.createAbove"),e[8]=m):m=e[8];const p=u?d:void 0;let b,x,f;e[9]!==n.state||e[10]!==p?(b=i.jsx(Am,{tooltipContent:m,connectionState:n.state,onClick:p}),e[9]=n.state,e[10]=p,e[11]=b):b=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("div",{className:"flex-1"}),e[12]=x):x=e[12],e[13]===Symbol.for("react.memo_cache_sentinel")?(f=St("cell.createBelow"),e[13]=f):f=e[13];const g=u?l:void 0;let y,w;return e[14]!==n.state||e[15]!==g?(y=i.jsx(Am,{tooltipContent:f,connectionState:n.state,onClick:g}),e[14]=n.state,e[15]=g,e[16]=y):y=e[16],e[17]!==h||e[18]!==b||e[19]!==y?(w=i.jsxs("div",{className:h,children:[b,x,y]}),e[17]=h,e[18]=b,e[19]=y,e[20]=w):w=e[20],w});zf.displayName="CellLeftSideActions";const bl=S.memo(t=>{const e=z.c(27),{edited:n,status:o,cellConfig:r,needsRun:s,hasOutput:a,hasConsoleOutput:l,onRun:c,cellActionDropdownRef:d,cellId:u,getEditorView:h,name:m,includeCellActions:p}=t,b=p===void 0||p,x=ie(Nt),f=F1(x.state),g=!s&&"hover-action";let y;e[0]!==g?(y=de(g),e[0]=g,e[1]=y):y=e[1];const w=f?c:Pn.NOOP;let j,C,N,k;return e[2]!==r||e[3]!==x.state||e[4]!==n||e[5]!==s||e[6]!==o||e[7]!==w?(j=i.jsx(Uy,{edited:n,onClick:w,connectionState:x.state,status:o,config:r,needsRun:s}),e[2]=r,e[3]=x.state,e[4]=n,e[5]=s,e[6]=o,e[7]=w,e[8]=j):j=e[8],e[9]!==x.state||e[10]!==o?(C=i.jsx(Nx,{status:o,connectionState:x.state}),e[9]=x.state,e[10]=o,e[11]=C):C=e[11],e[12]!==d||e[13]!==r||e[14]!==u||e[15]!==h||e[16]!==l||e[17]!==a||e[18]!==b||e[19]!==m||e[20]!==o?(N=b&&i.jsx(Qi,{ref:d,cellId:u,status:o,getEditorView:h,name:m,config:r,hasOutput:a,hasConsoleOutput:l,children:i.jsx(er,{variant:"green",tooltip:null,"data-testid":"cell-actions-button",children:i.jsx(Ca,{strokeWidth:1.5})})}),e[12]=d,e[13]=r,e[14]=u,e[15]=h,e[16]=l,e[17]=a,e[18]=b,e[19]=m,e[20]=o,e[21]=N):N=e[21],e[22]!==y||e[23]!==j||e[24]!==C||e[25]!==N?(k=i.jsxs(Cx,{className:y,children:[j,C,N]}),e[22]=y,e[23]=j,e[24]=C,e[25]=N,e[26]=k):k=e[26],k});bl.displayName="CellToolbar";const qy=({theme:t,showPlaceholder:e,cellId:n,canDelete:o,userConfig:r,canMoveX:s,editorView:a,setEditorView:l})=>{var F;const c=S.useRef(null),d=Lr(n),u=Fr(n),h=S.useRef(null),m=S.useRef(null),p=ie(Nt),b=Ke(),x=qe(),f=jr(),g=Ct(Or),y=$a(n),w=d.config.disabled||u.status==="disabled-transitively",j=D1({executionTime:u.runElapsedTimeMs??d.lastExecutionTime,status:u.status,errored:u.errored,interrupted:u.interrupted,stopped:u.stopped}),C=d.edited||u.interrupted||u.staleInputs&&!w,N=u.status==="running"||u.status==="queued",k=(u.status==="queued"||d.edited||u.staleInputs)&&!u.interrupted,E=S.useCallback(()=>a.current,[a]),{isCellCodeShown:_,showHiddenCode:I}=Bf({cellId:n,cellConfig:d.config,languageAdapter:"python",editorView:a}),{closeCompletionHandler:A,resumeCompletionHandler:O}=Ff(c,a),D=Nf(n,{canMoveX:s,editorView:a,cellActionDropdownRef:h}),M=!gc(u.output),R=u.consoleOutputs.length>0,L=M1((F=u.output)==null?void 0:F.mimetype),P=xa("marimo-cell","hover-actions-parent z-10 border shadow-sm","border-(--blue-5)! rounded-sm!",{"needs-run":C,"has-error":u.errored,stopped:u.stopped}),T=Ce($=>{g({cellId:n,initialPrompt:$.prompt})});return i.jsx(O1,{children:i.jsx(Mm,{cellId:n,getEditorView:E,children:i.jsxs("div",{"data-status":u.status,ref:c,...Nl(D,{className:P,onBlur:A,onKeyDown:O}),...Sc(n,d.name),title:d.config.disabled?"This cell is disabled":u.status==="disabled-transitively"?"This cell has a disabled ancestor":void 0,"data-setup-cell":!0,children:[i.jsxs("div",{className:de("tray"),"data-hidden":!_,children:[i.jsx("div",{className:"absolute right-2 -top-4 z-10",children:i.jsx(bl,{edited:d.edited,status:u.status,cellConfig:d.config,needsRun:C,hasOutput:M,hasConsoleOutput:R,cellActionDropdownRef:h,cellId:n,name:d.name,getEditorView:E,onRun:y,includeCellActions:!0})}),i.jsx(Ia,{theme:t,showPlaceholder:e,id:n,code:d.code,config:d.config,status:u.status,serializedEditorState:d.serializedEditorState,runCell:y,setEditorView:l,userConfig:r,editorViewRef:a,editorViewParentRef:m,hidden:!_,hasOutput:M,showHiddenCode:I,languageAdapter:"python",setLanguageAdapter:Pn.NOOP,showLanguageToggles:!1}),i.jsx(gl,{edited:d.edited,status:u.status,isCellStatusInline:!1,uninstantiated:j,disabled:d.config.disabled,runElapsedTimeMs:u.runElapsedTimeMs,runStartTimestamp:u.runStartTimestamp,lastRunStartTimestamp:u.lastRunStartTimestamp,staleInputs:u.staleInputs,interrupted:u.interrupted}),i.jsx("div",{className:"shoulder-bottom hover-action",children:o&&i.jsx(Df,{connectionState:p.state,status:u.status,onClick:()=>{N||en(p.state)||f({cellId:n})}})})]}),i.jsxs("div",{className:"py-1 px-2 flex justify-end gap-2 last:rounded-b",children:[i.jsx("span",{className:"text-muted-foreground text-xs font-bold",children:"setup cell"}),i.jsx(pe,{content:i.jsxs("span",{className:"max-w-16",children:["This ",i.jsx("b",{children:"setup cell"})," is guaranteed to run before all other cells. Include ",i.jsx("br",{}),"initialization or imports and constants required by top-level functions."]}),children:i.jsx(R1,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})})]}),L&&i.jsx(wc,{allowExpand:!0,forceExpand:!0,className:"output-area",cellId:n,output:u.output,stale:!1,loading:N}),i.jsx(rg,{consoleOutputs:u.consoleOutputs,stale:k,cellName:"_",onRefactorWithAI:T,onClear:()=>{b.clearCellConsoleOutput({cellId:n})},onSubmitDebugger:($,W)=>{b.setStdinResponse({cellId:n,response:$,outputIndex:W}),x.sendStdin({text:$})},cellId:n,debuggerActive:u.debuggerActive})]})})})},Uf=S.memo(t=>{const{cellId:e,mode:n}=t,o=uj(e);Ye.debug("Rendering Cell",e);const r=S.useRef(null);return S.useImperativeHandle(o,()=>({get editorView(){return(function(s){const a=s.current;if(a===null)throw new ReferenceError("Attempting to dereference null object.");return a})(r)},get editorViewOrNull(){return r.current}}),[r]),e===Pr?i.jsx(qy,{...t,cellId:e,editorView:r,setEditorView:s=>{r.current=s}}):n==="edit"?i.jsx(Gy,{...t,cellId:e,editorView:r,setEditorView:s=>{r.current=s}}):i.jsx(Pf,{cellId:e})}),Hy=(t,e)=>(function(n,o){const r=/^(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/,s=a=>{const l=a.match(r);if(!l)return null;const[,c,d,u,h]=l;return{major:Number.parseInt(c,10),minor:Number.parseInt(d,10),patch:Number.parseInt(u,10),preRelease:h||""}};try{const a=s(n),l=s(o);return a&&l?a.major!==l.major?a.major-l.major:a.minor!==l.minor?a.minor-l.minor:a.patch!==l.patch?a.patch-l.patch:a.preRelease===""&&l.preRelease!==""?1:a.preRelease!==""&&l.preRelease===""?-1:a.preRelease.localeCompare(l.preRelease):n.localeCompare(o,void 0,{numeric:!0,sensitivity:"base"})}catch{return n.localeCompare(o,void 0,{numeric:!0,sensitivity:"base"})}})(e,t),Wf=new class{constructor(t){this.ttl=void 0,this.cache=new Map,this.ttl=t.ttl}cleanupExpiredEntries(){const t=Date.now();for(const[e,n]of this.cache.entries())t-n.timestamp>this.ttl&&this.cache.delete(e)}get(t){this.cleanupExpiredEntries();const e=this.cache.get(t);if(e){if(!(Date.now()-e.timestamp>this.ttl))return e.data;this.cache.delete(t)}}set(t,e){this.cache.set(t,{data:e,timestamp:Date.now()})}clear(){this.cache.clear()}}({ttl:3e5}),Jy=Be({info:Be({provides_extra:Me().array().nullable()}),releases:fj(Me(),pj())});function $f(t){const e=z.c(5);let n;e[0]!==t?(n=t.replaceAll(/\[.*]/g,"").trim(),e[0]=t,e[1]=n):n=e[1];const o=n;let r,s;return e[2]!==o?(r=async()=>{const a=Wf.get(o);if(a)return a;const l=await fetch(`https://pypi.org/pypi/${o}/json`,{method:"GET"});if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);const c=Jy.transform(Ky).parse(await l.json());return Wf.set(o,c),c},s=[o],e[2]=o,e[3]=r,e[4]=s):(r=e[3],s=e[4]),vr(r,s)}function Ky(t){return{versions:Object.keys(t.releases).toSorted(Hy),extras:t.info.provides_extra??[]}}function Vf(t){const e=t.match(/^([^[]+)(?:\[([^\]]+)])?$/);if(!e)return{name:t,extras:[]};const[,n,o]=e;return{name:n,extras:o?o.split(",").map(r=>r.trim()):[]}}const Yy=()=>{const t=z.c(69),{packageAlert:e,packageLogs:n}=tg(),{clearPackageAlert:o}=ng(),[r]=Qs();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={},t[0]=s):s=t[0];const[a,l]=S.useState(s);let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={},t[1]=c):c=t[1];const[d,u]=S.useState(c);if(e===null)return null;const h=r.package_management.manager!=="pixi";if(yC(e)){let m,p,b,x,f,g,y,w,j,C;if(t[2]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[i.jsx(La,{className:"w-5 h-5 inline-block mr-2"}),"Missing packages"]}),t[2]=m):m=t[2],t[3]!==o||t[4]!==e.id?(p=()=>o(e.id),t[3]=o,t[4]=e.id,t[5]=p):p=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx($t,{className:"w-5 h-5"}),t[6]=b):b=t[6],t[7]!==p?(x=i.jsxs("div",{className:"flex justify-between",children:[m,i.jsx(ye,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:p,children:b})]}),t[7]=p,t[8]=x):x=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("p",{children:"The following packages were not found:"}),t[9]=f):f=t[9],t[10]!==a||t[11]!==h||t[12]!==e.packages||t[13]!==d){let N;t[15]!==a||t[16]!==h||t[17]!==d?(N=(k,E)=>{const _=Vf(k),I=d[k]||_.extras;return i.jsxs("tr",{className:"font-mono text-sm",children:[i.jsx("td",{className:"pr-2 py-1 align-middle",children:i.jsx(ja,{size:"1rem"})}),i.jsx("td",{className:"pr-2 py-1 align-middle",children:i.jsx(ev,{packageName:_.name,selectedExtras:I,onExtrasChange:A=>u(O=>({...O,[k]:A}))})}),h&&i.jsx("td",{className:"pr-2 py-1 align-middle",children:i.jsx(tv,{value:a[k]??"latest",onChange:A=>l(O=>({...O,[k]:A})),packageName:_.name})})]},E)},t[15]=a,t[16]=h,t[17]=d,t[18]=N):N=t[18],g=e.packages.map(N),t[10]=a,t[11]=h,t[12]=e.packages,t[13]=d,t[14]=g}else g=t[14];return t[19]!==g?(y=i.jsxs("div",{children:[f,i.jsx("table",{className:"list-disc ml-2 mt-1",children:g})]}),t[19]=g,t[20]=y):y=t[20],t[21]!==o||t[22]!==a||t[23]!==e.id||t[24]!==e.isolated||t[25]!==e.packages||t[26]!==d||t[27]!==r.package_management.manager?(w=i.jsx("div",{className:"ml-auto flex flex-row items-baseline",children:e.isolated?i.jsxs(i.Fragment,{children:[i.jsx(Qy,{manager:r.package_management.manager,packages:e.packages.map(N=>{const k=Vf(N),E=d[N]||k.extras;return _=k.name,(I=E).length===0?_:`${_}[${I.join(",")}]`;var _,I}),versions:a,clearPackageAlert:()=>o(e.id)}),!Xt()&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"px-2 text-sm",children:"with"})," ",i.jsx(Zy,{})]})]}):i.jsxs("p",{children:["If you set up a"," ",i.jsx(Rl,{href:"https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments",children:"virtual environment"}),", marimo can install these packages for you."]})}),t[21]=o,t[22]=a,t[23]=e.id,t[24]=e.isolated,t[25]=e.packages,t[26]=d,t[27]=r.package_management.manager,t[28]=w):w=t[28],t[29]!==y||t[30]!==w?(j=i.jsxs("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:[y,w]}),t[29]=y,t[30]=w,t[31]=j):j=t[31],t[32]!==j||t[33]!==x?(C=i.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-200 opacity-95 max-w-[600px]",children:i.jsxs(Lo,{kind:"danger",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left overflow-auto max-h-[80vh] scrollbar-thin",children:[x,j]})}),t[32]=j,t[33]=x,t[34]=C):C=t[34],C}if(vC(e)){let m;t[35]!==e.packages?(m=(function(R){const L=new Set(Object.values(R)),P=L.has("queued")||L.has("installing")?"installing":L.has("failed")?"failed":"installed";return P==="installing"?{status:"installing",title:"Installing packages",titleIcon:i.jsx($r,{className:"w-5 h-5 inline-block mr-2"}),description:"Installing packages:"}:P==="installed"?{status:"installed",title:"All packages installed!",titleIcon:i.jsx(cd,{className:"w-5 h-5 inline-block mr-2"}),description:"Installed packages:"}:{status:"failed",title:"Some packages failed to install",titleIcon:i.jsx(La,{className:"w-5 h-5 inline-block mr-2"}),description:"See error logs."}})(e.packages),t[35]=e.packages,t[36]=m):m=t[36];const{status:p,title:b,titleIcon:x,description:f}=m;p==="installed"&&setTimeout(()=>o(e.id),1e4);const g=p==="failed"?"danger":"info";let y,w,j,C,N;t[37]!==b||t[38]!==x?(y=i.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[x,b]}),t[37]=b,t[38]=x,t[39]=y):y=t[39],t[40]!==o||t[41]!==e.id?(w=()=>o(e.id),t[40]=o,t[41]=e.id,t[42]=w):w=t[42],t[43]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx($t,{className:"w-5 h-5"}),t[43]=j):j=t[43],t[44]!==w?(C=i.jsx(ye,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:w,children:j}),t[44]=w,t[45]=C):C=t[45],t[46]!==y||t[47]!==C?(N=i.jsxs("div",{className:"flex justify-between",children:[y,C]}),t[46]=y,t[47]=C,t[48]=N):N=t[48];const k=p==="installed"&&"text-accent-foreground";let E,_,I,A,O,D,M;return t[49]!==k?(E=de("flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",k),t[49]=k,t[50]=E):E=t[50],t[51]!==f?(_=i.jsx("p",{children:f}),t[51]=f,t[52]=_):_=t[52],t[53]!==e.packages?(I=Object.entries(e.packages),t[53]=e.packages,t[54]=I):I=t[54],t[55]!==p||t[56]!==I?(A=i.jsx("ul",{className:"list-disc ml-2 mt-1",children:I.map((R,L)=>{const[P,T]=R;return i.jsxs("li",{className:de("flex items-center gap-1 font-mono text-sm",T==="installing"&&"font-semibold",T==="failed"&&"text-destructive",T==="installed"&&"text-accent-foreground",T==="installed"&&p==="failed"&&"text-muted-foreground"),children:[i.jsx(Xy,{status:T}),P]},L)})}),t[55]=p,t[56]=I,t[57]=A):A=t[57],t[58]!==n?(O=Object.keys(n).length>0&&i.jsx(nv,{packageLogs:n}),t[58]=n,t[59]=O):O=t[59],t[60]!==E||t[61]!==_||t[62]!==A||t[63]!==O?(D=i.jsxs("div",{className:E,children:[_,A,O]}),t[60]=E,t[61]=_,t[62]=A,t[63]=O,t[64]=D):D=t[64],t[65]!==D||t[66]!==g||t[67]!==N?(M=i.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-200 opacity-95 max-w-[600px] ",children:i.jsxs(Lo,{kind:g,className:"flex flex-col rounded pt-3 pb-4 px-5 overflow-auto max-h-[80vh] scrollbar-thin",children:[N,D]})}),t[65]=D,t[66]=g,t[67]=N,t[68]=M):M=t[68],M}return Fl(e),null},Xy=t=>{const e=z.c(4),{status:n}=t;switch(n){case"queued":{let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(ja,{size:"1rem"}),e[0]=o):o=e[0],o}case"installing":{let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx($r,{size:"1rem"}),e[1]=o):o=e[1],o}case"installed":{let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(Wl,{size:"1rem"}),e[2]=o):o=e[2],o}case"failed":{let o;return e[3]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx($t,{size:"1rem"}),e[3]=o):o=e[3],o}default:return Fl(n),null}},Qy=t=>{const e=z.c(10),{manager:n,packages:o,versions:r,clearPackageAlert:s}=t,{sendInstallMissingPackages:a}=qe();let l,c,d,u;return e[0]!==s||e[1]!==n||e[2]!==o||e[3]!==a||e[4]!==r?(l=async()=>{s();const h={...r};for(const m of o)h[m]=h[m]??"";await a({manager:n,versions:h}).catch(ov)},e[0]=s,e[1]=n,e[2]=o,e[3]=a,e[4]=r,e[5]=l):l=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx($r,{className:"w-4 h-4 mr-2"}),d=i.jsx("span",{className:"font-semibold",children:"Install"}),e[6]=c,e[7]=d):(c=e[6],d=e[7]),e[8]!==l?(u=i.jsxs(ye,{variant:"outline","data-testid":"install-packages-button",size:"sm",onClick:l,children:[c,d]}),e[8]=l,e[9]=u):u=e[9],u},Zy=()=>{const t=z.c(17),[e,n]=Qs(),{saveUserConfig:o}=qe();let r,s;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=Np(gj),t[0]=r):r=t[0],t[1]!==e?(s={resolver:r,defaultValues:e},t[1]=e,t[2]=s):s=t[2];const a=Sp(s);let l;t[3]!==o||t[4]!==n?(l=async p=>{await o({config:p}).then(()=>{n(p)})},t[3]=o,t[4]=n,t[5]=l):l=t[5];const c=l;let d,u,h,m;return t[6]!==a||t[7]!==c?(d=a.handleSubmit(c),t[6]=a,t[7]=c,t[8]=d):d=t[8],t[9]!==a.control?(u=i.jsx("div",{className:"flex flex-col gap-3",children:i.jsx(yp,{control:a.control,name:"package_management.manager",render:sv})}),t[9]=a.control,t[10]=u):u=t[10],t[11]!==d||t[12]!==u?(h=i.jsx("form",{onChange:d,className:"flex flex-col gap-5",children:u}),t[11]=d,t[12]=u,t[13]=h):h=t[13],t[14]!==a||t[15]!==h?(m=i.jsx(bj,{...a,children:h}),t[14]=a,t[15]=h,t[16]=m):m=t[16],m},ev=t=>{const e=z.c(12),{packageName:n,selectedExtras:o,onExtrasChange:r}=t,[s,a]=S.useState(!1),{isPending:l,error:c,data:d}=$f(n);let u;e[0]!==r||e[1]!==o?(u=(b,x)=>{r(x?[...o,b]:o.filter(f=>f!==b))},e[0]=r,e[1]=o,e[2]=u):u=e[2];const h=u,m=!l&&!c;let p;if(e[3]!==m||e[4]!==h||e[5]!==s||e[6]!==n||e[7]!==(d==null?void 0:d.extras)||e[8]!==o){const b=((d==null?void 0:d.extras)??[]).filter(av);let x;e[10]!==n?(x=i.jsx("span",{className:"shrink-0 flex-1",children:n}),e[10]=n,e[11]=x):x=e[11],p=i.jsxs("div",{className:"flex items-center max-w-72",children:[x,o.length>0?i.jsxs("span",{className:"flex items-center min-w-0 flex-1",children:[i.jsx("span",{className:"shrink-0",children:"["}),i.jsxs(Un,{open:s&&m,onOpenChange:f=>{m&&a(f)},children:[i.jsx(Wn,{asChild:!0,children:i.jsx("button",{className:"hover:bg-muted/50 rounded text-sm px-1 transition-colors border border-muted-foreground/30 hover:border-muted-foreground/60 min-w-0 flex-1 truncate text-left",title:`Selected extras: ${o.join(", ")}`,children:o.join(",")})}),i.jsxs($n,{align:"start",className:"w-64 p-0 max-h-96 flex flex-col",children:[o.length>0&&i.jsx("div",{className:"p-2 bg-popover border-b border-border",children:i.jsx("div",{className:"flex flex-wrap gap-1 p-1 min-h-[24px]",children:o.map(f=>i.jsxs("span",{className:"inline-flex items-center gap-1 px-1 py-0.5 text-sm font-mono border border-muted-foreground/30 hover:border-muted-foreground/60 rounded-sm cursor-pointer group transition-colors",onClick:()=>h(f,!1),children:[f,i.jsx($t,{className:"w-3 h-3 opacity-60 group-hover:opacity-100"})]},f))})}),i.jsx("div",{className:"overflow-y-auto flex-1",children:b.map(f=>i.jsx(B1,{checked:o.includes(f),onCheckedChange:g=>{h(f,g)},className:"font-mono text-sm",onSelect:iv,children:f},f))})]})]}),i.jsx("span",{className:"shrink-0",children:"]"})]}):b.length>0?i.jsxs(Un,{open:s&&m,onOpenChange:f=>{m&&a(f)},children:[i.jsx(Wn,{asChild:!0,children:i.jsx("button",{disabled:!m,className:de("hover:bg-muted/50 rounded text-sm ml-2 transition-colors border border-muted-foreground/30 hover:border-muted-foreground/60 h-5 w-5 flex items-center justify-center p-0",!m&&"opacity-50 cursor-not-allowed"),title:m?"Add extras":"Loading extras...",children:i.jsx(uc,{className:"w-3 h-3 shrink-0"})})}),i.jsxs($n,{align:"start",className:"w-64 p-0 max-h-96 flex flex-col",children:[i.jsx("div",{className:"p-2 bg-popover border-b border-border",children:i.jsx("span",{className:"text-muted-foreground italic text-sm",children:"Package extras"})}),i.jsx("div",{className:"overflow-y-auto flex-1",children:b.map(f=>i.jsx(B1,{checked:o.includes(f),onCheckedChange:g=>{h(f,g)},className:"font-mono text-sm",onSelect:lv,children:f},f))})]})]}):null]}),e[3]=m,e[4]=h,e[5]=s,e[6]=n,e[7]=d==null?void 0:d.extras,e[8]=o,e[9]=p}else p=e[9];return p},tv=t=>{const e=z.c(16),{value:n,onChange:o,packageName:r}=t,{error:s,isPending:a,data:l}=$f(r);if(s){let h,m,p;return e[0]!==o?(h=b=>o(b.target.value),e[0]=o,e[1]=h):h=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx("option",{value:"latest",children:"latest"}),e[2]=m):m=e[2],e[3]!==h||e[4]!==n?(p=i.jsx(pe,{content:"Failed to fetch package versions",children:i.jsx(jc,{value:n,onChange:h,disabled:!0,className:"inline-flex ml-2 w-24 text-ellipsis",children:m})}),e[3]=h,e[4]=n,e[5]=p):p=e[5],p}let c,d,u;return e[6]!==o?(c=h=>o(h.target.value),e[6]=o,e[7]=c):c=e[7],e[8]!==a||e[9]!==l?(d=a?i.jsx("option",{value:"latest",children:"latest"}):["latest",...l.versions.slice(0,100)].map(cv),e[8]=a,e[9]=l,e[10]=d):d=e[10],e[11]!==a||e[12]!==c||e[13]!==d||e[14]!==n?(u=i.jsx(jc,{value:n,onChange:c,disabled:a,className:"inline-flex ml-2 w-24 text-ellipsis",children:d}),e[11]=a,e[12]=c,e[13]=d,e[14]=n,e[15]=u):u=e[15],u},nv=t=>{const e=z.c(13),{packageLogs:n}=t,[o,r]=S.useState(!0);if(Object.keys(n).length===0)return null;let s,a,l,c,d;return e[0]!==o?(s=()=>r(!o),e[0]=o,e[1]=s):s=e[1],e[2]!==o?(a=o?i.jsx(Vn,{className:"w-4 h-4"}):i.jsx(fa,{className:"w-4 h-4"}),e[2]=o,e[3]=a):a=e[3],e[4]!==s||e[5]!==a?(l=i.jsxs("button",{onClick:s,className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",children:[a,"Installation logs"]}),e[4]=s,e[5]=a,e[6]=l):l=e[6],e[7]!==o||e[8]!==n?(c=o&&i.jsx("div",{className:"mt-3 space-y-3 w-full",children:Object.entries(n).map(dv)}),e[7]=o,e[8]=n,e[9]=c):c=e[9],e[10]!==l||e[11]!==c?(d=i.jsxs("div",{className:"mt-4 border-t border-border pt-4 w-full",children:[l,c]}),e[10]=l,e[11]=c,e[12]=d):d=e[12],d};function ov(t){Ye.error(t)}function rv(t){return i.jsx("option",{value:t,children:t},t)}function sv(t){const{field:e}=t;return i.jsxs(vp,{children:[i.jsx(wp,{children:i.jsx(jc,{"data-testid":"install-package-manager-select",onChange:n=>e.onChange(n.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:xj.map(rv)})}),i.jsx(Cp,{})]})}function av(t){return!/^(dev|test|testing)$/i.test(t)}function iv(t){return t.preventDefault()}function lv(t){return t.preventDefault()}function cv(t){return i.jsx("option",{value:t,children:t},t)}function dv(t){const[e,n]=t;return i.jsxs("div",{className:"w-full",children:[i.jsx("h4",{className:"font-mono text-sm font-medium mb-2 text-foreground",children:e}),i.jsx("div",{className:"border border-border rounded w-full",children:i.jsx("pre",{className:"p-3 text-xs font-mono bg-background max-h-64 overflow-y-auto text-muted-foreground whitespace-pre-wrap scrollbar-thin",children:n||"No logs available"})})]},e)}const uv=t=>{let{transform:e}=t;return{...e,x:0}},hv={threshold:{x:0,y:.1}},mv=he.memo(t=>{const e=z.c(23),{children:n,multiColumn:o}=t,{dropCellOverCell:r,dropCellOverColumn:s,moveColumn:a,compactColumns:l}=Ke(),[c,d]=S.useState(null),[u,h]=S.useState(null),[m]=yj();let p;e:{if(m.width==="columns"){p=vj.EMPTY;break e}let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M=[uv],e[0]=M):M=e[0],p=M}const b=p;let x,f;e[1]===Symbol.for("react.memo_cache_sentinel")?(x={activationConstraint:{distance:8}},e[1]=x):x=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(f={coordinateGetter:wx},e[2]=f):f=e[2];const g=(function(){for(var M=arguments.length,R=new Array(M),L=0;L<M;L++)R[L]=arguments[L];return S.useMemo(()=>[...R].filter(P=>P!=null),[...R])})(pu(bi,x),pu(pi,f));let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=M=>{d(M.active.id);const R=Mt();h(R.cellIds)},e[3]=y):y=e[3];const w=Ce(y);let j;e[4]!==u?(j=()=>{d(null),h(null)},e[4]=u,e[5]=j):j=e[5];const C=Ce(j);let N;e[6]!==c?(N=M=>{const R=M.droppableContainers.filter(fv);if(c&&Co(c))return di({...M,droppableContainers:R});const L=(W=>{let{droppableContainers:H,droppableRects:X,pointerCoordinates:q}=W;if(!q)return[];const Y=[];for(const J of H){const{id:V}=J,G=X.get(V);if(G&&Pb(q,G)){const U=li(G).reduce((Q,ee)=>Q+ai(q,ee),0),ne=Number((U/4).toFixed(4));Y.push({id:V,data:{droppableContainer:J,value:ne}})}}return Y.sort(ii)})({...M,droppableContainers:R}),P=ci(L.length>0?L:bu({...M,droppableContainers:R}),"id");if(!P)return[];Zt(Co(P),`Expected column id. Got: ${P}`);const T=Mt().cellIds.get(P);if(Zt(T,`Expected column. Got: ${P}`),T&&T.topLevelIds.length===0)return[{id:P}];const F=new Set(T.topLevelIds),$=di({...M,droppableContainers:M.droppableContainers.filter(W=>W.id!==P&&F.has(W.id))});if($.length>0){const W=$[0].id;return Zt(xl(W),`Expected cell id. Got: ${W}`),[{id:W}]}return[]},e[6]=c,e[7]=N):N=e[7];const k=N;let E;e[8]!==r||e[9]!==s||e[10]!==a?(E=M=>{const{active:R,over:L}=M,P=L==null?void 0:L.id;if(P!=null&&R.id!==P){if(xl(R.id)){if(Co(P))return void s({cellId:R.id,columnId:P});if(xl(P))return void r({cellId:R.id,overCellId:P})}Co(R.id)&&Co(P)&&a({column:R.id,overColumn:P})}},e[8]=r,e[9]=s,e[10]=a,e[11]=E):E=e[11];const _=Ce(E);let I;e[12]!==l?(I=M=>{const{active:R,over:L}=M;L!==null&&R.id!==L.id&&l()},e[12]=l,e[13]=I):I=e[13];const A=Ce(I),O=o?k:di;let D;return e[14]!==n||e[15]!==C||e[16]!==A||e[17]!==_||e[18]!==w||e[19]!==b||e[20]!==g||e[21]!==O?(D=i.jsx(lx,{autoScroll:hv,sensors:g,collisionDetection:O,modifiers:b,onDragEnd:A,onDragStart:w,onDragCancel:C,onDragOver:_,children:n}),e[14]=n,e[15]=C,e[16]=A,e[17]=_,e[18]=w,e[19]=b,e[20]=g,e[21]=O,e[22]=D):D=e[22],D});function xl(t){return typeof t=="string"&&!t.startsWith("tree_")}function Co(t){return typeof t=="string"&&t.startsWith("tree_")}function fv(t){return Co(t.id)}const pv=t=>{const e=z.c(13),{className:n,size:o,gap:r,durationMs:s}=t,a=o===void 0?8:o,l=r===void 0?"gap-1":r,c=s===void 0?1200:s,d=`${c}ms`;let u;e[0]!==d?(u={animationDuration:d},e[0]=d,e[1]=u):u=e[1];const h=u;let m,p,b,x;return e[2]!==n||e[3]!==l?(m=xa("flex",l,n),e[2]=n,e[3]=l,e[4]=m):m=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(p=[0,1,2],e[5]=p):p=e[5],e[6]!==h||e[7]!==c||e[8]!==a?(b=p.map(f=>i.jsx(wj,{width:a,height:a,className:"fill-current text-current animate-ellipsis-dot",style:{...h,animationDelay:c/3*f+"ms"}},f)),e[6]=h,e[7]=c,e[8]=a,e[9]=b):b=e[9],e[10]!==m||e[11]!==b?(x=i.jsx("div",{className:m,"aria-label":"Loading",children:b}),e[10]=m,e[11]=b,e[12]=x):x=e[12],x},Gf=t=>{const e=z.c(11),{title:n,children:o,show:r,delayMs:s,kind:a}=t,l=s===void 0?2e3:s,c=a===void 0?"info":a;if(!r)return null;let d,u,h;e[0]!==n?(d=n&&i.jsx("div",{className:"flex justify-between",children:i.jsx("span",{className:"font-bold text-lg flex items-center mb-1",children:n})}),e[0]=n,e[1]=d):d=e[1],e[2]!==o?(u=i.jsx("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:i.jsx("div",{children:o})}),e[2]=o,e[3]=u):u=e[3],e[4]!==c||e[5]!==d||e[6]!==u?(h=i.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-1/2 transform -translate-x-1/2 z-200 opacity-95",children:i.jsxs(Lo,{kind:c,className:"flex flex-col rounded py-2 px-4 animate-in slide-in-from-top w-fit",children:[d,u]})}),e[4]=c,e[5]=d,e[6]=u,e[7]=h):h=e[7];const m=h;let p;return e[8]!==m||e[9]!==l?(p=i.jsx(ba,{milliseconds:l,children:m}),e[8]=m,e[9]=l,e[10]=p):p=e[10],p},gv=()=>{const t=z.c(3),e=ie(kj),n=ie(jj);let o;return t[0]!==n||t[1]!==e?(o=e&&i.jsxs(i.Fragment,{children:[i.jsx(ba,{milliseconds:1e3,children:i.jsx("div",{className:"absolute top-4 m-0 flex items-center min-h-[28px] left-1/2 transform -translate-x-1/2 z-200 ",children:i.jsx(pe,{content:"Connecting to a marimo runtime",children:i.jsx("div",{className:"flex items-center",children:i.jsx(pv,{size:5,className:"text-yellow-500"})})})})}),i.jsx(Gf,{show:e,delayMs:5e3,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ya,{className:"h-4 w-4"}),i.jsx("p",{children:"Connecting to a marimo runtime ..."})]})})]})||n&&i.jsx(Gf,{show:n,kind:"danger",children:i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("p",{children:"Failed to connect."})})}),t[0]=n,t[1]=e,t[2]=o):o=t[2],o},qf=he.forwardRef((t,e)=>{const n=z.c(60),{columnId:o,canDelete:r,canMoveLeft:s,canMoveRight:a,footer:l,...c}=t;let d;n[0]!==o?(d={id:o},n[0]=o,n[1]=d):d=n[1];const{attributes:u,listeners:h,setNodeRef:m,transform:p,transition:b,isDragging:x,isOver:f}=qu(d);let g;n[2]!==p?(g=p?ca.Transform.toString({x:p.x,y:0,scaleX:1,scaleY:1}):void 0,n[2]=p,n[3]=g):g=n[3];const y=x?2:void 0;let w;n[4]!==g||n[5]!==y||n[6]!==b?(w={transform:g,transition:b,zIndex:y,position:"relative","--gutter-width":"50px"},n[4]=g,n[5]=y,n[6]=b,n[7]=w):w=n[7];const j=w,{deleteColumn:C,moveColumn:N,addColumn:k}=Ke(),E=xv;let _;n[8]!==o||n[9]!==N?(_=()=>N({column:o,overColumn:"_left_"}),n[8]=o,n[9]=N,n[10]=_):_=n[10];const I=!s;let A,O,D;n[11]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsx(f1,{className:"size-4"}),n[11]=A):A=n[11],n[12]!==_||n[13]!==I?(O=i.jsx(pe,{content:"Move column left",side:"top",delayDuration:300,children:i.jsx(ye,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",onClick:_,disabled:I,children:A})}),n[12]=_,n[13]=I,n[14]=O):O=n[14],n[15]!==o||n[16]!==N?(D=()=>N({column:o,overColumn:"_right_"}),n[15]=o,n[16]=N,n[17]=D):D=n[17];const M=!a;let R,L,P,T,F,$;n[18]===Symbol.for("react.memo_cache_sentinel")?(R=i.jsx(fa,{className:"size-4"}),n[18]=R):R=n[18],n[19]!==M||n[20]!==D?(L=i.jsx(pe,{content:"Move column right",side:"top",delayDuration:300,children:i.jsx(ye,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",onClick:D,disabled:M,children:R})}),n[19]=M,n[20]=D,n[21]=L):L=n[21],n[22]===Symbol.for("react.memo_cache_sentinel")?(P=i.jsx(Cj,{className:"size-4 opacity-0 group-hover:opacity-50 transition-opacity duration-200"}),n[22]=P):P=n[22],n[23]!==u||n[24]!==h?(T=i.jsx("div",{className:"flex gap-2 h-full grow cursor-grab active:cursor-grabbing items-center justify-center","data-testid":"column-drag-spacer",...u,...h,children:P}),n[23]=u,n[24]=h,n[25]=T):T=n[25],n[26]===Symbol.for("react.memo_cache_sentinel")?(F=i.jsx(Wn,{asChild:!0,children:i.jsx(ye,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",children:i.jsx(Ca,{className:"size-4"})})}),n[26]=F):F=n[26],n[27]!==o||n[28]!==C?($=()=>C({columnId:o}),n[27]=o,n[28]=C,n[29]=$):$=n[29];const W=!r;let H,X,q,Y,J,V;n[30]===Symbol.for("react.memo_cache_sentinel")?(H=i.jsx($t,{className:"mr-2 size-4"}),n[30]=H):H=n[30],n[31]!==$||n[32]!==W?(X=i.jsxs(Un,{children:[F,i.jsx($n,{align:"end",children:i.jsxs(lo,{onClick:$,disabled:W,children:[H,"Delete column"]})})]}),n[31]=$,n[32]=W,n[33]=X):X=n[33],n[34]!==k||n[35]!==o?(q=()=>{k({columnId:o}),requestAnimationFrame(E)},n[34]=k,n[35]=o,n[36]=q):q=n[36],n[37]===Symbol.for("react.memo_cache_sentinel")?(Y=i.jsx(uc,{className:"size-4"}),n[37]=Y):Y=n[37],n[38]!==q?(J=i.jsx(pe,{content:"Add column",side:"top",delayDuration:300,children:i.jsx(ye,{variant:"text",size:"xs",className:"hover:bg-(--gray-3) aspect-square p-0 w-7 h-7",onClick:q,children:Y})}),n[38]=q,n[39]=J):J=n[39],n[40]!==L||n[41]!==T||n[42]!==X||n[43]!==J||n[44]!==O?(V=i.jsxs("div",{className:"px-2 pt-3 pb-0 group flex items-center rounded-t-lg overflow-hidden",children:[O,L,T,X,J]}),n[40]=L,n[41]=T,n[42]=X,n[43]=J,n[44]=O,n[45]=V):V=n[45];const G=V;let U;n[46]!==e||n[47]!==m?(U=te=>{Ls(e,m)(te)},n[46]=e,n[47]=m,n[48]=U):U=n[48];const ne=de(x?"":c.className,x?"z-20":"z-1 hover:z-10 focus-within:z-10",f&&"bg-accent/20");let Q,ee;return n[49]!==G||n[50]!==c.children?(Q=i.jsxs("div",{className:"bg-(--slate-1) rounded-lg",children:[G,c.children]}),n[49]=G,n[50]=c.children,n[51]=Q):Q=n[51],n[52]!==l||n[53]!==x||n[54]!==c||n[55]!==j||n[56]!==U||n[57]!==ne||n[58]!==Q?(ee=i.jsxs("div",{tabIndex:-1,ref:U,...c,style:j,"data-is-dragging":x,className:ne,children:[Q,l]}),n[52]=l,n[53]=x,n[54]=c,n[55]=j,n[56]=U,n[57]=ne,n[58]=Q,n[59]=ee):ee=n[59],ee});qf.displayName="SortableColumn";const bv=S.memo(qf);function xv(){const t=document.getElementById("App");t&&t.scrollTo({left:t.scrollLeft+1e3,behavior:"smooth"})}const{getColumnWidth:yv,saveColumnWidth:vv}=Nj,Hf=S.memo(t=>{const e=z.c(20),n=S.useRef(null);if(t.width==="columns"){const s=t.canDelete,a=t.columnId,l=t.canMoveLeft,c=t.canMoveRight,d=t.footer;let u,h,m,p;return e[0]!==t.index?(u=yv(t.index),e[0]=t.index,e[1]=u):u=e[1],e[2]!==t.index?(h=b=>{vv(t.index,b)},e[2]=t.index,e[3]=h):h=e[3],e[4]!==t.children||e[5]!==u||e[6]!==h?(m=i.jsx(wv,{startingWidth:u,onResize:h,children:t.children}),e[4]=t.children,e[5]=u,e[6]=h,e[7]=m):m=e[7],e[8]!==t.canDelete||e[9]!==t.canMoveLeft||e[10]!==t.canMoveRight||e[11]!==t.columnId||e[12]!==t.footer||e[13]!==m?(p=i.jsx(bv,{tabIndex:-1,ref:n,canDelete:s,columnId:a,canMoveLeft:l,canMoveRight:c,className:"group/column",footer:d,children:m}),e[8]=t.canDelete,e[9]=t.canMoveLeft,e[10]=t.canMoveRight,e[11]=t.columnId,e[12]=t.footer,e[13]=m,e[14]=p):p=e[14],p}let o,r;return e[15]!==t.children?(o=i.jsx("div",{"data-testid":"cell-column",className:"flex flex-col gap-5",children:t.children}),e[15]=t.children,e[16]=o):o=e[16],e[17]!==t.footer||e[18]!==o?(r=i.jsxs(i.Fragment,{children:[o,t.footer]}),e[17]=t.footer,e[18]=o,e[19]=r):r=e[19],r});Hf.displayName="Column";const wv=t=>{const e=z.c(15),{startingWidth:n,onResize:o,children:r}=t;let s;e[0]!==o||e[1]!==n?(s={startingWidth:n,onResize:o},e[0]=o,e[1]=n,e[2]=s):s=e[2];const{resizableDivRef:a,handleRefs:l,style:c}=Sj(s),d=kv;let u,h,m,p;return e[3]!==l.left?(u=d(l.left),e[3]=l.left,e[4]=u):u=e[4],e[5]!==r||e[6]!==a||e[7]!==c?(h=i.jsx("div",{ref:a,className:"flex flex-col gap-5 box-content min-h-[100px] px-11 pt-3 pb-6 min-w-[500px] z-1",style:c,children:r}),e[5]=r,e[6]=a,e[7]=c,e[8]=h):h=e[8],e[9]!==l.right?(m=d(l.right),e[9]=l.right,e[10]=m):m=e[10],e[11]!==u||e[12]!==h||e[13]!==m?(p=i.jsxs("div",{className:"flex flex-row",children:[u,h,m]}),e[11]=u,e[12]=h,e[13]=m,e[14]=p):p=e[14],p};function kv(t){return i.jsx("div",{ref:t,className:`w-[3px] cursor-col-resize transition-colors duration-200 z-100
124
135
  relative before:content-[''] before:absolute before:inset-y-0 before:-left-[3px]
125
136
  before:right-[-3px] before:w-[9px] before:z-[-1]
126
137
  hover/column:bg-[var(--slate-3)] dark:hover/column:bg-[var(--slate-5)]
127
- hover/column:hover:bg-primary/60 dark:hover/column:hover:bg-primary/60`})}const Ev=t=>{const e=P.c(10),{width:n}=t,{banners:o}=jC(),{removeBanner:r}=CC();if(o.length===0)return null;const s=n==="columns"&&"sticky left-12 w-full max-w-[80vw]";let a,l,c;if(e[0]!==s?(a=ue("flex flex-col gap-4 mb-5 print:hidden",s),e[0]=s,e[1]=a):a=e[1],e[2]!==o||e[3]!==r){let d;e[5]!==r?(d=u=>i.jsxs(Lo,{kind:u.variant||"info",className:"flex flex-col rounded p-3",children:[i.jsxs("div",{className:"flex justify-between",children:[i.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[i.jsx(U1,{className:"w-5 h-5 inline-block mr-2"}),u.title]}),i.jsx(ye,{"data-testid":"remove-banner-button",variant:"text",size:"icon",onClick:()=>r(u.id),children:i.jsx(Vt,{className:"w-5 h-5"})})]}),i.jsxs("div",{className:"flex justify-between items-end",children:[i.jsx("span",{children:Ij({html:u.description})}),u.action==="restart"&&i.jsx(_v,{})]})]},u.id),e[5]=r,e[6]=d):d=e[6],l=o.map(d),e[2]=o,e[3]=r,e[4]=l}else l=e[4];return e[7]!==a||e[8]!==l?(c=i.jsx("div",{className:a,children:l}),e[7]=a,e[8]=l,e[9]=c):c=e[9],c},_v=()=>{const t=P.c(3),e=tu();let n,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(Tc,{className:"w-3 h-3 mr-2"}),t[0]=n):n=t[0],t[1]!==e?(o=i.jsxs(ye,{"data-testid":"restart-session-button",variant:"link",size:"xs",onClick:e,children:[n,"Restart"]}),t[1]=e,t[2]=o):o=t[2],o},Iv=Bt(t=>{const e=t(Gt);for(const n of e.cellIds.inOrderIds){const o=e.cellRuntime[n];if(o.status==="idle"&&o.consoleOutputs.some(r=>r.channel==="stdin"&&r.response===void 0))return!0}return!1}),Av=()=>{const t=P.c(3),e=Tv;if(!ie(Iv))return null;let n,o,r;if(t[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"flex justify-between",children:i.jsx("span",{className:"font-bold text-lg flex items-center mb-1",children:"Program waiting for input"})}),t[0]=n):n=t[0],t[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(s1,{className:"inline",children:"stdin"}),t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")){const s=i.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-1/2 transform -translate-x-1/2 z-200 opacity-95",children:i.jsxs(Lo,{kind:"info",className:"flex flex-col rounded py-2 px-4 animate-in slide-in-from-top w-fit",children:[n,i.jsx("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:i.jsx("div",{children:i.jsxs("p",{children:["The program is still running, but blocked on"," ",o,".",i.jsx(ye,{variant:"link",className:"h-auto font-normal",onClick:e,children:"Jump to the cell"})]})})})]})});r=i.jsx(ba,{milliseconds:2e3,children:s}),t[2]=r}else r=t[2];return r};function Tv(){const t=document.querySelector("[data-stdin-blocking]");t?(t.scrollIntoView({behavior:"smooth",block:"center"}),requestAnimationFrame(()=>{t.focus()})):He.error("No element with data-stdin-blocking found")}function Dv(){const t=setTimeout(Mv,100);return()=>clearTimeout(t)}function Mv(){requestAnimationFrame(Ov)}function Ov(){const t=(function(e){const n=e.match(/scrollTo=([^&]+)/),o=n==null?void 0:n[1];return o?decodeURIComponent(o.split("&")[0]):null})(window.location.hash);if(t)(function(e){var o,r;if(Yf)return;const n=document.querySelector(`[data-cell-name="${e}"]`);if(n){if(n.scrollIntoView({behavior:"smooth",block:"start"}),Yf=!0,n instanceof HTMLElement){n.focus();const{cellHandles:s}=Mt(),a=n.dataset.cellId;if(!a)return void He.error(`Missing cellId for cell with name ${e}`);const l=(r=(o=s[a])==null?void 0:o.current)==null?void 0:r.editorView;l&&l.focus()}}else He.warn(`Cannot focus cell with name ${e} because it was not found`),Kf()})(t);else try{Kf()}catch(e){const n=e;He.warn("Error focusing first editor",n)}}function Kf(){var o,r;const{cellIds:t,cellData:e,cellHandles:n}=Mt();for(const s of t.iterateTopLevelIds){const a=n[s];if(!((o=e[s])==null?void 0:o.config.hide_code)&&((r=a==null?void 0:a.current)!=null&&r.editorView))return void a.current.editorView.focus()}}let Yf=!1;const Rv=t=>{const e=P.c(8),n=ie(Aj),o=t.appConfig.width==="columns";let r,s,a;return e[0]!==t?(r=i.jsx(Lv,{...t}),e[0]=t,e[1]=r):r=e[1],e[2]!==n||e[3]!==r?(s=i.jsx(Gu,{id:"column-container",items:n,strategy:gx,children:r}),e[2]=n,e[3]=r,e[4]=s):s=e[4],e[5]!==o||e[6]!==s?(a=i.jsx(bv,{multiColumn:o,children:s}),e[5]=o,e[6]=s,e[7]=a):a=e[7],a},Lv=t=>{const e=P.c(28),{mode:n,userConfig:o,appConfig:r}=t,s=Ye(),{theme:a}=C1(),{toggleSidebarPanel:l}=kr();W1(Dv),st("global.focusTop",s.focusTopCell),st("global.focusBottom",s.focusBottomCell),st("global.toggleSidebar",l),st("global.foldCode",s.foldAll),st("global.unfoldCode",s.unfoldAll),st("global.formatAll",Pv),st("cell.hideCode",Bn.NOOP),st("cell.format",Bn.NOOP);const c=jc(),d=Tj(),u=c.getColumnIds(),h=s.scrollToTarget;let m,p;e[0]!==d||e[1]!==h?(m=()=>{d!==null&&h()},e[0]=d,e[1]=h,e[2]=m):m=e[2],e[3]!==c||e[4]!==d||e[5]!==h?(p=[c,d,h],e[3]=c,e[4]=d,e[5]=h,e[6]=p):p=e[6],S.useEffect(m,p);const b=NC;let x,f,g,y,w;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(ev,{}),f=i.jsx(Nx,{}),g=i.jsx(Av,{}),y=i.jsx(vv,{}),e[7]=x,e[8]=f,e[9]=g,e[10]=y):(x=e[7],f=e[8],g=e[9],y=e[10]),e[11]!==r.width?(w=i.jsx(Ev,{width:r.width}),e[11]=r.width,e[12]=w):w=e[12];const j=r.width==="columns"&&"grid grid-flow-col auto-cols-min gap-6";let C;e[13]!==j?(C=ue(j),e[13]=j,e[14]=C):C=e[14];const N=u.map((I,A)=>i.jsx(Fv,{columnId:I,index:A,columnsLength:u.length,appConfig:r,mode:n,userConfig:o,theme:a},I));let k,E,_;return e[15]!==C||e[16]!==N?(k=i.jsx("div",{className:C,children:N}),e[15]=C,e[16]=N,e[17]=k):k=e[17],e[18]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsx(Dj,{}),e[18]=E):E=e[18],e[19]!==b||e[20]!==r||e[21]!==w||e[22]!==k||e[23]!==x||e[24]!==f||e[25]!==g||e[26]!==y?(_=i.jsxs(b,{className:"pb-[40vh]",invisible:!1,appConfig:r,innerClassName:"pr-4",children:[x,f,g,y,w,k,E]}),e[19]=b,e[20]=r,e[21]=w,e[22]=k,e[23]=x,e[24]=f,e[25]=g,e[26]=y,e[27]=_):_=e[27],_},Fv=t=>{const e=P.c(54),{columnId:n,index:o,columnsLength:r,appConfig:s,mode:a,userConfig:l,theme:c}=t,d=jc();let u,h,m,p,b,x,f,g,y,w,j,C,N,k,E,_;if(e[0]!==s.width||e[1]!==d||e[2]!==n||e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==c||e[7]!==l){const I=d.get(n);let A;Zt(I,`Expected column for: ${n}`),e[22]!==d?(A=d.hasOnlyOneId(),e[22]=d,e[23]=A):A=e[23];const O=A;let D;e[24]!==d.inOrderIds?(D=d.inOrderIds.includes(Pr),e[24]=d.inOrderIds,e[25]=D):D=e[25];const M=D;h=Jf,j=n,C=o,N=o>0,k=o<r-1,p=s.width,b=r>1;const R=s.width==="columns"&&"opacity-0 group-hover/column:opacity-100";let L;e[26]!==R?(L=ue(R),e[26]=R,e[27]=L):L=e[27],e[28]!==n||e[29]!==L?(x=i.jsx(Bv,{columnId:n,className:L}),e[28]=n,e[29]=L,e[30]=x):x=e[30],u=Gu,m=`column-${o+1}`,f=I.topLevelIds,g=bx,e[31]!==M||e[32]!==o||e[33]!==a||e[34]!==c||e[35]!==l?(y=o===0&&M&&i.jsx(Wf,{cellId:Pr,theme:c,showPlaceholder:!1,canDelete:!0,mode:a,userConfig:l,isCollapsed:!1,collapseCount:0,canMoveX:!1},Pr),e[31]=M,e[32]=o,e[33]=a,e[34]=c,e[35]=l,e[36]=y):y=e[36],w=I.topLevelIds.map(z=>z===Pr?null:i.jsx(Wf,{cellId:z,theme:c,showPlaceholder:O,canDelete:!O,mode:a,userConfig:l,isCollapsed:I.isCollapsed(z),collapseCount:I.getCount(z),canMoveX:s.width==="columns"},z)),e[0]=s.width,e[1]=d,e[2]=n,e[3]=r,e[4]=o,e[5]=a,e[6]=c,e[7]=l,e[8]=u,e[9]=h,e[10]=m,e[11]=p,e[12]=b,e[13]=x,e[14]=f,e[15]=g,e[16]=y,e[17]=w,e[18]=j,e[19]=C,e[20]=N,e[21]=k}else u=e[8],h=e[9],m=e[10],p=e[11],b=e[12],x=e[13],f=e[14],g=e[15],y=e[16],w=e[17],j=e[18],C=e[19],N=e[20],k=e[21];return e[37]!==u||e[38]!==m||e[39]!==f||e[40]!==g||e[41]!==y||e[42]!==w?(E=i.jsxs(u,{id:m,items:f,strategy:g,children:[y,w]}),e[37]=u,e[38]=m,e[39]=f,e[40]=g,e[41]=y,e[42]=w,e[43]=E):E=e[43],e[44]!==h||e[45]!==p||e[46]!==b||e[47]!==x||e[48]!==E||e[49]!==j||e[50]!==C||e[51]!==N||e[52]!==k?(_=i.jsx(h,{columnId:j,index:C,canMoveLeft:N,canMoveRight:k,width:p,canDelete:b,footer:x,children:E}),e[44]=h,e[45]=p,e[46]=b,e[47]=x,e[48]=E,e[49]=j,e[50]=C,e[51]=N,e[52]=k,e[53]=_):_=e[53],_},Bv=t=>{const e=P.c(17),{columnId:n,className:o}=t,{createNewCell:r}=Ye(),[s,a]=Mj(!1),l=ie(mc),c=ie(Hp);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=ue("mb-0 rounded-none sm:px-4 md:px-5 lg:px-8 tracking-wide no-wrap whitespace-nowrap","hover:bg-accent hover:text-accent-foreground font-semibold uppercase text-xs"),e[0]=d):d=e[0];const u=d;let h;e[1]!==l||e[2]!==n||e[3]!==r||e[4]!==s||e[5]!==a.toggle||e[6]!==c?(h=()=>s?i.jsx(Oj,{onClose:a.toggle}):i.jsxs(i.Fragment,{children:[i.jsxs(ye,{className:u,variant:"text",size:"sm",disabled:!c,onClick:()=>r({cellId:{type:"__end__",columnId:n},before:!1}),children:[i.jsx(md,{className:"mr-2 size-4 shrink-0"}),"Python"]}),i.jsxs(ye,{className:u,variant:"text",size:"sm",disabled:!c,onClick:()=>{Gn({autoInstantiate:!0,createNewCell:r}),r({cellId:{type:"__end__",columnId:n},before:!1,code:Bo.markdown.defaultCode,hideCode:!0})},children:[i.jsx(pd,{className:"mr-2 size-4 shrink-0"}),"Markdown"]}),i.jsxs(ye,{className:u,variant:"text",size:"sm",disabled:!c,onClick:()=>{Gn({autoInstantiate:!0,createNewCell:r}),r({cellId:{type:"__end__",columnId:n},before:!1,code:Bo.sql.defaultCode})},children:[i.jsx(_o,{className:"mr-2 size-4 shrink-0"}),"SQL"]}),i.jsx(pe,{content:l?null:i.jsx("span",{children:"Enable via settings under AI Assist"}),delayDuration:100,asChild:!1,children:i.jsxs(ye,{className:u,variant:"text",size:"sm",disabled:!l||!c,onClick:a.toggle,children:[i.jsx(Rr,{className:"mr-2 size-4 shrink-0"}),"Generate with AI"]})})]}),e[1]=l,e[2]=n,e[3]=r,e[4]=s,e[5]=a.toggle,e[6]=c,e[7]=h):h=e[7];const m=h,p=!s&&"w-fit",b=s&&"opacity-100 w-full max-w-4xl shadow-lg shadow-(color:--blue-3)";let x,f,g;return e[8]!==o||e[9]!==p||e[10]!==b?(x=ue("shadow-sm border border-border rounded transition-all duration-200 overflow-hidden divide-x divide-border flex",p,b,o),e[8]=o,e[9]=p,e[10]=b,e[11]=x):x=e[11],e[12]!==m?(f=m(),e[12]=m,e[13]=f):f=e[13],e[14]!==x||e[15]!==f?(g=i.jsx("div",{className:"flex justify-center mt-4 pt-6 pb-32 group gap-4 w-full print:hidden",children:i.jsx("div",{className:x,children:f})}),e[14]=x,e[15]=f,e[16]=g):g=e[16],g};function Pv(){$p()}const zv=Rj(t=>a1().syncCellIds(t),400),Uv=(t,e)=>{Le.get(To)||t.isEmpty()||e.isEmpty()||jr(t.inOrderIds,e.inOrderIds)||zv({cell_ids:t.inOrderIds})},Xf=t=>{const e=P.c(70),{userConfig:n,appConfig:o,hideControls:r}=t,s=r!==void 0&&r;Lj(ga,Uv);const{setCells:a,mergeAllColumns:l,collapseAllCells:c,expandAllCells:d}=Ye(),u=ie(Sl),h=ie(Fj),m=ie(Bj),p=zl(),b=Ct(ei),{sendComponentValues:x,sendInterrupt:f}=qe(),g=u.mode==="edit",y=u.mode==="present",w=ie(Pj);let j,C;e[0]!==x?(j=()=>(lg.INSTANCE.start(x),Wv),e[0]=x,e[1]=j):j=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[2]=C):C=e[2],S.useEffect(j,C);const N=n.runtime.auto_instantiate;let k,E,_;e[3]!==a||e[4]!==b?(k=(te,_e)=>{a(te);const he=te.map($v),we=te.map(Vv),ke=te.map(Gv);b({names:he,codes:we,configs:ke,layout:_e})},e[3]=a,e[4]=b,e[5]=k):k=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(E=w1(),e[6]=E):E=e[6],e[7]!==k||e[8]!==n.runtime.auto_instantiate?(_={autoInstantiate:N,setCells:k,sessionId:E},e[7]=k,e[8]=n.runtime.auto_instantiate,e[9]=_):_=e[9];const{connection:I}=SC(_);let A,O;e[10]!==o.app_title||e[11]!==p?(A=()=>{document.title=o.app_title||Ot.basename(p??"")||"Untitled Notebook"},O=[o.app_title,p],e[10]=o.app_title,e[11]=p,e[12]=A,e[13]=O):(A=e[12],O=e[13]),S.useEffect(A,O);const D=la(o.width);let M,R;e[14]!==o.width||e[15]!==l||e[16]!==D?(M=()=>{D==="columns"&&o.width!=="columns"&&l()},e[14]=o.width,e[15]=l,e[16]=D,e[17]=M):M=e[17],e[18]!==o.width||e[19]!==l||e[20]!==h||e[21]!==D?(R=[o.width,D,l,h],e[18]=o.width,e[19]=l,e[20]=h,e[21]=D,e[22]=R):R=e[22],S.useEffect(M,R);const L=(function(){const te=P.c(2),_e=Ho();let he;return te[0]!==_e?(he=()=>_e(lk(Mt())),te[0]=_e,te[1]=he):he=te[1],Ce(he)})(),z=_d(),T=Ed();let F,$,W,G,X,H,Y;e[23]!==L?(F=()=>{L()},e[23]=L,e[24]=F):F=e[24],st("global.runStale",F),e[25]!==f?($=()=>{f()},e[25]=f,e[26]=$):$=e[26],st("global.interrupt",$),e[27]!==T?(W=()=>{T()},e[27]=T,e[28]=W):W=e[28],st("global.hideCode",W),e[29]!==z?(G=()=>{z()},e[29]=z,e[30]=G):G=e[30],st("global.runAll",G),e[31]!==c?(X=()=>{c()},e[31]=c,e[32]=X):X=e[32],st("global.collapseAllSections",X),e[33]!==d?(H=()=>{d()},e[33]=d,e[34]=H):H=e[34],st("global.expandAllSections",H),e[35]!==o||e[36]!==n||e[37]!==u.mode?(Y=i.jsx(Rv,{mode:u.mode,userConfig:n,appConfig:o}),e[35]=o,e[36]=n,e[37]=u.mode,e[38]=Y):Y=e[38];const K=Y,V=o.width;let q,U,ne,Q,ee,oe,se,ae;return e[39]===Symbol.for("react.memo_cache_sentinel")?(q=ue("pt-4 sm:pt-12 pb-2 mb-4 print:hidden z-50","sticky left-0"),e[39]=q):q=e[39],e[40]!==p||e[41]!==g?(U=g&&i.jsx("div",{className:"flex items-center justify-center container",children:i.jsx(yb,{filename:p})}),e[40]=p,e[41]=g,e[42]=U):U=e[42],e[43]!==I||e[44]!==U?(ne=i.jsx(_C,{connection:I,className:q,children:U}),e[43]=I,e[44]=U,e[45]=ne):ne=e[45],e[46]!==o||e[47]!==K||e[48]!==m||e[49]!==u.mode?(Q=m&&i.jsx(EC,{appConfig:o,mode:u.mode,children:K}),e[46]=o,e[47]=K,e[48]=m,e[49]=u.mode,e[50]=Q):Q=e[50],e[51]!==o.width||e[52]!==I||e[53]!==w||e[54]!==ne||e[55]!==Q?(ee=i.jsxs(IC,{connection:I,isRunning:w,width:V,children:[ne,Q]}),e[51]=o.width,e[52]=I,e[53]=w,e[54]=ne,e[55]=Q,e[56]=ee):ee=e[56],e[57]===Symbol.for("react.memo_cache_sentinel")?(oe=i.jsx(Ab,{}),e[57]=oe):oe=e[57],e[58]!==o||e[59]!==I||e[60]!==s||e[61]!==y||e[62]!==w||e[63]!==L||e[64]!==f||e[65]!==T?(se=!s&&i.jsx(va,{children:i.jsx(fb,{presenting:y,onTogglePresenting:T,onInterrupt:f,onRun:L,connectionState:I.state,running:w,appConfig:o})}),e[58]=o,e[59]=I,e[60]=s,e[61]=y,e[62]=w,e[63]=L,e[64]=f,e[65]=T,e[66]=se):se=e[66],e[67]!==ee||e[68]!==se?(ae=i.jsxs(i.Fragment,{children:[ee,oe,se]}),e[67]=ee,e[68]=se,e[69]=ae):ae=e[69],ae};function Wv(){lg.INSTANCE.stop()}function $v(t){return t.name}function Vv(t){return t.code}function Gv(t){return t.config}const Qf=t=>ie(zj)[t.capability]?t.children:null,At=S.forwardRef((t,e)=>{const n=P.c(18);let o,r,s,a,l;n[0]!==t?({children:o,tooltip:l,selected:a,className:r,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a,n[5]=l):(o=n[1],r=n[2],s=n[3],a=n[4],l=n[5]);const c=!a&&"hover:bg-(--sage-3)",d=a&&"bg-(--sage-4)";let u,h;n[6]!==r||n[7]!==c||n[8]!==d?(u=ue("h-full flex items-center p-2 text-sm shadow-inset font-mono cursor-pointer rounded",c,d,r),n[6]=r,n[7]=c,n[8]=d,n[9]=u):u=n[9],n[10]!==o||n[11]!==e||n[12]!==s||n[13]!==u?(h=i.jsx("div",{ref:e,className:u,...s,children:o}),n[10]=o,n[11]=e,n[12]=s,n[13]=u,n[14]=h):h=n[14];const m=h;if(l){let p;return n[15]!==m||n[16]!==l?(p=i.jsx(pe,{content:l,side:"top",delayDuration:200,children:m}),n[15]=m,n[16]=l,n[17]=p):p=n[17],p}return m});At.displayName="FooterItem";const qv=()=>{var p,b;const t=P.c(17),e=ie(Uj),n=ie(mc),o=((p=e==null?void 0:e.models)==null?void 0:p.chat_model)||Wj,r=((b=e==null?void 0:e.models)==null?void 0:b.edit_model)||o,{handleClick:s}=K1();if(!n){let x,f,g;return t[0]!==s?(x=()=>s("ai"),t[0]=s,t[1]=x):x=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Rr,{className:"h-4 w-4 opacity-60"}),t[2]=f):f=t[2],t[3]!==x?(g=i.jsx(At,{tooltip:"Assist is disabled",selected:!1,onClick:x,"data-testid":"footer-ai-disabled",children:f}),t[3]=x,t[4]=g):g=t[4],g}let a,l,c,d,u,h,m;return t[5]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("b",{children:"Chat model:"}),t[5]=a):a=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("br",{}),c=i.jsx("b",{children:"Edit model:"}),t[6]=l,t[7]=c):(l=t[6],c=t[7]),t[8]!==o||t[9]!==r?(d=i.jsxs(i.Fragment,{children:[a," ",o,l,c," ",r]}),t[8]=o,t[9]=r,t[10]=d):d=t[10],t[11]!==s?(u=()=>s("ai"),t[11]=s,t[12]=u):u=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Rr,{className:"h-4 w-4"}),t[13]=h):h=t[13],t[14]!==d||t[15]!==u?(m=i.jsx(At,{tooltip:d,onClick:u,selected:!1,"data-testid":"footer-ai-enabled",children:h}),t[14]=d,t[15]=u,t[16]=m):m=t[16],m},Hv=()=>{const t=P.c(26),e=ie(Nt).state,n=j1();let o,r;t[0]!==e||t[1]!==n?(o=async()=>{if(e===ht.OPEN){if(Qt())return{isHealthy:!0,lastChecked:new Date,error:void 0};try{return{isHealthy:await n.isHealthy(),lastChecked:new Date,error:void 0}}catch(j){const C=j;return{isHealthy:!1,lastChecked:new Date,error:C instanceof Error?C.message:"Unknown error"}}}},r=[n,e],t[0]=e,t[1]=n,t[2]=o,t[3]=r):(o=t[2],r=t[3]);const{isFetching:s,error:a,data:l,refetch:c}=wr(o,r),d=e===ht.OPEN?3e4:null;let u,h;t[4]!==d?(u={delayMs:d,whenVisible:!0},t[4]=d,t[5]=u):u=t[5],zr(c,u),t[6]!==e||t[7]!==l||t[8]!==a?(h=()=>[Ll(e.toLowerCase()),l!=null&&l.lastChecked?l.isHealthy?"\u2713 Healthy":"\u2717 Unhealthy":"Health: Unknown",a?`Error: ${a}`:""].filter(Boolean).join(`
128
- `),t[6]=e,t[7]=l,t[8]=a,t[9]=h):h=t[9];const m=h;let p;t[10]!==e||t[11]!==(l==null?void 0:l.isHealthy)||t[12]!==(l==null?void 0:l.lastChecked)||t[13]!==s?(p=()=>s||e===ht.CONNECTING?i.jsx(ya,{size:"small"}):e===ht.CLOSING?i.jsx(ya,{className:"text-destructive",size:"small"}):e===ht.OPEN?l!=null&&l.isHealthy?i.jsx(Na,{className:"w-4 h-4 text-(--green-9)"}):l!=null&&l.lastChecked?i.jsx(U1,{className:"w-4 h-4 text-(--yellow-9)"}):i.jsx(Na,{className:"w-4 h-4"}):i.jsx(Ur,{className:"w-4 h-4 text-red-500"}),t[10]=e,t[11]=l==null?void 0:l.isHealthy,t[12]=l==null?void 0:l.lastChecked,t[13]=s,t[14]=p):p=t[14];const b=p,x=m();let f,g,y,w;return t[15]!==e?(f=e===ht.OPEN&&i.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Click to refresh health status"}),t[15]=e,t[16]=f):f=t[16],t[17]!==x||t[18]!==f?(g=i.jsxs("div",{className:"text-sm whitespace-pre-line",children:[x,f]}),t[17]=x,t[18]=f,t[19]=g):g=t[19],t[20]!==b?(y=b(),t[20]=b,t[21]=y):y=t[21],t[22]!==c||t[23]!==g||t[24]!==y?(w=i.jsx(At,{tooltip:g,selected:!1,onClick:c,"data-testid":"footer-backend-status",children:y}),t[22]=c,t[23]=g,t[24]=y,t[25]=w):w=t[25],w},Jv=t=>{const e=P.c(3);let n,o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("path",{d:"M205.28 31.36c14.096 14.88 20.016 35.2 22.512 63.68c6.626 0 12.805 1.47 16.976 7.152l7.792 10.56A17.55 17.55 0 0 1 256 123.2v28.688c-.008 3.704-1.843 7.315-4.832 9.504C215.885 187.222 172.35 208 128 208c-49.066 0-98.19-28.273-123.168-46.608c-2.989-2.189-4.825-5.8-4.832-9.504V123.2c0-3.776 1.2-7.424 3.424-10.464l7.792-10.544c4.173-5.657 10.38-7.152 16.992-7.152c2.496-28.48 8.4-48.8 22.512-63.68C77.331 3.165 112.567.06 127.552 0H128c14.72 0 50.4 2.88 77.28 31.36m-77.264 47.376c-3.04 0-6.544.176-10.272.544c-1.312 4.896-3.248 9.312-6.08 12.128c-11.2 11.2-24.704 12.928-31.936 12.928c-6.802 0-13.927-1.42-19.744-5.088c-5.502 1.808-10.786 4.415-11.136 10.912c-.586 12.28-.637 24.55-.688 36.824c-.026 6.16-.05 12.322-.144 18.488c.024 3.579 2.182 6.903 5.44 8.384C79.936 185.92 104.976 192 128.016 192c23.008 0 48.048-6.08 74.512-18.144c3.258-1.48 5.415-4.805 5.44-8.384c.317-18.418.062-36.912-.816-55.312h.016c-.342-6.534-5.648-9.098-11.168-10.912c-5.82 3.652-12.927 5.088-19.728 5.088c-7.232 0-20.72-1.728-31.936-12.928c-2.832-2.816-4.768-7.232-6.08-12.128a106 106 0 0 0-10.24-.544m-26.941 43.93c5.748 0 10.408 4.66 10.408 10.409v19.183c0 5.749-4.66 10.409-10.408 10.409s-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408m53.333 0c5.749 0 10.409 4.66 10.409 10.409v19.183c0 5.749-4.66 10.409-10.409 10.409c-5.748 0-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408M81.44 28.32c-11.2 1.12-20.64 4.8-25.44 9.92c-10.4 11.36-8.16 40.16-2.24 46.24c4.32 4.32 12.48 7.2 21.28 7.2c6.72 0 19.52-1.44 30.08-12.16c4.64-4.48 7.52-15.68 7.2-27.04c-.32-9.12-2.88-16.64-6.72-19.84c-4.16-3.68-13.6-5.28-24.16-4.32m68.96 4.32c-3.84 3.2-6.4 10.72-6.72 19.84c-.32 11.36 2.56 22.56 7.2 27.04c10.56 10.72 23.36 12.16 30.08 12.16c8.8 0 16.96-2.88 21.28-7.2c5.92-6.08 8.16-34.88-2.24-46.24c-4.8-5.12-14.24-8.8-25.44-9.92c-10.56-.96-20 .64-24.16 4.32M128 56c-2.56 0-5.6.16-8.96.48c.32 1.76.48 3.68.64 5.76c0 1.44 0 2.88-.16 4.48c3.2-.32 5.92-.32 8.48-.32s5.28 0 8.48.32c-.16-1.6-.16-3.04-.16-4.48c.16-2.08.32-4 .64-5.76c-3.36-.32-6.4-.48-8.96-.48"}),e[0]=n):n=e[0],e[1]!==t?(o=i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1.24em",height:"1em",viewBox:"0 0 256 208",fill:"currentColor",...t,children:n}),e[1]=t,e[2]=o):o=e[2],o},Kv=Bt(t=>t($j).completion.copilot),Yv=()=>{const t=P.c(1);if(ie(Kv)==="github"){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(Xv,{}),t[0]=e):e=t[0],e}return null},Zf=He.get("[copilot-status-bar]"),Xv=()=>{const t=ie(Y1),e=ie(fC)!==null,{handleClick:n}=K1(),o=()=>n("ai"),r=t?"Ready":"Not connected",s=Ct(Y1),a=Ct(pC);return W1(()=>{const l=J1();let c=!0;return(async()=>{try{if(await l.initializePromise.catch(u=>{throw Zf.error("Failed to initialize",u),l.close(),u}),!c)return;const d=await l.signedIn();if(!c)return;s(d),a(d?"signedIn":"signedOut")}catch(d){if(!c)return;Zf.warn("Connection failed",d),s(!1),a("connectionError"),ze({title:"GitHub Copilot Connection Error",description:"Failed to connect to GitHub Copilot. Check settings and try again.",variant:"danger",action:i.jsx(ye,{variant:"link",onClick:o,children:"Settings"})})}})(),()=>{c=!1}}),i.jsx(At,{tooltip:i.jsxs(i.Fragment,{children:[i.jsx("b",{children:"GitHub Copilot:"})," ",r]}),selected:!1,onClick:o,"data-testid":"footer-copilot-status",children:i.jsx("span",{children:e?i.jsx(ya,{className:"h-4 w-4"}):i.jsx(Jv,{className:ue("h-4 w-4",!t&&"opacity-60")})})})},Qv=()=>{const t=P.c(18),[e,n]=S.useState(0),o=ie(Nt),{getUsageStats:r}=qe();let s,a,l,c;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>n(nw),a={delayMs:1e4,whenVisible:!0},t[0]=s,t[1]=a):(s=t[0],a=t[1]),zr(s,a),t[2]!==o.state||t[3]!==r?(l=async()=>Qt()||o.state!==ht.OPEN?null:r(),t[2]=o.state,t[3]=r,t[4]=l):l=t[4],t[5]!==o.state||t[6]!==e?(c=[e,o.state],t[5]=o.state,t[6]=e,t[7]=c):c=t[7];const{data:d}=wr(l,c);let u,h,m,p;return t[8]!==d?(u=(d==null?void 0:d.gpu)&&d.gpu.length>0&&i.jsx(tw,{gpus:d.gpu}),t[8]=d,t[9]=u):u=t[9],t[10]!==d?(h=d&&i.jsx(Zv,{memory:d.memory,kernel:d.kernel,server:d.server}),t[10]=d,t[11]=h):h=t[11],t[12]!==d?(m=d&&i.jsx(ew,{cpu:d.cpu}),t[12]=d,t[13]=m):m=t[13],t[14]!==u||t[15]!==h||t[16]!==m?(p=i.jsxs("div",{className:"flex gap-2 items-center px-1",children:[u,h,m]}),t[14]=u,t[15]=h,t[16]=m,t[17]=p):p=t[17],p},Zv=t=>{const e=P.c(36),{memory:n,kernel:o,server:r}=t,{percent:s,total:a,available:l}=n;let c;e[0]!==s?(c=Math.round(s),e[0]=s,e[1]=c):c=e[1];const d=c;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u={maximumFractionDigits:2},e[2]=u):u=e[2];const h=wa(u);let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m={maximumFractionDigits:0},e[3]=m):m=e[3];const p=wa(m);let b;e[4]!==h||e[5]!==p?(b=D=>D>1073741824?`${h.format(D/1073741824)} GB`:`${p.format(D/1048576)} MB`,e[4]=h,e[5]=p,e[6]=b):b=e[6];const x=b;let f;e[7]!==h?(f=D=>h.format(D/1073741824),e[7]=h,e[8]=f):f=e[8];const g=f;let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx("b",{children:"computer memory:"}),e[9]=y):y=e[9];const w=a-l;let j,C,N,k,E,_,I,A,O;return e[10]!==g||e[11]!==w?(j=g(w),e[10]=g,e[11]=w,e[12]=j):j=e[12],e[13]!==g||e[14]!==a?(C=g(a),e[13]=g,e[14]=a,e[15]=C):C=e[15],e[16]!==d||e[17]!==j||e[18]!==C?(N=i.jsxs("span",{children:[y," ",j," /"," ",C," GB (",d,"%)"]}),e[16]=d,e[17]=j,e[18]=C,e[19]=N):N=e[19],e[20]!==x||e[21]!==r?(k=(r==null?void 0:r.memory)&&i.jsxs("span",{children:[i.jsx("b",{children:"marimo server:"})," ",x(r.memory)]}),e[20]=x,e[21]=r,e[22]=k):k=e[22],e[23]!==x||e[24]!==o?(E=(o==null?void 0:o.memory)&&i.jsxs("span",{children:[i.jsx("b",{children:"kernel:"})," ",x(o.memory)]}),e[23]=x,e[24]=o,e[25]=E):E=e[25],e[26]!==N||e[27]!==k||e[28]!==E?(_=i.jsxs("div",{className:"flex flex-col gap-1",children:[N,k,E]}),e[26]=N,e[27]=k,e[28]=E,e[29]=_):_=e[29],e[30]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(sd,{className:"w-4 h-4"}),e[30]=I):I=e[30],e[31]!==d?(A=i.jsxs("div",{className:"flex items-center gap-1","data-testid":"memory-usage-bar",children:[I,i.jsx(yl,{percent:d,colorClassName:"bg-primary"})]}),e[31]=d,e[32]=A):A=e[32],e[33]!==_||e[34]!==A?(O=i.jsx(pe,{delayDuration:200,content:_,children:A}),e[33]=_,e[34]=A,e[35]=O):O=e[35],O},ew=t=>{const e=P.c(11),{cpu:n}=t,{percent:o}=n;let r;e[0]!==o?(r=Math.round(o),e[0]=o,e[1]=r):r=e[1];const s=r;let a,l,c,d,u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("b",{children:"CPU:"}),e[2]=a):a=e[2],e[3]!==s?(l=i.jsxs("span",{children:[a," ",s,"%"]}),e[3]=s,e[4]=l):l=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(gC,{className:"w-4 h-4"}),e[5]=c):c=e[5],e[6]!==s?(d=i.jsxs("div",{className:"flex items-center gap-1","data-testid":"cpu-bar",children:[c,i.jsx(yl,{percent:s,colorClassName:"bg-primary"})]}),e[6]=s,e[7]=d):d=e[7],e[8]!==l||e[9]!==d?(u=i.jsx(pe,{delayDuration:200,content:l,children:d}),e[8]=l,e[9]=d,e[10]=u):u=e[10],u},tw=t=>{const e=P.c(20),{gpus:n}=t;let o;e[0]!==n?(o=Math.round(n.reduce(ow,0)/n.length),e[0]=n,e[1]=o):o=e[1];const r=o;let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s={maximumFractionDigits:2},e[2]=s):s=e[2];const a=wa(s);let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l={maximumFractionDigits:0},e[3]=l):l=e[3];const c=wa(l);let d;e[4]!==a||e[5]!==c?(d=f=>f>1073741824?`${a.format(f/1073741824)} GB`:`${c.format(f/1048576)} MB`,e[4]=a,e[5]=c,e[6]=d):d=e[6];const u=d;let h,m,p,b,x;if(e[7]!==u||e[8]!==n){let f;e[10]!==u?(f=g=>i.jsxs("span",{children:[i.jsxs("b",{children:["GPU ",g.index," (",g.name,"):"]})," ",u(g.memory.used)," / ",u(g.memory.total)," (",Math.round(g.memory.percent),"%)"]},g.index),e[10]=u,e[11]=f):f=e[11],h=n.map(f),e[7]=u,e[8]=n,e[9]=h}else h=e[9];return e[12]!==h?(m=i.jsx("div",{className:"flex flex-col gap-1",children:h}),e[12]=h,e[13]=m):m=e[13],e[14]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(id,{className:"w-4 h-4"}),e[14]=p):p=e[14],e[15]!==r?(b=i.jsxs("div",{className:"flex items-center gap-1","data-testid":"gpu-bar",children:[p,i.jsx(yl,{percent:r,colorClassName:"bg-(--grass-9)"})]}),e[15]=r,e[16]=b):b=e[16],e[17]!==m||e[18]!==b?(x=i.jsx(pe,{delayDuration:200,content:m,children:b}),e[17]=m,e[18]=b,e[19]=x):x=e[19],x},yl=t=>{const e=P.c(7),{percent:n,colorClassName:o}=t;let r;e[0]!==o?(r=ue("h-full bg-primary",o),e[0]=o,e[1]=r):r=e[1];const s=`${n}%`;let a,l;return e[2]!==s?(a={width:s},e[2]=s,e[3]=a):a=e[3],e[4]!==r||e[5]!==a?(l=i.jsx("div",{className:"h-3 w-20 bg-(--slate-4) rounded-lg overflow-hidden border",children:i.jsx("div",{className:r,style:a})}),e[4]=r,e[5]=a,e[6]=l):l=e[6],l};function nw(t){return t+1}function ow(t,e){return t+e.memory.percent}const ep=Bt(!1);function vl(t,e,n=new Set){if(n.has(t))return new Set;n.add(t);const o=new Set;for(const r of e(t)){o.add(r);for(const s of vl(r,e,n))o.add(s)}return o}const rw=Bt(t=>{const e=t(ga),n=t(Jp);return(function(o,r){var l,c,d;const s=new Map;for(const u of o)s.set(u,{variables:new Set,parents:new Set,children:new Set});for(const u of Object.values(r))if(u.dataType!=="module")for(const h of u.declaredBy){(l=s.get(h))==null||l.variables.add(u.name);for(const m of u.usedBy)h!==m&&((c=s.get(m))==null||c.parents.add(h),(d=s.get(h))==null||d.children.add(m))}const a={};for(const[u,h]of s.entries())a[u]={parents:h.parents,children:h.children,variables:[...h.variables],ancestors:vl(u,m=>{var p;return((p=s.get(m))==null?void 0:p.parents)??new Set}),descendants:vl(u,m=>{var p;return((p=s.get(m))==null?void 0:p.children)??new Set})};return a})(e.inOrderIds,n)});function sw(t,e){return e?t.usedBy.includes(e.id)||t.declaredBy.includes(e.id)?!0:t.declaredBy.some(n=>e.graph.parents.has(n))?t.usedBy.some(n=>e.graph.parents.has(n)):!!t.declaredBy.some(n=>e.graph.children.has(n)):!1}const aw=()=>{const t=P.c(6),[e,n]=_n(ep);let o,r,s;return t[0]!==n?(o=()=>n(iw),t[0]=n,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(rd,{className:"h-4 w-4"}),t[2]=r):r=t[2],t[3]!==e||t[4]!==o?(s=i.jsx(At,{tooltip:"Toggle Minimap",selected:e,onClick:o,"data-testid":"footer-minimap",children:r}),t[3]=e,t[4]=o,t[5]=s):s=t[5],s};function iw(t){return!t}const lw=()=>{const t=P.c(13),e=ie(yo),[n,o]=_n(k1),[r,s]=S.useState(!1);if(!pa()||e==="disabled")return null;const a=e?"Real-time collaboration active":"Connecting to real-time collaboration";let l,c,d,u,h,m;return t[0]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(xd,{className:"w-4 h-4"}),t[0]=l):l=t[0],t[1]!==a?(c=i.jsx(pc,{asChild:!0,children:i.jsx(At,{tooltip:a,selected:!1,"data-testid":"footer-rtc-status",children:l})}),t[1]=a,t[2]=c):c=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsxs("div",{className:"space-y-2",children:[i.jsx("h4",{className:"font-medium leading-none",children:"Username"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Set your username for real-time collaboration"})]}),t[3]=d):d=t[3],t[4]!==o?(u=p=>o(p.target.value),t[4]=o,t[5]=u):u=t[5],t[6]!==u||t[7]!==n?(h=i.jsx(Kl,{className:"w-80",children:i.jsxs("div",{className:"space-y-4",children:[d,i.jsx(ao,{value:n,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",onChange:u,placeholder:"Enter your username"})]})}),t[6]=u,t[7]=n,t[8]=h):h=t[8],t[9]!==r||t[10]!==c||t[11]!==h?(m=i.jsxs(ta,{open:r,onOpenChange:s,children:[c,h]}),t[9]=r,t[10]=c,t[11]=h,t[12]=m):m=t[12],m},cw=t=>{const e=P.c(104),{className:n}=t,{saveUserConfig:o}=qe(),[r,s]=Vj(),a=Qs()[0],[l,c]=S.useState(!1);let d,u,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const ve=window.matchMedia("(min-width: 768px)"),be=()=>{ve.matches&&c(!1)};return ve.addEventListener("change",be),()=>ve.removeEventListener("change",be)},u=[],e[0]=d,e[1]=u):(d=e[0],u=e[1]),S.useEffect(d,u),e[2]!==a||e[3]!==o||e[4]!==s?(h=async ve=>{const be={...a,runtime:{...a.runtime,auto_instantiate:ve}};await o({config:be}).then(()=>s(be))},e[2]=a,e[3]=o,e[4]=s,e[5]=h):h=e[5];const m=h;let p;e[6]!==o||e[7]!==s||e[8]!==r?(p=async ve=>{const be={...r,runtime:{...r.runtime,on_cell_change:ve?"autorun":"lazy"}};await o({config:be}).then(()=>s(be))},e[6]=o,e[7]=s,e[8]=r,e[9]=p):p=e[9];const b=p;let x;e[10]!==o||e[11]!==s||e[12]!==r?(x=async ve=>{const be={...r,runtime:{...r.runtime,auto_reload:ve}};await o({config:be}).then(()=>s(be))},e[10]=o,e[11]=s,e[12]=r,e[13]=x):x=e[13];const f=x;let g;e[14]!==a.runtime.auto_instantiate||e[15]!==a.runtime.auto_reload||e[16]!==a.runtime.on_cell_change?(g=!a.runtime.auto_instantiate&&a.runtime.on_cell_change==="lazy"&&(Qt()||a.runtime.auto_reload!=="autorun"),e[14]=a.runtime.auto_instantiate,e[15]=a.runtime.auto_reload,e[16]=a.runtime.on_cell_change,e[17]=g):g=e[17];const y=g;let w;e[18]!==n?(w=ue("flex items-center",n),e[18]=n,e[19]=w):w=e[19];const j=a.runtime.auto_instantiate?"Disable autorun on startup":"Enable autorun on startup";let C,N,k;e[20]!==a.runtime.auto_instantiate||e[21]!==m?(C=()=>m(!a.runtime.auto_instantiate),e[20]=a.runtime.auto_instantiate,e[21]=m,e[22]=C):C=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(N=i.jsx("span",{children:"on startup: "}),e[23]=N):N=e[23],e[24]!==a.runtime.auto_instantiate?(k=a.runtime.auto_instantiate?i.jsx(_t,{size:14}):i.jsx(Et,{size:14}),e[24]=a.runtime.auto_instantiate,e[25]=k):k=e[25];const E=a.runtime.auto_instantiate?"autorun":"lazy";let _,I,A,O;e[26]!==E?(_=i.jsx("span",{children:E}),e[26]=E,e[27]=_):_=e[27],e[28]!==k||e[29]!==_?(I=i.jsxs("div",{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[N,k,_]}),e[28]=k,e[29]=_,e[30]=I):I=e[30],e[31]!==I||e[32]!==j||e[33]!==C?(A=i.jsx(zo,{name:"runtime.auto_instantiate",children:i.jsx(At,{tooltip:j,selected:!1,onClick:C,"data-testid":"footer-autorun-startup",children:I})}),e[31]=I,e[32]=j,e[33]=C,e[34]=A):A=e[34],e[35]===Symbol.for("react.memo_cache_sentinel")?(O=i.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[35]=O):O=e[35];const D=a.runtime.on_cell_change==="autorun"?"Disable autorun":"Enable autorun";let M,R,L,z,T,F,$,W,G,X,H,Y,K;e[36]!==a.runtime.on_cell_change||e[37]!==b?(M=()=>b(a.runtime.on_cell_change!=="autorun"),e[36]=a.runtime.on_cell_change,e[37]=b,e[38]=M):M=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(R=i.jsx("span",{children:"on cell change: "}),e[39]=R):R=e[39],e[40]!==a.runtime.on_cell_change?(L=i.jsxs("div",{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[R,a.runtime.on_cell_change==="autorun"?i.jsx(_t,{size:14}):i.jsx(Et,{size:14}),i.jsx("span",{children:a.runtime.on_cell_change})]}),e[40]=a.runtime.on_cell_change,e[41]=L):L=e[41],e[42]!==D||e[43]!==M||e[44]!==L?(z=i.jsx(zo,{name:"runtime.on_cell_change",children:i.jsx(At,{tooltip:D,selected:!1,onClick:M,"data-testid":"footer-autorun-cell-change",children:L})}),e[42]=D,e[43]=M,e[44]=L,e[45]=z):z=e[45],e[46]!==a.runtime.auto_reload||e[47]!==f?(T=!Qt()&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"border-r border-border h-6 mx-1"}),i.jsx(zo,{name:"runtime.auto_reload",children:i.jsx(At,{tooltip:null,selected:!1,"data-testid":"footer-module-reload",children:i.jsxs(zn,{children:[i.jsxs(Un,{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[i.jsx("span",{children:"on module change: "}),a.runtime.auto_reload==="off"&&i.jsx(Ur,{size:14}),a.runtime.auto_reload==="lazy"&&i.jsx(Et,{size:14}),a.runtime.auto_reload==="autorun"&&i.jsx(_t,{size:14}),i.jsx("span",{children:a.runtime.auto_reload}),i.jsx($n,{size:14})]}),i.jsx(Wn,{children:["off","lazy","autorun"].map(ve=>i.jsxs(lo,{onClick:()=>f(ve),children:[ve==="off"&&i.jsx(Ur,{size:14,className:"mr-2 text-muted-foreground"}),ve==="lazy"&&i.jsx(Et,{size:14,className:"mr-2 text-muted-foreground"}),ve==="autorun"&&i.jsx(_t,{size:14,className:"mr-2 text-muted-foreground"}),ve]},ve))})]})})})]}),e[46]=a.runtime.auto_reload,e[47]=f,e[48]=T):T=e[48],e[49]!==A||e[50]!==z||e[51]!==T?(F=i.jsxs("div",{className:"hidden md:flex md:items-center",children:[A,O,z,T]}),e[49]=A,e[50]=z,e[51]=T,e[52]=F):F=e[52],e[53]!==y?($=y?i.jsx(Et,{size:16,className:"text-muted-foreground"}):i.jsx(_t,{size:16,className:"text-amber-500"}),e[53]=y,e[54]=$):$=e[54],e[55]===Symbol.for("react.memo_cache_sentinel")?(W=i.jsx($n,{size:14}),e[55]=W):W=e[55],e[56]!==$?(G=i.jsx(Un,{asChild:!0,children:i.jsx(At,{tooltip:"Runtime reactivity",selected:!1,"data-testid":"footer-runtime-settings",children:i.jsxs("div",{className:"flex items-center gap-1",children:[$,W]})})}),e[56]=$,e[57]=G):G=e[57],e[58]===Symbol.for("react.memo_cache_sentinel")?(X=i.jsx(Cp,{children:"Runtime reactivity"}),H=i.jsx(En,{}),e[58]=X,e[59]=H):(X=e[58],H=e[59]),e[60]!==a.runtime.auto_instantiate?(Y=a.runtime.auto_instantiate?i.jsx(_t,{size:14,className:"text-amber-500"}):i.jsx(Et,{size:14,className:"text-muted-foreground"}),e[60]=a.runtime.auto_instantiate,e[61]=Y):Y=e[61],e[62]===Symbol.for("react.memo_cache_sentinel")?(K=i.jsx("div",{className:"text-sm font-medium",children:"On startup"}),e[62]=K):K=e[62];const V=a.runtime.auto_instantiate?"autorun":"lazy";let q,U,ne,Q,ee,oe,se,ae,te;e[63]!==V?(q=i.jsxs("div",{children:[K,i.jsx("div",{className:"text-xs text-muted-foreground",children:V})]}),e[63]=V,e[64]=q):q=e[64],e[65]!==Y||e[66]!==q?(U=i.jsxs("div",{className:"flex items-center space-x-2",children:[Y,q]}),e[65]=Y,e[66]=q,e[67]=U):U=e[67],e[68]!==a.runtime.auto_instantiate||e[69]!==m?(ne=i.jsx(fc,{checked:a.runtime.auto_instantiate,onCheckedChange:m,size:"sm"}),e[68]=a.runtime.auto_instantiate,e[69]=m,e[70]=ne):ne=e[70],e[71]!==U||e[72]!==ne?(Q=i.jsx(zo,{name:"runtime.auto_instantiate",children:i.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[U,ne]})}),e[71]=U,e[72]=ne,e[73]=Q):Q=e[73],e[74]===Symbol.for("react.memo_cache_sentinel")?(ee=i.jsx(En,{}),e[74]=ee):ee=e[74],e[75]!==a.runtime.on_cell_change?(oe=a.runtime.on_cell_change==="autorun"?i.jsx(_t,{size:14,className:"text-amber-500"}):i.jsx(Et,{size:14,className:"text-muted-foreground"}),e[75]=a.runtime.on_cell_change,e[76]=oe):oe=e[76],e[77]===Symbol.for("react.memo_cache_sentinel")?(se=i.jsx("div",{className:"text-sm font-medium",children:"On cell change"}),e[77]=se):se=e[77],e[78]!==a.runtime.on_cell_change?(ae=i.jsxs("div",{children:[se,i.jsx("div",{className:"text-xs text-muted-foreground",children:a.runtime.on_cell_change})]}),e[78]=a.runtime.on_cell_change,e[79]=ae):ae=e[79],e[80]!==oe||e[81]!==ae?(te=i.jsxs("div",{className:"flex items-center space-x-2",children:[oe,ae]}),e[80]=oe,e[81]=ae,e[82]=te):te=e[82];const _e=a.runtime.on_cell_change==="autorun";let he,we,ke,ge,Ee,Oe;return e[83]!==b||e[84]!==_e?(he=i.jsx(fc,{checked:_e,onCheckedChange:b,size:"sm"}),e[83]=b,e[84]=_e,e[85]=he):he=e[85],e[86]!==te||e[87]!==he?(we=i.jsx(zo,{name:"runtime.on_cell_change",children:i.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[te,he]})}),e[86]=te,e[87]=he,e[88]=we):we=e[88],e[89]!==a.runtime.auto_reload||e[90]!==f?(ke=!Qt()&&i.jsxs(i.Fragment,{children:[i.jsx(En,{}),i.jsx(zo,{name:"runtime.auto_reload",children:i.jsxs("div",{className:"px-2 py-1",children:[i.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[a.runtime.auto_reload==="off"&&i.jsx(Ur,{size:14,className:"text-muted-foreground"}),a.runtime.auto_reload==="lazy"&&i.jsx(Et,{size:14,className:"text-muted-foreground"}),a.runtime.auto_reload==="autorun"&&i.jsx(_t,{size:14,className:"text-amber-500"}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium",children:"On module change"}),i.jsx("div",{className:"text-xs text-muted-foreground",children:a.runtime.auto_reload})]})]}),i.jsx("div",{className:"space-y-1",children:["off","lazy","autorun"].map(ve=>i.jsxs("button",{onClick:()=>f(ve),className:ue("w-full flex items-center px-2 py-1 text-sm rounded hover:bg-accent",ve===a.runtime.auto_reload&&"bg-accent"),children:[ve==="off"&&i.jsx(Ur,{size:12,className:"mr-2"}),ve==="lazy"&&i.jsx(Et,{size:12,className:"mr-2"}),ve==="autorun"&&i.jsx(_t,{size:12,className:"mr-2"}),i.jsx("span",{className:"capitalize",children:ve}),ve===a.runtime.auto_reload&&i.jsx("span",{className:"ml-auto",children:"\u2713"})]},ve))})]})})]}),e[89]=a.runtime.auto_reload,e[90]=f,e[91]=ke):ke=e[91],e[92]!==Q||e[93]!==we||e[94]!==ke?(ge=i.jsxs(Wn,{align:"start",className:"w-64",children:[X,H,Q,ee,we,ke]}),e[92]=Q,e[93]=we,e[94]=ke,e[95]=ge):ge=e[95],e[96]!==l||e[97]!==G||e[98]!==ge?(Ee=i.jsx("div",{className:"flex md:hidden",children:i.jsxs(zn,{open:l,onOpenChange:c,children:[G,ge]})}),e[96]=l,e[97]=G,e[98]=ge,e[99]=Ee):Ee=e[99],e[100]!==F||e[101]!==Ee||e[102]!==w?(Oe=i.jsxs("div",{className:w,children:[F,Ee]}),e[100]=F,e[101]=Ee,e[102]=w,e[103]=Oe):Oe=e[103],Oe},dw=()=>{const t=P.c(24),{selectedPanel:e,isTerminalOpen:n}=Xs(),{toggleApplication:o,toggleTerminal:r}=kr(),s=ie(Gj),a=uw,l=Yr.find(hw);let c;Zt(l,"Error panel not found"),t[0]!==r?(c=()=>{r()},t[0]=r,t[1]=c):c=t[1],st("global.toggleTerminal",c);const d=At,u=l.tooltip,h=e===l.type,m=()=>o(l.type),p=a(l,s>0?"text-destructive":"");let b,x,f,g,y,w,j,C,N,k;return t[2]!==s?(b=i.jsx("span",{className:"ml-1 font-mono mt-0.5",children:s}),t[2]=s,t[3]=b):b=t[3],t[4]!==d||t[5]!==l||t[6]!==h||t[7]!==m||t[8]!==p||t[9]!==b?(x=i.jsxs(d,{tooltip:u,selected:h,onClick:m,"data-testid":"footer-errors",children:[p,b]}),t[4]=d,t[5]=l,t[6]=h,t[7]=m,t[8]=p,t[9]=b,t[10]=x):x=t[10],t[11]!==r?(f=()=>r(),t[11]=r,t[12]=f):f=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(Pc,{className:"h-5 w-5"}),t[13]=g):g=t[13],t[14]!==n||t[15]!==f?(y=i.jsx(Qf,{capability:"terminal",children:i.jsx(At,{tooltip:"Open terminal",selected:n,onClick:f,"data-testid":"footer-terminal",children:g})}),t[14]=n,t[15]=f,t[16]=y):y=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(cw,{}),j=i.jsx("div",{className:"mx-auto"}),t[17]=w,t[18]=j):(w=t[17],j=t[18]),t[19]===Symbol.for("react.memo_cache_sentinel")?(C=i.jsx(du,{children:i.jsx(pe,{content:i.jsx("div",{className:"w-[200px]",children:"Kiosk mode is enabled. This allows you to view the outputs of the cells without the ability to edit them."}),children:i.jsx("span",{className:"text-muted-foreground text-sm mr-4",children:"kiosk mode"})})}),t[19]=C):C=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(N=i.jsxs("div",{className:"flex items-center shrink-0 min-w-0",children:[i.jsx(Qv,{}),i.jsx(aw,{}),i.jsx(qv,{}),i.jsx(Yv,{}),i.jsx(lw,{}),i.jsx(Hv,{})]}),t[20]=N):N=t[20],t[21]!==y||t[22]!==x?(k=i.jsxs("footer",{className:"h-10 py-2 bg-background flex items-center text-muted-foreground text-md px-1 border-t border-border select-none no-print text-sm shadow-[0_0_4px_1px_rgba(0,0,0,0.1)] z-50 print:hidden hide-on-fullscreen overflow-x-auto overflow-y-hidden scrollbar-thin",children:[x,y,w,j,C,N]}),t[21]=y,t[22]=x,t[23]=k):k=t[23],k};function uw(t,e){const{Icon:n}=t;return i.jsx(n,{className:ue("h-5 w-5",e)})}function hw(t){return t.type==="errors"}const mw=t=>{const e=P.c(6),{children:n}=t,{openModal:o,closeModal:r}=Pn();let s,a;return e[0]!==r||e[1]!==o?(s=()=>o(i.jsx(fw,{onClose:r})),e[0]=r,e[1]=o,e[2]=s):s=e[2],e[3]!==n||e[4]!==s?(a=i.jsx(qj,{onClick:s,children:n}),e[3]=n,e[4]=s,e[5]=a):a=e[5],a},fw=t=>{const e=P.c(9),{onClose:n}=t;let o,r,s,a,l,c,d;return e[0]!==n?(o=async u=>{u.preventDefault();const h=new FormData(u.target),m=h.get("rating"),p=h.get("message");fetch("https://marimo.io/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:m,message:p})}),n(),ze({title:"Feedback sent!",description:"Thank you for your feedback!"})},e[0]=n,e[1]=o):o=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(so,{children:"Send Feedback"}),e[2]=r):r=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("p",{className:"my-2 prose dark:prose-invert",children:"We want to hear from you \u2014 from minor bug reports to wishlist features and everything in between. Here are some ways you can get in touch:"}),e[3]=s):s=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs("li",{className:"my-0",children:["Take our"," ",i.jsx("a",{href:Xt.feedbackForm,target:"_blank",className:"underline",children:"two-minute survey."})]}),e[4]=a):a=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("li",{className:"my-0",children:["File a"," ",i.jsx("a",{href:Xt.issuesPage,target:"_blank",className:"underline",children:"GitHub issue."})]}),e[5]=l):l=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsxs(yr,{children:[r,i.jsxs(vr,{children:[s,i.jsxs("ul",{className:"list-disc ml-8 my-2 prose dark:prose-invert",children:[a,l,i.jsxs("li",{className:"my-0",children:["Chat with us on"," ",i.jsx("a",{href:Xt.discordLink,target:"_blank",className:"underline",children:"Discord."})]})]}),i.jsx("p",{className:"my-2 prose dark:prose-invert",children:"We're excited you're here as we build the future of Python data tooling. Thanks for being part of our community!"})]})]}),e[6]=c):c=e[6],e[7]!==o?(d=i.jsx(io,{className:"w-fit",children:i.jsx("form",{onSubmit:o,children:c})}),e[7]=o,e[8]=d):d=e[8],d},pw=()=>{const t=P.c(10),{selectedPanel:e}=Xs(),{toggleApplication:n}=kr(),o=bw;let r,s,a,l,c,d;return t[0]!==e||t[1]!==n?(r="h-full pt-4 pb-1 px-1 flex flex-col items-start text-muted-foreground text-md select-none no-print text-sm z-50 dark:bg-background print:hidden hide-on-fullscreen",s=Yr.filter(xw).map(u=>i.jsx(tp,{tooltip:u.tooltip,selected:e===u.type,onClick:()=>n(u.type),children:o(u)},u.type)),t[0]=e,t[1]=n,t[2]=r,t[3]=s):(r=t[2],s=t[3]),t[4]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(mw,{children:i.jsx(tp,{tooltip:"Send feedback!",selected:!1,children:i.jsx(ad,{className:"h-5 w-5"})})}),l=i.jsx("div",{className:"flex-1"}),c=i.jsx(gw,{}),t[4]=a,t[5]=l,t[6]=c):(a=t[4],l=t[5],c=t[6]),t[7]!==r||t[8]!==s?(d=i.jsxs("div",{className:r,children:[s,a,l,c]}),t[7]=r,t[8]=s,t[9]=d):d=t[9],d},gw=()=>{const t=P.c(7),e=ie(Hj);let n,o,r;return t[0]!==e?(n=e>0?i.jsxs("span",{children:[e," cell",e>1?"s":""," queued or running"]}):"No cells queued or running",t[0]=e,t[1]=n):n=t[1],t[2]!==e?(o=i.jsx("div",{className:"flex flex-col-reverse gap-px overflow-hidden",children:Array.from({length:e}).map(yw)}),t[2]=e,t[3]=o):o=t[3],t[4]!==n||t[5]!==o?(r=i.jsx(pe,{content:n,side:"right",delayDuration:200,children:o}),t[4]=n,t[5]=o,t[6]=r):r=t[6],r},tp=t=>{const e=P.c(17);let n,o,r,s,a;e[0]!==t?({children:n,tooltip:a,selected:s,className:o,...r}=t,e[0]=t,e[1]=n,e[2]=o,e[3]=r,e[4]=s,e[5]=a):(n=e[1],o=e[2],r=e[3],s=e[4],a=e[5]);const l=!s&&"hover:bg-(--sage-3)",c=s&&"bg-(--sage-4)";let d,u,h;return e[6]!==o||e[7]!==l||e[8]!==c?(d=ue("flex items-center p-2 text-sm mx-px shadow-inset font-mono cursor-pointer rounded",l,c,o),e[6]=o,e[7]=l,e[8]=c,e[9]=d):d=e[9],e[10]!==n||e[11]!==r||e[12]!==d?(u=i.jsx("button",{className:d,...r,children:n}),e[10]=n,e[11]=r,e[12]=d,e[13]=u):u=e[13],e[14]!==u||e[15]!==a?(h=i.jsx(pe,{content:a,side:"right",delayDuration:200,children:u}),e[14]=u,e[15]=a,e[16]=h):h=e[16],h};function bw(t,e){const{Icon:n}=t;return i.jsx(n,{className:ue("h-5 w-5",e)})}function xw(t){return!t.hidden&&t.position==="sidebar"}function yw(t,e){return i.jsx("div",{className:"shrink-0 h-1 w-2 bg-(--grass-6) border border-(--grass-7)"},e.toString())}const vw=t=>{const e=P.c(4),{isOpen:n,children:o}=t,[r,s]=me.useState(!1);let a,l;return e[0]!==r||e[1]!==n?(a=()=>{n&&!r&&s(!0)},l=[n,r],e[0]=r,e[1]=n,e[2]=a,e[3]=l):(a=e[2],l=e[3]),me.useEffect(a,l),r?o:null},ww=t=>{const e=P.c(38),n=ie(Jj),o=ie(rw),r=Ye(),s=_1(),a=t.cellId,l=o[t.cellId],c=Lr(t.cellId),d=c.code,u=Fr(t.cellId);let h,m,p,b,x,f,g,y,w,j;if(e[0]!==r||e[1]!==s||e[2]!==n.focusedCellId||e[3]!==o||e[4]!==t.cellId||e[5]!==l||e[6]!==c.code||e[7]!==u.errored){h={id:a,graph:l,code:d,hasError:u.errored},n.focusedCellId&&o[n.focusedCellId]&&(b={id:n.focusedCellId,graph:o[n.focusedCellId]}),p=(b==null?void 0:b.id)===h.id,m=op(h.graph)?1.5:3;const _=()=>{p?s.blurCell():(r.focusCell({cellId:h.id,where:"exact"}),s.focusCell({cellId:h.id}))};g=h.id;const I=p?"text-primary-foreground":"text-(--gray-8) hover:text-(--gray-9)";e[18]!==I?(y=ue("group bg-transparent text-left w-full flex relative justify-between items-center","border-none rounded cursor-pointer","h-[21px] pl-[51px] font-inherit",I),e[18]=I,e[19]=y):y=e[19],w=_,j=Ew;const A=p&&"bg-primary group-hover:bg-primary";let O;e[20]!==A?(O=ue("group-hover:bg-(--gray-2) flex h-full w-full px-0.5 items-center rounded",A),e[20]=A,e[21]=O):O=e[21],x=i.jsx("div",{className:O,children:i.jsx("div",{className:"truncate px-1 font-mono text-sm flex gap-1",title:h.code,children:h.graph.variables.length>0?i.jsx(Cw,{cell:h,selectedCell:b}):i.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap max-w-full",children:(C=h.code,(C.split(`
129
- `)[0].trim()||void 0)??i.jsx("span",{className:"italic",children:"empty"}))})})}),f=ue("absolute overflow-visible top-[10.5px] left-[calc(var(--spacing-extra-small,8px)+17px)] pointer-events-none",p?"z-30":"z-20",(function({cell:D,selectedCell:M}){return D.hasError?"text-destructive":!M&&!op(D.graph)?"text-foreground":(M==null?void 0:M.id)===D.id||M!=null&&M.graph.parents.has(D.id)||M!=null&&M.graph.children.has(D.id)?"text-primary":"text-(--gray-8)"})({cell:h,selectedCell:b})),e[0]=r,e[1]=s,e[2]=n.focusedCellId,e[3]=o,e[4]=t.cellId,e[5]=l,e[6]=c.code,e[7]=u.errored,e[8]=h,e[9]=m,e[10]=p,e[11]=b,e[12]=x,e[13]=f,e[14]=g,e[15]=y,e[16]=w,e[17]=j}else h=e[8],m=e[9],p=e[10],b=e[11],x=e[12],f=e[13],g=e[14],y=e[15],w=e[16],j=e[17];var C;let N,k,E;return e[22]!==h||e[23]!==m||e[24]!==p||e[25]!==t.cellPositions||e[26]!==b?(N=p?i.jsx(Nw,{cell:h,cellPositions:t.cellPositions,circleRadius:m}):i.jsx(Sw,{cell:h,selectedCell:b,circleRadius:m}),e[22]=h,e[23]=m,e[24]=p,e[25]=t.cellPositions,e[26]=b,e[27]=N):N=e[27],e[28]!==N||e[29]!==f?(k=i.jsx("svg",{className:f,width:"1",height:"1",children:N}),e[28]=N,e[29]=f,e[30]=k):k=e[30],e[31]!==x||e[32]!==k||e[33]!==g||e[34]!==y||e[35]!==w||e[36]!==j?(E=i.jsxs("button",{"data-node-id":g,className:y,onClick:w,onMouseDown:j,children:[x,k]}),e[31]=x,e[32]=k,e[33]=g,e[34]=y,e[35]=w,e[36]=j,e[37]=E):E=e[37],E},kw=t=>{const e=P.c(28),{open:n,setOpen:o}=t,r=jc();let s;e[0]!==r.inOrderIds?(s=Object.fromEntries(r.inOrderIds.map(_w)),e[0]=r.inOrderIds,e[1]=s):s=e[1];const a=s;let l;if(e[2]!==r){l=[];let w=0;for(const[j,C]of r.getColumns().entries())j>0&&l.push(w),w+=C.inOrderIds.length;e[2]=r,e[3]=l}else l=e[3];const c=n?"translate-x-0":"translate-x-[calc(100%+20px)]";let d,u,h,m,p,b,x,f,g,y;if(e[4]!==c?(d=ue("fixed top-14 right-5 z-50 bg-background/95 backdrop-blur-sm supports-backdrop-filter:bg-background/60 rounded-lg border shadow-lg w-64 flex flex-col max-h-[58vh]","motion-safe:transition-transform motion-safe:duration-200 motion-safe:ease-in-out",c),e[4]=c,e[5]=d):d=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx("span",{className:"text-sm font-semibold",children:"Minimap"}),e[6]=u):u=e[6],e[7]!==o?(h=()=>o(!1),e[7]=o,e[8]=h):h=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Vt,{className:"h-4 w-4"}),e[9]=m):m=e[9],e[10]!==h?(p=i.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[u,i.jsx(ye,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:h,children:m})]}),e[10]=h,e[11]=p):p=e[11],e[12]!==r.inOrderIds||e[13]!==a||e[14]!==l){let w;e[16]!==a||e[17]!==l?(w=(j,C)=>{const N=l.includes(C);return i.jsxs(S.Fragment,{children:[N&&i.jsx("div",{className:"absolute left-5 w-[36px] h-px bg-(--gray-4) pointer-events-none","aria-hidden":"true"}),i.jsx(ww,{cellId:j,cellPositions:a})]},j)},e[16]=a,e[17]=l,e[18]=w):w=e[18],b=r.inOrderIds.map(w),e[12]=r.inOrderIds,e[13]=a,e[14]=l,e[15]=b}else b=e[15];return e[19]!==b?(x=i.jsx("div",{className:"py-3 pl-3 pr-4 relative min-h-full",children:b}),e[19]=b,e[20]=x):x=e[20],e[21]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("div",{className:"h-0 overflow-hidden","aria-hidden":"true"}),e[21]=f):f=e[21],e[22]!==x?(g=i.jsxs("div",{className:"overflow-y-auto overflow-x-hidden flex-1 scrollbar-none",children:[x,f]}),e[22]=x,e[23]=g):g=e[23],e[24]!==g||e[25]!==d||e[26]!==p?(y=i.jsxs("div",{className:d,children:[p,g]}),e[24]=g,e[25]=d,e[26]=p,e[27]=y):y=e[27],y},jw=()=>{const t=P.c(5),[e,n]=_n(ep);let o,r;return t[0]!==n?(o=()=>n(Iw),t[0]=n,t[1]=o):o=t[1],st("global.toggleMinimap",o),t[2]!==e||t[3]!==n?(r=i.jsx(kw,{open:e,setOpen:n}),t[2]=e,t[3]=n,t[4]=r):r=t[4],r},Cw=t=>{const e=P.c(11),{cell:n,selectedCell:o}=t,r=Kj(),s=n.id===(o==null?void 0:o.id);let a,l;if(e[0]!==n.graph.variables||e[1]!==s||e[2]!==o||e[3]!==r){let c;e[5]!==s||e[6]!==o||e[7]!==r?(c=(d,u)=>{const h=r[d];return i.jsxs(S.Fragment,{children:[u>0&&", ",i.jsx("span",{className:ue({"font-bold":s,"text-foreground":o===void 0,"text-primary font-medium":!s&&sw(h,o)}),children:d})]},d)},e[5]=s,e[6]=o,e[7]=r,e[8]=c):c=e[8],a=n.graph.variables.map(c),e[0]=n.graph.variables,e[1]=s,e[2]=o,e[3]=r,e[4]=a}else a=e[4];return e[9]!==a?(l=i.jsx(i.Fragment,{children:a}),e[9]=a,e[10]=l):l=e[10],l},Nw=t=>{const e=P.c(12),{cell:n,cellPositions:o,circleRadius:r}=t;let s,a,l,c;if(e[0]!==n.graph.children||e[1]!==n.graph.parents||e[2]!==n.id||e[3]!==o){s=[];const d=o[n.id]??0,u=new Set;for(const h of n.graph.parents)n.graph.children.has(h)&&u.add(h);for(const h of u){const m=o[h];if(m!==void 0){const p=21*(m-d);s.push(i.jsx("path",{d:`M -3 0 H -7 v ${p} h 14 v ${-p} H 3`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-cycle-${h}`))}}for(const h of n.graph.parents){if(u.has(h))continue;const m=o[h];if(m!==void 0){const p=21*(m-d);s.push(i.jsx("path",{d:`M -3 0 H -7 v ${p} h -4`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-up-${h}`))}}for(const h of n.graph.children){if(u.has(h))continue;const m=o[h];if(m!==void 0){const p=21*(m-d);s.push(i.jsx("path",{d:`M 3 0 H 7 v ${p} h 4`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-down-${h}`))}}e[0]=n.graph.children,e[1]=n.graph.parents,e[2]=n.id,e[3]=o,e[4]=s}else s=e[4];return e[5]!==r?(a=i.jsx("circle",{r,fill:"currentColor",className:"pointer-events-auto"}),e[5]=r,e[6]=a):a=e[6],e[7]!==s?(l=i.jsx("g",{className:"pen pointer-events-auto",children:s}),e[7]=s,e[8]=l):l=e[8],e[9]!==a||e[10]!==l?(c=i.jsxs("g",{transform:"translate(0, 0)",children:[a,l]}),e[9]=a,e[10]=l,e[11]=c):c=e[11],c};function Sw(t){const{cell:e,selectedCell:n,circleRadius:o}=t,r=e.graph.ancestors.size>0,s=e.graph.descendants.size>0;if(!n)return np({circleRadius:o,leftWisker:r,rightWisker:s});const a=n.graph.ancestors.has(e.id),l=n.graph.descendants.has(e.id);return np(a||l?{circleRadius:o,leftWisker:r,rightWisker:s,shift:a&&l?void 0:a?"left":"right"}:{circleRadius:o,leftWisker:!1,rightWisker:!1})}function np(t){const{circleRadius:e,leftWisker:n,rightWisker:o,shift:r}=t,s=r===void 0?0:r==="left"?-14:14;return i.jsxs("g",{transform:`translate(${s}, 0)`,children:[i.jsxs("g",{children:[n&&i.jsx("path",{d:"M 0 0 h -8",fill:"none",strokeWidth:"2",stroke:"currentColor"}),o&&i.jsx("path",{d:"M 0 0 h 8",fill:"none",strokeWidth:"2",stroke:"currentColor"})]}),i.jsx("circle",{r:e,fill:"currentColor",className:"pointer-events-auto"})]})}function op(t){return t.variables.length===0&&t.ancestors.size===0&&t.descendants.size===0}function Ew(t){return t.preventDefault()}function _w(t,e){return[t,e]}function Iw(t){return!t}const Aw=me.lazy(()=>mt(()=>import("./terminal-BX3Su5q7.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110]),import.meta.url)),Tw=me.lazy(()=>mt(()=>import("./chat-panel-9alr8FS4.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([111,1,2,4,5,112,113,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,114,115,116,117,107,108,109]),import.meta.url)),Dw=me.lazy(()=>mt(()=>import("./agent-panel-RGLNjkYe.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([118,1,2,113,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,114,115,116,4,5,112,3,107,108,109,119]),import.meta.url)),Mw=me.lazy(()=>mt(()=>import("./dependency-graph-panel-CEog_O7V.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([120,1,2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,121,122,123,124,125,4,5,107,108,109,126]),import.meta.url)),Ow=me.lazy(()=>mt(()=>import("./datasources-panel-v7H3cR0p.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([127,1,2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,112,128,108,129,4,5,107,109]),import.meta.url)),Rw=me.lazy(()=>mt(()=>import("./documentation-panel-C1BtMZ3M.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([130,1,2,112,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109]),import.meta.url)),Lw=me.lazy(()=>mt(()=>import("./error-panel-Bs34jXFh.js"),__vite__mapDeps([131,1,2,112]),import.meta.url)),Fw=me.lazy(()=>mt(()=>import("./file-explorer-panel-Ck6UL861.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([132,1,2,4,5,133,134,135,125,115,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109]),import.meta.url)),Bw=me.lazy(()=>mt(()=>import("./logs-panel-DC7wpmPz.js"),__vite__mapDeps([136,1,2,137,112]),import.meta.url)),Pw=me.lazy(()=>mt(()=>import("./outline-panel-CdsnAy2w.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([138,1,2,112,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,139]),import.meta.url)),zw=me.lazy(()=>mt(()=>import("./packages-panel-DiTA-d_D.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([140,1,2,4,5,112,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109]),import.meta.url)),Uw=me.lazy(()=>mt(()=>import("./scratchpad-panel-CuHWpHO8.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([141,1,2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,115,4,5,107,108,109]),import.meta.url)),Ww=me.lazy(()=>mt(()=>import("./secrets-panel-CfHc5YD0.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([142,1,2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,112,4,5,107,108,109]),import.meta.url)),$w=me.lazy(()=>mt(()=>import("./snippets-panel-B2EC1txM.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([143,1,2,112,115,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,144]),import.meta.url)),Vw=me.lazy(()=>mt(()=>import("./tracing-panel-Du8WCnno.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([145,1,2]),import.meta.url)),Gw=me.lazy(()=>mt(()=>import("./variable-panel-D5qgJI7k.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([146,1,2,124,128,108,129,112,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,109]),import.meta.url)),qw=t=>{const e=P.c(127),{children:n}=t,{isSidebarOpen:o,isTerminalOpen:r,selectedPanel:s}=Xs(),{setIsSidebarOpen:a,setIsTerminalOpen:l}=kr(),c=me.useRef(null),d=me.useRef(null),u=S.useId(),h=S.useId();let m,p,b,x,f;e[0]!==o?(m=()=>{if(!c.current)return;const le=c.current.isCollapsed();o&&le&&c.current.expand(),o||le||c.current.collapse(),requestAnimationFrame(Jw)},p=[o],e[0]=o,e[1]=m,e[2]=p):(m=e[1],p=e[2]),S.useEffect(m,p),e[3]!==r?(b=()=>{if(!d.current)return;const le=d.current.isCollapsed();r&&le&&d.current.expand(),r||le||d.current.collapse(),requestAnimationFrame(Yw)},x=[r],e[3]=r,e[4]=b,e[5]=x):(b=e[4],x=e[5]),S.useEffect(b,x),e[6]!==n?(f=i.jsx(ka,{id:"app",className:"relative h-full",children:i.jsx(S.Suspense,{children:n})},"app"),e[6]=n,e[7]=f):f=e[7];const g=f,y=o?"resize-handle":"resize-handle-collapsed";let w,j;e[8]!==y?(w=ue("border-border no-print z-10",y,"vertical"),e[8]=y,e[9]=w):w=e[9],e[10]!==w?(j=i.jsx($1,{onDragging:V1,className:w}),e[10]=w,e[11]=j):j=e[11];const C=j,N=r?"resize-handle":"resize-handle-collapsed";let k,E;e[12]!==N?(k=ue("border-border no-print z-20",N,"horizontal"),e[12]=N,e[13]=k):k=e[13],e[14]!==k?(E=i.jsx($1,{onDragging:V1,className:k}),e[14]=k,e[15]=E):E=e[15];const _=E;let I,A,O,D,M,R,L,z,T,F,$,W,G,X,H,Y,K,V,q,U,ne,Q;e[16]!==s?(I=i.jsx("div",{className:"text-sm text-(--slate-11) uppercase tracking-wide font-semibold flex-1",children:s}),e[16]=s,e[17]=I):I=e[17],e[18]!==a?(A=()=>a(!1),e[18]=a,e[19]=A):A=e[19],e[20]===Symbol.for("react.memo_cache_sentinel")?(O=i.jsx(Vt,{className:"w-4 h-4"}),e[20]=O):O=e[20],e[21]!==A?(D=i.jsx(ye,{"data-testid":"close-helper-pane",className:"m-0",size:"xs",variant:"text",onClick:A,children:O}),e[21]=A,e[22]=D):D=e[22],e[23]!==I||e[24]!==D?(M=i.jsxs("div",{className:"p-3 border-b flex justify-between items-center",children:[I,D]}),e[23]=I,e[24]=D,e[25]=M):M=e[25],e[26]!==s?(R=s==="files"&&i.jsx(Fw,{}),e[26]=s,e[27]=R):R=e[27],e[28]!==s?(L=s==="errors"&&i.jsx(Lw,{}),e[28]=s,e[29]=L):L=e[29],e[30]!==s?(z=s==="variables"&&i.jsx(Gw,{}),e[30]=s,e[31]=z):z=e[31],e[32]!==s?(T=s==="dependencies"&&i.jsx(Mw,{}),e[32]=s,e[33]=T):T=e[33],e[34]!==s?(F=s==="packages"&&i.jsx(zw,{}),e[34]=s,e[35]=F):F=e[35],e[36]!==s?($=s==="outline"&&i.jsx(Pw,{}),e[36]=s,e[37]=$):$=e[37],e[38]!==s?(W=s==="datasources"&&i.jsx(Ow,{}),e[38]=s,e[39]=W):W=e[39],e[40]!==s?(G=s==="documentation"&&i.jsx(Rw,{}),e[40]=s,e[41]=G):G=e[41],e[42]!==s?(X=s==="snippets"&&i.jsx($w,{}),e[42]=s,e[43]=X):X=e[43],e[44]!==s?(H=s==="scratchpad"&&i.jsx(Uw,{}),e[44]=s,e[45]=H):H=e[45],e[46]!==s?(Y=s==="chat"&&i.jsx(Tw,{}),e[46]=s,e[47]=Y):Y=e[47],e[48]!==s?(K=s==="agents"&&i.jsx(Dw,{}),e[48]=s,e[49]=K):K=e[49],e[50]!==s?(V=s==="logs"&&i.jsx(Bw,{}),e[50]=s,e[51]=V):V=e[51],e[52]!==s?(q=s==="tracing"&&i.jsx(Vw,{}),e[52]=s,e[53]=q):q=e[53],e[54]!==s?(U=s==="secrets"&&i.jsx(Ww,{}),e[54]=s,e[55]=U):U=e[55],e[56]!==R||e[57]!==L||e[58]!==z||e[59]!==T||e[60]!==F||e[61]!==$||e[62]!==W||e[63]!==G||e[64]!==X||e[65]!==H||e[66]!==Y||e[67]!==K||e[68]!==V||e[69]!==q||e[70]!==U?(ne=i.jsx(S.Suspense,{children:i.jsxs(va,{children:[R,L,z,T,F,$,W,G,X,H,Y,K,V,q,U]})}),e[56]=R,e[57]=L,e[58]=z,e[59]=T,e[60]=F,e[61]=$,e[62]=W,e[63]=G,e[64]=X,e[65]=H,e[66]=Y,e[67]=K,e[68]=V,e[69]=q,e[70]=U,e[71]=ne):ne=e[71],e[72]!==M||e[73]!==ne?(Q=i.jsx(Yl,{children:i.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden mr-[-4px]",children:[M,ne]})}),e[72]=M,e[73]=ne,e[74]=Q):Q=e[74];const ee=Q,oe=`helper-${u}`,se=o&&"border-r border-l border-(--slate-7)";let ae,te,_e,he,we,ke;e[75]!==se?(ae=ue("dark:bg-(--slate-1) no-print print:hidden hide-on-fullscreen",se),e[75]=se,e[76]=ae):ae=e[76],e[77]===Symbol.for("react.memo_cache_sentinel")?(te=(le,je)=>{var Ne;je===0&&le===10&&((Ne=c.current)==null||Ne.resize(30))},e[77]=te):te=e[77],e[78]!==a?(_e=()=>a(!1),he=()=>a(!0),e[78]=a,e[79]=_e,e[80]=he):(_e=e[79],he=e[80]),e[81]!==ee||e[82]!==C?(we=i.jsxs("span",{className:"flex flex-row h-full",children:[ee," ",C]}),e[81]=ee,e[82]=C,e[83]=we):we=e[83],e[84]!==oe||e[85]!==ae||e[86]!==_e||e[87]!==he||e[88]!==we?(ke=i.jsx(ka,{ref:c,id:oe,"data-testid":"helper",collapsedSize:0,collapsible:!0,className:ae,minSize:10,defaultSize:0,maxSize:75,onResize:te,onCollapse:_e,onExpand:he,children:we},"helper"),e[84]=oe,e[85]=ae,e[86]=_e,e[87]=he,e[88]=we,e[89]=ke):ke=e[89];const ge=ke,Ee=`terminal-${h}`,Oe=r&&"border-(--slate-7)";let ve,be,et,rt,ct,dt,pt,ut,wt;e[90]!==Oe?(ve=ue("dark:bg-(--slate-1) no-print print:hidden hide-on-fullscreen",Oe),e[90]=Oe,e[91]=ve):ve=e[91],e[92]===Symbol.for("react.memo_cache_sentinel")?(be=(le,je)=>{var Ne;je===0&&le===10&&((Ne=d.current)==null||Ne.resize(30))},e[92]=be):be=e[92],e[93]!==l?(et=()=>l(!1),rt=()=>l(!0),e[93]=l,e[94]=et,e[95]=rt):(et=e[94],rt=e[95]),e[96]===Symbol.for("react.memo_cache_sentinel")?(ct=i.jsx("div",{}),e[96]=ct):ct=e[96],e[97]!==l?(dt=()=>l(!1),e[97]=l,e[98]=dt):dt=e[98],e[99]!==r||e[100]!==dt?(pt=i.jsx(S.Suspense,{fallback:ct,children:i.jsx(Aw,{visible:r,onClose:dt})}),e[99]=r,e[100]=dt,e[101]=pt):pt=e[101],e[102]!==r||e[103]!==pt?(ut=i.jsx(vw,{isOpen:r,children:pt}),e[102]=r,e[103]=pt,e[104]=ut):ut=e[104],e[105]!==Ee||e[106]!==ve||e[107]!==et||e[108]!==rt||e[109]!==ut||e[110]!==_?(wt=i.jsxs(ka,{ref:d,id:Ee,"data-testid":"terminal",collapsedSize:0,collapsible:!0,className:ve,minSize:10,defaultSize:0,maxSize:75,onResize:be,onCollapse:et,onExpand:rt,children:[_,ut]},"terminal"),e[105]=Ee,e[106]=ve,e[107]=et,e[108]=rt,e[109]=ut,e[110]=_,e[111]=wt):wt=e[111];const Lt=wt;let On,Jt,Ft,zt,to,Rn,No,re,ce;return e[112]===Symbol.for("react.memo_cache_sentinel")?(On=AC(),e[112]=On):On=e[112],e[113]===Symbol.for("react.memo_cache_sentinel")?(Jt=i.jsx(va,{children:i.jsx(pw,{})}),e[113]=Jt):Jt=e[113],e[114]!==Lt?(Ft=i.jsx(Qf,{capability:"terminal",children:Lt}),e[114]=Lt,e[115]=Ft):Ft=e[115],e[116]!==g||e[117]!==Ft?(zt=i.jsx(ka,{children:i.jsxs(G1,{autoSaveId:"marimo:chrome:v1:l1",direction:"vertical",children:[g,Ft]})}),e[116]=g,e[117]=Ft,e[118]=zt):zt=e[118],e[119]===Symbol.for("react.memo_cache_sentinel")?(to=i.jsx(Yj,{}),e[119]=to):to=e[119],e[120]!==ge||e[121]!==zt?(Rn=i.jsxs(G1,{autoSaveId:"marimo:chrome:v1:l2",direction:"horizontal",storage:On,children:[Jt,ge,zt,to]}),e[120]=ge,e[121]=zt,e[122]=Rn):Rn=e[122],e[123]===Symbol.for("react.memo_cache_sentinel")?(No=i.jsx(jw,{}),e[123]=No):No=e[123],e[124]===Symbol.for("react.memo_cache_sentinel")?(re=i.jsx(Yl,{children:i.jsx(va,{children:i.jsx(dw,{})})}),e[124]=re):re=e[124],e[125]!==Rn?(ce=i.jsxs(TC,{children:[Rn,No,re]}),e[125]=Rn,e[126]=ce):ce=e[126],ce};function Hw(){window.dispatchEvent(new Event("resize"))}function Jw(){requestAnimationFrame(Hw)}function Kw(){window.dispatchEvent(new Event("resize"))}function Yw(){requestAnimationFrame(Kw)}let wl,rp;wl=S.lazy(()=>mt(()=>import("./command-palette-B93Pjcky.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([147,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109]),import.meta.url)),rp=new URL(window.location.href).searchParams.get(Xj.showChrome)==="false",gg=Object.freeze(Object.defineProperty({__proto__:null,default:t=>{const e=P.c(10);if(rp){let s,a,l;return e[0]!==t?(s=i.jsx(Xf,{hideControls:!0,...t}),e[0]=t,e[1]=s):s=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(wl,{}),e[2]=a):a=e[2],e[3]!==s?(l=i.jsxs(i.Fragment,{children:[s,a]}),e[3]=s,e[4]=l):l=e[4],l}let n,o,r;return e[5]!==t?(n=i.jsx(Xf,{...t}),e[5]=t,e[6]=n):n=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(wl,{}),e[7]=o):o=e[7],e[8]!==n?(r=i.jsxs(qw,{children:[n,o]}),e[8]=n,e[9]=r):r=e[9],r}},Symbol.toStringTag,{value:"Module"}))});export{fg as A,Na as C,Sa as E,Ec as F,Ea as H,_c as K,Ic as N,Ac as P,Tc as R,Dc as S,Mc as T,Oc as W,BC as __tla,Rc as a,Lc as b,_a as c,Ia as d,Aa as e,Wo as f,pg as g,Ta as h,Fc as i,Bc as j,Pc as k,zc as l,Uc as m,gg as n,Wc as s,Da as u};
138
+ hover/column:hover:bg-primary/60 dark:hover/column:hover:bg-primary/60`})}const jv=t=>{const e=z.c(10),{width:n}=t,{banners:o}=wC(),{removeBanner:r}=kC();if(o.length===0)return null;const s=n==="columns"&&"sticky left-12 w-full max-w-[80vw]";let a,l,c;if(e[0]!==s?(a=de("flex flex-col gap-4 mb-5 print:hidden",s),e[0]=s,e[1]=a):a=e[1],e[2]!==o||e[3]!==r){let d;e[5]!==r?(d=u=>i.jsxs(Lo,{kind:u.variant||"info",className:"flex flex-col rounded p-3",children:[i.jsxs("div",{className:"flex justify-between",children:[i.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[i.jsx(vc,{className:"w-5 h-5 inline-block mr-2"}),u.title]}),i.jsx(ye,{"data-testid":"remove-banner-button",variant:"text",size:"icon",onClick:()=>r(u.id),children:i.jsx($t,{className:"w-5 h-5"})})]}),i.jsxs("div",{className:"flex justify-between items-end",children:[i.jsx("span",{children:Ej({html:u.description})}),u.action==="restart"&&i.jsx(Cv,{})]})]},u.id),e[5]=r,e[6]=d):d=e[6],l=o.map(d),e[2]=o,e[3]=r,e[4]=l}else l=e[4];return e[7]!==a||e[8]!==l?(c=i.jsx("div",{className:a,children:l}),e[7]=a,e[8]=l,e[9]=c):c=e[9],c},Cv=()=>{const t=z.c(3),e=eu();let n,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(Tc,{className:"w-3 h-3 mr-2"}),t[0]=n):n=t[0],t[1]!==e?(o=i.jsxs(ye,{"data-testid":"restart-session-button",variant:"link",size:"xs",onClick:e,children:[n,"Restart"]}),t[1]=e,t[2]=o):o=t[2],o},Nv=Qt(t=>{const e=t(Vt);for(const n of e.cellIds.inOrderIds){const o=e.cellRuntime[n];if(o.status==="idle"&&o.consoleOutputs.some(r=>r.channel==="stdin"&&r.response===void 0))return!0}return!1}),Sv=()=>{const t=z.c(3),e=Ev;if(!ie(Nv))return null;let n,o,r;if(t[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"flex justify-between",children:i.jsx("span",{className:"font-bold text-lg flex items-center mb-1",children:"Program waiting for input"})}),t[0]=n):n=t[0],t[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(o1,{className:"inline",children:"stdin"}),t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")){const s=i.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-1/2 transform -translate-x-1/2 z-200 opacity-95",children:i.jsxs(Lo,{kind:"info",className:"flex flex-col rounded py-2 px-4 animate-in slide-in-from-top w-fit",children:[n,i.jsx("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:i.jsx("div",{children:i.jsxs("p",{children:["The program is still running, but blocked on"," ",o,".",i.jsx(ye,{variant:"link",className:"h-auto font-normal",onClick:e,children:"Jump to the cell"})]})})})]})});r=i.jsx(ba,{milliseconds:2e3,children:s}),t[2]=r}else r=t[2];return r};function Ev(){const t=document.querySelector("[data-stdin-blocking]");t?(t.scrollIntoView({behavior:"smooth",block:"center"}),requestAnimationFrame(()=>{t.focus()})):Ye.error("No element with data-stdin-blocking found")}function _v(){const t=setTimeout(Iv,100);return()=>clearTimeout(t)}function Iv(){requestAnimationFrame(Av)}function Av(){const t=(function(e){const n=e.match(/scrollTo=([^&]+)/),o=n==null?void 0:n[1];return o?decodeURIComponent(o.split("&")[0]):null})(window.location.hash);if(t)(function(e){var o,r;if(Kf)return;const n=document.querySelector(`[data-cell-name="${e}"]`);if(n){if(n.scrollIntoView({behavior:"smooth",block:"start"}),Kf=!0,n instanceof HTMLElement){n.focus();const{cellHandles:s}=Mt(),a=n.dataset.cellId;if(!a)return void Ye.error(`Missing cellId for cell with name ${e}`);const l=(r=(o=s[a])==null?void 0:o.current)==null?void 0:r.editorView;l&&l.focus()}}else Ye.warn(`Cannot focus cell with name ${e} because it was not found`),Jf()})(t);else try{Jf()}catch(e){const n=e;Ye.warn("Error focusing first editor",n)}}function Jf(){var o,r;const{cellIds:t,cellData:e,cellHandles:n}=Mt();for(const s of t.iterateTopLevelIds){const a=n[s];if(!((o=e[s])==null?void 0:o.config.hide_code)&&((r=a==null?void 0:a.current)!=null&&r.editorView))return void a.current.editorView.focus()}}let Kf=!1;const Tv=t=>{const e=z.c(8),n=ie(_j),o=t.appConfig.width==="columns";let r,s,a;return e[0]!==t?(r=i.jsx(Dv,{...t}),e[0]=t,e[1]=r):r=e[1],e[2]!==n||e[3]!==r?(s=i.jsx(Vu,{id:"column-container",items:n,strategy:mx,children:r}),e[2]=n,e[3]=r,e[4]=s):s=e[4],e[5]!==o||e[6]!==s?(a=i.jsx(mv,{multiColumn:o,children:s}),e[5]=o,e[6]=s,e[7]=a):a=e[7],a},Dv=t=>{const e=z.c(28),{mode:n,userConfig:o,appConfig:r}=t,s=Ke(),{theme:a}=k1(),{toggleSidebarPanel:l}=wr();P1(_v),st("global.focusTop",s.focusTopCell),st("global.focusBottom",s.focusBottomCell),st("global.toggleSidebar",l),st("global.foldCode",s.foldAll),st("global.unfoldCode",s.unfoldAll),st("global.formatAll",Rv),st("cell.hideCode",Pn.NOOP),st("cell.format",Pn.NOOP);const c=Cc(),d=Ij(),u=c.getColumnIds(),h=s.scrollToTarget;let m,p;e[0]!==d||e[1]!==h?(m=()=>{d!==null&&h()},e[0]=d,e[1]=h,e[2]=m):m=e[2],e[3]!==c||e[4]!==d||e[5]!==h?(p=[c,d,h],e[3]=c,e[4]=d,e[5]=h,e[6]=p):p=e[6],S.useEffect(m,p);const b=jC;let x,f,g,y,w;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Yy,{}),f=i.jsx(kx,{}),g=i.jsx(Sv,{}),y=i.jsx(gv,{}),e[7]=x,e[8]=f,e[9]=g,e[10]=y):(x=e[7],f=e[8],g=e[9],y=e[10]),e[11]!==r.width?(w=i.jsx(jv,{width:r.width}),e[11]=r.width,e[12]=w):w=e[12];const j=r.width==="columns"&&"grid grid-flow-col auto-cols-min gap-6";let C;e[13]!==j?(C=de(j),e[13]=j,e[14]=C):C=e[14];const N=u.map((I,A)=>i.jsx(Mv,{columnId:I,index:A,columnsLength:u.length,appConfig:r,mode:n,userConfig:o,theme:a},I));let k,E,_;return e[15]!==C||e[16]!==N?(k=i.jsx("div",{className:C,children:N}),e[15]=C,e[16]=N,e[17]=k):k=e[17],e[18]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsx(Aj,{}),e[18]=E):E=e[18],e[19]!==b||e[20]!==r||e[21]!==w||e[22]!==k||e[23]!==x||e[24]!==f||e[25]!==g||e[26]!==y?(_=i.jsxs(b,{className:"pb-[40vh]",invisible:!1,appConfig:r,innerClassName:"pr-4",children:[x,f,g,y,w,k,E]}),e[19]=b,e[20]=r,e[21]=w,e[22]=k,e[23]=x,e[24]=f,e[25]=g,e[26]=y,e[27]=_):_=e[27],_},Mv=t=>{const e=z.c(54),{columnId:n,index:o,columnsLength:r,appConfig:s,mode:a,userConfig:l,theme:c}=t,d=Cc();let u,h,m,p,b,x,f,g,y,w,j,C,N,k,E,_;if(e[0]!==s.width||e[1]!==d||e[2]!==n||e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==c||e[7]!==l){const I=d.get(n);let A;Zt(I,`Expected column for: ${n}`),e[22]!==d?(A=d.hasOnlyOneId(),e[22]=d,e[23]=A):A=e[23];const O=A;let D;e[24]!==d.inOrderIds?(D=d.inOrderIds.includes(Pr),e[24]=d.inOrderIds,e[25]=D):D=e[25];const M=D;h=Hf,j=n,C=o,N=o>0,k=o<r-1,p=s.width,b=r>1;const R=s.width==="columns"&&"opacity-0 group-hover/column:opacity-100";let L;e[26]!==R?(L=de(R),e[26]=R,e[27]=L):L=e[27],e[28]!==n||e[29]!==L?(x=i.jsx(Ov,{columnId:n,className:L}),e[28]=n,e[29]=L,e[30]=x):x=e[30],u=Vu,m=`column-${o+1}`,f=I.topLevelIds,g=fx,e[31]!==M||e[32]!==o||e[33]!==a||e[34]!==c||e[35]!==l?(y=o===0&&M&&i.jsx(Uf,{cellId:Pr,theme:c,showPlaceholder:!1,canDelete:!0,mode:a,userConfig:l,isCollapsed:!1,collapseCount:0,canMoveX:!1},Pr),e[31]=M,e[32]=o,e[33]=a,e[34]=c,e[35]=l,e[36]=y):y=e[36],w=I.topLevelIds.map(P=>P===Pr?null:i.jsx(Uf,{cellId:P,theme:c,showPlaceholder:O,canDelete:!O,mode:a,userConfig:l,isCollapsed:I.isCollapsed(P),collapseCount:I.getCount(P),canMoveX:s.width==="columns"},P)),e[0]=s.width,e[1]=d,e[2]=n,e[3]=r,e[4]=o,e[5]=a,e[6]=c,e[7]=l,e[8]=u,e[9]=h,e[10]=m,e[11]=p,e[12]=b,e[13]=x,e[14]=f,e[15]=g,e[16]=y,e[17]=w,e[18]=j,e[19]=C,e[20]=N,e[21]=k}else u=e[8],h=e[9],m=e[10],p=e[11],b=e[12],x=e[13],f=e[14],g=e[15],y=e[16],w=e[17],j=e[18],C=e[19],N=e[20],k=e[21];return e[37]!==u||e[38]!==m||e[39]!==f||e[40]!==g||e[41]!==y||e[42]!==w?(E=i.jsxs(u,{id:m,items:f,strategy:g,children:[y,w]}),e[37]=u,e[38]=m,e[39]=f,e[40]=g,e[41]=y,e[42]=w,e[43]=E):E=e[43],e[44]!==h||e[45]!==p||e[46]!==b||e[47]!==x||e[48]!==E||e[49]!==j||e[50]!==C||e[51]!==N||e[52]!==k?(_=i.jsx(h,{columnId:j,index:C,canMoveLeft:N,canMoveRight:k,width:p,canDelete:b,footer:x,children:E}),e[44]=h,e[45]=p,e[46]=b,e[47]=x,e[48]=E,e[49]=j,e[50]=C,e[51]=N,e[52]=k,e[53]=_):_=e[53],_},Ov=t=>{const e=z.c(17),{columnId:n,className:o}=t,{createNewCell:r}=Ke(),[s,a]=Tj(!1),l=ie(mc),c=ie(qp);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=de("mb-0 rounded-none sm:px-4 md:px-5 lg:px-8 tracking-wide no-wrap whitespace-nowrap","hover:bg-accent hover:text-accent-foreground font-semibold uppercase text-xs"),e[0]=d):d=e[0];const u=d;let h;e[1]!==l||e[2]!==n||e[3]!==r||e[4]!==s||e[5]!==a.toggle||e[6]!==c?(h=()=>s?i.jsx(Dj,{onClose:a.toggle}):i.jsxs(i.Fragment,{children:[i.jsxs(ye,{className:u,variant:"text",size:"sm",disabled:!c,onClick:()=>r({cellId:{type:"__end__",columnId:n},before:!1}),children:[i.jsx(md,{className:"mr-2 size-4 shrink-0"}),"Python"]}),i.jsxs(ye,{className:u,variant:"text",size:"sm",disabled:!c,onClick:()=>{qn({autoInstantiate:!0,createNewCell:r}),r({cellId:{type:"__end__",columnId:n},before:!1,code:Bo.markdown.defaultCode,hideCode:!0})},children:[i.jsx(pd,{className:"mr-2 size-4 shrink-0"}),"Markdown"]}),i.jsxs(ye,{className:u,variant:"text",size:"sm",disabled:!c,onClick:()=>{qn({autoInstantiate:!0,createNewCell:r}),r({cellId:{type:"__end__",columnId:n},before:!1,code:Bo.sql.defaultCode})},children:[i.jsx(_o,{className:"mr-2 size-4 shrink-0"}),"SQL"]}),i.jsx(pe,{content:l?null:i.jsx("span",{children:"Enable via settings under AI Assist"}),delayDuration:100,asChild:!1,children:i.jsxs(ye,{className:u,variant:"text",size:"sm",disabled:!l||!c,onClick:a.toggle,children:[i.jsx(Rr,{className:"mr-2 size-4 shrink-0"}),"Generate with AI"]})})]}),e[1]=l,e[2]=n,e[3]=r,e[4]=s,e[5]=a.toggle,e[6]=c,e[7]=h):h=e[7];const m=h,p=!s&&"w-fit",b=s&&"opacity-100 w-full max-w-4xl shadow-lg shadow-(color:--blue-3)";let x,f,g;return e[8]!==o||e[9]!==p||e[10]!==b?(x=de("shadow-sm border border-border rounded transition-all duration-200 overflow-hidden divide-x divide-border flex",p,b,o),e[8]=o,e[9]=p,e[10]=b,e[11]=x):x=e[11],e[12]!==m?(f=m(),e[12]=m,e[13]=f):f=e[13],e[14]!==x||e[15]!==f?(g=i.jsx("div",{className:"flex justify-center mt-4 pt-6 pb-32 group gap-4 w-full print:hidden",children:i.jsx("div",{className:x,children:f})}),e[14]=x,e[15]=f,e[16]=g):g=e[16],g};function Rv(){Wp()}const Lv=Mj(t=>r1().syncCellIds(t),400),Fv=(t,e)=>{Le.get(To)||t.isEmpty()||e.isEmpty()||kr(t.inOrderIds,e.inOrderIds)||Lv({cell_ids:t.inOrderIds})},Yf=t=>{const e=z.c(70),{userConfig:n,appConfig:o,hideControls:r}=t,s=r!==void 0&&r;Oj(ga,Fv);const{setCells:a,mergeAllColumns:l,collapseAllCells:c,expandAllCells:d}=Ke(),u=ie(Sl),h=ie(Rj),m=ie(Lj),p=zl(),b=Ct(ti),{sendComponentValues:x,sendInterrupt:f}=qe(),g=u.mode==="edit",y=u.mode==="present",w=ie(Fj);let j,C;e[0]!==x?(j=()=>(sg.INSTANCE.start(x),Bv),e[0]=x,e[1]=j):j=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[2]=C):C=e[2],S.useEffect(j,C);const N=n.runtime.auto_instantiate;let k,E,_;e[3]!==a||e[4]!==b?(k=(oe,Ee)=>{a(oe);const ve=oe.map(Pv),ge=oe.map(zv),ke=oe.map(Uv);b({names:ve,codes:ge,configs:ke,layout:Ee})},e[3]=a,e[4]=b,e[5]=k):k=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(E=y1(),e[6]=E):E=e[6],e[7]!==k||e[8]!==n.runtime.auto_instantiate?(_={autoInstantiate:N,setCells:k,sessionId:E},e[7]=k,e[8]=n.runtime.auto_instantiate,e[9]=_):_=e[9];const{connection:I}=CC(_);let A,O;e[10]!==o.app_title||e[11]!==p?(A=()=>{document.title=o.app_title||Ot.basename(p??"")||"Untitled Notebook"},O=[o.app_title,p],e[10]=o.app_title,e[11]=p,e[12]=A,e[13]=O):(A=e[12],O=e[13]),S.useEffect(A,O);const D=la(o.width);let M,R;e[14]!==o.width||e[15]!==l||e[16]!==D?(M=()=>{D==="columns"&&o.width!=="columns"&&l()},e[14]=o.width,e[15]=l,e[16]=D,e[17]=M):M=e[17],e[18]!==o.width||e[19]!==l||e[20]!==h||e[21]!==D?(R=[o.width,D,l,h],e[18]=o.width,e[19]=l,e[20]=h,e[21]=D,e[22]=R):R=e[22],S.useEffect(M,R);const L=(function(){const oe=z.c(2),Ee=Ho();let ve;return oe[0]!==Ee?(ve=()=>Ee(rk(Mt())),oe[0]=Ee,oe[1]=ve):ve=oe[1],Ce(ve)})(),P=_d(),T=Ed();let F,$,W,H,X,q,Y;e[23]!==L?(F=()=>{L()},e[23]=L,e[24]=F):F=e[24],st("global.runStale",F),e[25]!==f?($=()=>{f()},e[25]=f,e[26]=$):$=e[26],st("global.interrupt",$),e[27]!==T?(W=()=>{T()},e[27]=T,e[28]=W):W=e[28],st("global.hideCode",W),e[29]!==P?(H=()=>{P()},e[29]=P,e[30]=H):H=e[30],st("global.runAll",H),e[31]!==c?(X=()=>{c()},e[31]=c,e[32]=X):X=e[32],st("global.collapseAllSections",X),e[33]!==d?(q=()=>{d()},e[33]=d,e[34]=q):q=e[34],st("global.expandAllSections",q),e[35]!==o||e[36]!==n||e[37]!==u.mode?(Y=i.jsx(Tv,{mode:u.mode,userConfig:n,appConfig:o}),e[35]=o,e[36]=n,e[37]=u.mode,e[38]=Y):Y=e[38];const J=Y,V=o.width;let G,U,ne,Q,ee,te,se,ae;return e[39]===Symbol.for("react.memo_cache_sentinel")?(G=de("pt-4 sm:pt-12 pb-2 mb-4 print:hidden z-50","sticky left-0"),e[39]=G):G=e[39],e[40]!==p||e[41]!==g?(U=g&&i.jsx("div",{className:"flex items-center justify-center container",children:i.jsx(gb,{filename:p})}),e[40]=p,e[41]=g,e[42]=U):U=e[42],e[43]!==I||e[44]!==U?(ne=i.jsx(SC,{connection:I,className:G,children:U}),e[43]=I,e[44]=U,e[45]=ne):ne=e[45],e[46]!==o||e[47]!==J||e[48]!==m||e[49]!==u.mode?(Q=m&&i.jsx(NC,{appConfig:o,mode:u.mode,children:J}),e[46]=o,e[47]=J,e[48]=m,e[49]=u.mode,e[50]=Q):Q=e[50],e[51]!==o.width||e[52]!==I||e[53]!==w||e[54]!==ne||e[55]!==Q?(ee=i.jsxs(EC,{connection:I,isRunning:w,width:V,children:[ne,Q]}),e[51]=o.width,e[52]=I,e[53]=w,e[54]=ne,e[55]=Q,e[56]=ee):ee=e[56],e[57]===Symbol.for("react.memo_cache_sentinel")?(te=i.jsx(Eb,{}),e[57]=te):te=e[57],e[58]!==o||e[59]!==I||e[60]!==s||e[61]!==y||e[62]!==w||e[63]!==L||e[64]!==f||e[65]!==T?(se=!s&&i.jsx(va,{children:i.jsx(ub,{presenting:y,onTogglePresenting:T,onInterrupt:f,onRun:L,connectionState:I.state,running:w,appConfig:o})}),e[58]=o,e[59]=I,e[60]=s,e[61]=y,e[62]=w,e[63]=L,e[64]=f,e[65]=T,e[66]=se):se=e[66],e[67]!==ee||e[68]!==se?(ae=i.jsxs(i.Fragment,{children:[ee,te,se]}),e[67]=ee,e[68]=se,e[69]=ae):ae=e[69],ae};function Bv(){sg.INSTANCE.stop()}function Pv(t){return t.name}function zv(t){return t.code}function Uv(t){return t.config}const Xf=t=>ie(Bj)[t.capability]?t.children:null,At=S.forwardRef((t,e)=>{const n=z.c(18);let o,r,s,a,l;n[0]!==t?({children:o,tooltip:l,selected:a,className:r,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a,n[5]=l):(o=n[1],r=n[2],s=n[3],a=n[4],l=n[5]);const c=!a&&"hover:bg-(--sage-3)",d=a&&"bg-(--sage-4)";let u,h;n[6]!==r||n[7]!==c||n[8]!==d?(u=de("h-full flex items-center p-2 text-sm shadow-inset font-mono cursor-pointer rounded",c,d,r),n[6]=r,n[7]=c,n[8]=d,n[9]=u):u=n[9],n[10]!==o||n[11]!==e||n[12]!==s||n[13]!==u?(h=i.jsx("div",{ref:e,className:u,...s,children:o}),n[10]=o,n[11]=e,n[12]=s,n[13]=u,n[14]=h):h=n[14];const m=h;if(l){let p;return n[15]!==m||n[16]!==l?(p=i.jsx(pe,{content:l,side:"top",delayDuration:200,children:m}),n[15]=m,n[16]=l,n[17]=p):p=n[17],p}return m});At.displayName="FooterItem";const Wv=()=>{var p,b;const t=z.c(17),e=ie(Pj),n=ie(mc),o=((p=e==null?void 0:e.models)==null?void 0:p.chat_model)||zj,r=((b=e==null?void 0:e.models)==null?void 0:b.edit_model)||o,{handleClick:s}=q1();if(!n){let x,f,g;return t[0]!==s?(x=()=>s("ai"),t[0]=s,t[1]=x):x=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Rr,{className:"h-4 w-4 opacity-60"}),t[2]=f):f=t[2],t[3]!==x?(g=i.jsx(At,{tooltip:"Assist is disabled",selected:!1,onClick:x,"data-testid":"footer-ai-disabled",children:f}),t[3]=x,t[4]=g):g=t[4],g}let a,l,c,d,u,h,m;return t[5]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("b",{children:"Chat model:"}),t[5]=a):a=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("br",{}),c=i.jsx("b",{children:"Edit model:"}),t[6]=l,t[7]=c):(l=t[6],c=t[7]),t[8]!==o||t[9]!==r?(d=i.jsxs(i.Fragment,{children:[a," ",o,l,c," ",r]}),t[8]=o,t[9]=r,t[10]=d):d=t[10],t[11]!==s?(u=()=>s("ai"),t[11]=s,t[12]=u):u=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Rr,{className:"h-4 w-4"}),t[13]=h):h=t[13],t[14]!==d||t[15]!==u?(m=i.jsx(At,{tooltip:d,onClick:u,selected:!1,"data-testid":"footer-ai-enabled",children:h}),t[14]=d,t[15]=u,t[16]=m):m=t[16],m},$v=()=>{const t=z.c(26),e=ie(Nt).state,n=w1();let o,r;t[0]!==e||t[1]!==n?(o=async()=>{if(e===mt.OPEN){if(Xt())return{isHealthy:!0,lastChecked:new Date,error:void 0};try{return{isHealthy:await n.isHealthy(),lastChecked:new Date,error:void 0}}catch(j){const C=j;return{isHealthy:!1,lastChecked:new Date,error:C instanceof Error?C.message:"Unknown error"}}}},r=[n,e],t[0]=e,t[1]=n,t[2]=o,t[3]=r):(o=t[2],r=t[3]);const{isFetching:s,error:a,data:l,refetch:c}=vr(o,r),d=e===mt.OPEN?3e4:null;let u,h;t[4]!==d?(u={delayMs:d,whenVisible:!0},t[4]=d,t[5]=u):u=t[5],zr(c,u),t[6]!==e||t[7]!==l||t[8]!==a?(h=()=>[Ll(e.toLowerCase()),l!=null&&l.lastChecked?l.isHealthy?"\u2713 Healthy":"\u2717 Unhealthy":"Health: Unknown",a?`Error: ${a}`:""].filter(Boolean).join(`
139
+ `),t[6]=e,t[7]=l,t[8]=a,t[9]=h):h=t[9];const m=h;let p;t[10]!==e||t[11]!==(l==null?void 0:l.isHealthy)||t[12]!==(l==null?void 0:l.lastChecked)||t[13]!==s?(p=()=>s||e===mt.CONNECTING?i.jsx(ya,{size:"small"}):e===mt.CLOSING?i.jsx(ya,{className:"text-destructive",size:"small"}):e===mt.OPEN?l!=null&&l.isHealthy?i.jsx(Na,{className:"w-4 h-4 text-(--green-9)"}):l!=null&&l.lastChecked?i.jsx(vc,{className:"w-4 h-4 text-(--yellow-9)"}):i.jsx(Na,{className:"w-4 h-4"}):i.jsx(Ur,{className:"w-4 h-4 text-red-500"}),t[10]=e,t[11]=l==null?void 0:l.isHealthy,t[12]=l==null?void 0:l.lastChecked,t[13]=s,t[14]=p):p=t[14];const b=p,x=m();let f,g,y,w;return t[15]!==e?(f=e===mt.OPEN&&i.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Click to refresh health status"}),t[15]=e,t[16]=f):f=t[16],t[17]!==x||t[18]!==f?(g=i.jsxs("div",{className:"text-sm whitespace-pre-line",children:[x,f]}),t[17]=x,t[18]=f,t[19]=g):g=t[19],t[20]!==b?(y=b(),t[20]=b,t[21]=y):y=t[21],t[22]!==c||t[23]!==g||t[24]!==y?(w=i.jsx(At,{tooltip:g,selected:!1,onClick:c,"data-testid":"footer-backend-status",children:y}),t[22]=c,t[23]=g,t[24]=y,t[25]=w):w=t[25],w},Vv=t=>{const e=z.c(3);let n,o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("path",{d:"M205.28 31.36c14.096 14.88 20.016 35.2 22.512 63.68c6.626 0 12.805 1.47 16.976 7.152l7.792 10.56A17.55 17.55 0 0 1 256 123.2v28.688c-.008 3.704-1.843 7.315-4.832 9.504C215.885 187.222 172.35 208 128 208c-49.066 0-98.19-28.273-123.168-46.608c-2.989-2.189-4.825-5.8-4.832-9.504V123.2c0-3.776 1.2-7.424 3.424-10.464l7.792-10.544c4.173-5.657 10.38-7.152 16.992-7.152c2.496-28.48 8.4-48.8 22.512-63.68C77.331 3.165 112.567.06 127.552 0H128c14.72 0 50.4 2.88 77.28 31.36m-77.264 47.376c-3.04 0-6.544.176-10.272.544c-1.312 4.896-3.248 9.312-6.08 12.128c-11.2 11.2-24.704 12.928-31.936 12.928c-6.802 0-13.927-1.42-19.744-5.088c-5.502 1.808-10.786 4.415-11.136 10.912c-.586 12.28-.637 24.55-.688 36.824c-.026 6.16-.05 12.322-.144 18.488c.024 3.579 2.182 6.903 5.44 8.384C79.936 185.92 104.976 192 128.016 192c23.008 0 48.048-6.08 74.512-18.144c3.258-1.48 5.415-4.805 5.44-8.384c.317-18.418.062-36.912-.816-55.312h.016c-.342-6.534-5.648-9.098-11.168-10.912c-5.82 3.652-12.927 5.088-19.728 5.088c-7.232 0-20.72-1.728-31.936-12.928c-2.832-2.816-4.768-7.232-6.08-12.128a106 106 0 0 0-10.24-.544m-26.941 43.93c5.748 0 10.408 4.66 10.408 10.409v19.183c0 5.749-4.66 10.409-10.408 10.409s-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408m53.333 0c5.749 0 10.409 4.66 10.409 10.409v19.183c0 5.749-4.66 10.409-10.409 10.409c-5.748 0-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408M81.44 28.32c-11.2 1.12-20.64 4.8-25.44 9.92c-10.4 11.36-8.16 40.16-2.24 46.24c4.32 4.32 12.48 7.2 21.28 7.2c6.72 0 19.52-1.44 30.08-12.16c4.64-4.48 7.52-15.68 7.2-27.04c-.32-9.12-2.88-16.64-6.72-19.84c-4.16-3.68-13.6-5.28-24.16-4.32m68.96 4.32c-3.84 3.2-6.4 10.72-6.72 19.84c-.32 11.36 2.56 22.56 7.2 27.04c10.56 10.72 23.36 12.16 30.08 12.16c8.8 0 16.96-2.88 21.28-7.2c5.92-6.08 8.16-34.88-2.24-46.24c-4.8-5.12-14.24-8.8-25.44-9.92c-10.56-.96-20 .64-24.16 4.32M128 56c-2.56 0-5.6.16-8.96.48c.32 1.76.48 3.68.64 5.76c0 1.44 0 2.88-.16 4.48c3.2-.32 5.92-.32 8.48-.32s5.28 0 8.48.32c-.16-1.6-.16-3.04-.16-4.48c.16-2.08.32-4 .64-5.76c-3.36-.32-6.4-.48-8.96-.48"}),e[0]=n):n=e[0],e[1]!==t?(o=i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1.24em",height:"1em",viewBox:"0 0 256 208",fill:"currentColor",...t,children:n}),e[1]=t,e[2]=o):o=e[2],o},Gv=Qt(t=>t(Uj).completion.copilot),qv=()=>{const t=z.c(1);if(ie(Gv)==="github"){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(Hv,{}),t[0]=e):e=t[0],e}return null},Qf=Ye.get("[copilot-status-bar]"),Hv=()=>{const t=ie(H1),e=ie(hC)!==null,{handleClick:n}=q1(),o=()=>n("ai"),r=t?"Ready":"Not connected",s=Ct(H1),a=Ct(mC);return P1(()=>{const l=G1();let c=!0;return(async()=>{try{if(await l.initializePromise.catch(u=>{throw Qf.error("Failed to initialize",u),l.close(),u}),!c)return;const d=await l.signedIn();if(!c)return;s(d),a(d?"signedIn":"signedOut")}catch(d){if(!c)return;Qf.warn("Connection failed",d),s(!1),a("connectionError"),ze({title:"GitHub Copilot Connection Error",description:"Failed to connect to GitHub Copilot. Check settings and try again.",variant:"danger",action:i.jsx(ye,{variant:"link",onClick:o,children:"Settings"})})}})(),()=>{c=!1}}),i.jsx(At,{tooltip:i.jsxs(i.Fragment,{children:[i.jsx("b",{children:"GitHub Copilot:"})," ",r]}),selected:!1,onClick:o,"data-testid":"footer-copilot-status",children:i.jsx("span",{children:e?i.jsx(ya,{className:"h-4 w-4"}):i.jsx(Vv,{className:de("h-4 w-4",!t&&"opacity-60")})})})},Jv=()=>{const t=z.c(18),[e,n]=S.useState(0),o=ie(Nt),{getUsageStats:r}=qe();let s,a,l,c;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>n(Qv),a={delayMs:1e4,whenVisible:!0},t[0]=s,t[1]=a):(s=t[0],a=t[1]),zr(s,a),t[2]!==o.state||t[3]!==r?(l=async()=>Xt()||o.state!==mt.OPEN?null:r(),t[2]=o.state,t[3]=r,t[4]=l):l=t[4],t[5]!==o.state||t[6]!==e?(c=[e,o.state],t[5]=o.state,t[6]=e,t[7]=c):c=t[7];const{data:d}=vr(l,c);let u,h,m,p;return t[8]!==d?(u=(d==null?void 0:d.gpu)&&d.gpu.length>0&&i.jsx(Xv,{gpus:d.gpu}),t[8]=d,t[9]=u):u=t[9],t[10]!==d?(h=d&&i.jsx(Kv,{memory:d.memory,kernel:d.kernel,server:d.server}),t[10]=d,t[11]=h):h=t[11],t[12]!==d?(m=d&&i.jsx(Yv,{cpu:d.cpu}),t[12]=d,t[13]=m):m=t[13],t[14]!==u||t[15]!==h||t[16]!==m?(p=i.jsxs("div",{className:"flex gap-2 items-center px-1",children:[u,h,m]}),t[14]=u,t[15]=h,t[16]=m,t[17]=p):p=t[17],p},Kv=t=>{const e=z.c(36),{memory:n,kernel:o,server:r}=t,{percent:s,total:a,available:l}=n;let c;e[0]!==s?(c=Math.round(s),e[0]=s,e[1]=c):c=e[1];const d=c;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u={maximumFractionDigits:2},e[2]=u):u=e[2];const h=wa(u);let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m={maximumFractionDigits:0},e[3]=m):m=e[3];const p=wa(m);let b;e[4]!==h||e[5]!==p?(b=D=>D>1073741824?`${h.format(D/1073741824)} GB`:`${p.format(D/1048576)} MB`,e[4]=h,e[5]=p,e[6]=b):b=e[6];const x=b;let f;e[7]!==h?(f=D=>h.format(D/1073741824),e[7]=h,e[8]=f):f=e[8];const g=f;let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx("b",{children:"computer memory:"}),e[9]=y):y=e[9];const w=a-l;let j,C,N,k,E,_,I,A,O;return e[10]!==g||e[11]!==w?(j=g(w),e[10]=g,e[11]=w,e[12]=j):j=e[12],e[13]!==g||e[14]!==a?(C=g(a),e[13]=g,e[14]=a,e[15]=C):C=e[15],e[16]!==d||e[17]!==j||e[18]!==C?(N=i.jsxs("span",{children:[y," ",j," /"," ",C," GB (",d,"%)"]}),e[16]=d,e[17]=j,e[18]=C,e[19]=N):N=e[19],e[20]!==x||e[21]!==r?(k=(r==null?void 0:r.memory)&&i.jsxs("span",{children:[i.jsx("b",{children:"marimo server:"})," ",x(r.memory)]}),e[20]=x,e[21]=r,e[22]=k):k=e[22],e[23]!==x||e[24]!==o?(E=(o==null?void 0:o.memory)&&i.jsxs("span",{children:[i.jsx("b",{children:"kernel:"})," ",x(o.memory)]}),e[23]=x,e[24]=o,e[25]=E):E=e[25],e[26]!==N||e[27]!==k||e[28]!==E?(_=i.jsxs("div",{className:"flex flex-col gap-1",children:[N,k,E]}),e[26]=N,e[27]=k,e[28]=E,e[29]=_):_=e[29],e[30]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(sd,{className:"w-4 h-4"}),e[30]=I):I=e[30],e[31]!==d?(A=i.jsxs("div",{className:"flex items-center gap-1","data-testid":"memory-usage-bar",children:[I,i.jsx(yl,{percent:d,colorClassName:"bg-primary"})]}),e[31]=d,e[32]=A):A=e[32],e[33]!==_||e[34]!==A?(O=i.jsx(pe,{delayDuration:200,content:_,children:A}),e[33]=_,e[34]=A,e[35]=O):O=e[35],O},Yv=t=>{const e=z.c(11),{cpu:n}=t,{percent:o}=n;let r;e[0]!==o?(r=Math.round(o),e[0]=o,e[1]=r):r=e[1];const s=r;let a,l,c,d,u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("b",{children:"CPU:"}),e[2]=a):a=e[2],e[3]!==s?(l=i.jsxs("span",{children:[a," ",s,"%"]}),e[3]=s,e[4]=l):l=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(fC,{className:"w-4 h-4"}),e[5]=c):c=e[5],e[6]!==s?(d=i.jsxs("div",{className:"flex items-center gap-1","data-testid":"cpu-bar",children:[c,i.jsx(yl,{percent:s,colorClassName:"bg-primary"})]}),e[6]=s,e[7]=d):d=e[7],e[8]!==l||e[9]!==d?(u=i.jsx(pe,{delayDuration:200,content:l,children:d}),e[8]=l,e[9]=d,e[10]=u):u=e[10],u},Xv=t=>{const e=z.c(20),{gpus:n}=t;let o;e[0]!==n?(o=Math.round(n.reduce(Zv,0)/n.length),e[0]=n,e[1]=o):o=e[1];const r=o;let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s={maximumFractionDigits:2},e[2]=s):s=e[2];const a=wa(s);let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l={maximumFractionDigits:0},e[3]=l):l=e[3];const c=wa(l);let d;e[4]!==a||e[5]!==c?(d=f=>f>1073741824?`${a.format(f/1073741824)} GB`:`${c.format(f/1048576)} MB`,e[4]=a,e[5]=c,e[6]=d):d=e[6];const u=d;let h,m,p,b,x;if(e[7]!==u||e[8]!==n){let f;e[10]!==u?(f=g=>i.jsxs("span",{children:[i.jsxs("b",{children:["GPU ",g.index," (",g.name,"):"]})," ",u(g.memory.used)," / ",u(g.memory.total)," (",Math.round(g.memory.percent),"%)"]},g.index),e[10]=u,e[11]=f):f=e[11],h=n.map(f),e[7]=u,e[8]=n,e[9]=h}else h=e[9];return e[12]!==h?(m=i.jsx("div",{className:"flex flex-col gap-1",children:h}),e[12]=h,e[13]=m):m=e[13],e[14]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(id,{className:"w-4 h-4"}),e[14]=p):p=e[14],e[15]!==r?(b=i.jsxs("div",{className:"flex items-center gap-1","data-testid":"gpu-bar",children:[p,i.jsx(yl,{percent:r,colorClassName:"bg-(--grass-9)"})]}),e[15]=r,e[16]=b):b=e[16],e[17]!==m||e[18]!==b?(x=i.jsx(pe,{delayDuration:200,content:m,children:b}),e[17]=m,e[18]=b,e[19]=x):x=e[19],x},yl=t=>{const e=z.c(7),{percent:n,colorClassName:o}=t;let r;e[0]!==o?(r=de("h-full bg-primary",o),e[0]=o,e[1]=r):r=e[1];const s=`${n}%`;let a,l;return e[2]!==s?(a={width:s},e[2]=s,e[3]=a):a=e[3],e[4]!==r||e[5]!==a?(l=i.jsx("div",{className:"h-3 w-20 bg-(--slate-4) rounded-lg overflow-hidden border",children:i.jsx("div",{className:r,style:a})}),e[4]=r,e[5]=a,e[6]=l):l=e[6],l};function Qv(t){return t+1}function Zv(t,e){return t+e.memory.percent}const Zf=Qt(!1);function vl(t,e,n=new Set){if(n.has(t))return new Set;n.add(t);const o=new Set;for(const r of e(t)){o.add(r);for(const s of vl(r,e,n))o.add(s)}return o}const ew=Qt(t=>{const e=t(ga),n=t(Hp);return(function(o,r){var l,c,d;const s=new Map;for(const u of o)s.set(u,{variables:new Set,parents:new Set,children:new Set});for(const u of Object.values(r))if(u.dataType!=="module")for(const h of u.declaredBy){(l=s.get(h))==null||l.variables.add(u.name);for(const m of u.usedBy)h!==m&&((c=s.get(m))==null||c.parents.add(h),(d=s.get(h))==null||d.children.add(m))}const a={};for(const[u,h]of s.entries())a[u]={parents:h.parents,children:h.children,variables:[...h.variables],ancestors:vl(u,m=>{var p;return((p=s.get(m))==null?void 0:p.parents)??new Set}),descendants:vl(u,m=>{var p;return((p=s.get(m))==null?void 0:p.children)??new Set})};return a})(e.inOrderIds,n)});function tw(t,e){return e?t.usedBy.includes(e.id)||t.declaredBy.includes(e.id)?!0:t.declaredBy.some(n=>e.graph.parents.has(n))?t.usedBy.some(n=>e.graph.parents.has(n)):!!t.declaredBy.some(n=>e.graph.children.has(n)):!1}const nw=()=>{const t=z.c(6),[e,n]=_n(Zf);let o,r,s;return t[0]!==n?(o=()=>n(ow),t[0]=n,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(rd,{className:"h-4 w-4"}),t[2]=r):r=t[2],t[3]!==e||t[4]!==o?(s=i.jsx(At,{tooltip:"Toggle Minimap",selected:e,onClick:o,"data-testid":"footer-minimap",children:r}),t[3]=e,t[4]=o,t[5]=s):s=t[5],s};function ow(t){return!t}const rw=()=>{const t=z.c(13),e=ie(yo),[n,o]=_n(v1),[r,s]=S.useState(!1);if(!pa()||e==="disabled")return null;const a=e?"Real-time collaboration active":"Connecting to real-time collaboration";let l,c,d,u,h,m;return t[0]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(xd,{className:"w-4 h-4"}),t[0]=l):l=t[0],t[1]!==a?(c=i.jsx(pc,{asChild:!0,children:i.jsx(At,{tooltip:a,selected:!1,"data-testid":"footer-rtc-status",children:l})}),t[1]=a,t[2]=c):c=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsxs("div",{className:"space-y-2",children:[i.jsx("h4",{className:"font-medium leading-none",children:"Username"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Set your username for real-time collaboration"})]}),t[3]=d):d=t[3],t[4]!==o?(u=p=>o(p.target.value),t[4]=o,t[5]=u):u=t[5],t[6]!==u||t[7]!==n?(h=i.jsx(Kl,{className:"w-80",children:i.jsxs("div",{className:"space-y-4",children:[d,i.jsx(ao,{value:n,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",onChange:u,placeholder:"Enter your username"})]})}),t[6]=u,t[7]=n,t[8]=h):h=t[8],t[9]!==r||t[10]!==c||t[11]!==h?(m=i.jsxs(ta,{open:r,onOpenChange:s,children:[c,h]}),t[9]=r,t[10]=c,t[11]=h,t[12]=m):m=t[12],m},sw=t=>{const e=z.c(104),{className:n}=t,{saveUserConfig:o}=qe(),[r,s]=Wj(),a=Qs()[0],[l,c]=S.useState(!1);let d,u,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const we=window.matchMedia("(min-width: 768px)"),be=()=>{we.matches&&c(!1)};return we.addEventListener("change",be),()=>we.removeEventListener("change",be)},u=[],e[0]=d,e[1]=u):(d=e[0],u=e[1]),S.useEffect(d,u),e[2]!==a||e[3]!==o||e[4]!==s?(h=async we=>{const be={...a,runtime:{...a.runtime,auto_instantiate:we}};await o({config:be}).then(()=>s(be))},e[2]=a,e[3]=o,e[4]=s,e[5]=h):h=e[5];const m=h;let p;e[6]!==o||e[7]!==s||e[8]!==r?(p=async we=>{const be={...r,runtime:{...r.runtime,on_cell_change:we?"autorun":"lazy"}};await o({config:be}).then(()=>s(be))},e[6]=o,e[7]=s,e[8]=r,e[9]=p):p=e[9];const b=p;let x;e[10]!==o||e[11]!==s||e[12]!==r?(x=async we=>{const be={...r,runtime:{...r.runtime,auto_reload:we}};await o({config:be}).then(()=>s(be))},e[10]=o,e[11]=s,e[12]=r,e[13]=x):x=e[13];const f=x;let g;e[14]!==a.runtime.auto_instantiate||e[15]!==a.runtime.auto_reload||e[16]!==a.runtime.on_cell_change?(g=!a.runtime.auto_instantiate&&a.runtime.on_cell_change==="lazy"&&(Xt()||a.runtime.auto_reload!=="autorun"),e[14]=a.runtime.auto_instantiate,e[15]=a.runtime.auto_reload,e[16]=a.runtime.on_cell_change,e[17]=g):g=e[17];const y=g;let w;e[18]!==n?(w=de("flex items-center",n),e[18]=n,e[19]=w):w=e[19];const j=a.runtime.auto_instantiate?"Disable autorun on startup":"Enable autorun on startup";let C,N,k;e[20]!==a.runtime.auto_instantiate||e[21]!==m?(C=()=>m(!a.runtime.auto_instantiate),e[20]=a.runtime.auto_instantiate,e[21]=m,e[22]=C):C=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(N=i.jsx("span",{children:"on startup: "}),e[23]=N):N=e[23],e[24]!==a.runtime.auto_instantiate?(k=a.runtime.auto_instantiate?i.jsx(_t,{size:14}):i.jsx(Et,{size:14}),e[24]=a.runtime.auto_instantiate,e[25]=k):k=e[25];const E=a.runtime.auto_instantiate?"autorun":"lazy";let _,I,A,O;e[26]!==E?(_=i.jsx("span",{children:E}),e[26]=E,e[27]=_):_=e[27],e[28]!==k||e[29]!==_?(I=i.jsxs("div",{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[N,k,_]}),e[28]=k,e[29]=_,e[30]=I):I=e[30],e[31]!==I||e[32]!==j||e[33]!==C?(A=i.jsx(zo,{name:"runtime.auto_instantiate",children:i.jsx(At,{tooltip:j,selected:!1,onClick:C,"data-testid":"footer-autorun-startup",children:I})}),e[31]=I,e[32]=j,e[33]=C,e[34]=A):A=e[34],e[35]===Symbol.for("react.memo_cache_sentinel")?(O=i.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[35]=O):O=e[35];const D=a.runtime.on_cell_change==="autorun"?"Disable autorun":"Enable autorun";let M,R,L,P,T,F,$,W,H,X,q,Y,J;e[36]!==a.runtime.on_cell_change||e[37]!==b?(M=()=>b(a.runtime.on_cell_change!=="autorun"),e[36]=a.runtime.on_cell_change,e[37]=b,e[38]=M):M=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(R=i.jsx("span",{children:"on cell change: "}),e[39]=R):R=e[39],e[40]!==a.runtime.on_cell_change?(L=i.jsxs("div",{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[R,a.runtime.on_cell_change==="autorun"?i.jsx(_t,{size:14}):i.jsx(Et,{size:14}),i.jsx("span",{children:a.runtime.on_cell_change})]}),e[40]=a.runtime.on_cell_change,e[41]=L):L=e[41],e[42]!==D||e[43]!==M||e[44]!==L?(P=i.jsx(zo,{name:"runtime.on_cell_change",children:i.jsx(At,{tooltip:D,selected:!1,onClick:M,"data-testid":"footer-autorun-cell-change",children:L})}),e[42]=D,e[43]=M,e[44]=L,e[45]=P):P=e[45],e[46]!==a.runtime.auto_reload||e[47]!==f?(T=!Xt()&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"border-r border-border h-6 mx-1"}),i.jsx(zo,{name:"runtime.auto_reload",children:i.jsx(At,{tooltip:null,selected:!1,"data-testid":"footer-module-reload",children:i.jsxs(Un,{children:[i.jsxs(Wn,{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[i.jsx("span",{children:"on module change: "}),a.runtime.auto_reload==="off"&&i.jsx(Ur,{size:14}),a.runtime.auto_reload==="lazy"&&i.jsx(Et,{size:14}),a.runtime.auto_reload==="autorun"&&i.jsx(_t,{size:14}),i.jsx("span",{children:a.runtime.auto_reload}),i.jsx(Vn,{size:14})]}),i.jsx($n,{children:["off","lazy","autorun"].map(we=>i.jsxs(lo,{onClick:()=>f(we),children:[we==="off"&&i.jsx(Ur,{size:14,className:"mr-2 text-muted-foreground"}),we==="lazy"&&i.jsx(Et,{size:14,className:"mr-2 text-muted-foreground"}),we==="autorun"&&i.jsx(_t,{size:14,className:"mr-2 text-muted-foreground"}),we]},we))})]})})})]}),e[46]=a.runtime.auto_reload,e[47]=f,e[48]=T):T=e[48],e[49]!==A||e[50]!==P||e[51]!==T?(F=i.jsxs("div",{className:"hidden md:flex md:items-center",children:[A,O,P,T]}),e[49]=A,e[50]=P,e[51]=T,e[52]=F):F=e[52],e[53]!==y?($=y?i.jsx(Et,{size:16,className:"text-muted-foreground"}):i.jsx(_t,{size:16,className:"text-amber-500"}),e[53]=y,e[54]=$):$=e[54],e[55]===Symbol.for("react.memo_cache_sentinel")?(W=i.jsx(Vn,{size:14}),e[55]=W):W=e[55],e[56]!==$?(H=i.jsx(Wn,{asChild:!0,children:i.jsx(At,{tooltip:"Runtime reactivity",selected:!1,"data-testid":"footer-runtime-settings",children:i.jsxs("div",{className:"flex items-center gap-1",children:[$,W]})})}),e[56]=$,e[57]=H):H=e[57],e[58]===Symbol.for("react.memo_cache_sentinel")?(X=i.jsx(jp,{children:"Runtime reactivity"}),q=i.jsx(En,{}),e[58]=X,e[59]=q):(X=e[58],q=e[59]),e[60]!==a.runtime.auto_instantiate?(Y=a.runtime.auto_instantiate?i.jsx(_t,{size:14,className:"text-amber-500"}):i.jsx(Et,{size:14,className:"text-muted-foreground"}),e[60]=a.runtime.auto_instantiate,e[61]=Y):Y=e[61],e[62]===Symbol.for("react.memo_cache_sentinel")?(J=i.jsx("div",{className:"text-sm font-medium",children:"On startup"}),e[62]=J):J=e[62];const V=a.runtime.auto_instantiate?"autorun":"lazy";let G,U,ne,Q,ee,te,se,ae,oe;e[63]!==V?(G=i.jsxs("div",{children:[J,i.jsx("div",{className:"text-xs text-muted-foreground",children:V})]}),e[63]=V,e[64]=G):G=e[64],e[65]!==Y||e[66]!==G?(U=i.jsxs("div",{className:"flex items-center space-x-2",children:[Y,G]}),e[65]=Y,e[66]=G,e[67]=U):U=e[67],e[68]!==a.runtime.auto_instantiate||e[69]!==m?(ne=i.jsx(fc,{checked:a.runtime.auto_instantiate,onCheckedChange:m,size:"sm"}),e[68]=a.runtime.auto_instantiate,e[69]=m,e[70]=ne):ne=e[70],e[71]!==U||e[72]!==ne?(Q=i.jsx(zo,{name:"runtime.auto_instantiate",children:i.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[U,ne]})}),e[71]=U,e[72]=ne,e[73]=Q):Q=e[73],e[74]===Symbol.for("react.memo_cache_sentinel")?(ee=i.jsx(En,{}),e[74]=ee):ee=e[74],e[75]!==a.runtime.on_cell_change?(te=a.runtime.on_cell_change==="autorun"?i.jsx(_t,{size:14,className:"text-amber-500"}):i.jsx(Et,{size:14,className:"text-muted-foreground"}),e[75]=a.runtime.on_cell_change,e[76]=te):te=e[76],e[77]===Symbol.for("react.memo_cache_sentinel")?(se=i.jsx("div",{className:"text-sm font-medium",children:"On cell change"}),e[77]=se):se=e[77],e[78]!==a.runtime.on_cell_change?(ae=i.jsxs("div",{children:[se,i.jsx("div",{className:"text-xs text-muted-foreground",children:a.runtime.on_cell_change})]}),e[78]=a.runtime.on_cell_change,e[79]=ae):ae=e[79],e[80]!==te||e[81]!==ae?(oe=i.jsxs("div",{className:"flex items-center space-x-2",children:[te,ae]}),e[80]=te,e[81]=ae,e[82]=oe):oe=e[82];const Ee=a.runtime.on_cell_change==="autorun";let ve,ge,ke,fe,Ie,Oe;return e[83]!==b||e[84]!==Ee?(ve=i.jsx(fc,{checked:Ee,onCheckedChange:b,size:"sm"}),e[83]=b,e[84]=Ee,e[85]=ve):ve=e[85],e[86]!==oe||e[87]!==ve?(ge=i.jsx(zo,{name:"runtime.on_cell_change",children:i.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[oe,ve]})}),e[86]=oe,e[87]=ve,e[88]=ge):ge=e[88],e[89]!==a.runtime.auto_reload||e[90]!==f?(ke=!Xt()&&i.jsxs(i.Fragment,{children:[i.jsx(En,{}),i.jsx(zo,{name:"runtime.auto_reload",children:i.jsxs("div",{className:"px-2 py-1",children:[i.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[a.runtime.auto_reload==="off"&&i.jsx(Ur,{size:14,className:"text-muted-foreground"}),a.runtime.auto_reload==="lazy"&&i.jsx(Et,{size:14,className:"text-muted-foreground"}),a.runtime.auto_reload==="autorun"&&i.jsx(_t,{size:14,className:"text-amber-500"}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium",children:"On module change"}),i.jsx("div",{className:"text-xs text-muted-foreground",children:a.runtime.auto_reload})]})]}),i.jsx("div",{className:"space-y-1",children:["off","lazy","autorun"].map(we=>i.jsxs("button",{onClick:()=>f(we),className:de("w-full flex items-center px-2 py-1 text-sm rounded hover:bg-accent",we===a.runtime.auto_reload&&"bg-accent"),children:[we==="off"&&i.jsx(Ur,{size:12,className:"mr-2"}),we==="lazy"&&i.jsx(Et,{size:12,className:"mr-2"}),we==="autorun"&&i.jsx(_t,{size:12,className:"mr-2"}),i.jsx("span",{className:"capitalize",children:we}),we===a.runtime.auto_reload&&i.jsx("span",{className:"ml-auto",children:"\u2713"})]},we))})]})})]}),e[89]=a.runtime.auto_reload,e[90]=f,e[91]=ke):ke=e[91],e[92]!==Q||e[93]!==ge||e[94]!==ke?(fe=i.jsxs($n,{align:"start",className:"w-64",children:[X,q,Q,ee,ge,ke]}),e[92]=Q,e[93]=ge,e[94]=ke,e[95]=fe):fe=e[95],e[96]!==l||e[97]!==H||e[98]!==fe?(Ie=i.jsx("div",{className:"flex md:hidden",children:i.jsxs(Un,{open:l,onOpenChange:c,children:[H,fe]})}),e[96]=l,e[97]=H,e[98]=fe,e[99]=Ie):Ie=e[99],e[100]!==F||e[101]!==Ie||e[102]!==w?(Oe=i.jsxs("div",{className:w,children:[F,Ie]}),e[100]=F,e[101]=Ie,e[102]=w,e[103]=Oe):Oe=e[103],Oe},aw=()=>{const t=z.c(24),{selectedPanel:e,isTerminalOpen:n}=Xs(),{toggleApplication:o,toggleTerminal:r}=wr(),s=ie($j),a=iw,l=Yr.find(lw);let c;Zt(l,"Error panel not found"),t[0]!==r?(c=()=>{r()},t[0]=r,t[1]=c):c=t[1],st("global.toggleTerminal",c);const d=At,u=l.tooltip,h=e===l.type,m=()=>o(l.type),p=a(l,s>0?"text-destructive":"");let b,x,f,g,y,w,j,C,N,k;return t[2]!==s?(b=i.jsx("span",{className:"ml-1 font-mono mt-0.5",children:s}),t[2]=s,t[3]=b):b=t[3],t[4]!==d||t[5]!==l||t[6]!==h||t[7]!==m||t[8]!==p||t[9]!==b?(x=i.jsxs(d,{tooltip:u,selected:h,onClick:m,"data-testid":"footer-errors",children:[p,b]}),t[4]=d,t[5]=l,t[6]=h,t[7]=m,t[8]=p,t[9]=b,t[10]=x):x=t[10],t[11]!==r?(f=()=>r(),t[11]=r,t[12]=f):f=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(Pc,{className:"h-5 w-5"}),t[13]=g):g=t[13],t[14]!==n||t[15]!==f?(y=i.jsx(Xf,{capability:"terminal",children:i.jsx(At,{tooltip:"Open terminal",selected:n,onClick:f,"data-testid":"footer-terminal",children:g})}),t[14]=n,t[15]=f,t[16]=y):y=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(sw,{}),j=i.jsx("div",{className:"mx-auto"}),t[17]=w,t[18]=j):(w=t[17],j=t[18]),t[19]===Symbol.for("react.memo_cache_sentinel")?(C=i.jsx(cu,{children:i.jsx(pe,{content:i.jsx("div",{className:"w-[200px]",children:"Kiosk mode is enabled. This allows you to view the outputs of the cells without the ability to edit them."}),children:i.jsx("span",{className:"text-muted-foreground text-sm mr-4",children:"kiosk mode"})})}),t[19]=C):C=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(N=i.jsxs("div",{className:"flex items-center shrink-0 min-w-0",children:[i.jsx(Jv,{}),i.jsx(nw,{}),i.jsx(Wv,{}),i.jsx(qv,{}),i.jsx(rw,{}),i.jsx($v,{})]}),t[20]=N):N=t[20],t[21]!==y||t[22]!==x?(k=i.jsxs("footer",{className:"h-10 py-2 bg-background flex items-center text-muted-foreground text-md px-1 border-t border-border select-none no-print text-sm shadow-[0_0_4px_1px_rgba(0,0,0,0.1)] z-50 print:hidden hide-on-fullscreen overflow-x-auto overflow-y-hidden scrollbar-thin",children:[x,y,w,j,C,N]}),t[21]=y,t[22]=x,t[23]=k):k=t[23],k};function iw(t,e){const{Icon:n}=t;return i.jsx(n,{className:de("h-5 w-5",e)})}function lw(t){return t.type==="errors"}const cw=t=>{const e=z.c(6),{children:n}=t,{openModal:o,closeModal:r}=zn();let s,a;return e[0]!==r||e[1]!==o?(s=()=>o(i.jsx(dw,{onClose:r})),e[0]=r,e[1]=o,e[2]=s):s=e[2],e[3]!==n||e[4]!==s?(a=i.jsx(Vj,{onClick:s,children:n}),e[3]=n,e[4]=s,e[5]=a):a=e[5],a},dw=t=>{const e=z.c(9),{onClose:n}=t;let o,r,s,a,l,c,d;return e[0]!==n?(o=async u=>{u.preventDefault();const h=new FormData(u.target),m=h.get("rating"),p=h.get("message");fetch("https://marimo.io/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:m,message:p})}),n(),ze({title:"Feedback sent!",description:"Thank you for your feedback!"})},e[0]=n,e[1]=o):o=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(so,{children:"Send Feedback"}),e[2]=r):r=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("p",{className:"my-2 prose dark:prose-invert",children:"We want to hear from you \u2014 from minor bug reports to wishlist features and everything in between. Here are some ways you can get in touch:"}),e[3]=s):s=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs("li",{className:"my-0",children:["Take our"," ",i.jsx("a",{href:Yt.feedbackForm,target:"_blank",className:"underline",children:"two-minute survey."})]}),e[4]=a):a=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("li",{className:"my-0",children:["File a"," ",i.jsx("a",{href:Yt.issuesPage,target:"_blank",className:"underline",children:"GitHub issue."})]}),e[5]=l):l=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsxs(xr,{children:[r,i.jsxs(yr,{children:[s,i.jsxs("ul",{className:"list-disc ml-8 my-2 prose dark:prose-invert",children:[a,l,i.jsxs("li",{className:"my-0",children:["Chat with us on"," ",i.jsx("a",{href:Yt.discordLink,target:"_blank",className:"underline",children:"Discord."})]})]}),i.jsx("p",{className:"my-2 prose dark:prose-invert",children:"We're excited you're here as we build the future of Python data tooling. Thanks for being part of our community!"})]})]}),e[6]=c):c=e[6],e[7]!==o?(d=i.jsx(io,{className:"w-fit",children:i.jsx("form",{onSubmit:o,children:c})}),e[7]=o,e[8]=d):d=e[8],d},uw=()=>{const t=z.c(10),{selectedPanel:e}=Xs(),{toggleApplication:n}=wr(),o=mw;let r,s,a,l,c,d;return t[0]!==e||t[1]!==n?(r="h-full pt-4 pb-1 px-1 flex flex-col items-start text-muted-foreground text-md select-none no-print text-sm z-50 dark:bg-background print:hidden hide-on-fullscreen",s=Yr.filter(fw).map(u=>i.jsx(ep,{tooltip:u.tooltip,selected:e===u.type,onClick:()=>n(u.type),children:o(u)},u.type)),t[0]=e,t[1]=n,t[2]=r,t[3]=s):(r=t[2],s=t[3]),t[4]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(cw,{children:i.jsx(ep,{tooltip:"Send feedback!",selected:!1,children:i.jsx(ad,{className:"h-5 w-5"})})}),l=i.jsx("div",{className:"flex-1"}),c=i.jsx(hw,{}),t[4]=a,t[5]=l,t[6]=c):(a=t[4],l=t[5],c=t[6]),t[7]!==r||t[8]!==s?(d=i.jsxs("div",{className:r,children:[s,a,l,c]}),t[7]=r,t[8]=s,t[9]=d):d=t[9],d},hw=()=>{const t=z.c(7),e=ie(Gj);let n,o,r;return t[0]!==e?(n=e>0?i.jsxs("span",{children:[e," cell",e>1?"s":""," queued or running"]}):"No cells queued or running",t[0]=e,t[1]=n):n=t[1],t[2]!==e?(o=i.jsx("div",{className:"flex flex-col-reverse gap-px overflow-hidden",children:Array.from({length:e}).map(pw)}),t[2]=e,t[3]=o):o=t[3],t[4]!==n||t[5]!==o?(r=i.jsx(pe,{content:n,side:"right",delayDuration:200,children:o}),t[4]=n,t[5]=o,t[6]=r):r=t[6],r},ep=t=>{const e=z.c(17);let n,o,r,s,a;e[0]!==t?({children:n,tooltip:a,selected:s,className:o,...r}=t,e[0]=t,e[1]=n,e[2]=o,e[3]=r,e[4]=s,e[5]=a):(n=e[1],o=e[2],r=e[3],s=e[4],a=e[5]);const l=!s&&"hover:bg-(--sage-3)",c=s&&"bg-(--sage-4)";let d,u,h;return e[6]!==o||e[7]!==l||e[8]!==c?(d=de("flex items-center p-2 text-sm mx-px shadow-inset font-mono cursor-pointer rounded",l,c,o),e[6]=o,e[7]=l,e[8]=c,e[9]=d):d=e[9],e[10]!==n||e[11]!==r||e[12]!==d?(u=i.jsx("button",{className:d,...r,children:n}),e[10]=n,e[11]=r,e[12]=d,e[13]=u):u=e[13],e[14]!==u||e[15]!==a?(h=i.jsx(pe,{content:a,side:"right",delayDuration:200,children:u}),e[14]=u,e[15]=a,e[16]=h):h=e[16],h};function mw(t,e){const{Icon:n}=t;return i.jsx(n,{className:de("h-5 w-5",e)})}function fw(t){return!t.hidden&&t.position==="sidebar"}function pw(t,e){return i.jsx("div",{className:"shrink-0 h-1 w-2 bg-(--grass-6) border border-(--grass-7)"},e.toString())}const gw=t=>{const e=z.c(4),{isOpen:n,children:o}=t,[r,s]=he.useState(!1);let a,l;return e[0]!==r||e[1]!==n?(a=()=>{n&&!r&&s(!0)},l=[n,r],e[0]=r,e[1]=n,e[2]=a,e[3]=l):(a=e[2],l=e[3]),he.useEffect(a,l),r?o:null},bw=t=>{const e=z.c(38),n=ie(qj),o=ie(ew),r=Ke(),s=S1(),a=t.cellId,l=o[t.cellId],c=Lr(t.cellId),d=c.code,u=Fr(t.cellId);let h,m,p,b,x,f,g,y,w,j;if(e[0]!==r||e[1]!==s||e[2]!==n.focusedCellId||e[3]!==o||e[4]!==t.cellId||e[5]!==l||e[6]!==c.code||e[7]!==u.errored){h={id:a,graph:l,code:d,hasError:u.errored},n.focusedCellId&&o[n.focusedCellId]&&(b={id:n.focusedCellId,graph:o[n.focusedCellId]}),p=(b==null?void 0:b.id)===h.id,m=np(h.graph)?1.5:3;const _=()=>{p?s.blurCell():(r.focusCell({cellId:h.id,where:"exact"}),s.focusCell({cellId:h.id}))};g=h.id;const I=p?"text-primary-foreground":"text-(--gray-8) hover:text-(--gray-9)";e[18]!==I?(y=de("group bg-transparent text-left w-full flex relative justify-between items-center","border-none rounded cursor-pointer","h-[21px] pl-[51px] font-inherit",I),e[18]=I,e[19]=y):y=e[19],w=_,j=jw;const A=p&&"bg-primary group-hover:bg-primary";let O;e[20]!==A?(O=de("group-hover:bg-(--gray-2) flex h-full w-full px-0.5 items-center rounded",A),e[20]=A,e[21]=O):O=e[21],x=i.jsx("div",{className:O,children:i.jsx("div",{className:"truncate px-1 font-mono text-sm flex gap-1",title:h.code,children:h.graph.variables.length>0?i.jsx(vw,{cell:h,selectedCell:b}):i.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap max-w-full",children:(C=h.code,(C.split(`
140
+ `)[0].trim()||void 0)??i.jsx("span",{className:"italic",children:"empty"}))})})}),f=de("absolute overflow-visible top-[10.5px] left-[calc(var(--spacing-extra-small,8px)+17px)] pointer-events-none",p?"z-30":"z-20",(function({cell:D,selectedCell:M}){return D.hasError?"text-destructive":!M&&!np(D.graph)?"text-foreground":(M==null?void 0:M.id)===D.id||M!=null&&M.graph.parents.has(D.id)||M!=null&&M.graph.children.has(D.id)?"text-primary":"text-(--gray-8)"})({cell:h,selectedCell:b})),e[0]=r,e[1]=s,e[2]=n.focusedCellId,e[3]=o,e[4]=t.cellId,e[5]=l,e[6]=c.code,e[7]=u.errored,e[8]=h,e[9]=m,e[10]=p,e[11]=b,e[12]=x,e[13]=f,e[14]=g,e[15]=y,e[16]=w,e[17]=j}else h=e[8],m=e[9],p=e[10],b=e[11],x=e[12],f=e[13],g=e[14],y=e[15],w=e[16],j=e[17];var C;let N,k,E;return e[22]!==h||e[23]!==m||e[24]!==p||e[25]!==t.cellPositions||e[26]!==b?(N=p?i.jsx(ww,{cell:h,cellPositions:t.cellPositions,circleRadius:m}):i.jsx(kw,{cell:h,selectedCell:b,circleRadius:m}),e[22]=h,e[23]=m,e[24]=p,e[25]=t.cellPositions,e[26]=b,e[27]=N):N=e[27],e[28]!==N||e[29]!==f?(k=i.jsx("svg",{className:f,width:"1",height:"1",children:N}),e[28]=N,e[29]=f,e[30]=k):k=e[30],e[31]!==x||e[32]!==k||e[33]!==g||e[34]!==y||e[35]!==w||e[36]!==j?(E=i.jsxs("button",{"data-node-id":g,className:y,onClick:w,onMouseDown:j,children:[x,k]}),e[31]=x,e[32]=k,e[33]=g,e[34]=y,e[35]=w,e[36]=j,e[37]=E):E=e[37],E},xw=t=>{const e=z.c(28),{open:n,setOpen:o}=t,r=Cc();let s;e[0]!==r.inOrderIds?(s=Object.fromEntries(r.inOrderIds.map(Cw)),e[0]=r.inOrderIds,e[1]=s):s=e[1];const a=s;let l;if(e[2]!==r){l=[];let w=0;for(const[j,C]of r.getColumns().entries())j>0&&l.push(w),w+=C.inOrderIds.length;e[2]=r,e[3]=l}else l=e[3];const c=n?"translate-x-0":"translate-x-[calc(100%+20px)]";let d,u,h,m,p,b,x,f,g,y;if(e[4]!==c?(d=de("fixed top-14 right-5 z-50 bg-background/95 backdrop-blur-sm supports-backdrop-filter:bg-background/60 rounded-lg border shadow-lg w-64 flex flex-col max-h-[58vh]","motion-safe:transition-transform motion-safe:duration-200 motion-safe:ease-in-out",c),e[4]=c,e[5]=d):d=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx("span",{className:"text-sm font-semibold",children:"Minimap"}),e[6]=u):u=e[6],e[7]!==o?(h=()=>o(!1),e[7]=o,e[8]=h):h=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx($t,{className:"h-4 w-4"}),e[9]=m):m=e[9],e[10]!==h?(p=i.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[u,i.jsx(ye,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:h,children:m})]}),e[10]=h,e[11]=p):p=e[11],e[12]!==r.inOrderIds||e[13]!==a||e[14]!==l){let w;e[16]!==a||e[17]!==l?(w=(j,C)=>{const N=l.includes(C);return i.jsxs(S.Fragment,{children:[N&&i.jsx("div",{className:"absolute left-5 w-[36px] h-px bg-(--gray-4) pointer-events-none","aria-hidden":"true"}),i.jsx(bw,{cellId:j,cellPositions:a})]},j)},e[16]=a,e[17]=l,e[18]=w):w=e[18],b=r.inOrderIds.map(w),e[12]=r.inOrderIds,e[13]=a,e[14]=l,e[15]=b}else b=e[15];return e[19]!==b?(x=i.jsx("div",{className:"py-3 pl-3 pr-4 relative min-h-full",children:b}),e[19]=b,e[20]=x):x=e[20],e[21]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("div",{className:"h-0 overflow-hidden","aria-hidden":"true"}),e[21]=f):f=e[21],e[22]!==x?(g=i.jsxs("div",{className:"overflow-y-auto overflow-x-hidden flex-1 scrollbar-none",children:[x,f]}),e[22]=x,e[23]=g):g=e[23],e[24]!==g||e[25]!==d||e[26]!==p?(y=i.jsxs("div",{className:d,children:[p,g]}),e[24]=g,e[25]=d,e[26]=p,e[27]=y):y=e[27],y},yw=()=>{const t=z.c(5),[e,n]=_n(Zf);let o,r;return t[0]!==n?(o=()=>n(Nw),t[0]=n,t[1]=o):o=t[1],st("global.toggleMinimap",o),t[2]!==e||t[3]!==n?(r=i.jsx(xw,{open:e,setOpen:n}),t[2]=e,t[3]=n,t[4]=r):r=t[4],r},vw=t=>{const e=z.c(11),{cell:n,selectedCell:o}=t,r=Hj(),s=n.id===(o==null?void 0:o.id);let a,l;if(e[0]!==n.graph.variables||e[1]!==s||e[2]!==o||e[3]!==r){let c;e[5]!==s||e[6]!==o||e[7]!==r?(c=(d,u)=>{const h=r[d];return i.jsxs(S.Fragment,{children:[u>0&&", ",i.jsx("span",{className:de({"font-bold":s,"text-foreground":o===void 0,"text-primary font-medium":!s&&tw(h,o)}),children:d})]},d)},e[5]=s,e[6]=o,e[7]=r,e[8]=c):c=e[8],a=n.graph.variables.map(c),e[0]=n.graph.variables,e[1]=s,e[2]=o,e[3]=r,e[4]=a}else a=e[4];return e[9]!==a?(l=i.jsx(i.Fragment,{children:a}),e[9]=a,e[10]=l):l=e[10],l},ww=t=>{const e=z.c(12),{cell:n,cellPositions:o,circleRadius:r}=t;let s,a,l,c;if(e[0]!==n.graph.children||e[1]!==n.graph.parents||e[2]!==n.id||e[3]!==o){s=[];const d=o[n.id]??0,u=new Set;for(const h of n.graph.parents)n.graph.children.has(h)&&u.add(h);for(const h of u){const m=o[h];if(m!==void 0){const p=21*(m-d);s.push(i.jsx("path",{d:`M -3 0 H -7 v ${p} h 14 v ${-p} H 3`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-cycle-${h}`))}}for(const h of n.graph.parents){if(u.has(h))continue;const m=o[h];if(m!==void 0){const p=21*(m-d);s.push(i.jsx("path",{d:`M -3 0 H -7 v ${p} h -4`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-up-${h}`))}}for(const h of n.graph.children){if(u.has(h))continue;const m=o[h];if(m!==void 0){const p=21*(m-d);s.push(i.jsx("path",{d:`M 3 0 H 7 v ${p} h 4`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-down-${h}`))}}e[0]=n.graph.children,e[1]=n.graph.parents,e[2]=n.id,e[3]=o,e[4]=s}else s=e[4];return e[5]!==r?(a=i.jsx("circle",{r,fill:"currentColor",className:"pointer-events-auto"}),e[5]=r,e[6]=a):a=e[6],e[7]!==s?(l=i.jsx("g",{className:"pen pointer-events-auto",children:s}),e[7]=s,e[8]=l):l=e[8],e[9]!==a||e[10]!==l?(c=i.jsxs("g",{transform:"translate(0, 0)",children:[a,l]}),e[9]=a,e[10]=l,e[11]=c):c=e[11],c};function kw(t){const{cell:e,selectedCell:n,circleRadius:o}=t,r=e.graph.ancestors.size>0,s=e.graph.descendants.size>0;if(!n)return tp({circleRadius:o,leftWisker:r,rightWisker:s});const a=n.graph.ancestors.has(e.id),l=n.graph.descendants.has(e.id);return tp(a||l?{circleRadius:o,leftWisker:r,rightWisker:s,shift:a&&l?void 0:a?"left":"right"}:{circleRadius:o,leftWisker:!1,rightWisker:!1})}function tp(t){const{circleRadius:e,leftWisker:n,rightWisker:o,shift:r}=t,s=r===void 0?0:r==="left"?-14:14;return i.jsxs("g",{transform:`translate(${s}, 0)`,children:[i.jsxs("g",{children:[n&&i.jsx("path",{d:"M 0 0 h -8",fill:"none",strokeWidth:"2",stroke:"currentColor"}),o&&i.jsx("path",{d:"M 0 0 h 8",fill:"none",strokeWidth:"2",stroke:"currentColor"})]}),i.jsx("circle",{r:e,fill:"currentColor",className:"pointer-events-auto"})]})}function np(t){return t.variables.length===0&&t.ancestors.size===0&&t.descendants.size===0}function jw(t){return t.preventDefault()}function Cw(t,e){return[t,e]}function Nw(t){return!t}const Sw=he.lazy(()=>ft(()=>import("./terminal-CPV44BXz.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110]),import.meta.url)),Ew=he.lazy(()=>ft(()=>import("./chat-panel-DJkOLrw9.js"),__vite__mapDeps([111,1,2,4,5,112,113,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,114,115,116,117]),import.meta.url)),_w=he.lazy(()=>ft(()=>import("./agent-panel-BoscVLCT.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([118,1,2,113,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,114,115,116,4,5,112,3,107,108,109,119]),import.meta.url)),Iw=he.lazy(()=>ft(()=>import("./dependency-graph-panel-DNajptzv.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([120,1,2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,121,122,123,124,125,4,5,107,108,109,126]),import.meta.url)),Aw=he.lazy(()=>ft(()=>import("./datasources-panel-C7sqRIHs.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([127,1,2,112,128,108,129,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,109]),import.meta.url)),Tw=he.lazy(()=>ft(()=>import("./documentation-panel-Dm6Ozl67.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([130,1,2,112,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109]),import.meta.url)),Dw=he.lazy(()=>ft(()=>import("./error-panel-BYG4twCa.js"),__vite__mapDeps([131,1,2,112]),import.meta.url)),Mw=he.lazy(()=>ft(()=>import("./file-explorer-panel-BSMiOApi.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([132,1,2,4,5,133,134,135,125,115,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109]),import.meta.url)),Ow=he.lazy(()=>ft(()=>import("./logs-panel-CjbuhBLx.js"),__vite__mapDeps([136,1,2,137,112]),import.meta.url)),Rw=he.lazy(()=>ft(()=>import("./outline-panel-BvGcPKdd.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([138,1,2,112,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,139]),import.meta.url)),Lw=he.lazy(()=>ft(()=>import("./packages-panel-BichDQWG.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([140,1,2,4,5,112,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109]),import.meta.url)),Fw=he.lazy(()=>ft(()=>import("./scratchpad-panel-D5N15ji1.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([141,1,2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,115,4,5,107,108,109]),import.meta.url)),Bw=he.lazy(()=>ft(()=>import("./secrets-panel-BpbnAO4R.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([142,1,2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,112,4,5,107,108,109]),import.meta.url)),Pw=he.lazy(()=>ft(()=>import("./snippets-panel-wlpZ_Wzx.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([143,1,2,112,115,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,144]),import.meta.url)),zw=he.lazy(()=>ft(()=>import("./tracing-panel-BMgy3D7d.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([145,1,2]),import.meta.url)),Uw=he.lazy(()=>ft(()=>import("./variable-panel-sFTn4Oih.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([146,1,2,124,128,108,129,112,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,109]),import.meta.url)),Ww=t=>{const e=z.c(127),{children:n}=t,{isSidebarOpen:o,isTerminalOpen:r,selectedPanel:s}=Xs(),{setIsSidebarOpen:a,setIsTerminalOpen:l}=wr(),c=he.useRef(null),d=he.useRef(null),u=S.useId(),h=S.useId();let m,p,b,x,f;e[0]!==o?(m=()=>{if(!c.current)return;const le=c.current.isCollapsed();o&&le&&c.current.expand(),o||le||c.current.collapse(),requestAnimationFrame(Vw)},p=[o],e[0]=o,e[1]=m,e[2]=p):(m=e[1],p=e[2]),S.useEffect(m,p),e[3]!==r?(b=()=>{if(!d.current)return;const le=d.current.isCollapsed();r&&le&&d.current.expand(),r||le||d.current.collapse(),requestAnimationFrame(qw)},x=[r],e[3]=r,e[4]=b,e[5]=x):(b=e[4],x=e[5]),S.useEffect(b,x),e[6]!==n?(f=i.jsx(ka,{id:"app",className:"relative h-full",children:i.jsx(S.Suspense,{children:n})},"app"),e[6]=n,e[7]=f):f=e[7];const g=f,y=o?"resize-handle":"resize-handle-collapsed";let w,j;e[8]!==y?(w=de("border-border no-print z-10",y,"vertical"),e[8]=y,e[9]=w):w=e[9],e[10]!==w?(j=i.jsx(z1,{onDragging:U1,className:w}),e[10]=w,e[11]=j):j=e[11];const C=j,N=r?"resize-handle":"resize-handle-collapsed";let k,E;e[12]!==N?(k=de("border-border no-print z-20",N,"horizontal"),e[12]=N,e[13]=k):k=e[13],e[14]!==k?(E=i.jsx(z1,{onDragging:U1,className:k}),e[14]=k,e[15]=E):E=e[15];const _=E;let I,A,O,D,M,R,L,P,T,F,$,W,H,X,q,Y,J,V,G,U,ne,Q;e[16]!==s?(I=i.jsx("div",{className:"text-sm text-(--slate-11) uppercase tracking-wide font-semibold flex-1",children:s}),e[16]=s,e[17]=I):I=e[17],e[18]!==a?(A=()=>a(!1),e[18]=a,e[19]=A):A=e[19],e[20]===Symbol.for("react.memo_cache_sentinel")?(O=i.jsx($t,{className:"w-4 h-4"}),e[20]=O):O=e[20],e[21]!==A?(D=i.jsx(ye,{"data-testid":"close-helper-pane",className:"m-0",size:"xs",variant:"text",onClick:A,children:O}),e[21]=A,e[22]=D):D=e[22],e[23]!==I||e[24]!==D?(M=i.jsxs("div",{className:"p-3 border-b flex justify-between items-center",children:[I,D]}),e[23]=I,e[24]=D,e[25]=M):M=e[25],e[26]!==s?(R=s==="files"&&i.jsx(Mw,{}),e[26]=s,e[27]=R):R=e[27],e[28]!==s?(L=s==="errors"&&i.jsx(Dw,{}),e[28]=s,e[29]=L):L=e[29],e[30]!==s?(P=s==="variables"&&i.jsx(Uw,{}),e[30]=s,e[31]=P):P=e[31],e[32]!==s?(T=s==="dependencies"&&i.jsx(Iw,{}),e[32]=s,e[33]=T):T=e[33],e[34]!==s?(F=s==="packages"&&i.jsx(Lw,{}),e[34]=s,e[35]=F):F=e[35],e[36]!==s?($=s==="outline"&&i.jsx(Rw,{}),e[36]=s,e[37]=$):$=e[37],e[38]!==s?(W=s==="datasources"&&i.jsx(Aw,{}),e[38]=s,e[39]=W):W=e[39],e[40]!==s?(H=s==="documentation"&&i.jsx(Tw,{}),e[40]=s,e[41]=H):H=e[41],e[42]!==s?(X=s==="snippets"&&i.jsx(Pw,{}),e[42]=s,e[43]=X):X=e[43],e[44]!==s?(q=s==="scratchpad"&&i.jsx(Fw,{}),e[44]=s,e[45]=q):q=e[45],e[46]!==s?(Y=s==="chat"&&i.jsx(Ew,{}),e[46]=s,e[47]=Y):Y=e[47],e[48]!==s?(J=s==="agents"&&i.jsx(_w,{}),e[48]=s,e[49]=J):J=e[49],e[50]!==s?(V=s==="logs"&&i.jsx(Ow,{}),e[50]=s,e[51]=V):V=e[51],e[52]!==s?(G=s==="tracing"&&i.jsx(zw,{}),e[52]=s,e[53]=G):G=e[53],e[54]!==s?(U=s==="secrets"&&i.jsx(Bw,{}),e[54]=s,e[55]=U):U=e[55],e[56]!==R||e[57]!==L||e[58]!==P||e[59]!==T||e[60]!==F||e[61]!==$||e[62]!==W||e[63]!==H||e[64]!==X||e[65]!==q||e[66]!==Y||e[67]!==J||e[68]!==V||e[69]!==G||e[70]!==U?(ne=i.jsx(S.Suspense,{children:i.jsxs(va,{children:[R,L,P,T,F,$,W,H,X,q,Y,J,V,G,U]})}),e[56]=R,e[57]=L,e[58]=P,e[59]=T,e[60]=F,e[61]=$,e[62]=W,e[63]=H,e[64]=X,e[65]=q,e[66]=Y,e[67]=J,e[68]=V,e[69]=G,e[70]=U,e[71]=ne):ne=e[71],e[72]!==M||e[73]!==ne?(Q=i.jsx(Yl,{children:i.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden mr-[-4px]",children:[M,ne]})}),e[72]=M,e[73]=ne,e[74]=Q):Q=e[74];const ee=Q,te=`helper-${u}`,se=o&&"border-r border-l border-(--slate-7)";let ae,oe,Ee,ve,ge,ke;e[75]!==se?(ae=de("dark:bg-(--slate-1) no-print print:hidden hide-on-fullscreen",se),e[75]=se,e[76]=ae):ae=e[76],e[77]===Symbol.for("react.memo_cache_sentinel")?(oe=(le,je)=>{var Ne;je===0&&le===10&&((Ne=c.current)==null||Ne.resize(30))},e[77]=oe):oe=e[77],e[78]!==a?(Ee=()=>a(!1),ve=()=>a(!0),e[78]=a,e[79]=Ee,e[80]=ve):(Ee=e[79],ve=e[80]),e[81]!==ee||e[82]!==C?(ge=i.jsxs("span",{className:"flex flex-row h-full",children:[ee," ",C]}),e[81]=ee,e[82]=C,e[83]=ge):ge=e[83],e[84]!==te||e[85]!==ae||e[86]!==Ee||e[87]!==ve||e[88]!==ge?(ke=i.jsx(ka,{ref:c,id:te,"data-testid":"helper",collapsedSize:0,collapsible:!0,className:ae,minSize:10,defaultSize:0,maxSize:75,onResize:oe,onCollapse:Ee,onExpand:ve,children:ge},"helper"),e[84]=te,e[85]=ae,e[86]=Ee,e[87]=ve,e[88]=ge,e[89]=ke):ke=e[89];const fe=ke,Ie=`terminal-${h}`,Oe=r&&"border-(--slate-7)";let we,be,et,ct,dt,tt,ut,ht,wt;e[90]!==Oe?(we=de("dark:bg-(--slate-1) no-print print:hidden hide-on-fullscreen",Oe),e[90]=Oe,e[91]=we):we=e[91],e[92]===Symbol.for("react.memo_cache_sentinel")?(be=(le,je)=>{var Ne;je===0&&le===10&&((Ne=d.current)==null||Ne.resize(30))},e[92]=be):be=e[92],e[93]!==l?(et=()=>l(!1),ct=()=>l(!0),e[93]=l,e[94]=et,e[95]=ct):(et=e[94],ct=e[95]),e[96]===Symbol.for("react.memo_cache_sentinel")?(dt=i.jsx("div",{}),e[96]=dt):dt=e[96],e[97]!==l?(tt=()=>l(!1),e[97]=l,e[98]=tt):tt=e[98],e[99]!==r||e[100]!==tt?(ut=i.jsx(S.Suspense,{fallback:dt,children:i.jsx(Sw,{visible:r,onClose:tt})}),e[99]=r,e[100]=tt,e[101]=ut):ut=e[101],e[102]!==r||e[103]!==ut?(ht=i.jsx(gw,{isOpen:r,children:ut}),e[102]=r,e[103]=ut,e[104]=ht):ht=e[104],e[105]!==Ie||e[106]!==we||e[107]!==et||e[108]!==ct||e[109]!==ht||e[110]!==_?(wt=i.jsxs(ka,{ref:d,id:Ie,"data-testid":"terminal",collapsedSize:0,collapsible:!0,className:we,minSize:10,defaultSize:0,maxSize:75,onResize:be,onCollapse:et,onExpand:ct,children:[_,ht]},"terminal"),e[105]=Ie,e[106]=we,e[107]=et,e[108]=ct,e[109]=ht,e[110]=_,e[111]=wt):wt=e[111];const Lt=wt;let Rn,Ht,Ft,Pt,to,Ln,No,re,ce;return e[112]===Symbol.for("react.memo_cache_sentinel")?(Rn=_C(),e[112]=Rn):Rn=e[112],e[113]===Symbol.for("react.memo_cache_sentinel")?(Ht=i.jsx(va,{children:i.jsx(uw,{})}),e[113]=Ht):Ht=e[113],e[114]!==Lt?(Ft=i.jsx(Xf,{capability:"terminal",children:Lt}),e[114]=Lt,e[115]=Ft):Ft=e[115],e[116]!==g||e[117]!==Ft?(Pt=i.jsx(ka,{children:i.jsxs(W1,{autoSaveId:"marimo:chrome:v1:l1",direction:"vertical",children:[g,Ft]})}),e[116]=g,e[117]=Ft,e[118]=Pt):Pt=e[118],e[119]===Symbol.for("react.memo_cache_sentinel")?(to=i.jsx(Jj,{}),e[119]=to):to=e[119],e[120]!==fe||e[121]!==Pt?(Ln=i.jsxs(W1,{autoSaveId:"marimo:chrome:v1:l2",direction:"horizontal",storage:Rn,children:[Ht,fe,Pt,to]}),e[120]=fe,e[121]=Pt,e[122]=Ln):Ln=e[122],e[123]===Symbol.for("react.memo_cache_sentinel")?(No=i.jsx(yw,{}),e[123]=No):No=e[123],e[124]===Symbol.for("react.memo_cache_sentinel")?(re=i.jsx(Yl,{children:i.jsx(va,{children:i.jsx(aw,{})})}),e[124]=re):re=e[124],e[125]!==Ln?(ce=i.jsxs(IC,{children:[Ln,No,re]}),e[125]=Ln,e[126]=ce):ce=e[126],ce};function $w(){window.dispatchEvent(new Event("resize"))}function Vw(){requestAnimationFrame($w)}function Gw(){window.dispatchEvent(new Event("resize"))}function qw(){requestAnimationFrame(Gw)}let wl,op;wl=S.lazy(()=>ft(()=>import("./command-palette-BUXkqoLh.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([147,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109]),import.meta.url)),op=new URL(window.location.href).searchParams.get(Kj.showChrome)==="false",hg=Object.freeze(Object.defineProperty({__proto__:null,default:t=>{const e=z.c(10);if(op){let s,a,l;return e[0]!==t?(s=i.jsx(Yf,{hideControls:!0,...t}),e[0]=t,e[1]=s):s=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(wl,{}),e[2]=a):a=e[2],e[3]!==s?(l=i.jsxs(i.Fragment,{children:[s,a]}),e[3]=s,e[4]=l):l=e[4],l}let n,o,r;return e[5]!==t?(n=i.jsx(Yf,{...t}),e[5]=t,e[6]=n):n=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(wl,{}),e[7]=o):o=e[7],e[8]!==n?(r=i.jsxs(Ww,{children:[n,o]}),e[8]=n,e[9]=r):r=e[9],r}},Symbol.toStringTag,{value:"Module"}))});export{ug as A,Na as C,Sa as E,_c as F,Ea as H,Ic as N,Ac as P,Tc as R,Dc as S,Mc as T,Oc as W,LC as __tla,Rc as a,Lc as b,_a as c,Ia as d,Aa as e,Wo as f,Fc as g,Bc as h,Pc as i,zc as j,Uc as k,hg as l,Wc as s,Ta as u};