@marimo-team/frontend 0.23.10-dev17 → 0.23.10-dev18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{edit-page-i8CUVb2_.js → edit-page-CGx2DFyl.js} +2 -2
- package/dist/assets/file-explorer-panel-CMO-xFNA.js +26 -0
- package/dist/assets/{index-BXAJ4fJT.js → index-wzbuxKZH.js} +2 -2
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/editor/file-tree/tree-actions.tsx +0 -2
- package/src/components/storage/__tests__/storage-inspector.test.ts +1 -3
- package/src/components/storage/storage-inspector.tsx +18 -24
- package/dist/assets/file-explorer-panel-ndSjEMW1.js +0 -26
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import{s as qe}from"./chunk-LvLJmgfZ.js";import{i as Vt,l as ke,n as ee,p as Ue,u as ye}from"./useEvent-D91BmmQi.js";import{t as Et}from"./react-Bj1aDYRI.js";import{D as Rt,Fn as We,Oi as Ke,wi as At,wr as Bt}from"./cells-FW8WlzJY.js";import"./react-dom-CSu739Rf.js";import{t as fe}from"./compiler-runtime-B3qBwwSJ.js";import{_ as De}from"./useEventListener-DvoEXWke.js";import{t as Ht}from"./invariant-BUdrueMv.js";import{f as Ge,h as Lt}from"./utils-CvI-39U6.js";import{T as Fe}from"./config-DH1Le_e1.js";import{t as ie}from"./cn-DCUzRj2J.js";import{t as qt}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-eipL3i3Y.js";import{n as Ut}from"./multi-map-CUuNtzHt.js";import{o as Wt}from"./alert-dialog-BqFLkbUc.js";import"./popover-Bz_0Vkyf.js";import{a as E,c as ue,p as Kt,r as Gt,t as Jt}from"./dropdown-menu-CR7cnzLX.js";import{a as Yt,i as Je,o as _e,wt as Me}from"./JsonOutput-Df7Vt26h.js";import{c as Zt,i as Pe,r as Se}from"./download-4dvb0Tm7.js";import{r as Ye}from"./radio-group-BMlG1iLU.js";import{t as R}from"./tooltip-DTV9tlSr.js";import{n as Qt,t as V}from"./button-BbCh-29a.js";import{St as Xt}from"./dist-BrR4M-k3.js";import"./cjs-BRGiG41H.js";import"./main-B0OX4z33.js";import"./useNonce-DfoVjkkH.js";import{n as ea,r as ze}from"./requests-DIwGYs0l.js";import{t as ne}from"./createLucideIcon-D5guW7EU.js";import{a as Ze,c as Qe,i as Xe,n as Ce,o as Te,r as ta,t as aa}from"./state-CcAGAozT.js";import{n as ra}from"./LazyAnyLanguageCodeMirror-kGFT2d8V.js";import{t as na}from"./x-C-6liIBr.js";import{n as Oe}from"./markdown-renderer-B2dVZ8Vp.js";import{u as sa}from"./toDate-B5A0DFEz.js";import{t as et}from"./copy-BwrPA9zQ.js";import{t as $e}from"./external-link-BTNxSavU.js";import{a as la,i as tt,n as at,r as oa,t as ia}from"./file-icons-QWprdVWf.js";import{t as rt}from"./file-HTLbeC2b.js";import{i as nt,r as ca,t as st}from"./add-connection-dialog-DV3vbtpl.js";import{n as Ie,t as da}from"./spinner-UuZAUjoP.js";import{a as ma,c as pa,d as ha,f as xa,i as fa,l as ua,n as ya,r as ja,t as ga,u as ba}from"./file-name-input-4pvJeVQK.js";import{t as lt}from"./plus-CxkHs8QM.js";import{t as ot}from"./refresh-cw-a_9k9BK7.js";import{t as va}from"./save-DZ5aail6.js";import{t as wa}from"./triangle-alert-CJ0ZIqcz.js";import{n as Na,t as ka}from"./es-au8YY-8E.js";import"./dist-DCqxOggh.js";import"./dist-BZr6MMV-.js";import"./dist-BU26XwgJ.js";import"./dist-COs9gIu5.js";import"./dist-DkA__6UI.js";import{t as te}from"./use-toast-9t59MOqR.js";import{t as Fa}from"./paths-SFhaqGlE.js";import"./session-DGdfs0bJ.js";import"./purify.es-DvRMX74T.js";import"./dates-DS_7IZoI.js";import{n as je}from"./copy-Ch48HVPK.js";import{t as _a}from"./copy-icon-z0dzhmL4.js";import{t as it}from"./context-C1Tm_47t.js";import{n as ct}from"./ImperativeModal-BeQmePpG.js";import{t as dt}from"./blob-3_FN0u9S.js";import"./utils-DQRuLEof.js";import"./vega-loader.browser-xq8miGHn.js";import"./defaultLocale-DPBdGRrH.js";import"./defaultLocale-Lfi0pexn.js";import{n as Sa,t as Ca}from"./alert-DrHguQlr.js";import{n as mt}from"./error-banner-CLO6LFll.js";import"./chunk-5FQGJX7Z-WmZDj8ty.js";import"./html-to-image-C5f8yFhw.js";import{o as Da}from"./focus-9N2kMkkO.js";import{n as Ve}from"./useAsyncData-Dg8E_bPh.js";import"./react-resizable-panels.browser.esm-BdtIs0E-.js";import{a as Ma,d as Pa,o as pt,t as za}from"./command-DUeag2QH.js";import{a as Ta}from"./renderShortcut-BTgMpqTK.js";import{t as Oa}from"./bundle.esm-BXIlAZ6T.js";import{a as $a,i as Ee,n as Ia,r as ht,t as ge}from"./tree-actions-B5athjIm.js";import{a as Va}from"./components-CtK6Njp_.js";import{n as Ea}from"./pathUtils-vgBYIo5B.js";import{n as Ra}from"./semaphore-X3ApuO41.js";import{t as Aa}from"./empty-state-CcobJSnG.js";import{t as Re}from"./formatting-BGBHA0kw.js";import{a as Ba,i as Ha,n as xt,r as ft,t as ut}from"./components-BqAv4KRy.js";import{n as yt,t as La}from"./marimo-icons-BmEL8W-Z.js";import{t as qa}from"./links-C-_seirg.js";var Ua=ne("book-plus",[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]),Wa=ne("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"}]]),jt=ne("file-plus-corner",[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]]),Ka=ne("file-symlink",[["path",{d:"M4 11V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"huwfnr"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m10 18 3-3-3-3",key:"18f6ys"}]]),gt=ne("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"}]]),bt=ne("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"}]]),Ga=ne("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"}]]),vt=ne("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"}]]),O=qe(Et(),1),Ja=fe(),a=qe(qt(),1);const wt=t=>{let e=(0,Ja.c)(17),{filename:r,filenameIcon:o,onBack:i,onRefresh:n,onDownload:m,actions:c}=t,x;e[0]===i?x=e[1]:(x=i&&(0,a.jsx)(R,{content:"Back to file list",children:(0,a.jsx)(V,{variant:"text",size:"xs",onClick:i,children:(0,a.jsx)(Qe,{className:"h-4 w-4"})})}),e[0]=i,e[1]=x);let s;e[2]!==r||e[3]!==o?(s=r?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate",children:[o,r]}):(0,a.jsx)("span",{className:"flex-1"}),e[2]=r,e[3]=o,e[4]=s):s=e[4];let f;e[5]===n?f=e[6]:(f=n&&(0,a.jsx)(R,{content:"Refresh",children:(0,a.jsx)(V,{variant:"text",size:"xs",onClick:n,children:(0,a.jsx)(ot,{className:"h-3.5 w-3.5"})})}),e[5]=n,e[6]=f);let h;e[7]===m?h=e[8]:(h=m&&(0,a.jsx)(R,{content:"Download",children:(0,a.jsx)(V,{variant:"text",size:"xs",onClick:m,children:(0,a.jsx)(Me,{className:"h-3.5 w-3.5"})})}),e[7]=m,e[8]=h);let p;e[9]!==c||e[10]!==f||e[11]!==h?(p=(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[f,c,h]}),e[9]=c,e[10]=f,e[11]=h,e[12]=p):p=e[12];let g;return e[13]!==x||e[14]!==s||e[15]!==p?(g=(0,a.jsxs)("div",{className:"flex items-center shrink-0 border-b px-1 gap-1",children:[x,s,p]}),e[13]=x,e[14]=s,e[15]=p,e[16]=g):g=e[16],g};var Ya=new Set(["http","file","in-memory"]);function Ae(t){return JSON.stringify(t).slice(1,-1)}const Nt=[{id:"read-file",label:"Insert read snippet",icon:Ua,getCode:t=>{if(t.entry.kind==="directory")return null;let e=Ae(t.entry.path);return t.backendType==="obstore"?`_data = ${t.variableName}.get("${e}").bytes()
|
|
2
|
+
_data`:`_data = ${t.variableName}.cat_file("${e}")
|
|
3
|
+
_data`}},{id:"download-file",label:"Insert download snippet",icon:Ka,getCode:t=>{if(t.entry.kind==="directory")return null;let e=Ae(t.entry.path);if(t.backendType==="obstore")return Ya.has(t.protocol)?null:`from datetime import timedelta
|
|
4
|
+
from obstore import sign
|
|
5
|
+
|
|
6
|
+
signed_url = sign(
|
|
7
|
+
${t.variableName}, "GET", "${e}",
|
|
8
|
+
expires_in=timedelta(hours=1),
|
|
9
|
+
)
|
|
10
|
+
signed_url`;let r=Ae(t.entry.path.split("/").pop()||"download");return`${t.variableName}.get("${e}", "${r}")`}}];var Za=100*1024*1024;function Qa(t){let e=t.endsWith("/")?t.slice(0,-1):t,r=e.split("/");return r[r.length-1]||e}const Xa=({entry:t,namespace:e,protocol:r,backendType:o,onBack:i})=>{let{locale:n}=it(),m=Ye(),c=Qa(t.path),x=t.mimeType||"text/plain",s=_e(x),f=s&&t.size>Za&&t.size>0,{data:h,isPending:p,error:g,refetch:y}=Ve(async()=>{if(f)return null;let d=await Te.request({namespace:e,path:t.path,preview:!s});if(d.error)throw Error(d.error);if(!d.url)throw Error("No URL returned");if(s)return{type:"media",url:d.url};let b=await fetch(d.url);if(!b.ok)throw Error(`Failed to fetch preview: ${b.statusText}`);return{type:"text",content:await b.text()}},[e,t.path,s,f]),w=(0,O.useCallback)(async()=>{try{let d=await Te.request({namespace:e,path:t.path});if(d.error){te({title:"Download failed",description:d.error,variant:"danger"});return}d.url&&Pe(d.url,d.filename??c)}catch(d){De.error("Failed to download storage entry",d),te({title:"Download failed",description:String(d),variant:"danger"})}},[e,t.path,c]),v=Nt.map(d=>{let b=d.getCode({variableName:e,protocol:r,entry:t,backendType:o});if(b===null)return null;let N=d.icon;return(0,a.jsx)(R,{content:d.label,children:(0,a.jsx)(V,{variant:"text",size:"xs",onClick:()=>m(b),"aria-label":d.label,children:(0,a.jsx)(N,{className:"h-3.5 w-3.5"})})},d.id)}),l=(0,a.jsx)(wt,{filename:c,filenameIcon:tt(c),onBack:i,onDownload:w,actions:v}),j=({includeMime:d=!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)(_a,{value:t.path,className:"h-3 w-3"})]}),d&&(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Type"}),d&&(0,a.jsx)("span",{children:x}),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:Re(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 f?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[l,j({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-muted-foreground italic",children:["File is too large to preview (",Re(t.size,n),")."]})]}):p?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[l,j({}),(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)(Ie,{className:"h-4 w-4 animate-spin"}),"Loading preview..."]})]}):g?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[l,j({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)(V,{variant:"secondary",size:"xs",onClick:y,children:[(0,a.jsx)(ot,{className:"h-3 w-3 mr-1"}),"Retry"]})})]}):h?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[l,j({}),(0,a.jsx)(Je,{mimeType:x,contents:h.type==="text"?h.content:void 0,mediaSource:h.type==="media"?{url:h.url}:void 0})]}):(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[l,j({includeMime:!0}),(0,a.jsxs)("div",{className:"p-4 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(rt,{className:"h-4 w-4"}),"Preview not available for this file type."]})]})};var Be=fe(),er=16;function se(t){return{paddingLeft:t*er}}function tr(t,e){return new Date(t*1e3).toLocaleDateString(e,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function kt(t){let e=t.endsWith("/")?t.slice(0,-1):t,r=e.split("/");return r[r.length-1]||e}function Ft(t,e){var o;let r=(o=t.metadata)==null?void 0:o.id;return typeof r=="string"&&r.length>0?r:`${t.path}::${e}`}function He(t,{namespace:e,searchValue:r,entriesByPath:o}){let i=r.toLowerCase();if(kt(t.path).toLowerCase().includes(i))return!0;if(t.kind==="directory"){let n=o.get(Ze(e,t.path));if(n)return n.some(m=>He(m,{namespace:e,searchValue:r,entriesByPath:o}))}return!1}function _t(t,e){return e.searchValue.trim()?t.filter(r=>He(r,e)):t}var ar=t=>{let e=(0,Be.c)(37),{namespace:r,protocol:o,rootPath:i,backendType:n,prefix:m,depth:c,locale:x,searchValue:s,onOpenFile:f}=t,{entriesByPath:h}=Ce(),{entries:p,isPending:g,error:y}=Xe(r,m);if(g){let l;e[0]===c?l=e[1]:(l=se(c),e[0]=c,e[1]=l);let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)(Ie,{className:"h-3 w-3 animate-spin"}),e[2]=j):j=e[2];let d;return e[3]===l?d=e[4]:(d=(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:l,children:[j,"Loading..."]}),e[3]=l,e[4]=d),d}if(y){let l;e[5]===c?l=e[6]:(l=se(c),e[5]=c,e[6]=l);let j;return e[7]!==y.message||e[8]!==l?(j=(0,a.jsxs)("div",{className:"py-1 text-xs text-destructive",style:l,children:["Failed to load: ",y.message]}),e[7]=y.message,e[8]=l,e[9]=j):j=e[9],j}if(p.length===0){let l;e[10]===c?l=e[11]:(l=se(c),e[10]=c,e[11]=l);let j;return e[12]===l?j=e[13]:(j=(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:l,children:"Empty"}),e[12]=l,e[13]=j),j}let w;if(e[14]!==n||e[15]!==p||e[16]!==c||e[17]!==h||e[18]!==x||e[19]!==r||e[20]!==f||e[21]!==o||e[22]!==i||e[23]!==s){let l=_t(p,{namespace:r,searchValue:s,entriesByPath:h}),j;e[25]!==n||e[26]!==p||e[27]!==c||e[28]!==x||e[29]!==r||e[30]!==f||e[31]!==o||e[32]!==i||e[33]!==s?(j=d=>{let b=Ft(d,p.indexOf(d));return(0,a.jsx)(St,{rowKey:b,entry:d,namespace:r,protocol:o,rootPath:i,backendType:n,depth:c,locale:x,searchValue:s,onOpenFile:f},b)},e[25]=n,e[26]=p,e[27]=c,e[28]=x,e[29]=r,e[30]=f,e[31]=o,e[32]=i,e[33]=s,e[34]=j):j=e[34],w=l.map(j),e[14]=n,e[15]=p,e[16]=c,e[17]=h,e[18]=x,e[19]=r,e[20]=f,e[21]=o,e[22]=i,e[23]=s,e[24]=w}else w=e[24];let v;return e[35]===w?v=e[36]:(v=(0,a.jsx)(a.Fragment,{children:w}),e[35]=w,e[36]=v),v},St=({entry:t,rowKey:e,namespace:r,protocol:o,rootPath:i,backendType:n,depth:m,locale:c,searchValue:x,onOpenFile:s})=>{var N;let[f,h]=(0,O.useState)(!1),{entriesByPath:p}=Ce(),g=Ye(),y=t.kind==="directory",w=kt(t.path),v=!!x.trim(),l=y&&v&&w.toLowerCase().includes(x.trim().toLowerCase()),j=y&&v&&!!((N=p.get(Ze(r,t.path)))!=null&&N.some(u=>He(u,{namespace:r,searchValue:x,entriesByPath:p}))),d=f||j,b=(0,O.useCallback)(async()=>{try{let u=await Te.request({namespace:r,path:t.path});if(u.error){te({title:"Download failed",description:u.error,variant:"danger"});return}u.url&&Pe(u.url,u.filename??"download")}catch(u){De.error("Failed to download storage entry",u),te({title:"Download failed",description:String(u),variant:"danger"})}},[r,t.path]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(pt,{className:ie("text-xs flex items-center gap-1.5 cursor-pointer rounded-none group h-6.5",y&&"font-medium"),style:se(m),value:`${r}:${e}`,onSelect:()=>{y?h(!d):s({entry:t,namespace:r,protocol:o,backendType:n})},children:[y?(0,a.jsx)(Ee,{isExpanded:d,className:"h-3 w-3"}):(0,a.jsx)("span",{className:"w-3 shrink-0"}),y?(0,a.jsx)(la,{className:ie("h-3.5 w-3.5 shrink-0",at.directory)}):tt(w),(0,a.jsx)("span",{className:"truncate flex-1 text-left",children:w}),(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:Re(t.size,c)}),t.lastModified!=null&&(0,a.jsx)(R,{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:tr(t.lastModified,c)})}),(0,a.jsxs)(Jt,{children:[(0,a.jsx)(Kt,{asChild:!0,children:(0,a.jsx)(Ia,{iconClassName:"h-3 w-3",onClick:u=>u.stopPropagation()})}),(0,a.jsxs)(Gt,{align:"end",onClick:u=>u.stopPropagation(),onCloseAutoFocus:u=>u.preventDefault(),children:[!y&&(0,a.jsxs)(E,{onSelect:()=>s({entry:t,namespace:r,protocol:o,backendType:n}),children:[(0,a.jsx)(vt,{className:"h-3.5 w-3.5 mr-2"}),"View"]}),(0,a.jsxs)(E,{onSelect:async()=>{await je(t.path),te({title:"Copied to clipboard"})},children:[(0,a.jsx)(et,{className:ge}),"Copy path"]}),!y&&(0,a.jsxs)(E,{onSelect:()=>b(),children:[(0,a.jsx)(Me,{className:"h-3.5 w-3.5 mr-2"}),"Download"]}),(0,a.jsx)(ue,{}),Nt.map(u=>{let F=u.getCode({variableName:r,protocol:o,entry:t,backendType:n});if(F===null)return null;let _=u.icon;return(0,a.jsxs)(E,{onSelect:()=>g(F),children:[(0,a.jsx)(_,{className:ge}),u.label]},u.id)})]})]})]})]}),y&&d&&(0,a.jsx)(ar,{namespace:r,protocol:o,rootPath:i,backendType:n,prefix:t.path,depth:m+1,locale:c,searchValue:l?"":x,onOpenFile:s})]})},rr=t=>{let e=(0,Be.c)(43),{namespace:r,locale:o,searchValue:i,onOpenFile:n}=t,[m,c]=(0,O.useState)(!0),{entriesByPath:x}=Ce(),{clearNamespaceCache:s}=ta(),f=r.name??r.displayName,{entries:h,isPending:p,error:g,refetch:y}=Xe(f),w;e[0]!==s||e[1]!==f||e[2]!==y?(w=d=>{d.stopPropagation(),s(f),y()},e[0]=s,e[1]=f,e[2]=y,e[3]=w):w=e[3];let v=w,l=p?r.storageEntries:h,j;if(e[4]!==l||e[5]!==x||e[6]!==g||e[7]!==v||e[8]!==m||e[9]!==p||e[10]!==o||e[11]!==r.backendType||e[12]!==r.displayName||e[13]!==r.name||e[14]!==r.protocol||e[15]!==r.rootPath||e[16]!==f||e[17]!==n||e[18]!==i){let d=_t(l,{namespace:f,searchValue:i,entriesByPath:x}),b;e[20]===m?b=e[21]:(b=()=>c(!m),e[20]=m,e[21]=b);let N;e[22]===m?N=e[23]:(N=(0,a.jsx)(Ee,{isExpanded:m,className:"h-3 w-3"}),e[22]=m,e[23]=N);let u;e[24]===r.protocol?u=e[25]:(u=(0,a.jsx)(ca,{protocol:r.protocol}),e[24]=r.protocol,e[25]=u);let F;e[26]===r.displayName?F=e[27]:(F=(0,a.jsx)("span",{children:r.displayName}),e[26]=r.displayName,e[27]=F);let _;e[28]===r.name?_=e[29]:(_=r.name&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-normal",children:["(",(0,a.jsx)(Ba,{variableName:r.name}),")"]}),e[28]=r.name,e[29]=_);let S;e[30]===v?S=e[31]:(S=(0,a.jsx)(ht,{onClick:v,tooltip:"Refresh storage connection",className:"p-0",iconClassName:"h-3 w-3"}),e[30]=v,e[31]=S);let P=r.rootPath||"(root)",C;e[32]===P?C=e[33]:(C=(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-normal tabular-nums ml-auto",children:P}),e[32]=P,e[33]=C);let D;e[34]!==r.name||e[35]!==C||e[36]!==b||e[37]!==N||e[38]!==u||e[39]!==F||e[40]!==_||e[41]!==S?(D=(0,a.jsxs)(pt,{value:r.name,onSelect:b,className:"flex flex-row font-semibold h-7 text-xs gap-1.5 bg-(--slate-2) text-muted-foreground rounded-none",children:[N,u,F,_,S,C]}),e[34]=r.name,e[35]=C,e[36]=b,e[37]=N,e[38]=u,e[39]=F,e[40]=_,e[41]=S,e[42]=D):D=e[42],j=(0,a.jsxs)(a.Fragment,{children:[D,m&&(0,a.jsxs)(a.Fragment,{children:[p&&l.length===0&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:se(1),children:[(0,a.jsx)(Ie,{className:"h-3 w-3 animate-spin"}),"Loading..."]}),g&&l.length===0&&(0,a.jsx)(Va,{error:g,style:se(1),className:"py-1 text-xs h-auto overflow-auto max-h-32 items-start",showIcon:!1}),!p&&l.length===0&&!g&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:se(1),children:"No entries"}),i&&d.length===0&&l.length>0&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:se(1),children:"No matches"}),d.map(I=>{let T=Ft(I,l.indexOf(I));return(0,a.jsx)(St,{rowKey:T,entry:I,namespace:f,protocol:r.protocol,rootPath:r.rootPath,backendType:r.backendType,depth:1,locale:o,searchValue:i,onOpenFile:n},T)})]})]}),e[4]=l,e[5]=x,e[6]=g,e[7]=v,e[8]=m,e[9]=p,e[10]=o,e[11]=r.backendType,e[12]=r.displayName,e[13]=r.name,e[14]=r.protocol,e[15]=r.rootPath,e[16]=f,e[17]=n,e[18]=i,e[19]=j}else j=e[19];return j};const nr=()=>{let t=(0,Be.c)(31),{namespaces:e}=Ce(),{locale:r}=it(),[o,i]=(0,O.useState)(""),[n,m]=(0,O.useState)(null),c=!!o.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)(Aa,{title:"No storage connected",description:b,action:(0,a.jsx)(st,{defaultTab:"storage",children:(0,a.jsxs)(V,{variant:"outline",size:"sm",children:["Add remote storage",(0,a.jsx)(lt,{className:"h-4 w-4 ml-2"})]})}),icon:(0,a.jsx)(nt,{className:"h-8 w-8"})}),t[1]=N):N=t[1],N}let x;t[2]===n?x=t[3]:(x=n&&(0,a.jsx)(Xa,{entry:n.entry,namespace:n.namespace,protocol:n.protocol,backendType:n.backendType,onBack:()=>m(null)}),t[2]=n,t[3]=x);let s=n&&"hidden",f;t[4]===s?f=t[5]:(f=ie("border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin",s),t[4]=s,t[5]=f);let h;t[6]===o?h=t[7]:(h=(0,a.jsx)(Ma,{placeholder:"Search entries...",className:"h-6 m-1",value:o,onValueChange:i,rootClassName:"flex-1 border-b-0"}),t[6]=o,t[7]=h);let p;t[8]===c?p=t[9]:(p=c&&(0,a.jsx)(V,{variant:"text",size:"xs",className:"float-right border-none px-2 m-0 h-full",onClick:()=>i(""),children:(0,a.jsx)(na,{className:"h-4 w-4"})}),t[8]=c,t[9]=p);let g;t[10]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsx)(R,{content:"Filters loaded entries only. Expand directories to include their contents in the search.",delayDuration:200,children:(0,a.jsx)(sa,{className:"h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2"})}),t[10]=g):g=t[10];let y;t[11]===Symbol.for("react.memo_cache_sentinel")?(y=(0,a.jsx)(st,{defaultTab:"storage",children:(0,a.jsx)(V,{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)(lt,{className:"h-4 w-4"})})}),t[11]=y):y=t[11];let w;t[12]!==h||t[13]!==p?(w=(0,a.jsxs)("div",{className:"flex items-center w-full border-b",children:[h,p,g,y]}),t[12]=h,t[13]=p,t[14]=w):w=t[14];let v;if(t[15]!==r||t[16]!==e||t[17]!==o){let b;t[19]!==r||t[20]!==o?(b=N=>(0,a.jsx)(rr,{namespace:N,locale:r,searchValue:o,onOpenFile:m},N.name??N.displayName),t[19]=r,t[20]=o,t[21]=b):b=t[21],v=e.map(b),t[15]=r,t[16]=e,t[17]=o,t[18]=v}else v=t[18];let l;t[22]===v?l=t[23]:(l=(0,a.jsx)(Pa,{className:"flex flex-col",children:v}),t[22]=v,t[23]=l);let j;t[24]!==f||t[25]!==w||t[26]!==l?(j=(0,a.jsxs)(za,{className:f,shouldFilter:!1,children:[w,l]}),t[24]=f,t[25]=w,t[26]=l,t[27]=j):j=t[27];let d;return t[28]!==x||t[29]!==j?(d=(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[x,j]}),t[28]=x,t[29]=j,t[30]=d):d=t[30],d};var Ct=fe(),Dt=(0,O.createContext)(null);function sr(){return(0,O.useContext)(Dt)??void 0}var lr=t=>{let e=(0,Ct.c)(3),{children:r}=t,o=ha(),i;return e[0]!==r||e[1]!==o?(i=(0,a.jsx)(Dt.Provider,{value:o,children:r}),e[0]=r,e[1]=o,e[2]=i):i=e[2],i};const or=t=>{let e=(0,Ct.c)(5),{children:r}=t,[o,i]=(0,O.useState)(null),n;e[0]!==r||e[1]!==o?(n=o&&(0,a.jsx)(xa,{backend:ba,options:{rootElement:o},children:(0,a.jsx)(lr,{children:r})}),e[0]=r,e[1]=o,e[2]=n):n=e[2];let m;return e[3]===n?m=e[4]:(m=(0,a.jsx)("div",{ref:i,className:"contents",children:n}),e[3]=n,e[4]=m),m};var Le=new Map;const ir=({file:t,onOpenNotebook:e})=>{let{sendFileDetails:r,sendUpdateFile:o}=ze(),i=ye(Lt),n=ye(Ge),m=ye(At),[c,x]=(0,O.useState)(""),{data:s,isPending:f,error:h,setData:p,refetch:g}=Ve(async()=>{let u=await r({path:t.path}),F=u.contents||"";return x(Le.get(t.path)||F),u},[t.path]),y=async()=>{c!==(s==null?void 0:s.contents)&&await o({path:t.path,contents:c}).then(u=>{u.success&&(p(F=>({...F,contents:c})),x(c))})},w=(0,O.useRef)(c);if(w.current=c,(0,O.useEffect)(()=>()=>{if(!(s!=null&&s.contents))return;let u=w.current;u===s.contents?Le.delete(t.path):Le.set(t.path,u)},[t.path,s==null?void 0:s.contents]),h)return(0,a.jsx)(mt,{error:h});if(f||!s)return null;let v=s.mimeType||"text/plain",l=v in Yt,j=m&&s.file.isMarimoFile&&(t.path===m||t.path.endsWith(`/${m}`));if(!s.contents&&!l)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:s.file.name}),(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Type"}),(0,a.jsx)("div",{children:v})]});let d=(0,a.jsx)(wt,{filename:s.file.name,onRefresh:g,onDownload:n?void 0:()=>{if(s.isBase64&&s.contents){_e(v)?Pe(Oe(s.contents,v),s.file.name):Se(dt(Oe(s.contents,s.mimeType||"application/octet-stream")),s.file.name);return}Se(new Blob([s.contents||c],{type:v}),s.file.name)},actions:(0,a.jsxs)(a.Fragment,{children:[t.isMarimoFile&&!Fe()&&(0,a.jsx)(R,{content:"Open notebook",children:(0,a.jsx)(V,{variant:"text",size:"xs",onClick:u=>e(u),children:(0,a.jsx)($e,{className:"h-3.5 w-3.5"})})}),!_e(v)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(R,{content:"Copy contents to clipboard",children:(0,a.jsx)(V,{variant:"text",size:"xs",onClick:async()=>{await je(c)},children:(0,a.jsx)(et,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(R,{content:Ta("global.save"),children:(0,a.jsx)(V,{variant:"text",size:"xs",onClick:y,disabled:c===s.contents,children:(0,a.jsx)(va,{className:"h-3.5 w-3.5"})})})]})]})}),b=_e(v),N=!b&&v!=="text/csv";return(0,a.jsxs)(a.Fragment,{children:[d,N&&j&&(0,a.jsxs)(Ca,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(wa,{className:"h-4 w-4"}),(0,a.jsx)(Sa,{children:"Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution."})]}),(0,a.jsx)(Je,{mimeType:v,contents:b?void 0:N?c:s.contents??void 0,mediaSource:b?{base64:s.contents,mime:v}:void 0,readOnly:!N,onChange:x,extensions:[Xt.of([{key:i.getHotkey("global.save").key,stopPropagation:!0,run:()=>c===s.contents?!1:(y(),!0)}])]})]})},Mt=Ue(t=>{let e=t(ea);return Ht(e,"no requestClientAtom set"),new pa({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,copyFileOrFolder:e.sendCopyFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),cr=Ue({});async function dr(){await Vt.get(Mt).refreshAll([])}var le=" ";const Pt={directory:t=>`os.listdir("${t}")`,python:t=>`with open("${t}", "r") as _f:
|
|
11
|
+
${le}...
|
|
12
|
+
`,json:t=>`with open("${t}", "r") as _f:
|
|
13
|
+
${le}_data = json.load(_f)
|
|
14
|
+
`,code:t=>`with open("${t}", "r") as _f:
|
|
15
|
+
${le}...
|
|
16
|
+
`,text:t=>`with open("${t}", "r") as _f:
|
|
17
|
+
${le}...
|
|
18
|
+
`,image:t=>`mo.image("${t}")`,audio:t=>`mo.audio("${t}")`,video:t=>`mo.video("${t}")`,pdf:t=>`with open("${t}", "rb") as _f:
|
|
19
|
+
${le}...
|
|
20
|
+
`,zip:t=>`with open("${t}", "rb") as _f:
|
|
21
|
+
${le}...
|
|
22
|
+
`,data:t=>`with open("${t}", "r") as _f:
|
|
23
|
+
${le}...
|
|
24
|
+
`,unknown:t=>`with open("${t}", "r") as _f:
|
|
25
|
+
${le}...
|
|
26
|
+
`};var mr=fe(),pr=1024*1024*100,hr=5;function zt(t){let e=(0,mr.c)(7),r;e[0]===t?r=e[1]:(r=t===void 0?{}:t,e[0]=t,e[1]=r);let o=r,{sendCreateFileOrFolder:i}=ze(),n;e[2]===i?n=e[3]:(n=async c=>{if(c.length===0)return;let x=c.length===1;await Zt(x?"Uploading file...":"Uploading files...",async s=>{s.addTotal(c.length),await Ra(c,hr,async f=>{let h=gr(jr(f)),p="";h&&(p=Fa.guessDeliminator(h).dirname(h)),await i({path:p,type:"file",name:f.name,file:f}),s.increment(1)}),await dr()},{title:x?"File uploaded":`${c.length} files uploaded`})},e[2]=i,e[3]=n);let m;return e[4]!==o||e[5]!==n?(m={multiple:!0,maxSize:pr,onError:yr,onDropRejected:xr,onDrop:n,...o},e[4]=o,e[5]=n,e[6]=m):m=e[6],ka(m)}function xr(t){te({title:"File upload failed",description:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:t.map(fr)}),variant:"danger"})}function fr(t){return(0,a.jsxs)("div",{children:[t.file.name," (",t.errors.map(ur).join(", "),")"]},t.file.name)}function ur(t){return t.message}function yr(t){De.error(t),te({title:"File upload failed",description:t.message,variant:"danger"})}function jr(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 gr(t){if(t)return t.replace(/^\/+/,"")}var be=fe(),br=Ke("marimo:showHiddenFiles",!0,We,{getOnInit:!0}),Tt=O.createContext(null);const vr=t=>{let e=(0,be.c)(73),{height:r}=t,o=(0,O.useRef)(null),i=sr(),[n]=ke(Mt),m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0];let[c,x]=(0,O.useState)(m),[s,f]=(0,O.useState)(null),[h,p]=ke(br),{openPrompt:g}=ct(),[y,w]=ke(cr),v;e[1]===n?v=e[2]:(v=()=>n.initialize(x),e[1]=n,e[2]=v);let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=[],e[3]=l):l=e[3];let{isPending:j,error:d}=Ve(v,l),b;e[4]!==y||e[5]!==n?(b=()=>n.refreshAll(Object.keys(y).filter(k=>y[k])),e[4]=y,e[5]=n,e[6]=b):b=e[6];let N=ee(b),u;e[7]!==p||e[8]!==h?(u=()=>{p(!h)},e[7]=p,e[8]=h,e[9]=u):u=e[9];let F=ee(u),_;e[10]!==g||e[11]!==n?(_=async()=>{g({title:"Folder name",onConfirm:async k=>{n.createFolder(k,null)}})},e[10]=g,e[11]=n,e[12]=_):_=e[12];let S=ee(_),P;e[13]!==g||e[14]!==n?(P=async()=>{g({title:"File name",onConfirm:async k=>{n.createFile({name:k,parentId:null})}})},e[13]=g,e[14]=n,e[15]=P):P=e[15];let C=ee(P),D;e[16]!==g||e[17]!==n?(D=async()=>{g({title:"Notebook name",onConfirm:async k=>{n.createFile({name:k,parentId:null,type:"notebook"})}})},e[16]=g,e[17]=n,e[18]=D):D=e[18];let I=ee(D),T;e[19]===w?T=e[20]:(T=()=>{var k;(k=o.current)==null||k.closeAll(),w({})},e[19]=w,e[20]=T);let Q=ee(T),G;e[21]!==c||e[22]!==h?(G=$t(c,h),e[21]=c,e[22]=h,e[23]=G):G=e[23];let oe=G;if(j){let k;return e[24]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(da,{size:"medium",centered:!0}),e[24]=k):k=e[24],k}if(d){let k;return e[25]===d?k=e[26]:(k=(0,a.jsx)(mt,{error:d}),e[25]=d,e[26]=k),k}if(s){let k;e[27]===Symbol.for("react.memo_cache_sentinel")?(k=()=>f(null),e[27]=k):k=e[27];let z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsx)(V,{onClick:k,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:(0,a.jsx)(Qe,{size:16})}),e[28]=z):z=e[28];let $;e[29]===s.name?$=e[30]:($=(0,a.jsxs)("div",{className:"flex items-center pl-1 pr-3 shrink-0 border-b justify-between",children:[z,(0,a.jsx)("span",{className:"font-bold",children:s.name})]}),e[29]=s.name,e[30]=$);let K;e[31]!==s.path||e[32]!==n?(K=re=>Ot(re,n.relativeFromRoot(s.path)),e[31]=s.path,e[32]=n,e[33]=K):K=e[33];let Y;e[34]!==s||e[35]!==K?(Y=(0,a.jsx)(O.Suspense,{children:(0,a.jsx)(ir,{onOpenNotebook:K,file:s})}),e[34]=s,e[35]=K,e[36]=Y):Y=e[36];let Z;return e[37]!==$||e[38]!==Y?(Z=(0,a.jsxs)(a.Fragment,{children:[$,Y]}),e[37]=$,e[38]=Y,e[39]=Z):Z=e[39],Z}let A;e[40]!==Q||e[41]!==C||e[42]!==S||e[43]!==I||e[44]!==F||e[45]!==N||e[46]!==h||e[47]!==n?(A=(0,a.jsx)(Nr,{onRefresh:N,onHidden:F,showHiddenFiles:h,onCreateFile:C,onCreateNotebook:I,onCreateFolder:S,onCollapseAll:Q,tree:n}),e[40]=Q,e[41]=C,e[42]=S,e[43]=I,e[44]=F,e[45]=N,e[46]=h,e[47]=n,e[48]=A):A=e[48];let X=r-33,B,H,L;e[49]===n?(B=e[50],H=e[51],L=e[52]):(B=async k=>{let{ids:z}=k;for(let $ of z)await n.delete($)},H=async k=>{let{id:z,name:$}=k;await n.rename(z,$)},L=async k=>{let{dragIds:z,parentId:$}=k;await n.move(z,$)},e[49]=n,e[50]=B,e[51]=H,e[52]=L);let J;e[53]===Symbol.for("react.memo_cache_sentinel")?(J=k=>{let z=k[0];z&&(z.data.isDirectory||f(z.data))},e[53]=J):J=e[53];let q;e[54]!==y||e[55]!==w||e[56]!==n?(q=async k=>{if(await n.expand(k)){let z=y[k]??!1;w({...y,[k]:!z})}},e[54]=y,e[55]=w,e[56]=n,e[57]=q):q=e[57];let U;e[58]!==i||e[59]!==y||e[60]!==X||e[61]!==B||e[62]!==H||e[63]!==L||e[64]!==q||e[65]!==oe?(U=(0,a.jsx)(ua,{width:"100%",ref:o,height:X,className:"h-full",data:oe,initialOpenState:y,openByDefault:!1,dndManager:i,renderCursor:Cr,disableDrop:Dr,onDelete:B,onRename:H,onMove:L,onSelect:J,onToggle:q,padding:15,rowHeight:30,indent:wr,overscanCount:1e3,disableMultiSelection:!0,children:Fr}),e[58]=i,e[59]=y,e[60]=X,e[61]=B,e[62]=H,e[63]=L,e[64]=q,e[65]=oe,e[66]=U):U=e[66];let W;e[67]!==U||e[68]!==n?(W=(0,a.jsx)(Tt,{value:n,children:U}),e[67]=U,e[68]=n,e[69]=W):W=e[69];let ae;return e[70]!==A||e[71]!==W?(ae=(0,a.jsxs)(a.Fragment,{children:[A,W]}),e[70]=A,e[71]=W,e[72]=ae):ae=e[72],ae};var wr=15,Nr=t=>{let e=(0,be.c)(37),{onRefresh:r,onHidden:o,showHiddenFiles:i,onCreateFile:n,onCreateNotebook:m,onCreateFolder:c,onCollapseAll:x}=t,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={noDrag:!0,noDragEventsBubbling:!0},e[0]=s):s=e[0];let{getRootProps:f,getInputProps:h}=zt(s),p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(yt,{size:16}),e[1]=p):p=e[1];let g;e[2]===m?g=e[3]:(g=(0,a.jsx)(R,{content:"Add notebook",children:(0,a.jsx)(V,{"data-testid":"file-explorer-add-notebook-button",onClick:m,variant:"text",size:"xs",children:p})}),e[2]=m,e[3]=g);let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=(0,a.jsx)(jt,{size:16}),e[4]=y):y=e[4];let w;e[5]===n?w=e[6]:(w=(0,a.jsx)(R,{content:"Add file",children:(0,a.jsx)(V,{"data-testid":"file-explorer-add-file-button",onClick:n,variant:"text",size:"xs",children:y})}),e[5]=n,e[6]=w);let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsx)(gt,{size:16}),e[7]=v):v=e[7];let l;e[8]===c?l=e[9]:(l=(0,a.jsx)(R,{content:"Add folder",children:(0,a.jsx)(V,{"data-testid":"file-explorer-add-folder-button",onClick:c,variant:"text",size:"xs",children:v})}),e[8]=c,e[9]=l);let j;e[10]===f?j=e[11]:(j=f({}),e[10]=f,e[11]=j);let d,b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=Qt({variant:"text",size:"xs"}),d=(0,a.jsx)(Na,{size:16}),e[12]=d,e[13]=b):(d=e[12],b=e[13]);let N;e[14]===j?N=e[15]:(N=(0,a.jsx)(R,{content:"Upload file",children:(0,a.jsx)("button",{"data-testid":"file-explorer-upload-button",...j,className:b,children:d})}),e[14]=j,e[15]=N);let u;e[16]===h?u=e[17]:(u=h({}),e[16]=h,e[17]=u);let F;e[18]===u?F=e[19]:(F=(0,a.jsx)("input",{...u,type:"file"}),e[18]=u,e[19]=F);let _;e[20]===r?_=e[21]:(_=(0,a.jsx)(ht,{"data-testid":"file-explorer-refresh-button",onClick:r}),e[20]=r,e[21]=_);let S;e[22]!==o||e[23]!==i?(S=(0,a.jsx)($a,{"data-testid":"file-explorer-hidden-files-button",isVisible:i,onToggle:o,showTooltip:"Show hidden files",hideTooltip:"Hide hidden files"}),e[22]=o,e[23]=i,e[24]=S):S=e[24];let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=(0,a.jsx)(Wa,{size:16}),e[25]=P):P=e[25];let C;e[26]===x?C=e[27]:(C=(0,a.jsx)(R,{content:"Collapse all folders",children:(0,a.jsx)(V,{"data-testid":"file-explorer-collapse-button",onClick:x,variant:"text",size:"xs",children:P})}),e[26]=x,e[27]=C);let D;return e[28]!==N||e[29]!==F||e[30]!==_||e[31]!==S||e[32]!==C||e[33]!==g||e[34]!==w||e[35]!==l?(D=(0,a.jsxs)("div",{className:"flex items-center justify-end px-2 shrink-0 border-b",children:[g,w,l,N,F,_,S,C]}),e[28]=N,e[29]=F,e[30]=_,e[31]=S,e[32]=C,e[33]=g,e[34]=w,e[35]=l,e[36]=D):D=e[36],D},kr=t=>{let e=(0,be.c)(9),{node:r,onOpenMarimoFile:o}=t,i;e[0]===r?i=e[1]:(i=c=>{r.data.isDirectory||(c.stopPropagation(),r.select())},e[0]=r,e[1]=i);let n;e[2]!==r.data.isMarimoFile||e[3]!==o?(n=r.data.isMarimoFile&&!Fe()&&(0,a.jsxs)("span",{"data-testid":"file-explorer-open-marimo-button",className:"shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:o,children:["open ",(0,a.jsx)($e,{className:"inline ml-1",size:12})]}),e[2]=r.data.isMarimoFile,e[3]=o,e[4]=n):n=e[4];let m;return e[5]!==r.data.name||e[6]!==i||e[7]!==n?(m=(0,a.jsxs)("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:i,children:[r.data.name,n]}),e[5]=r.data.name,e[6]=i,e[7]=n,e[8]=m):m=e[8],m},Fr=t=>{let e=(0,be.c)(116),{node:r,style:o,dragHandle:i}=t,{openFile:n,sendFileDetails:m}=ze(),c=ye(Ge),x;e[0]!==r.data.isDirectory||e[1]!==r.data.name?(x=r.data.isDirectory?"directory":oa(r.data.name),e[0]=r.data.isDirectory,e[1]=r.data.name,e[2]=x):x=e[2];let s=x,f=ia[s],{openConfirm:h,openPrompt:p}=ct(),{createNewCell:g}=Rt(),y=Da(),w;e[3]!==g||e[4]!==y?(w=M=>{g({code:M,before:!1,cellId:y??"__end__"})},e[3]=g,e[4]=y,e[5]=w):w=e[5];let v=w,l=(0,O.use)(Tt),j;e[6]!==r.data.path||e[7]!==l?(j=async M=>{Ot(M,l?l.relativeFromRoot(r.data.path):r.data.path)},e[6]=r.data.path,e[7]=l,e[8]=j):j=e[8];let d=j,b;e[9]!==r.data.name||e[10]!==r.id||e[11]!==r.tree||e[12]!==h?(b=async M=>{M.stopPropagation(),M.preventDefault(),h({title:"Delete file",description:`Are you sure you want to delete ${r.data.name}?`,confirmAction:(0,a.jsx)(Wt,{onClick:async()=>{await r.tree.delete(r.id)},"aria-label":"Confirm",children:"Delete"})})},e[9]=r.data.name,e[10]=r.id,e[11]=r.tree,e[12]=h,e[13]=b):b=e[13];let N=b,u;e[14]!==r||e[15]!==p||e[16]!==l?(u=async()=>{r.open(),p({title:"Folder name",onConfirm:async M=>{l==null||l.createFolder(M,r.id)}})},e[14]=r,e[15]=p,e[16]=l,e[17]=u):u=e[17];let F=ee(u),_;e[18]!==r||e[19]!==p||e[20]!==l?(_=async()=>{r.open(),p({title:"File name",onConfirm:async M=>{l==null||l.createFile({name:M,parentId:r.id})}})},e[18]=r,e[19]=p,e[20]=l,e[21]=_):_=e[21];let S=ee(_),P;e[22]!==r||e[23]!==p||e[24]!==l?(P=async()=>{r.open(),p({title:"Notebook name",onConfirm:async M=>{l==null||l.createFile({name:M,parentId:r.id,type:"notebook"})}})},e[22]=r,e[23]=p,e[24]=l,e[25]=P):P=e[25];let C=ee(P),D;e[26]!==r.data.name||e[27]!==r.id||e[28]!==l?(D=async()=>{l&&await l.copy(r.id,Ea(r.data.name))},e[26]=r.data.name,e[27]=r.id,e[28]=l,e[29]=D):D=e[29];let I=ee(D),T;e[30]===Symbol.for("react.memo_cache_sentinel")?(T=ie("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),e[30]=T):T=e[30];let Q,G;e[31]===r?(Q=e[32],G=e[33]):(Q=M=>{M.stopPropagation(),r.data.isDirectory&&r.toggle()},G=(0,a.jsx)(_r,{node:r}),e[31]=r,e[32]=Q,e[33]=G);let oe=r.willReceiveDrop&&r.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground",A;e[34]===oe?A=e[35]:(A=ie("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",oe),e[34]=oe,e[35]=A);let X;e[36]!==f||e[37]!==s||e[38]!==r.data.isMarimoFile?(X=r.data.isMarimoFile?(0,a.jsx)(La,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}):(0,a.jsx)(f,{className:ie("w-5 h-5 shrink-0 mr-2",at[s]),strokeWidth:1.5}),e[36]=f,e[37]=s,e[38]=r.data.isMarimoFile,e[39]=X):X=e[39];let B;e[40]!==d||e[41]!==r?(B=r.isEditing?(0,a.jsx)(ga,{node:r}):(0,a.jsx)(kr,{node:r,onOpenMarimoFile:d}),e[40]=d,e[41]=r,e[42]=B):B=e[42];let H;e[43]===r?H=e[44]:(H=!r.data.isDirectory&&(0,a.jsxs)(E,{onSelect:()=>r.select(),"data-testid":"file-explorer-open-file-menu-item",children:[(0,a.jsx)(vt,{className:"h-3.5 w-3.5 mr-2"}),"Open file"]}),e[43]=r,e[44]=H);let L;e[45]!==r.data.isDirectory||e[46]!==r.data.path||e[47]!==n?(L=!r.data.isDirectory&&!Fe()&&(0,a.jsxs)(E,{onSelect:()=>{n({path:r.data.path})},"data-testid":"file-explorer-open-external-menu-item",children:[(0,a.jsx)($e,{className:"h-3.5 w-3.5 mr-2"}),"Open file in external editor"]}),e[45]=r.data.isDirectory,e[46]=r.data.path,e[47]=n,e[48]=L):L=e[48];let J;e[49]!==S||e[50]!==F||e[51]!==C||e[52]!==r.data.isDirectory?(J=r.data.isDirectory&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(E,{onSelect:()=>C(),"data-testid":"file-explorer-create-notebook-menu-item",children:[(0,a.jsx)(yt,{className:"h-3.5 w-3.5 mr-2"}),"Create notebook"]}),(0,a.jsxs)(E,{onSelect:()=>S(),"data-testid":"file-explorer-create-file-menu-item",children:[(0,a.jsx)(jt,{className:"h-3.5 w-3.5 mr-2"}),"Create file"]}),(0,a.jsxs)(E,{onSelect:()=>F(),"data-testid":"file-explorer-create-folder-menu-item",children:[(0,a.jsx)(gt,{className:"h-3.5 w-3.5 mr-2"}),"Create folder"]}),(0,a.jsx)(ue,{})]}),e[49]=S,e[50]=F,e[51]=C,e[52]=r.data.isDirectory,e[53]=J):J=e[53];let q;e[54]===r?q=e[55]:(q=(0,a.jsx)(ma,{onSelect:()=>r.edit(),testId:"file-explorer-rename-menu-item"}),e[54]=r,e[55]=q);let U;e[56]===I?U=e[57]:(U=(0,a.jsx)(ja,{onSelect:I,testId:"file-explorer-duplicate-menu-item"}),e[56]=I,e[57]=U);let W;e[58]===r.data.path?W=e[59]:(W=async()=>{await je(r.data.path),te({title:"Copied to clipboard"})},e[58]=r.data.path,e[59]=W);let ae;e[60]===Symbol.for("react.memo_cache_sentinel")?(ae=(0,a.jsx)(bt,{className:ge}),e[60]=ae):ae=e[60];let k;e[61]===W?k=e[62]:(k=(0,a.jsxs)(E,{onSelect:W,"data-testid":"file-explorer-copy-path-menu-item",children:[ae,"Copy path"]}),e[61]=W,e[62]=k);let z;e[63]!==r.data.path||e[64]!==l?(z=l&&(0,a.jsxs)(E,{onSelect:async()=>{await je(l.relativeFromRoot(r.data.path)),te({title:"Copied to clipboard"})},"data-testid":"file-explorer-copy-relative-path-menu-item",children:[(0,a.jsx)(bt,{className:"h-3.5 w-3.5 mr-2"}),"Copy relative path"]}),e[63]=r.data.path,e[64]=l,e[65]=z):z=e[65];let $;e[66]===Symbol.for("react.memo_cache_sentinel")?($=(0,a.jsx)(ue,{}),e[66]=$):$=e[66];let K;e[67]!==s||e[68]!==v||e[69]!==r.data?(K=()=>{let{path:M}=r.data;v(Pt[s](M))},e[67]=s,e[68]=v,e[69]=r.data,e[70]=K):K=e[70];let Y;e[71]===Symbol.for("react.memo_cache_sentinel")?(Y=(0,a.jsx)(ra,{className:ge}),e[71]=Y):Y=e[71];let Z;e[72]===K?Z=e[73]:(Z=(0,a.jsxs)(E,{onSelect:K,"data-testid":"file-explorer-insert-snippet-menu-item",children:[Y,"Insert snippet for reading file"]}),e[72]=K,e[73]=Z);let re;e[74]!==s||e[75]!==r.data?(re=async()=>{te({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:M}=r.data;await je(Pt[s](M))},e[74]=s,e[75]=r.data,e[76]=re):re=e[76];let ve;e[77]===Symbol.for("react.memo_cache_sentinel")?(ve=(0,a.jsx)(Bt,{className:ge}),e[77]=ve):ve=e[77];let ce;e[78]===re?ce=e[79]:(ce=(0,a.jsxs)(E,{onSelect:re,"data-testid":"file-explorer-copy-snippet-menu-item",children:[ve,"Copy snippet for reading file"]}),e[78]=re,e[79]=ce);let de;e[80]!==d||e[81]!==r.data.isMarimoFile?(de=r.data.isMarimoFile&&!Fe()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ue,{}),(0,a.jsxs)(E,{onSelect:d,"data-testid":"file-explorer-open-notebook-menu-item",children:[(0,a.jsx)(Ga,{className:"h-3.5 w-3.5 mr-2"}),"Open notebook"]})]}),e[80]=d,e[81]=r.data.isMarimoFile,e[82]=de):de=e[82];let we;e[83]===Symbol.for("react.memo_cache_sentinel")?(we=(0,a.jsx)(ue,{}),e[83]=we):we=e[83];let me;e[84]!==c||e[85]!==r.data.isDirectory||e[86]!==r.data.name||e[87]!==r.data.path||e[88]!==m?(me=!r.data.isDirectory&&!c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(E,{onSelect:async()=>{let M=await m({path:r.data.path});M.isBase64&&M.contents?Se(dt(Oe(M.contents,M.mimeType||"application/octet-stream")),r.data.name):Se(new Blob([M.contents||""]),r.data.name)},"data-testid":"file-explorer-download-menu-item",children:[(0,a.jsx)(Me,{className:"h-3.5 w-3.5 mr-2"}),"Download"]}),(0,a.jsx)(ue,{})]}),e[84]=c,e[85]=r.data.isDirectory,e[86]=r.data.name,e[87]=r.data.path,e[88]=m,e[89]=me):me=e[89];let pe;e[90]===N?pe=e[91]:(pe=(0,a.jsx)(ya,{onSelect:N,testId:"file-explorer-delete-menu-item"}),e[90]=N,e[91]=pe);let he;e[92]!==H||e[93]!==L||e[94]!==J||e[95]!==q||e[96]!==U||e[97]!==k||e[98]!==z||e[99]!==Z||e[100]!==ce||e[101]!==de||e[102]!==me||e[103]!==pe?(he=(0,a.jsxs)(fa,{testId:"file-explorer-more-button",iconClassName:"w-5 h-5",children:[H,L,J,q,U,k,z,$,Z,ce,de,we,me,pe]}),e[92]=H,e[93]=L,e[94]=J,e[95]=q,e[96]=U,e[97]=k,e[98]=z,e[99]=Z,e[100]=ce,e[101]=de,e[102]=me,e[103]=pe,e[104]=he):he=e[104];let xe;e[105]!==A||e[106]!==X||e[107]!==B||e[108]!==he?(xe=(0,a.jsxs)("span",{className:A,children:[X,B,he]}),e[105]=A,e[106]=X,e[107]=B,e[108]=he,e[109]=xe):xe=e[109];let Ne;return e[110]!==i||e[111]!==o||e[112]!==Q||e[113]!==G||e[114]!==xe?(Ne=(0,a.jsxs)("div",{style:o,ref:i,className:T,draggable:!0,onClick:Q,children:[G,xe]}),e[110]=i,e[111]=o,e[112]=Q,e[113]=G,e[114]=xe,e[115]=Ne):Ne=e[115],Ne},_r=t=>{let e=(0,be.c)(3),{node:r}=t;if(!r.data.isDirectory){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)("span",{className:"w-4 h-4 shrink-0"}),e[0]=i):i=e[0],i}let o;return e[1]===r.isOpen?o=e[2]:(o=(0,a.jsx)(Ee,{isExpanded:r.isOpen,className:"w-4 h-4"}),e[1]=r.isOpen,e[2]=o),o};function Ot(t,e){t.stopPropagation(),t.preventDefault(),qa(e)}function $t(t,e){if(e)return t;let r=[];for(let o of t){if(Sr(o.name))continue;let i=o;if(o.children){let n=$t(o.children,e);n!==o.children&&(i={...o,children:n})}r.push(i)}return r}function Sr(t){return!!t.startsWith(".")}function Cr(){return null}function Dr(t){let{parentNode:e}=t;return!e.data.isDirectory}var It=fe(),Mr=Ke("marimo:file-explorer-panel:state",{openSections:["files"],hasUserInteracted:!1},We),Pr=t=>{let e=(0,It.c)(20),{height:r}=t,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={noClick:!0,noKeyboard:!0},e[0]=o):o=e[0];let{getRootProps:i,getInputProps:n,isDragActive:m}=zt(o),c;e[1]===i?c=e[2]:(c=i(),e[1]=i,e[2]=c);let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=ie("flex flex-col overflow-hidden relative"),e[3]=x):x=e[3];let s;e[4]===r?s=e[5]:(s={height:r},e[4]=r,e[5]=s);let f;e[6]===n?f=e[7]:(f=n(),e[6]=n,e[7]=f);let h;e[8]===f?h=e[9]:(h=(0,a.jsx)("input",{...f}),e[8]=f,e[9]=h);let p;e[10]===m?p=e[11]:(p=m&&(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]=m,e[11]=p);let g;e[12]===r?g=e[13]:(g=(0,a.jsx)(vr,{height:r}),e[12]=r,e[13]=g);let y;return e[14]!==c||e[15]!==s||e[16]!==h||e[17]!==p||e[18]!==g?(y=(0,a.jsx)(or,{children:(0,a.jsxs)("div",{...c,className:x,style:s,children:[h,p,g]})}),e[14]=c,e[15]=s,e[16]=h,e[17]=p,e[18]=g,e[19]=y):y=e[19],y},zr=33,Tr=()=>{let t=(0,It.c)(36),{ref:e,height:r}=Oa(),o=r===void 0?500:r,[i,n]=ke(Mr),m=ye(aa).length,c;e:{if(!i.hasUserInteracted&&m>0){if(i.openSections.includes("remote-storage")){c=i.openSections;break e}let T;t[0]===i.openSections?T=t[1]:(T=[...i.openSections,"remote-storage"],t[0]=i.openSections,t[1]=T),c=T;break e}c=i.openSections}let x=c,s;t[2]===n?s=t[3]:(s=T=>{n({openSections:T,hasUserInteracted:!0})},t[2]=n,t[3]=s);let f=s,h=o-zr*2,p;t[4]===x?p=t[5]:(p=x.includes("remote-storage"),t[4]=x,t[5]=p);let g=p,y;t[6]!==x||t[7]!==g?(y=g&&x.includes("files"),t[6]=x,t[7]=g,t[8]=y):y=t[8];let w=y,v;t[9]!==h||t[10]!==w?(v=w?Math.round(h*.4):h,t[9]=h,t[10]=w,t[11]=v):v=t[11];let l=v,j=Math.max(200,w?h-l:h),d;t[12]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)(nt,{className:"w-4 h-4"}),t[12]=d):d=t[12];let b;t[13]===m?b=t[14]:(b=m>0&&(0,a.jsx)(Ha,{children:m}),t[13]=m,t[14]=b);let N;t[15]===b?N=t[16]:(N=(0,a.jsxs)(ft,{children:[d," Remote storage",b]}),t[15]=b,t[16]=N);let u;t[17]===l?u=t[18]:(u={maxHeight:l},t[17]=l,t[18]=u);let F;t[19]===Symbol.for("react.memo_cache_sentinel")?(F=(0,a.jsx)(nr,{}),t[19]=F):F=t[19];let _;t[20]===u?_=t[21]:(_=(0,a.jsx)(ut,{className:"overflow-auto",style:u,children:F}),t[20]=u,t[21]=_);let S;t[22]!==_||t[23]!==N?(S=(0,a.jsxs)(xt,{value:"remote-storage",children:[N,_]}),t[22]=_,t[23]=N,t[24]=S):S=t[24];let P;t[25]===Symbol.for("react.memo_cache_sentinel")?(P=(0,a.jsxs)(ft,{children:[(0,a.jsx)(rt,{className:"w-4 h-4"}),"Files"]}),t[25]=P):P=t[25];let C;t[26]===j?C=t[27]:(C=(0,a.jsxs)(xt,{value:"files",children:[P,(0,a.jsx)(ut,{children:(0,a.jsx)(Pr,{height:j})})]}),t[26]=j,t[27]=C);let D;t[28]!==f||t[29]!==x||t[30]!==S||t[31]!==C?(D=(0,a.jsxs)(Ut,{type:"multiple",value:x,onValueChange:f,children:[S,C]}),t[28]=f,t[29]=x,t[30]=S,t[31]=C,t[32]=D):D=t[32];let I;return t[33]!==e||t[34]!==D?(I=(0,a.jsx)("div",{ref:e,className:"h-full overflow-auto",children:D}),t[33]=e,t[34]=D,t[35]=I):I=t[35],I};export{Tr as default};
|