@aiquants/markdown-explorer 0.32.0 → 0.34.0

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