@marimo-team/frontend 0.23.5-dev6 → 0.23.5-dev7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{s as qe}from"./chunk-LvLJmgfZ.js";import{i as Rt,l as ke,n as ee,p as Ue,u as ye}from"./useEvent-D91BmmQi.js";import{t as At}from"./react-Bj1aDYRI.js";import{E as Et,Pn as We,Si as Ge,vi as It,vr as Ht}from"./cells-CcBfzJ1Z.js";import"./react-dom-CSu739Rf.js";import{t as fe}from"./compiler-runtime-B3qBwwSJ.js";import{_ as Me}from"./useEventListener-BR0C1MaI.js";import{t as Lt}from"./invariant-BUdrueMv.js";import{p as Vt,u as Je}from"./utils-DIGrmLDO.js";import{S as _e}from"./config-DczIUz0b.js";import{t as ie}from"./cn-DCUzRj2J.js";import{t as Bt}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-BDxedMYP.js";import{n as qt}from"./multi-map-rafH3cg3.js";import{o as Ut}from"./alert-dialog-BGBdrcqJ.js";import"./popover-UExmgBsf.js";import{a as E,c as ue,p as Wt,r as Gt,t as Jt}from"./dropdown-menu-D1A3cFC8.js";import{a as Kt,bt as De,i as Ke,o as Se}from"./JsonOutput-Bw-rSneQ.js";import{c as Yt,i as ze,r as Ce}from"./download-YUQiaxS9.js";import{r as Ye}from"./radio-group-6t7ozlnG.js";import{t as I}from"./tooltip-Gcwqb_SK.js";import{n as Xt,t as $}from"./button-D9nb17Rw.js";import{St as Zt}from"./dist-BrR4M-k3.js";import"./cjs-BRGiG41H.js";import"./main-B0OX4z33.js";import"./useNonce-DfoVjkkH.js";import{n as Qt,r as Pe}from"./requests-DIwGYs0l.js";import{t as re}from"./createLucideIcon-D5guW7EU.js";import{a as Xe,c as Ze,i as Qe,n as Fe,o as Te,r as ea,t as ta}from"./state-B34hXjp9.js";import{n as aa}from"./LazyAnyLanguageCodeMirror-BF3xpDgO.js";import{t as na}from"./x-C-6liIBr.js";import{n as Oe}from"./maps-C48Oksn0.js";import{n as $e}from"./markdown-renderer-DmnGXdCp.js";import{u as ra}from"./toDate-B5A0DFEz.js";import{t as et}from"./copy-BwrPA9zQ.js";import{t as sa}from"./eye-off-n1Li95bE.js";import{a as oa,i as tt,n as at,r as la,t as ia}from"./file-icons-CMxkj_kV.js";import{t as nt}from"./file-BrdxGLRX.js";import{i as rt,r as ca,t as st}from"./add-connection-dialog-C14LN8_M.js";import{n as Re,t as da}from"./spinner-Bhir8k53.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-B1tIGkqI.js";import{t as ot}from"./plus-BgB18UzY.js";import{t as lt}from"./refresh-cw-DHwG4Mac.js";import{t as va}from"./save-Clg5dMoP.js";import{t as wa}from"./triangle-alert-B8l157gP.js";import{n as Na,t as ka}from"./es-DaYh1PsD.js";import"./dist-DQOq2Tf-.js";import"./dist-DBiqbYe-.js";import"./dist-VjDnmGCZ.js";import"./dist-E6ttb8td.js";import"./dist-B324sPca.js";import{t as te}from"./use-toast-T0_cQDma.js";import{t as _a}from"./paths-BXWH6vv4.js";import"./session-VtovaFBS.js";import"./purify.es-DBmVz-Wl.js";import"./dates-CAlnO9QB.js";import{n as je}from"./copy-BCF-tANo.js";import{t as Sa}from"./copy-icon-BYNydU7b.js";import{t as it}from"./context-B3MsQb-b.js";import{n as ct}from"./ImperativeModal-D7lQ0Q7_.js";import{n as Ca,t as dt}from"./blob-D-eV0cU3.js";import"./utils-CGtUbqcR.js";import"./vega-loader.browser-BegSZk0G.js";import"./defaultLocale-YteS-k_t.js";import"./defaultLocale-B6z1Qyqt.js";import{n as Fa,t as Ma}from"./alert-DvqcBMUv.js";import{n as mt}from"./error-banner-C6aBa98y.js";import{n as Ae}from"./useAsyncData-BFC6lWG9.js";import{a as Da,o as pt,t as za,u as Pa}from"./command-CBCkexpx.js";import"./chunk-5FQGJX7Z-e_arGD4o.js";import"./html-to-image-BHdf1t5J.js";import{o as Ta}from"./focus-CXQpR65O.js";import"./react-resizable-panels.browser.esm-BUNcfKXO.js";import{a as Oa}from"./renderShortcut-DZpkrZaP.js";import{t as $a}from"./bundle.esm-BIoPrMH_.js";import{i as Ee,n as Ra,r as ht,t as ge}from"./tree-actions-Ci3CV3hN.js";import{a as Aa}from"./components-DVKf_7RU.js";import{n as Ea}from"./pathUtils-DOhgNpTR.js";import{t as Ia}from"./empty-state-CsVQSqKA.js";import{t as Ie}from"./formatting-TmuwpwTs.js";import{a as Ha,i as La,n as xt,r as ft,t as ut}from"./components-HCInimq-.js";import{n as yt,t as Va}from"./marimo-icons-BSB-Z_W3.js";import{t as Ba}from"./links-iy4RlM-h.js";var qa=re("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"}]]),Ua=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"}]]),jt=re("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"}]]),Wa=re("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=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"}]]),bt=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"}]]),Ga=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"}]]),vt=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"}]]),T=qe(At(),1),Ja=fe(),a=qe(Bt(),1);const wt=t=>{let e=(0,Ja.c)(17),{filename:n,filenameIcon:i,onBack:l,onRefresh:r,onDownload:d,actions:c}=t,h;e[0]===l?h=e[1]:(h=l&&(0,a.jsx)(I,{content:"Back to file list",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:l,children:(0,a.jsx)(Ze,{className:"h-4 w-4"})})}),e[0]=l,e[1]=h);let s;e[2]!==n||e[3]!==i?(s=n?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate",children:[i,n]}):(0,a.jsx)("span",{className:"flex-1"}),e[2]=n,e[3]=i,e[4]=s):s=e[4];let y;e[5]===r?y=e[6]:(y=r&&(0,a.jsx)(I,{content:"Refresh",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:r,children:(0,a.jsx)(lt,{className:"h-3.5 w-3.5"})})}),e[5]=r,e[6]=y);let x;e[7]===d?x=e[8]:(x=d&&(0,a.jsx)(I,{content:"Download",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:d,children:(0,a.jsx)(De,{className:"h-3.5 w-3.5"})})}),e[7]=d,e[8]=x);let p;e[9]!==c||e[10]!==y||e[11]!==x?(p=(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[y,c,x]}),e[9]=c,e[10]=y,e[11]=x,e[12]=p):p=e[12];let u;return e[13]!==h||e[14]!==s||e[15]!==p?(u=(0,a.jsxs)("div",{className:"flex items-center shrink-0 border-b px-1 gap-1",children:[h,s,p]}),e[13]=h,e[14]=s,e[15]=p,e[16]=u):u=e[16],u};var Ka=new Set(["http","file","in-memory"]);function He(t){return JSON.stringify(t).slice(1,-1)}const Nt=[{id:"read-file",label:"Insert read snippet",icon:qa,getCode:t=>{if(t.entry.kind==="directory")return null;let e=He(t.entry.path);return t.backendType==="obstore"?`_data = ${t.variableName}.get("${e}").bytes()
1
+ import{s as qe}from"./chunk-LvLJmgfZ.js";import{i as It,l as ke,n as ee,p as Ue,u as ye}from"./useEvent-D91BmmQi.js";import{t as Rt}from"./react-Bj1aDYRI.js";import{E as At,Pn as We,Si as Ge,vi as Et,vr as Ht}from"./cells-CcBfzJ1Z.js";import"./react-dom-CSu739Rf.js";import{t as fe}from"./compiler-runtime-B3qBwwSJ.js";import{_ as Me}from"./useEventListener-BR0C1MaI.js";import{t as Lt}from"./invariant-BUdrueMv.js";import{p as Vt,u as Je}from"./utils-DIGrmLDO.js";import{S as _e}from"./config-DczIUz0b.js";import{t as ie}from"./cn-DCUzRj2J.js";import{t as Bt}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-BDxedMYP.js";import{n as qt}from"./multi-map-rafH3cg3.js";import{o as Ut}from"./alert-dialog-BGBdrcqJ.js";import"./popover-UExmgBsf.js";import{a as A,c as ue,p as Wt,r as Gt,t as Jt}from"./dropdown-menu-D1A3cFC8.js";import{a as Kt,bt as De,i as Ke,o as Se}from"./JsonOutput-Bw-rSneQ.js";import{c as Yt,i as ze,r as Ce}from"./download-YUQiaxS9.js";import{r as Ye}from"./radio-group-6t7ozlnG.js";import{t as E}from"./tooltip-Gcwqb_SK.js";import{n as Xt,t as $}from"./button-D9nb17Rw.js";import{St as Zt}from"./dist-BrR4M-k3.js";import"./cjs-BRGiG41H.js";import"./main-B0OX4z33.js";import"./useNonce-DfoVjkkH.js";import{n as Qt,r as Pe}from"./requests-DIwGYs0l.js";import{t as re}from"./createLucideIcon-D5guW7EU.js";import{a as Xe,c as Ze,i as Qe,n as Fe,o as Te,r as ea,t as ta}from"./state-B34hXjp9.js";import{n as aa}from"./LazyAnyLanguageCodeMirror-BF3xpDgO.js";import{t as na}from"./x-C-6liIBr.js";import{n as Oe}from"./maps-C48Oksn0.js";import{n as $e}from"./markdown-renderer-DmnGXdCp.js";import{u as ra}from"./toDate-B5A0DFEz.js";import{t as et}from"./copy-BwrPA9zQ.js";import{t as sa}from"./eye-off-n1Li95bE.js";import{a as la,i as tt,n as at,r as oa,t as ia}from"./file-icons-CMxkj_kV.js";import{t as nt}from"./file-BrdxGLRX.js";import{i as rt,r as ca,t as st}from"./add-connection-dialog-C14LN8_M.js";import{n as Ie,t as da}from"./spinner-Bhir8k53.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-C70pv8AE.js";import{t as lt}from"./plus-BgB18UzY.js";import{t as ot}from"./refresh-cw-DHwG4Mac.js";import{t as va}from"./save-Clg5dMoP.js";import{t as wa}from"./triangle-alert-B8l157gP.js";import{n as Na,t as ka}from"./es-DaYh1PsD.js";import"./dist-DQOq2Tf-.js";import"./dist-DBiqbYe-.js";import"./dist-VjDnmGCZ.js";import"./dist-E6ttb8td.js";import"./dist-B324sPca.js";import{t as te}from"./use-toast-T0_cQDma.js";import{t as _a}from"./paths-BXWH6vv4.js";import"./session-VtovaFBS.js";import"./purify.es-DBmVz-Wl.js";import"./dates-CAlnO9QB.js";import{n as je}from"./copy-BCF-tANo.js";import{t as Sa}from"./copy-icon-BYNydU7b.js";import{t as it}from"./context-B3MsQb-b.js";import{n as ct}from"./ImperativeModal-D7lQ0Q7_.js";import{n as Ca,t as dt}from"./blob-D-eV0cU3.js";import"./utils-CGtUbqcR.js";import"./vega-loader.browser-BegSZk0G.js";import"./defaultLocale-YteS-k_t.js";import"./defaultLocale-B6z1Qyqt.js";import{n as Fa,t as Ma}from"./alert-DvqcBMUv.js";import{n as mt}from"./error-banner-C6aBa98y.js";import{n as Re}from"./useAsyncData-BFC6lWG9.js";import{a as Da,o as pt,t as za,u as Pa}from"./command-CBCkexpx.js";import"./chunk-5FQGJX7Z-e_arGD4o.js";import"./html-to-image-BHdf1t5J.js";import{o as Ta}from"./focus-CXQpR65O.js";import"./react-resizable-panels.browser.esm-BUNcfKXO.js";import{a as Oa}from"./renderShortcut-DZpkrZaP.js";import{t as $a}from"./bundle.esm-BIoPrMH_.js";import{i as Ae,n as Ia,r as ht,t as ge}from"./tree-actions-Ci3CV3hN.js";import{a as Ra}from"./components-DVKf_7RU.js";import{n as Aa}from"./pathUtils-DOhgNpTR.js";import{t as Ea}from"./empty-state-CsVQSqKA.js";import{t as Ee}from"./formatting-TmuwpwTs.js";import{a as Ha,i as La,n as xt,r as ft,t as ut}from"./components-HCInimq-.js";import{n as yt,t as Va}from"./marimo-icons-BSB-Z_W3.js";import{t as Ba}from"./links-iy4RlM-h.js";var qa=re("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"}]]),Ua=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"}]]),jt=re("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"}]]),Wa=re("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=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"}]]),bt=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"}]]),Ga=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"}]]),vt=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"}]]),T=qe(Rt(),1),Ja=fe(),a=qe(Bt(),1);const wt=t=>{let e=(0,Ja.c)(17),{filename:n,filenameIcon:i,onBack:o,onRefresh:r,onDownload:d,actions:c}=t,h;e[0]===o?h=e[1]:(h=o&&(0,a.jsx)(E,{content:"Back to file list",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:o,children:(0,a.jsx)(Ze,{className:"h-4 w-4"})})}),e[0]=o,e[1]=h);let s;e[2]!==n||e[3]!==i?(s=n?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate",children:[i,n]}):(0,a.jsx)("span",{className:"flex-1"}),e[2]=n,e[3]=i,e[4]=s):s=e[4];let y;e[5]===r?y=e[6]:(y=r&&(0,a.jsx)(E,{content:"Refresh",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:r,children:(0,a.jsx)(ot,{className:"h-3.5 w-3.5"})})}),e[5]=r,e[6]=y);let x;e[7]===d?x=e[8]:(x=d&&(0,a.jsx)(E,{content:"Download",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:d,children:(0,a.jsx)(De,{className:"h-3.5 w-3.5"})})}),e[7]=d,e[8]=x);let p;e[9]!==c||e[10]!==y||e[11]!==x?(p=(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[y,c,x]}),e[9]=c,e[10]=y,e[11]=x,e[12]=p):p=e[12];let u;return e[13]!==h||e[14]!==s||e[15]!==p?(u=(0,a.jsxs)("div",{className:"flex items-center shrink-0 border-b px-1 gap-1",children:[h,s,p]}),e[13]=h,e[14]=s,e[15]=p,e[16]=u):u=e[16],u};var Ka=new Set(["http","file","in-memory"]);function He(t){return JSON.stringify(t).slice(1,-1)}const Nt=[{id:"read-file",label:"Insert read snippet",icon:qa,getCode:t=>{if(t.entry.kind==="directory")return null;let e=He(t.entry.path);return t.backendType==="obstore"?`_data = ${t.variableName}.get("${e}").bytes()
2
2
  _data`:`_data = ${t.variableName}.cat_file("${e}")
3
3
  _data`}},{id:"download-file",label:"Insert download snippet",icon:Wa,getCode:t=>{if(t.entry.kind==="directory")return null;let e=He(t.entry.path);if(t.backendType==="obstore")return Ka.has(t.protocol)?null:`from datetime import timedelta
4
4
  from obstore import sign
@@ -7,20 +7,20 @@ signed_url = sign(
7
7
  ${t.variableName}, "GET", "${e}",
8
8
  expires_in=timedelta(hours=1),
9
9
  )
10
- signed_url`;let n=He(t.entry.path.split("/").pop()||"download");return`${t.variableName}.get("${e}", "${n}")`}}];var Ya=100*1024*1024;function Xa(t){let e=t.endsWith("/")?t.slice(0,-1):t,n=e.split("/");return n[n.length-1]||e}const Za=({entry:t,namespace:e,protocol:n,backendType:i,onBack:l})=>{let{locale:r}=it(),d=Ye(),c=Xa(t.path),h=t.mimeType||"text/plain",s=Se(h),y=s&&t.size>Ya&&t.size>0,{data:x,isPending:p,error:u,refetch:g}=Ae(async()=>{if(y)return null;let m=await Te.request({namespace:e,path:t.path,preview:!s});if(m.error)throw Error(m.error);if(!m.url)throw Error("No URL returned");if(s)return{type:"media",url:m.url};let b=await fetch(m.url);if(!b.ok)throw Error(`Failed to fetch preview: ${b.statusText}`);return{type:"text",content:await b.text()}},[e,t.path,s,y]),w=(0,T.useCallback)(async()=>{try{let m=await Te.request({namespace:e,path:t.path});if(m.error){te({title:"Download failed",description:m.error,variant:"danger"});return}m.url&&ze(m.url,m.filename??c)}catch(m){Me.error("Failed to download storage entry",m),te({title:"Download failed",description:String(m),variant:"danger"})}},[e,t.path,c]),v=Nt.map(m=>{let b=m.getCode({variableName:e,protocol:n,entry:t,backendType:i});if(b===null)return null;let f=m.icon;return(0,a.jsx)(I,{content:m.label,children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:()=>d(b),"aria-label":m.label,children:(0,a.jsx)(f,{className:"h-3.5 w-3.5"})})},m.id)}),o=(0,a.jsx)(wt,{filename:c,filenameIcon:tt(c),onBack:l,onDownload:w,actions:v}),j=({includeMime:m=!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)(Sa,{value:t.path,className:"h-3 w-3"})]}),m&&(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Type"}),m&&(0,a.jsx)("span",{children:h}),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:Ie(t.size,r)})]}),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 y?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[o,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 (",Ie(t.size,r),")."]})]}):p?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[o,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)(Re,{className:"h-4 w-4 animate-spin"}),"Loading preview..."]})]}):u?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[o,j({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-destructive",children:["Failed to load preview: ",u.message]}),(0,a.jsx)("div",{className:"px-4 pb-4",children:(0,a.jsxs)($,{variant:"secondary",size:"xs",onClick:g,children:[(0,a.jsx)(lt,{className:"h-3 w-3 mr-1"}),"Retry"]})})]}):x?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[o,j({}),(0,a.jsx)(Ke,{mimeType:h,contents:x.type==="text"?x.content:void 0,mediaSource:x.type==="media"?{url:x.url}:void 0})]}):(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[o,j({includeMime:!0}),(0,a.jsxs)("div",{className:"p-4 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(nt,{className:"h-4 w-4"}),"Preview not available for this file type."]})]})};var Le=fe(),Qa=16;function se(t){return{paddingLeft:t*Qa}}function en(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,n=e.split("/");return n[n.length-1]||e}function Ve(t,e,n,i){let l=n.toLowerCase();if(kt(t.path).toLowerCase().includes(l))return!0;if(t.kind==="directory"){let r=i.get(Xe(e,t.path));if(r)return r.some(d=>Ve(d,e,n,i))}return!1}function _t(t,e,n,i){return n.trim()?t.filter(l=>Ve(l,e,n,i)):t}var tn=t=>{let e=(0,Le.c)(36),{namespace:n,protocol:i,rootPath:l,backendType:r,prefix:d,depth:c,locale:h,searchValue:s,onOpenFile:y}=t,{entriesByPath:x}=Fe(),{entries:p,isPending:u,error:g}=Qe(n,d);if(u){let o;e[0]===c?o=e[1]:(o=se(c),e[0]=c,e[1]=o);let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)(Re,{className:"h-3 w-3 animate-spin"}),e[2]=j):j=e[2];let m;return e[3]===o?m=e[4]:(m=(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:o,children:[j,"Loading..."]}),e[3]=o,e[4]=m),m}if(g){let o;e[5]===c?o=e[6]:(o=se(c),e[5]=c,e[6]=o);let j;return e[7]!==g.message||e[8]!==o?(j=(0,a.jsxs)("div",{className:"py-1 text-xs text-destructive",style:o,children:["Failed to load: ",g.message]}),e[7]=g.message,e[8]=o,e[9]=j):j=e[9],j}if(p.length===0){let o;e[10]===c?o=e[11]:(o=se(c),e[10]=c,e[11]=o);let j;return e[12]===o?j=e[13]:(j=(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:o,children:"Empty"}),e[12]=o,e[13]=j),j}let w;if(e[14]!==r||e[15]!==p||e[16]!==c||e[17]!==x||e[18]!==h||e[19]!==n||e[20]!==y||e[21]!==i||e[22]!==l||e[23]!==s){let o=_t(p,n,s,x),j;e[25]!==r||e[26]!==c||e[27]!==h||e[28]!==n||e[29]!==y||e[30]!==i||e[31]!==l||e[32]!==s?(j=m=>(0,a.jsx)(St,{entry:m,namespace:n,protocol:i,rootPath:l,backendType:r,depth:c,locale:h,searchValue:s,onOpenFile:y},m.path),e[25]=r,e[26]=c,e[27]=h,e[28]=n,e[29]=y,e[30]=i,e[31]=l,e[32]=s,e[33]=j):j=e[33],w=o.map(j),e[14]=r,e[15]=p,e[16]=c,e[17]=x,e[18]=h,e[19]=n,e[20]=y,e[21]=i,e[22]=l,e[23]=s,e[24]=w}else w=e[24];let v;return e[34]===w?v=e[35]:(v=(0,a.jsx)(a.Fragment,{children:w}),e[34]=w,e[35]=v),v},St=({entry:t,namespace:e,protocol:n,rootPath:i,backendType:l,depth:r,locale:d,searchValue:c,onOpenFile:h})=>{var b;let[s,y]=(0,T.useState)(!1),{entriesByPath:x}=Fe(),p=Ye(),u=t.kind==="directory",g=kt(t.path),w=!!c.trim(),v=u&&w&&g.toLowerCase().includes(c.trim().toLowerCase()),o=u&&w&&!!((b=x.get(Xe(e,t.path)))!=null&&b.some(f=>Ve(f,e,c,x))),j=s||o,m=(0,T.useCallback)(async()=>{try{let f=await Te.request({namespace:e,path:t.path});if(f.error){te({title:"Download failed",description:f.error,variant:"danger"});return}f.url&&ze(f.url,f.filename??"download")}catch(f){Me.error("Failed to download storage entry",f),te({title:"Download failed",description:String(f),variant:"danger"})}},[e,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",u&&"font-medium"),style:se(r),value:`${e}:${t.path}`,onSelect:()=>{u?y(!j):h({entry:t,namespace:e,protocol:n,backendType:l})},children:[u?(0,a.jsx)(Ee,{isExpanded:j,className:"h-3 w-3"}):(0,a.jsx)("span",{className:"w-3 shrink-0"}),u?(0,a.jsx)(oa,{className:ie("h-3.5 w-3.5 shrink-0",at.directory)}):tt(g),(0,a.jsx)("span",{className:"truncate flex-1 text-left",children:g}),(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:Ie(t.size,d)}),t.lastModified!=null&&(0,a.jsx)(I,{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:en(t.lastModified,d)})}),(0,a.jsxs)(Jt,{children:[(0,a.jsx)(Wt,{asChild:!0,children:(0,a.jsx)(Ra,{iconClassName:"h-3 w-3",onClick:f=>f.stopPropagation()})}),(0,a.jsxs)(Gt,{align:"end",onClick:f=>f.stopPropagation(),onCloseAutoFocus:f=>f.preventDefault(),children:[!u&&(0,a.jsxs)(E,{onSelect:()=>h({entry:t,namespace:e,protocol:n,backendType:l}),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"]}),!u&&(0,a.jsxs)(E,{onSelect:()=>m(),children:[(0,a.jsx)(De,{className:"h-3.5 w-3.5 mr-2"}),"Download"]}),(0,a.jsx)(ue,{}),Nt.map(f=>{let k=f.getCode({variableName:e,protocol:n,entry:t,backendType:l});if(k===null)return null;let _=f.icon;return(0,a.jsxs)(E,{onSelect:()=>p(k),children:[(0,a.jsx)(_,{className:ge}),f.label]},f.id)})]})]})]})]}),u&&j&&(0,a.jsx)(tn,{namespace:e,protocol:n,rootPath:i,backendType:l,prefix:t.path,depth:r+1,locale:d,searchValue:v?"":c,onOpenFile:h})]})},an=t=>{let e=(0,Le.c)(43),{namespace:n,locale:i,searchValue:l,onOpenFile:r}=t,[d,c]=(0,T.useState)(!0),{entriesByPath:h}=Fe(),{clearNamespaceCache:s}=ea(),y=n.name??n.displayName,{entries:x,isPending:p,error:u,refetch:g}=Qe(y),w;e[0]!==s||e[1]!==y||e[2]!==g?(w=m=>{m.stopPropagation(),s(y),g()},e[0]=s,e[1]=y,e[2]=g,e[3]=w):w=e[3];let v=w,o=p?n.storageEntries:x,j;if(e[4]!==o||e[5]!==h||e[6]!==u||e[7]!==v||e[8]!==d||e[9]!==p||e[10]!==i||e[11]!==n.backendType||e[12]!==n.displayName||e[13]!==n.name||e[14]!==n.protocol||e[15]!==n.rootPath||e[16]!==y||e[17]!==r||e[18]!==l){let m=_t(o,y,l,h),b;e[20]===d?b=e[21]:(b=()=>c(!d),e[20]=d,e[21]=b);let f;e[22]===d?f=e[23]:(f=(0,a.jsx)(Ee,{isExpanded:d,className:"h-3 w-3"}),e[22]=d,e[23]=f);let k;e[24]===n.protocol?k=e[25]:(k=(0,a.jsx)(ca,{protocol:n.protocol}),e[24]=n.protocol,e[25]=k);let _;e[26]===n.displayName?_=e[27]:(_=(0,a.jsx)("span",{children:n.displayName}),e[26]=n.displayName,e[27]=_);let S;e[28]===n.name?S=e[29]:(S=n.name&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-normal",children:["(",(0,a.jsx)(Ha,{variableName:n.name}),")"]}),e[28]=n.name,e[29]=S);let C;e[30]===v?C=e[31]:(C=(0,a.jsx)(ht,{onClick:v,tooltip:"Refresh storage connection",className:"p-0",iconClassName:"h-3 w-3"}),e[30]=v,e[31]=C);let z=n.rootPath||"(root)",F;e[32]===z?F=e[33]:(F=(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-normal tabular-nums ml-auto",children:z}),e[32]=z,e[33]=F);let M;e[34]!==n.name||e[35]!==F||e[36]!==b||e[37]!==f||e[38]!==k||e[39]!==_||e[40]!==S||e[41]!==C?(M=(0,a.jsxs)(pt,{value:n.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:[f,k,_,S,C,F]}),e[34]=n.name,e[35]=F,e[36]=b,e[37]=f,e[38]=k,e[39]=_,e[40]=S,e[41]=C,e[42]=M):M=e[42],j=(0,a.jsxs)(a.Fragment,{children:[M,d&&(0,a.jsxs)(a.Fragment,{children:[p&&o.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)(Re,{className:"h-3 w-3 animate-spin"}),"Loading..."]}),u&&o.length===0&&(0,a.jsx)(Aa,{error:u,style:se(1),className:"py-1 text-xs h-auto overflow-auto max-h-32 items-start",showIcon:!1}),!p&&o.length===0&&!u&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:se(1),children:"No entries"}),l&&m.length===0&&o.length>0&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:se(1),children:"No matches"}),m.map(A=>(0,a.jsx)(St,{entry:A,namespace:y,protocol:n.protocol,rootPath:n.rootPath,backendType:n.backendType,depth:1,locale:i,searchValue:l,onOpenFile:r},A.path))]})]}),e[4]=o,e[5]=h,e[6]=u,e[7]=v,e[8]=d,e[9]=p,e[10]=i,e[11]=n.backendType,e[12]=n.displayName,e[13]=n.name,e[14]=n.protocol,e[15]=n.rootPath,e[16]=y,e[17]=r,e[18]=l,e[19]=j}else j=e[19];return j};const nn=()=>{let t=(0,Le.c)(31),{namespaces:e}=Fe(),{locale:n}=it(),[i,l]=(0,T.useState)(""),[r,d]=(0,T.useState)(null),c=!!i.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 f;return t[1]===Symbol.for("react.memo_cache_sentinel")?(f=(0,a.jsx)(Ia,{title:"No storage connected",description:b,action:(0,a.jsx)(st,{defaultTab:"storage",children:(0,a.jsxs)($,{variant:"outline",size:"sm",children:["Add remote storage",(0,a.jsx)(ot,{className:"h-4 w-4 ml-2"})]})}),icon:(0,a.jsx)(rt,{className:"h-8 w-8"})}),t[1]=f):f=t[1],f}let h;t[2]===r?h=t[3]:(h=r&&(0,a.jsx)(Za,{entry:r.entry,namespace:r.namespace,protocol:r.protocol,backendType:r.backendType,onBack:()=>d(null)}),t[2]=r,t[3]=h);let s=r&&"hidden",y;t[4]===s?y=t[5]:(y=ie("border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin",s),t[4]=s,t[5]=y);let x;t[6]===i?x=t[7]:(x=(0,a.jsx)(Da,{placeholder:"Search entries...",className:"h-6 m-1",value:i,onValueChange:l,rootClassName:"flex-1 border-b-0"}),t[6]=i,t[7]=x);let p;t[8]===c?p=t[9]:(p=c&&(0,a.jsx)($,{variant:"text",size:"xs",className:"float-right border-none px-2 m-0 h-full",onClick:()=>l(""),children:(0,a.jsx)(na,{className:"h-4 w-4"})}),t[8]=c,t[9]=p);let u;t[10]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(I,{content:"Filters loaded entries only. Expand directories to include their contents in the search.",delayDuration:200,children:(0,a.jsx)(ra,{className:"h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2"})}),t[10]=u):u=t[10];let g;t[11]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsx)(st,{defaultTab:"storage",children:(0,a.jsx)($,{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)(ot,{className:"h-4 w-4"})})}),t[11]=g):g=t[11];let w;t[12]!==x||t[13]!==p?(w=(0,a.jsxs)("div",{className:"flex items-center w-full border-b",children:[x,p,u,g]}),t[12]=x,t[13]=p,t[14]=w):w=t[14];let v;if(t[15]!==n||t[16]!==e||t[17]!==i){let b;t[19]!==n||t[20]!==i?(b=f=>(0,a.jsx)(an,{namespace:f,locale:n,searchValue:i,onOpenFile:d},f.name??f.displayName),t[19]=n,t[20]=i,t[21]=b):b=t[21],v=e.map(b),t[15]=n,t[16]=e,t[17]=i,t[18]=v}else v=t[18];let o;t[22]===v?o=t[23]:(o=(0,a.jsx)(Pa,{className:"flex flex-col",children:v}),t[22]=v,t[23]=o);let j;t[24]!==y||t[25]!==w||t[26]!==o?(j=(0,a.jsxs)(za,{className:y,shouldFilter:!1,children:[w,o]}),t[24]=y,t[25]=w,t[26]=o,t[27]=j):j=t[27];let m;return t[28]!==h||t[29]!==j?(m=(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[h,j]}),t[28]=h,t[29]=j,t[30]=m):m=t[30],m};var Ct=fe(),Ft=(0,T.createContext)(null);function rn(){return(0,T.useContext)(Ft)??void 0}var sn=t=>{let e=(0,Ct.c)(3),{children:n}=t,i=ha(),l;return e[0]!==n||e[1]!==i?(l=(0,a.jsx)(Ft.Provider,{value:i,children:n}),e[0]=n,e[1]=i,e[2]=l):l=e[2],l};const on=t=>{let e=(0,Ct.c)(5),{children:n}=t,[i,l]=(0,T.useState)(null),r;e[0]!==n||e[1]!==i?(r=i&&(0,a.jsx)(xa,{backend:ba,options:{rootElement:i},children:(0,a.jsx)(sn,{children:n})}),e[0]=n,e[1]=i,e[2]=r):r=e[2];let d;return e[3]===r?d=e[4]:(d=(0,a.jsx)("div",{ref:l,className:"contents",children:r}),e[3]=r,e[4]=d),d};var Be=new Map;const ln=({file:t,onOpenNotebook:e})=>{let{sendFileDetails:n,sendUpdateFile:i}=Pe(),l=ye(Vt),r=ye(Je),d=ye(It),[c,h]=(0,T.useState)(""),{data:s,isPending:y,error:x,setData:p,refetch:u}=Ae(async()=>{let k=await n({path:t.path}),_=k.contents||"";return h(Be.get(t.path)||_),k},[t.path]),g=async()=>{c!==(s==null?void 0:s.contents)&&await i({path:t.path,contents:c}).then(k=>{k.success&&(p(_=>({..._,contents:c})),h(c))})},w=(0,T.useRef)(c);if(w.current=c,(0,T.useEffect)(()=>()=>{if(!(s!=null&&s.contents))return;let k=w.current;k===s.contents?Be.delete(t.path):Be.set(t.path,k)},[t.path,s==null?void 0:s.contents]),x)return(0,a.jsx)(mt,{error:x});if(y||!s)return null;let v=s.mimeType||"text/plain",o=v in Kt,j=d&&s.file.isMarimoFile&&(t.path===d||t.path.endsWith(`/${d}`));if(!s.contents&&!o)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 m=(0,a.jsx)(wt,{filename:s.file.name,onRefresh:u,onDownload:r?void 0:()=>{if(s.isBase64&&s.contents){Se(v)?ze($e(s.contents,v),s.file.name):Ce(dt($e(s.contents,s.mimeType||"application/octet-stream")),s.file.name);return}Ce(new Blob([s.contents||c],{type:v}),s.file.name)},actions:(0,a.jsxs)(a.Fragment,{children:[t.isMarimoFile&&!_e()&&(0,a.jsx)(I,{content:"Open notebook",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:k=>e(k),children:(0,a.jsx)(Oe,{className:"h-3.5 w-3.5"})})}),!Se(v)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I,{content:"Copy contents to clipboard",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:async()=>{await je(c)},children:(0,a.jsx)(et,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(I,{content:Oa("global.save"),children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:g,disabled:c===s.contents,children:(0,a.jsx)(va,{className:"h-3.5 w-3.5"})})})]})]})}),b=Se(v),f=!b&&v!=="text/csv";return(0,a.jsxs)(a.Fragment,{children:[m,f&&j&&(0,a.jsxs)(Ma,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(wa,{className:"h-4 w-4"}),(0,a.jsx)(Fa,{children:"Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution."})]}),(0,a.jsx)(Ke,{mimeType:v,contents:b?void 0:f?c:s.contents??void 0,mediaSource:b?{base64:s.contents,mime:v}:void 0,readOnly:!f,onChange:h,extensions:[Zt.of([{key:l.getHotkey("global.save").key,stopPropagation:!0,run:()=>c===s.contents?!1:(g(),!0)}])]})]})},Mt=Ue(t=>{let e=t(Qt);return Lt(e,"no requestClientAtom set"),new pa({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,copyFileOrFolder:e.sendCopyFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),cn=Ue({});async function dn(){await Rt.get(Mt).refreshAll([])}var oe=" ";const Dt={directory:t=>`os.listdir("${t}")`,python:t=>`with open("${t}", "r") as _f:
11
- ${oe}...
10
+ signed_url`;let n=He(t.entry.path.split("/").pop()||"download");return`${t.variableName}.get("${e}", "${n}")`}}];var Ya=100*1024*1024;function Xa(t){let e=t.endsWith("/")?t.slice(0,-1):t,n=e.split("/");return n[n.length-1]||e}const Za=({entry:t,namespace:e,protocol:n,backendType:i,onBack:o})=>{let{locale:r}=it(),d=Ye(),c=Xa(t.path),h=t.mimeType||"text/plain",s=Se(h),y=s&&t.size>Ya&&t.size>0,{data:x,isPending:p,error:u,refetch:g}=Re(async()=>{if(y)return null;let m=await Te.request({namespace:e,path:t.path,preview:!s});if(m.error)throw Error(m.error);if(!m.url)throw Error("No URL returned");if(s)return{type:"media",url:m.url};let b=await fetch(m.url);if(!b.ok)throw Error(`Failed to fetch preview: ${b.statusText}`);return{type:"text",content:await b.text()}},[e,t.path,s,y]),w=(0,T.useCallback)(async()=>{try{let m=await Te.request({namespace:e,path:t.path});if(m.error){te({title:"Download failed",description:m.error,variant:"danger"});return}m.url&&ze(m.url,m.filename??c)}catch(m){Me.error("Failed to download storage entry",m),te({title:"Download failed",description:String(m),variant:"danger"})}},[e,t.path,c]),v=Nt.map(m=>{let b=m.getCode({variableName:e,protocol:n,entry:t,backendType:i});if(b===null)return null;let f=m.icon;return(0,a.jsx)(E,{content:m.label,children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:()=>d(b),"aria-label":m.label,children:(0,a.jsx)(f,{className:"h-3.5 w-3.5"})})},m.id)}),l=(0,a.jsx)(wt,{filename:c,filenameIcon:tt(c),onBack:o,onDownload:w,actions:v}),j=({includeMime:m=!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)(Sa,{value:t.path,className:"h-3 w-3"})]}),m&&(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Type"}),m&&(0,a.jsx)("span",{children:h}),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:Ee(t.size,r)})]}),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 y?(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 (",Ee(t.size,r),")."]})]}):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..."]})]}):u?(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: ",u.message]}),(0,a.jsx)("div",{className:"px-4 pb-4",children:(0,a.jsxs)($,{variant:"secondary",size:"xs",onClick:g,children:[(0,a.jsx)(ot,{className:"h-3 w-3 mr-1"}),"Retry"]})})]}):x?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[l,j({}),(0,a.jsx)(Ke,{mimeType:h,contents:x.type==="text"?x.content:void 0,mediaSource:x.type==="media"?{url:x.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)(nt,{className:"h-4 w-4"}),"Preview not available for this file type."]})]})};var Le=fe(),Qa=16;function se(t){return{paddingLeft:t*Qa}}function en(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,n=e.split("/");return n[n.length-1]||e}function Ve(t,e,n,i){let o=n.toLowerCase();if(kt(t.path).toLowerCase().includes(o))return!0;if(t.kind==="directory"){let r=i.get(Xe(e,t.path));if(r)return r.some(d=>Ve(d,e,n,i))}return!1}function _t(t,e,n,i){return n.trim()?t.filter(o=>Ve(o,e,n,i)):t}var tn=t=>{let e=(0,Le.c)(36),{namespace:n,protocol:i,rootPath:o,backendType:r,prefix:d,depth:c,locale:h,searchValue:s,onOpenFile:y}=t,{entriesByPath:x}=Fe(),{entries:p,isPending:u,error:g}=Qe(n,d);if(u){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 m;return e[3]===l?m=e[4]:(m=(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]=m),m}if(g){let l;e[5]===c?l=e[6]:(l=se(c),e[5]=c,e[6]=l);let j;return e[7]!==g.message||e[8]!==l?(j=(0,a.jsxs)("div",{className:"py-1 text-xs text-destructive",style:l,children:["Failed to load: ",g.message]}),e[7]=g.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]!==r||e[15]!==p||e[16]!==c||e[17]!==x||e[18]!==h||e[19]!==n||e[20]!==y||e[21]!==i||e[22]!==o||e[23]!==s){let l=_t(p,n,s,x),j;e[25]!==r||e[26]!==c||e[27]!==h||e[28]!==n||e[29]!==y||e[30]!==i||e[31]!==o||e[32]!==s?(j=m=>(0,a.jsx)(St,{entry:m,namespace:n,protocol:i,rootPath:o,backendType:r,depth:c,locale:h,searchValue:s,onOpenFile:y},m.path),e[25]=r,e[26]=c,e[27]=h,e[28]=n,e[29]=y,e[30]=i,e[31]=o,e[32]=s,e[33]=j):j=e[33],w=l.map(j),e[14]=r,e[15]=p,e[16]=c,e[17]=x,e[18]=h,e[19]=n,e[20]=y,e[21]=i,e[22]=o,e[23]=s,e[24]=w}else w=e[24];let v;return e[34]===w?v=e[35]:(v=(0,a.jsx)(a.Fragment,{children:w}),e[34]=w,e[35]=v),v},St=({entry:t,namespace:e,protocol:n,rootPath:i,backendType:o,depth:r,locale:d,searchValue:c,onOpenFile:h})=>{var b;let[s,y]=(0,T.useState)(!1),{entriesByPath:x}=Fe(),p=Ye(),u=t.kind==="directory",g=kt(t.path),w=!!c.trim(),v=u&&w&&g.toLowerCase().includes(c.trim().toLowerCase()),l=u&&w&&!!((b=x.get(Xe(e,t.path)))!=null&&b.some(f=>Ve(f,e,c,x))),j=s||l,m=(0,T.useCallback)(async()=>{try{let f=await Te.request({namespace:e,path:t.path});if(f.error){te({title:"Download failed",description:f.error,variant:"danger"});return}f.url&&ze(f.url,f.filename??"download")}catch(f){Me.error("Failed to download storage entry",f),te({title:"Download failed",description:String(f),variant:"danger"})}},[e,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",u&&"font-medium"),style:se(r),value:`${e}:${t.path}`,onSelect:()=>{u?y(!j):h({entry:t,namespace:e,protocol:n,backendType:o})},children:[u?(0,a.jsx)(Ae,{isExpanded:j,className:"h-3 w-3"}):(0,a.jsx)("span",{className:"w-3 shrink-0"}),u?(0,a.jsx)(la,{className:ie("h-3.5 w-3.5 shrink-0",at.directory)}):tt(g),(0,a.jsx)("span",{className:"truncate flex-1 text-left",children:g}),(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:Ee(t.size,d)}),t.lastModified!=null&&(0,a.jsx)(E,{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:en(t.lastModified,d)})}),(0,a.jsxs)(Jt,{children:[(0,a.jsx)(Wt,{asChild:!0,children:(0,a.jsx)(Ia,{iconClassName:"h-3 w-3",onClick:f=>f.stopPropagation()})}),(0,a.jsxs)(Gt,{align:"end",onClick:f=>f.stopPropagation(),onCloseAutoFocus:f=>f.preventDefault(),children:[!u&&(0,a.jsxs)(A,{onSelect:()=>h({entry:t,namespace:e,protocol:n,backendType:o}),children:[(0,a.jsx)(vt,{className:"h-3.5 w-3.5 mr-2"}),"View"]}),(0,a.jsxs)(A,{onSelect:async()=>{await je(t.path),te({title:"Copied to clipboard"})},children:[(0,a.jsx)(et,{className:ge}),"Copy path"]}),!u&&(0,a.jsxs)(A,{onSelect:()=>m(),children:[(0,a.jsx)(De,{className:"h-3.5 w-3.5 mr-2"}),"Download"]}),(0,a.jsx)(ue,{}),Nt.map(f=>{let k=f.getCode({variableName:e,protocol:n,entry:t,backendType:o});if(k===null)return null;let _=f.icon;return(0,a.jsxs)(A,{onSelect:()=>p(k),children:[(0,a.jsx)(_,{className:ge}),f.label]},f.id)})]})]})]})]}),u&&j&&(0,a.jsx)(tn,{namespace:e,protocol:n,rootPath:i,backendType:o,prefix:t.path,depth:r+1,locale:d,searchValue:v?"":c,onOpenFile:h})]})},an=t=>{let e=(0,Le.c)(43),{namespace:n,locale:i,searchValue:o,onOpenFile:r}=t,[d,c]=(0,T.useState)(!0),{entriesByPath:h}=Fe(),{clearNamespaceCache:s}=ea(),y=n.name??n.displayName,{entries:x,isPending:p,error:u,refetch:g}=Qe(y),w;e[0]!==s||e[1]!==y||e[2]!==g?(w=m=>{m.stopPropagation(),s(y),g()},e[0]=s,e[1]=y,e[2]=g,e[3]=w):w=e[3];let v=w,l=p?n.storageEntries:x,j;if(e[4]!==l||e[5]!==h||e[6]!==u||e[7]!==v||e[8]!==d||e[9]!==p||e[10]!==i||e[11]!==n.backendType||e[12]!==n.displayName||e[13]!==n.name||e[14]!==n.protocol||e[15]!==n.rootPath||e[16]!==y||e[17]!==r||e[18]!==o){let m=_t(l,y,o,h),b;e[20]===d?b=e[21]:(b=()=>c(!d),e[20]=d,e[21]=b);let f;e[22]===d?f=e[23]:(f=(0,a.jsx)(Ae,{isExpanded:d,className:"h-3 w-3"}),e[22]=d,e[23]=f);let k;e[24]===n.protocol?k=e[25]:(k=(0,a.jsx)(ca,{protocol:n.protocol}),e[24]=n.protocol,e[25]=k);let _;e[26]===n.displayName?_=e[27]:(_=(0,a.jsx)("span",{children:n.displayName}),e[26]=n.displayName,e[27]=_);let S;e[28]===n.name?S=e[29]:(S=n.name&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-normal",children:["(",(0,a.jsx)(Ha,{variableName:n.name}),")"]}),e[28]=n.name,e[29]=S);let C;e[30]===v?C=e[31]:(C=(0,a.jsx)(ht,{onClick:v,tooltip:"Refresh storage connection",className:"p-0",iconClassName:"h-3 w-3"}),e[30]=v,e[31]=C);let z=n.rootPath||"(root)",F;e[32]===z?F=e[33]:(F=(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-normal tabular-nums ml-auto",children:z}),e[32]=z,e[33]=F);let M;e[34]!==n.name||e[35]!==F||e[36]!==b||e[37]!==f||e[38]!==k||e[39]!==_||e[40]!==S||e[41]!==C?(M=(0,a.jsxs)(pt,{value:n.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:[f,k,_,S,C,F]}),e[34]=n.name,e[35]=F,e[36]=b,e[37]=f,e[38]=k,e[39]=_,e[40]=S,e[41]=C,e[42]=M):M=e[42],j=(0,a.jsxs)(a.Fragment,{children:[M,d&&(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..."]}),u&&l.length===0&&(0,a.jsx)(Ra,{error:u,style:se(1),className:"py-1 text-xs h-auto overflow-auto max-h-32 items-start",showIcon:!1}),!p&&l.length===0&&!u&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:se(1),children:"No entries"}),o&&m.length===0&&l.length>0&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:se(1),children:"No matches"}),m.map(R=>(0,a.jsx)(St,{entry:R,namespace:y,protocol:n.protocol,rootPath:n.rootPath,backendType:n.backendType,depth:1,locale:i,searchValue:o,onOpenFile:r},R.path))]})]}),e[4]=l,e[5]=h,e[6]=u,e[7]=v,e[8]=d,e[9]=p,e[10]=i,e[11]=n.backendType,e[12]=n.displayName,e[13]=n.name,e[14]=n.protocol,e[15]=n.rootPath,e[16]=y,e[17]=r,e[18]=o,e[19]=j}else j=e[19];return j};const nn=()=>{let t=(0,Le.c)(31),{namespaces:e}=Fe(),{locale:n}=it(),[i,o]=(0,T.useState)(""),[r,d]=(0,T.useState)(null),c=!!i.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 f;return t[1]===Symbol.for("react.memo_cache_sentinel")?(f=(0,a.jsx)(Ea,{title:"No storage connected",description:b,action:(0,a.jsx)(st,{defaultTab:"storage",children:(0,a.jsxs)($,{variant:"outline",size:"sm",children:["Add remote storage",(0,a.jsx)(lt,{className:"h-4 w-4 ml-2"})]})}),icon:(0,a.jsx)(rt,{className:"h-8 w-8"})}),t[1]=f):f=t[1],f}let h;t[2]===r?h=t[3]:(h=r&&(0,a.jsx)(Za,{entry:r.entry,namespace:r.namespace,protocol:r.protocol,backendType:r.backendType,onBack:()=>d(null)}),t[2]=r,t[3]=h);let s=r&&"hidden",y;t[4]===s?y=t[5]:(y=ie("border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin",s),t[4]=s,t[5]=y);let x;t[6]===i?x=t[7]:(x=(0,a.jsx)(Da,{placeholder:"Search entries...",className:"h-6 m-1",value:i,onValueChange:o,rootClassName:"flex-1 border-b-0"}),t[6]=i,t[7]=x);let p;t[8]===c?p=t[9]:(p=c&&(0,a.jsx)($,{variant:"text",size:"xs",className:"float-right border-none px-2 m-0 h-full",onClick:()=>o(""),children:(0,a.jsx)(na,{className:"h-4 w-4"})}),t[8]=c,t[9]=p);let u;t[10]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(E,{content:"Filters loaded entries only. Expand directories to include their contents in the search.",delayDuration:200,children:(0,a.jsx)(ra,{className:"h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2"})}),t[10]=u):u=t[10];let g;t[11]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsx)(st,{defaultTab:"storage",children:(0,a.jsx)($,{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]=g):g=t[11];let w;t[12]!==x||t[13]!==p?(w=(0,a.jsxs)("div",{className:"flex items-center w-full border-b",children:[x,p,u,g]}),t[12]=x,t[13]=p,t[14]=w):w=t[14];let v;if(t[15]!==n||t[16]!==e||t[17]!==i){let b;t[19]!==n||t[20]!==i?(b=f=>(0,a.jsx)(an,{namespace:f,locale:n,searchValue:i,onOpenFile:d},f.name??f.displayName),t[19]=n,t[20]=i,t[21]=b):b=t[21],v=e.map(b),t[15]=n,t[16]=e,t[17]=i,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]!==y||t[25]!==w||t[26]!==l?(j=(0,a.jsxs)(za,{className:y,shouldFilter:!1,children:[w,l]}),t[24]=y,t[25]=w,t[26]=l,t[27]=j):j=t[27];let m;return t[28]!==h||t[29]!==j?(m=(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[h,j]}),t[28]=h,t[29]=j,t[30]=m):m=t[30],m};var Ct=fe(),Ft=(0,T.createContext)(null);function rn(){return(0,T.useContext)(Ft)??void 0}var sn=t=>{let e=(0,Ct.c)(3),{children:n}=t,i=ha(),o;return e[0]!==n||e[1]!==i?(o=(0,a.jsx)(Ft.Provider,{value:i,children:n}),e[0]=n,e[1]=i,e[2]=o):o=e[2],o};const ln=t=>{let e=(0,Ct.c)(5),{children:n}=t,[i,o]=(0,T.useState)(null),r;e[0]!==n||e[1]!==i?(r=i&&(0,a.jsx)(xa,{backend:ba,options:{rootElement:i},children:(0,a.jsx)(sn,{children:n})}),e[0]=n,e[1]=i,e[2]=r):r=e[2];let d;return e[3]===r?d=e[4]:(d=(0,a.jsx)("div",{ref:o,className:"contents",children:r}),e[3]=r,e[4]=d),d};var Be=new Map;const on=({file:t,onOpenNotebook:e})=>{let{sendFileDetails:n,sendUpdateFile:i}=Pe(),o=ye(Vt),r=ye(Je),d=ye(Et),[c,h]=(0,T.useState)(""),{data:s,isPending:y,error:x,setData:p,refetch:u}=Re(async()=>{let k=await n({path:t.path}),_=k.contents||"";return h(Be.get(t.path)||_),k},[t.path]),g=async()=>{c!==(s==null?void 0:s.contents)&&await i({path:t.path,contents:c}).then(k=>{k.success&&(p(_=>({..._,contents:c})),h(c))})},w=(0,T.useRef)(c);if(w.current=c,(0,T.useEffect)(()=>()=>{if(!(s!=null&&s.contents))return;let k=w.current;k===s.contents?Be.delete(t.path):Be.set(t.path,k)},[t.path,s==null?void 0:s.contents]),x)return(0,a.jsx)(mt,{error:x});if(y||!s)return null;let v=s.mimeType||"text/plain",l=v in Kt,j=d&&s.file.isMarimoFile&&(t.path===d||t.path.endsWith(`/${d}`));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 m=(0,a.jsx)(wt,{filename:s.file.name,onRefresh:u,onDownload:r?void 0:()=>{if(s.isBase64&&s.contents){Se(v)?ze($e(s.contents,v),s.file.name):Ce(dt($e(s.contents,s.mimeType||"application/octet-stream")),s.file.name);return}Ce(new Blob([s.contents||c],{type:v}),s.file.name)},actions:(0,a.jsxs)(a.Fragment,{children:[t.isMarimoFile&&!_e()&&(0,a.jsx)(E,{content:"Open notebook",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:k=>e(k),children:(0,a.jsx)(Oe,{className:"h-3.5 w-3.5"})})}),!Se(v)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(E,{content:"Copy contents to clipboard",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:async()=>{await je(c)},children:(0,a.jsx)(et,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(E,{content:Oa("global.save"),children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:g,disabled:c===s.contents,children:(0,a.jsx)(va,{className:"h-3.5 w-3.5"})})})]})]})}),b=Se(v),f=!b&&v!=="text/csv";return(0,a.jsxs)(a.Fragment,{children:[m,f&&j&&(0,a.jsxs)(Ma,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(wa,{className:"h-4 w-4"}),(0,a.jsx)(Fa,{children:"Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution."})]}),(0,a.jsx)(Ke,{mimeType:v,contents:b?void 0:f?c:s.contents??void 0,mediaSource:b?{base64:s.contents,mime:v}:void 0,readOnly:!f,onChange:h,extensions:[Zt.of([{key:o.getHotkey("global.save").key,stopPropagation:!0,run:()=>c===s.contents?!1:(g(),!0)}])]})]})},Mt=Ue(t=>{let e=t(Qt);return Lt(e,"no requestClientAtom set"),new pa({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,copyFileOrFolder:e.sendCopyFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),cn=Ue({});async function dn(){await It.get(Mt).refreshAll([])}var le=" ";const Dt={directory:t=>`os.listdir("${t}")`,python:t=>`with open("${t}", "r") as _f:
11
+ ${le}...
12
12
  `,json:t=>`with open("${t}", "r") as _f:
13
- ${oe}_data = json.load(_f)
13
+ ${le}_data = json.load(_f)
14
14
  `,code:t=>`with open("${t}", "r") as _f:
15
- ${oe}...
15
+ ${le}...
16
16
  `,text:t=>`with open("${t}", "r") as _f:
17
- ${oe}...
17
+ ${le}...
18
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
- ${oe}...
19
+ ${le}...
20
20
  `,zip:t=>`with open("${t}", "rb") as _f:
21
- ${oe}...
21
+ ${le}...
22
22
  `,data:t=>`with open("${t}", "r") as _f:
23
- ${oe}...
23
+ ${le}...
24
24
  `,unknown:t=>`with open("${t}", "r") as _f:
25
- ${oe}...
26
- `};var mn=fe(),pn=1024*1024*100;function zt(t){let e=(0,mn.c)(7),n;e[0]===t?n=e[1]:(n=t===void 0?{}:t,e[0]=t,e[1]=n);let i=n,{sendCreateFileOrFolder:l}=Pe(),r;e[2]===l?r=e[3]:(r=async c=>{if(c.length===0)return;let h=c.length===1;await Yt(h?"Uploading file...":"Uploading files...",async s=>{s.addTotal(c.length);for(let y of c){let x=jn(yn(y)),p="";x&&(p=_a.guessDeliminator(x).dirname(x));let u=(await Ca(y)).split(",")[1];await l({path:p,type:"file",name:y.name,contents:u}),s.increment(1)}await dn()},{title:h?"File uploaded":`${c.length} files uploaded`})},e[2]=l,e[3]=r);let d;return e[4]!==i||e[5]!==r?(d={multiple:!0,maxSize:pn,onError:un,onDropRejected:hn,onDrop:r,...i},e[4]=i,e[5]=r,e[6]=d):d=e[6],ka(d)}function hn(t){te({title:"File upload failed",description:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:t.map(xn)}),variant:"danger"})}function xn(t){return(0,a.jsxs)("div",{children:[t.file.name," (",t.errors.map(fn).join(", "),")"]},t.file.name)}function fn(t){return t.message}function un(t){Me.error(t),te({title:"File upload failed",description:t.message,variant:"danger"})}function yn(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 jn(t){if(t)return t.replace(/^\/+/,"")}var be=fe(),gn=Ge("marimo:showHiddenFiles",!0,We,{getOnInit:!0}),Pt=T.createContext(null);const bn=t=>{let e=(0,be.c)(72),{height:n}=t,i=(0,T.useRef)(null),l=rn(),[r]=ke(Mt),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];let[c,h]=(0,T.useState)(d),[s,y]=(0,T.useState)(null),[x,p]=ke(gn),{openPrompt:u}=ct(),[g,w]=ke(cn),v;e[1]===r?v=e[2]:(v=()=>r.initialize(h),e[1]=r,e[2]=v);let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[3]=o):o=e[3];let{isPending:j,error:m}=Ae(v,o),b;e[4]!==g||e[5]!==r?(b=()=>r.refreshAll(Object.keys(g).filter(N=>g[N])),e[4]=g,e[5]=r,e[6]=b):b=e[6];let f=ee(b),k;e[7]!==p||e[8]!==x?(k=()=>{p(!x)},e[7]=p,e[8]=x,e[9]=k):k=e[9];let _=ee(k),S;e[10]!==u||e[11]!==r?(S=async()=>{u({title:"Folder name",onConfirm:async N=>{r.createFolder(N,null)}})},e[10]=u,e[11]=r,e[12]=S):S=e[12];let C=ee(S),z;e[13]!==u||e[14]!==r?(z=async()=>{u({title:"File name",onConfirm:async N=>{r.createFile({name:N,parentId:null})}})},e[13]=u,e[14]=r,e[15]=z):z=e[15];let F=ee(z),M;e[16]!==u||e[17]!==r?(M=async()=>{u({title:"Notebook name",onConfirm:async N=>{r.createFile({name:N,parentId:null,type:"notebook"})}})},e[16]=u,e[17]=r,e[18]=M):M=e[18];let A=ee(M),R;e[19]===w?R=e[20]:(R=()=>{var N;(N=i.current)==null||N.closeAll(),w({})},e[19]=w,e[20]=R);let Z=ee(R),J;e[21]!==c||e[22]!==x?(J=Ot(c,x),e[21]=c,e[22]=x,e[23]=J):J=e[23];let le=J;if(j){let N;return e[24]===Symbol.for("react.memo_cache_sentinel")?(N=(0,a.jsx)(da,{size:"medium",centered:!0}),e[24]=N):N=e[24],N}if(m){let N;return e[25]===m?N=e[26]:(N=(0,a.jsx)(mt,{error:m}),e[25]=m,e[26]=N),N}if(s){let N;e[27]===Symbol.for("react.memo_cache_sentinel")?(N=()=>y(null),e[27]=N):N=e[27];let P;e[28]===Symbol.for("react.memo_cache_sentinel")?(P=(0,a.jsx)($,{onClick:N,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:(0,a.jsx)(Ze,{size:16})}),e[28]=P):P=e[28];let O;e[29]===s.name?O=e[30]:(O=(0,a.jsxs)("div",{className:"flex items-center pl-1 pr-3 shrink-0 border-b justify-between",children:[P,(0,a.jsx)("span",{className:"font-bold",children:s.name})]}),e[29]=s.name,e[30]=O);let G;e[31]!==s.path||e[32]!==r?(G=ne=>Tt(ne,r.relativeFromRoot(s.path)),e[31]=s.path,e[32]=r,e[33]=G):G=e[33];let Y;e[34]!==s||e[35]!==G?(Y=(0,a.jsx)(T.Suspense,{children:(0,a.jsx)(ln,{onOpenNotebook:G,file:s})}),e[34]=s,e[35]=G,e[36]=Y):Y=e[36];let X;return e[37]!==O||e[38]!==Y?(X=(0,a.jsxs)(a.Fragment,{children:[O,Y]}),e[37]=O,e[38]=Y,e[39]=X):X=e[39],X}let H;e[40]!==Z||e[41]!==F||e[42]!==C||e[43]!==A||e[44]!==_||e[45]!==f||e[46]!==r?(H=(0,a.jsx)(wn,{onRefresh:f,onHidden:_,onCreateFile:F,onCreateNotebook:A,onCreateFolder:C,onCollapseAll:Z,tree:r}),e[40]=Z,e[41]=F,e[42]=C,e[43]=A,e[44]=_,e[45]=f,e[46]=r,e[47]=H):H=e[47];let Q=n-33,L,V,B;e[48]===r?(L=e[49],V=e[50],B=e[51]):(L=async N=>{let{ids:P}=N;for(let O of P)await r.delete(O)},V=async N=>{let{id:P,name:O}=N;await r.rename(P,O)},B=async N=>{let{dragIds:P,parentId:O}=N;await r.move(P,O)},e[48]=r,e[49]=L,e[50]=V,e[51]=B);let K;e[52]===Symbol.for("react.memo_cache_sentinel")?(K=N=>{let P=N[0];P&&(P.data.isDirectory||y(P.data))},e[52]=K):K=e[52];let q;e[53]!==g||e[54]!==w||e[55]!==r?(q=async N=>{if(await r.expand(N)){let P=g[N]??!1;w({...g,[N]:!P})}},e[53]=g,e[54]=w,e[55]=r,e[56]=q):q=e[56];let U;e[57]!==l||e[58]!==g||e[59]!==Q||e[60]!==L||e[61]!==V||e[62]!==B||e[63]!==q||e[64]!==le?(U=(0,a.jsx)(ua,{width:"100%",ref:i,height:Q,className:"h-full",data:le,initialOpenState:g,openByDefault:!1,dndManager:l,renderCursor:Cn,disableDrop:Fn,onDelete:L,onRename:V,onMove:B,onSelect:K,onToggle:q,padding:15,rowHeight:30,indent:vn,overscanCount:1e3,disableMultiSelection:!0,children:kn}),e[57]=l,e[58]=g,e[59]=Q,e[60]=L,e[61]=V,e[62]=B,e[63]=q,e[64]=le,e[65]=U):U=e[65];let W;e[66]!==U||e[67]!==r?(W=(0,a.jsx)(Pt,{value:r,children:U}),e[66]=U,e[67]=r,e[68]=W):W=e[68];let ae;return e[69]!==H||e[70]!==W?(ae=(0,a.jsxs)(a.Fragment,{children:[H,W]}),e[69]=H,e[70]=W,e[71]=ae):ae=e[71],ae};var vn=15,wn=t=>{let e=(0,be.c)(37),{onRefresh:n,onHidden:i,onCreateFile:l,onCreateNotebook:r,onCreateFolder:d,onCollapseAll:c}=t,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={noDrag:!0,noDragEventsBubbling:!0},e[0]=h):h=e[0];let{getRootProps:s,getInputProps:y}=zt(h),x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=(0,a.jsx)(yt,{size:16}),e[1]=x):x=e[1];let p;e[2]===r?p=e[3]:(p=(0,a.jsx)(I,{content:"Add notebook",children:(0,a.jsx)($,{"data-testid":"file-explorer-add-notebook-button",onClick:r,variant:"text",size:"xs",children:x})}),e[2]=r,e[3]=p);let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(jt,{size:16}),e[4]=u):u=e[4];let g;e[5]===l?g=e[6]:(g=(0,a.jsx)(I,{content:"Add file",children:(0,a.jsx)($,{"data-testid":"file-explorer-add-file-button",onClick:l,variant:"text",size:"xs",children:u})}),e[5]=l,e[6]=g);let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsx)(gt,{size:16}),e[7]=w):w=e[7];let v;e[8]===d?v=e[9]:(v=(0,a.jsx)(I,{content:"Add folder",children:(0,a.jsx)($,{"data-testid":"file-explorer-add-folder-button",onClick:d,variant:"text",size:"xs",children:w})}),e[8]=d,e[9]=v);let o;e[10]===s?o=e[11]:(o=s({}),e[10]=s,e[11]=o);let j,m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=Xt({variant:"text",size:"xs"}),j=(0,a.jsx)(Na,{size:16}),e[12]=j,e[13]=m):(j=e[12],m=e[13]);let b;e[14]===o?b=e[15]:(b=(0,a.jsx)(I,{content:"Upload file",children:(0,a.jsx)("button",{"data-testid":"file-explorer-upload-button",...o,className:m,children:j})}),e[14]=o,e[15]=b);let f;e[16]===y?f=e[17]:(f=y({}),e[16]=y,e[17]=f);let k;e[18]===f?k=e[19]:(k=(0,a.jsx)("input",{...f,type:"file"}),e[18]=f,e[19]=k);let _;e[20]===n?_=e[21]:(_=(0,a.jsx)(ht,{"data-testid":"file-explorer-refresh-button",onClick:n}),e[20]=n,e[21]=_);let S;e[22]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)(sa,{size:16}),e[22]=S):S=e[22];let C;e[23]===i?C=e[24]:(C=(0,a.jsx)(I,{content:"Toggle hidden files",children:(0,a.jsx)($,{"data-testid":"file-explorer-hidden-files-button",onClick:i,variant:"text",size:"xs",children:S})}),e[23]=i,e[24]=C);let z;e[25]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsx)(Ua,{size:16}),e[25]=z):z=e[25];let F;e[26]===c?F=e[27]:(F=(0,a.jsx)(I,{content:"Collapse all folders",children:(0,a.jsx)($,{"data-testid":"file-explorer-collapse-button",onClick:c,variant:"text",size:"xs",children:z})}),e[26]=c,e[27]=F);let M;return e[28]!==b||e[29]!==k||e[30]!==_||e[31]!==C||e[32]!==F||e[33]!==p||e[34]!==g||e[35]!==v?(M=(0,a.jsxs)("div",{className:"flex items-center justify-end px-2 shrink-0 border-b",children:[p,g,v,b,k,_,C,F]}),e[28]=b,e[29]=k,e[30]=_,e[31]=C,e[32]=F,e[33]=p,e[34]=g,e[35]=v,e[36]=M):M=e[36],M},Nn=t=>{let e=(0,be.c)(9),{node:n,onOpenMarimoFile:i}=t,l;e[0]===n?l=e[1]:(l=c=>{n.data.isDirectory||(c.stopPropagation(),n.select())},e[0]=n,e[1]=l);let r;e[2]!==n.data.isMarimoFile||e[3]!==i?(r=n.data.isMarimoFile&&!_e()&&(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:i,children:["open ",(0,a.jsx)(Oe,{className:"inline ml-1",size:12})]}),e[2]=n.data.isMarimoFile,e[3]=i,e[4]=r):r=e[4];let d;return e[5]!==n.data.name||e[6]!==l||e[7]!==r?(d=(0,a.jsxs)("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:l,children:[n.data.name,r]}),e[5]=n.data.name,e[6]=l,e[7]=r,e[8]=d):d=e[8],d},kn=t=>{let e=(0,be.c)(116),{node:n,style:i,dragHandle:l}=t,{openFile:r,sendFileDetails:d}=Pe(),c=ye(Je),h;e[0]!==n.data.isDirectory||e[1]!==n.data.name?(h=n.data.isDirectory?"directory":la(n.data.name),e[0]=n.data.isDirectory,e[1]=n.data.name,e[2]=h):h=e[2];let s=h,y=ia[s],{openConfirm:x,openPrompt:p}=ct(),{createNewCell:u}=Et(),g=Ta(),w;e[3]!==u||e[4]!==g?(w=D=>{u({code:D,before:!1,cellId:g??"__end__"})},e[3]=u,e[4]=g,e[5]=w):w=e[5];let v=w,o=(0,T.use)(Pt),j;e[6]!==n.data.path||e[7]!==o?(j=async D=>{Tt(D,o?o.relativeFromRoot(n.data.path):n.data.path)},e[6]=n.data.path,e[7]=o,e[8]=j):j=e[8];let m=j,b;e[9]!==n.data.name||e[10]!==n.id||e[11]!==n.tree||e[12]!==x?(b=async D=>{D.stopPropagation(),D.preventDefault(),x({title:"Delete file",description:`Are you sure you want to delete ${n.data.name}?`,confirmAction:(0,a.jsx)(Ut,{onClick:async()=>{await n.tree.delete(n.id)},"aria-label":"Confirm",children:"Delete"})})},e[9]=n.data.name,e[10]=n.id,e[11]=n.tree,e[12]=x,e[13]=b):b=e[13];let f=b,k;e[14]!==n||e[15]!==p||e[16]!==o?(k=async()=>{n.open(),p({title:"Folder name",onConfirm:async D=>{o==null||o.createFolder(D,n.id)}})},e[14]=n,e[15]=p,e[16]=o,e[17]=k):k=e[17];let _=ee(k),S;e[18]!==n||e[19]!==p||e[20]!==o?(S=async()=>{n.open(),p({title:"File name",onConfirm:async D=>{o==null||o.createFile({name:D,parentId:n.id})}})},e[18]=n,e[19]=p,e[20]=o,e[21]=S):S=e[21];let C=ee(S),z;e[22]!==n||e[23]!==p||e[24]!==o?(z=async()=>{n.open(),p({title:"Notebook name",onConfirm:async D=>{o==null||o.createFile({name:D,parentId:n.id,type:"notebook"})}})},e[22]=n,e[23]=p,e[24]=o,e[25]=z):z=e[25];let F=ee(z),M;e[26]!==n.data.name||e[27]!==n.id||e[28]!==o?(M=async()=>{o&&await o.copy(n.id,Ea(n.data.name))},e[26]=n.data.name,e[27]=n.id,e[28]=o,e[29]=M):M=e[29];let A=ee(M),R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=ie("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),e[30]=R):R=e[30];let Z,J;e[31]===n?(Z=e[32],J=e[33]):(Z=D=>{D.stopPropagation(),n.data.isDirectory&&n.toggle()},J=(0,a.jsx)(_n,{node:n}),e[31]=n,e[32]=Z,e[33]=J);let le=n.willReceiveDrop&&n.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground",H;e[34]===le?H=e[35]:(H=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",le),e[34]=le,e[35]=H);let Q;e[36]!==y||e[37]!==s||e[38]!==n.data.isMarimoFile?(Q=n.data.isMarimoFile?(0,a.jsx)(Va,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}):(0,a.jsx)(y,{className:ie("w-5 h-5 shrink-0 mr-2",at[s]),strokeWidth:1.5}),e[36]=y,e[37]=s,e[38]=n.data.isMarimoFile,e[39]=Q):Q=e[39];let L;e[40]!==m||e[41]!==n?(L=n.isEditing?(0,a.jsx)(ga,{node:n}):(0,a.jsx)(Nn,{node:n,onOpenMarimoFile:m}),e[40]=m,e[41]=n,e[42]=L):L=e[42];let V;e[43]===n?V=e[44]:(V=!n.data.isDirectory&&(0,a.jsxs)(E,{onSelect:()=>n.select(),children:[(0,a.jsx)(vt,{className:"h-3.5 w-3.5 mr-2"}),"Open file"]}),e[43]=n,e[44]=V);let B;e[45]!==n.data.isDirectory||e[46]!==n.data.path||e[47]!==r?(B=!n.data.isDirectory&&!_e()&&(0,a.jsxs)(E,{onSelect:()=>{r({path:n.data.path})},children:[(0,a.jsx)(Oe,{className:"h-3.5 w-3.5 mr-2"}),"Open file in external editor"]}),e[45]=n.data.isDirectory,e[46]=n.data.path,e[47]=r,e[48]=B):B=e[48];let K;e[49]!==C||e[50]!==_||e[51]!==F||e[52]!==n.data.isDirectory?(K=n.data.isDirectory&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(E,{onSelect:()=>F(),children:[(0,a.jsx)(yt,{className:"h-3.5 w-3.5 mr-2"}),"Create notebook"]}),(0,a.jsxs)(E,{onSelect:()=>C(),children:[(0,a.jsx)(jt,{className:"h-3.5 w-3.5 mr-2"}),"Create file"]}),(0,a.jsxs)(E,{onSelect:()=>_(),children:[(0,a.jsx)(gt,{className:"h-3.5 w-3.5 mr-2"}),"Create folder"]}),(0,a.jsx)(ue,{})]}),e[49]=C,e[50]=_,e[51]=F,e[52]=n.data.isDirectory,e[53]=K):K=e[53];let q;e[54]===n?q=e[55]:(q=(0,a.jsx)(ma,{onSelect:()=>n.edit()}),e[54]=n,e[55]=q);let U;e[56]===A?U=e[57]:(U=(0,a.jsx)(ja,{onSelect:A}),e[56]=A,e[57]=U);let W;e[58]===n.data.path?W=e[59]:(W=async()=>{await je(n.data.path),te({title:"Copied to clipboard"})},e[58]=n.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 N;e[61]===W?N=e[62]:(N=(0,a.jsxs)(E,{onSelect:W,children:[ae,"Copy path"]}),e[61]=W,e[62]=N);let P;e[63]!==n.data.path||e[64]!==o?(P=o&&(0,a.jsxs)(E,{onSelect:async()=>{await je(o.relativeFromRoot(n.data.path)),te({title:"Copied to clipboard"})},children:[(0,a.jsx)(bt,{className:"h-3.5 w-3.5 mr-2"}),"Copy relative path"]}),e[63]=n.data.path,e[64]=o,e[65]=P):P=e[65];let O;e[66]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(ue,{}),e[66]=O):O=e[66];let G;e[67]!==s||e[68]!==v||e[69]!==n.data?(G=()=>{let{path:D}=n.data;v(Dt[s](D))},e[67]=s,e[68]=v,e[69]=n.data,e[70]=G):G=e[70];let Y;e[71]===Symbol.for("react.memo_cache_sentinel")?(Y=(0,a.jsx)(aa,{className:ge}),e[71]=Y):Y=e[71];let X;e[72]===G?X=e[73]:(X=(0,a.jsxs)(E,{onSelect:G,children:[Y,"Insert snippet for reading file"]}),e[72]=G,e[73]=X);let ne;e[74]!==s||e[75]!==n.data?(ne=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:D}=n.data;await je(Dt[s](D))},e[74]=s,e[75]=n.data,e[76]=ne):ne=e[76];let ve;e[77]===Symbol.for("react.memo_cache_sentinel")?(ve=(0,a.jsx)(Ht,{className:ge}),e[77]=ve):ve=e[77];let ce;e[78]===ne?ce=e[79]:(ce=(0,a.jsxs)(E,{onSelect:ne,children:[ve,"Copy snippet for reading file"]}),e[78]=ne,e[79]=ce);let de;e[80]!==m||e[81]!==n.data.isMarimoFile?(de=n.data.isMarimoFile&&!_e()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ue,{}),(0,a.jsxs)(E,{onSelect:m,children:[(0,a.jsx)(Ga,{className:"h-3.5 w-3.5 mr-2"}),"Open notebook"]})]}),e[80]=m,e[81]=n.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]!==n.data.isDirectory||e[86]!==n.data.name||e[87]!==n.data.path||e[88]!==d?(me=!n.data.isDirectory&&!c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(E,{onSelect:async()=>{let D=await d({path:n.data.path});D.isBase64&&D.contents?Ce(dt($e(D.contents,D.mimeType||"application/octet-stream")),n.data.name):Ce(new Blob([D.contents||""]),n.data.name)},children:[(0,a.jsx)(De,{className:"h-3.5 w-3.5 mr-2"}),"Download"]}),(0,a.jsx)(ue,{})]}),e[84]=c,e[85]=n.data.isDirectory,e[86]=n.data.name,e[87]=n.data.path,e[88]=d,e[89]=me):me=e[89];let pe;e[90]===f?pe=e[91]:(pe=(0,a.jsx)(ya,{onSelect:f}),e[90]=f,e[91]=pe);let he;e[92]!==V||e[93]!==B||e[94]!==K||e[95]!==q||e[96]!==U||e[97]!==N||e[98]!==P||e[99]!==X||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:[V,B,K,q,U,N,P,O,X,ce,de,we,me,pe]}),e[92]=V,e[93]=B,e[94]=K,e[95]=q,e[96]=U,e[97]=N,e[98]=P,e[99]=X,e[100]=ce,e[101]=de,e[102]=me,e[103]=pe,e[104]=he):he=e[104];let xe;e[105]!==H||e[106]!==Q||e[107]!==L||e[108]!==he?(xe=(0,a.jsxs)("span",{className:H,children:[Q,L,he]}),e[105]=H,e[106]=Q,e[107]=L,e[108]=he,e[109]=xe):xe=e[109];let Ne;return e[110]!==l||e[111]!==i||e[112]!==Z||e[113]!==J||e[114]!==xe?(Ne=(0,a.jsxs)("div",{style:i,ref:l,className:R,draggable:!0,onClick:Z,children:[J,xe]}),e[110]=l,e[111]=i,e[112]=Z,e[113]=J,e[114]=xe,e[115]=Ne):Ne=e[115],Ne},_n=t=>{let e=(0,be.c)(3),{node:n}=t;if(!n.data.isDirectory){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)("span",{className:"w-4 h-4 shrink-0"}),e[0]=l):l=e[0],l}let i;return e[1]===n.isOpen?i=e[2]:(i=(0,a.jsx)(Ee,{isExpanded:n.isOpen,className:"w-4 h-4"}),e[1]=n.isOpen,e[2]=i),i};function Tt(t,e){t.stopPropagation(),t.preventDefault(),Ba(e)}function Ot(t,e){if(e)return t;let n=[];for(let i of t){if(Sn(i.name))continue;let l=i;if(i.children){let r=Ot(i.children,e);r!==i.children&&(l={...i,children:r})}n.push(l)}return n}function Sn(t){return!!t.startsWith(".")}function Cn(){return null}function Fn(t){let{parentNode:e}=t;return!e.data.isDirectory}var $t=fe(),Mn=Ge("marimo:file-explorer-panel:state",{openSections:["files"],hasUserInteracted:!1},We),Dn=t=>{let e=(0,$t.c)(20),{height:n}=t,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={noClick:!0,noKeyboard:!0},e[0]=i):i=e[0];let{getRootProps:l,getInputProps:r,isDragActive:d}=zt(i),c;e[1]===l?c=e[2]:(c=l(),e[1]=l,e[2]=c);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=ie("flex flex-col overflow-hidden relative"),e[3]=h):h=e[3];let s;e[4]===n?s=e[5]:(s={height:n},e[4]=n,e[5]=s);let y;e[6]===r?y=e[7]:(y=r(),e[6]=r,e[7]=y);let x;e[8]===y?x=e[9]:(x=(0,a.jsx)("input",{...y}),e[8]=y,e[9]=x);let p;e[10]===d?p=e[11]:(p=d&&(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]=d,e[11]=p);let u;e[12]===n?u=e[13]:(u=(0,a.jsx)(bn,{height:n}),e[12]=n,e[13]=u);let g;return e[14]!==c||e[15]!==s||e[16]!==x||e[17]!==p||e[18]!==u?(g=(0,a.jsx)(on,{children:(0,a.jsxs)("div",{...c,className:h,style:s,children:[x,p,u]})}),e[14]=c,e[15]=s,e[16]=x,e[17]=p,e[18]=u,e[19]=g):g=e[19],g},zn=33,Pn=()=>{let t=(0,$t.c)(36),{ref:e,height:n}=$a(),i=n===void 0?500:n,[l,r]=ke(Mn),d=ye(ta).length,c;e:{if(!l.hasUserInteracted&&d>0){if(l.openSections.includes("remote-storage")){c=l.openSections;break e}let R;t[0]===l.openSections?R=t[1]:(R=[...l.openSections,"remote-storage"],t[0]=l.openSections,t[1]=R),c=R;break e}c=l.openSections}let h=c,s;t[2]===r?s=t[3]:(s=R=>{r({openSections:R,hasUserInteracted:!0})},t[2]=r,t[3]=s);let y=s,x=i-zn*2,p;t[4]===h?p=t[5]:(p=h.includes("remote-storage"),t[4]=h,t[5]=p);let u=p,g;t[6]!==h||t[7]!==u?(g=u&&h.includes("files"),t[6]=h,t[7]=u,t[8]=g):g=t[8];let w=g,v;t[9]!==x||t[10]!==w?(v=w?Math.round(x*.4):x,t[9]=x,t[10]=w,t[11]=v):v=t[11];let o=v,j=Math.max(200,w?x-o:x),m;t[12]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(rt,{className:"w-4 h-4"}),t[12]=m):m=t[12];let b;t[13]===d?b=t[14]:(b=d>0&&(0,a.jsx)(La,{children:d}),t[13]=d,t[14]=b);let f;t[15]===b?f=t[16]:(f=(0,a.jsxs)(ft,{children:[m," Remote storage",b]}),t[15]=b,t[16]=f);let k;t[17]===o?k=t[18]:(k={maxHeight:o},t[17]=o,t[18]=k);let _;t[19]===Symbol.for("react.memo_cache_sentinel")?(_=(0,a.jsx)(nn,{}),t[19]=_):_=t[19];let S;t[20]===k?S=t[21]:(S=(0,a.jsx)(ut,{className:"overflow-auto",style:k,children:_}),t[20]=k,t[21]=S);let C;t[22]!==S||t[23]!==f?(C=(0,a.jsxs)(xt,{value:"remote-storage",children:[f,S]}),t[22]=S,t[23]=f,t[24]=C):C=t[24];let z;t[25]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsxs)(ft,{children:[(0,a.jsx)(nt,{className:"w-4 h-4"}),"Files"]}),t[25]=z):z=t[25];let F;t[26]===j?F=t[27]:(F=(0,a.jsxs)(xt,{value:"files",children:[z,(0,a.jsx)(ut,{children:(0,a.jsx)(Dn,{height:j})})]}),t[26]=j,t[27]=F);let M;t[28]!==y||t[29]!==h||t[30]!==C||t[31]!==F?(M=(0,a.jsxs)(qt,{type:"multiple",value:h,onValueChange:y,children:[C,F]}),t[28]=y,t[29]=h,t[30]=C,t[31]=F,t[32]=M):M=t[32];let A;return t[33]!==e||t[34]!==M?(A=(0,a.jsx)("div",{ref:e,className:"h-full overflow-auto",children:M}),t[33]=e,t[34]=M,t[35]=A):A=t[35],A};export{Pn as default};
25
+ ${le}...
26
+ `};var mn=fe(),pn=1024*1024*100;function zt(t){let e=(0,mn.c)(7),n;e[0]===t?n=e[1]:(n=t===void 0?{}:t,e[0]=t,e[1]=n);let i=n,{sendCreateFileOrFolder:o}=Pe(),r;e[2]===o?r=e[3]:(r=async c=>{if(c.length===0)return;let h=c.length===1;await Yt(h?"Uploading file...":"Uploading files...",async s=>{s.addTotal(c.length);for(let y of c){let x=jn(yn(y)),p="";x&&(p=_a.guessDeliminator(x).dirname(x));let u=(await Ca(y)).split(",")[1];await o({path:p,type:"file",name:y.name,contents:u}),s.increment(1)}await dn()},{title:h?"File uploaded":`${c.length} files uploaded`})},e[2]=o,e[3]=r);let d;return e[4]!==i||e[5]!==r?(d={multiple:!0,maxSize:pn,onError:un,onDropRejected:hn,onDrop:r,...i},e[4]=i,e[5]=r,e[6]=d):d=e[6],ka(d)}function hn(t){te({title:"File upload failed",description:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:t.map(xn)}),variant:"danger"})}function xn(t){return(0,a.jsxs)("div",{children:[t.file.name," (",t.errors.map(fn).join(", "),")"]},t.file.name)}function fn(t){return t.message}function un(t){Me.error(t),te({title:"File upload failed",description:t.message,variant:"danger"})}function yn(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 jn(t){if(t)return t.replace(/^\/+/,"")}var be=fe(),gn=Ge("marimo:showHiddenFiles",!0,We,{getOnInit:!0}),Pt=T.createContext(null);const bn=t=>{let e=(0,be.c)(72),{height:n}=t,i=(0,T.useRef)(null),o=rn(),[r]=ke(Mt),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];let[c,h]=(0,T.useState)(d),[s,y]=(0,T.useState)(null),[x,p]=ke(gn),{openPrompt:u}=ct(),[g,w]=ke(cn),v;e[1]===r?v=e[2]:(v=()=>r.initialize(h),e[1]=r,e[2]=v);let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=[],e[3]=l):l=e[3];let{isPending:j,error:m}=Re(v,l),b;e[4]!==g||e[5]!==r?(b=()=>r.refreshAll(Object.keys(g).filter(N=>g[N])),e[4]=g,e[5]=r,e[6]=b):b=e[6];let f=ee(b),k;e[7]!==p||e[8]!==x?(k=()=>{p(!x)},e[7]=p,e[8]=x,e[9]=k):k=e[9];let _=ee(k),S;e[10]!==u||e[11]!==r?(S=async()=>{u({title:"Folder name",onConfirm:async N=>{r.createFolder(N,null)}})},e[10]=u,e[11]=r,e[12]=S):S=e[12];let C=ee(S),z;e[13]!==u||e[14]!==r?(z=async()=>{u({title:"File name",onConfirm:async N=>{r.createFile({name:N,parentId:null})}})},e[13]=u,e[14]=r,e[15]=z):z=e[15];let F=ee(z),M;e[16]!==u||e[17]!==r?(M=async()=>{u({title:"Notebook name",onConfirm:async N=>{r.createFile({name:N,parentId:null,type:"notebook"})}})},e[16]=u,e[17]=r,e[18]=M):M=e[18];let R=ee(M),I;e[19]===w?I=e[20]:(I=()=>{var N;(N=i.current)==null||N.closeAll(),w({})},e[19]=w,e[20]=I);let Z=ee(I),J;e[21]!==c||e[22]!==x?(J=Ot(c,x),e[21]=c,e[22]=x,e[23]=J):J=e[23];let oe=J;if(j){let N;return e[24]===Symbol.for("react.memo_cache_sentinel")?(N=(0,a.jsx)(da,{size:"medium",centered:!0}),e[24]=N):N=e[24],N}if(m){let N;return e[25]===m?N=e[26]:(N=(0,a.jsx)(mt,{error:m}),e[25]=m,e[26]=N),N}if(s){let N;e[27]===Symbol.for("react.memo_cache_sentinel")?(N=()=>y(null),e[27]=N):N=e[27];let P;e[28]===Symbol.for("react.memo_cache_sentinel")?(P=(0,a.jsx)($,{onClick:N,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:(0,a.jsx)(Ze,{size:16})}),e[28]=P):P=e[28];let O;e[29]===s.name?O=e[30]:(O=(0,a.jsxs)("div",{className:"flex items-center pl-1 pr-3 shrink-0 border-b justify-between",children:[P,(0,a.jsx)("span",{className:"font-bold",children:s.name})]}),e[29]=s.name,e[30]=O);let G;e[31]!==s.path||e[32]!==r?(G=ne=>Tt(ne,r.relativeFromRoot(s.path)),e[31]=s.path,e[32]=r,e[33]=G):G=e[33];let Y;e[34]!==s||e[35]!==G?(Y=(0,a.jsx)(T.Suspense,{children:(0,a.jsx)(on,{onOpenNotebook:G,file:s})}),e[34]=s,e[35]=G,e[36]=Y):Y=e[36];let X;return e[37]!==O||e[38]!==Y?(X=(0,a.jsxs)(a.Fragment,{children:[O,Y]}),e[37]=O,e[38]=Y,e[39]=X):X=e[39],X}let H;e[40]!==Z||e[41]!==F||e[42]!==C||e[43]!==R||e[44]!==_||e[45]!==f||e[46]!==r?(H=(0,a.jsx)(wn,{onRefresh:f,onHidden:_,onCreateFile:F,onCreateNotebook:R,onCreateFolder:C,onCollapseAll:Z,tree:r}),e[40]=Z,e[41]=F,e[42]=C,e[43]=R,e[44]=_,e[45]=f,e[46]=r,e[47]=H):H=e[47];let Q=n-33,L,V,B;e[48]===r?(L=e[49],V=e[50],B=e[51]):(L=async N=>{let{ids:P}=N;for(let O of P)await r.delete(O)},V=async N=>{let{id:P,name:O}=N;await r.rename(P,O)},B=async N=>{let{dragIds:P,parentId:O}=N;await r.move(P,O)},e[48]=r,e[49]=L,e[50]=V,e[51]=B);let K;e[52]===Symbol.for("react.memo_cache_sentinel")?(K=N=>{let P=N[0];P&&(P.data.isDirectory||y(P.data))},e[52]=K):K=e[52];let q;e[53]!==g||e[54]!==w||e[55]!==r?(q=async N=>{if(await r.expand(N)){let P=g[N]??!1;w({...g,[N]:!P})}},e[53]=g,e[54]=w,e[55]=r,e[56]=q):q=e[56];let U;e[57]!==o||e[58]!==g||e[59]!==Q||e[60]!==L||e[61]!==V||e[62]!==B||e[63]!==q||e[64]!==oe?(U=(0,a.jsx)(ua,{width:"100%",ref:i,height:Q,className:"h-full",data:oe,initialOpenState:g,openByDefault:!1,dndManager:o,renderCursor:Cn,disableDrop:Fn,onDelete:L,onRename:V,onMove:B,onSelect:K,onToggle:q,padding:15,rowHeight:30,indent:vn,overscanCount:1e3,disableMultiSelection:!0,children:kn}),e[57]=o,e[58]=g,e[59]=Q,e[60]=L,e[61]=V,e[62]=B,e[63]=q,e[64]=oe,e[65]=U):U=e[65];let W;e[66]!==U||e[67]!==r?(W=(0,a.jsx)(Pt,{value:r,children:U}),e[66]=U,e[67]=r,e[68]=W):W=e[68];let ae;return e[69]!==H||e[70]!==W?(ae=(0,a.jsxs)(a.Fragment,{children:[H,W]}),e[69]=H,e[70]=W,e[71]=ae):ae=e[71],ae};var vn=15,wn=t=>{let e=(0,be.c)(37),{onRefresh:n,onHidden:i,onCreateFile:o,onCreateNotebook:r,onCreateFolder:d,onCollapseAll:c}=t,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={noDrag:!0,noDragEventsBubbling:!0},e[0]=h):h=e[0];let{getRootProps:s,getInputProps:y}=zt(h),x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=(0,a.jsx)(yt,{size:16}),e[1]=x):x=e[1];let p;e[2]===r?p=e[3]:(p=(0,a.jsx)(E,{content:"Add notebook",children:(0,a.jsx)($,{"data-testid":"file-explorer-add-notebook-button",onClick:r,variant:"text",size:"xs",children:x})}),e[2]=r,e[3]=p);let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(jt,{size:16}),e[4]=u):u=e[4];let g;e[5]===o?g=e[6]:(g=(0,a.jsx)(E,{content:"Add file",children:(0,a.jsx)($,{"data-testid":"file-explorer-add-file-button",onClick:o,variant:"text",size:"xs",children:u})}),e[5]=o,e[6]=g);let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsx)(gt,{size:16}),e[7]=w):w=e[7];let v;e[8]===d?v=e[9]:(v=(0,a.jsx)(E,{content:"Add folder",children:(0,a.jsx)($,{"data-testid":"file-explorer-add-folder-button",onClick:d,variant:"text",size:"xs",children:w})}),e[8]=d,e[9]=v);let l;e[10]===s?l=e[11]:(l=s({}),e[10]=s,e[11]=l);let j,m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=Xt({variant:"text",size:"xs"}),j=(0,a.jsx)(Na,{size:16}),e[12]=j,e[13]=m):(j=e[12],m=e[13]);let b;e[14]===l?b=e[15]:(b=(0,a.jsx)(E,{content:"Upload file",children:(0,a.jsx)("button",{"data-testid":"file-explorer-upload-button",...l,className:m,children:j})}),e[14]=l,e[15]=b);let f;e[16]===y?f=e[17]:(f=y({}),e[16]=y,e[17]=f);let k;e[18]===f?k=e[19]:(k=(0,a.jsx)("input",{...f,type:"file"}),e[18]=f,e[19]=k);let _;e[20]===n?_=e[21]:(_=(0,a.jsx)(ht,{"data-testid":"file-explorer-refresh-button",onClick:n}),e[20]=n,e[21]=_);let S;e[22]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)(sa,{size:16}),e[22]=S):S=e[22];let C;e[23]===i?C=e[24]:(C=(0,a.jsx)(E,{content:"Toggle hidden files",children:(0,a.jsx)($,{"data-testid":"file-explorer-hidden-files-button",onClick:i,variant:"text",size:"xs",children:S})}),e[23]=i,e[24]=C);let z;e[25]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsx)(Ua,{size:16}),e[25]=z):z=e[25];let F;e[26]===c?F=e[27]:(F=(0,a.jsx)(E,{content:"Collapse all folders",children:(0,a.jsx)($,{"data-testid":"file-explorer-collapse-button",onClick:c,variant:"text",size:"xs",children:z})}),e[26]=c,e[27]=F);let M;return e[28]!==b||e[29]!==k||e[30]!==_||e[31]!==C||e[32]!==F||e[33]!==p||e[34]!==g||e[35]!==v?(M=(0,a.jsxs)("div",{className:"flex items-center justify-end px-2 shrink-0 border-b",children:[p,g,v,b,k,_,C,F]}),e[28]=b,e[29]=k,e[30]=_,e[31]=C,e[32]=F,e[33]=p,e[34]=g,e[35]=v,e[36]=M):M=e[36],M},Nn=t=>{let e=(0,be.c)(9),{node:n,onOpenMarimoFile:i}=t,o;e[0]===n?o=e[1]:(o=c=>{n.data.isDirectory||(c.stopPropagation(),n.select())},e[0]=n,e[1]=o);let r;e[2]!==n.data.isMarimoFile||e[3]!==i?(r=n.data.isMarimoFile&&!_e()&&(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:i,children:["open ",(0,a.jsx)(Oe,{className:"inline ml-1",size:12})]}),e[2]=n.data.isMarimoFile,e[3]=i,e[4]=r):r=e[4];let d;return e[5]!==n.data.name||e[6]!==o||e[7]!==r?(d=(0,a.jsxs)("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:o,children:[n.data.name,r]}),e[5]=n.data.name,e[6]=o,e[7]=r,e[8]=d):d=e[8],d},kn=t=>{let e=(0,be.c)(116),{node:n,style:i,dragHandle:o}=t,{openFile:r,sendFileDetails:d}=Pe(),c=ye(Je),h;e[0]!==n.data.isDirectory||e[1]!==n.data.name?(h=n.data.isDirectory?"directory":oa(n.data.name),e[0]=n.data.isDirectory,e[1]=n.data.name,e[2]=h):h=e[2];let s=h,y=ia[s],{openConfirm:x,openPrompt:p}=ct(),{createNewCell:u}=At(),g=Ta(),w;e[3]!==u||e[4]!==g?(w=D=>{u({code:D,before:!1,cellId:g??"__end__"})},e[3]=u,e[4]=g,e[5]=w):w=e[5];let v=w,l=(0,T.use)(Pt),j;e[6]!==n.data.path||e[7]!==l?(j=async D=>{Tt(D,l?l.relativeFromRoot(n.data.path):n.data.path)},e[6]=n.data.path,e[7]=l,e[8]=j):j=e[8];let m=j,b;e[9]!==n.data.name||e[10]!==n.id||e[11]!==n.tree||e[12]!==x?(b=async D=>{D.stopPropagation(),D.preventDefault(),x({title:"Delete file",description:`Are you sure you want to delete ${n.data.name}?`,confirmAction:(0,a.jsx)(Ut,{onClick:async()=>{await n.tree.delete(n.id)},"aria-label":"Confirm",children:"Delete"})})},e[9]=n.data.name,e[10]=n.id,e[11]=n.tree,e[12]=x,e[13]=b):b=e[13];let f=b,k;e[14]!==n||e[15]!==p||e[16]!==l?(k=async()=>{n.open(),p({title:"Folder name",onConfirm:async D=>{l==null||l.createFolder(D,n.id)}})},e[14]=n,e[15]=p,e[16]=l,e[17]=k):k=e[17];let _=ee(k),S;e[18]!==n||e[19]!==p||e[20]!==l?(S=async()=>{n.open(),p({title:"File name",onConfirm:async D=>{l==null||l.createFile({name:D,parentId:n.id})}})},e[18]=n,e[19]=p,e[20]=l,e[21]=S):S=e[21];let C=ee(S),z;e[22]!==n||e[23]!==p||e[24]!==l?(z=async()=>{n.open(),p({title:"Notebook name",onConfirm:async D=>{l==null||l.createFile({name:D,parentId:n.id,type:"notebook"})}})},e[22]=n,e[23]=p,e[24]=l,e[25]=z):z=e[25];let F=ee(z),M;e[26]!==n.data.name||e[27]!==n.id||e[28]!==l?(M=async()=>{l&&await l.copy(n.id,Aa(n.data.name))},e[26]=n.data.name,e[27]=n.id,e[28]=l,e[29]=M):M=e[29];let R=ee(M),I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=ie("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),e[30]=I):I=e[30];let Z,J;e[31]===n?(Z=e[32],J=e[33]):(Z=D=>{D.stopPropagation(),n.data.isDirectory&&n.toggle()},J=(0,a.jsx)(_n,{node:n}),e[31]=n,e[32]=Z,e[33]=J);let oe=n.willReceiveDrop&&n.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground",H;e[34]===oe?H=e[35]:(H=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]=H);let Q;e[36]!==y||e[37]!==s||e[38]!==n.data.isMarimoFile?(Q=n.data.isMarimoFile?(0,a.jsx)(Va,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}):(0,a.jsx)(y,{className:ie("w-5 h-5 shrink-0 mr-2",at[s]),strokeWidth:1.5}),e[36]=y,e[37]=s,e[38]=n.data.isMarimoFile,e[39]=Q):Q=e[39];let L;e[40]!==m||e[41]!==n?(L=n.isEditing?(0,a.jsx)(ga,{node:n}):(0,a.jsx)(Nn,{node:n,onOpenMarimoFile:m}),e[40]=m,e[41]=n,e[42]=L):L=e[42];let V;e[43]===n?V=e[44]:(V=!n.data.isDirectory&&(0,a.jsxs)(A,{onSelect:()=>n.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]=n,e[44]=V);let B;e[45]!==n.data.isDirectory||e[46]!==n.data.path||e[47]!==r?(B=!n.data.isDirectory&&!_e()&&(0,a.jsxs)(A,{onSelect:()=>{r({path:n.data.path})},"data-testid":"file-explorer-open-external-menu-item",children:[(0,a.jsx)(Oe,{className:"h-3.5 w-3.5 mr-2"}),"Open file in external editor"]}),e[45]=n.data.isDirectory,e[46]=n.data.path,e[47]=r,e[48]=B):B=e[48];let K;e[49]!==C||e[50]!==_||e[51]!==F||e[52]!==n.data.isDirectory?(K=n.data.isDirectory&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(A,{onSelect:()=>F(),"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)(A,{onSelect:()=>C(),"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)(A,{onSelect:()=>_(),"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]=C,e[50]=_,e[51]=F,e[52]=n.data.isDirectory,e[53]=K):K=e[53];let q;e[54]===n?q=e[55]:(q=(0,a.jsx)(ma,{onSelect:()=>n.edit(),testId:"file-explorer-rename-menu-item"}),e[54]=n,e[55]=q);let U;e[56]===R?U=e[57]:(U=(0,a.jsx)(ja,{onSelect:R,testId:"file-explorer-duplicate-menu-item"}),e[56]=R,e[57]=U);let W;e[58]===n.data.path?W=e[59]:(W=async()=>{await je(n.data.path),te({title:"Copied to clipboard"})},e[58]=n.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 N;e[61]===W?N=e[62]:(N=(0,a.jsxs)(A,{onSelect:W,"data-testid":"file-explorer-copy-path-menu-item",children:[ae,"Copy path"]}),e[61]=W,e[62]=N);let P;e[63]!==n.data.path||e[64]!==l?(P=l&&(0,a.jsxs)(A,{onSelect:async()=>{await je(l.relativeFromRoot(n.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]=n.data.path,e[64]=l,e[65]=P):P=e[65];let O;e[66]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(ue,{}),e[66]=O):O=e[66];let G;e[67]!==s||e[68]!==v||e[69]!==n.data?(G=()=>{let{path:D}=n.data;v(Dt[s](D))},e[67]=s,e[68]=v,e[69]=n.data,e[70]=G):G=e[70];let Y;e[71]===Symbol.for("react.memo_cache_sentinel")?(Y=(0,a.jsx)(aa,{className:ge}),e[71]=Y):Y=e[71];let X;e[72]===G?X=e[73]:(X=(0,a.jsxs)(A,{onSelect:G,"data-testid":"file-explorer-insert-snippet-menu-item",children:[Y,"Insert snippet for reading file"]}),e[72]=G,e[73]=X);let ne;e[74]!==s||e[75]!==n.data?(ne=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:D}=n.data;await je(Dt[s](D))},e[74]=s,e[75]=n.data,e[76]=ne):ne=e[76];let ve;e[77]===Symbol.for("react.memo_cache_sentinel")?(ve=(0,a.jsx)(Ht,{className:ge}),e[77]=ve):ve=e[77];let ce;e[78]===ne?ce=e[79]:(ce=(0,a.jsxs)(A,{onSelect:ne,"data-testid":"file-explorer-copy-snippet-menu-item",children:[ve,"Copy snippet for reading file"]}),e[78]=ne,e[79]=ce);let de;e[80]!==m||e[81]!==n.data.isMarimoFile?(de=n.data.isMarimoFile&&!_e()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ue,{}),(0,a.jsxs)(A,{onSelect:m,"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]=m,e[81]=n.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]!==n.data.isDirectory||e[86]!==n.data.name||e[87]!==n.data.path||e[88]!==d?(me=!n.data.isDirectory&&!c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(A,{onSelect:async()=>{let D=await d({path:n.data.path});D.isBase64&&D.contents?Ce(dt($e(D.contents,D.mimeType||"application/octet-stream")),n.data.name):Ce(new Blob([D.contents||""]),n.data.name)},"data-testid":"file-explorer-download-menu-item",children:[(0,a.jsx)(De,{className:"h-3.5 w-3.5 mr-2"}),"Download"]}),(0,a.jsx)(ue,{})]}),e[84]=c,e[85]=n.data.isDirectory,e[86]=n.data.name,e[87]=n.data.path,e[88]=d,e[89]=me):me=e[89];let pe;e[90]===f?pe=e[91]:(pe=(0,a.jsx)(ya,{onSelect:f,testId:"file-explorer-delete-menu-item"}),e[90]=f,e[91]=pe);let he;e[92]!==V||e[93]!==B||e[94]!==K||e[95]!==q||e[96]!==U||e[97]!==N||e[98]!==P||e[99]!==X||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:[V,B,K,q,U,N,P,O,X,ce,de,we,me,pe]}),e[92]=V,e[93]=B,e[94]=K,e[95]=q,e[96]=U,e[97]=N,e[98]=P,e[99]=X,e[100]=ce,e[101]=de,e[102]=me,e[103]=pe,e[104]=he):he=e[104];let xe;e[105]!==H||e[106]!==Q||e[107]!==L||e[108]!==he?(xe=(0,a.jsxs)("span",{className:H,children:[Q,L,he]}),e[105]=H,e[106]=Q,e[107]=L,e[108]=he,e[109]=xe):xe=e[109];let Ne;return e[110]!==o||e[111]!==i||e[112]!==Z||e[113]!==J||e[114]!==xe?(Ne=(0,a.jsxs)("div",{style:i,ref:o,className:I,draggable:!0,onClick:Z,children:[J,xe]}),e[110]=o,e[111]=i,e[112]=Z,e[113]=J,e[114]=xe,e[115]=Ne):Ne=e[115],Ne},_n=t=>{let e=(0,be.c)(3),{node:n}=t;if(!n.data.isDirectory){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,a.jsx)("span",{className:"w-4 h-4 shrink-0"}),e[0]=o):o=e[0],o}let i;return e[1]===n.isOpen?i=e[2]:(i=(0,a.jsx)(Ae,{isExpanded:n.isOpen,className:"w-4 h-4"}),e[1]=n.isOpen,e[2]=i),i};function Tt(t,e){t.stopPropagation(),t.preventDefault(),Ba(e)}function Ot(t,e){if(e)return t;let n=[];for(let i of t){if(Sn(i.name))continue;let o=i;if(i.children){let r=Ot(i.children,e);r!==i.children&&(o={...i,children:r})}n.push(o)}return n}function Sn(t){return!!t.startsWith(".")}function Cn(){return null}function Fn(t){let{parentNode:e}=t;return!e.data.isDirectory}var $t=fe(),Mn=Ge("marimo:file-explorer-panel:state",{openSections:["files"],hasUserInteracted:!1},We),Dn=t=>{let e=(0,$t.c)(20),{height:n}=t,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={noClick:!0,noKeyboard:!0},e[0]=i):i=e[0];let{getRootProps:o,getInputProps:r,isDragActive:d}=zt(i),c;e[1]===o?c=e[2]:(c=o(),e[1]=o,e[2]=c);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=ie("flex flex-col overflow-hidden relative"),e[3]=h):h=e[3];let s;e[4]===n?s=e[5]:(s={height:n},e[4]=n,e[5]=s);let y;e[6]===r?y=e[7]:(y=r(),e[6]=r,e[7]=y);let x;e[8]===y?x=e[9]:(x=(0,a.jsx)("input",{...y}),e[8]=y,e[9]=x);let p;e[10]===d?p=e[11]:(p=d&&(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]=d,e[11]=p);let u;e[12]===n?u=e[13]:(u=(0,a.jsx)(bn,{height:n}),e[12]=n,e[13]=u);let g;return e[14]!==c||e[15]!==s||e[16]!==x||e[17]!==p||e[18]!==u?(g=(0,a.jsx)(ln,{children:(0,a.jsxs)("div",{...c,className:h,style:s,children:[x,p,u]})}),e[14]=c,e[15]=s,e[16]=x,e[17]=p,e[18]=u,e[19]=g):g=e[19],g},zn=33,Pn=()=>{let t=(0,$t.c)(36),{ref:e,height:n}=$a(),i=n===void 0?500:n,[o,r]=ke(Mn),d=ye(ta).length,c;e:{if(!o.hasUserInteracted&&d>0){if(o.openSections.includes("remote-storage")){c=o.openSections;break e}let I;t[0]===o.openSections?I=t[1]:(I=[...o.openSections,"remote-storage"],t[0]=o.openSections,t[1]=I),c=I;break e}c=o.openSections}let h=c,s;t[2]===r?s=t[3]:(s=I=>{r({openSections:I,hasUserInteracted:!0})},t[2]=r,t[3]=s);let y=s,x=i-zn*2,p;t[4]===h?p=t[5]:(p=h.includes("remote-storage"),t[4]=h,t[5]=p);let u=p,g;t[6]!==h||t[7]!==u?(g=u&&h.includes("files"),t[6]=h,t[7]=u,t[8]=g):g=t[8];let w=g,v;t[9]!==x||t[10]!==w?(v=w?Math.round(x*.4):x,t[9]=x,t[10]=w,t[11]=v):v=t[11];let l=v,j=Math.max(200,w?x-l:x),m;t[12]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(rt,{className:"w-4 h-4"}),t[12]=m):m=t[12];let b;t[13]===d?b=t[14]:(b=d>0&&(0,a.jsx)(La,{children:d}),t[13]=d,t[14]=b);let f;t[15]===b?f=t[16]:(f=(0,a.jsxs)(ft,{children:[m," Remote storage",b]}),t[15]=b,t[16]=f);let k;t[17]===l?k=t[18]:(k={maxHeight:l},t[17]=l,t[18]=k);let _;t[19]===Symbol.for("react.memo_cache_sentinel")?(_=(0,a.jsx)(nn,{}),t[19]=_):_=t[19];let S;t[20]===k?S=t[21]:(S=(0,a.jsx)(ut,{className:"overflow-auto",style:k,children:_}),t[20]=k,t[21]=S);let C;t[22]!==S||t[23]!==f?(C=(0,a.jsxs)(xt,{value:"remote-storage",children:[f,S]}),t[22]=S,t[23]=f,t[24]=C):C=t[24];let z;t[25]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsxs)(ft,{children:[(0,a.jsx)(nt,{className:"w-4 h-4"}),"Files"]}),t[25]=z):z=t[25];let F;t[26]===j?F=t[27]:(F=(0,a.jsxs)(xt,{value:"files",children:[z,(0,a.jsx)(ut,{children:(0,a.jsx)(Dn,{height:j})})]}),t[26]=j,t[27]=F);let M;t[28]!==y||t[29]!==h||t[30]!==C||t[31]!==F?(M=(0,a.jsxs)(qt,{type:"multiple",value:h,onValueChange:y,children:[C,F]}),t[28]=y,t[29]=h,t[30]=C,t[31]=F,t[32]=M):M=t[32];let R;return t[33]!==e||t[34]!==M?(R=(0,a.jsx)("div",{ref:e,className:"h-full overflow-auto",children:M}),t[33]=e,t[34]=M,t[35]=R):R=t[35],R};export{Pn as default};
@@ -1,3 +1,3 @@
1
1
  var Rr=Object.defineProperty;var Pr=(e,t,r)=>t in e?Rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var k=(e,t,r)=>Pr(e,typeof t!="symbol"?t+"":t,r);import{r as et,s as ve,t as jr}from"./chunk-LvLJmgfZ.js";import{n as ye}from"./useEvent-D91BmmQi.js";import{t as _r}from"./react-Bj1aDYRI.js";import{t as tt}from"./compiler-runtime-B3qBwwSJ.js";import{v as Mr}from"./useEventListener-BR0C1MaI.js";import{t as Ar}from"./jsx-runtime-BqBOg78p.js";import{o as kr}from"./alert-dialog-BGBdrcqJ.js";import{d as Lr}from"./popover-UExmgBsf.js";import{a as Oe,p as Fr,r as Hr,t as Ur}from"./dropdown-menu-D1A3cFC8.js";import{r as Br}from"./requests-DIwGYs0l.js";import{t as zr}from"./createLucideIcon-D5guW7EU.js";import{t as Wr}from"./copy-BwrPA9zQ.js";import{t as Vr}from"./trash-2-CKlZA04n.js";import{t as q}from"./use-toast-T0_cQDma.js";import{t as rt}from"./paths-BXWH6vv4.js";import{n as Gr}from"./ImperativeModal-D7lQ0Q7_.js";import{r as Kr}from"./errors-TZBmrJmc.js";import{t as $r}from"./extends-B2LJnKU3.js";import{n as Yr,t as Ie}from"./tree-actions-Ci3CV3hN.js";import{i as qr,n as Xr,r as te}from"./pathUtils-DOhgNpTR.js";var Jr=zr("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"}]]);function be(e,t){return be=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},be(e,t)}function Qr(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,be(e,t)}function nt(e){if(e===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var Zr=jr(((e,t)=>{t.exports=function r(n,i){if(n===i)return!0;if(n&&i&&typeof n=="object"&&typeof i=="object"){if(n.constructor!==i.constructor)return!1;var s,o,a;if(Array.isArray(n)){if(s=n.length,s!=i.length)return!1;for(o=s;o--!==0;)if(!r(n[o],i[o]))return!1;return!0}if(n.constructor===RegExp)return n.source===i.source&&n.flags===i.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===i.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===i.toString();if(a=Object.keys(n),s=a.length,s!==Object.keys(i).length)return!1;for(o=s;o--!==0;)if(!Object.prototype.hasOwnProperty.call(i,a[o]))return!1;for(o=s;o--!==0;){var d=a[o];if(!r(n[d],i[d]))return!1}return!0}return n!==n&&i!==i}})),p=ve(_r(),1);const it=(0,p.createContext)({dragDropManager:void 0});function R(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var st=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})(),Se=function(){return Math.random().toString(36).substring(7).split("").join(".")},ot={INIT:"@@redux/INIT"+Se(),REPLACE:"@@redux/REPLACE"+Se(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Se()}};function en(e){if(typeof e!="object"||!e)return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function at(e,t,r){var n;if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw Error(R(0));if(typeof t=="function"&&r===void 0&&(r=t,t=void 0),r!==void 0){if(typeof r!="function")throw Error(R(1));return r(at)(e,t)}if(typeof e!="function")throw Error(R(2));var i=e,s=t,o=[],a=o,d=!1;function c(){a===o&&(a=o.slice())}function f(){if(d)throw Error(R(3));return s}function O(l){if(typeof l!="function")throw Error(R(4));if(d)throw Error(R(5));var g=!0;return c(),a.push(l),function(){if(g){if(d)throw Error(R(6));g=!1,c();var m=a.indexOf(l);a.splice(m,1),o=null}}}function y(l){if(!en(l))throw Error(R(7));if(l.type===void 0)throw Error(R(8));if(d)throw Error(R(9));try{d=!0,s=i(s,l)}finally{d=!1}for(var g=o=a,m=0;m<g.length;m++){var b=g[m];b()}return l}function h(l){if(typeof l!="function")throw Error(R(10));i=l,y({type:ot.REPLACE})}function u(){var l,g=O;return l={subscribe:function(m){if(typeof m!="object"||!m)throw Error(R(11));function b(){m.next&&m.next(f())}return b(),{unsubscribe:g(b)}}},l[st]=function(){return this},l}return y({type:ot.INIT}),n={dispatch:y,subscribe:O,getState:f,replaceReducer:h},n[st]=u,n}function I(e,t,...r){if(tn()&&t===void 0)throw Error("invariant requires an error message argument");if(!e){let n;if(t===void 0)n=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{let i=0;n=Error(t.replace(/%s/g,function(){return r[i++]})),n.name="Invariant Violation"}throw n.framesToPop=1,n}}function tn(){return typeof process<"u"&&!0}function rn(e,t,r){return t.split(".").reduce((n,i)=>n&&n[i]?n[i]:r||null,e)}function nn(e,t){return e.filter(r=>r!==t)}function lt(e){return typeof e=="object"}function sn(e,t){let r=new Map,n=s=>{r.set(s,r.has(s)?r.get(s)+1:1)};e.forEach(n),t.forEach(n);let i=[];return r.forEach((s,o)=>{s===1&&i.push(o)}),i}function on(e,t){return e.filter(r=>t.indexOf(r)>-1)}const De="dnd-core/INIT_COORDS",re="dnd-core/BEGIN_DRAG",we="dnd-core/PUBLISH_DRAG_SOURCE",ne="dnd-core/HOVER",ie="dnd-core/DROP",se="dnd-core/END_DRAG";function dt(e,t){return{type:De,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}var an={type:De,payload:{clientOffset:null,sourceClientOffset:null}};function ln(e){return function(t=[],r={publishSource:!0}){let{publishSource:n=!0,clientOffset:i,getSourceClientOffset:s}=r,o=e.getMonitor(),a=e.getRegistry();e.dispatch(dt(i)),dn(t,o,a);let d=hn(t,o);if(d==null){e.dispatch(an);return}let c=null;if(i){if(!s)throw Error("getSourceClientOffset must be defined");cn(s),c=s(d)}e.dispatch(dt(i,c));let f=a.getSource(d).beginDrag(o,d);if(f!=null)return un(f),a.pinSource(d),{type:re,payload:{itemType:a.getSourceType(d),item:f,sourceId:d,clientOffset:i||null,sourceClientOffset:c||null,isSourcePublic:!!n}}}}function dn(e,t,r){I(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach(function(n){I(r.getSource(n),"Expected sourceIds to be registered.")})}function cn(e){I(typeof e=="function","When clientOffset is provided, getSourceClientOffset must be a function.")}function un(e){I(lt(e),"Item must be an object.")}function hn(e,t){let r=null;for(let n=e.length-1;n>=0;n--)if(t.canDragSource(e[n])){r=e[n];break}return r}function fn(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function gn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]==null?{}:arguments[t],n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){fn(e,i,r[i])})}return e}function pn(e){return function(t={}){let r=e.getMonitor(),n=e.getRegistry();mn(r),On(r).forEach((i,s)=>{let o={type:ie,payload:{dropResult:gn({},t,vn(i,s,n,r))}};e.dispatch(o)})}}function mn(e){I(e.isDragging(),"Cannot call drop while not dragging."),I(!e.didDrop(),"Cannot call drop twice during one drag operation.")}function vn(e,t,r,n){let i=r.getTarget(e),s=i?i.drop(n,e):void 0;return yn(s),s===void 0&&(s=t===0?{}:n.getDropResult()),s}function yn(e){I(e===void 0||lt(e),"Drop result must either be an object or undefined.")}function On(e){let t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}function In(e){return function(){let t=e.getMonitor(),r=e.getRegistry();bn(t);let n=t.getSourceId();return n!=null&&(r.getSource(n,!0).endDrag(t,n),r.unpinSource()),{type:se}}}function bn(e){I(e.isDragging(),"Cannot call endDrag while not dragging.")}function Te(e,t){return t===null?e===null:Array.isArray(e)?e.some(r=>r===t):e===t}function Sn(e){return function(t,{clientOffset:r}={}){Dn(t);let n=t.slice(0),i=e.getMonitor(),s=e.getRegistry();return Tn(n,s,i.getItemType()),wn(n,i,s),En(n,i,s),{type:ne,payload:{targetIds:n,clientOffset:r||null}}}}function Dn(e){I(Array.isArray(e),"Expected targetIds to be an array.")}function wn(e,t,r){I(t.isDragging(),"Cannot call hover while not dragging."),I(!t.didDrop(),"Cannot call hover after drop.");for(let n=0;n<e.length;n++){let i=e[n];I(e.lastIndexOf(i)===n,"Expected targetIds to be unique in the passed array."),I(r.getTarget(i),"Expected targetIds to be registered.")}}function Tn(e,t,r){for(let n=e.length-1;n>=0;n--){let i=e[n];Te(t.getTargetType(i),r)||e.splice(n,1)}}function En(e,t,r){e.forEach(function(n){r.getTarget(n).hover(t,n)})}function xn(e){return function(){if(e.getMonitor().isDragging())return{type:we}}}function Cn(e){return{beginDrag:ln(e),publishDragSource:xn(e),hover:Sn(e),drop:pn(e),endDrag:In(e)}}var Nn=class{receiveBackend(e){this.backend=e}getMonitor(){return this.monitor}getBackend(){return this.backend}getRegistry(){return this.monitor.registry}getActions(){let e=this,{dispatch:t}=this.store;function r(i){return(...s)=>{let o=i.apply(e,s);o!==void 0&&t(o)}}let n=Cn(this);return Object.keys(n).reduce((i,s)=>{let o=n[s];return i[s]=r(o),i},{})}dispatch(e){this.store.dispatch(e)}constructor(e,t){this.isSetUp=!1,this.handleRefCountChange=()=>{let r=this.store.getState().refCount>0;this.backend&&(r&&!this.isSetUp?(this.backend.setup(),this.isSetUp=!0):!r&&this.isSetUp&&(this.backend.teardown(),this.isSetUp=!1))},this.store=e,this.monitor=t,e.subscribe(this.handleRefCountChange)}};function Rn(e,t){return{x:e.x+t.x,y:e.y+t.y}}function ct(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Pn(e){let{clientOffset:t,initialClientOffset:r,initialSourceClientOffset:n}=e;return!t||!r||!n?null:ct(Rn(t,n),r)}function jn(e){let{clientOffset:t,initialClientOffset:r}=e;return!t||!r?null:ct(t,r)}const X=[],Ee=[];X.__IS_NONE__=!0,Ee.__IS_ALL__=!0;function _n(e,t){return e===X?!1:e===Ee||t===void 0?!0:on(t,e).length>0}var Mn=class{subscribeToStateChange(e,t={}){let{handlerIds:r}=t;I(typeof e=="function","listener must be a function."),I(r===void 0||Array.isArray(r),"handlerIds, when specified, must be an array of strings.");let n=this.store.getState().stateId;return this.store.subscribe(()=>{let i=this.store.getState(),s=i.stateId;try{s===n||s===n+1&&!_n(i.dirtyHandlerIds,r)||e()}finally{n=s}})}subscribeToOffsetChange(e){I(typeof e=="function","listener must be a function.");let t=this.store.getState().dragOffset;return this.store.subscribe(()=>{let r=this.store.getState().dragOffset;r!==t&&(t=r,e())})}canDragSource(e){if(!e)return!1;let t=this.registry.getSource(e);return I(t,`Expected to find a valid source. sourceId=${e}`),this.isDragging()?!1:t.canDrag(this,e)}canDropOnTarget(e){if(!e)return!1;let t=this.registry.getTarget(e);return I(t,`Expected to find a valid target. targetId=${e}`),!this.isDragging()||this.didDrop()?!1:Te(this.registry.getTargetType(e),this.getItemType())&&t.canDrop(this,e)}isDragging(){return!!this.getItemType()}isDraggingSource(e){if(!e)return!1;let t=this.registry.getSource(e,!0);return I(t,`Expected to find a valid source. sourceId=${e}`),!this.isDragging()||!this.isSourcePublic()||this.registry.getSourceType(e)!==this.getItemType()?!1:t.isDragging(this,e)}isOverTarget(e,t={shallow:!1}){if(!e)return!1;let{shallow:r}=t;if(!this.isDragging())return!1;let n=this.registry.getTargetType(e),i=this.getItemType();if(i&&!Te(n,i))return!1;let s=this.getTargetIds();if(!s.length)return!1;let o=s.indexOf(e);return r?o===s.length-1:o>-1}getItemType(){return this.store.getState().dragOperation.itemType}getItem(){return this.store.getState().dragOperation.item}getSourceId(){return this.store.getState().dragOperation.sourceId}getTargetIds(){return this.store.getState().dragOperation.targetIds}getDropResult(){return this.store.getState().dragOperation.dropResult}didDrop(){return this.store.getState().dragOperation.didDrop}isSourcePublic(){return!!this.store.getState().dragOperation.isSourcePublic}getInitialClientOffset(){return this.store.getState().dragOffset.initialClientOffset}getInitialSourceClientOffset(){return this.store.getState().dragOffset.initialSourceClientOffset}getClientOffset(){return this.store.getState().dragOffset.clientOffset}getSourceClientOffset(){return Pn(this.store.getState().dragOffset)}getDifferenceFromInitialOffset(){return jn(this.store.getState().dragOffset)}constructor(e,t){this.store=e,this.registry=t}},ut=typeof global<"u"?global:self,ht=ut.MutationObserver||ut.WebKitMutationObserver;function ft(e){return function(){let t=setTimeout(n,0),r=setInterval(n,50);function n(){clearTimeout(t),clearInterval(r),e()}}}function An(e){let t=1,r=new ht(e),n=document.createTextNode("");return r.observe(n,{characterData:!0}),function(){t=-t,n.data=t}}const kn=typeof ht=="function"?An:ft;var Ln=class{enqueueTask(e){let{queue:t,requestFlush:r}=this;t.length||(r(),this.flushing=!0),t[t.length]=e}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{let{queue:e}=this;for(;this.index<e.length;){let t=this.index;if(this.index++,e[t].call(),this.index>this.capacity){for(let r=0,n=e.length-this.index;r<n;r++)e[r]=e[r+this.index];e.length-=this.index,this.index=0}}e.length=0,this.index=0,this.flushing=!1},this.registerPendingError=e=>{this.pendingErrors.push(e),this.requestErrorThrow()},this.requestFlush=kn(this.flush),this.requestErrorThrow=ft(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}},Fn=class{call(){try{this.task&&this.task()}catch(e){this.onError(e)}finally{this.task=null,this.release(this)}}constructor(e,t){this.onError=e,this.release=t,this.task=null}},Hn=class{create(e){let t=this.freeTasks,r=t.length?t.pop():new Fn(this.onError,n=>t[t.length]=n);return r.task=e,r}constructor(e){this.onError=e,this.freeTasks=[]}},gt=new Ln,Un=new Hn(gt.registerPendingError);function Bn(e){gt.enqueueTask(Un.create(e))}const xe="dnd-core/ADD_SOURCE",Ce="dnd-core/ADD_TARGET",Ne="dnd-core/REMOVE_SOURCE",oe="dnd-core/REMOVE_TARGET";function zn(e){return{type:xe,payload:{sourceId:e}}}function Wn(e){return{type:Ce,payload:{targetId:e}}}function Vn(e){return{type:Ne,payload:{sourceId:e}}}function Gn(e){return{type:oe,payload:{targetId:e}}}function Kn(e){I(typeof e.canDrag=="function","Expected canDrag to be a function."),I(typeof e.beginDrag=="function","Expected beginDrag to be a function."),I(typeof e.endDrag=="function","Expected endDrag to be a function.")}function $n(e){I(typeof e.canDrop=="function","Expected canDrop to be a function."),I(typeof e.hover=="function","Expected hover to be a function."),I(typeof e.drop=="function","Expected beginDrag to be a function.")}function Re(e,t){if(t&&Array.isArray(e)){e.forEach(r=>Re(r,!1));return}I(typeof e=="string"||typeof e=="symbol",t?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}var P;(function(e){e.SOURCE="SOURCE",e.TARGET="TARGET"})(P||(P={}));var Yn=0;function qn(){return Yn++}function Xn(e){let t=qn().toString();switch(e){case P.SOURCE:return`S${t}`;case P.TARGET:return`T${t}`;default:throw Error(`Unknown Handler Role: ${e}`)}}function pt(e){switch(e[0]){case"S":return P.SOURCE;case"T":return P.TARGET;default:throw Error(`Cannot parse handler ID: ${e}`)}}function mt(e,t){let r=e.entries(),n=!1;do{let{done:i,value:[,s]}=r.next();if(s===t)return!0;n=!!i}while(!n);return!1}var Jn=class{addSource(e,t){Re(e),Kn(t);let r=this.addHandler(P.SOURCE,e,t);return this.store.dispatch(zn(r)),r}addTarget(e,t){Re(e,!0),$n(t);let r=this.addHandler(P.TARGET,e,t);return this.store.dispatch(Wn(r)),r}containsHandler(e){return mt(this.dragSources,e)||mt(this.dropTargets,e)}getSource(e,t=!1){return I(this.isSourceId(e),"Expected a valid source ID."),t&&e===this.pinnedSourceId?this.pinnedSource:this.dragSources.get(e)}getTarget(e){return I(this.isTargetId(e),"Expected a valid target ID."),this.dropTargets.get(e)}getSourceType(e){return I(this.isSourceId(e),"Expected a valid source ID."),this.types.get(e)}getTargetType(e){return I(this.isTargetId(e),"Expected a valid target ID."),this.types.get(e)}isSourceId(e){return pt(e)===P.SOURCE}isTargetId(e){return pt(e)===P.TARGET}removeSource(e){I(this.getSource(e),"Expected an existing source."),this.store.dispatch(Vn(e)),Bn(()=>{this.dragSources.delete(e),this.types.delete(e)})}removeTarget(e){I(this.getTarget(e),"Expected an existing target."),this.store.dispatch(Gn(e)),this.dropTargets.delete(e),this.types.delete(e)}pinSource(e){let t=this.getSource(e);I(t,"Expected an existing source."),this.pinnedSourceId=e,this.pinnedSource=t}unpinSource(){I(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}addHandler(e,t,r){let n=Xn(e);return this.types.set(n,t),e===P.SOURCE?this.dragSources.set(n,r):e===P.TARGET&&this.dropTargets.set(n,r),n}constructor(e){this.types=new Map,this.dragSources=new Map,this.dropTargets=new Map,this.pinnedSourceId=null,this.pinnedSource=null,this.store=e}};const Qn=(e,t)=>e===t;function Zn(e,t){return!e&&!t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y}function ei(e,t,r=Qn){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!r(e[n],t[n]))return!1;return!0}function ti(e=X,t){switch(t.type){case ne:break;case xe:case Ce:case oe:case Ne:return X;case re:case we:case se:case ie:default:return Ee}let{targetIds:r=[],prevTargetIds:n=[]}=t.payload,i=sn(r,n);if(!(i.length>0||!ei(r,n)))return X;let s=n[n.length-1],o=r[r.length-1];return s!==o&&(s&&i.push(s),o&&i.push(o)),i}function ri(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ni(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]==null?{}:arguments[t],n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){ri(e,i,r[i])})}return e}var vt={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null};function ii(e=vt,t){let{payload:r}=t;switch(t.type){case De:case re:return{initialSourceClientOffset:r.sourceClientOffset,initialClientOffset:r.clientOffset,clientOffset:r.clientOffset};case ne:return Zn(e.clientOffset,r.clientOffset)?e:ni({},e,{clientOffset:r.clientOffset});case se:case ie:return vt;default:return e}}function si(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function W(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]==null?{}:arguments[t],n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){si(e,i,r[i])})}return e}var oi={itemType:null,item:null,sourceId:null,targetIds:[],dropResult:null,didDrop:!1,isSourcePublic:null};function ai(e=oi,t){let{payload:r}=t;switch(t.type){case re:return W({},e,{itemType:r.itemType,item:r.item,sourceId:r.sourceId,isSourcePublic:r.isSourcePublic,dropResult:null,didDrop:!1});case we:return W({},e,{isSourcePublic:!0});case ne:return W({},e,{targetIds:r.targetIds});case oe:return e.targetIds.indexOf(r.targetId)===-1?e:W({},e,{targetIds:nn(e.targetIds,r.targetId)});case ie:return W({},e,{dropResult:r.dropResult,didDrop:!0,targetIds:[]});case se:return W({},e,{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return e}}function li(e=0,t){switch(t.type){case xe:case Ce:return e+1;case Ne:case oe:return e-1;default:return e}}function di(e=0){return e+1}function ci(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ui(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]==null?{}:arguments[t],n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){ci(e,i,r[i])})}return e}function hi(e={},t){return{dirtyHandlerIds:ti(e.dirtyHandlerIds,{type:t.type,payload:ui({},t.payload,{prevTargetIds:rn(e,"dragOperation.targetIds",[])})}),dragOffset:ii(e.dragOffset,t),refCount:li(e.refCount,t),dragOperation:ai(e.dragOperation,t),stateId:di(e.stateId)}}function fi(e,t=void 0,r={},n=!1){let i=gi(n),s=new Nn(i,new Mn(i,new Jn(i))),o=e(s,t,r);return s.receiveBackend(o),s}function gi(e){let t=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__;return at(hi,e&&t&&t({name:"dnd-core",instanceId:"dnd-core"}))}var v=ve(Ar(),1);function pi(e,t){if(e==null)return{};var r=mi(e,t),n,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)n=s[i],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function mi(e,t){if(e==null)return{};var r={},n=Object.keys(e),i,s;for(s=0;s<n.length;s++)i=n[s],!(t.indexOf(i)>=0)&&(r[i]=e[i]);return r}var yt=0,ae=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__"),Ot=(0,p.memo)(function(e){var{children:t}=e;let[r,n]=vi(pi(e,["children"]));return(0,p.useEffect)(()=>{if(n){let i=It();return++yt,()=>{--yt===0&&(i[ae]=null)}}},[]),(0,v.jsx)(it.Provider,{value:r,children:t})});function vi(e){return"manager"in e?[{dragDropManager:e.manager},!1]:[yi(e.backend,e.context,e.options,e.debugMode),!e.context]}function yi(e,t=It(),r,n){let i=t;return i[ae]||(i[ae]={dragDropManager:fi(e,t,r,n)}),i[ae]}function It(){return typeof global<"u"?global:window}const H=typeof window<"u"?p.useLayoutEffect:p.useEffect;var Oi=ve(Zr(),1);function bt(e,t,r){let[n,i]=(0,p.useState)(()=>t(e)),s=(0,p.useCallback)(()=>{let o=t(e);(0,Oi.default)(n,o)||(i(o),r&&r())},[n,e,r]);return H(s),[n,s]}function Ii(e,t,r){let[n,i]=bt(e,t,r);return H(function(){let s=e.getHandlerId();if(s!=null)return e.subscribeToStateChange(i,{handlerIds:[s]})},[e,i]),n}function St(e,t,r){return Ii(t,e||(()=>({})),()=>r.reconnect())}function Dt(e,t){let r=[...t||[]];return t==null&&typeof e!="function"&&r.push(e),(0,p.useMemo)(()=>typeof e=="function"?e():e,r)}function bi(e){return(0,p.useMemo)(()=>e.hooks.dragSource(),[e])}function Si(e){return(0,p.useMemo)(()=>e.hooks.dragPreview(),[e])}var Pe=!1,je=!1,Di=class{receiveHandlerId(e){this.sourceId=e}getHandlerId(){return this.sourceId}canDrag(){I(!Pe,"You may not call monitor.canDrag() inside your canDrag() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return Pe=!0,this.internalMonitor.canDragSource(this.sourceId)}finally{Pe=!1}}isDragging(){if(!this.sourceId)return!1;I(!je,"You may not call monitor.isDragging() inside your isDragging() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return je=!0,this.internalMonitor.isDraggingSource(this.sourceId)}finally{je=!1}}subscribeToStateChange(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}isDraggingSource(e){return this.internalMonitor.isDraggingSource(e)}isOverTarget(e,t){return this.internalMonitor.isOverTarget(e,t)}getTargetIds(){return this.internalMonitor.getTargetIds()}isSourcePublic(){return this.internalMonitor.isSourcePublic()}getSourceId(){return this.internalMonitor.getSourceId()}subscribeToOffsetChange(e){return this.internalMonitor.subscribeToOffsetChange(e)}canDragSource(e){return this.internalMonitor.canDragSource(e)}canDropOnTarget(e){return this.internalMonitor.canDropOnTarget(e)}getItemType(){return this.internalMonitor.getItemType()}getItem(){return this.internalMonitor.getItem()}getDropResult(){return this.internalMonitor.getDropResult()}didDrop(){return this.internalMonitor.didDrop()}getInitialClientOffset(){return this.internalMonitor.getInitialClientOffset()}getInitialSourceClientOffset(){return this.internalMonitor.getInitialSourceClientOffset()}getSourceClientOffset(){return this.internalMonitor.getSourceClientOffset()}getClientOffset(){return this.internalMonitor.getClientOffset()}getDifferenceFromInitialOffset(){return this.internalMonitor.getDifferenceFromInitialOffset()}constructor(e){this.sourceId=null,this.internalMonitor=e.getMonitor()}},_e=!1,wi=class{receiveHandlerId(e){this.targetId=e}getHandlerId(){return this.targetId}subscribeToStateChange(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}canDrop(){if(!this.targetId)return!1;I(!_e,"You may not call monitor.canDrop() inside your canDrop() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor");try{return _e=!0,this.internalMonitor.canDropOnTarget(this.targetId)}finally{_e=!1}}isOver(e){return this.targetId?this.internalMonitor.isOverTarget(this.targetId,e):!1}getItemType(){return this.internalMonitor.getItemType()}getItem(){return this.internalMonitor.getItem()}getDropResult(){return this.internalMonitor.getDropResult()}didDrop(){return this.internalMonitor.didDrop()}getInitialClientOffset(){return this.internalMonitor.getInitialClientOffset()}getInitialSourceClientOffset(){return this.internalMonitor.getInitialSourceClientOffset()}getSourceClientOffset(){return this.internalMonitor.getSourceClientOffset()}getClientOffset(){return this.internalMonitor.getClientOffset()}getDifferenceFromInitialOffset(){return this.internalMonitor.getDifferenceFromInitialOffset()}constructor(e){this.targetId=null,this.internalMonitor=e.getMonitor()}};function Ti(e,t,r){let n=r.getRegistry(),i=n.addTarget(e,t);return[i,()=>n.removeTarget(i)]}function Ei(e,t,r){let n=r.getRegistry(),i=n.addSource(e,t);return[i,()=>n.removeSource(i)]}function Me(e,t,r,n){let i=r?r.call(n,e,t):void 0;if(i!==void 0)return!!i;if(e===t)return!0;if(typeof e!="object"||!e||typeof t!="object"||!t)return!1;let s=Object.keys(e),o=Object.keys(t);if(s.length!==o.length)return!1;let a=Object.prototype.hasOwnProperty.bind(t);for(let d=0;d<s.length;d++){let c=s[d];if(!a(c))return!1;let f=e[c],O=t[c];if(i=r?r.call(n,f,O,c):void 0,i===!1||i===void 0&&f!==O)return!1}return!0}function Ae(e){return typeof e=="object"&&!!e&&Object.prototype.hasOwnProperty.call(e,"current")}function xi(e){if(typeof e.type=="string")return;let t=e.type.displayName||e.type.name||"the component";throw Error(`Only native element nodes can now be passed to React DnD connectors.You can either wrap ${t} into a <div>, or turn it into a drag source or a drop target itself.`)}function Ci(e){return(t=null,r=null)=>{if(!(0,p.isValidElement)(t)){let i=t;return e(i,r),i}let n=t;return xi(n),Ni(n,r?i=>e(i,r):e)}}function wt(e){let t={};return Object.keys(e).forEach(r=>{let n=e[r];if(r.endsWith("Ref"))t[r]=e[r];else{let i=Ci(n);t[r]=()=>i}}),t}function Tt(e,t){typeof e=="function"?e(t):e.current=t}function Ni(e,t){let r=e.ref;return I(typeof r!="string","Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs"),r?(0,p.cloneElement)(e,{ref:n=>{Tt(r,n),Tt(t,n)}}):(0,p.cloneElement)(e,{ref:t})}var Ri=class{receiveHandlerId(e){this.handlerId!==e&&(this.handlerId=e,this.reconnect())}get connectTarget(){return this.dragSource}get dragSourceOptions(){return this.dragSourceOptionsInternal}set dragSourceOptions(e){this.dragSourceOptionsInternal=e}get dragPreviewOptions(){return this.dragPreviewOptionsInternal}set dragPreviewOptions(e){this.dragPreviewOptionsInternal=e}reconnect(){let e=this.reconnectDragSource();this.reconnectDragPreview(e)}reconnectDragSource(){let e=this.dragSource,t=this.didHandlerIdChange()||this.didConnectedDragSourceChange()||this.didDragSourceOptionsChange();return t&&this.disconnectDragSource(),this.handlerId?e?(t&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragSource=e,this.lastConnectedDragSourceOptions=this.dragSourceOptions,this.dragSourceUnsubscribe=this.backend.connectDragSource(this.handlerId,e,this.dragSourceOptions)),t):(this.lastConnectedDragSource=e,t):t}reconnectDragPreview(e=!1){let t=this.dragPreview,r=e||this.didHandlerIdChange()||this.didConnectedDragPreviewChange()||this.didDragPreviewOptionsChange();if(r&&this.disconnectDragPreview(),this.handlerId){if(!t){this.lastConnectedDragPreview=t;return}r&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragPreview=t,this.lastConnectedDragPreviewOptions=this.dragPreviewOptions,this.dragPreviewUnsubscribe=this.backend.connectDragPreview(this.handlerId,t,this.dragPreviewOptions))}}didHandlerIdChange(){return this.lastConnectedHandlerId!==this.handlerId}didConnectedDragSourceChange(){return this.lastConnectedDragSource!==this.dragSource}didConnectedDragPreviewChange(){return this.lastConnectedDragPreview!==this.dragPreview}didDragSourceOptionsChange(){return!Me(this.lastConnectedDragSourceOptions,this.dragSourceOptions)}didDragPreviewOptionsChange(){return!Me(this.lastConnectedDragPreviewOptions,this.dragPreviewOptions)}disconnectDragSource(){this.dragSourceUnsubscribe&&(this.dragSourceUnsubscribe=(this.dragSourceUnsubscribe(),void 0))}disconnectDragPreview(){this.dragPreviewUnsubscribe&&(this.dragPreviewUnsubscribe(),this.dragPreviewUnsubscribe=void 0,this.dragPreviewNode=null,this.dragPreviewRef=null)}get dragSource(){return this.dragSourceNode||this.dragSourceRef&&this.dragSourceRef.current}get dragPreview(){return this.dragPreviewNode||this.dragPreviewRef&&this.dragPreviewRef.current}clearDragSource(){this.dragSourceNode=null,this.dragSourceRef=null}clearDragPreview(){this.dragPreviewNode=null,this.dragPreviewRef=null}constructor(e){this.hooks=wt({dragSource:(t,r)=>{this.clearDragSource(),this.dragSourceOptions=r||null,Ae(t)?this.dragSourceRef=t:this.dragSourceNode=t,this.reconnectDragSource()},dragPreview:(t,r)=>{this.clearDragPreview(),this.dragPreviewOptions=r||null,Ae(t)?this.dragPreviewRef=t:this.dragPreviewNode=t,this.reconnectDragPreview()}}),this.handlerId=null,this.dragSourceRef=null,this.dragSourceOptionsInternal=null,this.dragPreviewRef=null,this.dragPreviewOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDragSource=null,this.lastConnectedDragSourceOptions=null,this.lastConnectedDragPreview=null,this.lastConnectedDragPreviewOptions=null,this.backend=e}},Pi=class{get connectTarget(){return this.dropTarget}reconnect(){let e=this.didHandlerIdChange()||this.didDropTargetChange()||this.didOptionsChange();e&&this.disconnectDropTarget();let t=this.dropTarget;if(this.handlerId){if(!t){this.lastConnectedDropTarget=t;return}e&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDropTarget=t,this.lastConnectedDropTargetOptions=this.dropTargetOptions,this.unsubscribeDropTarget=this.backend.connectDropTarget(this.handlerId,t,this.dropTargetOptions))}}receiveHandlerId(e){e!==this.handlerId&&(this.handlerId=e,this.reconnect())}get dropTargetOptions(){return this.dropTargetOptionsInternal}set dropTargetOptions(e){this.dropTargetOptionsInternal=e}didHandlerIdChange(){return this.lastConnectedHandlerId!==this.handlerId}didDropTargetChange(){return this.lastConnectedDropTarget!==this.dropTarget}didOptionsChange(){return!Me(this.lastConnectedDropTargetOptions,this.dropTargetOptions)}disconnectDropTarget(){this.unsubscribeDropTarget&&(this.unsubscribeDropTarget=(this.unsubscribeDropTarget(),void 0))}get dropTarget(){return this.dropTargetNode||this.dropTargetRef&&this.dropTargetRef.current}clearDropTarget(){this.dropTargetRef=null,this.dropTargetNode=null}constructor(e){this.hooks=wt({dropTarget:(t,r)=>{this.clearDropTarget(),this.dropTargetOptions=r,Ae(t)?this.dropTargetRef=t:this.dropTargetNode=t,this.reconnect()}}),this.handlerId=null,this.dropTargetRef=null,this.dropTargetOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDropTarget=null,this.lastConnectedDropTargetOptions=null,this.backend=e}};function L(){let{dragDropManager:e}=(0,p.useContext)(it);return I(e!=null,"Expected drag drop context"),e}function ji(e,t){let r=L(),n=(0,p.useMemo)(()=>new Ri(r.getBackend()),[r]);return H(()=>(n.dragSourceOptions=e||null,n.reconnect(),()=>n.disconnectDragSource()),[n,e]),H(()=>(n.dragPreviewOptions=t||null,n.reconnect(),()=>n.disconnectDragPreview()),[n,t]),n}function _i(){let e=L();return(0,p.useMemo)(()=>new Di(e),[e])}var Mi=class{beginDrag(){let e=this.spec,t=this.monitor,r=null;return r=typeof e.item=="object"?e.item:typeof e.item=="function"?e.item(t):{},r??null}canDrag(){let e=this.spec,t=this.monitor;return typeof e.canDrag=="boolean"?e.canDrag:typeof e.canDrag=="function"?e.canDrag(t):!0}isDragging(e,t){let r=this.spec,n=this.monitor,{isDragging:i}=r;return i?i(n):t===e.getSourceId()}endDrag(){let e=this.spec,t=this.monitor,r=this.connector,{end:n}=e;n&&n(t.getItem(),t),r.reconnect()}constructor(e,t,r){this.spec=e,this.monitor=t,this.connector=r}};function Ai(e,t,r){let n=(0,p.useMemo)(()=>new Mi(e,t,r),[t,r]);return(0,p.useEffect)(()=>{n.spec=e},[e]),n}function ki(e){return(0,p.useMemo)(()=>{let t=e.type;return I(t!=null,"spec.type must be defined"),t},[e])}function Li(e,t,r){let n=L(),i=Ai(e,t,r),s=ki(e);H(function(){if(s!=null){let[o,a]=Ei(s,i,n);return t.receiveHandlerId(o),r.receiveHandlerId(o),a}},[n,t,r,i,s])}function Fi(e,t){let r=Dt(e,t);I(!r.begin,"useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)");let n=_i(),i=ji(r.options,r.previewOptions);return Li(r,n,i),[St(r.collect,n,i),bi(i),Si(i)]}function Hi(e){let t=L().getMonitor(),[r,n]=bt(t,e);return(0,p.useEffect)(()=>t.subscribeToOffsetChange(n)),(0,p.useEffect)(()=>t.subscribeToStateChange(n)),r}function Ui(e){return(0,p.useMemo)(()=>e.hooks.dropTarget(),[e])}function Bi(e){let t=L(),r=(0,p.useMemo)(()=>new Pi(t.getBackend()),[t]);return H(()=>(r.dropTargetOptions=e||null,r.reconnect(),()=>r.disconnectDropTarget()),[e]),r}function zi(){let e=L();return(0,p.useMemo)(()=>new wi(e),[e])}function Wi(e){let{accept:t}=e;return(0,p.useMemo)(()=>(I(e.accept!=null,"accept must be defined"),Array.isArray(t)?t:[t]),[t])}var Vi=class{canDrop(){let e=this.spec,t=this.monitor;return e.canDrop?e.canDrop(t.getItem(),t):!0}hover(){let e=this.spec,t=this.monitor;e.hover&&e.hover(t.getItem(),t)}drop(){let e=this.spec,t=this.monitor;if(e.drop)return e.drop(t.getItem(),t)}constructor(e,t){this.spec=e,this.monitor=t}};function Gi(e,t){let r=(0,p.useMemo)(()=>new Vi(e,t),[t]);return(0,p.useEffect)(()=>{r.spec=e},[e]),r}function Ki(e,t,r){let n=L(),i=Gi(e,t),s=Wi(e);H(function(){let[o,a]=Ti(s,i,n);return t.receiveHandlerId(o),r.receiveHandlerId(o),a},[n,t,i,r,s.map(o=>o.toString()).join("|")])}function Et(e,t){let r=Dt(e,t),n=zi(),i=Bi(r.options);return Ki(r,n,i),[St(r.collect,n,i),Ui(i)]}function xt(e){let t=null;return()=>(t??(t=e()),t)}function $i(e,t){return e.filter(r=>r!==t)}function Yi(e,t){let r=new Set,n=s=>r.add(s);e.forEach(n),t.forEach(n);let i=[];return r.forEach(s=>i.push(s)),i}var qi=class{enter(e){let t=this.entered.length;return this.entered=Yi(this.entered.filter(r=>this.isNodeInDocument(r)&&(!r.contains||r.contains(e))),[e]),t===0&&this.entered.length>0}leave(e){let t=this.entered.length;return this.entered=$i(this.entered.filter(this.isNodeInDocument),e),t>0&&this.entered.length===0}reset(){this.entered=[]}constructor(e){this.entered=[],this.isNodeInDocument=e}},Xi=class{initializeExposedProperties(){Object.keys(this.config.exposeProperties).forEach(e=>{Object.defineProperty(this.item,e,{configurable:!0,enumerable:!0,get(){return console.warn(`Browser doesn't allow reading "${e}" until the drop event.`),null}})})}loadDataTransfer(e){if(e){let t={};Object.keys(this.config.exposeProperties).forEach(r=>{let n=this.config.exposeProperties[r];n!=null&&(t[r]={value:n(e,this.config.matchesTypes),configurable:!0,enumerable:!0})}),Object.defineProperties(this.item,t)}}canDrag(){return!0}beginDrag(){return this.item}isDragging(e,t){return t===e.getSourceId()}endDrag(){}constructor(e){this.config=e,this.item={},this.initializeExposedProperties()}},Ct=et({FILE:()=>Nt,HTML:()=>jt,TEXT:()=>Pt,URL:()=>Rt},1);const Nt="__NATIVE_FILE__",Rt="__NATIVE_URL__",Pt="__NATIVE_TEXT__",jt="__NATIVE_HTML__";function ke(e,t,r){return t.reduce((n,i)=>n||e.getData(i),"")??r}const Le={[Nt]:{exposeProperties:{files:e=>Array.prototype.slice.call(e.files),items:e=>e.items,dataTransfer:e=>e},matchesTypes:["Files"]},[jt]:{exposeProperties:{html:(e,t)=>ke(e,t,""),dataTransfer:e=>e},matchesTypes:["Html","text/html"]},[Rt]:{exposeProperties:{urls:(e,t)=>ke(e,t,"").split(`
2
2
  `),dataTransfer:e=>e},matchesTypes:["Url","text/uri-list"]},[Pt]:{exposeProperties:{text:(e,t)=>ke(e,t,""),dataTransfer:e=>e},matchesTypes:["Text","text/plain"]}};function Ji(e,t){let r=Le[e];if(!r)throw Error(`native type ${e} has no configuration`);let n=new Xi(r);return n.loadDataTransfer(t),n}function Fe(e){if(!e)return null;let t=Array.prototype.slice.call(e.types||[]);return Object.keys(Le).filter(r=>{let n=Le[r];return n!=null&&n.matchesTypes?n.matchesTypes.some(i=>t.indexOf(i)>-1):!1})[0]||null}const Qi=xt(()=>/firefox/i.test(navigator.userAgent)),_t=xt(()=>!!window.safari);var Mt=class{interpolate(e){let{xs:t,ys:r,c1s:n,c2s:i,c3s:s}=this,o=t.length-1;if(e===t[o])return r[o];let a=0,d=s.length-1,c;for(;a<=d;){c=Math.floor(.5*(a+d));let y=t[c];if(y<e)a=c+1;else if(y>e)d=c-1;else return r[c]}o=Math.max(0,d);let f=e-t[o],O=f*f;return r[o]+n[o]*f+i[o]*O+s[o]*f*O}constructor(e,t){let{length:r}=e,n=[];for(let h=0;h<r;h++)n.push(h);n.sort((h,u)=>e[h]<e[u]?-1:1);let i=[],s=[],o=[],a,d;for(let h=0;h<r-1;h++)a=e[h+1]-e[h],d=t[h+1]-t[h],s.push(a),i.push(d),o.push(d/a);let c=[o[0]];for(let h=0;h<s.length-1;h++){let u=o[h],l=o[h+1];if(u*l<=0)c.push(0);else{a=s[h];let g=s[h+1],m=a+g;c.push(3*m/((m+g)/u+(m+a)/l))}}c.push(o[o.length-1]);let f=[],O=[],y;for(let h=0;h<c.length-1;h++){y=o[h];let u=c[h],l=1/s[h],g=u+c[h+1]-y-y;f.push((y-u-g)*l),O.push(g*l*l)}this.xs=e,this.ys=t,this.c1s=c,this.c2s=f,this.c3s=O}},Zi=1;function At(e){let t=e.nodeType===Zi?e:e.parentElement;if(!t)return null;let{top:r,left:n}=t.getBoundingClientRect();return{x:n,y:r}}function le(e){return{x:e.clientX,y:e.clientY}}function es(e){var t;return e.nodeName==="IMG"&&(Qi()||!((t=document.documentElement)!=null&&t.contains(e)))}function ts(e,t,r,n){let i=e?t.width:r,s=e?t.height:n;return _t()&&e&&(s/=window.devicePixelRatio,i/=window.devicePixelRatio),{dragPreviewWidth:i,dragPreviewHeight:s}}function rs(e,t,r,n,i){let s=es(t),o=At(s?e:t),a={x:r.x-o.x,y:r.y-o.y},{offsetWidth:d,offsetHeight:c}=e,{anchorX:f,anchorY:O}=n,{dragPreviewWidth:y,dragPreviewHeight:h}=ts(s,t,d,c),u=()=>{let D=new Mt([0,.5,1],[a.y,a.y/c*h,a.y+h-c]).interpolate(O);return _t()&&s&&(D+=(window.devicePixelRatio-1)*h),D},l=()=>new Mt([0,.5,1],[a.x,a.x/d*y,a.x+y-d]).interpolate(f),{offsetX:g,offsetY:m}=i,b=g===0||g,S=m===0||m;return{x:b?g:l(),y:S?m:u()}}var ns=class{get window(){if(this.globalContext)return this.globalContext;if(typeof window<"u")return window}get document(){var e;if((e=this.globalContext)!=null&&e.document)return this.globalContext.document;if(this.window)return this.window.document}get rootElement(){var e;return((e=this.optionsArgs)==null?void 0:e.rootElement)||this.window}constructor(e,t){this.ownerDocument=null,this.globalContext=e,this.optionsArgs=t}};function is(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function kt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]==null?{}:arguments[t],n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){is(e,i,r[i])})}return e}var ss=class{profile(){var e,t;return{sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,sourceNodeOptions:this.sourceNodeOptions.size,sourceNodes:this.sourceNodes.size,dragStartSourceIds:((e=this.dragStartSourceIds)==null?void 0:e.length)||0,dropTargetIds:this.dropTargetIds.length,dragEnterTargetIds:this.dragEnterTargetIds.length,dragOverTargetIds:((t=this.dragOverTargetIds)==null?void 0:t.length)||0}}get window(){return this.options.window}get document(){return this.options.document}get rootElement(){return this.options.rootElement}setup(){let e=this.rootElement;if(e!==void 0){if(e.__isReactDndBackendSetUp)throw Error("Cannot have two HTML5 backends at the same time.");e.__isReactDndBackendSetUp=!0,this.addEventListeners(e)}}teardown(){let e=this.rootElement;if(e!==void 0&&(e.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.rootElement),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId)){var t;(t=this.window)==null||t.cancelAnimationFrame(this.asyncEndDragFrameId)}}connectDragPreview(e,t,r){return this.sourcePreviewNodeOptions.set(e,r),this.sourcePreviewNodes.set(e,t),()=>{this.sourcePreviewNodes.delete(e),this.sourcePreviewNodeOptions.delete(e)}}connectDragSource(e,t,r){this.sourceNodes.set(e,t),this.sourceNodeOptions.set(e,r);let n=s=>this.handleDragStart(s,e),i=s=>this.handleSelectStart(s);return t.setAttribute("draggable","true"),t.addEventListener("dragstart",n),t.addEventListener("selectstart",i),()=>{this.sourceNodes.delete(e),this.sourceNodeOptions.delete(e),t.removeEventListener("dragstart",n),t.removeEventListener("selectstart",i),t.setAttribute("draggable","false")}}connectDropTarget(e,t){let r=s=>this.handleDragEnter(s,e),n=s=>this.handleDragOver(s,e),i=s=>this.handleDrop(s,e);return t.addEventListener("dragenter",r),t.addEventListener("dragover",n),t.addEventListener("drop",i),()=>{t.removeEventListener("dragenter",r),t.removeEventListener("dragover",n),t.removeEventListener("drop",i)}}addEventListeners(e){e.addEventListener&&(e.addEventListener("dragstart",this.handleTopDragStart),e.addEventListener("dragstart",this.handleTopDragStartCapture,!0),e.addEventListener("dragend",this.handleTopDragEndCapture,!0),e.addEventListener("dragenter",this.handleTopDragEnter),e.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.addEventListener("dragover",this.handleTopDragOver),e.addEventListener("dragover",this.handleTopDragOverCapture,!0),e.addEventListener("drop",this.handleTopDrop),e.addEventListener("drop",this.handleTopDropCapture,!0))}removeEventListeners(e){e.removeEventListener&&(e.removeEventListener("dragstart",this.handleTopDragStart),e.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),e.removeEventListener("dragend",this.handleTopDragEndCapture,!0),e.removeEventListener("dragenter",this.handleTopDragEnter),e.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.removeEventListener("dragover",this.handleTopDragOver),e.removeEventListener("dragover",this.handleTopDragOverCapture,!0),e.removeEventListener("drop",this.handleTopDrop),e.removeEventListener("drop",this.handleTopDropCapture,!0))}getCurrentSourceNodeOptions(){let e=this.monitor.getSourceId(),t=this.sourceNodeOptions.get(e);return kt({dropEffect:this.altKeyPressed?"copy":"move"},t||{})}getCurrentDropEffect(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}getCurrentSourcePreviewNodeOptions(){let e=this.monitor.getSourceId();return kt({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(e)||{})}isDraggingNativeItem(){let e=this.monitor.getItemType();return Object.keys(Ct).some(t=>Ct[t]===e)}beginDragNativeItem(e,t){this.clearCurrentDragSourceNode(),this.currentNativeSource=Ji(e,t),this.currentNativeHandle=this.registry.addSource(e,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}setCurrentDragSourceNode(e){this.clearCurrentDragSourceNode(),this.currentDragSourceNode=e,this.mouseMoveTimeoutTimer=setTimeout(()=>{var t;return(t=this.rootElement)==null?void 0:t.addEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)},1e3)}clearCurrentDragSourceNode(){if(this.currentDragSourceNode){if(this.currentDragSourceNode=null,this.rootElement){var e;(e=this.window)==null||e.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)}return this.mouseMoveTimeoutTimer=null,!0}return!1}handleDragStart(e,t){e.defaultPrevented||(this.dragStartSourceIds||(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(t))}handleDragEnter(e,t){this.dragEnterTargetIds.unshift(t)}handleDragOver(e,t){this.dragOverTargetIds===null&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(t)}handleDrop(e,t){this.dropTargetIds.unshift(t)}constructor(e,t,r){this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.sourceNodes=new Map,this.sourceNodeOptions=new Map,this.dragStartSourceIds=null,this.dropTargetIds=[],this.dragEnterTargetIds=[],this.currentNativeSource=null,this.currentNativeHandle=null,this.currentDragSourceNode=null,this.altKeyPressed=!1,this.mouseMoveTimeoutTimer=null,this.asyncEndDragFrameId=null,this.dragOverTargetIds=null,this.lastClientOffset=null,this.hoverRafId=null,this.getSourceClientOffset=n=>{let i=this.sourceNodes.get(n);return i&&At(i)||null},this.endDragNativeItem=()=>{this.isDraggingNativeItem()&&(this.actions.endDrag(),this.currentNativeHandle&&this.registry.removeSource(this.currentNativeHandle),this.currentNativeHandle=null,this.currentNativeSource=null)},this.isNodeInDocument=n=>!!(n&&this.document&&this.document.body&&this.document.body.contains(n)),this.endDragIfSourceWasRemovedFromDOM=()=>{let n=this.currentDragSourceNode;n==null||this.isNodeInDocument(n)||(this.clearCurrentDragSourceNode()&&this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover())},this.scheduleHover=n=>{this.hoverRafId===null&&typeof requestAnimationFrame<"u"&&(this.hoverRafId=requestAnimationFrame(()=>{this.monitor.isDragging()&&this.actions.hover(n||[],{clientOffset:this.lastClientOffset}),this.hoverRafId=null}))},this.cancelHover=()=>{this.hoverRafId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this.hoverRafId),this.hoverRafId=null)},this.handleTopDragStartCapture=()=>{this.clearCurrentDragSourceNode(),this.dragStartSourceIds=[]},this.handleTopDragStart=n=>{if(n.defaultPrevented)return;let{dragStartSourceIds:i}=this;this.dragStartSourceIds=null;let s=le(n);this.monitor.isDragging()&&(this.actions.endDrag(),this.cancelHover()),this.actions.beginDrag(i||[],{publishSource:!1,getSourceClientOffset:this.getSourceClientOffset,clientOffset:s});let{dataTransfer:o}=n,a=Fe(o);if(this.monitor.isDragging()){if(o&&typeof o.setDragImage=="function"){let c=this.monitor.getSourceId(),f=this.sourceNodes.get(c),O=this.sourcePreviewNodes.get(c)||f;if(O){let{anchorX:y,anchorY:h,offsetX:u,offsetY:l}=this.getCurrentSourcePreviewNodeOptions(),g=rs(f,O,s,{anchorX:y,anchorY:h},{offsetX:u,offsetY:l});o.setDragImage(O,g.x,g.y)}}try{o==null||o.setData("application/json",{})}catch{}this.setCurrentDragSourceNode(n.target);let{captureDraggingState:d}=this.getCurrentSourcePreviewNodeOptions();d?this.actions.publishDragSource():setTimeout(()=>this.actions.publishDragSource(),0)}else if(a)this.beginDragNativeItem(a);else{if(o&&!o.types&&(n.target&&!n.target.hasAttribute||!n.target.hasAttribute("draggable")))return;n.preventDefault()}},this.handleTopDragEndCapture=()=>{this.clearCurrentDragSourceNode()&&this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover()},this.handleTopDragEnterCapture=n=>{if(this.dragEnterTargetIds=[],this.isDraggingNativeItem()){var i;(i=this.currentNativeSource)==null||i.loadDataTransfer(n.dataTransfer)}if(!this.enterLeaveCounter.enter(n.target)||this.monitor.isDragging())return;let{dataTransfer:s}=n,o=Fe(s);o&&this.beginDragNativeItem(o,s)},this.handleTopDragEnter=n=>{let{dragEnterTargetIds:i}=this;this.dragEnterTargetIds=[],this.monitor.isDragging()&&(this.altKeyPressed=n.altKey,i.length>0&&this.actions.hover(i,{clientOffset:le(n)}),i.some(s=>this.monitor.canDropOnTarget(s))&&(n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=this.getCurrentDropEffect())))},this.handleTopDragOverCapture=n=>{if(this.dragOverTargetIds=[],this.isDraggingNativeItem()){var i;(i=this.currentNativeSource)==null||i.loadDataTransfer(n.dataTransfer)}},this.handleTopDragOver=n=>{let{dragOverTargetIds:i}=this;if(this.dragOverTargetIds=[],!this.monitor.isDragging()){n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect="none");return}this.altKeyPressed=n.altKey,this.lastClientOffset=le(n),this.scheduleHover(i),(i||[]).some(s=>this.monitor.canDropOnTarget(s))?(n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=this.getCurrentDropEffect())):this.isDraggingNativeItem()?n.preventDefault():(n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect="none"))},this.handleTopDragLeaveCapture=n=>{this.isDraggingNativeItem()&&n.preventDefault(),this.enterLeaveCounter.leave(n.target)&&(this.isDraggingNativeItem()&&setTimeout(()=>this.endDragNativeItem(),0),this.cancelHover())},this.handleTopDropCapture=n=>{if(this.dropTargetIds=[],this.isDraggingNativeItem()){var i;n.preventDefault(),(i=this.currentNativeSource)==null||i.loadDataTransfer(n.dataTransfer)}else Fe(n.dataTransfer)&&n.preventDefault();this.enterLeaveCounter.reset()},this.handleTopDrop=n=>{let{dropTargetIds:i}=this;this.dropTargetIds=[],this.actions.hover(i,{clientOffset:le(n)}),this.actions.drop({dropEffect:this.getCurrentDropEffect()}),this.isDraggingNativeItem()?this.endDragNativeItem():this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover()},this.handleSelectStart=n=>{let i=n.target;typeof i.dragDrop=="function"&&(i.tagName==="INPUT"||i.tagName==="SELECT"||i.tagName==="TEXTAREA"||i.isContentEditable||(n.preventDefault(),i.dragDrop()))},this.options=new ns(t,r),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.registry=e.getRegistry(),this.enterLeaveCounter=new qi(this.isNodeInDocument)}},de;function os(){return de||(de=new Image,de.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),de}const Lt=function(e,t,r){return new ss(e,t,r)},Ft=(0,p.createContext)(null);function N(){let e=(0,p.useContext)(Ft);if(e===null)throw Error("No Tree Api Provided");return e}const Ht=(0,p.createContext)(null);function as(){let e=(0,p.useContext)(Ht);if(e===null)throw Error("Provide a NodesContext");return e}const Ut=(0,p.createContext)(null);function ls(){let e=(0,p.useContext)(Ut);if(e===null)throw Error("Provide a DnDContext");return e}const Bt=(0,p.createContext)(0);function zt(){(0,p.useContext)(Bt)}var ds=et({access:()=>J,bound:()=>ce,dfs:()=>He,focusNextElement:()=>Yt,focusPrevElement:()=>qt,getInsertIndex:()=>er,getInsertParentId:()=>tr,identify:()=>U,identifyNull:()=>Jt,indexOf:()=>$t,isClosed:()=>Vt,isDescendant:()=>Kt,isItem:()=>Wt,isOpenWithEmptyChildren:()=>Gt,mergeRefs:()=>fs,noop:()=>cs,safeRun:()=>Qt,waitFor:()=>Zt,walk:()=>ue},1);function ce(e,t,r){return Math.max(Math.min(e,r),t)}function Wt(e){return e&&e.isLeaf}function Vt(e){return e&&e.isInternal&&!e.isOpen}function Gt(e){var t;return e&&e.isOpen&&!((t=e.children)!=null&&t.length)}const Kt=(e,t)=>{let r=e;for(;r;){if(r.id===t.id)return!0;r=r.parent}return!1},$t=e=>{if(!e.parent)throw Error("Node does not have a parent");return e.parent.children.findIndex(t=>t.id===e.id)};function cs(){}function He(e,t){if(!e)return null;if(e.id===t)return e;if(e.children)for(let r of e.children){let n=He(r,t);if(n)return n}return null}function ue(e,t){if(t(e),e.children)for(let r of e.children)ue(r,t)}function Yt(e){let t=Xt(e),r;for(let n=0;n<t.length;++n)if(t[n]===e){r=us(t,n);break}r==null||r.focus()}function qt(e){let t=Xt(e),r;for(let n=0;n<t.length;++n)if(t[n]===e){r=hs(t,n);break}r==null||r.focus()}function us(e,t){return t+1<e.length?e[t+1]:e[0]}function hs(e,t){return t-1>=0?e[t-1]:e[e.length-1]}function Xt(e){return Array.from(document.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)')).filter(t=>t===e||!e.contains(t))}function J(e,t){return typeof t=="boolean"?t:typeof t=="string"?e[t]:t(e)}function Jt(e){return e===null?null:U(e)}function U(e){return typeof e=="string"?e:e.id}function fs(...e){return t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})}}function Qt(e,...t){if(e)return e(...t)}function Zt(e){return new Promise((t,r)=>{let n=0;function i(){n+=1,n===100&&r(),e()?t():setTimeout(i,10)}i()})}function er(e){var r;let t=e.focusedNode;return t?t.isOpen?0:t.parent?t.childIndex+1:0:((r=e.root.children)==null?void 0:r.length)??0}function tr(e){let t=e.focusedNode;return t?t.isOpen?t.id:t.parent&&!t.parent.isRoot?t.parent.id:null:null}var gs={display:"flex",alignItems:"center",zIndex:1},ps={flex:1,height:"2px",background:"#4B91E2",borderRadius:"1px"},ms={width:"4px",height:"4px",boxShadow:"0 0 0 3px #4B91E2",borderRadius:"50%"};const vs=p.memo(function({top:e,left:t,indent:r}){let n={position:"absolute",pointerEvents:"none",top:e-2+"px",left:t+"px",right:r+"px"};return(0,v.jsxs)("div",{style:Object.assign(Object.assign({},gs),n),children:[(0,v.jsx)("div",{style:Object.assign({},ms)}),(0,v.jsx)("div",{style:Object.assign({},ps)})]})});function ys({node:e,attrs:t,innerRef:r,children:n}){return(0,v.jsx)("div",Object.assign({},t,{ref:r,onFocus:i=>i.stopPropagation(),onClick:e.handleClick,children:n}))}function Os(e){return(0,v.jsxs)("div",{ref:e.dragHandle,style:e.style,children:[(0,v.jsx)("span",{onClick:t=>{t.stopPropagation(),e.node.toggle()},children:e.node.isLeaf?"\u{1F333}":e.node.isOpen?"\u{1F5C1}":"\u{1F5C0}"})," ",e.node.isEditing?(0,v.jsx)(bs,Object.assign({},e)):(0,v.jsx)(Is,Object.assign({},e))]})}function Is(e){return(0,v.jsx)(v.Fragment,{children:(0,v.jsx)("span",{children:e.node.data.name})})}function bs({node:e}){let t=(0,p.useRef)();return(0,p.useEffect)(()=>{var r,n;(r=t.current)==null||r.focus(),(n=t.current)==null||n.select()},[]),(0,v.jsx)("input",{ref:t,defaultValue:e.data.name,onBlur:()=>e.reset(),onKeyDown:r=>{var n;r.key==="Escape"&&e.reset(),r.key==="Enter"&&e.submit(((n=t.current)==null?void 0:n.value)||"")}})}function Ue(e){return{type:"EDIT",id:e}}function Ss(e={id:null},t){return t.type==="EDIT"?Object.assign(Object.assign({},e),{id:t.id}):e}function V(e){return{type:"FOCUS",id:e}}function Ds(){return{type:"TREE_BLUR"}}function ws(e={id:null,treeFocused:!1},t){return t.type==="FOCUS"?Object.assign(Object.assign({},e),{id:t.id,treeFocused:!0}):t.type==="TREE_BLUR"?Object.assign(Object.assign({},e),{treeFocused:!1}):e}var rr=class Sr{constructor(t){this.handleClick=r=>{r.metaKey&&!this.tree.props.disableMultiSelection?this.isSelected?this.deselect():this.selectMulti():r.shiftKey&&!this.tree.props.disableMultiSelection?this.selectContiguous():(this.select(),this.activate())},this.tree=t.tree,this.id=t.id,this.data=t.data,this.level=t.level,this.children=t.children,this.parent=t.parent,this.isDraggable=t.isDraggable,this.rowIndex=t.rowIndex}get isRoot(){return this.id===Be}get isLeaf(){return!Array.isArray(this.children)}get isInternal(){return!this.isLeaf}get isOpen(){return this.isLeaf?!1:this.tree.isOpen(this.id)}get isClosed(){return this.isLeaf?!1:!this.tree.isOpen(this.id)}get isEditable(){return this.tree.isEditable(this.data)}get isEditing(){return this.tree.editingId===this.id}get isSelected(){return this.tree.isSelected(this.id)}get isOnlySelection(){return this.isSelected&&this.tree.hasOneSelection}get isSelectedStart(){var t;return this.isSelected&&!((t=this.prev)!=null&&t.isSelected)}get isSelectedEnd(){var t;return this.isSelected&&!((t=this.next)!=null&&t.isSelected)}get isFocused(){return this.tree.isFocused(this.id)}get isDragging(){return this.tree.isDragging(this.id)}get willReceiveDrop(){return this.tree.willReceiveDrop(this.id)}get state(){return{isClosed:this.isClosed,isDragging:this.isDragging,isEditing:this.isEditing,isFocused:this.isFocused,isInternal:this.isInternal,isLeaf:this.isLeaf,isOpen:this.isOpen,isSelected:this.isSelected,isSelectedEnd:this.isSelectedEnd,isSelectedStart:this.isSelectedStart,willReceiveDrop:this.willReceiveDrop}}get childIndex(){return this.parent&&this.parent.children?this.parent.children.findIndex(t=>t.id===this.id):-1}get next(){return this.rowIndex===null?null:this.tree.at(this.rowIndex+1)}get prev(){return this.rowIndex===null?null:this.tree.at(this.rowIndex-1)}get nextSibling(){var r;let t=this.childIndex;return((r=this.parent)==null?void 0:r.children[t+1])??null}isAncestorOf(t){if(!t)return!1;let r=t;for(;r;){if(r.id===this.id)return!0;r=r.parent}return!1}select(){this.tree.select(this)}deselect(){this.tree.deselect(this)}selectMulti(){this.tree.selectMulti(this)}selectContiguous(){this.tree.selectContiguous(this)}activate(){this.tree.activate(this)}focus(){this.tree.focus(this)}toggle(){this.tree.toggle(this)}open(){this.tree.open(this)}openParents(){this.tree.openParents(this)}close(){this.tree.close(this)}submit(t){this.tree.submit(this,t)}reset(){this.tree.reset()}clone(){return new Sr(Object.assign({},this))}edit(){return this.tree.edit(this)}};const Be="__REACT_ARBORIST_INTERNAL_ROOT__";function nr(e){function t(n,i,s){let o=new rr({tree:e,data:n,level:i,parent:s,id:e.accessId(n),children:null,isDraggable:e.isDraggable(n),rowIndex:null}),a=e.accessChildren(n);return a&&(o.children=a.map(d=>t(d,i+1,o))),o}let r=new rr({tree:e,id:Be,data:{id:Be},level:-1,parent:null,children:null,isDraggable:!0,rowIndex:null});return r.children=(e.props.data??[]).map(n=>t(n,0,r)),r}const ze={open(e,t){return{type:"VISIBILITY_OPEN",id:e,filtered:t}},close(e,t){return{type:"VISIBILITY_CLOSE",id:e,filtered:t}},toggle(e,t){return{type:"VISIBILITY_TOGGLE",id:e,filtered:t}},clear(e){return{type:"VISIBILITY_CLEAR",filtered:e}}};function ir(e={},t){if(t.type==="VISIBILITY_OPEN")return Object.assign(Object.assign({},e),{[t.id]:!0});if(t.type==="VISIBILITY_CLOSE")return Object.assign(Object.assign({},e),{[t.id]:!1});if(t.type==="VISIBILITY_TOGGLE"){let r=e[t.id];return Object.assign(Object.assign({},e),{[t.id]:!r})}else return t.type==="VISIBILITY_CLEAR"?{}:e}function Ts(e={filtered:{},unfiltered:{}},t){return t.type.startsWith("VISIBILITY")?t.filtered?Object.assign(Object.assign({},e),{filtered:ir(e.filtered,t)}):Object.assign(Object.assign({},e),{unfiltered:ir(e.unfiltered,t)}):e}const G=e=>({nodes:{open:{filtered:{},unfiltered:(e==null?void 0:e.initialOpenState)??{}},focus:{id:null,treeFocused:!1},edit:{id:null},drag:{id:null,selectedIds:[],destinationParentId:null,destinationIndex:null},selection:{ids:new Set,anchor:null,mostRecent:null}},dnd:{cursor:{type:"none"},dragId:null,dragIds:[],parentId:null,index:-1}}),j={clear:()=>({type:"SELECTION_CLEAR"}),only:e=>({type:"SELECTION_ONLY",id:U(e)}),add:e=>({type:"SELECTION_ADD",ids:(Array.isArray(e)?e:[e]).map(U)}),remove:e=>({type:"SELECTION_REMOVE",ids:(Array.isArray(e)?e:[e]).map(U)}),set:e=>Object.assign({type:"SELECTION_SET"},e),mostRecent:e=>({type:"SELECTION_MOST_RECENT",id:e===null?null:U(e)}),anchor:e=>({type:"SELECTION_ANCHOR",id:e===null?null:U(e)})};function Es(e=G().nodes.selection,t){let r=e.ids;switch(t.type){case"SELECTION_CLEAR":return Object.assign(Object.assign({},e),{ids:new Set});case"SELECTION_ONLY":return Object.assign(Object.assign({},e),{ids:new Set([t.id])});case"SELECTION_ADD":return t.ids.length===0?e:(t.ids.forEach(n=>r.add(n)),Object.assign(Object.assign({},e),{ids:new Set(r)}));case"SELECTION_REMOVE":return t.ids.length===0?e:(t.ids.forEach(n=>r.delete(n)),Object.assign(Object.assign({},e),{ids:new Set(r)}));case"SELECTION_SET":return Object.assign(Object.assign({},e),{ids:t.ids,mostRecent:t.mostRecent,anchor:t.anchor});case"SELECTION_MOST_RECENT":return Object.assign(Object.assign({},e),{mostRecent:t.id});case"SELECTION_ANCHOR":return Object.assign(Object.assign({},e),{anchor:t.id});default:return e}}const K={cursor(e){return{type:"DND_CURSOR",cursor:e}},dragStart(e,t){return{type:"DND_DRAG_START",id:e,dragIds:t}},dragEnd(){return{type:"DND_DRAG_END"}},hovering(e,t){return{type:"DND_HOVERING",parentId:e,index:t}}};function xs(e=G().dnd,t){switch(t.type){case"DND_CURSOR":return Object.assign(Object.assign({},e),{cursor:t.cursor});case"DND_DRAG_START":return Object.assign(Object.assign({},e),{dragId:t.id,dragIds:t.dragIds});case"DND_DRAG_END":return G().dnd;case"DND_HOVERING":return Object.assign(Object.assign({},e),{parentId:t.parentId,index:t.index});default:return e}}var Cs={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"},Ns=e=>{if(!e)return{display:"none"};let{x:t,y:r}=e;return{transform:`translate(${t}px, ${r}px)`}},Rs=e=>{if(!e)return{display:"none"};let{x:t,y:r}=e;return{transform:`translate(${t+10}px, ${r+10}px)`}};function sr({offset:e,mouse:t,id:r,dragIds:n,isDragging:i}){return(0,v.jsxs)(Ps,{isDragging:i,children:[(0,v.jsx)(js,{offset:e,children:(0,v.jsx)(Ms,{id:r,dragIds:n})}),(0,v.jsx)(_s,{mouse:t,count:n.length})]})}var Ps=(0,p.memo)(function(e){return e.isDragging?(0,v.jsx)("div",{style:Cs,children:e.children}):null});function js(e){return(0,v.jsx)("div",{className:"row preview",style:Ns(e.offset),children:e.children})}function _s(e){let{count:t,mouse:r}=e;return t>1?(0,v.jsx)("div",{className:"selected-count",style:Rs(r),children:t}):null}var Ms=(0,p.memo)(function(e){let t=N(),r=t.get(e.id);return r?(0,v.jsx)(t.renderNode,{preview:!0,node:r,style:{paddingLeft:r.level*t.indent,opacity:.2,background:"transparent"},tree:t}):null}),or=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function As(e,t){return!!(e===t||or(e)&&or(t))}function ks(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!As(e[r],t[r]))return!1;return!0}function Ls(e,t){t===void 0&&(t=ks);var r,n=[],i,s=!1;function o(){var a=[...arguments];return s&&r===this&&t(a,n)||(i=e.apply(this,a),s=!0,r=this,n=a),i}return o}var We=Ls,ar=typeof performance=="object"&&typeof performance.now=="function"?function(){return performance.now()}:function(){return Date.now()};function lr(e){cancelAnimationFrame(e.id)}function Fs(e,t){var r=ar();function n(){ar()-r>=t?e.call(null):i.id=requestAnimationFrame(n)}var i={id:requestAnimationFrame(n)};return i}var Ve=-1;function dr(e){if(e===void 0&&(e=!1),Ve===-1||e){var t=document.createElement("div"),r=t.style;r.width="50px",r.height="50px",r.overflow="scroll",document.body.appendChild(t),Ve=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return Ve}var Q=null;function cr(e){if(e===void 0&&(e=!1),Q===null||e){var t=document.createElement("div"),r=t.style;r.width="50px",r.height="50px",r.overflow="scroll",r.direction="rtl";var n=document.createElement("div"),i=n.style;return i.width="100px",i.height="100px",t.appendChild(n),document.body.appendChild(t),t.scrollLeft>0?Q="positive-descending":(t.scrollLeft=1,Q=t.scrollLeft===0?"negative":"positive-ascending"),document.body.removeChild(t),Q}return Q}var Hs=150,Us=function(e,t){return e};function Bs(e){var t,r=e.getItemOffset,n=e.getEstimatedTotalSize,i=e.getItemSize,s=e.getOffsetForIndexAndAlignment,o=e.getStartIndexForOffset,a=e.getStopIndexForStartIndex,d=e.initInstanceProps,c=e.shouldResetStyleCacheOnItemSizeChange,f=e.validateProps;return t=(function(O){Qr(y,O);function y(u){var l=O.call(this,u)||this;return l._instanceProps=d(l.props,nt(l)),l._outerRef=void 0,l._resetIsScrollingTimeoutId=null,l.state={instance:nt(l),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof l.props.initialScrollOffset=="number"?l.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},l._callOnItemsRendered=void 0,l._callOnItemsRendered=We(function(g,m,b,S){return l.props.onItemsRendered({overscanStartIndex:g,overscanStopIndex:m,visibleStartIndex:b,visibleStopIndex:S})}),l._callOnScroll=void 0,l._callOnScroll=We(function(g,m,b){return l.props.onScroll({scrollDirection:g,scrollOffset:m,scrollUpdateWasRequested:b})}),l._getItemStyle=void 0,l._getItemStyle=function(g){var m=l.props,b=m.direction,S=m.itemSize,D=m.layout,w=l._getItemStyleCache(c&&S,c&&D,c&&b),x;if(w.hasOwnProperty(g))x=w[g];else{var C=r(l.props,g,l._instanceProps),F=i(l.props,g,l._instanceProps),z=b==="horizontal"||D==="horizontal",Z=b==="rtl",ee=z?C:0;w[g]=x={position:"absolute",left:Z?void 0:ee,right:Z?ee:void 0,top:z?0:C,height:z?"100%":F,width:z?F:"100%"}}return x},l._getItemStyleCache=void 0,l._getItemStyleCache=We(function(g,m,b){return{}}),l._onScrollHorizontal=function(g){var m=g.currentTarget,b=m.clientWidth,S=m.scrollLeft,D=m.scrollWidth;l.setState(function(w){if(w.scrollOffset===S)return null;var x=l.props.direction,C=S;if(x==="rtl")switch(cr()){case"negative":C=-S;break;case"positive-descending":C=D-b-S;break}return C=Math.max(0,Math.min(C,D-b)),{isScrolling:!0,scrollDirection:w.scrollOffset<C?"forward":"backward",scrollOffset:C,scrollUpdateWasRequested:!1}},l._resetIsScrollingDebounced)},l._onScrollVertical=function(g){var m=g.currentTarget,b=m.clientHeight,S=m.scrollHeight,D=m.scrollTop;l.setState(function(w){if(w.scrollOffset===D)return null;var x=Math.max(0,Math.min(D,S-b));return{isScrolling:!0,scrollDirection:w.scrollOffset<x?"forward":"backward",scrollOffset:x,scrollUpdateWasRequested:!1}},l._resetIsScrollingDebounced)},l._outerRefSetter=function(g){var m=l.props.outerRef;l._outerRef=g,typeof m=="function"?m(g):typeof m=="object"&&m&&m.hasOwnProperty("current")&&(m.current=g)},l._resetIsScrollingDebounced=function(){l._resetIsScrollingTimeoutId!==null&&lr(l._resetIsScrollingTimeoutId),l._resetIsScrollingTimeoutId=Fs(l._resetIsScrolling,Hs)},l._resetIsScrolling=function(){l._resetIsScrollingTimeoutId=null,l.setState({isScrolling:!1},function(){l._getItemStyleCache(-1,null)})},l}y.getDerivedStateFromProps=function(u,l){return zs(u,l),f(u),null};var h=y.prototype;return h.scrollTo=function(u){u=Math.max(0,u),this.setState(function(l){return l.scrollOffset===u?null:{scrollDirection:l.scrollOffset<u?"forward":"backward",scrollOffset:u,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},h.scrollToItem=function(u,l){l===void 0&&(l="auto");var g=this.props,m=g.itemCount,b=g.layout,S=this.state.scrollOffset;u=Math.max(0,Math.min(u,m-1));var D=0;if(this._outerRef){var w=this._outerRef;D=b==="vertical"?w.scrollWidth>w.clientWidth?dr():0:w.scrollHeight>w.clientHeight?dr():0}this.scrollTo(s(this.props,u,l,S,this._instanceProps,D))},h.componentDidMount=function(){var u=this.props,l=u.direction,g=u.initialScrollOffset,m=u.layout;if(typeof g=="number"&&this._outerRef!=null){var b=this._outerRef;l==="horizontal"||m==="horizontal"?b.scrollLeft=g:b.scrollTop=g}this._callPropsCallbacks()},h.componentDidUpdate=function(){var u=this.props,l=u.direction,g=u.layout,m=this.state,b=m.scrollOffset;if(m.scrollUpdateWasRequested&&this._outerRef!=null){var S=this._outerRef;if(l==="horizontal"||g==="horizontal")if(l==="rtl")switch(cr()){case"negative":S.scrollLeft=-b;break;case"positive-ascending":S.scrollLeft=b;break;default:var D=S.clientWidth;S.scrollLeft=S.scrollWidth-D-b;break}else S.scrollLeft=b;else S.scrollTop=b}this._callPropsCallbacks()},h.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&lr(this._resetIsScrollingTimeoutId)},h.render=function(){var u=this.props,l=u.children,g=u.className,m=u.direction,b=u.height,S=u.innerRef,D=u.innerElementType,w=u.innerTagName,x=u.itemCount,C=u.itemData,F=u.itemKey,z=F===void 0?Us:F,Z=u.layout,ee=u.outerElementType,Dr=u.outerTagName,wr=u.style,Tr=u.useIsScrolling,Er=u.width,Xe=this.state.isScrolling,me=m==="horizontal"||Z==="horizontal",xr=me?this._onScrollHorizontal:this._onScrollVertical,Je=this._getRangeToRender(),Cr=Je[0],Nr=Je[1],Qe=[];if(x>0)for(var Y=Cr;Y<=Nr;Y++)Qe.push((0,p.createElement)(l,{data:C,key:z(Y,C),index:Y,isScrolling:Tr?Xe:void 0,style:this._getItemStyle(Y)}));var Ze=n(this.props,this._instanceProps);return(0,p.createElement)(ee||Dr||"div",{className:g,onScroll:xr,ref:this._outerRefSetter,style:$r({position:"relative",height:b,width:Er,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:m},wr)},(0,p.createElement)(D||w||"div",{children:Qe,ref:S,style:{height:me?"100%":Ze,pointerEvents:Xe?"none":void 0,width:me?Ze:"100%"}}))},h._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"&&this.props.itemCount>0){var u=this._getRangeToRender(),l=u[0],g=u[1],m=u[2],b=u[3];this._callOnItemsRendered(l,g,m,b)}if(typeof this.props.onScroll=="function"){var S=this.state,D=S.scrollDirection,w=S.scrollOffset,x=S.scrollUpdateWasRequested;this._callOnScroll(D,w,x)}},h._getRangeToRender=function(){var u=this.props,l=u.itemCount,g=u.overscanCount,m=this.state,b=m.isScrolling,S=m.scrollDirection,D=m.scrollOffset;if(l===0)return[0,0,0,0];var w=o(this.props,D,this._instanceProps),x=a(this.props,w,D,this._instanceProps),C=!b||S==="backward"?Math.max(1,g):1,F=!b||S==="forward"?Math.max(1,g):1;return[Math.max(0,w-C),Math.max(0,Math.min(l-1,x+F)),w,x]},y})(p.PureComponent),t.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},t}var zs=function(e,t){e.children,e.direction,e.height,e.layout,e.innerTagName,e.outerTagName,e.width,t.instance},Ws=Bs({getItemOffset:function(e,t){return t*e.itemSize},getItemSize:function(e,t){return e.itemSize},getEstimatedTotalSize:function(e){var t=e.itemCount;return e.itemSize*t},getOffsetForIndexAndAlignment:function(e,t,r,n,i,s){var o=e.direction,a=e.height,d=e.itemCount,c=e.itemSize,f=e.layout,O=e.width,y=o==="horizontal"||f==="horizontal"?O:a,h=Math.max(0,d*c-y),u=Math.min(h,t*c),l=Math.max(0,t*c-y+c+s);switch(r==="smart"&&(r=n>=l-y&&n<=u+y?"auto":"center"),r){case"start":return u;case"end":return l;case"center":var g=Math.round(l+(u-l)/2);return g<Math.ceil(y/2)?0:g>h+Math.floor(y/2)?h:g;default:return n>=l&&n<=u?n:n<l?l:u}},getStartIndexForOffset:function(e,t){var r=e.itemCount,n=e.itemSize;return Math.max(0,Math.min(r-1,Math.floor(t/n)))},getStopIndexForStartIndex:function(e,t,r){var n=e.direction,i=e.height,s=e.itemCount,o=e.itemSize,a=e.layout,d=e.width,c=n==="horizontal"||a==="horizontal",f=t*o,O=c?d:i,y=Math.ceil((O+r-f)/o);return Math.max(0,Math.min(s-1,t+y-1))},initInstanceProps:function(e){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(e){e.itemSize}});function Vs(){let e=N(),t=ls().cursor;if(!t||t.type!=="line")return null;let r=e.indent,n=e.rowHeight*t.index+(e.props.padding??e.props.paddingTop??0),i=r*t.level,s=e.renderCursor;return(0,v.jsx)(s,{top:n,left:i,indent:r})}var Gs=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r};const Ks=(0,p.forwardRef)(function(e,t){let{children:r}=e,n=Gs(e,["children"]),i=N();return(0,v.jsxs)("div",Object.assign({ref:t},n,{onClick:s=>{s.currentTarget===s.target&&i.deselectAll()},children:[(0,v.jsx)($s,{}),r]}))});var $s=()=>{let e=N();return(0,v.jsx)("div",{style:{height:e.visibleNodes.length*e.rowHeight,width:"100%",position:"absolute",left:"0",right:"0"},children:(0,v.jsx)(Vs,{})})},Ys=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r};const qs=(0,p.forwardRef)(function(e,t){var{style:r}=e,n=Ys(e,["style"]);let i=N(),s=i.props.padding??i.props.paddingTop??0,o=i.props.padding??i.props.paddingBottom??0;return(0,v.jsx)("div",Object.assign({ref:t,style:Object.assign(Object.assign({},r),{height:`${parseFloat(r.height)+s+o}px`})},n))});function Xs(e){let t=N(),r=t.selectedIds,[n,i,s]=Fi(()=>({canDrag:()=>e.isDraggable,type:"NODE",item:()=>{let o=t.isSelected(e.id)?Array.from(r):[e.id];return t.dispatch(K.dragStart(e.id,o)),{id:e.id,dragIds:o}},end:()=>{t.hideCursor(),t.dispatch(K.dragEnd())}}),[r,e]);return(0,p.useEffect)(()=>{s(os())},[s]),i}function Js(e,t){let r=e.getBoundingClientRect(),n=t.x-Math.round(r.x),i=t.y-Math.round(r.y),s=r.height,o=i<s/2,a=!o,d=s/4,c=i>d&&i<s-d;return{x:n,inTopHalf:o,inBottomHalf:a,inMiddle:c,atTop:!c&&o,atBottom:!c&&a}}function Qs(e,t,r,n){return e?e.isInternal?n.atTop?[t,e]:n.inMiddle?[e,e]:[e,r]:n.inTopHalf?[t,e]:[e,r]:[t,null]}function he(e,t){return{parentId:e||null,index:t}}function $(e,t){return{type:"line",index:e,level:t}}function Zs(e){return{type:"highlight",id:e}}function Ge(e,t){var n;let r=e;for(;r.parent&&r.level>t;)r=r.parent;return{parentId:((n=r.parent)==null?void 0:n.id)||null,index:$t(r)+1}}function ur(e){var c;let t=Js(e.element,e.offset),r=e.indent,n=Math.round(Math.max(0,t.x-r)/r),{node:i,nextNode:s,prevNode:o}=e,[a,d]=Qs(i,o,s,t);if(i&&i.isInternal&&t.inMiddle)return{drop:he(i.id,null),cursor:Zs(i.id)};if(!a)return{drop:he((c=d==null?void 0:d.parent)==null?void 0:c.id,0),cursor:$(0,0)};if(Wt(a)){let f=ce(n,(d==null?void 0:d.level)||0,a.level);return{drop:Ge(a,f),cursor:$(a.rowIndex+1,f)}}if(Vt(a)){let f=ce(n,(d==null?void 0:d.level)||0,a.level);return{drop:Ge(a,f),cursor:$(a.rowIndex+1,f)}}if(Gt(a)){let f=ce(n,0,a.level+1);return f>a.level?{drop:he(a.id,0),cursor:$(a.rowIndex+1,f)}:{drop:Ge(a,f),cursor:$(a.rowIndex+1,f)}}return{drop:he(a==null?void 0:a.id,0),cursor:$(a.rowIndex+1,a.level+1)}}function eo(e,t){let r=N(),[n,i]=Et(()=>({accept:"NODE",canDrop:()=>r.canDrop(),hover:(s,o)=>{let a=o.getClientOffset();if(!e.current||!a)return;let{cursor:d,drop:c}=ur({element:e.current,offset:a,indent:r.indent,node:t,prevNode:t.prev,nextNode:t.next});c&&r.dispatch(K.hovering(c.parentId,c.index)),o.canDrop()?d&&r.showCursor(d):r.hideCursor()},drop:(s,o)=>{if(!o.canDrop())return null;let{parentId:a,index:d,dragIds:c}=r.state.dnd;Qt(r.props.onMove,{dragIds:c,parentId:a==="__REACT_ARBORIST_INTERNAL_ROOT__"?null:a,index:d===null?0:d,dragNodes:r.dragNodes,parentNode:r.get(a)}),r.open(a)}}),[t,e.current,r.props]);return i}function to(e){let t=N(),r=t.at(e);if(!r)throw Error(`Could not find node for index: ${e}`);return(0,p.useMemo)(()=>{let n=r.clone();return t.visibleNodes[e]=n,n},[...Object.values(r.state),r])}const ro=p.memo(function({index:e,style:t}){zt(),as();let r=N(),n=to(e),i=(0,p.useRef)(null),s=Xs(n),o=eo(i,n),a=(0,p.useCallback)(u=>{i.current=u,o(u)},[o]),d=r.indent*n.level,c=(0,p.useMemo)(()=>({paddingLeft:d}),[d]),f=(0,p.useMemo)(()=>Object.assign(Object.assign({},t),{top:parseFloat(t.top)+(r.props.padding??r.props.paddingTop??0)}),[t,r.props.padding,r.props.paddingTop]),O={role:"treeitem","aria-level":n.level+1,"aria-selected":n.isSelected,"aria-expanded":n.isOpen,style:f,tabIndex:-1,className:r.props.rowClassName};(0,p.useEffect)(()=>{var u;!n.isEditing&&n.isFocused&&((u=i.current)==null||u.focus({preventScroll:!0}))},[n.isEditing,n.isFocused,i.current]);let y=r.renderNode,h=r.renderRow;return(0,v.jsx)(h,{node:n,innerRef:a,attrs:O,children:(0,v.jsx)(y,{node:n,tree:r,style:c,dragHandle:s})})});var Ke="",hr=null;function fr(){zt();let e=N();return(0,v.jsx)("div",{role:"tree",style:{height:e.height,width:e.width,minHeight:0,minWidth:0},onContextMenu:e.props.onContextMenu,onClick:e.props.onClick,tabIndex:0,onFocus:t=>{t.currentTarget.contains(t.relatedTarget)||e.onFocus()},onBlur:t=>{t.currentTarget.contains(t.relatedTarget)||e.onBlur()},onKeyDown:t=>{var n;if(e.isEditing)return;if(t.key==="Backspace"){if(!e.props.onDelete)return;let i=Array.from(e.selectedIds);if(i.length>1){let s=e.mostRecentNode;for(;s&&s.isSelected;)s=s.nextSibling;s||(s=e.lastNode),e.focus(s,{scroll:!1}),e.delete(Array.from(i))}else{let s=e.focusedNode;if(s){let o=s.nextSibling,a=s.parent;e.focus(o||a,{scroll:!1}),e.delete(s)}}return}if(t.key==="Tab"&&!t.shiftKey){t.preventDefault(),Yt(t.currentTarget);return}if(t.key==="Tab"&&t.shiftKey){t.preventDefault(),qt(t.currentTarget);return}if(t.key==="ArrowDown"){t.preventDefault();let i=e.nextNode;if(t.metaKey){e.select(e.focusedNode),e.activate(e.focusedNode);return}else if(!t.shiftKey||e.props.disableMultiSelection){e.focus(i);return}else{if(!i)return;let s=e.focusedNode;s?s.isSelected?e.selectContiguous(i):e.selectMulti(i):e.focus(e.firstNode);return}}if(t.key==="ArrowUp"){t.preventDefault();let i=e.prevNode;if(!t.shiftKey||e.props.disableMultiSelection){e.focus(i);return}else{if(!i)return;let s=e.focusedNode;s?s.isSelected?e.selectContiguous(i):e.selectMulti(i):e.focus(e.lastNode);return}}if(t.key==="ArrowRight"){let i=e.focusedNode;if(!i)return;i.isInternal&&i.isOpen?e.focus(e.nextNode):i.isInternal&&e.open(i.id);return}if(t.key==="ArrowLeft"){let i=e.focusedNode;if(!i||i.isRoot)return;i.isInternal&&i.isOpen?e.close(i.id):(n=i.parent)!=null&&n.isRoot||e.focus(i.parent);return}if(t.key==="a"&&t.metaKey&&!e.props.disableMultiSelection){t.preventDefault(),e.selectAll();return}if(t.key==="a"&&!t.metaKey&&e.props.onCreate){e.createLeaf();return}if(t.key==="A"&&!t.metaKey){if(!e.props.onCreate)return;e.createInternal();return}if(t.key==="Home"){t.preventDefault(),e.focus(e.firstNode);return}if(t.key==="End"){t.preventDefault(),e.focus(e.lastNode);return}if(t.key==="Enter"){let i=e.focusedNode;if(!i||!i.isEditable||!e.props.onRename)return;setTimeout(()=>{i&&e.edit(i)});return}if(t.key===" "){t.preventDefault();let i=e.focusedNode;if(!i)return;i.isLeaf?(i.select(),i.activate()):i.toggle();return}if(t.key==="*"){let i=e.focusedNode;if(!i)return;e.openSiblings(i);return}if(t.key==="PageUp"){t.preventDefault(),e.pageUp();return}t.key==="PageDown"&&(t.preventDefault(),e.pageDown()),clearTimeout(hr),Ke+=t.key,hr=setTimeout(()=>{Ke=""},600);let r=e.visibleNodes.find(i=>{let s=i.data.name;return typeof s=="string"?s.toLowerCase().startsWith(Ke):!1});r&&e.focus(r.id)},children:(0,v.jsx)(Ws,{className:e.props.className,outerRef:e.listEl,itemCount:e.visibleNodes.length,height:e.height,width:e.width,itemSize:e.rowHeight,overscanCount:e.overscanCount,itemKey:t=>{var r;return((r=e.visibleNodes[t])==null?void 0:r.id)||t},outerElementType:Ks,innerElementType:qs,onScroll:e.props.onScroll,onItemsRendered:e.onItemsRendered.bind(e),ref:e.list,children:ro})})}function gr(e){return e.isFiltered?io(e.root,e.isMatch.bind(e)):no(e.root)}function no(e){let t=[];function r(n){var i;n.level>=0&&t.push(n),n.isOpen&&((i=n.children)==null||i.forEach(r))}return r(e),t.forEach(pr),t}function io(e,t){let r={},n=[];function i(o){if(!o.isRoot&&t(o)){r[o.id]=!0;let a=o.parent;for(;a;)r[a.id]=!0,a=a.parent}if(o.children)for(let a of o.children)i(a)}function s(o){var a;o.level>=0&&r[o.id]&&n.push(o),o.isOpen&&((a=o.children)==null||a.forEach(s))}return i(e),s(e),n.forEach(pr),n}function pr(e,t){e.rowIndex=t}const mr=e=>e.reduce((t,r,n)=>(t[r.id]=n,t),{});var $e=function(e,t,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(f){try{c(n.next(f))}catch(O){o(O)}}function d(f){try{c(n.throw(f))}catch(O){o(O)}}function c(f){f.done?s(f.value):i(f.value).then(a,d)}c((n=n.apply(e,t||[])).next())})},{safeRun:T,identify:M,identifyNull:_}=ds,so=class pe{constructor(t,r,n,i){this.store=t,this.props=r,this.list=n,this.listEl=i,this.visibleStartIndex=0,this.visibleStopIndex=0,this.root=nr(this),this.visibleNodes=gr(this),this.idToIndex=mr(this.visibleNodes)}update(t){this.props=t,this.root=nr(this),this.visibleNodes=gr(this),this.idToIndex=mr(this.visibleNodes)}dispatch(t){return this.store.dispatch(t)}get state(){return this.store.getState()}get openState(){return this.state.nodes.open.unfiltered}get width(){return this.props.width??300}get height(){return this.props.height??500}get indent(){return this.props.indent??24}get rowHeight(){return this.props.rowHeight??24}get overscanCount(){return this.props.overscanCount??1}get searchTerm(){return(this.props.searchTerm||"").trim()}get matchFn(){let t=this.props.searchMatch??((r,n)=>JSON.stringify(Object.values(r.data)).toLocaleLowerCase().includes(n.toLocaleLowerCase()));return r=>t(r,this.searchTerm)}accessChildren(t){return J(t,this.props.childrenAccessor||"children")??null}accessId(t){let r=J(t,this.props.idAccessor||"id");if(!r)throw Error("Data must contain an 'id' property or props.idAccessor must return a string");return r}get firstNode(){return this.visibleNodes[0]??null}get lastNode(){return this.visibleNodes[this.visibleNodes.length-1]??null}get focusedNode(){return this.get(this.state.nodes.focus.id)??null}get mostRecentNode(){return this.get(this.state.nodes.selection.mostRecent)??null}get nextNode(){let t=this.indexOf(this.focusedNode);return t===null?null:this.at(t+1)}get prevNode(){let t=this.indexOf(this.focusedNode);return t===null?null:this.at(t-1)}get(t){return t&&t in this.idToIndex&&this.visibleNodes[this.idToIndex[t]]||null}at(t){return this.visibleNodes[t]||null}nodesBetween(t,r){if(t===null||r===null)return[];let n=this.indexOf(t)??0,i=this.indexOf(r);if(i===null)return[];let s=Math.min(n,i),o=Math.max(n,i);return this.visibleNodes.slice(s,o+1)}indexOf(t){let r=Jt(t);return r?this.idToIndex[r]:null}get editingId(){return this.state.nodes.edit.id}createInternal(){return this.create({type:"internal"})}createLeaf(){return this.create({type:"leaf"})}create(){return $e(this,arguments,void 0,function*(t={}){let r=t.parentId===void 0?tr(this):t.parentId,n=t.index??er(this),i=t.type??"leaf",s=yield T(this.props.onCreate,{type:i,parentId:r,index:n,parentNode:this.get(r)});s&&(this.focus(s),setTimeout(()=>{this.edit(s).then(()=>{this.select(s),this.activate(s)})}))})}delete(t){return $e(this,void 0,void 0,function*(){if(!t)return;let r=(Array.isArray(t)?t:[t]).map(M),n=r.map(i=>this.get(i)).filter(i=>!!i);yield T(this.props.onDelete,{nodes:n,ids:r})})}edit(t){let r=M(t);return this.resolveEdit({cancelled:!0}),this.scrollTo(r),this.dispatch(Ue(r)),new Promise(n=>{pe.editPromise=n})}submit(t,r){return $e(this,void 0,void 0,function*(){if(!t)return;let n=M(t);yield T(this.props.onRename,{id:n,name:r,node:this.get(n)}),this.dispatch(Ue(null)),this.resolveEdit({cancelled:!1,value:r}),setTimeout(()=>this.onFocus())})}reset(){this.dispatch(Ue(null)),this.resolveEdit({cancelled:!0}),setTimeout(()=>this.onFocus())}activate(t){let r=this.get(_(t));r&&T(this.props.onActivate,r)}resolveEdit(t){let r=pe.editPromise;r&&r(t),pe.editPromise=null}get selectedIds(){return this.state.nodes.selection.ids}get selectedNodes(){let t=[];for(let r of Array.from(this.selectedIds)){let n=this.get(r);n&&t.push(n)}return t}focus(t,r={}){t&&(this.props.selectionFollowsFocus?this.select(t):(this.dispatch(V(M(t))),r.scroll!==!1&&this.scrollTo(t),this.focusedNode&&T(this.props.onFocus,this.focusedNode)))}pageUp(){var i;let t=this.visibleStartIndex,r=this.visibleStopIndex-t,n=((i=this.focusedNode)==null?void 0:i.rowIndex)??0;n=n>t?t:Math.max(t-r,0),this.focus(this.at(n))}pageDown(){var s;let t=this.visibleStartIndex,r=this.visibleStopIndex,n=r-t,i=((s=this.focusedNode)==null?void 0:s.rowIndex)??0;i=i<r?r:Math.min(i+n,this.visibleNodes.length-1),this.focus(this.at(i))}select(t,r={}){if(!t)return;let n=r.focus!==!1,i=M(t);n&&this.dispatch(V(i)),this.dispatch(j.only(i)),this.dispatch(j.anchor(i)),this.dispatch(j.mostRecent(i)),this.scrollTo(i,r.align),this.focusedNode&&n&&T(this.props.onFocus,this.focusedNode),T(this.props.onSelect,this.selectedNodes)}deselect(t){if(!t)return;let r=M(t);this.dispatch(j.remove(r)),T(this.props.onSelect,this.selectedNodes)}selectMulti(t){let r=this.get(_(t));r&&(this.dispatch(V(r.id)),this.dispatch(j.add(r.id)),this.dispatch(j.anchor(r.id)),this.dispatch(j.mostRecent(r.id)),this.scrollTo(r),this.focusedNode&&T(this.props.onFocus,this.focusedNode),T(this.props.onSelect,this.selectedNodes))}selectContiguous(t){if(!t)return;let r=M(t),{anchor:n,mostRecent:i}=this.state.nodes.selection;this.dispatch(V(r)),this.dispatch(j.remove(this.nodesBetween(n,i))),this.dispatch(j.add(this.nodesBetween(n,_(r)))),this.dispatch(j.mostRecent(r)),this.scrollTo(r),this.focusedNode&&T(this.props.onFocus,this.focusedNode),T(this.props.onSelect,this.selectedNodes)}deselectAll(){this.setSelection({ids:[],anchor:null,mostRecent:null}),T(this.props.onSelect,this.selectedNodes)}selectAll(){var t;this.setSelection({ids:Object.keys(this.idToIndex),anchor:this.firstNode,mostRecent:this.lastNode}),this.dispatch(V((t=this.lastNode)==null?void 0:t.id)),this.focusedNode&&T(this.props.onFocus,this.focusedNode),T(this.props.onSelect,this.selectedNodes)}setSelection(t){var s;let r=new Set((s=t.ids)==null?void 0:s.map(M)),n=_(t.anchor),i=_(t.mostRecent);this.dispatch(j.set({ids:r,anchor:n,mostRecent:i})),T(this.props.onSelect,this.selectedNodes)}get cursorParentId(){let{cursor:t}=this.state.dnd;return t.type==="highlight"?t.id:null}get cursorOverFolder(){return this.state.dnd.cursor.type==="highlight"}get dragNodes(){return this.state.dnd.dragIds.map(t=>this.get(t)).filter(t=>!!t)}get dragNode(){return this.get(this.state.nodes.drag.id)}get dragDestinationParent(){return this.get(this.state.nodes.drag.destinationParentId)}get dragDestinationIndex(){return this.state.nodes.drag.destinationIndex}canDrop(){if(this.isFiltered)return!1;let t=this.get(this.state.dnd.parentId)??this.root,r=this.dragNodes,n=this.props.disableDrop;for(let i of r)if(!i||!t||i.isInternal&&Kt(t,i))return!1;return typeof n=="function"?!n({parentNode:t,dragNodes:this.dragNodes,index:this.state.dnd.index||0}):typeof n=="string"?!t.data[n]:typeof n=="boolean"?!n:!0}hideCursor(){this.dispatch(K.cursor({type:"none"}))}showCursor(t){this.dispatch(K.cursor(t))}open(t){let r=_(t);r&&(this.isOpen(r)||(this.dispatch(ze.open(r,this.isFiltered)),T(this.props.onToggle,r)))}close(t){let r=_(t);r&&this.isOpen(r)&&(this.dispatch(ze.close(r,this.isFiltered)),T(this.props.onToggle,r))}toggle(t){let r=_(t);if(r)return this.isOpen(r)?this.close(r):this.open(r)}openParents(t){var i;let r=_(t);if(!r)return;let n=(i=He(this.root,r))==null?void 0:i.parent;for(;n;)this.open(n.id),n=n.parent}openSiblings(t){let r=t.parent;if(!r)this.toggle(t.id);else if(r.children){let n=t.isOpen;for(let i of r.children)i.isInternal&&(n?this.close(i.id):this.open(i.id));this.scrollTo(this.focusedNode)}}openAll(){ue(this.root,t=>{t.isInternal&&t.open()})}closeAll(){ue(this.root,t=>{t.isInternal&&t.close()})}scrollTo(t,r="smart"){if(!t)return;let n=M(t);return this.openParents(n),Zt(()=>n in this.idToIndex).then(()=>{var i;let s=this.idToIndex[n];s!==void 0&&((i=this.list.current)==null||i.scrollToItem(s,r))}).catch(()=>{})}get isEditing(){return this.state.nodes.edit.id!==null}get isFiltered(){var t;return!!((t=this.props.searchTerm)!=null&&t.trim())}get hasFocus(){return this.state.nodes.focus.treeFocused}get hasNoSelection(){return this.state.nodes.selection.ids.size===0}get hasOneSelection(){return this.state.nodes.selection.ids.size===1}get hasMultipleSelections(){return this.state.nodes.selection.ids.size>1}isSelected(t){return t?this.state.nodes.selection.ids.has(t):!1}isOpen(t){if(!t)return!1;if(t==="__REACT_ARBORIST_INTERNAL_ROOT__")return!0;let r=this.props.openByDefault??!0;return this.isFiltered?this.state.nodes.open.filtered[t]??!0:this.state.nodes.open.unfiltered[t]??r}isEditable(t){return!J(t,this.props.disableEdit||(()=>!1))}isDraggable(t){return!J(t,this.props.disableDrag||(()=>!1))}isDragging(t){let r=_(t);return r?this.state.nodes.drag.id===r:!1}isFocused(t){return this.hasFocus&&this.state.nodes.focus.id===t}isMatch(t){return this.matchFn(t)}willReceiveDrop(t){let r=_(t);if(!r)return!1;let{destinationParentId:n,destinationIndex:i}=this.state.nodes.drag;return r===n&&i===null}onFocus(){let t=this.focusedNode||this.firstNode;t&&this.dispatch(V(t.id))}onBlur(){this.dispatch(Ds())}onItemsRendered(t){this.visibleStartIndex=t.visibleStartIndex,this.visibleStopIndex=t.visibleStopIndex}get renderContainer(){return this.props.renderContainer||fr}get renderRow(){return this.props.renderRow||ys}get renderNode(){return this.props.children||Os}get renderDragPreview(){return this.props.renderDragPreview||sr}get renderCursor(){return this.props.renderCursor||vs}};function E(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var vr=typeof Symbol=="function"&&Symbol.observable||"@@observable",Ye=()=>Math.random().toString(36).substring(7).split("").join("."),fe={INIT:`@@redux/INIT${Ye()}`,REPLACE:`@@redux/REPLACE${Ye()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Ye()}`};function oo(e){if(typeof e!="object"||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function yr(e,t,r){if(typeof e!="function")throw Error(E(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw Error(E(0));if(typeof t=="function"&&r===void 0&&(r=t,t=void 0),r!==void 0){if(typeof r!="function")throw Error(E(1));return r(yr)(e,t)}let n=e,i=t,s=new Map,o=s,a=0,d=!1;function c(){o===s&&(o=new Map,s.forEach((l,g)=>{o.set(g,l)}))}function f(){if(d)throw Error(E(3));return i}function O(l){if(typeof l!="function")throw Error(E(4));if(d)throw Error(E(5));let g=!0;c();let m=a++;return o.set(m,l),function(){if(g){if(d)throw Error(E(6));g=!1,c(),o.delete(m),s=null}}}function y(l){if(!oo(l))throw Error(E(7));if(l.type===void 0)throw Error(E(8));if(typeof l.type!="string")throw Error(E(17));if(d)throw Error(E(9));try{d=!0,i=n(i,l)}finally{d=!1}return(s=o).forEach(g=>{g()}),l}function h(l){if(typeof l!="function")throw Error(E(10));n=l,y({type:fe.REPLACE})}function u(){let l=O;return{subscribe(g){if(typeof g!="object"||!g)throw Error(E(11));function m(){let b=g;b.next&&b.next(f())}return m(),{unsubscribe:l(m)}},[vr](){return this}}}return y({type:fe.INIT}),{dispatch:y,subscribe:O,getState:f,replaceReducer:h,[vr]:u}}function ao(e){Object.keys(e).forEach(t=>{let r=e[t];if(r(void 0,{type:fe.INIT})===void 0)throw Error(E(12));if(r(void 0,{type:fe.PROBE_UNKNOWN_ACTION()})===void 0)throw Error(E(13))})}function Or(e){let t=Object.keys(e),r={};for(let s=0;s<t.length;s++){let o=t[s];typeof e[o]=="function"&&(r[o]=e[o])}let n=Object.keys(r),i;try{ao(r)}catch(s){i=s}return function(s={},o){if(i)throw i;let a=!1,d={};for(let c=0;c<n.length;c++){let f=n[c],O=r[f],y=s[f],h=O(y,o);if(h===void 0)throw o&&o.type,Error(E(14));d[f]=h,a||(a=h!==y)}return a||(a=n.length!==Object.keys(s).length),a?d:s}}function lo(e=G().nodes.drag,t){switch(t.type){case"DND_DRAG_START":return Object.assign(Object.assign({},e),{id:t.id,selectedIds:t.dragIds});case"DND_DRAG_END":return Object.assign(Object.assign({},e),{id:null,destinationParentId:null,destinationIndex:null,selectedIds:[]});case"DND_HOVERING":return t.parentId!==e.destinationParentId||t.index!=e.destinationIndex?Object.assign(Object.assign({},e),{destinationParentId:t.parentId,destinationIndex:t.index}):e;default:return e}}const co=Or({nodes:Or({focus:ws,edit:Ss,open:Ts,selection:Es,drag:lo}),dnd:xs});var uo=Lr(),ho=G();function fo({treeProps:e,imperativeHandle:t,children:r}){let n=(0,p.useRef)(null),i=(0,p.useRef)(null),s=(0,p.useRef)(yr(co,G(e))),o=(0,uo.useSyncExternalStore)(s.current.subscribe,s.current.getState,()=>ho),a=(0,p.useMemo)(()=>new so(s.current,e,n,i),[]),d=(0,p.useRef)(0);return(0,p.useMemo)(()=>{d.current+=1,a.update(e)},[...Object.values(e),o.nodes.open]),(0,p.useImperativeHandle)(t,()=>a),(0,p.useEffect)(()=>{a.props.selection?a.select(a.props.selection,{focus:!1}):a.deselectAll()},[a.props.selection]),(0,p.useEffect)(()=>{a.props.searchTerm||s.current.dispatch(ze.clear(!0))},[a.props.searchTerm]),(0,v.jsx)(Ft.Provider,{value:a,children:(0,v.jsx)(Bt.Provider,{value:d.current,children:(0,v.jsx)(Ht.Provider,{value:o.nodes,children:(0,v.jsx)(Ut.Provider,{value:o.dnd,children:(0,v.jsx)(Ot,Object.assign({backend:Lt,options:{rootElement:a.props.dndRootElement||void 0}},e.dndManager&&{manager:e.dndManager},{children:r}))})})})})}function go(){let e=N(),[,t]=Et(()=>({accept:"NODE",canDrop:(r,n)=>n.isOver({shallow:!0})?e.canDrop():!1,hover:(r,n)=>{if(!n.isOver({shallow:!0}))return;let i=n.getClientOffset();if(!e.listEl.current||!i)return;let{cursor:s,drop:o}=ur({element:e.listEl.current,offset:i,indent:e.indent,node:null,prevNode:e.visibleNodes[e.visibleNodes.length-1],nextNode:null});o&&e.dispatch(K.hovering(o.parentId,o.index)),n.canDrop()?s&&e.showCursor(s):e.hideCursor()}}),[e]);t(e.listEl)}function po(e){return go(),e.children}function mo(){return(0,v.jsx)(v.Fragment,{children:(0,v.jsx)(N().props.renderContainer||fr,{})})}function vo(){let e=N(),{offset:t,mouse:r,item:n,isDragging:i}=Hi(s=>({offset:s.getSourceClientOffset(),mouse:s.getClientOffset(),item:s.getItem(),isDragging:s.isDragging()}));return(0,v.jsx)(e.props.renderDragPreview||sr,{offset:t,mouse:r,id:(n==null?void 0:n.id)||null,dragIds:(n==null?void 0:n.dragIds)||[],isDragging:i})}var ge=class{constructor(e){this.root=yo(e)}get data(){var e;return((e=this.root.children)==null?void 0:e.map(t=>t.data))??[]}create(e){let t=e.parentId?this.find(e.parentId):this.root;if(!t)return null;t.addChild(e.data,e.index)}move(e){let t=this.find(e.id),r=e.parentId?this.find(e.parentId):this.root;!t||!r||(r.addChild(t.data,e.index),t.drop())}update(e){let t=this.find(e.id);t&&t.update(e.changes)}drop(e){let t=this.find(e.id);t&&t.drop()}find(e,t=this.root){if(!t)return null;if(t.id===e)return t;if(t.children){for(let r of t.children){let n=this.find(e,r);if(n)return n}return null}return null}};function yo(e){let t=new Ir({id:"ROOT"},null);return t.children=e.map(r=>qe(r,t)),t}function qe(e,t){let r=new Ir(e,t);return e.children&&(r.children=e.children.map(n=>qe(n,r))),r}var Ir=class{constructor(e,t){this.data=e,this.parent=t,this.id=e.id}hasParent(){return!!this.parent}get childIndex(){return this.hasParent()?this.parent.children.indexOf(this):-1}addChild(e,t){let r=qe(e,this);this.children=this.children??[],this.children.splice(t,0,r),this.data.children=this.data.children??[],this.data.children.splice(t,0,e)}removeChild(e){var t,r;(t=this.children)==null||t.splice(e,1),(r=this.data.children)==null||r.splice(e,1)}update(e){if(this.hasParent()){let t=this.childIndex;this.parent.addChild(Object.assign(Object.assign({},this.data),e),t),this.drop()}}drop(){this.hasParent()&&this.parent.removeChild(this.childIndex)}},Oo=0;function Io(e){let[t,r]=(0,p.useState)(e),n=(0,p.useMemo)(()=>new ge(t),[t]);return[t,{onMove:i=>{for(let s of i.dragIds)n.move({id:s,parentId:i.parentId,index:i.index});r(n.data)},onRename:({name:i,id:s})=>{n.update({id:s,changes:{name:i}}),r(n.data)},onCreate:({parentId:i,index:s,type:o})=>{let a={id:`simple-tree-id-${Oo++}`,name:""};return o==="internal"&&(a.children=[]),n.create({parentId:i,index:s,data:a}),r(n.data),a},onDelete:i=>{i.ids.forEach(s=>n.drop({id:s})),r(n.data)}}]}function bo(e){if(e.initialData&&e.data)throw Error("React Arborist Tree => Provide either a data or initialData prop, but not both.");if(e.initialData&&(e.onCreate||e.onDelete||e.onMove||e.onRename))throw Error(`React Arborist Tree => You passed the initialData prop along with a data handler.
3
- Use the data prop if you want to provide your own handlers.`);if(e.initialData){let[t,r]=Io(e.initialData);return Object.assign(Object.assign(Object.assign({},e),r),{data:t})}else return e}function So(e,t){return(0,v.jsxs)(fo,{treeProps:bo(e),imperativeHandle:t,children:[(0,v.jsx)(po,{children:(0,v.jsx)(mo,{})}),(0,v.jsx)(vo,{})]})}const Do=(0,p.forwardRef)(So);function A(e){return e.success?e:(q({title:"Failed",description:e.message}),null)}var wo=class{constructor(e){k(this,"delegate",new ge([]));k(this,"rootPath","");k(this,"onChange",Mr.NOOP);k(this,"path",new rt("/"));k(this,"initialize",async e=>{if(this.onChange=e,this.delegate.data.length===0)try{let t=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new ge(t.files),this.rootPath=t.root,this.path=rt.guessDeliminator(t.root)}catch(t){q({title:"Failed",description:Kr(t)})}this.onChange(this.delegate.data)});k(this,"refreshAll",async e=>{let t=[this.rootPath,...e.map(n=>{var i;return(i=this.delegate.find(n))==null?void 0:i.data.path})].filter(Boolean),r=await Promise.all(t.map(n=>this.callbacks.listFiles({path:n}).catch(()=>({files:[]}))));for(let[n,i]of t.entries()){let s=r[n];i===this.rootPath?this.delegate=new ge(s.files):this.delegate.update({id:i,changes:{children:s.files}})}this.onChange(this.delegate.data)});k(this,"relativeFromRoot",e=>{let t=this.rootPath.endsWith(this.path.deliminator)?this.rootPath:`${this.rootPath}${this.path.deliminator}`;return e.startsWith(t)?e.slice(t.length):e});this.callbacks=e}async expand(e){let t=this.delegate.find(e);if(!t||!t.data.isDirectory)return!1;if(t.children&&t.children.length>0)return!0;let r=await this.callbacks.listFiles({path:t.data.path});return this.delegate.update({id:e,changes:{children:r.files}}),this.onChange(this.delegate.data),!0}async copy(e,t){var a;let r=this.delegate.find(e);if(!r){q({title:"Failed",description:`Node with id ${e} not found in the tree`});return}let{path:n,newPath:i}=te({path:r.data.path,name:t,root:this.rootPath}),s=this.path.dirname(n),o=await this.callbacks.copyFileOrFolder({path:n,newPath:i}).then(A);o!=null&&o.info&&(this.delegate.create({parentId:((a=r.parent)==null?void 0:a.id)??null,index:0,data:o.info}),this.onChange(this.delegate.data),await this.refreshAll([s]))}async rename(e,t){let r=this.delegate.find(e);if(!r){q({title:"Failed",description:`Node with id ${e} not found in the tree`});return}let{path:n,newPath:i}=te({path:r.data.path,name:t,root:this.rootPath});await this.callbacks.renameFileOrFolder({path:n,newPath:i}).then(A)&&(this.delegate.update({id:e,changes:{name:t,path:i}}),this.onChange(this.delegate.data),await this.refreshAll([i]))}async move(e,t){var n;let r=t?((n=this.delegate.find(t))==null?void 0:n.data.path)??t:this.rootPath;await Promise.all(e.map(async i=>{let s=this.delegate.find(i);if(!s)return;let o=s.data.path,a=this.path.join(r,this.path.basename(o));await this.callbacks.renameFileOrFolder({path:o,newPath:a}).then(A)&&(this.delegate.move({id:i,parentId:t,index:0}),this.delegate.update({id:i,changes:{path:a}}))})),this.onChange(this.delegate.data),await this.refreshAll([r])}async createFile({name:e,parentId:t,type:r="file"}){var s;let n=t?((s=this.delegate.find(t))==null?void 0:s.data.path)??t:this.rootPath,i=await this.callbacks.createFileOrFolder({path:n,type:r,name:e}).then(A);i!=null&&i.info&&(this.delegate.create({parentId:t,index:0,data:i.info}),this.onChange(this.delegate.data),await this.refreshAll([n]))}async createFolder(e,t){var i;let r=t?((i=this.delegate.find(t))==null?void 0:i.data.path)??t:this.rootPath,n=await this.callbacks.createFileOrFolder({path:r,type:"directory",name:e}).then(A);n!=null&&n.info&&(this.delegate.create({parentId:t,index:0,data:n.info}),this.onChange(this.delegate.data),await this.refreshAll([r]))}async delete(e){let t=this.delegate.find(e);if(!t){q({title:"Failed",description:`Node with id ${e} not found in the tree`});return}await this.callbacks.deleteFileOrFolder({path:t.data.path}).then(A)&&(this.delegate.drop({id:e}),this.onChange(this.delegate.data))}},B=tt();function br(e){let t=(0,B.c)(13),{root:r}=e,{sendRenameFileOrFolder:n,sendCopyFileOrFolder:i,sendDeleteFileOrFolder:s}=Br(),o;t[0]!==r||t[1]!==n?(o=async(h,u)=>{let{path:l,newPath:g}=te({path:h.path,name:u,root:r});return A(await n({path:l,newPath:g}))},t[0]=r,t[1]=n,t[2]=o):o=t[2];let a=o,d;t[3]!==r||t[4]!==i?(d=async h=>{let{path:u,newPath:l}=te({path:h.path,name:Xr(h.name),root:r});return A(await i({path:u,newPath:l}))},t[3]=r,t[4]=i,t[5]=d):d=t[5];let c=d,f;t[6]!==r||t[7]!==s?(f=async h=>A(await s({path:qr(h.path,r)})),t[6]=r,t[7]=s,t[8]=f):f=t[8];let O=f,y;return t[9]!==O||t[10]!==c||t[11]!==a?(y={renameFile:a,duplicateFile:c,deleteFile:O},t[9]=O,t[10]=c,t[11]=a,t[12]=y):y=t[12],y}var To={file:"Delete file",folder:"Delete folder",notebook:"Delete notebook"};function Eo(){let e=(0,B.c)(2),{openConfirm:t}=Gr(),r;return e[0]===t?r=e[1]:(r=(n,i)=>{t({title:To[n.kind??"file"],description:`Are you sure you want to delete ${n.name}?`,confirmAction:(0,v.jsx)(kr,{onClick:async()=>{await i()},"aria-label":"Confirm",children:"Delete"})})},e[0]=t,e[1]=r),r}function xo(e){let t=(0,B.c)(17),{node:r,root:n,onAfterChange:i}=e,s;t[0]===n?s=t[1]:(s={root:n},t[0]=n,t[1]=s);let{duplicateFile:o,deleteFile:a}=br(s),d=Eo(),c;t[2]===r?c=t[3]:(c=()=>{r.edit()},t[2]=r,t[3]=c);let f=ye(c),O;t[4]!==o||t[5]!==r.data||t[6]!==i?(O=async()=>{await o(r.data)&&(i==null||i())},t[4]=o,t[5]=r.data,t[6]=i,t[7]=O):O=t[7];let y=ye(O),h;t[8]!==d||t[9]!==a||t[10]!==r.data||t[11]!==i?(h=()=>{let g=r.data.isDirectory?"folder":r.data.isMarimoFile?"notebook":"file";d({name:r.data.name,kind:g},async()=>{await a(r.data)&&(i==null||i())})},t[8]=d,t[9]=a,t[10]=r.data,t[11]=i,t[12]=h):h=t[12];let u=ye(h),l;return t[13]!==u||t[14]!==y||t[15]!==f?(l={handleRename:f,handleDuplicate:y,handleDelete:u},t[13]=u,t[14]=y,t[15]=f,t[16]=l):l=t[16],l}const Co=e=>{let t=(0,B.c)(15),{testId:r,buttonClassName:n,iconClassName:i,contentClassName:s,preventDefaultOnTrigger:o,children:a}=e,d=o===void 0?!1:o,c;t[0]===d?c=t[1]:(c=l=>{l.stopPropagation(),d&&l.preventDefault()},t[0]=d,t[1]=c);let f;t[2]!==n||t[3]!==i||t[4]!==r?(f=(0,v.jsx)(Yr,{"data-testid":r,className:n,iconClassName:i}),t[2]=n,t[3]=i,t[4]=r,t[5]=f):f=t[5];let O;t[6]!==c||t[7]!==f?(O=(0,v.jsx)(Fr,{asChild:!0,tabIndex:-1,onClick:c,children:f}),t[6]=c,t[7]=f,t[8]=O):O=t[8];let y=s??"print:hidden w-[220px]",h;t[9]!==a||t[10]!==y?(h=(0,v.jsx)(Hr,{align:"end",className:y,onClick:jo,onCloseAutoFocus:_o,children:a}),t[9]=a,t[10]=y,t[11]=h):h=t[11];let u;return t[12]!==O||t[13]!==h?(u=(0,v.jsxs)(Ur,{modal:!1,children:[O,h]}),t[12]=O,t[13]=h,t[14]=u):u=t[14],u},No=e=>{let t=(0,B.c)(5),{onSelect:r,disabled:n,title:i}=e,s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,v.jsx)(Jr,{className:Ie}),t[0]=s):s=t[0];let o;return t[1]!==n||t[2]!==r||t[3]!==i?(o=(0,v.jsxs)(Oe,{onSelect:r,disabled:n,title:i,children:[s,"Rename"]}),t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o},Ro=e=>{let t=(0,B.c)(5),{onSelect:r,disabled:n,title:i}=e,s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,v.jsx)(Wr,{className:Ie}),t[0]=s):s=t[0];let o;return t[1]!==n||t[2]!==r||t[3]!==i?(o=(0,v.jsxs)(Oe,{onSelect:r,disabled:n,title:i,children:[s,"Duplicate"]}),t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o},Po=e=>{let t=(0,B.c)(5),{onSelect:r,disabled:n,title:i}=e,s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,v.jsx)(Vr,{className:Ie}),t[0]=s):s=t[0];let o;return t[1]!==n||t[2]!==r||t[3]!==i?(o=(0,v.jsxs)(Oe,{onSelect:r,variant:"danger",disabled:n,title:i,children:[s,"Delete"]}),t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o};function jo(e){return e.stopPropagation()}function _o(e){return e.preventDefault()}var Mo=tt();const Ao=e=>{let t=(0,Mo.c)(10),{node:r}=e,n=(0,p.useRef)(null),i,s;t[0]===r.data.name?(i=t[1],s=t[2]):(i=()=>{var y,h;(y=n.current)==null||y.focus();let c=r.data.name,f=c.lastIndexOf("."),O=f>0?f:c.length;(h=n.current)==null||h.setSelectionRange(0,O)},s=[r.data.name],t[0]=r.data.name,t[1]=i,t[2]=s),(0,p.useEffect)(i,s);let o,a;t[3]===r?(o=t[4],a=t[5]):(o=()=>r.reset(),a=c=>{c.key==="Escape"&&r.reset(),c.key==="Enter"&&r.submit(c.currentTarget.value)},t[3]=r,t[4]=o,t[5]=a);let d;return t[6]!==r.data.name||t[7]!==o||t[8]!==a?(d=(0,v.jsx)("input",{ref:n,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:r.data.name,onClick:ko,onBlur:o,onKeyDown:a}),t[6]=r.data.name,t[7]=o,t[8]=a,t[9]=d):d=t[9],d};function ko(e){return e.stopPropagation()}export{No as a,wo as c,L as d,Ot as f,Co as i,Do as l,Po as n,br as o,Ro as r,xo as s,Ao as t,Lt as u};
3
+ Use the data prop if you want to provide your own handlers.`);if(e.initialData){let[t,r]=Io(e.initialData);return Object.assign(Object.assign(Object.assign({},e),r),{data:t})}else return e}function So(e,t){return(0,v.jsxs)(fo,{treeProps:bo(e),imperativeHandle:t,children:[(0,v.jsx)(po,{children:(0,v.jsx)(mo,{})}),(0,v.jsx)(vo,{})]})}const Do=(0,p.forwardRef)(So);function A(e){return e.success?e:(q({title:"Failed",description:e.message}),null)}var wo=class{constructor(e){k(this,"delegate",new ge([]));k(this,"rootPath","");k(this,"onChange",Mr.NOOP);k(this,"path",new rt("/"));k(this,"initialize",async e=>{if(this.onChange=e,this.delegate.data.length===0)try{let t=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new ge(t.files),this.rootPath=t.root,this.path=rt.guessDeliminator(t.root)}catch(t){q({title:"Failed",description:Kr(t)})}this.onChange(this.delegate.data)});k(this,"refreshAll",async e=>{let t=[this.rootPath,...e.map(n=>{var i;return(i=this.delegate.find(n))==null?void 0:i.data.path})].filter(Boolean),r=await Promise.all(t.map(n=>this.callbacks.listFiles({path:n}).catch(()=>({files:[]}))));for(let[n,i]of t.entries()){let s=r[n];i===this.rootPath?this.delegate=new ge(s.files):this.delegate.update({id:i,changes:{children:s.files}})}this.onChange(this.delegate.data)});k(this,"relativeFromRoot",e=>{let t=this.rootPath.endsWith(this.path.deliminator)?this.rootPath:`${this.rootPath}${this.path.deliminator}`;return e.startsWith(t)?e.slice(t.length):e});this.callbacks=e}async expand(e){let t=this.delegate.find(e);if(!t||!t.data.isDirectory)return!1;if(t.children&&t.children.length>0)return!0;let r=await this.callbacks.listFiles({path:t.data.path});return this.delegate.update({id:e,changes:{children:r.files}}),this.onChange(this.delegate.data),!0}async copy(e,t){var a;let r=this.delegate.find(e);if(!r){q({title:"Failed",description:`Node with id ${e} not found in the tree`});return}let{path:n,newPath:i}=te({path:r.data.path,name:t,root:this.rootPath}),s=this.path.dirname(n),o=await this.callbacks.copyFileOrFolder({path:n,newPath:i}).then(A);o!=null&&o.info&&(this.delegate.create({parentId:((a=r.parent)==null?void 0:a.id)??null,index:0,data:o.info}),this.onChange(this.delegate.data),await this.refreshAll([s]))}async rename(e,t){let r=this.delegate.find(e);if(!r){q({title:"Failed",description:`Node with id ${e} not found in the tree`});return}let{path:n,newPath:i}=te({path:r.data.path,name:t,root:this.rootPath});await this.callbacks.renameFileOrFolder({path:n,newPath:i}).then(A)&&(this.delegate.update({id:e,changes:{name:t,path:i}}),this.onChange(this.delegate.data),await this.refreshAll([i]))}async move(e,t){var n;let r=t?((n=this.delegate.find(t))==null?void 0:n.data.path)??t:this.rootPath;await Promise.all(e.map(async i=>{let s=this.delegate.find(i);if(!s)return;let o=s.data.path,a=this.path.join(r,this.path.basename(o));await this.callbacks.renameFileOrFolder({path:o,newPath:a}).then(A)&&(this.delegate.move({id:i,parentId:t,index:0}),this.delegate.update({id:i,changes:{path:a}}))})),this.onChange(this.delegate.data),await this.refreshAll([r])}async createFile({name:e,parentId:t,type:r="file"}){var s;let n=t?((s=this.delegate.find(t))==null?void 0:s.data.path)??t:this.rootPath,i=await this.callbacks.createFileOrFolder({path:n,type:r,name:e}).then(A);i!=null&&i.info&&(this.delegate.create({parentId:t,index:0,data:i.info}),this.onChange(this.delegate.data),await this.refreshAll([n]))}async createFolder(e,t){var i;let r=t?((i=this.delegate.find(t))==null?void 0:i.data.path)??t:this.rootPath,n=await this.callbacks.createFileOrFolder({path:r,type:"directory",name:e}).then(A);n!=null&&n.info&&(this.delegate.create({parentId:t,index:0,data:n.info}),this.onChange(this.delegate.data),await this.refreshAll([r]))}async delete(e){let t=this.delegate.find(e);if(!t){q({title:"Failed",description:`Node with id ${e} not found in the tree`});return}await this.callbacks.deleteFileOrFolder({path:t.data.path}).then(A)&&(this.delegate.drop({id:e}),this.onChange(this.delegate.data))}},B=tt();function br(e){let t=(0,B.c)(13),{root:r}=e,{sendRenameFileOrFolder:n,sendCopyFileOrFolder:i,sendDeleteFileOrFolder:s}=Br(),o;t[0]!==r||t[1]!==n?(o=async(h,u)=>{let{path:l,newPath:g}=te({path:h.path,name:u,root:r});return A(await n({path:l,newPath:g}))},t[0]=r,t[1]=n,t[2]=o):o=t[2];let a=o,d;t[3]!==r||t[4]!==i?(d=async h=>{let{path:u,newPath:l}=te({path:h.path,name:Xr(h.name),root:r});return A(await i({path:u,newPath:l}))},t[3]=r,t[4]=i,t[5]=d):d=t[5];let c=d,f;t[6]!==r||t[7]!==s?(f=async h=>A(await s({path:qr(h.path,r)})),t[6]=r,t[7]=s,t[8]=f):f=t[8];let O=f,y;return t[9]!==O||t[10]!==c||t[11]!==a?(y={renameFile:a,duplicateFile:c,deleteFile:O},t[9]=O,t[10]=c,t[11]=a,t[12]=y):y=t[12],y}var To={file:"Delete file",folder:"Delete folder",notebook:"Delete notebook"};function Eo(){let e=(0,B.c)(2),{openConfirm:t}=Gr(),r;return e[0]===t?r=e[1]:(r=(n,i)=>{t({title:To[n.kind??"file"],description:`Are you sure you want to delete ${n.name}?`,confirmAction:(0,v.jsx)(kr,{onClick:async()=>{await i()},"aria-label":"Confirm",children:"Delete"})})},e[0]=t,e[1]=r),r}function xo(e){let t=(0,B.c)(17),{node:r,root:n,onAfterChange:i}=e,s;t[0]===n?s=t[1]:(s={root:n},t[0]=n,t[1]=s);let{duplicateFile:o,deleteFile:a}=br(s),d=Eo(),c;t[2]===r?c=t[3]:(c=()=>{r.edit()},t[2]=r,t[3]=c);let f=ye(c),O;t[4]!==o||t[5]!==r.data||t[6]!==i?(O=async()=>{await o(r.data)&&(i==null||i())},t[4]=o,t[5]=r.data,t[6]=i,t[7]=O):O=t[7];let y=ye(O),h;t[8]!==d||t[9]!==a||t[10]!==r.data||t[11]!==i?(h=()=>{let g=r.data.isDirectory?"folder":r.data.isMarimoFile?"notebook":"file";d({name:r.data.name,kind:g},async()=>{await a(r.data)&&(i==null||i())})},t[8]=d,t[9]=a,t[10]=r.data,t[11]=i,t[12]=h):h=t[12];let u=ye(h),l;return t[13]!==u||t[14]!==y||t[15]!==f?(l={handleRename:f,handleDuplicate:y,handleDelete:u},t[13]=u,t[14]=y,t[15]=f,t[16]=l):l=t[16],l}const Co=e=>{let t=(0,B.c)(15),{testId:r,buttonClassName:n,iconClassName:i,contentClassName:s,preventDefaultOnTrigger:o,children:a}=e,d=o===void 0?!1:o,c;t[0]===d?c=t[1]:(c=l=>{l.stopPropagation(),d&&l.preventDefault()},t[0]=d,t[1]=c);let f;t[2]!==n||t[3]!==i||t[4]!==r?(f=(0,v.jsx)(Yr,{"data-testid":r,className:n,iconClassName:i}),t[2]=n,t[3]=i,t[4]=r,t[5]=f):f=t[5];let O;t[6]!==c||t[7]!==f?(O=(0,v.jsx)(Fr,{asChild:!0,tabIndex:-1,onClick:c,children:f}),t[6]=c,t[7]=f,t[8]=O):O=t[8];let y=s??"print:hidden w-[220px]",h;t[9]!==a||t[10]!==y?(h=(0,v.jsx)(Hr,{align:"end",className:y,onClick:jo,onCloseAutoFocus:_o,children:a}),t[9]=a,t[10]=y,t[11]=h):h=t[11];let u;return t[12]!==O||t[13]!==h?(u=(0,v.jsxs)(Ur,{modal:!1,children:[O,h]}),t[12]=O,t[13]=h,t[14]=u):u=t[14],u},No=e=>{let t=(0,B.c)(6),{onSelect:r,disabled:n,title:i,testId:s}=e,o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,v.jsx)(Jr,{className:Ie}),t[0]=o):o=t[0];let a;return t[1]!==n||t[2]!==r||t[3]!==s||t[4]!==i?(a=(0,v.jsxs)(Oe,{onSelect:r,disabled:n,title:i,"data-testid":s,children:[o,"Rename"]}),t[1]=n,t[2]=r,t[3]=s,t[4]=i,t[5]=a):a=t[5],a},Ro=e=>{let t=(0,B.c)(6),{onSelect:r,disabled:n,title:i,testId:s}=e,o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,v.jsx)(Wr,{className:Ie}),t[0]=o):o=t[0];let a;return t[1]!==n||t[2]!==r||t[3]!==s||t[4]!==i?(a=(0,v.jsxs)(Oe,{onSelect:r,disabled:n,title:i,"data-testid":s,children:[o,"Duplicate"]}),t[1]=n,t[2]=r,t[3]=s,t[4]=i,t[5]=a):a=t[5],a},Po=e=>{let t=(0,B.c)(6),{onSelect:r,disabled:n,title:i,testId:s}=e,o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,v.jsx)(Vr,{className:Ie}),t[0]=o):o=t[0];let a;return t[1]!==n||t[2]!==r||t[3]!==s||t[4]!==i?(a=(0,v.jsxs)(Oe,{onSelect:r,variant:"danger",disabled:n,title:i,"data-testid":s,children:[o,"Delete"]}),t[1]=n,t[2]=r,t[3]=s,t[4]=i,t[5]=a):a=t[5],a};function jo(e){return e.stopPropagation()}function _o(e){return e.preventDefault()}var Mo=tt();const Ao=e=>{let t=(0,Mo.c)(10),{node:r}=e,n=(0,p.useRef)(null),i,s;t[0]===r.data.name?(i=t[1],s=t[2]):(i=()=>{var y,h;(y=n.current)==null||y.focus();let c=r.data.name,f=c.lastIndexOf("."),O=f>0?f:c.length;(h=n.current)==null||h.setSelectionRange(0,O)},s=[r.data.name],t[0]=r.data.name,t[1]=i,t[2]=s),(0,p.useEffect)(i,s);let o,a;t[3]===r?(o=t[4],a=t[5]):(o=()=>r.reset(),a=c=>{c.key==="Escape"&&r.reset(),c.key==="Enter"&&r.submit(c.currentTarget.value)},t[3]=r,t[4]=o,t[5]=a);let d;return t[6]!==r.data.name||t[7]!==o||t[8]!==a?(d=(0,v.jsx)("input",{ref:n,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:r.data.name,onClick:ko,onBlur:o,onKeyDown:a}),t[6]=r.data.name,t[7]=o,t[8]=a,t[9]=d):d=t[9],d};function ko(e){return e.stopPropagation()}export{No as a,wo as c,L as d,Ot as f,Co as i,Do as l,Po as n,br as o,Ro as r,xo as s,Ao as t,Lt as u};