@aiquants/markdown-explorer 0.36.0 → 0.37.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 (54) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +74 -11
  3. package/dist/{EditSurface-BCFJRyIM.js → EditSurface-BQgwRUrR.js} +250 -245
  4. package/dist/EditSurface-Xvk5wZu7.cjs +6 -0
  5. package/dist/ExplorerSplit-C_3FChSt.cjs +2 -0
  6. package/dist/ExplorerSplit-C_kaEnyM.js +1619 -0
  7. package/dist/{MultiLayout-Bo9LAXiY.cjs → MultiLayout-BZNj1GYo.cjs} +1 -1
  8. package/dist/{MultiLayout-Dy5TIC2t.js → MultiLayout-DROxkTdD.js} +22 -22
  9. package/dist/{NativeScrollBar-Bj-LKej0.cjs → NativeScrollBar-BDF9A1sc.cjs} +1 -1
  10. package/dist/{NativeScrollBar-DpZMYhmf.js → NativeScrollBar-DvdOpwIW.js} +2 -2
  11. package/dist/{TreeLayout-DsSKW_Qj.js → TreeLayout-Cc-ykewY.js} +2 -2
  12. package/dist/{TreeLayout-T8sc_wg7.cjs → TreeLayout-D_DYV64_.cjs} +1 -1
  13. package/dist/client/MarkdownExplorer.d.cts +4 -5
  14. package/dist/client/MarkdownExplorer.d.ts +4 -5
  15. package/dist/client/hostContract.d.cts +1 -8
  16. package/dist/client/hostContract.d.ts +1 -8
  17. package/dist/core/labels.d.cts +0 -9
  18. package/dist/core/labels.d.ts +0 -9
  19. package/dist/explorerCore-DivWkFQF.cjs +1 -0
  20. package/dist/{explorerCore-B3RGmMG6.js → explorerCore-EkU0mwdW.js} +310 -308
  21. package/dist/index-BmOU3xcK.cjs +18 -0
  22. package/dist/{index-D0l_BJqb.js → index-dtjghDWY.js} +2451 -2434
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.cts +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +54 -55
  27. package/dist/{merge-Dckw7r9T.cjs → merge-BCFCL1cF.cjs} +1 -1
  28. package/dist/{merge-BwcqBd4c.js → merge-DC_h-t31.js} +1 -1
  29. package/dist/server/anonymous.d.cts +2 -2
  30. package/dist/server/anonymous.d.ts +2 -2
  31. package/dist/server/ports.d.cts +5 -2
  32. package/dist/server/ports.d.ts +5 -2
  33. package/dist/server.cjs +1 -1
  34. package/dist/server.d.cts +1 -1
  35. package/dist/server.d.ts +1 -1
  36. package/dist/server.js +12 -12
  37. package/dist/serverCore.cjs +1 -1
  38. package/dist/serverCore.d.cts +1 -1
  39. package/dist/serverCore.d.ts +1 -1
  40. package/dist/serverCore.js +1 -1
  41. package/dist/styles/markdown-explorer.css +1 -1
  42. package/dist/{tapScrollCircle-smKLgRa2.js → tapScrollCircle-CqMZzWjo.js} +1 -1
  43. package/dist/{tapScrollCircle-DyLInGck.cjs → tapScrollCircle-DVNlszeF.cjs} +1 -1
  44. package/docs/behavior/dom-hooks.md +8 -1
  45. package/docs/behavior/hosting.md +1 -1
  46. package/docs/behavior/localization.md +2 -2
  47. package/docs/behavior/security.md +1 -1
  48. package/docs/behavior/url-contract.md +2 -2
  49. package/package.json +6 -4
  50. package/dist/EditSurface-B70iRFkG.cjs +0 -6
  51. package/dist/ExplorerSplit-BNrHrIus.cjs +0 -2
  52. package/dist/ExplorerSplit-Bgccz2nm.js +0 -1589
  53. package/dist/explorerCore-CUkyKtm8.cjs +0 -1
  54. package/dist/index-lpL7GltU.cjs +0 -18
@@ -1,24 +1,24 @@
1
- import { jsx as q, jsxs as re, Fragment as Ze } from "react/jsx-runtime";
2
- import { useState as oe, useRef as N, useLayoutEffect as D, useEffectEvent as Ee, useEffect as Ve, useImperativeHandle as et, useMemo as Y, startTransition as tt, useCallback as J, useId as nt } from "react";
3
- import { v as ie, k as ge, l as rt, u as ae, m as ot, n as it, o as st, p as He, q as lt, t as ct, w as at, c as ut, x as dt, E as ft, y as mt, z as pt, A as ht, B as gt, G as xe, H as Se, I as vt, J as wt, K as ye, L as bt, M as Et, O as xt, Q as St } from "./index-D0l_BJqb.js";
4
- import { fencedBodyAsRead as yt, planFencedBodyEdit as kt, fencedCodeLanguageOf as Tt, SPREADSHEETS_LANGUAGE as At, readFencedLine as It, listItemWidthOn as Ot, openingFenceOn as Ct } from "@aiquants/markdown/code-blocks";
5
- import { history as Lt, historyKeymap as Mt, defaultKeymap as qt, historyField as Rt, redo as _t, undo as Pt, isolateHistory as Nt } from "@codemirror/commands";
6
- import { markdown as Dt, markdownLanguage as Bt } from "@codemirror/lang-markdown";
7
- import { syntaxHighlighting as Vt, syntaxTreeAvailable as Ht, HighlightStyle as zt, ensureSyntaxTree as ze } from "@codemirror/language";
8
- import { highlightSelectionMatches as Ft, searchKeymap as Gt } from "@codemirror/search";
9
- import { EditorState as Fe, EditorSelection as he, StateField as Ut, RangeSetBuilder as Wt, MapMode as Kt } from "@codemirror/state";
10
- import { EditorView as $, lineNumbers as $t, highlightActiveLineGutter as Xt, drawSelection as jt, highlightActiveLine as Yt, keymap as Jt, ViewPlugin as Qt, Decoration as ue, WidgetType as Zt } from "@codemirror/view";
1
+ import { jsx as M, jsxs as re, Fragment as et } from "react/jsx-runtime";
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-dtjghDWY.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";
11
11
  import { tags as _ } from "@lezer/highlight";
