@aiquants/markdown-explorer 0.23.0 → 0.24.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 +112 -0
- package/README.md +61 -21
- package/dist/{EditSurface-Bk4tdJ99.cjs → EditSurface-CRc4g0Qa.cjs} +5 -5
- package/dist/{EditSurface-Dhvw9IDD.js → EditSurface-CcWEczj3.js} +333 -336
- package/dist/{ExplorerSplit-Q5VqUBDE.js → ExplorerSplit-97SeIAOS.js} +81 -81
- package/dist/{ExplorerSplit-BAFiXU-V.cjs → ExplorerSplit-ByxxXlgs.cjs} +1 -1
- package/dist/{MultiLayout-Bq_TS3ez.cjs → MultiLayout-B_yMVDt_.cjs} +1 -1
- package/dist/{MultiLayout-DlATT7km.js → MultiLayout-CnbuAlxd.js} +22 -22
- package/dist/{NativeScrollBar-TsIcS3JZ.js → NativeScrollBar-BXdaM3EA.js} +1 -1
- package/dist/{NativeScrollBar-A6-qEpz7.cjs → NativeScrollBar-D4a7fBOS.cjs} +1 -1
- package/dist/{TreeLayout-zrSo4MNZ.js → TreeLayout-BIQBKAkV.js} +3 -3
- package/dist/{TreeLayout-l-r2pPao.cjs → TreeLayout-C6QDpEBS.cjs} +1 -1
- package/dist/core/config.d.cts +13 -0
- package/dist/core/config.d.ts +13 -0
- package/dist/core/contracts.d.cts +22 -4
- package/dist/core/contracts.d.ts +22 -4
- package/dist/core/labels.d.cts +9 -0
- package/dist/core/labels.d.ts +9 -0
- package/dist/core/textEncoding.d.cts +4 -0
- package/dist/core/textEncoding.d.ts +4 -0
- package/dist/{dataRoute-Diu_7gle.js → dataRoute-BEvesOvN.js} +105 -97
- package/dist/dataRoute-Cv7fgCW7.cjs +1 -0
- package/dist/index-BwTVYkTR.cjs +13 -0
- package/dist/index-CeZDCyEl.js +4088 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +24 -23
- package/dist/location-CasigkBk.cjs +1 -0
- package/dist/location-gXXmC7CQ.js +643 -0
- package/dist/{merge-BzMpSaxx.js → merge-DqjUgcV_.js} +1 -1
- package/dist/{merge-DlPkU2Jc.cjs → merge-QLktbpZY.cjs} +1 -1
- package/dist/{sanitizePolicy-Du3lFZd-.cjs → sanitizePolicy-CZwOaJ92.cjs} +1 -1
- package/dist/{sanitizePolicy-BvhYIqVO.js → sanitizePolicy-gVKBhabq.js} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +1 -1
- package/dist/server/fileSystemSource.d.cts +1 -0
- package/dist/server/fileSystemSource.d.ts +1 -0
- package/dist/server/ports.d.cts +8 -1
- package/dist/server/ports.d.ts +8 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +783 -768
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/{useSplitPersistence-HfAb8Kzh.js → useSplitPersistence-BPNjvuJi.js} +1 -1
- package/dist/{useSplitPersistence-CR4Oxtaa.cjs → useSplitPersistence-Bmpb2prR.cjs} +1 -1
- package/docs/behavior/dom-hooks.md +13 -6
- package/docs/behavior/layout.md +19 -10
- package/docs/behavior/localization.md +6 -3
- package/docs/behavior/security.md +6 -4
- package/docs/behavior/url-contract.md +2 -2
- package/package.json +5 -5
- package/dist/dataRoute-vXGZMVB-.cjs +0 -1
- package/dist/index-BNFl3BsO.cjs +0 -13
- package/dist/index-Jz6zeO4O.js +0 -3703
- package/dist/location-8Ho8ZNv_.js +0 -499
- package/dist/location-DN0AI4ir.cjs +0 -1
|
@@ -1,499 +0,0 @@
|
|
|
1
|
-
import { NO_EMBEDS as we, isEmbedProviderId as ge, EMBED_PROVIDER_IDS as pe, isLinkCardSize as he, LINK_CARD_SIZES as Ee } from "@aiquants/markdown/embeds";
|
|
2
|
-
import { CONTENT_ALIGNS as N, DEFAULT_MARKDOWN_STYLES as Se } from "@aiquants/markdown/viewer-settings";
|
|
3
|
-
import { a as xe, i as A } from "./dataRoute-Diu_7gle.js";
|
|
4
|
-
const J = (e) => {
|
|
5
|
-
if (e === null || typeof e != "object") return !1;
|
|
6
|
-
const t = Object.getPrototypeOf(e);
|
|
7
|
-
return t === Object.prototype || t === null;
|
|
8
|
-
}, I = new Intl.Collator("en", { numeric: !0, sensitivity: "variant" }), be = /^readme(?:\.|$)/iu, W = /^readme(?:\.[^.]*)?$/iu, H = Object.freeze(["md", "markdown", "mdx", "txt", ""]), ye = (e) => be.test(e), V = (e) => e.type === "file" && ye(e.name), K = (e) => {
|
|
9
|
-
const t = e.lastIndexOf("."), r = H.indexOf(t < 0 ? "" : e.slice(t + 1).toLowerCase());
|
|
10
|
-
return r < 0 ? H.length : r;
|
|
11
|
-
}, Oe = (e, t) => {
|
|
12
|
-
const r = +!W.test(e.name) - +!W.test(t.name);
|
|
13
|
-
if (r !== 0) return r;
|
|
14
|
-
const n = K(e.name) - K(t.name);
|
|
15
|
-
if (n !== 0) return n;
|
|
16
|
-
const o = I.compare(e.name, t.name);
|
|
17
|
-
return o !== 0 ? o : I.compare(e.path, t.path);
|
|
18
|
-
}, ht = (e) => {
|
|
19
|
-
let t = null;
|
|
20
|
-
for (const r of e)
|
|
21
|
-
V(r) && (t === null || Oe(r, t) < 0) && (t = r);
|
|
22
|
-
return t === null ? null : t.path;
|
|
23
|
-
}, q = Object.freeze({
|
|
24
|
-
sortMode: "native",
|
|
25
|
-
folderPlacement: "mixed",
|
|
26
|
-
readmePlacement: "mixed",
|
|
27
|
-
selectionMode: "single",
|
|
28
|
-
doubleClickAction: "recursive",
|
|
29
|
-
expandIconSize: 8,
|
|
30
|
-
alwaysExpanded: !1,
|
|
31
|
-
revealDocument: !1,
|
|
32
|
-
removeRootIndent: !1,
|
|
33
|
-
lines: !0,
|
|
34
|
-
expandIcons: !0,
|
|
35
|
-
directoryIcons: !0,
|
|
36
|
-
fileIcons: !0
|
|
37
|
-
}), ke = [!0, !1], Re = (e, t) => t ? e.settingOn : e.settingOff, h = (e, t) => ({ key: e, labelKey: t, values: ke, formatValue: Re, requiresItemSelection: !1 }), _e = Object.freeze({
|
|
38
|
-
native: (e) => e.sortNative,
|
|
39
|
-
asc: (e) => e.sortAscending,
|
|
40
|
-
desc: (e) => e.sortDescending,
|
|
41
|
-
oldest: (e) => e.sortOldest,
|
|
42
|
-
newest: (e) => e.sortNewest
|
|
43
|
-
}), x = Object.freeze([
|
|
44
|
-
{
|
|
45
|
-
key: "sortMode",
|
|
46
|
-
labelKey: "settingSortMode",
|
|
47
|
-
values: ["native", "asc", "desc", "oldest", "newest"],
|
|
48
|
-
formatValue: (e, t) => _e[t](e),
|
|
49
|
-
requiresItemSelection: !1
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
key: "folderPlacement",
|
|
53
|
-
labelKey: "settingFolderPlacement",
|
|
54
|
-
values: ["mixed", "first", "last"],
|
|
55
|
-
formatValue: (e, t) => t === "mixed" ? e.folderPlacementMixed : t === "first" ? e.folderPlacementFirst : e.folderPlacementLast,
|
|
56
|
-
requiresItemSelection: !1
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
key: "readmePlacement",
|
|
60
|
-
labelKey: "settingReadmePlacement",
|
|
61
|
-
values: ["mixed", "first", "last"],
|
|
62
|
-
formatValue: (e, t) => t === "mixed" ? e.readmePlacementMixed : t === "first" ? e.readmePlacementFirst : e.readmePlacementLast,
|
|
63
|
-
requiresItemSelection: !1
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
key: "selectionMode",
|
|
67
|
-
labelKey: "settingSelectionMode",
|
|
68
|
-
values: ["single", "multiple", "none"],
|
|
69
|
-
formatValue: (e, t) => t === "single" ? e.selectionSingle : t === "multiple" ? e.selectionMultiple : e.selectionNone,
|
|
70
|
-
requiresItemSelection: !0
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
key: "doubleClickAction",
|
|
74
|
-
labelKey: "settingDoubleClick",
|
|
75
|
-
values: ["recursive", "toggle"],
|
|
76
|
-
formatValue: (e, t) => t === "recursive" ? e.doubleClickRecursive : e.doubleClickToggle,
|
|
77
|
-
requiresItemSelection: !1
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
key: "expandIconSize",
|
|
81
|
-
labelKey: "settingExpandIconSize",
|
|
82
|
-
values: [8, 13, 5],
|
|
83
|
-
formatValue: (e, t) => e.expandIconSizeValue(t),
|
|
84
|
-
requiresItemSelection: !1
|
|
85
|
-
},
|
|
86
|
-
h("alwaysExpanded", "settingAlwaysExpanded"),
|
|
87
|
-
h("revealDocument", "settingRevealDocument"),
|
|
88
|
-
h("removeRootIndent", "settingRemoveRootIndent"),
|
|
89
|
-
h("lines", "settingTreeLines"),
|
|
90
|
-
h("expandIcons", "settingExpandIcons"),
|
|
91
|
-
h("directoryIcons", "settingDirectoryIcons"),
|
|
92
|
-
h("fileIcons", "settingFileIcons")
|
|
93
|
-
]), Et = (e) => e ? x : x.filter((t) => !t.requiresItemSelection), oe = (e) => {
|
|
94
|
-
const t = x.find((r) => r.key === e);
|
|
95
|
-
if (t === void 0) throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);
|
|
96
|
-
return t;
|
|
97
|
-
}, St = (e, t) => {
|
|
98
|
-
const r = oe(t).values, n = r[(r.indexOf(e[t]) + 1) % r.length];
|
|
99
|
-
return { ...e, [t]: n };
|
|
100
|
-
}, xt = (e, t, r) => oe(r).formatValue(e, t[r]), se = 2, B = Object.freeze({}), X = (e, t) => Object.freeze(Object.fromEntries(x.filter((r) => t(r, e[r.key])).map((r) => [r.key, e[r.key]]))), Z = "directoriesFirst", Te = (e) => {
|
|
101
|
-
if (!Object.hasOwn(e, Z)) return e;
|
|
102
|
-
const { [Z]: t, ...r } = e;
|
|
103
|
-
return Object.hasOwn(r, "folderPlacement") || typeof t != "boolean" ? r : { ...r, folderPlacement: t ? "first" : "mixed" };
|
|
104
|
-
}, bt = (e) => {
|
|
105
|
-
if (e === null || typeof e != "object" || Array.isArray(e)) return B;
|
|
106
|
-
const t = e;
|
|
107
|
-
return t.version !== se || t.settings === null || typeof t.settings != "object" || Array.isArray(t.settings) ? B : X(Te(t.settings), (r, n) => r.values.includes(n));
|
|
108
|
-
}, yt = (e, t) => {
|
|
109
|
-
const r = X(t, (n, o) => o !== void 0 && o !== e[n.key]);
|
|
110
|
-
return Object.keys(r).length === 0 ? e : Object.freeze({ ...e, ...r });
|
|
111
|
-
}, Ot = (e, t, r, n) => X({ ...e, [t]: r }, (o, s) => s !== void 0 && !(o.key === t && s === n[t])), kt = (e) => JSON.stringify({ version: se, settings: e }), Ne = (e, t, r) => e === void 0 || t === void 0 ? e === t ? 0 : e === void 0 ? 1 : -1 : r * (e - t), Rt = (e) => {
|
|
112
|
-
const { sortMode: t, folderPlacement: r, readmePlacement: n } = e;
|
|
113
|
-
if (t === "native" && r === "mixed" && n === "mixed") return;
|
|
114
|
-
const o = (s, i) => {
|
|
115
|
-
const l = I.compare(s.name, i.name);
|
|
116
|
-
return l !== 0 ? l : I.compare(s.path, i.path);
|
|
117
|
-
};
|
|
118
|
-
return (s, i) => {
|
|
119
|
-
if (r !== "mixed" && s.type !== i.type) return s.type === "directory" == (r === "first") ? -1 : 1;
|
|
120
|
-
if (n !== "mixed") {
|
|
121
|
-
const a = V(s);
|
|
122
|
-
if (a !== V(i)) return a === (n === "first") ? -1 : 1;
|
|
123
|
-
}
|
|
124
|
-
if (t === "native") return 0;
|
|
125
|
-
if (t === "asc") return o(s, i);
|
|
126
|
-
if (t === "desc") return -o(s, i);
|
|
127
|
-
const l = Ne(s.modifiedAt, i.modifiedAt, t === "oldest" ? 1 : -1);
|
|
128
|
-
return l !== 0 ? l : o(s, i);
|
|
129
|
-
};
|
|
130
|
-
}, g = (1 + Math.sqrt(5)) / 2, _t = 100 / g ** 3, Tt = 100 / g ** 4, ie = 100 / g ** 2, Ae = 13, Nt = 16, At = Object.freeze({ gripThickness: 5, gripLength: 34, barThickness: 2, barLength: 21 }), Ie = Object.freeze([89, 144, 233, 377]), Pe = 44, It = Pe, Pt = 24, vt = 1 / g, $t = 1 / g ** 3, Mt = "40ch", ve = (e) => {
|
|
131
|
-
if (!Number.isFinite(e) || e <= 0)
|
|
132
|
-
throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${String(e)}`);
|
|
133
|
-
}, $e = (e) => (ve(e), Ae * e), Ct = (e) => $e(e) * g ** 2, Lt = 233, Dt = 50, Me = 100 / g ** 3, zt = 100 - Me, jt = Ie[0], w = (e, t) => {
|
|
134
|
-
if (!Number.isFinite(t) || t < 0)
|
|
135
|
-
throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${String(t)}`);
|
|
136
|
-
}, Ce = ({ trackInlineSize: e, gap: t, minColumnInlineSize: r, logicalColumns: n }) => {
|
|
137
|
-
if (w("trackInlineSize", e), w("gap", t), !Number.isFinite(r) || r <= 0)
|
|
138
|
-
throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${String(r)}`);
|
|
139
|
-
if (!Number.isInteger(n) || n < 1)
|
|
140
|
-
throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${String(n)}`);
|
|
141
|
-
const o = Math.floor((e + t) / (r + t));
|
|
142
|
-
return Math.min(n, Math.max(1, o));
|
|
143
|
-
}, Ft = (e, t) => {
|
|
144
|
-
const { trackInlineSize: r, gap: n, minColumnInlineSize: o, logicalColumns: s } = t;
|
|
145
|
-
if (!([r, n, o].every(Number.isFinite) && r > 0 && n >= 0 && o > 0)) return e;
|
|
146
|
-
const l = Ce(t);
|
|
147
|
-
if (e === null || l === e) return l;
|
|
148
|
-
const a = Math.min(s, Math.max(1, e));
|
|
149
|
-
if (l > a) {
|
|
150
|
-
const $ = (a + 1) * o + a * n + n / g;
|
|
151
|
-
return r >= $ ? l : a;
|
|
152
|
-
}
|
|
153
|
-
return r >= a * o + (a - 1) * n ? a : l;
|
|
154
|
-
}, Vt = (e, t) => {
|
|
155
|
-
if (!(Number.isInteger(e) && Number.isInteger(t)) || t < 1 || t > e)
|
|
156
|
-
throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${String(t)}`);
|
|
157
|
-
return Array.from({ length: t }, (r, n) => [Math.floor(n * e / t), Math.floor((n + 1) * e / t)]);
|
|
158
|
-
}, Ut = (e, t, r) => {
|
|
159
|
-
if (w("surfaceInlineSize", e), w("handlePixels", r), !Number.isFinite(t) || t <= 0)
|
|
160
|
-
throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${String(t)}`);
|
|
161
|
-
return e >= 2 * t + r ? "beside" : "stacked";
|
|
162
|
-
}, F = (e, t, r) => Math.max(t, Math.min(e, r)), Y = (e, t, r, n) => {
|
|
163
|
-
const o = (F(e, 0, r) + F(t, 0, r)) / 2;
|
|
164
|
-
return F(o - n / 2, 0, r - n);
|
|
165
|
-
}, Jt = (e, t, r) => {
|
|
166
|
-
for (const [n, o] of Object.entries(e))
|
|
167
|
-
if (!Number.isFinite(o)) throw new RangeError(`[markdown-explorer] anchor.${n} must be a finite number; got ${String(o)}`);
|
|
168
|
-
return w("marginBox.width", t.width), w("marginBox.height", t.height), w("viewport.width", r.width), w("viewport.height", r.height), {
|
|
169
|
-
left: Y(e.left, e.right, r.width, t.width),
|
|
170
|
-
top: Y(e.top, e.bottom, r.height, t.height)
|
|
171
|
-
};
|
|
172
|
-
}, Le = 31536e3, De = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u, ze = (e) => {
|
|
173
|
-
if (typeof e != "string" || !De.test(e))
|
|
174
|
-
throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${JSON.stringify(e)}`);
|
|
175
|
-
}, Q = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= ie, je = (e, t) => {
|
|
176
|
-
if (e === null || typeof e != "object" || Array.isArray(e)) return {};
|
|
177
|
-
const r = e, { treeExplorer: n, multiExplorer: o, style: s, align: i } = r;
|
|
178
|
-
return {
|
|
179
|
-
...Q(n) ? { treeExplorer: n } : {},
|
|
180
|
-
...Q(o) ? { multiExplorer: o } : {},
|
|
181
|
-
...typeof s == "string" && t.includes(s) ? { style: s } : {},
|
|
182
|
-
...typeof i == "string" && N.includes(i) ? { align: i } : {}
|
|
183
|
-
};
|
|
184
|
-
}, Xt = (e, t) => {
|
|
185
|
-
if (e !== null)
|
|
186
|
-
for (const r of e.split(";")) {
|
|
187
|
-
const n = r.indexOf("=");
|
|
188
|
-
if (!(n < 0) && r.slice(0, n).trim() === t)
|
|
189
|
-
return r.slice(n + 1).trim();
|
|
190
|
-
}
|
|
191
|
-
}, Gt = (e, t) => {
|
|
192
|
-
if (e === void 0 || e === "") return {};
|
|
193
|
-
try {
|
|
194
|
-
return je(JSON.parse(decodeURIComponent(e)), t);
|
|
195
|
-
} catch {
|
|
196
|
-
return {};
|
|
197
|
-
}
|
|
198
|
-
}, P = 100, Fe = Math.floor(ie * P) / P, Ve = (e) => {
|
|
199
|
-
const t = (r) => Math.min(Fe, Math.max(1, Math.round(r * P)) / P);
|
|
200
|
-
return encodeURIComponent(
|
|
201
|
-
JSON.stringify({
|
|
202
|
-
...e.treeExplorer === void 0 ? {} : { treeExplorer: t(e.treeExplorer) },
|
|
203
|
-
...e.multiExplorer === void 0 ? {} : { multiExplorer: t(e.multiExplorer) },
|
|
204
|
-
...e.style === void 0 ? {} : { style: e.style },
|
|
205
|
-
...e.align === void 0 ? {} : { align: e.align }
|
|
206
|
-
})
|
|
207
|
-
);
|
|
208
|
-
}, Wt = (e, t, r) => `${e}=${Ve(t)}; Path=/; Max-Age=${String(Le)}; SameSite=Lax${r ? "; Secure" : ""}`, ee = Object.freeze({ tree: "tree", multi: "multi", single: "single" }), Ue = Object.freeze({ default: 12, min: 1, max: 64 }), Je = Object.freeze({ default: 4, min: 1, max: 6 }), Xe = Object.freeze({ default: 500, min: 1, max: 1e4 }), Ge = Object.freeze({ default: 16, min: 1, max: 64 }), We = Object.freeze({ default: 16, min: 1, max: 64 }), He = /^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u, Ke = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u, qe = /^[a-z0-9][a-z0-9-]*$/u, Be = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u, te = (e, t) => {
|
|
209
|
-
if (typeof t != "string") throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${typeof t}`);
|
|
210
|
-
if (!He.test(t) || t.split("/").some((r) => r === "." || r === ".."))
|
|
211
|
-
throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", and use only letters, digits and "._~-" in each segment; got ${JSON.stringify(t)}`);
|
|
212
|
-
}, d = (e) => typeof e == "string" ? JSON.stringify(e) : typeof e == "bigint" ? `${String(e)}n` : Object.is(e, -0) ? "-0" : typeof e == "function" ? "a function" : Array.isArray(e) ? "an array" : e !== null && typeof e == "object" ? J(e) ? "a plain object" : `a non-plain object (${Object.prototype.toString.call(e)})` : String(e), S = (e, t, r) => {
|
|
213
|
-
if (t === void 0) return [];
|
|
214
|
-
if (!J(t)) throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${d(t)}`);
|
|
215
|
-
const n = Object.entries(t);
|
|
216
|
-
for (const [o] of n)
|
|
217
|
-
if (!r.includes(o)) throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${r.join(", ")}`);
|
|
218
|
-
return n.filter(([, o]) => o !== void 0);
|
|
219
|
-
}, Ze = (e) => {
|
|
220
|
-
const t = { ...ee };
|
|
221
|
-
for (const [r, n] of S("views", e, Object.keys(ee))) t[r] = n;
|
|
222
|
-
for (const [r, n] of Object.entries(t))
|
|
223
|
-
if (typeof n != "string" || !Ke.test(n))
|
|
224
|
-
throw new RangeError(`[markdown-explorer] views.${r} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${JSON.stringify(n)}`);
|
|
225
|
-
return Object.freeze(t);
|
|
226
|
-
}, R = (e, t, r) => {
|
|
227
|
-
if (t === void 0) return r.default;
|
|
228
|
-
if (typeof t != "number" || !Number.isInteger(t) || t < r.min || t > r.max)
|
|
229
|
-
throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(r.min)}..${String(r.max)}; got ${d(t)}`);
|
|
230
|
-
return t;
|
|
231
|
-
}, Ye = (e, t) => {
|
|
232
|
-
const r = new Map(S("embeds", e, ["providers", "linkCards", "linkCardSize"]));
|
|
233
|
-
if (r.size === 0) return we;
|
|
234
|
-
const n = r.has("providers") ? r.get("providers") : [];
|
|
235
|
-
if (!Array.isArray(n)) throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${d(n)}`);
|
|
236
|
-
for (const l of n)
|
|
237
|
-
if (!ge(l)) throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${pe.join(", ")}; got ${d(l)}`);
|
|
238
|
-
const o = r.has("linkCards") ? r.get("linkCards") : !1;
|
|
239
|
-
if (typeof o != "boolean") throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${d(o)}`);
|
|
240
|
-
const s = { providers: Object.freeze([...new Set(n)]), linkCardEndpoint: o ? xe(t) : null };
|
|
241
|
-
if (!r.has("linkCardSize")) return Object.freeze(s);
|
|
242
|
-
const i = r.get("linkCardSize");
|
|
243
|
-
if (!he(i)) throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${Ee.join(", ")}; got ${d(i)}`);
|
|
244
|
-
if (!o) throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${d(i)} with linkCards ${d(o)}`);
|
|
245
|
-
return Object.freeze({ ...s, linkCardSize: i });
|
|
246
|
-
}, Qe = (e) => {
|
|
247
|
-
const t = new Map(
|
|
248
|
-
S(
|
|
249
|
-
"defaultTreeSettings",
|
|
250
|
-
e,
|
|
251
|
-
x.map((n) => n.key)
|
|
252
|
-
)
|
|
253
|
-
);
|
|
254
|
-
if (t.size === 0) return q;
|
|
255
|
-
const r = { ...q };
|
|
256
|
-
for (const n of x) {
|
|
257
|
-
if (!t.has(n.key)) continue;
|
|
258
|
-
const o = t.get(n.key), s = n.values;
|
|
259
|
-
if (!s.includes(o)) throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${s.map(d).join(", ")}; got ${d(o)}`);
|
|
260
|
-
r[n.key] = o;
|
|
261
|
-
}
|
|
262
|
-
return Object.freeze(r);
|
|
263
|
-
}, et = (e) => {
|
|
264
|
-
if (e === null || typeof e != "object") throw new TypeError("[markdown-explorer] the explorer configuration must be an object");
|
|
265
|
-
te("basePath", e.basePath), te("dataPath", e.dataPath);
|
|
266
|
-
const t = Ze(e.views);
|
|
267
|
-
if ((/* @__PURE__ */ new Set([t.tree, t.multi, t.single])).size !== 3)
|
|
268
|
-
throw new RangeError(`[markdown-explorer] the view slugs must differ; got ${JSON.stringify(t)}`);
|
|
269
|
-
if (e.dataPath === e.basePath) throw new RangeError("[markdown-explorer] dataPath must differ from basePath");
|
|
270
|
-
if (e.dataPath.startsWith(`${e.basePath}/`)) {
|
|
271
|
-
const a = e.dataPath.slice(e.basePath.length + 1).split("/")[0];
|
|
272
|
-
if (a === t.tree || a === t.multi || a === t.single)
|
|
273
|
-
throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug under basePath; got ${JSON.stringify(e.dataPath)}`);
|
|
274
|
-
}
|
|
275
|
-
ze(e.settingsCookie);
|
|
276
|
-
const r = e.iframeHosts ?? [];
|
|
277
|
-
if (!Array.isArray(r) || r.some((a) => typeof a != "string" || !Be.test(a)))
|
|
278
|
-
throw new RangeError(`[markdown-explorer] iframeHosts must be lowercase host names without scheme, port or path; got ${JSON.stringify(r)}`);
|
|
279
|
-
const n = Object.fromEntries(S("multiView", e.multiView, ["maxPanels", "columns"])), o = Object.fromEntries(S("expandAll", e.expandAll, ["maxFolders", "maxDepth"])), s = Object.fromEntries(S("revealDocument", e.revealDocument, ["maxDepth"])), i = e.documentStyles ?? Se;
|
|
280
|
-
if (!Array.isArray(i) || i.length === 0) throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");
|
|
281
|
-
const l = /* @__PURE__ */ new Set();
|
|
282
|
-
for (const a of i) {
|
|
283
|
-
if (a === null || typeof a != "object" || typeof a.name != "string" || a.name.trim() === "" || typeof a.className != "string")
|
|
284
|
-
throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");
|
|
285
|
-
if (l.has(a.name)) throw new RangeError(`[markdown-explorer] document style names must be unique; ${JSON.stringify(a.name)} repeats`);
|
|
286
|
-
l.add(a.name);
|
|
287
|
-
}
|
|
288
|
-
return Object.freeze({
|
|
289
|
-
basePath: e.basePath,
|
|
290
|
-
dataPath: e.dataPath,
|
|
291
|
-
settingsCookie: e.settingsCookie,
|
|
292
|
-
views: t,
|
|
293
|
-
multiView: Object.freeze({
|
|
294
|
-
maxPanels: R("multiView.maxPanels", n.maxPanels, Ue),
|
|
295
|
-
columns: R("multiView.columns", n.columns, Je)
|
|
296
|
-
}),
|
|
297
|
-
expandAll: Object.freeze({
|
|
298
|
-
maxFolders: R("expandAll.maxFolders", o.maxFolders, Xe),
|
|
299
|
-
maxDepth: R("expandAll.maxDepth", o.maxDepth, Ge)
|
|
300
|
-
}),
|
|
301
|
-
revealDocument: Object.freeze({ maxDepth: R("revealDocument.maxDepth", s.maxDepth, We) }),
|
|
302
|
-
documentStyles: Object.freeze(i.map((a) => Object.freeze({ name: a.name, className: a.className }))),
|
|
303
|
-
iframeHosts: Object.freeze([...new Set(r)]),
|
|
304
|
-
embeds: Ye(e.embeds, e.dataPath),
|
|
305
|
-
defaultTreeSettings: Qe(e.defaultTreeSettings)
|
|
306
|
-
});
|
|
307
|
-
}, Ht = (e) => {
|
|
308
|
-
const t = e.embeds;
|
|
309
|
-
if (!J(t)) throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${d(t)}`);
|
|
310
|
-
if (Object.hasOwn(t, "linkCards"))
|
|
311
|
-
throw new RangeError(`[markdown-explorer] config.embeds.linkCards is an option of defineExplorerConfig, not a key of the embeds it resolves; pass the option to defineExplorerConfig (got linkCards ${d(t.linkCards)})`);
|
|
312
|
-
const { linkCardEndpoint: r, ...n } = t, o = et({ ...e, embeds: { ...n, linkCards: r !== null } });
|
|
313
|
-
if (o.embeds.linkCardEndpoint !== r)
|
|
314
|
-
throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${d(o.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${d(r)}`);
|
|
315
|
-
return o;
|
|
316
|
-
}, tt = (e) => typeof e == "string" && qe.test(e), Kt = (e, t) => {
|
|
317
|
-
if (e === null || typeof e != "object") throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${d(e)}`);
|
|
318
|
-
if (!Array.isArray(t) || t.length === 0) throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${d(t)}`);
|
|
319
|
-
for (const r of t)
|
|
320
|
-
if (!tt(r)) throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${d(r)}`);
|
|
321
|
-
if (new Set(t).size !== t.length) throw new RangeError(`[markdown-explorer] source ids must be unique; got ${JSON.stringify(t)}`);
|
|
322
|
-
return Object.freeze({ ...e, sourceIds: Object.freeze([...t]) });
|
|
323
|
-
}, qt = (e) => e.documentStyles.map((t) => t.name), c = Object.freeze({
|
|
324
|
-
source: "source",
|
|
325
|
-
doc: "doc",
|
|
326
|
-
maximized: "maximized",
|
|
327
|
-
style: "style",
|
|
328
|
-
align: "align",
|
|
329
|
-
showToc: "showToc",
|
|
330
|
-
showStyle: "showStyle",
|
|
331
|
-
showAlign: "showAlign",
|
|
332
|
-
padding: "padding",
|
|
333
|
-
width: "width",
|
|
334
|
-
maxWidth: "maxWidth",
|
|
335
|
-
markup: "markup"
|
|
336
|
-
}), ae = "true", v = "/", re = ".data", le = 256, ce = /^\d+(?:\.\d+)?$/u, U = /^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u, de = Object.freeze(["showToc", "showStyle", "showAlign"]), ne = (e) => {
|
|
337
|
-
const t = encodeURIComponent(e.replaceAll("%", "%25"));
|
|
338
|
-
return t.endsWith(re) ? `${t.slice(0, -re.length)}%2Edata` : t;
|
|
339
|
-
}, rt = (e) => e.replaceAll("%25", "%"), me = (e) => {
|
|
340
|
-
const { sourceIds: t } = e;
|
|
341
|
-
if (t === void 0) throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");
|
|
342
|
-
return t;
|
|
343
|
-
}, nt = (e, t, r) => {
|
|
344
|
-
const n = r.getAll(c.source);
|
|
345
|
-
if (n.length === 0) return t;
|
|
346
|
-
const [o] = n;
|
|
347
|
-
return n.length > 1 || o === void 0 || o === t || !e.includes(o) ? null : o;
|
|
348
|
-
}, ot = (e, t) => {
|
|
349
|
-
const r = t.get(c.style), n = t.get(c.align);
|
|
350
|
-
return {
|
|
351
|
-
...r !== null && e.documentStyles.some((o) => o.name === r) ? { style: r } : {},
|
|
352
|
-
...n !== null && N.includes(n) ? { align: n } : {}
|
|
353
|
-
};
|
|
354
|
-
}, ue = (e) => Number.isFinite(e) && e >= 0 && e <= le && ce.test(String(e)), st = (e) => {
|
|
355
|
-
const t = e.get(c.padding), r = t !== null && ce.test(t) ? Number(t) : Number.NaN, n = e.get(c.width), o = e.get(c.maxWidth);
|
|
356
|
-
return {
|
|
357
|
-
...e.get(c.showToc) === "false" ? { showToc: !1 } : {},
|
|
358
|
-
...e.get(c.showStyle) === "false" ? { showStyle: !1 } : {},
|
|
359
|
-
...e.get(c.showAlign) === "false" ? { showAlign: !1 } : {},
|
|
360
|
-
...ue(r) ? { padding: r } : {},
|
|
361
|
-
...n !== null && U.test(n) ? { width: n } : {},
|
|
362
|
-
...o !== null && U.test(o) ? { maxWidth: o } : {}
|
|
363
|
-
};
|
|
364
|
-
}, it = (e, t) => [...new Set(t.filter(A))].slice(0, e.multiView.maxPanels), at = (e, t, r, n) => {
|
|
365
|
-
for (const s of t) G(s);
|
|
366
|
-
if (new Set(t).size !== t.length) throw new RangeError(`[markdown-explorer] multi-view documents must each appear once; got ${String(t.length)} with repeats`);
|
|
367
|
-
if (t.length > e.multiView.maxPanels) throw new RangeError(`[markdown-explorer] the multi view opens at most ${String(e.multiView.maxPanels)} documents; got ${String(t.length)}`);
|
|
368
|
-
if (r !== null && !t.includes(r)) throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${JSON.stringify(r.slice(0, 80))}`);
|
|
369
|
-
if (new Set(n).size !== n.length) throw new RangeError(`[markdown-explorer] the documents shown as written must each appear once; got ${String(n.length)} with repeats`);
|
|
370
|
-
const o = n.find((s) => !t.includes(s));
|
|
371
|
-
if (o !== void 0) throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${JSON.stringify(o.slice(0, 80))}`);
|
|
372
|
-
}, G = (e) => {
|
|
373
|
-
if (!A(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(String(e).slice(0, 80))}`);
|
|
374
|
-
return e;
|
|
375
|
-
}, lt = (e) => {
|
|
376
|
-
if (G(e).endsWith(v)) throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${JSON.stringify(e.slice(0, 80))}`);
|
|
377
|
-
return e;
|
|
378
|
-
}, ct = (e, t) => {
|
|
379
|
-
if (t.style !== void 0 && !e.documentStyles.some((r) => r.name === t.style))
|
|
380
|
-
throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map((r) => JSON.stringify(r.name)).join(", ")}); got ${JSON.stringify(t.style)}`);
|
|
381
|
-
if (t.align !== void 0 && !N.includes(t.align))
|
|
382
|
-
throw new RangeError(`[markdown-explorer] overrides.align must be one of ${N.join(", ")}; got ${JSON.stringify(t.align)}`);
|
|
383
|
-
}, dt = (e) => {
|
|
384
|
-
for (const t of de)
|
|
385
|
-
if (e[t] !== void 0 && typeof e[t] != "boolean") throw new RangeError(`[markdown-explorer] embed.${t} must be a boolean; got ${JSON.stringify(e[t])}`);
|
|
386
|
-
if (e.padding !== void 0 && !ue(e.padding)) throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(le)} px in plain decimal digits; got ${String(e.padding)}`);
|
|
387
|
-
for (const t of ["width", "maxWidth"]) {
|
|
388
|
-
const r = e[t];
|
|
389
|
-
if (r !== void 0 && !U.test(r)) throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${JSON.stringify(r)}`);
|
|
390
|
-
}
|
|
391
|
-
}, mt = (e, t) => {
|
|
392
|
-
const r = new URLSearchParams();
|
|
393
|
-
let n = `${e.basePath}/${e.views[t.view]}`;
|
|
394
|
-
if (t.view === "multi") {
|
|
395
|
-
const s = t.docs ?? [], i = t.maximized ?? null, l = t.markup ?? [];
|
|
396
|
-
at(e, s, i, l);
|
|
397
|
-
for (const a of s) r.append(c.doc, a);
|
|
398
|
-
i !== null && r.set(c.maximized, i);
|
|
399
|
-
for (const a of s) l.includes(a) && r.append(c.markup, a);
|
|
400
|
-
} else {
|
|
401
|
-
const s = t.doc ?? null, i = t.view === "tree" ? t.folder ?? null : null;
|
|
402
|
-
if (s !== null && i !== null) throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");
|
|
403
|
-
s !== null && (n += `/${ne(lt(s))}`), i !== null && (n += `/${ne(`${G(i)}${v}`)}`);
|
|
404
|
-
}
|
|
405
|
-
if (t.source !== void 0) {
|
|
406
|
-
const s = me(e);
|
|
407
|
-
if (!s.includes(t.source)) throw new RangeError(`[markdown-explorer] unknown source ${JSON.stringify(t.source)}; expected one of ${s.join(", ")}`);
|
|
408
|
-
t.source !== s[0] && r.set(c.source, t.source);
|
|
409
|
-
}
|
|
410
|
-
if (t.view !== "multi" && t.overrides !== void 0 && (ct(e, t.overrides), t.overrides.style !== void 0 && r.set(c.style, t.overrides.style), t.overrides.align !== void 0 && r.set(c.align, t.overrides.align)), t.view !== "multi" && t.markup === !0) {
|
|
411
|
-
if (!(t.doc !== void 0 && t.doc !== null || t.view === "tree" && t.folder !== void 0 && t.folder !== null)) throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");
|
|
412
|
-
r.set(c.markup, ae);
|
|
413
|
-
}
|
|
414
|
-
if (t.view === "single" && t.embed !== void 0) {
|
|
415
|
-
const { embed: s } = t;
|
|
416
|
-
dt(s);
|
|
417
|
-
for (const i of de) s[i] === !1 && r.set(c[i], "false");
|
|
418
|
-
s.padding !== void 0 && r.set(c.padding, String(s.padding)), s.width !== void 0 && r.set(c.width, s.width), s.maxWidth !== void 0 && r.set(c.maxWidth, s.maxWidth);
|
|
419
|
-
}
|
|
420
|
-
const o = r.toString();
|
|
421
|
-
return o === "" ? n : `${n}?${o}`;
|
|
422
|
-
}, ut = (e, t) => Object.keys(e.views).find((r) => e.views[r] === t), Bt = (e, t, r) => {
|
|
423
|
-
const n = me(e), [o] = n;
|
|
424
|
-
if (o === void 0) throw new RangeError("[markdown-explorer] the configuration has no source");
|
|
425
|
-
const s = nt(n, o, r), i = s === null ? o : s, l = (m) => ({ kind: "redirect", href: mt(e, m), location: m }), a = () => l({ view: "tree", source: i, doc: null, folder: null, overrides: {}, markup: !1 });
|
|
426
|
-
if (t === void 0 || t === "") return a();
|
|
427
|
-
const b = t.indexOf("/"), $ = b < 0 ? t : t.slice(0, b), M = b < 0 ? null : t.slice(b + 1), p = ut(e, $);
|
|
428
|
-
if (p === void 0) return a();
|
|
429
|
-
if (p === "multi") {
|
|
430
|
-
const m = r.getAll(c.doc), E = it(e, m), C = r.getAll(c.maximized), [L] = C, D = C.length === 1 && L !== void 0 && E.includes(L) ? L : null, z = r.getAll(c.markup), T = E.filter((k) => z.includes(k)), fe = T.length === z.length && T.every((k, j) => k === z[j]);
|
|
431
|
-
return M === null && s !== null && E.length === m.length && E.every((k, j) => k === m[j]) && (C.length === 0 || D !== null) && fe ? { kind: "location", location: { view: "multi", source: i, docs: E, maximized: D, markup: T } } : l({ view: "multi", source: i, docs: E, maximized: D, markup: T });
|
|
432
|
-
}
|
|
433
|
-
const _ = M === null ? null : rt(M), u = _?.endsWith(v) === !0 ? _.slice(0, -v.length) : null, f = _ !== null && u === null ? _ : null;
|
|
434
|
-
if (f !== null && !A(f) || u !== null && !A(u)) return a();
|
|
435
|
-
const y = ot(e, r), O = (f !== null || u !== null) && r.get(c.markup) === ae;
|
|
436
|
-
if (p === "single") {
|
|
437
|
-
if (u !== null) return l({ view: "tree", source: i, doc: null, folder: u, overrides: y, markup: O });
|
|
438
|
-
if (f === null) return a();
|
|
439
|
-
const m = st(r);
|
|
440
|
-
return s === null ? l({ view: p, source: i, doc: f, overrides: y, embed: m, markup: O }) : { kind: "location", location: { view: p, source: i, doc: f, overrides: y, embed: m, markup: O } };
|
|
441
|
-
}
|
|
442
|
-
return s === null ? l({ view: p, source: i, doc: f, folder: u, overrides: y, markup: O }) : { kind: "location", location: { view: p, source: i, doc: f, folder: u, overrides: y, markup: O } };
|
|
443
|
-
};
|
|
444
|
-
export {
|
|
445
|
-
et as $,
|
|
446
|
-
Nt as A,
|
|
447
|
-
Jt as B,
|
|
448
|
-
It as C,
|
|
449
|
-
ht as D,
|
|
450
|
-
zt as E,
|
|
451
|
-
Pt as F,
|
|
452
|
-
jt as G,
|
|
453
|
-
g as H,
|
|
454
|
-
Ot as I,
|
|
455
|
-
St as J,
|
|
456
|
-
yt as K,
|
|
457
|
-
kt as L,
|
|
458
|
-
B as M,
|
|
459
|
-
I as N,
|
|
460
|
-
bt as O,
|
|
461
|
-
vt as P,
|
|
462
|
-
Wt as Q,
|
|
463
|
-
Mt as R,
|
|
464
|
-
Lt as S,
|
|
465
|
-
q as T,
|
|
466
|
-
ee as U,
|
|
467
|
-
Ge as V,
|
|
468
|
-
Xe as W,
|
|
469
|
-
Ae as X,
|
|
470
|
-
Je as Y,
|
|
471
|
-
Ue as Z,
|
|
472
|
-
We as _,
|
|
473
|
-
Me as a,
|
|
474
|
-
At as b,
|
|
475
|
-
it as c,
|
|
476
|
-
Ut as d,
|
|
477
|
-
mt as e,
|
|
478
|
-
qt as f,
|
|
479
|
-
Bt as g,
|
|
480
|
-
Xt as h,
|
|
481
|
-
tt as i,
|
|
482
|
-
J as j,
|
|
483
|
-
Vt as k,
|
|
484
|
-
Ft as l,
|
|
485
|
-
$t as m,
|
|
486
|
-
Pe as n,
|
|
487
|
-
Rt as o,
|
|
488
|
-
Gt as p,
|
|
489
|
-
xt as q,
|
|
490
|
-
Ht as r,
|
|
491
|
-
Ct as s,
|
|
492
|
-
$e as t,
|
|
493
|
-
ie as u,
|
|
494
|
-
Et as v,
|
|
495
|
-
Kt as w,
|
|
496
|
-
_t as x,
|
|
497
|
-
Tt as y,
|
|
498
|
-
Dt as z
|
|
499
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const y=require("@aiquants/markdown/embeds"),N=require("@aiquants/markdown/viewer-settings"),I=require("./dataRoute-vXGZMVB-.cjs"),M=e=>{if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},A=new Intl.Collator("en",{numeric:!0,sensitivity:"variant"}),Ie=/^readme(?:\.|$)/iu,Z=/^readme(?:\.[^.]*)?$/iu,Y=Object.freeze(["md","markdown","mdx","txt",""]),Ae=e=>Ie.test(e),X=e=>e.type==="file"&&Ae(e.name),Q=e=>{const t=e.lastIndexOf("."),r=Y.indexOf(t<0?"":e.slice(t+1).toLowerCase());return r<0?Y.length:r},ke=(e,t)=>{const r=+!Z.test(e.name)-+!Z.test(t.name);if(r!==0)return r;const n=Q(e.name)-Q(t.name);if(n!==0)return n;const o=A.compare(e.name,t.name);return o!==0?o:A.compare(e.path,t.path)},Pe=e=>{let t=null;for(const r of e)X(r)&&(t===null||ke(r,t)<0)&&(t=r);return t===null?null:t.path},G=Object.freeze({sortMode:"native",folderPlacement:"mixed",readmePlacement:"mixed",selectionMode:"single",doubleClickAction:"recursive",expandIconSize:8,alwaysExpanded:!1,revealDocument:!1,removeRootIndent:!1,lines:!0,expandIcons:!0,directoryIcons:!0,fileIcons:!0}),Le=[!0,!1],Ce=(e,t)=>t?e.settingOn:e.settingOff,p=(e,t)=>({key:e,labelKey:t,values:Le,formatValue:Ce,requiresItemSelection:!1}),Me=Object.freeze({native:e=>e.sortNative,asc:e=>e.sortAscending,desc:e=>e.sortDescending,oldest:e=>e.sortOldest,newest:e=>e.sortNewest}),_=Object.freeze([{key:"sortMode",labelKey:"settingSortMode",values:["native","asc","desc","oldest","newest"],formatValue:(e,t)=>Me[t](e),requiresItemSelection:!1},{key:"folderPlacement",labelKey:"settingFolderPlacement",values:["mixed","first","last"],formatValue:(e,t)=>t==="mixed"?e.folderPlacementMixed:t==="first"?e.folderPlacementFirst:e.folderPlacementLast,requiresItemSelection:!1},{key:"readmePlacement",labelKey:"settingReadmePlacement",values:["mixed","first","last"],formatValue:(e,t)=>t==="mixed"?e.readmePlacementMixed:t==="first"?e.readmePlacementFirst:e.readmePlacementLast,requiresItemSelection:!1},{key:"selectionMode",labelKey:"settingSelectionMode",values:["single","multiple","none"],formatValue:(e,t)=>t==="single"?e.selectionSingle:t==="multiple"?e.selectionMultiple:e.selectionNone,requiresItemSelection:!0},{key:"doubleClickAction",labelKey:"settingDoubleClick",values:["recursive","toggle"],formatValue:(e,t)=>t==="recursive"?e.doubleClickRecursive:e.doubleClickToggle,requiresItemSelection:!1},{key:"expandIconSize",labelKey:"settingExpandIconSize",values:[8,13,5],formatValue:(e,t)=>e.expandIconSizeValue(t),requiresItemSelection:!1},p("alwaysExpanded","settingAlwaysExpanded"),p("revealDocument","settingRevealDocument"),p("removeRootIndent","settingRemoveRootIndent"),p("lines","settingTreeLines"),p("expandIcons","settingExpandIcons"),p("directoryIcons","settingDirectoryIcons"),p("fileIcons","settingFileIcons")]),ve=e=>e?_:_.filter(t=>!t.requiresItemSelection),se=e=>{const t=_.find(r=>r.key===e);if(t===void 0)throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);return t},De=(e,t)=>{const r=se(t).values,n=r[(r.indexOf(e[t])+1)%r.length];return{...e,[t]:n}},$e=(e,t,r)=>se(r).formatValue(e,t[r]),ae=2,W=Object.freeze({}),K=(e,t)=>Object.freeze(Object.fromEntries(_.filter(r=>t(r,e[r.key])).map(r=>[r.key,e[r.key]]))),ee="directoriesFirst",ze=e=>{if(!Object.hasOwn(e,ee))return e;const{[ee]:t,...r}=e;return Object.hasOwn(r,"folderPlacement")||typeof t!="boolean"?r:{...r,folderPlacement:t?"first":"mixed"}},je=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return W;const t=e;return t.version!==ae||t.settings===null||typeof t.settings!="object"||Array.isArray(t.settings)?W:K(ze(t.settings),(r,n)=>r.values.includes(n))},Fe=(e,t)=>{const r=K(t,(n,o)=>o!==void 0&&o!==e[n.key]);return Object.keys(r).length===0?e:Object.freeze({...e,...r})},Ve=(e,t,r,n)=>K({...e,[t]:r},(o,i)=>i!==void 0&&!(o.key===t&&i===n[t])),Ue=e=>JSON.stringify({version:ae,settings:e}),Xe=(e,t,r)=>e===void 0||t===void 0?e===t?0:e===void 0?1:-1:r*(e-t),Ge=e=>{const{sortMode:t,folderPlacement:r,readmePlacement:n}=e;if(t==="native"&&r==="mixed"&&n==="mixed")return;const o=(i,s)=>{const l=A.compare(i.name,s.name);return l!==0?l:A.compare(i.path,s.path)};return(i,s)=>{if(r!=="mixed"&&i.type!==s.type)return i.type==="directory"==(r==="first")?-1:1;if(n!=="mixed"){const a=X(i);if(a!==X(s))return a===(n==="first")?-1:1}if(t==="native")return 0;if(t==="asc")return o(i,s);if(t==="desc")return-o(i,s);const l=Xe(i.modifiedAt,s.modifiedAt,t==="oldest"?1:-1);return l!==0?l:o(i,s)}},u=(1+Math.sqrt(5))/2,We=100/u**3,Je=100/u**4,q=100/u**2,le=13,He=16,Ke=Object.freeze({gripThickness:5,gripLength:34,barThickness:2,barLength:21}),qe=Object.freeze([89,144,233,377]),ce=44,Be=ce,Ze=24,Ye=1/u,Qe=1/u**3,et="40ch",tt=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${String(e)}`)},de=e=>(tt(e),le*e),rt=e=>de(e)*u**2,nt=233,ot=50,me=100/u**3,it=100-me,st=qe[0],g=(e,t)=>{if(!Number.isFinite(t)||t<0)throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${String(t)}`)},at=({trackInlineSize:e,gap:t,minColumnInlineSize:r,logicalColumns:n})=>{if(g("trackInlineSize",e),g("gap",t),!Number.isFinite(r)||r<=0)throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${String(r)}`);if(!Number.isInteger(n)||n<1)throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${String(n)}`);const o=Math.floor((e+t)/(r+t));return Math.min(n,Math.max(1,o))},lt=(e,t)=>{const{trackInlineSize:r,gap:n,minColumnInlineSize:o,logicalColumns:i}=t;if(!([r,n,o].every(Number.isFinite)&&r>0&&n>=0&&o>0))return e;const l=at(t);if(e===null||l===e)return l;const a=Math.min(i,Math.max(1,e));if(l>a){const v=(a+1)*o+a*n+n/u;return r>=v?l:a}return r>=a*o+(a-1)*n?a:l},ct=(e,t)=>{if(!(Number.isInteger(e)&&Number.isInteger(t))||t<1||t>e)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${String(t)}`);return Array.from({length:t},(r,n)=>[Math.floor(n*e/t),Math.floor((n+1)*e/t)])},dt=(e,t,r)=>{if(g("surfaceInlineSize",e),g("handlePixels",r),!Number.isFinite(t)||t<=0)throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${String(t)}`);return e>=2*t+r?"beside":"stacked"},U=(e,t,r)=>Math.max(t,Math.min(e,r)),te=(e,t,r,n)=>{const o=(U(e,0,r)+U(t,0,r))/2;return U(o-n/2,0,r-n)},mt=(e,t,r)=>{for(const[n,o]of Object.entries(e))if(!Number.isFinite(o))throw new RangeError(`[markdown-explorer] anchor.${n} must be a finite number; got ${String(o)}`);return g("marginBox.width",t.width),g("marginBox.height",t.height),g("viewport.width",r.width),g("viewport.height",r.height),{left:te(e.left,e.right,r.width,t.width),top:te(e.top,e.bottom,r.height,t.height)}},ut=31536e3,ft=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u,Et=e=>{if(typeof e!="string"||!ft.test(e))throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${JSON.stringify(e)}`)},re=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=q,gt=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))return{};const r=e,{treeExplorer:n,multiExplorer:o,style:i,align:s}=r;return{...re(n)?{treeExplorer:n}:{},...re(o)?{multiExplorer:o}:{},...typeof i=="string"&&t.includes(i)?{style:i}:{},...typeof s=="string"&&N.CONTENT_ALIGNS.includes(s)?{align:s}:{}}},wt=(e,t)=>{if(e!==null)for(const r of e.split(";")){const n=r.indexOf("=");if(!(n<0)&&r.slice(0,n).trim()===t)return r.slice(n+1).trim()}},pt=(e,t)=>{if(e===void 0||e==="")return{};try{return gt(JSON.parse(decodeURIComponent(e)),t)}catch{return{}}},L=100,St=Math.floor(q*L)/L,ht=e=>{const t=r=>Math.min(St,Math.max(1,Math.round(r*L))/L);return encodeURIComponent(JSON.stringify({...e.treeExplorer===void 0?{}:{treeExplorer:t(e.treeExplorer)},...e.multiExplorer===void 0?{}:{multiExplorer:t(e.multiExplorer)},...e.style===void 0?{}:{style:e.style},...e.align===void 0?{}:{align:e.align}}))},_t=(e,t,r)=>`${e}=${ht(t)}; Path=/; Max-Age=${String(ut)}; SameSite=Lax${r?"; Secure":""}`,J=Object.freeze({tree:"tree",multi:"multi",single:"single"}),ue=Object.freeze({default:12,min:1,max:64}),fe=Object.freeze({default:4,min:1,max:6}),Ee=Object.freeze({default:500,min:1,max:1e4}),ge=Object.freeze({default:16,min:1,max:64}),we=Object.freeze({default:16,min:1,max:64}),xt=/^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u,Ot=/^[A-Za-z0-9][A-Za-z0-9_-]*$/u,Tt=/^[a-z0-9][a-z0-9-]*$/u,bt=/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u,ne=(e,t)=>{if(typeof t!="string")throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${typeof t}`);if(!xt.test(t)||t.split("/").some(r=>r==="."||r===".."))throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", and use only letters, digits and "._~-" in each segment; got ${JSON.stringify(t)}`)},d=e=>typeof e=="string"?JSON.stringify(e):typeof e=="bigint"?`${String(e)}n`:Object.is(e,-0)?"-0":typeof e=="function"?"a function":Array.isArray(e)?"an array":e!==null&&typeof e=="object"?M(e)?"a plain object":`a non-plain object (${Object.prototype.toString.call(e)})`:String(e),h=(e,t,r)=>{if(t===void 0)return[];if(!M(t))throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${d(t)}`);const n=Object.entries(t);for(const[o]of n)if(!r.includes(o))throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${r.join(", ")}`);return n.filter(([,o])=>o!==void 0)},yt=e=>{const t={...J};for(const[r,n]of h("views",e,Object.keys(J)))t[r]=n;for(const[r,n]of Object.entries(t))if(typeof n!="string"||!Ot.test(n))throw new RangeError(`[markdown-explorer] views.${r} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${JSON.stringify(n)}`);return Object.freeze(t)},R=(e,t,r)=>{if(t===void 0)return r.default;if(typeof t!="number"||!Number.isInteger(t)||t<r.min||t>r.max)throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(r.min)}..${String(r.max)}; got ${d(t)}`);return t},Rt=(e,t)=>{const r=new Map(h("embeds",e,["providers","linkCards","linkCardSize"]));if(r.size===0)return y.NO_EMBEDS;const n=r.has("providers")?r.get("providers"):[];if(!Array.isArray(n))throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${d(n)}`);for(const l of n)if(!y.isEmbedProviderId(l))throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${y.EMBED_PROVIDER_IDS.join(", ")}; got ${d(l)}`);const o=r.has("linkCards")?r.get("linkCards"):!1;if(typeof o!="boolean")throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${d(o)}`);const i={providers:Object.freeze([...new Set(n)]),linkCardEndpoint:o?I.explorerLinkCardEndpoint(t):null};if(!r.has("linkCardSize"))return Object.freeze(i);const s=r.get("linkCardSize");if(!y.isLinkCardSize(s))throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${y.LINK_CARD_SIZES.join(", ")}; got ${d(s)}`);if(!o)throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${d(s)} with linkCards ${d(o)}`);return Object.freeze({...i,linkCardSize:s})},Nt=e=>{const t=new Map(h("defaultTreeSettings",e,_.map(n=>n.key)));if(t.size===0)return G;const r={...G};for(const n of _){if(!t.has(n.key))continue;const o=t.get(n.key),i=n.values;if(!i.includes(o))throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${i.map(d).join(", ")}; got ${d(o)}`);r[n.key]=o}return Object.freeze(r)},pe=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the explorer configuration must be an object");ne("basePath",e.basePath),ne("dataPath",e.dataPath);const t=yt(e.views);if(new Set([t.tree,t.multi,t.single]).size!==3)throw new RangeError(`[markdown-explorer] the view slugs must differ; got ${JSON.stringify(t)}`);if(e.dataPath===e.basePath)throw new RangeError("[markdown-explorer] dataPath must differ from basePath");if(e.dataPath.startsWith(`${e.basePath}/`)){const a=e.dataPath.slice(e.basePath.length+1).split("/")[0];if(a===t.tree||a===t.multi||a===t.single)throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug under basePath; got ${JSON.stringify(e.dataPath)}`)}Et(e.settingsCookie);const r=e.iframeHosts??[];if(!Array.isArray(r)||r.some(a=>typeof a!="string"||!bt.test(a)))throw new RangeError(`[markdown-explorer] iframeHosts must be lowercase host names without scheme, port or path; got ${JSON.stringify(r)}`);const n=Object.fromEntries(h("multiView",e.multiView,["maxPanels","columns"])),o=Object.fromEntries(h("expandAll",e.expandAll,["maxFolders","maxDepth"])),i=Object.fromEntries(h("revealDocument",e.revealDocument,["maxDepth"])),s=e.documentStyles??N.DEFAULT_MARKDOWN_STYLES;if(!Array.isArray(s)||s.length===0)throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");const l=new Set;for(const a of s){if(a===null||typeof a!="object"||typeof a.name!="string"||a.name.trim()===""||typeof a.className!="string")throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");if(l.has(a.name))throw new RangeError(`[markdown-explorer] document style names must be unique; ${JSON.stringify(a.name)} repeats`);l.add(a.name)}return Object.freeze({basePath:e.basePath,dataPath:e.dataPath,settingsCookie:e.settingsCookie,views:t,multiView:Object.freeze({maxPanels:R("multiView.maxPanels",n.maxPanels,ue),columns:R("multiView.columns",n.columns,fe)}),expandAll:Object.freeze({maxFolders:R("expandAll.maxFolders",o.maxFolders,Ee),maxDepth:R("expandAll.maxDepth",o.maxDepth,ge)}),revealDocument:Object.freeze({maxDepth:R("revealDocument.maxDepth",i.maxDepth,we)}),documentStyles:Object.freeze(s.map(a=>Object.freeze({name:a.name,className:a.className}))),iframeHosts:Object.freeze([...new Set(r)]),embeds:Rt(e.embeds,e.dataPath),defaultTreeSettings:Nt(e.defaultTreeSettings)})},It=e=>{const t=e.embeds;if(!M(t))throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${d(t)}`);if(Object.hasOwn(t,"linkCards"))throw new RangeError(`[markdown-explorer] config.embeds.linkCards is an option of defineExplorerConfig, not a key of the embeds it resolves; pass the option to defineExplorerConfig (got linkCards ${d(t.linkCards)})`);const{linkCardEndpoint:r,...n}=t,o=pe({...e,embeds:{...n,linkCards:r!==null}});if(o.embeds.linkCardEndpoint!==r)throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${d(o.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${d(r)}`);return o},Se=e=>typeof e=="string"&&Tt.test(e),At=(e,t)=>{if(e===null||typeof e!="object")throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${d(e)}`);if(!Array.isArray(t)||t.length===0)throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${d(t)}`);for(const r of t)if(!Se(r))throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${d(r)}`);if(new Set(t).size!==t.length)throw new RangeError(`[markdown-explorer] source ids must be unique; got ${JSON.stringify(t)}`);return Object.freeze({...e,sourceIds:Object.freeze([...t])})},kt=e=>e.documentStyles.map(t=>t.name),c=Object.freeze({source:"source",doc:"doc",maximized:"maximized",style:"style",align:"align",showToc:"showToc",showStyle:"showStyle",showAlign:"showAlign",padding:"padding",width:"width",maxWidth:"maxWidth",markup:"markup"}),he="true",C="/",oe=".data",_e=256,xe=/^\d+(?:\.\d+)?$/u,H=/^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u,Oe=Object.freeze(["showToc","showStyle","showAlign"]),ie=e=>{const t=encodeURIComponent(e.replaceAll("%","%25"));return t.endsWith(oe)?`${t.slice(0,-oe.length)}%2Edata`:t},Pt=e=>e.replaceAll("%25","%"),Te=e=>{const{sourceIds:t}=e;if(t===void 0)throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");return t},Lt=(e,t,r)=>{const n=r.getAll(c.source);if(n.length===0)return t;const[o]=n;return n.length>1||o===void 0||o===t||!e.includes(o)?null:o},Ct=(e,t)=>{const r=t.get(c.style),n=t.get(c.align);return{...r!==null&&e.documentStyles.some(o=>o.name===r)?{style:r}:{},...n!==null&&N.CONTENT_ALIGNS.includes(n)?{align:n}:{}}},be=e=>Number.isFinite(e)&&e>=0&&e<=_e&&xe.test(String(e)),Mt=e=>{const t=e.get(c.padding),r=t!==null&&xe.test(t)?Number(t):Number.NaN,n=e.get(c.width),o=e.get(c.maxWidth);return{...e.get(c.showToc)==="false"?{showToc:!1}:{},...e.get(c.showStyle)==="false"?{showStyle:!1}:{},...e.get(c.showAlign)==="false"?{showAlign:!1}:{},...be(r)?{padding:r}:{},...n!==null&&H.test(n)?{width:n}:{},...o!==null&&H.test(o)?{maxWidth:o}:{}}},ye=(e,t)=>[...new Set(t.filter(I.isAcceptableDocumentPath))].slice(0,e.multiView.maxPanels),vt=(e,t,r,n)=>{for(const i of t)B(i);if(new Set(t).size!==t.length)throw new RangeError(`[markdown-explorer] multi-view documents must each appear once; got ${String(t.length)} with repeats`);if(t.length>e.multiView.maxPanels)throw new RangeError(`[markdown-explorer] the multi view opens at most ${String(e.multiView.maxPanels)} documents; got ${String(t.length)}`);if(r!==null&&!t.includes(r))throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${JSON.stringify(r.slice(0,80))}`);if(new Set(n).size!==n.length)throw new RangeError(`[markdown-explorer] the documents shown as written must each appear once; got ${String(n.length)} with repeats`);const o=n.find(i=>!t.includes(i));if(o!==void 0)throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${JSON.stringify(o.slice(0,80))}`)},B=e=>{if(!I.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(String(e).slice(0,80))}`);return e},Dt=e=>{if(B(e).endsWith(C))throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${JSON.stringify(e.slice(0,80))}`);return e},$t=(e,t)=>{if(t.style!==void 0&&!e.documentStyles.some(r=>r.name===t.style))throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map(r=>JSON.stringify(r.name)).join(", ")}); got ${JSON.stringify(t.style)}`);if(t.align!==void 0&&!N.CONTENT_ALIGNS.includes(t.align))throw new RangeError(`[markdown-explorer] overrides.align must be one of ${N.CONTENT_ALIGNS.join(", ")}; got ${JSON.stringify(t.align)}`)},zt=e=>{for(const t of Oe)if(e[t]!==void 0&&typeof e[t]!="boolean")throw new RangeError(`[markdown-explorer] embed.${t} must be a boolean; got ${JSON.stringify(e[t])}`);if(e.padding!==void 0&&!be(e.padding))throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(_e)} px in plain decimal digits; got ${String(e.padding)}`);for(const t of["width","maxWidth"]){const r=e[t];if(r!==void 0&&!H.test(r))throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${JSON.stringify(r)}`)}},Re=(e,t)=>{const r=new URLSearchParams;let n=`${e.basePath}/${e.views[t.view]}`;if(t.view==="multi"){const i=t.docs??[],s=t.maximized??null,l=t.markup??[];vt(e,i,s,l);for(const a of i)r.append(c.doc,a);s!==null&&r.set(c.maximized,s);for(const a of i)l.includes(a)&&r.append(c.markup,a)}else{const i=t.doc??null,s=t.view==="tree"?t.folder??null:null;if(i!==null&&s!==null)throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");i!==null&&(n+=`/${ie(Dt(i))}`),s!==null&&(n+=`/${ie(`${B(s)}${C}`)}`)}if(t.source!==void 0){const i=Te(e);if(!i.includes(t.source))throw new RangeError(`[markdown-explorer] unknown source ${JSON.stringify(t.source)}; expected one of ${i.join(", ")}`);t.source!==i[0]&&r.set(c.source,t.source)}if(t.view!=="multi"&&t.overrides!==void 0&&($t(e,t.overrides),t.overrides.style!==void 0&&r.set(c.style,t.overrides.style),t.overrides.align!==void 0&&r.set(c.align,t.overrides.align)),t.view!=="multi"&&t.markup===!0){if(!(t.doc!==void 0&&t.doc!==null||t.view==="tree"&&t.folder!==void 0&&t.folder!==null))throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");r.set(c.markup,he)}if(t.view==="single"&&t.embed!==void 0){const{embed:i}=t;zt(i);for(const s of Oe)i[s]===!1&&r.set(c[s],"false");i.padding!==void 0&&r.set(c.padding,String(i.padding)),i.width!==void 0&&r.set(c.width,i.width),i.maxWidth!==void 0&&r.set(c.maxWidth,i.maxWidth)}const o=r.toString();return o===""?n:`${n}?${o}`},jt=(e,t)=>Object.keys(e.views).find(r=>e.views[r]===t),Ft=(e,t,r)=>{const n=Te(e),[o]=n;if(o===void 0)throw new RangeError("[markdown-explorer] the configuration has no source");const i=Lt(n,o,r),s=i===null?o:i,l=m=>({kind:"redirect",href:Re(e,m),location:m}),a=()=>l({view:"tree",source:s,doc:null,folder:null,overrides:{},markup:!1});if(t===void 0||t==="")return a();const x=t.indexOf("/"),v=x<0?t:t.slice(0,x),D=x<0?null:t.slice(x+1),w=jt(e,v);if(w===void 0)return a();if(w==="multi"){const m=r.getAll(c.doc),S=ye(e,m),$=r.getAll(c.maximized),[z]=$,j=$.length===1&&z!==void 0&&S.includes(z)?z:null,F=r.getAll(c.markup),P=S.filter(b=>F.includes(b)),Ne=P.length===F.length&&P.every((b,V)=>b===F[V]);return D===null&&i!==null&&S.length===m.length&&S.every((b,V)=>b===m[V])&&($.length===0||j!==null)&&Ne?{kind:"location",location:{view:"multi",source:s,docs:S,maximized:j,markup:P}}:l({view:"multi",source:s,docs:S,maximized:j,markup:P})}const k=D===null?null:Pt(D),f=k?.endsWith(C)===!0?k.slice(0,-C.length):null,E=k!==null&&f===null?k:null;if(E!==null&&!I.isAcceptableDocumentPath(E)||f!==null&&!I.isAcceptableDocumentPath(f))return a();const O=Ct(e,r),T=(E!==null||f!==null)&&r.get(c.markup)===he;if(w==="single"){if(f!==null)return l({view:"tree",source:s,doc:null,folder:f,overrides:O,markup:T});if(E===null)return a();const m=Mt(r);return i===null?l({view:w,source:s,doc:E,overrides:O,embed:m,markup:T}):{kind:"location",location:{view:w,source:s,doc:E,overrides:O,embed:m,markup:T}}}return i===null?l({view:w,source:s,doc:E,folder:f,overrides:O,markup:T}):{kind:"location",location:{view:w,source:s,doc:E,folder:f,overrides:O,markup:T}}};exports.ASSUMED_ROOT_FONT_PIXELS=He;exports.COARSE_TARGET_PIXELS=Be;exports.COLUMN_MIN_MEASURE=et;exports.CONTROL_BLOCK_PIXELS=ce;exports.DEFAULT_TREE_SETTINGS=G;exports.DEFAULT_VIEW_SLUGS=J;exports.EDIT_SPLIT_DEFAULT_PERCENT=ot;exports.EDIT_SPLIT_MAX_PERCENT=it;exports.EDIT_SPLIT_MIN_PERCENT=me;exports.EXPAND_ALL_DEPTH_LIMITS=ge;exports.EXPAND_ALL_FOLDER_LIMITS=Ee;exports.EXPLORER_DEFAULT_PERCENT=We;exports.EXPLORER_MAX_PERCENT=q;exports.EXPLORER_MIN_REM=le;exports.EXPLORER_MULTI_DEFAULT_PERCENT=Je;exports.FINE_TARGET_PIXELS=Ze;exports.GOLDEN_RATIO=u;exports.MULTI_VIEW_COLUMN_LIMITS=fe;exports.MULTI_VIEW_PANEL_LIMITS=ue;exports.NAME_COLLATOR=A;exports.NO_TREE_SETTING_CHANGES=W;exports.PANEL_MAX_BLOCK_RATIO=Ye;exports.PANEL_MIN_BLOCK_RATIO=Qe;exports.PREFETCH_DWELL_MS=st;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=we;exports.SPLIT_HANDLE_PIXELS=Ke;exports.SPLIT_PERSIST_DELAY_MS=nt;exports.advanceTreeSetting=De;exports.applyTreeSettingChanges=Fe;exports.canonicalMultiDocuments=ye;exports.centeredDialogPosition=mt;exports.columnGroups=ct;exports.createEntryComparator=Ge;exports.defineExplorerConfig=pe;exports.documentStyleNames=kt;exports.editSplitOrientation=dt;exports.explorerHref=Re;exports.explorerMinPixels=de;exports.explorerSheetBelowPixels=rt;exports.folderReadmeOf=Pe;exports.formatTreeSettingValue=$e;exports.isExplorerSourceId=Se;exports.isPlainObject=M;exports.parseViewSettings=pt;exports.readCookieValue=wt;exports.readTreeSettingChanges=je;exports.recordTreeSettingChange=Ve;exports.replanVisibleColumns=lt;exports.resolveExplorerLocation=Ft;exports.revalidateExplorerConfig=It;exports.serializeTreeSettingChanges=Ue;exports.viewSettingsCookieString=_t;exports.visibleTreeSettingDescriptors=ve;exports.withExplorerSources=At;
|