@marimo-team/frontend 0.19.8-dev31 → 0.19.8-dev33

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 oe}from"./chunk-LvLJmgfZ.js";import{d as ce,i as Ee,l as Me,p as me,u as K}from"./useEvent-BhXAndur.js";import{t as Pe}from"./react-Bj1aDYRI.js";import{An as Oe,Dt as Ue,Et as ze,Hn as Ae,Nn as Re,Qt as ie,Un as le,Yr as Ge,a as We,ar as de,bt as He,dr as he,er as Ke,f as ue,ft as Je,gn as Qe,hn as Xe,ir as xe,j as Ye,jn as Ze,k as ea,mr as pe,or as aa,pr as ta,rr as fe,sr as sa,ur as be,vn as ge,w as la,zn as na}from"./cells-CiFhRLUd.js";import"./react-dom-CSu739Rf.js";import{t as ne}from"./compiler-runtime-B3qBwwSJ.js";import{n as ra}from"./assertNever-CBU83Y6o.js";import{t as je}from"./add-database-form-D8ppo-Wx.js";import"./tooltip-DqsDDLgU.js";import{t as J}from"./sortBy-CGfmqUg5.js";import{o as oa}from"./utils-YqBXNpsM.js";import{t as ca}from"./ErrorBoundary-B9Ifj8Jf.js";import{t as ma}from"./jsx-runtime-ZmTK25f3.js";import{r as ia,t as Q}from"./button-CZ3Cs4qb.js";import{t as L}from"./cn-BKtXLv3a.js";import"./dist-DBwNzi3C.js";import{B as da,I as Ne,L as ha,R as ua,k as re,z as xa}from"./JsonOutput-BUok9dqY.js";import"./cjs-CH5Rj0g8.js";import"./main-U5Goe76G.js";import"./useNonce-CS26E0hA.js";import{r as pa}from"./requests-B4FYHTZl.js";import{t as fa}from"./createLucideIcon-BCdY6lG5.js";import{t as ba}from"./x-ZP5cObgf.js";import"./download-CUgZOA9O.js";import"./markdown-renderer-Dotqbx_q.js";import{t as ye}from"./plus-B7DF33lD.js";import{t as ga}from"./refresh-cw-Dx8TEWFP.js";import{a as ja}from"./input-DHHmNa19.js";import{c as ve,d as we,f as Se,l as ae,n as Na,o as ya,p as va,u as _e}from"./column-preview-BUTci9vI.js";import{t as wa}from"./workflow-B12dAR4X.js";import{t as Sa}from"./badge-D4keL3YC.js";import"./dist-Cayq-K1c.js";import"./dist-TiFCI16_.js";import"./dist-BIKFl48f.js";import"./dist-B0VqT_4z.js";import"./dist-BYyu59D8.js";import"./session-fBtIbMpB.js";import"./Combination-izwufzWe.js";import{t as te}from"./tooltip-C_WgOOcZ.js";import"./dates-CT5PUuFo.js";import{t as _a}from"./context-Ga_vV5mE.js";import"./popover-B-131r4d.js";import"./vega-loader.browser-BegSZk0G.js";import"./defaultLocale-YteS-k_t.js";import"./defaultLocale-B6z1Qyqt.js";import{t as Ca}from"./copy-icon-C9v8EtBA.js";import"./purify.es-B-nzWya6.js";import{a as Ce,i as ke,n as ka,r as $e}from"./multi-map-A4XNra08.js";import{t as Fe}from"./cell-link-dnd6DfEI.js";import{n as Ie}from"./useAsyncData-CgmD3hjw.js";import{a as $a,o as se,t as Fa,u as Ia}from"./command-MHa10zT2.js";import"./chunk-5FQGJX7Z-T2jyw7ZD.js";import"./katex-CbllUrnh.js";import{r as Ta}from"./html-to-image-BKGhRUqR.js";import{o as qa}from"./focus-CtXToHnV.js";import{a as La,i as Ba,n as Da,o as Te,r as Va,t as Ea}from"./table-BOsFCeLh.js";import{n as Ma}from"./icons-DjR3qLG_.js";import{t as qe}from"./useAddCell-DQzBfMNz.js";import{t as Pa}from"./empty-state-DrmGF88A.js";import{n as Oa,t as Ua}from"./common-CR6DwVIy.js";var za=fa("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"}]]),_=oe(Pe(),1),Aa=ne(),t=oe(ma(),1);const Ra=a=>{let e=(0,Aa.c)(8),{variableName:s,className:l}=a,r;e[0]===s?r=e[1]:(r=()=>{let g=Ga(s);if(!g)return;let N=ue(g);N&&ie(N,s)},e[0]=s,e[1]=r);let o=r,n;e[2]===l?n=e[3]:(n=L("text-link opacity-80 hover:opacity-100 hover:underline",l),e[2]=l,e[3]=n);let b;return e[4]!==o||e[5]!==n||e[6]!==s?(b=(0,t.jsx)("button",{type:"button",onClick:o,className:n,children:s}),e[4]=o,e[5]=n,e[6]=s,e[7]=b):b=e[7],b};function Ga(a){let e=Ee.get(ge)[a];if(e)return e.declaredBy[0]}var A=ne(),C={engineEmpty:"pl-3",engine:"pl-3 pr-2",database:"pl-4",schemaEmpty:"pl-8",schema:"pl-7",tableLoading:"pl-11",tableSchemaless:"pl-8",tableWithSchema:"pl-12",columnLocal:"pl-5",columnSql:"pl-13",columnPreview:"pl-10"},Wa=me(a=>{let e=a(de),s=a(ge),l=a(We);return J(e,r=>{if(!r.variable_name)return-1;let o=Object.values(s).find(b=>b.name===r.variable_name);if(!o)return 0;let n=l.inOrderIds.indexOf(o.declaredBy[0]);return n===-1?0:n})});const Le=me(a=>{let e=new Map(a(Ke));for(let s of pe){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=>pe.has(s.name)?1:0)}),Ha=()=>{let a=(0,A.c)(32),[e,s]=_.useState(""),l=ce(xe),r=K(Wa),o=K(Le);if(r.length===0&&o.length===0){let p;return a[0]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)(Pa,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:(0,t.jsx)(je,{children:(0,t.jsxs)(Q,{variant:"outline",size:"sm",children:["Add database or catalog",(0,t.jsx)(ye,{className:"h-4 w-4 ml-2"})]})}),icon:(0,t.jsx)(le,{})}),a[0]=p):p=a[0],p}let n=!!e.trim(),b;a[1]===l?b=a[2]:(b=p=>{l(p.length>0),s(p)},a[1]=l,a[2]=b);let g;a[3]!==e||a[4]!==b?(g=(0,t.jsx)($a,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:b,rootClassName:"flex-1 border-r border-b-0"}),a[3]=e,a[4]=b,a[5]=g):g=a[5];let N;a[6]===n?N=a[7]:(N=n&&(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)(ba,{className:"h-4 w-4"})}),a[6]=n,a[7]=N);let j;a[8]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)(je,{children:(0,t.jsx)(Q,{variant:"ghost",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden",children:(0,t.jsx)(ye,{className:"h-4 w-4"})})}),a[8]=j):j=a[8];let i;a[9]!==g||a[10]!==N?(i=(0,t.jsxs)("div",{className:"flex items-center w-full border-b",children:[g,N,j]}),a[9]=g,a[10]=N,a[11]=i):i=a[11];let c;if(a[12]!==o||a[13]!==n||a[14]!==e){let p;a[16]!==n||a[17]!==e?(p=u=>(0,t.jsx)(Ka,{connection:u,hasChildren:u.databases.length>0,children:u.databases.map(f=>(0,t.jsx)(Ja,{engineName:u.name,database:f,hasSearch:n,children:(0,t.jsx)(Qa,{schemas:f.schemas,defaultSchema:u.default_schema,defaultDatabase:u.default_database,engineName:u.name,databaseName:f.name,hasSearch:n,searchValue:e,dialect:u.dialect})},f.name))},u.name),a[16]=n,a[17]=e,a[18]=p):p=a[18],c=o.map(p),a[12]=o,a[13]=n,a[14]=e,a[15]=c}else c=a[15];let d;a[19]!==o.length||a[20]!==r.length?(d=o.length>0&&r.length>0&&(0,t.jsxs)(ve,{className:C.engine,children:[(0,t.jsx)(Ma,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-xs",children:"Python"})]}),a[19]=o.length,a[20]=r.length,a[21]=d):d=a[21];let x;a[22]!==e||a[23]!==r?(x=r.length>0&&(0,t.jsx)(Be,{tables:r,searchValue:e}),a[22]=e,a[23]=r,a[24]=x):x=a[24];let h;a[25]!==c||a[26]!==d||a[27]!==x?(h=(0,t.jsxs)(Ia,{className:"flex flex-col",children:[c,d,x]}),a[25]=c,a[26]=d,a[27]=x,a[28]=h):h=a[28];let m;return a[29]!==i||a[30]!==h?(m=(0,t.jsxs)(Fa,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden",shouldFilter:!1,children:[i,h]}),a[29]=i,a[30]=h,a[31]=m):m=a[31],m};var Ka=a=>{let e=(0,A.c)(26),{connection:s,children:l,hasChildren:r}=a,o=s.name===ta,n=o?"In-Memory":s.name,{previewDataSourceConnection:b}=pa(),[g,N]=_.useState(!1),j;e[0]!==s.name||e[1]!==b?(j=async()=>{N(!0),await b({engine:s.name}),setTimeout(()=>N(!1),500)},e[0]=s.name,e[1]=b,e[2]=j):j=e[2];let i=j,c;e[3]===s.dialect?c=e[4]:(c=(0,t.jsx)(Je,{className:"h-4 w-4 text-muted-foreground",name:s.dialect}),e[3]=s.dialect,e[4]=c);let d;e[5]===s.dialect?d=e[6]:(d=Oe(s.dialect),e[5]=s.dialect,e[6]=d);let x;e[7]===d?x=e[8]:(x=(0,t.jsx)("span",{className:"text-xs",children:d}),e[7]=d,e[8]=x);let h=n,m;e[9]===h?m=e[10]:(m=(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(0,t.jsx)(Ra,{variableName:h}),")"]}),e[9]=h,e[10]=m);let p;e[11]!==i||e[12]!==o||e[13]!==g?(p=!o&&(0,t.jsx)(te,{content:"Refresh connection",children:(0,t.jsx)(Q,{variant:"ghost",size:"icon",className:"ml-auto hover:bg-transparent hover:shadow-none",onClick:i,children:(0,t.jsx)(ga,{className:L("h-4 w-4 text-muted-foreground hover:text-foreground",g&&"animate-[spin_0.5s]")})})}),e[11]=i,e[12]=o,e[13]=g,e[14]=p):p=e[14];let u;e[15]!==c||e[16]!==x||e[17]!==m||e[18]!==p?(u=(0,t.jsxs)(ve,{className:C.engine,children:[c,x,m,p]}),e[15]=c,e[16]=x,e[17]=m,e[18]=p,e[19]=u):u=e[19];let f;e[20]!==l||e[21]!==r?(f=r?l:(0,t.jsx)(ae,{content:"No databases available",className:C.engineEmpty}),e[20]=l,e[21]=r,e[22]=f):f=e[22];let y;return e[23]!==u||e[24]!==f?(y=(0,t.jsxs)(t.Fragment,{children:[u,f]}),e[23]=u,e[24]=f,e[25]=y):y=e[25],y},Ja=a=>{let e=(0,A.c)(26),{hasSearch:s,engineName:l,database:r,children:o}=a,[n,b]=_.useState(!1),[g,N]=_.useState(!1),[j,i]=_.useState(s);j!==s&&(i(s),b(s));let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=L("text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",C.database),e[0]=c):c=e[0];let d;e[1]!==n||e[2]!==g?(d=()=>{b(!n),N(!g)},e[1]=n,e[2]=g,e[3]=d):d=e[3];let x=`${l}:${r.name}`,h;e[4]===n?h=e[5]:(h=(0,t.jsx)(Se,{isExpanded:n}),e[4]=n,e[5]=h);let m=g&&n?"text-foreground":"text-muted-foreground",p;e[6]===m?p=e[7]:(p=L("h-4 w-4",m),e[6]=m,e[7]=p);let u;e[8]===p?u=e[9]:(u=(0,t.jsx)(le,{className:p}),e[8]=p,e[9]=u);let f=g&&n&&"font-semibold",y;e[10]===f?y=e[11]:(y=L(f),e[10]=f,e[11]=y);let v;e[12]===r.name?v=e[13]:(v=r.name===""?(0,t.jsx)("i",{children:"Not connected"}):r.name,e[12]=r.name,e[13]=v);let w;e[14]!==v||e[15]!==y?(w=(0,t.jsx)("span",{className:y,children:v}),e[14]=v,e[15]=y,e[16]=w):w=e[16];let S;e[17]!==w||e[18]!==d||e[19]!==x||e[20]!==h||e[21]!==u?(S=(0,t.jsxs)(se,{className:c,onSelect:d,value:x,children:[h,u,w]}),e[17]=w,e[18]=d,e[19]=x,e[20]=h,e[21]=u,e[22]=S):S=e[22];let q=n&&o,k;return e[23]!==S||e[24]!==q?(k=(0,t.jsxs)(t.Fragment,{children:[S,q]}),e[23]=S,e[24]=q,e[25]=k):k=e[25],k},Qa=a=>{let e=(0,A.c)(22),{schemas:s,defaultSchema:l,defaultDatabase:r,dialect:o,engineName:n,databaseName:b,hasSearch:g,searchValue:N}=a;if(s.length===0){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(ae,{content:"No schemas available",className:C.schemaEmpty}),e[0]=c):c=e[0],c}let j;if(e[1]!==b||e[2]!==r||e[3]!==l||e[4]!==o||e[5]!==n||e[6]!==g||e[7]!==s||e[8]!==N){let c;e[10]===N?c=e[11]:(c=h=>N?h.tables.some(m=>m.name.toLowerCase().includes(N.toLowerCase())):!0,e[10]=N,e[11]=c);let d=s.filter(c),x;e[12]!==b||e[13]!==r||e[14]!==l||e[15]!==o||e[16]!==n||e[17]!==g||e[18]!==N?(x=h=>(0,t.jsx)(Xa,{databaseName:b,schema:h,hasSearch:g,children:(0,t.jsx)(Be,{tables:h.tables,searchValue:N,sqlTableContext:{engine:n,database:b,schema:h.name,defaultSchema:l,defaultDatabase:r,dialect:o}})},h.name),e[12]=b,e[13]=r,e[14]=l,e[15]=o,e[16]=n,e[17]=g,e[18]=N,e[19]=x):x=e[19],j=d.map(x),e[1]=b,e[2]=r,e[3]=l,e[4]=o,e[5]=n,e[6]=g,e[7]=s,e[8]=N,e[9]=j}else j=e[9];let i;return e[20]===j?i=e[21]:(i=(0,t.jsx)(t.Fragment,{children:j}),e[20]=j,e[21]=i),i},Xa=a=>{let e=(0,A.c)(24),{databaseName:s,schema:l,children:r,hasSearch:o}=a,[n,b]=_.useState(o),[g,N]=_.useState(!1),j=`${s}:${l.name}`;if(be(l.name))return r;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=L("text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",C.schema),e[0]=i):i=e[0];let c;e[1]!==n||e[2]!==g?(c=()=>{b(!n),N(!g)},e[1]=n,e[2]=g,e[3]=c):c=e[3];let d;e[4]===n?d=e[5]:(d=(0,t.jsx)(Se,{isExpanded:n}),e[4]=n,e[5]=d);let x=g&&n&&"text-foreground",h;e[6]===x?h=e[7]:(h=L("h-4 w-4 text-muted-foreground",x),e[6]=x,e[7]=h);let m;e[8]===h?m=e[9]:(m=(0,t.jsx)(na,{className:h}),e[8]=h,e[9]=m);let p=g&&n&&"font-semibold",u;e[10]===p?u=e[11]:(u=L(p),e[10]=p,e[11]=u);let f;e[12]!==l.name||e[13]!==u?(f=(0,t.jsx)("span",{className:u,children:l.name}),e[12]=l.name,e[13]=u,e[14]=f):f=e[14];let y;e[15]!==c||e[16]!==d||e[17]!==m||e[18]!==f||e[19]!==j?(y=(0,t.jsxs)(se,{className:i,onSelect:c,value:j,children:[d,m,f]}),e[15]=c,e[16]=d,e[17]=m,e[18]=f,e[19]=j,e[20]=y):y=e[20];let v=n&&r,w;return e[21]!==y||e[22]!==v?(w=(0,t.jsxs)(t.Fragment,{children:[y,v]}),e[21]=y,e[22]=v,e[23]=w):w=e[23],w},Be=a=>{let e=(0,A.c)(24),{tables:s,sqlTableContext:l,searchValue:r}=a,{addTableList:o}=fe(),[n,b]=_.useState(!1),[g,N]=_.useState(!1),j;e[0]!==o||e[1]!==l||e[2]!==s.length||e[3]!==n?(j=async()=>{if(s.length===0&&l&&!n){b(!0),N(!0);let{engine:m,database:p,schema:u}=l,f=await Ue.request({engine:m,database:p,schema:u});if(!(f!=null&&f.tables))throw N(!1),Error("No tables available");o({tables:f.tables,sqlTableContext:l}),N(!1)}},e[0]=o,e[1]=l,e[2]=s.length,e[3]=n,e[4]=j):j=e[4];let i;e[5]!==l||e[6]!==s.length||e[7]!==n?(i=[s.length,l,n],e[5]=l,e[6]=s.length,e[7]=n,e[8]=i):i=e[8];let{isPending:c,error:d}=Ie(j,i);if(c||g){let m;return e[9]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(we,{message:"Loading tables...",className:C.tableLoading}),e[9]=m):m=e[9],m}if(d){let m;return e[10]===d?m=e[11]:(m=(0,t.jsx)(_e,{error:d,className:C.tableLoading}),e[10]=d,e[11]=m),m}if(s.length===0){let m;return e[12]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(ae,{content:"No tables found",className:C.tableLoading}),e[12]=m):m=e[12],m}let x;if(e[13]!==r||e[14]!==l||e[15]!==s){let m;e[17]===r?m=e[18]:(m=f=>r?f.name.toLowerCase().includes(r.toLowerCase()):!0,e[17]=r,e[18]=m);let p=s.filter(m),u;e[19]!==r||e[20]!==l?(u=f=>(0,t.jsx)(Ya,{table:f,sqlTableContext:l,isSearching:!!r},f.name),e[19]=r,e[20]=l,e[21]=u):u=e[21],x=p.map(u),e[13]=r,e[14]=l,e[15]=s,e[16]=x}else x=e[16];let h;return e[22]===x?h=e[23]:(h=(0,t.jsx)(t.Fragment,{children:x}),e[22]=x,e[23]=h),h},Ya=a=>{let e=(0,A.c)(64),{table:s,sqlTableContext:l,isSearching:r}=a,{addTable:o}=fe(),[n,b]=_.useState(!1),[g,N]=_.useState(!1),j=s.columns.length>0,i;e[0]!==o||e[1]!==n||e[2]!==l||e[3]!==s.name||e[4]!==j||e[5]!==g?(i=async()=>{if(n&&!j&&l&&!g){N(!0);let{engine:V,database:Z,schema:Ve}=l,ee=await ze.request({engine:V,database:Z,schema:Ve,tableName:s.name});if(!(ee!=null&&ee.table))throw Error("No table details available");o({table:ee.table,sqlTableContext:l})}},e[0]=o,e[1]=n,e[2]=l,e[3]=s.name,e[4]=j,e[5]=g,e[6]=i):i=e[6];let c;e[7]!==n||e[8]!==j?(c=[n,j],e[7]=n,e[8]=j,e[9]=c):c=e[9];let{isFetching:d,isPending:x,error:h}=Ie(i,c),m=K(oa),p=qa(),{createNewCell:u}=la(),f=qe(),y;e[10]!==f||e[11]!==m||e[12]!==u||e[13]!==p||e[14]!==l||e[15]!==s?(y=()=>{Ta({autoInstantiate:m,createNewCell:u,fromCellId:p}),f((()=>{if(s.source_type==="catalog"){let V=l!=null&&l.database?`${l.database}.${s.name}`:s.name;return`${s.engine}.load_table("${V}")`}if(l)return he({table:s,columnName:"*",sqlTableContext:l});switch(s.source_type){case"local":return`mo.ui.table(${s.name})`;case"duckdb":case"connection":return he({table:s,columnName:"*",sqlTableContext:l});default:return ra(s.source_type),""}})())},e[10]=f,e[11]=m,e[12]=u,e[13]=p,e[14]=l,e[15]=s,e[16]=y):y=e[16];let v=y,w;e[17]!==s.num_columns||e[18]!==s.num_rows?(w=()=>{let V=[];return s.num_rows!=null&&V.push(`${s.num_rows} rows`),s.num_columns!=null&&V.push(`${s.num_columns} columns`),V.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:V.join(", ")})})},e[17]=s.num_columns,e[18]=s.num_rows,e[19]=w):w=e[19];let S=w,q;e[20]!==h||e[21]!==d||e[22]!==x||e[23]!==l||e[24]!==s?(q=()=>{if(x||d)return(0,t.jsx)(we,{message:"Loading columns...",className:C.tableLoading});if(h)return(0,t.jsx)(_e,{error:h,className:C.tableLoading});let V=s.columns;return V.length===0?(0,t.jsx)(ae,{content:"No columns found",className:C.tableLoading}):V.map(Z=>(0,t.jsx)(Za,{table:s,column:Z,sqlTableContext:l},Z.name))},e[20]=h,e[21]=d,e[22]=x,e[23]=l,e[24]=s,e[25]=q):q=e[25];let k=q,B;e[26]!==n||e[27]!==r||e[28]!==s.source_type||e[29]!==s.type?(B=()=>{if(s.source_type!=="local")return(0,t.jsx)(s.type==="table"?Re:Ae,{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]=B):B=e[30];let E=B,M=l?`${l.database}.${l.schema}.${s.name}`:s.name,P=l&&(be(l.schema)?C.tableSchemaless:C.tableWithSchema),O=(n||r)&&"font-semibold",$;e[31]!==P||e[32]!==O?($=L("rounded-none group h-8 cursor-pointer",P,O),e[31]=P,e[32]=O,e[33]=$):$=e[33];let F;e[34]===n?F=e[35]:(F=()=>b(!n),e[34]=n,e[35]=F);let I;e[36]===E?I=e[37]:(I=E(),e[36]=E,e[37]=I);let D;e[38]===s.name?D=e[39]:(D=(0,t.jsx)("span",{className:"text-sm",children:s.name}),e[38]=s.name,e[39]=D);let U;e[40]!==I||e[41]!==D?(U=(0,t.jsxs)("div",{className:"flex gap-2 items-center flex-1 pl-1",children:[I,D]}),e[40]=I,e[41]=D,e[42]=U):U=e[42];let z;e[43]===S?z=e[44]:(z=S(),e[43]=S,e[44]=z);let T;e[45]===v?T=e[46]:(T=ia.stopPropagation(()=>v()),e[45]=v,e[46]=T);let X;e[47]===Symbol.for("react.memo_cache_sentinel")?(X=(0,t.jsx)(va,{className:"h-3 w-3"}),e[47]=X):X=e[47];let G;e[48]===T?G=e[49]:(G=(0,t.jsx)(te,{content:"Add table to notebook",delayDuration:400,children:(0,t.jsx)(Q,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:T,children:X})}),e[48]=T,e[49]=G);let W;e[50]!==n||e[51]!==F||e[52]!==U||e[53]!==z||e[54]!==G||e[55]!==$||e[56]!==M?(W=(0,t.jsxs)(se,{className:$,value:M,"aria-selected":n,forceMount:!0,onSelect:F,children:[U,z,G]}),e[50]=n,e[51]=F,e[52]=U,e[53]=z,e[54]=G,e[55]=$,e[56]=M,e[57]=W):W=e[57];let H;e[58]!==n||e[59]!==k?(H=n&&k(),e[58]=n,e[59]=k,e[60]=H):H=e[60];let Y;return e[61]!==W||e[62]!==H?(Y=(0,t.jsxs)(t.Fragment,{children:[W,H]}),e[61]=W,e[62]=H,e[63]=Y):Y=e[63],Y},Za=a=>{var U,z;let e=(0,A.c)(48),{table:s,column:l,sqlTableContext:r}=a,[o,n]=_.useState(!1),b=K(xe),g=ce(aa);b&&o&&n(!1),g(o?T=>new Set([...T,`${s.name}:${l.name}`]):T=>(T.delete(`${s.name}:${l.name}`),new Set(T)));let N=qe(),{columnsPreviews:j}=sa(),i;e[0]!==l.name||e[1]!==s.primary_keys?(i=((U=s.primary_keys)==null?void 0:U.includes(l.name))||!1,e[0]=l.name,e[1]=s.primary_keys,e[2]=i):i=e[2];let c=i,d;e[3]!==l.name||e[4]!==s.indexes?(d=((z=s.indexes)==null?void 0:z.includes(l.name))||!1,e[3]=l.name,e[4]=s.indexes,e[5]=d):d=e[5];let x=d,h;e[6]===N?h=e[7]:(h=T=>{N(T)},e[6]=N,e[7]=h);let m=h,p=et,u=o?"font-semibold":"",f;e[8]!==l.name||e[9]!==u?(f=(0,t.jsx)("span",{className:u,children:l.name}),e[8]=l.name,e[9]=u,e[10]=f):f=e[10];let y=f,v=`${s.name}.${l.name}`,w=`${s.name}.${l.name}`,S;e[11]===o?S=e[12]:(S=()=>n(!o),e[11]=o,e[12]=S);let q=r?C.columnSql:C.columnLocal,k;e[13]===q?k=e[14]:(k=L("flex flex-row gap-2 items-center flex-1",q),e[13]=q,e[14]=k);let B;e[15]!==l.type||e[16]!==y?(B=(0,t.jsx)(ya,{columnName:y,dataType:l.type}),e[15]=l.type,e[16]=y,e[17]=B):B=e[17];let E;e[18]===c?E=e[19]:(E=c&&p({tooltipContent:"Primary key",content:"PK"}),e[18]=c,e[19]=E);let M;e[20]===x?M=e[21]:(M=x&&p({tooltipContent:"Indexed",content:"IDX"}),e[20]=x,e[21]=M);let P;e[22]!==k||e[23]!==B||e[24]!==E||e[25]!==M?(P=(0,t.jsxs)("div",{className:k,children:[B,E,M]}),e[22]=k,e[23]=B,e[24]=E,e[25]=M,e[26]=P):P=e[26];let O;e[27]===l.name?O=e[28]:(O=(0,t.jsx)(te,{content:"Copy column name",delayDuration:400,children:(0,t.jsx)(Q,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:(0,t.jsx)(Ca,{tooltip:!1,value:l.name,className:"h-3 w-3"})})}),e[27]=l.name,e[28]=O);let $;e[29]===l.external_type?$=e[30]:($=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l.external_type}),e[29]=l.external_type,e[30]=$);let F;e[31]!==P||e[32]!==O||e[33]!==$||e[34]!==v||e[35]!==w||e[36]!==S?(F=(0,t.jsxs)(se,{className:"rounded-none py-1 group cursor-pointer",value:w,onSelect:S,children:[P,O,$]},v),e[31]=P,e[32]=O,e[33]=$,e[34]=v,e[35]=w,e[36]=S,e[37]=F):F=e[37];let I;e[38]!==l||e[39]!==j||e[40]!==m||e[41]!==o||e[42]!==r||e[43]!==s?(I=o&&(0,t.jsx)("div",{className:L(C.columnPreview,"pr-2 py-2 bg-(--slate-1) shadow-inner border-b"),children:(0,t.jsx)(ca,{children:(0,t.jsx)(Na,{table:s,column:l,onAddColumnChart:m,preview:j.get(r?`${r.database}.${r.schema}.${s.name}:${l.name}`:`${s.name}:${l.name}`),sqlTableContext:r})})}),e[38]=l,e[39]=j,e[40]=m,e[41]=o,e[42]=r,e[43]=s,e[44]=I):I=e[44];let D;return e[45]!==F||e[46]!==I?(D=(0,t.jsxs)(t.Fragment,{children:[F,I]}),e[45]=F,e[46]=I,e[47]=D):D=e[47],D};function et(a){let{tooltipContent:e,content:s}=a;return(0,t.jsx)(te,{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 us(a){return a}var R={name:"name",type:"type-value",defs:"defs-refs"},at=[{id:R.name,accessorFn:a=>[a.name,a.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,t.jsx)(re,{header:"Name",column:a}),cell:({getValue:a})=>{let[e,s]=a();return(0,t.jsx)(Ua,{name:e,declaredBy:s})}},{id:R.type,accessorFn:a=>[a.dataType,a.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,t.jsx)(re,{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:R.defs,accessorFn:a=>[a.declaredBy,a.usedBy,a.name,a.declaredByNames,a.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:a})=>(0,t.jsx)(re,{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=o=>{let n=ue(o);n&&ie(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)(Fe,{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((o,n)=>(0,t.jsxs)("span",{className:"flex",children:[(0,t.jsx)(Fe,{variant:"focus",cellId:o,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(o)},o),n<e.length-1&&", "]},o))})]}),(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)(wa,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,t.jsx)(Oa,{maxCount:3,cellIds:s,skipScroll:!0,onClick:r})]})]})}}];function tt({variables:a,sort:e,cellIdToIndex:s}){e||(e={id:R.defs,desc:!1});let l=[];switch(e.id){case R.name:l=J(a,r=>r.name);break;case R.type:l=J(a,r=>r.dataType);break;case R.defs:l=J(a,r=>s.get(r.declaredBy[0]));break}return e.desc?l.reverse():l}const De=(0,_.memo)(({className:a,cellIds:e,variables:s})=>{let[l,r]=_.useState([]),[o,n]=_.useState(""),b=Ye(),{locale:g}=_a(),N=(0,_.useMemo)(()=>{let i=c=>{let d=b[c];return He(d)?`cell-${e.indexOf(c)}`:d??`cell-${e.indexOf(c)}`};return Object.values(s).map(c=>({...c,declaredByNames:c.declaredBy.map(i),usedByNames:c.usedBy.map(i)}))},[s,b,e]),j=ha({data:(0,_.useMemo)(()=>{let i=new Map;return e.forEach((c,d)=>i.set(c,d)),tt({variables:N,sort:l[0],cellIdToIndex:i})},[N,l,e]),columns:at,getCoreRowModel:ua(),onGlobalFilterChange:n,getFilteredRowModel:xa(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(i){return i.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:g,onSortingChange:r,getSortedRowModel:da(),state:{sorting:l,globalFilter:o}});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ja,{className:"w-full",placeholder:"Search",value:o,onChange:i=>n(i.target.value)}),(0,t.jsxs)(Ea,{className:L("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,t.jsx)(La,{children:(0,t.jsx)(Te,{className:"whitespace-nowrap text-xs",children:j.getFlatHeaders().map(i=>(0,t.jsx)(Ba,{className:"sticky top-0 bg-background border-b",children:Ne(i.column.columnDef.header,i.getContext())},i.id))})}),(0,t.jsx)(Da,{children:j.getRowModel().rows.map(i=>(0,t.jsx)(Te,{className:"hover:bg-accent",children:i.getVisibleCells().map(c=>(0,t.jsx)(Va,{className:"border-b",children:Ne(c.column.columnDef.cell,c.getContext())},c.id))},i.id))})]})]})});De.displayName="VariableTable";var st=ne(),lt=Ge("marimo:session-panel:state",{openSections:["variables"],hasUserInteracted:!1},Xe),nt=()=>{let a=(0,st.c)(24),e=Qe(),s=ea(),l=K(de),r=K(Le),[o,n]=Me(lt),b=l.length+r.length,g;a[0]!==b||a[1]!==o.hasUserInteracted||a[2]!==o.openSections?(g=!o.hasUserInteracted&&b>0?[...new Set([...o.openSections,"datasources"])]:o.openSections,a[0]=b,a[1]=o.hasUserInteracted,a[2]=o.openSections,a[3]=g):g=a[3];let N=g,j;a[4]===n?j=a[5]:(j=v=>{n({openSections:v,hasUserInteracted:!0})},a[4]=n,a[5]=j);let i=j,c=!N.includes("datasources")&&b>0,d;a[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(le,{className:"w-4 h-4"}),a[6]=d):d=a[6];let x;a[7]!==b||a[8]!==c?(x=c&&(0,t.jsx)(Sa,{variant:"secondary",className:"ml-1 px-1.5 py-0 mb-px text-[10px]",children:b}),a[7]=b,a[8]=c,a[9]=x):x=a[9];let h;a[10]===x?h=a[11]:(h=(0,t.jsx)(Ce,{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide hover:no-underline",children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[d,"Data sources",x]})}),a[10]=x,a[11]=h);let m;a[12]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)($e,{wrapperClassName:"p-0",children:(0,t.jsx)(Ha,{})}),a[12]=m):m=a[12];let p;a[13]===h?p=a[14]:(p=(0,t.jsxs)(ke,{value:"datasources",className:"border-b",children:[h,m]}),a[13]=h,a[14]=p);let u;a[15]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(Ce,{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide hover:no-underline",children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ze,{className:"w-4 h-4"}),"Variables"]})}),a[15]=u):u=a[15];let f;a[16]!==s||a[17]!==e?(f=(0,t.jsxs)(ke,{value:"variables",className:"border-b-0",children:[u,(0,t.jsx)($e,{wrapperClassName:"p-0",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)(De,{cellIds:s.inOrderIds,variables:e})})]}),a[16]=s,a[17]=e,a[18]=f):f=a[18];let y;return a[19]!==i||a[20]!==N||a[21]!==p||a[22]!==f?(y=(0,t.jsxs)(ka,{type:"multiple",value:N,onValueChange:i,className:"flex flex-col h-full overflow-auto",children:[p,f]}),a[19]=i,a[20]=N,a[21]=p,a[22]=f,a[23]=y):y=a[23],y};export{nt as default};
1
+ import{s as oe}from"./chunk-LvLJmgfZ.js";import{d as ce,i as Ee,l as Me,p as me,u as K}from"./useEvent-BhXAndur.js";import{t as Pe}from"./react-Bj1aDYRI.js";import{An as Oe,Dt as Ue,Et as ze,Hn as Ae,Nn as Re,Qt as ie,Un as le,Yr as Ge,a as We,ar as de,bt as He,dr as he,er as Ke,f as ue,ft as Je,gn as Qe,hn as Xe,ir as xe,j as Ye,jn as Ze,k as ea,mr as pe,or as aa,pr as ta,rr as fe,sr as sa,ur as be,vn as ge,w as la,zn as na}from"./cells-CiFhRLUd.js";import"./react-dom-CSu739Rf.js";import{t as ne}from"./compiler-runtime-B3qBwwSJ.js";import{n as ra}from"./assertNever-CBU83Y6o.js";import{t as je}from"./add-database-form-mXHOy5uZ.js";import"./tooltip-DqsDDLgU.js";import{t as J}from"./sortBy-CGfmqUg5.js";import{o as oa}from"./utils-YqBXNpsM.js";import{t as ca}from"./ErrorBoundary-B9Ifj8Jf.js";import{t as ma}from"./jsx-runtime-ZmTK25f3.js";import{r as ia,t as Q}from"./button-CZ3Cs4qb.js";import{t as L}from"./cn-BKtXLv3a.js";import"./dist-DBwNzi3C.js";import{B as da,I as Ne,L as ha,R as ua,k as re,z as xa}from"./JsonOutput-BUok9dqY.js";import"./cjs-CH5Rj0g8.js";import"./main-U5Goe76G.js";import"./useNonce-CS26E0hA.js";import{r as pa}from"./requests-B4FYHTZl.js";import{t as fa}from"./createLucideIcon-BCdY6lG5.js";import{t as ba}from"./x-ZP5cObgf.js";import"./download-CUgZOA9O.js";import"./markdown-renderer-Dotqbx_q.js";import{t as ye}from"./plus-B7DF33lD.js";import{t as ga}from"./refresh-cw-Dx8TEWFP.js";import{a as ja}from"./input-DHHmNa19.js";import{c as ve,d as we,f as Se,l as ae,n as Na,o as ya,p as va,u as _e}from"./column-preview-BUTci9vI.js";import{t as wa}from"./workflow-B12dAR4X.js";import{t as Sa}from"./badge-D4keL3YC.js";import"./dist-Cayq-K1c.js";import"./dist-TiFCI16_.js";import"./dist-BIKFl48f.js";import"./dist-B0VqT_4z.js";import"./dist-BYyu59D8.js";import"./session-fBtIbMpB.js";import"./Combination-izwufzWe.js";import{t as te}from"./tooltip-C_WgOOcZ.js";import"./dates-CT5PUuFo.js";import{t as _a}from"./context-Ga_vV5mE.js";import"./popover-B-131r4d.js";import"./vega-loader.browser-BegSZk0G.js";import"./defaultLocale-YteS-k_t.js";import"./defaultLocale-B6z1Qyqt.js";import{t as Ca}from"./copy-icon-C9v8EtBA.js";import"./purify.es-B-nzWya6.js";import{a as Ce,i as ke,n as ka,r as $e}from"./multi-map-A4XNra08.js";import{t as Fe}from"./cell-link-dnd6DfEI.js";import{n as Ie}from"./useAsyncData-CgmD3hjw.js";import{a as $a,o as se,t as Fa,u as Ia}from"./command-MHa10zT2.js";import"./chunk-5FQGJX7Z-T2jyw7ZD.js";import"./katex-CbllUrnh.js";import{r as Ta}from"./html-to-image-BKGhRUqR.js";import{o as qa}from"./focus-CtXToHnV.js";import{a as La,i as Ba,n as Da,o as Te,r as Va,t as Ea}from"./table-BOsFCeLh.js";import{n as Ma}from"./icons-DjR3qLG_.js";import{t as qe}from"./useAddCell-DQzBfMNz.js";import{t as Pa}from"./empty-state-DrmGF88A.js";import{n as Oa,t as Ua}from"./common-CR6DwVIy.js";var za=fa("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"}]]),_=oe(Pe(),1),Aa=ne(),t=oe(ma(),1);const Ra=a=>{let e=(0,Aa.c)(8),{variableName:s,className:l}=a,r;e[0]===s?r=e[1]:(r=()=>{let g=Ga(s);if(!g)return;let N=ue(g);N&&ie(N,s)},e[0]=s,e[1]=r);let o=r,n;e[2]===l?n=e[3]:(n=L("text-link opacity-80 hover:opacity-100 hover:underline",l),e[2]=l,e[3]=n);let b;return e[4]!==o||e[5]!==n||e[6]!==s?(b=(0,t.jsx)("button",{type:"button",onClick:o,className:n,children:s}),e[4]=o,e[5]=n,e[6]=s,e[7]=b):b=e[7],b};function Ga(a){let e=Ee.get(ge)[a];if(e)return e.declaredBy[0]}var A=ne(),C={engineEmpty:"pl-3",engine:"pl-3 pr-2",database:"pl-4",schemaEmpty:"pl-8",schema:"pl-7",tableLoading:"pl-11",tableSchemaless:"pl-8",tableWithSchema:"pl-12",columnLocal:"pl-5",columnSql:"pl-13",columnPreview:"pl-10"},Wa=me(a=>{let e=a(de),s=a(ge),l=a(We);return J(e,r=>{if(!r.variable_name)return-1;let o=Object.values(s).find(b=>b.name===r.variable_name);if(!o)return 0;let n=l.inOrderIds.indexOf(o.declaredBy[0]);return n===-1?0:n})});const Le=me(a=>{let e=new Map(a(Ke));for(let s of pe){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=>pe.has(s.name)?1:0)}),Ha=()=>{let a=(0,A.c)(32),[e,s]=_.useState(""),l=ce(xe),r=K(Wa),o=K(Le);if(r.length===0&&o.length===0){let p;return a[0]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)(Pa,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:(0,t.jsx)(je,{children:(0,t.jsxs)(Q,{variant:"outline",size:"sm",children:["Add database or catalog",(0,t.jsx)(ye,{className:"h-4 w-4 ml-2"})]})}),icon:(0,t.jsx)(le,{})}),a[0]=p):p=a[0],p}let n=!!e.trim(),b;a[1]===l?b=a[2]:(b=p=>{l(p.length>0),s(p)},a[1]=l,a[2]=b);let g;a[3]!==e||a[4]!==b?(g=(0,t.jsx)($a,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:b,rootClassName:"flex-1 border-r border-b-0"}),a[3]=e,a[4]=b,a[5]=g):g=a[5];let N;a[6]===n?N=a[7]:(N=n&&(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)(ba,{className:"h-4 w-4"})}),a[6]=n,a[7]=N);let j;a[8]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)(je,{children:(0,t.jsx)(Q,{variant:"ghost",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden",children:(0,t.jsx)(ye,{className:"h-4 w-4"})})}),a[8]=j):j=a[8];let i;a[9]!==g||a[10]!==N?(i=(0,t.jsxs)("div",{className:"flex items-center w-full border-b",children:[g,N,j]}),a[9]=g,a[10]=N,a[11]=i):i=a[11];let c;if(a[12]!==o||a[13]!==n||a[14]!==e){let p;a[16]!==n||a[17]!==e?(p=u=>(0,t.jsx)(Ka,{connection:u,hasChildren:u.databases.length>0,children:u.databases.map(f=>(0,t.jsx)(Ja,{engineName:u.name,database:f,hasSearch:n,children:(0,t.jsx)(Qa,{schemas:f.schemas,defaultSchema:u.default_schema,defaultDatabase:u.default_database,engineName:u.name,databaseName:f.name,hasSearch:n,searchValue:e,dialect:u.dialect})},f.name))},u.name),a[16]=n,a[17]=e,a[18]=p):p=a[18],c=o.map(p),a[12]=o,a[13]=n,a[14]=e,a[15]=c}else c=a[15];let d;a[19]!==o.length||a[20]!==r.length?(d=o.length>0&&r.length>0&&(0,t.jsxs)(ve,{className:C.engine,children:[(0,t.jsx)(Ma,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-xs",children:"Python"})]}),a[19]=o.length,a[20]=r.length,a[21]=d):d=a[21];let x;a[22]!==e||a[23]!==r?(x=r.length>0&&(0,t.jsx)(Be,{tables:r,searchValue:e}),a[22]=e,a[23]=r,a[24]=x):x=a[24];let h;a[25]!==c||a[26]!==d||a[27]!==x?(h=(0,t.jsxs)(Ia,{className:"flex flex-col",children:[c,d,x]}),a[25]=c,a[26]=d,a[27]=x,a[28]=h):h=a[28];let m;return a[29]!==i||a[30]!==h?(m=(0,t.jsxs)(Fa,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden",shouldFilter:!1,children:[i,h]}),a[29]=i,a[30]=h,a[31]=m):m=a[31],m};var Ka=a=>{let e=(0,A.c)(26),{connection:s,children:l,hasChildren:r}=a,o=s.name===ta,n=o?"In-Memory":s.name,{previewDataSourceConnection:b}=pa(),[g,N]=_.useState(!1),j;e[0]!==s.name||e[1]!==b?(j=async()=>{N(!0),await b({engine:s.name}),setTimeout(()=>N(!1),500)},e[0]=s.name,e[1]=b,e[2]=j):j=e[2];let i=j,c;e[3]===s.dialect?c=e[4]:(c=(0,t.jsx)(Je,{className:"h-4 w-4 text-muted-foreground",name:s.dialect}),e[3]=s.dialect,e[4]=c);let d;e[5]===s.dialect?d=e[6]:(d=Oe(s.dialect),e[5]=s.dialect,e[6]=d);let x;e[7]===d?x=e[8]:(x=(0,t.jsx)("span",{className:"text-xs",children:d}),e[7]=d,e[8]=x);let h=n,m;e[9]===h?m=e[10]:(m=(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(0,t.jsx)(Ra,{variableName:h}),")"]}),e[9]=h,e[10]=m);let p;e[11]!==i||e[12]!==o||e[13]!==g?(p=!o&&(0,t.jsx)(te,{content:"Refresh connection",children:(0,t.jsx)(Q,{variant:"ghost",size:"icon",className:"ml-auto hover:bg-transparent hover:shadow-none",onClick:i,children:(0,t.jsx)(ga,{className:L("h-4 w-4 text-muted-foreground hover:text-foreground",g&&"animate-[spin_0.5s]")})})}),e[11]=i,e[12]=o,e[13]=g,e[14]=p):p=e[14];let u;e[15]!==c||e[16]!==x||e[17]!==m||e[18]!==p?(u=(0,t.jsxs)(ve,{className:C.engine,children:[c,x,m,p]}),e[15]=c,e[16]=x,e[17]=m,e[18]=p,e[19]=u):u=e[19];let f;e[20]!==l||e[21]!==r?(f=r?l:(0,t.jsx)(ae,{content:"No databases available",className:C.engineEmpty}),e[20]=l,e[21]=r,e[22]=f):f=e[22];let y;return e[23]!==u||e[24]!==f?(y=(0,t.jsxs)(t.Fragment,{children:[u,f]}),e[23]=u,e[24]=f,e[25]=y):y=e[25],y},Ja=a=>{let e=(0,A.c)(26),{hasSearch:s,engineName:l,database:r,children:o}=a,[n,b]=_.useState(!1),[g,N]=_.useState(!1),[j,i]=_.useState(s);j!==s&&(i(s),b(s));let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=L("text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",C.database),e[0]=c):c=e[0];let d;e[1]!==n||e[2]!==g?(d=()=>{b(!n),N(!g)},e[1]=n,e[2]=g,e[3]=d):d=e[3];let x=`${l}:${r.name}`,h;e[4]===n?h=e[5]:(h=(0,t.jsx)(Se,{isExpanded:n}),e[4]=n,e[5]=h);let m=g&&n?"text-foreground":"text-muted-foreground",p;e[6]===m?p=e[7]:(p=L("h-4 w-4",m),e[6]=m,e[7]=p);let u;e[8]===p?u=e[9]:(u=(0,t.jsx)(le,{className:p}),e[8]=p,e[9]=u);let f=g&&n&&"font-semibold",y;e[10]===f?y=e[11]:(y=L(f),e[10]=f,e[11]=y);let v;e[12]===r.name?v=e[13]:(v=r.name===""?(0,t.jsx)("i",{children:"Not connected"}):r.name,e[12]=r.name,e[13]=v);let w;e[14]!==v||e[15]!==y?(w=(0,t.jsx)("span",{className:y,children:v}),e[14]=v,e[15]=y,e[16]=w):w=e[16];let S;e[17]!==w||e[18]!==d||e[19]!==x||e[20]!==h||e[21]!==u?(S=(0,t.jsxs)(se,{className:c,onSelect:d,value:x,children:[h,u,w]}),e[17]=w,e[18]=d,e[19]=x,e[20]=h,e[21]=u,e[22]=S):S=e[22];let q=n&&o,k;return e[23]!==S||e[24]!==q?(k=(0,t.jsxs)(t.Fragment,{children:[S,q]}),e[23]=S,e[24]=q,e[25]=k):k=e[25],k},Qa=a=>{let e=(0,A.c)(22),{schemas:s,defaultSchema:l,defaultDatabase:r,dialect:o,engineName:n,databaseName:b,hasSearch:g,searchValue:N}=a;if(s.length===0){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(ae,{content:"No schemas available",className:C.schemaEmpty}),e[0]=c):c=e[0],c}let j;if(e[1]!==b||e[2]!==r||e[3]!==l||e[4]!==o||e[5]!==n||e[6]!==g||e[7]!==s||e[8]!==N){let c;e[10]===N?c=e[11]:(c=h=>N?h.tables.some(m=>m.name.toLowerCase().includes(N.toLowerCase())):!0,e[10]=N,e[11]=c);let d=s.filter(c),x;e[12]!==b||e[13]!==r||e[14]!==l||e[15]!==o||e[16]!==n||e[17]!==g||e[18]!==N?(x=h=>(0,t.jsx)(Xa,{databaseName:b,schema:h,hasSearch:g,children:(0,t.jsx)(Be,{tables:h.tables,searchValue:N,sqlTableContext:{engine:n,database:b,schema:h.name,defaultSchema:l,defaultDatabase:r,dialect:o}})},h.name),e[12]=b,e[13]=r,e[14]=l,e[15]=o,e[16]=n,e[17]=g,e[18]=N,e[19]=x):x=e[19],j=d.map(x),e[1]=b,e[2]=r,e[3]=l,e[4]=o,e[5]=n,e[6]=g,e[7]=s,e[8]=N,e[9]=j}else j=e[9];let i;return e[20]===j?i=e[21]:(i=(0,t.jsx)(t.Fragment,{children:j}),e[20]=j,e[21]=i),i},Xa=a=>{let e=(0,A.c)(24),{databaseName:s,schema:l,children:r,hasSearch:o}=a,[n,b]=_.useState(o),[g,N]=_.useState(!1),j=`${s}:${l.name}`;if(be(l.name))return r;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=L("text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",C.schema),e[0]=i):i=e[0];let c;e[1]!==n||e[2]!==g?(c=()=>{b(!n),N(!g)},e[1]=n,e[2]=g,e[3]=c):c=e[3];let d;e[4]===n?d=e[5]:(d=(0,t.jsx)(Se,{isExpanded:n}),e[4]=n,e[5]=d);let x=g&&n&&"text-foreground",h;e[6]===x?h=e[7]:(h=L("h-4 w-4 text-muted-foreground",x),e[6]=x,e[7]=h);let m;e[8]===h?m=e[9]:(m=(0,t.jsx)(na,{className:h}),e[8]=h,e[9]=m);let p=g&&n&&"font-semibold",u;e[10]===p?u=e[11]:(u=L(p),e[10]=p,e[11]=u);let f;e[12]!==l.name||e[13]!==u?(f=(0,t.jsx)("span",{className:u,children:l.name}),e[12]=l.name,e[13]=u,e[14]=f):f=e[14];let y;e[15]!==c||e[16]!==d||e[17]!==m||e[18]!==f||e[19]!==j?(y=(0,t.jsxs)(se,{className:i,onSelect:c,value:j,children:[d,m,f]}),e[15]=c,e[16]=d,e[17]=m,e[18]=f,e[19]=j,e[20]=y):y=e[20];let v=n&&r,w;return e[21]!==y||e[22]!==v?(w=(0,t.jsxs)(t.Fragment,{children:[y,v]}),e[21]=y,e[22]=v,e[23]=w):w=e[23],w},Be=a=>{let e=(0,A.c)(24),{tables:s,sqlTableContext:l,searchValue:r}=a,{addTableList:o}=fe(),[n,b]=_.useState(!1),[g,N]=_.useState(!1),j;e[0]!==o||e[1]!==l||e[2]!==s.length||e[3]!==n?(j=async()=>{if(s.length===0&&l&&!n){b(!0),N(!0);let{engine:m,database:p,schema:u}=l,f=await Ue.request({engine:m,database:p,schema:u});if(!(f!=null&&f.tables))throw N(!1),Error("No tables available");o({tables:f.tables,sqlTableContext:l}),N(!1)}},e[0]=o,e[1]=l,e[2]=s.length,e[3]=n,e[4]=j):j=e[4];let i;e[5]!==l||e[6]!==s.length||e[7]!==n?(i=[s.length,l,n],e[5]=l,e[6]=s.length,e[7]=n,e[8]=i):i=e[8];let{isPending:c,error:d}=Ie(j,i);if(c||g){let m;return e[9]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(we,{message:"Loading tables...",className:C.tableLoading}),e[9]=m):m=e[9],m}if(d){let m;return e[10]===d?m=e[11]:(m=(0,t.jsx)(_e,{error:d,className:C.tableLoading}),e[10]=d,e[11]=m),m}if(s.length===0){let m;return e[12]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(ae,{content:"No tables found",className:C.tableLoading}),e[12]=m):m=e[12],m}let x;if(e[13]!==r||e[14]!==l||e[15]!==s){let m;e[17]===r?m=e[18]:(m=f=>r?f.name.toLowerCase().includes(r.toLowerCase()):!0,e[17]=r,e[18]=m);let p=s.filter(m),u;e[19]!==r||e[20]!==l?(u=f=>(0,t.jsx)(Ya,{table:f,sqlTableContext:l,isSearching:!!r},f.name),e[19]=r,e[20]=l,e[21]=u):u=e[21],x=p.map(u),e[13]=r,e[14]=l,e[15]=s,e[16]=x}else x=e[16];let h;return e[22]===x?h=e[23]:(h=(0,t.jsx)(t.Fragment,{children:x}),e[22]=x,e[23]=h),h},Ya=a=>{let e=(0,A.c)(64),{table:s,sqlTableContext:l,isSearching:r}=a,{addTable:o}=fe(),[n,b]=_.useState(!1),[g,N]=_.useState(!1),j=s.columns.length>0,i;e[0]!==o||e[1]!==n||e[2]!==l||e[3]!==s.name||e[4]!==j||e[5]!==g?(i=async()=>{if(n&&!j&&l&&!g){N(!0);let{engine:V,database:Z,schema:Ve}=l,ee=await ze.request({engine:V,database:Z,schema:Ve,tableName:s.name});if(!(ee!=null&&ee.table))throw Error("No table details available");o({table:ee.table,sqlTableContext:l})}},e[0]=o,e[1]=n,e[2]=l,e[3]=s.name,e[4]=j,e[5]=g,e[6]=i):i=e[6];let c;e[7]!==n||e[8]!==j?(c=[n,j],e[7]=n,e[8]=j,e[9]=c):c=e[9];let{isFetching:d,isPending:x,error:h}=Ie(i,c),m=K(oa),p=qa(),{createNewCell:u}=la(),f=qe(),y;e[10]!==f||e[11]!==m||e[12]!==u||e[13]!==p||e[14]!==l||e[15]!==s?(y=()=>{Ta({autoInstantiate:m,createNewCell:u,fromCellId:p}),f((()=>{if(s.source_type==="catalog"){let V=l!=null&&l.database?`${l.database}.${s.name}`:s.name;return`${s.engine}.load_table("${V}")`}if(l)return he({table:s,columnName:"*",sqlTableContext:l});switch(s.source_type){case"local":return`mo.ui.table(${s.name})`;case"duckdb":case"connection":return he({table:s,columnName:"*",sqlTableContext:l});default:return ra(s.source_type),""}})())},e[10]=f,e[11]=m,e[12]=u,e[13]=p,e[14]=l,e[15]=s,e[16]=y):y=e[16];let v=y,w;e[17]!==s.num_columns||e[18]!==s.num_rows?(w=()=>{let V=[];return s.num_rows!=null&&V.push(`${s.num_rows} rows`),s.num_columns!=null&&V.push(`${s.num_columns} columns`),V.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:V.join(", ")})})},e[17]=s.num_columns,e[18]=s.num_rows,e[19]=w):w=e[19];let S=w,q;e[20]!==h||e[21]!==d||e[22]!==x||e[23]!==l||e[24]!==s?(q=()=>{if(x||d)return(0,t.jsx)(we,{message:"Loading columns...",className:C.tableLoading});if(h)return(0,t.jsx)(_e,{error:h,className:C.tableLoading});let V=s.columns;return V.length===0?(0,t.jsx)(ae,{content:"No columns found",className:C.tableLoading}):V.map(Z=>(0,t.jsx)(Za,{table:s,column:Z,sqlTableContext:l},Z.name))},e[20]=h,e[21]=d,e[22]=x,e[23]=l,e[24]=s,e[25]=q):q=e[25];let k=q,B;e[26]!==n||e[27]!==r||e[28]!==s.source_type||e[29]!==s.type?(B=()=>{if(s.source_type!=="local")return(0,t.jsx)(s.type==="table"?Re:Ae,{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]=B):B=e[30];let E=B,M=l?`${l.database}.${l.schema}.${s.name}`:s.name,P=l&&(be(l.schema)?C.tableSchemaless:C.tableWithSchema),O=(n||r)&&"font-semibold",$;e[31]!==P||e[32]!==O?($=L("rounded-none group h-8 cursor-pointer",P,O),e[31]=P,e[32]=O,e[33]=$):$=e[33];let F;e[34]===n?F=e[35]:(F=()=>b(!n),e[34]=n,e[35]=F);let I;e[36]===E?I=e[37]:(I=E(),e[36]=E,e[37]=I);let D;e[38]===s.name?D=e[39]:(D=(0,t.jsx)("span",{className:"text-sm",children:s.name}),e[38]=s.name,e[39]=D);let U;e[40]!==I||e[41]!==D?(U=(0,t.jsxs)("div",{className:"flex gap-2 items-center flex-1 pl-1",children:[I,D]}),e[40]=I,e[41]=D,e[42]=U):U=e[42];let z;e[43]===S?z=e[44]:(z=S(),e[43]=S,e[44]=z);let T;e[45]===v?T=e[46]:(T=ia.stopPropagation(()=>v()),e[45]=v,e[46]=T);let X;e[47]===Symbol.for("react.memo_cache_sentinel")?(X=(0,t.jsx)(va,{className:"h-3 w-3"}),e[47]=X):X=e[47];let G;e[48]===T?G=e[49]:(G=(0,t.jsx)(te,{content:"Add table to notebook",delayDuration:400,children:(0,t.jsx)(Q,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:T,children:X})}),e[48]=T,e[49]=G);let W;e[50]!==n||e[51]!==F||e[52]!==U||e[53]!==z||e[54]!==G||e[55]!==$||e[56]!==M?(W=(0,t.jsxs)(se,{className:$,value:M,"aria-selected":n,forceMount:!0,onSelect:F,children:[U,z,G]}),e[50]=n,e[51]=F,e[52]=U,e[53]=z,e[54]=G,e[55]=$,e[56]=M,e[57]=W):W=e[57];let H;e[58]!==n||e[59]!==k?(H=n&&k(),e[58]=n,e[59]=k,e[60]=H):H=e[60];let Y;return e[61]!==W||e[62]!==H?(Y=(0,t.jsxs)(t.Fragment,{children:[W,H]}),e[61]=W,e[62]=H,e[63]=Y):Y=e[63],Y},Za=a=>{var U,z;let e=(0,A.c)(48),{table:s,column:l,sqlTableContext:r}=a,[o,n]=_.useState(!1),b=K(xe),g=ce(aa);b&&o&&n(!1),g(o?T=>new Set([...T,`${s.name}:${l.name}`]):T=>(T.delete(`${s.name}:${l.name}`),new Set(T)));let N=qe(),{columnsPreviews:j}=sa(),i;e[0]!==l.name||e[1]!==s.primary_keys?(i=((U=s.primary_keys)==null?void 0:U.includes(l.name))||!1,e[0]=l.name,e[1]=s.primary_keys,e[2]=i):i=e[2];let c=i,d;e[3]!==l.name||e[4]!==s.indexes?(d=((z=s.indexes)==null?void 0:z.includes(l.name))||!1,e[3]=l.name,e[4]=s.indexes,e[5]=d):d=e[5];let x=d,h;e[6]===N?h=e[7]:(h=T=>{N(T)},e[6]=N,e[7]=h);let m=h,p=et,u=o?"font-semibold":"",f;e[8]!==l.name||e[9]!==u?(f=(0,t.jsx)("span",{className:u,children:l.name}),e[8]=l.name,e[9]=u,e[10]=f):f=e[10];let y=f,v=`${s.name}.${l.name}`,w=`${s.name}.${l.name}`,S;e[11]===o?S=e[12]:(S=()=>n(!o),e[11]=o,e[12]=S);let q=r?C.columnSql:C.columnLocal,k;e[13]===q?k=e[14]:(k=L("flex flex-row gap-2 items-center flex-1",q),e[13]=q,e[14]=k);let B;e[15]!==l.type||e[16]!==y?(B=(0,t.jsx)(ya,{columnName:y,dataType:l.type}),e[15]=l.type,e[16]=y,e[17]=B):B=e[17];let E;e[18]===c?E=e[19]:(E=c&&p({tooltipContent:"Primary key",content:"PK"}),e[18]=c,e[19]=E);let M;e[20]===x?M=e[21]:(M=x&&p({tooltipContent:"Indexed",content:"IDX"}),e[20]=x,e[21]=M);let P;e[22]!==k||e[23]!==B||e[24]!==E||e[25]!==M?(P=(0,t.jsxs)("div",{className:k,children:[B,E,M]}),e[22]=k,e[23]=B,e[24]=E,e[25]=M,e[26]=P):P=e[26];let O;e[27]===l.name?O=e[28]:(O=(0,t.jsx)(te,{content:"Copy column name",delayDuration:400,children:(0,t.jsx)(Q,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:(0,t.jsx)(Ca,{tooltip:!1,value:l.name,className:"h-3 w-3"})})}),e[27]=l.name,e[28]=O);let $;e[29]===l.external_type?$=e[30]:($=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l.external_type}),e[29]=l.external_type,e[30]=$);let F;e[31]!==P||e[32]!==O||e[33]!==$||e[34]!==v||e[35]!==w||e[36]!==S?(F=(0,t.jsxs)(se,{className:"rounded-none py-1 group cursor-pointer",value:w,onSelect:S,children:[P,O,$]},v),e[31]=P,e[32]=O,e[33]=$,e[34]=v,e[35]=w,e[36]=S,e[37]=F):F=e[37];let I;e[38]!==l||e[39]!==j||e[40]!==m||e[41]!==o||e[42]!==r||e[43]!==s?(I=o&&(0,t.jsx)("div",{className:L(C.columnPreview,"pr-2 py-2 bg-(--slate-1) shadow-inner border-b"),children:(0,t.jsx)(ca,{children:(0,t.jsx)(Na,{table:s,column:l,onAddColumnChart:m,preview:j.get(r?`${r.database}.${r.schema}.${s.name}:${l.name}`:`${s.name}:${l.name}`),sqlTableContext:r})})}),e[38]=l,e[39]=j,e[40]=m,e[41]=o,e[42]=r,e[43]=s,e[44]=I):I=e[44];let D;return e[45]!==F||e[46]!==I?(D=(0,t.jsxs)(t.Fragment,{children:[F,I]}),e[45]=F,e[46]=I,e[47]=D):D=e[47],D};function et(a){let{tooltipContent:e,content:s}=a;return(0,t.jsx)(te,{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 us(a){return a}var R={name:"name",type:"type-value",defs:"defs-refs"},at=[{id:R.name,accessorFn:a=>[a.name,a.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,t.jsx)(re,{header:"Name",column:a}),cell:({getValue:a})=>{let[e,s]=a();return(0,t.jsx)(Ua,{name:e,declaredBy:s})}},{id:R.type,accessorFn:a=>[a.dataType,a.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,t.jsx)(re,{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:R.defs,accessorFn:a=>[a.declaredBy,a.usedBy,a.name,a.declaredByNames,a.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:a})=>(0,t.jsx)(re,{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=o=>{let n=ue(o);n&&ie(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)(Fe,{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((o,n)=>(0,t.jsxs)("span",{className:"flex",children:[(0,t.jsx)(Fe,{variant:"focus",cellId:o,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(o)},o),n<e.length-1&&", "]},o))})]}),(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)(wa,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,t.jsx)(Oa,{maxCount:3,cellIds:s,skipScroll:!0,onClick:r})]})]})}}];function tt({variables:a,sort:e,cellIdToIndex:s}){e||(e={id:R.defs,desc:!1});let l=[];switch(e.id){case R.name:l=J(a,r=>r.name);break;case R.type:l=J(a,r=>r.dataType);break;case R.defs:l=J(a,r=>s.get(r.declaredBy[0]));break}return e.desc?l.reverse():l}const De=(0,_.memo)(({className:a,cellIds:e,variables:s})=>{let[l,r]=_.useState([]),[o,n]=_.useState(""),b=Ye(),{locale:g}=_a(),N=(0,_.useMemo)(()=>{let i=c=>{let d=b[c];return He(d)?`cell-${e.indexOf(c)}`:d??`cell-${e.indexOf(c)}`};return Object.values(s).map(c=>({...c,declaredByNames:c.declaredBy.map(i),usedByNames:c.usedBy.map(i)}))},[s,b,e]),j=ha({data:(0,_.useMemo)(()=>{let i=new Map;return e.forEach((c,d)=>i.set(c,d)),tt({variables:N,sort:l[0],cellIdToIndex:i})},[N,l,e]),columns:at,getCoreRowModel:ua(),onGlobalFilterChange:n,getFilteredRowModel:xa(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(i){return i.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:g,onSortingChange:r,getSortedRowModel:da(),state:{sorting:l,globalFilter:o}});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ja,{className:"w-full",placeholder:"Search",value:o,onChange:i=>n(i.target.value)}),(0,t.jsxs)(Ea,{className:L("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,t.jsx)(La,{children:(0,t.jsx)(Te,{className:"whitespace-nowrap text-xs",children:j.getFlatHeaders().map(i=>(0,t.jsx)(Ba,{className:"sticky top-0 bg-background border-b",children:Ne(i.column.columnDef.header,i.getContext())},i.id))})}),(0,t.jsx)(Da,{children:j.getRowModel().rows.map(i=>(0,t.jsx)(Te,{className:"hover:bg-accent",children:i.getVisibleCells().map(c=>(0,t.jsx)(Va,{className:"border-b",children:Ne(c.column.columnDef.cell,c.getContext())},c.id))},i.id))})]})]})});De.displayName="VariableTable";var st=ne(),lt=Ge("marimo:session-panel:state",{openSections:["variables"],hasUserInteracted:!1},Xe),nt=()=>{let a=(0,st.c)(24),e=Qe(),s=ea(),l=K(de),r=K(Le),[o,n]=Me(lt),b=l.length+r.length,g;a[0]!==b||a[1]!==o.hasUserInteracted||a[2]!==o.openSections?(g=!o.hasUserInteracted&&b>0?[...new Set([...o.openSections,"datasources"])]:o.openSections,a[0]=b,a[1]=o.hasUserInteracted,a[2]=o.openSections,a[3]=g):g=a[3];let N=g,j;a[4]===n?j=a[5]:(j=v=>{n({openSections:v,hasUserInteracted:!0})},a[4]=n,a[5]=j);let i=j,c=!N.includes("datasources")&&b>0,d;a[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(le,{className:"w-4 h-4"}),a[6]=d):d=a[6];let x;a[7]!==b||a[8]!==c?(x=c&&(0,t.jsx)(Sa,{variant:"secondary",className:"ml-1 px-1.5 py-0 mb-px text-[10px]",children:b}),a[7]=b,a[8]=c,a[9]=x):x=a[9];let h;a[10]===x?h=a[11]:(h=(0,t.jsx)(Ce,{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide hover:no-underline",children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[d,"Data sources",x]})}),a[10]=x,a[11]=h);let m;a[12]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)($e,{wrapperClassName:"p-0",children:(0,t.jsx)(Ha,{})}),a[12]=m):m=a[12];let p;a[13]===h?p=a[14]:(p=(0,t.jsxs)(ke,{value:"datasources",className:"border-b",children:[h,m]}),a[13]=h,a[14]=p);let u;a[15]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(Ce,{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide hover:no-underline",children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ze,{className:"w-4 h-4"}),"Variables"]})}),a[15]=u):u=a[15];let f;a[16]!==s||a[17]!==e?(f=(0,t.jsxs)(ke,{value:"variables",className:"border-b-0",children:[u,(0,t.jsx)($e,{wrapperClassName:"p-0",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)(De,{cellIds:s.inOrderIds,variables:e})})]}),a[16]=s,a[17]=e,a[18]=f):f=a[18];let y;return a[19]!==i||a[20]!==N||a[21]!==p||a[22]!==f?(y=(0,t.jsxs)(ka,{type:"multiple",value:N,onValueChange:i,className:"flex flex-col h-full overflow-auto",children:[p,f]}),a[19]=i,a[20]=N,a[21]=p,a[22]=f,a[23]=y):y=a[23],y};export{nt as default};
@@ -1 +1 @@
1
- import{s as de}from"./chunk-LvLJmgfZ.js";import{d as D,l as Oe,p as Be,u as ee}from"./useEvent-BhXAndur.js";import{t as Ue}from"./react-Bj1aDYRI.js";import{Kn as Ye,Mt as $e,Un as Fe,Vn as Ge,Zn as Ke,_r as Je,cn as Ze,g as Xe,ln as Qe,m as ce,pn as he,ri as te,t as et,un as tt,w as pe}from"./cells-CiFhRLUd.js";import{t as W}from"./compiler-runtime-B3qBwwSJ.js";import{n as at}from"./assertNever-CBU83Y6o.js";import{s as me}from"./useLifecycle-ClI_npeg.js";import{n as ot}from"./add-database-form-D8ppo-Wx.js";import{n as nt,x as it}from"./ai-model-dropdown-DC4t5PJE.js";import{a as ue,d as I}from"./hotkeys-BHHWjLlp.js";import{y as lt}from"./utils-YqBXNpsM.js";import{n as _,t as fe}from"./constants-B6Cb__3x.js";import{S as ye,h as st,x as rt}from"./config-D2-Bw6QC.js";import{t as dt}from"./jsx-runtime-ZmTK25f3.js";import{r as ct,t as ae}from"./button-CZ3Cs4qb.js";import{r as P}from"./requests-B4FYHTZl.js";import{t as h}from"./createLucideIcon-BCdY6lG5.js";import{a as be,f as ht,i as ke,m as pt,p as xe,u as we}from"./layout-DWzvYkJc.js";import{t as ge}from"./check-Dr3SxUsb.js";import{c as mt,d as je,n as ut,o as ft,r as ve,t as yt}from"./download-CUgZOA9O.js";import{f as bt}from"./maps-D2_Mq1pZ.js";import{r as kt}from"./useCellActionButton-ChlSq72t.js";import{t as xt}from"./copy-D-8y6iMN.js";import{t as wt}from"./download-Dg7clfkc.js";import{t as gt}from"./eye-off-AK_9uodG.js";import{t as jt}from"./file-plus-corner-CvAy4H5W.js";import{t as vt}from"./file-Ch78NKWp.js";import{i as Ct,n as zt,r as Mt,t as Wt}from"./youtube--tNPNRy6.js";import{n as _t,t as St}from"./house-BI81AWSn.js";import{n as At}from"./play-GLWQQs7F.js";import{t as Nt}from"./link-DxicfMbs.js";import{r as Dt}from"./input-DHHmNa19.js";import{t as It}from"./settings-OBbrbhij.js";import{y as Pt}from"./textarea-sdXkC92D.js";import{t as Et}from"./square-DPZjfUaq.js";import{t as C}from"./use-toast-T0_cQDma.js";import{n as Ce,t as Tt}from"./paths-Dfii2bN8.js";import{o as Ht}from"./session-fBtIbMpB.js";import{a as Lt,c as qt,i as Rt,n as Vt,r as Ot,s as Bt,t as Ut}from"./select-B7bfltkI.js";import{t as Yt}from"./tooltip-C_WgOOcZ.js";import{a as ze,i as $t,r as Ft}from"./mode-O-1bKZO6.js";import{o as Gt}from"./alert-dialog-Ctz24SMn.js";import{a as Kt,c as Jt,i as Zt,n as Xt,r as Qt}from"./dialog-tQELcltn.js";import{n as oe}from"./ImperativeModal-DZr52ffu.js";import{r as ea,t as ta}from"./share-rXkgGlhr.js";import{t as U}from"./copy-BaRrAFL-.js";import{r as aa}from"./useRunCells-CNmJhP6h.js";import{a as oa}from"./cell-link-dnd6DfEI.js";import{a as Me}from"./renderShortcut-Xr6z-RjZ.js";import{t as na}from"./icons-DjR3qLG_.js";import{t as ia}from"./links-DgZx-VxW.js";import{r as la,t as sa}from"./hooks-STSuFYve.js";import{t as We}from"./types-DZmRsGZN.js";var ra=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),da=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),_e=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Se=h("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),Ae=h("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),ca=h("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),ha=h("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),pa=h("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Ne=h("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),ma=h("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),ua=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),De=h("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),fa=h("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),ya=h("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Ie=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"}]]),Pe=W(),ne=de(Ue(),1),a=de(dt(),1),Y="https://static.marimo.app";const ba=e=>{let t=(0,Pe.c)(25),{onClose:n}=e,[o,l]=(0,ne.useState)(""),{exportAsHTML:r}=P(),s=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${Y}/static/${s}`,d;t[0]!==r||t[1]!==n||t[2]!==s?(d=async v=>{v.preventDefault(),n();let S=await r({download:!1,includeCode:!0,files:ht.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Y}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:S,path:s})}).catch(()=>{z.dismiss(),C({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:_.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),C({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=s,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(Jt,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Kt,{children:[p,(0,a.jsxs)(Qt,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:Y,target:"_blank",children:Y}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{l(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let m;t[7]===o?m=t[8]:(m=(0,a.jsx)(Dt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=m);let u;t[9]===i?u=t[10]:(u=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(ka,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=u);let f;t[11]!==m||t[12]!==u?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[m,u]}),t[11]=m,t[12]=u,t[13]=f):f=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(ae,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(ae,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await U(i)},children:"Create"}),t[16]=i,t[17]=b);let k;t[18]!==y||t[19]!==b?(k=(0,a.jsxs)(Zt,{children:[y,b]}),t[18]=y,t[19]=b,t[20]=k):k=t[20];let j;return t[21]!==d||t[22]!==k||t[23]!==f?(j=(0,a.jsx)(Xt,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,f,k]})}),t[21]=d,t[22]=k,t[23]=f,t[24]=j):j=t[24],j};var ka=e=>{let t=(0,Pe.c)(8),[n,o]=ne.useState(!1),l;t[0]===e.text?l=t[1]:(l=ct.stopPropagation(async p=>{p.preventDefault(),await U(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=l);let r=l,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(xt,{size:14,strokeWidth:1.5}),t[2]=s):s=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(ae,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:s}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Yt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},xa=W();function wa(){let e=document.getElementsByClassName(fe.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=te.findElement(t);if(!o){I.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:te.parse(o.id)}}}return I.warn("No visible output area found for scroll anchor"),null}function ga(e){if(!e){I.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(te.create(e.cellId));if(!t){I.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${fe.outputArea}`)){I.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ee(){let e=(0,xa.c)(2),t=D(ze),n;return e[0]===t?n=e[1]:(n=()=>{let o=wa();t(l=>({mode:$t(l.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{ga(o)})})},e[0]=t,e[1]=n),n}const Te=Be(!1);var ja=W();const va=()=>{let e=(0,ja.c)(7),{selectedLayout:t}=be(),{setLayoutView:n}=ke();if(ye()&&!he("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Bt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(qt,{placeholder:"Select a view"})}),e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Vt,{children:(0,a.jsxs)(Ot,{children:[(0,a.jsx)(Lt,{children:"View as"}),We.map(za)]})}),e[3]=r):r=e[3];let s;return e[4]!==t||e[5]!==o?(s=(0,a.jsxs)(Ut,{"data-testid":"layout-select",value:t,onValueChange:o,children:[l,r]}),e[4]=t,e[5]=o,e[6]=s):s=e[6],s};function Ca(e){return(0,a.jsx)(He(e),{className:"h-4 w-4"})}function He(e){switch(e){case"vertical":return ma;case"grid":return Mt;case"slides":return De;default:return at(e),Et}}function Le(e){return me(e)}function za(e){return(0,a.jsx)(Rt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ca(e),(0,a.jsx)("span",{children:Le(e)})]})},e)}var Ma=W();function Wa(e){let t=(0,Ma.c)(5),{openPrompt:n,closeModal:o}=oe(),{sendCopy:l}=P(),r;return t[0]!==o||t[1]!==n||t[2]!==l||t[3]!==e?(r=()=>{if(!e)return null;let s=Tt.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Ce.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=s.join(Ce.dirname(e),i);l({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),ia(d)})}})},t[0]=o,t[1]=n,t[2]=l,t[3]=e,t[4]=r):r=t[4],r}const _a=()=>{let{updateCellConfig:e}=pe(),{saveCellConfig:t}=P();return(0,ne.useCallback)(async()=>{let n=new $e,o=ce(),l=o.cellIds.inOrderIds,r={};for(let i of l){if(o.cellData[i]===void 0)continue;let{code:d,config:p}=o.cellData[i];p.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let s=ue.entries(r);if(s.length!==0){await t({configs:r});for(let[i,d]of s)e({cellId:i,config:d})}},[e])};var Sa=W();function qe(){let e=(0,Sa.c)(4),{openConfirm:t}=oe(),n=D(st),{sendRestart:o}=P(),l;return e[0]!==t||e[1]!==o||e[2]!==n?(l=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(Gt,{onClick:async()=>{n({state:rt.CLOSING}),await o(),ea()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=l):l=e[3],l}var Aa=W(),E=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Na(){var se,re;let e=(0,Aa.c)(40),t=oa(),{openModal:n,closeModal:o}=oe(),{toggleApplication:l}=Ze(),{selectedPanel:r}=Qe(),[s]=Oe(ze),i=ee(Ft),d=_a(),[p]=lt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:m,addSetupCellIfDoesntExist:u,collapseAllCells:f,expandAllCells:y}=pe(),b=qe(),k=aa(),j=Wa(t),v=D(Te),S=D(nt),z=D(it),{exportAsMarkdown:$,readCode:A,saveCellConfig:F,updateCellOutputs:G}=P(),K=ee(Xe),J=ee(et),{selectedLayout:Z}=be(),{setLayoutView:X}=ke(),T=Ee(),Q=la(),H=((se=p.sharing)==null?void 0:se.html)??!0,L=((re=p.sharing)==null?void 0:re.wasm)??!0,q;e[0]===Symbol.for("react.memo_cache_sentinel")?(q=he("server_side_pdf_export"),e[0]=q):q=e[0];let le=q,R=le||s.mode==="present",Re=Ga,V;e[1]===Symbol.for("react.memo_cache_sentinel")?(V=(0,a.jsx)(wt,{size:14,strokeWidth:1.5}),e[1]=V):V=e[1];let O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(xe,{size:14,strokeWidth:1.5}),e[2]=O):O=e[2];let M;e[3]===t?M=e[4]:(M=async()=>{if(!t){ie();return}await we({filename:t,includeCode:!0})},e[3]=t,e[4]=M);let B;return e[5]!==u||e[6]!==J||e[7]!==m||e[8]!==o||e[9]!==f||e[10]!==j||e[11]!==y||e[12]!==$||e[13]!==t||e[14]!==K||e[15]!==d||e[16]!==i||e[17]!==n||e[18]!==R||e[19]!==A||e[20]!==b||e[21]!==k||e[22]!==F||e[23]!==Z||e[24]!==r||e[25]!==v||e[26]!==z||e[27]!==X||e[28]!==S||e[29]!==H||e[30]!==L||e[31]!==M||e[32]!==Q||e[33]!==l||e[34]!==T||e[35]!==g||e[36]!==w||e[37]!==G||e[38]!==s.mode?(B=[{icon:V,label:"Download",handle:E,dropdown:[{icon:O,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(xe,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ie();return}await we({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(na,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await $({download:!1});ve(new Blob([c],{type:"text/plain"}),je.toMarkdown(document.title))}},{icon:(0,a.jsx)(pt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await A();ve(new Blob([c.contents],{type:"text/plain"}),je.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:s.mode!=="present",tooltip:s.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Me("global.hideCode",!1)]}),handle:Fa},{icon:(0,a.jsx)(vt,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:!R,tooltip:R?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Me("global.hideCode",!1)]}),handle:async()=>{if(le){if(!t){ie();return}await mt("Downloading PDF...",async N=>{await sa({takeScreenshots:()=>Q({progress:N}),updateCellOutputs:G}),await ut({filename:t,webpdf:!1})});return}let c=new Event("export-beforeprint"),x=new Event("export-afterprint");(function(){window.dispatchEvent(c),setTimeout($a,0),setTimeout(()=>window.dispatchEvent(x),0)})()}}]},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Share",handle:E,hidden:!H&&!L,dropdown:[{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!H,handle:async()=>{n((0,a.jsx)(ba,{onClose:o}))}},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!L,handle:async()=>{await U(ta({code:(await A()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:E,dropdown:tt.flatMap(c=>{let{type:x,Icon:N,hidden:Ve}=c;return Ve?[]:{label:me(x),rightElement:Re(r===x),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),handle:()=>l(x)}})},{icon:(0,a.jsx)(De,{size:14,strokeWidth:1.5}),label:"Present as",handle:E,dropdown:[{icon:s.mode==="present"?(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{T()}},...We.map((c,x)=>{let N=He(c);return{divider:x===0,label:Le(c),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:Z===c&&(0,a.jsx)(ge,{size:14})}),handle:()=>{X(c),s.mode==="edit"&&T()}}})]},{icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ye(),handle:j},{icon:(0,a.jsx)(_e,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await U((await A()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(kt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!K||i,handle:async()=>{let c=Je(ce());await F({configs:ue.fromEntries(c.map(Ya))});for(let x of c)w({cellId:x,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{u({})}},{icon:(0,a.jsx)(Fe,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(ot,{onClose:o}))}},{icon:(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!J||i,handle:()=>{g()}},{icon:(0,a.jsx)(ya,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{m()}},{icon:(0,a.jsx)(gt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:f,redundant:!0},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(Se,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ua)},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Ba)},{icon:(0,a.jsx)(It,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>S(Oa),redundant:!0},{icon:(0,a.jsx)(bt,{size:14,strokeWidth:1.5}),label:"Resources",handle:E,dropdown:[{icon:(0,a.jsx)(Ke,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Va},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Ra},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:qa},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:La},{icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ha}]},{divider:!0,icon:(0,a.jsx)(St,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Ta},{icon:(0,a.jsx)(jt,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ea}].filter(Pa).map(Da),e[5]=u,e[6]=J,e[7]=m,e[8]=o,e[9]=f,e[10]=j,e[11]=y,e[12]=$,e[13]=t,e[14]=K,e[15]=d,e[16]=i,e[17]=n,e[18]=R,e[19]=A,e[20]=b,e[21]=k,e[22]=F,e[23]=Z,e[24]=r,e[25]=v,e[26]=z,e[27]=X,e[28]=S,e[29]=H,e[30]=L,e[31]=M,e[32]=Q,e[33]=l,e[34]=T,e[35]=g,e[36]=w,e[37]=G,e[38]=s.mode,e[39]=B):B=e[39],B}function Da(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Ia)}:e}function Ia(e){return!e.hidden}function Pa(e){return!e.hidden}function Ea(){let e=Ht();window.open(e,"_blank")}function Ta(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ha(){window.open(_.releasesPage,"_blank")}function La(){window.open(_.youtube,"_blank")}function qa(){window.open(_.discordLink,"_blank")}function Ra(){window.open(_.githubPage,"_blank")}function Va(){window.open(_.docsPage,"_blank")}function Oa(e){return!e}function Ba(e){return!e}function Ua(e){return!e}function Ya(e){return[e,{disabled:!1}]}function $a(){return window.print()}async function Fa(){let e=document.getElementById("App");e&&await ft({element:e,filename:document.title,prepare:yt})}function Ga(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(ge,{size:14})})}function ie(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Ee as a,Ae as c,Te as i,Se as l,qe as n,Ie as o,va as r,Ne as s,Na as t,_e as u};
1
+ import{s as de}from"./chunk-LvLJmgfZ.js";import{d as D,l as Oe,p as Be,u as ee}from"./useEvent-BhXAndur.js";import{t as Ue}from"./react-Bj1aDYRI.js";import{Kn as Ye,Mt as $e,Un as Fe,Vn as Ge,Zn as Ke,_r as Je,cn as Ze,g as Xe,ln as Qe,m as ce,pn as he,ri as te,t as et,un as tt,w as pe}from"./cells-CiFhRLUd.js";import{t as W}from"./compiler-runtime-B3qBwwSJ.js";import{n as at}from"./assertNever-CBU83Y6o.js";import{s as me}from"./useLifecycle-ClI_npeg.js";import{n as ot}from"./add-database-form-mXHOy5uZ.js";import{n as nt,x as it}from"./ai-model-dropdown-DC4t5PJE.js";import{a as ue,d as I}from"./hotkeys-BHHWjLlp.js";import{y as lt}from"./utils-YqBXNpsM.js";import{n as _,t as fe}from"./constants-B6Cb__3x.js";import{S as ye,h as st,x as rt}from"./config-D2-Bw6QC.js";import{t as dt}from"./jsx-runtime-ZmTK25f3.js";import{r as ct,t as ae}from"./button-CZ3Cs4qb.js";import{r as P}from"./requests-B4FYHTZl.js";import{t as h}from"./createLucideIcon-BCdY6lG5.js";import{a as be,f as ht,i as ke,m as pt,p as xe,u as we}from"./layout-DWzvYkJc.js";import{t as ge}from"./check-Dr3SxUsb.js";import{c as mt,d as je,n as ut,o as ft,r as ve,t as yt}from"./download-CUgZOA9O.js";import{f as bt}from"./maps-D2_Mq1pZ.js";import{r as kt}from"./useCellActionButton-ChlSq72t.js";import{t as xt}from"./copy-D-8y6iMN.js";import{t as wt}from"./download-Dg7clfkc.js";import{t as gt}from"./eye-off-AK_9uodG.js";import{t as jt}from"./file-plus-corner-CvAy4H5W.js";import{t as vt}from"./file-Ch78NKWp.js";import{i as Ct,n as zt,r as Mt,t as Wt}from"./youtube--tNPNRy6.js";import{n as _t,t as St}from"./house-BI81AWSn.js";import{n as At}from"./play-GLWQQs7F.js";import{t as Nt}from"./link-DxicfMbs.js";import{r as Dt}from"./input-DHHmNa19.js";import{t as It}from"./settings-OBbrbhij.js";import{y as Pt}from"./textarea-sdXkC92D.js";import{t as Et}from"./square-DPZjfUaq.js";import{t as C}from"./use-toast-T0_cQDma.js";import{n as Ce,t as Tt}from"./paths-Dfii2bN8.js";import{o as Ht}from"./session-fBtIbMpB.js";import{a as Lt,c as qt,i as Rt,n as Vt,r as Ot,s as Bt,t as Ut}from"./select-B7bfltkI.js";import{t as Yt}from"./tooltip-C_WgOOcZ.js";import{a as ze,i as $t,r as Ft}from"./mode-O-1bKZO6.js";import{o as Gt}from"./alert-dialog-Ctz24SMn.js";import{a as Kt,c as Jt,i as Zt,n as Xt,r as Qt}from"./dialog-tQELcltn.js";import{n as oe}from"./ImperativeModal-DZr52ffu.js";import{r as ea,t as ta}from"./share-rXkgGlhr.js";import{t as U}from"./copy-BaRrAFL-.js";import{r as aa}from"./useRunCells-CNmJhP6h.js";import{a as oa}from"./cell-link-dnd6DfEI.js";import{a as Me}from"./renderShortcut-Xr6z-RjZ.js";import{t as na}from"./icons-DjR3qLG_.js";import{t as ia}from"./links-DgZx-VxW.js";import{r as la,t as sa}from"./hooks-STSuFYve.js";import{t as We}from"./types-DZmRsGZN.js";var ra=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),da=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),_e=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Se=h("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),Ae=h("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),ca=h("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),ha=h("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),pa=h("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Ne=h("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),ma=h("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),ua=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),De=h("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),fa=h("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),ya=h("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Ie=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"}]]),Pe=W(),ne=de(Ue(),1),a=de(dt(),1),Y="https://static.marimo.app";const ba=e=>{let t=(0,Pe.c)(25),{onClose:n}=e,[o,l]=(0,ne.useState)(""),{exportAsHTML:r}=P(),s=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${Y}/static/${s}`,d;t[0]!==r||t[1]!==n||t[2]!==s?(d=async v=>{v.preventDefault(),n();let S=await r({download:!1,includeCode:!0,files:ht.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Y}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:S,path:s})}).catch(()=>{z.dismiss(),C({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:_.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),C({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=s,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(Jt,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Kt,{children:[p,(0,a.jsxs)(Qt,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:Y,target:"_blank",children:Y}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{l(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let m;t[7]===o?m=t[8]:(m=(0,a.jsx)(Dt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=m);let u;t[9]===i?u=t[10]:(u=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(ka,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=u);let f;t[11]!==m||t[12]!==u?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[m,u]}),t[11]=m,t[12]=u,t[13]=f):f=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(ae,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(ae,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await U(i)},children:"Create"}),t[16]=i,t[17]=b);let k;t[18]!==y||t[19]!==b?(k=(0,a.jsxs)(Zt,{children:[y,b]}),t[18]=y,t[19]=b,t[20]=k):k=t[20];let j;return t[21]!==d||t[22]!==k||t[23]!==f?(j=(0,a.jsx)(Xt,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,f,k]})}),t[21]=d,t[22]=k,t[23]=f,t[24]=j):j=t[24],j};var ka=e=>{let t=(0,Pe.c)(8),[n,o]=ne.useState(!1),l;t[0]===e.text?l=t[1]:(l=ct.stopPropagation(async p=>{p.preventDefault(),await U(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=l);let r=l,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(xt,{size:14,strokeWidth:1.5}),t[2]=s):s=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(ae,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:s}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Yt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},xa=W();function wa(){let e=document.getElementsByClassName(fe.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=te.findElement(t);if(!o){I.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:te.parse(o.id)}}}return I.warn("No visible output area found for scroll anchor"),null}function ga(e){if(!e){I.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(te.create(e.cellId));if(!t){I.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${fe.outputArea}`)){I.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ee(){let e=(0,xa.c)(2),t=D(ze),n;return e[0]===t?n=e[1]:(n=()=>{let o=wa();t(l=>({mode:$t(l.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{ga(o)})})},e[0]=t,e[1]=n),n}const Te=Be(!1);var ja=W();const va=()=>{let e=(0,ja.c)(7),{selectedLayout:t}=be(),{setLayoutView:n}=ke();if(ye()&&!he("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Bt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(qt,{placeholder:"Select a view"})}),e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Vt,{children:(0,a.jsxs)(Ot,{children:[(0,a.jsx)(Lt,{children:"View as"}),We.map(za)]})}),e[3]=r):r=e[3];let s;return e[4]!==t||e[5]!==o?(s=(0,a.jsxs)(Ut,{"data-testid":"layout-select",value:t,onValueChange:o,children:[l,r]}),e[4]=t,e[5]=o,e[6]=s):s=e[6],s};function Ca(e){return(0,a.jsx)(He(e),{className:"h-4 w-4"})}function He(e){switch(e){case"vertical":return ma;case"grid":return Mt;case"slides":return De;default:return at(e),Et}}function Le(e){return me(e)}function za(e){return(0,a.jsx)(Rt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ca(e),(0,a.jsx)("span",{children:Le(e)})]})},e)}var Ma=W();function Wa(e){let t=(0,Ma.c)(5),{openPrompt:n,closeModal:o}=oe(),{sendCopy:l}=P(),r;return t[0]!==o||t[1]!==n||t[2]!==l||t[3]!==e?(r=()=>{if(!e)return null;let s=Tt.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Ce.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=s.join(Ce.dirname(e),i);l({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),ia(d)})}})},t[0]=o,t[1]=n,t[2]=l,t[3]=e,t[4]=r):r=t[4],r}const _a=()=>{let{updateCellConfig:e}=pe(),{saveCellConfig:t}=P();return(0,ne.useCallback)(async()=>{let n=new $e,o=ce(),l=o.cellIds.inOrderIds,r={};for(let i of l){if(o.cellData[i]===void 0)continue;let{code:d,config:p}=o.cellData[i];p.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let s=ue.entries(r);if(s.length!==0){await t({configs:r});for(let[i,d]of s)e({cellId:i,config:d})}},[e])};var Sa=W();function qe(){let e=(0,Sa.c)(4),{openConfirm:t}=oe(),n=D(st),{sendRestart:o}=P(),l;return e[0]!==t||e[1]!==o||e[2]!==n?(l=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(Gt,{onClick:async()=>{n({state:rt.CLOSING}),await o(),ea()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=l):l=e[3],l}var Aa=W(),E=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Na(){var se,re;let e=(0,Aa.c)(40),t=oa(),{openModal:n,closeModal:o}=oe(),{toggleApplication:l}=Ze(),{selectedPanel:r}=Qe(),[s]=Oe(ze),i=ee(Ft),d=_a(),[p]=lt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:m,addSetupCellIfDoesntExist:u,collapseAllCells:f,expandAllCells:y}=pe(),b=qe(),k=aa(),j=Wa(t),v=D(Te),S=D(nt),z=D(it),{exportAsMarkdown:$,readCode:A,saveCellConfig:F,updateCellOutputs:G}=P(),K=ee(Xe),J=ee(et),{selectedLayout:Z}=be(),{setLayoutView:X}=ke(),T=Ee(),Q=la(),H=((se=p.sharing)==null?void 0:se.html)??!0,L=((re=p.sharing)==null?void 0:re.wasm)??!0,q;e[0]===Symbol.for("react.memo_cache_sentinel")?(q=he("server_side_pdf_export"),e[0]=q):q=e[0];let le=q,R=le||s.mode==="present",Re=Ga,V;e[1]===Symbol.for("react.memo_cache_sentinel")?(V=(0,a.jsx)(wt,{size:14,strokeWidth:1.5}),e[1]=V):V=e[1];let O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(xe,{size:14,strokeWidth:1.5}),e[2]=O):O=e[2];let M;e[3]===t?M=e[4]:(M=async()=>{if(!t){ie();return}await we({filename:t,includeCode:!0})},e[3]=t,e[4]=M);let B;return e[5]!==u||e[6]!==J||e[7]!==m||e[8]!==o||e[9]!==f||e[10]!==j||e[11]!==y||e[12]!==$||e[13]!==t||e[14]!==K||e[15]!==d||e[16]!==i||e[17]!==n||e[18]!==R||e[19]!==A||e[20]!==b||e[21]!==k||e[22]!==F||e[23]!==Z||e[24]!==r||e[25]!==v||e[26]!==z||e[27]!==X||e[28]!==S||e[29]!==H||e[30]!==L||e[31]!==M||e[32]!==Q||e[33]!==l||e[34]!==T||e[35]!==g||e[36]!==w||e[37]!==G||e[38]!==s.mode?(B=[{icon:V,label:"Download",handle:E,dropdown:[{icon:O,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(xe,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ie();return}await we({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(na,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await $({download:!1});ve(new Blob([c],{type:"text/plain"}),je.toMarkdown(document.title))}},{icon:(0,a.jsx)(pt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await A();ve(new Blob([c.contents],{type:"text/plain"}),je.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:s.mode!=="present",tooltip:s.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Me("global.hideCode",!1)]}),handle:Fa},{icon:(0,a.jsx)(vt,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:!R,tooltip:R?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Me("global.hideCode",!1)]}),handle:async()=>{if(le){if(!t){ie();return}await mt("Downloading PDF...",async N=>{await sa({takeScreenshots:()=>Q({progress:N}),updateCellOutputs:G}),await ut({filename:t,webpdf:!1})});return}let c=new Event("export-beforeprint"),x=new Event("export-afterprint");(function(){window.dispatchEvent(c),setTimeout($a,0),setTimeout(()=>window.dispatchEvent(x),0)})()}}]},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Share",handle:E,hidden:!H&&!L,dropdown:[{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!H,handle:async()=>{n((0,a.jsx)(ba,{onClose:o}))}},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!L,handle:async()=>{await U(ta({code:(await A()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:E,dropdown:tt.flatMap(c=>{let{type:x,Icon:N,hidden:Ve}=c;return Ve?[]:{label:me(x),rightElement:Re(r===x),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),handle:()=>l(x)}})},{icon:(0,a.jsx)(De,{size:14,strokeWidth:1.5}),label:"Present as",handle:E,dropdown:[{icon:s.mode==="present"?(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{T()}},...We.map((c,x)=>{let N=He(c);return{divider:x===0,label:Le(c),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:Z===c&&(0,a.jsx)(ge,{size:14})}),handle:()=>{X(c),s.mode==="edit"&&T()}}})]},{icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ye(),handle:j},{icon:(0,a.jsx)(_e,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await U((await A()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(kt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!K||i,handle:async()=>{let c=Je(ce());await F({configs:ue.fromEntries(c.map(Ya))});for(let x of c)w({cellId:x,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{u({})}},{icon:(0,a.jsx)(Fe,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(ot,{onClose:o}))}},{icon:(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!J||i,handle:()=>{g()}},{icon:(0,a.jsx)(ya,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{m()}},{icon:(0,a.jsx)(gt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:f,redundant:!0},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(Se,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ua)},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Ba)},{icon:(0,a.jsx)(It,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>S(Oa),redundant:!0},{icon:(0,a.jsx)(bt,{size:14,strokeWidth:1.5}),label:"Resources",handle:E,dropdown:[{icon:(0,a.jsx)(Ke,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Va},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Ra},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:qa},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:La},{icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ha}]},{divider:!0,icon:(0,a.jsx)(St,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Ta},{icon:(0,a.jsx)(jt,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ea}].filter(Pa).map(Da),e[5]=u,e[6]=J,e[7]=m,e[8]=o,e[9]=f,e[10]=j,e[11]=y,e[12]=$,e[13]=t,e[14]=K,e[15]=d,e[16]=i,e[17]=n,e[18]=R,e[19]=A,e[20]=b,e[21]=k,e[22]=F,e[23]=Z,e[24]=r,e[25]=v,e[26]=z,e[27]=X,e[28]=S,e[29]=H,e[30]=L,e[31]=M,e[32]=Q,e[33]=l,e[34]=T,e[35]=g,e[36]=w,e[37]=G,e[38]=s.mode,e[39]=B):B=e[39],B}function Da(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Ia)}:e}function Ia(e){return!e.hidden}function Pa(e){return!e.hidden}function Ea(){let e=Ht();window.open(e,"_blank")}function Ta(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ha(){window.open(_.releasesPage,"_blank")}function La(){window.open(_.youtube,"_blank")}function qa(){window.open(_.discordLink,"_blank")}function Ra(){window.open(_.githubPage,"_blank")}function Va(){window.open(_.docsPage,"_blank")}function Oa(e){return!e}function Ba(e){return!e}function Ua(e){return!e}function Ya(e){return[e,{disabled:!1}]}function $a(){return window.print()}async function Fa(){let e=document.getElementById("App");e&&await ft({element:e,filename:document.title,prepare:yt})}function Ga(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(ge,{size:14})})}function ie(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Ee as a,Ae as c,Te as i,Se as l,qe as n,Ie as o,va as r,Ne as s,Na as t,_e as u};
package/dist/index.html CHANGED
@@ -66,7 +66,7 @@
66
66
  <marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
67
67
  <!-- /TODO -->
68
68
  <title>{{ title }}</title>
69
- <script type="module" crossorigin src="./assets/index-CQLP3a6_.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-CeTG5rkZ.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-DItdS47A.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/clsx-D8GwTfvk.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/cn-BKtXLv3a.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.19.8-dev31",
3
+ "version": "0.19.8-dev33",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -461,6 +461,21 @@ engine = clickhouse_connect.get_client(
461
461
  )"
462
462
  `;
463
463
 
464
+ exports[`generateDatabaseCode > edge cases > clickhouse with proxy_path 1`] = `
465
+ "import clickhouse_connect
466
+ import os
467
+
468
+ _password = os.environ.get("CLICKHOUSE_PASSWORD", "pass")
469
+ engine = clickhouse_connect.get_client(
470
+ host="localhost",
471
+ user="user",
472
+ secure=False,
473
+ port=8123,
474
+ password=_password,
475
+ proxy_path="/clickhouse",
476
+ )"
477
+ `;
478
+
464
479
  exports[`generateDatabaseCode > edge cases > duckdb with relative path 1`] = `
465
480
  "import sqlmodel
466
481
 
@@ -532,6 +532,14 @@ describe("generateDatabaseCode", () => {
532
532
  },
533
533
  "clickhouse_connect",
534
534
  ],
535
+ [
536
+ "clickhouse with proxy_path",
537
+ {
538
+ ...clickhouseConnection,
539
+ proxy_path: "/clickhouse",
540
+ },
541
+ "clickhouse_connect",
542
+ ],
535
543
  [
536
544
  "timeplus with no port",
537
545
  {
@@ -412,6 +412,9 @@ class ClickHouseGenerator extends CodeGenerator<"clickhouse_connect"> {
412
412
  ? this.secrets.print("port", this.connection.port)
413
413
  : undefined,
414
414
  password: this.connection.password ? password : undefined,
415
+ proxy_path: this.connection.proxy_path
416
+ ? this.secrets.print("proxy_path", this.connection.proxy_path)
417
+ : undefined,
415
418
  };
416
419
 
417
420
  return dedent(`
@@ -267,6 +267,15 @@ export const ClickhouseConnectionSchema = z
267
267
  .boolean()
268
268
  .default(false)
269
269
  .describe(FieldOptions.of({ label: "Use HTTPs" })),
270
+ proxy_path: z
271
+ .string()
272
+ .optional()
273
+ .describe(
274
+ FieldOptions.of({
275
+ label: "Proxy Path",
276
+ placeholder: "/clickhouse",
277
+ }),
278
+ ),
270
279
  })
271
280
  .describe(FieldOptions.of({ direction: "two-columns" }));
272
281