@aiquants/markdown-explorer 0.4.0 → 0.6.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 (44) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +30 -4
  3. package/dist/ExplorerSplit-CN5TvRj6.js +1495 -0
  4. package/dist/ExplorerSplit-CUIbSLQm.cjs +1 -0
  5. package/dist/MultiLayout-BDcQSpa6.cjs +1 -0
  6. package/dist/{MultiLayout-8s7q3-Hm.js → MultiLayout-hPmV-bae.js} +69 -66
  7. package/dist/{NativeScrollBar-DqkutcGb.cjs → NativeScrollBar-CHEQgaVx.cjs} +1 -1
  8. package/dist/{NativeScrollBar-D3VDRQqf.js → NativeScrollBar-DYEv2GLV.js} +1 -1
  9. package/dist/TreeLayout-BDaIyoGT.cjs +1 -0
  10. package/dist/TreeLayout-CqzxLpoM.js +23 -0
  11. package/dist/core/contracts.d.cts +23 -7
  12. package/dist/core/contracts.d.ts +23 -7
  13. package/dist/core/labels.d.cts +4 -0
  14. package/dist/core/labels.d.ts +4 -0
  15. package/dist/dataRoute-CUXlMhUJ.cjs +1 -0
  16. package/dist/{dataRoute-Dl6xmEFs.js → dataRoute-Ce6EIuu4.js} +69 -63
  17. package/dist/index-B3nShkkt.cjs +3 -0
  18. package/dist/{index-Dv9lUZqD.js → index-gJp1iXTc.js} +1020 -916
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +3 -3
  21. package/dist/{location-CaNtUswk.js → location-CtM94G0O.js} +1 -1
  22. package/dist/{location-2QZADLiv.cjs → location-FavgY_gB.cjs} +1 -1
  23. package/dist/sanitizeWorker.cjs +1 -1
  24. package/dist/sanitizeWorker.js +1 -1
  25. package/dist/server/errors.d.cts +1 -1
  26. package/dist/server/errors.d.ts +1 -1
  27. package/dist/server/ports.d.cts +1 -0
  28. package/dist/server/ports.d.ts +1 -0
  29. package/dist/server.cjs +1 -1
  30. package/dist/server.js +753 -716
  31. package/dist/styles/markdown-explorer.css +1 -1
  32. package/docs/behavior/dom-hooks.md +6 -3
  33. package/docs/behavior/layout.md +6 -0
  34. package/docs/behavior/localization.md +4 -1
  35. package/docs/behavior/security.md +11 -4
  36. package/docs/behavior/url-contract.md +1 -0
  37. package/package.json +4 -3
  38. package/dist/ExplorerSplit-rUVsf5i-.cjs +0 -1
  39. package/dist/ExplorerSplit-uX2ojZe8.js +0 -1479
  40. package/dist/MultiLayout-ZK2V9nms.cjs +0 -1
  41. package/dist/TreeLayout-C7ZNnaOr.js +0 -22
  42. package/dist/TreeLayout-DkTVgxxb.cjs +0 -1
  43. package/dist/dataRoute-DYjYBiXF.cjs +0 -1
  44. package/dist/index-CLe6vRXs.cjs +0 -3
