@aiquants/markdown-explorer 0.30.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +12 -8
  3. package/dist/{EditSurface-Cw0kbedj.cjs → EditSurface-BPqqykro.cjs} +3 -3
  4. package/dist/{EditSurface-DY1VNM9L.js → EditSurface-BmbDSrrw.js} +187 -187
  5. package/dist/{ExplorerSplit-x9Qkldh6.cjs → ExplorerSplit-CQxr6b0v.cjs} +1 -1
  6. package/dist/{ExplorerSplit-D3f1FiZ7.js → ExplorerSplit-DPuXOBqs.js} +4 -4
  7. package/dist/{MultiLayout-B0dfZlpx.js → MultiLayout-DKgZ1sBK.js} +238 -232
  8. package/dist/MultiLayout-TXbet9k3.cjs +1 -0
  9. package/dist/{NativeScrollBar-C4vkvdGz.js → NativeScrollBar-C1CtjwBm.js} +2 -2
  10. package/dist/{NativeScrollBar-C2UoYO3i.cjs → NativeScrollBar-UpjxjLlB.cjs} +1 -1
  11. package/dist/{TreeLayout-Bak1y1m4.js → TreeLayout-BpazybVQ.js} +3 -3
  12. package/dist/{TreeLayout-DsFH17x_.cjs → TreeLayout-C0O1OGi4.cjs} +1 -1
  13. package/dist/core/config.d.cts +2 -0
  14. package/dist/core/config.d.ts +2 -0
  15. package/dist/core/labels.d.cts +7 -0
  16. package/dist/core/labels.d.ts +7 -0
  17. package/dist/{index-auQVKY4M.js → index-CcXMPCRS.js} +919 -903
  18. package/dist/{index-DgaTEKsI.cjs → index-DSkK8iLE.cjs} +6 -6
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +6 -6
  21. package/dist/location-BxiJRTyw.cjs +1 -0
  22. package/dist/{location-CKuabtKl.js → location-perTmwct.js} +253 -245
  23. package/dist/{merge-D1jbIOPw.js → merge-3xGYZqbE.js} +1 -1
  24. package/dist/{merge-BEa-lale.cjs → merge-DZI4pkWI.cjs} +1 -1
  25. package/dist/server.cjs +1 -1
  26. package/dist/server.js +2 -2
  27. package/dist/{tapScrollCircle-BSb6lisN.cjs → tapScrollCircle-Cbf17x8g.cjs} +1 -1
  28. package/dist/{tapScrollCircle-DYQ8P2ag.js → tapScrollCircle-DacgW2F_.js} +1 -1
  29. package/dist/{useSplitPersistence-Bf4M35Il.js → useSplitPersistence-Du01PHNg.js} +1 -1
  30. package/dist/{useSplitPersistence-9Nu6J1WF.cjs → useSplitPersistence-pPmE4GTT.cjs} +1 -1
  31. package/docs/behavior/layout.md +19 -9
  32. package/docs/behavior/localization.md +4 -4
  33. package/docs/behavior/url-contract.md +1 -1
  34. package/package.json +12 -12
  35. package/dist/MultiLayout-BXr2UAvl.cjs +0 -1
  36. package/dist/location-l_HysaZR.cjs +0 -1
