@marimo-team/frontend 0.23.11-dev22 → 0.23.11-dev23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{JsonOutput-BP1BF3ok.js → JsonOutput-BgU0YoWq.js} +12 -12
- package/dist/assets/{add-connection-dialog-B60ibI0N.js → add-connection-dialog-CYdyYsKy.js} +1 -1
- package/dist/assets/{agent-panel-HJKRcCdY.js → agent-panel-C3fnscrX.js} +1 -1
- package/dist/assets/{cell-editor-Bx7gOPwL.js → cell-editor-KKuNgpaD.js} +1 -1
- package/dist/assets/{column-preview-BatLzSJO.js → column-preview-DSb2IIj-.js} +1 -1
- package/dist/assets/{command-palette-IMHTYfai.js → command-palette-CN7OBmHG.js} +1 -1
- package/dist/assets/{edit-page-BBtiKJhO.js → edit-page-_lMTxldP.js} +4 -4
- package/dist/assets/{file-explorer-panel-cxPI6o3h.js → file-explorer-panel-BhxWVmmA.js} +1 -1
- package/dist/assets/{form-b6jUTUMx.js → form-DMjMUXw1.js} +1 -1
- package/dist/assets/{hooks-CY4KeAYS.js → hooks-CvOsTpNH.js} +1 -1
- package/dist/assets/{index-CjSc3ZEy.js → index-DW5V-tbG.js} +2 -2
- package/dist/assets/{layout-B093uDWH.js → layout-CrjtGZlj.js} +3 -3
- package/dist/assets/{panels-CtE4FsFt.js → panels-DL9ZPvBQ.js} +1 -1
- package/dist/assets/{reveal-component-CYeSojfe.js → reveal-component-DuIVIgwS.js} +1 -1
- package/dist/assets/{run-page-Hxusxawi.js → run-page-IO7tlMDF.js} +1 -1
- package/dist/assets/{scratchpad-panel-Cs-2Mtyy.js → scratchpad-panel-DhudwLmZ.js} +1 -1
- package/dist/assets/{session-panel-DRwd_pTY.js → session-panel-B4I5vfLW.js} +1 -1
- package/dist/assets/{useNotebookActions-3Vk8OfKI.js → useNotebookActions-Bkh6zqQr.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/src/components/datasources/__tests__/install-package-button.test.tsx +11 -0
- package/src/components/datasources/install-package-button.tsx +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as ge}from"./chunk-LvLJmgfZ.js";import{d as je,l as ye,p as ve,u as X}from"./useEvent-D91BmmQi.js";import{t as Qe}from"./react-Bj1aDYRI.js";import{Br as oe,D as Ye,Fi as Ne,Fr as we,Gr as Ze,Gt as ea,Hr as ce,In as Se,Ir as _e,Jr as aa,Kr as ta,Kt as sa,Ln as la,Lr as na,M as ra,P as oa,Pr as me,Rr as ca,Vr as Ce,Wr as ma,Xr as ia,Zr as Ie,a as da,br as ie,f as ha,gr as ua,jr as xa,jt as pa,lr as fa,or as ba,qr as ke,qt as ga,sr as ja,vn as ya,yr as va,zn as Na,zt as wa}from"./cells-a44D37GV.js";import"./react-dom-CSu739Rf.js";import{t as Pe}from"./compiler-runtime-B3qBwwSJ.js";import{c as Sa}from"./utils-BGFUZat2.js";import{t as _a}from"./ErrorBoundary-clTdAaK7.js";import{t as Q}from"./cn-X2M2usMq.js";import{t as Ca}from"./jsx-runtime-PbYoItBR.js";import"./fullscreen-6ovMHcQN.js";import{n as Ia}from"./multi-map-DDbeVHF9.js";import"./popover-D1IutFqN.js";import{$ as Te,Q as de,et as ka,f as Fe,g as $e,h as he,m as ue,nt as Pa,p as le,rt as Ta,tt as Fa,u as $a}from"./JsonOutput-BP1BF3ok.js";import"./download-YFYBUFlh.js";import{r as Re}from"./radio-group-CCf-GEZ7.js";import{t as xe}from"./tooltip-CWSr2PfE.js";import{r as Ra,t as ne}from"./button-Db07tdz7.js";import"./dist-Dez1I5M9.js";import{u as Y}from"./arrays-DWxvyYxP.js";import"./cjs-DXo9vDEJ.js";import"./main-DmhaVp6Y.js";import"./useNonce-0SWz6w4W.js";import{i as Da}from"./strings-B-yaq2o7.js";import{r as Va}from"./requests-KshNNAOp.js";import{t as qa}from"./createLucideIcon-BTp1tQDO.js";import{t as Ba}from"./x-9vLEgLY6.js";import{a as La,r as Ma}from"./tree-actions-DwvEEjdS.js";import"./markdown-renderer-DhkuKp0Y.js";import{t as De}from"./add-connection-dialog-B60ibI0N.js";import{t as Ve}from"./plus-Dvg5FyTi.js";import{a as Ea}from"./input-DiAad2nt.js";import{n as Oa,o as za}from"./column-preview-BatLzSJO.js";import{t as Aa}from"./workflow-ClrYl5m7.js";import"./dist-DHMtQYxT.js";import"./dist-Bj9Iedc0.js";import"./dist-D-o1OXc9.js";import"./dist-BZhJ1bTM.js";import"./dist-DnIl7RU-.js";import"./session-DF0gSADo.js";import"./purify.es-DdxMtdqK.js";import"./dates-Digd3pPR.js";import{t as Ua}from"./copy-icon-C8Cq0-V0.js";import{t as Ga}from"./context-DE_5rdOV.js";import"./utils-TBIUapDT.js";import"./vega-loader.browser-BJ9oKrvH.js";import"./defaultLocale-CuYNS33t.js";import"./defaultLocale-CGfP-Ye3.js";import{t as qe}from"./cell-link-Bia8_3oN.js";import"./chunk-5FQGJX7Z-D-AUn5sP.js";import{r as Ha}from"./html-to-image-B6hPo7Eh.js";import{o as Ka}from"./focus-Ptvt4Jk-.js";import{n as pe}from"./useAsyncData-CT1LpOBD.js";import{a as Wa,i as Ja,n as Xa,o as Be,r as Qa,t as Ya}from"./table-BEAxH5RS.js";import"./react-resizable-panels.browser.esm-CgWOEYeG.js";import{a as Za,f as et,o as re,t as at}from"./command-Dzjey1r-.js";import{n as tt}from"./icons-D3YFXNmD.js";import{t as st}from"./useDeepCompareMemoize-zUHU--0D.js";import{t as lt}from"./empty-state-BpcrGgJU.js";import{n as nt,t as rt}from"./common-C9NNLp8D.js";import{a as ot,i as ct,n as Le,r as Me,t as Ee}from"./components-Cu0sIUo1.js";var mt=qa("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"}]]),U=Pe(),F=ge(Qe(),1),s=ge(Ca(),1),fe=1;function Oe(a){return 1.75+a*fe}function it(a){return 3+a*fe}function ze(a){return 3.25+a*fe}var A={engineEmpty:.75,engine:.75,database:1,tableLoading:2.75,tableSchemaless:2,columnLocal:1.25,columnPreview:2.5};function E(a){return{paddingLeft:`${a}rem`}}var dt=ve(a=>{let e=a(_e),t=a(Na),l=a(da);return Y(e,n=>{if(!n.variable_name)return-1;let i=Object.values(t).find(d=>d.name===n.variable_name);if(!i)return 0;let c=l.inOrderIds.indexOf(i.declaredBy[0]);return c===-1?0:c})});const ht=Ne("marimo:datasources:hideEmpty",!1,Se,{getOnInit:!0});function Ae(a){let e=!1,t=[];for(let l of a){if(!ce(l)||!oe(l)){t.push(l);continue}let n=l.child_schemas??[],i=Ae(n);if(l.tables.length===0&&i.length===0){e=!0;continue}if(i===n){t.push(l);continue}e=!0,t.push({...l,child_schemas:i})}return e?t:a}function ut(a){let e=!1,t=[];for(let l of a){if(Ce(l)&&l.schemas.length===0){e=!0;continue}if(l.schemas.length===0){t.push(l);continue}let n=Ae(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 Ue=ve(a=>{let e=new Map(a(xa));for(let t of Ie){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=>Ie.has(t.name)?1:0)}),xt=()=>{let a=(0,U.c)(40),[e,t]=F.useState(""),[l,n]=ye(ht),i=je(we),c=X(dt),d=X(Ue),r;e:{if(!l){r=d;break e}let f,v;a[0]===d?(f=a[1],v=a[2]):(f=!1,v=d.map(C=>{let k=ut(C.databases);return k===C.databases?C:(f=!0,{...C,databases:k})}),a[0]=d,a[1]=f,a[2]=v),r=f?v:d}let x=r;if(c.length===0&&x.length===0){let f;return a[3]===Symbol.for("react.memo_cache_sentinel")?(f=(0,s.jsx)(lt,{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)(Ve,{className:"h-4 w-4 ml-2"})]})}),icon:(0,s.jsx)(ie,{})}),a[3]=f):f=a[3],f}let h=!!e.trim(),m;a[4]===i?m=a[5]:(m=f=>{i(f.length>0),t(f)},a[4]=i,a[5]=m);let o;a[6]!==e||a[7]!==m?(o=(0,s.jsx)(Za,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:m,rootClassName:"flex-1 border-r border-b-0"}),a[6]=e,a[7]=m,a[8]=o):o=a[8];let p;a[9]===h?p=a[10]:(p=h&&(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)(Ba,{className:"h-4 w-4"})}),a[9]=h,a[10]=p);let S=!l,b;a[11]!==l||a[12]!==n?(b=()=>n(!l),a[11]=l,a[12]=n,a[13]=b):b=a[13];let N;a[14]!==S||a[15]!==b?(N=(0,s.jsx)(La,{"data-testid":"datasources-hide-empty-button",isVisible:S,onToggle:b,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]=S,a[15]=b,a[16]=N):N=a[16];let y;a[17]===Symbol.for("react.memo_cache_sentinel")?(y=(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)(Ve,{className:"h-4 w-4"})})}),a[17]=y):y=a[17];let j;a[18]!==o||a[19]!==p||a[20]!==N?(j=(0,s.jsxs)("div",{className:"flex items-center w-full border-b",children:[o,p,N,y]}),a[18]=o,a[19]=p,a[20]=N,a[21]=j):j=a[21];let g;if(a[22]!==x||a[23]!==e){let f;a[25]===e?f=a[26]:(f=v=>(0,s.jsx)(pt,{connection:v,hasChildren:v.databases.length>0,children:v.databases.map(C=>(0,s.jsx)(ft,{connection:v,database:C,searchValue:e},C.name))},v.name),a[25]=e,a[26]=f),g=x.map(f),a[22]=x,a[23]=e,a[24]=g}else g=a[24];let w;a[27]!==x.length||a[28]!==c.length?(w=x.length>0&&c.length>0&&(0,s.jsxs)(Fe,{className:"pr-2",style:E(A.engine),children:[(0,s.jsx)(tt,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-xs",children:"Python"})]}),a[27]=x.length,a[28]=c.length,a[29]=w):w=a[29];let u;a[30]!==e||a[31]!==c?(u=c.length>0&&(0,s.jsx)(be,{tables:c,searchValue:e}),a[30]=e,a[31]=c,a[32]=u):u=a[32];let _;a[33]!==w||a[34]!==u||a[35]!==g?(_=(0,s.jsxs)(et,{className:"flex flex-col",children:[g,w,u]}),a[33]=w,a[34]=u,a[35]=g,a[36]=_):_=a[36];let I;return a[37]!==_||a[38]!==j?(I=(0,s.jsxs)(at,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden",shouldFilter:!1,children:[j,_]}),a[37]=_,a[38]=j,a[39]=I):I=a[39],I};var pt=a=>{let e=(0,U.c)(26),{connection:t,children:l,hasChildren:n}=a,i=t.name===ia,c=i?"In-Memory":t.name,{previewDataSourceConnection:d}=Va(),r;e[0]!==t.name||e[1]!==d?(r=async()=>{await d({engine:t.name})},e[0]=t.name,e[1]=d,e[2]=r):r=e[2];let x=r,h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=E(A.engine),e[3]=h):h=e[3];let m;e[4]===t.dialect?m=e[5]:(m=(0,s.jsx)(pa,{className:"h-4 w-4 text-muted-foreground",name:t.dialect}),e[4]=t.dialect,e[5]=m);let o;e[6]===t.dialect?o=e[7]:(o=ba(t.dialect),e[6]=t.dialect,e[7]=o);let p;e[8]===o?p=e[9]:(p=(0,s.jsx)("span",{className:"text-xs",children:o}),e[8]=o,e[9]=p);let S=c,b;e[10]===S?b=e[11]:(b=(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(0,s.jsx)(ot,{variableName:S}),")"]}),e[10]=S,e[11]=b);let N;e[12]!==x||e[13]!==i?(N=!i&&(0,s.jsx)(Ma,{onClick:x,tooltip:"Refresh connection",className:"ml-auto h-4 p-0",iconClassName:"h-3.5 w-3.5"}),e[12]=x,e[13]=i,e[14]=N):N=e[14];let y;e[15]!==m||e[16]!==p||e[17]!==b||e[18]!==N?(y=(0,s.jsxs)(Fe,{className:"pr-2",style:h,children:[m,p,b,N]}),e[15]=m,e[16]=p,e[17]=b,e[18]=N,e[19]=y):y=e[19];let j;e[20]!==l||e[21]!==n?(j=n?l:(0,s.jsx)(le,{content:"No databases available",style:E(A.engineEmpty)}),e[20]=l,e[21]=n,e[22]=j):j=e[22];let g;return e[23]!==j||e[24]!==y?(g=(0,s.jsxs)(s.Fragment,{children:[y,j]}),e[23]=j,e[24]=y,e[25]=g):g=e[25],g},Ge=F.createContext(null);function He(){let a=F.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 ft=a=>{let e=(0,U.c)(21),{connection:t,database:l,searchValue:n}=a,i;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?(i={engineName:t.name,databaseName:l.name,dialect:t.dialect,defaultSchema:t.default_schema,defaultDatabase:t.default_database,searchValue:n},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]=i):i=e[6];let c=i,d=t.name,r=l.schemas,x;e[7]===l?x=e[8]:(x=Ce(l),e[7]=l,e[8]=x);let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=[],e[9]=h):h=e[9];let m;e[10]!==l.schemas||e[11]!==x?(m=(0,s.jsx)(We,{schemas:r,schemasResolved:x,schemaPath:h,depth:0}),e[10]=l.schemas,e[11]=x,e[12]=m):m=e[12];let o;e[13]!==m||e[14]!==c?(o=(0,s.jsx)(Ge.Provider,{value:c,children:m}),e[13]=m,e[14]=c,e[15]=o):o=e[15];let p;return e[16]!==t.name||e[17]!==l||e[18]!==n||e[19]!==o?(p=(0,s.jsx)(bt,{engineName:d,database:l,searchValue:n,children:o}),e[16]=t.name,e[17]=l,e[18]=n,e[19]=o,e[20]=p):p=e[20],p},bt=a=>{let e=(0,U.c)(29),{searchValue:t,engineName:l,database:n,children:i}=a,c;e[0]!==n||e[1]!==t?(c=ta(n,t),e[0]=n,e[1]=t,e[2]=c):c=e[2];let d=c,[r,x]=F.useState(d),[h,m]=F.useState(!1),[o,p]=F.useState(t),[S,b]=F.useState(d);(o!==t||S!==d)&&(p(t),b(d),x(d));let N;e[3]===Symbol.for("react.memo_cache_sentinel")?(N=E(A.database),e[3]=N):N=e[3];let y;e[4]!==r||e[5]!==h?(y=()=>{x(!r),m(!h)},e[4]=r,e[5]=h,e[6]=y):y=e[6];let j=`${l}:${n.name}`,g;e[7]===r?g=e[8]:(g=(0,s.jsx)($e,{isExpanded:r}),e[7]=r,e[8]=g);let w=h&&r?"text-foreground":"text-muted-foreground",u;e[9]===w?u=e[10]:(u=Q("h-4 w-4",w),e[9]=w,e[10]=u);let _;e[11]===u?_=e[12]:(_=(0,s.jsx)(ie,{className:u}),e[11]=u,e[12]=_);let I=h&&r&&"font-semibold",f;e[13]===I?f=e[14]:(f=Q(I),e[13]=I,e[14]=f);let v;e[15]===n.name?v=e[16]:(v=n.name===""?(0,s.jsx)("i",{children:"Not connected"}):n.name,e[15]=n.name,e[16]=v);let C;e[17]!==f||e[18]!==v?(C=(0,s.jsx)("span",{className:f,children:v}),e[17]=f,e[18]=v,e[19]=C):C=e[19];let k;e[20]!==C||e[21]!==y||e[22]!==j||e[23]!==g||e[24]!==_?(k=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:N,onSelect:y,value:j,children:[g,_,C]}),e[20]=C,e[21]=y,e[22]=j,e[23]=g,e[24]=_,e[25]=k):k=e[25];let P=r&&i,T;return e[26]!==k||e[27]!==P?(T=(0,s.jsxs)(s.Fragment,{children:[k,P]}),e[26]=k,e[27]=P,e[28]=T):T=e[28],T},We=a=>{let{schemas:e,schemasResolved:t,depth:l}=a,n=He(),{engineName:i,databaseName:c,searchValue:d}=n,{addSchemaList:r}=me(),x=st(a.schemaPath),[h,m]=F.useState(!1),{isPending:o,error:p}=pe(async()=>{if(!t&&i){m(!0);try{r({schemas:(await ea.request({engine:i,database:c,schemaPath:x})).schemas??[],sqlSchemaContext:{engine:i,database:c,schemaPath:x}})}finally{m(!1)}}},[t,i,c,x]),S=E(Oe(l));return o||h?(0,s.jsx)(he,{message:"Loading schemas...",style:S}):p?(0,s.jsx)(ue,{error:p,style:S}):e.length===0?(0,s.jsx)(le,{content:"No schemas available",style:S}):(0,s.jsx)(s.Fragment,{children:e.map(b=>ma(b.name)?(0,s.jsx)(be,{tables:b.tables,tablesResolved:ce(b),searchValue:d,sqlTableContext:Ke(n,{schema:b.name,schemaPath:x})},b.name):(0,s.jsx)(gt,{schema:b,schemaPath:[...x,b.name],depth:l},b.name))})},gt=a=>{let e=(0,U.c)(39),{schema:t,schemaPath:l,depth:n}=a,i=He(),{databaseName:c,searchValue:d}=i,r;e[0]!==t||e[1]!==d?(r=Ze(t,d),e[0]=t,e[1]=d,e[2]=r):r=e[2];let x=r,[h,m]=F.useState(x),[o,p]=F.useState(!1),[S,b]=F.useState(d),[N,y]=F.useState(x),j=`${c}:${l.join(".")}`,g;e[3]===t.child_schemas?g=e[4]:(g=t.child_schemas??[],e[3]=t.child_schemas,e[4]=g);let w=g;(S!==d||N!==x)&&(b(d),y(x),m(x));let u;e[5]===n?u=e[6]:(u=E(Oe(n)),e[5]=n,e[6]=u);let _;e[7]!==h||e[8]!==o?(_=()=>{m(!h),p(!o)},e[7]=h,e[8]=o,e[9]=_):_=e[9];let I;e[10]===h?I=e[11]:(I=(0,s.jsx)($e,{isExpanded:h}),e[10]=h,e[11]=I);let f=o&&h&&"text-foreground",v;e[12]===f?v=e[13]:(v=Q("h-4 w-4 text-muted-foreground",f),e[12]=f,e[13]=v);let C;e[14]===v?C=e[15]:(C=(0,s.jsx)(ua,{className:v}),e[14]=v,e[15]=C);let k=o&&h&&"font-semibold",P;e[16]===k?P=e[17]:(P=Q(k),e[16]=k,e[17]=P);let T;e[18]!==t.name||e[19]!==P?(T=(0,s.jsx)("span",{className:P,children:t.name}),e[18]=t.name,e[19]=P,e[20]=T):T=e[20];let R;e[21]!==T||e[22]!==u||e[23]!==_||e[24]!==I||e[25]!==C||e[26]!==j?(R=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:u,onSelect:_,value:j,children:[I,C,T]}),e[21]=T,e[22]=u,e[23]=_,e[24]=I,e[25]=C,e[26]=j,e[27]=R):R=e[27];let D;e[28]!==w||e[29]!==n||e[30]!==h||e[31]!==t||e[32]!==l||e[33]!==d||e[34]!==i?(D=h&&(0,s.jsxs)(s.Fragment,{children:[(w.length>0||!oe(t))&&(0,s.jsx)(We,{schemas:w,schemasResolved:oe(t),schemaPath:l,depth:n+1}),(0,s.jsx)(be,{tables:t.tables,tablesResolved:ce(t),searchValue:d,tableIndentRem:it(n),columnIndentRem:ze(n),sqlTableContext:Ke(i,{schema:t.name,schemaPath:l})})]}),e[28]=w,e[29]=n,e[30]=h,e[31]=t,e[32]=l,e[33]=d,e[34]=i,e[35]=D):D=e[35];let $;return e[36]!==R||e[37]!==D?($=(0,s.jsxs)(s.Fragment,{children:[R,D]}),e[36]=R,e[37]=D,e[38]=$):$=e[38],$},be=a=>{let e=(0,U.c)(31),{tables:t,sqlTableContext:l,searchValue:n,tablesResolved:i,tableIndentRem:c,columnIndentRem:d}=a,r=i===void 0?!0:i,{addTableList:x}=me(),[h,m]=F.useState(!1),o;e[0]!==x||e[1]!==l||e[2]!==r?(o=async()=>{if(!r&&l){m(!0);let{engine:u,database:_,schema:I,schemaPath:f}=l,v=await ga.request({engine:u,database:_,schema:I,schemaPath:f??[]});if(!(v!=null&&v.tables))throw m(!1),Error("No tables available");x({tables:v.tables,sqlTableContext:l}),m(!1)}},e[0]=x,e[1]=l,e[2]=r,e[3]=o):o=e[3];let p;e[4]!==l||e[5]!==r?(p=[r,l],e[4]=l,e[5]=r,e[6]=p):p=e[6];let{isPending:S,error:b}=pe(o,p),N=c??A.tableLoading,y;e[7]===N?y=e[8]:(y=E(N),e[7]=N,e[8]=y);let j=y;if(S||h){let u;return e[9]===j?u=e[10]:(u=(0,s.jsx)(he,{message:"Loading tables...",style:j}),e[9]=j,e[10]=u),u}if(b){let u;return e[11]!==b||e[12]!==j?(u=(0,s.jsx)(ue,{error:b,style:j}),e[11]=b,e[12]=j,e[13]=u):u=e[13],u}if(t.length===0){let u;return e[14]===j?u=e[15]:(u=(0,s.jsx)(le,{content:"No tables found",style:j}),e[14]=j,e[15]=u),u}let g;if(e[16]!==d||e[17]!==n||e[18]!==l||e[19]!==c||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 _=t.filter(u),I;e[24]!==d||e[25]!==n||e[26]!==l||e[27]!==c?(I=f=>(0,s.jsx)(jt,{table:f,sqlTableContext:l,isSearching:!!n,tableIndentRem:c,columnIndentRem:d},f.name),e[24]=d,e[25]=n,e[26]=l,e[27]=c,e[28]=I):I=e[28],g=_.map(I),e[16]=d,e[17]=n,e[18]=l,e[19]=c,e[20]=t,e[21]=g}else g=e[21];let w;return e[29]===g?w=e[30]:(w=(0,s.jsx)(s.Fragment,{children:g}),e[29]=g,e[30]=w),w},jt=a=>{let e=(0,U.c)(69),{table:t,sqlTableContext:l,isSearching:n,tableIndentRem:i,columnIndentRem:c}=a,{addTable:d}=me(),[r,x]=F.useState(!1),h=t.columns.length>0,m;e[0]!==d||e[1]!==r||e[2]!==l||e[3]!==t.name||e[4]!==h?(m=async()=>{if(r&&!h&&l){let{engine:L,database:ae,schema:te,schemaPath:Xe}=l,se=await sa.request({engine:L,database:ae,schema:te,tableName:t.name,schemaPath:Xe??[]});if(!(se!=null&&se.table))throw Error("No table details available");d({table:se.table,sqlTableContext:l})}},e[0]=d,e[1]=r,e[2]=l,e[3]=t.name,e[4]=h,e[5]=m):m=e[5];let o;e[6]!==r||e[7]!==h?(o=[r,h],e[6]=r,e[7]=h,e[8]=o):o=e[8];let{isFetching:p,isPending:S,error:b}=pe(m,o),N=X(Sa),y=Ka(),{createNewCell:j}=Ye(),g=Re(),w;e[9]!==g||e[10]!==N||e[11]!==j||e[12]!==y||e[13]!==l||e[14]!==t?(w=()=>{Ha({autoInstantiate:N,createNewCell:j,fromCellId:y}),g((()=>{if(t.source_type==="catalog"){let L=l!=null&&l.database?[l.database,...l.schemaPath??[],t.name].join("."):t.name;return`${t.engine}.load_table("${L}")`}if(l)return ke({table:t,columnName:"*",sqlTableContext:l});switch(t.source_type){case"local":return`mo.ui.table(${t.name})`;case"duckdb":case"connection":return ke({table:t,columnName:"*",sqlTableContext:l});default:return Da(t.source_type),""}})())},e[9]=g,e[10]=N,e[11]=j,e[12]=y,e[13]=l,e[14]=t,e[15]=w):w=e[15];let u=w,_;e[16]!==t.num_columns||e[17]!==t.num_rows?(_=()=>{let L=[];return t.num_rows!=null&&L.push(`${t.num_rows} rows`),t.num_columns!=null&&L.push(`${t.num_columns} columns`),L.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:L.join(", ")})})},e[16]=t.num_columns,e[17]=t.num_rows,e[18]=_):_=e[18];let I=_,f;e[19]!==c||e[20]!==b||e[21]!==p||e[22]!==S||e[23]!==l||e[24]!==t?(f=()=>{let L=E(c??A.tableLoading);if(S||p)return(0,s.jsx)(he,{message:"Loading columns...",style:L});if(b)return(0,s.jsx)(ue,{error:b,style:L});let ae=t.columns;return ae.length===0?(0,s.jsx)(le,{content:"No columns found",style:L}):ae.map(te=>(0,s.jsx)(yt,{table:t,column:te,sqlTableContext:l,columnIndentRem:c},te.name))},e[19]=c,e[20]=b,e[21]=p,e[22]=S,e[23]=l,e[24]=t,e[25]=f):f=e[25];let v=f,C;e[26]!==r||e[27]!==n||e[28]!==t.source_type||e[29]!==t.type?(C=()=>{if(t.source_type!=="local")return(0,s.jsx)(t.type==="table"?fa:va,{className:"h-3 w-3",strokeWidth:r||n?2.5:void 0})},e[26]=r,e[27]=n,e[28]=t.source_type,e[29]=t.type,e[30]=C):C=e[30];let k=C,P;e[31]!==l||e[32]!==t.name?(P=aa(l,t.name),e[31]=l,e[32]=t.name,e[33]=P):P=e[33];let T=P,R=i??(l?A.tableSchemaless:0),D=(r||n)&&"font-semibold",$;e[34]===D?$=e[35]:($=Q("rounded-none group h-8 cursor-pointer",D),e[34]=D,e[35]=$);let V;e[36]===R?V=e[37]:(V=E(R),e[36]=R,e[37]=V);let q;e[38]===r?q=e[39]:(q=()=>x(!r),e[38]=r,e[39]=q);let M;e[40]===k?M=e[41]:(M=k(),e[40]=k,e[41]=M);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]!==M||e[45]!==O?(z=(0,s.jsxs)("div",{className:"flex gap-2 items-center flex-1 pl-1",children:[M,O]}),e[44]=M,e[45]=O,e[46]=z):z=e[46];let B;e[47]===I?B=e[48]:(B=I(),e[47]=I,e[48]=B);let H;e[49]===u?H=e[50]:(H=Ra.stopPropagation(()=>u()),e[49]=u,e[50]=H);let Z;e[51]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,s.jsx)(za,{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]!==r||e[55]!==V||e[56]!==q||e[57]!==z||e[58]!==B||e[59]!==K||e[60]!==$||e[61]!==T?(W=(0,s.jsxs)(re,{className:$,style:V,value:T,"aria-selected":r,forceMount:!0,onSelect:q,children:[z,B,K]}),e[54]=r,e[55]=V,e[56]=q,e[57]=z,e[58]=B,e[59]=K,e[60]=$,e[61]=T,e[62]=W):W=e[62];let J;e[63]!==r||e[64]!==v?(J=r&&v(),e[63]=r,e[64]=v,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},yt=a=>{var O,z;let e=(0,U.c)(51),{table:t,column:l,sqlTableContext:n,columnIndentRem:i}=a,[c,d]=F.useState(!1),r=X(we),x=je(na);r&&c&&d(!1),x(c?B=>new Set([...B,`${t.name}:${l.name}`]):B=>(B.delete(`${t.name}:${l.name}`),new Set(B)));let h=Re(),{columnsPreviews:m}=ca(),o;e[0]!==l.name||e[1]!==t.primary_keys?(o=((O=t.primary_keys)==null?void 0:O.includes(l.name))||!1,e[0]=l.name,e[1]=t.primary_keys,e[2]=o):o=e[2];let p=o,S;e[3]!==l.name||e[4]!==t.indexes?(S=((z=t.indexes)==null?void 0:z.includes(l.name))||!1,e[3]=l.name,e[4]=t.indexes,e[5]=S):S=e[5];let b=S,N;e[6]===h?N=e[7]:(N=B=>{h(B)},e[6]=h,e[7]=N);let y=N,j=vt,g=c?"font-semibold":"",w;e[8]!==l.name||e[9]!==g?(w=(0,s.jsx)("span",{className:g,children:l.name}),e[8]=l.name,e[9]=g,e[10]=w):w=e[10];let u=w,_=`${t.name}.${l.name}`,I=`${t.name}.${l.name}`,f;e[11]===c?f=e[12]:(f=()=>d(!c),e[11]=c,e[12]=f);let v;e[13]!==i||e[14]!==n?(v=i??(n?ze(0):A.columnLocal),e[13]=i,e[14]=n,e[15]=v):v=e[15];let C;e[16]===v?C=e[17]:(C=E(v),e[16]=v,e[17]=C);let k;e[18]!==l.type||e[19]!==u?(k=(0,s.jsx)($a,{columnName:u,dataType:l.type}),e[18]=l.type,e[19]=u,e[20]=k):k=e[20];let P;e[21]===p?P=e[22]:(P=p&&j({tooltipContent:"Primary key",content:"PK"}),e[21]=p,e[22]=P);let T;e[23]===b?T=e[24]:(T=b&&j({tooltipContent:"Indexed",content:"IDX"}),e[23]=b,e[24]=T);let R;e[25]!==C||e[26]!==k||e[27]!==P||e[28]!==T?(R=(0,s.jsxs)("div",{className:"flex flex-row gap-2 items-center flex-1",style:C,children:[k,P,T]}),e[25]=C,e[26]=k,e[27]=P,e[28]=T,e[29]=R):R=e[29];let D;e[30]===l.name?D=e[31]:(D=(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)(Ua,{tooltip:!1,value:l.name,className:"h-3 w-3"})})}),e[30]=l.name,e[31]=D);let $;e[32]===l.external_type?$=e[33]:($=(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:l.external_type}),e[32]=l.external_type,e[33]=$);let V;e[34]!==R||e[35]!==D||e[36]!==$||e[37]!==_||e[38]!==I||e[39]!==f?(V=(0,s.jsxs)(re,{className:"rounded-none py-1 group cursor-pointer",value:I,onSelect:f,children:[R,D,$]},_),e[34]=R,e[35]=D,e[36]=$,e[37]=_,e[38]=I,e[39]=f,e[40]=V):V=e[40];let q;e[41]!==l||e[42]!==m||e[43]!==y||e[44]!==c||e[45]!==n||e[46]!==t?(q=c&&(0,s.jsx)("div",{className:"pr-2 py-2 bg-(--slate-1) shadow-inner border-b",style:E(A.columnPreview),children:(0,s.jsx)(_a,{children:(0,s.jsx)(Oa,{table:t,column:l,onAddColumnChart:y,preview:m.get(n?`${n.database}.${n.schema}.${t.name}:${l.name}`:`${t.name}:${l.name}`),sqlTableContext:n})})}),e[41]=l,e[42]=m,e[43]=y,e[44]=c,e[45]=n,e[46]=t,e[47]=q):q=e[47];let M;return e[48]!==V||e[49]!==q?(M=(0,s.jsxs)(s.Fragment,{children:[V,q]}),e[48]=V,e[49]=q,e[50]=M):M=e[50],M};function vt(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 Vs(a){return a}var G={name:"name",type:"type-value",defs:"defs-refs"},Nt=[{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)(rt,{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=i=>{let c=ha(i);c&&ya(c,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)(mt,{className:"w-3.5 h-3.5 text-muted-foreground"})}),e.length===1?(0,s.jsx)(qe,{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((i,c)=>(0,s.jsxs)("span",{className:"flex",children:[(0,s.jsx)(qe,{variant:"focus",cellId:i,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>n(i)},i),c<e.length-1&&", "]},i))})]}),(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)(Aa,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,s.jsx)(nt,{maxCount:3,cellIds:t,skipScroll:!0,onClick:n})]})]})}}];function wt({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,F.memo)(({className:a,cellIds:e,variables:t})=>{let[l,n]=F.useState([]),[i,c]=F.useState(""),d=oa(),{locale:r}=Ga(),x=(0,F.useMemo)(()=>{let m=o=>{let p=d[o];return wa(p)?`cell-${e.indexOf(o)}`:p??`cell-${e.indexOf(o)}`};return Object.values(t).map(o=>({...o,declaredByNames:o.declaredBy.map(m),usedByNames:o.usedBy.map(m)}))},[t,d,e]),h=ka({data:(0,F.useMemo)(()=>{let m=new Map;return e.forEach((o,p)=>m.set(o,p)),wt({variables:x,sort:l[0],cellIdToIndex:m})},[x,l,e]),columns:Nt,getCoreRowModel:Fa(),onGlobalFilterChange:c,getFilteredRowModel:Pa(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(m){return m.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:r,onSortingChange:n,getSortedRowModel:Ta(),state:{sorting:l,globalFilter:i}});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Ea,{className:"w-full",placeholder:"Search",value:i,onChange:m=>c(m.target.value)}),(0,s.jsxs)(Ya,{className:Q("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,s.jsx)(Wa,{children:(0,s.jsx)(Be,{className:"whitespace-nowrap text-xs",children:h.getFlatHeaders().map(m=>(0,s.jsx)(Ja,{className:"sticky top-0 bg-background border-b",children:Te(m.column.columnDef.header,m.getContext())},m.id))})}),(0,s.jsx)(Xa,{children:h.getRowModel().rows.map(m=>(0,s.jsx)(Be,{className:"hover:bg-accent",children:m.getVisibleCells().map(o=>(0,s.jsx)(Qa,{className:"border-b",children:Te(o.column.columnDef.cell,o.getContext())},o.id))},m.id))})]})]})});Je.displayName="VariableTable";var St=Pe(),_t=Ne("marimo:session-panel:state",{openSections:["variables"],hasUserInteracted:!1},Se),Ct=()=>{let a=(0,St.c)(24),e=la(),t=ra(),l=X(_e),n=X(Ue),[i,c]=ye(_t),d=l.length+n.length,r;a[0]!==d||a[1]!==i.hasUserInteracted||a[2]!==i.openSections?(r=!i.hasUserInteracted&&d>0?[...new Set([...i.openSections,"datasources"])]:i.openSections,a[0]=d,a[1]=i.hasUserInteracted,a[2]=i.openSections,a[3]=r):r=a[3];let x=r,h;a[4]===c?h=a[5]:(h=u=>{c({openSections:u,hasUserInteracted:!0})},a[4]=c,a[5]=h);let m=h,o=!x.includes("datasources")&&d>0,p;a[6]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(ie,{className:"w-4 h-4"}),a[6]=p):p=a[6];let S;a[7]!==d||a[8]!==o?(S=o&&(0,s.jsx)(ct,{children:d}),a[7]=d,a[8]=o,a[9]=S):S=a[9];let b;a[10]===S?b=a[11]:(b=(0,s.jsxs)(Me,{children:[p,"Data sources",S]}),a[10]=S,a[11]=b);let N;a[12]===Symbol.for("react.memo_cache_sentinel")?(N=(0,s.jsx)(Ee,{children:(0,s.jsx)(xt,{})}),a[12]=N):N=a[12];let y;a[13]===b?y=a[14]:(y=(0,s.jsxs)(Le,{value:"datasources",children:[b,N]}),a[13]=b,a[14]=y);let j;a[15]===Symbol.for("react.memo_cache_sentinel")?(j=(0,s.jsxs)(Me,{children:[(0,s.jsx)(ja,{className:"w-4 h-4"}),"Variables"]}),a[15]=j):j=a[15];let g;a[16]!==t||a[17]!==e?(g=(0,s.jsxs)(Le,{value:"variables",lastItem:!0,children:[j,(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]=g):g=a[18];let w;return a[19]!==m||a[20]!==x||a[21]!==y||a[22]!==g?(w=(0,s.jsxs)(Ia,{type:"multiple",value:x,onValueChange:m,className:"flex flex-col h-full overflow-auto",children:[y,g]}),a[19]=m,a[20]=x,a[21]=y,a[22]=g,a[23]=w):w=a[23],w};export{Ct as default};
|
|
1
|
+
import{s as ge}from"./chunk-LvLJmgfZ.js";import{d as je,l as ye,p as ve,u as X}from"./useEvent-D91BmmQi.js";import{t as Qe}from"./react-Bj1aDYRI.js";import{Br as oe,D as Ye,Fi as Ne,Fr as we,Gr as Ze,Gt as ea,Hr as ce,In as Se,Ir as _e,Jr as aa,Kr as ta,Kt as sa,Ln as la,Lr as na,M as ra,P as oa,Pr as me,Rr as ca,Vr as Ce,Wr as ma,Xr as ia,Zr as Ie,a as da,br as ie,f as ha,gr as ua,jr as xa,jt as pa,lr as fa,or as ba,qr as ke,qt as ga,sr as ja,vn as ya,yr as va,zn as Na,zt as wa}from"./cells-a44D37GV.js";import"./react-dom-CSu739Rf.js";import{t as Pe}from"./compiler-runtime-B3qBwwSJ.js";import{c as Sa}from"./utils-BGFUZat2.js";import{t as _a}from"./ErrorBoundary-clTdAaK7.js";import{t as Q}from"./cn-X2M2usMq.js";import{t as Ca}from"./jsx-runtime-PbYoItBR.js";import"./fullscreen-6ovMHcQN.js";import{n as Ia}from"./multi-map-DDbeVHF9.js";import"./popover-D1IutFqN.js";import{$ as Te,Q as de,et as ka,f as Fe,g as $e,h as he,m as ue,nt as Pa,p as le,rt as Ta,tt as Fa,u as $a}from"./JsonOutput-BgU0YoWq.js";import"./download-YFYBUFlh.js";import{r as Re}from"./radio-group-CCf-GEZ7.js";import{t as xe}from"./tooltip-CWSr2PfE.js";import{r as Ra,t as ne}from"./button-Db07tdz7.js";import"./dist-Dez1I5M9.js";import{u as Y}from"./arrays-DWxvyYxP.js";import"./cjs-DXo9vDEJ.js";import"./main-DmhaVp6Y.js";import"./useNonce-0SWz6w4W.js";import{i as Da}from"./strings-B-yaq2o7.js";import{r as Va}from"./requests-KshNNAOp.js";import{t as qa}from"./createLucideIcon-BTp1tQDO.js";import{t as Ba}from"./x-9vLEgLY6.js";import{a as La,r as Ma}from"./tree-actions-DwvEEjdS.js";import"./markdown-renderer-DhkuKp0Y.js";import{t as De}from"./add-connection-dialog-CYdyYsKy.js";import{t as Ve}from"./plus-Dvg5FyTi.js";import{a as Ea}from"./input-DiAad2nt.js";import{n as Oa,o as za}from"./column-preview-DSb2IIj-.js";import{t as Aa}from"./workflow-ClrYl5m7.js";import"./dist-DHMtQYxT.js";import"./dist-Bj9Iedc0.js";import"./dist-D-o1OXc9.js";import"./dist-BZhJ1bTM.js";import"./dist-DnIl7RU-.js";import"./session-DF0gSADo.js";import"./purify.es-DdxMtdqK.js";import"./dates-Digd3pPR.js";import{t as Ua}from"./copy-icon-C8Cq0-V0.js";import{t as Ga}from"./context-DE_5rdOV.js";import"./utils-TBIUapDT.js";import"./vega-loader.browser-BJ9oKrvH.js";import"./defaultLocale-CuYNS33t.js";import"./defaultLocale-CGfP-Ye3.js";import{t as qe}from"./cell-link-Bia8_3oN.js";import"./chunk-5FQGJX7Z-D-AUn5sP.js";import{r as Ha}from"./html-to-image-B6hPo7Eh.js";import{o as Ka}from"./focus-Ptvt4Jk-.js";import{n as pe}from"./useAsyncData-CT1LpOBD.js";import{a as Wa,i as Ja,n as Xa,o as Be,r as Qa,t as Ya}from"./table-BEAxH5RS.js";import"./react-resizable-panels.browser.esm-CgWOEYeG.js";import{a as Za,f as et,o as re,t as at}from"./command-Dzjey1r-.js";import{n as tt}from"./icons-D3YFXNmD.js";import{t as st}from"./useDeepCompareMemoize-zUHU--0D.js";import{t as lt}from"./empty-state-BpcrGgJU.js";import{n as nt,t as rt}from"./common-C9NNLp8D.js";import{a as ot,i as ct,n as Le,r as Me,t as Ee}from"./components-Cu0sIUo1.js";var mt=qa("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"}]]),U=Pe(),F=ge(Qe(),1),s=ge(Ca(),1),fe=1;function Oe(a){return 1.75+a*fe}function it(a){return 3+a*fe}function ze(a){return 3.25+a*fe}var A={engineEmpty:.75,engine:.75,database:1,tableLoading:2.75,tableSchemaless:2,columnLocal:1.25,columnPreview:2.5};function E(a){return{paddingLeft:`${a}rem`}}var dt=ve(a=>{let e=a(_e),t=a(Na),l=a(da);return Y(e,n=>{if(!n.variable_name)return-1;let i=Object.values(t).find(d=>d.name===n.variable_name);if(!i)return 0;let c=l.inOrderIds.indexOf(i.declaredBy[0]);return c===-1?0:c})});const ht=Ne("marimo:datasources:hideEmpty",!1,Se,{getOnInit:!0});function Ae(a){let e=!1,t=[];for(let l of a){if(!ce(l)||!oe(l)){t.push(l);continue}let n=l.child_schemas??[],i=Ae(n);if(l.tables.length===0&&i.length===0){e=!0;continue}if(i===n){t.push(l);continue}e=!0,t.push({...l,child_schemas:i})}return e?t:a}function ut(a){let e=!1,t=[];for(let l of a){if(Ce(l)&&l.schemas.length===0){e=!0;continue}if(l.schemas.length===0){t.push(l);continue}let n=Ae(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 Ue=ve(a=>{let e=new Map(a(xa));for(let t of Ie){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=>Ie.has(t.name)?1:0)}),xt=()=>{let a=(0,U.c)(40),[e,t]=F.useState(""),[l,n]=ye(ht),i=je(we),c=X(dt),d=X(Ue),r;e:{if(!l){r=d;break e}let f,v;a[0]===d?(f=a[1],v=a[2]):(f=!1,v=d.map(C=>{let k=ut(C.databases);return k===C.databases?C:(f=!0,{...C,databases:k})}),a[0]=d,a[1]=f,a[2]=v),r=f?v:d}let x=r;if(c.length===0&&x.length===0){let f;return a[3]===Symbol.for("react.memo_cache_sentinel")?(f=(0,s.jsx)(lt,{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)(Ve,{className:"h-4 w-4 ml-2"})]})}),icon:(0,s.jsx)(ie,{})}),a[3]=f):f=a[3],f}let h=!!e.trim(),m;a[4]===i?m=a[5]:(m=f=>{i(f.length>0),t(f)},a[4]=i,a[5]=m);let o;a[6]!==e||a[7]!==m?(o=(0,s.jsx)(Za,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:m,rootClassName:"flex-1 border-r border-b-0"}),a[6]=e,a[7]=m,a[8]=o):o=a[8];let p;a[9]===h?p=a[10]:(p=h&&(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)(Ba,{className:"h-4 w-4"})}),a[9]=h,a[10]=p);let S=!l,b;a[11]!==l||a[12]!==n?(b=()=>n(!l),a[11]=l,a[12]=n,a[13]=b):b=a[13];let N;a[14]!==S||a[15]!==b?(N=(0,s.jsx)(La,{"data-testid":"datasources-hide-empty-button",isVisible:S,onToggle:b,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]=S,a[15]=b,a[16]=N):N=a[16];let y;a[17]===Symbol.for("react.memo_cache_sentinel")?(y=(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)(Ve,{className:"h-4 w-4"})})}),a[17]=y):y=a[17];let j;a[18]!==o||a[19]!==p||a[20]!==N?(j=(0,s.jsxs)("div",{className:"flex items-center w-full border-b",children:[o,p,N,y]}),a[18]=o,a[19]=p,a[20]=N,a[21]=j):j=a[21];let g;if(a[22]!==x||a[23]!==e){let f;a[25]===e?f=a[26]:(f=v=>(0,s.jsx)(pt,{connection:v,hasChildren:v.databases.length>0,children:v.databases.map(C=>(0,s.jsx)(ft,{connection:v,database:C,searchValue:e},C.name))},v.name),a[25]=e,a[26]=f),g=x.map(f),a[22]=x,a[23]=e,a[24]=g}else g=a[24];let w;a[27]!==x.length||a[28]!==c.length?(w=x.length>0&&c.length>0&&(0,s.jsxs)(Fe,{className:"pr-2",style:E(A.engine),children:[(0,s.jsx)(tt,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-xs",children:"Python"})]}),a[27]=x.length,a[28]=c.length,a[29]=w):w=a[29];let u;a[30]!==e||a[31]!==c?(u=c.length>0&&(0,s.jsx)(be,{tables:c,searchValue:e}),a[30]=e,a[31]=c,a[32]=u):u=a[32];let _;a[33]!==w||a[34]!==u||a[35]!==g?(_=(0,s.jsxs)(et,{className:"flex flex-col",children:[g,w,u]}),a[33]=w,a[34]=u,a[35]=g,a[36]=_):_=a[36];let I;return a[37]!==_||a[38]!==j?(I=(0,s.jsxs)(at,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden",shouldFilter:!1,children:[j,_]}),a[37]=_,a[38]=j,a[39]=I):I=a[39],I};var pt=a=>{let e=(0,U.c)(26),{connection:t,children:l,hasChildren:n}=a,i=t.name===ia,c=i?"In-Memory":t.name,{previewDataSourceConnection:d}=Va(),r;e[0]!==t.name||e[1]!==d?(r=async()=>{await d({engine:t.name})},e[0]=t.name,e[1]=d,e[2]=r):r=e[2];let x=r,h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=E(A.engine),e[3]=h):h=e[3];let m;e[4]===t.dialect?m=e[5]:(m=(0,s.jsx)(pa,{className:"h-4 w-4 text-muted-foreground",name:t.dialect}),e[4]=t.dialect,e[5]=m);let o;e[6]===t.dialect?o=e[7]:(o=ba(t.dialect),e[6]=t.dialect,e[7]=o);let p;e[8]===o?p=e[9]:(p=(0,s.jsx)("span",{className:"text-xs",children:o}),e[8]=o,e[9]=p);let S=c,b;e[10]===S?b=e[11]:(b=(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(0,s.jsx)(ot,{variableName:S}),")"]}),e[10]=S,e[11]=b);let N;e[12]!==x||e[13]!==i?(N=!i&&(0,s.jsx)(Ma,{onClick:x,tooltip:"Refresh connection",className:"ml-auto h-4 p-0",iconClassName:"h-3.5 w-3.5"}),e[12]=x,e[13]=i,e[14]=N):N=e[14];let y;e[15]!==m||e[16]!==p||e[17]!==b||e[18]!==N?(y=(0,s.jsxs)(Fe,{className:"pr-2",style:h,children:[m,p,b,N]}),e[15]=m,e[16]=p,e[17]=b,e[18]=N,e[19]=y):y=e[19];let j;e[20]!==l||e[21]!==n?(j=n?l:(0,s.jsx)(le,{content:"No databases available",style:E(A.engineEmpty)}),e[20]=l,e[21]=n,e[22]=j):j=e[22];let g;return e[23]!==j||e[24]!==y?(g=(0,s.jsxs)(s.Fragment,{children:[y,j]}),e[23]=j,e[24]=y,e[25]=g):g=e[25],g},Ge=F.createContext(null);function He(){let a=F.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 ft=a=>{let e=(0,U.c)(21),{connection:t,database:l,searchValue:n}=a,i;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?(i={engineName:t.name,databaseName:l.name,dialect:t.dialect,defaultSchema:t.default_schema,defaultDatabase:t.default_database,searchValue:n},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]=i):i=e[6];let c=i,d=t.name,r=l.schemas,x;e[7]===l?x=e[8]:(x=Ce(l),e[7]=l,e[8]=x);let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=[],e[9]=h):h=e[9];let m;e[10]!==l.schemas||e[11]!==x?(m=(0,s.jsx)(We,{schemas:r,schemasResolved:x,schemaPath:h,depth:0}),e[10]=l.schemas,e[11]=x,e[12]=m):m=e[12];let o;e[13]!==m||e[14]!==c?(o=(0,s.jsx)(Ge.Provider,{value:c,children:m}),e[13]=m,e[14]=c,e[15]=o):o=e[15];let p;return e[16]!==t.name||e[17]!==l||e[18]!==n||e[19]!==o?(p=(0,s.jsx)(bt,{engineName:d,database:l,searchValue:n,children:o}),e[16]=t.name,e[17]=l,e[18]=n,e[19]=o,e[20]=p):p=e[20],p},bt=a=>{let e=(0,U.c)(29),{searchValue:t,engineName:l,database:n,children:i}=a,c;e[0]!==n||e[1]!==t?(c=ta(n,t),e[0]=n,e[1]=t,e[2]=c):c=e[2];let d=c,[r,x]=F.useState(d),[h,m]=F.useState(!1),[o,p]=F.useState(t),[S,b]=F.useState(d);(o!==t||S!==d)&&(p(t),b(d),x(d));let N;e[3]===Symbol.for("react.memo_cache_sentinel")?(N=E(A.database),e[3]=N):N=e[3];let y;e[4]!==r||e[5]!==h?(y=()=>{x(!r),m(!h)},e[4]=r,e[5]=h,e[6]=y):y=e[6];let j=`${l}:${n.name}`,g;e[7]===r?g=e[8]:(g=(0,s.jsx)($e,{isExpanded:r}),e[7]=r,e[8]=g);let w=h&&r?"text-foreground":"text-muted-foreground",u;e[9]===w?u=e[10]:(u=Q("h-4 w-4",w),e[9]=w,e[10]=u);let _;e[11]===u?_=e[12]:(_=(0,s.jsx)(ie,{className:u}),e[11]=u,e[12]=_);let I=h&&r&&"font-semibold",f;e[13]===I?f=e[14]:(f=Q(I),e[13]=I,e[14]=f);let v;e[15]===n.name?v=e[16]:(v=n.name===""?(0,s.jsx)("i",{children:"Not connected"}):n.name,e[15]=n.name,e[16]=v);let C;e[17]!==f||e[18]!==v?(C=(0,s.jsx)("span",{className:f,children:v}),e[17]=f,e[18]=v,e[19]=C):C=e[19];let k;e[20]!==C||e[21]!==y||e[22]!==j||e[23]!==g||e[24]!==_?(k=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:N,onSelect:y,value:j,children:[g,_,C]}),e[20]=C,e[21]=y,e[22]=j,e[23]=g,e[24]=_,e[25]=k):k=e[25];let P=r&&i,T;return e[26]!==k||e[27]!==P?(T=(0,s.jsxs)(s.Fragment,{children:[k,P]}),e[26]=k,e[27]=P,e[28]=T):T=e[28],T},We=a=>{let{schemas:e,schemasResolved:t,depth:l}=a,n=He(),{engineName:i,databaseName:c,searchValue:d}=n,{addSchemaList:r}=me(),x=st(a.schemaPath),[h,m]=F.useState(!1),{isPending:o,error:p}=pe(async()=>{if(!t&&i){m(!0);try{r({schemas:(await ea.request({engine:i,database:c,schemaPath:x})).schemas??[],sqlSchemaContext:{engine:i,database:c,schemaPath:x}})}finally{m(!1)}}},[t,i,c,x]),S=E(Oe(l));return o||h?(0,s.jsx)(he,{message:"Loading schemas...",style:S}):p?(0,s.jsx)(ue,{error:p,style:S}):e.length===0?(0,s.jsx)(le,{content:"No schemas available",style:S}):(0,s.jsx)(s.Fragment,{children:e.map(b=>ma(b.name)?(0,s.jsx)(be,{tables:b.tables,tablesResolved:ce(b),searchValue:d,sqlTableContext:Ke(n,{schema:b.name,schemaPath:x})},b.name):(0,s.jsx)(gt,{schema:b,schemaPath:[...x,b.name],depth:l},b.name))})},gt=a=>{let e=(0,U.c)(39),{schema:t,schemaPath:l,depth:n}=a,i=He(),{databaseName:c,searchValue:d}=i,r;e[0]!==t||e[1]!==d?(r=Ze(t,d),e[0]=t,e[1]=d,e[2]=r):r=e[2];let x=r,[h,m]=F.useState(x),[o,p]=F.useState(!1),[S,b]=F.useState(d),[N,y]=F.useState(x),j=`${c}:${l.join(".")}`,g;e[3]===t.child_schemas?g=e[4]:(g=t.child_schemas??[],e[3]=t.child_schemas,e[4]=g);let w=g;(S!==d||N!==x)&&(b(d),y(x),m(x));let u;e[5]===n?u=e[6]:(u=E(Oe(n)),e[5]=n,e[6]=u);let _;e[7]!==h||e[8]!==o?(_=()=>{m(!h),p(!o)},e[7]=h,e[8]=o,e[9]=_):_=e[9];let I;e[10]===h?I=e[11]:(I=(0,s.jsx)($e,{isExpanded:h}),e[10]=h,e[11]=I);let f=o&&h&&"text-foreground",v;e[12]===f?v=e[13]:(v=Q("h-4 w-4 text-muted-foreground",f),e[12]=f,e[13]=v);let C;e[14]===v?C=e[15]:(C=(0,s.jsx)(ua,{className:v}),e[14]=v,e[15]=C);let k=o&&h&&"font-semibold",P;e[16]===k?P=e[17]:(P=Q(k),e[16]=k,e[17]=P);let T;e[18]!==t.name||e[19]!==P?(T=(0,s.jsx)("span",{className:P,children:t.name}),e[18]=t.name,e[19]=P,e[20]=T):T=e[20];let R;e[21]!==T||e[22]!==u||e[23]!==_||e[24]!==I||e[25]!==C||e[26]!==j?(R=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:u,onSelect:_,value:j,children:[I,C,T]}),e[21]=T,e[22]=u,e[23]=_,e[24]=I,e[25]=C,e[26]=j,e[27]=R):R=e[27];let D;e[28]!==w||e[29]!==n||e[30]!==h||e[31]!==t||e[32]!==l||e[33]!==d||e[34]!==i?(D=h&&(0,s.jsxs)(s.Fragment,{children:[(w.length>0||!oe(t))&&(0,s.jsx)(We,{schemas:w,schemasResolved:oe(t),schemaPath:l,depth:n+1}),(0,s.jsx)(be,{tables:t.tables,tablesResolved:ce(t),searchValue:d,tableIndentRem:it(n),columnIndentRem:ze(n),sqlTableContext:Ke(i,{schema:t.name,schemaPath:l})})]}),e[28]=w,e[29]=n,e[30]=h,e[31]=t,e[32]=l,e[33]=d,e[34]=i,e[35]=D):D=e[35];let $;return e[36]!==R||e[37]!==D?($=(0,s.jsxs)(s.Fragment,{children:[R,D]}),e[36]=R,e[37]=D,e[38]=$):$=e[38],$},be=a=>{let e=(0,U.c)(31),{tables:t,sqlTableContext:l,searchValue:n,tablesResolved:i,tableIndentRem:c,columnIndentRem:d}=a,r=i===void 0?!0:i,{addTableList:x}=me(),[h,m]=F.useState(!1),o;e[0]!==x||e[1]!==l||e[2]!==r?(o=async()=>{if(!r&&l){m(!0);let{engine:u,database:_,schema:I,schemaPath:f}=l,v=await ga.request({engine:u,database:_,schema:I,schemaPath:f??[]});if(!(v!=null&&v.tables))throw m(!1),Error("No tables available");x({tables:v.tables,sqlTableContext:l}),m(!1)}},e[0]=x,e[1]=l,e[2]=r,e[3]=o):o=e[3];let p;e[4]!==l||e[5]!==r?(p=[r,l],e[4]=l,e[5]=r,e[6]=p):p=e[6];let{isPending:S,error:b}=pe(o,p),N=c??A.tableLoading,y;e[7]===N?y=e[8]:(y=E(N),e[7]=N,e[8]=y);let j=y;if(S||h){let u;return e[9]===j?u=e[10]:(u=(0,s.jsx)(he,{message:"Loading tables...",style:j}),e[9]=j,e[10]=u),u}if(b){let u;return e[11]!==b||e[12]!==j?(u=(0,s.jsx)(ue,{error:b,style:j}),e[11]=b,e[12]=j,e[13]=u):u=e[13],u}if(t.length===0){let u;return e[14]===j?u=e[15]:(u=(0,s.jsx)(le,{content:"No tables found",style:j}),e[14]=j,e[15]=u),u}let g;if(e[16]!==d||e[17]!==n||e[18]!==l||e[19]!==c||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 _=t.filter(u),I;e[24]!==d||e[25]!==n||e[26]!==l||e[27]!==c?(I=f=>(0,s.jsx)(jt,{table:f,sqlTableContext:l,isSearching:!!n,tableIndentRem:c,columnIndentRem:d},f.name),e[24]=d,e[25]=n,e[26]=l,e[27]=c,e[28]=I):I=e[28],g=_.map(I),e[16]=d,e[17]=n,e[18]=l,e[19]=c,e[20]=t,e[21]=g}else g=e[21];let w;return e[29]===g?w=e[30]:(w=(0,s.jsx)(s.Fragment,{children:g}),e[29]=g,e[30]=w),w},jt=a=>{let e=(0,U.c)(69),{table:t,sqlTableContext:l,isSearching:n,tableIndentRem:i,columnIndentRem:c}=a,{addTable:d}=me(),[r,x]=F.useState(!1),h=t.columns.length>0,m;e[0]!==d||e[1]!==r||e[2]!==l||e[3]!==t.name||e[4]!==h?(m=async()=>{if(r&&!h&&l){let{engine:L,database:ae,schema:te,schemaPath:Xe}=l,se=await sa.request({engine:L,database:ae,schema:te,tableName:t.name,schemaPath:Xe??[]});if(!(se!=null&&se.table))throw Error("No table details available");d({table:se.table,sqlTableContext:l})}},e[0]=d,e[1]=r,e[2]=l,e[3]=t.name,e[4]=h,e[5]=m):m=e[5];let o;e[6]!==r||e[7]!==h?(o=[r,h],e[6]=r,e[7]=h,e[8]=o):o=e[8];let{isFetching:p,isPending:S,error:b}=pe(m,o),N=X(Sa),y=Ka(),{createNewCell:j}=Ye(),g=Re(),w;e[9]!==g||e[10]!==N||e[11]!==j||e[12]!==y||e[13]!==l||e[14]!==t?(w=()=>{Ha({autoInstantiate:N,createNewCell:j,fromCellId:y}),g((()=>{if(t.source_type==="catalog"){let L=l!=null&&l.database?[l.database,...l.schemaPath??[],t.name].join("."):t.name;return`${t.engine}.load_table("${L}")`}if(l)return ke({table:t,columnName:"*",sqlTableContext:l});switch(t.source_type){case"local":return`mo.ui.table(${t.name})`;case"duckdb":case"connection":return ke({table:t,columnName:"*",sqlTableContext:l});default:return Da(t.source_type),""}})())},e[9]=g,e[10]=N,e[11]=j,e[12]=y,e[13]=l,e[14]=t,e[15]=w):w=e[15];let u=w,_;e[16]!==t.num_columns||e[17]!==t.num_rows?(_=()=>{let L=[];return t.num_rows!=null&&L.push(`${t.num_rows} rows`),t.num_columns!=null&&L.push(`${t.num_columns} columns`),L.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:L.join(", ")})})},e[16]=t.num_columns,e[17]=t.num_rows,e[18]=_):_=e[18];let I=_,f;e[19]!==c||e[20]!==b||e[21]!==p||e[22]!==S||e[23]!==l||e[24]!==t?(f=()=>{let L=E(c??A.tableLoading);if(S||p)return(0,s.jsx)(he,{message:"Loading columns...",style:L});if(b)return(0,s.jsx)(ue,{error:b,style:L});let ae=t.columns;return ae.length===0?(0,s.jsx)(le,{content:"No columns found",style:L}):ae.map(te=>(0,s.jsx)(yt,{table:t,column:te,sqlTableContext:l,columnIndentRem:c},te.name))},e[19]=c,e[20]=b,e[21]=p,e[22]=S,e[23]=l,e[24]=t,e[25]=f):f=e[25];let v=f,C;e[26]!==r||e[27]!==n||e[28]!==t.source_type||e[29]!==t.type?(C=()=>{if(t.source_type!=="local")return(0,s.jsx)(t.type==="table"?fa:va,{className:"h-3 w-3",strokeWidth:r||n?2.5:void 0})},e[26]=r,e[27]=n,e[28]=t.source_type,e[29]=t.type,e[30]=C):C=e[30];let k=C,P;e[31]!==l||e[32]!==t.name?(P=aa(l,t.name),e[31]=l,e[32]=t.name,e[33]=P):P=e[33];let T=P,R=i??(l?A.tableSchemaless:0),D=(r||n)&&"font-semibold",$;e[34]===D?$=e[35]:($=Q("rounded-none group h-8 cursor-pointer",D),e[34]=D,e[35]=$);let V;e[36]===R?V=e[37]:(V=E(R),e[36]=R,e[37]=V);let q;e[38]===r?q=e[39]:(q=()=>x(!r),e[38]=r,e[39]=q);let M;e[40]===k?M=e[41]:(M=k(),e[40]=k,e[41]=M);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]!==M||e[45]!==O?(z=(0,s.jsxs)("div",{className:"flex gap-2 items-center flex-1 pl-1",children:[M,O]}),e[44]=M,e[45]=O,e[46]=z):z=e[46];let B;e[47]===I?B=e[48]:(B=I(),e[47]=I,e[48]=B);let H;e[49]===u?H=e[50]:(H=Ra.stopPropagation(()=>u()),e[49]=u,e[50]=H);let Z;e[51]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,s.jsx)(za,{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]!==r||e[55]!==V||e[56]!==q||e[57]!==z||e[58]!==B||e[59]!==K||e[60]!==$||e[61]!==T?(W=(0,s.jsxs)(re,{className:$,style:V,value:T,"aria-selected":r,forceMount:!0,onSelect:q,children:[z,B,K]}),e[54]=r,e[55]=V,e[56]=q,e[57]=z,e[58]=B,e[59]=K,e[60]=$,e[61]=T,e[62]=W):W=e[62];let J;e[63]!==r||e[64]!==v?(J=r&&v(),e[63]=r,e[64]=v,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},yt=a=>{var O,z;let e=(0,U.c)(51),{table:t,column:l,sqlTableContext:n,columnIndentRem:i}=a,[c,d]=F.useState(!1),r=X(we),x=je(na);r&&c&&d(!1),x(c?B=>new Set([...B,`${t.name}:${l.name}`]):B=>(B.delete(`${t.name}:${l.name}`),new Set(B)));let h=Re(),{columnsPreviews:m}=ca(),o;e[0]!==l.name||e[1]!==t.primary_keys?(o=((O=t.primary_keys)==null?void 0:O.includes(l.name))||!1,e[0]=l.name,e[1]=t.primary_keys,e[2]=o):o=e[2];let p=o,S;e[3]!==l.name||e[4]!==t.indexes?(S=((z=t.indexes)==null?void 0:z.includes(l.name))||!1,e[3]=l.name,e[4]=t.indexes,e[5]=S):S=e[5];let b=S,N;e[6]===h?N=e[7]:(N=B=>{h(B)},e[6]=h,e[7]=N);let y=N,j=vt,g=c?"font-semibold":"",w;e[8]!==l.name||e[9]!==g?(w=(0,s.jsx)("span",{className:g,children:l.name}),e[8]=l.name,e[9]=g,e[10]=w):w=e[10];let u=w,_=`${t.name}.${l.name}`,I=`${t.name}.${l.name}`,f;e[11]===c?f=e[12]:(f=()=>d(!c),e[11]=c,e[12]=f);let v;e[13]!==i||e[14]!==n?(v=i??(n?ze(0):A.columnLocal),e[13]=i,e[14]=n,e[15]=v):v=e[15];let C;e[16]===v?C=e[17]:(C=E(v),e[16]=v,e[17]=C);let k;e[18]!==l.type||e[19]!==u?(k=(0,s.jsx)($a,{columnName:u,dataType:l.type}),e[18]=l.type,e[19]=u,e[20]=k):k=e[20];let P;e[21]===p?P=e[22]:(P=p&&j({tooltipContent:"Primary key",content:"PK"}),e[21]=p,e[22]=P);let T;e[23]===b?T=e[24]:(T=b&&j({tooltipContent:"Indexed",content:"IDX"}),e[23]=b,e[24]=T);let R;e[25]!==C||e[26]!==k||e[27]!==P||e[28]!==T?(R=(0,s.jsxs)("div",{className:"flex flex-row gap-2 items-center flex-1",style:C,children:[k,P,T]}),e[25]=C,e[26]=k,e[27]=P,e[28]=T,e[29]=R):R=e[29];let D;e[30]===l.name?D=e[31]:(D=(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)(Ua,{tooltip:!1,value:l.name,className:"h-3 w-3"})})}),e[30]=l.name,e[31]=D);let $;e[32]===l.external_type?$=e[33]:($=(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:l.external_type}),e[32]=l.external_type,e[33]=$);let V;e[34]!==R||e[35]!==D||e[36]!==$||e[37]!==_||e[38]!==I||e[39]!==f?(V=(0,s.jsxs)(re,{className:"rounded-none py-1 group cursor-pointer",value:I,onSelect:f,children:[R,D,$]},_),e[34]=R,e[35]=D,e[36]=$,e[37]=_,e[38]=I,e[39]=f,e[40]=V):V=e[40];let q;e[41]!==l||e[42]!==m||e[43]!==y||e[44]!==c||e[45]!==n||e[46]!==t?(q=c&&(0,s.jsx)("div",{className:"pr-2 py-2 bg-(--slate-1) shadow-inner border-b",style:E(A.columnPreview),children:(0,s.jsx)(_a,{children:(0,s.jsx)(Oa,{table:t,column:l,onAddColumnChart:y,preview:m.get(n?`${n.database}.${n.schema}.${t.name}:${l.name}`:`${t.name}:${l.name}`),sqlTableContext:n})})}),e[41]=l,e[42]=m,e[43]=y,e[44]=c,e[45]=n,e[46]=t,e[47]=q):q=e[47];let M;return e[48]!==V||e[49]!==q?(M=(0,s.jsxs)(s.Fragment,{children:[V,q]}),e[48]=V,e[49]=q,e[50]=M):M=e[50],M};function vt(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 Vs(a){return a}var G={name:"name",type:"type-value",defs:"defs-refs"},Nt=[{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)(rt,{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=i=>{let c=ha(i);c&&ya(c,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)(mt,{className:"w-3.5 h-3.5 text-muted-foreground"})}),e.length===1?(0,s.jsx)(qe,{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((i,c)=>(0,s.jsxs)("span",{className:"flex",children:[(0,s.jsx)(qe,{variant:"focus",cellId:i,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>n(i)},i),c<e.length-1&&", "]},i))})]}),(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)(Aa,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,s.jsx)(nt,{maxCount:3,cellIds:t,skipScroll:!0,onClick:n})]})]})}}];function wt({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,F.memo)(({className:a,cellIds:e,variables:t})=>{let[l,n]=F.useState([]),[i,c]=F.useState(""),d=oa(),{locale:r}=Ga(),x=(0,F.useMemo)(()=>{let m=o=>{let p=d[o];return wa(p)?`cell-${e.indexOf(o)}`:p??`cell-${e.indexOf(o)}`};return Object.values(t).map(o=>({...o,declaredByNames:o.declaredBy.map(m),usedByNames:o.usedBy.map(m)}))},[t,d,e]),h=ka({data:(0,F.useMemo)(()=>{let m=new Map;return e.forEach((o,p)=>m.set(o,p)),wt({variables:x,sort:l[0],cellIdToIndex:m})},[x,l,e]),columns:Nt,getCoreRowModel:Fa(),onGlobalFilterChange:c,getFilteredRowModel:Pa(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(m){return m.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:r,onSortingChange:n,getSortedRowModel:Ta(),state:{sorting:l,globalFilter:i}});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Ea,{className:"w-full",placeholder:"Search",value:i,onChange:m=>c(m.target.value)}),(0,s.jsxs)(Ya,{className:Q("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,s.jsx)(Wa,{children:(0,s.jsx)(Be,{className:"whitespace-nowrap text-xs",children:h.getFlatHeaders().map(m=>(0,s.jsx)(Ja,{className:"sticky top-0 bg-background border-b",children:Te(m.column.columnDef.header,m.getContext())},m.id))})}),(0,s.jsx)(Xa,{children:h.getRowModel().rows.map(m=>(0,s.jsx)(Be,{className:"hover:bg-accent",children:m.getVisibleCells().map(o=>(0,s.jsx)(Qa,{className:"border-b",children:Te(o.column.columnDef.cell,o.getContext())},o.id))},m.id))})]})]})});Je.displayName="VariableTable";var St=Pe(),_t=Ne("marimo:session-panel:state",{openSections:["variables"],hasUserInteracted:!1},Se),Ct=()=>{let a=(0,St.c)(24),e=la(),t=ra(),l=X(_e),n=X(Ue),[i,c]=ye(_t),d=l.length+n.length,r;a[0]!==d||a[1]!==i.hasUserInteracted||a[2]!==i.openSections?(r=!i.hasUserInteracted&&d>0?[...new Set([...i.openSections,"datasources"])]:i.openSections,a[0]=d,a[1]=i.hasUserInteracted,a[2]=i.openSections,a[3]=r):r=a[3];let x=r,h;a[4]===c?h=a[5]:(h=u=>{c({openSections:u,hasUserInteracted:!0})},a[4]=c,a[5]=h);let m=h,o=!x.includes("datasources")&&d>0,p;a[6]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(ie,{className:"w-4 h-4"}),a[6]=p):p=a[6];let S;a[7]!==d||a[8]!==o?(S=o&&(0,s.jsx)(ct,{children:d}),a[7]=d,a[8]=o,a[9]=S):S=a[9];let b;a[10]===S?b=a[11]:(b=(0,s.jsxs)(Me,{children:[p,"Data sources",S]}),a[10]=S,a[11]=b);let N;a[12]===Symbol.for("react.memo_cache_sentinel")?(N=(0,s.jsx)(Ee,{children:(0,s.jsx)(xt,{})}),a[12]=N):N=a[12];let y;a[13]===b?y=a[14]:(y=(0,s.jsxs)(Le,{value:"datasources",children:[b,N]}),a[13]=b,a[14]=y);let j;a[15]===Symbol.for("react.memo_cache_sentinel")?(j=(0,s.jsxs)(Me,{children:[(0,s.jsx)(ja,{className:"w-4 h-4"}),"Variables"]}),a[15]=j):j=a[15];let g;a[16]!==t||a[17]!==e?(g=(0,s.jsxs)(Le,{value:"variables",lastItem:!0,children:[j,(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]=g):g=a[18];let w;return a[19]!==m||a[20]!==x||a[21]!==y||a[22]!==g?(w=(0,s.jsxs)(Ia,{type:"multiple",value:x,onValueChange:m,className:"flex flex-col h-full overflow-auto",children:[y,g]}),a[19]=m,a[20]=x,a[21]=y,a[22]=g,a[23]=w):w=a[23],w};export{Ct as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as We}from"./chunk-LvLJmgfZ.js";import{d as L,l as it,p as st,u as P}from"./useEvent-D91BmmQi.js";import{t as lt}from"./react-Bj1aDYRI.js";import{An as rt,Cr as dt,D as Me,E as ct,Mn as ht,Nn as pt,On as mt,Or as ut,Qt as ft,Tn as bt,Ui as be,_ as yt,br as kt,ct as xt,dt as De,h as _e,kn as wt,lt as gt,ni as jt,t as vt,vr as Ct}from"./cells-a44D37GV.js";import{t as I}from"./compiler-runtime-B3qBwwSJ.js";import{n as zt,r as Wt,x as Mt}from"./ai-model-dropdown-BUVX-tXn.js";import{_ as H,d as Se}from"./useEventListener-BfYriKqt.js";import{r as Dt,x as _t}from"./utils-BGFUZat2.js";import{n as z,t as Ae}from"./constants-B9JJ72XE.js";import{T as X,v as St,w as At}from"./config-Fh_0wwfW.js";import{t as Nt}from"./jsx-runtime-PbYoItBR.js";import{o as Pt}from"./alert-dialog-V2tySmFn.js";import{a as It,c as Et,i as Tt,n as Lt,r as Ht,s as Rt,t as qt}from"./select-sS-2VQvj.js";import{Nt as Ot}from"./JsonOutput-BP1BF3ok.js";import{c as Ne,d as ye,n as Bt,o as Ft,r as ke,t as Vt}from"./download-YFYBUFlh.js";import{t as Yt}from"./tooltip-CWSr2PfE.js";import{r as Ut,t as xe}from"./button-Db07tdz7.js";import{i as $t,t as Pe}from"./strings-B-yaq2o7.js";import{r as R}from"./requests-KshNNAOp.js";import{t as h}from"./createLucideIcon-BTp1tQDO.js";import{F as Kt,I as Gt,L as Ie,P as Jt,R as Qt,a as Ee,i as Te,u as Le}from"./layout-B093uDWH.js";import{t as He}from"./check-DQmqoJgr.js";import{r as Xt}from"./useCellActionButton-B8YCBRJi.js";import{t as Zt}from"./copy-CFO636Td.js";import{t as ea}from"./eye-off-6RDlHoCz.js";import{t as ta}from"./external-link-mfK38Tpg.js";import{t as Z}from"./file-ZPWSptQF.js";import{t as aa}from"./github-BZsqHbeC.js";import{u as oa}from"./form-b6jUTUMx.js";import{n as na,r as ia,t as sa}from"./youtube-DER9xpF0.js";import{i as la,n as Re}from"./add-connection-dialog-B60ibI0N.js";import{t as ra}from"./house-DTijHETb.js";import{t as da}from"./image-CzV694oU.js";import{t as ca}from"./link-D215MpkN.js";import{r as ha}from"./input-DiAad2nt.js";import{t as pa}from"./settings-CP-IXCzQ.js";import{t as ma}from"./sparkles-DctOjjEz.js";import{y as ua}from"./textarea-D1Q7dFo2.js";import{t as fa}from"./square-DPWHdF_-.js";import{t as W}from"./use-toast-BH8bU9Xf.js";import{n as qe,t as ba}from"./paths-kNeJ8nbe.js";import{o as ya}from"./session-DF0gSADo.js";import{n as ee}from"./copy-DlC1PYY-.js";import{r as ka}from"./useRunCells-BRYGWDtj.js";import{a as xa,c as wa,i as ga,n as ja,r as va}from"./dialog-CNmqslzW.js";import{n as we}from"./ImperativeModal-CEtvKaPt.js";import{r as Ca,t as Oe}from"./share-CDUcBp99.js";import{a as za}from"./cell-link-Bia8_3oN.js";import{a as Wa}from"./renderShortcut-BV7Qf4L2.js";import{t as Ma}from"./icons-D3YFXNmD.js";import{t as Da}from"./pair-with-agent-modal-DHxMYnfm.js";import{n as Be}from"./marimo-icons-D6kVaIsS.js";import{t as _a}from"./links-DYp0FOur.js";import{r as Sa,t as Fe}from"./hooks-CY4KeAYS.js";import{t as Ve}from"./types-DZmRsGZN.js";var Aa=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Na=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ye=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"}]]),Ue=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"}]]),$e=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"}]]),Pa=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"}]]),Ia=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"}]]),Ea=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"}]]),Ta=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"}]]),La=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ke=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"}]]),Ha=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"}]]),Ra=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"}]]),Ge=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"}]]),Je=I(),ge=We(lt(),1),a=We(Nt(),1),te="https://static.marimo.app";const qa=e=>{let t=(0,Je.c)(25),{onClose:n}=e,[o,s]=(0,ge.useState)(""),{exportAsHTML:r}=R(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${te}/static/${l}`,c;t[0]!==r||t[1]!==n||t[2]!==l?(c=async v=>{v.preventDefault(),n();let T=await r({download:!1,includeCode:!0,files:Jt.INSTANCE.filenames()}),M=W({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${te}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:T,path:l})}).catch(()=>{M.dismiss(),W({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:z.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),M.dismiss(),W({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]=c):c=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(wa,{children:"Share static notebook"}),t[4]=p):p=t[4];let g;t[5]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsxs)(xa,{children:[p,(0,a.jsxs)(va,{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]=g):g=t[5];let w;t[6]===Symbol.for("react.memo_cache_sentinel")?(w=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=w):w=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(ha,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:w,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)(Oa,{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)(xe,{"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)(xe,{"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)(ga,{children:[y,k]}),t[18]=y,t[19]=k,t[20]=x):x=t[20];let j;return t[21]!==c||t[22]!==x||t[23]!==b?(j=(0,a.jsx)(ja,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:c,children:[g,b,x]})}),t[21]=c,t[22]=x,t[23]=b,t[24]=j):j=t[24],j};var Oa=e=>{let t=(0,Je.c)(8),[n,o]=ge.useState(!1),s;t[0]===e.text?s=t[1]:(s=Ut.stopPropagation(async p=>{p.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)(Zt,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(xe,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let c;return t[5]!==n||t[6]!==i?(c=(0,a.jsx)(Yt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=c):c=t[7],c},Ba=I();function Fa(){let e=document.getElementsByClassName(Ae.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=be.findElement(t);if(!o){H.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:be.parse(o.id)}}}return H.warn("No visible output area found for scroll anchor"),null}function Va(e){if(!e){H.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(be.create(e.cellId));if(!t){H.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${Ae.outputArea}`)){H.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Qe(){let e=(0,Ba.c)(2),t=L(De),n;return e[0]===t?n=e[1]:(n=()=>{let o=Fa();t(s=>({mode:gt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Va(o)})})},e[0]=t,e[1]=n),n}const Xe=st(!1);var Ya=I();const Ua=()=>{let e=(0,Ya.c)(7),{selectedLayout:t}=Ee(),{setLayoutView:n}=Te();if(X()&&!pt("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)(Rt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Et,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Lt,{children:(0,a.jsxs)(Ht,{children:[(0,a.jsx)(It,{children:"View as"}),Ve.map(Ka)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(qt,{"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 $a(e){return(0,a.jsx)(Ze(e),{className:"h-4 w-4"})}function Ze(e){switch(e){case"vertical":return Ea;case"grid":return ia;case"slides":return Ke;default:return $t(e),fa}}function et(e){return Pe.startCase(e)}function Ka(e){return(0,a.jsx)(Tt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[$a(e),(0,a.jsx)("span",{children:et(e)})]})},e)}async function Ga(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ja=I();function Qa(e){let t=(0,Ja.c)(5),{openPrompt:n,closeModal:o}=we(),{sendCopy:s}=R(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=ba.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${qe.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let c=l.join(qe.dirname(e),i);s({source:e,destination:c}).then(()=>{o(),W({title:"Notebook copied",description:"A copy of the notebook has been created."}),_a(c)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Xa=()=>{let{updateCellConfig:e}=Me(),{saveCellConfig:t}=R();return(0,ge.useCallback)(async()=>{let n=new ft,o=_e(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:c,config:p}=o.cellData[i];p.hide_code||n.isSupported(c)&&(r[i]={hide_code:!0})}let l=Se.entries(r);if(l.length!==0){await t({configs:r});for(let[i,c]of l)e({cellId:i,config:c})}},[e])};var Za=I();function tt(){let e=(0,Za.c)(4),{openConfirm:t}=we(),n=L(St),{sendRestart:o}=R(),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)(Pt,{onClick:async()=>{n({state:At.CLOSING}),await o(),Ca()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var eo=I(),E=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function to(){var ve,Ce,ze;let e=(0,eo.c)(56),t=za(),{openModal:n,closeModal:o}=we(),{toggleApplication:s}=mt(),{selectedPanel:r}=wt(),[l]=it(De),i=P(xt),c=Xa(),[p]=_t(),g=P(bt),w=P(Dt),{updateCellConfig:u,undoDeleteCell:f,clearAllCellOutputs:b,addSetupCellIfDoesntExist:y,collapseAllCells:k,expandAllCells:x}=Me(),j=tt(),v=ka(),T=Qa(t),M=L(Xe),oe=L(zt),{handleClick:ne}=Wt(),ie=L(Mt),{exportAsIPYNB:se,exportAsMarkdown:le,readCode:D,saveCellConfig:re,updateCellOutputs:_}=R(),S=Sa(),de=P(yt),ce=P(vt),he=P(ct),{selectedLayout:q}=Ee(),{setLayoutView:pe}=Te(),O=Qe(),B=((ve=p.sharing)==null?void 0:ve.html)??!0,F=((Ce=p.sharing)==null?void 0:Ce.wasm)??!0,V=((ze=p.sharing)==null?void 0:ze.molab)??!0,je=!X(),me=q==="slides",at=wo,ot=xo,Y;e[0]!==t||e[1]!==S||e[2]!==_?(Y=async d=>{let{preset:m,title:C}=d;if(!t){ae();return}await Ne(C,async fe=>{await Fe({takeScreenshots:()=>S({progress:fe}),updateCellOutputs:_}),await Ga({filename:t,preset:m,downloadPDF:Bt})})},e[0]=t,e[1]=S,e[2]=_,e[3]=Y):Y=e[3];let A=Y,U;e[4]===A?U=e[5]:(U=async()=>{if(je){await A({preset:"document",title:"Downloading Document PDF..."});return}let d=new Event("export-beforeprint"),m=new Event("export-afterprint");window.dispatchEvent(d),setTimeout(ko,0),setTimeout(()=>window.dispatchEvent(m),0)},e[4]=A,e[5]=U);let $=U,K;e[6]!==se||e[7]!==t||e[8]!==S||e[9]!==_?(K=async()=>{if(!t){ae();return}await Ne("Downloading IPYNB...",async d=>{await Fe({takeScreenshots:()=>S({progress:d}),updateCellOutputs:_});let m=await se({download:!1});ke(new Blob([m],{type:"application/x-ipynb+json"}),ye.toIPYNB(document.title))})},e[6]=se,e[7]=t,e[8]=S,e[9]=_,e[10]=K):K=e[10];let ue=K,G;e[11]===Symbol.for("react.memo_cache_sentinel")?(G=(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}),e[11]=G):G=e[11];let J;e[12]===Symbol.for("react.memo_cache_sentinel")?(J=(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),e[12]=J):J=e[12];let N;e[13]===t?N=e[14]:(N=async()=>{if(!t){ae();return}await Le({filename:t,includeCode:!0})},e[13]=t,e[14]=N);let Q;return e[15]!==y||e[16]!==w||e[17]!==ce||e[18]!==g||e[19]!==b||e[20]!==o||e[21]!==k||e[22]!==T||e[23]!==A||e[24]!==x||e[25]!==le||e[26]!==t||e[27]!==$||e[28]!==ue||e[29]!==de||e[30]!==c||e[31]!==me||e[32]!==i||e[33]!==n||e[34]!==ne||e[35]!==D||e[36]!==j||e[37]!==v||e[38]!==re||e[39]!==q||e[40]!==r||e[41]!==M||e[42]!==ie||e[43]!==pe||e[44]!==oe||e[45]!==B||e[46]!==V||e[47]!==F||e[48]!==N||e[49]!==s||e[50]!==O||e[51]!==f||e[52]!==he||e[53]!==u||e[54]!==l.mode?(Q=[{icon:G,label:"Download",handle:E,dropdown:[{icon:J,label:"Download as HTML",handle:N},{icon:(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ae();return}await Le({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(Ma,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let d=await le({download:!1});ke(new Blob([d],{type:"text/plain"}),ye.toMarkdown(document.title))}},{icon:(0,a.jsx)(Ta,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:ue},{icon:(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let d=await D();ke(new Blob([d.contents],{type:"text/plain"}),ye.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(da,{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: ",Wa("global.hideCode",!1)]}),handle:yo},me?{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:E,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:ot(!0),hidden:!je,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)(ma,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:X(),handle:async()=>{n((0,a.jsx)(Da,{onClose:o}))}},{icon:(0,a.jsx)(Ha,{size:14,strokeWidth:1.5}),label:"Share",handle:E,hidden:!B&&!F&&!V,dropdown:[{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!B,handle:async()=>{n((0,a.jsx)(qa,{onClose:o}))}},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!F,handle:async()=>{await ee(Oe({code:(await D()).contents})),W({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!V,handle:async()=>{let d=Oe({code:(await D()).contents,baseUrl:`${z.molab}/new`});window.open(d,"_blank")}}]},{icon:(0,a.jsx)(La,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:E,dropdown:rt.flatMap(d=>{let m=d.type==="ai"&&!w;if(ht({panel:d,capabilities:g,aiEnabled:w})&&!m)return[];let{type:C,Icon:fe,additionalKeywords:nt}=d;return{label:Pe.startCase(C),rightElement:at(r===C),icon:(0,a.jsx)(fe,{size:14,strokeWidth:1.5}),handle:()=>{if(m){ne("ai","ai-features");return}s(C)},additionalKeywords:nt}})},{icon:(0,a.jsx)(Ke,{size:14,strokeWidth:1.5}),label:"Present as",handle:E,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(ua,{size:14,strokeWidth:1.5}):(0,a.jsx)(Kt,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{O()}},...Ve.map((d,m)=>{let C=Ze(d);return{divider:m===0,label:et(d),icon:(0,a.jsx)(C,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:q===d&&(0,a.jsx)(He,{size:14})}),handle:()=>{pe(d),l.mode==="edit"&&O()}}})]},{icon:(0,a.jsx)(Ia,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||X(),handle:T},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ee((await D()).contents),W({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Xt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!de||i,handle:async()=>{let d=jt(_e());await re({configs:Se.fromEntries(d.map(bo))});for(let m of d)u({cellId:m,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{y({})}},{icon:(0,a.jsx)(kt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Re,{onClose:o}))}},{icon:(0,a.jsx)(la,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Re,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:he,hidden:!ce||i,handle:()=>{f()}},{icon:(0,a.jsx)(Ra,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:j,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{v()}},{icon:(0,a.jsx)(dt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{b()}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:c,redundant:!0},{icon:(0,a.jsx)(Na,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:k,redundant:!0},{icon:(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:x,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ue,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>M(fo)},{icon:(0,a.jsx)(Gt,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>ie(uo)},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>oe(mo),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Resources",handle:E,dropdown:[{icon:(0,a.jsx)(ut,{size:14,strokeWidth:1.5}),label:"Documentation",handle:po},{icon:(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),label:"GitHub",handle:ho},{icon:(0,a.jsx)(na,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:co},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"YouTube",handle:ro},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"Changelog",handle:lo}]},{divider:!0,icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:so},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:io}].filter(no).map(ao),e[15]=y,e[16]=w,e[17]=ce,e[18]=g,e[19]=b,e[20]=o,e[21]=k,e[22]=T,e[23]=A,e[24]=x,e[25]=le,e[26]=t,e[27]=$,e[28]=ue,e[29]=de,e[30]=c,e[31]=me,e[32]=i,e[33]=n,e[34]=ne,e[35]=D,e[36]=j,e[37]=v,e[38]=re,e[39]=q,e[40]=r,e[41]=M,e[42]=ie,e[43]=pe,e[44]=oe,e[45]=B,e[46]=V,e[47]=F,e[48]=N,e[49]=s,e[50]=O,e[51]=f,e[52]=he,e[53]=u,e[54]=l.mode,e[55]=Q):Q=e[55],Q}function ao(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(oo)}:e}function oo(e){return!e.hidden}function no(e){return!e.hidden}function io(){let e=ya();window.open(e,"_blank")}function so(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function lo(){window.open(z.releasesPage,"_blank")}function ro(){window.open(z.youtube,"_blank")}function co(){window.open(z.discordLink,"_blank")}function ho(){window.open(z.githubPage,"_blank")}function po(){window.open(z.docsPage,"_blank")}function mo(e){return!e}function uo(e){return!e}function fo(e){return!e}function bo(e){return[e,{disabled:!1}]}async function yo(){let e=document.getElementById("App");e&&await Ft({element:e,filename:document.title,prepare:Vt})}function ko(){return window.print()}function xo(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 wo(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(He,{size:14})})}function ae(){W({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Qe as a,Ue as c,Xe as i,Ye as l,tt as n,Ge as o,Ua as r,$e as s,to as t};
|
|
1
|
+
import{s as We}from"./chunk-LvLJmgfZ.js";import{d as L,l as it,p as st,u as P}from"./useEvent-D91BmmQi.js";import{t as lt}from"./react-Bj1aDYRI.js";import{An as rt,Cr as dt,D as Me,E as ct,Mn as ht,Nn as pt,On as mt,Or as ut,Qt as ft,Tn as bt,Ui as be,_ as yt,br as kt,ct as xt,dt as De,h as _e,kn as wt,lt as gt,ni as jt,t as vt,vr as Ct}from"./cells-a44D37GV.js";import{t as I}from"./compiler-runtime-B3qBwwSJ.js";import{n as zt,r as Wt,x as Mt}from"./ai-model-dropdown-BUVX-tXn.js";import{_ as H,d as Se}from"./useEventListener-BfYriKqt.js";import{r as Dt,x as _t}from"./utils-BGFUZat2.js";import{n as z,t as Ae}from"./constants-B9JJ72XE.js";import{T as X,v as St,w as At}from"./config-Fh_0wwfW.js";import{t as Nt}from"./jsx-runtime-PbYoItBR.js";import{o as Pt}from"./alert-dialog-V2tySmFn.js";import{a as It,c as Et,i as Tt,n as Lt,r as Ht,s as Rt,t as qt}from"./select-sS-2VQvj.js";import{Nt as Ot}from"./JsonOutput-BgU0YoWq.js";import{c as Ne,d as ye,n as Bt,o as Ft,r as ke,t as Vt}from"./download-YFYBUFlh.js";import{t as Yt}from"./tooltip-CWSr2PfE.js";import{r as Ut,t as xe}from"./button-Db07tdz7.js";import{i as $t,t as Pe}from"./strings-B-yaq2o7.js";import{r as R}from"./requests-KshNNAOp.js";import{t as h}from"./createLucideIcon-BTp1tQDO.js";import{F as Kt,I as Gt,L as Ie,P as Jt,R as Qt,a as Ee,i as Te,u as Le}from"./layout-CrjtGZlj.js";import{t as He}from"./check-DQmqoJgr.js";import{r as Xt}from"./useCellActionButton-B8YCBRJi.js";import{t as Zt}from"./copy-CFO636Td.js";import{t as ea}from"./eye-off-6RDlHoCz.js";import{t as ta}from"./external-link-mfK38Tpg.js";import{t as Z}from"./file-ZPWSptQF.js";import{t as aa}from"./github-BZsqHbeC.js";import{u as oa}from"./form-DMjMUXw1.js";import{n as na,r as ia,t as sa}from"./youtube-DER9xpF0.js";import{i as la,n as Re}from"./add-connection-dialog-CYdyYsKy.js";import{t as ra}from"./house-DTijHETb.js";import{t as da}from"./image-CzV694oU.js";import{t as ca}from"./link-D215MpkN.js";import{r as ha}from"./input-DiAad2nt.js";import{t as pa}from"./settings-CP-IXCzQ.js";import{t as ma}from"./sparkles-DctOjjEz.js";import{y as ua}from"./textarea-D1Q7dFo2.js";import{t as fa}from"./square-DPWHdF_-.js";import{t as W}from"./use-toast-BH8bU9Xf.js";import{n as qe,t as ba}from"./paths-kNeJ8nbe.js";import{o as ya}from"./session-DF0gSADo.js";import{n as ee}from"./copy-DlC1PYY-.js";import{r as ka}from"./useRunCells-BRYGWDtj.js";import{a as xa,c as wa,i as ga,n as ja,r as va}from"./dialog-CNmqslzW.js";import{n as we}from"./ImperativeModal-CEtvKaPt.js";import{r as Ca,t as Oe}from"./share-CDUcBp99.js";import{a as za}from"./cell-link-Bia8_3oN.js";import{a as Wa}from"./renderShortcut-BV7Qf4L2.js";import{t as Ma}from"./icons-D3YFXNmD.js";import{t as Da}from"./pair-with-agent-modal-DHxMYnfm.js";import{n as Be}from"./marimo-icons-D6kVaIsS.js";import{t as _a}from"./links-DYp0FOur.js";import{r as Sa,t as Fe}from"./hooks-CvOsTpNH.js";import{t as Ve}from"./types-DZmRsGZN.js";var Aa=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Na=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ye=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"}]]),Ue=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"}]]),$e=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"}]]),Pa=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"}]]),Ia=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"}]]),Ea=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"}]]),Ta=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"}]]),La=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ke=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"}]]),Ha=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"}]]),Ra=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"}]]),Ge=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"}]]),Je=I(),ge=We(lt(),1),a=We(Nt(),1),te="https://static.marimo.app";const qa=e=>{let t=(0,Je.c)(25),{onClose:n}=e,[o,s]=(0,ge.useState)(""),{exportAsHTML:r}=R(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${te}/static/${l}`,c;t[0]!==r||t[1]!==n||t[2]!==l?(c=async v=>{v.preventDefault(),n();let T=await r({download:!1,includeCode:!0,files:Jt.INSTANCE.filenames()}),M=W({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${te}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:T,path:l})}).catch(()=>{M.dismiss(),W({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:z.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),M.dismiss(),W({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]=c):c=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(wa,{children:"Share static notebook"}),t[4]=p):p=t[4];let g;t[5]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsxs)(xa,{children:[p,(0,a.jsxs)(va,{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]=g):g=t[5];let w;t[6]===Symbol.for("react.memo_cache_sentinel")?(w=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=w):w=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(ha,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:w,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)(Oa,{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)(xe,{"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)(xe,{"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)(ga,{children:[y,k]}),t[18]=y,t[19]=k,t[20]=x):x=t[20];let j;return t[21]!==c||t[22]!==x||t[23]!==b?(j=(0,a.jsx)(ja,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:c,children:[g,b,x]})}),t[21]=c,t[22]=x,t[23]=b,t[24]=j):j=t[24],j};var Oa=e=>{let t=(0,Je.c)(8),[n,o]=ge.useState(!1),s;t[0]===e.text?s=t[1]:(s=Ut.stopPropagation(async p=>{p.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)(Zt,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(xe,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let c;return t[5]!==n||t[6]!==i?(c=(0,a.jsx)(Yt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=c):c=t[7],c},Ba=I();function Fa(){let e=document.getElementsByClassName(Ae.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=be.findElement(t);if(!o){H.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:be.parse(o.id)}}}return H.warn("No visible output area found for scroll anchor"),null}function Va(e){if(!e){H.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(be.create(e.cellId));if(!t){H.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${Ae.outputArea}`)){H.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Qe(){let e=(0,Ba.c)(2),t=L(De),n;return e[0]===t?n=e[1]:(n=()=>{let o=Fa();t(s=>({mode:gt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Va(o)})})},e[0]=t,e[1]=n),n}const Xe=st(!1);var Ya=I();const Ua=()=>{let e=(0,Ya.c)(7),{selectedLayout:t}=Ee(),{setLayoutView:n}=Te();if(X()&&!pt("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)(Rt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Et,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Lt,{children:(0,a.jsxs)(Ht,{children:[(0,a.jsx)(It,{children:"View as"}),Ve.map(Ka)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(qt,{"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 $a(e){return(0,a.jsx)(Ze(e),{className:"h-4 w-4"})}function Ze(e){switch(e){case"vertical":return Ea;case"grid":return ia;case"slides":return Ke;default:return $t(e),fa}}function et(e){return Pe.startCase(e)}function Ka(e){return(0,a.jsx)(Tt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[$a(e),(0,a.jsx)("span",{children:et(e)})]})},e)}async function Ga(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ja=I();function Qa(e){let t=(0,Ja.c)(5),{openPrompt:n,closeModal:o}=we(),{sendCopy:s}=R(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=ba.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${qe.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let c=l.join(qe.dirname(e),i);s({source:e,destination:c}).then(()=>{o(),W({title:"Notebook copied",description:"A copy of the notebook has been created."}),_a(c)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Xa=()=>{let{updateCellConfig:e}=Me(),{saveCellConfig:t}=R();return(0,ge.useCallback)(async()=>{let n=new ft,o=_e(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:c,config:p}=o.cellData[i];p.hide_code||n.isSupported(c)&&(r[i]={hide_code:!0})}let l=Se.entries(r);if(l.length!==0){await t({configs:r});for(let[i,c]of l)e({cellId:i,config:c})}},[e])};var Za=I();function tt(){let e=(0,Za.c)(4),{openConfirm:t}=we(),n=L(St),{sendRestart:o}=R(),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)(Pt,{onClick:async()=>{n({state:At.CLOSING}),await o(),Ca()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var eo=I(),E=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function to(){var ve,Ce,ze;let e=(0,eo.c)(56),t=za(),{openModal:n,closeModal:o}=we(),{toggleApplication:s}=mt(),{selectedPanel:r}=wt(),[l]=it(De),i=P(xt),c=Xa(),[p]=_t(),g=P(bt),w=P(Dt),{updateCellConfig:u,undoDeleteCell:f,clearAllCellOutputs:b,addSetupCellIfDoesntExist:y,collapseAllCells:k,expandAllCells:x}=Me(),j=tt(),v=ka(),T=Qa(t),M=L(Xe),oe=L(zt),{handleClick:ne}=Wt(),ie=L(Mt),{exportAsIPYNB:se,exportAsMarkdown:le,readCode:D,saveCellConfig:re,updateCellOutputs:_}=R(),S=Sa(),de=P(yt),ce=P(vt),he=P(ct),{selectedLayout:q}=Ee(),{setLayoutView:pe}=Te(),O=Qe(),B=((ve=p.sharing)==null?void 0:ve.html)??!0,F=((Ce=p.sharing)==null?void 0:Ce.wasm)??!0,V=((ze=p.sharing)==null?void 0:ze.molab)??!0,je=!X(),me=q==="slides",at=wo,ot=xo,Y;e[0]!==t||e[1]!==S||e[2]!==_?(Y=async d=>{let{preset:m,title:C}=d;if(!t){ae();return}await Ne(C,async fe=>{await Fe({takeScreenshots:()=>S({progress:fe}),updateCellOutputs:_}),await Ga({filename:t,preset:m,downloadPDF:Bt})})},e[0]=t,e[1]=S,e[2]=_,e[3]=Y):Y=e[3];let A=Y,U;e[4]===A?U=e[5]:(U=async()=>{if(je){await A({preset:"document",title:"Downloading Document PDF..."});return}let d=new Event("export-beforeprint"),m=new Event("export-afterprint");window.dispatchEvent(d),setTimeout(ko,0),setTimeout(()=>window.dispatchEvent(m),0)},e[4]=A,e[5]=U);let $=U,K;e[6]!==se||e[7]!==t||e[8]!==S||e[9]!==_?(K=async()=>{if(!t){ae();return}await Ne("Downloading IPYNB...",async d=>{await Fe({takeScreenshots:()=>S({progress:d}),updateCellOutputs:_});let m=await se({download:!1});ke(new Blob([m],{type:"application/x-ipynb+json"}),ye.toIPYNB(document.title))})},e[6]=se,e[7]=t,e[8]=S,e[9]=_,e[10]=K):K=e[10];let ue=K,G;e[11]===Symbol.for("react.memo_cache_sentinel")?(G=(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}),e[11]=G):G=e[11];let J;e[12]===Symbol.for("react.memo_cache_sentinel")?(J=(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),e[12]=J):J=e[12];let N;e[13]===t?N=e[14]:(N=async()=>{if(!t){ae();return}await Le({filename:t,includeCode:!0})},e[13]=t,e[14]=N);let Q;return e[15]!==y||e[16]!==w||e[17]!==ce||e[18]!==g||e[19]!==b||e[20]!==o||e[21]!==k||e[22]!==T||e[23]!==A||e[24]!==x||e[25]!==le||e[26]!==t||e[27]!==$||e[28]!==ue||e[29]!==de||e[30]!==c||e[31]!==me||e[32]!==i||e[33]!==n||e[34]!==ne||e[35]!==D||e[36]!==j||e[37]!==v||e[38]!==re||e[39]!==q||e[40]!==r||e[41]!==M||e[42]!==ie||e[43]!==pe||e[44]!==oe||e[45]!==B||e[46]!==V||e[47]!==F||e[48]!==N||e[49]!==s||e[50]!==O||e[51]!==f||e[52]!==he||e[53]!==u||e[54]!==l.mode?(Q=[{icon:G,label:"Download",handle:E,dropdown:[{icon:J,label:"Download as HTML",handle:N},{icon:(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ae();return}await Le({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(Ma,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let d=await le({download:!1});ke(new Blob([d],{type:"text/plain"}),ye.toMarkdown(document.title))}},{icon:(0,a.jsx)(Ta,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:ue},{icon:(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let d=await D();ke(new Blob([d.contents],{type:"text/plain"}),ye.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(da,{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: ",Wa("global.hideCode",!1)]}),handle:yo},me?{divider:!0,icon:(0,a.jsx)(Z,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:E,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:ot(!0),hidden:!je,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)(ma,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:X(),handle:async()=>{n((0,a.jsx)(Da,{onClose:o}))}},{icon:(0,a.jsx)(Ha,{size:14,strokeWidth:1.5}),label:"Share",handle:E,hidden:!B&&!F&&!V,dropdown:[{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!B,handle:async()=>{n((0,a.jsx)(qa,{onClose:o}))}},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!F,handle:async()=>{await ee(Oe({code:(await D()).contents})),W({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!V,handle:async()=>{let d=Oe({code:(await D()).contents,baseUrl:`${z.molab}/new`});window.open(d,"_blank")}}]},{icon:(0,a.jsx)(La,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:E,dropdown:rt.flatMap(d=>{let m=d.type==="ai"&&!w;if(ht({panel:d,capabilities:g,aiEnabled:w})&&!m)return[];let{type:C,Icon:fe,additionalKeywords:nt}=d;return{label:Pe.startCase(C),rightElement:at(r===C),icon:(0,a.jsx)(fe,{size:14,strokeWidth:1.5}),handle:()=>{if(m){ne("ai","ai-features");return}s(C)},additionalKeywords:nt}})},{icon:(0,a.jsx)(Ke,{size:14,strokeWidth:1.5}),label:"Present as",handle:E,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(ua,{size:14,strokeWidth:1.5}):(0,a.jsx)(Kt,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{O()}},...Ve.map((d,m)=>{let C=Ze(d);return{divider:m===0,label:et(d),icon:(0,a.jsx)(C,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:q===d&&(0,a.jsx)(He,{size:14})}),handle:()=>{pe(d),l.mode==="edit"&&O()}}})]},{icon:(0,a.jsx)(Ia,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||X(),handle:T},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ee((await D()).contents),W({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Xt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!de||i,handle:async()=>{let d=jt(_e());await re({configs:Se.fromEntries(d.map(bo))});for(let m of d)u({cellId:m,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{y({})}},{icon:(0,a.jsx)(kt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Re,{onClose:o}))}},{icon:(0,a.jsx)(la,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Re,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:he,hidden:!ce||i,handle:()=>{f()}},{icon:(0,a.jsx)(Ra,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:j,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{v()}},{icon:(0,a.jsx)(dt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{b()}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:c,redundant:!0},{icon:(0,a.jsx)(Na,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:k,redundant:!0},{icon:(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:x,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ue,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>M(fo)},{icon:(0,a.jsx)(Gt,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>ie(uo)},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>oe(mo),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Resources",handle:E,dropdown:[{icon:(0,a.jsx)(ut,{size:14,strokeWidth:1.5}),label:"Documentation",handle:po},{icon:(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),label:"GitHub",handle:ho},{icon:(0,a.jsx)(na,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:co},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"YouTube",handle:ro},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"Changelog",handle:lo}]},{divider:!0,icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:so},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:io}].filter(no).map(ao),e[15]=y,e[16]=w,e[17]=ce,e[18]=g,e[19]=b,e[20]=o,e[21]=k,e[22]=T,e[23]=A,e[24]=x,e[25]=le,e[26]=t,e[27]=$,e[28]=ue,e[29]=de,e[30]=c,e[31]=me,e[32]=i,e[33]=n,e[34]=ne,e[35]=D,e[36]=j,e[37]=v,e[38]=re,e[39]=q,e[40]=r,e[41]=M,e[42]=ie,e[43]=pe,e[44]=oe,e[45]=B,e[46]=V,e[47]=F,e[48]=N,e[49]=s,e[50]=O,e[51]=f,e[52]=he,e[53]=u,e[54]=l.mode,e[55]=Q):Q=e[55],Q}function ao(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(oo)}:e}function oo(e){return!e.hidden}function no(e){return!e.hidden}function io(){let e=ya();window.open(e,"_blank")}function so(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function lo(){window.open(z.releasesPage,"_blank")}function ro(){window.open(z.youtube,"_blank")}function co(){window.open(z.discordLink,"_blank")}function ho(){window.open(z.githubPage,"_blank")}function po(){window.open(z.docsPage,"_blank")}function mo(e){return!e}function uo(e){return!e}function fo(e){return!e}function bo(e){return[e,{disabled:!1}]}async function yo(){let e=document.getElementById("App");e&&await Ft({element:e,filename:document.title,prepare:Vt})}function ko(){return window.print()}function xo(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 wo(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(He,{size:14})})}function ae(){W({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Qe as a,Ue as c,Xe as i,Ye as l,tt as n,Ge as o,Ua as r,$e as s,to 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-DW5V-tbG.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-y72bE5iF.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
|
|
@@ -198,11 +198,11 @@
|
|
|
198
198
|
<link rel="modulepreload" crossorigin href="./assets/plus-Dvg5FyTi.js">
|
|
199
199
|
<link rel="modulepreload" crossorigin href="./assets/trash-2-CjPoUZCP.js">
|
|
200
200
|
<link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-CgWOEYeG.js">
|
|
201
|
-
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-
|
|
201
|
+
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-BgU0YoWq.js">
|
|
202
202
|
<link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-DVEV2j1H.js">
|
|
203
203
|
<link rel="modulepreload" crossorigin href="./assets/square-function-CPbVtjKW.js">
|
|
204
204
|
<link rel="modulepreload" crossorigin href="./assets/spec-RgR7OB72.js">
|
|
205
|
-
<link rel="modulepreload" crossorigin href="./assets/column-preview-
|
|
205
|
+
<link rel="modulepreload" crossorigin href="./assets/column-preview-DSb2IIj-.js">
|
|
206
206
|
<link rel="modulepreload" crossorigin href="./assets/icons-D3YFXNmD.js">
|
|
207
207
|
<link rel="modulepreload" crossorigin href="./assets/radio-group-CCf-GEZ7.js">
|
|
208
208
|
<link rel="modulepreload" crossorigin href="./assets/floating-outline-Db29DekO.js">
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
<link rel="modulepreload" crossorigin href="./assets/label-BbRibkug.js">
|
|
226
226
|
<link rel="modulepreload" crossorigin href="./assets/textarea-D1Q7dFo2.js">
|
|
227
227
|
<link rel="modulepreload" crossorigin href="./assets/refresh-ccw-AYso5mC6.js">
|
|
228
|
-
<link rel="modulepreload" crossorigin href="./assets/form-
|
|
228
|
+
<link rel="modulepreload" crossorigin href="./assets/form-DMjMUXw1.js">
|
|
229
229
|
<link rel="modulepreload" crossorigin href="./assets/renderShortcut-BV7Qf4L2.js">
|
|
230
230
|
<link rel="modulepreload" crossorigin href="./assets/useBoolean-D0taClF7.js">
|
|
231
231
|
<link rel="modulepreload" crossorigin href="./assets/useDeepCompareMemoize-zUHU--0D.js">
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { Provider } from "jotai";
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
7
|
import { MockRequestClient } from "@/__mocks__/requests";
|
|
8
|
+
import { viewStateAtom } from "@/core/mode";
|
|
8
9
|
import { requestClientAtom } from "@/core/network/requests";
|
|
9
10
|
import { store } from "@/core/state/jotai";
|
|
10
11
|
import { InstallPackageButton } from "../install-package-button";
|
|
@@ -48,6 +49,7 @@ describe("InstallPackageButton", () => {
|
|
|
48
49
|
beforeEach(() => {
|
|
49
50
|
vi.clearAllMocks();
|
|
50
51
|
store.set(requestClientAtom, MockRequestClient.create());
|
|
52
|
+
store.set(viewStateAtom, { mode: "edit", cellAnchor: null });
|
|
51
53
|
});
|
|
52
54
|
|
|
53
55
|
it("should not render when packages is undefined", () => {
|
|
@@ -82,4 +84,13 @@ describe("InstallPackageButton", () => {
|
|
|
82
84
|
);
|
|
83
85
|
expect(screen.getByText("Install altair")).toBeInTheDocument();
|
|
84
86
|
});
|
|
87
|
+
|
|
88
|
+
it("should not render in read mode, where installs are not allowed", () => {
|
|
89
|
+
store.set(viewStateAtom, { mode: "read", cellAnchor: null });
|
|
90
|
+
const { container } = render(
|
|
91
|
+
<InstallPackageButton packages={["altair"]} />,
|
|
92
|
+
{ wrapper },
|
|
93
|
+
);
|
|
94
|
+
expect(container.firstChild).toBeNull();
|
|
95
|
+
});
|
|
85
96
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { Button } from "@/components/ui/button";
|
|
5
|
+
import { useInstallAllowed } from "@/core/mode";
|
|
5
6
|
import { useInstallPackages } from "@/core/packages/useInstallPackage";
|
|
6
7
|
import { cn } from "@/utils/cn";
|
|
7
8
|
|
|
@@ -23,8 +24,9 @@ export const InstallPackageButton: React.FC<InstallPackageButtonProps> = ({
|
|
|
23
24
|
onInstall,
|
|
24
25
|
}) => {
|
|
25
26
|
const { handleInstallPackages } = useInstallPackages();
|
|
27
|
+
const installAllowed = useInstallAllowed();
|
|
26
28
|
|
|
27
|
-
if (!packages || packages.length === 0) {
|
|
29
|
+
if (!packages || packages.length === 0 || !installAllowed) {
|
|
28
30
|
return null;
|
|
29
31
|
}
|
|
30
32
|
|