@aiquants/directory-tree 3.12.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -125,6 +125,7 @@ The main component for rendering the directory tree.
125
125
  | `selection` | `object` | Yes | Configuration for item selection |
126
126
  | `visual` | `object` | No | Visual customization options |
127
127
  | `virtualScroll` | `DirectoryTreeVirtualScrollOptions` | No | Pass-through options for the underlying VirtualScroll component |
128
+ | `ref` | `Ref<DirectoryTreeHandle>` | No | Receives the tree's imperative scroll handle. See [Scroll handle](#scroll-handle-ref) |
128
129
  | `locale` | `DirectoryTreeLocale` (`"en"` \| `"ja"`) | No | UI chrome language (default `"en"`). See [Localization](#localization) |
129
130
  | `labels` | `DirectoryTreeLabelOverrides` | No | Per-key overrides over the catalog of `locale`. See [Localization](#localization) |
130
131
 
@@ -145,7 +146,8 @@ The main component for rendering the directory tree.
145
146
  | Prop | Type | Required | Default | Description |
146
147
  | --- | --- | --- | --- | --- |
147
148
  | `onEntryClick` | `(event: DirectoryTreeClickEvent) => void` | Yes | - | Callback function triggered when an entry is clicked |
148
- | `selectedPath` | `string \| null` | No | - | The currently selected file path |
149
+ | `selectedPath` | `string \| null` | No | - | The currently selected file path (highlighted with `data-entry-selected`). In classic mode the selected row is also where the tree's Tab stop starts (grid rows are each a Tab stop) — see [Keyboard and focus](#keyboard-and-focus) |
150
+ | `currentPath` | `string \| null` | No | - | The entry the host shows as current (for example the open document). Its row carries `aria-current="page"` in every selection mode, so assistive technology can tell the shown entry from the selected set in multiple selection. The tree draws no style for it; style `[aria-current="page"]` yourself |
149
151
  | `mode` | `'none' \| 'single' \| 'multiple'` | No | `'none'` | Selection mode for items |
150
152
  | `selectedItems` | `Set<string>` | No | - | Set of paths for currently selected items |
151
153
  | `onSelectionChange` | `(entry: DirectoryEntry, isSelected: boolean) => void` | No | - | Callback when item selection changes |
@@ -174,19 +176,43 @@ The main component for rendering the directory tree.
174
176
  | `directoryNameStyle` | `React.CSSProperties` | No | - | Additional inline styles specifically for directory names |
175
177
  | `fileNameClassName` | `string` | No | - | Additional CSS classes specifically for file names |
176
178
  | `fileNameStyle` | `React.CSSProperties` | No | - | Additional inline styles specifically for file names |
179
+ | `expandIconClassName` | `string` | No | - | Additional CSS classes for the expand glyph (the chevron drawn in the row when `showTreeLines` is `false`), merged like `nameClassName`: the selected-row colour class still follows it, and a colour class replaces only the light default, so the built-in `dark:text-gray-400` stays unless the class carries a `dark:` colour too |
180
+ | `expandIconStyle` | `React.CSSProperties` | No | - | Inline styles for the expand glyph, applied like `nameStyle` (they win over every class, the selected-row colour included). The glyph is drawn in `currentColor`, so `{ color: "var(--your-token)" }` follows your colour tokens independently of the `dark` class. The canvas glyph drawn with the tree lines takes `lineColor` |
177
181
 
178
182
  ### Virtual Scroll Options
179
183
 
180
- `virtualScroll` lets you customize the embedded `@aiquants/virtualscroll` instance without re-implementing list rendering. Every option is optional and mirrors the VirtualScroll API.
184
+ `virtualScroll` lets you customize the embedded `@aiquants/virtualscroll` instance without re-implementing list rendering. Every option is optional and mirrors the VirtualScroll API, except the parts the tree owns (listed below).
181
185
 
182
- - `overscanCount`: Adjust how many items render beyond the viewport for smoother scrolling (default: `10`).
186
+ - `overscanCount`: Adjust how many items render beyond the viewport for smoother scrolling (default: `15`).
183
187
  - `scrollBarOptions`: Configure scrollbar appearance and behavior (width, thumb drag, track click, arrow buttons, tap scroll circle).
184
- - `behaviorOptions`: Configure scrolling behavior (pointer drag, keyboard navigation, inertia, wheel speed).
185
- - `onScroll`, `onRangeChange`, `className`, `background`, `initialScrollIndex`, `initialScrollOffset`: Hook into scroll lifecycle or provide bespoke styling.
186
-
187
- The engine's `locale` / `labels` are **not** accepted here (a type error): the one surface for the UI chrome
188
- language is the top-level `locale` / `labels` of `DirectoryTree`, which also reaches the row kind words and the
189
- grid-mode horizontal scrollbar. See [Localization](#localization).
188
+ A host that drives the classic tree from the keyboard can pass `enableArrowButtonTabStops: false` to make the scrollbar and the
189
+ Top/Bottom buttons pointer-only: the tree's own arrow keys, Home and End keep the focused row in view. In grid mode the option
190
+ reaches the vertical scrollbar and the Top/Bottom buttons only; the horizontal scrollbar of the numeric columns keeps its arrow
191
+ buttons as Tab stops, because it is the only keyboard path to the columns scrolled out of view.
192
+ - `behaviorOptions`: Configure scrolling behavior (pointer drag, inertia, wheel speed, overscroll, height reconciliation).
193
+ - `onItemFocus`: Called with the row's index in the flattened list whenever a row (or an element inside it) receives focus. The tree calls it itself, in classic and grid mode.
194
+ - `contentProps`: ARIA / identity attributes for the scroll pane's content element — the element that carries `role="tree"` (classic mode) or the body `role="rowgroup"` (grid mode).
195
+ - `liveRegion`: Opt-in `role="status"` region that announces the visible range (`format` builds the text). It is rendered next to the scroll pane, so in classic mode it stays outside `role="tree"`.
196
+ - `onScrollAdjust`: Called synchronously each time the embedded list moves its scroll position on its own (layout-shift compensation, re-pinning a pending alignment), never for scrolls the user or the host start.
197
+ - `onScroll`, `onRangeChange`, `className`, `background`, `initialScrollIndex`, `initialScrollOffset`, `initialScrollAnchor`: Hook into scroll lifecycle or provide bespoke styling. `background` renders inside the element that carries `role="tree"`, so mark decorative backgrounds `aria-hidden`.
198
+
199
+ These are **not** accepted, because the tree owns them:
200
+
201
+ - The engine's `locale` / `labels`: the one surface for the UI chrome language is the top-level `locale` / `labels`
202
+ of `DirectoryTree`, which also reaches the row kind words and the grid-mode horizontal scrollbar. See
203
+ [Localization](#localization).
204
+ - `ref`: use the tree's own handle ([Scroll handle](#scroll-handle-ref)).
205
+ - `onWheelHorizontal`, `onPanHorizontal`, `horizontalKeyInputs`, `horizontalKeyStep`: the tree owns the horizontal axis.
206
+ - `behaviorOptions.enableKeyboardNavigation` and `behaviorOptions.enableEscapeRowReturn`: the tree's rows own the
207
+ keyboard (see [Keyboard and focus](#keyboard-and-focus)); the tree always turns the engine's row navigation off,
208
+ because its row wrappers would otherwise be focusable elements between `role="tree"` and the treeitems.
209
+ - `contentProps.role`, `contentProps["aria-label"]`, `contentProps["aria-labelledby"]` and
210
+ `contentProps["aria-multiselectable"]`: the tree's name comes from `visual.ariaLabel` / `visual.ariaLabelledBy`
211
+ and its multiselection from `selection.mode`.
212
+
213
+ Writing one of them in an object literal typed as `DirectoryTreeVirtualScrollOptions` is a type error. A value that
214
+ reaches the tree any other way (a variable of a wider type, an object built by a generic helper or a spread, a
215
+ JavaScript caller) compiles, and the tree ignores it at runtime.
190
216
 
191
217
  Example:
192
218
 
@@ -208,6 +234,77 @@ Example:
208
234
  />;
209
235
  ```
210
236
 
237
+ ### Keyboard and focus
238
+
239
+ The classic tree follows the WAI-ARIA tree pattern with a roving tabindex: it always has exactly one Tab stop.
240
+
241
+ - **Where Tab enters**: the row that last received focus — while it still holds focus, or while the selection has not
242
+ changed since it received focus — else the selected row (`selection.selectedPath`), else the first row. A candidate
243
+ inside a collapsed folder is skipped. So Tab enters a tree on its selected row, and once focus has left the tree, any
244
+ selection change moves the Tab stop to the selected row — also a change that later comes back to the path the
245
+ selection had when the row received focus.
246
+ - **Focus makes the Tab stop**: a row that receives focus — by the tree's keys, a script or a pointer, or through an
247
+ element inside the row — becomes the single Tab stop. A row holding focus stays the Tab stop even if the selection
248
+ changes meanwhile, so Shift+Tab from it leaves the tree. A row keeps holding focus while the window or browser tab is
249
+ inactive (it is still the page's focused element).
250
+ - **Keys**: `ArrowDown` / `ArrowUp` move between visible rows, `Home` / `End` jump to either end, `ArrowRight` opens a
251
+ collapsed folder or moves to its first child (an open folder without child rows keeps the focus), `ArrowLeft` closes
252
+ an open folder or moves to the parent, `Enter` and `Space` activate the row once per press (the auto-repeat of a held
253
+ key only has its default action prevented, so a held key never flips a folder or a gathered entry back and forth).
254
+ Grid rows activate on `Enter` with the same rule.
255
+ - **Keys with Alt, Ctrl or ⌘ are not the tree's**: an arrow key, `Home` or `End` held with Alt, Ctrl or Meta (⌘) is
256
+ neither handled nor has its default action prevented, so the browser's history keys (Alt+Left / Alt+Right,
257
+ ⌘+Left / ⌘+Right) and a host's own shortcuts on them (for example Alt+Shift+Arrow) work while a row has focus.
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.
265
+ - **Rows outside the render window**: when the Tab stop row is virtualized away, a visually hidden stand-in Tab stop
266
+ (`data-directory-tree-tab-stop`, outside `role="tree"`) takes its place in the Tab order; when it receives focus it
267
+ scrolls the Tab stop row into view and hands the focus to it. A host that hands focus to the tree by selector should
268
+ look for `[role="tree"] [role="treeitem"][tabindex="0"]` and then `[data-directory-tree-tab-stop]`. The stand-in
269
+ appears in the render that follows the one where the Tab stop row left the render window (the tree measures that
270
+ in its own layout effect), so look it up after that commit, not in a layout effect of the same commit.
271
+
272
+ The element that carries `role="tree"` (with the tree's name and `aria-multiselectable`) is the scroll pane's
273
+ content element, which owns only the rows: the scrollbar, the Top/Bottom buttons and the live region
274
+ (`virtualScroll.liveRegion`) stay outside the tree, and the wrappers between the tree and its rows carry no role,
275
+ tabindex or ARIA attribute. The root container has no role; target it through `visual.className`.
276
+
277
+ Grid mode (`grid`) differs: every grid row is a Tab stop and the rows have no arrow-key navigation, and
278
+ `role="treegrid"` sits on the root container, so the vertical and horizontal scrollbars and the live region are inside
279
+ the treegrid.
280
+
281
+ ### Scroll handle (`ref`)
282
+
283
+ `ref` receives a `DirectoryTreeHandle`. Rows are addressed by their index in the flattened list (the rows the tree
284
+ shows, in display order — what `onRangeChange`, `onItemFocus` and `getScrollAnchor` report) or by
285
+ `DirectoryEntry.absolutePath`. No method moves the focus.
286
+
287
+ | Method | Description |
288
+ | --- | --- |
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` |
290
+ | `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
+ | `getScrollAnchor()` | The first visible row as `{ index, offsetPx }`, to restore exactly through `virtualScroll.initialScrollAnchor` on the next mount; `null` for an empty tree |
292
+
293
+ ```tsx
294
+ import { useRef } from 'react';
295
+ import { DirectoryTree, type DirectoryTreeHandle } from '@aiquants/directory-tree';
296
+
297
+ const tree = useRef<DirectoryTreeHandle>(null);
298
+
299
+ // Bring the shown document's row into view without moving the focus
300
+ tree.current?.scrollToPath(currentPath, { align: 'nearest' });
301
+
302
+ <DirectoryTree ref={tree} {...commonProps} selection={{ ...selection, currentPath }} />;
303
+ ```
304
+
305
+ The embedded VirtualScroll's own handle is not exposed (`virtualScroll.ref` is a type error): the tree's handle
306
+ addresses rows of the flattened list and leaves the axes the tree owns alone.
307
+
211
308
  ### useDirectoryTreeState Hook
212
309
 
213
310
  A hook for managing directory tree state with localStorage persistence.
@@ -323,6 +420,22 @@ You can customize the appearance by passing custom classes or inline styles for
323
420
  />
324
421
  ```
325
422
 
423
+ The expand glyph drawn in the row (when `showTreeLines` is `false`) takes `expandIconClassName` /
424
+ `expandIconStyle` the same way. To make its colour follow your own theme rather than the `dark` class, pass a colour
425
+ token through `expandIconStyle`: an inline style wins over every class, the built-in `dark:` colour included.
426
+
427
+ ```tsx
428
+ <DirectoryTree
429
+ visual={{ showTreeLines: false, expandIconStyle: { color: "var(--app-tree-glyph)" } }}
430
+ // ... other props
431
+ />
432
+ ```
433
+
434
+ `expandIconClassName` is merged into the built-in classes like `nameClassName`, so a colour class on its own replaces
435
+ only the light default (`text-gray-500`): the built-in `dark:text-gray-400` stays and wins under your `dark` class.
436
+ To set the colour with a class, give its `dark:` variant as well, for example
437
+ `"text-(--app-tree-glyph) dark:text-(--app-tree-glyph)"`.
438
+
326
439
  Alternatively, you can customize components inside the container using global CSS classes:
327
440
 
328
441
  ```css
@@ -490,9 +603,10 @@ const { toggle, isExpanded, expandMultiple, collapseMultiple } = useDirectoryTre
490
603
 
491
604
  ## Localization
492
605
 
493
- `DirectoryTree` renders nine strings of its own (UI chrome): the kind word of each classic-mode row's
494
- accessible name (`"src (directory)"`, `"package.json (file)"`) and the seven chrome strings of the embedded
495
- `@aiquants/virtualscroll` (scrollbar arrow labels, scroll-to-edge pills, empty state). They come from a built-in
606
+ `DirectoryTree` renders its own UI chrome strings: the kind word of each classic-mode row's
607
+ accessible name (`"src (directory)"`, `"package.json (file)"`) and the chrome strings of the embedded
608
+ `@aiquants/virtualscroll` (every key of its `VIRTUAL_SCROLL_LABEL_KEYS`, such as the scrollbar arrow labels,
609
+ scroll-to-edge pills and empty state). They come from a built-in
496
610
  catalog in English (`"en"`, the default) and Japanese (`"ja"`). Entry names, column headers / footers and the
497
611
  tree's own accessible name (`visual.ariaLabel`) are your content and are never translated.
498
612
 
@@ -515,7 +629,9 @@ tree's own accessible name (`visual.ariaLabel`) are your content and are never t
515
629
  | `scrollToBottom` | `Bottom` | `末尾へ` | Scroll-to-bottom pill (same option) |
516
630
  | `noItems` | `No items` | `項目がありません` | Empty state when `entries` is `[]` |
517
631
 
518
- The seven engine rows are `VIRTUAL_SCROLL_LABEL_CATALOGS` of `@aiquants/virtualscroll`, reused by value. Grid-mode
632
+ The engine rows are `VIRTUAL_SCROLL_LABEL_CATALOGS` of `@aiquants/virtualscroll`, reused by value. The table lists the
633
+ engine keys every supported engine version has; any further key of the installed engine's `VIRTUAL_SCROLL_LABEL_KEYS` is
634
+ accepted, validated and forwarded the same way. Grid-mode
519
635
  rows carry no row-level accessible name (their cells name them), so the kind words apply to classic mode only.
520
636
 
521
637
  - **Default**: omitting `locale` is identical to `locale="en"`, and the `en` catalog is the historical English
@@ -528,7 +644,7 @@ rows carry no row-level accessible name (their cells name them), so the kind wor
528
644
  `undefined` value keeps the catalog value, and every present value must be a string with non-whitespace
529
645
  content. The result is frozen. The engine keys are validated by the engine's `resolveVirtualScrollLabels`
530
646
  (`[virtualscroll]` messages), the own keys by the package (`[directory-tree]` messages).
531
- - **Forwarding**: `locale` and the seven engine keys reach both the embedded `VirtualScroll` and the grid-mode
647
+ - **Forwarding**: `locale` and the engine keys reach both the embedded `VirtualScroll` and the grid-mode
532
648
  horizontal `ScrollBar`. An inline `labels={{…}}` object is fine: the forwarded engine labels keep their identity
533
649
  while the strings are unchanged, so the virtualized body is not re-rendered.
534
650
 
@@ -1,5 +1,5 @@
1
1
  import { directoryTreeClasses } from "./entryRendering.tsx";
2
2
  import { DirectoryTreeProps, TreeLineGeometry, TreeLineItemInfo } from "./types.ts";
3
3
  export declare const buildTreeLineGeometry: (items: TreeLineItemInfo[], itemHeights: number[], itemOffsets: number[], segmentWidth: number, includeGlyphs: boolean, glyphSizeOverride?: number) => TreeLineGeometry;
4
- export declare const DirectoryTree: ({ entries, expansion: { toggle, isExpanded, expandMultiple, collapseMultiple, isPending, alwaysExpanded, doubleClickAction }, selection: { onEntryClick, selectedPath, mode: selectionMode, selectedItems, onSelectionChange }, visual: { className, style, ariaLabel, ariaLabelledBy, lineColor, showTreeLines, showExpandIcons, showDirectoryIcons, showFileIcons, iconOverrides, expandIconSize, itemHeight, removeRootIndent, highlightStyles, entryClassName, entryStyle, nameClassName, nameStyle, directoryNameClassName, directoryNameStyle, fileNameClassName, fileNameStyle, }, virtualScroll: virtualScrollOptions, grid, sort, locale, labels, }: DirectoryTreeProps) => import("react").JSX.Element;
4
+ export declare const DirectoryTree: ({ entries, expansion: { toggle, isExpanded, expandMultiple, collapseMultiple, isPending, alwaysExpanded, doubleClickAction }, selection: { onEntryClick, selectedPath, currentPath, mode: selectionMode, selectedItems, onSelectionChange }, visual: { className, style, ariaLabel, ariaLabelledBy, lineColor, showTreeLines, showExpandIcons, showDirectoryIcons, showFileIcons, iconOverrides, expandIconSize, itemHeight, removeRootIndent, highlightStyles, entryClassName, entryStyle, nameClassName, nameStyle, directoryNameClassName, directoryNameStyle, fileNameClassName, fileNameStyle, expandIconClassName, expandIconStyle, }, virtualScroll: virtualScrollOptions, grid, sort, locale, labels, ref, }: DirectoryTreeProps) => import("react").JSX.Element;
5
5
  export { directoryTreeClasses };
@@ -1,3 +1,4 @@
1
+ import { CSSProperties } from "react";
1
2
  import { DirectoryEntry, DirectoryTreeColumn, DirectoryTreeIconOverrides, HighlightStyles } from "./types.ts";
2
3
  export type GridRowVisual = {
3
4
  iconOverrides?: DirectoryTreeIconOverrides;
@@ -10,6 +11,8 @@ export type GridRowVisual = {
10
11
  fontSize?: number | string;
11
12
  indentSize?: number;
12
13
  highlightStyles?: HighlightStyles;
14
+ expandIconClassName?: string;
15
+ expandIconStyle?: CSSProperties;
13
16
  };
14
17
  export declare const isEntryExpanded: (entry: DirectoryEntry, isDirOpen: (path: string) => boolean) => boolean;
15
18
  export type DirectoryTreeGridRowProps = {
@@ -18,6 +21,9 @@ export type DirectoryTreeGridRowProps = {
18
21
  positionInSet: number;
19
22
  setSize: number;
20
23
  rowIndex: number;
24
+ flatIndex: number;
25
+ onRowFocus: (index: number, path: string, row: HTMLElement) => void;
26
+ onRowBlur: (path: string, row: HTMLElement) => void;
21
27
  isSelectedForAria: boolean;
22
28
  rowHeight: number;
23
29
  isDirOpen: (path: string) => boolean;
@@ -28,6 +34,7 @@ export type DirectoryTreeGridRowProps = {
28
34
  rowClassName?: string | ((entry: DirectoryEntry) => string);
29
35
  selection: {
30
36
  selectedPath: string | null;
37
+ currentPath: string | null;
31
38
  mode?: "none" | "single" | "multiple";
32
39
  selectedItems?: Set<string>;
33
40
  onEntryClick: (event: import("./types.ts").DirectoryTreeClickEvent) => void;
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),ue=require("@aiquants/virtualscroll"),D=require("tailwind-merge"),F=require("@phosphor-icons/react");function br(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const ie=br(l);var Ye={exports:{}},Ae={};var Wt;function gr(){if(Wt)return Ae;Wt=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function s(r,n,c){var i=null;if(c!==void 0&&(i=""+c),n.key!==void 0&&(i=""+n.key),"key"in n){c={};for(var f in n)f!=="key"&&(c[f]=n[f])}else c=n;return n=c.ref,{$$typeof:e,type:r,key:i,ref:n!==void 0?n:null,props:c}}return Ae.Fragment=t,Ae.jsx=s,Ae.jsxs=s,Ae}var Me={};var Bt;function xr(){return Bt||(Bt=1,process.env.NODE_ENV!=="production"&&(function(){function e(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===B?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case y:return"Fragment";case C:return"Profiler";case S:return"StrictMode";case W:return"Suspense";case _:return"SuspenseList";case J:return"Activity"}if(typeof a=="object")switch(typeof a.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),a.$$typeof){case m:return"Portal";case E:return a.displayName||"Context";case I:return(a._context.displayName||"Context")+".Consumer";case p:var b=a.render;return a=a.displayName,a||(a=b.displayName||b.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case H:return b=a.displayName||null,b!==null?b:e(a.type)||"Memo";case te:b=a._payload,a=a._init;try{return e(a(b))}catch{}}return null}function t(a){return""+a}function s(a){try{t(a);var b=!1}catch{b=!0}if(b){b=console;var T=b.error,A=typeof Symbol=="function"&&Symbol.toStringTag&&a[Symbol.toStringTag]||a.constructor.name||"Object";return T.call(b,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",A),t(a)}}function r(a){if(a===y)return"<>";if(typeof a=="object"&&a!==null&&a.$$typeof===te)return"<...>";try{var b=e(a);return b?"<"+b+">":"<...>"}catch{return"<...>"}}function n(){var a=re.A;return a===null?null:a.getOwner()}function c(){return Error("react-stack-top-frame")}function i(a){if(ne.call(a,"key")){var b=Object.getOwnPropertyDescriptor(a,"key").get;if(b&&b.isReactWarning)return!1}return a.key!==void 0}function f(a,b){function T(){M||(M=!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)",b))}T.isReactWarning=!0,Object.defineProperty(a,"key",{get:T,configurable:!0})}function R(){var a=e(this.type);return V[a]||(V[a]=!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.")),a=this.props.ref,a!==void 0?a:null}function x(a,b,T,A,se,ce){var L=T.ref;return a={$$typeof:j,type:a,key:b,props:T,_owner:A},(L!==void 0?L:null)!==null?Object.defineProperty(a,"ref",{enumerable:!1,get:R}):Object.defineProperty(a,"ref",{enumerable:!1,value:null}),a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(a,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(a,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:se}),Object.defineProperty(a,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ce}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a}function d(a,b,T,A,se,ce){var L=b.children;if(L!==void 0)if(A)if(N(L)){for(A=0;A<L.length;A++)h(L[A]);Object.freeze&&Object.freeze(L)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else h(L);if(ne.call(b,"key")){L=e(a);var ae=Object.keys(b).filter(function(U){return U!=="key"});A=0<ae.length?"{key: someKey, "+ae.join(": ..., ")+": ...}":"{key: someKey}",P[L+A]||(ae=0<ae.length?"{"+ae.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"),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:
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} />`,A,L,ae,L),P[L+A]=!0)}if(L=null,T!==void 0&&(s(T),L=""+T),i(b)&&(s(b.key),L=""+b.key),"key"in b){T={};for(var k in b)k!=="key"&&(T[k]=b[k])}else T=b;return L&&f(T,typeof a=="function"?a.displayName||a.name||"Unknown":a),x(a,L,T,n(),se,ce)}function h(a){v(a)?a._store&&(a._store.validated=1):typeof a=="object"&&a!==null&&a.$$typeof===te&&(a._payload.status==="fulfilled"?v(a._payload.value)&&a._payload.value._store&&(a._payload.value._store.validated=1):a._store&&(a._store.validated=1))}function v(a){return typeof a=="object"&&a!==null&&a.$$typeof===j}var w=l,j=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),E=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),te=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),B=Symbol.for("react.client.reference"),re=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=Object.prototype.hasOwnProperty,N=Array.isArray,z=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(a){return a()}};var M,V={},de=w.react_stack_bottom_frame.bind(w,c)(),fe=z(r(c)),P={};Me.Fragment=y,Me.jsx=function(a,b,T){var A=1e4>re.recentlyCreatedOwnerStacks++;return d(a,b,T,!1,A?Error("react-stack-top-frame"):de,A?z(r(a)):fe)},Me.jsxs=function(a,b,T){var A=1e4>re.recentlyCreatedOwnerStacks++;return d(a,b,T,!0,A?Error("react-stack-top-frame"):de,A?z(r(a)):fe)}})()),Me}var Yt;function vr(){return Yt||(Yt=1,process.env.NODE_ENV==="production"?Ye.exports=gr():Ye.exports=xr()),Ye.exports}var u=vr();function wr({title:e,titleId:t,...s},r){return ie.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},s),e?ie.createElement("title",{id:t},e):null,ie.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 Er=ie.forwardRef(wr);function Sr({title:e,titleId:t,...s},r){return ie.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},s),e?ie.createElement("title",{id:t},e):null,ie.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 kr=ie.forwardRef(Sr);function Rr({title:e,titleId:t,...s},r){return ie.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},s),e?ie.createElement("title",{id:t},e):null,ie.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 jr=ie.forwardRef(Rr),ze=18,Ve=12,zt=8,$={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:D.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:D.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:D.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:D.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:D.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:D.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:D.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:D.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:D.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},ve=e=>{if(!e)return"";const t=e.split("?")[0].split("#")[0].split("/").pop()||e,s=t.lastIndexOf(".");return s<=0?"":t.slice(s+1).toLowerCase()},Xt=({isDirectory:e,isExpanded:t,showExpandIcons:s,useCanvasExpandIcons:r,expandIconSize:n})=>{const c=n?{width:n,height:n}:void 0,i=n?"":"h-4 w-4";return!(s&&e)||r?u.jsx("span",{className:i,style:c,"aria-hidden":"true"}):t?u.jsx(Er,{className:i,style:c}):u.jsx(kr,{className:i,style:c})},at=(e,t)=>{if(e==null||typeof e=="boolean")return null;if(typeof e=="function")return console.warn(`[DirectoryTree] Function returned by renderer for "${t}". Return a node.`),null;if(typeof e=="object"){if("then"in e)return console.warn(`[DirectoryTree] Promise returned for "${t}". Not supported.`),null;if(Array.isArray(e)){const r=e.map(n=>at(n,t)).filter(Boolean);return r.length?r:null}const s=e.type;if(s&&s.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},Ir=(e,t,s)=>{const r=(t||(s?ve(s):"")).toLowerCase(),n=(e||"").toLowerCase();if(n&&n!=="application/octet-stream"){if(n==="text/markdown"||n==="text/x-markdown")return u.jsx(F.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(n==="application/pdf")return u.jsx(F.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(n.includes("excel")||n.includes("spreadsheet")||n.includes("google-apps.spreadsheet"))return u.jsx(F.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(n==="text/csv"||n==="text/tab-separated-values")return u.jsx(F.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(n.includes("word")||n.includes("msword")||n.includes("wordprocessingml")||n.includes("google-apps.document")||n==="application/rtf")return u.jsx(F.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(n.includes("powerpoint")||n.includes("presentation")||n.includes("google-apps.presentation"))return u.jsx(F.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(n.startsWith("image/"))return u.jsx(F.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(n.startsWith("audio/"))return u.jsx(F.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(n.startsWith("video/"))return u.jsx(F.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(n.includes("zip")||n.includes("tar")||n.includes("compressed")||n.includes("archive"))return u.jsx(F.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(n==="application/json"||n.includes("javascript")||n.includes("typescript")||n.includes("xml")||n.startsWith("text/html")||n.startsWith("text/css")||n.includes("x-python")||n.includes("x-sh")||n.includes("x-go")||n.includes("x-rust"))return u.jsx(F.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(n.startsWith("text/"))return u.jsx(F.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}if(r){if(r==="md"||r==="markdown"||r==="mdx")return u.jsx(F.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(r==="pdf")return u.jsx(F.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(["xls","xlsx","xlsm","xlsb","ods"].includes(r))return u.jsx(F.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["csv","tsv"].includes(r))return u.jsx(F.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["doc","docx","rtf","odt"].includes(r))return u.jsx(F.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(["ppt","pptx","odp"].includes(r))return u.jsx(F.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(r))return u.jsx(F.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(r))return u.jsx(F.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(["mp3","wav","ogg","m4a","flac","aac","wma"].includes(r))return u.jsx(F.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(["mp4","webm","mov","avi","mkv","wmv","flv"].includes(r))return u.jsx(F.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(["zip","tar","gz","7z","rar","tgz","bz2"].includes(r))return u.jsx(F.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(["txt","log"].includes(r))return u.jsx(F.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}return u.jsx(F.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"})},Jt=(e,t)=>{const{entry:s,isDirectory:r,isExpanded:n,extension:c,mimeType:i}=e;let f;const R=i||s.mimeType;return s.icon!==void 0?f=s.icon:r?f=n&&t?.directoryExpanded||t?.directory||u.jsx(jr,{className:"h-4 w-4"}):c&&t?.fileByExtension?.[c]?f=t.fileByExtension[c]:f=t?.file||Ir(R,c,s.name),at(typeof f=="function"?f(e):f,s.absolutePath)},Cr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),qt=e=>{if(!e)return;const t=Object.entries(e).filter(([,s])=>s!=null);if(t.length!==0)return Object.fromEntries(t.map(([s,r])=>[`data-${Cr(s)}`,String(r)]))},Nr=500,Zt=({entry:e,isDirectory:t,isExpanded:s,isItemSelected:r,selectionMode:n,onSelectionChange:c,onEntryClick:i,toggleDirectory:f,onToggleDirectoryRecursive:R})=>{const x=l.useRef(null);return l.useEffect(()=>()=>{x.current&&window.clearTimeout(x.current)},[]),l.useCallback(d=>{d.stopPropagation(),n!=="none"&&!t&&c&&c(e,!r);let h=!1;i({entry:e,isDirectory:t,isExpanded:s,preventDefault:()=>{h=!0}}),!(!t||h)&&(x.current?(window.clearTimeout(x.current),x.current=null,R(e)):x.current=window.setTimeout(()=>{f(e.absolutePath),x.current=null},Nr))},[t,e,s,R,f,i,n,c,r])},Qt=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",Vt=(e,t)=>e.children!==void 0&&t(e.absolutePath),er=(e,t)=>({width:e,gridTemplateColumns:t}),tr=l.memo(({entry:e,indentLevel:t,positionInSet:s,setSize:r,rowIndex:n,isSelectedForAria:c,rowHeight:i,isDirOpen:f,columns:R,numericTemplate:x,numericTotal:d,nameWidth:h,rowClassName:v,selection:{onEntryClick:w,selectedPath:j,mode:m="none",selectedItems:y,onSelectionChange:S},expansion:{toggleDirectory:C,onToggleDirectoryRecursive:I},visual:{iconOverrides:E,showExpandIcons:p=!0,showDirectoryIcons:W=!0,showFileIcons:_=!0,useCanvasExpandIcons:H=!1,expandIconSize:te,indentSize:J=Ve,highlightStyles:B}})=>{const[re,ne]=l.useState(!1),N=e.children!==void 0,z=N&&f(e.absolutePath),M=e.absolutePath===j,V=!N&&!!y?.has(e.absolutePath),de=N?void 0:ve(e.name)||ve(e.relativePath)||ve(e.absolutePath),fe=Zt({entry:e,isDirectory:N,isExpanded:z,isItemSelected:V,selectionMode:m,onSelectionChange:S,onEntryClick:w,toggleDirectory:C,onToggleDirectoryRecursive:I}),P=re?B?.hoverClassName!==void 0?B.hoverClassName:$.entryHover:"",a=(()=>{if(N){if(M)return B?.directorySelectedClassName!==void 0?B.directorySelectedClassName:$.entrySelected}else if(M||V)return B?.itemSelectedClassName!==void 0?B.itemSelectedClassName:D.twMerge(M&&$.entrySelected,V&&$.entryItemSelected);return""})(),b=typeof v=="function"?v(e):v,T=D.twMerge("dt-grid-row cursor-pointer select-none",P,a,b,e.className),A=D.twMerge($.expandIcon,(M||V)&&$.expandIconSelected),se=D.twMerge($.typeIcon,(M||V)&&$.typeIconSelected),ce=D.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",N&&$.nameDirectory,(M||V)&&$.nameSelected),L=Xt({isDirectory:N,isExpanded:z,showExpandIcons:p,useCanvasExpandIcons:H,expandIconSize:te}),ae=(N?W:_)?Jt({entry:e,isDirectory:N,isExpanded:z,isSelected:M,isItemSelected:V,extension:de,mimeType:e.mimeType},E):null,k={indentLevel:t,isDirectory:N,isExpanded:z},[U,...q]=R,Z=U?.render?U.render(e,k):e.label??e.name,we={...re?B?.hoverStyle:{},...N&&M?B?.directorySelectedStyle:{},...!N&&(M||V)?B?.itemSelectedStyle:{}};return u.jsxs("div",{className:T,style:{height:i,...we,...e.style},role:"row","aria-expanded":N?z:void 0,"aria-level":t+1,"aria-posinset":s,"aria-setsize":r,"aria-rowindex":n,"aria-selected":m==="none"?void 0:c,...qt(e.data),"data-entry-type":N?"directory":"file","data-entry-expanded":N?String(z):void 0,"data-entry-selected":M?"true":void 0,"data-entry-item-selected":V?"true":void 0,onClick:fe,onMouseEnter:()=>ne(!0),onMouseLeave:()=>ne(!1),onKeyDown:Q=>Q.key==="Enter"&&fe(Q),tabIndex:0,children:[u.jsxs("div",{className:D.twMerge("dt-grid-name-cell",U?.className),role:"gridcell",style:{width:h,paddingLeft:Math.max(0,t*J)},children:[(p||H)&&u.jsx("span",{className:A,children:L}),(N?W:_)&&u.jsx("span",{className:se,children:ae}),u.jsx("span",{className:ce,children:Z})]}),q.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:er(d,x),children:q.map(Q=>u.jsx("div",{className:D.twMerge("dt-grid-cell",Qt(Q.align),Q.className),role:"gridcell",children:Q.render?Q.render(e,k):null},Q.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const s=Vt(e.entry,e.isDirOpen),r=Vt(t.entry,t.isDirOpen);return e.indentLevel===t.indentLevel&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.rowIndex===t.rowIndex&&e.isSelectedForAria===t.isSelectedForAria&&e.rowHeight===t.rowHeight&&s===r&&e.columns===t.columns&&e.numericTemplate===t.numericTemplate&&e.numericTotal===t.numericTotal&&e.nameWidth===t.nameWidth&&e.rowClassName===t.rowClassName&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});tr.displayName="DirectoryTreeGridRow";const rr=({kind:e,columns:t,numericTemplate:s,numericTotal:r,nameWidth:n,scrollBarWidth:c,className:i,nameContent:f,renderCell:R})=>{const[,...x]=t,d=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",h=e==="header"?"dt-grid-header":"dt-grid-footer",v=e==="header"?"columnheader":"gridcell";return u.jsxs("div",{className:D.twMerge(h,"text-gray-600 dark:text-gray-300",i),role:"row",children:[u.jsx("div",{className:D.twMerge(d,"px-1",t[0]?.className),role:v,style:{width:n},children:f}),x.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:er(r,s),children:x.map(w=>u.jsx("div",{className:D.twMerge("dt-grid-cell",Qt(w.align),w.className),role:v,children:R(w)},w.key))})}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},Tr=({columns:e,className:t,...s})=>u.jsx(rr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:r=>r.header??null,...s}),Gt=(e,t)=>typeof e=="function"?e(t):e??null,_r=({columns:e,allEntries:t,className:s,...r})=>u.jsx(rr,{kind:"footer",columns:e,className:s,nameContent:Gt(e[0]?.footer,t),renderCell:n=>Gt(n.footer,t),...r}),Ar=240,nr=96,sr=12,ot=(e,t)=>{const s=e?.width;return typeof s=="number"&&Number.isFinite(s)&&s>0?s:t},Mr=e=>e.slice(1).map(t=>`${ot(t,nr)}px`).join(" "),Lr=({measuredWidth:e,columns:t,scrollBarWidth:s=sr})=>{const r=ot(t[0],Ar),n=t.slice(1).reduce((R,x)=>R+ot(x,nr),0),c=Number.isFinite(e)&&e>0?e:0,i=Math.max(0,c-r-Math.max(0,s)),f=Math.max(0,n-i);return{nameWidth:r,numericTotal:n,numericVisible:i,maxHScroll:f}},st=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,Pr=e=>{const t=[],s=r=>{for(const n of r)t.push(n),n.children&&n.children.length>0&&s(n.children)};return s(e),t},ar=["entryKindDirectory","entryKindFile"],lt=[...ue.VIRTUAL_SCROLL_LABEL_KEYS,...ar],it=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),or=Object.freeze({en:Object.freeze({...ue.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...it.en}),ja:Object.freeze({...ue.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...it.ja})}),Ut=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,Or=e=>{const t={};let s=!1;for(const r of ue.VIRTUAL_SCROLL_LABEL_KEYS){const n=Object.hasOwn(e,r)?e[r]:void 0;n!==void 0&&(t[r]=n,s=!0)}return s?t:void 0},lr=(e,t)=>{const s=ue.resolveVirtualScrollLocale(e);if(t===void 0)return or[s];if(t===null||typeof t!="object")throw new RangeError(`[directory-tree] labels must be an object; got ${Ut(t)}`);const r=Object.getPrototypeOf(t);if(r!==Object.prototype&&r!==null)throw new RangeError(`[directory-tree] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);for(const i of Object.keys(t))if(!lt.includes(i))throw new RangeError(`[directory-tree] labels.${i} is not a known label key; expected one of ${lt.join(", ")}`);const c={...ue.resolveVirtualScrollLabels(s,Or(t)),...it[s]};for(const i of ar){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 ${Ut(f)}`);c[i]=f}}return Object.freeze(c)},Dr=e=>{const t={};for(const s of ue.VIRTUAL_SCROLL_LABEL_KEYS)t[s]=e[s];return Object.freeze(t)},Fr=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let r=0,n=s-1,c=0;for(;r<=n;){const i=r+n>>>1;e[i]<=t?(c=i,r=i+1):n=i-1}return c},$r=(e,t,s)=>{if(s<=0||e.length===0||t.length!==e.length+1)return null;const r=Fr(t,s),n=e[r];return n?{path:n.entry.absolutePath,offsetInViewport:s-t[r]}:null},Hr=(e,t,s)=>{if(t.length===0||s.length!==t.length+1)return null;for(let r=0;r<t.length;r++)if(t[r].entry.absolutePath===e.path)return Math.max(0,s[r]+e.offsetInViewport);return null},Wr=(e,t,s)=>{const r=[];for(let n=t;n<s;n++){const c=e[n];if(!(!c||c.length===0))for(const i of c)r.push(i)}return r},Br=(e,t,s)=>{const r=[];for(let n=t;n<s;n++){const c=e[n];if(!(!c||c.length===0))for(const i of c)r.push(i)}return r},Yr=(e,t,s,r)=>{const n=Math.max(1,Math.floor(t*r)),c=Math.max(1,Math.floor(s*r));(e.width!==n||e.height!==c)&&(e.width=n,e.height=c);const i=e.style;i.width!==`${t}px`&&(i.width=`${t}px`),i.height!==`${s}px`&&(i.height=`${s}px`)},zr=(e,t,s)=>{e.lineWidth=s,e.beginPath();for(const r of t)e.moveTo(r.x1,r.y1),e.lineTo(r.x2,r.y2);e.stroke()},Vr=(e,t)=>{const s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!s)return null;let r=s[1];r.length===3&&(r=r.split("").map(f=>f+f).join(""));const n=Number.parseInt(r.slice(0,2),16),c=Number.parseInt(r.slice(2,4),16),i=Number.parseInt(r.slice(4,6),16);return`rgba(${n}, ${c}, ${i}, ${t})`},Gr=(e,t,s,r)=>{if(t.length===0)return;const n=Vr(s,.14),c=e.strokeStyle,i=e.fillStyle,f=e.lineWidth,R=e.lineCap,x=e.lineJoin;e.strokeStyle=s,e.lineCap="round",e.lineJoin="round";for(const d of t){const h=r??d.size,v=Math.max(0,h/2),w=Math.max(1,Math.round(h*.08)),j=Math.max(1,Math.round(h*.14)),m=Math.max(0,v-w*.8),y=Math.max(0,m*.55);n&&(e.fillStyle=n,e.beginPath(),e.arc(d.centerX,d.centerY,m,0,Math.PI*2),e.fill()),e.lineWidth=w,e.beginPath(),e.arc(d.centerX,d.centerY,Math.max(0,v-w*.3),0,Math.PI*2),e.stroke(),e.lineWidth=j,e.beginPath(),e.moveTo(d.centerX-y,d.centerY),e.lineTo(d.centerX+y,d.centerY),e.stroke(),d.isExpanded||(e.beginPath(),e.moveTo(d.centerX,d.centerY-y),e.lineTo(d.centerX,d.centerY+y),e.stroke())}e.strokeStyle=c,e.fillStyle=i,e.lineWidth=f,e.lineCap=R,e.lineJoin=x},ir=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:r,viewportHeight:n,scrollPosition:c,color:i="#a0aec0",strokeWidth:f=1,renderStartIndex:R,renderEndIndex:x,lookaheadEndIndex:d,devicePixelRatio:h,expandGlyphColor:v,expandGlyphSize:w})=>{const j=l.useRef(null),m=l.useRef(null),y=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:r,viewportHeight:n,scrollPosition:c,color:i,strokeWidth:f,renderStartIndex:R,renderEndIndex:x,lookaheadEndIndex:d,devicePixelRatio:h,expandGlyphColor:v,expandGlyphSize:w}),S=l.useCallback(()=>{m.current=null;const I=j.current;if(!I)return;const E=I.getContext("2d");if(!E)return;const p=y.current;if(p.width<=0||p.viewportHeight<=0){E.clearRect(0,0,I.width,I.height);return}const W=Number.isFinite(p.devicePixelRatio??NaN)?p.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;Yr(I,p.width,p.viewportHeight,W);const _=p.segmentsByItem.length,H=typeof p.renderStartIndex=="number"&&Number.isFinite(p.renderStartIndex)?Math.max(0,Math.floor(p.renderStartIndex)):Math.max(0,Math.floor(p.scrollPosition/p.itemHeight)),te=Math.min(_,Math.ceil((p.scrollPosition+p.viewportHeight)/p.itemHeight)),J=(()=>{if(typeof p.renderEndIndex=="number"&&Number.isFinite(p.renderEndIndex)){const N=Math.floor(p.renderEndIndex);return Math.max(Math.min(_,N+1),H)}return Math.max(te,H)})(),B=(()=>{if(typeof p.lookaheadEndIndex=="number"&&Number.isFinite(p.lookaheadEndIndex)){const N=Math.floor(p.lookaheadEndIndex),z=Math.min(_,N+1);return Math.max(z,J)}return Math.max(te,J)})(),re=Wr(p.segmentsByItem,H,B),ne=Br(p.glyphsByItem,H,B);E.save(),E.scale(W,W),E.clearRect(0,0,p.width,p.viewportHeight),E.translate(0,-p.scrollPosition),E.strokeStyle=p.color,zr(E,re,p.strokeWidth),Gr(E,ne,p.expandGlyphColor??p.color,p.expandGlyphSize),E.restore()},[]),C=l.useCallback(()=>{m.current===null&&(m.current=window.requestAnimationFrame(S))},[S]);return l.useEffect(()=>{y.current={segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:r,viewportHeight:n,scrollPosition:c,color:i,strokeWidth:f,renderStartIndex:R,renderEndIndex:x,lookaheadEndIndex:d,devicePixelRatio:h,expandGlyphColor:v,expandGlyphSize:w},C()},[e,t,s,r,n,c,i,f,R,x,d,h,v,w,C]),l.useEffect(()=>()=>{m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null)},[]),u.jsx("canvas",{ref:j,className:"pointer-events-none absolute top-0 left-0 z-0"})});ir.displayName="TreeLineCanvas";const Ur={msOverflowStyle:"none",scrollbarWidth:"none"},Kr=()=>{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))},Xr=e=>{const t=l.useRef(null),s=t.current;return s!==null&&ue.VIRTUAL_SCROLL_LABEL_KEYS.every(r=>s[r]===e[r])?s:(t.current=e,e)},Jr=(e,t,s,r,n)=>{const c=[],i=[];let f=0;const R=(x,d,h)=>{const v=n?[...x].sort(n):x;for(let w=0;w<v.length;w++){const j=v[w],m=w===v.length-1,y=[...h,m],S=j.children!==void 0,C=S&&t(j.absolutePath,j.relativePath);let I=d,E=y,p=h;r&&(I=d-1,E=y.slice(1),p=h.slice(1)),c.push({entry:j,indentLevel:I,depth:d,positionInSet:w+1,setSize:v.length,parentIsLast:E}),s&&(I>f&&(f=I),i.push({id:j.absolutePath,name:j.name,absolutePath:j.absolutePath,indentLevel:I,isLastChild:m,isDirectory:S,isExpanded:C,ancestorIsLast:[...p],hideLines:r&&d===0})),S&&C&&j.children&&R(j.children,d+1,y)}};return R(e,0,[]),{flatItems:c,lineItems:i,maxIndent:f}},Kt=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let r=0,n=s-1,c=0;for(;r<=n;){const i=r+n>>>1;e[i]<=t?(c=i,r=i+1):n=i-1}return c},qr=(e,t,s,r,n,c)=>{const i=r?.renderStart??Math.max(0,Kt(c,n)),f=t>0?Kt(c,n+t)+s:i+s,R=e>0?Math.min(e-1,Math.max(i,f)):i,x=r?.renderEnd??R,d=e>0?Math.min(e-1,x+s):x;return{renderStart:i,renderEnd:x,lookaheadEnd:d}},Zr=(e,t,s,r,n,c)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const i=Array.from({length:e.length},()=>[]),f=Array.from({length:e.length},()=>[]),R=d=>n?typeof c=="number"&&Number.isFinite(c)&&c>0?c:Math.max(8,Math.min(r*.9,d*.7)):0,x=3;for(let d=0;d<e.length;d++){const h=e[d];if(h.hideLines)continue;const v=[],w=t[d]??0,j=s[d]??0,m=j+w/2,y=R(w),S=y>0?y/2+2:r/1.5;for(let E=0;E<h.indentLevel;E++){if(h.ancestorIsLast[E]??!1)continue;let W=!1;for(let _=d;_<e.length;_++){const H=e[_];if(H.indentLevel>E&&H.ancestorIsLast.length>E&&!H.ancestorIsLast[E]){W=!0;break}if(_>d&&H.indentLevel===E)break}if(W){const _=E*r+r/2+x;v.push({key:`${h.id}-ancestor-${E}`,x1:_,y1:j,x2:_,y2:j+w,itemIndex:d})}}const C=h.indentLevel*r,I=C+r/2+x;if(h.isDirectory?v.push({key:`${h.id}-connector-top`,x1:I,y1:j,x2:I,y2:m-S,itemIndex:d}):v.push({key:`${h.id}-connector-top`,x1:I,y1:j,x2:I,y2:m,itemIndex:d}),!h.isDirectory&&h.isLastChild&&v.push({key:`${h.id}-connector-horizontal`,x1:I,y1:m,x2:C+r+x,y2:m,itemIndex:d}),h.isLastChild||(h.isDirectory?v.push({key:`${h.id}-connector-bottom`,x1:I,y1:m+S,x2:I,y2:j+w,itemIndex:d}):v.push({key:`${h.id}-connector-bottom`,x1:I,y1:m,x2:I,y2:j+w,itemIndex:d})),i[d]=v,n&&h.isDirectory){const E=y,p=I,W=m;f[d]=[{key:`${h.id}-glyph`,itemIndex:d,centerX:p,centerY:W,size:E,isExpanded:h.isExpanded}]}}return{segmentsByItem:i,glyphsByItem:f}},ct=l.memo(({entry:e,indentLevel:t,depth:s,positionInSet:r,setSize:n,isSelectedForAria:c,flatIndex:i,isActive:f,registerRowRef:R,onNavigationKeyDown:x,rowHeight:d,entryKindDirectory:h,entryKindFile:v,isDirOpen:w,parentIsLast:j,renderChildren:m=!0,expansion:{toggleDirectory:y,onToggleDirectoryRecursive:S},selection:{onEntryClick:C,selectedPath:I,mode:E="none",selectedItems:p,onSelectionChange:W},visual:{iconOverrides:_,showExpandIcons:H=!0,showDirectoryIcons:te=!0,showFileIcons:J=!0,useCanvasExpandIcons:B=!1,expandIconSize:re,typeIconSize:ne,fontSize:N,indentSize:z=Ve,highlightStyles:M,entryClassName:V,entryStyle:de,nameClassName:fe,nameStyle:P,directoryNameClassName:a,directoryNameStyle:b,fileNameClassName:T,fileNameStyle:A}})=>{const[se,ce]=l.useState(null),[L,ae]=l.useState(!1),k=e.children!==void 0,U=k&&w(e.absolutePath),q=e.absolutePath===I,Z=!k&&p?.has(e.absolutePath),we=k?void 0:ve(e.name)||ve(e.relativePath)||ve(e.absolutePath);l.useEffect(()=>{ce(U&&e.children?e.children:null)},[U,e.children]);const Q=Zt({entry:e,isDirectory:k,isExpanded:U,isItemSelected:!!Z,selectionMode:E,onSelectionChange:W,onEntryClick:C,toggleDirectory:y,onToggleDirectoryRecursive:S}),Ge=L?M?.hoverClassName!==void 0?M.hoverClassName:$.entryHover:"",Ie=(()=>{if(k){if(q)return M?.directorySelectedClassName!==void 0?M.directorySelectedClassName:$.entrySelected}else if(q||Z)return M?.itemSelectedClassName!==void 0?M.itemSelectedClassName:D.twMerge(q&&$.entrySelected,Z&&$.entryItemSelected);return""})(),Le=D.twMerge($.entry,Ge,Ie,V,e.className),Ue=D.twMerge($.expandIcon,(q||Z)&&$.expandIconSelected),Ce=D.twMerge($.typeIcon,(q||Z)&&$.typeIconSelected),Ne=D.twMerge($.name,fe,k&&$.nameDirectory,k&&a,!k&&T,(q||Z)&&$.nameSelected),Pe=Xt({isDirectory:k,isExpanded:U,showExpandIcons:H,useCanvasExpandIcons:B,expandIconSize:re}),Ke=(k?te:J)?Jt({entry:e,isDirectory:k,isExpanded:U,isSelected:q,isItemSelected:!!Z,extension:we,mimeType:e.mimeType},_):null,Ee={...L?M?.hoverStyle:{},...k&&q?M?.directorySelectedStyle:{},...!k&&(q||Z)?M?.itemSelectedStyle:{}},Oe=qt(e.data),De=ne?{width:ne,height:ne}:void 0,Te=N?{fontSize:typeof N=="number"?`${N}px`:N}:void 0;return u.jsxs(l.Fragment,{children:[u.jsxs("div",{className:Le,style:{paddingLeft:`${Math.max(0,t*z)}px`,transform:t<0?`translateX(${t*z}px)`:void 0,width:t<0?`calc(100% + ${Math.abs(t*z)}px)`:void 0,height:`${d}px`,...Te,...Ee,...de,...e.style},...Oe,"data-entry-type":k?"directory":"file","data-entry-expanded":k?String(U):void 0,"data-entry-selected":q?"true":void 0,"data-entry-item-selected":Z?"true":void 0,onClick:Q,onMouseEnter:()=>ae(!0),onMouseLeave:()=>ae(!1),ref:oe=>R(i,oe),onKeyDown:oe=>{if(oe.key==="Enter"||oe.key===" "){oe.preventDefault(),Q(oe);return}x(oe,i)},tabIndex:f?0:-1,role:"treeitem","aria-expanded":k?U:void 0,"aria-level":s+1,"aria-posinset":r,"aria-setsize":n,"aria-selected":E==="none"?void 0:c,"aria-label":`${e.name} (${k?h:v})`,children:[(H||B)&&u.jsx("span",{className:Ue,children:Pe}),(k?te:J)&&u.jsx("span",{className:Ce,style:De,children:Ke}),u.jsx("span",{className:Ne,style:{...Te,...P,...k?b:A},"data-entry-type":k?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),U&&se&&m&&u.jsx("fieldset",{children:se.map((oe,_e)=>u.jsx(ct,{entry:oe,indentLevel:t+1,depth:s+1,positionInSet:_e+1,setSize:se.length,isSelectedForAria:!!p?.has(oe.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:R,onNavigationKeyDown:x,rowHeight:d,entryKindDirectory:h,entryKindFile:v,isDirOpen:w,parentIsLast:[...j,_e===se.length-1],expansion:{toggleDirectory:y,onToggleDirectoryRecursive:S},selection:{onEntryClick:C,selectedPath:I,mode:E,selectedItems:p,onSelectionChange:W},visual:{iconOverrides:_,showExpandIcons:H,showDirectoryIcons:te,showFileIcons:J,useCanvasExpandIcons:B,expandIconSize:re,highlightStyles:M,entryClassName:V,entryStyle:de,nameClassName:fe,nameStyle:P,directoryNameClassName:a,directoryNameStyle:b,fileNameClassName:T,fileNameStyle:A}},oe.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const s=e.entry.children!==void 0,r=t.entry.children!==void 0,n=s&&e.isDirOpen(e.entry.absolutePath),c=r&&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&&n===c&&e.selection.selectedPath===t.selection.selectedPath&&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.parentIsLast.length===t.parentIsLast.length&&e.parentIsLast.every((i,f)=>i===t.parentIsLast[f])});ct.displayName="DirectoryEntryItem";const cr=e=>{const t=[];if(e.children)for(const s of e.children)s.type==="directory"&&(t.push(s.absolutePath),t.push(...cr(s)));return t},Qr=({entries:e,expansion:{toggle:t,isExpanded:s,expandMultiple:r,collapseMultiple:n,isPending:c,alwaysExpanded:i=!1,doubleClickAction:f="recursive"},selection:{onEntryClick:R,selectedPath:x,mode:d="none",selectedItems:h,onSelectionChange:v},visual:{className:w,style:j,ariaLabel:m,ariaLabelledBy:y,lineColor:S="#A0AEC0",showTreeLines:C=!0,showExpandIcons:I=!0,showDirectoryIcons:E=!0,showFileIcons:p=!0,iconOverrides:W,expandIconSize:_,itemHeight:H=ze,removeRootIndent:te=!1,highlightStyles:J,entryClassName:B,entryStyle:re,nameClassName:ne,nameStyle:N,directoryNameClassName:z,directoryNameStyle:M,fileNameClassName:V,fileNameStyle:de}={},virtualScroll:fe,grid:P,sort:a,locale:b,labels:T})=>{const A=ue.resolveVirtualScrollLocale(b),se=l.useMemo(()=>lr(b,T),[b,T]),ce=Xr(Dr(se)),{entryKindDirectory:L,entryKindFile:ae}=se,k=P!==void 0,[U,q]=l.useState(!1),Z=l.useRef(null),we=l.useRef(null),Q=l.useRef(null),[Ge,Ie]=l.useState(0),[Le,Ue]=l.useState(0),[Ce,Ne]=l.useState(0),[Pe,Ke]=l.useState(null),{overscanCount:Ee=15,className:Oe,background:De,onScroll:Te,onRangeChange:oe,initialScrollIndex:_e,initialScrollOffset:Se,initialScrollAnchor:ut,callbackThrottleMs:dt=5,contentInsets:ft,onItemFocus:mt,viewportHeightOverride:le,scrollBarOptions:Xe,behaviorOptions:ht,preserveScrollAnchor:pt=!1,getItemKey:ur,testId:yt,contentProps:Je}=fe??{},bt=l.useMemo(()=>k?{role:"rowgroup",...Je}:Je,[k,Je]),[Fe,gt]=l.useState(typeof Se=="number"?Se:0),qe=l.useRef(typeof Se=="number"?Se:0),xt=l.useCallback((o,g)=>{qe.current=o,gt(o),Te?.(o,g)},[Te]),vt=l.useCallback(o=>{const{renderingStartIndex:g,renderingEndIndex:O}=o;Ke(Y=>Y&&Y.renderStart===g&&Y.renderEnd===O?Y:{renderStart:g,renderEnd:O}),oe?.(o)},[oe]);l.useEffect(()=>{q(!0),Kr()},[]),l.useEffect(()=>{const o=Z.current,g=k?we.current:o,O=()=>{if(o){const G=o.clientWidth;Ue(X=>Math.abs(X-G)>1?G:X)}if(typeof le=="number")Ie(G=>Math.abs(G-le)>1?le:G);else if(g){const G=g.clientHeight;Ie(X=>Math.abs(X-G)>1?G:X)}};if(!(o||g))return Ie(0);O();const Y=new ResizeObserver(O);return o&&Y.observe(o),g&&g!==o&&Y.observe(g),()=>Y.disconnect()},[le,k]);const ke=typeof le=="number"?le:Ge,me=l.useCallback(o=>i||(U?s(o):!1),[U,s,i]),wt=D.twMerge($.container,c&&$.containerPending,w),Et=l.useMemo(()=>({...Ur,...j??{},...typeof le=="number"?{height:le,minHeight:le}:{}}),[j,le]),Ze=l.useCallback((o,g)=>{const O=[o.absolutePath,...cr(o)],Y=g||f;if(O.every(he=>me(he)))return n(O);if(O.every(he=>!me(he))||Y==="recursive")return r(O);if(Y==="toggle")return n(O);console.warn(`[DirectoryTree] Unknown double click action: ${Y}. No action taken.`)},[me,r,n,f]),St=k?!1:te,{flatItems:be,lineItems:Qe,maxIndent:kt}=l.useMemo(()=>Jr(e,me,C,St,a),[e,me,C,St,a]),K=l.useMemo(()=>be.map((o,g)=>{const O=typeof H=="function"?H(o.entry,g):H;return{...o,rowHeight:Number.isFinite(O)&&O>0?O:ze}}),[be,H]),pe=l.useMemo(()=>K.map(o=>o.rowHeight),[K]),ge=l.useMemo(()=>{const o=new Array(pe.length+1);o[0]=0;for(let g=0;g<pe.length;g++)o[g+1]=o[g]+pe[g];return o},[pe]),Rt=l.useCallback(o=>K[o]?.rowHeight??ze,[K]),dr=l.useCallback(o=>K[o]?.entry.absolutePath??o,[K]),jt=ur??dr,It=l.useRef(be);It.current=be;const Ct=l.useRef(me);Ct.current=me;const et=l.useRef(t);et.current=t;const[Nt,Tt]=l.useState(0),tt=l.useRef(new Map),rt=l.useRef(null),_t=l.useCallback((o,g)=>{g?(tt.current.set(o,g),rt.current===o&&(rt.current=null,g.focus())):tt.current.delete(o)},[]),xe=l.useCallback(o=>{Tt(o);const g=tt.current.get(o);if(g){g.focus();return}rt.current=o,Q.current?.scrollToIndex(o)},[]);l.useEffect(()=>{Tt(o=>be.length===0?0:Math.min(o,be.length-1))},[be.length]);const At=l.useCallback((o,g)=>{const O=It.current,Y=O.length-1;if(Y<0)return;const G=O[g],X=G?.entry.children!==void 0,he=X&&Ct.current(G.entry.absolutePath);switch(o.key){case"ArrowDown":o.preventDefault(),xe(Math.min(g+1,Y));break;case"ArrowUp":o.preventDefault(),xe(Math.max(g-1,0));break;case"Home":o.preventDefault(),xe(0);break;case"End":o.preventDefault(),xe(Y);break;case"ArrowRight":o.preventDefault(),X&&!he?et.current(G.entry.absolutePath):X&&g<Y&&xe(g+1);break;case"ArrowLeft":{if(o.preventDefault(),X&&he){et.current(G.entry.absolutePath);break}const yr=G?.depth??0;for(let Be=g-1;Be>=0;Be--)if(O[Be].depth<yr){xe(Be);break}break}}},[xe]),$e=l.useMemo(()=>!C||Qe.length===0?{segmentsByItem:[],glyphsByItem:[]}:Zr(Qe,pe,ge,Ve,C,_??zt),[Qe,pe,ge,C,_]),He=l.useMemo(()=>!C||e.length===0?0:(kt+2)*Ve,[e.length,kt,C]),{renderStart:Mt,renderEnd:Lt,lookaheadEnd:Pt}=l.useMemo(()=>qr(K.length,ke,Ee,Pe,Fe,ge),[K.length,ke,Ee,Pe,Fe,ge]),nt=l.useMemo(()=>!C||He<=0||ke<=0||$e.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:He,height:ke},children:u.jsx(ir,{segmentsByItem:$e.segmentsByItem,glyphsByItem:$e.glyphsByItem,itemHeight:pe[0]??ze,width:He,viewportHeight:ke,scrollPosition:Fe,color:S,expandGlyphColor:S,expandGlyphSize:_??zt,renderStartIndex:Mt,renderEndIndex:Lt,lookaheadEndIndex:Pt})})}),[He,ke,Mt,Lt,Pt,Fe,$e,S,C,_,pe]),Ot=l.useCallback(o=>K[o],[K]),Dt=l.useRef(null);l.useLayoutEffect(()=>{const o=Dt.current;if(Dt.current={items:K,offsets:ge},!pt||!o||o.items===K)return;const g=Q.current,O=g?.getScrollPosition(),Y=typeof O=="number"&&O>=0?O:qe.current,G=$r(o.items,o.offsets,Y);if(!G)return;const X=Hr(G,K,ge);if(X===null||Math.abs(X-Y)<1)return;const he=g?g.scrollTo(X):X;qe.current=he,gt(he)},[K,ge,pt]);const ye=P?.columns,Re=P?.scrollBarWidth??Xe?.width??sr,ee=l.useMemo(()=>ye?Lr({measuredWidth:Le,columns:ye,scrollBarWidth:Re}):null,[ye,Le,Re]),We=l.useMemo(()=>ye?Mr(ye):"",[ye]),fr=l.useMemo(()=>P?.showFooter&&ye?Pr(e):[],[P?.showFooter,ye,e]),je=ee?.maxHScroll??0;l.useEffect(()=>{Ne(o=>st(o,je))},[je]);const Ft=l.useCallback(o=>Ne(g=>st(g+o,je)),[je]),$t=l.useMemo(()=>({iconOverrides:W,showExpandIcons:I,showDirectoryIcons:E,showFileIcons:p,useCanvasExpandIcons:C,expandIconSize:_,highlightStyles:J}),[W,I,E,p,C,_,J]),Ht=l.useMemo(()=>u.jsx(ue.VirtualScroll,{ref:Q,itemCount:K.length,getItem:Ot,getItemHeight:Rt,getItemKey:jt,testId:yt,contentProps:bt,locale:A,labels:ce,viewportSize:typeof le=="number"?le:void 0,overscanCount:Ee,onScroll:xt,onRangeChange:vt,className:Oe,onWheelHorizontal:k?Ft:void 0,background:u.jsxs(u.Fragment,{children:[k&&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:nt}):nt,De]}),initialScrollIndex:_e,initialScrollOffset:Se,initialScrollAnchor:ut,onItemFocus:mt,callbackThrottleMs:dt,contentInsets:ft,scrollBarOptions:Xe,behaviorOptions:ht,children:(o,g)=>o?k&&P&&ee?u.jsx(tr,{entry:o.entry,indentLevel:o.indentLevel,positionInSet:o.positionInSet,setSize:o.setSize,rowIndex:g+(P.showHeader??!0?2:1),isSelectedForAria:!!h?.has(o.entry.absolutePath),rowHeight:o.rowHeight,isDirOpen:me,columns:P.columns,numericTemplate:We,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,rowClassName:P.rowClassName,selection:{onEntryClick:R,selectedPath:x??null,mode:d,selectedItems:h,onSelectionChange:v},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Ze},visual:$t},o.entry.absolutePath):u.jsx(ct,{entry:o.entry,indentLevel:o.indentLevel,depth:o.depth,positionInSet:o.positionInSet,setSize:o.setSize,isSelectedForAria:!!h?.has(o.entry.absolutePath),flatIndex:g,isActive:g===Nt,registerRowRef:_t,onNavigationKeyDown:At,rowHeight:o.rowHeight,entryKindDirectory:L,entryKindFile:ae,isDirOpen:me,parentIsLast:o.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Ze},selection:{onEntryClick:R,selectedPath:x??null,mode:d,selectedItems:h,onSelectionChange:v},visual:{iconOverrides:W,showExpandIcons:I,showDirectoryIcons:E,showFileIcons:p,useCanvasExpandIcons:C,expandIconSize:_,highlightStyles:J,entryClassName:B,entryStyle:re,nameClassName:ne,nameStyle:N,directoryNameClassName:z,directoryNameStyle:M,fileNameClassName:V,fileNameStyle:de}},o.entry.absolutePath):null}),[K.length,Ot,Rt,jt,yt,bt,A,ce,L,ae,Nt,_t,At,le,Ee,xt,vt,Oe,k,Ft,ee,nt,De,_e,Se,ut,mt,dt,ft,Xe,ht,P,We,me,R,x,d,h,v,t,Ze,$t,W,I,E,p,C,_,J,B,re,ne,N,z,M,V,de]);if(!(P&&ee))return u.jsx("div",{ref:Z,className:wt,style:Et,role:"tree","aria-label":y?void 0:m,"aria-labelledby":y,"aria-multiselectable":d==="multiple"?!0:void 0,children:Ht});const mr=P.showHeader??!0,hr=P.showFooter??!1,pr={...Et,"--dt-hscroll":`${Ce}px`};return u.jsxs("div",{ref:Z,className:D.twMerge(wt,"dt-grid"),style:pr,role:"treegrid","aria-label":y?void 0:m,"aria-labelledby":y,"aria-multiselectable":d==="multiple"?!0:void 0,"aria-rowcount":K.length+(P.showHeader??!0?1:0),children:[mr&&u.jsx("div",{role:"rowgroup",children:u.jsx(Tr,{columns:P.columns,numericTemplate:We,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Re,className:P.headerClassName})}),u.jsx("div",{ref:we,className:"dt-grid-body",children:Ht}),je>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(ue.ScrollBar,{horizontal:!0,contentSize:ee.numericTotal,viewportSize:ee.numericVisible,scrollPosition:Ce,scrollBarWidth:Re,locale:A,labels:ce,onScroll:o=>{const g=typeof o=="function"?o(Ce):o,O=st(g,je);return Ne(O),O}}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Re},"aria-hidden":"true"})]}),hr&&u.jsx("div",{role:"rowgroup",children:u.jsx(_r,{columns:P.columns,numericTemplate:We,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Re,allEntries:fr,className:P.footerClassName})})]})},en=({initialExpanded:e=new Set,storageKey:t}={})=>{const[s,r]=l.useTransition(),[n,c]=l.useState(()=>{if(typeof window<"u"&&t)try{const m=window.localStorage.getItem(t);if(m){const y=JSON.parse(m);return new Set(y)}}catch(m){console.error("[useDirectoryTreeState] Error reading from localStorage",m)}return e}),i=l.useCallback(m=>{r(()=>{c(y=>{const S=new Set(y);return m(S),S})})},[]),f=l.useCallback((m,y)=>{i(S=>{for(const C of m)y(S,C)})},[i]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(n)))}catch(m){console.warn(`Error setting localStorage key "${t}":`,m)}},[n,t]);const R=l.useCallback(m=>{f([m],(y,S)=>{y.has(S)?y.delete(S):y.add(S)})},[f]),x=l.useCallback(m=>{f([m],(y,S)=>{y.add(S)})},[f]),d=l.useCallback(m=>{f([m],(y,S)=>{y.delete(S)})},[f]),h=l.useCallback(m=>{f(m,(y,S)=>{y.delete(S)})},[f]),v=l.useCallback(m=>{f(m,(y,S)=>{y.add(S)})},[f]),w=l.useCallback(()=>{i(m=>{m.clear()})},[i]),j=l.useCallback(m=>n.has(m),[n]);return{expanded:n,toggle:R,expand:x,collapse:d,collapseMultiple:h,expandMultiple:v,collapseAll:w,isExpanded:j,isPending:s}};exports.DIRECTORY_TREE_LABEL_CATALOGS=or;exports.DIRECTORY_TREE_LABEL_KEYS=lt;exports.DirectoryTree=Qr;exports.directoryTreeClasses=$;exports.resolveDirectoryTreeLabels=lr;exports.useDirectoryTreeState=en;
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;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { DirectoryTree, directoryTreeClasses } from "./DirectoryTree.tsx";
2
2
  export { DIRECTORY_TREE_LABEL_CATALOGS, DIRECTORY_TREE_LABEL_KEYS, type DirectoryTreeLabelOverrides, type DirectoryTreeLabels, type DirectoryTreeLocale, resolveDirectoryTreeLabels } from "./labels.ts";
3
- export type { DirectoryEntry, DirectoryEntryComparator, DirectoryEntryItemProps, DirectoryTreeClickEvent, DirectoryTreeColumn, DirectoryTreeGrid, DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext, DirectoryTreeIconRenderer, DirectoryTreeProps, DirectoryTreeState, DirectoryTreeVirtualScrollOptions, HighlightStyles, ItemHeight, TreeLineItemInfo, TreeLineProps, UseDirectoryTreeStateProps, } from "./types.ts";
3
+ export type { DirectoryEntry, DirectoryEntryComparator, DirectoryEntryItemProps, DirectoryTreeClickEvent, DirectoryTreeColumn, DirectoryTreeGrid, DirectoryTreeHandle, DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext, DirectoryTreeIconRenderer, DirectoryTreeProps, DirectoryTreeScrollAlign, DirectoryTreeScrollOptions, DirectoryTreeState, DirectoryTreeVirtualScrollOptions, HighlightStyles, ItemHeight, TreeLineItemInfo, TreeLineProps, UseDirectoryTreeStateProps, } from "./types.ts";
4
4
  export { useDirectoryTreeState } from "./useDirectoryTreeState.ts";