@@ -1,11 +1,11 @@
1
- import { NO_EMBEDS as ye, isEmbedProviderId as be, EMBED_PROVIDER_IDS as Oe, isLinkCardSize as ke, LINK_CARD_SIZES as Te } from "@aiquants/markdown/embeds";
2
- import { CONTENT_ALIGNS as N, DEFAULT_MARKDOWN_STYLES as Re } from "@aiquants/markdown/viewer-settings";
3
- import { a as Ie, i as A } from "./dataRoute-DLhQfdoW.js";
4
- const R = (e) => {
1
+ import { NO_EMBEDS as xe, isEmbedProviderId as be, EMBED_PROVIDER_IDS as Oe, isLinkCardSize as ke, LINK_CARD_SIZES as Te } from "@aiquants/markdown/embeds";
2
+ import { CONTENT_ALIGNS as $, DEFAULT_MARKDOWN_STYLES as Re, DEFAULT_MARKDOWN_STYLE as _e } from "@aiquants/markdown/viewer-settings";
3
+ import { a as Ie, i as P } from "./dataRoute-DLhQfdoW.js";
4
+ const I = (e) => {
5
5
  if (e === null || typeof e != "object") return !1;
6
6
  const t = Object.getPrototypeOf(e);
7
7
  return t === Object.prototype || t === null;
8
- }, _e = Object.freeze([
8
+ }, Ne = Object.freeze([
9
9
  "UTF-8",
10
10
  "IBM866",
11
11
  "ISO-8859-2",
@@ -46,12 +46,12 @@ const R = (e) => {
46
46
  "UTF-16BE",
47
47
  "UTF-16LE",
48
48
  "x-user-defined"
49
- ]), Ne = new Map(_e.map((e) => [e.toLowerCase(), e])), $ = "UTF-8", q = Object.freeze([
50
- Object.freeze({ bytes: Object.freeze([239, 187, 191]), encoding: $ }),
49
+ ]), Ae = new Map(Ne.map((e) => [e.toLowerCase(), e])), v = "UTF-8", q = Object.freeze([
50
+ Object.freeze({ bytes: Object.freeze([239, 187, 191]), encoding: v }),
51
51
  Object.freeze({ bytes: Object.freeze([255, 254]), encoding: "UTF-16LE" }),
52
52
  Object.freeze({ bytes: Object.freeze([254, 255]), encoding: "UTF-16BE" })
53
- ]), Ae = /* @__PURE__ */ new Map([
54
- [$, "is read before any legacy encoding"],
53
+ ]), $e = /* @__PURE__ */ new Map([
54
+ [v, "is read before any legacy encoding"],
55
55
  ["UTF-16LE", "is read only by its byte order mark"],
56
56
  ["UTF-16BE", "is read only by its byte order mark"],
57
57
  ["ISO-2022-JP", "writes only bytes below 0x80, which UTF-8 always reads first, so it would never be used"],
@@ -63,41 +63,41 @@ const R = (e) => {
63
63
  } catch (o) {
64
64
  throw o instanceof RangeError ? new RangeError(`[markdown-explorer] legacyTextEncoding ${JSON.stringify(e)} is no encoding label TextDecoder knows (for example "Shift_JIS" or "windows-1252")`) : o;
65
65
  }
66
- const n = $e(t), r = Ae.get(n);
66
+ const n = Pe(t), r = $e.get(n);
67
67
  if (r !== void 0) throw new RangeError(`[markdown-explorer] legacyTextEncoding ${JSON.stringify(e)} names ${n}, which cannot be the legacy encoding: it ${r}`);
68
68
  return n;
69
- }, $e = (e) => {
70
- const t = Ne.get(e);
69
+ }, Pe = (e) => {
70
+ const t = Ae.get(e);
71
71
  if (t === void 0) throw new RangeError(`[markdown-explorer] TextDecoder answered ${JSON.stringify(e)}, which is no encoding of the WHATWG Encoding Standard`);
72
72
  return t;
73
- }, C = (e, t, n) => {
74
- const r = n === null ? null : de(n), o = q.find(({ bytes: i }) => i.every((a, l) => e[l] === a));
73
+ }, L = (e, t, n) => {
74
+ const r = n === null ? null : de(n), o = q.find(({ bytes: i }) => i.every((a, c) => e[c] === a));
75
75
  if (o !== void 0) return { body: e.subarray(o.bytes.length), encodings: [o.encoding] };
76
- const s = t || e.length === 0 ? void 0 : q.find(({ bytes: i }) => e.length < i.length && e.every((a, l) => i[l] === a));
77
- return s !== void 0 ? { body: e.subarray(e.length), encodings: [s.encoding] } : { body: e, encodings: r === null ? [$] : [$, r] };
78
- }, Pt = (e, t, n) => C(e, t, n).encodings, Pe = (e, t, n) => {
76
+ const s = t || e.length === 0 ? void 0 : q.find(({ bytes: i }) => e.length < i.length && e.every((a, c) => i[c] === a));
77
+ return s !== void 0 ? { body: e.subarray(e.length), encodings: [s.encoding] } : { body: e, encodings: r === null ? [v] : [v, r] };
78
+ }, vt = (e, t, n) => L(e, t, n).encodings, ve = (e, t, n) => {
79
79
  try {
80
80
  return new TextDecoder(e, { fatal: !0, ignoreBOM: !0 }).decode(t, { stream: !n });
81
81
  } catch (r) {
82
82
  if (r instanceof TypeError) return null;
83
83
  throw r;
84
84
  }
85
- }, vt = (e, t, n) => {
86
- const r = X(C(e, t, n), t);
85
+ }, Dt = (e, t, n) => {
86
+ const r = X(L(e, t, n), t);
87
87
  return r === null ? null : r.text;
88
88
  }, X = ({ body: e, encodings: t }, n) => {
89
89
  for (const r of t) {
90
- const o = Pe(r, e, n);
90
+ const o = ve(r, e, n);
91
91
  if (o !== null) return { encoding: r, text: o };
92
92
  }
93
93
  return null;
94
94
  }, jt = (e, t, n) => {
95
- const r = C(e, t, n), o = X(r, t);
95
+ const r = L(e, t, n), o = X(r, t);
96
96
  return o === null ? r.encodings[0] : o.encoding;
97
97
  }, Ct = (e, t, n) => {
98
- const r = C(e, t, n), o = X(r, t);
98
+ const r = L(e, t, n), o = X(r, t);
99
99
  return o !== null ? o.text : new TextDecoder(r.encodings[0], { ignoreBOM: !0 }).decode(r.body, { stream: !t });
100
- }, P = new Intl.Collator("en", { numeric: !0, sensitivity: "variant" }), ve = /^readme(?:\.|$)/iu, Y = /^readme(?:\.[^.]*)?$/iu, Z = Object.freeze(["md", "markdown", "mdx", "txt", ""]), je = (e) => ve.test(e), J = (e) => e.type === "file" && je(e.name), Q = (e) => {
100
+ }, D = new Intl.Collator("en", { numeric: !0, sensitivity: "variant" }), De = /^readme(?:\.|$)/iu, Y = /^readme(?:\.[^.]*)?$/iu, Z = Object.freeze(["md", "markdown", "mdx", "txt", ""]), je = (e) => De.test(e), B = (e) => e.type === "file" && je(e.name), Q = (e) => {
101
101
  const t = e.lastIndexOf("."), n = Z.indexOf(t < 0 ? "" : e.slice(t + 1).toLowerCase());
102
102
  return n < 0 ? Z.length : n;
103
103
  }, Ce = (e, t) => {
@@ -105,12 +105,12 @@ const R = (e) => {
105
105
  if (n !== 0) return n;
106
106
  const r = Q(e.name) - Q(t.name);
107
107
  if (r !== 0) return r;
108
- const o = P.compare(e.name, t.name);
109
- return o !== 0 ? o : P.compare(e.path, t.path);
110
- }, Mt = (e) => {
108
+ const o = D.compare(e.name, t.name);
109
+ return o !== 0 ? o : D.compare(e.path, t.path);
110
+ }, Lt = (e) => {
111
111
  let t = null;
112
112
  for (const n of e)
113
- J(n) && (t === null || Ce(n, t) < 0) && (t = n);
113
+ B(n) && (t === null || Ce(n, t) < 0) && (t = n);
114
114
  return t === null ? null : t.path;
115
115
  }, ee = Object.freeze({
116
116
  sortMode: "native",
@@ -126,18 +126,18 @@ const R = (e) => {
126
126
  expandIcons: !0,
127
127
  directoryIcons: !0,
128
128
  fileIcons: !0
129
- }), Me = [!0, !1], Le = (e, t) => t ? e.settingOn : e.settingOff, p = (e, t) => ({ key: e, labelKey: t, values: Me, formatValue: Le, requiresItemSelection: !1 }), De = Object.freeze({
129
+ }), Le = [!0, !1], Me = (e, t) => t ? e.settingOn : e.settingOff, S = (e, t) => ({ key: e, labelKey: t, values: Le, formatValue: Me, requiresItemSelection: !1 }), ze = Object.freeze({
130
130
  native: (e) => e.sortNative,
131
131
  asc: (e) => e.sortAscending,
132
132
  desc: (e) => e.sortDescending,
133
133
  oldest: (e) => e.sortOldest,
134
134
  newest: (e) => e.sortNewest
135
- }), b = Object.freeze([
135
+ }), O = Object.freeze([
136
136
  {
137
137
  key: "sortMode",
138
138
  labelKey: "settingSortMode",
139
139
  values: ["native", "asc", "desc", "oldest", "newest"],
140
- formatValue: (e, t) => De[t](e),
140
+ formatValue: (e, t) => ze[t](e),
141
141
  requiresItemSelection: !1
142
142
  },
143
143
  {
@@ -175,120 +175,120 @@ const R = (e) => {
175
175
  formatValue: (e, t) => e.expandIconSizeValue(t),
176
176
  requiresItemSelection: !1
177
177
  },
178
- p("alwaysExpanded", "settingAlwaysExpanded"),
179
- p("revealDocument", "settingRevealDocument"),
180
- p("removeRootIndent", "settingRemoveRootIndent"),
181
- p("lines", "settingTreeLines"),
182
- p("expandIcons", "settingExpandIcons"),
183
- p("directoryIcons", "settingDirectoryIcons"),
184
- p("fileIcons", "settingFileIcons")
185
- ]), Lt = (e) => e ? b : b.filter((t) => !t.requiresItemSelection), me = (e) => {
186
- const t = b.find((n) => n.key === e);
178
+ S("alwaysExpanded", "settingAlwaysExpanded"),
179
+ S("revealDocument", "settingRevealDocument"),
180
+ S("removeRootIndent", "settingRemoveRootIndent"),
181
+ S("lines", "settingTreeLines"),
182
+ S("expandIcons", "settingExpandIcons"),
183
+ S("directoryIcons", "settingDirectoryIcons"),
184
+ S("fileIcons", "settingFileIcons")
185
+ ]), Mt = (e) => e ? O : O.filter((t) => !t.requiresItemSelection), me = (e) => {
186
+ const t = O.find((n) => n.key === e);
187
187
  if (t === void 0) throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);
188
188
  return t;
189
- }, Dt = (e, t) => {
189
+ }, zt = (e, t) => {
190
190
  const n = me(t).values, r = n[(n.indexOf(e[t]) + 1) % n.length];
191
191
  return { ...e, [t]: r };
192
- }, zt = (e, t, n) => me(n).formatValue(e, t[n]), fe = 2, te = Object.freeze({}), K = (e, t) => Object.freeze(Object.fromEntries(b.filter((n) => t(n, e[n.key])).map((n) => [n.key, e[n.key]]))), ne = "directoriesFirst", ze = (e) => {
192
+ }, Ft = (e, t, n) => me(n).formatValue(e, t[n]), fe = 2, te = Object.freeze({}), K = (e, t) => Object.freeze(Object.fromEntries(O.filter((n) => t(n, e[n.key])).map((n) => [n.key, e[n.key]]))), ne = "directoriesFirst", Fe = (e) => {
193
193
  if (!Object.hasOwn(e, ne)) return e;
194
194
  const { [ne]: t, ...n } = e;
195
195
  return Object.hasOwn(n, "folderPlacement") || typeof t != "boolean" ? n : { ...n, folderPlacement: t ? "first" : "mixed" };
196
- }, Ft = (e) => {
196
+ }, Ut = (e) => {
197
197
  if (e === null || typeof e != "object" || Array.isArray(e)) return te;
198
198
  const t = e;
199
- return t.version !== fe || t.settings === null || typeof t.settings != "object" || Array.isArray(t.settings) ? te : K(ze(t.settings), (n, r) => n.values.includes(r));
200
- }, Ut = (e, t) => {
199
+ return t.version !== fe || t.settings === null || typeof t.settings != "object" || Array.isArray(t.settings) ? te : K(Fe(t.settings), (n, r) => n.values.includes(r));
200
+ }, Vt = (e, t) => {
201
201
  const n = K(t, (r, o) => o !== void 0 && o !== e[r.key]);
202
202
  return Object.keys(n).length === 0 ? e : Object.freeze({ ...e, ...n });
203
- }, Vt = (e, t, n, r) => K({ ...e, [t]: n }, (o, s) => s !== void 0 && !(o.key === t && s === r[t])), Bt = (e) => JSON.stringify({ version: fe, settings: e }), Fe = (e, t, n) => e === void 0 || t === void 0 ? e === t ? 0 : e === void 0 ? 1 : -1 : n * (e - t), Jt = (e) => {
203
+ }, Jt = (e, t, n, r) => K({ ...e, [t]: n }, (o, s) => s !== void 0 && !(o.key === t && s === r[t])), Bt = (e) => JSON.stringify({ version: fe, settings: e }), Ue = (e, t, n) => e === void 0 || t === void 0 ? e === t ? 0 : e === void 0 ? 1 : -1 : n * (e - t), Wt = (e) => {
204
204
  const { sortMode: t, folderPlacement: n, readmePlacement: r } = e;
205
205
  if (t === "native" && n === "mixed" && r === "mixed") return;
206
206
  const o = (s, i) => {
207
- const a = P.compare(s.name, i.name);
208
- return a !== 0 ? a : P.compare(s.path, i.path);
207
+ const a = D.compare(s.name, i.name);
208
+ return a !== 0 ? a : D.compare(s.path, i.path);
209
209
  };
210
210
  return (s, i) => {
211
211
  if (n !== "mixed" && s.type !== i.type) return s.type === "directory" == (n === "first") ? -1 : 1;
212
212
  if (r !== "mixed") {
213
- const l = J(s);
214
- if (l !== J(i)) return l === (r === "first") ? -1 : 1;
213
+ const c = B(s);
214
+ if (c !== B(i)) return c === (r === "first") ? -1 : 1;
215
215
  }
216
216
  if (t === "native") return 0;
217
217
  if (t === "asc") return o(s, i);
218
218
  if (t === "desc") return -o(s, i);
219
- const a = Fe(s.modifiedAt, i.modifiedAt, t === "oldest" ? 1 : -1);
219
+ const a = Ue(s.modifiedAt, i.modifiedAt, t === "oldest" ? 1 : -1);
220
220
  return a !== 0 ? a : o(s, i);
221
221
  };
222
- }, h = (1 + Math.sqrt(5)) / 2, Gt = 100 / h ** 3, Wt = 100 / h ** 4, ue = 100 / h ** 2, Ue = 13, Xt = 16, Kt = Object.freeze({ gripThickness: 5, gripLength: 34, barThickness: 2, barLength: 21 }), Ht = Object.freeze([1, 2, 3, 5, 8, 13, 21, 34, 55]), Ve = Object.freeze([89, 144, 233, 377]), Be = 44, qt = Be, Yt = 24, Zt = 1 / h, Qt = 1 / h ** 3, en = "40ch", Je = (e) => {
222
+ }, E = (1 + Math.sqrt(5)) / 2, Gt = 100 / E ** 3, Xt = 100 / E ** 4, ue = 100 / E ** 2, Ve = 13, Kt = 16, Ht = Object.freeze({ gripThickness: 5, gripLength: 34, barThickness: 2, barLength: 21 }), qt = Object.freeze([1, 2, 3, 5, 8, 13, 21, 34, 55]), Je = Object.freeze([89, 144, 233, 377]), Be = 44, Yt = Be, Zt = 24, Qt = 1 / E, en = 1 / E ** 3, tn = "40ch", We = (e) => {
223
223
  if (!Number.isFinite(e) || e <= 0)
224
224
  throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${String(e)}`);
225
- }, Ge = (e) => (Je(e), Ue * e), tn = (e) => Ge(e) * h ** 2, nn = 233, rn = 50, We = 100 / h ** 3, on = 100 - We, sn = Ve[0], w = (e, t) => {
225
+ }, Ge = (e) => (We(e), Ve * e), nn = (e) => Ge(e) * E ** 2, rn = 233, on = 50, Xe = 100 / E ** 3, sn = 100 - Xe, an = Je[0], h = (e, t) => {
226
226
  if (!Number.isFinite(t) || t < 0)
227
227
  throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${String(t)}`);
228
- }, Xe = ({ trackInlineSize: e, gap: t, minColumnInlineSize: n, logicalColumns: r }) => {
229
- if (w("trackInlineSize", e), w("gap", t), !Number.isFinite(n) || n <= 0)
228
+ }, Ke = ({ trackInlineSize: e, gap: t, minColumnInlineSize: n, logicalColumns: r }) => {
229
+ if (h("trackInlineSize", e), h("gap", t), !Number.isFinite(n) || n <= 0)
230
230
  throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${String(n)}`);
231
231
  if (!Number.isInteger(r) || r < 1)
232
232
  throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${String(r)}`);
233
233
  const o = Math.floor((e + t) / (n + t));
234
234
  return Math.min(r, Math.max(1, o));
235
- }, an = (e, t) => {
235
+ }, cn = (e, t) => {
236
236
  const { trackInlineSize: n, gap: r, minColumnInlineSize: o, logicalColumns: s } = t;
237
237
  if (!([n, r, o].every(Number.isFinite) && n > 0 && r >= 0 && o > 0)) return e;
238
- const a = Xe(t);
238
+ const a = Ke(t);
239
239
  if (e === null || a === e) return a;
240
- const l = Math.min(s, Math.max(1, e));
241
- if (a > l) {
242
- const M = (l + 1) * o + l * r + r / h;
243
- return n >= M ? a : l;
240
+ const c = Math.min(s, Math.max(1, e));
241
+ if (a > c) {
242
+ const l = (c + 1) * o + c * r + r / E;
243
+ return n >= l ? a : c;
244
244
  }
245
- return n >= l * o + (l - 1) * r ? l : a;
246
- }, cn = (e, t) => {
245
+ return n >= c * o + (c - 1) * r ? c : a;
246
+ }, ln = (e, t) => {
247
247
  if (!(Number.isInteger(e) && Number.isInteger(t)) || t < 1 || t > e)
248
248
  throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${String(t)}`);
249
249
  return Array.from({ length: t }, (n, r) => [Math.floor(r * e / t), Math.floor((r + 1) * e / t)]);
250
- }, ln = (e, t, n) => {
251
- if (w("surfaceInlineSize", e), w("handlePixels", n), !Number.isFinite(t) || t <= 0)
250
+ }, dn = (e, t, n) => {
251
+ if (h("surfaceInlineSize", e), h("handlePixels", n), !Number.isFinite(t) || t <= 0)
252
252
  throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${String(t)}`);
253
253
  return e >= 2 * t + n ? "beside" : "stacked";
254
- }, B = (e, t, n) => Math.max(t, Math.min(e, n)), re = (e, t, n, r) => {
255
- const o = (B(e, 0, n) + B(t, 0, n)) / 2;
256
- return B(o - r / 2, 0, n - r);
257
- }, dn = (e, t, n) => {
254
+ }, J = (e, t, n) => Math.max(t, Math.min(e, n)), re = (e, t, n, r) => {
255
+ const o = (J(e, 0, n) + J(t, 0, n)) / 2;
256
+ return J(o - r / 2, 0, n - r);
257
+ }, mn = (e, t, n) => {
258
258
  for (const [r, o] of Object.entries(e))
259
259
  if (!Number.isFinite(o)) throw new RangeError(`[markdown-explorer] anchor.${r} must be a finite number; got ${String(o)}`);
260
- return w("marginBox.width", t.width), w("marginBox.height", t.height), w("viewport.width", n.width), w("viewport.height", n.height), {
260
+ return h("marginBox.width", t.width), h("marginBox.height", t.height), h("viewport.width", n.width), h("viewport.height", n.height), {
261
261
  left: re(e.left, e.right, n.width, t.width),
262
262
  top: re(e.top, e.bottom, n.height, t.height)
263
263
  };
264
- }, Ke = 31536e3, He = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u, qe = (e) => {
265
- if (typeof e != "string" || !He.test(e))
264
+ }, He = 31536e3, qe = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u, Ye = (e) => {
265
+ if (typeof e != "string" || !qe.test(e))
266
266
  throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${JSON.stringify(e)}`);
267
- }, oe = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= ue, Ye = (e, t) => {
267
+ }, oe = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= ue, Ze = (e, t) => {
268
268
  if (e === null || typeof e != "object" || Array.isArray(e)) return {};
269
269
  const n = e, { treeExplorer: r, multiExplorer: o, style: s, align: i } = n;
270
270
  return {
271
271
  ...oe(r) ? { treeExplorer: r } : {},
272
272
  ...oe(o) ? { multiExplorer: o } : {},
273
273
  ...typeof s == "string" && t.includes(s) ? { style: s } : {},
274
- ...typeof i == "string" && N.includes(i) ? { align: i } : {}
274
+ ...typeof i == "string" && $.includes(i) ? { align: i } : {}
275
275
  };
276
- }, mn = (e, t) => {
276
+ }, fn = (e, t) => {
277
277
  if (e !== null)
278
278
  for (const n of e.split(";")) {
279
279
  const r = n.indexOf("=");
280
280
  if (!(r < 0) && n.slice(0, r).trim() === t)
281
281
  return n.slice(r + 1).trim();
282
282
  }
283
- }, fn = (e, t) => {
283
+ }, un = (e, t) => {
284
284
  if (e === void 0 || e === "") return {};
285
285
  try {
286
- return Ye(JSON.parse(decodeURIComponent(e)), t);
286
+ return Ze(JSON.parse(decodeURIComponent(e)), t);
287
287
  } catch {
288
288
  return {};
289
289
  }
290
- }, v = 100, Ze = Math.floor(ue * v) / v, Qe = (e) => {
291
- const t = (n) => Math.min(Ze, Math.max(1, Math.round(n * v)) / v);
290
+ }, j = 100, Qe = Math.floor(ue * j) / j, et = (e) => {
291
+ const t = (n) => Math.min(Qe, Math.max(1, Math.round(n * j)) / j);
292
292
  return encodeURIComponent(
293
293
  JSON.stringify({
294
294
  ...e.treeExplorer === void 0 ? {} : { treeExplorer: t(e.treeExplorer) },
@@ -297,11 +297,11 @@ const R = (e) => {
297
297
  ...e.align === void 0 ? {} : { align: e.align }
298
298
  })
299
299
  );
300
- }, un = (e, t, n) => `${e}=${Qe(t)}; Path=/; Max-Age=${String(Ke)}; SameSite=Lax${n ? "; Secure" : ""}`, se = Object.freeze({ tree: "tree", multi: "multi", single: "single" }), et = Object.freeze({ default: 12, min: 1, max: 64 }), tt = Object.freeze({ default: 4, min: 1, max: 6 }), nt = Object.freeze({ default: 500, min: 1, max: 1e4 }), rt = Object.freeze({ default: 16, min: 1, max: 64 }), ot = Object.freeze({ default: 16, min: 1, max: 64 }), st = Object.freeze({ default: 2 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), it = Object.freeze({ default: 8 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), at = /^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u, ct = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u, lt = /^[a-z0-9][a-z0-9-]*$/u, dt = /^(?=.{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, ie = (e, t) => {
300
+ }, gn = (e, t, n) => `${e}=${et(t)}; Path=/; Max-Age=${String(He)}; SameSite=Lax${n ? "; Secure" : ""}`, se = Object.freeze({ tree: "tree", multi: "multi", single: "single" }), tt = Object.freeze({ default: 12, min: 1, max: 64 }), nt = Object.freeze({ default: 4, min: 1, max: 6 }), rt = Object.freeze({ default: 500, min: 1, max: 1e4 }), ot = Object.freeze({ default: 16, min: 1, max: 64 }), st = Object.freeze({ default: 16, min: 1, max: 64 }), it = Object.freeze({ default: 2 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), at = Object.freeze({ default: 8 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), ct = /^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u, lt = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u, dt = /^[a-z0-9][a-z0-9-]*$/u, mt = /^(?=.{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, ie = (e, t) => {
301
301
  if (typeof t != "string") throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${typeof t}`);
302
- if (!at.test(t) || t.split("/").some((n) => n === "." || n === ".."))
302
+ if (!ct.test(t) || t.split("/").some((n) => n === "." || n === ".."))
303
303
  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)}`);
304
- }, m = (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" ? R(e) ? "a plain object" : `a non-plain object (${Object.prototype.toString.call(e)})` : String(e), ae = Object.freeze(
304
+ }, 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" ? I(e) ? "a plain object" : `a non-plain object (${Object.prototype.toString.call(e)})` : String(e), ae = Object.freeze(
305
305
  Object.keys({
306
306
  basePath: !0,
307
307
  dataPath: !0,
@@ -311,6 +311,7 @@ const R = (e) => {
311
311
  expandAll: !0,
312
312
  revealDocument: !0,
313
313
  documentStyles: !0,
314
+ defaultDocumentStyle: !0,
314
315
  iframeHosts: !0,
315
316
  embeds: !0,
316
317
  defaultTreeSettings: !0,
@@ -319,85 +320,91 @@ const R = (e) => {
319
320
  })
320
321
  ), x = (e, t, n) => {
321
322
  if (t === void 0) return [];
322
- if (!R(t)) throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${m(t)}`);
323
+ if (!I(t)) throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${d(t)}`);
323
324
  const r = Object.entries(t);
324
325
  for (const [o] of r)
325
326
  if (!n.includes(o)) throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${n.join(", ")}`);
