@aiquants/directory-tree 3.11.2 โ†’ 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
@@ -13,6 +13,7 @@ A high-performance React directory tree component with virtualization, file sele
13
13
  - **๐Ÿ”ง TypeScript**: Complete TypeScript support with comprehensive type definitions
14
14
  - **๐Ÿ’พ State Persistence**: Automatic localStorage persistence for expansion states
15
15
  - **๐ŸŽฏ Flexible Selection**: Support for none, single, or multiple selection modes
16
+ - **๐ŸŒ Localization**: Row kind words and the embedded scroll chrome ship in English (default) and Japanese via `locale`, with per-key `labels` overrides. See [Localization](#localization)
16
17
 
17
18
  ## Installation
18
19
 
@@ -32,6 +33,8 @@ This package requires the following peer dependencies:
32
33
  npm install react react-dom @aiquants/virtualscroll
33
34
  ```
34
35
 
36
+ `@aiquants/virtualscroll` must be 3.7.0 or later (it supplies the `locale` / `labels` chrome catalog).
37
+
35
38
  ## Quick Start
36
39
 
37
40
  ```tsx
@@ -122,6 +125,9 @@ The main component for rendering the directory tree.
122
125
  | `selection` | `object` | Yes | Configuration for item selection |
123
126
  | `visual` | `object` | No | Visual customization options |
124
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) |
129
+ | `locale` | `DirectoryTreeLocale` (`"en"` \| `"ja"`) | No | UI chrome language (default `"en"`). See [Localization](#localization) |
130
+ | `labels` | `DirectoryTreeLabelOverrides` | No | Per-key overrides over the catalog of `locale`. See [Localization](#localization) |
125
131
 
126
132
  #### Expansion Options (`expansion`)
127
133
 
@@ -140,7 +146,8 @@ The main component for rendering the directory tree.
140
146
  | Prop | Type | Required | Default | Description |
141
147
  | --- | --- | --- | --- | --- |
142
148
  | `onEntryClick` | `(event: DirectoryTreeClickEvent) => void` | Yes | - | Callback function triggered when an entry is clicked |
143
- | `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 |
144
151
  | `mode` | `'none' \| 'single' \| 'multiple'` | No | `'none'` | Selection mode for items |
145
152
  | `selectedItems` | `Set<string>` | No | - | Set of paths for currently selected items |
146
153
  | `onSelectionChange` | `(entry: DirectoryEntry, isSelected: boolean) => void` | No | - | Callback when item selection changes |
@@ -169,15 +176,43 @@ The main component for rendering the directory tree.
169
176
  | `directoryNameStyle` | `React.CSSProperties` | No | - | Additional inline styles specifically for directory names |
170
177
  | `fileNameClassName` | `string` | No | - | Additional CSS classes specifically for file names |
171
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` |
172
181
 
173
182
  ### Virtual Scroll Options
174
183
 
175
- `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).
176
185
 
177
- - `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`).
178
187
  - `scrollBarOptions`: Configure scrollbar appearance and behavior (width, thumb drag, track click, arrow buttons, tap scroll circle).
179
- - `behaviorOptions`: Configure scrolling behavior (pointer drag, keyboard navigation, inertia, wheel speed).
180
- - `onScroll`, `onRangeChange`, `className`, `background`, `initialScrollIndex`, `initialScrollOffset`: Hook into scroll lifecycle or provide bespoke styling.
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.
181
216
 
182
217
  Example:
183
218
 
@@ -199,6 +234,77 @@ Example:
199
234
  />;
200
235
  ```
201
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
+
202
308
  ### useDirectoryTreeState Hook
203
309
 
204
310
  A hook for managing directory tree state with localStorage persistence.
@@ -314,6 +420,22 @@ You can customize the appearance by passing custom classes or inline styles for
314
420
  />
315
421
  ```
316
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
+
317
439
  Alternatively, you can customize components inside the container using global CSS classes:
318
440
 
319
441
  ```css
@@ -479,6 +601,77 @@ const { toggle, isExpanded, expandMultiple, collapseMultiple } = useDirectoryTre
479
601
  });
