@marimo-team/frontend 0.23.12-dev20 → 0.23.12-dev23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/assets/{add-cell-with-ai-C-PLUgpy.js → add-cell-with-ai-BFxK5eot.js} +26 -26
  2. package/dist/assets/{agent-panel-DvRo8bi8.js → agent-panel-DSAn7fOl.js} +1 -1
  3. package/dist/assets/{ai-model-dropdown-bEbPXoSM.js → ai-model-dropdown-_YnYnMmq.js} +4 -4
  4. package/dist/assets/{app-config-button-C_o1pRld.js → app-config-button-cq--QVn3.js} +1 -1
  5. package/dist/assets/{cell-editor-BWw39or5.js → cell-editor-qigKRSz9.js} +1 -1
  6. package/dist/assets/{chat-display-DbDJHscS.js → chat-display-CJlKQfDb.js} +1 -1
  7. package/dist/assets/{chat-panel-8tlYTTQ-.js → chat-panel-BgSc5e9b.js} +1 -1
  8. package/dist/assets/{chat-ui-BvFUJMPP.js → chat-ui-B_nksQW2.js} +1 -1
  9. package/dist/assets/{command-palette-ByJVoDSa.js → command-palette-DJRDHX0f.js} +1 -1
  10. package/dist/assets/{edit-page-DkG-GrgE.js → edit-page-DRbYOO8f.js} +4 -4
  11. package/dist/assets/{home-page-Bhs2dkdU.js → home-page-DVfydKpV.js} +1 -1
  12. package/dist/assets/{hooks-BsAxp2GU.js → hooks-zvW2aL55.js} +1 -1
  13. package/dist/assets/{index-D5xY00XH.js → index-BclLs_8o.js} +3 -3
  14. package/dist/assets/{index-Bj8QWDiJ.css → index-CaelsqOA.css} +1 -1
  15. package/dist/assets/{layout-wXClIsC4.js → layout-CjAOfhP_.js} +3 -3
  16. package/dist/assets/{packages-panel-Cu-rx9mM.js → packages-panel-CceNbmy_.js} +1 -1
  17. package/dist/assets/{panels-CHtiP6qk.js → panels-q47cSDt0.js} +1 -1
  18. package/dist/assets/{reveal-component-DeMaX7RH.js → reveal-component-B4Y8dNQc.js} +1 -1
  19. package/dist/assets/{run-page-CE_UtXUq.js → run-page-BoTKI9c0.js} +1 -1
  20. package/dist/assets/{scratchpad-panel-D5KM35-P.js → scratchpad-panel-CbFzReQM.js} +1 -1
  21. package/dist/assets/{useNotebookActions-Ct85HJ1G.js → useNotebookActions-BcjULbTQ.js} +1 -1
  22. package/dist/index.html +2 -2
  23. package/package.json +1 -1
  24. package/src/components/editor/ai/__tests__/completion-utils.test.ts +48 -2
  25. package/src/components/editor/ai/completion-utils.ts +54 -36
  26. package/src/components/editor/app-container.tsx +3 -1
  27. package/src/components/editor/renderers/vertical-layout/vertical-layout-wrapper.tsx +2 -2
