@marimo-team/frontend 0.20.5-dev3 → 0.20.5-dev5

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.
@@ -1 +1 @@
1
- import{s as fe}from"./chunk-LvLJmgfZ.js";import{d as E,l as Ge,p as Ye,u as ie}from"./useEvent-WUlsM6MC.js";import{t as $e}from"./react-Bj1aDYRI.js";import{Cn as Ke,En as Je,Gt as Xe,Nr as Ze,Sn as Qe,T as ye,_ as et,ar as tt,cr as at,dt as ke,h as be,lt as ot,pr as nt,pt as it,rr as st,t as lt,ut as rt,vi as se,xn as dt}from"./cells-CCtxWKxf.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{n as ct}from"./assertNever-Dw9aFN4h.js";import{s as xe}from"./useLifecycle-BDXC6oVR.js";import{a as ht,n as we}from"./add-connection-dialog-9CzjZlY9.js";import{n as pt,x as mt}from"./ai-model-dropdown-C3Y44M85.js";import{c as ge,m as I}from"./useEventListener-CjXriKgk.js";import{y as ut}from"./utils-CORJ8yYa.js";import{n as _,t as je}from"./constants-CdR60lKM.js";import{S as le,h as ft,x as yt}from"./config-D9X9QKiL.js";import{t as kt}from"./jsx-runtime-CP2fAiZX.js";import{r as bt,t as re}from"./button-BmOH9agK.js";import{r as L}from"./requests-DZy_SQ_v.js";import{t as h}from"./createLucideIcon-BvP5LBIs.js";import{a as ve,f as xt,i as Ce,m as wt,p as ze,u as We}from"./layout-DVAA7kHH.js";import{t as Me}from"./check-BnZGcuDh.js";import{c as gt,d as Se,n as jt,o as vt,r as _e,t as Ct}from"./download-BTm4CTKr.js";import{f as zt}from"./maps-8VTEe-0T.js";import{r as Wt}from"./useCellActionButton-DFgACqVf.js";import{t as Mt}from"./copy-CAR4dOiD.js";import{t as St}from"./download-BG-iMGgV.js";import{t as _t}from"./eye-off-DgTL09j7.js";import{t as Dt}from"./file-plus-corner-BRwJx0yp.js";import{t as Y}from"./file-DVwc11C3.js";import{t as At}from"./github-BrsjF9dp.js";import{m as Nt}from"./form-B7_NRa34.js";import{n as Pt,r as Et,t as It}from"./youtube-fKFch587.js";import{n as Lt,t as Tt}from"./square-oV8Csj8Y.js";import{i as Ht}from"./html-to-image-b9BimK8l.js";import{t as qt}from"./link-Cpo6yhBB.js";import{r as Rt}from"./input-BPldEXfy.js";import{t as Vt}from"./settings-DD8FJvQ_.js";import{x as Ft}from"./azure-Ddr1pZpW.js";import{t as C}from"./use-toast-BhMe50aT.js";import{n as De,t as Ot}from"./paths-bMgYkaP2.js";import{o as Ut}from"./session-DnMOyddG.js";import{a as Bt,c as Gt,i as Yt,n as $t,r as Kt,s as Jt,t as Xt}from"./select-DygbgNTD.js";import{t as Zt}from"./tooltip-DOQlecCr.js";import{o as Qt}from"./alert-dialog-DsNfSYaw.js";import{a as ea,c as ta,i as aa,n as oa,r as na}from"./dialog-BXzvlof-.js";import{n as de}from"./ImperativeModal-CRNJOvqT.js";import{r as ia,t as sa}from"./share-sD4fbzpH.js";import{t as $}from"./copy-DMCkK2TI.js";import{a as la}from"./cell-link-B59Kn5nL.js";import{a as ra}from"./renderShortcut-BJEd-iA7.js";import{t as da}from"./icons-B9sHgc9n.js";import{t as ca}from"./links-syPBpTLO.js";import{r as ha,t as pa}from"./hooks-BY6oGAlX.js";import{t as Ae}from"./types-Myu7G9iV.js";var ma=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),ua=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ne=h("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"}]]),Pe=h("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"}]]),Ee=h("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"}]]),fa=h("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"}]]),ya=h("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"}]]),ka=h("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"}]]),Ie=h("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"}]]),ba=h("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"}]]),xa=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Le=h("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"}]]),wa=h("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"}]]),ga=h("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"}]]),Te=h("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"}]]),He=S(),ce=fe($e(),1),a=fe(kt(),1),K="https://static.marimo.app";const ja=e=>{let t=(0,He.c)(25),{onClose:n}=e,[o,s]=(0,ce.useState)(""),{exportAsHTML:r}=L(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${K}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let A=await r({download:!1,includeCode:!0,files:xt.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${K}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:A,path:l})}).catch(()=>{z.dismiss(),C({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(),C({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]=n,t[2]=l,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(ta,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(ea,{children:[p,(0,a.jsxs)(na,{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:K,target:"_blank",children:K}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(Rt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(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)(va,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let y;t[11]!==u||t[12]!==f?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=y):y=t[13];let k;t[14]===n?k=t[15]:(k=(0,a.jsx)(re,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=k);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(re,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await $(i)},children:"Create"}),t[16]=i,t[17]=b);let x;t[18]!==k||t[19]!==b?(x=(0,a.jsxs)(aa,{children:[k,b]}),t[18]=k,t[19]=b,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==y?(j=(0,a.jsx)(oa,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,y,x]})}),t[21]=d,t[22]=x,t[23]=y,t[24]=j):j=t[24],j};var va=e=>{let t=(0,He.c)(8),[n,o]=ce.useState(!1),s;t[0]===e.text?s=t[1]:(s=bt.stopPropagation(async p=>{p.preventDefault(),await $(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Mt,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(re,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Zt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},Ca=S();function za(){let e=document.getElementsByClassName(je.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=se.findElement(t);if(!o){I.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:se.parse(o.id)}}}return I.warn("No visible output area found for scroll anchor"),null}function Wa(e){if(!e){I.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(se.create(e.cellId));if(!t){I.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${je.outputArea}`)){I.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function qe(){let e=(0,Ca.c)(2),t=E(ke),n;return e[0]===t?n=e[1]:(n=()=>{let o=za();t(s=>({mode:rt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Wa(o)})})},e[0]=t,e[1]=n),n}const Re=Ye(!1);var Ma=S();const Sa=()=>{let e=(0,Ma.c)(7),{selectedLayout:t}=ve(),{setLayoutView:n}=Ce();if(le()&&!Je("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Jt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Gt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)($t,{children:(0,a.jsxs)(Kt,{children:[(0,a.jsx)(Bt,{children:"View as"}),Ae.map(Da)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Xt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function _a(e){return(0,a.jsx)(Ve(e),{className:"h-4 w-4"})}function Ve(e){switch(e){case"vertical":return ba;case"grid":return Et;case"slides":return Le;default:return ct(e),Tt}}function Fe(e){return xe(e)}function Da(e){return(0,a.jsx)(Yt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[_a(e),(0,a.jsx)("span",{children:Fe(e)})]})},e)}async function Aa(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Na=S();function Pa(e){let t=(0,Na.c)(5),{openPrompt:n,closeModal:o}=de(),{sendCopy:s}=L(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=Ot.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${De.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(De.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),ca(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Ea=()=>{let{updateCellConfig:e}=ye(),{saveCellConfig:t}=L();return(0,ce.useCallback)(async()=>{let n=new Xe,o=be(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:d,config:p}=o.cellData[i];p.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let l=ge.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var Ia=S();function Oe(){let e=(0,Ia.c)(4),{openConfirm:t}=de(),n=E(ft),{sendRestart:o}=L(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{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()=>{n({state:yt.CLOSING}),await o(),ia()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var La=S(),D=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Ta(){var me,ue;let e=(0,La.c)(45),t=la(),{openModal:n,closeModal:o}=de(),{toggleApplication:s}=dt(),{selectedPanel:r}=Qe(),[l]=Ge(ke),i=ie(ot),d=Ea(),[p]=ut(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:y,expandAllCells:k}=ye(),b=Oe(),x=it(),j=Pa(t),v=E(Re),A=E(pt),z=E(mt),{exportAsMarkdown:J,readCode:N,saveCellConfig:X,updateCellOutputs:Z}=L(),Q=ha(),ee=ie(et),te=ie(lt),{selectedLayout:T}=ve(),{setLayoutView:ae}=Ce(),H=qe(),q=((me=p.sharing)==null?void 0:me.html)??!0,R=((ue=p.sharing)==null?void 0:ue.wasm)??!0,pe=!le(),oe=T==="slides",Ue=to,Be=eo,V;e[0]!==t||e[1]!==Q||e[2]!==Z?(V=async c=>{let{preset:m,title:P}=c;if(!t){he();return}await gt(P,async ne=>{await pa({takeScreenshots:()=>Q({progress:ne}),updateCellOutputs:Z}),await Aa({filename:t,preset:m,downloadPDF:jt})})},e[0]=t,e[1]=Q,e[2]=Z,e[3]=V):V=e[3];let W=V,F;e[4]===W?F=e[5]:(F=async()=>{if(pe){await W({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),m=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(Qa,0),setTimeout(()=>window.dispatchEvent(m),0)},e[4]=W,e[5]=F);let O=F,U;e[6]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(St,{size:14,strokeWidth:1.5}),e[6]=U):U=e[6];let B;e[7]===Symbol.for("react.memo_cache_sentinel")?(B=(0,a.jsx)(ze,{size:14,strokeWidth:1.5}),e[7]=B):B=e[7];let M;e[8]===t?M=e[9]:(M=async()=>{if(!t){he();return}await We({filename:t,includeCode:!0})},e[8]=t,e[9]=M);let G;return e[10]!==f||e[11]!==te||e[12]!==u||e[13]!==o||e[14]!==y||e[15]!==j||e[16]!==W||e[17]!==k||e[18]!==J||e[19]!==t||e[20]!==O||e[21]!==ee||e[22]!==d||e[23]!==oe||e[24]!==i||e[25]!==n||e[26]!==N||e[27]!==b||e[28]!==x||e[29]!==X||e[30]!==T||e[31]!==r||e[32]!==v||e[33]!==z||e[34]!==ae||e[35]!==A||e[36]!==q||e[37]!==R||e[38]!==M||e[39]!==s||e[40]!==H||e[41]!==g||e[42]!==w||e[43]!==l.mode?(G=[{icon:U,label:"Download",handle:D,dropdown:[{icon:B,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(ze,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){he();return}await We({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(da,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await J({download:!1});_e(new Blob([c],{type:"text/plain"}),Se.toMarkdown(document.title))}},{icon:(0,a.jsx)(wt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await N();_e(new Blob([c.contents],{type:"text/plain"}),Se.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Ht,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",ra("global.hideCode",!1)]}),handle:Za},oe?{divider:!0,icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:D,dropdown:[{icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:O},{icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:Be(!0),hidden:!pe,handle:async()=>{await W({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:O}]},{icon:(0,a.jsx)(wa,{size:14,strokeWidth:1.5}),label:"Share",handle:D,hidden:!q&&!R,dropdown:[{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!q,handle:async()=>{n((0,a.jsx)(ja,{onClose:o}))}},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!R,handle:async()=>{await $(sa({code:(await N()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(xa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:D,dropdown:Ke.flatMap(c=>{let{type:m,Icon:P,hidden:ne}=c;return ne?[]:{label:xe(m),rightElement:Ue(r===m),icon:(0,a.jsx)(P,{size:14,strokeWidth:1.5}),handle:()=>s(m)}})},{icon:(0,a.jsx)(Le,{size:14,strokeWidth:1.5}),label:"Present as",handle:D,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{H()}},...Ae.map((c,m)=>{let P=Ve(c);return{divider:m===0,label:Fe(c),icon:(0,a.jsx)(P,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:T===c&&(0,a.jsx)(Me,{size:14})}),handle:()=>{ae(c),l.mode==="edit"&&H()}}})]},{icon:(0,a.jsx)(ya,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||le(),handle:j},{icon:(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await $((await N()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!ee||i,handle:async()=>{let c=Ze(be());await X({configs:ge.fromEntries(c.map(Xa))});for(let m of c)w({cellId:m,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(tt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(we,{onClose:o}))}},{icon:(0,a.jsx)(ht,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(we,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!te||i,handle:()=>{g()}},{icon:(0,a.jsx)(ga,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(at,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:y,redundant:!0},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:k,redundant:!0},{divider:!0,icon:(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ja)},{icon:(0,a.jsx)(ka,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Ka)},{icon:(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>A($a),redundant:!0},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Resources",handle:D,dropdown:[{icon:(0,a.jsx)(nt,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Ya},{icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Ga},{icon:(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Ba},{icon:(0,a.jsx)(It,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Ua},{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Oa}]},{divider:!0,icon:(0,a.jsx)(Lt,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Fa},{icon:(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Va}].filter(Ra).map(Ha),e[10]=f,e[11]=te,e[12]=u,e[13]=o,e[14]=y,e[15]=j,e[16]=W,e[17]=k,e[18]=J,e[19]=t,e[20]=O,e[21]=ee,e[22]=d,e[23]=oe,e[24]=i,e[25]=n,e[26]=N,e[27]=b,e[28]=x,e[29]=X,e[30]=T,e[31]=r,e[32]=v,e[33]=z,e[34]=ae,e[35]=A,e[36]=q,e[37]=R,e[38]=M,e[39]=s,e[40]=H,e[41]=g,e[42]=w,e[43]=l.mode,e[44]=G):G=e[44],G}function Ha(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(qa)}:e}function qa(e){return!e.hidden}function Ra(e){return!e.hidden}function Va(){let e=Ut();window.open(e,"_blank")}function Fa(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Oa(){window.open(_.releasesPage,"_blank")}function Ua(){window.open(_.youtube,"_blank")}function Ba(){window.open(_.discordLink,"_blank")}function Ga(){window.open(_.githubPage,"_blank")}function Ya(){window.open(_.docsPage,"_blank")}function $a(e){return!e}function Ka(e){return!e}function Ja(e){return!e}function Xa(e){return[e,{disabled:!1}]}async function Za(){let e=document.getElementById("App");e&&await vt({element:e,filename:document.title,prepare:Ct})}function Qa(){return window.print()}function eo(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function to(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Me,{size:14})})}function he(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{qe as a,Ee as c,Re as i,Pe as l,Oe as n,Te as o,Sa as r,Ie as s,Ta as t,Ne as u};
1
+ import{s as fe}from"./chunk-LvLJmgfZ.js";import{d as E,l as Ge,p as Ye,u as ie}from"./useEvent-WUlsM6MC.js";import{t as $e}from"./react-Bj1aDYRI.js";import{Cn as Ke,En as Je,Gt as Xe,Nr as Ze,Sn as Qe,T as ye,_ as et,ar as tt,cr as at,dt as ke,h as be,lt as ot,pr as nt,pt as it,rr as st,t as lt,ut as rt,vi as se,xn as dt}from"./cells-CCtxWKxf.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{n as ct}from"./assertNever-Dw9aFN4h.js";import{s as xe}from"./useLifecycle-BDXC6oVR.js";import{a as ht,n as we}from"./add-connection-dialog-9CzjZlY9.js";import{n as pt,x as mt}from"./ai-model-dropdown-C3Y44M85.js";import{c as ge,m as I}from"./useEventListener-CjXriKgk.js";import{y as ut}from"./utils-CORJ8yYa.js";import{n as _,t as je}from"./constants-CdR60lKM.js";import{S as le,h as ft,x as yt}from"./config-D9X9QKiL.js";import{t as kt}from"./jsx-runtime-CP2fAiZX.js";import{r as bt,t as re}from"./button-BmOH9agK.js";import{r as L}from"./requests-DZy_SQ_v.js";import{t as h}from"./createLucideIcon-BvP5LBIs.js";import{a as ve,f as xt,i as Ce,m as wt,p as ze,u as We}from"./layout-DcfIrJXW.js";import{t as Me}from"./check-BnZGcuDh.js";import{c as gt,d as Se,n as jt,o as vt,r as _e,t as Ct}from"./download-BTm4CTKr.js";import{f as zt}from"./maps-8VTEe-0T.js";import{r as Wt}from"./useCellActionButton-DFgACqVf.js";import{t as Mt}from"./copy-CAR4dOiD.js";import{t as St}from"./download-BG-iMGgV.js";import{t as _t}from"./eye-off-DgTL09j7.js";import{t as Dt}from"./file-plus-corner-BRwJx0yp.js";import{t as Y}from"./file-DVwc11C3.js";import{t as At}from"./github-BrsjF9dp.js";import{m as Nt}from"./form-B7_NRa34.js";import{n as Pt,r as Et,t as It}from"./youtube-fKFch587.js";import{n as Lt,t as Tt}from"./square-oV8Csj8Y.js";import{i as Ht}from"./html-to-image-b9BimK8l.js";import{t as qt}from"./link-Cpo6yhBB.js";import{r as Rt}from"./input-BPldEXfy.js";import{t as Vt}from"./settings-DD8FJvQ_.js";import{x as Ft}from"./azure-Ddr1pZpW.js";import{t as C}from"./use-toast-BhMe50aT.js";import{n as De,t as Ot}from"./paths-bMgYkaP2.js";import{o as Ut}from"./session-DnMOyddG.js";import{a as Bt,c as Gt,i as Yt,n as $t,r as Kt,s as Jt,t as Xt}from"./select-DygbgNTD.js";import{t as Zt}from"./tooltip-DOQlecCr.js";import{o as Qt}from"./alert-dialog-DsNfSYaw.js";import{a as ea,c as ta,i as aa,n as oa,r as na}from"./dialog-BXzvlof-.js";import{n as de}from"./ImperativeModal-CRNJOvqT.js";import{r as ia,t as sa}from"./share-sD4fbzpH.js";import{t as $}from"./copy-DMCkK2TI.js";import{a as la}from"./cell-link-B59Kn5nL.js";import{a as ra}from"./renderShortcut-BJEd-iA7.js";import{t as da}from"./icons-B9sHgc9n.js";import{t as ca}from"./links-syPBpTLO.js";import{r as ha,t as pa}from"./hooks-BllYlfDO.js";import{t as Ae}from"./types-Myu7G9iV.js";var ma=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),ua=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ne=h("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"}]]),Pe=h("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"}]]),Ee=h("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"}]]),fa=h("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"}]]),ya=h("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"}]]),ka=h("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"}]]),Ie=h("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"}]]),ba=h("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"}]]),xa=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Le=h("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"}]]),wa=h("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"}]]),ga=h("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"}]]),Te=h("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"}]]),He=S(),ce=fe($e(),1),a=fe(kt(),1),K="https://static.marimo.app";const ja=e=>{let t=(0,He.c)(25),{onClose:n}=e,[o,s]=(0,ce.useState)(""),{exportAsHTML:r}=L(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${K}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let A=await r({download:!1,includeCode:!0,files:xt.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${K}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:A,path:l})}).catch(()=>{z.dismiss(),C({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(),C({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]=n,t[2]=l,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(ta,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(ea,{children:[p,(0,a.jsxs)(na,{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:K,target:"_blank",children:K}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(Rt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(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)(va,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let y;t[11]!==u||t[12]!==f?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=y):y=t[13];let k;t[14]===n?k=t[15]:(k=(0,a.jsx)(re,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=k);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(re,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await $(i)},children:"Create"}),t[16]=i,t[17]=b);let x;t[18]!==k||t[19]!==b?(x=(0,a.jsxs)(aa,{children:[k,b]}),t[18]=k,t[19]=b,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==y?(j=(0,a.jsx)(oa,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,y,x]})}),t[21]=d,t[22]=x,t[23]=y,t[24]=j):j=t[24],j};var va=e=>{let t=(0,He.c)(8),[n,o]=ce.useState(!1),s;t[0]===e.text?s=t[1]:(s=bt.stopPropagation(async p=>{p.preventDefault(),await $(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Mt,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(re,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Zt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},Ca=S();function za(){let e=document.getElementsByClassName(je.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=se.findElement(t);if(!o){I.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:se.parse(o.id)}}}return I.warn("No visible output area found for scroll anchor"),null}function Wa(e){if(!e){I.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(se.create(e.cellId));if(!t){I.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${je.outputArea}`)){I.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function qe(){let e=(0,Ca.c)(2),t=E(ke),n;return e[0]===t?n=e[1]:(n=()=>{let o=za();t(s=>({mode:rt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Wa(o)})})},e[0]=t,e[1]=n),n}const Re=Ye(!1);var Ma=S();const Sa=()=>{let e=(0,Ma.c)(7),{selectedLayout:t}=ve(),{setLayoutView:n}=Ce();if(le()&&!Je("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Jt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Gt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)($t,{children:(0,a.jsxs)(Kt,{children:[(0,a.jsx)(Bt,{children:"View as"}),Ae.map(Da)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Xt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function _a(e){return(0,a.jsx)(Ve(e),{className:"h-4 w-4"})}function Ve(e){switch(e){case"vertical":return ba;case"grid":return Et;case"slides":return Le;default:return ct(e),Tt}}function Fe(e){return xe(e)}function Da(e){return(0,a.jsx)(Yt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[_a(e),(0,a.jsx)("span",{children:Fe(e)})]})},e)}async function Aa(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Na=S();function Pa(e){let t=(0,Na.c)(5),{openPrompt:n,closeModal:o}=de(),{sendCopy:s}=L(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=Ot.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${De.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(De.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),ca(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Ea=()=>{let{updateCellConfig:e}=ye(),{saveCellConfig:t}=L();return(0,ce.useCallback)(async()=>{let n=new Xe,o=be(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:d,config:p}=o.cellData[i];p.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let l=ge.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var Ia=S();function Oe(){let e=(0,Ia.c)(4),{openConfirm:t}=de(),n=E(ft),{sendRestart:o}=L(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{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()=>{n({state:yt.CLOSING}),await o(),ia()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var La=S(),D=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Ta(){var me,ue;let e=(0,La.c)(45),t=la(),{openModal:n,closeModal:o}=de(),{toggleApplication:s}=dt(),{selectedPanel:r}=Qe(),[l]=Ge(ke),i=ie(ot),d=Ea(),[p]=ut(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:y,expandAllCells:k}=ye(),b=Oe(),x=it(),j=Pa(t),v=E(Re),A=E(pt),z=E(mt),{exportAsMarkdown:J,readCode:N,saveCellConfig:X,updateCellOutputs:Z}=L(),Q=ha(),ee=ie(et),te=ie(lt),{selectedLayout:T}=ve(),{setLayoutView:ae}=Ce(),H=qe(),q=((me=p.sharing)==null?void 0:me.html)??!0,R=((ue=p.sharing)==null?void 0:ue.wasm)??!0,pe=!le(),oe=T==="slides",Ue=to,Be=eo,V;e[0]!==t||e[1]!==Q||e[2]!==Z?(V=async c=>{let{preset:m,title:P}=c;if(!t){he();return}await gt(P,async ne=>{await pa({takeScreenshots:()=>Q({progress:ne}),updateCellOutputs:Z}),await Aa({filename:t,preset:m,downloadPDF:jt})})},e[0]=t,e[1]=Q,e[2]=Z,e[3]=V):V=e[3];let W=V,F;e[4]===W?F=e[5]:(F=async()=>{if(pe){await W({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),m=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(Qa,0),setTimeout(()=>window.dispatchEvent(m),0)},e[4]=W,e[5]=F);let O=F,U;e[6]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(St,{size:14,strokeWidth:1.5}),e[6]=U):U=e[6];let B;e[7]===Symbol.for("react.memo_cache_sentinel")?(B=(0,a.jsx)(ze,{size:14,strokeWidth:1.5}),e[7]=B):B=e[7];let M;e[8]===t?M=e[9]:(M=async()=>{if(!t){he();return}await We({filename:t,includeCode:!0})},e[8]=t,e[9]=M);let G;return e[10]!==f||e[11]!==te||e[12]!==u||e[13]!==o||e[14]!==y||e[15]!==j||e[16]!==W||e[17]!==k||e[18]!==J||e[19]!==t||e[20]!==O||e[21]!==ee||e[22]!==d||e[23]!==oe||e[24]!==i||e[25]!==n||e[26]!==N||e[27]!==b||e[28]!==x||e[29]!==X||e[30]!==T||e[31]!==r||e[32]!==v||e[33]!==z||e[34]!==ae||e[35]!==A||e[36]!==q||e[37]!==R||e[38]!==M||e[39]!==s||e[40]!==H||e[41]!==g||e[42]!==w||e[43]!==l.mode?(G=[{icon:U,label:"Download",handle:D,dropdown:[{icon:B,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(ze,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){he();return}await We({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(da,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await J({download:!1});_e(new Blob([c],{type:"text/plain"}),Se.toMarkdown(document.title))}},{icon:(0,a.jsx)(wt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await N();_e(new Blob([c.contents],{type:"text/plain"}),Se.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Ht,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",ra("global.hideCode",!1)]}),handle:Za},oe?{divider:!0,icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:D,dropdown:[{icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:O},{icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:Be(!0),hidden:!pe,handle:async()=>{await W({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:O}]},{icon:(0,a.jsx)(wa,{size:14,strokeWidth:1.5}),label:"Share",handle:D,hidden:!q&&!R,dropdown:[{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!q,handle:async()=>{n((0,a.jsx)(ja,{onClose:o}))}},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!R,handle:async()=>{await $(sa({code:(await N()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(xa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:D,dropdown:Ke.flatMap(c=>{let{type:m,Icon:P,hidden:ne}=c;return ne?[]:{label:xe(m),rightElement:Ue(r===m),icon:(0,a.jsx)(P,{size:14,strokeWidth:1.5}),handle:()=>s(m)}})},{icon:(0,a.jsx)(Le,{size:14,strokeWidth:1.5}),label:"Present as",handle:D,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{H()}},...Ae.map((c,m)=>{let P=Ve(c);return{divider:m===0,label:Fe(c),icon:(0,a.jsx)(P,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:T===c&&(0,a.jsx)(Me,{size:14})}),handle:()=>{ae(c),l.mode==="edit"&&H()}}})]},{icon:(0,a.jsx)(ya,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||le(),handle:j},{icon:(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await $((await N()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!ee||i,handle:async()=>{let c=Ze(be());await X({configs:ge.fromEntries(c.map(Xa))});for(let m of c)w({cellId:m,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(tt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(we,{onClose:o}))}},{icon:(0,a.jsx)(ht,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(we,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!te||i,handle:()=>{g()}},{icon:(0,a.jsx)(ga,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(at,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:y,redundant:!0},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:k,redundant:!0},{divider:!0,icon:(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ja)},{icon:(0,a.jsx)(ka,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Ka)},{icon:(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>A($a),redundant:!0},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Resources",handle:D,dropdown:[{icon:(0,a.jsx)(nt,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Ya},{icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Ga},{icon:(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Ba},{icon:(0,a.jsx)(It,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Ua},{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Oa}]},{divider:!0,icon:(0,a.jsx)(Lt,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Fa},{icon:(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Va}].filter(Ra).map(Ha),e[10]=f,e[11]=te,e[12]=u,e[13]=o,e[14]=y,e[15]=j,e[16]=W,e[17]=k,e[18]=J,e[19]=t,e[20]=O,e[21]=ee,e[22]=d,e[23]=oe,e[24]=i,e[25]=n,e[26]=N,e[27]=b,e[28]=x,e[29]=X,e[30]=T,e[31]=r,e[32]=v,e[33]=z,e[34]=ae,e[35]=A,e[36]=q,e[37]=R,e[38]=M,e[39]=s,e[40]=H,e[41]=g,e[42]=w,e[43]=l.mode,e[44]=G):G=e[44],G}function Ha(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(qa)}:e}function qa(e){return!e.hidden}function Ra(e){return!e.hidden}function Va(){let e=Ut();window.open(e,"_blank")}function Fa(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Oa(){window.open(_.releasesPage,"_blank")}function Ua(){window.open(_.youtube,"_blank")}function Ba(){window.open(_.discordLink,"_blank")}function Ga(){window.open(_.githubPage,"_blank")}function Ya(){window.open(_.docsPage,"_blank")}function $a(e){return!e}function Ka(e){return!e}function Ja(e){return!e}function Xa(e){return[e,{disabled:!1}]}async function Za(){let e=document.getElementById("App");e&&await vt({element:e,filename:document.title,prepare:Ct})}function Qa(){return window.print()}function eo(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function to(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Me,{size:14})})}function he(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{qe as a,Ee as c,Re as i,Pe as l,Oe as n,Te as o,Sa as r,Ie as s,Ta as t,Ne as u};
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-B8ImLAg8.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-Dt_vPSmJ.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-TXkS1QI3.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/clsx-A78R3nYl.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/cn-d_A4rA-x.js">
@@ -206,7 +206,7 @@
206
206
  <link rel="modulepreload" crossorigin href="./assets/useDateFormatter-CmtFqjqu.js">
