@aiquants/markdown-explorer 0.38.0 → 0.39.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 (35) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +2 -2
  3. package/dist/{EditSurface-BTrQ1viw.js → EditSurface-CUPN9dUY.js} +211 -211
  4. package/dist/{EditSurface-Dis52Iwq.cjs → EditSurface-CZnjX0sv.cjs} +2 -2
  5. package/dist/{ExplorerSplit-Dq7HfNre.js → ExplorerSplit-DHpgdXhb.js} +407 -407
  6. package/dist/{ExplorerSplit-13nPIuf0.cjs → ExplorerSplit-DWBhCe7m.cjs} +1 -1
  7. package/dist/{MultiLayout-B7RvBpCj.cjs → MultiLayout-BkHbfUuh.cjs} +1 -1
  8. package/dist/{MultiLayout-1rKm2Hzt.js → MultiLayout-HmvjE8ht.js} +3 -3
  9. package/dist/{NativeScrollBar-D63-6AL1.cjs → NativeScrollBar-CzGhZ-w3.cjs} +1 -1
  10. package/dist/{NativeScrollBar-Bg05yuzM.js → NativeScrollBar-DAukiH01.js} +2 -2
  11. package/dist/{TreeLayout-CNE0XkWz.cjs → TreeLayout-BEvPaxLb.cjs} +1 -1
  12. package/dist/{TreeLayout-9eEP62LF.js → TreeLayout-dtnugwQ7.js} +3 -3
  13. package/dist/core/geometry.d.cts +0 -1
  14. package/dist/core/geometry.d.ts +0 -1
  15. package/dist/{explorerCore-GCqatHTO.js → explorerCore-CUtc1Vmx.js} +1 -1
  16. package/dist/{explorerCore-5qeC3-gt.cjs → explorerCore-Dj7RxZRd.cjs} +1 -1
  17. package/dist/{index-C52Nj37x.js → index-BBJoJu-b.js} +7 -7
  18. package/dist/{index-_XNluAcx.cjs → index-D6at9qMs.cjs} +5 -5
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +15 -15
  21. package/dist/location-DFXJSMit.cjs +1 -0
  22. package/dist/{location-CJvL6JNs.js → location-T9o5XYpX.js} +74 -75
  23. package/dist/{merge-CnrrjXmc.js → merge-CkMe5hqA.js} +1 -1
  24. package/dist/{merge-CKpFyeqR.cjs → merge-XyuOlVWP.cjs} +1 -1
  25. package/dist/server.cjs +1 -1
  26. package/dist/server.js +3 -3
  27. package/dist/serverCore.cjs +1 -1
  28. package/dist/serverCore.js +3 -3
  29. package/dist/styles/markdown-explorer.css +1 -1
  30. package/dist/{tapScrollCircle-D-Lgzdxx.js → tapScrollCircle-CvWJKtbF.js} +1 -1
  31. package/dist/{tapScrollCircle-6etmzCb7.cjs → tapScrollCircle-ExxyHVWY.cjs} +1 -1
  32. package/dist/{useSplitPersistence-CD_n1ivo.cjs → useSplitPersistence-BCitqdAe.cjs} +1 -1
  33. package/dist/{useSplitPersistence-tbTu3P5m.js → useSplitPersistence-C86jW1yY.js} +1 -1
  34. package/package.json +3 -3
  35. package/dist/location-DOIG84V9.cjs +0 -1
@@ -1,24 +1,24 @@
1
1
  import { jsx as M, jsxs as re, Fragment as et } from "react/jsx-runtime";
2
2
  import { useState as oe, useRef as N, useLayoutEffect as D, useEffectEvent as Ee, useEffect as Ve, useImperativeHandle as tt, useMemo as Y, startTransition as nt, useCallback as J, useId as rt } from "react";
3
- import { v as ie, k as ge, l as ot, u as se, m as it, n as st, o as lt, p as ct, q as at, t as ut, w as He, A as dt, x as Fe, c as ft, y as mt, E as pt, z as ht, B as gt, G as vt, H as wt, I as Se, J as xe, K as bt, L as Et, M as ye, O as St, Q as xt, R as yt, S as kt } from "./index-C52Nj37x.js";
4
- import { fencedBodyAsRead as Tt, planFencedBodyEdit as At, fencedCodeLanguageOf as It, SPREADSHEETS_LANGUAGE as Ot, readFencedLine as Ct, listItemWidthOn as Lt, openingFenceOn as Mt } from "@aiquants/markdown/code-blocks";
5
- import { history as qt, historyKeymap as Rt, defaultKeymap as _t, historyField as Pt, redo as Nt, undo as Dt, isolateHistory as Bt } from "@codemirror/commands";
6
- import { markdown as Vt, markdownLanguage as Ht } from "@codemirror/lang-markdown";
7
- import { syntaxHighlighting as Ft, syntaxTreeAvailable as zt, HighlightStyle as Gt, ensureSyntaxTree as ze } from "@codemirror/language";
8
- import { highlightSelectionMatches as Ut, searchKeymap as Wt } from "@codemirror/search";
9
- import { EditorState as Ge, EditorSelection as he, StateField as Kt, RangeSetBuilder as $t, MapMode as Xt } from "@codemirror/state";
10
- import { EditorView as $, lineNumbers as jt, highlightActiveLineGutter as Yt, drawSelection as Jt, highlightActiveLine as Qt, keymap as Zt, ViewPlugin as en, Decoration as ue, WidgetType as tn } from "@codemirror/view";
3
+ import { v as ie, k as ge, l as ot, u as se, m as it, n as st, o as lt, p as ct, q as at, t as ut, w as He, A as dt, x as ze, y as ft, E as mt, z as pt, B as ht, G as gt, H as vt, I as xe, J as Se, K as wt, L as bt, M as ye, O as Et, Q as xt, R as St, S as yt } from "./index-BBJoJu-b.js";
4
+ import { fencedBodyAsRead as kt, planFencedBodyEdit as Tt, fencedCodeLanguageOf as At, SPREADSHEETS_LANGUAGE as It, readFencedLine as Ot, listItemWidthOn as Ct, openingFenceOn as Lt } from "@aiquants/markdown/code-blocks";
5
+ import { history as Mt, historyKeymap as qt, defaultKeymap as Rt, historyField as _t, redo as Pt, undo as Nt, isolateHistory as Dt } from "@codemirror/commands";
6
+ import { markdown as Bt, markdownLanguage as Vt } from "@codemirror/lang-markdown";
7
+ import { syntaxHighlighting as Ht, syntaxTreeAvailable as zt, HighlightStyle as Ft, ensureSyntaxTree as Fe } from "@codemirror/language";
8
+ import { highlightSelectionMatches as Ut, searchKeymap as Gt } from "@codemirror/search";
9
+ import { EditorState as Ue, EditorSelection as he, StateField as Wt, RangeSetBuilder as Kt, MapMode as $t } from "@codemirror/state";
10
+ import { EditorView as $, lineNumbers as Xt, highlightActiveLineGutter as jt, drawSelection as Yt, highlightActiveLine as Jt, keymap as Qt, ViewPlugin as Zt, Decoration as ue, WidgetType as en } from "@codemirror/view";
11
11
  import { tags as _ } from "@lezer/highlight";