480
602
  ```
481
603
 
604
+ ## Localization
605
+
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
610
+ catalog in English (`"en"`, the default) and Japanese (`"ja"`). Entry names, column headers / footers and the
611
+ tree's own accessible name (`visual.ariaLabel`) are your content and are never translated.
612
+
613
+ ```tsx
614
+ <DirectoryTree {...commonProps} locale="ja" />
615
+
616
+ // Any subset of keys can be overridden on top of the chosen catalog
617
+ <DirectoryTree {...commonProps} locale="ja" labels={{ entryKindDirectory: "ใƒ•ใ‚ฉใƒซใƒ€", noItems: "ใƒ•ใ‚กใ‚คใƒซใŒใ‚ใ‚Šใพใ›ใ‚“" }} />
618
+ ```
619
+
620
+ | Key | `en` | `ja` | Where it appears |
621
+ | --- | --- | --- | --- |
622
+ | `entryKindDirectory` | `directory` | `ใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒช` | Directory row accessible name `${name} (${kind})` (classic mode) |
623
+ | `entryKindFile` | `file` | `ใƒ•ใ‚กใ‚คใƒซ` | File row accessible name `${name} (${kind})` (classic mode) |
624
+ | `scrollUp` | `Scroll up` | `ไธŠใธใ‚นใ‚ฏใƒญใƒผใƒซ` | Vertical scrollbar up-arrow `aria-label` |
625
+ | `scrollDown` | `Scroll down` | `ไธ‹ใธใ‚นใ‚ฏใƒญใƒผใƒซ` | Vertical scrollbar down-arrow `aria-label` |
626
+ | `scrollLeft` | `Scroll left` | `ๅทฆใธใ‚นใ‚ฏใƒญใƒผใƒซ` | Grid-mode horizontal scrollbar left-arrow `aria-label` |
627
+ | `scrollRight` | `Scroll right` | `ๅณใธใ‚นใ‚ฏใƒญใƒผใƒซ` | Grid-mode horizontal scrollbar right-arrow `aria-label` |
628
+ | `scrollToTop` | `Top` | `ๅ…ˆ้ ญใธ` | Scroll-to-top pill (`scrollBarOptions.enableScrollToTopBottomButtons`) |
629
+ | `scrollToBottom` | `Bottom` | `ๆœซๅฐพใธ` | Scroll-to-bottom pill (same option) |
630
+ | `noItems` | `No items` | `้ …็›ฎใŒใ‚ใ‚Šใพใ›ใ‚“` | Empty state when `entries` is `[]` |
631
+
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
635
+ rows carry no row-level accessible name (their cells name them), so the kind words apply to classic mode only.
636
+
637
+ - **Default**: omitting `locale` is identical to `locale="en"`, and the `en` catalog is the historical English
638
+ wording byte for byte, so hosts that pass nothing see no DOM change.
639
+ - **No negotiation**: `locale` accepts exactly `"en"` or `"ja"`. Anything else (`"ja-JP"`, `"EN"`, `""`, `null`)
640
+ throws a `RangeError` at render. Map `navigator.language` (or your own setting) to a supported locale yourself.
641
+ - **Validation** (`resolveDirectoryTreeLabels(locale, overrides)`, also exported): `undefined` overrides return the
642
+ frozen catalog itself; otherwise `labels` must be a plain object (prototype `Object.prototype` or `null`; arrays
643
+ and class instances are rejected), only its own properties are read, an unknown key is a `RangeError`, an
644
+ `undefined` value keeps the catalog value, and every present value must be a string with non-whitespace
645
+ content. The result is frozen. The engine keys are validated by the engine's `resolveVirtualScrollLabels`
646
+ (`[virtualscroll]` messages), the own keys by the package (`[directory-tree]` messages).
647
+ - **Forwarding**: `locale` and the engine keys reach both the embedded `VirtualScroll` and the grid-mode
648
+ horizontal `ScrollBar`. An inline `labels={{โ€ฆ}}` object is fine: the forwarded engine labels keep their identity
649
+ while the strings are unchanged, so the virtualized body is not re-rendered.
650
+
651
+ Exports: `DirectoryTreeLocale`, `DirectoryTreeLabels`, `DirectoryTreeLabelOverrides`, `DIRECTORY_TREE_LABEL_KEYS`,
652
+ `DIRECTORY_TREE_LABEL_CATALOGS`, `resolveDirectoryTreeLabels`.
653
+
654
+ ### Migrating to 3.12.0
655
+
656
+ - **Runtime requirement โ€” update `@aiquants/virtualscroll` in the same change**: 3.12.0 imports
657
+ `VIRTUAL_SCROLL_LABEL_KEYS`, `VIRTUAL_SCROLL_LABEL_CATALOGS`, `resolveVirtualScrollLocale` and
658
+ `resolveVirtualScrollLabels`, which exist only in `@aiquants/virtualscroll` >= 3.7.0 (the published peer range is
659
+ `^3.7.0`). A `^3.11.x` caret on this package accepts 3.12.0, so a host that updates only `@aiquants/directory-tree`
660
+ while its lockfile keeps virtualscroll 3.6.x gets just an unmet-peer warning from pnpm's default (non-strict) peer
661
+ handling, and then a missing-export failure at build or load time. Bump both together, e.g.
662
+ `"@aiquants/virtualscroll": "^3.6.1"` โ†’ `"^3.7.0"`.
663
+ - **Default output is unchanged**: omitting `locale` renders the same English DOM as 3.11.x. To show the chrome in
664
+ Japanese (`ใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒช` / `ใƒ•ใ‚กใ‚คใƒซ`, `ไธŠใธใ‚นใ‚ฏใƒญใƒผใƒซ`, `้ …็›ฎใŒใ‚ใ‚Šใพใ›ใ‚“`, โ€ฆ) pass `locale="ja"` explicitly โ€”
665
+ there is no language negotiation.
666
+ - **New API**: the top-level `locale` / `labels` props and the exports listed above.
667
+ - **`virtualScroll.locale` / `virtualScroll.labels` are rejected by the type** (they were accepted but silently
668
+ dropped before, so they never had an effect): move them to the top-level `locale` / `labels`.
669
+ - **`DirectoryEntryItemProps` gains two required fields**, `entryKindDirectory` / `entryKindFile` (the resolved kind
670
+ words; take them from `resolveDirectoryTreeLabels(locale, labels)`). Only code that builds this exported type
671
+ itself is affected.
672
+ - **`locale` is not a formatting locale**: this package has no BCP 47 `formatLocale` axis. `locale` switches the UI
673
+ chrome language only; entry names, column headers / footers and `visual.ariaLabel` remain your content.
674
+
482
675
  ## TypeScript Support
483
676
 
484
677
  This package is written in TypeScript and provides comprehensive type definitions. All components and hooks are fully typed for the best development experience.
@@ -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, }: 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"),Tt=require("@aiquants/virtualscroll"),A=require("tailwind-merge"),D=require("@phosphor-icons/react");function sr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const oe=sr(l);var We={exports:{}},Ce={};var Pt;function ar(){if(Pt)return Ce;Pt=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function s(n,r,i){var u=null;if(i!==void 0&&(u=""+i),r.key!==void 0&&(u=""+r.key),"key"in r){i={};for(var f in r)f!=="key"&&(i[f]=r[f])}else i=r;return r=i.ref,{$$typeof:e,type:n,key:u,ref:r!==void 0?r:null,props:i}}return Ce.Fragment=t,Ce.jsx=s,Ce.jsxs=s,Ce}var je={};var _t;function or(){return _t||(_t=1,process.env.NODE_ENV!=="production"&&(function(){function e(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===H?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case b:return"Fragment";case j:return"Profiler";case S:return"StrictMode";case $:return"Suspense";case T:return"SuspenseList";case ee: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 R:return(a._context.displayName||"Context")+".Consumer";case y:var h=a.render;return a=a.displayName,a||(a=h.displayName||h.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case L:return h=a.displayName||null,h!==null?h:e(a.type)||"Memo";case Q:h=a._payload,a=a._init;try{return e(a(h))}catch{}}return null}function t(a){return""+a}function s(a){try{t(a);var h=!1}catch{h=!0}if(h){h=console;var M=h.error,F=typeof Symbol=="function"&&Symbol.toStringTag&&a[Symbol.toStringTag]||a.constructor.name||"Object";return M.call(h,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",F),t(a)}}function n(a){if(a===b)return"<>";if(typeof a=="object"&&a!==null&&a.$$typeof===Q)return"<...>";try{var h=e(a);return h?"<"+h+">":"<...>"}catch{return"<...>"}}function r(){var a=q.A;return a===null?null:a.getOwner()}function i(){return Error("react-stack-top-frame")}function u(a){if(te.call(a,"key")){var h=Object.getOwnPropertyDescriptor(a,"key").get;if(h&&h.isReactWarning)return!1}return a.key!==void 0}function f(a,h){function M(){z||(z=!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)",h))}M.isReactWarning=!0,Object.defineProperty(a,"key",{get:M,configurable:!0})}function C(){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 v(a,h,M,F,ne,le){var x=M.ref;return a={$$typeof:I,type:a,key:h,props:M,_owner:F},(x!==void 0?x:null)!==null?Object.defineProperty(a,"ref",{enumerable:!1,get:C}):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:ne}),Object.defineProperty(a,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:le}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a}function d(a,h,M,F,ne,le){var x=h.children;if(x!==void 0)if(F)if(N(x)){for(F=0;F<x.length;F++)p(x[F]);Object.freeze&&Object.freeze(x)}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 p(x);if(te.call(h,"key")){x=e(a);var Y=Object.keys(h).filter(function(U){return U!=="key"});F=0<Y.length?"{key: someKey, "+Y.join(": ..., ")+": ...}":"{key: someKey}",P[x+F]||(Y=0<Y.length?"{"+Y.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} />`,F,x,Y,x),P[x+F]=!0)}if(x=null,M!==void 0&&(s(M),x=""+M),u(h)&&(s(h.key),x=""+h.key),"key"in h){M={};for(var W in h)W!=="key"&&(M[W]=h[W])}else M=h;return x&&f(M,typeof a=="function"?a.displayName||a.name||"Unknown":a),v(a,x,M,r(),ne,le)}function p(a){w(a)?a._store&&(a._store.validated=1):typeof a=="object"&&a!==null&&a.$$typeof===Q&&(a._payload.status==="fulfilled"?w(a._payload.value)&&a._payload.value._store&&(a._payload.value._store.validated=1):a._store&&(a._store.validated=1))}function w(a){return typeof a=="object"&&a!==null&&a.$$typeof===I}var k=l,I=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),E=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),$=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),ee=Symbol.for("react.activity"),H=Symbol.for("react.client.reference"),q=k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=Object.prototype.hasOwnProperty,N=Array.isArray,G=console.createTask?console.createTask:function(){return null};k={react_stack_bottom_frame:function(a){return a()}};var z,V={},ie=k.react_stack_bottom_frame.bind(k,i)(),ce=G(n(i)),P={};je.Fragment=b,je.jsx=function(a,h,M){var F=1e4>q.recentlyCreatedOwnerStacks++;return d(a,h,M,!1,F?Error("react-stack-top-frame"):ie,F?G(n(a)):ce)},je.jsxs=function(a,h,M){var F=1e4>q.recentlyCreatedOwnerStacks++;return d(a,h,M,!0,F?Error("react-stack-top-frame"):ie,F?G(n(a)):ce)}})()),je}var At;function lr(){return At||(At=1,process.env.NODE_ENV==="production"?We.exports=ar():We.exports=or()),We.exports}var c=lr();function ir({title:e,titleId:t,...s},n){return oe.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},s),e?oe.createElement("title",{id:t},e):null,oe.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 cr=oe.forwardRef(ir);function ur({title:e,titleId:t,...s},n){return oe.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},s),e?oe.createElement("title",{id:t},e):null,oe.createElement("path",{fillRule:"evenodd",d:"M16.28 11.47a.75.75 0 0 1 0 1.06l-7.5 7.5a.75.75 0 0 1-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 0 1 1.06-1.06l7.5 7.5Z",clipRule:"evenodd"}))}const dr=oe.forwardRef(ur);function fr({title:e,titleId:t,...s},n){return oe.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},s),e?oe.createElement("title",{id:t},e):null,oe.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 mr=oe.forwardRef(fr),Be=18,ze=12,Ft=8,O={container:"directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"opacity-70",entry:"directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",entryHover:A.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:A.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:A.twMerge("directory-tree-entry--item-selected bg-blue-400/20 shadow-[0_0_0_1px_rgba(59,130,246,0.3)]","dark:bg-blue-400/25 dark:shadow-[0_0_0_1px_rgba(96,165,250,0.4)]"),expandIcon:A.twMerge("directory-tree-expand-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),expandIconSelected:A.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:A.twMerge("directory-tree-type-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),typeIconSelected:A.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:A.twMerge("directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 text-xs font-normal","text-gray-700","dark:text-gray-200"),nameDirectory:"directory-tree-name--directory font-medium",nameSelected:A.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},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()},$t=({isDirectory:e,isExpanded:t,showExpandIcons:s,useCanvasExpandIcons:n,expandIconSize:r})=>{const i=r?{width:r,height:r}:void 0,u=r?"":"h-4 w-4";return!(s&&e)||n?c.jsx("span",{className:u,style:i,"aria-hidden":"true"}):t?c.jsx(cr,{className:u,style:i}):c.jsx(dr,{className:u,style:i})},tt=(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(r=>tt(r,t)).filter(Boolean);return n.length?n: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},hr=(e,t,s)=>{const n=(t||(s?ve(s):"")).toLowerCase(),r=(e||"").toLowerCase();if(r&&r!=="application/octet-stream"){if(r==="text/markdown"||r==="text/x-markdown")return c.jsx(D.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(r==="application/pdf")return c.jsx(D.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(r.includes("excel")||r.includes("spreadsheet")||r.includes("google-apps.spreadsheet"))return c.jsx(D.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(r==="text/csv"||r==="text/tab-separated-values")return c.jsx(D.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(r.includes("word")||r.includes("msword")||r.includes("wordprocessingml")||r.includes("google-apps.document")||r==="application/rtf")return c.jsx(D.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(r.includes("powerpoint")||r.includes("presentation")||r.includes("google-apps.presentation"))return c.jsx(D.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(r.startsWith("image/"))return c.jsx(D.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(r.startsWith("audio/"))return c.jsx(D.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(r.startsWith("video/"))return c.jsx(D.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(r.includes("zip")||r.includes("tar")||r.includes("compressed")||r.includes("archive"))return c.jsx(D.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(r==="application/json"||r.includes("javascript")||r.includes("typescript")||r.includes("xml")||r.startsWith("text/html")||r.startsWith("text/css")||r.includes("x-python")||r.includes("x-sh")||r.includes("x-go")||r.includes("x-rust"))return c.jsx(D.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(r.startsWith("text/"))return c.jsx(D.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}if(n){if(n==="md"||n==="markdown"||n==="mdx")return c.jsx(D.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(n==="pdf")return c.jsx(D.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(["xls","xlsx","xlsm","xlsb","ods"].includes(n))return c.jsx(D.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["csv","tsv"].includes(n))return c.jsx(D.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["doc","docx","rtf","odt"].includes(n))return c.jsx(D.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(["ppt","pptx","odp"].includes(n))return c.jsx(D.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 c.jsx(D.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 c.jsx(D.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(["mp3","wav","ogg","m4a","flac","aac","wma"].includes(n))return c.jsx(D.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(["mp4","webm","mov","avi","mkv","wmv","flv"].includes(n))return c.jsx(D.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(["zip","tar","gz","7z","rar","tgz","bz2"].includes(n))return c.jsx(D.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(["txt","log"].includes(n))return c.jsx(D.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}return c.jsx(D.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"})},Ht=(e,t)=>{const{entry:s,isDirectory:n,isExpanded:r,extension:i,mimeType:u}=e;let f;const C=u||s.mimeType;return s.icon!==void 0?f=s.icon:n?f=r&&t?.directoryExpanded||t?.directory||c.jsx(mr,{className:"h-4 w-4"}):i&&t?.fileByExtension?.[i]?f=t.fileByExtension[i]:f=t?.file||hr(C,i,s.name),tt(typeof f=="function"?f(e):f,s.absolutePath)},pr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Wt=e=>{if(!e)return;const t=Object.entries(e).filter(([,s])=>s!=null);if(t.length!==0)return Object.fromEntries(t.map(([s,n])=>[`data-${pr(s)}`,String(n)]))},yr=500,Bt=({entry:e,isDirectory:t,isExpanded:s,isItemSelected:n,selectionMode:r,onSelectionChange:i,onEntryClick:u,toggleDirectory:f,onToggleDirectoryRecursive:C})=>{const v=l.useRef(null);return l.useEffect(()=>()=>{v.current&&window.clearTimeout(v.current)},[]),l.useCallback(d=>{d.stopPropagation(),r!=="none"&&!t&&i&&i(e,!n);let p=!1;u({entry:e,isDirectory:t,isExpanded:s,preventDefault:()=>{p=!0}}),!(!t||p)&&(v.current?(window.clearTimeout(v.current),v.current=null,C(e)):v.current=window.setTimeout(()=>{f(e.absolutePath),v.current=null},yr))},[t,e,s,C,f,u,r,i,n])},zt=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",Dt=(e,t)=>e.children!==void 0&&t(e.absolutePath),Yt=(e,t)=>({width:e,gridTemplateColumns:t}),Gt=l.memo(({entry:e,indentLevel:t,positionInSet:s,setSize:n,rowIndex:r,isSelectedForAria:i,rowHeight:u,isDirOpen:f,columns:C,numericTemplate:v,numericTotal:d,nameWidth:p,rowClassName:w,selection:{onEntryClick:k,selectedPath:I,mode:m="none",selectedItems:b,onSelectionChange:S},expansion:{toggleDirectory:j,onToggleDirectoryRecursive:R},visual:{iconOverrides:E,showExpandIcons:y=!0,showDirectoryIcons:$=!0,showFileIcons:T=!0,useCanvasExpandIcons:L=!1,expandIconSize:Q,indentSize:ee=ze,highlightStyles:H}})=>{const[q,te]=l.useState(!1),N=e.children!==void 0,G=N&&f(e.absolutePath),z=e.absolutePath===I,V=!N&&!!b?.has(e.absolutePath),ie=N?void 0:ve(e.name)||ve(e.relativePath)||ve(e.absolutePath),ce=Bt({entry:e,isDirectory:N,isExpanded:G,isItemSelected:V,selectionMode:m,onSelectionChange:S,onEntryClick:k,toggleDirectory:j,onToggleDirectoryRecursive:R}),P=q?H?.hoverClassName!==void 0?H.hoverClassName:O.entryHover:"",a=(()=>{if(N){if(z)return H?.directorySelectedClassName!==void 0?H.directorySelectedClassName:O.entrySelected}else if(z||V)return H?.itemSelectedClassName!==void 0?H.itemSelectedClassName:A.twMerge(z&&O.entrySelected,V&&O.entryItemSelected);return""})(),h=typeof w=="function"?w(e):w,M=A.twMerge("dt-grid-row cursor-pointer select-none",P,a,h,e.className),F=A.twMerge(O.expandIcon,(z||V)&&O.expandIconSelected),ne=A.twMerge(O.typeIcon,(z||V)&&O.typeIconSelected),le=A.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",N&&O.nameDirectory,(z||V)&&O.nameSelected),x=$t({isDirectory:N,isExpanded:G,showExpandIcons:y,useCanvasExpandIcons:L,expandIconSize:Q}),Y=(N?$:T)?Ht({entry:e,isDirectory:N,isExpanded:G,isSelected:z,isItemSelected:V,extension:ie,mimeType:e.mimeType},E):null,W={indentLevel:t,isDirectory:N,isExpanded:G},[U,...we]=C,fe=U?.render?U.render(e,W):e.label??e.name,ye={...q?H?.hoverStyle:{},...N&&z?H?.directorySelectedStyle:{},...!N&&(z||V)?H?.itemSelectedStyle:{}};return c.jsxs("div",{className:M,style:{height:u,...ye,...e.style},role:"row","aria-expanded":N?G:void 0,"aria-level":t+1,"aria-posinset":s,"aria-setsize":n,"aria-rowindex":r,"aria-selected":m==="none"?void 0:i,...Wt(e.data),"data-entry-type":N?"directory":"file","data-entry-expanded":N?String(G):void 0,"data-entry-selected":z?"true":void 0,"data-entry-item-selected":V?"true":void 0,onClick:ce,onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),onKeyDown:se=>se.key==="Enter"&&ce(se),tabIndex:0,children:[c.jsxs("div",{className:A.twMerge("dt-grid-name-cell",U?.className),role:"gridcell",style:{width:p,paddingLeft:Math.max(0,t*ee)},children:[(y||L)&&c.jsx("span",{className:F,children:x}),(N?$:T)&&c.jsx("span",{className:ne,children:Y}),c.jsx("span",{className:le,children:fe})]}),we.length>0&&c.jsx("div",{className:"dt-grid-numeric-viewport",children:c.jsx("div",{className:"dt-grid-numeric-track",style:Yt(d,v),children:we.map(se=>c.jsx("div",{className:A.twMerge("dt-grid-cell",zt(se.align),se.className),role:"gridcell",children:se.render?se.render(e,W):null},se.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const s=Dt(e.entry,e.isDirOpen),n=Dt(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===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.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});Gt.displayName="DirectoryTreeGridRow";const Vt=({kind:e,columns:t,numericTemplate:s,numericTotal:n,nameWidth:r,scrollBarWidth:i,className:u,nameContent:f,renderCell:C})=>{const[,...v]=t,d=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",p=e==="header"?"dt-grid-header":"dt-grid-footer",w=e==="header"?"columnheader":"gridcell";return c.jsxs("div",{className:A.twMerge(p,"text-gray-600 dark:text-gray-300",u),role:"row",children:[c.jsx("div",{className:A.twMerge(d,"px-1",t[0]?.className),role:w,style:{width:r},children:f}),v.length>0&&c.jsx("div",{className:"dt-grid-numeric-viewport",children:c.jsx("div",{className:"dt-grid-numeric-track",style:Yt(n,s),children:v.map(k=>c.jsx("div",{className:A.twMerge("dt-grid-cell",zt(k.align),k.className),role:w,children:C(k)},k.key))})}),c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:i},"aria-hidden":"true"})]})},br=({columns:e,className:t,...s})=>c.jsx(Vt,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...s}),Ot=(e,t)=>typeof e=="function"?e(t):e??null,gr=({columns:e,allEntries:t,className:s,...n})=>c.jsx(Vt,{kind:"footer",columns:e,className:s,nameContent:Ot(e[0]?.footer,t),renderCell:r=>Ot(r.footer,t),...n}),xr=240,Ut=96,Xt=12,rt=(e,t)=>{const s=e?.width;return typeof s=="number"&&Number.isFinite(s)&&s>0?s:t},vr=e=>e.slice(1).map(t=>`${rt(t,Ut)}px`).join(" "),wr=({measuredWidth:e,columns:t,scrollBarWidth:s=Xt})=>{const n=rt(t[0],xr),r=t.slice(1).reduce((C,v)=>C+rt(v,Ut),0),i=Number.isFinite(e)&&e>0?e:0,u=Math.max(0,i-n-Math.max(0,s)),f=Math.max(0,r-u);return{nameWidth:n,numericTotal:r,numericVisible:u,maxHScroll:f}},et=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,kr=e=>{const t=[],s=n=>{for(const r of n)t.push(r),r.children&&r.children.length>0&&s(r.children)};return s(e),t},Sr=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let n=0,r=s-1,i=0;for(;n<=r;){const u=n+r>>>1;e[u]<=t?(i=u,n=u+1):r=u-1}return i},Er=(e,t,s)=>{if(s<=0||e.length===0||t.length!==e.length+1)return null;const n=Sr(t,s),r=e[n];return r?{path:r.entry.absolutePath,offsetInViewport:s-t[n]}:null},Nr=(e,t,s)=>{if(t.length===0||s.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,s[n]+e.offsetInViewport);return null},Ir=(e,t,s)=>{const n=[];for(let r=t;r<s;r++){const i=e[r];if(!(!i||i.length===0))for(const u of i)n.push(u)}return n},Rr=(e,t,s)=>{const n=[];for(let r=t;r<s;r++){const i=e[r];if(!(!i||i.length===0))for(const u of i)n.push(u)}return n},Cr=(e,t,s,n)=>{const r=Math.max(1,Math.floor(t*n)),i=Math.max(1,Math.floor(s*n));(e.width!==r||e.height!==i)&&(e.width=r,e.height=i);const u=e.style;u.width!==`${t}px`&&(u.width=`${t}px`),u.height!==`${s}px`&&(u.height=`${s}px`)},jr=(e,t,s)=>{e.lineWidth=s,e.beginPath();for(const n of t)e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke()},Mr=(e,t)=>{const s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!s)return null;let n=s[1];n.length===3&&(n=n.split("").map(f=>f+f).join(""));const r=Number.parseInt(n.slice(0,2),16),i=Number.parseInt(n.slice(2,4),16),u=Number.parseInt(n.slice(4,6),16);return`rgba(${r}, ${i}, ${u}, ${t})`},Tr=(e,t,s,n)=>{if(t.length===0)return;const r=Mr(s,.14),i=e.strokeStyle,u=e.fillStyle,f=e.lineWidth,C=e.lineCap,v=e.lineJoin;e.strokeStyle=s,e.lineCap="round",e.lineJoin="round";for(const d of t){const p=n??d.size,w=Math.max(0,p/2),k=Math.max(1,Math.round(p*.08)),I=Math.max(1,Math.round(p*.14)),m=Math.max(0,w-k*.8),b=Math.max(0,m*.55);r&&(e.fillStyle=r,e.beginPath(),e.arc(d.centerX,d.centerY,m,0,Math.PI*2),e.fill()),e.lineWidth=k,e.beginPath(),e.arc(d.centerX,d.centerY,Math.max(0,w-k*.3),0,Math.PI*2),e.stroke(),e.lineWidth=I,e.beginPath(),e.moveTo(d.centerX-b,d.centerY),e.lineTo(d.centerX+b,d.centerY),e.stroke(),d.isExpanded||(e.beginPath(),e.moveTo(d.centerX,d.centerY-b),e.lineTo(d.centerX,d.centerY+b),e.stroke())}e.strokeStyle=i,e.fillStyle=u,e.lineWidth=f,e.lineCap=C,e.lineJoin=v},Jt=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u="#a0aec0",strokeWidth:f=1,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k})=>{const I=l.useRef(null),m=l.useRef(null),b=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u,strokeWidth:f,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k}),S=l.useCallback(()=>{m.current=null;const R=I.current;if(!R)return;const E=R.getContext("2d");if(!E)return;const y=b.current;if(y.width<=0||y.viewportHeight<=0){E.clearRect(0,0,R.width,R.height);return}const $=Number.isFinite(y.devicePixelRatio??NaN)?y.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;Cr(R,y.width,y.viewportHeight,$);const T=y.segmentsByItem.length,L=typeof y.renderStartIndex=="number"&&Number.isFinite(y.renderStartIndex)?Math.max(0,Math.floor(y.renderStartIndex)):Math.max(0,Math.floor(y.scrollPosition/y.itemHeight)),Q=Math.min(T,Math.ceil((y.scrollPosition+y.viewportHeight)/y.itemHeight)),ee=(()=>{if(typeof y.renderEndIndex=="number"&&Number.isFinite(y.renderEndIndex)){const N=Math.floor(y.renderEndIndex);return Math.max(Math.min(T,N+1),L)}return Math.max(Q,L)})(),H=(()=>{if(typeof y.lookaheadEndIndex=="number"&&Number.isFinite(y.lookaheadEndIndex)){const N=Math.floor(y.lookaheadEndIndex),G=Math.min(T,N+1);return Math.max(G,ee)}return Math.max(Q,ee)})(),q=Ir(y.segmentsByItem,L,H),te=Rr(y.glyphsByItem,L,H);E.save(),E.scale($,$),E.clearRect(0,0,y.width,y.viewportHeight),E.translate(0,-y.scrollPosition),E.strokeStyle=y.color,jr(E,q,y.strokeWidth),Tr(E,te,y.expandGlyphColor??y.color,y.expandGlyphSize),E.restore()},[]),j=l.useCallback(()=>{m.current===null&&(m.current=window.requestAnimationFrame(S))},[S]);return l.useEffect(()=>{b.current={segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u,strokeWidth:f,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k},j()},[e,t,s,n,r,i,u,f,C,v,d,p,w,k,j]),l.useEffect(()=>()=>{m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null)},[]),c.jsx("canvas",{ref:I,className:"pointer-events-none absolute top-0 left-0 z-0"})});Jt.displayName="TreeLineCanvas";const Pr={msOverflowStyle:"none",scrollbarWidth:"none"},_r=()=>{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))},Ar=(e,t,s,n,r)=>{const i=[],u=[];let f=0;const C=(v,d,p)=>{const w=r?[...v].sort(r):v;for(let k=0;k<w.length;k++){const I=w[k],m=k===w.length-1,b=[...p,m],S=I.children!==void 0,j=S&&t(I.absolutePath,I.relativePath);let R=d,E=b,y=p;n&&(R=d-1,E=b.slice(1),y=p.slice(1)),i.push({entry:I,indentLevel:R,depth:d,positionInSet:k+1,setSize:w.length,parentIsLast:E}),s&&(R>f&&(f=R),u.push({id:I.absolutePath,name:I.name,absolutePath:I.absolutePath,indentLevel:R,isLastChild:m,isDirectory:S,isExpanded:j,ancestorIsLast:[...y],hideLines:n&&d===0})),S&&j&&I.children&&C(I.children,d+1,b)}};return C(e,0,[]),{flatItems:i,lineItems:u,maxIndent:f}},Lt=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let n=0,r=s-1,i=0;for(;n<=r;){const u=n+r>>>1;e[u]<=t?(i=u,n=u+1):r=u-1}return i},Fr=(e,t,s,n,r,i)=>{const u=n?.renderStart??Math.max(0,Lt(i,r)),f=t>0?Lt(i,r+t)+s:u+s,C=e>0?Math.min(e-1,Math.max(u,f)):u,v=n?.renderEnd??C,d=e>0?Math.min(e-1,v+s):v;return{renderStart:u,renderEnd:v,lookaheadEnd:d}},Dr=(e,t,s,n,r,i)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const u=Array.from({length:e.length},()=>[]),f=Array.from({length:e.length},()=>[]),C=d=>r?typeof i=="number"&&Number.isFinite(i)&&i>0?i:Math.max(8,Math.min(n*.9,d*.7)):0,v=3;for(let d=0;d<e.length;d++){const p=e[d];if(p.hideLines)continue;const w=[],k=t[d]??0,I=s[d]??0,m=I+k/2,b=C(k),S=b>0?b/2+2:n/1.5;for(let E=0;E<p.indentLevel;E++){if(p.ancestorIsLast[E]??!1)continue;let $=!1;for(let T=d;T<e.length;T++){const L=e[T];if(L.indentLevel>E&&L.ancestorIsLast.length>E&&!L.ancestorIsLast[E]){$=!0;break}if(T>d&&L.indentLevel===E)break}if($){const T=E*n+n/2+v;w.push({key:`${p.id}-ancestor-${E}`,x1:T,y1:I,x2:T,y2:I+k,itemIndex:d})}}const j=p.indentLevel*n,R=j+n/2+v;if(p.isDirectory?w.push({key:`${p.id}-connector-top`,x1:R,y1:I,x2:R,y2:m-S,itemIndex:d}):w.push({key:`${p.id}-connector-top`,x1:R,y1:I,x2:R,y2:m,itemIndex:d}),!p.isDirectory&&p.isLastChild&&w.push({key:`${p.id}-connector-horizontal`,x1:R,y1:m,x2:j+n+v,y2:m,itemIndex:d}),p.isLastChild||(p.isDirectory?w.push({key:`${p.id}-connector-bottom`,x1:R,y1:m+S,x2:R,y2:I+k,itemIndex:d}):w.push({key:`${p.id}-connector-bottom`,x1:R,y1:m,x2:R,y2:I+k,itemIndex:d})),u[d]=w,r&&p.isDirectory){const E=b,y=R,$=m;f[d]=[{key:`${p.id}-glyph`,itemIndex:d,centerX:y,centerY:$,size:E,isExpanded:p.isExpanded}]}}return{segmentsByItem:u,glyphsByItem:f}},nt=l.memo(({entry:e,indentLevel:t,depth:s,positionInSet:n,setSize:r,isSelectedForAria:i,flatIndex:u,isActive:f,registerRowRef:C,onNavigationKeyDown:v,rowHeight:d,isDirOpen:p,parentIsLast:w,renderChildren:k=!0,expansion:{toggleDirectory:I,onToggleDirectoryRecursive:m},selection:{onEntryClick:b,selectedPath:S,mode:j="none",selectedItems:R,onSelectionChange:E},visual:{iconOverrides:y,showExpandIcons:$=!0,showDirectoryIcons:T=!0,showFileIcons:L=!0,useCanvasExpandIcons:Q=!1,expandIconSize:ee,typeIconSize:H,fontSize:q,indentSize:te=ze,highlightStyles:N,entryClassName:G,entryStyle:z,nameClassName:V,nameStyle:ie,directoryNameClassName:ce,directoryNameStyle:P,fileNameClassName:a,fileNameStyle:h}})=>{const[M,F]=l.useState(null),[ne,le]=l.useState(!1),x=e.children!==void 0,Y=x&&p(e.absolutePath),W=e.absolutePath===S,U=!x&&R?.has(e.absolutePath),we=x?void 0:ve(e.name)||ve(e.relativePath)||ve(e.absolutePath);l.useEffect(()=>{F(Y&&e.children?e.children:null)},[Y,e.children]);const fe=Bt({entry:e,isDirectory:x,isExpanded:Y,isItemSelected:!!U,selectionMode:j,onSelectionChange:E,onEntryClick:b,toggleDirectory:I,onToggleDirectoryRecursive:m}),ye=ne?N?.hoverClassName!==void 0?N.hoverClassName:O.entryHover:"",se=(()=>{if(x){if(W)return N?.directorySelectedClassName!==void 0?N.directorySelectedClassName:O.entrySelected}else if(W||U)return N?.itemSelectedClassName!==void 0?N.itemSelectedClassName:A.twMerge(W&&O.entrySelected,U&&O.entryItemSelected);return""})(),Ye=A.twMerge(O.entry,ye,se,G,e.className),ke=A.twMerge(O.expandIcon,(W||U)&&O.expandIconSelected),Me=A.twMerge(O.typeIcon,(W||U)&&O.typeIconSelected),Te=A.twMerge(O.name,V,x&&O.nameDirectory,x&&ce,!x&&a,(W||U)&&O.nameSelected),Pe=$t({isDirectory:x,isExpanded:Y,showExpandIcons:$,useCanvasExpandIcons:Q,expandIconSize:ee}),_e=(x?T:L)?Ht({entry:e,isDirectory:x,isExpanded:Y,isSelected:W,isItemSelected:!!U,extension:we,mimeType:e.mimeType},y):null,Ae={...ne?N?.hoverStyle:{},...x&&W?N?.directorySelectedStyle:{},...!x&&(W||U)?N?.itemSelectedStyle:{}},me=Wt(e.data),Fe=H?{width:H,height:H}:void 0,Ie=q?{fontSize:typeof q=="number"?`${q}px`:q}:void 0;return c.jsxs(l.Fragment,{children:[c.jsxs("div",{className:Ye,style:{paddingLeft:`${Math.max(0,t*te)}px`,transform:t<0?`translateX(${t*te}px)`:void 0,width:t<0?`calc(100% + ${Math.abs(t*te)}px)`:void 0,height:`${d}px`,...Ie,...Ae,...z,...e.style},...me,"data-entry-type":x?"directory":"file","data-entry-expanded":x?String(Y):void 0,"data-entry-selected":W?"true":void 0,"data-entry-item-selected":U?"true":void 0,onClick:fe,onMouseEnter:()=>le(!0),onMouseLeave:()=>le(!1),ref:re=>C(u,re),onKeyDown:re=>{if(re.key==="Enter"||re.key===" "){re.preventDefault(),fe(re);return}v(re,u)},tabIndex:f?0:-1,role:"treeitem","aria-expanded":x?Y:void 0,"aria-level":s+1,"aria-posinset":n,"aria-setsize":r,"aria-selected":j==="none"?void 0:i,"aria-label":`${e.name} (${x?"directory":"file"})`,children:[($||Q)&&c.jsx("span",{className:ke,children:Pe}),(x?T:L)&&c.jsx("span",{className:Me,style:Fe,children:_e}),c.jsx("span",{className:Te,style:{...Ie,...ie,...x?P:h},"data-entry-type":x?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),Y&&M&&k&&c.jsx("fieldset",{children:M.map((re,Re)=>c.jsx(nt,{entry:re,indentLevel:t+1,depth:s+1,positionInSet:Re+1,setSize:M.length,isSelectedForAria:!!R?.has(re.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:C,onNavigationKeyDown:v,rowHeight:d,isDirOpen:p,parentIsLast:[...w,Re===M.length-1],expansion:{toggleDirectory:I,onToggleDirectoryRecursive:m},selection:{onEntryClick:b,selectedPath:S,mode:j,selectedItems:R,onSelectionChange:E},visual:{iconOverrides:y,showExpandIcons:$,showDirectoryIcons:T,showFileIcons:L,useCanvasExpandIcons:Q,expandIconSize:ee,highlightStyles:N,entryClassName:G,entryStyle:z,nameClassName:V,nameStyle:ie,directoryNameClassName:ce,directoryNameStyle:P,fileNameClassName:a,fileNameStyle:h}},re.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const s=e.entry.children!==void 0,n=t.entry.children!==void 0,r=s&&e.isDirOpen(e.entry.absolutePath),i=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&&r===i&&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((u,f)=>u===t.parentIsLast[f])});nt.displayName="DirectoryEntryItem";const qt=e=>{const t=[];if(e.children)for(const s of e.children)s.type==="directory"&&(t.push(s.absolutePath),t.push(...qt(s)));return t},Or=({entries:e,expansion:{toggle:t,isExpanded:s,expandMultiple:n,collapseMultiple:r,isPending:i,alwaysExpanded:u=!1,doubleClickAction:f="recursive"},selection:{onEntryClick:C,selectedPath:v,mode:d="none",selectedItems:p,onSelectionChange:w},visual:{className:k,style:I,ariaLabel:m,ariaLabelledBy:b,lineColor:S="#A0AEC0",showTreeLines:j=!0,showExpandIcons:R=!0,showDirectoryIcons:E=!0,showFileIcons:y=!0,iconOverrides:$,expandIconSize:T,itemHeight:L=Be,removeRootIndent:Q=!1,highlightStyles:ee,entryClassName:H,entryStyle:q,nameClassName:te,nameStyle:N,directoryNameClassName:G,directoryNameStyle:z,fileNameClassName:V,fileNameStyle:ie}={},virtualScroll:ce,grid:P,sort:a})=>{const h=P!==void 0,[M,F]=l.useState(!1),ne=l.useRef(null),le=l.useRef(null),x=l.useRef(null),[Y,W]=l.useState(0),[U,we]=l.useState(0),[fe,ye]=l.useState(0),[se,Ye]=l.useState(null),{overscanCount:ke=15,className:Me,background:Te,onScroll:Pe,onRangeChange:_e,initialScrollIndex:Ae,initialScrollOffset:me,initialScrollAnchor:Fe,callbackThrottleMs:Ie=5,contentInsets:re,onItemFocus:Re,viewportHeightOverride:ae,scrollBarOptions:Ge,behaviorOptions:st,preserveScrollAnchor:at=!1,getItemKey:Zt,testId:ot,contentProps:Ve}=ce??{},lt=l.useMemo(()=>h?{role:"rowgroup",...Ve}:Ve,[h,Ve]),[De,it]=l.useState(typeof me=="number"?me:0),Ue=l.useRef(typeof me=="number"?me:0),ct=l.useCallback((o,g)=>{Ue.current=o,it(o),Pe?.(o,g)},[Pe]),ut=l.useCallback(o=>{const{renderingStartIndex:g,renderingEndIndex:_}=o;Ye(B=>B&&B.renderStart===g&&B.renderEnd===_?B:{renderStart:g,renderEnd:_}),_e?.(o)},[_e]);l.useEffect(()=>{F(!0),_r()},[]),l.useEffect(()=>{const o=ne.current,g=h?le.current:o,_=()=>{if(o){const X=o.clientWidth;we(Z=>Math.abs(Z-X)>1?X:Z)}if(typeof ae=="number")W(X=>Math.abs(X-ae)>1?ae:X);else if(g){const X=g.clientHeight;W(Z=>Math.abs(Z-X)>1?X:Z)}};if(!(o||g))return W(0);_();const B=new ResizeObserver(_);return o&&B.observe(o),g&&g!==o&&B.observe(g),()=>B.disconnect()},[ae,h]);const Se=typeof ae=="number"?ae:Y,ue=l.useCallback(o=>u||(M?s(o):!1),[M,s,u]),dt=A.twMerge(O.container,i&&O.containerPending,k),ft=l.useMemo(()=>({...Pr,...I??{},...typeof ae=="number"?{height:ae,minHeight:ae}:{}}),[I,ae]),Xe=l.useCallback((o,g)=>{const _=[o.absolutePath,...qt(o)],B=g||f;if(_.every(de=>ue(de)))return r(_);if(_.every(de=>!ue(de))||B==="recursive")return n(_);if(B==="toggle")return r(_);console.warn(`[DirectoryTree] Unknown double click action: ${B}. No action taken.`)},[ue,n,r,f]),mt=h?!1:Q,{flatItems:be,lineItems:Je,maxIndent:ht}=l.useMemo(()=>Ar(e,ue,j,mt,a),[e,ue,j,mt,a]),J=l.useMemo(()=>be.map((o,g)=>{const _=typeof L=="function"?L(o.entry,g):L;return{...o,rowHeight:Number.isFinite(_)&&_>0?_:Be}}),[be,L]),he=l.useMemo(()=>J.map(o=>o.rowHeight),[J]),ge=l.useMemo(()=>{const o=new Array(he.length+1);o[0]=0;for(let g=0;g<he.length;g++)o[g+1]=o[g]+he[g];return o},[he]),pt=l.useCallback(o=>J[o]?.rowHeight??Be,[J]),Kt=l.useCallback(o=>J[o]?.entry.absolutePath??o,[J]),yt=Zt??Kt,bt=l.useRef(be);bt.current=be;const gt=l.useRef(ue);gt.current=ue;const qe=l.useRef(t);qe.current=t;const[xt,vt]=l.useState(0),Ze=l.useRef(new Map),Ke=l.useRef(null),wt=l.useCallback((o,g)=>{g?(Ze.current.set(o,g),Ke.current===o&&(Ke.current=null,g.focus())):Ze.current.delete(o)},[]),xe=l.useCallback(o=>{vt(o);const g=Ze.current.get(o);if(g){g.focus();return}Ke.current=o,x.current?.scrollToIndex(o)},[]);l.useEffect(()=>{vt(o=>be.length===0?0:Math.min(o,be.length-1))},[be.length]);const kt=l.useCallback((o,g)=>{const _=bt.current,B=_.length-1;if(B<0)return;const X=_[g],Z=X?.entry.children!==void 0,de=Z&&gt.current(X.entry.absolutePath);switch(o.key){case"ArrowDown":o.preventDefault(),xe(Math.min(g+1,B));break;case"ArrowUp":o.preventDefault(),xe(Math.max(g-1,0));break;case"Home":o.preventDefault(),xe(0);break;case"End":o.preventDefault(),xe(B);break;case"ArrowRight":o.preventDefault(),Z&&!de?qe.current(X.entry.absolutePath):Z&&g<B&&xe(g+1);break;case"ArrowLeft":{if(o.preventDefault(),Z&&de){qe.current(X.entry.absolutePath);break}const nr=X?.depth??0;for(let He=g-1;He>=0;He--)if(_[He].depth<nr){xe(He);break}break}}},[xe]),Oe=l.useMemo(()=>!j||Je.length===0?{segmentsByItem:[],glyphsByItem:[]}:Dr(Je,he,ge,ze,j,T??Ft),[Je,he,ge,j,T]),Le=l.useMemo(()=>!j||e.length===0?0:(ht+2)*ze,[e.length,ht,j]),{renderStart:St,renderEnd:Et,lookaheadEnd:Nt}=l.useMemo(()=>Fr(J.length,Se,ke,se,De,ge),[J.length,Se,ke,se,De,ge]),Qe=l.useMemo(()=>!j||Le<=0||Se<=0||Oe.segmentsByItem.length===0?null:c.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:c.jsx("div",{className:"absolute top-0 left-0",style:{width:Le,height:Se},children:c.jsx(Jt,{segmentsByItem:Oe.segmentsByItem,glyphsByItem:Oe.glyphsByItem,itemHeight:he[0]??Be,width:Le,viewportHeight:Se,scrollPosition:De,color:S,expandGlyphColor:S,expandGlyphSize:T??Ft,renderStartIndex:St,renderEndIndex:Et,lookaheadEndIndex:Nt})})}),[Le,Se,St,Et,Nt,De,Oe,S,j,T,he]),It=l.useCallback(o=>J[o],[J]),Rt=l.useRef(null);l.useLayoutEffect(()=>{const o=Rt.current;if(Rt.current={items:J,offsets:ge},!at||!o||o.items===J)return;const g=x.current,_=g?.getScrollPosition(),B=typeof _=="number"&&_>=0?_:Ue.current,X=Er(o.items,o.offsets,B);if(!X)return;const Z=Nr(X,J,ge);if(Z===null||Math.abs(Z-B)<1)return;const de=g?g.scrollTo(Z):Z;Ue.current=de,it(de)},[J,ge,at]);const pe=P?.columns,Ee=P?.scrollBarWidth??Ge?.width??Xt,K=l.useMemo(()=>pe?wr({measuredWidth:U,columns:pe,scrollBarWidth:Ee}):null,[pe,U,Ee]),$e=l.useMemo(()=>pe?vr(pe):"",[pe]),Qt=l.useMemo(()=>P?.showFooter&&pe?kr(e):[],[P?.showFooter,pe,e]),Ne=K?.maxHScroll??0;l.useEffect(()=>{ye(o=>et(o,Ne))},[Ne]);const Ct=l.useCallback(o=>ye(g=>et(g+o,Ne)),[Ne]),jt=l.useMemo(()=>({iconOverrides:$,showExpandIcons:R,showDirectoryIcons:E,showFileIcons:y,useCanvasExpandIcons:j,expandIconSize:T,highlightStyles:ee}),[$,R,E,y,j,T,ee]),Mt=l.useMemo(()=>c.jsx(Tt.VirtualScroll,{ref:x,itemCount:J.length,getItem:It,getItemHeight:pt,getItemKey:yt,testId:ot,contentProps:lt,viewportSize:typeof ae=="number"?ae:void 0,overscanCount:ke,onScroll:ct,onRangeChange:ut,className:Me,onWheelHorizontal:h?Ct:void 0,background:c.jsxs(c.Fragment,{children:[h&&K?c.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:K.nameWidth},"aria-hidden":"true",children:Qe}):Qe,Te]}),initialScrollIndex:Ae,initialScrollOffset:me,initialScrollAnchor:Fe,onItemFocus:Re,callbackThrottleMs:Ie,contentInsets:re,scrollBarOptions:Ge,behaviorOptions:st,children:(o,g)=>o?h&&P&&K?c.jsx(Gt,{entry:o.entry,indentLevel:o.indentLevel,positionInSet:o.positionInSet,setSize:o.setSize,rowIndex:g+(P.showHeader??!0?2:1),isSelectedForAria:!!p?.has(o.entry.absolutePath),rowHeight:o.rowHeight,isDirOpen:ue,columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,rowClassName:P.rowClassName,selection:{onEntryClick:C,selectedPath:v??null,mode:d,selectedItems:p,onSelectionChange:w},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Xe},visual:jt},o.entry.absolutePath):c.jsx(nt,{entry:o.entry,indentLevel:o.indentLevel,depth:o.depth,positionInSet:o.positionInSet,setSize:o.setSize,isSelectedForAria:!!p?.has(o.entry.absolutePath),flatIndex:g,isActive:g===xt,registerRowRef:wt,onNavigationKeyDown:kt,rowHeight:o.rowHeight,isDirOpen:ue,parentIsLast:o.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Xe},selection:{onEntryClick:C,selectedPath:v??null,mode:d,selectedItems:p,onSelectionChange:w},visual:{iconOverrides:$,showExpandIcons:R,showDirectoryIcons:E,showFileIcons:y,useCanvasExpandIcons:j,expandIconSize:T,highlightStyles:ee,entryClassName:H,entryStyle:q,nameClassName:te,nameStyle:N,directoryNameClassName:G,directoryNameStyle:z,fileNameClassName:V,fileNameStyle:ie}},o.entry.absolutePath):null}),[J.length,It,pt,yt,ot,lt,xt,wt,kt,ae,ke,ct,ut,Me,h,Ct,K,Qe,Te,Ae,me,Fe,Re,Ie,re,Ge,st,P,$e,ue,C,v,d,p,w,t,Xe,jt,$,R,E,y,j,T,ee,H,q,te,N,G,z,V,ie]);if(!(P&&K))return c.jsx("div",{ref:ne,className:dt,style:ft,role:"tree","aria-label":b?void 0:m,"aria-labelledby":b,"aria-multiselectable":d==="multiple"?!0:void 0,children:Mt});const er=P.showHeader??!0,tr=P.showFooter??!1,rr={...ft,"--dt-hscroll":`${fe}px`};return c.jsxs("div",{ref:ne,className:A.twMerge(dt,"dt-grid"),style:rr,role:"treegrid","aria-label":b?void 0:m,"aria-labelledby":b,"aria-multiselectable":d==="multiple"?!0:void 0,"aria-rowcount":J.length+(P.showHeader??!0?1:0),children:[er&&c.jsx("div",{role:"rowgroup",children:c.jsx(br,{columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,scrollBarWidth:Ee,className:P.headerClassName})}),c.jsx("div",{ref:le,className:"dt-grid-body",children:Mt}),Ne>0&&c.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:K.nameWidth},"aria-hidden":"true"}),c.jsx(Tt.ScrollBar,{horizontal:!0,contentSize:K.numericTotal,viewportSize:K.numericVisible,scrollPosition:fe,scrollBarWidth:Ee,onScroll:o=>{const g=typeof o=="function"?o(fe):o,_=et(g,Ne);return ye(_),_}}),c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Ee},"aria-hidden":"true"})]}),tr&&c.jsx("div",{role:"rowgroup",children:c.jsx(gr,{columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,scrollBarWidth:Ee,allEntries:Qt,className:P.footerClassName})})]})},Lr=({initialExpanded:e=new Set,storageKey:t}={})=>{const[s,n]=l.useTransition(),[r,i]=l.useState(()=>{if(typeof window<"u"&&t)try{const m=window.localStorage.getItem(t);if(m){const b=JSON.parse(m);return new Set(b)}}catch(m){console.error("[useDirectoryTreeState] Error reading from localStorage",m)}return e}),u=l.useCallback(m=>{n(()=>{i(b=>{const S=new Set(b);return m(S),S})})},[]),f=l.useCallback((m,b)=>{u(S=>{for(const j of m)b(S,j)})},[u]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(r)))}catch(m){console.warn(`Error setting localStorage key "${t}":`,m)}},[r,t]);const C=l.useCallback(m=>{f([m],(b,S)=>{b.has(S)?b.delete(S):b.add(S)})},[f]),v=l.useCallback(m=>{f([m],(b,S)=>{b.add(S)})},[f]),d=l.useCallback(m=>{f([m],(b,S)=>{b.delete(S)})},[f]),p=l.useCallback(m=>{f(m,(b,S)=>{b.delete(S)})},[f]),w=l.useCallback(m=>{f(m,(b,S)=>{b.add(S)})},[f]),k=l.useCallback(()=>{u(m=>{m.clear()})},[u]),I=l.useCallback(m=>r.has(m),[r]);return{expanded:r,toggle:C,expand:v,collapse:d,collapseMultiple:p,expandMultiple:w,collapseAll:k,isExpanded:I,isPending:s}};exports.DirectoryTree=Or;exports.directoryTreeClasses=O;exports.useDirectoryTreeState=Lr;
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,3 +1,4 @@
1
1
  export { DirectoryTree, directoryTreeClasses } from "./DirectoryTree.tsx";
2
- export type { DirectoryEntry, DirectoryEntryComparator, DirectoryEntryItemProps, DirectoryTreeClickEvent, DirectoryTreeColumn, DirectoryTreeGrid, DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext, DirectoryTreeIconRenderer, DirectoryTreeProps, DirectoryTreeState, DirectoryTreeVirtualScrollOptions, HighlightStyles, ItemHeight, TreeLineItemInfo, TreeLineProps, UseDirectoryTreeStateProps, } from "./types.ts";
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, DirectoryTreeHandle, DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext, DirectoryTreeIconRenderer, DirectoryTreeProps, DirectoryTreeScrollAlign, DirectoryTreeScrollOptions, DirectoryTreeState, DirectoryTreeVirtualScrollOptions, HighlightStyles, ItemHeight, TreeLineItemInfo, TreeLineProps, UseDirectoryTreeStateProps, } from "./types.ts";
3
4
  export { useDirectoryTreeState } from "./useDirectoryTreeState.ts";