@aiquants/directory-tree 4.0.0 → 4.1.1

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 CHANGED
@@ -33,7 +33,7 @@ This package requires the following peer dependencies:
33
33
  npm install react react-dom @aiquants/virtualscroll
34
34
  ```
35
35
 
36
- `@aiquants/virtualscroll` must be 3.7.0 or later (it supplies the `locale` / `labels` chrome catalog).
36
+ `@aiquants/virtualscroll` must be 3.11.3 or later: it supplies the `locale` / `labels` chrome catalog, the pill-aware `scrollToIndex(index, { align: "nearest" })` that reveals focused rows, and the edge pills that hide while the pane rests at their edge (so the first and last rows are never left under a pill).
37
37
 
38
38
  ## Quick Start
39
39
 
@@ -256,12 +256,15 @@ The classic tree follows the WAI-ARIA tree pattern with a roving tabindex: it al
256
256
  neither handled nor has its default action prevented, so the browser's history keys (Alt+Left / Alt+Right,
257
257
  ⌘+Left / ⌘+Right) and a host's own shortcuts on them (for example Alt+Shift+Arrow) work while a row has focus.
258
258
  Shift alone does not change a key.
259
- - **The focused row stays in view**: when the tree's keys move the focus to a row that is not wholly inside the
260
- window — rendered beyond its edge or not rendered at all — the tree scrolls it in through the virtual list, aligning
261
- the nearer edge. A row that receives focus some other way (Tab, a script, a pointer) is scrolled in only when it lies
262
- entirely outside the window, so a press never shifts the row under the pointer. A row that gets focus back because
263
- the window or browser tab became active again is not scrolled: focus never left it, and the browser does not scroll
264
- there either.
259
+ - **The focused row is wholly in view**: a row that receives focus — moved there by the tree's keys, entered with Tab,
260
+ or focused by a script — is brought wholly into the window through the virtual list's reveal
261
+ (`scrollToIndex(index, { align: "nearest" })` of `@aiquants/virtualscroll`): the least scroll, and none when the row
262
+ already lies wholly inside, whether it was rendered beyond the window's edge or not rendered at all. While a Top/Bottom
263
+ button (`virtualScroll.scrollBarOptions.enableScrollToTopBottomButtons`) shows, the edge it covers does not count as
264
+ window, so the row lands clear of the button at any text size. A row a pointer press lands on is never scrolled, even when part of it
265
+ is under a button or beyond the window's edge: a press never shifts the row under the pointer, so both clicks of a
266
+ double-click hit the same row. A row that gets focus back because the window or browser tab became active again is not
267
+ scrolled: focus never left it, and the browser does not scroll there either.
265
268
  - **Rows outside the render window**: when the Tab stop row is virtualized away, a visually hidden stand-in Tab stop
266
269
  (`data-directory-tree-tab-stop`, outside `role="tree"`) takes its place in the Tab order; when it receives focus it
267
270
  scrolls the Tab stop row into view and hands the focus to it. A host that hands focus to the tree by selector should
@@ -286,7 +289,7 @@ shows, in display order — what `onRangeChange`, `onItemFocus` and `getScrollAn
286
289
 
287
290
  | Method | Description |
288
291
  | --- | --- |
