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