@aiquants/markdown-explorer 0.10.0 → 0.12.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/README.md +66 -6
  3. package/dist/EditSurface-BTAhzvHi.js +509 -0
  4. package/dist/EditSurface-Dfj6Sxxb.cjs +2 -0
  5. package/dist/ExplorerSplit-DekOjAUZ.cjs +1 -0
  6. package/dist/{ExplorerSplit-D0zf7Cr_.js → ExplorerSplit-MPHjw3nW.js} +251 -248
  7. package/dist/{MultiLayout-Jy9BKofx.js → MultiLayout-DtSW4rEQ.js} +4 -4
  8. package/dist/{MultiLayout-Bq10p3a3.cjs → MultiLayout-HMzVDYWq.cjs} +1 -1
  9. package/dist/{NativeScrollBar-Dt6xH5Mb.cjs → NativeScrollBar-B0AkVF3E.cjs} +1 -1
  10. package/dist/{NativeScrollBar-CyiyL47o.js → NativeScrollBar-CNQr7JY1.js} +1 -1
  11. package/dist/{TreeLayout-8pRo1ANN.js → TreeLayout-CJO9tOPq.js} +3 -3
  12. package/dist/{TreeLayout-kVWFEKJD.cjs → TreeLayout-_XQR-9tV.cjs} +1 -1
  13. package/dist/client/MarkdownExplorer.d.cts +3 -2
  14. package/dist/client/MarkdownExplorer.d.ts +3 -2
  15. package/dist/core/contracts.d.cts +17 -0
  16. package/dist/core/contracts.d.ts +17 -0
  17. package/dist/core/labels.d.cts +2 -0
  18. package/dist/core/labels.d.ts +2 -0
  19. package/dist/core/treeSettings.d.cts +2 -1
  20. package/dist/core/treeSettings.d.ts +2 -1
  21. package/dist/dataRoute-CH3yOKR0.cjs +1 -0
  22. package/dist/dataRoute-Pm_0ue_4.js +279 -0
  23. package/dist/index-DpIVKG8Y.cjs +13 -0
  24. package/dist/{index-CfcJEnrC.js → index-o6OpR4ND.js} +967 -907
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.d.cts +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +9 -9
  29. package/dist/location-BUNWJ4eB.cjs +1 -0
  30. package/dist/{location-Dc1qNEGm.js → location-DWd6SQhN.js} +123 -112
  31. package/dist/{merge-D0aGvFKC.cjs → merge-Bs7o3GyP.cjs} +1 -1
  32. package/dist/{merge-SRCxtHk2.js → merge-DDJaJmMU.js} +1 -1
  33. package/dist/sanitizePolicy-BfUlXI5E.cjs +1 -0
  34. package/dist/sanitizePolicy-djLC3fRN.js +96 -0
  35. package/dist/sanitizeWorker.cjs +1 -1
  36. package/dist/sanitizeWorker.js +143 -226
  37. package/dist/server.cjs +1 -1
  38. package/dist/server.js +548 -540
  39. package/docs/behavior/dom-hooks.md +2 -2
  40. package/docs/behavior/localization.md +1 -0
  41. package/docs/behavior/security.md +2 -0
  42. package/package.json +3 -3
  43. package/dist/EditSurface-1Jf0CG-f.js +0 -371
  44. package/dist/EditSurface-B-l3Do_C.cjs +0 -2
  45. package/dist/ExplorerSplit-WX8afxrQ.cjs +0 -1
  46. package/dist/dataRoute-8pyILcjL.cjs +0 -1
  47. package/dist/dataRoute-Csl1WBDz.js +0 -278
  48. package/dist/index-sNJrKoGN.cjs +0 -13
  49. package/dist/location-CRYkEWiC.cjs +0 -1
@@ -53,7 +53,7 @@ Tests and host styling may rely on the `data-testid` values and `data-aqmx-*` at
53
53
  | `data-testid="markdown-explorer-tree-empty"` | Empty tree message | |