12
- import { MarkdownViewer as nn } from "@aiquants/markdown";
13
- import { SOURCE_LINES_ATTRIBUTE as Ue, parseSourceLines as rn } from "@aiquants/markdown/source-lines";
14
- import { U as on, k as le, E as sn } from "./ownUrls-DD0cSCsF.js";
15
- import { H as ln, c as cn, M as an } from "./sanitizePolicy-DAPnUUVm.js";
16
- import un from "isomorphic-dompurify";
17
- import { o as dn, C as fn, F as mn, E as pn, m as hn, n as ce, q as gn } from "./location-CJvL6JNs.js";
18
- import { d as vn } from "./describeValue-CLlVRO8d.js";
19
- import { PanelGroup as wn, Panel as ke, PanelResizeHandle as bn } from "@aiquants/resize-panels";
20
- import { t as En, u as Sn } from "./useSplitPersistence-tbTu3P5m.js";
21
- const We = { history: Pt }, xn = Gt.define([
12
+ import { MarkdownViewer as tn } from "@aiquants/markdown";
13
+ import { SOURCE_LINES_ATTRIBUTE as Ge, parseSourceLines as nn } from "@aiquants/markdown/source-lines";
14
+ import { U as rn, k as le, E as on } from "./ownUrls-DD0cSCsF.js";
15
+ import { H as sn, c as ln, M as cn } from "./sanitizePolicy-DAPnUUVm.js";
16
+ import an from "isomorphic-dompurify";
17
+ import { o as un, C as dn, E as fn, m as mn, n as ce, q as pn } from "./location-T9o5XYpX.js";
18
+ import { d as hn } from "./describeValue-CLlVRO8d.js";
19
+ import { PanelGroup as gn, Panel as ke, PanelResizeHandle as vn } from "@aiquants/resize-panels";
20
+ import { t as wn, u as bn } from "./useSplitPersistence-C86jW1yY.js";
21
+ const We = { history: _t }, En = Ft.define([
22
22
  { tag: [_.heading1, _.heading2, _.heading3, _.heading4, _.heading5, _.heading6, _.heading], color: "var(--aqmx-syntax-heading)", fontWeight: "700" },
23
23
  { tag: _.strong, fontWeight: "700" },
24
24
  { tag: _.emphasis, fontStyle: "italic" },
@@ -28,7 +28,7 @@ const We = { history: Pt }, xn = Gt.define([
28
28
  { tag: _.monospace, color: "var(--aqmx-syntax-code)" },
29
29
  { tag: _.quote, color: "var(--aqmx-syntax-quote)" },
30
30
  { tag: [_.processingInstruction, _.contentSeparator, _.labelName, _.meta], color: "var(--aqmx-syntax-mark)" }
31
- ]), yn = $.theme({
31
+ ]), xn = $.theme({
32
32
  "&": { height: "100%", color: "var(--aqmx-text)", backgroundColor: "var(--aqmx-surface)", fontSize: "var(--aqmx-font-size-title)" },
33
33
  "&.cm-focused": { outline: "none" },
34
34
  ".cm-scroller": { fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace', lineHeight: "var(--aqmx-line-height-prose)" },
@@ -41,8 +41,8 @@ const We = { history: Pt }, xn = Gt.define([
41
41
  ".cm-activeLineGutter": { backgroundColor: "var(--aqmx-editor-active-line)" },
42
42
  ".cm-searchMatch": { outline: "var(--aqmx-space-1) solid var(--aqmx-border-strong)" },
43
43
  ".cm-panels": { backgroundColor: "var(--aqmx-surface-raised)", color: "var(--aqmx-text)" }
44
- }), Ke = "data-aqmx-conflict-actions", kn = ue.line({ attributes: { "data-aqmx-conflict-line": "marker" } }), Tn = ue.line({ attributes: { "data-aqmx-conflict-line": "ours" } }), An = ue.line({ attributes: { "data-aqmx-conflict-line": "theirs" } });
45
- class In extends tn {
44
+ }), Ke = "data-aqmx-conflict-actions", Sn = ue.line({ attributes: { "data-aqmx-conflict-line": "marker" } }), yn = ue.line({ attributes: { "data-aqmx-conflict-line": "ours" } }), kn = ue.line({ attributes: { "data-aqmx-conflict-line": "theirs" } });
45
+ class Tn extends en {
46
46
  constructor(t, n) {
47
47
  super(), this.index = t, this.labels = n;
48
48
  }
@@ -72,16 +72,16 @@ class In extends tn {
72
72
  }
73
73
  }
74
74
  const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
75
- const n = new $t();
75
+ const n = new Kt();
76
76
  return ne(e).forEach((o, i) => {
77
77
  const r = e.line(o.start);
78
- n.add(r.from, r.from, ue.widget({ widget: new In(i, t), block: !0, side: -1 }));
78
+ n.add(r.from, r.from, ue.widget({ widget: new Tn(i, t), block: !0, side: -1 }));
79
79
  for (let l = o.start; l <= o.end; l += 1) {
80
- const s = e.line(l).from, f = l === o.start || l === o.separator || l === o.end ? kn : l < o.separator ? Tn : An;
80
+ const s = e.line(l).from, f = l === o.start || l === o.separator || l === o.end ? Sn : l < o.separator ? yn : kn;
81
81
  n.add(s, s, f);
82
82
  }
83
83
  }), n.finish();
84
- }, On = (e) => Kt.define({
84
+ }, An = (e) => Wt.define({
85
85
  create: (t) => Te(t.doc, e),
86
86
  update: (t, n) => n.docChanged ? Te(n.state.doc, e) : t,
87
87
  provide: (t) => $.decorations.from(t)
@@ -96,7 +96,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
96
96
  const b = s.join(`
97
97
  `);
98
98
  e.dispatch({ changes: { from: f, to: d, insert: b }, selection: he.cursor(f), scrollIntoView: !0, userEvent: "input.resolve" });
99
- }, Ae = "input.preview", Cn = 20, Ln = en.fromClass(
99
+ }, Ae = "input.preview", In = 20, On = Zt.fromClass(
100
100
  class {
101
101
  constructor(e) {
102
102
  this.view = e, this.schedule();
@@ -111,7 +111,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
111
111
  const e = this.view.dom.ownerDocument.defaultView;
112
112
  if (e === null) return;
113
113
  const t = () => {
114
- this.cancel = null, ze(this.view.state, this.view.state.doc.length, Cn), this.schedule();
114
+ this.cancel = null, Fe(this.view.state, this.view.state.doc.length, In), this.schedule();
115
115
  };
116
116
  if (typeof e.requestIdleCallback == "function") {
117
117
  const n = e.requestIdleCallback(t);
@@ -125,7 +125,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
125
125
  this.cancel?.(), this.cancel = null;
126
126
  }
127
127
  }
128
- ), Mn = /`{3,}|~{3,}/u, ee = Object.freeze({ kind: "absent" }), me = Object.freeze({ kind: "unreadable" }), qn = (e, t, n) => {
128
+ ), Cn = /`{3,}|~{3,}/u, ee = Object.freeze({ kind: "absent" }), me = Object.freeze({ kind: "unreadable" }), Ln = (e, t, n) => {
129
129
  const o = [];
130
130
  for (let f = t.parent; f !== null; f = f.parent)
131
131
  (f.name === "Blockquote" || f.name === "ListItem") && o.unshift(f);
@@ -136,20 +136,20 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
136
136
  for (const f of o) {
137
137
  const d = e.lineAt(f.from).number;
138
138
  if (f.name === "ListItem") {
139
- const b = Lt(e.line(d).text, i, l(d));
139
+ const b = Ct(e.line(d).text, i, l(d));
140
140
  if (b === null) return null;
141
141
  i.push({ kind: "listItem", width: b });
142
142
  } else
143
143
  i.push({ kind: "quote" });
144
144
  r.push(d);
145
145
  }
146
- const s = Mt(n.text, i, l(n.number));
146
+ const s = Lt(n.text, i, l(n.number));
147
147
  return s === null ? null : { containers: i, ...s };
148
- }, Rn = (e, t) => {
148
+ }, Mn = (e, t) => {
149
149
  const { doc: n } = e;
150
150
  let o = n.lineAt(t).to;
151
151
  for (; ; ) {
152
- const i = ze(e, o, Number.POSITIVE_INFINITY);
152
+ const i = Fe(e, o, Number.POSITIVE_INFINITY);
153
153
  if (i === null) return null;
154
154
  const r = i.resolveInner(t, 1), l = r.parent;
155
155
  if (r.name !== "CodeMark" || l === null || l.name !== "FencedCode" || l.from !== r.from) return null;
@@ -159,58 +159,58 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
159
159
  }, Ie = (e, t) => {
160
160
  const { doc: n } = e;
161
161
  if (!Number.isInteger(t) || t < 1 || t > n.lines) return ee;
162
- const o = n.line(t), i = Mn.exec(o.text);
162
+ const o = n.line(t), i = Cn.exec(o.text);
163
163
  if (i === null) return ee;
164
- const r = Rn(e, o.from + i.index);
164
+ const r = Mn(e, o.from + i.index);
165
165
  if (r === null) return ee;
166
166
  const l = r.getChild("CodeInfo");
167
167
  if (l === null) return ee;
168
- const s = It(n.sliceString(l.from, l.to));
168
+ const s = At(n.sliceString(l.from, l.to));
169
169
  if (s === null) return me;
170
- if (s !== Ot) return ee;
171
- const f = qn(n, r, o);
170
+ if (s !== It) return ee;
171
+ const f = Ln(n, r, o);
172
172
  if (f === null) return me;
173
173
  const [, ...d] = r.getChildren("CodeMark"), b = d.at(-1), w = b === void 0 ? n.lineAt(r.to).number : n.lineAt(b.from).number - 1, c = [];
174
174
  let v = "";
175
175
  for (let u = t + 1; u <= w; u += 1) {
176
- const m = n.line(u).text, h = Ct(m, f);
176
+ const m = n.line(u).text, h = Ot(m, f);
177
177
  if (h === null) return me;
178
178
  c.push(m), v += u < n.lines ? `${h.content}
179
179
  ` : h.content;
180
180
  }
181
181
  return { kind: "found", firstLine: t + 1, lines: c, layout: f, body: v };
182
- }, _n = ({ parent: e, scroll: t, text: n, saved: o, labels: i, revisions: r, onChange: l, onGeometry: s, onSave: f }) => {
182
+ }, qn = ({ parent: e, scroll: t, text: n, saved: o, labels: i, revisions: r, onChange: l, onGeometry: s, onSave: f }) => {
183
183
  let d = !1;
184
184
  const b = [
185
- $.scrollHandler.of((u, m, h) => (Pn(u, m.head, h, t), !0)),
185
+ $.scrollHandler.of((u, m, h) => (Rn(u, m.head, h, t), !0)),
186
+ Xt(),
186
187
  jt(),
188
+ Mt(),
187
189
  Yt(),
188
- qt(),
189
190
  Jt(),
190
- Qt(),
191
191
  Ut(),
192
192
  $.lineWrapping,
193
- Vt({ base: Ht }),
194
- Ln,
195
- Ft(xn),
196
- On(i),
197
- Zt.of([
193
+ Bt({ base: Vt }),
194
+ On,
195
+ Ht(En),
196
+ An(i),
197
+ Qt.of([
198
198
  {
199
199
  key: "Mod-s",
200
200
  preventDefault: !0,
201
201
  run: () => (f(), !0)
202
202
  },
203
- ...Wt,
204
- ...Rt,
205
- ..._t
203
+ ...Gt,
204
+ ...qt,
205
+ ...Rt
206
206
  ]),
207
207
  $.contentAttributes.of({ "aria-label": i.editor, "aria-multiline": "true" }),
208
208
  $.updateListener.of((u) => {
209
209
  for (const m of u.transactions) m.docChanged && r.record(m.changes, m.newDoc);
210
210
  u.docChanged && l(u.transactions.every((m) => !m.docChanged || m.isUserEvent(Ae))), (u.docChanged || u.heightChanged || u.geometryChanged) && s(u.docChanged && !d);
211
211
  }),
212
- yn
213
- ], w = Bn(o, b) ?? Ge.create({ doc: n, extensions: b }), c = new $({ state: w, parent: e });
212
+ xn
213
+ ], w = Nn(o, b) ?? Ue.create({ doc: n, extensions: b }), c = new $({ state: w, parent: e });
214
214
  r.mount(c.state.doc);
215
215
  const v = (u) => {
216
216
  d = !0;
@@ -226,74 +226,74 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
226
226
  const m = c.state.doc.toString();
227
227
  if (m === u) return;
228
228
  let h = 0;
229
- const S = Math.min(m.length, u.length);
230
- for (; h < S && m.charCodeAt(h) === u.charCodeAt(h); ) h += 1;
229
+ const x = Math.min(m.length, u.length);
230
+ for (; h < x && m.charCodeAt(h) === u.charCodeAt(h); ) h += 1;
231
231
  let p = 0;
232
- for (; p < S - h && m.charCodeAt(m.length - 1 - p) === u.charCodeAt(u.length - 1 - p); ) p += 1;
232
+ for (; p < x - h && m.charCodeAt(m.length - 1 - p) === u.charCodeAt(u.length - 1 - p); ) p += 1;
233
233
  c.dispatch({ changes: { from: h, to: m.length - p, insert: u.slice(h, u.length - p) }, userEvent: "input.replace" });
234
234
  },
235
- replaceBody: (u, m, h, S) => {
236
- const { doc: p } = c.state, x = r.lineOf(S, u);
237
- if (x === null) return "changed";
238
- const I = Ie(c.state, x);
235
+ replaceBody: (u, m, h, x) => {
236
+ const { doc: p } = c.state, S = r.lineOf(x, u);
237
+ if (S === null) return "changed";
238
+ const I = Ie(c.state, S);
239
239
  if (I.kind === "absent") return "changed";
240
240
  if (I.kind === "unreadable") return "unwritable";
241
- if (I.body !== Tt(m, I.layout)) return "changed";
242
- const k = At(I.lines, I.layout, h);
241
+ if (I.body !== kt(m, I.layout)) return "changed";
242
+ const k = Tt(I.lines, I.layout, h);
243
243
  if (k.kind !== "edit") return k.kind;
244
244
  if (k.from === k.to && k.lines.length === 0) return "written";
245
- const R = (F) => {
246
- const V = I.firstLine + F;
245
+ const R = (z) => {
246
+ const V = I.firstLine + z;
247
247
  return V <= p.lines ? p.line(V).from : p.length;
248
248
  }, L = R(k.from), B = `${L === p.length && p.sliceString(p.length - 1) !== `
249
249
  ` ? `
250
- ` : ""}${k.lines.map((F) => `${F}
250
+ ` : ""}${k.lines.map((z) => `${z}
251
251
  `).join("")}`;
252
- return v(() => c.dispatch({ changes: { from: L, to: R(k.to), insert: B }, userEvent: Ae, annotations: Bt.of("full") })), "written";
252
+ return v(() => c.dispatch({ changes: { from: L, to: R(k.to), insert: B }, userEvent: Ae, annotations: Dt.of("full") })), "written";
253
253
  },
254
254
  readBody: (u, m) => {
255
255
  const h = r.lineOf(m, u);
256
256
  if (h === null) return null;
257
- const S = Ie(c.state, h);
258
- return S.kind === "found" ? S.body : null;
257
+ const x = Ie(c.state, h);
258
+ return x.kind === "found" ? x.body : null;
259
259
  },
260
- undo: () => v(() => Dt(c)),
261
- redo: () => v(() => Nt(c)),
260
+ undo: () => v(() => Nt(c)),
261
+ redo: () => v(() => Pt(c)),
262
262
  reveal: ({ line: u, column: m }, h) => {
263
- const { doc: S } = c.state, p = S.line(Math.min(Math.max(u, 1), S.lines)), x = Math.min(p.from + m, p.to);
264
- c.dispatch({ selection: he.cursor(x), effects: Oe(c, x, h, t) });
263
+ const { doc: x } = c.state, p = x.line(Math.min(Math.max(u, 1), x.lines)), S = Math.min(p.from + m, p.to);
264
+ c.dispatch({ selection: he.cursor(S), effects: Oe(c, S, h, t) });
265
265
  },
266
266
  showLine: (u) => {
267
267
  const { doc: m } = c.state, h = m.line(Math.min(Math.max(u, 1), m.lines)).from;
268
268
  c.dispatch({ effects: Oe(c, h, null, t) });
269
269
  },
270
270
  topLine: () => {
271
- const u = t.scrollerOf(c.scrollDOM), m = ie(u, c.contentDOM), h = ge(u) + u.clientHeight, { documentTop: S } = c, { doc: p } = c.state;
272
- let x = c.lineBlockAtHeight(Math.max(m - S, 0));
273
- for (; p.lineAt(x.from).text.trim() === "" && x.to < p.length; ) {
274
- const R = c.lineBlockAt(x.to + 1);
275
- if (S + R.top >= h) break;
276
- x = R;
271
+ const u = t.scrollerOf(c.scrollDOM), m = ie(u, c.contentDOM), h = ge(u) + u.clientHeight, { documentTop: x } = c, { doc: p } = c.state;
272
+ let S = c.lineBlockAtHeight(Math.max(m - x, 0));
273
+ for (; p.lineAt(S.from).text.trim() === "" && S.to < p.length; ) {
274
+ const R = c.lineBlockAt(S.to + 1);
275
+ if (x + R.top >= h) break;
276
+ S = R;
277
277
  }
278
- const I = c.coordsAtPos(x.from), k = I === null ? S + x.top : I.top;
279
- return { line: c.state.doc.lineAt(x.from).number, clientTop: k, offset: k - m };
278
+ const I = c.coordsAtPos(S.from), k = I === null ? x + S.top : I.top;
279
+ return { line: c.state.doc.lineAt(S.from).number, clientTop: k, offset: k - m };
280
280
  },
281
281
  lineSpans: (u) => {
282
- const m = c.scrollDOM, h = m.scrollTop + c.documentTop - ie(m, c.contentDOM), { doc: S } = c.state, p = (x) => S.line(Math.min(Math.max(x, 1), S.lines)).from;
283
- return u.map(({ first: x, last: I }) => ({ top: h + c.lineBlockAt(p(x)).top, bottom: h + c.lineBlockAt(p(I)).bottom }));
282
+ const m = c.scrollDOM, h = m.scrollTop + c.documentTop - ie(m, c.contentDOM), { doc: x } = c.state, p = (S) => x.line(Math.min(Math.max(S, 1), x.lines)).from;
283
+ return u.map(({ first: S, last: I }) => ({ top: h + c.lineBlockAt(p(S)).top, bottom: h + c.lineBlockAt(p(I)).bottom }));
284
284
  },
285
285
  scrollElement: c.scrollDOM,
286
286
  focus: () => c.focus(),
287
287
  conflicts: () => ne(c.state.doc),
288
288
  resolveAtCursor: (u) => {
289
- const m = ne(c.state.doc), h = c.state.doc.lineAt(c.state.selection.main.head).number, S = m.find((p) => p.end >= h);
290
- return S === void 0 ? !1 : ($e(c, S, u), !0);
289
+ const m = ne(c.state.doc), h = c.state.doc.lineAt(c.state.selection.main.head).number, x = m.find((p) => p.end >= h);
290
+ return x === void 0 ? !1 : ($e(c, x, u), !0);
291
291
  },
292
292
  nextConflict: () => {
293
293
  const u = ne(c.state.doc);
294
294
  if (u[0] === void 0) return !1;
295
- const h = c.state.doc.lineAt(c.state.selection.main.head).number, S = u.findIndex((k) => k.start > h), p = S < 0 ? 0 : S, x = c.state.doc.line(u[p].start).from;
296
- c.dispatch({ selection: he.cursor(x), effects: $.scrollIntoView(x, { y: "center" }) });
295
+ const h = c.state.doc.lineAt(c.state.selection.main.head).number, x = u.findIndex((k) => k.start > h), p = x < 0 ? 0 : x, S = c.state.doc.line(u[p].start).from;
296
+ c.dispatch({ selection: he.cursor(S), effects: $.scrollIntoView(S, { y: "center" }) });
297
297
  const I = c.contentDOM.querySelector(`[${Ke}="${String(p)}"] button`);
298
298
  return I instanceof HTMLElement ? I.focus({ preventScroll: !0 }) : c.focus(), !0;
299
299
  },
@@ -303,8 +303,8 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
303
303
  }, Oe = (e, t, n, o) => {
304
304
  const i = o.scrollerOf(e.scrollDOM), r = (n === null ? ie(i, e.contentDOM) : n) - ge(i);
305
305
  return $.scrollIntoView(t, { y: "start", yMargin: r });
306
- }, Pn = (e, t, n, o) => {
307
- const i = Nn(e, t), r = o.scrollerOf(e.scrollDOM), l = ge(r), s = ie(r, e.contentDOM), f = l + r.clientHeight;
306
+ }, Rn = (e, t, n, o) => {
307
+ const i = _n(e, t), r = o.scrollerOf(e.scrollDOM), l = ge(r), s = ie(r, e.contentDOM), f = l + r.clientHeight;
308
308
  let d = 0;
309
309
  switch (n.y) {
310
310
  case "start":
@@ -320,9 +320,9 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
320
320
  i.top < s + n.yMargin ? d = i.top - (s + n.yMargin) : i.bottom > f - n.yMargin && (d = Math.min(i.bottom - (f - n.yMargin), i.top - (s + n.yMargin)));
321
321
  }
322
322
  if (d !== 0 && (r.scrollTop += d), n.y === "start") return;
323
- const b = Dn(e, t);
323
+ const b = Pn(e, t);
324
324
  b !== null && o.reveal(b);
325
- }, Nn = (e, t) => {
325
+ }, _n = (e, t) => {
326
326
  const { node: n, offset: o } = e.domAtPos(t);
327
327
  if (n.nodeType === Node.TEXT_NODE) {
328
328
  const l = n.ownerDocument?.createRange();
@@ -334,60 +334,60 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
334
334
  }
335
335
  const i = e.lineBlockAt(t), r = e.documentTop + i.top;
336
336
  return { top: r, bottom: r + i.height };
337
- }, Dn = (e, t) => {
337
+ }, Pn = (e, t) => {
338
338
  const { node: n } = e.domAtPos(t);
339
339
  for (let o = n instanceof Element ? n : n.parentElement; o !== null; o = o.parentElement)
340
340
  if (o.parentElement === e.contentDOM) return o;
341
341
  return null;
342
- }, Bn = (e, t) => {
342
+ }, Nn = (e, t) => {
343
343
  if (e == null) return null;
344
344
  try {
345
- return Ge.fromJSON(e, { extensions: t }, We);
345
+ return Ue.fromJSON(e, { extensions: t }, We);
346
346
  } catch {
347
347
  return null;
348
348
  }
349
- }, Vn = 610, Hn = 987, Ce = Object.freeze({ kind: "unavailable" }), Fn = "true", zn = "false", Gn = (e) => e === Fn ? !0 : e === zn ? !1 : null, Un = (e) => {
349
+ }, Dn = 610, Bn = 987, Ce = Object.freeze({ kind: "unavailable" }), Vn = "true", Hn = "false", zn = (e) => e === Vn ? !0 : e === Hn ? !1 : null, Fn = (e) => {
350
350
  const t = new DOMParser().parseFromString(e, "text/html"), n = [];
351
351
  for (const o of t.querySelectorAll("img[data-asset-src], a[data-doc-path]")) {
352
352
  const i = o.localName === "img", r = o.getAttribute(i ? "data-asset-src" : "data-doc-path");
353
- r !== null && n.push({ target: { kind: i ? "asset" : "doc", path: r }, exists: Gn(o.getAttribute(i ? "data-asset-exists" : "data-doc-exists")) });
353
+ r !== null && n.push({ target: { kind: i ? "asset" : "doc", path: r }, exists: zn(o.getAttribute(i ? "data-asset-exists" : "data-doc-exists")) });
354
354
  }
355
355
  return n;
356
- }, Wn = ({ path: e, instant: t, preview: n, initial: o, onView: i }) => {
356
+ }, Un = ({ path: e, instant: t, preview: n, initial: o, onView: i }) => {
357
357
  const r = new AbortController(), l = { asset: /* @__PURE__ */ new Map(), doc: /* @__PURE__ */ new Map() };
358
- let s = o, f = null, d = !1, b = !1, w = null, c = null, v = [], u, m = !1, h, S = null;
358
+ let s = o, f = null, d = !1, b = !1, w = null, c = null, v = [], u, m = !1, h, x = null;
359
359
  const p = (g) => {
360
360
  g.parsed === s.parsed && g.source === s.source && g.failure === s.failure && g.busy === s.busy && g.tier === s.tier || (s = g, i(g));
361
- }, x = (g, E) => {
361
+ }, S = (g, E) => {
362
362
  d || (d = !0, console.error(`[markdown-explorer] ${g}`, ...E === void 0 ? [] : [E]));
363
363
  }, I = (g) => {
364
364
  if (t !== null)
365
365
  for (const { target: E, exists: C } of t.marksOf(g)) l[E.kind].set(E.path, C);
366
366
  }, k = () => {
367
- clearTimeout(h), h = void 0, S?.abort(), S = null;
367
+ clearTimeout(h), h = void 0, x?.abort(), x = null;
368
368
  }, R = () => {
369
369
  c = null, v = [], clearTimeout(u), u = void 0;
370
370
  }, L = (g, E) => {
371
371
  p({ ...s, failure: g, busy: !1, tier: E });
372
- }, G = () => {
373
- clearTimeout(u), u = v.length === 0 ? void 0 : setTimeout(F, Hn);
372
+ }, U = () => {
373
+ clearTimeout(u), u = v.length === 0 ? void 0 : setTimeout(z, Bn);
374
374
  }, B = () => {
375
375
  if (t === null || c === null) return;
376
376
  const g = c, E = [], C = { asset: /* @__PURE__ */ new Set(), doc: /* @__PURE__ */ new Set() };
377
- let U;
377
+ let G;
378
378
  try {
379
- U = t.sanitize(g.html, (z) => {
380
- const de = l[z.kind].get(z.path);
381
- return de === void 0 && !C[z.kind].has(z.path) && (C[z.kind].add(z.path), E.push(z)), de ?? void 0;
379
+ G = t.sanitize(g.html, (F) => {
380
+ const de = l[F.kind].get(F.path);
381
+ return de === void 0 && !C[F.kind].has(F.path) && (C[F.kind].add(F.path), E.push(F)), de ?? void 0;
382
382
  });
383
- } catch (z) {
384
- R(), z instanceof ln ? L(le("too-large"), "instant") : (x("the draft sanitizer failed", z), L(le("failed"), "instant"));
383
+ } catch (F) {
384
+ R(), F instanceof sn ? L(le("too-large"), "instant") : (S("the draft sanitizer failed", F), L(le("failed"), "instant"));
385
385
  return;
386
386
  }
387
387
  v = E;
388
- const X = s.parsed !== null && s.parsed.htmlContent === U && s.parsed.headings === g.headings ? s.parsed : { htmlContent: U, headings: g.headings };
389
- p({ parsed: X, source: g.draft, failure: null, busy: !1, tier: "instant" }), G();
390
- }, F = () => {
388
+ const X = s.parsed !== null && s.parsed.htmlContent === G && s.parsed.headings === g.headings ? s.parsed : { htmlContent: G, headings: g.headings };
389
+ p({ parsed: X, source: g.draft, failure: null, busy: !1, tier: "instant" }), U();
390
+ }, z = () => {
391
391
  if (u = void 0, m || c === null || v.length === 0) return;
392
392
  m = !0;
393
393
  const g = v;
@@ -401,34 +401,34 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
401
401
  }, V = (g) => {
402
402
  k(), R(), p({ ...s, busy: !0, tier: "server" });
403
403
  const E = new AbortController();
404
- S = E, h = setTimeout(() => {
404
+ x = E, h = setTimeout(() => {
405
405
  h = void 0, n(e, g.text, E.signal).then((C) => {
406
406
  if (!(E.signal.aborted || !("kind" in C))) {
407
- if (S = null, C.kind === "failure") {
407
+ if (x = null, C.kind === "failure") {
408
408
  L(C.failure, "server");
409
409
  return;
410
410
  }
411
411
  I(C.htmlContent), p({ parsed: { htmlContent: C.htmlContent, headings: C.headings }, source: g, failure: null, busy: !1, tier: "server" });
412
412
  }
413
413
  });
414
- }, Vn);
414
+ }, Dn);
415
415
  }, a = async (g, E) => {
416
416
  let C;
417
417
  try {
418
418
  C = await g.convert({ path: e, text: E }, r.signal);
419
419
  } catch (X) {
420
- return r.signal.aborted || x("the draft converter rejected a conversion, which its contract allows only once the signal aborted", X), Ce;
420
+ return r.signal.aborted || S("the draft converter rejected a conversion, which its contract allows only once the signal aborted", X), Ce;
421
421
  }
422
- const U = on(C);
423
- return U === null ? C : (x(`the draft converter answered outside its contract: ${U}`), Ce);
422
+ const G = rn(C);
423
+ return G === null ? C : (S(`the draft converter answered outside its contract: ${G}`), Ce);
424
424
  }, T = (g, E) => {
425
425
  switch (E.kind) {
426
426
  case "preview":
427
- if (k(), E.headings.length > sn) {
427
+ if (k(), E.headings.length > on) {
428
428
  R(), L(le("too-large"), "instant");
429
429
  return;
430
430
  }
431
- c = { draft: g, html: E.htmlContent, headings: E.headings.map(({ text: C, depth: U, id: X }) => ({ text: C, depth: U, id: X })) }, B();
431
+ c = { draft: g, html: E.htmlContent, headings: E.headings.map(({ text: C, depth: G, id: X }) => ({ text: C, depth: G, id: X })) }, B();
432
432
  return;
433
433
  case "failure":
434
434
  k(), R(), L(le(E.failure.reason, E.failure.code), "instant");
@@ -465,7 +465,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
465
465
  r.abort(), w = null, clearTimeout(u), u = void 0, k();
466
466
  }
467
467
  };
468
- }, Kn = (e) => cn(un(window), e.iframeHosts, e.dataPath, an, dn(e)), $n = (e, t) => e.flatMap((n, o) => {
468
+ }, Gn = (e) => ln(an(window), e.iframeHosts, e.dataPath, cn, un(e)), Wn = (e, t) => e.flatMap((n, o) => {
469
469
  const i = t[o];
470
470
  return i === void 0 ? [] : [
471
471
  { editor: i.top, preview: n.top },
@@ -473,9 +473,9 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
473
473
  ];
474
474
  }), j = (e, t) => {
475
475
  const n = e[t];
476
- if (n === void 0) throw new RangeError(`[markdown-explorer] a scroll map index must be in 0..${String(e.length - 1)}; got ${vn(t)}`);
476
+ if (n === void 0) throw new RangeError(`[markdown-explorer] a scroll map index must be in 0..${String(e.length - 1)}; got ${hn(t)}`);
477
477
  return n;
478
- }, Xn = (e) => {
478
+ }, Kn = (e) => {
479
479
  const t = [];
480
480
  for (const o of e) {
481
481
  let i = 0, r = t.length;
@@ -488,11 +488,11 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
488
488
  const n = [];
489
489
  for (let o = t.at(-1); o !== void 0; o = o.before) n.push(o.pair);
490
490
  return n.reverse();
491
- }, jn = (e, t) => {
491
+ }, $n = (e, t) => {
492
492
  const n = Math.max(t.editorMax, 0), o = Math.max(t.previewMax, 0), i = n - t.editorViewport, r = o - t.previewViewport, l = e.filter((d) => d.editor > 0 && d.editor < i && d.preview > 0 && d.preview < r).sort((d, b) => d.editor - b.editor || d.preview - b.preview);
493
493
  let s = { editor: 0, preview: 0 };
494
494
  const f = [s];
495
- for (const d of Xn(l))
495
+ for (const d of Kn(l))
496
496
  d.editor > s.editor && d.preview > s.preview && (f.push(d), s = d);
497
497
  return f.push({ editor: n, preview: o }), {
498
498
  toPreview: (d) => Le(f, "editor", "preview", d),
@@ -509,33 +509,33 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
509
509
  }
510
510
  const f = j(e, l), d = j(e, s);
511
511
  return f[n] + (d[n] - f[n]) * (o - f[t]) / (d[t] - f[t]);
512
- }, Yn = 610, Me = 89, qe = 0.5, Jn = ({ editor: e, preview: t, previewBlocks: n, editorSpans: o, requestFrame: i, cancelFrame: r, now: l }) => {
512
+ }, Xn = 610, Me = 89, qe = 0.5, jn = ({ editor: e, preview: t, previewBlocks: n, editorSpans: o, requestFrame: i, cancelFrame: r, now: l }) => {
513
513
  let s = "editor", f = 0, d = null, b = null, w = !1, c = null, v = null;
514
514
  const u = { editor: 0, preview: 0 }, m = { editor: null, preview: null };
515
- let h = null, S = () => {
515
+ let h = null, x = () => {
516
516
  };
517
517
  const p = (a) => {
518
- d !== null && a !== d || (s = a, f = l() + Yn);
519
- }, x = (a, T) => {
518
+ d !== null && a !== d || (s = a, f = l() + Xn);
519
+ }, S = (a, T) => {
520
520
  a !== s && d === null && l() >= f && !I(a, T) && (s = a), B();
521
521
  }, I = (a, T) => {
522
522
  const A = m[a];
523
523
  return l() < u[a] || A !== null && Math.abs(T.position() - A) < qe;
524
- }, k = e.onScroll(() => x("editor", e)), R = e.onIntent(() => p("editor")), L = () => {
524
+ }, k = e.onScroll(() => S("editor", e)), R = e.onIntent(() => p("editor")), L = () => {
525
525
  const a = t();
526
- return a !== h && (S(), h = a, S = a === null ? () => {
527
- } : G(a)), a;
528
- }, G = (a) => {
529
- const T = a.onScroll(() => x("preview", a)), A = a.onIntent(() => p("preview"));
526
+ return a !== h && (x(), h = a, x = a === null ? () => {
527
+ } : U(a)), a;
528
+ }, U = (a) => {
529
+ const T = a.onScroll(() => S("preview", a)), A = a.onIntent(() => p("preview"));
530
530
  return () => {
531
531
  T(), A();
532
532
  };
533
533
  }, B = () => {
534
- !w && b === null && (b = i(F));
535
- }, F = () => {
534
+ !w && b === null && (b = i(z));
535
+ }, z = () => {
536
536
  b = null;
537
537
  const a = L();
538
- a !== null && (c ??= n(), v ??= jn($n(c, o(c)), { editorMax: e.max(), previewMax: a.max(), editorViewport: e.viewport(), previewViewport: a.viewport() }), s === "editor" ? V(a, "preview", v.toPreview(e.position())) : V(e, "editor", v.toEditor(a.position())));
538
+ a !== null && (c ??= n(), v ??= $n(Wn(c, o(c)), { editorMax: e.max(), previewMax: a.max(), editorViewport: e.viewport(), previewViewport: a.viewport() }), s === "editor" ? V(a, "preview", v.toPreview(e.position())) : V(e, "editor", v.toEditor(a.position())));
539
539
  }, V = (a, T, A) => {
540
540
  if (Math.abs(a.position() - A) < qe) {
541
541
  m[T] = a.position();
@@ -554,7 +554,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
554
554
  d = a, !(a === null || a === s) && (s = a, f = 0, B());
555
555
  },
556
556
  dispose: () => {
557
- w = !0, b !== null && r(b), b = null, k(), R(), S();
557
+ w = !0, b !== null && r(b), b = null, k(), R(), x();
558
558
  }
559
559
  };
560
560
  }, Re = Object.freeze(["wheel", "pointerdown", "keydown", "focusin"]), Xe = (e) => ({
@@ -569,53 +569,53 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
569
569
  for (const n of Re) e.removeEventListener(n, t, { capture: !0 });
570
570
  };
571
571
  }
572
- }), te = "[data-aqmd-scroll-container]", Qn = "[data-aqmd-content]", Zn = `[${Ue}]`, er = Object.freeze(["p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8"]), je = (e, t) => {
572
+ }), te = "[data-aqmd-scroll-container]", Yn = "[data-aqmd-content]", Jn = `[${Ge}]`, Qn = Object.freeze(["p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8"]), je = (e, t) => {
573
573
  const n = ct(e.peek(t));
574
574
  return n !== null && n.document.kind === "markdown" ? { htmlContent: n.document.htmlContent, headings: n.document.headings } : null;
575
- }, tr = (e, t, n, o) => {
575
+ }, Zn = (e, t, n, o) => {
576
576
  if (t === void 0) return null;
577
577
  let i;
578
578
  try {
579
- i = Kn(e);
579
+ i = Gn(e);
580
580
  } catch (r) {
581
581
  return console.error("[markdown-explorer] the draft sanitizer cannot run in this browser, so the server renders the preview", r), null;
582
582
  }
583
- return { converter: t, sanitize: i, marksOf: Un, seed: je(n, o)?.htmlContent ?? null };
584
- }, nr = (e) => {
583
+ return { converter: t, sanitize: i, marksOf: Fn, seed: je(n, o)?.htmlContent ?? null };
584
+ }, er = (e) => {
585
585
  const t = [];
586
586
  let n = null;
587
- for (const o of e.querySelectorAll(Zn)) {
588
- const i = rn(o.getAttribute(Ue));
587
+ for (const o of e.querySelectorAll(Jn)) {
588
+ const i = nn(o.getAttribute(Ge));
589
589
  if (i === null || o.getClientRects().length === 0) continue;
590
590
  n ??= e.scrollTop - ie(e, o);
591
591
  const { top: r, bottom: l } = o.getBoundingClientRect();
592
592
  t.push({ first: i.first, last: i.last, top: n + r, bottom: n + l });
593
593
  }
594
594
  return t;
595
- }, rr = ({ path: e, readDraft: t, viewer: n, tables: o, concealed: i, onEditAt: r, onLayout: l, handleRef: s }) => {
596
- const { config: f, data: d, documents: b, draftConverter: w, labels: c } = se(), [v, u] = oe(() => ({ parsed: je(b, e), source: null, failure: null, busy: !0, tier: w === void 0 ? "server" : "instant" })), m = N(null), h = N(null), S = N(v);
595
+ }, tr = ({ path: e, readDraft: t, viewer: n, tables: o, concealed: i, onEditAt: r, onLayout: l, handleRef: s }) => {
596
+ const { config: f, data: d, documents: b, draftConverter: w, labels: c } = se(), [v, u] = oe(() => ({ parsed: je(b, e), source: null, failure: null, busy: !0, tier: w === void 0 ? "server" : "instant" })), m = N(null), h = N(null), x = N(v);
597
597
  D(() => {
598
- S.current = v;
598
+ x.current = v;
599
599
  });
600
600
  const p = Ee(() => t());
601
601
  Ve(() => {
602
- const a = tr(f, w, b, e), T = p(), A = Wn({ path: e, instant: a, preview: d.preview, initial: S.current, onView: (g) => nt(() => u(g)) });
602
+ const a = Zn(f, w, b, e), T = p(), A = Un({ path: e, instant: a, preview: d.preview, initial: x.current, onView: (g) => nt(() => u(g)) });
603
603
  return h.current = A, A.update(T), () => {
604
604
  A.dispose(), h.current = null;
605
605
  };
606
606
  }, [f, d, b, w, e]);
607
- const x = Ee(() => l());
607
+ const S = Ee(() => l());
608
608
  D(() => {
609
- v.parsed !== null && x();
609
+ v.parsed !== null && S();
610
610
  }, [v.parsed]);
611
611
  const I = v.parsed !== null;
612
612
  D(() => {
613
613
  const a = I ? m.current?.querySelector(te) : null;
614
614
  if (!(a instanceof HTMLElement)) return;
615
615
  a.tabIndex = 0;
616
- const T = new ResizeObserver(() => x());
616
+ const T = new ResizeObserver(() => S());
617
617
  T.observe(a);
618
- const A = a.querySelector(Qn);
618
+ const A = a.querySelector(Yn);
619
619
  return A !== null && T.observe(A), () => T.disconnect();
620
620
  }, [I]);
621
621
  const k = N(null);
@@ -631,7 +631,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
631
631
  },
632
632
  blocks: () => {
633
633
  const a = m.current?.querySelector(te);
634
- return a instanceof HTMLElement ? nr(a) : [];
634
+ return a instanceof HTMLElement ? er(a) : [];
635
635
  },
636
636
  focus: () => {
637
637
  const a = m.current?.querySelector(te);
@@ -653,7 +653,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
653
653
  if (r === void 0 || T === null || !(A instanceof Element) || !at(A)) return;
654
654
  const g = ut(A, T, T.ownerDocument.getSelection());
655
655
  g !== null && r(g);
656
- }, L = v.source === null ? null : v.source.revision, G = Y(
656
+ }, L = v.source === null ? null : v.source.revision, U = Y(
657
657
  () => L === null ? void 0 : {
658
658
  write: (a) => o.write(L, a),
659
659
  read: (a) => o.read(L, a),
@@ -662,10 +662,10 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
662
662
  subscribe: o.subscribe
663
663
  },
664
664
  [o, L]
665
- ), B = Y(() => ({ ...n.labels, spreadsheetReadOnly: c.previewTablePending }), [n.labels, c.previewTablePending]), F = Y(
665
+ ), B = Y(() => ({ ...n.labels, spreadsheetReadOnly: c.previewTablePending }), [n.labels, c.previewTablePending]), z = Y(
666
666
  () => ({
667
667
  ...n,
668
- labels: G === void 0 ? B : n.labels,
668
+ labels: U === void 0 ? B : n.labels,
669
669
  showToc: !1,
670
670
  showStyle: !1,
671
671
  showAlign: !1,
@@ -674,12 +674,12 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
674
674
  renderScrollBar: void 0,
675
675
  scrollBarGutter: void 0,
676
676
  scrollBarInlineSize: void 0,
677
- spreadsheetEditor: G
677
+ spreadsheetEditor: U
678
678
  }),
679
- [n, B, G]
679
+ [n, B, U]
680
680
  ), V = Y(
681
- () => v.parsed === null ? null : /* @__PURE__ */ M("div", { className: "aqmx-document-viewer", children: /* @__PURE__ */ M(nn, { ...F, parseResult: v.parsed, content: null }) }),
682
- [F, v.parsed]
681
+ () => v.parsed === null ? null : /* @__PURE__ */ M("div", { className: "aqmx-document-viewer", children: /* @__PURE__ */ M(tn, { ...z, parseResult: v.parsed, content: null }) }),
682
+ [z, v.parsed]
683
683
  );
684
684
  return /* @__PURE__ */ re(
685
685
  "section",
@@ -694,16 +694,16 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
694
694
  "data-testid": "markdown-explorer-edit-preview",
695
695
  onDoubleClick: r === void 0 ? void 0 : R,
696
696
  children: [
697
- v.failure === null ? null : /* @__PURE__ */ M(or, { failure: v.failure }),
698
- V ?? (v.failure === null ? /* @__PURE__ */ M("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-edit-preview-skeleton", children: er.map((a) => /* @__PURE__ */ M("span", {}, a)) }) : null),
697
+ v.failure === null ? null : /* @__PURE__ */ M(nr, { failure: v.failure }),
698
+ V ?? (v.failure === null ? /* @__PURE__ */ M("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-edit-preview-skeleton", children: Qn.map((a) => /* @__PURE__ */ M("span", {}, a)) }) : null),
699
699
  v.busy ? /* @__PURE__ */ M("p", { className: "aqmx-sr-only", children: c.previewUpdating }) : null
700
700
  ]
701
701
  }
702
702
  );
703
- }, or = ({ failure: e }) => {
703
+ }, nr = ({ failure: e }) => {
704
704
  const { labels: t } = se(), { reason: n } = e;
705
- return He(n) ? /* @__PURE__ */ M(dt, { failure: e, place: "read", deniedSentence: null, retry: null, testId: "markdown-explorer-edit-preview-failure" }) : /* @__PURE__ */ M("p", { className: "aqmx-callout aqmx-document-notice", "data-aqmx-tone": "warning", "data-testid": "markdown-explorer-edit-preview-failure", children: t.previewFailed(Fe(t, n)) });
706
- }, _e = "data-aqmx-edit-split", pe = "--aqmx-edit-share", Pe = "--aqmx-edit-gutter", ir = "data-aqmx-edit-split-probe", sr = "aqmx-edit-split", lr = "aqmx-edit-editor", cr = "aqmx-edit-preview", Ne = { value: hn, unit: "percentage" }, De = { value: pn, unit: "percentage" }, Be = (e) => {
705
+ return He(n) ? /* @__PURE__ */ M(dt, { failure: e, place: "read", deniedSentence: null, retry: null, testId: "markdown-explorer-edit-preview-failure" }) : /* @__PURE__ */ M("p", { className: "aqmx-callout aqmx-document-notice", "data-aqmx-tone": "warning", "data-testid": "markdown-explorer-edit-preview-failure", children: t.previewFailed(ze(t, n)) });
706
+ }, _e = "data-aqmx-edit-split", pe = "--aqmx-edit-share", Pe = "--aqmx-edit-gutter", rr = "data-aqmx-edit-split-probe", or = "aqmx-edit-split", ir = "aqmx-edit-editor", sr = "aqmx-edit-preview", Ne = { value: mn, unit: "percentage" }, De = { value: fn, unit: "percentage" }, Be = (e) => {
707
707
  if (e.length !== 2) return null;
708
708
  const [t = 0, n = 0] = e, o = t + n;
709
709
  return o > 0 ? t / o * 100 : null;
@@ -711,13 +711,13 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
711
711
  const t = e.current?.parentElement;
712
712
  if (t == null) throw new Error("[markdown-explorer] the edit split is not mounted in its surface");
713
713
  return t;
714
- }, ar = (e, t, n) => {
714
+ }, lr = (e, t, n) => {
715
715
  const [o, i] = oe(null);
716
716
  return D(() => {
717
717
  const r = e.current, l = t.current;
718
718
  if (r === null || l === null) throw new Error("[markdown-explorer] the edit split is not mounted");
719
719
  const s = { frame: r.getBoundingClientRect().width, measure: l.getBoundingClientRect().width }, f = () => {
720
- s.frame > 0 && s.measure > 0 && i(gn(s.frame, s.measure, n));
720
+ s.frame > 0 && s.measure > 0 && i(pn(s.frame, s.measure, n));
721
721
  };
722
722
  f();
723
723
  const d = new ResizeObserver((b) => {
@@ -729,8 +729,8 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
729
729
  });
730
730
  return d.observe(r), d.observe(l), () => d.disconnect();
731
731
  }, [e, t, n]), o;
732
- }, ur = ({ editorId: e }) => {
733
- const { edits: t, labels: n } = se(), o = Y(() => En(n), [n]), i = N(null), r = N(null), l = ft() ? fn : mn, s = ar(i, r, l), [f] = oe(() => t.editorShare());
732
+ }, cr = ({ editorId: e }) => {
733
+ const { edits: t, labels: n } = se(), o = Y(() => wn(n), [n]), i = N(null), r = N(null), l = dn, s = lr(i, r, l), [f] = oe(() => t.editorShare());
734
734
  D(() => {
735
735
  const w = ae(i);
736
736
  return w.style.setProperty(Pe, `${String(l)}px`), () => {
@@ -746,7 +746,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
746
746
  const w = ae(i);
747
747
  return w.setAttribute(_e, s), () => w.removeAttribute(_e);
748
748
  }, [s]);
749
- const d = Sn(
749
+ const d = bn(
750
750
  J(
751
751
  (w) => {
752
752
  const c = Be(w);
@@ -762,11 +762,11 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
762
762
  [d]
763
763
  );
764
764
  return /* @__PURE__ */ re("div", { ref: i, className: "aqmx-edit-split", "data-testid": "markdown-explorer-edit-split", children: [
765
- /* @__PURE__ */ M("span", { ref: r, className: "aqmx-edit-split-probe", "aria-hidden": "true", [ir]: "" }),
766
- s === null ? null : /* @__PURE__ */ re(wn, { id: sr, direction: s === "beside" ? "horizontal" : "vertical", onLayout: b, labels: o, className: "aqmx-edit-split-group", children: [
767
- /* @__PURE__ */ M(ke, { id: lr, defaultSize: { value: f, unit: "percentage" }, minSize: Ne, maxSize: De, contentOverflow: "hidden" }),
765
+ /* @__PURE__ */ M("span", { ref: r, className: "aqmx-edit-split-probe", "aria-hidden": "true", [rr]: "" }),
766
+ s === null ? null : /* @__PURE__ */ re(gn, { id: or, direction: s === "beside" ? "horizontal" : "vertical", onLayout: b, labels: o, className: "aqmx-edit-split-group", children: [
767
+ /* @__PURE__ */ M(ke, { id: ir, defaultSize: { value: f, unit: "percentage" }, minSize: Ne, maxSize: De, contentOverflow: "hidden" }),
768
768
  /* @__PURE__ */ M(
769
- bn,
769
+ vn,
770
770
  {
771
771
  thickness: l,
772
772
  indicator: { visible: !0, thickness: ce.gripThickness, length: ce.gripLength, barThickness: ce.barThickness, barLength: ce.barLength },
@@ -777,10 +777,10 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
777
777
  className: "aqmx-split-handle aqmx-edit-split-handle"
778
778
  }
779
779
  ),
780
- /* @__PURE__ */ M(ke, { id: cr, defaultSize: { value: 100 - f, unit: "percentage" }, minSize: Ne, maxSize: De, contentOverflow: "hidden" })
780
+ /* @__PURE__ */ M(ke, { id: sr, defaultSize: { value: 100 - f, unit: "percentage" }, minSize: Ne, maxSize: De, contentOverflow: "hidden" })
781
781
  ] })
782
782
  ] });
783
- }, dr = 512, fr = () => {
783
+ }, ar = 512, ur = () => {
784
784
  const e = [];
785
785
  let t = 0, n = null;
786
786
  const o = (i) => {
@@ -801,44 +801,44 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
801
801
  },
802
802
  record: (i, r) => {
803
803
  if (n === null) throw new Error("[markdown-explorer] a change of the editor's text was recorded before an editor mounted");
804
- e.push({ before: n, changes: i }), n = r, e.length > dr && (e.shift(), t += 1);
804
+ e.push({ before: n, changes: i }), n = r, e.length > ar && (e.shift(), t += 1);
805
805
  },
806
806
  lineOf: (i, r) => {
807
807
  const l = o(i);
808
808
  if (l === null || n === null || !Number.isInteger(r) || r < 1 || r > l.lines) return null;
809
809
  let s = l.line(r).from;
810
810
  for (const f of e.slice(i - t)) {
811
- const d = f.changes.mapPos(s, 1, Xt.TrackAfter);
811
+ const d = f.changes.mapPos(s, 1, $t.TrackAfter);
812
812
  if (d === null) return null;
813
813
  s = d;
814
814
  }
815
815
  return n.lineAt(s).number;
816
816
  }
817
817
  };
818
- }, mr = 144, pr = (e) => {
818
+ }, dr = 144, fr = (e) => {
819
819
  if (typeof e != "object" || e === null) return !1;
820
820
  const { generation: t, topLine: n } = e;
821
821
  return "state" in e && typeof t == "number" && typeof n == "number";
822
- }, hr = (e) => {
822
+ }, mr = (e) => {
823
823
  e.stopPropagation();
824
- }, Dr = (e) => {
824
+ }, Pr = (e) => {
825
825
  const { path: t, name: n, session: o } = e, { edits: i, labels: r, announcer: l } = se(), { phase: s } = o, f = J(() => i.retry(t), [i, t]);
826
826
  switch (Ve(() => {
827
827
  if (s.kind !== "failed") return;
828
828
  const { reason: d } = s.failure;
829
- He(d) || l.announce(r.documentFailed(n, Fe(r, d)));
829
+ He(d) || l.announce(r.documentFailed(n, ze(r, d)));
830
830
  }, [s, l, r, n]), s.kind) {
831
831
  case "opening":
832
- return /* @__PURE__ */ M(ht, { label: r.editLoading, testId: "markdown-explorer-edit-skeleton" });
832
+ return /* @__PURE__ */ M(pt, { label: r.editLoading, testId: "markdown-explorer-edit-skeleton" });
833
833
  case "grant":
834
- return /* @__PURE__ */ M("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ M(pt, { href: s.href, onRetry: f, testId: "markdown-explorer-edit-grant" }) });
834
+ return /* @__PURE__ */ M("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ M(mt, { href: s.href, onRetry: f, testId: "markdown-explorer-edit-grant" }) });
835
835
  case "failed":
836
- return /* @__PURE__ */ M("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ M(mt, { failure: s.failure, alert: !1, onRetry: f, testId: "markdown-explorer-edit-failure" }) });
836
+ return /* @__PURE__ */ M("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ M(ft, { failure: s.failure, alert: !1, onRetry: f, testId: "markdown-explorer-edit-failure" }) });
837
837
  case "editing":
838
- return /* @__PURE__ */ M(gr, { ...e });
838
+ return /* @__PURE__ */ M(pr, { ...e });
839
839
  }
840
- }, gr = ({ path: e, name: t, session: n, layout: o, viewer: i, region: r, paneScroll: l }) => {
841
- const { edits: s, labels: f } = se(), d = N(null), b = rt(), w = N(null), [c] = oe(() => /* @__PURE__ */ new Set()), [v] = oe(fr), u = N(null), m = N(null), h = o === "fill", S = gt(), p = vt(n, S, h), x = p !== "editor" || n.previewPrepared, I = x && h, k = N({ layout: o, region: r, paneScroll: l });
840
+ }, pr = ({ path: e, name: t, session: n, layout: o, viewer: i, region: r, paneScroll: l }) => {
841
+ const { edits: s, labels: f } = se(), d = N(null), b = rt(), w = N(null), [c] = oe(() => /* @__PURE__ */ new Set()), [v] = oe(ur), u = N(null), m = N(null), h = o === "fill", x = ht(), p = gt(n, x, h), S = p !== "editor" || n.previewPrepared, I = S && h, k = N({ layout: o, region: r, paneScroll: l });
842
842
  D(() => {
843
843
  k.current = { layout: o, region: r, paneScroll: l };
844
844
  });
@@ -846,13 +846,13 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
846
846
  D(() => {
847
847
  R.current = n.generation;
848
848
  });
849
- const L = N({ view: p, previewMounted: x });
849
+ const L = N({ view: p, previewMounted: S });
850
850
  D(() => {
851
- L.current = { view: p, previewMounted: x };
851
+ L.current = { view: p, previewMounted: S };
852
852
  });
853
- const { requestSave: G, confirmation: B } = wt(e), F = N(G);
853
+ const { requestSave: U, confirmation: B } = vt(e), z = N(U);
854
854
  D(() => {
855
- F.current = G;
855
+ z.current = U;
856
856
  });
857
857
  const V = N(null), a = N(null), T = N(!1), A = Y(() => ({ editor: f.editorLabel(t), useOurs: f.conflictUseOurs, useTheirs: f.conflictUseTheirs, keepBoth: f.conflictKeepBoth }), [f, t]), g = J((y) => {
858
858
  const { region: O, paneScroll: P } = k.current, H = O();
@@ -861,11 +861,11 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
861
861
  D(() => {
862
862
  const y = d.current, O = s.draft(e);
863
863
  if (y === null || O === null) return;
864
- const P = s.editorState.get(e), H = pr(P) && P.generation === R.current ? P : null;
864
+ const P = s.editorState.get(e), H = fr(P) && P.generation === R.current ? P : null;
865
865
  let K = null, Q = null;
866
866
  const fe = () => {
867
867
  K !== null && clearTimeout(K), K = null, Q !== null && s.setDraft(e, Q.text());
868
- }, W = _n({
868
+ }, W = qn({
869
869
  parent: y,
870
870
  scroll: {
871
871
  scrollerOf: (q) => {
@@ -880,11 +880,11 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
880
880
  revisions: v,
881
881
  onGeometry: (q) => m.current?.editorChanged(q),
882
882
  onChange: (q) => {
883
- if (K ??= setTimeout(fe, mr), !q)
883
+ if (K ??= setTimeout(fe, dr), !q)
884
884
  for (const Z of [...c]) Z();
885
885
  L.current.previewMounted && Q !== null && u.current?.draft({ text: Q.text(), revision: v.revision() });
886
886
  },
887
- onSave: () => F.current()
887
+ onSave: () => z.current()
888
888
  });
889
889
  Q = W, w.current = W;
890
890
  const ve = () => {
@@ -915,7 +915,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
915
915
  const { request: E } = n;
916
916
  D(() => {
917
917
  const y = w.current, O = s.draft(e);
918
- y === null || O === null || E === null || (E.anchor !== null && y.reveal(Se(O, E.anchor), E.anchor.clientTop), y.focus(), s.consumeRequest(e));
918
+ y === null || O === null || E === null || (E.anchor !== null && y.reveal(xe(O, E.anchor), E.anchor.clientTop), y.focus(), s.consumeRequest(e));
919
919
  }, [s, e, E, A]), D(() => {
920
920
  p !== "editor" && !n.previewPrepared && s.preparePreview(e);
921
921
  }, [s, e, p, n.previewPrepared]), D(() => {
@@ -925,7 +925,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
925
925
  if (y?.to === "preview") u.current?.place(y.point, g);
926
926
  else if (y?.to === "editor" && H !== null) {
927
927
  const K = s.draft(e);
928
- K !== null && H.reveal(Se(K, y.anchor), y.anchor.clientTop);
928
+ K !== null && H.reveal(xe(K, y.anchor), y.anchor.clientTop);
929
929
  }
930
930
  P ? H?.nextConflict() : O === "editor" ? H?.focus() : O === "preview" && u.current?.focus();
931
931
  }, [s, e, p, g]);
@@ -944,7 +944,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
944
944
  c.delete(O);
945
945
  })
946
946
  };
947
- }, [c]), U = J(() => {
947
+ }, [c]), G = J(() => {
948
948
  const y = w.current;
949
949
  if (y === null) throw new Error("[markdown-explorer] the preview read the draft before the editor was mounted");
950
950
  return { text: y.text(), revision: v.revision() };
@@ -952,7 +952,7 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
952
952
  D(() => {
953
953
  const y = w.current;
954
954
  if (!I || y === null) return;
955
- const O = Jn({
955
+ const O = jn({
956
956
  editor: Xe(y.scrollElement),
957
957
  preview: () => u.current?.scrollPort() ?? null,
958
958
  previewBlocks: () => u.current?.blocks() ?? [],
@@ -961,27 +961,27 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
961
961
  cancelFrame: (P) => cancelAnimationFrame(P),
962
962
  now: () => performance.now()
963
963
  });
964
- return O.showAlone(xe(L.current.view)), m.current = O, () => {
964
+ return O.showAlone(Se(L.current.view)), m.current = O, () => {
965
965
  O.dispose(), m.current = null;
966
966
  };
967
967
  }, [I, s, e, A]), D(() => {
968
- m.current?.showAlone(xe(p));
968
+ m.current?.showAlone(Se(p));
969
969
  }, [p]);
970
- const X = J(() => m.current?.previewChanged(), []), z = J((y) => s.start(e, y), [s, e]), Ye = (
970
+ const X = J(() => m.current?.previewChanged(), []), F = J((y) => s.start(e, y), [s, e]), Ye = (
971
971
  /* @__PURE__ */ re("div", { className: "aqmx-edit", "data-aqmx-edit-layout": o, "data-aqmx-edit-view": p, "data-testid": "markdown-explorer-edit", onKeyDown: (y) => {
972
- if (Et(y.target)) return;
972
+ if (bt(y.target)) return;
973
973
  if (y.key === "Escape") {
974
974
  ye(y);
975
975
  return;
976
976
  }
977
- if (!St(y.nativeEvent, xt(navigator.platform))) return;
977
+ if (!Et(y.nativeEvent, xt(navigator.platform))) return;
978
978
  ye(y);
979
- const O = kt(p);
980
- a.current = O, yt(s, e, O, h);
981
- }, onDoubleClick: hr, children: [
982
- /* @__PURE__ */ M("div", { ref: d, id: b, className: "aqmx-edit-editor", "data-testid": "markdown-explorer-editor", inert: p === "preview", hidden: p === "preview" && !h, ...bt }),
983
- p === "split" ? /* @__PURE__ */ M(ur, { editorId: b }) : null,
984
- x ? /* @__PURE__ */ M(rr, { path: e, readDraft: U, viewer: i, tables: C, concealed: p !== "editor" ? null : h ? "overlay" : "removed", onEditAt: p === "preview" ? z : void 0, onLayout: X, handleRef: u }) : null
979
+ const O = yt(p);
980
+ a.current = O, St(s, e, O, h);
981
+ }, onDoubleClick: mr, children: [
982
+ /* @__PURE__ */ M("div", { ref: d, id: b, className: "aqmx-edit-editor", "data-testid": "markdown-explorer-editor", inert: p === "preview", hidden: p === "preview" && !h, ...wt }),
983
+ p === "split" ? /* @__PURE__ */ M(cr, { editorId: b }) : null,
984
+ S ? /* @__PURE__ */ M(tr, { path: e, readDraft: G, viewer: i, tables: C, concealed: p !== "editor" ? null : h ? "overlay" : "removed", onEditAt: p === "preview" ? F : void 0, onLayout: X, handleRef: u }) : null
985
985
  ] })
986
986
  );
987
987
  return /* @__PURE__ */ re(et, { children: [
@@ -990,6 +990,6 @@ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
990
990
  ] });
991
991
  };
992
992
  export {
993
- mr as DRAFT_WRITE_INTERVAL_MS,
994
- Dr as default
993
+ dr as DRAFT_WRITE_INTERVAL_MS,
994
+ Pr as default
995
995
  };