@@ -1,1479 +0,0 @@
1
- import { jsx as m, jsxs as k, Fragment as Ve } from "react/jsx-runtime";
2
- import { u as D, F as Et, d as Re, f as je, g as bt, E as yt, h as Rt, i as St, j as Tt, k as Nt } from "./index-Dv9lUZqD.js";
3
- import * as u from "react";
4
- import { use as he, createContext as Se, useState as C, useCallback as w, useMemo as F, useRef as v, useLayoutEffect as H, useEffect as I, useSyncExternalStore as xe, Suspense as Ke, useId as we } from "react";
5
- import { C as Lt, k as kt, l as Ue, v as Ot, m as Pt, n as At, E as qt, o as _e, q as Ct, s as Ft, S as pe, t as Mt, F as _t, A as It } from "./location-CaNtUswk.js";
6
- import { useDirectoryTreeState as Dt, DirectoryTree as Ht } from "@aiquants/directory-tree";
7
- import { T as Zt } from "./tapScrollCircle-u4EXeLhx.js";
8
- import { s as $t } from "./storage-DA4ItHzl.js";
9
- import { PanelGroup as Bt, Panel as Ie, PanelResizeHandle as zt } from "@aiquants/resize-panels";
10
- import { useLocation as Vt } from "react-router";
11
- function jt({
12
- title: e,
13
- titleId: t,
14
- ...n
15
- }, r) {
16
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
17
- xmlns: "http://www.w3.org/2000/svg",
18
- viewBox: "0 0 24 24",
19
- fill: "currentColor",
20
- "aria-hidden": "true",
21
- "data-slot": "icon",
22
- ref: r,
23
- "aria-labelledby": t
24
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
25
- id: t
26
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
27
- fillRule: "evenodd",
28
- 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",
29
- clipRule: "evenodd"
30
- }));
31
- }
32
- const Kt = /* @__PURE__ */ u.forwardRef(jt);
33
- function Ut({
34
- title: e,
35
- titleId: t,
36
- ...n
37
- }, r) {
38
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
39
- xmlns: "http://www.w3.org/2000/svg",
40
- viewBox: "0 0 24 24",
41
- fill: "currentColor",
42
- "aria-hidden": "true",
43
- "data-slot": "icon",
44
- ref: r,
45
- "aria-labelledby": t
46
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
47
- id: t
48
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
49
- fillRule: "evenodd",
50
- 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",
51
- clipRule: "evenodd"
52
- }));
53
- }
54
- const Wt = /* @__PURE__ */ u.forwardRef(Ut);
55
- function Xt({
56
- title: e,
57
- titleId: t,
58
- ...n
59
- }, r) {
60
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
61
- xmlns: "http://www.w3.org/2000/svg",
62
- viewBox: "0 0 24 24",
63
- fill: "currentColor",
64
- "aria-hidden": "true",
65
- "data-slot": "icon",
66
- ref: r,
67
- "aria-labelledby": t
68
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
69
- id: t
70
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
71
- 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"
72
- }), /* @__PURE__ */ u.createElement("path", {
73
- 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"
74
- }));
75
- }
76
- const Gt = /* @__PURE__ */ u.forwardRef(Xt);
77
- function Yt({
78
- title: e,
79
- titleId: t,
80
- ...n
81
- }, r) {
82
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
83
- xmlns: "http://www.w3.org/2000/svg",
84
- viewBox: "0 0 24 24",
85
- fill: "currentColor",
86
- "aria-hidden": "true",
87
- "data-slot": "icon",
88
- ref: r,
89
- "aria-labelledby": t
90
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
91
- id: t
92
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
93
- fillRule: "evenodd",
94
- 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",
95
- clipRule: "evenodd"
96
- }));
97
- }
98
- const Qt = /* @__PURE__ */ u.forwardRef(Yt), Jt = () => {
99
- const { notices: e } = D(), t = he(e);
100
- return t.length === 0 ? null : /* @__PURE__ */ m("div", { className: "aqmx-explorer-notices", children: t.map((n) => /* @__PURE__ */ k("div", { className: "aqmx-callout", "data-aqmx-tone": n.tone, "data-testid": "markdown-explorer-notice", "data-aqmx-notice": n.id, children: [
101
- /* @__PURE__ */ m("p", { className: "aqmx-callout-title", children: n.title }),
102
- n.body === void 0 ? null : /* @__PURE__ */ m("p", { className: "aqmx-callout-body", children: n.body }),
103
- n.action === void 0 ? null : (
104
- /* @__PURE__ */ m("a", { className: "aqmx-callout-action", href: n.action.href, children: n.action.label })
105
- )
106
- ] }, n.id)) });
107
- };
108
- function en({
109
- title: e,
110
- titleId: t,
111
- ...n
112
- }, r) {
113
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
114
- xmlns: "http://www.w3.org/2000/svg",
115
- viewBox: "0 0 24 24",
116
- fill: "currentColor",
117
- "aria-hidden": "true",
118
- "data-slot": "icon",
119
- ref: r,
120
- "aria-labelledby": t
121
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
122
- id: t
123
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
124
- fillRule: "evenodd",
125
- 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",
126
- clipRule: "evenodd"
127
- }));
128
- }
129
- const tn = /* @__PURE__ */ u.forwardRef(en), Te = Se(!0), We = "\0loop\0", Xe = "\0", nn = () => {
130
- const e = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = (l) => {
131
- const a = e.get(l);
132
- if (a !== void 0) return a;
133
- const o = Object.freeze({ type: "loop", name: l.name, path: l.path });
134
- return e.set(l, o), o;
135
- }, s = (l, a, o) => {
136
- let p = !1;
137
- const d = l.map((f) => {
138
- const h = c(f, a, o);
139
- return h !== f && (p = !0), h;
140
- });
141
- if (!p) return l;
142
- const i = n.get(l);
143
- return i !== void 0 && i.length === d.length && i.every((f, h) => f === d[h]) ? i : (n.set(l, d), d);
144
- }, c = (l, a, o) => {
145
- if (l.type !== "directory") return l;
146
- if (o.has(l.path)) return r(l);
147
- const p = l.lazy === !0 ? a(l.path) : void 0, d = p?.status === "loaded", i = d ? p.entries : l.children;
148
- if (i === void 0) return l;
149
- o.add(l.path);
150
- const f = s(i, a, o);
151
- if (o.delete(l.path), !d && f === l.children) return l;
152
- const h = t.get(l);
153
- if (h !== void 0 && h.state === p && h.children === f) return h.grafted;
154
- const g = { ...l, children: f, lazy: d ? !1 : l.lazy };
155
- return t.set(l, { state: p, children: f, grafted: g }), g;
156
- };
157
- return (l, a) => s(l, a, /* @__PURE__ */ new Set());
158
- }, rn = (e, t) => `${We}${e}${Xe}${t}`, ie = (e) => e.startsWith(We), an = (e) => e.slice(e.lastIndexOf(Xe) + 1), oe = "data-aqmx-path", ln = (e, t, n, r, s) => {
159
- const c = { aqmxPath: e.path };
160
- return n && (c.aqmxOpen = !0), (r === "loading" || r === "failed") && (c.aqmxChildren = r), {
161
- name: e.name,
162
- type: e.type,
163
- absolutePath: e.path,
164
- relativePath: e.path,
165
- mimeType: e.mimeType,
166
- children: t,
167
- label: s,
168
- data: c
169
- };
170
- }, on = (e, t, n, r) => {
171
- const s = rn(t, e.path);
172
- return { name: n, type: "directory", absolutePath: s, relativePath: s, children: r, data: { aqmxLoop: e.path } };
173
- }, sn = () => {
174
- const e = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = [], s = (a, o, p) => {
175
- const d = a.map((f) => f.type === "loop" ? c(f, o, p) : l(f, o)), i = n.get(a);
176
- return i !== void 0 && i.length === d.length && i.every((f, h) => f === d[h]) ? i : (n.set(a, d), d);
177
- }, c = (a, o, p) => {
178
- const d = t.get(a);
179
- if (d !== void 0 && d.parentKey === p && d.loopFolderName === o.loopFolderName) return d.row;
180
- const i = on(a, p, o.loopFolderName(a.name), r);
181
- return t.set(a, { row: i, parentKey: p, loopFolderName: o.loopFolderName }), i;
182
- }, l = (a, o) => {
183
- const p = a.type === "directory" ? a.children === void 0 ? r : s(a.children, o, a.path) : void 0, d = o.openPaths.has(a.path), i = a.type === "directory" && a.lazy === !0 ? o.childrenOf(a.path)?.status : void 0, f = i === "failed" ? o.renderFailedFolder : void 0, h = e.get(a);
184
- if (h !== void 0 && h.open === d && h.childrenStatus === i && h.children === p && h.renderFailedFolder === f)
185
- return h.row;
186
- const g = ln(a, p, d, i, f === void 0 ? void 0 : f(a));
187
- return e.set(a, { row: g, open: d, childrenStatus: i, children: p, renderFailedFolder: f }), g;
188
- };
189
- return (a, o) => s(a, o, "");
190
- }, cn = (e) => {
191
- if (e === void 0) return;
192
- const t = (n) => ({ name: n.name, path: n.absolutePath, type: n.type });
193
- return (n, r) => e(t(n), t(r));
194
- }, ye = (e, t) => {
195
- const n = e.filter((r) => r.type === "directory");
196
- return t === void 0 ? n : n.sort(t);
197
- }, dn = (e, t) => {
198
- const n = /* @__PURE__ */ new Map();
199
- let r = 0;
200
- const s = (c) => {
201
- for (const l of ye(c, t.compare))
202
- if (t.isShownExpanded(l.path)) {
203
- if (l.lazy !== !0) {
204
- l.children !== void 0 && s(l.children);
205
- continue;
206
- }
207
- n.has(l.path) || (n.set(l.path, t.isDirect(l.path) ? "direct" : "bulk"), t.childrenOf(l.path)?.status !== "failed" && (r += 1));
208
- }
209
- };
210
- return s(e), { folders: n, waiting: r };
211
- }, un = (e) => {
212
- const t = /* @__PURE__ */ new Set(), n = (r) => {
213
- for (const s of r)
214
- s.type === "directory" && (s.lazy === !0 && t.add(s.path), s.children !== void 0 && n(s.children));
215
- };
216
- return n(e), t;
217
- }, Ge = (e, t) => {
218
- for (const n of e) {
219
- if (n.type !== "directory") continue;
220
- if (n.path === t) return n;
221
- const r = n.children === void 0 ? null : Ge(n.children, t);
222
- if (r !== null) return r;
223
- }
224
- return null;
225
- }, mn = (e, t, n, r) => {
226
- let s = e;
227
- for (const c of t) {
228
- const l = s.find((a) => a.type === "directory" && a.path === c);
229
- if (l === void 0) return "missing";
230
- if (l.lazy === !0) return r.childrenOf(l.path)?.status === "failed" ? "failed" : "loading";
231
- if (!r.isShownExpanded(l.path)) return "loading";
232
- s = l.children ?? [];
233
- }
234
- return s.some((c) => c.type === "file" && c.path === n) ? "ready" : "missing";
235
- }, De = /* @__PURE__ */ new Set(), fn = (e, t) => e.has(t) ? e : new Set(e).add(t), pn = (e, t) => {
236
- if (!t.some((r) => e.has(r))) return e;
237
- const n = new Set(t);
238
- return new Set([...e].filter((r) => !n.has(r)));
239
- }, hn = (e, t) => [...e].every((n) => t.has(n)) ? e : new Set([...e].filter((n) => t.has(n))), xn = () => {
240
- const [e, t] = C(De), n = w((l) => t((a) => fn(a, l)), []), r = w((l) => t((a) => pn(a, l)), []), s = w((l) => t((a) => hn(a, l)), []), c = w(() => t(De), []);
241
- return F(() => ({ direct: e, markDirect: n, unmarkDirect: r, pruneDirect: s, clearDirect: c }), [e, n, r, s, c]);
242
- }, wn = (e) => ({
243
- budget: e,
244
- handled: /* @__PURE__ */ new Set(),
245
- loads: /* @__PURE__ */ new Set(),
246
- opened: 0,
247
- folderLimited: !1,
248
- depthLimited: !1,
249
- announcedStart: !1,
250
- issuedAgainst: null
251
- }), gn = (e, t) => {
252
- const n = [];
253
- let r = ye(t.entries, t.compare);
254
- for (let s = 1; r.length > 0; s += 1) {
255
- const c = [];
256
- for (const l of r) {
257
- const { path: a } = l;
258
- if (t.isShownExpanded(a))
259
- e.handled.add(a);
260
- else {
261
- if (e.handled.has(a)) continue;
262
- if (e.handled.add(a), l.lazy === !0 && t.childrenOf(a) === void 0) {
263
- if (s > e.budget.maxDepth) {
264
- e.depthLimited = !0;
265
- continue;
266
- }
267
- if (e.loads.size >= e.budget.maxFolders) {
268
- e.folderLimited = !0;
269
- continue;
270
- }
271
- e.loads.add(a);
272
- }
273
- n.push(a), e.opened += 1;
274
- }
275
- l.lazy !== !0 && l.children !== void 0 && c.push(...ye(l.children, t.compare));
276
- }
277
- r = c;
278
- }
279
- return n;
280
- }, Ye = (e, t) => e.every((n) => n.type !== "directory" || t(n.path) && (n.lazy === !0 || n.children === void 0 || Ye(n.children, t))), vn = (e, t) => {
281
- if (e.folderLimited) return { kind: "folder-limit", opened: e.opened };
282
- if (e.depthLimited) return { kind: "depth-limit", opened: e.opened };
283
- let n = 0;
284
- for (const r of e.loads) t.childrenOf(r)?.status === "failed" && (n += 1);
285
- return { kind: "done", opened: e.opened, failed: n, complete: Ye(t.entries, t.isShownExpanded) };
286
- }, Ee = Object.freeze({ state: "idle" }), En = (e) => {
287
- const t = v(null), n = v(e), [r, s] = C(Ee);
288
- H(() => {
289
- n.current = e;
290
- });
291
- const c = w(() => {
292
- t.current === null && (t.current = wn(n.current.budget), s({ state: "running", opened: 0 }));
293
- }, []), l = w(() => {
294
- t.current = null, s(Ee);
295
- }, []), a = w((o) => {
296
- const p = t.current;
297
- if (p === null) return;
298
- const d = gn(p, o);
299
- if (d.length > 0 && (p.issuedAgainst = o.expanded, n.current.expandMultiple([...d])), !p.announcedStart && (p.loads.size > 0 || o.waiting > 0) && (p.announcedStart = !0, n.current.onStart()), d.length === 0 && !o.expansionPending && o.expanded !== p.issuedAgainst && o.waiting === 0) {
300
- t.current = null;
301
- const f = vn(p, o);
302
- s(f.kind === "done" ? Ee : { state: "stopped", stop: f.kind, opened: f.opened }), n.current.onFinish(f);
303
- return;
304
- }
305
- const { opened: i } = p;
306
- s((f) => f.state === "running" && f.opened === i ? f : { state: "running", opened: i });
307
- }, []);
308
- return F(() => ({ status: r, start: c, end: l, advance: a }), [r, c, l, a]);
309
- }, He = ["pointerdown", "wheel", "touchstart", "keydown", "focusin"], bn = 8, Ze = { least: Number.POSITIVE_INFINITY, stalled: 0 }, yn = ({ tree: e, container: t, path: n, chain: r, rows: s, cancel: c, displayed: l, placement: a }) => {
310
- const o = v(null), p = v(!0), d = v(Ze), i = v(null), f = v(null), h = v(r), g = v(a);
311
- H(() => {
312
- h.current = r, g.current = a;
313
- }, [r, a]);
314
- const b = w(() => {
315
- const S = i.current;
316
- S !== null && (i.current = null, S.phase === "asking" ? S.controller.abort() : h.current?.open(null));
317
- }, []), L = w(() => {
318
- o.current = null, b();
319
- }, [b]), R = w(() => {
320
- const S = t.current;
321
- o.current === null || f.current !== null || S === null || S.getClientRects().length === 0 || (f.current = requestAnimationFrame(() => {
322
- f.current = null;
323
- const E = o.current;
324
- if (E === null) return;
325
- const T = g.current(E);
326
- if (T === 0) {
327
- p.current = !0, i.current?.phase === "opening" && b();
328
- return;
329
- }
330
- if (e.current?.scrollToPath(E, { align: "nearest" }) === !0) {
331
- i.current?.phase === "opening" && b();
332
- const { least: P, stalled: M } = d.current;
333
- d.current = T < P ? { least: T, stalled: 0 } : { least: P, stalled: M + 1 }, d.current.stalled < bn && R();
334
- return;
335
- }
336
- const y = i.current;
337
- if (y === null) {
338
- o.current = null;
339
- return;
340
- }
341
- y.phase === "opening" && h.current?.progress(y.folders, E) !== "loading" && L();
342
- }));
343
- }, [e, t, b, L]), A = w(() => {
344
- p.current = !1, d.current = Ze, R();
345
- }, [R]);
346
- I(() => {
347
- const S = t.current;
348
- if (S === null) return;
349
- const E = typeof ResizeObserver > "u" ? null : new ResizeObserver(A);
350
- E?.observe(S);
351
- for (const T of He) S.addEventListener(T, L, { passive: !0 });
352
- return () => {
353
- E?.disconnect();
354
- for (const T of He) S.removeEventListener(T, L);
355
- f.current !== null && cancelAnimationFrame(f.current), f.current = null, b();
356
- };
357
- }, [t, A, L, b]);
358
- const O = r !== null;
359
- I(() => {
360
- const S = t.current;
361
- if (L(), n === null || S === null || S.contains(S.ownerDocument.activeElement)) return;
362
- o.current = n;
363
- const E = h.current;
364
- if (O && E !== null) {
365
- const T = new AbortController(), y = { phase: "asking", controller: T };
366
- i.current = y, E.ancestors(n, T.signal).then((P) => {
367
- i.current === y && (P === null ? i.current = null : (i.current = { phase: "opening", folders: P }, h.current?.open(P)), A());
368
- });
369
- }
370
- A();
371
- }, [n, O, t, L, A]), I(() => {
372
- (i.current?.phase === "opening" || o.current !== null && !p.current) && A();
373
- }, [s, A]);
374
- const Z = v(c);
375
- I(() => {
376
- Z.current !== c && (Z.current = c, L());
377
- }, [c, L]);
378
- const B = v(l);
379
- I(() => {
380
- B.current && !l && b(), B.current = l;
381
- }, [l, b]);
382
- }, Rn = "--aqmx-tree-line", Sn = Object.freeze(["(forced-colors: active)", "(prefers-color-scheme: dark)"]), Tn = "data-aqmx-tree-probe", Nn = Object.freeze({ rowHeight: Lt, lineColor: null }), Ln = /^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/u, kn = (e) => {
383
- const t = Ln.exec(e);
384
- return t === null ? e : `#${t.slice(1).map((n) => Number(n).toString(16).padStart(2, "0")).join("")}`;
385
- }, On = (e, t) => {
386
- const [n, r] = C(Nn);
387
- return H(() => {
388
- const s = e.current;
389
- if (s === null) return;
390
- const c = () => {
391
- const o = Math.round(s.getBoundingClientRect().height), p = getComputedStyle(s), d = p.getPropertyValue(Rn).trim() === "" ? null : kn(p.color);
392
- r((i) => {
393
- const f = Number.isFinite(o) && o > 0 ? o : i.rowHeight;
394
- return i.rowHeight === f && i.lineColor === d ? i : { rowHeight: f, lineColor: d };
395
- });
396
- };
397
- c();
398
- const l = Sn.map((o) => window.matchMedia(o));
399
- for (const o of l) o.addEventListener("change", c);
400
- const a = typeof ResizeObserver > "u" ? null : new ResizeObserver(c);
401
- return a?.observe(s), () => {
402
- for (const o of l) o.removeEventListener("change", c);
403
- a?.disconnect();
404
- };
405
- }, [e, t]), n;
406
- }, Qe = "markdown-explorer-tree-scroll", Pn = 0.5, Je = (e, t) => [...e.querySelectorAll(`[role="treeitem"][${oe}]`)].find((n) => n.getAttribute(oe) === t), An = (e, t) => {
407
- const n = Je(e, t), r = n?.closest(`[data-testid="${Qe}"]`);
408
- if (n === void 0 || r === null || r === void 0) return Number.POSITIVE_INFINITY;
409
- const s = r.getBoundingClientRect(), c = n.getBoundingClientRect(), l = s.top - c.top, a = c.height > s.height ? Math.abs(l) : Math.max(0, l) + Math.max(0, c.bottom - s.bottom);
410
- return a <= Pn ? 0 : a;
411
- }, qn = {
412
- testId: Qe,
413
- overscanCount: 13,
414
- callbackThrottleMs: 13,
415
- scrollBarOptions: {
416
- width: 8,
417
- enableTrackClick: !0,
418
- enableThumbDrag: !0,
419
- enableArrowButtons: !0,
420
- enableArrowButtonTabStops: !1,
421
- enableScrollToTopBottomButtons: !0,
422
- tapScrollCircleOptions: Zt
423
- },
424
- behaviorOptions: { enablePointerDrag: !0 }
425
- }, Cn = { hoverClassName: "", directorySelectedClassName: "", itemSelectedClassName: "" }, Fn = { color: "inherit" }, Mn = { paddingBlock: 0 }, _n = /* @__PURE__ */ new Set(), In = /* @__PURE__ */ new Map(), Dn = { color: "var(--aqmx-tree-line)" }, Hn = (e) => {
426
- const t = e instanceof Element ? e.closest(`[${oe}]`) : null;
427
- return t === null || t.getAttribute("data-entry-type") !== "file" ? null : t.getAttribute(oe);
428
- }, et = (e, t, n, r) => n === "folder-limit" ? e.expandAllFolderLimit(r, t.maxFolders, e.expandAll) : e.expandAllDepthLimit(r, t.maxDepth), Zn = (e, t, n) => n.kind === "done" ? e.expandAllDone(n.opened, n.failed, n.complete) : et(e, t, n.kind, n.opened), tt = () => {
429
- const { labels: e } = D();
430
- return /* @__PURE__ */ k("div", { className: "aqmx-explorer-loading", "aria-busy": "true", "data-testid": "markdown-explorer-tree-loading", children: [
431
- /* @__PURE__ */ m("p", { className: "aqmx-explorer-loading-text", children: e.treeLoading }),
432
- /* @__PURE__ */ k("div", { className: "aqmx-skeleton", "aria-hidden": "true", children: [
433
- /* @__PURE__ */ m("span", {}),
434
- /* @__PURE__ */ m("span", {}),
435
- /* @__PURE__ */ m("span", {}),
436
- /* @__PURE__ */ m("span", {}),
437
- /* @__PURE__ */ m("span", {})
438
- ] })
439
- ] });
440
- }, $n = () => {
441
- const { labels: e } = D();
442
- return /* @__PURE__ */ k("div", { className: "aqmx-empty", "data-testid": "markdown-explorer-tree-empty", children: [
443
- /* @__PURE__ */ m(tn, { className: "aqmx-explorer-empty-icon", "aria-hidden": "true" }),
444
- /* @__PURE__ */ m("p", { className: "aqmx-empty-title", children: e.treeEmptyTitle }),
445
- /* @__PURE__ */ m("p", { className: "aqmx-explorer-empty-body", children: e.treeEmptyBody })
446
- ] });
447
- }, Bn = ({ name: e, onRetry: t }) => {
448
- const { labels: n } = D(), r = we();
449
- return /* @__PURE__ */ k("span", { className: "aqmx-explorer-folder-failed", children: [
450
- /* @__PURE__ */ m("span", { className: "aqmx-explorer-folder-name", children: e }),
451
- /* @__PURE__ */ m("span", { id: r, className: "aqmx-explorer-folder-error", children: n.folderLoadFailed }),
452
- /* @__PURE__ */ k(
453
- "button",
454
- {
455
- type: "button",
456
- className: "aqmx-explorer-folder-retry",
457
- "aria-describedby": r,
458
- "data-testid": "markdown-explorer-folder-retry",
459
- onClick: (s) => {
460
- s.stopPropagation();
461
- const c = s.currentTarget, l = c.ownerDocument.activeElement === c ? c.closest('[role="treeitem"]') : null;
462
- l instanceof HTMLElement && je(l), t();
463
- },
464
- onKeyDown: (s) => {
465
- s.key !== "Escape" && s.stopPropagation();
466
- },
467
- children: [
468
- /* @__PURE__ */ m(Re, { className: "aqmx-explorer-folder-retry-icon", "aria-hidden": "true" }),
469
- /* @__PURE__ */ m("span", { className: "aqmx-explorer-folder-retry-text", children: n.retry })
470
- ]
471
- }
472
- )
473
- ] });
474
- }, zn = ({
475
- entries: e,
476
- version: t,
477
- mode: n,
478
- sourceId: r,
479
- settings: s,
480
- reveal: c,
481
- openPaths: l,
482
- selection: a,
483
- onOpenDocument: o,
484
- expansion: p,
485
- onShown: d,
486
- marks: i,
487
- claimsHeld: f,
488
- expandAll: h,
489
- revealCancel: g
490
- }) => {
491
- const { trees: b, documents: L, labels: R, locale: A, theme: O, data: Z, config: B } = D(), S = he(Te), [E] = C(sn), T = v(null), { rowHeight: y, lineColor: P } = On(T, O), { isExpanded: M, toggle: ne, expandMultiple: $, collapseMultiple: K, expanded: j, isPending: re } = p, { alwaysExpanded: U, sortMode: ae, folderPlacement: W } = s, { direct: Q, markDirect: q, unmarkDirect: X, pruneDirect: se } = i, { running: le, advance: de } = h, ce = v(null), J = v(null), N = F(() => kt({ sortMode: ae, folderPlacement: W }), [ae, W]), G = F(() => cn(N), [N]), z = w((x) => b.children(r, x), [b, r]), ee = F(() => un(e), [e]), te = w((x) => !ie(x) && (M(x) || U && !ee.has(x)), [M, U, ee]), Y = v({ shownExpanded: te, isExpanded: M, unloadedFolders: ee, entries: e, childrenOf: z });
492
- H(() => {
493
- Y.current = { shownExpanded: te, isExpanded: M, unloadedFolders: ee, entries: e, childrenOf: z };
494
- }, [te, M, ee, e, z]);
495
- const Oe = w((x) => {
496
- ce.current?.scrollToPath(x, { align: "nearest" }), requestAnimationFrame(() => {
497
- const _ = J.current, V = _ === null ? void 0 : Je(_, x);
498
- V !== void 0 && je(V);
499
- });
500
- }, []), ct = w(
501
- (x) => {
502
- if (ie(x)) {
503
- Oe(an(x));
504
- return;
505
- }
506
- Y.current.isExpanded(x) ? X([x]) : Y.current.unloadedFolders.has(x) && q(x), ne(x);
507
- },
508
- [Oe, q, X, ne]
509
- ), ge = w(
510
- (x) => {
511
- const _ = x.filter((V) => !ie(V));
512
- _.length !== 0 && (X(_), K(_));
513
- },
514
- [X, K]
515
- ), it = w(
516
- (x) => {
517
- const _ = x.filter((V) => !ie(V));
518
- _.length !== 0 && (_.length < x.length && _.every((V) => Y.current.shownExpanded(V)) ? ge(_) : $(_));
519
- },
520
- [$, ge]
521
- ), Pe = w(
522
- (x) => /* @__PURE__ */ m(
523
- Bn,
524
- {
525
- name: x.name,
526
- onRetry: () => {
527
- q(x.path), b.retryChildren(r, x.path), Y.current.shownExpanded(x.path) || $([x.path]);
528
- }
529
- }
530
- ),
531
- [b, r, q, $]
532
- ), Ae = n === "multi" ? l : _n, { loopFolderName: qe } = R, dt = F(() => E(e, { openPaths: Ae, childrenOf: z, renderFailedFolder: Pe, loopFolderName: qe }), [E, e, Ae, z, Pe, qe, t]), ut = bt(L, Hn), Ce = v([]), ue = w(() => {
533
- for (const x of Ce.current) Y.current.unloadedFolders.has(x) && q(x);
534
- }, [q]), { maxDepth: Fe } = B.revealDocument, mt = F(
535
- () => ({
536
- ancestors: async (x, _) => {
537
- const V = await Z.ancestors(r, x, _);
538
- return V.status !== "ok" || V.ancestors === null || V.ancestors.length > Fe ? null : V.ancestors;
539
- },
540
- open: (x) => {
541
- Ce.current = x ?? [], x !== null && (ue(), $([...x]));
542
- },
543
- progress: (x, _) => mn(Y.current.entries, x, _, { isShownExpanded: Y.current.shownExpanded, childrenOf: Y.current.childrenOf })
544
- }),
545
- [Z, r, Fe, ue, $]
546
- );
547
- I(() => ue(), [ue, ee]);
548
- const ft = F(() => [e, t, j], [e, t, j]), pt = w((x) => J.current === null ? Number.POSITIVE_INFINITY : An(J.current, x), []);
549
- yn({ tree: ce, container: J, path: c.path, chain: c.openFolders ? mt : null, rows: ft, cancel: g, displayed: S, placement: pt });
550
- const Me = w((x) => Q.has(x), [Q]), me = F(() => dn(e, { isShownExpanded: te, childrenOf: z, compare: N, isDirect: Me }), [e, te, z, N, Me, t]), fe = S && f;
551
- H(() => {
552
- d(e);
553
- }, [e, d]), H(() => () => d(null), [d]), I(() => b.claimChildren(r, fe ? me.folders : In), [b, r, fe, me]), I(() => se(ee), [se, ee]), I(() => {
554
- fe && le && de({ entries: e, isShownExpanded: te, childrenOf: z, compare: N, expanded: j, waiting: me.waiting, expansionPending: re });
555
- }, [fe, le, de, e, te, z, N, j, me, re]);
556
- const ht = w(
557
- (x) => {
558
- x.isDirectory || o(x.entry.absolutePath);
559
- },
560
- [o]
561
- ), { onChange: ve } = a, xt = F(
562
- () => ve === null ? void 0 : (x, _) => {
563
- ie(x.absolutePath) || ve({ path: x.absolutePath, name: x.name, selected: _ });
564
- },
565
- [ve]
566
- ), wt = F(() => new Set(a.items), [a.items]), gt = F(
567
- () => ({
568
- entryKindDirectory: R.treeEntryKindDirectory,
569
- entryKindFile: R.treeEntryKindFile,
570
- scrollUp: R.treeScrollUp,
571
- scrollDown: R.treeScrollDown,
572
- scrollToTop: R.treeScrollToTop,
573
- scrollToBottom: R.treeScrollToBottom
574
- }),
575
- [R]
576
- ), vt = P === null ? { showTreeLines: !1 } : { showTreeLines: s.lines, lineColor: P };
577
- return /* @__PURE__ */ k("div", { ref: J, className: "aqmx-explorer-tree", "data-testid": "markdown-explorer-tree", ...ut, children: [
578
- /* @__PURE__ */ m("span", { ref: T, className: "aqmx-explorer-tree-probe", "aria-hidden": "true", [Tn]: "" }),
579
- /* @__PURE__ */ m(
580
- Ht,
581
- {
582
- ref: ce,
583
- entries: dt,
584
- expansion: {
585
- toggle: ct,
586
- isExpanded: te,
587
- expandMultiple: it,
588
- collapseMultiple: ge,
589
- isPending: re && !le,
590
- doubleClickAction: s.doubleClickAction
591
- },
592
- selection: { mode: a.mode, selectedPath: a.shownPath, currentPath: a.shownPath, selectedItems: wt, onEntryClick: ht, onSelectionChange: xt },
593
- visual: {
594
- className: "aqmx-explorer-tree-view",
595
- ariaLabel: R.treeRegion,
596
- ...vt,
597
- showExpandIcons: s.expandIcons,
598
- expandIconStyle: Dn,
599
- showDirectoryIcons: s.directoryIcons,
600
- showFileIcons: s.fileIcons,
601
- expandIconSize: s.expandIconSize,
602
- itemHeight: y,
603
- removeRootIndent: s.removeRootIndent,
604
- highlightStyles: Cn,
605
- entryStyle: Mn,
606
- nameStyle: Fn
607
- },
608
- virtualScroll: qn,
609
- sort: G,
610
- locale: A,
611
- labels: gt
612
- }
613
- )
614
- ] });
615
- }, Vn = ({ pending: e, status: t }) => {
616
- const { labels: n } = D(), r = t.state !== "running", [s, c] = C(0), l = v(!0);
617
- H(() => {
618
- const o = l.current;
619
- if (l.current = r, !r || e > 0 && !o) {
620
- c(0);
621
- return;
622
- }
623
- if (e > 0) {
624
- c(e);
625
- return;
626
- }
627
- if (s === 0) return;
628
- const p = setTimeout(() => c(0), 0);
629
- return () => clearTimeout(p);
630
- }, [r, e, s]);
631
- const a = r && e === 0 ? s : e;
632
- return a === 0 && r ? null : /* @__PURE__ */ k("p", { className: "aqmx-explorer-tree-progress", "data-testid": "markdown-explorer-tree-progress", "data-aqmx-loading": String(a), "data-aqmx-expand-all": t.state, children: [
633
- a > 0 ? /* @__PURE__ */ m(Re, { className: "aqmx-explorer-tree-progress-icon", "aria-hidden": "true" }) : null,
634
- /* @__PURE__ */ m("span", { children: t.state === "running" ? n.expandAllProgress(t.opened, a) : n.foldersLoading(a) })
635
- ] });
636
- }, jn = ({ stop: e, opened: t, budget: n }) => {
637
- const { labels: r } = D();
638
- return /* @__PURE__ */ m("p", { className: "aqmx-explorer-expand-all-stop", "data-testid": "markdown-explorer-expand-all-stop", "data-aqmx-stop": e, children: et(r, n, e, t) });
639
- }, Kn = ({ entries: e, ...t }) => {
640
- const { trees: n } = D(), r = xe(n.subscribe, n.version, n.version), { sourceId: s } = t, [c] = C(nn), l = F(() => c(e, (a) => n.children(s, a)), [c, e, n, s, r]);
641
- return l.length === 0 ? /* @__PURE__ */ m($n, {}) : /* @__PURE__ */ m(zn, { entries: l, version: r, ...t });
642
- }, Un = ({ result: e, onRetry: t, ...n }) => {
643
- const { renderTreeFailure: r } = D(), s = he(e);
644
- if (s.status === "deferred") return /* @__PURE__ */ m(tt, {});
645
- if (s.status === "ok") return /* @__PURE__ */ m(Kn, { entries: s.entries, ...n });
646
- const c = r?.(s.failure);
647
- return /* @__PURE__ */ m("div", { className: "aqmx-explorer-tree-message", "data-testid": "markdown-explorer-tree-failure", "data-aqmx-failure": s.failure.reason, children: c !== void 0 ? c : /* @__PURE__ */ m(Et, { failure: s.failure, alert: !0, onRetry: t, testId: null }) });
648
- }, Wn = ({ onControls: e, ...t }) => {
649
- const { trees: n, storageNamespace: r, labels: s, announcer: c, config: l } = D(), { sourceId: a } = t, o = Dt({ storageKey: $t(r).treeExpansion(a) });
650
- xe(n.subscribe, n.version, n.version);
651
- const p = n.read(a), d = w(() => n.retry(a), [n, a]);
652
- H(() => n.open(a), [n, a]);
653
- const i = xn(), { expanded: f, expandMultiple: h, collapseAll: g } = o, [b, L] = C(null), R = b !== f, A = v(f);
654
- H(() => {
655
- A.current = f;
656
- }, [f]);
657
- const O = l.expandAll, Z = w(() => c.announce(s.expandAllStarted), [c, s]), B = w((q) => c.announce(Zn(s, O, q)), [c, s, O]), S = En({ budget: O, expandMultiple: h, onStart: Z, onFinish: B }), { status: E, start: T, end: y, advance: P } = S, M = E.state === "running", ne = F(() => ({ running: M, advance: P }), [M, P]), $ = v(null), [K, j] = C(!1), re = w((q) => {
658
- $.current = q, j(q !== null);
659
- }, []);
660
- I(
661
- () => n.subscribeChildrenFailures((q) => {
662
- const X = q.sourceId === a && $.current !== null ? Ge($.current, q.path) : null;
663
- X !== null && c.announce({ list: s.foldersLoadFailedNamed, item: X.name });
664
- }),
665
- [n, a, c, s]
666
- );
667
- const { clearDirect: U } = i, [ae, W] = C(0), Q = w(() => {
668
- W((q) => q + 1), y(), U(), L(A.current), g();
669
- }, [y, U, g]);
670
- return I(() => {
671
- e({ collapseAll: Q, expandAll: K ? T : null, expanding: M });
672
- }, [e, Q, T, K, M]), I(() => () => e(null), [e]), I(() => {
673
- K || y();
674
- }, [K, y]), /* @__PURE__ */ k(Ve, { children: [
675
- E.state === "stopped" ? /* @__PURE__ */ m(jn, { stop: E.stop, opened: E.opened, budget: O }) : null,
676
- /* @__PURE__ */ k("div", { className: "aqmx-explorer-tree-area", children: [
677
- /* @__PURE__ */ m(Ke, { fallback: /* @__PURE__ */ m(tt, {}), children: /* @__PURE__ */ m(Un, { result: p, onRetry: d, expansion: o, onShown: re, marks: i, claimsHeld: R, expandAll: ne, revealCancel: ae, ...t }) }),
678
- /* @__PURE__ */ m(Vn, { pending: n.pendingChildren(a), status: E })
679
- ] })
680
- ] });
681
- };
682
- function Xn({
683
- title: e,
684
- titleId: t,
685
- ...n
686
- }, r) {
687
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
688
- xmlns: "http://www.w3.org/2000/svg",
689
- viewBox: "0 0 24 24",
690
- fill: "currentColor",
691
- "aria-hidden": "true",
692
- "data-slot": "icon",
693
- ref: r,
694
- "aria-labelledby": t
695
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
696
- id: t
697
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
698
- fillRule: "evenodd",
699
- 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",
700
- clipRule: "evenodd"
701
- }));
702
- }
703
- const nt = /* @__PURE__ */ u.forwardRef(Xn), $e = "markdown-explorer-selection-remove", Gn = ({ selection: e, onRemove: t, onClear: n, onOpenSelection: r, onLeave: s }) => {
704
- const { labels: c } = D(), l = we(), a = v(null), o = [...e], p = (i, f) => {
705
- if (f.ownerDocument.activeElement === f) {
706
- const h = a.current === null ? [] : [...a.current.querySelectorAll(`[data-testid="${$e}"]`)], g = h.indexOf(f), b = [h[g + 1], h[g - 1]].find((L) => L !== void 0);
707
- b === void 0 ? s() : b.focus();
708
- }
709
- t(i);
710
- }, d = () => {
711
- const i = a.current;
712
- i !== null && i.contains(i.ownerDocument.activeElement) && s(), n();
713
- };
714
- return /* @__PURE__ */ k("section", { ref: a, className: "aqmx-explorer-tray", "aria-labelledby": l, "data-testid": "markdown-explorer-selection-tray", children: [
715
- /* @__PURE__ */ k("div", { className: "aqmx-explorer-tray-header", children: [
716
- /* @__PURE__ */ m("p", { id: l, className: "aqmx-explorer-tray-title", children: c.selectionTitle(o.length) }),
717
- /* @__PURE__ */ m("button", { type: "button", className: "aqmx-explorer-tray-button", "data-testid": "markdown-explorer-selection-clear", onClick: d, children: c.clearSelection })
718
- ] }),
719
- /* @__PURE__ */ m("ul", { className: "aqmx-explorer-tray-list", children: o.map(([i, f]) => /* @__PURE__ */ k("li", { className: "aqmx-explorer-tray-item", children: [
720
- /* @__PURE__ */ m("span", { className: "aqmx-explorer-tray-name", title: i, children: f }),
721
- /* @__PURE__ */ m(
722
- "button",
723
- {
724
- type: "button",
725
- className: "aqmx-icon-button aqmx-explorer-tray-remove",
726
- "aria-label": c.removeFromSelection(f),
727
- title: c.removeFromSelection(f),
728
- "data-testid": $e,
729
- "data-aqmx-path": i,
730
- onClick: (h) => p(i, h.currentTarget),
731
- children: /* @__PURE__ */ m(nt, { "aria-hidden": "true" })
732
- }
733
- )
734
- ] }, i)) }),
735
- r === void 0 ? null : /* @__PURE__ */ m("button", { type: "button", className: "aqmx-explorer-tray-open", "data-testid": "markdown-explorer-selection-open", onClick: () => r(o.map(([i]) => i)), children: c.openSelectionInMulti(o.length) })
736
- ] });
737
- }, be = /* @__PURE__ */ new Map(), Yn = (e, t) => {
738
- if (t.selected === e.has(t.path)) return e;
739
- const n = new Map(e);
740
- return t.selected ? n.set(t.path, t.name) : n.delete(t.path), n;
741
- }, Qn = (e, t) => {
742
- if (!e.has(t)) return e;
743
- const n = new Map(e);
744
- return n.delete(t), n;
745
- }, rt = Se(null), Jn = (e) => {
746
- const t = he(rt);
747
- H(() => {
748
- if (t !== null)
749
- return t(e), () => t(!1);
750
- }, [t, e]);
751
- };
752
- function er({
753
- title: e,
754
- titleId: t,
755
- ...n
756
- }, r) {
757
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
758
- xmlns: "http://www.w3.org/2000/svg",
759
- viewBox: "0 0 24 24",
760
- fill: "currentColor",
761
- "aria-hidden": "true",
762
- "data-slot": "icon",
763
- ref: r,
764
- "aria-labelledby": t
765
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
766
- id: t
767
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
768
- fillRule: "evenodd",
769
- 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",
770
- clipRule: "evenodd"
771
- }));
772
- }
773
- const tr = /* @__PURE__ */ u.forwardRef(er);
774
- function nr({
775
- title: e,
776
- titleId: t,
777
- ...n
778
- }, r) {
779
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
780
- xmlns: "http://www.w3.org/2000/svg",
781
- viewBox: "0 0 24 24",
782
- fill: "currentColor",
783
- "aria-hidden": "true",
784
- "data-slot": "icon",
785
- ref: r,
786
- "aria-labelledby": t
787
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
788
- id: t
789
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
790
- fillRule: "evenodd",
791
- 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",
792
- clipRule: "evenodd"
793
- }));
794
- }
795
- const rr = /* @__PURE__ */ u.forwardRef(nr);
796
- function ar({
797
- title: e,
798
- titleId: t,
799
- ...n
800
- }, r) {
801
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
802
- xmlns: "http://www.w3.org/2000/svg",
803
- viewBox: "0 0 24 24",
804
- fill: "currentColor",
805
- "aria-hidden": "true",
806
- "data-slot": "icon",
807
- ref: r,
808
- "aria-labelledby": t
809
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
810
- id: t
811
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
812
- fillRule: "evenodd",
813
- 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",
814
- clipRule: "evenodd"
815
- }));
816
- }
817
- const lr = /* @__PURE__ */ u.forwardRef(ar);
818
- function or({
819
- title: e,
820
- titleId: t,
821
- ...n
822
- }, r) {
823
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
824
- xmlns: "http://www.w3.org/2000/svg",
825
- viewBox: "0 0 24 24",
826
- fill: "currentColor",
827
- "aria-hidden": "true",
828
- "data-slot": "icon",
829
- ref: r,
830
- "aria-labelledby": t
831
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
832
- id: t
833
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
834
- fillRule: "evenodd",
835
- 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",
836
- clipRule: "evenodd"
837
- }));
838
- }
839
- const sr = /* @__PURE__ */ u.forwardRef(or);
840
- function cr({
841
- title: e,
842
- titleId: t,
843
- ...n
844
- }, r) {
845
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
846
- xmlns: "http://www.w3.org/2000/svg",
847
- viewBox: "0 0 24 24",
848
- fill: "currentColor",
849
- "aria-hidden": "true",
850
- "data-slot": "icon",
851
- ref: r,
852
- "aria-labelledby": t
853
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
854
- id: t
855
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
856
- fillRule: "evenodd",
857
- 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",
858
- clipRule: "evenodd"
859
- }));
860
- }
861
- const ir = /* @__PURE__ */ u.forwardRef(cr);
862
- function dr({
863
- title: e,
864
- titleId: t,
865
- ...n
866
- }, r) {
867
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
868
- xmlns: "http://www.w3.org/2000/svg",
869
- viewBox: "0 0 24 24",
870
- fill: "currentColor",
871
- "aria-hidden": "true",
872
- "data-slot": "icon",
873
- ref: r,
874
- "aria-labelledby": t
875
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
876
- id: t
877
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
878
- fillRule: "evenodd",
879
- 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",
880
- clipRule: "evenodd"
881
- }));
882
- }
883
- const ur = /* @__PURE__ */ u.forwardRef(dr);
884
- function mr({
885
- title: e,
886
- titleId: t,
887
- ...n
888
- }, r) {
889
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
890
- xmlns: "http://www.w3.org/2000/svg",
891
- viewBox: "0 0 24 24",
892
- fill: "currentColor",
893
- "aria-hidden": "true",
894
- "data-slot": "icon",
895
- ref: r,
896
- "aria-labelledby": t
897
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
898
- id: t
899
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
900
- fillRule: "evenodd",
901
- 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",
902
- clipRule: "evenodd"
903
- }));
904
- }
905
- const fr = /* @__PURE__ */ u.forwardRef(mr);
906
- function pr({
907
- title: e,
908
- titleId: t,
909
- ...n
910
- }, r) {
911
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
912
- xmlns: "http://www.w3.org/2000/svg",
913
- viewBox: "0 0 24 24",
914
- fill: "currentColor",
915
- "aria-hidden": "true",
916
- "data-slot": "icon",
917
- ref: r,
918
- "aria-labelledby": t
919
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
920
- id: t
921
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
922
- fillRule: "evenodd",
923
- 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",
924
- clipRule: "evenodd"
925
- }), /* @__PURE__ */ u.createElement("path", {
926
- 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"
927
- }));
928
- }
929
- const hr = /* @__PURE__ */ u.forwardRef(pr);
930
- function xr({
931
- title: e,
932
- titleId: t,
933
- ...n
934
- }, r) {
935
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
936
- xmlns: "http://www.w3.org/2000/svg",
937
- viewBox: "0 0 24 24",
938
- fill: "currentColor",
939
- "aria-hidden": "true",
940
- "data-slot": "icon",
941
- ref: r,
942
- "aria-labelledby": t
943
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
944
- id: t
945
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
946
- d: "M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"
947
- }), /* @__PURE__ */ u.createElement("path", {
948
- fillRule: "evenodd",
949
- d: "M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",
950
- clipRule: "evenodd"
951
- }));
952
- }
953
- const wr = /* @__PURE__ */ u.forwardRef(xr);
954
- function gr({
955
- title: e,
956
- titleId: t,
957
- ...n
958
- }, r) {
959
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
960
- xmlns: "http://www.w3.org/2000/svg",
961
- viewBox: "0 0 24 24",
962
- fill: "currentColor",
963
- "aria-hidden": "true",
964
- "data-slot": "icon",
965
- ref: r,
966
- "aria-labelledby": t
967
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
968
- id: t
969
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
970
- 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"
971
- }));
972
- }
973
- const vr = /* @__PURE__ */ u.forwardRef(gr);
974
- function Er({
975
- title: e,
976
- titleId: t,
977
- ...n
978
- }, r) {
979
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
980
- xmlns: "http://www.w3.org/2000/svg",
981
- viewBox: "0 0 24 24",
982
- fill: "currentColor",
983
- "aria-hidden": "true",
984
- "data-slot": "icon",
985
- ref: r,
986
- "aria-labelledby": t
987
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
988
- id: t
989
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
990
- 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"
991
- }));
992
- }
993
- const br = /* @__PURE__ */ u.forwardRef(Er);
994
- function yr({
995
- title: e,
996
- titleId: t,
997
- ...n
998
- }, r) {
999
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
1000
- xmlns: "http://www.w3.org/2000/svg",
1001
- viewBox: "0 0 24 24",
1002
- fill: "currentColor",
1003
- "aria-hidden": "true",
1004
- "data-slot": "icon",
1005
- ref: r,
1006
- "aria-labelledby": t
1007
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
1008
- id: t
1009
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
1010
- fillRule: "evenodd",
1011
- 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",
1012
- clipRule: "evenodd"
1013
- }));
1014
- }
1015
- const Rr = /* @__PURE__ */ u.forwardRef(yr);
1016
- function Sr({
1017
- title: e,
1018
- titleId: t,
1019
- ...n
1020
- }, r) {
1021
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
1022
- xmlns: "http://www.w3.org/2000/svg",
1023
- viewBox: "0 0 24 24",
1024
- fill: "currentColor",
1025
- "aria-hidden": "true",
1026
- "data-slot": "icon",
1027
- ref: r,
1028
- "aria-labelledby": t
1029
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
1030
- id: t
1031
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
1032
- 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"
1033
- }));
1034
- }
1035
- const Tr = /* @__PURE__ */ u.forwardRef(Sr), Ne = (e) => {
1036
- e.preventDefault(), e.stopPropagation();
1037
- }, Nr = Object.freeze({
1038
- sortMode: rr,
1039
- folderPlacement: vr,
1040
- selectionMode: lr,
1041
- doubleClickAction: fr,
1042
- expandIconSize: Rr,
1043
- alwaysExpanded: tr,
1044
- revealDocument: wr,
1045
- removeRootIndent: sr,
1046
- lines: Tr,
1047
- expandIcons: ir,
1048
- directoryIcons: br,
1049
- fileIcons: hr
1050
- }), at = (e, t) => {
1051
- const n = e[t.labelKey];
1052
- 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}`);
1053
- return n;
1054
- }, Lr = ({ id: e, settings: t, descriptors: n, onAdvance: r, onClose: s, ref: c }) => {
1055
- const { labels: l } = D(), a = v([]);
1056
- I(() => {
1057
- a.current[0]?.focus();
1058
- }, []);
1059
- const o = w(
1060
- (d) => {
1061
- const i = n.length;
1062
- a.current[(d % i + i) % i]?.focus();
1063
- },
1064
- [n.length]
1065
- ), p = w(
1066
- (d, i) => {
1067
- switch (d.key) {
1068
- case "ArrowDown":
1069
- d.preventDefault(), o(i + 1);
1070
- break;
1071
- case "ArrowUp":
1072
- d.preventDefault(), o(i - 1);
1073
- break;
1074
- case "Home":
1075
- d.preventDefault(), o(0);
1076
- break;
1077
- case "End":
1078
- d.preventDefault(), o(n.length - 1);
1079
- break;
1080
- case "Escape":
1081
- Ne(d), s();
1082
- break;
1083
- case "Tab":
1084
- s();
1085
- break;
1086
- }
1087
- },
1088
- [n.length, o, s]
1089
- );
1090
- return /* @__PURE__ */ m("div", { ref: c, id: e, role: "menu", "aria-label": l.treeSettings, className: "aqmx-explorer-menu", "data-testid": "markdown-explorer-tree-settings-menu", children: n.map((d, i) => {
1091
- const f = Nr[d.key], h = at(l, d), g = Ue(l, t, d.key), b = t[d.key], L = typeof b == "boolean" ? { role: "menuitemcheckbox", "aria-checked": b, "aria-label": h } : { role: "menuitem", "aria-label": `${h}: ${g}` };
1092
- return /* @__PURE__ */ k(
1093
- "button",
1094
- {
1095
- ref: (R) => {
1096
- a.current[i] = R;
1097
- },
1098
- type: "button",
1099
- tabIndex: -1,
1100
- ...L,
1101
- title: `${h}: ${g}`,
1102
- className: "aqmx-explorer-menu-item",
1103
- "data-testid": "markdown-explorer-tree-settings-item",
1104
- "data-aqmx-setting": d.key,
1105
- onClick: () => r(d),
1106
- onKeyDown: (R) => p(R, i),
1107
- children: [
1108
- /* @__PURE__ */ m(f, { className: "aqmx-explorer-menu-icon", "aria-hidden": "true" }),
1109
- /* @__PURE__ */ m("span", { className: "aqmx-explorer-menu-name", children: h }),
1110
- /* @__PURE__ */ m("span", { className: "aqmx-explorer-menu-value", children: g })
1111
- ]
1112
- },
1113
- d.key
1114
- );
1115
- }) });
1116
- }, kr = ({ settings: e, descriptors: t, onAdvance: n }) => {
1117
- const { labels: r, announcer: s } = D(), [c, l] = C(!1), a = v(null), o = v(null), p = v(null), d = we(), i = w(() => {
1118
- a.current?.focus(), l(!1);
1119
- }, []);
1120
- I(() => {
1121
- if (!c) return;
1122
- const g = (b) => {
1123
- b.target instanceof Node && (a.current?.contains(b.target) === !0 || o.current?.contains(b.target) === !0) || (l(!1), p.current !== null && window.clearTimeout(p.current), p.current = window.setTimeout(() => {
1124
- p.current = null, (document.activeElement === null || document.activeElement === document.body) && a.current?.focus();
1125
- }, 0));
1126
- };
1127
- return document.addEventListener("pointerdown", g), () => document.removeEventListener("pointerdown", g);
1128
- }, [c]), I(
1129
- () => () => {
1130
- p.current !== null && window.clearTimeout(p.current);
1131
- },
1132
- []
1133
- );
1134
- const f = w(
1135
- (g) => {
1136
- g.key !== "Escape" || !c || (Ne(g), i());
1137
- },
1138
- [c, i]
1139
- ), h = w(
1140
- (g) => {
1141
- const b = n(g.key);
1142
- s.announce(r.settingAnnouncement(at(r, g), Ue(r, b, g.key)));
1143
- },
1144
- [s, r, n]
1145
- );
1146
- return {
1147
- trigger: /* @__PURE__ */ m(
1148
- "button",
1149
- {
1150
- ref: a,
1151
- type: "button",
1152
- className: "aqmx-icon-button",
1153
- "aria-haspopup": "menu",
1154
- "aria-expanded": c,
1155
- "aria-controls": c ? d : void 0,
1156
- "aria-label": r.treeSettings,
1157
- title: r.treeSettings,
1158
- "data-testid": "markdown-explorer-tree-settings",
1159
- onClick: () => l((g) => !g),
1160
- onKeyDown: f,
1161
- children: /* @__PURE__ */ m(ur, { "aria-hidden": "true" })
1162
- }
1163
- ),
1164
- menu: c ? /* @__PURE__ */ m(Lr, { ref: o, id: d, settings: e, descriptors: t, onAdvance: h, onClose: i }) : null
1165
- };
1166
- }, Or = () => {
1167
- const { treeSettings: e } = D();
1168
- return { settings: xe(e.subscribe, e.getSnapshot, e.getServerSnapshot), advance: e.advance };
1169
- }, Be = /* @__PURE__ */ new Set(), Pr = '[role="tree"] [role="treeitem"][tabindex="0"]', Ar = "[data-directory-tree-tab-stop]", ta = (e) => {
1170
- const { mode: t, sourceId: n, currentPath: r, openPaths: s, onOpenDocument: c, onSourceChange: l, viewSwitch: a } = e, { labels: o, sources: p, trees: d, documents: i, announcer: f } = D(), { settings: h, advance: g } = Or(), b = F(() => Ot(t === "tree"), [t]), L = t === "tree" && h.selectionMode === "multiple";
1171
- Jn(L);
1172
- const R = e.mode === "tree" ? e.tray.onGatheredChange : null, A = e.mode === "tree" ? e.onOpenSelection : void 0, O = e.mode === "tree" && L ? e.tray.gathered : be, Z = w(
1173
- (N) => {
1174
- const G = g(N);
1175
- return G.selectionMode !== "multiple" && R?.(be), G;
1176
- },
1177
- [g, R]
1178
- ), B = kr({ settings: h, descriptors: b, onAdvance: Z }), S = w((N) => R?.((G) => Yn(G, N)), [R]), E = w((N) => R?.((G) => Qn(G, N)), [R]), T = w(() => R?.(be), [R]), y = v(null), P = w(() => {
1179
- const N = y.current;
1180
- if (N === null) return;
1181
- [Pr, Ar, '[data-testid="markdown-explorer-tree-settings"]'].map((z) => N.querySelector(z)).find((z) => z !== null)?.focus();
1182
- }, []), M = F(() => new Set(O.keys()), [O]), ne = F(() => r === null ? Be : /* @__PURE__ */ new Set([r]), [r]), $ = F(() => {
1183
- if (t === "multi") return { mode: "multiple", items: s, shownPath: null, onChange: null };
1184
- switch (h.selectionMode) {
1185
- case "single":
1186
- return { mode: "single", items: ne, shownPath: r, onChange: null };
1187
- case "multiple":
1188
- return { mode: "multiple", items: M, shownPath: r, onChange: S };
1189
- case "none":
1190
- return { mode: "none", items: Be, shownPath: null, onChange: null };
1191
- }
1192
- }, [t, s, h.selectionMode, ne, r, M, S]), K = F(() => h.revealDocument ? { path: r, openFolders: !0 } : { path: $.shownPath, openFolders: !1 }, [h.revealDocument, r, $.shownPath]), [j, re] = C(null), [U, ae] = C(!1), [W, Q] = C(null), q = v(!1), X = w(async () => {
1193
- if (!q.current) {
1194
- q.current = !0, ae(!0), Q(null);
1195
- try {
1196
- const N = await d.refresh(n);
1197
- if (N.status === "superseded") return;
1198
- i.invalidate(), N.status === "failed" ? Q({ sourceId: n, failure: N.failure }) : f.announce(o.treeRefreshed);
1199
- } finally {
1200
- q.current = !1, ae(!1);
1201
- }
1202
- }
1203
- }, [d, i, n, f, o]), se = j === null ? null : j.expandAll, le = j?.expanding === !0, de = p.find((N) => N.id === n), ce = a.target === "multi" ? Qt : Gt, J = a.target === "multi" ? o.switchToMulti : o.switchToTree;
1204
- return /* @__PURE__ */ k("nav", { ref: y, "aria-label": o.explorerRegion, className: "aqmx-explorer", "data-testid": "markdown-explorer-explorer", "data-aqmx-mode": t, children: [
1205
- /* @__PURE__ */ k("div", { className: "aqmx-explorer-header", children: [
1206
- p.length > 1 ? /* @__PURE__ */ m("select", { className: "aqmx-explorer-source", "aria-label": o.sourceLabel, title: de?.label, value: n, onChange: (N) => l(N.currentTarget.value), "data-testid": "markdown-explorer-source-select", children: p.map((N) => /* @__PURE__ */ m("option", { value: N.id, children: N.label }, N.id)) }) : null,
1207
- /* @__PURE__ */ k("div", { className: "aqmx-explorer-actions", children: [
1208
- /* @__PURE__ */ m(yt, { to: a.href, navigation: "switch-view", className: "aqmx-icon-button", "aria-label": J, title: J, "data-testid": "markdown-explorer-view-switch", "data-aqmx-target": a.target, children: /* @__PURE__ */ m(ce, { "aria-hidden": "true" }) }),
1209
- /* @__PURE__ */ k(
1210
- "button",
1211
- {
1212
- type: "button",
1213
- className: "aqmx-icon-button aqmx-labelled-button",
1214
- title: o.refreshTree,
1215
- "aria-disabled": U,
1216
- "aria-busy": U,
1217
- "data-aqmx-busy": U ? "true" : void 0,
1218
- "data-testid": "markdown-explorer-refresh",
1219
- onClick: () => {
1220
- X();
1221
- },
1222
- children: [
1223
- /* @__PURE__ */ m(Re, { "aria-hidden": "true" }),
1224
- /* @__PURE__ */ m("span", { children: o.refreshTreeLabel })
1225
- ]
1226
- }
1227
- ),
1228
- /* @__PURE__ */ m(
1229
- "button",
1230
- {
1231
- type: "button",
1232
- className: "aqmx-icon-button",
1233
- "aria-label": o.expandAll,
1234
- title: o.expandAll,
1235
- "aria-disabled": se === null || le,
1236
- "aria-busy": le,
1237
- "data-aqmx-busy": le ? "true" : void 0,
1238
- "data-testid": "markdown-explorer-expand-all",
1239
- onClick: () => se?.(),
1240
- children: /* @__PURE__ */ m(Wt, { "aria-hidden": "true" })
1241
- }
1242
- ),
1243
- /* @__PURE__ */ m("button", { type: "button", className: "aqmx-icon-button", "aria-label": o.collapseAll, title: o.collapseAll, "aria-disabled": j === null, "data-testid": "markdown-explorer-collapse-all", onClick: () => j?.collapseAll(), children: /* @__PURE__ */ m(Kt, { "aria-hidden": "true" }) }),
1244
- B.trigger
1245
- ] })
1246
- ] }),
1247
- /* @__PURE__ */ k("div", { className: "aqmx-explorer-body", "data-aqmx-explorer-body": "", children: [
1248
- W !== null && W.sourceId === n ? /* @__PURE__ */ m("p", { role: "alert", className: "aqmx-explorer-refresh-failure", "data-testid": "markdown-explorer-refresh-failure", "data-aqmx-failure": W.failure.reason, children: o.treeRefreshFailed(Rt(o, W.failure.reason)) }) : null,
1249
- /* @__PURE__ */ m(Ke, { fallback: null, children: /* @__PURE__ */ m(Jt, {}) }),
1250
- /* @__PURE__ */ m(Wn, { mode: t, sourceId: n, settings: h, reveal: K, openPaths: s, selection: $, onOpenDocument: c, onControls: re }, n),
1251
- L && O.size > 0 ? /* @__PURE__ */ m(Gn, { selection: O, onRemove: E, onClear: T, onOpenSelection: A, onLeave: P }) : null,
1252
- B.menu
1253
- ] })
1254
- ] });
1255
- }, lt = "(pointer: coarse)", qr = (e) => {
1256
- const t = window.matchMedia(lt);
1257
- return t.addEventListener("change", e), () => t.removeEventListener("change", e);
1258
- }, Cr = () => window.matchMedia(lt).matches, Fr = () => !1, Mr = () => xe(qr, Cr, Fr);
1259
- function _r({
1260
- title: e,
1261
- titleId: t,
1262
- ...n
1263
- }, r) {
1264
- return /* @__PURE__ */ u.createElement("svg", Object.assign({
1265
- xmlns: "http://www.w3.org/2000/svg",
1266
- viewBox: "0 0 24 24",
1267
- fill: "currentColor",
1268
- "aria-hidden": "true",
1269
- "data-slot": "icon",
1270
- ref: r,
1271
- "aria-labelledby": t
1272
- }, n), e ? /* @__PURE__ */ u.createElement("title", {
1273
- id: t
1274
- }, e) : null, /* @__PURE__ */ u.createElement("path", {
1275
- fillRule: "evenodd",
1276
- 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",
1277
- clipRule: "evenodd"
1278
- }));
1279
- }
1280
- const Ir = /* @__PURE__ */ u.forwardRef(_r), Dr = ({ explorer: e, toggleRef: t, covered: n, onNoticeSlotChange: r, dismissals: s }) => {
1281
- const { labels: c } = D(), l = Vt(), { location: a } = St(), [o, p] = C(!1), [d, i] = C({ navigated: l, source: a.source }), [f, h] = C(!1);
1282
- d.navigated !== l && (i({ navigated: l, source: a.source }), d.source === a.source && !f && p(!1));
1283
- const [g, b] = C(s);
1284
- g !== s && (b(s), p(!1));
1285
- const L = v(null), R = v(null), A = v(null), O = v(!1), Z = we();
1286
- H(() => {
1287
- const y = L.current;
1288
- y !== null && (o && !y.open ? (y.showModal(), R.current?.focus()) : !o && y.open && (y.close(), t.current?.focus()), r(o ? A.current : null));
1289
- }, [o, t, r]), H(() => () => r(null), [r]);
1290
- const B = w((y) => {
1291
- y.key !== "Escape" || y.defaultPrevented || (Ne(y), p(!1));
1292
- }, []), S = w((y) => {
1293
- O.current = y.target === y.currentTarget;
1294
- }, []), E = w((y) => {
1295
- const P = O.current;
1296
- O.current = !1, P && y.target === y.currentTarget && p(!1);
1297
- }, []), T = w(() => {
1298
- p(!1);
1299
- }, []);
1300
- return /* @__PURE__ */ k(Ve, { children: [
1301
- /* @__PURE__ */ m("div", { className: "aqmx-sheet-bar", inert: n, children: /* @__PURE__ */ k("button", { ref: t, type: "button", className: "aqmx-sheet-toggle", "aria-haspopup": "dialog", "aria-expanded": o, "aria-controls": Z, "data-testid": "markdown-explorer-sheet-toggle", onClick: () => p(!0), children: [
1302
- /* @__PURE__ */ m(Ir, { "aria-hidden": "true" }),
1303
- /* @__PURE__ */ m("span", { children: c.showExplorer })
1304
- ] }) }),
1305
- /* @__PURE__ */ m("dialog", { ref: L, id: Z, className: "aqmx-sheet", "aria-label": c.explorerRegion, "data-testid": "markdown-explorer-sheet", onKeyDown: B, onPointerDown: S, onClick: E, onClose: T, children: /* @__PURE__ */ k("div", { className: "aqmx-sheet-panel", children: [
1306
- /* @__PURE__ */ k("div", { className: "aqmx-sheet-header", children: [
1307
- /* @__PURE__ */ m("div", { ref: A, className: "aqmx-sheet-notice-slot" }),
1308
- /* @__PURE__ */ m("button", { ref: R, type: "button", className: "aqmx-sheet-close", "aria-label": c.hideExplorer, title: c.hideExplorer, "data-testid": "markdown-explorer-sheet-close", onClick: () => p(!1), children: /* @__PURE__ */ m(nt, { "aria-hidden": "true" }) })
1309
- ] }),
1310
- /* @__PURE__ */ m("div", { className: "aqmx-sheet-body", children: /* @__PURE__ */ m(Te, { value: o, children: /* @__PURE__ */ m(rt, { value: h, children: e }) }) }),
1311
- /* @__PURE__ */ m(Tt, { holds: o, testId: "markdown-explorer-sheet-announcer" })
1312
- ] }) })
1313
- ] });
1314
- }, Hr = Se(null), Le = "aqmx-explorer", ot = "aqmx-content", ke = '[role="tree"] [role="treeitem"]', Zr = `${ke}[tabindex="0"]`, $r = "[data-directory-tree-tab-stop]", Br = (e, t) => {
1315
- for (const n of e.querySelectorAll(`[data-panel-id="${Le}"] ${ke}`)) if (n.getAttribute(oe) === t) return n;
1316
- return null;
1317
- }, ze = (e, t) => ({
1318
- inlineSize: e > 0 ? e : null,
1319
- rootFontPixels: t > 0 ? t : It
1320
- }), zr = (e, t) => {
1321
- const [n, r] = C(() => ze(0, 0));
1322
- return H(() => {
1323
- const s = e.current, c = t.current;
1324
- if (s === null || c === null) throw new Error("[markdown-explorer] the split frame is not mounted");
1325
- const l = { frame: s.getBoundingClientRect().width, rem: c.getBoundingClientRect().width }, a = () => {
1326
- const p = ze(l.frame, l.rem);
1327
- r((d) => d.inlineSize === p.inlineSize && d.rootFontPixels === p.rootFontPixels ? d : p);
1328
- };
1329
- a();
1330
- const o = new ResizeObserver((p) => {
1331
- for (const d of p) {
1332
- const [i] = d.borderBoxSize;
1333
- i !== void 0 && (d.target === s && (l.frame = i.inlineSize), d.target === c && (l.rem = i.inlineSize));
1334
- }
1335
- a();
1336
- });
1337
- return o.observe(s), o.observe(c), () => o.disconnect();
1338
- }, [e, t]), n;
1339
- }, st = (e) => `aqmx-split-handle-${e}`, Vr = (e, { frameRef: t, sheetToggleRef: n, handleId: r }) => {
1340
- const s = v(!1), c = v(null), l = v(!1);
1341
- H(() => {
1342
- const o = t.current;
1343
- if (o === null) throw new Error("[markdown-explorer] the split frame is not mounted");
1344
- const p = (i) => {
1345
- const f = i.target instanceof Element ? i.target : null;
1346
- s.current = f !== null && f.closest(`[data-panel-id="${ot}"]`) === null, !l.current && (c.current = f?.closest(`${ke}[${oe}]`)?.getAttribute(oe) ?? null);
1347
- }, d = (i) => {
1348
- i.relatedTarget instanceof Node && !o.contains(i.relatedTarget) && (s.current = !1);
1349
- };
1350
- return o.addEventListener("focusin", p), o.addEventListener("focusout", d), () => {
1351
- o.removeEventListener("focusin", p), o.removeEventListener("focusout", d);
1352
- };
1353
- }, [t]);
1354
- const a = v(e);
1355
- H(() => {
1356
- if (a.current === e) return;
1357
- a.current = e;
1358
- const o = t.current;
1359
- if (o === null || !s.current) return;
1360
- const p = (d) => {
1361
- const { activeElement: i, body: f } = o.ownerDocument;
1362
- if (i !== null && i !== f) return;
1363
- const h = d.find((g) => g !== null);
1364
- if (h != null) {
1365
- l.current = !0;
1366
- try {
1367
- h.focus();
1368
- } finally {
1369
- l.current = !1;
1370
- }
1371
- }
1372
- };
1373
- if (e) {
1374
- p([n.current]);
1375
- return;
1376
- }
1377
- queueMicrotask(() => {
1378
- if (a.current !== e || !s.current) return;
1379
- const d = c.current, i = `[data-panel-id="${Le}"]`;
1380
- p([
1381
- d === null ? null : Br(o, d),
1382
- o.querySelector(`${i} ${Zr}`),
1383
- o.querySelector(`${i} ${$r}`),
1384
- o.querySelector(`[data-resize-handle-id="${r}"]`)
1385
- ]);
1386
- });
1387
- }, [e, t, n, r]);
1388
- }, na = ({ view: e, explorer: t, content: n, contentCoversPage: r = !1, sheetDismissals: s = 0, onDraggingChange: c }) => {
1389
- const l = v(null), [a, o] = C(null), p = v(null), d = v(null), { inlineSize: i, rootFontPixels: f } = zr(l, p), h = i !== null && i < Pt(f);
1390
- return Vr(h, { frameRef: l, sheetToggleRef: d, handleId: st(e) }), /* @__PURE__ */ k("div", { ref: l, className: "aqmx-split-frame", "data-aqmx-explorer-mode": h ? "sheet" : "split", children: [
1391
- /* @__PURE__ */ m("span", { ref: p, className: "aqmx-rem-probe", "aria-hidden": "true", "data-aqmx-rem-probe": "" }),
1392
- h ? /* @__PURE__ */ m(Dr, { explorer: t, toggleRef: d, covered: r, onNoticeSlotChange: o, dismissals: s }) : null,
1393
- /* @__PURE__ */ m(Hr, { value: h ? a : null, children: /* @__PURE__ */ m(jr, { view: e, sheet: h, explorer: t, content: n, contentCoversPage: r, onDraggingChange: c, explorerMinPixels: At(f) }) })
1394
- ] });
1395
- }, jr = ({
1396
- view: e,
1397
- sheet: t,
1398
- explorer: n,
1399
- content: r,
1400
- contentCoversPage: s,
1401
- onDraggingChange: c,
1402
- explorerMinPixels: l
1403
- }) => {
1404
- const { viewSettings: a, labels: o } = D(), d = Nt((E) => e === "tree" ? E.treeExplorer : E.multiExplorer) ?? (e === "tree" ? Ct : Ft), i = v(null), f = v(null), h = v(!1), g = v(!1), [b, L] = C(!1), R = v(c);
1405
- H(() => {
1406
- R.current = c;
1407
- }, [c]);
1408
- const A = w(() => {
1409
- const E = i.current;
1410
- if (E === null || E.length !== 2) return;
1411
- const [T = 0, y = 0] = E, P = T + y;
1412
- if (P <= 0 || T <= 0) return;
1413
- const M = Math.min(_e, T / P * 100);
1414
- a.update(e === "tree" ? { treeExplorer: M } : { multiExplorer: M });
1415
- }, [a, e]), O = w(() => {
1416
- f.current !== null && clearTimeout(f.current), f.current = setTimeout(() => {
1417
- f.current = null, A();
1418
- }, qt);
1419
- }, [A]);
1420
- I(
1421
- () => () => {
1422
- f.current !== null && clearTimeout(f.current), g.current && R.current?.(!1);
1423
- },
1424
- []
1425
- );
1426
- const Z = Mr(), B = w(
1427
- (E, T) => {
1428
- i.current = E;
1429
- const [y = 0, P = 0] = E;
1430
- E.length === 2 && P > 0 && L(y <= 0), T.source === "keyboard" ? O() : T.source === "pointer" && (h.current = !0);
1431
- },
1432
- [O]
1433
- ), S = w(
1434
- (E) => {
1435
- if (g.current = E, c?.(E), E) {
1436
- h.current = !1;
1437
- return;
1438
- }
1439
- h.current && (h.current = !1, O());
1440
- },
1441
- [c, O]
1442
- );
1443
- return /* @__PURE__ */ k(Bt, { id: `aqmx-split-${e}`, direction: "horizontal", onLayout: B, className: "aqmx-split", "data-aqmx-split": e, children: [
1444
- t ? null : /* @__PURE__ */ m(
1445
- Ie,
1446
- {
1447
- id: Le,
1448
- defaultSize: { value: d, unit: "percentage" },
1449
- minSize: { value: l, unit: "pixels" },
1450
- maxSize: { value: _e, unit: "percentage" },
1451
- collapsible: { from: "end" },
1452
- pixelAdjustPriority: 1,
1453
- inert: s,
1454
- className: "aqmx-split-explorer",
1455
- children: /* @__PURE__ */ m(Te, { value: !b, children: n })
1456
- }
1457
- ),
1458
- t ? null : /* @__PURE__ */ m(
1459
- zt,
1460
- {
1461
- id: st(e),
1462
- thickness: Z ? Mt : _t,
1463
- indicator: { visible: !0, thickness: pe.gripThickness, length: pe.gripLength, barThickness: pe.barThickness, barLength: pe.barLength },
1464
- title: o.resizeExplorer,
1465
- "aria-label": o.resizeExplorer,
1466
- onDragging: S,
1467
- inert: s,
1468
- className: "aqmx-split-handle"
1469
- }
1470
- ),
1471
- /* @__PURE__ */ m(Ie, { id: ot, defaultSize: { value: 100 - d, unit: "percentage" }, contentOverflow: "hidden", className: "aqmx-split-content", ...s ? { style: { isolation: "auto" } } : {}, children: r })
1472
- ] });
1473
- };
1474
- export {
1475
- be as E,
1476
- Hr as S,
1477
- na as a,
1478
- ta as b
1479
- };