@marimo-team/frontend 0.20.5-dev0 → 0.20.5-dev3

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.
Files changed (29) hide show
  1. package/dist/assets/{JsonOutput-BSyDxU0G.js → JsonOutput-GlMQ3aLA.js} +10 -10
  2. package/dist/assets/{add-connection-dialog-D4U9I7ze.js → add-connection-dialog-9CzjZlY9.js} +43 -38
  3. package/dist/assets/{agent-panel-ZBBeZzCj.js → agent-panel-BX_iKZeN.js} +1 -1
  4. package/dist/assets/{cell-editor-E00pyx5t.js → cell-editor-B1x4zkBp.js} +1 -1
  5. package/dist/assets/{column-preview-BQP0K_pZ.js → column-preview-BhU5Ow0e.js} +1 -1
  6. package/dist/assets/{command-palette-CqTN1VKY.js → command-palette-BSS73m03.js} +1 -1
  7. package/dist/assets/{context-aware-panel-D7ygyp92.js → context-aware-panel-HnyO4-L2.js} +1 -1
  8. package/dist/assets/{edit-page-lJN42JGx.js → edit-page-26-lDVMB.js} +3 -3
  9. package/dist/assets/{file-explorer-panel-BU69ZByp.js → file-explorer-panel-Bv8lRdKl.js} +1 -1
  10. package/dist/assets/{hooks-FnmFpagQ.js → hooks-BY6oGAlX.js} +1 -1
  11. package/dist/assets/{index-DyRdaW9o.js → index-B8ImLAg8.js} +3 -3
  12. package/dist/assets/index-Dzwe9vKA.css +2 -0
  13. package/dist/assets/{layout-DnAy5Tn0.js → layout-DVAA7kHH.js} +1 -1
  14. package/dist/assets/{panels-h8gAGYxu.js → panels-Do1_ry1k.js} +1 -1
  15. package/dist/assets/{run-page-hoKz5ZHk.js → run-page-BGijCqbR.js} +1 -1
  16. package/dist/assets/{scratchpad-panel-BJOVrgA9.js → scratchpad-panel-ByOWj9u_.js} +1 -1
  17. package/dist/assets/{session-panel-Bpv4DUGh.js → session-panel-B_8ny7jh.js} +1 -1
  18. package/dist/assets/{useNotebookActions-B17g4RO8.js → useNotebookActions-XGX8NzaB.js} +1 -1
  19. package/dist/index.html +5 -5
  20. package/package.json +1 -1
  21. package/src/components/data-table/range-focus/__tests__/cell-selection-stats.test.tsx +14 -9
  22. package/src/components/data-table/range-focus/cell-selection-stats.tsx +44 -13
  23. package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap +37 -0
  24. package/src/components/editor/connections/storage/__tests__/as-code.test.ts +60 -0
  25. package/src/components/editor/connections/storage/add-storage-form.tsx +20 -13
  26. package/src/components/editor/connections/storage/as-code.ts +37 -0
  27. package/src/components/editor/connections/storage/schemas.ts +45 -1
  28. package/src/components/storage/components.tsx +6 -2
  29. package/dist/assets/index-DrPzoH7F.css +0 -2
