@marimo-team/frontend 0.22.4-dev1 → 0.22.4-dev10

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 (105) hide show
  1. package/dist/assets/{CellStatus-Cf0Jlrcs.js → CellStatus-Cj_aMmmE.js} +1 -1
  2. package/dist/assets/{ConnectedDataExplorerComponent-DUxaLoL7.js → ConnectedDataExplorerComponent-Dksi3IQd.js} +1 -1
  3. package/dist/assets/{JsonOutput-Ctdzcd2D.js → JsonOutput-heEAqE8H.js} +5 -5
  4. package/dist/assets/MarimoErrorOutput-EEO_bAbD.js +7 -0
  5. package/dist/assets/RenderHTML-CvgwqLt6.js +1 -0
  6. package/dist/assets/{add-cell-with-ai-C0J3LyiV.js → add-cell-with-ai-0ix1W1XL.js} +16 -16
  7. package/dist/assets/{add-connection-dialog-CEquGDgf.js → add-connection-dialog-C6EGRNCR.js} +1 -1
  8. package/dist/assets/{agent-panel-BxXEWtsJ.js → agent-panel-CEpFr5i0.js} +3 -3
  9. package/dist/assets/{ai-model-dropdown-D14GiszF.js → ai-model-dropdown-DeJNr_5y.js} +4 -4
  10. package/dist/assets/{app-config-button-v-557oRb.js → app-config-button-D_F4_5Oy.js} +1 -1
  11. package/dist/assets/{cell-editor-B8HsInsi.js → cell-editor-DAw6YxwR.js} +10 -10
  12. package/dist/assets/{cell-link-Cimoe3Fv.js → cell-link-CUOy8qvK.js} +1 -1
  13. package/dist/assets/cells-C9wzDxwr.js +229 -0
  14. package/dist/assets/{chat-display-hfpeXiYe.js → chat-display-CQUXzNpU.js} +1 -1
  15. package/dist/assets/{chat-panel-DxT370nA.js → chat-panel-C_NSR1GT.js} +1 -1
  16. package/dist/assets/{chat-ui-Dv4y0-td.js → chat-ui-Dy2xkVP7.js} +4 -4
  17. package/dist/assets/{column-preview-BlmqVfbV.js → column-preview-D9viH8oS.js} +1 -1
  18. package/dist/assets/{command-palette-B4mH4ZSa.js → command-palette-CYqukIao.js} +1 -1
  19. package/dist/assets/{common-BZK7spst.js → common-D_w2m-ro.js} +1 -1
  20. package/dist/assets/{components-DpxyscxU.js → components-CtW4EQ0a.js} +1 -1
  21. package/dist/assets/{components-D2OlyENc.js → components-DMCRbi3Y.js} +1 -1
  22. package/dist/assets/{config-CmaJdl9U.js → config-DCMsCquu.js} +1 -1
  23. package/dist/assets/{datasource-D9nfSxKS.js → datasource-o22Gadpo.js} +2 -2
  24. package/dist/assets/{dependency-graph-panel-5MbMtFss.js → dependency-graph-panel-CgvfWoUz.js} +4 -4
  25. package/dist/assets/{documentation-panel-DPdXS3YO.js → documentation-panel-BLrwS8mG.js} +1 -1
  26. package/dist/assets/{download-BFQaUFKI.js → download-Bpd05cN4.js} +3 -3
  27. package/dist/assets/{edit-page-hUrrzd-W.js → edit-page-ByLzpRKM.js} +7 -7
  28. package/dist/assets/{error-panel-DV8jpRsf.js → error-panel-ChRfACaA.js} +1 -1
  29. package/dist/assets/{file-explorer-panel-Bg6RAr5R.js → file-explorer-panel-DGIa-t9I.js} +3 -3
  30. package/dist/assets/{file-icons-DSJsG_mI.js → file-icons-BJUn_Zwi.js} +1 -1
  31. package/dist/assets/floating-outline-CEoUA-ND.js +1 -0
  32. package/dist/assets/{focus-C5u0JQUq.js → focus-4jo_CuOp.js} +1 -1
  33. package/dist/assets/{form-DkNMeOSQ.js → form-yizCLBQu.js} +1 -1
  34. package/dist/assets/{glide-data-editor-a3qLDl-r.js → glide-data-editor-B8IKnskT.js} +1 -1
  35. package/dist/assets/{globals-DK8gKReW.js → globals-CinMfY9h.js} +1 -1
  36. package/dist/assets/{home-page-BrqppCUS.js → home-page-tqfl2F4G.js} +2 -2
  37. package/dist/assets/{hooks-wt7ylZro.js → hooks-CKIyvt9N.js} +1 -1
  38. package/dist/assets/{html-to-image-BRbQwG7G.js → html-to-image-DN6TNqeX.js} +1 -1
  39. package/dist/assets/index-BNN_F0CC.css +2 -0
  40. package/dist/assets/index-CaFbHOEK.js +42 -0
  41. package/dist/assets/kiosk-mode-CMcS0n9N.js +1 -0
  42. package/dist/assets/layout-zIm4ogA2.js +5 -0
  43. package/dist/assets/{logs-panel-CNVgwoHO.js → logs-panel-D1sZXqHo.js} +1 -1
  44. package/dist/assets/{markdown-renderer-B91NzmVT.js → markdown-renderer-B-YFfOW1.js} +2 -2
  45. package/dist/assets/{mermaid-BQRzyqkQ.js → mermaid-CMMJIxJ5.js} +1 -1
  46. package/dist/assets/{name-cell-input-hsV_b1Op.js → name-cell-input-BpUnj_OW.js} +1 -1
  47. package/dist/assets/{outline-panel-C3jvSnZF.js → outline-panel-Cyc-3UPs.js} +1 -1
  48. package/dist/assets/{packages-panel-0_Z5vM7i.js → packages-panel-BKB49Pn0.js} +1 -1
  49. package/dist/assets/panels-C0kGoK7J.js +1 -0
  50. package/dist/assets/process-output-DRHgVscl.js +1 -0
  51. package/dist/assets/{readonly-python-code-oFCRG7Wt.js → readonly-python-code-BNv35LAm.js} +1 -1
  52. package/dist/assets/{renderShortcut-Bjt8kSBs.js → renderShortcut-9B7Z8taX.js} +1 -1
  53. package/dist/assets/{run-page-D7ezkhN_.js → run-page-BoiyjeoB.js} +1 -1
  54. package/dist/assets/{scratchpad-panel-BELUYBUe.js → scratchpad-panel-o2wFoJUh.js} +1 -1
  55. package/dist/assets/{session-panel-BfReO77m.js → session-panel-BoqrSaAQ.js} +1 -1
  56. package/dist/assets/{snippets-panel-CDqEDwpY.js → snippets-panel-DB9DRB1O.js} +1 -1
  57. package/dist/assets/{state-BBVlYaRC.js → state-BeEg2EJ6.js} +1 -1
  58. package/dist/assets/{state-BpEWsL00.js → state-Cybx0BE_.js} +3 -3
  59. package/dist/assets/{switch-DqrqDBdD.js → switch-BOBVe-9H.js} +1 -1
  60. package/dist/assets/{terminal-DXod4Bkk.js → terminal-BpQ9AtyJ.js} +1 -1
  61. package/dist/assets/{textarea-DJEKmYtw.js → textarea-DoPazz3x.js} +1 -1
  62. package/dist/assets/{tracing-panel-ksnvVrMH.js → tracing-panel-GFrltKb1.js} +2 -2
  63. package/dist/assets/{tracing-CLWi5jD3.js → tracing-qb2BTgvS.js} +1 -1
  64. package/dist/assets/{useAddCell-mJ1PkF-E.js → useAddCell-TIHLIw_p.js} +1 -1
  65. package/dist/assets/{useBoolean-DN8PHql0.js → useBoolean-Dvk5-C1P.js} +1 -1
  66. package/dist/assets/useCellActionButton-D6Wt_LnE.js +1 -0
  67. package/dist/assets/{useDeleteCell-B0OAS0ly.js → useDeleteCell-DHcT-SKt.js} +1 -1
  68. package/dist/assets/{useDependencyPanelTab-BuZ0fgAR.js → useDependencyPanelTab-B0iWJBOX.js} +1 -1
  69. package/dist/assets/{useHotkey-C05CMwqk.js → useHotkey-BY9xqWO8.js} +1 -1
  70. package/dist/assets/useNotebookActions-DGjP_qmV.js +1 -0
  71. package/dist/assets/useRunCells-DQQ6CB8T.js +1 -0
  72. package/dist/assets/{useSplitCell-CeL7eJq1.js → useSplitCell-CNLAHTUp.js} +1 -1
  73. package/dist/assets/{useTheme-wMq5x3Hi.js → useTheme-B1JCa4JT.js} +1 -1
  74. package/dist/assets/utils-8btzWeZg.js +1 -0
  75. package/dist/assets/{vega-component-CdvEZvzS.js → vega-component-BLi2Qo88.js} +1 -1
  76. package/dist/index.html +30 -30
  77. package/package.json +1 -1
  78. package/src/components/editor/TracebackModalContainer.tsx +22 -0
  79. package/src/components/editor/errors/traceback-modal.tsx +87 -0
  80. package/src/components/editor/output/MarimoErrorOutput.tsx +23 -3
  81. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +16 -2
  82. package/src/components/ui/toast.tsx +3 -1
  83. package/src/core/MarimoApp.tsx +2 -0
  84. package/src/core/cells/__tests__/apply-transaction.test.ts +28 -0
  85. package/src/core/cells/cells.ts +13 -1
  86. package/src/core/cells/logs.ts +48 -9
  87. package/src/core/config/__tests__/config-schema.test.ts +2 -0
  88. package/src/core/config/config-schema.ts +1 -0
  89. package/src/core/errors/traceback-atom.ts +9 -0
  90. package/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx +8 -6
  91. package/src/plugins/impl/anywidget/__tests__/AnyWidgetPlugin.test.tsx +25 -0
  92. package/dist/assets/MarimoErrorOutput-dTNCLY-Q.js +0 -7
  93. package/dist/assets/RenderHTML-C5GEp4ca.js +0 -1
  94. package/dist/assets/cells-CcsG9Aum.js +0 -229
  95. package/dist/assets/floating-outline-Cfa1ESSb.js +0 -1
  96. package/dist/assets/index-B_DGbLw5.js +0 -42
  97. package/dist/assets/index-BkdonYlq.css +0 -2
  98. package/dist/assets/kiosk-mode-Cu86-jaD.js +0 -1
  99. package/dist/assets/layout-CsKQkdEh.js +0 -5
  100. package/dist/assets/panels-D87Ptke4.js +0 -1
  101. package/dist/assets/process-output-CsvKn_Mr.js +0 -1
  102. package/dist/assets/useCellActionButton-4HWj1rt3.js +0 -1
  103. package/dist/assets/useNotebookActions-DXmWi5xU.js +0 -1
  104. package/dist/assets/useRunCells-Du76UV1R.js +0 -1
  105. package/dist/assets/utils-DKaC_ndw.js +0 -1
