@marimo-team/frontend 0.23.10-dev44 → 0.23.10-dev46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{s as 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 ze,Lr as Ge,M as We,Nr as se,Oi as be,P as He,Pr as ge,Rn as Ke,Rt as Je,Ur as Qe,Vr as je,Wr as Ne,Wt as Xe,_n as Ye,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-k7Js5h2t.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 ca}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-DFky0PAA.js";import{n as ma}from"./multi-map-C4OANz8X.js";import"./popover-CNCYAwbC.js";import{$ as ve,Q as ne,et as ia,f as we,g as Se,h as re,m as oe,nt as da,p as ee,rt as ha,tt as ua,u as xa}from"./JsonOutput-CZQlutzs.js";import"./download-BS31LU22.js";import{r as Ce}from"./radio-group-DS_mmqHJ.js";import{t as ce}from"./tooltip-B_PkSKN3.js";import{r as pa,t as ae}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 fa}from"./strings-wdPMRf6Z.js";import{r as ba}from"./requests-DIwGYs0l.js";import{t as ga}from"./createLucideIcon-D5guW7EU.js";import{t as ja}from"./x-C-6liIBr.js";import{a as Na,r as ya}from"./tree-actions-XvgFV23w.js";import"./markdown-renderer-BHa-Tbwi.js";import{t as _e}from"./add-connection-dialog-CXSKXWr_.js";import{t as ke}from"./plus-BgB18UzY.js";import{a as va}from"./input-DA8xlX70.js";import{n as wa,o as Sa}from"./column-preview-DM1s1Z9h.js";import{t as Ca}from"./workflow-Bm8qF7yj.js";import"./dist-HyCgERnW.js";import"./dist-BwnT-_gD.js";import"./dist-rBRbke5D.js";import"./dist-RMRSa-Mj.js";import"./dist-BURue7-e.js";import"./session-0B5NBztP.js";import"./purify.es-B9KxLTTS.js";import"./dates-CTxr0EqQ.js";import{t as _a}from"./copy-icon-BuRdHNPA.js";import{t as ka}from"./context-QkTujrKn.js";import"./utils-DCL4n9wx.js";import"./vega-loader.browser-C8wT63Va.js";import"./defaultLocale-BLUna9fQ.js";import"./defaultLocale-DzliDDTm.js";import{t as $e}from"./cell-link-spbX-mlL.js";import"./chunk-5FQGJX7Z-D91x7QHS.js";import{r as $a}from"./html-to-image-rLeQGF-G.js";import{o as Fa}from"./focus-CRI5ilWC.js";import{n as me}from"./useAsyncData-bgszE9F0.js";import{a as Ta,i as Ia,n as La,o as Fe,r as qa,t as Da}from"./table-BGPSHfig.js";import"./react-resizable-panels.browser.esm-CV8-hvjx.js";import{a as Va,f as Ba,o as te,t as Pa}from"./command-BmOGG6-2.js";import{n as Ma}from"./icons-Ol38nIbL.js";import{t as Ea}from"./empty-state-vCWg-_A9.js";import{n as Oa,t as Ra}from"./common-Zqa_rd3u.js";import{a as Ua,i as Aa,n as Te,r as Ie,t as Le}from"./components-CXG-2UWv.js";var za=ga("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(),F=ie(Pe(),1),t=ie(ca(),1),$={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"},Ga=ue(a=>{let e=a(fe),s=a(Ke),l=a(Ze);return J(e,r=>{if(!r.variable_name)return-1;let c=Object.values(s).find(g=>g.name===r.variable_name);if(!c)return 0;let n=l.inOrderIds.indexOf(c.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(c=>!Ha(c));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]=F.useState(""),[l,r]=he(Wa),c=de(ge),n=K(Ga),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)(_e,{children:(0,t.jsxs)(ae,{variant:"outline",size:"sm",children:["Add database or catalog",(0,t.jsx)(ke,{className:"h-4 w-4 ml-2"})]})}),icon:(0,t.jsx)(le,{})}),a[3]=v):v=a[3],v}let u=!!e.trim(),m;a[4]===c?m=a[5]:(m=v=>{c(v.length>0),s(v)},a[4]=c,a[5]=m);let i;a[6]!==e||a[7]!==m?(i=(0,t.jsx)(Va,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:m,rootClassName:"flex-1 border-r border-b-0"}),a[6]=e,a[7]=m,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)(ja,{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)(Na,{"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)(_e,{children:(0,t.jsx)(ae,{variant:"ghost",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden",children:(0,t.jsx)(ke,{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)(Qa,{connection:w,hasChildren:w.databases.length>0,children:w.databases.map(k=>(0,t.jsx)(Xa,{engineName:w.name,database:k,hasSearch:u,children:(0,t.jsx)(Ya,{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)(we,{className:$.engine,children:[(0,t.jsx)(Ma,{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)(Ba,{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)(Pa,{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 Qa=a=>{let e=(0,A.c)(25),{connection:s,children:l,hasChildren:r}=a,c=s.name===Qe,n=c?"In-Memory":s.name,{previewDataSourceConnection:g}=ba(),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 m;e[5]===s.dialect?m=e[6]:(m=ea(s.dialect),e[5]=s.dialect,e[6]=m);let i;e[7]===m?i=e[8]:(i=(0,t.jsx)("span",{className:"text-xs",children:m}),e[7]=m,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]!==c?(d=!c&&(0,t.jsx)(ya,{onClick:N,tooltip:"Refresh connection",className:"ml-auto h-4 p-0",iconClassName:"h-3.5 w-3.5"}),e[11]=N,e[12]=c,e[13]=d):d=e[13];let o;e[14]!==u||e[15]!==i||e[16]!==p||e[17]!==d?(o=(0,t.jsxs)(we,{className:$.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)(ee,{content:"No databases available",className:$.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},Xa=a=>{let e=(0,A.c)(26),{hasSearch:s,engineName:l,database:r,children:c}=a,[n,g]=F.useState(!1),[j,N]=F.useState(!1),[u,m]=F.useState(s);u!==s&&(m(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",$.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)(Se,{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)(te,{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&&c,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},Ya=({schemas:a,defaultSchema:e,defaultDatabase:s,dialect:l,engineName:r,databaseName:c,hasSearch:n,searchValue:g})=>{let{addSchemaList:j}=se(),[N,u]=F.useState(!1),[m,i]=F.useState(!1),{isPending:h,error:p}=me(async()=>{if(a.length===0&&r&&!N){u(!0),i(!0);try{j({schemas:(await Xe.request({engine:r,database:c})).schemas??[],sqlSchemaContext:{engine:r,database:c}})}finally{i(!1)}}},[a.length,r,c,N]);return h||m?(0,t.jsx)(re,{message:"Loading schemas...",className:$.schemaLoading}):p?(0,t.jsx)(oe,{error:p,className:$.schemaLoading}):a.length===0?(0,t.jsx)(ee,{content:"No schemas available",className:$.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:c,schema:d,hasSearch:n,children:(0,t.jsx)(De,{tables:d.tables,searchValue:g,sqlTableContext:{engine:r,database:c,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:c}=a,[n,g]=F.useState(c),[j,N]=F.useState(!1),u=`${s}:${l.name}`;if(xe(l.name))return r;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=O("text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",$.schema),e[0]=m):m=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)(Se,{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)(te,{className:m,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:c}=se(),[n,g]=F.useState(!1),[j,N]=F.useState(!1),u;e[0]!==c||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 ze.request({engine:o,database:b,schema:x});if(!(f!=null&&f.tables))throw N(!1),Error("No tables available");c({tables:f.tables,sqlTableContext:l}),N(!1)}},e[0]=c,e[1]=l,e[2]=s.length,e[3]=n,e[4]=u):u=e[4];let m;e[5]!==l||e[6]!==s.length||e[7]!==n?(m=[s.length,l,n],e[5]=l,e[6]=s.length,e[7]=n,e[8]=m):m=e[8];let{isPending:i,error:h}=me(u,m);if(i||j){let o;return e[9]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(re,{message:"Loading tables...",className:$.tableLoading}),e[9]=o):o=e[9],o}if(h){let o;return e[10]===h?o=e[11]:(o=(0,t.jsx)(oe,{error:h,className:$.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)(ee,{content:"No tables found",className:$.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:c}=se(),[n,g]=F.useState(!1),[j,N]=F.useState(!1),u=s.columns.length>0,m;e[0]!==c||e[1]!==n||e[2]!==l||e[3]!==s.name||e[4]!==u||e[5]!==j?(m=async()=>{if(n&&!u&&l&&!j){N(!0);let{engine:B,database:Y,schema:Be}=l,Z=await Re.request({engine:B,database:Y,schema:Be,tableName:s.name});if(!(Z!=null&&Z.table))throw Error("No table details available");c({table:Z.table,sqlTableContext:l})}},e[0]=c,e[1]=n,e[2]=l,e[3]=s.name,e[4]=u,e[5]=j,e[6]=m):m=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}=me(m,i),o=K(ra),b=Fa(),{createNewCell:x}=Oe(),f=Ce(),y;e[10]!==f||e[11]!==o||e[12]!==x||e[13]!==b||e[14]!==l||e[15]!==s?(y=()=>{$a({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 fa(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)(re,{message:"Loading columns...",className:$.tableLoading});if(d)return(0,t.jsx)(oe,{error:d,className:$.tableLoading});let B=s.columns;return B.length===0?(0,t.jsx)(ee,{content:"No columns found",className:$.tableLoading}):B.map(Y=>(0,t.jsx)(at,{table:s,column:Y,sqlTableContext:l},Y.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)?$.tableSchemaless:$.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=pa.stopPropagation(()=>S()),e[45]=S,e[46]=D);let Q;e[47]===Symbol.for("react.memo_cache_sentinel")?(Q=(0,t.jsx)(Sa,{className:"h-3 w-3"}),e[47]=Q):Q=e[47];let G;e[48]===D?G=e[49]:(G=(0,t.jsx)(ce,{content:"Add table to notebook",delayDuration:400,children:(0,t.jsx)(ae,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:D,children:Q})}),e[48]=D,e[49]=G);let W;e[50]!==n||e[51]!==L||e[52]!==R||e[53]!==U||e[54]!==G||e[55]!==I||e[56]!==P?(W=(0,t.jsxs)(te,{className:I,value:P,"aria-selected":n,forceMount:!0,onSelect:L,children:[R,U,G]}),e[50]=n,e[51]=L,e[52]=R,e[53]=U,e[54]=G,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 X;return e[61]!==W||e[62]!==H?(X=(0,t.jsxs)(t.Fragment,{children:[W,H]}),e[61]=W,e[62]=H,e[63]=X):X=e[63],X},at=a=>{var R,U;let e=(0,A.c)(48),{table:s,column:l,sqlTableContext:r}=a,[c,n]=F.useState(!1),g=K(ge),j=de(Ae);g&&c&&n(!1),j(c?D=>new Set([...D,`${s.name}:${l.name}`]):D=>(D.delete(`${s.name}:${l.name}`),new Set(D)));let N=Ce(),{columnsPreviews:u}=Ge(),m;e[0]!==l.name||e[1]!==s.primary_keys?(m=((R=s.primary_keys)==null?void 0:R.includes(l.name))||!1,e[0]=l.name,e[1]=s.primary_keys,e[2]=m):m=e[2];let i=m,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=c?"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]===c?_=e[12]:(_=()=>n(!c),e[11]=c,e[12]=_);let v=r?$.columnSql:$.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)(xa,{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)(ce,{content:"Copy column name",delayDuration:400,children:(0,t.jsx)(ae,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:(0,t.jsx)(_a,{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)(te,{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]!==c||e[42]!==r||e[43]!==s?(q=c&&(0,t.jsx)("div",{className:O($.columnPreview,"pr-2 py-2 bg-(--slate-1) shadow-inner border-b"),children:(0,t.jsx)(oa,{children:(0,t.jsx)(wa,{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]=c,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)(ce,{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 ps(a){return a}var z={name:"name",type:"type-value",defs:"defs-refs"},st=[{id:z.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:z.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:z.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=c=>{let n=ta(c);n&&Ye(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)(za,{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((c,n)=>(0,t.jsxs)("span",{className:"flex",children:[(0,t.jsx)($e,{variant:"focus",cellId:c,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(c)},c),n<e.length-1&&", "]},c))})]}),(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)(Ca,{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:z.defs,desc:!1});let l=[];switch(e.id){case z.name:l=J(a,r=>r.name);break;case z.type:l=J(a,r=>r.dataType);break;case z.defs:l=J(a,r=>s.get(r.declaredBy[0]));break}return e.desc?l.toReversed():l}const Ve=(0,F.memo)(({className:a,cellIds:e,variables:s})=>{let[l,r]=F.useState([]),[c,n]=F.useState(""),g=He(),{locale:j}=ka(),N=(0,F.useMemo)(()=>{let m=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(m),usedByNames:i.usedBy.map(m)}))},[s,g,e]),u=ia({data:(0,F.useMemo)(()=>{let m=new Map;return e.forEach((i,h)=>m.set(i,h)),lt({variables:N,sort:l[0],cellIdToIndex:m})},[N,l,e]),columns:st,getCoreRowModel:ua(),onGlobalFilterChange:n,getFilteredRowModel:da(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(m){return m.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:j,onSortingChange:r,getSortedRowModel:ha(),state:{sorting:l,globalFilter:c}});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(va,{className:"w-full",placeholder:"Search",value:c,onChange:m=>n(m.target.value)}),(0,t.jsxs)(Da,{className:O("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,t.jsx)(Ta,{children:(0,t.jsx)(Fe,{className:"whitespace-nowrap text-xs",children:u.getFlatHeaders().map(m=>(0,t.jsx)(Ia,{className:"sticky top-0 bg-background border-b",children:ve(m.column.columnDef.header,m.getContext())},m.id))})}),(0,t.jsx)(La,{children:u.getRowModel().rows.map(m=>(0,t.jsx)(Fe,{className:"hover:bg-accent",children:m.getVisibleCells().map(i=>(0,t.jsx)(qa,{className:"border-b",children:ve(i.column.columnDef.cell,i.getContext())},i.id))},m.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),[c,n]=he(rt),g=l.length+r.length,j;a[0]!==g||a[1]!==c.hasUserInteracted||a[2]!==c.openSections?(j=!c.hasUserInteracted&&g>0?[...new Set([...c.openSections,"datasources"])]:c.openSections,a[0]=g,a[1]=c.hasUserInteracted,a[2]=c.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 m=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]!==m||a[20]!==N||a[21]!==b||a[22]!==f?(y=(0,t.jsxs)(ma,{type:"multiple",value:N,onValueChange:m,className:"flex flex-col h-full overflow-auto",children:[b,f]}),a[19]=m,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 ze,Lr as Ge,M as We,Nr as se,Oi as be,P as He,Pr as ge,Rn as Ke,Rt as Je,Ur as Qe,Vr as je,Wr as Ne,Wt as Xe,_n as Ye,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-k7Js5h2t.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 ca}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-DFky0PAA.js";import{n as ma}from"./multi-map-C4OANz8X.js";import"./popover-CNCYAwbC.js";import{$ as ve,Q as ne,et as ia,f as we,g as Se,h as re,m as oe,nt as da,p as ee,rt as ha,tt as ua,u as xa}from"./JsonOutput-CZQlutzs.js";import"./download-BS31LU22.js";import{r as Ce}from"./radio-group-DS_mmqHJ.js";import{t as ce}from"./tooltip-B_PkSKN3.js";import{r as pa,t as ae}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 fa}from"./strings-wdPMRf6Z.js";import{r as ba}from"./requests-DIwGYs0l.js";import{t as ga}from"./createLucideIcon-D5guW7EU.js";import{t as ja}from"./x-C-6liIBr.js";import{a as Na,r as ya}from"./tree-actions-XvgFV23w.js";import"./markdown-renderer-BHa-Tbwi.js";import{t as _e}from"./add-connection-dialog-C_jDtIZF.js";import{t as ke}from"./plus-BgB18UzY.js";import{a as va}from"./input-DA8xlX70.js";import{n as wa,o as Sa}from"./column-preview-DM1s1Z9h.js";import{t as Ca}from"./workflow-Bm8qF7yj.js";import"./dist-HyCgERnW.js";import"./dist-BwnT-_gD.js";import"./dist-rBRbke5D.js";import"./dist-RMRSa-Mj.js";import"./dist-BURue7-e.js";import"./session-0B5NBztP.js";import"./purify.es-B9KxLTTS.js";import"./dates-CTxr0EqQ.js";import{t as _a}from"./copy-icon-BuRdHNPA.js";import{t as ka}from"./context-QkTujrKn.js";import"./utils-DCL4n9wx.js";import"./vega-loader.browser-C8wT63Va.js";import"./defaultLocale-BLUna9fQ.js";import"./defaultLocale-DzliDDTm.js";import{t as $e}from"./cell-link-spbX-mlL.js";import"./chunk-5FQGJX7Z-D91x7QHS.js";import{r as $a}from"./html-to-image-rLeQGF-G.js";import{o as Fa}from"./focus-CRI5ilWC.js";import{n as me}from"./useAsyncData-bgszE9F0.js";import{a as Ta,i as Ia,n as La,o as Fe,r as qa,t as Da}from"./table-BGPSHfig.js";import"./react-resizable-panels.browser.esm-CV8-hvjx.js";import{a as Va,f as Ba,o as te,t as Pa}from"./command-BmOGG6-2.js";import{n as Ma}from"./icons-Ol38nIbL.js";import{t as Ea}from"./empty-state-vCWg-_A9.js";import{n as Oa,t as Ra}from"./common-Zqa_rd3u.js";import{a as Ua,i as Aa,n as Te,r as Ie,t as Le}from"./components-CXG-2UWv.js";var za=ga("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(),F=ie(Pe(),1),t=ie(ca(),1),$={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"},Ga=ue(a=>{let e=a(fe),s=a(Ke),l=a(Ze);return J(e,r=>{if(!r.variable_name)return-1;let c=Object.values(s).find(g=>g.name===r.variable_name);if(!c)return 0;let n=l.inOrderIds.indexOf(c.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(c=>!Ha(c));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]=F.useState(""),[l,r]=he(Wa),c=de(ge),n=K(Ga),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)(_e,{children:(0,t.jsxs)(ae,{variant:"outline",size:"sm",children:["Add database or catalog",(0,t.jsx)(ke,{className:"h-4 w-4 ml-2"})]})}),icon:(0,t.jsx)(le,{})}),a[3]=v):v=a[3],v}let u=!!e.trim(),m;a[4]===c?m=a[5]:(m=v=>{c(v.length>0),s(v)},a[4]=c,a[5]=m);let i;a[6]!==e||a[7]!==m?(i=(0,t.jsx)(Va,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:m,rootClassName:"flex-1 border-r border-b-0"}),a[6]=e,a[7]=m,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)(ja,{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)(Na,{"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)(_e,{children:(0,t.jsx)(ae,{variant:"ghost",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden",children:(0,t.jsx)(ke,{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)(Qa,{connection:w,hasChildren:w.databases.length>0,children:w.databases.map(k=>(0,t.jsx)(Xa,{engineName:w.name,database:k,hasSearch:u,children:(0,t.jsx)(Ya,{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)(we,{className:$.engine,children:[(0,t.jsx)(Ma,{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)(Ba,{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)(Pa,{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 Qa=a=>{let e=(0,A.c)(25),{connection:s,children:l,hasChildren:r}=a,c=s.name===Qe,n=c?"In-Memory":s.name,{previewDataSourceConnection:g}=ba(),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 m;e[5]===s.dialect?m=e[6]:(m=ea(s.dialect),e[5]=s.dialect,e[6]=m);let i;e[7]===m?i=e[8]:(i=(0,t.jsx)("span",{className:"text-xs",children:m}),e[7]=m,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]!==c?(d=!c&&(0,t.jsx)(ya,{onClick:N,tooltip:"Refresh connection",className:"ml-auto h-4 p-0",iconClassName:"h-3.5 w-3.5"}),e[11]=N,e[12]=c,e[13]=d):d=e[13];let o;e[14]!==u||e[15]!==i||e[16]!==p||e[17]!==d?(o=(0,t.jsxs)(we,{className:$.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)(ee,{content:"No databases available",className:$.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},Xa=a=>{let e=(0,A.c)(26),{hasSearch:s,engineName:l,database:r,children:c}=a,[n,g]=F.useState(!1),[j,N]=F.useState(!1),[u,m]=F.useState(s);u!==s&&(m(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",$.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)(Se,{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)(te,{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&&c,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},Ya=({schemas:a,defaultSchema:e,defaultDatabase:s,dialect:l,engineName:r,databaseName:c,hasSearch:n,searchValue:g})=>{let{addSchemaList:j}=se(),[N,u]=F.useState(!1),[m,i]=F.useState(!1),{isPending:h,error:p}=me(async()=>{if(a.length===0&&r&&!N){u(!0),i(!0);try{j({schemas:(await Xe.request({engine:r,database:c})).schemas??[],sqlSchemaContext:{engine:r,database:c}})}finally{i(!1)}}},[a.length,r,c,N]);return h||m?(0,t.jsx)(re,{message:"Loading schemas...",className:$.schemaLoading}):p?(0,t.jsx)(oe,{error:p,className:$.schemaLoading}):a.length===0?(0,t.jsx)(ee,{content:"No schemas available",className:$.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:c,schema:d,hasSearch:n,children:(0,t.jsx)(De,{tables:d.tables,searchValue:g,sqlTableContext:{engine:r,database:c,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:c}=a,[n,g]=F.useState(c),[j,N]=F.useState(!1),u=`${s}:${l.name}`;if(xe(l.name))return r;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=O("text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",$.schema),e[0]=m):m=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)(Se,{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)(te,{className:m,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:c}=se(),[n,g]=F.useState(!1),[j,N]=F.useState(!1),u;e[0]!==c||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 ze.request({engine:o,database:b,schema:x});if(!(f!=null&&f.tables))throw N(!1),Error("No tables available");c({tables:f.tables,sqlTableContext:l}),N(!1)}},e[0]=c,e[1]=l,e[2]=s.length,e[3]=n,e[4]=u):u=e[4];let m;e[5]!==l||e[6]!==s.length||e[7]!==n?(m=[s.length,l,n],e[5]=l,e[6]=s.length,e[7]=n,e[8]=m):m=e[8];let{isPending:i,error:h}=me(u,m);if(i||j){let o;return e[9]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(re,{message:"Loading tables...",className:$.tableLoading}),e[9]=o):o=e[9],o}if(h){let o;return e[10]===h?o=e[11]:(o=(0,t.jsx)(oe,{error:h,className:$.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)(ee,{content:"No tables found",className:$.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:c}=se(),[n,g]=F.useState(!1),[j,N]=F.useState(!1),u=s.columns.length>0,m;e[0]!==c||e[1]!==n||e[2]!==l||e[3]!==s.name||e[4]!==u||e[5]!==j?(m=async()=>{if(n&&!u&&l&&!j){N(!0);let{engine:B,database:Y,schema:Be}=l,Z=await Re.request({engine:B,database:Y,schema:Be,tableName:s.name});if(!(Z!=null&&Z.table))throw Error("No table details available");c({table:Z.table,sqlTableContext:l})}},e[0]=c,e[1]=n,e[2]=l,e[3]=s.name,e[4]=u,e[5]=j,e[6]=m):m=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}=me(m,i),o=K(ra),b=Fa(),{createNewCell:x}=Oe(),f=Ce(),y;e[10]!==f||e[11]!==o||e[12]!==x||e[13]!==b||e[14]!==l||e[15]!==s?(y=()=>{$a({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 fa(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)(re,{message:"Loading columns...",className:$.tableLoading});if(d)return(0,t.jsx)(oe,{error:d,className:$.tableLoading});let B=s.columns;return B.length===0?(0,t.jsx)(ee,{content:"No columns found",className:$.tableLoading}):B.map(Y=>(0,t.jsx)(at,{table:s,column:Y,sqlTableContext:l},Y.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)?$.tableSchemaless:$.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=pa.stopPropagation(()=>S()),e[45]=S,e[46]=D);let Q;e[47]===Symbol.for("react.memo_cache_sentinel")?(Q=(0,t.jsx)(Sa,{className:"h-3 w-3"}),e[47]=Q):Q=e[47];let G;e[48]===D?G=e[49]:(G=(0,t.jsx)(ce,{content:"Add table to notebook",delayDuration:400,children:(0,t.jsx)(ae,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:D,children:Q})}),e[48]=D,e[49]=G);let W;e[50]!==n||e[51]!==L||e[52]!==R||e[53]!==U||e[54]!==G||e[55]!==I||e[56]!==P?(W=(0,t.jsxs)(te,{className:I,value:P,"aria-selected":n,forceMount:!0,onSelect:L,children:[R,U,G]}),e[50]=n,e[51]=L,e[52]=R,e[53]=U,e[54]=G,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 X;return e[61]!==W||e[62]!==H?(X=(0,t.jsxs)(t.Fragment,{children:[W,H]}),e[61]=W,e[62]=H,e[63]=X):X=e[63],X},at=a=>{var R,U;let e=(0,A.c)(48),{table:s,column:l,sqlTableContext:r}=a,[c,n]=F.useState(!1),g=K(ge),j=de(Ae);g&&c&&n(!1),j(c?D=>new Set([...D,`${s.name}:${l.name}`]):D=>(D.delete(`${s.name}:${l.name}`),new Set(D)));let N=Ce(),{columnsPreviews:u}=Ge(),m;e[0]!==l.name||e[1]!==s.primary_keys?(m=((R=s.primary_keys)==null?void 0:R.includes(l.name))||!1,e[0]=l.name,e[1]=s.primary_keys,e[2]=m):m=e[2];let i=m,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=c?"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]===c?_=e[12]:(_=()=>n(!c),e[11]=c,e[12]=_);let v=r?$.columnSql:$.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)(xa,{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)(ce,{content:"Copy column name",delayDuration:400,children:(0,t.jsx)(ae,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:(0,t.jsx)(_a,{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)(te,{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]!==c||e[42]!==r||e[43]!==s?(q=c&&(0,t.jsx)("div",{className:O($.columnPreview,"pr-2 py-2 bg-(--slate-1) shadow-inner border-b"),children:(0,t.jsx)(oa,{children:(0,t.jsx)(wa,{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]=c,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)(ce,{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 ps(a){return a}var z={name:"name",type:"type-value",defs:"defs-refs"},st=[{id:z.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:z.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:z.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=c=>{let n=ta(c);n&&Ye(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)(za,{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((c,n)=>(0,t.jsxs)("span",{className:"flex",children:[(0,t.jsx)($e,{variant:"focus",cellId:c,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(c)},c),n<e.length-1&&", "]},c))})]}),(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)(Ca,{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:z.defs,desc:!1});let l=[];switch(e.id){case z.name:l=J(a,r=>r.name);break;case z.type:l=J(a,r=>r.dataType);break;case z.defs:l=J(a,r=>s.get(r.declaredBy[0]));break}return e.desc?l.toReversed():l}const Ve=(0,F.memo)(({className:a,cellIds:e,variables:s})=>{let[l,r]=F.useState([]),[c,n]=F.useState(""),g=He(),{locale:j}=ka(),N=(0,F.useMemo)(()=>{let m=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(m),usedByNames:i.usedBy.map(m)}))},[s,g,e]),u=ia({data:(0,F.useMemo)(()=>{let m=new Map;return e.forEach((i,h)=>m.set(i,h)),lt({variables:N,sort:l[0],cellIdToIndex:m})},[N,l,e]),columns:st,getCoreRowModel:ua(),onGlobalFilterChange:n,getFilteredRowModel:da(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(m){return m.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:j,onSortingChange:r,getSortedRowModel:ha(),state:{sorting:l,globalFilter:c}});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(va,{className:"w-full",placeholder:"Search",value:c,onChange:m=>n(m.target.value)}),(0,t.jsxs)(Da,{className:O("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,t.jsx)(Ta,{children:(0,t.jsx)(Fe,{className:"whitespace-nowrap text-xs",children:u.getFlatHeaders().map(m=>(0,t.jsx)(Ia,{className:"sticky top-0 bg-background border-b",children:ve(m.column.columnDef.header,m.getContext())},m.id))})}),(0,t.jsx)(La,{children:u.getRowModel().rows.map(m=>(0,t.jsx)(Fe,{className:"hover:bg-accent",children:m.getVisibleCells().map(i=>(0,t.jsx)(qa,{className:"border-b",children:ve(i.column.columnDef.cell,i.getContext())},i.id))},m.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),[c,n]=he(rt),g=l.length+r.length,j;a[0]!==g||a[1]!==c.hasUserInteracted||a[2]!==c.openSections?(j=!c.hasUserInteracted&&g>0?[...new Set([...c.openSections,"datasources"])]:c.openSections,a[0]=g,a[1]=c.hasUserInteracted,a[2]=c.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 m=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]!==m||a[20]!==N||a[21]!==b||a[22]!==f?(y=(0,t.jsxs)(ma,{type:"multiple",value:N,onValueChange:m,className:"flex flex-col h-full overflow-auto",children:[b,f]}),a[19]=m,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-k7Js5h2t.js";import{t as P}from"./compiler-runtime-B3qBwwSJ.js";import{n as wt,x as gt}from"./ai-model-dropdown-CXNYq3J_.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-ClMcu_sV.js";import{t as zt}from"./jsx-runtime-BqBOg78p.js";import{o as Wt}from"./alert-dialog-5BGIfskO.js";import{a as Mt,c as Dt,i as _t,n as St,r as At,s as Pt,t as Nt}from"./select-6suE6YM2.js";import{Nt as It}from"./JsonOutput-CZQlutzs.js";import{c as _e,d as ue,n as Et,o as Lt,r as fe,t as Tt}from"./download-BS31LU22.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-C9L0bRP-.js";import{t as Ee}from"./check-BH35Ndha.js";import{r as Vt}from"./useCellActionButton-DNDYDKvS.js";import{t as $t}from"./copy-BwrPA9zQ.js";import{t as Kt}from"./eye-off-Cm6DdkeR.js";import{t as Ut}from"./external-link-BTNxSavU.js";import{t as X}from"./file-BrdxGLRX.js";import{t as Gt}from"./github-BKS_2Qwn.js";import{u as Jt}from"./form-HcuPVpyt.js";import{n as Zt,r as Qt,t as Xt}from"./youtube-CbdpN8oL.js";import{i as ea,n as Le}from"./add-connection-dialog-CXSKXWr_.js";import{t as ta}from"./house-mGK3v0Mm.js";import{t as aa}from"./image-DQHXdEQn.js";import{t as oa}from"./link-CfEtM3Rl.js";import{r as na}from"./input-DA8xlX70.js";import{t as ia}from"./settings-DfFe0dWD.js";import{t as sa}from"./sparkles-lWUAsPhp.js";import{y as la}from"./textarea-BfDUjd9c.js";import{t as ra}from"./square-B5xWCt0a.js";import{t as z}from"./use-toast-CJ1Tj2eC.js";import{n as Te,t as da}from"./paths-D5zczhUD.js";import{o as ca}from"./session-0B5NBztP.js";import{n as ee}from"./copy-LK56fFow.js";import{r as ha}from"./useRunCells-CVd2QKS9.js";import{a as pa,c as ma,i as ua,n as fa,r as ba}from"./dialog-DRnNAWYl.js";import{n as ye}from"./ImperativeModal-BW1dmntO.js";import{r as ya,t as He}from"./share-mSf5FZIP.js";import{a as ka}from"./cell-link-spbX-mlL.js";import{a as xa}from"./renderShortcut--ku7VECI.js";import{t as wa}from"./icons-Ol38nIbL.js";import{t as ga}from"./pair-with-agent-modal-_SlYEcmZ.js";import{n as Re}from"./marimo-icons-CLbC-oB3.js";import{t as ja}from"./links-DoPgJNku.js";import{r as va,t as Fe}from"./hooks-C1zkcVIj.js";import{t as Oe}from"./types-Cpe-qFT-.js";var Ca=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),za=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),qe=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),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)(Kt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:b,redundant:!0},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(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)(Ut,{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-k7Js5h2t.js";import{t as P}from"./compiler-runtime-B3qBwwSJ.js";import{n as wt,x as gt}from"./ai-model-dropdown-CXNYq3J_.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-ClMcu_sV.js";import{t as zt}from"./jsx-runtime-BqBOg78p.js";import{o as Wt}from"./alert-dialog-5BGIfskO.js";import{a as Mt,c as Dt,i as _t,n as St,r as At,s as Pt,t as Nt}from"./select-6suE6YM2.js";import{Nt as It}from"./JsonOutput-CZQlutzs.js";import{c as _e,d as ue,n as Et,o as Lt,r as fe,t as Tt}from"./download-BS31LU22.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-C9L0bRP-.js";import{t as Ee}from"./check-BH35Ndha.js";import{r as Vt}from"./useCellActionButton-DNDYDKvS.js";import{t as $t}from"./copy-BwrPA9zQ.js";import{t as Kt}from"./eye-off-Cm6DdkeR.js";import{t as Ut}from"./external-link-BTNxSavU.js";import{t as X}from"./file-BrdxGLRX.js";import{t as Gt}from"./github-BKS_2Qwn.js";import{u as Jt}from"./form-HcuPVpyt.js";import{n as Zt,r as Qt,t as Xt}from"./youtube-CbdpN8oL.js";import{i as ea,n as Le}from"./add-connection-dialog-C_jDtIZF.js";import{t as ta}from"./house-mGK3v0Mm.js";import{t as aa}from"./image-DQHXdEQn.js";import{t as oa}from"./link-CfEtM3Rl.js";import{r as na}from"./input-DA8xlX70.js";import{t as ia}from"./settings-DfFe0dWD.js";import{t as sa}from"./sparkles-lWUAsPhp.js";import{y as la}from"./textarea-BfDUjd9c.js";import{t as ra}from"./square-B5xWCt0a.js";import{t as z}from"./use-toast-CJ1Tj2eC.js";import{n as Te,t as da}from"./paths-D5zczhUD.js";import{o as ca}from"./session-0B5NBztP.js";import{n as ee}from"./copy-LK56fFow.js";import{r as ha}from"./useRunCells-CVd2QKS9.js";import{a as pa,c as ma,i as ua,n as fa,r as ba}from"./dialog-DRnNAWYl.js";import{n as ye}from"./ImperativeModal-BW1dmntO.js";import{r as ya,t as He}from"./share-mSf5FZIP.js";import{a as ka}from"./cell-link-spbX-mlL.js";import{a as xa}from"./renderShortcut--ku7VECI.js";import{t as wa}from"./icons-Ol38nIbL.js";import{t as ga}from"./pair-with-agent-modal-_SlYEcmZ.js";import{n as Re}from"./marimo-icons-CLbC-oB3.js";import{t as ja}from"./links-DoPgJNku.js";import{r as va,t as Fe}from"./hooks-C1zkcVIj.js";import{t as Oe}from"./types-Cpe-qFT-.js";var Ca=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),za=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),qe=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),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)(Kt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:b,redundant:!0},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(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)(Ut,{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-CsVX7C4o.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-44I991hQ.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-BPPi7vOr.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.23.10-dev44",
3
+ "version": "0.23.10-dev46",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -82,10 +82,17 @@ exports[`generateStorageCode > GCS > without service account key (default creden
82
82
  store = GCSStore("my-bucket")"
83
83
  `;
84
84
 
85
- exports[`generateStorageCode > Google Drive > with browser auth (no credentials) 1`] = `
85
+ exports[`generateStorageCode > Google Drive > with default auth (no credentials) 1`] = `
86
86
  "from gdrive_fsspec import GoogleDriveFileSystem
87
87
 
88
- fs = GoogleDriveFileSystem(token="browser", use_listings_cache=False)"
88
+ fs = GoogleDriveFileSystem(use_listings_cache=False)"
89
+ `;
90
+
91
+ exports[`generateStorageCode > Google Drive > with embedded auth (no credentials) 1`] = `
92
+ "from gdrive_fsspec import GoogleDriveFileSystem
93
+
94
+ fs = GoogleDriveFileSystem(use_listings_cache=False, auth_kwargs={"use_local_webserver": False})
95
+ print("Google Drive connected! Important: Run this cell again to clear the console")"
89
96
  `;
90
97
 
91
98
  exports[`generateStorageCode > Google Drive > with service account credentials 1`] = `
@@ -43,7 +43,9 @@ describe("generateStorageCode", () => {
43
43
 
44
44
  describe("S3", () => {
45
45
  it("basic connection with all fields", () => {
46
- expect(generateStorageCode(baseS3, "obstore")).toMatchSnapshot();
46
+ expect(
47
+ generateStorageCode(baseS3, { library: "obstore" }),
48
+ ).toMatchSnapshot();
47
49
  });
48
50
 
49
51
  it("minimal connection (bucket only)", () => {
@@ -51,7 +53,9 @@ describe("generateStorageCode", () => {
51
53
  type: "s3",
52
54
  bucket: "my-bucket",
53
55
  };
54
- expect(generateStorageCode(conn, "obstore")).toMatchSnapshot();
56
+ expect(
57
+ generateStorageCode(conn, { library: "obstore" }),
58
+ ).toMatchSnapshot();
55
59
  });
56
60
 
57
61
  it("with custom endpoint", () => {
@@ -59,7 +63,9 @@ describe("generateStorageCode", () => {
59
63
  ...baseS3,
60
64
  endpoint_url: "https://minio.example.com:9000",
61
65
  };
62
- expect(generateStorageCode(conn, "obstore")).toMatchSnapshot();
66
+ expect(
67
+ generateStorageCode(conn, { library: "obstore" }),
68
+ ).toMatchSnapshot();
63
69
  });
64
70
 
65
71
  it("with secrets", () => {
@@ -70,13 +76,17 @@ describe("generateStorageCode", () => {
70
76
  access_key_id: prefixSecret("AWS_ACCESS_KEY_ID"),
71
77
  secret_access_key: prefixSecret("AWS_SECRET_ACCESS_KEY"),
72
78
  };
73
- expect(generateStorageCode(conn, "obstore")).toMatchSnapshot();
79
+ expect(
80
+ generateStorageCode(conn, { library: "obstore" }),
81
+ ).toMatchSnapshot();
74
82
  });
75
83
  });
76
84
 
77
85
  describe("GCS", () => {
78
86
  it("with service account key", () => {
79
- expect(generateStorageCode(baseGCS, "obstore")).toMatchSnapshot();
87
+ expect(
88
+ generateStorageCode(baseGCS, { library: "obstore" }),
89
+ ).toMatchSnapshot();
80
90
  });
81
91
 
82
92
  it("without service account key (default credentials)", () => {
@@ -84,13 +94,17 @@ describe("generateStorageCode", () => {
84
94
  type: "gcs",
85
95
  bucket: "my-bucket",
86
96
  };
87
- expect(generateStorageCode(conn, "obstore")).toMatchSnapshot();
97
+ expect(
98
+ generateStorageCode(conn, { library: "obstore" }),
99
+ ).toMatchSnapshot();
88
100
  });
89
101
  });
90
102
 
91
103
  describe("Azure", () => {
92
104
  it("basic connection with account key", () => {
93
- expect(generateStorageCode(baseAzure, "obstore")).toMatchSnapshot();
105
+ expect(
106
+ generateStorageCode(baseAzure, { library: "obstore" }),
107
+ ).toMatchSnapshot();
94
108
  });
95
109
 
96
110
  it("without account key", () => {
@@ -99,7 +113,9 @@ describe("generateStorageCode", () => {
99
113
  container: "my-container",
100
114
  account_name: "storageaccount",
101
115
  };
102
- expect(generateStorageCode(conn, "obstore")).toMatchSnapshot();
116
+ expect(
117
+ generateStorageCode(conn, { library: "obstore" }),
118
+ ).toMatchSnapshot();
103
119
  });
104
120
 
105
121
  it("with secrets", () => {
@@ -109,13 +125,17 @@ describe("generateStorageCode", () => {
109
125
  account_name: prefixSecret("AZURE_ACCOUNT"),
110
126
  account_key: prefixSecret("AZURE_KEY"),
111
127
  };
112
- expect(generateStorageCode(conn, "obstore")).toMatchSnapshot();
128
+ expect(
129
+ generateStorageCode(conn, { library: "obstore" }),
130
+ ).toMatchSnapshot();
113
131
  });
114
132
  });
115
133
 
116
134
  describe("CoreWeave", () => {
117
135
  it("basic connection with all fields", () => {
118
- expect(generateStorageCode(baseCoreWeave, "obstore")).toMatchSnapshot();
136
+ expect(
137
+ generateStorageCode(baseCoreWeave, { library: "obstore" }),
138
+ ).toMatchSnapshot();
119
139
  });
120
140
 
121
141
  it("minimal connection (bucket and region only)", () => {
@@ -124,7 +144,9 @@ describe("generateStorageCode", () => {
124
144
  bucket: "operator-bucket",
125
145
  region: "US-EAST-04A",
126
146
  };
127
- expect(generateStorageCode(conn, "obstore")).toMatchSnapshot();
147
+ expect(
148
+ generateStorageCode(conn, { library: "obstore" }),
149
+ ).toMatchSnapshot();
128
150
  });
129
151
 
130
152
  it("with secrets", () => {
@@ -135,39 +157,52 @@ describe("generateStorageCode", () => {
135
157
  access_key_id: prefixSecret("COREWEAVE_OBJECT_STORAGE_KEY"),
136
158
  secret_access_key: prefixSecret("COREWEAVE_OBJECT_STORAGE_SECRET"),
137
159
  };
138
- expect(generateStorageCode(conn, "obstore")).toMatchSnapshot();
160
+ expect(
161
+ generateStorageCode(conn, { library: "obstore" }),
162
+ ).toMatchSnapshot();
139
163
  });
140
164
  });
141
165
 
142
166
  describe("Google Drive", () => {
143
167
  it("with service account credentials", () => {
144
- expect(generateStorageCode(baseGDrive, "fsspec")).toMatchSnapshot();
168
+ expect(
169
+ generateStorageCode(baseGDrive, { library: "fsspec" }),
170
+ ).toMatchSnapshot();
145
171
  });
146
172
 
147
- it("with browser auth (no credentials)", () => {
173
+ it("with default auth (no credentials)", () => {
148
174
  const conn: StorageConnection = {
149
175
  type: "gdrive",
150
176
  };
151
- expect(generateStorageCode(conn, "fsspec")).toMatchSnapshot();
177
+ expect(
178
+ generateStorageCode(conn, { library: "fsspec" }),
179
+ ).toMatchSnapshot();
180
+ });
181
+
182
+ it("with embedded auth (no credentials)", () => {
183
+ const conn: StorageConnection = {
184
+ type: "gdrive",
185
+ };
186
+ expect(
187
+ generateStorageCode(conn, { library: "fsspec", isEmbedded: true }),
188
+ ).toMatchSnapshot();
152
189
  });
153
190
  });
154
191
 
155
192
  describe("invalid cases", () => {
156
193
  it("throws for empty S3 bucket", () => {
157
194
  expect(() =>
158
- generateStorageCode(
159
- { type: "s3", bucket: "" } as StorageConnection,
160
- "obstore",
161
- ),
195
+ generateStorageCode({ type: "s3", bucket: "" } as StorageConnection, {
196
+ library: "obstore",
197
+ }),
162
198
  ).toThrow();
163
199
  });
164
200
 
165
201
  it("throws for empty GCS bucket", () => {
166
202
  expect(() =>
167
- generateStorageCode(
168
- { type: "gcs", bucket: "" } as StorageConnection,
169
- "obstore",
170
- ),
203
+ generateStorageCode({ type: "gcs", bucket: "" } as StorageConnection, {
204
+ library: "obstore",
205
+ }),
171
206
  ).toThrow();
172
207
  });
173
208
 
@@ -179,7 +214,7 @@ describe("generateStorageCode", () => {
179
214
  container: "",
180
215
  account_name: "acct",
181
216
  } as StorageConnection,
182
- "obstore",
217
+ { library: "obstore" },
183
218
  ),
184
219
  ).toThrow();
185
220
  });
@@ -192,7 +227,7 @@ describe("generateStorageCode", () => {
192
227
  container: "my-container",
193
228
  account_name: "",
194
229
  } as StorageConnection,
195
- "obstore",
230
+ { library: "obstore" },
196
231
  ),
197
232
  ).toThrow();
198
233
  });
@@ -205,7 +240,7 @@ describe("generateStorageCode", () => {
205
240
  bucket: "",
206
241
  region: "US-EAST-04A",
207
242
  } as StorageConnection,
208
- "obstore",
243
+ { library: "obstore" },
209
244
  ),
210
245
  ).toThrow();
211
246
  });
@@ -218,7 +253,7 @@ describe("generateStorageCode", () => {
218
253
  bucket: "operator-bucket",
219
254
  region: "",
220
255
  } as StorageConnection,
221
- "obstore",
256
+ { library: "obstore" },
222
257
  ),
223
258
  ).toThrow();
224
259
  });
@@ -5,6 +5,7 @@ import type { FieldValues } from "react-hook-form";
5
5
  import type { z } from "zod";
6
6
  import { ProtocolIcon } from "@/components/storage/components";
7
7
  import type { KnownStorageProtocol } from "@/core/storage/types";
8
+ import { useIframeCapabilities } from "@/hooks/useIframeCapabilities";
8
9
  import { ConnectionForm, SelectorButton, SelectorGrid } from "../components";
9
10
  import {
10
11
  generateStorageCode,
@@ -108,6 +109,7 @@ export const AddStorageForm: React.FC<{
108
109
  onSubmit: () => void;
109
110
  header?: React.ReactNode;
110
111
  }> = ({ onSubmit, header }) => {
112
+ const { isEmbedded } = useIframeCapabilities();
111
113
  const [selectedSchema, setSelectedSchema] = useState<z.ZodType<
112
114
  StorageConnection,
113
115
  FieldValues
@@ -134,7 +136,9 @@ export const AddStorageForm: React.FC<{
134
136
  preferredLibrary={libs?.preferred ?? "obstore"}
135
137
  displayNames={StorageLibraryDisplayNames}
136
138
  libraryLabel="Preferred storage library"
137
- generateCode={(values, library) => generateStorageCode(values, library)}
139
+ generateCode={(values, library) =>
140
+ generateStorageCode(values, { library, isEmbedded })
141
+ }
138
142
  onSubmit={onSubmit}
139
143
  onBack={() => setSelectedSchema(null)}
140
144
  />
@@ -7,6 +7,11 @@ import { type StorageConnection, StorageConnectionSchema } from "./schemas";
7
7
 
8
8
  export type StorageLibrary = "obstore" | "fsspec";
9
9
 
10
+ export interface StorageCodeOptions {
11
+ library: StorageLibrary;
12
+ isEmbedded?: boolean;
13
+ }
14
+
10
15
  export const StorageLibraryDisplayNames: Record<StorageLibrary, string> = {
11
16
  obstore: "obstore",
12
17
  fsspec: "fsspec",
@@ -161,8 +166,9 @@ function generateCoreWeaveCode(
161
166
 
162
167
  function generateGDriveCode(
163
168
  connection: Extract<StorageConnection, { type: "gdrive" }>,
164
- secrets: SecretContainer,
169
+ options: { secrets: SecretContainer; isEmbedded?: boolean },
165
170
  ): { imports: Set<string>; code: string } {
171
+ const { secrets, isEmbedded = false } = options;
166
172
  const imports = new Set(["from gdrive_fsspec import GoogleDriveFileSystem"]);
167
173
 
168
174
  if (connection.credentials_json) {
@@ -178,15 +184,20 @@ function generateGDriveCode(
178
184
  return { imports, code };
179
185
  }
180
186
 
181
- const code = dedent(`
182
- fs = GoogleDriveFileSystem(token="browser", use_listings_cache=False)
183
- `);
187
+ const code = isEmbedded
188
+ ? dedent(`
189
+ fs = GoogleDriveFileSystem(use_listings_cache=False, auth_kwargs={"use_local_webserver": False})
190
+ print("Google Drive connected! Important: Run this cell again to clear the console")
191
+ `)
192
+ : dedent(`
193
+ fs = GoogleDriveFileSystem(use_listings_cache=False)
194
+ `);
184
195
  return { imports, code };
185
196
  }
186
197
 
187
198
  export function generateStorageCode(
188
199
  connection: StorageConnection,
189
- _library: StorageLibrary,
200
+ options: StorageCodeOptions,
190
201
  ): string {
191
202
  StorageConnectionSchema.parse(connection);
192
203
 
@@ -207,7 +218,10 @@ export function generateStorageCode(
207
218
  result = generateCoreWeaveCode(connection, secrets);
208
219
  break;
209
220
  case "gdrive":
210
- result = generateGDriveCode(connection, secrets);
221
+ result = generateGDriveCode(connection, {
222
+ secrets,
223
+ isEmbedded: options.isEmbedded,
224
+ });
211
225
  break;
212
226
  default:
213
227
  assertNever(connection);