@marimo-team/frontend 0.23.11-dev11 → 0.23.11-dev13

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.
@@ -0,0 +1 @@
1
+ import{s as We}from"./chunk-LvLJmgfZ.js";import{d as L,l as it,p as st,u as P}from"./useEvent-D91BmmQi.js";import{t as lt}from"./react-Bj1aDYRI.js";import{An as rt,Cr as dt,D as Me,E as ct,Mn as ht,Nn as pt,On as mt,Or as ut,Qt as ft,Tn as bt,Vi as be,_ as yt,br as kt,ct as xt,dt as De,ei as wt,h as _e,kn as gt,lt as jt,t as vt,vr as Ct}from"./cells-D-v2lBet.js";import{t as I}from"./compiler-runtime-B3qBwwSJ.js";import{n as zt,r as Wt,x as Mt}from"./ai-model-dropdown-rE64ytSX.js";import{_ as H,d as Se}from"./useEventListener-DvoEXWke.js";import{r as Dt,x as _t}from"./utils-CvI-39U6.js";import{n as z,t as Ae}from"./constants-DMpttj8Q.js";import{T as X,v as St,w as At}from"./config-ClMcu_sV.js";import{t as Nt}from"./jsx-runtime-BqBOg78p.js";import{o as Pt}from"./alert-dialog-5BGIfskO.js";import{a as It,c as Et,i as Tt,n as Lt,r as Ht,s as Rt,t as qt}from"./select-6suE6YM2.js";import{Nt as Ot}from"./JsonOutput-uEJijGXp.js";import{c as Ne,d as ye,n as Bt,o as Vt,r as ke,t as Ft}from"./download-WGU5w_3m.js";import{t as Yt}from"./tooltip-B_PkSKN3.js";import{r as $t,t as xe}from"./button-BbCh-29a.js";import{i as Kt,t as Pe}from"./strings-wdPMRf6Z.js";import{r as R}from"./requests-DIwGYs0l.js";import{t as h}from"./createLucideIcon-D5guW7EU.js";import{F as Ut,I as Gt,L as Ie,P as Jt,R as Qt,a as Ee,i as Te,u as Le}from"./layout-ks0WJ2vR.js";import{t as He}from"./check-BH35Ndha.js";import{r as Xt}from"./useCellActionButton-CtOZIXD0.js";import{t as Zt}from"./copy-BwrPA9zQ.js";import{t as ea}from"./eye-off-Cm6DdkeR.js";import{t as ta}from"./external-link-BTNxSavU.js";import{t as Z}from"./file-BrdxGLRX.js";import{t as aa}from"./github-BKS_2Qwn.js";import{u as oa}from"./form-CVBFx2z3.js";import{n as na,r as ia,t as sa}from"./youtube-CbdpN8oL.js";import{i as la,n as Re}from"./add-connection-dialog-ZyXXfAVG.js";import{t as ra}from"./house-mGK3v0Mm.js";import{t as da}from"./image-DQHXdEQn.js";import{t as ca}from"./link-CfEtM3Rl.js";import{r as ha}from"./input-DA8xlX70.js";import{t as pa}from"./settings-DfFe0dWD.js";import{t as ma}from"./sparkles-lWUAsPhp.js";import{y as ua}from"./textarea-CBbixTxi.js";import{t as fa}from"./square-B5xWCt0a.js";import{t as W}from"./use-toast-CJ1Tj2eC.js";import{n as qe,t as ba}from"./paths-D5zczhUD.js";import{o as ya}from"./session-0B5NBztP.js";import{n as ee}from"./copy-LK56fFow.js";import{r as ka}from"./useRunCells-BClkx9Pq.js";import{a as xa,c as wa,i as ga,n as ja,r as va}from"./dialog-DRnNAWYl.js";import{n as we}from"./ImperativeModal-BW1dmntO.js";import{r as Ca,t as Oe}from"./share-mSf5FZIP.js";import{a as za}from"./cell-link-DY95GSb7.js";import{a as Wa}from"./renderShortcut--ku7VECI.js";import{t as Ma}from"./icons-Ol38nIbL.js";import{t as Da}from"./pair-with-agent-modal-_SlYEcmZ.js";import{n as Be}from"./marimo-icons-CLbC-oB3.js";import{t as _a}from"./links-DoPgJNku.js";import{r as Sa,t as Ve}from"./hooks-83y0XCiC.js";import{t as Fe}from"./types-Cpe-qFT-.js";var Aa=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Na=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ye=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"}]]),$e=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"}]]),Ke=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"}]]),Pa=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"}]]),Ia=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"}]]),Ea=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"}]]),Ta=h("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),La=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ue=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"}]]),Ha=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"}]]),Ra=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"}]]),Ge=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"}]]),Je=I(),ge=We(lt(),1),a=We(Nt(),1),te="https://static.marimo.app";const qa=e=>{let t=(0,Je.c)(25),{onClose:n}=e,[o,s]=(0,ge.useState)(""),{exportAsHTML:r}=R(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${te}/static/${l}`,c;t[0]!==r||t[1]!==n||t[2]!==l?(c=async v=>{v.preventDefault(),n();let T=await r({download:!1,includeCode:!0,files:Jt.INSTANCE.filenames()}),M=W({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${te}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:T,path:l})}).catch(()=>{M.dismiss(),W({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:z.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),M.dismiss(),W({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]=c):c=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(wa,{children:"Share static notebook"}),t[4]=p):p=t[4];let g;t[5]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsxs)(xa,{children:[p,(0,a.jsxs)(va,{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:te,target:"_blank",children:te}),"."]})]}),t[5]=g):g=t[5];let w;t[6]===Symbol.for("react.memo_cache_sentinel")?(w=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=w):w=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(ha,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:w,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)(Oa,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let b;t[11]!==u||t[12]!==f?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=b):b=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(xe,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let k;t[16]===i?k=t[17]:(k=(0,a.jsx)(xe,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await ee(i)},children:"Create"}),t[16]=i,t[17]=k);let x;t[18]!==y||t[19]!==k?(x=(0,a.jsxs)(ga,{children:[y,k]}),t[18]=y,t[19]=k,t[20]=x):x=t[20];let j;return t[21]!==c||t[22]!==x||t[23]!==b?(j=(0,a.jsx)(ja,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:c,children:[g,b,x]})}),t[21]=c,t[22]=x,t[23]=b,t[24]=j):j=t[24],j};var Oa=e=>{let t=(0,Je.c)(8),[n,o]=ge.useState(!1),s;t[0]===e.text?s=t[1]:(s=$t.stopPropagation(async p=>{p.preventDefault(),await ee(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)(Zt,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(xe,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let c;return t[5]!==n||t[6]!==i?(c=(0,a.jsx)(Yt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=c):c=t[7],c},Ba=I();function Va(){let e=document.getElementsByClassName(Ae.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=be.findElement(t);if(!o){H.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:be.parse(o.id)}}}return H.warn("No visible output area found for scroll anchor"),null}function Fa(e){if(!e){H.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(be.create(e.cellId));if(!t){H.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${Ae.outputArea}`)){H.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Qe(){let e=(0,Ba.c)(2),t=L(De),n;return e[0]===t?n=e[1]:(n=()=>{let o=Va();t(s=>({mode:jt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Fa(o)})})},e[0]=t,e[1]=n),n}const Xe=st(!1);var Ya=I();const $a=()=>{let e=(0,Ya.c)(7),{selectedLayout:t}=Ee(),{setLayoutView:n}=Te();if(X()&&!pt("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)(Rt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Et,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Lt,{children:(0,a.jsxs)(Ht,{children:[(0,a.jsx)(It,{children:"View as"}),Fe.map(Ua)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(qt,{"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 Ka(e){return(0,a.jsx)(Ze(e),{className:"h-4 w-4"})}function Ze(e){switch(e){case"vertical":return Ea;case"grid":return ia;case"slides":return Ue;default:return Kt(e),fa}}function et(e){return Pe.startCase(e)}function Ua(e){return(0,a.jsx)(Tt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ka(e),(0,a.jsx)("span",{children:et(e)})]})},e)}async function Ga(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ja=I();function Qa(e){let t=(0,Ja.c)(5),{openPrompt:n,closeModal:o}=we(),{sendCopy:s}=R(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=ba.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${qe.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let c=l.join(qe.dirname(e),i);s({source:e,destination:c}).then(()=>{o(),W({title:"Notebook copied",description:"A copy of the notebook has been created."}),_a(c)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Xa=()=>{let{updateCellConfig:e}=Me(),{saveCellConfig:t}=R();return(0,ge.useCallback)(async()=>{let n=new ft,o=_e(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:c,config:p}=o.cellData[i];p.hide_code||n.isSupported(c)&&(r[i]={hide_code:!0})}let l=Se.entries(r);if(l.length!==0){await t({configs:r});for(let[i,c]of l)e({cellId:i,config:c})}},[e])};var Za=I();function tt(){let e=(0,Za.c)(4),{openConfirm:t}=we(),n=L(St),{sendRestart:o}=R(),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)(Pt,{onClick:async()=>{n({state:At.CLOSING}),await o(),Ca()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var eo=I(),E=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function to(){var ve,Ce,ze;let e=(0,eo.c)(56),t=za(),{openModal:n,closeModal:o}=we(),{toggleApplication:s}=mt(),{selectedPanel:r}=gt(),[l]=it(De),i=P(xt),c=Xa(),[p]=_t(),g=P(bt),w=P(Dt),{updateCellConfig:u,undoDeleteCell:f,clearAllCellOutputs:b,addSetupCellIfDoesntExist:y,collapseAllCells:k,expandAllCells:x}=Me(),j=tt(),v=ka(),T=Qa(t),M=L(Xe),oe=L(zt),{handleClick:ne}=Wt(),ie=L(Mt),{exportAsIPYNB:se,exportAsMarkdown:le,readCode:D,saveCellConfig:re,updateCellOutputs:_}=R(),S=Sa(),de=P(yt),ce=P(vt),he=P(ct),{selectedLayout:q}=Ee(),{setLayoutView:pe}=Te(),O=Qe(),B=((ve=p.sharing)==null?void 0:ve.html)??!0,V=((Ce=p.sharing)==null?void 0:Ce.wasm)??!0,F=((ze=p.sharing)==null?void 0:ze.molab)??!0,je=!X(),me=q==="slides",at=wo,ot=xo,Y;e[0]!==t||e[1]!==S||e[2]!==_?(Y=async d=>{let{preset:m,title:C}=d;if(!t){ae();return}await Ne(C,async fe=>{await Ve({takeScreenshots:()=>S({progress:fe}),updateCellOutputs:_}),await Ga({filename:t,preset:m,downloadPDF:Bt})})},e[0]=t,e[1]=S,e[2]=_,e[3]=Y):Y=e[3];let A=Y,$;e[4]===A?$=e[5]:($=async()=>{if(je){await A({preset:"document",title:"Downloading Document PDF..."});return}let d=new Event("export-beforeprint"),m=new Event("export-afterprint");window.dispatchEvent(d),setTimeout(ko,0),setTimeout(()=>window.dispatchEvent(m),0)},e[4]=A,e[5]=$);let K=$,U;e[6]!==se||e[7]!==t||e[8]!==S||e[9]!==_?(U=async()=>{if(!t){ae();return}await Ne("Downloading IPYNB...",async d=>{await Ve({takeScreenshots:()=>S({progress:d}),updateCellOutputs:_});let m=await se({download:!1});ke(new Blob([m],{type:"application/x-ipynb+json"}),ye.toIPYNB(document.title))})},e[6]=se,e[7]=t,e[8]=S,e[9]=_,e[10]=U):U=e[10];let ue=U,G;e[11]===Symbol.for("react.memo_cache_sentinel")?(G=(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}),e[11]=G):G=e[11];let J;e[12]===Symbol.for("react.memo_cache_sentinel")?(J=(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),e[12]=J):J=e[12];let N;e[13]===t?N=e[14]:(N=async()=>{if(!t){ae();return}await Le({filename:t,includeCode:!0})},e[13]=t,e[14]=N);let Q;return e[15]!==y||e[16]!==w||e[17]!==ce||e[18]!==g||e[19]!==b||e[20]!==o||e[21]!==k||e[22]!==T||e[23]!==A||e[24]!==x||e[25]!==le||e[26]!==t||e[27]!==K||e[28]!==ue||e[29]!==de||e[30]!==c||e[31]!==me||e[32]!==i||e[33]!==n||e[34]!==ne||e[35]!==D||e[36]!==j||e[37]!==v||e[38]!==re||e[39]!==q||e[40]!==r||e[41]!==M||e[42]!==ie||e[43]!==pe||e[44]!==oe||e[45]!==B||e[46]!==F||e[47]!==V||e[48]!==N||e[49]!==s||e[50]!==O||e[51]!==f||e[52]!==he||e[53]!==u||e[54]!==l.mode?(Q=[{icon:G,label:"Download",handle:E,dropdown:[{icon:J,label:"Download as HTML",handle:N},{icon:(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ae();return}await Le({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(Ma,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let d=await le({download:!1});ke(new Blob([d],{type:"text/plain"}),ye.toMarkdown(document.title))}},{icon:(0,a.jsx)(Ta,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:ue},{icon:(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let d=await D();ke(new Blob([d.contents],{type:"text/plain"}),ye.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(da,{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: ",Wa("global.hideCode",!1)]}),handle:yo},me?{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:E,dropdown:[{icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:K},{icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:ot(!0),hidden:!je,handle:async()=>{await A({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:K}]},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:X(),handle:async()=>{n((0,a.jsx)(Da,{onClose:o}))}},{icon:(0,a.jsx)(Ha,{size:14,strokeWidth:1.5}),label:"Share",handle:E,hidden:!B&&!V&&!F,dropdown:[{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!B,handle:async()=>{n((0,a.jsx)(qa,{onClose:o}))}},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!V,handle:async()=>{await ee(Oe({code:(await D()).contents})),W({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!F,handle:async()=>{let d=Oe({code:(await D()).contents,baseUrl:`${z.molab}/new`});window.open(d,"_blank")}}]},{icon:(0,a.jsx)(La,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:E,dropdown:rt.flatMap(d=>{let m=d.type==="ai"&&!w;if(ht({panel:d,capabilities:g,aiEnabled:w})&&!m)return[];let{type:C,Icon:fe,additionalKeywords:nt}=d;return{label:Pe.startCase(C),rightElement:at(r===C),icon:(0,a.jsx)(fe,{size:14,strokeWidth:1.5}),handle:()=>{if(m){ne("ai","ai-features");return}s(C)},additionalKeywords:nt}})},{icon:(0,a.jsx)(Ue,{size:14,strokeWidth:1.5}),label:"Present as",handle:E,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(ua,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ut,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{O()}},...Fe.map((d,m)=>{let C=Ze(d);return{divider:m===0,label:et(d),icon:(0,a.jsx)(C,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:q===d&&(0,a.jsx)(He,{size:14})}),handle:()=>{pe(d),l.mode==="edit"&&O()}}})]},{icon:(0,a.jsx)(Ia,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||X(),handle:T},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ee((await D()).contents),W({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Xt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!de||i,handle:async()=>{let d=wt(_e());await re({configs:Se.fromEntries(d.map(bo))});for(let m of d)u({cellId:m,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ke,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{y({})}},{icon:(0,a.jsx)(kt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Re,{onClose:o}))}},{icon:(0,a.jsx)(la,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Re,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:he,hidden:!ce||i,handle:()=>{f()}},{icon:(0,a.jsx)(Ra,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:j,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{v()}},{icon:(0,a.jsx)(dt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{b()}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:c,redundant:!0},{icon:(0,a.jsx)(Na,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:k,redundant:!0},{icon:(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:x,redundant:!0},{divider:!0,icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>M(fo)},{icon:(0,a.jsx)(Gt,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>ie(uo)},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>oe(mo),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Resources",handle:E,dropdown:[{icon:(0,a.jsx)(ut,{size:14,strokeWidth:1.5}),label:"Documentation",handle:po},{icon:(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),label:"GitHub",handle:ho},{icon:(0,a.jsx)(na,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:co},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"YouTube",handle:ro},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"Changelog",handle:lo}]},{divider:!0,icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:so},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:io}].filter(no).map(ao),e[15]=y,e[16]=w,e[17]=ce,e[18]=g,e[19]=b,e[20]=o,e[21]=k,e[22]=T,e[23]=A,e[24]=x,e[25]=le,e[26]=t,e[27]=K,e[28]=ue,e[29]=de,e[30]=c,e[31]=me,e[32]=i,e[33]=n,e[34]=ne,e[35]=D,e[36]=j,e[37]=v,e[38]=re,e[39]=q,e[40]=r,e[41]=M,e[42]=ie,e[43]=pe,e[44]=oe,e[45]=B,e[46]=F,e[47]=V,e[48]=N,e[49]=s,e[50]=O,e[51]=f,e[52]=he,e[53]=u,e[54]=l.mode,e[55]=Q):Q=e[55],Q}function ao(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(oo)}:e}function oo(e){return!e.hidden}function no(e){return!e.hidden}function io(){let e=ya();window.open(e,"_blank")}function so(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function lo(){window.open(z.releasesPage,"_blank")}function ro(){window.open(z.youtube,"_blank")}function co(){window.open(z.discordLink,"_blank")}function ho(){window.open(z.githubPage,"_blank")}function po(){window.open(z.docsPage,"_blank")}function mo(e){return!e}function uo(e){return!e}function fo(e){return!e}function bo(e){return[e,{disabled:!1}]}async function yo(){let e=document.getElementById("App");e&&await Vt({element:e,filename:document.title,prepare:Ft})}function ko(){return window.print()}function xo(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 wo(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(He,{size:14})})}function ae(){W({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Qe as a,$e as c,Xe as i,Ye as l,tt as n,Ge as o,$a as r,Ke as s,to as t};
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-CuhY66ZR.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-CXUns9uS.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-BPPi7vOr.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.23.11-dev11",
3
+ "version": "0.23.11-dev13",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -41,7 +41,10 @@ import {
41
41
  YoutubeIcon,
42
42
  ZapIcon,
43
43
  } from "lucide-react";