@@ -1 +1 @@
1
- var Ft=Object.defineProperty;var Ct=(t,e,s)=>e in t?Ft(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var G=(t,e,s)=>Ct(t,typeof e!="symbol"?e+"":e,s);import{s as Oe}from"./chunk-LvLJmgfZ.js";import{i as St,l as me,n as q,p as Re,u as ne}from"./useEvent-WUlsM6MC.js";import{t as _t}from"./react-Bj1aDYRI.js";import{En as Pt,T as Dt,kn as Ae,si as zt,ui as Ie,ur as Mt}from"./cells-CCtxWKxf.js";import"./react-dom-CSu739Rf.js";import{t as se}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-D_HRHf_c.js";import{a as Te,i as Le,r as Ot,t as Ee}from"./add-connection-dialog-D4U9I7ze.js";import{h as Rt,m as ue}from"./useEventListener-CjXriKgk.js";import{t as At}from"./invariant-awXiPaF0.js";import{p as It,u as Be}from"./utils-CORJ8yYa.js";import{S as pe}from"./config-D9X9QKiL.js";import{t as Tt}from"./jsx-runtime-CP2fAiZX.js";import{n as Lt,t as R}from"./button-BmOH9agK.js";import{t as Y}from"./cn-d_A4rA-x.js";import{St as Et}from"./dist-DUY6xZX8.js";import{a as Bt,i as Ve,o as xe}from"./JsonOutput-BSyDxU0G.js";import"./cjs-CVt8hZ5L.js";import"./main-Cmx6WhDY.js";import"./useNonce-BY4jV7Yb.js";import{n as Vt,r as ge}from"./requests-DZy_SQ_v.js";import{t as re}from"./createLucideIcon-BvP5LBIs.js";import{a as He,i as Ue,l as We,n as fe,o as Ht,r as Ut,s as je,t as Wt}from"./state-B_fNn_z_.js";import{n as $t}from"./LazyAnyLanguageCodeMirror-BdX_Y5NA.js";import{r as qt,t as Kt}from"./x-yqLqiq5Q.js";import{c as Gt,i as ye,r as $e}from"./download-BTm4CTKr.js";import{t as ve}from"./chevron-right-_z3dkNFy.js";import{f as be}from"./maps-8VTEe-0T.js";import{n as Yt}from"./markdown-renderer-B6a5ZAwT.js";import{u as Zt}from"./toDate-DDAiY7kz.js";import{a as A,c as ie,p as qe,r as Ke,t as Ge}from"./dropdown-menu-CKhrfxsx.js";import{t as we}from"./copy-CAR4dOiD.js";import{t as Ne}from"./download-BG-iMGgV.js";import{t as Ye}from"./ellipsis-vertical-CqcBoxmi.js";import{t as Jt}from"./eye-off-DgTL09j7.js";import{t as Ze}from"./file-plus-corner-BRwJx0yp.js";import{t as Je}from"./file-DVwc11C3.js";import{i as Qt,n as Qe,r as Xt,t as ea}from"./types-DFiYrN2w.js";import"./html-to-image-b9BimK8l.js";import{n as ke,t as ta}from"./spinner-DCSoZZhh.js";import{t as Xe}from"./plus-B-s-VRHt.js";import{t as aa}from"./refresh-ccw-BOzRCrXK.js";import{t as Fe}from"./refresh-cw-DeCFDX1B.js";import{t as sa}from"./save-I_RGv5p0.js";import{t as ra}from"./trash-2-DtQaB9NM.js";import{t as na}from"./triangle-alert-n1-FF7zs.js";import{i as ia,n as la,t as oa}from"./es-1hBRXVlM.js";import"./dist-DfBASypd.js";import"./dist-Dq_iQ08e.js";import"./dist-BjtLy-VA.js";import"./dist-odxAaH5Z.js";import"./dist-51xFOPFs.js";import{t as E}from"./use-toast-BhMe50aT.js";import{t as Ce}from"./paths-bMgYkaP2.js";import"./session-DnMOyddG.js";import"./Combination-tjZP3FH6.js";import{t as T}from"./tooltip-DOQlecCr.js";import"./purify.es-CPplrWRQ.js";import"./dates-CzBDvj6R.js";import{o as ca}from"./alert-dialog-DsNfSYaw.js";import{t as et}from"./context-B1_BdDTF.js";import"./popover-Cvl9xY6R.js";import{n as tt}from"./ImperativeModal-CRNJOvqT.js";import{r as da}from"./errors-Bfogio62.js";import{n as ha}from"./blob-CObhN-9g.js";import"./vega-loader.browser-CZV6_g2i.js";import"./defaultLocale-OkOxlkkM.js";import"./defaultLocale-DK1MWd7f.js";import{t as le}from"./copy-DMCkK2TI.js";import{t as ma}from"./copy-icon-6RnnFDPt.js";import{n as pa}from"./multi-map-kCmlVJ-5.js";import{a as xa,i as fa,n as Se,r as ua,t as ga}from"./tree-D0AxVJ_I.js";import{n as ja,t as ya}from"./alert-0YTlkh9P.js";import{n as at}from"./error-banner-R2OkQKR0.js";import{n as _e}from"./useAsyncData-DVm0BCFt.js";import{a as va,o as st,t as ba,u as wa}from"./command-DQqqP-WF.js";import"./chunk-5FQGJX7Z-BJDu6jwt.js";import"./katex-rvFxOCU-.js";import{o as Na}from"./focus-ShrwcKIv.js";import{a as ka}from"./renderShortcut-BJEd-iA7.js";import{t as Fa}from"./bundle.esm-_LzfhNmX.js";import{a as Ca}from"./components-CF9x5raB.js";import{t as Sa}from"./empty-state-DFr2pZOz.js";import{t as Pe}from"./formatting-8bP-RDnl.js";import{a as _a,i as Pa,n as rt,r as nt,t as it}from"./components-BZCdnYSp.js";import{n as lt,t as Da}from"./marimo-icons-BDAuIiW5.js";import{t as za}from"./links-syPBpTLO.js";var Ma=re("copy-minus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),ot=re("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),ct=re("list-tree",[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]),Oa=re("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),Ra=re("square-play",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}]]),dt=re("view",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),M=Oe(_t(),1),Aa=se(),a=Oe(Tt(),1);const ht=t=>{let e=(0,Aa.c)(17),{filename:s,filenameIcon:n,onBack:i,onRefresh:r,onDownload:l,actions:c}=t,p;e[0]===i?p=e[1]:(p=i&&(0,a.jsx)(T,{content:"Back to file list",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:i,children:(0,a.jsx)(We,{className:"h-4 w-4"})})}),e[0]=i,e[1]=p);let o;e[2]!==s||e[3]!==n?(o=s?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate",children:[n,s]}):(0,a.jsx)("span",{className:"flex-1"}),e[2]=s,e[3]=n,e[4]=o):o=e[4];let g;e[5]===r?g=e[6]:(g=r&&(0,a.jsx)(T,{content:"Refresh",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:r,children:(0,a.jsx)(Fe,{className:"h-3.5 w-3.5"})})}),e[5]=r,e[6]=g);let m;e[7]===l?m=e[8]:(m=l&&(0,a.jsx)(T,{content:"Download",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:l,children:(0,a.jsx)(Ne,{className:"h-3.5 w-3.5"})})}),e[7]=l,e[8]=m);let f;e[9]!==c||e[10]!==g||e[11]!==m?(f=(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[g,c,m]}),e[9]=c,e[10]=g,e[11]=m,e[12]=f):f=e[12];let j;return e[13]!==p||e[14]!==o||e[15]!==f?(j=(0,a.jsxs)("div",{className:"flex items-center shrink-0 border-b px-1 gap-1",children:[p,o,f]}),e[13]=p,e[14]=o,e[15]=f,e[16]=j):j=e[16],j};var Ia=100*1024*1024;function Ta(t){let e=t.endsWith("/")?t.slice(0,-1):t,s=e.split("/");return s[s.length-1]||e}const La=({entry:t,namespace:e,onBack:s})=>{let{locale:n}=et(),i=Ta(t.path),r=t.mimeType||"text/plain",l=xe(r),c=l&&t.size>Ia&&t.size>0,{data:p,isPending:o,error:g,refetch:m}=_e(async()=>{if(c)return null;let u=await je.request({namespace:e,path:t.path,preview:!l});if(u.error)throw Error(u.error);if(!u.url)throw Error("No URL returned");if(l)return{type:"media",url:u.url};let h=await fetch(u.url);if(!h.ok)throw Error(`Failed to fetch preview: ${h.statusText}`);return{type:"text",content:await h.text()}},[e,t.path,l,c]),f=(0,M.useCallback)(async()=>{try{let u=await je.request({namespace:e,path:t.path});if(u.error){E({title:"Download failed",description:u.error,variant:"danger"});return}u.url&&ye(u.url,u.filename??i)}catch(u){ue.error("Failed to download storage entry",u),E({title:"Download failed",description:String(u),variant:"danger"})}},[e,t.path,i]),j=(0,a.jsx)(ht,{filename:i,filenameIcon:Le(i),onBack:s,onDownload:f}),d=({includeMime:u=!1})=>(0,a.jsxs)("div",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 p-4 text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Path"}),(0,a.jsxs)("div",{className:"truncate flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"font-mono text-[11px]",children:t.path}),(0,a.jsx)(ma,{value:t.path,className:"h-3 w-3"})]}),u&&(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Type"}),u&&(0,a.jsx)("span",{children:r}),t.size>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Size"}),(0,a.jsx)("span",{children:Pe(t.size,n)})]}),t.lastModified!=null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Modified"}),(0,a.jsx)("span",{children:new Date(t.lastModified*1e3).toLocaleString()})]})]});return c?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[j,d({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-muted-foreground italic",children:["File is too large to preview (",Pe(t.size,n),")."]})]}):o?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[j,d({}),(0,a.jsxs)("div",{className:"flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground min-h-24",children:[(0,a.jsx)(ke,{className:"h-4 w-4 animate-spin"}),"Loading preview..."]})]}):g?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[j,d({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-destructive",children:["Failed to load preview: ",g.message]}),(0,a.jsx)("div",{className:"px-4 pb-4",children:(0,a.jsxs)(R,{variant:"secondary",size:"xs",onClick:m,children:[(0,a.jsx)(Fe,{className:"h-3 w-3 mr-1"}),"Retry"]})})]}):p?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[j,d({}),(0,a.jsx)(Ve,{mimeType:r,contents:p.type==="text"?p.content:void 0,mediaSource:p.type==="media"?{url:p.url}:void 0})]}):(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[j,d({includeMime:!0}),(0,a.jsxs)("div",{className:"p-4 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(Je,{className:"h-4 w-4"}),"Preview not available for this file type."]})]})};var De=se(),Ea=16;function Z(t){return{paddingLeft:t*Ea}}function Ba(t,e){return new Date(t*1e3).toLocaleDateString(e,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function mt(t){let e=t.endsWith("/")?t.slice(0,-1):t,s=e.split("/");return s[s.length-1]||e}function ze(t,e,s,n){let i=s.toLowerCase();if(mt(t.path).toLowerCase().includes(i))return!0;if(t.kind==="directory"){let r=n.get(He(e,t.path));if(r)return r.some(l=>ze(l,e,s,n))}return!1}function pt(t,e,s,n){return s.trim()?t.filter(i=>ze(i,e,s,n)):t}var Va=t=>{let e=(0,De.c)(34),{namespace:s,protocol:n,rootPath:i,prefix:r,depth:l,locale:c,searchValue:p,onOpenFile:o}=t,{entriesByPath:g}=fe(),{entries:m,isPending:f,error:j}=Ue(s,r);if(f){let h;e[0]===l?h=e[1]:(h=Z(l),e[0]=l,e[1]=h);let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=(0,a.jsx)(ke,{className:"h-3 w-3 animate-spin"}),e[2]=y):y=e[2];let w;return e[3]===h?w=e[4]:(w=(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:h,children:[y,"Loading..."]}),e[3]=h,e[4]=w),w}if(j){let h;e[5]===l?h=e[6]:(h=Z(l),e[5]=l,e[6]=h);let y;return e[7]!==j.message||e[8]!==h?(y=(0,a.jsxs)("div",{className:"py-1 text-xs text-destructive",style:h,children:["Failed to load: ",j.message]}),e[7]=j.message,e[8]=h,e[9]=y):y=e[9],y}if(m.length===0){let h;e[10]===l?h=e[11]:(h=Z(l),e[10]=l,e[11]=h);let y;return e[12]===h?y=e[13]:(y=(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:h,children:"Empty"}),e[12]=h,e[13]=y),y}let d;if(e[14]!==m||e[15]!==l||e[16]!==g||e[17]!==c||e[18]!==s||e[19]!==o||e[20]!==n||e[21]!==i||e[22]!==p){let h=pt(m,s,p,g),y;e[24]!==l||e[25]!==c||e[26]!==s||e[27]!==o||e[28]!==n||e[29]!==i||e[30]!==p?(y=w=>(0,a.jsx)(xt,{entry:w,namespace:s,protocol:n,rootPath:i,depth:l,locale:c,searchValue:p,onOpenFile:o},w.path),e[24]=l,e[25]=c,e[26]=s,e[27]=o,e[28]=n,e[29]=i,e[30]=p,e[31]=y):y=e[31],d=h.map(y),e[14]=m,e[15]=l,e[16]=g,e[17]=c,e[18]=s,e[19]=o,e[20]=n,e[21]=i,e[22]=p,e[23]=d}else d=e[23];let u;return e[32]===d?u=e[33]:(u=(0,a.jsx)(a.Fragment,{children:d}),e[32]=d,e[33]=u),u},xt=({entry:t,namespace:e,protocol:s,rootPath:n,depth:i,locale:r,searchValue:l,onOpenFile:c})=>{var w;let[p,o]=(0,M.useState)(!1),{entriesByPath:g}=fe(),m=t.kind==="directory",f=mt(t.path),j=!!l.trim(),d=m&&j&&f.toLowerCase().includes(l.trim().toLowerCase()),u=m&&j&&!!((w=g.get(He(e,t.path)))!=null&&w.some(v=>ze(v,e,l,g))),h=p||u,y=(0,M.useCallback)(async()=>{try{let v=await je.request({namespace:e,path:t.path});if(v.error){E({title:"Download failed",description:v.error,variant:"danger"});return}v.url&&ye(v.url,v.filename??"download")}catch(v){ue.error("Failed to download storage entry",v),E({title:"Download failed",description:String(v),variant:"danger"})}},[e,t.path]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(st,{className:Y("text-xs flex items-center gap-1.5 cursor-pointer rounded-none group h-6.5",m&&"font-medium"),style:Z(i),value:`${e}:${t.path}`,onSelect:()=>{m?o(!h):c({entry:t,namespace:e})},children:[m?(0,a.jsx)(ve,{className:Y("h-3 w-3 shrink-0 transition-transform",h&&"rotate-90")}):(0,a.jsx)("span",{className:"w-3 shrink-0"}),m?(0,a.jsx)(Qt,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}):Le(f),(0,a.jsx)("span",{className:"truncate flex-1 text-left",children:f}),(0,a.jsxs)("div",{className:"flex items-center",children:[t.size>0&&(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground pr-2 opacity-0 group-hover:opacity-100 transition-opacity tabular-nums",children:Pe(t.size,r)}),t.lastModified!=null&&(0,a.jsx)(T,{content:`Last modified: ${new Date(t.lastModified*1e3).toLocaleString()}`,children:(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground pr-1 opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap",children:Ba(t.lastModified,r)})}),(0,a.jsxs)(Ge,{children:[(0,a.jsx)(qe,{asChild:!0,children:(0,a.jsx)(R,{variant:"text",size:"icon",className:"opacity-0 group-hover:opacity-100 transition-opacity hover:shadow-none hover:text-link text-muted-foreground",onClick:v=>v.stopPropagation(),children:(0,a.jsx)(Ye,{className:"h-3 w-3"})})}),(0,a.jsxs)(Ke,{align:"end",onClick:v=>v.stopPropagation(),onCloseAutoFocus:v=>v.preventDefault(),children:[!m&&(0,a.jsxs)(A,{onSelect:()=>c({entry:t,namespace:e}),children:[(0,a.jsx)(dt,{className:"h-3.5 w-3.5 mr-2"}),"View"]}),(0,a.jsxs)(A,{onSelect:async()=>{await le(Ht(s,n,t.path).toString()),E({title:"Copied to clipboard"})},children:[(0,a.jsx)(we,{className:"h-3.5 w-3.5 mr-2"}),"Copy URL"]}),!m&&(0,a.jsxs)(A,{onSelect:()=>y(),children:[(0,a.jsx)(Ne,{className:"h-3.5 w-3.5 mr-2"}),"Download"]})]})]})]})]}),m&&h&&(0,a.jsx)(Va,{namespace:e,protocol:s,rootPath:n,prefix:t.path,depth:i+1,locale:r,searchValue:d?"":l,onOpenFile:c})]})},Ha=t=>{let e=(0,De.c)(50),{namespace:s,locale:n,searchValue:i,onOpenFile:r}=t,[l,c]=(0,M.useState)(!0),[p,o]=(0,M.useState)(!1),{entriesByPath:g}=fe(),{clearNamespaceCache:m}=Ut(),f=s.name??s.displayName,{entries:j,isPending:d,error:u,refetch:h}=Ue(f),y;e[0]!==m||e[1]!==f||e[2]!==h?(y=N=>{N.stopPropagation(),o(!0),m(f),h(),setTimeout(()=>o(!1),500)},e[0]=m,e[1]=f,e[2]=h,e[3]=y):y=e[3];let w=y,v=d?s.storageEntries:j,b;if(e[4]!==v||e[5]!==g||e[6]!==u||e[7]!==w||e[8]!==l||e[9]!==d||e[10]!==p||e[11]!==n||e[12]!==s.displayName||e[13]!==s.name||e[14]!==s.protocol||e[15]!==s.rootPath||e[16]!==f||e[17]!==r||e[18]!==i){let N=pt(v,f,i,g),x=s.name,F;e[20]===l?F=e[21]:(F=()=>c(!l),e[20]=l,e[21]=F);let D=l&&"rotate-90",S;e[22]===D?S=e[23]:(S=Y("h-3 w-3 shrink-0 transition-transform",D),e[22]=D,e[23]=S);let C;e[24]===S?C=e[25]:(C=(0,a.jsx)(ve,{className:S}),e[24]=S,e[25]=C);let _;e[26]===s.protocol?_=e[27]:(_=(0,a.jsx)(Ot,{protocol:s.protocol}),e[26]=s.protocol,e[27]=_);let P;e[28]===s.displayName?P=e[29]:(P=(0,a.jsx)("span",{children:s.displayName}),e[28]=s.displayName,e[29]=P);let O;e[30]===s.name?O=e[31]:(O=s.name&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-normal",children:["(",(0,a.jsx)(_a,{variableName:s.name}),")"]}),e[30]=s.name,e[31]=O);let z=p&&"animate-[spin_0.5s]",L;e[32]===z?L=e[33]:(L=Y("h-3 w-3 text-muted-foreground hover:text-foreground",z),e[32]=z,e[33]=L);let V;e[34]===L?V=e[35]:(V=(0,a.jsx)(Fe,{className:L}),e[34]=L,e[35]=V);let U;e[36]!==w||e[37]!==V?(U=(0,a.jsx)(T,{content:"Refresh storage connection",children:(0,a.jsx)(R,{variant:"ghost",size:"icon",className:"hover:bg-transparent hover:shadow-none",onClick:w,children:V})}),e[36]=w,e[37]=V,e[38]=U):U=e[38];let W=s.rootPath||"(root)",$;e[39]===W?$=e[40]:($=(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-normal tabular-nums ml-auto",children:W}),e[39]=W,e[40]=$);let H;e[41]!==s.name||e[42]!==O||e[43]!==U||e[44]!==$||e[45]!==F||e[46]!==C||e[47]!==_||e[48]!==P?(H=(0,a.jsxs)(st,{value:x,onSelect:F,className:"flex flex-row font-semibold h-7 text-xs gap-1.5 bg-(--slate-2) text-muted-foreground rounded-none",children:[C,_,P,O,U,$]}),e[41]=s.name,e[42]=O,e[43]=U,e[44]=$,e[45]=F,e[46]=C,e[47]=_,e[48]=P,e[49]=H):H=e[49],b=(0,a.jsxs)(a.Fragment,{children:[H,l&&(0,a.jsxs)(a.Fragment,{children:[d&&v.length===0&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:Z(1),children:[(0,a.jsx)(ke,{className:"h-3 w-3 animate-spin"}),"Loading..."]}),u&&v.length===0&&(0,a.jsx)(Ca,{error:u,style:Z(1),className:"py-1 text-xs h-auto",showIcon:!1}),!d&&v.length===0&&!u&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:Z(1),children:"No entries"}),i&&N.length===0&&v.length>0&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:Z(1),children:"No matches"}),N.map(K=>(0,a.jsx)(xt,{entry:K,namespace:f,protocol:s.protocol,rootPath:s.rootPath,depth:1,locale:n,searchValue:i,onOpenFile:r},K.path))]})]}),e[4]=v,e[5]=g,e[6]=u,e[7]=w,e[8]=l,e[9]=d,e[10]=p,e[11]=n,e[12]=s.displayName,e[13]=s.name,e[14]=s.protocol,e[15]=s.rootPath,e[16]=f,e[17]=r,e[18]=i,e[19]=b}else b=e[19];return b};const Ua=()=>{let t=(0,De.c)(31),{namespaces:e}=fe(),{locale:s}=et(),[n,i]=(0,M.useState)(""),[r,l]=(0,M.useState)(null),c=!!n.trim();if(e.length===0){let b;t[0]===Symbol.for("react.memo_cache_sentinel")?(b=(0,a.jsxs)("span",{children:["Create an Obstore or fsspec connection in your notebook. See the"," ",(0,a.jsx)("a",{className:"text-link",href:"https://docs.marimo.io/guides/working_with_data/remote_storage/#quick-start",target:"_blank",rel:"noopener noreferrer",children:"docs"}),"."]}),t[0]=b):b=t[0];let N;return t[1]===Symbol.for("react.memo_cache_sentinel")?(N=(0,a.jsx)(Sa,{title:"No storage connected",description:b,action:(0,a.jsx)(Ee,{defaultTab:"storage",children:(0,a.jsxs)(R,{variant:"outline",size:"sm",children:["Add remote storage",(0,a.jsx)(Xe,{className:"h-4 w-4 ml-2"})]})}),icon:(0,a.jsx)(Te,{className:"h-8 w-8"})}),t[1]=N):N=t[1],N}let p;t[2]===r?p=t[3]:(p=r&&(0,a.jsx)(La,{entry:r.entry,namespace:r.namespace,onBack:()=>l(null)}),t[2]=r,t[3]=p);let o=r&&"hidden",g;t[4]===o?g=t[5]:(g=Y("border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin",o),t[4]=o,t[5]=g);let m;t[6]===n?m=t[7]:(m=(0,a.jsx)(va,{placeholder:"Search entries...",className:"h-6 m-1",value:n,onValueChange:i,rootClassName:"flex-1 border-b-0"}),t[6]=n,t[7]=m);let f;t[8]===c?f=t[9]:(f=c&&(0,a.jsx)(R,{variant:"text",size:"xs",className:"float-right border-none px-2 m-0 h-full",onClick:()=>i(""),children:(0,a.jsx)(Kt,{className:"h-4 w-4"})}),t[8]=c,t[9]=f);let j;t[10]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)(T,{content:"Filters loaded entries only. Expand directories to include their contents in the search.",delayDuration:200,children:(0,a.jsx)(Zt,{className:"h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2"})}),t[10]=j):j=t[10];let d;t[11]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)(Ee,{defaultTab:"storage",children:(0,a.jsx)(R,{variant:"ghost",size:"sm",className:"px-2 border-0 border-l border-muted-background rounded-none focus-visible:ring-0 focus-visible:ring-offset-0",children:(0,a.jsx)(Xe,{className:"h-4 w-4"})})}),t[11]=d):d=t[11];let u;t[12]!==m||t[13]!==f?(u=(0,a.jsxs)("div",{className:"flex items-center w-full border-b",children:[m,f,j,d]}),t[12]=m,t[13]=f,t[14]=u):u=t[14];let h;if(t[15]!==s||t[16]!==e||t[17]!==n){let b;t[19]!==s||t[20]!==n?(b=N=>(0,a.jsx)(Ha,{namespace:N,locale:s,searchValue:n,onOpenFile:l},N.name??N.displayName),t[19]=s,t[20]=n,t[21]=b):b=t[21],h=e.map(b),t[15]=s,t[16]=e,t[17]=n,t[18]=h}else h=t[18];let y;t[22]===h?y=t[23]:(y=(0,a.jsx)(wa,{className:"flex flex-col",children:h}),t[22]=h,t[23]=y);let w;t[24]!==g||t[25]!==u||t[26]!==y?(w=(0,a.jsxs)(ba,{className:g,shouldFilter:!1,children:[u,y]}),t[24]=g,t[25]=u,t[26]=y,t[27]=w):w=t[27];let v;return t[28]!==p||t[29]!==w?(v=(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[p,w]}),t[28]=p,t[29]=w,t[30]=v):v=t[30],v};var ft=se(),ut=(0,M.createContext)(null);function Wa(){return(0,M.useContext)(ut)??void 0}var $a=t=>{let e=(0,ft.c)(3),{children:s}=t,n=fa(),i;return e[0]!==s||e[1]!==n?(i=(0,a.jsx)(ut.Provider,{value:n,children:s}),e[0]=s,e[1]=n,e[2]=i):i=e[2],i};const qa=t=>{let e=(0,ft.c)(5),{children:s}=t,[n,i]=(0,M.useState)(null),r;e[0]!==s||e[1]!==n?(r=n&&(0,a.jsx)(xa,{backend:ua,options:{rootElement:n},children:(0,a.jsx)($a,{children:s})}),e[0]=s,e[1]=n,e[2]=r):r=e[2];let l;return e[3]===r?l=e[4]:(l=(0,a.jsx)("div",{ref:i,className:"contents",children:r}),e[3]=r,e[4]=l),l};var Me=new Map;const Ka=({file:t,onOpenNotebook:e})=>{let{sendFileDetails:s,sendUpdateFile:n}=ge(),i=ne(It),r=ne(Be),l=ne(zt),[c,p]=(0,M.useState)(""),{data:o,isPending:g,error:m,setData:f,refetch:j}=_e(async()=>{let x=await s({path:t.path}),F=x.contents||"";return p(Me.get(t.path)||F),x},[t.path]),d=async()=>{c!==(o==null?void 0:o.contents)&&await n({path:t.path,contents:c}).then(x=>{x.success&&(f(F=>({...F,contents:c})),p(c))})},u=(0,M.useRef)(c);if(u.current=c,(0,M.useEffect)(()=>()=>{if(!(o!=null&&o.contents))return;let x=u.current;x===o.contents?Me.delete(t.path):Me.set(t.path,x)},[t.path,o==null?void 0:o.contents]),m)return(0,a.jsx)(at,{error:m});if(g||!o)return null;let h=o.mimeType||"text/plain",y=h in Bt,w=l&&o.file.isMarimoFile&&(t.path===l||t.path.endsWith(`/${l}`));if(!o.contents&&!y)return(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 p-6",children:[(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Name"}),(0,a.jsx)("div",{children:o.file.name}),(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Type"}),(0,a.jsx)("div",{children:h})]});let v=(0,a.jsx)(ht,{filename:o.file.name,onRefresh:j,onDownload:r?void 0:()=>{if(xe(h)){ye(Yt(o.contents,h),o.file.name);return}$e(new Blob([o.contents||c],{type:h}),o.file.name)},actions:(0,a.jsxs)(a.Fragment,{children:[t.isMarimoFile&&!pe()&&(0,a.jsx)(T,{content:"Open notebook",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:x=>e(x),children:(0,a.jsx)(be,{className:"h-3.5 w-3.5"})})}),!xe(h)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(T,{content:"Copy contents to clipboard",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:async()=>{await le(c)},children:(0,a.jsx)(we,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(T,{content:ka("global.save"),children:(0,a.jsx)(R,{variant:c===o.contents?"text":"success",size:"xs",onClick:d,disabled:c===o.contents,children:(0,a.jsx)(sa,{className:"h-3.5 w-3.5"})})})]})]})}),b=xe(h),N=!b&&h!=="text/csv";return(0,a.jsxs)(a.Fragment,{children:[v,N&&w&&(0,a.jsxs)(ya,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(na,{className:"h-4 w-4"}),(0,a.jsx)(ja,{children:"Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution."})]}),(0,a.jsx)(Ve,{mimeType:h,contents:b?void 0:N?c:o.contents??void 0,mediaSource:b?{base64:o.contents,mime:h}:void 0,readOnly:!N,onChange:p,extensions:[Et.of([{key:i.getHotkey("global.save").key,stopPropagation:!0,run:()=>c===o.contents?!1:(d(),!0)}])]})]})};var Ga=class{constructor(t){G(this,"delegate",new Se([]));G(this,"rootPath","");G(this,"onChange",Rt.NOOP);G(this,"path",new Ce("/"));G(this,"initialize",async t=>{if(this.onChange=t,this.delegate.data.length===0)try{let e=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new Se(e.files),this.rootPath=e.root,this.path=Ce.guessDeliminator(e.root)}catch(e){E({title:"Failed",description:da(e)})}this.onChange(this.delegate.data)});G(this,"refreshAll",async t=>{let e=[this.rootPath,...t.map(n=>{var i;return(i=this.delegate.find(n))==null?void 0:i.data.path})].filter(Boolean),s=await Promise.all(e.map(n=>this.callbacks.listFiles({path:n}).catch(()=>({files:[]}))));for(let[n,i]of e.entries()){let r=s[n];i===this.rootPath?this.delegate=new Se(r.files):this.delegate.update({id:i,changes:{children:r.files}})}this.onChange(this.delegate.data)});G(this,"relativeFromRoot",t=>{let e=this.rootPath.endsWith(this.path.deliminator)?this.rootPath:`${this.rootPath}${this.path.deliminator}`;return t.startsWith(e)?t.slice(e.length):t});G(this,"handleResponse",t=>t.success?t:(E({title:"Failed",description:t.message}),null));this.callbacks=t}async expand(t){let e=this.delegate.find(t);if(!e||!e.data.isDirectory)return!1;if(e.children&&e.children.length>0)return!0;let s=await this.callbacks.listFiles({path:e.data.path});return this.delegate.update({id:t,changes:{children:s.files}}),this.onChange(this.delegate.data),!0}async rename(t,e){let s=this.delegate.find(t);if(!s)return;let n=s.data.path,i=this.path.join(this.path.dirname(n),e);await this.callbacks.renameFileOrFolder({path:n,newPath:i}).then(this.handleResponse),this.delegate.update({id:t,changes:{name:e,path:i}}),this.onChange(this.delegate.data),await this.refreshAll([i])}async move(t,e){var n;let s=e?((n=this.delegate.find(e))==null?void 0:n.data.path)??e:this.rootPath;await Promise.all(t.map(i=>{this.delegate.move({id:i,parentId:e,index:0});let r=this.delegate.find(i);if(!r)return Promise.resolve();let l=this.path.join(s,this.path.basename(r.data.path));return this.delegate.update({id:i,changes:{path:l}}),this.callbacks.renameFileOrFolder({path:r.data.path,newPath:l}).then(this.handleResponse)})),this.onChange(this.delegate.data),await this.refreshAll([s])}async createFile(t,e,s="file"){var r;let n=e?((r=this.delegate.find(e))==null?void 0:r.data.path)??e:this.rootPath,i=await this.callbacks.createFileOrFolder({path:n,type:s,name:t}).then(this.handleResponse);i!=null&&i.info&&(this.delegate.create({parentId:e,index:0,data:i.info}),this.onChange(this.delegate.data),await this.refreshAll([n]))}async createFolder(t,e){var i;let s=e?((i=this.delegate.find(e))==null?void 0:i.data.path)??e:this.rootPath,n=await this.callbacks.createFileOrFolder({path:s,type:"directory",name:t}).then(this.handleResponse);n!=null&&n.info&&(this.delegate.create({parentId:e,index:0,data:n.info}),this.onChange(this.delegate.data),await this.refreshAll([s]))}async delete(t){let e=this.delegate.find(t);e&&(await this.callbacks.deleteFileOrFolder({path:e.data.path}).then(this.handleResponse),this.delegate.drop({id:t}),this.onChange(this.delegate.data))}};const gt=Re(t=>{let e=t(Vt);return At(e,"no requestClientAtom set"),new Ga({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),Ya=Re({});async function Za(){await St.get(gt).refreshAll([])}var Ja=se(),Qa=1024*1024*100;function jt(t){let e=(0,Ja.c)(7),s;e[0]===t?s=e[1]:(s=t===void 0?{}:t,e[0]=t,e[1]=s);let n=s,{sendCreateFileOrFolder:i}=ge(),r;e[2]===i?r=e[3]:(r=async c=>{if(c.length===0)return;let p=c.length===1;await Gt(p?"Uploading file...":"Uploading files...",async o=>{o.addTotal(c.length);for(let g of c){let m=rs(ss(g)),f="";m&&(f=Ce.guessDeliminator(m).dirname(m));let j=(await ha(g)).split(",")[1];await i({path:f,type:"file",name:g.name,contents:j}),o.increment(1)}await Za()},{title:p?"File uploaded":`${c.length} files uploaded`})},e[2]=i,e[3]=r);let l;return e[4]!==n||e[5]!==r?(l={multiple:!0,maxSize:Qa,onError:as,onDropRejected:Xa,onDrop:r,...n},e[4]=n,e[5]=r,e[6]=l):l=e[6],oa(l)}function Xa(t){E({title:"File upload failed",description:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:t.map(es)}),variant:"danger"})}function es(t){return(0,a.jsxs)("div",{children:[t.file.name," (",t.errors.map(ts).join(", "),")"]},t.file.name)}function ts(t){return t.message}function as(t){ue.error(t),E({title:"File upload failed",description:t.message,variant:"danger"})}function ss(t){if(t.webkitRelativePath)return t.webkitRelativePath;if("path"in t&&typeof t.path=="string")return t.path;if("relativePath"in t&&typeof t.relativePath=="string")return t.relativePath}function rs(t){if(t)return t.replace(/^\/+/,"")}var oe=se(),ns=Ie("marimo:showHiddenFiles",!0,Ae,{getOnInit:!0}),yt=M.createContext(null);const is=t=>{let e=(0,oe.c)(72),{height:s}=t,n=(0,M.useRef)(null),i=Wa(),[r]=me(gt),l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=[],e[0]=l):l=e[0];let[c,p]=(0,M.useState)(l),[o,g]=(0,M.useState)(null),[m,f]=me(ns),{openPrompt:j}=tt(),[d,u]=me(Ya),h;e[1]===r?h=e[2]:(h=()=>r.initialize(p),e[1]=r,e[2]=h);let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[3]=y):y=e[3];let{isPending:w,error:v}=_e(h,y),b;e[4]!==d||e[5]!==r?(b=()=>{r.refreshAll(Object.keys(d).filter(k=>d[k]))},e[4]=d,e[5]=r,e[6]=b):b=e[6];let N=q(b),x;e[7]!==f||e[8]!==m?(x=()=>{f(!m)},e[7]=f,e[8]=m,e[9]=x):x=e[9];let F=q(x),D;e[10]!==j||e[11]!==r?(D=async()=>{j({title:"Folder name",onConfirm:async k=>{r.createFolder(k,null)}})},e[10]=j,e[11]=r,e[12]=D):D=e[12];let S=q(D),C;e[13]!==j||e[14]!==r?(C=async()=>{j({title:"File name",onConfirm:async k=>{r.createFile(k,null)}})},e[13]=j,e[14]=r,e[15]=C):C=e[15];let _=q(C),P;e[16]!==j||e[17]!==r?(P=async()=>{j({title:"Notebook name",onConfirm:async k=>{r.createFile(k,null,"notebook")}})},e[16]=j,e[17]=r,e[18]=P):P=e[18];let O=q(P),z;e[19]===u?z=e[20]:(z=()=>{var k;(k=n.current)==null||k.closeAll(),u({})},e[19]=u,e[20]=z);let L=q(z),V;e[21]!==c||e[22]!==m?(V=bt(c,m),e[21]=c,e[22]=m,e[23]=V):V=e[23];let U=V;if(w){let k;return e[24]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(ta,{size:"medium",centered:!0}),e[24]=k):k=e[24],k}if(v){let k;return e[25]===v?k=e[26]:(k=(0,a.jsx)(at,{error:v}),e[25]=v,e[26]=k),k}if(o){let k;e[27]===Symbol.for("react.memo_cache_sentinel")?(k=()=>g(null),e[27]=k):k=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=(0,a.jsx)(R,{onClick:k,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:(0,a.jsx)(We,{size:16})}),e[28]=I):I=e[28];let B;e[29]===o.name?B=e[30]:(B=(0,a.jsxs)("div",{className:"flex items-center pl-1 pr-3 shrink-0 border-b justify-between",children:[I,(0,a.jsx)("span",{className:"font-bold",children:o.name})]}),e[29]=o.name,e[30]=B);let te;e[31]!==o.path||e[32]!==r?(te=kt=>vt(kt,r.relativeFromRoot(o.path)),e[31]=o.path,e[32]=r,e[33]=te):te=e[33];let ae;e[34]!==o||e[35]!==te?(ae=(0,a.jsx)(M.Suspense,{children:(0,a.jsx)(Ka,{onOpenNotebook:te,file:o})}),e[34]=o,e[35]=te,e[36]=ae):ae=e[36];let he;return e[37]!==B||e[38]!==ae?(he=(0,a.jsxs)(a.Fragment,{children:[B,ae]}),e[37]=B,e[38]=ae,e[39]=he):he=e[39],he}let W;e[40]!==L||e[41]!==_||e[42]!==S||e[43]!==O||e[44]!==F||e[45]!==N||e[46]!==r?(W=(0,a.jsx)(os,{onRefresh:N,onHidden:F,onCreateFile:_,onCreateNotebook:O,onCreateFolder:S,onCollapseAll:L,tree:r}),e[40]=L,e[41]=_,e[42]=S,e[43]=O,e[44]=F,e[45]=N,e[46]=r,e[47]=W):W=e[47];let $=s-33,H,K,J;e[48]===r?(H=e[49],K=e[50],J=e[51]):(H=async k=>{let{ids:I}=k;for(let B of I)await r.delete(B)},K=async k=>{let{id:I,name:B}=k;await r.rename(I,B)},J=async k=>{let{dragIds:I,parentId:B}=k;await r.move(I,B)},e[48]=r,e[49]=H,e[50]=K,e[51]=J);let ce;e[52]===Symbol.for("react.memo_cache_sentinel")?(ce=k=>{let I=k[0];I&&(I.data.isDirectory||g(I.data))},e[52]=ce):ce=e[52];let Q;e[53]!==d||e[54]!==u||e[55]!==r?(Q=async k=>{if(await r.expand(k)){let I=d[k]??!1;u({...d,[k]:!I})}},e[53]=d,e[54]=u,e[55]=r,e[56]=Q):Q=e[56];let X;e[57]!==i||e[58]!==d||e[59]!==$||e[60]!==H||e[61]!==K||e[62]!==J||e[63]!==Q||e[64]!==U?(X=(0,a.jsx)(ga,{width:"100%",ref:n,height:$,className:"h-full",data:U,initialOpenState:d,openByDefault:!1,dndManager:i,renderCursor:xs,disableDrop:fs,onDelete:H,onRename:K,onMove:J,onSelect:ce,onToggle:Q,padding:15,rowHeight:30,indent:ls,overscanCount:1e3,disableMultiSelection:!0,children:hs}),e[57]=i,e[58]=d,e[59]=$,e[60]=H,e[61]=K,e[62]=J,e[63]=Q,e[64]=U,e[65]=X):X=e[65];let ee;e[66]!==X||e[67]!==r?(ee=(0,a.jsx)(yt,{value:r,children:X}),e[66]=X,e[67]=r,e[68]=ee):ee=e[68];let de;return e[69]!==W||e[70]!==ee?(de=(0,a.jsxs)(a.Fragment,{children:[W,ee]}),e[69]=W,e[70]=ee,e[71]=de):de=e[71],de};var ls=15,os=t=>{let e=(0,oe.c)(38),{onRefresh:s,onHidden:n,onCreateFile:i,onCreateNotebook:r,onCreateFolder:l,onCollapseAll:c}=t,p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={noDrag:!0,noDragEventsBubbling:!0},e[0]=p):p=e[0];let{getRootProps:o,getInputProps:g}=jt(p),m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(lt,{size:16}),e[1]=m):m=e[1];let f;e[2]===r?f=e[3]:(f=(0,a.jsx)(T,{content:"Add notebook",children:(0,a.jsx)(R,{"data-testid":"file-explorer-add-notebook-button",onClick:r,variant:"text",size:"xs",children:m})}),e[2]=r,e[3]=f);let j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)(Ze,{size:16}),e[4]=j):j=e[4];let d;e[5]===i?d=e[6]:(d=(0,a.jsx)(T,{content:"Add file",children:(0,a.jsx)(R,{"data-testid":"file-explorer-add-file-button",onClick:i,variant:"text",size:"xs",children:j})}),e[5]=i,e[6]=d);let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(ot,{size:16}),e[7]=u):u=e[7];let h;e[8]===l?h=e[9]:(h=(0,a.jsx)(T,{content:"Add folder",children:(0,a.jsx)(R,{"data-testid":"file-explorer-add-folder-button",onClick:l,variant:"text",size:"xs",children:u})}),e[8]=l,e[9]=h);let y;e[10]===o?y=e[11]:(y=o({}),e[10]=o,e[11]=y);let w,v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=Lt({variant:"text",size:"xs"}),w=(0,a.jsx)(ia,{size:16}),e[12]=w,e[13]=v):(w=e[12],v=e[13]);let b;e[14]===y?b=e[15]:(b=(0,a.jsx)(T,{content:"Upload file",children:(0,a.jsx)("button",{"data-testid":"file-explorer-upload-button",...y,className:v,children:w})}),e[14]=y,e[15]=b);let N;e[16]===g?N=e[17]:(N=g({}),e[16]=g,e[17]=N);let x;e[18]===N?x=e[19]:(x=(0,a.jsx)("input",{...N,type:"file"}),e[18]=N,e[19]=x);let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F=(0,a.jsx)(aa,{size:16}),e[20]=F):F=e[20];let D;e[21]===s?D=e[22]:(D=(0,a.jsx)(T,{content:"Refresh",children:(0,a.jsx)(R,{"data-testid":"file-explorer-refresh-button",onClick:s,variant:"text",size:"xs",children:F})}),e[21]=s,e[22]=D);let S;e[23]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)(Jt,{size:16}),e[23]=S):S=e[23];let C;e[24]===n?C=e[25]:(C=(0,a.jsx)(T,{content:"Toggle hidden files",children:(0,a.jsx)(R,{"data-testid":"file-explorer-hidden-files-button",onClick:n,variant:"text",size:"xs",children:S})}),e[24]=n,e[25]=C);let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=(0,a.jsx)(Ma,{size:16}),e[26]=_):_=e[26];let P;e[27]===c?P=e[28]:(P=(0,a.jsx)(T,{content:"Collapse all folders",children:(0,a.jsx)(R,{"data-testid":"file-explorer-collapse-button",onClick:c,variant:"text",size:"xs",children:_})}),e[27]=c,e[28]=P);let O;return e[29]!==b||e[30]!==x||e[31]!==D||e[32]!==C||e[33]!==P||e[34]!==f||e[35]!==d||e[36]!==h?(O=(0,a.jsxs)("div",{className:"flex items-center justify-end px-2 shrink-0 border-b",children:[f,d,h,b,x,D,C,P]}),e[29]=b,e[30]=x,e[31]=D,e[32]=C,e[33]=P,e[34]=f,e[35]=d,e[36]=h,e[37]=O):O=e[37],O},cs=t=>{let e=(0,oe.c)(9),{node:s,onOpenMarimoFile:n}=t,i;e[0]===s?i=e[1]:(i=c=>{s.data.isDirectory||(c.stopPropagation(),s.select())},e[0]=s,e[1]=i);let r;e[2]!==s.data.isMarimoFile||e[3]!==n?(r=s.data.isMarimoFile&&!pe()&&(0,a.jsxs)("span",{className:"shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:n,children:["open ",(0,a.jsx)(be,{className:"inline ml-1",size:12})]}),e[2]=s.data.isMarimoFile,e[3]=n,e[4]=r):r=e[4];let l;return e[5]!==s.data.name||e[6]!==i||e[7]!==r?(l=(0,a.jsxs)("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:i,children:[s.data.name,r]}),e[5]=s.data.name,e[6]=i,e[7]=r,e[8]=l):l=e[8],l},ds=t=>{let e=(0,oe.c)(10),{node:s}=t,n=(0,M.useRef)(null),i,r;e[0]===s.data.name?(i=e[1],r=e[2]):(i=()=>{var o,g;(o=n.current)==null||o.focus(),(g=n.current)==null||g.setSelectionRange(0,s.data.name.lastIndexOf("."))},r=[s.data.name],e[0]=s.data.name,e[1]=i,e[2]=r),(0,M.useEffect)(i,r);let l,c;e[3]===s?(l=e[4],c=e[5]):(l=()=>s.reset(),c=o=>{o.key==="Escape"&&s.reset(),o.key==="Enter"&&s.submit(o.currentTarget.value)},e[3]=s,e[4]=l,e[5]=c);let p;return e[6]!==s.data.name||e[7]!==l||e[8]!==c?(p=(0,a.jsx)("input",{ref:n,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:s.data.name,onClick:us,onBlur:l,onKeyDown:c}),e[6]=s.data.name,e[7]=l,e[8]=c,e[9]=p):p=e[9],p},hs=({node:t,style:e,dragHandle:s})=>{let{openFile:n,sendCreateFileOrFolder:i,sendFileDetails:r}=ge(),l=ne(Be),c=t.data.isDirectory?"directory":Xt(t.data.name),p=ea[c],{openConfirm:o,openPrompt:g}=tt(),{createNewCell:m}=Dt(),f=Na(),j=x=>{m({code:x,before:!1,cellId:f??"__end__"})},d=(0,M.use)(yt),u=async x=>{vt(x,d?d.relativeFromRoot(t.data.path):t.data.path)},h=async x=>{x.stopPropagation(),x.preventDefault(),o({title:"Delete file",description:`Are you sure you want to delete ${t.data.name}?`,confirmAction:(0,a.jsx)(ca,{onClick:async()=>{await t.tree.delete(t.id)},"aria-label":"Confirm",children:"Delete"})})},y=q(async()=>{t.open(),g({title:"Folder name",onConfirm:async x=>{d==null||d.createFolder(x,t.id)}})}),w=q(async()=>{t.open(),g({title:"File name",onConfirm:async x=>{d==null||d.createFile(x,t.id)}})}),v=q(async()=>{t.open(),g({title:"Notebook name",onConfirm:async x=>{d==null||d.createFile(x,t.id,"notebook")}})}),b=q(async()=>{var S;if(!d||t.data.isDirectory)return;let[x,F]=la(t.data.name),D=`${x}_copy${F}`;try{let C=await r({path:t.data.path}),_=((S=t.parent)==null?void 0:S.data.path)||"";await i({path:_,type:"file",name:D,contents:C.contents?btoa(C.contents):void 0}),await d.refreshAll([_])}catch{E({title:"Failed to duplicate file",description:"Unable to create a duplicate of the file",variant:"danger"})}}),N=()=>{let x={size:14,strokeWidth:1.5,className:"mr-2"};return(0,a.jsxs)(Ke,{align:"end",className:"print:hidden w-[220px]",onClick:F=>F.stopPropagation(),onCloseAutoFocus:F=>F.preventDefault(),children:[!t.data.isDirectory&&(0,a.jsxs)(A,{onSelect:()=>t.select(),children:[(0,a.jsx)(dt,{...x}),"Open file"]}),!t.data.isDirectory&&!pe()&&(0,a.jsxs)(A,{onSelect:()=>{n({path:t.data.path})},children:[(0,a.jsx)(be,{...x}),"Open file in external editor"]}),t.data.isDirectory&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(A,{onSelect:()=>v(),children:[(0,a.jsx)(lt,{...x}),"Create notebook"]}),(0,a.jsxs)(A,{onSelect:()=>w(),children:[(0,a.jsx)(Ze,{...x}),"Create file"]}),(0,a.jsxs)(A,{onSelect:()=>y(),children:[(0,a.jsx)(ot,{...x}),"Create folder"]}),(0,a.jsx)(ie,{})]}),(0,a.jsxs)(A,{onSelect:()=>t.edit(),children:[(0,a.jsx)(Oa,{...x}),"Rename"]}),!t.data.isDirectory&&(0,a.jsxs)(A,{onSelect:b,children:[(0,a.jsx)(we,{...x}),"Duplicate"]}),(0,a.jsxs)(A,{onSelect:async()=>{await le(t.data.path),E({title:"Copied to clipboard"})},children:[(0,a.jsx)(ct,{...x}),"Copy path"]}),d&&(0,a.jsxs)(A,{onSelect:async()=>{await le(d.relativeFromRoot(t.data.path)),E({title:"Copied to clipboard"})},children:[(0,a.jsx)(ct,{...x}),"Copy relative path"]}),(0,a.jsx)(ie,{}),(0,a.jsxs)(A,{onSelect:()=>{let{path:F}=t.data;j(Qe[c](F))},children:[(0,a.jsx)($t,{...x}),"Insert snippet for reading file"]}),(0,a.jsxs)(A,{onSelect:async()=>{E({title:"Copied to clipboard",description:"Code to open the file has been copied to your clipboard. You can also drag and drop this file into the editor"});let{path:F}=t.data;await le(Qe[c](F))},children:[(0,a.jsx)(Mt,{...x}),"Copy snippet for reading file"]}),t.data.isMarimoFile&&!pe()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ie,{}),(0,a.jsxs)(A,{onSelect:u,children:[(0,a.jsx)(Ra,{...x}),"Open notebook"]})]}),(0,a.jsx)(ie,{}),!t.data.isDirectory&&!l&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(A,{onSelect:async()=>{let F=(await r({path:t.data.path})).contents||"";$e(new Blob([F]),t.data.name)},children:[(0,a.jsx)(Ne,{...x}),"Download"]}),(0,a.jsx)(ie,{})]}),(0,a.jsxs)(A,{onSelect:h,variant:"danger",children:[(0,a.jsx)(ra,{...x}),"Delete"]})]})};return(0,a.jsxs)("div",{style:e,ref:s,className:Y("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),draggable:!0,onClick:x=>{x.stopPropagation(),t.data.isDirectory&&t.toggle()},children:[(0,a.jsx)(ms,{node:t}),(0,a.jsxs)("span",{className:Y("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",t.willReceiveDrop&&t.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground"),children:[t.data.isMarimoFile?(0,a.jsx)(Da,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}):(0,a.jsx)(p,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}),t.isEditing?(0,a.jsx)(ds,{node:t}):(0,a.jsx)(cs,{node:t,onOpenMarimoFile:u}),(0,a.jsxs)(Ge,{modal:!1,children:[(0,a.jsx)(qe,{asChild:!0,tabIndex:-1,onClick:x=>x.stopPropagation(),children:(0,a.jsx)(R,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:(0,a.jsx)(Ye,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),N()]})]})]})},ms=t=>{let e=(0,oe.c)(3),{node:s}=t;if(!s.data.isDirectory){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)("span",{className:"w-5 h-5 shrink-0"}),e[0]=i):i=e[0],i}let n;return e[1]===s.isOpen?n=e[2]:(n=s.isOpen?(0,a.jsx)(qt,{className:"w-5 h-5 shrink-0"}):(0,a.jsx)(ve,{className:"w-5 h-5 shrink-0"}),e[1]=s.isOpen,e[2]=n),n};function vt(t,e){t.stopPropagation(),t.preventDefault(),za(e)}function bt(t,e){if(e)return t;let s=[];for(let n of t){if(ps(n.name))continue;let i=n;if(n.children){let r=bt(n.children,e);r!==n.children&&(i={...n,children:r})}s.push(i)}return s}function ps(t){return!!t.startsWith(".")}function xs(){return null}function fs(t){let{parentNode:e}=t;return!e.data.isDirectory}function us(t){return t.stopPropagation()}var wt=se(),gs=Ie("marimo:file-explorer-panel:state",{openSections:["files"],hasUserInteracted:!1},Ae),Nt=t=>{let e=(0,wt.c)(20),{height:s}=t,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={noClick:!0,noKeyboard:!0},e[0]=n):n=e[0];let{getRootProps:i,getInputProps:r,isDragActive:l}=jt(n),c;e[1]===i?c=e[2]:(c=i(),e[1]=i,e[2]=c);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=Y("flex flex-col overflow-hidden relative"),e[3]=p):p=e[3];let o;e[4]===s?o=e[5]:(o={height:s},e[4]=s,e[5]=o);let g;e[6]===r?g=e[7]:(g=r(),e[6]=r,e[7]=g);let m;e[8]===g?m=e[9]:(m=(0,a.jsx)("input",{...g}),e[8]=g,e[9]=m);let f;e[10]===l?f=e[11]:(f=l&&(0,a.jsx)("div",{className:"absolute inset-0 flex items-center uppercase justify-center text-xl font-bold text-primary/90 bg-accent/85 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none",children:"Drop files here"}),e[10]=l,e[11]=f);let j;e[12]===s?j=e[13]:(j=(0,a.jsx)(is,{height:s}),e[12]=s,e[13]=j);let d;return e[14]!==c||e[15]!==o||e[16]!==m||e[17]!==f||e[18]!==j?(d=(0,a.jsx)(qa,{children:(0,a.jsxs)("div",{...c,className:p,style:o,children:[m,f,j]})}),e[14]=c,e[15]=o,e[16]=m,e[17]=f,e[18]=j,e[19]=d):d=e[19],d},js=33,ys=()=>{let t=(0,wt.c)(41),{ref:e,height:s}=Fa(),n=s===void 0?500:s,[i,r]=me(gs),l=ne(Wt).length,c;e:{if(!i.hasUserInteracted&&l>0){if(i.openSections.includes("remote-storage")){c=i.openSections;break e}let z;t[0]===i.openSections?z=t[1]:(z=[...i.openSections,"remote-storage"],t[0]=i.openSections,t[1]=z),c=z;break e}c=i.openSections}let p=c,o;t[2]===r?o=t[3]:(o=z=>{r({openSections:z,hasUserInteracted:!0})},t[2]=r,t[3]=o);let g=o,m=n-js*2,f;t[4]===p?f=t[5]:(f=p.includes("remote-storage"),t[4]=p,t[5]=f);let j=f,d;t[6]!==p||t[7]!==j?(d=j&&p.includes("files"),t[6]=p,t[7]=j,t[8]=d):d=t[8];let u=d,h;t[9]!==m||t[10]!==u?(h=u?Math.round(m*.4):m,t[9]=m,t[10]=u,t[11]=h):h=t[11];let y=h,w=Math.max(200,u?m-y:m);if(!Pt("storage_inspector")){let z;t[12]===n?z=t[13]:(z=(0,a.jsx)(Nt,{height:n}),t[12]=n,t[13]=z);let L;return t[14]!==e||t[15]!==z?(L=(0,a.jsx)("div",{ref:e,className:"h-full overflow-auto",children:z}),t[14]=e,t[15]=z,t[16]=L):L=t[16],L}let v;t[17]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsx)(Te,{className:"w-4 h-4"}),t[17]=v):v=t[17];let b;t[18]===l?b=t[19]:(b=l>0&&(0,a.jsx)(Pa,{children:l}),t[18]=l,t[19]=b);let N;t[20]===b?N=t[21]:(N=(0,a.jsxs)(nt,{children:[v," Remote storage",b]}),t[20]=b,t[21]=N);let x;t[22]===y?x=t[23]:(x={maxHeight:y},t[22]=y,t[23]=x);let F;t[24]===Symbol.for("react.memo_cache_sentinel")?(F=(0,a.jsx)(Ua,{}),t[24]=F):F=t[24];let D;t[25]===x?D=t[26]:(D=(0,a.jsx)(it,{className:"overflow-auto",style:x,children:F}),t[25]=x,t[26]=D);let S;t[27]!==D||t[28]!==N?(S=(0,a.jsxs)(rt,{value:"remote-storage",children:[N,D]}),t[27]=D,t[28]=N,t[29]=S):S=t[29];let C;t[30]===Symbol.for("react.memo_cache_sentinel")?(C=(0,a.jsxs)(nt,{children:[(0,a.jsx)(Je,{className:"w-4 h-4"}),"Files"]}),t[30]=C):C=t[30];let _;t[31]===w?_=t[32]:(_=(0,a.jsxs)(rt,{value:"files",children:[C,(0,a.jsx)(it,{children:(0,a.jsx)(Nt,{height:w})})]}),t[31]=w,t[32]=_);let P;t[33]!==g||t[34]!==p||t[35]!==S||t[36]!==_?(P=(0,a.jsxs)(pa,{type:"multiple",value:p,onValueChange:g,children:[S,_]}),t[33]=g,t[34]=p,t[35]=S,t[36]=_,t[37]=P):P=t[37];let O;return t[38]!==e||t[39]!==P?(O=(0,a.jsx)("div",{ref:e,className:"h-full overflow-auto",children:P}),t[38]=e,t[39]=P,t[40]=O):O=t[40],O};export{ys as default};
1
+ var Ft=Object.defineProperty;var Ct=(t,e,s)=>e in t?Ft(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var G=(t,e,s)=>Ct(t,typeof e!="symbol"?e+"":e,s);import{s as Oe}from"./chunk-LvLJmgfZ.js";import{i as St,l as me,n as q,p as Re,u as ne}from"./useEvent-WUlsM6MC.js";import{t as _t}from"./react-Bj1aDYRI.js";import{En as Pt,T as Dt,kn as Ae,si as zt,ui as Ie,ur as Mt}from"./cells-CCtxWKxf.js";import"./react-dom-CSu739Rf.js";import{t as se}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-D_HRHf_c.js";import{a as Te,i as Le,r as Ot,t as Ee}from"./add-connection-dialog-9CzjZlY9.js";import{h as Rt,m as ue}from"./useEventListener-CjXriKgk.js";import{t as At}from"./invariant-awXiPaF0.js";import{p as It,u as Be}from"./utils-CORJ8yYa.js";import{S as pe}from"./config-D9X9QKiL.js";import{t as Tt}from"./jsx-runtime-CP2fAiZX.js";import{n as Lt,t as R}from"./button-BmOH9agK.js";import{t as Y}from"./cn-d_A4rA-x.js";import{St as Et}from"./dist-DUY6xZX8.js";import{a as Bt,i as Ve,o as xe}from"./JsonOutput-GlMQ3aLA.js";import"./cjs-CVt8hZ5L.js";import"./main-Cmx6WhDY.js";import"./useNonce-BY4jV7Yb.js";import{n as Vt,r as ge}from"./requests-DZy_SQ_v.js";import{t as re}from"./createLucideIcon-BvP5LBIs.js";import{a as He,i as Ue,l as We,n as fe,o as Ht,r as Ut,s as je,t as Wt}from"./state-B_fNn_z_.js";import{n as $t}from"./LazyAnyLanguageCodeMirror-BdX_Y5NA.js";import{r as qt,t as Kt}from"./x-yqLqiq5Q.js";import{c as Gt,i as ye,r as $e}from"./download-BTm4CTKr.js";import{t as ve}from"./chevron-right-_z3dkNFy.js";import{f as be}from"./maps-8VTEe-0T.js";import{n as Yt}from"./markdown-renderer-B6a5ZAwT.js";import{u as Zt}from"./toDate-DDAiY7kz.js";import{a as A,c as ie,p as qe,r as Ke,t as Ge}from"./dropdown-menu-CKhrfxsx.js";import{t as we}from"./copy-CAR4dOiD.js";import{t as Ne}from"./download-BG-iMGgV.js";import{t as Ye}from"./ellipsis-vertical-CqcBoxmi.js";import{t as Jt}from"./eye-off-DgTL09j7.js";import{t as Ze}from"./file-plus-corner-BRwJx0yp.js";import{t as Je}from"./file-DVwc11C3.js";import{i as Qt,n as Qe,r as Xt,t as ea}from"./types-DFiYrN2w.js";import"./html-to-image-b9BimK8l.js";import{n as ke,t as ta}from"./spinner-DCSoZZhh.js";import{t as Xe}from"./plus-B-s-VRHt.js";import{t as aa}from"./refresh-ccw-BOzRCrXK.js";import{t as Fe}from"./refresh-cw-DeCFDX1B.js";import{t as sa}from"./save-I_RGv5p0.js";import{t as ra}from"./trash-2-DtQaB9NM.js";import{t as na}from"./triangle-alert-n1-FF7zs.js";import{i as ia,n as la,t as oa}from"./es-1hBRXVlM.js";import"./dist-DfBASypd.js";import"./dist-Dq_iQ08e.js";import"./dist-BjtLy-VA.js";import"./dist-odxAaH5Z.js";import"./dist-51xFOPFs.js";import{t as E}from"./use-toast-BhMe50aT.js";import{t as Ce}from"./paths-bMgYkaP2.js";import"./session-DnMOyddG.js";import"./Combination-tjZP3FH6.js";import{t as T}from"./tooltip-DOQlecCr.js";import"./purify.es-CPplrWRQ.js";import"./dates-CzBDvj6R.js";import{o as ca}from"./alert-dialog-DsNfSYaw.js";import{t as et}from"./context-B1_BdDTF.js";import"./popover-Cvl9xY6R.js";import{n as tt}from"./ImperativeModal-CRNJOvqT.js";import{r as da}from"./errors-Bfogio62.js";import{n as ha}from"./blob-CObhN-9g.js";import"./vega-loader.browser-CZV6_g2i.js";import"./defaultLocale-OkOxlkkM.js";import"./defaultLocale-DK1MWd7f.js";import{t as le}from"./copy-DMCkK2TI.js";import{t as ma}from"./copy-icon-6RnnFDPt.js";import{n as pa}from"./multi-map-kCmlVJ-5.js";import{a as xa,i as fa,n as Se,r as ua,t as ga}from"./tree-D0AxVJ_I.js";import{n as ja,t as ya}from"./alert-0YTlkh9P.js";import{n as at}from"./error-banner-R2OkQKR0.js";import{n as _e}from"./useAsyncData-DVm0BCFt.js";import{a as va,o as st,t as ba,u as wa}from"./command-DQqqP-WF.js";import"./chunk-5FQGJX7Z-BJDu6jwt.js";import"./katex-rvFxOCU-.js";import{o as Na}from"./focus-ShrwcKIv.js";import{a as ka}from"./renderShortcut-BJEd-iA7.js";import{t as Fa}from"./bundle.esm-_LzfhNmX.js";import{a as Ca}from"./components-CF9x5raB.js";import{t as Sa}from"./empty-state-DFr2pZOz.js";import{t as Pe}from"./formatting-8bP-RDnl.js";import{a as _a,i as Pa,n as rt,r as nt,t as it}from"./components-BZCdnYSp.js";import{n as lt,t as Da}from"./marimo-icons-BDAuIiW5.js";import{t as za}from"./links-syPBpTLO.js";var Ma=re("copy-minus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),ot=re("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),ct=re("list-tree",[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]),Oa=re("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),Ra=re("square-play",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}]]),dt=re("view",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),M=Oe(_t(),1),Aa=se(),a=Oe(Tt(),1);const ht=t=>{let e=(0,Aa.c)(17),{filename:s,filenameIcon:n,onBack:i,onRefresh:r,onDownload:l,actions:c}=t,p;e[0]===i?p=e[1]:(p=i&&(0,a.jsx)(T,{content:"Back to file list",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:i,children:(0,a.jsx)(We,{className:"h-4 w-4"})})}),e[0]=i,e[1]=p);let o;e[2]!==s||e[3]!==n?(o=s?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate",children:[n,s]}):(0,a.jsx)("span",{className:"flex-1"}),e[2]=s,e[3]=n,e[4]=o):o=e[4];let g;e[5]===r?g=e[6]:(g=r&&(0,a.jsx)(T,{content:"Refresh",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:r,children:(0,a.jsx)(Fe,{className:"h-3.5 w-3.5"})})}),e[5]=r,e[6]=g);let m;e[7]===l?m=e[8]:(m=l&&(0,a.jsx)(T,{content:"Download",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:l,children:(0,a.jsx)(Ne,{className:"h-3.5 w-3.5"})})}),e[7]=l,e[8]=m);let f;e[9]!==c||e[10]!==g||e[11]!==m?(f=(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[g,c,m]}),e[9]=c,e[10]=g,e[11]=m,e[12]=f):f=e[12];let j;return e[13]!==p||e[14]!==o||e[15]!==f?(j=(0,a.jsxs)("div",{className:"flex items-center shrink-0 border-b px-1 gap-1",children:[p,o,f]}),e[13]=p,e[14]=o,e[15]=f,e[16]=j):j=e[16],j};var Ia=100*1024*1024;function Ta(t){let e=t.endsWith("/")?t.slice(0,-1):t,s=e.split("/");return s[s.length-1]||e}const La=({entry:t,namespace:e,onBack:s})=>{let{locale:n}=et(),i=Ta(t.path),r=t.mimeType||"text/plain",l=xe(r),c=l&&t.size>Ia&&t.size>0,{data:p,isPending:o,error:g,refetch:m}=_e(async()=>{if(c)return null;let u=await je.request({namespace:e,path:t.path,preview:!l});if(u.error)throw Error(u.error);if(!u.url)throw Error("No URL returned");if(l)return{type:"media",url:u.url};let h=await fetch(u.url);if(!h.ok)throw Error(`Failed to fetch preview: ${h.statusText}`);return{type:"text",content:await h.text()}},[e,t.path,l,c]),f=(0,M.useCallback)(async()=>{try{let u=await je.request({namespace:e,path:t.path});if(u.error){E({title:"Download failed",description:u.error,variant:"danger"});return}u.url&&ye(u.url,u.filename??i)}catch(u){ue.error("Failed to download storage entry",u),E({title:"Download failed",description:String(u),variant:"danger"})}},[e,t.path,i]),j=(0,a.jsx)(ht,{filename:i,filenameIcon:Le(i),onBack:s,onDownload:f}),d=({includeMime:u=!1})=>(0,a.jsxs)("div",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 p-4 text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Path"}),(0,a.jsxs)("div",{className:"truncate flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"font-mono text-[11px]",children:t.path}),(0,a.jsx)(ma,{value:t.path,className:"h-3 w-3"})]}),u&&(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Type"}),u&&(0,a.jsx)("span",{children:r}),t.size>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Size"}),(0,a.jsx)("span",{children:Pe(t.size,n)})]}),t.lastModified!=null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Modified"}),(0,a.jsx)("span",{children:new Date(t.lastModified*1e3).toLocaleString()})]})]});return c?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[j,d({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-muted-foreground italic",children:["File is too large to preview (",Pe(t.size,n),")."]})]}):o?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[j,d({}),(0,a.jsxs)("div",{className:"flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground min-h-24",children:[(0,a.jsx)(ke,{className:"h-4 w-4 animate-spin"}),"Loading preview..."]})]}):g?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[j,d({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-destructive",children:["Failed to load preview: ",g.message]}),(0,a.jsx)("div",{className:"px-4 pb-4",children:(0,a.jsxs)(R,{variant:"secondary",size:"xs",onClick:m,children:[(0,a.jsx)(Fe,{className:"h-3 w-3 mr-1"}),"Retry"]})})]}):p?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[j,d({}),(0,a.jsx)(Ve,{mimeType:r,contents:p.type==="text"?p.content:void 0,mediaSource:p.type==="media"?{url:p.url}:void 0})]}):(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[j,d({includeMime:!0}),(0,a.jsxs)("div",{className:"p-4 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(Je,{className:"h-4 w-4"}),"Preview not available for this file type."]})]})};var De=se(),Ea=16;function Z(t){return{paddingLeft:t*Ea}}function Ba(t,e){return new Date(t*1e3).toLocaleDateString(e,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function mt(t){let e=t.endsWith("/")?t.slice(0,-1):t,s=e.split("/");return s[s.length-1]||e}function ze(t,e,s,n){let i=s.toLowerCase();if(mt(t.path).toLowerCase().includes(i))return!0;if(t.kind==="directory"){let r=n.get(He(e,t.path));if(r)return r.some(l=>ze(l,e,s,n))}return!1}function pt(t,e,s,n){return s.trim()?t.filter(i=>ze(i,e,s,n)):t}var Va=t=>{let e=(0,De.c)(34),{namespace:s,protocol:n,rootPath:i,prefix:r,depth:l,locale:c,searchValue:p,onOpenFile:o}=t,{entriesByPath:g}=fe(),{entries:m,isPending:f,error:j}=Ue(s,r);if(f){let h;e[0]===l?h=e[1]:(h=Z(l),e[0]=l,e[1]=h);let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=(0,a.jsx)(ke,{className:"h-3 w-3 animate-spin"}),e[2]=y):y=e[2];let w;return e[3]===h?w=e[4]:(w=(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:h,children:[y,"Loading..."]}),e[3]=h,e[4]=w),w}if(j){let h;e[5]===l?h=e[6]:(h=Z(l),e[5]=l,e[6]=h);let y;return e[7]!==j.message||e[8]!==h?(y=(0,a.jsxs)("div",{className:"py-1 text-xs text-destructive",style:h,children:["Failed to load: ",j.message]}),e[7]=j.message,e[8]=h,e[9]=y):y=e[9],y}if(m.length===0){let h;e[10]===l?h=e[11]:(h=Z(l),e[10]=l,e[11]=h);let y;return e[12]===h?y=e[13]:(y=(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:h,children:"Empty"}),e[12]=h,e[13]=y),y}let d;if(e[14]!==m||e[15]!==l||e[16]!==g||e[17]!==c||e[18]!==s||e[19]!==o||e[20]!==n||e[21]!==i||e[22]!==p){let h=pt(m,s,p,g),y;e[24]!==l||e[25]!==c||e[26]!==s||e[27]!==o||e[28]!==n||e[29]!==i||e[30]!==p?(y=w=>(0,a.jsx)(xt,{entry:w,namespace:s,protocol:n,rootPath:i,depth:l,locale:c,searchValue:p,onOpenFile:o},w.path),e[24]=l,e[25]=c,e[26]=s,e[27]=o,e[28]=n,e[29]=i,e[30]=p,e[31]=y):y=e[31],d=h.map(y),e[14]=m,e[15]=l,e[16]=g,e[17]=c,e[18]=s,e[19]=o,e[20]=n,e[21]=i,e[22]=p,e[23]=d}else d=e[23];let u;return e[32]===d?u=e[33]:(u=(0,a.jsx)(a.Fragment,{children:d}),e[32]=d,e[33]=u),u},xt=({entry:t,namespace:e,protocol:s,rootPath:n,depth:i,locale:r,searchValue:l,onOpenFile:c})=>{var w;let[p,o]=(0,M.useState)(!1),{entriesByPath:g}=fe(),m=t.kind==="directory",f=mt(t.path),j=!!l.trim(),d=m&&j&&f.toLowerCase().includes(l.trim().toLowerCase()),u=m&&j&&!!((w=g.get(He(e,t.path)))!=null&&w.some(v=>ze(v,e,l,g))),h=p||u,y=(0,M.useCallback)(async()=>{try{let v=await je.request({namespace:e,path:t.path});if(v.error){E({title:"Download failed",description:v.error,variant:"danger"});return}v.url&&ye(v.url,v.filename??"download")}catch(v){ue.error("Failed to download storage entry",v),E({title:"Download failed",description:String(v),variant:"danger"})}},[e,t.path]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(st,{className:Y("text-xs flex items-center gap-1.5 cursor-pointer rounded-none group h-6.5",m&&"font-medium"),style:Z(i),value:`${e}:${t.path}`,onSelect:()=>{m?o(!h):c({entry:t,namespace:e})},children:[m?(0,a.jsx)(ve,{className:Y("h-3 w-3 shrink-0 transition-transform",h&&"rotate-90")}):(0,a.jsx)("span",{className:"w-3 shrink-0"}),m?(0,a.jsx)(Qt,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}):Le(f),(0,a.jsx)("span",{className:"truncate flex-1 text-left",children:f}),(0,a.jsxs)("div",{className:"flex items-center",children:[t.size>0&&(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground pr-2 opacity-0 group-hover:opacity-100 transition-opacity tabular-nums",children:Pe(t.size,r)}),t.lastModified!=null&&(0,a.jsx)(T,{content:`Last modified: ${new Date(t.lastModified*1e3).toLocaleString()}`,children:(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground pr-1 opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap",children:Ba(t.lastModified,r)})}),(0,a.jsxs)(Ge,{children:[(0,a.jsx)(qe,{asChild:!0,children:(0,a.jsx)(R,{variant:"text",size:"icon",className:"opacity-0 group-hover:opacity-100 transition-opacity hover:shadow-none hover:text-link text-muted-foreground",onClick:v=>v.stopPropagation(),children:(0,a.jsx)(Ye,{className:"h-3 w-3"})})}),(0,a.jsxs)(Ke,{align:"end",onClick:v=>v.stopPropagation(),onCloseAutoFocus:v=>v.preventDefault(),children:[!m&&(0,a.jsxs)(A,{onSelect:()=>c({entry:t,namespace:e}),children:[(0,a.jsx)(dt,{className:"h-3.5 w-3.5 mr-2"}),"View"]}),(0,a.jsxs)(A,{onSelect:async()=>{await le(Ht(s,n,t.path).toString()),E({title:"Copied to clipboard"})},children:[(0,a.jsx)(we,{className:"h-3.5 w-3.5 mr-2"}),"Copy URL"]}),!m&&(0,a.jsxs)(A,{onSelect:()=>y(),children:[(0,a.jsx)(Ne,{className:"h-3.5 w-3.5 mr-2"}),"Download"]})]})]})]})]}),m&&h&&(0,a.jsx)(Va,{namespace:e,protocol:s,rootPath:n,prefix:t.path,depth:i+1,locale:r,searchValue:d?"":l,onOpenFile:c})]})},Ha=t=>{let e=(0,De.c)(50),{namespace:s,locale:n,searchValue:i,onOpenFile:r}=t,[l,c]=(0,M.useState)(!0),[p,o]=(0,M.useState)(!1),{entriesByPath:g}=fe(),{clearNamespaceCache:m}=Ut(),f=s.name??s.displayName,{entries:j,isPending:d,error:u,refetch:h}=Ue(f),y;e[0]!==m||e[1]!==f||e[2]!==h?(y=N=>{N.stopPropagation(),o(!0),m(f),h(),setTimeout(()=>o(!1),500)},e[0]=m,e[1]=f,e[2]=h,e[3]=y):y=e[3];let w=y,v=d?s.storageEntries:j,b;if(e[4]!==v||e[5]!==g||e[6]!==u||e[7]!==w||e[8]!==l||e[9]!==d||e[10]!==p||e[11]!==n||e[12]!==s.displayName||e[13]!==s.name||e[14]!==s.protocol||e[15]!==s.rootPath||e[16]!==f||e[17]!==r||e[18]!==i){let N=pt(v,f,i,g),x=s.name,F;e[20]===l?F=e[21]:(F=()=>c(!l),e[20]=l,e[21]=F);let D=l&&"rotate-90",S;e[22]===D?S=e[23]:(S=Y("h-3 w-3 shrink-0 transition-transform",D),e[22]=D,e[23]=S);let C;e[24]===S?C=e[25]:(C=(0,a.jsx)(ve,{className:S}),e[24]=S,e[25]=C);let _;e[26]===s.protocol?_=e[27]:(_=(0,a.jsx)(Ot,{protocol:s.protocol}),e[26]=s.protocol,e[27]=_);let P;e[28]===s.displayName?P=e[29]:(P=(0,a.jsx)("span",{children:s.displayName}),e[28]=s.displayName,e[29]=P);let O;e[30]===s.name?O=e[31]:(O=s.name&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-normal",children:["(",(0,a.jsx)(_a,{variableName:s.name}),")"]}),e[30]=s.name,e[31]=O);let z=p&&"animate-[spin_0.5s]",L;e[32]===z?L=e[33]:(L=Y("h-3 w-3 text-muted-foreground hover:text-foreground",z),e[32]=z,e[33]=L);let V;e[34]===L?V=e[35]:(V=(0,a.jsx)(Fe,{className:L}),e[34]=L,e[35]=V);let U;e[36]!==w||e[37]!==V?(U=(0,a.jsx)(T,{content:"Refresh storage connection",children:(0,a.jsx)(R,{variant:"ghost",size:"icon",className:"hover:bg-transparent hover:shadow-none",onClick:w,children:V})}),e[36]=w,e[37]=V,e[38]=U):U=e[38];let W=s.rootPath||"(root)",$;e[39]===W?$=e[40]:($=(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-normal tabular-nums ml-auto",children:W}),e[39]=W,e[40]=$);let H;e[41]!==s.name||e[42]!==O||e[43]!==U||e[44]!==$||e[45]!==F||e[46]!==C||e[47]!==_||e[48]!==P?(H=(0,a.jsxs)(st,{value:x,onSelect:F,className:"flex flex-row font-semibold h-7 text-xs gap-1.5 bg-(--slate-2) text-muted-foreground rounded-none",children:[C,_,P,O,U,$]}),e[41]=s.name,e[42]=O,e[43]=U,e[44]=$,e[45]=F,e[46]=C,e[47]=_,e[48]=P,e[49]=H):H=e[49],b=(0,a.jsxs)(a.Fragment,{children:[H,l&&(0,a.jsxs)(a.Fragment,{children:[d&&v.length===0&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:Z(1),children:[(0,a.jsx)(ke,{className:"h-3 w-3 animate-spin"}),"Loading..."]}),u&&v.length===0&&(0,a.jsx)(Ca,{error:u,style:Z(1),className:"py-1 text-xs h-auto",showIcon:!1}),!d&&v.length===0&&!u&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:Z(1),children:"No entries"}),i&&N.length===0&&v.length>0&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:Z(1),children:"No matches"}),N.map(K=>(0,a.jsx)(xt,{entry:K,namespace:f,protocol:s.protocol,rootPath:s.rootPath,depth:1,locale:n,searchValue:i,onOpenFile:r},K.path))]})]}),e[4]=v,e[5]=g,e[6]=u,e[7]=w,e[8]=l,e[9]=d,e[10]=p,e[11]=n,e[12]=s.displayName,e[13]=s.name,e[14]=s.protocol,e[15]=s.rootPath,e[16]=f,e[17]=r,e[18]=i,e[19]=b}else b=e[19];return b};const Ua=()=>{let t=(0,De.c)(31),{namespaces:e}=fe(),{locale:s}=et(),[n,i]=(0,M.useState)(""),[r,l]=(0,M.useState)(null),c=!!n.trim();if(e.length===0){let b;t[0]===Symbol.for("react.memo_cache_sentinel")?(b=(0,a.jsxs)("span",{children:["Create an Obstore or fsspec connection in your notebook. See the"," ",(0,a.jsx)("a",{className:"text-link",href:"https://docs.marimo.io/guides/working_with_data/remote_storage/#quick-start",target:"_blank",rel:"noopener noreferrer",children:"docs"}),"."]}),t[0]=b):b=t[0];let N;return t[1]===Symbol.for("react.memo_cache_sentinel")?(N=(0,a.jsx)(Sa,{title:"No storage connected",description:b,action:(0,a.jsx)(Ee,{defaultTab:"storage",children:(0,a.jsxs)(R,{variant:"outline",size:"sm",children:["Add remote storage",(0,a.jsx)(Xe,{className:"h-4 w-4 ml-2"})]})}),icon:(0,a.jsx)(Te,{className:"h-8 w-8"})}),t[1]=N):N=t[1],N}let p;t[2]===r?p=t[3]:(p=r&&(0,a.jsx)(La,{entry:r.entry,namespace:r.namespace,onBack:()=>l(null)}),t[2]=r,t[3]=p);let o=r&&"hidden",g;t[4]===o?g=t[5]:(g=Y("border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin",o),t[4]=o,t[5]=g);let m;t[6]===n?m=t[7]:(m=(0,a.jsx)(va,{placeholder:"Search entries...",className:"h-6 m-1",value:n,onValueChange:i,rootClassName:"flex-1 border-b-0"}),t[6]=n,t[7]=m);let f;t[8]===c?f=t[9]:(f=c&&(0,a.jsx)(R,{variant:"text",size:"xs",className:"float-right border-none px-2 m-0 h-full",onClick:()=>i(""),children:(0,a.jsx)(Kt,{className:"h-4 w-4"})}),t[8]=c,t[9]=f);let j;t[10]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)(T,{content:"Filters loaded entries only. Expand directories to include their contents in the search.",delayDuration:200,children:(0,a.jsx)(Zt,{className:"h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2"})}),t[10]=j):j=t[10];let d;t[11]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)(Ee,{defaultTab:"storage",children:(0,a.jsx)(R,{variant:"ghost",size:"sm",className:"px-2 border-0 border-l border-muted-background rounded-none focus-visible:ring-0 focus-visible:ring-offset-0",children:(0,a.jsx)(Xe,{className:"h-4 w-4"})})}),t[11]=d):d=t[11];let u;t[12]!==m||t[13]!==f?(u=(0,a.jsxs)("div",{className:"flex items-center w-full border-b",children:[m,f,j,d]}),t[12]=m,t[13]=f,t[14]=u):u=t[14];let h;if(t[15]!==s||t[16]!==e||t[17]!==n){let b;t[19]!==s||t[20]!==n?(b=N=>(0,a.jsx)(Ha,{namespace:N,locale:s,searchValue:n,onOpenFile:l},N.name??N.displayName),t[19]=s,t[20]=n,t[21]=b):b=t[21],h=e.map(b),t[15]=s,t[16]=e,t[17]=n,t[18]=h}else h=t[18];let y;t[22]===h?y=t[23]:(y=(0,a.jsx)(wa,{className:"flex flex-col",children:h}),t[22]=h,t[23]=y);let w;t[24]!==g||t[25]!==u||t[26]!==y?(w=(0,a.jsxs)(ba,{className:g,shouldFilter:!1,children:[u,y]}),t[24]=g,t[25]=u,t[26]=y,t[27]=w):w=t[27];let v;return t[28]!==p||t[29]!==w?(v=(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[p,w]}),t[28]=p,t[29]=w,t[30]=v):v=t[30],v};var ft=se(),ut=(0,M.createContext)(null);function Wa(){return(0,M.useContext)(ut)??void 0}var $a=t=>{let e=(0,ft.c)(3),{children:s}=t,n=fa(),i;return e[0]!==s||e[1]!==n?(i=(0,a.jsx)(ut.Provider,{value:n,children:s}),e[0]=s,e[1]=n,e[2]=i):i=e[2],i};const qa=t=>{let e=(0,ft.c)(5),{children:s}=t,[n,i]=(0,M.useState)(null),r;e[0]!==s||e[1]!==n?(r=n&&(0,a.jsx)(xa,{backend:ua,options:{rootElement:n},children:(0,a.jsx)($a,{children:s})}),e[0]=s,e[1]=n,e[2]=r):r=e[2];let l;return e[3]===r?l=e[4]:(l=(0,a.jsx)("div",{ref:i,className:"contents",children:r}),e[3]=r,e[4]=l),l};var Me=new Map;const Ka=({file:t,onOpenNotebook:e})=>{let{sendFileDetails:s,sendUpdateFile:n}=ge(),i=ne(It),r=ne(Be),l=ne(zt),[c,p]=(0,M.useState)(""),{data:o,isPending:g,error:m,setData:f,refetch:j}=_e(async()=>{let x=await s({path:t.path}),F=x.contents||"";return p(Me.get(t.path)||F),x},[t.path]),d=async()=>{c!==(o==null?void 0:o.contents)&&await n({path:t.path,contents:c}).then(x=>{x.success&&(f(F=>({...F,contents:c})),p(c))})},u=(0,M.useRef)(c);if(u.current=c,(0,M.useEffect)(()=>()=>{if(!(o!=null&&o.contents))return;let x=u.current;x===o.contents?Me.delete(t.path):Me.set(t.path,x)},[t.path,o==null?void 0:o.contents]),m)return(0,a.jsx)(at,{error:m});if(g||!o)return null;let h=o.mimeType||"text/plain",y=h in Bt,w=l&&o.file.isMarimoFile&&(t.path===l||t.path.endsWith(`/${l}`));if(!o.contents&&!y)return(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 p-6",children:[(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Name"}),(0,a.jsx)("div",{children:o.file.name}),(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Type"}),(0,a.jsx)("div",{children:h})]});let v=(0,a.jsx)(ht,{filename:o.file.name,onRefresh:j,onDownload:r?void 0:()=>{if(xe(h)){ye(Yt(o.contents,h),o.file.name);return}$e(new Blob([o.contents||c],{type:h}),o.file.name)},actions:(0,a.jsxs)(a.Fragment,{children:[t.isMarimoFile&&!pe()&&(0,a.jsx)(T,{content:"Open notebook",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:x=>e(x),children:(0,a.jsx)(be,{className:"h-3.5 w-3.5"})})}),!xe(h)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(T,{content:"Copy contents to clipboard",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:async()=>{await le(c)},children:(0,a.jsx)(we,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(T,{content:ka("global.save"),children:(0,a.jsx)(R,{variant:c===o.contents?"text":"success",size:"xs",onClick:d,disabled:c===o.contents,children:(0,a.jsx)(sa,{className:"h-3.5 w-3.5"})})})]})]})}),b=xe(h),N=!b&&h!=="text/csv";return(0,a.jsxs)(a.Fragment,{children:[v,N&&w&&(0,a.jsxs)(ya,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(na,{className:"h-4 w-4"}),(0,a.jsx)(ja,{children:"Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution."})]}),(0,a.jsx)(Ve,{mimeType:h,contents:b?void 0:N?c:o.contents??void 0,mediaSource:b?{base64:o.contents,mime:h}:void 0,readOnly:!N,onChange:p,extensions:[Et.of([{key:i.getHotkey("global.save").key,stopPropagation:!0,run:()=>c===o.contents?!1:(d(),!0)}])]})]})};var Ga=class{constructor(t){G(this,"delegate",new Se([]));G(this,"rootPath","");G(this,"onChange",Rt.NOOP);G(this,"path",new Ce("/"));G(this,"initialize",async t=>{if(this.onChange=t,this.delegate.data.length===0)try{let e=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new Se(e.files),this.rootPath=e.root,this.path=Ce.guessDeliminator(e.root)}catch(e){E({title:"Failed",description:da(e)})}this.onChange(this.delegate.data)});G(this,"refreshAll",async t=>{let e=[this.rootPath,...t.map(n=>{var i;return(i=this.delegate.find(n))==null?void 0:i.data.path})].filter(Boolean),s=await Promise.all(e.map(n=>this.callbacks.listFiles({path:n}).catch(()=>({files:[]}))));for(let[n,i]of e.entries()){let r=s[n];i===this.rootPath?this.delegate=new Se(r.files):this.delegate.update({id:i,changes:{children:r.files}})}this.onChange(this.delegate.data)});G(this,"relativeFromRoot",t=>{let e=this.rootPath.endsWith(this.path.deliminator)?this.rootPath:`${this.rootPath}${this.path.deliminator}`;return t.startsWith(e)?t.slice(e.length):t});G(this,"handleResponse",t=>t.success?t:(E({title:"Failed",description:t.message}),null));this.callbacks=t}async expand(t){let e=this.delegate.find(t);if(!e||!e.data.isDirectory)return!1;if(e.children&&e.children.length>0)return!0;let s=await this.callbacks.listFiles({path:e.data.path});return this.delegate.update({id:t,changes:{children:s.files}}),this.onChange(this.delegate.data),!0}async rename(t,e){let s=this.delegate.find(t);if(!s)return;let n=s.data.path,i=this.path.join(this.path.dirname(n),e);await this.callbacks.renameFileOrFolder({path:n,newPath:i}).then(this.handleResponse),this.delegate.update({id:t,changes:{name:e,path:i}}),this.onChange(this.delegate.data),await this.refreshAll([i])}async move(t,e){var n;let s=e?((n=this.delegate.find(e))==null?void 0:n.data.path)??e:this.rootPath;await Promise.all(t.map(i=>{this.delegate.move({id:i,parentId:e,index:0});let r=this.delegate.find(i);if(!r)return Promise.resolve();let l=this.path.join(s,this.path.basename(r.data.path));return this.delegate.update({id:i,changes:{path:l}}),this.callbacks.renameFileOrFolder({path:r.data.path,newPath:l}).then(this.handleResponse)})),this.onChange(this.delegate.data),await this.refreshAll([s])}async createFile(t,e,s="file"){var r;let n=e?((r=this.delegate.find(e))==null?void 0:r.data.path)??e:this.rootPath,i=await this.callbacks.createFileOrFolder({path:n,type:s,name:t}).then(this.handleResponse);i!=null&&i.info&&(this.delegate.create({parentId:e,index:0,data:i.info}),this.onChange(this.delegate.data),await this.refreshAll([n]))}async createFolder(t,e){var i;let s=e?((i=this.delegate.find(e))==null?void 0:i.data.path)??e:this.rootPath,n=await this.callbacks.createFileOrFolder({path:s,type:"directory",name:t}).then(this.handleResponse);n!=null&&n.info&&(this.delegate.create({parentId:e,index:0,data:n.info}),this.onChange(this.delegate.data),await this.refreshAll([s]))}async delete(t){let e=this.delegate.find(t);e&&(await this.callbacks.deleteFileOrFolder({path:e.data.path}).then(this.handleResponse),this.delegate.drop({id:t}),this.onChange(this.delegate.data))}};const gt=Re(t=>{let e=t(Vt);return At(e,"no requestClientAtom set"),new Ga({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),Ya=Re({});async function Za(){await St.get(gt).refreshAll([])}var Ja=se(),Qa=1024*1024*100;function jt(t){let e=(0,Ja.c)(7),s;e[0]===t?s=e[1]:(s=t===void 0?{}:t,e[0]=t,e[1]=s);let n=s,{sendCreateFileOrFolder:i}=ge(),r;e[2]===i?r=e[3]:(r=async c=>{if(c.length===0)return;let p=c.length===1;await Gt(p?"Uploading file...":"Uploading files...",async o=>{o.addTotal(c.length);for(let g of c){let m=rs(ss(g)),f="";m&&(f=Ce.guessDeliminator(m).dirname(m));let j=(await ha(g)).split(",")[1];await i({path:f,type:"file",name:g.name,contents:j}),o.increment(1)}await Za()},{title:p?"File uploaded":`${c.length} files uploaded`})},e[2]=i,e[3]=r);let l;return e[4]!==n||e[5]!==r?(l={multiple:!0,maxSize:Qa,onError:as,onDropRejected:Xa,onDrop:r,...n},e[4]=n,e[5]=r,e[6]=l):l=e[6],oa(l)}function Xa(t){E({title:"File upload failed",description:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:t.map(es)}),variant:"danger"})}function es(t){return(0,a.jsxs)("div",{children:[t.file.name," (",t.errors.map(ts).join(", "),")"]},t.file.name)}function ts(t){return t.message}function as(t){ue.error(t),E({title:"File upload failed",description:t.message,variant:"danger"})}function ss(t){if(t.webkitRelativePath)return t.webkitRelativePath;if("path"in t&&typeof t.path=="string")return t.path;if("relativePath"in t&&typeof t.relativePath=="string")return t.relativePath}function rs(t){if(t)return t.replace(/^\/+/,"")}var oe=se(),ns=Ie("marimo:showHiddenFiles",!0,Ae,{getOnInit:!0}),yt=M.createContext(null);const is=t=>{let e=(0,oe.c)(72),{height:s}=t,n=(0,M.useRef)(null),i=Wa(),[r]=me(gt),l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=[],e[0]=l):l=e[0];let[c,p]=(0,M.useState)(l),[o,g]=(0,M.useState)(null),[m,f]=me(ns),{openPrompt:j}=tt(),[d,u]=me(Ya),h;e[1]===r?h=e[2]:(h=()=>r.initialize(p),e[1]=r,e[2]=h);let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[3]=y):y=e[3];let{isPending:w,error:v}=_e(h,y),b;e[4]!==d||e[5]!==r?(b=()=>{r.refreshAll(Object.keys(d).filter(k=>d[k]))},e[4]=d,e[5]=r,e[6]=b):b=e[6];let N=q(b),x;e[7]!==f||e[8]!==m?(x=()=>{f(!m)},e[7]=f,e[8]=m,e[9]=x):x=e[9];let F=q(x),D;e[10]!==j||e[11]!==r?(D=async()=>{j({title:"Folder name",onConfirm:async k=>{r.createFolder(k,null)}})},e[10]=j,e[11]=r,e[12]=D):D=e[12];let S=q(D),C;e[13]!==j||e[14]!==r?(C=async()=>{j({title:"File name",onConfirm:async k=>{r.createFile(k,null)}})},e[13]=j,e[14]=r,e[15]=C):C=e[15];let _=q(C),P;e[16]!==j||e[17]!==r?(P=async()=>{j({title:"Notebook name",onConfirm:async k=>{r.createFile(k,null,"notebook")}})},e[16]=j,e[17]=r,e[18]=P):P=e[18];let O=q(P),z;e[19]===u?z=e[20]:(z=()=>{var k;(k=n.current)==null||k.closeAll(),u({})},e[19]=u,e[20]=z);let L=q(z),V;e[21]!==c||e[22]!==m?(V=bt(c,m),e[21]=c,e[22]=m,e[23]=V):V=e[23];let U=V;if(w){let k;return e[24]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(ta,{size:"medium",centered:!0}),e[24]=k):k=e[24],k}if(v){let k;return e[25]===v?k=e[26]:(k=(0,a.jsx)(at,{error:v}),e[25]=v,e[26]=k),k}if(o){let k;e[27]===Symbol.for("react.memo_cache_sentinel")?(k=()=>g(null),e[27]=k):k=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=(0,a.jsx)(R,{onClick:k,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:(0,a.jsx)(We,{size:16})}),e[28]=I):I=e[28];let B;e[29]===o.name?B=e[30]:(B=(0,a.jsxs)("div",{className:"flex items-center pl-1 pr-3 shrink-0 border-b justify-between",children:[I,(0,a.jsx)("span",{className:"font-bold",children:o.name})]}),e[29]=o.name,e[30]=B);let te;e[31]!==o.path||e[32]!==r?(te=kt=>vt(kt,r.relativeFromRoot(o.path)),e[31]=o.path,e[32]=r,e[33]=te):te=e[33];let ae;e[34]!==o||e[35]!==te?(ae=(0,a.jsx)(M.Suspense,{children:(0,a.jsx)(Ka,{onOpenNotebook:te,file:o})}),e[34]=o,e[35]=te,e[36]=ae):ae=e[36];let he;return e[37]!==B||e[38]!==ae?(he=(0,a.jsxs)(a.Fragment,{children:[B,ae]}),e[37]=B,e[38]=ae,e[39]=he):he=e[39],he}let W;e[40]!==L||e[41]!==_||e[42]!==S||e[43]!==O||e[44]!==F||e[45]!==N||e[46]!==r?(W=(0,a.jsx)(os,{onRefresh:N,onHidden:F,onCreateFile:_,onCreateNotebook:O,onCreateFolder:S,onCollapseAll:L,tree:r}),e[40]=L,e[41]=_,e[42]=S,e[43]=O,e[44]=F,e[45]=N,e[46]=r,e[47]=W):W=e[47];let $=s-33,H,K,J;e[48]===r?(H=e[49],K=e[50],J=e[51]):(H=async k=>{let{ids:I}=k;for(let B of I)await r.delete(B)},K=async k=>{let{id:I,name:B}=k;await r.rename(I,B)},J=async k=>{let{dragIds:I,parentId:B}=k;await r.move(I,B)},e[48]=r,e[49]=H,e[50]=K,e[51]=J);let ce;e[52]===Symbol.for("react.memo_cache_sentinel")?(ce=k=>{let I=k[0];I&&(I.data.isDirectory||g(I.data))},e[52]=ce):ce=e[52];let Q;e[53]!==d||e[54]!==u||e[55]!==r?(Q=async k=>{if(await r.expand(k)){let I=d[k]??!1;u({...d,[k]:!I})}},e[53]=d,e[54]=u,e[55]=r,e[56]=Q):Q=e[56];let X;e[57]!==i||e[58]!==d||e[59]!==$||e[60]!==H||e[61]!==K||e[62]!==J||e[63]!==Q||e[64]!==U?(X=(0,a.jsx)(ga,{width:"100%",ref:n,height:$,className:"h-full",data:U,initialOpenState:d,openByDefault:!1,dndManager:i,renderCursor:xs,disableDrop:fs,onDelete:H,onRename:K,onMove:J,onSelect:ce,onToggle:Q,padding:15,rowHeight:30,indent:ls,overscanCount:1e3,disableMultiSelection:!0,children:hs}),e[57]=i,e[58]=d,e[59]=$,e[60]=H,e[61]=K,e[62]=J,e[63]=Q,e[64]=U,e[65]=X):X=e[65];let ee;e[66]!==X||e[67]!==r?(ee=(0,a.jsx)(yt,{value:r,children:X}),e[66]=X,e[67]=r,e[68]=ee):ee=e[68];let de;return e[69]!==W||e[70]!==ee?(de=(0,a.jsxs)(a.Fragment,{children:[W,ee]}),e[69]=W,e[70]=ee,e[71]=de):de=e[71],de};var ls=15,os=t=>{let e=(0,oe.c)(38),{onRefresh:s,onHidden:n,onCreateFile:i,onCreateNotebook:r,onCreateFolder:l,onCollapseAll:c}=t,p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={noDrag:!0,noDragEventsBubbling:!0},e[0]=p):p=e[0];let{getRootProps:o,getInputProps:g}=jt(p),m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(lt,{size:16}),e[1]=m):m=e[1];let f;e[2]===r?f=e[3]:(f=(0,a.jsx)(T,{content:"Add notebook",children:(0,a.jsx)(R,{"data-testid":"file-explorer-add-notebook-button",onClick:r,variant:"text",size:"xs",children:m})}),e[2]=r,e[3]=f);let j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)(Ze,{size:16}),e[4]=j):j=e[4];let d;e[5]===i?d=e[6]:(d=(0,a.jsx)(T,{content:"Add file",children:(0,a.jsx)(R,{"data-testid":"file-explorer-add-file-button",onClick:i,variant:"text",size:"xs",children:j})}),e[5]=i,e[6]=d);let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(ot,{size:16}),e[7]=u):u=e[7];let h;e[8]===l?h=e[9]:(h=(0,a.jsx)(T,{content:"Add folder",children:(0,a.jsx)(R,{"data-testid":"file-explorer-add-folder-button",onClick:l,variant:"text",size:"xs",children:u})}),e[8]=l,e[9]=h);let y;e[10]===o?y=e[11]:(y=o({}),e[10]=o,e[11]=y);let w,v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=Lt({variant:"text",size:"xs"}),w=(0,a.jsx)(ia,{size:16}),e[12]=w,e[13]=v):(w=e[12],v=e[13]);let b;e[14]===y?b=e[15]:(b=(0,a.jsx)(T,{content:"Upload file",children:(0,a.jsx)("button",{"data-testid":"file-explorer-upload-button",...y,className:v,children:w})}),e[14]=y,e[15]=b);let N;e[16]===g?N=e[17]:(N=g({}),e[16]=g,e[17]=N);let x;e[18]===N?x=e[19]:(x=(0,a.jsx)("input",{...N,type:"file"}),e[18]=N,e[19]=x);let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F=(0,a.jsx)(aa,{size:16}),e[20]=F):F=e[20];let D;e[21]===s?D=e[22]:(D=(0,a.jsx)(T,{content:"Refresh",children:(0,a.jsx)(R,{"data-testid":"file-explorer-refresh-button",onClick:s,variant:"text",size:"xs",children:F})}),e[21]=s,e[22]=D);let S;e[23]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)(Jt,{size:16}),e[23]=S):S=e[23];let C;e[24]===n?C=e[25]:(C=(0,a.jsx)(T,{content:"Toggle hidden files",children:(0,a.jsx)(R,{"data-testid":"file-explorer-hidden-files-button",onClick:n,variant:"text",size:"xs",children:S})}),e[24]=n,e[25]=C);let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=(0,a.jsx)(Ma,{size:16}),e[26]=_):_=e[26];let P;e[27]===c?P=e[28]:(P=(0,a.jsx)(T,{content:"Collapse all folders",children:(0,a.jsx)(R,{"data-testid":"file-explorer-collapse-button",onClick:c,variant:"text",size:"xs",children:_})}),e[27]=c,e[28]=P);let O;return e[29]!==b||e[30]!==x||e[31]!==D||e[32]!==C||e[33]!==P||e[34]!==f||e[35]!==d||e[36]!==h?(O=(0,a.jsxs)("div",{className:"flex items-center justify-end px-2 shrink-0 border-b",children:[f,d,h,b,x,D,C,P]}),e[29]=b,e[30]=x,e[31]=D,e[32]=C,e[33]=P,e[34]=f,e[35]=d,e[36]=h,e[37]=O):O=e[37],O},cs=t=>{let e=(0,oe.c)(9),{node:s,onOpenMarimoFile:n}=t,i;e[0]===s?i=e[1]:(i=c=>{s.data.isDirectory||(c.stopPropagation(),s.select())},e[0]=s,e[1]=i);let r;e[2]!==s.data.isMarimoFile||e[3]!==n?(r=s.data.isMarimoFile&&!pe()&&(0,a.jsxs)("span",{className:"shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:n,children:["open ",(0,a.jsx)(be,{className:"inline ml-1",size:12})]}),e[2]=s.data.isMarimoFile,e[3]=n,e[4]=r):r=e[4];let l;return e[5]!==s.data.name||e[6]!==i||e[7]!==r?(l=(0,a.jsxs)("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:i,children:[s.data.name,r]}),e[5]=s.data.name,e[6]=i,e[7]=r,e[8]=l):l=e[8],l},ds=t=>{let e=(0,oe.c)(10),{node:s}=t,n=(0,M.useRef)(null),i,r;e[0]===s.data.name?(i=e[1],r=e[2]):(i=()=>{var o,g;(o=n.current)==null||o.focus(),(g=n.current)==null||g.setSelectionRange(0,s.data.name.lastIndexOf("."))},r=[s.data.name],e[0]=s.data.name,e[1]=i,e[2]=r),(0,M.useEffect)(i,r);let l,c;e[3]===s?(l=e[4],c=e[5]):(l=()=>s.reset(),c=o=>{o.key==="Escape"&&s.reset(),o.key==="Enter"&&s.submit(o.currentTarget.value)},e[3]=s,e[4]=l,e[5]=c);let p;return e[6]!==s.data.name||e[7]!==l||e[8]!==c?(p=(0,a.jsx)("input",{ref:n,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:s.data.name,onClick:us,onBlur:l,onKeyDown:c}),e[6]=s.data.name,e[7]=l,e[8]=c,e[9]=p):p=e[9],p},hs=({node:t,style:e,dragHandle:s})=>{let{openFile:n,sendCreateFileOrFolder:i,sendFileDetails:r}=ge(),l=ne(Be),c=t.data.isDirectory?"directory":Xt(t.data.name),p=ea[c],{openConfirm:o,openPrompt:g}=tt(),{createNewCell:m}=Dt(),f=Na(),j=x=>{m({code:x,before:!1,cellId:f??"__end__"})},d=(0,M.use)(yt),u=async x=>{vt(x,d?d.relativeFromRoot(t.data.path):t.data.path)},h=async x=>{x.stopPropagation(),x.preventDefault(),o({title:"Delete file",description:`Are you sure you want to delete ${t.data.name}?`,confirmAction:(0,a.jsx)(ca,{onClick:async()=>{await t.tree.delete(t.id)},"aria-label":"Confirm",children:"Delete"})})},y=q(async()=>{t.open(),g({title:"Folder name",onConfirm:async x=>{d==null||d.createFolder(x,t.id)}})}),w=q(async()=>{t.open(),g({title:"File name",onConfirm:async x=>{d==null||d.createFile(x,t.id)}})}),v=q(async()=>{t.open(),g({title:"Notebook name",onConfirm:async x=>{d==null||d.createFile(x,t.id,"notebook")}})}),b=q(async()=>{var S;if(!d||t.data.isDirectory)return;let[x,F]=la(t.data.name),D=`${x}_copy${F}`;try{let C=await r({path:t.data.path}),_=((S=t.parent)==null?void 0:S.data.path)||"";await i({path:_,type:"file",name:D,contents:C.contents?btoa(C.contents):void 0}),await d.refreshAll([_])}catch{E({title:"Failed to duplicate file",description:"Unable to create a duplicate of the file",variant:"danger"})}}),N=()=>{let x={size:14,strokeWidth:1.5,className:"mr-2"};return(0,a.jsxs)(Ke,{align:"end",className:"print:hidden w-[220px]",onClick:F=>F.stopPropagation(),onCloseAutoFocus:F=>F.preventDefault(),children:[!t.data.isDirectory&&(0,a.jsxs)(A,{onSelect:()=>t.select(),children:[(0,a.jsx)(dt,{...x}),"Open file"]}),!t.data.isDirectory&&!pe()&&(0,a.jsxs)(A,{onSelect:()=>{n({path:t.data.path})},children:[(0,a.jsx)(be,{...x}),"Open file in external editor"]}),t.data.isDirectory&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(A,{onSelect:()=>v(),children:[(0,a.jsx)(lt,{...x}),"Create notebook"]}),(0,a.jsxs)(A,{onSelect:()=>w(),children:[(0,a.jsx)(Ze,{...x}),"Create file"]}),(0,a.jsxs)(A,{onSelect:()=>y(),children:[(0,a.jsx)(ot,{...x}),"Create folder"]}),(0,a.jsx)(ie,{})]}),(0,a.jsxs)(A,{onSelect:()=>t.edit(),children:[(0,a.jsx)(Oa,{...x}),"Rename"]}),!t.data.isDirectory&&(0,a.jsxs)(A,{onSelect:b,children:[(0,a.jsx)(we,{...x}),"Duplicate"]}),(0,a.jsxs)(A,{onSelect:async()=>{await le(t.data.path),E({title:"Copied to clipboard"})},children:[(0,a.jsx)(ct,{...x}),"Copy path"]}),d&&(0,a.jsxs)(A,{onSelect:async()=>{await le(d.relativeFromRoot(t.data.path)),E({title:"Copied to clipboard"})},children:[(0,a.jsx)(ct,{...x}),"Copy relative path"]}),(0,a.jsx)(ie,{}),(0,a.jsxs)(A,{onSelect:()=>{let{path:F}=t.data;j(Qe[c](F))},children:[(0,a.jsx)($t,{...x}),"Insert snippet for reading file"]}),(0,a.jsxs)(A,{onSelect:async()=>{E({title:"Copied to clipboard",description:"Code to open the file has been copied to your clipboard. You can also drag and drop this file into the editor"});let{path:F}=t.data;await le(Qe[c](F))},children:[(0,a.jsx)(Mt,{...x}),"Copy snippet for reading file"]}),t.data.isMarimoFile&&!pe()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ie,{}),(0,a.jsxs)(A,{onSelect:u,children:[(0,a.jsx)(Ra,{...x}),"Open notebook"]})]}),(0,a.jsx)(ie,{}),!t.data.isDirectory&&!l&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(A,{onSelect:async()=>{let F=(await r({path:t.data.path})).contents||"";$e(new Blob([F]),t.data.name)},children:[(0,a.jsx)(Ne,{...x}),"Download"]}),(0,a.jsx)(ie,{})]}),(0,a.jsxs)(A,{onSelect:h,variant:"danger",children:[(0,a.jsx)(ra,{...x}),"Delete"]})]})};return(0,a.jsxs)("div",{style:e,ref:s,className:Y("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),draggable:!0,onClick:x=>{x.stopPropagation(),t.data.isDirectory&&t.toggle()},children:[(0,a.jsx)(ms,{node:t}),(0,a.jsxs)("span",{className:Y("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",t.willReceiveDrop&&t.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground"),children:[t.data.isMarimoFile?(0,a.jsx)(Da,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}):(0,a.jsx)(p,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}),t.isEditing?(0,a.jsx)(ds,{node:t}):(0,a.jsx)(cs,{node:t,onOpenMarimoFile:u}),(0,a.jsxs)(Ge,{modal:!1,children:[(0,a.jsx)(qe,{asChild:!0,tabIndex:-1,onClick:x=>x.stopPropagation(),children:(0,a.jsx)(R,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:(0,a.jsx)(Ye,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),N()]})]})]})},ms=t=>{let e=(0,oe.c)(3),{node:s}=t;if(!s.data.isDirectory){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)("span",{className:"w-5 h-5 shrink-0"}),e[0]=i):i=e[0],i}let n;return e[1]===s.isOpen?n=e[2]:(n=s.isOpen?(0,a.jsx)(qt,{className:"w-5 h-5 shrink-0"}):(0,a.jsx)(ve,{className:"w-5 h-5 shrink-0"}),e[1]=s.isOpen,e[2]=n),n};function vt(t,e){t.stopPropagation(),t.preventDefault(),za(e)}function bt(t,e){if(e)return t;let s=[];for(let n of t){if(ps(n.name))continue;let i=n;if(n.children){let r=bt(n.children,e);r!==n.children&&(i={...n,children:r})}s.push(i)}return s}function ps(t){return!!t.startsWith(".")}function xs(){return null}function fs(t){let{parentNode:e}=t;return!e.data.isDirectory}function us(t){return t.stopPropagation()}var wt=se(),gs=Ie("marimo:file-explorer-panel:state",{openSections:["files"],hasUserInteracted:!1},Ae),Nt=t=>{let e=(0,wt.c)(20),{height:s}=t,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={noClick:!0,noKeyboard:!0},e[0]=n):n=e[0];let{getRootProps:i,getInputProps:r,isDragActive:l}=jt(n),c;e[1]===i?c=e[2]:(c=i(),e[1]=i,e[2]=c);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=Y("flex flex-col overflow-hidden relative"),e[3]=p):p=e[3];let o;e[4]===s?o=e[5]:(o={height:s},e[4]=s,e[5]=o);let g;e[6]===r?g=e[7]:(g=r(),e[6]=r,e[7]=g);let m;e[8]===g?m=e[9]:(m=(0,a.jsx)("input",{...g}),e[8]=g,e[9]=m);let f;e[10]===l?f=e[11]:(f=l&&(0,a.jsx)("div",{className:"absolute inset-0 flex items-center uppercase justify-center text-xl font-bold text-primary/90 bg-accent/85 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none",children:"Drop files here"}),e[10]=l,e[11]=f);let j;e[12]===s?j=e[13]:(j=(0,a.jsx)(is,{height:s}),e[12]=s,e[13]=j);let d;return e[14]!==c||e[15]!==o||e[16]!==m||e[17]!==f||e[18]!==j?(d=(0,a.jsx)(qa,{children:(0,a.jsxs)("div",{...c,className:p,style:o,children:[m,f,j]})}),e[14]=c,e[15]=o,e[16]=m,e[17]=f,e[18]=j,e[19]=d):d=e[19],d},js=33,ys=()=>{let t=(0,wt.c)(41),{ref:e,height:s}=Fa(),n=s===void 0?500:s,[i,r]=me(gs),l=ne(Wt).length,c;e:{if(!i.hasUserInteracted&&l>0){if(i.openSections.includes("remote-storage")){c=i.openSections;break e}let z;t[0]===i.openSections?z=t[1]:(z=[...i.openSections,"remote-storage"],t[0]=i.openSections,t[1]=z),c=z;break e}c=i.openSections}let p=c,o;t[2]===r?o=t[3]:(o=z=>{r({openSections:z,hasUserInteracted:!0})},t[2]=r,t[3]=o);let g=o,m=n-js*2,f;t[4]===p?f=t[5]:(f=p.includes("remote-storage"),t[4]=p,t[5]=f);let j=f,d;t[6]!==p||t[7]!==j?(d=j&&p.includes("files"),t[6]=p,t[7]=j,t[8]=d):d=t[8];let u=d,h;t[9]!==m||t[10]!==u?(h=u?Math.round(m*.4):m,t[9]=m,t[10]=u,t[11]=h):h=t[11];let y=h,w=Math.max(200,u?m-y:m);if(!Pt("storage_inspector")){let z;t[12]===n?z=t[13]:(z=(0,a.jsx)(Nt,{height:n}),t[12]=n,t[13]=z);let L;return t[14]!==e||t[15]!==z?(L=(0,a.jsx)("div",{ref:e,className:"h-full overflow-auto",children:z}),t[14]=e,t[15]=z,t[16]=L):L=t[16],L}let v;t[17]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsx)(Te,{className:"w-4 h-4"}),t[17]=v):v=t[17];let b;t[18]===l?b=t[19]:(b=l>0&&(0,a.jsx)(Pa,{children:l}),t[18]=l,t[19]=b);let N;t[20]===b?N=t[21]:(N=(0,a.jsxs)(nt,{children:[v," Remote storage",b]}),t[20]=b,t[21]=N);let x;t[22]===y?x=t[23]:(x={maxHeight:y},t[22]=y,t[23]=x);let F;t[24]===Symbol.for("react.memo_cache_sentinel")?(F=(0,a.jsx)(Ua,{}),t[24]=F):F=t[24];let D;t[25]===x?D=t[26]:(D=(0,a.jsx)(it,{className:"overflow-auto",style:x,children:F}),t[25]=x,t[26]=D);let S;t[27]!==D||t[28]!==N?(S=(0,a.jsxs)(rt,{value:"remote-storage",children:[N,D]}),t[27]=D,t[28]=N,t[29]=S):S=t[29];let C;t[30]===Symbol.for("react.memo_cache_sentinel")?(C=(0,a.jsxs)(nt,{children:[(0,a.jsx)(Je,{className:"w-4 h-4"}),"Files"]}),t[30]=C):C=t[30];let _;t[31]===w?_=t[32]:(_=(0,a.jsxs)(rt,{value:"files",children:[C,(0,a.jsx)(it,{children:(0,a.jsx)(Nt,{height:w})})]}),t[31]=w,t[32]=_);let P;t[33]!==g||t[34]!==p||t[35]!==S||t[36]!==_?(P=(0,a.jsxs)(pa,{type:"multiple",value:p,onValueChange:g,children:[S,_]}),t[33]=g,t[34]=p,t[35]=S,t[36]=_,t[37]=P):P=t[37];let O;return t[38]!==e||t[39]!==P?(O=(0,a.jsx)("div",{ref:e,className:"h-full overflow-auto",children:P}),t[38]=e,t[39]=P,t[40]=O):O=t[40],O};export{ys as default};
@@ -1 +1 @@
1
- var O=Object.defineProperty;var V=(t,e,i)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var b=(t,e,i)=>V(t,typeof e!="symbol"?e+"":e,i);import{u as I}from"./useEvent-WUlsM6MC.js";import{o as j}from"./cells-CCtxWKxf.js";import{t as T}from"./compiler-runtime-B3qBwwSJ.js";import{c as k,m as E}from"./useEventListener-CjXriKgk.js";import{i as N}from"./utils-CORJ8yYa.js";import{h as P,x as _}from"./config-D9X9QKiL.js";import{r as z}from"./requests-DZy_SQ_v.js";import{f as D}from"./layout-DnAy5Tn0.js";import{s as $,u as B}from"./download-BTm4CTKr.js";import{t as H}from"./Deferred-D2igisxY.js";import{t as L}from"./use-toast-BhMe50aT.js";import{t as x}from"./useInterval-lamrIyKJ.js";var R=class{constructor(){b(this,"capturedInputs",new Map);b(this,"inFlight",new Map)}cancelEntry(t){t.controller.abort(),t.deferred.status==="pending"&&t.deferred.resolve(void 0)}needsCapture(t,e){if(this.capturedInputs.get(t)===e)return!1;let i=this.inFlight.get(t);return!(i&&i.inputValue===e)}waitForInFlight(t,e){let i=this.inFlight.get(t);return i&&i.inputValue===e?i.deferred.promise:null}startCapture(t,e){let i=this.inFlight.get(t);i&&this.cancelEntry(i);let n=new AbortController,l=new H,u={controller:n,inputValue:e,deferred:l};return this.inFlight.set(t,u),{signal:n.signal,markCaptured:p=>{this.inFlight.get(t)===u&&(l.resolve(p),this.capturedInputs.set(t,e),this.inFlight.delete(t))},markFailed:()=>{this.inFlight.get(t)===u&&(l.resolve(void 0),this.inFlight.delete(t))}}}prune(t){for(let e of this.capturedInputs.keys())t.has(e)||this.capturedInputs.delete(e);for(let[e,i]of this.inFlight)t.has(e)||(this.cancelEntry(i),this.inFlight.delete(e))}get isCapturing(){return this.inFlight.size>0}abort(){for(let t of this.inFlight.values())this.cancelEntry(t);this.inFlight.clear()}reset(){this.abort(),this.capturedInputs.clear()}},Y=T(),M=5e3;function q(){let t=(0,Y.c)(14),e=I(N),{state:i}=I(P),n=e.auto_download.includes("markdown"),l=e.auto_download.includes("html"),u=e.auto_download.includes("ipynb"),p=i===_.OPEN,m=!n||!p,d=!l||!p,h=!u||!p,{autoExportAsHTML:a,autoExportAsIPYNB:s,autoExportAsMarkdown:r,updateCellOutputs:o}=z(),c=S(),f;t[0]===r?f=t[1]:(f=async()=>{await r({download:!1})},t[0]=r,t[1]=f);let g;t[2]===m?g=t[3]:(g={delayMs:M,whenVisible:!0,disabled:m},t[2]=m,t[3]=g),x(f,g);let w;t[4]===a?w=t[5]:(w=async()=>{await a({download:!1,includeCode:!0,files:D.INSTANCE.filenames()})},t[4]=a,t[5]=w);let v;t[6]===d?v=t[7]:(v={delayMs:M,whenVisible:!0,disabled:d},t[6]=d,t[7]=v),x(w,v);let F;t[8]!==s||t[9]!==c||t[10]!==o?(F=async()=>{await A({takeScreenshots:()=>c({progress:B.indeterminate()}),updateCellOutputs:o}),await s({download:!1})},t[8]=s,t[9]=c,t[10]=o,t[11]=F):F=t[11];let y;t[12]===h?y=t[13]:(y={delayMs:M,whenVisible:!0,disabled:h,skipIfRunning:!0},t[12]=h,t[13]=y),x(F,y)}var G=new Set(["text/html","application/vnd.vegalite.v5+json","application/vnd.vega.v5+json","application/vnd.vegalite.v6+json","application/vnd.vega.v6+json"]);const C=new R;function S(){let t=I(j);return async e=>{var d,h;let{progress:i}=e,n=new Set(k.keys(t));C.prune(n);let l=[],u=[];for(let[a,s]of k.entries(t)){let r=(d=s.output)==null?void 0:d.data;if((h=s.output)!=null&&h.mimetype&&G.has(s.output.mimetype)&&r)if(C.needsCapture(a,r))l.push([a,r]);else{let o=C.waitForInFlight(a,r);o&&u.push({cellId:a,promise:o})}}if(l.length===0&&u.length===0)return{};l.length>0&&i.addTotal(l.length);let p={};for(let[a,s]of l){let r=C.startCapture(a,s);try{let o=await $(a);if(r.signal.aborted)continue;if(!o){E.error(`Failed to capture screenshot for cell ${a}`),r.markFailed();continue}let c=["image/png",o];p[a]=c,r.markCaptured(c)}catch(o){E.error(`Error screenshotting cell ${a}:`,o),r.markFailed()}finally{i.increment(1)}}let m=await Promise.allSettled(u.map(({promise:a})=>a));for(let[a,{cellId:s}]of u.entries()){let r=m[a];r.status==="fulfilled"&&r.value&&(p[s]=r.value)}return p}}async function A(t){let{takeScreenshots:e,updateCellOutputs:i}=t;try{let n=await e();k.size(n)>0&&await i({cellIdsToOutput:n})}catch(n){E.error("Error updating cell outputs with screenshots:",n),L({title:"Failed to capture cell outputs",description:"Some outputs may not appear in the PDF. Continuing with export.",variant:"danger"})}}export{q as n,S as r,A as t};
1
+ var O=Object.defineProperty;var V=(t,e,i)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var b=(t,e,i)=>V(t,typeof e!="symbol"?e+"":e,i);import{u as I}from"./useEvent-WUlsM6MC.js";import{o as j}from"./cells-CCtxWKxf.js";import{t as T}from"./compiler-runtime-B3qBwwSJ.js";import{c as k,m as E}from"./useEventListener-CjXriKgk.js";import{i as N}from"./utils-CORJ8yYa.js";import{h as P,x as _}from"./config-D9X9QKiL.js";import{r as z}from"./requests-DZy_SQ_v.js";import{f as D}from"./layout-DVAA7kHH.js";import{s as $,u as B}from"./download-BTm4CTKr.js";import{t as H}from"./Deferred-D2igisxY.js";import{t as L}from"./use-toast-BhMe50aT.js";import{t as x}from"./useInterval-lamrIyKJ.js";var R=class{constructor(){b(this,"capturedInputs",new Map);b(this,"inFlight",new Map)}cancelEntry(t){t.controller.abort(),t.deferred.status==="pending"&&t.deferred.resolve(void 0)}needsCapture(t,e){if(this.capturedInputs.get(t)===e)return!1;let i=this.inFlight.get(t);return!(i&&i.inputValue===e)}waitForInFlight(t,e){let i=this.inFlight.get(t);return i&&i.inputValue===e?i.deferred.promise:null}startCapture(t,e){let i=this.inFlight.get(t);i&&this.cancelEntry(i);let n=new AbortController,l=new H,u={controller:n,inputValue:e,deferred:l};return this.inFlight.set(t,u),{signal:n.signal,markCaptured:p=>{this.inFlight.get(t)===u&&(l.resolve(p),this.capturedInputs.set(t,e),this.inFlight.delete(t))},markFailed:()=>{this.inFlight.get(t)===u&&(l.resolve(void 0),this.inFlight.delete(t))}}}prune(t){for(let e of this.capturedInputs.keys())t.has(e)||this.capturedInputs.delete(e);for(let[e,i]of this.inFlight)t.has(e)||(this.cancelEntry(i),this.inFlight.delete(e))}get isCapturing(){return this.inFlight.size>0}abort(){for(let t of this.inFlight.values())this.cancelEntry(t);this.inFlight.clear()}reset(){this.abort(),this.capturedInputs.clear()}},Y=T(),M=5e3;function q(){let t=(0,Y.c)(14),e=I(N),{state:i}=I(P),n=e.auto_download.includes("markdown"),l=e.auto_download.includes("html"),u=e.auto_download.includes("ipynb"),p=i===_.OPEN,m=!n||!p,d=!l||!p,h=!u||!p,{autoExportAsHTML:a,autoExportAsIPYNB:s,autoExportAsMarkdown:r,updateCellOutputs:o}=z(),c=S(),f;t[0]===r?f=t[1]:(f=async()=>{await r({download:!1})},t[0]=r,t[1]=f);let g;t[2]===m?g=t[3]:(g={delayMs:M,whenVisible:!0,disabled:m},t[2]=m,t[3]=g),x(f,g);let w;t[4]===a?w=t[5]:(w=async()=>{await a({download:!1,includeCode:!0,files:D.INSTANCE.filenames()})},t[4]=a,t[5]=w);let v;t[6]===d?v=t[7]:(v={delayMs:M,whenVisible:!0,disabled:d},t[6]=d,t[7]=v),x(w,v);let F;t[8]!==s||t[9]!==c||t[10]!==o?(F=async()=>{await A({takeScreenshots:()=>c({progress:B.indeterminate()}),updateCellOutputs:o}),await s({download:!1})},t[8]=s,t[9]=c,t[10]=o,t[11]=F):F=t[11];let y;t[12]===h?y=t[13]:(y={delayMs:M,whenVisible:!0,disabled:h,skipIfRunning:!0},t[12]=h,t[13]=y),x(F,y)}var G=new Set(["text/html","application/vnd.vegalite.v5+json","application/vnd.vega.v5+json","application/vnd.vegalite.v6+json","application/vnd.vega.v6+json"]);const C=new R;function S(){let t=I(j);return async e=>{var d,h;let{progress:i}=e,n=new Set(k.keys(t));C.prune(n);let l=[],u=[];for(let[a,s]of k.entries(t)){let r=(d=s.output)==null?void 0:d.data;if((h=s.output)!=null&&h.mimetype&&G.has(s.output.mimetype)&&r)if(C.needsCapture(a,r))l.push([a,r]);else{let o=C.waitForInFlight(a,r);o&&u.push({cellId:a,promise:o})}}if(l.length===0&&u.length===0)return{};l.length>0&&i.addTotal(l.length);let p={};for(let[a,s]of l){let r=C.startCapture(a,s);try{let o=await $(a);if(r.signal.aborted)continue;if(!o){E.error(`Failed to capture screenshot for cell ${a}`),r.markFailed();continue}let c=["image/png",o];p[a]=c,r.markCaptured(c)}catch(o){E.error(`Error screenshotting cell ${a}:`,o),r.markFailed()}finally{i.increment(1)}}let m=await Promise.allSettled(u.map(({promise:a})=>a));for(let[a,{cellId:s}]of u.entries()){let r=m[a];r.status==="fulfilled"&&r.value&&(p[s]=r.value)}return p}}async function A(t){let{takeScreenshots:e,updateCellOutputs:i}=t;try{let n=await e();k.size(n)>0&&await i({cellIdsToOutput:n})}catch(n){E.error("Error updating cell outputs with screenshots:",n),L({title:"Failed to capture cell outputs",description:"Some outputs may not appear in the PDF. Continuing with export.",variant:"danger"})}}export{q as n,S as r,A as t};