@marimo-team/frontend 0.23.11-dev6 → 0.23.11-dev7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{add-connection-dialog-DKp7ZBWA.js → add-connection-dialog-CTDOffvK.js} +32 -32
- package/dist/assets/{command-palette-BtXkFFyo.js → command-palette-CaSDsaso.js} +1 -1
- package/dist/assets/{edit-page-Bq0PlZWO.js → edit-page-C4YQzfXX.js} +4 -4
- package/dist/assets/{file-explorer-panel-D9WR_f2x.js → file-explorer-panel-B93dHKmf.js} +1 -1
- package/dist/assets/{index-Cc7y-hhH.js → index-BT43KXXM.js} +2 -2
- package/dist/assets/{session-panel-BbcFNEli.js → session-panel-DbKOGT8V.js} +1 -1
- package/dist/assets/{useNotebookActions-DWcbGJ23.js → useNotebookActions-di3w31CS.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/editor/connections/components.tsx +13 -0
- package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap +4 -4
- package/src/components/editor/connections/storage/as-code.ts +11 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as ge}from"./chunk-LvLJmgfZ.js";import{d as je,l as ye,p as ve,u as Q}from"./useEvent-D91BmmQi.js";import{t as Xe}from"./react-Bj1aDYRI.js";import{Br as oe,D as Ye,Fr as Ne,Gr as we,Gt as Ze,Hr as ce,In as Se,Ir as _e,Jr as ea,Kr as aa,Kt as ta,Ln as sa,Lr as la,M as na,Ni as Ce,P as ra,Pr as me,Rr as oa,Vr as Ie,Wr as ca,Yr as ke,a as ma,br as ie,f as ia,gr as da,jr as ha,jt as ua,lr as xa,or as pa,qt as fa,sr as ba,vn as ga,yr as ja,zn as ya,zt as va}from"./cells-DGi-ohLl.js";import"./react-dom-CSu739Rf.js";import{t as Pe}from"./compiler-runtime-B3qBwwSJ.js";import{c as Na}from"./utils-CvI-39U6.js";import{t as wa}from"./ErrorBoundary-DyYDV0HI.js";import{t as X}from"./cn-DCUzRj2J.js";import{t as Sa}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-DFky0PAA.js";import{n as _a}from"./multi-map-C4OANz8X.js";import"./popover-CNCYAwbC.js";import{$ as Te,Q as de,et as Ca,f as Fe,g as $e,h as he,m as ue,nt as Ia,p as le,rt as ka,tt as Pa,u as Ta}from"./JsonOutput-CbiJ_QRH.js";import"./download-YWP1Hdr2.js";import{r as Re}from"./radio-group-NLdY8xke.js";import{t as xe}from"./tooltip-B_PkSKN3.js";import{r as Fa,t as ne}from"./button-BbCh-29a.js";import"./dist-D0HyMpgV.js";import{u as Y}from"./arrays-DYDL-3-i.js";import"./cjs-BRGiG41H.js";import"./main-B0OX4z33.js";import"./useNonce-DfoVjkkH.js";import{i as $a}from"./strings-wdPMRf6Z.js";import{r as Ra}from"./requests-DIwGYs0l.js";import{t as Da}from"./createLucideIcon-D5guW7EU.js";import{t as qa}from"./x-C-6liIBr.js";import{a as Va,r as La}from"./tree-actions-DupCr05h.js";import"./markdown-renderer-iZsApCjt.js";import{t as De}from"./add-connection-dialog-DKp7ZBWA.js";import{t as qe}from"./plus-BgB18UzY.js";import{a as Ba}from"./input-DA8xlX70.js";import{n as Ma,o as Ea}from"./column-preview-DypE7iks.js";import{t as Oa}from"./workflow-Bm8qF7yj.js";import"./dist-HyCgERnW.js";import"./dist-BwnT-_gD.js";import"./dist-rBRbke5D.js";import"./dist-RMRSa-Mj.js";import"./dist-BURue7-e.js";import"./session-0B5NBztP.js";import"./purify.es-B9KxLTTS.js";import"./dates-CTxr0EqQ.js";import{t as za}from"./copy-icon-BuRdHNPA.js";import{t as Ua}from"./context-QkTujrKn.js";import"./utils-DCL4n9wx.js";import"./vega-loader.browser-C8wT63Va.js";import"./defaultLocale-BLUna9fQ.js";import"./defaultLocale-DzliDDTm.js";import{t as Ve}from"./cell-link-kkkjfd8C.js";import"./chunk-5FQGJX7Z-D91x7QHS.js";import{r as Aa}from"./html-to-image-Cso6uxBX.js";import{o as Ga}from"./focus-cLz6vpFk.js";import{n as pe}from"./useAsyncData-bgszE9F0.js";import{a as Ha,i as Ka,n as Wa,o as Le,r as Ja,t as Qa}from"./table-BGPSHfig.js";import"./react-resizable-panels.browser.esm-CV8-hvjx.js";import{a as Xa,f as Ya,o as re,t as Za}from"./command-BmOGG6-2.js";import{n as et}from"./icons-Ol38nIbL.js";import{t as at}from"./useDeepCompareMemoize-CVmg-GkP.js";import{t as tt}from"./empty-state-vCWg-_A9.js";import{n as st,t as lt}from"./common-ByASZK7c.js";import{a as nt,i as rt,n as Be,r as Me,t as Ee}from"./components-D8MC-pIV.js";var ot=Da("square-equal",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]),A=Pe(),P=ge(Xe(),1),s=ge(Sa(),1),fe=1;function Oe(a){return 1.75+a*fe}function ct(a){return 3+a*fe}function ze(a){return 3.25+a*fe}var U={engineEmpty:.75,engine:.75,database:1,tableLoading:2.75,tableSchemaless:2,columnLocal:1.25,columnPreview:2.5};function L(a){return{paddingLeft:`${a}rem`}}var mt=ve(a=>{let e=a(_e),t=a(ya),l=a(ma);return Y(e,n=>{if(!n.variable_name)return-1;let m=Object.values(t).find(g=>g.name===n.variable_name);if(!m)return 0;let r=l.inOrderIds.indexOf(m.declaredBy[0]);return r===-1?0:r})});const it=Ce("marimo:datasources:hideEmpty",!1,Se,{getOnInit:!0});function Ue(a){let e=!1,t=[];for(let l of a){if(!ce(l)||!oe(l)){t.push(l);continue}let n=l.child_schemas??[],m=Ue(n);if(l.tables.length===0&&m.length===0){e=!0;continue}if(m===n){t.push(l);continue}e=!0,t.push({...l,child_schemas:m})}return e?t:a}function dt(a){let e=!1,t=[];for(let l of a){if(Ie(l)&&l.schemas.length===0){e=!0;continue}if(l.schemas.length===0){t.push(l);continue}let n=Ue(l.schemas);if(n.length===0){e=!0;continue}if(n===l.schemas){t.push(l);continue}e=!0,t.push({...l,schemas:n})}return e?t:a}const Ae=ve(a=>{let e=new Map(a(ha));for(let t of ke){let l=e.get(t);l&&(l.databases.length===0&&e.delete(t),l.databases.length===1&&l.databases[0].name==="memory"&&l.databases[0].schemas.length===0&&e.delete(t))}return Y([...e.values()],t=>ke.has(t.name)?1:0)}),ht=()=>{let a=(0,A.c)(42),[e,t]=P.useState(""),[l,n]=ye(it),m=je(Ne),r=Q(mt),g=Q(Ae),i;e:{if(!l){i=g;break e}let f,S;a[0]===g?(f=a[1],S=a[2]):(f=!1,S=g.map(I=>{let k=dt(I.databases);return k===I.databases?I:(f=!0,{...I,databases:k})}),a[0]=g,a[1]=f,a[2]=S),i=f?S:g}let x=i;if(r.length===0&&x.length===0){let f;return a[3]===Symbol.for("react.memo_cache_sentinel")?(f=(0,s.jsx)(tt,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:(0,s.jsx)(De,{children:(0,s.jsxs)(ne,{variant:"outline",size:"sm",children:["Add database or catalog",(0,s.jsx)(qe,{className:"h-4 w-4 ml-2"})]})}),icon:(0,s.jsx)(ie,{})}),a[3]=f):f=a[3],f}let b=!!e.trim(),o;a[4]===m?o=a[5]:(o=f=>{m(f.length>0),t(f)},a[4]=m,a[5]=o);let c;a[6]!==e||a[7]!==o?(c=(0,s.jsx)(Xa,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:o,rootClassName:"flex-1 border-r border-b-0"}),a[6]=e,a[7]=o,a[8]=c):c=a[8];let d;a[9]===b?d=a[10]:(d=b&&(0,s.jsx)("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:()=>t(""),children:(0,s.jsx)(qa,{className:"h-4 w-4"})}),a[9]=b,a[10]=d);let y=!l,h;a[11]!==l||a[12]!==n?(h=()=>n(!l),a[11]=l,a[12]=n,a[13]=h):h=a[13];let v;a[14]!==y||a[15]!==h?(v=(0,s.jsx)(Va,{"data-testid":"datasources-hide-empty-button",isVisible:y,onToggle:h,showTooltip:"Show empty schemas and databases",hideTooltip:"Hide empty schemas and databases",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden"}),a[14]=y,a[15]=h,a[16]=v):v=a[16];let j;a[17]===Symbol.for("react.memo_cache_sentinel")?(j=(0,s.jsx)(De,{children:(0,s.jsx)(ne,{variant:"ghost",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden",children:(0,s.jsx)(qe,{className:"h-4 w-4"})})}),a[17]=j):j=a[17];let p;a[18]!==c||a[19]!==d||a[20]!==v?(p=(0,s.jsxs)("div",{className:"flex items-center w-full border-b",children:[c,d,v,j]}),a[18]=c,a[19]=d,a[20]=v,a[21]=p):p=a[21];let N;if(a[22]!==x||a[23]!==b||a[24]!==e){let f;a[26]!==b||a[27]!==e?(f=S=>(0,s.jsx)(ut,{connection:S,hasChildren:S.databases.length>0,children:S.databases.map(I=>(0,s.jsx)(xt,{connection:S,database:I,hasSearch:b,searchValue:e},I.name))},S.name),a[26]=b,a[27]=e,a[28]=f):f=a[28],N=x.map(f),a[22]=x,a[23]=b,a[24]=e,a[25]=N}else N=a[25];let w;a[29]!==x.length||a[30]!==r.length?(w=x.length>0&&r.length>0&&(0,s.jsxs)(Fe,{className:"pr-2",style:L(U.engine),children:[(0,s.jsx)(et,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-xs",children:"Python"})]}),a[29]=x.length,a[30]=r.length,a[31]=w):w=a[31];let u;a[32]!==e||a[33]!==r?(u=r.length>0&&(0,s.jsx)(be,{tables:r,searchValue:e}),a[32]=e,a[33]=r,a[34]=u):u=a[34];let C;a[35]!==w||a[36]!==u||a[37]!==N?(C=(0,s.jsxs)(Ya,{className:"flex flex-col",children:[N,w,u]}),a[35]=w,a[36]=u,a[37]=N,a[38]=C):C=a[38];let _;return a[39]!==C||a[40]!==p?(_=(0,s.jsxs)(Za,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden",shouldFilter:!1,children:[p,C]}),a[39]=C,a[40]=p,a[41]=_):_=a[41],_};var ut=a=>{let e=(0,A.c)(26),{connection:t,children:l,hasChildren:n}=a,m=t.name===ea,r=m?"In-Memory":t.name,{previewDataSourceConnection:g}=Ra(),i;e[0]!==t.name||e[1]!==g?(i=async()=>{await g({engine:t.name})},e[0]=t.name,e[1]=g,e[2]=i):i=e[2];let x=i,b;e[3]===Symbol.for("react.memo_cache_sentinel")?(b=L(U.engine),e[3]=b):b=e[3];let o;e[4]===t.dialect?o=e[5]:(o=(0,s.jsx)(ua,{className:"h-4 w-4 text-muted-foreground",name:t.dialect}),e[4]=t.dialect,e[5]=o);let c;e[6]===t.dialect?c=e[7]:(c=pa(t.dialect),e[6]=t.dialect,e[7]=c);let d;e[8]===c?d=e[9]:(d=(0,s.jsx)("span",{className:"text-xs",children:c}),e[8]=c,e[9]=d);let y=r,h;e[10]===y?h=e[11]:(h=(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(0,s.jsx)(nt,{variableName:y}),")"]}),e[10]=y,e[11]=h);let v;e[12]!==x||e[13]!==m?(v=!m&&(0,s.jsx)(La,{onClick:x,tooltip:"Refresh connection",className:"ml-auto h-4 p-0",iconClassName:"h-3.5 w-3.5"}),e[12]=x,e[13]=m,e[14]=v):v=e[14];let j;e[15]!==o||e[16]!==d||e[17]!==h||e[18]!==v?(j=(0,s.jsxs)(Fe,{className:"pr-2",style:b,children:[o,d,h,v]}),e[15]=o,e[16]=d,e[17]=h,e[18]=v,e[19]=j):j=e[19];let p;e[20]!==l||e[21]!==n?(p=n?l:(0,s.jsx)(le,{content:"No databases available",style:L(U.engineEmpty)}),e[20]=l,e[21]=n,e[22]=p):p=e[22];let N;return e[23]!==p||e[24]!==j?(N=(0,s.jsxs)(s.Fragment,{children:[j,p]}),e[23]=p,e[24]=j,e[25]=N):N=e[25],N},Ge=P.createContext(null);function He(){let a=P.useContext(Ge);if(a==null)throw Error("useDataSourceTree must be used within a DataSourceTreeContext.Provider");return a}function Ke(a,{schema:e,schemaPath:t}){return{engine:a.engineName,database:a.databaseName,schema:e,schemaPath:t,defaultSchema:a.defaultSchema,defaultDatabase:a.defaultDatabase,dialect:a.dialect}}var xt=a=>{let e=(0,A.c)(22),{connection:t,database:l,hasSearch:n,searchValue:m}=a,r;e[0]!==t.default_database||e[1]!==t.default_schema||e[2]!==t.dialect||e[3]!==t.name||e[4]!==l.name||e[5]!==n||e[6]!==m?(r={engineName:t.name,databaseName:l.name,dialect:t.dialect,defaultSchema:t.default_schema,defaultDatabase:t.default_database,hasSearch:n,searchValue:m},e[0]=t.default_database,e[1]=t.default_schema,e[2]=t.dialect,e[3]=t.name,e[4]=l.name,e[5]=n,e[6]=m,e[7]=r):r=e[7];let g=r,i=t.name,x=l.schemas,b;e[8]===l?b=e[9]:(b=Ie(l),e[8]=l,e[9]=b);let o;e[10]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[10]=o):o=e[10];let c;e[11]!==l.schemas||e[12]!==b?(c=(0,s.jsx)(We,{schemas:x,schemasResolved:b,schemaPath:o,depth:0}),e[11]=l.schemas,e[12]=b,e[13]=c):c=e[13];let d;e[14]!==c||e[15]!==g?(d=(0,s.jsx)(Ge.Provider,{value:g,children:c}),e[14]=c,e[15]=g,e[16]=d):d=e[16];let y;return e[17]!==t.name||e[18]!==l||e[19]!==n||e[20]!==d?(y=(0,s.jsx)(pt,{engineName:i,database:l,hasSearch:n,children:d}),e[17]=t.name,e[18]=l,e[19]=n,e[20]=d,e[21]=y):y=e[21],y},pt=a=>{let e=(0,A.c)(26),{hasSearch:t,engineName:l,database:n,children:m}=a,[r,g]=P.useState(!1),[i,x]=P.useState(!1),[b,o]=P.useState(t);b!==t&&(o(t),g(t));let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=L(U.database),e[0]=c):c=e[0];let d;e[1]!==r||e[2]!==i?(d=()=>{g(!r),x(!i)},e[1]=r,e[2]=i,e[3]=d):d=e[3];let y=`${l}:${n.name}`,h;e[4]===r?h=e[5]:(h=(0,s.jsx)($e,{isExpanded:r}),e[4]=r,e[5]=h);let v=i&&r?"text-foreground":"text-muted-foreground",j;e[6]===v?j=e[7]:(j=X("h-4 w-4",v),e[6]=v,e[7]=j);let p;e[8]===j?p=e[9]:(p=(0,s.jsx)(ie,{className:j}),e[8]=j,e[9]=p);let N=i&&r&&"font-semibold",w;e[10]===N?w=e[11]:(w=X(N),e[10]=N,e[11]=w);let u;e[12]===n.name?u=e[13]:(u=n.name===""?(0,s.jsx)("i",{children:"Not connected"}):n.name,e[12]=n.name,e[13]=u);let C;e[14]!==u||e[15]!==w?(C=(0,s.jsx)("span",{className:w,children:u}),e[14]=u,e[15]=w,e[16]=C):C=e[16];let _;e[17]!==C||e[18]!==d||e[19]!==y||e[20]!==h||e[21]!==p?(_=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:c,onSelect:d,value:y,children:[h,p,C]}),e[17]=C,e[18]=d,e[19]=y,e[20]=h,e[21]=p,e[22]=_):_=e[22];let f=r&&m,S;return e[23]!==_||e[24]!==f?(S=(0,s.jsxs)(s.Fragment,{children:[_,f]}),e[23]=_,e[24]=f,e[25]=S):S=e[25],S},We=a=>{let{schemas:e,schemasResolved:t,depth:l}=a,n=He(),{engineName:m,databaseName:r,searchValue:g}=n,{addSchemaList:i}=me(),x=at(a.schemaPath),[b,o]=P.useState(!1),{isPending:c,error:d}=pe(async()=>{if(!t&&m){o(!0);try{i({schemas:(await Ze.request({engine:m,database:r,schemaPath:x})).schemas??[],sqlSchemaContext:{engine:m,database:r,schemaPath:x}})}finally{o(!1)}}},[t,m,r,x]),y=L(Oe(l));return c||b?(0,s.jsx)(he,{message:"Loading schemas...",style:y}):d?(0,s.jsx)(ue,{error:d,style:y}):e.length===0?(0,s.jsx)(le,{content:"No schemas available",style:y}):(0,s.jsx)(s.Fragment,{children:e.map(h=>ca(h.name)?(0,s.jsx)(be,{tables:h.tables,tablesResolved:ce(h),searchValue:g,sqlTableContext:Ke(n,{schema:h.name,schemaPath:x})},h.name):(0,s.jsx)(ft,{schema:h,schemaPath:[...x,h.name],depth:l},h.name))})},ft=a=>{let e=(0,A.c)(36),{schema:t,schemaPath:l,depth:n}=a,m=He(),{databaseName:r,hasSearch:g,searchValue:i}=m,[x,b]=P.useState(g),[o,c]=P.useState(!1),d=`${r}:${l.join(".")}`,y;e[0]===t.child_schemas?y=e[1]:(y=t.child_schemas??[],e[0]=t.child_schemas,e[1]=y);let h=y,v;e[2]===n?v=e[3]:(v=L(Oe(n)),e[2]=n,e[3]=v);let j;e[4]!==x||e[5]!==o?(j=()=>{b(!x),c(!o)},e[4]=x,e[5]=o,e[6]=j):j=e[6];let p;e[7]===x?p=e[8]:(p=(0,s.jsx)($e,{isExpanded:x}),e[7]=x,e[8]=p);let N=o&&x&&"text-foreground",w;e[9]===N?w=e[10]:(w=X("h-4 w-4 text-muted-foreground",N),e[9]=N,e[10]=w);let u;e[11]===w?u=e[12]:(u=(0,s.jsx)(da,{className:w}),e[11]=w,e[12]=u);let C=o&&x&&"font-semibold",_;e[13]===C?_=e[14]:(_=X(C),e[13]=C,e[14]=_);let f;e[15]!==t.name||e[16]!==_?(f=(0,s.jsx)("span",{className:_,children:t.name}),e[15]=t.name,e[16]=_,e[17]=f):f=e[17];let S;e[18]!==v||e[19]!==j||e[20]!==p||e[21]!==u||e[22]!==f||e[23]!==d?(S=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:v,onSelect:j,value:d,children:[p,u,f]}),e[18]=v,e[19]=j,e[20]=p,e[21]=u,e[22]=f,e[23]=d,e[24]=S):S=e[24];let I;e[25]!==h||e[26]!==n||e[27]!==x||e[28]!==t||e[29]!==l||e[30]!==i||e[31]!==m?(I=x&&(0,s.jsxs)(s.Fragment,{children:[(h.length>0||!oe(t))&&(0,s.jsx)(We,{schemas:h,schemasResolved:oe(t),schemaPath:l,depth:n+1}),(0,s.jsx)(be,{tables:t.tables,tablesResolved:ce(t),searchValue:i,tableIndentRem:ct(n),columnIndentRem:ze(n),sqlTableContext:Ke(m,{schema:t.name,schemaPath:l})})]}),e[25]=h,e[26]=n,e[27]=x,e[28]=t,e[29]=l,e[30]=i,e[31]=m,e[32]=I):I=e[32];let k;return e[33]!==S||e[34]!==I?(k=(0,s.jsxs)(s.Fragment,{children:[S,I]}),e[33]=S,e[34]=I,e[35]=k):k=e[35],k},be=a=>{let e=(0,A.c)(31),{tables:t,sqlTableContext:l,searchValue:n,tablesResolved:m,tableIndentRem:r,columnIndentRem:g}=a,i=m===void 0?!0:m,{addTableList:x}=me(),[b,o]=P.useState(!1),c;e[0]!==x||e[1]!==l||e[2]!==i?(c=async()=>{if(!i&&l){o(!0);let{engine:u,database:C,schema:_,schemaPath:f}=l,S=await fa.request({engine:u,database:C,schema:_,schemaPath:f??[]});if(!(S!=null&&S.tables))throw o(!1),Error("No tables available");x({tables:S.tables,sqlTableContext:l}),o(!1)}},e[0]=x,e[1]=l,e[2]=i,e[3]=c):c=e[3];let d;e[4]!==l||e[5]!==i?(d=[i,l],e[4]=l,e[5]=i,e[6]=d):d=e[6];let{isPending:y,error:h}=pe(c,d),v=r??U.tableLoading,j;e[7]===v?j=e[8]:(j=L(v),e[7]=v,e[8]=j);let p=j;if(y||b){let u;return e[9]===p?u=e[10]:(u=(0,s.jsx)(he,{message:"Loading tables...",style:p}),e[9]=p,e[10]=u),u}if(h){let u;return e[11]!==h||e[12]!==p?(u=(0,s.jsx)(ue,{error:h,style:p}),e[11]=h,e[12]=p,e[13]=u):u=e[13],u}if(t.length===0){let u;return e[14]===p?u=e[15]:(u=(0,s.jsx)(le,{content:"No tables found",style:p}),e[14]=p,e[15]=u),u}let N;if(e[16]!==g||e[17]!==n||e[18]!==l||e[19]!==r||e[20]!==t){let u;e[22]===n?u=e[23]:(u=f=>n?f.name.toLowerCase().includes(n.toLowerCase()):!0,e[22]=n,e[23]=u);let C=t.filter(u),_;e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==r?(_=f=>(0,s.jsx)(bt,{table:f,sqlTableContext:l,isSearching:!!n,tableIndentRem:r,columnIndentRem:g},f.name),e[24]=g,e[25]=n,e[26]=l,e[27]=r,e[28]=_):_=e[28],N=C.map(_),e[16]=g,e[17]=n,e[18]=l,e[19]=r,e[20]=t,e[21]=N}else N=e[21];let w;return e[29]===N?w=e[30]:(w=(0,s.jsx)(s.Fragment,{children:N}),e[29]=N,e[30]=w),w},bt=a=>{let e=(0,A.c)(69),{table:t,sqlTableContext:l,isSearching:n,tableIndentRem:m,columnIndentRem:r}=a,{addTable:g}=me(),[i,x]=P.useState(!1),b=t.columns.length>0,o;e[0]!==g||e[1]!==i||e[2]!==l||e[3]!==t.name||e[4]!==b?(o=async()=>{if(i&&!b&&l){let{engine:D,database:ae,schema:te,schemaPath:Qe}=l,se=await ta.request({engine:D,database:ae,schema:te,tableName:t.name,schemaPath:Qe??[]});if(!(se!=null&&se.table))throw Error("No table details available");g({table:se.table,sqlTableContext:l})}},e[0]=g,e[1]=i,e[2]=l,e[3]=t.name,e[4]=b,e[5]=o):o=e[5];let c;e[6]!==i||e[7]!==b?(c=[i,b],e[6]=i,e[7]=b,e[8]=c):c=e[8];let{isFetching:d,isPending:y,error:h}=pe(o,c),v=Q(Na),j=Ga(),{createNewCell:p}=Ye(),N=Re(),w;e[9]!==N||e[10]!==v||e[11]!==p||e[12]!==j||e[13]!==l||e[14]!==t?(w=()=>{Aa({autoInstantiate:v,createNewCell:p,fromCellId:j}),N((()=>{if(t.source_type==="catalog"){let D=l!=null&&l.database?[l.database,...l.schemaPath??[],t.name].join("."):t.name;return`${t.engine}.load_table("${D}")`}if(l)return we({table:t,columnName:"*",sqlTableContext:l});switch(t.source_type){case"local":return`mo.ui.table(${t.name})`;case"duckdb":case"connection":return we({table:t,columnName:"*",sqlTableContext:l});default:return $a(t.source_type),""}})())},e[9]=N,e[10]=v,e[11]=p,e[12]=j,e[13]=l,e[14]=t,e[15]=w):w=e[15];let u=w,C;e[16]!==t.num_columns||e[17]!==t.num_rows?(C=()=>{let D=[];return t.num_rows!=null&&D.push(`${t.num_rows} rows`),t.num_columns!=null&&D.push(`${t.num_columns} columns`),D.length===0?null:(0,s.jsx)("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:D.join(", ")})})},e[16]=t.num_columns,e[17]=t.num_rows,e[18]=C):C=e[18];let _=C,f;e[19]!==r||e[20]!==h||e[21]!==d||e[22]!==y||e[23]!==l||e[24]!==t?(f=()=>{let D=L(r??U.tableLoading);if(y||d)return(0,s.jsx)(he,{message:"Loading columns...",style:D});if(h)return(0,s.jsx)(ue,{error:h,style:D});let ae=t.columns;return ae.length===0?(0,s.jsx)(le,{content:"No columns found",style:D}):ae.map(te=>(0,s.jsx)(gt,{table:t,column:te,sqlTableContext:l,columnIndentRem:r},te.name))},e[19]=r,e[20]=h,e[21]=d,e[22]=y,e[23]=l,e[24]=t,e[25]=f):f=e[25];let S=f,I;e[26]!==i||e[27]!==n||e[28]!==t.source_type||e[29]!==t.type?(I=()=>{if(t.source_type!=="local")return(0,s.jsx)(t.type==="table"?xa:ja,{className:"h-3 w-3",strokeWidth:i||n?2.5:void 0})},e[26]=i,e[27]=n,e[28]=t.source_type,e[29]=t.type,e[30]=I):I=e[30];let k=I,q;e[31]!==l||e[32]!==t.name?(q=aa(l,t.name),e[31]=l,e[32]=t.name,e[33]=q):q=e[33];let B=q,M=m??(l?U.tableSchemaless:0),E=(i||n)&&"font-semibold",T;e[34]===E?T=e[35]:(T=X("rounded-none group h-8 cursor-pointer",E),e[34]=E,e[35]=T);let F;e[36]===M?F=e[37]:(F=L(M),e[36]=M,e[37]=F);let $;e[38]===i?$=e[39]:($=()=>x(!i),e[38]=i,e[39]=$);let V;e[40]===k?V=e[41]:(V=k(),e[40]=k,e[41]=V);let O;e[42]===t.name?O=e[43]:(O=(0,s.jsx)("span",{className:"text-sm",children:t.name}),e[42]=t.name,e[43]=O);let z;e[44]!==V||e[45]!==O?(z=(0,s.jsxs)("div",{className:"flex gap-2 items-center flex-1 pl-1",children:[V,O]}),e[44]=V,e[45]=O,e[46]=z):z=e[46];let R;e[47]===_?R=e[48]:(R=_(),e[47]=_,e[48]=R);let H;e[49]===u?H=e[50]:(H=Fa.stopPropagation(()=>u()),e[49]=u,e[50]=H);let Z;e[51]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,s.jsx)(Ea,{className:"h-3 w-3"}),e[51]=Z):Z=e[51];let K;e[52]===H?K=e[53]:(K=(0,s.jsx)(xe,{content:"Add table to notebook",delayDuration:400,children:(0,s.jsx)(ne,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:H,children:Z})}),e[52]=H,e[53]=K);let W;e[54]!==i||e[55]!==F||e[56]!==$||e[57]!==z||e[58]!==R||e[59]!==K||e[60]!==T||e[61]!==B?(W=(0,s.jsxs)(re,{className:T,style:F,value:B,"aria-selected":i,forceMount:!0,onSelect:$,children:[z,R,K]}),e[54]=i,e[55]=F,e[56]=$,e[57]=z,e[58]=R,e[59]=K,e[60]=T,e[61]=B,e[62]=W):W=e[62];let J;e[63]!==i||e[64]!==S?(J=i&&S(),e[63]=i,e[64]=S,e[65]=J):J=e[65];let ee;return e[66]!==W||e[67]!==J?(ee=(0,s.jsxs)(s.Fragment,{children:[W,J]}),e[66]=W,e[67]=J,e[68]=ee):ee=e[68],ee},gt=a=>{var O,z;let e=(0,A.c)(51),{table:t,column:l,sqlTableContext:n,columnIndentRem:m}=a,[r,g]=P.useState(!1),i=Q(Ne),x=je(la);i&&r&&g(!1),x(r?R=>new Set([...R,`${t.name}:${l.name}`]):R=>(R.delete(`${t.name}:${l.name}`),new Set(R)));let b=Re(),{columnsPreviews:o}=oa(),c;e[0]!==l.name||e[1]!==t.primary_keys?(c=((O=t.primary_keys)==null?void 0:O.includes(l.name))||!1,e[0]=l.name,e[1]=t.primary_keys,e[2]=c):c=e[2];let d=c,y;e[3]!==l.name||e[4]!==t.indexes?(y=((z=t.indexes)==null?void 0:z.includes(l.name))||!1,e[3]=l.name,e[4]=t.indexes,e[5]=y):y=e[5];let h=y,v;e[6]===b?v=e[7]:(v=R=>{b(R)},e[6]=b,e[7]=v);let j=v,p=jt,N=r?"font-semibold":"",w;e[8]!==l.name||e[9]!==N?(w=(0,s.jsx)("span",{className:N,children:l.name}),e[8]=l.name,e[9]=N,e[10]=w):w=e[10];let u=w,C=`${t.name}.${l.name}`,_=`${t.name}.${l.name}`,f;e[11]===r?f=e[12]:(f=()=>g(!r),e[11]=r,e[12]=f);let S;e[13]!==m||e[14]!==n?(S=m??(n?ze(0):U.columnLocal),e[13]=m,e[14]=n,e[15]=S):S=e[15];let I;e[16]===S?I=e[17]:(I=L(S),e[16]=S,e[17]=I);let k;e[18]!==l.type||e[19]!==u?(k=(0,s.jsx)(Ta,{columnName:u,dataType:l.type}),e[18]=l.type,e[19]=u,e[20]=k):k=e[20];let q;e[21]===d?q=e[22]:(q=d&&p({tooltipContent:"Primary key",content:"PK"}),e[21]=d,e[22]=q);let B;e[23]===h?B=e[24]:(B=h&&p({tooltipContent:"Indexed",content:"IDX"}),e[23]=h,e[24]=B);let M;e[25]!==I||e[26]!==k||e[27]!==q||e[28]!==B?(M=(0,s.jsxs)("div",{className:"flex flex-row gap-2 items-center flex-1",style:I,children:[k,q,B]}),e[25]=I,e[26]=k,e[27]=q,e[28]=B,e[29]=M):M=e[29];let E;e[30]===l.name?E=e[31]:(E=(0,s.jsx)(xe,{content:"Copy column name",delayDuration:400,children:(0,s.jsx)(ne,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:(0,s.jsx)(za,{tooltip:!1,value:l.name,className:"h-3 w-3"})})}),e[30]=l.name,e[31]=E);let T;e[32]===l.external_type?T=e[33]:(T=(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:l.external_type}),e[32]=l.external_type,e[33]=T);let F;e[34]!==M||e[35]!==E||e[36]!==T||e[37]!==C||e[38]!==_||e[39]!==f?(F=(0,s.jsxs)(re,{className:"rounded-none py-1 group cursor-pointer",value:_,onSelect:f,children:[M,E,T]},C),e[34]=M,e[35]=E,e[36]=T,e[37]=C,e[38]=_,e[39]=f,e[40]=F):F=e[40];let $;e[41]!==l||e[42]!==o||e[43]!==j||e[44]!==r||e[45]!==n||e[46]!==t?($=r&&(0,s.jsx)("div",{className:"pr-2 py-2 bg-(--slate-1) shadow-inner border-b",style:L(U.columnPreview),children:(0,s.jsx)(wa,{children:(0,s.jsx)(Ma,{table:t,column:l,onAddColumnChart:j,preview:o.get(n?`${n.database}.${n.schema}.${t.name}:${l.name}`:`${t.name}:${l.name}`),sqlTableContext:n})})}),e[41]=l,e[42]=o,e[43]=j,e[44]=r,e[45]=n,e[46]=t,e[47]=$):$=e[47];let V;return e[48]!==F||e[49]!==$?(V=(0,s.jsxs)(s.Fragment,{children:[F,$]}),e[48]=F,e[49]=$,e[50]=V):V=e[50],V};function jt(a){let{tooltipContent:e,content:t}=a;return(0,s.jsx)(xe,{content:e,delayDuration:100,children:(0,s.jsx)("span",{className:"text-xs text-black bg-gray-100 dark:invert rounded px-1",children:t})})}function Rs(a){return a}var G={name:"name",type:"type-value",defs:"defs-refs"},yt=[{id:G.name,accessorFn:a=>[a.name,a.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,s.jsx)(de,{header:"Name",column:a}),cell:({getValue:a})=>{let[e,t]=a();return(0,s.jsx)(lt,{name:e,declaredBy:t})}},{id:G.type,accessorFn:a=>[a.dataType,a.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,s.jsx)(de,{header:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{children:"Type"}),(0,s.jsx)("span",{children:"Value"})]}),column:a}),cell:({getValue:a})=>{let[e,t]=a();return(0,s.jsxs)("div",{className:"max-w-[150px]",children:[(0,s.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:e}),(0,s.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:t??"",children:t})]})}},{id:G.defs,accessorFn:a=>[a.declaredBy,a.usedBy,a.name,a.declaredByNames,a.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:a})=>(0,s.jsx)(de,{header:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{children:"Declared By"}),(0,s.jsx)("span",{children:"Used By"})]}),column:a}),cell:({getValue:a})=>{let[e,t,l]=a(),n=m=>{let r=ia(m);r&&ga(r,l)};return(0,s.jsxs)("div",{className:"flex flex-col gap-1 py-1",children:[(0,s.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[(0,s.jsx)("span",{title:"Declared by",children:(0,s.jsx)(ot,{className:"w-3.5 h-3.5 text-muted-foreground"})}),e.length===1?(0,s.jsx)(Ve,{variant:"focus",cellId:e[0],skipScroll:!0,onClick:()=>n(e[0])}):(0,s.jsx)("div",{className:"text-destructive flex flex-row gap-2",children:e.slice(0,3).map((m,r)=>(0,s.jsxs)("span",{className:"flex",children:[(0,s.jsx)(Ve,{variant:"focus",cellId:m,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>n(m)},m),r<e.length-1&&", "]},m))})]}),(0,s.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[(0,s.jsx)("span",{title:"Used by",children:(0,s.jsx)(Oa,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,s.jsx)(st,{maxCount:3,cellIds:t,skipScroll:!0,onClick:n})]})]})}}];function vt({variables:a,sort:e,cellIdToIndex:t}){e||(e={id:G.defs,desc:!1});let l=[];switch(e.id){case G.name:l=Y(a,n=>n.name);break;case G.type:l=Y(a,n=>n.dataType);break;case G.defs:l=Y(a,n=>t.get(n.declaredBy[0]));break}return e.desc?l.toReversed():l}const Je=(0,P.memo)(({className:a,cellIds:e,variables:t})=>{let[l,n]=P.useState([]),[m,r]=P.useState(""),g=ra(),{locale:i}=Ua(),x=(0,P.useMemo)(()=>{let o=c=>{let d=g[c];return va(d)?`cell-${e.indexOf(c)}`:d??`cell-${e.indexOf(c)}`};return Object.values(t).map(c=>({...c,declaredByNames:c.declaredBy.map(o),usedByNames:c.usedBy.map(o)}))},[t,g,e]),b=Ca({data:(0,P.useMemo)(()=>{let o=new Map;return e.forEach((c,d)=>o.set(c,d)),vt({variables:x,sort:l[0],cellIdToIndex:o})},[x,l,e]),columns:yt,getCoreRowModel:Pa(),onGlobalFilterChange:r,getFilteredRowModel:Ia(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(o){return o.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:i,onSortingChange:n,getSortedRowModel:ka(),state:{sorting:l,globalFilter:m}});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Ba,{className:"w-full",placeholder:"Search",value:m,onChange:o=>r(o.target.value)}),(0,s.jsxs)(Qa,{className:X("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,s.jsx)(Ha,{children:(0,s.jsx)(Le,{className:"whitespace-nowrap text-xs",children:b.getFlatHeaders().map(o=>(0,s.jsx)(Ka,{className:"sticky top-0 bg-background border-b",children:Te(o.column.columnDef.header,o.getContext())},o.id))})}),(0,s.jsx)(Wa,{children:b.getRowModel().rows.map(o=>(0,s.jsx)(Le,{className:"hover:bg-accent",children:o.getVisibleCells().map(c=>(0,s.jsx)(Ja,{className:"border-b",children:Te(c.column.columnDef.cell,c.getContext())},c.id))},o.id))})]})]})});Je.displayName="VariableTable";var Nt=Pe(),wt=Ce("marimo:session-panel:state",{openSections:["variables"],hasUserInteracted:!1},Se),St=()=>{let a=(0,Nt.c)(24),e=sa(),t=na(),l=Q(_e),n=Q(Ae),[m,r]=ye(wt),g=l.length+n.length,i;a[0]!==g||a[1]!==m.hasUserInteracted||a[2]!==m.openSections?(i=!m.hasUserInteracted&&g>0?[...new Set([...m.openSections,"datasources"])]:m.openSections,a[0]=g,a[1]=m.hasUserInteracted,a[2]=m.openSections,a[3]=i):i=a[3];let x=i,b;a[4]===r?b=a[5]:(b=u=>{r({openSections:u,hasUserInteracted:!0})},a[4]=r,a[5]=b);let o=b,c=!x.includes("datasources")&&g>0,d;a[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(ie,{className:"w-4 h-4"}),a[6]=d):d=a[6];let y;a[7]!==g||a[8]!==c?(y=c&&(0,s.jsx)(rt,{children:g}),a[7]=g,a[8]=c,a[9]=y):y=a[9];let h;a[10]===y?h=a[11]:(h=(0,s.jsxs)(Me,{children:[d,"Data sources",y]}),a[10]=y,a[11]=h);let v;a[12]===Symbol.for("react.memo_cache_sentinel")?(v=(0,s.jsx)(Ee,{children:(0,s.jsx)(ht,{})}),a[12]=v):v=a[12];let j;a[13]===h?j=a[14]:(j=(0,s.jsxs)(Be,{value:"datasources",children:[h,v]}),a[13]=h,a[14]=j);let p;a[15]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsxs)(Me,{children:[(0,s.jsx)(ba,{className:"w-4 h-4"}),"Variables"]}),a[15]=p):p=a[15];let N;a[16]!==t||a[17]!==e?(N=(0,s.jsxs)(Be,{value:"variables",lastItem:!0,children:[p,(0,s.jsx)(Ee,{children:Object.keys(e).length===0?(0,s.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No variables defined"}):(0,s.jsx)(Je,{cellIds:t.inOrderIds,variables:e})})]}),a[16]=t,a[17]=e,a[18]=N):N=a[18];let w;return a[19]!==o||a[20]!==x||a[21]!==j||a[22]!==N?(w=(0,s.jsxs)(_a,{type:"multiple",value:x,onValueChange:o,className:"flex flex-col h-full overflow-auto",children:[j,N]}),a[19]=o,a[20]=x,a[21]=j,a[22]=N,a[23]=w):w=a[23],w};export{St as default};
|
|
1
|
+
import{s as ge}from"./chunk-LvLJmgfZ.js";import{d as je,l as ye,p as ve,u as Q}from"./useEvent-D91BmmQi.js";import{t as Xe}from"./react-Bj1aDYRI.js";import{Br as oe,D as Ye,Fr as Ne,Gr as we,Gt as Ze,Hr as ce,In as Se,Ir as _e,Jr as ea,Kr as aa,Kt as ta,Ln as sa,Lr as la,M as na,Ni as Ce,P as ra,Pr as me,Rr as oa,Vr as Ie,Wr as ca,Yr as ke,a as ma,br as ie,f as ia,gr as da,jr as ha,jt as ua,lr as xa,or as pa,qt as fa,sr as ba,vn as ga,yr as ja,zn as ya,zt as va}from"./cells-DGi-ohLl.js";import"./react-dom-CSu739Rf.js";import{t as Pe}from"./compiler-runtime-B3qBwwSJ.js";import{c as Na}from"./utils-CvI-39U6.js";import{t as wa}from"./ErrorBoundary-DyYDV0HI.js";import{t as X}from"./cn-DCUzRj2J.js";import{t as Sa}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-DFky0PAA.js";import{n as _a}from"./multi-map-C4OANz8X.js";import"./popover-CNCYAwbC.js";import{$ as Te,Q as de,et as Ca,f as Fe,g as $e,h as he,m as ue,nt as Ia,p as le,rt as ka,tt as Pa,u as Ta}from"./JsonOutput-CbiJ_QRH.js";import"./download-YWP1Hdr2.js";import{r as Re}from"./radio-group-NLdY8xke.js";import{t as xe}from"./tooltip-B_PkSKN3.js";import{r as Fa,t as ne}from"./button-BbCh-29a.js";import"./dist-D0HyMpgV.js";import{u as Y}from"./arrays-DYDL-3-i.js";import"./cjs-BRGiG41H.js";import"./main-B0OX4z33.js";import"./useNonce-DfoVjkkH.js";import{i as $a}from"./strings-wdPMRf6Z.js";import{r as Ra}from"./requests-DIwGYs0l.js";import{t as Da}from"./createLucideIcon-D5guW7EU.js";import{t as qa}from"./x-C-6liIBr.js";import{a as Va,r as La}from"./tree-actions-DupCr05h.js";import"./markdown-renderer-iZsApCjt.js";import{t as De}from"./add-connection-dialog-CTDOffvK.js";import{t as qe}from"./plus-BgB18UzY.js";import{a as Ba}from"./input-DA8xlX70.js";import{n as Ma,o as Ea}from"./column-preview-DypE7iks.js";import{t as Oa}from"./workflow-Bm8qF7yj.js";import"./dist-HyCgERnW.js";import"./dist-BwnT-_gD.js";import"./dist-rBRbke5D.js";import"./dist-RMRSa-Mj.js";import"./dist-BURue7-e.js";import"./session-0B5NBztP.js";import"./purify.es-B9KxLTTS.js";import"./dates-CTxr0EqQ.js";import{t as za}from"./copy-icon-BuRdHNPA.js";import{t as Ua}from"./context-QkTujrKn.js";import"./utils-DCL4n9wx.js";import"./vega-loader.browser-C8wT63Va.js";import"./defaultLocale-BLUna9fQ.js";import"./defaultLocale-DzliDDTm.js";import{t as Ve}from"./cell-link-kkkjfd8C.js";import"./chunk-5FQGJX7Z-D91x7QHS.js";import{r as Aa}from"./html-to-image-Cso6uxBX.js";import{o as Ga}from"./focus-cLz6vpFk.js";import{n as pe}from"./useAsyncData-bgszE9F0.js";import{a as Ha,i as Ka,n as Wa,o as Le,r as Ja,t as Qa}from"./table-BGPSHfig.js";import"./react-resizable-panels.browser.esm-CV8-hvjx.js";import{a as Xa,f as Ya,o as re,t as Za}from"./command-BmOGG6-2.js";import{n as et}from"./icons-Ol38nIbL.js";import{t as at}from"./useDeepCompareMemoize-CVmg-GkP.js";import{t as tt}from"./empty-state-vCWg-_A9.js";import{n as st,t as lt}from"./common-ByASZK7c.js";import{a as nt,i as rt,n as Be,r as Me,t as Ee}from"./components-D8MC-pIV.js";var ot=Da("square-equal",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]),A=Pe(),P=ge(Xe(),1),s=ge(Sa(),1),fe=1;function Oe(a){return 1.75+a*fe}function ct(a){return 3+a*fe}function ze(a){return 3.25+a*fe}var U={engineEmpty:.75,engine:.75,database:1,tableLoading:2.75,tableSchemaless:2,columnLocal:1.25,columnPreview:2.5};function L(a){return{paddingLeft:`${a}rem`}}var mt=ve(a=>{let e=a(_e),t=a(ya),l=a(ma);return Y(e,n=>{if(!n.variable_name)return-1;let m=Object.values(t).find(g=>g.name===n.variable_name);if(!m)return 0;let r=l.inOrderIds.indexOf(m.declaredBy[0]);return r===-1?0:r})});const it=Ce("marimo:datasources:hideEmpty",!1,Se,{getOnInit:!0});function Ue(a){let e=!1,t=[];for(let l of a){if(!ce(l)||!oe(l)){t.push(l);continue}let n=l.child_schemas??[],m=Ue(n);if(l.tables.length===0&&m.length===0){e=!0;continue}if(m===n){t.push(l);continue}e=!0,t.push({...l,child_schemas:m})}return e?t:a}function dt(a){let e=!1,t=[];for(let l of a){if(Ie(l)&&l.schemas.length===0){e=!0;continue}if(l.schemas.length===0){t.push(l);continue}let n=Ue(l.schemas);if(n.length===0){e=!0;continue}if(n===l.schemas){t.push(l);continue}e=!0,t.push({...l,schemas:n})}return e?t:a}const Ae=ve(a=>{let e=new Map(a(ha));for(let t of ke){let l=e.get(t);l&&(l.databases.length===0&&e.delete(t),l.databases.length===1&&l.databases[0].name==="memory"&&l.databases[0].schemas.length===0&&e.delete(t))}return Y([...e.values()],t=>ke.has(t.name)?1:0)}),ht=()=>{let a=(0,A.c)(42),[e,t]=P.useState(""),[l,n]=ye(it),m=je(Ne),r=Q(mt),g=Q(Ae),i;e:{if(!l){i=g;break e}let f,S;a[0]===g?(f=a[1],S=a[2]):(f=!1,S=g.map(I=>{let k=dt(I.databases);return k===I.databases?I:(f=!0,{...I,databases:k})}),a[0]=g,a[1]=f,a[2]=S),i=f?S:g}let x=i;if(r.length===0&&x.length===0){let f;return a[3]===Symbol.for("react.memo_cache_sentinel")?(f=(0,s.jsx)(tt,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:(0,s.jsx)(De,{children:(0,s.jsxs)(ne,{variant:"outline",size:"sm",children:["Add database or catalog",(0,s.jsx)(qe,{className:"h-4 w-4 ml-2"})]})}),icon:(0,s.jsx)(ie,{})}),a[3]=f):f=a[3],f}let b=!!e.trim(),o;a[4]===m?o=a[5]:(o=f=>{m(f.length>0),t(f)},a[4]=m,a[5]=o);let c;a[6]!==e||a[7]!==o?(c=(0,s.jsx)(Xa,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:o,rootClassName:"flex-1 border-r border-b-0"}),a[6]=e,a[7]=o,a[8]=c):c=a[8];let d;a[9]===b?d=a[10]:(d=b&&(0,s.jsx)("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:()=>t(""),children:(0,s.jsx)(qa,{className:"h-4 w-4"})}),a[9]=b,a[10]=d);let y=!l,h;a[11]!==l||a[12]!==n?(h=()=>n(!l),a[11]=l,a[12]=n,a[13]=h):h=a[13];let v;a[14]!==y||a[15]!==h?(v=(0,s.jsx)(Va,{"data-testid":"datasources-hide-empty-button",isVisible:y,onToggle:h,showTooltip:"Show empty schemas and databases",hideTooltip:"Hide empty schemas and databases",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden"}),a[14]=y,a[15]=h,a[16]=v):v=a[16];let j;a[17]===Symbol.for("react.memo_cache_sentinel")?(j=(0,s.jsx)(De,{children:(0,s.jsx)(ne,{variant:"ghost",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden",children:(0,s.jsx)(qe,{className:"h-4 w-4"})})}),a[17]=j):j=a[17];let p;a[18]!==c||a[19]!==d||a[20]!==v?(p=(0,s.jsxs)("div",{className:"flex items-center w-full border-b",children:[c,d,v,j]}),a[18]=c,a[19]=d,a[20]=v,a[21]=p):p=a[21];let N;if(a[22]!==x||a[23]!==b||a[24]!==e){let f;a[26]!==b||a[27]!==e?(f=S=>(0,s.jsx)(ut,{connection:S,hasChildren:S.databases.length>0,children:S.databases.map(I=>(0,s.jsx)(xt,{connection:S,database:I,hasSearch:b,searchValue:e},I.name))},S.name),a[26]=b,a[27]=e,a[28]=f):f=a[28],N=x.map(f),a[22]=x,a[23]=b,a[24]=e,a[25]=N}else N=a[25];let w;a[29]!==x.length||a[30]!==r.length?(w=x.length>0&&r.length>0&&(0,s.jsxs)(Fe,{className:"pr-2",style:L(U.engine),children:[(0,s.jsx)(et,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-xs",children:"Python"})]}),a[29]=x.length,a[30]=r.length,a[31]=w):w=a[31];let u;a[32]!==e||a[33]!==r?(u=r.length>0&&(0,s.jsx)(be,{tables:r,searchValue:e}),a[32]=e,a[33]=r,a[34]=u):u=a[34];let C;a[35]!==w||a[36]!==u||a[37]!==N?(C=(0,s.jsxs)(Ya,{className:"flex flex-col",children:[N,w,u]}),a[35]=w,a[36]=u,a[37]=N,a[38]=C):C=a[38];let _;return a[39]!==C||a[40]!==p?(_=(0,s.jsxs)(Za,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden",shouldFilter:!1,children:[p,C]}),a[39]=C,a[40]=p,a[41]=_):_=a[41],_};var ut=a=>{let e=(0,A.c)(26),{connection:t,children:l,hasChildren:n}=a,m=t.name===ea,r=m?"In-Memory":t.name,{previewDataSourceConnection:g}=Ra(),i;e[0]!==t.name||e[1]!==g?(i=async()=>{await g({engine:t.name})},e[0]=t.name,e[1]=g,e[2]=i):i=e[2];let x=i,b;e[3]===Symbol.for("react.memo_cache_sentinel")?(b=L(U.engine),e[3]=b):b=e[3];let o;e[4]===t.dialect?o=e[5]:(o=(0,s.jsx)(ua,{className:"h-4 w-4 text-muted-foreground",name:t.dialect}),e[4]=t.dialect,e[5]=o);let c;e[6]===t.dialect?c=e[7]:(c=pa(t.dialect),e[6]=t.dialect,e[7]=c);let d;e[8]===c?d=e[9]:(d=(0,s.jsx)("span",{className:"text-xs",children:c}),e[8]=c,e[9]=d);let y=r,h;e[10]===y?h=e[11]:(h=(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(0,s.jsx)(nt,{variableName:y}),")"]}),e[10]=y,e[11]=h);let v;e[12]!==x||e[13]!==m?(v=!m&&(0,s.jsx)(La,{onClick:x,tooltip:"Refresh connection",className:"ml-auto h-4 p-0",iconClassName:"h-3.5 w-3.5"}),e[12]=x,e[13]=m,e[14]=v):v=e[14];let j;e[15]!==o||e[16]!==d||e[17]!==h||e[18]!==v?(j=(0,s.jsxs)(Fe,{className:"pr-2",style:b,children:[o,d,h,v]}),e[15]=o,e[16]=d,e[17]=h,e[18]=v,e[19]=j):j=e[19];let p;e[20]!==l||e[21]!==n?(p=n?l:(0,s.jsx)(le,{content:"No databases available",style:L(U.engineEmpty)}),e[20]=l,e[21]=n,e[22]=p):p=e[22];let N;return e[23]!==p||e[24]!==j?(N=(0,s.jsxs)(s.Fragment,{children:[j,p]}),e[23]=p,e[24]=j,e[25]=N):N=e[25],N},Ge=P.createContext(null);function He(){let a=P.useContext(Ge);if(a==null)throw Error("useDataSourceTree must be used within a DataSourceTreeContext.Provider");return a}function Ke(a,{schema:e,schemaPath:t}){return{engine:a.engineName,database:a.databaseName,schema:e,schemaPath:t,defaultSchema:a.defaultSchema,defaultDatabase:a.defaultDatabase,dialect:a.dialect}}var xt=a=>{let e=(0,A.c)(22),{connection:t,database:l,hasSearch:n,searchValue:m}=a,r;e[0]!==t.default_database||e[1]!==t.default_schema||e[2]!==t.dialect||e[3]!==t.name||e[4]!==l.name||e[5]!==n||e[6]!==m?(r={engineName:t.name,databaseName:l.name,dialect:t.dialect,defaultSchema:t.default_schema,defaultDatabase:t.default_database,hasSearch:n,searchValue:m},e[0]=t.default_database,e[1]=t.default_schema,e[2]=t.dialect,e[3]=t.name,e[4]=l.name,e[5]=n,e[6]=m,e[7]=r):r=e[7];let g=r,i=t.name,x=l.schemas,b;e[8]===l?b=e[9]:(b=Ie(l),e[8]=l,e[9]=b);let o;e[10]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[10]=o):o=e[10];let c;e[11]!==l.schemas||e[12]!==b?(c=(0,s.jsx)(We,{schemas:x,schemasResolved:b,schemaPath:o,depth:0}),e[11]=l.schemas,e[12]=b,e[13]=c):c=e[13];let d;e[14]!==c||e[15]!==g?(d=(0,s.jsx)(Ge.Provider,{value:g,children:c}),e[14]=c,e[15]=g,e[16]=d):d=e[16];let y;return e[17]!==t.name||e[18]!==l||e[19]!==n||e[20]!==d?(y=(0,s.jsx)(pt,{engineName:i,database:l,hasSearch:n,children:d}),e[17]=t.name,e[18]=l,e[19]=n,e[20]=d,e[21]=y):y=e[21],y},pt=a=>{let e=(0,A.c)(26),{hasSearch:t,engineName:l,database:n,children:m}=a,[r,g]=P.useState(!1),[i,x]=P.useState(!1),[b,o]=P.useState(t);b!==t&&(o(t),g(t));let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=L(U.database),e[0]=c):c=e[0];let d;e[1]!==r||e[2]!==i?(d=()=>{g(!r),x(!i)},e[1]=r,e[2]=i,e[3]=d):d=e[3];let y=`${l}:${n.name}`,h;e[4]===r?h=e[5]:(h=(0,s.jsx)($e,{isExpanded:r}),e[4]=r,e[5]=h);let v=i&&r?"text-foreground":"text-muted-foreground",j;e[6]===v?j=e[7]:(j=X("h-4 w-4",v),e[6]=v,e[7]=j);let p;e[8]===j?p=e[9]:(p=(0,s.jsx)(ie,{className:j}),e[8]=j,e[9]=p);let N=i&&r&&"font-semibold",w;e[10]===N?w=e[11]:(w=X(N),e[10]=N,e[11]=w);let u;e[12]===n.name?u=e[13]:(u=n.name===""?(0,s.jsx)("i",{children:"Not connected"}):n.name,e[12]=n.name,e[13]=u);let C;e[14]!==u||e[15]!==w?(C=(0,s.jsx)("span",{className:w,children:u}),e[14]=u,e[15]=w,e[16]=C):C=e[16];let _;e[17]!==C||e[18]!==d||e[19]!==y||e[20]!==h||e[21]!==p?(_=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:c,onSelect:d,value:y,children:[h,p,C]}),e[17]=C,e[18]=d,e[19]=y,e[20]=h,e[21]=p,e[22]=_):_=e[22];let f=r&&m,S;return e[23]!==_||e[24]!==f?(S=(0,s.jsxs)(s.Fragment,{children:[_,f]}),e[23]=_,e[24]=f,e[25]=S):S=e[25],S},We=a=>{let{schemas:e,schemasResolved:t,depth:l}=a,n=He(),{engineName:m,databaseName:r,searchValue:g}=n,{addSchemaList:i}=me(),x=at(a.schemaPath),[b,o]=P.useState(!1),{isPending:c,error:d}=pe(async()=>{if(!t&&m){o(!0);try{i({schemas:(await Ze.request({engine:m,database:r,schemaPath:x})).schemas??[],sqlSchemaContext:{engine:m,database:r,schemaPath:x}})}finally{o(!1)}}},[t,m,r,x]),y=L(Oe(l));return c||b?(0,s.jsx)(he,{message:"Loading schemas...",style:y}):d?(0,s.jsx)(ue,{error:d,style:y}):e.length===0?(0,s.jsx)(le,{content:"No schemas available",style:y}):(0,s.jsx)(s.Fragment,{children:e.map(h=>ca(h.name)?(0,s.jsx)(be,{tables:h.tables,tablesResolved:ce(h),searchValue:g,sqlTableContext:Ke(n,{schema:h.name,schemaPath:x})},h.name):(0,s.jsx)(ft,{schema:h,schemaPath:[...x,h.name],depth:l},h.name))})},ft=a=>{let e=(0,A.c)(36),{schema:t,schemaPath:l,depth:n}=a,m=He(),{databaseName:r,hasSearch:g,searchValue:i}=m,[x,b]=P.useState(g),[o,c]=P.useState(!1),d=`${r}:${l.join(".")}`,y;e[0]===t.child_schemas?y=e[1]:(y=t.child_schemas??[],e[0]=t.child_schemas,e[1]=y);let h=y,v;e[2]===n?v=e[3]:(v=L(Oe(n)),e[2]=n,e[3]=v);let j;e[4]!==x||e[5]!==o?(j=()=>{b(!x),c(!o)},e[4]=x,e[5]=o,e[6]=j):j=e[6];let p;e[7]===x?p=e[8]:(p=(0,s.jsx)($e,{isExpanded:x}),e[7]=x,e[8]=p);let N=o&&x&&"text-foreground",w;e[9]===N?w=e[10]:(w=X("h-4 w-4 text-muted-foreground",N),e[9]=N,e[10]=w);let u;e[11]===w?u=e[12]:(u=(0,s.jsx)(da,{className:w}),e[11]=w,e[12]=u);let C=o&&x&&"font-semibold",_;e[13]===C?_=e[14]:(_=X(C),e[13]=C,e[14]=_);let f;e[15]!==t.name||e[16]!==_?(f=(0,s.jsx)("span",{className:_,children:t.name}),e[15]=t.name,e[16]=_,e[17]=f):f=e[17];let S;e[18]!==v||e[19]!==j||e[20]!==p||e[21]!==u||e[22]!==f||e[23]!==d?(S=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:v,onSelect:j,value:d,children:[p,u,f]}),e[18]=v,e[19]=j,e[20]=p,e[21]=u,e[22]=f,e[23]=d,e[24]=S):S=e[24];let I;e[25]!==h||e[26]!==n||e[27]!==x||e[28]!==t||e[29]!==l||e[30]!==i||e[31]!==m?(I=x&&(0,s.jsxs)(s.Fragment,{children:[(h.length>0||!oe(t))&&(0,s.jsx)(We,{schemas:h,schemasResolved:oe(t),schemaPath:l,depth:n+1}),(0,s.jsx)(be,{tables:t.tables,tablesResolved:ce(t),searchValue:i,tableIndentRem:ct(n),columnIndentRem:ze(n),sqlTableContext:Ke(m,{schema:t.name,schemaPath:l})})]}),e[25]=h,e[26]=n,e[27]=x,e[28]=t,e[29]=l,e[30]=i,e[31]=m,e[32]=I):I=e[32];let k;return e[33]!==S||e[34]!==I?(k=(0,s.jsxs)(s.Fragment,{children:[S,I]}),e[33]=S,e[34]=I,e[35]=k):k=e[35],k},be=a=>{let e=(0,A.c)(31),{tables:t,sqlTableContext:l,searchValue:n,tablesResolved:m,tableIndentRem:r,columnIndentRem:g}=a,i=m===void 0?!0:m,{addTableList:x}=me(),[b,o]=P.useState(!1),c;e[0]!==x||e[1]!==l||e[2]!==i?(c=async()=>{if(!i&&l){o(!0);let{engine:u,database:C,schema:_,schemaPath:f}=l,S=await fa.request({engine:u,database:C,schema:_,schemaPath:f??[]});if(!(S!=null&&S.tables))throw o(!1),Error("No tables available");x({tables:S.tables,sqlTableContext:l}),o(!1)}},e[0]=x,e[1]=l,e[2]=i,e[3]=c):c=e[3];let d;e[4]!==l||e[5]!==i?(d=[i,l],e[4]=l,e[5]=i,e[6]=d):d=e[6];let{isPending:y,error:h}=pe(c,d),v=r??U.tableLoading,j;e[7]===v?j=e[8]:(j=L(v),e[7]=v,e[8]=j);let p=j;if(y||b){let u;return e[9]===p?u=e[10]:(u=(0,s.jsx)(he,{message:"Loading tables...",style:p}),e[9]=p,e[10]=u),u}if(h){let u;return e[11]!==h||e[12]!==p?(u=(0,s.jsx)(ue,{error:h,style:p}),e[11]=h,e[12]=p,e[13]=u):u=e[13],u}if(t.length===0){let u;return e[14]===p?u=e[15]:(u=(0,s.jsx)(le,{content:"No tables found",style:p}),e[14]=p,e[15]=u),u}let N;if(e[16]!==g||e[17]!==n||e[18]!==l||e[19]!==r||e[20]!==t){let u;e[22]===n?u=e[23]:(u=f=>n?f.name.toLowerCase().includes(n.toLowerCase()):!0,e[22]=n,e[23]=u);let C=t.filter(u),_;e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==r?(_=f=>(0,s.jsx)(bt,{table:f,sqlTableContext:l,isSearching:!!n,tableIndentRem:r,columnIndentRem:g},f.name),e[24]=g,e[25]=n,e[26]=l,e[27]=r,e[28]=_):_=e[28],N=C.map(_),e[16]=g,e[17]=n,e[18]=l,e[19]=r,e[20]=t,e[21]=N}else N=e[21];let w;return e[29]===N?w=e[30]:(w=(0,s.jsx)(s.Fragment,{children:N}),e[29]=N,e[30]=w),w},bt=a=>{let e=(0,A.c)(69),{table:t,sqlTableContext:l,isSearching:n,tableIndentRem:m,columnIndentRem:r}=a,{addTable:g}=me(),[i,x]=P.useState(!1),b=t.columns.length>0,o;e[0]!==g||e[1]!==i||e[2]!==l||e[3]!==t.name||e[4]!==b?(o=async()=>{if(i&&!b&&l){let{engine:D,database:ae,schema:te,schemaPath:Qe}=l,se=await ta.request({engine:D,database:ae,schema:te,tableName:t.name,schemaPath:Qe??[]});if(!(se!=null&&se.table))throw Error("No table details available");g({table:se.table,sqlTableContext:l})}},e[0]=g,e[1]=i,e[2]=l,e[3]=t.name,e[4]=b,e[5]=o):o=e[5];let c;e[6]!==i||e[7]!==b?(c=[i,b],e[6]=i,e[7]=b,e[8]=c):c=e[8];let{isFetching:d,isPending:y,error:h}=pe(o,c),v=Q(Na),j=Ga(),{createNewCell:p}=Ye(),N=Re(),w;e[9]!==N||e[10]!==v||e[11]!==p||e[12]!==j||e[13]!==l||e[14]!==t?(w=()=>{Aa({autoInstantiate:v,createNewCell:p,fromCellId:j}),N((()=>{if(t.source_type==="catalog"){let D=l!=null&&l.database?[l.database,...l.schemaPath??[],t.name].join("."):t.name;return`${t.engine}.load_table("${D}")`}if(l)return we({table:t,columnName:"*",sqlTableContext:l});switch(t.source_type){case"local":return`mo.ui.table(${t.name})`;case"duckdb":case"connection":return we({table:t,columnName:"*",sqlTableContext:l});default:return $a(t.source_type),""}})())},e[9]=N,e[10]=v,e[11]=p,e[12]=j,e[13]=l,e[14]=t,e[15]=w):w=e[15];let u=w,C;e[16]!==t.num_columns||e[17]!==t.num_rows?(C=()=>{let D=[];return t.num_rows!=null&&D.push(`${t.num_rows} rows`),t.num_columns!=null&&D.push(`${t.num_columns} columns`),D.length===0?null:(0,s.jsx)("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:D.join(", ")})})},e[16]=t.num_columns,e[17]=t.num_rows,e[18]=C):C=e[18];let _=C,f;e[19]!==r||e[20]!==h||e[21]!==d||e[22]!==y||e[23]!==l||e[24]!==t?(f=()=>{let D=L(r??U.tableLoading);if(y||d)return(0,s.jsx)(he,{message:"Loading columns...",style:D});if(h)return(0,s.jsx)(ue,{error:h,style:D});let ae=t.columns;return ae.length===0?(0,s.jsx)(le,{content:"No columns found",style:D}):ae.map(te=>(0,s.jsx)(gt,{table:t,column:te,sqlTableContext:l,columnIndentRem:r},te.name))},e[19]=r,e[20]=h,e[21]=d,e[22]=y,e[23]=l,e[24]=t,e[25]=f):f=e[25];let S=f,I;e[26]!==i||e[27]!==n||e[28]!==t.source_type||e[29]!==t.type?(I=()=>{if(t.source_type!=="local")return(0,s.jsx)(t.type==="table"?xa:ja,{className:"h-3 w-3",strokeWidth:i||n?2.5:void 0})},e[26]=i,e[27]=n,e[28]=t.source_type,e[29]=t.type,e[30]=I):I=e[30];let k=I,q;e[31]!==l||e[32]!==t.name?(q=aa(l,t.name),e[31]=l,e[32]=t.name,e[33]=q):q=e[33];let B=q,M=m??(l?U.tableSchemaless:0),E=(i||n)&&"font-semibold",T;e[34]===E?T=e[35]:(T=X("rounded-none group h-8 cursor-pointer",E),e[34]=E,e[35]=T);let F;e[36]===M?F=e[37]:(F=L(M),e[36]=M,e[37]=F);let $;e[38]===i?$=e[39]:($=()=>x(!i),e[38]=i,e[39]=$);let V;e[40]===k?V=e[41]:(V=k(),e[40]=k,e[41]=V);let O;e[42]===t.name?O=e[43]:(O=(0,s.jsx)("span",{className:"text-sm",children:t.name}),e[42]=t.name,e[43]=O);let z;e[44]!==V||e[45]!==O?(z=(0,s.jsxs)("div",{className:"flex gap-2 items-center flex-1 pl-1",children:[V,O]}),e[44]=V,e[45]=O,e[46]=z):z=e[46];let R;e[47]===_?R=e[48]:(R=_(),e[47]=_,e[48]=R);let H;e[49]===u?H=e[50]:(H=Fa.stopPropagation(()=>u()),e[49]=u,e[50]=H);let Z;e[51]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,s.jsx)(Ea,{className:"h-3 w-3"}),e[51]=Z):Z=e[51];let K;e[52]===H?K=e[53]:(K=(0,s.jsx)(xe,{content:"Add table to notebook",delayDuration:400,children:(0,s.jsx)(ne,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:H,children:Z})}),e[52]=H,e[53]=K);let W;e[54]!==i||e[55]!==F||e[56]!==$||e[57]!==z||e[58]!==R||e[59]!==K||e[60]!==T||e[61]!==B?(W=(0,s.jsxs)(re,{className:T,style:F,value:B,"aria-selected":i,forceMount:!0,onSelect:$,children:[z,R,K]}),e[54]=i,e[55]=F,e[56]=$,e[57]=z,e[58]=R,e[59]=K,e[60]=T,e[61]=B,e[62]=W):W=e[62];let J;e[63]!==i||e[64]!==S?(J=i&&S(),e[63]=i,e[64]=S,e[65]=J):J=e[65];let ee;return e[66]!==W||e[67]!==J?(ee=(0,s.jsxs)(s.Fragment,{children:[W,J]}),e[66]=W,e[67]=J,e[68]=ee):ee=e[68],ee},gt=a=>{var O,z;let e=(0,A.c)(51),{table:t,column:l,sqlTableContext:n,columnIndentRem:m}=a,[r,g]=P.useState(!1),i=Q(Ne),x=je(la);i&&r&&g(!1),x(r?R=>new Set([...R,`${t.name}:${l.name}`]):R=>(R.delete(`${t.name}:${l.name}`),new Set(R)));let b=Re(),{columnsPreviews:o}=oa(),c;e[0]!==l.name||e[1]!==t.primary_keys?(c=((O=t.primary_keys)==null?void 0:O.includes(l.name))||!1,e[0]=l.name,e[1]=t.primary_keys,e[2]=c):c=e[2];let d=c,y;e[3]!==l.name||e[4]!==t.indexes?(y=((z=t.indexes)==null?void 0:z.includes(l.name))||!1,e[3]=l.name,e[4]=t.indexes,e[5]=y):y=e[5];let h=y,v;e[6]===b?v=e[7]:(v=R=>{b(R)},e[6]=b,e[7]=v);let j=v,p=jt,N=r?"font-semibold":"",w;e[8]!==l.name||e[9]!==N?(w=(0,s.jsx)("span",{className:N,children:l.name}),e[8]=l.name,e[9]=N,e[10]=w):w=e[10];let u=w,C=`${t.name}.${l.name}`,_=`${t.name}.${l.name}`,f;e[11]===r?f=e[12]:(f=()=>g(!r),e[11]=r,e[12]=f);let S;e[13]!==m||e[14]!==n?(S=m??(n?ze(0):U.columnLocal),e[13]=m,e[14]=n,e[15]=S):S=e[15];let I;e[16]===S?I=e[17]:(I=L(S),e[16]=S,e[17]=I);let k;e[18]!==l.type||e[19]!==u?(k=(0,s.jsx)(Ta,{columnName:u,dataType:l.type}),e[18]=l.type,e[19]=u,e[20]=k):k=e[20];let q;e[21]===d?q=e[22]:(q=d&&p({tooltipContent:"Primary key",content:"PK"}),e[21]=d,e[22]=q);let B;e[23]===h?B=e[24]:(B=h&&p({tooltipContent:"Indexed",content:"IDX"}),e[23]=h,e[24]=B);let M;e[25]!==I||e[26]!==k||e[27]!==q||e[28]!==B?(M=(0,s.jsxs)("div",{className:"flex flex-row gap-2 items-center flex-1",style:I,children:[k,q,B]}),e[25]=I,e[26]=k,e[27]=q,e[28]=B,e[29]=M):M=e[29];let E;e[30]===l.name?E=e[31]:(E=(0,s.jsx)(xe,{content:"Copy column name",delayDuration:400,children:(0,s.jsx)(ne,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:(0,s.jsx)(za,{tooltip:!1,value:l.name,className:"h-3 w-3"})})}),e[30]=l.name,e[31]=E);let T;e[32]===l.external_type?T=e[33]:(T=(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:l.external_type}),e[32]=l.external_type,e[33]=T);let F;e[34]!==M||e[35]!==E||e[36]!==T||e[37]!==C||e[38]!==_||e[39]!==f?(F=(0,s.jsxs)(re,{className:"rounded-none py-1 group cursor-pointer",value:_,onSelect:f,children:[M,E,T]},C),e[34]=M,e[35]=E,e[36]=T,e[37]=C,e[38]=_,e[39]=f,e[40]=F):F=e[40];let $;e[41]!==l||e[42]!==o||e[43]!==j||e[44]!==r||e[45]!==n||e[46]!==t?($=r&&(0,s.jsx)("div",{className:"pr-2 py-2 bg-(--slate-1) shadow-inner border-b",style:L(U.columnPreview),children:(0,s.jsx)(wa,{children:(0,s.jsx)(Ma,{table:t,column:l,onAddColumnChart:j,preview:o.get(n?`${n.database}.${n.schema}.${t.name}:${l.name}`:`${t.name}:${l.name}`),sqlTableContext:n})})}),e[41]=l,e[42]=o,e[43]=j,e[44]=r,e[45]=n,e[46]=t,e[47]=$):$=e[47];let V;return e[48]!==F||e[49]!==$?(V=(0,s.jsxs)(s.Fragment,{children:[F,$]}),e[48]=F,e[49]=$,e[50]=V):V=e[50],V};function jt(a){let{tooltipContent:e,content:t}=a;return(0,s.jsx)(xe,{content:e,delayDuration:100,children:(0,s.jsx)("span",{className:"text-xs text-black bg-gray-100 dark:invert rounded px-1",children:t})})}function Rs(a){return a}var G={name:"name",type:"type-value",defs:"defs-refs"},yt=[{id:G.name,accessorFn:a=>[a.name,a.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,s.jsx)(de,{header:"Name",column:a}),cell:({getValue:a})=>{let[e,t]=a();return(0,s.jsx)(lt,{name:e,declaredBy:t})}},{id:G.type,accessorFn:a=>[a.dataType,a.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,s.jsx)(de,{header:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{children:"Type"}),(0,s.jsx)("span",{children:"Value"})]}),column:a}),cell:({getValue:a})=>{let[e,t]=a();return(0,s.jsxs)("div",{className:"max-w-[150px]",children:[(0,s.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:e}),(0,s.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:t??"",children:t})]})}},{id:G.defs,accessorFn:a=>[a.declaredBy,a.usedBy,a.name,a.declaredByNames,a.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:a})=>(0,s.jsx)(de,{header:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{children:"Declared By"}),(0,s.jsx)("span",{children:"Used By"})]}),column:a}),cell:({getValue:a})=>{let[e,t,l]=a(),n=m=>{let r=ia(m);r&&ga(r,l)};return(0,s.jsxs)("div",{className:"flex flex-col gap-1 py-1",children:[(0,s.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[(0,s.jsx)("span",{title:"Declared by",children:(0,s.jsx)(ot,{className:"w-3.5 h-3.5 text-muted-foreground"})}),e.length===1?(0,s.jsx)(Ve,{variant:"focus",cellId:e[0],skipScroll:!0,onClick:()=>n(e[0])}):(0,s.jsx)("div",{className:"text-destructive flex flex-row gap-2",children:e.slice(0,3).map((m,r)=>(0,s.jsxs)("span",{className:"flex",children:[(0,s.jsx)(Ve,{variant:"focus",cellId:m,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>n(m)},m),r<e.length-1&&", "]},m))})]}),(0,s.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[(0,s.jsx)("span",{title:"Used by",children:(0,s.jsx)(Oa,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,s.jsx)(st,{maxCount:3,cellIds:t,skipScroll:!0,onClick:n})]})]})}}];function vt({variables:a,sort:e,cellIdToIndex:t}){e||(e={id:G.defs,desc:!1});let l=[];switch(e.id){case G.name:l=Y(a,n=>n.name);break;case G.type:l=Y(a,n=>n.dataType);break;case G.defs:l=Y(a,n=>t.get(n.declaredBy[0]));break}return e.desc?l.toReversed():l}const Je=(0,P.memo)(({className:a,cellIds:e,variables:t})=>{let[l,n]=P.useState([]),[m,r]=P.useState(""),g=ra(),{locale:i}=Ua(),x=(0,P.useMemo)(()=>{let o=c=>{let d=g[c];return va(d)?`cell-${e.indexOf(c)}`:d??`cell-${e.indexOf(c)}`};return Object.values(t).map(c=>({...c,declaredByNames:c.declaredBy.map(o),usedByNames:c.usedBy.map(o)}))},[t,g,e]),b=Ca({data:(0,P.useMemo)(()=>{let o=new Map;return e.forEach((c,d)=>o.set(c,d)),vt({variables:x,sort:l[0],cellIdToIndex:o})},[x,l,e]),columns:yt,getCoreRowModel:Pa(),onGlobalFilterChange:r,getFilteredRowModel:Ia(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(o){return o.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:i,onSortingChange:n,getSortedRowModel:ka(),state:{sorting:l,globalFilter:m}});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Ba,{className:"w-full",placeholder:"Search",value:m,onChange:o=>r(o.target.value)}),(0,s.jsxs)(Qa,{className:X("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,s.jsx)(Ha,{children:(0,s.jsx)(Le,{className:"whitespace-nowrap text-xs",children:b.getFlatHeaders().map(o=>(0,s.jsx)(Ka,{className:"sticky top-0 bg-background border-b",children:Te(o.column.columnDef.header,o.getContext())},o.id))})}),(0,s.jsx)(Wa,{children:b.getRowModel().rows.map(o=>(0,s.jsx)(Le,{className:"hover:bg-accent",children:o.getVisibleCells().map(c=>(0,s.jsx)(Ja,{className:"border-b",children:Te(c.column.columnDef.cell,c.getContext())},c.id))},o.id))})]})]})});Je.displayName="VariableTable";var Nt=Pe(),wt=Ce("marimo:session-panel:state",{openSections:["variables"],hasUserInteracted:!1},Se),St=()=>{let a=(0,Nt.c)(24),e=sa(),t=na(),l=Q(_e),n=Q(Ae),[m,r]=ye(wt),g=l.length+n.length,i;a[0]!==g||a[1]!==m.hasUserInteracted||a[2]!==m.openSections?(i=!m.hasUserInteracted&&g>0?[...new Set([...m.openSections,"datasources"])]:m.openSections,a[0]=g,a[1]=m.hasUserInteracted,a[2]=m.openSections,a[3]=i):i=a[3];let x=i,b;a[4]===r?b=a[5]:(b=u=>{r({openSections:u,hasUserInteracted:!0})},a[4]=r,a[5]=b);let o=b,c=!x.includes("datasources")&&g>0,d;a[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(ie,{className:"w-4 h-4"}),a[6]=d):d=a[6];let y;a[7]!==g||a[8]!==c?(y=c&&(0,s.jsx)(rt,{children:g}),a[7]=g,a[8]=c,a[9]=y):y=a[9];let h;a[10]===y?h=a[11]:(h=(0,s.jsxs)(Me,{children:[d,"Data sources",y]}),a[10]=y,a[11]=h);let v;a[12]===Symbol.for("react.memo_cache_sentinel")?(v=(0,s.jsx)(Ee,{children:(0,s.jsx)(ht,{})}),a[12]=v):v=a[12];let j;a[13]===h?j=a[14]:(j=(0,s.jsxs)(Be,{value:"datasources",children:[h,v]}),a[13]=h,a[14]=j);let p;a[15]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsxs)(Me,{children:[(0,s.jsx)(ba,{className:"w-4 h-4"}),"Variables"]}),a[15]=p):p=a[15];let N;a[16]!==t||a[17]!==e?(N=(0,s.jsxs)(Be,{value:"variables",lastItem:!0,children:[p,(0,s.jsx)(Ee,{children:Object.keys(e).length===0?(0,s.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No variables defined"}):(0,s.jsx)(Je,{cellIds:t.inOrderIds,variables:e})})]}),a[16]=t,a[17]=e,a[18]=N):N=a[18];let w;return a[19]!==o||a[20]!==x||a[21]!==j||a[22]!==N?(w=(0,s.jsxs)(_a,{type:"multiple",value:x,onValueChange:o,className:"flex flex-col h-full overflow-auto",children:[j,N]}),a[19]=o,a[20]=x,a[21]=j,a[22]=N,a[23]=w):w=a[23],w};export{St as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as ve}from"./chunk-LvLJmgfZ.js";import{d as T,l as at,p as ot,u as Q}from"./useEvent-D91BmmQi.js";import{t as nt}from"./react-Bj1aDYRI.js";import{An as it,Cr as st,D as Ce,E as lt,Nn as rt,On as dt,Or as ct,Qt as ht,Vi as me,_ as pt,br as mt,ct as ut,dt as ze,ei as ft,h as We,kn as bt,lt as yt,t as kt,vr as xt}from"./cells-DGi-ohLl.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{n as wt,x as gt}from"./ai-model-dropdown-iEXaZ6YH.js";import{_ as L,d as Me}from"./useEventListener-DvoEXWke.js";import{x as jt}from"./utils-CvI-39U6.js";import{n as C,t as De}from"./constants-DMpttj8Q.js";import{T as X,v as vt,w as Ct}from"./config-ClMcu_sV.js";import{t as zt}from"./jsx-runtime-BqBOg78p.js";import{o as Wt}from"./alert-dialog-5BGIfskO.js";import{a as Mt,c as Dt,i as _t,n as At,r as Pt,s as St,t as Nt}from"./select-6suE6YM2.js";import{Nt as It}from"./JsonOutput-CbiJ_QRH.js";import{c as _e,d as ue,n as Et,o as Tt,r as fe,t as Lt}from"./download-YWP1Hdr2.js";import{t as Ht}from"./tooltip-B_PkSKN3.js";import{r as Rt,t as be}from"./button-BbCh-29a.js";import{i as Ot,t as Ae}from"./strings-wdPMRf6Z.js";import{r as H}from"./requests-DIwGYs0l.js";import{t as h}from"./createLucideIcon-D5guW7EU.js";import{F as Vt,I as qt,L as Pe,P as Bt,R as Ft,a as Se,i as Ne,u as Ie}from"./layout-Bx16aCt5.js";import{t as Ee}from"./check-BH35Ndha.js";import{r as Yt}from"./useCellActionButton-BAo_hBug.js";import{t as $t}from"./copy-BwrPA9zQ.js";import{t as Kt}from"./eye-off-Cm6DdkeR.js";import{t as Ut}from"./external-link-BTNxSavU.js";import{t as Z}from"./file-BrdxGLRX.js";import{t as Gt}from"./github-BKS_2Qwn.js";import{u as Jt}from"./form-CMwVIRZb.js";import{n as Qt,r as Xt,t as Zt}from"./youtube-CbdpN8oL.js";import{i as ea,n as Te}from"./add-connection-dialog-DKp7ZBWA.js";import{t as ta}from"./house-mGK3v0Mm.js";import{t as aa}from"./image-DQHXdEQn.js";import{t as oa}from"./link-CfEtM3Rl.js";import{r as na}from"./input-DA8xlX70.js";import{t as ia}from"./settings-DfFe0dWD.js";import{t as sa}from"./sparkles-lWUAsPhp.js";import{y as la}from"./textarea-CTAL0lla.js";import{t as ra}from"./square-B5xWCt0a.js";import{t as z}from"./use-toast-CJ1Tj2eC.js";import{n as Le,t as da}from"./paths-D5zczhUD.js";import{o as ca}from"./session-0B5NBztP.js";import{n as ee}from"./copy-LK56fFow.js";import{r as ha}from"./useRunCells-mJYEegIM.js";import{a as pa,c as ma,i as ua,n as fa,r as ba}from"./dialog-DRnNAWYl.js";import{n as ye}from"./ImperativeModal-BW1dmntO.js";import{r as ya,t as He}from"./share-mSf5FZIP.js";import{a as ka}from"./cell-link-kkkjfd8C.js";import{a as xa}from"./renderShortcut--ku7VECI.js";import{t as wa}from"./icons-Ol38nIbL.js";import{t as ga}from"./pair-with-agent-modal-_SlYEcmZ.js";import{n as Re}from"./marimo-icons-CLbC-oB3.js";import{t as ja}from"./links-DoPgJNku.js";import{r as va,t as Oe}from"./hooks-BZ1DWowv.js";import{t as Ve}from"./types-Cpe-qFT-.js";var Ca=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),za=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),qe=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Be=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"}]]),Fe=h("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),Wa=h("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),Ma=h("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),Da=h("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),_a=h("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),Aa=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ye=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"}]]),Pa=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"}]]),Sa=h("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),$e=h("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),Ke=S(),ke=ve(nt(),1),a=ve(zt(),1),te="https://static.marimo.app";const Na=e=>{let t=(0,Ke.c)(25),{onClose:n}=e,[o,s]=(0,ke.useState)(""),{exportAsHTML:r}=H(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${te}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let I=await r({download:!1,includeCode:!0,files:Bt.INSTANCE.filenames()}),W=z({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${te}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:I,path:l})}).catch(()=>{W.dismiss(),z({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:C.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),W.dismiss(),z({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=l,t[3]=d):d=t[3];let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(ma,{children:"Share static notebook"}),t[4]=m):m=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(pa,{children:[m,(0,a.jsxs)(ba,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:te,target:"_blank",children:te}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(na,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Ia,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let b;t[11]!==u||t[12]!==f?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=b):b=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(be,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let k;t[16]===i?k=t[17]:(k=(0,a.jsx)(be,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await ee(i)},children:"Create"}),t[16]=i,t[17]=k);let x;t[18]!==y||t[19]!==k?(x=(0,a.jsxs)(ua,{children:[y,k]}),t[18]=y,t[19]=k,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==b?(j=(0,a.jsx)(fa,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,b,x]})}),t[21]=d,t[22]=x,t[23]=b,t[24]=j):j=t[24],j};var Ia=e=>{let t=(0,Ke.c)(8),[n,o]=ke.useState(!1),s;t[0]===e.text?s=t[1]:(s=Rt.stopPropagation(async m=>{m.preventDefault(),await ee(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)($t,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(be,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Ht,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},Ea=S();function Ta(){let e=document.getElementsByClassName(De.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=me.findElement(t);if(!o){L.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:me.parse(o.id)}}}return L.warn("No visible output area found for scroll anchor"),null}function La(e){if(!e){L.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(me.create(e.cellId));if(!t){L.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${De.outputArea}`)){L.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ue(){let e=(0,Ea.c)(2),t=T(ze),n;return e[0]===t?n=e[1]:(n=()=>{let o=Ta();t(s=>({mode:yt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{La(o)})})},e[0]=t,e[1]=n),n}const Ge=ot(!1);var Ha=S();const Ra=()=>{let e=(0,Ha.c)(7),{selectedLayout:t}=Se(),{setLayoutView:n}=Ne();if(X()&&!rt("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(St,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Dt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(At,{children:(0,a.jsxs)(Pt,{children:[(0,a.jsx)(Mt,{children:"View as"}),Ve.map(Va)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Nt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Oa(e){return(0,a.jsx)(Je(e),{className:"h-4 w-4"})}function Je(e){switch(e){case"vertical":return Da;case"grid":return Xt;case"slides":return Ye;default:return Ot(e),ra}}function Qe(e){return Ae.startCase(e)}function Va(e){return(0,a.jsx)(_t,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Oa(e),(0,a.jsx)("span",{children:Qe(e)})]})},e)}async function qa(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ba=S();function Fa(e){let t=(0,Ba.c)(5),{openPrompt:n,closeModal:o}=ye(),{sendCopy:s}=H(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=da.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Le.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(Le.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),z({title:"Notebook copied",description:"A copy of the notebook has been created."}),ja(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Ya=()=>{let{updateCellConfig:e}=Ce(),{saveCellConfig:t}=H();return(0,ke.useCallback)(async()=>{let n=new ht,o=We(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:d,config:m}=o.cellData[i];m.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let l=Me.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var $a=S();function Xe(){let e=(0,$a.c)(4),{openConfirm:t}=ye(),n=T(vt),{sendRestart:o}=H(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(Wt,{onClick:async()=>{n({state:Ct.CLOSING}),await o(),ya()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Ka=S(),N=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Ua(){var we,ge,je;let e=(0,Ka.c)(53),t=ka(),{openModal:n,closeModal:o}=ye(),{toggleApplication:s}=dt(),{selectedPanel:r}=bt(),[l]=at(ze),i=Q(ut),d=Ya(),[m]=jt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:b,expandAllCells:y}=Ce(),k=Xe(),x=ha(),j=Fa(t),v=T(Ge),I=T(wt),W=T(gt),{exportAsIPYNB:oe,exportAsMarkdown:ne,readCode:M,saveCellConfig:ie,updateCellOutputs:D}=H(),_=va(),se=Q(pt),le=Q(kt),re=Q(lt),{selectedLayout:R}=Se(),{setLayoutView:de}=Ne(),O=Ue(),V=((we=m.sharing)==null?void 0:we.html)??!0,q=((ge=m.sharing)==null?void 0:ge.wasm)??!0,B=((je=m.sharing)==null?void 0:je.molab)??!0,xe=!X(),ce=R==="slides",Ze=mo,et=po,F;e[0]!==t||e[1]!==_||e[2]!==D?(F=async c=>{let{preset:p,title:E}=c;if(!t){ae();return}await _e(E,async pe=>{await Oe({takeScreenshots:()=>_({progress:pe}),updateCellOutputs:D}),await qa({filename:t,preset:p,downloadPDF:Et})})},e[0]=t,e[1]=_,e[2]=D,e[3]=F):F=e[3];let A=F,Y;e[4]===A?Y=e[5]:(Y=async()=>{if(xe){await A({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),p=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(ho,0),setTimeout(()=>window.dispatchEvent(p),0)},e[4]=A,e[5]=Y);let $=Y,K;e[6]!==oe||e[7]!==t||e[8]!==_||e[9]!==D?(K=async()=>{if(!t){ae();return}await _e("Downloading IPYNB...",async c=>{await Oe({takeScreenshots:()=>_({progress:c}),updateCellOutputs:D});let p=await oe({download:!1});fe(new Blob([p],{type:"application/x-ipynb+json"}),ue.toIPYNB(document.title))})},e[6]=oe,e[7]=t,e[8]=_,e[9]=D,e[10]=K):K=e[10];let he=K,U;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(It,{size:14,strokeWidth:1.5}),e[11]=U):U=e[11];let G;e[12]===Symbol.for("react.memo_cache_sentinel")?(G=(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),e[12]=G):G=e[12];let P;e[13]===t?P=e[14]:(P=async()=>{if(!t){ae();return}await Ie({filename:t,includeCode:!0})},e[13]=t,e[14]=P);let J;return e[15]!==f||e[16]!==le||e[17]!==u||e[18]!==o||e[19]!==b||e[20]!==j||e[21]!==A||e[22]!==y||e[23]!==ne||e[24]!==t||e[25]!==$||e[26]!==he||e[27]!==se||e[28]!==d||e[29]!==ce||e[30]!==i||e[31]!==n||e[32]!==M||e[33]!==k||e[34]!==x||e[35]!==ie||e[36]!==R||e[37]!==r||e[38]!==v||e[39]!==W||e[40]!==de||e[41]!==I||e[42]!==V||e[43]!==B||e[44]!==q||e[45]!==P||e[46]!==s||e[47]!==O||e[48]!==g||e[49]!==re||e[50]!==w||e[51]!==l.mode?(J=[{icon:U,label:"Download",handle:N,dropdown:[{icon:G,label:"Download as HTML",handle:P},{icon:(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ae();return}await Ie({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(wa,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await ne({download:!1});fe(new Blob([c],{type:"text/plain"}),ue.toMarkdown(document.title))}},{icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:he},{icon:(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await M();fe(new Blob([c.contents],{type:"text/plain"}),ue.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",xa("global.hideCode",!1)]}),handle:co},ce?{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:N,dropdown:[{icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:$},{icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:et(!0),hidden:!xe,handle:async()=>{await A({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:$}]},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:X(),handle:async()=>{n((0,a.jsx)(ga,{onClose:o}))}},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Share",handle:N,hidden:!V&&!q&&!B,dropdown:[{icon:(0,a.jsx)(Jt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!V,handle:async()=>{n((0,a.jsx)(Na,{onClose:o}))}},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!q,handle:async()=>{await ee(He({code:(await M()).contents})),z({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!B,handle:async()=>{let c=He({code:(await M()).contents,baseUrl:`${C.molab}/new`});window.open(c,"_blank")}}]},{icon:(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:N,dropdown:it.flatMap(c=>{let{type:p,Icon:E,hidden:pe,additionalKeywords:tt}=c;return pe?[]:{label:Ae.startCase(p),rightElement:Ze(r===p),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),handle:()=>s(p),additionalKeywords:tt}})},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Present as",handle:N,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(la,{size:14,strokeWidth:1.5}):(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{O()}},...Ve.map((c,p)=>{let E=Je(c);return{divider:p===0,label:Qe(c),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:R===c&&(0,a.jsx)(Ee,{size:14})}),handle:()=>{de(c),l.mode==="edit"&&O()}}})]},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||X(),handle:j},{icon:(0,a.jsx)(qe,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ee((await M()).contents),z({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Yt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!se||i,handle:async()=>{let c=ft(We());await ie({configs:Me.fromEntries(c.map(ro))});for(let p of c)w({cellId:p,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Fe,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(mt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Te,{onClose:o}))}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Te,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:re,hidden:!le||i,handle:()=>{g()}},{icon:(0,a.jsx)(Sa,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:k,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Wa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Kt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:b,redundant:!0},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(lo)},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>W(so)},{icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>I(io),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(Ut,{size:14,strokeWidth:1.5}),label:"Resources",handle:N,dropdown:[{icon:(0,a.jsx)(ct,{size:14,strokeWidth:1.5}),label:"Documentation",handle:no},{icon:(0,a.jsx)(Gt,{size:14,strokeWidth:1.5}),label:"GitHub",handle:oo},{icon:(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:ao},{icon:(0,a.jsx)(Zt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:to},{icon:(0,a.jsx)(xt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:eo}]},{divider:!0,icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Za},{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Xa}].filter(Qa).map(Ga),e[15]=f,e[16]=le,e[17]=u,e[18]=o,e[19]=b,e[20]=j,e[21]=A,e[22]=y,e[23]=ne,e[24]=t,e[25]=$,e[26]=he,e[27]=se,e[28]=d,e[29]=ce,e[30]=i,e[31]=n,e[32]=M,e[33]=k,e[34]=x,e[35]=ie,e[36]=R,e[37]=r,e[38]=v,e[39]=W,e[40]=de,e[41]=I,e[42]=V,e[43]=B,e[44]=q,e[45]=P,e[46]=s,e[47]=O,e[48]=g,e[49]=re,e[50]=w,e[51]=l.mode,e[52]=J):J=e[52],J}function Ga(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Ja)}:e}function Ja(e){return!e.hidden}function Qa(e){return!e.hidden}function Xa(){let e=ca();window.open(e,"_blank")}function Za(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function eo(){window.open(C.releasesPage,"_blank")}function to(){window.open(C.youtube,"_blank")}function ao(){window.open(C.discordLink,"_blank")}function oo(){window.open(C.githubPage,"_blank")}function no(){window.open(C.docsPage,"_blank")}function io(e){return!e}function so(e){return!e}function lo(e){return!e}function ro(e){return[e,{disabled:!1}]}async function co(){let e=document.getElementById("App");e&&await Tt({element:e,filename:document.title,prepare:Lt})}function ho(){return window.print()}function po(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function mo(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Ee,{size:14})})}function ae(){z({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Ue as a,Be as c,Ge as i,qe as l,Xe as n,$e as o,Ra as r,Fe as s,Ua as t};
|
|
1
|
+
import{s as ve}from"./chunk-LvLJmgfZ.js";import{d as T,l as at,p as ot,u as Q}from"./useEvent-D91BmmQi.js";import{t as nt}from"./react-Bj1aDYRI.js";import{An as it,Cr as st,D as Ce,E as lt,Nn as rt,On as dt,Or as ct,Qt as ht,Vi as me,_ as pt,br as mt,ct as ut,dt as ze,ei as ft,h as We,kn as bt,lt as yt,t as kt,vr as xt}from"./cells-DGi-ohLl.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{n as wt,x as gt}from"./ai-model-dropdown-iEXaZ6YH.js";import{_ as L,d as Me}from"./useEventListener-DvoEXWke.js";import{x as jt}from"./utils-CvI-39U6.js";import{n as C,t as De}from"./constants-DMpttj8Q.js";import{T as X,v as vt,w as Ct}from"./config-ClMcu_sV.js";import{t as zt}from"./jsx-runtime-BqBOg78p.js";import{o as Wt}from"./alert-dialog-5BGIfskO.js";import{a as Mt,c as Dt,i as _t,n as At,r as Pt,s as St,t as Nt}from"./select-6suE6YM2.js";import{Nt as It}from"./JsonOutput-CbiJ_QRH.js";import{c as _e,d as ue,n as Et,o as Tt,r as fe,t as Lt}from"./download-YWP1Hdr2.js";import{t as Ht}from"./tooltip-B_PkSKN3.js";import{r as Rt,t as be}from"./button-BbCh-29a.js";import{i as Ot,t as Ae}from"./strings-wdPMRf6Z.js";import{r as H}from"./requests-DIwGYs0l.js";import{t as h}from"./createLucideIcon-D5guW7EU.js";import{F as Vt,I as qt,L as Pe,P as Bt,R as Ft,a as Se,i as Ne,u as Ie}from"./layout-Bx16aCt5.js";import{t as Ee}from"./check-BH35Ndha.js";import{r as Yt}from"./useCellActionButton-BAo_hBug.js";import{t as $t}from"./copy-BwrPA9zQ.js";import{t as Kt}from"./eye-off-Cm6DdkeR.js";import{t as Ut}from"./external-link-BTNxSavU.js";import{t as Z}from"./file-BrdxGLRX.js";import{t as Gt}from"./github-BKS_2Qwn.js";import{u as Jt}from"./form-CMwVIRZb.js";import{n as Qt,r as Xt,t as Zt}from"./youtube-CbdpN8oL.js";import{i as ea,n as Te}from"./add-connection-dialog-CTDOffvK.js";import{t as ta}from"./house-mGK3v0Mm.js";import{t as aa}from"./image-DQHXdEQn.js";import{t as oa}from"./link-CfEtM3Rl.js";import{r as na}from"./input-DA8xlX70.js";import{t as ia}from"./settings-DfFe0dWD.js";import{t as sa}from"./sparkles-lWUAsPhp.js";import{y as la}from"./textarea-CTAL0lla.js";import{t as ra}from"./square-B5xWCt0a.js";import{t as z}from"./use-toast-CJ1Tj2eC.js";import{n as Le,t as da}from"./paths-D5zczhUD.js";import{o as ca}from"./session-0B5NBztP.js";import{n as ee}from"./copy-LK56fFow.js";import{r as ha}from"./useRunCells-mJYEegIM.js";import{a as pa,c as ma,i as ua,n as fa,r as ba}from"./dialog-DRnNAWYl.js";import{n as ye}from"./ImperativeModal-BW1dmntO.js";import{r as ya,t as He}from"./share-mSf5FZIP.js";import{a as ka}from"./cell-link-kkkjfd8C.js";import{a as xa}from"./renderShortcut--ku7VECI.js";import{t as wa}from"./icons-Ol38nIbL.js";import{t as ga}from"./pair-with-agent-modal-_SlYEcmZ.js";import{n as Re}from"./marimo-icons-CLbC-oB3.js";import{t as ja}from"./links-DoPgJNku.js";import{r as va,t as Oe}from"./hooks-BZ1DWowv.js";import{t as Ve}from"./types-Cpe-qFT-.js";var Ca=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),za=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),qe=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Be=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"}]]),Fe=h("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),Wa=h("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),Ma=h("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),Da=h("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),_a=h("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),Aa=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ye=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"}]]),Pa=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"}]]),Sa=h("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),$e=h("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),Ke=S(),ke=ve(nt(),1),a=ve(zt(),1),te="https://static.marimo.app";const Na=e=>{let t=(0,Ke.c)(25),{onClose:n}=e,[o,s]=(0,ke.useState)(""),{exportAsHTML:r}=H(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${te}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let I=await r({download:!1,includeCode:!0,files:Bt.INSTANCE.filenames()}),W=z({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${te}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:I,path:l})}).catch(()=>{W.dismiss(),z({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:C.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),W.dismiss(),z({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=l,t[3]=d):d=t[3];let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(ma,{children:"Share static notebook"}),t[4]=m):m=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(pa,{children:[m,(0,a.jsxs)(ba,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:te,target:"_blank",children:te}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(na,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Ia,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let b;t[11]!==u||t[12]!==f?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=b):b=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(be,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let k;t[16]===i?k=t[17]:(k=(0,a.jsx)(be,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await ee(i)},children:"Create"}),t[16]=i,t[17]=k);let x;t[18]!==y||t[19]!==k?(x=(0,a.jsxs)(ua,{children:[y,k]}),t[18]=y,t[19]=k,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==b?(j=(0,a.jsx)(fa,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,b,x]})}),t[21]=d,t[22]=x,t[23]=b,t[24]=j):j=t[24],j};var Ia=e=>{let t=(0,Ke.c)(8),[n,o]=ke.useState(!1),s;t[0]===e.text?s=t[1]:(s=Rt.stopPropagation(async m=>{m.preventDefault(),await ee(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)($t,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(be,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Ht,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},Ea=S();function Ta(){let e=document.getElementsByClassName(De.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=me.findElement(t);if(!o){L.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:me.parse(o.id)}}}return L.warn("No visible output area found for scroll anchor"),null}function La(e){if(!e){L.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(me.create(e.cellId));if(!t){L.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${De.outputArea}`)){L.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ue(){let e=(0,Ea.c)(2),t=T(ze),n;return e[0]===t?n=e[1]:(n=()=>{let o=Ta();t(s=>({mode:yt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{La(o)})})},e[0]=t,e[1]=n),n}const Ge=ot(!1);var Ha=S();const Ra=()=>{let e=(0,Ha.c)(7),{selectedLayout:t}=Se(),{setLayoutView:n}=Ne();if(X()&&!rt("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(St,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Dt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(At,{children:(0,a.jsxs)(Pt,{children:[(0,a.jsx)(Mt,{children:"View as"}),Ve.map(Va)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Nt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Oa(e){return(0,a.jsx)(Je(e),{className:"h-4 w-4"})}function Je(e){switch(e){case"vertical":return Da;case"grid":return Xt;case"slides":return Ye;default:return Ot(e),ra}}function Qe(e){return Ae.startCase(e)}function Va(e){return(0,a.jsx)(_t,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Oa(e),(0,a.jsx)("span",{children:Qe(e)})]})},e)}async function qa(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ba=S();function Fa(e){let t=(0,Ba.c)(5),{openPrompt:n,closeModal:o}=ye(),{sendCopy:s}=H(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=da.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Le.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(Le.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),z({title:"Notebook copied",description:"A copy of the notebook has been created."}),ja(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Ya=()=>{let{updateCellConfig:e}=Ce(),{saveCellConfig:t}=H();return(0,ke.useCallback)(async()=>{let n=new ht,o=We(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:d,config:m}=o.cellData[i];m.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let l=Me.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var $a=S();function Xe(){let e=(0,$a.c)(4),{openConfirm:t}=ye(),n=T(vt),{sendRestart:o}=H(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(Wt,{onClick:async()=>{n({state:Ct.CLOSING}),await o(),ya()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Ka=S(),N=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Ua(){var we,ge,je;let e=(0,Ka.c)(53),t=ka(),{openModal:n,closeModal:o}=ye(),{toggleApplication:s}=dt(),{selectedPanel:r}=bt(),[l]=at(ze),i=Q(ut),d=Ya(),[m]=jt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:b,expandAllCells:y}=Ce(),k=Xe(),x=ha(),j=Fa(t),v=T(Ge),I=T(wt),W=T(gt),{exportAsIPYNB:oe,exportAsMarkdown:ne,readCode:M,saveCellConfig:ie,updateCellOutputs:D}=H(),_=va(),se=Q(pt),le=Q(kt),re=Q(lt),{selectedLayout:R}=Se(),{setLayoutView:de}=Ne(),O=Ue(),V=((we=m.sharing)==null?void 0:we.html)??!0,q=((ge=m.sharing)==null?void 0:ge.wasm)??!0,B=((je=m.sharing)==null?void 0:je.molab)??!0,xe=!X(),ce=R==="slides",Ze=mo,et=po,F;e[0]!==t||e[1]!==_||e[2]!==D?(F=async c=>{let{preset:p,title:E}=c;if(!t){ae();return}await _e(E,async pe=>{await Oe({takeScreenshots:()=>_({progress:pe}),updateCellOutputs:D}),await qa({filename:t,preset:p,downloadPDF:Et})})},e[0]=t,e[1]=_,e[2]=D,e[3]=F):F=e[3];let A=F,Y;e[4]===A?Y=e[5]:(Y=async()=>{if(xe){await A({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),p=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(ho,0),setTimeout(()=>window.dispatchEvent(p),0)},e[4]=A,e[5]=Y);let $=Y,K;e[6]!==oe||e[7]!==t||e[8]!==_||e[9]!==D?(K=async()=>{if(!t){ae();return}await _e("Downloading IPYNB...",async c=>{await Oe({takeScreenshots:()=>_({progress:c}),updateCellOutputs:D});let p=await oe({download:!1});fe(new Blob([p],{type:"application/x-ipynb+json"}),ue.toIPYNB(document.title))})},e[6]=oe,e[7]=t,e[8]=_,e[9]=D,e[10]=K):K=e[10];let he=K,U;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(It,{size:14,strokeWidth:1.5}),e[11]=U):U=e[11];let G;e[12]===Symbol.for("react.memo_cache_sentinel")?(G=(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),e[12]=G):G=e[12];let P;e[13]===t?P=e[14]:(P=async()=>{if(!t){ae();return}await Ie({filename:t,includeCode:!0})},e[13]=t,e[14]=P);let J;return e[15]!==f||e[16]!==le||e[17]!==u||e[18]!==o||e[19]!==b||e[20]!==j||e[21]!==A||e[22]!==y||e[23]!==ne||e[24]!==t||e[25]!==$||e[26]!==he||e[27]!==se||e[28]!==d||e[29]!==ce||e[30]!==i||e[31]!==n||e[32]!==M||e[33]!==k||e[34]!==x||e[35]!==ie||e[36]!==R||e[37]!==r||e[38]!==v||e[39]!==W||e[40]!==de||e[41]!==I||e[42]!==V||e[43]!==B||e[44]!==q||e[45]!==P||e[46]!==s||e[47]!==O||e[48]!==g||e[49]!==re||e[50]!==w||e[51]!==l.mode?(J=[{icon:U,label:"Download",handle:N,dropdown:[{icon:G,label:"Download as HTML",handle:P},{icon:(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ae();return}await Ie({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(wa,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await ne({download:!1});fe(new Blob([c],{type:"text/plain"}),ue.toMarkdown(document.title))}},{icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:he},{icon:(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await M();fe(new Blob([c.contents],{type:"text/plain"}),ue.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",xa("global.hideCode",!1)]}),handle:co},ce?{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:N,dropdown:[{icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:$},{icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:et(!0),hidden:!xe,handle:async()=>{await A({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:$}]},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:X(),handle:async()=>{n((0,a.jsx)(ga,{onClose:o}))}},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Share",handle:N,hidden:!V&&!q&&!B,dropdown:[{icon:(0,a.jsx)(Jt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!V,handle:async()=>{n((0,a.jsx)(Na,{onClose:o}))}},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!q,handle:async()=>{await ee(He({code:(await M()).contents})),z({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!B,handle:async()=>{let c=He({code:(await M()).contents,baseUrl:`${C.molab}/new`});window.open(c,"_blank")}}]},{icon:(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:N,dropdown:it.flatMap(c=>{let{type:p,Icon:E,hidden:pe,additionalKeywords:tt}=c;return pe?[]:{label:Ae.startCase(p),rightElement:Ze(r===p),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),handle:()=>s(p),additionalKeywords:tt}})},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Present as",handle:N,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(la,{size:14,strokeWidth:1.5}):(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{O()}},...Ve.map((c,p)=>{let E=Je(c);return{divider:p===0,label:Qe(c),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:R===c&&(0,a.jsx)(Ee,{size:14})}),handle:()=>{de(c),l.mode==="edit"&&O()}}})]},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||X(),handle:j},{icon:(0,a.jsx)(qe,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ee((await M()).contents),z({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Yt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!se||i,handle:async()=>{let c=ft(We());await ie({configs:Me.fromEntries(c.map(ro))});for(let p of c)w({cellId:p,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Fe,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(mt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Te,{onClose:o}))}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Te,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:re,hidden:!le||i,handle:()=>{g()}},{icon:(0,a.jsx)(Sa,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:k,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Wa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Kt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:b,redundant:!0},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(lo)},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>W(so)},{icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>I(io),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(Ut,{size:14,strokeWidth:1.5}),label:"Resources",handle:N,dropdown:[{icon:(0,a.jsx)(ct,{size:14,strokeWidth:1.5}),label:"Documentation",handle:no},{icon:(0,a.jsx)(Gt,{size:14,strokeWidth:1.5}),label:"GitHub",handle:oo},{icon:(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:ao},{icon:(0,a.jsx)(Zt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:to},{icon:(0,a.jsx)(xt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:eo}]},{divider:!0,icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Za},{icon:(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Xa}].filter(Qa).map(Ga),e[15]=f,e[16]=le,e[17]=u,e[18]=o,e[19]=b,e[20]=j,e[21]=A,e[22]=y,e[23]=ne,e[24]=t,e[25]=$,e[26]=he,e[27]=se,e[28]=d,e[29]=ce,e[30]=i,e[31]=n,e[32]=M,e[33]=k,e[34]=x,e[35]=ie,e[36]=R,e[37]=r,e[38]=v,e[39]=W,e[40]=de,e[41]=I,e[42]=V,e[43]=B,e[44]=q,e[45]=P,e[46]=s,e[47]=O,e[48]=g,e[49]=re,e[50]=w,e[51]=l.mode,e[52]=J):J=e[52],J}function Ga(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Ja)}:e}function Ja(e){return!e.hidden}function Qa(e){return!e.hidden}function Xa(){let e=ca();window.open(e,"_blank")}function Za(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function eo(){window.open(C.releasesPage,"_blank")}function to(){window.open(C.youtube,"_blank")}function ao(){window.open(C.discordLink,"_blank")}function oo(){window.open(C.githubPage,"_blank")}function no(){window.open(C.docsPage,"_blank")}function io(e){return!e}function so(e){return!e}function lo(e){return!e}function ro(e){return[e,{disabled:!1}]}async function co(){let e=document.getElementById("App");e&&await Tt({element:e,filename:document.title,prepare:Lt})}function ho(){return window.print()}function po(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function mo(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Ee,{size:14})})}function ae(){z({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Ue as a,Be as c,Ge as i,qe as l,Xe as n,$e as o,Ra as r,Fe as s,Ua as t};
|
package/dist/index.html
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
|
|
67
67
|
<!-- /TODO -->
|
|
68
68
|
<title>{{ title }}</title>
|
|
69
|
-
<script type="module" crossorigin src="./assets/index-
|
|
69
|
+
<script type="module" crossorigin src="./assets/index-BT43KXXM.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-BPPi7vOr.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
+
import { useAtomValue } from "jotai";
|
|
4
5
|
import React from "react";
|
|
5
6
|
import { type DefaultValues, type FieldValues, useForm } from "react-hook-form";
|
|
6
7
|
import type { z } from "zod";
|
|
@@ -16,8 +17,10 @@ import {
|
|
|
16
17
|
SelectTrigger,
|
|
17
18
|
SelectValue,
|
|
18
19
|
} from "@/components/ui/select";
|
|
20
|
+
import { maybeAddMarimoImport } from "@/core/cells/add-missing-import";
|
|
19
21
|
import { useCellActions } from "@/core/cells/cells";
|
|
20
22
|
import { useLastFocusedCellId } from "@/core/cells/focus";
|
|
23
|
+
import { autoInstantiateAtom } from "@/core/config/config";
|
|
21
24
|
import { ENV_RENDERER, SecretsProvider } from "./form-renderers";
|
|
22
25
|
|
|
23
26
|
const RENDERERS: FormRenderer[] = [ENV_RENDERER];
|
|
@@ -106,8 +109,18 @@ export const ConnectionFormFooter = <L extends string>({
|
|
|
106
109
|
export function useInsertCode() {
|
|
107
110
|
const { createNewCell } = useCellActions();
|
|
108
111
|
const lastFocusedCellId = useLastFocusedCellId();
|
|
112
|
+
const autoInstantiate = useAtomValue(autoInstantiateAtom);
|
|
109
113
|
|
|
110
114
|
return (code: string) => {
|
|
115
|
+
// Ensure `mo` is importable when the generated code references it
|
|
116
|
+
if (/\bmo\./.test(code)) {
|
|
117
|
+
maybeAddMarimoImport({
|
|
118
|
+
autoInstantiate,
|
|
119
|
+
createNewCell,
|
|
120
|
+
fromCellId: lastFocusedCellId,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
111
124
|
createNewCell({
|
|
112
125
|
code,
|
|
113
126
|
before: false,
|
package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap
CHANGED
|
@@ -85,14 +85,14 @@ store = GCSStore("my-bucket")"
|
|
|
85
85
|
exports[`generateStorageCode > Google Drive > with default auth (no credentials) 1`] = `
|
|
86
86
|
"from gdrive_fsspec import GoogleDriveFileSystem
|
|
87
87
|
|
|
88
|
-
fs = GoogleDriveFileSystem(use_listings_cache=False)"
|
|
88
|
+
fs = GoogleDriveFileSystem(use_listings_cache=False, skip_instance_cache=True)"
|
|
89
89
|
`;
|
|
90
90
|
|
|
91
91
|
exports[`generateStorageCode > Google Drive > with embedded auth (no credentials) 1`] = `
|
|
92
92
|
"from gdrive_fsspec import GoogleDriveFileSystem
|
|
93
93
|
|
|
94
|
-
fs = GoogleDriveFileSystem(use_listings_cache=False, auth_kwargs={"use_local_webserver": False})
|
|
95
|
-
|
|
94
|
+
fs = GoogleDriveFileSystem(use_listings_cache=False, skip_instance_cache=True, auth_kwargs={"use_local_webserver": False})
|
|
95
|
+
mo.output.clear_console()"
|
|
96
96
|
`;
|
|
97
97
|
|
|
98
98
|
exports[`generateStorageCode > Google Drive > with service account credentials 1`] = `
|
|
@@ -100,7 +100,7 @@ exports[`generateStorageCode > Google Drive > with service account credentials 1
|
|
|
100
100
|
import json
|
|
101
101
|
|
|
102
102
|
_creds = json.loads("""{"type": "service_account", "client_email": "test@test.iam.gserviceaccount.com"}""")
|
|
103
|
-
fs = GoogleDriveFileSystem(creds=_creds, token="service_account", use_listings_cache=False)"
|
|
103
|
+
fs = GoogleDriveFileSystem(creds=_creds, token="service_account", use_listings_cache=False, skip_instance_cache=True)"
|
|
104
104
|
`;
|
|
105
105
|
|
|
106
106
|
exports[`generateStorageCode > S3 > basic connection with all fields 1`] = `
|
|
@@ -168,6 +168,10 @@ function generateGDriveCode(
|
|
|
168
168
|
connection: Extract<StorageConnection, { type: "gdrive" }>,
|
|
169
169
|
options: { secrets: SecretContainer; isEmbedded?: boolean },
|
|
170
170
|
): { imports: Set<string>; code: string } {
|
|
171
|
+
/**
|
|
172
|
+
* Skip instance cache True so you can create multiple connections which don't reference the same creds.
|
|
173
|
+
* Use listings cache False so we don't get stale reads.
|
|
174
|
+
*/
|
|
171
175
|
const { secrets, isEmbedded = false } = options;
|
|
172
176
|
const imports = new Set(["from gdrive_fsspec import GoogleDriveFileSystem"]);
|
|
173
177
|
|
|
@@ -179,18 +183,21 @@ function generateGDriveCode(
|
|
|
179
183
|
);
|
|
180
184
|
const code = dedent(`
|
|
181
185
|
_creds = json.loads("""${connection.credentials_json?.startsWith("ENV:") ? `{${creds}}` : connection.credentials_json}""")
|
|
182
|
-
fs = GoogleDriveFileSystem(creds=_creds, token="service_account", use_listings_cache=False)
|
|
186
|
+
fs = GoogleDriveFileSystem(creds=_creds, token="service_account", use_listings_cache=False, skip_instance_cache=True)
|
|
183
187
|
`);
|
|
184
188
|
return { imports, code };
|
|
185
189
|
}
|
|
186
190
|
|
|
191
|
+
// In the iframe (embedded) flow we authenticate via the console-based OOB
|
|
192
|
+
// flow, which prints an auth URL and reads the code from stdin. Clear the
|
|
193
|
+
// console afterwards so the (single-use) auth code doesn't linger.
|
|
187
194
|
const code = isEmbedded
|
|
188
195
|
? dedent(`
|
|
189
|
-
fs = GoogleDriveFileSystem(use_listings_cache=False, auth_kwargs={"use_local_webserver": False})
|
|
190
|
-
|
|
196
|
+
fs = GoogleDriveFileSystem(use_listings_cache=False, skip_instance_cache=True, auth_kwargs={"use_local_webserver": False})
|
|
197
|
+
mo.output.clear_console()
|
|
191
198
|
`)
|
|
192
199
|
: dedent(`
|
|
193
|
-
fs = GoogleDriveFileSystem(use_listings_cache=False)
|
|
200
|
+
fs = GoogleDriveFileSystem(use_listings_cache=False, skip_instance_cache=True)
|
|
194
201
|
`);
|
|
195
202
|
return { imports, code };
|
|
196
203
|
}
|