326
327
  return r.filter(([, o]) => o !== void 0);
327
- }, mt = (e) => {
328
+ }, ft = (e) => {
328
329
  const t = { ...se };
329
330
  for (const [n, r] of x("views", e, Object.keys(se))) t[n] = r;
330
331
  for (const [n, r] of Object.entries(t))
331
- if (typeof r != "string" || !ct.test(r))
332
+ if (typeof r != "string" || !lt.test(r))
332
333
  throw new RangeError(`[markdown-explorer] views.${n} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${JSON.stringify(r)}`);
333
334
  return Object.freeze(t);
334
- }, S = (e, t, n) => {
335
+ }, y = (e, t, n) => {
335
336
  if (t === void 0) return n.default;
336
337
  if (typeof t != "number" || !Number.isInteger(t) || t < n.min || t > n.max)
337
- throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(n.min)}..${String(n.max)}; got ${m(t)}`);
338
+ throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(n.min)}..${String(n.max)}; got ${d(t)}`);
338
339
  return t;
339
- }, ft = (e, t) => {
340
+ }, ut = (e, t) => {
340
341
  const n = new Map(x("embeds", e, ["providers", "linkCards", "linkCardSize"]));
341
- if (n.size === 0) return ye;
342
+ if (n.size === 0) return xe;
342
343
  const r = n.has("providers") ? n.get("providers") : [];
343
- if (!Array.isArray(r)) throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${m(r)}`);
344
+ if (!Array.isArray(r)) throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${d(r)}`);
344
345
  for (const a of r)