@@ -0,0 +1,9 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+ import { atom } from "jotai";
3
+
4
+ export interface TracebackData {
5
+ traceback: string;
6
+ errorMessage: string;
7
+ }
8
+
9
+ export const tracebackModalAtom = atom<TracebackData | null>(null);
@@ -21,17 +21,19 @@ import { BINDING_MANAGER, WIDGET_DEF_REGISTRY } from "./widget-binding";
21
21
  interface Data {
22
22
  jsUrl: string;
23
23
  jsHash: string;
24
+ modelId: WidgetModelId;
24
25
  }
25
26
 
26
27
  type AnyWidgetState = ModelState;
27
28
 
28
29
  /**
29
- * Initial value is a model_id reference.
30
- * The backend sends just { model_id: string } and the frontend
31
- * retrieves the actual state from the 'open' message.
30
+ * Value payload sent by the frontend on state updates.
31
+ *
32
+ * The initial value from the backend is empty — `model_id` is passed
33
+ * via immutable data attributes (`args`) so it survives value overwrites.
32
34
  */
33
35
  interface ModelIdRef {
34
- model_id: WidgetModelId;
36
+ model_id?: WidgetModelId;
35
37
  }
36
38
 
37
39
  export function useAnyWidgetModule(opts: { jsUrl: string; jsHash: string }) {
@@ -117,14 +119,14 @@ export const AnyWidgetPlugin = createPlugin<ModelIdRef>("marimo-anywidget")
117
119
  z.object({
118
120
  jsUrl: z.string(),
119
121
  jsHash: z.string(),
122
+ modelId: z.string().transform((v) => v as WidgetModelId),
120
123
  }),
121
124
  )
