@marimo-team/frontend 0.23.10-dev25 → 0.23.10-dev27
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-BDXmjEj9.js +53 -0
- package/dist/assets/{add-connection-dialog-BGaI0GCh.js → add-connection-dialog-T9Z5voxY.js} +1 -1
- package/dist/assets/{agent-panel-DHmaD72L.js → agent-panel-KWjanOTZ.js} +1 -1
- package/dist/assets/{cell-editor-DS-GvQu7.js → cell-editor-LaoP9GSh.js} +11 -11
- package/dist/assets/{column-preview-Bqp95o1c.js → column-preview-CSZ9RgJ8.js} +1 -1
- package/dist/assets/{command-palette-DW1BLZPt.js → command-palette-w_8Xo74m.js} +1 -1
- package/dist/assets/{edit-page-B-PsS6Sa.js → edit-page-COOCUoYP.js} +6 -6
- package/dist/assets/{file-explorer-panel-DbV2PFVU.js → file-explorer-panel-lBLLgjMq.js} +4 -4
- package/dist/assets/{form-B_6lxOn3.js → form-DKdvoZxk.js} +2 -2
- package/dist/assets/{hooks-L9VY624Y.js → hooks-BKLlyDAs.js} +1 -1
- package/dist/assets/index-DQ1e8BSW.js +38 -0
- package/dist/assets/{layout-BI8kBq9L.js → layout-B5MRVsVq.js} +5 -5
- package/dist/assets/{panels-BaGwQI8n.js → panels-uc-7IiOR.js} +1 -1
- package/dist/assets/reveal-component-C65H4dfJ.js +1069 -0
- package/dist/assets/{run-page-Zk3oGT6p.js → run-page-BMwyeBi9.js} +1 -1
- package/dist/assets/{scratchpad-panel-D6mOgXuh.js → scratchpad-panel-COwpb3AK.js} +1 -1
- package/dist/assets/{session-panel-CjbHqSx7.js → session-panel-Cn1bujIW.js} +1 -1
- package/dist/assets/{useNotebookActions-D6T6RU9i.js → useNotebookActions-C3Vj2qZ-.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/src/components/data-table/filter-by-values-picker.tsx +39 -17
- package/src/components/data-table/filter-pills.tsx +1 -1
- package/src/components/editor/cell/code/language-toggle.tsx +7 -1
- package/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts +20 -0
- package/src/components/editor/renderers/slides-layout/types.ts +1 -0
- package/src/components/slides/__tests__/reveal-component.test.ts +425 -0
- package/src/components/slides/reveal-component.tsx +283 -61
- package/src/components/slides/slide-cell-view.tsx +26 -2
- package/src/components/slides/slide-form.tsx +26 -4
- package/src/components/ui/combobox.tsx +51 -32
- package/src/components/ui/select-core/__tests__/use-select-list.test.ts +294 -0
- package/src/components/ui/select-core/__tests__/utils.test.ts +222 -0
- package/src/components/ui/select-core/index.ts +16 -0
- package/src/components/ui/select-core/option-row.tsx +33 -0
- package/src/components/ui/select-core/render-slot.ts +20 -0
- package/src/components/ui/select-core/select-list.tsx +248 -0
- package/src/components/ui/select-core/types.ts +44 -0
- package/src/components/ui/select-core/use-select-list.ts +347 -0
- package/src/components/ui/select-core/utils.ts +121 -0
- package/src/plugins/impl/MultiselectPlugin.tsx +19 -142
- package/src/plugins/impl/SearchableSelect.tsx +16 -97
- package/src/plugins/impl/__tests__/DropdownPlugin.test.tsx +5 -2
- package/src/plugins/impl/__tests__/MultiSelectPlugin.test.ts +1 -1
- package/dist/assets/JsonOutput-BYEhZqb8.js +0 -53
- package/dist/assets/index-gFLNrEY2.js +0 -38
- package/dist/assets/reveal-component-CRWK2ub0.js +0 -1069
- package/src/plugins/impl/multiselectFilterFn.tsx +0 -22
- /package/src/components/{data-table → ui}/value-chips.tsx +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as
|
|
1
|
+
import{s as T}from"./chunk-LvLJmgfZ.js";import{u as E}from"./useEvent-D91BmmQi.js";import{t as L}from"./react-Bj1aDYRI.js";import{D as U,Si as $,g as H,x as W}from"./cells-vjZ69d-u.js";import"./react-dom-CSu739Rf.js";import{t as I}from"./compiler-runtime-B3qBwwSJ.js";import{x as F}from"./utils-CvI-39U6.js";import{n as z}from"./constants-DMpttj8Q.js";import{T as M,l as O,m as V}from"./config-DH1Le_e1.js";import{t as q}from"./cn-DCUzRj2J.js";import{t as G}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-DFky0PAA.js";import"./popover-CNCYAwbC.js";import{E as J,Et as K,H as Q}from"./JsonOutput-BDXmjEj9.js";import{r as X}from"./download-DyF92TRH.js";import{n as Y,t as R}from"./button-BbCh-29a.js";import"./dist-D0HyMpgV.js";import"./cjs-BRGiG41H.js";import"./main-B0OX4z33.js";import"./useNonce-DfoVjkkH.js";import{r as Z}from"./requests-DIwGYs0l.js";import"./layout-B5MRVsVq.js";import{c as ee}from"./state-CcAGAozT.js";import"./markdown-renderer-DTD6g-4R.js";import{t as te}from"./copy-BwrPA9zQ.js";import{i as re,l as se,n as oe,r as B,t as ae,u as ie}from"./panels-uc-7IiOR.js";import{t as ne}from"./spinner-UuZAUjoP.js";import"./dist-CMvFIVSA.js";import"./dist-cJl5Fok5.js";import"./dist-BFCmbzWi.js";import"./dist-CS6moqWs.js";import"./dist-DTNIEaQR.js";import{t as le}from"./use-toast-9t59MOqR.js";import{t as me}from"./session-DGdfs0bJ.js";import"./purify.es-DvRMX74T.js";import"./dates-DS_7IZoI.js";import{n as ce}from"./copy-Ch48HVPK.js";import{a as de,c as pe,l as he,n as xe,r as fe,t as be}from"./dialog-QgtiqcL7.js";import{t as je}from"./share-DQLjaPiK.js";import"./utils-DQRuLEof.js";import"./vega-loader.browser-xq8miGHn.js";import"./defaultLocale-DPBdGRrH.js";import"./defaultLocale-Lfi0pexn.js";import{a as ue}from"./cell-link-CgOvnjYt.js";import"./chunk-5FQGJX7Z-CfK7VoEZ.js";import"./html-to-image-2JVKRW1b.js";import{n as ge,t as ye}from"./react-resizable-panels.browser.esm-BdtIs0E-.js";import"./esm-ChQLuryJ.js";import"./name-cell-input-Cwis179U.js";import{n as ke,t as _e}from"./marimo-icons-CiwvnnsT.js";import"./ws-BnE9sl8z.js";import"./dist-CH3UDWFp.js";import"./dist-DlCkNQAM.js";import"./dist-DtK0zh8h.js";import"./dist-Bmk2jyet.js";import"./dist-Sbt478Wh.js";import"./dist-C_EhQKG7.js";import"./dist-CAeBZ0Nq.js";import"./dist-BPey9y-W.js";import"./dist-CWGKeV6c.js";import"./esm-B2f-WXoG.js";var Ne=I(),ve=T(L(),1),t=T(G(),1);const we=o=>{let e=(0,Ne.c)(27),{appConfig:s}=o,{setCells:r}=U(),{sendComponentValues:p}=Z(),i;e[0]===p?i=e[1]:(i=()=>(B.INSTANCE.start(p),Se),e[0]=p,e[1]=i);let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[2]=n):n=e[2],(0,ve.useEffect)(i,n);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=me(),e[3]=h):h=e[3];let u;e[4]===r?u=e[5]:(u={autoInstantiate:!0,setCells:r,sessionId:h},e[4]=r,e[5]=u);let{connection:l,reconnect:v}=oe(u),f=E(W),g;e[6]===l.state?g=e[7]:(g=V(l.state),e[6]=l.state,e[7]=g);let w=g,b=E(H),y;e[8]!==s||e[9]!==b||e[10]!==w?(y=()=>w&&!b?(0,t.jsxs)(Q,{milliseconds:2e3,fallback:null,children:[(0,t.jsx)(ne,{className:"mx-auto"}),(0,t.jsx)("p",{className:"text-center text-sm text-muted-foreground mt-2",children:"Connecting..."})]}):(0,t.jsx)(re,{appConfig:s,mode:"read"}),e[8]=s,e[9]=b,e[10]=w,e[11]=y):y=e[11];let j=y,m;e:{if(typeof window>"u"){m=null;break e}let x,a;if(e[12]===Symbol.for("react.memo_cache_sentinel")){if(a=new URL(window.location.href),!a.searchParams.has("file")){m=null;break e}a.searchParams.delete("file"),x=a.searchParams.toString(),e[12]=x,e[13]=a,e[14]=m}else x=e[12],a=e[13],m=e[14];let C=x;m=C?`${a.pathname}?${C}`:a.pathname}let k=m,S=s.width,_;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=k&&(0,t.jsx)("div",{className:"flex items-center px-6 pt-4 sm:-mt-8",children:(0,t.jsxs)("a",{href:k,"aria-label":"Back to gallery",className:q(Y({variant:"text",size:"sm"}),"gap-2 px-0 text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(ee,{className:"size-4","aria-hidden":!0}),(0,t.jsx)("span",{children:"Back"})]})}),e[15]=_):_=e[15];let c;e[16]===l?c=e[17]:(c=(0,t.jsx)(ie,{connection:l,className:"sm:pt-8",children:_}),e[16]=l,e[17]=c);let d;e[18]===j?d=e[19]:(d=j(),e[18]=j,e[19]=d);let N;return e[20]!==s.width||e[21]!==l||e[22]!==f||e[23]!==v||e[24]!==c||e[25]!==d?(N=(0,t.jsxs)(se,{connection:l,isRunning:f,width:S,onReconnect:v,children:[c,d]}),e[20]=s.width,e[21]=l,e[22]=f,e[23]=v,e[24]=c,e[25]=d,e[26]=N):N=e[26],N};function Se(){B.INSTANCE.stop()}var A=I();const Ce=()=>{let o=(0,A.c)(3),e=E($);if(!O()||!e)return null;let s;o[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsxs)("span",{children:["Static"," ",(0,t.jsx)("a",{href:z.githubPage,target:"_blank",className:"text-(--sky-11) font-medium underline",children:"marimo"})," ","notebook - Run or edit for full interactivity"]}),o[0]=s):s=o[0];let r;return o[1]===e?r=o[2]:(r=(0,t.jsxs)("div",{className:"px-4 py-2 bg-(--sky-2) border-b border-(--sky-7) text-(--sky-11) flex justify-between items-center gap-4 print:hidden text-sm","data-testid":"static-notebook-banner",children:[s,(0,t.jsx)("span",{className:"shrink-0",children:(0,t.jsx)(ze,{code:e})})]}),o[1]=e,o[2]=r),r};var ze=o=>{var P;let e=(0,A.c)(36),{code:s}=o,r=ue()||"notebook.py",p=r.lastIndexOf("/");p!==-1&&(r=r.slice(p+1));let[i]=F(),n=((P=i.sharing)==null?void 0:P.molab)!==!1,h=window.location.href,u;e[0]===s?u=e[1]:(u=je({code:s,baseUrl:`${z.molab}/new`}),e[0]=s,e[1]=u);let l=u,v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)(he,{asChild:!0,children:(0,t.jsx)(R,{"data-testid":"static-notebook-dialog-trigger",variant:"outline",size:"xs",children:"Run or Edit"})}),e[2]=v):v=e[2];let f;e[3]===r?f=e[4]:(f=(0,t.jsx)(pe,{children:r}),e[3]=r,e[4]=f);let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=(0,t.jsxs)("p",{children:["This is a static"," ",(0,t.jsx)("a",{href:z.githubPage,target:"_blank",className:"text-(--sky-11) hover:underline font-medium",children:"marimo"})," ","notebook. To run interactively:"]}),e[5]=g):g=e[5];let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=(0,t.jsx)("br",{}),e[6]=w):w=e[6];let b;e[7]===r?b=e[8]:(b=(0,t.jsx)("div",{className:"rounded-lg p-3 border bg-(--sky-2) border-(--sky-7)",children:(0,t.jsxs)("div",{className:"font-mono text-(--sky-11) leading-relaxed",children:["pip install marimo",w,"marimo edit ",r]})}),e[7]=r,e[8]=b);let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=!h.endsWith(".html")&&(0,t.jsxs)("div",{className:"rounded-lg p-3 border bg-(--sky-2) border-(--sky-7)",children:[(0,t.jsx)("div",{className:"text-sm text-(--sky-12) mb-1",children:"Or run directly from URL:"}),(0,t.jsxs)("div",{className:"font-mono text-(--sky-11) break-all",children:["marimo edit ",window.location.href]})]}),e[9]=y):y=e[9];let j;e[10]!==n||e[11]!==l?(j=n&&(0,t.jsxs)("div",{className:"pt-3 border-t flex gap-2 items-center",children:[(0,t.jsx)(R,{asChild:!0,variant:"outline",size:"xs",className:"shrink-0",children:(0,t.jsxs)("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:[(0,t.jsx)(ke,{size:12,strokeWidth:1.5,className:"mr-1.5 mt-px text-(--grass-11)"}),"Open in molab"]})}),(0,t.jsxs)("p",{className:"text-sm text-(--sky-12)",children:["Run this notebook in"," ",(0,t.jsx)("span",{className:"font-semibold",children:"molab"}),", marimo's cloud-hosted notebook platform."]})]}),e[10]=n,e[11]=l,e[12]=j):j=e[12];let m;e[13]!==b||e[14]!==j?(m=(0,t.jsxs)(fe,{className:"pt-3 text-left space-y-3",children:[g,b,y,j]}),e[13]=b,e[14]=j,e[15]=m):m=e[15];let k;e[16]!==f||e[17]!==m?(k=(0,t.jsxs)(de,{children:[f,m]}),e[16]=f,e[17]=m,e[18]=k):k=e[18];let S;e[19]===s?S=e[20]:(S=async()=>{await ce(s),le({title:"Copied to clipboard"})},e[19]=s,e[20]=S);let _;e[21]===Symbol.for("react.memo_cache_sentinel")?(_=(0,t.jsx)(te,{className:"w-3 h-3 mr-2"}),e[21]=_):_=e[21];let c;e[22]===S?c=e[23]:(c=(0,t.jsxs)(R,{"data-testid":"copy-static-notebook-dialog-button",variant:"outline",size:"sm",onClick:S,children:[_,"Copy code"]}),e[22]=S,e[23]=c);let d;e[24]!==s||e[25]!==r?(d=()=>{X(new Blob([s],{type:"text/plain"}),r)},e[24]=s,e[25]=r,e[26]=d):d=e[26];let N;e[27]===Symbol.for("react.memo_cache_sentinel")?(N=(0,t.jsx)(K,{className:"w-3 h-3 mr-2"}),e[27]=N):N=e[27];let x;e[28]===d?x=e[29]:(x=(0,t.jsxs)(R,{"data-testid":"download-static-notebook-dialog-button",variant:"outline",size:"sm",onClick:d,children:[N,"Download"]}),e[28]=d,e[29]=x);let a;e[30]!==c||e[31]!==x?(a=(0,t.jsxs)("div",{className:"flex gap-3 pt-2",children:[c,x]}),e[30]=c,e[31]=x,e[32]=a):a=e[32];let C;return e[33]!==k||e[34]!==a?(C=(0,t.jsxs)(be,{children:[v,(0,t.jsxs)(xe,{children:[k,a]})]}),e[33]=k,e[34]=a,e[35]=C):C=e[35],C},D=I(),Re=M()||O(),Ee=o=>{let e=(0,D.c)(9),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(Ce,{}),e[0]=s):s=e[0];let r;e[1]===o.appConfig?r=e[2]:(r=(0,t.jsx)(we,{appConfig:o.appConfig}),e[1]=o.appConfig,e[2]=r);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=Re&&(0,t.jsx)(Ie,{}),e[3]=p):p=e[3];let i;e[4]===r?i=e[5]:(i=(0,t.jsxs)(ye,{children:[s,r,p]}),e[4]=r,e[5]=i);let n;e[6]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(J,{}),e[6]=n):n=e[6];let h;return e[7]===i?h=e[8]:(h=(0,t.jsx)(ae,{children:(0,t.jsxs)(ge,{direction:"horizontal",autoSaveId:"marimo:chrome:v1:run1",children:[i,n]})}),e[7]=i,e[8]=h),h},Ie=()=>{let o=(0,D.c)(1),e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"fixed bottom-0 right-0 z-50 print:hidden","data-testid":"watermark",children:(0,t.jsxs)("a",{href:z.githubPage,target:"_blank",className:"text-sm text-(--grass-11) font-bold tracking-wide transition-colors bg-(--grass-4) hover:bg-(--grass-5) border-t border-l border-(--grass-8) px-3 py-1 rounded-tl-md flex items-center gap-2",children:[(0,t.jsx)("span",{children:"made with marimo"}),(0,t.jsx)(_e,{className:"h-4 w-auto"})]})}),o[0]=e):e=o[0],e},Pe=Ee;export{Pe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as ae}from"./chunk-LvLJmgfZ.js";import{d as be,l as ye,n as V,p as oe,u as we}from"./useEvent-D91BmmQi.js";import{t as Ne}from"./react-Bj1aDYRI.js";import{D as ke,Fn as ze,I as Ce,Ii as Se,Li as m,Oi as Oe,__tla as Ie}from"./cells-vjZ69d-u.js";import"./react-dom-CSu739Rf.js";import{t as se}from"./compiler-runtime-B3qBwwSJ.js";import{v as ie}from"./useEventListener-DvoEXWke.js";import{x as Ae}from"./utils-CvI-39U6.js";import{t as Le}from"./constants-DMpttj8Q.js";import{t as le}from"./cn-DCUzRj2J.js";import{t as Me}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-DFky0PAA.js";import"./popover-CNCYAwbC.js";import{n as Pe,__tla as De}from"./JsonOutput-
|
|
1
|
+
import{s as ae}from"./chunk-LvLJmgfZ.js";import{d as be,l as ye,n as V,p as oe,u as we}from"./useEvent-D91BmmQi.js";import{t as Ne}from"./react-Bj1aDYRI.js";import{D as ke,Fn as ze,I as Ce,Ii as Se,Li as m,Oi as Oe,__tla as Ie}from"./cells-vjZ69d-u.js";import"./react-dom-CSu739Rf.js";import{t as se}from"./compiler-runtime-B3qBwwSJ.js";import{v as ie}from"./useEventListener-DvoEXWke.js";import{x as Ae}from"./utils-CvI-39U6.js";import{t as Le}from"./constants-DMpttj8Q.js";import{t as le}from"./cn-DCUzRj2J.js";import{t as Me}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-DFky0PAA.js";import"./popover-CNCYAwbC.js";import{n as Pe,__tla as De}from"./JsonOutput-BDXmjEj9.js";import"./download-DyF92TRH.js";import{t as z}from"./tooltip-B_PkSKN3.js";import{t as C}from"./button-BbCh-29a.js";import"./dist-D0HyMpgV.js";import"./cjs-BRGiG41H.js";import"./main-B0OX4z33.js";import"./useNonce-DfoVjkkH.js";import{r as Ee}from"./requests-DIwGYs0l.js";import{t as ne}from"./createLucideIcon-D5guW7EU.js";import{f as Re,__tla as He}from"./layout-B5MRVsVq.js";import{n as Ve,t as qe,__tla as Fe}from"./LazyAnyLanguageCodeMirror-DGz0wXbE.js";import{__tla as Te}from"./markdown-renderer-DTD6g-4R.js";import{u as Ge}from"./toDate-B5A0DFEz.js";import{t as Ue,__tla as Be}from"./cell-editor-LaoP9GSh.js";import{t as Je}from"./spinner-UuZAUjoP.js";import{i as Ke}from"./useDeleteCell-ChnARMDw.js";import"./dist-CMvFIVSA.js";import"./dist-cJl5Fok5.js";import"./dist-BFCmbzWi.js";import"./dist-CS6moqWs.js";import"./dist-DTNIEaQR.js";import"./session-DGdfs0bJ.js";import{r as Qe}from"./useTheme-BrivXfaa.js";import"./purify.es-DvRMX74T.js";import"./dates-DS_7IZoI.js";import"./utils-DQRuLEof.js";import"./vega-loader.browser-xq8miGHn.js";import"./defaultLocale-DPBdGRrH.js";import"./defaultLocale-Lfi0pexn.js";import{__tla as We}from"./chunk-5FQGJX7Z-CfK7VoEZ.js";import"./html-to-image-2JVKRW1b.js";import{o as Xe}from"./focus-D3l6p56g.js";import{n as Ye,r as Ze,t as me}from"./react-resizable-panels.browser.esm-BdtIs0E-.js";import{a as $e}from"./renderShortcut-DbyG33_r.js";import"./esm-ChQLuryJ.js";import"./name-cell-input-Cwis179U.js";import{n as et,r as tt}from"./panel-context-BJbBGfoL.js";import{__tla as rt}from"./loro_wasm_bg-CXnd80ne.js";import"./ws-BnE9sl8z.js";import"./Inputs-C6ftxLAJ.js";import"./dist-CH3UDWFp.js";import"./dist-DlCkNQAM.js";import"./dist-DtK0zh8h.js";import"./dist-Bmk2jyet.js";import"./dist-Sbt478Wh.js";import"./dist-C_EhQKG7.js";import"./dist-CAeBZ0Nq.js";import"./dist-BPey9y-W.js";import"./dist-CWGKeV6c.js";import"./esm-B2f-WXoG.js";import{t as at}from"./kiosk-mode-D6Pog-b5.js";let ce,ot=Promise.all([(()=>{try{return Ie}catch{}})(),(()=>{try{return De}catch{}})(),(()=>{try{return He}catch{}})(),(()=>{try{return Fe}catch{}})(),(()=>{try{return Te}catch{}})(),(()=>{try{return Be}catch{}})(),(()=>{try{return We}catch{}})(),(()=>{try{return rt}catch{}})()]).then(async()=>{var de=ne("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),he=ne("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),pe=se(),q=ae(Ne(),1),ue=15;const F=Oe("marimo:scratchpadHistory:v1",[],ze),fe=oe(!1),xe=oe(null,(e,s,i)=>{if(i=i.trim(),!i)return;let n=e(F);s(F,[i,...n.filter(c=>c!==i)].slice(0,ue))});var t=ae(Me(),1),_e={hide_code:!1,disabled:!1};const ve=()=>{var re;let e=(0,pe.c)(60),s=Ce(),[i]=Ae(),{theme:n}=Qe(),c=(0,q.useRef)(null),T=Xe(),{createNewCell:G,updateCellCode:d}=ke(),{sendRunScratchpad:h}=Ee(),S=et(),U=tt(),l=s.cellRuntime[m],B=l==null?void 0:l.output,O=l==null?void 0:l.status,J=l==null?void 0:l.consoleOutputs,r=((re=s.cellData.__scratch__)==null?void 0:re.code)??"",K=be(xe),[o,p]=ye(fe),u=we(F),I;e[0]!==K||e[1]!==r||e[2]!==h?(I=()=>{h({code:r}),K(r)},e[0]=K,e[1]=r,e[2]=h,e[3]=I):I=e[3];let f=V(I),A;e[4]!==r||e[5]!==G||e[6]!==T?(A=()=>{r.trim()&&G({code:r,before:!1,cellId:T??"__end__"})},e[4]=r,e[5]=G,e[6]=T,e[7]=A):A=e[7];let Q=V(A),L;e[8]!==h||e[9]!==d?(L=()=>{d({cellId:m,code:"",formattingChange:!1}),h({code:""});let a=c.current;a&&a.dispatch({changes:{from:0,to:a.state.doc.length,insert:""}})},e[8]=h,e[9]=d,e[10]=L):L=e[10];let W=V(L),M;e[11]!==p||e[12]!==d?(M=a=>{p(!1),d({cellId:m,code:a,formattingChange:!1});let k=c.current;k&&k.dispatch({changes:{from:0,to:k.state.doc.length,insert:a}})},e[11]=p,e[12]=d,e[13]=M):M=e[13];let X=V(M),[Y,ge]=(0,q.useState)(),P;e[14]!==X||e[15]!==u||e[16]!==o||e[17]!==n?(P=()=>o?(0,t.jsx)("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:(0,t.jsx)("div",{className:"overflow-auto flex flex-col gap-3",children:u.map((a,k)=>(0,t.jsx)("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>X(a),children:(0,t.jsx)(q.Suspense,{children:(0,t.jsx)(qe,{language:"python",theme:n,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:a.trim(),editable:!1,readOnly:!0})})},k))})}):null,e[14]=X,e[15]=u,e[16]=o,e[17]=n,e[18]=P):P=e[18];let Z=P,D;e[19]!==W||e[20]!==Q||e[21]!==f||e[22]!==u.length||e[23]!==o||e[24]!==p||e[25]!==O?(D=()=>(0,t.jsxs)("div",{className:"flex items-center shrink-0 border-b",children:[(0,t.jsx)(z,{content:$e("cell.run"),children:(0,t.jsx)(C,{"data-testid":"scratchpad-run-button",onClick:f,disabled:o,variant:"text",size:"xs",children:(0,t.jsx)(Ke,{color:"var(--grass-11)",size:16})})}),(0,t.jsx)(z,{content:"Clear code and outputs",children:(0,t.jsx)(C,{disabled:o,size:"xs",variant:"text",onClick:W,children:(0,t.jsx)(de,{size:16})})}),(0,t.jsx)(at,{children:(0,t.jsx)(z,{content:"Insert code",children:(0,t.jsx)(C,{disabled:o,size:"xs",variant:"text",onClick:Q,children:(0,t.jsx)(Ve,{size:16})})})}),(O==="running"||O==="queued")&&(0,t.jsx)(Je,{className:"inline",size:"small"}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsx)(z,{content:"Toggle history",children:(0,t.jsx)(C,{size:"xs",variant:"text",className:le(o&&"bg-(--sky-3) rounded-none"),onClick:()=>p(!o),disabled:u.length===0,children:(0,t.jsx)(he,{size:16})})}),(0,t.jsx)(z,{content:(0,t.jsx)("span",{className:"block max-w-prose",children:"Use this scratchpad to experiment with code without restrictions on variable names. Variables defined here aren't saved to notebook memory, and the code is not saved in the notebook file."}),children:(0,t.jsx)(C,{size:"xs",variant:"text",children:(0,t.jsx)(Ge,{size:16})})})]}),e[19]=W,e[20]=Q,e[21]=f,e[22]=u.length,e[23]=o,e[24]=p,e[25]=O,e[26]=D):D=e[26];let $=D,je=S==="vertical",E;e[27]===Symbol.for("react.memo_cache_sentinel")?(E=Se.create(m),e[27]=E):E=e[27];let x;e[28]===$?x=e[29]:(x=$(),e[28]=$,e[29]=x);let R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=a=>{c.current=a},e[30]=R):R=e[30];let _;e[31]!==r||e[32]!==f||e[33]!==Y||e[34]!==n||e[35]!==i?(_=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Ue,{theme:n,showPlaceholder:!1,id:m,code:r,config:_e,status:"idle",serializedEditorState:null,runCell:f,userConfig:i,editorViewRef:c,setEditorView:R,hidden:!1,showHiddenCode:ie.NOOP,languageAdapter:Y,setLanguageAdapter:ge})}),e[31]=r,e[32]=f,e[33]=Y,e[34]=n,e[35]=i,e[36]=_):_=e[36];let v;e[37]===Z?v=e[38]:(v=Z(),e[37]=Z,e[38]=v);let g;e[39]!==v||e[40]!==x||e[41]!==_?(g=(0,t.jsx)(me,{defaultSize:40,minSize:20,maxSize:70,children:(0,t.jsxs)("div",{className:"h-full flex flex-col overflow-hidden relative",children:[x,_,v]})}),e[39]=v,e[40]=x,e[41]=_,e[42]=g):g=e[42];let ee=je?"h-1":"w-1",j;e[43]===ee?j=e[44]:(j=le("bg-border hover:bg-primary/50 transition-colors",ee),e[43]=ee,e[44]=j);let b;e[45]===j?b=e[46]:(b=(0,t.jsx)(Ze,{className:j}),e[45]=j,e[46]=b);let y;e[47]===B?y=e[48]:(y=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Pe,{allowExpand:!1,output:B,className:Le.outputArea,cellId:m,stale:!1,loading:!1})}),e[47]=B,e[48]=y);let w;e[49]===J?w=e[50]:(w=(0,t.jsx)("div",{className:"overflow-auto shrink-0 max-h-[50%]",children:(0,t.jsx)(Re,{consoleOutputs:J,className:"overflow-auto",stale:!1,interrupted:!1,cellName:"_",onSubmitDebugger:ie.NOOP,cellId:m,debuggerActive:!1})}),e[49]=J,e[50]=w);let N;e[51]!==y||e[52]!==w?(N=(0,t.jsx)(me,{defaultSize:60,minSize:20,children:(0,t.jsxs)("div",{className:"h-full flex flex-col divide-y overflow-hidden",children:[y,w]})}),e[51]=y,e[52]=w,e[53]=N):N=e[53];let H;return e[54]!==S||e[55]!==U||e[56]!==g||e[57]!==b||e[58]!==N?(H=(0,t.jsx)("div",{className:"flex flex-col h-full overflow-hidden",id:E,children:(0,t.jsxs)(Ye,{direction:S,className:"h-full",children:[g,b,N]},U)}),e[54]=S,e[55]=U,e[56]=g,e[57]=b,e[58]=N,e[59]=H):H=e[59],H};let te;te=se(),ce=()=>{let e=(0,te.c)(1),s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(ve,{}),e[0]=s):s=e[0],s}});export{ot as __tla,ce as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as ie}from"./chunk-LvLJmgfZ.js";import{d as de,l as he,p as ue,u as K}from"./useEvent-D91BmmQi.js";import{t as Pe}from"./react-Bj1aDYRI.js";import{Ar as Me,At as Ee,Br as xe,D as Oe,Fn as pe,Fr as fe,Gt as Re,In as Ue,Ir as Ae,Kt as Ge,Lr as We,M as ze,Nr as se,Oi as be,P as He,Pr as ge,Rn as Ke,Rt as Je,Ur as Xe,Vr as je,Wr as Ne,Wt as Ye,_n as Qe,a as Ze,ar as ea,cr as aa,f as ta,hr as sa,or as la,vr as na,yr as le}from"./cells-vjZ69d-u.js";import"./react-dom-CSu739Rf.js";import{t as ye}from"./compiler-runtime-B3qBwwSJ.js";import{c as ra}from"./utils-CvI-39U6.js";import{t as oa}from"./ErrorBoundary-DyYDV0HI.js";import{t as O}from"./cn-DCUzRj2J.js";import{t as ma}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-DFky0PAA.js";import{n as ca}from"./multi-map-C4OANz8X.js";import"./popover-CNCYAwbC.js";import{G as ia,J as da,K as ha,U as ne,W as ve,q as ua}from"./JsonOutput-BYEhZqb8.js";import"./download-DyF92TRH.js";import{r as we}from"./radio-group-BI8_7tB1.js";import{t as re}from"./tooltip-B_PkSKN3.js";import{r as xa,t as ee}from"./button-BbCh-29a.js";import"./dist-D0HyMpgV.js";import{u as J}from"./arrays-DYDL-3-i.js";import"./cjs-BRGiG41H.js";import"./main-B0OX4z33.js";import"./useNonce-DfoVjkkH.js";import{i as pa}from"./strings-wdPMRf6Z.js";import{r as fa}from"./requests-DIwGYs0l.js";import{t as ba}from"./createLucideIcon-D5guW7EU.js";import{t as ga}from"./x-C-6liIBr.js";import"./markdown-renderer-DTD6g-4R.js";import{t as Se}from"./add-connection-dialog-BGaI0GCh.js";import{t as Ce}from"./plus-CxkHs8QM.js";import{a as ja}from"./input-Dvl7sgNQ.js";import{n as Na,o as ya}from"./column-preview-Bqp95o1c.js";import{t as va}from"./workflow-CgnDnnoN.js";import"./dist-CMvFIVSA.js";import"./dist-cJl5Fok5.js";import"./dist-BFCmbzWi.js";import"./dist-CS6moqWs.js";import"./dist-DTNIEaQR.js";import"./session-DGdfs0bJ.js";import"./purify.es-DvRMX74T.js";import"./dates-DS_7IZoI.js";import{t as wa}from"./copy-icon-c48rtYOO.js";import{t as Sa}from"./context-C1Tm_47t.js";import"./utils-DQRuLEof.js";import"./vega-loader.browser-xq8miGHn.js";import"./defaultLocale-DPBdGRrH.js";import"./defaultLocale-Lfi0pexn.js";import{t as _e}from"./cell-link-CgOvnjYt.js";import"./chunk-5FQGJX7Z-CfK7VoEZ.js";import{r as Ca}from"./html-to-image-2JVKRW1b.js";import{o as _a}from"./focus-D3l6p56g.js";import{n as oe}from"./useAsyncData-Dg8E_bPh.js";import{a as ka,i as Fa,n as $a,o as ke,r as Ta,t as Ia}from"./table-Bgc-inJs.js";import"./react-resizable-panels.browser.esm-BdtIs0E-.js";import{a as La,d as qa,o as ae,t as Da}from"./command-rtnOVF57.js";import{n as Va}from"./icons-8tfAri2V.js";import{a as Ba,r as Pa}from"./tree-actions-ovIJqNLj.js";import{a as me,i as te,o as ce,r as Fe,s as $e,t as Ma}from"./components-1VuqOYTA.js";import{t as Ea}from"./empty-state-Cjt8SfMh.js";import{n as Oa,t as Ra}from"./common-yg4W3pLU.js";import{a as Ua,i as Aa,n as Te,r as Ie,t as Le}from"./components-DRXxpmLU.js";var Ga=ba("square-equal",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]),A=ye(),$=ie(Pe(),1),t=ie(ma(),1),F={engineEmpty:"pl-3",engine:"pl-3 pr-2",database:"pl-4",schemaEmpty:"pl-8",schema:"pl-7",schemaLoading:"pl-8",tableLoading:"pl-11",tableSchemaless:"pl-8",tableWithSchema:"pl-12",columnLocal:"pl-5",columnSql:"pl-13",columnPreview:"pl-10"},Wa=ue(a=>{let e=a(fe),s=a(Ke),l=a(Ze);return J(e,r=>{if(!r.variable_name)return-1;let m=Object.values(s).find(g=>g.name===r.variable_name);if(!m)return 0;let n=l.inOrderIds.indexOf(m.declaredBy[0]);return n===-1?0:n})});const za=be("marimo:datasources:hideEmpty",!1,pe,{getOnInit:!0});function Ha(a){return a.tables_resolved!==!1&&a.tables.length===0}function Ka(a){let e=!1,s=[];for(let l of a){if(l.schemas_resolved!==!1&&l.schemas.length===0){e=!0;continue}if(l.schemas.length===0){s.push(l);continue}let r=l.schemas.filter(m=>!Ha(m));if(r.length===0){e=!0;continue}if(r.length===l.schemas.length){s.push(l);continue}e=!0,s.push({...l,schemas:r})}return e?s:a}const qe=ue(a=>{let e=new Map(a(Me));for(let s of Ne){let l=e.get(s);l&&(l.databases.length===0&&e.delete(s),l.databases.length===1&&l.databases[0].name==="memory"&&l.databases[0].schemas.length===0&&e.delete(s))}return J([...e.values()],s=>Ne.has(s.name)?1:0)}),Ja=()=>{let a=(0,A.c)(42),[e,s]=$.useState(""),[l,r]=he(za),m=de(ge),n=K(Wa),g=K(qe),j;e:{if(!l){j=g;break e}let v,w;a[0]===g?(v=a[1],w=a[2]):(v=!1,w=g.map(k=>{let T=Ka(k.databases);return T===k.databases?k:(v=!0,{...k,databases:T})}),a[0]=g,a[1]=v,a[2]=w),j=v?w:g}let N=j;if(n.length===0&&N.length===0){let v;return a[3]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)(Ea,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:(0,t.jsx)(Se,{children:(0,t.jsxs)(ee,{variant:"outline",size:"sm",children:["Add database or catalog",(0,t.jsx)(Ce,{className:"h-4 w-4 ml-2"})]})}),icon:(0,t.jsx)(le,{})}),a[3]=v):v=a[3],v}let u=!!e.trim(),c;a[4]===m?c=a[5]:(c=v=>{m(v.length>0),s(v)},a[4]=m,a[5]=c);let i;a[6]!==e||a[7]!==c?(i=(0,t.jsx)(La,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:c,rootClassName:"flex-1 border-r border-b-0"}),a[6]=e,a[7]=c,a[8]=i):i=a[8];let h;a[9]===u?h=a[10]:(h=u&&(0,t.jsx)("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:()=>s(""),children:(0,t.jsx)(ga,{className:"h-4 w-4"})}),a[9]=u,a[10]=h);let p=!l,d;a[11]!==l||a[12]!==r?(d=()=>r(!l),a[11]=l,a[12]=r,a[13]=d):d=a[13];let o;a[14]!==p||a[15]!==d?(o=(0,t.jsx)(Ba,{"data-testid":"datasources-hide-empty-button",isVisible:p,onToggle:d,showTooltip:"Show empty schemas and databases",hideTooltip:"Hide empty schemas and databases",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden"}),a[14]=p,a[15]=d,a[16]=o):o=a[16];let b;a[17]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)(Se,{children:(0,t.jsx)(ee,{variant:"ghost",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden",children:(0,t.jsx)(Ce,{className:"h-4 w-4"})})}),a[17]=b):b=a[17];let x;a[18]!==i||a[19]!==h||a[20]!==o?(x=(0,t.jsxs)("div",{className:"flex items-center w-full border-b",children:[i,h,o,b]}),a[18]=i,a[19]=h,a[20]=o,a[21]=x):x=a[21];let f;if(a[22]!==N||a[23]!==u||a[24]!==e){let v;a[26]!==u||a[27]!==e?(v=w=>(0,t.jsx)(Xa,{connection:w,hasChildren:w.databases.length>0,children:w.databases.map(k=>(0,t.jsx)(Ya,{engineName:w.name,database:k,hasSearch:u,children:(0,t.jsx)(Qa,{schemas:k.schemas,defaultSchema:w.default_schema,defaultDatabase:w.default_database,engineName:w.name,databaseName:k.name,hasSearch:u,searchValue:e,dialect:w.dialect})},k.name))},w.name),a[26]=u,a[27]=e,a[28]=v):v=a[28],f=N.map(v),a[22]=N,a[23]=u,a[24]=e,a[25]=f}else f=a[25];let y;a[29]!==N.length||a[30]!==n.length?(y=N.length>0&&n.length>0&&(0,t.jsxs)(Fe,{className:F.engine,children:[(0,t.jsx)(Va,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-xs",children:"Python"})]}),a[29]=N.length,a[30]=n.length,a[31]=y):y=a[31];let S;a[32]!==e||a[33]!==n?(S=n.length>0&&(0,t.jsx)(De,{tables:n,searchValue:e}),a[32]=e,a[33]=n,a[34]=S):S=a[34];let C;a[35]!==y||a[36]!==S||a[37]!==f?(C=(0,t.jsxs)(qa,{className:"flex flex-col",children:[f,y,S]}),a[35]=y,a[36]=S,a[37]=f,a[38]=C):C=a[38];let _;return a[39]!==C||a[40]!==x?(_=(0,t.jsxs)(Da,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden",shouldFilter:!1,children:[x,C]}),a[39]=C,a[40]=x,a[41]=_):_=a[41],_};var Xa=a=>{let e=(0,A.c)(25),{connection:s,children:l,hasChildren:r}=a,m=s.name===Xe,n=m?"In-Memory":s.name,{previewDataSourceConnection:g}=fa(),j;e[0]!==s.name||e[1]!==g?(j=async()=>{await g({engine:s.name})},e[0]=s.name,e[1]=g,e[2]=j):j=e[2];let N=j,u;e[3]===s.dialect?u=e[4]:(u=(0,t.jsx)(Ee,{className:"h-4 w-4 text-muted-foreground",name:s.dialect}),e[3]=s.dialect,e[4]=u);let c;e[5]===s.dialect?c=e[6]:(c=ea(s.dialect),e[5]=s.dialect,e[6]=c);let i;e[7]===c?i=e[8]:(i=(0,t.jsx)("span",{className:"text-xs",children:c}),e[7]=c,e[8]=i);let h=n,p;e[9]===h?p=e[10]:(p=(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(0,t.jsx)(Ua,{variableName:h}),")"]}),e[9]=h,e[10]=p);let d;e[11]!==N||e[12]!==m?(d=!m&&(0,t.jsx)(Pa,{onClick:N,tooltip:"Refresh connection",className:"ml-auto h-4 p-0",iconClassName:"h-3.5 w-3.5"}),e[11]=N,e[12]=m,e[13]=d):d=e[13];let o;e[14]!==u||e[15]!==i||e[16]!==p||e[17]!==d?(o=(0,t.jsxs)(Fe,{className:F.engine,children:[u,i,p,d]}),e[14]=u,e[15]=i,e[16]=p,e[17]=d,e[18]=o):o=e[18];let b;e[19]!==l||e[20]!==r?(b=r?l:(0,t.jsx)(te,{content:"No databases available",className:F.engineEmpty}),e[19]=l,e[20]=r,e[21]=b):b=e[21];let x;return e[22]!==o||e[23]!==b?(x=(0,t.jsxs)(t.Fragment,{children:[o,b]}),e[22]=o,e[23]=b,e[24]=x):x=e[24],x},Ya=a=>{let e=(0,A.c)(26),{hasSearch:s,engineName:l,database:r,children:m}=a,[n,g]=$.useState(!1),[j,N]=$.useState(!1),[u,c]=$.useState(s);u!==s&&(c(s),g(s));let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=O("text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",F.database),e[0]=i):i=e[0];let h;e[1]!==n||e[2]!==j?(h=()=>{g(!n),N(!j)},e[1]=n,e[2]=j,e[3]=h):h=e[3];let p=`${l}:${r.name}`,d;e[4]===n?d=e[5]:(d=(0,t.jsx)($e,{isExpanded:n}),e[4]=n,e[5]=d);let o=j&&n?"text-foreground":"text-muted-foreground",b;e[6]===o?b=e[7]:(b=O("h-4 w-4",o),e[6]=o,e[7]=b);let x;e[8]===b?x=e[9]:(x=(0,t.jsx)(le,{className:b}),e[8]=b,e[9]=x);let f=j&&n&&"font-semibold",y;e[10]===f?y=e[11]:(y=O(f),e[10]=f,e[11]=y);let S;e[12]===r.name?S=e[13]:(S=r.name===""?(0,t.jsx)("i",{children:"Not connected"}):r.name,e[12]=r.name,e[13]=S);let C;e[14]!==S||e[15]!==y?(C=(0,t.jsx)("span",{className:y,children:S}),e[14]=S,e[15]=y,e[16]=C):C=e[16];let _;e[17]!==C||e[18]!==h||e[19]!==p||e[20]!==d||e[21]!==x?(_=(0,t.jsxs)(ae,{className:i,onSelect:h,value:p,children:[d,x,C]}),e[17]=C,e[18]=h,e[19]=p,e[20]=d,e[21]=x,e[22]=_):_=e[22];let v=n&&m,w;return e[23]!==_||e[24]!==v?(w=(0,t.jsxs)(t.Fragment,{children:[_,v]}),e[23]=_,e[24]=v,e[25]=w):w=e[25],w},Qa=({schemas:a,defaultSchema:e,defaultDatabase:s,dialect:l,engineName:r,databaseName:m,hasSearch:n,searchValue:g})=>{let{addSchemaList:j}=se(),[N,u]=$.useState(!1),[c,i]=$.useState(!1),{isPending:h,error:p}=oe(async()=>{if(a.length===0&&r&&!N){u(!0),i(!0);try{j({schemas:(await Ye.request({engine:r,database:m})).schemas??[],sqlSchemaContext:{engine:r,database:m}})}finally{i(!1)}}},[a.length,r,m,N]);return h||c?(0,t.jsx)(ce,{message:"Loading schemas...",className:F.schemaLoading}):p?(0,t.jsx)(me,{error:p,className:F.schemaLoading}):a.length===0?(0,t.jsx)(te,{content:"No schemas available",className:F.schemaEmpty}):(0,t.jsx)(t.Fragment,{children:a.filter(d=>g?d.tables.some(o=>o.name.toLowerCase().includes(g.toLowerCase())):!0).map(d=>(0,t.jsx)(Za,{databaseName:m,schema:d,hasSearch:n,children:(0,t.jsx)(De,{tables:d.tables,searchValue:g,sqlTableContext:{engine:r,database:m,schema:d.name,defaultSchema:e,defaultDatabase:s,dialect:l}})},d.name))})},Za=a=>{let e=(0,A.c)(24),{databaseName:s,schema:l,children:r,hasSearch:m}=a,[n,g]=$.useState(m),[j,N]=$.useState(!1),u=`${s}:${l.name}`;if(xe(l.name))return r;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=O("text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",F.schema),e[0]=c):c=e[0];let i;e[1]!==n||e[2]!==j?(i=()=>{g(!n),N(!j)},e[1]=n,e[2]=j,e[3]=i):i=e[3];let h;e[4]===n?h=e[5]:(h=(0,t.jsx)($e,{isExpanded:n}),e[4]=n,e[5]=h);let p=j&&n&&"text-foreground",d;e[6]===p?d=e[7]:(d=O("h-4 w-4 text-muted-foreground",p),e[6]=p,e[7]=d);let o;e[8]===d?o=e[9]:(o=(0,t.jsx)(sa,{className:d}),e[8]=d,e[9]=o);let b=j&&n&&"font-semibold",x;e[10]===b?x=e[11]:(x=O(b),e[10]=b,e[11]=x);let f;e[12]!==l.name||e[13]!==x?(f=(0,t.jsx)("span",{className:x,children:l.name}),e[12]=l.name,e[13]=x,e[14]=f):f=e[14];let y;e[15]!==i||e[16]!==h||e[17]!==o||e[18]!==f||e[19]!==u?(y=(0,t.jsxs)(ae,{className:c,onSelect:i,value:u,children:[h,o,f]}),e[15]=i,e[16]=h,e[17]=o,e[18]=f,e[19]=u,e[20]=y):y=e[20];let S=n&&r,C;return e[21]!==y||e[22]!==S?(C=(0,t.jsxs)(t.Fragment,{children:[y,S]}),e[21]=y,e[22]=S,e[23]=C):C=e[23],C},De=a=>{let e=(0,A.c)(24),{tables:s,sqlTableContext:l,searchValue:r}=a,{addTableList:m}=se(),[n,g]=$.useState(!1),[j,N]=$.useState(!1),u;e[0]!==m||e[1]!==l||e[2]!==s.length||e[3]!==n?(u=async()=>{if(s.length===0&&l&&!n){g(!0),N(!0);let{engine:o,database:b,schema:x}=l,f=await Ge.request({engine:o,database:b,schema:x});if(!(f!=null&&f.tables))throw N(!1),Error("No tables available");m({tables:f.tables,sqlTableContext:l}),N(!1)}},e[0]=m,e[1]=l,e[2]=s.length,e[3]=n,e[4]=u):u=e[4];let c;e[5]!==l||e[6]!==s.length||e[7]!==n?(c=[s.length,l,n],e[5]=l,e[6]=s.length,e[7]=n,e[8]=c):c=e[8];let{isPending:i,error:h}=oe(u,c);if(i||j){let o;return e[9]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(ce,{message:"Loading tables...",className:F.tableLoading}),e[9]=o):o=e[9],o}if(h){let o;return e[10]===h?o=e[11]:(o=(0,t.jsx)(me,{error:h,className:F.tableLoading}),e[10]=h,e[11]=o),o}if(s.length===0){let o;return e[12]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(te,{content:"No tables found",className:F.tableLoading}),e[12]=o):o=e[12],o}let p;if(e[13]!==r||e[14]!==l||e[15]!==s){let o;e[17]===r?o=e[18]:(o=f=>r?f.name.toLowerCase().includes(r.toLowerCase()):!0,e[17]=r,e[18]=o);let b=s.filter(o),x;e[19]!==r||e[20]!==l?(x=f=>(0,t.jsx)(et,{table:f,sqlTableContext:l,isSearching:!!r},f.name),e[19]=r,e[20]=l,e[21]=x):x=e[21],p=b.map(x),e[13]=r,e[14]=l,e[15]=s,e[16]=p}else p=e[16];let d;return e[22]===p?d=e[23]:(d=(0,t.jsx)(t.Fragment,{children:p}),e[22]=p,e[23]=d),d},et=a=>{let e=(0,A.c)(64),{table:s,sqlTableContext:l,isSearching:r}=a,{addTable:m}=se(),[n,g]=$.useState(!1),[j,N]=$.useState(!1),u=s.columns.length>0,c;e[0]!==m||e[1]!==n||e[2]!==l||e[3]!==s.name||e[4]!==u||e[5]!==j?(c=async()=>{if(n&&!u&&l&&!j){N(!0);let{engine:B,database:Q,schema:Be}=l,Z=await Re.request({engine:B,database:Q,schema:Be,tableName:s.name});if(!(Z!=null&&Z.table))throw Error("No table details available");m({table:Z.table,sqlTableContext:l})}},e[0]=m,e[1]=n,e[2]=l,e[3]=s.name,e[4]=u,e[5]=j,e[6]=c):c=e[6];let i;e[7]!==n||e[8]!==u?(i=[n,u],e[7]=n,e[8]=u,e[9]=i):i=e[9];let{isFetching:h,isPending:p,error:d}=oe(c,i),o=K(ra),b=_a(),{createNewCell:x}=Oe(),f=we(),y;e[10]!==f||e[11]!==o||e[12]!==x||e[13]!==b||e[14]!==l||e[15]!==s?(y=()=>{Ca({autoInstantiate:o,createNewCell:x,fromCellId:b}),f((()=>{if(s.source_type==="catalog"){let B=l!=null&&l.database?`${l.database}.${s.name}`:s.name;return`${s.engine}.load_table("${B}")`}if(l)return je({table:s,columnName:"*",sqlTableContext:l});switch(s.source_type){case"local":return`mo.ui.table(${s.name})`;case"duckdb":case"connection":return je({table:s,columnName:"*",sqlTableContext:l});default:return pa(s.source_type),""}})())},e[10]=f,e[11]=o,e[12]=x,e[13]=b,e[14]=l,e[15]=s,e[16]=y):y=e[16];let S=y,C;e[17]!==s.num_columns||e[18]!==s.num_rows?(C=()=>{let B=[];return s.num_rows!=null&&B.push(`${s.num_rows} rows`),s.num_columns!=null&&B.push(`${s.num_columns} columns`),B.length===0?null:(0,t.jsx)("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:B.join(", ")})})},e[17]=s.num_columns,e[18]=s.num_rows,e[19]=C):C=e[19];let _=C,v;e[20]!==d||e[21]!==h||e[22]!==p||e[23]!==l||e[24]!==s?(v=()=>{if(p||h)return(0,t.jsx)(ce,{message:"Loading columns...",className:F.tableLoading});if(d)return(0,t.jsx)(me,{error:d,className:F.tableLoading});let B=s.columns;return B.length===0?(0,t.jsx)(te,{content:"No columns found",className:F.tableLoading}):B.map(Q=>(0,t.jsx)(at,{table:s,column:Q,sqlTableContext:l},Q.name))},e[20]=d,e[21]=h,e[22]=p,e[23]=l,e[24]=s,e[25]=v):v=e[25];let w=v,k;e[26]!==n||e[27]!==r||e[28]!==s.source_type||e[29]!==s.type?(k=()=>{if(s.source_type!=="local")return(0,t.jsx)(s.type==="table"?aa:na,{className:"h-3 w-3",strokeWidth:n||r?2.5:void 0})},e[26]=n,e[27]=r,e[28]=s.source_type,e[29]=s.type,e[30]=k):k=e[30];let T=k,P=l?`${l.database}.${l.schema}.${s.name}`:s.name,M=l&&(xe(l.schema)?F.tableSchemaless:F.tableWithSchema),E=(n||r)&&"font-semibold",I;e[31]!==M||e[32]!==E?(I=O("rounded-none group h-8 cursor-pointer",M,E),e[31]=M,e[32]=E,e[33]=I):I=e[33];let L;e[34]===n?L=e[35]:(L=()=>g(!n),e[34]=n,e[35]=L);let q;e[36]===T?q=e[37]:(q=T(),e[36]=T,e[37]=q);let V;e[38]===s.name?V=e[39]:(V=(0,t.jsx)("span",{className:"text-sm",children:s.name}),e[38]=s.name,e[39]=V);let R;e[40]!==q||e[41]!==V?(R=(0,t.jsxs)("div",{className:"flex gap-2 items-center flex-1 pl-1",children:[q,V]}),e[40]=q,e[41]=V,e[42]=R):R=e[42];let U;e[43]===_?U=e[44]:(U=_(),e[43]=_,e[44]=U);let D;e[45]===S?D=e[46]:(D=xa.stopPropagation(()=>S()),e[45]=S,e[46]=D);let X;e[47]===Symbol.for("react.memo_cache_sentinel")?(X=(0,t.jsx)(ya,{className:"h-3 w-3"}),e[47]=X):X=e[47];let W;e[48]===D?W=e[49]:(W=(0,t.jsx)(re,{content:"Add table to notebook",delayDuration:400,children:(0,t.jsx)(ee,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:D,children:X})}),e[48]=D,e[49]=W);let z;e[50]!==n||e[51]!==L||e[52]!==R||e[53]!==U||e[54]!==W||e[55]!==I||e[56]!==P?(z=(0,t.jsxs)(ae,{className:I,value:P,"aria-selected":n,forceMount:!0,onSelect:L,children:[R,U,W]}),e[50]=n,e[51]=L,e[52]=R,e[53]=U,e[54]=W,e[55]=I,e[56]=P,e[57]=z):z=e[57];let H;e[58]!==n||e[59]!==w?(H=n&&w(),e[58]=n,e[59]=w,e[60]=H):H=e[60];let Y;return e[61]!==z||e[62]!==H?(Y=(0,t.jsxs)(t.Fragment,{children:[z,H]}),e[61]=z,e[62]=H,e[63]=Y):Y=e[63],Y},at=a=>{var R,U;let e=(0,A.c)(48),{table:s,column:l,sqlTableContext:r}=a,[m,n]=$.useState(!1),g=K(ge),j=de(Ae);g&&m&&n(!1),j(m?D=>new Set([...D,`${s.name}:${l.name}`]):D=>(D.delete(`${s.name}:${l.name}`),new Set(D)));let N=we(),{columnsPreviews:u}=We(),c;e[0]!==l.name||e[1]!==s.primary_keys?(c=((R=s.primary_keys)==null?void 0:R.includes(l.name))||!1,e[0]=l.name,e[1]=s.primary_keys,e[2]=c):c=e[2];let i=c,h;e[3]!==l.name||e[4]!==s.indexes?(h=((U=s.indexes)==null?void 0:U.includes(l.name))||!1,e[3]=l.name,e[4]=s.indexes,e[5]=h):h=e[5];let p=h,d;e[6]===N?d=e[7]:(d=D=>{N(D)},e[6]=N,e[7]=d);let o=d,b=tt,x=m?"font-semibold":"",f;e[8]!==l.name||e[9]!==x?(f=(0,t.jsx)("span",{className:x,children:l.name}),e[8]=l.name,e[9]=x,e[10]=f):f=e[10];let y=f,S=`${s.name}.${l.name}`,C=`${s.name}.${l.name}`,_;e[11]===m?_=e[12]:(_=()=>n(!m),e[11]=m,e[12]=_);let v=r?F.columnSql:F.columnLocal,w;e[13]===v?w=e[14]:(w=O("flex flex-row gap-2 items-center flex-1",v),e[13]=v,e[14]=w);let k;e[15]!==l.type||e[16]!==y?(k=(0,t.jsx)(Ma,{columnName:y,dataType:l.type}),e[15]=l.type,e[16]=y,e[17]=k):k=e[17];let T;e[18]===i?T=e[19]:(T=i&&b({tooltipContent:"Primary key",content:"PK"}),e[18]=i,e[19]=T);let P;e[20]===p?P=e[21]:(P=p&&b({tooltipContent:"Indexed",content:"IDX"}),e[20]=p,e[21]=P);let M;e[22]!==w||e[23]!==k||e[24]!==T||e[25]!==P?(M=(0,t.jsxs)("div",{className:w,children:[k,T,P]}),e[22]=w,e[23]=k,e[24]=T,e[25]=P,e[26]=M):M=e[26];let E;e[27]===l.name?E=e[28]:(E=(0,t.jsx)(re,{content:"Copy column name",delayDuration:400,children:(0,t.jsx)(ee,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:(0,t.jsx)(wa,{tooltip:!1,value:l.name,className:"h-3 w-3"})})}),e[27]=l.name,e[28]=E);let I;e[29]===l.external_type?I=e[30]:(I=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l.external_type}),e[29]=l.external_type,e[30]=I);let L;e[31]!==M||e[32]!==E||e[33]!==I||e[34]!==S||e[35]!==C||e[36]!==_?(L=(0,t.jsxs)(ae,{className:"rounded-none py-1 group cursor-pointer",value:C,onSelect:_,children:[M,E,I]},S),e[31]=M,e[32]=E,e[33]=I,e[34]=S,e[35]=C,e[36]=_,e[37]=L):L=e[37];let q;e[38]!==l||e[39]!==u||e[40]!==o||e[41]!==m||e[42]!==r||e[43]!==s?(q=m&&(0,t.jsx)("div",{className:O(F.columnPreview,"pr-2 py-2 bg-(--slate-1) shadow-inner border-b"),children:(0,t.jsx)(oa,{children:(0,t.jsx)(Na,{table:s,column:l,onAddColumnChart:o,preview:u.get(r?`${r.database}.${r.schema}.${s.name}:${l.name}`:`${s.name}:${l.name}`),sqlTableContext:r})})}),e[38]=l,e[39]=u,e[40]=o,e[41]=m,e[42]=r,e[43]=s,e[44]=q):q=e[44];let V;return e[45]!==L||e[46]!==q?(V=(0,t.jsxs)(t.Fragment,{children:[L,q]}),e[45]=L,e[46]=q,e[47]=V):V=e[47],V};function tt(a){let{tooltipContent:e,content:s}=a;return(0,t.jsx)(re,{content:e,delayDuration:100,children:(0,t.jsx)("span",{className:"text-xs text-black bg-gray-100 dark:invert rounded px-1",children:s})})}function fs(a){return a}var G={name:"name",type:"type-value",defs:"defs-refs"},st=[{id:G.name,accessorFn:a=>[a.name,a.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,t.jsx)(ne,{header:"Name",column:a}),cell:({getValue:a})=>{let[e,s]=a();return(0,t.jsx)(Ra,{name:e,declaredBy:s})}},{id:G.type,accessorFn:a=>[a.dataType,a.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,t.jsx)(ne,{header:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{children:"Type"}),(0,t.jsx)("span",{children:"Value"})]}),column:a}),cell:({getValue:a})=>{let[e,s]=a();return(0,t.jsxs)("div",{className:"max-w-[150px]",children:[(0,t.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:e}),(0,t.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:s??"",children:s})]})}},{id:G.defs,accessorFn:a=>[a.declaredBy,a.usedBy,a.name,a.declaredByNames,a.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:a})=>(0,t.jsx)(ne,{header:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{children:"Declared By"}),(0,t.jsx)("span",{children:"Used By"})]}),column:a}),cell:({getValue:a})=>{let[e,s,l]=a(),r=m=>{let n=ta(m);n&&Qe(n,l)};return(0,t.jsxs)("div",{className:"flex flex-col gap-1 py-1",children:[(0,t.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[(0,t.jsx)("span",{title:"Declared by",children:(0,t.jsx)(Ga,{className:"w-3.5 h-3.5 text-muted-foreground"})}),e.length===1?(0,t.jsx)(_e,{variant:"focus",cellId:e[0],skipScroll:!0,onClick:()=>r(e[0])}):(0,t.jsx)("div",{className:"text-destructive flex flex-row gap-2",children:e.slice(0,3).map((m,n)=>(0,t.jsxs)("span",{className:"flex",children:[(0,t.jsx)(_e,{variant:"focus",cellId:m,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(m)},m),n<e.length-1&&", "]},m))})]}),(0,t.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[(0,t.jsx)("span",{title:"Used by",children:(0,t.jsx)(va,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,t.jsx)(Oa,{maxCount:3,cellIds:s,skipScroll:!0,onClick:r})]})]})}}];function lt({variables:a,sort:e,cellIdToIndex:s}){e||(e={id:G.defs,desc:!1});let l=[];switch(e.id){case G.name:l=J(a,r=>r.name);break;case G.type:l=J(a,r=>r.dataType);break;case G.defs:l=J(a,r=>s.get(r.declaredBy[0]));break}return e.desc?l.toReversed():l}const Ve=(0,$.memo)(({className:a,cellIds:e,variables:s})=>{let[l,r]=$.useState([]),[m,n]=$.useState(""),g=He(),{locale:j}=Sa(),N=(0,$.useMemo)(()=>{let c=i=>{let h=g[i];return Je(h)?`cell-${e.indexOf(i)}`:h??`cell-${e.indexOf(i)}`};return Object.values(s).map(i=>({...i,declaredByNames:i.declaredBy.map(c),usedByNames:i.usedBy.map(c)}))},[s,g,e]),u=ia({data:(0,$.useMemo)(()=>{let c=new Map;return e.forEach((i,h)=>c.set(i,h)),lt({variables:N,sort:l[0],cellIdToIndex:c})},[N,l,e]),columns:st,getCoreRowModel:ha(),onGlobalFilterChange:n,getFilteredRowModel:ua(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(c){return c.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:j,onSortingChange:r,getSortedRowModel:da(),state:{sorting:l,globalFilter:m}});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ja,{className:"w-full",placeholder:"Search",value:m,onChange:c=>n(c.target.value)}),(0,t.jsxs)(Ia,{className:O("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,t.jsx)(ka,{children:(0,t.jsx)(ke,{className:"whitespace-nowrap text-xs",children:u.getFlatHeaders().map(c=>(0,t.jsx)(Fa,{className:"sticky top-0 bg-background border-b",children:ve(c.column.columnDef.header,c.getContext())},c.id))})}),(0,t.jsx)($a,{children:u.getRowModel().rows.map(c=>(0,t.jsx)(ke,{className:"hover:bg-accent",children:c.getVisibleCells().map(i=>(0,t.jsx)(Ta,{className:"border-b",children:ve(i.column.columnDef.cell,i.getContext())},i.id))},c.id))})]})]})});Ve.displayName="VariableTable";var nt=ye(),rt=be("marimo:session-panel:state",{openSections:["variables"],hasUserInteracted:!1},pe),ot=()=>{let a=(0,nt.c)(24),e=Ue(),s=ze(),l=K(fe),r=K(qe),[m,n]=he(rt),g=l.length+r.length,j;a[0]!==g||a[1]!==m.hasUserInteracted||a[2]!==m.openSections?(j=!m.hasUserInteracted&&g>0?[...new Set([...m.openSections,"datasources"])]:m.openSections,a[0]=g,a[1]=m.hasUserInteracted,a[2]=m.openSections,a[3]=j):j=a[3];let N=j,u;a[4]===n?u=a[5]:(u=S=>{n({openSections:S,hasUserInteracted:!0})},a[4]=n,a[5]=u);let c=u,i=!N.includes("datasources")&&g>0,h;a[6]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)(le,{className:"w-4 h-4"}),a[6]=h):h=a[6];let p;a[7]!==g||a[8]!==i?(p=i&&(0,t.jsx)(Aa,{children:g}),a[7]=g,a[8]=i,a[9]=p):p=a[9];let d;a[10]===p?d=a[11]:(d=(0,t.jsxs)(Ie,{children:[h,"Data sources",p]}),a[10]=p,a[11]=d);let o;a[12]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(Le,{children:(0,t.jsx)(Ja,{})}),a[12]=o):o=a[12];let b;a[13]===d?b=a[14]:(b=(0,t.jsxs)(Te,{value:"datasources",children:[d,o]}),a[13]=d,a[14]=b);let x;a[15]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsxs)(Ie,{children:[(0,t.jsx)(la,{className:"w-4 h-4"}),"Variables"]}),a[15]=x):x=a[15];let f;a[16]!==s||a[17]!==e?(f=(0,t.jsxs)(Te,{value:"variables",lastItem:!0,children:[x,(0,t.jsx)(Le,{children:Object.keys(e).length===0?(0,t.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No variables defined"}):(0,t.jsx)(Ve,{cellIds:s.inOrderIds,variables:e})})]}),a[16]=s,a[17]=e,a[18]=f):f=a[18];let y;return a[19]!==c||a[20]!==N||a[21]!==b||a[22]!==f?(y=(0,t.jsxs)(ca,{type:"multiple",value:N,onValueChange:c,className:"flex flex-col h-full overflow-auto",children:[b,f]}),a[19]=c,a[20]=N,a[21]=b,a[22]=f,a[23]=y):y=a[23],y};export{ot as default};
|
|
1
|
+
import{s as ie}from"./chunk-LvLJmgfZ.js";import{d as de,l as he,p as ue,u as K}from"./useEvent-D91BmmQi.js";import{t as Pe}from"./react-Bj1aDYRI.js";import{Ar as Me,At as Ee,Br as xe,D as Oe,Fn as pe,Fr as fe,Gt as Re,In as Ue,Ir as Ae,Kt as Ge,Lr as ze,M as We,Nr as se,Oi as be,P as He,Pr as ge,Rn as Ke,Rt as Je,Ur as Xe,Vr as je,Wr as Ne,Wt as Ye,_n as Qe,a as Ze,ar as ea,cr as aa,f as ta,hr as sa,or as la,vr as na,yr as le}from"./cells-vjZ69d-u.js";import"./react-dom-CSu739Rf.js";import{t as ye}from"./compiler-runtime-B3qBwwSJ.js";import{c as ra}from"./utils-CvI-39U6.js";import{t as oa}from"./ErrorBoundary-DyYDV0HI.js";import{t as O}from"./cn-DCUzRj2J.js";import{t as ma}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-DFky0PAA.js";import{n as ca}from"./multi-map-C4OANz8X.js";import"./popover-CNCYAwbC.js";import{G as ne,J as ia,K as ve,X as da,Y as ha,q as ua}from"./JsonOutput-BDXmjEj9.js";import"./download-DyF92TRH.js";import{r as we}from"./radio-group-BI8_7tB1.js";import{t as re}from"./tooltip-B_PkSKN3.js";import{r as xa,t as ee}from"./button-BbCh-29a.js";import"./dist-D0HyMpgV.js";import{u as J}from"./arrays-DYDL-3-i.js";import"./cjs-BRGiG41H.js";import"./main-B0OX4z33.js";import"./useNonce-DfoVjkkH.js";import{i as pa}from"./strings-wdPMRf6Z.js";import{r as fa}from"./requests-DIwGYs0l.js";import{t as ba}from"./createLucideIcon-D5guW7EU.js";import{t as ga}from"./x-C-6liIBr.js";import"./markdown-renderer-DTD6g-4R.js";import{t as Se}from"./add-connection-dialog-T9Z5voxY.js";import{t as Ce}from"./plus-CxkHs8QM.js";import{a as ja}from"./input-Dvl7sgNQ.js";import{n as Na,o as ya}from"./column-preview-CSZ9RgJ8.js";import{t as va}from"./workflow-CgnDnnoN.js";import"./dist-CMvFIVSA.js";import"./dist-cJl5Fok5.js";import"./dist-BFCmbzWi.js";import"./dist-CS6moqWs.js";import"./dist-DTNIEaQR.js";import"./session-DGdfs0bJ.js";import"./purify.es-DvRMX74T.js";import"./dates-DS_7IZoI.js";import{t as wa}from"./copy-icon-c48rtYOO.js";import{t as Sa}from"./context-C1Tm_47t.js";import"./utils-DQRuLEof.js";import"./vega-loader.browser-xq8miGHn.js";import"./defaultLocale-DPBdGRrH.js";import"./defaultLocale-Lfi0pexn.js";import{t as _e}from"./cell-link-CgOvnjYt.js";import"./chunk-5FQGJX7Z-CfK7VoEZ.js";import{r as Ca}from"./html-to-image-2JVKRW1b.js";import{o as _a}from"./focus-D3l6p56g.js";import{n as oe}from"./useAsyncData-Dg8E_bPh.js";import{a as ka,i as Fa,n as $a,o as ke,r as Ta,t as Ia}from"./table-Bgc-inJs.js";import"./react-resizable-panels.browser.esm-BdtIs0E-.js";import{a as La,d as qa,o as ae,t as Da}from"./command-rtnOVF57.js";import{n as Va}from"./icons-8tfAri2V.js";import{a as Ba,r as Pa}from"./tree-actions-ovIJqNLj.js";import{a as me,i as te,o as ce,r as Fe,s as $e,t as Ma}from"./components-1VuqOYTA.js";import{t as Ea}from"./empty-state-Cjt8SfMh.js";import{n as Oa,t as Ra}from"./common-yg4W3pLU.js";import{a as Ua,i as Aa,n as Te,r as Ie,t as Le}from"./components-DRXxpmLU.js";var Ga=ba("square-equal",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]),A=ye(),$=ie(Pe(),1),t=ie(ma(),1),F={engineEmpty:"pl-3",engine:"pl-3 pr-2",database:"pl-4",schemaEmpty:"pl-8",schema:"pl-7",schemaLoading:"pl-8",tableLoading:"pl-11",tableSchemaless:"pl-8",tableWithSchema:"pl-12",columnLocal:"pl-5",columnSql:"pl-13",columnPreview:"pl-10"},za=ue(a=>{let e=a(fe),s=a(Ke),l=a(Ze);return J(e,r=>{if(!r.variable_name)return-1;let m=Object.values(s).find(g=>g.name===r.variable_name);if(!m)return 0;let n=l.inOrderIds.indexOf(m.declaredBy[0]);return n===-1?0:n})});const Wa=be("marimo:datasources:hideEmpty",!1,pe,{getOnInit:!0});function Ha(a){return a.tables_resolved!==!1&&a.tables.length===0}function Ka(a){let e=!1,s=[];for(let l of a){if(l.schemas_resolved!==!1&&l.schemas.length===0){e=!0;continue}if(l.schemas.length===0){s.push(l);continue}let r=l.schemas.filter(m=>!Ha(m));if(r.length===0){e=!0;continue}if(r.length===l.schemas.length){s.push(l);continue}e=!0,s.push({...l,schemas:r})}return e?s:a}const qe=ue(a=>{let e=new Map(a(Me));for(let s of Ne){let l=e.get(s);l&&(l.databases.length===0&&e.delete(s),l.databases.length===1&&l.databases[0].name==="memory"&&l.databases[0].schemas.length===0&&e.delete(s))}return J([...e.values()],s=>Ne.has(s.name)?1:0)}),Ja=()=>{let a=(0,A.c)(42),[e,s]=$.useState(""),[l,r]=he(Wa),m=de(ge),n=K(za),g=K(qe),j;e:{if(!l){j=g;break e}let v,w;a[0]===g?(v=a[1],w=a[2]):(v=!1,w=g.map(k=>{let T=Ka(k.databases);return T===k.databases?k:(v=!0,{...k,databases:T})}),a[0]=g,a[1]=v,a[2]=w),j=v?w:g}let N=j;if(n.length===0&&N.length===0){let v;return a[3]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)(Ea,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:(0,t.jsx)(Se,{children:(0,t.jsxs)(ee,{variant:"outline",size:"sm",children:["Add database or catalog",(0,t.jsx)(Ce,{className:"h-4 w-4 ml-2"})]})}),icon:(0,t.jsx)(le,{})}),a[3]=v):v=a[3],v}let u=!!e.trim(),c;a[4]===m?c=a[5]:(c=v=>{m(v.length>0),s(v)},a[4]=m,a[5]=c);let i;a[6]!==e||a[7]!==c?(i=(0,t.jsx)(La,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:c,rootClassName:"flex-1 border-r border-b-0"}),a[6]=e,a[7]=c,a[8]=i):i=a[8];let h;a[9]===u?h=a[10]:(h=u&&(0,t.jsx)("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:()=>s(""),children:(0,t.jsx)(ga,{className:"h-4 w-4"})}),a[9]=u,a[10]=h);let p=!l,d;a[11]!==l||a[12]!==r?(d=()=>r(!l),a[11]=l,a[12]=r,a[13]=d):d=a[13];let o;a[14]!==p||a[15]!==d?(o=(0,t.jsx)(Ba,{"data-testid":"datasources-hide-empty-button",isVisible:p,onToggle:d,showTooltip:"Show empty schemas and databases",hideTooltip:"Hide empty schemas and databases",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden"}),a[14]=p,a[15]=d,a[16]=o):o=a[16];let b;a[17]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)(Se,{children:(0,t.jsx)(ee,{variant:"ghost",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden",children:(0,t.jsx)(Ce,{className:"h-4 w-4"})})}),a[17]=b):b=a[17];let x;a[18]!==i||a[19]!==h||a[20]!==o?(x=(0,t.jsxs)("div",{className:"flex items-center w-full border-b",children:[i,h,o,b]}),a[18]=i,a[19]=h,a[20]=o,a[21]=x):x=a[21];let f;if(a[22]!==N||a[23]!==u||a[24]!==e){let v;a[26]!==u||a[27]!==e?(v=w=>(0,t.jsx)(Xa,{connection:w,hasChildren:w.databases.length>0,children:w.databases.map(k=>(0,t.jsx)(Ya,{engineName:w.name,database:k,hasSearch:u,children:(0,t.jsx)(Qa,{schemas:k.schemas,defaultSchema:w.default_schema,defaultDatabase:w.default_database,engineName:w.name,databaseName:k.name,hasSearch:u,searchValue:e,dialect:w.dialect})},k.name))},w.name),a[26]=u,a[27]=e,a[28]=v):v=a[28],f=N.map(v),a[22]=N,a[23]=u,a[24]=e,a[25]=f}else f=a[25];let y;a[29]!==N.length||a[30]!==n.length?(y=N.length>0&&n.length>0&&(0,t.jsxs)(Fe,{className:F.engine,children:[(0,t.jsx)(Va,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-xs",children:"Python"})]}),a[29]=N.length,a[30]=n.length,a[31]=y):y=a[31];let S;a[32]!==e||a[33]!==n?(S=n.length>0&&(0,t.jsx)(De,{tables:n,searchValue:e}),a[32]=e,a[33]=n,a[34]=S):S=a[34];let C;a[35]!==y||a[36]!==S||a[37]!==f?(C=(0,t.jsxs)(qa,{className:"flex flex-col",children:[f,y,S]}),a[35]=y,a[36]=S,a[37]=f,a[38]=C):C=a[38];let _;return a[39]!==C||a[40]!==x?(_=(0,t.jsxs)(Da,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden",shouldFilter:!1,children:[x,C]}),a[39]=C,a[40]=x,a[41]=_):_=a[41],_};var Xa=a=>{let e=(0,A.c)(25),{connection:s,children:l,hasChildren:r}=a,m=s.name===Xe,n=m?"In-Memory":s.name,{previewDataSourceConnection:g}=fa(),j;e[0]!==s.name||e[1]!==g?(j=async()=>{await g({engine:s.name})},e[0]=s.name,e[1]=g,e[2]=j):j=e[2];let N=j,u;e[3]===s.dialect?u=e[4]:(u=(0,t.jsx)(Ee,{className:"h-4 w-4 text-muted-foreground",name:s.dialect}),e[3]=s.dialect,e[4]=u);let c;e[5]===s.dialect?c=e[6]:(c=ea(s.dialect),e[5]=s.dialect,e[6]=c);let i;e[7]===c?i=e[8]:(i=(0,t.jsx)("span",{className:"text-xs",children:c}),e[7]=c,e[8]=i);let h=n,p;e[9]===h?p=e[10]:(p=(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(0,t.jsx)(Ua,{variableName:h}),")"]}),e[9]=h,e[10]=p);let d;e[11]!==N||e[12]!==m?(d=!m&&(0,t.jsx)(Pa,{onClick:N,tooltip:"Refresh connection",className:"ml-auto h-4 p-0",iconClassName:"h-3.5 w-3.5"}),e[11]=N,e[12]=m,e[13]=d):d=e[13];let o;e[14]!==u||e[15]!==i||e[16]!==p||e[17]!==d?(o=(0,t.jsxs)(Fe,{className:F.engine,children:[u,i,p,d]}),e[14]=u,e[15]=i,e[16]=p,e[17]=d,e[18]=o):o=e[18];let b;e[19]!==l||e[20]!==r?(b=r?l:(0,t.jsx)(te,{content:"No databases available",className:F.engineEmpty}),e[19]=l,e[20]=r,e[21]=b):b=e[21];let x;return e[22]!==o||e[23]!==b?(x=(0,t.jsxs)(t.Fragment,{children:[o,b]}),e[22]=o,e[23]=b,e[24]=x):x=e[24],x},Ya=a=>{let e=(0,A.c)(26),{hasSearch:s,engineName:l,database:r,children:m}=a,[n,g]=$.useState(!1),[j,N]=$.useState(!1),[u,c]=$.useState(s);u!==s&&(c(s),g(s));let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=O("text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",F.database),e[0]=i):i=e[0];let h;e[1]!==n||e[2]!==j?(h=()=>{g(!n),N(!j)},e[1]=n,e[2]=j,e[3]=h):h=e[3];let p=`${l}:${r.name}`,d;e[4]===n?d=e[5]:(d=(0,t.jsx)($e,{isExpanded:n}),e[4]=n,e[5]=d);let o=j&&n?"text-foreground":"text-muted-foreground",b;e[6]===o?b=e[7]:(b=O("h-4 w-4",o),e[6]=o,e[7]=b);let x;e[8]===b?x=e[9]:(x=(0,t.jsx)(le,{className:b}),e[8]=b,e[9]=x);let f=j&&n&&"font-semibold",y;e[10]===f?y=e[11]:(y=O(f),e[10]=f,e[11]=y);let S;e[12]===r.name?S=e[13]:(S=r.name===""?(0,t.jsx)("i",{children:"Not connected"}):r.name,e[12]=r.name,e[13]=S);let C;e[14]!==S||e[15]!==y?(C=(0,t.jsx)("span",{className:y,children:S}),e[14]=S,e[15]=y,e[16]=C):C=e[16];let _;e[17]!==C||e[18]!==h||e[19]!==p||e[20]!==d||e[21]!==x?(_=(0,t.jsxs)(ae,{className:i,onSelect:h,value:p,children:[d,x,C]}),e[17]=C,e[18]=h,e[19]=p,e[20]=d,e[21]=x,e[22]=_):_=e[22];let v=n&&m,w;return e[23]!==_||e[24]!==v?(w=(0,t.jsxs)(t.Fragment,{children:[_,v]}),e[23]=_,e[24]=v,e[25]=w):w=e[25],w},Qa=({schemas:a,defaultSchema:e,defaultDatabase:s,dialect:l,engineName:r,databaseName:m,hasSearch:n,searchValue:g})=>{let{addSchemaList:j}=se(),[N,u]=$.useState(!1),[c,i]=$.useState(!1),{isPending:h,error:p}=oe(async()=>{if(a.length===0&&r&&!N){u(!0),i(!0);try{j({schemas:(await Ye.request({engine:r,database:m})).schemas??[],sqlSchemaContext:{engine:r,database:m}})}finally{i(!1)}}},[a.length,r,m,N]);return h||c?(0,t.jsx)(ce,{message:"Loading schemas...",className:F.schemaLoading}):p?(0,t.jsx)(me,{error:p,className:F.schemaLoading}):a.length===0?(0,t.jsx)(te,{content:"No schemas available",className:F.schemaEmpty}):(0,t.jsx)(t.Fragment,{children:a.filter(d=>g?d.tables.some(o=>o.name.toLowerCase().includes(g.toLowerCase())):!0).map(d=>(0,t.jsx)(Za,{databaseName:m,schema:d,hasSearch:n,children:(0,t.jsx)(De,{tables:d.tables,searchValue:g,sqlTableContext:{engine:r,database:m,schema:d.name,defaultSchema:e,defaultDatabase:s,dialect:l}})},d.name))})},Za=a=>{let e=(0,A.c)(24),{databaseName:s,schema:l,children:r,hasSearch:m}=a,[n,g]=$.useState(m),[j,N]=$.useState(!1),u=`${s}:${l.name}`;if(xe(l.name))return r;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=O("text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",F.schema),e[0]=c):c=e[0];let i;e[1]!==n||e[2]!==j?(i=()=>{g(!n),N(!j)},e[1]=n,e[2]=j,e[3]=i):i=e[3];let h;e[4]===n?h=e[5]:(h=(0,t.jsx)($e,{isExpanded:n}),e[4]=n,e[5]=h);let p=j&&n&&"text-foreground",d;e[6]===p?d=e[7]:(d=O("h-4 w-4 text-muted-foreground",p),e[6]=p,e[7]=d);let o;e[8]===d?o=e[9]:(o=(0,t.jsx)(sa,{className:d}),e[8]=d,e[9]=o);let b=j&&n&&"font-semibold",x;e[10]===b?x=e[11]:(x=O(b),e[10]=b,e[11]=x);let f;e[12]!==l.name||e[13]!==x?(f=(0,t.jsx)("span",{className:x,children:l.name}),e[12]=l.name,e[13]=x,e[14]=f):f=e[14];let y;e[15]!==i||e[16]!==h||e[17]!==o||e[18]!==f||e[19]!==u?(y=(0,t.jsxs)(ae,{className:c,onSelect:i,value:u,children:[h,o,f]}),e[15]=i,e[16]=h,e[17]=o,e[18]=f,e[19]=u,e[20]=y):y=e[20];let S=n&&r,C;return e[21]!==y||e[22]!==S?(C=(0,t.jsxs)(t.Fragment,{children:[y,S]}),e[21]=y,e[22]=S,e[23]=C):C=e[23],C},De=a=>{let e=(0,A.c)(24),{tables:s,sqlTableContext:l,searchValue:r}=a,{addTableList:m}=se(),[n,g]=$.useState(!1),[j,N]=$.useState(!1),u;e[0]!==m||e[1]!==l||e[2]!==s.length||e[3]!==n?(u=async()=>{if(s.length===0&&l&&!n){g(!0),N(!0);let{engine:o,database:b,schema:x}=l,f=await Ge.request({engine:o,database:b,schema:x});if(!(f!=null&&f.tables))throw N(!1),Error("No tables available");m({tables:f.tables,sqlTableContext:l}),N(!1)}},e[0]=m,e[1]=l,e[2]=s.length,e[3]=n,e[4]=u):u=e[4];let c;e[5]!==l||e[6]!==s.length||e[7]!==n?(c=[s.length,l,n],e[5]=l,e[6]=s.length,e[7]=n,e[8]=c):c=e[8];let{isPending:i,error:h}=oe(u,c);if(i||j){let o;return e[9]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(ce,{message:"Loading tables...",className:F.tableLoading}),e[9]=o):o=e[9],o}if(h){let o;return e[10]===h?o=e[11]:(o=(0,t.jsx)(me,{error:h,className:F.tableLoading}),e[10]=h,e[11]=o),o}if(s.length===0){let o;return e[12]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(te,{content:"No tables found",className:F.tableLoading}),e[12]=o):o=e[12],o}let p;if(e[13]!==r||e[14]!==l||e[15]!==s){let o;e[17]===r?o=e[18]:(o=f=>r?f.name.toLowerCase().includes(r.toLowerCase()):!0,e[17]=r,e[18]=o);let b=s.filter(o),x;e[19]!==r||e[20]!==l?(x=f=>(0,t.jsx)(et,{table:f,sqlTableContext:l,isSearching:!!r},f.name),e[19]=r,e[20]=l,e[21]=x):x=e[21],p=b.map(x),e[13]=r,e[14]=l,e[15]=s,e[16]=p}else p=e[16];let d;return e[22]===p?d=e[23]:(d=(0,t.jsx)(t.Fragment,{children:p}),e[22]=p,e[23]=d),d},et=a=>{let e=(0,A.c)(64),{table:s,sqlTableContext:l,isSearching:r}=a,{addTable:m}=se(),[n,g]=$.useState(!1),[j,N]=$.useState(!1),u=s.columns.length>0,c;e[0]!==m||e[1]!==n||e[2]!==l||e[3]!==s.name||e[4]!==u||e[5]!==j?(c=async()=>{if(n&&!u&&l&&!j){N(!0);let{engine:B,database:Q,schema:Be}=l,Z=await Re.request({engine:B,database:Q,schema:Be,tableName:s.name});if(!(Z!=null&&Z.table))throw Error("No table details available");m({table:Z.table,sqlTableContext:l})}},e[0]=m,e[1]=n,e[2]=l,e[3]=s.name,e[4]=u,e[5]=j,e[6]=c):c=e[6];let i;e[7]!==n||e[8]!==u?(i=[n,u],e[7]=n,e[8]=u,e[9]=i):i=e[9];let{isFetching:h,isPending:p,error:d}=oe(c,i),o=K(ra),b=_a(),{createNewCell:x}=Oe(),f=we(),y;e[10]!==f||e[11]!==o||e[12]!==x||e[13]!==b||e[14]!==l||e[15]!==s?(y=()=>{Ca({autoInstantiate:o,createNewCell:x,fromCellId:b}),f((()=>{if(s.source_type==="catalog"){let B=l!=null&&l.database?`${l.database}.${s.name}`:s.name;return`${s.engine}.load_table("${B}")`}if(l)return je({table:s,columnName:"*",sqlTableContext:l});switch(s.source_type){case"local":return`mo.ui.table(${s.name})`;case"duckdb":case"connection":return je({table:s,columnName:"*",sqlTableContext:l});default:return pa(s.source_type),""}})())},e[10]=f,e[11]=o,e[12]=x,e[13]=b,e[14]=l,e[15]=s,e[16]=y):y=e[16];let S=y,C;e[17]!==s.num_columns||e[18]!==s.num_rows?(C=()=>{let B=[];return s.num_rows!=null&&B.push(`${s.num_rows} rows`),s.num_columns!=null&&B.push(`${s.num_columns} columns`),B.length===0?null:(0,t.jsx)("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:B.join(", ")})})},e[17]=s.num_columns,e[18]=s.num_rows,e[19]=C):C=e[19];let _=C,v;e[20]!==d||e[21]!==h||e[22]!==p||e[23]!==l||e[24]!==s?(v=()=>{if(p||h)return(0,t.jsx)(ce,{message:"Loading columns...",className:F.tableLoading});if(d)return(0,t.jsx)(me,{error:d,className:F.tableLoading});let B=s.columns;return B.length===0?(0,t.jsx)(te,{content:"No columns found",className:F.tableLoading}):B.map(Q=>(0,t.jsx)(at,{table:s,column:Q,sqlTableContext:l},Q.name))},e[20]=d,e[21]=h,e[22]=p,e[23]=l,e[24]=s,e[25]=v):v=e[25];let w=v,k;e[26]!==n||e[27]!==r||e[28]!==s.source_type||e[29]!==s.type?(k=()=>{if(s.source_type!=="local")return(0,t.jsx)(s.type==="table"?aa:na,{className:"h-3 w-3",strokeWidth:n||r?2.5:void 0})},e[26]=n,e[27]=r,e[28]=s.source_type,e[29]=s.type,e[30]=k):k=e[30];let T=k,P=l?`${l.database}.${l.schema}.${s.name}`:s.name,M=l&&(xe(l.schema)?F.tableSchemaless:F.tableWithSchema),E=(n||r)&&"font-semibold",I;e[31]!==M||e[32]!==E?(I=O("rounded-none group h-8 cursor-pointer",M,E),e[31]=M,e[32]=E,e[33]=I):I=e[33];let L;e[34]===n?L=e[35]:(L=()=>g(!n),e[34]=n,e[35]=L);let q;e[36]===T?q=e[37]:(q=T(),e[36]=T,e[37]=q);let V;e[38]===s.name?V=e[39]:(V=(0,t.jsx)("span",{className:"text-sm",children:s.name}),e[38]=s.name,e[39]=V);let R;e[40]!==q||e[41]!==V?(R=(0,t.jsxs)("div",{className:"flex gap-2 items-center flex-1 pl-1",children:[q,V]}),e[40]=q,e[41]=V,e[42]=R):R=e[42];let U;e[43]===_?U=e[44]:(U=_(),e[43]=_,e[44]=U);let D;e[45]===S?D=e[46]:(D=xa.stopPropagation(()=>S()),e[45]=S,e[46]=D);let X;e[47]===Symbol.for("react.memo_cache_sentinel")?(X=(0,t.jsx)(ya,{className:"h-3 w-3"}),e[47]=X):X=e[47];let z;e[48]===D?z=e[49]:(z=(0,t.jsx)(re,{content:"Add table to notebook",delayDuration:400,children:(0,t.jsx)(ee,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:D,children:X})}),e[48]=D,e[49]=z);let W;e[50]!==n||e[51]!==L||e[52]!==R||e[53]!==U||e[54]!==z||e[55]!==I||e[56]!==P?(W=(0,t.jsxs)(ae,{className:I,value:P,"aria-selected":n,forceMount:!0,onSelect:L,children:[R,U,z]}),e[50]=n,e[51]=L,e[52]=R,e[53]=U,e[54]=z,e[55]=I,e[56]=P,e[57]=W):W=e[57];let H;e[58]!==n||e[59]!==w?(H=n&&w(),e[58]=n,e[59]=w,e[60]=H):H=e[60];let Y;return e[61]!==W||e[62]!==H?(Y=(0,t.jsxs)(t.Fragment,{children:[W,H]}),e[61]=W,e[62]=H,e[63]=Y):Y=e[63],Y},at=a=>{var R,U;let e=(0,A.c)(48),{table:s,column:l,sqlTableContext:r}=a,[m,n]=$.useState(!1),g=K(ge),j=de(Ae);g&&m&&n(!1),j(m?D=>new Set([...D,`${s.name}:${l.name}`]):D=>(D.delete(`${s.name}:${l.name}`),new Set(D)));let N=we(),{columnsPreviews:u}=ze(),c;e[0]!==l.name||e[1]!==s.primary_keys?(c=((R=s.primary_keys)==null?void 0:R.includes(l.name))||!1,e[0]=l.name,e[1]=s.primary_keys,e[2]=c):c=e[2];let i=c,h;e[3]!==l.name||e[4]!==s.indexes?(h=((U=s.indexes)==null?void 0:U.includes(l.name))||!1,e[3]=l.name,e[4]=s.indexes,e[5]=h):h=e[5];let p=h,d;e[6]===N?d=e[7]:(d=D=>{N(D)},e[6]=N,e[7]=d);let o=d,b=tt,x=m?"font-semibold":"",f;e[8]!==l.name||e[9]!==x?(f=(0,t.jsx)("span",{className:x,children:l.name}),e[8]=l.name,e[9]=x,e[10]=f):f=e[10];let y=f,S=`${s.name}.${l.name}`,C=`${s.name}.${l.name}`,_;e[11]===m?_=e[12]:(_=()=>n(!m),e[11]=m,e[12]=_);let v=r?F.columnSql:F.columnLocal,w;e[13]===v?w=e[14]:(w=O("flex flex-row gap-2 items-center flex-1",v),e[13]=v,e[14]=w);let k;e[15]!==l.type||e[16]!==y?(k=(0,t.jsx)(Ma,{columnName:y,dataType:l.type}),e[15]=l.type,e[16]=y,e[17]=k):k=e[17];let T;e[18]===i?T=e[19]:(T=i&&b({tooltipContent:"Primary key",content:"PK"}),e[18]=i,e[19]=T);let P;e[20]===p?P=e[21]:(P=p&&b({tooltipContent:"Indexed",content:"IDX"}),e[20]=p,e[21]=P);let M;e[22]!==w||e[23]!==k||e[24]!==T||e[25]!==P?(M=(0,t.jsxs)("div",{className:w,children:[k,T,P]}),e[22]=w,e[23]=k,e[24]=T,e[25]=P,e[26]=M):M=e[26];let E;e[27]===l.name?E=e[28]:(E=(0,t.jsx)(re,{content:"Copy column name",delayDuration:400,children:(0,t.jsx)(ee,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:(0,t.jsx)(wa,{tooltip:!1,value:l.name,className:"h-3 w-3"})})}),e[27]=l.name,e[28]=E);let I;e[29]===l.external_type?I=e[30]:(I=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l.external_type}),e[29]=l.external_type,e[30]=I);let L;e[31]!==M||e[32]!==E||e[33]!==I||e[34]!==S||e[35]!==C||e[36]!==_?(L=(0,t.jsxs)(ae,{className:"rounded-none py-1 group cursor-pointer",value:C,onSelect:_,children:[M,E,I]},S),e[31]=M,e[32]=E,e[33]=I,e[34]=S,e[35]=C,e[36]=_,e[37]=L):L=e[37];let q;e[38]!==l||e[39]!==u||e[40]!==o||e[41]!==m||e[42]!==r||e[43]!==s?(q=m&&(0,t.jsx)("div",{className:O(F.columnPreview,"pr-2 py-2 bg-(--slate-1) shadow-inner border-b"),children:(0,t.jsx)(oa,{children:(0,t.jsx)(Na,{table:s,column:l,onAddColumnChart:o,preview:u.get(r?`${r.database}.${r.schema}.${s.name}:${l.name}`:`${s.name}:${l.name}`),sqlTableContext:r})})}),e[38]=l,e[39]=u,e[40]=o,e[41]=m,e[42]=r,e[43]=s,e[44]=q):q=e[44];let V;return e[45]!==L||e[46]!==q?(V=(0,t.jsxs)(t.Fragment,{children:[L,q]}),e[45]=L,e[46]=q,e[47]=V):V=e[47],V};function tt(a){let{tooltipContent:e,content:s}=a;return(0,t.jsx)(re,{content:e,delayDuration:100,children:(0,t.jsx)("span",{className:"text-xs text-black bg-gray-100 dark:invert rounded px-1",children:s})})}function fs(a){return a}var G={name:"name",type:"type-value",defs:"defs-refs"},st=[{id:G.name,accessorFn:a=>[a.name,a.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,t.jsx)(ne,{header:"Name",column:a}),cell:({getValue:a})=>{let[e,s]=a();return(0,t.jsx)(Ra,{name:e,declaredBy:s})}},{id:G.type,accessorFn:a=>[a.dataType,a.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,t.jsx)(ne,{header:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{children:"Type"}),(0,t.jsx)("span",{children:"Value"})]}),column:a}),cell:({getValue:a})=>{let[e,s]=a();return(0,t.jsxs)("div",{className:"max-w-[150px]",children:[(0,t.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:e}),(0,t.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:s??"",children:s})]})}},{id:G.defs,accessorFn:a=>[a.declaredBy,a.usedBy,a.name,a.declaredByNames,a.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:a})=>(0,t.jsx)(ne,{header:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{children:"Declared By"}),(0,t.jsx)("span",{children:"Used By"})]}),column:a}),cell:({getValue:a})=>{let[e,s,l]=a(),r=m=>{let n=ta(m);n&&Qe(n,l)};return(0,t.jsxs)("div",{className:"flex flex-col gap-1 py-1",children:[(0,t.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[(0,t.jsx)("span",{title:"Declared by",children:(0,t.jsx)(Ga,{className:"w-3.5 h-3.5 text-muted-foreground"})}),e.length===1?(0,t.jsx)(_e,{variant:"focus",cellId:e[0],skipScroll:!0,onClick:()=>r(e[0])}):(0,t.jsx)("div",{className:"text-destructive flex flex-row gap-2",children:e.slice(0,3).map((m,n)=>(0,t.jsxs)("span",{className:"flex",children:[(0,t.jsx)(_e,{variant:"focus",cellId:m,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(m)},m),n<e.length-1&&", "]},m))})]}),(0,t.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[(0,t.jsx)("span",{title:"Used by",children:(0,t.jsx)(va,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,t.jsx)(Oa,{maxCount:3,cellIds:s,skipScroll:!0,onClick:r})]})]})}}];function lt({variables:a,sort:e,cellIdToIndex:s}){e||(e={id:G.defs,desc:!1});let l=[];switch(e.id){case G.name:l=J(a,r=>r.name);break;case G.type:l=J(a,r=>r.dataType);break;case G.defs:l=J(a,r=>s.get(r.declaredBy[0]));break}return e.desc?l.toReversed():l}const Ve=(0,$.memo)(({className:a,cellIds:e,variables:s})=>{let[l,r]=$.useState([]),[m,n]=$.useState(""),g=He(),{locale:j}=Sa(),N=(0,$.useMemo)(()=>{let c=i=>{let h=g[i];return Je(h)?`cell-${e.indexOf(i)}`:h??`cell-${e.indexOf(i)}`};return Object.values(s).map(i=>({...i,declaredByNames:i.declaredBy.map(c),usedByNames:i.usedBy.map(c)}))},[s,g,e]),u=ua({data:(0,$.useMemo)(()=>{let c=new Map;return e.forEach((i,h)=>c.set(i,h)),lt({variables:N,sort:l[0],cellIdToIndex:c})},[N,l,e]),columns:st,getCoreRowModel:ia(),onGlobalFilterChange:n,getFilteredRowModel:ha(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(c){return c.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:j,onSortingChange:r,getSortedRowModel:da(),state:{sorting:l,globalFilter:m}});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ja,{className:"w-full",placeholder:"Search",value:m,onChange:c=>n(c.target.value)}),(0,t.jsxs)(Ia,{className:O("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,t.jsx)(ka,{children:(0,t.jsx)(ke,{className:"whitespace-nowrap text-xs",children:u.getFlatHeaders().map(c=>(0,t.jsx)(Fa,{className:"sticky top-0 bg-background border-b",children:ve(c.column.columnDef.header,c.getContext())},c.id))})}),(0,t.jsx)($a,{children:u.getRowModel().rows.map(c=>(0,t.jsx)(ke,{className:"hover:bg-accent",children:c.getVisibleCells().map(i=>(0,t.jsx)(Ta,{className:"border-b",children:ve(i.column.columnDef.cell,i.getContext())},i.id))},c.id))})]})]})});Ve.displayName="VariableTable";var nt=ye(),rt=be("marimo:session-panel:state",{openSections:["variables"],hasUserInteracted:!1},pe),ot=()=>{let a=(0,nt.c)(24),e=Ue(),s=We(),l=K(fe),r=K(qe),[m,n]=he(rt),g=l.length+r.length,j;a[0]!==g||a[1]!==m.hasUserInteracted||a[2]!==m.openSections?(j=!m.hasUserInteracted&&g>0?[...new Set([...m.openSections,"datasources"])]:m.openSections,a[0]=g,a[1]=m.hasUserInteracted,a[2]=m.openSections,a[3]=j):j=a[3];let N=j,u;a[4]===n?u=a[5]:(u=S=>{n({openSections:S,hasUserInteracted:!0})},a[4]=n,a[5]=u);let c=u,i=!N.includes("datasources")&&g>0,h;a[6]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)(le,{className:"w-4 h-4"}),a[6]=h):h=a[6];let p;a[7]!==g||a[8]!==i?(p=i&&(0,t.jsx)(Aa,{children:g}),a[7]=g,a[8]=i,a[9]=p):p=a[9];let d;a[10]===p?d=a[11]:(d=(0,t.jsxs)(Ie,{children:[h,"Data sources",p]}),a[10]=p,a[11]=d);let o;a[12]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(Le,{children:(0,t.jsx)(Ja,{})}),a[12]=o):o=a[12];let b;a[13]===d?b=a[14]:(b=(0,t.jsxs)(Te,{value:"datasources",children:[d,o]}),a[13]=d,a[14]=b);let x;a[15]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsxs)(Ie,{children:[(0,t.jsx)(la,{className:"w-4 h-4"}),"Variables"]}),a[15]=x):x=a[15];let f;a[16]!==s||a[17]!==e?(f=(0,t.jsxs)(Te,{value:"variables",lastItem:!0,children:[x,(0,t.jsx)(Le,{children:Object.keys(e).length===0?(0,t.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No variables defined"}):(0,t.jsx)(Ve,{cellIds:s.inOrderIds,variables:e})})]}),a[16]=s,a[17]=e,a[18]=f):f=a[18];let y;return a[19]!==c||a[20]!==N||a[21]!==b||a[22]!==f?(y=(0,t.jsxs)(ca,{type:"multiple",value:N,onValueChange:c,className:"flex flex-col h-full overflow-auto",children:[b,f]}),a[19]=c,a[20]=N,a[21]=b,a[22]=f,a[23]=y):y=a[23],y};export{ot as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as ve}from"./chunk-LvLJmgfZ.js";import{d as L,l as at,p as ot,u as Z}from"./useEvent-D91BmmQi.js";import{t as nt}from"./react-Bj1aDYRI.js";import{D as Ce,Dn as it,Dr as st,E as lt,Ii as me,Mn as rt,On as dt,Sr as ct,Yr as ht,Zt as pt,_ as mt,_r as ut,ct as ft,h as ze,kn as bt,st as yt,t as kt,ut as We,yr as xt}from"./cells-vjZ69d-u.js";import{t as P}from"./compiler-runtime-B3qBwwSJ.js";import{n as wt,x as gt}from"./ai-model-dropdown-B0cy2CXL.js";import{_ as T,d as Me}from"./useEventListener-DvoEXWke.js";import{x as jt}from"./utils-CvI-39U6.js";import{n as C,t as De}from"./constants-DMpttj8Q.js";import{T as Q,v as vt,w as Ct}from"./config-DH1Le_e1.js";import{t as zt}from"./jsx-runtime-BqBOg78p.js";import{o as Wt}from"./alert-dialog-5BGIfskO.js";import{a as Mt,c as Dt,i as _t,n as St,r as At,s as Pt,t as Nt}from"./select-6suE6YM2.js";import{wt as It}from"./JsonOutput-BYEhZqb8.js";import{c as _e,d as ue,n as Et,o as Lt,r as fe,t as Tt}from"./download-DyF92TRH.js";import{t as Ht}from"./tooltip-B_PkSKN3.js";import{r as Rt,t as be}from"./button-BbCh-29a.js";import{i as Ft,t as Se}from"./strings-wdPMRf6Z.js";import{r as H}from"./requests-DIwGYs0l.js";import{t as h}from"./createLucideIcon-D5guW7EU.js";import{F as Ot,I as qt,L as Ae,P as Yt,R as Bt,a as Pe,i as Ne,u as Ie}from"./layout-BI8kBq9L.js";import{t as Ee}from"./check-BH35Ndha.js";import{r as Vt}from"./useCellActionButton-CpShaxQ-.js";import{t as $t}from"./copy-BwrPA9zQ.js";import{t as Kt}from"./external-link-BTNxSavU.js";import{t as Ut}from"./eye-off-BT-KOYV5.js";import{t as X}from"./file-HTLbeC2b.js";import{t as Gt}from"./github-raQvpeuZ.js";import{u as Jt}from"./form-B_6lxOn3.js";import{n as Zt,r as Qt,t as Xt}from"./youtube-3lRHw8NU.js";import{i as ea,n as Le}from"./add-connection-dialog-BGaI0GCh.js";import{t as ta}from"./house-D2ldnAB9.js";import{t as aa}from"./image-BIibSXT6.js";import{t as oa}from"./link-CoJxTwWE.js";import{r as na}from"./input-Dvl7sgNQ.js";import{t as ia}from"./settings-SnYErNWQ.js";import{t as sa}from"./sparkles-CC9Bko6a.js";import{y as la}from"./textarea-ibvi1Qnd.js";import{t as ra}from"./square-rACnnz-q.js";import{t as z}from"./use-toast-9t59MOqR.js";import{n as Te,t as da}from"./paths-SFhaqGlE.js";import{o as ca}from"./session-DGdfs0bJ.js";import{n as ee}from"./copy-Ch48HVPK.js";import{r as ha}from"./useRunCells-DELfNFG_.js";import{a as pa,c as ma,i as ua,n as fa,r as ba}from"./dialog-QgtiqcL7.js";import{n as ye}from"./ImperativeModal-CYpBrCHJ.js";import{r as ya,t as He}from"./share-DQLjaPiK.js";import{a as ka}from"./cell-link-CgOvnjYt.js";import{a as xa}from"./renderShortcut-DbyG33_r.js";import{t as wa}from"./icons-8tfAri2V.js";import{t as ga}from"./pair-with-agent-modal-DQuvaMjY.js";import{n as Re}from"./marimo-icons-CiwvnnsT.js";import{t as ja}from"./links-C6riF5tE.js";import{r as va,t as Fe}from"./hooks-L9VY624Y.js";import{t as Oe}from"./types-a-yURniQ.js";var Ca=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),za=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),qe=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Ye=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"}]]),Be=h("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),Wa=h("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),Ma=h("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),Da=h("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),_a=h("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),Sa=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ve=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"}]]),Aa=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"}]]),Pa=h("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),$e=h("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),Ke=P(),ke=ve(nt(),1),a=ve(zt(),1),te="https://static.marimo.app";const Na=e=>{let t=(0,Ke.c)(25),{onClose:n}=e,[o,s]=(0,ke.useState)(""),{exportAsHTML:r}=H(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${te}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let I=await r({download:!1,includeCode:!0,files:Yt.INSTANCE.filenames()}),W=z({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${te}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:I,path:l})}).catch(()=>{W.dismiss(),z({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:C.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),W.dismiss(),z({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=l,t[3]=d):d=t[3];let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(ma,{children:"Share static notebook"}),t[4]=m):m=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(pa,{children:[m,(0,a.jsxs)(ba,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:te,target:"_blank",children:te}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(na,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Ia,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let b;t[11]!==u||t[12]!==f?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=b):b=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(be,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let k;t[16]===i?k=t[17]:(k=(0,a.jsx)(be,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await ee(i)},children:"Create"}),t[16]=i,t[17]=k);let x;t[18]!==y||t[19]!==k?(x=(0,a.jsxs)(ua,{children:[y,k]}),t[18]=y,t[19]=k,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==b?(j=(0,a.jsx)(fa,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,b,x]})}),t[21]=d,t[22]=x,t[23]=b,t[24]=j):j=t[24],j};var Ia=e=>{let t=(0,Ke.c)(8),[n,o]=ke.useState(!1),s;t[0]===e.text?s=t[1]:(s=Rt.stopPropagation(async m=>{m.preventDefault(),await ee(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)($t,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(be,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Ht,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},Ea=P();function La(){let e=document.getElementsByClassName(De.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=me.findElement(t);if(!o){T.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:me.parse(o.id)}}}return T.warn("No visible output area found for scroll anchor"),null}function Ta(e){if(!e){T.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(me.create(e.cellId));if(!t){T.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${De.outputArea}`)){T.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ue(){let e=(0,Ea.c)(2),t=L(We),n;return e[0]===t?n=e[1]:(n=()=>{let o=La();t(s=>({mode:ft(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Ta(o)})})},e[0]=t,e[1]=n),n}const Ge=ot(!1);var Ha=P();const Ra=()=>{let e=(0,Ha.c)(7),{selectedLayout:t}=Pe(),{setLayoutView:n}=Ne();if(Q()&&!rt("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Pt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Dt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(St,{children:(0,a.jsxs)(At,{children:[(0,a.jsx)(Mt,{children:"View as"}),Oe.map(Oa)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Nt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Fa(e){return(0,a.jsx)(Je(e),{className:"h-4 w-4"})}function Je(e){switch(e){case"vertical":return Da;case"grid":return Qt;case"slides":return Ve;default:return Ft(e),ra}}function Ze(e){return Se.startCase(e)}function Oa(e){return(0,a.jsx)(_t,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Fa(e),(0,a.jsx)("span",{children:Ze(e)})]})},e)}async function qa(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ya=P();function Ba(e){let t=(0,Ya.c)(5),{openPrompt:n,closeModal:o}=ye(),{sendCopy:s}=H(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=da.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Te.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(Te.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),z({title:"Notebook copied",description:"A copy of the notebook has been created."}),ja(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Va=()=>{let{updateCellConfig:e}=Ce(),{saveCellConfig:t}=H();return(0,ke.useCallback)(async()=>{let n=new pt,o=ze(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:d,config:m}=o.cellData[i];m.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let l=Me.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var $a=P();function Qe(){let e=(0,$a.c)(4),{openConfirm:t}=ye(),n=L(vt),{sendRestart:o}=H(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(Wt,{onClick:async()=>{n({state:Ct.CLOSING}),await o(),ya()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Ka=P(),N=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Ua(){var we,ge,je;let e=(0,Ka.c)(53),t=ka(),{openModal:n,closeModal:o}=ye(),{toggleApplication:s}=it(),{selectedPanel:r}=dt(),[l]=at(We),i=Z(yt),d=Va(),[m]=jt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:b,expandAllCells:y}=Ce(),k=Qe(),x=ha(),j=Ba(t),v=L(Ge),I=L(wt),W=L(gt),{exportAsIPYNB:oe,exportAsMarkdown:ne,readCode:M,saveCellConfig:ie,updateCellOutputs:D}=H(),_=va(),se=Z(mt),le=Z(kt),re=Z(lt),{selectedLayout:R}=Pe(),{setLayoutView:de}=Ne(),F=Ue(),O=((we=m.sharing)==null?void 0:we.html)??!0,q=((ge=m.sharing)==null?void 0:ge.wasm)??!0,Y=((je=m.sharing)==null?void 0:je.molab)??!0,xe=!Q(),ce=R==="slides",Xe=mo,et=po,B;e[0]!==t||e[1]!==_||e[2]!==D?(B=async c=>{let{preset:p,title:E}=c;if(!t){ae();return}await _e(E,async pe=>{await Fe({takeScreenshots:()=>_({progress:pe}),updateCellOutputs:D}),await qa({filename:t,preset:p,downloadPDF:Et})})},e[0]=t,e[1]=_,e[2]=D,e[3]=B):B=e[3];let S=B,V;e[4]===S?V=e[5]:(V=async()=>{if(xe){await S({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),p=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(ho,0),setTimeout(()=>window.dispatchEvent(p),0)},e[4]=S,e[5]=V);let $=V,K;e[6]!==oe||e[7]!==t||e[8]!==_||e[9]!==D?(K=async()=>{if(!t){ae();return}await _e("Downloading IPYNB...",async c=>{await Fe({takeScreenshots:()=>_({progress:c}),updateCellOutputs:D});let p=await oe({download:!1});fe(new Blob([p],{type:"application/x-ipynb+json"}),ue.toIPYNB(document.title))})},e[6]=oe,e[7]=t,e[8]=_,e[9]=D,e[10]=K):K=e[10];let he=K,U;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(It,{size:14,strokeWidth:1.5}),e[11]=U):U=e[11];let G;e[12]===Symbol.for("react.memo_cache_sentinel")?(G=(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),e[12]=G):G=e[12];let A;e[13]===t?A=e[14]:(A=async()=>{if(!t){ae();return}await Ie({filename:t,includeCode:!0})},e[13]=t,e[14]=A);let J;return e[15]!==f||e[16]!==le||e[17]!==u||e[18]!==o||e[19]!==b||e[20]!==j||e[21]!==S||e[22]!==y||e[23]!==ne||e[24]!==t||e[25]!==$||e[26]!==he||e[27]!==se||e[28]!==d||e[29]!==ce||e[30]!==i||e[31]!==n||e[32]!==M||e[33]!==k||e[34]!==x||e[35]!==ie||e[36]!==R||e[37]!==r||e[38]!==v||e[39]!==W||e[40]!==de||e[41]!==I||e[42]!==O||e[43]!==Y||e[44]!==q||e[45]!==A||e[46]!==s||e[47]!==F||e[48]!==g||e[49]!==re||e[50]!==w||e[51]!==l.mode?(J=[{icon:U,label:"Download",handle:N,dropdown:[{icon:G,label:"Download as HTML",handle:A},{icon:(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ae();return}await Ie({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(wa,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await ne({download:!1});fe(new Blob([c],{type:"text/plain"}),ue.toMarkdown(document.title))}},{icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:he},{icon:(0,a.jsx)(Bt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await M();fe(new Blob([c.contents],{type:"text/plain"}),ue.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",xa("global.hideCode",!1)]}),handle:co},ce?{divider:!0,icon:(0,a.jsx)(X,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:N,dropdown:[{icon:(0,a.jsx)(X,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:$},{icon:(0,a.jsx)(X,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:et(!0),hidden:!xe,handle:async()=>{await S({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(X,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:$}]},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:Q(),handle:async()=>{n((0,a.jsx)(ga,{onClose:o}))}},{icon:(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),label:"Share",handle:N,hidden:!O&&!q&&!Y,dropdown:[{icon:(0,a.jsx)(Jt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!O,handle:async()=>{n((0,a.jsx)(Na,{onClose:o}))}},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!q,handle:async()=>{await ee(He({code:(await M()).contents})),z({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!Y,handle:async()=>{let c=He({code:(await M()).contents,baseUrl:`${C.molab}/new`});window.open(c,"_blank")}}]},{icon:(0,a.jsx)(Sa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:N,dropdown:bt.flatMap(c=>{let{type:p,Icon:E,hidden:pe,additionalKeywords:tt}=c;return pe?[]:{label:Se.startCase(p),rightElement:Xe(r===p),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),handle:()=>s(p),additionalKeywords:tt}})},{icon:(0,a.jsx)(Ve,{size:14,strokeWidth:1.5}),label:"Present as",handle:N,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(la,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{F()}},...Oe.map((c,p)=>{let E=Je(c);return{divider:p===0,label:Ze(c),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:R===c&&(0,a.jsx)(Ee,{size:14})}),handle:()=>{de(c),l.mode==="edit"&&F()}}})]},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||Q(),handle:j},{icon:(0,a.jsx)(qe,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ee((await M()).contents),z({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!se||i,handle:async()=>{let c=ht(ze());await ie({configs:Me.fromEntries(c.map(ro))});for(let p of c)w({cellId:p,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(xt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Le,{onClose:o}))}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Le,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:re,hidden:!le||i,handle:()=>{g()}},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:k,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Wa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(ct,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Ut,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:b,redundant:!0},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(lo)},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>W(so)},{icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>I(io),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(Kt,{size:14,strokeWidth:1.5}),label:"Resources",handle:N,dropdown:[{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Documentation",handle:no},{icon:(0,a.jsx)(Gt,{size:14,strokeWidth:1.5}),label:"GitHub",handle:oo},{icon:(0,a.jsx)(Zt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:ao},{icon:(0,a.jsx)(Xt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:to},{icon:(0,a.jsx)(ut,{size:14,strokeWidth:1.5}),label:"Changelog",handle:eo}]},{divider:!0,icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Xa},{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Qa}].filter(Za).map(Ga),e[15]=f,e[16]=le,e[17]=u,e[18]=o,e[19]=b,e[20]=j,e[21]=S,e[22]=y,e[23]=ne,e[24]=t,e[25]=$,e[26]=he,e[27]=se,e[28]=d,e[29]=ce,e[30]=i,e[31]=n,e[32]=M,e[33]=k,e[34]=x,e[35]=ie,e[36]=R,e[37]=r,e[38]=v,e[39]=W,e[40]=de,e[41]=I,e[42]=O,e[43]=Y,e[44]=q,e[45]=A,e[46]=s,e[47]=F,e[48]=g,e[49]=re,e[50]=w,e[51]=l.mode,e[52]=J):J=e[52],J}function Ga(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Ja)}:e}function Ja(e){return!e.hidden}function Za(e){return!e.hidden}function Qa(){let e=ca();window.open(e,"_blank")}function Xa(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function eo(){window.open(C.releasesPage,"_blank")}function to(){window.open(C.youtube,"_blank")}function ao(){window.open(C.discordLink,"_blank")}function oo(){window.open(C.githubPage,"_blank")}function no(){window.open(C.docsPage,"_blank")}function io(e){return!e}function so(e){return!e}function lo(e){return!e}function ro(e){return[e,{disabled:!1}]}async function co(){let e=document.getElementById("App");e&&await Lt({element:e,filename:document.title,prepare:Tt})}function ho(){return window.print()}function po(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function mo(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Ee,{size:14})})}function ae(){z({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Ue as a,Ye as c,Ge as i,qe as l,Qe as n,$e as o,Ra as r,Be as s,Ua as t};
|
|
1
|
+
import{s as ve}from"./chunk-LvLJmgfZ.js";import{d as L,l as at,p as ot,u as Z}from"./useEvent-D91BmmQi.js";import{t as nt}from"./react-Bj1aDYRI.js";import{D as Ce,Dn as it,Dr as st,E as lt,Ii as me,Mn as rt,On as dt,Sr as ct,Yr as ht,Zt as pt,_ as mt,_r as ut,ct as ft,h as ze,kn as bt,st as yt,t as kt,ut as We,yr as xt}from"./cells-vjZ69d-u.js";import{t as P}from"./compiler-runtime-B3qBwwSJ.js";import{n as wt,x as gt}from"./ai-model-dropdown-B0cy2CXL.js";import{_ as T,d as Me}from"./useEventListener-DvoEXWke.js";import{x as jt}from"./utils-CvI-39U6.js";import{n as C,t as De}from"./constants-DMpttj8Q.js";import{T as Q,v as vt,w as Ct}from"./config-DH1Le_e1.js";import{t as zt}from"./jsx-runtime-BqBOg78p.js";import{o as Wt}from"./alert-dialog-5BGIfskO.js";import{a as Mt,c as Dt,i as _t,n as St,r as At,s as Pt,t as Nt}from"./select-6suE6YM2.js";import{Et as It}from"./JsonOutput-BDXmjEj9.js";import{c as _e,d as ue,n as Et,o as Lt,r as fe,t as Tt}from"./download-DyF92TRH.js";import{t as Ht}from"./tooltip-B_PkSKN3.js";import{r as Rt,t as be}from"./button-BbCh-29a.js";import{i as Ft,t as Se}from"./strings-wdPMRf6Z.js";import{r as H}from"./requests-DIwGYs0l.js";import{t as h}from"./createLucideIcon-D5guW7EU.js";import{F as Ot,I as qt,L as Ae,P as Yt,R as Bt,a as Pe,i as Ne,u as Ie}from"./layout-B5MRVsVq.js";import{t as Ee}from"./check-BH35Ndha.js";import{r as Vt}from"./useCellActionButton-CpShaxQ-.js";import{t as $t}from"./copy-BwrPA9zQ.js";import{t as Kt}from"./external-link-BTNxSavU.js";import{t as Ut}from"./eye-off-BT-KOYV5.js";import{t as X}from"./file-HTLbeC2b.js";import{t as Gt}from"./github-raQvpeuZ.js";import{u as Jt}from"./form-DKdvoZxk.js";import{n as Zt,r as Qt,t as Xt}from"./youtube-3lRHw8NU.js";import{i as ea,n as Le}from"./add-connection-dialog-T9Z5voxY.js";import{t as ta}from"./house-D2ldnAB9.js";import{t as aa}from"./image-BIibSXT6.js";import{t as oa}from"./link-CoJxTwWE.js";import{r as na}from"./input-Dvl7sgNQ.js";import{t as ia}from"./settings-SnYErNWQ.js";import{t as sa}from"./sparkles-CC9Bko6a.js";import{y as la}from"./textarea-ibvi1Qnd.js";import{t as ra}from"./square-rACnnz-q.js";import{t as z}from"./use-toast-9t59MOqR.js";import{n as Te,t as da}from"./paths-SFhaqGlE.js";import{o as ca}from"./session-DGdfs0bJ.js";import{n as ee}from"./copy-Ch48HVPK.js";import{r as ha}from"./useRunCells-DELfNFG_.js";import{a as pa,c as ma,i as ua,n as fa,r as ba}from"./dialog-QgtiqcL7.js";import{n as ye}from"./ImperativeModal-CYpBrCHJ.js";import{r as ya,t as He}from"./share-DQLjaPiK.js";import{a as ka}from"./cell-link-CgOvnjYt.js";import{a as xa}from"./renderShortcut-DbyG33_r.js";import{t as wa}from"./icons-8tfAri2V.js";import{t as ga}from"./pair-with-agent-modal-DQuvaMjY.js";import{n as Re}from"./marimo-icons-CiwvnnsT.js";import{t as ja}from"./links-C6riF5tE.js";import{r as va,t as Fe}from"./hooks-BKLlyDAs.js";import{t as Oe}from"./types-a-yURniQ.js";var Ca=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),za=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),qe=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Ye=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"}]]),Be=h("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),Wa=h("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),Ma=h("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),Da=h("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),_a=h("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),Sa=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ve=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"}]]),Aa=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"}]]),Pa=h("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),$e=h("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),Ke=P(),ke=ve(nt(),1),a=ve(zt(),1),te="https://static.marimo.app";const Na=e=>{let t=(0,Ke.c)(25),{onClose:n}=e,[o,s]=(0,ke.useState)(""),{exportAsHTML:r}=H(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${te}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let I=await r({download:!1,includeCode:!0,files:Yt.INSTANCE.filenames()}),W=z({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${te}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:I,path:l})}).catch(()=>{W.dismiss(),z({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:C.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),W.dismiss(),z({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=l,t[3]=d):d=t[3];let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(ma,{children:"Share static notebook"}),t[4]=m):m=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(pa,{children:[m,(0,a.jsxs)(ba,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:te,target:"_blank",children:te}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(na,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Ia,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let b;t[11]!==u||t[12]!==f?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=b):b=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(be,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let k;t[16]===i?k=t[17]:(k=(0,a.jsx)(be,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await ee(i)},children:"Create"}),t[16]=i,t[17]=k);let x;t[18]!==y||t[19]!==k?(x=(0,a.jsxs)(ua,{children:[y,k]}),t[18]=y,t[19]=k,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==b?(j=(0,a.jsx)(fa,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,b,x]})}),t[21]=d,t[22]=x,t[23]=b,t[24]=j):j=t[24],j};var Ia=e=>{let t=(0,Ke.c)(8),[n,o]=ke.useState(!1),s;t[0]===e.text?s=t[1]:(s=Rt.stopPropagation(async m=>{m.preventDefault(),await ee(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)($t,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(be,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Ht,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},Ea=P();function La(){let e=document.getElementsByClassName(De.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=me.findElement(t);if(!o){T.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:me.parse(o.id)}}}return T.warn("No visible output area found for scroll anchor"),null}function Ta(e){if(!e){T.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(me.create(e.cellId));if(!t){T.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${De.outputArea}`)){T.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ue(){let e=(0,Ea.c)(2),t=L(We),n;return e[0]===t?n=e[1]:(n=()=>{let o=La();t(s=>({mode:ft(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Ta(o)})})},e[0]=t,e[1]=n),n}const Ge=ot(!1);var Ha=P();const Ra=()=>{let e=(0,Ha.c)(7),{selectedLayout:t}=Pe(),{setLayoutView:n}=Ne();if(Q()&&!rt("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Pt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Dt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(St,{children:(0,a.jsxs)(At,{children:[(0,a.jsx)(Mt,{children:"View as"}),Oe.map(Oa)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Nt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Fa(e){return(0,a.jsx)(Je(e),{className:"h-4 w-4"})}function Je(e){switch(e){case"vertical":return Da;case"grid":return Qt;case"slides":return Ve;default:return Ft(e),ra}}function Ze(e){return Se.startCase(e)}function Oa(e){return(0,a.jsx)(_t,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Fa(e),(0,a.jsx)("span",{children:Ze(e)})]})},e)}async function qa(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ya=P();function Ba(e){let t=(0,Ya.c)(5),{openPrompt:n,closeModal:o}=ye(),{sendCopy:s}=H(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=da.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Te.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(Te.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),z({title:"Notebook copied",description:"A copy of the notebook has been created."}),ja(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Va=()=>{let{updateCellConfig:e}=Ce(),{saveCellConfig:t}=H();return(0,ke.useCallback)(async()=>{let n=new pt,o=ze(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:d,config:m}=o.cellData[i];m.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let l=Me.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var $a=P();function Qe(){let e=(0,$a.c)(4),{openConfirm:t}=ye(),n=L(vt),{sendRestart:o}=H(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(Wt,{onClick:async()=>{n({state:Ct.CLOSING}),await o(),ya()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Ka=P(),N=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Ua(){var we,ge,je;let e=(0,Ka.c)(53),t=ka(),{openModal:n,closeModal:o}=ye(),{toggleApplication:s}=it(),{selectedPanel:r}=dt(),[l]=at(We),i=Z(yt),d=Va(),[m]=jt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:b,expandAllCells:y}=Ce(),k=Qe(),x=ha(),j=Ba(t),v=L(Ge),I=L(wt),W=L(gt),{exportAsIPYNB:oe,exportAsMarkdown:ne,readCode:M,saveCellConfig:ie,updateCellOutputs:D}=H(),_=va(),se=Z(mt),le=Z(kt),re=Z(lt),{selectedLayout:R}=Pe(),{setLayoutView:de}=Ne(),F=Ue(),O=((we=m.sharing)==null?void 0:we.html)??!0,q=((ge=m.sharing)==null?void 0:ge.wasm)??!0,Y=((je=m.sharing)==null?void 0:je.molab)??!0,xe=!Q(),ce=R==="slides",Xe=mo,et=po,B;e[0]!==t||e[1]!==_||e[2]!==D?(B=async c=>{let{preset:p,title:E}=c;if(!t){ae();return}await _e(E,async pe=>{await Fe({takeScreenshots:()=>_({progress:pe}),updateCellOutputs:D}),await qa({filename:t,preset:p,downloadPDF:Et})})},e[0]=t,e[1]=_,e[2]=D,e[3]=B):B=e[3];let S=B,V;e[4]===S?V=e[5]:(V=async()=>{if(xe){await S({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),p=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(ho,0),setTimeout(()=>window.dispatchEvent(p),0)},e[4]=S,e[5]=V);let $=V,K;e[6]!==oe||e[7]!==t||e[8]!==_||e[9]!==D?(K=async()=>{if(!t){ae();return}await _e("Downloading IPYNB...",async c=>{await Fe({takeScreenshots:()=>_({progress:c}),updateCellOutputs:D});let p=await oe({download:!1});fe(new Blob([p],{type:"application/x-ipynb+json"}),ue.toIPYNB(document.title))})},e[6]=oe,e[7]=t,e[8]=_,e[9]=D,e[10]=K):K=e[10];let he=K,U;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(It,{size:14,strokeWidth:1.5}),e[11]=U):U=e[11];let G;e[12]===Symbol.for("react.memo_cache_sentinel")?(G=(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),e[12]=G):G=e[12];let A;e[13]===t?A=e[14]:(A=async()=>{if(!t){ae();return}await Ie({filename:t,includeCode:!0})},e[13]=t,e[14]=A);let J;return e[15]!==f||e[16]!==le||e[17]!==u||e[18]!==o||e[19]!==b||e[20]!==j||e[21]!==S||e[22]!==y||e[23]!==ne||e[24]!==t||e[25]!==$||e[26]!==he||e[27]!==se||e[28]!==d||e[29]!==ce||e[30]!==i||e[31]!==n||e[32]!==M||e[33]!==k||e[34]!==x||e[35]!==ie||e[36]!==R||e[37]!==r||e[38]!==v||e[39]!==W||e[40]!==de||e[41]!==I||e[42]!==O||e[43]!==Y||e[44]!==q||e[45]!==A||e[46]!==s||e[47]!==F||e[48]!==g||e[49]!==re||e[50]!==w||e[51]!==l.mode?(J=[{icon:U,label:"Download",handle:N,dropdown:[{icon:G,label:"Download as HTML",handle:A},{icon:(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ae();return}await Ie({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(wa,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await ne({download:!1});fe(new Blob([c],{type:"text/plain"}),ue.toMarkdown(document.title))}},{icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:he},{icon:(0,a.jsx)(Bt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await M();fe(new Blob([c.contents],{type:"text/plain"}),ue.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",xa("global.hideCode",!1)]}),handle:co},ce?{divider:!0,icon:(0,a.jsx)(X,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:N,dropdown:[{icon:(0,a.jsx)(X,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:$},{icon:(0,a.jsx)(X,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:et(!0),hidden:!xe,handle:async()=>{await S({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(X,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:$}]},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:Q(),handle:async()=>{n((0,a.jsx)(ga,{onClose:o}))}},{icon:(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),label:"Share",handle:N,hidden:!O&&!q&&!Y,dropdown:[{icon:(0,a.jsx)(Jt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!O,handle:async()=>{n((0,a.jsx)(Na,{onClose:o}))}},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!q,handle:async()=>{await ee(He({code:(await M()).contents})),z({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!Y,handle:async()=>{let c=He({code:(await M()).contents,baseUrl:`${C.molab}/new`});window.open(c,"_blank")}}]},{icon:(0,a.jsx)(Sa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:N,dropdown:bt.flatMap(c=>{let{type:p,Icon:E,hidden:pe,additionalKeywords:tt}=c;return pe?[]:{label:Se.startCase(p),rightElement:Xe(r===p),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),handle:()=>s(p),additionalKeywords:tt}})},{icon:(0,a.jsx)(Ve,{size:14,strokeWidth:1.5}),label:"Present as",handle:N,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(la,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{F()}},...Oe.map((c,p)=>{let E=Je(c);return{divider:p===0,label:Ze(c),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:R===c&&(0,a.jsx)(Ee,{size:14})}),handle:()=>{de(c),l.mode==="edit"&&F()}}})]},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||Q(),handle:j},{icon:(0,a.jsx)(qe,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ee((await M()).contents),z({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!se||i,handle:async()=>{let c=ht(ze());await ie({configs:Me.fromEntries(c.map(ro))});for(let p of c)w({cellId:p,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(xt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Le,{onClose:o}))}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Le,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:re,hidden:!le||i,handle:()=>{g()}},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:k,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Wa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(ct,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Ut,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:b,redundant:!0},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(lo)},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>W(so)},{icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>I(io),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(Kt,{size:14,strokeWidth:1.5}),label:"Resources",handle:N,dropdown:[{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Documentation",handle:no},{icon:(0,a.jsx)(Gt,{size:14,strokeWidth:1.5}),label:"GitHub",handle:oo},{icon:(0,a.jsx)(Zt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:ao},{icon:(0,a.jsx)(Xt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:to},{icon:(0,a.jsx)(ut,{size:14,strokeWidth:1.5}),label:"Changelog",handle:eo}]},{divider:!0,icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Xa},{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Qa}].filter(Za).map(Ga),e[15]=f,e[16]=le,e[17]=u,e[18]=o,e[19]=b,e[20]=j,e[21]=S,e[22]=y,e[23]=ne,e[24]=t,e[25]=$,e[26]=he,e[27]=se,e[28]=d,e[29]=ce,e[30]=i,e[31]=n,e[32]=M,e[33]=k,e[34]=x,e[35]=ie,e[36]=R,e[37]=r,e[38]=v,e[39]=W,e[40]=de,e[41]=I,e[42]=O,e[43]=Y,e[44]=q,e[45]=A,e[46]=s,e[47]=F,e[48]=g,e[49]=re,e[50]=w,e[51]=l.mode,e[52]=J):J=e[52],J}function Ga(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Ja)}:e}function Ja(e){return!e.hidden}function Za(e){return!e.hidden}function Qa(){let e=ca();window.open(e,"_blank")}function Xa(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function eo(){window.open(C.releasesPage,"_blank")}function to(){window.open(C.youtube,"_blank")}function ao(){window.open(C.discordLink,"_blank")}function oo(){window.open(C.githubPage,"_blank")}function no(){window.open(C.docsPage,"_blank")}function io(e){return!e}function so(e){return!e}function lo(e){return!e}function ro(e){return[e,{disabled:!1}]}async function co(){let e=document.getElementById("App");e&&await Lt({element:e,filename:document.title,prepare:Tt})}function ho(){return window.print()}function po(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function mo(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Ee,{size:14})})}function ae(){z({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Ue as a,Ye as c,Ge as i,qe as l,Qe as n,$e as o,Ra as r,Be as s,Ua as t};
|
package/dist/index.html
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
|
|
67
67
|
<!-- /TODO -->
|
|
68
68
|
<title>{{ title }}</title>
|
|
69
|
-
<script type="module" crossorigin src="./assets/index-
|
|
69
|
+
<script type="module" crossorigin src="./assets/index-DQ1e8BSW.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-DdZsAcJe.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
<link rel="modulepreload" crossorigin href="./assets/plus-CxkHs8QM.js">
|
|
198
198
|
<link rel="modulepreload" crossorigin href="./assets/trash-2-BJLYnZpG.js">
|
|
199
199
|
<link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-BdtIs0E-.js">
|
|
200
|
-
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-
|
|
200
|
+
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-BDXmjEj9.js">
|
|
201
201
|
<link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-nqk474t8.js">
|
|
202
202
|
<link rel="modulepreload" crossorigin href="./assets/square-function-blYaQso8.js">
|
|
203
203
|
<link rel="modulepreload" crossorigin href="./assets/spec-D1ptWKg6.js">
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
<link rel="modulepreload" crossorigin href="./assets/refresh-cw-a_9k9BK7.js">
|
|
206
206
|
<link rel="modulepreload" crossorigin href="./assets/tree-actions-ovIJqNLj.js">
|
|
207
207
|
<link rel="modulepreload" crossorigin href="./assets/components-1VuqOYTA.js">
|
|
208
|
-
<link rel="modulepreload" crossorigin href="./assets/column-preview-
|
|
208
|
+
<link rel="modulepreload" crossorigin href="./assets/column-preview-CSZ9RgJ8.js">
|
|
209
209
|
<link rel="modulepreload" crossorigin href="./assets/icons-8tfAri2V.js">
|
|
210
210
|
<link rel="modulepreload" crossorigin href="./assets/radio-group-BI8_7tB1.js">
|
|
211
211
|
<link rel="modulepreload" crossorigin href="./assets/floating-outline-p8p6wKPj.js">
|
|
@@ -228,7 +228,7 @@
|
|
|
228
228
|
<link rel="modulepreload" crossorigin href="./assets/label-C2_YQRio.js">
|
|
229
229
|
<link rel="modulepreload" crossorigin href="./assets/textarea-ibvi1Qnd.js">
|
|
230
230
|
<link rel="modulepreload" crossorigin href="./assets/refresh-ccw-DLc784Sj.js">
|
|
231
|
-
<link rel="modulepreload" crossorigin href="./assets/form-
|
|
231
|
+
<link rel="modulepreload" crossorigin href="./assets/form-DKdvoZxk.js">
|
|
232
232
|
<link rel="modulepreload" crossorigin href="./assets/renderShortcut-DbyG33_r.js">
|
|
233
233
|
<link rel="modulepreload" crossorigin href="./assets/useBoolean-D4l-DzBM.js">
|
|
234
234
|
<link rel="modulepreload" crossorigin href="./assets/useDeepCompareMemoize-CWcgQCbT.js">
|
package/package.json
CHANGED
|
@@ -7,6 +7,8 @@ import { useMemo, useState } from "react";
|
|
|
7
7
|
import { useAsyncData } from "@/hooks/useAsyncData";
|
|
8
8
|
import { ErrorBanner } from "@/plugins/impl/common/error-banner";
|
|
9
9
|
import type { CalculateTopKRows } from "@/plugins/impl/DataTablePlugin";
|
|
10
|
+
import type { Option } from "@/components/ui/select-core";
|
|
11
|
+
import { useSelectList } from "@/components/ui/select-core";
|
|
10
12
|
import { Logger } from "@/utils/Logger";
|
|
11
13
|
import { Sets } from "@/utils/sets";
|
|
12
14
|
import { smartMatch } from "@/utils/smartMatch";
|
|
@@ -23,7 +25,7 @@ import {
|
|
|
23
25
|
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
|
|
24
26
|
import { SentinelCell } from "./sentinel-cell";
|
|
25
27
|
import { detectSentinel, stringifyUnknownValue } from "./utils";
|
|
26
|
-
import { CompactChipRow } from "
|
|
28
|
+
import { CompactChipRow } from "@/components/ui/value-chips";
|
|
27
29
|
|
|
28
30
|
const TOP_K_ROWS = 30;
|
|
29
31
|
|
|
@@ -101,8 +103,6 @@ export const FilterByValuesList = <TData, TValue>({
|
|
|
101
103
|
onChange,
|
|
102
104
|
creatable = false,
|
|
103
105
|
}: FilterByValuesListProps<TData, TValue>) => {
|
|
104
|
-
const [query, setQuery] = useState<string>("");
|
|
105
|
-
|
|
106
106
|
const { data, isPending, error } = useAsyncData(async () => {
|
|
107
107
|
if (!calculateTopKRows) {
|
|
108
108
|
return null;
|
|
@@ -111,27 +111,49 @@ export const FilterByValuesList = <TData, TValue>({
|
|
|
111
111
|
return res.data;
|
|
112
112
|
}, [calculateTopKRows, column.id]);
|
|
113
113
|
|
|
114
|
-
const
|
|
114
|
+
const options = useMemo<Array<Option<unknown>>>(() => {
|
|
115
115
|
if (!data) {
|
|
116
116
|
return [];
|
|
117
117
|
}
|
|
118
118
|
try {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
smartMatch(query, str) ||
|
|
127
|
-
str.toLowerCase().includes(query.toLowerCase())
|
|
128
|
-
);
|
|
129
|
-
});
|
|
119
|
+
return data
|
|
120
|
+
.filter(([value]) => value !== undefined)
|
|
121
|
+
.map(([value, count]) => ({
|
|
122
|
+
value,
|
|
123
|
+
label: String(value),
|
|
124
|
+
data: { count },
|
|
125
|
+
}));
|
|
130
126
|
} catch (error_) {
|
|
131
|
-
Logger.error("Error
|
|
127
|
+
Logger.error("Error building filter options", error_);
|
|
132
128
|
return [];
|
|
133
129
|
}
|
|
134
|
-
}, [data
|
|
130
|
+
}, [data]);
|
|
131
|
+
|
|
132
|
+
const list = useSelectList<unknown>({
|
|
133
|
+
options,
|
|
134
|
+
value: [...chosenValues],
|
|
135
|
+
onChange: (next) => onChange(next as unknown[]),
|
|
136
|
+
multiple: true,
|
|
137
|
+
filterFn: (label, q) =>
|
|
138
|
+
smartMatch(q, label) || label.toLowerCase().includes(q.toLowerCase())
|
|
139
|
+
? 1
|
|
140
|
+
: 0,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const query = list.searchQuery;
|
|
144
|
+
const setQuery = list.setSearchQuery;
|
|
145
|
+
|
|
146
|
+
const filteredData = useMemo<Array<[unknown, number | undefined]>>(
|
|
147
|
+
() =>
|
|
148
|
+
list.visibleOptions.map(
|
|
149
|
+
(o) =>
|
|
150
|
+
[o.value, (o.data as { count: number }).count] as [
|
|
151
|
+
unknown,
|
|
152
|
+
number | undefined,
|
|
153
|
+
],
|
|
154
|
+
),
|
|
155
|
+
[list.visibleOptions],
|
|
156
|
+
);
|
|
135
157
|
|
|
136
158
|
// Surface chosen values that aren't in the top-K so they stay visible/uncheckable.
|
|
137
159
|
// Count is undefined for these rows; the cell renders an em-dash.
|
|
@@ -21,7 +21,7 @@ import { AddFilterButton } from "./add-filter-button";
|
|
|
21
21
|
import { FilterPillEditor } from "./filter-pill-editor";
|
|
22
22
|
import { type ColumnFilterValue, formatValue, type Snapshot } from "./filters";
|
|
23
23
|
import { extractTimezone } from "./types";
|
|
24
|
-
import { ChipWithComma, CompactChipRow } from "
|
|
24
|
+
import { ChipWithComma, CompactChipRow } from "@/components/ui/value-chips";
|
|
25
25
|
|
|
26
26
|
interface Props<TData> {
|
|
27
27
|
filters: ColumnFiltersState | undefined;
|
|
@@ -17,6 +17,11 @@ interface LanguageTogglesProps {
|
|
|
17
17
|
code: string;
|
|
18
18
|
currentLanguageAdapter: LanguageAdapter["type"] | undefined;
|
|
19
19
|
onAfterToggle: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Classes for the wrapper element. Defaults to the absolutely-positioned,
|
|
22
|
+
* hover-revealed placement used inside the notebook cell editor.
|
|
23
|
+
*/
|
|
24
|
+
className?: string;
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
export const LanguageToggles: React.FC<LanguageTogglesProps> = ({
|
|
@@ -24,6 +29,7 @@ export const LanguageToggles: React.FC<LanguageTogglesProps> = ({
|
|
|
24
29
|
code,
|
|
25
30
|
currentLanguageAdapter,
|
|
26
31
|
onAfterToggle,
|
|
32
|
+
className = "absolute right-3 top-2 z-20 flex hover-action gap-1",
|
|
27
33
|
}) => {
|
|
28
34
|
const canUseMarkdown = useMemo(
|
|
29
35
|
() => LanguageAdapters.markdown.isSupported(code) || code.trim() === "",
|
|
@@ -35,7 +41,7 @@ export const LanguageToggles: React.FC<LanguageTogglesProps> = ({
|
|
|
35
41
|
);
|
|
36
42
|
|
|
37
43
|
return (
|
|
38
|
-
<div className=
|
|
44
|
+
<div className={className}>
|
|
39
45
|
<LanguageToggle
|
|
40
46
|
editorView={editorView}
|
|
41
47
|
currentLanguageAdapter={currentLanguageAdapter}
|
|
@@ -248,6 +248,26 @@ const BACKWARDS_COMPAT_SNAPSHOTS: BackwardsCompatCase[] = [
|
|
|
248
248
|
],
|
|
249
249
|
},
|
|
250
250
|
},
|
|
251
|
+
{
|
|
252
|
+
// `showCode` was added to SlideConfig. The validator must know about it (so
|
|
253
|
+
// it isn't silently stripped), the deserializer must carry it through, and
|
|
254
|
+
// serialize → deserialize must round-trip both values.
|
|
255
|
+
label: "showCode round-trips through validate + (de)serialize",
|
|
256
|
+
input: {
|
|
257
|
+
cells: [
|
|
258
|
+
{ type: "slide", showCode: true },
|
|
259
|
+
{ type: "fragment", showCode: false },
|
|
260
|
+
],
|
|
261
|
+
},
|
|
262
|
+
expected: {
|
|
263
|
+
deck: {},
|
|
264
|
+
cellIds: ["a", "b"],
|
|
265
|
+
cellEntries: [
|
|
266
|
+
["a", { type: "slide", showCode: true }],
|
|
267
|
+
["b", { type: "fragment", showCode: false }],
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
},
|
|
251
271
|
];
|
|
252
272
|
|
|
253
273
|
describe("SlidesLayoutPlugin backwards compatibility", () => {
|
|
@@ -9,6 +9,7 @@ export type SlideType = z.infer<typeof SlideTypeSchema>;
|
|
|
9
9
|
const SlideConfigSchema = z.looseObject({
|
|
10
10
|
type: SlideTypeSchema.optional(),
|
|
11
11
|
speakerNotes: z.string().optional(),
|
|
12
|
+
showCode: z.boolean().optional(),
|
|
12
13
|
});
|
|
13
14
|
export type SlideConfig = z.infer<typeof SlideConfigSchema>;
|
|
14
15
|
|