345
- if (!be(a)) throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${Oe.join(", ")}; got ${m(a)}`);
346
+ if (!be(a)) throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${Oe.join(", ")}; got ${d(a)}`);
346
347
  const o = n.has("linkCards") ? n.get("linkCards") : !1;
347
- if (typeof o != "boolean") throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${m(o)}`);
348
+ if (typeof o != "boolean") throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${d(o)}`);
348
349
  const s = { providers: Object.freeze([...new Set(r)]), linkCardEndpoint: o ? Ie(t) : null };
349
350
  if (!n.has("linkCardSize")) return Object.freeze(s);
350
351
  const i = n.get("linkCardSize");
351
- if (!ke(i)) throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${Te.join(", ")}; got ${m(i)}`);
352
- if (!o) throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${m(i)} with linkCards ${m(o)}`);
352
+ if (!ke(i)) throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${Te.join(", ")}; got ${d(i)}`);
353
+ if (!o) throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${d(i)} with linkCards ${d(o)}`);
353
354
  return Object.freeze({ ...s, linkCardSize: i });
354
- }, ut = (e) => {
355
+ }, gt = (e) => {
355
356
  if (e === void 0) return null;
356
- if (typeof e != "string") throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${m(e)}`);
357
+ if (typeof e != "string") throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${d(e)}`);
357
358
  return de(e);