289
- | `scrollToIndex(index, { align? })` | Scrolls the row into view. `align` is `"top"` (default), `"bottom"` or `"center"` (as VirtualScroll's `scrollToIndex`), or `"nearest"` (scroll only when the row is not wholly inside the window, aligning the nearer edge). A non-integer or out-of-range index, or an unknown `align`, throws a `RangeError` |
292
+ | `scrollToIndex(index, { align? })` | Scrolls the row into view. `align` is `"top"` (default), `"bottom"` or `"center"` (as VirtualScroll's `scrollToIndex`, against the window itself), or `"nearest"` (the reveal a row gets when it receives focus by key, Tab or script: the least scroll that brings the row wholly into the window clear of a visible Top/Bottom button, none when it already lies wholly inside). A non-integer or out-of-range index, or an unknown `align`, throws a `RangeError` |
290
293
  | `scrollToPath(path, { align? })` | Same, by absolute path. Returns `false` (and does nothing) when the path is not in the flattened list — an unknown path, or an entry inside a collapsed folder |
291
294
  | `getScrollAnchor()` | The first visible row as `{ index, offsetPx }`, to restore exactly through `virtualScroll.initialScrollAnchor` on the next mount; `null` for an empty tree |
292
295
 
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from "react";
2
- import { DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext } from "./types.ts";
2
+ import { DirectoryEntry, DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext } from "./types.ts";
3
3
  export declare const DEFAULT_ITEM_HEIGHT = 18;
4
4
  export declare const INDENT_SIZE = 12;
5
5
  export declare const EXPAND_GLYPH_SIZE = 8;
@@ -19,6 +19,8 @@ export declare const directoryTreeClasses: {
19
19
  nameSelected: string;
20
20
  };
21
21
  export declare const getFileExtension: (filename: string) => string;
22
+ export declare const getPathExtension: (path: string) => string;
23
+ export declare const getEntryExtension: (entry: Pick<DirectoryEntry, "name" | "relativePath" | "absolutePath">) => string;
22
24
  export type ExpandIconParams = {
23
25
  isDirectory: boolean;
24
26
  isExpanded: boolean;
@@ -27,6 +29,8 @@ export type ExpandIconParams = {
27
29
  expandIconSize?: number;
28
30
  };
29
31
  export declare const resolveExpandIcon: ({ isDirectory, isExpanded, showExpandIcons, useCanvasExpandIcons, expandIconSize }: ExpandIconParams) => ReactNode;
32
+ export declare const GENERIC_MIME_TYPES: ReadonlySet<string>;
33
+ export declare const normalizeMimeType: (mimeType: string | undefined) => string;
30
34
  export declare const getFileIconByMimeOrExtension: (mimeType?: string, extension?: string, filename?: string) => ReactNode;
31
35
  export declare const resolveEntryIcon: (ctx: DirectoryTreeIconRenderContext, overrides?: DirectoryTreeIconOverrides) => ReactNode;
32
36
  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"),be=require("@aiquants/virtualscroll"),M=require("tailwind-merge"),O=require("@phosphor-icons/react");function Yr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const me=Yr(l);var st={exports:{}},ze={};var ir;function Gr(){if(ir)return ze;ir=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,s,c){var i=null;if(c!==void 0&&(i=""+c),s.key!==void 0&&(i=""+s.key),"key"in s){c={};for(var f in s)f!=="key"&&(c[f]=s[f])}else c=s;return s=c.ref,{$$typeof:e,type:n,key:i,ref:s!==void 0?s:null,props:c}}return ze.Fragment=t,ze.jsx=r,ze.jsxs=r,ze}var Ye={};var ur;function Vr(){return ur||(ur=1,process.env.NODE_ENV!=="production"&&(function(){function e(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===q?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case v:return"Fragment";case B:return"Profiler";case I:return"StrictMode";case W:return"Suspense";case D:return"SuspenseList";case ae:return"Activity"}if(typeof o=="object")switch(typeof o.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),o.$$typeof){case h:return"Portal";case C:return o.displayName||"Context";case x:return(o._context.displayName||"Context")+".Consumer";case g:var p=o.render;return o=o.displayName,o||(o=p.displayName||p.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case P:return p=o.displayName||null,p!==null?p:e(o.type)||"Memo";case K:p=o._payload,o=o._init;try{return e(o(p))}catch{}}return null}function t(o){return""+o}function r(o){try{t(o);var p=!1}catch{p=!0}if(p){p=console;var w=p.error,T=typeof Symbol=="function"&&Symbol.toStringTag&&o[Symbol.toStringTag]||o.constructor.name||"Object";return w.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",T),t(o)}}function n(o){if(o===v)return"<>";if(typeof o=="object"&&o!==null&&o.$$typeof===K)return"<...>";try{var p=e(o);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function s(){var o=Z.A;return o===null?null:o.getOwner()}function c(){return Error("react-stack-top-frame")}function i(o){if(ne.call(o,"key")){var p=Object.getOwnPropertyDescriptor(o,"key").get;if(p&&p.isReactWarning)return!1}return o.key!==void 0}function f(o,p){function w(){he||(he=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",p))}w.isReactWarning=!0,Object.defineProperty(o,"key",{get:w,configurable:!0})}function j(){var o=e(this.type);return le[o]||(le[o]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),o=this.props.ref,o!==void 0?o:null}function E(o,p,w,T,se,ie){var A=w.ref;return o={$$typeof:N,type:o,key:p,props:w,_owner:T},(A!==void 0?A:null)!==null?Object.defineProperty(o,"ref",{enumerable:!1,get:j}):Object.defineProperty(o,"ref",{enumerable:!1,value:null}),o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(o,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(o,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:se}),Object.defineProperty(o,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ie}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}function m(o,p,w,T,se,ie){var A=p.children;if(A!==void 0)if(T)if(te(A)){for(T=0;T<A.length;T++)b(A[T]);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 b(A);if(ne.call(p,"key")){A=e(o);var Q=Object.keys(p).filter(function(ue){return ue!=="key"});T=0<Q.length?"{key: someKey, "+Q.join(": ..., ")+": ...}":"{key: someKey}",_[A+T]||(Q=0<Q.length?"{"+Q.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),pe=require("@aiquants/virtualscroll"),A=require("tailwind-merge"),se=require("@phosphor-icons/react");function Kr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const fe=Kr(l);var st={exports:{}},We={};var ur;function Ur(){if(ur)return We;ur=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,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:n,key:i,ref:a!==void 0?a:null,props:c}}return We.Fragment=t,We.jsx=r,We.jsxs=r,We}var ze={};var dr;function Xr(){return dr||(dr=1,process.env.NODE_ENV!=="production"&&(function(){function e(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===X?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case w:return"Fragment";case F:return"Profiler";case k:return"StrictMode";case H:return"Suspense";case D:return"SuspenseList";case ae:return"Activity"}if(typeof o=="object")switch(typeof o.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),o.$$typeof){case m:return"Portal";case C:return o.displayName||"Context";case x:return(o._context.displayName||"Context")+".Consumer";case b:var p=o.render;return o=o.displayName,o||(o=p.displayName||p.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case P:return p=o.displayName||null,p!==null?p:e(o.type)||"Memo";case V:p=o._payload,o=o._init;try{return e(o(p))}catch{}}return null}function t(o){return""+o}function r(o){try{t(o);var p=!1}catch{p=!0}if(p){p=console;var v=p.error,_=typeof Symbol=="function"&&Symbol.toStringTag&&o[Symbol.toStringTag]||o.constructor.name||"Object";return v.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",_),t(o)}}function n(o){if(o===w)return"<>";if(typeof o=="object"&&o!==null&&o.$$typeof===V)return"<...>";try{var p=e(o);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function a(){var o=q.A;return o===null?null:o.getOwner()}function c(){return Error("react-stack-top-frame")}function i(o){if(re.call(o,"key")){var p=Object.getOwnPropertyDescriptor(o,"key").get;if(p&&p.isReactWarning)return!1}return o.key!==void 0}function u(o,p){function v(){he||(he=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",p))}v.isReactWarning=!0,Object.defineProperty(o,"key",{get:v,configurable:!0})}function I(){var o=e(this.type);return le[o]||(le[o]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),o=this.props.ref,o!==void 0?o:null}function S(o,p,v,_,ne,ie){var M=v.ref;return o={$$typeof:N,type:o,key:p,props:v,_owner:_},(M!==void 0?M:null)!==null?Object.defineProperty(o,"ref",{enumerable:!1,get:I}):Object.defineProperty(o,"ref",{enumerable:!1,value:null}),o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(o,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(o,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ne}),Object.defineProperty(o,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ie}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}function h(o,p,v,_,ne,ie){var M=p.children;if(M!==void 0)if(_)if(ee(M)){for(_=0;_<M.length;_++)y(M[_]);Object.freeze&&Object.freeze(M)}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 y(M);if(re.call(p,"key")){M=e(o);var Z=Object.keys(p).filter(function(ue){return ue!=="key"});_=0<Z.length?"{key: someKey, "+Z.join(": ..., ")+": ...}":"{key: someKey}",j[M+_]||(Z=0<Z.length?"{"+Z.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),_[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 pe in p)pe!=="key"&&(w[pe]=p[pe])}else w=p;return A&&f(w,typeof o=="function"?o.displayName||o.name||"Unknown":o),E(o,A,w,s(),se,ie)}function b(o){k(o)?o._store&&(o._store.validated=1):typeof o=="object"&&o!==null&&o.$$typeof===K&&(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 R=l,N=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),C=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),q=Symbol.for("react.client.reference"),Z=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=Object.prototype.hasOwnProperty,te=Array.isArray,H=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(o){return o()}};var he,le={},ce=R.react_stack_bottom_frame.bind(R,c)(),Y=H(n(c)),_={};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?H(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?H(n(o)):Y)}})()),Ye}var dr;function Ur(){return dr||(dr=1,process.env.NODE_ENV==="production"?st.exports=Gr():st.exports=Vr()),st.exports}var u=Ur();function Kr({title:e,titleId:t,...r},n){return me.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?me.createElement("title",{id:t},e):null,me.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 Xr=me.forwardRef(Kr);function Jr({title:e,titleId:t,...r},n){return me.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?me.createElement("title",{id:t},e):null,me.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 qr=me.forwardRef(Jr);function Zr({title:e,titleId:t,...r},n){return me.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?me.createElement("title",{id:t},e):null,me.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 Qr=me.forwardRef(Zr),ot=18,at=12,fr=8,F={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()},vr=({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(Xr,{className:i,style:c}):u.jsx(qr,{className:i,style:c})},Rt=(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=>Rt(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},en=(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"})},xr=(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(Qr,{className:"h-4 w-4"}):c&&t?.fileByExtension?.[c]?f=t.fileByExtension[c]:f=t?.file||en(j,c,r.name),Rt(typeof f=="function"?f(e):f,r.absolutePath)},tn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Sr=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-${tn(r)}`,String(n)]))},rn=500,Er=({entry:e,isDirectory:t,isExpanded:r,isItemSelected:n,selectionMode:s,onSelectionChange:c,onEntryClick:i,toggleDirectory:f,onToggleDirectoryRecursive:j})=>{const E=l.useRef(null);return l.useEffect(()=>()=>{E.current&&window.clearTimeout(E.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)&&(E.current?(window.clearTimeout(E.current),E.current=null,j(e)):E.current=window.setTimeout(()=>{f(e.absolutePath),E.current=null},rn))},[t,e,r,j,f,i,s,c,n])},Rr=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",mr=(e,t)=>e.children!==void 0&&t(e.absolutePath),kr=(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:E,isDirOpen:m,columns:b,numericTemplate:k,numericTotal:R,nameWidth:N,rowClassName:h,selection:{onEntryClick:v,selectedPath:I,currentPath:B,mode:x="none",selectedItems:C,onSelectionChange:g},expansion:{toggleDirectory:W,onToggleDirectoryRecursive:D},visual:{iconOverrides:P,showExpandIcons:K=!0,showDirectoryIcons:ae=!0,showFileIcons:q=!0,useCanvasExpandIcons:Z=!1,expandIconSize:ne,indentSize:te=at,highlightStyles:H,expandIconClassName:he,expandIconStyle:le}})=>{const[ce,Y]=l.useState(!1),_=e.children!==void 0,o=_&&m(e.absolutePath),p=e.absolutePath===I,w=e.absolutePath===B,T=!_&&!!C?.has(e.absolutePath),se=_?void 0:je(e.name)||je(e.relativePath)||je(e.absolutePath),ie=Er({entry:e,isDirectory:_,isExpanded:o,isItemSelected:T,selectionMode:x,onSelectionChange:g,onEntryClick:v,toggleDirectory:W,onToggleDirectoryRecursive:D}),A=ce?H?.hoverClassName!==void 0?H.hoverClassName:F.entryHover:"",Q=(()=>{if(_){if(p)return H?.directorySelectedClassName!==void 0?H.directorySelectedClassName:F.entrySelected}else if(p||T)return H?.itemSelectedClassName!==void 0?H.itemSelectedClassName:M.twMerge(p&&F.entrySelected,T&&F.entryItemSelected);return""})(),pe=typeof h=="function"?h(e):h,ue=M.twMerge("dt-grid-row cursor-pointer select-none",A,Q,pe,e.className),Te=M.twMerge(F.expandIcon,he,(p||T)&&F.expandIconSelected),Re=M.twMerge(F.typeIcon,(p||T)&&F.typeIconSelected),re=M.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",_&&F.nameDirectory,(p||T)&&F.nameSelected),L=vr({isDirectory:_,isExpanded:o,showExpandIcons:K,useCanvasExpandIcons:Z,expandIconSize:ne}),de=(_?ae:q)?xr({entry:e,isDirectory:_,isExpanded:o,isSelected:p,isItemSelected:T,extension:se,mimeType:e.mimeType},P):null,X={indentLevel:t,isDirectory:_,isExpanded:o},[xe,...U]=b,Oe=xe?.render?xe.render(e,X):e.label??e.name,ke={...ce?H?.hoverStyle:{},..._&&p?H?.directorySelectedStyle:{},...!_&&(p||T)?H?.itemSelectedStyle:{}};return u.jsxs("div",{className:ue,style:{height:E,...ke,...e.style},role:"row","aria-expanded":_?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,...Sr(e.data),"data-entry-type":_?"directory":"file","data-entry-expanded":_?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",xe?.className),role:"gridcell",style:{width:N,paddingLeft:Math.max(0,t*te)},children:[(K||Z)&&u.jsx("span",{className:Te,style:le,children:L}),(_?ae:q)&&u.jsx("span",{className:Re,children:de}),u.jsx("span",{className:re,children:Oe})]}),U.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:kr(R,k),children:U.map(z=>u.jsx("div",{className:M.twMerge("dt-grid-cell",Rr(z.align),z.className),role:"gridcell",children:z.render?z.render(e,X):null},z.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=mr(e.entry,e.isDirOpen),n=mr(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 Cr=({kind:e,columns:t,numericTemplate:r,numericTotal:n,nameWidth:s,scrollBarWidth:c,className:i,nameContent:f,renderCell:j})=>{const[,...E]=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}),E.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:kr(n,r),children:E.map(R=>u.jsx("div",{className:M.twMerge("dt-grid-cell",Rr(R.align),R.className),role:k,children:j(R)},R.key))})}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},nn=({columns:e,className:t,...r})=>u.jsx(Cr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...r}),hr=(e,t)=>typeof e=="function"?e(t):e??null,sn=({columns:e,allEntries:t,className:r,...n})=>u.jsx(Cr,{kind:"footer",columns:e,className:r,nameContent:hr(e[0]?.footer,t),renderCell:s=>hr(s.footer,t),...n}),on=240,jr=96,Tr=12,kt=(e,t)=>{const r=e?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:t},an=e=>e.slice(1).map(t=>`${kt(t,jr)}px`).join(" "),ln=({measuredWidth:e,columns:t,scrollBarWidth:r=Tr})=>{const n=kt(t[0],on),s=t.slice(1).reduce((j,E)=>j+kt(E,jr),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}},Et=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,cn=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},Nr=["entryKindDirectory","entryKindFile"],It=[...be.VIRTUAL_SCROLL_LABEL_KEYS,...Nr],Ct=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),_r=Object.freeze({en:Object.freeze({...be.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Ct.en}),ja:Object.freeze({...be.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Ct.ja})}),pr=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,un=e=>{const t={};let r=!1;for(const n of be.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},Pr=(e,t)=>{const r=be.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 ${pr(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(!It.includes(i))throw new RangeError(`[directory-tree] labels.${i} is not a known label key; expected one of ${It.join(", ")}`);const c={...be.resolveVirtualScrollLabels(r,un(t)),...Ct[r]};for(const i of Nr){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 ${pr(f)}`);c[i]=f}}return Object.freeze(c)},dn=e=>{const t={};for(const r of be.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},fn=(e,t,r,n,s)=>{const c=r+n;return s==="visible"&&t>r&&e<c?null:t-e>n?e===r?null:"top":e<r?"top":t>c?"bottom":null},mn=(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},hn=(e,t,r)=>{if(r<=0||e.length===0||t.length!==e.length+1)return null;const n=mn(t,r),s=e[n];return s?{path:s.entry.absolutePath,offsetInViewport:r-t[n]}:null},pn=(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},bn=(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},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,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`)},wn=(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()},vn=(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})`},xn=(e,t,r,n)=>{if(t.length===0)return;const s=vn(r,.14),c=e.strokeStyle,i=e.fillStyle,f=e.lineWidth,j=e.lineCap,E=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),R=Math.max(1,Math.round(b*.08)),N=Math.max(1,Math.round(b*.14)),h=Math.max(0,k-R*.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=R,e.beginPath(),e.arc(m.centerX,m.centerY,Math.max(0,k-R*.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=E},Ar=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:s,scrollPosition:c,color:i="#a0aec0",strokeWidth:f=1,renderStartIndex:j,renderEndIndex:E,lookaheadEndIndex:m,devicePixelRatio:b,expandGlyphColor:k,expandGlyphSize:R})=>{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:E,lookaheadEndIndex:m,devicePixelRatio:b,expandGlyphColor:k,expandGlyphSize:R}),I=l.useCallback(()=>{h.current=null;const x=N.current;if(!x)return;const C=x.getContext("2d");if(!C)return;const g=v.current;if(g.width<=0||g.viewportHeight<=0){C.clearRect(0,0,x.width,x.height);return}const W=Number.isFinite(g.devicePixelRatio??NaN)?g.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;gn(x,g.width,g.viewportHeight,W);const D=g.segmentsByItem.length,P=typeof g.renderStartIndex=="number"&&Number.isFinite(g.renderStartIndex)?Math.max(0,Math.floor(g.renderStartIndex)):Math.max(0,Math.floor(g.scrollPosition/g.itemHeight)),K=Math.min(D,Math.ceil((g.scrollPosition+g.viewportHeight)/g.itemHeight)),ae=(()=>{if(typeof g.renderEndIndex=="number"&&Number.isFinite(g.renderEndIndex)){const te=Math.floor(g.renderEndIndex);return Math.max(Math.min(D,te+1),P)}return Math.max(K,P)})(),q=(()=>{if(typeof g.lookaheadEndIndex=="number"&&Number.isFinite(g.lookaheadEndIndex)){const te=Math.floor(g.lookaheadEndIndex),H=Math.min(D,te+1);return Math.max(H,ae)}return Math.max(K,ae)})(),Z=bn(g.segmentsByItem,P,q),ne=yn(g.glyphsByItem,P,q);C.save(),C.scale(W,W),C.clearRect(0,0,g.width,g.viewportHeight),C.translate(0,-g.scrollPosition),C.strokeStyle=g.color,wn(C,Z,g.strokeWidth),xn(C,ne,g.expandGlyphColor??g.color,g.expandGlyphSize),C.restore()},[]),B=l.useCallback(()=>{h.current===null&&(h.current=window.requestAnimationFrame(I))},[I]);return l.useEffect(()=>{v.current={segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:s,scrollPosition:c,color:i,strokeWidth:f,renderStartIndex:j,renderEndIndex:E,lookaheadEndIndex:m,devicePixelRatio:b,expandGlyphColor:k,expandGlyphSize:R},B()},[e,t,r,n,s,c,i,f,j,E,m,b,k,R,B]),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"})});Ar.displayName="TreeLineCanvas";const Sn=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},br=(e,t)=>e.selectedPath===t?e:{selectedPath:t,selectionGeneration:e.selectionGeneration+1,anchor:e.anchor},En=(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},kn={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))},Cn=e=>{const t=l.useRef(null),r=t.current;return r!==null&&be.VIRTUAL_SCROLL_LABEL_KEYS.every(n=>r[n]===e[n])?r:(t.current=e,e)},yr=new Set(["top","bottom","center","nearest"]),gr=e=>{const t=e?.align;if(t===void 0)return"top";if(!yr.has(t))throw new RangeError(`[directory-tree] Unsupported scroll alignment ${JSON.stringify(t)}; expected one of ${[...yr].join(", ")}.`);return t},jn={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},Tn=(e,t,r,n,s)=>{const c=[],i=[];let f=0;const j=(E,m,b)=>{const k=s?[...E].sort(s):E;for(let R=0;R<k.length;R++){const N=k[R],h=R===k.length-1,v=[...b,h],I=N.children!==void 0,B=I&&t(N.absolutePath,N.relativePath);let x=m,C=v,g=b;n&&(x=m-1,C=v.slice(1),g=b.slice(1)),c.push({entry:N,indentLevel:x,depth:m,positionInSet:R+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:I,isExpanded:B,ancestorIsLast:[...g],hideLines:n&&m===0})),I&&B&&N.children&&j(N.children,m+1,v)}};return j(e,0,[]),{flatItems:c,lineItems:i,maxIndent:f}},wr=(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},Nn=(e,t,r,n,s,c)=>{const i=n?.renderStart??Math.max(0,wr(c,s)),f=t>0?wr(c,s+t)+r:i+r,j=e>0?Math.min(e-1,Math.max(i,f)):i,E=n?.renderEnd??j,m=e>0?Math.min(e-1,E+r):E;return{renderStart:i,renderEnd:E,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,E=3;for(let m=0;m<e.length;m++){const b=e[m];if(b.hideLines)continue;const k=[],R=t[m]??0,N=r[m]??0,h=N+R/2,v=j(R),I=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 D=m;D<e.length;D++){const P=e[D];if(P.indentLevel>C&&P.ancestorIsLast.length>C&&!P.ancestorIsLast[C]){W=!0;break}if(D>m&&P.indentLevel===C)break}if(W){const D=C*n+n/2+E;k.push({key:`${b.id}-ancestor-${C}`,x1:D,y1:N,x2:D,y2:N+R,itemIndex:m})}}const B=b.indentLevel*n,x=B+n/2+E;if(b.isDirectory?k.push({key:`${b.id}-connector-top`,x1:x,y1:N,x2:x,y2:h-I,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:B+n+E,y2:h,itemIndex:m}),b.isLastChild||(b.isDirectory?k.push({key:`${b.id}-connector-bottom`,x1:x,y1:h+I,x2:x,y2:N+R,itemIndex:m}):k.push({key:`${b.id}-connector-bottom`,x1:x,y1:h,x2:x,y2:N+R,itemIndex:m})),i[m]=k,s&&b.isDirectory){const C=v,g=x,W=h;f[m]=[{key:`${b.id}-glyph`,itemIndex:m,centerX:g,centerY:W,size:C,isExpanded:b.isExpanded}]}}return{segmentsByItem:i,glyphsByItem:f}},jt=l.memo(({entry:e,indentLevel:t,depth:r,positionInSet:n,setSize:s,isSelectedForAria:c,flatIndex:i,isActive:f,registerRowRef:j,onNavigationKeyDown:E,onRowFocus:m,onRowBlur:b,rowHeight:k,entryKindDirectory:R,entryKindFile:N,isDirOpen:h,parentIsLast:v,renderChildren:I=!0,expansion:{toggleDirectory:B,onToggleDirectoryRecursive:x},selection:{onEntryClick:C,selectedPath:g,currentPath:W,mode:D="none",selectedItems:P,onSelectionChange:K},visual:{iconOverrides:ae,showExpandIcons:q=!0,showDirectoryIcons:Z=!0,showFileIcons:ne=!0,useCanvasExpandIcons:te=!1,expandIconSize:H,typeIconSize:he,fontSize:le,indentSize:ce=at,highlightStyles:Y,entryClassName:_,entryStyle:o,nameClassName:p,nameStyle:w,directoryNameClassName:T,directoryNameStyle:se,fileNameClassName:ie,fileNameStyle:A,expandIconClassName:Q,expandIconStyle:pe}})=>{const[ue,Te]=l.useState(null),[Re,re]=l.useState(!1),L=e.children!==void 0,de=L&&h(e.absolutePath),X=e.absolutePath===g,xe=e.absolutePath===W,U=!L&&P?.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=Er({entry:e,isDirectory:L,isExpanded:de,isItemSelected:!!U,selectionMode:D,onSelectionChange:K,onEntryClick:C,toggleDirectory:B,onToggleDirectoryRecursive:x}),lt=Re?Y?.hoverClassName!==void 0?Y.hoverClassName:F.entryHover:"",Fe=(()=>{if(L){if(X)return Y?.directorySelectedClassName!==void 0?Y.directorySelectedClassName:F.entrySelected}else if(X||U)return Y?.itemSelectedClassName!==void 0?Y.itemSelectedClassName:M.twMerge(X&&F.entrySelected,U&&F.entryItemSelected);return""})(),De=M.twMerge(F.entry,lt,Fe,_,e.className),Ge=M.twMerge(F.expandIcon,Q,(X||U)&&F.expandIconSelected),ct=M.twMerge(F.typeIcon,(X||U)&&F.typeIconSelected),Ne=M.twMerge(F.name,p,L&&F.nameDirectory,L&&T,!L&&ie,(X||U)&&F.nameSelected),Ve=vr({isDirectory:L,isExpanded:de,showExpandIcons:q,useCanvasExpandIcons:te,expandIconSize:H}),Ue=(L?Z:ne)?xr({entry:e,isDirectory:L,isExpanded:de,isSelected:X,isItemSelected:!!U,extension:ke,mimeType:e.mimeType},ae):null,Ke={...Re?Y?.hoverStyle:{},...L&&X?Y?.directorySelectedStyle:{},...!L&&(X||U)?Y?.itemSelectedStyle:{}},Xe=Sr(e.data),Je=he?{width:he,height:he}:void 0,$e=le?{fontSize:typeof le=="number"?`${le}px`:le}:void 0;return u.jsxs(l.Fragment,{children:[u.jsxs("div",{className:De,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":X?"true":void 0,"data-entry-item-selected":U?"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}E(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":D==="none"?void 0:c,"aria-current":xe?"page":void 0,"aria-label":`${e.name} (${L?R:N})`,children:[(q||te)&&u.jsx("span",{className:Ge,style:pe,children:Ve}),(L?Z:ne)&&u.jsx("span",{className:ct,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&&I&&u.jsx("fieldset",{children:ue.map((G,ge)=>u.jsx(jt,{entry:G,indentLevel:t+1,depth:r+1,positionInSet:ge+1,setSize:ue.length,isSelectedForAria:!!P?.has(G.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:j,onNavigationKeyDown:E,onRowFocus:m,onRowBlur:b,rowHeight:k,entryKindDirectory:R,entryKindFile:N,isDirOpen:h,parentIsLast:[...v,ge===ue.length-1],expansion:{toggleDirectory:B,onToggleDirectoryRecursive:x},selection:{onEntryClick:C,selectedPath:g,currentPath:W,mode:D,selectedItems:P,onSelectionChange:K},visual:{iconOverrides:ae,showExpandIcons:q,showDirectoryIcons:Z,showFileIcons:ne,useCanvasExpandIcons:te,expandIconSize:H,highlightStyles:Y,entryClassName:_,entryStyle:o,nameClassName:p,nameStyle:w,directoryNameClassName:T,directoryNameStyle:se,fileNameClassName:ie,fileNameStyle:A,expandIconClassName:Q,expandIconStyle:pe}},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])});jt.displayName="DirectoryEntryItem";const Mr=e=>{const t=[];if(e.children)for(const r of e.children)r.type==="directory"&&(t.push(r.absolutePath),t.push(...Mr(r)));return t},Pn=({entries:e,expansion:{toggle:t,isExpanded:r,expandMultiple:n,collapseMultiple:s,isPending:c,alwaysExpanded:i=!1,doubleClickAction:f="recursive"},selection:{onEntryClick:j,selectedPath:E,currentPath:m,mode:b="none",selectedItems:k,onSelectionChange:R},visual:{className:N,style:h,ariaLabel:v,ariaLabelledBy:I,lineColor:B="#A0AEC0",showTreeLines:x=!0,showExpandIcons:C=!0,showDirectoryIcons:g=!0,showFileIcons:W=!0,iconOverrides:D,expandIconSize:P,itemHeight:K=ot,removeRootIndent:ae=!1,highlightStyles:q,entryClassName:Z,entryStyle:ne,nameClassName:te,nameStyle:H,directoryNameClassName:he,directoryNameStyle:le,fileNameClassName:ce,fileNameStyle:Y,expandIconClassName:_,expandIconStyle:o}={},virtualScroll:p,grid:w,sort:T,locale:se,labels:ie,ref:A})=>{const Q=be.resolveVirtualScrollLocale(se),pe=l.useMemo(()=>Pr(se,ie),[se,ie]),ue=Cn(dn(pe)),{entryKindDirectory:Te,entryKindFile:Re}=pe,re=w!==void 0,[L,de]=l.useState(!1),X=l.useRef(null),xe=l.useRef(null),U=l.useRef(null),[Oe,ke]=l.useState(0),[z,lt]=l.useState(0),[Fe,De]=l.useState(0),[Ge,ct]=l.useState(null),{overscanCount:Ne=15,className:Ve,background:Ue,onScroll:Ke,onRangeChange:Xe,onScrollAdjust:Je,liveRegion:$e,initialScrollIndex:G,initialScrollOffset:ge,initialScrollAnchor:Tt,callbackThrottleMs:Nt=5,contentInsets:_t,onItemFocus:Pt,viewportHeightOverride:oe,scrollBarOptions:it,behaviorOptions:At,preserveScrollAnchor:Mt=!1,getItemKey:Lr,testId:Lt,contentProps:ut}=p??{},Ot=l.useMemo(()=>re?{...ut,role:"rowgroup"}:{...ut,role:"tree","aria-label":I?void 0:v,"aria-labelledby":I,"aria-multiselectable":b==="multiple"?!0:void 0},[re,ut,v,I,b]),Ft=l.useMemo(()=>({...At,enableKeyboardNavigation:!1}),[At]),[qe,Dt]=l.useState(typeof ge=="number"?ge:0),dt=l.useRef(typeof ge=="number"?ge:0),$t=l.useCallback((a,d)=>{dt.current=a,Dt(a),Ke?.(a,d)},[Ke]),Bt=l.useCallback(a=>{const{renderingStartIndex:d,renderingEndIndex:y}=a;ct(S=>S&&S.renderStart===d&&S.renderEnd===y?S:{renderStart:d,renderEnd:y}),Xe?.(a)},[Xe]);l.useEffect(()=>{de(!0),In()},[]),l.useEffect(()=>{const a=X.current,d=re?xe.current:a,y=()=>{if(a){const $=a.clientWidth;lt(V=>Math.abs(V-$)>1?$:V)}if(typeof oe=="number")ke($=>Math.abs($-oe)>1?oe:$);else if(d){const $=d.clientHeight;ke(V=>Math.abs(V-$)>1?$:V)}};if(!(a||d))return ke(0);y();const S=new ResizeObserver(y);return a&&S.observe(a),d&&d!==a&&S.observe(d),()=>S.disconnect()},[oe,re]);const _e=typeof oe=="number"?oe:Oe,ye=l.useCallback(a=>i||(L?r(a):!1),[L,r,i]),Ht=M.twMerge(F.container,c&&F.containerPending,N),Wt=l.useMemo(()=>({...kn,...h??{},...typeof oe=="number"?{height:oe,minHeight:oe}:{}}),[h,oe]),ft=l.useCallback((a,d)=>{const y=[a.absolutePath,...Mr(a)],S=d||f;if(y.every(fe=>ye(fe)))return s(y);if(y.every(fe=>!ye(fe))||S==="recursive")return n(y);if(S==="toggle")return s(y);console.warn(`[DirectoryTree] Unknown double click action: ${S}. No action taken.`)},[ye,n,s,f]),zt=re?!1:ae,{flatItems:Ie,lineItems:mt,maxIndent:Yt}=l.useMemo(()=>Tn(e,ye,x,zt,T),[e,ye,x,zt,T]),J=l.useMemo(()=>Ie.map((a,d)=>{const y=typeof K=="function"?K(a.entry,d):K;return{...a,rowHeight:Number.isFinite(y)&&y>0?y:ot}}),[Ie,K]),Se=l.useMemo(()=>J.map(a=>a.rowHeight),[J]),we=l.useMemo(()=>{const a=new Array(Se.length+1);a[0]=0;for(let d=0;d<Se.length;d++)a[d+1]=a[d]+Se[d];return a},[Se]),Gt=l.useCallback(a=>J[a]?.rowHeight??ot,[J]),Or=l.useCallback(a=>J[a]?.entry.absolutePath??a,[J]),Vt=Lr??Or,Pe=E??null,ht=m??null,[Ut,Be]=l.useState(()=>({selectedPath:Pe,selectionGeneration:0,anchor:null})),pt=br(Ut,Pe);pt!==Ut&&Be(a=>br(a,Pe));const Ze=l.useMemo(()=>Sn(Ie),[Ie]),Ae=l.useMemo(()=>Rn(Ze,pt),[Ze,pt]),He=l.useRef(new Map),Qe=l.useRef(null),We=l.useRef(null),[Fr,Kt]=l.useState(!0),bt=l.useRef(Ie);bt.current=Ie;const Xt=l.useRef(ye);Xt.current=ye;const yt=l.useRef(t);yt.current=t;const Jt=l.useRef(Ze);Jt.current=Ze;const qt=l.useRef(we);qt.current=we;const gt=l.useRef(Ae);gt.current=Ae;const Zt=l.useRef(Pt);Zt.current=Pt;const Ce=l.useCallback((a,d)=>{const y=U.current,S=qt.current;if(!y||a<0||a>=S.length-1)return!1;const $=y.getScrollPosition(),V=y.getViewportSize();if($<0||V<=0)return!1;const fe=fn(S[a],S[a+1],$,V,d);return fe===null?!1:(y.scrollToIndex(a,{align:fe}),!0)},[]),ve=l.useCallback(a=>{const d=He.current.get(a);if(d===void 0){We.current=a,Ce(a,"whole")||(We.current=null);return}We.current=null,Ce(a,"whole"),d.focus({preventScroll:!0})},[Ce]),Qt=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(y=>y.anchor===null?y:{...y,anchor:{...y.anchor,focused:!0}});else{const y=He.current.get(a);He.current.delete(a),y?.contains(y.ownerDocument.activeElement)&&Be(S=>S.anchor===null?S:{...S,anchor:{...S.anchor,focused:!1}})}a===gt.current&&Kt(d!==null)},[]);l.useLayoutEffect(()=>{Kt(He.current.has(Ae))},[Ae]);const wt=l.useCallback((a,d,y)=>{const S=Qe.current===y;Qe.current=null,S||(Be($=>En($,d)),Ce(a,"visible")),Zt.current?.(a)},[Ce]),vt=l.useCallback((a,d)=>{const{ownerDocument:y}=d;if(!y.hasFocus()&&d.contains(y.activeElement)){Qe.current=d;return}Qe.current=null,Be(S=>S.anchor!==null&&S.anchor.path===a?{...S,anchor:{...S.anchor,focused:!1}}:S)},[]),Dr=l.useCallback(()=>ve(gt.current),[ve]),xt=l.useCallback((a,d)=>{const y=gr(d),S=bt.current.length;if(!Number.isInteger(a)||a<0||a>=S)throw new RangeError(`[directory-tree] scrollToIndex: ${String(a)} is not a row index (${S===0?"the tree has no rows":`expected an integer in 0..${String(S-1)}`}).`);if(y==="nearest"){Ce(a,"whole");return}U.current?.scrollToIndex(a,{align:y})},[Ce]);l.useImperativeHandle(A,()=>({scrollToIndex:xt,scrollToPath:(a,d)=>{gr(d);const y=Jt.current.get(a);return y===void 0?!1:(xt(y,d),!0)},getScrollAnchor:()=>U.current?.getScrollAnchor()??null}),[xt]);const er=l.useCallback((a,d)=>{if(a.altKey||a.ctrlKey||a.metaKey)return;const y=bt.current,S=y.length-1;if(S<0)return;const $=y[d],V=$?.entry.children!==void 0,fe=V&&Xt.current($.entry.absolutePath);switch(a.key){case"ArrowDown":a.preventDefault(),ve(Math.min(d+1,S));break;case"ArrowUp":a.preventDefault(),ve(Math.max(d-1,0));break;case"Home":a.preventDefault(),ve(0);break;case"End":a.preventDefault(),ve(S);break;case"ArrowRight":a.preventDefault(),V&&!fe?yt.current($.entry.absolutePath):V&&d<S&&y[d+1].depth>$.depth&&ve(d+1);break;case"ArrowLeft":{if(a.preventDefault(),V&&fe){yt.current($.entry.absolutePath);break}const zr=$?.depth??0;for(let nt=d-1;nt>=0;nt--)if(y[nt].depth<zr){ve(nt);break}break}}},[ve]),et=l.useMemo(()=>!x||mt.length===0?{segmentsByItem:[],glyphsByItem:[]}:_n(mt,Se,we,at,x,P??fr),[mt,Se,we,x,P]),tt=l.useMemo(()=>!x||e.length===0?0:(Yt+2)*at,[e.length,Yt,x]),{renderStart:tr,renderEnd:rr,lookaheadEnd:nr}=l.useMemo(()=>Nn(J.length,_e,Ne,Ge,qe,we),[J.length,_e,Ne,Ge,qe,we]),St=l.useMemo(()=>!x||tt<=0||_e<=0||et.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:tt,height:_e},children:u.jsx(Ar,{segmentsByItem:et.segmentsByItem,glyphsByItem:et.glyphsByItem,itemHeight:Se[0]??ot,width:tt,viewportHeight:_e,scrollPosition:qe,color:B,expandGlyphColor:B,expandGlyphSize:P??fr,renderStartIndex:tr,renderEndIndex:rr,lookaheadEndIndex:nr})})}),[tt,_e,tr,rr,nr,qe,et,B,x,P,Se]),sr=l.useCallback(a=>J[a],[J]),or=l.useRef(null);l.useLayoutEffect(()=>{const a=or.current;if(or.current={items:J,offsets:we},!Mt||!a||a.items===J)return;const d=U.current,y=d?.getScrollPosition(),S=typeof y=="number"&&y>=0?y:dt.current,$=hn(a.items,a.offsets,S);if(!$)return;const V=pn($,J,we);if(V===null||Math.abs(V-S)<1)return;const fe=d?d.scrollTo(V):V;dt.current=fe,Dt(fe)},[J,we,Mt]);const Ee=w?.columns,Me=w?.scrollBarWidth??it?.width??Tr,ee=l.useMemo(()=>Ee?ln({measuredWidth:z,columns:Ee,scrollBarWidth:Me}):null,[Ee,z,Me]),rt=l.useMemo(()=>Ee?an(Ee):"",[Ee]),$r=l.useMemo(()=>w?.showFooter&&Ee?cn(e):[],[w?.showFooter,Ee,e]),Le=ee?.maxHScroll??0;l.useEffect(()=>{De(a=>Et(a,Le))},[Le]);const ar=l.useCallback(a=>De(d=>Et(d+a,Le)),[Le]),lr=l.useMemo(()=>({iconOverrides:D,showExpandIcons:C,showDirectoryIcons:g,showFileIcons:W,useCanvasExpandIcons:x,expandIconSize:P,highlightStyles:q,expandIconClassName:_,expandIconStyle:o}),[D,C,g,W,x,P,q,_,o]),cr=l.useMemo(()=>u.jsx(be.VirtualScroll,{ref:U,itemCount:J.length,getItem:sr,getItemHeight:Gt,getItemKey:Vt,testId:Lt,contentProps:Ot,locale:Q,labels:ue,viewportSize:typeof oe=="number"?oe:void 0,overscanCount:Ne,onScroll:$t,onRangeChange:Bt,onScrollAdjust:Je,liveRegion:$e,className:Ve,onWheelHorizontal:re?ar: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:St}):St,Ue]}),initialScrollIndex:G,initialScrollOffset:ge,initialScrollAnchor:Tt,callbackThrottleMs:Nt,contentInsets:_t,scrollBarOptions:it,behaviorOptions:Ft,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:wt,onRowBlur:vt,isSelectedForAria:!!k?.has(a.entry.absolutePath),rowHeight:a.rowHeight,isDirOpen:ye,columns:w.columns,numericTemplate:rt,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,rowClassName:w.rowClassName,selection:{onEntryClick:j,selectedPath:Pe,currentPath:ht,mode:b,selectedItems:k,onSelectionChange:R},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ft},visual:lr},a.entry.absolutePath):u.jsx(jt,{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:Qt,onNavigationKeyDown:er,onRowFocus:wt,onRowBlur:vt,rowHeight:a.rowHeight,entryKindDirectory:Te,entryKindFile:Re,isDirOpen:ye,parentIsLast:a.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ft},selection:{onEntryClick:j,selectedPath:Pe,currentPath:ht,mode:b,selectedItems:k,onSelectionChange:R},visual:{iconOverrides:D,showExpandIcons:C,showDirectoryIcons:g,showFileIcons:W,useCanvasExpandIcons:x,expandIconSize:P,highlightStyles:q,entryClassName:Z,entryStyle:ne,nameClassName:te,nameStyle:H,directoryNameClassName:he,directoryNameStyle:le,fileNameClassName:ce,fileNameStyle:Y,expandIconClassName:_,expandIconStyle:o}},a.entry.absolutePath):null}),[J.length,sr,Gt,Vt,Lt,Ot,Q,ue,Te,Re,Ae,Qt,er,wt,vt,oe,Ne,$t,Bt,Je,$e,Ve,re,ar,ee,St,Ue,G,ge,Tt,Nt,_t,it,Ft,w,rt,ye,j,Pe,ht,b,k,R,t,ft,lr,D,C,g,W,x,P,q,Z,ne,te,H,he,le,ce,Y,_,o]);if(!(w&&ee))return u.jsxs("div",{ref:X,className:Ht,style:Wt,children:[Ie.length>0&&!Fr&&u.jsx("span",{tabIndex:0,"data-directory-tree-tab-stop":"",style:jn,onFocus:Dr}),cr]});const Br=w.showHeader??!0,Hr=w.showFooter??!1,Wr={...Wt,"--dt-hscroll":`${Fe}px`};return u.jsxs("div",{ref:X,className:M.twMerge(Ht,"dt-grid"),style:Wr,role:"treegrid","aria-label":I?void 0:v,"aria-labelledby":I,"aria-multiselectable":b==="multiple"?!0:void 0,"aria-rowcount":J.length+(w.showHeader??!0?1:0),children:[Br&&u.jsx("div",{role:"rowgroup",children:u.jsx(nn,{columns:w.columns,numericTemplate:rt,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Me,className:w.headerClassName})}),u.jsx("div",{ref:xe,className:"dt-grid-body",children:cr}),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(be.ScrollBar,{horizontal:!0,contentSize:ee.numericTotal,viewportSize:ee.numericVisible,scrollPosition:Fe,scrollBarWidth:Me,locale:Q,labels:ue,onScroll:a=>{const d=typeof a=="function"?a(Fe):a,y=Et(d,Le);return De(y),y}}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Me},"aria-hidden":"true"})]}),Hr&&u.jsx("div",{role:"rowgroup",children:u.jsx(sn,{columns:w.columns,numericTemplate:rt,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Me,allEntries:$r,className:w.footerClassName})})]})},An=({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 I=new Set(v);return h(I),I})})},[]),f=l.useCallback((h,v)=>{i(I=>{for(const B of h)v(I,B)})},[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,I)=>{v.has(I)?v.delete(I):v.add(I)})},[f]),E=l.useCallback(h=>{f([h],(v,I)=>{v.add(I)})},[f]),m=l.useCallback(h=>{f([h],(v,I)=>{v.delete(I)})},[f]),b=l.useCallback(h=>{f(h,(v,I)=>{v.delete(I)})},[f]),k=l.useCallback(h=>{f(h,(v,I)=>{v.add(I)})},[f]),R=l.useCallback(()=>{i(h=>{h.clear()})},[i]),N=l.useCallback(h=>s.has(h),[s]);return{expanded:s,toggle:j,expand:E,collapse:m,collapseMultiple:b,expandMultiple:k,collapseAll:R,isExpanded:N,isPending:r}};exports.DIRECTORY_TREE_LABEL_CATALOGS=_r;exports.DIRECTORY_TREE_LABEL_KEYS=It;exports.DirectoryTree=Pn;exports.directoryTreeClasses=F;exports.resolveDirectoryTreeLabels=Pr;exports.useDirectoryTreeState=An;