44
- import { settingDialogAtom } from "@/components/app-config/state";
44
+ import {
45
+ settingDialogAtom,
46
+ useOpenSettingsToTab,
47
+ } from "@/components/app-config/state";
45
48
  import { MarkdownIcon } from "@/components/editor/cell/code/icons";
46
49
  import { MarimoPlusIcon } from "@/components/icons/marimo-icons";
47
50
  import { useImperativeModal } from "@/components/modal/ImperativeModal";
@@ -57,7 +60,8 @@ import {
57
60
  useCellActions,
58
61
  } from "@/core/cells/cells";
59
62
  import { disabledCellIds } from "@/core/cells/utils";
60
- import { useResolvedMarimoConfig } from "@/core/config/config";
63
+ import { capabilitiesAtom } from "@/core/config/capabilities";
64
+ import { aiEnabledAtom, useResolvedMarimoConfig } from "@/core/config/config";
61
65
  import { Constants } from "@/core/constants";
62
66
  import {
63
67
  updateCellOutputsWithScreenshots,
@@ -86,7 +90,7 @@ import { Strings } from "@/utils/strings";
86
90
  import { newNotebookURL } from "@/utils/urls";
87
91
  import { useRunAllCells } from "../cell/useRunCells";
88
92
  import { useChromeActions, useChromeState } from "../chrome/state";
89
- import { PANELS } from "../chrome/types";
93
+ import { isPanelHidden, PANELS } from "../chrome/types";
90
94
  import { AddConnectionDialogContent } from "../connections/add-connection-dialog";
91
95
  import { keyboardShortcutsAtom } from "../controls/keyboard-shortcuts";
92
96
  import { commandPaletteAtom } from "../controls/state";
@@ -112,6 +116,8 @@ export function useNotebookActions() {
112
116
  const kioskMode = useAtomValue(kioskModeAtom);
113
117
  const hideAllMarkdownCode = useHideAllMarkdownCode();
114
118
  const [resolvedConfig] = useResolvedMarimoConfig();
119
+ const capabilities = useAtomValue(capabilitiesAtom);
120
+ const aiEnabled = useAtomValue(aiEnabledAtom);
115
121
 
116
122
  const {
117
123
  updateCellConfig,
@@ -126,6 +132,7 @@ export function useNotebookActions() {
126
132
  const copyNotebook = useCopyNotebook(filename);
127
133
  const setCommandPaletteOpen = useSetAtom(commandPaletteAtom);
128
134
  const setSettingsDialogOpen = useSetAtom(settingDialogAtom);
135
+ const { handleClick: openSettings } = useOpenSettingsToTab();
129
136
  const setKeyboardShortcutsOpen = useSetAtom(keyboardShortcutsAtom);
130
137
  const {
131
138
  exportAsIPYNB,
@@ -407,20 +414,31 @@ export function useNotebookActions() {
407
414
  label: "Helper panel",
408
415
  redundant: true,
409
416
  handle: NOOP_HANDLER,
410
- dropdown: PANELS.flatMap(
411
- ({ type: id, Icon, hidden, additionalKeywords }) => {
412
- if (hidden) {
413
- return [];
414
- }
415
- return {
416
- label: Strings.startCase(id),
417
- rightElement: renderCheckboxElement(selectedPanel === id),
418
- icon: <Icon size={14} strokeWidth={1.5} />,
419
- handle: () => toggleApplication(id),
420
- additionalKeywords,
421
- };
422
- },
423
- ),
417
+ dropdown: PANELS.flatMap((panel) => {
418
+ // Still show the AI panel in the command palette so users can try AI
419
+ // features. When AI is disabled, open settings instead of the panel.
420
+ const openAiSettingsWhenDisabled = panel.type === "ai" && !aiEnabled;
421
+ if (
422
+ isPanelHidden({ panel, capabilities, aiEnabled }) &&
423
+ !openAiSettingsWhenDisabled
424
+ ) {
425
+ return [];
426
+ }
427
+ const { type: id, Icon, additionalKeywords } = panel;
428
+ return {
429
+ label: Strings.startCase(id),
430
+ rightElement: renderCheckboxElement(selectedPanel === id),
431
+ icon: <Icon size={14} strokeWidth={1.5} />,
432
+ handle: () => {
433
+ if (openAiSettingsWhenDisabled) {
434
+ openSettings("ai", "ai-features");
435
+ return;
436
+ }
437
+ toggleApplication(id);
438
+ },
439
+ additionalKeywords,
440
+ };
441
+ }),
424
442
  },
425
443
 
426
444
  {
@@ -1 +0,0 @@
1
- import{s as ve}from"./chunk-LvLJmgfZ.js";import{d as T,l as at,p as ot,u as Q}from"./useEvent-D91BmmQi.js";import{t as nt}from"./react-Bj1aDYRI.js";import{An as it,Cr as st,D as Ce,E as lt,Nn as rt,On as dt,Or as ct,Qt as ht,Vi as me,_ as pt,br as mt,ct as ut,dt as ze,ei as ft,h as We,kn as bt,lt as yt,t as kt,vr as xt}from"./cells-D-v2lBet.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{n as wt,x as gt}from"./ai-model-dropdown-rE64ytSX.js";import{_ as L,d as Me}from"./useEventListener-DvoEXWke.js";import{x as jt}from"./utils-CvI-39U6.js";import{n as C,t as De}from"./constants-DMpttj8Q.js";import{T as X,v as vt,w as Ct}from"./config-ClMcu_sV.js";import{t as zt}from"./jsx-runtime-BqBOg78p.js";import{o as Wt}from"./alert-dialog-5BGIfskO.js";import{a as Mt,c as Dt,i as _t,n as At,r as Pt,s as St,t as Nt}from"./select-6suE6YM2.js";import{Nt as It}from"./JsonOutput-uEJijGXp.js";import{c as _e,d as ue,n as Et,o as Tt,r as fe,t as Lt}from"./download-WGU5w_3m.js";import{t as Ht}from"./tooltip-B_PkSKN3.js";import{r as Rt,t as be}from"./button-BbCh-29a.js";import{i as Ot,t as Ae}from"./strings-wdPMRf6Z.js";import{r as H}from"./requests-DIwGYs0l.js";import{t as h}from"./createLucideIcon-D5guW7EU.js";import{F as Vt,I as qt,L as Pe,P as Bt,R as Ft,a as Se,i as Ne,u as Ie}from"./layout-ks0WJ2vR.js";import{t as Ee}from"./check-BH35Ndha.js";import{r as Yt}from"./useCellActionButton-CtOZIXD0.js";import{t as $t}from"./copy-BwrPA9zQ.js";import{t as Kt}from"./eye-off-Cm6DdkeR.js";import{t as Ut}from"./external-link-BTNxSavU.js";import{t as Z}from"./file-BrdxGLRX.js";import{t as Gt}from"./github-BKS_2Qwn.js";import{u as Jt}from"./form-CVBFx2z3.js";import{n as Qt,r as Xt,t as Zt}from"./youtube-CbdpN8oL.js";import{i as ea,n as Te}from"./add-connection-dialog-ZyXXfAVG.js";import{t as ta}from"./house-mGK3v0Mm.js";import{t as aa}from"./image-DQHXdEQn.js";import{t as oa}from"./link-CfEtM3Rl.js";import{r as na}from"./input-DA8xlX70.js";import{t as ia}from"./settings-DfFe0dWD.js";import{t as sa}from"./sparkles-lWUAsPhp.js";import{y as la}from"./textarea-CBbixTxi.js";import{t as ra}from"./square-B5xWCt0a.js";import{t as z}from"./use-toast-CJ1Tj2eC.js";import{n as Le,t as da}from"./paths-D5zczhUD.js";import{o as ca}from"./session-0B5NBztP.js";import{n as ee}from"./copy-LK56fFow.js";import{r as ha}from"./useRunCells-BClkx9Pq.js";import{a as pa,c as ma,i as ua,n as fa,r as ba}from"./dialog-DRnNAWYl.js";import{n as ye}from"./ImperativeModal-BW1dmntO.js";import{r as ya,t as He}from"./share-mSf5FZIP.js";import{a as ka}from"./cell-link-DY95GSb7.js";import{a as xa}from"./renderShortcut--ku7VECI.js";import{t as wa}from"./icons-Ol38nIbL.js";import{t as ga}from"./pair-with-agent-modal-_SlYEcmZ.js";import{n as Re}from"./marimo-icons-CLbC-oB3.js";import{t as ja}from"./links-DoPgJNku.js";import{r as va,t as Oe}from"./hooks-83y0XCiC.js";import{t as Ve}from"./types-Cpe-qFT-.js";var Ca=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),za=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),qe=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"}]]),Be=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"}]]),Fe=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"}]]),Wa=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"}]]),Ma=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"}]]),Da=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"}]]),_a=h("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),Aa=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ye=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"}]]),Pa=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"}]]),Sa=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"}]]),$e=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"}]]),Ke=S(),ke=ve(nt(),1),a=ve(zt(),1),te="https://static.marimo.app";const Na=e=>{let t=(0,Ke.c)(25),{onClose:n}=e,[o,s]=(0,ke.useState)(""),{exportAsHTML:r}=H(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${te}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let I=await r({download:!1,includeCode:!0,files:Bt.INSTANCE.filenames()}),W=z({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${te}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:I,path:l})}).catch(()=>{W.dismiss(),z({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:C.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),W.dismiss(),z({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 m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(ma,{children:"Share static notebook"}),t[4]=m):m=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(pa,{children:[m,(0,a.jsxs)(ba,{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:te,target:"_blank",children:te}),"."]})]}),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)(na,{"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)(Ia,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let b;t[11]!==u||t[12]!==f?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=b):b=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(be,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let k;t[16]===i?k=t[17]:(k=(0,a.jsx)(be,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await ee(i)},children:"Create"}),t[16]=i,t[17]=k);let x;t[18]!==y||t[19]!==k?(x=(0,a.jsxs)(ua,{children:[y,k]}),t[18]=y,t[19]=k,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==b?(j=(0,a.jsx)(fa,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,b,x]})}),t[21]=d,t[22]=x,t[23]=b,t[24]=j):j=t[24],j};var Ia=e=>{let t=(0,Ke.c)(8),[n,o]=ke.useState(!1),s;t[0]===e.text?s=t[1]:(s=Rt.stopPropagation(async m=>{m.preventDefault(),await ee(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)($t,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(be,{"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)(Ht,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},Ea=S();function Ta(){let e=document.getElementsByClassName(De.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=me.findElement(t);if(!o){L.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:me.parse(o.id)}}}return L.warn("No visible output area found for scroll anchor"),null}function La(e){if(!e){L.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(me.create(e.cellId));if(!t){L.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${De.outputArea}`)){L.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ue(){let e=(0,Ea.c)(2),t=T(ze),n;return e[0]===t?n=e[1]:(n=()=>{let o=Ta();t(s=>({mode:yt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{La(o)})})},e[0]=t,e[1]=n),n}const Ge=ot(!1);var Ha=S();const Ra=()=>{let e=(0,Ha.c)(7),{selectedLayout:t}=Se(),{setLayoutView:n}=Ne();if(X()&&!rt("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)(St,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Dt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(At,{children:(0,a.jsxs)(Pt,{children:[(0,a.jsx)(Mt,{children:"View as"}),Ve.map(Va)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Nt,{"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 Oa(e){return(0,a.jsx)(Je(e),{className:"h-4 w-4"})}function Je(e){switch(e){case"vertical":return Da;case"grid":return Xt;case"slides":return Ye;default:return Ot(e),ra}}function Qe(e){return Ae.startCase(e)}function Va(e){return(0,a.jsx)(_t,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Oa(e),(0,a.jsx)("span",{children:Qe(e)})]})},e)}async function qa(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ba=S();function Fa(e){let t=(0,Ba.c)(5),{openPrompt:n,closeModal:o}=ye(),{sendCopy:s}=H(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=da.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Le.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(Le.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),z({title:"Notebook copied",description:"A copy of the notebook has been created."}),ja(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Ya=()=>{let{updateCellConfig:e}=Ce(),{saveCellConfig:t}=H();return(0,ke.useCallback)(async()=>{let n=new ht,o=We(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:d,config:m}=o.cellData[i];m.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let l=Me.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var $a=S();function Xe(){let e=(0,$a.c)(4),{openConfirm:t}=ye(),n=T(vt),{sendRestart:o}=H(),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)(Wt,{onClick:async()=>{n({state:Ct.CLOSING}),await o(),ya()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Ka=S(),N=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Ua(){var we,ge,je;let e=(0,Ka.c)(53),t=ka(),{openModal:n,closeModal:o}=ye(),{toggleApplication:s}=dt(),{selectedPanel:r}=bt(),[l]=at(ze),i=Q(ut),d=Ya(),[m]=jt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:b,expandAllCells:y}=Ce(),k=Xe(),x=ha(),j=Fa(t),v=T(Ge),I=T(wt),W=T(gt),{exportAsIPYNB:oe,exportAsMarkdown:ne,readCode:M,saveCellConfig:ie,updateCellOutputs:D}=H(),_=va(),se=Q(pt),le=Q(kt),re=Q(lt),{selectedLayout:R}=Se(),{setLayoutView:de}=Ne(),O=Ue(),V=((we=m.sharing)==null?void 0:we.html)??!0,q=((ge=m.sharing)==null?void 0:ge.wasm)??!0,B=((je=m.sharing)==null?void 0:je.molab)??!0,xe=!X(),ce=R==="slides",Ze=mo,et=po,F;e[0]!==t||e[1]!==_||e[2]!==D?(F=async c=>{let{preset:p,title:E}=c;if(!t){ae();return}await _e(E,async pe=>{await Oe({takeScreenshots:()=>_({progress:pe}),updateCellOutputs:D}),await qa({filename:t,preset:p,downloadPDF:Et})})},e[0]=t,e[1]=_,e[2]=D,e[3]=F):F=e[3];let A=F,Y;e[4]===A?Y=e[5]:(Y=async()=>{if(xe){await A({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),p=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(ho,0),setTimeout(()=>window.dispatchEvent(p),0)},e[4]=A,e[5]=Y);let $=Y,K;e[6]!==oe||e[7]!==t||e[8]!==_||e[9]!==D?(K=async()=>{if(!t){ae();return}await _e("Downloading IPYNB...",async c=>{await Oe({takeScreenshots:()=>_({progress:c}),updateCellOutputs:D});let p=await oe({download:!1});fe(new Blob([p],{type:"application/x-ipynb+json"}),ue.toIPYNB(document.title))})},e[6]=oe,e[7]=t,e[8]=_,e[9]=D,e[10]=K):K=e[10];let he=K,U;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(It,{size:14,strokeWidth:1.5}),e[11]=U):U=e[11];let G;e[12]===Symbol.for("react.memo_cache_sentinel")?(G=(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),e[12]=G):G=e[12];let P;e[13]===t?P=e[14]:(P=async()=>{if(!t){ae();return}await Ie({filename:t,includeCode:!0})},e[13]=t,e[14]=P);let J;return e[15]!==f||e[16]!==le||e[17]!==u||e[18]!==o||e[19]!==b||e[20]!==j||e[21]!==A||e[22]!==y||e[23]!==ne||e[24]!==t||e[25]!==$||e[26]!==he||e[27]!==se||e[28]!==d||e[29]!==ce||e[30]!==i||e[31]!==n||e[32]!==M||e[33]!==k||e[34]!==x||e[35]!==ie||e[36]!==R||e[37]!==r||e[38]!==v||e[39]!==W||e[40]!==de||e[41]!==I||e[42]!==V||e[43]!==B||e[44]!==q||e[45]!==P||e[46]!==s||e[47]!==O||e[48]!==g||e[49]!==re||e[50]!==w||e[51]!==l.mode?(J=[{icon:U,label:"Download",handle:N,dropdown:[{icon:G,label:"Download as HTML",handle:P},{icon:(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ae();return}await Ie({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(wa,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await ne({download:!1});fe(new Blob([c],{type:"text/plain"}),ue.toMarkdown(document.title))}},{icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:he},{icon:(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await M();fe(new Blob([c.contents],{type:"text/plain"}),ue.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(aa,{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: ",xa("global.hideCode",!1)]}),handle:co},ce?{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:N,dropdown:[{icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:$},{icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:et(!0),hidden:!xe,handle:async()=>{await A({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:$}]},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:X(),handle:async()=>{n((0,a.jsx)(ga,{onClose:o}))}},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Share",handle:N,hidden:!V&&!q&&!B,dropdown:[{icon:(0,a.jsx)(Jt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!V,handle:async()=>{n((0,a.jsx)(Na,{onClose:o}))}},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!q,handle:async()=>{await ee(He({code:(await M()).contents})),z({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!B,handle:async()=>{let c=He({code:(await M()).contents,baseUrl:`${C.molab}/new`});window.open(c,"_blank")}}]},{icon:(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:N,dropdown:it.flatMap(c=>{let{type:p,Icon:E,hidden:pe,additionalKeywords:tt}=c;return pe?[]:{label:Ae.startCase(p),rightElement:Ze(r===p),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),handle:()=>s(p),additionalKeywords:tt}})},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Present as",handle:N,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(la,{size:14,strokeWidth:1.5}):(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{O()}},...Ve.map((c,p)=>{let E=Je(c);return{divider:p===0,label:Qe(c),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:R===c&&(0,a.jsx)(Ee,{size:14})}),handle:()=>{de(c),l.mode==="edit"&&O()}}})]},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||X(),handle:j},{icon:(0,a.jsx)(qe,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ee((await M()).contents),z({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Yt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!se||i,handle:async()=>{let c=ft(We());await ie({configs:Me.fromEntries(c.map(ro))});for(let p of c)w({cellId:p,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Fe,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(mt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Te,{onClose:o}))}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Te,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:re,hidden:!le||i,handle:()=>{g()}},{icon:(0,a.jsx)(Sa,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:k,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Wa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Kt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:b,redundant:!0},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(lo)},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>W(so)},{icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>I(io),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(Ut,{size:14,strokeWidth:1.5}),label:"Resources",handle:N,dropdown:[{icon:(0,a.jsx)(ct,{size:14,strokeWidth:1.5}),label:"Documentation",handle:no},{icon:(0,a.jsx)(Gt,{size:14,strokeWidth:1.5}),label:"GitHub",handle:oo},{icon:(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:ao},{icon:(0,a.jsx)(Zt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:to},{icon:(0,a.jsx)(xt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:eo}]},{divider:!0,icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Za},{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Xa}].filter(Qa).map(Ga),e[15]=f,e[16]=le,e[17]=u,e[18]=o,e[19]=b,e[20]=j,e[21]=A,e[22]=y,e[23]=ne,e[24]=t,e[25]=$,e[26]=he,e[27]=se,e[28]=d,e[29]=ce,e[30]=i,e[31]=n,e[32]=M,e[33]=k,e[34]=x,e[35]=ie,e[36]=R,e[37]=r,e[38]=v,e[39]=W,e[40]=de,e[41]=I,e[42]=V,e[43]=B,e[44]=q,e[45]=P,e[46]=s,e[47]=O,e[48]=g,e[49]=re,e[50]=w,e[51]=l.mode,e[52]=J):J=e[52],J}function Ga(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Ja)}:e}function Ja(e){return!e.hidden}function Qa(e){return!e.hidden}function Xa(){let e=ca();window.open(e,"_blank")}function Za(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function eo(){window.open(C.releasesPage,"_blank")}function to(){window.open(C.youtube,"_blank")}function ao(){window.open(C.discordLink,"_blank")}function oo(){window.open(C.githubPage,"_blank")}function no(){window.open(C.docsPage,"_blank")}function io(e){return!e}function so(e){return!e}function lo(e){return!e}function ro(e){return[e,{disabled:!1}]}async function co(){let e=document.getElementById("App");e&&await Tt({element:e,filename:document.title,prepare:Lt})}function ho(){return window.print()}function po(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 mo(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Ee,{size:14})})}function ae(){z({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Ue as a,Be as c,Ge as i,qe as l,Xe as n,$e as o,Ra as r,Fe as s,Ua as t};