358
- }, gt = (e) => {
359
+ }, wt = (e) => {
359
360
  const t = new Map(
360
361
  x(
361
362
  "defaultTreeSettings",
362
363
  e,
363
- b.map((r) => r.key)
364
+ O.map((r) => r.key)
364
365
  )
365
366
  );
366
367
  if (t.size === 0) return ee;
367
368
  const n = { ...ee };
368
- for (const r of b) {
369
+ for (const r of O) {
369
370
  if (!t.has(r.key)) continue;
370
371
  const o = t.get(r.key), s = r.values;
371
- if (!s.includes(o)) throw new RangeError(`[markdown-explorer] defaultTreeSettings.${r.key} must be one of ${s.map(m).join(", ")}; got ${m(o)}`);
372
+ if (!s.includes(o)) throw new RangeError(`[markdown-explorer] defaultTreeSettings.${r.key} must be one of ${s.map(d).join(", ")}; got ${d(o)}`);
372
373
  n[r.key] = o;
373
374
  }
374
375
  return Object.freeze(n);
375
- }, wt = (e) => {
376
+ }, ht = (e) => {
376
377
  if (e === null || typeof e != "object") throw new TypeError("[markdown-explorer] the explorer configuration must be an object");
377
- for (const c of Object.keys(e))
378
- if (!ae.includes(c)) throw new RangeError(`[markdown-explorer] ${c} is not an option of the explorer configuration; expected ${ae.join(", ")}`);
378
+ for (const l of Object.keys(e))
379
+ if (!ae.includes(l)) throw new RangeError(`[markdown-explorer] ${l} is not an option of the explorer configuration; expected ${ae.join(", ")}`);
379
380
  ie("basePath", e.basePath), ie("dataPath", e.dataPath);
380
- const t = mt(e.views);
381
+ const t = ft(e.views);
381
382
  if ((/* @__PURE__ */ new Set([t.tree, t.multi, t.single])).size !== 3)
382
383
  throw new RangeError(`[markdown-explorer] the view slugs must differ; got ${JSON.stringify(t)}`);
383
384
  if (e.dataPath === e.basePath) throw new RangeError("[markdown-explorer] dataPath must differ from basePath");
384
385
  if (e.dataPath.startsWith(`${e.basePath}/`)) {
385
- const c = e.dataPath.slice(e.basePath.length + 1).split("/")[0];
386
- if (c === t.tree || c === t.multi || c === t.single)
386
+ const l = e.dataPath.slice(e.basePath.length + 1).split("/")[0];
387
+ if (l === t.tree || l === t.multi || l === t.single)
387
388
  throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug under basePath; got ${JSON.stringify(e.dataPath)}`);
388
389
  }
389
- qe(e.settingsCookie);
390
+ Ye(e.settingsCookie);
390
391
  const n = e.iframeHosts ?? [];
391
- if (!Array.isArray(n) || n.some((c) => typeof c != "string" || !dt.test(c)))
392
+ if (!Array.isArray(n) || n.some((l) => typeof l != "string" || !mt.test(l)))
392
393
  throw new RangeError(`[markdown-explorer] iframeHosts must be lowercase host names without scheme, port or path; got ${JSON.stringify(n)}`);
393
394
  const r = Object.fromEntries(x("multiView", e.multiView, ["maxPanels", "columns"])), o = Object.fromEntries(x("expandAll", e.expandAll, ["maxFolders", "maxDepth"])), s = Object.fromEntries(x("revealDocument", e.revealDocument, ["maxDepth"])), i = Object.fromEntries(x("spreadsheets", e.spreadsheets, ["maxBytes", "maxWorkbookBytes"])), a = e.documentStyles ?? Re;
394
395
  if (!Array.isArray(a) || a.length === 0) throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");
395
- const l = /* @__PURE__ */ new Set();
396
- for (const c of a) {
397
- if (c === null || typeof c != "object" || typeof c.name != "string" || c.name.trim() === "" || typeof c.className != "string")
396
+ const c = /* @__PURE__ */ new Set();
397
+ for (const l of a) {
398
+ if (l === null || typeof l != "object" || typeof l.name != "string" || l.name.trim() === "" || typeof l.className != "string")
398
399
  throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");
399
- if (l.has(c.name)) throw new RangeError(`[markdown-explorer] document style names must be unique; ${JSON.stringify(c.name)} repeats`);
400
- l.add(c.name);
400
+ if (c.has(l.name)) throw new RangeError(`[markdown-explorer] document style names must be unique; ${JSON.stringify(l.name)} repeats`);
401
+ c.add(l.name);
402
+ }
403
+ const f = e.defaultDocumentStyle === void 0 ? _e : e.defaultDocumentStyle;
404
+ if (typeof f != "string") throw new TypeError(`[markdown-explorer] defaultDocumentStyle must be a string; got ${d(f)}`);
405
+ if (!c.has(f)) {
406
+ const l = e.defaultDocumentStyle === void 0 ? " (the default, DEFAULT_MARKDOWN_STYLE; name one of documentStyles)" : "";
407
+ throw new RangeError(`[markdown-explorer] defaultDocumentStyle must name a configured document style (${[...c].map((k) => JSON.stringify(k)).join(", ")}); got ${JSON.stringify(f)}${l}`);
401
408
  }
402
409
  return Object.freeze({
403
410
  basePath: e.basePath,
@@ -405,70 +412,71 @@ const R = (e) => {
405
412
  settingsCookie: e.settingsCookie,
406
413
  views: t,
407
414
  multiView: Object.freeze({
408
- maxPanels: S("multiView.maxPanels", r.maxPanels, et),
409
- columns: S("multiView.columns", r.columns, tt)
415
+ maxPanels: y("multiView.maxPanels", r.maxPanels, tt),
416
+ columns: y("multiView.columns", r.columns, nt)
410
417
  }),
411
418
  expandAll: Object.freeze({
412
- maxFolders: S("expandAll.maxFolders", o.maxFolders, nt),
413
- maxDepth: S("expandAll.maxDepth", o.maxDepth, rt)
419
+ maxFolders: y("expandAll.maxFolders", o.maxFolders, rt),
420
+ maxDepth: y("expandAll.maxDepth", o.maxDepth, ot)
414
421
  }),
415
- revealDocument: Object.freeze({ maxDepth: S("revealDocument.maxDepth", s.maxDepth, ot) }),
416
- documentStyles: Object.freeze(a.map((c) => Object.freeze({ name: c.name, className: c.className }))),
422
+ revealDocument: Object.freeze({ maxDepth: y("revealDocument.maxDepth", s.maxDepth, st) }),
423
+ documentStyles: Object.freeze(a.map((l) => Object.freeze({ name: l.name, className: l.className }))),
424
+ defaultDocumentStyle: f,
417
425
  iframeHosts: Object.freeze([...new Set(n)]),
418
- embeds: ft(e.embeds, e.dataPath),
419
- defaultTreeSettings: gt(e.defaultTreeSettings),
420
- legacyTextEncoding: ut(e.legacyTextEncoding),
426
+ embeds: ut(e.embeds, e.dataPath),
427
+ defaultTreeSettings: wt(e.defaultTreeSettings),
428
+ legacyTextEncoding: gt(e.legacyTextEncoding),
421
429
  spreadsheets: Object.freeze({
422
- maxBytes: S("spreadsheets.maxBytes", i.maxBytes, st),
423
- maxWorkbookBytes: S("spreadsheets.maxWorkbookBytes", i.maxWorkbookBytes, it)
430
+ maxBytes: y("spreadsheets.maxBytes", i.maxBytes, it),
431
+ maxWorkbookBytes: y("spreadsheets.maxWorkbookBytes", i.maxWorkbookBytes, at)
424
432
  })
425
433
  });
426
- }, gn = (e) => {
434
+ }, wn = (e) => {
427
435
  const t = e.embeds;
428
- if (!R(t)) throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${m(t)}`);
436
+ if (!I(t)) throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${d(t)}`);
429
437
  if (Object.hasOwn(t, "linkCards"))
430
- 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 ${m(t.linkCards)})`);
438
+ 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)})`);
431
439
  const n = e.legacyTextEncoding;
432
440
  if (n !== null && typeof n != "string")
433
- throw new TypeError(`[markdown-explorer] config.legacyTextEncoding must be the encoding defineExplorerConfig resolved, or null; got ${m(n)}`);
434
- const { linkCardEndpoint: r, ...o } = t, s = wt({ ...e, embeds: { ...o, linkCards: r !== null }, legacyTextEncoding: n === null ? void 0 : n });
441
+ throw new TypeError(`[markdown-explorer] config.legacyTextEncoding must be the encoding defineExplorerConfig resolved, or null; got ${d(n)}`);
442
+ const { linkCardEndpoint: r, ...o } = t, s = ht({ ...e, embeds: { ...o, linkCards: r !== null }, legacyTextEncoding: n === null ? void 0 : n });
435
443
  if (s.embeds.linkCardEndpoint !== r)
436
- throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${m(s.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${m(r)}`);
444
+ throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${d(s.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${d(r)}`);
437
445
  if (s.legacyTextEncoding !== n)
438
- throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${m(s.legacyTextEncoding)} (the written name of the encoding it names); got ${m(n)}`);
446
+ throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${d(s.legacyTextEncoding)} (the written name of the encoding it names); got ${d(n)}`);
439
447
  const i = e;
440
- for (const [a, l] of Object.entries(s)) {
441
- const c = G(i[a], l, a);
442
- if (c !== null)
443
- throw c.kind === "extra" ? new RangeError(`[markdown-explorer] config.${c.path} is not a key of what defineExplorerConfig resolves; got ${m(c.given)} there`) : new RangeError(`[markdown-explorer] config.${c.path} must be what defineExplorerConfig resolves; got ${m(c.given)} where it resolves ${m(c.resolved)}`);
448
+ for (const [a, c] of Object.entries(s)) {
449
+ const f = W(i[a], c, a);
450
+ if (f !== null)
451
+ throw f.kind === "extra" ? new RangeError(`[markdown-explorer] config.${f.path} is not a key of what defineExplorerConfig resolves; got ${d(f.given)} there`) : new RangeError(`[markdown-explorer] config.${f.path} must be what defineExplorerConfig resolves; got ${d(f.given)} where it resolves ${d(f.resolved)}`);
444
452
  }
445
453
  return s;
446
- }, G = (e, t, n) => {
454
+ }, W = (e, t, n) => {
447
455
  if (Object.is(e, t)) return null;
448
456
  if (Array.isArray(t)) {
449
457
  if (!Array.isArray(e)) return { kind: "value", path: n, given: e, resolved: t };
450
458
  if (e.length !== t.length) return { kind: "value", path: `${n}.length`, given: e.length, resolved: t.length };
451
459
  for (const [o, s] of t.entries()) {
452
- const i = G(e[o], s, `${n}[${String(o)}]`);
460
+ const i = W(e[o], s, `${n}[${String(o)}]`);
453
461
  if (i !== null) return i;
454
462
  }
455
463
  return null;
456
464
  }
457
- if (!(R(t) && R(e))) return { kind: "value", path: n, given: e, resolved: t };
465
+ if (!(I(t) && I(e))) return { kind: "value", path: n, given: e, resolved: t };
458
466
  for (const o of Object.keys(t)) {
459
- const s = G(Object.hasOwn(e, o) ? e[o] : void 0, t[o], `${n}.${o}`);
467
+ const s = W(Object.hasOwn(e, o) ? e[o] : void 0, t[o], `${n}.${o}`);
460
468
  if (s !== null) return s;
461
469
  }
462
470
  const r = Object.keys(e).find((o) => !Object.hasOwn(t, o));
463
471
  return r === void 0 ? null : { kind: "extra", path: `${n}.${r}`, given: e[r] };
464
- }, ht = (e) => typeof e == "string" && lt.test(e), wn = (e, t) => {
465
- if (e === null || typeof e != "object") throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${m(e)}`);
466
- if (!Array.isArray(t) || t.length === 0) throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${m(t)}`);
472
+ }, Et = (e) => typeof e == "string" && dt.test(e), hn = (e, t) => {
473
+ if (e === null || typeof e != "object") throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${d(e)}`);
474
+ if (!Array.isArray(t) || t.length === 0) throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${d(t)}`);
467
475
  for (const n of t)
468
- if (!ht(n)) throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${m(n)}`);
476
+ if (!Et(n)) throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${d(n)}`);
469
477
  if (new Set(t).size !== t.length) throw new RangeError(`[markdown-explorer] source ids must be unique; got ${JSON.stringify(t)}`);
470
478
  return Object.freeze({ ...e, sourceIds: Object.freeze([...t]) });
471
- }, hn = (e) => e.documentStyles.map((t) => t.name), d = Object.freeze({
479
+ }, En = (e) => e.documentStyles.map((t) => t.name), m = Object.freeze({
472
480
  source: "source",
473
481
  doc: "doc",
474
482
  maximized: "maximized",
@@ -481,35 +489,35 @@ const R = (e) => {
481
489
  width: "width",
482
490
  maxWidth: "maxWidth",
483
491
  markup: "markup"
484
- }), ge = "true", j = "/", ce = ".data", we = 256, he = /^\d+(?:\.\d+)?$/u, W = /^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u, Ee = Object.freeze(["showToc", "showStyle", "showAlign"]), le = (e) => {
492
+ }), ge = "true", C = "/", ce = ".data", we = 256, he = /^\d+(?:\.\d+)?$/u, G = /^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u, Ee = Object.freeze(["showToc", "showStyle", "showAlign"]), le = (e) => {
485
493
  const t = encodeURIComponent(e.replaceAll("%", "%25"));
486
494
  return t.endsWith(ce) ? `${t.slice(0, -ce.length)}%2Edata` : t;
487
- }, Et = (e) => e.replaceAll("%25", "%"), pe = (e) => {
495
+ }, pt = (e) => e.replaceAll("%25", "%"), pe = (e) => {
488
496
  const { sourceIds: t } = e;
489
497
  if (t === void 0) throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");
490
498
  return t;
491
- }, pt = (e, t, n) => {
492
- const r = n.getAll(d.source);
499
+ }, St = (e, t, n) => {
500
+ const r = n.getAll(m.source);
493
501
  if (r.length === 0) return t;
494
502
  const [o] = r;
495
503
  return r.length > 1 || o === void 0 || o === t || !e.includes(o) ? null : o;
496
- }, St = (e, t) => {
497
- const n = t.get(d.style), r = t.get(d.align);
504
+ }, yt = (e, t) => {
505
+ const n = t.get(m.style), r = t.get(m.align);
498
506
  return {
499
507
  ...n !== null && e.documentStyles.some((o) => o.name === n) ? { style: n } : {},
500
- ...r !== null && N.includes(r) ? { align: r } : {}
508
+ ...r !== null && $.includes(r) ? { align: r } : {}
501
509
  };
502
510
  }, Se = (e) => Number.isFinite(e) && e >= 0 && e <= we && he.test(String(e)), xt = (e) => {
503
- const t = e.get(d.padding), n = t !== null && he.test(t) ? Number(t) : Number.NaN, r = e.get(d.width), o = e.get(d.maxWidth);
511
+ const t = e.get(m.padding), n = t !== null && he.test(t) ? Number(t) : Number.NaN, r = e.get(m.width), o = e.get(m.maxWidth);
504
512
  return {
505
- ...e.get(d.showToc) === "false" ? { showToc: !1 } : {},
506
- ...e.get(d.showStyle) === "false" ? { showStyle: !1 } : {},
507
- ...e.get(d.showAlign) === "false" ? { showAlign: !1 } : {},
513
+ ...e.get(m.showToc) === "false" ? { showToc: !1 } : {},
514
+ ...e.get(m.showStyle) === "false" ? { showStyle: !1 } : {},
515
+ ...e.get(m.showAlign) === "false" ? { showAlign: !1 } : {},
508
516
  ...Se(n) ? { padding: n } : {},
509
- ...r !== null && W.test(r) ? { width: r } : {},
510
- ...o !== null && W.test(o) ? { maxWidth: o } : {}
517
+ ...r !== null && G.test(r) ? { width: r } : {},
518
+ ...o !== null && G.test(o) ? { maxWidth: o } : {}
511
519
  };
512
- }, yt = (e, t) => [...new Set(t.filter(A))].slice(0, e.multiView.maxPanels), bt = (e, t, n, r) => {
520
+ }, bt = (e, t) => [...new Set(t.filter(P))].slice(0, e.multiView.maxPanels), Ot = (e, t, n, r) => {
513
521
  for (const s of t) H(s);
514
522
  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`);
