@box/threaded-annotations 2.1.10 → 3.0.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.
@@ -1,54 +1,61 @@
1
- function e(t, n, r) {
2
- for (let i = 0;; i++) {
3
- if (i == t.childCount || i == n.childCount) return t.childCount == n.childCount ? null : r;
4
- let a = t.child(i), o = n.child(i);
5
- if (a == o) {
6
- r += a.nodeSize;
1
+ function e(t, i, a) {
2
+ for (let o = 0;; o++) {
3
+ if (o == t.childCount || o == i.childCount) return t.childCount == i.childCount ? null : a;
4
+ let s = t.child(o), c = i.child(o);
5
+ if (s == c) {
6
+ a += s.nodeSize;
7
7
  continue;
8
8
  }
9
- if (!a.sameMarkup(o)) return r;
10
- if (a.isText && a.text != o.text) {
11
- for (let e = 0; a.text[e] == o.text[e]; e++) r++;
12
- return r;
9
+ if (!s.sameMarkup(c)) return a;
10
+ if (s.isText && s.text != c.text) {
11
+ let e = s.text, t = c.text, i = 0;
12
+ for (; e[i] == t[i]; i++) a++;
13
+ return i && i < e.length && i < t.length && r(e.charCodeAt(i - 1)) && n(e.charCodeAt(i)) && a--, a;
13
14
  }
14
- if (a.content.size || o.content.size) {
15
- let t = e(a.content, o.content, r + 1);
15
+ if (s.content.size || c.content.size) {
16
+ let t = e(s.content, c.content, a + 1);
16
17
  if (t != null) return t;
17
18
  }
18
- r += a.nodeSize;
19
+ a += s.nodeSize;
19
20
  }
20
21
  }
21
- function t(e, n, r, i) {
22
- for (let a = e.childCount, o = n.childCount;;) {
23
- if (a == 0 || o == 0) return a == o ? null : {
24
- a: r,
25
- b: i
22
+ function t(e, i, a, o) {
23
+ for (let s = e.childCount, c = i.childCount;;) {
24
+ if (s == 0 || c == 0) return s == c ? null : {
25
+ a,
26
+ b: o
26
27
  };
27
- let s = e.child(--a), c = n.child(--o), l = s.nodeSize;
28
- if (s == c) {
29
- r -= l, i -= l;
28
+ let l = e.child(--s), u = i.child(--c), d = l.nodeSize;
29
+ if (l == u) {
30
+ a -= d, o -= d;
30
31
  continue;
31
32
  }
32
- if (!s.sameMarkup(c)) return {
33
- a: r,
34
- b: i
33
+ if (!l.sameMarkup(u)) return {
34
+ a,
35
+ b: o
35
36
  };
36
- if (s.isText && s.text != c.text) {
37
- let e = 0, t = Math.min(s.text.length, c.text.length);
38
- for (; e < t && s.text[s.text.length - e - 1] == c.text[c.text.length - e - 1];) e++, r--, i--;
39
- return {
40
- a: r,
41
- b: i
37
+ if (l.isText && l.text != u.text) {
38
+ let e = l.text, t = u.text, i = e.length, s = t.length;
39
+ for (; i > 0 && s > 0 && e[i - 1] == t[s - 1];) i--, s--, a--, o--;
40
+ return i && s && i < e.length && r(e.charCodeAt(i - 1)) && n(e.charCodeAt(i)) && (a++, o++), {
41
+ a,
42
+ b: o
42
43
  };
43
44
  }
44
- if (s.content.size || c.content.size) {
45
- let e = t(s.content, c.content, r - 1, i - 1);
45
+ if (l.content.size || u.content.size) {
46
+ let e = t(l.content, u.content, a - 1, o - 1);
46
47
  if (e) return e;
47
48
  }
48
- r -= l, i -= l;
49
+ a -= d, o -= d;
49
50
  }
50
51
  }
51
- var n = class n {
52
+ function n(e) {
53
+ return e >= 56320 && e < 57344;
54
+ }
55
+ function r(e) {
56
+ return e >= 55296 && e < 56320;
57
+ }
58
+ var i = class n {
52
59
  constructor(e, t) {
53
60
  if (this.content = e, this.size = t || 0, t == null) for (let t = 0; t < e.length; t++) this.size += e[t].nodeSize;
54
61
  }
@@ -138,13 +145,13 @@ var n = class n {
138
145
  return t(this, e, n, r);
139
146
  }
140
147
  findIndex(e) {
141
- if (e == 0) return i(0, e);
142
- if (e == this.size) return i(this.content.length, e);
148
+ if (e == 0) return o(0, e);
149
+ if (e == this.size) return o(this.content.length, e);
143
150
  if (e > this.size || e < 0) throw RangeError(`Position ${e} outside of fragment (${this})`);
144
151
  for (let t = 0, n = 0;; t++) {
145
- let r = this.child(t), a = n + r.nodeSize;
146
- if (a >= e) return a == e ? i(t + 1, a) : i(t, n);
147
- n = a;
152
+ let r = this.child(t), i = n + r.nodeSize;
153
+ if (i >= e) return i == e ? o(t + 1, i) : o(t, n);
154
+ n = i;
148
155
  }
149
156
  }
150
157
  toString() {
@@ -159,7 +166,7 @@ var n = class n {
159
166
  static fromJSON(e, t) {
160
167
  if (!t) return n.empty;
161
168
  if (!Array.isArray(t)) throw RangeError("Invalid input for Fragment.fromJSON");
162
- return new n(t.map(e.nodeFromJSON));
169
+ return n.fromArray(t.map(e.nodeFromJSON));
163
170
  }
164
171
  static fromArray(e) {
165
172
  if (!e.length) return n.empty;
@@ -178,29 +185,29 @@ var n = class n {
178
185
  throw RangeError("Can not convert " + e + " to a Fragment" + (e.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
179
186
  }
180
187
  };
181
- n.empty = new n([], 0);
182
- var r = {
188
+ i.empty = new i([], 0);
189
+ var a = {
183
190
  index: 0,
184
191
  offset: 0
185
192
  };
186
- function i(e, t) {
187
- return r.index = e, r.offset = t, r;
193
+ function o(e, t) {
194
+ return a.index = e, a.offset = t, a;
188
195
  }
189
- function a(e, t) {
196
+ function s(e, t) {
190
197
  if (e === t) return !0;
191
198
  if (!(e && typeof e == "object") || !(t && typeof t == "object")) return !1;
192
199
  let n = Array.isArray(e);
193
200
  if (Array.isArray(t) != n) return !1;
194
201
  if (n) {
195
202
  if (e.length != t.length) return !1;
196
- for (let n = 0; n < e.length; n++) if (!a(e[n], t[n])) return !1;
203
+ for (let n = 0; n < e.length; n++) if (!s(e[n], t[n])) return !1;
197
204
  } else {
198
- for (let n in e) if (!(n in t) || !a(e[n], t[n])) return !1;
205
+ for (let n in e) if (!(n in t) || !s(e[n], t[n])) return !1;
199
206
  for (let n in t) if (!(n in e)) return !1;
200
207
  }
201
208
  return !0;
202
209
  }
203
- var o = class e {
210
+ var c = class e {
204
211
  constructor(e, t) {
205
212
  this.type = e, this.attrs = t;
206
213
  }
@@ -224,7 +231,7 @@ var o = class e {
224
231
  return !1;
225
232
  }
226
233
  eq(e) {
227
- return this == e || this.type == e.type && a(this.attrs, e.attrs);
234
+ return this == e || this.type == e.type && s(this.attrs, e.attrs);
228
235
  }
229
236
  toJSON() {
230
237
  let e = { type: this.type.name };
@@ -254,8 +261,8 @@ var o = class e {
254
261
  return n.sort((e, t) => e.type.rank - t.type.rank), n;
255
262
  }
256
263
  };
257
- o.none = [];
258
- var s = class extends Error {}, c = class e {
264
+ c.none = [];
265
+ var l = class extends Error {}, u = class e {
259
266
  constructor(e, t, n) {
260
267
  this.content = e, this.openStart = t, this.openEnd = n;
261
268
  }
@@ -263,11 +270,11 @@ var s = class extends Error {}, c = class e {
263
270
  return this.content.size - this.openStart - this.openEnd;
264
271
  }
265
272
  insertAt(t, n) {
266
- let r = u(this.content, t + this.openStart, n);
273
+ let r = f(this.content, t + this.openStart, n, this.openStart + 1, this.openEnd + 1);
267
274
  return r && new e(r, this.openStart, this.openEnd);
268
275
  }
269
276
  removeBetween(t, n) {
270
- return new e(l(this.content, t + this.openStart, n + this.openStart), this.openStart, this.openEnd);
277
+ return new e(d(this.content, t + this.openStart, n + this.openStart), this.openStart, this.openEnd);
271
278
  }
272
279
  eq(e) {
273
280
  return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd;
@@ -280,11 +287,11 @@ var s = class extends Error {}, c = class e {
280
287
  let e = { content: this.content.toJSON() };
281
288
  return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e;
282
289
  }
283
- static fromJSON(t, r) {
284
- if (!r) return e.empty;
285
- let i = r.openStart || 0, a = r.openEnd || 0;
286
- if (typeof i != "number" || typeof a != "number") throw RangeError("Invalid input for Slice.fromJSON");
287
- return new e(n.fromJSON(t, r.content), i, a);
290
+ static fromJSON(t, n) {
291
+ if (!n) return e.empty;
292
+ let r = n.openStart || 0, a = n.openEnd || 0;
293
+ if (typeof r != "number" || typeof a != "number") throw RangeError("Invalid input for Slice.fromJSON");
294
+ return new e(i.fromJSON(t, n.content), r, a);
288
295
  }
289
296
  static maxOpen(t, n = !0) {
290
297
  let r = 0, i = 0;
@@ -293,78 +300,79 @@ var s = class extends Error {}, c = class e {
293
300
  return new e(t, r, i);
294
301
  }
295
302
  };
296
- c.empty = new c(n.empty, 0, 0);
297
- function l(e, t, n) {
303
+ u.empty = new u(i.empty, 0, 0);
304
+ function d(e, t, n) {
298
305
  let { index: r, offset: i } = e.findIndex(t), a = e.maybeChild(r), { index: o, offset: s } = e.findIndex(n);
299
306
  if (i == t || a.isText) {
300
307
  if (s != n && !e.child(o).isText) throw RangeError("Removing non-flat range");
301
308
  return e.cut(0, t).append(e.cut(n));
302
309
  }
303
310
  if (r != o) throw RangeError("Removing non-flat range");
304
- return e.replaceChild(r, a.copy(l(a.content, t - i - 1, n - i - 1)));
311
+ return e.replaceChild(r, a.copy(d(a.content, t - i - 1, n - i - 1)));
305
312
  }
306
- function u(e, t, n, r) {
307
- let { index: i, offset: a } = e.findIndex(t), o = e.maybeChild(i);
308
- if (a == t || o.isText) return r && !r.canReplace(i, i, n) ? null : e.cut(0, t).append(n).append(e.cut(t));
309
- let s = u(o.content, t - a - 1, n, o);
310
- return s && e.replaceChild(i, o.copy(s));
313
+ function f(e, t, n, r, i, a) {
314
+ let { index: o, offset: s } = e.findIndex(t), c = e.maybeChild(o);
315
+ if (s == t || c.isText) return a && r <= 0 && i <= 0 && !a.canReplace(o, o, n) ? null : e.cut(0, t).append(n).append(e.cut(t));
316
+ let l = f(c.content, t - s - 1, n, o == 0 ? r - 1 : 0, o == e.childCount - 1 ? i - 1 : 0, c);
317
+ return l && e.replaceChild(o, c.copy(l));
311
318
  }
312
- function d(e, t, n) {
313
- if (n.openStart > e.depth) throw new s("Inserted content deeper than insertion position");
314
- if (e.depth - n.openStart != t.depth - n.openEnd) throw new s("Inconsistent open depths");
315
- return f(e, t, n, 0);
319
+ function ee(e, t, n) {
320
+ if (n.openStart > e.depth) throw new l("Inserted content deeper than insertion position");
321
+ if (e.depth - n.openStart != t.depth - n.openEnd) throw new l("Inconsistent open depths");
322
+ return p(e, t, n, 0);
316
323
  }
317
- function f(e, t, n, r) {
324
+ function p(e, t, n, r) {
318
325
  let i = e.index(r), a = e.node(r);
319
326
  if (i == t.index(r) && r < e.depth - n.openStart) {
320
- let o = f(e, t, n, r + 1);
327
+ let o = p(e, t, n, r + 1);
321
328
  return a.copy(a.content.replaceChild(i, o));
322
- } else if (!n.content.size) return g(a, v(e, t, r));
329
+ } else if (!n.content.size) return v(a, y(e, t, r));
323
330
  else if (!n.openStart && !n.openEnd && e.depth == r && t.depth == r) {
324
331
  let r = e.parent, i = r.content;
325
- return g(r, i.cut(0, e.parentOffset).append(n.content).append(i.cut(t.parentOffset)));
332
+ return v(r, i.cut(0, e.parentOffset).append(n.content).append(i.cut(t.parentOffset)));
326
333
  } else {
327
- let { start: i, end: o } = te(n, e);
328
- return g(a, _(e, i, o, t, r));
334
+ let { start: i, end: o } = ne(n, e);
335
+ return v(a, te(e, i, o, t, r));
329
336
  }
330
337
  }
331
- function ee(e, t) {
332
- if (!t.type.compatibleContent(e.type)) throw new s("Cannot join " + t.type.name + " onto " + e.type.name);
338
+ function m(e, t) {
339
+ if (!t.type.compatibleContent(e.type)) throw new l("Cannot join " + t.type.name + " onto " + e.type.name);
333
340
  }
334
- function p(e, t, n) {
341
+ function h(e, t, n) {
335
342
  let r = e.node(n);
336
- return ee(r, t.node(n)), r;
343
+ return m(r, t.node(n)), r;
337
344
  }
338
- function m(e, t) {
345
+ function g(e, t) {
339
346
  let n = t.length - 1;
340
347
  n >= 0 && e.isText && e.sameMarkup(t[n]) ? t[n] = e.withText(t[n].text + e.text) : t.push(e);
341
348
  }
342
- function h(e, t, n, r) {
349
+ function _(e, t, n, r) {
343
350
  let i = (t || e).node(n), a = 0, o = t ? t.index(n) : i.childCount;
344
- e && (a = e.index(n), e.depth > n ? a++ : e.textOffset && (m(e.nodeAfter, r), a++));
345
- for (let e = a; e < o; e++) m(i.child(e), r);
346
- t && t.depth == n && t.textOffset && m(t.nodeBefore, r);
351
+ e && (a = e.index(n), e.depth > n ? a++ : e.textOffset && (g(e.nodeAfter, r), a++));
352
+ for (let e = a; e < o; e++) g(i.child(e), r);
353
+ t && t.depth == n && t.textOffset && g(t.nodeBefore, r);
347
354
  }
348
- function g(e, t) {
349
- return e.type.checkContent(t), e.copy(t);
355
+ function v(e, t) {
356
+ if (!e.type.validContent(t)) throw new l("Invalid content for node " + e.type.name);
357
+ return e.copy(t);
350
358
  }
351
- function _(e, t, r, i, a) {
352
- let o = e.depth > a && p(e, t, a + 1), s = i.depth > a && p(r, i, a + 1), c = [];
353
- return h(null, e, a, c), o && s && t.index(a) == r.index(a) ? (ee(o, s), m(g(o, _(e, t, r, i, a + 1)), c)) : (o && m(g(o, v(e, t, a + 1)), c), h(t, r, a, c), s && m(g(s, v(r, i, a + 1)), c)), h(i, null, a, c), new n(c);
359
+ function te(e, t, n, r, a) {
360
+ let o = e.depth > a && h(e, t, a + 1), s = r.depth > a && h(n, r, a + 1), c = [];
361
+ return _(null, e, a, c), o && s && t.index(a) == n.index(a) ? (m(o, s), g(v(o, te(e, t, n, r, a + 1)), c)) : (o && g(v(o, y(e, t, a + 1)), c), _(t, n, a, c), s && g(v(s, y(n, r, a + 1)), c)), _(r, null, a, c), new i(c);
354
362
  }
355
- function v(e, t, r) {
356
- let i = [];
357
- return h(null, e, r, i), e.depth > r && m(g(p(e, t, r + 1), v(e, t, r + 1)), i), h(t, null, r, i), new n(i);
363
+ function y(e, t, n) {
364
+ let r = [];
365
+ return _(null, e, n, r), e.depth > n && g(v(h(e, t, n + 1), y(e, t, n + 1)), r), _(t, null, n, r), new i(r);
358
366
  }
359
- function te(e, t) {
360
- let r = t.depth - e.openStart, i = t.node(r).copy(e.content);
361
- for (let e = r - 1; e >= 0; e--) i = t.node(e).copy(n.from(i));
367
+ function ne(e, t) {
368
+ let n = t.depth - e.openStart, r = t.node(n).copy(e.content);
369
+ for (let e = n - 1; e >= 0; e--) r = t.node(e).copy(i.from(r));
362
370
  return {
363
- start: i.resolveNoCache(e.openStart + r),
364
- end: i.resolveNoCache(i.content.size - e.openEnd - r)
371
+ start: r.resolveNoCache(e.openStart + n),
372
+ end: r.resolveNoCache(r.content.size - e.openEnd - n)
365
373
  };
366
374
  }
367
- var y = class e {
375
+ var b = class e {
368
376
  constructor(e, t, n) {
369
377
  this.pos = e, this.path = t, this.parentOffset = n, this.depth = t.length / 3 - 1;
370
378
  }
@@ -421,7 +429,7 @@ var y = class e {
421
429
  }
422
430
  marks() {
423
431
  let e = this.parent, t = this.index();
424
- if (e.content.size == 0) return o.none;
432
+ if (e.content.size == 0) return c.none;
425
433
  if (this.textOffset) return e.child(t).marks;
426
434
  let n = e.maybeChild(t - 1), r = e.maybeChild(t);
427
435
  if (!n) {
@@ -445,7 +453,7 @@ var y = class e {
445
453
  }
446
454
  blockRange(e = this, t) {
447
455
  if (e.pos < this.pos) return e.blockRange(this);
448
- for (let n = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); n >= 0; n--) if (e.pos <= this.end(n) && (!t || t(this.node(n)))) return new ie(this, e, n);
456
+ for (let n = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); n >= 0; n--) if (e.pos <= this.end(n) && (!t || t(this.node(n)))) return new ae(this, e, n);
449
457
  return null;
450
458
  }
451
459
  sameParent(e) {
@@ -473,20 +481,20 @@ var y = class e {
473
481
  return new e(n, r, a);
474
482
  }
475
483
  static resolveCached(t, n) {
476
- let r = b.get(t);
484
+ let r = x.get(t);
477
485
  if (r) for (let e = 0; e < r.elts.length; e++) {
478
486
  let t = r.elts[e];
479
487
  if (t.pos == n) return t;
480
488
  }
481
- else b.set(t, r = new ne());
489
+ else x.set(t, r = new re());
482
490
  let i = r.elts[r.i] = e.resolve(t, n);
483
- return r.i = (r.i + 1) % re, i;
491
+ return r.i = (r.i + 1) % ie, i;
484
492
  }
485
- }, ne = class {
493
+ }, re = class {
486
494
  constructor() {
487
495
  this.elts = [], this.i = 0;
488
496
  }
489
- }, re = 12, b = /* @__PURE__ */ new WeakMap(), ie = class {
497
+ }, ie = 12, x = /* @__PURE__ */ new WeakMap(), ae = class {
490
498
  constructor(e, t, n) {
491
499
  this.$from = e, this.$to = t, this.depth = n;
492
500
  }
@@ -505,9 +513,9 @@ var y = class e {
505
513
  get endIndex() {
506
514
  return this.$to.indexAfter(this.depth);
507
515
  }
508
- }, ae = Object.create(null), oe = class e {
509
- constructor(e, t, r, i = o.none) {
510
- this.type = e, this.attrs = t, this.marks = i, this.content = r || n.empty;
516
+ }, oe = Object.create(null), se = class e {
517
+ constructor(e, t, n, r = c.none) {
518
+ this.type = e, this.attrs = t, this.marks = r, this.content = n || i.empty;
511
519
  }
512
520
  get children() {
513
521
  return this.content.content;
@@ -552,7 +560,7 @@ var y = class e {
552
560
  return this.hasMarkup(e.type, e.attrs, e.marks);
553
561
  }
554
562
  hasMarkup(e, t, n) {
555
- return this.type == e && a(this.attrs, t || e.defaultAttrs || ae) && o.sameSet(this.marks, n || o.none);
563
+ return this.type == e && s(this.attrs, t || e.defaultAttrs || oe) && c.sameSet(this.marks, n || c.none);
556
564
  }
557
565
  copy(t = null) {
558
566
  return t == this.content ? this : new e(this.type, this.attrs, t, this.marks);
@@ -564,12 +572,12 @@ var y = class e {
564
572
  return e == 0 && t == this.content.size ? this : this.copy(this.content.cut(e, t));
565
573
  }
566
574
  slice(e, t = this.content.size, n = !1) {
567
- if (e == t) return c.empty;
575
+ if (e == t) return u.empty;
568
576
  let r = this.resolve(e), i = this.resolve(t), a = n ? 0 : r.sharedDepth(t), o = r.start(a);
569
- return new c(r.node(a).content.cut(r.pos - o, i.pos - o), r.depth - a, i.depth - a);
577
+ return new u(r.node(a).content.cut(r.pos - o, i.pos - o), r.depth - a, i.depth - a);
570
578
  }
571
579
  replace(e, t, n) {
572
- return d(this.resolve(e), this.resolve(t), n);
580
+ return ee(this.resolve(e), this.resolve(t), n);
573
581
  }
574
582
  nodeAt(e) {
575
583
  for (let t = this;;) {
@@ -607,10 +615,10 @@ var y = class e {
607
615
  };
608
616
  }
609
617
  resolve(e) {
610
- return y.resolveCached(this, e);
618
+ return b.resolveCached(this, e);
611
619
  }
612
620
  resolveNoCache(e) {
613
- return y.resolve(this, e);
621
+ return b.resolve(this, e);
614
622
  }
615
623
  rangeHasMark(e, t, n) {
616
624
  let r = !1;
@@ -640,17 +648,17 @@ var y = class e {
640
648
  toString() {
641
649
  if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this);
642
650
  let e = this.type.name;
643
- return this.content.size && (e += "(" + this.content.toStringInner() + ")"), se(this.marks, e);
651
+ return this.content.size && (e += "(" + this.content.toStringInner() + ")"), ce(this.marks, e);
644
652
  }
645
653
  contentMatchAt(e) {
646
654
  let t = this.type.contentMatch.matchFragment(this.content, 0, e);
647
655
  if (!t) throw Error("Called contentMatchAt on a node with invalid content");
648
656
  return t;
649
657
  }
650
- canReplace(e, t, r = n.empty, i = 0, a = r.childCount) {
651
- let o = this.contentMatchAt(e).matchFragment(r, i, a), s = o && o.matchFragment(this.content, t);
658
+ canReplace(e, t, n = i.empty, r = 0, a = n.childCount) {
659
+ let o = this.contentMatchAt(e).matchFragment(n, r, a), s = o && o.matchFragment(this.content, t);
652
660
  if (!s || !s.validEnd) return !1;
653
- for (let e = i; e < a; e++) if (!this.type.allowsMarks(r.child(e).marks)) return !1;
661
+ for (let e = r; e < a; e++) if (!this.type.allowsMarks(n.child(e).marks)) return !1;
654
662
  return !0;
655
663
  }
656
664
  canReplaceWith(e, t, n, r) {
@@ -663,12 +671,12 @@ var y = class e {
663
671
  }
664
672
  check() {
665
673
  this.type.checkContent(this.content), this.type.checkAttrs(this.attrs);
666
- let e = o.none;
674
+ let e = c.none;
667
675
  for (let t = 0; t < this.marks.length; t++) {
668
676
  let n = this.marks[t];
669
677
  n.type.checkAttrs(n.attrs), e = n.addToSet(e);
670
678
  }
671
- if (!o.sameSet(e, this.marks)) throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`);
679
+ if (!c.sameSet(e, this.marks)) throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`);
672
680
  this.content.forEach((e) => e.check());
673
681
  }
674
682
  toJSON() {
@@ -681,32 +689,32 @@ var y = class e {
681
689
  }
682
690
  static fromJSON(e, t) {
683
691
  if (!t) throw RangeError("Invalid input for Node.fromJSON");
684
- let r;
692
+ let n;
685
693
  if (t.marks) {
686
694
  if (!Array.isArray(t.marks)) throw RangeError("Invalid mark data for Node.fromJSON");
687
- r = t.marks.map(e.markFromJSON);
695
+ n = t.marks.map(e.markFromJSON);
688
696
  }
689
697
  if (t.type == "text") {
690
698
  if (typeof t.text != "string") throw RangeError("Invalid text node in JSON");
691
- return e.text(t.text, r);
699
+ return e.text(t.text, n);
692
700
  }
693
- let i = n.fromJSON(e, t.content), a = e.nodeType(t.type).create(t.attrs, i, r);
701
+ let r = i.fromJSON(e, t.content), a = e.nodeType(t.type).create(t.attrs, r, n);
694
702
  return a.type.checkAttrs(a.attrs), a;
695
703
  }
696
704
  };
697
- oe.prototype.text = void 0;
698
- function se(e, t) {
705
+ se.prototype.text = void 0;
706
+ function ce(e, t) {
699
707
  for (let n = e.length - 1; n >= 0; n--) t = e[n].type.name + "(" + t + ")";
700
708
  return t;
701
709
  }
702
- var x = class e {
710
+ var S = class e {
703
711
  constructor(e) {
704
712
  this.validEnd = e, this.next = [], this.wrapCache = [];
705
713
  }
706
714
  static parse(t, n) {
707
- let r = new ce(t, n);
715
+ let r = new le(t, n);
708
716
  if (r.next == null) return e.empty;
709
- let i = le(r);
717
+ let i = ue(r);
710
718
  r.next && r.err("Unexpected trailing text");
711
719
  let a = _e(ge(i));
712
720
  return ve(a, r), a;
@@ -734,15 +742,15 @@ var x = class e {
734
742
  for (let t = 0; t < this.next.length; t++) for (let n = 0; n < e.next.length; n++) if (this.next[t].type == e.next[n].type) return !0;
735
743
  return !1;
736
744
  }
737
- fillBefore(e, t = !1, r = 0) {
738
- let i = [this];
745
+ fillBefore(e, t = !1, n = 0) {
746
+ let r = [this];
739
747
  function a(o, s) {
740
- let c = o.matchFragment(e, r);
741
- if (c && (!t || c.validEnd)) return n.from(s.map((e) => e.createAndFill()));
748
+ let c = o.matchFragment(e, n);
749
+ if (c && (!t || c.validEnd)) return i.from(s.map((e) => e.createAndFill()));
742
750
  for (let e = 0; e < o.next.length; e++) {
743
751
  let { type: t, next: n } = o.next[e];
744
- if (!(t.isText || t.hasRequiredAttrs()) && i.indexOf(n) == -1) {
745
- i.push(n);
752
+ if (!(t.isText || t.hasRequiredAttrs()) && r.indexOf(n) == -1) {
753
+ r.push(n);
746
754
  let e = a(n, s.concat(t));
747
755
  if (e) return e;
748
756
  }
@@ -800,8 +808,8 @@ var x = class e {
800
808
  }).join("\n");
801
809
  }
802
810
  };
803
- x.empty = new x(!0);
804
- var ce = class {
811
+ S.empty = new S(!0);
812
+ var le = class {
805
813
  constructor(e, t) {
806
814
  this.string = e, this.nodeTypes = t, this.inline = null, this.pos = 0, this.tokens = e.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift();
807
815
  }
@@ -815,27 +823,27 @@ var ce = class {
815
823
  throw SyntaxError(e + " (in content expression '" + this.string + "')");
816
824
  }
817
825
  };
818
- function le(e) {
826
+ function ue(e) {
819
827
  let t = [];
820
828
  do
821
- t.push(ue(e));
829
+ t.push(de(e));
822
830
  while (e.eat("|"));
823
831
  return t.length == 1 ? t[0] : {
824
832
  type: "choice",
825
833
  exprs: t
826
834
  };
827
835
  }
828
- function ue(e) {
836
+ function de(e) {
829
837
  let t = [];
830
838
  do
831
- t.push(de(e));
839
+ t.push(fe(e));
832
840
  while (e.next && e.next != ")" && e.next != "|");
833
841
  return t.length == 1 ? t[0] : {
834
842
  type: "seq",
835
843
  exprs: t
836
844
  };
837
845
  }
838
- function de(e) {
846
+ function fe(e) {
839
847
  let t = he(e);
840
848
  for (;;) if (e.eat("+")) t = {
841
849
  type: "plus",
@@ -853,14 +861,14 @@ function de(e) {
853
861
  else break;
854
862
  return t;
855
863
  }
856
- function fe(e) {
864
+ function C(e) {
857
865
  /\D/.test(e.next) && e.err("Expected number, got '" + e.next + "'");
858
866
  let t = Number(e.next);
859
867
  return e.pos++, t;
860
868
  }
861
869
  function pe(e, t) {
862
- let n = fe(e), r = n;
863
- return e.eat(",") && (r = e.next == "}" ? -1 : fe(e)), e.eat("}") || e.err("Unclosed braced range"), {
870
+ let n = C(e), r = n;
871
+ return e.eat(",") && (r = e.next == "}" ? -1 : C(e)), e.eat("}") || e.err("Unclosed braced range"), {
864
872
  type: "range",
865
873
  min: n,
866
874
  max: r,
@@ -879,7 +887,7 @@ function me(e, t) {
879
887
  }
880
888
  function he(e) {
881
889
  if (e.eat("(")) {
882
- let t = le(e);
890
+ let t = ue(e);
883
891
  return e.eat(")") || e.err("Missing closing paren"), t;
884
892
  } else if (/\W/.test(e.next)) e.err("Unexpected token '" + e.next + "'");
885
893
  else {
@@ -939,12 +947,12 @@ function ge(e) {
939
947
  else throw Error("Unknown expr type");
940
948
  }
941
949
  }
942
- function S(e, t) {
950
+ function w(e, t) {
943
951
  return t - e;
944
952
  }
945
- function C(e, t) {
953
+ function T(e, t) {
946
954
  let n = [];
947
- return r(t), n.sort(S);
955
+ return r(t), n.sort(w);
948
956
  function r(t) {
949
957
  let i = e[t];
950
958
  if (i.length == 1 && !i[0].term) return r(i[0].to);
@@ -957,7 +965,7 @@ function C(e, t) {
957
965
  }
958
966
  function _e(e) {
959
967
  let t = Object.create(null);
960
- return n(C(e, 0));
968
+ return n(T(e, 0));
961
969
  function n(r) {
962
970
  let i = [];
963
971
  r.forEach((t) => {
@@ -965,14 +973,14 @@ function _e(e) {
965
973
  if (!t) return;
966
974
  let r;
967
975
  for (let e = 0; e < i.length; e++) i[e][0] == t && (r = i[e][1]);
968
- C(e, n).forEach((e) => {
976
+ T(e, n).forEach((e) => {
969
977
  r || i.push([t, r = []]), r.indexOf(e) == -1 && r.push(e);
970
978
  });
971
979
  });
972
980
  });
973
- let a = t[r.join(",")] = new x(r.indexOf(e.length - 1) > -1);
981
+ let a = t[r.join(",")] = new S(r.indexOf(e.length - 1) > -1);
974
982
  for (let e = 0; e < i.length; e++) {
975
- let r = i[e][1].sort(S);
983
+ let r = i[e][1].sort(w);
976
984
  a.next.push({
977
985
  type: i[e][0],
978
986
  next: t[r.join(",")] || n(r)
@@ -991,22 +999,22 @@ function ve(e, t) {
991
999
  i && t.err("Only non-generatable nodes (" + a.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
992
1000
  }
993
1001
  }
994
- var w = 65535, T = 2 ** 16;
1002
+ var E = 65535, D = 2 ** 16;
995
1003
  function ye(e, t) {
996
- return e + t * T;
1004
+ return e + t * D;
997
1005
  }
998
- function E(e) {
999
- return e & w;
1006
+ function O(e) {
1007
+ return e & E;
1000
1008
  }
1001
1009
  function be(e) {
1002
- return (e - (e & w)) / T;
1010
+ return (e - (e & E)) / D;
1003
1011
  }
1004
- var xe = 1, Se = 2, D = 4, O = 8, k = class {
1012
+ var xe = 1, Se = 2, k = 4, A = 8, j = class {
1005
1013
  constructor(e, t, n) {
1006
1014
  this.pos = e, this.delInfo = t, this.recover = n;
1007
1015
  }
1008
1016
  get deleted() {
1009
- return (this.delInfo & O) > 0;
1017
+ return (this.delInfo & A) > 0;
1010
1018
  }
1011
1019
  get deletedBefore() {
1012
1020
  return (this.delInfo & 5) > 0;
@@ -1015,14 +1023,14 @@ var xe = 1, Se = 2, D = 4, O = 8, k = class {
1015
1023
  return (this.delInfo & 6) > 0;
1016
1024
  }
1017
1025
  get deletedAcross() {
1018
- return (this.delInfo & D) > 0;
1026
+ return (this.delInfo & k) > 0;
1019
1027
  }
1020
- }, A = class e {
1028
+ }, M = class e {
1021
1029
  constructor(t, n = !1) {
1022
1030
  if (this.ranges = t, this.inverted = n, !t.length && e.empty) return e.empty;
1023
1031
  }
1024
1032
  recover(e) {
1025
- let t = 0, n = E(e);
1033
+ let t = 0, n = O(e);
1026
1034
  if (!this.inverted) for (let e = 0; e < n; e++) t += this.ranges[e * 3 + 2] - this.ranges[e * 3 + 1];
1027
1035
  return this.ranges[n * 3] + t + be(e);
1028
1036
  }
@@ -1041,15 +1049,15 @@ var xe = 1, Se = 2, D = 4, O = 8, k = class {
1041
1049
  if (e <= u) {
1042
1050
  let i = c ? e == s ? -1 : e == u ? 1 : t : t, a = s + r + (i < 0 ? 0 : l);
1043
1051
  if (n) return a;
1044
- let d = e == (t < 0 ? s : u) ? null : ye(o / 3, e - s), f = e == s ? Se : e == u ? xe : D;
1045
- return (t < 0 ? e != s : e != u) && (f |= O), new k(a, f, d);
1052
+ let d = e == (t < 0 ? s : u) ? null : ye(o / 3, e - s), f = e == s ? Se : e == u ? xe : k;
1053
+ return (t < 0 ? e != s : e != u) && (f |= A), new j(a, f, d);
1046
1054
  }
1047
1055
  r += l - c;
1048
1056
  }
1049
- return n ? e + r : new k(e + r, 0, null);
1057
+ return n ? e + r : new j(e + r, 0, null);
1050
1058
  }
1051
1059
  touches(e, t) {
1052
- let n = 0, r = E(t), i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
1060
+ let n = 0, r = O(t), i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
1053
1061
  for (let t = 0; t < this.ranges.length; t += 3) {
1054
1062
  let o = this.ranges[t] - (this.inverted ? n : 0);
1055
1063
  if (o > e) break;
@@ -1084,25 +1092,25 @@ var xe = 1, Se = 2, D = 4, O = 8, k = class {
1084
1092
  ]);
1085
1093
  }
1086
1094
  };
1087
- A.empty = new A([]);
1088
- var j = Object.create(null), M = class {
1095
+ M.empty = new M([]);
1096
+ var N = Object.create(null), P = class {
1089
1097
  getMap() {
1090
- return A.empty;
1098
+ return M.empty;
1091
1099
  }
1092
1100
  merge(e) {
1093
1101
  return null;
1094
1102
  }
1095
1103
  static fromJSON(e, t) {
1096
1104
  if (!t || !t.stepType) throw RangeError("Invalid input for Step.fromJSON");
1097
- let n = j[t.stepType];
1105
+ let n = N[t.stepType];
1098
1106
  if (!n) throw RangeError(`No step type ${t.stepType} defined`);
1099
1107
  return n.fromJSON(e, t);
1100
1108
  }
1101
1109
  static jsonID(e, t) {
1102
- if (e in j) throw RangeError("Duplicate use of step JSON ID " + e);
1103
- return j[e] = t, t.prototype.jsonID = e, t;
1110
+ if (e in N) throw RangeError("Duplicate use of step JSON ID " + e);
1111
+ return N[e] = t, t.prototype.jsonID = e, t;
1104
1112
  }
1105
- }, N = class e {
1113
+ }, F = class e {
1106
1114
  constructor(e, t) {
1107
1115
  this.doc = e, this.failed = t;
1108
1116
  }
@@ -1116,29 +1124,29 @@ var j = Object.create(null), M = class {
1116
1124
  try {
1117
1125
  return e.ok(t.replace(n, r, i));
1118
1126
  } catch (t) {
1119
- if (t instanceof s) return e.fail(t.message);
1127
+ if (t instanceof l) return e.fail(t.message);
1120
1128
  throw t;
1121
1129
  }
1122
1130
  }
1123
1131
  };
1124
- function P(e, t, r) {
1125
- let i = [];
1126
- for (let n = 0; n < e.childCount; n++) {
1127
- let a = e.child(n);
1128
- a.content.size && (a = a.copy(P(a.content, t, a))), a.isInline && (a = t(a, r, n)), i.push(a);
1132
+ function I(e, t, n) {
1133
+ let r = [];
1134
+ for (let i = 0; i < e.childCount; i++) {
1135
+ let a = e.child(i);
1136
+ a.content.size && (a = a.copy(I(a.content, t, a))), a.isInline && (a = t(a, n, i)), r.push(a);
1129
1137
  }
1130
- return n.fromArray(i);
1138
+ return i.fromArray(r);
1131
1139
  }
1132
- var F = class e extends M {
1140
+ var L = class e extends P {
1133
1141
  constructor(e, t, n) {
1134
1142
  super(), this.from = e, this.to = t, this.mark = n;
1135
1143
  }
1136
1144
  apply(e) {
1137
- let t = e.slice(this.from, this.to), n = e.resolve(this.from), r = n.node(n.sharedDepth(this.to)), i = new c(P(t.content, (e, t) => !e.isAtom || !t.type.allowsMarkType(this.mark.type) ? e : e.mark(this.mark.addToSet(e.marks)), r), t.openStart, t.openEnd);
1138
- return N.fromReplace(e, this.from, this.to, i);
1145
+ let t = e.slice(this.from, this.to), n = e.resolve(this.from), r = n.node(n.sharedDepth(this.to)), i = new u(I(t.content, (e, t) => !e.isAtom || !t.type.allowsMarkType(this.mark.type) ? e : e.mark(this.mark.addToSet(e.marks)), r), t.openStart, t.openEnd);
1146
+ return F.fromReplace(e, this.from, this.to, i);
1139
1147
  }
1140
1148
  invert() {
1141
- return new I(this.from, this.to, this.mark);
1149
+ return new R(this.from, this.to, this.mark);
1142
1150
  }
1143
1151
  map(t) {
1144
1152
  let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
@@ -1160,17 +1168,17 @@ var F = class e extends M {
1160
1168
  return new e(n.from, n.to, t.markFromJSON(n.mark));
1161
1169
  }
1162
1170
  };
1163
- M.jsonID("addMark", F);
1164
- var I = class e extends M {
1171
+ P.jsonID("addMark", L);
1172
+ var R = class e extends P {
1165
1173
  constructor(e, t, n) {
1166
1174
  super(), this.from = e, this.to = t, this.mark = n;
1167
1175
  }
1168
1176
  apply(e) {
1169
- let t = e.slice(this.from, this.to), n = new c(P(t.content, (e) => e.mark(this.mark.removeFromSet(e.marks)), e), t.openStart, t.openEnd);
1170
- return N.fromReplace(e, this.from, this.to, n);
1177
+ let t = e.slice(this.from, this.to), n = new u(I(t.content, (e) => e.mark(this.mark.removeFromSet(e.marks)), e), t.openStart, t.openEnd);
1178
+ return F.fromReplace(e, this.from, this.to, n);
1171
1179
  }
1172
1180
  invert() {
1173
- return new F(this.from, this.to, this.mark);
1181
+ return new L(this.from, this.to, this.mark);
1174
1182
  }
1175
1183
  map(t) {
1176
1184
  let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
@@ -1192,16 +1200,16 @@ var I = class e extends M {
1192
1200
  return new e(n.from, n.to, t.markFromJSON(n.mark));
1193
1201
  }
1194
1202
  };
1195
- M.jsonID("removeMark", I);
1196
- var L = class e extends M {
1203
+ P.jsonID("removeMark", R);
1204
+ var z = class e extends P {
1197
1205
  constructor(e, t) {
1198
1206
  super(), this.pos = e, this.mark = t;
1199
1207
  }
1200
1208
  apply(e) {
1201
1209
  let t = e.nodeAt(this.pos);
1202
- if (!t) return N.fail("No node at mark step's position");
1203
- let r = t.type.create(t.attrs, null, this.mark.addToSet(t.marks));
1204
- return N.fromReplace(e, this.pos, this.pos + 1, new c(n.from(r), 0, +!t.isLeaf));
1210
+ if (!t) return F.fail("No node at mark step's position");
1211
+ let n = t.type.create(t.attrs, null, this.mark.addToSet(t.marks));
1212
+ return F.fromReplace(e, this.pos, this.pos + 1, new u(i.from(n), 0, +!t.isLeaf));
1205
1213
  }
1206
1214
  invert(t) {
1207
1215
  let n = t.nodeAt(this.pos);
@@ -1212,7 +1220,7 @@ var L = class e extends M {
1212
1220
  return new e(this.pos, this.mark);
1213
1221
  }
1214
1222
  }
1215
- return new R(this.pos, this.mark);
1223
+ return new B(this.pos, this.mark);
1216
1224
  }
1217
1225
  map(t) {
1218
1226
  let n = t.mapResult(this.pos, 1);
@@ -1230,20 +1238,20 @@ var L = class e extends M {
1230
1238
  return new e(n.pos, t.markFromJSON(n.mark));
1231
1239
  }
1232
1240
  };
1233
- M.jsonID("addNodeMark", L);
1234
- var R = class e extends M {
1241
+ P.jsonID("addNodeMark", z);
1242
+ var B = class e extends P {
1235
1243
  constructor(e, t) {
1236
1244
  super(), this.pos = e, this.mark = t;
1237
1245
  }
1238
1246
  apply(e) {
1239
1247
  let t = e.nodeAt(this.pos);
1240
- if (!t) return N.fail("No node at mark step's position");
1241
- let r = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks));
1242
- return N.fromReplace(e, this.pos, this.pos + 1, new c(n.from(r), 0, +!t.isLeaf));
1248
+ if (!t) return F.fail("No node at mark step's position");
1249
+ let n = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks));
1250
+ return F.fromReplace(e, this.pos, this.pos + 1, new u(i.from(n), 0, +!t.isLeaf));
1243
1251
  }
1244
1252
  invert(e) {
1245
1253
  let t = e.nodeAt(this.pos);
1246
- return !t || !this.mark.isInSet(t.marks) ? this : new L(this.pos, this.mark);
1254
+ return !t || !this.mark.isInSet(t.marks) ? this : new z(this.pos, this.mark);
1247
1255
  }
1248
1256
  map(t) {
1249
1257
  let n = t.mapResult(this.pos, 1);
@@ -1261,16 +1269,16 @@ var R = class e extends M {
1261
1269
  return new e(n.pos, t.markFromJSON(n.mark));
1262
1270
  }
1263
1271
  };
1264
- M.jsonID("removeNodeMark", R);
1265
- var z = class e extends M {
1272
+ P.jsonID("removeNodeMark", B);
1273
+ var V = class e extends P {
1266
1274
  constructor(e, t, n, r = !1) {
1267
1275
  super(), this.from = e, this.to = t, this.slice = n, this.structure = r;
1268
1276
  }
1269
1277
  apply(e) {
1270
- return this.structure && V(e, this.from, this.to) ? N.fail("Structure replace would overwrite content") : N.fromReplace(e, this.from, this.to, this.slice);
1278
+ return this.structure && U(e, this.from, this.to) ? F.fail("Structure replace would overwrite content") : F.fromReplace(e, this.from, this.to, this.slice);
1271
1279
  }
1272
1280
  getMap() {
1273
- return new A([
1281
+ return new M([
1274
1282
  this.from,
1275
1283
  this.to - this.from,
1276
1284
  this.slice.size
@@ -1286,10 +1294,10 @@ var z = class e extends M {
1286
1294
  merge(t) {
1287
1295
  if (!(t instanceof e) || t.structure || this.structure) return null;
1288
1296
  if (this.from + this.slice.size == t.from && !this.slice.openEnd && !t.slice.openStart) {
1289
- let n = this.slice.size + t.slice.size == 0 ? c.empty : new c(this.slice.content.append(t.slice.content), this.slice.openStart, t.slice.openEnd);
1297
+ let n = this.slice.size + t.slice.size == 0 ? u.empty : new u(this.slice.content.append(t.slice.content), this.slice.openStart, t.slice.openEnd);
1290
1298
  return new e(this.from, this.to + (t.to - t.from), n, this.structure);
1291
1299
  } else if (t.to == this.from && !this.slice.openStart && !t.slice.openEnd) {
1292
- let n = this.slice.size + t.slice.size == 0 ? c.empty : new c(t.slice.content.append(this.slice.content), t.slice.openStart, this.slice.openEnd);
1300
+ let n = this.slice.size + t.slice.size == 0 ? u.empty : new u(t.slice.content.append(this.slice.content), t.slice.openStart, this.slice.openEnd);
1293
1301
  return new e(t.from, this.to, n, this.structure);
1294
1302
  } else return null;
1295
1303
  }
@@ -1303,23 +1311,23 @@ var z = class e extends M {
1303
1311
  }
1304
1312
  static fromJSON(t, n) {
1305
1313
  if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for ReplaceStep.fromJSON");
1306
- return new e(n.from, n.to, c.fromJSON(t, n.slice), !!n.structure);
1314
+ return new e(n.from, n.to, u.fromJSON(t, n.slice), !!n.structure);
1307
1315
  }
1308
1316
  };
1309
- M.jsonID("replace", z);
1310
- var B = class e extends M {
1317
+ P.jsonID("replace", V);
1318
+ var H = class e extends P {
1311
1319
  constructor(e, t, n, r, i, a, o = !1) {
1312
1320
  super(), this.from = e, this.to = t, this.gapFrom = n, this.gapTo = r, this.slice = i, this.insert = a, this.structure = o;
1313
1321
  }
1314
1322
  apply(e) {
1315
- if (this.structure && (V(e, this.from, this.gapFrom) || V(e, this.gapTo, this.to))) return N.fail("Structure gap-replace would overwrite content");
1323
+ if (this.structure && (U(e, this.from, this.gapFrom) || U(e, this.gapTo, this.to))) return F.fail("Structure gap-replace would overwrite content");
1316
1324
  let t = e.slice(this.gapFrom, this.gapTo);
1317
- if (t.openStart || t.openEnd) return N.fail("Gap is not a flat range");
1325
+ if (t.openStart || t.openEnd) return F.fail("Gap is not a flat range");
1318
1326
  let n = this.slice.insertAt(this.insert, t.content);
1319
- return n ? N.fromReplace(e, this.from, this.to, n) : N.fail("Content does not fit in gap");
1327
+ return n ? F.fromReplace(e, this.from, this.to, n) : F.fail("Content does not fit in gap");
1320
1328
  }
1321
1329
  getMap() {
1322
- return new A([
1330
+ return new M([
1323
1331
  this.from,
1324
1332
  this.gapFrom - this.from,
1325
1333
  this.insert,
@@ -1349,11 +1357,11 @@ var B = class e extends M {
1349
1357
  }
1350
1358
  static fromJSON(t, n) {
1351
1359
  if (typeof n.from != "number" || typeof n.to != "number" || typeof n.gapFrom != "number" || typeof n.gapTo != "number" || typeof n.insert != "number") throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");
1352
- return new e(n.from, n.to, n.gapFrom, n.gapTo, c.fromJSON(t, n.slice), n.insert, !!n.structure);
1360
+ return new e(n.from, n.to, n.gapFrom, n.gapTo, u.fromJSON(t, n.slice), n.insert, !!n.structure);
1353
1361
  }
1354
1362
  };
1355
- M.jsonID("replaceAround", B);
1356
- function V(e, t, n) {
1363
+ P.jsonID("replaceAround", H);
1364
+ function U(e, t, n) {
1357
1365
  let r = e.resolve(t), i = n - t, a = r.depth;
1358
1366
  for (; i > 0 && a > 0 && r.indexAfter(a) == r.node(a).childCount;) a--, i--;
1359
1367
  if (i > 0) {
@@ -1365,21 +1373,21 @@ function V(e, t, n) {
1365
1373
  }
1366
1374
  return !1;
1367
1375
  }
1368
- var Ce = class e extends M {
1376
+ var Ce = class e extends P {
1369
1377
  constructor(e, t, n) {
1370
1378
  super(), this.pos = e, this.attr = t, this.value = n;
1371
1379
  }
1372
1380
  apply(e) {
1373
1381
  let t = e.nodeAt(this.pos);
1374
- if (!t) return N.fail("No node at attribute step's position");
1375
- let r = Object.create(null);
1376
- for (let e in t.attrs) r[e] = t.attrs[e];
1377
- r[this.attr] = this.value;
1378
- let i = t.type.create(r, null, t.marks);
1379
- return N.fromReplace(e, this.pos, this.pos + 1, new c(n.from(i), 0, +!t.isLeaf));
1382
+ if (!t) return F.fail("No node at attribute step's position");
1383
+ let n = Object.create(null);
1384
+ for (let e in t.attrs) n[e] = t.attrs[e];
1385
+ n[this.attr] = this.value;
1386
+ let r = t.type.create(n, null, t.marks);
1387
+ return F.fromReplace(e, this.pos, this.pos + 1, new u(i.from(r), 0, +!t.isLeaf));
1380
1388
  }
1381
1389
  getMap() {
1382
- return A.empty;
1390
+ return M.empty;
1383
1391
  }
1384
1392
  invert(t) {
1385
1393
  return new e(this.pos, this.attr, t.nodeAt(this.pos).attrs[this.attr]);
@@ -1401,8 +1409,8 @@ var Ce = class e extends M {
1401
1409
  return new e(n.pos, n.attr, n.value);
1402
1410
  }
1403
1411
  };
1404
- M.jsonID("attr", Ce);
1405
- var we = class e extends M {
1412
+ P.jsonID("attr", Ce);
1413
+ var we = class e extends P {
1406
1414
  constructor(e, t) {
1407
1415
  super(), this.attr = e, this.value = t;
1408
1416
  }
@@ -1411,10 +1419,10 @@ var we = class e extends M {
1411
1419
  for (let n in e.attrs) t[n] = e.attrs[n];
1412
1420
  t[this.attr] = this.value;
1413
1421
  let n = e.type.create(t, e.content, e.marks);
1414
- return N.ok(n);
1422
+ return F.ok(n);
1415
1423
  }
1416
1424
  getMap() {
1417
- return A.empty;
1425
+ return M.empty;
1418
1426
  }
1419
1427
  invert(t) {
1420
1428
  return new e(this.attr, t.attrs[this.attr]);
@@ -1434,13 +1442,13 @@ var we = class e extends M {
1434
1442
  return new e(n.attr, n.value);
1435
1443
  }
1436
1444
  };
1437
- M.jsonID("docAttr", we);
1438
- var H = class extends Error {};
1439
- H = function e(t) {
1445
+ P.jsonID("docAttr", we);
1446
+ var W = class extends Error {};
1447
+ W = function e(t) {
1440
1448
  let n = Error.call(this, t);
1441
1449
  return n.__proto__ = e.prototype, n;
1442
- }, H.prototype = Object.create(Error.prototype), H.prototype.constructor = H, H.prototype.name = "TransformError";
1443
- var U = Object.create(null), W = class {
1450
+ }, W.prototype = Object.create(Error.prototype), W.prototype.constructor = W, W.prototype.name = "TransformError";
1451
+ var G = Object.create(null), K = class {
1444
1452
  constructor(e, t, n) {
1445
1453
  this.$anchor = e, this.$head = t, this.ranges = n || [new Te(e.min(t), e.max(t))];
1446
1454
  }
@@ -1470,64 +1478,64 @@ var U = Object.create(null), W = class {
1470
1478
  content() {
1471
1479
  return this.$from.doc.slice(this.from, this.to, !0);
1472
1480
  }
1473
- replace(e, t = c.empty) {
1481
+ replace(e, t = u.empty) {
1474
1482
  let n = t.content.lastChild, r = null;
1475
1483
  for (let e = 0; e < t.openEnd; e++) r = n, n = n.lastChild;
1476
1484
  let i = e.steps.length, a = this.ranges;
1477
1485
  for (let o = 0; o < a.length; o++) {
1478
- let { $from: s, $to: l } = a[o], u = e.mapping.slice(i);
1479
- e.replaceRange(u.map(s.pos), u.map(l.pos), o ? c.empty : t), o == 0 && ke(e, i, (n ? n.isInline : r && r.isTextblock) ? -1 : 1);
1486
+ let { $from: s, $to: c } = a[o], l = e.mapping.slice(i);
1487
+ e.replaceRange(l.map(s.pos), l.map(c.pos), o ? u.empty : t), o == 0 && Ae(e, i, (n ? n.isInline : r && r.isTextblock) ? -1 : 1);
1480
1488
  }
1481
1489
  }
1482
1490
  replaceWith(e, t) {
1483
1491
  let n = e.steps.length, r = this.ranges;
1484
1492
  for (let i = 0; i < r.length; i++) {
1485
1493
  let { $from: a, $to: o } = r[i], s = e.mapping.slice(n), c = s.map(a.pos), l = s.map(o.pos);
1486
- i ? e.deleteRange(c, l) : (e.replaceRangeWith(c, l, t), ke(e, n, t.isInline ? -1 : 1));
1494
+ i ? e.deleteRange(c, l) : (e.replaceRangeWith(c, l, t), Ae(e, n, t.isInline ? -1 : 1));
1487
1495
  }
1488
1496
  }
1489
1497
  static findFrom(e, t, n = !1) {
1490
- let r = e.parent.inlineContent ? new K(e) : X(e.node(0), e.parent, e.pos, e.index(), t, n);
1498
+ let r = e.parent.inlineContent ? new J(e) : Z(e.node(0), e.parent, e.pos, e.index(), t, n);
1491
1499
  if (r) return r;
1492
1500
  for (let r = e.depth - 1; r >= 0; r--) {
1493
- let i = t < 0 ? X(e.node(0), e.node(r), e.before(r + 1), e.index(r), t, n) : X(e.node(0), e.node(r), e.after(r + 1), e.index(r) + 1, t, n);
1501
+ let i = t < 0 ? Z(e.node(0), e.node(r), e.before(r + 1), e.index(r), t, n) : Z(e.node(0), e.node(r), e.after(r + 1), e.index(r) + 1, t, n);
1494
1502
  if (i) return i;
1495
1503
  }
1496
1504
  return null;
1497
1505
  }
1498
1506
  static near(e, t = 1) {
1499
- return this.findFrom(e, t) || this.findFrom(e, -t) || new Y(e.node(0));
1507
+ return this.findFrom(e, t) || this.findFrom(e, -t) || new X(e.node(0));
1500
1508
  }
1501
1509
  static atStart(e) {
1502
- return X(e, e, 0, 0, 1) || new Y(e);
1510
+ return Z(e, e, 0, 0, 1) || new X(e);
1503
1511
  }
1504
1512
  static atEnd(e) {
1505
- return X(e, e, e.content.size, e.childCount, -1) || new Y(e);
1513
+ return Z(e, e, e.content.size, e.childCount, -1) || new X(e);
1506
1514
  }
1507
1515
  static fromJSON(e, t) {
1508
1516
  if (!t || !t.type) throw RangeError("Invalid input for Selection.fromJSON");
1509
- let n = U[t.type];
1517
+ let n = G[t.type];
1510
1518
  if (!n) throw RangeError(`No selection type ${t.type} defined`);
1511
1519
  return n.fromJSON(e, t);
1512
1520
  }
1513
1521
  static jsonID(e, t) {
1514
- if (e in U) throw RangeError("Duplicate use of selection JSON ID " + e);
1515
- return U[e] = t, t.prototype.jsonID = e, t;
1522
+ if (e in G) throw RangeError("Duplicate use of selection JSON ID " + e);
1523
+ return G[e] = t, t.prototype.jsonID = e, t;
1516
1524
  }
1517
1525
  getBookmark() {
1518
- return K.between(this.$anchor, this.$head).getBookmark();
1526
+ return J.between(this.$anchor, this.$head).getBookmark();
1519
1527
  }
1520
1528
  };
1521
- W.prototype.visible = !0;
1529
+ K.prototype.visible = !0;
1522
1530
  var Te = class {
1523
1531
  constructor(e, t) {
1524
1532
  this.$from = e, this.$to = t;
1525
1533
  }
1526
- }, G = !1;
1534
+ }, q = !1;
1527
1535
  function Ee(e) {
1528
- !G && !e.parent.inlineContent && (G = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + e.parent.type.name + ")"));
1536
+ !q && !e.parent.inlineContent && (q = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + e.parent.type.name + ")"));
1529
1537
  }
1530
- var K = class e extends W {
1538
+ var J = class e extends K {
1531
1539
  constructor(e, t = e) {
1532
1540
  Ee(e), Ee(t), super(e, t);
1533
1541
  }
@@ -1536,12 +1544,12 @@ var K = class e extends W {
1536
1544
  }
1537
1545
  map(t, n) {
1538
1546
  let r = t.resolve(n.map(this.head));
1539
- if (!r.parent.inlineContent) return W.near(r);
1547
+ if (!r.parent.inlineContent) return K.near(r);
1540
1548
  let i = t.resolve(n.map(this.anchor));
1541
1549
  return new e(i.parent.inlineContent ? i : r, r);
1542
1550
  }
1543
- replace(e, t = c.empty) {
1544
- if (super.replace(e, t), t == c.empty) {
1551
+ replace(e, t = u.empty) {
1552
+ if (super.replace(e, t), t == u.empty) {
1545
1553
  let t = this.$from.marksAcross(this.$to);
1546
1554
  t && e.ensureMarks(t);
1547
1555
  }
@@ -1550,7 +1558,7 @@ var K = class e extends W {
1550
1558
  return t instanceof e && t.anchor == this.anchor && t.head == this.head;
1551
1559
  }
1552
1560
  getBookmark() {
1553
- return new q(this.anchor, this.head);
1561
+ return new De(this.anchor, this.head);
1554
1562
  }
1555
1563
  toJSON() {
1556
1564
  return {
@@ -1570,15 +1578,15 @@ var K = class e extends W {
1570
1578
  static between(t, n, r) {
1571
1579
  let i = t.pos - n.pos;
1572
1580
  if ((!r || i) && (r = i >= 0 ? 1 : -1), !n.parent.inlineContent) {
1573
- let e = W.findFrom(n, r, !0) || W.findFrom(n, -r, !0);
1581
+ let e = K.findFrom(n, r, !0) || K.findFrom(n, -r, !0);
1574
1582
  if (e) n = e.$head;
1575
- else return W.near(n, r);
1583
+ else return K.near(n, r);
1576
1584
  }
1577
- return t.parent.inlineContent || (i == 0 ? t = n : (t = (W.findFrom(t, -r, !0) || W.findFrom(t, r, !0)).$anchor, t.pos < n.pos != i < 0 && (t = n))), new e(t, n);
1585
+ return t.parent.inlineContent || (i == 0 ? t = n : (t = (K.findFrom(t, -r, !0) || K.findFrom(t, r, !0)).$anchor, t.pos < n.pos != i < 0 && (t = n))), new e(t, n);
1578
1586
  }
1579
1587
  };
1580
- W.jsonID("text", K);
1581
- var q = class e {
1588
+ K.jsonID("text", J);
1589
+ var De = class e {
1582
1590
  constructor(e, t) {
1583
1591
  this.anchor = e, this.head = t;
1584
1592
  }
@@ -1586,19 +1594,19 @@ var q = class e {
1586
1594
  return new e(t.map(this.anchor), t.map(this.head));
1587
1595
  }
1588
1596
  resolve(e) {
1589
- return K.between(e.resolve(this.anchor), e.resolve(this.head));
1597
+ return J.between(e.resolve(this.anchor), e.resolve(this.head));
1590
1598
  }
1591
- }, J = class e extends W {
1599
+ }, Y = class e extends K {
1592
1600
  constructor(e) {
1593
1601
  let t = e.nodeAfter, n = e.node(0).resolve(e.pos + t.nodeSize);
1594
1602
  super(e, n), this.node = t;
1595
1603
  }
1596
1604
  map(t, n) {
1597
1605
  let { deleted: r, pos: i } = n.mapResult(this.anchor), a = t.resolve(i);
1598
- return r ? W.near(a) : new e(a);
1606
+ return r ? K.near(a) : new e(a);
1599
1607
  }
1600
1608
  content() {
1601
- return new c(n.from(this.node), 0, 0);
1609
+ return new u(i.from(this.node), 0, 0);
1602
1610
  }
1603
1611
  eq(t) {
1604
1612
  return t instanceof e && t.anchor == this.anchor;
@@ -1610,7 +1618,7 @@ var q = class e {
1610
1618
  };
1611
1619
  }
1612
1620
  getBookmark() {
1613
- return new De(this.anchor);
1621
+ return new Oe(this.anchor);
1614
1622
  }
1615
1623
  static fromJSON(t, n) {
1616
1624
  if (typeof n.anchor != "number") throw RangeError("Invalid input for NodeSelection.fromJSON");
@@ -1623,27 +1631,27 @@ var q = class e {
1623
1631
  return !e.isText && e.type.spec.selectable !== !1;
1624
1632
  }
1625
1633
  };
1626
- J.prototype.visible = !1, W.jsonID("node", J);
1627
- var De = class e {
1634
+ Y.prototype.visible = !1, K.jsonID("node", Y);
1635
+ var Oe = class e {
1628
1636
  constructor(e) {
1629
1637
  this.anchor = e;
1630
1638
  }
1631
1639
  map(t) {
1632
1640
  let { deleted: n, pos: r } = t.mapResult(this.anchor);
1633
- return n ? new q(r, r) : new e(r);
1641
+ return n ? new De(r, r) : new e(r);
1634
1642
  }
1635
1643
  resolve(e) {
1636
1644
  let t = e.resolve(this.anchor), n = t.nodeAfter;
1637
- return n && J.isSelectable(n) ? new J(t) : W.near(t);
1645
+ return n && Y.isSelectable(n) ? new Y(t) : K.near(t);
1638
1646
  }
1639
- }, Y = class e extends W {
1647
+ }, X = class e extends K {
1640
1648
  constructor(e) {
1641
1649
  super(e.resolve(0), e.resolve(e.content.size));
1642
1650
  }
1643
- replace(e, t = c.empty) {
1644
- if (t == c.empty) {
1651
+ replace(e, t = u.empty) {
1652
+ if (t == u.empty) {
1645
1653
  e.delete(0, e.doc.content.size);
1646
- let t = W.atStart(e.doc);
1654
+ let t = K.atStart(e.doc);
1647
1655
  t.eq(e.selection) || e.setSelection(t);
1648
1656
  } else super.replace(e, t);
1649
1657
  }
@@ -1660,46 +1668,46 @@ var De = class e {
1660
1668
  return t instanceof e;
1661
1669
  }
1662
1670
  getBookmark() {
1663
- return Oe;
1671
+ return ke;
1664
1672
  }
1665
1673
  };
1666
- W.jsonID("all", Y);
1667
- var Oe = {
1674
+ K.jsonID("all", X);
1675
+ var ke = {
1668
1676
  map() {
1669
1677
  return this;
1670
1678
  },
1671
1679
  resolve(e) {
1672
- return new Y(e);
1680
+ return new X(e);
1673
1681
  }
1674
1682
  };
1675
- function X(e, t, n, r, i, a = !1) {
1676
- if (t.inlineContent) return K.create(e, n);
1683
+ function Z(e, t, n, r, i, a = !1) {
1684
+ if (t.inlineContent) return J.create(e, n);
1677
1685
  for (let o = r - (i > 0 ? 0 : 1); i > 0 ? o < t.childCount : o >= 0; o += i) {
1678
1686
  let r = t.child(o);
1679
1687
  if (!r.isAtom) {
1680
- let t = X(e, r, n + i, i < 0 ? r.childCount : 0, i, a);
1688
+ let t = Z(e, r, n + i, i < 0 ? r.childCount : 0, i, a);
1681
1689
  if (t) return t;
1682
- } else if (!a && J.isSelectable(r)) return J.create(e, n - (i < 0 ? r.nodeSize : 0));
1690
+ } else if (!a && Y.isSelectable(r)) return Y.create(e, n - (i < 0 ? r.nodeSize : 0));
1683
1691
  n += r.nodeSize * i;
1684
1692
  }
1685
1693
  return null;
1686
1694
  }
1687
- function ke(e, t, n) {
1695
+ function Ae(e, t, n) {
1688
1696
  let r = e.steps.length - 1;
1689
1697
  if (r < t) return;
1690
1698
  let i = e.steps[r];
1691
- if (!(i instanceof z || i instanceof B)) return;
1699
+ if (!(i instanceof V || i instanceof H)) return;
1692
1700
  let a = e.mapping.maps[r], o;
1693
1701
  a.forEach((e, t, n, r) => {
1694
1702
  o ??= r;
1695
- }), e.setSelection(W.near(e.doc.resolve(o), n));
1703
+ }), e.setSelection(K.near(e.doc.resolve(o), n));
1696
1704
  }
1697
- function Z(e, t) {
1705
+ function je(e, t) {
1698
1706
  return !t || !e ? e : e.bind(t);
1699
1707
  }
1700
1708
  var Q = class {
1701
1709
  constructor(e, t, n) {
1702
- this.name = e, this.init = Z(t.init, n), this.apply = Z(t.apply, n);
1710
+ this.name = e, this.init = je(t.init, n), this.apply = je(t.apply, n);
1703
1711
  }
1704
1712
  };
1705
1713
  new Q("doc", {
@@ -1711,7 +1719,7 @@ new Q("doc", {
1711
1719
  }
1712
1720
  }), new Q("selection", {
1713
1721
  init(e, t) {
1714
- return e.selection || W.atStart(t.doc);
1722
+ return e.selection || K.atStart(t.doc);
1715
1723
  },
1716
1724
  apply(e) {
1717
1725
  return e.selection;
@@ -1732,12 +1740,12 @@ new Q("doc", {
1732
1740
  }
1733
1741
  });
1734
1742
  var $ = Object.create(null);
1735
- function Ae(e) {
1743
+ function Me(e) {
1736
1744
  return e in $ ? e + "$" + ++$[e] : ($[e] = 0, e + "$");
1737
1745
  }
1738
- var je = class {
1746
+ var Ne = class {
1739
1747
  constructor(e = "key") {
1740
- this.key = Ae(e);
1748
+ this.key = Me(e);
1741
1749
  }
1742
1750
  get(e) {
1743
1751
  return e.config.pluginsByKey[this.key];
@@ -1746,4 +1754,4 @@ var je = class {
1746
1754
  return e[this.key];
1747
1755
  }
1748
1756
  };
1749
- export { je as t };
1757
+ export { Ne as t };