207
207
  <link rel="modulepreload" crossorigin href="./assets/range-BGa3qZre.js">
208
208
  <link rel="modulepreload" crossorigin href="./assets/table-CeILsq6V.js">
209
- <link rel="modulepreload" crossorigin href="./assets/JsonOutput-GlMQ3aLA.js">
209
+ <link rel="modulepreload" crossorigin href="./assets/JsonOutput-BW2KjuuO.js">
210
210
  <link rel="modulepreload" crossorigin href="./assets/useDeleteCell-BAfiIxKf.js">
211
211
  <link rel="modulepreload" crossorigin href="./assets/icons-B9sHgc9n.js">
212
212
  <link rel="modulepreload" crossorigin href="./assets/process-output-4yip1nZE.js">
@@ -223,13 +223,13 @@
223
223
  <link rel="modulepreload" crossorigin href="./assets/square-function-4zY5Dv0P.js">
224
224
  <link rel="modulepreload" crossorigin href="./assets/spec-Be-iRLAY.js">
225
225
  <link rel="modulepreload" crossorigin href="./assets/components-CF9x5raB.js">
226
- <link rel="modulepreload" crossorigin href="./assets/column-preview-BhU5Ow0e.js">
226
+ <link rel="modulepreload" crossorigin href="./assets/column-preview-Bd1U8JUS.js">
227
227
  <link rel="modulepreload" crossorigin href="./assets/toggle-BhEcsHTu.js">