515
523
  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)}`);
@@ -518,138 +526,138 @@ const R = (e) => {
518
526
  const o = r.find((s) => !t.includes(s));
519
527
  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))}`);
520
528
  }, H = (e) => {
521
- if (!A(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(String(e).slice(0, 80))}`);
529
+ if (!P(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(String(e).slice(0, 80))}`);
522
530
  return e;
523
- }, Ot = (e) => {
524
- if (H(e).endsWith(j)) 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))}`);
531
+ }, kt = (e) => {
532
+ if (H(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))}`);
525
533
  return e;
526
- }, kt = (e, t) => {
534
+ }, Tt = (e, t) => {
527
535
  if (t.style !== void 0 && !e.documentStyles.some((n) => n.name === t.style))
528
536
  throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map((n) => JSON.stringify(n.name)).join(", ")}); got ${JSON.stringify(t.style)}`);
529
- if (t.align !== void 0 && !N.includes(t.align))
530
- throw new RangeError(`[markdown-explorer] overrides.align must be one of ${N.join(", ")}; got ${JSON.stringify(t.align)}`);
531
- }, Tt = (e) => {
537
+ if (t.align !== void 0 && !$.includes(t.align))
538
+ throw new RangeError(`[markdown-explorer] overrides.align must be one of ${$.join(", ")}; got ${JSON.stringify(t.align)}`);
539
+ }, Rt = (e) => {
532
540
  for (const t of Ee)
533
541
  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])}`);
