@aiquants/markdown-explorer 0.2.0 → 0.4.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/CHANGELOG.md +51 -0
- package/README.md +69 -11
- package/dist/ExplorerSplit-rUVsf5i-.cjs +1 -0
- package/dist/ExplorerSplit-uX2ojZe8.js +1479 -0
- package/dist/MultiLayout-8s7q3-Hm.js +919 -0
- package/dist/MultiLayout-ZK2V9nms.cjs +1 -0
- package/dist/NativeScrollBar-D3VDRQqf.js +59 -0
- package/dist/NativeScrollBar-DqkutcGb.cjs +1 -0
- package/dist/{TreeLayout-BoyFelK2.js → TreeLayout-C7ZNnaOr.js} +3 -3
- package/dist/{TreeLayout-CLWbWjOc.cjs → TreeLayout-DkTVgxxb.cjs} +1 -1
- package/dist/core/config.d.cts +15 -2
- package/dist/core/config.d.ts +15 -2
- package/dist/core/contracts.d.cts +8 -0
- package/dist/core/contracts.d.ts +8 -0
- package/dist/core/labels.d.cts +5 -1
- package/dist/core/labels.d.ts +5 -1
- package/dist/core/treeSettings.d.cts +4 -2
- package/dist/core/treeSettings.d.ts +4 -2
- package/dist/dataRoute-DYjYBiXF.cjs +1 -0
- package/dist/{dataRoute-Bkfwfp1R.js → dataRoute-Dl6xmEFs.js} +59 -53
- package/dist/index-CLe6vRXs.cjs +3 -0
- package/dist/{index-BfuAu2GV.js → index-Dv9lUZqD.js} +530 -503
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -22
- package/dist/location-2QZADLiv.cjs +1 -0
- package/dist/location-CaNtUswk.js +424 -0
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +1 -1
- package/dist/scrollBarGeometry-C46jBtmM.cjs +1 -0
- package/dist/scrollBarGeometry-DOBdGNV-.js +4 -0
- package/dist/server/anonymous.d.cts +2 -2
- package/dist/server/anonymous.d.ts +2 -2
- package/dist/server/errors.d.cts +1 -1
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/fileSystemSource.d.cts +1 -0
- package/dist/server/fileSystemSource.d.ts +1 -0
- package/dist/server/ports.d.cts +8 -1
- package/dist/server/ports.d.ts +8 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +763 -690
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/tapScrollCircle-C5DGI-0H.cjs +1 -0
- package/dist/tapScrollCircle-u4EXeLhx.js +6 -0
- package/docs/behavior/dom-hooks.md +3 -1
- package/docs/behavior/layout.md +2 -0
- package/docs/behavior/localization.md +1 -0
- package/docs/behavior/security.md +17 -3
- package/package.json +7 -7
- package/dist/ExplorerSplit-D2plJRRe.cjs +0 -1
- package/dist/ExplorerSplit-DB37U7Kh.js +0 -1362
- package/dist/MultiLayout-DCPDu1-l.js +0 -909
- package/dist/MultiLayout-UyWxs6Xy.cjs +0 -1
- package/dist/dataRoute-CKbdwkQ7.cjs +0 -1
- package/dist/index-Cx3-jSna.cjs +0 -3
- package/dist/location-Oo21lTyV.cjs +0 -1
- package/dist/location-fVl2R1ee.js +0 -395
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0 (2026-10-08)
|
|
4
|
+
|
|
5
|
+
### Breaking
|
|
6
|
+
|
|
7
|
+
- **Folder placement replaces "Folders first"**: `TreeSettings.directoriesFirst: boolean` is now `TreeSettings.folderPlacement: "mixed" | "first" | "last"` (`TreeFolderPlacement`, exported next to `TreeSortMode`), default `"mixed"` (the old `false`). `defaultTreeSettings.directoriesFirst` is now an unknown key and throws a `RangeError`: pass `folderPlacement: "first"` for `true`, and omit it (or pass `"mixed"`) for `false`.
|
|
8
|
+
The label key `settingDirectoriesFirst` is replaced by `settingFolderPlacement`, `folderPlacementMixed`, `folderPlacementFirst` and `folderPlacementLast`; a host overriding the old key gets the unknown-key `RangeError`. `createEntryComparator` takes `{ sortMode, folderPlacement }`.
|
|
9
|
+
A reader's stored settings keep working: a stored `directoriesFirst: true` is read as `"first"` and `false` as `"mixed"` (a stored `folderPlacement` wins); the storage format stays version 2 and the next change the reader makes stores only the new key.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **Folders last**: the settings menu row "Folders: Mixed / First / Last" (「フォルダーの位置: 混ぜる / 先に / 後に」) places the folders among, before or after the files, under any sort order.
|
|
14
|
+
- **Reveal the open document**: the reader's tree setting `revealDocument` (off by default; a host turns it on with `defaultTreeSettings: { revealDocument: true }`) opens the folders down to the open document — the tree view's document, or the multi view's maximized panel's, else the last opened — and keeps bringing its row into view while lazy folders load, on load, on a document link and on Back and Forward.
|
|
15
|
+
It ends at the reader's next input in the tree, the next document or source, Collapse all, the explorer being hidden, a failed listing, or a chain that has fully loaded without the row; the folders it opens are stored as the reader's expansion. A click in the tree never reveals again.
|
|
16
|
+
- The new optional source port `ancestors?(context, path, readPath, options): Promise<readonly string[] | null>` answers the folder row paths from the source's top level down to the document's parent, or `null`. `options` (`ExplorerAncestorsOptions`, exported from the server entry) is `{ maxDepth }`, the configuration's `revealDocument.maxDepth`, so a source whose climb costs requests can stop early.
|
|
17
|
+
The data route serves it as `GET <dataPath>/ancestors?source=&path=` behind the same authentication, deny rules and boundary checks as `children` (outside the source's boundary answers `null` without calling the host; a source without the port answers `not-found`), answers `null` for a chain longer than `maxDepth` without validating it, and validates every path of any other chain (acceptable, not denied, inside the boundary, not the document, no repeats): a malformed answer is logged as `ancestors` and answered `failed`. The browser's data client gains `ancestors(sourceId, path, signal)`.
|
|
18
|
+
- `createFileSystemSource` implements `ancestors` from path prefixes.
|
|
19
|
+
- The configuration's `revealDocument: { maxDepth? }` (`REVEAL_DOCUMENT_DEPTH_LIMITS`: 1–64, default 16) bounds the chain a reveal opens.
|
|
20
|
+
|
|
21
|
+
- **Tap-scroll circle on the document**: in the tree and single views, markdown and text documents get a pointer scroll bar with the tree's tap-scroll circle (`@aiquants/virtualscroll`'s `ScrollBar`, one shared circle setting), driving the viewer's native scroller through `@aiquants/markdown`'s `renderScrollBar` seam: the native vertical scrollbar is hidden, the bar is hidden from assistive technology and has no Tab stops, and keyboard, wheel and touch scrolling are unchanged. Multi-view panels have none (the panel's area scrolls).
|
|
22
|
+
The bar's module loads on first use; if it fails to load (a chunk gone after a redeploy) or the bar throws, the slot stays empty, the document keeps its native scroller and the failure is reported with `console.error`, instead of the error reaching the route.
|
|
23
|
+
- **Tap-scroll circle on every scroller that needs one**: the same bar and circle (one shared component) now also drive, in the tree and single views, a zoomed image's canvas (its native horizontal scrollbar stays), a medium's and a file view's stage and the failure view, each laid out with `@aiquants/markdown`'s `HostedScrollArea`; in the multi view, each panel's scroll area, maximized or not (drag-drop-panels' `renderPanelScrollArea`; the bar is exempt from panel drags). The stage gets the same bar without a circle (drag-drop-panels' `renderStageScrollBar`), in 8 px it adds to the inline end of its padding: a circle there would sit on the right-most panel next to that panel's own circle, and a gutter for it would cost the stage a column at common widths. A bar shows only while its content overflows. Inside a panel, the viewer and the image, media, file and failure views keep no bar of their own. Menus, popovers, nested horizontal scrollers and embedded frames (a PDF's included) get no circle.
|
|
24
|
+
Requires the `@aiquants/markdown` release that exports `HostedScrollArea` and the `@aiquants/drag-drop-panels` release with `renderPanelScrollArea`, `renderStageScrollBar`, `SCROLL_AREA_SELECTOR` and `NO_PANEL_DRAG_ATTRIBUTE`; the peer floors in the README follow those releases.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **The tree's reveal checks where the row landed**: bringing the open document's row into the tree's view (the shown document, and the `revealDocument` setting, in the tree and multi views) is finished only when the drawn row is measured wholly inside the tree's scroll window; until then it tries again once per frame, and a row already inside is never scrolled. It stops trying after 8 tries in a row that bring the row no nearer, and starts again when the rows or the tree's area change before the row has been seen inside; the reader's input in the tree, the next document and Collapse all still end it.
|
|
29
|
+
Before, a reveal ended as soon as the tree's `scrollToPath` answered `true`, which says only that the row is in the list, not where the scroll landed: with a source that lists every folder at once (all the folders down to the document open in one render), a host saw the document's row left about 13 rows below the window.
|
|
30
|
+
|
|
31
|
+
## 0.3.0 (2026-10-08)
|
|
32
|
+
|
|
33
|
+
### Breaking
|
|
34
|
+
|
|
35
|
+
- **`authenticate` takes a mode**: the port is `(request: Request, mode: ExplorerAuthenticationMode) => Promise<ExplorerAuthentication<P>>`, with `ExplorerAuthenticationMode = { readonly readOnly: boolean }` (exported from `@aiquants/markdown-explorer/server`).
|
|
36
|
+
The page loader and every data operation but `link-card` pass `{ readOnly: false }`; the `link-card` operation passes `{ readOnly: true }`, in which the host only reads the session: it never refreshes a token, writes no cookie and returns no `headers` (cards ask in the background, and a refreshed cookie arriving after a sign-out would sign the reader back in).
|
|
37
|
+
The explorer fails closed: a read-only authentication that carries any header is logged through `logger` (operation `authenticate`) and answered `failed` with `private, no-store` and none of its headers; a throw is logged and answered `failed` the same way (an `ExplorerError` answers its own reason unlogged and an aborted request is not logged, as on every operation), never with `Set-Cookie`. `anonymousAccess` returns no headers in any mode and needs no change.
|
|
38
|
+
- **`embeds.linkCardEndpoint` is replaced by `embeds.linkCards`**: `defineExplorerConfig({ embeds: { providers?, linkCards?, linkCardSize? } })`. `linkCards: true` points the cards at the data route's own `link-card` operation, so the host's separate card endpoint and its route go away; `linkCardEndpoint` is now an unknown key and throws a `RangeError`, as does a `linkCards` that is not a boolean.
|
|
39
|
+
The resolved `config.embeds` stays the `MarkdownEmbeds` of `@aiquants/markdown/embeds`: `linkCardEndpoint` is `<dataPath>/link-card` when link cards are on, otherwise `null`. A resolved configuration is no longer a valid input of `defineExplorerConfig`; `createMarkdownExplorer` still validates the frozen value it receives again (it reads the resolved embeds back into the option and requires the endpoint `dataPath` derives); a resolved `embeds` that carries the option-only `linkCards`, whatever its value, throws a `RangeError` instead of being overwritten by what the endpoint implies.
|
|
40
|
+
- **`@aiquants/markdown` 6.1**: the peer range becomes `^6.1.0` when the package is published (the handler `createLinkCardHandler` of `@aiquants/markdown/server` and `linkCardSize`). Node.js: `engines.node` stays `>=22.22.0`, which already covers the `>=22.13.0` `@aiquants/markdown` now declares for its handler.
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
- **The `link-card` operation**: with `embeds: { linkCards: true }`, `GET` and `HEAD` `<dataPath>/link-card?url=<href>` serve the cards through `@aiquants/markdown`'s `createLinkCardHandler`, created once in `createMarkdownExplorer` behind the read-only authentication. Its answers pass through unchanged: a card (`200`, `private, max-age=1800`), a link without a card (`204 No Content` with `X-Link-Card-Skip`: `private-network`, `forbidden-url`, `unreachable` or `not-html`) or the handler's own errors (`no-store`).
|
|
45
|
+
`signed-out` and `forbidden` mean no card. With link cards off, `link-card` answers `not-found` exactly as an unknown operation does. Internal addresses never become cards: the SSRF guards live in `@aiquants/markdown`, and neither the handler nor the explorer has an option to allow them. The endpoint is same-origin, so a content security policy needs no extra `connect-src`.
|
|
46
|
+
- **Card size**: `embeds.linkCardSize` (`compact`, `banner` or `full`, `LINK_CARD_SIZES` of `@aiquants/markdown/embeds`) passes into the resolved `MarkdownEmbeds.linkCardSize`; absent means `@aiquants/markdown`'s `banner`. An unknown size, or a size without `linkCards: true`, throws a `RangeError`.
|
|
47
|
+
- **Build check**: `verify-dist` proves both server builds keep `@aiquants/markdown/server` external and serve `link-card` through it (an internal address answered by the real handler's `204 private-network` after a read-only authentication, `not-found` with link cards off), and that no browser, storage or sanitizer-worker build reaches it.
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
|
|
51
|
+
- **No header value in the log**: `headers` that `Headers` cannot read are refused with a fixed message instead of the runtime's, which quoted the value (a session cookie or token), in the page loader and on every data operation, `link-card` included; and a `Response` that `authenticate` throws in a data request (React Router's `throw redirect(...)`) is logged as a `TypeError` naming its status instead of with its headers.
|
|
52
|
+
The answers do not change (`failed`, `private, no-store`, no `Set-Cookie`); unreadable `headers` of a data request are now logged as `authenticate` instead of under the operation's name.
|
|
53
|
+
|
|
3
54
|
## 0.2.0 (2026-10-07)
|
|
4
55
|
|
|
5
56
|
### Changed
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ reloaded document is announced, and a failed reload keeps the document under a n
|
|
|
19
19
|
announced too and stays until a newer copy of the document replaces or confirms it, the reader moves to another
|
|
20
20
|
document, or the next refresh starts.
|
|
21
21
|
A single-view (embedding) page never downloads the tree and multi-panel views, which load on demand.
|
|
22
|
-
- **Embeds and link cards** — with `embeds` in the configuration, a link alone in a paragraph shows its post or video from up to ten providers (YouTube, X, Instagram, Threads, TikTok, Bluesky, LinkedIn, Reddit, note and niconico) in a cross-origin frame, with no provider script in the page, or a card
|
|
22
|
+
- **Embeds and link cards** — with `embeds` in the configuration, a link alone in a paragraph shows its post or video from up to ten providers (YouTube, X, Instagram, Threads, TikTok, Bluesky, LinkedIn, Reddit, note and niconico) in a cross-origin frame, with no provider script in the page, or a link card the explorer's own data route reads (`{dataPath}/link-card`, through `@aiquants/markdown`'s link-card handler: internal addresses never become cards); the link itself always stays, under the frame, as the card or as the paragraph.
|
|
23
23
|
- **Secure by default** — Markdown HTML is sanitized on the server with an allow-list (scripts, event handlers, `srcdoc` and foreign iframes never reach the browser), and the document viewer applies its own on every render (a document keeps only the converter's class tokens, and ids only on headings, footnotes and `user-content-…` targets); document paths are validated, and deny rules hide environment files, keys and version-control metadata through up to three percent-decoding levels; tokens, principals, server paths and raw error messages never leave the server.
|
|
24
24
|
- **Multi-panel reading** — open documents as panels, rearrange them by dragging (on a touch screen or with a pen, after a long-press on a panel's header), with the move buttons in each panel's header, or with Alt + Shift + arrow keys, hide, maximize (Escape restores), and navigate inside a panel; the arrangement survives reloads, and a document reopened later returns to its column.
|
|
25
25
|
- **Accessible and localized** — named landmarks and controls, a keyboard-operable tree with one Tab stop on the shown document, keyboard-operable menus, panel headers and resize handle, polite announcements (spoken from the sheet while it is open), WCAG 2.2 contrast in light and dark; English (default) and Japanese built in — the tree's and the panel headers' strings included —, every string overridable.
|
|
@@ -28,7 +28,8 @@ A single-view (embedding) page never downloads the tree and multi-panel views, w
|
|
|
28
28
|
|
|
29
29
|
- React 19.2.7 or later and React Router 8 in framework mode (route modules with `loader` / `headers`).
|
|
30
30
|
- Node.js 22.22 or later (the floor React Router 8 declares). The package ships ES modules and CommonJS; the CommonJS entries load the ESM-only `react-router` through `require(esm)`.
|
|
31
|
-
- The peer packages, at these versions or later within the caret ranges the package declares: `@aiquants/markdown` ^6.
|
|
31
|
+
- The peer packages, at these versions or later within the caret ranges the package declares: `@aiquants/markdown` ^6.2.0 (document rendering; its math diagnostics, gantt sizing, embeds, link cards and their sizes, the React-free `@aiquants/markdown/embeds` the sanitizer worker loads, and the Node-only link-card handler of `@aiquants/markdown/server`, which needs Node.js 22.13 or later — below the explorer's own floor),
|
|
32
|
+
`@aiquants/directory-tree` ^4.1.1 (reveals of rows under the scroll bar's buttons), `@aiquants/drag-drop-panels` ^0.10.0, `@aiquants/resize-panels` ^2.1.0 (the source of each layout change, by which the tree pane's width is saved) and `@aiquants/virtualscroll` ^3.11.4.
|
|
32
33
|
The client depends on these floors, while a package manager may only warn about an older peer.
|
|
33
34
|
- A Markdown parser of your choice on the server that produces HTML and its headings (the explorer sanitizes the HTML before it is sent).
|
|
34
35
|
- Browsers: the multi view's panel-limit notice uses the Popover API (Chrome and Edge 114, Firefox 125, Safari 17 and later). In browsers without it (for example iOS 16), the notice is drawn in place at the stage's corner instead of in the top layer (while the sheet is open it spans the sheet's header, as in every browser).
|
|
@@ -59,7 +60,7 @@ export const explorerConfig = defineExplorerConfig({
|
|
|
59
60
|
})
|
|
60
61
|
```
|
|
61
62
|
|
|
62
|
-
`defineExplorerConfig` validates everything once and returns a frozen value: mount paths, view slugs (`tree`, `multi`, `single` by default), the multi-view limits (`maxPanels` 12, `columns` 4), Expand all's budget per press (`maxFolders` 500, `maxDepth` 16), the document styles, the iframe host allow-list, the embeds and link cards and the reader's default tree settings. A mistake throws at startup instead of producing links that point nowhere.
|
|
63
|
+
`defineExplorerConfig` validates everything once and returns a frozen value: mount paths, view slugs (`tree`, `multi`, `single` by default), the multi-view limits (`maxPanels` 12, `columns` 4), Expand all's budget per press (`maxFolders` 500, `maxDepth` 16), the deepest document the reader's reveal opens folders for (`maxDepth` 16), the document styles, the iframe host allow-list, the embeds and link cards and the reader's default tree settings. A mistake throws at startup instead of producing links that point nowhere.
|
|
63
64
|
The source ids are not part of it: they are the ids of the server's `sources` (a runtime setting of the server), and the browser learns them from the page data. `withExplorerSources(config, sourceIds)` joins them to the configuration where the URL codec needs them (see [Views and URLs](#views-and-urls)).
|
|
64
65
|
|
|
65
66
|
| Option | Type | Purpose |
|
|
@@ -70,10 +71,11 @@ The source ids are not part of it: they are the ids of the server's `sources` (a
|
|
|
70
71
|
| `views?` | `{ tree?, multi?, single? }` | URL slugs of the views; each defaults to its view's name. |
|
|
71
72
|
| `multiView?` | `{ maxPanels?, columns? }` | The panel limit (1–64, default 12) and the logical column count (1–6, default 4). |
|
|
72
73
|
| `expandAll?` | `{ maxFolders?, maxDepth? }` | Expand all's budget per press (see [Expand all and Collapse all](#expand-all-and-collapse-all)): the folder listings a press may start (1–10,000, default 500, `EXPAND_ALL_FOLDER_LIMITS`) and the deepest level (the top being 1) at which it opens a folder of unknown contents (1–64, default 16, `EXPAND_ALL_DEPTH_LIMITS`). Each field defaults on its own, also when given as `undefined`; a value that is not an integer within its bounds or an unknown key throws a `RangeError` naming the field, and anything but a plain object a `TypeError`. |
|
|
74
|
+
| `revealDocument?` | `{ maxDepth? }` | The deepest document whose folders the reader's "Reveal the open document" setting opens, counted in folders between the source's top level and the document (1–64, default 16, `REVEAL_DOCUMENT_DEPTH_LIMITS`); a deeper document is not revealed. Each folder of the chain takes at most one listing, so this also bounds a reveal's listings. The field defaults on its own, also when given as `undefined`; an unknown key throws a `RangeError`, anything but a plain object a `TypeError` (see [Revealing the open document](#revealing-the-open-document)). |
|
|
73
75
|
| `documentStyles?` | `readonly { name, className }[]` | Document styles, the first being the default; `@aiquants/markdown`'s `DEFAULT_MARKDOWN_STYLES` (None, GitHub, Zenn; also exported without React from `@aiquants/markdown/viewer-settings`) when omitted. |
|
|
74
76
|
| `iframeHosts?` | `readonly string[]` | Host names whose `https:` iframes written in documents may load (exact match); none when omitted. They gate only iframes written in documents; provider frames come from `embeds`, and no iframe of the page's own origin ever renders, whatever is listed. |
|
|
75
|
-
| `embeds?` | `{ providers?,
|
|
76
|
-
| `defaultTreeSettings?` | `Partial<TreeSettings>` | The reader's tree settings before they change any, merged over the package's `DEFAULT_TREE_SETTINGS` (the source's own order, folders
|
|
77
|
+
| `embeds?` | `{ providers?, linkCards?, linkCardSize? }` | What `@aiquants/markdown` makes of a link alone in a paragraph. `providers` lists the ids (`EMBED_PROVIDER_IDS` of `@aiquants/markdown/embeds`: `youtube`, `x`, `instagram`, `threads`, `tiktok`, `bluesky`, `linkedin`, `reddit`, `note`, `niconico`) whose posts and videos documents embed as cross-origin frames, whatever the link's text. `linkCards: true` turns a link written as its own URL into a card, which the data route's own `link-card` operation serves (see [Link cards](#link-cards)): no route of yours is needed. `linkCardSize` picks the size of every card, `compact`, `banner` or `full` (`LINK_CARD_SIZES` of `@aiquants/markdown/embeds`; `@aiquants/markdown`'s `banner` when omitted), and needs `linkCards: true`. Each field defaults to none (`[]`, `false`, omitted), also when given as `undefined`, so without the option such a link stays its paragraph. Repeated ids are removed. An unknown id, a `linkCards` that is not a boolean, an unknown size, a size without `linkCards: true` or an unknown key (`linkCardEndpoint` included) throws a `RangeError` (`[markdown-explorer] embeds…`), and anything but a plain object a `TypeError`. The resolved `config.embeds` is the `MarkdownEmbeds` the viewer takes: `linkCardEndpoint` is `<dataPath>/link-card` when link cards are on and `null` otherwise, and `linkCardSize` is present only when given. See `@aiquants/markdown`'s README (Embeds) for the URLs each provider recognizes, the frames' sizes and the cards' sizes. |
|
|
78
|
+
| `defaultTreeSettings?` | `Partial<TreeSettings>` | The reader's tree settings before they change any, merged over the package's `DEFAULT_TREE_SETTINGS` (the source's own order, folders mixed among the files, Single selection, a recursive double click, 8 px expand icons, nothing kept expanded, the open document not revealed, the root indent kept, lines, expand icons and folder and file icons on). Each value is one the settings menu offers: `sortMode` `"native"`, `"asc"` or `"desc"`; `folderPlacement` `"mixed"`, `"first"` or `"last"`; `selectionMode` `"single"`, `"multiple"` or `"none"`; `doubleClickAction` `"recursive"` or `"toggle"`; `expandIconSize` `8`, `13` or `5`; the other settings (`alwaysExpanded`, `revealDocument`, `removeRootIndent`, `lines`, `expandIcons`, `directoryIcons`, `fileIcons`) `true` or `false`. An unknown key or any other value throws a `RangeError`, and anything but a plain object (a `Map`, a class instance, an object inheriting its settings) throws a `TypeError`; a setting given as `undefined` keeps the package default. The server render and the hydration draw these defaults (see [Tree settings](#tree-settings)). |
|
|
77
79
|
|
|
78
80
|
For example, `defaultTreeSettings: { sortMode: "desc" }` lists every folder's entries by name, Z to A, until the reader picks another order.
|
|
79
81
|
|
|
@@ -261,10 +263,10 @@ The full contract, including canonicalization, is in [URL contract](docs/behavio
|
|
|
261
263
|
| Option | Type | Purpose |
|
|
262
264
|
| --- | --- | --- |
|
|
263
265
|
| `config` | `ExplorerConfig` | The shared configuration; the source ids come from `sources`. |
|
|
264
|
-
| `authenticate` | `(request) => Promise<ExplorerAuthentication<P>>` | `signed-in` with a principal, `signed-out`, or `forbidden`; `headers` (for example a refreshed session cookie) are added to every response. |
|
|
266
|
+
| `authenticate` | `(request, mode) => Promise<ExplorerAuthentication<P>>` | `signed-in` with a principal, `signed-out`, or `forbidden`; `headers` (for example a refreshed session cookie) are added to every response. `mode` is an `ExplorerAuthenticationMode`, `{ readOnly: boolean }`: the page loader and every data operation but `link-card` pass `{ readOnly: false }`; the `link-card` operation passes `{ readOnly: true }`, and then the host only reads the session — it never refreshes a token, writes no cookie and returns no `headers` — because cards ask in the background and a refreshed cookie arriving after a sign-out would sign the reader back in. The explorer fails closed: a read-only authentication that carries any header is logged and answered as a failure (see [Link cards](#link-cards)). |
|
|
265
267
|
| `principalKey` | `(principal) => string` | A stable identity of the principal (it must not change when a token refreshes); used to isolate caches and, through an HMAC under `scopeSecret`, as the browser's pseudonymous scope. |
|
|
266
268
|
| `scopeSecret` | `string` | The deployment's secret for the readers' scopes: at least 32 characters (a shorter one throws a `RangeError`) and the same on every server instance. |
|
|
267
|
-
| `sources` | `ExplorerSource<P>[]` | The sources in switcher order (at least one; the first is the default): `id` (lowercase letters, digits and `-`, starting with a letter or digit, unique; the URL's `source` value), `label` (a string, or a function of the principal), `boundary` (where the source's documents may lie, see [Source boundaries](#source-boundaries)), `tree(context)` (lists the source's roots), `children?(context, path, readPath)` for lazy folders (asked only while the tree shows the folder open — the reader opened it, Expand all opened it (a press keeps opening folders as their listings land, within `expandAll`), or a remembered expansion opened it — and only for a path inside the source's boundary; a listing no tree wants any more is aborted through `context.signal`, which the source should honour), `cacheScope?` (`"principal"`, the default, or `"shared"`). The `context` is described under [Entries and notices](#entries-and-notices). |
|
|
269
|
+
| `sources` | `ExplorerSource<P>[]` | The sources in switcher order (at least one; the first is the default): `id` (lowercase letters, digits and `-`, starting with a letter or digit, unique; the URL's `source` value), `label` (a string, or a function of the principal), `boundary` (where the source's documents may lie, see [Source boundaries](#source-boundaries)), `tree(context)` (lists the source's roots), `children?(context, path, readPath)` for lazy folders (asked only while the tree shows the folder open — the reader opened it, Expand all opened it (a press keeps opening folders as their listings land, within `expandAll`), or a remembered expansion opened it — and only for a path inside the source's boundary; a listing no tree wants any more is aborted through `context.signal`, which the source should honour), `ancestors?(context, path, readPath, options)` (the folders down to a document, for the reader's reveal; see [Revealing the open document](#revealing-the-open-document)), `cacheScope?` (`"principal"`, the default, or `"shared"`). The `context` is described under [Entries and notices](#entries-and-notices). |
|
|
268
270
|
| `document` | `(context, path, readPath) => Promise<ExplorerHostDocument>` | Resolves a document path. Called only for a path inside at least one source's boundary; `readPath` is what the admitting source's `confirm` answered (`path` when that source has no `confirm`), so read `readPath` and show the document as `path`. An image, media, text or file document reports its file's `version`; the explorer writes its URL (see [Documents](#documents)). |
|
|
269
271
|
| `asset` | `(context, path, readPath) => Promise<ExplorerAssetFile>` | Finds the file behind the data route's `asset` operation: any regular file the document admission admits, whatever its kind. Called only after the path passed the deny rules and the same union admission as a document, with the same `readPath`; see [Serving files](#serving-files). |
|
|
270
272
|
| `signedOutPage` | `(request, headers) => Response` | The page response for a signed-out reader, usually a redirect to sign-in. Data requests answer 401 instead. |
|
|
@@ -274,7 +276,7 @@ The full contract, including canonicalization, is in [URL contract](docs/behavio
|
|
|
274
276
|
| `treeCache?` | `{ ttlMs?, maxEntries?, maxBytes? } \| false` | The server's tree cache, each limit defaulting on its own (5 minutes, 64 entries, 64 MiB of the trees' JSON, counted at two bytes per character). The time to live counts from the moment the tree's walk began, and an expired tree is never answered: a page load or tree request after it waits for one new walk, which every concurrent request shares. Each cached tree is also kept parsed beside its JSON, which `maxBytes` does not count; its share falls as names get longer and is higher for non-ASCII names (measured on trees of 20,000 entries: about 1.0 to 1.9 times the counted bytes for ASCII names of 40 down to 4 characters, 1.4 to 2.2 times for non-ASCII names), and a tree with any non-ASCII name keeps a two-byte JSON as large as its count, so plan for up to about 2.4 times `maxBytes` of memory per process with ASCII names and up to about 3.2 times with short non-ASCII names. `false` turns the cache off. |
|
|
275
277
|
| `sanitizer?` | `{ workers?, deadlineMs?, maxHtmlBytes?, cacheBytes?, workerHeapMb?, jobsPerScope?, maxQueuedJobs? }` | The HTML sanitizer, each field defaulting on its own: 2 worker threads, a 30 s deadline per document, HTML up to 4 MiB, a 64 MiB cache of outcomes, 512 MiB of heap per worker (`workerHeapMb`), at most `multiView.maxPanels` + max(1, `workers` − 1) + 3 documents per reader running or waiting (`maxPanels` + 4 with the default two workers, 16 with the default 12 panels) and four times `jobsPerScope` waiting in all, also when `jobsPerScope` is set. Neither `jobsPerScope` nor `maxQueuedJobs` may be set below `multiView.maxPanels`, because a page sends the document of every panel at once and a reader who finds every worker busy waits with all of them; a smaller value throws a `RangeError` naming both options at startup, as does a `workerHeapMb` that leaves room for fewer than 4,096 parsed nodes beside HTML of `maxHtmlBytes`. A document over the size, nesting, node, comment or attribute limits, whose sanitized HTML is longer than four characters per byte of `maxHtmlBytes` (16,777,216 by default), past the deadline, or one that runs a worker out of heap is `too-large`; one beyond either admission limit, or one whose worker could not start, is `failed` (logged without the principal) and a later request tries again. A reader runs at most `workers` − 1 documents at once (one when there is a single worker): with the default two workers, one reader — or all anonymous readers, who share one scope and so one admission budget — uses one. |
|
|
276
278
|
| `deferredTimeoutMs?` | `number` | How long the page loader waits for a streamed value (default 4000 ms; keep it below your server entry's `streamTimeout`). A late value renders the loading state on the server (never a failure) and is fetched by the browser once a pane shows it. The work behind a late tree or document keeps running for another `deferredTimeoutMs`, so the browser's data request for it can join that work instead of starting over (a host that joins requests for the same work keeps it for that request), and its `signal` aborts then; the work behind late notices, which the browser never fetches again, is aborted as soon as they are given up. |
|
|
277
|
-
| `logger?` | `{ error(message, detail) }` | Where adapter failures and malformed source output are reported (default `console.error`). A tree or children entry with an empty name, or with a path the browser cannot address (empty, too long, a lone surrogate, a control character or a backslash — for example macOS's `Icon\r`), or outside its source's boundary, is left out together with its subtree and reported with the message `[markdown-explorer] <operation> left out an entry` and the detail `{ operation, sourceId, path, error }`, whose `error` names the reason; any other malformed listing becomes `failed`. A boundary that throws or answers malformed values is reported with the operation `boundary`, and so is the rejection of a promise a `contains` answers (it is not awaited and counts as outside). |
|
|
279
|
+
| `logger?` | `{ error(message, detail) }` | Where adapter failures and malformed source output are reported (default `console.error`). A tree or children entry with an empty name, or with a path the browser cannot address (empty, too long, a lone surrogate, a control character or a backslash — for example macOS's `Icon\r`), or outside its source's boundary, is left out together with its subtree and reported with the message `[markdown-explorer] <operation> left out an entry` and the detail `{ operation, sourceId, path, error }`, whose `error` names the reason; any other malformed listing becomes `failed`. A boundary that throws or answers malformed values is reported with the operation `boundary`, and so is the rejection of a promise a `contains` answers (it is not awaited and counts as outside). A failed authentication of a data request is reported with the operation `authenticate` and never quotes a header: `headers` that `Headers` cannot read are reported by a fixed message, and a `Response` that `authenticate` throws (React Router's `throw redirect(...)`) by its status alone; any other exception of your adapters is logged as thrown, so keep secrets out of it. |
|
|
278
280
|
| `onTreeRefreshed?` | `(key: string) => void` | Called once per tree refresh, after its reload settled (whatever its result) unless the request went away, with the refreshed tree's cache key (opaque). A multi-process host relays the key to its other processes, which call `forgetTree(key)` (see [Hosting notes](#hosting-notes)). Its return value is ignored, but a promise it returns (an asynchronous relay) is observed, never awaited: a throw, or the rejection of that promise, is logged with the operation `refresh` and does not change the response. |
|
|
279
281
|
|
|
280
282
|
It returns `{ loader, headers, dataLoader, dataAction, forgetTree }`. `forgetTree(key)` drops this process's cached tree for a key another process refreshed and supersedes a load of it that already began (its waiting requests still receive that tree, which is not kept); it starts no load and throws a `TypeError` for a non-string key. Export `headers` from the page route: it carries the loader's `Cache-Control: private, no-store` to both the HTML and the single-fetch responses.
|
|
@@ -294,6 +296,7 @@ Every source declares where its documents may lie, as `boundary: { contains, con
|
|
|
294
296
|
|
|
295
297
|
- A source's tree and children list only paths inside its own boundary: an entry outside it is left out with its subtree and logged.
|
|
296
298
|
- A children request is checked against the named source alone: the deny rules, then `contains` (outside answers `forbidden`), then `confirm` (outside answers `forbidden`, a thrown `ExplorerError` its reason); `children(context, path, readPath)` is called only after both passed.
|
|
299
|
+
- An ancestors request is checked against the named source alone as well: the deny rules (a denied path answers `forbidden`), then `contains` and `confirm`, where outside answers `{ status: "ok", ancestors: null }` without calling the host (the open document may lie in another source) and a thrown `ExplorerError` its reason; `ancestors(context, path, readPath, options)` is called only after both passed.
|
|
297
300
|
- A document — of any view, panel, document link or seeded page — carries no source: it opens when the boundary of at least one source admits its path (the union of every source's boundary). The deny rules come first; a path no source contains answers `forbidden` without calling the host or storage; a containing source without `confirm` admits it at once with `readPath` equal to the path; otherwise the containing sources confirm it in configuration order and the first inside admits it with its `readPath`. When none does, the first confirmation's failure answers, else `forbidden`.
|
|
298
301
|
- The union is exactly what the deployment exposes: a source whose boundary admits every document a reader can read in a store (an entry point listing everything the reader sees) opens every such document through every view, link and asset URL, so documents of that store are confined only when every source over it has a confined boundary. Asset URLs are admitted by the same union, because the explorer serves them itself.
|
|
299
302
|
|
|
@@ -367,6 +370,21 @@ Your parser resolves each link and each image; the rules are in [Document links]
|
|
|
367
370
|
a missing target gets `data-asset-exists="false"`, which the viewer shows as a labelled placeholder; a relative `src` left as written would resolve against the page URL and load an explorer page instead), and the demo's parser (`demo/app/markdown.server.ts` in the source repository) is a complete example.
|
|
368
371
|
The deny rules are checked on the document's path only: a parser that expands include directives (such as `<!-- @import "…" -->`) must apply them to every file it reads, or leave such directives unexpanded (`@aiquants/markdown`'s `parseMarkdown` leaves them unexpanded unless `resolveImports` is set, and applies the `deniedPathSegments` you give it, the explorer's rules, to every import, image and link target). The explorer serves the files of documents and embedded images itself (see [Serving files](#serving-files)).
|
|
369
372
|
|
|
373
|
+
### Revealing the open document
|
|
374
|
+
|
|
375
|
+
The reader's tree setting "Reveal the open document" (`revealDocument`, off in `DEFAULT_TREE_SETTINGS`; turn it on for every reader with `defaultTreeSettings: { revealDocument: true }`) opens the folders down to the open document and brings its row into the tree's window. The open document is the URL's document in the tree view (whatever the selection mode, "Off" included), and in the multi view the maximized panel's document, else the one opened last (a panel's link replaces its document; on load, where no order of opening is known, the last open document in layout order).
|
|
376
|
+
The single view has no tree.
|
|
377
|
+
|
|
378
|
+
- **When**: on load, and whenever that document changes from outside the tree (a link in the document, Back and Forward, opening or maximizing a panel). A document the reader opens by clicking or pressing Enter in the tree is not revealed again: the tree already has the focus there.
|
|
379
|
+
- **How**: the browser asks the data route's `ancestors` operation (`GET <dataPath>/ancestors?source=<shown source>&path=<document>`) for the folders of the **shown** source, opens them all at once, and keeps bringing the row into view while their listings land (each lazy folder is listed as soon as its parent's contents are known, ahead of bulk work).
|
|
380
|
+
It stops at the reader's next input in the tree (a press, a wheel, a touch, a key or a focus), at the next document or source, at Collapse all, when the explorer is hidden during the reveal (closing the sheet, collapsing the explorer panel), when a folder's listing fails, or when every folder of the chain has loaded and the row is not there — so it waits for at most one listing per folder. A chain deeper than `revealDocument.maxDepth` (16 by default) opens nothing: the server answers `null` for it.
|
|
381
|
+
- **Stored state**: the folders a reveal opens are part of the reader's remembered expansion for that source, exactly as if the reader had opened them, so a reload shows them open and the reader closes them as any other folder.
|
|
382
|
+
- **The port**: `ExplorerSource.ancestors?(context, path, readPath, options): Promise<readonly string[] | null>` answers the folder row paths from the source's top level down to the document's direct parent, exactly as that source's `tree` and `children` name them (`[]` for a document at the top level), or `null` when the document is not in this source or cannot be revealed there (for example a document reached only through a shortcut, whose row has the shortcut's path).
|
|
383
|
+
It is called only for a document path inside the source's boundary that passed the deny rules, with the confirmed `readPath` (see [Source boundaries](#source-boundaries)). A source without it answers `not-found`, and its documents are not revealed.
|
|
384
|
+
`options` (`ExplorerAncestorsOptions`) is always `{ maxDepth }`, the configuration's `revealDocument.maxDepth`. The server answers `{ status: "ok", ancestors: null }` for a chain of more folders than that, without validating it, so a source whose climb costs requests (a parent climb in a cloud drive, for example) may stop once the chain is longer and answer `null` itself; a source that ignores `options` gets the same answer.
|
|
385
|
+
- **Validation**: every path of a chain within `maxDepth` must be acceptable (non-empty, within the length limit, no control character, lone surrogate or backslash), pass the deny rules, lie inside the source's boundary, differ from the document and appear once. Any other answer (not `null` or an array, or one bad path) is logged with the operation `ancestors` and answered `{ status: "error", failure: { reason: "failed" } }`, and the tree opens nothing; the browser checks the answer's shape again. A thrown `ExplorerError` answers its reason, any other exception is logged and answers `failed`.
|
|
386
|
+
- **Answers**: `200` with `{ status: "ok", ancestors: string[] | null }` or `{ status: "error", failure }`, `400` for a missing or malformed `source` or `path`, `404` for an unknown source or one without `ancestors`, `405` for anything but `GET` and `HEAD`, and the usual `401` and `403`.
|
|
387
|
+
|
|
370
388
|
### `createFileSystemSource(options)`
|
|
371
389
|
|
|
372
390
|
A reference source over a folder on disk: lexical containment checked before any filesystem call and again after resolving the real path, symbolic links refused, a file read only when the opened file is the one the checks saw, denied branches pruned while walking, a cap on the number of entries (`too-large` above it), a size cap on Markdown files, and a bounded streamed preview for files with a known text extension or name (any other file is a `file` document, offered for download).
|
|
@@ -389,6 +407,7 @@ Names the tree cannot carry — not in NFC, with a colon, ending in a dot or a s
|
|
|
389
407
|
Any other option key (a misspelt limit, an option this source does not have) throws a `TypeError` naming it when the source is created, instead of being ignored.
|
|
390
408
|
|
|
391
409
|
The source's `document(context, path, readPath)` reads the file `readPath` names and shows it as `path` (its parser receives `path`); every other kind (image, media, text, file) reports the file's version, `<size>-<mtimeNs>`. A file of an unknown extension, and a text file whose preview holds a NUL byte, is a `file` document.
|
|
410
|
+
The source's `ancestors(context, path, readPath)` answers the folders down to the file `readPath` names from its path prefixes (`<prefix>a` and `<prefix>a/b` for `<prefix>a/b/c.md`, `[]` for a file at the top level), which are exactly its tree's row paths, and `null` for any path its walk would not list (outside the prefix, missing, not a regular file, denied, or reached through a symbolic link). A wrapper that turns a folder lazy (as the demo's `withLazyFolder` does) keeps it, because the row paths do not change.
|
|
392
411
|
The source's `asset(context, path, readPath)` serves every regular file the same checks admit: images and media with their type, everything else (Markdown, text and the files of unknown extensions) without one (`""`), so the explorer delivers it as an `application/octet-stream` download.
|
|
393
412
|
It opens the file again without following links, requires the device, inode, size and modification time the checks saw (`not-found` when the path now names another file or the file has changed since) and streams the requested range from that handle (the whole file only as long as the checks saw it), which closes when the stream ends, fails or is cancelled, or the request aborts.
|
|
394
413
|
Files of unknown extensions are downloadable, and so are the whole bytes of every Markdown and text file the source admits, so the `deny` rules are their only filter. The explorer hands both ports a `readPath` equal to the path, because the boundary has no `confirm`. Several folders are combined by giving each a `pathPrefix` and routing `document` and `asset` to a source whose boundary contains the path; the explorer refuses a path no source contains before it calls either port:
|
|
@@ -454,15 +473,31 @@ and `Cache-Control: private, max-age=60, stale-while-revalidate=600, no-transfor
|
|
|
454
473
|
The body of a 200 or 206 with a `Content-Length` carries exactly that many bytes: the explorer drops the bytes past it and cancels the stream `open` returned, and fails the response when that stream ends short, so a file that changes while it is served never gets a body that disagrees with its length and ETag.
|
|
455
474
|
The URL carries the path in its query, so no name needs an extra escape and the request's own path never ends in `.data`; a document's URL carries `v=<version>` as a cache-buster, which the server never reads (the ETag is always the current version).
|
|
456
475
|
|
|
476
|
+
### Link cards
|
|
477
|
+
|
|
478
|
+
With `embeds: { linkCards: true }`, the data route has a `link-card` operation: `GET` or `HEAD` `<dataPath>/link-card?url=<href>`, which `@aiquants/markdown`'s link card asks (same-origin, in the background, once the card nears the viewport). It is the only route of the cards: the explorer creates `@aiquants/markdown`'s `createLinkCardHandler` once, in `createMarkdownExplorer`, behind the read-only authentication, and passes every answer of it through unchanged — status, headers and cache headers. In order:
|
|
479
|
+
|
|
480
|
+
1. A single-fetch request (`<dataPath>/link-card.data`) answers `not-found` (404), as every operation does; with link cards off, `link-card` answers `not-found` exactly as an unknown operation does, whatever the method.
|
|
481
|
+
2. A method other than `GET` and `HEAD` answers 405 with `Allow: GET, HEAD`, before authenticating.
|
|
482
|
+
3. `authenticate(request, { readOnly: true })` runs. `signed-in` lets the handler answer; `signed-out` and `forbidden` both mean no card (the handler's 401, `no-store`).
|
|
483
|
+
An authentication that carries any header — even a non-empty `headers` with `signed-out` — breaks the read-only contract: none of its headers is forwarded, the failure is logged once through `logger` (operation `authenticate`), and the answer is a `failed` failure (500, `private, no-store`, no `Set-Cookie`). An `authenticate` that throws is handled the same way (an `ExplorerError` answers its reason unlogged, as everywhere; an aborted request is not logged).
|
|
484
|
+
The log never quotes a header: `headers` that `Headers` cannot read are logged by a fixed message, and a `Response` that `authenticate` throws (React Router's `throw redirect(...)`) by its status alone.
|
|
485
|
+
4. The handler answers: `200` with the card's JSON (`private, max-age=1800`), `204 No Content` with `X-Link-Card-Skip: <reason>` when the link gets no card (`private-network`, `forbidden-url`, `unreachable` or `not-html`), or its own `400`, `401` and `500` JSON with `no-store`. It never sets a cookie.
|
|
486
|
+
|
|
487
|
+
Internal addresses never become cards, in any environment: the handler refuses loopback, private, link-local and every other non-global address, internal names, names that resolve to such addresses and redirects to them, before connecting (see `@aiquants/markdown`'s README, Link-card endpoint). There is no option to allow them, in the handler or in the explorer. A skipped link renders as a compact card that keeps the link, and `@aiquants/markdown` writes one `console.info` line for it; the explorer logs nothing of its own for cards.
|
|
488
|
+
|
|
489
|
+
The cards need nothing extra in your content security policy: they ask the page's own origin, so `connect-src 'self'` covers them (only the cards' images and icons need `https:` in `img-src`, see [Hosting notes](#hosting-notes)). The handler needs Node.js 22.13 or later and keeps its own cache (cards 1 hour, skips as long as their `Cache-Control`, 1000 URLs) and connection pool per explorer.
|
|
490
|
+
|
|
457
491
|
### `anonymousAccess`
|
|
458
492
|
|
|
459
|
-
Spread it into the configuration when your application has no sign-in: it provides `authenticate`, `principalKey` and `signedOutPage`.
|
|
493
|
+
Spread it into the configuration when your application has no sign-in: it provides `authenticate`, `principalKey` and `signedOutPage`. Its `authenticate` returns no `headers` in any mode, so it honours read-only mode as it is.
|
|
460
494
|
|
|
461
495
|
### Hosting notes
|
|
462
496
|
|
|
463
497
|
- The HTML sanitizer runs in worker threads started from `sanitizeWorker.js` (`sanitizeWorker.cjs` for the CommonJS entry) next to the server entry, and creating the explorer fails when that file is missing: keep the package external in your server bundle instead of bundling it into your own file. Each worker has its own DOMPurify, so nothing else in your server shares its configuration. Running the package from its TypeScript sources (tests, a dev server aliased to `src/`) needs Node's type stripping (22.18+, 23.6+ or 24).
|
|
464
498
|
- Serve a content security policy of your own; the explorer's sanitizer is the first line of defence, not the only one. In a single-page app a policy binds to the document, which client-side navigations keep, so set one policy for every page (at the root route or the document handler, or at the edge), never on the explorer's route responses alone: a policy sent only there is missing when the reader arrives by a client-side navigation, and stays on every page the reader visits next.
|
|
465
499
|
The explorer needs `frame-src`, `img-src` and `media-src` to allow `'self'`, the origin of its own asset URLs (PDF documents open in a frame from that URL), plus `frame-src https://<host>` for each `iframeHosts` entry and each host of `embedFrameHostsOf(config.embeds.providers)` (from `@aiquants/markdown/embeds`); a policy with `connect-src` also needs `embedConnectOriginsOf(config.embeds.providers)` (the Bluesky handle lookup), and one with `img-src` needs `https:` for card images and icons.
|
|
500
|
+
Link cards need no extra `connect-src`: the card endpoint is the data route's own `link-card` operation, same-origin.
|
|
466
501
|
It renders no `<object>` or `<embed>`, so `object-src 'none'` and `base-uri 'none'` hold for it; prefer a nonce-based `script-src` if your framework's inline hydration scripts allow it.
|
|
467
502
|
A host that enables providers should also send `Cross-Origin-Opener-Policy: same-origin`: provider frames may open popups that escape their sandbox (`allow-popups-to-escape-sandbox`), and the policy severs such a popup's opener.
|
|
468
503
|
- Every GET route on the explorer's origin is reachable from a document: a rendered document makes the reader's browser send credentialed same-origin GET requests through its images (``, `<img src>`), media (`<video poster>`, `<audio src>`) and frames without the reader's interaction, and through its links once the reader follows one; the sanitizer keeps relative and root-relative URLs because a document's own images are legitimate.
|
|
@@ -524,7 +559,8 @@ With `lockDocumentScroll` the explorer must fill a container of definite block s
|
|
|
524
559
|
|
|
525
560
|
The reader's tree settings are kept in memory for the explorer's lifetime and saved to browser storage under `storageNamespace` when the browser allows it; where it cannot write (blocked site data, a full quota) they last until the explorer unmounts (a navigation away from its route, a reload). The server render and the hydration use the defaults — the package's, with the configuration's `defaultTreeSettings` over them — and the stored settings apply right after the hydration.
|
|
526
561
|
Storage keeps only the settings the reader changed, each with the value they chose: a later change of `defaultTreeSettings` reaches every setting the reader has left alone, the ones they changed stay as they set them (also when a later default happens to equal their choice), and a setting the reader moves back to the default in force at that moment is dropped from storage, so later defaults reach it again.
|
|
527
|
-
A stored value of another format version is ignored, so its reader starts from the defaults.
|
|
562
|
+
A stored value of another format version is ignored, so its reader starts from the defaults. A stored `directoriesFirst` (from when "Folders first" was a switch) is read as `folderPlacement`: `true` as `"first"`, `false` as `"mixed"` (a stored `false` exists only where the default was `true`), unless a `folderPlacement` is stored too; the next change the reader makes stores the new key only. Folders: Mixed (the package default) keeps the source's order, or interleaves folders and files by name under a name order;
|
|
563
|
+
First puts the folders before the files and Last after them, under any sort order (a descending name order reverses the names, not the placement). Reveal the open document: see [Revealing the open document](#revealing-the-open-document). Selection: Single (the package default) selects the shown document; Multiple gathers clicked documents in a tray that opens them as panels; Off shows no row as selected, not even the shown document.
|
|
528
564
|
The tray shrinks and scrolls before the tree does: the tree keeps at least three rows at any text size, the tray keeps its header row and scrolls the rest, and an explorer too short for both scrolls as a whole. Always expanded shows every folder whose contents are known as expanded; a lazy folder stays collapsed until the reader opens it, so the setting never loads folders by itself.
|
|
529
565
|
|
|
530
566
|
Call `clearExplorerStorage(storageNamespace)` when a reader signs out of a shared browser (it throws a `RangeError` for a malformed namespace instead of clearing the wrong keys). Import it from `@aiquants/markdown-explorer/storage`: that entry imports nothing (no React, no `@aiquants/markdown`), so a layout or root route that runs on every page can call it without loading the explorer; the root entry exports the same function. The explorer also clears the namespace by itself: on every page load, before anything reads it, when the reader recorded there is not the page's reader, and when a data response reports a different reader.
|
|
@@ -565,6 +601,26 @@ The labels the layout fills with a value are templates with `{name}` placeholder
|
|
|
565
601
|
|
|
566
602
|
The reader's own explorer width is remembered per view as a percentage, and only after the reader moves the handle: a drag that moved it (once, when it ends) or an arrow key that moved it, never a press that moved nothing or a change of the window. The document's column fills its pane; the viewer's alignment control appears only for a column a single-view embed narrows (`?width=` / `?maxWidth=`). See [Layout](docs/behavior/layout.md).
|
|
567
603
|
|
|
604
|
+
### Scroll bars and the tap-scroll circle
|
|
605
|
+
|
|
606
|
+
Every scroller of the explorer that the reader browses gets one pointer scroll bar of the explorer's own in place of its native vertical scrollbar: `@aiquants/virtualscroll`'s `ScrollBar` (8 px, styled by the `@aiquants/virtualscroll` stylesheet the tree already needs), with the tree's tap-scroll circle and speeds (a quarter of the base speed at the circle's centre, 18 times at its rim) everywhere but on the multi view's stage. The bar shows only while the scroller's content is taller than the scroller, so a scroller whose content fits shows neither the bar nor the circle.
|
|
607
|
+
|
|
608
|
+
| Where | Scroller | How the bar is attached |
|
|
609
|
+
| --- | --- | --- |
|
|
610
|
+
| Tree, single view | Markdown and text documents (the viewer's scroller) | `@aiquants/markdown`'s `renderScrollBar` seam |
|
|
611
|
+
| Tree, single view | An image's canvas (zoomed past the pane), a medium's stage, a file view's stage and a failure view | `@aiquants/markdown`'s `HostedScrollArea` around the explorer's own scroller |
|
|
612
|
+
| Multi view | Each panel's scroll area, maximized or not | drag-drop-panels' `renderPanelScrollArea`, filled with a `HostedScrollArea` |
|
|
613
|
+
| Multi view | The stage (bar without a circle) | drag-drop-panels' `renderStageScrollBar`, over the stage's inline-end edge, in 8 px the stage adds to its inline-end padding |
|
|
614
|
+
|
|
615
|
+
- Press the circle and pull it up or down: the scroller scrolls while the pointer is held, faster the farther it is pulled, and stops on release and at either end. A plain tap scrolls nothing.
|
|
616
|
+
- A circle sits 80 px before its bar, at the middle of the scroller's height. It scrolls the same when a Mermaid diagram or an embedded frame lies under it, and a drag that starts on it selects no text.
|
|
617
|
+
- The stage's bar has no circle: 80 px before the stage's bar a circle would cover the right-most panel, next to that panel's own circle, and a gutter wide enough to hold it (53 px) would cost the stage a column (4 to 3 at a 1920 px window, 3 to 2 at 1440 px). The stage keeps its thumb, track and arrows, the plain wheel (which the panels hand to the stage), touch and the keyboard.
|
|
618
|
+
- Each bar drives its scroller's native scrolling, of which only the vertical scrollbar is hidden: a zoomed image keeps its native horizontal scrollbar, and the wheel, the keyboard, touch, find in page, fragments and the table of contents, the reading position a panel keeps, Ctrl/⌘ + wheel over a panel, and the browser's scroll anchoring work as without it, with the bar following each of them. The viewer's toolbar keeps clear of the document's bar.
|
|
619
|
+
- In a multi-view panel the document follows its content's height and the panel's scroll area scrolls, so the panel's viewer, image, medium, file and failure views have no bar of their own; the panel's bar is exempt from panel drags (`data-aqdd-no-panel-drag`). The stage's bar is not shown while a panel is maximized.
|
|
620
|
+
- Menus and popovers (the tree settings, the table of contents, the toolbars), the scrollers nested in a document (code blocks, tables, inline math) and embedded frames, a PDF's included, keep their native scrollbars and get no circle.
|
|
621
|
+
- Like the tree's bar every bar is pointer-only: hidden from assistive technology and without Tab stops, because the keyboard and assistive technology scroll the native scroller.
|
|
622
|
+
- The bar's code loads on first use. If it fails to load (for example a chunk gone after a redeploy) or a bar throws, that bar's slot stays empty and its scroller keeps scrolling natively; the failure is reported with `console.error` (the explorer's `logger` is a server option and does not reach the browser), and the rest of the page is unaffected.
|
|
623
|
+
|
|
568
624
|
## Security model
|
|
569
625
|
|
|
570
626
|
- Markdown HTML is sanitized on the server with DOMPurify and an allow-list, in worker threads with limits on size (4 MiB), nesting (512 levels, as the sanitizer's parser builds the tree), parsed nodes (81,920 elements, attributes and comments, at most 4,096 of them comments), attributes (at most 1,024 per element, and no more attribute characters than `maxHtmlBytes`, counting the copies the parser makes of reopened formatting elements), output (at most four characters per byte of `maxHtmlBytes`), heap (512 MiB per worker) and time (30 s) and a fair share of the workers for each reader:
|
|
@@ -574,6 +630,7 @@ The reader's own explorer width is remembered per view as a percentage, and only
|
|
|
574
630
|
- Every source is confined to its boundary: its tree and children list only paths inside it, a children request reaches the host only for a path the named source's boundary admits, and a document or a file's bytes reach the host only when the boundary of at least one source admits its path (see [Source boundaries](#source-boundaries)). A source whose boundary admits everything a reader can read in a store confines nothing in that store.
|
|
575
631
|
- File bytes are served only by the explorer's `asset` operation, after the deny rules and the document admission, inline only for raster images, audio, video and PDF, always with `nosniff` and a `same-origin` resource policy, and with a sandboxing policy except for PDF, under which inline audio and video keep the URL's origin (`allow-same-origin`, no `allow-scripts`) (see [Serving files](#serving-files)).
|
|
576
632
|
- Data responses are `private, no-store` JSON with `nosniff`, a sandboxing content security policy and `same-origin` resource policy, and the data route refuses React Router's single-fetch requests (`.data`), whose answers would carry none of those headers; the tree refresh, and a document request marked as triggered by a refresh (`X-Markdown-Explorer: refresh`, which makes the host skip its caches), require the custom request header and a same-origin fetch.
|
|
633
|
+
- Link cards are read by `@aiquants/markdown`'s handler behind a read-only authentication (no token refresh, no `Set-Cookie`; an authentication that carries headers is refused and logged), and its guards keep every internal address from becoming a card; see [Link cards](#link-cards).
|
|
577
634
|
- Each data response carries an opaque, pseudonymous scope (an HMAC of the principal key under `scopeSecret`); when it changes, the browser drops every cache and remembered path. Browser storage is also checked against the page's scope on every page load, before anything reads it.
|
|
578
635
|
|
|
579
636
|
Details: [Security](docs/behavior/security.md).
|
|
@@ -599,7 +656,8 @@ Tests and host styling may rely on the `data-testid` and `data-aqmx-*` attribute
|
|
|
599
656
|
## Demo
|
|
600
657
|
|
|
601
658
|
The source repository holds a runnable demo next to the package (`packages/markdown-explorer/demo`): three file-system sources with anonymous access (`guide` and `notes`, kept apart by their path prefix, with one folder of the guide, `guide/a`, served lazily through `children`; and `reference`, rooted at the folder `guide/reference` inside `guide`, so a document under it appears in two trees under the same path),
|
|
602
|
-
the page and data routes, the error boundary, document and asset ports that route each path to the first source whose boundary contains it (no asset route of its own), a Markdown parser that produces document links and image targets, GitHub alerts, Zenn's message and details containers, embed placeholders, and footnotes, task lists and formulas in the Go converter's markup,
|
|
659
|
+
the page and data routes, the error boundary, document and asset ports that route each path to the first source whose boundary contains it (no asset route of its own), a Markdown parser that produces document links and image targets, GitHub alerts, Zenn's message and details containers, embed placeholders, and footnotes, task lists and formulas in the Go converter's markup,
|
|
660
|
+
every embed provider and link cards served by the data route (`embeds: { providers, linkCards: true }`; `guide/reference/embeds.md` and `guide/reference/link-cards.md` show them; the end-to-end tests answer the browser's card requests from their own fixtures, so they stay offline), and the end-to-end tests' fixtures.
|
|
603
661
|
Run it with `pnpm run demo:dev` from the package folder.
|
|
604
662
|
|
|
605
663
|
## License
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),y=require("./index-CLe6vRXs.cjs"),r=require("react"),O=require("./location-2QZADLiv.cjs"),Oe=require("@aiquants/directory-tree"),ot=require("./tapScrollCircle-C5DGI-0H.cjs"),st=require("./storage-Bkb2Axdi.cjs"),ie=require("@aiquants/resize-panels"),ct=require("react-router");function it(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=it(r);function ut({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15ZM9 12.75a.75.75 0 0 0 0 1.5h6a.75.75 0 0 0 0-1.5H9Z",clipRule:"evenodd"}))}const dt=m.forwardRef(ut);function ft({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15Zm-6.75-10.5a.75.75 0 0 0-1.5 0v2.25H9a.75.75 0 0 0 0 1.5h2.25v2.25a.75.75 0 0 0 1.5 0v-2.25H15a.75.75 0 0 0 0-1.5h-2.25V10.5Z",clipRule:"evenodd"}))}const mt=m.forwardRef(ft);function pt({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M16.5 6a3 3 0 0 0-3-3H6a3 3 0 0 0-3 3v7.5a3 3 0 0 0 3 3v-6A4.5 4.5 0 0 1 10.5 6h6Z"}),m.createElement("path",{d:"M18 7.5a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-7.5a3 3 0 0 1-3-3v-7.5a3 3 0 0 1 3-3H18Z"}))}const ht=m.forwardRef(pt);function xt({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M3 6a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3V6ZM3 15.75a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-2.25Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3v-2.25Z",clipRule:"evenodd"}))}const wt=m.forwardRef(xt),gt=()=>{const{notices:e}=y.useExplorer(),t=r.use(e);return t.length===0?null:i.jsx("div",{className:"aqmx-explorer-notices",children:t.map(n=>i.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":n.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":n.id,children:[i.jsx("p",{className:"aqmx-callout-title",children:n.title}),n.body===void 0?null:i.jsx("p",{className:"aqmx-callout-body",children:n.body}),n.action===void 0?null:i.jsx("a",{className:"aqmx-callout-action",href:n.action.href,children:n.action.label})]},n.id))})};function Et({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M6.912 3a3 3 0 0 0-2.868 2.118l-2.411 7.838a3 3 0 0 0-.133.882V18a3 3 0 0 0 3 3h15a3 3 0 0 0 3-3v-4.162c0-.299-.045-.596-.133-.882l-2.412-7.838A3 3 0 0 0 17.088 3H6.912Zm13.823 9.75-2.213-7.191A1.5 1.5 0 0 0 17.088 4.5H6.912a1.5 1.5 0 0 0-1.434 1.059L3.265 12.75H6.11a3 3 0 0 1 2.684 1.658l.256.513a1.5 1.5 0 0 0 1.342.829h3.218a1.5 1.5 0 0 0 1.342-.83l.256-.512a3 3 0 0 1 2.684-1.658h2.844Z",clipRule:"evenodd"}))}const bt=m.forwardRef(Et),he=r.createContext(!0),Me="\0loop\0",qe="\0",vt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=o=>{const l=e.get(o);if(l!==void 0)return l;const s=Object.freeze({type:"loop",name:o.name,path:o.path});return e.set(o,s),s},c=(o,l,s)=>{let h=!1;const f=o.map(p=>{const x=u(p,l,s);return x!==p&&(h=!0),x});if(!h)return o;const d=n.get(o);return d!==void 0&&d.length===f.length&&d.every((p,x)=>p===f[x])?d:(n.set(o,f),f)},u=(o,l,s)=>{if(o.type!=="directory")return o;if(s.has(o.path))return a(o);const h=o.lazy===!0?l(o.path):void 0,f=h?.status==="loaded",d=f?h.entries:o.children;if(d===void 0)return o;s.add(o.path);const p=c(d,l,s);if(s.delete(o.path),!f&&p===o.children)return o;const x=t.get(o);if(x!==void 0&&x.state===h&&x.children===p)return x.grafted;const g={...o,children:p,lazy:f?!1:o.lazy};return t.set(o,{state:h,children:p,grafted:g}),g};return(o,l)=>c(o,l,new Set)},Rt=(e,t)=>`${Me}${e}${qe}${t}`,ae=e=>e.startsWith(Me),yt=e=>e.slice(e.lastIndexOf(qe)+1),te="data-aqmx-path",St=(e,t,n,a,c)=>{const u={aqmxPath:e.path};return n&&(u.aqmxOpen=!0),(a==="loading"||a==="failed")&&(u.aqmxChildren=a),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:c,data:u}},kt=(e,t,n,a)=>{const c=Rt(t,e.path);return{name:n,type:"directory",absolutePath:c,relativePath:c,children:a,data:{aqmxLoop:e.path}}},Ct=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=[],c=(l,s,h)=>{const f=l.map(p=>p.type==="loop"?u(p,s,h):o(p,s)),d=n.get(l);return d!==void 0&&d.length===f.length&&d.every((p,x)=>p===f[x])?d:(n.set(l,f),f)},u=(l,s,h)=>{const f=t.get(l);if(f!==void 0&&f.parentKey===h&&f.loopFolderName===s.loopFolderName)return f.row;const d=kt(l,h,s.loopFolderName(l.name),a);return t.set(l,{row:d,parentKey:h,loopFolderName:s.loopFolderName}),d},o=(l,s)=>{const h=l.type==="directory"?l.children===void 0?a:c(l.children,s,l.path):void 0,f=s.openPaths.has(l.path),d=l.type==="directory"&&l.lazy===!0?s.childrenOf(l.path)?.status:void 0,p=d==="failed"?s.renderFailedFolder:void 0,x=e.get(l);if(x!==void 0&&x.open===f&&x.childrenStatus===d&&x.children===h&&x.renderFailedFolder===p)return x.row;const g=St(l,h,f,d,p===void 0?void 0:p(l));return e.set(l,{row:g,open:f,childrenStatus:d,children:h,renderFailedFolder:p}),g};return(l,s)=>c(l,s,"")},Tt=e=>{if(e===void 0)return;const t=n=>({name:n.name,path:n.absolutePath,type:n.type});return(n,a)=>e(t(n),t(a))},pe=(e,t)=>{const n=e.filter(a=>a.type==="directory");return t===void 0?n:n.sort(t)},Lt=(e,t)=>{const n=new Map;let a=0;const c=u=>{for(const o of pe(u,t.compare))if(t.isShownExpanded(o.path)){if(o.lazy!==!0){o.children!==void 0&&c(o.children);continue}n.has(o.path)||(n.set(o.path,t.isDirect(o.path)?"direct":"bulk"),t.childrenOf(o.path)?.status!=="failed"&&(a+=1))}};return c(e),{folders:n,waiting:a}},jt=e=>{const t=new Set,n=a=>{for(const c of a)c.type==="directory"&&(c.lazy===!0&&t.add(c.path),c.children!==void 0&&n(c.children))};return n(e),t},Ae=(e,t)=>{for(const n of e){if(n.type!=="directory")continue;if(n.path===t)return n;const a=n.children===void 0?null:Ae(n.children,t);if(a!==null)return a}return null},Nt=(e,t,n,a)=>{let c=e;for(const u of t){const o=c.find(l=>l.type==="directory"&&l.path===u);if(o===void 0)return"missing";if(o.lazy===!0)return a.childrenOf(o.path)?.status==="failed"?"failed":"loading";if(!a.isShownExpanded(o.path))return"loading";c=o.children??[]}return c.some(u=>u.type==="file"&&u.path===n)?"ready":"missing"},Ce=new Set,Pt=(e,t)=>e.has(t)?e:new Set(e).add(t),Ot=(e,t)=>{if(!t.some(a=>e.has(a)))return e;const n=new Set(t);return new Set([...e].filter(a=>!n.has(a)))},Mt=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),qt=()=>{const[e,t]=r.useState(Ce),n=r.useCallback(o=>t(l=>Pt(l,o)),[]),a=r.useCallback(o=>t(l=>Ot(l,o)),[]),c=r.useCallback(o=>t(l=>Mt(l,o)),[]),u=r.useCallback(()=>t(Ce),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:a,pruneDirect:c,clearDirect:u}),[e,n,a,c,u])},At=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),Ft=(e,t)=>{const n=[];let a=pe(t.entries,t.compare);for(let c=1;a.length>0;c+=1){const u=[];for(const o of a){const{path:l}=o;if(t.isShownExpanded(l))e.handled.add(l);else{if(e.handled.has(l))continue;if(e.handled.add(l),o.lazy===!0&&t.childrenOf(l)===void 0){if(c>e.budget.maxDepth){e.depthLimited=!0;continue}if(e.loads.size>=e.budget.maxFolders){e.folderLimited=!0;continue}e.loads.add(l)}n.push(l),e.opened+=1}o.lazy!==!0&&o.children!==void 0&&u.push(...pe(o.children,t.compare))}a=u}return n},Fe=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||Fe(n.children,t))),_t=(e,t)=>{if(e.folderLimited)return{kind:"folder-limit",opened:e.opened};if(e.depthLimited)return{kind:"depth-limit",opened:e.opened};let n=0;for(const a of e.loads)t.childrenOf(a)?.status==="failed"&&(n+=1);return{kind:"done",opened:e.opened,failed:n,complete:Fe(t.entries,t.isShownExpanded)}},me=Object.freeze({state:"idle"}),It=e=>{const t=r.useRef(null),n=r.useRef(e),[a,c]=r.useState(me);r.useLayoutEffect(()=>{n.current=e});const u=r.useCallback(()=>{t.current===null&&(t.current=At(n.current.budget),c({state:"running",opened:0}))},[]),o=r.useCallback(()=>{t.current=null,c(me)},[]),l=r.useCallback(s=>{const h=t.current;if(h===null)return;const f=Ft(h,s);if(f.length>0&&(h.issuedAgainst=s.expanded,n.current.expandMultiple([...f])),!h.announcedStart&&(h.loads.size>0||s.waiting>0)&&(h.announcedStart=!0,n.current.onStart()),f.length===0&&!s.expansionPending&&s.expanded!==h.issuedAgainst&&s.waiting===0){t.current=null;const p=_t(h,s);c(p.kind==="done"?me:{state:"stopped",stop:p.kind,opened:p.opened}),n.current.onFinish(p);return}const{opened:d}=h;c(p=>p.state==="running"&&p.opened===d?p:{state:"running",opened:d})},[]);return r.useMemo(()=>({status:a,start:u,end:o,advance:l}),[a,u,o,l])},Te=["pointerdown","wheel","touchstart","keydown","focusin"],Dt=8,Le={least:Number.POSITIVE_INFINITY,stalled:0},Ht=({tree:e,container:t,path:n,chain:a,rows:c,cancel:u,displayed:o,placement:l})=>{const s=r.useRef(null),h=r.useRef(!0),f=r.useRef(Le),d=r.useRef(null),p=r.useRef(null),x=r.useRef(a),g=r.useRef(l);r.useLayoutEffect(()=>{x.current=a,g.current=l},[a,l]);const b=r.useCallback(()=>{const S=d.current;S!==null&&(d.current=null,S.phase==="asking"?S.controller.abort():x.current?.open(null))},[]),T=r.useCallback(()=>{s.current=null,b()},[b]),R=r.useCallback(()=>{const S=t.current;s.current===null||p.current!==null||S===null||S.getClientRects().length===0||(p.current=requestAnimationFrame(()=>{p.current=null;const E=s.current;if(E===null)return;const k=g.current(E);if(k===0){h.current=!0,d.current?.phase==="opening"&&b();return}if(e.current?.scrollToPath(E,{align:"nearest"})===!0){d.current?.phase==="opening"&&b();const{least:j,stalled:M}=f.current;f.current=k<j?{least:k,stalled:0}:{least:j,stalled:M+1},f.current.stalled<Dt&&R();return}const v=d.current;if(v===null){s.current=null;return}v.phase==="opening"&&x.current?.progress(v.folders,E)!=="loading"&&T()}))},[e,t,b,T]),N=r.useCallback(()=>{h.current=!1,f.current=Le,R()},[R]);r.useEffect(()=>{const S=t.current;if(S===null)return;const E=typeof ResizeObserver>"u"?null:new ResizeObserver(N);E?.observe(S);for(const k of Te)S.addEventListener(k,T,{passive:!0});return()=>{E?.disconnect();for(const k of Te)S.removeEventListener(k,T);p.current!==null&&cancelAnimationFrame(p.current),p.current=null,b()}},[t,N,T,b]);const L=a!==null;r.useEffect(()=>{const S=t.current;if(T(),n===null||S===null||S.contains(S.ownerDocument.activeElement))return;s.current=n;const E=x.current;if(L&&E!==null){const k=new AbortController,v={phase:"asking",controller:k};d.current=v,E.ancestors(n,k.signal).then(j=>{d.current===v&&(j===null?d.current=null:(d.current={phase:"opening",folders:j},x.current?.open(j)),N())})}N()},[n,L,t,T,N]),r.useEffect(()=>{(d.current?.phase==="opening"||s.current!==null&&!h.current)&&N()},[c,N]);const A=r.useRef(u);r.useEffect(()=>{A.current!==u&&(A.current=u,T())},[u,T]);const _=r.useRef(o);r.useEffect(()=>{_.current&&!o&&b(),_.current=o},[o,b])},Zt="--aqmx-tree-line",$t=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),Bt="data-aqmx-tree-probe",zt=Object.freeze({rowHeight:O.CONTROL_BLOCK_PIXELS,lineColor:null}),Vt=/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/u,Kt=e=>{const t=Vt.exec(e);return t===null?e:`#${t.slice(1).map(n=>Number(n).toString(16).padStart(2,"0")).join("")}`},Xt=(e,t)=>{const[n,a]=r.useState(zt);return r.useLayoutEffect(()=>{const c=e.current;if(c===null)return;const u=()=>{const s=Math.round(c.getBoundingClientRect().height),h=getComputedStyle(c),f=h.getPropertyValue(Zt).trim()===""?null:Kt(h.color);a(d=>{const p=Number.isFinite(s)&&s>0?s:d.rowHeight;return d.rowHeight===p&&d.lineColor===f?d:{rowHeight:p,lineColor:f}})};u();const o=$t.map(s=>window.matchMedia(s));for(const s of o)s.addEventListener("change",u);const l=typeof ResizeObserver>"u"?null:new ResizeObserver(u);return l?.observe(c),()=>{for(const s of o)s.removeEventListener("change",u);l?.disconnect()}},[e,t]),n},_e="markdown-explorer-tree-scroll",Wt=.5,Ie=(e,t)=>[...e.querySelectorAll(`[role="treeitem"][${te}]`)].find(n=>n.getAttribute(te)===t),Ut=(e,t)=>{const n=Ie(e,t),a=n?.closest(`[data-testid="${_e}"]`);if(n===void 0||a===null||a===void 0)return Number.POSITIVE_INFINITY;const c=a.getBoundingClientRect(),u=n.getBoundingClientRect(),o=c.top-u.top,l=u.height>c.height?Math.abs(o):Math.max(0,o)+Math.max(0,u.bottom-c.bottom);return l<=Wt?0:l},Gt={testId:_e,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:{width:8,enableTrackClick:!0,enableThumbDrag:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:ot.TAP_SCROLL_CIRCLE},behaviorOptions:{enablePointerDrag:!0}},Yt={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},Qt={color:"inherit"},Jt={paddingBlock:0},en=new Set,tn=new Map,nn={color:"var(--aqmx-tree-line)"},rn=e=>{const t=e instanceof Element?e.closest(`[${te}]`):null;return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(te)},De=(e,t,n,a)=>n==="folder-limit"?e.expandAllFolderLimit(a,t.maxFolders,e.expandAll):e.expandAllDepthLimit(a,t.maxDepth),an=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):De(e,t,n.kind,n.opened),He=()=>{const{labels:e}=y.useExplorer();return i.jsxs("div",{className:"aqmx-explorer-loading","aria-busy":"true","data-testid":"markdown-explorer-tree-loading",children:[i.jsx("p",{className:"aqmx-explorer-loading-text",children:e.treeLoading}),i.jsxs("div",{className:"aqmx-skeleton","aria-hidden":"true",children:[i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{})]})]})},ln=()=>{const{labels:e}=y.useExplorer();return i.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[i.jsx(bt,{className:"aqmx-explorer-empty-icon","aria-hidden":"true"}),i.jsx("p",{className:"aqmx-empty-title",children:e.treeEmptyTitle}),i.jsx("p",{className:"aqmx-explorer-empty-body",children:e.treeEmptyBody})]})},on=({name:e,onRetry:t})=>{const{labels:n}=y.useExplorer(),a=r.useId();return i.jsxs("span",{className:"aqmx-explorer-folder-failed",children:[i.jsx("span",{className:"aqmx-explorer-folder-name",children:e}),i.jsx("span",{id:a,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),i.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":a,"data-testid":"markdown-explorer-folder-retry",onClick:c=>{c.stopPropagation();const u=c.currentTarget,o=u.ownerDocument.activeElement===u?u.closest('[role="treeitem"]'):null;o instanceof HTMLElement&&y.focusWithoutScroll(o),t()},onKeyDown:c=>{c.key!=="Escape"&&c.stopPropagation()},children:[i.jsx(y.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),i.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},sn=({entries:e,version:t,mode:n,sourceId:a,settings:c,reveal:u,openPaths:o,selection:l,onOpenDocument:s,expansion:h,onShown:f,marks:d,claimsHeld:p,expandAll:x,revealCancel:g})=>{const{trees:b,documents:T,labels:R,locale:N,theme:L,data:A,config:_}=y.useExplorer(),S=r.use(he),[E]=r.useState(Ct),k=r.useRef(null),{rowHeight:v,lineColor:j}=Xt(k,L),{isExpanded:M,toggle:Y,expandMultiple:F,collapseMultiple:Z,expanded:H,isPending:Q}=h,{alwaysExpanded:$,sortMode:J,folderPlacement:B}=c,{direct:X,markDirect:P,unmarkDirect:z,pruneDirect:ne}=d,{running:ee,advance:le}=x,re=r.useRef(null),W=r.useRef(null),C=r.useMemo(()=>O.createEntryComparator({sortMode:J,folderPlacement:B}),[J,B]),V=r.useMemo(()=>Tt(C),[C]),I=r.useCallback(w=>b.children(a,w),[b,a]),U=r.useMemo(()=>jt(e),[e]),G=r.useCallback(w=>!ae(w)&&(M(w)||$&&!U.has(w)),[M,$,U]),K=r.useRef({shownExpanded:G,isExpanded:M,unloadedFolders:U,entries:e,childrenOf:I});r.useLayoutEffect(()=>{K.current={shownExpanded:G,isExpanded:M,unloadedFolders:U,entries:e,childrenOf:I}},[G,M,U,e,I]);const Ee=r.useCallback(w=>{re.current?.scrollToPath(w,{align:"nearest"}),requestAnimationFrame(()=>{const q=W.current,D=q===null?void 0:Ie(q,w);D!==void 0&&y.focusWithoutScroll(D)})},[]),We=r.useCallback(w=>{if(ae(w)){Ee(yt(w));return}K.current.isExpanded(w)?z([w]):K.current.unloadedFolders.has(w)&&P(w),Y(w)},[Ee,P,z,Y]),de=r.useCallback(w=>{const q=w.filter(D=>!ae(D));q.length!==0&&(z(q),Z(q))},[z,Z]),Ue=r.useCallback(w=>{const q=w.filter(D=>!ae(D));q.length!==0&&(q.length<w.length&&q.every(D=>K.current.shownExpanded(D))?de(q):F(q))},[F,de]),be=r.useCallback(w=>i.jsx(on,{name:w.name,onRetry:()=>{P(w.path),b.retryChildren(a,w.path),K.current.shownExpanded(w.path)||F([w.path])}}),[b,a,P,F]),ve=n==="multi"?o:en,{loopFolderName:Re}=R,Ge=r.useMemo(()=>E(e,{openPaths:ve,childrenOf:I,renderFailedFolder:be,loopFolderName:Re}),[E,e,ve,I,be,Re,t]),Ye=y.useIntentPrefetch(T,rn),ye=r.useRef([]),oe=r.useCallback(()=>{for(const w of ye.current)K.current.unloadedFolders.has(w)&&P(w)},[P]),{maxDepth:Se}=_.revealDocument,Qe=r.useMemo(()=>({ancestors:async(w,q)=>{const D=await A.ancestors(a,w,q);return D.status!=="ok"||D.ancestors===null||D.ancestors.length>Se?null:D.ancestors},open:w=>{ye.current=w??[],w!==null&&(oe(),F([...w]))},progress:(w,q)=>Nt(K.current.entries,w,q,{isShownExpanded:K.current.shownExpanded,childrenOf:K.current.childrenOf})}),[A,a,Se,oe,F]);r.useEffect(()=>oe(),[oe,U]);const Je=r.useMemo(()=>[e,t,H],[e,t,H]),et=r.useCallback(w=>W.current===null?Number.POSITIVE_INFINITY:Ut(W.current,w),[]);Ht({tree:re,container:W,path:u.path,chain:u.openFolders?Qe:null,rows:Je,cancel:g,displayed:S,placement:et});const ke=r.useCallback(w=>X.has(w),[X]),se=r.useMemo(()=>Lt(e,{isShownExpanded:G,childrenOf:I,compare:C,isDirect:ke}),[e,G,I,C,ke,t]),ce=S&&p;r.useLayoutEffect(()=>{f(e)},[e,f]),r.useLayoutEffect(()=>()=>f(null),[f]),r.useEffect(()=>b.claimChildren(a,ce?se.folders:tn),[b,a,ce,se]),r.useEffect(()=>ne(U),[ne,U]),r.useEffect(()=>{ce&&ee&&le({entries:e,isShownExpanded:G,childrenOf:I,compare:C,expanded:H,waiting:se.waiting,expansionPending:Q})},[ce,ee,le,e,G,I,C,H,se,Q]);const tt=r.useCallback(w=>{w.isDirectory||s(w.entry.absolutePath)},[s]),{onChange:fe}=l,nt=r.useMemo(()=>fe===null?void 0:(w,q)=>{ae(w.absolutePath)||fe({path:w.absolutePath,name:w.name,selected:q})},[fe]),rt=r.useMemo(()=>new Set(l.items),[l.items]),at=r.useMemo(()=>({entryKindDirectory:R.treeEntryKindDirectory,entryKindFile:R.treeEntryKindFile,scrollUp:R.treeScrollUp,scrollDown:R.treeScrollDown,scrollToTop:R.treeScrollToTop,scrollToBottom:R.treeScrollToBottom}),[R]),lt=j===null?{showTreeLines:!1}:{showTreeLines:c.lines,lineColor:j};return i.jsxs("div",{ref:W,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",...Ye,children:[i.jsx("span",{ref:k,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[Bt]:""}),i.jsx(Oe.DirectoryTree,{ref:re,entries:Ge,expansion:{toggle:We,isExpanded:G,expandMultiple:Ue,collapseMultiple:de,isPending:Q&&!ee,doubleClickAction:c.doubleClickAction},selection:{mode:l.mode,selectedPath:l.shownPath,currentPath:l.shownPath,selectedItems:rt,onEntryClick:tt,onSelectionChange:nt},visual:{className:"aqmx-explorer-tree-view",ariaLabel:R.treeRegion,...lt,showExpandIcons:c.expandIcons,expandIconStyle:nn,showDirectoryIcons:c.directoryIcons,showFileIcons:c.fileIcons,expandIconSize:c.expandIconSize,itemHeight:v,removeRootIndent:c.removeRootIndent,highlightStyles:Yt,entryStyle:Jt,nameStyle:Qt},virtualScroll:Gt,sort:V,locale:N,labels:at})]})},cn=({pending:e,status:t})=>{const{labels:n}=y.useExplorer(),a=t.state!=="running",[c,u]=r.useState(0),o=r.useRef(!0);r.useLayoutEffect(()=>{const s=o.current;if(o.current=a,!a||e>0&&!s){u(0);return}if(e>0){u(e);return}if(c===0)return;const h=setTimeout(()=>u(0),0);return()=>clearTimeout(h)},[a,e,c]);const l=a&&e===0?c:e;return l===0&&a?null:i.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(l),"data-aqmx-expand-all":t.state,children:[l>0?i.jsx(y.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,i.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,l):n.foldersLoading(l)})]})},un=({stop:e,opened:t,budget:n})=>{const{labels:a}=y.useExplorer();return i.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:De(a,n,e,t)})},dn=({entries:e,...t})=>{const{trees:n}=y.useExplorer(),a=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:c}=t,[u]=r.useState(vt),o=r.useMemo(()=>u(e,l=>n.children(c,l)),[u,e,n,c,a]);return o.length===0?i.jsx(ln,{}):i.jsx(sn,{entries:o,version:a,...t})},fn=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:a}=y.useExplorer(),c=r.use(e);if(c.status==="deferred")return i.jsx(He,{});if(c.status==="ok")return i.jsx(dn,{entries:c.entries,...n});const u=a?.(c.failure);return i.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":c.failure.reason,children:u!==void 0?u:i.jsx(y.FailureView,{failure:c.failure,alert:!0,onRetry:t,testId:null})})},mn=({onControls:e,...t})=>{const{trees:n,storageNamespace:a,labels:c,announcer:u,config:o}=y.useExplorer(),{sourceId:l}=t,s=Oe.useDirectoryTreeState({storageKey:st.storageKeys(a).treeExpansion(l)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const h=n.read(l),f=r.useCallback(()=>n.retry(l),[n,l]);r.useLayoutEffect(()=>n.open(l),[n,l]);const d=qt(),{expanded:p,expandMultiple:x,collapseAll:g}=s,[b,T]=r.useState(null),R=b!==p,N=r.useRef(p);r.useLayoutEffect(()=>{N.current=p},[p]);const L=o.expandAll,A=r.useCallback(()=>u.announce(c.expandAllStarted),[u,c]),_=r.useCallback(P=>u.announce(an(c,L,P)),[u,c,L]),S=It({budget:L,expandMultiple:x,onStart:A,onFinish:_}),{status:E,start:k,end:v,advance:j}=S,M=E.state==="running",Y=r.useMemo(()=>({running:M,advance:j}),[M,j]),F=r.useRef(null),[Z,H]=r.useState(!1),Q=r.useCallback(P=>{F.current=P,H(P!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(P=>{const z=P.sourceId===l&&F.current!==null?Ae(F.current,P.path):null;z!==null&&u.announce({list:c.foldersLoadFailedNamed,item:z.name})}),[n,l,u,c]);const{clearDirect:$}=d,[J,B]=r.useState(0),X=r.useCallback(()=>{B(P=>P+1),v(),$(),T(N.current),g()},[v,$,g]);return r.useEffect(()=>{e({collapseAll:X,expandAll:Z?k:null,expanding:M})},[e,X,k,Z,M]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{Z||v()},[Z,v]),i.jsxs(i.Fragment,{children:[E.state==="stopped"?i.jsx(un,{stop:E.stop,opened:E.opened,budget:L}):null,i.jsxs("div",{className:"aqmx-explorer-tree-area",children:[i.jsx(r.Suspense,{fallback:i.jsx(He,{}),children:i.jsx(fn,{result:h,onRetry:f,expansion:s,onShown:Q,marks:d,claimsHeld:R,expandAll:Y,revealCancel:J,...t})}),i.jsx(cn,{pending:n.pendingChildren(l),status:E})]})]})};function pn({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const Ze=m.forwardRef(pn),je="markdown-explorer-selection-remove",hn=({selection:e,onRemove:t,onClear:n,onOpenSelection:a,onLeave:c})=>{const{labels:u}=y.useExplorer(),o=r.useId(),l=r.useRef(null),s=[...e],h=(d,p)=>{if(p.ownerDocument.activeElement===p){const x=l.current===null?[]:[...l.current.querySelectorAll(`[data-testid="${je}"]`)],g=x.indexOf(p),b=[x[g+1],x[g-1]].find(T=>T!==void 0);b===void 0?c():b.focus()}t(d)},f=()=>{const d=l.current;d!==null&&d.contains(d.ownerDocument.activeElement)&&c(),n()};return i.jsxs("section",{ref:l,className:"aqmx-explorer-tray","aria-labelledby":o,"data-testid":"markdown-explorer-selection-tray",children:[i.jsxs("div",{className:"aqmx-explorer-tray-header",children:[i.jsx("p",{id:o,className:"aqmx-explorer-tray-title",children:u.selectionTitle(s.length)}),i.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:f,children:u.clearSelection})]}),i.jsx("ul",{className:"aqmx-explorer-tray-list",children:s.map(([d,p])=>i.jsxs("li",{className:"aqmx-explorer-tray-item",children:[i.jsx("span",{className:"aqmx-explorer-tray-name",title:d,children:p}),i.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":u.removeFromSelection(p),title:u.removeFromSelection(p),"data-testid":je,"data-aqmx-path":d,onClick:x=>h(d,x.currentTarget),children:i.jsx(Ze,{"aria-hidden":"true"})})]},d))}),a===void 0?null:i.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>a(s.map(([d])=>d)),children:u.openSelectionInMulti(s.length)})]})},ue=new Map,xn=(e,t)=>{if(t.selected===e.has(t.path))return e;const n=new Map(e);return t.selected?n.set(t.path,t.name):n.delete(t.path),n},wn=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},$e=r.createContext(null),gn=e=>{const t=r.use($e);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};function En({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M15 3.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0V5.56l-3.97 3.97a.75.75 0 1 1-1.06-1.06l3.97-3.97h-2.69a.75.75 0 0 1-.75-.75Zm-12 0A.75.75 0 0 1 3.75 3h4.5a.75.75 0 0 1 0 1.5H5.56l3.97 3.97a.75.75 0 0 1-1.06 1.06L4.5 5.56v2.69a.75.75 0 0 1-1.5 0v-4.5Zm11.47 11.78a.75.75 0 1 1 1.06-1.06l3.97 3.97v-2.69a.75.75 0 0 1 1.5 0v4.5a.75.75 0 0 1-.75.75h-4.5a.75.75 0 0 1 0-1.5h2.69l-3.97-3.97Zm-4.94-1.06a.75.75 0 0 1 0 1.06L5.56 19.5h2.69a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75v-4.5a.75.75 0 0 1 1.5 0v2.69l3.97-3.97a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const bn=m.forwardRef(En);function vn({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M6.97 2.47a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.25 4.81V16.5a.75.75 0 0 1-1.5 0V4.81L3.53 8.03a.75.75 0 0 1-1.06-1.06l4.5-4.5Zm9.53 4.28a.75.75 0 0 1 .75.75v11.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 1 1 1.06-1.06l3.22 3.22V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const Rn=m.forwardRef(vn);function yn({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm13.36-1.814a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}))}const Sn=m.forwardRef(yn);function kn({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M7.72 12.53a.75.75 0 0 1 0-1.06l7.5-7.5a.75.75 0 1 1 1.06 1.06L9.31 12l6.97 6.97a.75.75 0 1 1-1.06 1.06l-7.5-7.5Z",clipRule:"evenodd"}))}const Cn=m.forwardRef(kn);function Tn({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M11.47 4.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1-1.06 1.06L12 6.31 8.78 9.53a.75.75 0 0 1-1.06-1.06l3.75-3.75Zm-3.75 9.75a.75.75 0 0 1 1.06 0L12 17.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-3.75 3.75a.75.75 0 0 1-1.06 0l-3.75-3.75a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const Ln=m.forwardRef(Tn);function jn({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M11.078 2.25c-.917 0-1.699.663-1.85 1.567L9.05 4.889c-.02.12-.115.26-.297.348a7.493 7.493 0 0 0-.986.57c-.166.115-.334.126-.45.083L6.3 5.508a1.875 1.875 0 0 0-2.282.819l-.922 1.597a1.875 1.875 0 0 0 .432 2.385l.84.692c.095.078.17.229.154.43a7.598 7.598 0 0 0 0 1.139c.015.2-.059.352-.153.43l-.841.692a1.875 1.875 0 0 0-.432 2.385l.922 1.597a1.875 1.875 0 0 0 2.282.818l1.019-.382c.115-.043.283-.031.45.082.312.214.641.405.985.57.182.088.277.228.297.35l.178 1.071c.151.904.933 1.567 1.85 1.567h1.844c.916 0 1.699-.663 1.85-1.567l.178-1.072c.02-.12.114-.26.297-.349.344-.165.673-.356.985-.57.167-.114.335-.125.45-.082l1.02.382a1.875 1.875 0 0 0 2.28-.819l.923-1.597a1.875 1.875 0 0 0-.432-2.385l-.84-.692c-.095-.078-.17-.229-.154-.43a7.614 7.614 0 0 0 0-1.139c-.016-.2.059-.352.153-.43l.84-.692c.708-.582.891-1.59.433-2.385l-.922-1.597a1.875 1.875 0 0 0-2.282-.818l-1.02.382c-.114.043-.282.031-.449-.083a7.49 7.49 0 0 0-.985-.57c-.183-.087-.277-.227-.297-.348l-.179-1.072a1.875 1.875 0 0 0-1.85-1.567h-1.843ZM12 15.75a3.75 3.75 0 1 0 0-7.5 3.75 3.75 0 0 0 0 7.5Z",clipRule:"evenodd"}))}const Nn=m.forwardRef(jn);function Pn({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M12 1.5a.75.75 0 0 1 .75.75V4.5a.75.75 0 0 1-1.5 0V2.25A.75.75 0 0 1 12 1.5ZM5.636 4.136a.75.75 0 0 1 1.06 0l1.592 1.591a.75.75 0 0 1-1.061 1.06l-1.591-1.59a.75.75 0 0 1 0-1.061Zm12.728 0a.75.75 0 0 1 0 1.06l-1.591 1.592a.75.75 0 0 1-1.06-1.061l1.59-1.591a.75.75 0 0 1 1.061 0Zm-6.816 4.496a.75.75 0 0 1 .82.311l5.228 7.917a.75.75 0 0 1-.777 1.148l-2.097-.43 1.045 3.9a.75.75 0 0 1-1.45.388l-1.044-3.899-1.601 1.42a.75.75 0 0 1-1.247-.606l.569-9.47a.75.75 0 0 1 .554-.68ZM3 10.5a.75.75 0 0 1 .75-.75H6a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 10.5Zm14.25 0a.75.75 0 0 1 .75-.75h2.25a.75.75 0 0 1 0 1.5H18a.75.75 0 0 1-.75-.75Zm-8.962 3.712a.75.75 0 0 1 0 1.061l-1.591 1.591a.75.75 0 1 1-1.061-1.06l1.591-1.592a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const On=m.forwardRef(Pn);function Mn({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5H5.625ZM7.5 15a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 7.5 15Zm.75 2.25a.75.75 0 0 0 0 1.5H12a.75.75 0 0 0 0-1.5H8.25Z",clipRule:"evenodd"}),m.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const qn=m.forwardRef(Mn);function An({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),m.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const Fn=m.forwardRef(An);function _n({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.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 In=m.forwardRef(_n);function Dn({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M19.906 9c.382 0 .749.057 1.094.162V9a3 3 0 0 0-3-3h-3.879a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H6a3 3 0 0 0-3 3v3.162A3.756 3.756 0 0 1 4.094 9h15.812ZM4.094 10.5a2.25 2.25 0 0 0-2.227 2.568l.857 6A2.25 2.25 0 0 0 4.951 21H19.05a2.25 2.25 0 0 0 2.227-1.932l.857-6a2.25 2.25 0 0 0-2.227-2.568H4.094Z"}))}const Hn=m.forwardRef(Dn);function Zn({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M10.5 3.75a6.75 6.75 0 1 0 0 13.5 6.75 6.75 0 0 0 0-13.5ZM2.25 10.5a8.25 8.25 0 1 1 14.59 5.28l4.69 4.69a.75.75 0 1 1-1.06 1.06l-4.69-4.69A8.25 8.25 0 0 1 2.25 10.5Zm8.25-3.75a.75.75 0 0 1 .75.75v2.25h2.25a.75.75 0 0 1 0 1.5h-2.25v2.25a.75.75 0 0 1-1.5 0v-2.25H7.5a.75.75 0 0 1 0-1.5h2.25V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const $n=m.forwardRef(Zn);function Bn({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M5.625 3.75a2.625 2.625 0 1 0 0 5.25h12.75a2.625 2.625 0 0 0 0-5.25H5.625ZM3.75 11.25a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75ZM3 15.75a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75ZM3.75 18.75a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75Z"}))}const zn=m.forwardRef(Bn),xe=e=>{e.preventDefault(),e.stopPropagation()},Vn=Object.freeze({sortMode:Rn,folderPlacement:In,selectionMode:Sn,doubleClickAction:On,expandIconSize:$n,alwaysExpanded:bn,revealDocument:Fn,removeRootIndent:Cn,lines:zn,expandIcons:Ln,directoryIcons:Hn,fileIcons:qn}),Be=(e,t)=>{const n=e[t.labelKey];if(typeof n!="string")throw new TypeError(`[markdown-explorer] the tree setting ${t.key} must name a string label; labels.${t.labelKey} is a ${typeof n}`);return n},Kn=({id:e,settings:t,descriptors:n,onAdvance:a,onClose:c,ref:u})=>{const{labels:o}=y.useExplorer(),l=r.useRef([]);r.useEffect(()=>{l.current[0]?.focus()},[]);const s=r.useCallback(f=>{const d=n.length;l.current[(f%d+d)%d]?.focus()},[n.length]),h=r.useCallback((f,d)=>{switch(f.key){case"ArrowDown":f.preventDefault(),s(d+1);break;case"ArrowUp":f.preventDefault(),s(d-1);break;case"Home":f.preventDefault(),s(0);break;case"End":f.preventDefault(),s(n.length-1);break;case"Escape":xe(f),c();break;case"Tab":c();break}},[n.length,s,c]);return i.jsx("div",{ref:u,id:e,role:"menu","aria-label":o.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((f,d)=>{const p=Vn[f.key],x=Be(o,f),g=O.formatTreeSettingValue(o,t,f.key),b=t[f.key],T=typeof b=="boolean"?{role:"menuitemcheckbox","aria-checked":b,"aria-label":x}:{role:"menuitem","aria-label":`${x}: ${g}`};return i.jsxs("button",{ref:R=>{l.current[d]=R},type:"button",tabIndex:-1,...T,title:`${x}: ${g}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":f.key,onClick:()=>a(f),onKeyDown:R=>h(R,d),children:[i.jsx(p,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),i.jsx("span",{className:"aqmx-explorer-menu-name",children:x}),i.jsx("span",{className:"aqmx-explorer-menu-value",children:g})]},f.key)})})},Xn=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:a,announcer:c}=y.useExplorer(),[u,o]=r.useState(!1),l=r.useRef(null),s=r.useRef(null),h=r.useRef(null),f=r.useId(),d=r.useCallback(()=>{l.current?.focus(),o(!1)},[]);r.useEffect(()=>{if(!u)return;const g=b=>{b.target instanceof Node&&(l.current?.contains(b.target)===!0||s.current?.contains(b.target)===!0)||(o(!1),h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{h.current=null,(document.activeElement===null||document.activeElement===document.body)&&l.current?.focus()},0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[u]),r.useEffect(()=>()=>{h.current!==null&&window.clearTimeout(h.current)},[]);const p=r.useCallback(g=>{g.key!=="Escape"||!u||(xe(g),d())},[u,d]),x=r.useCallback(g=>{const b=n(g.key);c.announce(a.settingAnnouncement(Be(a,g),O.formatTreeSettingValue(a,b,g.key)))},[c,a,n]);return{trigger:i.jsx("button",{ref:l,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":u,"aria-controls":u?f:void 0,"aria-label":a.treeSettings,title:a.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>o(g=>!g),onKeyDown:p,children:i.jsx(Nn,{"aria-hidden":"true"})}),menu:u?i.jsx(Kn,{ref:s,id:f,settings:e,descriptors:t,onAdvance:x,onClose:d}):null}},Wn=()=>{const{treeSettings:e}=y.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},Ne=new Set,Un='[role="tree"] [role="treeitem"][tabindex="0"]',Gn="[data-directory-tree-tab-stop]",Yn=e=>{const{mode:t,sourceId:n,currentPath:a,openPaths:c,onOpenDocument:u,onSourceChange:o,viewSwitch:l}=e,{labels:s,sources:h,trees:f,documents:d,announcer:p}=y.useExplorer(),{settings:x,advance:g}=Wn(),b=r.useMemo(()=>O.visibleTreeSettingDescriptors(t==="tree"),[t]),T=t==="tree"&&x.selectionMode==="multiple";gn(T);const R=e.mode==="tree"?e.tray.onGatheredChange:null,N=e.mode==="tree"?e.onOpenSelection:void 0,L=e.mode==="tree"&&T?e.tray.gathered:ue,A=r.useCallback(C=>{const V=g(C);return V.selectionMode!=="multiple"&&R?.(ue),V},[g,R]),_=Xn({settings:x,descriptors:b,onAdvance:A}),S=r.useCallback(C=>R?.(V=>xn(V,C)),[R]),E=r.useCallback(C=>R?.(V=>wn(V,C)),[R]),k=r.useCallback(()=>R?.(ue),[R]),v=r.useRef(null),j=r.useCallback(()=>{const C=v.current;if(C===null)return;[Un,Gn,'[data-testid="markdown-explorer-tree-settings"]'].map(I=>C.querySelector(I)).find(I=>I!==null)?.focus()},[]),M=r.useMemo(()=>new Set(L.keys()),[L]),Y=r.useMemo(()=>a===null?Ne:new Set([a]),[a]),F=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:c,shownPath:null,onChange:null};switch(x.selectionMode){case"single":return{mode:"single",items:Y,shownPath:a,onChange:null};case"multiple":return{mode:"multiple",items:M,shownPath:a,onChange:S};case"none":return{mode:"none",items:Ne,shownPath:null,onChange:null}}},[t,c,x.selectionMode,Y,a,M,S]),Z=r.useMemo(()=>x.revealDocument?{path:a,openFolders:!0}:{path:F.shownPath,openFolders:!1},[x.revealDocument,a,F.shownPath]),[H,Q]=r.useState(null),[$,J]=r.useState(!1),[B,X]=r.useState(null),P=r.useRef(!1),z=r.useCallback(async()=>{if(!P.current){P.current=!0,J(!0),X(null);try{const C=await f.refresh(n);if(C.status==="superseded")return;d.invalidate(),C.status==="failed"?X({sourceId:n,failure:C.failure}):p.announce(s.treeRefreshed)}finally{P.current=!1,J(!1)}}},[f,d,n,p,s]),ne=H===null?null:H.expandAll,ee=H?.expanding===!0,le=h.find(C=>C.id===n),re=l.target==="multi"?wt:ht,W=l.target==="multi"?s.switchToMulti:s.switchToTree;return i.jsxs("nav",{ref:v,"aria-label":s.explorerRegion,className:"aqmx-explorer","data-testid":"markdown-explorer-explorer","data-aqmx-mode":t,children:[i.jsxs("div",{className:"aqmx-explorer-header",children:[h.length>1?i.jsx("select",{className:"aqmx-explorer-source","aria-label":s.sourceLabel,title:le?.label,value:n,onChange:C=>o(C.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:h.map(C=>i.jsx("option",{value:C.id,children:C.label},C.id))}):null,i.jsxs("div",{className:"aqmx-explorer-actions",children:[i.jsx(y.ExplorerLink,{to:l.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":W,title:W,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":l.target,children:i.jsx(re,{"aria-hidden":"true"})}),i.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:s.refreshTree,"aria-disabled":$,"aria-busy":$,"data-aqmx-busy":$?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{z()},children:[i.jsx(y.ForwardRef,{"aria-hidden":"true"}),i.jsx("span",{children:s.refreshTreeLabel})]}),i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":s.expandAll,title:s.expandAll,"aria-disabled":ne===null||ee,"aria-busy":ee,"data-aqmx-busy":ee?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>ne?.(),children:i.jsx(mt,{"aria-hidden":"true"})}),i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":s.collapseAll,title:s.collapseAll,"aria-disabled":H===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>H?.collapseAll(),children:i.jsx(dt,{"aria-hidden":"true"})}),_.trigger]})]}),i.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[B!==null&&B.sourceId===n?i.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":B.failure.reason,children:s.treeRefreshFailed(y.failureTitleOf(s,B.failure.reason))}):null,i.jsx(r.Suspense,{fallback:null,children:i.jsx(gt,{})}),i.jsx(mn,{mode:t,sourceId:n,settings:x,reveal:Z,openPaths:c,selection:F,onOpenDocument:u,onControls:Q},n),T&&L.size>0?i.jsx(hn,{selection:L,onRemove:E,onClear:k,onOpenSelection:N,onLeave:j}):null,_.menu]})]})},ze="(pointer: coarse)",Qn=e=>{const t=window.matchMedia(ze);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},Jn=()=>window.matchMedia(ze).matches,er=()=>!1,tr=()=>r.useSyncExternalStore(Qn,Jn,er);function nr({title:e,titleId:t,...n},a){return m.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:a,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M3 6.75A.75.75 0 0 1 3.75 6h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 6.75ZM3 12a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 12Zm0 5.25a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75Z",clipRule:"evenodd"}))}const rr=m.forwardRef(nr),ar=({explorer:e,toggleRef:t,covered:n,onNoticeSlotChange:a,dismissals:c})=>{const{labels:u}=y.useExplorer(),o=ct.useLocation(),{location:l}=y.useExplorerLocation(),[s,h]=r.useState(!1),[f,d]=r.useState({navigated:o,source:l.source}),[p,x]=r.useState(!1);f.navigated!==o&&(d({navigated:o,source:l.source}),f.source===l.source&&!p&&h(!1));const[g,b]=r.useState(c);g!==c&&(b(c),h(!1));const T=r.useRef(null),R=r.useRef(null),N=r.useRef(null),L=r.useRef(!1),A=r.useId();r.useLayoutEffect(()=>{const v=T.current;v!==null&&(s&&!v.open?(v.showModal(),R.current?.focus()):!s&&v.open&&(v.close(),t.current?.focus()),a(s?N.current:null))},[s,t,a]),r.useLayoutEffect(()=>()=>a(null),[a]);const _=r.useCallback(v=>{v.key!=="Escape"||v.defaultPrevented||(xe(v),h(!1))},[]),S=r.useCallback(v=>{L.current=v.target===v.currentTarget},[]),E=r.useCallback(v=>{const j=L.current;L.current=!1,j&&v.target===v.currentTarget&&h(!1)},[]),k=r.useCallback(()=>{h(!1)},[]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"aqmx-sheet-bar",inert:n,children:i.jsxs("button",{ref:t,type:"button",className:"aqmx-sheet-toggle","aria-haspopup":"dialog","aria-expanded":s,"aria-controls":A,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>h(!0),children:[i.jsx(rr,{"aria-hidden":"true"}),i.jsx("span",{children:u.showExplorer})]})}),i.jsx("dialog",{ref:T,id:A,className:"aqmx-sheet","aria-label":u.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:_,onPointerDown:S,onClick:E,onClose:k,children:i.jsxs("div",{className:"aqmx-sheet-panel",children:[i.jsxs("div",{className:"aqmx-sheet-header",children:[i.jsx("div",{ref:N,className:"aqmx-sheet-notice-slot"}),i.jsx("button",{ref:R,type:"button",className:"aqmx-sheet-close","aria-label":u.hideExplorer,title:u.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>h(!1),children:i.jsx(Ze,{"aria-hidden":"true"})})]}),i.jsx("div",{className:"aqmx-sheet-body",children:i.jsx(he,{value:s,children:i.jsx($e,{value:x,children:e})})}),i.jsx(y.LiveRegion,{holds:s,testId:"markdown-explorer-sheet-announcer"})]})})]})},Ve=r.createContext(null),we="aqmx-explorer",Ke="aqmx-content",ge='[role="tree"] [role="treeitem"]',lr=`${ge}[tabindex="0"]`,or="[data-directory-tree-tab-stop]",sr=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${we}"] ${ge}`))if(n.getAttribute(te)===t)return n;return null},Pe=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:O.ASSUMED_ROOT_FONT_PIXELS}),cr=(e,t)=>{const[n,a]=r.useState(()=>Pe(0,0));return r.useLayoutEffect(()=>{const c=e.current,u=t.current;if(c===null||u===null)throw new Error("[markdown-explorer] the split frame is not mounted");const o={frame:c.getBoundingClientRect().width,rem:u.getBoundingClientRect().width},l=()=>{const h=Pe(o.frame,o.rem);a(f=>f.inlineSize===h.inlineSize&&f.rootFontPixels===h.rootFontPixels?f:h)};l();const s=new ResizeObserver(h=>{for(const f of h){const[d]=f.borderBoxSize;d!==void 0&&(f.target===c&&(o.frame=d.inlineSize),f.target===u&&(o.rem=d.inlineSize))}l()});return s.observe(c),s.observe(u),()=>s.disconnect()},[e,t]),n},Xe=e=>`aqmx-split-handle-${e}`,ir=(e,{frameRef:t,sheetToggleRef:n,handleId:a})=>{const c=r.useRef(!1),u=r.useRef(null),o=r.useRef(!1);r.useLayoutEffect(()=>{const s=t.current;if(s===null)throw new Error("[markdown-explorer] the split frame is not mounted");const h=d=>{const p=d.target instanceof Element?d.target:null;c.current=p!==null&&p.closest(`[data-panel-id="${Ke}"]`)===null,!o.current&&(u.current=p?.closest(`${ge}[${te}]`)?.getAttribute(te)??null)},f=d=>{d.relatedTarget instanceof Node&&!s.contains(d.relatedTarget)&&(c.current=!1)};return s.addEventListener("focusin",h),s.addEventListener("focusout",f),()=>{s.removeEventListener("focusin",h),s.removeEventListener("focusout",f)}},[t]);const l=r.useRef(e);r.useLayoutEffect(()=>{if(l.current===e)return;l.current=e;const s=t.current;if(s===null||!c.current)return;const h=f=>{const{activeElement:d,body:p}=s.ownerDocument;if(d!==null&&d!==p)return;const x=f.find(g=>g!==null);if(x!=null){o.current=!0;try{x.focus()}finally{o.current=!1}}};if(e){h([n.current]);return}queueMicrotask(()=>{if(l.current!==e||!c.current)return;const f=u.current,d=`[data-panel-id="${we}"]`;h([f===null?null:sr(s,f),s.querySelector(`${d} ${lr}`),s.querySelector(`${d} ${or}`),s.querySelector(`[data-resize-handle-id="${a}"]`)])})},[e,t,n,a])},ur=({view:e,explorer:t,content:n,contentCoversPage:a=!1,sheetDismissals:c=0,onDraggingChange:u})=>{const o=r.useRef(null),[l,s]=r.useState(null),h=r.useRef(null),f=r.useRef(null),{inlineSize:d,rootFontPixels:p}=cr(o,h),x=d!==null&&d<O.explorerSheetBelowPixels(p);return ir(x,{frameRef:o,sheetToggleRef:f,handleId:Xe(e)}),i.jsxs("div",{ref:o,className:"aqmx-split-frame","data-aqmx-explorer-mode":x?"sheet":"split",children:[i.jsx("span",{ref:h,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),x?i.jsx(ar,{explorer:t,toggleRef:f,covered:a,onNoticeSlotChange:s,dismissals:c}):null,i.jsx(Ve,{value:x?l:null,children:i.jsx(dr,{view:e,sheet:x,explorer:t,content:n,contentCoversPage:a,onDraggingChange:u,explorerMinPixels:O.explorerMinPixels(p)})})]})},dr=({view:e,sheet:t,explorer:n,content:a,contentCoversPage:c,onDraggingChange:u,explorerMinPixels:o})=>{const{viewSettings:l,labels:s}=y.useExplorer(),f=y.useViewSetting(E=>e==="tree"?E.treeExplorer:E.multiExplorer)??(e==="tree"?O.EXPLORER_DEFAULT_PERCENT:O.EXPLORER_MULTI_DEFAULT_PERCENT),d=r.useRef(null),p=r.useRef(null),x=r.useRef(!1),g=r.useRef(!1),[b,T]=r.useState(!1),R=r.useRef(u);r.useLayoutEffect(()=>{R.current=u},[u]);const N=r.useCallback(()=>{const E=d.current;if(E===null||E.length!==2)return;const[k=0,v=0]=E,j=k+v;if(j<=0||k<=0)return;const M=Math.min(O.EXPLORER_MAX_PERCENT,k/j*100);l.update(e==="tree"?{treeExplorer:M}:{multiExplorer:M})},[l,e]),L=r.useCallback(()=>{p.current!==null&&clearTimeout(p.current),p.current=setTimeout(()=>{p.current=null,N()},O.EXPLORER_WIDTH_PERSIST_DELAY_MS)},[N]);r.useEffect(()=>()=>{p.current!==null&&clearTimeout(p.current),g.current&&R.current?.(!1)},[]);const A=tr(),_=r.useCallback((E,k)=>{d.current=E;const[v=0,j=0]=E;E.length===2&&j>0&&T(v<=0),k.source==="keyboard"?L():k.source==="pointer"&&(x.current=!0)},[L]),S=r.useCallback(E=>{if(g.current=E,u?.(E),E){x.current=!1;return}x.current&&(x.current=!1,L())},[u,L]);return i.jsxs(ie.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:_,className:"aqmx-split","data-aqmx-split":e,children:[t?null:i.jsx(ie.Panel,{id:we,defaultSize:{value:f,unit:"percentage"},minSize:{value:o,unit:"pixels"},maxSize:{value:O.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:c,className:"aqmx-split-explorer",children:i.jsx(he,{value:!b,children:n})}),t?null:i.jsx(ie.PanelResizeHandle,{id:Xe(e),thickness:A?O.COARSE_TARGET_PIXELS:O.FINE_TARGET_PIXELS,indicator:{visible:!0,thickness:O.SPLIT_HANDLE_PIXELS.gripThickness,length:O.SPLIT_HANDLE_PIXELS.gripLength,barThickness:O.SPLIT_HANDLE_PIXELS.barThickness,barLength:O.SPLIT_HANDLE_PIXELS.barLength},title:s.resizeExplorer,"aria-label":s.resizeExplorer,onDragging:S,inert:c,className:"aqmx-split-handle"}),i.jsx(ie.Panel,{id:Ke,defaultSize:{value:100-f,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...c?{style:{isolation:"auto"}}:{},children:a})]})};exports.EMPTY_SELECTION=ue;exports.ExplorerPane=Yn;exports.ExplorerSplit=ur;exports.SheetNoticeSlotContext=Ve;
|