@@ -1 +1 @@
1
- import{s as ze}from"./chunk-LvLJmgfZ.js";import{d as L,l as rt,p as dt,u as I}from"./useEvent-D91BmmQi.js";import{t as ct}from"./react-Bj1aDYRI.js";import{An as ht,Cr as pt,D as We,E as mt,Mn as ut,Nn as ft,On as bt,Or as yt,Qt as kt,Tn as wt,Ui as be,_ as xt,br as gt,ct as jt,dt as Me,h as Ae,kn as vt,lt as Ct,ni as zt,t as Wt,vr as Mt,yr as Se}from"./cells-06TDmJ8V.js";import{t as z}from"./compiler-runtime-B3qBwwSJ.js";import{n as At,r as St,x as _t}from"./ai-model-dropdown-bEbPXoSM.js";import{_ as H,d as _e}from"./useEventListener-BakX-tnw.js";import{r as Dt,x as Nt}from"./utils-Dev6I_Kv.js";import{n as W,t as De}from"./constants-B9JJ72XE.js";import{T as X,v as Pt,w as It}from"./config-BE150fVL.js";import{t as Et}from"./jsx-runtime-PbYoItBR.js";import{o as Tt}from"./alert-dialog-CC0gG4Av.js";import{a as Lt,c as Ht,i as Ot,n as Rt,r as qt,s as Ft,t as Bt}from"./select-Cjly7tmx.js";import{Nt as Vt}from"./JsonOutput-B1X71OMV.js";import{c as Ne,d as ye,n as Yt,o as $t,r as ke,t as Ut}from"./download-VxqV5OSK.js";import{t as Kt}from"./tooltip-CgQpRVyN.js";import{r as Gt,t as we}from"./button-BF7GSjhW.js";import{i as Jt,t as Pe}from"./strings-DvZlHYnD.js";import{r as O}from"./requests-KshNNAOp.js";import{t as m}from"./createLucideIcon-BTp1tQDO.js";import{F as Qt,I as Xt,L as Ie,P as Zt,a as Ee,i as Te,u as Le}from"./layout-wXClIsC4.js";import{t as He}from"./check-DQmqoJgr.js";import{r as ea}from"./useCellActionButton-B88iHApv.js";import{t as ta}from"./code-DP40S9ln.js";import{t as aa}from"./copy-IBNGDypD.js";import{t as Oe}from"./eye-off-DI0EQXw0.js";import{t as oa}from"./external-link-BktyywYg.js";import{t as Z}from"./file-BvoBtS_V.js";import{u as na}from"./form-BAB18E37.js";import{n as ia,r as sa,t as la}from"./youtube-NfBeYlaL.js";import{i as ra,n as Re}from"./add-connection-dialog-ZpfrNSP5.js";import{t as da}from"./house-DkdBWh44.js";import{t as ca}from"./image-jhXeQEgs.js";import{t as ha}from"./link-My4Pey3q.js";import{r as pa}from"./input-b2KTOk0X.js";import{t as ma}from"./settings-Cn43l_vx.js";import{t as ua}from"./sparkles-DctOjjEz.js";import{y as fa}from"./textarea-BM7hAwR3.js";import{t as ba}from"./square-DPWHdF_-.js";import{t as M}from"./use-toast-BH8bU9Xf.js";import{n as qe,t as ya}from"./paths-kNeJ8nbe.js";import{o as ka}from"./session-B6_8umQX.js";import{n as ee}from"./copy-CyasABTK.js";import{r as wa}from"./useRunCells-DNaOKKqW.js";import{a as xa,c as ga,i as ja,n as va,r as Ca}from"./dialog-Dr_Y1zNi.js";import{n as xe}from"./ImperativeModal-MQnbMIO2.js";import{r as za,t as Fe}from"./share-vrPro738.js";import{a as Wa}from"./cell-link-DgWTiCtG.js";import{a as Ma}from"./renderShortcut-CKbqJyj4.js";import{t as Aa}from"./icons-D3YFXNmD.js";import{t as Sa}from"./pair-with-agent-modal-BONZmBdh.js";import{t as _a}from"./github-BQ8If5nZ.js";import{n as Be}from"./marimo-icons-CbdeMmbB.js";import{t as Da}from"./links-BL4SaTJe.js";import{r as Na,t as Ve}from"./hooks-BsAxp2GU.js";import{t as Ye}from"./types-a-yURniQ.js";var Pa=m("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Ia=m("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),$e=m("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"}]]),Ue=m("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=m("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"}]]),Ea=m("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"}]]),Ta=m("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"}]]),La=m("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"}]]),Ha=m("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"}]]),Oa=m("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ge=m("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"}]]),Ra=m("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"}]]),qa=m("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"}]]),Je=m("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"}]]),Qe=z(),Xe=ze(ct(),1),a=ze(Et(),1),te="https://static.marimo.app";const Fa=e=>{let t=(0,Qe.c)(25),{onClose:n}=e,[o,i]=(0,Xe.useState)(""),{exportAsHTML:d}=O(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,s=`${te}/static/${l}`,r;t[0]!==d||t[1]!==n||t[2]!==l?(r=async v=>{v.preventDefault(),n();let T=await d({download:!1,includeCode:!0,files:Zt.INSTANCE.filenames()}),A=M({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(()=>{A.dismiss(),M({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:W.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),A.dismiss(),M({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]=d,t[1]=n,t[2]=l,t[3]=r):r=t[3];let h;t[4]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsx)(ga,{children:"Share static notebook"}),t[4]=h):h=t[4];let p;t[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsxs)(xa,{children:[h,(0,a.jsxs)(Ca,{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]=p):p=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{i(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let f;t[7]===o?f=t[8]:(f=(0,a.jsx)(pa,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=f);let b;t[9]===s?b=t[10]:(b=(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)(Ba,{text:s}),(0,a.jsx)("span",{className:"text-primary",children:s})]})]}),t[9]=s,t[10]=b);let y;t[11]!==f||t[12]!==b?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[f,b]}),t[11]=f,t[12]=b,t[13]=y):y=t[13];let k;t[14]===n?k=t[15]:(k=(0,a.jsx)(we,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=k);let w;t[16]===s?w=t[17]:(w=(0,a.jsx)(we,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await ee(s)},children:"Create"}),t[16]=s,t[17]=w);let x;t[18]!==k||t[19]!==w?(x=(0,a.jsxs)(ja,{children:[k,w]}),t[18]=k,t[19]=w,t[20]=x):x=t[20];let j;return t[21]!==r||t[22]!==x||t[23]!==y?(j=(0,a.jsx)(va,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:r,children:[p,y,x]})}),t[21]=r,t[22]=x,t[23]=y,t[24]=j):j=t[24],j};var Ba=e=>{let t=(0,Qe.c)(8),[n,o]=Xe.useState(!1),i;t[0]===e.text?i=t[1]:(i=Gt.stopPropagation(async h=>{h.preventDefault(),await ee(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=i);let d=i,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let s;t[3]===d?s=t[4]:(s=(0,a.jsx)(we,{"data-testid":"copy-static-notebook-url-button",onClick:d,size:"xs",variant:"secondary",children:l}),t[3]=d,t[4]=s);let r;return t[5]!==n||t[6]!==s?(r=(0,a.jsx)(Kt,{content:"Copied!",open:n,children:s}),t[5]=n,t[6]=s,t[7]=r):r=t[7],r},Va=z();function Ya(){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=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 $a(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(`.${De.outputArea}`)){H.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ze(){let e=(0,Va.c)(2),t=L(Me),n;return e[0]===t?n=e[1]:(n=()=>{let o=Ya();t(i=>({mode:Ct(i.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{$a(o)})})},e[0]=t,e[1]=n),n}const et=dt(!1);var Ua=z();const Ka=()=>{let e=(0,Ua.c)(7),{selectedLayout:t}=Ee(),{setLayoutView:n}=Te();if(X()&&!ft("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=s=>n(s),e[0]=n,e[1]=o);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)(Ft,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Ht,{placeholder:"Select a view"})}),e[2]=i):i=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)(Rt,{children:(0,a.jsxs)(qt,{children:[(0,a.jsx)(Lt,{children:"View as"}),Ye.map(Ja)]})}),e[3]=d):d=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Bt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[i,d]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Ga(e){return(0,a.jsx)(tt(e),{className:"h-4 w-4"})}function tt(e){switch(e){case"vertical":return La;case"grid":return sa;case"slides":return Ge;default:return Jt(e),ba}}function at(e){return Pe.startCase(e)}function Ja(e){return(0,a.jsx)(Ot,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ga(e),(0,a.jsx)("span",{children:at(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 Xa=z();function Za(e){let t=(0,Xa.c)(5),{openPrompt:n,closeModal:o}=xe(),{sendCopy:i}=O(),d;return t[0]!==o||t[1]!==n||t[2]!==i||t[3]!==e?(d=()=>{if(!e)return null;let l=ya.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:s=>{let r=l.join(qe.dirname(e),s);i({source:e,destination:r}).then(()=>{o(),M({title:"Notebook copied",description:"A copy of the notebook has been created."}),Da(r)})}})},t[0]=o,t[1]=n,t[2]=i,t[3]=e,t[4]=d):d=t[4],d}var eo=z();function ot(){let e=(0,eo.c)(4),{openConfirm:t}=xe(),n=L(Pt),{sendRestart:o}=O(),i;return e[0]!==t||e[1]!==o||e[2]!==n?(i=()=>{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)(Tt,{onClick:async()=>{n({state:It.CLOSING}),await o(),za()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=i):i=e[3],i}var to=z(),ao=new kt,oo=e=>ao.isSupported(e)?"markdown":"code";const nt=()=>{let e=(0,to.c)(3),{updateCellConfig:t}=We(),{saveCellConfig:n}=O(),o;return e[0]!==n||e[1]!==t?(o=async(i,d)=>{let l=Ae(),s={};for(let h of l.cellIds.inOrderIds){let p=l.cellData[h];p===void 0||p.config.hide_code===i||oo(p.code)===d&&(s[h]={hide_code:i})}let r=_e.entries(s);if(r.length!==0){await n({configs:s});for(let[h,p]of r)t({cellId:h,config:p})}},e[0]=n,e[1]=t,e[2]=o):o=e[2],o};var no=z(),E=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function io(){var je,ve,Ce;let e=(0,no.c)(56),t=Wa(),{openModal:n,closeModal:o}=xe(),{toggleApplication:i}=bt(),{selectedPanel:d}=vt(),[l]=rt(Me),s=I(jt),r=nt(),[h]=Nt(),p=I(wt),g=I(Dt),{updateCellConfig:f,undoDeleteCell:b,clearAllCellOutputs:y,addSetupCellIfDoesntExist:k,collapseAllCells:w,expandAllCells:x}=We(),j=ot(),v=wa(),T=Za(t),A=L(et),oe=L(At),{handleClick:ne}=St(),ie=L(_t),{exportAsIPYNB:se,exportAsMarkdown:le,readCode:S,saveCellConfig:re,updateCellOutputs:_}=O(),D=Na(),de=I(xt),ce=I(Wt),he=I(mt),{selectedLayout:R}=Ee(),{setLayoutView:pe}=Te(),q=Ze(),F=((je=h.sharing)==null?void 0:je.html)??!0,B=((ve=h.sharing)==null?void 0:ve.wasm)??!0,V=((Ce=h.sharing)==null?void 0:Ce.molab)??!0,ge=!X(),me=R==="slides",it=Co,st=vo,Y;e[0]!==t||e[1]!==D||e[2]!==_?(Y=async c=>{let{preset:u,title:C}=c;if(!t){ae();return}await Ne(C,async fe=>{await Ve({takeScreenshots:()=>D({progress:fe}),updateCellOutputs:_}),await Qa({filename:t,preset:u,downloadPDF:Yt})})},e[0]=t,e[1]=D,e[2]=_,e[3]=Y):Y=e[3];let N=Y,$;e[4]===N?$=e[5]:($=async()=>{if(ge){await N({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),u=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(jo,0),setTimeout(()=>window.dispatchEvent(u),0)},e[4]=N,e[5]=$);let U=$,K;e[6]!==se||e[7]!==t||e[8]!==D||e[9]!==_?(K=async()=>{if(!t){ae();return}await Ne("Downloading IPYNB...",async c=>{await Ve({takeScreenshots:()=>D({progress:c}),updateCellOutputs:_});let u=await se({download:!1});ke(new Blob([u],{type:"application/x-ipynb+json"}),ye.toIPYNB(document.title))})},e[6]=se,e[7]=t,e[8]=D,e[9]=_,e[10]=K):K=e[10];let ue=K,G;e[11]===Symbol.for("react.memo_cache_sentinel")?(G=(0,a.jsx)(Vt,{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 P;e[13]===t?P=e[14]:(P=async()=>{if(!t){ae();return}await Le({filename:t,includeCode:!0})},e[13]=t,e[14]=P);let Q;return e[15]!==k||e[16]!==g||e[17]!==ce||e[18]!==p||e[19]!==y||e[20]!==o||e[21]!==w||e[22]!==T||e[23]!==N||e[24]!==x||e[25]!==le||e[26]!==t||e[27]!==U||e[28]!==ue||e[29]!==de||e[30]!==me||e[31]!==s||e[32]!==n||e[33]!==ne||e[34]!==S||e[35]!==j||e[36]!==v||e[37]!==re||e[38]!==R||e[39]!==d||e[40]!==r||e[41]!==A||e[42]!==ie||e[43]!==pe||e[44]!==oe||e[45]!==F||e[46]!==V||e[47]!==B||e[48]!==P||e[49]!==i||e[50]!==q||e[51]!==b||e[52]!==he||e[53]!==f||e[54]!==l.mode?(Q=[{icon:G,label:"Download",handle:E,dropdown:[{icon:J,label:"Download as HTML",handle:P},{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)(Aa,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await le({download:!1});ke(new Blob([c],{type:"text/plain"}),ye.toMarkdown(document.title))}},{icon:(0,a.jsx)(Ha,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:ue},{icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await S();ke(new Blob([c.contents],{type:"text/plain"}),ye.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(ca,{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: ",Ma("global.hideCode",!1)]}),handle:go},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:U},{icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:st(!0),hidden:!ge,handle:async()=>{await N({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:U}]},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:X(),handle:async()=>{n((0,a.jsx)(Sa,{onClose:o}))}},{icon:(0,a.jsx)(Ra,{size:14,strokeWidth:1.5}),label:"Share",handle:E,hidden:!F&&!B&&!V,dropdown:[{icon:(0,a.jsx)(na,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!F,handle:async()=>{n((0,a.jsx)(Fa,{onClose:o}))}},{icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!B,handle:async()=>{await ee(Fe({code:(await S()).contents})),M({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!V,handle:async()=>{let c=Fe({code:(await S()).contents,baseUrl:`${W.molab}/new`});window.open(c,"_blank")}}]},{icon:(0,a.jsx)(Oa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:E,dropdown:ht.flatMap(c=>{let u=c.type==="ai"&&!g;if(ut({panel:c,capabilities:p,aiEnabled:g})&&!u)return[];let{type:C,Icon:fe,additionalKeywords:lt}=c;return{label:Pe.startCase(C),rightElement:it(d===C),icon:(0,a.jsx)(fe,{size:14,strokeWidth:1.5}),handle:()=>{if(u){ne("ai","ai-features");return}i(C)},additionalKeywords:lt}})},{icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:"Present as",handle:E,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(fa,{size:14,strokeWidth:1.5}):(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{q()}},...Ye.map((c,u)=>{let C=tt(c);return{divider:u===0,label:at(c),icon:(0,a.jsx)(C,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:R===c&&(0,a.jsx)(He,{size:14})}),handle:()=>{pe(c),l.mode==="edit"&&q()}}})]},{icon:(0,a.jsx)(Ta,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||X(),handle:T},{icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ee((await S()).contents),M({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!de||s,handle:async()=>{let c=zt(Ae());await re({configs:_e.fromEntries(c.map(xo))});for(let u of c)f({cellId:u,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ke,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{k({})}},{icon:(0,a.jsx)(gt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Re,{onClose:o}))}},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Re,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Je,{size:14,strokeWidth:1.5}),label:he,hidden:!ce||s,handle:()=>{b()}},{icon:(0,a.jsx)(qa,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:j,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Ea,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{v()}},{icon:(0,a.jsx)(pt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{y()}},{icon:(0,a.jsx)(Se,{size:14,strokeWidth:1.5}),label:"Show all code",hotkey:"global.showAllCode",handle:()=>r(!1,"code"),redundant:!0},{icon:(0,a.jsx)(Oe,{size:14,strokeWidth:1.5}),label:"Hide all code",hotkey:"global.hideAllCode",handle:()=>r(!0,"code"),redundant:!0},{icon:(0,a.jsx)(Se,{size:14,strokeWidth:1.5}),label:"Show all markdown code",hotkey:"global.showAllMarkdownCode",handle:()=>r(!1,"markdown"),redundant:!0},{icon:(0,a.jsx)(Oe,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",hotkey:"global.hideAllMarkdownCode",handle:()=>r(!0,"markdown"),redundant:!0},{icon:(0,a.jsx)(Ia,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:w,redundant:!0},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:x,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ue,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>A(wo)},{icon:(0,a.jsx)(Xt,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>ie(ko)},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>oe(yo),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Resources",handle:E,dropdown:[{icon:(0,a.jsx)(yt,{size:14,strokeWidth:1.5}),label:"Documentation",handle:bo},{icon:(0,a.jsx)(_a,{className:"h-3.5 w-3.5"}),label:"GitHub",handle:fo},{icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:uo},{icon:(0,a.jsx)(la,{className:"h-3.5 w-3.5"}),label:"YouTube",handle:mo},{icon:(0,a.jsx)(Mt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:po}]},{divider:!0,icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:ho},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:co}].filter(ro).map(so),e[15]=k,e[16]=g,e[17]=ce,e[18]=p,e[19]=y,e[20]=o,e[21]=w,e[22]=T,e[23]=N,e[24]=x,e[25]=le,e[26]=t,e[27]=U,e[28]=ue,e[29]=de,e[30]=me,e[31]=s,e[32]=n,e[33]=ne,e[34]=S,e[35]=j,e[36]=v,e[37]=re,e[38]=R,e[39]=d,e[40]=r,e[41]=A,e[42]=ie,e[43]=pe,e[44]=oe,e[45]=F,e[46]=V,e[47]=B,e[48]=P,e[49]=i,e[50]=q,e[51]=b,e[52]=he,e[53]=f,e[54]=l.mode,e[55]=Q):Q=e[55],Q}function so(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(lo)}:e}function lo(e){return!e.hidden}function ro(e){return!e.hidden}function co(){let e=ka();window.open(e,"_blank")}function ho(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function po(){window.open(W.releasesPage,"_blank")}function mo(){window.open(W.youtube,"_blank")}function uo(){window.open(W.discordLink,"_blank")}function fo(){window.open(W.githubPage,"_blank")}function bo(){window.open(W.docsPage,"_blank")}function yo(e){return!e}function ko(e){return!e}function wo(e){return!e}function xo(e){return[e,{disabled:!1}]}async function go(){let e=document.getElementById("App");e&&await $t({element:e,filename:document.title,prepare:Ut})}function jo(){return window.print()}function vo(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 Co(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(He,{size:14})})}function ae(){M({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{et as a,Ke as c,Ka as i,Ue as l,nt as n,Ze as o,ot as r,Je as s,io as t,$e as u};
1
+ import{s as ze}from"./chunk-LvLJmgfZ.js";import{d as L,l as rt,p as dt,u as I}from"./useEvent-D91BmmQi.js";import{t as ct}from"./react-Bj1aDYRI.js";import{An as ht,Cr as pt,D as We,E as mt,Mn as ut,Nn as ft,On as bt,Or as yt,Qt as kt,Tn as wt,Ui as be,_ as xt,br as gt,ct as jt,dt as Me,h as Ae,kn as vt,lt as Ct,ni as zt,t as Wt,vr as Mt,yr as Se}from"./cells-06TDmJ8V.js";import{t as z}from"./compiler-runtime-B3qBwwSJ.js";import{n as At,r as St,x as _t}from"./ai-model-dropdown-_YnYnMmq.js";import{_ as H,d as _e}from"./useEventListener-BakX-tnw.js";import{r as Dt,x as Nt}from"./utils-Dev6I_Kv.js";import{n as W,t as De}from"./constants-B9JJ72XE.js";import{T as X,v as Pt,w as It}from"./config-BE150fVL.js";import{t as Et}from"./jsx-runtime-PbYoItBR.js";import{o as Tt}from"./alert-dialog-CC0gG4Av.js";import{a as Lt,c as Ht,i as Ot,n as Rt,r as qt,s as Ft,t as Bt}from"./select-Cjly7tmx.js";import{Nt as Vt}from"./JsonOutput-B1X71OMV.js";import{c as Ne,d as ye,n as Yt,o as $t,r as ke,t as Ut}from"./download-VxqV5OSK.js";import{t as Kt}from"./tooltip-CgQpRVyN.js";import{r as Gt,t as we}from"./button-BF7GSjhW.js";import{i as Jt,t as Pe}from"./strings-DvZlHYnD.js";import{r as O}from"./requests-KshNNAOp.js";import{t as m}from"./createLucideIcon-BTp1tQDO.js";import{F as Qt,I as Xt,L as Ie,P as Zt,a as Ee,i as Te,u as Le}from"./layout-CjAOfhP_.js";import{t as He}from"./check-DQmqoJgr.js";import{r as ea}from"./useCellActionButton-B88iHApv.js";import{t as ta}from"./code-DP40S9ln.js";import{t as aa}from"./copy-IBNGDypD.js";import{t as Oe}from"./eye-off-DI0EQXw0.js";import{t as oa}from"./external-link-BktyywYg.js";import{t as Z}from"./file-BvoBtS_V.js";import{u as na}from"./form-BAB18E37.js";import{n as ia,r as sa,t as la}from"./youtube-NfBeYlaL.js";import{i as ra,n as Re}from"./add-connection-dialog-ZpfrNSP5.js";import{t as da}from"./house-DkdBWh44.js";import{t as ca}from"./image-jhXeQEgs.js";import{t as ha}from"./link-My4Pey3q.js";import{r as pa}from"./input-b2KTOk0X.js";import{t as ma}from"./settings-Cn43l_vx.js";import{t as ua}from"./sparkles-DctOjjEz.js";import{y as fa}from"./textarea-BM7hAwR3.js";import{t as ba}from"./square-DPWHdF_-.js";import{t as M}from"./use-toast-BH8bU9Xf.js";import{n as qe,t as ya}from"./paths-kNeJ8nbe.js";import{o as ka}from"./session-B6_8umQX.js";import{n as ee}from"./copy-CyasABTK.js";import{r as wa}from"./useRunCells-DNaOKKqW.js";import{a as xa,c as ga,i as ja,n as va,r as Ca}from"./dialog-Dr_Y1zNi.js";import{n as xe}from"./ImperativeModal-MQnbMIO2.js";import{r as za,t as Fe}from"./share-vrPro738.js";import{a as Wa}from"./cell-link-DgWTiCtG.js";import{a as Ma}from"./renderShortcut-CKbqJyj4.js";import{t as Aa}from"./icons-D3YFXNmD.js";import{t as Sa}from"./pair-with-agent-modal-BONZmBdh.js";import{t as _a}from"./github-BQ8If5nZ.js";import{n as Be}from"./marimo-icons-CbdeMmbB.js";import{t as Da}from"./links-BL4SaTJe.js";import{r as Na,t as Ve}from"./hooks-zvW2aL55.js";import{t as Ye}from"./types-a-yURniQ.js";var Pa=m("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Ia=m("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),$e=m("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"}]]),Ue=m("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=m("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"}]]),Ea=m("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"}]]),Ta=m("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"}]]),La=m("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"}]]),Ha=m("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"}]]),Oa=m("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ge=m("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"}]]),Ra=m("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"}]]),qa=m("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"}]]),Je=m("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"}]]),Qe=z(),Xe=ze(ct(),1),a=ze(Et(),1),te="https://static.marimo.app";const Fa=e=>{let t=(0,Qe.c)(25),{onClose:n}=e,[o,i]=(0,Xe.useState)(""),{exportAsHTML:d}=O(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,s=`${te}/static/${l}`,r;t[0]!==d||t[1]!==n||t[2]!==l?(r=async v=>{v.preventDefault(),n();let T=await d({download:!1,includeCode:!0,files:Zt.INSTANCE.filenames()}),A=M({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(()=>{A.dismiss(),M({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:W.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),A.dismiss(),M({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]=d,t[1]=n,t[2]=l,t[3]=r):r=t[3];let h;t[4]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsx)(ga,{children:"Share static notebook"}),t[4]=h):h=t[4];let p;t[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsxs)(xa,{children:[h,(0,a.jsxs)(Ca,{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]=p):p=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{i(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let f;t[7]===o?f=t[8]:(f=(0,a.jsx)(pa,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=f);let b;t[9]===s?b=t[10]:(b=(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)(Ba,{text:s}),(0,a.jsx)("span",{className:"text-primary",children:s})]})]}),t[9]=s,t[10]=b);let y;t[11]!==f||t[12]!==b?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[f,b]}),t[11]=f,t[12]=b,t[13]=y):y=t[13];let k;t[14]===n?k=t[15]:(k=(0,a.jsx)(we,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=k);let w;t[16]===s?w=t[17]:(w=(0,a.jsx)(we,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await ee(s)},children:"Create"}),t[16]=s,t[17]=w);let x;t[18]!==k||t[19]!==w?(x=(0,a.jsxs)(ja,{children:[k,w]}),t[18]=k,t[19]=w,t[20]=x):x=t[20];let j;return t[21]!==r||t[22]!==x||t[23]!==y?(j=(0,a.jsx)(va,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:r,children:[p,y,x]})}),t[21]=r,t[22]=x,t[23]=y,t[24]=j):j=t[24],j};var Ba=e=>{let t=(0,Qe.c)(8),[n,o]=Xe.useState(!1),i;t[0]===e.text?i=t[1]:(i=Gt.stopPropagation(async h=>{h.preventDefault(),await ee(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=i);let d=i,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let s;t[3]===d?s=t[4]:(s=(0,a.jsx)(we,{"data-testid":"copy-static-notebook-url-button",onClick:d,size:"xs",variant:"secondary",children:l}),t[3]=d,t[4]=s);let r;return t[5]!==n||t[6]!==s?(r=(0,a.jsx)(Kt,{content:"Copied!",open:n,children:s}),t[5]=n,t[6]=s,t[7]=r):r=t[7],r},Va=z();function Ya(){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=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 $a(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(`.${De.outputArea}`)){H.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ze(){let e=(0,Va.c)(2),t=L(Me),n;return e[0]===t?n=e[1]:(n=()=>{let o=Ya();t(i=>({mode:Ct(i.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{$a(o)})})},e[0]=t,e[1]=n),n}const et=dt(!1);var Ua=z();const Ka=()=>{let e=(0,Ua.c)(7),{selectedLayout:t}=Ee(),{setLayoutView:n}=Te();if(X()&&!ft("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=s=>n(s),e[0]=n,e[1]=o);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)(Ft,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Ht,{placeholder:"Select a view"})}),e[2]=i):i=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)(Rt,{children:(0,a.jsxs)(qt,{children:[(0,a.jsx)(Lt,{children:"View as"}),Ye.map(Ja)]})}),e[3]=d):d=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Bt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[i,d]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Ga(e){return(0,a.jsx)(tt(e),{className:"h-4 w-4"})}function tt(e){switch(e){case"vertical":return La;case"grid":return sa;case"slides":return Ge;default:return Jt(e),ba}}function at(e){return Pe.startCase(e)}function Ja(e){return(0,a.jsx)(Ot,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ga(e),(0,a.jsx)("span",{children:at(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 Xa=z();function Za(e){let t=(0,Xa.c)(5),{openPrompt:n,closeModal:o}=xe(),{sendCopy:i}=O(),d;return t[0]!==o||t[1]!==n||t[2]!==i||t[3]!==e?(d=()=>{if(!e)return null;let l=ya.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:s=>{let r=l.join(qe.dirname(e),s);i({source:e,destination:r}).then(()=>{o(),M({title:"Notebook copied",description:"A copy of the notebook has been created."}),Da(r)})}})},t[0]=o,t[1]=n,t[2]=i,t[3]=e,t[4]=d):d=t[4],d}var eo=z();function ot(){let e=(0,eo.c)(4),{openConfirm:t}=xe(),n=L(Pt),{sendRestart:o}=O(),i;return e[0]!==t||e[1]!==o||e[2]!==n?(i=()=>{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)(Tt,{onClick:async()=>{n({state:It.CLOSING}),await o(),za()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=i):i=e[3],i}var to=z(),ao=new kt,oo=e=>ao.isSupported(e)?"markdown":"code";const nt=()=>{let e=(0,to.c)(3),{updateCellConfig:t}=We(),{saveCellConfig:n}=O(),o;return e[0]!==n||e[1]!==t?(o=async(i,d)=>{let l=Ae(),s={};for(let h of l.cellIds.inOrderIds){let p=l.cellData[h];p===void 0||p.config.hide_code===i||oo(p.code)===d&&(s[h]={hide_code:i})}let r=_e.entries(s);if(r.length!==0){await n({configs:s});for(let[h,p]of r)t({cellId:h,config:p})}},e[0]=n,e[1]=t,e[2]=o):o=e[2],o};var no=z(),E=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function io(){var je,ve,Ce;let e=(0,no.c)(56),t=Wa(),{openModal:n,closeModal:o}=xe(),{toggleApplication:i}=bt(),{selectedPanel:d}=vt(),[l]=rt(Me),s=I(jt),r=nt(),[h]=Nt(),p=I(wt),g=I(Dt),{updateCellConfig:f,undoDeleteCell:b,clearAllCellOutputs:y,addSetupCellIfDoesntExist:k,collapseAllCells:w,expandAllCells:x}=We(),j=ot(),v=wa(),T=Za(t),A=L(et),oe=L(At),{handleClick:ne}=St(),ie=L(_t),{exportAsIPYNB:se,exportAsMarkdown:le,readCode:S,saveCellConfig:re,updateCellOutputs:_}=O(),D=Na(),de=I(xt),ce=I(Wt),he=I(mt),{selectedLayout:R}=Ee(),{setLayoutView:pe}=Te(),q=Ze(),F=((je=h.sharing)==null?void 0:je.html)??!0,B=((ve=h.sharing)==null?void 0:ve.wasm)??!0,V=((Ce=h.sharing)==null?void 0:Ce.molab)??!0,ge=!X(),me=R==="slides",it=Co,st=vo,Y;e[0]!==t||e[1]!==D||e[2]!==_?(Y=async c=>{let{preset:u,title:C}=c;if(!t){ae();return}await Ne(C,async fe=>{await Ve({takeScreenshots:()=>D({progress:fe}),updateCellOutputs:_}),await Qa({filename:t,preset:u,downloadPDF:Yt})})},e[0]=t,e[1]=D,e[2]=_,e[3]=Y):Y=e[3];let N=Y,$;e[4]===N?$=e[5]:($=async()=>{if(ge){await N({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),u=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(jo,0),setTimeout(()=>window.dispatchEvent(u),0)},e[4]=N,e[5]=$);let U=$,K;e[6]!==se||e[7]!==t||e[8]!==D||e[9]!==_?(K=async()=>{if(!t){ae();return}await Ne("Downloading IPYNB...",async c=>{await Ve({takeScreenshots:()=>D({progress:c}),updateCellOutputs:_});let u=await se({download:!1});ke(new Blob([u],{type:"application/x-ipynb+json"}),ye.toIPYNB(document.title))})},e[6]=se,e[7]=t,e[8]=D,e[9]=_,e[10]=K):K=e[10];let ue=K,G;e[11]===Symbol.for("react.memo_cache_sentinel")?(G=(0,a.jsx)(Vt,{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 P;e[13]===t?P=e[14]:(P=async()=>{if(!t){ae();return}await Le({filename:t,includeCode:!0})},e[13]=t,e[14]=P);let Q;return e[15]!==k||e[16]!==g||e[17]!==ce||e[18]!==p||e[19]!==y||e[20]!==o||e[21]!==w||e[22]!==T||e[23]!==N||e[24]!==x||e[25]!==le||e[26]!==t||e[27]!==U||e[28]!==ue||e[29]!==de||e[30]!==me||e[31]!==s||e[32]!==n||e[33]!==ne||e[34]!==S||e[35]!==j||e[36]!==v||e[37]!==re||e[38]!==R||e[39]!==d||e[40]!==r||e[41]!==A||e[42]!==ie||e[43]!==pe||e[44]!==oe||e[45]!==F||e[46]!==V||e[47]!==B||e[48]!==P||e[49]!==i||e[50]!==q||e[51]!==b||e[52]!==he||e[53]!==f||e[54]!==l.mode?(Q=[{icon:G,label:"Download",handle:E,dropdown:[{icon:J,label:"Download as HTML",handle:P},{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)(Aa,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await le({download:!1});ke(new Blob([c],{type:"text/plain"}),ye.toMarkdown(document.title))}},{icon:(0,a.jsx)(Ha,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:ue},{icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await S();ke(new Blob([c.contents],{type:"text/plain"}),ye.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(ca,{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: ",Ma("global.hideCode",!1)]}),handle:go},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:U},{icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:st(!0),hidden:!ge,handle:async()=>{await N({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:U}]},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:X(),handle:async()=>{n((0,a.jsx)(Sa,{onClose:o}))}},{icon:(0,a.jsx)(Ra,{size:14,strokeWidth:1.5}),label:"Share",handle:E,hidden:!F&&!B&&!V,dropdown:[{icon:(0,a.jsx)(na,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!F,handle:async()=>{n((0,a.jsx)(Fa,{onClose:o}))}},{icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!B,handle:async()=>{await ee(Fe({code:(await S()).contents})),M({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!V,handle:async()=>{let c=Fe({code:(await S()).contents,baseUrl:`${W.molab}/new`});window.open(c,"_blank")}}]},{icon:(0,a.jsx)(Oa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:E,dropdown:ht.flatMap(c=>{let u=c.type==="ai"&&!g;if(ut({panel:c,capabilities:p,aiEnabled:g})&&!u)return[];let{type:C,Icon:fe,additionalKeywords:lt}=c;return{label:Pe.startCase(C),rightElement:it(d===C),icon:(0,a.jsx)(fe,{size:14,strokeWidth:1.5}),handle:()=>{if(u){ne("ai","ai-features");return}i(C)},additionalKeywords:lt}})},{icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:"Present as",handle:E,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(fa,{size:14,strokeWidth:1.5}):(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{q()}},...Ye.map((c,u)=>{let C=tt(c);return{divider:u===0,label:at(c),icon:(0,a.jsx)(C,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:R===c&&(0,a.jsx)(He,{size:14})}),handle:()=>{pe(c),l.mode==="edit"&&q()}}})]},{icon:(0,a.jsx)(Ta,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||X(),handle:T},{icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ee((await S()).contents),M({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!de||s,handle:async()=>{let c=zt(Ae());await re({configs:_e.fromEntries(c.map(xo))});for(let u of c)f({cellId:u,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ke,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{k({})}},{icon:(0,a.jsx)(gt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Re,{onClose:o}))}},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Re,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Je,{size:14,strokeWidth:1.5}),label:he,hidden:!ce||s,handle:()=>{b()}},{icon:(0,a.jsx)(qa,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:j,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Ea,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{v()}},{icon:(0,a.jsx)(pt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{y()}},{icon:(0,a.jsx)(Se,{size:14,strokeWidth:1.5}),label:"Show all code",hotkey:"global.showAllCode",handle:()=>r(!1,"code"),redundant:!0},{icon:(0,a.jsx)(Oe,{size:14,strokeWidth:1.5}),label:"Hide all code",hotkey:"global.hideAllCode",handle:()=>r(!0,"code"),redundant:!0},{icon:(0,a.jsx)(Se,{size:14,strokeWidth:1.5}),label:"Show all markdown code",hotkey:"global.showAllMarkdownCode",handle:()=>r(!1,"markdown"),redundant:!0},{icon:(0,a.jsx)(Oe,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",hotkey:"global.hideAllMarkdownCode",handle:()=>r(!0,"markdown"),redundant:!0},{icon:(0,a.jsx)(Ia,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:w,redundant:!0},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:x,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ue,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>A(wo)},{icon:(0,a.jsx)(Xt,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>ie(ko)},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>oe(yo),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Resources",handle:E,dropdown:[{icon:(0,a.jsx)(yt,{size:14,strokeWidth:1.5}),label:"Documentation",handle:bo},{icon:(0,a.jsx)(_a,{className:"h-3.5 w-3.5"}),label:"GitHub",handle:fo},{icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:uo},{icon:(0,a.jsx)(la,{className:"h-3.5 w-3.5"}),label:"YouTube",handle:mo},{icon:(0,a.jsx)(Mt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:po}]},{divider:!0,icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:ho},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:co}].filter(ro).map(so),e[15]=k,e[16]=g,e[17]=ce,e[18]=p,e[19]=y,e[20]=o,e[21]=w,e[22]=T,e[23]=N,e[24]=x,e[25]=le,e[26]=t,e[27]=U,e[28]=ue,e[29]=de,e[30]=me,e[31]=s,e[32]=n,e[33]=ne,e[34]=S,e[35]=j,e[36]=v,e[37]=re,e[38]=R,e[39]=d,e[40]=r,e[41]=A,e[42]=ie,e[43]=pe,e[44]=oe,e[45]=F,e[46]=V,e[47]=B,e[48]=P,e[49]=i,e[50]=q,e[51]=b,e[52]=he,e[53]=f,e[54]=l.mode,e[55]=Q):Q=e[55],Q}function so(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(lo)}:e}function lo(e){return!e.hidden}function ro(e){return!e.hidden}function co(){let e=ka();window.open(e,"_blank")}function ho(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function po(){window.open(W.releasesPage,"_blank")}function mo(){window.open(W.youtube,"_blank")}function uo(){window.open(W.discordLink,"_blank")}function fo(){window.open(W.githubPage,"_blank")}function bo(){window.open(W.docsPage,"_blank")}function yo(e){return!e}function ko(e){return!e}function wo(e){return!e}function xo(e){return[e,{disabled:!1}]}async function go(){let e=document.getElementById("App");e&&await $t({element:e,filename:document.title,prepare:Ut})}function jo(){return window.print()}function vo(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 Co(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(He,{size:14})})}function ae(){M({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{et as a,Ke as c,Ka as i,Ue as l,nt as n,Ze as o,ot as r,Je as s,io as t,$e 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-D5xY00XH.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-BclLs_8o.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-y72bE5iF.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
@@ -247,7 +247,7 @@
247
247
  <link rel="stylesheet" crossorigin href="./assets/cells-BVzo2MHf.css">
248
248
  <link rel="stylesheet" crossorigin href="./assets/markdown-renderer-DdDKmWlR.css">
249
249
  <link rel="stylesheet" crossorigin href="./assets/JsonOutput-BQtz7-np.css">
250
- <link rel="stylesheet" crossorigin href="./assets/index-Bj8QWDiJ.css">
250
+ <link rel="stylesheet" crossorigin href="./assets/index-CaelsqOA.css">
251
251
  </head>
252
252
  <body>
253
253
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.23.12-dev20",
3
+ "version": "0.23.12-dev23",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -1,6 +1,15 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
- import { beforeEach, describe, expect, it, type Mock, vi } from "vitest";
2
+ import {
3
+ afterEach,
4
+ beforeEach,
5
+ describe,
6
+ expect,
7
+ it,
8
+ type Mock,
9
+ vi,
10
+ } from "vitest";
3
11
  import { variableName } from "@/__tests__/branded";
12
+ import * as aiContext from "@/core/ai/context/context";
4
13
  import { getCodes } from "@/core/codemirror/copilot/getCodes";
5
14
  import { dataSourceConnectionsAtom } from "@/core/datasets/data-source-connections";
6
15
  import { DUCKDB_ENGINE } from "@/core/datasets/engines";
@@ -8,10 +17,11 @@ import { datasetsAtom } from "@/core/datasets/state";
8
17
  import type { DatasetsState } from "@/core/datasets/types";
9
18
  import { store } from "@/core/state/jotai";
10
19
  import { variablesAtom } from "@/core/variables/state";
11
- import type { UIMessage } from "ai";
20
+ import type { FileUIPart, UIMessage } from "ai";
12
21
  import {
13
22
  codeToCells,
14
23
  getAICompletionBody,
24
+ getAICompletionBodyWithAttachments,
15
25
  isContextAttachment,
16
26
  MARIMO_CONTEXT_PART_TYPE,
17
27
  resolveChatContext,
@@ -440,6 +450,42 @@ describe("isContextAttachment", () => {
440
450
  });
441
451
  });
442
452
 
453
+ describe("context attachment stamping", () => {
454
+ const rawAttachment: FileUIPart = {
455
+ type: "file",
456
+ mediaType: "image/png",
457
+ url: "data:image/png;base64,abc",
458
+ };
459
+
460
+ beforeEach(() => {
461
+ vi.spyOn(aiContext, "getAIContextRegistry").mockReturnValue({
462
+ parseAllContextIds: () => ["data://t1"],
463
+ formatContextForAI: () => '<data name="t1" />',
464
+ getAttachmentsForContext: async () => [rawAttachment],
465
+ } as unknown as ReturnType<typeof aiContext.getAIContextRegistry>);
466
+ });
467
+
468
+ afterEach(() => {
469
+ vi.restoreAllMocks();
470
+ });
471
+
472
+ it("stamps chat attachments as context-derived", async () => {
473
+ const { attachments } = await resolveChatContext("see @data://t1");
474
+ expect(attachments).toHaveLength(1);
475
+ expect(isContextAttachment(attachments[0])).toBe(true);
476
+ // The original attachment is left untouched (we return a stamped copy).
477
+ expect(rawAttachment.providerMetadata).toBeUndefined();
478
+ });
479
+
480
+ it("stamps completion attachments the same way as chat", async () => {
481
+ const { attachments } = await getAICompletionBodyWithAttachments({
482
+ input: "see @data://t1",
483
+ });
484
+ expect(attachments).toHaveLength(1);
485
+ expect(isContextAttachment(attachments[0])).toBe(true);
486
+ });
487
+ });
488
+
443
489
  describe("codeToCells", () => {
444
490
  it("should return empty array for empty string", () => {
445
491
  const code = "";
@@ -9,6 +9,7 @@ import {
9
9
  import type { ReactCodeMirrorRef } from "@uiw/react-codemirror";
10
10
  import type { DataUIPart, FileUIPart, UIMessage } from "ai";
11
11
  import { getAIContextRegistry } from "@/core/ai/context/context";
12
+ import type { ContextLocatorId } from "@/core/ai/context/registry";
12
13
  import { getCodes } from "@/core/codemirror/copilot/getCodes";
13
14
  import type { LanguageAdapterType } from "@/core/codemirror/language/types";
14
15
  import type { AiCompletionRequest } from "@/core/network/types";
@@ -89,20 +90,51 @@ export function isContextAttachment(part: UIMessage["parts"][number]): boolean {
89
90
  }
90
91
 
91
92
  /**
92
- * Resolve @-context for messages. They represent referenced
93
- * datasets, variables, or other context from the user's prompt.
93
+ * Stamp a context-derived attachment with a provenance marker.
94
+ *
95
+ * Some @-mentions resolve to file attachments (e.g. a cell's image output),
96
+ * which get appended to the user message right alongside files the user
97
+ * uploaded by hand. Once they're in the message the two are indistinguishable,
98
+ * so we mark the context-derived ones. This matters on message edit: we
99
+ * re-resolve context from the edited text, and `isContextAttachment` lets us
100
+ * drop only the stale context attachments while preserving the user's own
101
+ * uploads
94
102
  */
95
- export async function resolveChatContext(
103
+ function stampContextAttachment(attachment: FileUIPart): FileUIPart {
104
+ return {
105
+ ...attachment,
106
+ providerMetadata: {
107
+ ...attachment.providerMetadata,
108
+ // Merge within the `marimo` namespace so we don't clobber any other
109
+ // marimo metadata a provider may have already set.
110
+ marimo: {
111
+ ...attachment.providerMetadata?.marimo,
112
+ ...CONTEXT_ATTACHMENT_METADATA.marimo,
113
+ },
114
+ },
115
+ };
116
+ }
117
+
118
+ interface ResolvedContext {
119
+ plainText: string;
120
+ contextIds: ContextLocatorId[];
121
+ attachments: FileUIPart[];
122
+ }
123
+
124
+ /**
125
+ * Parse @-context for messages
126
+ */
127
+ async function resolveContextAttachments(
96
128
  input: string,
97
- ): Promise<ResolvedChatContext> {
129
+ ): Promise<ResolvedContext> {
98
130
  if (!input.includes(CONTEXT_TRIGGER)) {
99
- return { contextPart: null, attachments: [] };
131
+ return { plainText: "", contextIds: [], attachments: [] };
100
132
  }
101
133
 
102
134
  const registry = getAIContextRegistry(store);
103
135
  const contextIds = registry.parseAllContextIds(input);
104
136
  if (contextIds.length === 0) {
105
- return { contextPart: null, attachments: [] };
137
+ return { plainText: "", contextIds: [], attachments: [] };
106
138
  }
107
139
 
108
140
  const plainText = registry.formatContextForAI(contextIds);
@@ -110,20 +142,24 @@ export async function resolveChatContext(
110
142
  let attachments: FileUIPart[] = [];
111
143
  try {
112
144
  const resolved = await registry.getAttachmentsForContext(contextIds);
113
- attachments = resolved.map((attachment) => ({
114
- ...attachment,
115
- providerMetadata: {
116
- ...attachment.providerMetadata,
117
- marimo: {
118
- ...attachment.providerMetadata?.marimo,
119
- ...CONTEXT_ATTACHMENT_METADATA.marimo,
120
- },
121
- },
122
- }));
145
+ attachments = resolved.map(stampContextAttachment);
123
146
  } catch (error) {
124
147
  Logger.error("Error getting attachments:", error);
125
148
  }
126
149
 
150
+ return { plainText, contextIds, attachments };
151
+ }
152
+
153
+ /**
154
+ * Resolve @-context for messages. They represent referenced
155
+ * datasets, variables, or other context from the user's prompt.
156
+ */
157
+ export async function resolveChatContext(
158
+ input: string,
159
+ ): Promise<ResolvedChatContext> {
160
+ const { plainText, contextIds, attachments } =
161
+ await resolveContextAttachments(input);
162
+
127
163
  let contextPart: MarimoContextUIPart | null = null;
128
164
  if (plainText.trim()) {
129
165
  contextPart = {
@@ -141,31 +177,13 @@ export async function resolveChatContext(
141
177
  export async function getAICompletionBodyWithAttachments({
142
178
  input,
143
179
  }: Opts): Promise<AICompletionBodyWithAttachments> {
144
- let contextString = "";
145
- let attachments: FileUIPart[] = [];
146
-
147
- // Skip if no '@' in the input
148
- if (input.includes("@")) {
149
- const registry = getAIContextRegistry(store);
150
- const contextIds = registry.parseAllContextIds(input);
151
-
152
- // Get context string
153
- contextString = registry.formatContextForAI(contextIds);
154
-
155
- // Get attachments
156
- try {
157
- attachments = await registry.getAttachmentsForContext(contextIds);
158
- Logger.debug("Included attachments", attachments.length);
159
- } catch (error) {
160
- Logger.error("Error getting attachments:", error);
161
- }
162
- }
180
+ const { plainText, attachments } = await resolveContextAttachments(input);
163
181
 
164
182
  return {
165
183
  body: {
166
184
  includeOtherCode: getCodes(""),
167
185
  context: {
168
- plainText: contextString,
186
+ plainText,
169
187
  schema: [],
170
188
  variables: [],
171
189
  },
@@ -48,7 +48,9 @@ export const AppContainer: React.FC<PropsWithChildren<Props>> = ({
48
48
  "bg-background w-full h-full text-textColor",
49
49
  "flex flex-col overflow-y-auto",
50
50
  width === "full" && "config-width-full",
51
- width === "columns" ? "overflow-x-auto" : "overflow-x-hidden",
51
+ width === "columns"
52
+ ? "overflow-x-auto"
53
+ : "overflow-x-auto sm:overflow-x-hidden",
52
54
  "print:height-fit",
53
55
  )}
54
56
  >
@@ -32,9 +32,9 @@ export const VerticalLayoutWrapper: React.FC<PropsWithChildren<Props>> = ({
32
32
  // This padding needs to be the same from above to be correctly applied
33
33
  "pb-24 sm:pb-12",
34
34
  appConfig.width === "compact" &&
35
- "max-w-(--content-width) min-w-[400px]",
35
+ "max-w-(--content-width) sm:min-w-[400px]",
36
36
  appConfig.width === "medium" &&
37
- "max-w-(--content-width-medium) min-w-[400px]",
37
+ "max-w-(--content-width-medium) sm:min-w-[400px]",
38
38
  appConfig.width === "columns" && "w-fit",
39
39
  appConfig.width === "full" && "max-w-full",
40
40
  // Hide the cells for a fake loading effect, to avoid flickering