534
542
  if (e.padding !== void 0 && !Se(e.padding)) throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(we)} px in plain decimal digits; got ${String(e.padding)}`);
535
543
  for (const t of ["width", "maxWidth"]) {
536
544
  const n = e[t];
537
- if (n !== void 0 && !W.test(n)) throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${JSON.stringify(n)}`);
545
+ if (n !== void 0 && !G.test(n)) throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${JSON.stringify(n)}`);
538
546
  }
539
- }, Rt = (e, t) => {
547
+ }, _t = (e, t) => {
540
548
  const n = new URLSearchParams();
541
549
  let r = `${e.basePath}/${e.views[t.view]}`;
542
550
  if (t.view === "multi") {
543
551
  const s = t.docs ?? [], i = t.maximized ?? null, a = t.markup ?? [];
544
- bt(e, s, i, a);
545
- for (const l of s) n.append(d.doc, l);
546
- i !== null && n.set(d.maximized, i);
547
- for (const l of s) a.includes(l) && n.append(d.markup, l);
552
+ Ot(e, s, i, a);
553
+ for (const c of s) n.append(m.doc, c);
554
+ i !== null && n.set(m.maximized, i);
555
+ for (const c of s) a.includes(c) && n.append(m.markup, c);
548
556
  } else {
549
557
  const s = t.doc ?? null, i = t.view === "tree" ? t.folder ?? null : null;
550
558
  if (s !== null && i !== null) throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");
551
- s !== null && (r += `/${le(Ot(s))}`), i !== null && (r += `/${le(`${H(i)}${j}`)}`);
559
+ s !== null && (r += `/${le(kt(s))}`), i !== null && (r += `/${le(`${H(i)}${C}`)}`);
552
560
  }
553
561
  if (t.source !== void 0) {
554
562
  const s = pe(e);
555
563
  if (!s.includes(t.source)) throw new RangeError(`[markdown-explorer] unknown source ${JSON.stringify(t.source)}; expected one of ${s.join(", ")}`);
556
- t.source !== s[0] && n.set(d.source, t.source);
564
+ t.source !== s[0] && n.set(m.source, t.source);
557
565
  }
558
- if (t.view !== "multi" && t.overrides !== void 0 && (kt(e, t.overrides), t.overrides.style !== void 0 && n.set(d.style, t.overrides.style), t.overrides.align !== void 0 && n.set(d.align, t.overrides.align)), t.view !== "multi" && t.markup === !0) {
566
+ if (t.view !== "multi" && t.overrides !== void 0 && (Tt(e, t.overrides), t.overrides.style !== void 0 && n.set(m.style, t.overrides.style), t.overrides.align !== void 0 && n.set(m.align, t.overrides.align)), t.view !== "multi" && t.markup === !0) {
559
567
  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");
560
- n.set(d.markup, ge);
568
+ n.set(m.markup, ge);
561
569
  }
562
570
  if (t.view === "single" && t.embed !== void 0) {
563
571
  const { embed: s } = t;
564
- Tt(s);
565
- for (const i of Ee) s[i] === !1 && n.set(d[i], "false");
566
- s.padding !== void 0 && n.set(d.padding, String(s.padding)), s.width !== void 0 && n.set(d.width, s.width), s.maxWidth !== void 0 && n.set(d.maxWidth, s.maxWidth);
572
+ Rt(s);
573
+ for (const i of Ee) s[i] === !1 && n.set(m[i], "false");
574
+ s.padding !== void 0 && n.set(m.padding, String(s.padding)), s.width !== void 0 && n.set(m.width, s.width), s.maxWidth !== void 0 && n.set(m.maxWidth, s.maxWidth);
567
575
  }
568
576
  const o = n.toString();
569
577
  return o === "" ? r : `${r}?${o}`;
570
- }, It = (e, t) => Object.keys(e.views).find((n) => e.views[n] === t), En = (e, t, n) => {
578
+ }, It = (e, t) => Object.keys(e.views).find((n) => e.views[n] === t), pn = (e, t, n) => {
571
579
  const r = pe(e), [o] = r;
572
580
  if (o === void 0) throw new RangeError("[markdown-explorer] the configuration has no source");
573
- const s = pt(r, o, n), i = s === null ? o : s, a = (f) => ({ kind: "redirect", href: Rt(e, f), location: f }), l = () => a({ view: "tree", source: i, doc: null, folder: null, overrides: {}, markup: !1 });
574
- if (t === void 0 || t === "") return l();
575
- const c = t.indexOf("/"), M = c < 0 ? t : t.slice(0, c), L = c < 0 ? null : t.slice(c + 1), E = It(e, M);
576
- if (E === void 0) return l();
577
- if (E === "multi") {
578
- const f = n.getAll(d.doc), y = yt(e, f), D = n.getAll(d.maximized), [z] = D, F = D.length === 1 && z !== void 0 && y.includes(z) ? z : null, U = n.getAll(d.markup), _ = y.filter((T) => U.includes(T)), xe = _.length === U.length && _.every((T, V) => T === U[V]);
579
- return L === null && s !== null && y.length === f.length && y.every((T, V) => T === f[V]) && (D.length === 0 || F !== null) && xe ? { kind: "location", location: { view: "multi", source: i, docs: y, maximized: F, markup: _ } } : a({ view: "multi", source: i, docs: y, maximized: F, markup: _ });
581
+ const s = St(r, o, n), i = s === null ? o : s, a = (u) => ({ kind: "redirect", href: _t(e, u), location: u }), c = () => a({ view: "tree", source: i, doc: null, folder: null, overrides: {}, markup: !1 });
582
+ if (t === void 0 || t === "") return c();
583
+ const f = t.indexOf("/"), l = f < 0 ? t : t.slice(0, f), k = f < 0 ? null : t.slice(f + 1), p = It(e, l);
584
+ if (p === void 0) return c();
585
+ if (p === "multi") {
586
+ const u = n.getAll(m.doc), b = bt(e, u), M = n.getAll(m.maximized), [z] = M, F = M.length === 1 && z !== void 0 && b.includes(z) ? z : null, U = n.getAll(m.markup), A = b.filter((_) => U.includes(_)), ye = A.length === U.length && A.every((_, V) => _ === U[V]);
587
+ return k === null && s !== null && b.length === u.length && b.every((_, V) => _ === u[V]) && (M.length === 0 || F !== null) && ye ? { kind: "location", location: { view: "multi", source: i, docs: b, maximized: F, markup: A } } : a({ view: "multi", source: i, docs: b, maximized: F, markup: A });
580
588
  }
581
- const I = L === null ? null : Et(L), u = I?.endsWith(j) === !0 ? I.slice(0, -j.length) : null, g = I !== null && u === null ? I : null;
582
- if (g !== null && !A(g) || u !== null && !A(u)) return l();
583
- const O = St(e, n), k = (g !== null || u !== null) && n.get(d.markup) === ge;
584
- if (E === "single") {
585
- if (u !== null) return a({ view: "tree", source: i, doc: null, folder: u, overrides: O, markup: k });
586
- if (g === null) return l();
587
- const f = xt(n);
588
- return s === null ? a({ view: E, source: i, doc: g, overrides: O, embed: f, markup: k }) : { kind: "location", location: { view: E, source: i, doc: g, overrides: O, embed: f, markup: k } };
589
+ const N = k === null ? null : pt(k), g = N?.endsWith(C) === !0 ? N.slice(0, -C.length) : null, w = N !== null && g === null ? N : null;
590
+ if (w !== null && !P(w) || g !== null && !P(g)) return c();
591
+ const T = yt(e, n), R = (w !== null || g !== null) && n.get(m.markup) === ge;
592
+ if (p === "single") {
593
+ if (g !== null) return a({ view: "tree", source: i, doc: null, folder: g, overrides: T, markup: R });
594
+ if (w === null) return c();
595
+ const u = xt(n);
596
+ return s === null ? a({ view: p, source: i, doc: w, overrides: T, embed: u, markup: R }) : { kind: "location", location: { view: p, source: i, doc: w, overrides: T, embed: u, markup: R } };
589
597
  }
590
- return s === null ? a({ view: E, source: i, doc: g, folder: u, overrides: O, markup: k }) : { kind: "location", location: { view: E, source: i, doc: g, folder: u, overrides: O, markup: k } };
598
+ return s === null ? a({ view: p, source: i, doc: w, folder: g, overrides: T, markup: R }) : { kind: "location", location: { view: p, source: i, doc: w, folder: g, overrides: T, markup: R } };
591
599
  };
592
600
  export {
593
- rt as $,
601
+ ot as $,
594
602
  ue as A,
595
603
  Gt as B,
596
- qt as C,
597
- Wt as D,
598
- on as E,
599
- Yt as F,
600
- Xt as G,
601
- rn as H,
602
- dn as I,
603
- Mt as J,
604
- sn as K,
605
- Ht as L,
606
- h as M,
607
- P as N,
608
- Pt as O,
609
- Zt as P,
610
- Vt as Q,
611
- Dt as R,
612
- nn as S,
613
- Ut as T,
604
+ Yt as C,
605
+ Xt as D,
606
+ sn as E,
607
+ Zt as F,
608
+ Kt as G,
609
+ on as H,
610
+ mn as I,
611
+ Lt as J,
612
+ an as K,
613
+ qt as L,
614
+ E as M,
615
+ D as N,
616
+ vt as O,
617
+ Qt as P,
618
+ Jt as Q,
619
+ zt as R,
620
+ rn as S,
621
+ Vt as T,
614
622
  Bt as U,
615
623
  te as V,
616
- Ft as W,
617
- un as X,
618
- en as Y,
624
+ Ut as W,
625
+ gn as X,
626
+ tn as Y,
619
627
  ee as Z,
620
628
  se as _,
621
- We as a,
622
- nt as a0,
623
- Ue as a1,
624
- tt as a2,
625
- et as a3,
626
- ot as a4,
627
- st as a5,
628
- it as a6,
629
- wt as a7,
630
- Kt as b,
631
- yt as c,
632
- ln as d,
633
- Rt as e,
629
+ Xe as a,
630
+ rt as a0,
631
+ Ve as a1,
632
+ nt as a2,
633
+ tt as a3,
634
+ st as a4,
635
+ it as a5,
636
+ at as a6,
637
+ ht as a7,
638
+ Ht as b,
639
+ bt as c,
640
+ dn as d,
641
+ _t as e,
634
642
  Ct as f,
635
- hn as g,
636
- En as h,
637
- ht as i,
638
- mn as j,
639
- R as k,
643
+ En as g,
644
+ pn as h,
645
+ Et as i,
646
+ fn as j,
647
+ I as k,
640
648
  de as l,
641
- vt as m,
642
- cn as n,
643
- an as o,
644
- fn as p,
645
- Qt as q,
646
- gn as r,
649
+ Dt as m,
650
+ ln as n,
651
+ cn as o,
652
+ un as p,
653
+ en as q,
654
+ wn as r,
647
655
  Be as s,
648
656
  jt as t,
649
- Jt as u,
650
- zt as v,
651
- wn as w,
652
- Lt as x,
653
- tn as y,
657
+ Wt as u,
658
+ Ft as v,
659
+ hn as w,
660
+ Mt as x,
661
+ nn as y,
654
662
  Ge as z
655
663
  };