@marimo-team/frontend 0.19.3-dev17 → 0.19.3-dev21
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.
- package/dist/assets/{CellStatus-BwPGnX3z.js → CellStatus-DLqgbVV4.js} +1 -1
- package/dist/assets/{JsonOutput--AuyEErr.js → JsonOutput-B64aMW9B.js} +1 -1
- package/dist/assets/{MarimoErrorOutput-BZjY8e2w.js → MarimoErrorOutput-Cva6Gfqr.js} +1 -1
- package/dist/assets/{RenderHTML-BTLaM20B.js → RenderHTML-Daqo9pcD.js} +1 -1
- package/dist/assets/{add-cell-with-ai-BWWVs9qV.js → add-cell-with-ai-BsHIKGwv.js} +1 -1
- package/dist/assets/{add-database-form-Bw_YRH1r.js → add-database-form-hxk-QlNU.js} +1 -1
- package/dist/assets/{agent-panel-DXYuB421.js → agent-panel-ZJGfvLy4.js} +1 -1
- package/dist/assets/{ai-model-dropdown-BrUOgnWS.js → ai-model-dropdown-nzo8MLQ5.js} +1 -1
- package/dist/assets/{app-config-button-B8CXELx0.js → app-config-button-BeOl77GX.js} +1 -1
- package/dist/assets/{cell-editor-CQcpZLQc.js → cell-editor-c1P0x4Fj.js} +1 -1
- package/dist/assets/{cell-link-CFAPzUg5.js → cell-link-T1P92ttw.js} +1 -1
- package/dist/assets/{cells-DU3EySUd.js → cells-CibeVr5R.js} +1 -1
- package/dist/assets/{chat-components-Bc9j9ls4.js → chat-components-CVdyP1VW.js} +1 -1
- package/dist/assets/{chat-display-BrTi6c8V.js → chat-display-Bbzp0CzX.js} +1 -1
- package/dist/assets/{chat-panel-8Dym5Gv3.js → chat-panel-T30-embL.js} +1 -1
- package/dist/assets/{client-DfkWorYM.js → client-CEtu-2VG.js} +1 -1
- package/dist/assets/{column-preview-Ck6B_-sQ.js → column-preview-BlyFeHSu.js} +1 -1
- package/dist/assets/{command-B_minI8b.js → command-CyUURgqS.js} +1 -1
- package/dist/assets/{command-palette-BT3u6JBB.js → command-palette-DfiEH7WH.js} +1 -1
- package/dist/assets/{common-jorbwXZC.js → common-eyGhVBMz.js} +1 -1
- package/dist/assets/{datasource-DCvPlnaJ.js → datasource-D4vwmOLv.js} +1 -1
- package/dist/assets/{dependency-graph-panel-C9jYZ6pA.js → dependency-graph-panel-Cr-_H1bC.js} +1 -1
- package/dist/assets/{documentation-panel-AsatrTfg.js → documentation-panel-mdqxAzQf.js} +1 -1
- package/dist/assets/{download-PR1bF3g_.js → download-Bd63S7ca.js} +1 -1
- package/dist/assets/{edit-page-BvHKW1ab.js → edit-page-CgVMZsLj.js} +4 -4
- package/dist/assets/{error-panel-D_wVKV6I.js → error-panel-zDg8AjLO.js} +1 -1
- package/dist/assets/{es-CEE_7T0w.js → es-BMs8n9bF.js} +1 -1
- package/dist/assets/{file-explorer-panel-DltK8JVp.js → file-explorer-panel-Bvbp6xd9.js} +1 -1
- package/dist/assets/{floating-outline-BfdazXWm.js → floating-outline-DmKm2GKv.js} +1 -1
- package/dist/assets/{focus-CtlWIiQr.js → focus-BGO2qwac.js} +1 -1
- package/dist/assets/{form-Cy5TkLzh.js → form-Cs-aYOue.js} +1 -1
- package/dist/assets/{globals-BSLm1nlz.js → globals-BkITdONE.js} +1 -1
- package/dist/assets/{home-page-CEnaUutq.js → home-page-CqrJtZ_6.js} +1 -1
- package/dist/assets/{index-ImpEfS6x.js → index-DXLkhAK3.js} +3 -3
- package/dist/assets/{kiosk-mode-BnTZR6mM.js → kiosk-mode-Ocj2e3JE.js} +1 -1
- package/dist/assets/{layout-BTiWDrbh.js → layout-HXw-kbRR.js} +1 -1
- package/dist/assets/{logs-panel-Cnp9tO_1.js → logs-panel-C70PjyAu.js} +1 -1
- package/dist/assets/{markdown-renderer-BSrbBHwX.js → markdown-renderer-D2XRRGdl.js} +1 -1
- package/dist/assets/{mode-yhfN-4ye.js → mode-j1jRJgw_.js} +1 -1
- package/dist/assets/{name-cell-input-CmuWqgFR.js → name-cell-input-XHY7Ji2w.js} +1 -1
- package/dist/assets/{outline-panel-DCfj1bI-.js → outline-panel-DmehVoPZ.js} +1 -1
- package/dist/assets/{packages-panel-BiEckVdM.js → packages-panel-D8Dc0jXW.js} +1 -1
- package/dist/assets/{panels-BXRys72u.js → panels-DOPj-FZ7.js} +1 -1
- package/dist/assets/{process-output-wGlHkL-Q.js → process-output-DZorMbgK.js} +1 -1
- package/dist/assets/{readonly-python-code-xbh7G2Y2.js → readonly-python-code-CzWlUPo8.js} +1 -1
- package/dist/assets/{run-page-BCwJRhCq.js → run-page-B7UH5d5F.js} +1 -1
- package/dist/assets/{scratchpad-panel-ByFq6zUA.js → scratchpad-panel-BvjbLs06.js} +1 -1
- package/dist/assets/{session-panel-DuQl_oQp.js → session-panel-Cg2ez0A-.js} +1 -1
- package/dist/assets/{snippets-panel-R_ql6HGu.js → snippets-panel-BCzTzB9R.js} +1 -1
- package/dist/assets/{state-DEHWsmkM.js → state-BxWZf58F.js} +1 -1
- package/dist/assets/{state-DXAf-ejz.js → state-Eihpi8Gd.js} +1 -1
- package/dist/assets/{switch-CWzL-0WF.js → switch-Bf7BdNuP.js} +1 -1
- package/dist/assets/{textarea-CfvBt_Xm.js → textarea-BRmAhRr_.js} +1 -1
- package/dist/assets/{tracing-Kscqc1t3.js → tracing-1SYqHZWJ.js} +1 -1
- package/dist/assets/{tracing-panel-BEzOflWc.js → tracing-panel-Bcs0pfdJ.js} +2 -2
- package/dist/assets/{types-DhuSHMNQ.js → types-Dqr8wUa4.js} +1 -1
- package/dist/assets/{useAddCell-C9lbOVO1.js → useAddCell-BEZy0w8u.js} +1 -1
- package/dist/assets/{useCellActionButton-fsh9MTAX.js → useCellActionButton-BPZZpi7i.js} +1 -1
- package/dist/assets/{useDeleteCell-ByImoTpm.js → useDeleteCell-BIkFVvVx.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-CngFbla0.js → useDependencyPanelTab-B4L5DuIf.js} +1 -1
- package/dist/assets/{useNotebookActions-D01w160c.js → useNotebookActions-N9jfUrVW.js} +1 -1
- package/dist/assets/{useRunCells-CmnSPQtM.js → useRunCells-d0gYuXYQ.js} +1 -1
- package/dist/assets/{useSplitCell-BTH64tve.js → useSplitCell-DGmYA9dE.js} +1 -1
- package/dist/assets/{utilities.esm-CMQs6YPp.js → utilities.esm-Bs_5S-OE.js} +1 -1
- package/dist/index.html +31 -31
- package/package.json +1 -1
- package/src/components/editor/renderers/vertical-layout/__tests__/useFocusFirstEditor.test.ts +27 -0
- package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +6 -0
- package/src/core/cells/scrollCellIntoView.ts +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as oe}from"./chunk-LvLJmgfZ.js";import{d as N,l as Ie,p as Te,u as K}from"./useEvent-DlWF5OMa.js";import{t as He}from"./react-BGmjiNul.js";import{Bn as Le,C as ie,Et as qe,Jn as Re,Nt as Ve,Pt as ne,Rn as Be,Un as Oe,an as Ue,ei as Q,h as Ye,in as $e,mr as Fe,on as Ge,p as le,t as Je,un as Ke}from"./cells-DU3EySUd.js";import{t as W}from"./compiler-runtime-DeeZ7FnK.js";import{i as Qe}from"./useLifecycle-CmDXEyIC.js";import{a as se}from"./type-BdyvjzTI.js";import{n as Xe}from"./add-database-form-Bw_YRH1r.js";import{a as re,d as P}from"./hotkeys-uKX61F1_.js";import{v as Ze}from"./utils-CJJIceVn.js";import{n as _,t as de}from"./constants-Bkp4R3bQ.js";import{M as ce,f as et,j as tt,w as at}from"./config-Ba3eeYri.js";import{t as ot}from"./jsx-runtime-DN_bIXfG.js";import{r as it,t as X}from"./button-DuYGqRtX.js";import{r as E}from"./requests-C0HaHO6a.js";import{t as c}from"./createLucideIcon-CW2xpJ57.js";import{a as he,f as nt,i as pe,m as lt,p as me,u as ue}from"./layout-BTiWDrbh.js";import{t as fe}from"./check-CrAQug3q.js";import{a as st,c as rt,i as dt,n as ct,r as ht,s as pt,t as mt}from"./select-D0g5GnIs.js";import{i as ye,r as ut,t as be}from"./download-PR1bF3g_.js";import{f as ft}from"./maps-s2pQkyf5.js";import{r as yt}from"./useCellActionButton-fsh9MTAX.js";import{t as bt}from"./copy-gBVL4NN-.js";import{d as kt,t as xt}from"./state-DEHWsmkM.js";import{t as wt}from"./download-DobaYJPt.js";import{t as gt}from"./eye-off-D9zAYqG9.js";import{t as jt}from"./file-plus-corner-BO_uS88s.js";import{t as vt}from"./file-BnFXtaZZ.js";import{i as Ct,n as zt,r as Mt,t as Wt}from"./youtube-BJQRl2JC.js";import{n as _t,t as At}from"./house-CncUa_LL.js";import{n as St}from"./play-BJDBXApx.js";import{t as Nt}from"./link-54sBkoQp.js";import{r as Pt}from"./input-CaEtLL8p.js";import{t as Et}from"./settings-MTlHVxz3.js";import{y as Dt}from"./textarea-CfvBt_Xm.js";import{t as It}from"./square-leQTJTJJ.js";import{t as j}from"./use-toast-Bzf3rpev.js";import{t as Tt}from"./tooltip-CvjcEpZC.js";import{a as ke,i as Ht,r as Lt}from"./mode-yhfN-4ye.js";import{o as qt}from"./alert-dialog-k5KxevGr.js";import{a as Rt,c as Vt,i as Bt,n as Ot,r as Ut}from"./dialog-DUEuLcT2.js";import{n as Z}from"./ImperativeModal-q6QlC2aZ.js";import{r as Yt,t as $t}from"./share-CXQVxivL.js";import{t as V}from"./copy-DRhpWiOq.js";import{r as Ft}from"./useRunCells-CmnSPQtM.js";import{a as Gt}from"./cell-link-CFAPzUg5.js";import{a as xe}from"./renderShortcut-D0Pei-OA.js";import{t as Jt}from"./icons-D4lB4En9.js";import{t as Kt}from"./links-Bpd4gqTj.js";import{t as we}from"./types-BLEgJ92v.js";var Qt=c("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Xt=c("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),ge=c("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"}]]),je=c("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"}]]),ve=c("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"}]]),Zt=c("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"}]]),ea=c("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["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"}]]),ta=c("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"}]]),Ce=c("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"}]]),aa=c("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),oa=c("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),ze=c("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"}]]),ia=c("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"}]]),na=c("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"}]]),Me=c("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"}]]),We=W(),ee=oe(He(),1),a=oe(ot(),1),B="https://static.marimo.app";const la=e=>{let t=(0,We.c)(25),{onClose:i}=e,[o,l]=(0,ee.useState)(""),{exportAsHTML:r}=E(),s=`${o}-${Math.random().toString(36).slice(2,6)}`,n=`${B}/static/${s}`,d;t[0]!==r||t[1]!==i||t[2]!==s?(d=async v=>{v.preventDefault(),i();let A=await r({download:!1,includeCode:!0,files:nt.INSTANCE.filenames()}),z=j({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${B}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:A,path:s})}).catch(()=>{z.dismiss(),j({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:_.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),j({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=i,t[2]=s,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(Vt,{children:"Share static notebook"}),t[4]=p):p=t[4];let x;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=(0,a.jsxs)(Rt,{children:[p,(0,a.jsxs)(Ut,{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"," ",(0,a.jsx)("a",{href:B,target:"_blank",children:B}),"."]})]}),t[5]=x):x=t[5];let w;t[6]===Symbol.for("react.memo_cache_sentinel")?(w=v=>{l(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=w):w=t[6];let m;t[7]===o?m=t[8]:(m=(0,a.jsx)(Pt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:w,required:!0,autoComplete:"off"}),t[7]=o,t[8]=m);let u;t[9]===n?u=t[10]:(u=(0,a.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:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(sa,{text:n}),(0,a.jsx)("span",{className:"text-primary",children:n})]})]}),t[9]=n,t[10]=u);let f;t[11]!==m||t[12]!==u?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[m,u]}),t[11]=m,t[12]=u,t[13]=f):f=t[13];let y;t[14]===i?y=t[15]:(y=(0,a.jsx)(X,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:i,children:"Cancel"}),t[14]=i,t[15]=y);let b;t[16]===n?b=t[17]:(b=(0,a.jsx)(X,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await V(n)},children:"Create"}),t[16]=n,t[17]=b);let k;t[18]!==y||t[19]!==b?(k=(0,a.jsxs)(Bt,{children:[y,b]}),t[18]=y,t[19]=b,t[20]=k):k=t[20];let g;return t[21]!==d||t[22]!==k||t[23]!==f?(g=(0,a.jsx)(Ot,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[x,f,k]})}),t[21]=d,t[22]=k,t[23]=f,t[24]=g):g=t[24],g};var sa=e=>{let t=(0,We.c)(8),[i,o]=ee.useState(!1),l;t[0]===e.text?l=t[1]:(l=it.stopPropagation(async p=>{p.preventDefault(),await V(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=l);let r=l,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(bt,{size:14,strokeWidth:1.5}),t[2]=s):s=t[2];let n;t[3]===r?n=t[4]:(n=(0,a.jsx)(X,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:s}),t[3]=r,t[4]=n);let d;return t[5]!==i||t[6]!==n?(d=(0,a.jsx)(Tt,{content:"Copied!",open:i,children:n}),t[5]=i,t[6]=n,t[7]=d):d=t[7],d},ra=W();function da(){let e=document.getElementsByClassName(de.outputArea);for(let t of e){let i=t.getBoundingClientRect();if(i.bottom>0&&i.top<window.innerHeight){let o=Q.findElement(t);if(!o){P.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:Q.parse(o.id)}}}return P.warn("No visible output area found for scroll anchor"),null}function ca(e){if(!e){P.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(Q.create(e.cellId));if(!t){P.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${de.outputArea}`)){P.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function _e(){let e=(0,ra.c)(2),t=N(ke),i;return e[0]===t?i=e[1]:(i=()=>{let o=da();t(l=>({mode:Ht(l.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{ca(o)})})},e[0]=t,e[1]=i),i}const Ae=Te(!1);var ha=W();const pa=()=>{let e=(0,ha.c)(7),{selectedLayout:t}=he(),{setLayoutView:i}=pe();if(ce()&&!Ke("wasm_layouts"))return null;let o;e[0]===i?o=e[1]:(o=n=>i(n),e[0]=i,e[1]=o);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(pt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(rt,{placeholder:"Select a view"})}),e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(ct,{children:(0,a.jsxs)(ht,{children:[(0,a.jsx)(st,{children:"View as"}),we.map(ua)]})}),e[3]=r):r=e[3];let s;return e[4]!==t||e[5]!==o?(s=(0,a.jsxs)(mt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[l,r]}),e[4]=t,e[5]=o,e[6]=s):s=e[6],s};function ma(e){return(0,a.jsx)(Se(e),{className:"h-4 w-4"})}function Se(e){switch(e){case"vertical":return aa;case"grid":return Mt;case"slides":return ze;default:return Qe(e),It}}function Ne(e){return se(e)}function ua(e){return(0,a.jsx)(dt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[ma(e),(0,a.jsx)("span",{children:Ne(e)})]})},e)}var fa=W();function ya(e){let t=(0,fa.c)(5),{openPrompt:i,closeModal:o}=Z(),{sendCopy:l}=E(),r;return t[0]!==o||t[1]!==i||t[2]!==l||t[3]!==e?(r=()=>{if(!e)return null;let s=Ve.guessDeliminator(e);i({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${ne.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:n=>{let d=s.join(ne.dirname(e),n);l({source:e,destination:d}).then(()=>{o(),j({title:"Notebook copied",description:"A copy of the notebook has been created."}),Kt(d)})}})},t[0]=o,t[1]=i,t[2]=l,t[3]=e,t[4]=r):r=t[4],r}const ba=()=>{let{updateCellConfig:e}=ie(),{saveCellConfig:t}=E();return(0,ee.useCallback)(async()=>{let i=new qe,o=le(),l=o.cellIds.inOrderIds,r={};for(let n of l){if(o.cellData[n]===void 0)continue;let{code:d,config:p}=o.cellData[n];p.hide_code||i.isSupported(d)&&(r[n]={hide_code:!0})}let s=re.entries(r);if(s.length!==0){await t({configs:r});for(let[n,d]of s)e({cellId:n,config:d})}},[e])};var ka=W();function Pe(){let e=(0,ka.c)(4),{openConfirm:t}=Z(),i=N(at),{sendRestart:o}=E(),l;return e[0]!==t||e[1]!==o||e[2]!==i?(l=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(qt,{onClick:async()=>{i({state:tt.CLOSING}),await o(),Yt()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=i,e[3]=l):l=e[3],l}var xa=W(),D=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function wa(){var te,ae;let e=(0,xa.c)(36),t=Gt(),{openModal:i,closeModal:o}=Z(),{toggleApplication:l}=$e(),{selectedPanel:r}=Ue(),[s]=Ie(ke),n=K(Lt),d=ba(),[p]=Ze(),{updateCellConfig:x,undoDeleteCell:w,clearAllCellOutputs:m,addSetupCellIfDoesntExist:u,collapseAllCells:f,expandAllCells:y}=ie(),b=Pe(),k=Ft(),g=ya(t),v=N(Ae),A=N(xt),z=N(kt),{exportAsMarkdown:O,readCode:S,saveCellConfig:U}=E(),Y=K(Ye),$=K(Je),{selectedLayout:F}=he(),{setLayoutView:G}=pe(),I=_e(),T=((te=p.sharing)==null?void 0:te.html)??!0,H=((ae=p.sharing)==null?void 0:ae.wasm)??!0,Ee=La,L;e[0]===Symbol.for("react.memo_cache_sentinel")?(L=(0,a.jsx)(wt,{size:14,strokeWidth:1.5}),e[0]=L):L=e[0];let q;e[1]===Symbol.for("react.memo_cache_sentinel")?(q=(0,a.jsx)(me,{size:14,strokeWidth:1.5}),e[1]=q):q=e[1];let M;e[2]===t?M=e[3]:(M=async()=>{if(!t){j({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."});return}await ue({filename:t,includeCode:!0})},e[2]=t,e[3]=M);let R;return e[4]!==u||e[5]!==$||e[6]!==m||e[7]!==o||e[8]!==f||e[9]!==g||e[10]!==y||e[11]!==O||e[12]!==t||e[13]!==Y||e[14]!==d||e[15]!==n||e[16]!==i||e[17]!==S||e[18]!==b||e[19]!==k||e[20]!==U||e[21]!==F||e[22]!==r||e[23]!==v||e[24]!==z||e[25]!==G||e[26]!==A||e[27]!==T||e[28]!==H||e[29]!==M||e[30]!==l||e[31]!==I||e[32]!==w||e[33]!==x||e[34]!==s.mode?(R=[{icon:L,label:"Download",handle:D,dropdown:[{icon:q,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(me,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){j({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."});return}await ue({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(Jt,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let h=await O({download:!1});be(new Blob([h],{type:"text/plain"}),ye.toMarkdown(document.title))}},{icon:(0,a.jsx)(lt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let h=await S();be(new Blob([h.contents],{type:"text/plain"}),ye.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(St,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:s.mode!=="present",tooltip:s.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",xe("global.hideCode",!1)]}),handle:Ha},{icon:(0,a.jsx)(vt,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:s.mode!=="present",tooltip:s.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",xe("global.hideCode",!1)]}),handle:Ia}]},{icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"Share",handle:D,hidden:!T&&!H,dropdown:[{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!T,handle:async()=>{i((0,a.jsx)(la,{onClose:o}))}},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!H,handle:async()=>{await V($t({code:(await S()).contents})),j({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:D,dropdown:Ge.flatMap(h=>{let{type:C,Icon:J,hidden:De}=h;return De?[]:{label:se(C),rightElement:Ee(r===C),icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),handle:()=>l(C)}})},{icon:(0,a.jsx)(ze,{size:14,strokeWidth:1.5}),label:"Present as",handle:D,dropdown:[{icon:s.mode==="present"?(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ce,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{I()}},...we.map((h,C)=>{let J=Se(h);return{divider:C===0,label:Ne(h),icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:F===h&&(0,a.jsx)(fe,{size:14})}),handle:()=>{G(h),s.mode==="edit"&&I()}}})]},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ce(),handle:g},{icon:(0,a.jsx)(ge,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await V((await S()).contents),j({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(yt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!Y||n,handle:async()=>{let h=Fe(le());await U({configs:re.fromEntries(h.map(Da))});for(let C of h)x({cellId:C,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(ve,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{u({})}},{icon:(0,a.jsx)(Le,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{i((0,a.jsx)(Xe,{onClose:o}))}},{icon:(0,a.jsx)(Me,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!$||n,handle:()=>{w()}},{icon:(0,a.jsx)(na,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b},{icon:(0,a.jsx)(Zt,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)(Oe,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{m()}},{icon:(0,a.jsx)(gt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(Xt,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:f,redundant:!0},{icon:(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(je,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ea)},{icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Pa)},{icon:(0,a.jsx)(Et,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>A(Na),redundant:!0},{icon:(0,a.jsx)(ft,{size:14,strokeWidth:1.5}),label:"Resources",handle:D,dropdown:[{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Sa},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Aa},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:_a},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Wa},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ma}]},{divider:!0,icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:za},{icon:(0,a.jsx)(jt,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ca}].filter(va).map(ga),e[4]=u,e[5]=$,e[6]=m,e[7]=o,e[8]=f,e[9]=g,e[10]=y,e[11]=O,e[12]=t,e[13]=Y,e[14]=d,e[15]=n,e[16]=i,e[17]=S,e[18]=b,e[19]=k,e[20]=U,e[21]=F,e[22]=r,e[23]=v,e[24]=z,e[25]=G,e[26]=A,e[27]=T,e[28]=H,e[29]=M,e[30]=l,e[31]=I,e[32]=w,e[33]=x,e[34]=s.mode,e[35]=R):R=e[35],R}function ga(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(ja)}:e}function ja(e){return!e.hidden}function va(e){return!e.hidden}function Ca(){let e=et();window.open(e,"_blank")}function za(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ma(){window.open(_.releasesPage,"_blank")}function Wa(){window.open(_.youtube,"_blank")}function _a(){window.open(_.discordLink,"_blank")}function Aa(){window.open(_.githubPage,"_blank")}function Sa(){window.open(_.docsPage,"_blank")}function Na(e){return!e}function Pa(e){return!e}function Ea(e){return!e}function Da(e){return[e,{disabled:!1}]}async function Ia(){let e=new Event("export-beforeprint"),t=new Event("export-afterprint");(function(){window.dispatchEvent(e),setTimeout(Ta,0),setTimeout(()=>window.dispatchEvent(t),0)})()}function Ta(){return window.print()}async function Ha(){let e=document.getElementById("App");e&&await ut(e,document.title)}function La(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(fe,{size:14})})}export{_e as a,ve as c,Ae as i,je as l,Pe as n,Me as o,pa as r,Ce as s,wa as t,ge as u};
|
|
1
|
+
import{s as oe}from"./chunk-LvLJmgfZ.js";import{d as N,l as Ie,p as Te,u as K}from"./useEvent-DlWF5OMa.js";import{t as He}from"./react-BGmjiNul.js";import{Bn as Le,C as ie,Et as qe,Jn as Re,Nt as Ve,Pt as ne,Rn as Be,Un as Oe,an as Ue,ei as Q,h as Ye,in as $e,mr as Fe,on as Ge,p as le,t as Je,un as Ke}from"./cells-CibeVr5R.js";import{t as W}from"./compiler-runtime-DeeZ7FnK.js";import{i as Qe}from"./useLifecycle-CmDXEyIC.js";import{a as se}from"./type-BdyvjzTI.js";import{n as Xe}from"./add-database-form-hxk-QlNU.js";import{a as re,d as P}from"./hotkeys-uKX61F1_.js";import{v as Ze}from"./utils-CJJIceVn.js";import{n as _,t as de}from"./constants-Bkp4R3bQ.js";import{M as ce,f as et,j as tt,w as at}from"./config-Ba3eeYri.js";import{t as ot}from"./jsx-runtime-DN_bIXfG.js";import{r as it,t as X}from"./button-DuYGqRtX.js";import{r as E}from"./requests-C0HaHO6a.js";import{t as c}from"./createLucideIcon-CW2xpJ57.js";import{a as he,f as nt,i as pe,m as lt,p as me,u as ue}from"./layout-HXw-kbRR.js";import{t as fe}from"./check-CrAQug3q.js";import{a as st,c as rt,i as dt,n as ct,r as ht,s as pt,t as mt}from"./select-D0g5GnIs.js";import{i as ye,r as ut,t as be}from"./download-Bd63S7ca.js";import{f as ft}from"./maps-s2pQkyf5.js";import{r as yt}from"./useCellActionButton-BPZZpi7i.js";import{t as bt}from"./copy-gBVL4NN-.js";import{d as kt,t as xt}from"./state-BxWZf58F.js";import{t as wt}from"./download-DobaYJPt.js";import{t as gt}from"./eye-off-D9zAYqG9.js";import{t as jt}from"./file-plus-corner-BO_uS88s.js";import{t as vt}from"./file-BnFXtaZZ.js";import{i as Ct,n as zt,r as Mt,t as Wt}from"./youtube-BJQRl2JC.js";import{n as _t,t as At}from"./house-CncUa_LL.js";import{n as St}from"./play-BJDBXApx.js";import{t as Nt}from"./link-54sBkoQp.js";import{r as Pt}from"./input-CaEtLL8p.js";import{t as Et}from"./settings-MTlHVxz3.js";import{y as Dt}from"./textarea-BRmAhRr_.js";import{t as It}from"./square-leQTJTJJ.js";import{t as j}from"./use-toast-Bzf3rpev.js";import{t as Tt}from"./tooltip-CvjcEpZC.js";import{a as ke,i as Ht,r as Lt}from"./mode-j1jRJgw_.js";import{o as qt}from"./alert-dialog-k5KxevGr.js";import{a as Rt,c as Vt,i as Bt,n as Ot,r as Ut}from"./dialog-DUEuLcT2.js";import{n as Z}from"./ImperativeModal-q6QlC2aZ.js";import{r as Yt,t as $t}from"./share-CXQVxivL.js";import{t as V}from"./copy-DRhpWiOq.js";import{r as Ft}from"./useRunCells-d0gYuXYQ.js";import{a as Gt}from"./cell-link-T1P92ttw.js";import{a as xe}from"./renderShortcut-D0Pei-OA.js";import{t as Jt}from"./icons-D4lB4En9.js";import{t as Kt}from"./links-Bpd4gqTj.js";import{t as we}from"./types-BLEgJ92v.js";var Qt=c("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Xt=c("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),ge=c("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"}]]),je=c("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"}]]),ve=c("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"}]]),Zt=c("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"}]]),ea=c("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["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"}]]),ta=c("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"}]]),Ce=c("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"}]]),aa=c("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),oa=c("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),ze=c("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"}]]),ia=c("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"}]]),na=c("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"}]]),Me=c("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"}]]),We=W(),ee=oe(He(),1),a=oe(ot(),1),B="https://static.marimo.app";const la=e=>{let t=(0,We.c)(25),{onClose:i}=e,[o,l]=(0,ee.useState)(""),{exportAsHTML:r}=E(),s=`${o}-${Math.random().toString(36).slice(2,6)}`,n=`${B}/static/${s}`,d;t[0]!==r||t[1]!==i||t[2]!==s?(d=async v=>{v.preventDefault(),i();let A=await r({download:!1,includeCode:!0,files:nt.INSTANCE.filenames()}),z=j({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${B}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:A,path:s})}).catch(()=>{z.dismiss(),j({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:_.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),j({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=i,t[2]=s,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(Vt,{children:"Share static notebook"}),t[4]=p):p=t[4];let x;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=(0,a.jsxs)(Rt,{children:[p,(0,a.jsxs)(Ut,{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"," ",(0,a.jsx)("a",{href:B,target:"_blank",children:B}),"."]})]}),t[5]=x):x=t[5];let w;t[6]===Symbol.for("react.memo_cache_sentinel")?(w=v=>{l(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=w):w=t[6];let m;t[7]===o?m=t[8]:(m=(0,a.jsx)(Pt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:w,required:!0,autoComplete:"off"}),t[7]=o,t[8]=m);let u;t[9]===n?u=t[10]:(u=(0,a.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:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(sa,{text:n}),(0,a.jsx)("span",{className:"text-primary",children:n})]})]}),t[9]=n,t[10]=u);let f;t[11]!==m||t[12]!==u?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[m,u]}),t[11]=m,t[12]=u,t[13]=f):f=t[13];let y;t[14]===i?y=t[15]:(y=(0,a.jsx)(X,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:i,children:"Cancel"}),t[14]=i,t[15]=y);let b;t[16]===n?b=t[17]:(b=(0,a.jsx)(X,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await V(n)},children:"Create"}),t[16]=n,t[17]=b);let k;t[18]!==y||t[19]!==b?(k=(0,a.jsxs)(Bt,{children:[y,b]}),t[18]=y,t[19]=b,t[20]=k):k=t[20];let g;return t[21]!==d||t[22]!==k||t[23]!==f?(g=(0,a.jsx)(Ot,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[x,f,k]})}),t[21]=d,t[22]=k,t[23]=f,t[24]=g):g=t[24],g};var sa=e=>{let t=(0,We.c)(8),[i,o]=ee.useState(!1),l;t[0]===e.text?l=t[1]:(l=it.stopPropagation(async p=>{p.preventDefault(),await V(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=l);let r=l,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(bt,{size:14,strokeWidth:1.5}),t[2]=s):s=t[2];let n;t[3]===r?n=t[4]:(n=(0,a.jsx)(X,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:s}),t[3]=r,t[4]=n);let d;return t[5]!==i||t[6]!==n?(d=(0,a.jsx)(Tt,{content:"Copied!",open:i,children:n}),t[5]=i,t[6]=n,t[7]=d):d=t[7],d},ra=W();function da(){let e=document.getElementsByClassName(de.outputArea);for(let t of e){let i=t.getBoundingClientRect();if(i.bottom>0&&i.top<window.innerHeight){let o=Q.findElement(t);if(!o){P.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:Q.parse(o.id)}}}return P.warn("No visible output area found for scroll anchor"),null}function ca(e){if(!e){P.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(Q.create(e.cellId));if(!t){P.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${de.outputArea}`)){P.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function _e(){let e=(0,ra.c)(2),t=N(ke),i;return e[0]===t?i=e[1]:(i=()=>{let o=da();t(l=>({mode:Ht(l.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{ca(o)})})},e[0]=t,e[1]=i),i}const Ae=Te(!1);var ha=W();const pa=()=>{let e=(0,ha.c)(7),{selectedLayout:t}=he(),{setLayoutView:i}=pe();if(ce()&&!Ke("wasm_layouts"))return null;let o;e[0]===i?o=e[1]:(o=n=>i(n),e[0]=i,e[1]=o);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(pt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(rt,{placeholder:"Select a view"})}),e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(ct,{children:(0,a.jsxs)(ht,{children:[(0,a.jsx)(st,{children:"View as"}),we.map(ua)]})}),e[3]=r):r=e[3];let s;return e[4]!==t||e[5]!==o?(s=(0,a.jsxs)(mt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[l,r]}),e[4]=t,e[5]=o,e[6]=s):s=e[6],s};function ma(e){return(0,a.jsx)(Se(e),{className:"h-4 w-4"})}function Se(e){switch(e){case"vertical":return aa;case"grid":return Mt;case"slides":return ze;default:return Qe(e),It}}function Ne(e){return se(e)}function ua(e){return(0,a.jsx)(dt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[ma(e),(0,a.jsx)("span",{children:Ne(e)})]})},e)}var fa=W();function ya(e){let t=(0,fa.c)(5),{openPrompt:i,closeModal:o}=Z(),{sendCopy:l}=E(),r;return t[0]!==o||t[1]!==i||t[2]!==l||t[3]!==e?(r=()=>{if(!e)return null;let s=Ve.guessDeliminator(e);i({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${ne.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:n=>{let d=s.join(ne.dirname(e),n);l({source:e,destination:d}).then(()=>{o(),j({title:"Notebook copied",description:"A copy of the notebook has been created."}),Kt(d)})}})},t[0]=o,t[1]=i,t[2]=l,t[3]=e,t[4]=r):r=t[4],r}const ba=()=>{let{updateCellConfig:e}=ie(),{saveCellConfig:t}=E();return(0,ee.useCallback)(async()=>{let i=new qe,o=le(),l=o.cellIds.inOrderIds,r={};for(let n of l){if(o.cellData[n]===void 0)continue;let{code:d,config:p}=o.cellData[n];p.hide_code||i.isSupported(d)&&(r[n]={hide_code:!0})}let s=re.entries(r);if(s.length!==0){await t({configs:r});for(let[n,d]of s)e({cellId:n,config:d})}},[e])};var ka=W();function Pe(){let e=(0,ka.c)(4),{openConfirm:t}=Z(),i=N(at),{sendRestart:o}=E(),l;return e[0]!==t||e[1]!==o||e[2]!==i?(l=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(qt,{onClick:async()=>{i({state:tt.CLOSING}),await o(),Yt()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=i,e[3]=l):l=e[3],l}var xa=W(),D=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function wa(){var te,ae;let e=(0,xa.c)(36),t=Gt(),{openModal:i,closeModal:o}=Z(),{toggleApplication:l}=$e(),{selectedPanel:r}=Ue(),[s]=Ie(ke),n=K(Lt),d=ba(),[p]=Ze(),{updateCellConfig:x,undoDeleteCell:w,clearAllCellOutputs:m,addSetupCellIfDoesntExist:u,collapseAllCells:f,expandAllCells:y}=ie(),b=Pe(),k=Ft(),g=ya(t),v=N(Ae),A=N(xt),z=N(kt),{exportAsMarkdown:O,readCode:S,saveCellConfig:U}=E(),Y=K(Ye),$=K(Je),{selectedLayout:F}=he(),{setLayoutView:G}=pe(),I=_e(),T=((te=p.sharing)==null?void 0:te.html)??!0,H=((ae=p.sharing)==null?void 0:ae.wasm)??!0,Ee=La,L;e[0]===Symbol.for("react.memo_cache_sentinel")?(L=(0,a.jsx)(wt,{size:14,strokeWidth:1.5}),e[0]=L):L=e[0];let q;e[1]===Symbol.for("react.memo_cache_sentinel")?(q=(0,a.jsx)(me,{size:14,strokeWidth:1.5}),e[1]=q):q=e[1];let M;e[2]===t?M=e[3]:(M=async()=>{if(!t){j({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."});return}await ue({filename:t,includeCode:!0})},e[2]=t,e[3]=M);let R;return e[4]!==u||e[5]!==$||e[6]!==m||e[7]!==o||e[8]!==f||e[9]!==g||e[10]!==y||e[11]!==O||e[12]!==t||e[13]!==Y||e[14]!==d||e[15]!==n||e[16]!==i||e[17]!==S||e[18]!==b||e[19]!==k||e[20]!==U||e[21]!==F||e[22]!==r||e[23]!==v||e[24]!==z||e[25]!==G||e[26]!==A||e[27]!==T||e[28]!==H||e[29]!==M||e[30]!==l||e[31]!==I||e[32]!==w||e[33]!==x||e[34]!==s.mode?(R=[{icon:L,label:"Download",handle:D,dropdown:[{icon:q,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(me,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){j({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."});return}await ue({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(Jt,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let h=await O({download:!1});be(new Blob([h],{type:"text/plain"}),ye.toMarkdown(document.title))}},{icon:(0,a.jsx)(lt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let h=await S();be(new Blob([h.contents],{type:"text/plain"}),ye.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(St,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:s.mode!=="present",tooltip:s.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",xe("global.hideCode",!1)]}),handle:Ha},{icon:(0,a.jsx)(vt,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:s.mode!=="present",tooltip:s.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",xe("global.hideCode",!1)]}),handle:Ia}]},{icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"Share",handle:D,hidden:!T&&!H,dropdown:[{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!T,handle:async()=>{i((0,a.jsx)(la,{onClose:o}))}},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!H,handle:async()=>{await V($t({code:(await S()).contents})),j({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:D,dropdown:Ge.flatMap(h=>{let{type:C,Icon:J,hidden:De}=h;return De?[]:{label:se(C),rightElement:Ee(r===C),icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),handle:()=>l(C)}})},{icon:(0,a.jsx)(ze,{size:14,strokeWidth:1.5}),label:"Present as",handle:D,dropdown:[{icon:s.mode==="present"?(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ce,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{I()}},...we.map((h,C)=>{let J=Se(h);return{divider:C===0,label:Ne(h),icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:F===h&&(0,a.jsx)(fe,{size:14})}),handle:()=>{G(h),s.mode==="edit"&&I()}}})]},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ce(),handle:g},{icon:(0,a.jsx)(ge,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await V((await S()).contents),j({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(yt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!Y||n,handle:async()=>{let h=Fe(le());await U({configs:re.fromEntries(h.map(Da))});for(let C of h)x({cellId:C,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(ve,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{u({})}},{icon:(0,a.jsx)(Le,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{i((0,a.jsx)(Xe,{onClose:o}))}},{icon:(0,a.jsx)(Me,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!$||n,handle:()=>{w()}},{icon:(0,a.jsx)(na,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b},{icon:(0,a.jsx)(Zt,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)(Oe,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{m()}},{icon:(0,a.jsx)(gt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(Xt,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:f,redundant:!0},{icon:(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(je,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ea)},{icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Pa)},{icon:(0,a.jsx)(Et,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>A(Na),redundant:!0},{icon:(0,a.jsx)(ft,{size:14,strokeWidth:1.5}),label:"Resources",handle:D,dropdown:[{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Sa},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Aa},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:_a},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Wa},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ma}]},{divider:!0,icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:za},{icon:(0,a.jsx)(jt,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ca}].filter(va).map(ga),e[4]=u,e[5]=$,e[6]=m,e[7]=o,e[8]=f,e[9]=g,e[10]=y,e[11]=O,e[12]=t,e[13]=Y,e[14]=d,e[15]=n,e[16]=i,e[17]=S,e[18]=b,e[19]=k,e[20]=U,e[21]=F,e[22]=r,e[23]=v,e[24]=z,e[25]=G,e[26]=A,e[27]=T,e[28]=H,e[29]=M,e[30]=l,e[31]=I,e[32]=w,e[33]=x,e[34]=s.mode,e[35]=R):R=e[35],R}function ga(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(ja)}:e}function ja(e){return!e.hidden}function va(e){return!e.hidden}function Ca(){let e=et();window.open(e,"_blank")}function za(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ma(){window.open(_.releasesPage,"_blank")}function Wa(){window.open(_.youtube,"_blank")}function _a(){window.open(_.discordLink,"_blank")}function Aa(){window.open(_.githubPage,"_blank")}function Sa(){window.open(_.docsPage,"_blank")}function Na(e){return!e}function Pa(e){return!e}function Ea(e){return!e}function Da(e){return[e,{disabled:!1}]}async function Ia(){let e=new Event("export-beforeprint"),t=new Event("export-afterprint");(function(){window.dispatchEvent(e),setTimeout(Ta,0),setTimeout(()=>window.dispatchEvent(t),0)})()}function Ta(){return window.print()}async function Ha(){let e=document.getElementById("App");e&&await ut(e,document.title)}function La(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(fe,{size:14})})}export{_e as a,ve as c,Ae as i,je as l,Pe as n,Me as o,pa as r,Ce as s,wa as t,ge as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as g,n as i,p as k}from"./useEvent-DlWF5OMa.js";import{C as v,_n as w,hr as F,p as f,rt as b,yr as _}from"./cells-
|
|
1
|
+
import{d as g,n as i,p as k}from"./useEvent-DlWF5OMa.js";import{C as v,_n as w,hr as F,p as f,rt as b,yr as _}from"./cells-CibeVr5R.js";import{t as x}from"./compiler-runtime-DeeZ7FnK.js";import{d as C}from"./hotkeys-uKX61F1_.js";import{o as D}from"./dist-DKNOF5xd.js";import{r as H}from"./requests-C0HaHO6a.js";var u=x();const y=k(!1);function V(){let r=(0,u.c)(2),n=p(),t;return r[0]===n?t=r[1]:(t=()=>n(_(f())),r[0]=n,r[1]=t),i(t)}function j(r){let n=(0,u.c)(3),t=p(),e;return n[0]!==r||n[1]!==t?(e=()=>{r!==void 0&&t([r])},n[0]=r,n[1]=t,n[2]=e):e=n[2],i(e)}function q(){let r=(0,u.c)(2),n=p(),t;return r[0]===n?t=r[1]:(t=()=>n(F(f())),r[0]=n,r[1]=t),i(t)}function p(){let r=(0,u.c)(4),{prepareForRun:n}=v(),{sendRun:t}=H(),e=g(y),o;return r[0]!==n||r[1]!==t||r[2]!==e?(o=async s=>{if(s.length===0)return;let c=f();return e(!0),I({cellIds:s,sendRun:t,prepareForRun:n,notebook:c})},r[0]=n,r[1]=t,r[2]=e,r[3]=o):o=r[3],i(o)}async function I({cellIds:r,sendRun:n,prepareForRun:t,notebook:e}){var m,h,R;if(r.length===0)return;let{cellHandles:o,cellData:s}=e,c=[];for(let a of r){let l=(h=(m=o[a])==null?void 0:m.current)==null?void 0:h.editorView,d;l?(w(l)!=="markdown"&&D(l),d=b(l)):d=((R=s[a])==null?void 0:R.code)||"",c.push(d),t({cellId:a})}await n({cellIds:r,codes:c}).catch(a=>{C.error(a)})}export{p as a,j as i,I as n,V as o,q as r,y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as m}from"./chunk-LvLJmgfZ.js";import{n as p}from"./useEvent-DlWF5OMa.js";import{C as d,d as f,rt as u}from"./cells-
|
|
1
|
+
import{s as m}from"./chunk-LvLJmgfZ.js";import{n as p}from"./useEvent-DlWF5OMa.js";import{C as d,d as f,rt as u}from"./cells-CibeVr5R.js";import{t as c}from"./compiler-runtime-DeeZ7FnK.js";import{t as C}from"./jsx-runtime-DN_bIXfG.js";import{t as h}from"./use-toast-Bzf3rpev.js";import{r as v}from"./useDeleteCell-BIkFVvVx.js";var x=c(),b=m(C(),1);function j(){let t=(0,x.c)(3),{splitCell:r,undoSplitCell:i}=d(),o;return t[0]!==r||t[1]!==i?(o=s=>{let l=f(s.cellId);if(!l)return;let a=u(l);r(s);let{dismiss:n}=h({title:"Cell split",action:(0,b.jsx)(v,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{i({...s,snapshot:a}),e()},children:"Undo"})}),e=n},t[0]=r,t[1]=i,t[2]=o):o=t[2],p(o)}export{j as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var it=Object.defineProperty;var ot=(t,e,n)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var a=(t,e,n)=>ot(t,typeof e!="symbol"?e+"":e,n);var j;import{s as ce}from"./chunk-LvLJmgfZ.js";import{i as Q,l as D,o as lt,p as q,u as ut}from"./useEvent-DlWF5OMa.js";import{t as ct}from"./react-BGmjiNul.js";import{Gr as dt,Xr as ft,Zr as z,v as mt,y as pt,zr as ht}from"./cells-DU3EySUd.js";import{B as gt,C as de,D as yt,I as bt,N as wt,P as O,R as fe,k as W,w as me}from"./zod-Cg4WLWh2.js";import{t as pe}from"./compiler-runtime-DeeZ7FnK.js";import{t as vt}from"./get-CyLJYAfP.js";import{r as xt}from"./useLifecycle-CmDXEyIC.js";import{t as Et}from"./debounce-BbFlGgjv.js";import{t as _t}from"./_baseSet-6FYvpjrm.js";import{d as E,p as y}from"./hotkeys-uKX61F1_.js";import{t as Ct}from"./invariant-C6yE60hi.js";import{x as kt}from"./utils-CJJIceVn.js";import{M as Rt}from"./config-Ba3eeYri.js";import{a as Ft}from"./switch-CWzL-0WF.js";import{n as he}from"./globals-BSLm1nlz.js";import{t as ge}from"./ErrorBoundary-Drf1manw.js";import{t as Nt}from"./jsx-runtime-DN_bIXfG.js";import{t as St}from"./button-DuYGqRtX.js";import{t as qt}from"./cn-C1rgT0yh.js";import{Z as Pt}from"./JsonOutput--AuyEErr.js";import{t as Mt}from"./createReducer-DDa-hVe3.js";import{t as ye}from"./requests-C0HaHO6a.js";import{t as be}from"./createLucideIcon-CW2xpJ57.js";import{h as jt}from"./select-D0g5GnIs.js";import{c as At,i as Tt,l as It,r as Lt,u as Ut}from"./markdown-renderer-BSrbBHwX.js";import{t as zt}from"./DeferredRequestRegistry-B3BENoUa.js";import{t as K}from"./Deferred-DzyBMRsy.js";import{t as we}from"./uuid-ClFZlR7U.js";import{t as Ot}from"./use-toast-Bzf3rpev.js";import{t as ve}from"./tooltip-CvjcEpZC.js";import{t as xe}from"./mode-yhfN-4ye.js";import{n as Wt,r as Dt,t as Ht}from"./share-CXQVxivL.js";import{r as Bt,t as Vt}from"./react-resizable-panels.browser.esm-BqxQegSf.js";import{t as Ee}from"./toggle-G1t0cQyf.js";function Xt(t,e,n){return t==null?t:_t(t,e,n)}var H=Xt,$t=be("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]),Yt=be("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function Gt(t){return{all:t||(t=new Map),on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(s){s(n)}),(r=t.get("*"))&&r.slice().map(function(s){s(e,n)})}}}var u=ce(ct(),1),Z=(0,u.createContext)(null),Qt=t=>{let{controller:e}=(0,u.useContext)(Z),n=u.useRef(Symbol("fill"));return(0,u.useEffect)(()=>(e.mount({name:t.name,ref:n.current,children:t.children}),()=>{e.unmount({name:t.name,ref:n.current})}),[]),(0,u.useEffect)(()=>{e.update({name:t.name,ref:n.current,children:t.children})}),null},Kt=Object.defineProperty,Zt=(t,e,n)=>e in t?Kt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_e=(t,e,n)=>(Zt(t,typeof e=="symbol"?e:e+"",n),n),Ce=console,Jt=class{constructor(t){_e(this,"_bus"),_e(this,"_db"),this._bus=t,this.handleFillMount=this.handleFillMount.bind(this),this.handleFillUpdated=this.handleFillUpdated.bind(this),this.handleFillUnmount=this.handleFillUnmount.bind(this),this._db={byName:new Map,byFill:new Map}}mount(){this._bus.on("fill-mount",this.handleFillMount),this._bus.on("fill-updated",this.handleFillUpdated),this._bus.on("fill-unmount",this.handleFillUnmount)}unmount(){this._bus.off("fill-mount",this.handleFillMount),this._bus.off("fill-updated",this.handleFillUpdated),this._bus.off("fill-unmount",this.handleFillUnmount)}handleFillMount({fill:t}){let e=u.Children.toArray(t.children),n=t.name,r={fill:t,children:e,name:n},s=this._db.byName.get(n);s?(s.components.push(r),s.listeners.forEach(i=>i([...s.components]))):this._db.byName.set(n,{listeners:[],components:[r]}),this._db.byFill.set(t.ref,r)}handleFillUpdated({fill:t}){let e=this._db.byFill.get(t.ref),n=u.Children.toArray(t.children);if(e){e.children=n;let r=this._db.byName.get(e.name);if(r)r.listeners.forEach(s=>s([...r.components]));else throw Error("registration was expected to be defined")}else{Ce.error("[handleFillUpdated] component was expected to be defined");return}}handleFillUnmount({fill:t}){let e=this._db.byFill.get(t.ref);if(!e){Ce.error("[handleFillUnmount] component was expected to be defined");return}let n=e.name,r=this._db.byName.get(n);if(!r)throw Error("registration was expected to be defined");r.components=r.components.filter(s=>s!==e),this._db.byFill.delete(t.ref),r.listeners.length===0&&r.components.length===0?this._db.byName.delete(n):r.listeners.forEach(s=>s([...r.components]))}onComponentsChange(t,e){let n=this._db.byName.get(t);n?(n.listeners.push(e),e(n.components)):(this._db.byName.set(t,{listeners:[e],components:[]}),e([]))}getFillsByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.fill):[]}getChildrenByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.children).reduce((n,r)=>n.concat(r),[]):[]}removeOnComponentsChange(t,e){let n=this._db.byName.get(t);if(!n)throw Error("expected registration to be defined");let r=n.listeners;r.splice(r.indexOf(e),1)}},en=Object.defineProperty,tn=(t,e,n)=>e in t?en(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,nn=(t,e,n)=>(tn(t,typeof e=="symbol"?e:e+"",n),n),ke=class{constructor(){nn(this,"bus",Gt())}mount(t){this.bus.emit("fill-mount",{fill:t})}unmount(t){this.bus.emit("fill-unmount",{fill:t})}update(t){this.bus.emit("fill-updated",{fill:t})}};function rn(t){let e=t||new ke;return{controller:e,manager:new Jt(e.bus)}}var sn=({controller:t,children:e})=>{let[n]=u.useState(()=>{let r=rn(t);return r.manager.mount(),r});return u.useEffect(()=>()=>{n.manager.unmount()},[]),u.createElement(Z.Provider,{value:n},e)};function J(t,e){let[n,r]=(0,u.useState)([]),{manager:s}=(0,u.useContext)(Z);return(0,u.useEffect)(()=>(s.onComponentsChange(t,r),()=>{s.removeOnComponentsChange(t,r)}),[t]),n.flatMap((i,d)=>{let{children:l}=i;return l.map((p,b)=>{if(typeof p=="number"||typeof p=="string")throw Error("Only element children will work here");return u.cloneElement(p,{key:d.toString()+b.toString(),...e})})})}var Re=t=>{let e=J(t.name,t.childProps);if(typeof t.children=="function"){let n=t.children(e);if(u.isValidElement(n)||n===null)return n;throw Error("Slot rendered with function must return a valid React Element.")}return e};const an=q(null);var{valueAtom:on,useActions:ln}=Mt(()=>({banners:[]}),{addBanner:(t,e)=>({...t,banners:[...t.banners,{...e,id:we()}]}),removeBanner:(t,e)=>({...t,banners:t.banners.filter(n=>n.id!==e)}),clearBanners:t=>({...t,banners:[]})});const un=()=>ut(on);function cn(){return ln()}const dn=new ke,B={SIDEBAR:"sidebar",CONTEXT_AWARE_PANEL:"context-aware-panel"};var fn=class{constructor(){a(this,"subscriptions",new Map)}addSubscription(t,e){var n;this.subscriptions.has(t)||this.subscriptions.set(t,new Set),(n=this.subscriptions.get(t))==null||n.add(e)}removeSubscription(t,e){var n;(n=this.subscriptions.get(t))==null||n.delete(e)}notify(t,e){for(let n of this.subscriptions.get(t)??[])n(e)}},Fe=class ue{constructor(e){a(this,"subscriptions",new fn);this.producer=e}static withProducerCallback(e){return new ue(e)}static empty(){return new ue}startProducer(){this.producer&&this.producer(e=>{this.subscriptions.notify("message",e)})}connect(){return new Promise(e=>setTimeout(e,0)).then(()=>{this.subscriptions.notify("open",new Event("open"))})}get readyState(){return WebSocket.OPEN}reconnect(e,n){this.close(),this.connect()}close(){this.subscriptions.notify("close",new Event("close"))}send(e){return this.subscriptions.notify("message",new MessageEvent("message",{data:e})),Promise.resolve()}addEventListener(e,n){this.subscriptions.addSubscription(e,n),e==="open"&&n(new Event("open")),e==="message"&&this.startProducer()}removeEventListener(e,n){this.subscriptions.removeSubscription(e,n)}},mn=1e10,pn=1e3;function V(t,e){let n=t.map(r=>`"${r}"`).join(", ");return Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${n}`)}function hn(t={}){let e={};function n(o){e=o}let r={};function s(o){var f;r.unregisterHandler&&r.unregisterHandler(),r=o,(f=r.registerHandler)==null||f.call(r,U)}let i;function d(o){if(typeof o=="function"){i=o;return}i=(f,g)=>{let c=o[f];if(c)return c(g);let h=o._;if(!h)throw Error(`The requested method has no handler: ${f}`);return h(f,g)}}let{maxRequestTime:l=pn}=t;t.transport&&s(t.transport),t.requestHandler&&d(t.requestHandler),t._debugHooks&&n(t._debugHooks);let p=0;function b(){return p<=mn?++p:p=0}let x=new Map,w=new Map;function _(o,...f){let g=f[0];return new Promise((c,h)=>{var T;if(!r.send)throw V(["send"],"make requests");let S=b(),M={type:"request",id:S,method:o,params:g};x.set(S,{resolve:c,reject:h}),l!==1/0&&w.set(S,setTimeout(()=>{w.delete(S),h(Error("RPC request timed out."))},l)),(T=e.onSend)==null||T.call(e,M),r.send(M)})}let F=new Proxy(_,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>_(f,c)}),C=F;function k(o,...f){var h;let g=f[0];if(!r.send)throw V(["send"],"send messages");let c={type:"message",id:o,payload:g};(h=e.onSend)==null||h.call(e,c),r.send(c)}let R=new Proxy(k,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>k(f,c)}),v=R,N=new Map,P=new Set;function A(o,f){var g;if(!r.registerHandler)throw V(["registerHandler"],"register message listeners");if(o==="*"){P.add(f);return}N.has(o)||N.set(o,new Set),(g=N.get(o))==null||g.add(f)}function L(o,f){var g,c;if(o==="*"){P.delete(f);return}(g=N.get(o))==null||g.delete(f),((c=N.get(o))==null?void 0:c.size)===0&&N.delete(o)}async function U(o){var f,g;if((f=e.onReceive)==null||f.call(e,o),!("type"in o))throw Error("Message does not contain a type.");if(o.type==="request"){if(!r.send||!i)throw V(["send","requestHandler"],"handle requests");let{id:c,method:h,params:S}=o,M;try{M={type:"response",id:c,success:!0,payload:await i(h,S)}}catch(T){if(!(T instanceof Error))throw T;M={type:"response",id:c,success:!1,error:T.message}}(g=e.onSend)==null||g.call(e,M),r.send(M);return}if(o.type==="response"){let c=w.get(o.id);c!=null&&clearTimeout(c);let{resolve:h,reject:S}=x.get(o.id)??{};o.success?h==null||h(o.payload):S==null||S(Error(o.error));return}if(o.type==="message"){for(let h of P)h(o.id,o.payload);let c=N.get(o.id);if(!c)return;for(let h of c)h(o.payload);return}throw Error(`Unexpected RPC message type: ${o.type}`)}return{setTransport:s,setRequestHandler:d,request:F,requestProxy:C,send:R,sendProxy:v,addMessageListener:A,removeMessageListener:L,proxy:{send:v,request:C},_setDebugHooks:n}}function gn(t){return hn(t)}var Ne="[transport-id]";function yn(t,e){let{transportId:n}=e;return n==null?t:{[Ne]:n,data:t}}function bn(t,e){let{transportId:n,filter:r}=e,s=r==null?void 0:r();if(n!=null&&s!=null)throw Error("Cannot use both `transportId` and `filter` at the same time");let i=t;if(n){if(t[Ne]!==n)return[!0];i=t.data}return s===!1?[!0]:[!1,i]}function wn(t,e={}){let{transportId:n,filter:r,remotePort:s}=e,i=t,d=s??t,l;return{send(p){d.postMessage(yn(p,{transportId:n}))},registerHandler(p){l=b=>{let x=b.data,[w,_]=bn(x,{transportId:n,filter:()=>r==null?void 0:r(b)});w||p(_)},i.addEventListener("message",l)},unregisterHandler(){l&&i.removeEventListener("message",l)}}}function vn(t,e){return wn(t,e)}function Se(t){return gn({transport:vn(t,{transportId:"marimo-transport"}),maxRequestTime:2e4,_debugHooks:{onSend:e=>{E.debug("[rpc] Parent -> Worker",e)},onReceive:e=>{E.debug("[rpc] Worker -> Parent",e)}}})}const qe=q("Initializing..."),xn=q(t=>{let e=t(mt),n=Object.values(e.cellRuntime);return n.some(r=>!Ut(r.output))?!0:n.every(r=>r.status==="idle")});var Pe=Wt(),Me="marimo:file",je=new ht(null);const En={saveFile(t){je.set(Me,t)},readFile(){return je.get(Me)}};var _n={saveFile(t){z.setCodeForHash((0,Pe.compressToEncodedURIComponent)(t))},readFile(){let t=z.getCodeFromHash()||z.getCodeFromSearchParam();return t?(0,Pe.decompressFromEncodedURIComponent)(t):null}};const Cn={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var kn={saveFile(t){},readFile(){if(window.location.hostname!=="marimo.app")return null;let t=new URL("files/wasm-intro.py",document.baseURI);return fetch(t.toString()).then(e=>e.ok?e.text():null).catch(()=>null)}},Rn={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
|
|
1
|
+
var it=Object.defineProperty;var ot=(t,e,n)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var a=(t,e,n)=>ot(t,typeof e!="symbol"?e+"":e,n);var j;import{s as ce}from"./chunk-LvLJmgfZ.js";import{i as Q,l as D,o as lt,p as q,u as ut}from"./useEvent-DlWF5OMa.js";import{t as ct}from"./react-BGmjiNul.js";import{Gr as dt,Xr as ft,Zr as z,v as mt,y as pt,zr as ht}from"./cells-CibeVr5R.js";import{B as gt,C as de,D as yt,I as bt,N as wt,P as O,R as fe,k as W,w as me}from"./zod-Cg4WLWh2.js";import{t as pe}from"./compiler-runtime-DeeZ7FnK.js";import{t as vt}from"./get-CyLJYAfP.js";import{r as xt}from"./useLifecycle-CmDXEyIC.js";import{t as Et}from"./debounce-BbFlGgjv.js";import{t as _t}from"./_baseSet-6FYvpjrm.js";import{d as E,p as y}from"./hotkeys-uKX61F1_.js";import{t as Ct}from"./invariant-C6yE60hi.js";import{x as kt}from"./utils-CJJIceVn.js";import{M as Rt}from"./config-Ba3eeYri.js";import{a as Ft}from"./switch-Bf7BdNuP.js";import{n as he}from"./globals-BkITdONE.js";import{t as ge}from"./ErrorBoundary-Drf1manw.js";import{t as Nt}from"./jsx-runtime-DN_bIXfG.js";import{t as St}from"./button-DuYGqRtX.js";import{t as qt}from"./cn-C1rgT0yh.js";import{Z as Pt}from"./JsonOutput-B64aMW9B.js";import{t as Mt}from"./createReducer-DDa-hVe3.js";import{t as ye}from"./requests-C0HaHO6a.js";import{t as be}from"./createLucideIcon-CW2xpJ57.js";import{h as jt}from"./select-D0g5GnIs.js";import{c as At,i as Tt,l as It,r as Lt,u as Ut}from"./markdown-renderer-D2XRRGdl.js";import{t as zt}from"./DeferredRequestRegistry-B3BENoUa.js";import{t as K}from"./Deferred-DzyBMRsy.js";import{t as we}from"./uuid-ClFZlR7U.js";import{t as Ot}from"./use-toast-Bzf3rpev.js";import{t as ve}from"./tooltip-CvjcEpZC.js";import{t as xe}from"./mode-j1jRJgw_.js";import{n as Wt,r as Dt,t as Ht}from"./share-CXQVxivL.js";import{r as Bt,t as Vt}from"./react-resizable-panels.browser.esm-BqxQegSf.js";import{t as Ee}from"./toggle-G1t0cQyf.js";function Xt(t,e,n){return t==null?t:_t(t,e,n)}var H=Xt,$t=be("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]),Yt=be("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function Gt(t){return{all:t||(t=new Map),on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(s){s(n)}),(r=t.get("*"))&&r.slice().map(function(s){s(e,n)})}}}var u=ce(ct(),1),Z=(0,u.createContext)(null),Qt=t=>{let{controller:e}=(0,u.useContext)(Z),n=u.useRef(Symbol("fill"));return(0,u.useEffect)(()=>(e.mount({name:t.name,ref:n.current,children:t.children}),()=>{e.unmount({name:t.name,ref:n.current})}),[]),(0,u.useEffect)(()=>{e.update({name:t.name,ref:n.current,children:t.children})}),null},Kt=Object.defineProperty,Zt=(t,e,n)=>e in t?Kt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_e=(t,e,n)=>(Zt(t,typeof e=="symbol"?e:e+"",n),n),Ce=console,Jt=class{constructor(t){_e(this,"_bus"),_e(this,"_db"),this._bus=t,this.handleFillMount=this.handleFillMount.bind(this),this.handleFillUpdated=this.handleFillUpdated.bind(this),this.handleFillUnmount=this.handleFillUnmount.bind(this),this._db={byName:new Map,byFill:new Map}}mount(){this._bus.on("fill-mount",this.handleFillMount),this._bus.on("fill-updated",this.handleFillUpdated),this._bus.on("fill-unmount",this.handleFillUnmount)}unmount(){this._bus.off("fill-mount",this.handleFillMount),this._bus.off("fill-updated",this.handleFillUpdated),this._bus.off("fill-unmount",this.handleFillUnmount)}handleFillMount({fill:t}){let e=u.Children.toArray(t.children),n=t.name,r={fill:t,children:e,name:n},s=this._db.byName.get(n);s?(s.components.push(r),s.listeners.forEach(i=>i([...s.components]))):this._db.byName.set(n,{listeners:[],components:[r]}),this._db.byFill.set(t.ref,r)}handleFillUpdated({fill:t}){let e=this._db.byFill.get(t.ref),n=u.Children.toArray(t.children);if(e){e.children=n;let r=this._db.byName.get(e.name);if(r)r.listeners.forEach(s=>s([...r.components]));else throw Error("registration was expected to be defined")}else{Ce.error("[handleFillUpdated] component was expected to be defined");return}}handleFillUnmount({fill:t}){let e=this._db.byFill.get(t.ref);if(!e){Ce.error("[handleFillUnmount] component was expected to be defined");return}let n=e.name,r=this._db.byName.get(n);if(!r)throw Error("registration was expected to be defined");r.components=r.components.filter(s=>s!==e),this._db.byFill.delete(t.ref),r.listeners.length===0&&r.components.length===0?this._db.byName.delete(n):r.listeners.forEach(s=>s([...r.components]))}onComponentsChange(t,e){let n=this._db.byName.get(t);n?(n.listeners.push(e),e(n.components)):(this._db.byName.set(t,{listeners:[e],components:[]}),e([]))}getFillsByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.fill):[]}getChildrenByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.children).reduce((n,r)=>n.concat(r),[]):[]}removeOnComponentsChange(t,e){let n=this._db.byName.get(t);if(!n)throw Error("expected registration to be defined");let r=n.listeners;r.splice(r.indexOf(e),1)}},en=Object.defineProperty,tn=(t,e,n)=>e in t?en(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,nn=(t,e,n)=>(tn(t,typeof e=="symbol"?e:e+"",n),n),ke=class{constructor(){nn(this,"bus",Gt())}mount(t){this.bus.emit("fill-mount",{fill:t})}unmount(t){this.bus.emit("fill-unmount",{fill:t})}update(t){this.bus.emit("fill-updated",{fill:t})}};function rn(t){let e=t||new ke;return{controller:e,manager:new Jt(e.bus)}}var sn=({controller:t,children:e})=>{let[n]=u.useState(()=>{let r=rn(t);return r.manager.mount(),r});return u.useEffect(()=>()=>{n.manager.unmount()},[]),u.createElement(Z.Provider,{value:n},e)};function J(t,e){let[n,r]=(0,u.useState)([]),{manager:s}=(0,u.useContext)(Z);return(0,u.useEffect)(()=>(s.onComponentsChange(t,r),()=>{s.removeOnComponentsChange(t,r)}),[t]),n.flatMap((i,d)=>{let{children:l}=i;return l.map((p,b)=>{if(typeof p=="number"||typeof p=="string")throw Error("Only element children will work here");return u.cloneElement(p,{key:d.toString()+b.toString(),...e})})})}var Re=t=>{let e=J(t.name,t.childProps);if(typeof t.children=="function"){let n=t.children(e);if(u.isValidElement(n)||n===null)return n;throw Error("Slot rendered with function must return a valid React Element.")}return e};const an=q(null);var{valueAtom:on,useActions:ln}=Mt(()=>({banners:[]}),{addBanner:(t,e)=>({...t,banners:[...t.banners,{...e,id:we()}]}),removeBanner:(t,e)=>({...t,banners:t.banners.filter(n=>n.id!==e)}),clearBanners:t=>({...t,banners:[]})});const un=()=>ut(on);function cn(){return ln()}const dn=new ke,B={SIDEBAR:"sidebar",CONTEXT_AWARE_PANEL:"context-aware-panel"};var fn=class{constructor(){a(this,"subscriptions",new Map)}addSubscription(t,e){var n;this.subscriptions.has(t)||this.subscriptions.set(t,new Set),(n=this.subscriptions.get(t))==null||n.add(e)}removeSubscription(t,e){var n;(n=this.subscriptions.get(t))==null||n.delete(e)}notify(t,e){for(let n of this.subscriptions.get(t)??[])n(e)}},Fe=class ue{constructor(e){a(this,"subscriptions",new fn);this.producer=e}static withProducerCallback(e){return new ue(e)}static empty(){return new ue}startProducer(){this.producer&&this.producer(e=>{this.subscriptions.notify("message",e)})}connect(){return new Promise(e=>setTimeout(e,0)).then(()=>{this.subscriptions.notify("open",new Event("open"))})}get readyState(){return WebSocket.OPEN}reconnect(e,n){this.close(),this.connect()}close(){this.subscriptions.notify("close",new Event("close"))}send(e){return this.subscriptions.notify("message",new MessageEvent("message",{data:e})),Promise.resolve()}addEventListener(e,n){this.subscriptions.addSubscription(e,n),e==="open"&&n(new Event("open")),e==="message"&&this.startProducer()}removeEventListener(e,n){this.subscriptions.removeSubscription(e,n)}},mn=1e10,pn=1e3;function V(t,e){let n=t.map(r=>`"${r}"`).join(", ");return Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${n}`)}function hn(t={}){let e={};function n(o){e=o}let r={};function s(o){var f;r.unregisterHandler&&r.unregisterHandler(),r=o,(f=r.registerHandler)==null||f.call(r,U)}let i;function d(o){if(typeof o=="function"){i=o;return}i=(f,g)=>{let c=o[f];if(c)return c(g);let h=o._;if(!h)throw Error(`The requested method has no handler: ${f}`);return h(f,g)}}let{maxRequestTime:l=pn}=t;t.transport&&s(t.transport),t.requestHandler&&d(t.requestHandler),t._debugHooks&&n(t._debugHooks);let p=0;function b(){return p<=mn?++p:p=0}let x=new Map,w=new Map;function _(o,...f){let g=f[0];return new Promise((c,h)=>{var T;if(!r.send)throw V(["send"],"make requests");let S=b(),M={type:"request",id:S,method:o,params:g};x.set(S,{resolve:c,reject:h}),l!==1/0&&w.set(S,setTimeout(()=>{w.delete(S),h(Error("RPC request timed out."))},l)),(T=e.onSend)==null||T.call(e,M),r.send(M)})}let F=new Proxy(_,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>_(f,c)}),C=F;function k(o,...f){var h;let g=f[0];if(!r.send)throw V(["send"],"send messages");let c={type:"message",id:o,payload:g};(h=e.onSend)==null||h.call(e,c),r.send(c)}let R=new Proxy(k,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>k(f,c)}),v=R,N=new Map,P=new Set;function A(o,f){var g;if(!r.registerHandler)throw V(["registerHandler"],"register message listeners");if(o==="*"){P.add(f);return}N.has(o)||N.set(o,new Set),(g=N.get(o))==null||g.add(f)}function L(o,f){var g,c;if(o==="*"){P.delete(f);return}(g=N.get(o))==null||g.delete(f),((c=N.get(o))==null?void 0:c.size)===0&&N.delete(o)}async function U(o){var f,g;if((f=e.onReceive)==null||f.call(e,o),!("type"in o))throw Error("Message does not contain a type.");if(o.type==="request"){if(!r.send||!i)throw V(["send","requestHandler"],"handle requests");let{id:c,method:h,params:S}=o,M;try{M={type:"response",id:c,success:!0,payload:await i(h,S)}}catch(T){if(!(T instanceof Error))throw T;M={type:"response",id:c,success:!1,error:T.message}}(g=e.onSend)==null||g.call(e,M),r.send(M);return}if(o.type==="response"){let c=w.get(o.id);c!=null&&clearTimeout(c);let{resolve:h,reject:S}=x.get(o.id)??{};o.success?h==null||h(o.payload):S==null||S(Error(o.error));return}if(o.type==="message"){for(let h of P)h(o.id,o.payload);let c=N.get(o.id);if(!c)return;for(let h of c)h(o.payload);return}throw Error(`Unexpected RPC message type: ${o.type}`)}return{setTransport:s,setRequestHandler:d,request:F,requestProxy:C,send:R,sendProxy:v,addMessageListener:A,removeMessageListener:L,proxy:{send:v,request:C},_setDebugHooks:n}}function gn(t){return hn(t)}var Ne="[transport-id]";function yn(t,e){let{transportId:n}=e;return n==null?t:{[Ne]:n,data:t}}function bn(t,e){let{transportId:n,filter:r}=e,s=r==null?void 0:r();if(n!=null&&s!=null)throw Error("Cannot use both `transportId` and `filter` at the same time");let i=t;if(n){if(t[Ne]!==n)return[!0];i=t.data}return s===!1?[!0]:[!1,i]}function wn(t,e={}){let{transportId:n,filter:r,remotePort:s}=e,i=t,d=s??t,l;return{send(p){d.postMessage(yn(p,{transportId:n}))},registerHandler(p){l=b=>{let x=b.data,[w,_]=bn(x,{transportId:n,filter:()=>r==null?void 0:r(b)});w||p(_)},i.addEventListener("message",l)},unregisterHandler(){l&&i.removeEventListener("message",l)}}}function vn(t,e){return wn(t,e)}function Se(t){return gn({transport:vn(t,{transportId:"marimo-transport"}),maxRequestTime:2e4,_debugHooks:{onSend:e=>{E.debug("[rpc] Parent -> Worker",e)},onReceive:e=>{E.debug("[rpc] Worker -> Parent",e)}}})}const qe=q("Initializing..."),xn=q(t=>{let e=t(mt),n=Object.values(e.cellRuntime);return n.some(r=>!Ut(r.output))?!0:n.every(r=>r.status==="idle")});var Pe=Wt(),Me="marimo:file",je=new ht(null);const En={saveFile(t){je.set(Me,t)},readFile(){return je.get(Me)}};var _n={saveFile(t){z.setCodeForHash((0,Pe.compressToEncodedURIComponent)(t))},readFile(){let t=z.getCodeFromHash()||z.getCodeFromSearchParam();return t?(0,Pe.decompressFromEncodedURIComponent)(t):null}};const Cn={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var kn={saveFile(t){},readFile(){if(window.location.hostname!=="marimo.app")return null;let t=new URL("files/wasm-intro.py",document.baseURI);return fetch(t.toString()).then(e=>e.ok?e.text():null).catch(()=>null)}},Rn={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
|
|
2
2
|
`)}},Ae=class{constructor(t){this.stores=t}insert(t,e){this.stores.splice(t,0,e)}saveFile(t){this.stores.forEach(e=>e.saveFile(t))}readFile(){for(let t of this.stores){let e=t.readFile();if(e)return e}return null}};const X=new Ae([Cn,_n]),ee=new Ae([En,kn,Rn]);var Te=class st{constructor(){a(this,"initialized",new K);a(this,"sendRename",async({filename:e})=>(e===null||(z.setFilename(e),await this.rpc.proxy.request.bridge({functionName:"rename_file",payload:e})),null));a(this,"sendSave",async e=>{if(!this.saveRpc)return E.warn("Save RPC not initialized"),null;await this.saveRpc.saveNotebook(e);let n=await this.readCode();return n.contents&&(X.saveFile(n.contents),ee.saveFile(n.contents)),this.rpc.proxy.request.saveNotebook(e).catch(r=>{E.error(r)}),null});a(this,"sendCopy",async()=>{y()});a(this,"sendStdin",async e=>(await this.rpc.proxy.request.bridge({functionName:"put_input",payload:e.text}),null));a(this,"sendPdb",async()=>{y()});a(this,"sendRun",async e=>(await this.rpc.proxy.request.loadPackages(e.codes.join(`
|
|
3
3
|
`)),await this.putControlRequest({type:"execute-cells",...e}),null));a(this,"sendRunScratchpad",async e=>(await this.rpc.proxy.request.loadPackages(e.code),await this.putControlRequest({type:"execute-scratchpad",...e}),null));a(this,"sendInterrupt",async()=>(this.interruptBuffer!==void 0&&(this.interruptBuffer[0]=2),null));a(this,"sendShutdown",async()=>(window.close(),null));a(this,"sendFormat",async e=>await this.rpc.proxy.request.bridge({functionName:"format",payload:e}));a(this,"sendDeleteCell",async e=>(await this.putControlRequest({type:"delete-cell",...e}),null));a(this,"sendInstallMissingPackages",async e=>(this.putControlRequest({type:"install-packages",...e}),null));a(this,"sendCodeCompletionRequest",async e=>(Q.get(pt)||await this.rpc.proxy.request.bridge({functionName:"code_complete",payload:e}),null));a(this,"saveUserConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_user_config",payload:e}),Ft.post("/kernel/save_user_config",e,{baseUrl:"/"}).catch(n=>(E.error(n),null))));a(this,"saveAppConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_app_config",payload:e}),null));a(this,"saveCellConfig",async e=>(await this.putControlRequest({type:"update-cell-config",...e}),null));a(this,"sendRestart",async()=>{let e=await this.readCode();return e.contents&&(X.saveFile(e.contents),ee.saveFile(e.contents)),Dt(),null});a(this,"readCode",async()=>this.saveRpc?{contents:await this.saveRpc.readNotebook()}:(E.warn("Save RPC not initialized"),{contents:""}));a(this,"readSnippets",async()=>await this.rpc.proxy.request.bridge({functionName:"read_snippets",payload:void 0}));a(this,"openFile",async({path:e})=>{let n=Ht({code:null,baseUrl:window.location.origin});return window.open(n,"_blank"),null});a(this,"sendListFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"list_files",payload:e}));a(this,"sendSearchFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"search_files",payload:e}));a(this,"sendComponentValues",async e=>(await this.putControlRequest({type:"update-ui-element",...e,token:we()}),null));a(this,"sendInstantiate",async e=>null);a(this,"sendFunctionRequest",async e=>(await this.putControlRequest({type:"invoke-function",...e}),null));a(this,"sendCreateFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"create_file_or_directory",payload:e}));a(this,"sendDeleteFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"delete_file_or_directory",payload:e}));a(this,"sendRenameFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"move_file_or_directory",payload:e}));a(this,"sendUpdateFile",async e=>await this.rpc.proxy.request.bridge({functionName:"update_file",payload:e}));a(this,"sendFileDetails",async e=>await this.rpc.proxy.request.bridge({functionName:"file_details",payload:e}));a(this,"exportAsHTML",async e=>await this.rpc.proxy.request.bridge({functionName:"export_html",payload:e}));a(this,"exportAsMarkdown",async e=>await this.rpc.proxy.request.bridge({functionName:"export_markdown",payload:e}));a(this,"previewDatasetColumn",async e=>(await this.putControlRequest({type:"preview-dataset-column",...e}),null));a(this,"previewSQLTable",async e=>(await this.putControlRequest({type:"preview-sql-table",...e}),null));a(this,"previewSQLTableList",async e=>(await this.putControlRequest({type:"list-sql-tables",...e}),null));a(this,"previewDataSourceConnection",async e=>(await this.putControlRequest({type:"list-data-source-connection",...e}),null));a(this,"validateSQL",async e=>(await this.putControlRequest({type:"validate-sql",...e}),null));a(this,"sendModelValue",async e=>(await this.putControlRequest({type:"update-widget-model",...e}),null));a(this,"syncCellIds",()=>Promise.resolve(null));a(this,"addPackage",async e=>this.rpc.proxy.request.addPackage(e));a(this,"removePackage",async e=>this.rpc.proxy.request.removePackage(e));a(this,"getPackageList",async()=>await this.rpc.proxy.request.listPackages());a(this,"getDependencyTree",async()=>({tree:{dependencies:[],name:"",tags:[],version:null}}));a(this,"listSecretKeys",async e=>(await this.putControlRequest({type:"list-secret-keys",...e}),null));a(this,"getUsageStats",y);a(this,"openTutorial",y);a(this,"getRecentFiles",y);a(this,"getWorkspaceFiles",y);a(this,"getRunningNotebooks",y);a(this,"shutdownSession",y);a(this,"autoExportAsHTML",y);a(this,"autoExportAsMarkdown",y);a(this,"autoExportAsIPYNB",y);a(this,"writeSecret",y);a(this,"invokeAiTool",y);a(this,"clearCache",y);a(this,"getCacheInfo",y);Rt()&&(this.rpc=Se(new Worker(new URL(""+new URL("worker-CUL1lW-N.js",import.meta.url).href,""+import.meta.url),{type:"module",name:he()})),this.rpc.addMessageListener("ready",()=>{this.startSession()}),this.rpc.addMessageListener("initialized",()=>{this.saveRpc=this.getSaveWorker(),this.setInterruptBuffer(),this.initialized.resolve()}),this.rpc.addMessageListener("initializingMessage",({message:e})=>{Q.set(qe,e)}),this.rpc.addMessageListener("initializedError",({error:e})=>{this.initialized.status==="resolved"&&(E.error(e),Ot({title:"Error initializing",description:e,variant:"danger"})),this.initialized.reject(Error(e))}),this.rpc.addMessageListener("kernelMessage",({message:e})=>{var n;(n=this.messageConsumer)==null||n.call(this,new MessageEvent("message",{data:e}))}))}static get INSTANCE(){let e="_marimo_private_PyodideBridge";return window[e]||(window[e]=new st),window[e]}getSaveWorker(){return xe()==="read"?(E.debug("Skipping SaveWorker in read-mode"),{readFile:y,readNotebook:y,saveNotebook:y}):Se(new Worker(new URL(""+new URL("save-worker-DtF6B3PS.js",import.meta.url).href,""+import.meta.url),{type:"module",name:he()})).proxy.request}async startSession(){let e=await X.readFile(),n=await ee.readFile(),r=z.getFilename(),s=Q.get(kt),i={},d=new URLSearchParams(window.location.search);for(let l of d.keys()){let p=d.getAll(l);i[l]=p.length===1?p[0]:p}await this.rpc.proxy.request.startSession({queryParameters:i,code:e||n||"",filename:r,userConfig:{...s,runtime:{...s.runtime,auto_instantiate:xe()==="read"?!0:s.runtime.auto_instantiate}}})}setInterruptBuffer(){crossOriginIsolated?(this.interruptBuffer=new Uint8Array(new SharedArrayBuffer(1)),this.rpc.proxy.request.setInterruptBuffer(this.interruptBuffer)):E.warn("Not running in a secure context; interrupts are not available.")}attachMessageConsumer(e){this.messageConsumer=e,this.rpc.proxy.send.consumerReady({})}async putControlRequest(e){await this.rpc.proxy.request.bridge({functionName:"put_control_request",payload:e})}};function Fn(){return Fe.withProducerCallback(t=>{Te.INSTANCE.attachMessageConsumer(t)})}const Ie=q({isInstantiated:!1,error:null});function Nn(){return lt(Ie,t=>t.isInstantiated)}function $(t){return()=>({TYPE:t,is(e){return e.type===t},create(e){return new CustomEvent(t,e)}})}const Le=$("marimo-value-input")(),Ue=$("marimo-value-update")(),ze=$("marimo-value-ready")(),Oe=$("marimo-incoming-message")();function Sn(t,e){return Le.create({bubbles:!0,composed:!0,detail:{value:t,element:e}})}var We=class at{static get INSTANCE(){let e="_marimo_private_UIElementRegistry";return window[e]||(window[e]=new at),window[e]}constructor(){this.entries=new Map}has(e){return this.entries.has(e)}set(e,n){if(this.entries.has(e))throw Error(`UIElement ${e} already registered`);this.entries.set(e,{objectId:e,value:n,elements:new Set})}registerInstance(e,n){let r=this.entries.get(e);r===void 0?this.entries.set(e,{objectId:e,value:ft(n,this),elements:new Set([n])}):r.elements.add(n)}removeInstance(e,n){let r=this.entries.get(e);r!=null&&r.elements.has(n)&&r.elements.delete(n)}removeElementsByCell(e){[...this.entries.keys()].filter(n=>n.startsWith(`${e}-`)).forEach(n=>{this.entries.delete(n)})}lookupValue(e){let n=this.entries.get(e);return n===void 0?void 0:n.value}broadcastMessage(e,n,r){let s=this.entries.get(e);s===void 0?E.warn("UIElementRegistry missing entry",e):s.elements.forEach(i=>{i.dispatchEvent(Oe.create({bubbles:!1,composed:!0,detail:{objectId:e,message:n,buffers:r}}))})}broadcastValueUpdate(e,n,r){let s=this.entries.get(n);s===void 0?E.warn("UIElementRegistry missing entry",n):(s.value=r,s.elements.forEach(i=>{i!==e&&i.dispatchEvent(Ue.create({bubbles:!1,composed:!0,detail:{value:r,element:i}}))}),document.dispatchEvent(ze.create({bubbles:!0,composed:!0,detail:{objectId:n}})))}};const qn=We.INSTANCE,Pn=new zt("function-call-result",async(t,e)=>{await ye().sendFunctionRequest({functionCallId:t,...e})}),Mn="68px";var jn="288px";const An=t=>t?/^\d+$/.test(t)?`${t}px`:t:jn,Tn=dt({isOpen:!0},(t,e)=>{if(!e)return t;switch(e.type){case"toggle":return{...t,isOpen:e.isOpen??t.isOpen};case"setWidth":return{...t,width:e.width};default:return t}});function In(t){return It(Lt(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)))}function te(t,e=[]){let n=[];if(t instanceof DataView)n.push(e);else if(Array.isArray(t))for(let[r,s]of t.entries())n.push(...te(s,[...e,r]));else if(typeof t=="object"&&t)for(let[r,s]of Object.entries(t))n.push(...te(s,[...e,r]));return n}function ne(t){let e=te(t);if(e.length===0)return{state:t,buffers:[],bufferPaths:[]};let n=structuredClone(t),r=[],s=[];for(let i of e){let d=vt(t,i);if(d instanceof DataView){let l=In(d);r.push(l),s.push(i),H(n,i,l)}}return{state:n,buffers:r,bufferPaths:s}}function Ln(t){return typeof t=="object"&&!!t&&"state"in t&&"bufferPaths"in t&&"buffers"in t}function Y(t){let{state:e,bufferPaths:n,buffers:r}=t;if(!n||n.length===0)return e;r&&Ct(r.length===n.length,"Buffers and buffer paths not the same length");let s=structuredClone(e);for(let[i,d]of n.entries()){let l=r==null?void 0:r[i];if(l==null){E.warn("[anywidget] Could not find buffer at path",d);continue}if(typeof l=="string"){let p=Tt(At(l));H(s,d,new DataView(p.buffer))}else H(s,d,l)}return s}const De=new class{constructor(t=1e4){a(this,"models",new Map);this.timeout=t}get(t){let e=this.models.get(t);return e||(e=new K,this.models.set(t,e),setTimeout(()=>{e.status==="pending"&&(e.reject(Error(`Model not found for key: ${t}`)),this.models.delete(t))},this.timeout)),e.promise}set(t,e){let n=this.models.get(t);n||(n=new K,this.models.set(t,n)),n.resolve(e)}delete(t){this.models.delete(t)}};var He=(j=class{constructor(e,n,r,s){a(this,"ANY_CHANGE_EVENT","change");a(this,"listeners",{});a(this,"widget_manager",{async get_model(e){let n=await j._modelManager.get(e);if(!n)throw Error(`Model not found with id: ${e}. This is likely because the model was not registered.`);return n}});a(this,"emitAnyChange",Et(()=>{var e;(e=this.listeners[this.ANY_CHANGE_EVENT])==null||e.forEach(n=>n())},0));this.data=e,this.onChange=n,this.sendToWidget=r,this.dirtyFields=new Map([...s].map(i=>[i,this.data[i]]))}off(e,n){var r;if(!e){this.listeners={};return}if(!n){this.listeners[e]=new Set;return}(r=this.listeners[e])==null||r.delete(n)}send(e,n,r){let{state:s,bufferPaths:i,buffers:d}=ne(e);this.sendToWidget({content:{state:s,bufferPaths:i},buffers:d}).then(n)}get(e){return this.data[e]}set(e,n){this.data={...this.data,[e]:n},this.dirtyFields.set(e,n),this.emit(`change:${e}`,n),this.emitAnyChange()}save_changes(){if(this.dirtyFields.size===0)return;let e=Object.fromEntries(this.dirtyFields.entries());this.dirtyFields.clear(),this.onChange(e)}updateAndEmitDiffs(e){e!=null&&Object.keys(e).forEach(n=>{let r=n;this.data[r]!==e[r]&&this.set(r,e[r])})}receiveCustomMessage(e,n=[]){var s;let r=Be.safeParse(e);if(r.success){let i=r.data;switch(i.method){case"update":this.updateAndEmitDiffs(Y({state:i.state,bufferPaths:i.buffer_paths??[],buffers:n}));break;case"custom":(s=this.listeners["msg:custom"])==null||s.forEach(d=>d(i.content,n));break;case"open":this.updateAndEmitDiffs(Y({state:i.state,bufferPaths:i.buffer_paths??[],buffers:n}));break;case"echo_update":break;default:E.error("[anywidget] Unknown message method",i.method);break}}else E.error("Failed to parse message",r.error),E.error("Message",e)}on(e,n){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(n)}emit(e,n){this.listeners[e]&&this.listeners[e].forEach(r=>r(n))}},a(j,"_modelManager",De),j),re=me(me(gt([fe(),wt()]))),se=bt(fe(),de()),Be=yt("method",[O({method:W("open"),state:se,buffer_paths:re.optional()}),O({method:W("update"),state:se,buffer_paths:re.optional()}),O({method:W("custom"),content:de()}),O({method:W("echo_update"),buffer_paths:re,state:se}),O({method:W("close")})]);function Un(t){return t==null?!1:Be.safeParse(t).success}async function zn({modelId:t,msg:e,buffers:n,modelManager:r}){if(e.method==="echo_update")return;if(e.method==="custom"){(await r.get(t)).receiveCustomMessage(e,n);return}if(e.method==="close"){r.delete(t);return}let{method:s,state:i,buffer_paths:d=[]}=e,l=Y({state:i,bufferPaths:d,buffers:n});if(s==="open"){let p=new He(l,b=>{let{state:x,buffers:w,bufferPaths:_}=ne(b);ye().sendModelValue({modelId:t,message:{state:x,bufferPaths:_},buffers:w})},y,new Set);r.set(t,p);return}if(s==="update"){(await r.get(t)).updateAndEmitDiffs(l);return}xt(s)}const Ve=q(null),On=q(null),Xe=q(!1),Wn=q(!1),$e=q(!1);var Dn=pe();const Ye=t=>{let e=(0,Dn.c)(8),{onResize:n,startingWidth:r,minWidth:s,maxWidth:i}=t,d=(0,u.useRef)(null),l=(0,u.useRef)(null),p=(0,u.useRef)(null),b,x;e[0]!==i||e[1]!==s||e[2]!==n?(b=()=>{let C=d.current,k=l.current,R=p.current;if(!C||!k&&!R)return;let v=Number.parseInt(window.getComputedStyle(C).width,10),N=0,P=!1,A=null,L=c=>{if(!C||!P||!A)return;let h=c.clientX-N;N=c.clientX,v=A==="left"?v-h:v+h,s&&(v=Math.max(s,v)),i&&(v=Math.min(i,v)),C.style.width=`${v}px`},U=()=>{P&&(n==null||n(v),P=!1,A=null),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",U)},o=(c,h)=>{c.preventDefault(),P=!0,A=h,N=c.clientX,document.addEventListener("mousemove",L),document.addEventListener("mouseup",U)},f=c=>o(c,"left"),g=c=>o(c,"right");return k&&k.addEventListener("mousedown",f),R&&R.addEventListener("mousedown",g),()=>{k&&k.removeEventListener("mousedown",f),R&&R.removeEventListener("mousedown",g),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",U)}},x=[s,i,n],e[0]=i,e[1]=s,e[2]=n,e[3]=b,e[4]=x):(b=e[3],x=e[4]),(0,u.useEffect)(b,x);let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w={left:l,right:p},e[5]=w):w=e[5];let _=r==="contentWidth"?"var(--content-width-medium)":`${r}px`,F;return e[6]===_?F=e[7]:(F={resizableDivRef:d,handleRefs:w,style:{width:_}},e[6]=_,e[7]=F),F};function Ge(t){t||window.dispatchEvent(new Event("resize"))}var Qe=pe(),m=ce(Nt(),1);const Hn=()=>{let t=(0,Qe.c)(16),[e,n]=D(Ve),[r,s]=D(Xe),[i,d]=D(Wn),[l,p]=D($e),b;t[0]!==s||t[1]!==n?(b=()=>{n(null),s(!1)},t[0]=s,t[1]=n,t[2]=b):b=t[2];let x=b;if(J(B.CONTEXT_AWARE_PANEL).length===0||!e||!r)return null;let w;t[3]!==l||t[4]!==i||t[5]!==p||t[6]!==d?(w=()=>(0,m.jsxs)("div",{className:"flex flex-row items-center gap-3",children:[(0,m.jsx)(ve,{content:i?"Unpin panel":"Pin panel",children:(0,m.jsx)(Ee,{size:"xs",onPressedChange:()=>d(!i),pressed:i,"aria-label":i?"Unpin panel":"Pin panel",children:i?(0,m.jsx)(Yt,{className:"w-4 h-4"}):(0,m.jsx)(Pt,{className:"w-4 h-4"})})}),(0,m.jsx)(ve,{content:l?(0,m.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,m.jsx)("span",{children:"Follow focused table"}),(0,m.jsx)("span",{className:"text-xs text-muted-foreground w-64",children:"The panel updates as cells that output tables are focused. Click to fix to the current cell."})]}):(0,m.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,m.jsx)("span",{children:"Focus on current table"}),(0,m.jsx)("span",{className:"text-xs text-muted-foreground w-64",children:"The panel is focused on the current table. Click to update based on which cell is focused."})]}),children:(0,m.jsx)(Ee,{size:"xs",onPressedChange:()=>p(!l),pressed:l,"aria-label":l?"Follow focused cell":"Fixed",children:(0,m.jsx)($t,{className:qt("w-4 h-4",l&&"text-primary")})})})]}),t[3]=l,t[4]=i,t[5]=p,t[6]=d,t[7]=w):w=t[7];let _=w,F;t[8]!==x||t[9]!==_?(F=()=>(0,m.jsxs)("div",{className:"mt-2 pb-7 mb-4 h-full overflow-auto",children:[(0,m.jsxs)("div",{className:"flex flex-row justify-between items-center mx-2",children:[_(),(0,m.jsx)(St,{variant:"linkDestructive",size:"icon",onClick:x,"aria-label":"Close selection panel",children:(0,m.jsx)(jt,{className:"w-4 h-4"})})]}),(0,m.jsx)(ge,{children:(0,m.jsx)(Re,{name:B.CONTEXT_AWARE_PANEL})})]}),t[8]=x,t[9]=_,t[10]=F):F=t[10];let C=F;if(!i){let v;return t[11]===C?v=t[12]:(v=(0,m.jsx)(Vn,{children:C()}),t[11]=C,t[12]=v),v}let k;t[13]===Symbol.for("react.memo_cache_sentinel")?(k=(0,m.jsx)(Bt,{onDragging:Ge,className:"resize-handle border-border z-20 no-print border-l"}),t[13]=k):k=t[13];let R;return t[14]===C?R=t[15]:(R=(0,m.jsxs)(m.Fragment,{children:[k,(0,m.jsx)(Vt,{defaultSize:20,minSize:15,maxSize:80,children:C()})]}),t[14]=C,t[15]=R),R},Bn=t=>{let e=(0,Qe.c)(2),{children:n}=t,r;return e[0]===n?r=e[1]:(r=(0,m.jsx)(ge,{children:(0,m.jsx)(Qt,{name:B.CONTEXT_AWARE_PANEL,children:n})}),e[0]=n,e[1]=r),r};var Vn=({children:t})=>{let{resizableDivRef:e,handleRefs:n,style:r}=Ye({startingWidth:400,minWidth:300,maxWidth:1500});return(0,m.jsxs)("div",{className:"absolute z-40 right-0 h-full bg-background flex flex-row",children:[(0,m.jsx)("div",{ref:n.left,className:"w-1 h-full cursor-col-resize border-l"}),(0,m.jsx)("div",{ref:e,style:r,children:t})]})};function Xn(){var t=[...arguments];return(0,u.useMemo)(()=>e=>{t.forEach(n=>n(e))},t)}var Ke=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0;function G(t){let e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function ae(t){return"nodeType"in t}function I(t){var e;return t?G(t)?t:ae(t)?((e=t.ownerDocument)==null?void 0:e.defaultView)??window:window:window}function Ze(t){let{Document:e}=I(t);return t instanceof e}function Je(t){return G(t)?!1:t instanceof I(t).HTMLElement}function et(t){return t instanceof I(t).SVGElement}function $n(t){return t?G(t)?t.document:ae(t)?Ze(t)?t:Je(t)||et(t)?t.ownerDocument:document:document:document}var ie=Ke?u.useLayoutEffect:u.useEffect;function tt(t){let e=(0,u.useRef)(t);return ie(()=>{e.current=t}),(0,u.useCallback)(function(){var n=[...arguments];return e.current==null?void 0:e.current(...n)},[])}function Yn(){let t=(0,u.useRef)(null);return[(0,u.useCallback)((e,n)=>{t.current=setInterval(e,n)},[]),(0,u.useCallback)(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[])]}function Gn(t,e){e===void 0&&(e=[t]);let n=(0,u.useRef)(t);return ie(()=>{n.current!==t&&(n.current=t)},e),n}function Qn(t,e){let n=(0,u.useRef)();return(0,u.useMemo)(()=>{let r=t(n.current);return n.current=r,r},[...e])}function Kn(t){let e=tt(t),n=(0,u.useRef)(null);return[n,(0,u.useCallback)(r=>{r!==n.current&&(e==null||e(r,n.current)),n.current=r},[])]}function Zn(t){let e=(0,u.useRef)();return(0,u.useEffect)(()=>{e.current=t},[t]),e.current}var oe={};function Jn(t,e){return(0,u.useMemo)(()=>{if(e)return e;let n=oe[t]==null?0:oe[t]+1;return oe[t]=n,t+"-"+n},[t,e])}function nt(t){return function(e){return[...arguments].slice(1).reduce((n,r)=>{let s=Object.entries(r);for(let[i,d]of s){let l=n[i];l!=null&&(n[i]=l+t*d)}return n},{...e})}}var er=nt(1),tr=nt(-1);function nr(t){return"clientX"in t&&"clientY"in t}function rr(t){if(!t)return!1;let{KeyboardEvent:e}=I(t.target);return e&&t instanceof e}function sr(t){if(!t)return!1;let{TouchEvent:e}=I(t.target);return e&&t instanceof e}function ar(t){if(sr(t)){if(t.touches&&t.touches.length){let{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){let{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return nr(t)?{x:t.clientX,y:t.clientY}:null}var le=Object.freeze({Translate:{toString(t){if(!t)return;let{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;let{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[le.Translate.toString(t),le.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),rt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function ir(t){return t.matches(rt)?t:t.querySelector(rt)}export{Fn as $,On as A,An as B,Jn as C,Ye as D,Ge as E,Un as F,Oe as G,Pn as H,Y as I,Ue as J,Le as K,Ln as L,De as M,He as N,Xe as O,zn as P,Te as Q,ne as R,Zn as S,Bn as T,We as U,Tn as V,qn as W,Ie as X,Sn as Y,Nn as Z,Yn as _,ar as a,dn as at,Qn as b,Ze as c,cn as ct,ae as d,J as dt,X as et,et as f,H as ft,tt as g,Xn as h,ir as i,B as it,$e as j,Ve as k,Je as l,sn as lt,tr as m,er as n,qe as nt,$n as o,an as ot,G as p,ze as q,Ke as r,Fe as rt,I as s,un as st,le as t,xn as tt,rr as u,Re as ut,ie as v,Hn as w,Kn as x,Gn as y,Mn as z};
|
package/dist/index.html
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
|
|
67
67
|
<!-- /TODO -->
|
|
68
68
|
<title>{{ title }}</title>
|
|
69
|
-
<script type="module" crossorigin src="./assets/index-
|
|
69
|
+
<script type="module" crossorigin src="./assets/index-DXLkhAK3.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-BW0IMuFq.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/hotkeys-uKX61F1_.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/defaultLocale-BLUna9fQ.js">
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
<link rel="modulepreload" crossorigin href="./assets/toInteger-CDcO32Gx.js">
|
|
137
137
|
<link rel="modulepreload" crossorigin href="./assets/database-zap-CaVvnK_o.js">
|
|
138
138
|
<link rel="modulepreload" crossorigin href="./assets/main-CwSdzVhm.js">
|
|
139
|
-
<link rel="modulepreload" crossorigin href="./assets/cells-
|
|
139
|
+
<link rel="modulepreload" crossorigin href="./assets/cells-CibeVr5R.js">
|
|
140
140
|
<link rel="modulepreload" crossorigin href="./assets/ErrorBoundary-Drf1manw.js">
|
|
141
141
|
<link rel="modulepreload" crossorigin href="./assets/kbd-Czc5z_04.js">
|
|
142
142
|
<link rel="modulepreload" crossorigin href="./assets/useInstallPackage-RldLPyJs.js">
|
|
@@ -150,33 +150,33 @@
|
|
|
150
150
|
<link rel="modulepreload" crossorigin href="./assets/usePress-C2LPFxyv.js">
|
|
151
151
|
<link rel="modulepreload" crossorigin href="./assets/input-CaEtLL8p.js">
|
|
152
152
|
<link rel="modulepreload" crossorigin href="./assets/ImperativeModal-q6QlC2aZ.js">
|
|
153
|
-
<link rel="modulepreload" crossorigin href="./assets/cell-link-
|
|
153
|
+
<link rel="modulepreload" crossorigin href="./assets/cell-link-T1P92ttw.js">
|
|
154
154
|
<link rel="modulepreload" crossorigin href="./assets/multi-map-fjX9ImVF.js">
|
|
155
155
|
<link rel="modulepreload" crossorigin href="./assets/alert-BEdExd6A.js">
|
|
156
156
|
<link rel="modulepreload" crossorigin href="./assets/chevron-right-CqEd11Di.js">
|
|
157
157
|
<link rel="modulepreload" crossorigin href="./assets/dropdown-menu-BP4_BZLr.js">
|
|
158
158
|
<link rel="modulepreload" crossorigin href="./assets/links-DNmjkr65.js">
|
|
159
|
-
<link rel="modulepreload" crossorigin href="./assets/datasource-
|
|
160
|
-
<link rel="modulepreload" crossorigin href="./assets/state-
|
|
161
|
-
<link rel="modulepreload" crossorigin href="./assets/MarimoErrorOutput-
|
|
159
|
+
<link rel="modulepreload" crossorigin href="./assets/datasource-D4vwmOLv.js">
|
|
160
|
+
<link rel="modulepreload" crossorigin href="./assets/state-Eihpi8Gd.js">
|
|
161
|
+
<link rel="modulepreload" crossorigin href="./assets/MarimoErrorOutput-Cva6Gfqr.js">
|
|
162
162
|
<link rel="modulepreload" crossorigin href="./assets/copy-DRhpWiOq.js">
|
|
163
163
|
<link rel="modulepreload" crossorigin href="./assets/copy-gBVL4NN-.js">
|
|
164
164
|
<link rel="modulepreload" crossorigin href="./assets/copy-icon-B69c-352.js">
|
|
165
165
|
<link rel="modulepreload" crossorigin href="./assets/spinner-C1czjtp7.js">
|
|
166
|
-
<link rel="modulepreload" crossorigin href="./assets/es-
|
|
167
|
-
<link rel="modulepreload" crossorigin href="./assets/focus-
|
|
166
|
+
<link rel="modulepreload" crossorigin href="./assets/es-BMs8n9bF.js">
|
|
167
|
+
<link rel="modulepreload" crossorigin href="./assets/focus-BGO2qwac.js">
|
|
168
168
|
<link rel="modulepreload" crossorigin href="./assets/LazyAnyLanguageCodeMirror-jpEDlD0M.js">
|
|
169
169
|
<link rel="modulepreload" crossorigin href="./assets/katex-AwOI3EvM.js">
|
|
170
170
|
<link rel="modulepreload" crossorigin href="./assets/marked.esm-CHnOtnr3.js">
|
|
171
171
|
<link rel="modulepreload" crossorigin href="./assets/chunk-OGVTOU66-CjNLT2C3.js">
|
|
172
|
-
<link rel="modulepreload" crossorigin href="./assets/markdown-renderer-
|
|
172
|
+
<link rel="modulepreload" crossorigin href="./assets/markdown-renderer-D2XRRGdl.js">
|
|
173
173
|
<link rel="modulepreload" crossorigin href="./assets/dist-DOFFh6Ii.js">
|
|
174
|
-
<link rel="modulepreload" crossorigin href="./assets/command-
|
|
174
|
+
<link rel="modulepreload" crossorigin href="./assets/command-CyUURgqS.js">
|
|
175
175
|
<link rel="modulepreload" crossorigin href="./assets/popover-DtnzNVk-.js">
|
|
176
|
-
<link rel="modulepreload" crossorigin href="./assets/useRunCells-
|
|
177
|
-
<link rel="modulepreload" crossorigin href="./assets/mode-
|
|
176
|
+
<link rel="modulepreload" crossorigin href="./assets/useRunCells-d0gYuXYQ.js">
|
|
177
|
+
<link rel="modulepreload" crossorigin href="./assets/mode-j1jRJgw_.js">
|
|
178
178
|
<link rel="modulepreload" crossorigin href="./assets/purify.es-N-2faAGj.js">
|
|
179
|
-
<link rel="modulepreload" crossorigin href="./assets/RenderHTML-
|
|
179
|
+
<link rel="modulepreload" crossorigin href="./assets/RenderHTML-Daqo9pcD.js">
|
|
180
180
|
<link rel="modulepreload" crossorigin href="./assets/table--_20dwBZ.js">
|
|
181
181
|
<link rel="modulepreload" crossorigin href="./assets/tabs-Ctk4D03n.js">
|
|
182
182
|
<link rel="modulepreload" crossorigin href="./assets/useAsyncData-BJJJOr9W.js">
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
<link rel="modulepreload" crossorigin href="./assets/en-US-DhMN8sxe.js">
|
|
187
187
|
<link rel="modulepreload" crossorigin href="./assets/isValid-DhzaK-Y1.js">
|
|
188
188
|
<link rel="modulepreload" crossorigin href="./assets/dates-CdsE1R40.js">
|
|
189
|
-
<link rel="modulepreload" crossorigin href="./assets/download-
|
|
189
|
+
<link rel="modulepreload" crossorigin href="./assets/download-Bd63S7ca.js">
|
|
190
190
|
<link rel="modulepreload" crossorigin href="./assets/maps-s2pQkyf5.js">
|
|
191
191
|
<link rel="modulepreload" crossorigin href="./assets/extends-B9D0JO9U.js">
|
|
192
192
|
<link rel="modulepreload" crossorigin href="./assets/emotion-is-prop-valid.esm-lG8j6oqk.js">
|
|
@@ -194,47 +194,47 @@
|
|
|
194
194
|
<link rel="modulepreload" crossorigin href="./assets/range-sshwVRcP.js">
|
|
195
195
|
<link rel="modulepreload" crossorigin href="./assets/capitalize-DQeWKRGx.js">
|
|
196
196
|
<link rel="modulepreload" crossorigin href="./assets/table-BLx7B_us.js">
|
|
197
|
-
<link rel="modulepreload" crossorigin href="./assets/JsonOutput
|
|
197
|
+
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-B64aMW9B.js">
|
|
198
198
|
<link rel="modulepreload" crossorigin href="./assets/file-BnFXtaZZ.js">
|
|
199
199
|
<link rel="modulepreload" crossorigin href="./assets/play-BJDBXApx.js">
|
|
200
|
-
<link rel="modulepreload" crossorigin href="./assets/chat-components-
|
|
200
|
+
<link rel="modulepreload" crossorigin href="./assets/chat-components-CVdyP1VW.js">
|
|
201
201
|
<link rel="modulepreload" crossorigin href="./assets/isEmpty-DIxUV1UR.js">
|
|
202
202
|
<link rel="modulepreload" crossorigin href="./assets/circle-check-big-OIMTUpe6.js">
|
|
203
|
-
<link rel="modulepreload" crossorigin href="./assets/chat-display-
|
|
204
|
-
<link rel="modulepreload" crossorigin href="./assets/ai-model-dropdown-
|
|
203
|
+
<link rel="modulepreload" crossorigin href="./assets/chat-display-Bbzp0CzX.js">
|
|
204
|
+
<link rel="modulepreload" crossorigin href="./assets/ai-model-dropdown-nzo8MLQ5.js">
|
|
205
205
|
<link rel="modulepreload" crossorigin href="./assets/renderShortcut-D0Pei-OA.js">
|
|
206
|
-
<link rel="modulepreload" crossorigin href="./assets/useDeleteCell-
|
|
206
|
+
<link rel="modulepreload" crossorigin href="./assets/useDeleteCell-BIkFVvVx.js">
|
|
207
207
|
<link rel="modulepreload" crossorigin href="./assets/icons-D4lB4En9.js">
|
|
208
|
-
<link rel="modulepreload" crossorigin href="./assets/process-output-
|
|
208
|
+
<link rel="modulepreload" crossorigin href="./assets/process-output-DZorMbgK.js">
|
|
209
209
|
<link rel="modulepreload" crossorigin href="./assets/blob-Dg_vNTSs.js">
|
|
210
210
|
<link rel="modulepreload" crossorigin href="./assets/objectWithoutPropertiesLoose-CboCOq4o.js">
|
|
211
211
|
<link rel="modulepreload" crossorigin href="./assets/esm-B3JckBtM.js">
|
|
212
|
-
<link rel="modulepreload" crossorigin href="./assets/add-cell-with-ai-
|
|
212
|
+
<link rel="modulepreload" crossorigin href="./assets/add-cell-with-ai-BsHIKGwv.js">
|
|
213
213
|
<link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-D42sFB6d.js">
|
|
214
214
|
<link rel="modulepreload" crossorigin href="./assets/square-function-DxXFdbn8.js">
|
|
215
215
|
<link rel="modulepreload" crossorigin href="./assets/spec-qp_XZeSS.js">
|
|
216
|
-
<link rel="modulepreload" crossorigin href="./assets/column-preview-
|
|
217
|
-
<link rel="modulepreload" crossorigin href="./assets/switch-
|
|
216
|
+
<link rel="modulepreload" crossorigin href="./assets/column-preview-BlyFeHSu.js">
|
|
217
|
+
<link rel="modulepreload" crossorigin href="./assets/switch-Bf7BdNuP.js">
|
|
218
218
|
<link rel="modulepreload" crossorigin href="./assets/toggle-G1t0cQyf.js">
|
|
219
|
-
<link rel="modulepreload" crossorigin href="./assets/globals-
|
|
219
|
+
<link rel="modulepreload" crossorigin href="./assets/globals-BkITdONE.js">
|
|
220
220
|
<link rel="modulepreload" crossorigin href="./assets/share-CXQVxivL.js">
|
|
221
221
|
<link rel="modulepreload" crossorigin href="./assets/memoize-DN0TMY36.js">
|
|
222
222
|
<link rel="modulepreload" crossorigin href="./assets/get-CyLJYAfP.js">
|
|
223
223
|
<link rel="modulepreload" crossorigin href="./assets/_baseSet-6FYvpjrm.js">
|
|
224
224
|
<link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-BqxQegSf.js">
|
|
225
|
-
<link rel="modulepreload" crossorigin href="./assets/utilities.esm-
|
|
226
|
-
<link rel="modulepreload" crossorigin href="./assets/floating-outline-
|
|
227
|
-
<link rel="modulepreload" crossorigin href="./assets/useAddCell-
|
|
225
|
+
<link rel="modulepreload" crossorigin href="./assets/utilities.esm-Bs_5S-OE.js">
|
|
226
|
+
<link rel="modulepreload" crossorigin href="./assets/floating-outline-DmKm2GKv.js">
|
|
227
|
+
<link rel="modulepreload" crossorigin href="./assets/useAddCell-BEZy0w8u.js">
|
|
228
228
|
<link rel="modulepreload" crossorigin href="./assets/eye-off-D9zAYqG9.js">
|
|
229
229
|
<link rel="modulepreload" crossorigin href="./assets/plus-CHesBJpY.js">
|
|
230
|
-
<link rel="modulepreload" crossorigin href="./assets/readonly-python-code-
|
|
230
|
+
<link rel="modulepreload" crossorigin href="./assets/readonly-python-code-CzWlUPo8.js">
|
|
231
231
|
<link rel="modulepreload" crossorigin href="./assets/file-video-camera-CZUg-nFA.js">
|
|
232
|
-
<link rel="modulepreload" crossorigin href="./assets/types-
|
|
232
|
+
<link rel="modulepreload" crossorigin href="./assets/types-Dqr8wUa4.js">
|
|
233
233
|
<link rel="modulepreload" crossorigin href="./assets/label-qwandMoh.js">
|
|
234
|
-
<link rel="modulepreload" crossorigin href="./assets/textarea-
|
|
234
|
+
<link rel="modulepreload" crossorigin href="./assets/textarea-BRmAhRr_.js">
|
|
235
235
|
<link rel="modulepreload" crossorigin href="./assets/refresh-ccw-DbW1_PHb.js">
|
|
236
236
|
<link rel="modulepreload" crossorigin href="./assets/trash-2-C-lF7BNB.js">
|
|
237
|
-
<link rel="modulepreload" crossorigin href="./assets/form-
|
|
237
|
+
<link rel="modulepreload" crossorigin href="./assets/form-Cs-aYOue.js">
|
|
238
238
|
<link rel="modulepreload" crossorigin href="./assets/field-DDKGFzpC.js">
|
|
239
239
|
<link rel="modulepreload" crossorigin href="./assets/useBoolean-B-A0dyIW.js">
|
|
240
240
|
<link rel="modulepreload" crossorigin href="./assets/useDeepCompareMemoize-gzLRYatP.js">
|
package/package.json
CHANGED
package/src/components/editor/renderers/vertical-layout/__tests__/useFocusFirstEditor.test.ts
CHANGED
|
@@ -12,6 +12,8 @@ describe("useFocusFirstEditor", () => {
|
|
|
12
12
|
cb(0);
|
|
13
13
|
return 0;
|
|
14
14
|
});
|
|
15
|
+
// Mock document.hasFocus() to return true so focus logic runs
|
|
16
|
+
vi.spyOn(document, "hasFocus").mockReturnValue(true);
|
|
15
17
|
});
|
|
16
18
|
|
|
17
19
|
afterEach(() => {
|
|
@@ -120,4 +122,29 @@ describe("useFocusFirstEditor", () => {
|
|
|
120
122
|
writable: true,
|
|
121
123
|
});
|
|
122
124
|
});
|
|
125
|
+
|
|
126
|
+
it("should not focus when document does not have focus", () => {
|
|
127
|
+
// Mock document.hasFocus() to return false (e.g., when embedded in iframe)
|
|
128
|
+
vi.spyOn(document, "hasFocus").mockReturnValue(false);
|
|
129
|
+
|
|
130
|
+
const mockEditor = { focus: vi.fn() };
|
|
131
|
+
vi.spyOn(cellsModule, "getNotebook").mockReturnValue({
|
|
132
|
+
cellIds: { iterateTopLevelIds: ["cell-1"] },
|
|
133
|
+
cellData: {
|
|
134
|
+
"cell-1": { config: { hide_code: false } },
|
|
135
|
+
},
|
|
136
|
+
cellHandles: {
|
|
137
|
+
"cell-1": { current: { editorView: mockEditor } },
|
|
138
|
+
},
|
|
139
|
+
} as unknown as cellsModule.NotebookState);
|
|
140
|
+
|
|
141
|
+
renderHook(() => useFocusFirstEditor());
|
|
142
|
+
|
|
143
|
+
act(() => {
|
|
144
|
+
vi.advanceTimersByTime(100);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Focus should NOT be called when document doesn't have focus
|
|
148
|
+
expect(mockEditor.focus).not.toHaveBeenCalled();
|
|
149
|
+
});
|
|
123
150
|
});
|
|
@@ -19,6 +19,12 @@ export function useFocusFirstEditor() {
|
|
|
19
19
|
const timeout = setTimeout(() => {
|
|
20
20
|
// Let the DOM render
|
|
21
21
|
requestAnimationFrame(() => {
|
|
22
|
+
// Skip auto-focus if the document doesn't have focus to avoid
|
|
23
|
+
// stealing focus from outside (e.g., when embedded in an iframe)
|
|
24
|
+
if (!document.hasFocus()) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
// Check if the URL contains a scrollTo parameter
|
|
23
29
|
const hash = window.location.hash;
|
|
24
30
|
const cellName = extractCellNameFromHash(hash);
|
|
@@ -53,8 +53,9 @@ export function focusAndScrollCellIntoView({
|
|
|
53
53
|
Logger.warn("scrollCellIntoView: editor not found", cellId);
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
//
|
|
57
|
-
|
|
56
|
+
// Skip auto-focus if already focused, or if the document doesn't have
|
|
57
|
+
// focus to avoid stealing focus from outside (e.g., when embedded in an iframe)
|
|
58
|
+
if (editor.hasFocus || !document.hasFocus()) {
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
61
|
|