6
+ <%s key={someKey} {...props} />`,_,M,Z,M),j[M+_]=!0)}if(M=null,v!==void 0&&(r(v),M=""+v),i(p)&&(r(p.key),M=""+p.key),"key"in p){v={};for(var me in p)me!=="key"&&(v[me]=p[me])}else v=p;return M&&u(v,typeof o=="function"?o.displayName||o.name||"Unknown":o),S(o,M,v,a(),ne,ie)}function y(o){R(o)?o._store&&(o._store.validated=1):typeof o=="object"&&o!==null&&o.$$typeof===V&&(o._payload.status==="fulfilled"?R(o._payload.value)&&o._payload.value._store&&(o._payload.value._store.validated=1):o._store&&(o._store.validated=1))}function R(o){return typeof o=="object"&&o!==null&&o.$$typeof===N}var E=l,N=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),F=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),C=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),X=Symbol.for("react.client.reference"),q=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,re=Object.prototype.hasOwnProperty,ee=Array.isArray,$=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(o){return o()}};var he,le={},ce=E.react_stack_bottom_frame.bind(E,c)(),z=$(n(c)),j={};ze.Fragment=w,ze.jsx=function(o,p,v){var _=1e4>q.recentlyCreatedOwnerStacks++;return h(o,p,v,!1,_?Error("react-stack-top-frame"):ce,_?$(n(o)):z)},ze.jsxs=function(o,p,v){var _=1e4>q.recentlyCreatedOwnerStacks++;return h(o,p,v,!0,_?Error("react-stack-top-frame"):ce,_?$(n(o)):z)}})()),ze}var fr;function Jr(){return fr||(fr=1,process.env.NODE_ENV==="production"?st.exports=Ur():st.exports=Xr()),st.exports}var f=Jr();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:"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 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",{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 en=fe.forwardRef(Qr);function tn({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 rn=fe.forwardRef(tn),at=18,lt=12,hr=8,L={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:A.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:A.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:A.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:A.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:A.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:A.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:A.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:A.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:A.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},_t=e=>{const t=e.slice(e.lastIndexOf("/")+1),r=t.lastIndexOf(".");return r<=0?"":t.slice(r+1).toLowerCase()},nn=/^[a-z][a-z\d+.-]*:\/\//i,mr=e=>_t(nn.test(e)?e.split(/[?#]/,1)[0]:e),Sr=e=>_t(e.name)||mr(e.relativePath)||mr(e.absolutePath),Er=({isDirectory:e,isExpanded:t,showExpandIcons:r,useCanvasExpandIcons:n,expandIconSize:a})=>{const c=a?{width:a,height:a}:void 0,i=a?"":"h-4 w-4";return!(r&&e)||n?f.jsx("span",{className:i,style:c,"aria-hidden":"true"}):t?f.jsx(Zr,{className:i,style:c}):f.jsx(en,{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 n=e.map(a=>kt(a,t)).filter(Boolean);return n.length?n:null}const r=e.type;if(r&&r.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},on={markdown:()=>f.jsx(se.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"}),pdf:()=>f.jsx(se.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"}),spreadsheet:()=>f.jsx(se.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"}),csv:()=>f.jsx(se.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"}),document:()=>f.jsx(se.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),presentation:()=>f.jsx(se.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"}),image:()=>f.jsx(se.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"}),audio:()=>f.jsx(se.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"}),video:()=>f.jsx(se.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"}),archive:()=>f.jsx(se.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"}),code:()=>f.jsx(se.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"}),text:()=>f.jsx(se.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})},sn={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"]},an=new Map(Object.entries(sn).flatMap(([e,t])=>t.map(r=>[r,e]))),ln=new Set(["","application/octet-stream","binary/octet-stream","text/plain","application/x-empty"]),cn=e=>(e??"").split(";",1)[0].trim().toLowerCase(),un=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"},dn=(e,t,r)=>{const n=cn(e),a=un(n),c=an.get((t||(r?_t(r):"")).toLowerCase()),u=(ln.has(n)?[c,a]:[a,c]).find(I=>I!==void 0);return u===void 0?f.jsx(se.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"}):on[u]()},Rr=(e,t)=>{const{entry:r,isDirectory:n,isExpanded:a,extension:c,mimeType:i}=e;let u;const I=i||r.mimeType;return r.icon!==void 0?u=r.icon:n?u=a&&t?.directoryExpanded||t?.directory||f.jsx(rn,{className:"h-4 w-4"}):c&&t?.fileByExtension?.[c]?u=t.fileByExtension[c]:u=t?.file||dn(I,c,r.name),kt(typeof u=="function"?u(e):u,r.absolutePath)},fn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),kr=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-${fn(r)}`,String(n)]))},hn=500,Ir=({entry:e,isDirectory:t,isExpanded:r,isItemSelected:n,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(h=>{h.stopPropagation(),a!=="none"&&!t&&c&&c(e,!n);let y=!1;i({entry:e,isDirectory:t,isExpanded:r,preventDefault:()=>{y=!0}}),!(!t||y)&&(S.current?(window.clearTimeout(S.current),S.current=null,I(e)):S.current=window.setTimeout(()=>{u(e.absolutePath),S.current=null},hn))},[t,e,r,I,u,i,a,c,n])},Cr=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",pr=(e,t)=>e.children!==void 0&&t(e.absolutePath),Tr=(e,t)=>({width:e,gridTemplateColumns:t}),_r=l.memo(({entry:e,indentLevel:t,positionInSet:r,setSize:n,rowIndex:a,flatIndex:c,onRowFocus:i,onRowBlur:u,isSelectedForAria:I,rowHeight:S,isDirOpen:h,columns:y,numericTemplate:R,numericTotal:E,nameWidth:N,rowClassName:m,selection:{onEntryClick:w,selectedPath:k,currentPath:F,mode:x="none",selectedItems:C,onSelectionChange:b},expansion:{toggleDirectory:H,onToggleDirectoryRecursive:D},visual:{iconOverrides:P,showExpandIcons:V=!0,showDirectoryIcons:ae=!0,showFileIcons:X=!0,useCanvasExpandIcons:q=!1,expandIconSize:re,indentSize:ee=lt,highlightStyles:$,expandIconClassName:he,expandIconStyle:le}})=>{const[ce,z]=l.useState(!1),j=e.children!==void 0,o=j&&h(e.absolutePath),p=e.absolutePath===k,v=e.absolutePath===F,_=!j&&!!C?.has(e.absolutePath),ne=j?void 0:Sr(e),ie=Ir({entry:e,isDirectory:j,isExpanded:o,isItemSelected:_,selectionMode:x,onSelectionChange:b,onEntryClick:w,toggleDirectory:H,onToggleDirectoryRecursive:D}),M=ce?$?.hoverClassName!==void 0?$.hoverClassName:L.entryHover:"",Z=(()=>{if(j){if(p)return $?.directorySelectedClassName!==void 0?$.directorySelectedClassName:L.entrySelected}else if(p||_)return $?.itemSelectedClassName!==void 0?$.itemSelectedClassName:A.twMerge(p&&L.entrySelected,_&&L.entryItemSelected);return""})(),me=typeof m=="function"?m(e):m,ue=A.twMerge("dt-grid-row cursor-pointer select-none",M,Z,me,e.className),Te=A.twMerge(L.expandIcon,he,(p||_)&&L.expandIconSelected),Ee=A.twMerge(L.typeIcon,(p||_)&&L.typeIconSelected),te=A.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",j&&L.nameDirectory,(p||_)&&L.nameSelected),O=Er({isDirectory:j,isExpanded:o,showExpandIcons:V,useCanvasExpandIcons:q,expandIconSize:re}),de=(j?ae:X)?Rr({entry:e,isDirectory:j,isExpanded:o,isSelected:p,isItemSelected:_,extension:ne,mimeType:e.mimeType},P):null,K={indentLevel:t,isDirectory:j,isExpanded:o},[we,...G]=y,Oe=we?.render?we.render(e,K):e.label??e.name,Re={...ce?$?.hoverStyle:{},...j&&p?$?.directorySelectedStyle:{},...!j&&(p||_)?$?.itemSelectedStyle:{}};return f.jsxs("div",{className:ue,style:{height:S,...Re,...e.style},role:"row","aria-expanded":j?o:void 0,"aria-level":t+1,"aria-posinset":r,"aria-setsize":n,"aria-rowindex":a,"aria-selected":x==="none"?void 0:I,"aria-current":v?"page":void 0,...kr(e.data),"data-entry-type":j?"directory":"file","data-entry-expanded":j?String(o):void 0,"data-entry-selected":p?"true":void 0,"data-entry-item-selected":_?"true":void 0,onClick:ie,onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1),onFocus:W=>i(c,e.absolutePath,W.currentTarget),onBlur:W=>u(e.absolutePath,W.currentTarget),onKeyDown:W=>{if(W.key==="Enter"){if(W.repeat){W.preventDefault();return}ie(W)}},tabIndex:0,children:[f.jsxs("div",{className:A.twMerge("dt-grid-name-cell",we?.className),role:"gridcell",style:{width:N,paddingLeft:Math.max(0,t*ee)},children:[(V||q)&&f.jsx("span",{className:Te,style:le,children:O}),(j?ae:X)&&f.jsx("span",{className:Ee,children:de}),f.jsx("span",{className:te,children:Oe})]}),G.length>0&&f.jsx("div",{className:"dt-grid-numeric-viewport",children:f.jsx("div",{className:"dt-grid-numeric-track",style:Tr(E,R),children:G.map(W=>f.jsx("div",{className:A.twMerge("dt-grid-cell",Cr(W.align),W.className),role:"gridcell",children:W.render?W.render(e,K):null},W.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=pr(e.entry,e.isDirOpen),n=pr(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});_r.displayName="DirectoryTreeGridRow";const Nr=({kind:e,columns:t,numericTemplate:r,numericTotal:n,nameWidth:a,scrollBarWidth:c,className:i,nameContent:u,renderCell:I})=>{const[,...S]=t,h=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",y=e==="header"?"dt-grid-header":"dt-grid-footer",R=e==="header"?"columnheader":"gridcell";return f.jsxs("div",{className:A.twMerge(y,"text-gray-600 dark:text-gray-300",i),role:"row",children:[f.jsx("div",{className:A.twMerge(h,"px-1",t[0]?.className),role:R,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:Tr(n,r),children:S.map(E=>f.jsx("div",{className:A.twMerge("dt-grid-cell",Cr(E.align),E.className),role:R,children:I(E)},E.key))})}),f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},mn=({columns:e,className:t,...r})=>f.jsx(Nr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...r}),yr=(e,t)=>typeof e=="function"?e(t):e??null,pn=({columns:e,allEntries:t,className:r,...n})=>f.jsx(Nr,{kind:"footer",columns:e,className:r,nameContent:yr(e[0]?.footer,t),renderCell:a=>yr(a.footer,t),...n}),yn=240,jr=96,Pr=12,It=(e,t)=>{const r=e?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:t},bn=e=>e.slice(1).map(t=>`${It(t,jr)}px`).join(" "),gn=({measuredWidth:e,columns:t,scrollBarWidth:r=Pr})=>{const n=It(t[0],yn),a=t.slice(1).reduce((I,S)=>I+It(S,jr),0),c=Number.isFinite(e)&&e>0?e:0,i=Math.max(0,c-n-Math.max(0,r)),u=Math.max(0,a-i);return{nameWidth:n,numericTotal:a,numericVisible:i,maxHScroll:u}},Rt=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,vn=e=>{const t=[],r=n=>{for(const a of n)t.push(a),a.children&&a.children.length>0&&r(a.children)};return r(e),t},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:"ファイル"})}),Ar=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,wn=e=>{const t={};let r=!1;for(const n of pe.VIRTUAL_SCROLL_LABEL_KEYS){const a=Object.hasOwn(e,n)?e[n]:void 0;a!==void 0&&(t[n]=a,r=!0)}return r?t:void 0},Or=(e,t)=>{const r=pe.resolveVirtualScrollLocale(e);if(t===void 0)return Ar[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(!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,wn(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 ${br(u)}`);c[i]=u}}return Object.freeze(c)},xn=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}},En=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,a=r-1,c=0;for(;n<=a;){const i=n+a>>>1;e[i]<=t?(c=i,n=i+1):a=i-1}return c},Rn=(e,t,r)=>{if(r<=0||e.length===0||t.length!==e.length+1)return null;const n=En(t,r),a=e[n];return a?{path:a.entry.absolutePath,offsetInViewport:r-t[n]}:null},kn=(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},In=(e,t,r)=>{const n=[];for(let a=t;a<r;a++){const c=e[a];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},Cn=(e,t,r)=>{const n=[];for(let a=t;a<r;a++){const c=e[a];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},Tn=(e,t,r,n)=>{const a=Math.max(1,Math.floor(t*n)),c=Math.max(1,Math.floor(r*n));(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`)},_n=(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()},Nn=(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(u=>u+u).join(""));const a=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(${a}, ${c}, ${i}, ${t})`},jn=(e,t,r,n)=>{if(t.length===0)return;const a=Nn(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 h of t){const y=n??h.size,R=Math.max(0,y/2),E=Math.max(1,Math.round(y*.08)),N=Math.max(1,Math.round(y*.14)),m=Math.max(0,R-E*.8),w=Math.max(0,m*.55);a&&(e.fillStyle=a,e.beginPath(),e.arc(h.centerX,h.centerY,m,0,Math.PI*2),e.fill()),e.lineWidth=E,e.beginPath(),e.arc(h.centerX,h.centerY,Math.max(0,R-E*.3),0,Math.PI*2),e.stroke(),e.lineWidth=N,e.beginPath(),e.moveTo(h.centerX-w,h.centerY),e.lineTo(h.centerX+w,h.centerY),e.stroke(),h.isExpanded||(e.beginPath(),e.moveTo(h.centerX,h.centerY-w),e.lineTo(h.centerX,h.centerY+w),e.stroke())}e.strokeStyle=c,e.fillStyle=i,e.lineWidth=u,e.lineCap=I,e.lineJoin=S},Lr=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i="#a0aec0",strokeWidth:u=1,renderStartIndex:I,renderEndIndex:S,lookaheadEndIndex:h,devicePixelRatio:y,expandGlyphColor:R,expandGlyphSize:E})=>{const N=l.useRef(null),m=l.useRef(null),w=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i,strokeWidth:u,renderStartIndex:I,renderEndIndex:S,lookaheadEndIndex:h,devicePixelRatio:y,expandGlyphColor:R,expandGlyphSize:E}),k=l.useCallback(()=>{m.current=null;const x=N.current;if(!x)return;const C=x.getContext("2d");if(!C)return;const b=w.current;if(b.width<=0||b.viewportHeight<=0){C.clearRect(0,0,x.width,x.height);return}const H=Number.isFinite(b.devicePixelRatio??NaN)?b.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;Tn(x,b.width,b.viewportHeight,H);const D=b.segmentsByItem.length,P=typeof b.renderStartIndex=="number"&&Number.isFinite(b.renderStartIndex)?Math.max(0,Math.floor(b.renderStartIndex)):Math.max(0,Math.floor(b.scrollPosition/b.itemHeight)),V=Math.min(D,Math.ceil((b.scrollPosition+b.viewportHeight)/b.itemHeight)),ae=(()=>{if(typeof b.renderEndIndex=="number"&&Number.isFinite(b.renderEndIndex)){const ee=Math.floor(b.renderEndIndex);return Math.max(Math.min(D,ee+1),P)}return Math.max(V,P)})(),X=(()=>{if(typeof b.lookaheadEndIndex=="number"&&Number.isFinite(b.lookaheadEndIndex)){const ee=Math.floor(b.lookaheadEndIndex),$=Math.min(D,ee+1);return Math.max($,ae)}return Math.max(V,ae)})(),q=In(b.segmentsByItem,P,X),re=Cn(b.glyphsByItem,P,X);C.save(),C.scale(H,H),C.clearRect(0,0,b.width,b.viewportHeight),C.translate(0,-b.scrollPosition),C.strokeStyle=b.color,_n(C,q,b.strokeWidth),jn(C,re,b.expandGlyphColor??b.color,b.expandGlyphSize),C.restore()},[]),F=l.useCallback(()=>{m.current===null&&(m.current=window.requestAnimationFrame(k))},[k]);return l.useEffect(()=>{w.current={segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:a,scrollPosition:c,color:i,strokeWidth:u,renderStartIndex:I,renderEndIndex:S,lookaheadEndIndex:h,devicePixelRatio:y,expandGlyphColor:R,expandGlyphSize:E},F()},[e,t,r,n,a,c,i,u,I,S,h,y,R,E,F]),l.useEffect(()=>()=>{m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null)},[]),f.jsx("canvas",{ref:N,className:"pointer-events-none absolute top-0 left-0 z-0"})});Lr.displayName="TreeLineCanvas";const Pn=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},gr=(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}}),An=(e,t)=>{const{anchor:r,selectionGeneration:n,selectedPath:a}=t;if(r!==null&&(r.focused||r.selectionGeneration===n)){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"},Ln=()=>{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))},Dn=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)},vr=new Set(["top","bottom","center","nearest"]),wr=e=>{const t=e?.align;if(t===void 0)return"top";if(!vr.has(t))throw new RangeError(`[directory-tree] Unsupported scroll alignment ${JSON.stringify(t)}; expected one of ${[...vr].join(", ")}.`);return t},Fn={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},$n=(e,t,r,n,a)=>{const c=[],i=[];let u=0;const I=(S,h,y)=>{const R=a?[...S].sort(a):S;for(let E=0;E<R.length;E++){const N=R[E],m=E===R.length-1,w=[...y,m],k=N.children!==void 0,F=k&&t(N.absolutePath,N.relativePath);let x=h,C=w,b=y;n&&(x=h-1,C=w.slice(1),b=y.slice(1)),c.push({entry:N,indentLevel:x,depth:h,positionInSet:E+1,setSize:R.length,parentIsLast:C}),r&&(x>u&&(u=x),i.push({id:N.absolutePath,name:N.name,absolutePath:N.absolutePath,indentLevel:x,isLastChild:m,isDirectory:k,isExpanded:F,ancestorIsLast:[...b],hideLines:n&&h===0})),k&&F&&N.children&&I(N.children,h+1,w)}};return I(e,0,[]),{flatItems:c,lineItems:i,maxIndent:u}},xr=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,a=r-1,c=0;for(;n<=a;){const i=n+a>>>1;e[i]<=t?(c=i,n=i+1):a=i-1}return c},Bn=(e,t,r,n,a,c)=>{const i=n?.renderStart??Math.max(0,xr(c,a)),u=t>0?xr(c,a+t)+r:i+r,I=e>0?Math.min(e-1,Math.max(i,u)):i,S=n?.renderEnd??I,h=e>0?Math.min(e-1,S+r):S;return{renderStart:i,renderEnd:S,lookaheadEnd:h}},Hn=(e,t,r,n,a,c)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const i=Array.from({length:e.length},()=>[]),u=Array.from({length:e.length},()=>[]),I=h=>a?typeof c=="number"&&Number.isFinite(c)&&c>0?c:Math.max(8,Math.min(n*.9,h*.7)):0,S=3;for(let h=0;h<e.length;h++){const y=e[h];if(y.hideLines)continue;const R=[],E=t[h]??0,N=r[h]??0,m=N+E/2,w=I(E),k=w>0?w/2+2:n/1.5;for(let C=0;C<y.indentLevel;C++){if(y.ancestorIsLast[C]??!1)continue;let H=!1;for(let D=h;D<e.length;D++){const P=e[D];if(P.indentLevel>C&&P.ancestorIsLast.length>C&&!P.ancestorIsLast[C]){H=!0;break}if(D>h&&P.indentLevel===C)break}if(H){const D=C*n+n/2+S;R.push({key:`${y.id}-ancestor-${C}`,x1:D,y1:N,x2:D,y2:N+E,itemIndex:h})}}const F=y.indentLevel*n,x=F+n/2+S;if(y.isDirectory?R.push({key:`${y.id}-connector-top`,x1:x,y1:N,x2:x,y2:m-k,itemIndex:h}):R.push({key:`${y.id}-connector-top`,x1:x,y1:N,x2:x,y2:m,itemIndex:h}),!y.isDirectory&&y.isLastChild&&R.push({key:`${y.id}-connector-horizontal`,x1:x,y1:m,x2:F+n+S,y2:m,itemIndex:h}),y.isLastChild||(y.isDirectory?R.push({key:`${y.id}-connector-bottom`,x1:x,y1:m+k,x2:x,y2:N+E,itemIndex:h}):R.push({key:`${y.id}-connector-bottom`,x1:x,y1:m,x2:x,y2:N+E,itemIndex:h})),i[h]=R,a&&y.isDirectory){const C=w,b=x,H=m;u[h]=[{key:`${y.id}-glyph`,itemIndex:h,centerX:b,centerY:H,size:C,isExpanded:y.isExpanded}]}}return{segmentsByItem:i,glyphsByItem:u}},Nt=l.memo(({entry:e,indentLevel:t,depth:r,positionInSet:n,setSize:a,isSelectedForAria:c,flatIndex:i,isActive:u,registerRowRef:I,onNavigationKeyDown:S,onRowFocus:h,onRowBlur:y,rowHeight:R,entryKindDirectory:E,entryKindFile:N,isDirOpen:m,parentIsLast:w,renderChildren:k=!0,expansion:{toggleDirectory:F,onToggleDirectoryRecursive:x},selection:{onEntryClick:C,selectedPath:b,currentPath:H,mode:D="none",selectedItems:P,onSelectionChange:V},visual:{iconOverrides:ae,showExpandIcons:X=!0,showDirectoryIcons:q=!0,showFileIcons:re=!0,useCanvasExpandIcons:ee=!1,expandIconSize:$,typeIconSize:he,fontSize:le,indentSize:ce=lt,highlightStyles:z,entryClassName:j,entryStyle:o,nameClassName:p,nameStyle:v,directoryNameClassName:_,directoryNameStyle:ne,fileNameClassName:ie,fileNameStyle:M,expandIconClassName:Z,expandIconStyle:me}})=>{const[ue,Te]=l.useState(null),[Ee,te]=l.useState(!1),O=e.children!==void 0,de=O&&m(e.absolutePath),K=e.absolutePath===b,we=e.absolutePath===H,G=!O&&P?.has(e.absolutePath),Oe=l.useCallback(Y=>I(i,Y),[I,i]),Re=O?void 0:Sr(e);l.useEffect(()=>{Te(de&&e.children?e.children:null)},[de,e.children]);const W=Ir({entry:e,isDirectory:O,isExpanded:de,isItemSelected:!!G,selectionMode:D,onSelectionChange:V,onEntryClick:C,toggleDirectory:F,onToggleDirectoryRecursive:x}),ct=Ee?z?.hoverClassName!==void 0?z.hoverClassName:L.entryHover:"",Le=(()=>{if(O){if(K)return z?.directorySelectedClassName!==void 0?z.directorySelectedClassName:L.entrySelected}else if(K||G)return z?.itemSelectedClassName!==void 0?z.itemSelectedClassName:A.twMerge(K&&L.entrySelected,G&&L.entryItemSelected);return""})(),De=A.twMerge(L.entry,ct,Le,j,e.className),Ye=A.twMerge(L.expandIcon,Z,(K||G)&&L.expandIconSelected),it=A.twMerge(L.typeIcon,(K||G)&&L.typeIconSelected),_e=A.twMerge(L.name,p,O&&L.nameDirectory,O&&_,!O&&ie,(K||G)&&L.nameSelected),Ge=Er({isDirectory:O,isExpanded:de,showExpandIcons:X,useCanvasExpandIcons:ee,expandIconSize:$}),Ve=(O?q:re)?Rr({entry:e,isDirectory:O,isExpanded:de,isSelected:K,isItemSelected:!!G,extension:Re,mimeType:e.mimeType},ae):null,Ke={...Ee?z?.hoverStyle:{},...O&&K?z?.directorySelectedStyle:{},...!O&&(K||G)?z?.itemSelectedStyle:{}},Ue=kr(e.data),Xe=he?{width:he,height:he}:void 0,Fe=le?{fontSize:typeof le=="number"?`${le}px`:le}:void 0;return f.jsxs(l.Fragment,{children:[f.jsxs("div",{className:De,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:`${R}px`,...Fe,...Ke,...o,...e.style},...Ue,"data-entry-type":O?"directory":"file","data-entry-expanded":O?String(de):void 0,"data-entry-selected":K?"true":void 0,"data-entry-item-selected":G?"true":void 0,onClick:W,onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),onFocus:Y=>h(i,e.absolutePath,Y.currentTarget),onBlur:Y=>y(e.absolutePath,Y.currentTarget),ref:Oe,onKeyDown:Y=>{if(Y.key==="Enter"||Y.key===" "){Y.preventDefault(),Y.repeat||W(Y);return}S(Y,i)},tabIndex:u?0:-1,role:"treeitem","aria-expanded":O?de:void 0,"aria-level":r+1,"aria-posinset":n,"aria-setsize":a,"aria-selected":D==="none"?void 0:c,"aria-current":we?"page":void 0,"aria-label":`${e.name} (${O?E:N})`,children:[(X||ee)&&f.jsx("span",{className:Ye,style:me,children:Ge}),(O?q:re)&&f.jsx("span",{className:it,style:Xe,children:Ve}),f.jsx("span",{className:_e,style:{...Fe,...v,...O?ne:M},"data-entry-type":O?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),de&&ue&&k&&f.jsx("fieldset",{children:ue.map((Y,be)=>f.jsx(Nt,{entry:Y,indentLevel:t+1,depth:r+1,positionInSet:be+1,setSize:ue.length,isSelectedForAria:!!P?.has(Y.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:I,onNavigationKeyDown:S,onRowFocus:h,onRowBlur:y,rowHeight:R,entryKindDirectory:E,entryKindFile:N,isDirOpen:m,parentIsLast:[...w,be===ue.length-1],expansion:{toggleDirectory:F,onToggleDirectoryRecursive:x},selection:{onEntryClick:C,selectedPath:b,currentPath:H,mode:D,selectedItems:P,onSelectionChange:V},visual:{iconOverrides:ae,showExpandIcons:X,showDirectoryIcons:q,showFileIcons:re,useCanvasExpandIcons:ee,expandIconSize:$,highlightStyles:z,entryClassName:j,entryStyle:o,nameClassName:p,nameStyle:v,directoryNameClassName:_,directoryNameStyle:ne,fileNameClassName:ie,fileNameStyle:M,expandIconClassName:Z,expandIconStyle:me}},Y.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,a=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&&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])});Nt.displayName="DirectoryEntryItem";const Dr=e=>{const t=[];if(e.children)for(const r of e.children)r.type==="directory"&&(t.push(r.absolutePath),t.push(...Dr(r)));return t},Wn=({entries:e,expansion:{toggle:t,isExpanded:r,expandMultiple:n,collapseMultiple:a,isPending:c,alwaysExpanded:i=!1,doubleClickAction:u="recursive"},selection:{onEntryClick:I,selectedPath:S,currentPath:h,mode:y="none",selectedItems:R,onSelectionChange:E},visual:{className:N,style:m,ariaLabel:w,ariaLabelledBy:k,lineColor:F="#A0AEC0",showTreeLines:x=!0,showExpandIcons:C=!0,showDirectoryIcons:b=!0,showFileIcons:H=!0,iconOverrides:D,expandIconSize:P,itemHeight:V=at,removeRootIndent:ae=!1,highlightStyles:X,entryClassName:q,entryStyle:re,nameClassName:ee,nameStyle:$,directoryNameClassName:he,directoryNameStyle:le,fileNameClassName:ce,fileNameStyle:z,expandIconClassName:j,expandIconStyle:o}={},virtualScroll:p,grid:v,sort:_,locale:ne,labels:ie,ref:M})=>{const Z=pe.resolveVirtualScrollLocale(ne),me=l.useMemo(()=>Or(ne,ie),[ne,ie]),ue=Dn(xn(me)),{entryKindDirectory:Te,entryKindFile:Ee}=me,te=v!==void 0,[O,de]=l.useState(!1),K=l.useRef(null),we=l.useRef(null),G=l.useRef(null),[Oe,Re]=l.useState(0),[W,ct]=l.useState(0),[Le,De]=l.useState(0),[Ye,it]=l.useState(null),{overscanCount:_e=15,className:Ge,background:Ve,onScroll:Ke,onRangeChange:Ue,onScrollAdjust:Xe,liveRegion:Fe,initialScrollIndex:Y,initialScrollOffset:be,initialScrollAnchor:jt,callbackThrottleMs:Pt=5,contentInsets:Mt,onItemFocus:At,viewportHeightOverride:oe,scrollBarOptions:ut,behaviorOptions:Ot,preserveScrollAnchor:Lt=!1,getItemKey:Fr,testId:Dt,contentProps:dt}=p??{},Ft=l.useMemo(()=>te?{...dt,role:"rowgroup"}:{...dt,role:"tree","aria-label":k?void 0:w,"aria-labelledby":k,"aria-multiselectable":y==="multiple"?!0:void 0},[te,dt,w,k,y]),$t=l.useMemo(()=>({...Ot,enableKeyboardNavigation:!1}),[Ot]),[Je,Bt]=l.useState(typeof be=="number"?be:0),ft=l.useRef(typeof be=="number"?be:0),Ht=l.useCallback((s,d)=>{ft.current=s,Bt(s),Ke?.(s,d)},[Ke]),Wt=l.useCallback(s=>{const{renderingStartIndex:d,renderingEndIndex:g}=s;it(T=>T&&T.renderStart===d&&T.renderEnd===g?T:{renderStart:d,renderEnd:g}),Ue?.(s)},[Ue]);l.useEffect(()=>{de(!0),Ln()},[]),l.useEffect(()=>{const s=K.current,d=te?we.current:s,g=()=>{if(s){const B=s.clientWidth;ct(J=>Math.abs(J-B)>1?B:J)}if(typeof oe=="number")Re(B=>Math.abs(B-oe)>1?oe:B);else if(d){const B=d.clientHeight;Re(J=>Math.abs(J-B)>1?B:J)}};if(!(s||d))return Re(0);g();const T=new ResizeObserver(g);return s&&T.observe(s),d&&d!==s&&T.observe(d),()=>T.disconnect()},[oe,te]);const Ne=typeof oe=="number"?oe:Oe,ye=l.useCallback(s=>i||(O?r(s):!1),[O,r,i]),zt=A.twMerge(L.container,c&&L.containerPending,N),Yt=l.useMemo(()=>({...On,...m??{},...typeof oe=="number"?{height:oe,minHeight:oe}:{}}),[m,oe]),ht=l.useCallback((s,d)=>{const g=[s.absolutePath,...Dr(s)],T=d||u;if(g.every(ve=>ye(ve)))return a(g);if(g.every(ve=>!ye(ve))||T==="recursive")return n(g);if(T==="toggle")return a(g);console.warn(`[DirectoryTree] Unknown double click action: ${T}. No action taken.`)},[ye,n,a,u]),Gt=te?!1:ae,{flatItems:ke,lineItems:mt,maxIndent:Vt}=l.useMemo(()=>$n(e,ye,x,Gt,_),[e,ye,x,Gt,_]),U=l.useMemo(()=>ke.map((s,d)=>{const g=typeof V=="function"?V(s.entry,d):V;return{...s,rowHeight:Number.isFinite(g)&&g>0?g:at}}),[ke,V]),xe=l.useMemo(()=>U.map(s=>s.rowHeight),[U]),Ie=l.useMemo(()=>{const s=new Array(xe.length+1);s[0]=0;for(let d=0;d<xe.length;d++)s[d+1]=s[d]+xe[d];return s},[xe]),Kt=l.useCallback(s=>U[s]?.rowHeight??at,[U]),$r=l.useCallback(s=>U[s]?.entry.absolutePath??s,[U]),Ut=Fr??$r,je=S??null,pt=h??null,[Xt,$e]=l.useState(()=>({selectedPath:je,selectionGeneration:0,anchor:null})),yt=gr(Xt,je);yt!==Xt&&$e(s=>gr(s,je));const qe=l.useMemo(()=>Pn(ke),[ke]),Pe=l.useMemo(()=>An(qe,yt),[qe,yt]),Be=l.useRef(new Map),Ze=l.useRef(null),[Qe]=l.useState(Sn),He=l.useRef(null),[Br,Jt]=l.useState(!0),bt=l.useRef(ke);bt.current=ke;const qt=l.useRef(ye);qt.current=ye;const gt=l.useRef(t);gt.current=t;const Zt=l.useRef(qe);Zt.current=qe;const vt=l.useRef(Pe);vt.current=Pe;const Qt=l.useRef(At);Qt.current=At;const Ce=l.useCallback(s=>{const d=G.current;return!d||d.getViewportSize()<=0?!1:(d.scrollToIndex(s,{align:"nearest"}),!0)},[]),ge=l.useCallback(s=>{const d=Be.current.get(s);if(d===void 0){He.current=s,Ce(s)||(He.current=null);return}He.current=null,Ce(s),d.focus({preventScroll:!0})},[Ce]),er=l.useCallback((s,d)=>{if(d)Be.current.set(s,d),He.current===s?(He.current=null,d.focus({preventScroll:!0})):d.contains(d.ownerDocument.activeElement)&&$e(g=>g.anchor===null?g:{...g,anchor:{...g.anchor,focused:!0}});else{const g=Be.current.get(s);Be.current.delete(s),g?.contains(g.ownerDocument.activeElement)&&$e(T=>T.anchor===null?T:{...T,anchor:{...T.anchor,focused:!1}})}s===vt.current&&Jt(d!==null)},[]);l.useLayoutEffect(()=>{Jt(Be.current.has(Pe))},[Pe]);const wt=l.useCallback((s,d,g)=>{const T=Ze.current===g;Ze.current=null,T||($e(B=>Mn(B,d)),Qe.landedOn(g)||Ce(s)),Qt.current?.(s)},[Ce,Qe]),et=l.useCallback(s=>Qe.mark(s.nativeEvent),[Qe]),xt=l.useCallback((s,d)=>{const{ownerDocument:g}=d;if(!g.hasFocus()&&d.contains(g.activeElement)){Ze.current=d;return}Ze.current=null,$e(T=>T.anchor!==null&&T.anchor.path===s?{...T,anchor:{...T.anchor,focused:!1}}:T)},[]),Hr=l.useCallback(()=>ge(vt.current),[ge]),St=l.useCallback((s,d)=>{const g=wr(d),T=bt.current.length;if(!Number.isInteger(s)||s<0||s>=T)throw new RangeError(`[directory-tree] scrollToIndex: ${String(s)} is not a row index (${T===0?"the tree has no rows":`expected an integer in 0..${String(T-1)}`}).`);if(g==="nearest"){Ce(s);return}G.current?.scrollToIndex(s,{align:g})},[Ce]);l.useImperativeHandle(M,()=>({scrollToIndex:St,scrollToPath:(s,d)=>{wr(d);const g=Zt.current.get(s);return g===void 0?!1:(St(g,d),!0)},getScrollAnchor:()=>G.current?.getScrollAnchor()??null}),[St]);const tr=l.useCallback((s,d)=>{if(s.altKey||s.ctrlKey||s.metaKey)return;const g=bt.current,T=g.length-1;if(T<0)return;const B=g[d],J=B?.entry.children!==void 0,ve=J&&qt.current(B.entry.absolutePath);switch(s.key){case"ArrowDown":s.preventDefault(),ge(Math.min(d+1,T));break;case"ArrowUp":s.preventDefault(),ge(Math.max(d-1,0));break;case"Home":s.preventDefault(),ge(0);break;case"End":s.preventDefault(),ge(T);break;case"ArrowRight":s.preventDefault(),J&&!ve?gt.current(B.entry.absolutePath):J&&d<T&&g[d+1].depth>B.depth&&ge(d+1);break;case"ArrowLeft":{if(s.preventDefault(),J&&ve){gt.current(B.entry.absolutePath);break}const Vr=B?.depth??0;for(let ot=d-1;ot>=0;ot--)if(g[ot].depth<Vr){ge(ot);break}break}}},[ge]),tt=l.useMemo(()=>!x||mt.length===0?{segmentsByItem:[],glyphsByItem:[]}:Hn(mt,xe,Ie,lt,x,P??hr),[mt,xe,Ie,x,P]),rt=l.useMemo(()=>!x||e.length===0?0:(Vt+2)*lt,[e.length,Vt,x]),{renderStart:rr,renderEnd:nr,lookaheadEnd:or}=l.useMemo(()=>Bn(U.length,Ne,_e,Ye,Je,Ie),[U.length,Ne,_e,Ye,Je,Ie]),Et=l.useMemo(()=>!x||rt<=0||Ne<=0||tt.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:rt,height:Ne},children:f.jsx(Lr,{segmentsByItem:tt.segmentsByItem,glyphsByItem:tt.glyphsByItem,itemHeight:xe[0]??at,width:rt,viewportHeight:Ne,scrollPosition:Je,color:F,expandGlyphColor:F,expandGlyphSize:P??hr,renderStartIndex:rr,renderEndIndex:nr,lookaheadEndIndex:or})})}),[rt,Ne,rr,nr,or,Je,tt,F,x,P,xe]),sr=l.useCallback(s=>U[s],[U]),ar=l.useRef(null);l.useLayoutEffect(()=>{const s=ar.current;if(ar.current={items:U,offsets:Ie},!Lt||!s||s.items===U)return;const d=G.current,g=d?.getScrollPosition(),T=typeof g=="number"&&g>=0?g:ft.current,B=Rn(s.items,s.offsets,T);if(!B)return;const J=kn(B,U,Ie);if(J===null||Math.abs(J-T)<1)return;const ve=d?d.scrollTo(J):J;ft.current=ve,Bt(ve)},[U,Ie,Lt]);const Se=v?.columns,Me=v?.scrollBarWidth??ut?.width??Pr,Q=l.useMemo(()=>Se?gn({measuredWidth:W,columns:Se,scrollBarWidth:Me}):null,[Se,W,Me]),nt=l.useMemo(()=>Se?bn(Se):"",[Se]),Wr=l.useMemo(()=>v?.showFooter&&Se?vn(e):[],[v?.showFooter,Se,e]),Ae=Q?.maxHScroll??0;l.useEffect(()=>{De(s=>Rt(s,Ae))},[Ae]);const lr=l.useCallback(s=>De(d=>Rt(d+s,Ae)),[Ae]),cr=l.useMemo(()=>({iconOverrides:D,showExpandIcons:C,showDirectoryIcons:b,showFileIcons:H,useCanvasExpandIcons:x,expandIconSize:P,highlightStyles:X,expandIconClassName:j,expandIconStyle:o}),[D,C,b,H,x,P,X,j,o]),ir=l.useMemo(()=>f.jsx(pe.VirtualScroll,{ref:G,itemCount:U.length,getItem:sr,getItemHeight:Kt,getItemKey:Ut,testId:Dt,contentProps:Ft,locale:Z,labels:ue,viewportSize:typeof oe=="number"?oe:void 0,overscanCount:_e,onScroll:Ht,onRangeChange:Wt,onScrollAdjust:Xe,liveRegion:Fe,className:Ge,onWheelHorizontal:te?lr:void 0,background:f.jsxs(f.Fragment,{children:[te&&Q?f.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:Q.nameWidth},"aria-hidden":"true",children:Et}):Et,Ve]}),initialScrollIndex:Y,initialScrollOffset:be,initialScrollAnchor:jt,callbackThrottleMs:Pt,contentInsets:Mt,scrollBarOptions:ut,behaviorOptions:$t,children:(s,d)=>s?te&&v&&Q?f.jsx(_r,{entry:s.entry,indentLevel:s.indentLevel,positionInSet:s.positionInSet,setSize:s.setSize,rowIndex:d+(v.showHeader??!0?2:1),flatIndex:d,onRowFocus:wt,onRowBlur:xt,isSelectedForAria:!!R?.has(s.entry.absolutePath),rowHeight:s.rowHeight,isDirOpen:ye,columns:v.columns,numericTemplate:nt,numericTotal:Q.numericTotal,nameWidth:Q.nameWidth,rowClassName:v.rowClassName,selection:{onEntryClick:I,selectedPath:je,currentPath:pt,mode:y,selectedItems:R,onSelectionChange:E},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ht},visual:cr},s.entry.absolutePath):f.jsx(Nt,{entry:s.entry,indentLevel:s.indentLevel,depth:s.depth,positionInSet:s.positionInSet,setSize:s.setSize,isSelectedForAria:!!R?.has(s.entry.absolutePath),flatIndex:d,isActive:d===Pe,registerRowRef:er,onNavigationKeyDown:tr,onRowFocus:wt,onRowBlur:xt,rowHeight:s.rowHeight,entryKindDirectory:Te,entryKindFile:Ee,isDirOpen:ye,parentIsLast:s.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ht},selection:{onEntryClick:I,selectedPath:je,currentPath:pt,mode:y,selectedItems:R,onSelectionChange:E},visual:{iconOverrides:D,showExpandIcons:C,showDirectoryIcons:b,showFileIcons:H,useCanvasExpandIcons:x,expandIconSize:P,highlightStyles:X,entryClassName:q,entryStyle:re,nameClassName:ee,nameStyle:$,directoryNameClassName:he,directoryNameStyle:le,fileNameClassName:ce,fileNameStyle:z,expandIconClassName:j,expandIconStyle:o}},s.entry.absolutePath):null}),[U.length,sr,Kt,Ut,Dt,Ft,Z,ue,Te,Ee,Pe,er,tr,wt,xt,oe,_e,Ht,Wt,Xe,Fe,Ge,te,lr,Q,Et,Ve,Y,be,jt,Pt,Mt,ut,$t,v,nt,ye,I,je,pt,y,R,E,t,ht,cr,D,C,b,H,x,P,X,q,re,ee,$,he,le,ce,z,j,o]);if(!(v&&Q))return f.jsxs("div",{ref:K,className:zt,style:Yt,onPointerDownCapture:et,onMouseDownCapture:et,children:[ke.length>0&&!Br&&f.jsx("span",{tabIndex:0,"data-directory-tree-tab-stop":"",style:Fn,onFocus:Hr}),ir]});const zr=v.showHeader??!0,Yr=v.showFooter??!1,Gr={...Yt,"--dt-hscroll":`${Le}px`};return f.jsxs("div",{ref:K,className:A.twMerge(zt,"dt-grid"),style:Gr,role:"treegrid","aria-label":k?void 0:w,"aria-labelledby":k,"aria-multiselectable":y==="multiple"?!0:void 0,"aria-rowcount":U.length+(v.showHeader??!0?1:0),onPointerDownCapture:et,onMouseDownCapture:et,children:[zr&&f.jsx("div",{role:"rowgroup",children:f.jsx(mn,{columns:v.columns,numericTemplate:nt,numericTotal:Q.numericTotal,nameWidth:Q.nameWidth,scrollBarWidth:Me,className:v.headerClassName})}),f.jsx("div",{ref:we,className:"dt-grid-body",children:ir}),Ae>0&&f.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Q.nameWidth},"aria-hidden":"true"}),f.jsx(pe.ScrollBar,{horizontal:!0,contentSize:Q.numericTotal,viewportSize:Q.numericVisible,scrollPosition:Le,scrollBarWidth:Me,locale:Z,labels:ue,onScroll:s=>{const d=typeof s=="function"?s(Le):s,g=Rt(d,Ae);return De(g),g}}),f.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Me},"aria-hidden":"true"})]}),Yr&&f.jsx("div",{role:"rowgroup",children:f.jsx(pn,{columns:v.columns,numericTemplate:nt,numericTotal:Q.numericTotal,nameWidth:Q.nameWidth,scrollBarWidth:Me,allEntries:Wr,className:v.footerClassName})})]})},zn=({initialExpanded:e=new Set,storageKey:t}={})=>{const[r,n]=l.useTransition(),[a,c]=l.useState(()=>{if(typeof window<"u"&&t)try{const m=window.localStorage.getItem(t);if(m){const w=JSON.parse(m);return new Set(w)}}catch(m){console.error("[useDirectoryTreeState] Error reading from localStorage",m)}return e}),i=l.useCallback(m=>{n(()=>{c(w=>{const k=new Set(w);return m(k),k})})},[]),u=l.useCallback((m,w)=>{i(k=>{for(const F of m)w(k,F)})},[i]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(a)))}catch(m){console.warn(`Error setting localStorage key "${t}":`,m)}},[a,t]);const I=l.useCallback(m=>{u([m],(w,k)=>{w.has(k)?w.delete(k):w.add(k)})},[u]),S=l.useCallback(m=>{u([m],(w,k)=>{w.add(k)})},[u]),h=l.useCallback(m=>{u([m],(w,k)=>{w.delete(k)})},[u]),y=l.useCallback(m=>{u(m,(w,k)=>{w.delete(k)})},[u]),R=l.useCallback(m=>{u(m,(w,k)=>{w.add(k)})},[u]),E=l.useCallback(()=>{i(m=>{m.clear()})},[i]),N=l.useCallback(m=>a.has(m),[a]);return{expanded:a,toggle:I,expand:S,collapse:h,collapseMultiple:y,expandMultiple:R,collapseAll:E,isExpanded:N,isPending:r}};exports.DIRECTORY_TREE_LABEL_CATALOGS=Ar;exports.DIRECTORY_TREE_LABEL_KEYS=Ct;exports.DirectoryTree=Wn;exports.directoryTreeClasses=L;exports.resolveDirectoryTreeLabels=Or;exports.useDirectoryTreeState=zn;