@vscode/markdown-editor 0.0.2-5 → 0.0.2-6

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.
package/dist/index.js CHANGED
@@ -1,26 +1,26 @@
1
- import { parse as en, preprocess as tn, postprocess as nn } from "micromark";
2
- import { math as sn } from "micromark-extension-math";
3
- import { gfmTable as rn } from "micromark-extension-gfm-table";
4
- import { gfmTaskListItem as on } from "micromark-extension-gfm-task-list-item";
5
- import { gfmStrikethrough as cn } from "micromark-extension-gfm-strikethrough";
6
- import { o as U, d as V, D as le, t as ln, r as an, a as ee, c as hn } from "./runOnChange-C00UIwqQ.js";
7
- import It from "katex";
8
- class w {
1
+ import { parse as ln, preprocess as hn, postprocess as dn } from "micromark";
2
+ import { math as un } from "micromark-extension-math";
3
+ import { gfmTable as fn } from "micromark-extension-gfm-table";
4
+ import { gfmTaskListItem as gn } from "micromark-extension-gfm-task-list-item";
5
+ import { gfmStrikethrough as pn } from "micromark-extension-gfm-strikethrough";
6
+ import { o as B, d as $, D as se, t as mn, r as _n, a as G, c as wn } from "./runOnChange-C00UIwqQ.js";
7
+ import $t from "katex";
8
+ class _ {
9
9
  constructor(e, t) {
10
10
  if (this.start = e, this.endExclusive = t, e > t)
11
11
  throw new Error(`Invalid range: [${e}, ${t})`);
12
12
  }
13
13
  static fromTo(e, t) {
14
- return new w(e, t);
14
+ return new _(e, t);
15
15
  }
16
16
  static ofLength(e) {
17
- return new w(0, e);
17
+ return new _(0, e);
18
18
  }
19
19
  static ofStartAndLength(e, t) {
20
- return new w(e, e + t);
20
+ return new _(e, e + t);
21
21
  }
22
22
  static emptyAt(e) {
23
- return new w(e, e);
23
+ return new _(e, e);
24
24
  }
25
25
  get isEmpty() {
26
26
  return this.start === this.endExclusive;
@@ -29,13 +29,13 @@ class w {
29
29
  return this.endExclusive - this.start;
30
30
  }
31
31
  delta(e) {
32
- return new w(this.start + e, this.endExclusive + e);
32
+ return new _(this.start + e, this.endExclusive + e);
33
33
  }
34
34
  deltaStart(e) {
35
- return new w(this.start + e, this.endExclusive);
35
+ return new _(this.start + e, this.endExclusive);
36
36
  }
37
37
  deltaEnd(e) {
38
- return new w(this.start, this.endExclusive + e);
38
+ return new _(this.start, this.endExclusive + e);
39
39
  }
40
40
  contains(e) {
41
41
  return this.start <= e && e < this.endExclusive;
@@ -52,10 +52,10 @@ class w {
52
52
  intersect(e) {
53
53
  const t = Math.max(this.start, e.start), s = Math.min(this.endExclusive, e.endExclusive);
54
54
  if (t <= s)
55
- return new w(t, s);
55
+ return new _(t, s);
56
56
  }
57
57
  join(e) {
58
- return new w(
58
+ return new _(
59
59
  Math.min(this.start, e.start),
60
60
  Math.max(this.endExclusive, e.endExclusive)
61
61
  );
@@ -79,18 +79,18 @@ class w {
79
79
  return `[${this.start}, ${this.endExclusive})`;
80
80
  }
81
81
  }
82
- class q {
82
+ class j {
83
83
  constructor(e, t) {
84
84
  this.replaceRange = e, this.newText = t;
85
85
  }
86
86
  static insert(e, t) {
87
- return new q(w.emptyAt(e), t);
87
+ return new j(_.emptyAt(e), t);
88
88
  }
89
89
  static replace(e, t) {
90
- return new q(e, t);
90
+ return new j(e, t);
91
91
  }
92
92
  static delete(e) {
93
- return new q(e, "");
93
+ return new j(e, "");
94
94
  }
95
95
  get isEmpty() {
96
96
  return this.replaceRange.isEmpty && this.newText.length === 0;
@@ -102,19 +102,19 @@ class q {
102
102
  return `${this.replaceRange} -> ${JSON.stringify(this.newText)}`;
103
103
  }
104
104
  }
105
- class E {
106
- static empty = new E([]);
105
+ class b {
106
+ static empty = new b([]);
107
107
  static single(e) {
108
- return new E([e]);
108
+ return new b([e]);
109
109
  }
110
110
  static replace(e, t) {
111
- return new E([q.replace(e, t)]);
111
+ return new b([j.replace(e, t)]);
112
112
  }
113
113
  static insert(e, t) {
114
- return new E([q.insert(e, t)]);
114
+ return new b([j.insert(e, t)]);
115
115
  }
116
116
  static delete(e) {
117
- return new E([q.delete(e)]);
117
+ return new b([j.delete(e)]);
118
118
  }
119
119
  replacements;
120
120
  constructor(e) {
@@ -144,13 +144,13 @@ class E {
144
144
  for (const i of this.replacements) {
145
145
  const r = e.substring(i.replaceRange.start, i.replaceRange.endExclusive);
146
146
  t.push(
147
- q.replace(
148
- w.ofStartAndLength(i.replaceRange.start + s, i.newText.length),
147
+ j.replace(
148
+ _.ofStartAndLength(i.replaceRange.start + s, i.newText.length),
149
149
  r
150
150
  )
151
151
  ), s += i.newText.length - i.replaceRange.length;
152
152
  }
153
- return new E(t);
153
+ return new b(t);
154
154
  }
155
155
  equals(e) {
156
156
  if (this.replacements.length !== e.replacements.length)
@@ -176,13 +176,13 @@ class E {
176
176
  return `[${this.replacements.map((e) => e.toString()).join(", ")}]`;
177
177
  }
178
178
  }
179
- class Ae {
179
+ class Pe {
180
180
  constructor(e, t) {
181
181
  if (this.replaceRange = e, this.newLength = t, t < 0)
182
182
  throw new Error(`newLength must be non-negative, got ${t}`);
183
183
  }
184
184
  static replace(e, t) {
185
- return new Ae(e, t);
185
+ return new Pe(e, t);
186
186
  }
187
187
  get lengthDelta() {
188
188
  return this.newLength - this.replaceRange.length;
@@ -194,13 +194,13 @@ class Ae {
194
194
  return `${this.replaceRange} -> +${this.newLength}`;
195
195
  }
196
196
  }
197
- class ie {
198
- static empty = new ie([]);
197
+ class oe {
198
+ static empty = new oe([]);
199
199
  static single(e) {
200
- return new ie([e]);
200
+ return new oe([e]);
201
201
  }
202
202
  static replace(e, t) {
203
- return new ie([Ae.replace(e, t)]);
203
+ return new oe([Pe.replace(e, t)]);
204
204
  }
205
205
  replacements;
206
206
  constructor(e) {
@@ -227,7 +227,7 @@ class ie {
227
227
  return this.isEmpty ? "LengthEdit.empty" : this.replacements.join(", ");
228
228
  }
229
229
  }
230
- class Le {
230
+ class ye {
231
231
  constructor(e) {
232
232
  this.value = e;
233
233
  }
@@ -241,12 +241,12 @@ class Le {
241
241
  return this.value;
242
242
  }
243
243
  }
244
- class x {
244
+ class k {
245
245
  constructor(e, t) {
246
246
  this.anchor = e, this.active = t;
247
247
  }
248
248
  static collapsed(e) {
249
- return new x(e, e);
249
+ return new k(e, e);
250
250
  }
251
251
  get isCollapsed() {
252
252
  return this.anchor === this.active;
@@ -255,34 +255,34 @@ class x {
255
255
  return this.active >= this.anchor;
256
256
  }
257
257
  get range() {
258
- return this.isForward ? new w(this.anchor, this.active) : new w(this.active, this.anchor);
258
+ return this.isForward ? new _(this.anchor, this.active) : new _(this.active, this.anchor);
259
259
  }
260
260
  collapseToActive() {
261
- return x.collapsed(this.active);
261
+ return k.collapsed(this.active);
262
262
  }
263
263
  withActive(e) {
264
- return new x(this.anchor, e);
264
+ return new k(this.anchor, e);
265
265
  }
266
266
  }
267
- class re {
267
+ class ae {
268
268
  constructor(e, t) {
269
269
  this.x = e, this.y = t;
270
270
  }
271
- static ZERO = new re(0, 0);
271
+ static ZERO = new ae(0, 0);
272
272
  translate(e, t) {
273
- return new re(this.x + e, this.y + t);
273
+ return new ae(this.x + e, this.y + t);
274
274
  }
275
275
  }
276
- class B {
276
+ class D {
277
277
  constructor(e, t, s, i) {
278
278
  this.x = e, this.y = t, this.width = s, this.height = i;
279
279
  }
280
- static EMPTY = new B(0, 0, 0, 0);
280
+ static EMPTY = new D(0, 0, 0, 0);
281
281
  static fromPointPoint(e, t, s, i) {
282
- return new B(e, t, s - e, i - t);
282
+ return new D(e, t, s - e, i - t);
283
283
  }
284
284
  static fromPointSize(e, t, s, i) {
285
- return new B(e, t, s, i);
285
+ return new D(e, t, s, i);
286
286
  }
287
287
  get left() {
288
288
  return this.x;
@@ -297,7 +297,7 @@ class B {
297
297
  return this.y + this.height;
298
298
  }
299
299
  get topLeft() {
300
- return new re(this.x, this.y);
300
+ return new ae(this.x, this.y);
301
301
  }
302
302
  containsX(e) {
303
303
  return e >= this.left && e < this.right;
@@ -310,13 +310,13 @@ class B {
310
310
  }
311
311
  /** Same y/height, zero-width band at `x = this.left`. Useful for caret rects derived from a line. */
312
312
  withZeroWidthAt(e) {
313
- return new B(e, this.y, 0, this.height);
313
+ return new D(e, this.y, 0, this.height);
314
314
  }
315
315
  translate(e, t) {
316
- return new B(this.x + e, this.y + t, this.width, this.height);
316
+ return new D(this.x + e, this.y + t, this.width, this.height);
317
317
  }
318
318
  }
319
- function Nt(n, e) {
319
+ function At(n, e) {
320
320
  if (e <= 0)
321
321
  return 0;
322
322
  let t = e - 1;
@@ -330,7 +330,7 @@ function Nt(n, e) {
330
330
  t--;
331
331
  return t;
332
332
  }
333
- function Rt(n, e) {
333
+ function Pt(n, e) {
334
334
  const t = n.length;
335
335
  if (e >= t)
336
336
  return t;
@@ -345,7 +345,7 @@ function Rt(n, e) {
345
345
  s++;
346
346
  return s;
347
347
  }
348
- function dn(n, e) {
348
+ function kn(n, e) {
349
349
  if (e >= n.length)
350
350
  return { start: n.length, end: n.length };
351
351
  const t = n[e];
@@ -372,14 +372,14 @@ function dn(n, e) {
372
372
  i++;
373
373
  return { start: s, end: i };
374
374
  }
375
- let un = 1;
375
+ let vn = 1;
376
376
  class N {
377
377
  /**
378
378
  * A stable identity. Every node has one: it is minted on construction and
379
379
  * carried across edits by reconciliation, so a node that survives an edit
380
380
  * (even with changed content) keeps the same id.
381
381
  */
382
- id = un++;
382
+ id = vn++;
383
383
  _length = -1;
384
384
  get length() {
385
385
  if (this._length < 0) {
@@ -424,7 +424,7 @@ class N {
424
424
  return Object.assign(t, this), t.id = e, t;
425
425
  }
426
426
  }
427
- const fn = [];
427
+ const xn = [];
428
428
  function O(n, e) {
429
429
  let t;
430
430
  for (let s = 0; s < e.length; s++) {
@@ -433,16 +433,16 @@ function O(n, e) {
433
433
  }
434
434
  return t ?? e;
435
435
  }
436
- function P(n, e) {
436
+ function K(n, e) {
437
437
  const t = n.get(e);
438
438
  return t && t !== e ? t : e;
439
439
  }
440
- function Z(n, e) {
441
- return e ? P(n, e) : void 0;
440
+ function ee(n, e) {
441
+ return e ? K(n, e) : void 0;
442
442
  }
443
- class Te extends N {
443
+ class Se extends N {
444
444
  get children() {
445
- return fn;
445
+ return xn;
446
446
  }
447
447
  get length() {
448
448
  return this.content.length;
@@ -451,7 +451,7 @@ class Te extends N {
451
451
  return this;
452
452
  }
453
453
  }
454
- class Ee extends Te {
454
+ class pe extends Se {
455
455
  constructor(e) {
456
456
  super(), this.content = e;
457
457
  }
@@ -460,7 +460,7 @@ class Ee extends Te {
460
460
  return this.content === e.content;
461
461
  }
462
462
  }
463
- class k extends Te {
463
+ class v extends Se {
464
464
  constructor(e, t) {
465
465
  super(), this.markerKind = e, this.content = t;
466
466
  }
@@ -469,7 +469,7 @@ class k extends Te {
469
469
  return this.markerKind === e.markerKind && this.content === e.content;
470
470
  }
471
471
  }
472
- class R extends Te {
472
+ class I extends Se {
473
473
  constructor(e, t) {
474
474
  super(), this.content = e, this.glueKind = t;
475
475
  }
@@ -478,13 +478,13 @@ class R extends Te {
478
478
  return this.content === e.content && this.glueKind === e.glueKind;
479
479
  }
480
480
  }
481
- class z extends N {
481
+ class Q extends N {
482
482
  /** Prepends {@link leadingTrivia}, if any, ahead of the block's own children. */
483
483
  _withLeading(e) {
484
484
  return this.leadingTrivia ? [this.leadingTrivia, ...e] : e;
485
485
  }
486
486
  }
487
- class te extends z {
487
+ class te extends Q {
488
488
  constructor(e, t) {
489
489
  super(), this.content = e, this.leadingTrivia = t;
490
490
  }
@@ -493,19 +493,19 @@ class te extends z {
493
493
  return this._withLeading(this.content);
494
494
  }
495
495
  get marker() {
496
- return ue(this.content, "content");
496
+ return fe(this.content, "content");
497
497
  }
498
498
  mapChildren(e) {
499
- return new te(O(e, this.content), Z(e, this.leadingTrivia));
499
+ return new te(O(e, this.content), ee(e, this.leadingTrivia));
500
500
  }
501
501
  withLeadingTrivia(e) {
502
502
  return new te(this.content, e);
503
503
  }
504
504
  }
505
- function ue(n, e) {
506
- return n.find((t) => t instanceof k && t.markerKind === e);
505
+ function fe(n, e) {
506
+ return n.find((t) => t instanceof v && t.markerKind === e);
507
507
  }
508
- class $e extends N {
508
+ class Fe extends N {
509
509
  constructor(e, t, s) {
510
510
  super(), this.openMarker = e, this.content = t, this.closeMarker = s;
511
511
  }
@@ -514,10 +514,10 @@ class $e extends N {
514
514
  return [this.openMarker, ...this.content, this.closeMarker];
515
515
  }
516
516
  mapChildren(e) {
517
- return new $e(P(e, this.openMarker), O(e, this.content), P(e, this.closeMarker));
517
+ return new Fe(K(e, this.openMarker), O(e, this.content), K(e, this.closeMarker));
518
518
  }
519
519
  }
520
- class Fe extends N {
520
+ class Ve extends N {
521
521
  constructor(e, t, s) {
522
522
  super(), this.openMarker = e, this.content = t, this.closeMarker = s;
523
523
  }
@@ -526,10 +526,10 @@ class Fe extends N {
526
526
  return [this.openMarker, ...this.content, this.closeMarker];
527
527
  }
528
528
  mapChildren(e) {
529
- return new Fe(P(e, this.openMarker), O(e, this.content), P(e, this.closeMarker));
529
+ return new Ve(K(e, this.openMarker), O(e, this.content), K(e, this.closeMarker));
530
530
  }
531
531
  }
532
- class Ve extends N {
532
+ class Ke extends N {
533
533
  constructor(e, t, s) {
534
534
  super(), this.openMarker = e, this.content = t, this.closeMarker = s;
535
535
  }
@@ -538,10 +538,10 @@ class Ve extends N {
538
538
  return [this.openMarker, ...this.content, this.closeMarker];
539
539
  }
540
540
  mapChildren(e) {
541
- return new Ve(P(e, this.openMarker), O(e, this.content), P(e, this.closeMarker));
541
+ return new Ke(K(e, this.openMarker), O(e, this.content), K(e, this.closeMarker));
542
542
  }
543
543
  }
544
- class Pe extends N {
544
+ class He extends N {
545
545
  constructor(e) {
546
546
  super(), this.content = e;
547
547
  }
@@ -550,10 +550,10 @@ class Pe extends N {
550
550
  return this.content;
551
551
  }
552
552
  mapChildren(e) {
553
- return new Pe(O(e, this.content));
553
+ return new He(O(e, this.content));
554
554
  }
555
555
  }
556
- class Ke extends N {
556
+ class We extends N {
557
557
  constructor(e) {
558
558
  super(), this.content = e;
559
559
  }
@@ -562,10 +562,10 @@ class Ke extends N {
562
562
  return this.content;
563
563
  }
564
564
  mapChildren(e) {
565
- return new Ke(O(e, this.content));
565
+ return new We(O(e, this.content));
566
566
  }
567
567
  }
568
- class we extends N {
568
+ class ke extends N {
569
569
  constructor(e, t) {
570
570
  super(), this.url = e, this.content = t;
571
571
  }
@@ -574,13 +574,13 @@ class we extends N {
574
574
  return this.content;
575
575
  }
576
576
  mapChildren(e) {
577
- return new we(this.url, O(e, this.content));
577
+ return new ke(this.url, O(e, this.content));
578
578
  }
579
579
  _localEquals(e) {
580
580
  return this.url === e.url;
581
581
  }
582
582
  }
583
- class _e extends N {
583
+ class ve extends N {
584
584
  constructor(e, t, s) {
585
585
  super(), this.alt = e, this.url = t, this.content = s;
586
586
  }
@@ -589,13 +589,13 @@ class _e extends N {
589
589
  return this.content;
590
590
  }
591
591
  mapChildren(e) {
592
- return new _e(this.alt, this.url, O(e, this.content));
592
+ return new ve(this.alt, this.url, O(e, this.content));
593
593
  }
594
594
  _localEquals(e) {
595
595
  return this.alt === e.alt && this.url === e.url;
596
596
  }
597
597
  }
598
- class J extends z {
598
+ class Z extends Q {
599
599
  constructor(e, t, s, i) {
600
600
  super(), this.level = e, this.marker = t, this.content = s, this.leadingTrivia = i;
601
601
  }
@@ -604,16 +604,16 @@ class J extends z {
604
604
  return this._withLeading([this.marker, ...this.content]);
605
605
  }
606
606
  mapChildren(e) {
607
- return new J(this.level, P(e, this.marker), O(e, this.content), Z(e, this.leadingTrivia));
607
+ return new Z(this.level, K(e, this.marker), O(e, this.content), ee(e, this.leadingTrivia));
608
608
  }
609
609
  withLeadingTrivia(e) {
610
- return new J(this.level, this.marker, this.content, e);
610
+ return new Z(this.level, this.marker, this.content, e);
611
611
  }
612
612
  _localEquals(e) {
613
613
  return this.level === e.level;
614
614
  }
615
615
  }
616
- class j extends z {
616
+ class H extends Q {
617
617
  constructor(e, t) {
618
618
  super(), this.content = e, this.leadingTrivia = t;
619
619
  }
@@ -622,13 +622,13 @@ class j extends z {
622
622
  return this._withLeading(this.content);
623
623
  }
624
624
  mapChildren(e) {
625
- return new j(O(e, this.content), Z(e, this.leadingTrivia));
625
+ return new H(O(e, this.content), ee(e, this.leadingTrivia));
626
626
  }
627
627
  withLeadingTrivia(e) {
628
- return new j(this.content, e);
628
+ return new H(this.content, e);
629
629
  }
630
630
  }
631
- class D extends z {
631
+ class A extends Q {
632
632
  constructor(e, t, s) {
633
633
  super(), this.language = e, this.content = t, this.leadingTrivia = s;
634
634
  }
@@ -639,13 +639,13 @@ class D extends z {
639
639
  return this._withLeading(this.content);
640
640
  }
641
641
  get openFence() {
642
- return ue(this.content, "openFence");
642
+ return fe(this.content, "openFence");
643
643
  }
644
644
  get closeFence() {
645
- return ue(this.content, "closeFence");
645
+ return fe(this.content, "closeFence");
646
646
  }
647
647
  get code() {
648
- return ue(this.content, "content");
648
+ return fe(this.content, "content");
649
649
  }
650
650
  /** Relative start offset of the {@link code} marker within this block. */
651
651
  get codeOffset() {
@@ -658,10 +658,10 @@ class D extends z {
658
658
  return e;
659
659
  }
660
660
  mapChildren(e) {
661
- return new D(this.language, O(e, this.content), Z(e, this.leadingTrivia));
661
+ return new A(this.language, O(e, this.content), ee(e, this.leadingTrivia));
662
662
  }
663
663
  withLeadingTrivia(e) {
664
- return new D(this.language, this.content, e);
664
+ return new A(this.language, this.content, e);
665
665
  }
666
666
  _localEquals(e) {
667
667
  return this.language === e.language;
@@ -686,7 +686,7 @@ class D extends z {
686
686
  return { stringEdit: this._contentEdit };
687
687
  }
688
688
  }
689
- class ne extends z {
689
+ class ne extends Q {
690
690
  constructor(e, t) {
691
691
  super(), this.content = e, this.leadingTrivia = t;
692
692
  }
@@ -695,16 +695,16 @@ class ne extends z {
695
695
  return this._withLeading(this.content);
696
696
  }
697
697
  get code() {
698
- return ue(this.content, "content");
698
+ return fe(this.content, "content");
699
699
  }
700
700
  mapChildren(e) {
701
- return new ne(O(e, this.content), Z(e, this.leadingTrivia));
701
+ return new ne(O(e, this.content), ee(e, this.leadingTrivia));
702
702
  }
703
703
  withLeadingTrivia(e) {
704
704
  return new ne(this.content, e);
705
705
  }
706
706
  }
707
- class oe extends z {
707
+ class le extends Q {
708
708
  constructor(e, t) {
709
709
  super(), this.content = e, this.leadingTrivia = t;
710
710
  }
@@ -713,16 +713,16 @@ class oe extends z {
713
713
  return this._withLeading(this.content);
714
714
  }
715
715
  get blocks() {
716
- return this.content.filter(We);
716
+ return this.content.filter(ze);
717
717
  }
718
718
  mapChildren(e) {
719
- return new oe(O(e, this.content), Z(e, this.leadingTrivia));
719
+ return new le(O(e, this.content), ee(e, this.leadingTrivia));
720
720
  }
721
721
  withLeadingTrivia(e) {
722
- return new oe(this.content, e);
722
+ return new le(this.content, e);
723
723
  }
724
724
  }
725
- class K extends z {
725
+ class W extends Q {
726
726
  constructor(e, t, s) {
727
727
  super(), this.ordered = e, this.content = t, this.leadingTrivia = s;
728
728
  }
@@ -731,19 +731,19 @@ class K extends z {
731
731
  return this._withLeading(this.content);
732
732
  }
733
733
  get items() {
734
- return this.content.filter((e) => e instanceof H);
734
+ return this.content.filter((e) => e instanceof q);
735
735
  }
736
736
  mapChildren(e) {
737
- return new K(this.ordered, O(e, this.content), Z(e, this.leadingTrivia));
737
+ return new W(this.ordered, O(e, this.content), ee(e, this.leadingTrivia));
738
738
  }
739
739
  withLeadingTrivia(e) {
740
- return new K(this.ordered, this.content, e);
740
+ return new W(this.ordered, this.content, e);
741
741
  }
742
742
  _localEquals(e) {
743
743
  return this.ordered === e.ordered;
744
744
  }
745
745
  }
746
- class H extends N {
746
+ class q extends N {
747
747
  constructor(e, t, s, i) {
748
748
  super(), this.marker = e, this.content = t, this.checked = s, this.leadingTrivia = i;
749
749
  }
@@ -752,24 +752,24 @@ class H extends N {
752
752
  return this.leadingTrivia ? [this.leadingTrivia, this.marker, ...this.content] : [this.marker, ...this.content];
753
753
  }
754
754
  get blocks() {
755
- return this.content.filter(We);
755
+ return this.content.filter(ze);
756
756
  }
757
757
  mapChildren(e) {
758
- return new H(
759
- P(e, this.marker),
758
+ return new q(
759
+ K(e, this.marker),
760
760
  O(e, this.content),
761
761
  this.checked,
762
- this.leadingTrivia ? P(e, this.leadingTrivia) : void 0
762
+ this.leadingTrivia ? K(e, this.leadingTrivia) : void 0
763
763
  );
764
764
  }
765
765
  withLeadingTrivia(e) {
766
- return new H(this.marker, this.content, this.checked, e);
766
+ return new q(this.marker, this.content, this.checked, e);
767
767
  }
768
768
  _localEquals(e) {
769
769
  return this.checked === e.checked;
770
770
  }
771
771
  }
772
- class ce extends z {
772
+ class he extends Q {
773
773
  constructor(e, t) {
774
774
  super(), this.content = e, this.leadingTrivia = t;
775
775
  }
@@ -778,7 +778,7 @@ class ce extends z {
778
778
  return this._withLeading(this.content);
779
779
  }
780
780
  get _rows() {
781
- return this.content.filter((e) => e instanceof ge);
781
+ return this.content.filter((e) => e instanceof me);
782
782
  }
783
783
  get headerRow() {
784
784
  return this._rows[0];
@@ -790,13 +790,13 @@ class ce extends z {
790
790
  return this._rows.slice(2);
791
791
  }
792
792
  mapChildren(e) {
793
- return new ce(O(e, this.content), Z(e, this.leadingTrivia));
793
+ return new he(O(e, this.content), ee(e, this.leadingTrivia));
794
794
  }
795
795
  withLeadingTrivia(e) {
796
- return new ce(this.content, e);
796
+ return new he(this.content, e);
797
797
  }
798
798
  }
799
- class ge extends N {
799
+ class me extends N {
800
800
  constructor(e) {
801
801
  super(), this.content = e;
802
802
  }
@@ -805,13 +805,13 @@ class ge extends N {
805
805
  return this.content;
806
806
  }
807
807
  get cells() {
808
- return this.content.filter((e) => e instanceof pe);
808
+ return this.content.filter((e) => e instanceof _e);
809
809
  }
810
810
  mapChildren(e) {
811
- return new ge(O(e, this.content));
811
+ return new me(O(e, this.content));
812
812
  }
813
813
  }
814
- class pe extends N {
814
+ class _e extends N {
815
815
  constructor(e) {
816
816
  super(), this.content = e;
817
817
  }
@@ -820,10 +820,10 @@ class pe extends N {
820
820
  return this.content;
821
821
  }
822
822
  mapChildren(e) {
823
- return new pe(O(e, this.content));
823
+ return new _e(O(e, this.content));
824
824
  }
825
825
  }
826
- class He extends N {
826
+ class qe extends N {
827
827
  constructor(e) {
828
828
  super(), this.content = e;
829
829
  }
@@ -832,67 +832,67 @@ class He extends N {
832
832
  return this.content;
833
833
  }
834
834
  get blocks() {
835
- return this.content.filter(We);
835
+ return this.content.filter(ze);
836
836
  }
837
837
  mapChildren(e) {
838
- return new He(O(e, this.content));
838
+ return new qe(O(e, this.content));
839
839
  }
840
840
  }
841
- function We(n) {
842
- return n instanceof J || n instanceof j || n instanceof D || n instanceof ne || n instanceof te || n instanceof oe || n instanceof K || n instanceof ce;
841
+ function ze(n) {
842
+ return n instanceof Z || n instanceof H || n instanceof A || n instanceof ne || n instanceof te || n instanceof le || n instanceof W || n instanceof he;
843
843
  }
844
- function gn(n, e) {
844
+ function Ft(n, e) {
845
845
  if (n.id === e.id)
846
846
  return 0;
847
847
  let t = 0;
848
848
  for (const s of n.children) {
849
- const i = gn(s, e);
849
+ const i = Ft(s, e);
850
850
  if (i !== void 0)
851
851
  return t + i;
852
852
  t += s.length;
853
853
  }
854
854
  }
855
- const pn = /\[[ xX]\]/;
856
- function Bi(n) {
855
+ const bn = /\[[ xX]\]/;
856
+ function er(n) {
857
857
  if (n.checked === void 0)
858
858
  return;
859
- const e = pn.exec(Bt(n));
859
+ const e = bn.exec(Vt(n));
860
860
  if (e)
861
- return w.ofStartAndLength(e.index, e[0].length);
861
+ return _.ofStartAndLength(e.index, e[0].length);
862
862
  }
863
- function Bt(n) {
864
- if (n instanceof Te)
863
+ function Vt(n) {
864
+ if (n instanceof Se)
865
865
  return n.content;
866
866
  let e = "";
867
867
  for (const t of n.children)
868
- e += Bt(t);
868
+ e += Vt(t);
869
869
  return e;
870
870
  }
871
- function mn(n) {
872
- const e = en({ extensions: [sn(), rn(), on(), cn()] }), t = tn()(n, void 0, !0);
873
- return nn(e.document().write(t)).map(([i, r]) => ({
871
+ function yn(n) {
872
+ const e = ln({ extensions: [un(), fn(), gn(), pn()] }), t = hn()(n, void 0, !0);
873
+ return dn(e.document().write(t)).map(([i, r]) => ({
874
874
  type: i,
875
875
  tokenType: r.type,
876
876
  startOffset: r.start.offset,
877
877
  endOffset: r.end.offset
878
878
  }));
879
879
  }
880
- function wn(n) {
881
- return new xn(mn(n), n).build();
880
+ function En(n) {
881
+ return new Tn(yn(n), n).build();
882
882
  }
883
- function ve(n) {
883
+ function Ee(n) {
884
884
  const e = [];
885
885
  for (let t = 0; t < n.length; t++) {
886
886
  const s = n[t], i = n[t + 1];
887
- if (s instanceof R && s.glueKind === "indent") {
888
- const r = i !== void 0 ? _n(i, s) : void 0;
887
+ if (s instanceof I && s.glueKind === "indent") {
888
+ const r = i !== void 0 ? Cn(i, s) : void 0;
889
889
  if (r) {
890
890
  e.push(r), t++;
891
891
  continue;
892
892
  }
893
893
  const o = e[e.length - 1];
894
- if (o instanceof R && o.glueKind === void 0) {
895
- e[e.length - 1] = new R(o.content + s.content);
894
+ if (o instanceof I && o.glueKind === void 0) {
895
+ e[e.length - 1] = new I(o.content + s.content);
896
896
  continue;
897
897
  }
898
898
  e.push(s);
@@ -902,43 +902,43 @@ function ve(n) {
902
902
  }
903
903
  return e;
904
904
  }
905
- function _n(n, e) {
906
- if (n instanceof K) {
907
- const t = n.content.findIndex((i) => i instanceof H);
905
+ function Cn(n, e) {
906
+ if (n instanceof W) {
907
+ const t = n.content.findIndex((i) => i instanceof q);
908
908
  if (t < 0)
909
909
  return;
910
910
  const s = n.content.map((i, r) => r === t ? i.withLeadingTrivia(e) : i);
911
- return new K(n.ordered, s, n.leadingTrivia);
911
+ return new W(n.ordered, s, n.leadingTrivia);
912
912
  }
913
- if (n instanceof H || n instanceof z)
913
+ if (n instanceof q || n instanceof Q)
914
914
  return n.withLeadingTrivia(e);
915
915
  }
916
- function be(n) {
916
+ function Ce(n) {
917
917
  const e = [];
918
918
  for (let t = 0; t < n.length; t++) {
919
919
  const s = n[t];
920
- if (s instanceof R && s.glueKind === void 0) {
921
- const i = e[e.length - 1], r = n[t + 1], o = i instanceof j && r instanceof j, c = new R(s.content, o ? "blockBreak" : "blockGap"), l = i !== void 0 ? Dt(i, c) : void 0;
922
- l ? e[e.length - 1] = l : e.push(c);
920
+ if (s instanceof I && s.glueKind === void 0) {
921
+ const i = e[e.length - 1], r = n[t + 1], o = i instanceof H && r instanceof H, c = new I(s.content, o ? "blockBreak" : "blockGap"), a = i !== void 0 ? Kt(i, c) : void 0;
922
+ a ? e[e.length - 1] = a : e.push(c);
923
923
  continue;
924
924
  }
925
925
  e.push(s);
926
926
  }
927
927
  return e;
928
928
  }
929
- function Dt(n, e) {
929
+ function Kt(n, e) {
930
930
  switch (n.kind) {
931
931
  case "paragraph": {
932
932
  const t = n;
933
- return new j([...t.content, e], t.leadingTrivia);
933
+ return new H([...t.content, e], t.leadingTrivia);
934
934
  }
935
935
  case "heading": {
936
936
  const t = n;
937
- return new J(t.level, t.marker, [...t.content, e], t.leadingTrivia);
937
+ return new Z(t.level, t.marker, [...t.content, e], t.leadingTrivia);
938
938
  }
939
939
  case "codeBlock": {
940
940
  const t = n;
941
- return new D(t.language, [...t.content, e], t.leadingTrivia);
941
+ return new A(t.language, [...t.content, e], t.leadingTrivia);
942
942
  }
943
943
  case "mathBlock": {
944
944
  const t = n;
@@ -950,34 +950,34 @@ function Dt(n, e) {
950
950
  }
951
951
  case "table": {
952
952
  const t = n;
953
- return new ce([...t.content, e], t.leadingTrivia);
953
+ return new he([...t.content, e], t.leadingTrivia);
954
954
  }
955
955
  case "blockQuote": {
956
956
  const t = n;
957
- return new oe(Ie(t.content, e), t.leadingTrivia);
957
+ return new le(Ie(t.content, e), t.leadingTrivia);
958
958
  }
959
959
  case "list": {
960
960
  const t = n;
961
- return new K(t.ordered, Ie(t.content, e), t.leadingTrivia);
961
+ return new W(t.ordered, Ie(t.content, e), t.leadingTrivia);
962
962
  }
963
963
  case "listItem": {
964
964
  const t = n;
965
- return new H(t.marker, Ie(t.content, e), t.checked, t.leadingTrivia);
965
+ return new q(t.marker, Ie(t.content, e), t.checked, t.leadingTrivia);
966
966
  }
967
967
  default:
968
968
  return;
969
969
  }
970
970
  }
971
971
  function Ie(n, e) {
972
- const t = n[n.length - 1], s = t !== void 0 ? Dt(t, e) : void 0;
972
+ const t = n[n.length - 1], s = t !== void 0 ? Kt(t, e) : void 0;
973
973
  if (s) {
974
974
  const i = n.slice();
975
975
  return i[i.length - 1] = s, i;
976
976
  }
977
977
  return [...n, e];
978
978
  }
979
- function kn(n) {
980
- return n.some((e) => !(e instanceof R)) ? n : [new j(n)];
979
+ function On(n) {
980
+ return n.some((e) => !(e instanceof I)) ? n : [new H(n)];
981
981
  }
982
982
  class C {
983
983
  constructor(e, t) {
@@ -988,24 +988,24 @@ class C {
988
988
  this._entries.push({ node: e, start: t });
989
989
  }
990
990
  build(e, t) {
991
- this._entries.sort((c, l) => c.start - l.start);
991
+ this._entries.sort((c, a) => c.start - a.start);
992
992
  const s = [];
993
993
  let i = this._parentStart;
994
- const r = this._parentStart + e, o = (c, l) => {
995
- const a = this._source.substring(c, l), h = t ? null : /\n[^\S\n]+$/.exec(a);
994
+ const r = this._parentStart + e, o = (c, a) => {
995
+ const l = this._source.substring(c, a), h = t ? null : /\n[^\S\n]+$/.exec(l);
996
996
  if (!h) {
997
- s.push(new R(a, t));
997
+ s.push(new I(l, t));
998
998
  return;
999
999
  }
1000
- const g = a.slice(h.index + 1);
1001
- s.push(new R(a.slice(0, a.length - g.length))), s.push(new R(g, "indent"));
1000
+ const u = l.slice(h.index + 1);
1001
+ s.push(new I(l.slice(0, l.length - u.length))), s.push(new I(u, "indent"));
1002
1002
  };
1003
- for (const { node: c, start: l } of this._entries)
1004
- c.length !== 0 && (l > i && o(i, l), s.push(c), i = l + c.length);
1003
+ for (const { node: c, start: a } of this._entries)
1004
+ c.length !== 0 && (a > i && o(i, a), s.push(c), i = a + c.length);
1005
1005
  return i < r && o(i, r), s;
1006
1006
  }
1007
1007
  }
1008
- class xn {
1008
+ class Tn {
1009
1009
  constructor(e, t) {
1010
1010
  this._events = e, this._source = t;
1011
1011
  }
@@ -1021,7 +1021,7 @@ class xn {
1021
1021
  } else
1022
1022
  this._idx++;
1023
1023
  }
1024
- return new He(kn(be(ve(e.build(this._source.length)))));
1024
+ return new qe(On(Ce(Ee(e.build(this._source.length)))));
1025
1025
  }
1026
1026
  _tryParseBlock() {
1027
1027
  switch (this._events[this._idx].tokenType) {
@@ -1055,17 +1055,17 @@ class xn {
1055
1055
  for (; this._notExit("atxHeading"); ) {
1056
1056
  const h = this._events[this._idx];
1057
1057
  if (h.type === "enter" && h.tokenType === "atxHeadingSequence") {
1058
- const g = this._consume("enter", "atxHeadingSequence"), d = this._consume("exit", "atxHeadingSequence");
1059
- i === e.startOffset && (t = Math.min(6, Math.max(1, d.endOffset - g.startOffset)), s = g.startOffset, i = d.endOffset);
1058
+ const u = this._consume("enter", "atxHeadingSequence"), f = this._consume("exit", "atxHeadingSequence");
1059
+ i === e.startOffset && (t = Math.min(6, Math.max(1, f.endOffset - u.startOffset)), s = u.startOffset, i = f.endOffset);
1060
1060
  } else h.type === "enter" && h.tokenType === "atxHeadingText" ? (this._consume("enter", "atxHeadingText"), this._parseInlines(r, "atxHeadingText"), this._consume("exit", "atxHeadingText")) : this._idx++;
1061
1061
  }
1062
1062
  const o = this._consume("exit", "atxHeading");
1063
1063
  i > s && r.length > 0 && (i = r[0].start);
1064
- const c = new k("headingMarker", this._source.substring(e.startOffset, i)), l = new C(i, this._source);
1064
+ const c = new v("headingMarker", this._source.substring(e.startOffset, i)), a = new C(i, this._source);
1065
1065
  for (const h of r)
1066
- l.add(h.node, h.start);
1067
- const a = l.build(o.endOffset - i);
1068
- return new J(t, c, a);
1066
+ a.add(h.node, h.start);
1067
+ const l = a.build(o.endOffset - i);
1068
+ return new Z(t, c, l);
1069
1069
  }
1070
1070
  _parseParagraph() {
1071
1071
  const e = this._consume("enter", "paragraph"), t = [];
@@ -1074,7 +1074,7 @@ class xn {
1074
1074
  const s = this._consume("exit", "paragraph"), i = new C(e.startOffset, this._source);
1075
1075
  for (const r of t)
1076
1076
  i.add(r.node, r.start);
1077
- return new j(i.build(s.endOffset - e.startOffset));
1077
+ return new H(i.build(s.endOffset - e.startOffset));
1078
1078
  }
1079
1079
  _parseCodeFenced() {
1080
1080
  const e = this._consume("enter", "codeFenced");
@@ -1082,29 +1082,29 @@ class xn {
1082
1082
  const s = new C(e.startOffset, this._source);
1083
1083
  let i = !1, r, o;
1084
1084
  for (; this._notExit("codeFenced"); ) {
1085
- const l = this._events[this._idx];
1086
- if (l.type === "enter" && l.tokenType === "codeFencedFence") {
1087
- const a = this._consume("enter", "codeFencedFence");
1085
+ const a = this._events[this._idx];
1086
+ if (a.type === "enter" && a.tokenType === "codeFencedFence") {
1087
+ const l = this._consume("enter", "codeFencedFence");
1088
1088
  for (; this._notExit("codeFencedFence"); ) {
1089
- const g = this._events[this._idx];
1090
- if (g.type === "enter" && g.tokenType === "codeFencedFenceInfo") {
1089
+ const u = this._events[this._idx];
1090
+ if (u.type === "enter" && u.tokenType === "codeFencedFenceInfo") {
1091
1091
  for (this._consume("enter", "codeFencedFenceInfo"); this._notExit("codeFencedFenceInfo"); ) {
1092
- const d = this._events[this._idx];
1093
- d.tokenType === "data" && (t = this._source.substring(d.startOffset, d.endOffset)), this._idx++;
1092
+ const f = this._events[this._idx];
1093
+ f.tokenType === "data" && (t = this._source.substring(f.startOffset, f.endOffset)), this._idx++;
1094
1094
  }
1095
1095
  this._consume("exit", "codeFencedFenceInfo");
1096
1096
  } else
1097
1097
  this._idx++;
1098
1098
  }
1099
1099
  const h = this._consume("exit", "codeFencedFence");
1100
- s.add(new k(
1100
+ s.add(new v(
1101
1101
  i ? "closeFence" : "openFence",
1102
- this._source.substring(a.startOffset, h.endOffset)
1103
- ), a.startOffset), i = !0;
1104
- } else l.tokenType === "codeFlowValue" || l.tokenType === "lineEnding" ? (r === void 0 && (r = l.startOffset), o = l.endOffset, this._idx++) : this._idx++;
1102
+ this._source.substring(l.startOffset, h.endOffset)
1103
+ ), l.startOffset), i = !0;
1104
+ } else a.tokenType === "codeFlowValue" || a.tokenType === "lineEnding" ? (r === void 0 && (r = a.startOffset), o = a.endOffset, this._idx++) : this._idx++;
1105
1105
  }
1106
1106
  const c = this._consume("exit", "codeFenced");
1107
- return r !== void 0 && s.add(new k("content", this._source.substring(r, o)), r), new D(t, s.build(c.endOffset - e.startOffset));
1107
+ return r !== void 0 && s.add(new v("content", this._source.substring(r, o)), r), new A(t, s.build(c.endOffset - e.startOffset));
1108
1108
  }
1109
1109
  /**
1110
1110
  * An indented code block has no fences and no info string: micromark strips a
@@ -1118,19 +1118,19 @@ class xn {
1118
1118
  const e = this._consume("enter", "codeIndented"), t = new C(e.startOffset, this._source);
1119
1119
  let s, i;
1120
1120
  const r = () => {
1121
- s !== void 0 && (t.add(new k("content", this._source.substring(s, i)), s), s = void 0);
1121
+ s !== void 0 && (t.add(new v("content", this._source.substring(s, i)), s), s = void 0);
1122
1122
  };
1123
1123
  for (; this._notExit("codeIndented"); ) {
1124
1124
  const c = this._events[this._idx];
1125
1125
  if (c.type === "enter" && c.tokenType === "linePrefix") {
1126
1126
  r();
1127
- const l = this._consume("enter", "linePrefix"), a = this._consume("exit", "linePrefix");
1128
- t.add(new k("codeIndent", this._source.substring(l.startOffset, a.endOffset)), l.startOffset);
1127
+ const a = this._consume("enter", "linePrefix"), l = this._consume("exit", "linePrefix");
1128
+ t.add(new v("codeIndent", this._source.substring(a.startOffset, l.endOffset)), a.startOffset);
1129
1129
  } else c.tokenType === "codeFlowValue" || c.tokenType === "lineEnding" ? (s === void 0 && (s = c.startOffset), i = c.endOffset, this._idx++) : this._idx++;
1130
1130
  }
1131
1131
  r();
1132
1132
  const o = this._consume("exit", "codeIndented");
1133
- return new D("", t.build(o.endOffset - e.startOffset));
1133
+ return new A("", t.build(o.endOffset - e.startOffset));
1134
1134
  }
1135
1135
  _parseMathFlow() {
1136
1136
  const e = this._consume("enter", "mathFlow"), t = new C(e.startOffset, this._source);
@@ -1138,24 +1138,24 @@ class xn {
1138
1138
  for (; this._notExit("mathFlow"); ) {
1139
1139
  const c = this._events[this._idx];
1140
1140
  if (c.type === "enter" && c.tokenType === "mathFlowFence") {
1141
- const l = this._consume("enter", "mathFlowFence");
1141
+ const a = this._consume("enter", "mathFlowFence");
1142
1142
  for (; this._notExit("mathFlowFence"); )
1143
1143
  this._idx++;
1144
- const a = this._consume("exit", "mathFlowFence");
1145
- t.add(new k(
1144
+ const l = this._consume("exit", "mathFlowFence");
1145
+ t.add(new v(
1146
1146
  s ? "closeFence" : "openFence",
1147
- this._source.substring(l.startOffset, a.endOffset)
1148
- ), l.startOffset), s = !0;
1147
+ this._source.substring(a.startOffset, l.endOffset)
1148
+ ), a.startOffset), s = !0;
1149
1149
  } else c.tokenType === "mathFlowValue" || c.tokenType === "lineEnding" ? (i === void 0 && (i = c.startOffset), r = c.endOffset, this._idx++) : this._idx++;
1150
1150
  }
1151
1151
  const o = this._consume("exit", "mathFlow");
1152
- return i !== void 0 && t.add(new k("content", this._source.substring(i, r)), i), new ne(t.build(o.endOffset - e.startOffset));
1152
+ return i !== void 0 && t.add(new v("content", this._source.substring(i, r)), i), new ne(t.build(o.endOffset - e.startOffset));
1153
1153
  }
1154
1154
  _parseThematicBreak() {
1155
1155
  const e = this._consume("enter", "thematicBreak");
1156
1156
  for (; this._notExit("thematicBreak"); )
1157
1157
  this._idx++;
1158
- const t = this._consume("exit", "thematicBreak"), s = new k("content", this._source.substring(e.startOffset, t.endOffset));
1158
+ const t = this._consume("exit", "thematicBreak"), s = new v("content", this._source.substring(e.startOffset, t.endOffset));
1159
1159
  return new te([s]);
1160
1160
  }
1161
1161
  _parseBlockQuote() {
@@ -1168,7 +1168,7 @@ class xn {
1168
1168
  for (; this._notExit("blockQuotePrefix"); )
1169
1169
  this._idx++;
1170
1170
  const c = this._consume("exit", "blockQuotePrefix");
1171
- s || t.add(new k("blockQuoteMarker", this._source.substring(o.startOffset, c.endOffset)), o.startOffset);
1171
+ s || t.add(new v("blockQuoteMarker", this._source.substring(o.startOffset, c.endOffset)), o.startOffset);
1172
1172
  } else if (r.type === "enter") {
1173
1173
  const o = r.startOffset, c = this._tryParseBlock();
1174
1174
  c ? (t.add(c, o), s = !0) : this._idx++;
@@ -1176,32 +1176,32 @@ class xn {
1176
1176
  this._idx++;
1177
1177
  }
1178
1178
  const i = this._consume("exit", "blockQuote");
1179
- return new oe(be(ve(t.build(i.endOffset - e.startOffset))));
1179
+ return new le(Ce(Ee(t.build(i.endOffset - e.startOffset))));
1180
1180
  }
1181
1181
  _parseList() {
1182
1182
  const e = this._events[this._idx].tokenType, t = e === "listOrdered", s = this._consume("enter", e), i = new C(s.startOffset, this._source);
1183
- let r, o, c, l, a, h;
1184
- const g = () => {
1185
- if (r === void 0 || o === void 0 || l === void 0)
1183
+ let r, o, c, a, l, h;
1184
+ const u = () => {
1185
+ if (r === void 0 || o === void 0 || a === void 0)
1186
1186
  return;
1187
- const u = new k("listItemMarker", this._source.substring(o, c)), f = h ?? c, p = l.build(f - c);
1188
- i.add(new H(u, be(ve(p)), a), r);
1187
+ const d = new v("listItemMarker", this._source.substring(o, c)), g = h ?? c, p = a.build(g - c);
1188
+ i.add(new q(d, Ce(Ee(p)), l), r);
1189
1189
  };
1190
1190
  for (; this._notExit(e); ) {
1191
- const u = this._events[this._idx];
1192
- if (u.type === "enter" && u.tokenType === "listItemPrefix") {
1193
- for (g(), this._consume("enter", "listItemPrefix"), r = u.startOffset, o = u.startOffset, a = void 0, h = void 0, this._checkChecked = void 0; this._notExit("listItemPrefix"); )
1191
+ const d = this._events[this._idx];
1192
+ if (d.type === "enter" && d.tokenType === "listItemPrefix") {
1193
+ for (u(), this._consume("enter", "listItemPrefix"), r = d.startOffset, o = d.startOffset, l = void 0, h = void 0, this._checkChecked = void 0; this._notExit("listItemPrefix"); )
1194
1194
  this._idx++;
1195
- c = this._events[this._idx].endOffset, this._consume("exit", "listItemPrefix"), l = new C(c, this._source);
1196
- } else if (u.type === "enter") {
1197
- const f = u.startOffset, p = this._tryParseBlock();
1198
- p && l ? (l.add(p, f), h = f + p.length, a === void 0 && this._checkChecked !== void 0 && (a = this._checkChecked)) : p || this._idx++;
1195
+ c = this._events[this._idx].endOffset, this._consume("exit", "listItemPrefix"), a = new C(c, this._source);
1196
+ } else if (d.type === "enter") {
1197
+ const g = d.startOffset, p = this._tryParseBlock();
1198
+ p && a ? (a.add(p, g), h = g + p.length, l === void 0 && this._checkChecked !== void 0 && (l = this._checkChecked)) : p || this._idx++;
1199
1199
  } else
1200
1200
  this._idx++;
1201
1201
  }
1202
- g();
1203
- const d = this._consume("exit", e);
1204
- return new K(t, be(ve(i.build(d.endOffset - s.startOffset))));
1202
+ u();
1203
+ const f = this._consume("exit", e);
1204
+ return new W(t, Ce(Ee(i.build(f.endOffset - s.startOffset))));
1205
1205
  }
1206
1206
  _parseTable() {
1207
1207
  const e = this._consume("enter", "table"), t = new C(e.startOffset, this._source);
@@ -1218,8 +1218,8 @@ class xn {
1218
1218
  const c = o.startOffset;
1219
1219
  for (; this._notExit("tableDelimiterRow"); )
1220
1220
  this._idx++;
1221
- const l = this._events[this._idx].endOffset;
1222
- this._idx++, t.add(this._buildDelimiterRow(c, l, s), c);
1221
+ const a = this._events[this._idx].endOffset;
1222
+ this._idx++, t.add(this._buildDelimiterRow(c, a, s), c);
1223
1223
  } else
1224
1224
  this._idx++;
1225
1225
  }
@@ -1234,27 +1234,27 @@ class xn {
1234
1234
  this._idx++;
1235
1235
  }
1236
1236
  const i = this._consume("exit", "table");
1237
- return new ce(t.build(i.endOffset - e.startOffset));
1237
+ return new he(t.build(i.endOffset - e.startOffset));
1238
1238
  }
1239
1239
  _buildDelimiterRow(e, t, s) {
1240
1240
  const i = this._source.substring(e, t), r = [];
1241
- for (let a = 0; a < i.length; a++)
1242
- i[a] === "|" && r.push(a);
1241
+ for (let l = 0; l < i.length; l++)
1242
+ i[l] === "|" && r.push(l);
1243
1243
  const o = [], c = Math.max(1, s);
1244
1244
  if (i[0] === "|")
1245
- for (let a = 0; a < c && a < r.length; a++)
1246
- o.push(r[a]);
1245
+ for (let l = 0; l < c && l < r.length; l++)
1246
+ o.push(r[l]);
1247
1247
  else {
1248
1248
  o.push(0);
1249
- for (let a = 0; a < c - 1 && a < r.length; a++)
1250
- o.push(r[a]);
1249
+ for (let l = 0; l < c - 1 && l < r.length; l++)
1250
+ o.push(r[l]);
1251
1251
  }
1252
- const l = new C(e, this._source);
1253
- for (let a = 0; a < o.length; a++) {
1254
- const h = o[a], g = a + 1 < o.length ? o[a + 1] : i.length, d = new C(e + h, this._source), u = i.substring(h, g);
1255
- a === o.length - 1 && u.length > 1 && u.endsWith("|") ? (d.add(new k("tableDelimiter", u.slice(0, -1)), e + h), d.add(new k("tableDelimiterClose", "|"), e + h + u.length - 1)) : d.add(new k("tableDelimiter", u), e + h), l.add(new pe(d.build(g - h)), e + h);
1252
+ const a = new C(e, this._source);
1253
+ for (let l = 0; l < o.length; l++) {
1254
+ const h = o[l], u = l + 1 < o.length ? o[l + 1] : i.length, f = new C(e + h, this._source), d = i.substring(h, u);
1255
+ l === o.length - 1 && d.length > 1 && d.endsWith("|") ? (f.add(new v("tableDelimiter", d.slice(0, -1)), e + h), f.add(new v("tableDelimiterClose", "|"), e + h + d.length - 1)) : f.add(new v("tableDelimiter", d), e + h), a.add(new _e(f.build(u - h)), e + h);
1256
1256
  }
1257
- return new ge(l.build(t - e));
1257
+ return new me(a.build(t - e));
1258
1258
  }
1259
1259
  _parseTableRow(e) {
1260
1260
  const t = this._consume("enter", "tableRow"), s = new C(t.startOffset, this._source);
@@ -1271,15 +1271,15 @@ class xn {
1271
1271
  } else
1272
1272
  this._idx++;
1273
1273
  }
1274
- const l = this._consume("exit", e), a = new C(o.startOffset, this._source);
1274
+ const a = this._consume("exit", e), l = new C(o.startOffset, this._source);
1275
1275
  for (const h of c)
1276
- a.add(h.node, h.start);
1277
- s.add(new pe(a.build(l.endOffset - o.startOffset, "tableCellGlue")), o.startOffset);
1276
+ l.add(h.node, h.start);
1277
+ s.add(new _e(l.build(a.endOffset - o.startOffset, "tableCellGlue")), o.startOffset);
1278
1278
  } else
1279
1279
  this._idx++;
1280
1280
  }
1281
1281
  const i = this._consume("exit", "tableRow");
1282
- return new ge(s.build(i.endOffset - t.startOffset));
1282
+ return new me(s.build(i.endOffset - t.startOffset));
1283
1283
  }
1284
1284
  _parseInlines(e, t) {
1285
1285
  for (; this._idx < this._events.length; ) {
@@ -1317,7 +1317,7 @@ class xn {
1317
1317
  e.push(this._parseHardBreak());
1318
1318
  return;
1319
1319
  }
1320
- t.type === "exit" && (t.tokenType === "data" || t.tokenType === "codeTextData") && e.push({ node: new Ee(this._source.substring(t.startOffset, t.endOffset)), start: t.startOffset }), t.type === "exit" && t.tokenType === "taskListCheckValueChecked" ? this._checkChecked = !0 : t.type === "exit" && t.tokenType === "taskListCheckValueUnchecked" && (this._checkChecked = !1), this._idx++;
1320
+ t.type === "exit" && (t.tokenType === "data" || t.tokenType === "codeTextData") && e.push({ node: new pe(this._source.substring(t.startOffset, t.endOffset)), start: t.startOffset }), t.type === "exit" && t.tokenType === "taskListCheckValueChecked" ? this._checkChecked = !0 : t.type === "exit" && t.tokenType === "taskListCheckValueUnchecked" && (this._checkChecked = !1), this._idx++;
1321
1321
  }
1322
1322
  /**
1323
1323
  * A GFM hard line break — either two-or-more trailing spaces
@@ -1333,61 +1333,61 @@ class xn {
1333
1333
  this._idx++;
1334
1334
  let s = this._consume("exit", t).endOffset;
1335
1335
  const i = this._events[this._idx];
1336
- return i && i.type === "enter" && i.tokenType === "lineEnding" && (this._consume("enter", "lineEnding"), s = this._consume("exit", "lineEnding").endOffset), { node: new k("hardBreak", this._source.substring(e.startOffset, s)), start: e.startOffset };
1336
+ return i && i.type === "enter" && i.tokenType === "lineEnding" && (this._consume("enter", "lineEnding"), s = this._consume("exit", "lineEnding").endOffset), { node: new v("hardBreak", this._source.substring(e.startOffset, s)), start: e.startOffset };
1337
1337
  }
1338
1338
  _parseEmphasisOrStrong(e) {
1339
1339
  const t = this._events[this._idx].tokenType, s = t === "strongSequence", i = this._consume("enter", t), r = this._consume("exit", t), o = [];
1340
1340
  for (; this._idx < this._events.length; ) {
1341
1341
  const c = this._events[this._idx];
1342
1342
  if (c.type === "enter" && c.tokenType === t) {
1343
- const l = this._consume("enter", t), a = this._consume("exit", t), h = new k("openMarker", this._source.substring(i.startOffset, r.endOffset)), g = new k("closeMarker", this._source.substring(l.startOffset, a.endOffset)), d = new C(r.endOffset, this._source);
1343
+ const a = this._consume("enter", t), l = this._consume("exit", t), h = new v("openMarker", this._source.substring(i.startOffset, r.endOffset)), u = new v("closeMarker", this._source.substring(a.startOffset, l.endOffset)), f = new C(r.endOffset, this._source);
1344
1344
  for (const p of o)
1345
- d.add(p.node, p.start);
1346
- const u = d.build(l.startOffset - r.endOffset), f = s ? new $e(h, u, g) : new Fe(h, u, g);
1347
- e.push({ node: f, start: i.startOffset });
1345
+ f.add(p.node, p.start);
1346
+ const d = f.build(a.startOffset - r.endOffset), g = s ? new Fe(h, d, u) : new Ve(h, d, u);
1347
+ e.push({ node: g, start: i.startOffset });
1348
1348
  return;
1349
1349
  }
1350
1350
  this._parseInlineEvent(o);
1351
1351
  }
1352
- e.push({ node: new Ee(this._source.substring(i.startOffset, r.endOffset)), start: i.startOffset });
1352
+ e.push({ node: new pe(this._source.substring(i.startOffset, r.endOffset)), start: i.startOffset });
1353
1353
  }
1354
1354
  _parseInlineCode() {
1355
1355
  const e = this._consume("enter", "codeText"), t = new C(e.startOffset, this._source);
1356
1356
  let s = !1, i, r;
1357
1357
  for (; this._notExit("codeText"); ) {
1358
1358
  const c = this._events[this._idx];
1359
- c.type === "enter" && c.tokenType === "codeTextSequence" ? (t.add(new k(s ? "closeMarker" : "openMarker", this._source.substring(c.startOffset, c.endOffset)), c.startOffset), s = !0) : c.type === "enter" && c.tokenType === "codeTextData" && (i === void 0 && (i = c.startOffset), r = c.endOffset), this._idx++;
1359
+ c.type === "enter" && c.tokenType === "codeTextSequence" ? (t.add(new v(s ? "closeMarker" : "openMarker", this._source.substring(c.startOffset, c.endOffset)), c.startOffset), s = !0) : c.type === "enter" && c.tokenType === "codeTextData" && (i === void 0 && (i = c.startOffset), r = c.endOffset), this._idx++;
1360
1360
  }
1361
1361
  const o = this._consume("exit", "codeText");
1362
- return i !== void 0 && t.add(new k("content", this._source.substring(i, r)), i), { node: new Pe(t.build(o.endOffset - e.startOffset)), start: e.startOffset };
1362
+ return i !== void 0 && t.add(new v("content", this._source.substring(i, r)), i), { node: new He(t.build(o.endOffset - e.startOffset)), start: e.startOffset };
1363
1363
  }
1364
1364
  _parseInlineMath() {
1365
1365
  const e = this._consume("enter", "mathText"), t = new C(e.startOffset, this._source);
1366
1366
  let s = !1, i, r;
1367
1367
  for (; this._notExit("mathText"); ) {
1368
1368
  const c = this._events[this._idx];
1369
- c.type === "enter" && c.tokenType === "mathTextSequence" ? (t.add(new k(s ? "closeMarker" : "openMarker", this._source.substring(c.startOffset, c.endOffset)), c.startOffset), s = !0) : c.type === "enter" && c.tokenType === "mathTextData" && (i === void 0 && (i = c.startOffset), r = c.endOffset), this._idx++;
1369
+ c.type === "enter" && c.tokenType === "mathTextSequence" ? (t.add(new v(s ? "closeMarker" : "openMarker", this._source.substring(c.startOffset, c.endOffset)), c.startOffset), s = !0) : c.type === "enter" && c.tokenType === "mathTextData" && (i === void 0 && (i = c.startOffset), r = c.endOffset), this._idx++;
1370
1370
  }
1371
1371
  const o = this._consume("exit", "mathText");
1372
- return i !== void 0 && t.add(new k("content", this._source.substring(i, r)), i), { node: new Ke(t.build(o.endOffset - e.startOffset)), start: e.startOffset };
1372
+ return i !== void 0 && t.add(new v("content", this._source.substring(i, r)), i), { node: new We(t.build(o.endOffset - e.startOffset)), start: e.startOffset };
1373
1373
  }
1374
1374
  _parseStrikethrough() {
1375
1375
  const e = this._consume("enter", "strikethrough");
1376
1376
  let t, s, i = e.startOffset, r = e.startOffset;
1377
1377
  const o = [];
1378
1378
  for (; this._notExit("strikethrough"); ) {
1379
- const a = this._events[this._idx];
1380
- if (a.type === "enter" && a.tokenType === "strikethroughSequence") {
1381
- const h = this._source.substring(a.startOffset, a.endOffset);
1382
- t ? (s = new k("closeMarker", h), r = a.startOffset) : (t = new k("openMarker", h), i = a.endOffset), this._idx++;
1383
- } else a.type === "enter" && a.tokenType === "strikethroughText" ? (this._consume("enter", "strikethroughText"), this._parseInlines(o, "strikethroughText"), this._consume("exit", "strikethroughText")) : this._idx++;
1379
+ const l = this._events[this._idx];
1380
+ if (l.type === "enter" && l.tokenType === "strikethroughSequence") {
1381
+ const h = this._source.substring(l.startOffset, l.endOffset);
1382
+ t ? (s = new v("closeMarker", h), r = l.startOffset) : (t = new v("openMarker", h), i = l.endOffset), this._idx++;
1383
+ } else l.type === "enter" && l.tokenType === "strikethroughText" ? (this._consume("enter", "strikethroughText"), this._parseInlines(o, "strikethroughText"), this._consume("exit", "strikethroughText")) : this._idx++;
1384
1384
  }
1385
1385
  this._consume("exit", "strikethrough");
1386
1386
  const c = new C(i, this._source);
1387
- for (const a of o)
1388
- c.add(a.node, a.start);
1389
- const l = c.build(r - i);
1390
- return { node: new Ve(t, l, s), start: e.startOffset };
1387
+ for (const l of o)
1388
+ c.add(l.node, l.start);
1389
+ const a = c.build(r - i);
1390
+ return { node: new Ke(t, a, s), start: e.startOffset };
1391
1391
  }
1392
1392
  _parseLink() {
1393
1393
  const e = this._consume("enter", "link"), t = new C(e.startOffset, this._source), s = [];
@@ -1396,10 +1396,10 @@ class xn {
1396
1396
  const c = this._events[this._idx];
1397
1397
  if (c.type === "enter" && c.tokenType === "label") {
1398
1398
  for (this._consume("enter", "label"); this._notExit("label"); ) {
1399
- const l = this._events[this._idx];
1400
- if (l.type === "enter" && l.tokenType === "labelMarker")
1401
- t.add(new k(r ? "closeBracket" : "openBracket", this._source.substring(l.startOffset, l.endOffset)), l.startOffset), r = !0;
1402
- else if (l.type === "enter" && l.tokenType === "labelText") {
1399
+ const a = this._events[this._idx];
1400
+ if (a.type === "enter" && a.tokenType === "labelMarker")
1401
+ t.add(new v(r ? "closeBracket" : "openBracket", this._source.substring(a.startOffset, a.endOffset)), a.startOffset), r = !0;
1402
+ else if (a.type === "enter" && a.tokenType === "labelText") {
1403
1403
  this._consume("enter", "labelText"), this._parseInlines(s, "labelText"), this._consume("exit", "labelText");
1404
1404
  continue;
1405
1405
  }
@@ -1408,10 +1408,10 @@ class xn {
1408
1408
  this._consume("exit", "label");
1409
1409
  } else if (c.type === "enter" && c.tokenType === "resource") {
1410
1410
  this._consume("enter", "resource");
1411
- let l = !1;
1411
+ let a = !1;
1412
1412
  for (; this._notExit("resource"); ) {
1413
- const a = this._events[this._idx];
1414
- a.type === "enter" && a.tokenType === "resourceMarker" ? (t.add(new k(l ? "closeParen" : "openParen", this._source.substring(a.startOffset, a.endOffset)), a.startOffset), l = !0) : a.type === "enter" && a.tokenType === "resourceDestinationString" && (i = this._source.substring(a.startOffset, a.endOffset), t.add(new k("url", i), a.startOffset)), this._idx++;
1413
+ const l = this._events[this._idx];
1414
+ l.type === "enter" && l.tokenType === "resourceMarker" ? (t.add(new v(a ? "closeParen" : "openParen", this._source.substring(l.startOffset, l.endOffset)), l.startOffset), a = !0) : l.type === "enter" && l.tokenType === "resourceDestinationString" && (i = this._source.substring(l.startOffset, l.endOffset), t.add(new v("url", i), l.startOffset)), this._idx++;
1415
1415
  }
1416
1416
  this._consume("exit", "resource");
1417
1417
  } else
@@ -1420,7 +1420,7 @@ class xn {
1420
1420
  const o = this._consume("exit", "link");
1421
1421
  for (const c of s)
1422
1422
  t.add(c.node, c.start);
1423
- return { node: new we(i, t.build(o.endOffset - e.startOffset)), start: e.startOffset };
1423
+ return { node: new ke(i, t.build(o.endOffset - e.startOffset)), start: e.startOffset };
1424
1424
  }
1425
1425
  _parseImage() {
1426
1426
  const e = this._consume("enter", "image"), t = new C(e.startOffset, this._source);
@@ -1429,23 +1429,23 @@ class xn {
1429
1429
  const c = this._events[this._idx];
1430
1430
  if (c.type === "enter" && c.tokenType === "label") {
1431
1431
  for (this._consume("enter", "label"); this._notExit("label"); ) {
1432
- const l = this._events[this._idx];
1433
- l.type === "enter" && l.tokenType === "labelImageMarker" ? t.add(new k("bangBracket", this._source.substring(l.startOffset, l.endOffset)), l.startOffset) : l.type === "enter" && l.tokenType === "labelMarker" ? (t.add(new k(r ? "closeBracket" : "openBracket", this._source.substring(l.startOffset, l.endOffset)), l.startOffset), r = !0) : l.type === "enter" && l.tokenType === "labelText" && (s = this._source.substring(l.startOffset, l.endOffset)), this._idx++;
1432
+ const a = this._events[this._idx];
1433
+ a.type === "enter" && a.tokenType === "labelImageMarker" ? t.add(new v("bangBracket", this._source.substring(a.startOffset, a.endOffset)), a.startOffset) : a.type === "enter" && a.tokenType === "labelMarker" ? (t.add(new v(r ? "closeBracket" : "openBracket", this._source.substring(a.startOffset, a.endOffset)), a.startOffset), r = !0) : a.type === "enter" && a.tokenType === "labelText" && (s = this._source.substring(a.startOffset, a.endOffset)), this._idx++;
1434
1434
  }
1435
1435
  this._consume("exit", "label");
1436
1436
  } else if (c.type === "enter" && c.tokenType === "resource") {
1437
1437
  this._consume("enter", "resource");
1438
- let l = !1;
1438
+ let a = !1;
1439
1439
  for (; this._notExit("resource"); ) {
1440
- const a = this._events[this._idx];
1441
- a.type === "enter" && a.tokenType === "resourceMarker" ? (t.add(new k(l ? "closeParen" : "openParen", this._source.substring(a.startOffset, a.endOffset)), a.startOffset), l = !0) : a.type === "enter" && a.tokenType === "resourceDestinationString" && (i = this._source.substring(a.startOffset, a.endOffset)), this._idx++;
1440
+ const l = this._events[this._idx];
1441
+ l.type === "enter" && l.tokenType === "resourceMarker" ? (t.add(new v(a ? "closeParen" : "openParen", this._source.substring(l.startOffset, l.endOffset)), l.startOffset), a = !0) : l.type === "enter" && l.tokenType === "resourceDestinationString" && (i = this._source.substring(l.startOffset, l.endOffset)), this._idx++;
1442
1442
  }
1443
1443
  this._consume("exit", "resource");
1444
1444
  } else
1445
1445
  this._idx++;
1446
1446
  }
1447
1447
  const o = this._consume("exit", "image");
1448
- return { node: new _e(s, i, t.build(o.endOffset - e.startOffset)), start: e.startOffset };
1448
+ return { node: new ve(s, i, t.build(o.endOffset - e.startOffset)), start: e.startOffset };
1449
1449
  }
1450
1450
  _notExit(e) {
1451
1451
  if (this._idx >= this._events.length)
@@ -1460,7 +1460,7 @@ class xn {
1460
1460
  return this._idx++, s;
1461
1461
  }
1462
1462
  }
1463
- class vn {
1463
+ class Mn {
1464
1464
  constructor(e) {
1465
1465
  this._edit = e;
1466
1466
  }
@@ -1495,7 +1495,7 @@ class vn {
1495
1495
  return e - t;
1496
1496
  }
1497
1497
  }
1498
- class bn {
1498
+ class Sn {
1499
1499
  _byRange = /* @__PURE__ */ new Map();
1500
1500
  _byId = /* @__PURE__ */ new Map();
1501
1501
  constructor(e) {
@@ -1518,100 +1518,100 @@ class bn {
1518
1518
  return this._byId.get(`${e}:${t}`);
1519
1519
  }
1520
1520
  }
1521
- function At(n, e, t, s, i) {
1521
+ function Ht(n, e, t, s, i) {
1522
1522
  let r, o = e;
1523
- for (const g of n.children) {
1524
- const d = At(g, o, t, s, i);
1525
- d !== g && (r ??= /* @__PURE__ */ new Map()).set(g, d), o += g.length;
1523
+ for (const u of n.children) {
1524
+ const f = Ht(u, o, t, s, i);
1525
+ f !== u && (r ??= /* @__PURE__ */ new Map()).set(u, f), o += u.length;
1526
1526
  }
1527
1527
  let c = r ? n.mapChildren(r) : n;
1528
- const l = t.getOriginalRange(w.ofStartAndLength(e, n.length));
1529
- if (l) {
1530
- const g = s.lookupExact(l, c.kind);
1531
- if (g && c.equalsShallow(g))
1532
- return g;
1533
- }
1534
- const a = t.getOriginalOffset(e), h = a !== void 0 ? s.lookupId(a, c.kind) : void 0;
1535
- if (h && h.id !== c.id && (c = c.cloneWithId(h.id)), c instanceof D && h instanceof D && a !== void 0) {
1536
- const g = yn(c, h, a, i);
1537
- if (g)
1538
- return g;
1528
+ const a = t.getOriginalRange(_.ofStartAndLength(e, n.length));
1529
+ if (a) {
1530
+ const u = s.lookupExact(a, c.kind);
1531
+ if (u && c.equalsShallow(u))
1532
+ return u;
1533
+ }
1534
+ const l = t.getOriginalOffset(e), h = l !== void 0 ? s.lookupId(l, c.kind) : void 0;
1535
+ if (h && h.id !== c.id && (c = c.cloneWithId(h.id)), c instanceof A && h instanceof A && l !== void 0) {
1536
+ const u = Ln(c, h, l, i);
1537
+ if (u)
1538
+ return u;
1539
1539
  }
1540
1540
  return c;
1541
1541
  }
1542
- function yn(n, e, t, s) {
1542
+ function Ln(n, e, t, s) {
1543
1543
  const i = e.code, r = n.code;
1544
1544
  if (!i || !r || n.language !== e.language || n.openFence?.content !== e.openFence?.content || n.closeFence?.content !== e.closeFence?.content)
1545
1545
  return;
1546
1546
  const o = t + e.codeOffset, c = o + i.length;
1547
- if (!En(s, o, c))
1547
+ if (!Rn(s, o, c))
1548
1548
  return;
1549
- const l = Cn(s, -o);
1550
- if (l.apply(i.content) === r.content)
1551
- return n.withCodeDiff(e, l);
1549
+ const a = In(s, -o);
1550
+ if (a.apply(i.content) === r.content)
1551
+ return n.withCodeDiff(e, a);
1552
1552
  }
1553
- function En(n, e, t) {
1553
+ function Rn(n, e, t) {
1554
1554
  for (const s of n.replacements)
1555
1555
  if (s.replaceRange.start < e || s.replaceRange.endExclusive > t)
1556
1556
  return !1;
1557
1557
  return !0;
1558
1558
  }
1559
- function Cn(n, e) {
1560
- return new E(n.replacements.map((t) => q.replace(t.replaceRange.delta(e), t.newText)));
1559
+ function In(n, e) {
1560
+ return new b(n.replacements.map((t) => j.replace(t.replaceRange.delta(e), t.newText)));
1561
1561
  }
1562
- function On(n, e, t) {
1563
- return At(n, 0, new vn(t), new bn(e), t);
1562
+ function Nn(n, e, t) {
1563
+ return Ht(n, 0, new Mn(t), new Sn(e), t);
1564
1564
  }
1565
- function Tn(n, e, t) {
1566
- const s = wn(n);
1567
- return !e || !t ? s : On(s, e, t);
1565
+ function Bn(n, e, t) {
1566
+ const s = En(n);
1567
+ return !e || !t ? s : Nn(s, e, t);
1568
1568
  }
1569
- class Mn {
1569
+ class Dn {
1570
1570
  parse(e, t, s) {
1571
- return Tn(e.value, t, s);
1571
+ return Bn(e.value, t, s);
1572
1572
  }
1573
1573
  }
1574
- function Sn(n, e, t = 0) {
1574
+ function $n(n, e, t = 0) {
1575
1575
  if (n.children.length === 0) {
1576
- const r = $t(e.substring(t, t + n.length));
1577
- if (n instanceof Ee)
1576
+ const r = Wt(e.substring(t, t + n.length));
1577
+ if (n instanceof pe)
1578
1578
  return r;
1579
- const o = n instanceof k ? n.markerKind : n.kind;
1580
- return `<${o}${Ze(n)}>${r}</${o}>`;
1579
+ const o = n instanceof v ? n.markerKind : n.kind;
1580
+ return `<${o}${st(n)}>${r}</${o}>`;
1581
1581
  }
1582
1582
  let s = "", i = t;
1583
1583
  for (const r of n.children)
1584
- s += Sn(r, e, i), i += r.length;
1585
- return `<${n.kind}${Ze(n)}>${s}</${n.kind}>`;
1584
+ s += $n(r, e, i), i += r.length;
1585
+ return `<${n.kind}${st(n)}>${s}</${n.kind}>`;
1586
1586
  }
1587
- function Ze(n) {
1587
+ function st(n) {
1588
1588
  const e = {};
1589
- return n instanceof J ? e.level = String(n.level) : n instanceof K ? e.ordered = String(n.ordered) : n instanceof D ? n.language && (e.language = n.language) : n instanceof we ? e.url = n.url : n instanceof _e ? (e.alt = n.alt, e.url = n.url) : n instanceof H ? n.checked !== void 0 && (e.checked = String(n.checked)) : n instanceof R && n.glueKind && (e.kind = n.glueKind), Object.entries(e).map(([t, s]) => ` ${t}="${$t(s)}"`).join("");
1589
+ return n instanceof Z ? e.level = String(n.level) : n instanceof W ? e.ordered = String(n.ordered) : n instanceof A ? n.language && (e.language = n.language) : n instanceof ke ? e.url = n.url : n instanceof ve ? (e.alt = n.alt, e.url = n.url) : n instanceof q ? n.checked !== void 0 && (e.checked = String(n.checked)) : n instanceof I && n.glueKind && (e.kind = n.glueKind), Object.entries(e).map(([t, s]) => ` ${t}="${Wt(s)}"`).join("");
1590
1590
  }
1591
- function $t(n) {
1591
+ function Wt(n) {
1592
1592
  return n.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1593
1593
  }
1594
- function Ln(n) {
1595
- return n instanceof Ee ? `text ${JSON.stringify(n.content)}` : n instanceof R ? `glue${n.glueKind ? `(${n.glueKind})` : ""} ${JSON.stringify(n.content)}` : n instanceof k ? `marker(${n.markerKind}) ${JSON.stringify(n.content)}` : n instanceof te ? `thematicBreak ${JSON.stringify(n.content)}` : n instanceof J ? `heading(level=${n.level})` : n instanceof K ? `list(ordered=${n.ordered})` : n instanceof H ? n.checked === void 0 ? "listItem" : `listItem(checked=${n.checked})` : n instanceof D ? `codeBlock(language=${JSON.stringify(n.language)})` : n instanceof ne ? "mathBlock" : n instanceof we ? `link(url=${JSON.stringify(n.url)})` : n instanceof _e ? `image(alt=${JSON.stringify(n.alt)}, url=${JSON.stringify(n.url)})` : n.kind;
1594
+ function An(n) {
1595
+ return n instanceof pe ? `text ${JSON.stringify(n.content)}` : n instanceof I ? `glue${n.glueKind ? `(${n.glueKind})` : ""} ${JSON.stringify(n.content)}` : n instanceof v ? `marker(${n.markerKind}) ${JSON.stringify(n.content)}` : n instanceof te ? `thematicBreak ${JSON.stringify(n.content)}` : n instanceof Z ? `heading(level=${n.level})` : n instanceof W ? `list(ordered=${n.ordered})` : n instanceof q ? n.checked === void 0 ? "listItem" : `listItem(checked=${n.checked})` : n instanceof A ? `codeBlock(language=${JSON.stringify(n.language)})` : n instanceof ne ? "mathBlock" : n instanceof ke ? `link(url=${JSON.stringify(n.url)})` : n instanceof ve ? `image(alt=${JSON.stringify(n.alt)}, url=${JSON.stringify(n.url)})` : n.kind;
1596
1596
  }
1597
- const et = /* @__PURE__ */ new WeakMap();
1598
- let In = 0;
1599
- function Nn(n) {
1600
- let e = et.get(n);
1601
- return e === void 0 && (e = In++, et.set(n, e)), e;
1597
+ const it = /* @__PURE__ */ new WeakMap();
1598
+ let Pn = 0;
1599
+ function Fn(n) {
1600
+ let e = it.get(n);
1601
+ return e === void 0 && (e = Pn++, it.set(n, e)), e;
1602
1602
  }
1603
- function Di(n, e) {
1603
+ function tr(n, e) {
1604
1604
  let t = 0;
1605
1605
  function s(i) {
1606
1606
  const r = t, o = i.children;
1607
1607
  let c;
1608
- return o.length === 0 ? t += i.length : c = o.map(s), { label: `${Ln(i)} #${Nn(i)} nid=${i.id}`, range: [r, t], children: c };
1608
+ return o.length === 0 ? t += i.length : c = o.map(s), { label: `${An(i)} #${Fn(i)} nid=${i.id}`, range: [r, t], children: c };
1609
1609
  }
1610
1610
  return { $fileExtension: "ast.w", source: e, root: s(n) };
1611
1611
  }
1612
- const Rn = Symbol("NO_ACTIVE_BLOCKS");
1613
- class Ai {
1614
- _parser = new Mn();
1612
+ const Vn = Symbol("NO_ACTIVE_BLOCKS");
1613
+ class nr {
1614
+ _parser = new Dn();
1615
1615
  /**
1616
1616
  * The most recent edit applied to {@link sourceText}, used by
1617
1617
  * {@link document} to let the parser link incrementally edited code
@@ -1619,12 +1619,26 @@ class Ai {
1619
1619
  * source text (see {@link document}).
1620
1620
  */
1621
1621
  _pendingEdit;
1622
- sourceText = U(this, new Le(""));
1622
+ sourceText = B(this, new ye(""));
1623
1623
  /**
1624
1624
  * The current selection, or `undefined` when the editor has no caret
1625
1625
  * (e.g. an inactive/unfocused rendering).
1626
1626
  */
1627
- selection = U(this, x.collapsed(0));
1627
+ selection = B(this, k.collapsed(0));
1628
+ /**
1629
+ * Whether a Ctrl/Cmd modifier is currently held. Set by the controller from
1630
+ * live keyboard state; the view reads it to show the link-open affordance
1631
+ * (underline + pointer cursor) only while a Ctrl/Cmd+click would open a link
1632
+ * whose block is active.
1633
+ */
1634
+ ctrlOrMetaDown = B(this, !1);
1635
+ /**
1636
+ * Gutter markers (source-control style change indicators) painted in the
1637
+ * left gutter. Each entry maps a source {@link OffsetRange} to a change kind
1638
+ * — see {@link GutterMarker}. Purely decorative: markers never affect the
1639
+ * parsed {@link document}, selection, or layout. Empty by default.
1640
+ */
1641
+ gutterMarkers = B(this, []);
1628
1642
  /**
1629
1643
  * Forces the rendered active-block set. `undefined` (the default)
1630
1644
  * derives the set from the current selection range (see
@@ -1632,8 +1646,15 @@ class Ai {
1632
1646
  * "no active block" — useful in fixtures that always want the
1633
1647
  * collapsed/inactive rendering.
1634
1648
  */
1635
- activeBlocksOverride = U(this, void 0);
1636
- cursorOffset = V(
1649
+ activeBlocksOverride = B(this, void 0);
1650
+ /**
1651
+ * The transient empty-paragraph editing state, or `undefined` when none is
1652
+ * armed. See {@link PendingParagraph}. This is *not* document data — it is
1653
+ * cleared by any source edit and lives only between the Enter that armed it
1654
+ * and the next keystroke.
1655
+ */
1656
+ pendingParagraph = B(this, void 0);
1657
+ cursorOffset = $(
1637
1658
  this,
1638
1659
  (e) => e.readObservable(this.selection)?.active
1639
1660
  );
@@ -1646,7 +1667,7 @@ class Ai {
1646
1667
  */
1647
1668
  document = (() => {
1648
1669
  let e, t;
1649
- return V(this, (s) => {
1670
+ return $(this, (s) => {
1650
1671
  const i = s.readObservable(this.sourceText), r = this._pendingEdit, o = r && r.baseText === t && r.newText === i.value ? r.edit : void 0, c = this._parser.parse(i, e, o);
1651
1672
  return e = c, t = i.value, c;
1652
1673
  });
@@ -1657,10 +1678,10 @@ class Ai {
1657
1678
  * visible. Unaffected by {@link activeBlocksOverride} because
1658
1679
  * navigation is independent of rendering.
1659
1680
  */
1660
- activeBlock = V(this, (e) => {
1681
+ activeBlock = $(this, (e) => {
1661
1682
  const t = e.readObservable(this.document), s = e.readObservable(this.cursorOffset);
1662
1683
  if (s !== void 0)
1663
- return Ft(t, s);
1684
+ return qt(t, s);
1664
1685
  });
1665
1686
  /**
1666
1687
  * All blocks whose source range intersects the current selection.
@@ -1668,25 +1689,58 @@ class Ai {
1668
1689
  * their expanded (markers-visible) form. When the selection is
1669
1690
  * collapsed this is a one-element set holding {@link activeBlock}.
1670
1691
  */
1671
- activeBlocks = V(this, (e) => {
1692
+ activeBlocks = $(this, (e) => {
1693
+ if (e.readObservable(this.pendingParagraph) !== void 0)
1694
+ return /* @__PURE__ */ new Set();
1672
1695
  const t = e.readObservable(this.activeBlocksOverride);
1673
- if (t === Rn)
1696
+ if (t === Vn)
1674
1697
  return /* @__PURE__ */ new Set();
1675
1698
  if (t !== void 0)
1676
1699
  return new Set(t);
1677
1700
  const s = e.readObservable(this.document), i = e.readObservable(this.selection);
1678
- return i === void 0 ? /* @__PURE__ */ new Set() : new Set(Bn(s, i.range.start, i.range.endExclusive));
1701
+ return i === void 0 ? /* @__PURE__ */ new Set() : new Set(Kn(s, i.range.start, i.range.endExclusive));
1679
1702
  });
1703
+ /**
1704
+ * Arm a {@link PendingParagraph} at the given gap, minting a fresh synthetic
1705
+ * AST node for it, and park the caret at the gap start. No source edit is
1706
+ * applied — the blank line exists only in the view until it is materialized.
1707
+ */
1708
+ armPendingParagraph(e) {
1709
+ this.pendingParagraph.set({ ...e, syntheticAst: new H([]) }, void 0), this.selection.set(k.collapsed(e.replaceRange.start), void 0);
1710
+ }
1711
+ /** Discard the pending paragraph (if any) without touching the source. */
1712
+ cancelPendingParagraph() {
1713
+ this.pendingParagraph.get() !== void 0 && this.pendingParagraph.set(void 0, void 0);
1714
+ }
1715
+ /**
1716
+ * Turn the pending paragraph into real source: rewrite its gap so the typed
1717
+ * `text` becomes its own paragraph, separated from its neighbours by blank
1718
+ * lines, and place the caret after the inserted text.
1719
+ */
1720
+ materializePendingParagraph(e) {
1721
+ const t = this.pendingParagraph.get();
1722
+ if (!t)
1723
+ return;
1724
+ const s = `
1725
+
1726
+ ` + e + (t.atEof ? "" : `
1727
+
1728
+ `), i = t.replaceRange.start + 2 + e.length, r = b.replace(t.replaceRange, s);
1729
+ this.pendingParagraph.set(void 0, void 0);
1730
+ const o = this.sourceText.get(), c = new ye(r.apply(o.value));
1731
+ this._pendingEdit = { baseText: o.value, newText: c.value, edit: r }, this.sourceText.set(c, void 0), this.selection.set(k.collapsed(i), void 0);
1732
+ }
1680
1733
  applyEdit(e) {
1681
- const t = this.sourceText.get(), s = new Le(e.apply(t.value)), i = this.selection.get() ?? x.collapsed(0), r = e.mapOffset(i.active);
1682
- this._pendingEdit = { baseText: t.value, newText: s.value, edit: e }, this.sourceText.set(s, void 0), this.selection.set(x.collapsed(r), void 0);
1734
+ this.cancelPendingParagraph();
1735
+ const t = this.sourceText.get(), s = new ye(e.apply(t.value)), i = this.selection.get() ?? k.collapsed(0), r = e.mapOffset(i.active);
1736
+ this._pendingEdit = { baseText: t.value, newText: s.value, edit: e }, this.sourceText.set(s, void 0), this.selection.set(k.collapsed(r), void 0);
1683
1737
  }
1684
1738
  applyEditForSelection(e) {
1685
- const t = this.sourceText.get(), s = new Le(e.apply(t.value)), i = this.selection.get() ?? x.collapsed(0), r = e.mapOffset(i.range.endExclusive);
1686
- this._pendingEdit = { baseText: t.value, newText: s.value, edit: e }, this.sourceText.set(s, void 0), this.selection.set(x.collapsed(r), void 0);
1739
+ const t = this.sourceText.get(), s = new ye(e.apply(t.value)), i = this.selection.get() ?? k.collapsed(0), r = e.mapOffset(i.range.endExclusive);
1740
+ this._pendingEdit = { baseText: t.value, newText: s.value, edit: e }, this.sourceText.set(s, void 0), this.selection.set(k.collapsed(r), void 0);
1687
1741
  }
1688
1742
  }
1689
- function Ft(n, e) {
1743
+ function qt(n, e) {
1690
1744
  let t = 0, s;
1691
1745
  for (const i of n.children) {
1692
1746
  const r = t + i.length;
@@ -1699,9 +1753,9 @@ function Ft(n, e) {
1699
1753
  }
1700
1754
  return s;
1701
1755
  }
1702
- function Bn(n, e, t) {
1756
+ function Kn(n, e, t) {
1703
1757
  if (e === t) {
1704
- const r = Ft(n, e);
1758
+ const r = qt(n, e);
1705
1759
  return r ? [r] : [];
1706
1760
  }
1707
1761
  const s = [];
@@ -1712,13 +1766,13 @@ function Bn(n, e, t) {
1712
1766
  }
1713
1767
  return s;
1714
1768
  }
1715
- class ke {
1769
+ class xe {
1716
1770
  constructor(e) {
1717
1771
  this.lines = e;
1718
1772
  }
1719
- static EMPTY = new ke([]);
1773
+ static EMPTY = new xe([]);
1720
1774
  static measure(e) {
1721
- return Fn(e);
1775
+ return zn(e);
1722
1776
  }
1723
1777
  get lineCount() {
1724
1778
  return this.lines.length;
@@ -1794,7 +1848,7 @@ class ke {
1794
1848
  return e < 0 || e >= this.lines.length ? 0 : this.lines[e].offsetAtX(t);
1795
1849
  }
1796
1850
  }
1797
- class Dn {
1851
+ class Hn {
1798
1852
  constructor(e, t) {
1799
1853
  this.rect = e, this.runs = t;
1800
1854
  }
@@ -1865,7 +1919,7 @@ class Dn {
1865
1919
  return e <= t.rect.left ? t.sourceRange.start : t.sourceRange.endExclusive;
1866
1920
  }
1867
1921
  }
1868
- class Be {
1922
+ class $e {
1869
1923
  constructor(e, t, s) {
1870
1924
  this.sourceRange = e, this.rect = t, this.source = s;
1871
1925
  }
@@ -1888,7 +1942,7 @@ class Be {
1888
1942
  if (this.sourceLength === 0)
1889
1943
  return this.rect.left;
1890
1944
  if (this.source)
1891
- return An(this.source.textNode, this.source.textNodeStart + (e - this.sourceStart), this.rect.left);
1945
+ return Wn(this.source.textNode, this.source.textNodeStart + (e - this.sourceStart), this.rect.left);
1892
1946
  const t = (e - this.sourceStart) / this.sourceLength;
1893
1947
  return this.rect.left + t * this.rect.width;
1894
1948
  }
@@ -1896,14 +1950,14 @@ class Be {
1896
1950
  if (this.rect.width <= 0)
1897
1951
  return this.sourceStart;
1898
1952
  if (this.source) {
1899
- const s = $n(this.source.textNode, this.source.textNodeStart, this.source.textNodeStart + this.sourceLength, e);
1953
+ const s = qn(this.source.textNode, this.source.textNodeStart, this.source.textNodeStart + this.sourceLength, e);
1900
1954
  return this.sourceStart + (s - this.source.textNodeStart);
1901
1955
  }
1902
1956
  const t = (e - this.rect.left) / this.rect.width;
1903
1957
  return this.sourceStart + Math.round(t * this.sourceLength);
1904
1958
  }
1905
1959
  }
1906
- function An(n, e, t) {
1960
+ function Wn(n, e, t) {
1907
1961
  if (e <= 0)
1908
1962
  return t;
1909
1963
  const s = document.createRange();
@@ -1911,82 +1965,82 @@ function An(n, e, t) {
1911
1965
  const i = s.getBoundingClientRect();
1912
1966
  return i.width === 0 && i.height === 0 ? t : i.right;
1913
1967
  }
1914
- function $n(n, e, t, s) {
1968
+ function qn(n, e, t, s) {
1915
1969
  const i = document.createRange();
1916
1970
  let r = e, o = 1 / 0;
1917
1971
  for (let c = e; c < t; c++) {
1918
1972
  i.setStart(n, c), i.setEnd(n, c + 1);
1919
- const l = i.getBoundingClientRect();
1920
- if (l.width === 0 && l.height === 0)
1973
+ const a = i.getBoundingClientRect();
1974
+ if (a.width === 0 && a.height === 0)
1921
1975
  continue;
1922
- const a = (l.left + l.right) / 2, h = Math.abs(s - l.left), g = Math.abs(s - l.right);
1923
- if (h < o && (o = h, r = c), g < o && (o = g, r = c + 1), s >= l.left && s <= l.right)
1924
- return s < a ? c : c + 1;
1976
+ const l = (a.left + a.right) / 2, h = Math.abs(s - a.left), u = Math.abs(s - a.right);
1977
+ if (h < o && (o = h, r = c), u < o && (o = u, r = c + 1), s >= a.left && s <= a.right)
1978
+ return s < l ? c : c + 1;
1925
1979
  }
1926
1980
  return r;
1927
1981
  }
1928
- function Fn(n) {
1982
+ function zn(n) {
1929
1983
  const e = [];
1930
- for (const a of n) {
1984
+ for (const l of n) {
1931
1985
  const h = e.length;
1932
- a.viewNode.forEachTextLeaf(a.absoluteStart, (g, d) => {
1933
- const u = g.dom;
1934
- if (u.length === 0)
1986
+ l.viewNode.forEachTextLeaf(l.absoluteStart, (u, f) => {
1987
+ const d = u.dom;
1988
+ if (d.length === 0)
1935
1989
  return;
1936
- const f = document.createRange();
1937
- f.selectNodeContents(u);
1938
- const p = f.getClientRects();
1990
+ const g = document.createRange();
1991
+ g.selectNodeContents(d);
1992
+ const p = g.getClientRects();
1939
1993
  if (p.length === 0)
1940
1994
  return;
1941
- const m = Pn(u);
1995
+ const m = jn(d);
1942
1996
  if (p.length === 1)
1943
- e.push(new Be(
1944
- w.fromTo(d, d + u.length),
1945
- tt(p[0], m),
1946
- { textNode: u, textNodeStart: 0 }
1997
+ e.push(new $e(
1998
+ _.fromTo(f, f + d.length),
1999
+ rt(p[0], m),
2000
+ { textNode: d, textNodeStart: 0 }
1947
2001
  ));
1948
2002
  else {
1949
- const _ = Vn(u, p);
1950
- for (let v = 0; v < p.length; v++) {
1951
- const y = v === 0 ? 0 : _[v - 1], M = v < _.length ? _[v] : u.length;
1952
- e.push(new Be(
1953
- w.fromTo(d + y, d + M),
1954
- tt(p[v], m),
1955
- { textNode: u, textNodeStart: y }
2003
+ const w = Gn(d, p);
2004
+ for (let x = 0; x < p.length; x++) {
2005
+ const E = x === 0 ? 0 : w[x - 1], M = x < w.length ? w[x] : d.length;
2006
+ e.push(new $e(
2007
+ _.fromTo(f + E, f + M),
2008
+ rt(p[x], m),
2009
+ { textNode: d, textNodeStart: E }
1956
2010
  ));
1957
2011
  }
1958
2012
  }
1959
- }), e.length === h && Kn(e, a.viewNode, a.absoluteStart);
2013
+ }), e.length === h && Xn(e, l.viewNode, l.absoluteStart);
1960
2014
  }
1961
- e.sort((a, h) => a.rect.y - h.rect.y || a.rect.x - h.rect.x);
2015
+ e.sort((l, h) => l.rect.y - h.rect.y || l.rect.x - h.rect.x);
1962
2016
  const t = [];
1963
2017
  let s = [], i = -1 / 0, r = 0, o = 1 / 0, c = -1 / 0;
1964
- const l = () => {
1965
- s.length !== 0 && t.push(new Dn(
1966
- B.fromPointPoint(o, i, c, i + r),
2018
+ const a = () => {
2019
+ s.length !== 0 && t.push(new Hn(
2020
+ D.fromPointPoint(o, i, c, i + r),
1967
2021
  s
1968
2022
  ));
1969
2023
  };
1970
- for (const a of e) {
1971
- const h = a.rect, g = Math.min(i + r, h.y + h.height) - Math.max(i, h.y);
1972
- s.length > 0 && g > Math.min(r, h.height) / 2 ? (s.push(a), r = Math.max(r, h.y + h.height - i), o = Math.min(o, h.left), c = Math.max(c, h.right)) : (l(), s = [a], i = h.y, r = h.height, o = h.left, c = h.right);
2024
+ for (const l of e) {
2025
+ const h = l.rect, u = Math.min(i + r, h.y + h.height) - Math.max(i, h.y);
2026
+ s.length > 0 && u > Math.min(r, h.height) / 2 ? (s.push(l), r = Math.max(r, h.y + h.height - i), o = Math.min(o, h.left), c = Math.max(c, h.right)) : (a(), s = [l], i = h.y, r = h.height, o = h.left, c = h.right);
1973
2027
  }
1974
- return l(), new ke(t);
2028
+ return a(), new xe(t);
1975
2029
  }
1976
- function Vn(n, e) {
2030
+ function Gn(n, e) {
1977
2031
  const t = [], s = document.createRange();
1978
2032
  for (let i = 0; i < e.length - 1; i++) {
1979
2033
  const r = e[i + 1].y;
1980
2034
  let o = i === 0 ? 0 : t[i - 1], c = n.length;
1981
2035
  for (; o < c; ) {
1982
- const l = o + c >>> 1;
1983
- s.setStart(n, l), s.setEnd(n, Math.min(l + 1, n.length)), s.getBoundingClientRect().y < r - 1 ? o = l + 1 : c = l;
2036
+ const a = o + c >>> 1;
2037
+ s.setStart(n, a), s.setEnd(n, Math.min(a + 1, n.length)), s.getBoundingClientRect().y < r - 1 ? o = a + 1 : c = a;
1984
2038
  }
1985
2039
  t.push(o);
1986
2040
  }
1987
2041
  return t;
1988
2042
  }
1989
- function Pn(n) {
2043
+ function jn(n) {
1990
2044
  const e = n.parentElement;
1991
2045
  if (!e)
1992
2046
  return 0;
@@ -1994,56 +2048,56 @@ function Pn(n) {
1994
2048
  let s = parseFloat(t.lineHeight);
1995
2049
  return isFinite(s) || (s = parseFloat(t.fontSize) * 1.2), s;
1996
2050
  }
1997
- function tt(n, e) {
2051
+ function rt(n, e) {
1998
2052
  if (e <= n.height)
1999
- return B.fromPointSize(n.x, n.y, n.width, n.height);
2053
+ return D.fromPointSize(n.x, n.y, n.width, n.height);
2000
2054
  const t = (e - n.height) / 2;
2001
- return B.fromPointSize(n.x, n.y - t, n.width, e);
2055
+ return D.fromPointSize(n.x, n.y - t, n.width, e);
2002
2056
  }
2003
- function Kn(n, e, t) {
2057
+ function Xn(n, e, t) {
2004
2058
  const s = e.dom;
2005
2059
  if (s.nodeType !== 1)
2006
2060
  return;
2007
2061
  const i = s.getBoundingClientRect();
2008
- i.width === 0 && i.height === 0 || n.push(new Be(
2009
- w.fromTo(t, t + e.sourceLength),
2010
- B.fromPointSize(i.x, i.y, i.width, i.height)
2062
+ i.width === 0 && i.height === 0 || n.push(new $e(
2063
+ _.fromTo(t, t + e.sourceLength),
2064
+ D.fromPointSize(i.x, i.y, i.width, i.height)
2011
2065
  ));
2012
2066
  }
2013
- class Hn {
2014
- measurements = U(this, []);
2067
+ class Qn {
2068
+ measurements = B(this, []);
2015
2069
  /**
2016
2070
  * Concatenated visual line map across all mounted blocks. Lines are
2017
2071
  * left in DOM (client-coordinate) y order — each per-block map already
2018
2072
  * uses absolute client coordinates from `getClientRects()`, so the
2019
2073
  * concatenation is well-formed without re-sorting.
2020
2074
  */
2021
- visualLineMap = V(this, (e) => {
2075
+ visualLineMap = $(this, (e) => {
2022
2076
  const s = e.readObservable(this.measurements).flatMap((i) => i.visualLineMap?.lines ?? []);
2023
- return new ke(s);
2077
+ return new xe(s);
2024
2078
  });
2025
2079
  }
2026
- function Vt(n, e, t, s) {
2080
+ function zt(n, e, t, s) {
2027
2081
  let i = s === "right" ? t + 1 : t - 1, r = 0;
2028
2082
  for (const o of n.children) {
2029
2083
  if (n.blocks.includes(o)) {
2030
- const l = o, a = Wn(l, l === e, t - r);
2031
- i = qn(i, r, a, s);
2084
+ const a = o, l = Un(a, a === e, t - r);
2085
+ i = Yn(i, r, l, s);
2032
2086
  }
2033
2087
  r += o.length;
2034
2088
  }
2035
2089
  return s === "right" ? Math.min(i, n.length) : Math.max(i, 0);
2036
2090
  }
2037
- function Wn(n, e, t) {
2091
+ function Un(n, e, t) {
2038
2092
  if (!e)
2039
- return Gn(n);
2093
+ return Zn(n);
2040
2094
  if (n.kind === "list") {
2041
- const s = Pt(n, t);
2042
- return jn(n, s);
2095
+ const s = Ge(n, t);
2096
+ return Jn(n, s);
2043
2097
  }
2044
2098
  return [];
2045
2099
  }
2046
- function qn(n, e, t, s) {
2100
+ function Yn(n, e, t, s) {
2047
2101
  if (s === "right")
2048
2102
  for (const i of t) {
2049
2103
  const r = n - e;
@@ -2056,7 +2110,7 @@ function qn(n, e, t, s) {
2056
2110
  }
2057
2111
  return n;
2058
2112
  }
2059
- function Pt(n, e) {
2113
+ function Ge(n, e) {
2060
2114
  let t = 0, s;
2061
2115
  for (let i = 0; i < n.children.length; i++) {
2062
2116
  const r = n.children[i], o = t + r.length, c = n.items.indexOf(r);
@@ -2069,26 +2123,26 @@ function Pt(n, e) {
2069
2123
  }
2070
2124
  return s;
2071
2125
  }
2072
- function jn(n, e) {
2126
+ function Jn(n, e) {
2073
2127
  const t = [];
2074
2128
  let s = 0;
2075
2129
  for (const i of n.children) {
2076
2130
  const r = n.items.indexOf(i);
2077
2131
  if (r >= 0 && r !== e) {
2078
2132
  const o = n.items[r];
2079
- qe(o, s, t);
2133
+ je(o, s, t);
2080
2134
  }
2081
2135
  s += i.length;
2082
2136
  }
2083
2137
  return t.sort((i, r) => i.start - r.start), t;
2084
2138
  }
2085
- function Gn(n) {
2139
+ function Zn(n) {
2086
2140
  const e = [];
2087
- return qe(n, 0, e), e.sort((t, s) => t.start - s.start), e;
2141
+ return je(n, 0, e), e.sort((t, s) => t.start - s.start), e;
2088
2142
  }
2089
- function qe(n, e, t) {
2143
+ function je(n, e, t) {
2090
2144
  if (n.children.length === 0) {
2091
- n instanceof k && t.push(w.ofStartAndLength(e, n.length));
2145
+ n instanceof v && t.push(_.ofStartAndLength(e, n.length));
2092
2146
  return;
2093
2147
  }
2094
2148
  switch (n.kind) {
@@ -2096,141 +2150,276 @@ function qe(n, e, t) {
2096
2150
  case "mathBlock": {
2097
2151
  let i = e;
2098
2152
  for (const r of n.children)
2099
- r instanceof k && (r.markerKind === "openFence" || r.markerKind === "closeFence") && t.push(w.ofStartAndLength(i, r.length)), i += r.length;
2153
+ r instanceof v && (r.markerKind === "openFence" || r.markerKind === "closeFence") && t.push(_.ofStartAndLength(i, r.length)), i += r.length;
2100
2154
  return;
2101
2155
  }
2102
2156
  case "inlineCode":
2103
2157
  case "inlineMath": {
2104
2158
  let i = e;
2105
2159
  for (const r of n.children)
2106
- r instanceof k && (r.markerKind === "openMarker" || r.markerKind === "closeMarker") && t.push(w.ofStartAndLength(i, r.length)), i += r.length;
2160
+ r instanceof v && (r.markerKind === "openMarker" || r.markerKind === "closeMarker") && t.push(_.ofStartAndLength(i, r.length)), i += r.length;
2107
2161
  return;
2108
2162
  }
2109
2163
  case "thematicBreak":
2110
2164
  return;
2111
2165
  case "image": {
2112
- t.push(w.ofStartAndLength(e, n.length));
2166
+ t.push(_.ofStartAndLength(e, n.length));
2113
2167
  return;
2114
2168
  }
2115
2169
  }
2116
2170
  let s = e;
2117
2171
  for (const i of n.children)
2118
- qe(i, s, t), s += i.length;
2172
+ je(i, s, t), s += i.length;
2119
2173
  }
2120
- const zn = (n) => n.selection.isCollapsed ? Math.min(n.selection.active + 1, n.text.length) : n.selection.range.endExclusive, Xn = (n) => n.selection.isCollapsed ? Math.max(n.selection.active - 1, 0) : n.selection.range.start, Qn = (n) => Math.min(n.selection.active + 1, n.text.length), Un = (n) => Math.max(n.selection.active - 1, 0), Yn = (n) => Rt(n.text, n.selection.active), nt = (n) => Nt(n.text, n.selection.active), Jn = (n) => n.text.lastIndexOf(`
2121
- `, n.selection.active - 1) + 1, Zn = (n) => {
2174
+ const es = (n) => n.selection.isCollapsed ? Math.min(n.selection.active + 1, n.text.length) : n.selection.range.endExclusive, ts = (n) => n.selection.isCollapsed ? Math.max(n.selection.active - 1, 0) : n.selection.range.start, ns = (n) => Math.min(n.selection.active + 1, n.text.length), ss = (n) => Math.max(n.selection.active - 1, 0), is = (n) => Pt(n.text, n.selection.active), ot = (n) => At(n.text, n.selection.active), rs = (n) => n.text.lastIndexOf(`
2175
+ `, n.selection.active - 1) + 1, os = (n) => {
2122
2176
  const e = n.text.indexOf(`
2123
2177
  `, n.selection.active);
2124
2178
  return e === -1 ? n.text.length : e;
2125
- }, es = () => 0, ts = (n) => n.text.length, st = (n) => {
2179
+ }, cs = () => 0, as = (n) => n.text.length, ct = (n) => {
2126
2180
  const e = n.lineMap.lineIndexOfOffset(n.selection.active), t = n.desiredColumn ?? n.lineMap.xAtOffset(n.selection.active);
2127
2181
  return e >= n.lineMap.lineCount - 1 ? { offset: n.selection.active, desiredColumn: t } : { offset: n.lineMap.offsetInLineAtX(e + 1, t), desiredColumn: t };
2128
- }, it = (n) => {
2182
+ }, at = (n) => {
2129
2183
  const e = n.lineMap.lineIndexOfOffset(n.selection.active), t = n.desiredColumn ?? n.lineMap.xAtOffset(n.selection.active);
2130
2184
  return e <= 0 ? { offset: n.selection.active, desiredColumn: t } : { offset: n.lineMap.offsetInLineAtX(e - 1, t), desiredColumn: t };
2131
- }, rt = (n) => {
2185
+ }, lt = (n) => {
2132
2186
  const e = n.selection;
2133
2187
  if (!e.isCollapsed)
2134
2188
  return {
2135
- edit: E.delete(e.range),
2136
- selection: x.collapsed(e.range.start)
2189
+ edit: b.delete(e.range),
2190
+ selection: k.collapsed(e.range.start)
2137
2191
  };
2138
2192
  if (e.active === 0)
2139
2193
  return;
2140
- const t = new w(Vt(n.document, n.activeBlock, e.active, "left"), e.active);
2194
+ const t = new _(zt(n.document, n.activeBlock, e.active, "left"), e.active);
2141
2195
  return {
2142
- edit: E.delete(t),
2143
- selection: x.collapsed(t.start)
2196
+ edit: b.delete(t),
2197
+ selection: k.collapsed(t.start)
2144
2198
  };
2145
- }, ns = (n) => {
2199
+ }, ls = (n) => {
2146
2200
  const e = n.selection;
2147
2201
  if (!e.isCollapsed)
2148
2202
  return {
2149
- edit: E.delete(e.range),
2150
- selection: x.collapsed(e.range.start)
2203
+ edit: b.delete(e.range),
2204
+ selection: k.collapsed(e.range.start)
2151
2205
  };
2152
2206
  if (e.active >= n.text.length)
2153
2207
  return;
2154
- const t = new w(e.active, Vt(n.document, n.activeBlock, e.active, "right"));
2208
+ const t = new _(e.active, zt(n.document, n.activeBlock, e.active, "right"));
2155
2209
  return {
2156
- edit: E.delete(t),
2157
- selection: x.collapsed(t.start)
2210
+ edit: b.delete(t),
2211
+ selection: k.collapsed(t.start)
2158
2212
  };
2159
- }, ss = (n) => {
2213
+ }, hs = (n) => {
2160
2214
  const e = n.selection;
2161
2215
  if (!e.isCollapsed)
2162
2216
  return {
2163
- edit: E.delete(e.range),
2164
- selection: x.collapsed(e.range.start)
2217
+ edit: b.delete(e.range),
2218
+ selection: k.collapsed(e.range.start)
2165
2219
  };
2166
2220
  if (e.active === 0)
2167
2221
  return;
2168
- const t = Nt(n.text, e.active), s = new w(t, e.active);
2222
+ const t = At(n.text, e.active), s = new _(t, e.active);
2169
2223
  return {
2170
- edit: E.delete(s),
2171
- selection: x.collapsed(t)
2224
+ edit: b.delete(s),
2225
+ selection: k.collapsed(t)
2172
2226
  };
2173
- }, is = (n) => {
2227
+ }, ds = (n) => {
2174
2228
  const e = n.selection;
2175
2229
  if (!e.isCollapsed)
2176
2230
  return {
2177
- edit: E.delete(e.range),
2178
- selection: x.collapsed(e.range.start)
2231
+ edit: b.delete(e.range),
2232
+ selection: k.collapsed(e.range.start)
2179
2233
  };
2180
2234
  if (e.active >= n.text.length)
2181
2235
  return;
2182
- const t = Rt(n.text, e.active), s = new w(e.active, t);
2236
+ const t = Pt(n.text, e.active), s = new _(e.active, t);
2183
2237
  return {
2184
- edit: E.delete(s),
2185
- selection: x.collapsed(e.active)
2238
+ edit: b.delete(s),
2239
+ selection: k.collapsed(e.active)
2186
2240
  };
2187
2241
  };
2188
- function rs(n) {
2242
+ function us(n) {
2189
2243
  return (e) => {
2190
- const t = E.replace(e.selection.range, n), s = e.selection.range.start + n.length;
2244
+ const t = b.replace(e.selection.range, n), s = e.selection.range.start + n.length;
2191
2245
  return {
2192
2246
  edit: t,
2193
- selection: x.collapsed(s)
2247
+ selection: k.collapsed(s)
2194
2248
  };
2195
2249
  };
2196
2250
  }
2197
- const os = (n) => {
2198
- const e = E.replace(n.selection.range, `
2251
+ const fs = (n) => {
2252
+ const e = b.replace(n.selection.range, `
2199
2253
 
2200
2254
  `), t = n.selection.range.start + 2;
2201
2255
  return {
2202
2256
  edit: e,
2203
- selection: x.collapsed(t)
2257
+ selection: k.collapsed(t)
2204
2258
  };
2205
- }, cs = (n) => {
2206
- const e = E.replace(n.selection.range, `
2259
+ }, gs = (n) => {
2260
+ const e = b.replace(n.selection.range, `
2207
2261
  `), t = n.selection.range.start + 1;
2208
2262
  return {
2209
2263
  edit: e,
2210
- selection: x.collapsed(t)
2264
+ selection: k.collapsed(t)
2211
2265
  };
2212
- }, ls = (n) => {
2266
+ }, ps = (n) => {
2213
2267
  const e = n.selection.range.start;
2214
2268
  let t = 0;
2215
2269
  for (; t < 2 && n.text[e - 1 - t] === " "; )
2216
2270
  t++;
2217
2271
  const i = " ".repeat(2 - t) + `
2218
- `, r = E.replace(n.selection.range, i), o = e + i.length;
2272
+ `, r = b.replace(n.selection.range, i), o = e + i.length;
2219
2273
  return {
2220
2274
  edit: r,
2221
- selection: x.collapsed(o)
2275
+ selection: k.collapsed(o)
2276
+ };
2277
+ }, ms = (n) => {
2278
+ const e = n.selection, t = n.activeBlock;
2279
+ if (!e.isCollapsed || !t)
2280
+ return ce(n);
2281
+ switch (t.kind) {
2282
+ case "paragraph":
2283
+ case "heading":
2284
+ case "thematicBreak":
2285
+ return _s(n, t);
2286
+ case "codeBlock":
2287
+ return ws(n);
2288
+ case "blockQuote":
2289
+ return ks(n);
2290
+ case "list":
2291
+ return vs(n, t);
2292
+ default:
2293
+ return ce(n);
2294
+ }
2295
+ };
2296
+ function _s(n, e) {
2297
+ const t = n.selection, s = Xt(n.document, e);
2298
+ if (s === void 0)
2299
+ return ce(n);
2300
+ const i = s + e.length - ys(e);
2301
+ if (t.active < i)
2302
+ return {
2303
+ kind: "edit",
2304
+ edit: b.replace(t.range, `
2305
+
2306
+ `),
2307
+ selection: k.collapsed(t.range.start + 2)
2308
+ };
2309
+ const r = s + e.length;
2310
+ return {
2311
+ kind: "pending",
2312
+ anchorBlock: e,
2313
+ replaceRange: new _(i, r),
2314
+ atEof: r >= n.text.length
2315
+ };
2316
+ }
2317
+ function ws(n) {
2318
+ const e = n.selection, t = n.text.lastIndexOf(`
2319
+ `, e.active - 1) + 1;
2320
+ let s = t;
2321
+ for (; s < e.active && (n.text[s] === " " || n.text[s] === " "); )
2322
+ s++;
2323
+ const i = `
2324
+ ` + n.text.slice(t, s);
2325
+ return Xe(e, i);
2326
+ }
2327
+ function ks(n) {
2328
+ const e = n.selection, t = n.text.lastIndexOf(`
2329
+ `, e.active - 1) + 1, s = bs(n.text, e.active), i = n.text.slice(t, s), r = /^(\s*(?:>\s*)+)/.exec(i), o = r ? r[1] : "> ";
2330
+ if (i.slice(o.length).trim() === "")
2331
+ return Gt(n, t, s);
2332
+ const a = `
2333
+ ` + o.replace(/\s*$/, " ");
2334
+ return Xe(e, a);
2335
+ }
2336
+ function vs(n, e) {
2337
+ const t = n.selection, s = Xt(n.document, e);
2338
+ if (s === void 0)
2339
+ return ce(n);
2340
+ const i = Ge(e, t.active - s);
2341
+ if (i === void 0)
2342
+ return ce(n);
2343
+ const r = e.items[i], o = Ft(n.document, r);
2344
+ if (o === void 0)
2345
+ return ce(n);
2346
+ if (!jt(r))
2347
+ return Gt(n, o, o + r.length);
2348
+ const c = `
2349
+ ` + xs(e, r);
2350
+ return Xe(t, c);
2351
+ }
2352
+ function Gt(n, e, t) {
2353
+ const s = e > 0 ? n.text.lastIndexOf(`
2354
+ `, e - 1) : -1;
2355
+ return s >= 0 ? {
2356
+ kind: "edit",
2357
+ edit: b.replace(new _(s, t), `
2358
+
2359
+ `),
2360
+ selection: k.collapsed(s + 2)
2361
+ } : {
2362
+ kind: "edit",
2363
+ edit: b.replace(new _(e, t), ""),
2364
+ selection: k.collapsed(e)
2365
+ };
2366
+ }
2367
+ function xs(n, e) {
2368
+ const t = e.marker.content.trim(), s = t.charAt(0) || "-";
2369
+ if (e.checked !== void 0)
2370
+ return `${s} [ ] `;
2371
+ if (n.ordered) {
2372
+ const i = /^(\d+)([.)])/.exec(t);
2373
+ if (i)
2374
+ return `${Number(i[1]) + 1}${i[2]} `;
2375
+ }
2376
+ return `${s} `;
2377
+ }
2378
+ function Xe(n, e) {
2379
+ return {
2380
+ kind: "edit",
2381
+ edit: b.replace(n.range, e),
2382
+ selection: k.collapsed(n.range.start + e.length)
2222
2383
  };
2223
- }, as = (n) => new x(0, n.text.length), hs = (n, e) => {
2224
- const t = dn(n.text, e);
2225
- return new x(t.start, t.end);
2384
+ }
2385
+ function bs(n, e) {
2386
+ const t = n.indexOf(`
2387
+ `, e);
2388
+ return t === -1 ? n.length : t;
2389
+ }
2390
+ function jt(n) {
2391
+ return n instanceof pe ? n.content.trim().length > 0 : n.children.some(jt);
2392
+ }
2393
+ function ce(n) {
2394
+ const e = gs(n);
2395
+ return { kind: "edit", edit: e.edit, selection: e.selection };
2396
+ }
2397
+ function Xt(n, e) {
2398
+ let t = 0;
2399
+ for (const s of n.children) {
2400
+ if (s === e)
2401
+ return t;
2402
+ t += s.length;
2403
+ }
2404
+ }
2405
+ function ys(n) {
2406
+ const e = n.children;
2407
+ let t = 0;
2408
+ for (let s = e.length - 1; s >= 0 && e[s] instanceof I; s--)
2409
+ t += e[s].length;
2410
+ return t;
2411
+ }
2412
+ const Es = (n) => new k(0, n.text.length), Cs = (n, e) => {
2413
+ const t = kn(n.text, e);
2414
+ return new k(t.start, t.end);
2226
2415
  };
2227
- function ds(n, e) {
2228
- return new x(e.start, e.endExclusive);
2416
+ function Os(n, e) {
2417
+ return new k(e.start, e.endExclusive);
2229
2418
  }
2230
- const ot = /* @__PURE__ */ new WeakMap(), Ne = /* @__PURE__ */ new WeakMap();
2231
- class ae extends le {
2232
- constructor(e, t, s = us) {
2233
- super(), this.ast = e, this.dom = t, this._children = s, ot.set(t, this);
2419
+ const ht = /* @__PURE__ */ new WeakMap(), Ne = /* @__PURE__ */ new WeakMap();
2420
+ class ie extends se {
2421
+ constructor(e, t, s = Ts) {
2422
+ super(), this.ast = e, this.dom = t, this._children = s, ht.set(t, this);
2234
2423
  for (const i of s)
2235
2424
  Ne.set(i, this);
2236
2425
  }
@@ -2289,7 +2478,7 @@ class ae extends le {
2289
2478
  */
2290
2479
  static forDom(e) {
2291
2480
  for (let t = e; t; t = t.parentNode) {
2292
- const s = ot.get(t);
2481
+ const s = ht.get(t);
2293
2482
  if (s)
2294
2483
  return s;
2295
2484
  }
@@ -2324,7 +2513,7 @@ class ae extends le {
2324
2513
  * edge by x).
2325
2514
  */
2326
2515
  getLocalSourceRange(e) {
2327
- return this.dom === e.node && this.dom.nodeType === 3 ? w.emptyAt(Math.max(0, Math.min(e.offset, this.sourceLength))) : w.emptyAt(0);
2516
+ return this.dom === e.node && this.dom.nodeType === 3 ? _.emptyAt(Math.max(0, Math.min(e.offset, this.sourceLength))) : _.emptyAt(0);
2328
2517
  }
2329
2518
  /**
2330
2519
  * DOM hit (any node + offset within it) → source offset relative to THIS
@@ -2335,7 +2524,7 @@ class ae extends le {
2335
2524
  * until it reaches this node.
2336
2525
  */
2337
2526
  resolveSource(e) {
2338
- let t = ae.forDom(e.node);
2527
+ let t = ie.forDom(e.node);
2339
2528
  if (!t)
2340
2529
  return;
2341
2530
  let s = t.getLocalSourceRange(e);
@@ -2379,8 +2568,8 @@ class ae extends le {
2379
2568
  i.forEachTextLeaf(s, t), s += i.sourceLength;
2380
2569
  }
2381
2570
  }
2382
- const us = [];
2383
- class T extends ae {
2571
+ const Ts = [];
2572
+ class T extends ie {
2384
2573
  constructor(e, t, s) {
2385
2574
  super(e.ast, t, s), this.data = e;
2386
2575
  }
@@ -2409,7 +2598,7 @@ class T extends ae {
2409
2598
  recordMeasuredHeight(e) {
2410
2599
  }
2411
2600
  }
2412
- function Y(n, e, t) {
2601
+ function J(n, e, t) {
2413
2602
  if (t instanceof T) {
2414
2603
  if (t.canReuse(n))
2415
2604
  return t;
@@ -2417,67 +2606,67 @@ function Y(n, e, t) {
2417
2606
  return t;
2418
2607
  switch (n.kind) {
2419
2608
  case "text":
2420
- return ms(n, L(t, je));
2609
+ return Rs(n, L(t, Qe));
2421
2610
  case "marker":
2422
- return n.ast.markerKind === "hardBreak" ? new at(n, L(t, at)) : new lt(n, L(t, lt));
2611
+ return n.ast.markerKind === "hardBreak" ? new ft(n, L(t, ft)) : new ut(n, L(t, ut));
2423
2612
  case "glue":
2424
- return new Ce(n, L(t, Ce));
2613
+ return new Te(n, L(t, Te));
2425
2614
  case "heading":
2426
- return new ht(n, e, L(t, ht));
2615
+ return new gt(n, e, L(t, gt));
2427
2616
  case "paragraph":
2428
- return new W(n, "p", "md-block md-paragraph", e, Q(t));
2617
+ return new z(n, "p", "md-block md-paragraph", e, Y(t));
2429
2618
  case "codeBlock":
2430
- return new Ge(n, e, t);
2619
+ return new Ue(n, e, t);
2431
2620
  case "mathBlock":
2432
- return new ft(n, e, L(t, ft));
2621
+ return new _t(n, e, L(t, _t));
2433
2622
  case "thematicBreak":
2434
- return new dt(n, e, L(t, dt));
2623
+ return new pt(n, e, L(t, pt));
2435
2624
  case "blockQuote":
2436
- return new W(n, "blockquote", "md-block md-blockquote", e, Q(t));
2625
+ return new z(n, "blockquote", "md-block md-blockquote", e, Y(t));
2437
2626
  case "list":
2438
- return new gt(n, e, L(t, gt));
2627
+ return new wt(n, e, L(t, wt));
2439
2628
  case "listItem":
2440
- return new pt(n, e, L(t, pt));
2629
+ return new kt(n, e, L(t, kt));
2441
2630
  case "table":
2442
- return new W(n, "table", "md-block md-table", e, Q(t));
2631
+ return new z(n, "table", "md-block md-table", e, Y(t));
2443
2632
  case "tableRow":
2444
- return new mt(n, e, L(t, mt));
2633
+ return new vt(n, e, L(t, vt));
2445
2634
  case "tableCell":
2446
- return new W(n, "td", "", e, Q(t));
2635
+ return new z(n, "td", "", e, Y(t));
2447
2636
  case "strong":
2448
- return new W(n, "strong", "", e, Q(t));
2637
+ return new z(n, "strong", "", e, Y(t));
2449
2638
  case "emphasis":
2450
- return new W(n, "em", "", e, Q(t));
2639
+ return new z(n, "em", "", e, Y(t));
2451
2640
  case "strikethrough":
2452
- return new W(n, "del", "", e, Q(t));
2641
+ return new z(n, "del", "", e, Y(t));
2453
2642
  case "inlineCode":
2454
- return new wt(n, e, L(t, wt));
2643
+ return new xt(n, e, L(t, xt));
2455
2644
  case "inlineMath":
2456
- return new _t(n, e, L(t, _t));
2645
+ return new bt(n, e, L(t, bt));
2457
2646
  case "link":
2458
- return new kt(n, e, L(t, kt));
2647
+ return new yt(n, e, L(t, yt));
2459
2648
  case "image":
2460
- return new xt(n, e, L(t, xt));
2649
+ return new Et(n, e, L(t, Et));
2461
2650
  case "document":
2462
- return new W(n, "div", "", e, Q(t));
2651
+ return new z(n, "div", "", e, Y(t));
2463
2652
  }
2464
2653
  }
2465
2654
  function L(n, e) {
2466
2655
  return n instanceof e ? n : void 0;
2467
2656
  }
2468
- function Q(n) {
2469
- return n instanceof W ? n : void 0;
2657
+ function Y(n) {
2658
+ return n instanceof z ? n : void 0;
2470
2659
  }
2471
- function X(n, e, t, s) {
2472
- const { paired: i, unused: r } = ze(e, t ?? S), o = e.map((c) => s(c, i.get(c)));
2660
+ function U(n, e, t, s) {
2661
+ const { paired: i, unused: r } = Ye(e, t ?? S), o = e.map((c) => s(c, i.get(c)));
2473
2662
  for (const c of r)
2474
2663
  c.dispose();
2475
- return fs(n, o), o;
2664
+ return Ms(n, o), o;
2476
2665
  }
2477
- function fs(n, e) {
2478
- fe(n, e.map((t) => t.mountNode));
2666
+ function Ms(n, e) {
2667
+ ge(n, e.map((t) => t.mountNode));
2479
2668
  }
2480
- function fe(n, e) {
2669
+ function ge(n, e) {
2481
2670
  let t = n.firstChild, s = 0;
2482
2671
  for (; s < e.length && t === e[s]; s++)
2483
2672
  t = t.nextSibling;
@@ -2492,61 +2681,61 @@ function fe(n, e) {
2492
2681
  }
2493
2682
  }
2494
2683
  }
2495
- function se(n) {
2496
- return (e, t) => Y(e, n, t);
2684
+ function re(n) {
2685
+ return (e, t) => J(e, n, t);
2497
2686
  }
2498
- function Kt(n) {
2499
- return (e, t) => e.kind === "marker" && e.ast.markerKind === "content" ? new je(e, document.createTextNode(e.ast.content)) : Y(e, n, t);
2687
+ function Qt(n) {
2688
+ return (e, t) => e.kind === "marker" && e.ast.markerKind === "content" ? new Qe(e, document.createTextNode(e.ast.content)) : J(e, n, t);
2500
2689
  }
2501
2690
  const S = [];
2502
- function gs(n) {
2503
- return "content" in n ? n.content : ps;
2691
+ function Ss(n) {
2692
+ return "content" in n ? n.content : Ls;
2504
2693
  }
2505
- const ps = [];
2506
- function ms(n, e) {
2694
+ const Ls = [];
2695
+ function Rs(n, e) {
2507
2696
  const t = n.ast.content, s = {
2508
2697
  leftBoundary: n.leftWordBoundary,
2509
2698
  rightBoundary: n.rightWordBoundary,
2510
2699
  decorateNewline: !0
2511
2700
  };
2512
- if (n.showWhitespace && Wt(t, s)) {
2701
+ if (n.showWhitespace && Yt(t, s)) {
2513
2702
  const o = document.createElement("span");
2514
2703
  o.className = "md-text";
2515
- const c = Me(o, t, s, n.ast);
2704
+ const c = Le(o, t, s, n.ast);
2516
2705
  return new T(n, o, c);
2517
2706
  }
2518
2707
  const i = e?.dom, r = i instanceof globalThis.Text && i.data === t ? i : document.createTextNode(t);
2519
- return new je(n, r);
2708
+ return new Qe(n, r);
2520
2709
  }
2521
- function ct(n) {
2710
+ function dt(n) {
2522
2711
  return n === " " || n === " " || n === `
2523
2712
  ` || n === "\r";
2524
2713
  }
2525
- const ws = { leftBoundary: !1, rightBoundary: !1, decorateNewline: !1 }, _s = { leftBoundary: !1, rightBoundary: !1, decorateNewline: !1 };
2526
- function ks(n, e, t) {
2527
- const s = e > 0 ? !ct(n[e - 1]) : t.leftBoundary, i = e < n.length - 1 ? !ct(n[e + 1]) : t.rightBoundary;
2714
+ const Is = { leftBoundary: !1, rightBoundary: !1, decorateNewline: !1 }, Ns = { leftBoundary: !1, rightBoundary: !1, decorateNewline: !1 };
2715
+ function Bs(n, e, t) {
2716
+ const s = e > 0 ? !dt(n[e - 1]) : t.leftBoundary, i = e < n.length - 1 ? !dt(n[e + 1]) : t.rightBoundary;
2528
2717
  return s && i;
2529
2718
  }
2530
- function Ht(n, e, t) {
2719
+ function Ut(n, e, t) {
2531
2720
  const s = n[e];
2532
2721
  if (s === " ")
2533
2722
  return "md-ws-tab";
2534
2723
  if (s === `
2535
2724
  ` || s === "\r")
2536
2725
  return t.decorateNewline ? "md-ws-newline" : void 0;
2537
- if (s === " " && !ks(n, e, t))
2726
+ if (s === " " && !Bs(n, e, t))
2538
2727
  return "md-ws-space";
2539
2728
  }
2540
- function Wt(n, e) {
2729
+ function Yt(n, e) {
2541
2730
  for (let t = 0; t < n.length; t++) {
2542
2731
  const s = n[t];
2543
2732
  if (e.newlineGlyph && (s === `
2544
- ` || s === "\r") || Ht(n, t, e) !== void 0)
2733
+ ` || s === "\r") || Ut(n, t, e) !== void 0)
2545
2734
  return !0;
2546
2735
  }
2547
2736
  return !1;
2548
2737
  }
2549
- function xs(n, e) {
2738
+ function Ds(n, e) {
2550
2739
  const t = [];
2551
2740
  let s = -1;
2552
2741
  const i = (c) => {
@@ -2555,44 +2744,44 @@ function xs(n, e) {
2555
2744
  `) : -1, o = e.newlineGlyph ? n.lastIndexOf(`
2556
2745
  `) : -1;
2557
2746
  for (let c = 0; c < n.length; c++) {
2558
- const l = n[c];
2559
- if (e.newlineGlyph && (l === `
2560
- ` || l === "\r")) {
2747
+ const a = n[c];
2748
+ if (e.newlineGlyph && (a === `
2749
+ ` || a === "\r")) {
2561
2750
  const h = c === r;
2562
2751
  if (c !== o || h) {
2563
- i(c), t.push({ text: l, cls: h ? e.breakGlyphClass : "md-ws-newline-glyph", display: "↵" });
2752
+ i(c), t.push({ text: a, cls: h ? e.breakGlyphClass : "md-ws-newline-glyph", display: "↵" });
2564
2753
  continue;
2565
2754
  }
2566
2755
  }
2567
- const a = e.newlineGlyph && (l === `
2568
- ` || l === "\r") ? void 0 : Ht(n, c, e);
2569
- if (a === void 0) {
2756
+ const l = e.newlineGlyph && (a === `
2757
+ ` || a === "\r") ? void 0 : Ut(n, c, e);
2758
+ if (l === void 0) {
2570
2759
  s < 0 && (s = c);
2571
2760
  continue;
2572
2761
  }
2573
- i(c), t.push({ text: l, cls: a });
2762
+ i(c), t.push({ text: a, cls: l });
2574
2763
  }
2575
2764
  return i(n.length), t;
2576
2765
  }
2577
- function Me(n, e, t, s) {
2766
+ function Le(n, e, t, s) {
2578
2767
  const i = [];
2579
- for (const r of xs(e, t)) {
2768
+ for (const r of Ds(e, t)) {
2580
2769
  const o = document.createTextNode(r.display ?? r.text);
2581
2770
  if (r.cls) {
2582
2771
  const c = document.createElement("span");
2583
2772
  c.className = r.cls, c.appendChild(o), n.appendChild(c);
2584
2773
  } else
2585
2774
  n.appendChild(o);
2586
- i.push(new G(s, o, S, r.text.length));
2775
+ i.push(new X(s, o, S, r.text.length));
2587
2776
  }
2588
2777
  return i;
2589
2778
  }
2590
- class je extends T {
2779
+ class Qe extends T {
2591
2780
  constructor(e, t) {
2592
2781
  super(e, t, S);
2593
2782
  }
2594
2783
  }
2595
- class G extends ae {
2784
+ class X extends ie {
2596
2785
  _sourceLength;
2597
2786
  constructor(e, t, s = S, i = e.length) {
2598
2787
  super(e, t, s), this._sourceLength = i;
@@ -2601,7 +2790,7 @@ class G extends ae {
2601
2790
  return this._sourceLength;
2602
2791
  }
2603
2792
  }
2604
- class lt extends T {
2793
+ class ut extends T {
2605
2794
  _span;
2606
2795
  constructor(e, t) {
2607
2796
  const s = e.ast, i = `md-marker md-marker-${s.markerKind}`, r = t && t.dom instanceof globalThis.Text && t.dom.data === s.content, o = r ? t._span : document.createElement("span");
@@ -2613,10 +2802,10 @@ class lt extends T {
2613
2802
  return this._span;
2614
2803
  }
2615
2804
  }
2616
- class Ce extends T {
2805
+ class Te extends T {
2617
2806
  _span;
2618
2807
  constructor(e, t) {
2619
- const s = Ce._build(e, t);
2808
+ const s = Te._build(e, t);
2620
2809
  super(e, s.dom, s.children), this._span = s.span;
2621
2810
  }
2622
2811
  get mountNode() {
@@ -2630,58 +2819,58 @@ class Ce extends T {
2630
2819
  newlineGlyph: s.glueKind === "blockGap" || r,
2631
2820
  breakGlyphClass: r ? "md-ws-blockbreak-glyph" : void 0
2632
2821
  };
2633
- if (e.visible && Wt(s.content, o)) {
2634
- const g = document.createElement("span");
2635
- g.className = i;
2636
- const d = Me(g, s.content, o, s);
2637
- return { span: g, dom: g, children: d };
2822
+ if (e.visible && Yt(s.content, o)) {
2823
+ const u = document.createElement("span");
2824
+ u.className = i;
2825
+ const f = Le(u, s.content, o, s);
2826
+ return { span: u, dom: u, children: f };
2638
2827
  }
2639
- const l = t && t.dom instanceof globalThis.Text && t.dom.data === s.content && t.children.length === 0, a = l ? t._span : document.createElement("span");
2640
- a.className = e.visible ? i : `${i} md-glue-hidden`;
2641
- const h = l ? t.dom : document.createTextNode(s.content);
2642
- return l || a.appendChild(h), { span: a, dom: h, children: S };
2828
+ const a = t && t.dom instanceof globalThis.Text && t.dom.data === s.content && t.children.length === 0, l = a ? t._span : document.createElement("span");
2829
+ l.className = e.visible ? i : `${i} md-glue-hidden`;
2830
+ const h = a ? t.dom : document.createTextNode(s.content);
2831
+ return a || l.appendChild(h), { span: l, dom: h, children: S };
2643
2832
  }
2644
2833
  }
2645
- class at extends T {
2834
+ class ft extends T {
2646
2835
  _span;
2647
2836
  constructor(e, t) {
2648
2837
  const s = e.ast.content, i = document.createElement("span");
2649
2838
  i.className = "md-hardbreak";
2650
2839
  const r = document.createElement("span");
2651
2840
  r.className = e.visible ? "md-hardbreak-src" : "md-hardbreak-src md-hardbreak-src-hidden";
2652
- const o = e.visible ? Me(r, s, ws, e.ast) : vs(r, s, e.ast);
2841
+ const o = e.visible ? Le(r, s, Is, e.ast) : $s(r, s, e.ast);
2653
2842
  i.appendChild(r), i.appendChild(document.createElement("br")), super(e, i, o), this._span = i;
2654
2843
  }
2655
2844
  get mountNode() {
2656
2845
  return this._span;
2657
2846
  }
2658
2847
  }
2659
- function vs(n, e, t) {
2848
+ function $s(n, e, t) {
2660
2849
  const s = document.createTextNode(e);
2661
- return n.appendChild(s), [new G(t, s)];
2850
+ return n.appendChild(s), [new X(t, s)];
2662
2851
  }
2663
- class W extends T {
2852
+ class z extends T {
2664
2853
  constructor(e, t, s, i, r) {
2665
2854
  const o = r?.element ?? document.createElement(t);
2666
2855
  !r && s && (o.className = s);
2667
- const c = X(o, gs(e), r?.children, se(i));
2856
+ const c = U(o, Ss(e), r?.children, re(i));
2668
2857
  super(e, o, c);
2669
2858
  }
2670
2859
  }
2671
- class ht extends T {
2860
+ class gt extends T {
2672
2861
  constructor(e, t, s) {
2673
2862
  const i = s && s.element.tagName === `H${e.ast.level}`, r = i ? s.element : document.createElement(`h${e.ast.level}`);
2674
2863
  i || (r.className = "md-block md-heading");
2675
- const o = X(r, e.content, s?.children, se(t));
2864
+ const o = U(r, e.content, s?.children, re(t));
2676
2865
  super(e, r, o);
2677
2866
  }
2678
2867
  }
2679
- class dt extends T {
2868
+ class pt extends T {
2680
2869
  constructor(e, t, s) {
2681
2870
  if (e.showMarkup) {
2682
2871
  const r = s?.dom instanceof HTMLDivElement ? s : void 0, o = r?.element ?? document.createElement("div");
2683
2872
  r || (o.className = "md-block md-thematic-break-source");
2684
- const c = X(o, e.content, r?.children, se(t));
2873
+ const c = U(o, e.content, r?.children, re(t));
2685
2874
  super(e, o, c);
2686
2875
  return;
2687
2876
  }
@@ -2689,7 +2878,7 @@ class dt extends T {
2689
2878
  i.className = "md-block md-thematic-break", super(e, i, S);
2690
2879
  }
2691
2880
  }
2692
- class Ge extends T {
2881
+ class Ue extends T {
2693
2882
  _session;
2694
2883
  /**
2695
2884
  * Subscription that re-tokenises the rendered `<code>` in place whenever the
@@ -2702,111 +2891,111 @@ class Ge extends T {
2702
2891
  */
2703
2892
  _snapshotSub;
2704
2893
  constructor(e, t, s) {
2705
- const i = e.ast, r = i.code?.content ?? "", o = !e.showMarkup && i.language && t?.renderCustomCodeBlock ? t.renderCustomCodeBlock(i.language, r) ?? void 0 : void 0, c = t?.syntaxHighlighter, l = s instanceof Ge ? s : void 0;
2706
- let a;
2894
+ const i = e.ast, r = i.code?.content ?? "", o = !e.showMarkup && i.language && t?.renderCustomCodeBlock ? t.renderCustomCodeBlock(i.language, r) ?? void 0 : void 0, c = t?.syntaxHighlighter, a = s instanceof Ue ? s : void 0;
2895
+ let l;
2707
2896
  if (!o && c && i.language) {
2708
- if (l?._session && i === l.ast)
2709
- a = l._session, l._session = void 0;
2710
- else if (l?._session) {
2711
- const f = i.getDiff(l.ast);
2712
- f && (a = l._session, l._session = void 0, ln((p) => a.update(f.stringEdit, p)));
2897
+ if (a?._session && i === a.ast)
2898
+ l = a._session, a._session = void 0;
2899
+ else if (a?._session) {
2900
+ const g = i.getDiff(a.ast);
2901
+ g && (l = a._session, a._session = void 0, mn((p) => l.update(g.stringEdit, p)));
2713
2902
  }
2714
- a || (a = c.create(i.language, r));
2903
+ l || (l = c.create(i.language, r));
2715
2904
  }
2716
- l?._session && (l._session.dispose(), l._session = void 0), l?._snapshotSub?.dispose(), l && (l._snapshotSub = void 0);
2717
- const h = a ? a.snapshot.get().getTokens(w.ofLength(r.length)).tokens : void 0;
2718
- let g, d, u;
2905
+ a?._session && (a._session.dispose(), a._session = void 0), a?._snapshotSub?.dispose(), a && (a._snapshotSub = void 0);
2906
+ const h = l ? l.snapshot.get().getTokens(_.ofLength(r.length)).tokens : void 0;
2907
+ let u, f, d;
2719
2908
  if (o)
2720
- o.classList.add("md-block", "md-code-block"), g = o, d = S;
2909
+ o.classList.add("md-block", "md-code-block"), u = o, f = S;
2721
2910
  else if (i.openFence) {
2722
- const f = document.createElement("pre");
2723
- f.className = "md-block md-code-block";
2911
+ const g = document.createElement("pre");
2912
+ g.className = "md-block md-code-block";
2724
2913
  const p = [];
2725
2914
  for (const m of e.content)
2726
2915
  if (m.ast === i.code) {
2727
- const _ = document.createElement("code");
2728
- i.language && (_.className = `language-${CSS.escape(i.language)}`);
2729
- const v = bs(i.code, r, _, h);
2730
- v instanceof qt && (u = v), p.push(v), f.appendChild(_);
2916
+ const w = document.createElement("code");
2917
+ i.language && (w.className = `language-${CSS.escape(i.language)}`);
2918
+ const x = As(i.code, r, w, h);
2919
+ x instanceof Jt && (d = x), p.push(x), g.appendChild(w);
2731
2920
  } else {
2732
- const _ = Y(m, t, void 0);
2733
- f.appendChild(_.mountNode), p.push(_);
2921
+ const w = J(m, t, void 0);
2922
+ g.appendChild(w.mountNode), p.push(w);
2734
2923
  }
2735
- g = f, d = p;
2924
+ u = g, f = p;
2736
2925
  } else {
2737
- const f = document.createElement("pre");
2738
- f.className = "md-block md-code-block";
2926
+ const g = document.createElement("pre");
2927
+ g.className = "md-block md-code-block";
2739
2928
  const p = document.createElement("code");
2740
- f.appendChild(p);
2929
+ g.appendChild(p);
2741
2930
  const m = [];
2742
- for (const _ of e.content) {
2743
- const v = _.ast;
2744
- if (_.kind === "marker" && v.markerKind === "content") {
2745
- const y = document.createTextNode(v.content);
2746
- p.appendChild(y), m.push(new G(v, y));
2747
- } else if (_.kind === "marker" && v.markerKind === "codeIndent") {
2748
- const y = v;
2749
- if (_.visible) {
2931
+ for (const w of e.content) {
2932
+ const x = w.ast;
2933
+ if (w.kind === "marker" && x.markerKind === "content") {
2934
+ const E = document.createTextNode(x.content);
2935
+ p.appendChild(E), m.push(new X(x, E));
2936
+ } else if (w.kind === "marker" && x.markerKind === "codeIndent") {
2937
+ const E = x;
2938
+ if (w.visible) {
2750
2939
  const M = document.createElement("span");
2751
2940
  M.className = "md-marker md-marker-codeIndent";
2752
- const A = Me(M, y.content, _s, y);
2753
- p.appendChild(M), m.push(new G(y, M, A));
2941
+ const P = Le(M, E.content, Ns, E);
2942
+ p.appendChild(M), m.push(new X(E, M, P));
2754
2943
  } else {
2755
- const M = Y(_, t, void 0);
2944
+ const M = J(w, t, void 0);
2756
2945
  p.appendChild(M.mountNode), m.push(M);
2757
2946
  }
2758
2947
  } else {
2759
- const y = Y(_, t, void 0);
2760
- f.appendChild(y.mountNode), m.push(y);
2948
+ const E = J(w, t, void 0);
2949
+ g.appendChild(E.mountNode), m.push(E);
2761
2950
  }
2762
2951
  }
2763
- g = f, d = m;
2952
+ u = g, f = m;
2764
2953
  }
2765
- super(e, g, d), this._session = a, a && u && (this._snapshotSub = an(a.snapshot, () => {
2766
- const f = a.snapshot.get();
2767
- u.refresh(r, f.getTokens(w.ofLength(r.length)).tokens);
2954
+ super(e, u, f), this._session = l, l && d && (this._snapshotSub = _n(l.snapshot, () => {
2955
+ const g = l.snapshot.get();
2956
+ d.refresh(r, g.getTokens(_.ofLength(r.length)).tokens);
2768
2957
  }));
2769
2958
  }
2770
2959
  dispose() {
2771
2960
  this._snapshotSub?.dispose(), this._snapshotSub = void 0, this._session?.dispose(), this._session = void 0, super.dispose();
2772
2961
  }
2773
2962
  }
2774
- function bs(n, e, t, s) {
2963
+ function As(n, e, t, s) {
2775
2964
  if (!s) {
2776
2965
  const i = document.createTextNode(e);
2777
- return t.appendChild(i), new G(n, i);
2966
+ return t.appendChild(i), new X(n, i);
2778
2967
  }
2779
- return new qt(n, t, e, s);
2968
+ return new Jt(n, t, e, s);
2780
2969
  }
2781
- class qt extends ae {
2970
+ class Jt extends ie {
2782
2971
  constructor(e, t, s, i) {
2783
- super(e, t, ut(e, t, s, i));
2972
+ super(e, t, mt(e, t, s, i));
2784
2973
  }
2785
2974
  /** Re-render the token spans for a new colouring, in place. */
2786
2975
  refresh(e, t) {
2787
2976
  const s = this.dom;
2788
- s.replaceChildren(), this._replaceChildren(ut(this.ast, s, e, t));
2977
+ s.replaceChildren(), this._replaceChildren(mt(this.ast, s, e, t));
2789
2978
  }
2790
2979
  }
2791
- function ut(n, e, t, s) {
2980
+ function mt(n, e, t, s) {
2792
2981
  const i = [];
2793
2982
  let r = 0;
2794
2983
  for (const o of s) {
2795
2984
  const c = t.slice(r, r + o.length);
2796
2985
  r += o.length;
2797
- const l = document.createTextNode(c);
2986
+ const a = document.createTextNode(c);
2798
2987
  if (o.className) {
2799
- const a = document.createElement("span");
2988
+ const l = document.createElement("span");
2800
2989
  for (const h of o.className.split("."))
2801
- h && a.classList.add(`tok-${h}`);
2802
- a.appendChild(l), e.appendChild(a);
2990
+ h && l.classList.add(`tok-${h}`);
2991
+ l.appendChild(a), e.appendChild(l);
2803
2992
  } else
2804
- e.appendChild(l);
2805
- i.push(new G(n, l, S, c.length));
2993
+ e.appendChild(a);
2994
+ i.push(new X(n, a, S, c.length));
2806
2995
  }
2807
2996
  return i;
2808
2997
  }
2809
- function jt(n) {
2998
+ function Zt(n) {
2810
2999
  let e = 0;
2811
3000
  for (const t of n) {
2812
3001
  if (t.kind === "marker" && t.markerKind === "content")
@@ -2815,17 +3004,17 @@ function jt(n) {
2815
3004
  }
2816
3005
  return e;
2817
3006
  }
2818
- function Gt(n, e, t) {
2819
- const s = e.filter((c) => c.length > 0 && c.start >= 0 && c.start + c.length <= t).slice().sort((c, l) => c.start - l.start), i = [];
3007
+ function en(n, e, t) {
3008
+ const s = e.filter((c) => c.length > 0 && c.start >= 0 && c.start + c.length <= t).slice().sort((c, a) => c.start - a.start), i = [];
2820
3009
  let r = 0;
2821
3010
  const o = (c) => {
2822
- c > 0 && i.push(new G(n, document.createTextNode(""), S, c));
3011
+ c > 0 && i.push(new X(n, document.createTextNode(""), S, c));
2823
3012
  };
2824
3013
  for (const c of s)
2825
- c.start < r || (o(c.start - r), i.push(new G(n, c.dom, S, c.length)), r = c.start + c.length);
3014
+ c.start < r || (o(c.start - r), i.push(new X(n, c.dom, S, c.length)), r = c.start + c.length);
2826
3015
  return o(t - r), i;
2827
3016
  }
2828
- class ft extends T {
3017
+ class _t extends T {
2829
3018
  /**
2830
3019
  * The rendered (inactive, KaTeX) height in px, measured after mount and
2831
3020
  * carried forward across rebuilds via `previous`. When the block becomes
@@ -2837,18 +3026,18 @@ class ft extends T {
2837
3026
  constructor(e, t, s) {
2838
3027
  const i = e.ast, r = s?._renderedHeight;
2839
3028
  if (e.showMarkup) {
2840
- const a = document.createElement("pre");
2841
- a.className = "md-block md-math-block", r !== void 0 && (a.style.boxSizing = "border-box", a.style.minHeight = `${r}px`);
3029
+ const l = document.createElement("pre");
3030
+ l.className = "md-block md-math-block", r !== void 0 && (l.style.boxSizing = "border-box", l.style.minHeight = `${r}px`);
2842
3031
  const h = [];
2843
- for (const g of e.content)
2844
- if (g.ast === i.code) {
2845
- const d = document.createElement("code"), u = document.createTextNode(i.code.content);
2846
- d.appendChild(u), a.appendChild(d), h.push(new G(i.code, u));
3032
+ for (const u of e.content)
3033
+ if (u.ast === i.code) {
3034
+ const f = document.createElement("code"), d = document.createTextNode(i.code.content);
3035
+ f.appendChild(d), l.appendChild(f), h.push(new X(i.code, d));
2847
3036
  } else {
2848
- const d = Y(g, t, void 0);
2849
- a.appendChild(d.mountNode), h.push(d);
3037
+ const f = J(u, t, void 0);
3038
+ l.appendChild(f.mountNode), h.push(f);
2850
3039
  }
2851
- super(e, a, h), this._renderedHeight = r;
3040
+ super(e, l, h), this._renderedHeight = r;
2852
3041
  return;
2853
3042
  }
2854
3043
  const o = i.code?.content ?? "", c = t?.renderMath?.({
@@ -2856,46 +3045,46 @@ class ft extends T {
2856
3045
  displayMode: !0,
2857
3046
  className: "md-block md-math-block",
2858
3047
  nodeLength: i.length,
2859
- contentStart: jt(i.content)
3048
+ contentStart: Zt(i.content)
2860
3049
  });
2861
3050
  if (c) {
2862
- super(e, c.dom, Gt(i, c.segments, i.length)), this._renderedHeight = r;
3051
+ super(e, c.dom, en(i, c.segments, i.length)), this._renderedHeight = r;
2863
3052
  return;
2864
3053
  }
2865
- const l = document.createElement("div");
2866
- l.className = "md-block md-math-block";
3054
+ const a = document.createElement("div");
3055
+ a.className = "md-block md-math-block";
2867
3056
  try {
2868
- It.render(o, l, { displayMode: !0, throwOnError: !1 });
3057
+ $t.render(o, a, { displayMode: !0, throwOnError: !1 });
2869
3058
  } catch {
2870
- l.textContent = o;
3059
+ a.textContent = o;
2871
3060
  }
2872
- super(e, l, S), this._renderedHeight = r;
3061
+ super(e, a, S), this._renderedHeight = r;
2873
3062
  }
2874
3063
  recordMeasuredHeight(e) {
2875
3064
  this.data.showMarkup || (this._renderedHeight = e);
2876
3065
  }
2877
3066
  }
2878
- class gt extends T {
3067
+ class wt extends T {
2879
3068
  constructor(e, t, s) {
2880
3069
  const i = e.ast.ordered ? "ol" : "ul", r = s && s.element.tagName === i.toUpperCase(), o = r ? s.element : document.createElement(i);
2881
3070
  r || (o.className = "md-block md-list");
2882
- const c = X(o, e.content, s?.children, se(t));
3071
+ const c = U(o, e.content, s?.children, re(t));
2883
3072
  super(e, o, c);
2884
3073
  }
2885
3074
  }
2886
- class pt extends T {
3075
+ class kt extends T {
2887
3076
  constructor(e, t, s) {
2888
3077
  const i = e.ast, r = document.createElement("li");
2889
3078
  e.isActive && r.classList.add("md-list-item-active"), i.checked !== void 0 && r.classList.add("md-task-list-item"), e.isActive || r.classList.add("md-markers-hidden"), r.style.setProperty("--md-list-level", String(e.level));
2890
- const o = ys(r, e.content, s, t);
3079
+ const o = Ps(r, e.content, s, t);
2891
3080
  if (!e.isActive && i.checked !== void 0) {
2892
3081
  const c = document.createElement("input");
2893
3082
  c.type = "checkbox", c.checked = i.checked, c.className = "md-checkbox";
2894
- const l = t?.onToggleCheckbox;
2895
- if (l) {
2896
- const a = i.checked;
3083
+ const a = t?.onToggleCheckbox;
3084
+ if (a) {
3085
+ const l = i.checked;
2897
3086
  c.addEventListener("mousedown", (h) => {
2898
- h.stopPropagation(), h.preventDefault(), l(i, !a);
3087
+ h.stopPropagation(), h.preventDefault(), a(i, !l);
2899
3088
  });
2900
3089
  } else
2901
3090
  c.disabled = !0;
@@ -2904,89 +3093,89 @@ class pt extends T {
2904
3093
  super(e, r, o);
2905
3094
  }
2906
3095
  }
2907
- function ys(n, e, t, s) {
2908
- const { paired: i, unused: r } = ze(e, t?.children ?? S), o = e.map((h) => Y(h, s, i.get(h)));
3096
+ function Ps(n, e, t, s) {
3097
+ const { paired: i, unused: r } = Ye(e, t?.children ?? S), o = e.map((h) => J(h, s, i.get(h)));
2909
3098
  for (const h of r)
2910
3099
  h.dispose();
2911
3100
  if (!(e.length >= 2 && e[0].kind === "glue" && e[0].ast.glueKind === "indent" && e[1].kind === "marker" && e[1].ast.markerKind === "listItemMarker"))
2912
- return fe(n, o.map((h) => h.mountNode)), o;
2913
- const l = n.firstElementChild, a = l && l.classList.contains("md-list-gutter") ? l : document.createElement("span");
2914
- return a.className = "md-list-gutter", fe(a, [o[0].mountNode, o[1].mountNode]), fe(n, [a, ...o.slice(2).map((h) => h.mountNode)]), o;
3101
+ return ge(n, o.map((h) => h.mountNode)), o;
3102
+ const a = n.firstElementChild, l = a && a.classList.contains("md-list-gutter") ? a : document.createElement("span");
3103
+ return l.className = "md-list-gutter", ge(l, [o[0].mountNode, o[1].mountNode]), ge(n, [l, ...o.slice(2).map((h) => h.mountNode)]), o;
2915
3104
  }
2916
- class mt extends T {
3105
+ class vt extends T {
2917
3106
  constructor(e, t, s) {
2918
3107
  const i = s?.element ?? document.createElement("tr");
2919
3108
  e.isDelimiter && i.classList.add("md-table-delimiter-row");
2920
- const r = X(i, e.content, s?.children, se(t));
3109
+ const r = U(i, e.content, s?.children, re(t));
2921
3110
  e.isDelimiter || e.content.forEach((o, c) => {
2922
3111
  o.kind === "tableCell" && o.isActive && r[c].element.classList.add("md-table-cell-active");
2923
3112
  }), super(e, i, r);
2924
3113
  }
2925
3114
  }
2926
- class wt extends T {
3115
+ class xt extends T {
2927
3116
  constructor(e, t, s) {
2928
- const i = s?.element ?? document.createElement("code"), r = X(i, e.content, s?.children, Kt(t));
3117
+ const i = s?.element ?? document.createElement("code"), r = U(i, e.content, s?.children, Qt(t));
2929
3118
  super(e, i, r);
2930
3119
  }
2931
3120
  }
2932
- class _t extends T {
3121
+ class bt extends T {
2933
3122
  constructor(e, t, s) {
2934
3123
  if (e.showMarkup) {
2935
- const l = document.createElement("span");
2936
- l.className = "md-inline-math";
2937
- const a = X(l, e.content, s?.children, Kt(t));
2938
- super(e, l, a);
3124
+ const a = document.createElement("span");
3125
+ a.className = "md-inline-math";
3126
+ const l = U(a, e.content, s?.children, Qt(t));
3127
+ super(e, a, l);
2939
3128
  return;
2940
3129
  }
2941
3130
  const r = e.content.find(
2942
- (l) => l.kind === "marker" && l.ast.markerKind === "content"
3131
+ (a) => a.kind === "marker" && a.ast.markerKind === "content"
2943
3132
  )?.ast.content ?? "", o = t?.renderMath?.({
2944
3133
  latex: r,
2945
3134
  displayMode: !1,
2946
3135
  className: "md-inline-math",
2947
3136
  nodeLength: e.ast.length,
2948
- contentStart: jt(e.ast.content)
3137
+ contentStart: Zt(e.ast.content)
2949
3138
  });
2950
3139
  if (o) {
2951
- super(e, o.dom, Gt(e.ast, o.segments, e.ast.length));
3140
+ super(e, o.dom, en(e.ast, o.segments, e.ast.length));
2952
3141
  return;
2953
3142
  }
2954
3143
  const c = document.createElement("span");
2955
3144
  c.className = "md-inline-math";
2956
3145
  try {
2957
- It.render(r, c, { throwOnError: !1 });
3146
+ $t.render(r, c, { throwOnError: !1 });
2958
3147
  } catch {
2959
3148
  c.textContent = r;
2960
3149
  }
2961
3150
  super(e, c, S);
2962
3151
  }
2963
3152
  }
2964
- class kt extends T {
3153
+ class yt extends T {
2965
3154
  constructor(e, t, s) {
2966
3155
  const i = s?.element ?? document.createElement("a");
2967
- zt(e.ast.url) ? (i.href = e.ast.url, i.dataset.mdUrl = e.ast.url) : (i.removeAttribute("href"), delete i.dataset.mdUrl), s || i.addEventListener("mousedown", (o) => {
3156
+ tn(e.ast.url) ? (i.href = e.ast.url, i.dataset.mdUrl = e.ast.url) : (i.removeAttribute("href"), delete i.dataset.mdUrl), s || i.addEventListener("mousedown", (o) => {
2968
3157
  const c = i.dataset.mdUrl;
2969
3158
  !c || i.closest(".md-block-active") !== null && !(o.ctrlKey || o.metaKey) || (o.preventDefault(), o.stopPropagation(), t?.onOpenLink ? t.onOpenLink(c, o) : window.open(c, "_blank", "noopener"));
2970
3159
  });
2971
- const r = X(i, e.content, s?.children, se(t));
3160
+ const r = U(i, e.content, s?.children, re(t));
2972
3161
  super(e, i, r);
2973
3162
  }
2974
3163
  }
2975
- class xt extends T {
3164
+ class Et extends T {
2976
3165
  constructor(e, t, s) {
2977
3166
  const i = e.ast;
2978
3167
  if (e.showMarkup) {
2979
3168
  const o = document.createElement("span");
2980
3169
  o.className = "md-image-source";
2981
- const c = X(o, e.content, s?.children, se(t));
3170
+ const c = U(o, e.content, s?.children, re(t));
2982
3171
  super(e, o, c);
2983
3172
  return;
2984
3173
  }
2985
3174
  const r = document.createElement("img");
2986
- zt(i.url) && (r.src = i.url), r.alt = i.alt, super(e, r, S);
3175
+ tn(i.url) && (r.src = i.url), r.alt = i.alt, super(e, r, S);
2987
3176
  }
2988
3177
  }
2989
- function ze(n, e) {
3178
+ function Ye(n, e) {
2990
3179
  const t = /* @__PURE__ */ new Map();
2991
3180
  for (const i of e)
2992
3181
  t.set(i.ast.id, i);
@@ -2997,39 +3186,53 @@ function ze(n, e) {
2997
3186
  }
2998
3187
  return { paired: s, unused: [...t.values()] };
2999
3188
  }
3000
- function zt(n) {
3189
+ function tn(n) {
3001
3190
  return !n.trim().toLowerCase().startsWith("javascript:");
3002
3191
  }
3003
- class Xe extends ae {
3004
- constructor(e, t, s, i) {
3005
- super(e, t, i), this.blocks = s;
3192
+ class Je extends ie {
3193
+ constructor(e, t, s, i, r) {
3194
+ super(e, t, i), this.blocks = s, this.pendingElement = r;
3006
3195
  }
3007
3196
  static create(e, t, s) {
3008
3197
  const i = s?.contentDomNode ?? document.createElement("div"), r = new Map(
3009
3198
  e.children.filter((d) => d.kind === "block").map((d) => [d.view, d.isActive])
3010
- ), o = s?.children, c = e.children.map((d) => d.view), { paired: l, unused: a } = ze(c, o ?? Es), h = c.map((d, u) => {
3011
- const f = l.get(d), p = Y(d, t, f);
3012
- if (e.children[u].kind === "block") {
3013
- const m = r.get(d);
3014
- m !== void 0 && (p.element.classList.toggle("md-block-active", m), p.element.classList.toggle("md-markers-hidden", !m));
3199
+ ), o = s?.children, c = e.children.map((d) => d.view), { paired: a, unused: l } = Ye(c, o ?? Fs);
3200
+ let h;
3201
+ const u = c.map((d, g) => {
3202
+ const p = a.get(d);
3203
+ if (e.children[g].kind === "pendingParagraph") {
3204
+ const w = p instanceof Ct ? p : new Ct(d);
3205
+ return h = w.element, w;
3015
3206
  }
3016
- return p;
3207
+ const m = J(d, t, p);
3208
+ if (e.children[g].kind === "block") {
3209
+ const w = r.get(d);
3210
+ w !== void 0 && (m.element.classList.toggle("md-block-active", w), m.element.classList.toggle("md-markers-hidden", !w));
3211
+ }
3212
+ return m;
3017
3213
  });
3018
- for (const d of a)
3214
+ for (const d of l)
3019
3215
  d.dispose();
3020
- fe(i, h.map((d) => d.mountNode));
3021
- const g = [];
3022
- return e.children.forEach((d, u) => {
3023
- d.kind === "block" && g.push({ node: h[u], absoluteStart: d.absoluteStart });
3024
- }), new Xe(e.ast, i, g, h);
3216
+ ge(i, u.map((d) => d.mountNode));
3217
+ const f = [];
3218
+ return e.children.forEach((d, g) => {
3219
+ d.kind === "block" && f.push({ node: u[g], absoluteStart: d.absoluteStart });
3220
+ }), new Je(e.ast, i, f, u, h);
3025
3221
  }
3026
3222
  /** The stable content element this document mounts its children into. */
3027
3223
  get contentDomNode() {
3028
3224
  return this.dom;
3029
3225
  }
3030
3226
  }
3031
- const Es = [];
3032
- function Cs(n) {
3227
+ class Ct extends ie {
3228
+ element;
3229
+ constructor(e) {
3230
+ const t = document.createElement("p");
3231
+ t.className = "md-block md-paragraph md-pending-paragraph", t.appendChild(document.createElement("br")), super(e.ast, t), this.element = t;
3232
+ }
3233
+ }
3234
+ const Fs = [];
3235
+ function Vs(n) {
3033
3236
  const e = document;
3034
3237
  if (e.caretPositionFromPoint) {
3035
3238
  const s = e.caretPositionFromPoint(n.x, n.y);
@@ -3039,115 +3242,121 @@ function Cs(n) {
3039
3242
  if (t)
3040
3243
  return { node: t.startContainer, offset: t.startOffset };
3041
3244
  }
3042
- class Os {
3245
+ class Ks {
3043
3246
  constructor(e, t, s) {
3044
3247
  this.ast = e, this.blocks = t, this.children = s;
3045
3248
  }
3046
3249
  kind = "document";
3047
3250
  }
3048
- class Ts {
3251
+ class Hs {
3049
3252
  constructor(e, t) {
3050
3253
  this.ast = e, this.content = t;
3051
3254
  }
3052
3255
  kind = "heading";
3053
3256
  }
3054
- class Ms {
3257
+ class Ws {
3055
3258
  constructor(e, t) {
3056
3259
  this.ast = e, this.content = t;
3057
3260
  }
3058
3261
  kind = "paragraph";
3059
3262
  }
3060
- class Ss {
3263
+ class qs {
3264
+ constructor(e) {
3265
+ this.ast = e;
3266
+ }
3267
+ kind = "pendingParagraph";
3268
+ }
3269
+ class zs {
3061
3270
  constructor(e, t, s) {
3062
3271
  this.ast = e, this.showMarkup = t, this.content = s;
3063
3272
  }
3064
3273
  kind = "codeBlock";
3065
3274
  }
3066
- class Ls {
3275
+ class Gs {
3067
3276
  constructor(e, t, s) {
3068
3277
  this.ast = e, this.showMarkup = t, this.content = s;
3069
3278
  }
3070
3279
  kind = "mathBlock";
3071
3280
  }
3072
- class Is {
3281
+ class js {
3073
3282
  constructor(e, t) {
3074
3283
  this.ast = e, this.content = t;
3075
3284
  }
3076
3285
  kind = "blockQuote";
3077
3286
  }
3078
- class Ns {
3287
+ class Xs {
3079
3288
  constructor(e, t) {
3080
3289
  this.ast = e, this.content = t;
3081
3290
  }
3082
3291
  kind = "list";
3083
3292
  }
3084
- class Rs {
3293
+ class Qs {
3085
3294
  constructor(e, t) {
3086
3295
  this.ast = e, this.content = t;
3087
3296
  }
3088
3297
  kind = "table";
3089
3298
  }
3090
- class Bs {
3299
+ class Us {
3091
3300
  constructor(e, t) {
3092
3301
  this.ast = e, this.content = t;
3093
3302
  }
3094
3303
  kind = "strong";
3095
3304
  }
3096
- class Ds {
3305
+ class Ys {
3097
3306
  constructor(e, t) {
3098
3307
  this.ast = e, this.content = t;
3099
3308
  }
3100
3309
  kind = "emphasis";
3101
3310
  }
3102
- class As {
3311
+ class Js {
3103
3312
  constructor(e, t) {
3104
3313
  this.ast = e, this.content = t;
3105
3314
  }
3106
3315
  kind = "strikethrough";
3107
3316
  }
3108
- class $s {
3317
+ class Zs {
3109
3318
  constructor(e, t) {
3110
3319
  this.ast = e, this.content = t;
3111
3320
  }
3112
3321
  kind = "inlineCode";
3113
3322
  }
3114
- class Fs {
3323
+ class ei {
3115
3324
  constructor(e, t, s) {
3116
3325
  this.ast = e, this.showMarkup = t, this.content = s;
3117
3326
  }
3118
3327
  kind = "inlineMath";
3119
3328
  }
3120
- class Vs {
3329
+ class ti {
3121
3330
  constructor(e, t) {
3122
3331
  this.ast = e, this.content = t;
3123
3332
  }
3124
3333
  kind = "link";
3125
3334
  }
3126
- class Ps {
3335
+ class ni {
3127
3336
  constructor(e, t, s) {
3128
3337
  this.ast = e, this.showMarkup = t, this.content = s;
3129
3338
  }
3130
3339
  kind = "image";
3131
3340
  }
3132
- class Ks {
3341
+ class si {
3133
3342
  constructor(e, t, s, i) {
3134
3343
  this.ast = e, this.isActive = t, this.content = s, this.level = i;
3135
3344
  }
3136
3345
  kind = "listItem";
3137
3346
  }
3138
- class Hs {
3347
+ class ii {
3139
3348
  constructor(e, t, s) {
3140
3349
  this.ast = e, this.isDelimiter = t, this.content = s;
3141
3350
  }
3142
3351
  kind = "tableRow";
3143
3352
  }
3144
- class Ws {
3353
+ class ri {
3145
3354
  constructor(e, t, s, i) {
3146
3355
  this.ast = e, this.isActive = t, this.showTableGlue = s, this.content = i;
3147
3356
  }
3148
3357
  kind = "tableCell";
3149
3358
  }
3150
- class qs {
3359
+ class oi {
3151
3360
  /**
3152
3361
  * Whether non-obvious whitespace in this text is revealed (block is active).
3153
3362
  * `leftWordBoundary`/`rightWordBoundary` say whether the inline sibling on
@@ -3160,133 +3369,138 @@ class qs {
3160
3369
  }
3161
3370
  kind = "text";
3162
3371
  }
3163
- class js {
3372
+ class ci {
3164
3373
  constructor(e, t, s) {
3165
3374
  this.ast = e, this.showMarkup = t, this.content = s;
3166
3375
  }
3167
3376
  kind = "thematicBreak";
3168
3377
  }
3169
- class Gs {
3378
+ class ai {
3170
3379
  constructor(e, t) {
3171
3380
  this.ast = e, this.visible = t;
3172
3381
  }
3173
3382
  kind = "marker";
3174
3383
  }
3175
- class Xt {
3384
+ class nn {
3176
3385
  constructor(e, t, s) {
3177
3386
  this.ast = e, this.visible = t, this.decorateNewline = s;
3178
3387
  }
3179
3388
  kind = "glue";
3180
3389
  }
3181
- const zs = { showMarkup: !1, showTableGlue: !1, selectionInNode: void 0 };
3182
- function F(n) {
3390
+ const li = { showMarkup: !1, showTableGlue: !1, selectionInNode: void 0 };
3391
+ function V(n) {
3183
3392
  return n.inlineFlow ? n : { ...n, inlineFlow: !0 };
3184
3393
  }
3185
- function Qt(n, e, t, s) {
3186
- const i = /* @__PURE__ */ new Map();
3394
+ function sn(n, e, t, s, i) {
3395
+ const r = /* @__PURE__ */ new Map();
3187
3396
  if (s)
3188
- for (const h of s.children)
3189
- i.set(h.view.ast, h);
3190
- const r = n.content, o = new Set(n.blocks), c = [], l = [];
3191
- let a = 0;
3192
- for (let h = 0; h < r.length; h++) {
3193
- const g = r[h];
3194
- if (o.has(g)) {
3195
- const d = g, u = e.has(d), f = i.get(d);
3196
- let p;
3197
- if (!u)
3198
- p = f && !f.isActive ? f.view : vt(d, zs, f?.view);
3397
+ for (const u of s.children)
3398
+ r.set(u.view.ast, u);
3399
+ const o = n.content, c = new Set(n.blocks), a = [], l = [];
3400
+ let h = 0;
3401
+ for (let u = 0; u < o.length; u++) {
3402
+ const f = o[u];
3403
+ if (c.has(f)) {
3404
+ const d = f, g = e.has(d), p = r.get(d);
3405
+ let m;
3406
+ if (!g)
3407
+ m = p && !p.isActive ? p.view : Ot(d, li, p?.view);
3199
3408
  else {
3200
- const m = t ? new w(
3201
- Math.max(0, t.start - a),
3202
- Math.min(d.length, t.endExclusive - a)
3409
+ const w = t ? new _(
3410
+ Math.max(0, t.start - h),
3411
+ Math.min(d.length, t.endExclusive - h)
3203
3412
  ) : void 0;
3204
- p = vt(d, { showMarkup: !0, showTableGlue: !1, selectionInNode: m }, f?.view);
3413
+ m = Ot(d, { showMarkup: !0, showTableGlue: !1, selectionInNode: w }, p?.view);
3205
3414
  }
3206
- c.push({ ast: d, absoluteStart: a, isActive: u, view: p }), l.push({ absoluteStart: a, isActive: u, view: p, kind: "block" });
3207
- } else if (g instanceof R) {
3208
- const d = i.get(g), u = b(d?.view, new Xt(g, !1, !1));
3209
- l.push({ absoluteStart: a, isActive: !1, view: u, kind: "glue" });
3415
+ a.push({ ast: d, absoluteStart: h, isActive: g, view: m }), l.push({ absoluteStart: h, isActive: g, view: m, kind: "block" }), i && i.anchorBlock === d && l.push({
3416
+ absoluteStart: h + d.length,
3417
+ isActive: !0,
3418
+ view: new qs(i.ast),
3419
+ kind: "pendingParagraph"
3420
+ });
3421
+ } else if (f instanceof I) {
3422
+ const d = r.get(f), g = y(d?.view, new nn(f, !1, !1));
3423
+ l.push({ absoluteStart: h, isActive: !1, view: g, kind: "glue" });
3210
3424
  }
3211
- a += g.length;
3425
+ h += f.length;
3212
3426
  }
3213
- return new Os(n, c, l);
3427
+ return new Ks(n, a, l);
3214
3428
  }
3215
- function vt(n, e, t) {
3216
- return he(n, e, t);
3429
+ function Ot(n, e, t) {
3430
+ return de(n, e, t);
3217
3431
  }
3218
- function he(n, e, t, s) {
3432
+ function de(n, e, t, s) {
3219
3433
  const i = n;
3220
3434
  switch (i.kind) {
3221
3435
  case "text":
3222
- return b(t, new qs(i, e.showMarkup, s?.left ?? !1, s?.right ?? !1));
3436
+ return y(t, new oi(i, e.showMarkup, s?.left ?? !1, s?.right ?? !1));
3223
3437
  // The trailing gap is revealed as `↵` glyphs by virtue of its `blockGap`
3224
3438
  // kind (see `GlueViewNode`), so the break needs no inline-flow opt-in.
3225
3439
  case "thematicBreak":
3226
- return b(t, new js(i, e.showMarkup, I(i.children, e, t)));
3440
+ return y(t, new ci(i, e.showMarkup, R(i.children, e, t)));
3227
3441
  case "marker":
3228
- return b(t, new Gs(i, Us(i.markerKind, e)));
3442
+ return y(t, new ai(i, ui(i.markerKind, e)));
3229
3443
  case "glue":
3230
- return b(t, new Xt(i, Ys(i.glueKind, e), e.inlineFlow ?? !1));
3444
+ return y(t, new nn(i, fi(i.glueKind, e), e.inlineFlow ?? !1));
3231
3445
  case "heading":
3232
- return b(t, new Ts(i, I(i.children, F(e), t)));
3446
+ return y(t, new Hs(i, R(i.children, V(e), t)));
3233
3447
  case "paragraph":
3234
- return b(t, new Ms(i, I(i.children, F(e), t)));
3448
+ return y(t, new Ws(i, R(i.children, V(e), t)));
3235
3449
  case "codeBlock":
3236
- return b(t, new Ss(i, e.showMarkup, I(i.children, e, t)));
3450
+ return y(t, new zs(i, e.showMarkup, R(i.children, e, t)));
3237
3451
  case "mathBlock":
3238
- return b(t, new Ls(i, e.showMarkup, I(i.children, e, t)));
3452
+ return y(t, new Gs(i, e.showMarkup, R(i.children, e, t)));
3239
3453
  case "blockQuote":
3240
- return b(t, new Is(i, I(i.children, e, t)));
3454
+ return y(t, new js(i, R(i.children, e, t)));
3241
3455
  case "list":
3242
- return b(t, Js(i, e, t));
3456
+ return y(t, gi(i, e, t));
3243
3457
  case "listItem":
3244
- return b(t, Ut(i, e, t));
3458
+ return y(t, rn(i, e, t));
3245
3459
  case "table":
3246
- return b(t, Zs(i, e, t));
3460
+ return y(t, pi(i, e, t));
3247
3461
  case "tableRow":
3248
- return b(t, Yt(i, e, !1, t));
3462
+ return y(t, on(i, e, !1, t));
3249
3463
  case "tableCell":
3250
- return b(t, Jt(i, e.showMarkup, e.showTableGlue, e.selectionInNode, t));
3464
+ return y(t, cn(i, e.showMarkup, e.showTableGlue, e.selectionInNode, t));
3251
3465
  case "strong":
3252
- return b(t, new Bs(i, I(i.children, F(e), t)));
3466
+ return y(t, new Us(i, R(i.children, V(e), t)));
3253
3467
  case "emphasis":
3254
- return b(t, new Ds(i, I(i.children, F(e), t)));
3468
+ return y(t, new Ys(i, R(i.children, V(e), t)));
3255
3469
  case "strikethrough":
3256
- return b(t, new As(i, I(i.children, F(e), t)));
3470
+ return y(t, new Js(i, R(i.children, V(e), t)));
3257
3471
  case "inlineCode":
3258
- return b(t, new $s(i, I(i.children, F(e), t)));
3472
+ return y(t, new Zs(i, R(i.children, V(e), t)));
3259
3473
  case "inlineMath":
3260
- return b(t, new Fs(i, e.showMarkup, I(i.children, F(e), t)));
3474
+ return y(t, new ei(i, e.showMarkup, R(i.children, V(e), t)));
3261
3475
  case "link":
3262
- return b(t, new Vs(i, I(i.children, F(e), t)));
3476
+ return y(t, new ti(i, R(i.children, V(e), t)));
3263
3477
  case "image":
3264
- return b(t, new Ps(i, e.showMarkup, I(i.children, F(e), t)));
3478
+ return y(t, new ni(i, e.showMarkup, R(i.children, V(e), t)));
3265
3479
  case "document":
3266
- return Qt(i, /* @__PURE__ */ new Set(), w.ofLength(0), void 0);
3480
+ return sn(i, /* @__PURE__ */ new Set(), _.ofLength(0), void 0);
3267
3481
  }
3268
3482
  }
3269
- function De(n) {
3270
- return n.kind === "document" ? n.blocks.map((e) => e.view) : "content" in n ? n.content : Xs;
3483
+ function Ae(n) {
3484
+ return n.kind === "document" ? n.blocks.map((e) => e.view) : "content" in n ? n.content : hi;
3271
3485
  }
3272
- const Xs = [];
3273
- function xe(n) {
3486
+ const hi = [];
3487
+ function be(n) {
3274
3488
  if (!n)
3275
3489
  return;
3276
3490
  const e = /* @__PURE__ */ new Map();
3277
- for (const t of De(n))
3491
+ for (const t of Ae(n))
3278
3492
  e.set(t.ast, t);
3279
3493
  return e;
3280
3494
  }
3281
- function b(n, e) {
3282
- if (n && n.kind === e.kind && n.ast === e.ast && Qs(n, e)) {
3283
- const t = De(n), s = De(e);
3495
+ function y(n, e) {
3496
+ if (n && n.kind === e.kind && n.ast === e.ast && di(n, e)) {
3497
+ const t = Ae(n), s = Ae(e);
3284
3498
  if (t.length === s.length && t.every((i, r) => i === s[r]))
3285
3499
  return n;
3286
3500
  }
3287
3501
  return e;
3288
3502
  }
3289
- function Qs(n, e) {
3503
+ function di(n, e) {
3290
3504
  switch (n.kind) {
3291
3505
  case "text":
3292
3506
  return n.showWhitespace === e.showWhitespace && n.leftWordBoundary === e.leftWordBoundary && n.rightWordBoundary === e.rightWordBoundary;
@@ -3316,17 +3530,17 @@ function Qs(n, e) {
3316
3530
  return !0;
3317
3531
  }
3318
3532
  }
3319
- function I(n, e, t) {
3320
- const s = xe(t);
3533
+ function R(n, e, t) {
3534
+ const s = be(t);
3321
3535
  return n.map((i, r) => {
3322
3536
  const o = i.kind === "text" ? {
3323
- left: r > 0 && bt(n[r - 1], "end"),
3324
- right: r < n.length - 1 && bt(n[r + 1], "start")
3537
+ left: r > 0 && Tt(n[r - 1], "end"),
3538
+ right: r < n.length - 1 && Tt(n[r + 1], "start")
3325
3539
  } : void 0;
3326
- return he(i, e, s?.get(i), o);
3540
+ return de(i, e, s?.get(i), o);
3327
3541
  });
3328
3542
  }
3329
- function bt(n, e) {
3543
+ function Tt(n, e) {
3330
3544
  switch (n.kind) {
3331
3545
  case "text": {
3332
3546
  const t = n.content, s = e === "end" ? t[t.length - 1] : t[0];
@@ -3345,83 +3559,83 @@ function bt(n, e) {
3345
3559
  return !1;
3346
3560
  }
3347
3561
  }
3348
- function Us(n, e) {
3562
+ function ui(n, e) {
3349
3563
  return e.showMarkup || n === "tableCellGlue" && e.showTableGlue;
3350
3564
  }
3351
- function Ys(n, e) {
3565
+ function fi(n, e) {
3352
3566
  return e.showMarkup || n === "tableCellGlue" && e.showTableGlue;
3353
3567
  }
3354
- function Js(n, e, t) {
3355
- const s = xe(t), i = ei(n, e), r = new Set(n.items), o = (e.listLevel ?? 0) + 1, c = [];
3356
- let l = 0;
3357
- for (const a of n.children) {
3358
- if (r.has(a)) {
3359
- const h = a, g = i.has(n.items.indexOf(h)), d = {
3360
- showMarkup: g,
3568
+ function gi(n, e, t) {
3569
+ const s = be(t), i = mi(n, e), r = new Set(n.items), o = (e.listLevel ?? 0) + 1, c = [];
3570
+ let a = 0;
3571
+ for (const l of n.children) {
3572
+ if (r.has(l)) {
3573
+ const h = l, u = i.has(n.items.indexOf(h)), f = {
3574
+ showMarkup: u,
3361
3575
  showTableGlue: !1,
3362
- selectionInNode: g && e.selectionInNode ? e.selectionInNode.delta(-l) : void 0,
3576
+ selectionInNode: u && e.selectionInNode ? e.selectionInNode.delta(-a) : void 0,
3363
3577
  listLevel: o
3364
3578
  };
3365
- c.push(b(s?.get(h), Ut(h, d, s?.get(h))));
3579
+ c.push(y(s?.get(h), rn(h, f, s?.get(h))));
3366
3580
  } else
3367
- c.push(he(a, e, s?.get(a)));
3368
- l += a.length;
3581
+ c.push(de(l, e, s?.get(l)));
3582
+ a += l.length;
3369
3583
  }
3370
- return new Ns(n, c);
3584
+ return new Xs(n, c);
3371
3585
  }
3372
- function Ut(n, e, t) {
3373
- const s = xe(t), i = [];
3586
+ function rn(n, e, t) {
3587
+ const s = be(t), i = [];
3374
3588
  let r = 0;
3375
3589
  for (const o of n.children) {
3376
3590
  const c = e.selectionInNode ? { ...e, selectionInNode: e.selectionInNode.delta(-r) } : e;
3377
- i.push(he(o, c, s?.get(o))), r += o.length;
3591
+ i.push(de(o, c, s?.get(o))), r += o.length;
3378
3592
  }
3379
- return new Ks(n, e.showMarkup, i, e.listLevel ?? 1);
3593
+ return new si(n, e.showMarkup, i, e.listLevel ?? 1);
3380
3594
  }
3381
- function Zs(n, e, t) {
3382
- const s = xe(t), i = e.showMarkup, r = n.delimiterRow, o = new Set(
3383
- [n.headerRow, n.delimiterRow, ...n.bodyRows].filter((a) => a !== void 0)
3595
+ function pi(n, e, t) {
3596
+ const s = be(t), i = e.showMarkup, r = n.delimiterRow, o = new Set(
3597
+ [n.headerRow, n.delimiterRow, ...n.bodyRows].filter((l) => l !== void 0)
3384
3598
  ), c = [];
3385
- let l = 0;
3386
- for (const a of n.children) {
3387
- if (o.has(a)) {
3388
- const h = a, g = h === r, d = {
3599
+ let a = 0;
3600
+ for (const l of n.children) {
3601
+ if (o.has(l)) {
3602
+ const h = l, u = h === r, f = {
3389
3603
  showMarkup: i,
3390
3604
  showTableGlue: i,
3391
- selectionInNode: !g && i && e.selectionInNode ? e.selectionInNode.delta(-l) : void 0
3605
+ selectionInNode: !u && i && e.selectionInNode ? e.selectionInNode.delta(-a) : void 0
3392
3606
  };
3393
- c.push(b(s?.get(h), Yt(h, d, g, s?.get(h))));
3607
+ c.push(y(s?.get(h), on(h, f, u, s?.get(h))));
3394
3608
  } else
3395
- c.push(he(a, e, s?.get(a)));
3396
- l += a.length;
3609
+ c.push(de(l, e, s?.get(l)));
3610
+ a += l.length;
3397
3611
  }
3398
- return new Rs(n, c);
3612
+ return new Qs(n, c);
3399
3613
  }
3400
- function Yt(n, e, t, s) {
3401
- const i = xe(s), r = e.showMarkup, o = t ? void 0 : ti(n, e), c = new Set(n.cells), l = [];
3402
- let a = 0;
3614
+ function on(n, e, t, s) {
3615
+ const i = be(s), r = e.showMarkup, o = t ? void 0 : _i(n, e), c = new Set(n.cells), a = [];
3616
+ let l = 0;
3403
3617
  for (const h of n.children) {
3404
3618
  if (c.has(h)) {
3405
- const g = h, d = t ? r : o.has(n.cells.indexOf(g)), u = d && e.selectionInNode ? e.selectionInNode.delta(-a) : void 0;
3406
- l.push(Jt(g, d, r, u, i?.get(g)));
3619
+ const u = h, f = t ? r : o.has(n.cells.indexOf(u)), d = f && e.selectionInNode ? e.selectionInNode.delta(-l) : void 0;
3620
+ a.push(cn(u, f, r, d, i?.get(u)));
3407
3621
  } else
3408
- l.push(he(h, e, i?.get(h)));
3409
- a += h.length;
3622
+ a.push(de(h, e, i?.get(h)));
3623
+ l += h.length;
3410
3624
  }
3411
- return new Hs(n, t, l);
3625
+ return new ii(n, t, a);
3412
3626
  }
3413
- function Jt(n, e, t, s, i) {
3627
+ function cn(n, e, t, s, i) {
3414
3628
  const r = { showMarkup: e, showTableGlue: t, selectionInNode: s };
3415
- return new Ws(n, e, t, I(n.children, F(r), i));
3629
+ return new ri(n, e, t, R(n.children, V(r), i));
3416
3630
  }
3417
- const Oe = /* @__PURE__ */ new Set();
3418
- function ei(n, e) {
3631
+ const Me = /* @__PURE__ */ new Set();
3632
+ function mi(n, e) {
3419
3633
  if (!e.showMarkup || !e.selectionInNode)
3420
- return Oe;
3634
+ return Me;
3421
3635
  const t = e.selectionInNode;
3422
3636
  if (t.isEmpty) {
3423
- const r = Pt(n, t.start);
3424
- return r === void 0 ? Oe : /* @__PURE__ */ new Set([r]);
3637
+ const r = Ge(n, t.start);
3638
+ return r === void 0 ? Me : /* @__PURE__ */ new Set([r]);
3425
3639
  }
3426
3640
  const s = /* @__PURE__ */ new Set();
3427
3641
  let i = 0;
@@ -3431,13 +3645,13 @@ function ei(n, e) {
3431
3645
  }
3432
3646
  return s;
3433
3647
  }
3434
- function ti(n, e) {
3648
+ function _i(n, e) {
3435
3649
  if (!e.showMarkup || !e.selectionInNode)
3436
- return Oe;
3650
+ return Me;
3437
3651
  const t = e.selectionInNode;
3438
3652
  if (t.isEmpty) {
3439
- const r = ni(n, t.start);
3440
- return r === void 0 ? Oe : /* @__PURE__ */ new Set([r]);
3653
+ const r = wi(n, t.start);
3654
+ return r === void 0 ? Me : /* @__PURE__ */ new Set([r]);
3441
3655
  }
3442
3656
  const s = /* @__PURE__ */ new Set();
3443
3657
  let i = 0;
@@ -3447,7 +3661,7 @@ function ti(n, e) {
3447
3661
  }
3448
3662
  return s;
3449
3663
  }
3450
- function ni(n, e) {
3664
+ function wi(n, e) {
3451
3665
  let t = 0;
3452
3666
  for (const s of n.children) {
3453
3667
  const i = t + s.length, r = n.cells.indexOf(s);
@@ -3456,34 +3670,90 @@ function ni(n, e) {
3456
3670
  t = i;
3457
3671
  }
3458
3672
  }
3459
- class si extends le {
3673
+ class ki extends se {
3460
3674
  constructor(e, t) {
3461
- super(), this._parent = e, this.element = document.createElement("div"), this.element.className = "md-cursor", this.rendering = V(this, (s) => {
3462
- const i = s.readObservable(t.offset), r = s.readObservable(t.visualLineMap);
3463
- if (i === void 0 || r.isEmpty)
3464
- return this.element.style.display = "none", new yt(i ?? 0, !1, B.EMPTY);
3465
- const o = r.lineIndexOfOffset(i), c = r.lineRect(o).withZeroWidthAt(r.xAtOffset(i)), l = this._parent.getBoundingClientRect(), a = c.translate(-l.left, -l.top);
3466
- return this.element.style.left = `${a.x}px`, this.element.style.top = `${a.y}px`, this.element.style.height = `${a.height}px`, this.element.style.display = "", new yt(i, !0, a);
3467
- }), this._register(ee((s) => {
3675
+ super(), this._parent = e, this.element = document.createElement("div"), this.element.className = "md-cursor", this.rendering = $(this, (s) => {
3676
+ const i = t.pendingCaretRect ? s.readObservable(t.pendingCaretRect) : void 0;
3677
+ if (i) {
3678
+ const u = this._parent.getBoundingClientRect(), f = i.translate(-u.left, -u.top);
3679
+ return this.element.style.left = `${f.x}px`, this.element.style.top = `${f.y}px`, this.element.style.height = `${f.height}px`, this.element.style.display = "", new Be(0, !0, f);
3680
+ }
3681
+ const r = s.readObservable(t.offset), o = s.readObservable(t.visualLineMap);
3682
+ if (r === void 0 || o.isEmpty)
3683
+ return this.element.style.display = "none", new Be(r ?? 0, !1, D.EMPTY);
3684
+ const c = o.lineIndexOfOffset(r), a = o.lineRect(c).withZeroWidthAt(o.xAtOffset(r)), l = this._parent.getBoundingClientRect(), h = a.translate(-l.left, -l.top);
3685
+ return this.element.style.left = `${h.x}px`, this.element.style.top = `${h.y}px`, this.element.style.height = `${h.height}px`, this.element.style.display = "", new Be(r, !0, h);
3686
+ }), this._register(G((s) => {
3468
3687
  s.readObservable(this.rendering);
3469
- })), this._register(ee((s) => {
3688
+ })), this._register(G((s) => {
3470
3689
  s.readObservable(t.offset), this.element.style.animation = "none", this.element.offsetWidth, this.element.style.animation = "";
3471
3690
  }));
3472
3691
  }
3473
3692
  element;
3474
3693
  rendering;
3475
3694
  }
3476
- class yt {
3695
+ class Be {
3477
3696
  constructor(e, t, s) {
3478
3697
  this.offset = e, this.visible = t, this.rect = s;
3479
3698
  }
3480
3699
  }
3481
- class ii extends le {
3700
+ class vi extends se {
3701
+ constructor(e, t) {
3702
+ super(), this._parent = e, this.element = document.createElement("div"), this.element.className = "md-gutter-layer", this.rendering = $(this, (s) => {
3703
+ const i = s.readObservable(t.markers), r = s.readObservable(t.visualLineMap);
3704
+ return this._render(i, r);
3705
+ }), this._register(G((s) => {
3706
+ s.readObservable(this.rendering);
3707
+ }));
3708
+ }
3709
+ element;
3710
+ rendering;
3711
+ _render(e, t) {
3712
+ if (this.element.replaceChildren(), t.isEmpty)
3713
+ return new Mt([]);
3714
+ const s = this._parent.getBoundingClientRect(), i = [];
3715
+ for (const r of e) {
3716
+ const o = r.type === "deleted" || r.range.isEmpty ? bi(r, t, s.top) : xi(r, t, s.top);
3717
+ if (!o)
3718
+ continue;
3719
+ const c = document.createElement("div");
3720
+ c.className = `md-gutter-marker md-gutter-marker-${o.type}`, c.style.top = `${o.y}px`, o.height > 0 && (c.style.height = `${o.height}px`), this.element.appendChild(c), i.push(o);
3721
+ }
3722
+ return new Mt(i);
3723
+ }
3724
+ }
3725
+ class Mt {
3726
+ constructor(e) {
3727
+ this.rects = e;
3728
+ }
3729
+ }
3730
+ function xi(n, e, t) {
3731
+ let s = 1 / 0, i = -1 / 0;
3732
+ for (const r of e.lines) {
3733
+ const o = yi(r);
3734
+ !o || !n.range.intersects(o) || (s = Math.min(s, r.rect.top), i = Math.max(i, r.rect.top + r.rect.height));
3735
+ }
3736
+ if (!(i <= s))
3737
+ return { type: n.type, y: s - t, height: i - s };
3738
+ }
3739
+ function bi(n, e, t) {
3740
+ const s = e.lineIndexOfOffset(n.range.start);
3741
+ return { type: "deleted", y: e.lineRect(s).top - t, height: 0 };
3742
+ }
3743
+ function yi(n) {
3744
+ if (n.runs.length === 0)
3745
+ return;
3746
+ let e = 1 / 0, t = -1 / 0;
3747
+ for (const s of n.runs)
3748
+ s.sourceStart < e && (e = s.sourceStart), s.sourceEndExclusive > t && (t = s.sourceEndExclusive);
3749
+ return _.fromTo(e, t);
3750
+ }
3751
+ class Ei extends se {
3482
3752
  constructor(e, t) {
3483
- super(), this._parent = e, this.element = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.element.setAttribute("class", "md-selection-layer"), this._path = document.createElementNS("http://www.w3.org/2000/svg", "path"), this._path.setAttribute("class", "md-selection-path"), this.element.appendChild(this._path), this.rendering = V(this, (s) => {
3753
+ super(), this._parent = e, this.element = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.element.setAttribute("class", "md-selection-layer"), this._path = document.createElementNS("http://www.w3.org/2000/svg", "path"), this._path.setAttribute("class", "md-selection-path"), this.element.appendChild(this._path), this.rendering = $(this, (s) => {
3484
3754
  const i = s.readObservable(t.selection), r = s.readObservable(t.visualLineMap), o = s.readObservable(t.blocks);
3485
- return ri(this._path, this._parent, i, r, o);
3486
- }), this._register(ee((s) => {
3755
+ return Ci(this._path, this._parent, i, r, o);
3756
+ }), this._register(G((s) => {
3487
3757
  s.readObservable(this.rendering);
3488
3758
  }));
3489
3759
  }
@@ -3491,125 +3761,125 @@ class ii extends le {
3491
3761
  rendering;
3492
3762
  _path;
3493
3763
  }
3494
- class Et {
3764
+ class St {
3495
3765
  constructor(e) {
3496
3766
  this.rects = e;
3497
3767
  }
3498
3768
  }
3499
- function ri(n, e, t, s, i) {
3769
+ function Ci(n, e, t, s, i) {
3500
3770
  if (!t || t.isCollapsed)
3501
- return n.setAttribute("d", ""), new Et([]);
3771
+ return n.setAttribute("d", ""), new St([]);
3502
3772
  const r = t.range, o = e.getBoundingClientRect(), c = [];
3503
- for (const u of s.lines) {
3504
- const f = Zt(u);
3505
- if (!f || !r.intersects(f))
3773
+ for (const d of s.lines) {
3774
+ const g = an(d);
3775
+ if (!g || !r.intersects(g))
3506
3776
  continue;
3507
- const p = i.find((m) => w.ofStartAndLength(m.absoluteStart, m.block.length).containsRange(f));
3508
- c.push({ line: u, lineRange: f, block: p });
3509
- }
3510
- const l = [], a = [];
3511
- for (let u = 0; u < c.length; u++) {
3512
- const { line: f, lineRange: p } = c[u], m = u === 0, _ = u === c.length - 1, v = m ? f.xAtOffset(Math.max(r.start, p.start)) : f.rect.left, y = _ ? f.xAtOffset(Math.min(r.endExclusive, p.endExclusive)) : f.rect.right;
3513
- l.push({
3514
- x: v - o.left,
3515
- y: f.rect.top - o.top,
3516
- width: Math.max(0, y - v),
3517
- height: f.rect.height
3518
- }), a.push({ left: v, right: y, top: f.rect.top, bottom: f.rect.top + f.rect.height });
3519
- }
3520
- for (let u = 0; u < a.length - 1; u++) {
3521
- const f = a[u], p = a[u + 1];
3522
- if (p.top <= f.bottom)
3777
+ const p = i.find((m) => _.ofStartAndLength(m.absoluteStart, m.block.length).containsRange(g));
3778
+ c.push({ line: d, lineRange: g, block: p });
3779
+ }
3780
+ const a = [], l = [];
3781
+ for (let d = 0; d < c.length; d++) {
3782
+ const { line: g, lineRange: p } = c[d], m = d === 0, w = d === c.length - 1, x = m ? g.xAtOffset(Math.max(r.start, p.start)) : g.rect.left, E = w ? g.xAtOffset(Math.min(r.endExclusive, p.endExclusive)) : g.rect.right;
3783
+ a.push({
3784
+ x: x - o.left,
3785
+ y: g.rect.top - o.top,
3786
+ width: Math.max(0, E - x),
3787
+ height: g.rect.height
3788
+ }), l.push({ left: x, right: E, top: g.rect.top, bottom: g.rect.top + g.rect.height });
3789
+ }
3790
+ for (let d = 0; d < l.length - 1; d++) {
3791
+ const g = l[d], p = l[d + 1];
3792
+ if (p.top <= g.bottom)
3523
3793
  continue;
3524
- const m = Math.max(f.left, p.left), _ = Math.min(f.right, p.right);
3525
- _ <= m || l.push({
3794
+ const m = Math.max(g.left, p.left), w = Math.min(g.right, p.right);
3795
+ w <= m || a.push({
3526
3796
  x: m - o.left,
3527
- y: f.bottom - o.top,
3528
- width: _ - m,
3529
- height: p.top - f.bottom
3797
+ y: g.bottom - o.top,
3798
+ width: w - m,
3799
+ height: p.top - g.bottom
3530
3800
  });
3531
3801
  }
3532
- const h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
3533
- for (let u = 0; u < c.length; u++) {
3534
- const f = c[u].block;
3535
- f && (h.has(f) || h.set(f, u), g.set(f, u));
3802
+ const h = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
3803
+ for (let d = 0; d < c.length; d++) {
3804
+ const g = c[d].block;
3805
+ g && (h.has(g) || h.set(g, d), u.set(g, d));
3536
3806
  }
3537
- const d = i.map(
3538
- (u) => r.intersects(w.ofStartAndLength(u.absoluteStart, u.block.length))
3807
+ const f = i.map(
3808
+ (d) => r.intersects(_.ofStartAndLength(d.absoluteStart, d.block.length))
3539
3809
  );
3540
- for (let u = 0; u < i.length - 1; u++) {
3541
- const f = i[u], p = i[u + 1], m = f.absoluteStart + f.block.length, _ = p.absoluteStart;
3542
- if (m < _ && !r.containsRange(w.fromTo(m, _)) || m >= _ && !(d[u] && d[u + 1]))
3810
+ for (let d = 0; d < i.length - 1; d++) {
3811
+ const g = i[d], p = i[d + 1], m = g.absoluteStart + g.block.length, w = p.absoluteStart;
3812
+ if (m < w && !r.containsRange(_.fromTo(m, w)) || m >= w && !(f[d] && f[d + 1]))
3543
3813
  continue;
3544
- const v = f.element.getBoundingClientRect(), y = p.element.getBoundingClientRect(), M = oi(s, p, y.top), A = v.bottom;
3545
- if (M <= A)
3814
+ const x = g.element.getBoundingClientRect(), E = p.element.getBoundingClientRect(), M = Oi(s, p, E.top), P = x.bottom;
3815
+ if (M <= P)
3546
3816
  continue;
3547
- const de = g.get(f), Qe = h.get(p), Ue = de !== void 0 ? a[de] : { left: v.left, right: v.right }, Ye = Qe !== void 0 ? a[Qe] : { left: y.left, right: y.right }, Se = Math.max(Ue.left, Ye.left), Je = Math.min(Ue.right, Ye.right);
3548
- Je <= Se || l.push({
3549
- x: Se - o.left,
3550
- y: A - o.top,
3551
- width: Je - Se,
3552
- height: M - A
3817
+ const ue = u.get(g), Ze = h.get(p), et = ue !== void 0 ? l[ue] : { left: x.left, right: x.right }, tt = Ze !== void 0 ? l[Ze] : { left: E.left, right: E.right }, Re = Math.max(et.left, tt.left), nt = Math.min(et.right, tt.right);
3818
+ nt <= Re || a.push({
3819
+ x: Re - o.left,
3820
+ y: P - o.top,
3821
+ width: nt - Re,
3822
+ height: M - P
3553
3823
  });
3554
3824
  }
3555
- for (const u of i) {
3556
- const f = w.ofStartAndLength(u.absoluteStart, u.block.length);
3557
- if (!r.intersects(f))
3825
+ for (const d of i) {
3826
+ const g = _.ofStartAndLength(d.absoluteStart, d.block.length);
3827
+ if (!r.intersects(g))
3558
3828
  continue;
3559
3829
  let p = !1;
3560
- for (const { lineRange: _ } of c)
3561
- if (_.intersects(f)) {
3830
+ for (const { lineRange: w } of c)
3831
+ if (w.intersects(g)) {
3562
3832
  p = !0;
3563
3833
  break;
3564
3834
  }
3565
3835
  if (p)
3566
3836
  continue;
3567
- const m = u.element.getBoundingClientRect();
3568
- l.push({
3837
+ const m = d.element.getBoundingClientRect();
3838
+ a.push({
3569
3839
  x: m.left - o.left,
3570
3840
  y: m.top - o.top,
3571
3841
  width: m.width,
3572
3842
  height: m.height
3573
3843
  });
3574
3844
  }
3575
- return n.setAttribute("d", ci(l, 4)), new Et(l);
3845
+ return n.setAttribute("d", Ti(a, 4)), new St(a);
3576
3846
  }
3577
- function Zt(n) {
3847
+ function an(n) {
3578
3848
  if (n.runs.length === 0)
3579
3849
  return;
3580
3850
  let e = 1 / 0, t = -1 / 0;
3581
3851
  for (const s of n.runs)
3582
3852
  s.sourceStart < e && (e = s.sourceStart), s.sourceEndExclusive > t && (t = s.sourceEndExclusive);
3583
- return w.fromTo(e, t);
3853
+ return _.fromTo(e, t);
3584
3854
  }
3585
- function oi(n, e, t) {
3586
- const s = w.ofStartAndLength(e.absoluteStart, e.block.length);
3855
+ function Oi(n, e, t) {
3856
+ const s = _.ofStartAndLength(e.absoluteStart, e.block.length);
3587
3857
  for (const i of n.lines) {
3588
- const r = Zt(i);
3858
+ const r = an(i);
3589
3859
  if (r && s.containsRange(r))
3590
3860
  return i.rect.top;
3591
3861
  }
3592
3862
  return t;
3593
3863
  }
3594
- function ci(n, e) {
3864
+ function Ti(n, e) {
3595
3865
  if (n.length === 0)
3596
3866
  return "";
3597
3867
  const t = n.slice().sort((r, o) => r.y - o.y || r.x - o.x), s = [];
3598
3868
  let i = [];
3599
3869
  for (const r of t) {
3600
- const o = i[i.length - 1], c = o !== void 0 && r.y <= o.y + o.height + 0.5, l = o !== void 0 && Math.max(o.x, r.x) < Math.min(o.x + o.width, r.x + r.width);
3601
- c && l ? i.push(r) : (i.length > 0 && s.push(i), i = [r]);
3870
+ const o = i[i.length - 1], c = o !== void 0 && r.y <= o.y + o.height + 0.5, a = o !== void 0 && Math.max(o.x, r.x) < Math.min(o.x + o.width, r.x + r.width);
3871
+ c && a ? i.push(r) : (i.length > 0 && s.push(i), i = [r]);
3602
3872
  }
3603
- return i.length > 0 && s.push(i), s.map((r) => li(r, e)).filter(Boolean).join(" ");
3873
+ return i.length > 0 && s.push(i), s.map((r) => Mi(r, e)).filter(Boolean).join(" ");
3604
3874
  }
3605
- function li(n, e) {
3875
+ function Mi(n, e) {
3606
3876
  const t = [];
3607
3877
  t.push({ x: n[0].x + n[0].width, y: n[0].y, convex: !0 });
3608
3878
  for (let i = 0; i < n.length - 1; i++) {
3609
- const r = n[i], o = n[i + 1], c = r.x + r.width, l = o.x + o.width;
3610
- if (Math.abs(c - l) > 0.5) {
3611
- const a = r.y + r.height, h = c > l;
3612
- t.push({ x: c, y: a, convex: h }), t.push({ x: l, y: a, convex: !h });
3879
+ const r = n[i], o = n[i + 1], c = r.x + r.width, a = o.x + o.width;
3880
+ if (Math.abs(c - a) > 0.5) {
3881
+ const l = r.y + r.height, h = c > a;
3882
+ t.push({ x: c, y: l, convex: h }), t.push({ x: a, y: l, convex: !h });
3613
3883
  }
3614
3884
  }
3615
3885
  const s = n[n.length - 1];
@@ -3617,63 +3887,67 @@ function li(n, e) {
3617
3887
  for (let i = n.length - 1; i > 0; i--) {
3618
3888
  const r = n[i], o = n[i - 1];
3619
3889
  if (Math.abs(r.x - o.x) > 0.5) {
3620
- const c = r.y, l = r.x < o.x;
3621
- t.push({ x: r.x, y: c, convex: l }), t.push({ x: o.x, y: c, convex: !l });
3890
+ const c = r.y, a = r.x < o.x;
3891
+ t.push({ x: r.x, y: c, convex: a }), t.push({ x: o.x, y: c, convex: !a });
3622
3892
  }
3623
3893
  }
3624
- return t.push({ x: n[0].x, y: n[0].y, convex: !0 }), ai(t, e);
3894
+ return t.push({ x: n[0].x, y: n[0].y, convex: !0 }), Si(t, e);
3625
3895
  }
3626
- function ai(n, e) {
3896
+ function Si(n, e) {
3627
3897
  const t = n.length;
3628
3898
  if (t < 3)
3629
3899
  return "";
3630
3900
  const s = new Array(t);
3631
3901
  for (let o = 0; o < t; o++) {
3632
- const c = n[(o + t - 1) % t], l = n[(o + 1) % t], a = ye(n[o], c), h = ye(n[o], l);
3633
- s[o] = Math.min(e, a / 2, h / 2);
3902
+ const c = n[(o + t - 1) % t], a = n[(o + 1) % t], l = Oe(n[o], c), h = Oe(n[o], a);
3903
+ s[o] = Math.min(e, l / 2, h / 2);
3634
3904
  }
3635
- const i = Re(n[t - 1], n[0], ye(n[t - 1], n[0]) - s[0]), r = [`M${$(i.x)},${$(i.y)}`];
3905
+ const i = De(n[t - 1], n[0], Oe(n[t - 1], n[0]) - s[0]), r = [`M${F(i.x)},${F(i.y)}`];
3636
3906
  for (let o = 0; o < t; o++) {
3637
- const c = n[o], l = n[(o + 1) % t], a = s[o], h = Re(c, l, a);
3638
- a > 0 ? r.push(`A${$(a)},${$(a)} 0 0 ${c.convex ? 1 : 0} ${$(h.x)},${$(h.y)}`) : r.push(`L${$(h.x)},${$(h.y)}`);
3639
- const g = s[(o + 1) % t], d = Re(c, l, ye(c, l) - g);
3640
- r.push(`L${$(d.x)},${$(d.y)}`);
3907
+ const c = n[o], a = n[(o + 1) % t], l = s[o], h = De(c, a, l);
3908
+ l > 0 ? r.push(`A${F(l)},${F(l)} 0 0 ${c.convex ? 1 : 0} ${F(h.x)},${F(h.y)}`) : r.push(`L${F(h.x)},${F(h.y)}`);
3909
+ const u = s[(o + 1) % t], f = De(c, a, Oe(c, a) - u);
3910
+ r.push(`L${F(f.x)},${F(f.y)}`);
3641
3911
  }
3642
3912
  return r.push("Z"), r.join(" ");
3643
3913
  }
3644
- function ye(n, e) {
3914
+ function Oe(n, e) {
3645
3915
  return Math.hypot(n.x - e.x, n.y - e.y);
3646
3916
  }
3647
- function Re(n, e, t) {
3917
+ function De(n, e, t) {
3648
3918
  const s = e.x - n.x, i = e.y - n.y, r = Math.hypot(s, i);
3649
3919
  if (r === 0)
3650
3920
  return { x: n.x, y: n.y };
3651
3921
  const o = t / r;
3652
3922
  return { x: n.x + s * o, y: n.y + i * o };
3653
3923
  }
3654
- function $(n) {
3924
+ function F(n) {
3655
3925
  return n.toFixed(2);
3656
3926
  }
3657
- const hi = 900;
3658
- class $i extends le {
3927
+ const Li = 900;
3928
+ class sr extends se {
3659
3929
  constructor(e, t) {
3660
3930
  super(), this._model = e, this._options = t, this.element = document.createElement("div"), this.element.className = "md-editor", this._options?.classNames && this.element.classList.add(...this._options.classNames), this.element.tabIndex = 0, this._contentContainer = document.createElement("div"), this._contentContainer.className = "md-editor-content", this.element.appendChild(this._contentContainer);
3661
- const s = this._options?.limitedWidth ?? hn(hi);
3662
- this._register(ee((i) => {
3931
+ const s = this._options?.limitedWidth ?? wn(Li);
3932
+ this._register(G((i) => {
3663
3933
  const r = s.read(i);
3664
3934
  this._contentContainer.style.maxWidth = r === void 0 ? "" : `${r}px`;
3665
- })), this.measuredLayout = new Hn(), this._selectionView = this._register(new ii(this._contentContainer, {
3935
+ })), this.measuredLayout = new Qn(), this._selectionView = this._register(new Ei(this._contentContainer, {
3666
3936
  selection: this._model.selection,
3667
3937
  visualLineMap: this.measuredLayout.visualLineMap,
3668
3938
  blocks: this._selectionBlocksObs
3669
- })), this._contentContainer.appendChild(this._selectionView.element), this._cursorView = this._register(new si(this._contentContainer, {
3939
+ })), this._contentContainer.appendChild(this._selectionView.element), this._cursorView = this._register(new ki(this._contentContainer, {
3670
3940
  offset: this._model.cursorOffset,
3941
+ visualLineMap: this.measuredLayout.visualLineMap,
3942
+ pendingCaretRect: this._pendingCaretRect
3943
+ })), this._contentContainer.appendChild(this._cursorView.element), this._gutterMarkersView = this._register(new vi(this._contentContainer, {
3944
+ markers: this._model.gutterMarkers,
3671
3945
  visualLineMap: this.measuredLayout.visualLineMap
3672
- })), this._contentContainer.appendChild(this._cursorView.element), this.editContext = new EditContext({
3946
+ })), this._contentContainer.appendChild(this._gutterMarkersView.element), this.editContext = new EditContext({
3673
3947
  text: this._model.sourceText.get().value,
3674
3948
  selectionStart: 0,
3675
3949
  selectionEnd: 0
3676
- }), this.element.editContext = this.editContext, this._register(ee(this._renderAutorun)), this._register(ee((i) => {
3950
+ }), this.element.editContext = this.editContext, this._register(G(this._renderAutorun)), this._setupModifierTracking(), this._register(G((i) => {
3677
3951
  const r = i.readObservable(this._model.selection)?.range;
3678
3952
  this.editContext.updateSelection(r?.start ?? 0, r?.endExclusive ?? 0);
3679
3953
  })), this._register({ dispose: () => {
@@ -3692,13 +3966,14 @@ class $i extends le {
3692
3966
  _contentContainer;
3693
3967
  _cursorView;
3694
3968
  _selectionView;
3969
+ _gutterMarkersView;
3695
3970
  /**
3696
3971
  * The mounted block sequence, in source order. Rebuilt (not mutated) each
3697
3972
  * frame by {@link DocumentViewNode.create}; the view just swaps one
3698
3973
  * immutable node for the next. Never used for source-of-truth lookups
3699
3974
  * (those go through the measured-layout model).
3700
3975
  */
3701
- _document = U(this, void 0);
3976
+ _document = B(this, void 0);
3702
3977
  /** The current view-node tree (AST overlaid with rendered DOM), for debugging. */
3703
3978
  get documentViewNode() {
3704
3979
  return this._document;
@@ -3711,16 +3986,23 @@ class $i extends le {
3711
3986
  */
3712
3987
  _previousViewData;
3713
3988
  /** The current view-data tree (AST overlaid with selection flags), for debugging. */
3714
- _viewData = U(this, void 0);
3989
+ _viewData = B(this, void 0);
3715
3990
  get viewData() {
3716
3991
  return this._viewData;
3717
3992
  }
3993
+ /**
3994
+ * Caret rect (client coords) for the transient empty paragraph, or
3995
+ * `undefined` when none is armed. Set each frame from the synthetic
3996
+ * paragraph element's geometry and fed to the {@link CursorView}, which has
3997
+ * no visual-line-map entry to place the caret from otherwise.
3998
+ */
3999
+ _pendingCaretRect = B(this, void 0);
3718
4000
  /**
3719
4001
  * The block cache projected for views (selection painting) that need to
3720
4002
  * react to mount/unmount. Derived from {@link _document}, so it stays in
3721
4003
  * lock-step without any manual bookkeeping.
3722
4004
  */
3723
- _selectionBlocksObs = V(this, (e) => {
4005
+ _selectionBlocksObs = $(this, (e) => {
3724
4006
  const t = this._document.read(e);
3725
4007
  return t ? t.blocks.map((s) => ({
3726
4008
  block: s.node.block,
@@ -3729,6 +4011,17 @@ class $i extends le {
3729
4011
  element: s.node.element
3730
4012
  })) : [];
3731
4013
  });
4014
+ /**
4015
+ * Mirrors the model's live Ctrl/Cmd state onto the editor root as
4016
+ * `.md-mod-down` so CSS can show the link-open underline and pointer cursor
4017
+ * only while a click would actually open the link: an inactive link opens on
4018
+ * a plain click, but an active link only opens with the modifier held.
4019
+ */
4020
+ _setupModifierTracking() {
4021
+ this._register(G((e) => {
4022
+ this.element.classList.toggle("md-mod-down", this._model.ctrlOrMetaDown.read(e));
4023
+ }));
4024
+ }
3732
4025
  focus() {
3733
4026
  this.element.focus({ preventScroll: !0 });
3734
4027
  }
@@ -3738,7 +4031,7 @@ class $i extends le {
3738
4031
  * original block.
3739
4032
  */
3740
4033
  resolveOffsetFromPoint(e) {
3741
- const t = Cs(e);
4034
+ const t = Vs(e);
3742
4035
  if (t)
3743
4036
  return this._document.get()?.resolveSource(t);
3744
4037
  }
@@ -3759,17 +4052,29 @@ class $i extends le {
3759
4052
  }
3760
4053
  // ----- render autorun ------------------------------------------------
3761
4054
  _renderAutorun = (e) => {
3762
- const t = e.readObservable(this._model.document), s = e.readObservable(this._model.sourceText).value, i = e.readObservable(this._model.activeBlocks), r = e.readObservable(this._model.selection);
4055
+ const t = e.readObservable(this._model.document), s = e.readObservable(this._model.sourceText).value, i = e.readObservable(this._model.activeBlocks), r = e.readObservable(this._model.selection), o = e.readObservable(this._model.pendingParagraph);
3763
4056
  this.editContext.text !== s && this.editContext.updateText(0, this.editContext.text.length, s);
3764
- const o = this._document.get(), c = Qt(t, i, r?.range, this._previousViewData);
3765
- this._previousViewData = c, this._viewData.set(c, void 0);
3766
- const l = Xe.create(c, this._options, o);
3767
- if (o) {
3768
- if (l.contentDomNode !== o.contentDomNode)
4057
+ const c = this._document.get(), a = sn(
4058
+ t,
4059
+ i,
4060
+ r?.range,
4061
+ this._previousViewData,
4062
+ o ? { anchorBlock: o.anchorBlock, ast: o.syntheticAst } : void 0
4063
+ );
4064
+ this._previousViewData = a, this._viewData.set(a, void 0);
4065
+ const l = Je.create(a, this._options, c);
4066
+ if (c) {
4067
+ if (l.contentDomNode !== c.contentDomNode)
3769
4068
  throw new Error("DocumentViewNode.contentDomNode must be stable across rebuilds");
3770
4069
  } else
3771
4070
  this._contentContainer.insertBefore(l.contentDomNode, this._contentContainer.firstChild);
3772
4071
  this._document.set(l, void 0), this._publishMeasurements(l);
4072
+ const h = l.pendingElement;
4073
+ if (h) {
4074
+ const u = h.getBoundingClientRect();
4075
+ this._pendingCaretRect.set(D.fromPointSize(u.left, u.top, 2, u.height), void 0);
4076
+ } else
4077
+ this._pendingCaretRect.set(void 0, void 0);
3773
4078
  };
3774
4079
  /** Current mounted blocks, or empty before the first render. */
3775
4080
  get _blocks() {
@@ -3785,7 +4090,7 @@ class $i extends le {
3785
4090
  for (const s of e.blocks) {
3786
4091
  const i = s.node.element.getBoundingClientRect();
3787
4092
  s.node.recordMeasuredHeight(i.height);
3788
- const r = ke.measure([{
4093
+ const r = xe.measure([{
3789
4094
  absoluteStart: s.absoluteStart,
3790
4095
  viewNode: s.node
3791
4096
  }]);
@@ -3801,7 +4106,7 @@ class $i extends le {
3801
4106
  this.measuredLayout.measurements.set(t, void 0);
3802
4107
  }
3803
4108
  }
3804
- class di {
4109
+ class Ri {
3805
4110
  connect(e) {
3806
4111
  const t = (o) => {
3807
4112
  const c = e.getSelectedText();
@@ -3821,7 +4126,7 @@ class di {
3821
4126
  };
3822
4127
  }
3823
4128
  }
3824
- class Fi {
4129
+ class ir {
3825
4130
  constructor(e = navigator.clipboard) {
3826
4131
  this._clipboard = e;
3827
4132
  }
@@ -3854,7 +4159,7 @@ class Fi {
3854
4159
  return s.addEventListener("keydown", t), { dispose: () => s.removeEventListener("keydown", t) };
3855
4160
  }
3856
4161
  }
3857
- class Vi extends le {
4162
+ class rr extends se {
3858
4163
  constructor(e, t, s) {
3859
4164
  super(), this._model = e, this._view = t;
3860
4165
  const i = this._view.element;
@@ -3863,29 +4168,41 @@ class Vi extends le {
3863
4168
  i.removeEventListener("mousedown", this._handleMouseDown), i.removeEventListener("keydown", this._handleKeyDown);
3864
4169
  }
3865
4170
  });
3866
- const r = s?.clipboardStrategy ?? new di();
3867
- this._register(r.connect({
4171
+ const r = i.ownerDocument.defaultView ?? window;
4172
+ r.addEventListener("keydown", this._updateModifierState), r.addEventListener("keyup", this._updateModifierState), r.addEventListener("blur", this._clearModifierState), this._register({
4173
+ dispose: () => {
4174
+ r.removeEventListener("keydown", this._updateModifierState), r.removeEventListener("keyup", this._updateModifierState), r.removeEventListener("blur", this._clearModifierState);
4175
+ }
4176
+ });
4177
+ const o = s?.clipboardStrategy ?? new Ri();
4178
+ this._register(o.connect({
3868
4179
  element: i,
3869
4180
  getSelectedText: () => this._selectedText(),
3870
- deleteSelection: () => this._executeEditCommand(rt),
3871
- insertText: (c) => this._executeEditCommand(rs(c))
4181
+ deleteSelection: () => this._executeEditCommand(lt),
4182
+ insertText: (a) => {
4183
+ this._model.pendingParagraph.get() !== void 0 ? this._model.materializePendingParagraph(a) : this._executeEditCommand(us(a));
4184
+ }
3872
4185
  }));
3873
- const o = this._view.editContext;
3874
- o.addEventListener("textupdate", this._handleTextUpdate), this._register({
3875
- dispose: () => o.removeEventListener("textupdate", this._handleTextUpdate)
4186
+ const c = this._view.editContext;
4187
+ c.addEventListener("textupdate", this._handleTextUpdate), this._register({
4188
+ dispose: () => c.removeEventListener("textupdate", this._handleTextUpdate)
3876
4189
  });
3877
4190
  }
3878
4191
  _desiredColumn;
3879
4192
  _handleTextUpdate = (e) => {
3880
- const t = E.replace(
3881
- new w(e.updateRangeStart, e.updateRangeEnd),
4193
+ if (this._model.pendingParagraph.get() !== void 0) {
4194
+ e.text.length > 0 ? this._model.materializePendingParagraph(e.text) : this._model.cancelPendingParagraph();
4195
+ return;
4196
+ }
4197
+ const t = b.replace(
4198
+ new _(e.updateRangeStart, e.updateRangeEnd),
3882
4199
  e.text
3883
4200
  );
3884
4201
  this._model.applyEdit(t);
3885
4202
  };
3886
4203
  _handleMouseDown = (e) => {
3887
- e.preventDefault(), this._view.focus(), this._desiredColumn = void 0;
3888
- const t = new re(e.clientX, e.clientY);
4204
+ e.preventDefault(), this._model.cancelPendingParagraph(), this._view.focus(), this._desiredColumn = void 0;
4205
+ const t = new ae(e.clientX, e.clientY);
3889
4206
  if (!this._view.isPointInContent(t)) {
3890
4207
  this._model.selection.set(void 0, void 0);
3891
4208
  return;
@@ -3893,22 +4210,22 @@ class Vi extends le {
3893
4210
  const s = this._view.resolveOffsetFromPoint(t) ?? this._model.sourceText.get().value.length;
3894
4211
  if (e.detail === 2) {
3895
4212
  const o = this._makeCursorContext();
3896
- this._model.selection.set(hs(o, s), void 0);
4213
+ this._model.selection.set(Cs(o, s), void 0);
3897
4214
  return;
3898
4215
  }
3899
4216
  if (e.detail === 3) {
3900
- const o = ui(this._model.document.get(), s);
3901
- o && this._model.selection.set(ds(this._makeCursorContext(), o), void 0);
4217
+ const o = Ii(this._model.document.get(), s);
4218
+ o && this._model.selection.set(Os(this._makeCursorContext(), o), void 0);
3902
4219
  return;
3903
4220
  }
3904
4221
  if (e.shiftKey) {
3905
- const o = this._model.selection.get() ?? x.collapsed(s);
4222
+ const o = this._model.selection.get() ?? k.collapsed(s);
3906
4223
  this._model.selection.set(o.withActive(s), void 0);
3907
4224
  } else
3908
- this._model.selection.set(x.collapsed(s), void 0);
4225
+ this._model.selection.set(k.collapsed(s), void 0);
3909
4226
  const i = (o) => {
3910
- const c = this._model.selection.get() ?? x.collapsed(s), l = this._view.resolveOffsetFromPoint(new re(o.clientX, o.clientY)) ?? c.active;
3911
- this._model.selection.set(new x(c.anchor, l), void 0);
4227
+ const c = this._model.selection.get() ?? k.collapsed(s), a = this._view.resolveOffsetFromPoint(new ae(o.clientX, o.clientY)) ?? c.active;
4228
+ this._model.selection.set(new k(c.anchor, a), void 0);
3912
4229
  }, r = () => {
3913
4230
  document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", r);
3914
4231
  };
@@ -3917,7 +4234,7 @@ class Vi extends le {
3917
4234
  _makeCursorContext() {
3918
4235
  return {
3919
4236
  text: this._model.sourceText.get().value,
3920
- selection: this._model.selection.get() ?? x.collapsed(0),
4237
+ selection: this._model.selection.get() ?? k.collapsed(0),
3921
4238
  document: this._model.document.get(),
3922
4239
  activeBlock: this._model.activeBlock.get()
3923
4240
  };
@@ -3932,7 +4249,7 @@ class Vi extends le {
3932
4249
  _executeCursorCommand(e, t) {
3933
4250
  const s = this._makeCursorContext(), i = e(s), r = s.selection;
3934
4251
  this._model.selection.set(
3935
- t ? r.withActive(i) : x.collapsed(i),
4252
+ t ? r.withActive(i) : k.collapsed(i),
3936
4253
  void 0
3937
4254
  ), this._desiredColumn = void 0;
3938
4255
  }
@@ -3943,57 +4260,82 @@ class Vi extends le {
3943
4260
  _executeVisualCursorCommand(e, t) {
3944
4261
  const s = this._makeVisualCursorContext(), i = e(s);
3945
4262
  this._model.selection.set(
3946
- t ? s.selection.withActive(i.offset) : x.collapsed(i.offset),
4263
+ t ? s.selection.withActive(i.offset) : k.collapsed(i.offset),
3947
4264
  void 0
3948
4265
  ), this._desiredColumn = i.desiredColumn;
3949
4266
  }
3950
4267
  /** Move the cursor down one visual line (Arrow Down). */
3951
4268
  cursorDown(e = !1) {
3952
- this._executeVisualCursorCommand(st, e);
4269
+ this._executeVisualCursorCommand(ct, e);
3953
4270
  }
3954
4271
  /** Move the cursor up one visual line (Arrow Up). */
3955
4272
  cursorUp(e = !1) {
3956
- this._executeVisualCursorCommand(it, e);
4273
+ this._executeVisualCursorCommand(at, e);
3957
4274
  }
3958
4275
  _selectedText() {
3959
4276
  const e = this._model.selection.get();
3960
4277
  if (!(!e || e.isCollapsed))
3961
4278
  return this._model.sourceText.get().value.slice(e.range.start, e.range.endExclusive);
3962
4279
  }
4280
+ _updateModifierState = (e) => {
4281
+ this._model.ctrlOrMetaDown.set(e.ctrlKey || e.metaKey, void 0);
4282
+ };
4283
+ _clearModifierState = () => {
4284
+ this._model.ctrlOrMetaDown.set(!1, void 0);
4285
+ };
3963
4286
  _handleKeyDown = (e) => {
3964
4287
  const t = e.ctrlKey || e.metaKey;
4288
+ if (this._model.pendingParagraph.get() !== void 0) {
4289
+ if (e.key === "Backspace" || e.key === "Escape") {
4290
+ e.preventDefault(), this._model.cancelPendingParagraph();
4291
+ return;
4292
+ }
4293
+ (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "Home" || e.key === "End" || e.key === "Delete") && this._model.cancelPendingParagraph();
4294
+ }
3965
4295
  if (e.key === "ArrowLeft")
3966
- e.preventDefault(), t ? this._executeCursorCommand((e.shiftKey, nt), e.shiftKey) : e.shiftKey ? this._executeCursorCommand(Un, !0) : this._executeCursorCommand(Xn, !1);
4296
+ e.preventDefault(), t ? this._executeCursorCommand((e.shiftKey, ot), e.shiftKey) : e.shiftKey ? this._executeCursorCommand(ss, !0) : this._executeCursorCommand(ts, !1);
3967
4297
  else if (e.key === "ArrowRight")
3968
- e.preventDefault(), t ? this._executeCursorCommand(Yn, e.shiftKey) : e.shiftKey ? this._executeCursorCommand(Qn, !0) : this._executeCursorCommand(zn, !1);
4298
+ e.preventDefault(), t ? this._executeCursorCommand(is, e.shiftKey) : e.shiftKey ? this._executeCursorCommand(ns, !0) : this._executeCursorCommand(es, !1);
3969
4299
  else if (e.key === "ArrowUp")
3970
- e.preventDefault(), this._executeVisualCursorCommand(it, e.shiftKey);
4300
+ e.preventDefault(), this._executeVisualCursorCommand(at, e.shiftKey);
3971
4301
  else if (e.key === "ArrowDown")
3972
- e.preventDefault(), this._executeVisualCursorCommand(st, e.shiftKey);
4302
+ e.preventDefault(), this._executeVisualCursorCommand(ct, e.shiftKey);
3973
4303
  else if (e.key === "Home")
3974
- e.preventDefault(), t ? this._executeCursorCommand(es, e.shiftKey) : this._executeCursorCommand(Jn, e.shiftKey);
4304
+ e.preventDefault(), t ? this._executeCursorCommand(cs, e.shiftKey) : this._executeCursorCommand(rs, e.shiftKey);
3975
4305
  else if (e.key === "End")
3976
- e.preventDefault(), t ? this._executeCursorCommand(ts, e.shiftKey) : this._executeCursorCommand(Zn, e.shiftKey);
4306
+ e.preventDefault(), t ? this._executeCursorCommand(as, e.shiftKey) : this._executeCursorCommand(os, e.shiftKey);
3977
4307
  else if (e.key === "a" && t) {
3978
4308
  e.preventDefault();
3979
4309
  const s = this._makeCursorContext();
3980
- this._model.selection.set(as(s), void 0);
3981
- } else e.key === "Backspace" ? (e.preventDefault(), this._executeEditCommand(t ? ss : rt)) : e.key === "Delete" ? (e.preventDefault(), this._executeEditCommand(t ? is : ns)) : e.key === "Enter" && (e.preventDefault(), this._executeEditCommand(t ? os : e.shiftKey ? ls : cs));
4310
+ this._model.selection.set(Es(s), void 0);
4311
+ } else e.key === "Backspace" ? (e.preventDefault(), this._executeEditCommand(t ? hs : lt)) : e.key === "Delete" ? (e.preventDefault(), this._executeEditCommand(t ? ds : ls)) : e.key === "Enter" && (e.preventDefault(), t ? this._executeEditCommand(fs) : e.shiftKey ? this._executeEditCommand(ps) : this._smartEnter());
3982
4312
  };
4313
+ /**
4314
+ * Context-aware Enter: splits / line-breaks via {@link insertSmartEnter}, or
4315
+ * arms a transient empty paragraph when at the end of a paragraph.
4316
+ */
4317
+ _smartEnter() {
4318
+ const e = this._makeCursorContext(), t = ms(e);
4319
+ t.kind === "edit" ? (this._model.applyEdit(t.edit), this._model.selection.set(t.selection, void 0)) : this._model.armPendingParagraph({
4320
+ anchorBlock: t.anchorBlock,
4321
+ replaceRange: t.replaceRange,
4322
+ atEof: t.atEof
4323
+ }), this._desiredColumn = void 0;
4324
+ }
3983
4325
  }
3984
- function ui(n, e) {
4326
+ function Ii(n, e) {
3985
4327
  let t = 0;
3986
4328
  for (const s of n.children) {
3987
4329
  if (n.blocks.includes(s)) {
3988
- const i = w.ofStartAndLength(t, s.length);
4330
+ const i = _.ofStartAndLength(t, s.length);
3989
4331
  if (i.contains(e) || i.endExclusive === e)
3990
4332
  return i;
3991
4333
  }
3992
4334
  t += s.length;
3993
4335
  }
3994
4336
  }
3995
- const Ct = "md-debug-show-line-rects";
3996
- function fi(n, e) {
4337
+ const Lt = "md-debug-show-line-rects";
4338
+ function Ni(n, e) {
3997
4339
  try {
3998
4340
  const t = localStorage.getItem(n);
3999
4341
  return t === null ? e : t === "true";
@@ -4001,13 +4343,13 @@ function fi(n, e) {
4001
4343
  return e;
4002
4344
  }
4003
4345
  }
4004
- function gi(n, e) {
4346
+ function Bi(n, e) {
4005
4347
  try {
4006
4348
  localStorage.setItem(n, String(e));
4007
4349
  } catch {
4008
4350
  }
4009
4351
  }
4010
- class Pi extends le {
4352
+ class or extends se {
4011
4353
  constructor(e, t) {
4012
4354
  super(), this._overlayParent = e, this.overlayElement = document.createElement("div"), this.overlayElement.className = "md-debug-layout-overlay", Object.assign(this.overlayElement.style, {
4013
4355
  position: "absolute",
@@ -4036,16 +4378,16 @@ class Pi extends le {
4036
4378
  });
4037
4379
  const i = document.createElement("input");
4038
4380
  i.type = "checkbox", i.checked = this._showLineRects.get(), i.addEventListener("change", () => {
4039
- this._showLineRects.set(i.checked, void 0), gi(Ct, i.checked);
4381
+ this._showLineRects.set(i.checked, void 0), Bi(Lt, i.checked);
4040
4382
  }), s.appendChild(i), s.appendChild(document.createTextNode("show line rects")), this.infoElement.appendChild(s);
4041
4383
  const r = document.createElement("pre");
4042
- r.style.margin = "0", r.style.whiteSpace = "pre", this.infoElement.appendChild(r), this.rendering = V(this, (o) => {
4043
- const c = o.readObservable(t.model.measurements), l = o.readObservable(this._showLineRects);
4044
- return mi(this.overlayElement, r, this._overlayParent, c, l, t.colorForOffset, t.hoveredOffset);
4045
- }), this.mappedOffsets = V(this, (o) => o.readObservable(this.rendering).mappedOffsets), this._register(ee((o) => {
4384
+ r.style.margin = "0", r.style.whiteSpace = "pre", this.infoElement.appendChild(r), this.rendering = $(this, (o) => {
4385
+ const c = o.readObservable(t.model.measurements), a = o.readObservable(this._showLineRects);
4386
+ return $i(this.overlayElement, r, this._overlayParent, c, a, t.colorForOffset, t.hoveredOffset);
4387
+ }), this.mappedOffsets = $(this, (o) => o.readObservable(this.rendering).mappedOffsets), this._register(G((o) => {
4046
4388
  o.readObservable(this.rendering);
4047
4389
  const c = t.hoveredOffset ? o.readObservable(t.hoveredOffset) : void 0;
4048
- t.hoveredOffset && _i(this.overlayElement, c);
4390
+ t.hoveredOffset && Pi(this.overlayElement, c);
4049
4391
  }));
4050
4392
  }
4051
4393
  overlayElement;
@@ -4054,88 +4396,88 @@ class Pi extends le {
4054
4396
  /** Absolute source offsets that map to a rendered DOM character. */
4055
4397
  mappedOffsets;
4056
4398
  /** Whether the dashed line-bands and run boxes are drawn (persisted). */
4057
- _showLineRects = U(this, fi(Ct, !0));
4399
+ _showLineRects = B(this, Ni(Lt, !0));
4058
4400
  }
4059
- class pi {
4401
+ class Di {
4060
4402
  constructor(e, t, s, i) {
4061
4403
  this.blockCount = e, this.mountedCount = t, this.lineCount = s, this.mappedOffsets = i;
4062
4404
  }
4063
4405
  }
4064
- function mi(n, e, t, s, i, r, o) {
4406
+ function $i(n, e, t, s, i, r, o) {
4065
4407
  n.textContent = "";
4066
4408
  const c = t.getBoundingClientRect();
4067
- let l = 0, a = 0, h = 0;
4068
- const g = /* @__PURE__ */ new Set();
4069
- for (let f = 0; f < s.length; f++) {
4070
- const p = s[f], m = p.visualLineMap?.lines ?? [];
4071
- if (p.isMeasured && l++, a += m.length, i)
4072
- for (let _ = 0; _ < m.length; _++) {
4073
- const v = m[_], y = v.rect, M = document.createElement("div");
4409
+ let a = 0, l = 0, h = 0;
4410
+ const u = /* @__PURE__ */ new Set();
4411
+ for (let g = 0; g < s.length; g++) {
4412
+ const p = s[g], m = p.visualLineMap?.lines ?? [];
4413
+ if (p.isMeasured && a++, l += m.length, i)
4414
+ for (let w = 0; w < m.length; w++) {
4415
+ const x = m[w], E = x.rect, M = document.createElement("div");
4074
4416
  Object.assign(M.style, {
4075
4417
  position: "absolute",
4076
4418
  left: "0",
4077
4419
  right: "0",
4078
- top: `${y.y - c.top}px`,
4079
- height: `${y.height}px`,
4420
+ top: `${E.y - c.top}px`,
4421
+ height: `${E.height}px`,
4080
4422
  border: "1px dashed rgba(180, 0, 200, 0.45)",
4081
4423
  boxSizing: "border-box"
4082
4424
  }), n.appendChild(M);
4083
- for (const A of v.runs) {
4084
- const de = document.createElement("div");
4085
- Object.assign(de.style, {
4425
+ for (const P of x.runs) {
4426
+ const ue = document.createElement("div");
4427
+ Object.assign(ue.style, {
4086
4428
  position: "absolute",
4087
- left: `${A.rect.x - c.left}px`,
4088
- top: `${A.rect.y - c.top}px`,
4089
- width: `${A.rect.width}px`,
4090
- height: `${A.rect.height}px`,
4429
+ left: `${P.rect.x - c.left}px`,
4430
+ top: `${P.rect.y - c.top}px`,
4431
+ width: `${P.rect.width}px`,
4432
+ height: `${P.rect.height}px`,
4091
4433
  outline: "1px solid rgba(255, 100, 0, 0.45)",
4092
4434
  boxSizing: "border-box"
4093
- }), n.appendChild(de);
4435
+ }), n.appendChild(ue);
4094
4436
  }
4095
4437
  }
4096
- p.viewNode && (h += wi(n, c, p.viewNode, p.absoluteStart, g, r, o));
4438
+ p.viewNode && (h += Ai(n, c, p.viewNode, p.absoluteStart, u, r, o));
4097
4439
  }
4098
- const d = `blocks: ${s.length} mounted: ${l} lines: ${a} chars: ${h}`, u = s.map((f, p) => {
4099
- const m = f.isMeasured ? "M" : "e", _ = f.visualLineMap?.lines.length ?? 0;
4100
- return `${String(p).padStart(2)} ${m} start=${String(f.absoluteStart).padStart(4)} h=${f.height.toFixed(1).padStart(6)} lines=${_} kind=${f.block.kind}`;
4440
+ const f = `blocks: ${s.length} mounted: ${a} lines: ${l} chars: ${h}`, d = s.map((g, p) => {
4441
+ const m = g.isMeasured ? "M" : "e", w = g.visualLineMap?.lines.length ?? 0;
4442
+ return `${String(p).padStart(2)} ${m} start=${String(g.absoluteStart).padStart(4)} h=${g.height.toFixed(1).padStart(6)} lines=${w} kind=${g.block.kind}`;
4101
4443
  });
4102
- return e.textContent = [d, ...u].join(`
4103
- `), new pi(s.length, l, a, g);
4444
+ return e.textContent = [f, ...d].join(`
4445
+ `), new Di(s.length, a, l, u);
4104
4446
  }
4105
- function wi(n, e, t, s, i, r, o) {
4447
+ function Ai(n, e, t, s, i, r, o) {
4106
4448
  let c = 0;
4107
- const l = document.createRange(), a = s + t.sourceLength, h = [];
4108
- t.forEachTextLeaf(s, (d, u) => {
4109
- h.push({ start: u, end: u + d.sourceLength });
4449
+ const a = document.createRange(), l = s + t.sourceLength, h = [];
4450
+ t.forEachTextLeaf(s, (f, d) => {
4451
+ h.push({ start: d, end: d + f.sourceLength });
4110
4452
  });
4111
- const g = (d) => h.some((u) => d >= u.start && d < u.end);
4112
- for (let d = s; d < a; d++) {
4113
- if (!g(d))
4453
+ const u = (f) => h.some((d) => f >= d.start && f < d.end);
4454
+ for (let f = s; f < l; f++) {
4455
+ if (!u(f))
4114
4456
  continue;
4115
- const u = t.sourceToDom(d + 1, s);
4116
- if (!u || u.offset < 1)
4457
+ const d = t.sourceToDom(f + 1, s);
4458
+ if (!d || d.offset < 1)
4117
4459
  continue;
4118
- l.setStart(u.node, u.offset - 1), l.setEnd(u.node, u.offset);
4119
- const f = l.getBoundingClientRect();
4120
- if (f.height === 0)
4460
+ a.setStart(d.node, d.offset - 1), a.setEnd(d.node, d.offset);
4461
+ const g = a.getBoundingClientRect();
4462
+ if (g.height === 0)
4121
4463
  continue;
4122
- const p = f.width === 0 ? 2 : f.width, m = document.createElement("div");
4464
+ const p = g.width === 0 ? 2 : g.width, m = document.createElement("div");
4123
4465
  Object.assign(m.style, {
4124
4466
  position: "absolute",
4125
- left: `${f.x - e.left}px`,
4126
- top: `${f.y - e.top}px`,
4467
+ left: `${g.x - e.left}px`,
4468
+ top: `${g.y - e.top}px`,
4127
4469
  width: `${p}px`,
4128
- height: `${f.height}px`,
4129
- background: r?.(d) ?? "rgba(0, 120, 220, 0.30)",
4470
+ height: `${g.height}px`,
4471
+ background: r?.(f) ?? "rgba(0, 120, 220, 0.30)",
4130
4472
  boxSizing: "border-box",
4131
4473
  pointerEvents: "auto"
4132
4474
  });
4133
- const _ = u.node.data?.[u.offset - 1] ?? "";
4134
- m.title = `offset ${d}: ${JSON.stringify(_)}`, m.dataset.offset = String(d), o ? (m.addEventListener("mouseenter", () => o.set(d, void 0)), m.addEventListener("mouseleave", () => o.set(void 0, void 0))) : (m.addEventListener("mouseenter", () => Ot(n, m, !0)), m.addEventListener("mouseleave", () => Ot(n, m, !1))), n.appendChild(m), i.add(d), c++;
4475
+ const w = d.node.data?.[d.offset - 1] ?? "";
4476
+ m.title = `offset ${f}: ${JSON.stringify(w)}`, m.dataset.offset = String(f), o ? (m.addEventListener("mouseenter", () => o.set(f, void 0)), m.addEventListener("mouseleave", () => o.set(void 0, void 0))) : (m.addEventListener("mouseenter", () => Rt(n, m, !0)), m.addEventListener("mouseleave", () => Rt(n, m, !1))), n.appendChild(m), i.add(f), c++;
4135
4477
  }
4136
4478
  return c;
4137
4479
  }
4138
- function _i(n, e) {
4480
+ function Pi(n, e) {
4139
4481
  for (const t of Array.from(n.children)) {
4140
4482
  if (!t.style)
4141
4483
  continue;
@@ -4143,16 +4485,16 @@ function _i(n, e) {
4143
4485
  t.style.visibility = e === void 0 || i ? "" : "hidden";
4144
4486
  }
4145
4487
  }
4146
- function Ot(n, e, t) {
4488
+ function Rt(n, e, t) {
4147
4489
  for (const s of Array.from(n.children))
4148
4490
  s.style.visibility = t && s !== e ? "hidden" : "";
4149
4491
  }
4150
- class me {
4492
+ class we {
4151
4493
  constructor(e, t) {
4152
4494
  this.length = e, this.className = t;
4153
4495
  }
4154
4496
  }
4155
- class ki {
4497
+ class Fi {
4156
4498
  /**
4157
4499
  * @param _monaco The Monarch runtime ({@link IMonarchApi}), injected so this
4158
4500
  * package depends on `monaco-editor` for types only.
@@ -4163,7 +4505,7 @@ class ki {
4163
4505
  }
4164
4506
  _tokenizers = /* @__PURE__ */ new Map();
4165
4507
  create(e, t) {
4166
- return new xi(this._tokenizerFor(e), t);
4508
+ return new Vi(this._tokenizerFor(e), t);
4167
4509
  }
4168
4510
  dispose() {
4169
4511
  for (const e of this._tokenizers.values())
@@ -4175,13 +4517,13 @@ class ki {
4175
4517
  if (t === void 0)
4176
4518
  return;
4177
4519
  let s = this._tokenizers.get(e);
4178
- return s || (s = new this._monaco.MonarchTokenizer(Ei, Ci, e, this._monaco.compile(e, t), Oi), this._tokenizers.set(e, s)), s;
4520
+ return s || (s = new this._monaco.MonarchTokenizer(qi, zi, e, this._monaco.compile(e, t), Gi), this._tokenizers.set(e, s)), s;
4179
4521
  }
4180
4522
  }
4181
- class xi {
4523
+ class Vi {
4182
4524
  constructor(e, t) {
4183
4525
  this._tokenizer = e, this._initialState = e?.getInitialState(), this._text = t, this._lines = this._tokenizeFrom(0, [], this._initialState, t.split(`
4184
- `)), this._lineStarts = this._computeLineStarts(), this._snapshotObs = U("syntaxSnapshot", new Tt(this, this._version));
4526
+ `)), this._lineStarts = this._computeLineStarts(), this._snapshotObs = B("syntaxSnapshot", new It(this, this._version));
4185
4527
  }
4186
4528
  _text;
4187
4529
  _lines;
@@ -4199,11 +4541,11 @@ class xi {
4199
4541
  throw new Error("document is disposed");
4200
4542
  if (e.isEmpty)
4201
4543
  return;
4202
- const s = Mt(this._lines), i = e.apply(this._text), r = e.replacements[0].replaceRange.start, o = this._lineIndexAt(r), c = this._lines.slice(0, o), l = o === 0 ? this._initialState : this._lines[o - 1].endState;
4203
- this._text = i, this._lines = this._tokenizeFrom(o, c, l, i.split(`
4544
+ const s = Nt(this._lines), i = e.apply(this._text), r = e.replacements[0].replaceRange.start, o = this._lineIndexAt(r), c = this._lines.slice(0, o), a = o === 0 ? this._initialState : this._lines[o - 1].endState;
4545
+ this._text = i, this._lines = this._tokenizeFrom(o, c, a, i.split(`
4204
4546
  `)), this._lineStarts = this._computeLineStarts(), this._version++;
4205
- const a = yi(s, Mt(this._lines));
4206
- this._snapshotObs.set(new Tt(this, this._version), t, a);
4547
+ const l = Wi(s, Nt(this._lines));
4548
+ this._snapshotObs.set(new It(this, this._version), t, l);
4207
4549
  }
4208
4550
  dispose() {
4209
4551
  this._disposed = !0;
@@ -4217,12 +4559,12 @@ class xi {
4217
4559
  const r = t.slice();
4218
4560
  let o = s;
4219
4561
  for (let c = e; c < i.length; c++) {
4220
- const l = i[c], a = c < i.length - 1;
4562
+ const a = i[c], l = c < i.length - 1;
4221
4563
  if (this._tokenizer && o) {
4222
- const h = this._tokenizer.tokenize(l, a, o);
4223
- r.push({ text: l, tokens: bi(h.tokens, l.length), endState: h.endState }), o = h.endState;
4564
+ const h = this._tokenizer.tokenize(a, l, o);
4565
+ r.push({ text: a, tokens: Hi(h.tokens, a.length), endState: h.endState }), o = h.endState;
4224
4566
  } else
4225
- r.push({ text: l, tokens: l.length === 0 ? [] : [new me(l.length, void 0)], endState: o });
4567
+ r.push({ text: a, tokens: a.length === 0 ? [] : [new we(a.length, void 0)], endState: o });
4226
4568
  }
4227
4569
  return r;
4228
4570
  }
@@ -4244,20 +4586,20 @@ class xi {
4244
4586
  if (e !== this._version)
4245
4587
  throw new Error("stale snapshot");
4246
4588
  const s = this._text.length, i = Math.max(0, Math.min(t.start, s)), r = Math.max(i, Math.min(t.endExclusive, s)), o = [];
4247
- let c = i, l = i, a = !1, h = 0;
4248
- const g = (d, u) => {
4249
- const f = h, p = h + d;
4250
- h = p, d !== 0 && f < r && p > i && (a || (c = f, a = !0), o.push(new me(d, u)), l = p);
4589
+ let c = i, a = i, l = !1, h = 0;
4590
+ const u = (f, d) => {
4591
+ const g = h, p = h + f;
4592
+ h = p, f !== 0 && g < r && p > i && (l || (c = g, l = !0), o.push(new we(f, d)), a = p);
4251
4593
  };
4252
- for (let d = 0; d < this._lines.length && h < r; d++) {
4253
- for (const u of this._lines[d].tokens)
4254
- g(u.length, u.className);
4255
- d < this._lines.length - 1 && g(1, void 0);
4594
+ for (let f = 0; f < this._lines.length && h < r; f++) {
4595
+ for (const d of this._lines[f].tokens)
4596
+ u(d.length, d.className);
4597
+ f < this._lines.length - 1 && u(1, void 0);
4256
4598
  }
4257
- return { range: new w(c, a ? l : i), tokens: o };
4599
+ return { range: new _(c, l ? a : i), tokens: o };
4258
4600
  }
4259
4601
  }
4260
- class Tt {
4602
+ class It {
4261
4603
  constructor(e, t) {
4262
4604
  this._doc = e, this._version = t;
4263
4605
  }
@@ -4265,63 +4607,63 @@ class Tt {
4265
4607
  return this._doc._getTokens(this._version, e);
4266
4608
  }
4267
4609
  }
4268
- function vi(n) {
4610
+ function Ki(n) {
4269
4611
  return n === "" ? void 0 : n;
4270
4612
  }
4271
- function bi(n, e) {
4613
+ function Hi(n, e) {
4272
4614
  if (n.length === 0)
4273
- return e === 0 ? [] : [new me(e, void 0)];
4615
+ return e === 0 ? [] : [new we(e, void 0)];
4274
4616
  const t = [];
4275
4617
  for (let s = 0; s < n.length; s++) {
4276
4618
  const i = n[s].offset, r = s + 1 < n.length ? n[s + 1].offset : e;
4277
- r > i && t.push(new me(r - i, vi(n[s].type)));
4619
+ r > i && t.push(new we(r - i, Ki(n[s].type)));
4278
4620
  }
4279
4621
  return t;
4280
4622
  }
4281
- function Mt(n) {
4623
+ function Nt(n) {
4282
4624
  const e = [];
4283
4625
  for (let t = 0; t < n.length; t++) {
4284
4626
  for (const s of n[t].tokens)
4285
4627
  e.push(s);
4286
- t < n.length - 1 && e.push(new me(1, void 0));
4628
+ t < n.length - 1 && e.push(new we(1, void 0));
4287
4629
  }
4288
4630
  return e;
4289
4631
  }
4290
- function St(n, e) {
4632
+ function Bt(n, e) {
4291
4633
  return n.length === e.length && n.className === e.className;
4292
4634
  }
4293
- function Lt(n) {
4635
+ function Dt(n) {
4294
4636
  let e = 0;
4295
4637
  for (const t of n)
4296
4638
  e += t.length;
4297
4639
  return e;
4298
4640
  }
4299
- function yi(n, e) {
4641
+ function Wi(n, e) {
4300
4642
  const t = n.length, s = e.length;
4301
4643
  let i = 0, r = 0;
4302
- for (; i < t && i < s && St(n[i], e[i]); )
4644
+ for (; i < t && i < s && Bt(n[i], e[i]); )
4303
4645
  r += n[i].length, i++;
4304
4646
  let o = 0, c = 0;
4305
- for (; o < t - i && o < s - i && St(n[t - 1 - o], e[s - 1 - o]); )
4647
+ for (; o < t - i && o < s - i && Bt(n[t - 1 - o], e[s - 1 - o]); )
4306
4648
  c += n[t - 1 - o].length, o++;
4307
- const l = Lt(n), a = Lt(e), h = new w(r, l - c), g = a - c - r;
4308
- return h.isEmpty && g === 0 ? ie.empty : ie.replace(h, g);
4649
+ const a = Dt(n), l = Dt(e), h = new _(r, a - c), u = l - c - r;
4650
+ return h.isEmpty && u === 0 ? oe.empty : oe.replace(h, u);
4309
4651
  }
4310
- const Ei = {
4652
+ const qi = {
4311
4653
  languageIdCodec: { encodeLanguageId: () => 0, decodeLanguageId: () => "" },
4312
4654
  isRegisteredLanguageId: () => !1,
4313
4655
  getLanguageIdByLanguageName: () => null,
4314
4656
  getLanguageIdByMimeType: () => null,
4315
4657
  requestBasicLanguageFeatures: () => {
4316
4658
  }
4317
- }, Ci = {
4659
+ }, zi = {
4318
4660
  getColorTheme: () => ({ tokenTheme: {} })
4319
- }, Oi = {
4661
+ }, Gi = {
4320
4662
  getValue: () => 2e4,
4321
4663
  onDidChangeConfiguration: () => ({ dispose() {
4322
4664
  } })
4323
4665
  };
4324
- function Ki(n, e) {
4666
+ function cr(n, e) {
4325
4667
  const t = /* @__PURE__ */ new Map([
4326
4668
  ["typescript", e.typescript],
4327
4669
  ["ts", e.typescript],
@@ -4337,94 +4679,95 @@ function Ki(n, e) {
4337
4679
  ["sh", e.shell],
4338
4680
  ["bash", e.shell]
4339
4681
  ]);
4340
- return new ki(n, t);
4682
+ return new Fi(n, t);
4341
4683
  }
4342
4684
  export {
4343
4685
  N as AstNode,
4344
- Fi as AsyncClipboardStrategy,
4345
- oe as BlockQuoteAstNode,
4686
+ ir as AsyncClipboardStrategy,
4687
+ le as BlockQuoteAstNode,
4346
4688
  T as BlockViewNode,
4347
- D as CodeBlockAstNode,
4348
- Ge as CodeBlockViewNode,
4349
- si as CursorView,
4350
- yt as CursorViewRendering,
4351
- He as DocumentAstNode,
4352
- Xe as DocumentViewNode,
4353
- Vi as EditorController,
4354
- Ai as EditorModel,
4355
- $i as EditorView,
4356
- Fe as EmphasisAstNode,
4357
- R as GlueAstNode,
4358
- J as HeadingAstNode,
4359
- _e as ImageAstNode,
4360
- Pe as InlineCodeAstNode,
4361
- Ke as InlineMathAstNode,
4362
- ie as LengthEdit,
4363
- Ae as LengthReplacement,
4364
- we as LinkAstNode,
4365
- K as ListAstNode,
4366
- H as ListItemAstNode,
4367
- Mn as MarkdownParser,
4368
- k as MarkerAstNode,
4689
+ A as CodeBlockAstNode,
4690
+ Ue as CodeBlockViewNode,
4691
+ ki as CursorView,
4692
+ Be as CursorViewRendering,
4693
+ qe as DocumentAstNode,
4694
+ Je as DocumentViewNode,
4695
+ rr as EditorController,
4696
+ nr as EditorModel,
4697
+ sr as EditorView,
4698
+ Ve as EmphasisAstNode,
4699
+ I as GlueAstNode,
4700
+ Z as HeadingAstNode,
4701
+ ve as ImageAstNode,
4702
+ He as InlineCodeAstNode,
4703
+ We as InlineMathAstNode,
4704
+ oe as LengthEdit,
4705
+ Pe as LengthReplacement,
4706
+ ke as LinkAstNode,
4707
+ W as ListAstNode,
4708
+ q as ListItemAstNode,
4709
+ Dn as MarkdownParser,
4710
+ v as MarkerAstNode,
4369
4711
  ne as MathBlockAstNode,
4370
- pi as MeasuredLayoutDebugRendering,
4371
- Pi as MeasuredLayoutDebugView,
4372
- Hn as MeasuredLayoutModel,
4373
- ki as MonacoSyntaxHighlighter,
4374
- di as NativeClipboardStrategy,
4375
- w as OffsetRange,
4376
- j as ParagraphAstNode,
4377
- re as Point2D,
4378
- B as Rect2D,
4379
- x as Selection,
4380
- ii as SelectionView,
4381
- Et as SelectionViewRendering,
4382
- Ve as StrikethroughAstNode,
4383
- E as StringEdit,
4384
- q as StringReplacement,
4385
- Le as StringValue,
4386
- $e as StrongAstNode,
4387
- ce as TableAstNode,
4388
- pe as TableCellAstNode,
4389
- ge as TableRowAstNode,
4390
- Ee as TextAstNode,
4712
+ Di as MeasuredLayoutDebugRendering,
4713
+ or as MeasuredLayoutDebugView,
4714
+ Qn as MeasuredLayoutModel,
4715
+ Fi as MonacoSyntaxHighlighter,
4716
+ Ri as NativeClipboardStrategy,
4717
+ _ as OffsetRange,
4718
+ H as ParagraphAstNode,
4719
+ ae as Point2D,
4720
+ D as Rect2D,
4721
+ k as Selection,
4722
+ Ei as SelectionView,
4723
+ St as SelectionViewRendering,
4724
+ Ke as StrikethroughAstNode,
4725
+ b as StringEdit,
4726
+ j as StringReplacement,
4727
+ ye as StringValue,
4728
+ Fe as StrongAstNode,
4729
+ he as TableAstNode,
4730
+ _e as TableCellAstNode,
4731
+ me as TableRowAstNode,
4732
+ pe as TextAstNode,
4391
4733
  te as ThematicBreakAstNode,
4392
- me as Token,
4393
- ae as ViewNode,
4394
- Dn as VisualLine,
4395
- ke as VisualLineMap,
4396
- Be as VisualRun,
4397
- Ki as createDefaultMonacoSyntaxHighlighter,
4398
- ts as cursorDocumentEnd,
4399
- es as cursorDocumentStart,
4400
- st as cursorDown,
4401
- Xn as cursorLeft,
4402
- Zn as cursorLineEnd,
4403
- Jn as cursorLineStart,
4404
- Un as cursorMoveLeft,
4405
- Qn as cursorMoveRight,
4406
- zn as cursorRight,
4407
- it as cursorUp,
4408
- nt as cursorWordLeft,
4409
- Yn as cursorWordRight,
4410
- rt as deleteLeft,
4411
- ns as deleteRight,
4412
- ss as deleteWordLeft,
4413
- is as deleteWordRight,
4414
- gn as findNodeOffsetById,
4415
- dn as findWordAt,
4416
- Nt as findWordBoundaryLeft,
4417
- Rt as findWordBoundaryRight,
4418
- Sn as getAnnotatedSource,
4419
- ls as insertHardLineBreak,
4420
- cs as insertLineBreak,
4421
- os as insertParagraph,
4422
- rs as insertText,
4423
- Vt as nextCursorPosition,
4424
- as as selectAll,
4425
- ds as selectBlock,
4426
- hs as selectWord,
4427
- Bi as taskCheckboxRange,
4428
- Di as visualizeAst
4734
+ we as Token,
4735
+ ie as ViewNode,
4736
+ Hn as VisualLine,
4737
+ xe as VisualLineMap,
4738
+ $e as VisualRun,
4739
+ cr as createDefaultMonacoSyntaxHighlighter,
4740
+ as as cursorDocumentEnd,
4741
+ cs as cursorDocumentStart,
4742
+ ct as cursorDown,
4743
+ ts as cursorLeft,
4744
+ os as cursorLineEnd,
4745
+ rs as cursorLineStart,
4746
+ ss as cursorMoveLeft,
4747
+ ns as cursorMoveRight,
4748
+ es as cursorRight,
4749
+ at as cursorUp,
4750
+ ot as cursorWordLeft,
4751
+ is as cursorWordRight,
4752
+ lt as deleteLeft,
4753
+ ls as deleteRight,
4754
+ hs as deleteWordLeft,
4755
+ ds as deleteWordRight,
4756
+ Ft as findNodeOffsetById,
4757
+ kn as findWordAt,
4758
+ At as findWordBoundaryLeft,
4759
+ Pt as findWordBoundaryRight,
4760
+ $n as getAnnotatedSource,
4761
+ ps as insertHardLineBreak,
4762
+ gs as insertLineBreak,
4763
+ fs as insertParagraph,
4764
+ ms as insertSmartEnter,
4765
+ us as insertText,
4766
+ zt as nextCursorPosition,
4767
+ Es as selectAll,
4768
+ Os as selectBlock,
4769
+ Cs as selectWord,
4770
+ er as taskCheckboxRange,
4771
+ tr as visualizeAst
4429
4772
  };
4430
4773
  //# sourceMappingURL=index.js.map