@aiquants/markdown-explorer 0.35.0 → 0.36.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 +93 -0
- package/README.md +31 -2
- package/dist/{EditSurface-CLG70Vnn.cjs → EditSurface-B70iRFkG.cjs} +1 -1
- package/dist/{EditSurface-D2j1kCEE.js → EditSurface-BCFJRyIM.js} +5 -5
- package/dist/{ExplorerSplit-D_0VohOv.cjs → ExplorerSplit-BNrHrIus.cjs} +1 -1
- package/dist/{ExplorerSplit-CfP1smbT.js → ExplorerSplit-Bgccz2nm.js} +77 -77
- package/dist/{MultiLayout-CxV5SI7f.cjs → MultiLayout-Bo9LAXiY.cjs} +1 -1
- package/dist/{MultiLayout-BeJ5Lubb.js → MultiLayout-Dy5TIC2t.js} +4 -4
- package/dist/{NativeScrollBar-RWXpVhbI.cjs → NativeScrollBar-Bj-LKej0.cjs} +1 -1
- package/dist/{NativeScrollBar-BM5NULzg.js → NativeScrollBar-DpZMYhmf.js} +2 -2
- package/dist/TreeLayout-DsSKW_Qj.js +103 -0
- package/dist/TreeLayout-T8sc_wg7.cjs +1 -0
- package/dist/core/config.d.cts +6 -0
- package/dist/core/config.d.ts +6 -0
- package/dist/core/contracts.d.cts +21 -0
- package/dist/core/contracts.d.ts +21 -0
- package/dist/core/dataRoute.d.cts +5 -1
- package/dist/core/dataRoute.d.ts +5 -1
- package/dist/core/documentId.d.cts +6 -0
- package/dist/core/documentId.d.ts +6 -0
- package/dist/core/labels.d.cts +10 -0
- package/dist/core/labels.d.ts +10 -0
- package/dist/core/location.d.cts +21 -0
- package/dist/core/location.d.ts +21 -0
- package/dist/explorerCore-B3RGmMG6.js +1083 -0
- package/dist/explorerCore-CUkyKtm8.cjs +1 -0
- package/dist/{index-C1YMH-yI.js → index-D0l_BJqb.js} +2536 -2372
- package/dist/index-lpL7GltU.cjs +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +38 -33
- package/dist/location-Dh6K-y7w.js +761 -0
- package/dist/location-DrOP6t1F.cjs +1 -0
- package/dist/{merge-Bb_HpPhe.js → merge-BwcqBd4c.js} +1 -1
- package/dist/{merge-DQUYEGCx.cjs → merge-Dckw7r9T.cjs} +1 -1
- package/dist/ownUrls-BTPGNhBt.cjs +1 -0
- package/dist/ownUrls-DD0cSCsF.js +409 -0
- package/dist/{sanitizeJob-BYRk17nr.js → sanitizeJob-BYqzjFJC.js} +1 -1
- package/dist/{sanitizeJob-Cs9o3Vpl.cjs → sanitizeJob-CudE1RUP.cjs} +1 -1
- package/dist/{sanitizePolicy-CiQfnxyd.cjs → sanitizePolicy-C-ehd0J_.cjs} +1 -1
- package/dist/{sanitizePolicy-CEMdaLUB.js → sanitizePolicy-DAPnUUVm.js} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +3 -3
- package/dist/{sanitizerService-KWXv7bPm.js → sanitizerService-B8v4ap9t.js} +1 -1
- package/dist/{sanitizerService-BY4CPCoA.cjs → sanitizerService-DomN7lwC.cjs} +1 -1
- package/dist/server/errors.d.cts +1 -1
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/ports.d.cts +19 -0
- package/dist/server/ports.d.ts +19 -0
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +6 -6
- package/dist/serverBrowser.cjs +1 -1
- package/dist/serverBrowser.js +3 -3
- package/dist/serverCore.cjs +1 -1
- package/dist/serverCore.d.cts +1 -1
- package/dist/serverCore.d.ts +1 -1
- package/dist/serverCore.js +4 -4
- package/dist/{tapScrollCircle-DdX0Wri0.cjs → tapScrollCircle-DyLInGck.cjs} +1 -1
- package/dist/{tapScrollCircle-BEydRn0y.js → tapScrollCircle-smKLgRa2.js} +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +5 -0
- package/dist/testing.d.ts +5 -0
- package/dist/testing.js +80 -2
- package/dist/{useSplitPersistence-B2Fj508K.cjs → useSplitPersistence-BUa_KMsV.cjs} +1 -1
- package/dist/{useSplitPersistence-Fkqak8G8.js → useSplitPersistence-pnb21dsr.js} +1 -1
- package/docs/behavior/dom-hooks.md +3 -1
- package/docs/behavior/security.md +23 -2
- package/docs/behavior/url-contract.md +26 -0
- package/package.json +2 -2
- package/dist/TreeLayout-AxLw-36S.js +0 -103
- package/dist/TreeLayout-Bg2YH-EY.cjs +0 -1
- package/dist/explorerCore-DLpDuSev.js +0 -998
- package/dist/explorerCore-DYrxS9ez.cjs +0 -1
- package/dist/index-LQWQfpAf.cjs +0 -18
- package/dist/location--KvTA0Ri.js +0 -726
- package/dist/location-D8DyDkuA.cjs +0 -1
- package/dist/ownUrls-B259RGgd.cjs +0 -1
- package/dist/ownUrls-Dh5g6ZJi.js +0 -370
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,98 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.36.0 (2026-11-12) — Document IDs: a permalink that keeps opening its document when the document's path changes
|
|
4
|
+
|
|
5
|
+
### Breaking
|
|
6
|
+
|
|
7
|
+
- **Two exported types gain what document IDs add (hosts, types only).** `ExplorerLocationResult` (what
|
|
8
|
+
`resolveExplorerLocation` answers) has a third kind, `{ kind: "document-id", id, opens, location }`, which the
|
|
9
|
+
resolver answers only with `documentIds` in the configuration: a host that switches over `kind` exhaustively needs a
|
|
10
|
+
case for it (its `location` is the one to draw meanwhile). `ExplorerPageData` carries a required `documentId`, `null`
|
|
11
|
+
on every page but an ID URL's that does not open (the explorer's loader writes it): a host that builds page data
|
|
12
|
+
itself, for its own tests for example, adds `documentId: null`. Without `documentIds` nothing changes at run time.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **Document IDs and their URLs (hosts, readers).** With `documentIds: { slug }` in `defineExplorerConfig`,
|
|
17
|
+
`{basePath}/{slug}/{ID}` opens the document an ID names in the tree view and `{basePath}/{slug}/{ID}/{views.single}`
|
|
18
|
+
in the single view, with the URL's `style` and `align` and, in the single view, its embedding parameters. The slug
|
|
19
|
+
follows the view slugs' rule and differs from every view slug and from `dataPath`'s first segment under `basePath`;
|
|
20
|
+
without the option it stays an unknown view slug.
|
|
21
|
+
The page loader answers an ID the reader can open with a `302` to the document's path URL, under the source that
|
|
22
|
+
admits it, with `Cache-Control: private, no-store` (never `301` or `308`, which a browser keeps while the path an ID
|
|
23
|
+
names changes when its document moves), and any other ID with the page of the default source's tree,
|
|
24
|
+
`documentId: { id, failure }` in the page data and the failure's status (`invalid` 400 for an ID written wrong,
|
|
25
|
+
`not-found` 404, `forbidden` 403, `failed` 500), never naming the path. A navigation inside the explorer to an ID URL
|
|
26
|
+
shows the document's skeleton, resolves the ID through the data route's new `resolve-id` operation and replaces the
|
|
27
|
+
URL with the path URL, keeping its fragment; a failure shows in the document's place
|
|
28
|
+
(`markdown-explorer-document-id-failure`, with `data-aqmx-failure`), with Try again for `failed` only.
|
|
29
|
+
- **The ID (hosts).** 12 symbols of Crockford's Base32: 11 random symbols the server draws from Web Crypto and a mod-37
|
|
30
|
+
check symbol, kept inside the alphabet by drawing again a body whose remainder is 32 or more. `DOCUMENT_ID_ALPHABET`,
|
|
31
|
+
`DOCUMENT_ID_LENGTH`, `isCanonicalDocumentId` (the canonical form), `parseDocumentId` (a reader's writing: hyphens,
|
|
32
|
+
lowercase, `I`, `L` and `O`; a character outside ASCII is refused before any case is raised) and `groupDocumentId`
|
|
33
|
+
(`7K3M-9QX2-AB4W`) are exported from `.`; `explorerHref` writes an ID URL from
|
|
34
|
+
`{ view: "document-id", id, opens?, overrides?, embed? }`, and `ExplorerDocumentIdOpening` names how the document
|
|
35
|
+
opens. `documentIdVectors()` and `DocumentIdVector` of `./testing` list the answers `parseDocumentId` owes, for a
|
|
36
|
+
host's registry and for an implementation of the rule in another language.
|
|
37
|
+
- **Copy permalink (readers).** With `documentIds`, the bar of a document that is not edited offers Copy permalink after
|
|
38
|
+
Refresh document, from the server's render on and unavailable (`aria-disabled`) while the document loads or failed,
|
|
39
|
+
so the bar's buttons keep their places: a press asks the new `issue-id` operation for the document's ID
|
|
40
|
+
(issued on the first press, the same ID ever after) and copies its ID URL, absolute and with the router's basename,
|
|
41
|
+
in the form of the current view (the single view's with its overrides and embedding parameters, the tree view's with
|
|
42
|
+
its overrides, a multi-view panel's as the tree view's). The write starts inside the press, as Safari requires, with
|
|
43
|
+
a `ClipboardItem` whose text the ID URL fulfils, and the outcome is announced and shown as the other copies' are,
|
|
44
|
+
with the ID grouped or with why nothing was copied (`markdown-explorer-document-permalink`,
|
|
45
|
+
`data-aqmx-copy-outcome`). New labels, in English and Japanese: `copyPermalink`, `copyPermalinkLabel`,
|
|
46
|
+
`copyPermalinkNamed`, `permalinkCopied`, `permalinkCopyFailed`, `permalinkClipboardRefused`,
|
|
47
|
+
`documentIdFailedTitle`, `documentIdInvalid`, `documentIdNotFound` and `documentIdForbidden`.
|
|
48
|
+
- **The registry of document IDs (hosts).** `createMarkdownExplorer` takes `documentIds`
|
|
49
|
+
(`ExplorerDocumentIdPorts`) exactly when the configuration has `documentIds` (either alone throws a `TypeError`):
|
|
50
|
+
`issue(context, path, candidate)` answers an `ExplorerDocumentIdIssue` (`issued`, `existing` with the path's ID, or
|
|
51
|
+
`taken`) and `resolve(context, id)` an `ExplorerDocumentIdBinding` (`bound` with a path, or `unbound`). The explorer
|
|
52
|
+
draws every candidate (up to 4 per issue), checks the reader before it calls a port — the deny rules, the sources'
|
|
53
|
+
boundaries and the document's existence through `asset`, without opening its bytes —, hands the registry the
|
|
54
|
+
document path (never a source's `readPath`), and checks every answer: a broken one is logged and answered `failed`.
|
|
55
|
+
`issue-id` (`POST`) needs `X-Markdown-Explorer: document-id` and the cross-origin check of a refresh, before the
|
|
56
|
+
reader is authenticated; `resolve-id` (`GET`, `HEAD`) takes the canonical form only. Unlike a document request, both
|
|
57
|
+
answer a failure with its own status, and without the ports both answer as unknown operations (404).
|
|
58
|
+
|
|
59
|
+
### Tests
|
|
60
|
+
|
|
61
|
+
- `tests/unit/documentId.test.ts`: the ID's alphabet, the drawing (the redraw of a body whose check value is 32 or
|
|
62
|
+
more included), the canonical check, the lenient reading and the grouping, against the table of
|
|
63
|
+
`tests/fixtures/document-id-vectors.json` that `./testing` ships.
|
|
64
|
+
- `tests/server/documentIdOperations.test.ts` (a runtime-independent suite): the ports' assembly, `issue-id` (the
|
|
65
|
+
method, the proof and the cross-origin check before authentication, the path checks before the registry, the
|
|
66
|
+
`readPath` the registry never sees, the redraw of `taken` candidates and its limit, broken answers, `ExplorerError`
|
|
67
|
+
and other exceptions), `resolve-id` (the method, canonical IDs only, the disclosure table, broken bindings) and the
|
|
68
|
+
page loader's redirects and failure pages.
|
|
69
|
+
- `tests/components/documentIdUrl.test.tsx` (an ID URL inside the explorer: the skeleton, the replacing navigation
|
|
70
|
+
that keeps the fragment, the failures and their Try again, the cancellation on a change of URL, the failures the
|
|
71
|
+
loader answered), `tests/components/documentPermalink.test.tsx` (Copy permalink: when the bar holds it and when it
|
|
72
|
+
is unavailable, its names, the write inside the press, the forms of the three views and the basename, the issue's
|
|
73
|
+
failure and the browser's refusal, the latest press deciding) and
|
|
74
|
+
`tests/components/documentPermalinkHydration.test.tsx` (the unavailable button the server draws while the document
|
|
75
|
+
streams, the hydration without a mismatch or a request, and the same button acting once the document opens, with the
|
|
76
|
+
served buttons keeping their order at the row's end).
|
|
77
|
+
- `location`, `settings`, `labels`, `dataClient` and `entryPurity` cover the ID URLs, the `documentIds` option, the new
|
|
78
|
+
labels, the client's `issueId` and `resolveId`, and the `./testing` entry's second table.
|
|
79
|
+
- `tests/e2e/document-ids.spec.ts` (Chromium), on the demo's registry of document IDs (`demo/app/document-ids.server.ts`,
|
|
80
|
+
which the demo's `/docs` explorer now has under `/docs/d/<ID>`): Copy permalink through the real clipboard, the
|
|
81
|
+
loader's `302` with `private, no-store` in the tree and single views with the fragment kept, and the pages of an ID
|
|
82
|
+
written wrong, one no document has and one bound to a path no source admits (the status, the failure in the
|
|
83
|
+
document's place, no second request, no Copy permalink, no path).
|
|
84
|
+
|
|
85
|
+
### Documentation
|
|
86
|
+
|
|
87
|
+
- README: `documentIds` in the configuration, the ID URLs in Views and URLs, the `documentIds` ports in the Server API
|
|
88
|
+
table, a Document IDs section (issue, resolve, the answers' checks, erasing and moving), the security model and the
|
|
89
|
+
demo's registry.
|
|
90
|
+
- `docs/behavior/url-contract.md`: the ID URLs in the shape and canonical-form tables and a Document IDs section (the
|
|
91
|
+
ID, writing and reading, the page loader, the browser, Copy permalink). `docs/behavior/security.md`: a Document IDs
|
|
92
|
+
section (an ID is not a permission, the disclosure table, `resolve-id`, `issue-id`, the answers' checks), the ID
|
|
93
|
+
operations' statuses, and what the host's registry must keep. `docs/behavior/dom-hooks.md`:
|
|
94
|
+
`markdown-explorer-document-permalink` and `markdown-explorer-document-id-failure`.
|
|
95
|
+
|
|
3
96
|
## 0.35.0 (2026-11-10) — The server half runs in the page on a browser runtime, a host drives the explorer through props and a handle, and each document carries its language
|
|
4
97
|
|
|
5
98
|
### Breaking
|
package/README.md
CHANGED
|
@@ -106,9 +106,10 @@ The source ids are not part of it: they are the ids of the server's `sources` (a
|
|
|
106
106
|
| Option | Type | Purpose |
|
|
107
107
|
| --- | --- | --- |
|
|
108
108
|
| `basePath` | `string` | Page mount, with a leading slash and no trailing slash (for example `/docs`). |
|
|
109
|
-
| `dataPath` | `string` | Data route mount in the same form; it differs from `basePath` and does not start with a view slug under it. |
|
|
109
|
+
| `dataPath` | `string` | Data route mount in the same form; it differs from `basePath` and does not start with a view slug or `documentIds.slug` under it. |
|
|
110
110
|
| `settingsCookie` | `string` | Name of the display-preference cookie (an RFC 6265 token). |
|
|
111
111
|
| `views?` | `{ tree?, multi?, single? }` | URL slugs of the views; each defaults to its view's name. |
|
|
112
|
+
| `documentIds?` | `{ slug }` | Document IDs (see [Document IDs](#document-ids)): `slug` is the URL segment under `basePath` that opens a document by its ID (`{basePath}/{slug}/{ID}`), written as a view slug is (letters, digits, `_` and `-`, starting with a letter or digit) and unlike every view slug. The server then needs the `documentIds` ports, and without the option it takes none; none when omitted. |
|
|
112
113
|
| `multiView?` | `{ maxPanels?, columns? }` | The panel limit (1–64, default 12) and the logical column count (1–6, default 4). |
|
|
113
114
|
| `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`. |
|
|
114
115
|
| `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)). |
|
|
@@ -309,6 +310,7 @@ to; load it when your documents contain math.
|
|
|
309
310
|
| Tree | `{basePath}/{tree}`, `{basePath}/{tree}/{document}` or `{basePath}/{tree}/{folder}/` | The source tree beside the selected document, or the selected folder's README |
|
|
310
311
|
| Multi-panel | `{basePath}/{multi}?doc=…&doc=…&maximized=…&markup=…` | Several documents as panels in columns |
|
|
311
312
|
| Single | `{basePath}/{single}/{document}` | One document over the whole frame (for reading and embedding) |
|
|
313
|
+
| Document ID | `{basePath}/{documentIds.slug}/{ID}` or `{basePath}/{documentIds.slug}/{ID}/{single}` | Nothing of its own: with `documentIds` in the configuration, it sends the reader to the path URL of the document its ID names, in the tree or the single view |
|
|
312
314
|
|
|
313
315
|
- `?source=<id>` selects the tree's source among the server's sources; the first source is the default and is written by omission. Switching the source never closes open documents — a document path names one document whichever trees list it.
|
|
314
316
|
- A document path occupies one URL segment. Build links with `explorerHref(config, target)`, the only function that writes explorer URLs; read them back with `resolveExplorerLocation(config, splat, search)`. Both need the server's source ids for the `source` parameter: pass a configuration joined with them, `withExplorerSources(config, sourceIds)` (`ExplorerLocationConfig`; `isExplorerSourceId` is the id rule, and an empty, invalid or repeated id throws a `RangeError`).
|
|
@@ -319,6 +321,8 @@ to; load it when your documents contain math.
|
|
|
319
321
|
- `markup` names the Markdown documents, SVG images and table files shown as written (the Source toggle): `markup=true` for the tree or single view's document, and one `markup=<document>` per open document shown that way in the multi view, in the order of `doc`. In `ExplorerLocation` it is a boolean in the tree and single views and a list in the multi view; a target without it shows every document rendered.
|
|
320
322
|
- `maximized` says what fills the page: `maximized=true` for the tree view's document or folder README (the Maximize button at the end of the document's bar; see [The maximized document](docs/behavior/layout.md#the-maximized-document)), and `maximized=<document>` for the open document whose panel is maximized in the multi view. In `ExplorerLocation` it is a boolean in the tree view and a document or `null` in the multi view; the single view, whose frame is the page already, has none.
|
|
321
323
|
The tree view's maximize stays through a source switch and the document links and table-of-contents entries it follows (their hrefs never carry it); a pick in the tree and a switch between the views drop it.
|
|
324
|
+
- With `documentIds` in the configuration, a document's bar offers **Copy permalink** (unavailable while the document loads or failed), which copies the document's ID URL in the form of the current view: an ID the server issues on the first press (12 symbols of Crockford's Base32, such as `7K3M9QX2AB4W`) and the host's registry binds to the document's path, so the link keeps opening the document when its path changes,
|
|
325
|
+
for every reader who may open that path. Write such a link with `explorerHref(config, { view: "document-id", id, opens?: "single", overrides?, embed? })`; `resolveExplorerLocation` reads one as `{ kind: "document-id", id, opens, location }` (see [Document IDs](docs/behavior/url-contract.md#document-ids)).
|
|
322
326
|
- History: a click in the tree replaces the URL's document or folder; links inside a document, entries of its table of contents (in the tree and single views, to the heading's hash), source switches and view switches push; every multi-view action, the Source toggle and the tree view's Maximize replace (hiding and showing a panel leave the URL unchanged).
|
|
323
327
|
- An entry of a document's table of contents links to its heading's own address: the page's URL with the heading's fragment, or, in a multi-view panel, the panel's document in the tree view with that fragment, so a modified or middle click, a new tab or a copied address opens the heading (see [URL contract](docs/behavior/url-contract.md#table-of-contents)).
|
|
324
328
|
|
|
@@ -363,6 +367,7 @@ In the tree view a folder can be selected as GitHub's file tree does, and the vi
|
|
|
363
367
|
| `textMaxBytes?` | `number` | The most bytes of a file the data route's `text` operation reads and answers (a positive integer up to 256 MiB; default 2 MiB): a longer file answers its beginning, marked truncated. The explorer shows a Markdown document's source with it, so a host that renders larger Markdown sets it to its own source limit. |
|
|
364
368
|
| `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. |
|
|
365
369
|
| `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. |
|
|
370
|
+
| `documentIds?` | `ExplorerDocumentIdPorts<P>` | The registry of document IDs, `{ issue, resolve }` (see [Document IDs](#document-ids)): given exactly when the configuration has `documentIds` (either alone throws a `TypeError`, as does a value that is not an object of the two functions). |
|
|
366
371
|
|
|
367
372
|
It returns `{ loader, headers, dataLoader, dataAction, planData, forgetTree }`. `planData` plans a data request for a host that streams a file's bytes itself (see [Streaming files yourself](docs/behavior/hosting.md#streaming-files-yourself)).
|
|
368
373
|
`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.
|
|
@@ -523,6 +528,28 @@ editMaxBytes: 2 * 1024 * 1024, // the largest source and draft, the default
|
|
|
523
528
|
- **Source lines.** The editor opens at the place the reader was reading, or at the word they double-clicked, and the editor and the preview scroll together block by block, through the source lines your converter writes on every block: `data-source-lines="<first>-<last>"` (1-based, both inclusive), `@aiquants/markdown`'s `includeSourceLines`. Without them the editor opens at the start of the document and the two panes scroll together in proportion alone, top with top and bottom with bottom; the sanitizer keeps the attribute only in that form.
|
|
524
529
|
A ```spreadsheets table needs its source lines to be editable in the preview, and its options need the info string after the language as `data-code-meta` on the `code` element, as `@aiquants/markdown`'s converter writes it.
|
|
525
530
|
|
|
531
|
+
### Document IDs
|
|
532
|
+
|
|
533
|
+
With `documentIds: { slug }` in the configuration, give `createMarkdownExplorer` the registry of document IDs as `documentIds` (`ExplorerDocumentIdPorts`). The registry only records and reads bindings of an ID to a document path: the explorer draws every candidate, checks the reader before it calls a port, and checks every answer.
|
|
534
|
+
|
|
535
|
+
```ts
|
|
536
|
+
documentIds: {
|
|
537
|
+
// Bind the candidate to the path atomically, unless the path already has an ID or the candidate is another path's
|
|
538
|
+
issue: async (context, path, candidate) => ({ kind: "issued" }), // or { kind: "existing", id } / { kind: "taken" }
|
|
539
|
+
// The path an ID (in its canonical form) is bound to
|
|
540
|
+
resolve: async (context, id) => ({ kind: "bound", path }), // or { kind: "unbound" }
|
|
541
|
+
},
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
- **Issue.** The data route's `issue-id` operation (`POST <dataPath>/issue-id?path=`, which Copy permalink sends with `X-Markdown-Explorer: document-id` and which passes the cross-origin check of a refresh) calls `issue` only for a document the reader can open now — after the deny rules, the document admission and a check through `asset` that the document exists — with the document path (never the source's `readPath`) and a candidate in its canonical form.
|
|
545
|
+
Answer `issued` when you bound the candidate, `existing` with the path's ID when it already has one, and `taken` when the candidate is another path's ID: the explorer draws another, up to 4 candidates. Keep the bindings unique both ways (a unique key on the ID and on the path) and the binding atomic, so two readers pressing Copy permalink at once get one ID: one `issued`, the other `existing`.
|
|
546
|
+
A registry may bind every spelling of one document as one (its canonical spelling, such as the URI your storage records the document under): `issue` then answers `existing` for any spelling of a document that has an ID, and `resolve` answers the canonical spelling, which the explorer checks as it checks any path.
|
|
547
|
+
- **Resolve.** The page loader for an ID URL, and the `resolve-id` operation (`GET <dataPath>/resolve-id?id=`) the browser asks for one reached without the loader, call `resolve` with an ID in its canonical form: answer `bound` with its path, or `unbound` for an ID never issued or forgotten.
|
|
548
|
+
The explorer then checks the path as it checks a document's and sends the reader to its path URL (a `302` from the loader, `{ status: "ok", path, source }` from the operation), or answers the failure without naming the path (see [Security](docs/behavior/security.md#document-ids)).
|
|
549
|
+
- **Answers.** An `existing` ID must be in its canonical form (`isCanonicalDocumentId`; keep the ID as it was given) and a `bound` path acceptable and with a URL (not ending in a slash); a broken answer is logged and answered `failed`. Refuse with `ExplorerError` as anywhere else (its reason's status); any other exception is logged and answered `failed`.
|
|
550
|
+
`documentIdVectors()` of `@aiquants/markdown-explorer/testing` lists IDs as readers write them with their canonical forms, for your registry's tests.
|
|
551
|
+
- **Erasing and moving.** Forget a document's ID when the document is erased, so the ID never comes to name another document. When a document moves, bind its ID to the new path to keep its permalinks working; until then they answer `not-found`.
|
|
552
|
+
|
|
526
553
|
### Revealing the open document
|
|
527
554
|
|
|
528
555
|
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).
|
|
@@ -1005,6 +1032,7 @@ Every scroller of the explorer that the reader browses gets one pointer scroll b
|
|
|
1005
1032
|
- 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 pass the shared cross-origin check of server routes (`@aiquants/request-isolation`).
|
|
1006
1033
|
- Editing writes only through the host's `edit` ports, after the deny rules and the same admission as a document. A save and a preview need the custom header `X-Markdown-Explorer: edit` and pass the shared cross-origin check, and their draft is read and checked (media type, `editMaxBytes`, UTF-8 without NUL) before any port is called; a grant's `href` must be root-relative and an external editor's `https:`; the preview is sanitized exactly as a document.
|
|
1007
1034
|
A draft the host's browser converter renders (`draftConverter`) is sanitized in the browser with the same allow-list rules before it is shown, and never leaves the browser; only the existence marks come from the server's answers. The host checks in every port that the reader may edit the document, and writes only over the version the draft started from.
|
|
1035
|
+
- Document IDs are not permissions: an ID URL and the `resolve-id` operation pass the same checks as the document's path and name the path only to a reader who can open it. IDs are issued only for a document the reader can open (`issue-id`, with a proof header and the cross-origin check of a refresh), drawn by the explorer from Web Crypto (about 55 random bits), and every answer of the host's registry is checked.
|
|
1008
1036
|
- 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).
|
|
1009
1037
|
- 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.
|
|
1010
1038
|
|
|
@@ -1045,7 +1073,8 @@ The source repository holds a runnable demo next to the package (`packages/markd
|
|
|
1045
1073
|
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,
|
|
1046
1074
|
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),
|
|
1047
1075
|
editing (the parser writes source lines; the Markdown of `notes` is edited in place and saved to memory, never to the files, per draft space named by a cookie so tests never share saves; `guide/reference/embeds.md` links to an external editor), table files (`notes/tables`: a UTF-8 CSV with quoted cells, a Shift_JIS CSV read through `legacyTextEncoding:
|
|
1048
|
-
"Shift_JIS"`, which the demo gives its file-system sources too, a TSV, and a CSV wider than the preview's 1,000 columns), the instant preview with `@aiquants/markdown`'s browser converter as `draftConverter` (`demo/app/draft-converter.client.ts`),
|
|
1076
|
+
"Shift_JIS"`, which the demo gives its file-system sources too, a TSV, and a CSV wider than the preview's 1,000 columns), the instant preview with `@aiquants/markdown`'s browser converter as `draftConverter` (`demo/app/draft-converter.client.ts`),
|
|
1077
|
+
document IDs under `/docs/d/<ID>` with a registry kept in memory (`demo/app/document-ids.server.ts`, starting with a fixed ID for `guide/getting-started.md` and one bound to a path no source admits), and the end-to-end tests' fixtures.
|
|
1049
1078
|
Its page `/browser-docs` runs the server half inside the page, as a desktop webview does (`demo/app/browser-host.client.ts`, following [Hosting](docs/behavior/hosting.md)): `createExplorerServer` of `./server/core` on the browser runtime of `./server/browser`, over a source of the Markdown documents the page bundles, rendered by the same browser converter, with the display settings kept in the page's storage. It has no server loader and no data route: the in-process fetch answers every data request in the page.
|
|
1050
1079
|
Run it with `pnpm run demo:dev` from the package folder. The end-to-end tests run every spec in Chromium, and the in-page host's spec (`tests/e2e/browser-core.spec.ts`) in WebKit too.
|
|
1051
1080
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),m=require("react"),S=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),m=require("react"),S=require("./index-lpL7GltU.cjs"),Z=require("@aiquants/markdown/code-blocks"),J=require("@codemirror/commands"),we=require("@codemirror/lang-markdown"),ie=require("@codemirror/language"),Ee=require("@codemirror/search"),K=require("@codemirror/state"),_=require("@codemirror/view"),D=require("@lezer/highlight"),Ge=require("@aiquants/markdown"),me=require("@aiquants/markdown/source-lines"),ne=require("./ownUrls-BTPGNhBt.cjs"),he=require("./sanitizePolicy-C-ehd0J_.cjs"),We=require("isomorphic-dompurify"),X=require("./location-DrOP6t1F.cjs"),Xe=require("./describeValue-Ccvhbt36.cjs"),ce=require("@aiquants/resize-panels"),be=require("./useSplitPersistence-BUa_KMsV.cjs"),Pe={history:J.historyField},$e=ie.HighlightStyle.define([{tag:[D.tags.heading1,D.tags.heading2,D.tags.heading3,D.tags.heading4,D.tags.heading5,D.tags.heading6,D.tags.heading],color:"var(--aqmx-syntax-heading)",fontWeight:"700"},{tag:D.tags.strong,fontWeight:"700"},{tag:D.tags.emphasis,fontStyle:"italic"},{tag:D.tags.strikethrough,textDecoration:"line-through"},{tag:D.tags.link,color:"var(--aqmx-syntax-link)",textDecoration:"underline"},{tag:D.tags.url,color:"var(--aqmx-syntax-url)"},{tag:D.tags.monospace,color:"var(--aqmx-syntax-code)"},{tag:D.tags.quote,color:"var(--aqmx-syntax-quote)"},{tag:[D.tags.processingInstruction,D.tags.contentSeparator,D.tags.labelName,D.tags.meta],color:"var(--aqmx-syntax-mark)"}]),Ke=_.EditorView.theme({"&":{height:"100%",color:"var(--aqmx-text)",backgroundColor:"var(--aqmx-surface)",fontSize:"var(--aqmx-font-size-title)"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',lineHeight:"var(--aqmx-line-height-prose)"},".cm-content":{caretColor:"var(--aqmx-text)",paddingBlock:"var(--aqmx-space-6)"},".cm-line":{paddingInline:"var(--aqmx-space-6)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--aqmx-text)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--aqmx-editor-selection)"},".cm-activeLine":{backgroundColor:"var(--aqmx-editor-active-line)"},".cm-gutters":{backgroundColor:"var(--aqmx-surface-raised)",color:"var(--aqmx-editor-gutter)",borderInlineEnd:"var(--aqmx-space-1) solid var(--aqmx-border)"},".cm-activeLineGutter":{backgroundColor:"var(--aqmx-editor-active-line)"},".cm-searchMatch":{outline:"var(--aqmx-space-1) solid var(--aqmx-border-strong)"},".cm-panels":{backgroundColor:"var(--aqmx-surface-raised)",color:"var(--aqmx-text)"}}),Ne="data-aqmx-conflict-actions",Ye=_.Decoration.line({attributes:{"data-aqmx-conflict-line":"marker"}}),Je=_.Decoration.line({attributes:{"data-aqmx-conflict-line":"ours"}}),Qe=_.Decoration.line({attributes:{"data-aqmx-conflict-line":"theirs"}});class Ze extends _.WidgetType{constructor(t,n){super(),this.index=t,this.labels=n}index;labels;eq(t){return t.index===this.index&&t.labels===this.labels}toDOM(t){const n=document.createElement("div");n.setAttribute(Ne,String(this.index));for(const[o,s]of[["ours",this.labels.useOurs],["theirs",this.labels.useTheirs],["both",this.labels.keepBoth]]){const r=document.createElement("button");r.type="button",r.textContent=s,r.setAttribute("data-aqmx-conflict-choice",o),r.addEventListener("mousedown",l=>l.preventDefault()),r.addEventListener("click",()=>{const l=se(t.state.doc)[this.index];l!==void 0&&(De(t,l,o),t.focus())}),n.append(r)}return n}ignoreEvent(){return!0}}const se=e=>S.findConflictsInLines(e.iterLines()),xe=(e,t)=>{const n=new K.RangeSetBuilder;return se(e).forEach((o,s)=>{const r=e.line(o.start);n.add(r.from,r.from,_.Decoration.widget({widget:new Ze(s,t),block:!0,side:-1}));for(let l=o.start;l<=o.end;l+=1){const i=e.line(l).from,f=l===o.start||l===o.separator||l===o.end?Ye:l<o.separator?Je:Qe;n.add(i,i,f)}}),n.finish()},et=e=>K.StateField.define({create:t=>xe(t.doc,e),update:(t,n)=>n.docChanged?xe(n.state.doc,e):t,provide:t=>_.EditorView.decorations.from(t)}),De=(e,t,n)=>{const{doc:o}=e.state,s=(E,c)=>{const w=[];for(let u=E;u<=c;u+=1)w.push(o.line(u).text);return w},r=s(t.start+1,t.separator-1),l=s(t.separator+1,t.end-1),i=n==="ours"?r:n==="theirs"?l:[...r,...l];let f=o.line(t.start).from,d=o.line(t.end).to;i.length===0&&(t.end<o.lines?d+=1:t.start>1&&(f-=1));const b=i.join(`
|
|
2
2
|
`);e.dispatch({changes:{from:f,to:d,insert:b},selection:K.EditorSelection.cursor(f),scrollIntoView:!0,userEvent:"input.resolve"})},Se="input.preview",tt=20,nt=_.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.schedule()}view;cancel=null;update(e){e.docChanged&&this.schedule()}schedule(){if(this.cancel!==null||ie.syntaxTreeAvailable(this.view.state))return;const e=this.view.dom.ownerDocument.defaultView;if(e===null)return;const t=()=>{this.cancel=null,ie.ensureSyntaxTree(this.view.state,this.view.state.doc.length,tt),this.schedule()};if(typeof e.requestIdleCallback=="function"){const n=e.requestIdleCallback(t);this.cancel=()=>e.cancelIdleCallback(n)}else{const n=e.setTimeout(t,0);this.cancel=()=>e.clearTimeout(n)}}destroy(){this.cancel?.(),this.cancel=null}}),rt=/`{3,}|~{3,}/u,re=Object.freeze({kind:"absent"}),de=Object.freeze({kind:"unreadable"}),ot=(e,t,n)=>{const o=[];for(let f=t.parent;f!==null;f=f.parent)(f.name==="Blockquote"||f.name==="ListItem")&&o.unshift(f);const s=[],r=[],l=f=>{const d=r.indexOf(f);return d===-1?r.length:d};for(const f of o){const d=e.lineAt(f.from).number;if(f.name==="ListItem"){const b=Z.listItemWidthOn(e.line(d).text,s,l(d));if(b===null)return null;s.push({kind:"listItem",width:b})}else s.push({kind:"quote"});r.push(d)}const i=Z.openingFenceOn(n.text,s,l(n.number));return i===null?null:{containers:s,...i}},st=(e,t)=>{const{doc:n}=e;let o=n.lineAt(t).to;for(;;){const s=ie.ensureSyntaxTree(e,o,Number.POSITIVE_INFINITY);if(s===null)return null;const r=s.resolveInner(t,1),l=r.parent;if(r.name!=="CodeMark"||l===null||l.name!=="FencedCode"||l.from!==r.from)return null;if(l.to<o||o>=n.length)return l;o=Math.min(n.length,l.to+Math.max(l.to-t,1))}},ye=(e,t)=>{const{doc:n}=e;if(!Number.isInteger(t)||t<1||t>n.lines)return re;const o=n.line(t),s=rt.exec(o.text);if(s===null)return re;const r=st(e,o.from+s.index);if(r===null)return re;const l=r.getChild("CodeInfo");if(l===null)return re;const i=Z.fencedCodeLanguageOf(n.sliceString(l.from,l.to));if(i===null)return de;if(i!==Z.SPREADSHEETS_LANGUAGE)return re;const f=ot(n,r,o);if(f===null)return de;const[,...d]=r.getChildren("CodeMark"),b=d.at(-1),E=b===void 0?n.lineAt(r.to).number:n.lineAt(b.from).number-1,c=[];let w="";for(let u=t+1;u<=E;u+=1){const h=n.line(u).text,g=Z.readFencedLine(h,f);if(g===null)return de;c.push(h),w+=u<n.lines?`${g.content}
|
|
3
3
|
`:g.content}return{kind:"found",firstLine:t+1,lines:c,layout:f,body:w}},it=({parent:e,scroll:t,text:n,saved:o,labels:s,revisions:r,onChange:l,onGeometry:i,onSave:f})=>{let d=!1;const b=[_.EditorView.scrollHandler.of((u,h,g)=>(lt(u,h.head,g,t),!0)),_.lineNumbers(),_.highlightActiveLineGutter(),J.history(),_.drawSelection(),_.highlightActiveLine(),Ee.highlightSelectionMatches(),_.EditorView.lineWrapping,we.markdown({base:we.markdownLanguage}),nt,ie.syntaxHighlighting($e),et(s),_.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(f(),!0)},...Ee.searchKeymap,...J.historyKeymap,...J.defaultKeymap]),_.EditorView.contentAttributes.of({"aria-label":s.editor,"aria-multiline":"true"}),_.EditorView.updateListener.of(u=>{for(const h of u.transactions)h.docChanged&&r.record(h.changes,h.newDoc);u.docChanged&&l(u.transactions.every(h=>!h.docChanged||h.isUserEvent(Se))),(u.docChanged||u.heightChanged||u.geometryChanged)&&i(u.docChanged&&!d)}),Ke],E=ut(o,b)??K.EditorState.create({doc:n,extensions:b}),c=new _.EditorView({state:E,parent:e});r.mount(c.state.doc);const w=u=>{d=!0;try{u()}finally{d=!1}};return{text:()=>c.state.doc.toString(),replaceText:u=>{const h=c.state.doc.toString();if(h===u)return;let g=0;const y=Math.min(h.length,u.length);for(;g<y&&h.charCodeAt(g)===u.charCodeAt(g);)g+=1;let p=0;for(;p<y-g&&h.charCodeAt(h.length-1-p)===u.charCodeAt(u.length-1-p);)p+=1;c.dispatch({changes:{from:g,to:h.length-p,insert:u.slice(g,u.length-p)},userEvent:"input.replace"})},replaceBody:(u,h,g,y)=>{const{doc:p}=c.state,T=r.lineOf(y,u);if(T===null)return"changed";const O=ye(c.state,T);if(O.kind==="absent")return"changed";if(O.kind==="unreadable")return"unwritable";if(O.body!==Z.fencedBodyAsRead(h,O.layout))return"changed";const L=Z.planFencedBodyEdit(O.lines,O.layout,g);if(L.kind!=="edit")return L.kind;if(L.from===L.to&&L.lines.length===0)return"written";const N=z=>{const H=O.firstLine+z;return H<=p.lines?p.line(H).from:p.length},M=N(L.from),B=`${M===p.length&&p.sliceString(p.length-1)!==`
|
|
4
4
|
`?`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as q, jsxs as re, Fragment as Ze } from "react/jsx-runtime";
|
|
2
2
|
import { useState as oe, useRef as N, useLayoutEffect as D, useEffectEvent as Ee, useEffect as Ve, useImperativeHandle as et, useMemo as Y, startTransition as tt, useCallback as J, useId as nt } from "react";
|
|
3
|
-
import { v as ie, k as ge, l as rt, u as ae, m as ot, n as it, o as st, p as He, q as lt, t as ct, w as at, c as ut, x as dt, E as ft, y as mt, z as pt, A as ht, B as gt, G as xe, H as Se, I as vt, J as wt, K as ye, L as bt, M as Et, O as xt, Q as St } from "./index-
|
|
3
|
+
import { v as ie, k as ge, l as rt, u as ae, m as ot, n as it, o as st, p as He, q as lt, t as ct, w as at, c as ut, x as dt, E as ft, y as mt, z as pt, A as ht, B as gt, G as xe, H as Se, I as vt, J as wt, K as ye, L as bt, M as Et, O as xt, Q as St } from "./index-D0l_BJqb.js";
|
|
4
4
|
import { fencedBodyAsRead as yt, planFencedBodyEdit as kt, fencedCodeLanguageOf as Tt, SPREADSHEETS_LANGUAGE as At, readFencedLine as It, listItemWidthOn as Ot, openingFenceOn as Ct } from "@aiquants/markdown/code-blocks";
|
|
5
5
|
import { history as Lt, historyKeymap as Mt, defaultKeymap as qt, historyField as Rt, redo as _t, undo as Pt, isolateHistory as Nt } from "@codemirror/commands";
|
|
6
6
|
import { markdown as Dt, markdownLanguage as Bt } from "@codemirror/lang-markdown";
|
|
@@ -11,13 +11,13 @@ import { EditorView as $, lineNumbers as $t, highlightActiveLineGutter as Xt, dr
|
|
|
11
11
|
import { tags as _ } from "@lezer/highlight";
|
|
12
12
|
import { MarkdownViewer as en } from "@aiquants/markdown";
|
|
13
13
|
import { SOURCE_LINES_ATTRIBUTE as Ge, parseSourceLines as tn } from "@aiquants/markdown/source-lines";
|
|
14
|
-
import {
|
|
15
|
-
import { H as on, c as sn, M as ln } from "./sanitizePolicy-
|
|
14
|
+
import { U as nn, k as se, E as rn } from "./ownUrls-DD0cSCsF.js";
|
|
15
|
+
import { H as on, c as sn, M as ln } from "./sanitizePolicy-DAPnUUVm.js";
|
|
16
16
|
import cn from "isomorphic-dompurify";
|
|
17
|
-
import { o as an, C as un, F as dn, E as fn,
|
|
17
|
+
import { o as an, C as un, F as dn, E as fn, m as mn, n as le, q as pn } from "./location-Dh6K-y7w.js";
|
|
18
18
|
import { d as hn } from "./describeValue-CLlVRO8d.js";
|
|
19
19
|
import { PanelGroup as gn, Panel as ke, PanelResizeHandle as vn } from "@aiquants/resize-panels";
|
|
20
|
-
import { t as wn, u as bn } from "./useSplitPersistence-
|
|
20
|
+
import { t as wn, u as bn } from "./useSplitPersistence-pnb21dsr.js";
|
|
21
21
|
const Ue = { history: Rt }, En = zt.define([
|
|
22
22
|
{ tag: [_.heading1, _.heading2, _.heading3, _.heading4, _.heading5, _.heading6, _.heading], color: "var(--aqmx-syntax-heading)", fontWeight: "700" },
|
|
23
23
|
{ tag: _.strong, fontWeight: "700" },
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! Bundled third-party code: @heroicons/react 2.2.0 (MIT, ./licenses/@heroicons/react/LICENSE) */
|
|
2
|
-
"use strict";const c=require("react/jsx-runtime"),v=require("./index-LQWQfpAf.cjs"),r=require("react"),q=require("./location-D8DyDkuA.cjs"),Te=require("react-router"),We=require("./ownUrls-B259RGgd.cjs"),nt=require("@aiquants/directory-tree"),rt=require("./tapScrollCircle-DdX0Wri0.cjs"),Mt=require("./storage-BpYsprog.cjs"),lt=require("./describeValue-Ccvhbt36.cjs"),ke=require("@aiquants/resize-panels"),Xe=require("./useSplitPersistence-B2Fj508K.cjs");function Ft(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const l=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,l.get?l:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=Ft(r);function _t({title:e,titleId:t,...n},l){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:l,"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 It=m.forwardRef(_t);function Dt({title:e,titleId:t,...n},l){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:l,"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 Ht=m.forwardRef(Dt);function Bt({title:e,titleId:t,...n},l){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:l,"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 Zt=m.forwardRef(Bt);function $t({title:e,titleId:t,...n},l){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:l,"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 zt=m.forwardRef($t),Vt="http://path.invalid",Kt=/[\t\n\r]/gu,Ut=(e,t,n,l)=>{const o=e.replace(Kt,"");if(!o.startsWith("/")||o.startsWith("//")||o.includes("\\"))return null;const{pathname:i,search:a,hash:s}=new URL(o,Vt);return!We.isUnder(i,[t])||We.isUnder(i,[n])?null:`${l}${i.slice(t.length)}${a}${s}`},Wt=()=>{const{notices:e,config:t}=v.useExplorer(),n=r.use(e),l=Te.useHref(t.basePath),o=Te.useHref(t.dataPath);return n.length===0?null:c.jsx("div",{className:"aqmx-explorer-notices",children:n.map(i=>{const a=i.action===void 0?null:Ut(i.action.href,l,o,t.basePath);return c.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":i.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":i.id,children:[c.jsx("p",{className:"aqmx-callout-title",children:i.title}),i.body===void 0?null:c.jsx("p",{className:"aqmx-callout-body",children:i.body}),i.action===void 0?null:a===null?c.jsx("a",{className:"aqmx-callout-action",href:i.action.href,children:i.action.label}):c.jsx(v.ExplorerLink,{className:"aqmx-callout-action",to:a,navigation:"follow-link",children:i.action.label})]},i.id)})})};function Xt({title:e,titleId:t,...n},l){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:l,"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 Gt=m.forwardRef(Xt),Me=r.createContext(!0),at=r.createContext(null),ot="\0loop\0",st="\0",Yt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,l=a=>{const s=e.get(a);if(s!==void 0)return s;const p=Object.freeze({type:"loop",name:a.name,path:a.path});return e.set(a,p),p},o=(a,s,p)=>{let f=!1;const u=a.map(h=>{const w=i(h,s,p);return w!==h&&(f=!0),w});if(!f)return a;const d=n.get(a);return d!==void 0&&d.length===u.length&&d.every((h,w)=>h===u[w])?d:(n.set(a,u),u)},i=(a,s,p)=>{if(a.type!=="directory")return a;if(p.has(a.path))return l(a);const f=a.lazy===!0?s(a.path):void 0,u=f?.status==="loaded",d=u?f.entries:a.children;if(d===void 0)return a;p.add(a.path);const h=o(d,s,p);if(p.delete(a.path),!u&&h===a.children)return a;const w=t.get(a);if(w!==void 0&&w.state===f&&w.children===h)return w.grafted;const g={...a,children:h,lazy:u?!1:a.lazy};return t.set(a,{state:f,children:h,grafted:g}),g};return(a,s)=>o(a,s,new Set)},Qt=(e,t)=>`${ot}${e}${st}${t}`,pe=e=>e.startsWith(ot),Jt=e=>e.slice(e.lastIndexOf(st)+1),ne="data-aqmx-path",en=(e,t,n,l,o)=>{const i={aqmxPath:e.path};return e.modifiedAt!==void 0&&(i.aqmxModifiedAt=e.modifiedAt),n&&(i.aqmxOpen=!0),(l==="loading"||l==="failed")&&(i.aqmxChildren=l),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:o,data:i}},tn=(e,t,n,l)=>{const o=Qt(t,e.path);return{name:n,type:"directory",absolutePath:o,relativePath:o,children:l,data:{aqmxLoop:e.path}}},nn=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,l=[],o=(s,p,f)=>{const u=s.map(h=>h.type==="loop"?i(h,p,f):a(h,p)),d=n.get(s);return d!==void 0&&d.length===u.length&&d.every((h,w)=>h===u[w])?d:(n.set(s,u),u)},i=(s,p,f)=>{const u=t.get(s);if(u!==void 0&&u.parentKey===f&&u.loopFolderName===p.loopFolderName)return u.row;const d=tn(s,f,p.loopFolderName(s.name),l);return t.set(s,{row:d,parentKey:f,loopFolderName:p.loopFolderName}),d},a=(s,p)=>{const f=s.type==="directory"?s.children===void 0?l:o(s.children,p,s.path):void 0,u=p.openPaths.has(s.path),d=s.type==="directory"&&s.lazy===!0?p.childrenOf(s.path)?.status:void 0,h=d==="failed"?p.renderFailedFolder:void 0,w=e.get(s);if(w!==void 0&&w.open===u&&w.childrenStatus===d&&w.children===f&&w.renderFailedFolder===h)return w.row;const g=en(s,f,u,d,h===void 0?void 0:h(s));return e.set(s,{row:g,open:u,childrenStatus:d,children:f,renderFailedFolder:h}),g};return(s,p)=>o(s,p,"")},rn=e=>{if(e===void 0)return;const t=n=>{const l=n.data?.aqmxModifiedAt;return typeof l=="number"?{name:n.name,path:n.absolutePath,type:n.type,modifiedAt:l}:{name:n.name,path:n.absolutePath,type:n.type}};return(n,l)=>e(t(n),t(l))},Pe=(e,t)=>{const n=e.filter(l=>l.type==="directory");return t===void 0?n:n.sort(t)},ln=(e,t)=>{const n=new Map;let l=0;const o=i=>{for(const a of Pe(i,t.compare))if(t.isShownExpanded(a.path)){if(a.lazy!==!0){a.children!==void 0&&o(a.children);continue}n.has(a.path)||(n.set(a.path,t.isDirect(a.path)?"direct":"bulk"),t.childrenOf(a.path)?.status!=="failed"&&(l+=1))}};return o(e),{folders:n,waiting:l}},an=e=>{const t=new Set,n=l=>{for(const o of l)o.type==="directory"&&(o.lazy===!0&&t.add(o.path),o.children!==void 0&&n(o.children))};return n(e),t},ct=(e,t)=>{for(const n of e){if(n.type!=="directory")continue;if(n.path===t)return n;const l=n.children===void 0?null:ct(n.children,t);if(l!==null)return l}return null},it=(e,t,n)=>{for(const l of e){if(l===t)return{parent:n};const o=l.children===void 0?null:it(l.children,t,l);if(o!==null)return o}return null},on=(e,t,n)=>{const l=it(e,n,null);if(l===null)throw new Error(`[markdown-explorer] the pressed folder's row is not among the tree's rows: ${lt.describeValue(n.absolutePath)}`);if(l.parent!==null)return{kind:"folder",path:l.parent.absolutePath};const o=q.folderReadmeOf(t.filter(i=>i.type!=="loop"));return o===null?{kind:"nothing"}:{kind:"document",path:o}},sn=(e,t,n,l)=>{let o=e;for(const i of t){const a=o.find(s=>s.type==="directory"&&s.path===i);if(a===void 0)return"missing";if(a.lazy===!0)return l.childrenOf(a.path)?.status==="failed"?"failed":"loading";if(!l.isShownExpanded(a.path))return"loading";o=a.children??[]}return o.some(i=>i.type==="file"&&i.path===n)?"ready":"missing"},Ge=new Set,cn=(e,t)=>e.has(t)?e:new Set(e).add(t),un=(e,t)=>{if(!t.some(l=>e.has(l)))return e;const n=new Set(t);return new Set([...e].filter(l=>!n.has(l)))},dn=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),fn=()=>{const[e,t]=r.useState(Ge),n=r.useCallback(a=>t(s=>cn(s,a)),[]),l=r.useCallback(a=>t(s=>un(s,a)),[]),o=r.useCallback(a=>t(s=>dn(s,a)),[]),i=r.useCallback(()=>t(Ge),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:l,pruneDirect:o,clearDirect:i}),[e,n,l,o,i])},pn=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),mn=(e,t)=>{const n=[];let l=Pe(t.entries,t.compare);for(let o=1;l.length>0;o+=1){const i=[];for(const a of l){const{path:s}=a;if(t.isShownExpanded(s))e.handled.add(s);else{if(e.handled.has(s))continue;if(e.handled.add(s),a.lazy===!0&&t.childrenOf(s)===void 0){if(o>e.budget.maxDepth){e.depthLimited=!0;continue}if(e.loads.size>=e.budget.maxFolders){e.folderLimited=!0;continue}e.loads.add(s)}n.push(s),e.opened+=1}a.lazy!==!0&&a.children!==void 0&&i.push(...Pe(a.children,t.compare))}l=i}return n},ut=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||ut(n.children,t))),hn=(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 l of e.loads)t.childrenOf(l)?.status==="failed"&&(n+=1);return{kind:"done",opened:e.opened,failed:n,complete:ut(t.entries,t.isShownExpanded)}},Ae=Object.freeze({state:"idle"}),xn=e=>{const t=r.useRef(null),n=r.useRef(e),[l,o]=r.useState(Ae);r.useLayoutEffect(()=>{n.current=e});const i=r.useCallback(()=>{t.current===null&&(t.current=pn(n.current.budget),o({state:"running",opened:0}))},[]),a=r.useCallback(()=>{t.current=null,o(Ae)},[]),s=r.useCallback(p=>{const f=t.current;if(f===null)return;const u=mn(f,p);if(u.length>0&&(f.issuedAgainst=p.expanded,n.current.expandMultiple([...u])),!f.announcedStart&&(f.loads.size>0||p.waiting>0)&&(f.announcedStart=!0,n.current.onStart()),u.length===0&&!p.expansionPending&&p.expanded!==f.issuedAgainst&&p.waiting===0){t.current=null;const h=hn(f,p);o(h.kind==="done"?Ae:{state:"stopped",stop:h.kind,opened:h.opened}),n.current.onFinish(h);return}const{opened:d}=f;o(h=>h.state==="running"&&h.opened===d?h:{state:"running",opened:d})},[]);return r.useMemo(()=>({status:l,start:i,end:a,advance:s}),[l,i,a,s])},Ye=["pointerdown","wheel","touchstart","keydown","focusin"],wn=8,Qe={least:Number.POSITIVE_INFINITY,stalled:0},gn=({tree:e,container:t,path:n,chain:l,rows:o,cancel:i,displayed:a,placement:s})=>{const p=r.useRef(null),f=r.useRef(!0),u=r.useRef(Qe),d=r.useRef(null),h=r.useRef(null),w=r.useRef(l),g=r.useRef(s);r.useLayoutEffect(()=>{w.current=l,g.current=s},[l,s]);const E=r.useCallback(()=>{const T=d.current;T!==null&&(d.current=null,T.phase==="asking"?T.controller.abort():w.current?.open(null))},[]),y=r.useCallback(()=>{p.current=null,E()},[E]),L=r.useCallback(()=>{const T=t.current;p.current===null||h.current!==null||T===null||T.getClientRects().length===0||(h.current=requestAnimationFrame(()=>{h.current=null;const C=p.current;if(C===null)return;const P=g.current(C);if(P===0){f.current=!0,d.current?.phase==="opening"&&E();return}if(e.current?.scrollToPath(C,{align:"nearest"})===!0){d.current?.phase==="opening"&&E();const{least:R,stalled:k}=u.current;u.current=P<R?{least:P,stalled:0}:{least:R,stalled:k+1},u.current.stalled<wn&&L();return}const O=d.current;if(O===null){p.current=null;return}O.phase==="opening"&&w.current?.progress(O.folders,C)!=="loading"&&y()}))},[e,t,E,y]),j=r.useCallback(()=>{f.current=!1,u.current=Qe,L()},[L]);r.useEffect(()=>{const T=t.current;if(T===null)return;const C=typeof ResizeObserver>"u"?null:new ResizeObserver(j);C?.observe(T);for(const P of Ye)T.addEventListener(P,y,{passive:!0});return()=>{C?.disconnect();for(const P of Ye)T.removeEventListener(P,y);h.current!==null&&cancelAnimationFrame(h.current),h.current=null,E()}},[t,j,y,E]);const S=l!==null;r.useEffect(()=>{const T=t.current;if(y(),n===null||T===null||T.contains(T.ownerDocument.activeElement))return;p.current=n;const C=w.current;if(S&&C!==null){const P=new AbortController,O={phase:"asking",controller:P};d.current=O,C.ancestors(n,P.signal).then(R=>{d.current===O&&(R===null?d.current=null:(d.current={phase:"opening",folders:R},w.current?.open(R)),j())})}j()},[n,S,t,y,j]),r.useEffect(()=>{(d.current?.phase==="opening"||p.current!==null&&!f.current)&&j()},[o,j]);const I=r.useRef(i);r.useEffect(()=>{I.current!==i&&(I.current=i,y())},[i,y]);const M=r.useRef(a);r.useEffect(()=>{M.current&&!a&&E(),M.current=a},[a,E])},bn="--aqmx-tree-line",En=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),vn="data-aqmx-tree-probe",Rn=Object.freeze({rowHeight:q.CONTROL_BLOCK_PIXELS,lineColor:null}),Sn=(e,t,n)=>{const[l,o]=r.useState(Rn);return r.useLayoutEffect(()=>{const i=e.current;if(i===null)return;const a=()=>{const f=Math.round(i.getBoundingClientRect().height),u=getComputedStyle(i),d=u.getPropertyValue(bn).trim()===""?null:u.color;o(h=>{const w=Number.isFinite(f)&&f>0?f:h.rowHeight;return h.rowHeight===w&&h.lineColor===d?h:{rowHeight:w,lineColor:d}})};a();const s=En.map(f=>window.matchMedia(f));for(const f of s)f.addEventListener("change",a);const p=typeof ResizeObserver>"u"?null:new ResizeObserver(a);return p?.observe(i),()=>{for(const f of s)f.removeEventListener("change",a);p?.disconnect()}},[e,t,n]),l},dt="markdown-explorer-tree-scroll",yn=.5,ft=(e,t)=>[...e.querySelectorAll(`[role="treeitem"][${ne}]`)].find(n=>n.getAttribute(ne)===t),kn=(e,t)=>{const n=ft(e,t),l=n?.closest(`[data-testid="${dt}"]`);if(n===void 0||l===null||l===void 0)return Number.POSITIVE_INFINITY;const o=l.getBoundingClientRect(),i=n.getBoundingClientRect(),a=o.top-i.top,s=i.height>o.height?Math.abs(a):Math.max(0,a)+Math.max(0,i.bottom-o.bottom);return s<=yn?0:s},qe=Object.freeze({testId:dt,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:Object.freeze({width:8,...v.SCROLL_BAR_CONTROLS,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:rt.TAP_SCROLL_CIRCLE}),behaviorOptions:Object.freeze({enablePointerDrag:!0})}),Cn=Object.freeze({...qe,scrollBarOptions:Object.freeze({...qe.scrollBarOptions,...v.TOUCH_SCROLL_BAR_CONTROLS,tapScrollCircleOptions:rt.TOUCH_TAP_SCROLL_CIRCLE})}),Tn=e=>e?Cn:qe,Ln={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},jn={color:"inherit",fontSize:"inherit"},On={fontSize:"inherit"},Nn=new Set,An=new Map,Pn={color:"var(--aqmx-tree-line)"},pt=e=>e instanceof Element?e.closest(`[${ne}]`):null,qn=e=>{const t=pt(e);return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(ne)},mt=(e,t,n,l)=>n==="folder-limit"?e.expandAllFolderLimit(l,t.maxFolders,e.expandAll):e.expandAllDepthLimit(l,t.maxDepth),Mn=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):mt(e,t,n.kind,n.opened),ht=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-explorer-loading","aria-busy":"true","data-testid":"markdown-explorer-tree-loading",children:[c.jsx("p",{className:"aqmx-explorer-loading-text",children:e.treeLoading}),c.jsxs("div",{className:"aqmx-skeleton","aria-hidden":"true",children:[c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{})]})]})},Fn=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[c.jsx(Gt,{className:"aqmx-explorer-empty-icon","aria-hidden":"true"}),c.jsx("p",{className:"aqmx-empty-title",children:e.treeEmptyTitle}),c.jsx("p",{className:"aqmx-explorer-empty-body",children:e.treeEmptyBody})]})},_n=({name:e,onRetry:t})=>{const{labels:n}=v.useExplorer(),l=r.useId();return c.jsxs("span",{className:"aqmx-explorer-folder-failed",children:[c.jsx("span",{className:"aqmx-explorer-folder-name",children:e}),c.jsx("span",{id:l,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),c.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":l,"data-testid":"markdown-explorer-folder-retry",onClick:o=>{o.stopPropagation();const i=o.currentTarget,a=i.ownerDocument.activeElement===i?i.closest('[role="treeitem"]'):null;a instanceof HTMLElement&&v.focusWithoutScroll(a),t()},onKeyDown:o=>{o.key!=="Escape"&&o.stopPropagation()},children:[c.jsx(v.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},In=({entries:e,version:t,mode:n,sourceId:l,settings:o,reveal:i,openPaths:a,selection:s,onOpenDocument:p,folders:f,onRevealSource:u,expansion:d,onShown:h,marks:w,claimsHeld:g,expandAll:E,revealCancel:y})=>{const{trees:L,documents:j,labels:S,locale:I,theme:M,paletteKey:T,data:C,config:P,sources:O,reveals:R}=v.useExplorer(),k=r.use(Me),F=r.use(at),[D]=r.useState(()=>F?.get(l)),$=Tn(v.useCoarsePointer()),le=r.useMemo(()=>D===void 0?$:{...$,initialScrollAnchor:D},[$,D]),[ae]=r.useState(nn),G=r.useRef(null),{rowHeight:oe,lineColor:Y}=Sn(G,M,T),{isExpanded:K,toggle:H,expandMultiple:_,collapseMultiple:we,expanded:Q,isPending:se}=d,{alwaysExpanded:re,sortMode:me,folderPlacement:ce,readmePlacement:ge}=o,{direct:he,markDirect:U,unmarkDirect:ie,pruneDirect:be}=w,{running:ue,advance:N}=E,V=r.useRef(null),W=r.useRef(null);r.useLayoutEffect(()=>{if(F===null)return;const x=V;return()=>{const b=x.current===null?null:x.current.getScrollAnchor();b===null?F.delete(l):F.set(l,b)}},[F,l]);const de=r.useMemo(()=>q.createEntryComparator({sortMode:me,folderPlacement:ce,readmePlacement:ge}),[me,ce,ge]),Rt=r.useMemo(()=>rn(de),[de]),X=r.useCallback(x=>L.children(l,x),[L,l]),J=r.useMemo(()=>an(e),[e]),xe=r.useCallback(x=>re&&!J.has(x),[re,J]),ee=r.useCallback(x=>!pe(x)&&(K(x)||xe(x)),[K,xe]),B=r.useRef({shownExpanded:ee,isExpanded:K,isHeld:xe,unloadedFolders:J,entries:e,childrenOf:X,folderSelection:f,openDocument:p});r.useLayoutEffect(()=>{B.current={shownExpanded:ee,isExpanded:K,isHeld:xe,unloadedFolders:J,entries:e,childrenOf:X,folderSelection:f,openDocument:p}},[ee,K,xe,J,e,X,f,p]);const[te]=r.useState(()=>new Map),Le=r.useCallback((x,b)=>{R.settle(b),x.open(b)},[R]),Ee=r.useCallback((x,b)=>{b.kind!=="nothing"&&R.settle(b.path),x.close(b)},[R]),fe=r.useCallback((x,b)=>{for(const A of x){const Z=te.get(A);if(Z===void 0)continue;te.delete(A);const z=B.current.folderSelection;!b&&z!==null&&z.current===A&&Ee(z,Z)}},[te,Ee]),De=r.useCallback(x=>{V.current?.scrollToPath(x,{align:"nearest"}),requestAnimationFrame(()=>{const b=W.current,A=b===null?void 0:ft(b,x);A!==void 0&&v.focusWithoutScroll(A)})},[]),St=r.useCallback(x=>{if(pe(x)){De(Jt(x));return}fe([x],!B.current.shownExpanded(x)),B.current.isExpanded(x)?ie([x]):B.current.unloadedFolders.has(x)&&U(x),H(x)},[De,fe,U,ie,H]),je=r.useCallback(x=>{const b=x.filter(A=>!pe(A));b.length!==0&&(fe(b,!1),ie(b),we(b))},[fe,ie,we]),yt=r.useCallback(x=>{const b=x.filter(A=>!pe(A));if(b.length!==0){if(b.length<x.length&&b.every(A=>B.current.shownExpanded(A))){je(b);return}fe(b,!0),_(b)}},[fe,_,je]),He=r.useCallback(x=>c.jsx(_n,{name:x.name,onRetry:()=>{U(x.path),L.retryChildren(l,x.path),B.current.shownExpanded(x.path)||_([x.path])}}),[L,l,U,_]),Be=n==="multi"?a:Nn,{loopFolderName:Ze}=S,ve=r.useMemo(()=>ae(e,{openPaths:Be,childrenOf:X,renderFailedFolder:He,loopFolderName:Ze}),[ae,e,Be,X,He,Ze,t]),$e=r.useRef(ve);r.useLayoutEffect(()=>{$e.current=ve},[ve]);const kt=v.useIntentPrefetch(j,qn),ze=r.useRef([]),Re=r.useCallback(()=>{for(const x of ze.current)B.current.unloadedFolders.has(x)&&U(x)},[U]),{maxDepth:Oe}=P.revealDocument,Ve=r.useRef(u);r.useLayoutEffect(()=>{Ve.current=u},[u]);const Ct=r.useMemo(()=>({ancestors:async(x,b)=>{const A=R.take(l,x);if(A!==null)return A;if(!R.mayMove(x)){const z=await C.ancestors(l,x,b);return z.status!=="ok"||z.ancestors===null||z.ancestors.length>Oe?null:z.ancestors}const Z=await C.reveal(l,x,b);return Z.status!=="ok"||Z.source===null||Z.ancestors.length>Oe?null:Z.source===l?Z.ancestors:(b.aborted||!O.some(z=>z.id===Z.source)||(R.move(Z.source,x,Z.ancestors),Ve.current(Z.source)),null)},open:x=>{ze.current=x??[],x!==null&&(Re(),_([...x]))},progress:(x,b)=>sn(B.current.entries,x,b,{isShownExpanded:B.current.shownExpanded,childrenOf:B.current.childrenOf})}),[C,l,O,R,Oe,Re,_]);r.useEffect(()=>Re(),[Re,J]);const Tt=r.useMemo(()=>[e,t,Q],[e,t,Q]),Lt=r.useCallback(x=>W.current===null?Number.POSITIVE_INFINITY:kn(W.current,x),[]);gn({tree:V,container:W,path:i.path,chain:i.openFolders?Ct:null,rows:Tt,cancel:y,displayed:k,placement:Lt});const Ke=r.useCallback(x=>he.has(x),[he]),Se=r.useMemo(()=>ln(e,{isShownExpanded:ee,childrenOf:X,compare:de,isDirect:Ke}),[e,ee,X,de,Ke,t]),ye=k&&g;r.useLayoutEffect(()=>{h(e)},[e,h]),r.useLayoutEffect(()=>()=>h(null),[h]),r.useEffect(()=>L.claimChildren(l,ye?Se.folders:An),[L,l,ye,Se]),r.useEffect(()=>be(J),[be,J]),r.useEffect(()=>{ye&&ue&&N({entries:e,isShownExpanded:ee,childrenOf:X,compare:de,expanded:Q,waiting:Se.waiting,expansionPending:se})},[ye,ue,N,e,ee,X,de,Q,Se,se]);const jt=r.useCallback(x=>{const b=x.entry.absolutePath,{folderSelection:A,openDocument:Z}=B.current;if(x.isDirectory){if(A===null||pe(b))return;const z=b===A.current,Ue=on($e.current,B.current.entries,x.entry);if(B.current.isHeld(b)){x.preventDefault(),te.delete(b),z?Ee(A,Ue):Le(A,b);return}te.set(b,Ue),x.isExpanded||z||Le(A,b);return}R.settle(b),Z(b)},[R,te,Ee,Le]),Ot=r.useCallback(x=>{if(x.key!=="ArrowLeft"&&x.key!=="ArrowRight")return;const b=pt(x.target),A=b===null?null:b.getAttribute(ne);A!==null&&te.delete(A)},[te]),{onChange:Ne}=s,Nt=r.useMemo(()=>Ne===null?void 0:(x,b)=>{pe(x.absolutePath)||Ne({path:x.absolutePath,name:x.name,selected:b})},[Ne]),At=r.useMemo(()=>new Set(s.items),[s.items]),Pt=r.useMemo(()=>({entryKindDirectory:S.treeEntryKindDirectory,entryKindFile:S.treeEntryKindFile,scrollUp:S.treeScrollUp,scrollDown:S.treeScrollDown,scrollToTop:S.treeScrollToTop,scrollToBottom:S.treeScrollToBottom}),[S]),qt=Y===null?{showTreeLines:!1}:{showTreeLines:o.lines,lineColor:Y};return c.jsxs("div",{ref:W,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",onKeyDownCapture:Ot,...kt,children:[c.jsx("span",{ref:G,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[vn]:""}),c.jsx(nt.DirectoryTree,{ref:V,entries:ve,expansion:{toggle:St,isExpanded:ee,expandMultiple:yt,collapseMultiple:je,isPending:se&&!ue,doubleClickAction:o.doubleClickAction},selection:{mode:s.mode,selectedPath:s.shownPath,currentPath:s.shownPath,selectedItems:At,onEntryClick:jt,onSelectionChange:Nt},visual:{className:"aqmx-explorer-tree-view",ariaLabel:S.treeRegion,...qt,showExpandIcons:o.expandIcons,expandIconStyle:Pn,showDirectoryIcons:o.directoryIcons,showFileIcons:o.fileIcons,expandIconSize:o.expandIconSize,itemHeight:oe,removeRootIndent:o.removeRootIndent,highlightStyles:Ln,entryStyle:On,nameStyle:jn},virtualScroll:le,sort:Rt,locale:I,labels:Pt})]})},Dn=({pending:e,status:t})=>{const{labels:n}=v.useExplorer(),l=t.state!=="running",[o,i]=r.useState(0),a=r.useRef(!0);r.useLayoutEffect(()=>{const p=a.current;if(a.current=l,!l||e>0&&!p){i(0);return}if(e>0){i(e);return}if(o===0)return;const f=setTimeout(()=>i(0),0);return()=>clearTimeout(f)},[l,e,o]);const s=l&&e===0?o:e;return s===0&&l?null:c.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(s),"data-aqmx-expand-all":t.state,children:[s>0?c.jsx(v.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,c.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,s):n.foldersLoading(s)})]})},Hn=({stop:e,opened:t,budget:n})=>{const{labels:l}=v.useExplorer();return c.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:mt(l,n,e,t)})},Bn=({entries:e,...t})=>{const{trees:n}=v.useExplorer(),l=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:o}=t,[i]=r.useState(Yt),a=r.useMemo(()=>i(e,s=>n.children(o,s)),[i,e,n,o,l]);return a.length===0?c.jsx(Fn,{}):c.jsx(In,{entries:a,version:l,...t})},Zn=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:l}=v.useExplorer(),o=r.use(e);if(o.status==="deferred")return c.jsx(ht,{});if(o.status==="ok")return c.jsx(Bn,{entries:o.entries,...n});const i=l?.(o.failure);return c.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":o.failure.reason,children:i!==void 0?i:c.jsx(v.FailureView,{failure:o.failure,alert:!0,onRetry:t,testId:null})})},$n=({onControls:e,...t})=>{const{trees:n,storageNamespace:l,labels:o,announcer:i,config:a}=v.useExplorer(),{sourceId:s}=t,p=nt.useDirectoryTreeState({storageKey:Mt.storageKeys(l).treeExpansion(s)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const f=n.read(s),u=r.useCallback(()=>n.retry(s),[n,s]);r.useLayoutEffect(()=>n.open(s),[n,s]);const d=fn(),{expanded:h,expandMultiple:w,collapseAll:g}=p,[E,y]=r.useState(null),L=E!==h,j=r.useRef(h);r.useLayoutEffect(()=>{j.current=h},[h]);const S=a.expandAll,I=r.useCallback(()=>i.announce(o.expandAllStarted),[i,o]),M=r.useCallback(H=>i.announce(Mn(o,S,H)),[i,o,S]),T=xn({budget:S,expandMultiple:w,onStart:I,onFinish:M}),{status:C,start:P,end:O,advance:R}=T,k=C.state==="running",F=r.useMemo(()=>({running:k,advance:R}),[k,R]),D=r.useRef(null),[$,le]=r.useState(!1),ae=r.useCallback(H=>{D.current=H,le(H!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(H=>{const _=H.sourceId===s&&D.current!==null?ct(D.current,H.path):null;_!==null&&i.announce({list:o.foldersLoadFailedNamed,item:_.name})}),[n,s,i,o]);const{clearDirect:G}=d,[oe,Y]=r.useState(0),K=r.useCallback(()=>{Y(H=>H+1),O(),G(),y(j.current),g()},[O,G,g]);return r.useEffect(()=>{e({collapseAll:K,expandAll:$?P:null,expanding:k})},[e,K,P,$,k]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{$||O()},[$,O]),c.jsxs(c.Fragment,{children:[C.state==="stopped"?c.jsx(Hn,{stop:C.stop,opened:C.opened,budget:S}):null,c.jsxs("div",{className:"aqmx-explorer-tree-area",children:[c.jsx(r.Suspense,{fallback:c.jsx(ht,{}),children:c.jsx(Zn,{result:f,onRetry:u,expansion:p,onShown:ae,marks:d,claimsHeld:L,expandAll:F,revealCancel:oe,...t})}),c.jsx(Dn,{pending:n.pendingChildren(s),status:C})]})]})};function zn({title:e,titleId:t,...n},l){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:l,"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 Fe=m.forwardRef(zn),Je="markdown-explorer-selection-remove",Vn=({selection:e,onRemove:t,onClear:n,onOpenSelection:l,onLeave:o})=>{const{labels:i}=v.useExplorer(),a=r.useId(),s=r.useRef(null),p=[...e],f=(d,h)=>{if(h.ownerDocument.activeElement===h){const w=s.current===null?[]:[...s.current.querySelectorAll(`[data-testid="${Je}"]`)],g=w.indexOf(h),E=[w[g+1],w[g-1]].find(y=>y!==void 0);E===void 0?o():E.focus()}t(d)},u=()=>{const d=s.current;d!==null&&d.contains(d.ownerDocument.activeElement)&&o(),n()};return c.jsxs("section",{ref:s,className:"aqmx-explorer-tray","aria-labelledby":a,"data-testid":"markdown-explorer-selection-tray",children:[c.jsxs("div",{className:"aqmx-explorer-tray-header",children:[c.jsx("p",{id:a,className:"aqmx-explorer-tray-title",children:i.selectionTitle(p.length)}),c.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:u,children:i.clearSelection})]}),c.jsx("ul",{className:"aqmx-explorer-tray-list",children:p.map(([d,h])=>c.jsxs("li",{className:"aqmx-explorer-tray-item",children:[c.jsx("span",{className:"aqmx-explorer-tray-name",title:d,children:h}),c.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":i.removeFromSelection(h),title:i.removeFromSelection(h),"data-testid":Je,"data-aqmx-path":d,onClick:w=>f(d,w.currentTarget),children:c.jsx(Fe,{"aria-hidden":"true"})})]},d))}),l===void 0?null:c.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>l(p.map(([d])=>d)),children:i.openSelectionInMulti(p.length)})]})},Ce=new Map,Kn=(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},Un=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},xt=r.createContext(null),Wn=e=>{const t=r.use(xt);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};function Xn({title:e,titleId:t,...n},l){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:l,"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 Gn=m.forwardRef(Xn);function Yn({title:e,titleId:t,...n},l){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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M11.25 4.533A9.707 9.707 0 0 0 6 3a9.735 9.735 0 0 0-3.25.555.75.75 0 0 0-.5.707v14.25a.75.75 0 0 0 1 .707A8.237 8.237 0 0 1 6 18.75c1.995 0 3.823.707 5.25 1.886V4.533ZM12.75 20.636A8.214 8.214 0 0 1 18 18.75c.966 0 1.89.166 2.75.47a.75.75 0 0 0 1-.708V4.262a.75.75 0 0 0-.5-.707A9.735 9.735 0 0 0 18 3a9.707 9.707 0 0 0-5.25 1.533v16.103Z"}))}const Qn=m.forwardRef(Yn);function Jn({title:e,titleId:t,...n},l){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:l,"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 er=m.forwardRef(Jn);function tr({title:e,titleId:t,...n},l){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:l,"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 nr=m.forwardRef(tr);function rr({title:e,titleId:t,...n},l){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:l,"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 lr=m.forwardRef(rr);function ar({title:e,titleId:t,...n},l){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:l,"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 or=m.forwardRef(ar);function sr({title:e,titleId:t,...n},l){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:l,"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 cr=m.forwardRef(sr);function ir({title:e,titleId:t,...n},l){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:l,"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 ur=m.forwardRef(ir);function dr({title:e,titleId:t,...n},l){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:l,"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 fr=m.forwardRef(dr);function pr({title:e,titleId:t,...n},l){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:l,"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 mr=m.forwardRef(pr);function hr({title:e,titleId:t,...n},l){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:l,"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 xr=m.forwardRef(hr);function wr({title:e,titleId:t,...n},l){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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M4.125 3C3.089 3 2.25 3.84 2.25 4.875V18a3 3 0 0 0 3 3h15a3 3 0 0 1-3-3V4.875C17.25 3.839 16.41 3 15.375 3H4.125ZM12 9.75a.75.75 0 0 0 0 1.5h1.5a.75.75 0 0 0 0-1.5H12Zm-.75-2.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 0 1.5H12a.75.75 0 0 1-.75-.75ZM6 12.75a.75.75 0 0 0 0 1.5h7.5a.75.75 0 0 0 0-1.5H6Zm-.75 3.75a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5H6a.75.75 0 0 1-.75-.75ZM6 6.75a.75.75 0 0 0-.75.75v3c0 .414.336.75.75.75h3a.75.75 0 0 0 .75-.75v-3A.75.75 0 0 0 9 6.75H6Z",clipRule:"evenodd"}),m.createElement("path",{d:"M18.75 6.75h1.875c.621 0 1.125.504 1.125 1.125V18a1.5 1.5 0 0 1-3 0V6.75Z"}))}const gr=m.forwardRef(wr);function br({title:e,titleId:t,...n},l){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:l,"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 Er=m.forwardRef(br),vr=Object.freeze({sortMode:Gn,folderPlacement:fr,readmePlacement:Qn,selectionMode:er,doubleClickAction:cr,expandIconSize:xr,alwaysExpanded:v.ForwardRef$2,revealDocument:v.ForwardRef$1,showFolderReadme:gr,removeRootIndent:nr,lines:Er,expandIcons:lr,directoryIcons:mr,fileIcons:ur}),wt=(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 ${lt.describeValue(n)}`);return n},Rr=({id:e,settings:t,descriptors:n,onAdvance:l,onClose:o,ref:i})=>{const{labels:a}=v.useExplorer(),s=r.useRef([]);r.useEffect(()=>{s.current[0]?.focus()},[]);const p=r.useCallback(u=>{const d=n.length;s.current[(u%d+d)%d]?.focus()},[n.length]),f=r.useCallback((u,d)=>{switch(u.key){case"ArrowDown":u.preventDefault(),p(d+1);break;case"ArrowUp":u.preventDefault(),p(d-1);break;case"Home":u.preventDefault(),p(0);break;case"End":u.preventDefault(),p(n.length-1);break;case"Escape":v.consumeKey(u),o();break;case"Tab":o();break}},[n.length,p,o]);return c.jsx("div",{ref:i,id:e,role:"menu","aria-label":a.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((u,d)=>{const h=vr[u.key],w=wt(a,u),g=q.formatTreeSettingValue(a,t,u.key),E=t[u.key],y=typeof E=="boolean"?{role:"menuitemcheckbox","aria-checked":E,"aria-label":w}:{role:"menuitem","aria-label":`${w}: ${g}`};return c.jsxs("button",{ref:L=>{s.current[d]=L},type:"button",tabIndex:-1,...y,title:`${w}: ${g}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":u.key,onClick:()=>l(u),onKeyDown:L=>f(L,d),children:[c.jsx(h,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-menu-name",children:w}),c.jsx("span",{className:"aqmx-explorer-menu-value",children:g})]},u.key)})})},Sr=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:l,announcer:o}=v.useExplorer(),[i,a]=r.useState(!1),s=r.useRef(null),p=r.useRef(null),f=r.useRef(null),u=r.useId(),d=r.useCallback(()=>{s.current?.focus(),a(!1)},[]);r.useEffect(()=>{if(!i)return;const g=E=>{E.target instanceof Node&&(s.current?.contains(E.target)===!0||p.current?.contains(E.target)===!0)||(a(!1),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{f.current=null,(document.activeElement===null||document.activeElement===document.body)&&s.current?.focus()},0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[i]),r.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);const h=r.useCallback(g=>{g.key!=="Escape"||!i||(v.consumeKey(g),d())},[i,d]),w=r.useCallback(g=>{const E=n(g.key);o.announce(l.settingAnnouncement(wt(l,g),q.formatTreeSettingValue(l,E,g.key)))},[o,l,n]);return{trigger:c.jsx("button",{ref:s,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?u:void 0,"aria-label":l.treeSettings,title:l.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>a(g=>!g),onKeyDown:h,children:c.jsx(or,{"aria-hidden":"true"})}),menu:i?c.jsx(Rr,{ref:p,id:u,settings:e,descriptors:t,onAdvance:w,onClose:d}):null}},yr=()=>{const{treeSettings:e}=v.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},et=new Set,kr='[role="tree"] [role="treeitem"][tabindex="0"]',Cr="[data-directory-tree-tab-stop]",Tr=e=>{const{mode:t,sourceId:n,currentPath:l,openPaths:o,onOpenDocument:i,onSourceChange:a,onRevealSource:s,viewSwitch:p}=e,{labels:f,sources:u,trees:d,documents:h,announcer:w,reveals:g}=v.useExplorer(),{settings:E,advance:y}=yr(),L=r.useMemo(()=>q.visibleTreeSettingDescriptors(t),[t]),j=t==="tree"&&E.selectionMode==="multiple";Wn(j);const S=e.mode==="tree"?e.tray.onGatheredChange:null,I=e.mode==="tree"?e.onOpenSelection:void 0,M=e.mode==="tree"?e.onOpenFolder:null,T=e.mode==="tree"?e.onCloseFolder:null,C=e.mode==="tree"&&e.currentFolder,P=r.useMemo(()=>M===null||T===null||!E.showFolderReadme?null:{current:l,open:M,close:T},[M,T,l,E.showFolderReadme]),O=e.mode==="tree"&&j?e.tray.gathered:Ce,R=r.useCallback(N=>{const V=y(N);return V.selectionMode!=="multiple"&&S?.(Ce),V},[y,S]),k=Sr({settings:E,descriptors:L,onAdvance:R}),F=r.useCallback(N=>S?.(V=>Kn(V,N)),[S]),D=r.useCallback(N=>S?.(V=>Un(V,N)),[S]),$=r.useCallback(()=>S?.(Ce),[S]),le=r.useRef(null),ae=r.useCallback(()=>{const N=le.current;if(N===null)return;[kr,Cr,'[data-testid="markdown-explorer-tree-settings"]'].map(W=>N.querySelector(W)).find(W=>W!==null)?.focus()},[]),G=r.useMemo(()=>new Set(O.keys()),[O]),oe=r.useMemo(()=>l===null?et:new Set([l]),[l]),Y=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:o,shownPath:null,onChange:null};switch(E.selectionMode){case"single":return{mode:"single",items:oe,shownPath:l,onChange:null};case"multiple":return{mode:"multiple",items:G,shownPath:l,onChange:F};case"none":return{mode:"none",items:et,shownPath:null,onChange:null}}},[t,o,E.selectionMode,oe,l,G,F]),K=r.useMemo(()=>E.revealDocument?{path:l,openFolders:!C}:{path:Y.shownPath,openFolders:!1},[E.revealDocument,l,C,Y.shownPath]),H=r.useCallback(N=>{l!==null&&g.settle(l),a(N)},[l,g,a]),[_,we]=r.useState(null),[Q,se]=r.useState(!1),[re,me]=r.useState(null),ce=r.useRef(!1),ge=r.useCallback(async()=>{if(!ce.current){ce.current=!0,se(!0),me(null);try{const N=await d.refresh(n);if(N.status==="superseded")return;h.invalidate(),N.status==="failed"?me({sourceId:n,failure:N.failure}):w.announce(f.treeRefreshed)}finally{ce.current=!1,se(!1)}}},[d,h,n,w,f]),he=_===null?null:_.expandAll,U=_?.expanding===!0,ie=u.find(N=>N.id===n),be=p.target==="multi"?zt:Zt,ue=p.target==="multi"?f.switchToMulti:f.switchToTree;return c.jsxs("nav",{ref:le,"aria-label":f.explorerRegion,className:"aqmx-explorer","data-testid":"markdown-explorer-explorer","data-aqmx-mode":t,children:[c.jsxs("div",{className:"aqmx-explorer-header",children:[u.length>1?c.jsx("select",{className:"aqmx-explorer-source","aria-label":f.sourceLabel,title:ie?.label,value:n,onChange:N=>H(N.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:u.map(N=>c.jsx("option",{value:N.id,children:N.label},N.id))}):null,c.jsxs("div",{className:"aqmx-explorer-actions",children:[c.jsx(v.ExplorerLink,{to:p.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":ue,title:ue,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":p.target,children:c.jsx(be,{"aria-hidden":"true"})}),c.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:f.refreshTree,"aria-disabled":Q,"aria-busy":Q,"data-aqmx-busy":Q?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{ge()},children:[c.jsx(v.ForwardRef,{"aria-hidden":"true"}),c.jsx("span",{children:f.refreshTreeLabel})]}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.expandAll,title:f.expandAll,"aria-disabled":he===null||U,"aria-busy":U,"data-aqmx-busy":U?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>he?.(),children:c.jsx(Ht,{"aria-hidden":"true"})}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.collapseAll,title:f.collapseAll,"aria-disabled":_===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>_?.collapseAll(),children:c.jsx(It,{"aria-hidden":"true"})}),k.trigger]})]}),c.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[re!==null&&re.sourceId===n?c.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":re.failure.reason,children:f.treeRefreshFailed(v.failureTitleOf(f,re.failure.reason))}):null,c.jsx(r.Suspense,{fallback:null,children:c.jsx(Wt,{})}),c.jsx($n,{mode:t,sourceId:n,settings:E,reveal:K,openPaths:o,selection:Y,onOpenDocument:i,folders:P,onRevealSource:s,onControls:we},n),j&&O.size>0?c.jsx(Vn,{selection:O,onRemove:D,onClear:$,onOpenSelection:I,onLeave:ae}):null,k.menu]})]})};function Lr({title:e,titleId:t,...n},l){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:l,"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 gt=m.forwardRef(Lr),jr=({explorer:e,toggleRef:t,covered:n,merged:l,onNoticeSlotChange:o,dismissals:i})=>{const{labels:a}=v.useExplorer(),s=Te.useLocation(),p=Te.useNavigationType(),{location:f}=v.useExplorerLocation(),[u,d]=r.useState(!1),[h,w]=r.useState({navigated:s,source:f.source}),[g,E]=r.useState(!1);h.navigated!==s&&(w({navigated:s,source:f.source}),h.source===f.source&&!g&&v.explorerNavigationOf(p,s.state)!=="close-folder"&&d(!1));const[y,L]=r.useState(i);y!==i&&(L(i),d(!1));const j=r.useRef(null),S=r.useRef(null),I=r.useRef(null),M=r.useRef(!1),T=r.useId();r.useLayoutEffect(()=>{const k=j.current;k!==null&&(u&&!k.open?(k.showModal(),S.current?.focus()):!u&&k.open&&(k.close(),t.current?.focus()),o(u?I.current:null))},[u,t,o]),r.useLayoutEffect(()=>()=>o(null),[o]);const C=r.useCallback(k=>{k.key!=="Escape"||k.defaultPrevented||(v.consumeKey(k),d(!1))},[]),P=r.useCallback(k=>{M.current=k.target===k.currentTarget},[]),O=r.useCallback(k=>{const F=M.current;M.current=!1,F&&k.target===k.currentTarget&&d(!1)},[]),R=r.useCallback(()=>{d(!1)},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"aqmx-sheet-bar",inert:n,"data-testid":"markdown-explorer-sheet-bar","data-aqmx-sheet-bar-merged":l?"true":"false",children:c.jsxs("button",{ref:t,type:"button",className:"aqmx-explorer-toggle",title:l?a.showExplorer:void 0,"aria-haspopup":"dialog","aria-expanded":u,"aria-controls":T,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>d(!0),children:[c.jsx(gt,{"aria-hidden":"true"}),c.jsx("span",{className:l?"aqmx-sr-only":void 0,children:a.showExplorer})]})}),c.jsx("dialog",{ref:j,id:T,className:"aqmx-sheet","aria-label":a.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:C,onPointerDown:P,onClick:O,onClose:R,children:c.jsxs("div",{className:"aqmx-sheet-panel",children:[c.jsxs("div",{className:"aqmx-explorer-chrome",children:[c.jsx("div",{ref:I,className:"aqmx-sheet-notice-slot"}),c.jsx("button",{ref:S,type:"button",className:"aqmx-explorer-close","aria-label":a.hideExplorer,title:a.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>d(!1),children:c.jsx(Fe,{"aria-hidden":"true"})})]}),c.jsx("div",{className:"aqmx-sheet-body",children:c.jsx(Me,{value:u,children:c.jsx(xt,{value:E,children:e})})}),c.jsx(v.LiveRegion,{holds:u,deferWhileFullscreenIn:null,testId:"markdown-explorer-sheet-announcer"})]})})]})},bt=r.createContext(null),_e="aqmx-explorer",Et="aqmx-content",Ie='[role="tree"] [role="treeitem"]',Or=`${Ie}[tabindex="0"]`,Nr="[data-directory-tree-tab-stop]",Ar=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${_e}"] ${Ie}`))if(n.getAttribute(ne)===t)return n;return null},tt=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:q.ASSUMED_ROOT_FONT_PIXELS}),Pr=(e,t)=>{const[n,l]=r.useState(()=>tt(0,0));return r.useLayoutEffect(()=>{const o=e.current,i=t.current;if(o===null||i===null)throw new Error("[markdown-explorer] the split frame is not mounted");const a={frame:o.getBoundingClientRect().width,rem:i.getBoundingClientRect().width},s=()=>{const f=tt(a.frame,a.rem);l(u=>u.inlineSize===f.inlineSize&&u.rootFontPixels===f.rootFontPixels?u:f)};s();const p=new ResizeObserver(f=>{for(const u of f){const[d]=u.borderBoxSize;d!==void 0&&(u.target===o&&(a.frame=d.inlineSize),u.target===i&&(a.rem=d.inlineSize))}s()});return p.observe(o),p.observe(i),()=>p.disconnect()},[e,t]),n},vt=e=>`aqmx-split-handle-${e}`,qr=(e,{frameRef:t,sheetToggleRef:n,railToggleRef:l,closeButtonRef:o,handleId:i})=>{const a=r.useRef(!1),s=r.useRef(null),p=r.useRef(!1);r.useLayoutEffect(()=>{const u=t.current;if(u===null)throw new Error("[markdown-explorer] the split frame is not mounted");const d=w=>{const g=w.target instanceof Element?w.target:null;a.current=g!==null&&g.closest(`[data-panel-id="${Et}"]`)===null,!p.current&&(s.current=g?.closest(`${Ie}[${ne}]`)?.getAttribute(ne)??null)},h=w=>{w.relatedTarget instanceof Node&&!u.contains(w.relatedTarget)&&(a.current=!1)};return u.addEventListener("focusin",d),u.addEventListener("focusout",h),()=>{u.removeEventListener("focusin",d),u.removeEventListener("focusout",h)}},[t]);const f=r.useRef(e);r.useLayoutEffect(()=>{const u=f.current;if(u===e)return;f.current=e;const d=t.current;if(d===null||!a.current)return;const h=w=>{const{activeElement:g,body:E}=d.ownerDocument;if(g!==null&&g!==E)return;const y=w.find(L=>L!==null);if(y!=null){p.current=!0;try{y.focus()}finally{p.current=!1}}};if(e==="sheet"){h([n.current]);return}if(e==="rail"){h([l.current]);return}if(u==="rail"){h([o.current]);return}queueMicrotask(()=>{if(f.current!==e||!a.current)return;const w=s.current,g=`[data-panel-id="${_e}"]`;h([w===null?null:Ar(d,w),d.querySelector(`${g} ${Or}`),d.querySelector(`${g} ${Nr}`),d.querySelector(`[data-resize-handle-id="${i}"]`)])})},[e,t,n,l,o,i])},Mr=e=>e==="tree"?"treeExplorerHidden":"multiExplorerHidden",Fr=({view:e,explorer:t,content:n,contentCoversPage:l=!1,sheetDismissals:o=0,onDraggingChange:i})=>{const{viewSettings:a}=v.useExplorer(),s=r.useRef(null),[p,f]=r.useState(null),u=r.useRef(null),d=r.useRef(null),h=r.useRef(null),w=r.useRef(null),{inlineSize:g,rootFontPixels:E}=Pr(s,u),y=Mr(e),L=v.useViewSetting(R=>R[y]===!0),j=g!==null&&g<q.explorerSheetBelowPixels(E),S=j?"sheet":L?"rail":"split";qr(S,{frameRef:s,sheetToggleRef:d,railToggleRef:h,closeButtonRef:w,handleId:vt(e)});const I=r.useCallback(()=>a.update({[y]:!0}),[a,y]),M=r.useCallback(()=>a.update({[y]:!1}),[a,y]),[T,C]=r.useState(!1),P=r.useMemo(()=>j?{lane:!l,onBar:C}:null,[j,l]),[O]=r.useState(()=>new Map);return c.jsx(at,{value:O,children:c.jsxs("div",{ref:s,className:"aqmx-split-frame","data-aqmx-explorer-mode":S,"data-aqmx-measured":g===null?"false":"true","data-aqmx-content-covers-page":l?"true":"false",children:[c.jsx("span",{ref:u,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),j?c.jsx(jr,{explorer:t,toggleRef:d,covered:l,merged:T,onNoticeSlotChange:f,dismissals:o}):null,c.jsxs("div",{className:"aqmx-split-row",children:[S==="rail"?c.jsx(_r,{toggleRef:h,covered:l,onOpen:M}):null,c.jsx(bt,{value:j?p:null,children:c.jsx(v.SheetBarContext,{value:P,children:c.jsx(Ir,{view:e,mode:S,explorer:t,content:n,contentCoversPage:l,onDraggingChange:i,explorerMinPixels:q.explorerMinPixels(E),closeButtonRef:w,onHide:I})})})]})]})})},_r=({toggleRef:e,covered:t,onOpen:n})=>{const{labels:l}=v.useExplorer();return c.jsx("div",{className:"aqmx-split-rail",inert:t,"data-testid":"markdown-explorer-rail",children:c.jsx("button",{ref:e,type:"button",className:"aqmx-explorer-toggle","aria-expanded":!1,"aria-label":l.showExplorer,title:l.showExplorer,"data-testid":"markdown-explorer-rail-toggle",onClick:n,children:c.jsx(gt,{"aria-hidden":"true"})})})},Ir=({view:e,mode:t,explorer:n,content:l,contentCoversPage:o,onDraggingChange:i,explorerMinPixels:a,closeButtonRef:s,onHide:p})=>{const{viewSettings:f,labels:u}=v.useExplorer(),d=r.useMemo(()=>Xe.toPanelGroupLabels(u),[u]),w=v.useViewSetting(R=>e==="tree"?R.treeExplorer:R.multiExplorer)??(e==="tree"?q.EXPLORER_DEFAULT_PERCENT:q.EXPLORER_MULTI_DEFAULT_PERCENT),g=r.useRef(!1),[E,y]=r.useState(!1),L=r.useRef(!1),j=r.useRef(i);r.useLayoutEffect(()=>{j.current=i},[i]);const S=Xe.useSplitPersistence(r.useCallback(R=>{if(R.length!==2)return;const[k=0,F=0]=R,D=k+F;if(D<=0||k<=0)return;const $=Math.min(q.EXPLORER_MAX_PERCENT,k/D*100);f.update(e==="tree"?{treeExplorer:$}:{multiExplorer:$})},[f,e]));r.useEffect(()=>()=>{g.current&&j.current?.(!1)},[]);const M=v.useCoarsePointer()?q.COARSE_TARGET_PIXELS:q.FINE_TARGET_PIXELS,T=t==="split",C=r.useCallback(()=>{L.current=!1,y(!1),p()},[p]),P=r.useCallback((R,k)=>{const[F=0,D=0]=R;R.length===2&&D>0&&(L.current=F<=0,y(L.current)),S.layoutChanged(R,k),L.current&&k.source==="keyboard"&&C()},[S,C]),O=r.useCallback(R=>{g.current=R,i?.(R),S.draggingChanged(R),!R&&L.current&&C()},[i,S,C]);return c.jsxs(ke.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:P,labels:d,className:"aqmx-split","data-aqmx-split":e,children:[T?c.jsxs(ke.Panel,{id:_e,defaultSize:{value:w,unit:"percentage"},minSize:{value:a,unit:"pixels"},maxSize:{value:q.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:o,className:"aqmx-split-explorer",children:[c.jsx("div",{className:"aqmx-explorer-chrome",children:c.jsx("button",{ref:s,type:"button",className:"aqmx-explorer-close","aria-label":u.hideExplorer,title:u.hideExplorer,"data-testid":"markdown-explorer-split-close",onClick:C,children:c.jsx(Fe,{"aria-hidden":"true"})})}),c.jsx(Me,{value:!E,children:n})]}):null,T?c.jsx(ke.PanelResizeHandle,{id:vt(e),thickness:M,indicator:{visible:!0,thickness:q.SPLIT_HANDLE_PIXELS.gripThickness,length:q.SPLIT_HANDLE_PIXELS.gripLength,barThickness:q.SPLIT_HANDLE_PIXELS.barThickness,barLength:q.SPLIT_HANDLE_PIXELS.barLength},title:u.resizeExplorer,"aria-label":u.resizeExplorer,onDragging:O,inert:o,className:"aqmx-split-handle"}):null,c.jsx(ke.Panel,{id:Et,defaultSize:{value:T?100-w:100,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...o?{style:{isolation:"auto"}}:{},children:l})]})};exports.EMPTY_SELECTION=Ce;exports.ExplorerPane=Tr;exports.ExplorerSplit=Fr;exports.SheetNoticeSlotContext=bt;
|
|
2
|
+
"use strict";const c=require("react/jsx-runtime"),v=require("./index-lpL7GltU.cjs"),r=require("react"),q=require("./location-DrOP6t1F.cjs"),Te=require("react-router"),We=require("./ownUrls-BTPGNhBt.cjs"),nt=require("@aiquants/directory-tree"),rt=require("./tapScrollCircle-DyLInGck.cjs"),Mt=require("./storage-BpYsprog.cjs"),lt=require("./describeValue-Ccvhbt36.cjs"),ke=require("@aiquants/resize-panels"),Xe=require("./useSplitPersistence-BUa_KMsV.cjs");function Ft(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const l=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,l.get?l:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=Ft(r);function _t({title:e,titleId:t,...n},l){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:l,"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 It=m.forwardRef(_t);function Dt({title:e,titleId:t,...n},l){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:l,"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 Ht=m.forwardRef(Dt);function Bt({title:e,titleId:t,...n},l){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:l,"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 Zt=m.forwardRef(Bt);function $t({title:e,titleId:t,...n},l){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:l,"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 zt=m.forwardRef($t),Vt="http://path.invalid",Kt=/[\t\n\r]/gu,Ut=(e,t,n,l)=>{const o=e.replace(Kt,"");if(!o.startsWith("/")||o.startsWith("//")||o.includes("\\"))return null;const{pathname:i,search:a,hash:s}=new URL(o,Vt);return!We.isUnder(i,[t])||We.isUnder(i,[n])?null:`${l}${i.slice(t.length)}${a}${s}`},Wt=()=>{const{notices:e,config:t}=v.useExplorer(),n=r.use(e),l=Te.useHref(t.basePath),o=Te.useHref(t.dataPath);return n.length===0?null:c.jsx("div",{className:"aqmx-explorer-notices",children:n.map(i=>{const a=i.action===void 0?null:Ut(i.action.href,l,o,t.basePath);return c.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":i.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":i.id,children:[c.jsx("p",{className:"aqmx-callout-title",children:i.title}),i.body===void 0?null:c.jsx("p",{className:"aqmx-callout-body",children:i.body}),i.action===void 0?null:a===null?c.jsx("a",{className:"aqmx-callout-action",href:i.action.href,children:i.action.label}):c.jsx(v.ExplorerLink,{className:"aqmx-callout-action",to:a,navigation:"follow-link",children:i.action.label})]},i.id)})})};function Xt({title:e,titleId:t,...n},l){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:l,"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 Gt=m.forwardRef(Xt),Me=r.createContext(!0),at=r.createContext(null),ot="\0loop\0",st="\0",Yt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,l=a=>{const s=e.get(a);if(s!==void 0)return s;const p=Object.freeze({type:"loop",name:a.name,path:a.path});return e.set(a,p),p},o=(a,s,p)=>{let f=!1;const u=a.map(h=>{const w=i(h,s,p);return w!==h&&(f=!0),w});if(!f)return a;const d=n.get(a);return d!==void 0&&d.length===u.length&&d.every((h,w)=>h===u[w])?d:(n.set(a,u),u)},i=(a,s,p)=>{if(a.type!=="directory")return a;if(p.has(a.path))return l(a);const f=a.lazy===!0?s(a.path):void 0,u=f?.status==="loaded",d=u?f.entries:a.children;if(d===void 0)return a;p.add(a.path);const h=o(d,s,p);if(p.delete(a.path),!u&&h===a.children)return a;const w=t.get(a);if(w!==void 0&&w.state===f&&w.children===h)return w.grafted;const g={...a,children:h,lazy:u?!1:a.lazy};return t.set(a,{state:f,children:h,grafted:g}),g};return(a,s)=>o(a,s,new Set)},Qt=(e,t)=>`${ot}${e}${st}${t}`,pe=e=>e.startsWith(ot),Jt=e=>e.slice(e.lastIndexOf(st)+1),ne="data-aqmx-path",en=(e,t,n,l,o)=>{const i={aqmxPath:e.path};return e.modifiedAt!==void 0&&(i.aqmxModifiedAt=e.modifiedAt),n&&(i.aqmxOpen=!0),(l==="loading"||l==="failed")&&(i.aqmxChildren=l),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:o,data:i}},tn=(e,t,n,l)=>{const o=Qt(t,e.path);return{name:n,type:"directory",absolutePath:o,relativePath:o,children:l,data:{aqmxLoop:e.path}}},nn=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,l=[],o=(s,p,f)=>{const u=s.map(h=>h.type==="loop"?i(h,p,f):a(h,p)),d=n.get(s);return d!==void 0&&d.length===u.length&&d.every((h,w)=>h===u[w])?d:(n.set(s,u),u)},i=(s,p,f)=>{const u=t.get(s);if(u!==void 0&&u.parentKey===f&&u.loopFolderName===p.loopFolderName)return u.row;const d=tn(s,f,p.loopFolderName(s.name),l);return t.set(s,{row:d,parentKey:f,loopFolderName:p.loopFolderName}),d},a=(s,p)=>{const f=s.type==="directory"?s.children===void 0?l:o(s.children,p,s.path):void 0,u=p.openPaths.has(s.path),d=s.type==="directory"&&s.lazy===!0?p.childrenOf(s.path)?.status:void 0,h=d==="failed"?p.renderFailedFolder:void 0,w=e.get(s);if(w!==void 0&&w.open===u&&w.childrenStatus===d&&w.children===f&&w.renderFailedFolder===h)return w.row;const g=en(s,f,u,d,h===void 0?void 0:h(s));return e.set(s,{row:g,open:u,childrenStatus:d,children:f,renderFailedFolder:h}),g};return(s,p)=>o(s,p,"")},rn=e=>{if(e===void 0)return;const t=n=>{const l=n.data?.aqmxModifiedAt;return typeof l=="number"?{name:n.name,path:n.absolutePath,type:n.type,modifiedAt:l}:{name:n.name,path:n.absolutePath,type:n.type}};return(n,l)=>e(t(n),t(l))},Pe=(e,t)=>{const n=e.filter(l=>l.type==="directory");return t===void 0?n:n.sort(t)},ln=(e,t)=>{const n=new Map;let l=0;const o=i=>{for(const a of Pe(i,t.compare))if(t.isShownExpanded(a.path)){if(a.lazy!==!0){a.children!==void 0&&o(a.children);continue}n.has(a.path)||(n.set(a.path,t.isDirect(a.path)?"direct":"bulk"),t.childrenOf(a.path)?.status!=="failed"&&(l+=1))}};return o(e),{folders:n,waiting:l}},an=e=>{const t=new Set,n=l=>{for(const o of l)o.type==="directory"&&(o.lazy===!0&&t.add(o.path),o.children!==void 0&&n(o.children))};return n(e),t},ct=(e,t)=>{for(const n of e){if(n.type!=="directory")continue;if(n.path===t)return n;const l=n.children===void 0?null:ct(n.children,t);if(l!==null)return l}return null},it=(e,t,n)=>{for(const l of e){if(l===t)return{parent:n};const o=l.children===void 0?null:it(l.children,t,l);if(o!==null)return o}return null},on=(e,t,n)=>{const l=it(e,n,null);if(l===null)throw new Error(`[markdown-explorer] the pressed folder's row is not among the tree's rows: ${lt.describeValue(n.absolutePath)}`);if(l.parent!==null)return{kind:"folder",path:l.parent.absolutePath};const o=q.folderReadmeOf(t.filter(i=>i.type!=="loop"));return o===null?{kind:"nothing"}:{kind:"document",path:o}},sn=(e,t,n,l)=>{let o=e;for(const i of t){const a=o.find(s=>s.type==="directory"&&s.path===i);if(a===void 0)return"missing";if(a.lazy===!0)return l.childrenOf(a.path)?.status==="failed"?"failed":"loading";if(!l.isShownExpanded(a.path))return"loading";o=a.children??[]}return o.some(i=>i.type==="file"&&i.path===n)?"ready":"missing"},Ge=new Set,cn=(e,t)=>e.has(t)?e:new Set(e).add(t),un=(e,t)=>{if(!t.some(l=>e.has(l)))return e;const n=new Set(t);return new Set([...e].filter(l=>!n.has(l)))},dn=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),fn=()=>{const[e,t]=r.useState(Ge),n=r.useCallback(a=>t(s=>cn(s,a)),[]),l=r.useCallback(a=>t(s=>un(s,a)),[]),o=r.useCallback(a=>t(s=>dn(s,a)),[]),i=r.useCallback(()=>t(Ge),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:l,pruneDirect:o,clearDirect:i}),[e,n,l,o,i])},pn=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),mn=(e,t)=>{const n=[];let l=Pe(t.entries,t.compare);for(let o=1;l.length>0;o+=1){const i=[];for(const a of l){const{path:s}=a;if(t.isShownExpanded(s))e.handled.add(s);else{if(e.handled.has(s))continue;if(e.handled.add(s),a.lazy===!0&&t.childrenOf(s)===void 0){if(o>e.budget.maxDepth){e.depthLimited=!0;continue}if(e.loads.size>=e.budget.maxFolders){e.folderLimited=!0;continue}e.loads.add(s)}n.push(s),e.opened+=1}a.lazy!==!0&&a.children!==void 0&&i.push(...Pe(a.children,t.compare))}l=i}return n},ut=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||ut(n.children,t))),hn=(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 l of e.loads)t.childrenOf(l)?.status==="failed"&&(n+=1);return{kind:"done",opened:e.opened,failed:n,complete:ut(t.entries,t.isShownExpanded)}},Ae=Object.freeze({state:"idle"}),xn=e=>{const t=r.useRef(null),n=r.useRef(e),[l,o]=r.useState(Ae);r.useLayoutEffect(()=>{n.current=e});const i=r.useCallback(()=>{t.current===null&&(t.current=pn(n.current.budget),o({state:"running",opened:0}))},[]),a=r.useCallback(()=>{t.current=null,o(Ae)},[]),s=r.useCallback(p=>{const f=t.current;if(f===null)return;const u=mn(f,p);if(u.length>0&&(f.issuedAgainst=p.expanded,n.current.expandMultiple([...u])),!f.announcedStart&&(f.loads.size>0||p.waiting>0)&&(f.announcedStart=!0,n.current.onStart()),u.length===0&&!p.expansionPending&&p.expanded!==f.issuedAgainst&&p.waiting===0){t.current=null;const h=hn(f,p);o(h.kind==="done"?Ae:{state:"stopped",stop:h.kind,opened:h.opened}),n.current.onFinish(h);return}const{opened:d}=f;o(h=>h.state==="running"&&h.opened===d?h:{state:"running",opened:d})},[]);return r.useMemo(()=>({status:l,start:i,end:a,advance:s}),[l,i,a,s])},Ye=["pointerdown","wheel","touchstart","keydown","focusin"],wn=8,Qe={least:Number.POSITIVE_INFINITY,stalled:0},gn=({tree:e,container:t,path:n,chain:l,rows:o,cancel:i,displayed:a,placement:s})=>{const p=r.useRef(null),f=r.useRef(!0),u=r.useRef(Qe),d=r.useRef(null),h=r.useRef(null),w=r.useRef(l),g=r.useRef(s);r.useLayoutEffect(()=>{w.current=l,g.current=s},[l,s]);const E=r.useCallback(()=>{const T=d.current;T!==null&&(d.current=null,T.phase==="asking"?T.controller.abort():w.current?.open(null))},[]),y=r.useCallback(()=>{p.current=null,E()},[E]),L=r.useCallback(()=>{const T=t.current;p.current===null||h.current!==null||T===null||T.getClientRects().length===0||(h.current=requestAnimationFrame(()=>{h.current=null;const C=p.current;if(C===null)return;const P=g.current(C);if(P===0){f.current=!0,d.current?.phase==="opening"&&E();return}if(e.current?.scrollToPath(C,{align:"nearest"})===!0){d.current?.phase==="opening"&&E();const{least:R,stalled:k}=u.current;u.current=P<R?{least:P,stalled:0}:{least:R,stalled:k+1},u.current.stalled<wn&&L();return}const O=d.current;if(O===null){p.current=null;return}O.phase==="opening"&&w.current?.progress(O.folders,C)!=="loading"&&y()}))},[e,t,E,y]),j=r.useCallback(()=>{f.current=!1,u.current=Qe,L()},[L]);r.useEffect(()=>{const T=t.current;if(T===null)return;const C=typeof ResizeObserver>"u"?null:new ResizeObserver(j);C?.observe(T);for(const P of Ye)T.addEventListener(P,y,{passive:!0});return()=>{C?.disconnect();for(const P of Ye)T.removeEventListener(P,y);h.current!==null&&cancelAnimationFrame(h.current),h.current=null,E()}},[t,j,y,E]);const S=l!==null;r.useEffect(()=>{const T=t.current;if(y(),n===null||T===null||T.contains(T.ownerDocument.activeElement))return;p.current=n;const C=w.current;if(S&&C!==null){const P=new AbortController,O={phase:"asking",controller:P};d.current=O,C.ancestors(n,P.signal).then(R=>{d.current===O&&(R===null?d.current=null:(d.current={phase:"opening",folders:R},w.current?.open(R)),j())})}j()},[n,S,t,y,j]),r.useEffect(()=>{(d.current?.phase==="opening"||p.current!==null&&!f.current)&&j()},[o,j]);const I=r.useRef(i);r.useEffect(()=>{I.current!==i&&(I.current=i,y())},[i,y]);const M=r.useRef(a);r.useEffect(()=>{M.current&&!a&&E(),M.current=a},[a,E])},bn="--aqmx-tree-line",En=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),vn="data-aqmx-tree-probe",Rn=Object.freeze({rowHeight:q.CONTROL_BLOCK_PIXELS,lineColor:null}),Sn=(e,t,n)=>{const[l,o]=r.useState(Rn);return r.useLayoutEffect(()=>{const i=e.current;if(i===null)return;const a=()=>{const f=Math.round(i.getBoundingClientRect().height),u=getComputedStyle(i),d=u.getPropertyValue(bn).trim()===""?null:u.color;o(h=>{const w=Number.isFinite(f)&&f>0?f:h.rowHeight;return h.rowHeight===w&&h.lineColor===d?h:{rowHeight:w,lineColor:d}})};a();const s=En.map(f=>window.matchMedia(f));for(const f of s)f.addEventListener("change",a);const p=typeof ResizeObserver>"u"?null:new ResizeObserver(a);return p?.observe(i),()=>{for(const f of s)f.removeEventListener("change",a);p?.disconnect()}},[e,t,n]),l},dt="markdown-explorer-tree-scroll",yn=.5,ft=(e,t)=>[...e.querySelectorAll(`[role="treeitem"][${ne}]`)].find(n=>n.getAttribute(ne)===t),kn=(e,t)=>{const n=ft(e,t),l=n?.closest(`[data-testid="${dt}"]`);if(n===void 0||l===null||l===void 0)return Number.POSITIVE_INFINITY;const o=l.getBoundingClientRect(),i=n.getBoundingClientRect(),a=o.top-i.top,s=i.height>o.height?Math.abs(a):Math.max(0,a)+Math.max(0,i.bottom-o.bottom);return s<=yn?0:s},qe=Object.freeze({testId:dt,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:Object.freeze({width:8,...v.SCROLL_BAR_CONTROLS,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:rt.TAP_SCROLL_CIRCLE}),behaviorOptions:Object.freeze({enablePointerDrag:!0})}),Cn=Object.freeze({...qe,scrollBarOptions:Object.freeze({...qe.scrollBarOptions,...v.TOUCH_SCROLL_BAR_CONTROLS,tapScrollCircleOptions:rt.TOUCH_TAP_SCROLL_CIRCLE})}),Tn=e=>e?Cn:qe,Ln={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},jn={color:"inherit",fontSize:"inherit"},On={fontSize:"inherit"},Nn=new Set,An=new Map,Pn={color:"var(--aqmx-tree-line)"},pt=e=>e instanceof Element?e.closest(`[${ne}]`):null,qn=e=>{const t=pt(e);return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(ne)},mt=(e,t,n,l)=>n==="folder-limit"?e.expandAllFolderLimit(l,t.maxFolders,e.expandAll):e.expandAllDepthLimit(l,t.maxDepth),Mn=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):mt(e,t,n.kind,n.opened),ht=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-explorer-loading","aria-busy":"true","data-testid":"markdown-explorer-tree-loading",children:[c.jsx("p",{className:"aqmx-explorer-loading-text",children:e.treeLoading}),c.jsxs("div",{className:"aqmx-skeleton","aria-hidden":"true",children:[c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{})]})]})},Fn=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[c.jsx(Gt,{className:"aqmx-explorer-empty-icon","aria-hidden":"true"}),c.jsx("p",{className:"aqmx-empty-title",children:e.treeEmptyTitle}),c.jsx("p",{className:"aqmx-explorer-empty-body",children:e.treeEmptyBody})]})},_n=({name:e,onRetry:t})=>{const{labels:n}=v.useExplorer(),l=r.useId();return c.jsxs("span",{className:"aqmx-explorer-folder-failed",children:[c.jsx("span",{className:"aqmx-explorer-folder-name",children:e}),c.jsx("span",{id:l,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),c.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":l,"data-testid":"markdown-explorer-folder-retry",onClick:o=>{o.stopPropagation();const i=o.currentTarget,a=i.ownerDocument.activeElement===i?i.closest('[role="treeitem"]'):null;a instanceof HTMLElement&&v.focusWithoutScroll(a),t()},onKeyDown:o=>{o.key!=="Escape"&&o.stopPropagation()},children:[c.jsx(v.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},In=({entries:e,version:t,mode:n,sourceId:l,settings:o,reveal:i,openPaths:a,selection:s,onOpenDocument:p,folders:f,onRevealSource:u,expansion:d,onShown:h,marks:w,claimsHeld:g,expandAll:E,revealCancel:y})=>{const{trees:L,documents:j,labels:S,locale:I,theme:M,paletteKey:T,data:C,config:P,sources:O,reveals:R}=v.useExplorer(),k=r.use(Me),F=r.use(at),[D]=r.useState(()=>F?.get(l)),$=Tn(v.useCoarsePointer()),le=r.useMemo(()=>D===void 0?$:{...$,initialScrollAnchor:D},[$,D]),[ae]=r.useState(nn),G=r.useRef(null),{rowHeight:oe,lineColor:Y}=Sn(G,M,T),{isExpanded:K,toggle:H,expandMultiple:_,collapseMultiple:we,expanded:Q,isPending:se}=d,{alwaysExpanded:re,sortMode:me,folderPlacement:ce,readmePlacement:ge}=o,{direct:he,markDirect:U,unmarkDirect:ie,pruneDirect:be}=w,{running:ue,advance:N}=E,V=r.useRef(null),W=r.useRef(null);r.useLayoutEffect(()=>{if(F===null)return;const x=V;return()=>{const b=x.current===null?null:x.current.getScrollAnchor();b===null?F.delete(l):F.set(l,b)}},[F,l]);const de=r.useMemo(()=>q.createEntryComparator({sortMode:me,folderPlacement:ce,readmePlacement:ge}),[me,ce,ge]),Rt=r.useMemo(()=>rn(de),[de]),X=r.useCallback(x=>L.children(l,x),[L,l]),J=r.useMemo(()=>an(e),[e]),xe=r.useCallback(x=>re&&!J.has(x),[re,J]),ee=r.useCallback(x=>!pe(x)&&(K(x)||xe(x)),[K,xe]),B=r.useRef({shownExpanded:ee,isExpanded:K,isHeld:xe,unloadedFolders:J,entries:e,childrenOf:X,folderSelection:f,openDocument:p});r.useLayoutEffect(()=>{B.current={shownExpanded:ee,isExpanded:K,isHeld:xe,unloadedFolders:J,entries:e,childrenOf:X,folderSelection:f,openDocument:p}},[ee,K,xe,J,e,X,f,p]);const[te]=r.useState(()=>new Map),Le=r.useCallback((x,b)=>{R.settle(b),x.open(b)},[R]),Ee=r.useCallback((x,b)=>{b.kind!=="nothing"&&R.settle(b.path),x.close(b)},[R]),fe=r.useCallback((x,b)=>{for(const A of x){const Z=te.get(A);if(Z===void 0)continue;te.delete(A);const z=B.current.folderSelection;!b&&z!==null&&z.current===A&&Ee(z,Z)}},[te,Ee]),De=r.useCallback(x=>{V.current?.scrollToPath(x,{align:"nearest"}),requestAnimationFrame(()=>{const b=W.current,A=b===null?void 0:ft(b,x);A!==void 0&&v.focusWithoutScroll(A)})},[]),St=r.useCallback(x=>{if(pe(x)){De(Jt(x));return}fe([x],!B.current.shownExpanded(x)),B.current.isExpanded(x)?ie([x]):B.current.unloadedFolders.has(x)&&U(x),H(x)},[De,fe,U,ie,H]),je=r.useCallback(x=>{const b=x.filter(A=>!pe(A));b.length!==0&&(fe(b,!1),ie(b),we(b))},[fe,ie,we]),yt=r.useCallback(x=>{const b=x.filter(A=>!pe(A));if(b.length!==0){if(b.length<x.length&&b.every(A=>B.current.shownExpanded(A))){je(b);return}fe(b,!0),_(b)}},[fe,_,je]),He=r.useCallback(x=>c.jsx(_n,{name:x.name,onRetry:()=>{U(x.path),L.retryChildren(l,x.path),B.current.shownExpanded(x.path)||_([x.path])}}),[L,l,U,_]),Be=n==="multi"?a:Nn,{loopFolderName:Ze}=S,ve=r.useMemo(()=>ae(e,{openPaths:Be,childrenOf:X,renderFailedFolder:He,loopFolderName:Ze}),[ae,e,Be,X,He,Ze,t]),$e=r.useRef(ve);r.useLayoutEffect(()=>{$e.current=ve},[ve]);const kt=v.useIntentPrefetch(j,qn),ze=r.useRef([]),Re=r.useCallback(()=>{for(const x of ze.current)B.current.unloadedFolders.has(x)&&U(x)},[U]),{maxDepth:Oe}=P.revealDocument,Ve=r.useRef(u);r.useLayoutEffect(()=>{Ve.current=u},[u]);const Ct=r.useMemo(()=>({ancestors:async(x,b)=>{const A=R.take(l,x);if(A!==null)return A;if(!R.mayMove(x)){const z=await C.ancestors(l,x,b);return z.status!=="ok"||z.ancestors===null||z.ancestors.length>Oe?null:z.ancestors}const Z=await C.reveal(l,x,b);return Z.status!=="ok"||Z.source===null||Z.ancestors.length>Oe?null:Z.source===l?Z.ancestors:(b.aborted||!O.some(z=>z.id===Z.source)||(R.move(Z.source,x,Z.ancestors),Ve.current(Z.source)),null)},open:x=>{ze.current=x??[],x!==null&&(Re(),_([...x]))},progress:(x,b)=>sn(B.current.entries,x,b,{isShownExpanded:B.current.shownExpanded,childrenOf:B.current.childrenOf})}),[C,l,O,R,Oe,Re,_]);r.useEffect(()=>Re(),[Re,J]);const Tt=r.useMemo(()=>[e,t,Q],[e,t,Q]),Lt=r.useCallback(x=>W.current===null?Number.POSITIVE_INFINITY:kn(W.current,x),[]);gn({tree:V,container:W,path:i.path,chain:i.openFolders?Ct:null,rows:Tt,cancel:y,displayed:k,placement:Lt});const Ke=r.useCallback(x=>he.has(x),[he]),Se=r.useMemo(()=>ln(e,{isShownExpanded:ee,childrenOf:X,compare:de,isDirect:Ke}),[e,ee,X,de,Ke,t]),ye=k&&g;r.useLayoutEffect(()=>{h(e)},[e,h]),r.useLayoutEffect(()=>()=>h(null),[h]),r.useEffect(()=>L.claimChildren(l,ye?Se.folders:An),[L,l,ye,Se]),r.useEffect(()=>be(J),[be,J]),r.useEffect(()=>{ye&&ue&&N({entries:e,isShownExpanded:ee,childrenOf:X,compare:de,expanded:Q,waiting:Se.waiting,expansionPending:se})},[ye,ue,N,e,ee,X,de,Q,Se,se]);const jt=r.useCallback(x=>{const b=x.entry.absolutePath,{folderSelection:A,openDocument:Z}=B.current;if(x.isDirectory){if(A===null||pe(b))return;const z=b===A.current,Ue=on($e.current,B.current.entries,x.entry);if(B.current.isHeld(b)){x.preventDefault(),te.delete(b),z?Ee(A,Ue):Le(A,b);return}te.set(b,Ue),x.isExpanded||z||Le(A,b);return}R.settle(b),Z(b)},[R,te,Ee,Le]),Ot=r.useCallback(x=>{if(x.key!=="ArrowLeft"&&x.key!=="ArrowRight")return;const b=pt(x.target),A=b===null?null:b.getAttribute(ne);A!==null&&te.delete(A)},[te]),{onChange:Ne}=s,Nt=r.useMemo(()=>Ne===null?void 0:(x,b)=>{pe(x.absolutePath)||Ne({path:x.absolutePath,name:x.name,selected:b})},[Ne]),At=r.useMemo(()=>new Set(s.items),[s.items]),Pt=r.useMemo(()=>({entryKindDirectory:S.treeEntryKindDirectory,entryKindFile:S.treeEntryKindFile,scrollUp:S.treeScrollUp,scrollDown:S.treeScrollDown,scrollToTop:S.treeScrollToTop,scrollToBottom:S.treeScrollToBottom}),[S]),qt=Y===null?{showTreeLines:!1}:{showTreeLines:o.lines,lineColor:Y};return c.jsxs("div",{ref:W,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",onKeyDownCapture:Ot,...kt,children:[c.jsx("span",{ref:G,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[vn]:""}),c.jsx(nt.DirectoryTree,{ref:V,entries:ve,expansion:{toggle:St,isExpanded:ee,expandMultiple:yt,collapseMultiple:je,isPending:se&&!ue,doubleClickAction:o.doubleClickAction},selection:{mode:s.mode,selectedPath:s.shownPath,currentPath:s.shownPath,selectedItems:At,onEntryClick:jt,onSelectionChange:Nt},visual:{className:"aqmx-explorer-tree-view",ariaLabel:S.treeRegion,...qt,showExpandIcons:o.expandIcons,expandIconStyle:Pn,showDirectoryIcons:o.directoryIcons,showFileIcons:o.fileIcons,expandIconSize:o.expandIconSize,itemHeight:oe,removeRootIndent:o.removeRootIndent,highlightStyles:Ln,entryStyle:On,nameStyle:jn},virtualScroll:le,sort:Rt,locale:I,labels:Pt})]})},Dn=({pending:e,status:t})=>{const{labels:n}=v.useExplorer(),l=t.state!=="running",[o,i]=r.useState(0),a=r.useRef(!0);r.useLayoutEffect(()=>{const p=a.current;if(a.current=l,!l||e>0&&!p){i(0);return}if(e>0){i(e);return}if(o===0)return;const f=setTimeout(()=>i(0),0);return()=>clearTimeout(f)},[l,e,o]);const s=l&&e===0?o:e;return s===0&&l?null:c.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(s),"data-aqmx-expand-all":t.state,children:[s>0?c.jsx(v.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,c.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,s):n.foldersLoading(s)})]})},Hn=({stop:e,opened:t,budget:n})=>{const{labels:l}=v.useExplorer();return c.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:mt(l,n,e,t)})},Bn=({entries:e,...t})=>{const{trees:n}=v.useExplorer(),l=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:o}=t,[i]=r.useState(Yt),a=r.useMemo(()=>i(e,s=>n.children(o,s)),[i,e,n,o,l]);return a.length===0?c.jsx(Fn,{}):c.jsx(In,{entries:a,version:l,...t})},Zn=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:l}=v.useExplorer(),o=r.use(e);if(o.status==="deferred")return c.jsx(ht,{});if(o.status==="ok")return c.jsx(Bn,{entries:o.entries,...n});const i=l?.(o.failure);return c.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":o.failure.reason,children:i!==void 0?i:c.jsx(v.FailureView,{failure:o.failure,alert:!0,onRetry:t,testId:null})})},$n=({onControls:e,...t})=>{const{trees:n,storageNamespace:l,labels:o,announcer:i,config:a}=v.useExplorer(),{sourceId:s}=t,p=nt.useDirectoryTreeState({storageKey:Mt.storageKeys(l).treeExpansion(s)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const f=n.read(s),u=r.useCallback(()=>n.retry(s),[n,s]);r.useLayoutEffect(()=>n.open(s),[n,s]);const d=fn(),{expanded:h,expandMultiple:w,collapseAll:g}=p,[E,y]=r.useState(null),L=E!==h,j=r.useRef(h);r.useLayoutEffect(()=>{j.current=h},[h]);const S=a.expandAll,I=r.useCallback(()=>i.announce(o.expandAllStarted),[i,o]),M=r.useCallback(H=>i.announce(Mn(o,S,H)),[i,o,S]),T=xn({budget:S,expandMultiple:w,onStart:I,onFinish:M}),{status:C,start:P,end:O,advance:R}=T,k=C.state==="running",F=r.useMemo(()=>({running:k,advance:R}),[k,R]),D=r.useRef(null),[$,le]=r.useState(!1),ae=r.useCallback(H=>{D.current=H,le(H!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(H=>{const _=H.sourceId===s&&D.current!==null?ct(D.current,H.path):null;_!==null&&i.announce({list:o.foldersLoadFailedNamed,item:_.name})}),[n,s,i,o]);const{clearDirect:G}=d,[oe,Y]=r.useState(0),K=r.useCallback(()=>{Y(H=>H+1),O(),G(),y(j.current),g()},[O,G,g]);return r.useEffect(()=>{e({collapseAll:K,expandAll:$?P:null,expanding:k})},[e,K,P,$,k]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{$||O()},[$,O]),c.jsxs(c.Fragment,{children:[C.state==="stopped"?c.jsx(Hn,{stop:C.stop,opened:C.opened,budget:S}):null,c.jsxs("div",{className:"aqmx-explorer-tree-area",children:[c.jsx(r.Suspense,{fallback:c.jsx(ht,{}),children:c.jsx(Zn,{result:f,onRetry:u,expansion:p,onShown:ae,marks:d,claimsHeld:L,expandAll:F,revealCancel:oe,...t})}),c.jsx(Dn,{pending:n.pendingChildren(s),status:C})]})]})};function zn({title:e,titleId:t,...n},l){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:l,"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 Fe=m.forwardRef(zn),Je="markdown-explorer-selection-remove",Vn=({selection:e,onRemove:t,onClear:n,onOpenSelection:l,onLeave:o})=>{const{labels:i}=v.useExplorer(),a=r.useId(),s=r.useRef(null),p=[...e],f=(d,h)=>{if(h.ownerDocument.activeElement===h){const w=s.current===null?[]:[...s.current.querySelectorAll(`[data-testid="${Je}"]`)],g=w.indexOf(h),E=[w[g+1],w[g-1]].find(y=>y!==void 0);E===void 0?o():E.focus()}t(d)},u=()=>{const d=s.current;d!==null&&d.contains(d.ownerDocument.activeElement)&&o(),n()};return c.jsxs("section",{ref:s,className:"aqmx-explorer-tray","aria-labelledby":a,"data-testid":"markdown-explorer-selection-tray",children:[c.jsxs("div",{className:"aqmx-explorer-tray-header",children:[c.jsx("p",{id:a,className:"aqmx-explorer-tray-title",children:i.selectionTitle(p.length)}),c.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:u,children:i.clearSelection})]}),c.jsx("ul",{className:"aqmx-explorer-tray-list",children:p.map(([d,h])=>c.jsxs("li",{className:"aqmx-explorer-tray-item",children:[c.jsx("span",{className:"aqmx-explorer-tray-name",title:d,children:h}),c.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":i.removeFromSelection(h),title:i.removeFromSelection(h),"data-testid":Je,"data-aqmx-path":d,onClick:w=>f(d,w.currentTarget),children:c.jsx(Fe,{"aria-hidden":"true"})})]},d))}),l===void 0?null:c.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>l(p.map(([d])=>d)),children:i.openSelectionInMulti(p.length)})]})},Ce=new Map,Kn=(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},Un=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},xt=r.createContext(null),Wn=e=>{const t=r.use(xt);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};function Xn({title:e,titleId:t,...n},l){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:l,"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 Gn=m.forwardRef(Xn);function Yn({title:e,titleId:t,...n},l){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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M11.25 4.533A9.707 9.707 0 0 0 6 3a9.735 9.735 0 0 0-3.25.555.75.75 0 0 0-.5.707v14.25a.75.75 0 0 0 1 .707A8.237 8.237 0 0 1 6 18.75c1.995 0 3.823.707 5.25 1.886V4.533ZM12.75 20.636A8.214 8.214 0 0 1 18 18.75c.966 0 1.89.166 2.75.47a.75.75 0 0 0 1-.708V4.262a.75.75 0 0 0-.5-.707A9.735 9.735 0 0 0 18 3a9.707 9.707 0 0 0-5.25 1.533v16.103Z"}))}const Qn=m.forwardRef(Yn);function Jn({title:e,titleId:t,...n},l){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:l,"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 er=m.forwardRef(Jn);function tr({title:e,titleId:t,...n},l){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:l,"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 nr=m.forwardRef(tr);function rr({title:e,titleId:t,...n},l){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:l,"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 lr=m.forwardRef(rr);function ar({title:e,titleId:t,...n},l){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:l,"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 or=m.forwardRef(ar);function sr({title:e,titleId:t,...n},l){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:l,"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 cr=m.forwardRef(sr);function ir({title:e,titleId:t,...n},l){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:l,"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 ur=m.forwardRef(ir);function dr({title:e,titleId:t,...n},l){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:l,"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 fr=m.forwardRef(dr);function pr({title:e,titleId:t,...n},l){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:l,"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 mr=m.forwardRef(pr);function hr({title:e,titleId:t,...n},l){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:l,"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 xr=m.forwardRef(hr);function wr({title:e,titleId:t,...n},l){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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M4.125 3C3.089 3 2.25 3.84 2.25 4.875V18a3 3 0 0 0 3 3h15a3 3 0 0 1-3-3V4.875C17.25 3.839 16.41 3 15.375 3H4.125ZM12 9.75a.75.75 0 0 0 0 1.5h1.5a.75.75 0 0 0 0-1.5H12Zm-.75-2.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 0 1.5H12a.75.75 0 0 1-.75-.75ZM6 12.75a.75.75 0 0 0 0 1.5h7.5a.75.75 0 0 0 0-1.5H6Zm-.75 3.75a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5H6a.75.75 0 0 1-.75-.75ZM6 6.75a.75.75 0 0 0-.75.75v3c0 .414.336.75.75.75h3a.75.75 0 0 0 .75-.75v-3A.75.75 0 0 0 9 6.75H6Z",clipRule:"evenodd"}),m.createElement("path",{d:"M18.75 6.75h1.875c.621 0 1.125.504 1.125 1.125V18a1.5 1.5 0 0 1-3 0V6.75Z"}))}const gr=m.forwardRef(wr);function br({title:e,titleId:t,...n},l){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:l,"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 Er=m.forwardRef(br),vr=Object.freeze({sortMode:Gn,folderPlacement:fr,readmePlacement:Qn,selectionMode:er,doubleClickAction:cr,expandIconSize:xr,alwaysExpanded:v.ForwardRef$2,revealDocument:v.ForwardRef$1,showFolderReadme:gr,removeRootIndent:nr,lines:Er,expandIcons:lr,directoryIcons:mr,fileIcons:ur}),wt=(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 ${lt.describeValue(n)}`);return n},Rr=({id:e,settings:t,descriptors:n,onAdvance:l,onClose:o,ref:i})=>{const{labels:a}=v.useExplorer(),s=r.useRef([]);r.useEffect(()=>{s.current[0]?.focus()},[]);const p=r.useCallback(u=>{const d=n.length;s.current[(u%d+d)%d]?.focus()},[n.length]),f=r.useCallback((u,d)=>{switch(u.key){case"ArrowDown":u.preventDefault(),p(d+1);break;case"ArrowUp":u.preventDefault(),p(d-1);break;case"Home":u.preventDefault(),p(0);break;case"End":u.preventDefault(),p(n.length-1);break;case"Escape":v.consumeKey(u),o();break;case"Tab":o();break}},[n.length,p,o]);return c.jsx("div",{ref:i,id:e,role:"menu","aria-label":a.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((u,d)=>{const h=vr[u.key],w=wt(a,u),g=q.formatTreeSettingValue(a,t,u.key),E=t[u.key],y=typeof E=="boolean"?{role:"menuitemcheckbox","aria-checked":E,"aria-label":w}:{role:"menuitem","aria-label":`${w}: ${g}`};return c.jsxs("button",{ref:L=>{s.current[d]=L},type:"button",tabIndex:-1,...y,title:`${w}: ${g}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":u.key,onClick:()=>l(u),onKeyDown:L=>f(L,d),children:[c.jsx(h,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-menu-name",children:w}),c.jsx("span",{className:"aqmx-explorer-menu-value",children:g})]},u.key)})})},Sr=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:l,announcer:o}=v.useExplorer(),[i,a]=r.useState(!1),s=r.useRef(null),p=r.useRef(null),f=r.useRef(null),u=r.useId(),d=r.useCallback(()=>{s.current?.focus(),a(!1)},[]);r.useEffect(()=>{if(!i)return;const g=E=>{E.target instanceof Node&&(s.current?.contains(E.target)===!0||p.current?.contains(E.target)===!0)||(a(!1),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{f.current=null,(document.activeElement===null||document.activeElement===document.body)&&s.current?.focus()},0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[i]),r.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);const h=r.useCallback(g=>{g.key!=="Escape"||!i||(v.consumeKey(g),d())},[i,d]),w=r.useCallback(g=>{const E=n(g.key);o.announce(l.settingAnnouncement(wt(l,g),q.formatTreeSettingValue(l,E,g.key)))},[o,l,n]);return{trigger:c.jsx("button",{ref:s,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?u:void 0,"aria-label":l.treeSettings,title:l.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>a(g=>!g),onKeyDown:h,children:c.jsx(or,{"aria-hidden":"true"})}),menu:i?c.jsx(Rr,{ref:p,id:u,settings:e,descriptors:t,onAdvance:w,onClose:d}):null}},yr=()=>{const{treeSettings:e}=v.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},et=new Set,kr='[role="tree"] [role="treeitem"][tabindex="0"]',Cr="[data-directory-tree-tab-stop]",Tr=e=>{const{mode:t,sourceId:n,currentPath:l,openPaths:o,onOpenDocument:i,onSourceChange:a,onRevealSource:s,viewSwitch:p}=e,{labels:f,sources:u,trees:d,documents:h,announcer:w,reveals:g}=v.useExplorer(),{settings:E,advance:y}=yr(),L=r.useMemo(()=>q.visibleTreeSettingDescriptors(t),[t]),j=t==="tree"&&E.selectionMode==="multiple";Wn(j);const S=e.mode==="tree"?e.tray.onGatheredChange:null,I=e.mode==="tree"?e.onOpenSelection:void 0,M=e.mode==="tree"?e.onOpenFolder:null,T=e.mode==="tree"?e.onCloseFolder:null,C=e.mode==="tree"&&e.currentFolder,P=r.useMemo(()=>M===null||T===null||!E.showFolderReadme?null:{current:l,open:M,close:T},[M,T,l,E.showFolderReadme]),O=e.mode==="tree"&&j?e.tray.gathered:Ce,R=r.useCallback(N=>{const V=y(N);return V.selectionMode!=="multiple"&&S?.(Ce),V},[y,S]),k=Sr({settings:E,descriptors:L,onAdvance:R}),F=r.useCallback(N=>S?.(V=>Kn(V,N)),[S]),D=r.useCallback(N=>S?.(V=>Un(V,N)),[S]),$=r.useCallback(()=>S?.(Ce),[S]),le=r.useRef(null),ae=r.useCallback(()=>{const N=le.current;if(N===null)return;[kr,Cr,'[data-testid="markdown-explorer-tree-settings"]'].map(W=>N.querySelector(W)).find(W=>W!==null)?.focus()},[]),G=r.useMemo(()=>new Set(O.keys()),[O]),oe=r.useMemo(()=>l===null?et:new Set([l]),[l]),Y=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:o,shownPath:null,onChange:null};switch(E.selectionMode){case"single":return{mode:"single",items:oe,shownPath:l,onChange:null};case"multiple":return{mode:"multiple",items:G,shownPath:l,onChange:F};case"none":return{mode:"none",items:et,shownPath:null,onChange:null}}},[t,o,E.selectionMode,oe,l,G,F]),K=r.useMemo(()=>E.revealDocument?{path:l,openFolders:!C}:{path:Y.shownPath,openFolders:!1},[E.revealDocument,l,C,Y.shownPath]),H=r.useCallback(N=>{l!==null&&g.settle(l),a(N)},[l,g,a]),[_,we]=r.useState(null),[Q,se]=r.useState(!1),[re,me]=r.useState(null),ce=r.useRef(!1),ge=r.useCallback(async()=>{if(!ce.current){ce.current=!0,se(!0),me(null);try{const N=await d.refresh(n);if(N.status==="superseded")return;h.invalidate(),N.status==="failed"?me({sourceId:n,failure:N.failure}):w.announce(f.treeRefreshed)}finally{ce.current=!1,se(!1)}}},[d,h,n,w,f]),he=_===null?null:_.expandAll,U=_?.expanding===!0,ie=u.find(N=>N.id===n),be=p.target==="multi"?zt:Zt,ue=p.target==="multi"?f.switchToMulti:f.switchToTree;return c.jsxs("nav",{ref:le,"aria-label":f.explorerRegion,className:"aqmx-explorer","data-testid":"markdown-explorer-explorer","data-aqmx-mode":t,children:[c.jsxs("div",{className:"aqmx-explorer-header",children:[u.length>1?c.jsx("select",{className:"aqmx-explorer-source","aria-label":f.sourceLabel,title:ie?.label,value:n,onChange:N=>H(N.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:u.map(N=>c.jsx("option",{value:N.id,children:N.label},N.id))}):null,c.jsxs("div",{className:"aqmx-explorer-actions",children:[c.jsx(v.ExplorerLink,{to:p.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":ue,title:ue,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":p.target,children:c.jsx(be,{"aria-hidden":"true"})}),c.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:f.refreshTree,"aria-disabled":Q,"aria-busy":Q,"data-aqmx-busy":Q?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{ge()},children:[c.jsx(v.ForwardRef,{"aria-hidden":"true"}),c.jsx("span",{children:f.refreshTreeLabel})]}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.expandAll,title:f.expandAll,"aria-disabled":he===null||U,"aria-busy":U,"data-aqmx-busy":U?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>he?.(),children:c.jsx(Ht,{"aria-hidden":"true"})}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.collapseAll,title:f.collapseAll,"aria-disabled":_===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>_?.collapseAll(),children:c.jsx(It,{"aria-hidden":"true"})}),k.trigger]})]}),c.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[re!==null&&re.sourceId===n?c.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":re.failure.reason,children:f.treeRefreshFailed(v.failureTitleOf(f,re.failure.reason))}):null,c.jsx(r.Suspense,{fallback:null,children:c.jsx(Wt,{})}),c.jsx($n,{mode:t,sourceId:n,settings:E,reveal:K,openPaths:o,selection:Y,onOpenDocument:i,folders:P,onRevealSource:s,onControls:we},n),j&&O.size>0?c.jsx(Vn,{selection:O,onRemove:D,onClear:$,onOpenSelection:I,onLeave:ae}):null,k.menu]})]})};function Lr({title:e,titleId:t,...n},l){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:l,"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 gt=m.forwardRef(Lr),jr=({explorer:e,toggleRef:t,covered:n,merged:l,onNoticeSlotChange:o,dismissals:i})=>{const{labels:a}=v.useExplorer(),s=Te.useLocation(),p=Te.useNavigationType(),{location:f}=v.useExplorerLocation(),[u,d]=r.useState(!1),[h,w]=r.useState({navigated:s,source:f.source}),[g,E]=r.useState(!1);h.navigated!==s&&(w({navigated:s,source:f.source}),h.source===f.source&&!g&&v.explorerNavigationOf(p,s.state)!=="close-folder"&&d(!1));const[y,L]=r.useState(i);y!==i&&(L(i),d(!1));const j=r.useRef(null),S=r.useRef(null),I=r.useRef(null),M=r.useRef(!1),T=r.useId();r.useLayoutEffect(()=>{const k=j.current;k!==null&&(u&&!k.open?(k.showModal(),S.current?.focus()):!u&&k.open&&(k.close(),t.current?.focus()),o(u?I.current:null))},[u,t,o]),r.useLayoutEffect(()=>()=>o(null),[o]);const C=r.useCallback(k=>{k.key!=="Escape"||k.defaultPrevented||(v.consumeKey(k),d(!1))},[]),P=r.useCallback(k=>{M.current=k.target===k.currentTarget},[]),O=r.useCallback(k=>{const F=M.current;M.current=!1,F&&k.target===k.currentTarget&&d(!1)},[]),R=r.useCallback(()=>{d(!1)},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"aqmx-sheet-bar",inert:n,"data-testid":"markdown-explorer-sheet-bar","data-aqmx-sheet-bar-merged":l?"true":"false",children:c.jsxs("button",{ref:t,type:"button",className:"aqmx-explorer-toggle",title:l?a.showExplorer:void 0,"aria-haspopup":"dialog","aria-expanded":u,"aria-controls":T,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>d(!0),children:[c.jsx(gt,{"aria-hidden":"true"}),c.jsx("span",{className:l?"aqmx-sr-only":void 0,children:a.showExplorer})]})}),c.jsx("dialog",{ref:j,id:T,className:"aqmx-sheet","aria-label":a.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:C,onPointerDown:P,onClick:O,onClose:R,children:c.jsxs("div",{className:"aqmx-sheet-panel",children:[c.jsxs("div",{className:"aqmx-explorer-chrome",children:[c.jsx("div",{ref:I,className:"aqmx-sheet-notice-slot"}),c.jsx("button",{ref:S,type:"button",className:"aqmx-explorer-close","aria-label":a.hideExplorer,title:a.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>d(!1),children:c.jsx(Fe,{"aria-hidden":"true"})})]}),c.jsx("div",{className:"aqmx-sheet-body",children:c.jsx(Me,{value:u,children:c.jsx(xt,{value:E,children:e})})}),c.jsx(v.LiveRegion,{holds:u,deferWhileFullscreenIn:null,testId:"markdown-explorer-sheet-announcer"})]})})]})},bt=r.createContext(null),_e="aqmx-explorer",Et="aqmx-content",Ie='[role="tree"] [role="treeitem"]',Or=`${Ie}[tabindex="0"]`,Nr="[data-directory-tree-tab-stop]",Ar=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${_e}"] ${Ie}`))if(n.getAttribute(ne)===t)return n;return null},tt=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:q.ASSUMED_ROOT_FONT_PIXELS}),Pr=(e,t)=>{const[n,l]=r.useState(()=>tt(0,0));return r.useLayoutEffect(()=>{const o=e.current,i=t.current;if(o===null||i===null)throw new Error("[markdown-explorer] the split frame is not mounted");const a={frame:o.getBoundingClientRect().width,rem:i.getBoundingClientRect().width},s=()=>{const f=tt(a.frame,a.rem);l(u=>u.inlineSize===f.inlineSize&&u.rootFontPixels===f.rootFontPixels?u:f)};s();const p=new ResizeObserver(f=>{for(const u of f){const[d]=u.borderBoxSize;d!==void 0&&(u.target===o&&(a.frame=d.inlineSize),u.target===i&&(a.rem=d.inlineSize))}s()});return p.observe(o),p.observe(i),()=>p.disconnect()},[e,t]),n},vt=e=>`aqmx-split-handle-${e}`,qr=(e,{frameRef:t,sheetToggleRef:n,railToggleRef:l,closeButtonRef:o,handleId:i})=>{const a=r.useRef(!1),s=r.useRef(null),p=r.useRef(!1);r.useLayoutEffect(()=>{const u=t.current;if(u===null)throw new Error("[markdown-explorer] the split frame is not mounted");const d=w=>{const g=w.target instanceof Element?w.target:null;a.current=g!==null&&g.closest(`[data-panel-id="${Et}"]`)===null,!p.current&&(s.current=g?.closest(`${Ie}[${ne}]`)?.getAttribute(ne)??null)},h=w=>{w.relatedTarget instanceof Node&&!u.contains(w.relatedTarget)&&(a.current=!1)};return u.addEventListener("focusin",d),u.addEventListener("focusout",h),()=>{u.removeEventListener("focusin",d),u.removeEventListener("focusout",h)}},[t]);const f=r.useRef(e);r.useLayoutEffect(()=>{const u=f.current;if(u===e)return;f.current=e;const d=t.current;if(d===null||!a.current)return;const h=w=>{const{activeElement:g,body:E}=d.ownerDocument;if(g!==null&&g!==E)return;const y=w.find(L=>L!==null);if(y!=null){p.current=!0;try{y.focus()}finally{p.current=!1}}};if(e==="sheet"){h([n.current]);return}if(e==="rail"){h([l.current]);return}if(u==="rail"){h([o.current]);return}queueMicrotask(()=>{if(f.current!==e||!a.current)return;const w=s.current,g=`[data-panel-id="${_e}"]`;h([w===null?null:Ar(d,w),d.querySelector(`${g} ${Or}`),d.querySelector(`${g} ${Nr}`),d.querySelector(`[data-resize-handle-id="${i}"]`)])})},[e,t,n,l,o,i])},Mr=e=>e==="tree"?"treeExplorerHidden":"multiExplorerHidden",Fr=({view:e,explorer:t,content:n,contentCoversPage:l=!1,sheetDismissals:o=0,onDraggingChange:i})=>{const{viewSettings:a}=v.useExplorer(),s=r.useRef(null),[p,f]=r.useState(null),u=r.useRef(null),d=r.useRef(null),h=r.useRef(null),w=r.useRef(null),{inlineSize:g,rootFontPixels:E}=Pr(s,u),y=Mr(e),L=v.useViewSetting(R=>R[y]===!0),j=g!==null&&g<q.explorerSheetBelowPixels(E),S=j?"sheet":L?"rail":"split";qr(S,{frameRef:s,sheetToggleRef:d,railToggleRef:h,closeButtonRef:w,handleId:vt(e)});const I=r.useCallback(()=>a.update({[y]:!0}),[a,y]),M=r.useCallback(()=>a.update({[y]:!1}),[a,y]),[T,C]=r.useState(!1),P=r.useMemo(()=>j?{lane:!l,onBar:C}:null,[j,l]),[O]=r.useState(()=>new Map);return c.jsx(at,{value:O,children:c.jsxs("div",{ref:s,className:"aqmx-split-frame","data-aqmx-explorer-mode":S,"data-aqmx-measured":g===null?"false":"true","data-aqmx-content-covers-page":l?"true":"false",children:[c.jsx("span",{ref:u,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),j?c.jsx(jr,{explorer:t,toggleRef:d,covered:l,merged:T,onNoticeSlotChange:f,dismissals:o}):null,c.jsxs("div",{className:"aqmx-split-row",children:[S==="rail"?c.jsx(_r,{toggleRef:h,covered:l,onOpen:M}):null,c.jsx(bt,{value:j?p:null,children:c.jsx(v.SheetBarContext,{value:P,children:c.jsx(Ir,{view:e,mode:S,explorer:t,content:n,contentCoversPage:l,onDraggingChange:i,explorerMinPixels:q.explorerMinPixels(E),closeButtonRef:w,onHide:I})})})]})]})})},_r=({toggleRef:e,covered:t,onOpen:n})=>{const{labels:l}=v.useExplorer();return c.jsx("div",{className:"aqmx-split-rail",inert:t,"data-testid":"markdown-explorer-rail",children:c.jsx("button",{ref:e,type:"button",className:"aqmx-explorer-toggle","aria-expanded":!1,"aria-label":l.showExplorer,title:l.showExplorer,"data-testid":"markdown-explorer-rail-toggle",onClick:n,children:c.jsx(gt,{"aria-hidden":"true"})})})},Ir=({view:e,mode:t,explorer:n,content:l,contentCoversPage:o,onDraggingChange:i,explorerMinPixels:a,closeButtonRef:s,onHide:p})=>{const{viewSettings:f,labels:u}=v.useExplorer(),d=r.useMemo(()=>Xe.toPanelGroupLabels(u),[u]),w=v.useViewSetting(R=>e==="tree"?R.treeExplorer:R.multiExplorer)??(e==="tree"?q.EXPLORER_DEFAULT_PERCENT:q.EXPLORER_MULTI_DEFAULT_PERCENT),g=r.useRef(!1),[E,y]=r.useState(!1),L=r.useRef(!1),j=r.useRef(i);r.useLayoutEffect(()=>{j.current=i},[i]);const S=Xe.useSplitPersistence(r.useCallback(R=>{if(R.length!==2)return;const[k=0,F=0]=R,D=k+F;if(D<=0||k<=0)return;const $=Math.min(q.EXPLORER_MAX_PERCENT,k/D*100);f.update(e==="tree"?{treeExplorer:$}:{multiExplorer:$})},[f,e]));r.useEffect(()=>()=>{g.current&&j.current?.(!1)},[]);const M=v.useCoarsePointer()?q.COARSE_TARGET_PIXELS:q.FINE_TARGET_PIXELS,T=t==="split",C=r.useCallback(()=>{L.current=!1,y(!1),p()},[p]),P=r.useCallback((R,k)=>{const[F=0,D=0]=R;R.length===2&&D>0&&(L.current=F<=0,y(L.current)),S.layoutChanged(R,k),L.current&&k.source==="keyboard"&&C()},[S,C]),O=r.useCallback(R=>{g.current=R,i?.(R),S.draggingChanged(R),!R&&L.current&&C()},[i,S,C]);return c.jsxs(ke.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:P,labels:d,className:"aqmx-split","data-aqmx-split":e,children:[T?c.jsxs(ke.Panel,{id:_e,defaultSize:{value:w,unit:"percentage"},minSize:{value:a,unit:"pixels"},maxSize:{value:q.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:o,className:"aqmx-split-explorer",children:[c.jsx("div",{className:"aqmx-explorer-chrome",children:c.jsx("button",{ref:s,type:"button",className:"aqmx-explorer-close","aria-label":u.hideExplorer,title:u.hideExplorer,"data-testid":"markdown-explorer-split-close",onClick:C,children:c.jsx(Fe,{"aria-hidden":"true"})})}),c.jsx(Me,{value:!E,children:n})]}):null,T?c.jsx(ke.PanelResizeHandle,{id:vt(e),thickness:M,indicator:{visible:!0,thickness:q.SPLIT_HANDLE_PIXELS.gripThickness,length:q.SPLIT_HANDLE_PIXELS.gripLength,barThickness:q.SPLIT_HANDLE_PIXELS.barThickness,barLength:q.SPLIT_HANDLE_PIXELS.barLength},title:u.resizeExplorer,"aria-label":u.resizeExplorer,onDragging:O,inert:o,className:"aqmx-split-handle"}):null,c.jsx(ke.Panel,{id:Et,defaultSize:{value:T?100-w:100,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...o?{style:{isolation:"auto"}}:{},children:l})]})};exports.EMPTY_SELECTION=Ce;exports.ExplorerPane=Tr;exports.ExplorerSplit=Fr;exports.SheetNoticeSlotContext=bt;
|