12
- import { MarkdownViewer as en } from "@aiquants/markdown";
13
- import { SOURCE_LINES_ATTRIBUTE as Ge, parseSourceLines as tn } from "@aiquants/markdown/source-lines";
14
- import { U as nn, k as se, E as rn } from "./ownUrls-DD0cSCsF.js";
15
- import { H as on, c as sn, M as ln } from "./sanitizePolicy-DAPnUUVm.js";
16
- import cn from "isomorphic-dompurify";
17
- import { o as an, C as un, F as dn, E as fn, m as mn, n as le, q as pn } from "./location-Dh6K-y7w.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-pnb21dsr.js";
21
- const Ue = { history: Rt }, En = zt.define([
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-Dh6K-y7w.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-pnb21dsr.js";
21
+ const We = { history: Pt }, xn = Gt.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 Ue = { history: Rt }, En = zt.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
- ]), xn = $.theme({
31
+ ]), yn = $.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 Ue = { history: Rt }, En = zt.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
- }), We = "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 Zt {
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 {
46
46
  constructor(t, n) {
47
47
  super(), this.index = t, this.labels = n;
48
48
  }
@@ -53,7 +53,7 @@ class Tn extends Zt {
53
53
  }
54
54
  toDOM(t) {
55
55
  const n = document.createElement("div");
56
- n.setAttribute(We, String(this.index));
56
+ n.setAttribute(Ke, String(this.index));
57
57
  for (const [o, i] of [
58
58
  ["ours", this.labels.useOurs],
59
59
  ["theirs", this.labels.useTheirs],
@@ -62,7 +62,7 @@ class Tn extends Zt {
62
62
  const r = document.createElement("button");
63
63
  r.type = "button", r.textContent = i, r.setAttribute("data-aqmx-conflict-choice", o), r.addEventListener("mousedown", (l) => l.preventDefault()), r.addEventListener("click", () => {
64
64
  const l = ne(t.state.doc)[this.index];
65
- l !== void 0 && (Ke(t, l, o), t.focus());
65
+ l !== void 0 && ($e(t, l, o), t.focus());
66
66
  }), n.append(r);
67
67
  }
68
68
  return n;
@@ -71,21 +71,21 @@ class Tn extends Zt {
71
71
  return !0;
72
72
  }
73
73
  }
74
- const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
75
- const n = new Wt();
74
+ const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
75
+ const n = new $t();
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 Tn(i, t), block: !0, side: -1 }));
78
+ n.add(r.from, r.from, ue.widget({ widget: new In(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 ? Sn : l < o.separator ? yn : kn;
80
+ const s = e.line(l).from, f = l === o.start || l === o.separator || l === o.end ? kn : l < o.separator ? Tn : An;
81
81
  n.add(s, s, f);
82
82
  }
83
83
  }), n.finish();
84
- }, An = (e) => Ut.define({
84
+ }, On = (e) => Kt.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)
88
- }), Ke = (e, t, n) => {
88
+ }), $e = (e, t, n) => {
89
89
  const { doc: o } = e.state, i = (w, c) => {
90
90
  const v = [];
91
91
  for (let u = w; u <= c; u += 1) v.push(o.line(u).text);
@@ -96,7 +96,7 @@ const ne = (e) => rt(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", In = 20, On = Qt.fromClass(
99
+ }, Ae = "input.preview", Cn = 20, Ln = en.fromClass(
100
100
  class {
101
101
  constructor(e) {
102
102
  this.view = e, this.schedule();
@@ -107,11 +107,11 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
107
107
  e.docChanged && this.schedule();
108
108
  }
109
109
  schedule() {
110
- if (this.cancel !== null || Ht(this.view.state)) return;
110
+ if (this.cancel !== null || zt(this.view.state)) return;
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, In), this.schedule();
114
+ this.cancel = null, ze(this.view.state, this.view.state.doc.length, Cn), 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) => rt(e.iterLines()), Te = (e, t) => {
125
125
  this.cancel?.(), this.cancel = null;
126
126
  }
127
127
  }
128
- ), Cn = /`{3,}|~{3,}/u, ee = Object.freeze({ kind: "absent" }), me = Object.freeze({ kind: "unreadable" }), Ln = (e, t, n) => {
128
+ ), Mn = /`{3,}|~{3,}/u, ee = Object.freeze({ kind: "absent" }), me = Object.freeze({ kind: "unreadable" }), qn = (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,16 +136,16 @@ const ne = (e) => rt(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 = Ot(e.line(d).text, i, l(d));
139
+ const b = Lt(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 = Ct(n.text, i, l(n.number));
146
+ const s = Mt(n.text, i, l(n.number));
147
147
  return s === null ? null : { containers: i, ...s };
148
- }, Mn = (e, t) => {
148
+ }, Rn = (e, t) => {
149
149
  const { doc: n } = e;
150
150
  let o = n.lineAt(t).to;
151
151
  for (; ; ) {
@@ -159,58 +159,58 @@ const ne = (e) => rt(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 = Cn.exec(o.text);
162
+ const o = n.line(t), i = Mn.exec(o.text);
163
163
  if (i === null) return ee;
164
- const r = Mn(e, o.from + i.index);
164
+ const r = Rn(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 = Tt(n.sliceString(l.from, l.to));
168
+ const s = It(n.sliceString(l.from, l.to));
169
169
  if (s === null) return me;
170
- if (s !== At) return ee;
171
- const f = Ln(n, r, o);
170
+ if (s !== Ot) return ee;
171
+ const f = qn(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 = It(m, f);
176
+ const m = n.line(u).text, h = Ct(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
- }, qn = ({ parent: e, scroll: t, text: n, saved: o, labels: i, revisions: r, onChange: l, onGeometry: s, onSave: f }) => {
182
+ }, _n = ({ 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) => (Rn(u, m.head, h, t), !0)),
186
- $t(),
187
- Xt(),
188
- Lt(),
185
+ $.scrollHandler.of((u, m, h) => (Pn(u, m.head, h, t), !0)),
189
186
  jt(),
190
187
  Yt(),
191
- Ft(),
188
+ qt(),
189
+ Jt(),
190
+ Qt(),
191
+ Ut(),
192
192
  $.lineWrapping,
193
- Dt({ base: Bt }),
194
- On,
195
- Vt(En),
196
- An(i),
197
- Jt.of([
193
+ Vt({ base: Ht }),
194
+ Ln,
195
+ Ft(xn),
196
+ On(i),
197
+ Zt.of([
198
198
  {
199
199
  key: "Mod-s",
200
200
  preventDefault: !0,
201
201
  run: () => (f(), !0)
202
202
  },
203
- ...Gt,
204
- ...Mt,
205
- ...qt
203
+ ...Wt,
204
+ ...Rt,
205
+ ..._t
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
- xn
213
- ], w = Nn(o, b) ?? Fe.create({ doc: n, extensions: b }), c = new $({ state: w, parent: e });
212
+ yn
213
+ ], w = Bn(o, b) ?? Ge.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,85 +226,85 @@ const ne = (e) => rt(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 x = Math.min(m.length, u.length);
230
- for (; h < x && m.charCodeAt(h) === u.charCodeAt(h); ) h += 1;
229
+ const S = Math.min(m.length, u.length);
230
+ for (; h < S && m.charCodeAt(h) === u.charCodeAt(h); ) h += 1;
231
231
  let p = 0;
232
- for (; p < x - h && m.charCodeAt(m.length - 1 - p) === u.charCodeAt(u.length - 1 - p); ) p += 1;
232
+ for (; p < S - 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, 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);
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);
239
239
  if (I.kind === "absent") return "changed";
240
240
  if (I.kind === "unreadable") return "unwritable";
241
- if (I.body !== yt(m, I.layout)) return "changed";
242
- const k = kt(I.lines, I.layout, h);
241
+ if (I.body !== Tt(m, I.layout)) return "changed";
242
+ const k = At(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 = (z) => {
246
- const V = I.firstLine + z;
245
+ const R = (F) => {
246
+ const V = I.firstLine + F;
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((z) => `${z}
250
+ ` : ""}${k.lines.map((F) => `${F}
251
251
  `).join("")}`;
252
- return v(() => c.dispatch({ changes: { from: L, to: R(k.to), insert: B }, userEvent: Ae, annotations: Nt.of("full") })), "written";
252
+ return v(() => c.dispatch({ changes: { from: L, to: R(k.to), insert: B }, userEvent: Ae, annotations: Bt.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 x = Ie(c.state, h);
258
- return x.kind === "found" ? x.body : null;
257
+ const S = Ie(c.state, h);
258
+ return S.kind === "found" ? S.body : null;
259
259
  },
260
- undo: () => v(() => Pt(c)),
261
- redo: () => v(() => _t(c)),
260
+ undo: () => v(() => Dt(c)),
261
+ redo: () => v(() => Nt(c)),
262
262
  reveal: ({ line: u, column: m }, h) => {
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) });
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) });
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: 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;
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;
277
277
  }
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 };
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 };
280
280
  },
281
281
  lineSpans: (u) => {
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 }));
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 }));
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, x = m.find((p) => p.end >= h);
290
- return x === void 0 ? !1 : (Ke(c, x, u), !0);
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);
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, 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
- const I = c.contentDOM.querySelector(`[${We}="${String(p)}"] button`);
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" }) });
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
  },
300
- save: () => c.state.toJSON(Ue),
300
+ save: () => c.state.toJSON(We),
301
301
  destroy: () => c.destroy()
302
302
  };
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
- }, 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;
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;
308
308
  let d = 0;
309
309
  switch (n.y) {
310
310
  case "start":
@@ -320,9 +320,9 @@ const ne = (e) => rt(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 = Pn(e, t);
323
+ const b = Dn(e, t);
324
324
  b !== null && o.reveal(b);
325
- }, _n = (e, t) => {
325
+ }, Nn = (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) => rt(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
- }, Pn = (e, t) => {
337
+ }, Dn = (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
- }, Nn = (e, t) => {
342
+ }, Bn = (e, t) => {
343
343
  if (e == null) return null;
344
344
  try {
345
- return Fe.fromJSON(e, { extensions: t }, Ue);
345
+ return Ge.fromJSON(e, { extensions: t }, We);
346
346
  } catch {
347
347
  return null;
348
348
  }
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) => {
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) => {
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: zn(o.getAttribute(i ? "data-asset-exists" : "data-doc-exists")) });
353
+ r !== null && n.push({ target: { kind: i ? "asset" : "doc", path: r }, exists: Gn(o.getAttribute(i ? "data-asset-exists" : "data-doc-exists")) });
354
354
  }
355
355
  return n;
356
- }, Gn = ({ path: e, instant: t, preview: n, initial: o, onView: i }) => {
356
+ }, Wn = ({ 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, x = null;
358
+ let s = o, f = null, d = !1, b = !1, w = null, c = null, v = [], u, m = !1, h, S = 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
- }, S = (g, E) => {
361
+ }, x = (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, x?.abort(), x = null;
367
+ clearTimeout(h), h = void 0, S?.abort(), S = 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
372
  }, G = () => {
373
- clearTimeout(u), u = v.length === 0 ? void 0 : setTimeout(z, Bn);
373
+ clearTimeout(u), u = v.length === 0 ? void 0 : setTimeout(F, Hn);
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
377
  let U;
378
378
  try {
379
- U = 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;
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;
382
382
  });
383
- } catch (F) {
384
- R(), F instanceof on ? L(se("too-large"), "instant") : (S("the draft sanitizer failed", F), L(se("failed"), "instant"));
383
+ } catch (z) {
384
+ R(), z instanceof ln ? L(le("too-large"), "instant") : (x("the draft sanitizer failed", z), L(le("failed"), "instant"));
385
385
  return;
386
386
  }
387
387
  v = E;
388
388
  const X = s.parsed !== null && s.parsed.htmlContent === U && s.parsed.headings === g.headings ? s.parsed : { htmlContent: U, headings: g.headings };
389
389
  p({ parsed: X, source: g.draft, failure: null, busy: !1, tier: "instant" }), G();
390
- }, z = () => {
390
+ }, F = () => {
391
391
  if (u = void 0, m || c === null || v.length === 0) return;
392
392
  m = !0;
393
393
  const g = v;
@@ -401,37 +401,37 @@ const ne = (e) => rt(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
- x = E, h = setTimeout(() => {
404
+ S = 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 (x = null, C.kind === "failure") {
407
+ if (S = 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
- }, Dn);
414
+ }, Vn);
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 || S("the draft converter rejected a conversion, which its contract allows only once the signal aborted", X), Ce;
420
+ return r.signal.aborted || x("the draft converter rejected a conversion, which its contract allows only once the signal aborted", X), Ce;
421
421
  }
422
- const U = nn(C);
423
- return U === null ? C : (S(`the draft converter answered outside its contract: ${U}`), Ce);
422
+ const U = on(C);
423
+ return U === null ? C : (x(`the draft converter answered outside its contract: ${U}`), Ce);
424
424
  }, T = (g, E) => {
425
425
  switch (E.kind) {
426
426
  case "preview":
427
- if (k(), E.headings.length > rn) {
428
- R(), L(se("too-large"), "instant");
427
+ if (k(), E.headings.length > sn) {
428
+ R(), L(le("too-large"), "instant");
429
429
  return;
430
430
  }
431
431
  c = { draft: g, html: E.htmlContent, headings: E.headings.map(({ text: C, depth: U, id: X }) => ({ text: C, depth: U, id: X })) }, B();
432
432
  return;
433
433
  case "failure":
434
- k(), R(), L(se(E.failure.reason, E.failure.code), "instant");
434
+ k(), R(), L(le(E.failure.reason, E.failure.code), "instant");
435
435
  return;
436
436
  case "unavailable":
437
437
  V(g);
@@ -465,7 +465,7 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
465
465
  r.abort(), w = null, clearTimeout(u), u = void 0, k();
466
466
  }
467
467
  };
468
- }, Un = (e) => sn(cn(window), e.iframeHosts, e.dataPath, ln, an(e)), Wn = (e, t) => e.flatMap((n, o) => {
468
+ }, Kn = (e) => cn(un(window), e.iframeHosts, e.dataPath, an, dn(e)), $n = (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) => rt(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 ${hn(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)}`);
477
477
  return n;
478
- }, Kn = (e) => {
478
+ }, Xn = (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) => rt(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
- }, $n = (e, t) => {
491
+ }, jn = (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 Kn(l))
495
+ for (const d of Xn(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) => rt(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
- }, Xn = 610, Me = 89, qe = 0.5, jn = ({ editor: e, preview: t, previewBlocks: n, editorSpans: o, requestFrame: i, cancelFrame: r, now: l }) => {
512
+ }, Yn = 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, x = () => {
515
+ let h = null, S = () => {
516
516
  };
517
517
  const p = (a) => {
518
- d !== null && a !== d || (s = a, f = l() + Xn);
519
- }, S = (a, T) => {
518
+ d !== null && a !== d || (s = a, f = l() + Yn);
519
+ }, x = (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(() => S("editor", e)), R = e.onIntent(() => p("editor")), L = () => {
524
+ }, k = e.onScroll(() => x("editor", e)), R = e.onIntent(() => p("editor")), L = () => {
525
525
  const a = t();
526
- return a !== h && (x(), h = a, x = a === null ? () => {
526
+ return a !== h && (S(), h = a, S = a === null ? () => {
527
527
  } : G(a)), a;
528
528
  }, G = (a) => {
529
- const T = a.onScroll(() => S("preview", a)), A = a.onIntent(() => p("preview"));
529
+ const T = a.onScroll(() => x("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(z));
535
- }, z = () => {
534
+ !w && b === null && (b = i(F));
535
+ }, F = () => {
536
536
  b = null;
537
537
  const a = L();
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())));
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())));
539
539
  }, V = (a, T, A) => {
540
540
  if (Math.abs(a.position() - A) < qe) {
541
541
  m[T] = a.position();
@@ -554,10 +554,10 @@ const ne = (e) => rt(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(), x();
557
+ w = !0, b !== null && r(b), b = null, k(), R(), S();
558
558
  }
559
559
  };
560
- }, Re = Object.freeze(["wheel", "pointerdown", "keydown", "focusin"]), $e = (e) => ({
560
+ }, Re = Object.freeze(["wheel", "pointerdown", "keydown", "focusin"]), Xe = (e) => ({
561
561
  position: () => e.scrollTop,
562
562
  max: () => Math.max(e.scrollHeight - e.clientHeight, 0),
563
563
  viewport: () => e.clientHeight,
@@ -569,57 +569,57 @@ const ne = (e) => rt(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]", Yn = "[data-aqmd-content]", Jn = `[${Ge}]`, Qn = Object.freeze(["p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8"]), Xe = (e, t) => {
573
- const n = lt(e.peek(t));
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) => {
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
- }, Zn = (e, t, n, o) => {
575
+ }, tr = (e, t, n, o) => {
576
576
  if (t === void 0) return null;
577
577
  let i;
578
578
  try {
579
- i = Un(e);
579
+ i = Kn(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: Fn, seed: Xe(n, o)?.htmlContent ?? null };
584
- }, er = (e) => {
583
+ return { converter: t, sanitize: i, marksOf: Un, seed: je(n, o)?.htmlContent ?? null };
584
+ }, nr = (e) => {
585
585
  const t = [];
586
586
  let n = null;
587
- for (const o of e.querySelectorAll(Jn)) {
588
- const i = tn(o.getAttribute(Ge));
587
+ for (const o of e.querySelectorAll(Zn)) {
588
+ const i = rn(o.getAttribute(Ue));
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
- }, 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 } = ae(), [v, u] = oe(() => ({ parsed: Xe(b, e), source: null, failure: null, busy: !0, tier: w === void 0 ? "server" : "instant" })), m = N(null), h = N(null), x = N(v);
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);
597
597
  D(() => {
598
- x.current = v;
598
+ S.current = v;
599
599
  });
600
600
  const p = Ee(() => t());
601
601
  Ve(() => {
602
- const a = Zn(f, w, b, e), T = p(), A = Gn({ path: e, instant: a, preview: d.preview, initial: x.current, onView: (g) => tt(() => u(g)) });
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)) });
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 S = Ee(() => l());
607
+ const x = Ee(() => l());
608
608
  D(() => {
609
- v.parsed !== null && S();
609
+ v.parsed !== null && x();
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(() => S());
616
+ const T = new ResizeObserver(() => x());
617
617
  T.observe(a);
618
- const A = a.querySelector(Yn);
618
+ const A = a.querySelector(Qn);
619
619
  return A !== null && T.observe(A), () => T.disconnect();
620
620
  }, [I]);
621
621
  const k = N(null);
622
- et(
622
+ tt(
623
623
  s,
624
624
  () => ({
625
625
  draft: (a) => {
@@ -627,11 +627,11 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
627
627
  },
628
628
  scrollPort: () => {
629
629
  const a = m.current?.querySelector(te);
630
- return a instanceof HTMLElement ? (k.current?.scroller !== a && (k.current = { scroller: a, port: $e(a) }), k.current.port) : null;
630
+ return a instanceof HTMLElement ? (k.current?.scroller !== a && (k.current = { scroller: a, port: Xe(a) }), k.current.port) : null;
631
631
  },
632
632
  blocks: () => {
633
633
  const a = m.current?.querySelector(te);
634
- return a instanceof HTMLElement ? er(a) : [];
634
+ return a instanceof HTMLElement ? nr(a) : [];
635
635
  },
636
636
  focus: () => {
637
637
  const a = m.current?.querySelector(te);
@@ -639,19 +639,19 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
639
639
  },
640
640
  anchor: (a) => {
641
641
  const T = m.current, A = T?.querySelector(te);
642
- return T === null || !(A instanceof HTMLElement) ? null : st(T, a(A));
642
+ return T === null || !(A instanceof HTMLElement) ? null : lt(T, a(A));
643
643
  },
644
644
  place: ({ line: a, clientTop: T }, A) => {
645
- const g = m.current, E = g === null ? null : ot(g, a);
646
- E !== null && (A(E).scrollTop += it(E, a) - T);
645
+ const g = m.current, E = g === null ? null : it(g, a);
646
+ E !== null && (A(E).scrollTop += st(E, a) - T);
647
647
  }
648
648
  }),
649
649
  []
650
650
  );
651
651
  const R = (a) => {
652
652
  const T = m.current, { target: A } = a;
653
- if (r === void 0 || T === null || !(A instanceof Element) || !ct(A)) return;
654
- const g = at(A, T, T.ownerDocument.getSelection());
653
+ if (r === void 0 || T === null || !(A instanceof Element) || !at(A)) return;
654
+ const g = ut(A, T, T.ownerDocument.getSelection());
655
655
  g !== null && r(g);
656
656
  }, L = v.source === null ? null : v.source.revision, G = Y(
657
657
  () => L === null ? void 0 : {
@@ -662,7 +662,7 @@ const ne = (e) => rt(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]), z = Y(
665
+ ), B = Y(() => ({ ...n.labels, spreadsheetReadOnly: c.previewTablePending }), [n.labels, c.previewTablePending]), F = Y(
666
666
  () => ({
667
667
  ...n,
668
668
  labels: G === void 0 ? B : n.labels,
@@ -678,8 +678,8 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
678
678
  }),
679
679
  [n, B, G]
680
680
  ), V = Y(
681
- () => v.parsed === null ? null : /* @__PURE__ */ q("div", { className: "aqmx-document-viewer", children: /* @__PURE__ */ q(en, { ...z, parseResult: v.parsed, content: null }) }),
682
- [z, v.parsed]
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]
683
683
  );
684
684
  return /* @__PURE__ */ re(
685
685
  "section",
@@ -694,27 +694,30 @@ const ne = (e) => rt(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__ */ q("p", { className: "aqmx-callout aqmx-document-notice", "data-aqmx-tone": "warning", "data-testid": "markdown-explorer-edit-preview-failure", children: c.previewFailed(He(c, v.failure.reason)) }),
698
- V ?? (v.failure === null ? /* @__PURE__ */ q("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-edit-preview-skeleton", children: Qn.map((a) => /* @__PURE__ */ q("span", {}, a)) }) : null),
699
- v.busy ? /* @__PURE__ */ q("p", { className: "aqmx-sr-only", children: c.previewUpdating }) : null
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),
699
+ v.busy ? /* @__PURE__ */ M("p", { className: "aqmx-sr-only", children: c.previewUpdating }) : null
700
700
  ]
701
701
  }
702
702
  );
703
- }, _e = "data-aqmx-edit-split", pe = "--aqmx-edit-share", Pe = "--aqmx-edit-gutter", nr = "data-aqmx-edit-split-probe", rr = "aqmx-edit-split", or = "aqmx-edit-editor", ir = "aqmx-edit-preview", Ne = { value: mn, unit: "percentage" }, De = { value: fn, unit: "percentage" }, Be = (e) => {
703
+ }, or = ({ failure: e }) => {
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) => {
704
707
  if (e.length !== 2) return null;
705
708
  const [t = 0, n = 0] = e, o = t + n;
706
709
  return o > 0 ? t / o * 100 : null;
707
- }, ce = (e) => {
710
+ }, ae = (e) => {
708
711
  const t = e.current?.parentElement;
709
712
  if (t == null) throw new Error("[markdown-explorer] the edit split is not mounted in its surface");
710
713
  return t;
711
- }, sr = (e, t, n) => {
714
+ }, ar = (e, t, n) => {
712
715
  const [o, i] = oe(null);
713
716
  return D(() => {
714
717
  const r = e.current, l = t.current;
715
718
  if (r === null || l === null) throw new Error("[markdown-explorer] the edit split is not mounted");
716
719
  const s = { frame: r.getBoundingClientRect().width, measure: l.getBoundingClientRect().width }, f = () => {
717
- s.frame > 0 && s.measure > 0 && i(pn(s.frame, s.measure, n));
720
+ s.frame > 0 && s.measure > 0 && i(gn(s.frame, s.measure, n));
718
721
  };
719
722
  f();
720
723
  const d = new ResizeObserver((b) => {
@@ -726,24 +729,24 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
726
729
  });
727
730
  return d.observe(r), d.observe(l), () => d.disconnect();
728
731
  }, [e, t, n]), o;
729
- }, lr = ({ editorId: e }) => {
730
- const { edits: t, labels: n } = ae(), o = Y(() => wn(n), [n]), i = N(null), r = N(null), l = ut() ? un : dn, s = sr(i, r, l), [f] = oe(() => t.editorShare());
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());
731
734
  D(() => {
732
- const w = ce(i);
735
+ const w = ae(i);
733
736
  return w.style.setProperty(Pe, `${String(l)}px`), () => {
734
737
  w.style.removeProperty(Pe);
735
738
  };
736
739
  }, [l]), D(() => {
737
- const w = ce(i);
740
+ const w = ae(i);
738
741
  return w.style.setProperty(pe, `${String(f)}%`), () => {
739
742
  w.style.removeProperty(pe);
740
743
  };
741
744
  }, [f]), D(() => {
742
745
  if (s === null) return;
743
- const w = ce(i);
746
+ const w = ae(i);
744
747
  return w.setAttribute(_e, s), () => w.removeAttribute(_e);
745
748
  }, [s]);
746
- const d = bn(
749
+ const d = Sn(
747
750
  J(
748
751
  (w) => {
749
752
  const c = Be(w);
@@ -754,19 +757,19 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
754
757
  ), b = J(
755
758
  (w, c) => {
756
759
  const v = Be(w);
757
- v !== null && ce(i).style.setProperty(pe, `${String(v)}%`), d.layoutChanged(w, c);
760
+ v !== null && ae(i).style.setProperty(pe, `${String(v)}%`), d.layoutChanged(w, c);
758
761
  },
759
762
  [d]
760
763
  );
761
764
  return /* @__PURE__ */ re("div", { ref: i, className: "aqmx-edit-split", "data-testid": "markdown-explorer-edit-split", children: [
762
- /* @__PURE__ */ q("span", { ref: r, className: "aqmx-edit-split-probe", "aria-hidden": "true", [nr]: "" }),
763
- s === null ? null : /* @__PURE__ */ re(gn, { id: rr, direction: s === "beside" ? "horizontal" : "vertical", onLayout: b, labels: o, className: "aqmx-edit-split-group", children: [
764
- /* @__PURE__ */ q(ke, { id: or, defaultSize: { value: f, unit: "percentage" }, minSize: Ne, maxSize: De, contentOverflow: "hidden" }),
765
- /* @__PURE__ */ q(
766
- vn,
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" }),
768
+ /* @__PURE__ */ M(
769
+ bn,
767
770
  {
768
771
  thickness: l,
769
- indicator: { visible: !0, thickness: le.gripThickness, length: le.gripLength, barThickness: le.barThickness, barLength: le.barLength },
772
+ indicator: { visible: !0, thickness: ce.gripThickness, length: ce.gripLength, barThickness: ce.barThickness, barLength: ce.barLength },
770
773
  title: n.editViewSplitResize,
771
774
  "aria-label": n.editViewSplitResize,
772
775
  "aria-controls": e,
@@ -774,10 +777,10 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
774
777
  className: "aqmx-split-handle aqmx-edit-split-handle"
775
778
  }
776
779
  ),
777
- /* @__PURE__ */ q(ke, { id: ir, defaultSize: { value: 100 - f, unit: "percentage" }, minSize: Ne, maxSize: De, contentOverflow: "hidden" })
780
+ /* @__PURE__ */ M(ke, { id: cr, defaultSize: { value: 100 - f, unit: "percentage" }, minSize: Ne, maxSize: De, contentOverflow: "hidden" })
778
781
  ] })
779
782
  ] });
780
- }, cr = 512, ar = () => {
783
+ }, dr = 512, fr = () => {
781
784
  const e = [];
782
785
  let t = 0, n = null;
783
786
  const o = (i) => {
@@ -798,42 +801,44 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
798
801
  },
799
802
  record: (i, r) => {
800
803
  if (n === null) throw new Error("[markdown-explorer] a change of the editor's text was recorded before an editor mounted");
801
- e.push({ before: n, changes: i }), n = r, e.length > cr && (e.shift(), t += 1);
804
+ e.push({ before: n, changes: i }), n = r, e.length > dr && (e.shift(), t += 1);
802
805
  },
803
806
  lineOf: (i, r) => {
804
807
  const l = o(i);
805
808
  if (l === null || n === null || !Number.isInteger(r) || r < 1 || r > l.lines) return null;
806
809
  let s = l.line(r).from;
807
810
  for (const f of e.slice(i - t)) {
808
- const d = f.changes.mapPos(s, 1, Kt.TrackAfter);
811
+ const d = f.changes.mapPos(s, 1, Xt.TrackAfter);
809
812
  if (d === null) return null;
810
813
  s = d;
811
814
  }
812
815
  return n.lineAt(s).number;
813
816
  }
814
817
  };
815
- }, ur = 144, dr = (e) => {
818
+ }, mr = 144, pr = (e) => {
816
819
  if (typeof e != "object" || e === null) return !1;
817
820
  const { generation: t, topLine: n } = e;
818
821
  return "state" in e && typeof t == "number" && typeof n == "number";
819
- }, fr = (e) => {
822
+ }, hr = (e) => {
820
823
  e.stopPropagation();
821
- }, _r = (e) => {
822
- const { path: t, name: n, session: o } = e, { edits: i, labels: r, announcer: l } = ae(), { phase: s } = o, f = J(() => i.retry(t), [i, t]);
824
+ }, Dr = (e) => {
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]);
823
826
  switch (Ve(() => {
824
- s.kind === "failed" && l.announce(r.documentFailed(n, He(r, s.failure.reason)));
827
+ if (s.kind !== "failed") return;
828
+ const { reason: d } = s.failure;
829
+ He(d) || l.announce(r.documentFailed(n, Fe(r, d)));
825
830
  }, [s, l, r, n]), s.kind) {
826
831
  case "opening":
827
- return /* @__PURE__ */ q(mt, { label: r.editLoading, testId: "markdown-explorer-edit-skeleton" });
832
+ return /* @__PURE__ */ M(ht, { label: r.editLoading, testId: "markdown-explorer-edit-skeleton" });
828
833
  case "grant":
829
- return /* @__PURE__ */ q("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ q(ft, { href: s.href, onRetry: f, testId: "markdown-explorer-edit-grant" }) });
834
+ return /* @__PURE__ */ M("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ M(pt, { href: s.href, onRetry: f, testId: "markdown-explorer-edit-grant" }) });
830
835
  case "failed":
831
- return /* @__PURE__ */ q("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ q(dt, { failure: s.failure, alert: !1, onRetry: f, testId: "markdown-explorer-edit-failure" }) });
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" }) });
832
837
  case "editing":
833
- return /* @__PURE__ */ q(mr, { ...e });
838
+ return /* @__PURE__ */ M(gr, { ...e });
834
839
  }
835
- }, mr = ({ path: e, name: t, session: n, layout: o, viewer: i, region: r, paneScroll: l }) => {
836
- const { edits: s, labels: f } = ae(), d = N(null), b = nt(), w = N(null), [c] = oe(() => /* @__PURE__ */ new Set()), [v] = oe(ar), u = N(null), m = N(null), h = o === "fill", x = pt(), p = ht(n, x, h), S = p !== "editor" || n.previewPrepared, I = S && h, k = N({ layout: o, region: r, paneScroll: l });
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 });
837
842
  D(() => {
838
843
  k.current = { layout: o, region: r, paneScroll: l };
839
844
  });
@@ -841,13 +846,13 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
841
846
  D(() => {
842
847
  R.current = n.generation;
843
848
  });
844
- const L = N({ view: p, previewMounted: S });
849
+ const L = N({ view: p, previewMounted: x });
845
850
  D(() => {
846
- L.current = { view: p, previewMounted: S };
851
+ L.current = { view: p, previewMounted: x };
847
852
  });
848
- const { requestSave: G, confirmation: B } = gt(e), z = N(G);
853
+ const { requestSave: G, confirmation: B } = wt(e), F = N(G);
849
854
  D(() => {
850
- z.current = G;
855
+ F.current = G;
851
856
  });
852
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) => {
853
858
  const { region: O, paneScroll: P } = k.current, H = O();
@@ -856,46 +861,46 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
856
861
  D(() => {
857
862
  const y = d.current, O = s.draft(e);
858
863
  if (y === null || O === null) return;
859
- const P = s.editorState.get(e), H = dr(P) && P.generation === R.current ? P : null;
864
+ const P = s.editorState.get(e), H = pr(P) && P.generation === R.current ? P : null;
860
865
  let K = null, Q = null;
861
866
  const fe = () => {
862
867
  K !== null && clearTimeout(K), K = null, Q !== null && s.setDraft(e, Q.text());
863
- }, W = qn({
868
+ }, W = _n({
864
869
  parent: y,
865
870
  scroll: {
866
- scrollerOf: (M) => {
867
- const { layout: Z, region: Je, paneScroll: Qe } = k.current, be = Je();
868
- return Z === "fill" || be === null ? M : Qe.scrollerOf(be, M);
871
+ scrollerOf: (q) => {
872
+ const { layout: Z, region: Qe, paneScroll: Ze } = k.current, be = Qe();
873
+ return Z === "fill" || be === null ? q : Ze.scrollerOf(be, q);
869
874
  },
870
- reveal: (M) => k.current.paneScroll.reveal(M)
875
+ reveal: (q) => k.current.paneScroll.reveal(q)
871
876
  },
872
877
  text: O,
873
878
  saved: H === null ? void 0 : H.state,
874
879
  labels: A,
875
880
  revisions: v,
876
- onGeometry: (M) => m.current?.editorChanged(M),
877
- onChange: (M) => {
878
- if (K ??= setTimeout(fe, ur), !M)
881
+ onGeometry: (q) => m.current?.editorChanged(q),
882
+ onChange: (q) => {
883
+ if (K ??= setTimeout(fe, mr), !q)
879
884
  for (const Z of [...c]) Z();
880
885
  L.current.previewMounted && Q !== null && u.current?.draft({ text: Q.text(), revision: v.revision() });
881
886
  },
882
- onSave: () => z.current()
887
+ onSave: () => F.current()
883
888
  });
884
889
  Q = W, w.current = W;
885
890
  const ve = () => {
886
- const M = W.topLine();
887
- return { line: M.line, clientTop: M.clientTop };
888
- }, we = () => u.current?.anchor(g) ?? null, Ye = s.bindEditor(e, {
891
+ const q = W.topLine();
892
+ return { line: q.line, clientTop: q.clientTop };
893
+ }, we = () => u.current?.anchor(g) ?? null, Je = s.bindEditor(e, {
889
894
  flush: fe,
890
- adopt: (M) => W.replaceText(M),
895
+ adopt: (q) => W.replaceText(q),
891
896
  returnPoint: () => {
892
- const M = L.current.view === "preview" && k.current.layout === "content" ? we() : null;
893
- return M === null ? ve() : { line: M.lines.first, clientTop: M.clientTop };
897
+ const q = L.current.view === "preview" && k.current.layout === "content" ? we() : null;
898
+ return q === null ? ve() : { line: q.lines.first, clientTop: q.clientTop };
894
899
  },
895
900
  nextConflict: () => L.current.view !== "preview" ? W.nextConflict() : W.conflicts().length === 0 ? !1 : (T.current = !0, s.setView(e, "editor"), !0),
896
- beforeView: (M) => {
901
+ beforeView: (q) => {
897
902
  if (k.current.layout === "fill") return;
898
- if (M === "preview") {
903
+ if (q === "preview") {
899
904
  V.current = { to: "preview", point: ve() };
900
905
  return;
901
906
  }
@@ -904,13 +909,13 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
904
909
  }
905
910
  });
906
911
  return H !== null && W.showLine(H.topLine), () => {
907
- fe(), s.editorState.set(e, { state: W.save(), generation: R.current, topLine: W.topLine().line }), Ye(), W.destroy(), Q = null, w.current = null;
912
+ fe(), s.editorState.set(e, { state: W.save(), generation: R.current, topLine: W.topLine().line }), Je(), W.destroy(), Q = null, w.current = null;
908
913
  };
909
914
  }, [s, e, A, g, c, v]);
910
915
  const { request: E } = n;
911
916
  D(() => {
912
917
  const y = w.current, O = s.draft(e);
913
- y === null || O === null || E === null || (E.anchor !== null && y.reveal(xe(O, E.anchor), E.anchor.clientTop), y.focus(), s.consumeRequest(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));
914
919
  }, [s, e, E, A]), D(() => {
915
920
  p !== "editor" && !n.previewPrepared && s.preparePreview(e);
916
921
  }, [s, e, p, n.previewPrepared]), D(() => {
@@ -920,7 +925,7 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
920
925
  if (y?.to === "preview") u.current?.place(y.point, g);
921
926
  else if (y?.to === "editor" && H !== null) {
922
927
  const K = s.draft(e);
923
- K !== null && H.reveal(xe(K, y.anchor), y.anchor.clientTop);
928
+ K !== null && H.reveal(Se(K, y.anchor), y.anchor.clientTop);
924
929
  }
925
930
  P ? H?.nextConflict() : O === "editor" ? H?.focus() : O === "preview" && u.current?.focus();
926
931
  }, [s, e, p, g]);
@@ -947,8 +952,8 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
947
952
  D(() => {
948
953
  const y = w.current;
949
954
  if (!I || y === null) return;
950
- const O = jn({
951
- editor: $e(y.scrollElement),
955
+ const O = Jn({
956
+ editor: Xe(y.scrollElement),
952
957
  preview: () => u.current?.scrollPort() ?? null,
953
958
  previewBlocks: () => u.current?.blocks() ?? [],
954
959
  editorSpans: (P) => y.lineSpans(P),
@@ -956,35 +961,35 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
956
961
  cancelFrame: (P) => cancelAnimationFrame(P),
957
962
  now: () => performance.now()
958
963
  });
959
- return O.showAlone(Se(L.current.view)), m.current = O, () => {
964
+ return O.showAlone(xe(L.current.view)), m.current = O, () => {
960
965
  O.dispose(), m.current = null;
961
966
  };
962
967
  }, [I, s, e, A]), D(() => {
963
- m.current?.showAlone(Se(p));
968
+ m.current?.showAlone(xe(p));
964
969
  }, [p]);
965
- const X = J(() => m.current?.previewChanged(), []), F = J((y) => s.start(e, y), [s, e]), je = (
970
+ const X = J(() => m.current?.previewChanged(), []), z = J((y) => s.start(e, y), [s, e]), Ye = (
966
971
  /* @__PURE__ */ re("div", { className: "aqmx-edit", "data-aqmx-edit-layout": o, "data-aqmx-edit-view": p, "data-testid": "markdown-explorer-edit", onKeyDown: (y) => {
967
- if (wt(y.target)) return;
972
+ if (Et(y.target)) return;
968
973
  if (y.key === "Escape") {
969
974
  ye(y);
970
975
  return;
971
976
  }
972
- if (!bt(y.nativeEvent, Et(navigator.platform))) return;
977
+ if (!St(y.nativeEvent, xt(navigator.platform))) return;
973
978
  ye(y);
974
- const O = St(p);
975
- a.current = O, xt(s, e, O, h);
976
- }, onDoubleClick: fr, children: [
977
- /* @__PURE__ */ q("div", { ref: d, id: b, className: "aqmx-edit-editor", "data-testid": "markdown-explorer-editor", inert: p === "preview", hidden: p === "preview" && !h, ...vt }),
978
- p === "split" ? /* @__PURE__ */ q(lr, { editorId: b }) : null,
979
- S ? /* @__PURE__ */ q(tr, { path: e, readDraft: U, viewer: i, tables: C, concealed: p !== "editor" ? null : h ? "overlay" : "removed", onEditAt: p === "preview" ? F : void 0, onLayout: X, handleRef: u }) : null
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
980
985
  ] })
981
986
  );
982
- return /* @__PURE__ */ re(Ze, { children: [
983
- je,
987
+ return /* @__PURE__ */ re(et, { children: [
988
+ Ye,
984
989
  B
985
990
  ] });
986
991
  };
987
992
  export {
988
- ur as DRAFT_WRITE_INTERVAL_MS,
989
- _r as default
993
+ mr as DRAFT_WRITE_INTERVAL_MS,
994
+ Dr as default
990
995
  };