228
228
  <link rel="modulepreload" crossorigin href="./assets/globals-BlB0Ba6E.js">
229
229
  <link rel="modulepreload" crossorigin href="./assets/share-sD4fbzpH.js">
230
230
  <link rel="modulepreload" crossorigin href="./assets/_baseSet-BEHvSeoM.js">
231
231
  <link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-RgA6v8U3.js">
232
- <link rel="modulepreload" crossorigin href="./assets/context-aware-panel-HnyO4-L2.js">
232
+ <link rel="modulepreload" crossorigin href="./assets/context-aware-panel-C1uqjYZU.js">
233
233
  <link rel="modulepreload" crossorigin href="./assets/floating-outline-BWK_nLJy.js">
234
234
  <link rel="modulepreload" crossorigin href="./assets/useAddCell-BRlAqdmq.js">
235
235
  <link rel="modulepreload" crossorigin href="./assets/eye-off-DgTL09j7.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.20.5-dev3",
3
+ "version": "0.20.5-dev5",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -37,6 +37,8 @@ import {
37
37
  } from "../ui/select";
38
38
  import type { DataTableSelection, PageRange } from "./types";
39
39
 
40
+ const MAX_PAGES_BEFORE_CLAMPING = 100;
41
+
40
42
  interface DataTablePaginationProps<TData> {
41
43
  table: Table<TData>;
42
44
  selection?: DataTableSelection;
@@ -325,35 +327,39 @@ export const PageSelector = ({
325
327
  ),
326
328
  )}
