@aiquants/markdown-explorer 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -1
- package/README.md +53 -16
- package/dist/{ExplorerSplit-DwEFmvQM.js → ExplorerSplit-B7pmzR8t.js} +3 -3
- package/dist/{ExplorerSplit-BESGFcu6.cjs → ExplorerSplit-Bi3yU6NG.cjs} +1 -1
- package/dist/MultiLayout-BxeXOLX1.js +909 -0
- package/dist/MultiLayout-DtFrFRmS.cjs +1 -0
- package/dist/TreeLayout-BQUfVNlA.cjs +1 -0
- package/dist/TreeLayout-D6hCSihW.js +22 -0
- package/dist/core/config.d.cts +8 -0
- package/dist/core/config.d.ts +8 -0
- package/dist/core/labels.d.cts +6 -1
- package/dist/core/labels.d.ts +6 -1
- package/dist/{dataRoute-CKbdwkQ7.cjs → dataRoute-B9Wk-G7A.cjs} +1 -1
- package/dist/{dataRoute-Bkfwfp1R.js → dataRoute-zUX-oR9j.js} +39 -38
- package/dist/{index-BgkZ9ATV.js → index-BJTmp0lR.js} +947 -901
- package/dist/index-DkiGlM7C.cjs +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +13 -13
- package/dist/location-DfYTzfFS.cjs +1 -0
- package/dist/{location-Cb2Ak55B.js → location-V5BKeWNs.js} +189 -162
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +196 -206
- package/dist/server/anonymous.d.cts +2 -2
- package/dist/server/anonymous.d.ts +2 -2
- package/dist/server/ports.d.cts +4 -1
- package/dist/server/ports.d.ts +4 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +631 -603
- package/dist/styles/markdown-explorer.css +1 -1
- package/docs/behavior/dom-hooks.md +4 -4
- package/docs/behavior/layout.md +21 -9
- package/docs/behavior/localization.md +4 -3
- package/docs/behavior/security.md +23 -5
- package/docs/behavior/url-contract.md +8 -2
- package/package.json +5 -5
- package/dist/MultiLayout-DxPiARsv.js +0 -896
- package/dist/MultiLayout-r_qx1Mfz.cjs +0 -1
- package/dist/TreeLayout-9-20bbSM.cjs +0 -1
- package/dist/TreeLayout-CW7lgV_e.js +0 -19
- package/dist/index-y9tVvDW7.cjs +0 -3
- package/dist/location-DWHQYntR.cjs +0 -1
|
@@ -0,0 +1,909 @@
|
|
|
1
|
+
import { jsx as T, jsxs as re } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as je, use as Me, useRef as q, useState as V, useLayoutEffect as F, useMemo as R, useSyncExternalStore as Ye, memo as We, useEffect as $, useCallback as D, useImperativeHandle as Ge } from "react";
|
|
3
|
+
import { g as se, e as Ne, h as Ke, P as Je, j as Xe } from "./location-V5BKeWNs.js";
|
|
4
|
+
import { c as Ze, u as W, e as Qe, f as en, I as nn, D as tn, b as on } from "./index-BJTmp0lR.js";
|
|
5
|
+
import { S as rn, a as ln, b as sn } from "./ExplorerSplit-B7pmzR8t.js";
|
|
6
|
+
import { SCROLL_ROOT_SELECTOR as Q, generateColumnIds as an, sortColumnIds as Ie, generateColumnId as Te, useDragDropColumns as cn, DEFAULT_DEBUG_CONFIG as ge, DragDropLayout as un } from "@aiquants/drag-drop-panels";
|
|
7
|
+
import { v as dn, i as mn } from "./dataRoute-zUX-oR9j.js";
|
|
8
|
+
import { useNavigate as fn, useLocation as pn } from "react-router";
|
|
9
|
+
import { s as gn, r as hn, w as vn } from "./storage-DA4ItHzl.js";
|
|
10
|
+
import { createPortal as wn } from "react-dom";
|
|
11
|
+
const yn = 0xcbf29ce484222325n, xn = 0x100000001b3n, Sn = (1n << 64n) - 1n, En = (1n << 53n) - 1n, bn = new TextEncoder(), Pn = (e) => {
|
|
12
|
+
let n = yn;
|
|
13
|
+
for (const t of bn.encode(e))
|
|
14
|
+
n = (n ^ BigInt(t)) * xn & Sn;
|
|
15
|
+
return Number(n & En);
|
|
16
|
+
}, ee = 256, On = (e) => `aqmx-p-${Pn(e).toString(36)}`, Le = (e, n) => {
|
|
17
|
+
const t = On(e);
|
|
18
|
+
let o = t;
|
|
19
|
+
for (let r = 2; n.has(o); r += 1) o = `${t}-${String(r)}`;
|
|
20
|
+
return o;
|
|
21
|
+
}, Cn = /* @__PURE__ */ new Map(), Mn = (e, n = Cn) => {
|
|
22
|
+
const t = new Set(e.flatMap((r) => n.get(r) ?? [])), o = /* @__PURE__ */ new Map();
|
|
23
|
+
for (const r of e) {
|
|
24
|
+
const l = n.get(r) ?? Le(r, t);
|
|
25
|
+
t.add(l), o.set(r, l);
|
|
26
|
+
}
|
|
27
|
+
return o;
|
|
28
|
+
}, De = (e, n, t) => {
|
|
29
|
+
const o = e.columnOf.get(n);
|
|
30
|
+
return o === void 0 ? void 0 : Math.min(t - 1, Math.max(0, o));
|
|
31
|
+
}, Ae = (e, n) => {
|
|
32
|
+
const [t, ...o] = se(n.logical, n.visible);
|
|
33
|
+
if (t === void 0) throw new RangeError("[markdown-explorer] there must be at least one visible column");
|
|
34
|
+
const r = ([c, f]) => e.slice(c, f).reduce((s, p) => s + p.length, 0);
|
|
35
|
+
let l = t;
|
|
36
|
+
for (const c of o) r(c) < r(l) && (l = c);
|
|
37
|
+
let i = l[0];
|
|
38
|
+
for (let c = l[0]; c < l[1]; c += 1) (e[c]?.length ?? 0) < (e[i]?.length ?? 0) && (i = c);
|
|
39
|
+
return i;
|
|
40
|
+
}, ne = (e, n) => {
|
|
41
|
+
const t = Array.from({ length: n.logical }, () => []), o = [];
|
|
42
|
+
for (const r of e.docs) {
|
|
43
|
+
const l = De(e, r, n.logical);
|
|
44
|
+
l === void 0 ? o.push(r) : t[l]?.push(r);
|
|
45
|
+
}
|
|
46
|
+
for (const r of o) t[Ae(t, n)]?.push(r);
|
|
47
|
+
return t;
|
|
48
|
+
}, Nn = (e, n) => se(e.length, n).map(([t, o]) => e.slice(t, o).flat()), In = (e, n, t) => {
|
|
49
|
+
const [o, r] = n, l = r - o, i = e.length, c = Array.from({ length: l }, (u, g) => {
|
|
50
|
+
const m = [0];
|
|
51
|
+
for (const b of e) m.push((m.at(-1) ?? 0) + (t(b) === o + g ? 1 : 0));
|
|
52
|
+
return m;
|
|
53
|
+
}), f = (u, g, m) => (c[u]?.[m] ?? 0) - (c[u]?.[g] ?? 0), s = Array.from({ length: l + 1 }, () => Array.from({ length: i + 1 }, () => Number.NEGATIVE_INFINITY)), p = Array.from({ length: l + 1 }, () => Array.from({ length: i + 1 }, () => 0)), w = s[0];
|
|
54
|
+
w && (w[0] = 0);
|
|
55
|
+
for (let u = 0; u < l; u += 1)
|
|
56
|
+
for (let g = 0; g <= i; g += 1)
|
|
57
|
+
for (let m = 0; m <= g; m += 1) {
|
|
58
|
+
const b = (s[u]?.[m] ?? Number.NEGATIVE_INFINITY) + f(u, m, g), x = s[u + 1], M = p[u + 1];
|
|
59
|
+
x && M && b > (x[g] ?? Number.NEGATIVE_INFINITY) && (x[g] = b, M[g] = m);
|
|
60
|
+
}
|
|
61
|
+
const O = Array.from({ length: l }, () => []);
|
|
62
|
+
let P = i;
|
|
63
|
+
for (let u = l; u > 0; u -= 1) {
|
|
64
|
+
const g = p[u]?.[P] ?? 0;
|
|
65
|
+
O[u - 1] = e.slice(g, P), P = g;
|
|
66
|
+
}
|
|
67
|
+
return O;
|
|
68
|
+
}, Re = (e, n) => {
|
|
69
|
+
const t = n.flat(), o = new Map(e.columnOf);
|
|
70
|
+
for (const [r, l] of n.entries())
|
|
71
|
+
for (const i of l)
|
|
72
|
+
o.delete(i), o.set(i, r);
|
|
73
|
+
for (const r of o.keys()) {
|
|
74
|
+
if (o.size <= ee) break;
|
|
75
|
+
o.delete(r);
|
|
76
|
+
}
|
|
77
|
+
return { docs: t, columnOf: o };
|
|
78
|
+
}, Tn = (e, n, t, o) => {
|
|
79
|
+
if (e.docs.includes(n)) return { state: e, outcome: "existing" };
|
|
80
|
+
if (e.docs.length >= o) return { state: e, outcome: "rejected" };
|
|
81
|
+
const r = ne(e, t), l = De(e, n, t.logical) ?? Ae(r, t);
|
|
82
|
+
r[l]?.push(n);
|
|
83
|
+
const i = new Map(e.panelIds);
|
|
84
|
+
return i.set(n, Le(n, new Set(i.values()))), { state: { ...e, ...Re(e, r), panelIds: i }, outcome: "opened" };
|
|
85
|
+
}, ke = (e, n) => {
|
|
86
|
+
if (!e.docs.includes(n)) return e;
|
|
87
|
+
const t = new Set(e.hidden);
|
|
88
|
+
t.delete(n);
|
|
89
|
+
const o = new Map(e.panelIds);
|
|
90
|
+
return o.delete(n), { ...e, docs: e.docs.filter((r) => r !== n), hidden: t, panelIds: o, maximized: e.maximized === n ? null : e.maximized };
|
|
91
|
+
}, Ln = (e, n, t, o) => {
|
|
92
|
+
if (e.hidden.has(n)) return { state: ze(e, n, !1), outcome: "shown" };
|
|
93
|
+
if (e.docs.includes(n)) return { state: ke(e, n), outcome: "closed" };
|
|
94
|
+
const r = Tn(e, n, t, o);
|
|
95
|
+
return { state: r.state, outcome: r.outcome === "rejected" ? "rejected" : "opened" };
|
|
96
|
+
}, Dn = (e, n, t) => {
|
|
97
|
+
if (n === t || !e.docs.includes(n)) return { state: e, outcome: "ignored" };
|
|
98
|
+
if (e.docs.includes(t)) return { state: e, outcome: "existing" };
|
|
99
|
+
const o = new Map(e.columnOf), r = o.get(n);
|
|
100
|
+
r !== void 0 && (o.delete(t), o.set(t, r));
|
|
101
|
+
const l = new Set(e.hidden);
|
|
102
|
+
l.delete(n);
|
|
103
|
+
const i = new Map(e.panelIds), c = i.get(n);
|
|
104
|
+
if (c === void 0) throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);
|
|
105
|
+
return i.delete(n), i.set(t, c), {
|
|
106
|
+
state: { docs: e.docs.map((f) => f === n ? t : f), maximized: e.maximized === n ? t : e.maximized, columnOf: o, hidden: l, panelIds: i },
|
|
107
|
+
outcome: "navigated"
|
|
108
|
+
};
|
|
109
|
+
}, ze = (e, n, t) => {
|
|
110
|
+
if (!e.docs.includes(n) || e.hidden.has(n) === t) return e;
|
|
111
|
+
const o = new Set(e.hidden);
|
|
112
|
+
return t ? o.add(n) : o.delete(n), { ...e, hidden: o, maximized: t && e.maximized === n ? null : e.maximized };
|
|
113
|
+
}, An = (e, n) => {
|
|
114
|
+
if (e.maximized === n || n !== null && !e.docs.includes(n)) return e;
|
|
115
|
+
if (n === null || !e.hidden.has(n)) return { ...e, maximized: n };
|
|
116
|
+
const t = new Set(e.hidden);
|
|
117
|
+
return t.delete(n), { ...e, maximized: n, hidden: t };
|
|
118
|
+
}, Rn = (e, n, t) => {
|
|
119
|
+
const o = ne(e, t), r = /* @__PURE__ */ new Map();
|
|
120
|
+
for (const [s, p] of o.entries())
|
|
121
|
+
for (const w of p) r.set(w, s);
|
|
122
|
+
const l = new Set(e.docs), i = /* @__PURE__ */ new Set(), c = se(t.logical, t.visible), f = Array.from({ length: t.logical }, () => []);
|
|
123
|
+
for (const [s, p] of c.entries()) {
|
|
124
|
+
const w = (n[s] ?? []).filter((O) => l.has(O) && !i.has(O));
|
|
125
|
+
for (const O of w) i.add(O);
|
|
126
|
+
for (const [O, P] of In(w, p, (u) => r.get(u)).entries())
|
|
127
|
+
f[p[0] + O]?.push(...P);
|
|
128
|
+
}
|
|
129
|
+
for (const s of e.docs)
|
|
130
|
+
i.has(s) || f[r.get(s) ?? 0]?.push(s);
|
|
131
|
+
return f.every((s, p) => s.length === o[p]?.length && s.every((w, O) => o[p]?.[O] === w)) ? e : { ...e, ...Re(e, f) };
|
|
132
|
+
}, te = (e, n) => {
|
|
133
|
+
const t = [...new Set(e.docs)].slice(0, n), o = new Set(t), r = e.maximized !== null && o.has(e.maximized) ? e.maximized : null;
|
|
134
|
+
return {
|
|
135
|
+
docs: t,
|
|
136
|
+
maximized: r,
|
|
137
|
+
columnOf: e.stored.columnOf,
|
|
138
|
+
hidden: new Set([...e.stored.hidden].filter((l) => o.has(l) && l !== r)),
|
|
139
|
+
panelIds: Mn(t, e.panelIds)
|
|
140
|
+
};
|
|
141
|
+
}, he = (e, n) => {
|
|
142
|
+
if (e.docs.every((o) => e.columnOf.has(o))) return e;
|
|
143
|
+
const t = new Map(e.columnOf);
|
|
144
|
+
for (const [o, r] of ne(e, n).entries())
|
|
145
|
+
for (const l of r)
|
|
146
|
+
t.delete(l), t.set(l, o);
|
|
147
|
+
for (const o of t.keys()) {
|
|
148
|
+
if (t.size <= ee) break;
|
|
149
|
+
t.delete(o);
|
|
150
|
+
}
|
|
151
|
+
return { ...e, columnOf: t };
|
|
152
|
+
}, He = 1, U = Object.freeze({ columnOf: /* @__PURE__ */ new Map(), hidden: /* @__PURE__ */ new Set() }), kn = (e, n) => {
|
|
153
|
+
if (e === null || e === "") return U;
|
|
154
|
+
let t;
|
|
155
|
+
try {
|
|
156
|
+
t = JSON.parse(e);
|
|
157
|
+
} catch {
|
|
158
|
+
return U;
|
|
159
|
+
}
|
|
160
|
+
if (t === null || typeof t != "object" || Array.isArray(t)) return U;
|
|
161
|
+
const o = t;
|
|
162
|
+
if (o.v !== He) return U;
|
|
163
|
+
const r = /* @__PURE__ */ new Map();
|
|
164
|
+
if (Array.isArray(o.columnOf))
|
|
165
|
+
for (const i of o.columnOf.slice(-ee))
|
|
166
|
+
Array.isArray(i) && i.length === 2 && typeof i[0] == "string" && i[0] !== "" && Number.isInteger(i[1]) && i[1] >= 0 && i[1] < n && (r.delete(i[0]), r.set(i[0], i[1]));
|
|
167
|
+
const l = new Set(Array.isArray(o.hidden) ? o.hidden.filter((i) => typeof i == "string" && i !== "") : []);
|
|
168
|
+
return { columnOf: r, hidden: l };
|
|
169
|
+
}, zn = (e) => JSON.stringify({
|
|
170
|
+
v: He,
|
|
171
|
+
columnOf: [...e.columnOf.entries()].slice(-ee),
|
|
172
|
+
hidden: e.docs.filter((n) => e.hidden.has(n))
|
|
173
|
+
}), ie = (e, n) => {
|
|
174
|
+
const t = e.get(n);
|
|
175
|
+
return t === void 0 ? dn(n) : t;
|
|
176
|
+
}, G = (e) => {
|
|
177
|
+
const n = /* @__PURE__ */ new Map();
|
|
178
|
+
for (const [t, o] of e.panelIds) n.set(o, t);
|
|
179
|
+
return n;
|
|
180
|
+
}, ve = (e) => {
|
|
181
|
+
if (!mn(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(e.slice(0, 80))}`);
|
|
182
|
+
}, Hn = ({ config: e, location: n, writeUrl: t, persist: o }) => {
|
|
183
|
+
const { maxPanels: r, columns: l } = e.multiView, i = Ze(), c = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
184
|
+
let s = {
|
|
185
|
+
layout: te({ docs: n.docs, maximized: n.maximized, stored: U }, r),
|
|
186
|
+
source: n.source,
|
|
187
|
+
visibleColumns: l,
|
|
188
|
+
ready: !1,
|
|
189
|
+
splitDragging: !1,
|
|
190
|
+
titles: /* @__PURE__ */ new Map(),
|
|
191
|
+
pendingHashes: /* @__PURE__ */ new Map()
|
|
192
|
+
}, p = !1;
|
|
193
|
+
const w = (a) => p ? he(a, { logical: l, visible: s.visibleColumns }) : a, O = (a, v) => Ne(e, { view: "multi", source: a, docs: v.docs, maximized: v.maximized });
|
|
194
|
+
let P = O(n.source, n), u = n.source, g = P;
|
|
195
|
+
const m = [], b = [];
|
|
196
|
+
let x = null;
|
|
197
|
+
const M = () => {
|
|
198
|
+
if (!(m.length > 0))
|
|
199
|
+
for (const a of b.splice(0)) a();
|
|
200
|
+
}, d = (a) => {
|
|
201
|
+
s = { ...s, ...a }, i.emit();
|
|
202
|
+
}, S = () => {
|
|
203
|
+
if (!s.ready) return;
|
|
204
|
+
const a = zn(s.layout);
|
|
205
|
+
a !== x && (x = a, o(a));
|
|
206
|
+
}, h = (a, v, C) => {
|
|
207
|
+
const L = O(a, v);
|
|
208
|
+
L !== P && (P = L, u = a, m.push(L), t(L, C));
|
|
209
|
+
}, N = (a) => {
|
|
210
|
+
const v = new Set(a.panelIds.values());
|
|
211
|
+
for (const E of [...c.keys()]) v.has(E) || c.delete(E);
|
|
212
|
+
for (const E of [...f.keys()]) v.has(E) || f.delete(E);
|
|
213
|
+
const C = new Set(a.docs), L = [...s.titles.keys()].every((E) => C.has(E)) ? s.titles : new Map([...s.titles].filter(([E]) => C.has(E))), y = [...s.pendingHashes.keys()].every((E) => v.has(E)) ? s.pendingHashes : new Map([...s.pendingHashes].filter(([E]) => v.has(E)));
|
|
214
|
+
return { titles: L, pendingHashes: y };
|
|
215
|
+
}, I = (a) => a === s.layout ? !1 : (d({ layout: a, ...N(a) }), h(u, a, "replace"), S(), !0), z = () => ({ logical: l, visible: s.visibleColumns });
|
|
216
|
+
return {
|
|
217
|
+
getSnapshot: () => s,
|
|
218
|
+
subscribe: i.subscribe,
|
|
219
|
+
toggle: (a) => {
|
|
220
|
+
ve(a);
|
|
221
|
+
const { state: v, outcome: C } = Ln(s.layout, a, z(), r);
|
|
222
|
+
return I(v), C;
|
|
223
|
+
},
|
|
224
|
+
close: (a) => I(ke(s.layout, a)),
|
|
225
|
+
navigate: (a, v) => {
|
|
226
|
+
ve(v);
|
|
227
|
+
const { state: C, outcome: L } = Dn(s.layout, a, v);
|
|
228
|
+
if (L !== "navigated") return L;
|
|
229
|
+
const y = C.panelIds.get(v);
|
|
230
|
+
return y !== void 0 && (c.delete(y), f.delete(y)), I(C), L;
|
|
231
|
+
},
|
|
232
|
+
setHidden: (a, v) => I(ze(s.layout, a, v)),
|
|
233
|
+
maximize: (a) => I(An(s.layout, a)),
|
|
234
|
+
arrange: (a) => I(Rn(s.layout, a, { logical: l, visible: a.length })),
|
|
235
|
+
changeSource: (a) => {
|
|
236
|
+
h(a, s.layout, "push");
|
|
237
|
+
},
|
|
238
|
+
observeLocation: (a) => {
|
|
239
|
+
const v = O(a.source, a);
|
|
240
|
+
if (v === P)
|
|
241
|
+
return m.length = 0, g = v, a.source !== s.source && d({ source: a.source }), M(), !1;
|
|
242
|
+
if (v === g) return !1;
|
|
243
|
+
g = v;
|
|
244
|
+
const C = m.indexOf(v);
|
|
245
|
+
if (C >= 0)
|
|
246
|
+
return m.splice(0, C + 1), a.source !== s.source && d({ source: a.source }), M(), !1;
|
|
247
|
+
m.length = 0, P = v, u = a.source;
|
|
248
|
+
const L = w(te({ docs: a.docs, maximized: a.maximized, stored: { columnOf: s.layout.columnOf, hidden: s.layout.hidden }, panelIds: s.layout.panelIds }, r));
|
|
249
|
+
return d({ layout: L, source: a.source, ...N(L) }), S(), M(), !0;
|
|
250
|
+
},
|
|
251
|
+
whenUrlRendered: (a) => {
|
|
252
|
+
b.push(a), M();
|
|
253
|
+
},
|
|
254
|
+
loadStored: (a) => {
|
|
255
|
+
d({ layout: w(te({ docs: s.layout.docs, maximized: s.layout.maximized, stored: a, panelIds: s.layout.panelIds }, r)), ready: !0 }), S();
|
|
256
|
+
},
|
|
257
|
+
setVisibleColumns: (a) => {
|
|
258
|
+
if (!Number.isInteger(a) || a < 1 || a > l) throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(l)}; got ${String(a)}`);
|
|
259
|
+
p = !0;
|
|
260
|
+
const v = he(s.layout, { logical: l, visible: a });
|
|
261
|
+
a === s.visibleColumns && v === s.layout || (d({ visibleColumns: a, layout: v }), v !== s.layout && S());
|
|
262
|
+
},
|
|
263
|
+
setSplitDragging: (a) => {
|
|
264
|
+
a !== s.splitDragging && d({ splitDragging: a });
|
|
265
|
+
},
|
|
266
|
+
setTitle: (a, v) => {
|
|
267
|
+
!s.layout.docs.includes(a) || s.titles.get(a) === v || d({ titles: new Map(s.titles).set(a, v) });
|
|
268
|
+
},
|
|
269
|
+
titleOf: (a) => ie(s.titles, a),
|
|
270
|
+
setPendingHash: (a, v) => {
|
|
271
|
+
const C = s.pendingHashes.get(a);
|
|
272
|
+
if (v === null || v === "") {
|
|
273
|
+
if (C === void 0) return;
|
|
274
|
+
const L = new Map(s.pendingHashes);
|
|
275
|
+
L.delete(a), d({ pendingHashes: L });
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
C !== v && d({ pendingHashes: new Map(s.pendingHashes).set(a, v) });
|
|
279
|
+
},
|
|
280
|
+
saveReadingPosition: (a, v, C) => {
|
|
281
|
+
s.layout.panelIds.get(v) === a && c.set(a, { doc: v, position: C });
|
|
282
|
+
},
|
|
283
|
+
readingPositionOf: (a, v) => {
|
|
284
|
+
const C = c.get(a);
|
|
285
|
+
return C === void 0 || C.doc !== v ? null : C.position;
|
|
286
|
+
},
|
|
287
|
+
saveImageView: (a, v, C) => {
|
|
288
|
+
f.set(a, { url: v, state: C });
|
|
289
|
+
},
|
|
290
|
+
imageViewOf: (a, v) => {
|
|
291
|
+
const C = f.get(a);
|
|
292
|
+
return C === void 0 || C.url !== v ? null : C.state;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
}, _n = () => {
|
|
296
|
+
const e = /* @__PURE__ */ new Map();
|
|
297
|
+
return {
|
|
298
|
+
hold: (n, t) => {
|
|
299
|
+
e.set(n, t), queueMicrotask(() => {
|
|
300
|
+
e.get(n) === t && e.delete(n);
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
take: (n) => {
|
|
304
|
+
const t = e.get(n);
|
|
305
|
+
return e.delete(n), t === void 0 ? null : t;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}, _e = je(null), ae = () => {
|
|
309
|
+
const e = Me(_e);
|
|
310
|
+
if (e === null) throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");
|
|
311
|
+
return e;
|
|
312
|
+
}, qn = (e, n) => {
|
|
313
|
+
const t = e.pendingHashes.get(n);
|
|
314
|
+
return t === void 0 ? null : t;
|
|
315
|
+
}, ce = "data-aqmx-column-probe", J = "data-panel-id", le = "--aqmx-multi-panel-chrome", B = (e) => e.endsWith("px") ? Number.parseFloat(e) : Number.NaN, Fn = (e) => e === "normal" ? 0 : B(e), Bn = (e, n) => {
|
|
316
|
+
const t = e.querySelector(Q)?.firstElementChild, o = e.querySelector(`[${ce}]`), r = o instanceof HTMLElement ? o.getBoundingClientRect().width : Number.NaN;
|
|
317
|
+
if (!(t instanceof HTMLElement))
|
|
318
|
+
return { plan: { trackInlineSize: Number.NaN, gap: Number.NaN, minColumnInlineSize: r, logicalColumns: n }, stageBlockSize: Number.NaN };
|
|
319
|
+
const l = getComputedStyle(t), i = t.clientWidth - B(l.paddingLeft) - B(l.paddingRight), c = t.clientHeight - B(l.paddingTop) - B(l.paddingBottom);
|
|
320
|
+
return { plan: { trackInlineSize: i, gap: Fn(l.columnGap), minColumnInlineSize: r, logicalColumns: n }, stageBlockSize: c };
|
|
321
|
+
}, Vn = (e, n) => {
|
|
322
|
+
if (e.getClientRects().length === 0) return Number.NaN;
|
|
323
|
+
const t = getComputedStyle(e);
|
|
324
|
+
return n.getBoundingClientRect().top - e.getBoundingClientRect().top + B(t.paddingBottom) + B(t.borderBottomWidth);
|
|
325
|
+
}, k = (e, n) => {
|
|
326
|
+
const t = () => n(e.getSnapshot());
|
|
327
|
+
return Ye(e.subscribe, t, t);
|
|
328
|
+
}, $n = (e) => {
|
|
329
|
+
const { config: n, storageNamespace: t } = W(), o = fn(), r = q(o), l = gn(t).multiLayout, [i] = V(
|
|
330
|
+
() => Hn({
|
|
331
|
+
config: n,
|
|
332
|
+
location: e,
|
|
333
|
+
writeUrl: (s, p) => {
|
|
334
|
+
r.current(s, Qe(p === "replace" ? "browse" : "switch-source"));
|
|
335
|
+
},
|
|
336
|
+
persist: (s) => vn(l, s)
|
|
337
|
+
})
|
|
338
|
+
);
|
|
339
|
+
F(() => {
|
|
340
|
+
r.current = o;
|
|
341
|
+
}, [o]);
|
|
342
|
+
const c = pn(), f = R(() => ({ location: e, navigated: c }), [e, c]);
|
|
343
|
+
return F(() => {
|
|
344
|
+
i.observeLocation(f.location);
|
|
345
|
+
}, [i, f]), F(() => {
|
|
346
|
+
i.loadStored(kn(hn(l), n.multiView.columns));
|
|
347
|
+
}, [i, l, n]), i;
|
|
348
|
+
}, qe = "[data-aqdd-scroll-area]", X = "data-aqmx-panel-frame", we = "--aqmx-multi-panel-pinned-block-size", Un = (e) => {
|
|
349
|
+
const { docPath: n, panelId: t } = e;
|
|
350
|
+
if (typeof n != "string" || typeof t != "string") throw new TypeError("[markdown-explorer] a multi-view panel needs string docPath and panelId props");
|
|
351
|
+
return { docPath: n, panelId: t };
|
|
352
|
+
}, jn = (e) => {
|
|
353
|
+
const n = getComputedStyle(e), t = Number.parseFloat(n.lineHeight);
|
|
354
|
+
return Number.isFinite(t) ? t : Number.parseFloat(n.fontSize);
|
|
355
|
+
}, Yn = (e, n, t) => e.deltaMode === WheelEvent.DOM_DELTA_PAGE ? e.deltaY * n.clientHeight : e.deltaMode !== WheelEvent.DOM_DELTA_LINE ? e.deltaY : e.deltaY * t(n), j = (e) => {
|
|
356
|
+
const n = e.closest(qe);
|
|
357
|
+
return n instanceof HTMLElement ? n : null;
|
|
358
|
+
}, Fe = (e) => {
|
|
359
|
+
const n = e.firstElementChild;
|
|
360
|
+
return n instanceof HTMLElement && getComputedStyle(n).position === "sticky" ? n : null;
|
|
361
|
+
}, Be = (e, n) => {
|
|
362
|
+
const t = n.getBoundingClientRect().top, o = Fe(e);
|
|
363
|
+
return o === null ? t : Math.max(t, o.getBoundingClientRect().bottom);
|
|
364
|
+
}, ye = (e, n) => {
|
|
365
|
+
let t = 0, o = e.length;
|
|
366
|
+
for (; t < o; ) {
|
|
367
|
+
const r = t + o >>> 1;
|
|
368
|
+
(e[r]?.getBoundingClientRect().bottom ?? Number.NEGATIVE_INFINITY) > n ? o = r : t = r + 1;
|
|
369
|
+
}
|
|
370
|
+
return t < e.length ? t : -1;
|
|
371
|
+
}, Wn = (e, n) => {
|
|
372
|
+
const t = Be(e, n), o = [];
|
|
373
|
+
let r = e;
|
|
374
|
+
for (let l = ye([...r.children], t); l >= 0; l = ye([...r.children], t)) {
|
|
375
|
+
const i = r.children[l];
|
|
376
|
+
if (i === void 0) break;
|
|
377
|
+
o.push(l), r = i;
|
|
378
|
+
}
|
|
379
|
+
return { scrollTop: n.scrollTop, anchor: o.length === 0 ? null : { path: o, offset: r.getBoundingClientRect().top - t } };
|
|
380
|
+
}, xe = (e, n, t) => {
|
|
381
|
+
if (n.scrollTop = t.scrollTop, t.anchor === null) return;
|
|
382
|
+
let o = e;
|
|
383
|
+
for (const r of t.anchor.path) o = o?.children[r];
|
|
384
|
+
o !== void 0 && (n.scrollTop += o.getBoundingClientRect().top - Be(e, n) - t.anchor.offset);
|
|
385
|
+
}, Gn = Object.freeze(["data-testid", "aria-label", "title", "href", "id", "name"]), Ve = (e) => JSON.stringify([e.tagName, ...Gn.map((n) => e.getAttribute(n))]), Kn = (e, n) => {
|
|
386
|
+
if (n === null || !e.contains(n)) return null;
|
|
387
|
+
const t = [];
|
|
388
|
+
for (let o = n; o !== e; ) {
|
|
389
|
+
const r = o.parentElement;
|
|
390
|
+
if (r === null) return null;
|
|
391
|
+
t.unshift([...r.children].indexOf(o)), o = r;
|
|
392
|
+
}
|
|
393
|
+
return { path: t, signature: Ve(n) };
|
|
394
|
+
}, Jn = (e, n, t) => {
|
|
395
|
+
let o = e;
|
|
396
|
+
for (const r of t.path) o = o?.children[r];
|
|
397
|
+
o instanceof HTMLElement && Ve(o) === t.signature && en(o) || n.focus({ preventScroll: !0 });
|
|
398
|
+
}, Xn = (e, n, t) => {
|
|
399
|
+
if (e.shiftKey || Math.abs(e.deltaX) > Math.abs(e.deltaY)) return;
|
|
400
|
+
const o = e.ctrlKey || e.metaKey, r = o ? j(n) : n.closest(Q);
|
|
401
|
+
if (!(r instanceof HTMLElement)) return;
|
|
402
|
+
const l = Yn(e, r, t);
|
|
403
|
+
(o || Zn(r, l)) && (e.preventDefault(), r.scrollTop += l);
|
|
404
|
+
}, Zn = (e, n) => n < 0 ? e.scrollTop > 0 : n > 0 ? Math.ceil(e.scrollTop + e.clientHeight) < e.scrollHeight : !1, Qn = (e) => e.scrollHeight > e.clientHeight, et = (e, n, t) => {
|
|
405
|
+
let o = Number.NaN, r = Number.NaN;
|
|
406
|
+
const l = Fe(t), i = () => {
|
|
407
|
+
const s = Vn(e, n);
|
|
408
|
+
if (!Number.isFinite(s)) return;
|
|
409
|
+
const p = l === null ? 0 : l.getBoundingClientRect().height;
|
|
410
|
+
p !== r && (r = p, t.style.setProperty(we, `${String(p)}px`));
|
|
411
|
+
const w = s + p;
|
|
412
|
+
w !== o && (o = w, e.style.setProperty(le, `${String(w)}px`));
|
|
413
|
+
};
|
|
414
|
+
i();
|
|
415
|
+
let c = null;
|
|
416
|
+
const f = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
|
|
417
|
+
c === null && (c = requestAnimationFrame(() => {
|
|
418
|
+
c = null, i();
|
|
419
|
+
}));
|
|
420
|
+
});
|
|
421
|
+
return f?.observe(e), f?.observe(n), l !== null && f?.observe(l), () => {
|
|
422
|
+
f?.disconnect(), c !== null && cancelAnimationFrame(c), e.style.removeProperty(le), t.style.removeProperty(we);
|
|
423
|
+
};
|
|
424
|
+
}, nt = (e) => {
|
|
425
|
+
const { docPath: n, panelId: t } = Un(e), { store: o, Body: r, maximize: l, focusCarry: i } = ae(), c = k(o, (u) => u.layout.maximized === n), f = k(o, (u) => ie(u.titles, n)), s = q(null), p = q(null), w = q(null);
|
|
426
|
+
$(() => {
|
|
427
|
+
const u = s.current, g = u === null ? null : j(u);
|
|
428
|
+
if (u === null || g === null || c) return;
|
|
429
|
+
const m = /* @__PURE__ */ new Map(), b = (h) => {
|
|
430
|
+
const N = m.get(h);
|
|
431
|
+
if (N !== void 0) return N;
|
|
432
|
+
const I = jn(h);
|
|
433
|
+
return m.set(h, I), I;
|
|
434
|
+
}, x = (h) => Xn(h, u, b);
|
|
435
|
+
let M = !1;
|
|
436
|
+
const d = () => {
|
|
437
|
+
const h = Qn(g);
|
|
438
|
+
h !== M && (M = h, h ? u.addEventListener("wheel", x, { capture: !0, passive: !1 }) : u.removeEventListener("wheel", x, { capture: !0 }));
|
|
439
|
+
};
|
|
440
|
+
d();
|
|
441
|
+
const S = typeof ResizeObserver > "u" ? null : new ResizeObserver(d);
|
|
442
|
+
return S?.observe(g), S?.observe(u), () => {
|
|
443
|
+
S?.disconnect(), u.removeEventListener("wheel", x, { capture: !0 });
|
|
444
|
+
};
|
|
445
|
+
}, [c]), F(() => {
|
|
446
|
+
const u = s.current, g = u === null ? null : j(u), m = u === null ? null : u.closest(`[${J}]`);
|
|
447
|
+
if (!(u === null || g === null || !(m instanceof HTMLElement)))
|
|
448
|
+
return et(m, g, u);
|
|
449
|
+
}, []), F(() => {
|
|
450
|
+
const u = s.current, g = u === null ? null : j(u);
|
|
451
|
+
if (u === null || g === null) return;
|
|
452
|
+
const m = o.readingPositionOf(t, n);
|
|
453
|
+
p.current = m === null ? null : { doc: n, position: m }, m !== null && xe(u, g, m);
|
|
454
|
+
let b = null;
|
|
455
|
+
const x = () => {
|
|
456
|
+
b === null && (b = requestAnimationFrame(() => {
|
|
457
|
+
b = null;
|
|
458
|
+
const M = w.current;
|
|
459
|
+
M !== null && o.saveReadingPosition(t, M, Wn(u, g));
|
|
460
|
+
}));
|
|
461
|
+
};
|
|
462
|
+
return g.addEventListener("scroll", x, { passive: !0 }), () => {
|
|
463
|
+
g.removeEventListener("scroll", x), b !== null && cancelAnimationFrame(b);
|
|
464
|
+
};
|
|
465
|
+
}, [o, t, n]), F(() => {
|
|
466
|
+
const u = s.current, g = u === null ? null : u.closest(`[${J}]`);
|
|
467
|
+
if (u === null || g === null) return;
|
|
468
|
+
const m = i.take(t);
|
|
469
|
+
return m !== null && Jn(g, u, m), () => {
|
|
470
|
+
const b = Kn(g, g.ownerDocument.activeElement);
|
|
471
|
+
b !== null && i.hold(t, b);
|
|
472
|
+
};
|
|
473
|
+
}, [i, t]);
|
|
474
|
+
const O = D((u) => {
|
|
475
|
+
const g = s.current, m = g === null ? null : j(g);
|
|
476
|
+
if (g === null || m === null) return;
|
|
477
|
+
const b = w.current;
|
|
478
|
+
w.current = u;
|
|
479
|
+
const x = p.current;
|
|
480
|
+
p.current = null, x !== null && x.doc === u ? xe(g, m, x.position) : b !== null && b !== u && (m.scrollTop = 0);
|
|
481
|
+
}, []), P = D(() => l(n), [l, n]);
|
|
482
|
+
return (
|
|
483
|
+
/* @__PURE__ */ T(
|
|
484
|
+
"div",
|
|
485
|
+
{
|
|
486
|
+
ref: s,
|
|
487
|
+
role: "group",
|
|
488
|
+
"aria-label": f,
|
|
489
|
+
className: "aqmx-multi-panel-frame",
|
|
490
|
+
tabIndex: -1,
|
|
491
|
+
"data-aqmx-panel-frame": t,
|
|
492
|
+
"data-aqmx-maximized": c ? "true" : "false",
|
|
493
|
+
"data-testid": "markdown-explorer-panel-frame",
|
|
494
|
+
onDoubleClick: c ? void 0 : P,
|
|
495
|
+
children: /* @__PURE__ */ T(r, { docPath: n, panelId: t, maximized: c, title: f, onContentShown: O })
|
|
496
|
+
}
|
|
497
|
+
)
|
|
498
|
+
);
|
|
499
|
+
}, tt = We(nt), ot = (e) => {
|
|
500
|
+
const n = e.closest(qe);
|
|
501
|
+
if (n === null) throw new Error("[markdown-explorer] a panel's document region is not inside the panel's scroll area");
|
|
502
|
+
return n;
|
|
503
|
+
}, rt = ({ docPath: e, panelId: n, maximized: t, title: o, onContentShown: r }) => {
|
|
504
|
+
const { store: l, followLink: i, revealInPanel: c } = ae(), { announcer: f } = W(), s = k(l, (x) => qn(x, n)), p = D((x, M) => i(n, e, x, M), [i, n, e]), w = D(() => l.setPendingHash(n, null), [l, n]), O = R(() => ({ read: (x) => l.imageViewOf(n, x), save: (x, M) => l.saveImageView(n, x, M) }), [l, n]), P = D(
|
|
505
|
+
(x, M) => {
|
|
506
|
+
M.kind !== "failure" && l.setTitle(x, M.name), r(x);
|
|
507
|
+
},
|
|
508
|
+
[l, r]
|
|
509
|
+
), u = D(
|
|
510
|
+
(x) => {
|
|
511
|
+
l.whenUrlRendered(() => f.announce(x));
|
|
512
|
+
},
|
|
513
|
+
[l, f]
|
|
514
|
+
), g = R(() => ({ scrollerOf: ot, reveal: (x) => c(n, x) }), [c, n]), m = R(
|
|
515
|
+
() => ({ kind: "panel", maximized: t, onDocumentLink: p, pendingHash: s, onHashConsumed: w, announceFailure: u, paneScroll: g }),
|
|
516
|
+
[t, p, s, w, u, g]
|
|
517
|
+
), b = R(() => ({ kind: "panel", documentName: o }), [o]);
|
|
518
|
+
return /* @__PURE__ */ re(nn, { value: O, children: [
|
|
519
|
+
/* @__PURE__ */ T(tn, { path: e, placement: b }),
|
|
520
|
+
/* @__PURE__ */ T(on, { path: e, variant: m, onDocumentShown: P })
|
|
521
|
+
] });
|
|
522
|
+
}, Se = () => typeof HTMLElement < "u" && typeof HTMLElement.prototype.showPopover == "function" && typeof HTMLElement.prototype.hidePopover == "function", K = (e, n) => {
|
|
523
|
+
const t = e.panelIds.get(n);
|
|
524
|
+
if (t === void 0) throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);
|
|
525
|
+
return t;
|
|
526
|
+
}, Ee = (e) => Object.fromEntries(an(e).map((n) => [n, []])), lt = (e, n) => {
|
|
527
|
+
const t = Nn(ne(e, n), n.visible);
|
|
528
|
+
return Object.fromEntries(t.map((o, r) => [Te(r), o.map((l) => K(e, l))]));
|
|
529
|
+
}, st = (e, n) => {
|
|
530
|
+
const t = G(e);
|
|
531
|
+
return Ie(Object.keys(n)).map(
|
|
532
|
+
(o) => (n[o] ?? []).flatMap((r) => {
|
|
533
|
+
const l = t.get(r);
|
|
534
|
+
return l === void 0 ? [] : [l];
|
|
535
|
+
})
|
|
536
|
+
);
|
|
537
|
+
}, it = (e) => ({
|
|
538
|
+
switchToCustomDragMode: e.panelSwitchToCustomDrag,
|
|
539
|
+
switchToNormalDragMode: e.panelSwitchToNormalDrag,
|
|
540
|
+
hidePanel: e.panelHide,
|
|
541
|
+
maximizePanel: e.panelMaximize,
|
|
542
|
+
restorePanel: e.panelRestore,
|
|
543
|
+
closePanel: e.panelClose,
|
|
544
|
+
movePanelToPreviousColumn: e.panelMovePreviousColumn,
|
|
545
|
+
movePanelToNextColumn: e.panelMoveNextColumn,
|
|
546
|
+
movePanelUp: e.panelMoveUp,
|
|
547
|
+
movePanelDown: e.panelMoveDown,
|
|
548
|
+
customDragModeBadge: e.panelCustomDragBadge,
|
|
549
|
+
panelMoved: e.panelMoved,
|
|
550
|
+
panelMoveUnavailable: e.panelMoveUnavailable,
|
|
551
|
+
panelDragStarted: e.panelDragStarted,
|
|
552
|
+
panelDragCancelled: e.panelDragCancelled,
|
|
553
|
+
hiddenPanels: e.hiddenPanelsTitle,
|
|
554
|
+
hiddenPanelBadge: e.hiddenPanelBadge,
|
|
555
|
+
hiddenPanelNotice: e.hiddenPanelNotice,
|
|
556
|
+
emptyColumn: e.multiColumnEmpty,
|
|
557
|
+
dropZone: e.multiColumnRegion,
|
|
558
|
+
dropHere: e.panelDropHere
|
|
559
|
+
}), ue = "--aqmx-stage-block", at = "--aqmx-multi-panel-body-floor", ct = `calc(var(${ue}) * ${String(Xe)})`, ut = `max(calc(var(${ue}) * ${String(Je)}), calc(var(${le}) + var(${at})))`, dt = (e, n) => {
|
|
560
|
+
const t = Object.entries(e);
|
|
561
|
+
return t.length !== Object.keys(n).length ? !1 : t.every(([o, r]) => {
|
|
562
|
+
const l = n[o];
|
|
563
|
+
return l !== void 0 && l.length === r.length && l.every((i, c) => r[c] === i);
|
|
564
|
+
});
|
|
565
|
+
}, be = ["keydown", "pointerdown", "wheel", "touchstart"], Y = /* @__PURE__ */ new WeakMap(), Pe = (e, n, t) => {
|
|
566
|
+
for (let o = n; o !== null && o !== t; o = o.parentElement) {
|
|
567
|
+
e.observe(o);
|
|
568
|
+
for (let r = o.previousElementSibling; r !== null; r = r.previousElementSibling) e.observe(r);
|
|
569
|
+
}
|
|
570
|
+
}, mt = (e) => {
|
|
571
|
+
const n = /* @__PURE__ */ new Map();
|
|
572
|
+
for (let t = e.parentElement; t !== null; t = t.parentElement) n.set(t, { top: t.scrollTop, left: t.scrollLeft });
|
|
573
|
+
return n;
|
|
574
|
+
}, Z = (e, n, t) => {
|
|
575
|
+
Y.get(e)?.();
|
|
576
|
+
const o = e.querySelector(`[${J}="${n}"]`);
|
|
577
|
+
if (!(o instanceof HTMLElement)) return;
|
|
578
|
+
const r = t !== null && o.contains(t) ? t : null;
|
|
579
|
+
let l = /* @__PURE__ */ new Map();
|
|
580
|
+
const i = () => {
|
|
581
|
+
if (!o.isConnected) return;
|
|
582
|
+
o.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "instant" });
|
|
583
|
+
const w = r?.isConnected === !0 ? r : o;
|
|
584
|
+
w !== o && w.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "instant" }), l = mt(w);
|
|
585
|
+
};
|
|
586
|
+
if (i(), typeof ResizeObserver > "u") return;
|
|
587
|
+
const c = new ResizeObserver(i);
|
|
588
|
+
Pe(c, o, o.closest(Q)), r !== null && Pe(c, r, o);
|
|
589
|
+
const { ownerDocument: f } = e, s = (w) => {
|
|
590
|
+
const O = w.target === f ? f.scrollingElement : w.target;
|
|
591
|
+
if (!(O instanceof Element)) return;
|
|
592
|
+
const P = l.get(O);
|
|
593
|
+
P !== void 0 && (O.scrollTop !== P.top || O.scrollLeft !== P.left) && p();
|
|
594
|
+
}, p = () => {
|
|
595
|
+
c.disconnect();
|
|
596
|
+
for (const w of be) f.removeEventListener(w, p, !0);
|
|
597
|
+
f.removeEventListener("scroll", s, !0), Y.get(e) === p && Y.delete(e);
|
|
598
|
+
};
|
|
599
|
+
for (const w of be) f.addEventListener(w, p, { capture: !0, passive: !0 });
|
|
600
|
+
f.addEventListener("scroll", s, { capture: !0, passive: !0 }), Y.set(e, p);
|
|
601
|
+
}, $e = (e, n) => {
|
|
602
|
+
const t = e.querySelector(`[${X}="${n}"]`);
|
|
603
|
+
return t instanceof HTMLElement ? (Z(e, n, null), t.focus({ preventScroll: !0 }), !0) : !1;
|
|
604
|
+
}, de = (e, n) => {
|
|
605
|
+
const t = e.querySelector(`[${J}="${n}"]`);
|
|
606
|
+
return t instanceof HTMLElement && t.contains(e.ownerDocument.activeElement);
|
|
607
|
+
}, Oe = (e, n) => {
|
|
608
|
+
if (!de(e, n)) return null;
|
|
609
|
+
const t = [...e.querySelectorAll(`[${X}]`)].map((i) => i.getAttribute(X)), o = t.indexOf(n), r = t[o + 1];
|
|
610
|
+
if (o >= 0 && typeof r == "string") return { kind: "panel", panelId: r };
|
|
611
|
+
const l = t[o - 1];
|
|
612
|
+
return o > 0 && typeof l == "string" ? { kind: "panel", panelId: l } : { kind: "stage" };
|
|
613
|
+
}, Ce = (e, n) => {
|
|
614
|
+
requestAnimationFrame(() => {
|
|
615
|
+
const t = e.current;
|
|
616
|
+
t !== null && (n.kind === "panel" && $e(t, n.panelId) || t.focus({ preventScroll: !0 }));
|
|
617
|
+
});
|
|
618
|
+
}, Ue = (e, n) => {
|
|
619
|
+
requestAnimationFrame(() => {
|
|
620
|
+
const t = e.current;
|
|
621
|
+
t !== null && $e(t, n);
|
|
622
|
+
});
|
|
623
|
+
}, ft = (e, n, t) => {
|
|
624
|
+
requestAnimationFrame(() => {
|
|
625
|
+
const o = e.current;
|
|
626
|
+
if (o === null) return;
|
|
627
|
+
const { activeElement: r, body: l } = o.ownerDocument;
|
|
628
|
+
if (Z(o, n, t && de(o, n) ? r : null), !t || r !== null && r !== l && r.isConnected) return;
|
|
629
|
+
const i = o.querySelector(`[${X}="${n}"]`);
|
|
630
|
+
i instanceof HTMLElement && i.focus({ preventScroll: !0 });
|
|
631
|
+
});
|
|
632
|
+
}, pt = ({ store: e, stageRef: n }) => {
|
|
633
|
+
const { config: t, labels: o, announcer: r } = W(), { maximize: l } = ae(), i = t.multiView.columns, c = k(e, (y) => y.layout), f = k(e, (y) => y.visibleColumns), s = k(e, (y) => y.titles), p = k(e, (y) => y.layout.maximized !== null || y.splitDragging), [w, O] = V(!1), [P] = V(() => Ee(f)), u = R(() => it(o), [o]), g = D(
|
|
634
|
+
(y) => {
|
|
635
|
+
e.arrange(st(e.getSnapshot().layout, y));
|
|
636
|
+
},
|
|
637
|
+
[e]
|
|
638
|
+
), m = cn({ initialColumnPanels: P, initialPanelVisibility: {}, debugConfig: ge, onColumnPanelsChange: g }), { columnPanels: b, setColumnPanels: x } = m, M = q(p), d = q(b);
|
|
639
|
+
F(() => {
|
|
640
|
+
M.current = p, d.current = b;
|
|
641
|
+
}, [p, b]);
|
|
642
|
+
const S = D(
|
|
643
|
+
(y) => {
|
|
644
|
+
const E = n.current;
|
|
645
|
+
if (E === null) return;
|
|
646
|
+
const { plan: _, stageBlockSize: A } = Bn(E, i);
|
|
647
|
+
if (Number.isFinite(A) && A > 0 && E.style.setProperty(ue, `${String(A)}px`), M.current && !y) return;
|
|
648
|
+
const H = Ke(e.getSnapshot().visibleColumns, _);
|
|
649
|
+
H !== null && e.setVisibleColumns(H);
|
|
650
|
+
},
|
|
651
|
+
[e, n, i]
|
|
652
|
+
);
|
|
653
|
+
F(() => {
|
|
654
|
+
S(!0), O(!0);
|
|
655
|
+
}, [S]), $(() => {
|
|
656
|
+
const y = n.current;
|
|
657
|
+
if (y === null || typeof ResizeObserver > "u") return;
|
|
658
|
+
let E = null;
|
|
659
|
+
const _ = new ResizeObserver(() => {
|
|
660
|
+
E === null && (E = requestAnimationFrame(() => {
|
|
661
|
+
E = null, S(!1);
|
|
662
|
+
}));
|
|
663
|
+
}), A = y.querySelector(Q)?.firstElementChild, H = y.querySelector(`[${ce}]`);
|
|
664
|
+
return A instanceof Element && _.observe(A), H instanceof Element && _.observe(H), () => {
|
|
665
|
+
_.disconnect(), E !== null && cancelAnimationFrame(E);
|
|
666
|
+
};
|
|
667
|
+
}, [n, S]), $(() => {
|
|
668
|
+
p || S(!1);
|
|
669
|
+
}, [p, S]);
|
|
670
|
+
const h = R(() => w ? lt(c, { logical: i, visible: f }) : Ee(f), [w, c, i, f]);
|
|
671
|
+
F(() => {
|
|
672
|
+
dt(d.current, h) || x(h);
|
|
673
|
+
}, [h, x]);
|
|
674
|
+
const N = R(() => Ie(Object.keys(b)).map((y) => ({ id: y, key: y, className: "aqmx-multi-column" })), [b]), I = R(
|
|
675
|
+
() => c.docs.map((y) => {
|
|
676
|
+
const E = K(c, y);
|
|
677
|
+
return { id: E, component: tt, title: ie(s, y), props: { docPath: y, panelId: E }, minHeight: ct, maxHeight: ut };
|
|
678
|
+
}),
|
|
679
|
+
[c, s]
|
|
680
|
+
), z = R(() => Object.fromEntries(c.docs.map((y) => [K(c, y), !c.hidden.has(y)])), [c]), a = c.maximized === null ? null : K(c, c.maximized), v = D(
|
|
681
|
+
(y) => {
|
|
682
|
+
const { layout: E } = e.getSnapshot();
|
|
683
|
+
for (const [_, A] of G(E)) {
|
|
684
|
+
const H = y[_];
|
|
685
|
+
if (H === void 0 || H !== E.hidden.has(A)) continue;
|
|
686
|
+
const me = e.titleOf(A);
|
|
687
|
+
if (H) {
|
|
688
|
+
if (!e.setHidden(A, !1)) continue;
|
|
689
|
+
r.announce(o.panelShown(me)), Ue(n, _);
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
const fe = n.current, pe = fe === null ? null : Oe(fe, _);
|
|
693
|
+
e.setHidden(A, !0) && (r.announce(o.panelHidden(me)), pe !== null && Ce(n, pe));
|
|
694
|
+
}
|
|
695
|
+
},
|
|
696
|
+
[e, n, r, o]
|
|
697
|
+
), C = D(
|
|
698
|
+
(y) => {
|
|
699
|
+
const E = G(e.getSnapshot().layout).get(y);
|
|
700
|
+
if (E === void 0) return;
|
|
701
|
+
const _ = e.titleOf(E), A = n.current, H = A === null ? null : Oe(A, y);
|
|
702
|
+
e.close(E) && (r.announce(o.panelClosed(_)), H !== null && Ce(n, H));
|
|
703
|
+
},
|
|
704
|
+
[e, n, r, o]
|
|
705
|
+
), L = D(
|
|
706
|
+
(y) => {
|
|
707
|
+
if (y === null) {
|
|
708
|
+
l(null);
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
const E = G(e.getSnapshot().layout).get(y);
|
|
712
|
+
E !== void 0 && l(E);
|
|
713
|
+
},
|
|
714
|
+
[e, l]
|
|
715
|
+
);
|
|
716
|
+
return /* @__PURE__ */ T("div", { className: "aqmx-multi-layout", "aria-busy": !w, children: /* @__PURE__ */ T(
|
|
717
|
+
un,
|
|
718
|
+
{
|
|
719
|
+
columns: N,
|
|
720
|
+
panels: I,
|
|
721
|
+
columnPanels: b,
|
|
722
|
+
onColumnPanelsChange: g,
|
|
723
|
+
panelVisibility: z,
|
|
724
|
+
onPanelVisibilityChange: v,
|
|
725
|
+
dragState: m.dragState,
|
|
726
|
+
dragOverPosition: m.dragOverPosition,
|
|
727
|
+
originalPanelPosition: m.originalPanelPosition,
|
|
728
|
+
dragModes: m.dragModes,
|
|
729
|
+
debugConfig: ge,
|
|
730
|
+
panelSizes: m.panelSizes,
|
|
731
|
+
customDrag: m.customDrag,
|
|
732
|
+
setPanelRef: m.setPanelRef,
|
|
733
|
+
onDragStart: m.handleDragStart,
|
|
734
|
+
onDragEnd: m.handleDragEnd,
|
|
735
|
+
onPlaceholderDragEnter: m.handlePlaceholderDragEnter,
|
|
736
|
+
onPlaceholderDragLeave: m.handlePlaceholderDragLeave,
|
|
737
|
+
onDragOverWithInsert: m.handleDragOverWithInsert,
|
|
738
|
+
onDropWithInsert: m.handleDropWithInsert,
|
|
739
|
+
onColumnDragLeave: m.handleColumnDragLeave,
|
|
740
|
+
onPanelMouseDown: m.handleMouseDown,
|
|
741
|
+
onPanelSizeInfoClick: m.handlePanelSizeInfoClick,
|
|
742
|
+
onToggleDragMode: m.toggleDragMode,
|
|
743
|
+
onPanelClose: C,
|
|
744
|
+
onPanelMaximizeChange: L,
|
|
745
|
+
maximizedPanel: a,
|
|
746
|
+
dragHandle: "header",
|
|
747
|
+
labels: u,
|
|
748
|
+
panelClassName: "aqmx-multi-panel"
|
|
749
|
+
}
|
|
750
|
+
) });
|
|
751
|
+
}, oe = { blockStart: "--aqmx-multi-toast-block-start", inlineEnd: "--aqmx-multi-toast-inline-end", room: "--aqmx-multi-toast-room" }, gt = (e, n) => {
|
|
752
|
+
const t = n.getBoundingClientRect(), o = [t.left + 1, t.left + t.width / 2, t.right - 1], r = [t.top + 1, t.top + t.height / 2, t.bottom - 1];
|
|
753
|
+
return o.some(
|
|
754
|
+
(l) => r.some((i) => {
|
|
755
|
+
const c = n.ownerDocument.elementsFromPoint(l, i), f = c.findIndex((p) => n.contains(p)), s = c.findIndex((p) => e.contains(p));
|
|
756
|
+
return f !== -1 && s !== -1 && s < f;
|
|
757
|
+
})
|
|
758
|
+
);
|
|
759
|
+
}, ht = (e, n) => {
|
|
760
|
+
const t = n.getBoundingClientRect(), o = n.ownerDocument.documentElement.clientWidth, r = getComputedStyle(n).direction === "rtl";
|
|
761
|
+
return e.style.setProperty(oe.blockStart, `${String(t.top)}px`), e.style.setProperty(oe.inlineEnd, `${String(r ? t.left : o - t.right)}px`), e.style.setProperty(oe.room, `${String(t.width)}px`), e.showPopover(), () => {
|
|
762
|
+
e.isConnected && e.hidePopover();
|
|
763
|
+
};
|
|
764
|
+
}, vt = ({ store: e, body: n, limitNotice: t, onLimitNoticeCovered: o, ref: r }) => {
|
|
765
|
+
const { config: l, labels: i, announcer: c } = W(), f = q(null), s = q(null), p = k(e, (d) => d.ready), w = k(e, (d) => d.layout.docs.length > 0), O = k(e, (d) => d.visibleColumns), P = Me(rn), u = D(
|
|
766
|
+
(d) => {
|
|
767
|
+
const { layout: S } = e.getSnapshot(), h = S.maximized, N = d === null && h !== null ? S.panelIds.get(h) : void 0, I = f.current, z = N !== void 0 && I !== null && de(I, N);
|
|
768
|
+
e.maximize(d) && (d !== null ? c.announce(i.panelMaximized(e.titleOf(d))) : h !== null && c.announce(i.panelRestored(e.titleOf(h))), N !== void 0 && ft(f, N, z));
|
|
769
|
+
},
|
|
770
|
+
[e, c, i]
|
|
771
|
+
), g = D(
|
|
772
|
+
(d, S, h, N) => {
|
|
773
|
+
if (h === S) {
|
|
774
|
+
e.setPendingHash(d, N);
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const I = e.navigate(S, h);
|
|
778
|
+
if (I === "navigated") {
|
|
779
|
+
e.setPendingHash(d, N);
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
if (I !== "existing") return;
|
|
783
|
+
const { layout: z } = e.getSnapshot(), a = z.panelIds.get(h);
|
|
784
|
+
a !== void 0 && (c.announce(i.panelAlreadyOpen(e.titleOf(h))), z.maximized === null ? e.setHidden(h, !1) : u(h), e.setPendingHash(a, N), Ue(f, a));
|
|
785
|
+
},
|
|
786
|
+
[e, c, i, u]
|
|
787
|
+
);
|
|
788
|
+
F(() => {
|
|
789
|
+
if (t === null || P !== null || !Se()) return;
|
|
790
|
+
const d = s.current, S = f.current;
|
|
791
|
+
if (d === null || S === null) throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");
|
|
792
|
+
return ht(d, S);
|
|
793
|
+
}, [t, P]), $(() => {
|
|
794
|
+
const d = s.current;
|
|
795
|
+
if (t === null || d === null) return;
|
|
796
|
+
const { ownerDocument: S } = d;
|
|
797
|
+
let h = null;
|
|
798
|
+
const N = (I) => {
|
|
799
|
+
const z = I.target;
|
|
800
|
+
z instanceof Element && (h !== null && cancelAnimationFrame(h), h = requestAnimationFrame(() => {
|
|
801
|
+
h = null, S.activeElement === z && d.isConnected && gt(d, z) && o();
|
|
802
|
+
}));
|
|
803
|
+
};
|
|
804
|
+
return S.addEventListener("focusin", N, !0), () => {
|
|
805
|
+
S.removeEventListener("focusin", N, !0), h !== null && cancelAnimationFrame(h);
|
|
806
|
+
};
|
|
807
|
+
}, [t, P, o]), Ge(
|
|
808
|
+
r,
|
|
809
|
+
() => ({
|
|
810
|
+
bringIntoView: (d) => {
|
|
811
|
+
requestAnimationFrame(() => {
|
|
812
|
+
const S = f.current, h = e.getSnapshot().layout.panelIds.get(d);
|
|
813
|
+
S !== null && h !== void 0 && Z(S, h, null);
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
}),
|
|
817
|
+
[e]
|
|
818
|
+
), $(() => {
|
|
819
|
+
const d = f.current;
|
|
820
|
+
return () => {
|
|
821
|
+
d !== null && Y.get(d)?.();
|
|
822
|
+
};
|
|
823
|
+
}, []);
|
|
824
|
+
const m = D((d, S) => {
|
|
825
|
+
const h = f.current;
|
|
826
|
+
h !== null && Z(h, d, S);
|
|
827
|
+
}, []), [b] = V(_n), x = R(() => ({ store: e, Body: n, followLink: g, maximize: u, revealInPanel: m, focusCarry: b }), [e, n, g, u, m, b]), M = R(() => Array.from({ length: l.multiView.columns }, (d, S) => Te(S)), [l]);
|
|
828
|
+
return (
|
|
829
|
+
/* @__PURE__ */ re("section", { ref: f, className: "aqmx-multi-stage", tabIndex: -1, "aria-label": i.multiRegion, "aria-busy": w && !p, "data-testid": "markdown-explorer-stage", "data-aqmx-visible-columns": O, children: [
|
|
830
|
+
/* @__PURE__ */ T("span", { className: "aqmx-multi-probe", "aria-hidden": "true", [ce]: "" }),
|
|
831
|
+
w ? p ? /* @__PURE__ */ T(_e, { value: x, children: /* @__PURE__ */ T(pt, { store: e, stageRef: f }) }) : /* @__PURE__ */ T("div", { className: "aqmx-multi-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-stage-skeleton", children: M.map((d) => /* @__PURE__ */ re("div", { className: "aqmx-skeleton aqmx-multi-skeleton-column", children: [
|
|
832
|
+
/* @__PURE__ */ T("span", {}),
|
|
833
|
+
/* @__PURE__ */ T("span", {}),
|
|
834
|
+
/* @__PURE__ */ T("span", {})
|
|
835
|
+
] }, d)) }) : /* @__PURE__ */ T("div", { className: "aqmx-empty", "data-testid": "markdown-explorer-multi-empty", children: /* @__PURE__ */ T("p", { className: "aqmx-empty-title", children: i.multiEmpty }) }),
|
|
836
|
+
t === null ? null : P !== null ? wn(
|
|
837
|
+
/* @__PURE__ */ T("div", { ref: s, className: "aqmx-toast aqmx-multi-toast", "data-testid": "markdown-explorer-panel-limit", children: t }),
|
|
838
|
+
P
|
|
839
|
+
) : (
|
|
840
|
+
/* @__PURE__ */ T("div", { ref: s, popover: Se() ? "manual" : void 0, className: "aqmx-toast aqmx-multi-toast", "data-testid": "markdown-explorer-panel-limit", children: t })
|
|
841
|
+
)
|
|
842
|
+
] })
|
|
843
|
+
);
|
|
844
|
+
}, wt = 3e3, yt = (e, n) => {
|
|
845
|
+
if (n !== null) return n;
|
|
846
|
+
const [t] = e;
|
|
847
|
+
return t === void 0 ? null : t;
|
|
848
|
+
}, xt = (e, n, t) => {
|
|
849
|
+
switch (n) {
|
|
850
|
+
case "opened":
|
|
851
|
+
return e.panelOpened(t);
|
|
852
|
+
case "shown":
|
|
853
|
+
return e.panelShown(t);
|
|
854
|
+
case "closed":
|
|
855
|
+
return e.panelClosed(t);
|
|
856
|
+
default: {
|
|
857
|
+
const o = n;
|
|
858
|
+
throw new RangeError(`[markdown-explorer] unknown toggle outcome ${JSON.stringify(o)}`);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}, Lt = ({ location: e }) => {
|
|
862
|
+
const { config: n, labels: t, announcer: o } = W(), r = $n(e), l = k(r, (d) => d.layout.docs), i = k(r, (d) => d.layout.maximized), c = k(r, (d) => d.source), [f, s] = V(!1), p = q(null), [w, O] = V(0), P = q(null), u = q(null);
|
|
863
|
+
F(() => {
|
|
864
|
+
const d = P.current;
|
|
865
|
+
P.current = null, d !== null && (r.whenUrlRendered(() => o.announce(d.announcement)), u.current?.bringIntoView(d.doc));
|
|
866
|
+
}), $(
|
|
867
|
+
() => () => {
|
|
868
|
+
p.current !== null && clearTimeout(p.current);
|
|
869
|
+
},
|
|
870
|
+
[]
|
|
871
|
+
);
|
|
872
|
+
const g = D(() => {
|
|
873
|
+
p.current !== null && clearTimeout(p.current), s(!0), p.current = setTimeout(() => {
|
|
874
|
+
p.current = null, s(!1);
|
|
875
|
+
}, wt);
|
|
876
|
+
}, []), m = D(() => {
|
|
877
|
+
p.current !== null && clearTimeout(p.current), p.current = null, s(!1);
|
|
878
|
+
}, []), b = D(
|
|
879
|
+
(d) => {
|
|
880
|
+
const S = r.titleOf(d), h = r.toggle(d);
|
|
881
|
+
h === "rejected" && g();
|
|
882
|
+
const N = h === "rejected" ? t.panelLimit(n.multiView.maxPanels) : xt(t, h, S);
|
|
883
|
+
if (h === "shown") {
|
|
884
|
+
P.current = { doc: d, announcement: N }, O((I) => I + 1);
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
r.whenUrlRendered(() => {
|
|
888
|
+
o.announce(N), h === "opened" && u.current?.bringIntoView(d);
|
|
889
|
+
});
|
|
890
|
+
},
|
|
891
|
+
[r, g, o, t, n]
|
|
892
|
+
), x = R(() => new Set(l), [l]), M = R(() => ({ href: Ne(n, { view: "tree", source: c, doc: yt(l, i) }), target: "tree" }), [n, c, l, i]);
|
|
893
|
+
return /* @__PURE__ */ T(
|
|
894
|
+
ln,
|
|
895
|
+
{
|
|
896
|
+
view: "multi",
|
|
897
|
+
explorer: /* @__PURE__ */ T(sn, { mode: "multi", sourceId: c, currentPath: null, openPaths: x, onOpenDocument: b, onSourceChange: r.changeSource, viewSwitch: M }),
|
|
898
|
+
content: /* @__PURE__ */ T(vt, { ref: u, store: r, body: rt, limitNotice: f ? t.panelLimit(n.multiView.maxPanels) : null, onLimitNoticeCovered: m }),
|
|
899
|
+
contentCoversPage: i !== null,
|
|
900
|
+
sheetDismissals: w,
|
|
901
|
+
onDraggingChange: r.setSplitDragging
|
|
902
|
+
}
|
|
903
|
+
);
|
|
904
|
+
};
|
|
905
|
+
export {
|
|
906
|
+
Lt as MultiLayout,
|
|
907
|
+
wt as PANEL_LIMIT_NOTICE_MS,
|
|
908
|
+
yt as treeSwitchDocument
|
|
909
|
+
};
|