54
54
  | `data-testid="markdown-explorer-tree-progress"` | Progress line floating at the bottom of the tree area (not a live region) | Shown while an Expand all press runs, and otherwise while the source has folder listings queued or in flight (after a press stopped at a limit too: the stop sentence is `markdown-explorer-expand-all-stop`'s, never this line's). Carries `data-aqmx-loading` (the source's queued and in-flight listings, whichever rows are drawn) and `data-aqmx-expand-all` (`idle` / `running` / `stopped`) |
55
55
  | `data-testid="markdown-explorer-tree-failure"` | Tree failure | Carries `data-aqmx-failure` (the reason) and holds the failure's callout, `role="alert"`; a host's `renderTreeFailure` view replaces the callout inside it (this element and its hooks stay) and must announce itself |
56
- | Tree rows | `role="treeitem"` | Carry `data-aqmx-path` (the entry's path; the split also returns the focus to the same row through it after the sheet threshold), `data-aqmx-open` on documents open as panels (open rows are styled through it), and `data-aqmx-children` (`loading` / `failed`) on lazy folders: `loading` only while some tree still shows the folder open (a cancelled folder loses it). The shown document's row carries `aria-current="page"` in the tree view with Selection Single or Multiple |
56
+ | Tree rows | `role="treeitem"` | Carry `data-aqmx-path` (the entry's path; the split also returns the focus to the same row through it after the sheet threshold), `data-aqmx-modified-at` when the source gave the entry a modification time (epoch milliseconds, which the Modified orders sort by), `data-aqmx-open` on documents open as panels (open rows are styled through it), and `data-aqmx-children` (`loading` / `failed`) on lazy folders: `loading` only while some tree still shows the folder open (a cancelled folder loses it). The shown document's row carries `aria-current="page"` in the tree view with Selection Single or Multiple |
57
57
  | Loop rows | `role="treeitem"` with `data-aqmx-loop` | A folder met again among its own ancestors (a shortcut inside its own target): `data-aqmx-loop` is the path of the folder it loops back to, and the row has no `data-aqmx-path`. It never expands; activating it scrolls to that folder, above it, and moves the focus there |
58
58
  | `data-testid="markdown-explorer-folder-retry"` | Retry inside a folder whose children failed | Named by its text (`retry`) also while a narrow row shows only its icon, and described by the failure text (`aria-describedby`); activating it while it holds the focus moves the focus to the folder's row before the children load again |
59
59
  | `data-testid="markdown-explorer-selection-tray"` | Selection tray (multiple selection) | |
@@ -79,7 +79,7 @@ The tree is named by `treeRegion`, apart from the explorer `nav` (`explorerRegio
79
79
  | `data-testid="markdown-explorer-edit-skeleton"` | Placeholder while the source for editing (or the editor's chunk) loads | Hidden from assistive technology; the screen-reader text `editLoading` sits beside it |
80
80
  | `data-testid="markdown-explorer-edit-grant"` / `-open` / `-retry` | The notice when opening the editor needs a grant, its action (a button with `onEditGrant`, else a link) and Try again | |
81
81
  | `data-testid="markdown-explorer-edit-failure"` / `markdown-explorer-edit-load-failure` | Failure to open the source for editing, or to load the editor's chunk | Carry `data-aqmx-failure`; no role (the announcer speaks an opening failure) |
82
- | `data-testid="markdown-explorer-edit-preview"` | The draft's preview (`role="region"`, named `previewRegion`) | `aria-busy` while a newer rendering is on its way; holds `-preview-skeleton` before the first rendering and `-preview-failure` (a notice) after a failed one |
82
+ | `data-testid="markdown-explorer-edit-preview"` | The draft's preview (`role="region"`, named `previewRegion`) | Carries `data-aqmx-preview-tier`: `instant` (the host's draft converter renders drafts in the browser) or `server` (the server renders them: no converter, or a draft the converter cannot render). `aria-busy` until the first rendering lands and while the server renders a newer draft, never for a rendering in the browser; before the first rendering it shows the document's own rendering, or holds `-preview-skeleton` when that is not loaded; holds `-preview-failure` (a notice) after a failed rendering |
83
83
  | `data-testid="markdown-explorer-image-view"` | Image viewer | |
84
84
  | `data-testid="markdown-explorer-image-canvas"` | The image's scroll area | The element that scrolls. In the tree and single views it sits in `@aiquants/markdown`'s HostedScrollArea row (`data-aqmd-scroll-row`, inside its clipping cell `data-aqmd-scroll-clip`), whose bar slot (`data-aqmd-scroll-bar`) holds the explorer's pointer scroll bar; so do a medium's and a file view's stage and the failure view (`data-aqmx-document-scroller`). In a multi-view panel they have no row |
85
85
  | `data-testid="markdown-explorer-image"` | The image (`img`) | Carries `data-aqmx-image-mode` (`fit` / `level`) |
@@ -45,6 +45,7 @@ const HANDBOOK_LABELS = {
45
45
  ## Formatting
46
46
 
47
47
  Counts and percentages are formatted by the label functions themselves, so a host that needs grouping or another numeral system overrides the function. The tree keeps the order its source returns unless the configuration's `defaultTreeSettings` sets a sort order or the reader picks one in the tree settings; sorted entries are compared with `Intl.Collator("en", { numeric: true, sensitivity: "variant" })` — numeric-aware and independent of the UI language, so a source sorts the same for every reader.
48
+ The sort order's menu row cycles through "Source order", "Name A→Z", "Name Z→A", "Modified old→new" and "Modified new→old" in English and 「取得順」「名前の昇順」「名前の降順」「更新日時の昇順 (古い順)」「更新日時の降順 (新しい順)」 in Japanese (`sortNative`, `sortAscending`, `sortDescending`, `sortOldest`, `sortNewest`). The Modified orders compare the entries' `modifiedAt`, put the entries whose time the source does not know last in both directions, and break equal or unknown times by name, A to Z.
48
49
  Folders keep their place among the files unless the folder placement puts them first or last; its menu row reads "Folders: Mixed / First / Last" in English and 「フォルダーの位置: 混ぜる / 先に / 後に」 in Japanese (`settingFolderPlacement`, `folderPlacementMixed`, `folderPlacementFirst`, `folderPlacementLast`). The reveal's switch is `settingRevealDocument` ("Reveal the open document", 「開いた文書をツリーで表示」).
49
50
 
50
51
  ## Strings outside the catalog
@@ -116,6 +116,8 @@ In a tree or children listing, an entry with an empty name, or with a path the b
116
116
  - `save` and `preview` are `POST` only, and need `X-Markdown-Explorer: edit` and the shared cross-origin check of a refresh (`crossOriginRefusal`), checked before the body is read (403). The body must be `text/markdown` with no charset or `utf-8` (else 400); a declared or actual length over `editMaxBytes` is refused (413) and the reading stops at the first byte past the limit; invalid UTF-8 and NUL are refused (400). All of this happens before any port is called.
117
117
  - `base` (a save's version) and `revision` are tokens of 1 to 1024 characters (400 otherwise). A version, a revision id and a grant are copied from the ports' answers only in their contract's shape: a grant's `href` must be root-relative, an external editor's `href` an absolute `https:` URL; sources, conflict texts and revisions longer than `editMaxBytes`, and malformed revisions, are logged and answered `failed`.
118
118
  - The preview's HTML goes through the same sanitizer, limits and reader share as a document's. The sanitizer keeps a converter's source lines only as `data-source-lines="<first>-<last>"` (positive line numbers, the first not after the last).
119
+ - With a draft converter (`draftConverter`), a draft is rendered in the browser and sanitized there before it is shown, by the same allow-list rules (`core/sanitizePolicy`, on a DOMPurify instance of the preview's own from `isomorphic-dompurify`'s browser build, so no hook another script adds to the page's shared DOMPurify takes part) and the same nesting limit (`too-large` deeper than 512 levels). The server's other resource limits do not apply there: the host's converter bounds the HTML (`maxHtmlBytes`), and the rendering never leaves the browser.
120
+ The only thing the browser takes from the server for it is the existence marks of images and linked documents, read from the HTML the server's `preview` operation answered (sanitized on the server) and written by the browser's sanitizer onto the elements naming the same document paths, exactly as the converter writes them; a draft the converter answers `unavailable` for is rendered by the server as before.
119
121
  - What the host must do: decide per document and per reader whether a document is editable, and check it again in every port (a request names any admitted path); write with the reader's own credentials, never a service account's; write only when the document still has the draft's base version, and otherwise answer the current content without writing; keep revisions only where readers may see them.
120
122
 
121
123
  ## Link cards
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiquants/markdown-explorer",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Markdown document explorer for React Router 8 (framework mode): a source tree with a single-document view and a multi-panel reading view, storage-agnostic server ports, golden-ratio layout and an en / ja UI.",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -69,7 +69,7 @@
69
69
  "peerDependencies": {
70
70
  "@aiquants/directory-tree": "^4.1.1",
71
71
  "@aiquants/drag-drop-panels": "^0.10.0",
72
- "@aiquants/markdown": "^6.3.0",
72
+ "@aiquants/markdown": "^6.4.0",
73
73
  "@aiquants/resize-panels": "^2.1.0",
74
74
  "@aiquants/virtualscroll": "^3.17.0",
75
75
  "react": "^19.2.7",
@@ -79,7 +79,7 @@
79
79
  "devDependencies": {
80
80
  "@aiquants/directory-tree": "4.1.1",
81
81
  "@aiquants/drag-drop-panels": "0.10.0",
82
- "@aiquants/markdown": "6.3.0",
82
+ "@aiquants/markdown": "6.4.0",
83
83
  "@aiquants/resize-panels": "2.1.0",
84
84
  "@aiquants/virtualscroll": "3.17.0",
85
85
  "@heroicons/react": "^2.2.0",
@@ -1,371 +0,0 @@
1
- import { jsxs as P, jsx as x, Fragment as se } from "react/jsx-runtime";
2
- import { useState as U, useRef as A, useEffect as N, useEffectEvent as le, useLayoutEffect as C, useImperativeHandle as ie, useMemo as $, useCallback as J } from "react";
3
- import { v as D, f as V, g as ae, u as K, h as Y, i as ce, l as ue, F as de, E as fe, j as me, p as pe, A as he, k as ge } from "./index-CfcJEnrC.js";
4
- import { history as xe, historyKeymap as be, defaultKeymap as ve, historyField as Ee } from "@codemirror/commands";
5
- import { markdown as ye, markdownLanguage as ke } from "@codemirror/lang-markdown";
6
- import { syntaxHighlighting as we, HighlightStyle as qe } from "@codemirror/language";
7
- import { highlightSelectionMatches as Se, searchKeymap as Le } from "@codemirror/search";
8
- import { EditorState as X, EditorSelection as H, StateField as Te, RangeSetBuilder as Me } from "@codemirror/state";
9
- import { EditorView as w, lineNumbers as Ae, highlightActiveLineGutter as Oe, drawSelection as Ce, highlightActiveLine as Re, keymap as Ie, Decoration as _, WidgetType as Ne } from "@codemirror/view";
10
- import { tags as g } from "@lezer/highlight";
11
- import { MarkdownViewer as De } from "@aiquants/markdown";
12
- const Q = { history: Ee }, _e = qe.define([
13
- { tag: [g.heading1, g.heading2, g.heading3, g.heading4, g.heading5, g.heading6, g.heading], color: "var(--aqmx-syntax-heading)", fontWeight: "700" },
14
- { tag: g.strong, fontWeight: "700" },
15
- { tag: g.emphasis, fontStyle: "italic" },
16
- { tag: g.strikethrough, textDecoration: "line-through" },
17
- { tag: g.link, color: "var(--aqmx-syntax-link)", textDecoration: "underline" },
18
- { tag: g.url, color: "var(--aqmx-syntax-url)" },
19
- { tag: g.monospace, color: "var(--aqmx-syntax-code)" },
20
- { tag: g.quote, color: "var(--aqmx-syntax-quote)" },
21
- { tag: [g.processingInstruction, g.contentSeparator, g.labelName, g.meta], color: "var(--aqmx-syntax-mark)" }
22
- ]), Fe = w.theme({
23
- "&": { height: "100%", color: "var(--aqmx-text)", backgroundColor: "var(--aqmx-surface)", fontSize: "var(--aqmx-font-size-title)" },
24
- "&.cm-focused": { outline: "none" },
25
- ".cm-scroller": { fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace', lineHeight: "var(--aqmx-line-height-prose)" },
26
- ".cm-content": { caretColor: "var(--aqmx-text)", paddingBlock: "var(--aqmx-space-6)" },
27
- ".cm-line": { paddingInline: "var(--aqmx-space-6)" },
28
- "&.cm-focused .cm-cursor": { borderLeftColor: "var(--aqmx-text)" },
29
- "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: "var(--aqmx-editor-selection)" },
30
- ".cm-activeLine": { backgroundColor: "var(--aqmx-editor-active-line)" },
31
- ".cm-gutters": { backgroundColor: "var(--aqmx-surface-raised)", color: "var(--aqmx-editor-gutter)", borderInlineEnd: "var(--aqmx-space-1) solid var(--aqmx-border)" },
32
- ".cm-activeLineGutter": { backgroundColor: "var(--aqmx-editor-active-line)" },
33
- ".cm-searchMatch": { outline: "var(--aqmx-space-1) solid var(--aqmx-border-strong)" },
34
- ".cm-panels": { backgroundColor: "var(--aqmx-surface-raised)", color: "var(--aqmx-text)" }
35
- }), Z = "data-aqmx-conflict-actions", Be = _.line({ attributes: { "data-aqmx-conflict-line": "marker" } }), He = _.line({ attributes: { "data-aqmx-conflict-line": "ours" } }), Pe = _.line({ attributes: { "data-aqmx-conflict-line": "theirs" } });
36
- class Ve extends Ne {
37
- constructor(t, n) {
38
- super(), this.index = t, this.labels = n;
39
- }
40
- index;
41
- labels;
42
- eq(t) {
43
- return t.index === this.index && t.labels === this.labels;
44
- }
45
- toDOM(t) {
46
- const n = document.createElement("div");
47
- n.setAttribute(Z, String(this.index));
48
- for (const [s, d] of [
49
- ["ours", this.labels.useOurs],
50
- ["theirs", this.labels.useTheirs],
51
- ["both", this.labels.keepBoth]
52
- ]) {
53
- const c = document.createElement("button");
54
- c.type = "button", c.textContent = d, c.setAttribute("data-aqmx-conflict-choice", s), c.addEventListener("mousedown", (a) => a.preventDefault()), c.addEventListener("click", () => {
55
- const a = I(t.state.doc)[this.index];
56
- a !== void 0 && (ee(t, a, s), t.focus());
57
- }), n.append(c);
58
- }
59
- return n;
60
- }
61
- ignoreEvent() {
62
- return !0;
63
- }
64
- }
65
- const I = (e) => ae(e.iterLines()), j = (e, t) => {
66
- const n = new Me();
67
- return I(e).forEach((s, d) => {
68
- const c = e.line(s.start);
69
- n.add(c.from, c.from, _.widget({ widget: new Ve(d, t), block: !0, side: -1 }));
70
- for (let a = s.start; a <= s.end; a += 1) {
71
- const r = e.line(a).from, p = a === s.start || a === s.separator || a === s.end ? Be : a < s.separator ? He : Pe;
72
- n.add(r, r, p);
73
- }
74
- }), n.finish();
75
- }, Ke = (e) => Te.define({
76
- create: (t) => j(t.doc, e),
77
- update: (t, n) => n.docChanged ? j(n.state.doc, e) : t,
78
- provide: (t) => w.decorations.from(t)
79
- }), ee = (e, t, n) => {
80
- const { doc: s } = e.state, d = (m, l) => {
81
- const f = [];
82
- for (let u = m; u <= l; u += 1) f.push(s.line(u).text);
83
- return f;
84
- }, c = d(t.start + 1, t.separator - 1), a = d(t.separator + 1, t.end - 1), r = n === "ours" ? c : n === "theirs" ? a : [...c, ...a];
85
- let p = s.line(t.start).from, o = s.line(t.end).to;
86
- r.length === 0 && (t.end < s.lines ? o += 1 : t.start > 1 && (p -= 1));
87
- const i = r.join(`
88
- `);
89
- e.dispatch({ changes: { from: p, to: o, insert: i }, selection: H.cursor(p), scrollIntoView: !0, userEvent: "input.resolve" });
90
- }, We = ({ parent: e, scroll: t, text: n, saved: s, labels: d, onChange: c, onSave: a }) => {
91
- const r = [
92
- w.scrollHandler.of((i, m, l) => (je(i, m.head, l, t), !0)),
93
- Ae(),
94
- Oe(),
95
- xe(),
96
- Ce(),
97
- Re(),
98
- Se(),
99
- w.lineWrapping,
100
- ye({ base: ke }),
101
- we(_e),
102
- Ke(d),
103
- Ie.of([
104
- {
105
- key: "Mod-s",
106
- preventDefault: !0,
107
- run: () => (a(), !0)
108
- },
109
- ...Le,
110
- ...be,
111
- ...ve
112
- ]),
113
- w.contentAttributes.of({ "aria-label": d.editor, "aria-multiline": "true" }),
114
- w.updateListener.of((i) => {
115
- i.docChanged && c();
116
- }),
117
- Fe
118
- ], p = Ue(s, r) ?? X.create({ doc: n, extensions: r }), o = new w({ state: p, parent: e });
119
- return {
120
- text: () => o.state.doc.toString(),
121
- replaceText: (i) => {
122
- const m = o.state.doc.toString();
123
- if (m === i) return;
124
- let l = 0;
125
- const f = Math.min(m.length, i.length);
126
- for (; l < f && m.charCodeAt(l) === i.charCodeAt(l); ) l += 1;
127
- let u = 0;
128
- for (; u < f - l && m.charCodeAt(m.length - 1 - u) === i.charCodeAt(i.length - 1 - u); ) u += 1;
129
- o.dispatch({ changes: { from: l, to: m.length - u, insert: i.slice(l, i.length - u) }, userEvent: "input.replace" });
130
- },
131
- reveal: ({ line: i, column: m }, l) => {
132
- const { doc: f } = o.state, u = f.line(Math.min(Math.max(i, 1), f.lines)), h = Math.min(u.from + m, u.to);
133
- o.dispatch({ selection: H.cursor(h), effects: z(o, h, l, t) });
134
- },
135
- showLine: (i) => {
136
- const { doc: m } = o.state, l = m.line(Math.min(Math.max(i, 1), m.lines)).from;
137
- o.dispatch({ effects: z(o, l, null, t) });
138
- },
139
- topLine: () => {
140
- const i = t.scrollerOf(o.scrollDOM), m = D(i, o.contentDOM), l = V(i) + i.clientHeight, { documentTop: f } = o, { doc: u } = o.state;
141
- let h = o.lineBlockAtHeight(Math.max(m - f, 0));
142
- for (; u.lineAt(h.from).text.trim() === "" && h.to < u.length; ) {
143
- const L = o.lineBlockAt(h.to + 1);
144
- if (f + L.top >= l) break;
145
- h = L;
146
- }
147
- const y = o.coordsAtPos(h.from), S = y === null ? f + h.top : y.top;
148
- return { line: o.state.doc.lineAt(h.from).number, clientTop: S, offset: S - m };
149
- },
150
- scrollElement: o.scrollDOM,
151
- focus: () => o.focus(),
152
- conflicts: () => I(o.state.doc),
153
- resolveAtCursor: (i) => {
154
- const m = I(o.state.doc), l = o.state.doc.lineAt(o.state.selection.main.head).number, f = m.find((u) => u.end >= l);
155
- return f === void 0 ? !1 : (ee(o, f, i), !0);
156
- },
157
- nextConflict: () => {
158
- const i = I(o.state.doc);
159
- if (i[0] === void 0) return !1;
160
- const l = o.state.doc.lineAt(o.state.selection.main.head).number, f = i.findIndex((S) => S.start > l), u = f < 0 ? 0 : f, h = o.state.doc.line(i[u].start).from;
161
- o.dispatch({ selection: H.cursor(h), effects: w.scrollIntoView(h, { y: "center" }) });
162
- const y = o.contentDOM.querySelector(`[${Z}="${String(u)}"] button`);
163
- return y instanceof HTMLElement ? y.focus({ preventScroll: !0 }) : o.focus(), !0;
164
- },
165
- save: () => o.state.toJSON(Q),
166
- destroy: () => o.destroy()
167
- };
168
- }, z = (e, t, n, s) => {
169
- const d = s.scrollerOf(e.scrollDOM), c = (n === null ? D(d, e.contentDOM) : n) - V(d);
170
- return w.scrollIntoView(t, { y: "start", yMargin: c });
171
- }, je = (e, t, n, s) => {
172
- const d = ze(e, t), c = s.scrollerOf(e.scrollDOM), a = V(c), r = D(c, e.contentDOM), p = a + c.clientHeight;
173
- let o = 0;
174
- switch (n.y) {
175
- case "start":
176
- o = d.top - (a + n.yMargin);
177
- break;
178
- case "center":
179
- o = (d.top + d.bottom) / 2 - (r + p) / 2;
180
- break;
181
- case "end":
182
- o = d.bottom - (p - n.yMargin);
183
- break;
184
- default:
185
- d.top < r + n.yMargin ? o = d.top - (r + n.yMargin) : d.bottom > p - n.yMargin && (o = Math.min(d.bottom - (p - n.yMargin), d.top - (r + n.yMargin)));
186
- }
187
- if (o !== 0 && (c.scrollTop += o), n.y === "start") return;
188
- const i = Ge(e, t);
189
- i !== null && s.reveal(i);
190
- }, ze = (e, t) => {
191
- const { node: n, offset: s } = e.domAtPos(t);
192
- if (n.nodeType === Node.TEXT_NODE) {
193
- const a = n.ownerDocument?.createRange();
194
- if (a !== void 0) {
195
- a.setStart(n, s), a.setEnd(n, s);
196
- const [r] = a.getClientRects();
197
- if (r !== void 0 && r.height > 0) return { top: r.top, bottom: r.bottom };
198
- }
199
- }
200
- const d = e.lineBlockAt(t), c = e.documentTop + d.top;
201
- return { top: c, bottom: c + d.height };
202
- }, Ge = (e, t) => {
203
- const { node: n } = e.domAtPos(t);
204
- for (let s = n instanceof Element ? n : n.parentElement; s !== null; s = s.parentElement)
205
- if (s.parentElement === e.contentDOM) return s;
206
- return null;
207
- }, Ue = (e, t) => {
208
- if (e == null) return null;
209
- try {
210
- return X.fromJSON(e, { extensions: t }, Q);
211
- } catch {
212
- return null;
213
- }
214
- }, $e = 610, Je = "[data-aqmd-scroll-container]", Ye = Object.freeze(["p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8"]), Xe = Object.freeze({ parsed: null, failure: null, busy: !0 }), G = (e, t) => {
215
- const n = e.querySelector(Je), s = ce(e, t.line);
216
- n === null || s === null || (n.scrollTop += ue(s, t.line) - (D(n, s) + t.offset));
217
- }, Qe = ({ path: e, text: t, viewer: n, editorPoint: s, handleRef: d }) => {
218
- const { data: c, labels: a } = K(), [r, p] = U(Xe), o = A(null);
219
- N(() => {
220
- const l = new AbortController();
221
- p((u) => u.busy ? u : { ...u, busy: !0 });
222
- const f = setTimeout(() => {
223
- c.preview(e, t, l.signal).then((u) => {
224
- l.signal.aborted || !("kind" in u) || (u.kind === "failure" ? p((h) => ({ parsed: h.parsed, failure: u.failure, busy: !1 })) : p({ parsed: { htmlContent: u.htmlContent, headings: [...u.headings] }, failure: null, busy: !1 }));
225
- });
226
- }, $e);
227
- return () => {
228
- clearTimeout(f), l.abort();
229
- };
230
- }, [c, e, t]);
231
- const i = le(() => {
232
- const l = o.current, f = s();
233
- l !== null && f !== null && G(l, f);
234
- });
235
- C(() => {
236
- r.parsed !== null && i();
237
- }, [r.parsed]), ie(
238
- d,
239
- () => ({
240
- follow: (l) => {
241
- const f = o.current;
242
- f !== null && G(f, l);
243
- }
244
- }),
245
- []
246
- );
247
- const m = $(() => ({ ...n, showToc: !1, showStyle: !1, showAlign: !1, renderScrollBar: void 0 }), [n]);
248
- return /* @__PURE__ */ P("section", { ref: o, className: "aqmx-edit-preview", "aria-label": a.previewRegion, "aria-busy": r.busy, "data-testid": "markdown-explorer-edit-preview", children: [
249
- r.failure === null ? null : /* @__PURE__ */ x("p", { className: "aqmx-callout aqmx-document-notice", "data-aqmx-tone": "warning", "data-testid": "markdown-explorer-edit-preview-failure", children: a.previewFailed(Y(a, r.failure.reason)) }),
250
- r.parsed !== null ? /* @__PURE__ */ x("div", { className: "aqmx-document-viewer", children: /* @__PURE__ */ x(De, { ...m, parseResult: r.parsed, content: null }) }) : r.failure === null ? /* @__PURE__ */ x("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-edit-preview-skeleton", children: Ye.map((l) => /* @__PURE__ */ x("span", {}, l)) }) : null,
251
- r.busy ? /* @__PURE__ */ x("p", { className: "aqmx-sr-only", children: a.previewUpdating }) : null
252
- ] });
253
- }, Ze = 144, et = Object.freeze(["e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8"]), tt = (e) => {
254
- if (typeof e != "object" || e === null) return !1;
255
- const { generation: t, topLine: n } = e;
256
- return "state" in e && typeof t == "number" && typeof n == "number";
257
- }, nt = (e) => {
258
- e.key === "Escape" && ge(e);
259
- }, ot = (e) => {
260
- e.stopPropagation();
261
- }, gt = (e) => {
262
- const { path: t, name: n, session: s } = e, { edits: d, labels: c, announcer: a } = K(), { phase: r } = s, p = J(() => d.retry(t), [d, t]);
263
- switch (N(() => {
264
- r.kind === "failed" && a.announce(c.documentFailed(n, Y(c, r.failure.reason)));
265
- }, [r, a, c, n]), r.kind) {
266
- case "opening":
267
- return /* @__PURE__ */ P(se, { children: [
268
- /* @__PURE__ */ x("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-edit-skeleton", children: et.map((o) => /* @__PURE__ */ x("span", {}, o)) }),
269
- /* @__PURE__ */ x("p", { className: "aqmx-sr-only", children: c.editLoading })
270
- ] });
271
- case "grant":
272
- return /* @__PURE__ */ x("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ x(fe, { href: r.href, onRetry: p, testId: "markdown-explorer-edit-grant" }) });
273
- case "failed":
274
- return /* @__PURE__ */ x("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ x(de, { failure: r.failure, alert: !1, onRetry: p, testId: "markdown-explorer-edit-failure" }) });
275
- case "editing":
276
- return /* @__PURE__ */ x(rt, { ...e });
277
- }
278
- }, rt = ({ path: e, name: t, session: n, layout: s, viewer: d, region: c, paneScroll: a }) => {
279
- const { edits: r, labels: p } = K(), o = A(null), i = A(null), m = A(null), l = me() && s === "fill", [f, u] = U(null), h = A({ layout: s, region: c, paneScroll: a });
280
- C(() => {
281
- h.current = { layout: s, region: c, paneScroll: a };
282
- });
283
- const y = A(n.generation);
284
- C(() => {
285
- y.current = n.generation;
286
- });
287
- const S = A(l);
288
- C(() => {
289
- S.current = l;
290
- });
291
- const L = $(() => ({ editor: p.editorLabel(t), useOurs: p.conflictUseOurs, useTheirs: p.conflictUseTheirs, keepBoth: p.conflictKeepBoth }), [p, t]);
292
- C(() => {
293
- const b = o.current, E = r.draft(e);
294
- if (b === null || E === null) return;
295
- const q = r.editorState.get(e), O = tt(q) && q.generation === y.current ? q : null;
296
- let T = null, M = null;
297
- const B = () => {
298
- if (T !== null && clearTimeout(T), T = null, M === null) return;
299
- const v = M.text();
300
- r.setDraft(e, v), S.current && u(v);
301
- }, k = We({
302
- parent: b,
303
- scroll: {
304
- scrollerOf: (v) => {
305
- const { layout: ne, region: oe, paneScroll: re } = h.current, W = oe();
306
- return ne === "fill" || W === null ? v : re.scrollerOf(W, v);
307
- },
308
- reveal: (v) => h.current.paneScroll.reveal(v)
309
- },
310
- text: E,
311
- saved: O === null ? void 0 : O.state,
312
- labels: L,
313
- onChange: () => {
314
- T ??= setTimeout(B, Ze);
315
- },
316
- onSave: () => {
317
- r.save(e);
318
- }
319
- });
320
- M = k, i.current = k;
321
- const te = r.bindEditor(e, {
322
- flush: B,
323
- adopt: (v) => k.replaceText(v),
324
- returnPoint: () => {
325
- const v = k.topLine();
326
- return { line: v.line, clientTop: v.clientTop };
327
- },
328
- nextConflict: () => k.nextConflict()
329
- });
330
- return O !== null && k.showLine(O.topLine), () => {
331
- B(), r.editorState.set(e, { state: k.save(), generation: y.current, topLine: k.topLine().line }), te(), k.destroy(), M = null, i.current = null;
332
- };
333
- }, [r, e, L]);
334
- const { request: R } = n;
335
- C(() => {
336
- const b = i.current, E = r.draft(e);
337
- b === null || E === null || R === null || (R.anchor !== null && b.reveal(pe(E, R.anchor), R.anchor.clientTop), b.focus(), r.consumeRequest(e));
338
- }, [r, e, R, L]), N(() => {
339
- l && (r.flush(e), u(r.draft(e)));
340
- }, [r, e, l]);
341
- const F = J(() => {
342
- const b = i.current;
343
- if (b === null) return null;
344
- const E = b.topLine();
345
- return { line: E.line, offset: E.offset };
346
- }, []);
347
- return N(() => {
348
- const b = i.current;
349
- if (!l || b === null) return;
350
- const E = b.scrollElement;
351
- let q = 0;
352
- const O = () => {
353
- q = 0;
354
- const M = F();
355
- M !== null && m.current?.follow(M);
356
- }, T = () => {
357
- q === 0 && (q = requestAnimationFrame(O));
358
- };
359
- return E.addEventListener("scroll", T, { passive: !0 }), () => {
360
- E.removeEventListener("scroll", T), cancelAnimationFrame(q);
361
- };
362
- }, [l, F, L]),
363
- /* @__PURE__ */ P("div", { className: "aqmx-edit", "data-aqmx-edit-layout": s, "data-testid": "markdown-explorer-edit", onKeyDown: nt, onDoubleClick: ot, children: [
364
- /* @__PURE__ */ x("div", { ref: o, className: "aqmx-edit-editor", "data-testid": "markdown-explorer-editor", ...he }),
365
- l && f !== null ? /* @__PURE__ */ x(Qe, { path: e, text: f, viewer: d, editorPoint: F, handleRef: m }) : null
366
- ] });
367
- };
368
- export {
369
- Ze as DRAFT_WRITE_INTERVAL_MS,
370
- gt as default
371
- };
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),p=require("react"),g=require("./index-sNJrKoGN.cjs"),N=require("@codemirror/commands"),F=require("@codemirror/lang-markdown"),K=require("@codemirror/language"),B=require("@codemirror/search"),A=require("@codemirror/state"),b=require("@codemirror/view"),v=require("@lezer/highlight"),Z=require("@aiquants/markdown"),z={history:N.historyField},ee=K.HighlightStyle.define([{tag:[v.tags.heading1,v.tags.heading2,v.tags.heading3,v.tags.heading4,v.tags.heading5,v.tags.heading6,v.tags.heading],color:"var(--aqmx-syntax-heading)",fontWeight:"700"},{tag:v.tags.strong,fontWeight:"700"},{tag:v.tags.emphasis,fontStyle:"italic"},{tag:v.tags.strikethrough,textDecoration:"line-through"},{tag:v.tags.link,color:"var(--aqmx-syntax-link)",textDecoration:"underline"},{tag:v.tags.url,color:"var(--aqmx-syntax-url)"},{tag:v.tags.monospace,color:"var(--aqmx-syntax-code)"},{tag:v.tags.quote,color:"var(--aqmx-syntax-quote)"},{tag:[v.tags.processingInstruction,v.tags.contentSeparator,v.tags.labelName,v.tags.meta],color:"var(--aqmx-syntax-mark)"}]),te=b.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)"}}),G="data-aqmx-conflict-actions",ne=b.Decoration.line({attributes:{"data-aqmx-conflict-line":"marker"}}),oe=b.Decoration.line({attributes:{"data-aqmx-conflict-line":"ours"}}),re=b.Decoration.line({attributes:{"data-aqmx-conflict-line":"theirs"}});class se extends b.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(G,String(this.index));for(const[s,d]of[["ours",this.labels.useOurs],["theirs",this.labels.useTheirs],["both",this.labels.keepBoth]]){const c=document.createElement("button");c.type="button",c.textContent=d,c.setAttribute("data-aqmx-conflict-choice",s),c.addEventListener("mousedown",l=>l.preventDefault()),c.addEventListener("click",()=>{const l=D(t.state.doc)[this.index];l!==void 0&&(U(t,l,s),t.focus())}),n.append(c)}return n}ignoreEvent(){return!0}}const D=e=>g.findConflictsInLines(e.iterLines()),H=(e,t)=>{const n=new A.RangeSetBuilder;return D(e).forEach((s,d)=>{const c=e.line(s.start);n.add(c.from,c.from,b.Decoration.widget({widget:new se(d,t),block:!0,side:-1}));for(let l=s.start;l<=s.end;l+=1){const r=e.line(l).from,h=l===s.start||l===s.separator||l===s.end?ne:l<s.separator?oe:re;n.add(r,r,h)}}),n.finish()},ie=e=>A.StateField.define({create:t=>H(t.doc,e),update:(t,n)=>n.docChanged?H(n.state.doc,e):t,provide:t=>b.EditorView.decorations.from(t)}),U=(e,t,n)=>{const{doc:s}=e.state,d=(m,i)=>{const f=[];for(let u=m;u<=i;u+=1)f.push(s.line(u).text);return f},c=d(t.start+1,t.separator-1),l=d(t.separator+1,t.end-1),r=n==="ours"?c:n==="theirs"?l:[...c,...l];let h=s.line(t.start).from,o=s.line(t.end).to;r.length===0&&(t.end<s.lines?o+=1:t.start>1&&(h-=1));const a=r.join(`
2
- `);e.dispatch({changes:{from:h,to:o,insert:a},selection:A.EditorSelection.cursor(h),scrollIntoView:!0,userEvent:"input.resolve"})},ae=({parent:e,scroll:t,text:n,saved:s,labels:d,onChange:c,onSave:l})=>{const r=[b.EditorView.scrollHandler.of((a,m,i)=>(le(a,m.head,i,t),!0)),b.lineNumbers(),b.highlightActiveLineGutter(),N.history(),b.drawSelection(),b.highlightActiveLine(),B.highlightSelectionMatches(),b.EditorView.lineWrapping,F.markdown({base:F.markdownLanguage}),K.syntaxHighlighting(ee),ie(d),b.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(l(),!0)},...B.searchKeymap,...N.historyKeymap,...N.defaultKeymap]),b.EditorView.contentAttributes.of({"aria-label":d.editor,"aria-multiline":"true"}),b.EditorView.updateListener.of(a=>{a.docChanged&&c()}),te],h=de(s,r)??A.EditorState.create({doc:n,extensions:r}),o=new b.EditorView({state:h,parent:e});return{text:()=>o.state.doc.toString(),replaceText:a=>{const m=o.state.doc.toString();if(m===a)return;let i=0;const f=Math.min(m.length,a.length);for(;i<f&&m.charCodeAt(i)===a.charCodeAt(i);)i+=1;let u=0;for(;u<f-i&&m.charCodeAt(m.length-1-u)===a.charCodeAt(a.length-1-u);)u+=1;o.dispatch({changes:{from:i,to:m.length-u,insert:a.slice(i,a.length-u)},userEvent:"input.replace"})},reveal:({line:a,column:m},i)=>{const{doc:f}=o.state,u=f.line(Math.min(Math.max(a,1),f.lines)),E=Math.min(u.from+m,u.to);o.dispatch({selection:A.EditorSelection.cursor(E),effects:P(o,E,i,t)})},showLine:a=>{const{doc:m}=o.state,i=m.line(Math.min(Math.max(a,1),m.lines)).from;o.dispatch({effects:P(o,i,null,t)})},topLine:()=>{const a=t.scrollerOf(o.scrollDOM),m=g.visibleTopOf(a,o.contentDOM),i=g.frameTopOf(a)+a.clientHeight,{documentTop:f}=o,{doc:u}=o.state;let E=o.lineBlockAtHeight(Math.max(m-f,0));for(;u.lineAt(E.from).text.trim()===""&&E.to<u.length;){const M=o.lineBlockAt(E.to+1);if(f+M.top>=i)break;E=M}const k=o.coordsAtPos(E.from),L=k===null?f+E.top:k.top;return{line:o.state.doc.lineAt(E.from).number,clientTop:L,offset:L-m}},scrollElement:o.scrollDOM,focus:()=>o.focus(),conflicts:()=>D(o.state.doc),resolveAtCursor:a=>{const m=D(o.state.doc),i=o.state.doc.lineAt(o.state.selection.main.head).number,f=m.find(u=>u.end>=i);return f===void 0?!1:(U(o,f,a),!0)},nextConflict:()=>{const a=D(o.state.doc);if(a[0]===void 0)return!1;const i=o.state.doc.lineAt(o.state.selection.main.head).number,f=a.findIndex(L=>L.start>i),u=f<0?0:f,E=o.state.doc.line(a[u].start).from;o.dispatch({selection:A.EditorSelection.cursor(E),effects:b.EditorView.scrollIntoView(E,{y:"center"})});const k=o.contentDOM.querySelector(`[${G}="${String(u)}"] button`);return k instanceof HTMLElement?k.focus({preventScroll:!0}):o.focus(),!0},save:()=>o.state.toJSON(z),destroy:()=>o.destroy()}},P=(e,t,n,s)=>{const d=s.scrollerOf(e.scrollDOM),c=(n===null?g.visibleTopOf(d,e.contentDOM):n)-g.frameTopOf(d);return b.EditorView.scrollIntoView(t,{y:"start",yMargin:c})},le=(e,t,n,s)=>{const d=ce(e,t),c=s.scrollerOf(e.scrollDOM),l=g.frameTopOf(c),r=g.visibleTopOf(c,e.contentDOM),h=l+c.clientHeight;let o=0;switch(n.y){case"start":o=d.top-(l+n.yMargin);break;case"center":o=(d.top+d.bottom)/2-(r+h)/2;break;case"end":o=d.bottom-(h-n.yMargin);break;default:d.top<r+n.yMargin?o=d.top-(r+n.yMargin):d.bottom>h-n.yMargin&&(o=Math.min(d.bottom-(h-n.yMargin),d.top-(r+n.yMargin)))}if(o!==0&&(c.scrollTop+=o),n.y==="start")return;const a=ue(e,t);a!==null&&s.reveal(a)},ce=(e,t)=>{const{node:n,offset:s}=e.domAtPos(t);if(n.nodeType===Node.TEXT_NODE){const l=n.ownerDocument?.createRange();if(l!==void 0){l.setStart(n,s),l.setEnd(n,s);const[r]=l.getClientRects();if(r!==void 0&&r.height>0)return{top:r.top,bottom:r.bottom}}}const d=e.lineBlockAt(t),c=e.documentTop+d.top;return{top:c,bottom:c+d.height}},ue=(e,t)=>{const{node:n}=e.domAtPos(t);for(let s=n instanceof Element?n:n.parentElement;s!==null;s=s.parentElement)if(s.parentElement===e.contentDOM)return s;return null},de=(e,t)=>{if(e==null)return null;try{return A.EditorState.fromJSON(e,{extensions:t},z)}catch{return null}},fe=610,me="[data-aqmd-scroll-container]",he=Object.freeze(["p1","p2","p3","p4","p5","p6","p7","p8"]),pe=Object.freeze({parsed:null,failure:null,busy:!0}),W=(e,t)=>{const n=e.querySelector(me),s=g.blockAtLine(e,t.line);n===null||s===null||(n.scrollTop+=g.lineTopIn(s,t.line)-(g.visibleTopOf(n,s)+t.offset))},ge=({path:e,text:t,viewer:n,editorPoint:s,handleRef:d})=>{const{data:c,labels:l}=g.useExplorer(),[r,h]=p.useState(pe),o=p.useRef(null);p.useEffect(()=>{const i=new AbortController;h(u=>u.busy?u:{...u,busy:!0});const f=setTimeout(()=>{c.preview(e,t,i.signal).then(u=>{i.signal.aborted||!("kind"in u)||(u.kind==="failure"?h(E=>({parsed:E.parsed,failure:u.failure,busy:!1})):h({parsed:{htmlContent:u.htmlContent,headings:[...u.headings]},failure:null,busy:!1}))})},fe);return()=>{clearTimeout(f),i.abort()}},[c,e,t]);const a=p.useEffectEvent(()=>{const i=o.current,f=s();i!==null&&f!==null&&W(i,f)});p.useLayoutEffect(()=>{r.parsed!==null&&a()},[r.parsed]),p.useImperativeHandle(d,()=>({follow:i=>{const f=o.current;f!==null&&W(f,i)}}),[]);const m=p.useMemo(()=>({...n,showToc:!1,showStyle:!1,showAlign:!1,renderScrollBar:void 0}),[n]);return x.jsxs("section",{ref:o,className:"aqmx-edit-preview","aria-label":l.previewRegion,"aria-busy":r.busy,"data-testid":"markdown-explorer-edit-preview",children:[r.failure===null?null:x.jsx("p",{className:"aqmx-callout aqmx-document-notice","data-aqmx-tone":"warning","data-testid":"markdown-explorer-edit-preview-failure",children:l.previewFailed(g.failureTitleOf(l,r.failure.reason))}),r.parsed!==null?x.jsx("div",{className:"aqmx-document-viewer",children:x.jsx(Z.MarkdownViewer,{...m,parseResult:r.parsed,content:null})}):r.failure===null?x.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-preview-skeleton",children:he.map(i=>x.jsx("span",{},i))}):null,r.busy?x.jsx("p",{className:"aqmx-sr-only",children:l.previewUpdating}):null]})},$=144,xe=Object.freeze(["e1","e2","e3","e4","e5","e6","e7","e8"]),Ee=e=>{if(typeof e!="object"||e===null)return!1;const{generation:t,topLine:n}=e;return"state"in e&&typeof t=="number"&&typeof n=="number"},be=e=>{e.key==="Escape"&&g.consumeKey(e)},ve=e=>{e.stopPropagation()},ye=e=>{const{path:t,name:n,session:s}=e,{edits:d,labels:c,announcer:l}=g.useExplorer(),{phase:r}=s,h=p.useCallback(()=>d.retry(t),[d,t]);switch(p.useEffect(()=>{r.kind==="failed"&&l.announce(c.documentFailed(n,g.failureTitleOf(c,r.failure.reason)))},[r,l,c,n]),r.kind){case"opening":return x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-skeleton",children:xe.map(o=>x.jsx("span",{},o))}),x.jsx("p",{className:"aqmx-sr-only",children:c.editLoading})]});case"grant":return x.jsx("div",{className:"aqmx-edit-message",children:x.jsx(g.EditGrantNotice,{href:r.href,onRetry:h,testId:"markdown-explorer-edit-grant"})});case"failed":return x.jsx("div",{className:"aqmx-edit-message",children:x.jsx(g.FailureView,{failure:r.failure,alert:!1,onRetry:h,testId:"markdown-explorer-edit-failure"})});case"editing":return x.jsx(we,{...e})}},we=({path:e,name:t,session:n,layout:s,viewer:d,region:c,paneScroll:l})=>{const{edits:r,labels:h}=g.useExplorer(),o=p.useRef(null),a=p.useRef(null),m=p.useRef(null),i=g.usePreviewShown()&&s==="fill",[f,u]=p.useState(null),E=p.useRef({layout:s,region:c,paneScroll:l});p.useLayoutEffect(()=>{E.current={layout:s,region:c,paneScroll:l}});const k=p.useRef(n.generation);p.useLayoutEffect(()=>{k.current=n.generation});const L=p.useRef(i);p.useLayoutEffect(()=>{L.current=i});const M=p.useMemo(()=>({editor:h.editorLabel(t),useOurs:h.conflictUseOurs,useTheirs:h.conflictUseTheirs,keepBoth:h.conflictKeepBoth}),[h,t]);p.useLayoutEffect(()=>{const y=o.current,q=r.draft(e);if(y===null||q===null)return;const S=r.editorState.get(e),C=Ee(S)&&S.generation===k.current?S:null;let O=null,R=null;const _=()=>{if(O!==null&&clearTimeout(O),O=null,R===null)return;const w=R.text();r.setDraft(e,w),L.current&&u(w)},T=ae({parent:y,scroll:{scrollerOf:w=>{const{layout:Y,region:X,paneScroll:Q}=E.current,V=X();return Y==="fill"||V===null?w:Q.scrollerOf(V,w)},reveal:w=>E.current.paneScroll.reveal(w)},text:q,saved:C===null?void 0:C.state,labels:M,onChange:()=>{O??=setTimeout(_,$)},onSave:()=>{r.save(e)}});R=T,a.current=T;const J=r.bindEditor(e,{flush:_,adopt:w=>T.replaceText(w),returnPoint:()=>{const w=T.topLine();return{line:w.line,clientTop:w.clientTop}},nextConflict:()=>T.nextConflict()});return C!==null&&T.showLine(C.topLine),()=>{_(),r.editorState.set(e,{state:T.save(),generation:k.current,topLine:T.topLine().line}),J(),T.destroy(),R=null,a.current=null}},[r,e,M]);const{request:I}=n;p.useLayoutEffect(()=>{const y=a.current,q=r.draft(e);y===null||q===null||I===null||(I.anchor!==null&&y.reveal(g.positionInSource(q,I.anchor),I.anchor.clientTop),y.focus(),r.consumeRequest(e))},[r,e,I,M]),p.useEffect(()=>{i&&(r.flush(e),u(r.draft(e)))},[r,e,i]);const j=p.useCallback(()=>{const y=a.current;if(y===null)return null;const q=y.topLine();return{line:q.line,offset:q.offset}},[]);return p.useEffect(()=>{const y=a.current;if(!i||y===null)return;const q=y.scrollElement;let S=0;const C=()=>{S=0;const R=j();R!==null&&m.current?.follow(R)},O=()=>{S===0&&(S=requestAnimationFrame(C))};return q.addEventListener("scroll",O,{passive:!0}),()=>{q.removeEventListener("scroll",O),cancelAnimationFrame(S)}},[i,j,M]),x.jsxs("div",{className:"aqmx-edit","data-aqmx-edit-layout":s,"data-testid":"markdown-explorer-edit",onKeyDown:be,onDoubleClick:ve,children:[x.jsx("div",{ref:o,className:"aqmx-edit-editor","data-testid":"markdown-explorer-editor",...g.ALLOW_KEY_REPEAT}),i&&f!==null?x.jsx(ge,{path:e,text:f,viewer:d,editorPoint:j,handleRef:m}):null]})};exports.DRAFT_WRITE_INTERVAL_MS=$;exports.default=ye;
@@ -1 +0,0 @@
1
- "use strict";const c=require("react/jsx-runtime"),R=require("./index-sNJrKoGN.cjs"),r=require("react"),O=require("./location-CRYkEWiC.cjs"),_e=require("@aiquants/directory-tree"),dt=require("./tapScrollCircle-C5DGI-0H.cjs"),ft=require("./storage-Dgi4JXaB.cjs"),pe=require("@aiquants/resize-panels"),mt=require("react-router");function pt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const h=pt(r);function ht({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 xt=h.forwardRef(ht);function wt({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 gt=h.forwardRef(wt);function Et({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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"}),h.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 bt=h.forwardRef(Et);function vt({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 Rt=h.forwardRef(vt),yt=()=>{const{notices:e}=R.useExplorer(),t=r.use(e);return t.length===0?null:c.jsx("div",{className:"aqmx-explorer-notices",children:t.map(n=>c.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":n.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":n.id,children:[c.jsx("p",{className:"aqmx-callout-title",children:n.title}),n.body===void 0?null:c.jsx("p",{className:"aqmx-callout-body",children:n.body}),n.action===void 0?null:c.jsx("a",{className:"aqmx-callout-action",href:n.action.href,children:n.action.label})]},n.id))})};function St({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 kt=h.forwardRef(St),ve=r.createContext(!0),Ie="\0loop\0",De="\0",Ct=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=o=>{const l=e.get(o);if(l!==void 0)return l;const i=Object.freeze({type:"loop",name:o.name,path:o.path});return e.set(o,i),i},s=(o,l,i)=>{let f=!1;const m=o.map(p=>{const x=d(p,l,i);return x!==p&&(f=!0),x});if(!f)return o;const u=n.get(o);return u!==void 0&&u.length===m.length&&u.every((p,x)=>p===m[x])?u:(n.set(o,m),m)},d=(o,l,i)=>{if(o.type!=="directory")return o;if(i.has(o.path))return a(o);const f=o.lazy===!0?l(o.path):void 0,m=f?.status==="loaded",u=m?f.entries:o.children;if(u===void 0)return o;i.add(o.path);const p=s(u,l,i);if(i.delete(o.path),!m&&p===o.children)return o;const x=t.get(o);if(x!==void 0&&x.state===f&&x.children===p)return x.grafted;const g={...o,children:p,lazy:m?!1:o.lazy};return t.set(o,{state:f,children:p,grafted:g}),g};return(o,l)=>s(o,l,new Set)},Tt=(e,t)=>`${Ie}${e}${De}${t}`,ie=e=>e.startsWith(Ie),Lt=e=>e.slice(e.lastIndexOf(De)+1),ne="data-aqmx-path",jt=(e,t,n,a,s)=>{const d={aqmxPath:e.path};return n&&(d.aqmxOpen=!0),(a==="loading"||a==="failed")&&(d.aqmxChildren=a),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:s,data:d}},Nt=(e,t,n,a)=>{const s=Tt(t,e.path);return{name:n,type:"directory",absolutePath:s,relativePath:s,children:a,data:{aqmxLoop:e.path}}},Pt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=[],s=(l,i,f)=>{const m=l.map(p=>p.type==="loop"?d(p,i,f):o(p,i)),u=n.get(l);return u!==void 0&&u.length===m.length&&u.every((p,x)=>p===m[x])?u:(n.set(l,m),m)},d=(l,i,f)=>{const m=t.get(l);if(m!==void 0&&m.parentKey===f&&m.loopFolderName===i.loopFolderName)return m.row;const u=Nt(l,f,i.loopFolderName(l.name),a);return t.set(l,{row:u,parentKey:f,loopFolderName:i.loopFolderName}),u},o=(l,i)=>{const f=l.type==="directory"?l.children===void 0?a:s(l.children,i,l.path):void 0,m=i.openPaths.has(l.path),u=l.type==="directory"&&l.lazy===!0?i.childrenOf(l.path)?.status:void 0,p=u==="failed"?i.renderFailedFolder:void 0,x=e.get(l);if(x!==void 0&&x.open===m&&x.childrenStatus===u&&x.children===f&&x.renderFailedFolder===p)return x.row;const g=jt(l,f,m,u,p===void 0?void 0:p(l));return e.set(l,{row:g,open:m,childrenStatus:u,children:f,renderFailedFolder:p}),g};return(l,i)=>s(l,i,"")},Ot=e=>{if(e===void 0)return;const t=n=>({name:n.name,path:n.absolutePath,type:n.type});return(n,a)=>e(t(n),t(a))},be=(e,t)=>{const n=e.filter(a=>a.type==="directory");return t===void 0?n:n.sort(t)},qt=(e,t)=>{const n=new Map;let a=0;const s=d=>{for(const o of be(d,t.compare))if(t.isShownExpanded(o.path)){if(o.lazy!==!0){o.children!==void 0&&s(o.children);continue}n.has(o.path)||(n.set(o.path,t.isDirect(o.path)?"direct":"bulk"),t.childrenOf(o.path)?.status!=="failed"&&(a+=1))}};return s(e),{folders:n,waiting:a}},Mt=e=>{const t=new Set,n=a=>{for(const s of a)s.type==="directory"&&(s.lazy===!0&&t.add(s.path),s.children!==void 0&&n(s.children))};return n(e),t},He=(e,t)=>{for(const n of e){if(n.type!=="directory")continue;if(n.path===t)return n;const a=n.children===void 0?null:He(n.children,t);if(a!==null)return a}return null},At=(e,t,n,a)=>{let s=e;for(const d of t){const o=s.find(l=>l.type==="directory"&&l.path===d);if(o===void 0)return"missing";if(o.lazy===!0)return a.childrenOf(o.path)?.status==="failed"?"failed":"loading";if(!a.isShownExpanded(o.path))return"loading";s=o.children??[]}return s.some(d=>d.type==="file"&&d.path===n)?"ready":"missing"},Pe=new Set,Ft=(e,t)=>e.has(t)?e:new Set(e).add(t),_t=(e,t)=>{if(!t.some(a=>e.has(a)))return e;const n=new Set(t);return new Set([...e].filter(a=>!n.has(a)))},It=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),Dt=()=>{const[e,t]=r.useState(Pe),n=r.useCallback(o=>t(l=>Ft(l,o)),[]),a=r.useCallback(o=>t(l=>_t(l,o)),[]),s=r.useCallback(o=>t(l=>It(l,o)),[]),d=r.useCallback(()=>t(Pe),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:a,pruneDirect:s,clearDirect:d}),[e,n,a,s,d])},Ht=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),Zt=(e,t)=>{const n=[];let a=be(t.entries,t.compare);for(let s=1;a.length>0;s+=1){const d=[];for(const o of a){const{path:l}=o;if(t.isShownExpanded(l))e.handled.add(l);else{if(e.handled.has(l))continue;if(e.handled.add(l),o.lazy===!0&&t.childrenOf(l)===void 0){if(s>e.budget.maxDepth){e.depthLimited=!0;continue}if(e.loads.size>=e.budget.maxFolders){e.folderLimited=!0;continue}e.loads.add(l)}n.push(l),e.opened+=1}o.lazy!==!0&&o.children!==void 0&&d.push(...be(o.children,t.compare))}a=d}return n},Ze=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||Ze(n.children,t))),$t=(e,t)=>{if(e.folderLimited)return{kind:"folder-limit",opened:e.opened};if(e.depthLimited)return{kind:"depth-limit",opened:e.opened};let n=0;for(const a of e.loads)t.childrenOf(a)?.status==="failed"&&(n+=1);return{kind:"done",opened:e.opened,failed:n,complete:Ze(t.entries,t.isShownExpanded)}},Ee=Object.freeze({state:"idle"}),Bt=e=>{const t=r.useRef(null),n=r.useRef(e),[a,s]=r.useState(Ee);r.useLayoutEffect(()=>{n.current=e});const d=r.useCallback(()=>{t.current===null&&(t.current=Ht(n.current.budget),s({state:"running",opened:0}))},[]),o=r.useCallback(()=>{t.current=null,s(Ee)},[]),l=r.useCallback(i=>{const f=t.current;if(f===null)return;const m=Zt(f,i);if(m.length>0&&(f.issuedAgainst=i.expanded,n.current.expandMultiple([...m])),!f.announcedStart&&(f.loads.size>0||i.waiting>0)&&(f.announcedStart=!0,n.current.onStart()),m.length===0&&!i.expansionPending&&i.expanded!==f.issuedAgainst&&i.waiting===0){t.current=null;const p=$t(f,i);s(p.kind==="done"?Ee:{state:"stopped",stop:p.kind,opened:p.opened}),n.current.onFinish(p);return}const{opened:u}=f;s(p=>p.state==="running"&&p.opened===u?p:{state:"running",opened:u})},[]);return r.useMemo(()=>({status:a,start:d,end:o,advance:l}),[a,d,o,l])},Oe=["pointerdown","wheel","touchstart","keydown","focusin"],zt=8,qe={least:Number.POSITIVE_INFINITY,stalled:0},Vt=({tree:e,container:t,path:n,chain:a,rows:s,cancel:d,displayed:o,placement:l})=>{const i=r.useRef(null),f=r.useRef(!0),m=r.useRef(qe),u=r.useRef(null),p=r.useRef(null),x=r.useRef(a),g=r.useRef(l);r.useLayoutEffect(()=>{x.current=a,g.current=l},[a,l]);const b=r.useCallback(()=>{const L=u.current;L!==null&&(u.current=null,L.phase==="asking"?L.controller.abort():x.current?.open(null))},[]),S=r.useCallback(()=>{i.current=null,b()},[b]),P=r.useCallback(()=>{const L=t.current;i.current===null||p.current!==null||L===null||L.getClientRects().length===0||(p.current=requestAnimationFrame(()=>{p.current=null;const E=i.current;if(E===null)return;const y=g.current(E);if(y===0){f.current=!0,u.current?.phase==="opening"&&b();return}if(e.current?.scrollToPath(E,{align:"nearest"})===!0){u.current?.phase==="opening"&&b();const{least:j,stalled:M}=m.current;m.current=y<j?{least:y,stalled:0}:{least:j,stalled:M+1},m.current.stalled<zt&&P();return}const v=u.current;if(v===null){i.current=null;return}v.phase==="opening"&&x.current?.progress(v.folders,E)!=="loading"&&S()}))},[e,t,b,S]),k=r.useCallback(()=>{f.current=!1,m.current=qe,P()},[P]);r.useEffect(()=>{const L=t.current;if(L===null)return;const E=typeof ResizeObserver>"u"?null:new ResizeObserver(k);E?.observe(L);for(const y of Oe)L.addEventListener(y,S,{passive:!0});return()=>{E?.disconnect();for(const y of Oe)L.removeEventListener(y,S);p.current!==null&&cancelAnimationFrame(p.current),p.current=null,b()}},[t,k,S,b]);const T=a!==null;r.useEffect(()=>{const L=t.current;if(S(),n===null||L===null||L.contains(L.ownerDocument.activeElement))return;i.current=n;const E=x.current;if(T&&E!==null){const y=new AbortController,v={phase:"asking",controller:y};u.current=v,E.ancestors(n,y.signal).then(j=>{u.current===v&&(j===null?u.current=null:(u.current={phase:"opening",folders:j},x.current?.open(j)),k())})}k()},[n,T,t,S,k]),r.useEffect(()=>{(u.current?.phase==="opening"||i.current!==null&&!f.current)&&k()},[s,k]);const F=r.useRef(d);r.useEffect(()=>{F.current!==d&&(F.current=d,S())},[d,S]);const q=r.useRef(o);r.useEffect(()=>{q.current&&!o&&b(),q.current=o},[o,b])},Kt="--aqmx-tree-line",Xt=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),Wt="data-aqmx-tree-probe",Ut=Object.freeze({rowHeight:O.CONTROL_BLOCK_PIXELS,lineColor:null}),Gt=/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/u,Yt=e=>{const t=Gt.exec(e);return t===null?e:`#${t.slice(1).map(n=>Number(n).toString(16).padStart(2,"0")).join("")}`},Qt=(e,t)=>{const[n,a]=r.useState(Ut);return r.useLayoutEffect(()=>{const s=e.current;if(s===null)return;const d=()=>{const i=Math.round(s.getBoundingClientRect().height),f=getComputedStyle(s),m=f.getPropertyValue(Kt).trim()===""?null:Yt(f.color);a(u=>{const p=Number.isFinite(i)&&i>0?i:u.rowHeight;return u.rowHeight===p&&u.lineColor===m?u:{rowHeight:p,lineColor:m}})};d();const o=Xt.map(i=>window.matchMedia(i));for(const i of o)i.addEventListener("change",d);const l=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return l?.observe(s),()=>{for(const i of o)i.removeEventListener("change",d);l?.disconnect()}},[e,t]),n},$e="markdown-explorer-tree-scroll",Jt=.5,Be=(e,t)=>[...e.querySelectorAll(`[role="treeitem"][${ne}]`)].find(n=>n.getAttribute(ne)===t),en=(e,t)=>{const n=Be(e,t),a=n?.closest(`[data-testid="${$e}"]`);if(n===void 0||a===null||a===void 0)return Number.POSITIVE_INFINITY;const s=a.getBoundingClientRect(),d=n.getBoundingClientRect(),o=s.top-d.top,l=d.height>s.height?Math.abs(o):Math.max(0,o)+Math.max(0,d.bottom-s.bottom);return l<=Jt?0:l},tn={testId:$e,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:{width:8,enableTrackClick:!0,enableThumbDrag:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:dt.TAP_SCROLL_CIRCLE},behaviorOptions:{enablePointerDrag:!0}},nn={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},rn={color:"inherit"},an={paddingBlock:0},ln=new Set,on=new Map,sn={color:"var(--aqmx-tree-line)"},cn=e=>{const t=e instanceof Element?e.closest(`[${ne}]`):null;return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(ne)},ze=(e,t,n,a)=>n==="folder-limit"?e.expandAllFolderLimit(a,t.maxFolders,e.expandAll):e.expandAllDepthLimit(a,t.maxDepth),un=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):ze(e,t,n.kind,n.opened),Ve=()=>{const{labels:e}=R.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",{})]})]})},dn=()=>{const{labels:e}=R.useExplorer();return c.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[c.jsx(kt,{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})]})},fn=({name:e,onRetry:t})=>{const{labels:n}=R.useExplorer(),a=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:a,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),c.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":a,"data-testid":"markdown-explorer-folder-retry",onClick:s=>{s.stopPropagation();const d=s.currentTarget,o=d.ownerDocument.activeElement===d?d.closest('[role="treeitem"]'):null;o instanceof HTMLElement&&R.focusWithoutScroll(o),t()},onKeyDown:s=>{s.key!=="Escape"&&s.stopPropagation()},children:[c.jsx(R.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},mn=({entries:e,version:t,mode:n,sourceId:a,settings:s,reveal:d,openPaths:o,selection:l,onOpenDocument:i,onRevealSource:f,expansion:m,onShown:u,marks:p,claimsHeld:x,expandAll:g,revealCancel:b})=>{const{trees:S,documents:P,labels:k,locale:T,theme:F,data:q,config:L,sources:E,reveals:y}=R.useExplorer(),v=r.use(ve),[j]=r.useState(Pt),M=r.useRef(null),{rowHeight:le,lineColor:z}=Qt(M,F),{isExpanded:_,toggle:U,expandMultiple:Z,collapseMultiple:J,expanded:D,isPending:ee}=m,{alwaysExpanded:V,sortMode:A,folderPlacement:$}=s,{direct:oe,markDirect:B,unmarkDirect:re,pruneDirect:se}=p,{running:te,advance:ue}=g,ce=r.useRef(null),G=r.useRef(null),C=r.useMemo(()=>O.createEntryComparator({sortMode:A,folderPlacement:$}),[A,$]),K=r.useMemo(()=>Ot(C),[C]),I=r.useCallback(w=>S.children(a,w),[S,a]),Y=r.useMemo(()=>Mt(e),[e]),Q=r.useCallback(w=>!ie(w)&&(_(w)||V&&!Y.has(w)),[_,V,Y]),X=r.useRef({shownExpanded:Q,isExpanded:_,unloadedFolders:Y,entries:e,childrenOf:I});r.useLayoutEffect(()=>{X.current={shownExpanded:Q,isExpanded:_,unloadedFolders:Y,entries:e,childrenOf:I}},[Q,_,Y,e,I]);const Se=r.useCallback(w=>{ce.current?.scrollToPath(w,{align:"nearest"}),requestAnimationFrame(()=>{const N=G.current,H=N===null?void 0:Be(N,w);H!==void 0&&R.focusWithoutScroll(H)})},[]),Je=r.useCallback(w=>{if(ie(w)){Se(Lt(w));return}X.current.isExpanded(w)?re([w]):X.current.unloadedFolders.has(w)&&B(w),U(w)},[Se,B,re,U]),xe=r.useCallback(w=>{const N=w.filter(H=>!ie(H));N.length!==0&&(re(N),J(N))},[re,J]),et=r.useCallback(w=>{const N=w.filter(H=>!ie(H));N.length!==0&&(N.length<w.length&&N.every(H=>X.current.shownExpanded(H))?xe(N):Z(N))},[Z,xe]),ke=r.useCallback(w=>c.jsx(fn,{name:w.name,onRetry:()=>{B(w.path),S.retryChildren(a,w.path),X.current.shownExpanded(w.path)||Z([w.path])}}),[S,a,B,Z]),Ce=n==="multi"?o:ln,{loopFolderName:Te}=k,tt=r.useMemo(()=>j(e,{openPaths:Ce,childrenOf:I,renderFailedFolder:ke,loopFolderName:Te}),[j,e,Ce,I,ke,Te,t]),nt=R.useIntentPrefetch(P,cn),Le=r.useRef([]),de=r.useCallback(()=>{for(const w of Le.current)X.current.unloadedFolders.has(w)&&B(w)},[B]),{maxDepth:we}=L.revealDocument,je=r.useRef(f);r.useLayoutEffect(()=>{je.current=f},[f]);const rt=r.useMemo(()=>({ancestors:async(w,N)=>{const H=y.take(a,w);if(H!==null)return H;if(!y.mayMove(w)){const ae=await q.ancestors(a,w,N);return ae.status!=="ok"||ae.ancestors===null||ae.ancestors.length>we?null:ae.ancestors}const W=await q.reveal(a,w,N);return W.status!=="ok"||W.source===null||W.ancestors.length>we?null:W.source===a?W.ancestors:(N.aborted||!E.some(ae=>ae.id===W.source)||(y.move(W.source,w,W.ancestors),je.current(W.source)),null)},open:w=>{Le.current=w??[],w!==null&&(de(),Z([...w]))},progress:(w,N)=>At(X.current.entries,w,N,{isShownExpanded:X.current.shownExpanded,childrenOf:X.current.childrenOf})}),[q,a,E,y,we,de,Z]);r.useEffect(()=>de(),[de,Y]);const at=r.useMemo(()=>[e,t,D],[e,t,D]),lt=r.useCallback(w=>G.current===null?Number.POSITIVE_INFINITY:en(G.current,w),[]);Vt({tree:ce,container:G,path:d.path,chain:d.openFolders?rt:null,rows:at,cancel:b,displayed:v,placement:lt});const Ne=r.useCallback(w=>oe.has(w),[oe]),fe=r.useMemo(()=>qt(e,{isShownExpanded:Q,childrenOf:I,compare:C,isDirect:Ne}),[e,Q,I,C,Ne,t]),me=v&&x;r.useLayoutEffect(()=>{u(e)},[e,u]),r.useLayoutEffect(()=>()=>u(null),[u]),r.useEffect(()=>S.claimChildren(a,me?fe.folders:on),[S,a,me,fe]),r.useEffect(()=>se(Y),[se,Y]),r.useEffect(()=>{me&&te&&ue({entries:e,isShownExpanded:Q,childrenOf:I,compare:C,expanded:D,waiting:fe.waiting,expansionPending:ee})},[me,te,ue,e,Q,I,C,D,fe,ee]);const ot=r.useCallback(w=>{w.isDirectory||(y.settle(w.entry.absolutePath),i(w.entry.absolutePath))},[y,i]),{onChange:ge}=l,st=r.useMemo(()=>ge===null?void 0:(w,N)=>{ie(w.absolutePath)||ge({path:w.absolutePath,name:w.name,selected:N})},[ge]),ct=r.useMemo(()=>new Set(l.items),[l.items]),it=r.useMemo(()=>({entryKindDirectory:k.treeEntryKindDirectory,entryKindFile:k.treeEntryKindFile,scrollUp:k.treeScrollUp,scrollDown:k.treeScrollDown,scrollToTop:k.treeScrollToTop,scrollToBottom:k.treeScrollToBottom}),[k]),ut=z===null?{showTreeLines:!1}:{showTreeLines:s.lines,lineColor:z};return c.jsxs("div",{ref:G,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",...nt,children:[c.jsx("span",{ref:M,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[Wt]:""}),c.jsx(_e.DirectoryTree,{ref:ce,entries:tt,expansion:{toggle:Je,isExpanded:Q,expandMultiple:et,collapseMultiple:xe,isPending:ee&&!te,doubleClickAction:s.doubleClickAction},selection:{mode:l.mode,selectedPath:l.shownPath,currentPath:l.shownPath,selectedItems:ct,onEntryClick:ot,onSelectionChange:st},visual:{className:"aqmx-explorer-tree-view",ariaLabel:k.treeRegion,...ut,showExpandIcons:s.expandIcons,expandIconStyle:sn,showDirectoryIcons:s.directoryIcons,showFileIcons:s.fileIcons,expandIconSize:s.expandIconSize,itemHeight:le,removeRootIndent:s.removeRootIndent,highlightStyles:nn,entryStyle:an,nameStyle:rn},virtualScroll:tn,sort:K,locale:T,labels:it})]})},pn=({pending:e,status:t})=>{const{labels:n}=R.useExplorer(),a=t.state!=="running",[s,d]=r.useState(0),o=r.useRef(!0);r.useLayoutEffect(()=>{const i=o.current;if(o.current=a,!a||e>0&&!i){d(0);return}if(e>0){d(e);return}if(s===0)return;const f=setTimeout(()=>d(0),0);return()=>clearTimeout(f)},[a,e,s]);const l=a&&e===0?s:e;return l===0&&a?null:c.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(l),"data-aqmx-expand-all":t.state,children:[l>0?c.jsx(R.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,c.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,l):n.foldersLoading(l)})]})},hn=({stop:e,opened:t,budget:n})=>{const{labels:a}=R.useExplorer();return c.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:ze(a,n,e,t)})},xn=({entries:e,...t})=>{const{trees:n}=R.useExplorer(),a=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:s}=t,[d]=r.useState(Ct),o=r.useMemo(()=>d(e,l=>n.children(s,l)),[d,e,n,s,a]);return o.length===0?c.jsx(dn,{}):c.jsx(mn,{entries:o,version:a,...t})},wn=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:a}=R.useExplorer(),s=r.use(e);if(s.status==="deferred")return c.jsx(Ve,{});if(s.status==="ok")return c.jsx(xn,{entries:s.entries,...n});const d=a?.(s.failure);return c.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":s.failure.reason,children:d!==void 0?d:c.jsx(R.FailureView,{failure:s.failure,alert:!0,onRetry:t,testId:null})})},gn=({onControls:e,...t})=>{const{trees:n,storageNamespace:a,labels:s,announcer:d,config:o}=R.useExplorer(),{sourceId:l}=t,i=_e.useDirectoryTreeState({storageKey:ft.storageKeys(a).treeExpansion(l)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const f=n.read(l),m=r.useCallback(()=>n.retry(l),[n,l]);r.useLayoutEffect(()=>n.open(l),[n,l]);const u=Dt(),{expanded:p,expandMultiple:x,collapseAll:g}=i,[b,S]=r.useState(null),P=b!==p,k=r.useRef(p);r.useLayoutEffect(()=>{k.current=p},[p]);const T=o.expandAll,F=r.useCallback(()=>d.announce(s.expandAllStarted),[d,s]),q=r.useCallback(A=>d.announce(un(s,T,A)),[d,s,T]),L=Bt({budget:T,expandMultiple:x,onStart:F,onFinish:q}),{status:E,start:y,end:v,advance:j}=L,M=E.state==="running",le=r.useMemo(()=>({running:M,advance:j}),[M,j]),z=r.useRef(null),[_,U]=r.useState(!1),Z=r.useCallback(A=>{z.current=A,U(A!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(A=>{const $=A.sourceId===l&&z.current!==null?He(z.current,A.path):null;$!==null&&d.announce({list:s.foldersLoadFailedNamed,item:$.name})}),[n,l,d,s]);const{clearDirect:J}=u,[D,ee]=r.useState(0),V=r.useCallback(()=>{ee(A=>A+1),v(),J(),S(k.current),g()},[v,J,g]);return r.useEffect(()=>{e({collapseAll:V,expandAll:_?y:null,expanding:M})},[e,V,y,_,M]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{_||v()},[_,v]),c.jsxs(c.Fragment,{children:[E.state==="stopped"?c.jsx(hn,{stop:E.stop,opened:E.opened,budget:T}):null,c.jsxs("div",{className:"aqmx-explorer-tree-area",children:[c.jsx(r.Suspense,{fallback:c.jsx(Ve,{}),children:c.jsx(wn,{result:f,onRetry:m,expansion:i,onShown:Z,marks:u,claimsHeld:P,expandAll:le,revealCancel:D,...t})}),c.jsx(pn,{pending:n.pendingChildren(l),status:E})]})]})};function En({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 Ke=h.forwardRef(En),Me="markdown-explorer-selection-remove",bn=({selection:e,onRemove:t,onClear:n,onOpenSelection:a,onLeave:s})=>{const{labels:d}=R.useExplorer(),o=r.useId(),l=r.useRef(null),i=[...e],f=(u,p)=>{if(p.ownerDocument.activeElement===p){const x=l.current===null?[]:[...l.current.querySelectorAll(`[data-testid="${Me}"]`)],g=x.indexOf(p),b=[x[g+1],x[g-1]].find(S=>S!==void 0);b===void 0?s():b.focus()}t(u)},m=()=>{const u=l.current;u!==null&&u.contains(u.ownerDocument.activeElement)&&s(),n()};return c.jsxs("section",{ref:l,className:"aqmx-explorer-tray","aria-labelledby":o,"data-testid":"markdown-explorer-selection-tray",children:[c.jsxs("div",{className:"aqmx-explorer-tray-header",children:[c.jsx("p",{id:o,className:"aqmx-explorer-tray-title",children:d.selectionTitle(i.length)}),c.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:m,children:d.clearSelection})]}),c.jsx("ul",{className:"aqmx-explorer-tray-list",children:i.map(([u,p])=>c.jsxs("li",{className:"aqmx-explorer-tray-item",children:[c.jsx("span",{className:"aqmx-explorer-tray-name",title:u,children:p}),c.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":d.removeFromSelection(p),title:d.removeFromSelection(p),"data-testid":Me,"data-aqmx-path":u,onClick:x=>f(u,x.currentTarget),children:c.jsx(Ke,{"aria-hidden":"true"})})]},u))}),a===void 0?null:c.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>a(i.map(([u])=>u)),children:d.openSelectionInMulti(i.length)})]})},he=new Map,vn=(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},Rn=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},Xe=r.createContext(null),yn=e=>{const t=r.use(Xe);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};function Sn({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.createElement("path",{fillRule:"evenodd",d:"M15 3.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0V5.56l-3.97 3.97a.75.75 0 1 1-1.06-1.06l3.97-3.97h-2.69a.75.75 0 0 1-.75-.75Zm-12 0A.75.75 0 0 1 3.75 3h4.5a.75.75 0 0 1 0 1.5H5.56l3.97 3.97a.75.75 0 0 1-1.06 1.06L4.5 5.56v2.69a.75.75 0 0 1-1.5 0v-4.5Zm11.47 11.78a.75.75 0 1 1 1.06-1.06l3.97 3.97v-2.69a.75.75 0 0 1 1.5 0v4.5a.75.75 0 0 1-.75.75h-4.5a.75.75 0 0 1 0-1.5h2.69l-3.97-3.97Zm-4.94-1.06a.75.75 0 0 1 0 1.06L5.56 19.5h2.69a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75v-4.5a.75.75 0 0 1 1.5 0v2.69l3.97-3.97a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const kn=h.forwardRef(Sn);function Cn({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 Tn=h.forwardRef(Cn);function Ln({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 jn=h.forwardRef(Ln);function Nn({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 Pn=h.forwardRef(Nn);function On({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 qn=h.forwardRef(On);function Mn({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 An=h.forwardRef(Mn);function Fn({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 _n=h.forwardRef(Fn);function In({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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"}),h.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 Dn=h.forwardRef(In);function Hn({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 Zn=h.forwardRef(Hn);function $n({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 Bn=h.forwardRef($n);function zn({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 Vn=h.forwardRef(zn);function Kn({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 Xn=h.forwardRef(Kn),Wn=Object.freeze({sortMode:Tn,folderPlacement:Zn,selectionMode:jn,doubleClickAction:_n,expandIconSize:Vn,alwaysExpanded:kn,revealDocument:R.ForwardRef$1,removeRootIndent:Pn,lines:Xn,expandIcons:qn,directoryIcons:Bn,fileIcons:Dn}),We=(e,t)=>{const n=e[t.labelKey];if(typeof n!="string")throw new TypeError(`[markdown-explorer] the tree setting ${t.key} must name a string label; labels.${t.labelKey} is a ${typeof n}`);return n},Un=({id:e,settings:t,descriptors:n,onAdvance:a,onClose:s,ref:d})=>{const{labels:o}=R.useExplorer(),l=r.useRef([]);r.useEffect(()=>{l.current[0]?.focus()},[]);const i=r.useCallback(m=>{const u=n.length;l.current[(m%u+u)%u]?.focus()},[n.length]),f=r.useCallback((m,u)=>{switch(m.key){case"ArrowDown":m.preventDefault(),i(u+1);break;case"ArrowUp":m.preventDefault(),i(u-1);break;case"Home":m.preventDefault(),i(0);break;case"End":m.preventDefault(),i(n.length-1);break;case"Escape":R.consumeKey(m),s();break;case"Tab":s();break}},[n.length,i,s]);return c.jsx("div",{ref:d,id:e,role:"menu","aria-label":o.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((m,u)=>{const p=Wn[m.key],x=We(o,m),g=O.formatTreeSettingValue(o,t,m.key),b=t[m.key],S=typeof b=="boolean"?{role:"menuitemcheckbox","aria-checked":b,"aria-label":x}:{role:"menuitem","aria-label":`${x}: ${g}`};return c.jsxs("button",{ref:P=>{l.current[u]=P},type:"button",tabIndex:-1,...S,title:`${x}: ${g}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":m.key,onClick:()=>a(m),onKeyDown:P=>f(P,u),children:[c.jsx(p,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-menu-name",children:x}),c.jsx("span",{className:"aqmx-explorer-menu-value",children:g})]},m.key)})})},Gn=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:a,announcer:s}=R.useExplorer(),[d,o]=r.useState(!1),l=r.useRef(null),i=r.useRef(null),f=r.useRef(null),m=r.useId(),u=r.useCallback(()=>{l.current?.focus(),o(!1)},[]);r.useEffect(()=>{if(!d)return;const g=b=>{b.target instanceof Node&&(l.current?.contains(b.target)===!0||i.current?.contains(b.target)===!0)||(o(!1),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{f.current=null,(document.activeElement===null||document.activeElement===document.body)&&l.current?.focus()},0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[d]),r.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);const p=r.useCallback(g=>{g.key!=="Escape"||!d||(R.consumeKey(g),u())},[d,u]),x=r.useCallback(g=>{const b=n(g.key);s.announce(a.settingAnnouncement(We(a,g),O.formatTreeSettingValue(a,b,g.key)))},[s,a,n]);return{trigger:c.jsx("button",{ref:l,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?m:void 0,"aria-label":a.treeSettings,title:a.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>o(g=>!g),onKeyDown:p,children:c.jsx(An,{"aria-hidden":"true"})}),menu:d?c.jsx(Un,{ref:i,id:m,settings:e,descriptors:t,onAdvance:x,onClose:u}):null}},Yn=()=>{const{treeSettings:e}=R.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},Ae=new Set,Qn='[role="tree"] [role="treeitem"][tabindex="0"]',Jn="[data-directory-tree-tab-stop]",er=e=>{const{mode:t,sourceId:n,currentPath:a,openPaths:s,onOpenDocument:d,onSourceChange:o,onRevealSource:l,viewSwitch:i}=e,{labels:f,sources:m,trees:u,documents:p,announcer:x,reveals:g}=R.useExplorer(),{settings:b,advance:S}=Yn(),P=r.useMemo(()=>O.visibleTreeSettingDescriptors(t==="tree"),[t]),k=t==="tree"&&b.selectionMode==="multiple";yn(k);const T=e.mode==="tree"?e.tray.onGatheredChange:null,F=e.mode==="tree"?e.onOpenSelection:void 0,q=e.mode==="tree"&&k?e.tray.gathered:he,L=r.useCallback(C=>{const K=S(C);return K.selectionMode!=="multiple"&&T?.(he),K},[S,T]),E=Gn({settings:b,descriptors:P,onAdvance:L}),y=r.useCallback(C=>T?.(K=>vn(K,C)),[T]),v=r.useCallback(C=>T?.(K=>Rn(K,C)),[T]),j=r.useCallback(()=>T?.(he),[T]),M=r.useRef(null),le=r.useCallback(()=>{const C=M.current;if(C===null)return;[Qn,Jn,'[data-testid="markdown-explorer-tree-settings"]'].map(I=>C.querySelector(I)).find(I=>I!==null)?.focus()},[]),z=r.useMemo(()=>new Set(q.keys()),[q]),_=r.useMemo(()=>a===null?Ae:new Set([a]),[a]),U=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:s,shownPath:null,onChange:null};switch(b.selectionMode){case"single":return{mode:"single",items:_,shownPath:a,onChange:null};case"multiple":return{mode:"multiple",items:z,shownPath:a,onChange:y};case"none":return{mode:"none",items:Ae,shownPath:null,onChange:null}}},[t,s,b.selectionMode,_,a,z,y]),Z=r.useMemo(()=>b.revealDocument?{path:a,openFolders:!0}:{path:U.shownPath,openFolders:!1},[b.revealDocument,a,U.shownPath]),J=r.useCallback(C=>{a!==null&&g.settle(a),o(C)},[a,g,o]),[D,ee]=r.useState(null),[V,A]=r.useState(!1),[$,oe]=r.useState(null),B=r.useRef(!1),re=r.useCallback(async()=>{if(!B.current){B.current=!0,A(!0),oe(null);try{const C=await u.refresh(n);if(C.status==="superseded")return;p.invalidate(),C.status==="failed"?oe({sourceId:n,failure:C.failure}):x.announce(f.treeRefreshed)}finally{B.current=!1,A(!1)}}},[u,p,n,x,f]),se=D===null?null:D.expandAll,te=D?.expanding===!0,ue=m.find(C=>C.id===n),ce=i.target==="multi"?Rt:bt,G=i.target==="multi"?f.switchToMulti:f.switchToTree;return c.jsxs("nav",{ref:M,"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:[m.length>1?c.jsx("select",{className:"aqmx-explorer-source","aria-label":f.sourceLabel,title:ue?.label,value:n,onChange:C=>J(C.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:m.map(C=>c.jsx("option",{value:C.id,children:C.label},C.id))}):null,c.jsxs("div",{className:"aqmx-explorer-actions",children:[c.jsx(R.ExplorerLink,{to:i.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":G,title:G,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":i.target,children:c.jsx(ce,{"aria-hidden":"true"})}),c.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:f.refreshTree,"aria-disabled":V,"aria-busy":V,"data-aqmx-busy":V?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{re()},children:[c.jsx(R.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":se===null||te,"aria-busy":te,"data-aqmx-busy":te?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>se?.(),children:c.jsx(gt,{"aria-hidden":"true"})}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.collapseAll,title:f.collapseAll,"aria-disabled":D===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>D?.collapseAll(),children:c.jsx(xt,{"aria-hidden":"true"})}),E.trigger]})]}),c.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[$!==null&&$.sourceId===n?c.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":$.failure.reason,children:f.treeRefreshFailed(R.failureTitleOf(f,$.failure.reason))}):null,c.jsx(r.Suspense,{fallback:null,children:c.jsx(yt,{})}),c.jsx(gn,{mode:t,sourceId:n,settings:b,reveal:Z,openPaths:s,selection:U,onOpenDocument:d,onRevealSource:l,onControls:ee},n),k&&q.size>0?c.jsx(bn,{selection:q,onRemove:v,onClear:j,onOpenSelection:F,onLeave:le}):null,E.menu]})]})},Ue="(pointer: coarse)",tr=e=>{const t=window.matchMedia(Ue);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},nr=()=>window.matchMedia(Ue).matches,rr=()=>!1,ar=()=>r.useSyncExternalStore(tr,nr,rr);function lr({title:e,titleId:t,...n},a){return h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?h.createElement("title",{id:t},e):null,h.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 or=h.forwardRef(lr),sr=({explorer:e,toggleRef:t,covered:n,onNoticeSlotChange:a,dismissals:s})=>{const{labels:d}=R.useExplorer(),o=mt.useLocation(),{location:l}=R.useExplorerLocation(),[i,f]=r.useState(!1),[m,u]=r.useState({navigated:o,source:l.source}),[p,x]=r.useState(!1);m.navigated!==o&&(u({navigated:o,source:l.source}),m.source===l.source&&!p&&f(!1));const[g,b]=r.useState(s);g!==s&&(b(s),f(!1));const S=r.useRef(null),P=r.useRef(null),k=r.useRef(null),T=r.useRef(!1),F=r.useId();r.useLayoutEffect(()=>{const v=S.current;v!==null&&(i&&!v.open?(v.showModal(),P.current?.focus()):!i&&v.open&&(v.close(),t.current?.focus()),a(i?k.current:null))},[i,t,a]),r.useLayoutEffect(()=>()=>a(null),[a]);const q=r.useCallback(v=>{v.key!=="Escape"||v.defaultPrevented||(R.consumeKey(v),f(!1))},[]),L=r.useCallback(v=>{T.current=v.target===v.currentTarget},[]),E=r.useCallback(v=>{const j=T.current;T.current=!1,j&&v.target===v.currentTarget&&f(!1)},[]),y=r.useCallback(()=>{f(!1)},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"aqmx-sheet-bar",inert:n,children:c.jsxs("button",{ref:t,type:"button",className:"aqmx-sheet-toggle","aria-haspopup":"dialog","aria-expanded":i,"aria-controls":F,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>f(!0),children:[c.jsx(or,{"aria-hidden":"true"}),c.jsx("span",{children:d.showExplorer})]})}),c.jsx("dialog",{ref:S,id:F,className:"aqmx-sheet","aria-label":d.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:q,onPointerDown:L,onClick:E,onClose:y,children:c.jsxs("div",{className:"aqmx-sheet-panel",children:[c.jsxs("div",{className:"aqmx-sheet-header",children:[c.jsx("div",{ref:k,className:"aqmx-sheet-notice-slot"}),c.jsx("button",{ref:P,type:"button",className:"aqmx-sheet-close","aria-label":d.hideExplorer,title:d.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>f(!1),children:c.jsx(Ke,{"aria-hidden":"true"})})]}),c.jsx("div",{className:"aqmx-sheet-body",children:c.jsx(ve,{value:i,children:c.jsx(Xe,{value:x,children:e})})}),c.jsx(R.LiveRegion,{holds:i,testId:"markdown-explorer-sheet-announcer"})]})})]})},Ge=r.createContext(null),Re="aqmx-explorer",Ye="aqmx-content",ye='[role="tree"] [role="treeitem"]',cr=`${ye}[tabindex="0"]`,ir="[data-directory-tree-tab-stop]",ur=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${Re}"] ${ye}`))if(n.getAttribute(ne)===t)return n;return null},Fe=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:O.ASSUMED_ROOT_FONT_PIXELS}),dr=(e,t)=>{const[n,a]=r.useState(()=>Fe(0,0));return r.useLayoutEffect(()=>{const s=e.current,d=t.current;if(s===null||d===null)throw new Error("[markdown-explorer] the split frame is not mounted");const o={frame:s.getBoundingClientRect().width,rem:d.getBoundingClientRect().width},l=()=>{const f=Fe(o.frame,o.rem);a(m=>m.inlineSize===f.inlineSize&&m.rootFontPixels===f.rootFontPixels?m:f)};l();const i=new ResizeObserver(f=>{for(const m of f){const[u]=m.borderBoxSize;u!==void 0&&(m.target===s&&(o.frame=u.inlineSize),m.target===d&&(o.rem=u.inlineSize))}l()});return i.observe(s),i.observe(d),()=>i.disconnect()},[e,t]),n},Qe=e=>`aqmx-split-handle-${e}`,fr=(e,{frameRef:t,sheetToggleRef:n,handleId:a})=>{const s=r.useRef(!1),d=r.useRef(null),o=r.useRef(!1);r.useLayoutEffect(()=>{const i=t.current;if(i===null)throw new Error("[markdown-explorer] the split frame is not mounted");const f=u=>{const p=u.target instanceof Element?u.target:null;s.current=p!==null&&p.closest(`[data-panel-id="${Ye}"]`)===null,!o.current&&(d.current=p?.closest(`${ye}[${ne}]`)?.getAttribute(ne)??null)},m=u=>{u.relatedTarget instanceof Node&&!i.contains(u.relatedTarget)&&(s.current=!1)};return i.addEventListener("focusin",f),i.addEventListener("focusout",m),()=>{i.removeEventListener("focusin",f),i.removeEventListener("focusout",m)}},[t]);const l=r.useRef(e);r.useLayoutEffect(()=>{if(l.current===e)return;l.current=e;const i=t.current;if(i===null||!s.current)return;const f=m=>{const{activeElement:u,body:p}=i.ownerDocument;if(u!==null&&u!==p)return;const x=m.find(g=>g!==null);if(x!=null){o.current=!0;try{x.focus()}finally{o.current=!1}}};if(e){f([n.current]);return}queueMicrotask(()=>{if(l.current!==e||!s.current)return;const m=d.current,u=`[data-panel-id="${Re}"]`;f([m===null?null:ur(i,m),i.querySelector(`${u} ${cr}`),i.querySelector(`${u} ${ir}`),i.querySelector(`[data-resize-handle-id="${a}"]`)])})},[e,t,n,a])},mr=({view:e,explorer:t,content:n,contentCoversPage:a=!1,sheetDismissals:s=0,onDraggingChange:d})=>{const o=r.useRef(null),[l,i]=r.useState(null),f=r.useRef(null),m=r.useRef(null),{inlineSize:u,rootFontPixels:p}=dr(o,f),x=u!==null&&u<O.explorerSheetBelowPixels(p);return fr(x,{frameRef:o,sheetToggleRef:m,handleId:Qe(e)}),c.jsxs("div",{ref:o,className:"aqmx-split-frame","data-aqmx-explorer-mode":x?"sheet":"split",children:[c.jsx("span",{ref:f,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),x?c.jsx(sr,{explorer:t,toggleRef:m,covered:a,onNoticeSlotChange:i,dismissals:s}):null,c.jsx(Ge,{value:x?l:null,children:c.jsx(pr,{view:e,sheet:x,explorer:t,content:n,contentCoversPage:a,onDraggingChange:d,explorerMinPixels:O.explorerMinPixels(p)})})]})},pr=({view:e,sheet:t,explorer:n,content:a,contentCoversPage:s,onDraggingChange:d,explorerMinPixels:o})=>{const{viewSettings:l,labels:i}=R.useExplorer(),m=R.useViewSetting(E=>e==="tree"?E.treeExplorer:E.multiExplorer)??(e==="tree"?O.EXPLORER_DEFAULT_PERCENT:O.EXPLORER_MULTI_DEFAULT_PERCENT),u=r.useRef(null),p=r.useRef(null),x=r.useRef(!1),g=r.useRef(!1),[b,S]=r.useState(!1),P=r.useRef(d);r.useLayoutEffect(()=>{P.current=d},[d]);const k=r.useCallback(()=>{const E=u.current;if(E===null||E.length!==2)return;const[y=0,v=0]=E,j=y+v;if(j<=0||y<=0)return;const M=Math.min(O.EXPLORER_MAX_PERCENT,y/j*100);l.update(e==="tree"?{treeExplorer:M}:{multiExplorer:M})},[l,e]),T=r.useCallback(()=>{p.current!==null&&clearTimeout(p.current),p.current=setTimeout(()=>{p.current=null,k()},O.EXPLORER_WIDTH_PERSIST_DELAY_MS)},[k]);r.useEffect(()=>()=>{p.current!==null&&clearTimeout(p.current),g.current&&P.current?.(!1)},[]);const F=ar(),q=r.useCallback((E,y)=>{u.current=E;const[v=0,j=0]=E;E.length===2&&j>0&&S(v<=0),y.source==="keyboard"?T():y.source==="pointer"&&(x.current=!0)},[T]),L=r.useCallback(E=>{if(g.current=E,d?.(E),E){x.current=!1;return}x.current&&(x.current=!1,T())},[d,T]);return c.jsxs(pe.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:q,className:"aqmx-split","data-aqmx-split":e,children:[t?null:c.jsx(pe.Panel,{id:Re,defaultSize:{value:m,unit:"percentage"},minSize:{value:o,unit:"pixels"},maxSize:{value:O.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:s,className:"aqmx-split-explorer",children:c.jsx(ve,{value:!b,children:n})}),t?null:c.jsx(pe.PanelResizeHandle,{id:Qe(e),thickness:F?O.COARSE_TARGET_PIXELS:O.FINE_TARGET_PIXELS,indicator:{visible:!0,thickness:O.SPLIT_HANDLE_PIXELS.gripThickness,length:O.SPLIT_HANDLE_PIXELS.gripLength,barThickness:O.SPLIT_HANDLE_PIXELS.barThickness,barLength:O.SPLIT_HANDLE_PIXELS.barLength},title:i.resizeExplorer,"aria-label":i.resizeExplorer,onDragging:L,inert:s,className:"aqmx-split-handle"}),c.jsx(pe.Panel,{id:Ye,defaultSize:{value:100-m,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...s?{style:{isolation:"auto"}}:{},children:a})]})};exports.EMPTY_SELECTION=he;exports.ExplorerPane=er;exports.ExplorerSplit=mr;exports.SheetNoticeSlotContext=Ge;