327
329
  </div>
328
- <DropdownMenuSeparator />
329
- <div
330
- className="px-2 pt-0.5 shrink-0"
331
- onKeyDown={(e) => e.stopPropagation()}
332
- >
333
- <label
334
- htmlFor={jumpInputId}
335
- className="text-xs text-muted-foreground block mb-1"
336
- >
337
- Jump to page
338
- </label>
339
- <Input
340
- id={jumpInputId}
341
- type="number"
342
- min={1}
343
- max={totalPages}
344
- placeholder={`1-${totalPages}`}
345
- value={jumpValue}
346
- onChange={(e) => setJumpValue(e.target.value)}
347
- onKeyDown={(e) => {
348
- if (e.key === "Enter") {
349
- handleJump();
350
- }
351
- e.stopPropagation();
352
- }}
353
- className="h-6 text-xs"
354
- data-testid="page-jump-input"
355
- />
356
- </div>
330
+ {totalPages > MAX_PAGES_BEFORE_CLAMPING && (
331
+ <>
332
+ <DropdownMenuSeparator />
333
+ <div
334
+ className="px-2 pt-0.5 shrink-0"
335
+ onKeyDown={(e) => e.stopPropagation()}
336
+ >
337
+ <label
338
+ htmlFor={jumpInputId}
339
+ className="text-xs text-muted-foreground block mb-1"
340
+ >
341
+ Jump to page
342
+ </label>
343
+ <Input
344
+ id={jumpInputId}
345
+ type="number"
346
+ min={1}
347
+ max={totalPages}
348
+ placeholder={`1-${totalPages}`}
349
+ value={jumpValue}
350
+ onChange={(e) => setJumpValue(e.target.value)}
351
+ onKeyDown={(e) => {
352
+ if (e.key === "Enter") {
353
+ handleJump();
354
+ }
355
+ e.stopPropagation();
356
+ }}
357
+ className="h-6 text-xs"
358
+ data-testid="page-jump-input"
359
+ />
360
+ </div>
361
+ </>
362
+ )}
357
363
  </DropdownMenuContent>
358
364
  </DropdownMenu>
359
365
  );
@@ -363,7 +369,7 @@ export function getPageRanges(
363
369
  currentPage: number,
364
370
  totalPages: number,
365
371
  ): PageRange[] {
366
- if (totalPages <= 100) {
372
+ if (totalPages <= MAX_PAGES_BEFORE_CLAMPING) {
367
373
  return range(totalPages).map((i) => ({ type: "page", page: i + 1 }));
368
374
  }
369
375