@aiquants/directory-tree 6.1.0 → 6.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/index.cjs +1 -6
- package/dist/index.js +976 -1234
- package/dist/styles/directory-tree.standalone.css +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -197,7 +197,8 @@ These are **not** accepted, because the tree owns them:
|
|
|
197
197
|
of `DirectoryTree`, which also reaches the row kind words and the grid-mode horizontal scrollbar. See
|
|
198
198
|
[Localization](#localization).
|
|
199
199
|
- `ref`: use the tree's own handle ([Scroll handle](#scroll-handle-ref)).
|
|
200
|
-
- `onWheelHorizontal`, `onPanHorizontal`, `horizontalKeyInputs`, `horizontalKeyStep`: the
|
|
200
|
+
- `onWheelHorizontal`, `onPanHorizontal`, `panHorizontalScrollable`, `horizontalKeyInputs`, `horizontalKeyStep`: the
|
|
201
|
+
tree owns the horizontal axis.
|
|
201
202
|
- `behaviorOptions.enableKeyboardNavigation` and `behaviorOptions.enableEscapeRowReturn`: the tree's rows own the
|
|
202
203
|
keyboard (see [Keyboard and focus](#keyboard-and-focus)); the tree always turns the engine's row navigation off,
|
|
203
204
|
because its row wrappers would otherwise be focusable elements between `role="tree"` and the treeitems.
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),ye=require("@aiquants/virtualscroll"),K=require("tailwind-merge"),le=require("@phosphor-icons/react");function hn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const ue=hn(l);var ft={exports:{}},Je={};var wr;function mn(){if(wr)return Je;wr=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,a,i){var c=null;if(i!==void 0&&(c=""+i),a.key!==void 0&&(c=""+a.key),"key"in a){i={};for(var u in a)u!=="key"&&(i[u]=a[u])}else i=a;return a=i.ref,{$$typeof:e,type:n,key:c,ref:a!==void 0?a:null,props:i}}return Je.Fragment=t,Je.jsx=r,Je.jsxs=r,Je}var qe={};var Er;function pn(){return Er||(Er=1,process.env.NODE_ENV!=="production"&&(function(){function e(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===F?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case E:return"Fragment";case $:return"Profiler";case v:return"StrictMode";case M:return"Suspense";case D:return"SuspenseList";case X:return"Activity"}if(typeof o=="object")switch(typeof o.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),o.$$typeof){case y:return"Portal";case P:return o.displayName||"Context";case N:return(o._context.displayName||"Context")+".Consumer";case b:var f=o.render;return o=o.displayName,o||(o=f.displayName||f.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case O:return f=o.displayName||null,f!==null?f:e(o.type)||"Memo";case q:f=o._payload,o=o._init;try{return e(o(f))}catch{}}return null}function t(o){return""+o}function r(o){try{t(o);var f=!1}catch{f=!0}if(f){f=console;var I=f.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&o[Symbol.toStringTag]||o.constructor.name||"Object";return I.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),t(o)}}function n(o){if(o===E)return"<>";if(typeof o=="object"&&o!==null&&o.$$typeof===q)return"<...>";try{var f=e(o);return f?"<"+f+">":"<...>"}catch{return"<...>"}}function a(){var o=H.A;return o===null?null:o.getOwner()}function i(){return Error("react-stack-top-frame")}function c(o){if(fe.call(o,"key")){var f=Object.getOwnPropertyDescriptor(o,"key").get;if(f&&f.isReactWarning)return!1}return o.key!==void 0}function u(o,f){function I(){he||(he=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",f))}I.isReactWarning=!0,Object.defineProperty(o,"key",{get:I,configurable:!0})}function m(){var o=e(this.type);return Y[o]||(Y[o]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),o=this.props.ref,o!==void 0?o:null}function S(o,f,I,R,be,C){var L=I.ref;return o={$$typeof:g,type:o,key:f,props:I,_owner:R},(L!==void 0?L:null)!==null?Object.defineProperty(o,"ref",{enumerable:!1,get:m}):Object.defineProperty(o,"ref",{enumerable:!1,value:null}),o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(o,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(o,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:be}),Object.defineProperty(o,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:C}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}function T(o,f,I,R,be,C){var L=f.children;if(L!==void 0)if(R)if(B(L)){for(R=0;R<L.length;R++)x(L[R]);Object.freeze&&Object.freeze(L)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else x(L);if(fe.call(f,"key")){L=e(o);var Z=Object.keys(f).filter(function(Ie){return Ie!=="key"});R=0<Z.length?"{key: someKey, "+Z.join(": ..., ")+": ...}":"{key: someKey}",ge[L+R]||(Z=0<Z.length?"{"+Z.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
-
let props = %s;
|
|
3
|
-
<%s {...props} />
|
|
4
|
-
React keys must be passed directly to JSX without using spread:
|
|
5
|
-
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,R,L,Z,L),ge[L+R]=!0)}if(L=null,I!==void 0&&(r(I),L=""+I),c(f)&&(r(f.key),L=""+f.key),"key"in f){I={};for(var me in f)me!=="key"&&(I[me]=f[me])}else I=f;return L&&u(I,typeof o=="function"?o.displayName||o.name||"Unknown":o),S(o,L,I,a(),be,C)}function x(o){_(o)?o._store&&(o._store.validated=1):typeof o=="object"&&o!==null&&o.$$typeof===q&&(o._payload.status==="fulfilled"?_(o._payload.value)&&o._payload.value._store&&(o._payload.value._store.validated=1):o._store&&(o._store.validated=1))}function _(o){return typeof o=="object"&&o!==null&&o.$$typeof===g}var p=l,g=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),P=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),F=Symbol.for("react.client.reference"),H=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe=Object.prototype.hasOwnProperty,B=Array.isArray,re=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(o){return o()}};var he,Y={},G=p.react_stack_bottom_frame.bind(p,i)(),Ee=re(n(i)),ge={};qe.Fragment=E,qe.jsx=function(o,f,I){var R=1e4>H.recentlyCreatedOwnerStacks++;return T(o,f,I,!1,R?Error("react-stack-top-frame"):G,R?re(n(o)):Ee)},qe.jsxs=function(o,f,I){var R=1e4>H.recentlyCreatedOwnerStacks++;return T(o,f,I,!0,R?Error("react-stack-top-frame"):G,R?re(n(o)):Ee)}})()),qe}var Rr;function yn(){return Rr||(Rr=1,process.env.NODE_ENV==="production"?ft.exports=mn():ft.exports=pn()),ft.exports}var h=yn();function gn({title:e,titleId:t,...r},n){return ue.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?ue.createElement("title",{id:t},e):null,ue.createElement("path",{fillRule:"evenodd",d:"M12.53 16.28a.75.75 0 0 1-1.06 0l-7.5-7.5a.75.75 0 0 1 1.06-1.06L12 14.69l6.97-6.97a.75.75 0 1 1 1.06 1.06l-7.5 7.5Z",clipRule:"evenodd"}))}const bn=ue.forwardRef(gn);function Sn({title:e,titleId:t,...r},n){return ue.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?ue.createElement("title",{id:t},e):null,ue.createElement("path",{fillRule:"evenodd",d:"M16.28 11.47a.75.75 0 0 1 0 1.06l-7.5 7.5a.75.75 0 0 1-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 0 1 1.06-1.06l7.5 7.5Z",clipRule:"evenodd"}))}const vn=ue.forwardRef(Sn);function wn({title:e,titleId:t,...r},n){return ue.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?ue.createElement("title",{id:t},e):null,ue.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const En=ue.forwardRef(wn),Lr={icon:{light:"#6a7282",dark:"#99a1af"},iconSelected:{light:"#1447e6",dark:"#51a2ff"},checkedRing:{light:"#155dfc",dark:"#51a2ff"}},Rn={markdown:{light:"#0084d1",dark:"#00bcff"},pdf:{light:"#e7000b",dark:"#ff6467"},spreadsheet:{light:"#007a55",dark:"#00d492"},csv:{light:"#007a55",dark:"#00d492"},document:{light:"#155dfc",dark:"#51a2ff"},presentation:{light:"#ca3500",dark:"#ff8904"},image:{light:"#00786f",dark:"#00d5be"},audio:{light:"#e60076",dark:"#fb64b6"},video:{light:"#7f22fe",dark:"#a684ff"},archive:{light:"#bb4d00",dark:"#ffb900"},code:{light:"#9810fa",dark:"#c27aff"},text:Lr.icon},jr="#71829b",ie={rowHover:"hover:bg-[color:light-dark(#f3f4f6,#1e2939)]",rowSelected:"bg-[color:light-dark(#eff6ff,#162456)]",checkedRing:"inset-ring-1 inset-ring-[color:light-dark(#155dfc,#51a2ff)]",name:"text-[color:light-dark(#364153,#e5e7eb)]",nameSelected:"text-[color:light-dark(#193cb8,#bedbff)]",gridEdge:"text-[color:light-dark(#4a5565,#d1d5dc)]",icon:"text-[color:light-dark(#6a7282,#99a1af)]",iconSelected:"text-[color:light-dark(#1447e6,#51a2ff)]"},de={markdown:"text-[color:light-dark(#0084d1,#00bcff)]",pdf:"text-[color:light-dark(#e7000b,#ff6467)]",spreadsheet:"text-[color:light-dark(#007a55,#00d492)]",csv:"text-[color:light-dark(#007a55,#00d492)]",document:"text-[color:light-dark(#155dfc,#51a2ff)]",presentation:"text-[color:light-dark(#ca3500,#ff8904)]",image:"text-[color:light-dark(#00786f,#00d5be)]",audio:"text-[color:light-dark(#e60076,#fb64b6)]",video:"text-[color:light-dark(#7f22fe,#a684ff)]",archive:"text-[color:light-dark(#bb4d00,#ffb900)]",code:"text-[color:light-dark(#9810fa,#c27aff)]",text:"text-[color:light-dark(#6a7282,#99a1af)]"},Ar="text-[length:var(--dt-font-size-body,0.8125rem)]",xn=`${Ar} leading-[max(var(--dt-line-height-body,1.25rem),1.5em)]`,_t=44,kn=12,In=8,ce=14,Cn=14,Mr=e=>e===void 0?void 0:{fontSize:typeof e=="number"?`${e}px`:e},oe=e=>({width:e,height:e}),A={container:"directory-tree-container relative h-full overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"cursor-progress",entry:`directory-tree-entry flex items-center cursor-pointer relative select-none ${xn}`,entryHover:`directory-tree-entry--hover ${ie.rowHover}`,entrySelected:`directory-tree-entry--selected ${ie.rowSelected}`,entryItemSelected:`directory-tree-entry--item-selected ${ie.rowSelected} ${ie.checkedRing}`,expandIcon:`directory-tree-expand-icon flex-shrink-0 flex items-center justify-center ${ie.icon}`,expandIconSelected:`directory-tree-expand-icon--selected ${ie.iconSelected}`,typeIcon:`directory-tree-type-icon flex-shrink-0 flex items-center justify-center ${ie.icon}`,typeIconSelected:`directory-tree-type-icon--selected ${ie.iconSelected}`,name:`directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 ${Ar} font-normal ${ie.name}`,nameDirectory:"directory-tree-name--directory font-medium",nameSelected:`directory-tree-name--selected font-semibold ${ie.nameSelected}`},Mt=e=>{const t=e.slice(e.lastIndexOf("/")+1),r=t.lastIndexOf(".");return r<=0?"":t.slice(r+1).toLowerCase()},Tn=/^[a-z][a-z\d+.-]*:\/\//i,xr=e=>Mt(Tn.test(e)?e.split(/[?#]/,1)[0]:e),Dr=e=>Mt(e.name)||xr(e.relativePath)||xr(e.absolutePath),$r=({isDirectory:e,isExpanded:t,showExpandIcons:r,useCanvasExpandIcons:n,expandIconSize:a})=>{const i=a?{width:a,height:a}:void 0,c=a?"":"h-4 w-4";return!(r&&e)||n?h.jsx("span",{className:c,style:i,"aria-hidden":"true"}):t?h.jsx(bn,{className:c,style:i}):h.jsx(vn,{className:c,style:i})},Pt=(e,t)=>{if(e==null||typeof e=="boolean")return null;if(typeof e=="function")return console.warn(`[DirectoryTree] Function returned by renderer for "${t}". Return a node.`),null;if(typeof e=="object"){if("then"in e)return console.warn(`[DirectoryTree] Promise returned for "${t}". Not supported.`),null;if(Array.isArray(e)){const n=e.map(a=>Pt(a,t)).filter(Boolean);return n.length?n:null}const r=e.type;if(r&&r.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},_n={markdown:e=>h.jsx(le.FileMd,{className:de.markdown,style:oe(e)}),pdf:e=>h.jsx(le.FilePdf,{className:de.pdf,style:oe(e)}),spreadsheet:e=>h.jsx(le.FileXls,{className:de.spreadsheet,style:oe(e)}),csv:e=>h.jsx(le.FileCsv,{className:de.csv,style:oe(e)}),document:e=>h.jsx(le.FileDoc,{className:de.document,style:oe(e)}),presentation:e=>h.jsx(le.FilePpt,{className:de.presentation,style:oe(e)}),image:e=>h.jsx(le.FileImage,{className:de.image,style:oe(e)}),audio:e=>h.jsx(le.FileAudio,{className:de.audio,style:oe(e)}),video:e=>h.jsx(le.FileVideo,{className:de.video,style:oe(e)}),archive:e=>h.jsx(le.FileZip,{className:de.archive,style:oe(e)}),code:e=>h.jsx(le.FileCode,{className:de.code,style:oe(e)}),text:e=>h.jsx(le.FileText,{className:de.text,style:oe(e)})},Nn={markdown:["md","markdown","mdx"],pdf:["pdf"],spreadsheet:["xls","xlsx","xlsm","xlsb","ods"],csv:["csv","tsv"],document:["doc","docx","rtf","odt"],presentation:["ppt","pptx","odp"],image:["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff","avif"],audio:["mp3","wav","ogg","m4a","flac","aac","wma"],video:["mp4","webm","mov","avi","mkv","wmv","flv"],archive:["zip","tar","gz","7z","rar","tgz","bz2"],code:["js","mjs","cjs","ts","tsx","jsx","json","html","htm","css","scss","py","go","rs","c","cpp","h","hpp","sh","bash","yaml","yml","sql","xml","toml"],text:["txt","log"]},Pn=new Map(Object.entries(Nn).flatMap(([e,t])=>t.map(r=>[r,e]))),On=new Set(["","application/octet-stream","binary/octet-stream","text/plain","application/x-empty"]),Ln=e=>(e??"").split(";",1)[0].trim().toLowerCase(),jn=e=>{if(e==="text/markdown"||e==="text/x-markdown")return"markdown";if(e==="application/pdf")return"pdf";if(e.includes("excel")||e.includes("spreadsheet"))return"spreadsheet";if(e==="text/csv"||e==="text/tab-separated-values")return"csv";if(e.includes("word")||e.includes("google-apps.document")||e==="application/rtf")return"document";if(e.includes("powerpoint")||e.includes("presentation"))return"presentation";if(e.startsWith("image/"))return"image";if(e.startsWith("audio/"))return"audio";if(e.startsWith("video/"))return"video";if(e.includes("zip")||e.includes("tar")||e.includes("compressed")||e.includes("archive"))return"archive";if(e==="application/json"||e.includes("javascript")||e.includes("typescript")||e.includes("xml")||e.startsWith("text/html")||e.startsWith("text/css")||e.includes("x-python")||e.includes("x-sh")||e.includes("x-go")||e.includes("x-rust"))return"code";if(e.startsWith("text/"))return"text"},An=(e,t,r,n)=>{const a=Ln(e),i=jn(a),c=Pn.get((t||(r?Mt(r):"")).toLowerCase()),m=(On.has(a)?[c,i]:[i,c]).find(S=>S!==void 0);return m===void 0?h.jsx(le.FileIcon,{className:ie.icon,style:oe(n)}):_n[m](n)},Fr=(e,t,r)=>{const{entry:n,isDirectory:a,isExpanded:i,extension:c,mimeType:u}=e;let m;const S=u||n.mimeType;return n.icon!==void 0?m=n.icon:a?m=i&&t?.directoryExpanded||t?.directory||h.jsx(En,{style:oe(r)}):c&&t?.fileByExtension?.[c]?m=t.fileByExtension[c]:m=t?.file||An(S,c,n.name,r),Pt(typeof m=="function"?m(e):m,n.absolutePath)},Mn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),zr=e=>{if(!e)return;const t=Object.entries(e).filter(([,r])=>r!=null);if(t.length!==0)return Object.fromEntries(t.map(([r,n])=>[`data-${Mn(r)}`,String(n)]))},Br=["color","background","backgroundColor","backgroundImage","backgroundPosition","backgroundSize","backgroundRepeat","backgroundClip","backgroundOrigin","backgroundAttachment","backgroundBlendMode","opacity","boxShadow","filter","backdropFilter","mixBlendMode","borderColor","borderRadius","outline","outlineColor","outlineStyle","outlineWidth","outlineOffset","textShadow","accentColor","caretColor","cursor","fontFamily","fontSize","fontStyle","fontWeight","fontVariant","fontFeatureSettings","fontVariationSettings","fontKerning","letterSpacing","lineHeight","textDecoration","textDecorationColor","textDecorationLine","textDecorationStyle","textDecorationThickness","textUnderlineOffset","textTransform"],Hr=["color","opacity"],Dn="the row's box belongs to the tree (height: visual.itemHeight, indent: visual.indentSize, icons: visual.typeIconSize, text size: visual.fontSize)",$n=new Set(Br),Fn=new Set(Hr),kr=(e,t)=>{const r=t===void 0?e.option:`${e.option}.${t}`;return e.absolutePath===void 0?r:`${r} of "${e.absolutePath}"`},Wr=(e,t,r,n)=>{if(e!==void 0){if(typeof e!="object"||e===null)throw new RangeError(`${kr(r,void 0)} must be an object of CSS properties or undefined, got ${e===null?"null":typeof e}.`);for(const[a,i]of Object.entries(e))if(i!==void 0&&!t.has(a))throw new RangeError(`${kr(r,a)} cannot be set: ${Dn}, so ${n}.`)}},We=(e,t)=>Wr(e,$n,t,"a row style accepts only paint and text properties (ROW_STYLE_PROPERTIES)"),zn=(e,t)=>Wr(e,Fn,t,"the expand icon style accepts only the glyph's colour and opacity (EXPAND_ICON_STYLE_PROPERTIES), and the 14 px expand box is the tree's"),Bn=500,Yr=({entry:e,isDirectory:t,isExpanded:r,isItemSelected:n,selectionMode:a,onSelectionChange:i,onEntryClick:c,toggleDirectory:u,onToggleDirectoryRecursive:m})=>{const S=l.useRef(null);return l.useEffect(()=>()=>{S.current&&window.clearTimeout(S.current)},[]),l.useCallback(T=>{T.stopPropagation(),a!=="none"&&!t&&i&&i(e,!n);let x=!1;c({entry:e,isDirectory:t,isExpanded:r,preventDefault:()=>{x=!0}}),!(!t||x)&&(S.current?(window.clearTimeout(S.current),S.current=null,m(e)):S.current=window.setTimeout(()=>{u(e.absolutePath),S.current=null},Bn))},[t,e,r,m,u,c,a,i,n])},Gr=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",Ir=(e,t)=>e.children!==void 0&&t(e.absolutePath),Vr=(e,t)=>({width:e,gridTemplateColumns:t}),Kr=l.memo(({entry:e,indentLevel:t,positionInSet:r,setSize:n,rowIndex:a,flatIndex:i,onRowFocus:c,onRowBlur:u,isSelectedForAria:m,rowHeight:S,isDirOpen:T,columns:x,numericTemplate:_,numericTotal:p,nameWidth:g,rowClassName:y,selection:{onEntryClick:E,selectedPath:v,currentPath:$,mode:N="none",selectedItems:P,onSelectionChange:b},expansion:{toggleDirectory:M,onToggleDirectoryRecursive:D},visual:{iconOverrides:O,showExpandIcons:q=!0,showDirectoryIcons:X=!0,showFileIcons:F=!0,useCanvasExpandIcons:H=!1,expandIconSize:fe,typeIconSize:B,fontSize:re,indentSize:he,highlightStyles:Y,expandIconClassName:G,expandIconStyle:Ee}})=>{We(e.style,{option:"entry.style",absolutePath:e.absolutePath});const[ge,o]=l.useState(!1),f=e.children!==void 0,I=f&&T(e.absolutePath),R=e.absolutePath===v,be=e.absolutePath===$,C=!f&&!!P?.has(e.absolutePath),L=f?void 0:Dr(e),Z=Yr({entry:e,isDirectory:f,isExpanded:I,isItemSelected:C,selectionMode:N,onSelectionChange:b,onEntryClick:E,toggleDirectory:M,onToggleDirectoryRecursive:D}),me=ge?Y?.hoverClassName!==void 0?Y.hoverClassName:A.entryHover:"",Ie=(()=>{if(f){if(R)return Y?.directorySelectedClassName!==void 0?Y.directorySelectedClassName:A.entrySelected}else if(R||C)return Y?.itemSelectedClassName!==void 0?Y.itemSelectedClassName:K.twMerge(R&&A.entrySelected,C&&A.entryItemSelected);return""})(),j=typeof y=="function"?y(e):y,Se=K.twMerge("dt-grid-row cursor-pointer select-none",me,Ie,j,e.className),U=K.twMerge(A.expandIcon,G,(R||C)&&A.expandIconSelected),Ae=K.twMerge(A.typeIcon,(R||C)&&A.typeIconSelected),ne=K.twMerge("dt-grid-name-label ml-1",ie.name,f&&A.nameDirectory,(R||C)&&A.nameSelected),Q=$r({isDirectory:f,isExpanded:I,showExpandIcons:q,useCanvasExpandIcons:H,expandIconSize:fe}),se=(f?X:F)?Fr({entry:e,isDirectory:f,isExpanded:I,isSelected:R,isItemSelected:C,extension:L,mimeType:e.mimeType},O,B):null,Ce={indentLevel:t,isDirectory:f,isExpanded:I},[Pe,...Te]=x,Me=Pe?.render?Pe.render(e,Ce):e.label??e.name,Re={...ge?Y?.hoverStyle:{},...f&&R?Y?.directorySelectedStyle:{},...!f&&(R||C)?Y?.itemSelectedStyle:{}};return h.jsxs("div",{className:Se,style:{...Re,...e.style,height:S},role:"row","aria-expanded":f?I:void 0,"aria-level":t+1,"aria-posinset":r,"aria-setsize":n,"aria-rowindex":a,"aria-selected":N==="none"?void 0:m,"aria-current":be?"page":void 0,...zr(e.data),"data-entry-type":f?"directory":"file","data-entry-expanded":f?String(I):void 0,"data-entry-selected":R?"true":void 0,"data-entry-item-selected":C?"true":void 0,onClick:Z,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:W=>c(i,e.absolutePath,W.currentTarget),onBlur:W=>u(e.absolutePath,W.currentTarget),onKeyDown:W=>{if(W.key==="Enter"){if(W.repeat){W.preventDefault();return}Z(W)}},tabIndex:0,children:[h.jsxs("div",{className:K.twMerge("dt-grid-name-cell",Pe?.className),role:"gridcell",style:{width:g,paddingLeft:Math.max(0,t*he)},children:[(q||H)&&h.jsx("span",{className:U,style:{...Ee,width:ce,height:ce},children:Q}),(f?X:F)&&h.jsx("span",{className:Ae,style:{width:B,height:B},children:se}),h.jsx("span",{className:ne,style:Mr(re),children:Me})]}),Te.length>0&&h.jsx("div",{className:"dt-grid-numeric-viewport",children:h.jsx("div",{className:"dt-grid-numeric-track",style:Vr(p,_),children:Te.map(W=>h.jsx("div",{className:K.twMerge("dt-grid-cell",Gr(W.align),W.className),role:"gridcell",children:W.render?W.render(e,Ce):null},W.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=Ir(e.entry,e.isDirOpen),n=Ir(t.entry,t.isDirOpen);return e.indentLevel===t.indentLevel&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.rowIndex===t.rowIndex&&e.flatIndex===t.flatIndex&&e.isSelectedForAria===t.isSelectedForAria&&e.rowHeight===t.rowHeight&&r===n&&e.columns===t.columns&&e.numericTemplate===t.numericTemplate&&e.numericTotal===t.numericTotal&&e.nameWidth===t.nameWidth&&e.rowClassName===t.rowClassName&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.currentPath===t.selection.currentPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});Kr.displayName="DirectoryTreeGridRow";const Xr=({kind:e,columns:t,numericTemplate:r,numericTotal:n,nameWidth:a,scrollBarWidth:i,className:c,nameContent:u,renderCell:m})=>{const[,...S]=t,T=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",x=e==="header"?"dt-grid-header":"dt-grid-footer",_=e==="header"?"columnheader":"gridcell";return h.jsxs("div",{className:K.twMerge(x,ie.gridEdge,c),role:"row",children:[h.jsx("div",{className:K.twMerge(T,"px-1",t[0]?.className),role:_,style:{width:a},children:u}),S.length>0&&h.jsx("div",{className:"dt-grid-numeric-viewport",children:h.jsx("div",{className:"dt-grid-numeric-track",style:Vr(n,r),children:S.map(p=>h.jsx("div",{className:K.twMerge("dt-grid-cell",Gr(p.align),p.className),role:_,children:m(p)},p.key))})}),h.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:i},"aria-hidden":"true"})]})},Hn=({columns:e,className:t,...r})=>h.jsx(Xr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...r}),Cr=(e,t)=>typeof e=="function"?e(t):e??null,Wn=({columns:e,allEntries:t,className:r,...n})=>h.jsx(Xr,{kind:"footer",columns:e,className:r,nameContent:Cr(e[0]?.footer,t),renderCell:a=>Cr(a.footer,t),...n}),Yn=240,Ur=96,Jr=12,Ot=(e,t)=>{const r=e?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:t},Gn=e=>e.slice(1).map(t=>`${Ot(t,Ur)}px`).join(" "),Vn=({measuredWidth:e,columns:t,scrollBarWidth:r=Jr})=>{const n=Ot(t[0],Yn),a=t.slice(1).reduce((m,S)=>m+Ot(S,Ur),0),i=Number.isFinite(e)&&e>0?e:0,c=Math.max(0,i-n-Math.max(0,r)),u=Math.max(0,a-c);return{nameWidth:n,numericTotal:a,numericVisible:c,maxHScroll:u}},Nt=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,Kn=e=>{const t=[],r=n=>{for(const a of n)t.push(a),a.children&&a.children.length>0&&r(a.children)};return r(e),t},qr=["entryKindDirectory","entryKindFile"],Lt=[...ye.VIRTUAL_SCROLL_LABEL_KEYS,...qr],jt=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),Zr=Object.freeze({en:Object.freeze({...ye.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...jt.en}),ja:Object.freeze({...ye.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...jt.ja})}),Tr=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,Xn=e=>{const t={};let r=!1;for(const n of ye.VIRTUAL_SCROLL_LABEL_KEYS){const a=Object.hasOwn(e,n)?e[n]:void 0;a!==void 0&&(t[n]=a,r=!0)}return r?t:void 0},Qr=(e,t)=>{const r=ye.resolveVirtualScrollLocale(e);if(t===void 0)return Zr[r];if(t===null||typeof t!="object")throw new RangeError(`[directory-tree] labels must be an object; got ${Tr(t)}`);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new RangeError(`[directory-tree] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);for(const c of Object.keys(t))if(!Lt.includes(c))throw new RangeError(`[directory-tree] labels.${c} is not a known label key; expected one of ${Lt.join(", ")}`);const i={...ye.resolveVirtualScrollLabels(r,Xn(t)),...jt[r]};for(const c of qr){const u=Object.hasOwn(t,c)?t[c]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[directory-tree] labels.${c} must be a non-blank string; got ${Tr(u)}`);i[c]=u}}return Object.freeze(i)},Un=e=>{const t={};for(const r of ye.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},Jn=()=>{let e=null;return{mark:t=>{const r=t.composedPath();e=r,setTimeout(()=>{e===r&&(e=null)},0)},landedOn:t=>e?.includes(t)===!0}},Ze=e=>typeof e=="string"?JSON.stringify(e):String(e),At=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t)||t<=0)throw new RangeError(`[directory-tree] visual.${e} must be a finite number greater than 0 (px); got ${Ze(t)}.`);return t},qn=e=>{if(typeof e=="string"&&e.trim()!==""||typeof e=="number"&&Number.isFinite(e)&&e>0)return e;throw new RangeError(`[directory-tree] visual.fontSize must be a finite number greater than 0 (px) or a CSS font size that is not blank; got ${Ze(e)}.`)},Zn=({indentSize:e,typeIconSize:t,fontSize:r})=>({indentSize:e===void 0?kn:At("indentSize",e),typeIconSize:t===void 0?Cn:At("typeIconSize",t),fontSize:r===void 0?void 0:qn(r)}),Qn=({indentSize:e,removeRootIndent:t,hasExpandBox:r})=>t?Math.max(0,e-(r?ce:0)):0,eo=(e,t,r)=>{if(typeof e!="function")return At("itemHeight",e);const n=e(t,r);if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new RangeError(`[directory-tree] visual.itemHeight returned ${Ze(n)} for ${JSON.stringify(t.absolutePath)} (row ${r}); it must return a finite number greater than 0 (px).`);return n},to=(e,t,r)=>{const n=t===void 0?In:t;if(typeof n!="number"||!Number.isFinite(n)||n<=0||n>ce)throw new RangeError(`[directory-tree] visual.expandIconSize must be a finite number greater than 0 and at most ${ce} (the expand box, px) while tree lines are drawn; got ${Ze(n)}.`);const{indentSize:a,typeIconSize:i}=e,c=n/2,u=ce+i-n/2;if(a<c||a>u)throw new RangeError(`[directory-tree] visual.indentSize ${Ze(a)} does not fit the tree lines: with typeIconSize ${i} and an expand glyph of ${n} px it must be from ${c} (half the glyph) to ${u} (the ${ce} px expand box + typeIconSize − half the glyph).`);return{indentSize:a,typeIconSize:i,glyphSize:n,originX:r}},ro=({indentSize:e,typeIconSize:t,glyphSize:r})=>Math.min(Math.max(ce+t/2-e,r/2),ce-r/2),no=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,a=r-1,i=0;for(;n<=a;){const c=n+a>>>1;e[c]<=t?(i=c,n=c+1):a=c-1}return i},oo=(e,t,r)=>{if(r<=0||e.length===0||t.length!==e.length+1)return null;const n=no(t,r),a=e[n];return a?{path:a.entry.absolutePath,offsetInViewport:r-t[n]}:null},so=(e,t,r)=>{if(t.length===0||r.length!==t.length+1)return null;for(let n=0;n<t.length;n++)if(t[n].entry.absolutePath===e.path)return Math.max(0,r[n]+e.offsetInViewport);return null},ao=(e,t,r)=>{const n=[];for(let a=t;a<r;a++){const i=e[a];if(!(!i||i.length===0))for(const c of i)n.push(c)}return n},lo=(e,t,r)=>{const n=[];for(let a=t;a<r;a++){const i=e[a];if(!(!i||i.length===0))for(const c of i)n.push(c)}return n},io=(e,t,r,n)=>{const a=Math.max(1,Math.floor(t*n)),i=Math.max(1,Math.floor(r*n));(e.width!==a||e.height!==i)&&(e.width=a,e.height=i);const c=e.style;c.width!==`${t}px`&&(c.width=`${t}px`),c.height!==`${r}px`&&(c.height=`${r}px`)},co=(e,t,r)=>{e.lineWidth=r,e.beginPath();for(const n of t)e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke()},uo=(e,t,r,n)=>{if(t.length===0)return;const a=e.strokeStyle,i=e.lineWidth,c=e.lineCap,u=e.lineJoin;e.strokeStyle=r,e.lineCap="round",e.lineJoin="round";for(const m of t){const S=n??m.size,T=Math.max(0,S/2),x=Math.max(1,Math.round(S*.08)),_=Math.max(1,Math.round(S*.14)),p=Math.max(0,T-x*.8),g=Math.max(0,p*.55);e.lineWidth=x,e.beginPath(),e.arc(m.centerX,m.centerY,Math.max(0,T-x*.3),0,Math.PI*2),e.stroke(),e.lineWidth=_,e.beginPath(),e.moveTo(m.centerX-g,m.centerY),e.lineTo(m.centerX+g,m.centerY),e.stroke(),m.isExpanded||(e.beginPath(),e.moveTo(m.centerX,m.centerY-g),e.lineTo(m.centerX,m.centerY+g),e.stroke())}e.strokeStyle=a,e.lineWidth=i,e.lineCap=c,e.lineJoin=u},en=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:i,color:c=jr,strokeWidth:u=1,renderStartIndex:m,renderEndIndex:S,lookaheadEndIndex:T,devicePixelRatio:x,expandGlyphColor:_,expandGlyphSize:p})=>{const g=l.useRef(null),y=l.useRef(null),E=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:i,color:c,strokeWidth:u,renderStartIndex:m,renderEndIndex:S,lookaheadEndIndex:T,devicePixelRatio:x,expandGlyphColor:_,expandGlyphSize:p}),v=l.useCallback(()=>{y.current=null;const N=g.current;if(!N)return;const P=N.getContext("2d");if(!P)return;const b=E.current;if(b.width<=0||b.viewportHeight<=0){P.clearRect(0,0,N.width,N.height);return}const M=Number.isFinite(b.devicePixelRatio??NaN)?b.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;io(N,b.width,b.viewportHeight,M);const D=b.segmentsByItem.length,O=typeof b.renderStartIndex=="number"&&Number.isFinite(b.renderStartIndex)?Math.max(0,Math.floor(b.renderStartIndex)):Math.max(0,Math.floor(b.scrollPosition/b.itemHeight)),q=Math.min(D,Math.ceil((b.scrollPosition+b.viewportHeight)/b.itemHeight)),X=(()=>{if(typeof b.renderEndIndex=="number"&&Number.isFinite(b.renderEndIndex)){const B=Math.floor(b.renderEndIndex);return Math.max(Math.min(D,B+1),O)}return Math.max(q,O)})(),F=(()=>{if(typeof b.lookaheadEndIndex=="number"&&Number.isFinite(b.lookaheadEndIndex)){const B=Math.floor(b.lookaheadEndIndex),re=Math.min(D,B+1);return Math.max(re,X)}return Math.max(q,X)})(),H=ao(b.segmentsByItem,O,F),fe=lo(b.glyphsByItem,O,F);P.save(),P.scale(M,M),P.clearRect(0,0,b.width,b.viewportHeight),P.translate(0,-b.scrollPosition),P.strokeStyle=b.color,co(P,H,b.strokeWidth),uo(P,fe,b.expandGlyphColor??b.color,b.expandGlyphSize),P.restore()},[]),$=l.useCallback(()=>{y.current===null&&(y.current=window.requestAnimationFrame(v))},[v]);return l.useEffect(()=>{E.current={segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:i,color:c,strokeWidth:u,renderStartIndex:m,renderEndIndex:S,lookaheadEndIndex:T,devicePixelRatio:x,expandGlyphColor:_,expandGlyphSize:p},$()},[e,t,r,n,a,i,c,u,m,S,T,x,_,p,$]),l.useEffect(()=>()=>{y.current!==null&&(window.cancelAnimationFrame(y.current),y.current=null)},[]),h.jsx("canvas",{ref:g,className:"pointer-events-none absolute top-0 left-0 z-0"})});en.displayName="TreeLineCanvas";const fo=e=>{const t=new Map;for(let r=0;r<e.length;r++){const n=e[r].entry.absolutePath;t.has(n)||t.set(n,r)}return t},_r=(e,t)=>e.selectedPath===t?e:{selectedPath:t,selectionGeneration:e.selectionGeneration+1,anchor:e.anchor},ho=(e,t)=>({...e,anchor:{path:t,selectionGeneration:e.selectionGeneration,focused:!0}}),mo=(e,t)=>{const{anchor:r,selectionGeneration:n,selectedPath:a}=t;if(r!==null&&(r.focused||r.selectionGeneration===n)){const i=e.get(r.path);if(i!==void 0)return i}if(a!==null){const i=e.get(a);if(i!==void 0)return i}return 0},po={msOverflowStyle:"none",scrollbarWidth:"none"},yo=()=>{let e=document.getElementById("directory-tree-webkit-scrollbar-hide");e||(e=document.createElement("style"),e.id="directory-tree-webkit-scrollbar-hide",e.textContent=".directory-tree-container::-webkit-scrollbar { display: none; }",document.head.appendChild(e))},go=e=>{const t=l.useRef(null),r=t.current;return r!==null&&ye.VIRTUAL_SCROLL_LABEL_KEYS.every(n=>r[n]===e[n])?r:(t.current=e,e)},Nr=new Set(["top","bottom","center","nearest"]),Pr=e=>{const t=e?.align;if(t===void 0)return"top";if(!Nr.has(t))throw new RangeError(`[directory-tree] Unsupported scroll alignment ${JSON.stringify(t)}; expected one of ${[...Nr].join(", ")}.`);return t},bo={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},So=(e,t,r,n,a)=>{const i=[],c=[];let u=0;const m=(S,T,x)=>{const _=a?[...S].sort(a):S;for(let p=0;p<_.length;p++){const g=_[p],y=p===_.length-1,E=[...x,y],v=g.children!==void 0,$=v&&t(g.absolutePath,g.relativePath);let N=T,P=x;n&&(N=T-1,P=x.slice(1)),i.push({entry:g,indentLevel:N,depth:T,positionInSet:p+1,setSize:_.length}),r&&(N>u&&(u=N),c.push({id:g.absolutePath,name:g.name,absolutePath:g.absolutePath,indentLevel:N,isLastChild:y,isDirectory:v,isExpanded:$,ancestorIsLast:[...P],hideLines:n&&T===0})),v&&$&&g.children&&m(g.children,T+1,E)}};return m(e,0,[]),{flatItems:i,lineItems:c,maxIndent:u}},Or=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,a=r-1,i=0;for(;n<=a;){const c=n+a>>>1;e[c]<=t?(i=c,n=c+1):a=c-1}return i},vo=(e,t,r,n,a,i)=>{const c=n?.renderStart??Math.max(0,Or(i,a)),u=t>0?Or(i,a+t)+r:c+r,m=e>0?Math.min(e-1,Math.max(c,u)):c,S=n?.renderEnd??m,T=e>0?Math.min(e-1,S+r):S;return{renderStart:c,renderEnd:S,lookaheadEnd:T}},wo=(e,t,r,n)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const{indentSize:a,typeIconSize:i,glyphSize:c,originX:u}=n,m=Array.from({length:e.length},()=>[]),S=Array.from({length:e.length},()=>[]),T=u+ro(n),x=p=>p*a+T,_=c/2+2;for(let p=0;p<e.length;p++){const g=e[p],y=t[p]??0,E=r[p]??0,v=E+y/2,$=e[p+1],N=v+i/2,P=E+y,b=$!==void 0&&$.indentLevel===g.indentLevel+1&&N<P?{key:`${g.id}-connector-children`,x1:x($.indentLevel),y1:N,x2:x($.indentLevel),y2:P,itemIndex:p}:null;if(g.hideLines){b!==null&&(m[p]=[b]);continue}const M=[];for(let O=0;O<g.indentLevel;O++){if(g.ancestorIsLast[O]??!1)continue;let X=!1;for(let F=p;F<e.length;F++){const H=e[F];if(H.indentLevel>O&&H.ancestorIsLast.length>O&&!H.ancestorIsLast[O]){X=!0;break}if(F>p&&H.indentLevel===O)break}if(X){const F=x(O);M.push({key:`${g.id}-ancestor-${O}`,x1:F,y1:E,x2:F,y2:E+y,itemIndex:p})}}const D=x(g.indentLevel);p>0&&M.push({key:`${g.id}-connector-top`,x1:D,y1:E,x2:D,y2:g.isDirectory?v-_:v,itemIndex:p}),!g.isDirectory&&g.isLastChild&&M.push({key:`${g.id}-connector-horizontal`,x1:D,y1:v,x2:u+g.indentLevel*a+ce,y2:v,itemIndex:p}),g.isLastChild||(g.isDirectory?M.push({key:`${g.id}-connector-bottom`,x1:D,y1:v+_,x2:D,y2:E+y,itemIndex:p}):M.push({key:`${g.id}-connector-bottom`,x1:D,y1:v,x2:D,y2:E+y,itemIndex:p})),b!==null&&M.push(b),m[p]=M,g.isDirectory&&(S[p]=[{key:`${g.id}-glyph`,itemIndex:p,centerX:D,centerY:v,size:c,isExpanded:g.isExpanded}])}return{segmentsByItem:m,glyphsByItem:S}},tn=l.memo(({entry:e,indentLevel:t,originX:r,depth:n,positionInSet:a,setSize:i,isSelectedForAria:c,flatIndex:u,isActive:m,registerRowRef:S,onNavigationKeyDown:T,onRowFocus:x,onRowBlur:_,rowHeight:p,entryKindDirectory:g,entryKindFile:y,isDirOpen:E,expansion:{toggleDirectory:v,onToggleDirectoryRecursive:$},selection:{onEntryClick:N,selectedPath:P,currentPath:b,mode:M="none",selectedItems:D,onSelectionChange:O},visual:{iconOverrides:q,showExpandIcons:X=!0,showDirectoryIcons:F=!0,showFileIcons:H=!0,useCanvasExpandIcons:fe=!1,expandIconSize:B,typeIconSize:re,fontSize:he,indentSize:Y,highlightStyles:G,entryClassName:Ee,entryStyle:ge,nameClassName:o,nameStyle:f,directoryNameClassName:I,directoryNameStyle:R,fileNameClassName:be,fileNameStyle:C,expandIconClassName:L,expandIconStyle:Z}})=>{We(e.style,{option:"entry.style",absolutePath:e.absolutePath});const[me,Ie]=l.useState(!1),j=e.children!==void 0,Se=j&&E(e.absolutePath),U=e.absolutePath===P,Ae=e.absolutePath===b,ne=!j&&D?.has(e.absolutePath),Q=l.useCallback(ee=>S(u,ee),[S,u]),se=j?void 0:Dr(e),Ce=Yr({entry:e,isDirectory:j,isExpanded:Se,isItemSelected:!!ne,selectionMode:M,onSelectionChange:O,onEntryClick:N,toggleDirectory:v,onToggleDirectoryRecursive:$}),Pe=me?G?.hoverClassName!==void 0?G.hoverClassName:A.entryHover:"",Te=(()=>{if(j){if(U)return G?.directorySelectedClassName!==void 0?G.directorySelectedClassName:A.entrySelected}else if(U||ne)return G?.itemSelectedClassName!==void 0?G.itemSelectedClassName:K.twMerge(U&&A.entrySelected,ne&&A.entryItemSelected);return""})(),Me=K.twMerge(A.entry,Pe,Te,Ee,e.className),Re=K.twMerge(A.expandIcon,L,(U||ne)&&A.expandIconSelected),W=K.twMerge(A.typeIcon,(U||ne)&&A.typeIconSelected),Ye=K.twMerge(A.name,o,j&&A.nameDirectory,j&&I,!j&&be,(U||ne)&&A.nameSelected),Qe=$r({isDirectory:j,isExpanded:Se,showExpandIcons:X&&t>=0,useCanvasExpandIcons:fe,expandIconSize:B}),ht=(j?F:H)?Fr({entry:e,isDirectory:j,isExpanded:Se,isSelected:U,isItemSelected:!!ne,extension:se,mimeType:e.mimeType},q,re):null,Ge={...me?G?.hoverStyle:{},...j&&U?G?.directorySelectedStyle:{},...!j&&(U||ne)?G?.itemSelectedStyle:{}},Ve=zr(e.data),et={width:re,height:re},tt=Mr(he),ve=r+t*Y;return h.jsxs("div",{className:Me,style:{...tt,...Ge,...ge,...e.style,paddingLeft:`${Math.max(0,ve)}px`,transform:ve<0?`translateX(${ve}px)`:void 0,width:ve<0?`calc(100% + ${-ve}px)`:void 0,height:`${p}px`},...Ve,"data-entry-type":j?"directory":"file","data-entry-expanded":j?String(Se):void 0,"data-entry-selected":U?"true":void 0,"data-entry-item-selected":ne?"true":void 0,onClick:Ce,onMouseEnter:()=>Ie(!0),onMouseLeave:()=>Ie(!1),onFocus:ee=>x(u,e.absolutePath,ee.currentTarget),onBlur:ee=>_(e.absolutePath,ee.currentTarget),ref:Q,onKeyDown:ee=>{if(ee.key==="Enter"||ee.key===" "){ee.preventDefault(),ee.repeat||Ce(ee);return}T(ee,u)},tabIndex:m?0:-1,role:"treeitem","aria-expanded":j?Se:void 0,"aria-level":n+1,"aria-posinset":a,"aria-setsize":i,"aria-selected":M==="none"?void 0:c,"aria-current":Ae?"page":void 0,"aria-label":`${e.name} (${j?g:y})`,children:[(X||fe)&&h.jsx("span",{className:Re,style:{...Z,width:ce,height:ce},children:Qe}),(j?F:H)&&h.jsx("span",{className:W,style:et,children:ht}),h.jsx("span",{className:Ye,style:{...tt,...f,...j?R:C},"data-entry-type":j?"directory":"file","data-entry-role":"name",children:e.label??e.name})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=e.entry.children!==void 0,n=t.entry.children!==void 0,a=r&&e.isDirOpen(e.entry.absolutePath),i=n&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&e.originX===t.originX&&e.depth===t.depth&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.isSelectedForAria===t.isSelectedForAria&&e.flatIndex===t.flatIndex&&e.isActive===t.isActive&&e.rowHeight===t.rowHeight&&e.entryKindDirectory===t.entryKindDirectory&&e.entryKindFile===t.entryKindFile&&a===i&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.currentPath===t.selection.currentPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual.iconOverrides===t.visual.iconOverrides&&e.visual.showExpandIcons===t.visual.showExpandIcons&&e.visual.showDirectoryIcons===t.visual.showDirectoryIcons&&e.visual.showFileIcons===t.visual.showFileIcons&&e.visual.useCanvasExpandIcons===t.visual.useCanvasExpandIcons&&e.visual.expandIconSize===t.visual.expandIconSize&&e.visual.typeIconSize===t.visual.typeIconSize&&e.visual.fontSize===t.visual.fontSize&&e.visual.indentSize===t.visual.indentSize&&e.visual.highlightStyles===t.visual.highlightStyles&&e.visual.entryClassName===t.visual.entryClassName&&e.visual.entryStyle===t.visual.entryStyle&&e.visual.nameClassName===t.visual.nameClassName&&e.visual.nameStyle===t.visual.nameStyle&&e.visual.directoryNameClassName===t.visual.directoryNameClassName&&e.visual.directoryNameStyle===t.visual.directoryNameStyle&&e.visual.fileNameClassName===t.visual.fileNameClassName&&e.visual.fileNameStyle===t.visual.fileNameStyle&&e.visual.expandIconClassName===t.visual.expandIconClassName&&e.visual.expandIconStyle===t.visual.expandIconStyle});tn.displayName="DirectoryEntryItem";const rn=e=>{const t=[];if(e.children)for(const r of e.children)r.type==="directory"&&(t.push(r.absolutePath),t.push(...rn(r)));return t},Eo=({entries:e,expansion:{toggle:t,isExpanded:r,expandMultiple:n,collapseMultiple:a,isPending:i,alwaysExpanded:c=!1,doubleClickAction:u="recursive"},selection:{onEntryClick:m,selectedPath:S,currentPath:T,mode:x="none",selectedItems:_,onSelectionChange:p},visual:{className:g,style:y,ariaLabel:E,ariaLabelledBy:v,lineColor:$=jr,showTreeLines:N=!0,showExpandIcons:P=!0,showDirectoryIcons:b=!0,showFileIcons:M=!0,iconOverrides:D,expandIconSize:O,typeIconSize:q,fontSize:X,indentSize:F,itemHeight:H=_t,removeRootIndent:fe=!1,highlightStyles:B,entryClassName:re,entryStyle:he,nameClassName:Y,nameStyle:G,directoryNameClassName:Ee,directoryNameStyle:ge,fileNameClassName:o,fileNameStyle:f,expandIconClassName:I,expandIconStyle:R}={},virtualScroll:be,grid:C,sort:L,locale:Z,labels:me,ref:Ie})=>{const j=ye.resolveVirtualScrollLocale(Z),Se=l.useMemo(()=>Qr(Z,me),[Z,me]),U=go(Un(Se)),{entryKindDirectory:Ae,entryKindFile:ne}=Se,Q=l.useMemo(()=>Zn({indentSize:F,typeIconSize:q,fontSize:X}),[F,q,X]);l.useMemo(()=>{We(he,{option:"visual.entryStyle"}),We(B?.hoverStyle,{option:"visual.highlightStyles.hoverStyle"}),We(B?.directorySelectedStyle,{option:"visual.highlightStyles.directorySelectedStyle"}),We(B?.itemSelectedStyle,{option:"visual.highlightStyles.itemSelectedStyle"}),zn(R,{option:"visual.expandIconStyle"})},[he,B,R]);const se=C!==void 0,[Ce,Pe]=l.useState(!1),Te=l.useRef(null),Me=l.useRef(null),Re=l.useRef(null),[W,Ye]=l.useState(0),[Qe,ht]=l.useState(0),[Ge,Ve]=l.useState(0),[et,tt]=l.useState(null),{overscanCount:ve=15,className:ee,background:Dt,onScroll:$t,onRangeChange:Ft,onScrollAdjust:zt,liveRegion:Bt,initialScrollIndex:Ht,initialScrollOffset:De,initialScrollAnchor:Wt,callbackThrottleMs:Yt=5,contentInsets:Gt,onItemFocus:Vt,viewportHeightOverride:ae,scrollBarOptions:mt,behaviorOptions:Kt,preserveScrollAnchor:Xt=!1,getItemKey:nn,testId:Ut,contentProps:pt}=be??{},Jt=l.useMemo(()=>se?{...pt,role:"rowgroup"}:{...pt,role:"tree","aria-label":v?void 0:E,"aria-labelledby":v,"aria-multiselectable":x==="multiple"?!0:void 0,"aria-busy":i?!0:void 0},[se,pt,E,v,x,i]),qt=l.useMemo(()=>({...Kt,enableKeyboardNavigation:!1}),[Kt]),[rt,Zt]=l.useState(typeof De=="number"?De:0),yt=l.useRef(typeof De=="number"?De:0),Qt=l.useCallback((s,d)=>{yt.current=s,Zt(s),$t?.(s,d)},[$t]),er=l.useCallback(s=>{const{renderingStartIndex:d,renderingEndIndex:w}=s;tt(k=>k&&k.renderStart===d&&k.renderEnd===w?k:{renderStart:d,renderEnd:w}),Ft?.(s)},[Ft]);l.useEffect(()=>{Pe(!0),yo()},[]),l.useEffect(()=>{const s=Te.current,d=se?Me.current:s,w=()=>{if(s){const z=s.clientWidth;ht(J=>Math.abs(J-z)>1?z:J)}if(typeof ae=="number")Ye(z=>Math.abs(z-ae)>1?ae:z);else if(d){const z=d.clientHeight;Ye(J=>Math.abs(J-z)>1?z:J)}};if(!(s||d))return Ye(0);w();const k=new ResizeObserver(w);return s&&k.observe(s),d&&d!==s&&k.observe(d),()=>k.disconnect()},[ae,se]);const $e=typeof ae=="number"?ae:W,we=l.useCallback(s=>c||(Ce?r(s):!1),[Ce,r,c]),tr=K.twMerge(A.container,i&&A.containerPending,g),rr=l.useMemo(()=>({...po,...y??{},...typeof ae=="number"?{height:ae,minHeight:ae}:{}}),[y,ae]),gt=l.useCallback((s,d)=>{const w=[s.absolutePath,...rn(s)],k=d||u;if(w.every(ke=>we(ke)))return a(w);if(w.every(ke=>!we(ke))||k==="recursive")return n(w);if(k==="toggle")return a(w);console.warn(`[DirectoryTree] Unknown double click action: ${k}. No action taken.`)},[we,n,a,u]),bt=se?!1:fe,{flatItems:Oe,lineItems:St,maxIndent:nr}=l.useMemo(()=>So(e,we,N,bt,L),[e,we,N,bt,L]),nt=Qn({indentSize:Q.indentSize,removeRootIndent:bt,hasExpandBox:P||N}),pe=l.useMemo(()=>N?to(Q,O,nt):null,[N,Q,O,nt]),V=l.useMemo(()=>Oe.map((s,d)=>({...s,rowHeight:eo(H,s.entry,d)})),[Oe,H]),_e=l.useMemo(()=>V.map(s=>s.rowHeight),[V]),Le=l.useMemo(()=>{const s=new Array(_e.length+1);s[0]=0;for(let d=0;d<_e.length;d++)s[d+1]=s[d]+_e[d];return s},[_e]),or=l.useCallback(s=>V[s]?.rowHeight??_t,[V]),on=l.useCallback(s=>V[s]?.entry.absolutePath??s,[V]),sr=nn??on,Fe=S??null,vt=T??null,[ar,Ke]=l.useState(()=>({selectedPath:Fe,selectionGeneration:0,anchor:null})),wt=_r(ar,Fe);wt!==ar&&Ke(s=>_r(s,Fe));const ot=l.useMemo(()=>fo(Oe),[Oe]),ze=l.useMemo(()=>mo(ot,wt),[ot,wt]),Xe=l.useRef(new Map),st=l.useRef(null),[at]=l.useState(Jn),Ue=l.useRef(null),[sn,lr]=l.useState(!0),Et=l.useRef(Oe);Et.current=Oe;const ir=l.useRef(we);ir.current=we;const Rt=l.useRef(t);Rt.current=t;const cr=l.useRef(ot);cr.current=ot;const xt=l.useRef(ze);xt.current=ze;const dr=l.useRef(Vt);dr.current=Vt;const je=l.useCallback(s=>{const d=Re.current;return!d||d.getViewportSize()<=0?!1:(d.scrollToIndex(s,{align:"nearest"}),!0)},[]),xe=l.useCallback(s=>{const d=Xe.current.get(s);if(d===void 0){Ue.current=s,je(s)||(Ue.current=null);return}Ue.current=null,je(s),d.focus({preventScroll:!0})},[je]),ur=l.useCallback((s,d)=>{if(d)Xe.current.set(s,d),Ue.current===s?(Ue.current=null,d.focus({preventScroll:!0})):d.contains(d.ownerDocument.activeElement)&&Ke(w=>w.anchor===null?w:{...w,anchor:{...w.anchor,focused:!0}});else{const w=Xe.current.get(s);Xe.current.delete(s),w?.contains(w.ownerDocument.activeElement)&&Ke(k=>k.anchor===null?k:{...k,anchor:{...k.anchor,focused:!1}})}s===xt.current&&lr(d!==null)},[]);l.useLayoutEffect(()=>{lr(Xe.current.has(ze))},[ze]);const kt=l.useCallback((s,d,w)=>{const k=st.current===w;st.current=null,k||(Ke(z=>ho(z,d)),at.landedOn(w)||je(s)),dr.current?.(s)},[je,at]),lt=l.useCallback(s=>at.mark(s.nativeEvent),[at]),It=l.useCallback((s,d)=>{const{ownerDocument:w}=d;if(!w.hasFocus()&&d.contains(w.activeElement)){st.current=d;return}st.current=null,Ke(k=>k.anchor!==null&&k.anchor.path===s?{...k,anchor:{...k.anchor,focused:!1}}:k)},[]),an=l.useCallback(()=>xe(xt.current),[xe]),Ct=l.useCallback((s,d)=>{const w=Pr(d),k=Et.current.length;if(!Number.isInteger(s)||s<0||s>=k)throw new RangeError(`[directory-tree] scrollToIndex: ${String(s)} is not a row index (${k===0?"the tree has no rows":`expected an integer in 0..${String(k-1)}`}).`);if(w==="nearest"){je(s);return}Re.current?.scrollToIndex(s,{align:w})},[je]);l.useImperativeHandle(Ie,()=>({scrollToIndex:Ct,scrollToPath:(s,d)=>{Pr(d);const w=cr.current.get(s);return w===void 0?!1:(Ct(w,d),!0)},getScrollAnchor:()=>Re.current?.getScrollAnchor()??null}),[Ct]);const fr=l.useCallback((s,d)=>{if(s.altKey||s.ctrlKey||s.metaKey)return;const w=Et.current,k=w.length-1;if(k<0)return;const z=w[d],J=z?.entry.children!==void 0,ke=J&&ir.current(z.entry.absolutePath);switch(s.key){case"ArrowDown":s.preventDefault(),xe(Math.min(d+1,k));break;case"ArrowUp":s.preventDefault(),xe(Math.max(d-1,0));break;case"Home":s.preventDefault(),xe(0);break;case"End":s.preventDefault(),xe(k);break;case"ArrowRight":s.preventDefault(),J&&!ke?Rt.current(z.entry.absolutePath):J&&d<k&&w[d+1].depth>z.depth&&xe(d+1);break;case"ArrowLeft":{if(s.preventDefault(),J&&ke){Rt.current(z.entry.absolutePath);break}const fn=z?.depth??0;for(let ut=d-1;ut>=0;ut--)if(w[ut].depth<fn){xe(ut);break}break}}},[xe]),it=l.useMemo(()=>pe===null||St.length===0?{segmentsByItem:[],glyphsByItem:[]}:wo(St,_e,Le,pe),[St,_e,Le,pe]),ct=l.useMemo(()=>pe===null||e.length===0?0:pe.originX+nr*pe.indentSize+ce+pe.typeIconSize,[e.length,nr,pe]),{renderStart:hr,renderEnd:mr,lookaheadEnd:pr}=l.useMemo(()=>vo(V.length,$e,ve,et,rt,Le),[V.length,$e,ve,et,rt,Le]),Tt=l.useMemo(()=>pe===null||ct<=0||$e<=0||it.segmentsByItem.length===0?null:h.jsx("div",{className:"pointer-events-none absolute inset-0 z-1","aria-hidden":"true",children:h.jsx("div",{className:"absolute top-0 left-0",style:{width:ct,height:$e},children:h.jsx(en,{segmentsByItem:it.segmentsByItem,glyphsByItem:it.glyphsByItem,itemHeight:_e[0]??_t,width:ct,viewportHeight:$e,scrollPosition:rt,color:$,expandGlyphColor:$,expandGlyphSize:pe.glyphSize,renderStartIndex:hr,renderEndIndex:mr,lookaheadEndIndex:pr})})}),[ct,$e,hr,mr,pr,rt,it,$,pe,_e]),yr=l.useCallback(s=>V[s],[V]),gr=l.useRef(null);l.useLayoutEffect(()=>{const s=gr.current;if(gr.current={items:V,offsets:Le},!Xt||!s||s.items===V)return;const d=Re.current,w=d?.getScrollPosition(),k=typeof w=="number"&&w>=0?w:yt.current,z=oo(s.items,s.offsets,k);if(!z)return;const J=so(z,V,Le);if(J===null||Math.abs(J-k)<1)return;const ke=d?d.scrollTo(J):J;yt.current=ke,Zt(ke)},[V,Le,Xt]);const Ne=C?.columns,Be=C?.scrollBarWidth??mt?.width??Jr,te=l.useMemo(()=>Ne?Vn({measuredWidth:Qe,columns:Ne,scrollBarWidth:Be}):null,[Ne,Qe,Be]),dt=l.useMemo(()=>Ne?Gn(Ne):"",[Ne]),ln=l.useMemo(()=>C?.showFooter&&Ne?Kn(e):[],[C?.showFooter,Ne,e]),He=te?.maxHScroll??0;l.useEffect(()=>{Ve(s=>Nt(s,He))},[He]);const br=l.useCallback(s=>Ve(d=>Nt(d+s,He)),[He]),Sr=l.useMemo(()=>({iconOverrides:D,showExpandIcons:P,showDirectoryIcons:b,showFileIcons:M,useCanvasExpandIcons:N,expandIconSize:O,typeIconSize:Q.typeIconSize,fontSize:Q.fontSize,indentSize:Q.indentSize,highlightStyles:B,expandIconClassName:I,expandIconStyle:R}),[D,P,b,M,N,O,Q,B,I,R]),vr=l.useMemo(()=>h.jsx(ye.VirtualScroll,{ref:Re,itemCount:V.length,getItem:yr,getItemHeight:or,getItemKey:sr,testId:Ut,contentProps:Jt,locale:j,labels:U,viewportSize:typeof ae=="number"?ae:void 0,overscanCount:ve,onScroll:Qt,onRangeChange:er,onScrollAdjust:zt,liveRegion:Bt,className:ee,onWheelHorizontal:se?br:void 0,background:h.jsxs(h.Fragment,{children:[se&&te?h.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-1 h-full overflow-hidden",style:{width:te.nameWidth},"aria-hidden":"true",children:Tt}):Tt,Dt]}),initialScrollIndex:Ht,initialScrollOffset:De,initialScrollAnchor:Wt,callbackThrottleMs:Yt,contentInsets:Gt,scrollBarOptions:mt,behaviorOptions:qt,children:(s,d)=>s?se&&C&&te?h.jsx(Kr,{entry:s.entry,indentLevel:s.indentLevel,positionInSet:s.positionInSet,setSize:s.setSize,rowIndex:d+(C.showHeader??!0?2:1),flatIndex:d,onRowFocus:kt,onRowBlur:It,isSelectedForAria:!!_?.has(s.entry.absolutePath),rowHeight:s.rowHeight,isDirOpen:we,columns:C.columns,numericTemplate:dt,numericTotal:te.numericTotal,nameWidth:te.nameWidth,rowClassName:C.rowClassName,selection:{onEntryClick:m,selectedPath:Fe,currentPath:vt,mode:x,selectedItems:_,onSelectionChange:p},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:gt},visual:Sr},s.entry.absolutePath):h.jsx(tn,{entry:s.entry,indentLevel:s.indentLevel,originX:nt,depth:s.depth,positionInSet:s.positionInSet,setSize:s.setSize,isSelectedForAria:!!_?.has(s.entry.absolutePath),flatIndex:d,isActive:d===ze,registerRowRef:ur,onNavigationKeyDown:fr,onRowFocus:kt,onRowBlur:It,rowHeight:s.rowHeight,entryKindDirectory:Ae,entryKindFile:ne,isDirOpen:we,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:gt},selection:{onEntryClick:m,selectedPath:Fe,currentPath:vt,mode:x,selectedItems:_,onSelectionChange:p},visual:{iconOverrides:D,showExpandIcons:P,showDirectoryIcons:b,showFileIcons:M,useCanvasExpandIcons:N,expandIconSize:O,typeIconSize:Q.typeIconSize,fontSize:Q.fontSize,indentSize:Q.indentSize,highlightStyles:B,entryClassName:re,entryStyle:he,nameClassName:Y,nameStyle:G,directoryNameClassName:Ee,directoryNameStyle:ge,fileNameClassName:o,fileNameStyle:f,expandIconClassName:I,expandIconStyle:R}},s.entry.absolutePath):null}),[V.length,yr,or,sr,Ut,Jt,j,U,Ae,ne,ze,ur,fr,kt,It,ae,ve,Qt,er,zt,Bt,ee,se,br,te,Tt,Dt,Ht,De,Wt,Yt,Gt,mt,qt,C,dt,we,m,Fe,vt,x,_,p,t,gt,Sr,D,P,b,M,N,O,Q,nt,B,re,he,Y,G,Ee,ge,o,f,I,R]);if(!(C&&te))return h.jsxs("div",{ref:Te,className:tr,style:rr,onPointerDownCapture:lt,onMouseDownCapture:lt,children:[Oe.length>0&&!sn&&h.jsx("span",{tabIndex:0,"data-directory-tree-tab-stop":"",style:bo,onFocus:an}),vr]});const cn=C.showHeader??!0,dn=C.showFooter??!1,un={...rr,"--dt-hscroll":`${Ge}px`};return h.jsxs("div",{ref:Te,className:K.twMerge(tr,"dt-grid"),style:un,role:"treegrid","aria-label":v?void 0:E,"aria-labelledby":v,"aria-multiselectable":x==="multiple"?!0:void 0,"aria-busy":i?!0:void 0,"aria-rowcount":V.length+(C.showHeader??!0?1:0),onPointerDownCapture:lt,onMouseDownCapture:lt,children:[cn&&h.jsx("div",{role:"rowgroup",children:h.jsx(Hn,{columns:C.columns,numericTemplate:dt,numericTotal:te.numericTotal,nameWidth:te.nameWidth,scrollBarWidth:Be,className:C.headerClassName})}),h.jsx("div",{ref:Me,className:"dt-grid-body",children:vr}),He>0&&h.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[h.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:te.nameWidth},"aria-hidden":"true"}),h.jsx(ye.ScrollBar,{horizontal:!0,contentSize:te.numericTotal,viewportSize:te.numericVisible,scrollPosition:Ge,scrollBarWidth:Be,locale:j,labels:U,onScroll:s=>{const d=typeof s=="function"?s(Ge):s,w=Nt(d,He);return Ve(w),w}}),h.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Be},"aria-hidden":"true"})]}),dn&&h.jsx("div",{role:"rowgroup",children:h.jsx(Wn,{columns:C.columns,numericTemplate:dt,numericTotal:te.numericTotal,nameWidth:te.nameWidth,scrollBarWidth:Be,allEntries:ln,className:C.footerClassName})})]})},Ro=({initialExpanded:e=new Set,storageKey:t}={})=>{const[r,n]=l.useTransition(),[a,i]=l.useState(()=>{if(typeof window<"u"&&t)try{const y=window.localStorage.getItem(t);if(y){const E=JSON.parse(y);return new Set(E)}}catch(y){console.error("[useDirectoryTreeState] Error reading from localStorage",y)}return e}),c=l.useCallback(y=>{n(()=>{i(E=>{const v=new Set(E);return y(v),v})})},[]),u=l.useCallback((y,E)=>{c(v=>{for(const $ of y)E(v,$)})},[c]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(a)))}catch(y){console.warn(`Error setting localStorage key "${t}":`,y)}},[a,t]);const m=l.useCallback(y=>{u([y],(E,v)=>{E.has(v)?E.delete(v):E.add(v)})},[u]),S=l.useCallback(y=>{u([y],(E,v)=>{E.add(v)})},[u]),T=l.useCallback(y=>{u([y],(E,v)=>{E.delete(v)})},[u]),x=l.useCallback(y=>{u(y,(E,v)=>{E.delete(v)})},[u]),_=l.useCallback(y=>{u(y,(E,v)=>{E.add(v)})},[u]),p=l.useCallback(()=>{c(y=>{y.clear()})},[c]),g=l.useCallback(y=>a.has(y),[a]);return{expanded:a,toggle:m,expand:S,collapse:T,collapseMultiple:x,expandMultiple:_,collapseAll:p,isExpanded:g,isPending:r}};exports.DIRECTORY_TREE_LABEL_CATALOGS=Zr;exports.DIRECTORY_TREE_LABEL_KEYS=Lt;exports.DirectoryTree=Eo;exports.EXPAND_ICON_STYLE_PROPERTIES=Hr;exports.FILE_ICON_PAIRS=Rn;exports.MARK_PAIRS=Lr;exports.ROW_STYLE_PROPERTIES=Br;exports.directoryTreeClasses=A;exports.resolveDirectoryTreeLabels=Qr;exports.useDirectoryTreeState=Ro;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),ce=require("@aiquants/virtualscroll"),s=require("react"),B=require("tailwind-merge"),ne=require("@phosphor-icons/react");function ar(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ae=ar(s);function lr({title:e,titleId:t,...n},r){return ae.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?ae.createElement("title",{id:t},e):null,ae.createElement("path",{fillRule:"evenodd",d:"M12.53 16.28a.75.75 0 0 1-1.06 0l-7.5-7.5a.75.75 0 0 1 1.06-1.06L12 14.69l6.97-6.97a.75.75 0 1 1 1.06 1.06l-7.5 7.5Z",clipRule:"evenodd"}))}const ir=ae.forwardRef(lr);function cr({title:e,titleId:t,...n},r){return ae.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?ae.createElement("title",{id:t},e):null,ae.createElement("path",{fillRule:"evenodd",d:"M16.28 11.47a.75.75 0 0 1 0 1.06l-7.5 7.5a.75.75 0 0 1-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 0 1 1.06-1.06l7.5 7.5Z",clipRule:"evenodd"}))}const dr=ae.forwardRef(cr);function ur({title:e,titleId:t,...n},r){return ae.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?ae.createElement("title",{id:t},e):null,ae.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const fr=ae.forwardRef(ur),kn={icon:{light:"#6a7282",dark:"#99a1af"},iconSelected:{light:"#1447e6",dark:"#51a2ff"},checkedRing:{light:"#155dfc",dark:"#51a2ff"}},hr={markdown:{light:"#0084d1",dark:"#00bcff"},pdf:{light:"#e7000b",dark:"#ff6467"},spreadsheet:{light:"#007a55",dark:"#00d492"},csv:{light:"#007a55",dark:"#00d492"},document:{light:"#155dfc",dark:"#51a2ff"},presentation:{light:"#ca3500",dark:"#ff8904"},image:{light:"#00786f",dark:"#00d5be"},audio:{light:"#e60076",dark:"#fb64b6"},video:{light:"#7f22fe",dark:"#a684ff"},archive:{light:"#bb4d00",dark:"#ffb900"},code:{light:"#9810fa",dark:"#c27aff"},text:kn.icon},Nn="#71829b",re={rowHover:"hover:bg-[color:light-dark(#f3f4f6,#1e2939)]",rowSelected:"bg-[color:light-dark(#eff6ff,#162456)]",checkedRing:"inset-ring-1 inset-ring-[color:light-dark(#155dfc,#51a2ff)]",name:"text-[color:light-dark(#364153,#e5e7eb)]",nameSelected:"text-[color:light-dark(#193cb8,#bedbff)]",gridEdge:"text-[color:light-dark(#4a5565,#d1d5dc)]",icon:"text-[color:light-dark(#6a7282,#99a1af)]",iconSelected:"text-[color:light-dark(#1447e6,#51a2ff)]"},se={markdown:"text-[color:light-dark(#0084d1,#00bcff)]",pdf:"text-[color:light-dark(#e7000b,#ff6467)]",spreadsheet:"text-[color:light-dark(#007a55,#00d492)]",csv:"text-[color:light-dark(#007a55,#00d492)]",document:"text-[color:light-dark(#155dfc,#51a2ff)]",presentation:"text-[color:light-dark(#ca3500,#ff8904)]",image:"text-[color:light-dark(#00786f,#00d5be)]",audio:"text-[color:light-dark(#e60076,#fb64b6)]",video:"text-[color:light-dark(#7f22fe,#a684ff)]",archive:"text-[color:light-dark(#bb4d00,#ffb900)]",code:"text-[color:light-dark(#9810fa,#c27aff)]",text:"text-[color:light-dark(#6a7282,#99a1af)]"},Ln="text-[length:var(--dt-font-size-body,0.8125rem)]",mr=`${Ln} leading-[max(var(--dt-line-height-body,1.25rem),1.5em)]`,Ct=44,pr=12,yr=8,oe=14,gr=14,Pn=e=>e===void 0?void 0:{fontSize:typeof e=="number"?`${e}px`:e},q=e=>({width:e,height:e}),P={container:"directory-tree-container relative h-full overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"cursor-progress",entry:`directory-tree-entry flex items-center cursor-pointer relative select-none ${mr}`,entryHover:`directory-tree-entry--hover ${re.rowHover}`,entrySelected:`directory-tree-entry--selected ${re.rowSelected}`,entryItemSelected:`directory-tree-entry--item-selected ${re.rowSelected} ${re.checkedRing}`,expandIcon:`directory-tree-expand-icon flex-shrink-0 flex items-center justify-center ${re.icon}`,expandIconSelected:`directory-tree-expand-icon--selected ${re.iconSelected}`,typeIcon:`directory-tree-type-icon flex-shrink-0 flex items-center justify-center ${re.icon}`,typeIconSelected:`directory-tree-type-icon--selected ${re.iconSelected}`,name:`directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 ${Ln} font-normal ${re.name}`,nameDirectory:"directory-tree-name--directory font-medium",nameSelected:`directory-tree-name--selected font-semibold ${re.nameSelected}`},Mt=e=>{const t=e.slice(e.lastIndexOf("/")+1),n=t.lastIndexOf(".");return n<=0?"":t.slice(n+1).toLowerCase()},br=/^[a-z][a-z\d+.-]*:\/\//i,bn=e=>Mt(br.test(e)?e.split(/[?#]/,1)[0]:e),Tn=e=>Mt(e.name)||bn(e.relativePath)||bn(e.absolutePath),On=({isDirectory:e,isExpanded:t,showExpandIcons:n,useCanvasExpandIcons:r,expandIconSize:a})=>{const i=a?{width:a,height:a}:void 0,l=a?"":"h-4 w-4";return!(n&&e)||r?d.jsx("span",{className:l,style:i,"aria-hidden":"true"}):t?d.jsx(ir,{className:l,style:i}):d.jsx(dr,{className:l,style:i})},Nt=(e,t)=>{if(e==null||typeof e=="boolean")return null;if(typeof e=="function")return console.warn(`[DirectoryTree] Function returned by renderer for "${t}". Return a node.`),null;if(typeof e=="object"){if("then"in e)return console.warn(`[DirectoryTree] Promise returned for "${t}". Not supported.`),null;if(Array.isArray(e)){const r=e.map(a=>Nt(a,t)).filter(Boolean);return r.length?r:null}const n=e.type;if(n&&n.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},Sr={markdown:e=>d.jsx(ne.FileMd,{className:se.markdown,style:q(e)}),pdf:e=>d.jsx(ne.FilePdf,{className:se.pdf,style:q(e)}),spreadsheet:e=>d.jsx(ne.FileXls,{className:se.spreadsheet,style:q(e)}),csv:e=>d.jsx(ne.FileCsv,{className:se.csv,style:q(e)}),document:e=>d.jsx(ne.FileDoc,{className:se.document,style:q(e)}),presentation:e=>d.jsx(ne.FilePpt,{className:se.presentation,style:q(e)}),image:e=>d.jsx(ne.FileImage,{className:se.image,style:q(e)}),audio:e=>d.jsx(ne.FileAudio,{className:se.audio,style:q(e)}),video:e=>d.jsx(ne.FileVideo,{className:se.video,style:q(e)}),archive:e=>d.jsx(ne.FileZip,{className:se.archive,style:q(e)}),code:e=>d.jsx(ne.FileCode,{className:se.code,style:q(e)}),text:e=>d.jsx(ne.FileText,{className:se.text,style:q(e)})},wr={markdown:["md","markdown","mdx"],pdf:["pdf"],spreadsheet:["xls","xlsx","xlsm","xlsb","ods"],csv:["csv","tsv"],document:["doc","docx","rtf","odt"],presentation:["ppt","pptx","odp"],image:["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff","avif"],audio:["mp3","wav","ogg","m4a","flac","aac","wma"],video:["mp4","webm","mov","avi","mkv","wmv","flv"],archive:["zip","tar","gz","7z","rar","tgz","bz2"],code:["js","mjs","cjs","ts","tsx","jsx","json","html","htm","css","scss","py","go","rs","c","cpp","h","hpp","sh","bash","yaml","yml","sql","xml","toml"],text:["txt","log"]},vr=new Map(Object.entries(wr).flatMap(([e,t])=>t.map(n=>[n,e]))),xr=new Set(["","application/octet-stream","binary/octet-stream","text/plain","application/x-empty"]),Er=e=>(e??"").split(";",1)[0].trim().toLowerCase(),Ir=e=>{if(e==="text/markdown"||e==="text/x-markdown")return"markdown";if(e==="application/pdf")return"pdf";if(e.includes("excel")||e.includes("spreadsheet"))return"spreadsheet";if(e==="text/csv"||e==="text/tab-separated-values")return"csv";if(e.includes("word")||e.includes("google-apps.document")||e==="application/rtf")return"document";if(e.includes("powerpoint")||e.includes("presentation"))return"presentation";if(e.startsWith("image/"))return"image";if(e.startsWith("audio/"))return"audio";if(e.startsWith("video/"))return"video";if(e.includes("zip")||e.includes("tar")||e.includes("compressed")||e.includes("archive"))return"archive";if(e==="application/json"||e.includes("javascript")||e.includes("typescript")||e.includes("xml")||e.startsWith("text/html")||e.startsWith("text/css")||e.includes("x-python")||e.includes("x-sh")||e.includes("x-go")||e.includes("x-rust"))return"code";if(e.startsWith("text/"))return"text"},Rr=(e,t,n,r)=>{const a=Er(e),i=Ir(a),l=vr.get((t||(n?Mt(n):"")).toLowerCase()),f=(xr.has(a)?[l,i]:[i,l]).find(g=>g!==void 0);return f===void 0?d.jsx(ne.FileIcon,{className:re.icon,style:q(r)}):Sr[f](r)},Mn=(e,t,n)=>{const{entry:r,isDirectory:a,isExpanded:i,extension:l,mimeType:u}=e;let f;const g=u||r.mimeType;return r.icon!==void 0?f=r.icon:a?f=i&&t?.directoryExpanded||t?.directory||d.jsx(fr,{style:q(n)}):l&&t?.fileByExtension?.[l]?f=t.fileByExtension[l]:f=t?.file||Rr(g,l,r.name,n),Nt(typeof f=="function"?f(e):f,r.absolutePath)},Cr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_n=e=>{if(!e)return;const t=Object.entries(e).filter(([,n])=>n!=null);if(t.length!==0)return Object.fromEntries(t.map(([n,r])=>[`data-${Cr(n)}`,String(r)]))},jn=["color","background","backgroundColor","backgroundImage","backgroundPosition","backgroundSize","backgroundRepeat","backgroundClip","backgroundOrigin","backgroundAttachment","backgroundBlendMode","opacity","boxShadow","filter","backdropFilter","mixBlendMode","borderColor","borderRadius","outline","outlineColor","outlineStyle","outlineWidth","outlineOffset","textShadow","accentColor","caretColor","cursor","fontFamily","fontSize","fontStyle","fontWeight","fontVariant","fontFeatureSettings","fontVariationSettings","fontKerning","letterSpacing","lineHeight","textDecoration","textDecorationColor","textDecorationLine","textDecorationStyle","textDecorationThickness","textUnderlineOffset","textTransform"],An=["color","opacity"],kr="the row's box belongs to the tree (height: visual.itemHeight, indent: visual.indentSize, icons: visual.typeIconSize, text size: visual.fontSize)",Nr=new Set(jn),Lr=new Set(An),Sn=(e,t)=>{const n=t===void 0?e.option:`${e.option}.${t}`;return e.absolutePath===void 0?n:`${n} of "${e.absolutePath}"`},Dn=(e,t,n,r)=>{if(e!==void 0){if(typeof e!="object"||e===null)throw new RangeError(`${Sn(n,void 0)} must be an object of CSS properties or undefined, got ${e===null?"null":typeof e}.`);for(const[a,i]of Object.entries(e))if(i!==void 0&&!t.has(a))throw new RangeError(`${Sn(n,a)} cannot be set: ${kr}, so ${r}.`)}},He=(e,t)=>Dn(e,Nr,t,"a row style accepts only paint and text properties (ROW_STYLE_PROPERTIES)"),Pr=(e,t)=>Dn(e,Lr,t,"the expand icon style accepts only the glyph's colour and opacity (EXPAND_ICON_STYLE_PROPERTIES), and the 14 px expand box is the tree's"),Tr=500,zn=({entry:e,isDirectory:t,isExpanded:n,isItemSelected:r,selectionMode:a,onSelectionChange:i,onEntryClick:l,toggleDirectory:u,onToggleDirectoryRecursive:f})=>{const g=s.useRef(null);return s.useEffect(()=>()=>{g.current&&window.clearTimeout(g.current)},[]),s.useCallback(R=>{R.stopPropagation(),a!=="none"&&!t&&i&&i(e,!r);let x=!1;l({entry:e,isDirectory:t,isExpanded:n,preventDefault:()=>{x=!0}}),!(!t||x)&&(g.current?(window.clearTimeout(g.current),g.current=null,f(e)):g.current=window.setTimeout(()=>{u(e.absolutePath),g.current=null},Tr))},[t,e,n,f,u,l,a,i,r])},Fn=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",wn=(e,t)=>e.children!==void 0&&t(e.absolutePath),$n=(e,t)=>({width:e,gridTemplateColumns:t}),Bn=s.memo(({entry:e,indentLevel:t,positionInSet:n,setSize:r,rowIndex:a,flatIndex:i,onRowFocus:l,onRowBlur:u,isSelectedForAria:f,rowHeight:g,isDirOpen:R,columns:x,numericTemplate:C,numericTotal:m,nameWidth:p,rowClassName:h,selection:{onEntryClick:w,selectedPath:S,currentPath:j,mode:I="none",selectedItems:k,onSelectionChange:y},expansion:{toggleDirectory:T,onToggleDirectoryRecursive:O},visual:{iconOverrides:L,showExpandIcons:le=!0,showDirectoryIcons:X=!0,showFileIcons:D=!0,useCanvasExpandIcons:K=!1,expandIconSize:ge,typeIconSize:F,fontSize:de,indentSize:be,highlightStyles:U,expandIconClassName:J,expandIconStyle:Oe}})=>{He(e.style,{option:"entry.style",absolutePath:e.absolutePath});const[Ie,Re]=s.useState(!1),M=e.children!==void 0,Q=M&&R(e.absolutePath),z=e.absolutePath===S,We=e.absolutePath===j,E=!M&&!!k?.has(e.absolutePath),Me=M?void 0:Tn(e),Se=zn({entry:e,isDirectory:M,isExpanded:Q,isItemSelected:E,selectionMode:I,onSelectionChange:y,onEntryClick:w,toggleDirectory:T,onToggleDirectoryRecursive:O}),Ce=Ie?U?.hoverClassName!==void 0?U.hoverClassName:P.entryHover:"",_e=(()=>{if(M){if(z)return U?.directorySelectedClassName!==void 0?U.directorySelectedClassName:P.entrySelected}else if(z||E)return U?.itemSelectedClassName!==void 0?U.itemSelectedClassName:B.twMerge(z&&P.entrySelected,E&&P.entryItemSelected);return""})(),N=typeof h=="function"?h(e):h,ue=B.twMerge("dt-grid-row cursor-pointer select-none",Ce,_e,N,e.className),H=B.twMerge(P.expandIcon,J,(z||E)&&P.expandIconSelected),je=B.twMerge(P.typeIcon,(z||E)&&P.typeIconSelected),Z=B.twMerge("dt-grid-name-label ml-1",re.name,M&&P.nameDirectory,(z||E)&&P.nameSelected),Y=On({isDirectory:M,isExpanded:Q,showExpandIcons:le,useCanvasExpandIcons:K,expandIconSize:ge}),ee=(M?X:D)?Mn({entry:e,isDirectory:M,isExpanded:Q,isSelected:z,isItemSelected:E,extension:Me,mimeType:e.mimeType},L,F):null,we={indentLevel:t,isDirectory:M,isExpanded:Q},[he,...ke]=x,me=he?.render?he.render(e,we):e.label??e.name,Ke={...Ie?U?.hoverStyle:{},...M&&z?U?.directorySelectedStyle:{},...!M&&(z||E)?U?.itemSelectedStyle:{}};return d.jsxs("div",{className:ue,style:{...Ke,...e.style,height:g},role:"row","aria-expanded":M?Q:void 0,"aria-level":t+1,"aria-posinset":n,"aria-setsize":r,"aria-rowindex":a,"aria-selected":I==="none"?void 0:f,"aria-current":We?"page":void 0,..._n(e.data),"data-entry-type":M?"directory":"file","data-entry-expanded":M?String(Q):void 0,"data-entry-selected":z?"true":void 0,"data-entry-item-selected":E?"true":void 0,onClick:Se,onMouseEnter:()=>Re(!0),onMouseLeave:()=>Re(!1),onFocus:A=>l(i,e.absolutePath,A.currentTarget),onBlur:A=>u(e.absolutePath,A.currentTarget),onKeyDown:A=>{if(A.key==="Enter"){if(A.repeat){A.preventDefault();return}Se(A)}},tabIndex:0,children:[d.jsxs("div",{className:B.twMerge("dt-grid-name-cell",he?.className),role:"gridcell",style:{width:p,paddingLeft:Math.max(0,t*be)},children:[(le||K)&&d.jsx("span",{className:H,style:{...Oe,width:oe,height:oe},children:Y}),(M?X:D)&&d.jsx("span",{className:je,style:{width:F,height:F},children:ee}),d.jsx("span",{className:Z,style:Pn(de),children:me})]}),ke.length>0&&d.jsx("div",{className:"dt-grid-numeric-viewport",children:d.jsx("div",{className:"dt-grid-numeric-track",style:$n(m,C),children:ke.map(A=>d.jsx("div",{className:B.twMerge("dt-grid-cell",Fn(A.align),A.className),role:"gridcell",children:A.render?A.render(e,we):null},A.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const n=wn(e.entry,e.isDirOpen),r=wn(t.entry,t.isDirOpen);return e.indentLevel===t.indentLevel&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.rowIndex===t.rowIndex&&e.flatIndex===t.flatIndex&&e.isSelectedForAria===t.isSelectedForAria&&e.rowHeight===t.rowHeight&&n===r&&e.columns===t.columns&&e.numericTemplate===t.numericTemplate&&e.numericTotal===t.numericTotal&&e.nameWidth===t.nameWidth&&e.rowClassName===t.rowClassName&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.currentPath===t.selection.currentPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});Bn.displayName="DirectoryTreeGridRow";const Hn=({kind:e,columns:t,numericTemplate:n,numericTotal:r,nameWidth:a,scrollBarWidth:i,className:l,nameContent:u,renderCell:f})=>{const[,...g]=t,R=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",x=e==="header"?"dt-grid-header":"dt-grid-footer",C=e==="header"?"columnheader":"gridcell";return d.jsxs("div",{className:B.twMerge(x,re.gridEdge,l),role:"row",children:[d.jsx("div",{className:B.twMerge(R,"px-1",t[0]?.className),role:C,style:{width:a},children:u}),g.length>0&&d.jsx("div",{className:"dt-grid-numeric-viewport",children:d.jsx("div",{className:"dt-grid-numeric-track",style:$n(r,n),children:g.map(m=>d.jsx("div",{className:B.twMerge("dt-grid-cell",Fn(m.align),m.className),role:C,children:f(m)},m.key))})}),d.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:i},"aria-hidden":"true"})]})},Or=({columns:e,className:t,...n})=>d.jsx(Hn,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:r=>r.header??null,...n}),vn=(e,t)=>typeof e=="function"?e(t):e??null,Mr=({columns:e,allEntries:t,className:n,...r})=>d.jsx(Hn,{kind:"footer",columns:e,className:n,nameContent:vn(e[0]?.footer,t),renderCell:a=>vn(a.footer,t),...r}),_r=240,Wn=96,Kn=12,Lt=(e,t)=>{const n=e?.width;return typeof n=="number"&&Number.isFinite(n)&&n>0?n:t},jr=e=>e.slice(1).map(t=>`${Lt(t,Wn)}px`).join(" "),Ar=({measuredWidth:e,columns:t,scrollBarWidth:n=Kn})=>{const r=Lt(t[0],_r),a=t.slice(1).reduce((f,g)=>f+Lt(g,Wn),0),i=Number.isFinite(e)&&e>0?e:0,l=Math.max(0,i-r-Math.max(0,n)),u=Math.max(0,a-l);return{nameWidth:r,numericTotal:a,numericVisible:l,maxHScroll:u}},kt=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,Dr=e=>{const t=[],n=r=>{for(const a of r)t.push(a),a.children&&a.children.length>0&&n(a.children)};return n(e),t},Yn=["entryKindDirectory","entryKindFile"],Pt=[...ce.VIRTUAL_SCROLL_LABEL_KEYS,...Yn],Tt=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),Gn=Object.freeze({en:Object.freeze({...ce.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Tt.en}),ja:Object.freeze({...ce.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Tt.ja})}),xn=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,zr=e=>{const t={};let n=!1;for(const r of ce.VIRTUAL_SCROLL_LABEL_KEYS){const a=Object.hasOwn(e,r)?e[r]:void 0;a!==void 0&&(t[r]=a,n=!0)}return n?t:void 0},Vn=(e,t)=>{const n=ce.resolveVirtualScrollLocale(e);if(t===void 0)return Gn[n];if(t===null||typeof t!="object")throw new RangeError(`[directory-tree] labels must be an object; got ${xn(t)}`);const r=Object.getPrototypeOf(t);if(r!==Object.prototype&&r!==null)throw new RangeError(`[directory-tree] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);for(const l of Object.keys(t))if(!Pt.includes(l))throw new RangeError(`[directory-tree] labels.${l} is not a known label key; expected one of ${Pt.join(", ")}`);const i={...ce.resolveVirtualScrollLabels(n,zr(t)),...Tt[n]};for(const l of Yn){const u=Object.hasOwn(t,l)?t[l]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[directory-tree] labels.${l} must be a non-blank string; got ${xn(u)}`);i[l]=u}}return Object.freeze(i)},Fr=e=>{const t={};for(const n of ce.VIRTUAL_SCROLL_LABEL_KEYS)t[n]=e[n];return Object.freeze(t)},$r=()=>{let e=null;return{mark:t=>{const n=t.composedPath();e=n,setTimeout(()=>{e===n&&(e=null)},0)},landedOn:t=>e?.includes(t)===!0}},Je=e=>typeof e=="string"?JSON.stringify(e):String(e),Ot=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t)||t<=0)throw new RangeError(`[directory-tree] visual.${e} must be a finite number greater than 0 (px); got ${Je(t)}.`);return t},Br=e=>{if(typeof e=="string"&&e.trim()!==""||typeof e=="number"&&Number.isFinite(e)&&e>0)return e;throw new RangeError(`[directory-tree] visual.fontSize must be a finite number greater than 0 (px) or a CSS font size that is not blank; got ${Je(e)}.`)},Hr=({indentSize:e,typeIconSize:t,fontSize:n})=>({indentSize:e===void 0?pr:Ot("indentSize",e),typeIconSize:t===void 0?gr:Ot("typeIconSize",t),fontSize:n===void 0?void 0:Br(n)}),Wr=({indentSize:e,removeRootIndent:t,hasExpandBox:n})=>t?Math.max(0,e-(n?oe:0)):0,Kr=(e,t,n)=>{if(typeof e!="function")return Ot("itemHeight",e);const r=e(t,n);if(typeof r!="number"||!Number.isFinite(r)||r<=0)throw new RangeError(`[directory-tree] visual.itemHeight returned ${Je(r)} for ${JSON.stringify(t.absolutePath)} (row ${n}); it must return a finite number greater than 0 (px).`);return r},Yr=(e,t,n)=>{const r=t===void 0?yr:t;if(typeof r!="number"||!Number.isFinite(r)||r<=0||r>oe)throw new RangeError(`[directory-tree] visual.expandIconSize must be a finite number greater than 0 and at most ${oe} (the expand box, px) while tree lines are drawn; got ${Je(r)}.`);const{indentSize:a,typeIconSize:i}=e,l=r/2,u=oe+i-r/2;if(a<l||a>u)throw new RangeError(`[directory-tree] visual.indentSize ${Je(a)} does not fit the tree lines: with typeIconSize ${i} and an expand glyph of ${r} px it must be from ${l} (half the glyph) to ${u} (the ${oe} px expand box + typeIconSize − half the glyph).`);return{indentSize:a,typeIconSize:i,glyphSize:r,originX:n}},Gr=({indentSize:e,typeIconSize:t,glyphSize:n})=>Math.min(Math.max(oe+t/2-e,n/2),oe-n/2),Vr=(e,t)=>{const n=e.length-1;if(n<=0)return 0;let r=0,a=n-1,i=0;for(;r<=a;){const l=r+a>>>1;e[l]<=t?(i=l,r=l+1):a=l-1}return i},Xr=(e,t,n)=>{if(n<=0||e.length===0||t.length!==e.length+1)return null;const r=Vr(t,n),a=e[r];return a?{path:a.entry.absolutePath,offsetInViewport:n-t[r]}:null},Ur=(e,t,n)=>{if(t.length===0||n.length!==t.length+1)return null;for(let r=0;r<t.length;r++)if(t[r].entry.absolutePath===e.path)return Math.max(0,n[r]+e.offsetInViewport);return null},Jr=(e,t,n)=>{const r=[];for(let a=t;a<n;a++){const i=e[a];if(!(!i||i.length===0))for(const l of i)r.push(l)}return r},Zr=(e,t,n)=>{const r=[];for(let a=t;a<n;a++){const i=e[a];if(!(!i||i.length===0))for(const l of i)r.push(l)}return r},qr=(e,t,n,r)=>{const a=Math.max(1,Math.floor(t*r)),i=Math.max(1,Math.floor(n*r));(e.width!==a||e.height!==i)&&(e.width=a,e.height=i);const l=e.style;l.width!==`${t}px`&&(l.width=`${t}px`),l.height!==`${n}px`&&(l.height=`${n}px`)},Qr=(e,t,n)=>{e.lineWidth=n,e.beginPath();for(const r of t)e.moveTo(r.x1,r.y1),e.lineTo(r.x2,r.y2);e.stroke()},eo=(e,t,n,r)=>{if(t.length===0)return;const a=e.strokeStyle,i=e.lineWidth,l=e.lineCap,u=e.lineJoin;e.strokeStyle=n,e.lineCap="round",e.lineJoin="round";for(const f of t){const g=r??f.size,R=Math.max(0,g/2),x=Math.max(1,Math.round(g*.08)),C=Math.max(1,Math.round(g*.14)),m=Math.max(0,R-x*.8),p=Math.max(0,m*.55);e.lineWidth=x,e.beginPath(),e.arc(f.centerX,f.centerY,Math.max(0,R-x*.3),0,Math.PI*2),e.stroke(),e.lineWidth=C,e.beginPath(),e.moveTo(f.centerX-p,f.centerY),e.lineTo(f.centerX+p,f.centerY),e.stroke(),f.isExpanded||(e.beginPath(),e.moveTo(f.centerX,f.centerY-p),e.lineTo(f.centerX,f.centerY+p),e.stroke())}e.strokeStyle=a,e.lineWidth=i,e.lineCap=l,e.lineJoin=u},Xn=s.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:n,width:r,viewportHeight:a,scrollPosition:i,color:l=Nn,strokeWidth:u=1,renderStartIndex:f,renderEndIndex:g,lookaheadEndIndex:R,devicePixelRatio:x,expandGlyphColor:C,expandGlyphSize:m})=>{const p=s.useRef(null),h=s.useRef(null),w=s.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:n,width:r,viewportHeight:a,scrollPosition:i,color:l,strokeWidth:u,renderStartIndex:f,renderEndIndex:g,lookaheadEndIndex:R,devicePixelRatio:x,expandGlyphColor:C,expandGlyphSize:m}),S=s.useCallback(()=>{h.current=null;const I=p.current;if(!I)return;const k=I.getContext("2d");if(!k)return;const y=w.current;if(y.width<=0||y.viewportHeight<=0){k.clearRect(0,0,I.width,I.height);return}const T=Number.isFinite(y.devicePixelRatio??NaN)?y.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;qr(I,y.width,y.viewportHeight,T);const O=y.segmentsByItem.length,L=typeof y.renderStartIndex=="number"&&Number.isFinite(y.renderStartIndex)?Math.max(0,Math.floor(y.renderStartIndex)):Math.max(0,Math.floor(y.scrollPosition/y.itemHeight)),le=Math.min(O,Math.ceil((y.scrollPosition+y.viewportHeight)/y.itemHeight)),X=(()=>{if(typeof y.renderEndIndex=="number"&&Number.isFinite(y.renderEndIndex)){const F=Math.floor(y.renderEndIndex);return Math.max(Math.min(O,F+1),L)}return Math.max(le,L)})(),D=(()=>{if(typeof y.lookaheadEndIndex=="number"&&Number.isFinite(y.lookaheadEndIndex)){const F=Math.floor(y.lookaheadEndIndex),de=Math.min(O,F+1);return Math.max(de,X)}return Math.max(le,X)})(),K=Jr(y.segmentsByItem,L,D),ge=Zr(y.glyphsByItem,L,D);k.save(),k.scale(T,T),k.clearRect(0,0,y.width,y.viewportHeight),k.translate(0,-y.scrollPosition),k.strokeStyle=y.color,Qr(k,K,y.strokeWidth),eo(k,ge,y.expandGlyphColor??y.color,y.expandGlyphSize),k.restore()},[]),j=s.useCallback(()=>{h.current===null&&(h.current=window.requestAnimationFrame(S))},[S]);return s.useEffect(()=>{w.current={segmentsByItem:e,glyphsByItem:t,itemHeight:n,width:r,viewportHeight:a,scrollPosition:i,color:l,strokeWidth:u,renderStartIndex:f,renderEndIndex:g,lookaheadEndIndex:R,devicePixelRatio:x,expandGlyphColor:C,expandGlyphSize:m},j()},[e,t,n,r,a,i,l,u,f,g,R,x,C,m,j]),s.useEffect(()=>()=>{h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null)},[]),d.jsx("canvas",{ref:p,className:"pointer-events-none absolute top-0 left-0 z-0"})});Xn.displayName="TreeLineCanvas";const to=e=>{const t=new Map;for(let n=0;n<e.length;n++){const r=e[n].entry.absolutePath;t.has(r)||t.set(r,n)}return t},En=(e,t)=>e.selectedPath===t?e:{selectedPath:t,selectionGeneration:e.selectionGeneration+1,anchor:e.anchor},no=(e,t)=>({...e,anchor:{path:t,selectionGeneration:e.selectionGeneration,focused:!0}}),ro=(e,t)=>{const{anchor:n,selectionGeneration:r,selectedPath:a}=t;if(n!==null&&(n.focused||n.selectionGeneration===r)){const i=e.get(n.path);if(i!==void 0)return i}if(a!==null){const i=e.get(a);if(i!==void 0)return i}return 0},oo={msOverflowStyle:"none",scrollbarWidth:"none"},so=()=>{let e=document.getElementById("directory-tree-webkit-scrollbar-hide");e||(e=document.createElement("style"),e.id="directory-tree-webkit-scrollbar-hide",e.textContent=".directory-tree-container::-webkit-scrollbar { display: none; }",document.head.appendChild(e))},ao=()=>()=>{},lo=()=>!0,io=()=>!1,co=e=>{const t=s.useRef(null),n=t.current;return n!==null&&ce.VIRTUAL_SCROLL_LABEL_KEYS.every(r=>n[r]===e[r])?n:(t.current=e,e)},In=new Set(["top","bottom","center","nearest"]),Rn=e=>{const t=e?.align;if(t===void 0)return"top";if(!In.has(t))throw new RangeError(`[directory-tree] Unsupported scroll alignment ${JSON.stringify(t)}; expected one of ${[...In].join(", ")}.`);return t},uo={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},fo=(e,t,n,r,a)=>{const i=[],l=[];let u=0;const f=(g,R,x)=>{const C=a?[...g].sort(a):g;for(let m=0;m<C.length;m++){const p=C[m],h=m===C.length-1,w=[...x,h],S=p.children!==void 0,j=S&&t(p.absolutePath,p.relativePath);let I=R,k=x;r&&(I=R-1,k=x.slice(1)),i.push({entry:p,indentLevel:I,depth:R,positionInSet:m+1,setSize:C.length}),n&&(I>u&&(u=I),l.push({id:p.absolutePath,name:p.name,absolutePath:p.absolutePath,indentLevel:I,isLastChild:h,isDirectory:S,isExpanded:j,ancestorIsLast:[...k],hideLines:r&&R===0})),S&&j&&p.children&&f(p.children,R+1,w)}};return f(e,0,[]),{flatItems:i,lineItems:l,maxIndent:u}},Cn=(e,t)=>{const n=e.length-1;if(n<=0)return 0;let r=0,a=n-1,i=0;for(;r<=a;){const l=r+a>>>1;e[l]<=t?(i=l,r=l+1):a=l-1}return i},ho=(e,t,n,r,a,i)=>{const l=r?.renderStart??Math.max(0,Cn(i,a)),u=t>0?Cn(i,a+t)+n:l+n,f=e>0?Math.min(e-1,Math.max(l,u)):l,g=r?.renderEnd??f,R=e>0?Math.min(e-1,g+n):g;return{renderStart:l,renderEnd:g,lookaheadEnd:R}},mo=(e,t,n,r)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const{indentSize:a,typeIconSize:i,glyphSize:l,originX:u}=r,f=Array.from({length:e.length},()=>[]),g=Array.from({length:e.length},()=>[]),R=u+Gr(r),x=m=>m*a+R,C=l/2+2;for(let m=0;m<e.length;m++){const p=e[m],h=t[m]??0,w=n[m]??0,S=w+h/2,j=e[m+1],I=S+i/2,k=w+h,y=j!==void 0&&j.indentLevel===p.indentLevel+1&&I<k?{key:`${p.id}-connector-children`,x1:x(j.indentLevel),y1:I,x2:x(j.indentLevel),y2:k,itemIndex:m}:null;if(p.hideLines){y!==null&&(f[m]=[y]);continue}const T=[];for(let L=0;L<p.indentLevel;L++){if(p.ancestorIsLast[L]??!1)continue;let X=!1;for(let D=m;D<e.length;D++){const K=e[D];if(K.indentLevel>L&&K.ancestorIsLast.length>L&&!K.ancestorIsLast[L]){X=!0;break}if(D>m&&K.indentLevel===L)break}if(X){const D=x(L);T.push({key:`${p.id}-ancestor-${L}`,x1:D,y1:w,x2:D,y2:w+h,itemIndex:m})}}const O=x(p.indentLevel);m>0&&T.push({key:`${p.id}-connector-top`,x1:O,y1:w,x2:O,y2:p.isDirectory?S-C:S,itemIndex:m}),!p.isDirectory&&p.isLastChild&&T.push({key:`${p.id}-connector-horizontal`,x1:O,y1:S,x2:u+p.indentLevel*a+oe,y2:S,itemIndex:m}),p.isLastChild||(p.isDirectory?T.push({key:`${p.id}-connector-bottom`,x1:O,y1:S+C,x2:O,y2:w+h,itemIndex:m}):T.push({key:`${p.id}-connector-bottom`,x1:O,y1:S,x2:O,y2:w+h,itemIndex:m})),y!==null&&T.push(y),f[m]=T,p.isDirectory&&(g[m]=[{key:`${p.id}-glyph`,itemIndex:m,centerX:O,centerY:S,size:l,isExpanded:p.isExpanded}])}return{segmentsByItem:f,glyphsByItem:g}},Un=s.memo(({entry:e,indentLevel:t,originX:n,depth:r,positionInSet:a,setSize:i,isSelectedForAria:l,flatIndex:u,isActive:f,registerRowRef:g,onNavigationKeyDown:R,onRowFocus:x,onRowBlur:C,rowHeight:m,entryKindDirectory:p,entryKindFile:h,isDirOpen:w,expansion:{toggleDirectory:S,onToggleDirectoryRecursive:j},selection:{onEntryClick:I,selectedPath:k,currentPath:y,mode:T="none",selectedItems:O,onSelectionChange:L},visual:{iconOverrides:le,showExpandIcons:X=!0,showDirectoryIcons:D=!0,showFileIcons:K=!0,useCanvasExpandIcons:ge=!1,expandIconSize:F,typeIconSize:de,fontSize:be,indentSize:U,highlightStyles:J,entryClassName:Oe,entryStyle:Ie,nameClassName:Re,nameStyle:M,directoryNameClassName:Q,directoryNameStyle:z,fileNameClassName:We,fileNameStyle:E,expandIconClassName:Me,expandIconStyle:Se}})=>{He(e.style,{option:"entry.style",absolutePath:e.absolutePath});const[Ce,_e]=s.useState(!1),N=e.children!==void 0,ue=N&&w(e.absolutePath),H=e.absolutePath===k,je=e.absolutePath===y,Z=!N&&O?.has(e.absolutePath),Y=s.useCallback(G=>g(u,G),[g,u]),ee=N?void 0:Tn(e),we=zn({entry:e,isDirectory:N,isExpanded:ue,isItemSelected:!!Z,selectionMode:T,onSelectionChange:L,onEntryClick:I,toggleDirectory:S,onToggleDirectoryRecursive:j}),he=Ce?J?.hoverClassName!==void 0?J.hoverClassName:P.entryHover:"",ke=(()=>{if(N){if(H)return J?.directorySelectedClassName!==void 0?J.directorySelectedClassName:P.entrySelected}else if(H||Z)return J?.itemSelectedClassName!==void 0?J.itemSelectedClassName:B.twMerge(H&&P.entrySelected,Z&&P.entryItemSelected);return""})(),me=B.twMerge(P.entry,he,ke,Oe,e.className),Ke=B.twMerge(P.expandIcon,Me,(H||Z)&&P.expandIconSelected),A=B.twMerge(P.typeIcon,(H||Z)&&P.typeIconSelected),Ze=B.twMerge(P.name,Re,N&&P.nameDirectory,N&&Q,!N&&We,(H||Z)&&P.nameSelected),ct=On({isDirectory:N,isExpanded:ue,showExpandIcons:X&&t>=0,useCanvasExpandIcons:ge,expandIconSize:F}),Ye=(N?D:K)?Mn({entry:e,isDirectory:N,isExpanded:ue,isSelected:H,isItemSelected:!!Z,extension:ee,mimeType:e.mimeType},le,de):null,Ge={...Ce?J?.hoverStyle:{},...N&&H?J?.directorySelectedStyle:{},...!N&&(H||Z)?J?.itemSelectedStyle:{}},qe=_n(e.data),dt={width:de,height:de},Ne=Pn(be),ve=n+t*U;return d.jsxs("div",{className:me,style:{...Ne,...Ge,...Ie,...e.style,paddingLeft:`${Math.max(0,ve)}px`,transform:ve<0?`translateX(${ve}px)`:void 0,width:ve<0?`calc(100% + ${-ve}px)`:void 0,height:`${m}px`},...qe,"data-entry-type":N?"directory":"file","data-entry-expanded":N?String(ue):void 0,"data-entry-selected":H?"true":void 0,"data-entry-item-selected":Z?"true":void 0,onClick:we,onMouseEnter:()=>_e(!0),onMouseLeave:()=>_e(!1),onFocus:G=>x(u,e.absolutePath,G.currentTarget),onBlur:G=>C(e.absolutePath,G.currentTarget),ref:Y,onKeyDown:G=>{if(G.key==="Enter"||G.key===" "){G.preventDefault(),G.repeat||we(G);return}R(G,u)},tabIndex:f?0:-1,role:"treeitem","aria-expanded":N?ue:void 0,"aria-level":r+1,"aria-posinset":a,"aria-setsize":i,"aria-selected":T==="none"?void 0:l,"aria-current":je?"page":void 0,"aria-label":`${e.name} (${N?p:h})`,children:[(X||ge)&&d.jsx("span",{className:Ke,style:{...Se,width:oe,height:oe},children:ct}),(N?D:K)&&d.jsx("span",{className:A,style:dt,children:Ye}),d.jsx("span",{className:Ze,style:{...Ne,...M,...N?z:E},"data-entry-type":N?"directory":"file","data-entry-role":"name",children:e.label??e.name})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const n=e.entry.children!==void 0,r=t.entry.children!==void 0,a=n&&e.isDirOpen(e.entry.absolutePath),i=r&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&e.originX===t.originX&&e.depth===t.depth&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.isSelectedForAria===t.isSelectedForAria&&e.flatIndex===t.flatIndex&&e.isActive===t.isActive&&e.rowHeight===t.rowHeight&&e.entryKindDirectory===t.entryKindDirectory&&e.entryKindFile===t.entryKindFile&&a===i&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.currentPath===t.selection.currentPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual.iconOverrides===t.visual.iconOverrides&&e.visual.showExpandIcons===t.visual.showExpandIcons&&e.visual.showDirectoryIcons===t.visual.showDirectoryIcons&&e.visual.showFileIcons===t.visual.showFileIcons&&e.visual.useCanvasExpandIcons===t.visual.useCanvasExpandIcons&&e.visual.expandIconSize===t.visual.expandIconSize&&e.visual.typeIconSize===t.visual.typeIconSize&&e.visual.fontSize===t.visual.fontSize&&e.visual.indentSize===t.visual.indentSize&&e.visual.highlightStyles===t.visual.highlightStyles&&e.visual.entryClassName===t.visual.entryClassName&&e.visual.entryStyle===t.visual.entryStyle&&e.visual.nameClassName===t.visual.nameClassName&&e.visual.nameStyle===t.visual.nameStyle&&e.visual.directoryNameClassName===t.visual.directoryNameClassName&&e.visual.directoryNameStyle===t.visual.directoryNameStyle&&e.visual.fileNameClassName===t.visual.fileNameClassName&&e.visual.fileNameStyle===t.visual.fileNameStyle&&e.visual.expandIconClassName===t.visual.expandIconClassName&&e.visual.expandIconStyle===t.visual.expandIconStyle});Un.displayName="DirectoryEntryItem";const Jn=e=>{const t=[];if(e.children)for(const n of e.children)n.type==="directory"&&(t.push(n.absolutePath),t.push(...Jn(n)));return t},po=({entries:e,expansion:{toggle:t,isExpanded:n,expandMultiple:r,collapseMultiple:a,isPending:i,alwaysExpanded:l=!1,doubleClickAction:u="recursive"},selection:{onEntryClick:f,selectedPath:g,currentPath:R,mode:x="none",selectedItems:C,onSelectionChange:m},visual:{className:p,style:h,ariaLabel:w,ariaLabelledBy:S,lineColor:j=Nn,showTreeLines:I=!0,showExpandIcons:k=!0,showDirectoryIcons:y=!0,showFileIcons:T=!0,iconOverrides:O,expandIconSize:L,typeIconSize:le,fontSize:X,indentSize:D,itemHeight:K=Ct,removeRootIndent:ge=!1,highlightStyles:F,entryClassName:de,entryStyle:be,nameClassName:U,nameStyle:J,directoryNameClassName:Oe,directoryNameStyle:Ie,fileNameClassName:Re,fileNameStyle:M,expandIconClassName:Q,expandIconStyle:z}={},virtualScroll:We,grid:E,sort:Me,locale:Se,labels:Ce,ref:_e})=>{const N=ce.resolveVirtualScrollLocale(Se),ue=s.useMemo(()=>Vn(Se,Ce),[Se,Ce]),H=co(Fr(ue)),{entryKindDirectory:je,entryKindFile:Z}=ue,Y=s.useMemo(()=>Hr({indentSize:D,typeIconSize:le,fontSize:X}),[D,le,X]);s.useMemo(()=>{He(be,{option:"visual.entryStyle"}),He(F?.hoverStyle,{option:"visual.highlightStyles.hoverStyle"}),He(F?.directorySelectedStyle,{option:"visual.highlightStyles.directorySelectedStyle"}),He(F?.itemSelectedStyle,{option:"visual.highlightStyles.itemSelectedStyle"}),Pr(z,{option:"visual.expandIconStyle"})},[be,F,z]);const ee=E!==void 0,we=s.useSyncExternalStore(ao,lo,io),he=s.useRef(null),ke=s.useRef(null),me=s.useRef(null),[Ke,A]=s.useState(0),[Ze,ct]=s.useState(0),[Ye,Ge]=s.useState(0),[qe,dt]=s.useState(null),{overscanCount:Ne=15,className:ve,background:G,onScroll:_t,onRangeChange:jt,onScrollAdjust:At,liveRegion:Dt,initialScrollIndex:zt,initialScrollOffset:Ae,initialScrollAnchor:Ft,callbackThrottleMs:$t=5,contentInsets:Bt,onItemFocus:Ht,viewportHeightOverride:te,scrollBarOptions:ut,behaviorOptions:Wt,preserveScrollAnchor:Kt=!1,getItemKey:Zn,testId:Yt,contentProps:ft}=We??{},Gt=s.useMemo(()=>ee?{...ft,role:"rowgroup"}:{...ft,role:"tree","aria-label":S?void 0:w,"aria-labelledby":S,"aria-multiselectable":x==="multiple"?!0:void 0,"aria-busy":i?!0:void 0},[ee,ft,w,S,x,i]),Vt=s.useMemo(()=>({...Wt,enableKeyboardNavigation:!1}),[Wt]),[Qe,Xt]=s.useState(typeof Ae=="number"?Ae:0),ht=s.useRef(typeof Ae=="number"?Ae:0),Ut=s.useCallback((o,c)=>{ht.current=o,Xt(o),_t?.(o,c)},[_t]),Jt=s.useCallback(o=>{const{renderingStartIndex:c,renderingEndIndex:b}=o;dt(v=>v&&v.renderStart===c&&v.renderEnd===b?v:{renderStart:c,renderEnd:b}),jt?.(o)},[jt]);s.useEffect(()=>{so()},[]),s.useEffect(()=>{const o=he.current,c=ee?ke.current:o,b=()=>{if(o){const _=o.clientWidth;ct(W=>Math.abs(W-_)>1?_:W)}if(typeof te=="number")A(_=>Math.abs(_-te)>1?te:_);else if(c){const _=c.clientHeight;A(W=>Math.abs(W-_)>1?_:W)}};if(!(o||c))return A(0);b();const v=new ResizeObserver(b);return o&&v.observe(o),c&&c!==o&&v.observe(c),()=>v.disconnect()},[te,ee]);const De=typeof te=="number"?te:Ke,fe=s.useCallback(o=>l||(we?n(o):!1),[we,n,l]),Zt=B.twMerge(P.container,i&&P.containerPending,p),qt=s.useMemo(()=>({...oo,...h??{},...typeof te=="number"?{height:te,minHeight:te}:{}}),[h,te]),mt=s.useCallback((o,c)=>{const b=[o.absolutePath,...Jn(o)],v=c||u;if(b.every(ye=>fe(ye)))return a(b);if(b.every(ye=>!fe(ye))||v==="recursive")return r(b);if(v==="toggle")return a(b);console.warn(`[DirectoryTree] Unknown double click action: ${v}. No action taken.`)},[fe,r,a,u]),pt=ee?!1:ge,{flatItems:Le,lineItems:yt,maxIndent:Qt}=s.useMemo(()=>fo(e,fe,I,pt,Me),[e,fe,I,pt,Me]),et=Wr({indentSize:Y.indentSize,removeRootIndent:pt,hasExpandBox:k||I}),ie=s.useMemo(()=>I?Yr(Y,L,et):null,[I,Y,L,et]),$=s.useMemo(()=>Le.map((o,c)=>({...o,rowHeight:Kr(K,o.entry,c)})),[Le,K]),xe=s.useMemo(()=>$.map(o=>o.rowHeight),[$]),Pe=s.useMemo(()=>{const o=new Array(xe.length+1);o[0]=0;for(let c=0;c<xe.length;c++)o[c+1]=o[c]+xe[c];return o},[xe]),en=s.useCallback(o=>$[o]?.rowHeight??Ct,[$]),qn=s.useCallback(o=>$[o]?.entry.absolutePath??o,[$]),tn=Zn??qn,ze=g??null,gt=R??null,[nn,Ve]=s.useState(()=>({selectedPath:ze,selectionGeneration:0,anchor:null})),bt=En(nn,ze);bt!==nn&&Ve(o=>En(o,ze));const tt=s.useMemo(()=>to(Le),[Le]),Fe=s.useMemo(()=>ro(tt,bt),[tt,bt]),Xe=s.useRef(new Map),nt=s.useRef(null),[rt]=s.useState($r),Ue=s.useRef(null),[Qn,rn]=s.useState(!0),St=s.useRef(Le);St.current=Le;const on=s.useRef(fe);on.current=fe;const wt=s.useRef(t);wt.current=t;const sn=s.useRef(tt);sn.current=tt;const vt=s.useRef(Fe);vt.current=Fe;const an=s.useRef(Ht);an.current=Ht;const Te=s.useCallback(o=>{const c=me.current;return!c||c.getViewportSize()<=0?!1:(c.scrollToIndex(o,{align:"nearest"}),!0)},[]),pe=s.useCallback(o=>{const c=Xe.current.get(o);if(c===void 0){Ue.current=o,Te(o)||(Ue.current=null);return}Ue.current=null,Te(o),c.focus({preventScroll:!0})},[Te]),ln=s.useCallback((o,c)=>{if(c)Xe.current.set(o,c),Ue.current===o?(Ue.current=null,c.focus({preventScroll:!0})):c.contains(c.ownerDocument.activeElement)&&Ve(b=>b.anchor===null?b:{...b,anchor:{...b.anchor,focused:!0}});else{const b=Xe.current.get(o);Xe.current.delete(o),b?.contains(b.ownerDocument.activeElement)&&Ve(v=>v.anchor===null?v:{...v,anchor:{...v.anchor,focused:!1}})}o===vt.current&&rn(c!==null)},[]);s.useLayoutEffect(()=>{rn(Xe.current.has(Fe))},[Fe]);const xt=s.useCallback((o,c,b)=>{const v=nt.current===b;nt.current=null,v||(Ve(_=>no(_,c)),rt.landedOn(b)||Te(o)),an.current?.(o)},[Te,rt]),ot=s.useCallback(o=>rt.mark(o.nativeEvent),[rt]),Et=s.useCallback((o,c)=>{const{ownerDocument:b}=c;if(!b.hasFocus()&&c.contains(b.activeElement)){nt.current=c;return}nt.current=null,Ve(v=>v.anchor!==null&&v.anchor.path===o?{...v,anchor:{...v.anchor,focused:!1}}:v)},[]),er=s.useCallback(()=>pe(vt.current),[pe]),It=s.useCallback((o,c)=>{const b=Rn(c),v=St.current.length;if(!Number.isInteger(o)||o<0||o>=v)throw new RangeError(`[directory-tree] scrollToIndex: ${String(o)} is not a row index (${v===0?"the tree has no rows":`expected an integer in 0..${String(v-1)}`}).`);if(b==="nearest"){Te(o);return}me.current?.scrollToIndex(o,{align:b})},[Te]);s.useImperativeHandle(_e,()=>({scrollToIndex:It,scrollToPath:(o,c)=>{Rn(c);const b=sn.current.get(o);return b===void 0?!1:(It(b,c),!0)},getScrollAnchor:()=>me.current?.getScrollAnchor()??null}),[It]);const cn=s.useCallback((o,c)=>{if(o.altKey||o.ctrlKey||o.metaKey)return;const b=St.current,v=b.length-1;if(v<0)return;const _=b[c],W=_?.entry.children!==void 0,ye=W&&on.current(_.entry.absolutePath);switch(o.key){case"ArrowDown":o.preventDefault(),pe(Math.min(c+1,v));break;case"ArrowUp":o.preventDefault(),pe(Math.max(c-1,0));break;case"Home":o.preventDefault(),pe(0);break;case"End":o.preventDefault(),pe(v);break;case"ArrowRight":o.preventDefault(),W&&!ye?wt.current(_.entry.absolutePath):W&&c<v&&b[c+1].depth>_.depth&&pe(c+1);break;case"ArrowLeft":{if(o.preventDefault(),W&&ye){wt.current(_.entry.absolutePath);break}const sr=_?.depth??0;for(let it=c-1;it>=0;it--)if(b[it].depth<sr){pe(it);break}break}}},[pe]),st=s.useMemo(()=>ie===null||yt.length===0?{segmentsByItem:[],glyphsByItem:[]}:mo(yt,xe,Pe,ie),[yt,xe,Pe,ie]),at=s.useMemo(()=>ie===null||e.length===0?0:ie.originX+Qt*ie.indentSize+oe+ie.typeIconSize,[e.length,Qt,ie]),{renderStart:dn,renderEnd:un,lookaheadEnd:fn}=s.useMemo(()=>ho($.length,De,Ne,qe,Qe,Pe),[$.length,De,Ne,qe,Qe,Pe]),Rt=s.useMemo(()=>ie===null||at<=0||De<=0||st.segmentsByItem.length===0?null:d.jsx("div",{className:"pointer-events-none absolute inset-0 z-1","aria-hidden":"true",children:d.jsx("div",{className:"absolute top-0 left-0",style:{width:at,height:De},children:d.jsx(Xn,{segmentsByItem:st.segmentsByItem,glyphsByItem:st.glyphsByItem,itemHeight:xe[0]??Ct,width:at,viewportHeight:De,scrollPosition:Qe,color:j,expandGlyphColor:j,expandGlyphSize:ie.glyphSize,renderStartIndex:dn,renderEndIndex:un,lookaheadEndIndex:fn})})}),[at,De,dn,un,fn,Qe,st,j,ie,xe]),hn=s.useCallback(o=>$[o],[$]),mn=s.useRef(null);s.useLayoutEffect(()=>{const o=mn.current;if(mn.current={items:$,offsets:Pe},!Kt||!o||o.items===$)return;const c=me.current,b=c?.getScrollPosition(),v=typeof b=="number"&&b>=0?b:ht.current,_=Xr(o.items,o.offsets,v);if(!_)return;const W=Ur(_,$,Pe);if(W===null||Math.abs(W-v)<1)return;const ye=c?c.scrollTo(W):W;ht.current=ye,Xt(ye)},[$,Pe,Kt]);const Ee=E?.columns,$e=E?.scrollBarWidth??ut?.width??Kn,V=s.useMemo(()=>Ee?Ar({measuredWidth:Ze,columns:Ee,scrollBarWidth:$e}):null,[Ee,Ze,$e]),lt=s.useMemo(()=>Ee?jr(Ee):"",[Ee]),tr=s.useMemo(()=>E?.showFooter&&Ee?Dr(e):[],[E?.showFooter,Ee,e]),Be=V?.maxHScroll??0;s.useEffect(()=>{Ge(o=>kt(o,Be))},[Be]);const pn=s.useCallback(o=>Ge(c=>kt(c+o,Be)),[Be]),yn=s.useMemo(()=>({iconOverrides:O,showExpandIcons:k,showDirectoryIcons:y,showFileIcons:T,useCanvasExpandIcons:I,expandIconSize:L,typeIconSize:Y.typeIconSize,fontSize:Y.fontSize,indentSize:Y.indentSize,highlightStyles:F,expandIconClassName:Q,expandIconStyle:z}),[O,k,y,T,I,L,Y,F,Q,z]),gn=s.useMemo(()=>d.jsx(ce.VirtualScroll,{ref:me,itemCount:$.length,getItem:hn,getItemHeight:en,getItemKey:tn,testId:Yt,contentProps:Gt,locale:N,labels:H,viewportSize:typeof te=="number"?te:void 0,overscanCount:Ne,onScroll:Ut,onRangeChange:Jt,onScrollAdjust:At,liveRegion:Dt,className:ve,onWheelHorizontal:ee?pn:void 0,background:d.jsxs(d.Fragment,{children:[ee&&V?d.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-1 h-full overflow-hidden",style:{width:V.nameWidth},"aria-hidden":"true",children:Rt}):Rt,G]}),initialScrollIndex:zt,initialScrollOffset:Ae,initialScrollAnchor:Ft,callbackThrottleMs:$t,contentInsets:Bt,scrollBarOptions:ut,behaviorOptions:Vt,children:(o,c)=>o?ee&&E&&V?d.jsx(Bn,{entry:o.entry,indentLevel:o.indentLevel,positionInSet:o.positionInSet,setSize:o.setSize,rowIndex:c+(E.showHeader??!0?2:1),flatIndex:c,onRowFocus:xt,onRowBlur:Et,isSelectedForAria:!!C?.has(o.entry.absolutePath),rowHeight:o.rowHeight,isDirOpen:fe,columns:E.columns,numericTemplate:lt,numericTotal:V.numericTotal,nameWidth:V.nameWidth,rowClassName:E.rowClassName,selection:{onEntryClick:f,selectedPath:ze,currentPath:gt,mode:x,selectedItems:C,onSelectionChange:m},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:mt},visual:yn},o.entry.absolutePath):d.jsx(Un,{entry:o.entry,indentLevel:o.indentLevel,originX:et,depth:o.depth,positionInSet:o.positionInSet,setSize:o.setSize,isSelectedForAria:!!C?.has(o.entry.absolutePath),flatIndex:c,isActive:c===Fe,registerRowRef:ln,onNavigationKeyDown:cn,onRowFocus:xt,onRowBlur:Et,rowHeight:o.rowHeight,entryKindDirectory:je,entryKindFile:Z,isDirOpen:fe,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:mt},selection:{onEntryClick:f,selectedPath:ze,currentPath:gt,mode:x,selectedItems:C,onSelectionChange:m},visual:{iconOverrides:O,showExpandIcons:k,showDirectoryIcons:y,showFileIcons:T,useCanvasExpandIcons:I,expandIconSize:L,typeIconSize:Y.typeIconSize,fontSize:Y.fontSize,indentSize:Y.indentSize,highlightStyles:F,entryClassName:de,entryStyle:be,nameClassName:U,nameStyle:J,directoryNameClassName:Oe,directoryNameStyle:Ie,fileNameClassName:Re,fileNameStyle:M,expandIconClassName:Q,expandIconStyle:z}},o.entry.absolutePath):null}),[$.length,hn,en,tn,Yt,Gt,N,H,je,Z,Fe,ln,cn,xt,Et,te,Ne,Ut,Jt,At,Dt,ve,ee,pn,V,Rt,G,zt,Ae,Ft,$t,Bt,ut,Vt,E,lt,fe,f,ze,gt,x,C,m,t,mt,yn,O,k,y,T,I,L,Y,et,F,de,be,U,J,Oe,Ie,Re,M,Q,z]);if(!(E&&V))return d.jsxs("div",{ref:he,className:Zt,style:qt,onPointerDownCapture:ot,onMouseDownCapture:ot,children:[Le.length>0&&!Qn&&d.jsx("span",{tabIndex:0,"data-directory-tree-tab-stop":"",style:uo,onFocus:er}),gn]});const nr=E.showHeader??!0,rr=E.showFooter??!1,or={...qt,"--dt-hscroll":`${Ye}px`};return d.jsxs("div",{ref:he,className:B.twMerge(Zt,"dt-grid"),style:or,role:"treegrid","aria-label":S?void 0:w,"aria-labelledby":S,"aria-multiselectable":x==="multiple"?!0:void 0,"aria-busy":i?!0:void 0,"aria-rowcount":$.length+(E.showHeader??!0?1:0),onPointerDownCapture:ot,onMouseDownCapture:ot,children:[nr&&d.jsx("div",{role:"rowgroup",children:d.jsx(Or,{columns:E.columns,numericTemplate:lt,numericTotal:V.numericTotal,nameWidth:V.nameWidth,scrollBarWidth:$e,className:E.headerClassName})}),d.jsx("div",{ref:ke,className:"dt-grid-body",children:gn}),Be>0&&d.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[d.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:V.nameWidth},"aria-hidden":"true"}),d.jsx(ce.ScrollBar,{horizontal:!0,contentSize:V.numericTotal,viewportSize:V.numericVisible,scrollPosition:Ye,scrollBarWidth:$e,locale:N,labels:H,onScroll:o=>{const c=typeof o=="function"?o(Ye):o,b=kt(c,Be);return Ge(b),b}}),d.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:$e},"aria-hidden":"true"})]}),rr&&d.jsx("div",{role:"rowgroup",children:d.jsx(Mr,{columns:E.columns,numericTemplate:lt,numericTotal:V.numericTotal,nameWidth:V.nameWidth,scrollBarWidth:$e,allEntries:tr,className:E.footerClassName})})]})},yo=({initialExpanded:e=new Set,storageKey:t}={})=>{const[n,r]=s.useTransition(),[a,i]=s.useState(()=>{if(typeof window<"u"&&t)try{const h=window.localStorage.getItem(t);if(h){const w=JSON.parse(h);return new Set(w)}}catch(h){console.error("[useDirectoryTreeState] Error reading from localStorage",h)}return e}),l=s.useCallback(h=>{r(()=>{i(w=>{const S=new Set(w);return h(S),S})})},[]),u=s.useCallback((h,w)=>{l(S=>{for(const j of h)w(S,j)})},[l]);s.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(a)))}catch(h){console.warn(`Error setting localStorage key "${t}":`,h)}},[a,t]);const f=s.useCallback(h=>{u([h],(w,S)=>{w.has(S)?w.delete(S):w.add(S)})},[u]),g=s.useCallback(h=>{u([h],(w,S)=>{w.add(S)})},[u]),R=s.useCallback(h=>{u([h],(w,S)=>{w.delete(S)})},[u]),x=s.useCallback(h=>{u(h,(w,S)=>{w.delete(S)})},[u]),C=s.useCallback(h=>{u(h,(w,S)=>{w.add(S)})},[u]),m=s.useCallback(()=>{l(h=>{h.clear()})},[l]),p=s.useCallback(h=>a.has(h),[a]);return{expanded:a,toggle:f,expand:g,collapse:R,collapseMultiple:x,expandMultiple:C,collapseAll:m,isExpanded:p,isPending:n}};exports.DIRECTORY_TREE_LABEL_CATALOGS=Gn;exports.DIRECTORY_TREE_LABEL_KEYS=Pt;exports.DirectoryTree=po;exports.EXPAND_ICON_STYLE_PROPERTIES=An;exports.FILE_ICON_PAIRS=hr;exports.MARK_PAIRS=kn;exports.ROW_STYLE_PROPERTIES=jn;exports.directoryTreeClasses=P;exports.resolveDirectoryTreeLabels=Vn;exports.useDirectoryTreeState=yo;
|