@marimo-team/frontend 0.19.8-dev19 → 0.19.8-dev21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{JsonOutput-BSoo6rnn.js → JsonOutput-DsO4felE.js} +1 -1
- package/dist/assets/MarimoErrorOutput-DrTj9k_Z.js +7 -0
- package/dist/assets/{add-cell-with-ai-BN_m4VjP.js → add-cell-with-ai-CPu9tI-Q.js} +1 -1
- package/dist/assets/{agent-panel-CbBdQTaH.js → agent-panel-Dbh-hMbm.js} +1 -1
- package/dist/assets/{ai-model-dropdown-Bfoz25CZ.js → ai-model-dropdown-CODXtvnr.js} +4 -4
- package/dist/assets/{app-config-button-CrXbU4T9.js → app-config-button-BGuwQV5R.js} +1 -1
- package/dist/assets/{cell-editor-BAqUkTV8.js → cell-editor-BpkNlmop.js} +1 -1
- package/dist/assets/{chat-display-CKRYf3fp.js → chat-display-BnUDaREA.js} +1 -1
- package/dist/assets/{chat-panel-CYVu9MUa.js → chat-panel-BpDjUlzW.js} +1 -1
- package/dist/assets/{column-preview-DtEv_bAg.js → column-preview-Bz3KIcIX.js} +1 -1
- package/dist/assets/{command-palette-A_nn_y2h.js → command-palette-D8q355Sm.js} +1 -1
- package/dist/assets/{edit-page-COE4a7-G.js → edit-page-e6xxDbUd.js} +3 -3
- package/dist/assets/{error-panel-B1n50cDF.js → error-panel-BMcWP1VH.js} +1 -1
- package/dist/assets/{file-explorer-panel-Ctq6A5l_.js → file-explorer-panel-th-ny103.js} +1 -1
- package/dist/assets/{home-page-CyLRJEZg.js → home-page-Bgzw3IP3.js} +1 -1
- package/dist/assets/{hooks-DfBLwtVf.js → hooks-B_N-kbrq.js} +1 -1
- package/dist/assets/{index-Ud-15Gp2.js → index-U7La6ZBB.js} +3 -3
- package/dist/assets/{layout-DFhAD73H.js → layout-D7NLGhPa.js} +1 -1
- package/dist/assets/{packages-panel-BMqAMJxC.js → packages-panel-DsF1uf9X.js} +1 -1
- package/dist/assets/{panels-BPRD9NT1.js → panels-aWY9-L83.js} +1 -1
- package/dist/assets/{run-page-CPt0ml4p.js → run-page-DQU-eaKQ.js} +1 -1
- package/dist/assets/{scratchpad-panel-DJdZVxe5.js → scratchpad-panel-N4QLTtHb.js} +1 -1
- package/dist/assets/{session-panel-Bqe3Jmko.js → session-panel-Cof-5_26.js} +1 -1
- package/dist/assets/{useNotebookActions-DY_TVOaP.js → useNotebookActions-BEKXbrFJ.js} +1 -1
- package/dist/assets/{utilities.esm-D1YtU9uV.js → utilities.esm-AIy-_q0N.js} +1 -1
- package/dist/index.html +8 -8
- package/package.json +1 -1
- package/src/components/app-config/ai-config.tsx +11 -2
- package/src/utils/__tests__/url-parser.test.ts +22 -0
- package/src/utils/url-parser.ts +1 -1
- package/dist/assets/MarimoErrorOutput-CAX5i2GE.js +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as de}from"./chunk-LvLJmgfZ.js";import{d as D,l as Ve,p as Be,u as ee}from"./useEvent-BhXAndur.js";import{t as Ue}from"./react-Bj1aDYRI.js";import{Bn as Ye,Gn as $e,Hn as Fe,Xn as Ge,cn as Ke,fn as ce,g as Je,gr as Xe,jt as Ze,ln as Qe,m as he,ni as te,sn as et,t as tt,w as pe}from"./cells-DbD2lYze.js";import{t as W}from"./compiler-runtime-B3qBwwSJ.js";import{n as at}from"./assertNever-CBU83Y6o.js";import{s as me}from"./useLifecycle-ClI_npeg.js";import{n as ot}from"./add-database-form-CvczP0Mq.js";import{n as nt,x as it}from"./ai-model-dropdown-Bfoz25CZ.js";import{a as ue,d as P}from"./hotkeys-BHHWjLlp.js";import{y as lt}from"./utils-YqBXNpsM.js";import{n as _,t as fe}from"./constants-B6Cb__3x.js";import{S as ye,h as st,x as rt}from"./config-D2-Bw6QC.js";import{t as dt}from"./jsx-runtime-ZmTK25f3.js";import{r as ct,t as ae}from"./button-CZ3Cs4qb.js";import{r as I}from"./requests-B4FYHTZl.js";import{t as h}from"./createLucideIcon-BCdY6lG5.js";import{a as be,f as ht,i as ke,m as pt,p as xe,u as we}from"./layout-DFhAD73H.js";import{t as ge}from"./check-Dr3SxUsb.js";import{c as mt,d as je,n as ut,o as ft,r as ve,t as yt}from"./download-CmdFQXRz.js";import{f as bt}from"./maps-D2_Mq1pZ.js";import{r as kt}from"./useCellActionButton-VRGP_KkG.js";import{t as xt}from"./copy-D-8y6iMN.js";import{t as wt}from"./download-Dg7clfkc.js";import{t as gt}from"./eye-off-AK_9uodG.js";import{t as jt}from"./file-plus-corner-CvAy4H5W.js";import{t as vt}from"./file-Ch78NKWp.js";import{i as Ct,n as zt,r as Mt,t as Wt}from"./youtube--tNPNRy6.js";import{n as _t,t as St}from"./house-BI81AWSn.js";import{n as At}from"./play-GLWQQs7F.js";import{t as Nt}from"./link-DxicfMbs.js";import{r as Dt}from"./input-DHHmNa19.js";import{t as Pt}from"./settings-OBbrbhij.js";import{y as It}from"./textarea-8F9GOEGf.js";import{t as Et}from"./square-DPZjfUaq.js";import{t as C}from"./use-toast-T0_cQDma.js";import{n as Ce,t as Tt}from"./paths-Dfii2bN8.js";import{o as Ht}from"./session-fBtIbMpB.js";import{a as Lt,c as qt,i as Rt,n as Ot,r as Vt,s as Bt,t as Ut}from"./select-B7bfltkI.js";import{t as Yt}from"./tooltip-C_WgOOcZ.js";import{a as ze,i as $t,r as Ft}from"./mode-CjmQoGEk.js";import{o as Gt}from"./alert-dialog-Ctz24SMn.js";import{a as Kt,c as Jt,i as Xt,n as Zt,r as Qt}from"./dialog-tQELcltn.js";import{n as oe}from"./ImperativeModal-DZr52ffu.js";import{r as ea,t as ta}from"./share-rXkgGlhr.js";import{t as U}from"./copy-DHrHayPa.js";import{r as aa}from"./useRunCells-BOowME8Z.js";import{a as oa}from"./cell-link-BoOn0OpK.js";import{a as Me}from"./renderShortcut-B1jzzLJw.js";import{t as na}from"./icons-DjR3qLG_.js";import{t as ia}from"./links-DgZx-VxW.js";import{r as la,t as sa}from"./hooks-DfBLwtVf.js";import{t as We}from"./types-DZmRsGZN.js";var ra=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),da=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),_e=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"}]]),Se=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"}]]),Ae=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"}]]),ca=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"}]]),ha=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"}]]),pa=h("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Ne=h("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),ma=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"}]]),ua=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),De=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"}]]),fa=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"}]]),ya=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"}]]),Pe=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"}]]),Ie=W(),ne=de(Ue(),1),a=de(dt(),1),Y="https://static.marimo.app";const ba=e=>{let t=(0,Ie.c)(25),{onClose:n}=e,[o,l]=(0,ne.useState)(""),{exportAsHTML:r}=I(),s=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${Y}/static/${s}`,d;t[0]!==r||t[1]!==n||t[2]!==s?(d=async v=>{v.preventDefault(),n();let S=await r({download:!1,includeCode:!0,files:ht.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Y}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:S,path:s})}).catch(()=>{z.dismiss(),C({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:_.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),C({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=s,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(Jt,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Kt,{children:[p,(0,a.jsxs)(Qt,{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:Y,target:"_blank",children:Y}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{l(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let m;t[7]===o?m=t[8]:(m=(0,a.jsx)(Dt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=m);let u;t[9]===i?u=t[10]:(u=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(ka,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=u);let f;t[11]!==m||t[12]!==u?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[m,u]}),t[11]=m,t[12]=u,t[13]=f):f=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(ae,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(ae,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await U(i)},children:"Create"}),t[16]=i,t[17]=b);let k;t[18]!==y||t[19]!==b?(k=(0,a.jsxs)(Xt,{children:[y,b]}),t[18]=y,t[19]=b,t[20]=k):k=t[20];let j;return t[21]!==d||t[22]!==k||t[23]!==f?(j=(0,a.jsx)(Zt,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,f,k]})}),t[21]=d,t[22]=k,t[23]=f,t[24]=j):j=t[24],j};var ka=e=>{let t=(0,Ie.c)(8),[n,o]=ne.useState(!1),l;t[0]===e.text?l=t[1]:(l=ct.stopPropagation(async p=>{p.preventDefault(),await U(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=l);let r=l,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(xt,{size:14,strokeWidth:1.5}),t[2]=s):s=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(ae,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:s}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Yt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},xa=W();function wa(){let e=document.getElementsByClassName(fe.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=te.findElement(t);if(!o){P.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:te.parse(o.id)}}}return P.warn("No visible output area found for scroll anchor"),null}function ga(e){if(!e){P.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(te.create(e.cellId));if(!t){P.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${fe.outputArea}`)){P.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ee(){let e=(0,xa.c)(2),t=D(ze),n;return e[0]===t?n=e[1]:(n=()=>{let o=wa();t(l=>({mode:$t(l.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{ga(o)})})},e[0]=t,e[1]=n),n}const Te=Be(!1);var ja=W();const va=()=>{let e=(0,ja.c)(7),{selectedLayout:t}=be(),{setLayoutView:n}=ke();if(ye()&&!ce("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Bt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(qt,{placeholder:"Select a view"})}),e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Ot,{children:(0,a.jsxs)(Vt,{children:[(0,a.jsx)(Lt,{children:"View as"}),We.map(za)]})}),e[3]=r):r=e[3];let s;return e[4]!==t||e[5]!==o?(s=(0,a.jsxs)(Ut,{"data-testid":"layout-select",value:t,onValueChange:o,children:[l,r]}),e[4]=t,e[5]=o,e[6]=s):s=e[6],s};function Ca(e){return(0,a.jsx)(He(e),{className:"h-4 w-4"})}function He(e){switch(e){case"vertical":return ma;case"grid":return Mt;case"slides":return De;default:return at(e),Et}}function Le(e){return me(e)}function za(e){return(0,a.jsx)(Rt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ca(e),(0,a.jsx)("span",{children:Le(e)})]})},e)}var Ma=W();function Wa(e){let t=(0,Ma.c)(5),{openPrompt:n,closeModal:o}=oe(),{sendCopy:l}=I(),r;return t[0]!==o||t[1]!==n||t[2]!==l||t[3]!==e?(r=()=>{if(!e)return null;let s=Tt.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Ce.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=s.join(Ce.dirname(e),i);l({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),ia(d)})}})},t[0]=o,t[1]=n,t[2]=l,t[3]=e,t[4]=r):r=t[4],r}const _a=()=>{let{updateCellConfig:e}=pe(),{saveCellConfig:t}=I();return(0,ne.useCallback)(async()=>{let n=new Ze,o=he(),l=o.cellIds.inOrderIds,r={};for(let i of l){if(o.cellData[i]===void 0)continue;let{code:d,config:p}=o.cellData[i];p.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let s=ue.entries(r);if(s.length!==0){await t({configs:r});for(let[i,d]of s)e({cellId:i,config:d})}},[e])};var Sa=W();function qe(){let e=(0,Sa.c)(4),{openConfirm:t}=oe(),n=D(st),{sendRestart:o}=I(),l;return e[0]!==t||e[1]!==o||e[2]!==n?(l=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(Gt,{onClick:async()=>{n({state:rt.CLOSING}),await o(),ea()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=l):l=e[3],l}var Aa=W(),E=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Na(){var se,re;let e=(0,Aa.c)(40),t=oa(),{openModal:n,closeModal:o}=oe(),{toggleApplication:l}=et(),{selectedPanel:r}=Ke(),[s]=Ve(ze),i=ee(Ft),d=_a(),[p]=lt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:m,addSetupCellIfDoesntExist:u,collapseAllCells:f,expandAllCells:y}=pe(),b=qe(),k=aa(),j=Wa(t),v=D(Te),S=D(nt),z=D(it),{exportAsMarkdown:$,readCode:A,saveCellConfig:F,updateCellOutputs:G}=I(),K=ee(Je),J=ee(tt),{selectedLayout:X}=be(),{setLayoutView:Z}=ke(),T=Ee(),Q=la(),H=((se=p.sharing)==null?void 0:se.html)??!0,L=((re=p.sharing)==null?void 0:re.wasm)??!0,q;e[0]===Symbol.for("react.memo_cache_sentinel")?(q=ce("server_side_pdf_export"),e[0]=q):q=e[0];let le=q,R=le||s.mode==="present",Re=Ga,O;e[1]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(wt,{size:14,strokeWidth:1.5}),e[1]=O):O=e[1];let V;e[2]===Symbol.for("react.memo_cache_sentinel")?(V=(0,a.jsx)(xe,{size:14,strokeWidth:1.5}),e[2]=V):V=e[2];let M;e[3]===t?M=e[4]:(M=async()=>{if(!t){ie();return}await we({filename:t,includeCode:!0})},e[3]=t,e[4]=M);let B;return e[5]!==u||e[6]!==J||e[7]!==m||e[8]!==o||e[9]!==f||e[10]!==j||e[11]!==y||e[12]!==$||e[13]!==t||e[14]!==K||e[15]!==d||e[16]!==i||e[17]!==n||e[18]!==R||e[19]!==A||e[20]!==b||e[21]!==k||e[22]!==F||e[23]!==X||e[24]!==r||e[25]!==v||e[26]!==z||e[27]!==Z||e[28]!==S||e[29]!==H||e[30]!==L||e[31]!==M||e[32]!==Q||e[33]!==l||e[34]!==T||e[35]!==g||e[36]!==w||e[37]!==G||e[38]!==s.mode?(B=[{icon:O,label:"Download",handle:E,dropdown:[{icon:V,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(xe,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ie();return}await we({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(na,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await $({download:!1});ve(new Blob([c],{type:"text/plain"}),je.toMarkdown(document.title))}},{icon:(0,a.jsx)(pt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await A();ve(new Blob([c.contents],{type:"text/plain"}),je.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:s.mode!=="present",tooltip:s.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Me("global.hideCode",!1)]}),handle:Fa},{icon:(0,a.jsx)(vt,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:!R,tooltip:R?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Me("global.hideCode",!1)]}),handle:async()=>{if(le){if(!t){ie();return}await mt("Downloading PDF...",async N=>{await sa({takeScreenshots:()=>Q({progress:N}),updateCellOutputs:G}),await ut({filename:t,webpdf:!1})});return}let c=new Event("export-beforeprint"),x=new Event("export-afterprint");(function(){window.dispatchEvent(c),setTimeout($a,0),setTimeout(()=>window.dispatchEvent(x),0)})()}}]},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Share",handle:E,hidden:!H&&!L,dropdown:[{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!H,handle:async()=>{n((0,a.jsx)(ba,{onClose:o}))}},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!L,handle:async()=>{await U(ta({code:(await A()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:E,dropdown:Qe.flatMap(c=>{let{type:x,Icon:N,hidden:Oe}=c;return Oe?[]:{label:me(x),rightElement:Re(r===x),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),handle:()=>l(x)}})},{icon:(0,a.jsx)(De,{size:14,strokeWidth:1.5}),label:"Present as",handle:E,dropdown:[{icon:s.mode==="present"?(0,a.jsx)(It,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{T()}},...We.map((c,x)=>{let N=He(c);return{divider:x===0,label:Le(c),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:X===c&&(0,a.jsx)(ge,{size:14})}),handle:()=>{Z(c),s.mode==="edit"&&T()}}})]},{icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ye(),handle:j},{icon:(0,a.jsx)(_e,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await U((await A()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(kt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!K||i,handle:async()=>{let c=Xe(he());await F({configs:ue.fromEntries(c.map(Ya))});for(let x of c)w({cellId:x,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{u({})}},{icon:(0,a.jsx)(Fe,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(ot,{onClose:o}))}},{icon:(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!J||i,handle:()=>{g()}},{icon:(0,a.jsx)(ya,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{m()}},{icon:(0,a.jsx)(gt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:f,redundant:!0},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(Se,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ua)},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Ba)},{icon:(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>S(Va),redundant:!0},{icon:(0,a.jsx)(bt,{size:14,strokeWidth:1.5}),label:"Resources",handle:E,dropdown:[{icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Oa},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Ra},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:qa},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:La},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ha}]},{divider:!0,icon:(0,a.jsx)(St,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Ta},{icon:(0,a.jsx)(jt,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ea}].filter(Ia).map(Da),e[5]=u,e[6]=J,e[7]=m,e[8]=o,e[9]=f,e[10]=j,e[11]=y,e[12]=$,e[13]=t,e[14]=K,e[15]=d,e[16]=i,e[17]=n,e[18]=R,e[19]=A,e[20]=b,e[21]=k,e[22]=F,e[23]=X,e[24]=r,e[25]=v,e[26]=z,e[27]=Z,e[28]=S,e[29]=H,e[30]=L,e[31]=M,e[32]=Q,e[33]=l,e[34]=T,e[35]=g,e[36]=w,e[37]=G,e[38]=s.mode,e[39]=B):B=e[39],B}function Da(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Pa)}:e}function Pa(e){return!e.hidden}function Ia(e){return!e.hidden}function Ea(){let e=Ht();window.open(e,"_blank")}function Ta(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ha(){window.open(_.releasesPage,"_blank")}function La(){window.open(_.youtube,"_blank")}function qa(){window.open(_.discordLink,"_blank")}function Ra(){window.open(_.githubPage,"_blank")}function Oa(){window.open(_.docsPage,"_blank")}function Va(e){return!e}function Ba(e){return!e}function Ua(e){return!e}function Ya(e){return[e,{disabled:!1}]}function $a(){return window.print()}async function Fa(){let e=document.getElementById("App");e&&await ft({element:e,filename:document.title,prepare:yt})}function Ga(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(ge,{size:14})})}function ie(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Ee as a,Ae as c,Te as i,Se as l,qe as n,Pe as o,va as r,Ne as s,Na as t,_e as u};
|
|
1
|
+
import{s as de}from"./chunk-LvLJmgfZ.js";import{d as D,l as Ve,p as Be,u as ee}from"./useEvent-BhXAndur.js";import{t as Ue}from"./react-Bj1aDYRI.js";import{Bn as Ye,Gn as $e,Hn as Fe,Xn as Ge,cn as Ke,fn as ce,g as Je,gr as Xe,jt as Ze,ln as Qe,m as he,ni as te,sn as et,t as tt,w as pe}from"./cells-DbD2lYze.js";import{t as W}from"./compiler-runtime-B3qBwwSJ.js";import{n as at}from"./assertNever-CBU83Y6o.js";import{s as me}from"./useLifecycle-ClI_npeg.js";import{n as ot}from"./add-database-form-CvczP0Mq.js";import{n as nt,x as it}from"./ai-model-dropdown-CODXtvnr.js";import{a as ue,d as P}from"./hotkeys-BHHWjLlp.js";import{y as lt}from"./utils-YqBXNpsM.js";import{n as _,t as fe}from"./constants-B6Cb__3x.js";import{S as ye,h as st,x as rt}from"./config-D2-Bw6QC.js";import{t as dt}from"./jsx-runtime-ZmTK25f3.js";import{r as ct,t as ae}from"./button-CZ3Cs4qb.js";import{r as I}from"./requests-B4FYHTZl.js";import{t as h}from"./createLucideIcon-BCdY6lG5.js";import{a as be,f as ht,i as ke,m as pt,p as xe,u as we}from"./layout-D7NLGhPa.js";import{t as ge}from"./check-Dr3SxUsb.js";import{c as mt,d as je,n as ut,o as ft,r as ve,t as yt}from"./download-CmdFQXRz.js";import{f as bt}from"./maps-D2_Mq1pZ.js";import{r as kt}from"./useCellActionButton-VRGP_KkG.js";import{t as xt}from"./copy-D-8y6iMN.js";import{t as wt}from"./download-Dg7clfkc.js";import{t as gt}from"./eye-off-AK_9uodG.js";import{t as jt}from"./file-plus-corner-CvAy4H5W.js";import{t as vt}from"./file-Ch78NKWp.js";import{i as Ct,n as zt,r as Mt,t as Wt}from"./youtube--tNPNRy6.js";import{n as _t,t as St}from"./house-BI81AWSn.js";import{n as At}from"./play-GLWQQs7F.js";import{t as Nt}from"./link-DxicfMbs.js";import{r as Dt}from"./input-DHHmNa19.js";import{t as Pt}from"./settings-OBbrbhij.js";import{y as It}from"./textarea-8F9GOEGf.js";import{t as Et}from"./square-DPZjfUaq.js";import{t as C}from"./use-toast-T0_cQDma.js";import{n as Ce,t as Tt}from"./paths-Dfii2bN8.js";import{o as Ht}from"./session-fBtIbMpB.js";import{a as Lt,c as qt,i as Rt,n as Ot,r as Vt,s as Bt,t as Ut}from"./select-B7bfltkI.js";import{t as Yt}from"./tooltip-C_WgOOcZ.js";import{a as ze,i as $t,r as Ft}from"./mode-CjmQoGEk.js";import{o as Gt}from"./alert-dialog-Ctz24SMn.js";import{a as Kt,c as Jt,i as Xt,n as Zt,r as Qt}from"./dialog-tQELcltn.js";import{n as oe}from"./ImperativeModal-DZr52ffu.js";import{r as ea,t as ta}from"./share-rXkgGlhr.js";import{t as U}from"./copy-DHrHayPa.js";import{r as aa}from"./useRunCells-BOowME8Z.js";import{a as oa}from"./cell-link-BoOn0OpK.js";import{a as Me}from"./renderShortcut-B1jzzLJw.js";import{t as na}from"./icons-DjR3qLG_.js";import{t as ia}from"./links-DgZx-VxW.js";import{r as la,t as sa}from"./hooks-B_N-kbrq.js";import{t as We}from"./types-DZmRsGZN.js";var ra=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),da=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),_e=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"}]]),Se=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"}]]),Ae=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"}]]),ca=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"}]]),ha=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"}]]),pa=h("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Ne=h("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),ma=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"}]]),ua=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),De=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"}]]),fa=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"}]]),ya=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"}]]),Pe=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"}]]),Ie=W(),ne=de(Ue(),1),a=de(dt(),1),Y="https://static.marimo.app";const ba=e=>{let t=(0,Ie.c)(25),{onClose:n}=e,[o,l]=(0,ne.useState)(""),{exportAsHTML:r}=I(),s=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${Y}/static/${s}`,d;t[0]!==r||t[1]!==n||t[2]!==s?(d=async v=>{v.preventDefault(),n();let S=await r({download:!1,includeCode:!0,files:ht.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Y}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:S,path:s})}).catch(()=>{z.dismiss(),C({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:_.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),C({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=s,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(Jt,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Kt,{children:[p,(0,a.jsxs)(Qt,{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:Y,target:"_blank",children:Y}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{l(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let m;t[7]===o?m=t[8]:(m=(0,a.jsx)(Dt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=m);let u;t[9]===i?u=t[10]:(u=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(ka,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=u);let f;t[11]!==m||t[12]!==u?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[m,u]}),t[11]=m,t[12]=u,t[13]=f):f=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(ae,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(ae,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await U(i)},children:"Create"}),t[16]=i,t[17]=b);let k;t[18]!==y||t[19]!==b?(k=(0,a.jsxs)(Xt,{children:[y,b]}),t[18]=y,t[19]=b,t[20]=k):k=t[20];let j;return t[21]!==d||t[22]!==k||t[23]!==f?(j=(0,a.jsx)(Zt,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,f,k]})}),t[21]=d,t[22]=k,t[23]=f,t[24]=j):j=t[24],j};var ka=e=>{let t=(0,Ie.c)(8),[n,o]=ne.useState(!1),l;t[0]===e.text?l=t[1]:(l=ct.stopPropagation(async p=>{p.preventDefault(),await U(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=l);let r=l,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(xt,{size:14,strokeWidth:1.5}),t[2]=s):s=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(ae,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:s}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Yt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},xa=W();function wa(){let e=document.getElementsByClassName(fe.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=te.findElement(t);if(!o){P.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:te.parse(o.id)}}}return P.warn("No visible output area found for scroll anchor"),null}function ga(e){if(!e){P.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(te.create(e.cellId));if(!t){P.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${fe.outputArea}`)){P.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ee(){let e=(0,xa.c)(2),t=D(ze),n;return e[0]===t?n=e[1]:(n=()=>{let o=wa();t(l=>({mode:$t(l.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{ga(o)})})},e[0]=t,e[1]=n),n}const Te=Be(!1);var ja=W();const va=()=>{let e=(0,ja.c)(7),{selectedLayout:t}=be(),{setLayoutView:n}=ke();if(ye()&&!ce("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Bt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(qt,{placeholder:"Select a view"})}),e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Ot,{children:(0,a.jsxs)(Vt,{children:[(0,a.jsx)(Lt,{children:"View as"}),We.map(za)]})}),e[3]=r):r=e[3];let s;return e[4]!==t||e[5]!==o?(s=(0,a.jsxs)(Ut,{"data-testid":"layout-select",value:t,onValueChange:o,children:[l,r]}),e[4]=t,e[5]=o,e[6]=s):s=e[6],s};function Ca(e){return(0,a.jsx)(He(e),{className:"h-4 w-4"})}function He(e){switch(e){case"vertical":return ma;case"grid":return Mt;case"slides":return De;default:return at(e),Et}}function Le(e){return me(e)}function za(e){return(0,a.jsx)(Rt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ca(e),(0,a.jsx)("span",{children:Le(e)})]})},e)}var Ma=W();function Wa(e){let t=(0,Ma.c)(5),{openPrompt:n,closeModal:o}=oe(),{sendCopy:l}=I(),r;return t[0]!==o||t[1]!==n||t[2]!==l||t[3]!==e?(r=()=>{if(!e)return null;let s=Tt.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Ce.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=s.join(Ce.dirname(e),i);l({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),ia(d)})}})},t[0]=o,t[1]=n,t[2]=l,t[3]=e,t[4]=r):r=t[4],r}const _a=()=>{let{updateCellConfig:e}=pe(),{saveCellConfig:t}=I();return(0,ne.useCallback)(async()=>{let n=new Ze,o=he(),l=o.cellIds.inOrderIds,r={};for(let i of l){if(o.cellData[i]===void 0)continue;let{code:d,config:p}=o.cellData[i];p.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let s=ue.entries(r);if(s.length!==0){await t({configs:r});for(let[i,d]of s)e({cellId:i,config:d})}},[e])};var Sa=W();function qe(){let e=(0,Sa.c)(4),{openConfirm:t}=oe(),n=D(st),{sendRestart:o}=I(),l;return e[0]!==t||e[1]!==o||e[2]!==n?(l=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(Gt,{onClick:async()=>{n({state:rt.CLOSING}),await o(),ea()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=l):l=e[3],l}var Aa=W(),E=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Na(){var se,re;let e=(0,Aa.c)(40),t=oa(),{openModal:n,closeModal:o}=oe(),{toggleApplication:l}=et(),{selectedPanel:r}=Ke(),[s]=Ve(ze),i=ee(Ft),d=_a(),[p]=lt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:m,addSetupCellIfDoesntExist:u,collapseAllCells:f,expandAllCells:y}=pe(),b=qe(),k=aa(),j=Wa(t),v=D(Te),S=D(nt),z=D(it),{exportAsMarkdown:$,readCode:A,saveCellConfig:F,updateCellOutputs:G}=I(),K=ee(Je),J=ee(tt),{selectedLayout:X}=be(),{setLayoutView:Z}=ke(),T=Ee(),Q=la(),H=((se=p.sharing)==null?void 0:se.html)??!0,L=((re=p.sharing)==null?void 0:re.wasm)??!0,q;e[0]===Symbol.for("react.memo_cache_sentinel")?(q=ce("server_side_pdf_export"),e[0]=q):q=e[0];let le=q,R=le||s.mode==="present",Re=Ga,O;e[1]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(wt,{size:14,strokeWidth:1.5}),e[1]=O):O=e[1];let V;e[2]===Symbol.for("react.memo_cache_sentinel")?(V=(0,a.jsx)(xe,{size:14,strokeWidth:1.5}),e[2]=V):V=e[2];let M;e[3]===t?M=e[4]:(M=async()=>{if(!t){ie();return}await we({filename:t,includeCode:!0})},e[3]=t,e[4]=M);let B;return e[5]!==u||e[6]!==J||e[7]!==m||e[8]!==o||e[9]!==f||e[10]!==j||e[11]!==y||e[12]!==$||e[13]!==t||e[14]!==K||e[15]!==d||e[16]!==i||e[17]!==n||e[18]!==R||e[19]!==A||e[20]!==b||e[21]!==k||e[22]!==F||e[23]!==X||e[24]!==r||e[25]!==v||e[26]!==z||e[27]!==Z||e[28]!==S||e[29]!==H||e[30]!==L||e[31]!==M||e[32]!==Q||e[33]!==l||e[34]!==T||e[35]!==g||e[36]!==w||e[37]!==G||e[38]!==s.mode?(B=[{icon:O,label:"Download",handle:E,dropdown:[{icon:V,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(xe,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ie();return}await we({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(na,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await $({download:!1});ve(new Blob([c],{type:"text/plain"}),je.toMarkdown(document.title))}},{icon:(0,a.jsx)(pt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await A();ve(new Blob([c.contents],{type:"text/plain"}),je.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:s.mode!=="present",tooltip:s.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Me("global.hideCode",!1)]}),handle:Fa},{icon:(0,a.jsx)(vt,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:!R,tooltip:R?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Me("global.hideCode",!1)]}),handle:async()=>{if(le){if(!t){ie();return}await mt("Downloading PDF...",async N=>{await sa({takeScreenshots:()=>Q({progress:N}),updateCellOutputs:G}),await ut({filename:t,webpdf:!1})});return}let c=new Event("export-beforeprint"),x=new Event("export-afterprint");(function(){window.dispatchEvent(c),setTimeout($a,0),setTimeout(()=>window.dispatchEvent(x),0)})()}}]},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Share",handle:E,hidden:!H&&!L,dropdown:[{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!H,handle:async()=>{n((0,a.jsx)(ba,{onClose:o}))}},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!L,handle:async()=>{await U(ta({code:(await A()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:E,dropdown:Qe.flatMap(c=>{let{type:x,Icon:N,hidden:Oe}=c;return Oe?[]:{label:me(x),rightElement:Re(r===x),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),handle:()=>l(x)}})},{icon:(0,a.jsx)(De,{size:14,strokeWidth:1.5}),label:"Present as",handle:E,dropdown:[{icon:s.mode==="present"?(0,a.jsx)(It,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{T()}},...We.map((c,x)=>{let N=He(c);return{divider:x===0,label:Le(c),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:X===c&&(0,a.jsx)(ge,{size:14})}),handle:()=>{Z(c),s.mode==="edit"&&T()}}})]},{icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ye(),handle:j},{icon:(0,a.jsx)(_e,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await U((await A()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(kt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!K||i,handle:async()=>{let c=Xe(he());await F({configs:ue.fromEntries(c.map(Ya))});for(let x of c)w({cellId:x,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{u({})}},{icon:(0,a.jsx)(Fe,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(ot,{onClose:o}))}},{icon:(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!J||i,handle:()=>{g()}},{icon:(0,a.jsx)(ya,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{m()}},{icon:(0,a.jsx)(gt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:f,redundant:!0},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(Se,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ua)},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Ba)},{icon:(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>S(Va),redundant:!0},{icon:(0,a.jsx)(bt,{size:14,strokeWidth:1.5}),label:"Resources",handle:E,dropdown:[{icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Oa},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Ra},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:qa},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:La},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ha}]},{divider:!0,icon:(0,a.jsx)(St,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Ta},{icon:(0,a.jsx)(jt,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ea}].filter(Ia).map(Da),e[5]=u,e[6]=J,e[7]=m,e[8]=o,e[9]=f,e[10]=j,e[11]=y,e[12]=$,e[13]=t,e[14]=K,e[15]=d,e[16]=i,e[17]=n,e[18]=R,e[19]=A,e[20]=b,e[21]=k,e[22]=F,e[23]=X,e[24]=r,e[25]=v,e[26]=z,e[27]=Z,e[28]=S,e[29]=H,e[30]=L,e[31]=M,e[32]=Q,e[33]=l,e[34]=T,e[35]=g,e[36]=w,e[37]=G,e[38]=s.mode,e[39]=B):B=e[39],B}function Da(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Pa)}:e}function Pa(e){return!e.hidden}function Ia(e){return!e.hidden}function Ea(){let e=Ht();window.open(e,"_blank")}function Ta(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ha(){window.open(_.releasesPage,"_blank")}function La(){window.open(_.youtube,"_blank")}function qa(){window.open(_.discordLink,"_blank")}function Ra(){window.open(_.githubPage,"_blank")}function Oa(){window.open(_.docsPage,"_blank")}function Va(e){return!e}function Ba(e){return!e}function Ua(e){return!e}function Ya(e){return[e,{disabled:!1}]}function $a(){return window.print()}async function Fa(){let e=document.getElementById("App");e&&await ft({element:e,filename:document.title,prepare:yt})}function Ga(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(ge,{size:14})})}function ie(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Ee as a,Ae as c,Te as i,Se as l,qe as n,Pe as o,va as r,Ne as s,Na as t,_e as u};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var at=Object.defineProperty;var it=(t,e,n)=>e in t?at(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var a=(t,e,n)=>it(t,typeof e!="symbol"?e+"":e,n);var j;import{s as ce}from"./chunk-LvLJmgfZ.js";import{i as G,l as D,p as P,u as ot}from"./useEvent-BhXAndur.js";import{t as lt}from"./react-Bj1aDYRI.js";import{$r as z,Qr as ut,Vr as ct,b as dt,qr as ft,y as mt}from"./cells-DbD2lYze.js";import{B as pt,C as de,D as ht,I as gt,N as yt,P as O,R as fe,k as W,w as me}from"./zod-H_cgTO0M.js";import{t as pe}from"./compiler-runtime-B3qBwwSJ.js";import{t as bt}from"./get-6uJrSKbw.js";import{t as wt}from"./assertNever-CBU83Y6o.js";import{t as vt}from"./debounce-B3mjKxHe.js";import{t as xt}from"./_baseSet-5Rdwpmr3.js";import{d as E,p as y}from"./hotkeys-BHHWjLlp.js";import{t as Et}from"./invariant-CAG_dYON.js";import{S as Ct}from"./utils-YqBXNpsM.js";import{S as _t}from"./config-D2-Bw6QC.js";import{a as kt}from"./switch-BUKXfBTu.js";import{n as he}from"./globals-BXYmO-WL.js";import{t as ge}from"./ErrorBoundary-B9Ifj8Jf.js";import{t as Rt}from"./jsx-runtime-ZmTK25f3.js";import{t as Ft}from"./button-CZ3Cs4qb.js";import{t as Nt}from"./cn-BKtXLv3a.js";import{Z as St}from"./JsonOutput-BSoo6rnn.js";import{t as qt}from"./createReducer-B3rBsy4P.js";import{t as ye}from"./requests-B4FYHTZl.js";import{t as be}from"./createLucideIcon-BCdY6lG5.js";import{t as Pt}from"./x-ZP5cObgf.js";import{a as Mt,l as jt,r as At}from"./markdown-renderer-D8AmLSIR.js";import{t as Tt}from"./DeferredRequestRegistry-tv0PqJZ0.js";import{t as K}from"./Deferred-CrO5-0RA.js";import{t as we}from"./uuid-DercMavo.js";import{t as It}from"./use-toast-T0_cQDma.js";import{t as ve}from"./tooltip-C_WgOOcZ.js";import{t as xe}from"./mode-CjmQoGEk.js";import{n as Lt,r as Ut,t as zt}from"./share-rXkgGlhr.js";import{r as Ot,t as Wt}from"./react-resizable-panels.browser.esm-Mq45xjWt.js";import{t as Ee}from"./toggle-CriARMQK.js";function Dt(t,e,n){return t==null?t:xt(t,e,n)}var H=Dt,Ht=be("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]),Bt=be("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function Vt(t){return{all:t||(t=new Map),on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(s){s(n)}),(r=t.get("*"))&&r.slice().map(function(s){s(e,n)})}}}var u=ce(lt(),1),J=(0,u.createContext)(null),$t=t=>{let{controller:e}=(0,u.useContext)(J),n=u.useRef(Symbol("fill"));return(0,u.useEffect)(()=>(e.mount({name:t.name,ref:n.current,children:t.children}),()=>{e.unmount({name:t.name,ref:n.current})}),[]),(0,u.useEffect)(()=>{e.update({name:t.name,ref:n.current,children:t.children})}),null},Xt=Object.defineProperty,Yt=(t,e,n)=>e in t?Xt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ce=(t,e,n)=>(Yt(t,typeof e=="symbol"?e:e+"",n),n),_e=console,Qt=class{constructor(t){Ce(this,"_bus"),Ce(this,"_db"),this._bus=t,this.handleFillMount=this.handleFillMount.bind(this),this.handleFillUpdated=this.handleFillUpdated.bind(this),this.handleFillUnmount=this.handleFillUnmount.bind(this),this._db={byName:new Map,byFill:new Map}}mount(){this._bus.on("fill-mount",this.handleFillMount),this._bus.on("fill-updated",this.handleFillUpdated),this._bus.on("fill-unmount",this.handleFillUnmount)}unmount(){this._bus.off("fill-mount",this.handleFillMount),this._bus.off("fill-updated",this.handleFillUpdated),this._bus.off("fill-unmount",this.handleFillUnmount)}handleFillMount({fill:t}){let e=u.Children.toArray(t.children),n=t.name,r={fill:t,children:e,name:n},s=this._db.byName.get(n);s?(s.components.push(r),s.listeners.forEach(i=>i([...s.components]))):this._db.byName.set(n,{listeners:[],components:[r]}),this._db.byFill.set(t.ref,r)}handleFillUpdated({fill:t}){let e=this._db.byFill.get(t.ref),n=u.Children.toArray(t.children);if(e){e.children=n;let r=this._db.byName.get(e.name);if(r)r.listeners.forEach(s=>s([...r.components]));else throw Error("registration was expected to be defined")}else{_e.error("[handleFillUpdated] component was expected to be defined");return}}handleFillUnmount({fill:t}){let e=this._db.byFill.get(t.ref);if(!e){_e.error("[handleFillUnmount] component was expected to be defined");return}let n=e.name,r=this._db.byName.get(n);if(!r)throw Error("registration was expected to be defined");r.components=r.components.filter(s=>s!==e),this._db.byFill.delete(t.ref),r.listeners.length===0&&r.components.length===0?this._db.byName.delete(n):r.listeners.forEach(s=>s([...r.components]))}onComponentsChange(t,e){let n=this._db.byName.get(t);n?(n.listeners.push(e),e(n.components)):(this._db.byName.set(t,{listeners:[e],components:[]}),e([]))}getFillsByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.fill):[]}getChildrenByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.children).reduce((n,r)=>n.concat(r),[]):[]}removeOnComponentsChange(t,e){let n=this._db.byName.get(t);if(!n)throw Error("expected registration to be defined");let r=n.listeners;r.splice(r.indexOf(e),1)}},Gt=Object.defineProperty,Kt=(t,e,n)=>e in t?Gt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Jt=(t,e,n)=>(Kt(t,typeof e=="symbol"?e:e+"",n),n),ke=class{constructor(){Jt(this,"bus",Vt())}mount(t){this.bus.emit("fill-mount",{fill:t})}unmount(t){this.bus.emit("fill-unmount",{fill:t})}update(t){this.bus.emit("fill-updated",{fill:t})}};function Zt(t){let e=t||new ke;return{controller:e,manager:new Qt(e.bus)}}var en=({controller:t,children:e})=>{let[n]=u.useState(()=>{let r=Zt(t);return r.manager.mount(),r});return u.useEffect(()=>()=>{n.manager.unmount()},[]),u.createElement(J.Provider,{value:n},e)};function Z(t,e){let[n,r]=(0,u.useState)([]),{manager:s}=(0,u.useContext)(J);return(0,u.useEffect)(()=>(s.onComponentsChange(t,r),()=>{s.removeOnComponentsChange(t,r)}),[t]),n.flatMap((i,d)=>{let{children:l}=i;return l.map((p,b)=>{if(typeof p=="number"||typeof p=="string")throw Error("Only element children will work here");return u.cloneElement(p,{key:d.toString()+b.toString(),...e})})})}var Re=t=>{let e=Z(t.name,t.childProps);if(typeof t.children=="function"){let n=t.children(e);if(u.isValidElement(n)||n===null)return n;throw Error("Slot rendered with function must return a valid React Element.")}return e};const tn=P(null);var{valueAtom:nn,useActions:rn}=qt(()=>({banners:[]}),{addBanner:(t,e)=>({...t,banners:[...t.banners,{...e,id:we()}]}),removeBanner:(t,e)=>({...t,banners:t.banners.filter(n=>n.id!==e)}),clearBanners:t=>({...t,banners:[]})});const sn=()=>ot(nn);function an(){return rn()}const on=new ke,B={SIDEBAR:"sidebar",CONTEXT_AWARE_PANEL:"context-aware-panel"};var ln=class{constructor(){a(this,"subscriptions",new Map)}addSubscription(t,e){var n;this.subscriptions.has(t)||this.subscriptions.set(t,new Set),(n=this.subscriptions.get(t))==null||n.add(e)}removeSubscription(t,e){var n;(n=this.subscriptions.get(t))==null||n.delete(e)}notify(t,e){for(let n of this.subscriptions.get(t)??[])n(e)}},Fe=class ue{constructor(e){a(this,"subscriptions",new ln);this.producer=e}static withProducerCallback(e){return new ue(e)}static empty(){return new ue}startProducer(){this.producer&&this.producer(e=>{this.subscriptions.notify("message",e)})}connect(){return new Promise(e=>setTimeout(e,0)).then(()=>{this.subscriptions.notify("open",new Event("open"))})}get readyState(){return WebSocket.OPEN}reconnect(e,n){this.close(),this.connect()}close(){this.subscriptions.notify("close",new Event("close"))}send(e){return this.subscriptions.notify("message",new MessageEvent("message",{data:e})),Promise.resolve()}addEventListener(e,n){this.subscriptions.addSubscription(e,n),e==="open"&&n(new Event("open")),e==="message"&&this.startProducer()}removeEventListener(e,n){this.subscriptions.removeSubscription(e,n)}},un=1e10,cn=1e3;function V(t,e){let n=t.map(r=>`"${r}"`).join(", ");return Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${n}`)}function dn(t={}){let e={};function n(o){e=o}let r={};function s(o){var f;r.unregisterHandler&&r.unregisterHandler(),r=o,(f=r.registerHandler)==null||f.call(r,U)}let i;function d(o){if(typeof o=="function"){i=o;return}i=(f,g)=>{let c=o[f];if(c)return c(g);let h=o._;if(!h)throw Error(`The requested method has no handler: ${f}`);return h(f,g)}}let{maxRequestTime:l=cn}=t;t.transport&&s(t.transport),t.requestHandler&&d(t.requestHandler),t._debugHooks&&n(t._debugHooks);let p=0;function b(){return p<=un?++p:p=0}let x=new Map,w=new Map;function C(o,...f){let g=f[0];return new Promise((c,h)=>{var T;if(!r.send)throw V(["send"],"make requests");let S=b(),M={type:"request",id:S,method:o,params:g};x.set(S,{resolve:c,reject:h}),l!==1/0&&w.set(S,setTimeout(()=>{w.delete(S),h(Error("RPC request timed out."))},l)),(T=e.onSend)==null||T.call(e,M),r.send(M)})}let F=new Proxy(C,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>C(f,c)}),_=F;function k(o,...f){var h;let g=f[0];if(!r.send)throw V(["send"],"send messages");let c={type:"message",id:o,payload:g};(h=e.onSend)==null||h.call(e,c),r.send(c)}let R=new Proxy(k,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>k(f,c)}),v=R,N=new Map,q=new Set;function A(o,f){var g;if(!r.registerHandler)throw V(["registerHandler"],"register message listeners");if(o==="*"){q.add(f);return}N.has(o)||N.set(o,new Set),(g=N.get(o))==null||g.add(f)}function L(o,f){var g,c;if(o==="*"){q.delete(f);return}(g=N.get(o))==null||g.delete(f),((c=N.get(o))==null?void 0:c.size)===0&&N.delete(o)}async function U(o){var f,g;if((f=e.onReceive)==null||f.call(e,o),!("type"in o))throw Error("Message does not contain a type.");if(o.type==="request"){if(!r.send||!i)throw V(["send","requestHandler"],"handle requests");let{id:c,method:h,params:S}=o,M;try{M={type:"response",id:c,success:!0,payload:await i(h,S)}}catch(T){if(!(T instanceof Error))throw T;M={type:"response",id:c,success:!1,error:T.message}}(g=e.onSend)==null||g.call(e,M),r.send(M);return}if(o.type==="response"){let c=w.get(o.id);c!=null&&clearTimeout(c);let{resolve:h,reject:S}=x.get(o.id)??{};o.success?h==null||h(o.payload):S==null||S(Error(o.error));return}if(o.type==="message"){for(let h of q)h(o.id,o.payload);let c=N.get(o.id);if(!c)return;for(let h of c)h(o.payload);return}throw Error(`Unexpected RPC message type: ${o.type}`)}return{setTransport:s,setRequestHandler:d,request:F,requestProxy:_,send:R,sendProxy:v,addMessageListener:A,removeMessageListener:L,proxy:{send:v,request:_},_setDebugHooks:n}}function fn(t){return dn(t)}var Ne="[transport-id]";function mn(t,e){let{transportId:n}=e;return n==null?t:{[Ne]:n,data:t}}function pn(t,e){let{transportId:n,filter:r}=e,s=r==null?void 0:r();if(n!=null&&s!=null)throw Error("Cannot use both `transportId` and `filter` at the same time");let i=t;if(n){if(t[Ne]!==n)return[!0];i=t.data}return s===!1?[!0]:[!1,i]}function hn(t,e={}){let{transportId:n,filter:r,remotePort:s}=e,i=t,d=s??t,l;return{send(p){d.postMessage(mn(p,{transportId:n}))},registerHandler(p){l=b=>{let x=b.data,[w,C]=pn(x,{transportId:n,filter:()=>r==null?void 0:r(b)});w||p(C)},i.addEventListener("message",l)},unregisterHandler(){l&&i.removeEventListener("message",l)}}}function gn(t,e){return hn(t,e)}function Se(t){return fn({transport:gn(t,{transportId:"marimo-transport"}),maxRequestTime:2e4,_debugHooks:{onSend:e=>{E.debug("[rpc] Parent -> Worker",e)},onReceive:e=>{E.debug("[rpc] Worker -> Parent",e)}}})}const qe=P("Initializing..."),yn=P(t=>{let e=t(mt),n=Object.values(e.cellRuntime);return n.some(r=>!jt(r.output))?!0:n.every(r=>r.status==="idle")});var Pe=Lt(),Me="marimo:file",je=new ct(null);const bn={saveFile(t){je.set(Me,t)},readFile(){return je.get(Me)}};var wn={saveFile(t){z.setCodeForHash((0,Pe.compressToEncodedURIComponent)(t))},readFile(){let t=z.getCodeFromHash()||z.getCodeFromSearchParam();return t?(0,Pe.decompressFromEncodedURIComponent)(t):null}};const vn={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var xn={saveFile(t){},readFile(){if(window.location.hostname!=="marimo.app")return null;let t=new URL("files/wasm-intro.py",document.baseURI);return fetch(t.toString()).then(e=>e.ok?e.text():null).catch(()=>null)}},En={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
|
|
1
|
+
var at=Object.defineProperty;var it=(t,e,n)=>e in t?at(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var a=(t,e,n)=>it(t,typeof e!="symbol"?e+"":e,n);var j;import{s as ce}from"./chunk-LvLJmgfZ.js";import{i as G,l as D,p as P,u as ot}from"./useEvent-BhXAndur.js";import{t as lt}from"./react-Bj1aDYRI.js";import{$r as z,Qr as ut,Vr as ct,b as dt,qr as ft,y as mt}from"./cells-DbD2lYze.js";import{B as pt,C as de,D as ht,I as gt,N as yt,P as O,R as fe,k as W,w as me}from"./zod-H_cgTO0M.js";import{t as pe}from"./compiler-runtime-B3qBwwSJ.js";import{t as bt}from"./get-6uJrSKbw.js";import{t as wt}from"./assertNever-CBU83Y6o.js";import{t as vt}from"./debounce-B3mjKxHe.js";import{t as xt}from"./_baseSet-5Rdwpmr3.js";import{d as E,p as y}from"./hotkeys-BHHWjLlp.js";import{t as Et}from"./invariant-CAG_dYON.js";import{S as Ct}from"./utils-YqBXNpsM.js";import{S as _t}from"./config-D2-Bw6QC.js";import{a as kt}from"./switch-BUKXfBTu.js";import{n as he}from"./globals-BXYmO-WL.js";import{t as ge}from"./ErrorBoundary-B9Ifj8Jf.js";import{t as Rt}from"./jsx-runtime-ZmTK25f3.js";import{t as Ft}from"./button-CZ3Cs4qb.js";import{t as Nt}from"./cn-BKtXLv3a.js";import{Z as St}from"./JsonOutput-DsO4felE.js";import{t as qt}from"./createReducer-B3rBsy4P.js";import{t as ye}from"./requests-B4FYHTZl.js";import{t as be}from"./createLucideIcon-BCdY6lG5.js";import{t as Pt}from"./x-ZP5cObgf.js";import{a as Mt,l as jt,r as At}from"./markdown-renderer-D8AmLSIR.js";import{t as Tt}from"./DeferredRequestRegistry-tv0PqJZ0.js";import{t as K}from"./Deferred-CrO5-0RA.js";import{t as we}from"./uuid-DercMavo.js";import{t as It}from"./use-toast-T0_cQDma.js";import{t as ve}from"./tooltip-C_WgOOcZ.js";import{t as xe}from"./mode-CjmQoGEk.js";import{n as Lt,r as Ut,t as zt}from"./share-rXkgGlhr.js";import{r as Ot,t as Wt}from"./react-resizable-panels.browser.esm-Mq45xjWt.js";import{t as Ee}from"./toggle-CriARMQK.js";function Dt(t,e,n){return t==null?t:xt(t,e,n)}var H=Dt,Ht=be("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]),Bt=be("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function Vt(t){return{all:t||(t=new Map),on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(s){s(n)}),(r=t.get("*"))&&r.slice().map(function(s){s(e,n)})}}}var u=ce(lt(),1),J=(0,u.createContext)(null),$t=t=>{let{controller:e}=(0,u.useContext)(J),n=u.useRef(Symbol("fill"));return(0,u.useEffect)(()=>(e.mount({name:t.name,ref:n.current,children:t.children}),()=>{e.unmount({name:t.name,ref:n.current})}),[]),(0,u.useEffect)(()=>{e.update({name:t.name,ref:n.current,children:t.children})}),null},Xt=Object.defineProperty,Yt=(t,e,n)=>e in t?Xt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ce=(t,e,n)=>(Yt(t,typeof e=="symbol"?e:e+"",n),n),_e=console,Qt=class{constructor(t){Ce(this,"_bus"),Ce(this,"_db"),this._bus=t,this.handleFillMount=this.handleFillMount.bind(this),this.handleFillUpdated=this.handleFillUpdated.bind(this),this.handleFillUnmount=this.handleFillUnmount.bind(this),this._db={byName:new Map,byFill:new Map}}mount(){this._bus.on("fill-mount",this.handleFillMount),this._bus.on("fill-updated",this.handleFillUpdated),this._bus.on("fill-unmount",this.handleFillUnmount)}unmount(){this._bus.off("fill-mount",this.handleFillMount),this._bus.off("fill-updated",this.handleFillUpdated),this._bus.off("fill-unmount",this.handleFillUnmount)}handleFillMount({fill:t}){let e=u.Children.toArray(t.children),n=t.name,r={fill:t,children:e,name:n},s=this._db.byName.get(n);s?(s.components.push(r),s.listeners.forEach(i=>i([...s.components]))):this._db.byName.set(n,{listeners:[],components:[r]}),this._db.byFill.set(t.ref,r)}handleFillUpdated({fill:t}){let e=this._db.byFill.get(t.ref),n=u.Children.toArray(t.children);if(e){e.children=n;let r=this._db.byName.get(e.name);if(r)r.listeners.forEach(s=>s([...r.components]));else throw Error("registration was expected to be defined")}else{_e.error("[handleFillUpdated] component was expected to be defined");return}}handleFillUnmount({fill:t}){let e=this._db.byFill.get(t.ref);if(!e){_e.error("[handleFillUnmount] component was expected to be defined");return}let n=e.name,r=this._db.byName.get(n);if(!r)throw Error("registration was expected to be defined");r.components=r.components.filter(s=>s!==e),this._db.byFill.delete(t.ref),r.listeners.length===0&&r.components.length===0?this._db.byName.delete(n):r.listeners.forEach(s=>s([...r.components]))}onComponentsChange(t,e){let n=this._db.byName.get(t);n?(n.listeners.push(e),e(n.components)):(this._db.byName.set(t,{listeners:[e],components:[]}),e([]))}getFillsByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.fill):[]}getChildrenByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.children).reduce((n,r)=>n.concat(r),[]):[]}removeOnComponentsChange(t,e){let n=this._db.byName.get(t);if(!n)throw Error("expected registration to be defined");let r=n.listeners;r.splice(r.indexOf(e),1)}},Gt=Object.defineProperty,Kt=(t,e,n)=>e in t?Gt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Jt=(t,e,n)=>(Kt(t,typeof e=="symbol"?e:e+"",n),n),ke=class{constructor(){Jt(this,"bus",Vt())}mount(t){this.bus.emit("fill-mount",{fill:t})}unmount(t){this.bus.emit("fill-unmount",{fill:t})}update(t){this.bus.emit("fill-updated",{fill:t})}};function Zt(t){let e=t||new ke;return{controller:e,manager:new Qt(e.bus)}}var en=({controller:t,children:e})=>{let[n]=u.useState(()=>{let r=Zt(t);return r.manager.mount(),r});return u.useEffect(()=>()=>{n.manager.unmount()},[]),u.createElement(J.Provider,{value:n},e)};function Z(t,e){let[n,r]=(0,u.useState)([]),{manager:s}=(0,u.useContext)(J);return(0,u.useEffect)(()=>(s.onComponentsChange(t,r),()=>{s.removeOnComponentsChange(t,r)}),[t]),n.flatMap((i,d)=>{let{children:l}=i;return l.map((p,b)=>{if(typeof p=="number"||typeof p=="string")throw Error("Only element children will work here");return u.cloneElement(p,{key:d.toString()+b.toString(),...e})})})}var Re=t=>{let e=Z(t.name,t.childProps);if(typeof t.children=="function"){let n=t.children(e);if(u.isValidElement(n)||n===null)return n;throw Error("Slot rendered with function must return a valid React Element.")}return e};const tn=P(null);var{valueAtom:nn,useActions:rn}=qt(()=>({banners:[]}),{addBanner:(t,e)=>({...t,banners:[...t.banners,{...e,id:we()}]}),removeBanner:(t,e)=>({...t,banners:t.banners.filter(n=>n.id!==e)}),clearBanners:t=>({...t,banners:[]})});const sn=()=>ot(nn);function an(){return rn()}const on=new ke,B={SIDEBAR:"sidebar",CONTEXT_AWARE_PANEL:"context-aware-panel"};var ln=class{constructor(){a(this,"subscriptions",new Map)}addSubscription(t,e){var n;this.subscriptions.has(t)||this.subscriptions.set(t,new Set),(n=this.subscriptions.get(t))==null||n.add(e)}removeSubscription(t,e){var n;(n=this.subscriptions.get(t))==null||n.delete(e)}notify(t,e){for(let n of this.subscriptions.get(t)??[])n(e)}},Fe=class ue{constructor(e){a(this,"subscriptions",new ln);this.producer=e}static withProducerCallback(e){return new ue(e)}static empty(){return new ue}startProducer(){this.producer&&this.producer(e=>{this.subscriptions.notify("message",e)})}connect(){return new Promise(e=>setTimeout(e,0)).then(()=>{this.subscriptions.notify("open",new Event("open"))})}get readyState(){return WebSocket.OPEN}reconnect(e,n){this.close(),this.connect()}close(){this.subscriptions.notify("close",new Event("close"))}send(e){return this.subscriptions.notify("message",new MessageEvent("message",{data:e})),Promise.resolve()}addEventListener(e,n){this.subscriptions.addSubscription(e,n),e==="open"&&n(new Event("open")),e==="message"&&this.startProducer()}removeEventListener(e,n){this.subscriptions.removeSubscription(e,n)}},un=1e10,cn=1e3;function V(t,e){let n=t.map(r=>`"${r}"`).join(", ");return Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${n}`)}function dn(t={}){let e={};function n(o){e=o}let r={};function s(o){var f;r.unregisterHandler&&r.unregisterHandler(),r=o,(f=r.registerHandler)==null||f.call(r,U)}let i;function d(o){if(typeof o=="function"){i=o;return}i=(f,g)=>{let c=o[f];if(c)return c(g);let h=o._;if(!h)throw Error(`The requested method has no handler: ${f}`);return h(f,g)}}let{maxRequestTime:l=cn}=t;t.transport&&s(t.transport),t.requestHandler&&d(t.requestHandler),t._debugHooks&&n(t._debugHooks);let p=0;function b(){return p<=un?++p:p=0}let x=new Map,w=new Map;function C(o,...f){let g=f[0];return new Promise((c,h)=>{var T;if(!r.send)throw V(["send"],"make requests");let S=b(),M={type:"request",id:S,method:o,params:g};x.set(S,{resolve:c,reject:h}),l!==1/0&&w.set(S,setTimeout(()=>{w.delete(S),h(Error("RPC request timed out."))},l)),(T=e.onSend)==null||T.call(e,M),r.send(M)})}let F=new Proxy(C,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>C(f,c)}),_=F;function k(o,...f){var h;let g=f[0];if(!r.send)throw V(["send"],"send messages");let c={type:"message",id:o,payload:g};(h=e.onSend)==null||h.call(e,c),r.send(c)}let R=new Proxy(k,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>k(f,c)}),v=R,N=new Map,q=new Set;function A(o,f){var g;if(!r.registerHandler)throw V(["registerHandler"],"register message listeners");if(o==="*"){q.add(f);return}N.has(o)||N.set(o,new Set),(g=N.get(o))==null||g.add(f)}function L(o,f){var g,c;if(o==="*"){q.delete(f);return}(g=N.get(o))==null||g.delete(f),((c=N.get(o))==null?void 0:c.size)===0&&N.delete(o)}async function U(o){var f,g;if((f=e.onReceive)==null||f.call(e,o),!("type"in o))throw Error("Message does not contain a type.");if(o.type==="request"){if(!r.send||!i)throw V(["send","requestHandler"],"handle requests");let{id:c,method:h,params:S}=o,M;try{M={type:"response",id:c,success:!0,payload:await i(h,S)}}catch(T){if(!(T instanceof Error))throw T;M={type:"response",id:c,success:!1,error:T.message}}(g=e.onSend)==null||g.call(e,M),r.send(M);return}if(o.type==="response"){let c=w.get(o.id);c!=null&&clearTimeout(c);let{resolve:h,reject:S}=x.get(o.id)??{};o.success?h==null||h(o.payload):S==null||S(Error(o.error));return}if(o.type==="message"){for(let h of q)h(o.id,o.payload);let c=N.get(o.id);if(!c)return;for(let h of c)h(o.payload);return}throw Error(`Unexpected RPC message type: ${o.type}`)}return{setTransport:s,setRequestHandler:d,request:F,requestProxy:_,send:R,sendProxy:v,addMessageListener:A,removeMessageListener:L,proxy:{send:v,request:_},_setDebugHooks:n}}function fn(t){return dn(t)}var Ne="[transport-id]";function mn(t,e){let{transportId:n}=e;return n==null?t:{[Ne]:n,data:t}}function pn(t,e){let{transportId:n,filter:r}=e,s=r==null?void 0:r();if(n!=null&&s!=null)throw Error("Cannot use both `transportId` and `filter` at the same time");let i=t;if(n){if(t[Ne]!==n)return[!0];i=t.data}return s===!1?[!0]:[!1,i]}function hn(t,e={}){let{transportId:n,filter:r,remotePort:s}=e,i=t,d=s??t,l;return{send(p){d.postMessage(mn(p,{transportId:n}))},registerHandler(p){l=b=>{let x=b.data,[w,C]=pn(x,{transportId:n,filter:()=>r==null?void 0:r(b)});w||p(C)},i.addEventListener("message",l)},unregisterHandler(){l&&i.removeEventListener("message",l)}}}function gn(t,e){return hn(t,e)}function Se(t){return fn({transport:gn(t,{transportId:"marimo-transport"}),maxRequestTime:2e4,_debugHooks:{onSend:e=>{E.debug("[rpc] Parent -> Worker",e)},onReceive:e=>{E.debug("[rpc] Worker -> Parent",e)}}})}const qe=P("Initializing..."),yn=P(t=>{let e=t(mt),n=Object.values(e.cellRuntime);return n.some(r=>!jt(r.output))?!0:n.every(r=>r.status==="idle")});var Pe=Lt(),Me="marimo:file",je=new ct(null);const bn={saveFile(t){je.set(Me,t)},readFile(){return je.get(Me)}};var wn={saveFile(t){z.setCodeForHash((0,Pe.compressToEncodedURIComponent)(t))},readFile(){let t=z.getCodeFromHash()||z.getCodeFromSearchParam();return t?(0,Pe.decompressFromEncodedURIComponent)(t):null}};const vn={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var xn={saveFile(t){},readFile(){if(window.location.hostname!=="marimo.app")return null;let t=new URL("files/wasm-intro.py",document.baseURI);return fetch(t.toString()).then(e=>e.ok?e.text():null).catch(()=>null)}},En={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
|
|
2
2
|
`)}},Ae=class{constructor(t){this.stores=t}insert(t,e){this.stores.splice(t,0,e)}saveFile(t){this.stores.forEach(e=>e.saveFile(t))}readFile(){for(let t of this.stores){let e=t.readFile();if(e)return e}return null}};const $=new Ae([vn,wn]),ee=new Ae([bn,xn,En]);var Te=class rt{constructor(){a(this,"initialized",new K);a(this,"sendRename",async({filename:e})=>(e===null||(z.setFilename(e),await this.rpc.proxy.request.bridge({functionName:"rename_file",payload:e})),null));a(this,"sendSave",async e=>{if(!this.saveRpc)return E.warn("Save RPC not initialized"),null;await this.saveRpc.saveNotebook(e);let n=await this.readCode();return n.contents&&($.saveFile(n.contents),ee.saveFile(n.contents)),this.rpc.proxy.request.saveNotebook(e).catch(r=>{E.error(r)}),null});a(this,"sendCopy",async()=>{y()});a(this,"sendStdin",async e=>(await this.rpc.proxy.request.bridge({functionName:"put_input",payload:e.text}),null));a(this,"sendPdb",async()=>{y()});a(this,"sendRun",async e=>(await this.rpc.proxy.request.loadPackages(e.codes.join(`
|
|
3
3
|
`)),await this.putControlRequest({type:"execute-cells",...e}),null));a(this,"sendRunScratchpad",async e=>(await this.rpc.proxy.request.loadPackages(e.code),await this.putControlRequest({type:"execute-scratchpad",...e}),null));a(this,"sendInterrupt",async()=>(this.interruptBuffer!==void 0&&(this.interruptBuffer[0]=2),null));a(this,"sendShutdown",async()=>(window.close(),null));a(this,"sendFormat",async e=>await this.rpc.proxy.request.bridge({functionName:"format",payload:e}));a(this,"sendDeleteCell",async e=>(await this.putControlRequest({type:"delete-cell",...e}),null));a(this,"sendInstallMissingPackages",async e=>(this.putControlRequest({type:"install-packages",...e}),null));a(this,"sendCodeCompletionRequest",async e=>(G.get(dt)||await this.rpc.proxy.request.bridge({functionName:"code_complete",payload:e}),null));a(this,"saveUserConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_user_config",payload:e}),kt.post("/kernel/save_user_config",e,{baseUrl:"/"}).catch(n=>(E.error(n),null))));a(this,"saveAppConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_app_config",payload:e}),null));a(this,"saveCellConfig",async e=>(await this.putControlRequest({type:"update-cell-config",...e}),null));a(this,"sendRestart",async()=>{let e=await this.readCode();return e.contents&&($.saveFile(e.contents),ee.saveFile(e.contents)),Ut(),null});a(this,"readCode",async()=>this.saveRpc?{contents:await this.saveRpc.readNotebook()}:(E.warn("Save RPC not initialized"),{contents:""}));a(this,"readSnippets",async()=>await this.rpc.proxy.request.bridge({functionName:"read_snippets",payload:void 0}));a(this,"openFile",async({path:e})=>{let n=zt({code:null,baseUrl:window.location.origin});return window.open(n,"_blank"),null});a(this,"sendListFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"list_files",payload:e}));a(this,"sendSearchFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"search_files",payload:e}));a(this,"sendComponentValues",async e=>(await this.putControlRequest({type:"update-ui-element",...e,token:we()}),null));a(this,"sendInstantiate",async e=>null);a(this,"sendFunctionRequest",async e=>(await this.putControlRequest({type:"invoke-function",...e}),null));a(this,"sendCreateFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"create_file_or_directory",payload:e}));a(this,"sendDeleteFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"delete_file_or_directory",payload:e}));a(this,"sendRenameFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"move_file_or_directory",payload:e}));a(this,"sendUpdateFile",async e=>await this.rpc.proxy.request.bridge({functionName:"update_file",payload:e}));a(this,"sendFileDetails",async e=>await this.rpc.proxy.request.bridge({functionName:"file_details",payload:e}));a(this,"exportAsHTML",async e=>await this.rpc.proxy.request.bridge({functionName:"export_html",payload:e}));a(this,"exportAsMarkdown",async e=>await this.rpc.proxy.request.bridge({functionName:"export_markdown",payload:e}));a(this,"previewDatasetColumn",async e=>(await this.putControlRequest({type:"preview-dataset-column",...e}),null));a(this,"previewSQLTable",async e=>(await this.putControlRequest({type:"preview-sql-table",...e}),null));a(this,"previewSQLTableList",async e=>(await this.putControlRequest({type:"list-sql-tables",...e}),null));a(this,"previewDataSourceConnection",async e=>(await this.putControlRequest({type:"list-data-source-connection",...e}),null));a(this,"validateSQL",async e=>(await this.putControlRequest({type:"validate-sql",...e}),null));a(this,"sendModelValue",async e=>(await this.putControlRequest({type:"update-widget-model",...e}),null));a(this,"syncCellIds",()=>Promise.resolve(null));a(this,"addPackage",async e=>this.rpc.proxy.request.addPackage(e));a(this,"removePackage",async e=>this.rpc.proxy.request.removePackage(e));a(this,"getPackageList",async()=>await this.rpc.proxy.request.listPackages());a(this,"getDependencyTree",async()=>({tree:{dependencies:[],name:"",tags:[],version:null}}));a(this,"listSecretKeys",async e=>(await this.putControlRequest({type:"list-secret-keys",...e}),null));a(this,"getUsageStats",y);a(this,"openTutorial",y);a(this,"getRecentFiles",y);a(this,"getWorkspaceFiles",y);a(this,"getRunningNotebooks",y);a(this,"shutdownSession",y);a(this,"exportAsPDF",y);a(this,"autoExportAsHTML",y);a(this,"autoExportAsMarkdown",y);a(this,"autoExportAsIPYNB",y);a(this,"updateCellOutputs",y);a(this,"writeSecret",y);a(this,"invokeAiTool",y);a(this,"clearCache",y);a(this,"getCacheInfo",y);_t()&&(this.rpc=Se(new Worker(new URL(""+new URL("worker-CyCdlLVf.js",import.meta.url).href,""+import.meta.url),{type:"module",name:he()})),this.rpc.addMessageListener("ready",()=>{this.startSession()}),this.rpc.addMessageListener("initialized",()=>{this.saveRpc=this.getSaveWorker(),this.setInterruptBuffer(),this.initialized.resolve()}),this.rpc.addMessageListener("initializingMessage",({message:e})=>{G.set(qe,e)}),this.rpc.addMessageListener("initializedError",({error:e})=>{this.initialized.status==="resolved"&&(E.error(e),It({title:"Error initializing",description:e,variant:"danger"})),this.initialized.reject(Error(e))}),this.rpc.addMessageListener("kernelMessage",({message:e})=>{var n;(n=this.messageConsumer)==null||n.call(this,new MessageEvent("message",{data:e}))}))}static get INSTANCE(){let e="_marimo_private_PyodideBridge";return window[e]||(window[e]=new rt),window[e]}getSaveWorker(){return xe()==="read"?(E.debug("Skipping SaveWorker in read-mode"),{readFile:y,readNotebook:y,saveNotebook:y}):Se(new Worker(new URL(""+new URL("save-worker-CtJsIYIM.js",import.meta.url).href,""+import.meta.url),{type:"module",name:he()})).proxy.request}async startSession(){let e=await $.readFile(),n=await ee.readFile(),r=z.getFilename(),s=G.get(Ct),i={},d=new URLSearchParams(window.location.search);for(let l of d.keys()){let p=d.getAll(l);i[l]=p.length===1?p[0]:p}await this.rpc.proxy.request.startSession({queryParameters:i,code:e||n||"",filename:r,userConfig:{...s,runtime:{...s.runtime,auto_instantiate:xe()==="read"?!0:s.runtime.auto_instantiate}}})}setInterruptBuffer(){crossOriginIsolated?(this.interruptBuffer=new Uint8Array(new SharedArrayBuffer(1)),this.rpc.proxy.request.setInterruptBuffer(this.interruptBuffer)):E.warn("Not running in a secure context; interrupts are not available.")}attachMessageConsumer(e){this.messageConsumer=e,this.rpc.proxy.send.consumerReady({})}async putControlRequest(e){await this.rpc.proxy.request.bridge({functionName:"put_control_request",payload:e})}};function Cn(){return Fe.withProducerCallback(t=>{Te.INSTANCE.attachMessageConsumer(t)})}function X(t){return()=>({TYPE:t,is(e){return e.type===t},create(e){return new CustomEvent(t,e)}})}const Ie=X("marimo-value-input")(),Le=X("marimo-value-update")(),Ue=X("marimo-value-ready")(),ze=X("marimo-incoming-message")();function _n(t,e){return Ie.create({bubbles:!0,composed:!0,detail:{value:t,element:e}})}var Oe=class st{static get INSTANCE(){let e="_marimo_private_UIElementRegistry";return window[e]||(window[e]=new st),window[e]}constructor(){this.entries=new Map}has(e){return this.entries.has(e)}set(e,n){if(this.entries.has(e))throw Error(`UIElement ${e} already registered`);this.entries.set(e,{objectId:e,value:n,elements:new Set})}registerInstance(e,n){let r=this.entries.get(e);r===void 0?this.entries.set(e,{objectId:e,value:ut(n,this),elements:new Set([n])}):r.elements.add(n)}removeInstance(e,n){let r=this.entries.get(e);r!=null&&r.elements.has(n)&&r.elements.delete(n)}removeElementsByCell(e){[...this.entries.keys()].filter(n=>n.startsWith(`${e}-`)).forEach(n=>{this.entries.delete(n)})}lookupValue(e){let n=this.entries.get(e);return n===void 0?void 0:n.value}broadcastMessage(e,n,r){let s=this.entries.get(e);s===void 0?E.warn("UIElementRegistry missing entry",e):s.elements.forEach(i=>{i.dispatchEvent(ze.create({bubbles:!1,composed:!0,detail:{objectId:e,message:n,buffers:r}}))})}broadcastValueUpdate(e,n,r){let s=this.entries.get(n);s===void 0?E.warn("UIElementRegistry missing entry",n):(s.value=r,s.elements.forEach(i=>{i!==e&&i.dispatchEvent(Le.create({bubbles:!1,composed:!0,detail:{value:r,element:i}}))}),document.dispatchEvent(Ue.create({bubbles:!0,composed:!0,detail:{objectId:n}})))}};const kn=Oe.INSTANCE,Rn=new Tt("function-call-result",async(t,e)=>{await ye().sendFunctionRequest({functionCallId:t,...e})}),Fn="68px";var Nn="288px";const Sn=t=>t?/^\d+$/.test(t)?`${t}px`:t:Nn,qn=ft({isOpen:!0},(t,e)=>{if(!e)return t;switch(e.type){case"toggle":return{...t,isOpen:e.isOpen??t.isOpen};case"setWidth":return{...t,width:e.width};default:return t}});function te(t,e=[]){let n=[];if(t instanceof DataView)n.push(e);else if(Array.isArray(t))for(let[r,s]of t.entries())n.push(...te(s,[...e,r]));else if(typeof t=="object"&&t)for(let[r,s]of Object.entries(t))n.push(...te(s,[...e,r]));return n}function ne(t){let e=te(t);if(e.length===0)return{state:t,buffers:[],bufferPaths:[]};let n=structuredClone(t),r=[],s=[];for(let i of e){let d=bt(t,i);if(d instanceof DataView){let l=Mt(d);r.push(l),s.push(i),H(n,i,l)}}return{state:n,buffers:r,bufferPaths:s}}function Pn(t){return typeof t=="object"&&!!t&&"state"in t&&"bufferPaths"in t&&"buffers"in t}function Y(t){let{state:e,bufferPaths:n,buffers:r}=t;if(!n||n.length===0)return e;r&&Et(r.length===n.length,"Buffers and buffer paths not the same length");let s=structuredClone(e);for(let[i,d]of n.entries()){let l=r==null?void 0:r[i];if(l==null){E.warn("[anywidget] Could not find buffer at path",d);continue}typeof l=="string"?H(s,d,At(l)):H(s,d,l)}return s}const We=new class{constructor(t=1e4){a(this,"models",new Map);this.timeout=t}get(t){let e=this.models.get(t);return e||(e=new K,this.models.set(t,e),setTimeout(()=>{e.status==="pending"&&(e.reject(Error(`Model not found for key: ${t}`)),this.models.delete(t))},this.timeout)),e.promise}set(t,e){let n=this.models.get(t);n||(n=new K,this.models.set(t,n)),n.resolve(e)}delete(t){this.models.delete(t)}};var De=(j=class{constructor(e,n,r,s){a(this,"ANY_CHANGE_EVENT","change");a(this,"listeners",{});a(this,"widget_manager",{async get_model(e){let n=await j._modelManager.get(e);if(!n)throw Error(`Model not found with id: ${e}. This is likely because the model was not registered.`);return n}});a(this,"emitAnyChange",vt(()=>{var e;(e=this.listeners[this.ANY_CHANGE_EVENT])==null||e.forEach(n=>n())},0));this.data=e,this.onChange=n,this.sendToWidget=r,this.dirtyFields=new Map([...s].map(i=>[i,this.data[i]]))}off(e,n){var r;if(!e){this.listeners={};return}if(!n){this.listeners[e]=new Set;return}(r=this.listeners[e])==null||r.delete(n)}send(e,n,r){let{state:s,bufferPaths:i,buffers:d}=ne(e);this.sendToWidget({content:{state:s,bufferPaths:i},buffers:d}).then(n)}get(e){return this.data[e]}set(e,n){this.data={...this.data,[e]:n},this.dirtyFields.set(e,n),this.emit(`change:${e}`,n),this.emitAnyChange()}save_changes(){if(this.dirtyFields.size===0)return;let e=Object.fromEntries(this.dirtyFields.entries());this.dirtyFields.clear(),this.onChange(e)}updateAndEmitDiffs(e){e!=null&&Object.keys(e).forEach(n=>{let r=n;this.data[r]!==e[r]&&this.set(r,e[r])})}receiveCustomMessage(e,n=[]){var s;let r=He.safeParse(e);if(r.success){let i=r.data;switch(i.method){case"update":this.updateAndEmitDiffs(Y({state:i.state,bufferPaths:i.buffer_paths??[],buffers:n}));break;case"custom":(s=this.listeners["msg:custom"])==null||s.forEach(d=>d(i.content,n));break;case"open":this.updateAndEmitDiffs(Y({state:i.state,bufferPaths:i.buffer_paths??[],buffers:n}));break;case"echo_update":break;default:E.error("[anywidget] Unknown message method",i.method);break}}else E.error("Failed to parse message",r.error),E.error("Message",e)}on(e,n){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(n)}emit(e,n){this.listeners[e]&&this.listeners[e].forEach(r=>r(n))}},a(j,"_modelManager",We),j),re=me(me(pt([fe(),yt()]))),se=gt(fe(),de()),He=ht("method",[O({method:W("open"),state:se,buffer_paths:re.optional()}),O({method:W("update"),state:se,buffer_paths:re.optional()}),O({method:W("custom"),content:de()}),O({method:W("echo_update"),buffer_paths:re,state:se}),O({method:W("close")})]);function Mn(t){return t==null?!1:He.safeParse(t).success}async function jn({modelId:t,msg:e,buffers:n,modelManager:r}){if(e.method==="echo_update")return;if(e.method==="custom"){(await r.get(t)).receiveCustomMessage(e,n);return}if(e.method==="close"){r.delete(t);return}let{method:s,state:i,buffer_paths:d=[]}=e,l=Y({state:i,bufferPaths:d,buffers:n});if(s==="open"){let p=new De(l,b=>{let{state:x,buffers:w,bufferPaths:C}=ne(b);ye().sendModelValue({modelId:t,message:{state:x,bufferPaths:C},buffers:w})},y,new Set);r.set(t,p);return}if(s==="update"){(await r.get(t)).updateAndEmitDiffs(l);return}wt(s)}const Be=P(null),An=P(null),Ve=P(!1),Tn=P(!1),$e=P(!1);var In=pe();const Xe=t=>{let e=(0,In.c)(8),{onResize:n,startingWidth:r,minWidth:s,maxWidth:i}=t,d=(0,u.useRef)(null),l=(0,u.useRef)(null),p=(0,u.useRef)(null),b,x;e[0]!==i||e[1]!==s||e[2]!==n?(b=()=>{let _=d.current,k=l.current,R=p.current;if(!_||!k&&!R)return;let v=Number.parseInt(window.getComputedStyle(_).width,10),N=0,q=!1,A=null,L=c=>{if(!_||!q||!A)return;let h=c.clientX-N;N=c.clientX,v=A==="left"?v-h:v+h,s&&(v=Math.max(s,v)),i&&(v=Math.min(i,v)),_.style.width=`${v}px`},U=()=>{q&&(n==null||n(v),q=!1,A=null),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",U)},o=(c,h)=>{c.preventDefault(),q=!0,A=h,N=c.clientX,document.addEventListener("mousemove",L),document.addEventListener("mouseup",U)},f=c=>o(c,"left"),g=c=>o(c,"right");return k&&k.addEventListener("mousedown",f),R&&R.addEventListener("mousedown",g),()=>{k&&k.removeEventListener("mousedown",f),R&&R.removeEventListener("mousedown",g),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",U)}},x=[s,i,n],e[0]=i,e[1]=s,e[2]=n,e[3]=b,e[4]=x):(b=e[3],x=e[4]),(0,u.useEffect)(b,x);let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w={left:l,right:p},e[5]=w):w=e[5];let C=r==="contentWidth"?"var(--content-width-medium)":`${r}px`,F;return e[6]===C?F=e[7]:(F={resizableDivRef:d,handleRefs:w,style:{width:C}},e[6]=C,e[7]=F),F};function Ye(t){t||window.dispatchEvent(new Event("resize"))}var Qe=pe(),m=ce(Rt(),1);const Ln=()=>{let t=(0,Qe.c)(16),[e,n]=D(Be),[r,s]=D(Ve),[i,d]=D(Tn),[l,p]=D($e),b;t[0]!==s||t[1]!==n?(b=()=>{n(null),s(!1)},t[0]=s,t[1]=n,t[2]=b):b=t[2];let x=b;if(Z(B.CONTEXT_AWARE_PANEL).length===0||!e||!r)return null;let w;t[3]!==l||t[4]!==i||t[5]!==p||t[6]!==d?(w=()=>(0,m.jsxs)("div",{className:"flex flex-row items-center gap-3",children:[(0,m.jsx)(ve,{content:i?"Unpin panel":"Pin panel",children:(0,m.jsx)(Ee,{size:"xs",onPressedChange:()=>d(!i),pressed:i,"aria-label":i?"Unpin panel":"Pin panel",children:i?(0,m.jsx)(Bt,{className:"w-4 h-4"}):(0,m.jsx)(St,{className:"w-4 h-4"})})}),(0,m.jsx)(ve,{content:l?(0,m.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,m.jsx)("span",{children:"Follow focused table"}),(0,m.jsx)("span",{className:"text-xs text-muted-foreground w-64",children:"The panel updates as cells that output tables are focused. Click to fix to the current cell."})]}):(0,m.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,m.jsx)("span",{children:"Focus on current table"}),(0,m.jsx)("span",{className:"text-xs text-muted-foreground w-64",children:"The panel is focused on the current table. Click to update based on which cell is focused."})]}),children:(0,m.jsx)(Ee,{size:"xs",onPressedChange:()=>p(!l),pressed:l,"aria-label":l?"Follow focused cell":"Fixed",children:(0,m.jsx)(Ht,{className:Nt("w-4 h-4",l&&"text-primary")})})})]}),t[3]=l,t[4]=i,t[5]=p,t[6]=d,t[7]=w):w=t[7];let C=w,F;t[8]!==x||t[9]!==C?(F=()=>(0,m.jsxs)("div",{className:"mt-2 pb-7 mb-4 h-full overflow-auto",children:[(0,m.jsxs)("div",{className:"flex flex-row justify-between items-center mx-2",children:[C(),(0,m.jsx)(Ft,{variant:"linkDestructive",size:"icon",onClick:x,"aria-label":"Close selection panel",children:(0,m.jsx)(Pt,{className:"w-4 h-4"})})]}),(0,m.jsx)(ge,{children:(0,m.jsx)(Re,{name:B.CONTEXT_AWARE_PANEL})})]}),t[8]=x,t[9]=C,t[10]=F):F=t[10];let _=F;if(!i){let v;return t[11]===_?v=t[12]:(v=(0,m.jsx)(zn,{children:_()}),t[11]=_,t[12]=v),v}let k;t[13]===Symbol.for("react.memo_cache_sentinel")?(k=(0,m.jsx)(Ot,{onDragging:Ye,className:"resize-handle border-border z-20 print:hidden border-l"}),t[13]=k):k=t[13];let R;return t[14]===_?R=t[15]:(R=(0,m.jsxs)(m.Fragment,{children:[k,(0,m.jsx)(Wt,{defaultSize:20,minSize:15,maxSize:80,children:_()})]}),t[14]=_,t[15]=R),R},Un=t=>{let e=(0,Qe.c)(2),{children:n}=t,r;return e[0]===n?r=e[1]:(r=(0,m.jsx)(ge,{children:(0,m.jsx)($t,{name:B.CONTEXT_AWARE_PANEL,children:n})}),e[0]=n,e[1]=r),r};var zn=({children:t})=>{let{resizableDivRef:e,handleRefs:n,style:r}=Xe({startingWidth:400,minWidth:300,maxWidth:1500});return(0,m.jsxs)("div",{className:"absolute z-40 right-0 h-full bg-background flex flex-row",children:[(0,m.jsx)("div",{ref:n.left,className:"w-1 h-full cursor-col-resize border-l"}),(0,m.jsx)("div",{ref:e,style:r,children:t})]})};function On(){var t=[...arguments];return(0,u.useMemo)(()=>e=>{t.forEach(n=>n(e))},t)}var Ge=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0;function Q(t){let e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function ae(t){return"nodeType"in t}function I(t){var e;return t?Q(t)?t:ae(t)?((e=t.ownerDocument)==null?void 0:e.defaultView)??window:window:window}function Ke(t){let{Document:e}=I(t);return t instanceof e}function Je(t){return Q(t)?!1:t instanceof I(t).HTMLElement}function Ze(t){return t instanceof I(t).SVGElement}function Wn(t){return t?Q(t)?t.document:ae(t)?Ke(t)?t:Je(t)||Ze(t)?t.ownerDocument:document:document:document}var ie=Ge?u.useLayoutEffect:u.useEffect;function et(t){let e=(0,u.useRef)(t);return ie(()=>{e.current=t}),(0,u.useCallback)(function(){var n=[...arguments];return e.current==null?void 0:e.current(...n)},[])}function Dn(){let t=(0,u.useRef)(null);return[(0,u.useCallback)((e,n)=>{t.current=setInterval(e,n)},[]),(0,u.useCallback)(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[])]}function Hn(t,e){e===void 0&&(e=[t]);let n=(0,u.useRef)(t);return ie(()=>{n.current!==t&&(n.current=t)},e),n}function Bn(t,e){let n=(0,u.useRef)();return(0,u.useMemo)(()=>{let r=t(n.current);return n.current=r,r},[...e])}function Vn(t){let e=et(t),n=(0,u.useRef)(null);return[n,(0,u.useCallback)(r=>{r!==n.current&&(e==null||e(r,n.current)),n.current=r},[])]}function $n(t){let e=(0,u.useRef)();return(0,u.useEffect)(()=>{e.current=t},[t]),e.current}var oe={};function Xn(t,e){return(0,u.useMemo)(()=>{if(e)return e;let n=oe[t]==null?0:oe[t]+1;return oe[t]=n,t+"-"+n},[t,e])}function tt(t){return function(e){return[...arguments].slice(1).reduce((n,r)=>{let s=Object.entries(r);for(let[i,d]of s){let l=n[i];l!=null&&(n[i]=l+t*d)}return n},{...e})}}var Yn=tt(1),Qn=tt(-1);function Gn(t){return"clientX"in t&&"clientY"in t}function Kn(t){if(!t)return!1;let{KeyboardEvent:e}=I(t.target);return e&&t instanceof e}function Jn(t){if(!t)return!1;let{TouchEvent:e}=I(t.target);return e&&t instanceof e}function Zn(t){if(Jn(t)){if(t.touches&&t.touches.length){let{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){let{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return Gn(t)?{x:t.clientX,y:t.clientY}:null}var le=Object.freeze({Translate:{toString(t){if(!t)return;let{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;let{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[le.Translate.toString(t),le.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),nt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function er(t){return t.matches(nt)?t:t.querySelector(nt)}export{yn as $,An as A,Sn as B,Xn as C,Xe as D,Ye as E,Mn as F,ze as G,Rn as H,Y as I,Le as J,Ie as K,Pn as L,We as M,De as N,Ve as O,jn as P,$ as Q,ne as R,$n as S,Un as T,Oe as U,qn as V,kn as W,Te as X,_n as Y,Cn as Z,Dn as _,Zn as a,sn as at,Bn as b,Ke as c,Re as ct,ae as d,qe as et,Ze as f,et as g,On as h,er as i,tn as it,$e as j,Be as k,Je as l,Z as lt,Qn as m,Yn as n,B as nt,Wn as o,an as ot,Q as p,Ue as q,Ge as r,on as rt,I as s,en as st,le as t,Fe as tt,Kn as u,H as ut,ie as v,Ln as w,Vn as x,Hn as y,Fn as z};
|
package/dist/index.html
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
|
|
67
67
|
<!-- /TODO -->
|
|
68
68
|
<title>{{ title }}</title>
|
|
69
|
-
<script type="module" crossorigin src="./assets/index-
|
|
69
|
+
<script type="module" crossorigin src="./assets/index-U7La6ZBB.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-DItdS47A.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/clsx-D8GwTfvk.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/cn-BKtXLv3a.js">
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
<link rel="modulepreload" crossorigin href="./assets/refresh-cw-Dx8TEWFP.js">
|
|
172
172
|
<link rel="modulepreload" crossorigin href="./assets/trash-2-B8SQYdQq.js">
|
|
173
173
|
<link rel="modulepreload" crossorigin href="./assets/triangle-alert-U93NZYDl.js">
|
|
174
|
-
<link rel="modulepreload" crossorigin href="./assets/ai-model-dropdown-
|
|
174
|
+
<link rel="modulepreload" crossorigin href="./assets/ai-model-dropdown-CODXtvnr.js">
|
|
175
175
|
<link rel="modulepreload" crossorigin href="./assets/defaultLocale-JieDVWC_.js">
|
|
176
176
|
<link rel="modulepreload" crossorigin href="./assets/precisionRound-CU2C3Vxx.js">
|
|
177
177
|
<link rel="modulepreload" crossorigin href="./assets/defaultLocale-BLne0bXb.js">
|
|
@@ -183,7 +183,7 @@
|
|
|
183
183
|
<link rel="modulepreload" crossorigin href="./assets/cell-link-BoOn0OpK.js">
|
|
184
184
|
<link rel="modulepreload" crossorigin href="./assets/datasource-Dkywo3Kg.js">
|
|
185
185
|
<link rel="modulepreload" crossorigin href="./assets/state-DlF73owK.js">
|
|
186
|
-
<link rel="modulepreload" crossorigin href="./assets/MarimoErrorOutput-
|
|
186
|
+
<link rel="modulepreload" crossorigin href="./assets/MarimoErrorOutput-DrTj9k_Z.js">
|
|
187
187
|
<link rel="modulepreload" crossorigin href="./assets/copy-icon-B9w72gBC.js">
|
|
188
188
|
<link rel="modulepreload" crossorigin href="./assets/html-to-image-DrmKVKna.js">
|
|
189
189
|
<link rel="modulepreload" crossorigin href="./assets/focus-BEf2RhRf.js">
|
|
@@ -207,29 +207,29 @@
|
|
|
207
207
|
<link rel="modulepreload" crossorigin href="./assets/useDateFormatter-CieT0-H-.js">
|
|
208
208
|
<link rel="modulepreload" crossorigin href="./assets/range-D2UKkEg-.js">
|
|
209
209
|
<link rel="modulepreload" crossorigin href="./assets/table-CfDbAm78.js">
|
|
210
|
-
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-
|
|
210
|
+
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-DsO4felE.js">
|
|
211
211
|
<link rel="modulepreload" crossorigin href="./assets/file-Ch78NKWp.js">
|
|
212
212
|
<link rel="modulepreload" crossorigin href="./assets/play-GLWQQs7F.js">
|
|
213
213
|
<link rel="modulepreload" crossorigin href="./assets/chat-components-C2rqCcnp.js">
|
|
214
214
|
<link rel="modulepreload" crossorigin href="./assets/isEmpty-CgX_-6Mt.js">
|
|
215
|
-
<link rel="modulepreload" crossorigin href="./assets/chat-display-
|
|
215
|
+
<link rel="modulepreload" crossorigin href="./assets/chat-display-BnUDaREA.js">
|
|
216
216
|
<link rel="modulepreload" crossorigin href="./assets/useDeleteCell-DHPNhAtW.js">
|
|
217
217
|
<link rel="modulepreload" crossorigin href="./assets/icons-DjR3qLG_.js">
|
|
218
218
|
<link rel="modulepreload" crossorigin href="./assets/process-output-OTqBNunj.js">
|
|
219
219
|
<link rel="modulepreload" crossorigin href="./assets/blob-t6qcPM7K.js">
|
|
220
220
|
<link rel="modulepreload" crossorigin href="./assets/objectWithoutPropertiesLoose-DfWeGRFv.js">
|
|
221
221
|
<link rel="modulepreload" crossorigin href="./assets/esm-C-53tlK5.js">
|
|
222
|
-
<link rel="modulepreload" crossorigin href="./assets/add-cell-with-ai-
|
|
222
|
+
<link rel="modulepreload" crossorigin href="./assets/add-cell-with-ai-CPu9tI-Q.js">
|
|
223
223
|
<link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-qvVRjhv1.js">
|
|
224
224
|
<link rel="modulepreload" crossorigin href="./assets/square-function-B6mgCeFJ.js">
|
|
225
225
|
<link rel="modulepreload" crossorigin href="./assets/spec-Ch0xnJY4.js">
|
|
226
|
-
<link rel="modulepreload" crossorigin href="./assets/column-preview-
|
|
226
|
+
<link rel="modulepreload" crossorigin href="./assets/column-preview-Bz3KIcIX.js">
|
|
227
227
|
<link rel="modulepreload" crossorigin href="./assets/toggle-CriARMQK.js">
|
|
228
228
|
<link rel="modulepreload" crossorigin href="./assets/globals-BXYmO-WL.js">
|
|
229
229
|
<link rel="modulepreload" crossorigin href="./assets/share-rXkgGlhr.js">
|
|
230
230
|
<link rel="modulepreload" crossorigin href="./assets/_baseSet-5Rdwpmr3.js">
|
|
231
231
|
<link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-Mq45xjWt.js">
|
|
232
|
-
<link rel="modulepreload" crossorigin href="./assets/utilities.esm-
|
|
232
|
+
<link rel="modulepreload" crossorigin href="./assets/utilities.esm-AIy-_q0N.js">
|
|
233
233
|
<link rel="modulepreload" crossorigin href="./assets/floating-outline-BULIQxKU.js">
|
|
234
234
|
<link rel="modulepreload" crossorigin href="./assets/useAddCell-Cx99GRHQ.js">
|
|
235
235
|
<link rel="modulepreload" crossorigin href="./assets/eye-off-AK_9uodG.js">
|
package/package.json
CHANGED
|
@@ -609,9 +609,13 @@ export const CustomProvidersConfig: React.FC<AiConfigProps> = ({
|
|
|
609
609
|
const isDuplicate =
|
|
610
610
|
KNOWN_PROVIDERS.includes(normalizedName as KnownProviderId) ||
|
|
611
611
|
(customProviders && Object.keys(customProviders).includes(normalizedName));
|
|
612
|
+
const hasInvalidChars = normalizedName.includes(".");
|
|
612
613
|
|
|
613
614
|
const hasValidValues =
|
|
614
|
-
normalizedName.trim() &&
|
|
615
|
+
normalizedName.trim() &&
|
|
616
|
+
newProviderBaseUrl.trim() &&
|
|
617
|
+
!isDuplicate &&
|
|
618
|
+
!hasInvalidChars;
|
|
615
619
|
|
|
616
620
|
const resetForm = () => {
|
|
617
621
|
setNewProviderName("");
|
|
@@ -669,7 +673,12 @@ export const CustomProvidersConfig: React.FC<AiConfigProps> = ({
|
|
|
669
673
|
A provider with this name already exists.
|
|
670
674
|
</p>
|
|
671
675
|
)}
|
|
672
|
-
{
|
|
676
|
+
{hasInvalidChars && (
|
|
677
|
+
<p className="text-xs text-destructive">
|
|
678
|
+
Provider names cannot contain '.' characters.
|
|
679
|
+
</p>
|
|
680
|
+
)}
|
|
681
|
+
{newProviderName && !hasInvalidChars && (
|
|
673
682
|
<p className="text-xs text-muted-secondary">
|
|
674
683
|
Use models with prefix:{" "}
|
|
675
684
|
<Kbd className="inline text-xs">{normalizedName}/</Kbd>
|
|
@@ -76,4 +76,26 @@ describe("parseContent", () => {
|
|
|
76
76
|
url: "https://avatars.githubusercontent.com/u/123",
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
|
+
|
|
80
|
+
it("preserves newlines between URLs", () => {
|
|
81
|
+
const parts = parseContent("https://marimo.io\nhttps://github.com\n");
|
|
82
|
+
expect(parts).toEqual([
|
|
83
|
+
{ type: "url", url: "https://marimo.io" },
|
|
84
|
+
{ type: "text", value: "\n" },
|
|
85
|
+
{ type: "url", url: "https://github.com" },
|
|
86
|
+
{ type: "text", value: "\n" },
|
|
87
|
+
]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("preserves whitespace in mixed content", () => {
|
|
91
|
+
const parts = parseContent(
|
|
92
|
+
"Line 1: https://marimo.io\nLine 2: https://github.com",
|
|
93
|
+
);
|
|
94
|
+
expect(parts).toEqual([
|
|
95
|
+
{ type: "text", value: "Line 1: " },
|
|
96
|
+
{ type: "url", url: "https://marimo.io" },
|
|
97
|
+
{ type: "text", value: "\nLine 2: " },
|
|
98
|
+
{ type: "url", url: "https://github.com" },
|
|
99
|
+
]);
|
|
100
|
+
});
|
|
79
101
|
});
|
package/src/utils/url-parser.ts
CHANGED
|
@@ -19,7 +19,7 @@ export function parseContent(text: string): ContentPart[] {
|
|
|
19
19
|
return [{ type: "image", url: text }];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const parts = text.split(urlRegex).filter((part) => part
|
|
22
|
+
const parts = text.split(urlRegex).filter((part) => part !== "");
|
|
23
23
|
return parts.map((part) => {
|
|
24
24
|
const isUrl = urlRegex.test(part);
|
|
25
25
|
if (isUrl) {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{s as G}from"./chunk-LvLJmgfZ.js";import{d as ye,f as ve,l as Ne,u as be}from"./useEvent-BhXAndur.js";import{t as we}from"./react-Bj1aDYRI.js";import{In as ke,Ir as Ie,J as $e,Jr as _e,Lr as K,mn as Fe,sn as Ae,w as Te,y as Ce}from"./cells-DbD2lYze.js";import{t as E}from"./compiler-runtime-B3qBwwSJ.js";import{t as Se}from"./invariant-CAG_dYON.js";import{r as Me}from"./utils-YqBXNpsM.js";import{t as ze}from"./jsx-runtime-ZmTK25f3.js";import{r as X,t as $}from"./button-CZ3Cs4qb.js";import{t as Y}from"./cn-BKtXLv3a.js";import{t as H}from"./createLucideIcon-BCdY6lG5.js";import{r as qe}from"./x-ZP5cObgf.js";import{a as Ee,p as Pe,r as Le,t as We}from"./dropdown-menu-BUgFWmX1.js";import{a as Ve,n as Be}from"./state-DlF73owK.js";import{c as Z,n as Qe}from"./datasource-Dkywo3Kg.js";import{a as De}from"./dist-BYyu59D8.js";import{t as ee}from"./tooltip-C_WgOOcZ.js";import{a as Oe,i as He,n as Je,r as Ue}from"./multi-map-t2yhdp8D.js";import{t as te}from"./kbd-Cm6Ba9qg.js";import{t as A}from"./links-7AQBmdyV.js";import{r as Re,t as Ge}from"./alert-BOoN6gJ1.js";import{o as Ke,t as Xe}from"./useInstallPackage-xrG_Tm9T.js";import{n as b}from"./cell-link-BoOn0OpK.js";var Ye=H("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),T=H("square-arrow-out-up-right",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]),re=H("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);function Ze(r){let e=null,s=r.cursor();do s.name==="ExpressionStatement"&&(e=s.node);while(s.next());return e}function et(r){let e=r.split(`
|
|
2
|
-
`),s=" ",n=Ze(De.parse(r));if(!n)return["def _():",...J(e,s),`${s}return`,"","","_()"].join(`
|
|
3
|
-
`);let i=r.slice(0,n.from).trim(),l=r.slice(n.from).trim(),a=i.split(`
|
|
4
|
-
`),c=l.split(`
|
|
5
|
-
`);return["def _():",...J(a,s),`${s}return ${c[0]}`,...J(c.slice(1),s),"","","_()"].join(`
|
|
6
|
-
`)}function J(r,e){if(r.length===1&&r[0]==="")return[];let s=[];for(let n of r)n===""?s.push(""):s.push(e+n);return s}function tt(r,e){var s;if(r.type==="multiple-defs")return[{title:"Fix: Wrap in a function",description:"Make this cell's variables local by wrapping the cell in a function.",fixType:"manual",onFix:async n=>{Se(n.editor,"Editor is null");let i=et(n.editor.state.doc.toString());n.editor.dispatch({changes:{from:0,to:n.editor.state.doc.length,insert:i}})}}];if(r.type==="exception"&&r.exception_type==="NameError"){let n=(s=r.msg.match(/name '(.+)' is not defined/))==null?void 0:s[1];if(!n||!(n in se))return[];let i=rt(n);return[{title:`Fix: Add '${i}'`,description:"Add a new cell for the missing import",fixType:"manual",onFix:async l=>{l.addCodeBelow(i)}}]}return r.type==="sql-error"&&e.aiEnabled?[{title:"Fix with AI",description:"Fix the SQL statement",fixType:"ai",onFix:async n=>{var a;let i=Qe(n.cellId),l=`Fix the SQL statement: ${r.msg}.`;i&&(l+=`
|
|
7
|
-
Database schema: ${i}`),(a=n.aiFix)==null||a.setAiCompletionCell({cellId:n.cellId,initialPrompt:l,triggerImmediately:n.aiFix.triggerFix})}}]:[]}function rt(r){let e=se[r];return e===r?`import ${e}`:`import ${e} as ${r}`}var se={mo:"marimo",alt:"altair",bokeh:"bokeh",dask:"dask",np:"numpy",pd:"pandas",pl:"polars",plotly:"plotly",plt:"matplotlib.pyplot",px:"plotly.express",scipy:"scipy",sk:"sklearn",sns:"seaborn",stats:"scipy.stats",tf:"tensorflow",torch:"torch",xr:"xarray",dt:"datetime",json:"json",math:"math",os:"os",re:"re",sys:"sys"},st=E(),nt=_e("marimo:ai-autofix-mode","autofix",Fe);function lt(){let r=(0,st.c)(3),[e,s]=Ne(nt),n;return r[0]!==e||r[1]!==s?(n={fixMode:e,setFixMode:s},r[0]=e,r[1]=s,r[2]=n):n=r[2],n}var U=E(),t=G(ze(),1);const N=r=>{let e=(0,U.c)(21),{errors:s,cellId:n,className:i}=r,l=ve(),{createNewCell:a}=Te(),c=be(Me),o;if(e[0]!==c||e[1]!==s){let x;e[3]===c?x=e[4]:(x=y=>tt(y,{aiEnabled:c}),e[3]=c,e[4]=x),o=s.flatMap(x),e[0]=c,e[1]=s,e[2]=o}else o=e[2];let m=o,p=ye(Be);if(m.length===0)return null;let d=m[0],f;e[5]!==n||e[6]!==a||e[7]!==d||e[8]!==p||e[9]!==l?(f=x=>{var w;let y=(w=l.get(Ce).cellHandles[n].current)==null?void 0:w.editorView;d.onFix({addCodeBelow:_=>{a({cellId:n,autoFocus:!1,before:!1,code:_})},editor:y,cellId:n,aiFix:{setAiCompletionCell:p,triggerFix:x}}),y==null||y.focus()},e[5]=n,e[6]=a,e[7]=d,e[8]=p,e[9]=l,e[10]=f):f=e[10];let u=f,j;e[11]===i?j=e[12]:(j=Y("my-2",i),e[11]=i,e[12]=j);let h;e[13]!==d.description||e[14]!==d.fixType||e[15]!==d.title||e[16]!==u?(h=d.fixType==="ai"?(0,t.jsx)(oe,{tooltip:d.description,openPrompt:()=>u(!1),applyAutofix:()=>u(!0)}):(0,t.jsx)(ee,{content:d.description,align:"start",children:(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>u(!1),children:[(0,t.jsx)(Z,{className:"h-3 w-3 mr-2"}),d.title]})}),e[13]=d.description,e[14]=d.fixType,e[15]=d.title,e[16]=u,e[17]=h):h=e[17];let g;return e[18]!==j||e[19]!==h?(g=(0,t.jsx)("div",{className:j,children:h}),e[18]=j,e[19]=h,e[20]=g):g=e[20],g};var ne=Ve,le=Z,ie="Suggest a prompt",ae="Fix with AI";const oe=r=>{let e=(0,U.c)(21),{tooltip:s,openPrompt:n,applyAutofix:i}=r,{fixMode:l,setFixMode:a}=lt(),c=l==="prompt"?n:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,t.jsx)(ne,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,t.jsx)(le,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let m=l==="prompt"?ie:ae,p;e[2]!==c||e[3]!==o||e[4]!==m?(p=(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:c,children:[o,m]}),e[2]=c,e[3]=o,e[4]=m,e[5]=p):p=e[5];let d;e[6]!==p||e[7]!==s?(d=(0,t.jsx)(ee,{content:s,align:"start",children:p}),e[6]=p,e[7]=s,e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(Pe,{asChild:!0,children:(0,t.jsx)($,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,t.jsx)(qe,{className:"h-3 w-3"})})}),e[9]=f):f=e[9];let u;e[10]!==l||e[11]!==a?(u=()=>{a(l==="prompt"?"autofix":"prompt")},e[10]=l,e[11]=a,e[12]=u):u=e[12];let j=l==="prompt"?"autofix":"prompt",h;e[13]===j?h=e[14]:(h=(0,t.jsx)(it,{mode:j}),e[13]=j,e[14]=h);let g;e[15]!==u||e[16]!==h?(g=(0,t.jsxs)(We,{children:[f,(0,t.jsx)(Le,{align:"end",className:"w-56",children:(0,t.jsx)(Ee,{className:"flex items-center gap-2",onClick:u,children:h})})]}),e[15]=u,e[16]=h,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==d?(x=(0,t.jsxs)("div",{className:"flex",children:[d,g]}),e[18]=g,e[19]=d,e[20]=x):x=e[20],x};var it=r=>{let e=(0,U.c)(12),{mode:s}=r,n;e[0]===s?n=e[1]:(n=s==="prompt"?(0,t.jsx)(ne,{className:"h-4 w-4"}):(0,t.jsx)(le,{className:"h-4 w-4"}),e[0]=s,e[1]=n);let i=n,l=s==="prompt"?ie:ae,a=s==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",c;e[2]===l?c=e[3]:(c=(0,t.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=c);let o;e[4]===a?o=e[5]:(o=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:a}),e[4]=a,e[5]=o);let m;e[6]!==c||e[7]!==o?(m=(0,t.jsxs)("div",{className:"flex flex-col",children:[c,o]}),e[6]=c,e[7]=o,e[8]=m):m=e[8];let p;return e[9]!==i||e[10]!==m?(p=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[i,m]}),e[9]=i,e[10]=m,e[11]=p):p=e[11],p},ce=/(https?:\/\/\S+)/,at=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,de=/^data:image\//i,ot=["avatars.githubusercontent.com"];function me(r){return de.test(r)?[{type:"image",url:r}]:r.split(ce).filter(e=>e.trim()!=="").map(e=>ce.test(e)?at.test(e)||de.test(e)||ot.some(s=>e.includes(s))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var pe=E(),P=G(we(),1),ct=new $e;const R=r=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return r.replaceAll(e,"")};var ue=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function dt(r){ue.lastIndex=0;let e=ue.exec(r);if(!e)return null;let s=e.index+e[0].length,n=r.slice(s).split(/\s+/),i="",l=0;for(let c of n){let o=c.trim();if(!o)continue;if(o.startsWith("-")){l+=o.length+1;continue}let m=o.match(/^[\w,.[\]-]+/);if(m){i=m[0];break}break}if(!i)return null;let a=s+l+i.length;return{package:i,endIndex:a}}function k(r,e=""){if(!r)return null;if(!/https?:\/\//.test(r))return r;let s=me(r);return s.length===1&&s[0].type==="text"?r:(0,t.jsx)(t.Fragment,{children:s.map((n,i)=>{let l=e?`${e}-${i}`:i;if(n.type==="url"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}if(n.type==="image"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}return(0,t.jsx)(P.Fragment,{children:n.value},l)})})}var mt=r=>{let e=(0,pe.c)(6),{packages:s,children:n}=r,{handleInstallPackages:i}=Xe(),l;e[0]!==i||e[1]!==s?(l=c=>{i(s),c.preventDefault()},e[0]=i,e[1]=s,e[2]=l):l=e[2];let a;return e[3]!==n||e[4]!==l?(a=(0,t.jsx)("button",{onClick:l,className:"text-link hover:underline",type:"button",children:n}),e[3]=n,e[4]=l,e[5]=a):a=e[5],a};const pt=r=>{if(!(r instanceof K.Text))return;let e=R(r.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let s=[],n=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,i;for(;(i=n.exec(e))!==null;){let c=i.index,o=dt(e.slice(c));o&&s.push({match:i,result:o})}if(s.length===0)return;let l=[],a=0;if(s.forEach((c,o)=>{let{match:m,result:p}=c,d=m.index,f=d+p.endIndex;if(a<d){let j=e.slice(a,d);l.push((0,t.jsx)(P.Fragment,{children:k(j,`before-${o}`)},`before-${o}`))}let u=e.slice(d,f);l.push((0,t.jsx)(mt,{packages:[p.package],children:u},`install-${o}`)),a=f}),a<e.length){let c=e.slice(a);l.push((0,t.jsx)(P.Fragment,{children:k(c,"after")},"after"))}return(0,t.jsx)(t.Fragment,{children:l})},ut=r=>{if(!(r instanceof K.Text))return;let e=r.data;if(!/https?:\/\//.test(e))return;let s=k(e);if(typeof s!="string")return(0,t.jsx)(t.Fragment,{children:s})},ht=(...r)=>e=>{for(let s of r){let n=s(e);if(n!==void 0)return n}},xt=(r,e)=>(0,t.jsx)("span",{children:Ie(ct.ansi_to_html(r),{replace:s=>e(s)})}),ft=r=>{let e=(0,pe.c)(4),{text:s}=r,n;e[0]===s?n=e[1]:(n=xt(s,ht(pt,ut)),e[0]=s,e[1]=n);let i=n,l;return e[2]===i?l=e[3]:(l=(0,t.jsx)(t.Fragment,{children:i}),e[2]=i,e[3]=l),l};var he=E(),I=r=>{let e=(0,he.c)(10),s=r.title??"Tip",n;e[0]===s?n=e[1]:(n=(0,t.jsx)(Oe,{className:"pt-2 pb-2 font-normal",children:s}),e[0]=s,e[1]=n);let i;e[2]===r.children?i=e[3]:(i=(0,t.jsx)(Ue,{className:"mr-24 text-[0.84375rem]",children:r.children}),e[2]=r.children,e[3]=i);let l;e[4]!==n||e[5]!==i?(l=(0,t.jsxs)(He,{value:"item-1",className:"text-muted-foreground",children:[n,i]}),e[4]=n,e[5]=i,e[6]=l):l=e[6];let a;return e[7]!==r.className||e[8]!==l?(a=(0,t.jsx)(Je,{type:"single",collapsible:!0,className:r.className,children:l}),e[7]=r.className,e[8]=l,e[9]=a):a=e[9],a};const jt=r=>{let e=(0,he.c)(31),{errors:s,cellId:n,className:i}=r,l=Ae(),a="This cell wasn't run because it has errors",c="destructive",o="text-error";if(s.some(gt))a="Interrupted";else if(s.some(yt))a="An internal error occurred";else if(s.some(vt))a="Ancestor prevented from running",c="default",o="text-secondary-foreground";else if(s.some(Nt))a="Ancestor stopped",c="default",o="text-secondary-foreground";else if(s.some(bt))a="SQL error";else{let x;e[0]===s?x=e[1]:(x=s.find(wt),e[0]=s,e[1]=x);let y=x;y&&"exception_type"in y&&(a=y.exception_type)}let m,p,d,f,u,j;if(e[2]!==c||e[3]!==n||e[4]!==l||e[5]!==i||e[6]!==s||e[7]!==o||e[8]!==a){let x=s.filter(kt),y=s.filter(It),w=s.filter($t),_=s.filter(_t),L=s.filter(Ft),C=s.filter(At),S=s.filter(Tt),W=s.filter(Ct),V=s.filter(St),B=s.filter(Mt),F=s.filter(zt),Q=s.filter(qt),D=s.filter(Et),M;e[15]===l?M=e[16]:(M=()=>{l.openApplication("scratchpad")},e[15]=l,e[16]=M);let xe=M,fe=()=>{let v=[];if(F.length>0||Q.length>0){let q=F.some(Pt),ge=!q&&F.some(Lt);v.push((0,t.jsxs)("div",{children:[F.map(Wt),Q.map(Vt),q&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>Ke(l),children:[(0,t.jsx)(Ye,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,t.jsx)("span",{children:"Open package manager"})]}),ge&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openApplication("terminal"),children:[(0,t.jsx)(re,{className:"h-3.5 w-3.5 mr-1.5"}),(0,t.jsx)("span",{children:"Open terminal"})]}),n&&(0,t.jsx)(N,{errors:[...F,...Q],cellId:n})]},"syntax-unknown"))}if(x.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,t.jsx)("ul",{className:"list-disc",children:x.flatMap(Bt)}),n&&(0,t.jsx)(N,{errors:x,cellId:n}),(0,t.jsxs)(I,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"The setup cell contains logic that must be run before any other cell runs, including top-level imports used by top-level functions. For this reason, it can't refer to other cells' variables."}),(0,t.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),y.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,t.jsx)("ul",{className:"list-disc",children:y.flatMap(Qt)}),n&&(0,t.jsx)(N,{errors:y,cellId:n}),(0,t.jsxs)(I,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"An example of a cycle is if one cell declares a variable 'a' and reads 'b', and another cell declares 'b' and and reads 'a'. Cycles like this make it impossible for marimo to know how to run your cells, and generally suggest that your code has a bug."}),(0,t.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),w.length>0){let q=w[0].name;v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),w.map(Ot),n&&(0,t.jsx)(N,{errors:w,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I redefine variables?",children:[(0,t.jsx)("p",{className:"pb-2",children:"marimo requires that each variable is defined in just one cell. This constraint enables reactive and reproducible execution, arbitrary cell reordering, seamless UI elements, execution as a script, and more."}),(0,t.jsxs)("p",{className:"py-2",children:["Try merging this cell with the mentioned cells or wrapping it in a function. Alternatively, prefix variables with an underscore (e.g., ",(0,t.jsxs)(te,{className:"inline",children:["_",q]}),"). to make them private to this cell."]}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,t.jsx)(I,{title:"Need a scratchpad?",children:(0,t.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,t.jsxs)($,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:xe,children:[(0,t.jsx)(ke,{className:"h-3"}),(0,t.jsx)("span",{children:"Try the scratchpad"})]}),(0,t.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return _.length>0&&v.push((0,t.jsxs)("div",{children:[_.map(Ht),n&&(0,t.jsx)(N,{errors:_,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I use `import *`?",children:[(0,t.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,t.jsx)("p",{className:"py-2",children:"marimo's Python file format stores code in functions, so notebooks can be imported as regular Python modules without executing all their code. But Python disallows `import *` everywhere except at the top-level of a module."}),(0,t.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),L.length>0&&v.push((0,t.jsxs)("div",{children:[L.map(Jt),n&&(0,t.jsx)(N,{errors:L,cellId:n})]},"interruption")),C.length>0&&v.push((0,t.jsxs)("ul",{children:[C.map(Ut),C.some(Rt)&&(0,t.jsx)(I,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),n&&(0,t.jsx)(N,{errors:C,cellId:n})]},"exception")),S.length>0&&v.push((0,t.jsxs)("ul",{children:[S.map(Gt),n&&(0,t.jsx)(N,{errors:S,cellId:n}),(0,t.jsx)(I,{children:S.some(Kt)?"Ensure that the referenced cells define the required variables, or turn off strict execution.":"Something is wrong with your declarations. Fix any discrepancies, or turn off strict execution."})]},"strict-exception")),W.length>0&&v.push((0,t.jsxs)("div",{children:[W.map(Xt),n&&(0,t.jsx)(N,{errors:W,cellId:n})]},"internal")),V.length>0&&v.push((0,t.jsxs)("div",{children:[V.map(Yt),n&&(0,t.jsx)(N,{errors:V,cellId:n})]},"ancestor-prevented")),B.length>0&&v.push((0,t.jsxs)("div",{children:[B.map(Zt),n&&(0,t.jsx)(N,{errors:B,cellId:n})]},"ancestor-stopped")),D.length>0&&v.push((0,t.jsxs)("div",{children:[D.map(er),n&&(0,t.jsx)(N,{errors:D,cellId:n,className:"mt-2.5"})]},"sql-errors")),v},O=`font-code font-medium tracking-wide ${o}`,z;e[17]!==O||e[18]!==a?(z=(0,t.jsx)(Re,{className:O,children:a}),e[17]=O,e[18]=a,e[19]=z):z=e[19];let je=z;m=Ge,f=c,e[20]===i?u=e[21]:(u=Y("border-none font-code text-sm text-[0.84375rem] px-0 text-muted-foreground normal [&:has(svg)]:pl-0 space-y-4",i),e[20]=i,e[21]=u),j=je,p="flex flex-col gap-8",d=fe(),e[2]=c,e[3]=n,e[4]=l,e[5]=i,e[6]=s,e[7]=o,e[8]=a,e[9]=m,e[10]=p,e[11]=d,e[12]=f,e[13]=u,e[14]=j}else m=e[9],p=e[10],d=e[11],f=e[12],u=e[13],j=e[14];let h;e[22]!==p||e[23]!==d?(h=(0,t.jsx)("div",{children:(0,t.jsx)("div",{className:p,children:d})}),e[22]=p,e[23]=d,e[24]=h):h=e[24];let g;return e[25]!==m||e[26]!==f||e[27]!==u||e[28]!==j||e[29]!==h?(g=(0,t.jsxs)(m,{variant:f,className:u,children:[j,h]}),e[25]=m,e[26]=f,e[27]=u,e[28]=j,e[29]=h,e[30]=g):g=e[30],g};function gt(r){return r.type==="interruption"}function yt(r){return r.type==="internal"}function vt(r){return r.type==="ancestor-prevented"}function Nt(r){return r.type==="ancestor-stopped"}function bt(r){return r.type==="sql-error"}function wt(r){return r.type==="exception"}function kt(r){return r.type==="setup-refs"}function It(r){return r.type==="cycle"}function $t(r){return r.type==="multiple-defs"}function _t(r){return r.type==="import-star"}function Ft(r){return r.type==="interruption"}function At(r){return r.type==="exception"}function Tt(r){return r.type==="strict-exception"}function Ct(r){return r.type==="internal"}function St(r){return r.type==="ancestor-prevented"}function Mt(r){return r.type==="ancestor-stopped"}function zt(r){return r.type==="syntax"}function qt(r){return r.type==="unknown"}function Et(r){return r.type==="sql-error"}function Pt(r){return r.msg.includes("!pip")}function Lt(r){return r.msg.includes("use os.subprocess")}function Wt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`syntax-${e}`)},`syntax-${e}`)}function Vt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`unknown-${e}`)},`unknown-${e}`)}function Bt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",s[1].length===1?s[1][0]:s[1].join(", ")]})]},`setup-refs-${e}-${n}`))}function Qt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",s[1].length===1?s[1][0]:s[1].join(", ")," -> "]}),(0,t.jsx)(b,{cellId:s[2]})]},`cycle-${e}-${n}`))}function Dt(r,e){return(0,t.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,t.jsx)(b,{cellId:r})},`cell-${e}`)}function Ot(r,e){return(0,t.jsxs)(P.Fragment,{children:[(0,t.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${r.name}' was also defined by:`}),(0,t.jsx)("ul",{className:"list-disc",children:r.cells.map(Dt)})]},`multiple-defs-${e}`)}function Ht(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function Jt(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Ut(r,e){return r.exception_type==="NameError"&&r.msg.startsWith("name 'mo'")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,t.jsx)(te,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${e}`):r.exception_type==="NameError"&&r.msg.startsWith("name '_")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,t.jsxs)(A,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),")."]}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${e}`):(0,t.jsx)("li",{className:"my-2",children:r.raising_cell==null?(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:k(r.msg,`exception-${e}`)}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,t.jsxs)("div",{children:[k(r.msg,`exception-${e}`),(0,t.jsx)(b,{cellId:r.raising_cell})]})},`exception-${e}`)}function Rt(r){return r.raising_cell!=null}function Gt(r,e){return(0,t.jsx)("li",{className:"my-2",children:r.blamed_cell==null?(0,t.jsx)("p",{children:r.msg}):(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.blamed_cell})]})},`strict-exception-${e}`)}function Kt(r){return r.blamed_cell!=null}function Xt(r,e){return(0,t.jsx)("p",{children:r.msg},`internal-${e}`)}function Yt(r,e){return(0,t.jsxs)("div",{children:[r.msg,r.blamed_cell==null?(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),")"]}):(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),"\xA0blames\xA0",(0,t.jsx)(b,{cellId:r.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function Zt(r,e){return(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.raising_cell})]},`ancestor-stopped-${e}`)}function er(r,e){return(0,t.jsx)("div",{className:"space-y-2 mt-2",children:(0,t.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.msg})},`sql-error-${e}`)}export{re as a,oe as i,ft as n,me as r,jt as t};
|