122
125
  .withFunctions({})
123
126
  .renderer((props) => <AnyWidgetSlot {...props} />);
124
127
 
125
128
  const AnyWidgetSlot = (props: IPluginProps<ModelIdRef, Data>) => {
126
- const { jsUrl, jsHash } = props.data;
127
- const { model_id: modelId } = props.value;
129
+ const { jsUrl, jsHash, modelId } = props.data;
128
130
  const host = props.host as HTMLElementNotDerivedFromRef;
129
131
 
130
132
  const { jsModule, error } = useAnyWidgetModule({ jsUrl, jsHash });
@@ -29,6 +29,7 @@ describe("LoadedSlot", () => {
29
29
  data: {
30
30
  jsUrl: "http://example.com/widget.js",
31
31
  jsHash: "abc123",
32
+ modelId: modelId,
32
33
  },
33
34
  host: document.createElement(
34
35
  "div",
@@ -67,6 +68,30 @@ describe("LoadedSlot", () => {
67
68
  });
68
69
  });
69
70
 
71
+ it("should not remount when value update drops model_id", async () => {
72
+ // Regression: when the frontend sends a state update (e.g. {zoom_level: 0}),
73
+ // it overwrites the UIElement value that originally held {model_id: "..."}.
74
+ // The key must stay stable because modelId comes from data, not value.
75
+ const { container, rerender } = render(<LoadedSlot {...mockProps} />);
76
+
77
+ await waitFor(() => {
78
+ expect(mockWidget.render).toHaveBeenCalledTimes(1);
79
+ });
80
+
81
+ const divBefore = container.querySelector("div");
82
+
83
+ // Simulate a value update that does NOT include model_id
84
+ // (this is what happens when the widget sends trait state)
85
+ rerender(<LoadedSlot {...mockProps} />);
86
+
87
+ await waitFor(() => {
88
+ // The div should be the same DOM node (no remount)
89
+ expect(container.querySelector("div")).toBe(divBefore);
90
+ // render should not be called again (no remount)
91
+ expect(mockWidget.render).toHaveBeenCalledTimes(1);
92
+ });
93
+ });
94
+
70
95
  it("should re-run widget when widget prop changes", async () => {
71
96
  const { rerender } = render(<LoadedSlot {...mockProps} />);
72
97
 
@@ -1,7 +0,0 @@
1
- import{s as X}from"./chunk-LvLJmgfZ.js";import{d as ye,f as ve,l as Ne,u as be}from"./useEvent-D91BmmQi.js";import{t as ke}from"./react-Bj1aDYRI.js";import{E as we,Tn as Ie,Xr as $e,Y as _e,Zn as Fe,Zr as Y,_n as Te,b as Ae,li as Ce}from"./cells-CcsG9Aum.js";import{t as q}from"./compiler-runtime-B3qBwwSJ.js";import{t as Se}from"./invariant-CkiqGLcK.js";import{r as Me}from"./utils-DKaC_ndw.js";import{t as G}from"./cn-DYvqRARy.js";import{t as ze}from"./jsx-runtime-Blw4afVn.js";import{a as Ee,i as qe,n as Pe,r as Le}from"./multi-map-MSuUqmbC.js";import{a as We,p as Ve,r as Be,t as Qe}from"./dropdown-menu-DrHAuMTb.js";import{t as J}from"./tooltip-DmqhBBs6.js";import{r as K,t as $}from"./button-BKVLeSTX.js";import{t as H}from"./createLucideIcon-w-Qo9n0R.js";import{r as De}from"./x-Bv2rCglF.js";import{t as Oe}from"./sparkles-DczT6OBt.js";import{c as ee,n as He}from"./datasource-D9nfSxKS.js";import{a as Ue}from"./dist-Bna8Uthk.js";import{t as te}from"./kbd-BbX-cXm5.js";import{t as T}from"./links-NCBzUApL.js";import{r as Ze,t as Re}from"./alert-DrrhKX67.js";import{o as Xe,t as Ye}from"./useInstallPackage-EEg9LCNy.js";import{n as Ge}from"./state-BBVlYaRC.js";import{n as b}from"./cell-link-Cimoe3Fv.js";var Je=H("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 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.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),A=H("square-arrow-out-up-right",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]),re=H("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);function Ke(r){let e=null,s=r.cursor();do s.name==="ExpressionStatement"&&(e=s.node);while(s.next());return e}function et(r){let e=r.split(`
2
- `),s=" ",n=Ke(Ue.parse(r));if(!n)return["def _():",...U(e,s),`${s}return`,"","","_()"].join(`
3
- `);let i=r.slice(0,n.from).trim(),l=r.slice(n.from).trim(),a=i.split(`
4
- `),c=l.split(`
5
- `);return["def _():",...U(a,s),`${s}return ${c[0]}`,...U(c.slice(1),s),"","","_()"].join(`
6
- `)}function U(r,e){if(r.length===1&&r[0]==="")return[];let s=[];for(let n of r)n===""?s.push(""):s.push(e+n);return s}function tt(r,e){var s;if(r.type==="multiple-defs")return[{title:"Fix: Wrap in a function",description:"Make this cell's variables local by wrapping the cell in a function.",fixType:"manual",onFix:async n=>{Se(n.editor,"Editor is null");let i=et(n.editor.state.doc.toString());n.editor.dispatch({changes:{from:0,to:n.editor.state.doc.length,insert:i}})}}];if(r.type==="exception"&&r.exception_type==="NameError"){let n=(s=r.msg.match(/name '(.+)' is not defined/))==null?void 0:s[1];if(!n||!(n in se))return[];let i=rt(n);return[{title:`Fix: Add '${i}'`,description:"Add a new cell for the missing import",fixType:"manual",onFix:async l=>{l.addCodeBelow(i)}}]}return r.type==="sql-error"&&e.aiEnabled?[{title:"Fix with AI",description:"Fix the SQL statement",fixType:"ai",onFix:async n=>{var a;let i=He(n.cellId),l=`Fix the SQL statement: ${r.msg}.`;i&&(l+=`
7
- Database schema: ${i}`),(a=n.aiFix)==null||a.setAiCompletionCell({cellId:n.cellId,initialPrompt:l,triggerImmediately:n.aiFix.triggerFix})}}]:[]}function rt(r){let e=se[r];return e===r?`import ${e}`:`import ${e} as ${r}`}var se={mo:"marimo",alt:"altair",bokeh:"bokeh",dask:"dask",np:"numpy",pd:"pandas",pl:"polars",plotly:"plotly",plt:"matplotlib.pyplot",px:"plotly.express",scipy:"scipy",sk:"sklearn",sns:"seaborn",stats:"scipy.stats",tf:"tensorflow",torch:"torch",xr:"xarray",dt:"datetime",json:"json",math:"math",os:"os",re:"re",sys:"sys"},st=q(),nt=Ce("marimo:ai-autofix-mode","autofix",Ie);function lt(){let r=(0,st.c)(3),[e,s]=Ne(nt),n;return r[0]!==e||r[1]!==s?(n={fixMode:e,setFixMode:s},r[0]=e,r[1]=s,r[2]=n):n=r[2],n}var Z=q(),t=X(ze(),1);const N=r=>{let e=(0,Z.c)(21),{errors:s,cellId:n,className:i}=r,l=ve(),{createNewCell:a}=we(),c=be(Me),o;if(e[0]!==c||e[1]!==s){let x;e[3]===c?x=e[4]:(x=y=>tt(y,{aiEnabled:c}),e[3]=c,e[4]=x),o=s.flatMap(x),e[0]=c,e[1]=s,e[2]=o}else o=e[2];let m=o,p=ye(Ge);if(m.length===0)return null;let d=m[0],f;e[5]!==n||e[6]!==a||e[7]!==d||e[8]!==p||e[9]!==l?(f=x=>{var k;let y=(k=l.get(Ae).cellHandles[n].current)==null?void 0:k.editorView;d.onFix({addCodeBelow:_=>{a({cellId:n,autoFocus:!1,before:!1,code:_})},editor:y,cellId:n,aiFix:{setAiCompletionCell:p,triggerFix:x}}),y==null||y.focus()},e[5]=n,e[6]=a,e[7]=d,e[8]=p,e[9]=l,e[10]=f):f=e[10];let u=f,j;e[11]===i?j=e[12]:(j=G("my-2",i),e[11]=i,e[12]=j);let h;e[13]!==d.description||e[14]!==d.fixType||e[15]!==d.title||e[16]!==u?(h=d.fixType==="ai"?(0,t.jsx)(oe,{tooltip:d.description,openPrompt:()=>u(!1),applyAutofix:()=>u(!0)}):(0,t.jsx)(J,{content:d.description,align:"start",children:(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>u(!1),children:[(0,t.jsx)(ee,{className:"h-3 w-3 mr-2"}),d.title]})}),e[13]=d.description,e[14]=d.fixType,e[15]=d.title,e[16]=u,e[17]=h):h=e[17];let g;return e[18]!==j||e[19]!==h?(g=(0,t.jsx)("div",{className:j,children:h}),e[18]=j,e[19]=h,e[20]=g):g=e[20],g};var ne=Oe,le=ee,ie="Suggest a prompt",ae="Fix with AI";const oe=r=>{let e=(0,Z.c)(21),{tooltip:s,openPrompt:n,applyAutofix:i}=r,{fixMode:l,setFixMode:a}=lt(),c=l==="prompt"?n:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,t.jsx)(ne,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,t.jsx)(le,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let m=l==="prompt"?ie:ae,p;e[2]!==c||e[3]!==o||e[4]!==m?(p=(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:c,children:[o,m]}),e[2]=c,e[3]=o,e[4]=m,e[5]=p):p=e[5];let d;e[6]!==p||e[7]!==s?(d=(0,t.jsx)(J,{content:s,align:"start",children:p}),e[6]=p,e[7]=s,e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(Ve,{asChild:!0,children:(0,t.jsx)($,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,t.jsx)(De,{className:"h-3 w-3"})})}),e[9]=f):f=e[9];let u;e[10]!==l||e[11]!==a?(u=()=>{a(l==="prompt"?"autofix":"prompt")},e[10]=l,e[11]=a,e[12]=u):u=e[12];let j=l==="prompt"?"autofix":"prompt",h;e[13]===j?h=e[14]:(h=(0,t.jsx)(it,{mode:j}),e[13]=j,e[14]=h);let g;e[15]!==u||e[16]!==h?(g=(0,t.jsxs)(Qe,{children:[f,(0,t.jsx)(Be,{align:"end",className:"w-56",children:(0,t.jsx)(We,{className:"flex items-center gap-2",onClick:u,children:h})})]}),e[15]=u,e[16]=h,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==d?(x=(0,t.jsxs)("div",{className:"flex",children:[d,g]}),e[18]=g,e[19]=d,e[20]=x):x=e[20],x};var it=r=>{let e=(0,Z.c)(12),{mode:s}=r,n;e[0]===s?n=e[1]:(n=s==="prompt"?(0,t.jsx)(ne,{className:"h-4 w-4"}):(0,t.jsx)(le,{className:"h-4 w-4"}),e[0]=s,e[1]=n);let i=n,l=s==="prompt"?ie:ae,a=s==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",c;e[2]===l?c=e[3]:(c=(0,t.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=c);let o;e[4]===a?o=e[5]:(o=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:a}),e[4]=a,e[5]=o);let m;e[6]!==c||e[7]!==o?(m=(0,t.jsxs)("div",{className:"flex flex-col",children:[c,o]}),e[6]=c,e[7]=o,e[8]=m):m=e[8];let p;return e[9]!==i||e[10]!==m?(p=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[i,m]}),e[9]=i,e[10]=m,e[11]=p):p=e[11],p},ce=/(https?:\/\/\S+)/,at=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,de=/^data:image\//i,ot=["avatars.githubusercontent.com"];function me(r){return de.test(r)?[{type:"image",url:r}]:r.split(ce).filter(e=>e!=="").map(e=>ce.test(e)?at.test(e)||de.test(e)||ot.some(s=>e.includes(s))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var pe=q(),P=X(ke(),1),ct=new _e;const R=r=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return r.replaceAll(e,"")};var ue=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function dt(r){ue.lastIndex=0;let e=ue.exec(r);if(!e)return null;let s=e.index+e[0].length,n=r.slice(s).split(/\s+/),i="",l=0;for(let c of n){let o=c.trim();if(!o)continue;if(o.startsWith("-")){l+=o.length+1;continue}let m=o.match(/^[\w,.[\]-]+/);if(m){i=m[0];break}break}if(!i)return null;let a=s+l+i.length;return{package:i,endIndex:a}}function w(r,e=""){if(!r)return null;if(!/https?:\/\//.test(r))return r;let s=me(r);return s.length===1&&s[0].type==="text"?r:(0,t.jsx)(t.Fragment,{children:s.map((n,i)=>{let l=e?`${e}-${i}`:i;if(n.type==="url"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:K.stopPropagation(),className:"text-link hover:underline",children:a},l)}if(n.type==="image"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:K.stopPropagation(),className:"text-link hover:underline",children:a},l)}return(0,t.jsx)(P.Fragment,{children:n.value},l)})})}var mt=r=>{let e=(0,pe.c)(6),{packages:s,children:n}=r,{handleInstallPackages:i}=Ye(),l;e[0]!==i||e[1]!==s?(l=c=>{i(s),c.preventDefault()},e[0]=i,e[1]=s,e[2]=l):l=e[2];let a;return e[3]!==n||e[4]!==l?(a=(0,t.jsx)("button",{onClick:l,className:"text-link hover:underline",type:"button",children:n}),e[3]=n,e[4]=l,e[5]=a):a=e[5],a};const pt=r=>{if(!(r instanceof Y.Text))return;let e=R(r.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let s=[],n=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,i;for(;(i=n.exec(e))!==null;){let c=i.index,o=dt(e.slice(c));o&&s.push({match:i,result:o})}if(s.length===0)return;let l=[],a=0;if(s.forEach((c,o)=>{let{match:m,result:p}=c,d=m.index,f=d+p.endIndex;if(a<d){let j=e.slice(a,d);l.push((0,t.jsx)(P.Fragment,{children:w(j,`before-${o}`)},`before-${o}`))}let u=e.slice(d,f);l.push((0,t.jsx)(mt,{packages:[p.package],children:u},`install-${o}`)),a=f}),a<e.length){let c=e.slice(a);l.push((0,t.jsx)(P.Fragment,{children:w(c,"after")},"after"))}return(0,t.jsx)(t.Fragment,{children:l})},ut=r=>{if(!(r instanceof Y.Text))return;let e=r.data;if(!/https?:\/\//.test(e))return;let s=w(e);if(typeof s!="string")return(0,t.jsx)(t.Fragment,{children:s})},ht=(...r)=>e=>{for(let s of r){let n=s(e);if(n!==void 0)return n}},xt=(r,e)=>(0,t.jsx)("span",{children:$e(ct.ansi_to_html(r),{replace:s=>e(s)})}),ft=r=>{let e=(0,pe.c)(4),{text:s}=r,n;e[0]===s?n=e[1]:(n=xt(s,ht(pt,ut)),e[0]=s,e[1]=n);let i=n,l;return e[2]===i?l=e[3]:(l=(0,t.jsx)(t.Fragment,{children:i}),e[2]=i,e[3]=l),l};var he=q(),I=r=>{let e=(0,he.c)(10),s=r.title??"Tip",n;e[0]===s?n=e[1]:(n=(0,t.jsx)(Ee,{className:"pt-2 pb-2 font-normal",children:s}),e[0]=s,e[1]=n);let i;e[2]===r.children?i=e[3]:(i=(0,t.jsx)(Le,{className:"mr-24 text-[0.84375rem]",children:r.children}),e[2]=r.children,e[3]=i);let l;e[4]!==n||e[5]!==i?(l=(0,t.jsxs)(qe,{value:"item-1",className:"text-muted-foreground",children:[n,i]}),e[4]=n,e[5]=i,e[6]=l):l=e[6];let a;return e[7]!==r.className||e[8]!==l?(a=(0,t.jsx)(Pe,{type:"single",collapsible:!0,className:r.className,children:l}),e[7]=r.className,e[8]=l,e[9]=a):a=e[9],a};const jt=r=>{let e=(0,he.c)(31),{errors:s,cellId:n,className:i}=r,l=Te(),a="This cell wasn't run because it has errors",c="destructive",o="text-error";if(s.some(gt))a="Interrupted";else if(s.some(yt))a="An internal error occurred";else if(s.some(vt))a="Ancestor prevented from running",c="default",o="text-secondary-foreground";else if(s.some(Nt))a="Ancestor stopped",c="default",o="text-secondary-foreground";else if(s.some(bt))a="SQL error";else{let x;e[0]===s?x=e[1]:(x=s.find(kt),e[0]=s,e[1]=x);let y=x;y&&"exception_type"in y&&(a=y.exception_type)}let m,p,d,f,u,j;if(e[2]!==c||e[3]!==n||e[4]!==l||e[5]!==i||e[6]!==s||e[7]!==o||e[8]!==a){let x=s.filter(wt),y=s.filter(It),k=s.filter($t),_=s.filter(_t),L=s.filter(Ft),C=s.filter(Tt),S=s.filter(At),W=s.filter(Ct),V=s.filter(St),B=s.filter(Mt),F=s.filter(zt),Q=s.filter(Et),D=s.filter(qt),M;e[15]===l?M=e[16]:(M=()=>{l.openApplication("scratchpad")},e[15]=l,e[16]=M);let xe=M,fe=()=>{let v=[];if(F.length>0||Q.length>0){let E=F.some(Pt),ge=!E&&F.some(Lt);v.push((0,t.jsxs)("div",{children:[F.map(Wt),Q.map(Vt),E&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>Xe(l),children:[(0,t.jsx)(Je,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,t.jsx)("span",{children:"Open package manager"})]}),ge&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openApplication("terminal"),children:[(0,t.jsx)(re,{className:"h-3.5 w-3.5 mr-1.5"}),(0,t.jsx)("span",{children:"Open terminal"})]}),n&&(0,t.jsx)(N,{errors:[...F,...Q],cellId:n})]},"syntax-unknown"))}if(x.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,t.jsx)("ul",{className:"list-disc",children:x.flatMap(Bt)}),n&&(0,t.jsx)(N,{errors:x,cellId:n}),(0,t.jsxs)(I,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"The setup cell contains logic that must be run before any other cell runs, including top-level imports used by top-level functions. For this reason, it can't refer to other cells' variables."}),(0,t.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),y.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,t.jsx)("ul",{className:"list-disc",children:y.flatMap(Qt)}),n&&(0,t.jsx)(N,{errors:y,cellId:n}),(0,t.jsxs)(I,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"An example of a cycle is if one cell declares a variable 'a' and reads 'b', and another cell declares 'b' and and reads 'a'. Cycles like this make it impossible for marimo to know how to run your cells, and generally suggest that your code has a bug."}),(0,t.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),k.length>0){let E=k[0].name;v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),k.map(Ot),n&&(0,t.jsx)(N,{errors:k,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I redefine variables?",children:[(0,t.jsx)("p",{className:"pb-2",children:"marimo requires that each variable is defined in just one cell. This constraint enables reactive and reproducible execution, arbitrary cell reordering, seamless UI elements, execution as a script, and more."}),(0,t.jsxs)("p",{className:"py-2",children:["Try merging this cell with the mentioned cells or wrapping it in a function. Alternatively, prefix variables with an underscore (e.g., ",(0,t.jsxs)(te,{className:"inline",children:["_",E]}),"). to make them private to this cell."]}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,t.jsx)(I,{title:"Need a scratchpad?",children:(0,t.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,t.jsxs)($,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:xe,children:[(0,t.jsx)(Fe,{className:"h-3"}),(0,t.jsx)("span",{children:"Try the scratchpad"})]}),(0,t.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return _.length>0&&v.push((0,t.jsxs)("div",{children:[_.map(Ht),n&&(0,t.jsx)(N,{errors:_,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I use `import *`?",children:[(0,t.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,t.jsx)("p",{className:"py-2",children:"marimo's Python file format stores code in functions, so notebooks can be imported as regular Python modules without executing all their code. But Python disallows `import *` everywhere except at the top-level of a module."}),(0,t.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),L.length>0&&v.push((0,t.jsxs)("div",{children:[L.map(Ut),n&&(0,t.jsx)(N,{errors:L,cellId:n})]},"interruption")),C.length>0&&v.push((0,t.jsxs)("ul",{children:[C.map(Zt),C.some(Rt)&&(0,t.jsx)(I,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),n&&(0,t.jsx)(N,{errors:C,cellId:n})]},"exception")),S.length>0&&v.push((0,t.jsxs)("ul",{children:[S.map(Xt),n&&(0,t.jsx)(N,{errors:S,cellId:n}),(0,t.jsx)(I,{children:S.some(Yt)?"Ensure that the referenced cells define the required variables, or turn off strict execution.":"Something is wrong with your declarations. Fix any discrepancies, or turn off strict execution."})]},"strict-exception")),W.length>0&&v.push((0,t.jsxs)("div",{children:[W.map(Gt),n&&(0,t.jsx)(N,{errors:W,cellId:n})]},"internal")),V.length>0&&v.push((0,t.jsxs)("div",{children:[V.map(Jt),n&&(0,t.jsx)(N,{errors:V,cellId:n})]},"ancestor-prevented")),B.length>0&&v.push((0,t.jsxs)("div",{children:[B.map(Kt),n&&(0,t.jsx)(N,{errors:B,cellId:n})]},"ancestor-stopped")),D.length>0&&v.push((0,t.jsxs)("div",{children:[D.map(er),n&&(0,t.jsx)(N,{errors:D,cellId:n,className:"mt-2.5"})]},"sql-errors")),v},O=`font-code font-medium tracking-wide ${o}`,z;e[17]!==O||e[18]!==a?(z=(0,t.jsx)(Ze,{className:O,children:a}),e[17]=O,e[18]=a,e[19]=z):z=e[19];let je=z;m=Re,f=c,e[20]===i?u=e[21]:(u=G("border-none font-code text-sm text-[0.84375rem] px-0 text-muted-foreground normal [&:has(svg)]:pl-0 space-y-4",i),e[20]=i,e[21]=u),j=je,p="flex flex-col gap-8",d=fe(),e[2]=c,e[3]=n,e[4]=l,e[5]=i,e[6]=s,e[7]=o,e[8]=a,e[9]=m,e[10]=p,e[11]=d,e[12]=f,e[13]=u,e[14]=j}else m=e[9],p=e[10],d=e[11],f=e[12],u=e[13],j=e[14];let h;e[22]!==p||e[23]!==d?(h=(0,t.jsx)("div",{children:(0,t.jsx)("div",{className:p,children:d})}),e[22]=p,e[23]=d,e[24]=h):h=e[24];let g;return e[25]!==m||e[26]!==f||e[27]!==u||e[28]!==j||e[29]!==h?(g=(0,t.jsxs)(m,{variant:f,className:u,children:[j,h]}),e[25]=m,e[26]=f,e[27]=u,e[28]=j,e[29]=h,e[30]=g):g=e[30],g};function gt(r){return r.type==="interruption"}function yt(r){return r.type==="internal"}function vt(r){return r.type==="ancestor-prevented"}function Nt(r){return r.type==="ancestor-stopped"}function bt(r){return r.type==="sql-error"}function kt(r){return r.type==="exception"}function wt(r){return r.type==="setup-refs"}function It(r){return r.type==="cycle"}function $t(r){return r.type==="multiple-defs"}function _t(r){return r.type==="import-star"}function Ft(r){return r.type==="interruption"}function Tt(r){return r.type==="exception"}function At(r){return r.type==="strict-exception"}function Ct(r){return r.type==="internal"}function St(r){return r.type==="ancestor-prevented"}function Mt(r){return r.type==="ancestor-stopped"}function zt(r){return r.type==="syntax"}function Et(r){return r.type==="unknown"}function qt(r){return r.type==="sql-error"}function Pt(r){return r.msg.includes("!pip")}function Lt(r){return r.msg.includes("use os.subprocess")}function Wt(r,e){return(0,t.jsx)("pre",{children:w(r.msg,`syntax-${e}`)},`syntax-${e}`)}function Vt(r,e){return(0,t.jsx)("pre",{children:w(r.msg,`unknown-${e}`)},`unknown-${e}`)}function Bt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",s[1].length===1?s[1][0]:s[1].join(", ")]})]},`setup-refs-${e}-${n}`))}function Qt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",s[1].length===1?s[1][0]:s[1].join(", ")," -> "]}),(0,t.jsx)(b,{cellId:s[2]})]},`cycle-${e}-${n}`))}function Dt(r,e){return(0,t.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,t.jsx)(b,{cellId:r})},`cell-${e}`)}function Ot(r,e){return(0,t.jsxs)(P.Fragment,{children:[(0,t.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${r.name}' was also defined by:`}),(0,t.jsx)("ul",{className:"list-disc",children:r.cells.map(Dt)})]},`multiple-defs-${e}`)}function Ht(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function Ut(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Zt(r,e){return r.exception_type==="NameError"&&r.msg.startsWith("name 'mo'")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,t.jsx)(te,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${e}`):r.exception_type==="NameError"&&r.msg.startsWith("name '_")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,t.jsxs)(T,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),")."]}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${e}`):(0,t.jsx)("li",{className:"my-2",children:r.raising_cell==null?(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:w(r.msg,`exception-${e}`)}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,t.jsxs)("div",{children:[w(r.msg,`exception-${e}`),(0,t.jsx)(b,{cellId:r.raising_cell})]})},`exception-${e}`)}function Rt(r){return r.raising_cell!=null}function Xt(r,e){return(0,t.jsx)("li",{className:"my-2",children:r.blamed_cell==null?(0,t.jsx)("p",{children:r.msg}):(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.blamed_cell})]})},`strict-exception-${e}`)}function Yt(r){return r.blamed_cell!=null}function Gt(r,e){return(0,t.jsx)("p",{children:r.msg},`internal-${e}`)}function Jt(r,e){return(0,t.jsxs)("div",{children:[r.msg,r.blamed_cell==null?(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),")"]}):(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),"\xA0blames\xA0",(0,t.jsx)(b,{cellId:r.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function Kt(r,e){return(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.raising_cell})]},`ancestor-stopped-${e}`)}function er(r,e){return(0,t.jsx)("div",{className:"space-y-2 mt-2",children:(0,t.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.msg})},`sql-error-${e}`)}export{re as a,oe as i,ft as n,me as r,jt as t};
@@ -1 +0,0 @@
1
- import{s as v}from"./chunk-LvLJmgfZ.js";import{i as j,p as y,u as w}from"./useEvent-D91BmmQi.js";import{t as R}from"./react-Bj1aDYRI.js";import{Xr as S,Z as _,Zr as c,dt as H,ln as I,m as M,pn as N}from"./cells-CcsG9Aum.js";import{t as E}from"./compiler-runtime-B3qBwwSJ.js";import{_ as T}from"./useEventListener-DGjKht0c.js";import{o as z}from"./utils-DKaC_ndw.js";import{t as C}from"./jsx-runtime-Blw4afVn.js";import{t as F}from"./tooltip-DmqhBBs6.js";import{t as L}from"./usePress-YLit4doY.js";import{n as V}from"./useDebounce-CnN5Ul9t.js";import{t as k}from"./copy-icon-CG2ao3lW.js";import{t as q}from"./useRunCells-Du76UV1R.js";var W=E(),m=v(R(),1),o=v(C(),1);const A=r=>{let t=(0,W.c)(16),e,n,i;t[0]===r?(e=t[1],n=t[2],i=t[3]):({href:n,children:e,...i}=r,t[0]=r,t[1]=e,t[2]=n,t[3]=i);let a=(0,m.useRef)(null),l;t[4]===n?l=t[5]:(l=()=>{let u=new URL(globalThis.location.href);u.hash=n,globalThis.history.pushState({},"",u.toString()),globalThis.dispatchEvent(new HashChangeEvent("hashchange"));let x=n.slice(1),g=document.getElementById(x);g&&g.scrollIntoView({behavior:"smooth",block:"start"})},t[4]=n,t[5]=l);let s=l,f;t[6]===s?f=t[7]:(f={onPress:()=>{s()}},t[6]=s,t[7]=f);let{pressProps:h}=L(f),d;t[8]===s?d=t[9]:(d=u=>{u.preventDefault(),s()},t[8]=s,t[9]=d);let b=d,p;return t[10]!==e||t[11]!==b||t[12]!==n||t[13]!==h||t[14]!==i?(p=(0,o.jsx)("a",{ref:a,href:n,...h,onClick:b,...i,children:e}),t[10]=e,t[11]=b,t[12]=n,t[13]=h,t[14]=i,t[15]=p):p=t[15],p};async function D(r){let t=M().inOrderIds.at(0);if(t)try{let e=await I.request({document:r,cellId:t});if(!e||e.options.length===0)return;let n=r.split(".").pop()??r,i=e.options[0],a=e.options.find(l=>l.name===n)??i;a!=null&&a.completion_info&&j.set(N,{documentation:a.completion_info})}catch(e){T.debug(`Doc lookup failed for "${r}"`,e)}}var O=E();const P=r=>{let t=(0,O.c)(8),{qualifiedName:e,children:n}=r,i;t[0]===e?i=t[1]:(i=()=>{D(e)},t[0]=e,t[1]=i);let a=V(i,100),l;t[2]===a?l=t[3]:(l=()=>a.cancel(),t[2]=a,t[3]=l);let s;return t[4]!==n||t[5]!==a||t[6]!==l?(s=(0,o.jsx)("span",{onMouseEnter:a,onMouseLeave:l,children:n}),t[4]=n,t[5]=a,t[6]=l,t[7]=s):s=t[7],s};var Z=y(r=>{let t=r(q),e=r(z);if(t||e)return!1;let n=!0;try{n=_()==="read"}catch{return!0}return!n});function $(){return w(Z)}var B=E(),U=r=>{if(r instanceof c.Element&&!/^[A-Za-z][\w-]*$/.test(r.name))return m.createElement(m.Fragment)},X=(r,t)=>{if(t instanceof c.Element&&t.name==="body"){if((0,m.isValidElement)(r)&&"props"in r){let e=r.props.children;return(0,o.jsx)(o.Fragment,{children:e})}return}},G=(r,t)=>{if(t instanceof c.Element&&t.name==="html"){if((0,m.isValidElement)(r)&&"props"in r){let e=r.props.children;return(0,o.jsx)(o.Fragment,{children:e})}return}},J=r=>{if(r instanceof c.Element&&r.attribs&&r.name==="iframe"){let t=document.createElement("iframe");return Object.entries(r.attribs).forEach(([e,n])=>{e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1)),t.setAttribute(e,n)}),(0,o.jsx)("div",{dangerouslySetInnerHTML:{__html:t.outerHTML}})}},K=r=>{if(r instanceof c.Element&&r.name==="script"){let t=r.attribs.src;if(!t)return;if(!document.querySelector(`script[src="${t}"]`)){let e=document.createElement("script");e.src=t,document.head.append(e)}return(0,o.jsx)(o.Fragment,{})}},Q=(r,t)=>{if(t instanceof c.Element&&t.name==="a"){let e=t.attribs.href;if(e!=null&&e.startsWith("#")&&!e.startsWith("#code/")){let n=null;return(0,m.isValidElement)(r)&&"props"in r&&(n=r.props.children),(0,o.jsx)(A,{href:e,...t.attribs,children:n})}}},Y=(r,t,e)=>{var n,i;if(t instanceof c.Element&&t.name==="div"&&((i=(n=t.attribs)==null?void 0:n.class)!=null&&i.includes("codehilite")))return(0,o.jsx)(rt,{children:r},e)},tt=(r,t)=>{var e;if(t instanceof c.Element&&((e=t.attribs)!=null&&e["data-marimo-doc"])){let n=t.attribs["data-marimo-doc"];return(0,o.jsx)(P,{qualifiedName:n,children:r})}},et=(r,t)=>{var e;if(t instanceof c.Element&&((e=t.attribs)!=null&&e["data-tooltip"])){let n=t.attribs["data-tooltip"];return(0,o.jsx)(F,{content:n,children:r})}},rt=r=>{let t=(0,B.c)(3),{children:e}=r,n=(0,m.useRef)(null),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,o.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,o.jsx)(k,{tooltip:!1,className:"p-1",value:()=>{var s;let l=(s=n.current)==null?void 0:s.firstChild;return l&&l.textContent||""}})}),t[0]=i):i=t[0];let a;return t[1]===e?a=t[2]:(a=(0,o.jsxs)("div",{className:"relative group codehilite-wrapper",ref:n,children:[e,i]}),t[1]=e,t[2]=a),a};const nt=({html:r,additionalReplacements:t=[],alwaysSanitizeHtml:e=!0})=>(0,o.jsx)(it,{html:r,alwaysSanitizeHtml:e,additionalReplacements:t});var it=({html:r,additionalReplacements:t=[],alwaysSanitizeHtml:e})=>{let n=$();return at({html:(0,m.useMemo)(()=>e||n?H(r):r,[r,e,n]),additionalReplacements:t})};function at({html:r,additionalReplacements:t=[]}){let e=[U,J,K,...t],n=[Y,Q,tt,et,X,G];return S(r,{replace:(i,a)=>{for(let l of e){let s=l(i,a);if(s)return s}return i},transform:(i,a,l)=>{for(let s of n){let f=s(i,a,l);if(f)return f}return i}})}export{nt as t};