@aiquants/directory-tree 4.1.0 → 4.2.0
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 +18 -8
- package/dist/entryRendering.d.ts +7 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +1078 -1095
- package/dist/labels.d.ts +0 -2
- package/dist/styles/directory-tree.css +1 -1
- package/dist/styles/directory-tree.standalone.css +1 -1
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -165,7 +165,7 @@ The main component for rendering the directory tree.
|
|
|
165
165
|
| `showFileIcons` | `boolean` | No | `true` | Flag indicating whether to render file type icons |
|
|
166
166
|
| `iconOverrides` | `DirectoryTreeIconOverrides` | No | - | Icon overrides applied globally |
|
|
167
167
|
| `expandIconSize` | `number` | No | - | Size of the expand icon |
|
|
168
|
-
| `itemHeight` | `number \| ((entry, index) => number)` | No | `
|
|
168
|
+
| `itemHeight` | `number \| ((entry, index) => number)` | No | `44` | Row height in px, or a function computing the height per entry (variable-height rows). The default makes every row a pointer target of at least 44 × 44 CSS px under every pointer (WCAG 2.5.5). Tree connector lines follow each row's cumulative offset. Invalid values (`NaN` / `Infinity` / `0` / negative) fall back to `44`. Memoize the function to keep its identity stable. |
|
|
169
169
|
| `removeRootIndent` | `boolean` | No | `false` | If true, removes the indentation and connector lines for root-level items |
|
|
170
170
|
| `highlightStyles` | `HighlightStyles` | No | - | Highlight styles configuration for hover and selection states |
|
|
171
171
|
| `entryClassName` | `string` | No | - | Additional CSS classes for each entry row |
|
|
@@ -364,9 +364,9 @@ The component's hand-written classes ship in **two CSS artifacts**; choose by ho
|
|
|
364
364
|
/* monorepo: @source "../../../../packages/directory-tree/src/**/*.{ts,tsx}"; */
|
|
365
365
|
```
|
|
366
366
|
|
|
367
|
-
`directory-tree.css` (Artifact A) carries only the hand-written `.dt-*` classes — no `:root` theme variables, no Tailwind utilities, no preflight — and it does **not** embed the virtualscroll stylesheet (the host imports virtualscroll's own Artifact A once, avoiding a duplicated, possibly stale copy). Do not also `@import` the standalone build here — the duplicated utilities flip the base/variant cascade order.
|
|
367
|
+
`directory-tree.css` (Artifact A) carries only the hand-written component rules (the `.dt-*` classes and the `box-sizing: border-box` rule of the container, the rows and the grid's name cells) — no `:root` theme variables, no Tailwind utilities, no preflight — and it does **not** embed the virtualscroll stylesheet (the host imports virtualscroll's own Artifact A once, avoiding a duplicated, possibly stale copy). Do not also `@import` the standalone build here — the duplicated utilities flip the base/variant cascade order.
|
|
368
368
|
|
|
369
|
-
- **Non-Tailwind host** — import the single self-contained standalone build; it bundles the `.dt-*` classes, every JSX utility, and the virtualscroll peer CSS for convenience:
|
|
369
|
+
- **Non-Tailwind host** — import the single self-contained standalone build; it bundles the `.dt-*` classes, every JSX utility, and the virtualscroll peer CSS for convenience. It needs no preflight: the container, the rows and the grid's name cells are `border-box` in both builds, so a 44 px row is 44 px tall here too:
|
|
370
370
|
|
|
371
371
|
```css
|
|
372
372
|
@import "@aiquants/directory-tree/styles/directory-tree.standalone.css";
|
|
@@ -474,20 +474,30 @@ Alternatively, you can dynamically configure specific highlight styles for hover
|
|
|
474
474
|
|
|
475
475
|
### Row Height (fixed & variable)
|
|
476
476
|
|
|
477
|
-
Rows are
|
|
478
|
-
|
|
479
|
-
|
|
477
|
+
Rows are 44 px tall by default, so every row is a pointer target of at least 44 × 44 CSS px under
|
|
478
|
+
every pointer — mouse, pen and touch alike (WCAG 2.5.5 Target Size). The expand glyph keeps its size
|
|
479
|
+
(8 px on the tree-line canvas) because the whole row is the target; a height below 44 px makes the
|
|
480
|
+
rows smaller targets than that.
|
|
481
|
+
Pass a number for a uniform height, or a function for variable-height rows — the virtual scroller
|
|
482
|
+
and the tree connector lines both follow each row's resolved height. Memoize the function so its
|
|
483
|
+
identity stays stable.
|
|
484
|
+
|
|
485
|
+
At any row height, fixed or variable, the line from an expanded folder to its children starts just
|
|
486
|
+
below the folder's type icon (a 14 px box centred in the row) and runs on into the first child's
|
|
487
|
+
connector, so the tree reads as one joined line however tall the rows are. A host that hides
|
|
488
|
+
directory icons (`showDirectoryIcons: false`) gets the same line: the name takes the icon's place,
|
|
489
|
+
and the line starts just below it.
|
|
480
490
|
|
|
481
491
|
```tsx
|
|
482
492
|
import { useCallback } from 'react';
|
|
483
493
|
import { DirectoryTree, type DirectoryEntry } from '@aiquants/directory-tree';
|
|
484
494
|
|
|
485
495
|
// Fixed height
|
|
486
|
-
<DirectoryTree entries={entries} /* ...required props */ visual={{ itemHeight:
|
|
496
|
+
<DirectoryTree entries={entries} /* ...required props */ visual={{ itemHeight: 48 }} />
|
|
487
497
|
|
|
488
498
|
// Variable height: taller rows for files that render inline metadata
|
|
489
499
|
const itemHeight = useCallback(
|
|
490
|
-
(entry: DirectoryEntry) => (entry.type === 'file' ?
|
|
500
|
+
(entry: DirectoryEntry) => (entry.type === 'file' ? 56 : 44),
|
|
491
501
|
[],
|
|
492
502
|
);
|
|
493
503
|
<DirectoryTree entries={entries} /* ...required props */ visual={{ itemHeight }} />
|
package/dist/entryRendering.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import { DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext } from "./types.ts";
|
|
3
|
-
export declare const DEFAULT_ITEM_HEIGHT =
|
|
2
|
+
import { DirectoryEntry, DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext } from "./types.ts";
|
|
3
|
+
export declare const DEFAULT_ITEM_HEIGHT = 44;
|
|
4
4
|
export declare const INDENT_SIZE = 12;
|
|
5
5
|
export declare const EXPAND_GLYPH_SIZE = 8;
|
|
6
|
+
export declare const TYPE_ICON_SIZE = 14;
|
|
6
7
|
export declare const directoryTreeClasses: {
|
|
7
8
|
container: string;
|
|
8
9
|
containerPending: string;
|
|
@@ -19,6 +20,8 @@ export declare const directoryTreeClasses: {
|
|
|
19
20
|
nameSelected: string;
|
|
20
21
|
};
|
|
21
22
|
export declare const getFileExtension: (filename: string) => string;
|
|
23
|
+
export declare const getPathExtension: (path: string) => string;
|
|
24
|
+
export declare const getEntryExtension: (entry: Pick<DirectoryEntry, "name" | "relativePath" | "absolutePath">) => string;
|
|
22
25
|
export type ExpandIconParams = {
|
|
23
26
|
isDirectory: boolean;
|
|
24
27
|
isExpanded: boolean;
|
|
@@ -27,6 +30,8 @@ export type ExpandIconParams = {
|
|
|
27
30
|
expandIconSize?: number;
|
|
28
31
|
};
|
|
29
32
|
export declare const resolveExpandIcon: ({ isDirectory, isExpanded, showExpandIcons, useCanvasExpandIcons, expandIconSize }: ExpandIconParams) => ReactNode;
|
|
33
|
+
export declare const GENERIC_MIME_TYPES: ReadonlySet<string>;
|
|
34
|
+
export declare const normalizeMimeType: (mimeType: string | undefined) => string;
|
|
30
35
|
export declare const getFileIconByMimeOrExtension: (mimeType?: string, extension?: string, filename?: string) => ReactNode;
|
|
31
36
|
export declare const resolveEntryIcon: (ctx: DirectoryTreeIconRenderContext, overrides?: DirectoryTreeIconOverrides) => ReactNode;
|
|
32
37
|
export declare const toDataAttributes: (data?: Record<string, string | number | boolean>) => Record<string, string> | undefined;
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),pe=require("@aiquants/virtualscroll"),M=require("tailwind-merge"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),pe=require("@aiquants/virtualscroll"),M=require("tailwind-merge"),le=require("@phosphor-icons/react");function Ur(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const de=Ur(l);var at={exports:{}},Ye={};var dr;function Xr(){if(dr)return Ye;dr=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(o,a,c){var i=null;if(c!==void 0&&(i=""+c),a.key!==void 0&&(i=""+a.key),"key"in a){c={};for(var u in a)u!=="key"&&(c[u]=a[u])}else c=a;return a=c.ref,{$$typeof:e,type:o,key:i,ref:a!==void 0?a:null,props:c}}return Ye.Fragment=t,Ye.jsx=r,Ye.jsxs=r,Ye}var ze={};var fr;function Jr(){return fr||(fr=1,process.env.NODE_ENV!=="production"&&(function(){function e(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===$?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case x:return"Fragment";case F:return"Profiler";case R:return"StrictMode";case G:return"Suspense";case V:return"SuspenseList";case Q:return"Activity"}if(typeof n=="object")switch(typeof n.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),n.$$typeof){case h:return"Portal";case _:return n.displayName||"Context";case k:return(n._context.displayName||"Context")+".Consumer";case b:var g=n.render;return n=n.displayName,n||(n=g.displayName||g.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case N:return g=n.displayName||null,g!==null?g:e(n.type)||"Memo";case j:g=n._payload,n=n._init;try{return e(n(g))}catch{}}return null}function t(n){return""+n}function r(n){try{t(n);var g=!1}catch{g=!0}if(g){g=console;var p=g.error,P=typeof Symbol=="function"&&Symbol.toStringTag&&n[Symbol.toStringTag]||n.constructor.name||"Object";return p.call(g,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",P),t(n)}}function o(n){if(n===x)return"<>";if(typeof n=="object"&&n!==null&&n.$$typeof===j)return"<...>";try{var g=e(n);return g?"<"+g+">":"<...>"}catch{return"<...>"}}function a(){var n=D.A;return n===null?null:n.getOwner()}function c(){return Error("react-stack-top-frame")}function i(n){if(K.call(n,"key")){var g=Object.getOwnPropertyDescriptor(n,"key").get;if(g&&g.isReactWarning)return!1}return n.key!==void 0}function u(n,g){function p(){U||(U=!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)",g))}p.isReactWarning=!0,Object.defineProperty(n,"key",{get:p,configurable:!0})}function I(){var n=e(this.type);return ce[n]||(ce[n]=!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.")),n=this.props.ref,n!==void 0?n:null}function S(n,g,p,P,B,he){var A=p.ref;return n={$$typeof:T,type:n,key:g,props:p,_owner:P},(A!==void 0?A:null)!==null?Object.defineProperty(n,"ref",{enumerable:!1,get:I}):Object.defineProperty(n,"ref",{enumerable:!1,value:null}),n._store={},Object.defineProperty(n._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(n,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(n,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:B}),Object.defineProperty(n,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:he}),Object.freeze&&(Object.freeze(n.props),Object.freeze(n)),n}function v(n,g,p,P,B,he){var A=g.children;if(A!==void 0)if(P)if(ee(A)){for(P=0;P<A.length;P++)m(A[P]);Object.freeze&&Object.freeze(A)}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 m(A);if(K.call(g,"key")){A=e(n);var te=Object.keys(g).filter(function(ie){return ie!=="key"});P=0<te.length?"{key: someKey, "+te.join(": ..., ")+": ...}":"{key: someKey}",se[A+P]||(te=0<te.length?"{"+te.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,T,A,Q,A),P[A+T]=!0)}if(A=null,w!==void 0&&(r(w),A=""+w),i(p)&&(r(p.key),A=""+p.key),"key"in p){w={};for(var he in p)he!=="key"&&(w[he]=p[he])}else w=p;return A&&f(w,typeof o=="function"?o.displayName||o.name||"Unknown":o),S(o,A,w,s(),se,ie)}function b(o){k(o)?o._store&&(o._store.validated=1):typeof o=="object"&&o!==null&&o.$$typeof===U&&(o._payload.status==="fulfilled"?k(o._payload.value)&&o._payload.value._store&&(o._payload.value._store.validated=1):o._store&&(o._store.validated=1))}function k(o){return typeof o=="object"&&o!==null&&o.$$typeof===N}var E=l,N=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),C=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),J=Symbol.for("react.client.reference"),Z=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=Object.prototype.hasOwnProperty,te=Array.isArray,B=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(o){return o()}};var me,le={},ce=E.react_stack_bottom_frame.bind(E,c)(),Y=B(n(c)),P={};Ye.Fragment=v,Ye.jsx=function(o,p,w){var T=1e4>Z.recentlyCreatedOwnerStacks++;return m(o,p,w,!1,T?Error("react-stack-top-frame"):ce,T?B(n(o)):Y)},Ye.jsxs=function(o,p,w){var T=1e4>Z.recentlyCreatedOwnerStacks++;return m(o,p,w,!0,T?Error("react-stack-top-frame"):ce,T?B(n(o)):Y)}})()),Ye}var fr;function Kr(){return fr||(fr=1,process.env.NODE_ENV==="production"?at.exports=Vr():at.exports=Ur()),at.exports}var u=Kr();function Xr({title:e,titleId:t,...r},n){return fe.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?fe.createElement("title",{id:t},e):null,fe.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 Jr=fe.forwardRef(Xr);function qr({title:e,titleId:t,...r},n){return fe.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?fe.createElement("title",{id:t},e):null,fe.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 Zr=fe.forwardRef(qr);function Qr({title:e,titleId:t,...r},n){return fe.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?fe.createElement("title",{id:t},e):null,fe.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=fe.forwardRef(Qr),lt=18,ct=12,mr=8,D={container:"directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"opacity-70",entry:"directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",entryHover:M.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:M.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:M.twMerge("directory-tree-entry--item-selected bg-blue-400/20 shadow-[0_0_0_1px_rgba(59,130,246,0.3)]","dark:bg-blue-400/25 dark:shadow-[0_0_0_1px_rgba(96,165,250,0.4)]"),expandIcon:M.twMerge("directory-tree-expand-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),expandIconSelected:M.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:M.twMerge("directory-tree-type-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),typeIconSelected:M.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:M.twMerge("directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 text-xs font-normal","text-gray-700","dark:text-gray-200"),nameDirectory:"directory-tree-name--directory font-medium",nameSelected:M.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},je=e=>{if(!e)return"";const t=e.split("?")[0].split("#")[0].split("/").pop()||e,r=t.lastIndexOf(".");return r<=0?"":t.slice(r+1).toLowerCase()},xr=({isDirectory:e,isExpanded:t,showExpandIcons:r,useCanvasExpandIcons:n,expandIconSize:s})=>{const c=s?{width:s,height:s}:void 0,i=s?"":"h-4 w-4";return!(r&&e)||n?u.jsx("span",{className:i,style:c,"aria-hidden":"true"}):t?u.jsx(Jr,{className:i,style:c}):u.jsx(Zr,{className:i,style:c})},Ct=(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(s=>Ct(s,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},tn=(e,t,r)=>{const n=(t||(r?je(r):"")).toLowerCase(),s=(e||"").toLowerCase();if(s&&s!=="application/octet-stream"){if(s==="text/markdown"||s==="text/x-markdown")return u.jsx(O.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(s==="application/pdf")return u.jsx(O.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(s.includes("excel")||s.includes("spreadsheet")||s.includes("google-apps.spreadsheet"))return u.jsx(O.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(s==="text/csv"||s==="text/tab-separated-values")return u.jsx(O.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(s.includes("word")||s.includes("msword")||s.includes("wordprocessingml")||s.includes("google-apps.document")||s==="application/rtf")return u.jsx(O.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(s.includes("powerpoint")||s.includes("presentation")||s.includes("google-apps.presentation"))return u.jsx(O.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(s.startsWith("image/"))return u.jsx(O.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(s.startsWith("audio/"))return u.jsx(O.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(s.startsWith("video/"))return u.jsx(O.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(s.includes("zip")||s.includes("tar")||s.includes("compressed")||s.includes("archive"))return u.jsx(O.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(s==="application/json"||s.includes("javascript")||s.includes("typescript")||s.includes("xml")||s.startsWith("text/html")||s.startsWith("text/css")||s.includes("x-python")||s.includes("x-sh")||s.includes("x-go")||s.includes("x-rust"))return u.jsx(O.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(s.startsWith("text/"))return u.jsx(O.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}if(n){if(n==="md"||n==="markdown"||n==="mdx")return u.jsx(O.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(n==="pdf")return u.jsx(O.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(["xls","xlsx","xlsm","xlsb","ods"].includes(n))return u.jsx(O.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["csv","tsv"].includes(n))return u.jsx(O.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["doc","docx","rtf","odt"].includes(n))return u.jsx(O.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(["ppt","pptx","odp"].includes(n))return u.jsx(O.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff","avif"].includes(n))return u.jsx(O.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(["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"].includes(n))return u.jsx(O.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(["mp3","wav","ogg","m4a","flac","aac","wma"].includes(n))return u.jsx(O.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(["mp4","webm","mov","avi","mkv","wmv","flv"].includes(n))return u.jsx(O.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(["zip","tar","gz","7z","rar","tgz","bz2"].includes(n))return u.jsx(O.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(["txt","log"].includes(n))return u.jsx(O.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}return u.jsx(O.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"})},Sr=(e,t)=>{const{entry:r,isDirectory:n,isExpanded:s,extension:c,mimeType:i}=e;let f;const j=i||r.mimeType;return r.icon!==void 0?f=r.icon:n?f=s&&t?.directoryExpanded||t?.directory||u.jsx(en,{className:"h-4 w-4"}):c&&t?.fileByExtension?.[c]?f=t.fileByExtension[c]:f=t?.file||tn(j,c,r.name),Ct(typeof f=="function"?f(e):f,r.absolutePath)},rn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Er=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-${rn(r)}`,String(n)]))},nn=500,kr=({entry:e,isDirectory:t,isExpanded:r,isItemSelected:n,selectionMode:s,onSelectionChange:c,onEntryClick:i,toggleDirectory:f,onToggleDirectoryRecursive:j})=>{const S=l.useRef(null);return l.useEffect(()=>()=>{S.current&&window.clearTimeout(S.current)},[]),l.useCallback(m=>{m.stopPropagation(),s!=="none"&&!t&&c&&c(e,!n);let b=!1;i({entry:e,isDirectory:t,isExpanded:r,preventDefault:()=>{b=!0}}),!(!t||b)&&(S.current?(window.clearTimeout(S.current),S.current=null,j(e)):S.current=window.setTimeout(()=>{f(e.absolutePath),S.current=null},nn))},[t,e,r,j,f,i,s,c,n])},Rr=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",hr=(e,t)=>e.children!==void 0&&t(e.absolutePath),Cr=(e,t)=>({width:e,gridTemplateColumns:t}),Ir=l.memo(({entry:e,indentLevel:t,positionInSet:r,setSize:n,rowIndex:s,flatIndex:c,onRowFocus:i,onRowBlur:f,isSelectedForAria:j,rowHeight:S,isDirOpen:m,columns:b,numericTemplate:k,numericTotal:E,nameWidth:N,rowClassName:h,selection:{onEntryClick:v,selectedPath:R,currentPath:$,mode:x="none",selectedItems:C,onSelectionChange:y},expansion:{toggleDirectory:W,onToggleDirectoryRecursive:F},visual:{iconOverrides:_,showExpandIcons:U=!0,showDirectoryIcons:ae=!0,showFileIcons:J=!0,useCanvasExpandIcons:Z=!1,expandIconSize:ne,indentSize:te=ct,highlightStyles:B,expandIconClassName:me,expandIconStyle:le}})=>{const[ce,Y]=l.useState(!1),P=e.children!==void 0,o=P&&m(e.absolutePath),p=e.absolutePath===R,w=e.absolutePath===$,T=!P&&!!C?.has(e.absolutePath),se=P?void 0:je(e.name)||je(e.relativePath)||je(e.absolutePath),ie=kr({entry:e,isDirectory:P,isExpanded:o,isItemSelected:T,selectionMode:x,onSelectionChange:y,onEntryClick:v,toggleDirectory:W,onToggleDirectoryRecursive:F}),A=ce?B?.hoverClassName!==void 0?B.hoverClassName:D.entryHover:"",Q=(()=>{if(P){if(p)return B?.directorySelectedClassName!==void 0?B.directorySelectedClassName:D.entrySelected}else if(p||T)return B?.itemSelectedClassName!==void 0?B.itemSelectedClassName:M.twMerge(p&&D.entrySelected,T&&D.entryItemSelected);return""})(),he=typeof h=="function"?h(e):h,ue=M.twMerge("dt-grid-row cursor-pointer select-none",A,Q,he,e.className),Te=M.twMerge(D.expandIcon,me,(p||T)&&D.expandIconSelected),Ee=M.twMerge(D.typeIcon,(p||T)&&D.typeIconSelected),re=M.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",P&&D.nameDirectory,(p||T)&&D.nameSelected),L=xr({isDirectory:P,isExpanded:o,showExpandIcons:U,useCanvasExpandIcons:Z,expandIconSize:ne}),de=(P?ae:J)?Sr({entry:e,isDirectory:P,isExpanded:o,isSelected:p,isItemSelected:T,extension:se,mimeType:e.mimeType},_):null,K={indentLevel:t,isDirectory:P,isExpanded:o},[ve,...V]=b,Oe=ve?.render?ve.render(e,K):e.label??e.name,ke={...ce?B?.hoverStyle:{},...P&&p?B?.directorySelectedStyle:{},...!P&&(p||T)?B?.itemSelectedStyle:{}};return u.jsxs("div",{className:ue,style:{height:S,...ke,...e.style},role:"row","aria-expanded":P?o:void 0,"aria-level":t+1,"aria-posinset":r,"aria-setsize":n,"aria-rowindex":s,"aria-selected":x==="none"?void 0:j,"aria-current":w?"page":void 0,...Er(e.data),"data-entry-type":P?"directory":"file","data-entry-expanded":P?String(o):void 0,"data-entry-selected":p?"true":void 0,"data-entry-item-selected":T?"true":void 0,onClick:ie,onMouseEnter:()=>Y(!0),onMouseLeave:()=>Y(!1),onFocus:z=>i(c,e.absolutePath,z.currentTarget),onBlur:z=>f(e.absolutePath,z.currentTarget),onKeyDown:z=>{if(z.key==="Enter"){if(z.repeat){z.preventDefault();return}ie(z)}},tabIndex:0,children:[u.jsxs("div",{className:M.twMerge("dt-grid-name-cell",ve?.className),role:"gridcell",style:{width:N,paddingLeft:Math.max(0,t*te)},children:[(U||Z)&&u.jsx("span",{className:Te,style:le,children:L}),(P?ae:J)&&u.jsx("span",{className:Ee,children:de}),u.jsx("span",{className:re,children:Oe})]}),V.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:Cr(E,k),children:V.map(z=>u.jsx("div",{className:M.twMerge("dt-grid-cell",Rr(z.align),z.className),role:"gridcell",children:z.render?z.render(e,K):null},z.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=hr(e.entry,e.isDirOpen),n=hr(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});Ir.displayName="DirectoryTreeGridRow";const jr=({kind:e,columns:t,numericTemplate:r,numericTotal:n,nameWidth:s,scrollBarWidth:c,className:i,nameContent:f,renderCell:j})=>{const[,...S]=t,m=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",b=e==="header"?"dt-grid-header":"dt-grid-footer",k=e==="header"?"columnheader":"gridcell";return u.jsxs("div",{className:M.twMerge(b,"text-gray-600 dark:text-gray-300",i),role:"row",children:[u.jsx("div",{className:M.twMerge(m,"px-1",t[0]?.className),role:k,style:{width:s},children:f}),S.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:Cr(n,r),children:S.map(E=>u.jsx("div",{className:M.twMerge("dt-grid-cell",Rr(E.align),E.className),role:k,children:j(E)},E.key))})}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},sn=({columns:e,className:t,...r})=>u.jsx(jr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...r}),pr=(e,t)=>typeof e=="function"?e(t):e??null,on=({columns:e,allEntries:t,className:r,...n})=>u.jsx(jr,{kind:"footer",columns:e,className:r,nameContent:pr(e[0]?.footer,t),renderCell:s=>pr(s.footer,t),...n}),an=240,Tr=96,Nr=12,It=(e,t)=>{const r=e?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:t},ln=e=>e.slice(1).map(t=>`${It(t,Tr)}px`).join(" "),cn=({measuredWidth:e,columns:t,scrollBarWidth:r=Nr})=>{const n=It(t[0],an),s=t.slice(1).reduce((j,S)=>j+It(S,Tr),0),c=Number.isFinite(e)&&e>0?e:0,i=Math.max(0,c-n-Math.max(0,r)),f=Math.max(0,s-i);return{nameWidth:n,numericTotal:s,numericVisible:i,maxHScroll:f}},Rt=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,un=e=>{const t=[],r=n=>{for(const s of n)t.push(s),s.children&&s.children.length>0&&r(s.children)};return r(e),t},Pr=["entryKindDirectory","entryKindFile"],jt=[...pe.VIRTUAL_SCROLL_LABEL_KEYS,...Pr],Tt=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),_r=Object.freeze({en:Object.freeze({...pe.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Tt.en}),ja:Object.freeze({...pe.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Tt.ja})}),br=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,dn=e=>{const t={};let r=!1;for(const n of pe.VIRTUAL_SCROLL_LABEL_KEYS){const s=Object.hasOwn(e,n)?e[n]:void 0;s!==void 0&&(t[n]=s,r=!0)}return r?t:void 0},Ar=(e,t)=>{const r=pe.resolveVirtualScrollLocale(e);if(t===void 0)return _r[r];if(t===null||typeof t!="object")throw new RangeError(`[directory-tree] labels must be an object; got ${br(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 i of Object.keys(t))if(!jt.includes(i))throw new RangeError(`[directory-tree] labels.${i} is not a known label key; expected one of ${jt.join(", ")}`);const c={...pe.resolveVirtualScrollLabels(r,dn(t)),...Tt[r]};for(const i of Pr){const f=Object.hasOwn(t,i)?t[i]:void 0;if(f!==void 0){if(typeof f!="string"||f.trim()==="")throw new RangeError(`[directory-tree] labels.${i} must be a non-blank string; got ${br(f)}`);c[i]=f}}return Object.freeze(c)},fn=e=>{const t={};for(const r of pe.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},mn=()=>{let e=null;return{mark:t=>{const r=t.composedPath();e=r,setTimeout(()=>{e===r&&(e=null)},0)},landedOn:t=>e?.includes(t)===!0}},hn=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,s=r-1,c=0;for(;n<=s;){const i=n+s>>>1;e[i]<=t?(c=i,n=i+1):s=i-1}return c},pn=(e,t,r)=>{if(r<=0||e.length===0||t.length!==e.length+1)return null;const n=hn(t,r),s=e[n];return s?{path:s.entry.absolutePath,offsetInViewport:r-t[n]}:null},bn=(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},yn=(e,t,r)=>{const n=[];for(let s=t;s<r;s++){const c=e[s];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},gn=(e,t,r)=>{const n=[];for(let s=t;s<r;s++){const c=e[s];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},wn=(e,t,r,n)=>{const s=Math.max(1,Math.floor(t*n)),c=Math.max(1,Math.floor(r*n));(e.width!==s||e.height!==c)&&(e.width=s,e.height=c);const i=e.style;i.width!==`${t}px`&&(i.width=`${t}px`),i.height!==`${r}px`&&(i.height=`${r}px`)},vn=(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()},xn=(e,t)=>{const r=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!r)return null;let n=r[1];n.length===3&&(n=n.split("").map(f=>f+f).join(""));const s=Number.parseInt(n.slice(0,2),16),c=Number.parseInt(n.slice(2,4),16),i=Number.parseInt(n.slice(4,6),16);return`rgba(${s}, ${c}, ${i}, ${t})`},Sn=(e,t,r,n)=>{if(t.length===0)return;const s=xn(r,.14),c=e.strokeStyle,i=e.fillStyle,f=e.lineWidth,j=e.lineCap,S=e.lineJoin;e.strokeStyle=r,e.lineCap="round",e.lineJoin="round";for(const m of t){const b=n??m.size,k=Math.max(0,b/2),E=Math.max(1,Math.round(b*.08)),N=Math.max(1,Math.round(b*.14)),h=Math.max(0,k-E*.8),v=Math.max(0,h*.55);s&&(e.fillStyle=s,e.beginPath(),e.arc(m.centerX,m.centerY,h,0,Math.PI*2),e.fill()),e.lineWidth=E,e.beginPath(),e.arc(m.centerX,m.centerY,Math.max(0,k-E*.3),0,Math.PI*2),e.stroke(),e.lineWidth=N,e.beginPath(),e.moveTo(m.centerX-v,m.centerY),e.lineTo(m.centerX+v,m.centerY),e.stroke(),m.isExpanded||(e.beginPath(),e.moveTo(m.centerX,m.centerY-v),e.lineTo(m.centerX,m.centerY+v),e.stroke())}e.strokeStyle=c,e.fillStyle=i,e.lineWidth=f,e.lineCap=j,e.lineJoin=S},Mr=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:s,scrollPosition:c,color:i="#a0aec0",strokeWidth:f=1,renderStartIndex:j,renderEndIndex:S,lookaheadEndIndex:m,devicePixelRatio:b,expandGlyphColor:k,expandGlyphSize:E})=>{const N=l.useRef(null),h=l.useRef(null),v=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:s,scrollPosition:c,color:i,strokeWidth:f,renderStartIndex:j,renderEndIndex:S,lookaheadEndIndex:m,devicePixelRatio:b,expandGlyphColor:k,expandGlyphSize:E}),R=l.useCallback(()=>{h.current=null;const x=N.current;if(!x)return;const C=x.getContext("2d");if(!C)return;const y=v.current;if(y.width<=0||y.viewportHeight<=0){C.clearRect(0,0,x.width,x.height);return}const W=Number.isFinite(y.devicePixelRatio??NaN)?y.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;wn(x,y.width,y.viewportHeight,W);const F=y.segmentsByItem.length,_=typeof y.renderStartIndex=="number"&&Number.isFinite(y.renderStartIndex)?Math.max(0,Math.floor(y.renderStartIndex)):Math.max(0,Math.floor(y.scrollPosition/y.itemHeight)),U=Math.min(F,Math.ceil((y.scrollPosition+y.viewportHeight)/y.itemHeight)),ae=(()=>{if(typeof y.renderEndIndex=="number"&&Number.isFinite(y.renderEndIndex)){const te=Math.floor(y.renderEndIndex);return Math.max(Math.min(F,te+1),_)}return Math.max(U,_)})(),J=(()=>{if(typeof y.lookaheadEndIndex=="number"&&Number.isFinite(y.lookaheadEndIndex)){const te=Math.floor(y.lookaheadEndIndex),B=Math.min(F,te+1);return Math.max(B,ae)}return Math.max(U,ae)})(),Z=yn(y.segmentsByItem,_,J),ne=gn(y.glyphsByItem,_,J);C.save(),C.scale(W,W),C.clearRect(0,0,y.width,y.viewportHeight),C.translate(0,-y.scrollPosition),C.strokeStyle=y.color,vn(C,Z,y.strokeWidth),Sn(C,ne,y.expandGlyphColor??y.color,y.expandGlyphSize),C.restore()},[]),$=l.useCallback(()=>{h.current===null&&(h.current=window.requestAnimationFrame(R))},[R]);return l.useEffect(()=>{v.current={segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:s,scrollPosition:c,color:i,strokeWidth:f,renderStartIndex:j,renderEndIndex:S,lookaheadEndIndex:m,devicePixelRatio:b,expandGlyphColor:k,expandGlyphSize:E},$()},[e,t,r,n,s,c,i,f,j,S,m,b,k,E,$]),l.useEffect(()=>()=>{h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null)},[]),u.jsx("canvas",{ref:N,className:"pointer-events-none absolute top-0 left-0 z-0"})});Mr.displayName="TreeLineCanvas";const En=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},yr=(e,t)=>e.selectedPath===t?e:{selectedPath:t,selectionGeneration:e.selectionGeneration+1,anchor:e.anchor},kn=(e,t)=>({...e,anchor:{path:t,selectionGeneration:e.selectionGeneration,focused:!0}}),Rn=(e,t)=>{const{anchor:r,selectionGeneration:n,selectedPath:s}=t;if(r!==null&&(r.focused||r.selectionGeneration===n)){const c=e.get(r.path);if(c!==void 0)return c}if(s!==null){const c=e.get(s);if(c!==void 0)return c}return 0},Cn={msOverflowStyle:"none",scrollbarWidth:"none"},In=()=>{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))},jn=e=>{const t=l.useRef(null),r=t.current;return r!==null&&pe.VIRTUAL_SCROLL_LABEL_KEYS.every(n=>r[n]===e[n])?r:(t.current=e,e)},gr=new Set(["top","bottom","center","nearest"]),wr=e=>{const t=e?.align;if(t===void 0)return"top";if(!gr.has(t))throw new RangeError(`[directory-tree] Unsupported scroll alignment ${JSON.stringify(t)}; expected one of ${[...gr].join(", ")}.`);return t},Tn={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},Nn=(e,t,r,n,s)=>{const c=[],i=[];let f=0;const j=(S,m,b)=>{const k=s?[...S].sort(s):S;for(let E=0;E<k.length;E++){const N=k[E],h=E===k.length-1,v=[...b,h],R=N.children!==void 0,$=R&&t(N.absolutePath,N.relativePath);let x=m,C=v,y=b;n&&(x=m-1,C=v.slice(1),y=b.slice(1)),c.push({entry:N,indentLevel:x,depth:m,positionInSet:E+1,setSize:k.length,parentIsLast:C}),r&&(x>f&&(f=x),i.push({id:N.absolutePath,name:N.name,absolutePath:N.absolutePath,indentLevel:x,isLastChild:h,isDirectory:R,isExpanded:$,ancestorIsLast:[...y],hideLines:n&&m===0})),R&&$&&N.children&&j(N.children,m+1,v)}};return j(e,0,[]),{flatItems:c,lineItems:i,maxIndent:f}},vr=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,s=r-1,c=0;for(;n<=s;){const i=n+s>>>1;e[i]<=t?(c=i,n=i+1):s=i-1}return c},Pn=(e,t,r,n,s,c)=>{const i=n?.renderStart??Math.max(0,vr(c,s)),f=t>0?vr(c,s+t)+r:i+r,j=e>0?Math.min(e-1,Math.max(i,f)):i,S=n?.renderEnd??j,m=e>0?Math.min(e-1,S+r):S;return{renderStart:i,renderEnd:S,lookaheadEnd:m}},_n=(e,t,r,n,s,c)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const i=Array.from({length:e.length},()=>[]),f=Array.from({length:e.length},()=>[]),j=m=>s?typeof c=="number"&&Number.isFinite(c)&&c>0?c:Math.max(8,Math.min(n*.9,m*.7)):0,S=3;for(let m=0;m<e.length;m++){const b=e[m];if(b.hideLines)continue;const k=[],E=t[m]??0,N=r[m]??0,h=N+E/2,v=j(E),R=v>0?v/2+2:n/1.5;for(let C=0;C<b.indentLevel;C++){if(b.ancestorIsLast[C]??!1)continue;let W=!1;for(let F=m;F<e.length;F++){const _=e[F];if(_.indentLevel>C&&_.ancestorIsLast.length>C&&!_.ancestorIsLast[C]){W=!0;break}if(F>m&&_.indentLevel===C)break}if(W){const F=C*n+n/2+S;k.push({key:`${b.id}-ancestor-${C}`,x1:F,y1:N,x2:F,y2:N+E,itemIndex:m})}}const $=b.indentLevel*n,x=$+n/2+S;if(b.isDirectory?k.push({key:`${b.id}-connector-top`,x1:x,y1:N,x2:x,y2:h-R,itemIndex:m}):k.push({key:`${b.id}-connector-top`,x1:x,y1:N,x2:x,y2:h,itemIndex:m}),!b.isDirectory&&b.isLastChild&&k.push({key:`${b.id}-connector-horizontal`,x1:x,y1:h,x2:$+n+S,y2:h,itemIndex:m}),b.isLastChild||(b.isDirectory?k.push({key:`${b.id}-connector-bottom`,x1:x,y1:h+R,x2:x,y2:N+E,itemIndex:m}):k.push({key:`${b.id}-connector-bottom`,x1:x,y1:h,x2:x,y2:N+E,itemIndex:m})),i[m]=k,s&&b.isDirectory){const C=v,y=x,W=h;f[m]=[{key:`${b.id}-glyph`,itemIndex:m,centerX:y,centerY:W,size:C,isExpanded:b.isExpanded}]}}return{segmentsByItem:i,glyphsByItem:f}},Nt=l.memo(({entry:e,indentLevel:t,depth:r,positionInSet:n,setSize:s,isSelectedForAria:c,flatIndex:i,isActive:f,registerRowRef:j,onNavigationKeyDown:S,onRowFocus:m,onRowBlur:b,rowHeight:k,entryKindDirectory:E,entryKindFile:N,isDirOpen:h,parentIsLast:v,renderChildren:R=!0,expansion:{toggleDirectory:$,onToggleDirectoryRecursive:x},selection:{onEntryClick:C,selectedPath:y,currentPath:W,mode:F="none",selectedItems:_,onSelectionChange:U},visual:{iconOverrides:ae,showExpandIcons:J=!0,showDirectoryIcons:Z=!0,showFileIcons:ne=!0,useCanvasExpandIcons:te=!1,expandIconSize:B,typeIconSize:me,fontSize:le,indentSize:ce=ct,highlightStyles:Y,entryClassName:P,entryStyle:o,nameClassName:p,nameStyle:w,directoryNameClassName:T,directoryNameStyle:se,fileNameClassName:ie,fileNameStyle:A,expandIconClassName:Q,expandIconStyle:he}})=>{const[ue,Te]=l.useState(null),[Ee,re]=l.useState(!1),L=e.children!==void 0,de=L&&h(e.absolutePath),K=e.absolutePath===y,ve=e.absolutePath===W,V=!L&&_?.has(e.absolutePath),Oe=l.useCallback(G=>j(i,G),[j,i]),ke=L?void 0:je(e.name)||je(e.relativePath)||je(e.absolutePath);l.useEffect(()=>{Te(de&&e.children?e.children:null)},[de,e.children]);const z=kr({entry:e,isDirectory:L,isExpanded:de,isItemSelected:!!V,selectionMode:F,onSelectionChange:U,onEntryClick:C,toggleDirectory:$,onToggleDirectoryRecursive:x}),it=Ee?Y?.hoverClassName!==void 0?Y.hoverClassName:D.entryHover:"",De=(()=>{if(L){if(K)return Y?.directorySelectedClassName!==void 0?Y.directorySelectedClassName:D.entrySelected}else if(K||V)return Y?.itemSelectedClassName!==void 0?Y.itemSelectedClassName:M.twMerge(K&&D.entrySelected,V&&D.entryItemSelected);return""})(),Fe=M.twMerge(D.entry,it,De,P,e.className),Ge=M.twMerge(D.expandIcon,Q,(K||V)&&D.expandIconSelected),ut=M.twMerge(D.typeIcon,(K||V)&&D.typeIconSelected),Ne=M.twMerge(D.name,p,L&&D.nameDirectory,L&&T,!L&&ie,(K||V)&&D.nameSelected),Ve=xr({isDirectory:L,isExpanded:de,showExpandIcons:J,useCanvasExpandIcons:te,expandIconSize:B}),Ue=(L?Z:ne)?Sr({entry:e,isDirectory:L,isExpanded:de,isSelected:K,isItemSelected:!!V,extension:ke,mimeType:e.mimeType},ae):null,Ke={...Ee?Y?.hoverStyle:{},...L&&K?Y?.directorySelectedStyle:{},...!L&&(K||V)?Y?.itemSelectedStyle:{}},Xe=Er(e.data),Je=me?{width:me,height:me}:void 0,$e=le?{fontSize:typeof le=="number"?`${le}px`:le}:void 0;return u.jsxs(l.Fragment,{children:[u.jsxs("div",{className:Fe,style:{paddingLeft:`${Math.max(0,t*ce)}px`,transform:t<0?`translateX(${t*ce}px)`:void 0,width:t<0?`calc(100% + ${Math.abs(t*ce)}px)`:void 0,height:`${k}px`,...$e,...Ke,...o,...e.style},...Xe,"data-entry-type":L?"directory":"file","data-entry-expanded":L?String(de):void 0,"data-entry-selected":K?"true":void 0,"data-entry-item-selected":V?"true":void 0,onClick:z,onMouseEnter:()=>re(!0),onMouseLeave:()=>re(!1),onFocus:G=>m(i,e.absolutePath,G.currentTarget),onBlur:G=>b(e.absolutePath,G.currentTarget),ref:Oe,onKeyDown:G=>{if(G.key==="Enter"||G.key===" "){G.preventDefault(),G.repeat||z(G);return}S(G,i)},tabIndex:f?0:-1,role:"treeitem","aria-expanded":L?de:void 0,"aria-level":r+1,"aria-posinset":n,"aria-setsize":s,"aria-selected":F==="none"?void 0:c,"aria-current":ve?"page":void 0,"aria-label":`${e.name} (${L?E:N})`,children:[(J||te)&&u.jsx("span",{className:Ge,style:he,children:Ve}),(L?Z:ne)&&u.jsx("span",{className:ut,style:Je,children:Ue}),u.jsx("span",{className:Ne,style:{...$e,...w,...L?se:A},"data-entry-type":L?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),de&&ue&&R&&u.jsx("fieldset",{children:ue.map((G,ye)=>u.jsx(Nt,{entry:G,indentLevel:t+1,depth:r+1,positionInSet:ye+1,setSize:ue.length,isSelectedForAria:!!_?.has(G.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:j,onNavigationKeyDown:S,onRowFocus:m,onRowBlur:b,rowHeight:k,entryKindDirectory:E,entryKindFile:N,isDirOpen:h,parentIsLast:[...v,ye===ue.length-1],expansion:{toggleDirectory:$,onToggleDirectoryRecursive:x},selection:{onEntryClick:C,selectedPath:y,currentPath:W,mode:F,selectedItems:_,onSelectionChange:U},visual:{iconOverrides:ae,showExpandIcons:J,showDirectoryIcons:Z,showFileIcons:ne,useCanvasExpandIcons:te,expandIconSize:B,highlightStyles:Y,entryClassName:P,entryStyle:o,nameClassName:p,nameStyle:w,directoryNameClassName:T,directoryNameStyle:se,fileNameClassName:ie,fileNameStyle:A,expandIconClassName:Q,expandIconStyle:he}},G.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const r=e.entry.children!==void 0,n=t.entry.children!==void 0,s=r&&e.isDirOpen(e.entry.absolutePath),c=n&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&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&&s===c&&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.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&&e.parentIsLast.length===t.parentIsLast.length&&e.parentIsLast.every((i,f)=>i===t.parentIsLast[f])});Nt.displayName="DirectoryEntryItem";const Lr=e=>{const t=[];if(e.children)for(const r of e.children)r.type==="directory"&&(t.push(r.absolutePath),t.push(...Lr(r)));return t},An=({entries:e,expansion:{toggle:t,isExpanded:r,expandMultiple:n,collapseMultiple:s,isPending:c,alwaysExpanded:i=!1,doubleClickAction:f="recursive"},selection:{onEntryClick:j,selectedPath:S,currentPath:m,mode:b="none",selectedItems:k,onSelectionChange:E},visual:{className:N,style:h,ariaLabel:v,ariaLabelledBy:R,lineColor:$="#A0AEC0",showTreeLines:x=!0,showExpandIcons:C=!0,showDirectoryIcons:y=!0,showFileIcons:W=!0,iconOverrides:F,expandIconSize:_,itemHeight:U=lt,removeRootIndent:ae=!1,highlightStyles:J,entryClassName:Z,entryStyle:ne,nameClassName:te,nameStyle:B,directoryNameClassName:me,directoryNameStyle:le,fileNameClassName:ce,fileNameStyle:Y,expandIconClassName:P,expandIconStyle:o}={},virtualScroll:p,grid:w,sort:T,locale:se,labels:ie,ref:A})=>{const Q=pe.resolveVirtualScrollLocale(se),he=l.useMemo(()=>Ar(se,ie),[se,ie]),ue=jn(fn(he)),{entryKindDirectory:Te,entryKindFile:Ee}=he,re=w!==void 0,[L,de]=l.useState(!1),K=l.useRef(null),ve=l.useRef(null),V=l.useRef(null),[Oe,ke]=l.useState(0),[z,it]=l.useState(0),[De,Fe]=l.useState(0),[Ge,ut]=l.useState(null),{overscanCount:Ne=15,className:Ve,background:Ue,onScroll:Ke,onRangeChange:Xe,onScrollAdjust:Je,liveRegion:$e,initialScrollIndex:G,initialScrollOffset:ye,initialScrollAnchor:Pt,callbackThrottleMs:_t=5,contentInsets:At,onItemFocus:Mt,viewportHeightOverride:oe,scrollBarOptions:dt,behaviorOptions:Lt,preserveScrollAnchor:Ot=!1,getItemKey:Or,testId:Dt,contentProps:ft}=p??{},Ft=l.useMemo(()=>re?{...ft,role:"rowgroup"}:{...ft,role:"tree","aria-label":R?void 0:v,"aria-labelledby":R,"aria-multiselectable":b==="multiple"?!0:void 0},[re,ft,v,R,b]),$t=l.useMemo(()=>({...Lt,enableKeyboardNavigation:!1}),[Lt]),[qe,Bt]=l.useState(typeof ye=="number"?ye:0),mt=l.useRef(typeof ye=="number"?ye:0),Ht=l.useCallback((a,d)=>{mt.current=a,Bt(a),Ke?.(a,d)},[Ke]),Wt=l.useCallback(a=>{const{renderingStartIndex:d,renderingEndIndex:g}=a;ut(I=>I&&I.renderStart===d&&I.renderEnd===g?I:{renderStart:d,renderEnd:g}),Xe?.(a)},[Xe]);l.useEffect(()=>{de(!0),In()},[]),l.useEffect(()=>{const a=K.current,d=re?ve.current:a,g=()=>{if(a){const H=a.clientWidth;it(q=>Math.abs(q-H)>1?H:q)}if(typeof oe=="number")ke(H=>Math.abs(H-oe)>1?oe:H);else if(d){const H=d.clientHeight;ke(q=>Math.abs(q-H)>1?H:q)}};if(!(a||d))return ke(0);g();const I=new ResizeObserver(g);return a&&I.observe(a),d&&d!==a&&I.observe(d),()=>I.disconnect()},[oe,re]);const Pe=typeof oe=="number"?oe:Oe,be=l.useCallback(a=>i||(L?r(a):!1),[L,r,i]),zt=M.twMerge(D.container,c&&D.containerPending,N),Yt=l.useMemo(()=>({...Cn,...h??{},...typeof oe=="number"?{height:oe,minHeight:oe}:{}}),[h,oe]),ht=l.useCallback((a,d)=>{const g=[a.absolutePath,...Lr(a)],I=d||f;if(g.every(we=>be(we)))return s(g);if(g.every(we=>!be(we))||I==="recursive")return n(g);if(I==="toggle")return s(g);console.warn(`[DirectoryTree] Unknown double click action: ${I}. No action taken.`)},[be,n,s,f]),Gt=re?!1:ae,{flatItems:Re,lineItems:pt,maxIndent:Vt}=l.useMemo(()=>Nn(e,be,x,Gt,T),[e,be,x,Gt,T]),X=l.useMemo(()=>Re.map((a,d)=>{const g=typeof U=="function"?U(a.entry,d):U;return{...a,rowHeight:Number.isFinite(g)&&g>0?g:lt}}),[Re,U]),xe=l.useMemo(()=>X.map(a=>a.rowHeight),[X]),Ce=l.useMemo(()=>{const a=new Array(xe.length+1);a[0]=0;for(let d=0;d<xe.length;d++)a[d+1]=a[d]+xe[d];return a},[xe]),Ut=l.useCallback(a=>X[a]?.rowHeight??lt,[X]),Dr=l.useCallback(a=>X[a]?.entry.absolutePath??a,[X]),Kt=Or??Dr,_e=S??null,bt=m??null,[Xt,Be]=l.useState(()=>({selectedPath:_e,selectionGeneration:0,anchor:null})),yt=yr(Xt,_e);yt!==Xt&&Be(a=>yr(a,_e));const Ze=l.useMemo(()=>En(Re),[Re]),Ae=l.useMemo(()=>Rn(Ze,yt),[Ze,yt]),He=l.useRef(new Map),Qe=l.useRef(null),[et]=l.useState(mn),We=l.useRef(null),[Fr,Jt]=l.useState(!0),gt=l.useRef(Re);gt.current=Re;const qt=l.useRef(be);qt.current=be;const wt=l.useRef(t);wt.current=t;const Zt=l.useRef(Ze);Zt.current=Ze;const vt=l.useRef(Ae);vt.current=Ae;const Qt=l.useRef(Mt);Qt.current=Mt;const Ie=l.useCallback(a=>{const d=V.current;return!d||d.getViewportSize()<=0?!1:(d.scrollToIndex(a,{align:"nearest"}),!0)},[]),ge=l.useCallback(a=>{const d=He.current.get(a);if(d===void 0){We.current=a,Ie(a)||(We.current=null);return}We.current=null,Ie(a),d.focus({preventScroll:!0})},[Ie]),er=l.useCallback((a,d)=>{if(d)He.current.set(a,d),We.current===a?(We.current=null,d.focus({preventScroll:!0})):d.contains(d.ownerDocument.activeElement)&&Be(g=>g.anchor===null?g:{...g,anchor:{...g.anchor,focused:!0}});else{const g=He.current.get(a);He.current.delete(a),g?.contains(g.ownerDocument.activeElement)&&Be(I=>I.anchor===null?I:{...I,anchor:{...I.anchor,focused:!1}})}a===vt.current&&Jt(d!==null)},[]);l.useLayoutEffect(()=>{Jt(He.current.has(Ae))},[Ae]);const xt=l.useCallback((a,d,g)=>{const I=Qe.current===g;Qe.current=null,I||(Be(H=>kn(H,d)),et.landedOn(g)||Ie(a)),Qt.current?.(a)},[Ie,et]),tt=l.useCallback(a=>et.mark(a.nativeEvent),[et]),St=l.useCallback((a,d)=>{const{ownerDocument:g}=d;if(!g.hasFocus()&&d.contains(g.activeElement)){Qe.current=d;return}Qe.current=null,Be(I=>I.anchor!==null&&I.anchor.path===a?{...I,anchor:{...I.anchor,focused:!1}}:I)},[]),$r=l.useCallback(()=>ge(vt.current),[ge]),Et=l.useCallback((a,d)=>{const g=wr(d),I=gt.current.length;if(!Number.isInteger(a)||a<0||a>=I)throw new RangeError(`[directory-tree] scrollToIndex: ${String(a)} is not a row index (${I===0?"the tree has no rows":`expected an integer in 0..${String(I-1)}`}).`);if(g==="nearest"){Ie(a);return}V.current?.scrollToIndex(a,{align:g})},[Ie]);l.useImperativeHandle(A,()=>({scrollToIndex:Et,scrollToPath:(a,d)=>{wr(d);const g=Zt.current.get(a);return g===void 0?!1:(Et(g,d),!0)},getScrollAnchor:()=>V.current?.getScrollAnchor()??null}),[Et]);const tr=l.useCallback((a,d)=>{if(a.altKey||a.ctrlKey||a.metaKey)return;const g=gt.current,I=g.length-1;if(I<0)return;const H=g[d],q=H?.entry.children!==void 0,we=q&&qt.current(H.entry.absolutePath);switch(a.key){case"ArrowDown":a.preventDefault(),ge(Math.min(d+1,I));break;case"ArrowUp":a.preventDefault(),ge(Math.max(d-1,0));break;case"Home":a.preventDefault(),ge(0);break;case"End":a.preventDefault(),ge(I);break;case"ArrowRight":a.preventDefault(),q&&!we?wt.current(H.entry.absolutePath):q&&d<I&&g[d+1].depth>H.depth&&ge(d+1);break;case"ArrowLeft":{if(a.preventDefault(),q&&we){wt.current(H.entry.absolutePath);break}const Yr=H?.depth??0;for(let ot=d-1;ot>=0;ot--)if(g[ot].depth<Yr){ge(ot);break}break}}},[ge]),rt=l.useMemo(()=>!x||pt.length===0?{segmentsByItem:[],glyphsByItem:[]}:_n(pt,xe,Ce,ct,x,_??mr),[pt,xe,Ce,x,_]),nt=l.useMemo(()=>!x||e.length===0?0:(Vt+2)*ct,[e.length,Vt,x]),{renderStart:rr,renderEnd:nr,lookaheadEnd:sr}=l.useMemo(()=>Pn(X.length,Pe,Ne,Ge,qe,Ce),[X.length,Pe,Ne,Ge,qe,Ce]),kt=l.useMemo(()=>!x||nt<=0||Pe<=0||rt.segmentsByItem.length===0?null:u.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:u.jsx("div",{className:"absolute top-0 left-0",style:{width:nt,height:Pe},children:u.jsx(Mr,{segmentsByItem:rt.segmentsByItem,glyphsByItem:rt.glyphsByItem,itemHeight:xe[0]??lt,width:nt,viewportHeight:Pe,scrollPosition:qe,color:$,expandGlyphColor:$,expandGlyphSize:_??mr,renderStartIndex:rr,renderEndIndex:nr,lookaheadEndIndex:sr})})}),[nt,Pe,rr,nr,sr,qe,rt,$,x,_,xe]),or=l.useCallback(a=>X[a],[X]),ar=l.useRef(null);l.useLayoutEffect(()=>{const a=ar.current;if(ar.current={items:X,offsets:Ce},!Ot||!a||a.items===X)return;const d=V.current,g=d?.getScrollPosition(),I=typeof g=="number"&&g>=0?g:mt.current,H=pn(a.items,a.offsets,I);if(!H)return;const q=bn(H,X,Ce);if(q===null||Math.abs(q-I)<1)return;const we=d?d.scrollTo(q):q;mt.current=we,Bt(we)},[X,Ce,Ot]);const Se=w?.columns,Me=w?.scrollBarWidth??dt?.width??Nr,ee=l.useMemo(()=>Se?cn({measuredWidth:z,columns:Se,scrollBarWidth:Me}):null,[Se,z,Me]),st=l.useMemo(()=>Se?ln(Se):"",[Se]),Br=l.useMemo(()=>w?.showFooter&&Se?un(e):[],[w?.showFooter,Se,e]),Le=ee?.maxHScroll??0;l.useEffect(()=>{Fe(a=>Rt(a,Le))},[Le]);const lr=l.useCallback(a=>Fe(d=>Rt(d+a,Le)),[Le]),cr=l.useMemo(()=>({iconOverrides:F,showExpandIcons:C,showDirectoryIcons:y,showFileIcons:W,useCanvasExpandIcons:x,expandIconSize:_,highlightStyles:J,expandIconClassName:P,expandIconStyle:o}),[F,C,y,W,x,_,J,P,o]),ir=l.useMemo(()=>u.jsx(pe.VirtualScroll,{ref:V,itemCount:X.length,getItem:or,getItemHeight:Ut,getItemKey:Kt,testId:Dt,contentProps:Ft,locale:Q,labels:ue,viewportSize:typeof oe=="number"?oe:void 0,overscanCount:Ne,onScroll:Ht,onRangeChange:Wt,onScrollAdjust:Je,liveRegion:$e,className:Ve,onWheelHorizontal:re?lr:void 0,background:u.jsxs(u.Fragment,{children:[re&&ee?u.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:ee.nameWidth},"aria-hidden":"true",children:kt}):kt,Ue]}),initialScrollIndex:G,initialScrollOffset:ye,initialScrollAnchor:Pt,callbackThrottleMs:_t,contentInsets:At,scrollBarOptions:dt,behaviorOptions:$t,children:(a,d)=>a?re&&w&&ee?u.jsx(Ir,{entry:a.entry,indentLevel:a.indentLevel,positionInSet:a.positionInSet,setSize:a.setSize,rowIndex:d+(w.showHeader??!0?2:1),flatIndex:d,onRowFocus:xt,onRowBlur:St,isSelectedForAria:!!k?.has(a.entry.absolutePath),rowHeight:a.rowHeight,isDirOpen:be,columns:w.columns,numericTemplate:st,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,rowClassName:w.rowClassName,selection:{onEntryClick:j,selectedPath:_e,currentPath:bt,mode:b,selectedItems:k,onSelectionChange:E},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ht},visual:cr},a.entry.absolutePath):u.jsx(Nt,{entry:a.entry,indentLevel:a.indentLevel,depth:a.depth,positionInSet:a.positionInSet,setSize:a.setSize,isSelectedForAria:!!k?.has(a.entry.absolutePath),flatIndex:d,isActive:d===Ae,registerRowRef:er,onNavigationKeyDown:tr,onRowFocus:xt,onRowBlur:St,rowHeight:a.rowHeight,entryKindDirectory:Te,entryKindFile:Ee,isDirOpen:be,parentIsLast:a.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ht},selection:{onEntryClick:j,selectedPath:_e,currentPath:bt,mode:b,selectedItems:k,onSelectionChange:E},visual:{iconOverrides:F,showExpandIcons:C,showDirectoryIcons:y,showFileIcons:W,useCanvasExpandIcons:x,expandIconSize:_,highlightStyles:J,entryClassName:Z,entryStyle:ne,nameClassName:te,nameStyle:B,directoryNameClassName:me,directoryNameStyle:le,fileNameClassName:ce,fileNameStyle:Y,expandIconClassName:P,expandIconStyle:o}},a.entry.absolutePath):null}),[X.length,or,Ut,Kt,Dt,Ft,Q,ue,Te,Ee,Ae,er,tr,xt,St,oe,Ne,Ht,Wt,Je,$e,Ve,re,lr,ee,kt,Ue,G,ye,Pt,_t,At,dt,$t,w,st,be,j,_e,bt,b,k,E,t,ht,cr,F,C,y,W,x,_,J,Z,ne,te,B,me,le,ce,Y,P,o]);if(!(w&&ee))return u.jsxs("div",{ref:K,className:zt,style:Yt,onPointerDownCapture:tt,onMouseDownCapture:tt,children:[Re.length>0&&!Fr&&u.jsx("span",{tabIndex:0,"data-directory-tree-tab-stop":"",style:Tn,onFocus:$r}),ir]});const Hr=w.showHeader??!0,Wr=w.showFooter??!1,zr={...Yt,"--dt-hscroll":`${De}px`};return u.jsxs("div",{ref:K,className:M.twMerge(zt,"dt-grid"),style:zr,role:"treegrid","aria-label":R?void 0:v,"aria-labelledby":R,"aria-multiselectable":b==="multiple"?!0:void 0,"aria-rowcount":X.length+(w.showHeader??!0?1:0),onPointerDownCapture:tt,onMouseDownCapture:tt,children:[Hr&&u.jsx("div",{role:"rowgroup",children:u.jsx(sn,{columns:w.columns,numericTemplate:st,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Me,className:w.headerClassName})}),u.jsx("div",{ref:ve,className:"dt-grid-body",children:ir}),Le>0&&u.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:ee.nameWidth},"aria-hidden":"true"}),u.jsx(pe.ScrollBar,{horizontal:!0,contentSize:ee.numericTotal,viewportSize:ee.numericVisible,scrollPosition:De,scrollBarWidth:Me,locale:Q,labels:ue,onScroll:a=>{const d=typeof a=="function"?a(De):a,g=Rt(d,Le);return Fe(g),g}}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Me},"aria-hidden":"true"})]}),Wr&&u.jsx("div",{role:"rowgroup",children:u.jsx(on,{columns:w.columns,numericTemplate:st,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Me,allEntries:Br,className:w.footerClassName})})]})},Mn=({initialExpanded:e=new Set,storageKey:t}={})=>{const[r,n]=l.useTransition(),[s,c]=l.useState(()=>{if(typeof window<"u"&&t)try{const h=window.localStorage.getItem(t);if(h){const v=JSON.parse(h);return new Set(v)}}catch(h){console.error("[useDirectoryTreeState] Error reading from localStorage",h)}return e}),i=l.useCallback(h=>{n(()=>{c(v=>{const R=new Set(v);return h(R),R})})},[]),f=l.useCallback((h,v)=>{i(R=>{for(const $ of h)v(R,$)})},[i]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(s)))}catch(h){console.warn(`Error setting localStorage key "${t}":`,h)}},[s,t]);const j=l.useCallback(h=>{f([h],(v,R)=>{v.has(R)?v.delete(R):v.add(R)})},[f]),S=l.useCallback(h=>{f([h],(v,R)=>{v.add(R)})},[f]),m=l.useCallback(h=>{f([h],(v,R)=>{v.delete(R)})},[f]),b=l.useCallback(h=>{f(h,(v,R)=>{v.delete(R)})},[f]),k=l.useCallback(h=>{f(h,(v,R)=>{v.add(R)})},[f]),E=l.useCallback(()=>{i(h=>{h.clear()})},[i]),N=l.useCallback(h=>s.has(h),[s]);return{expanded:s,toggle:j,expand:S,collapse:m,collapseMultiple:b,expandMultiple:k,collapseAll:E,isExpanded:N,isPending:r}};exports.DIRECTORY_TREE_LABEL_CATALOGS=_r;exports.DIRECTORY_TREE_LABEL_KEYS=jt;exports.DirectoryTree=An;exports.directoryTreeClasses=D;exports.resolveDirectoryTreeLabels=Ar;exports.useDirectoryTreeState=Mn;
|
|
6
|
+
<%s key={someKey} {...props} />`,P,A,te,A),se[A+P]=!0)}if(A=null,p!==void 0&&(r(p),A=""+p),i(g)&&(r(g.key),A=""+g.key),"key"in g){p={};for(var me in g)me!=="key"&&(p[me]=g[me])}else p=g;return A&&u(p,typeof n=="function"?n.displayName||n.name||"Unknown":n),S(n,A,p,a(),B,he)}function m(n){y(n)?n._store&&(n._store.validated=1):typeof n=="object"&&n!==null&&n.$$typeof===j&&(n._payload.status==="fulfilled"?y(n._payload.value)&&n._payload.value._store&&(n._payload.value._store.validated=1):n._store&&(n._store.validated=1))}function y(n){return typeof n=="object"&&n!==null&&n.$$typeof===T}var E=l,T=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),F=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),_=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),D=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=Object.prototype.hasOwnProperty,ee=Array.isArray,oe=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(n){return n()}};var U,ce={},fe=E.react_stack_bottom_frame.bind(E,c)(),W=oe(o(c)),se={};ze.Fragment=x,ze.jsx=function(n,g,p){var P=1e4>D.recentlyCreatedOwnerStacks++;return v(n,g,p,!1,P?Error("react-stack-top-frame"):fe,P?oe(o(n)):W)},ze.jsxs=function(n,g,p){var P=1e4>D.recentlyCreatedOwnerStacks++;return v(n,g,p,!0,P?Error("react-stack-top-frame"):fe,P?oe(o(n)):W)}})()),ze}var hr;function qr(){return hr||(hr=1,process.env.NODE_ENV==="production"?at.exports=Xr():at.exports=Jr()),at.exports}var f=qr();function Zr({title:e,titleId:t,...r},o){return de.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:o,"aria-labelledby":t},r),e?de.createElement("title",{id:t},e):null,de.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 Qr=de.forwardRef(Zr);function en({title:e,titleId:t,...r},o){return de.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:o,"aria-labelledby":t},r),e?de.createElement("title",{id:t},e):null,de.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 tn=de.forwardRef(en);function rn({title:e,titleId:t,...r},o){return de.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:o,"aria-labelledby":t},r),e?de.createElement("title",{id:t},e):null,de.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 nn=de.forwardRef(rn),lt=44,ct=12,mr=8,_t=14,O={container:"directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"opacity-70",entry:"directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",entryHover:M.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:M.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:M.twMerge("directory-tree-entry--item-selected bg-blue-400/20 shadow-[0_0_0_1px_rgba(59,130,246,0.3)]","dark:bg-blue-400/25 dark:shadow-[0_0_0_1px_rgba(96,165,250,0.4)]"),expandIcon:M.twMerge("directory-tree-expand-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),expandIconSelected:M.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:M.twMerge("directory-tree-type-icon flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),typeIconSelected:M.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:M.twMerge("directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 text-xs font-normal","text-gray-700","dark:text-gray-200"),nameDirectory:"directory-tree-name--directory font-medium",nameSelected:M.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},Nt=e=>{const t=e.slice(e.lastIndexOf("/")+1),r=t.lastIndexOf(".");return r<=0?"":t.slice(r+1).toLowerCase()},on=/^[a-z][a-z\d+.-]*:\/\//i,pr=e=>Nt(on.test(e)?e.split(/[?#]/,1)[0]:e),Sr=e=>Nt(e.name)||pr(e.relativePath)||pr(e.absolutePath),Rr=({isDirectory:e,isExpanded:t,showExpandIcons:r,useCanvasExpandIcons:o,expandIconSize:a})=>{const c=a?{width:a,height:a}:void 0,i=a?"":"h-4 w-4";return!(r&&e)||o?f.jsx("span",{className:i,style:c,"aria-hidden":"true"}):t?f.jsx(Qr,{className:i,style:c}):f.jsx(tn,{className:i,style:c})},kt=(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 o=e.map(a=>kt(a,t)).filter(Boolean);return o.length?o: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},sn={markdown:()=>f.jsx(le.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"}),pdf:()=>f.jsx(le.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"}),spreadsheet:()=>f.jsx(le.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"}),csv:()=>f.jsx(le.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"}),document:()=>f.jsx(le.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),presentation:()=>f.jsx(le.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"}),image:()=>f.jsx(le.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"}),audio:()=>f.jsx(le.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"}),video:()=>f.jsx(le.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"}),archive:()=>f.jsx(le.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"}),code:()=>f.jsx(le.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"}),text:()=>f.jsx(le.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})},an={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"]},ln=new Map(Object.entries(an).flatMap(([e,t])=>t.map(r=>[r,e]))),cn=new Set(["","application/octet-stream","binary/octet-stream","text/plain","application/x-empty"]),un=e=>(e??"").split(";",1)[0].trim().toLowerCase(),dn=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"},fn=(e,t,r)=>{const o=un(e),a=dn(o),c=ln.get((t||(r?Nt(r):"")).toLowerCase()),u=(cn.has(o)?[c,a]:[a,c]).find(I=>I!==void 0);return u===void 0?f.jsx(le.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"}):sn[u]()},kr=(e,t)=>{const{entry:r,isDirectory:o,isExpanded:a,extension:c,mimeType:i}=e;let u;const I=i||r.mimeType;return r.icon!==void 0?u=r.icon:o?u=a&&t?.directoryExpanded||t?.directory||f.jsx(nn,{className:"h-4 w-4"}):c&&t?.fileByExtension?.[c]?u=t.fileByExtension[c]:u=t?.file||fn(I,c,r.name),kt(typeof u=="function"?u(e):u,r.absolutePath)},hn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ir=e=>{if(!e)return;const t=Object.entries(e).filter(([,r])=>r!=null);if(t.length!==0)return Object.fromEntries(t.map(([r,o])=>[`data-${hn(r)}`,String(o)]))},mn=500,Cr=({entry:e,isDirectory:t,isExpanded:r,isItemSelected:o,selectionMode:a,onSelectionChange:c,onEntryClick:i,toggleDirectory:u,onToggleDirectoryRecursive:I})=>{const S=l.useRef(null);return l.useEffect(()=>()=>{S.current&&window.clearTimeout(S.current)},[]),l.useCallback(v=>{v.stopPropagation(),a!=="none"&&!t&&c&&c(e,!o);let m=!1;i({entry:e,isDirectory:t,isExpanded:r,preventDefault:()=>{m=!0}}),!(!t||m)&&(S.current?(window.clearTimeout(S.current),S.current=null,I(e)):S.current=window.setTimeout(()=>{u(e.absolutePath),S.current=null},mn))},[t,e,r,I,u,i,a,c,o])},Tr=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",yr=(e,t)=>e.children!==void 0&&t(e.absolutePath),_r=(e,t)=>({width:e,gridTemplateColumns:t}),Nr=l.memo(({entry:e,indentLevel:t,positionInSet:r,setSize:o,rowIndex:a,flatIndex:c,onRowFocus:i,onRowBlur:u,isSelectedForAria:I,rowHeight:S,isDirOpen:v,columns:m,numericTemplate:y,numericTotal:E,nameWidth:T,rowClassName:h,selection:{onEntryClick:x,selectedPath:R,currentPath:F,mode:k="none",selectedItems:_,onSelectionChange:b},expansion:{toggleDirectory:G,onToggleDirectoryRecursive:V},visual:{iconOverrides:N,showExpandIcons:j=!0,showDirectoryIcons:Q=!0,showFileIcons:$=!0,useCanvasExpandIcons:D=!1,expandIconSize:K,typeIconSize:ee=_t,indentSize:oe=ct,highlightStyles:U,expandIconClassName:ce,expandIconStyle:fe}})=>{const[W,se]=l.useState(!1),n=e.children!==void 0,g=n&&v(e.absolutePath),p=e.absolutePath===R,P=e.absolutePath===F,B=!n&&!!_?.has(e.absolutePath),he=n?void 0:Sr(e),A=Cr({entry:e,isDirectory:n,isExpanded:g,isItemSelected:B,selectionMode:k,onSelectionChange:b,onEntryClick:x,toggleDirectory:G,onToggleDirectoryRecursive:V}),te=W?U?.hoverClassName!==void 0?U.hoverClassName:O.entryHover:"",me=(()=>{if(n){if(p)return U?.directorySelectedClassName!==void 0?U.directorySelectedClassName:O.entrySelected}else if(p||B)return U?.itemSelectedClassName!==void 0?U.itemSelectedClassName:M.twMerge(p&&O.entrySelected,B&&O.entryItemSelected);return""})(),ie=typeof h=="function"?h(e):h,_e=M.twMerge("dt-grid-row cursor-pointer select-none",te,me,ie,e.className),Ee=M.twMerge(O.expandIcon,ce,(p||B)&&O.expandIconSelected),ne=M.twMerge(O.typeIcon,(p||B)&&O.typeIconSelected),L=M.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",n&&O.nameDirectory,(p||B)&&O.nameSelected),ue=Rr({isDirectory:n,isExpanded:g,showExpandIcons:j,useCanvasExpandIcons:D,expandIconSize:K}),q=(n?Q:$)?kr({entry:e,isDirectory:n,isExpanded:g,isSelected:p,isItemSelected:B,extension:he,mimeType:e.mimeType},N):null,Se={indentLevel:t,isDirectory:n,isExpanded:g},[Y,...Ne]=m,Re=Y?.render?Y.render(e,Se):e.label??e.name,ke={...W?U?.hoverStyle:{},...n&&p?U?.directorySelectedStyle:{},...!n&&(p||B)?U?.itemSelectedStyle:{}};return f.jsxs("div",{className:_e,style:{height:S,...ke,...e.style},role:"row","aria-expanded":n?g:void 0,"aria-level":t+1,"aria-posinset":r,"aria-setsize":o,"aria-rowindex":a,"aria-selected":k==="none"?void 0:I,"aria-current":P?"page":void 0,...Ir(e.data),"data-entry-type":n?"directory":"file","data-entry-expanded":n?String(g):void 0,"data-entry-selected":p?"true":void 0,"data-entry-item-selected":B?"true":void 0,onClick:A,onMouseEnter:()=>se(!0),onMouseLeave:()=>se(!1),onFocus:X=>i(c,e.absolutePath,X.currentTarget),onBlur:X=>u(e.absolutePath,X.currentTarget),onKeyDown:X=>{if(X.key==="Enter"){if(X.repeat){X.preventDefault();return}A(X)}},tabIndex:0,children:[f.jsxs("div",{className:M.twMerge("dt-grid-name-cell",Y?.className),role:"gridcell",style:{width:T,paddingLeft:Math.max(0,t*oe)},children:[(j||D)&&f.jsx("span",{className:Ee,style:fe,children:ue}),(n?Q:$)&&f.jsx("span",{className:ne,style:{width:ee,height:ee},children:q}),f.jsx("span",{className:L,children:Re})]}),Ne.length>0&&f.jsx("div",{className:"dt-grid-numeric-viewport",children:f.jsx("div",{className:"dt-grid-numeric-track",style:_r(E,y),children:Ne.map(X=>f.jsx("div",{className:M.twMerge("dt-grid-cell",Tr(X.align),X.className),role:"gridcell",children:X.render?X.render(e,Se):null},X.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=yr(e.entry,e.isDirOpen),o=yr(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===o&&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});Nr.displayName="DirectoryTreeGridRow";const jr=({kind:e,columns:t,numericTemplate:r,numericTotal:o,nameWidth:a,scrollBarWidth:c,className:i,nameContent:u,renderCell:I})=>{const[,...S]=t,v=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",m=e==="header"?"dt-grid-header":"dt-grid-footer",y=e==="header"?"columnheader":"gridcell";return f.jsxs("div",{className:M.twMerge(m,"text-gray-600 dark:text-gray-300",i),role:"row",children:[f.jsx("div",{className:M.twMerge(v,"px-1",t[0]?.className),role:y,style:{width:a},children:u}),S.length>0&&f.jsx("div",{className:"dt-grid-numeric-viewport",children:f.jsx("div",{className:"dt-grid-numeric-track",style:_r(o,r),children:S.map(E=>f.jsx("div",{className:M.twMerge("dt-grid-cell",Tr(E.align),E.className),role:y,children:I(E)},E.key))})}),f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},pn=({columns:e,className:t,...r})=>f.jsx(jr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:o=>o.header??null,...r}),br=(e,t)=>typeof e=="function"?e(t):e??null,yn=({columns:e,allEntries:t,className:r,...o})=>f.jsx(jr,{kind:"footer",columns:e,className:r,nameContent:br(e[0]?.footer,t),renderCell:a=>br(a.footer,t),...o}),bn=240,Pr=96,Ar=12,It=(e,t)=>{const r=e?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:t},gn=e=>e.slice(1).map(t=>`${It(t,Pr)}px`).join(" "),vn=({measuredWidth:e,columns:t,scrollBarWidth:r=Ar})=>{const o=It(t[0],bn),a=t.slice(1).reduce((I,S)=>I+It(S,Pr),0),c=Number.isFinite(e)&&e>0?e:0,i=Math.max(0,c-o-Math.max(0,r)),u=Math.max(0,a-i);return{nameWidth:o,numericTotal:a,numericVisible:i,maxHScroll:u}},Rt=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,wn=e=>{const t=[],r=o=>{for(const a of o)t.push(a),a.children&&a.children.length>0&&r(a.children)};return r(e),t},Mr=["entryKindDirectory","entryKindFile"],Ct=[...pe.VIRTUAL_SCROLL_LABEL_KEYS,...Mr],Tt=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),Lr=Object.freeze({en:Object.freeze({...pe.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Tt.en}),ja:Object.freeze({...pe.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Tt.ja})}),gr=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,xn=e=>{const t={};let r=!1;for(const o of pe.VIRTUAL_SCROLL_LABEL_KEYS){const a=Object.hasOwn(e,o)?e[o]:void 0;a!==void 0&&(t[o]=a,r=!0)}return r?t:void 0},Or=(e,t)=>{const r=pe.resolveVirtualScrollLocale(e);if(t===void 0)return Lr[r];if(t===null||typeof t!="object")throw new RangeError(`[directory-tree] labels must be an object; got ${gr(t)}`);const o=Object.getPrototypeOf(t);if(o!==Object.prototype&&o!==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 i of Object.keys(t))if(!Ct.includes(i))throw new RangeError(`[directory-tree] labels.${i} is not a known label key; expected one of ${Ct.join(", ")}`);const c={...pe.resolveVirtualScrollLabels(r,xn(t)),...Tt[r]};for(const i of Mr){const u=Object.hasOwn(t,i)?t[i]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[directory-tree] labels.${i} must be a non-blank string; got ${gr(u)}`);c[i]=u}}return Object.freeze(c)},En=e=>{const t={};for(const r of pe.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},Sn=()=>{let e=null;return{mark:t=>{const r=t.composedPath();e=r,setTimeout(()=>{e===r&&(e=null)},0)},landedOn:t=>e?.includes(t)===!0}},Rn=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let o=0,a=r-1,c=0;for(;o<=a;){const i=o+a>>>1;e[i]<=t?(c=i,o=i+1):a=i-1}return c},kn=(e,t,r)=>{if(r<=0||e.length===0||t.length!==e.length+1)return null;const o=Rn(t,r),a=e[o];return a?{path:a.entry.absolutePath,offsetInViewport:r-t[o]}:null},In=(e,t,r)=>{if(t.length===0||r.length!==t.length+1)return null;for(let o=0;o<t.length;o++)if(t[o].entry.absolutePath===e.path)return Math.max(0,r[o]+e.offsetInViewport);return null},Cn=(e,t,r)=>{const o=[];for(let a=t;a<r;a++){const c=e[a];if(!(!c||c.length===0))for(const i of c)o.push(i)}return o},Tn=(e,t,r)=>{const o=[];for(let a=t;a<r;a++){const c=e[a];if(!(!c||c.length===0))for(const i of c)o.push(i)}return o},_n=(e,t,r,o)=>{const a=Math.max(1,Math.floor(t*o)),c=Math.max(1,Math.floor(r*o));(e.width!==a||e.height!==c)&&(e.width=a,e.height=c);const i=e.style;i.width!==`${t}px`&&(i.width=`${t}px`),i.height!==`${r}px`&&(i.height=`${r}px`)},Nn=(e,t,r)=>{e.lineWidth=r,e.beginPath();for(const o of t)e.moveTo(o.x1,o.y1),e.lineTo(o.x2,o.y2);e.stroke()},jn=(e,t)=>{const r=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!r)return null;let o=r[1];o.length===3&&(o=o.split("").map(u=>u+u).join(""));const a=Number.parseInt(o.slice(0,2),16),c=Number.parseInt(o.slice(2,4),16),i=Number.parseInt(o.slice(4,6),16);return`rgba(${a}, ${c}, ${i}, ${t})`},Pn=(e,t,r,o)=>{if(t.length===0)return;const a=jn(r,.14),c=e.strokeStyle,i=e.fillStyle,u=e.lineWidth,I=e.lineCap,S=e.lineJoin;e.strokeStyle=r,e.lineCap="round",e.lineJoin="round";for(const v of t){const m=o??v.size,y=Math.max(0,m/2),E=Math.max(1,Math.round(m*.08)),T=Math.max(1,Math.round(m*.14)),h=Math.max(0,y-E*.8),x=Math.max(0,h*.55);a&&(e.fillStyle=a,e.beginPath(),e.arc(v.centerX,v.centerY,h,0,Math.PI*2),e.fill()),e.lineWidth=E,e.beginPath(),e.arc(v.centerX,v.centerY,Math.max(0,y-E*.3),0,Math.PI*2),e.stroke(),e.lineWidth=T,e.beginPath(),e.moveTo(v.centerX-x,v.centerY),e.lineTo(v.centerX+x,v.centerY),e.stroke(),v.isExpanded||(e.beginPath(),e.moveTo(v.centerX,v.centerY-x),e.lineTo(v.centerX,v.centerY+x),e.stroke())}e.strokeStyle=c,e.fillStyle=i,e.lineWidth=u,e.lineCap=I,e.lineJoin=S},Dr=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:o,viewportHeight:a,scrollPosition:c,color:i="#a0aec0",strokeWidth:u=1,renderStartIndex:I,renderEndIndex:S,lookaheadEndIndex:v,devicePixelRatio:m,expandGlyphColor:y,expandGlyphSize:E})=>{const T=l.useRef(null),h=l.useRef(null),x=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:o,viewportHeight:a,scrollPosition:c,color:i,strokeWidth:u,renderStartIndex:I,renderEndIndex:S,lookaheadEndIndex:v,devicePixelRatio:m,expandGlyphColor:y,expandGlyphSize:E}),R=l.useCallback(()=>{h.current=null;const k=T.current;if(!k)return;const _=k.getContext("2d");if(!_)return;const b=x.current;if(b.width<=0||b.viewportHeight<=0){_.clearRect(0,0,k.width,k.height);return}const G=Number.isFinite(b.devicePixelRatio??NaN)?b.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;_n(k,b.width,b.viewportHeight,G);const V=b.segmentsByItem.length,N=typeof b.renderStartIndex=="number"&&Number.isFinite(b.renderStartIndex)?Math.max(0,Math.floor(b.renderStartIndex)):Math.max(0,Math.floor(b.scrollPosition/b.itemHeight)),j=Math.min(V,Math.ceil((b.scrollPosition+b.viewportHeight)/b.itemHeight)),Q=(()=>{if(typeof b.renderEndIndex=="number"&&Number.isFinite(b.renderEndIndex)){const ee=Math.floor(b.renderEndIndex);return Math.max(Math.min(V,ee+1),N)}return Math.max(j,N)})(),$=(()=>{if(typeof b.lookaheadEndIndex=="number"&&Number.isFinite(b.lookaheadEndIndex)){const ee=Math.floor(b.lookaheadEndIndex),oe=Math.min(V,ee+1);return Math.max(oe,Q)}return Math.max(j,Q)})(),D=Cn(b.segmentsByItem,N,$),K=Tn(b.glyphsByItem,N,$);_.save(),_.scale(G,G),_.clearRect(0,0,b.width,b.viewportHeight),_.translate(0,-b.scrollPosition),_.strokeStyle=b.color,Nn(_,D,b.strokeWidth),Pn(_,K,b.expandGlyphColor??b.color,b.expandGlyphSize),_.restore()},[]),F=l.useCallback(()=>{h.current===null&&(h.current=window.requestAnimationFrame(R))},[R]);return l.useEffect(()=>{x.current={segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:o,viewportHeight:a,scrollPosition:c,color:i,strokeWidth:u,renderStartIndex:I,renderEndIndex:S,lookaheadEndIndex:v,devicePixelRatio:m,expandGlyphColor:y,expandGlyphSize:E},F()},[e,t,r,o,a,c,i,u,I,S,v,m,y,E,F]),l.useEffect(()=>()=>{h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null)},[]),f.jsx("canvas",{ref:T,className:"pointer-events-none absolute top-0 left-0 z-0"})});Dr.displayName="TreeLineCanvas";const An=e=>{const t=new Map;for(let r=0;r<e.length;r++){const o=e[r].entry.absolutePath;t.has(o)||t.set(o,r)}return t},vr=(e,t)=>e.selectedPath===t?e:{selectedPath:t,selectionGeneration:e.selectionGeneration+1,anchor:e.anchor},Mn=(e,t)=>({...e,anchor:{path:t,selectionGeneration:e.selectionGeneration,focused:!0}}),Ln=(e,t)=>{const{anchor:r,selectionGeneration:o,selectedPath:a}=t;if(r!==null&&(r.focused||r.selectionGeneration===o)){const c=e.get(r.path);if(c!==void 0)return c}if(a!==null){const c=e.get(a);if(c!==void 0)return c}return 0},On={msOverflowStyle:"none",scrollbarWidth:"none"},Dn=()=>{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))},Fn=e=>{const t=l.useRef(null),r=t.current;return r!==null&&pe.VIRTUAL_SCROLL_LABEL_KEYS.every(o=>r[o]===e[o])?r:(t.current=e,e)},wr=new Set(["top","bottom","center","nearest"]),xr=e=>{const t=e?.align;if(t===void 0)return"top";if(!wr.has(t))throw new RangeError(`[directory-tree] Unsupported scroll alignment ${JSON.stringify(t)}; expected one of ${[...wr].join(", ")}.`);return t},$n={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},Bn=(e,t,r,o,a)=>{const c=[],i=[];let u=0;const I=(S,v,m)=>{const y=a?[...S].sort(a):S;for(let E=0;E<y.length;E++){const T=y[E],h=E===y.length-1,x=[...m,h],R=T.children!==void 0,F=R&&t(T.absolutePath,T.relativePath);let k=v,_=x,b=m;o&&(k=v-1,_=x.slice(1),b=m.slice(1)),c.push({entry:T,indentLevel:k,depth:v,positionInSet:E+1,setSize:y.length,parentIsLast:_}),r&&(k>u&&(u=k),i.push({id:T.absolutePath,name:T.name,absolutePath:T.absolutePath,indentLevel:k,isLastChild:h,isDirectory:R,isExpanded:F,ancestorIsLast:[...b],hideLines:o&&v===0})),R&&F&&T.children&&I(T.children,v+1,x)}};return I(e,0,[]),{flatItems:c,lineItems:i,maxIndent:u}},Er=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let o=0,a=r-1,c=0;for(;o<=a;){const i=o+a>>>1;e[i]<=t?(c=i,o=i+1):a=i-1}return c},Hn=(e,t,r,o,a,c)=>{const i=o?.renderStart??Math.max(0,Er(c,a)),u=t>0?Er(c,a+t)+r:i+r,I=e>0?Math.min(e-1,Math.max(i,u)):i,S=o?.renderEnd??I,v=e>0?Math.min(e-1,S+r):S;return{renderStart:i,renderEnd:S,lookaheadEnd:v}},Wn=(e,t,r,o,a,c)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const i=Array.from({length:e.length},()=>[]),u=Array.from({length:e.length},()=>[]),I=m=>a?typeof c=="number"&&Number.isFinite(c)&&c>0?c:Math.max(8,Math.min(o*.9,m*.7)):0,S=3,v=m=>m*o+o/2+S;for(let m=0;m<e.length;m++){const y=e[m],E=t[m]??0,T=r[m]??0,h=T+E/2,x=e[m+1],R=h+_t/2,F=T+E,k=x!==void 0&&x.indentLevel===y.indentLevel+1&&R<F?{key:`${y.id}-connector-children`,x1:v(x.indentLevel),y1:R,x2:v(x.indentLevel),y2:F,itemIndex:m}:null;if(y.hideLines){k!==null&&(i[m]=[k]);continue}const _=[],b=I(E),G=b>0?b/2+2:o/1.5;for(let j=0;j<y.indentLevel;j++){if(y.ancestorIsLast[j]??!1)continue;let $=!1;for(let D=m;D<e.length;D++){const K=e[D];if(K.indentLevel>j&&K.ancestorIsLast.length>j&&!K.ancestorIsLast[j]){$=!0;break}if(D>m&&K.indentLevel===j)break}if($){const D=v(j);_.push({key:`${y.id}-ancestor-${j}`,x1:D,y1:T,x2:D,y2:T+E,itemIndex:m})}}const V=y.indentLevel*o,N=v(y.indentLevel);if(m>0&&_.push({key:`${y.id}-connector-top`,x1:N,y1:T,x2:N,y2:y.isDirectory?h-G:h,itemIndex:m}),!y.isDirectory&&y.isLastChild&&_.push({key:`${y.id}-connector-horizontal`,x1:N,y1:h,x2:V+o+S,y2:h,itemIndex:m}),y.isLastChild||(y.isDirectory?_.push({key:`${y.id}-connector-bottom`,x1:N,y1:h+G,x2:N,y2:T+E,itemIndex:m}):_.push({key:`${y.id}-connector-bottom`,x1:N,y1:h,x2:N,y2:T+E,itemIndex:m})),k!==null&&_.push(k),i[m]=_,a&&y.isDirectory){const j=b,Q=N,$=h;u[m]=[{key:`${y.id}-glyph`,itemIndex:m,centerX:Q,centerY:$,size:j,isExpanded:y.isExpanded}]}}return{segmentsByItem:i,glyphsByItem:u}},jt=l.memo(({entry:e,indentLevel:t,depth:r,positionInSet:o,setSize:a,isSelectedForAria:c,flatIndex:i,isActive:u,registerRowRef:I,onNavigationKeyDown:S,onRowFocus:v,onRowBlur:m,rowHeight:y,entryKindDirectory:E,entryKindFile:T,isDirOpen:h,parentIsLast:x,renderChildren:R=!0,expansion:{toggleDirectory:F,onToggleDirectoryRecursive:k},selection:{onEntryClick:_,selectedPath:b,currentPath:G,mode:V="none",selectedItems:N,onSelectionChange:j},visual:{iconOverrides:Q,showExpandIcons:$=!0,showDirectoryIcons:D=!0,showFileIcons:K=!0,useCanvasExpandIcons:ee=!1,expandIconSize:oe,typeIconSize:U=_t,fontSize:ce,indentSize:fe=ct,highlightStyles:W,entryClassName:se,entryStyle:n,nameClassName:g,nameStyle:p,directoryNameClassName:P,directoryNameStyle:B,fileNameClassName:he,fileNameStyle:A,expandIconClassName:te,expandIconStyle:me}})=>{const[ie,_e]=l.useState(null),[Ee,ne]=l.useState(!1),L=e.children!==void 0,ue=L&&h(e.absolutePath),q=e.absolutePath===b,Se=e.absolutePath===G,Y=!L&&N?.has(e.absolutePath),Ne=l.useCallback(z=>I(i,z),[I,i]),Re=L?void 0:Sr(e);l.useEffect(()=>{_e(ue&&e.children?e.children:null)},[ue,e.children]);const ke=Cr({entry:e,isDirectory:L,isExpanded:ue,isItemSelected:!!Y,selectionMode:V,onSelectionChange:j,onEntryClick:_,toggleDirectory:F,onToggleDirectoryRecursive:k}),X=Ee?W?.hoverClassName!==void 0?W.hoverClassName:O.entryHover:"",De=(()=>{if(L){if(q)return W?.directorySelectedClassName!==void 0?W.directorySelectedClassName:O.entrySelected}else if(q||Y)return W?.itemSelectedClassName!==void 0?W.itemSelectedClassName:M.twMerge(q&&O.entrySelected,Y&&O.entryItemSelected);return""})(),Fe=M.twMerge(O.entry,X,De,se,e.className),Ge=M.twMerge(O.expandIcon,te,(q||Y)&&O.expandIconSelected),it=M.twMerge(O.typeIcon,(q||Y)&&O.typeIconSelected),je=M.twMerge(O.name,g,L&&O.nameDirectory,L&&P,!L&&he,(q||Y)&&O.nameSelected),Ve=Rr({isDirectory:L,isExpanded:ue,showExpandIcons:$,useCanvasExpandIcons:ee,expandIconSize:oe}),Ke=(L?D:K)?kr({entry:e,isDirectory:L,isExpanded:ue,isSelected:q,isItemSelected:!!Y,extension:Re,mimeType:e.mimeType},Q):null,Ue={...Ee?W?.hoverStyle:{},...L&&q?W?.directorySelectedStyle:{},...!L&&(q||Y)?W?.itemSelectedStyle:{}},Xe=Ir(e.data),Je={width:U,height:U},$e=ce?{fontSize:typeof ce=="number"?`${ce}px`:ce}:void 0;return f.jsxs(l.Fragment,{children:[f.jsxs("div",{className:Fe,style:{paddingLeft:`${Math.max(0,t*fe)}px`,transform:t<0?`translateX(${t*fe}px)`:void 0,width:t<0?`calc(100% + ${Math.abs(t*fe)}px)`:void 0,height:`${y}px`,...$e,...Ue,...n,...e.style},...Xe,"data-entry-type":L?"directory":"file","data-entry-expanded":L?String(ue):void 0,"data-entry-selected":q?"true":void 0,"data-entry-item-selected":Y?"true":void 0,onClick:ke,onMouseEnter:()=>ne(!0),onMouseLeave:()=>ne(!1),onFocus:z=>v(i,e.absolutePath,z.currentTarget),onBlur:z=>m(e.absolutePath,z.currentTarget),ref:Ne,onKeyDown:z=>{if(z.key==="Enter"||z.key===" "){z.preventDefault(),z.repeat||ke(z);return}S(z,i)},tabIndex:u?0:-1,role:"treeitem","aria-expanded":L?ue:void 0,"aria-level":r+1,"aria-posinset":o,"aria-setsize":a,"aria-selected":V==="none"?void 0:c,"aria-current":Se?"page":void 0,"aria-label":`${e.name} (${L?E:T})`,children:[($||ee)&&f.jsx("span",{className:Ge,style:me,children:Ve}),(L?D:K)&&f.jsx("span",{className:it,style:Je,children:Ke}),f.jsx("span",{className:je,style:{...$e,...p,...L?B:A},"data-entry-type":L?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),ue&&ie&&R&&f.jsx("fieldset",{children:ie.map((z,be)=>f.jsx(jt,{entry:z,indentLevel:t+1,depth:r+1,positionInSet:be+1,setSize:ie.length,isSelectedForAria:!!N?.has(z.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:I,onNavigationKeyDown:S,onRowFocus:v,onRowBlur:m,rowHeight:y,entryKindDirectory:E,entryKindFile:T,isDirOpen:h,parentIsLast:[...x,be===ie.length-1],expansion:{toggleDirectory:F,onToggleDirectoryRecursive:k},selection:{onEntryClick:_,selectedPath:b,currentPath:G,mode:V,selectedItems:N,onSelectionChange:j},visual:{iconOverrides:Q,showExpandIcons:$,showDirectoryIcons:D,showFileIcons:K,useCanvasExpandIcons:ee,expandIconSize:oe,highlightStyles:W,entryClassName:se,entryStyle:n,nameClassName:g,nameStyle:p,directoryNameClassName:P,directoryNameStyle:B,fileNameClassName:he,fileNameStyle:A,expandIconClassName:te,expandIconStyle:me}},z.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const r=e.entry.children!==void 0,o=t.entry.children!==void 0,a=r&&e.isDirOpen(e.entry.absolutePath),c=o&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&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===c&&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.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&&e.parentIsLast.length===t.parentIsLast.length&&e.parentIsLast.every((i,u)=>i===t.parentIsLast[u])});jt.displayName="DirectoryEntryItem";const Fr=e=>{const t=[];if(e.children)for(const r of e.children)r.type==="directory"&&(t.push(r.absolutePath),t.push(...Fr(r)));return t},Yn=({entries:e,expansion:{toggle:t,isExpanded:r,expandMultiple:o,collapseMultiple:a,isPending:c,alwaysExpanded:i=!1,doubleClickAction:u="recursive"},selection:{onEntryClick:I,selectedPath:S,currentPath:v,mode:m="none",selectedItems:y,onSelectionChange:E},visual:{className:T,style:h,ariaLabel:x,ariaLabelledBy:R,lineColor:F="#A0AEC0",showTreeLines:k=!0,showExpandIcons:_=!0,showDirectoryIcons:b=!0,showFileIcons:G=!0,iconOverrides:V,expandIconSize:N,itemHeight:j=lt,removeRootIndent:Q=!1,highlightStyles:$,entryClassName:D,entryStyle:K,nameClassName:ee,nameStyle:oe,directoryNameClassName:U,directoryNameStyle:ce,fileNameClassName:fe,fileNameStyle:W,expandIconClassName:se,expandIconStyle:n}={},virtualScroll:g,grid:p,sort:P,locale:B,labels:he,ref:A})=>{const te=pe.resolveVirtualScrollLocale(B),me=l.useMemo(()=>Or(B,he),[B,he]),ie=Fn(En(me)),{entryKindDirectory:_e,entryKindFile:Ee}=me,ne=p!==void 0,[L,ue]=l.useState(!1),q=l.useRef(null),Se=l.useRef(null),Y=l.useRef(null),[Ne,Re]=l.useState(0),[ke,X]=l.useState(0),[De,Fe]=l.useState(0),[Ge,it]=l.useState(null),{overscanCount:je=15,className:Ve,background:Ke,onScroll:Ue,onRangeChange:Xe,onScrollAdjust:Je,liveRegion:$e,initialScrollIndex:z,initialScrollOffset:be,initialScrollAnchor:Pt,callbackThrottleMs:At=5,contentInsets:Mt,onItemFocus:Lt,viewportHeightOverride:ae,scrollBarOptions:ut,behaviorOptions:Ot,preserveScrollAnchor:Dt=!1,getItemKey:$r,testId:Ft,contentProps:dt}=g??{},$t=l.useMemo(()=>ne?{...dt,role:"rowgroup"}:{...dt,role:"tree","aria-label":R?void 0:x,"aria-labelledby":R,"aria-multiselectable":m==="multiple"?!0:void 0},[ne,dt,x,R,m]),Bt=l.useMemo(()=>({...Ot,enableKeyboardNavigation:!1}),[Ot]),[qe,Ht]=l.useState(typeof be=="number"?be:0),ft=l.useRef(typeof be=="number"?be:0),Wt=l.useCallback((s,d)=>{ft.current=s,Ht(s),Ue?.(s,d)},[Ue]),Yt=l.useCallback(s=>{const{renderingStartIndex:d,renderingEndIndex:w}=s;it(C=>C&&C.renderStart===d&&C.renderEnd===w?C:{renderStart:d,renderEnd:w}),Xe?.(s)},[Xe]);l.useEffect(()=>{ue(!0),Dn()},[]),l.useEffect(()=>{const s=q.current,d=ne?Se.current:s,w=()=>{if(s){const H=s.clientWidth;X(Z=>Math.abs(Z-H)>1?H:Z)}if(typeof ae=="number")Re(H=>Math.abs(H-ae)>1?ae:H);else if(d){const H=d.clientHeight;Re(Z=>Math.abs(Z-H)>1?H:Z)}};if(!(s||d))return Re(0);w();const C=new ResizeObserver(w);return s&&C.observe(s),d&&d!==s&&C.observe(d),()=>C.disconnect()},[ae,ne]);const Pe=typeof ae=="number"?ae:Ne,ye=l.useCallback(s=>i||(L?r(s):!1),[L,r,i]),zt=M.twMerge(O.container,c&&O.containerPending,T),Gt=l.useMemo(()=>({...On,...h??{},...typeof ae=="number"?{height:ae,minHeight:ae}:{}}),[h,ae]),ht=l.useCallback((s,d)=>{const w=[s.absolutePath,...Fr(s)],C=d||u;if(w.every(ve=>ye(ve)))return a(w);if(w.every(ve=>!ye(ve))||C==="recursive")return o(w);if(C==="toggle")return a(w);console.warn(`[DirectoryTree] Unknown double click action: ${C}. No action taken.`)},[ye,o,a,u]),Vt=ne?!1:Q,{flatItems:Ie,lineItems:mt,maxIndent:Kt}=l.useMemo(()=>Bn(e,ye,k,Vt,P),[e,ye,k,Vt,P]),J=l.useMemo(()=>Ie.map((s,d)=>{const w=typeof j=="function"?j(s.entry,d):j;return{...s,rowHeight:Number.isFinite(w)&&w>0?w:lt}}),[Ie,j]),we=l.useMemo(()=>J.map(s=>s.rowHeight),[J]),Ce=l.useMemo(()=>{const s=new Array(we.length+1);s[0]=0;for(let d=0;d<we.length;d++)s[d+1]=s[d]+we[d];return s},[we]),Ut=l.useCallback(s=>J[s]?.rowHeight??lt,[J]),Br=l.useCallback(s=>J[s]?.entry.absolutePath??s,[J]),Xt=$r??Br,Ae=S??null,pt=v??null,[Jt,Be]=l.useState(()=>({selectedPath:Ae,selectionGeneration:0,anchor:null})),yt=vr(Jt,Ae);yt!==Jt&&Be(s=>vr(s,Ae));const Ze=l.useMemo(()=>An(Ie),[Ie]),Me=l.useMemo(()=>Ln(Ze,yt),[Ze,yt]),He=l.useRef(new Map),Qe=l.useRef(null),[et]=l.useState(Sn),We=l.useRef(null),[Hr,qt]=l.useState(!0),bt=l.useRef(Ie);bt.current=Ie;const Zt=l.useRef(ye);Zt.current=ye;const gt=l.useRef(t);gt.current=t;const Qt=l.useRef(Ze);Qt.current=Ze;const vt=l.useRef(Me);vt.current=Me;const er=l.useRef(Lt);er.current=Lt;const Te=l.useCallback(s=>{const d=Y.current;return!d||d.getViewportSize()<=0?!1:(d.scrollToIndex(s,{align:"nearest"}),!0)},[]),ge=l.useCallback(s=>{const d=He.current.get(s);if(d===void 0){We.current=s,Te(s)||(We.current=null);return}We.current=null,Te(s),d.focus({preventScroll:!0})},[Te]),tr=l.useCallback((s,d)=>{if(d)He.current.set(s,d),We.current===s?(We.current=null,d.focus({preventScroll:!0})):d.contains(d.ownerDocument.activeElement)&&Be(w=>w.anchor===null?w:{...w,anchor:{...w.anchor,focused:!0}});else{const w=He.current.get(s);He.current.delete(s),w?.contains(w.ownerDocument.activeElement)&&Be(C=>C.anchor===null?C:{...C,anchor:{...C.anchor,focused:!1}})}s===vt.current&&qt(d!==null)},[]);l.useLayoutEffect(()=>{qt(He.current.has(Me))},[Me]);const wt=l.useCallback((s,d,w)=>{const C=Qe.current===w;Qe.current=null,C||(Be(H=>Mn(H,d)),et.landedOn(w)||Te(s)),er.current?.(s)},[Te,et]),tt=l.useCallback(s=>et.mark(s.nativeEvent),[et]),xt=l.useCallback((s,d)=>{const{ownerDocument:w}=d;if(!w.hasFocus()&&d.contains(w.activeElement)){Qe.current=d;return}Qe.current=null,Be(C=>C.anchor!==null&&C.anchor.path===s?{...C,anchor:{...C.anchor,focused:!1}}:C)},[]),Wr=l.useCallback(()=>ge(vt.current),[ge]),Et=l.useCallback((s,d)=>{const w=xr(d),C=bt.current.length;if(!Number.isInteger(s)||s<0||s>=C)throw new RangeError(`[directory-tree] scrollToIndex: ${String(s)} is not a row index (${C===0?"the tree has no rows":`expected an integer in 0..${String(C-1)}`}).`);if(w==="nearest"){Te(s);return}Y.current?.scrollToIndex(s,{align:w})},[Te]);l.useImperativeHandle(A,()=>({scrollToIndex:Et,scrollToPath:(s,d)=>{xr(d);const w=Qt.current.get(s);return w===void 0?!1:(Et(w,d),!0)},getScrollAnchor:()=>Y.current?.getScrollAnchor()??null}),[Et]);const rr=l.useCallback((s,d)=>{if(s.altKey||s.ctrlKey||s.metaKey)return;const w=bt.current,C=w.length-1;if(C<0)return;const H=w[d],Z=H?.entry.children!==void 0,ve=Z&&Zt.current(H.entry.absolutePath);switch(s.key){case"ArrowDown":s.preventDefault(),ge(Math.min(d+1,C));break;case"ArrowUp":s.preventDefault(),ge(Math.max(d-1,0));break;case"Home":s.preventDefault(),ge(0);break;case"End":s.preventDefault(),ge(C);break;case"ArrowRight":s.preventDefault(),Z&&!ve?gt.current(H.entry.absolutePath):Z&&d<C&&w[d+1].depth>H.depth&&ge(d+1);break;case"ArrowLeft":{if(s.preventDefault(),Z&&ve){gt.current(H.entry.absolutePath);break}const Kr=H?.depth??0;for(let st=d-1;st>=0;st--)if(w[st].depth<Kr){ge(st);break}break}}},[ge]),rt=l.useMemo(()=>!k||mt.length===0?{segmentsByItem:[],glyphsByItem:[]}:Wn(mt,we,Ce,ct,k,N??mr),[mt,we,Ce,k,N]),nt=l.useMemo(()=>!k||e.length===0?0:(Kt+2)*ct,[e.length,Kt,k]),{renderStart:nr,renderEnd:or,lookaheadEnd:sr}=l.useMemo(()=>Hn(J.length,Pe,je,Ge,qe,Ce),[J.length,Pe,je,Ge,qe,Ce]),St=l.useMemo(()=>!k||nt<=0||Pe<=0||rt.segmentsByItem.length===0?null:f.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:f.jsx("div",{className:"absolute top-0 left-0",style:{width:nt,height:Pe},children:f.jsx(Dr,{segmentsByItem:rt.segmentsByItem,glyphsByItem:rt.glyphsByItem,itemHeight:we[0]??lt,width:nt,viewportHeight:Pe,scrollPosition:qe,color:F,expandGlyphColor:F,expandGlyphSize:N??mr,renderStartIndex:nr,renderEndIndex:or,lookaheadEndIndex:sr})})}),[nt,Pe,nr,or,sr,qe,rt,F,k,N,we]),ar=l.useCallback(s=>J[s],[J]),lr=l.useRef(null);l.useLayoutEffect(()=>{const s=lr.current;if(lr.current={items:J,offsets:Ce},!Dt||!s||s.items===J)return;const d=Y.current,w=d?.getScrollPosition(),C=typeof w=="number"&&w>=0?w:ft.current,H=kn(s.items,s.offsets,C);if(!H)return;const Z=In(H,J,Ce);if(Z===null||Math.abs(Z-C)<1)return;const ve=d?d.scrollTo(Z):Z;ft.current=ve,Ht(ve)},[J,Ce,Dt]);const xe=p?.columns,Le=p?.scrollBarWidth??ut?.width??Ar,re=l.useMemo(()=>xe?vn({measuredWidth:ke,columns:xe,scrollBarWidth:Le}):null,[xe,ke,Le]),ot=l.useMemo(()=>xe?gn(xe):"",[xe]),Yr=l.useMemo(()=>p?.showFooter&&xe?wn(e):[],[p?.showFooter,xe,e]),Oe=re?.maxHScroll??0;l.useEffect(()=>{Fe(s=>Rt(s,Oe))},[Oe]);const cr=l.useCallback(s=>Fe(d=>Rt(d+s,Oe)),[Oe]),ir=l.useMemo(()=>({iconOverrides:V,showExpandIcons:_,showDirectoryIcons:b,showFileIcons:G,useCanvasExpandIcons:k,expandIconSize:N,highlightStyles:$,expandIconClassName:se,expandIconStyle:n}),[V,_,b,G,k,N,$,se,n]),ur=l.useMemo(()=>f.jsx(pe.VirtualScroll,{ref:Y,itemCount:J.length,getItem:ar,getItemHeight:Ut,getItemKey:Xt,testId:Ft,contentProps:$t,locale:te,labels:ie,viewportSize:typeof ae=="number"?ae:void 0,overscanCount:je,onScroll:Wt,onRangeChange:Yt,onScrollAdjust:Je,liveRegion:$e,className:Ve,onWheelHorizontal:ne?cr:void 0,background:f.jsxs(f.Fragment,{children:[ne&&re?f.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:re.nameWidth},"aria-hidden":"true",children:St}):St,Ke]}),initialScrollIndex:z,initialScrollOffset:be,initialScrollAnchor:Pt,callbackThrottleMs:At,contentInsets:Mt,scrollBarOptions:ut,behaviorOptions:Bt,children:(s,d)=>s?ne&&p&&re?f.jsx(Nr,{entry:s.entry,indentLevel:s.indentLevel,positionInSet:s.positionInSet,setSize:s.setSize,rowIndex:d+(p.showHeader??!0?2:1),flatIndex:d,onRowFocus:wt,onRowBlur:xt,isSelectedForAria:!!y?.has(s.entry.absolutePath),rowHeight:s.rowHeight,isDirOpen:ye,columns:p.columns,numericTemplate:ot,numericTotal:re.numericTotal,nameWidth:re.nameWidth,rowClassName:p.rowClassName,selection:{onEntryClick:I,selectedPath:Ae,currentPath:pt,mode:m,selectedItems:y,onSelectionChange:E},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ht},visual:ir},s.entry.absolutePath):f.jsx(jt,{entry:s.entry,indentLevel:s.indentLevel,depth:s.depth,positionInSet:s.positionInSet,setSize:s.setSize,isSelectedForAria:!!y?.has(s.entry.absolutePath),flatIndex:d,isActive:d===Me,registerRowRef:tr,onNavigationKeyDown:rr,onRowFocus:wt,onRowBlur:xt,rowHeight:s.rowHeight,entryKindDirectory:_e,entryKindFile:Ee,isDirOpen:ye,parentIsLast:s.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ht},selection:{onEntryClick:I,selectedPath:Ae,currentPath:pt,mode:m,selectedItems:y,onSelectionChange:E},visual:{iconOverrides:V,showExpandIcons:_,showDirectoryIcons:b,showFileIcons:G,useCanvasExpandIcons:k,expandIconSize:N,highlightStyles:$,entryClassName:D,entryStyle:K,nameClassName:ee,nameStyle:oe,directoryNameClassName:U,directoryNameStyle:ce,fileNameClassName:fe,fileNameStyle:W,expandIconClassName:se,expandIconStyle:n}},s.entry.absolutePath):null}),[J.length,ar,Ut,Xt,Ft,$t,te,ie,_e,Ee,Me,tr,rr,wt,xt,ae,je,Wt,Yt,Je,$e,Ve,ne,cr,re,St,Ke,z,be,Pt,At,Mt,ut,Bt,p,ot,ye,I,Ae,pt,m,y,E,t,ht,ir,V,_,b,G,k,N,$,D,K,ee,oe,U,ce,fe,W,se,n]);if(!(p&&re))return f.jsxs("div",{ref:q,className:zt,style:Gt,onPointerDownCapture:tt,onMouseDownCapture:tt,children:[Ie.length>0&&!Hr&&f.jsx("span",{tabIndex:0,"data-directory-tree-tab-stop":"",style:$n,onFocus:Wr}),ur]});const zr=p.showHeader??!0,Gr=p.showFooter??!1,Vr={...Gt,"--dt-hscroll":`${De}px`};return f.jsxs("div",{ref:q,className:M.twMerge(zt,"dt-grid"),style:Vr,role:"treegrid","aria-label":R?void 0:x,"aria-labelledby":R,"aria-multiselectable":m==="multiple"?!0:void 0,"aria-rowcount":J.length+(p.showHeader??!0?1:0),onPointerDownCapture:tt,onMouseDownCapture:tt,children:[zr&&f.jsx("div",{role:"rowgroup",children:f.jsx(pn,{columns:p.columns,numericTemplate:ot,numericTotal:re.numericTotal,nameWidth:re.nameWidth,scrollBarWidth:Le,className:p.headerClassName})}),f.jsx("div",{ref:Se,className:"dt-grid-body",children:ur}),Oe>0&&f.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:re.nameWidth},"aria-hidden":"true"}),f.jsx(pe.ScrollBar,{horizontal:!0,contentSize:re.numericTotal,viewportSize:re.numericVisible,scrollPosition:De,scrollBarWidth:Le,locale:te,labels:ie,onScroll:s=>{const d=typeof s=="function"?s(De):s,w=Rt(d,Oe);return Fe(w),w}}),f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Le},"aria-hidden":"true"})]}),Gr&&f.jsx("div",{role:"rowgroup",children:f.jsx(yn,{columns:p.columns,numericTemplate:ot,numericTotal:re.numericTotal,nameWidth:re.nameWidth,scrollBarWidth:Le,allEntries:Yr,className:p.footerClassName})})]})},zn=({initialExpanded:e=new Set,storageKey:t}={})=>{const[r,o]=l.useTransition(),[a,c]=l.useState(()=>{if(typeof window<"u"&&t)try{const h=window.localStorage.getItem(t);if(h){const x=JSON.parse(h);return new Set(x)}}catch(h){console.error("[useDirectoryTreeState] Error reading from localStorage",h)}return e}),i=l.useCallback(h=>{o(()=>{c(x=>{const R=new Set(x);return h(R),R})})},[]),u=l.useCallback((h,x)=>{i(R=>{for(const F of h)x(R,F)})},[i]);l.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 I=l.useCallback(h=>{u([h],(x,R)=>{x.has(R)?x.delete(R):x.add(R)})},[u]),S=l.useCallback(h=>{u([h],(x,R)=>{x.add(R)})},[u]),v=l.useCallback(h=>{u([h],(x,R)=>{x.delete(R)})},[u]),m=l.useCallback(h=>{u(h,(x,R)=>{x.delete(R)})},[u]),y=l.useCallback(h=>{u(h,(x,R)=>{x.add(R)})},[u]),E=l.useCallback(()=>{i(h=>{h.clear()})},[i]),T=l.useCallback(h=>a.has(h),[a]);return{expanded:a,toggle:I,expand:S,collapse:v,collapseMultiple:m,expandMultiple:y,collapseAll:E,isExpanded:T,isPending:r}};exports.DIRECTORY_TREE_LABEL_CATALOGS=Lr;exports.DIRECTORY_TREE_LABEL_KEYS=Ct;exports.DirectoryTree=Yn;exports.directoryTreeClasses=O;exports.resolveDirectoryTreeLabels=Or;exports.useDirectoryTreeState=zn;
|