@arach/arc 0.4.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2725 @@
1
+ let re = [], Ee = [];
2
+ (() => {
3
+ let l = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e) => e ? parseInt(e, 36) : 1);
4
+ for (let e = 0, t = 0; e < l.length; e++)
5
+ (e % 2 ? Ee : re).push(t = t + l[e]);
6
+ })();
7
+ function Ge(l) {
8
+ if (l < 768) return !1;
9
+ for (let e = 0, t = re.length; ; ) {
10
+ let n = e + t >> 1;
11
+ if (l < re[n]) t = n;
12
+ else if (l >= Ee[n]) e = n + 1;
13
+ else return !0;
14
+ if (e == t) return !1;
15
+ }
16
+ }
17
+ function ke(l) {
18
+ return l >= 127462 && l <= 127487;
19
+ }
20
+ const ye = 8205;
21
+ function je(l, e, t = !0, n = !0) {
22
+ return (t ? Oe : Ze)(l, e, n);
23
+ }
24
+ function Oe(l, e, t) {
25
+ if (e == l.length) return e;
26
+ e && Me(l.charCodeAt(e)) && Re(l.charCodeAt(e - 1)) && e--;
27
+ let n = ie(l, e);
28
+ for (e += Se(n); e < l.length; ) {
29
+ let i = ie(l, e);
30
+ if (n == ye || i == ye || t && Ge(i))
31
+ e += Se(i), n = i;
32
+ else if (ke(i)) {
33
+ let s = 0, r = e - 2;
34
+ for (; r >= 0 && ke(ie(l, r)); )
35
+ s++, r -= 2;
36
+ if (s % 2 == 0) break;
37
+ e += 2;
38
+ } else
39
+ break;
40
+ }
41
+ return e;
42
+ }
43
+ function Ze(l, e, t) {
44
+ for (; e > 1; ) {
45
+ let n = Oe(l, e - 2, t);
46
+ if (n < e) return n;
47
+ e--;
48
+ }
49
+ return 0;
50
+ }
51
+ function ie(l, e) {
52
+ let t = l.charCodeAt(e);
53
+ if (!Re(t) || e + 1 == l.length) return t;
54
+ let n = l.charCodeAt(e + 1);
55
+ return Me(n) ? (t - 55296 << 10) + (n - 56320) + 65536 : t;
56
+ }
57
+ function Me(l) {
58
+ return l >= 56320 && l < 57344;
59
+ }
60
+ function Re(l) {
61
+ return l >= 55296 && l < 56320;
62
+ }
63
+ function Se(l) {
64
+ return l < 65536 ? 1 : 2;
65
+ }
66
+ class x {
67
+ /**
68
+ Get the line description around the given position.
69
+ */
70
+ lineAt(e) {
71
+ if (e < 0 || e > this.length)
72
+ throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);
73
+ return this.lineInner(e, !1, 1, 0);
74
+ }
75
+ /**
76
+ Get the description for the given (1-based) line number.
77
+ */
78
+ line(e) {
79
+ if (e < 1 || e > this.lines)
80
+ throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);
81
+ return this.lineInner(e, !0, 1, 0);
82
+ }
83
+ /**
84
+ Replace a range of the text with the given content.
85
+ */
86
+ replace(e, t, n) {
87
+ [e, t] = J(this, e, t);
88
+ let i = [];
89
+ return this.decompose(
90
+ 0,
91
+ e,
92
+ i,
93
+ 2
94
+ /* Open.To */
95
+ ), n.length && n.decompose(
96
+ 0,
97
+ n.length,
98
+ i,
99
+ 3
100
+ /* Open.To */
101
+ ), this.decompose(
102
+ t,
103
+ this.length,
104
+ i,
105
+ 1
106
+ /* Open.From */
107
+ ), C.from(i, this.length - (t - e) + n.length);
108
+ }
109
+ /**
110
+ Append another document to this one.
111
+ */
112
+ append(e) {
113
+ return this.replace(this.length, this.length, e);
114
+ }
115
+ /**
116
+ Retrieve the text between the given points.
117
+ */
118
+ slice(e, t = this.length) {
119
+ [e, t] = J(this, e, t);
120
+ let n = [];
121
+ return this.decompose(e, t, n, 0), C.from(n, t - e);
122
+ }
123
+ /**
124
+ Test whether this text is equal to another instance.
125
+ */
126
+ eq(e) {
127
+ if (e == this)
128
+ return !0;
129
+ if (e.length != this.length || e.lines != this.lines)
130
+ return !1;
131
+ let t = this.scanIdentical(e, 1), n = this.length - this.scanIdentical(e, -1), i = new N(this), s = new N(e);
132
+ for (let r = t, h = t; ; ) {
133
+ if (i.next(r), s.next(r), r = 0, i.lineBreak != s.lineBreak || i.done != s.done || i.value != s.value)
134
+ return !1;
135
+ if (h += i.value.length, i.done || h >= n)
136
+ return !0;
137
+ }
138
+ }
139
+ /**
140
+ Iterate over the text. When `dir` is `-1`, iteration happens
141
+ from end to start. This will return lines and the breaks between
142
+ them as separate strings.
143
+ */
144
+ iter(e = 1) {
145
+ return new N(this, e);
146
+ }
147
+ /**
148
+ Iterate over a range of the text. When `from` > `to`, the
149
+ iterator will run in reverse.
150
+ */
151
+ iterRange(e, t = this.length) {
152
+ return new Te(this, e, t);
153
+ }
154
+ /**
155
+ Return a cursor that iterates over the given range of lines,
156
+ _without_ returning the line breaks between, and yielding empty
157
+ strings for empty lines.
158
+
159
+ When `from` and `to` are given, they should be 1-based line numbers.
160
+ */
161
+ iterLines(e, t) {
162
+ let n;
163
+ if (e == null)
164
+ n = this.iter();
165
+ else {
166
+ t == null && (t = this.lines + 1);
167
+ let i = this.line(e).from;
168
+ n = this.iterRange(i, Math.max(i, t == this.lines + 1 ? this.length : t <= 1 ? 0 : this.line(t - 1).to));
169
+ }
170
+ return new Be(n);
171
+ }
172
+ /**
173
+ Return the document as a string, using newline characters to
174
+ separate lines.
175
+ */
176
+ toString() {
177
+ return this.sliceString(0);
178
+ }
179
+ /**
180
+ Convert the document to an array of lines (which can be
181
+ deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
182
+ */
183
+ toJSON() {
184
+ let e = [];
185
+ return this.flatten(e), e;
186
+ }
187
+ /**
188
+ @internal
189
+ */
190
+ constructor() {
191
+ }
192
+ /**
193
+ Create a `Text` instance for the given array of lines.
194
+ */
195
+ static of(e) {
196
+ if (e.length == 0)
197
+ throw new RangeError("A document must have at least one line");
198
+ return e.length == 1 && !e[0] ? x.empty : e.length <= 32 ? new m(e) : C.from(m.split(e, []));
199
+ }
200
+ }
201
+ class m extends x {
202
+ constructor(e, t = Ke(e)) {
203
+ super(), this.text = e, this.length = t;
204
+ }
205
+ get lines() {
206
+ return this.text.length;
207
+ }
208
+ get children() {
209
+ return null;
210
+ }
211
+ lineInner(e, t, n, i) {
212
+ for (let s = 0; ; s++) {
213
+ let r = this.text[s], h = i + r.length;
214
+ if ((t ? n : h) >= e)
215
+ return new Qe(i, h, n, r);
216
+ i = h + 1, n++;
217
+ }
218
+ }
219
+ decompose(e, t, n, i) {
220
+ let s = e <= 0 && t >= this.length ? this : new m(Ie(this.text, e, t), Math.min(t, this.length) - Math.max(0, e));
221
+ if (i & 1) {
222
+ let r = n.pop(), h = Z(s.text, r.text.slice(), 0, s.length);
223
+ if (h.length <= 32)
224
+ n.push(new m(h, r.length + s.length));
225
+ else {
226
+ let o = h.length >> 1;
227
+ n.push(new m(h.slice(0, o)), new m(h.slice(o)));
228
+ }
229
+ } else
230
+ n.push(s);
231
+ }
232
+ replace(e, t, n) {
233
+ if (!(n instanceof m))
234
+ return super.replace(e, t, n);
235
+ [e, t] = J(this, e, t);
236
+ let i = Z(this.text, Z(n.text, Ie(this.text, 0, e)), t), s = this.length + n.length - (t - e);
237
+ return i.length <= 32 ? new m(i, s) : C.from(m.split(i, []), s);
238
+ }
239
+ sliceString(e, t = this.length, n = `
240
+ `) {
241
+ [e, t] = J(this, e, t);
242
+ let i = "";
243
+ for (let s = 0, r = 0; s <= t && r < this.text.length; r++) {
244
+ let h = this.text[r], o = s + h.length;
245
+ s > e && r && (i += n), e < o && t > s && (i += h.slice(Math.max(0, e - s), t - s)), s = o + 1;
246
+ }
247
+ return i;
248
+ }
249
+ flatten(e) {
250
+ for (let t of this.text)
251
+ e.push(t);
252
+ }
253
+ scanIdentical() {
254
+ return 0;
255
+ }
256
+ static split(e, t) {
257
+ let n = [], i = -1;
258
+ for (let s of e)
259
+ n.push(s), i += s.length + 1, n.length == 32 && (t.push(new m(n, i)), n = [], i = -1);
260
+ return i > -1 && t.push(new m(n, i)), t;
261
+ }
262
+ }
263
+ class C extends x {
264
+ constructor(e, t) {
265
+ super(), this.children = e, this.length = t, this.lines = 0;
266
+ for (let n of e)
267
+ this.lines += n.lines;
268
+ }
269
+ lineInner(e, t, n, i) {
270
+ for (let s = 0; ; s++) {
271
+ let r = this.children[s], h = i + r.length, o = n + r.lines - 1;
272
+ if ((t ? o : h) >= e)
273
+ return r.lineInner(e, t, n, i);
274
+ i = h + 1, n = o + 1;
275
+ }
276
+ }
277
+ decompose(e, t, n, i) {
278
+ for (let s = 0, r = 0; r <= t && s < this.children.length; s++) {
279
+ let h = this.children[s], o = r + h.length;
280
+ if (e <= o && t >= r) {
281
+ let a = i & ((r <= e ? 1 : 0) | (o >= t ? 2 : 0));
282
+ r >= e && o <= t && !a ? n.push(h) : h.decompose(e - r, t - r, n, a);
283
+ }
284
+ r = o + 1;
285
+ }
286
+ }
287
+ replace(e, t, n) {
288
+ if ([e, t] = J(this, e, t), n.lines < this.lines)
289
+ for (let i = 0, s = 0; i < this.children.length; i++) {
290
+ let r = this.children[i], h = s + r.length;
291
+ if (e >= s && t <= h) {
292
+ let o = r.replace(e - s, t - s, n), a = this.lines - r.lines + o.lines;
293
+ if (o.lines < a >> 4 && o.lines > a >> 6) {
294
+ let u = this.children.slice();
295
+ return u[i] = o, new C(u, this.length - (t - e) + n.length);
296
+ }
297
+ return super.replace(s, h, o);
298
+ }
299
+ s = h + 1;
300
+ }
301
+ return super.replace(e, t, n);
302
+ }
303
+ sliceString(e, t = this.length, n = `
304
+ `) {
305
+ [e, t] = J(this, e, t);
306
+ let i = "";
307
+ for (let s = 0, r = 0; s < this.children.length && r <= t; s++) {
308
+ let h = this.children[s], o = r + h.length;
309
+ r > e && s && (i += n), e < o && t > r && (i += h.sliceString(e - r, t - r, n)), r = o + 1;
310
+ }
311
+ return i;
312
+ }
313
+ flatten(e) {
314
+ for (let t of this.children)
315
+ t.flatten(e);
316
+ }
317
+ scanIdentical(e, t) {
318
+ if (!(e instanceof C))
319
+ return 0;
320
+ let n = 0, [i, s, r, h] = t > 0 ? [0, 0, this.children.length, e.children.length] : [this.children.length - 1, e.children.length - 1, -1, -1];
321
+ for (; ; i += t, s += t) {
322
+ if (i == r || s == h)
323
+ return n;
324
+ let o = this.children[i], a = e.children[s];
325
+ if (o != a)
326
+ return n + o.scanIdentical(a, t);
327
+ n += o.length + 1;
328
+ }
329
+ }
330
+ static from(e, t = e.reduce((n, i) => n + i.length + 1, -1)) {
331
+ let n = 0;
332
+ for (let c of e)
333
+ n += c.lines;
334
+ if (n < 32) {
335
+ let c = [];
336
+ for (let g of e)
337
+ g.flatten(c);
338
+ return new m(c, t);
339
+ }
340
+ let i = Math.max(
341
+ 32,
342
+ n >> 5
343
+ /* Tree.BranchShift */
344
+ ), s = i << 1, r = i >> 1, h = [], o = 0, a = -1, u = [];
345
+ function f(c) {
346
+ let g;
347
+ if (c.lines > s && c instanceof C)
348
+ for (let b of c.children)
349
+ f(b);
350
+ else c.lines > r && (o > r || !o) ? (d(), h.push(c)) : c instanceof m && o && (g = u[u.length - 1]) instanceof m && c.lines + g.lines <= 32 ? (o += c.lines, a += c.length + 1, u[u.length - 1] = new m(g.text.concat(c.text), g.length + 1 + c.length)) : (o + c.lines > i && d(), o += c.lines, a += c.length + 1, u.push(c));
351
+ }
352
+ function d() {
353
+ o != 0 && (h.push(u.length == 1 ? u[0] : C.from(u, a)), a = -1, o = u.length = 0);
354
+ }
355
+ for (let c of e)
356
+ f(c);
357
+ return d(), h.length == 1 ? h[0] : new C(h, t);
358
+ }
359
+ }
360
+ x.empty = /* @__PURE__ */ new m([""], 0);
361
+ function Ke(l) {
362
+ let e = -1;
363
+ for (let t of l)
364
+ e += t.length + 1;
365
+ return e;
366
+ }
367
+ function Z(l, e, t = 0, n = 1e9) {
368
+ for (let i = 0, s = 0, r = !0; s < l.length && i <= n; s++) {
369
+ let h = l[s], o = i + h.length;
370
+ o >= t && (o > n && (h = h.slice(0, n - i)), i < t && (h = h.slice(t - i)), r ? (e[e.length - 1] += h, r = !1) : e.push(h)), i = o + 1;
371
+ }
372
+ return e;
373
+ }
374
+ function Ie(l, e, t) {
375
+ return Z(l, [""], e, t);
376
+ }
377
+ class N {
378
+ constructor(e, t = 1) {
379
+ this.dir = t, this.done = !1, this.lineBreak = !1, this.value = "", this.nodes = [e], this.offsets = [t > 0 ? 1 : (e instanceof m ? e.text.length : e.children.length) << 1];
380
+ }
381
+ nextInner(e, t) {
382
+ for (this.done = this.lineBreak = !1; ; ) {
383
+ let n = this.nodes.length - 1, i = this.nodes[n], s = this.offsets[n], r = s >> 1, h = i instanceof m ? i.text.length : i.children.length;
384
+ if (r == (t > 0 ? h : 0)) {
385
+ if (n == 0)
386
+ return this.done = !0, this.value = "", this;
387
+ t > 0 && this.offsets[n - 1]++, this.nodes.pop(), this.offsets.pop();
388
+ } else if ((s & 1) == (t > 0 ? 0 : 1)) {
389
+ if (this.offsets[n] += t, e == 0)
390
+ return this.lineBreak = !0, this.value = `
391
+ `, this;
392
+ e--;
393
+ } else if (i instanceof m) {
394
+ let o = i.text[r + (t < 0 ? -1 : 0)];
395
+ if (this.offsets[n] += t, o.length > Math.max(0, e))
396
+ return this.value = e == 0 ? o : t > 0 ? o.slice(e) : o.slice(0, o.length - e), this;
397
+ e -= o.length;
398
+ } else {
399
+ let o = i.children[r + (t < 0 ? -1 : 0)];
400
+ e > o.length ? (e -= o.length, this.offsets[n] += t) : (t < 0 && this.offsets[n]--, this.nodes.push(o), this.offsets.push(t > 0 ? 1 : (o instanceof m ? o.text.length : o.children.length) << 1));
401
+ }
402
+ }
403
+ }
404
+ next(e = 0) {
405
+ return e < 0 && (this.nextInner(-e, -this.dir), e = this.value.length), this.nextInner(e, this.dir);
406
+ }
407
+ }
408
+ class Te {
409
+ constructor(e, t, n) {
410
+ this.value = "", this.done = !1, this.cursor = new N(e, t > n ? -1 : 1), this.pos = t > n ? e.length : 0, this.from = Math.min(t, n), this.to = Math.max(t, n);
411
+ }
412
+ nextInner(e, t) {
413
+ if (t < 0 ? this.pos <= this.from : this.pos >= this.to)
414
+ return this.value = "", this.done = !0, this;
415
+ e += Math.max(0, t < 0 ? this.pos - this.to : this.from - this.pos);
416
+ let n = t < 0 ? this.pos - this.from : this.to - this.pos;
417
+ e > n && (e = n), n -= e;
418
+ let { value: i } = this.cursor.next(e);
419
+ return this.pos += (i.length + e) * t, this.value = i.length <= n ? i : t < 0 ? i.slice(i.length - n) : i.slice(0, n), this.done = !this.value, this;
420
+ }
421
+ next(e = 0) {
422
+ return e < 0 ? e = Math.max(e, this.from - this.pos) : e > 0 && (e = Math.min(e, this.to - this.pos)), this.nextInner(e, this.cursor.dir);
423
+ }
424
+ get lineBreak() {
425
+ return this.cursor.lineBreak && this.value != "";
426
+ }
427
+ }
428
+ class Be {
429
+ constructor(e) {
430
+ this.inner = e, this.afterBreak = !0, this.value = "", this.done = !1;
431
+ }
432
+ next(e = 0) {
433
+ let { done: t, lineBreak: n, value: i } = this.inner.next(e);
434
+ return t && this.afterBreak ? (this.value = "", this.afterBreak = !1) : t ? (this.done = !0, this.value = "") : n ? this.afterBreak ? this.value = "" : (this.afterBreak = !0, this.next()) : (this.value = i, this.afterBreak = !1), this;
435
+ }
436
+ get lineBreak() {
437
+ return !1;
438
+ }
439
+ }
440
+ typeof Symbol < "u" && (x.prototype[Symbol.iterator] = function() {
441
+ return this.iter();
442
+ }, N.prototype[Symbol.iterator] = Te.prototype[Symbol.iterator] = Be.prototype[Symbol.iterator] = function() {
443
+ return this;
444
+ });
445
+ class Qe {
446
+ /**
447
+ @internal
448
+ */
449
+ constructor(e, t, n, i) {
450
+ this.from = e, this.to = t, this.number = n, this.text = i;
451
+ }
452
+ /**
453
+ The length of the line (not including any line break after it).
454
+ */
455
+ get length() {
456
+ return this.to - this.from;
457
+ }
458
+ }
459
+ function J(l, e, t) {
460
+ return e = Math.max(0, Math.min(l.length, e)), [e, Math.max(e, Math.min(l.length, t))];
461
+ }
462
+ function Q(l, e, t = !0, n = !0) {
463
+ return je(l, e, t, n);
464
+ }
465
+ function Xe(l) {
466
+ return l >= 56320 && l < 57344;
467
+ }
468
+ function Ye(l) {
469
+ return l >= 55296 && l < 56320;
470
+ }
471
+ function ft(l, e) {
472
+ let t = l.charCodeAt(e);
473
+ if (!Ye(t) || e + 1 == l.length)
474
+ return t;
475
+ let n = l.charCodeAt(e + 1);
476
+ return Xe(n) ? (t - 55296 << 10) + (n - 56320) + 65536 : t;
477
+ }
478
+ function ct(l) {
479
+ return l <= 65535 ? String.fromCharCode(l) : (l -= 65536, String.fromCharCode((l >> 10) + 55296, (l & 1023) + 56320));
480
+ }
481
+ function dt(l) {
482
+ return l < 65536 ? 1 : 2;
483
+ }
484
+ const le = /\r\n?|\n/;
485
+ var O = /* @__PURE__ */ (function(l) {
486
+ return l[l.Simple = 0] = "Simple", l[l.TrackDel = 1] = "TrackDel", l[l.TrackBefore = 2] = "TrackBefore", l[l.TrackAfter = 3] = "TrackAfter", l;
487
+ })(O || (O = {}));
488
+ class E {
489
+ // Sections are encoded as pairs of integers. The first is the
490
+ // length in the current document, and the second is -1 for
491
+ // unaffected sections, and the length of the replacement content
492
+ // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
493
+ // 0), and a replacement two positive numbers.
494
+ /**
495
+ @internal
496
+ */
497
+ constructor(e) {
498
+ this.sections = e;
499
+ }
500
+ /**
501
+ The length of the document before the change.
502
+ */
503
+ get length() {
504
+ let e = 0;
505
+ for (let t = 0; t < this.sections.length; t += 2)
506
+ e += this.sections[t];
507
+ return e;
508
+ }
509
+ /**
510
+ The length of the document after the change.
511
+ */
512
+ get newLength() {
513
+ let e = 0;
514
+ for (let t = 0; t < this.sections.length; t += 2) {
515
+ let n = this.sections[t + 1];
516
+ e += n < 0 ? this.sections[t] : n;
517
+ }
518
+ return e;
519
+ }
520
+ /**
521
+ False when there are actual changes in this set.
522
+ */
523
+ get empty() {
524
+ return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0;
525
+ }
526
+ /**
527
+ Iterate over the unchanged parts left by these changes. `posA`
528
+ provides the position of the range in the old document, `posB`
529
+ the new position in the changed document.
530
+ */
531
+ iterGaps(e) {
532
+ for (let t = 0, n = 0, i = 0; t < this.sections.length; ) {
533
+ let s = this.sections[t++], r = this.sections[t++];
534
+ r < 0 ? (e(n, i, s), i += s) : i += r, n += s;
535
+ }
536
+ }
537
+ /**
538
+ Iterate over the ranges changed by these changes. (See
539
+ [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
540
+ variant that also provides you with the inserted text.)
541
+ `fromA`/`toA` provides the extent of the change in the starting
542
+ document, `fromB`/`toB` the extent of the replacement in the
543
+ changed document.
544
+
545
+ When `individual` is true, adjacent changes (which are kept
546
+ separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
547
+ reported separately.
548
+ */
549
+ iterChangedRanges(e, t = !1) {
550
+ he(this, e, t);
551
+ }
552
+ /**
553
+ Get a description of the inverted form of these changes.
554
+ */
555
+ get invertedDesc() {
556
+ let e = [];
557
+ for (let t = 0; t < this.sections.length; ) {
558
+ let n = this.sections[t++], i = this.sections[t++];
559
+ i < 0 ? e.push(n, i) : e.push(i, n);
560
+ }
561
+ return new E(e);
562
+ }
563
+ /**
564
+ Compute the combined effect of applying another set of changes
565
+ after this one. The length of the document after this set should
566
+ match the length before `other`.
567
+ */
568
+ composeDesc(e) {
569
+ return this.empty ? e : e.empty ? this : Fe(this, e);
570
+ }
571
+ /**
572
+ Map this description, which should start with the same document
573
+ as `other`, over another set of changes, so that it can be
574
+ applied after it. When `before` is true, map as if the changes
575
+ in `this` happened before the ones in `other`.
576
+ */
577
+ mapDesc(e, t = !1) {
578
+ return e.empty ? this : oe(this, e, t);
579
+ }
580
+ mapPos(e, t = -1, n = O.Simple) {
581
+ let i = 0, s = 0;
582
+ for (let r = 0; r < this.sections.length; ) {
583
+ let h = this.sections[r++], o = this.sections[r++], a = i + h;
584
+ if (o < 0) {
585
+ if (a > e)
586
+ return s + (e - i);
587
+ s += h;
588
+ } else {
589
+ if (n != O.Simple && a >= e && (n == O.TrackDel && i < e && a > e || n == O.TrackBefore && i < e || n == O.TrackAfter && a > e))
590
+ return null;
591
+ if (a > e || a == e && t < 0 && !h)
592
+ return e == i || t < 0 ? s : s + o;
593
+ s += o;
594
+ }
595
+ i = a;
596
+ }
597
+ if (e > i)
598
+ throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);
599
+ return s;
600
+ }
601
+ /**
602
+ Check whether these changes touch a given range. When one of the
603
+ changes entirely covers the range, the string `"cover"` is
604
+ returned.
605
+ */
606
+ touchesRange(e, t = e) {
607
+ for (let n = 0, i = 0; n < this.sections.length && i <= t; ) {
608
+ let s = this.sections[n++], r = this.sections[n++], h = i + s;
609
+ if (r >= 0 && i <= t && h >= e)
610
+ return i < e && h > t ? "cover" : !0;
611
+ i = h;
612
+ }
613
+ return !1;
614
+ }
615
+ /**
616
+ @internal
617
+ */
618
+ toString() {
619
+ let e = "";
620
+ for (let t = 0; t < this.sections.length; ) {
621
+ let n = this.sections[t++], i = this.sections[t++];
622
+ e += (e ? " " : "") + n + (i >= 0 ? ":" + i : "");
623
+ }
624
+ return e;
625
+ }
626
+ /**
627
+ Serialize this change desc to a JSON-representable value.
628
+ */
629
+ toJSON() {
630
+ return this.sections;
631
+ }
632
+ /**
633
+ Create a change desc from its JSON representation (as produced
634
+ by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
635
+ */
636
+ static fromJSON(e) {
637
+ if (!Array.isArray(e) || e.length % 2 || e.some((t) => typeof t != "number"))
638
+ throw new RangeError("Invalid JSON representation of ChangeDesc");
639
+ return new E(e);
640
+ }
641
+ /**
642
+ @internal
643
+ */
644
+ static create(e) {
645
+ return new E(e);
646
+ }
647
+ }
648
+ class k extends E {
649
+ constructor(e, t) {
650
+ super(e), this.inserted = t;
651
+ }
652
+ /**
653
+ Apply the changes to a document, returning the modified
654
+ document.
655
+ */
656
+ apply(e) {
657
+ if (this.length != e.length)
658
+ throw new RangeError("Applying change set to a document with the wrong length");
659
+ return he(this, (t, n, i, s, r) => e = e.replace(i, i + (n - t), r), !1), e;
660
+ }
661
+ mapDesc(e, t = !1) {
662
+ return oe(this, e, t, !0);
663
+ }
664
+ /**
665
+ Given the document as it existed _before_ the changes, return a
666
+ change set that represents the inverse of this set, which could
667
+ be used to go from the document created by the changes back to
668
+ the document as it existed before the changes.
669
+ */
670
+ invert(e) {
671
+ let t = this.sections.slice(), n = [];
672
+ for (let i = 0, s = 0; i < t.length; i += 2) {
673
+ let r = t[i], h = t[i + 1];
674
+ if (h >= 0) {
675
+ t[i] = h, t[i + 1] = r;
676
+ let o = i >> 1;
677
+ for (; n.length < o; )
678
+ n.push(x.empty);
679
+ n.push(r ? e.slice(s, s + r) : x.empty);
680
+ }
681
+ s += r;
682
+ }
683
+ return new k(t, n);
684
+ }
685
+ /**
686
+ Combine two subsequent change sets into a single set. `other`
687
+ must start in the document produced by `this`. If `this` goes
688
+ `docA` → `docB` and `other` represents `docB` → `docC`, the
689
+ returned value will represent the change `docA` → `docC`.
690
+ */
691
+ compose(e) {
692
+ return this.empty ? e : e.empty ? this : Fe(this, e, !0);
693
+ }
694
+ /**
695
+ Given another change set starting in the same document, maps this
696
+ change set over the other, producing a new change set that can be
697
+ applied to the document produced by applying `other`. When
698
+ `before` is `true`, order changes as if `this` comes before
699
+ `other`, otherwise (the default) treat `other` as coming first.
700
+
701
+ Given two changes `A` and `B`, `A.compose(B.map(A))` and
702
+ `B.compose(A.map(B, true))` will produce the same document. This
703
+ provides a basic form of [operational
704
+ transformation](https://en.wikipedia.org/wiki/Operational_transformation),
705
+ and can be used for collaborative editing.
706
+ */
707
+ map(e, t = !1) {
708
+ return e.empty ? this : oe(this, e, t, !0);
709
+ }
710
+ /**
711
+ Iterate over the changed ranges in the document, calling `f` for
712
+ each, with the range in the original document (`fromA`-`toA`)
713
+ and the range that replaces it in the new document
714
+ (`fromB`-`toB`).
715
+
716
+ When `individual` is true, adjacent changes are reported
717
+ separately.
718
+ */
719
+ iterChanges(e, t = !1) {
720
+ he(this, e, t);
721
+ }
722
+ /**
723
+ Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
724
+ set.
725
+ */
726
+ get desc() {
727
+ return E.create(this.sections);
728
+ }
729
+ /**
730
+ @internal
731
+ */
732
+ filter(e) {
733
+ let t = [], n = [], i = [], s = new q(this);
734
+ e: for (let r = 0, h = 0; ; ) {
735
+ let o = r == e.length ? 1e9 : e[r++];
736
+ for (; h < o || h == o && s.len == 0; ) {
737
+ if (s.done)
738
+ break e;
739
+ let u = Math.min(s.len, o - h);
740
+ y(i, u, -1);
741
+ let f = s.ins == -1 ? -1 : s.off == 0 ? s.ins : 0;
742
+ y(t, u, f), f > 0 && R(n, t, s.text), s.forward(u), h += u;
743
+ }
744
+ let a = e[r++];
745
+ for (; h < a; ) {
746
+ if (s.done)
747
+ break e;
748
+ let u = Math.min(s.len, a - h);
749
+ y(t, u, -1), y(i, u, s.ins == -1 ? -1 : s.off == 0 ? s.ins : 0), s.forward(u), h += u;
750
+ }
751
+ }
752
+ return {
753
+ changes: new k(t, n),
754
+ filtered: E.create(i)
755
+ };
756
+ }
757
+ /**
758
+ Serialize this change set to a JSON-representable value.
759
+ */
760
+ toJSON() {
761
+ let e = [];
762
+ for (let t = 0; t < this.sections.length; t += 2) {
763
+ let n = this.sections[t], i = this.sections[t + 1];
764
+ i < 0 ? e.push(n) : i == 0 ? e.push([n]) : e.push([n].concat(this.inserted[t >> 1].toJSON()));
765
+ }
766
+ return e;
767
+ }
768
+ /**
769
+ Create a change set for the given changes, for a document of the
770
+ given length, using `lineSep` as line separator.
771
+ */
772
+ static of(e, t, n) {
773
+ let i = [], s = [], r = 0, h = null;
774
+ function o(u = !1) {
775
+ if (!u && !i.length)
776
+ return;
777
+ r < t && y(i, t - r, -1);
778
+ let f = new k(i, s);
779
+ h = h ? h.compose(f.map(h)) : f, i = [], s = [], r = 0;
780
+ }
781
+ function a(u) {
782
+ if (Array.isArray(u))
783
+ for (let f of u)
784
+ a(f);
785
+ else if (u instanceof k) {
786
+ if (u.length != t)
787
+ throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);
788
+ o(), h = h ? h.compose(u.map(h)) : u;
789
+ } else {
790
+ let { from: f, to: d = f, insert: c } = u;
791
+ if (f > d || f < 0 || d > t)
792
+ throw new RangeError(`Invalid change range ${f} to ${d} (in doc of length ${t})`);
793
+ let g = c ? typeof c == "string" ? x.of(c.split(n || le)) : c : x.empty, b = g.length;
794
+ if (f == d && b == 0)
795
+ return;
796
+ f < r && o(), f > r && y(i, f - r, -1), y(i, d - f, b), R(s, i, g), r = d;
797
+ }
798
+ }
799
+ return a(e), o(!h), h;
800
+ }
801
+ /**
802
+ Create an empty changeset of the given length.
803
+ */
804
+ static empty(e) {
805
+ return new k(e ? [e, -1] : [], []);
806
+ }
807
+ /**
808
+ Create a changeset from its JSON representation (as produced by
809
+ [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
810
+ */
811
+ static fromJSON(e) {
812
+ if (!Array.isArray(e))
813
+ throw new RangeError("Invalid JSON representation of ChangeSet");
814
+ let t = [], n = [];
815
+ for (let i = 0; i < e.length; i++) {
816
+ let s = e[i];
817
+ if (typeof s == "number")
818
+ t.push(s, -1);
819
+ else {
820
+ if (!Array.isArray(s) || typeof s[0] != "number" || s.some((r, h) => h && typeof r != "string"))
821
+ throw new RangeError("Invalid JSON representation of ChangeSet");
822
+ if (s.length == 1)
823
+ t.push(s[0], 0);
824
+ else {
825
+ for (; n.length < i; )
826
+ n.push(x.empty);
827
+ n[i] = x.of(s.slice(1)), t.push(s[0], n[i].length);
828
+ }
829
+ }
830
+ }
831
+ return new k(t, n);
832
+ }
833
+ /**
834
+ @internal
835
+ */
836
+ static createSet(e, t) {
837
+ return new k(e, t);
838
+ }
839
+ }
840
+ function y(l, e, t, n = !1) {
841
+ if (e == 0 && t <= 0)
842
+ return;
843
+ let i = l.length - 2;
844
+ i >= 0 && t <= 0 && t == l[i + 1] ? l[i] += e : i >= 0 && e == 0 && l[i] == 0 ? l[i + 1] += t : n ? (l[i] += e, l[i + 1] += t) : l.push(e, t);
845
+ }
846
+ function R(l, e, t) {
847
+ if (t.length == 0)
848
+ return;
849
+ let n = e.length - 2 >> 1;
850
+ if (n < l.length)
851
+ l[l.length - 1] = l[l.length - 1].append(t);
852
+ else {
853
+ for (; l.length < n; )
854
+ l.push(x.empty);
855
+ l.push(t);
856
+ }
857
+ }
858
+ function he(l, e, t) {
859
+ let n = l.inserted;
860
+ for (let i = 0, s = 0, r = 0; r < l.sections.length; ) {
861
+ let h = l.sections[r++], o = l.sections[r++];
862
+ if (o < 0)
863
+ i += h, s += h;
864
+ else {
865
+ let a = i, u = s, f = x.empty;
866
+ for (; a += h, u += o, o && n && (f = f.append(n[r - 2 >> 1])), !(t || r == l.sections.length || l.sections[r + 1] < 0); )
867
+ h = l.sections[r++], o = l.sections[r++];
868
+ e(i, a, s, u, f), i = a, s = u;
869
+ }
870
+ }
871
+ }
872
+ function oe(l, e, t, n = !1) {
873
+ let i = [], s = n ? [] : null, r = new q(l), h = new q(e);
874
+ for (let o = -1; ; ) {
875
+ if (r.done && h.len || h.done && r.len)
876
+ throw new Error("Mismatched change set lengths");
877
+ if (r.ins == -1 && h.ins == -1) {
878
+ let a = Math.min(r.len, h.len);
879
+ y(i, a, -1), r.forward(a), h.forward(a);
880
+ } else if (h.ins >= 0 && (r.ins < 0 || o == r.i || r.off == 0 && (h.len < r.len || h.len == r.len && !t))) {
881
+ let a = h.len;
882
+ for (y(i, h.ins, -1); a; ) {
883
+ let u = Math.min(r.len, a);
884
+ r.ins >= 0 && o < r.i && r.len <= u && (y(i, 0, r.ins), s && R(s, i, r.text), o = r.i), r.forward(u), a -= u;
885
+ }
886
+ h.next();
887
+ } else if (r.ins >= 0) {
888
+ let a = 0, u = r.len;
889
+ for (; u; )
890
+ if (h.ins == -1) {
891
+ let f = Math.min(u, h.len);
892
+ a += f, u -= f, h.forward(f);
893
+ } else if (h.ins == 0 && h.len < u)
894
+ u -= h.len, h.next();
895
+ else
896
+ break;
897
+ y(i, a, o < r.i ? r.ins : 0), s && o < r.i && R(s, i, r.text), o = r.i, r.forward(r.len - u);
898
+ } else {
899
+ if (r.done && h.done)
900
+ return s ? k.createSet(i, s) : E.create(i);
901
+ throw new Error("Mismatched change set lengths");
902
+ }
903
+ }
904
+ }
905
+ function Fe(l, e, t = !1) {
906
+ let n = [], i = t ? [] : null, s = new q(l), r = new q(e);
907
+ for (let h = !1; ; ) {
908
+ if (s.done && r.done)
909
+ return i ? k.createSet(n, i) : E.create(n);
910
+ if (s.ins == 0)
911
+ y(n, s.len, 0, h), s.next();
912
+ else if (r.len == 0 && !r.done)
913
+ y(n, 0, r.ins, h), i && R(i, n, r.text), r.next();
914
+ else {
915
+ if (s.done || r.done)
916
+ throw new Error("Mismatched change set lengths");
917
+ {
918
+ let o = Math.min(s.len2, r.len), a = n.length;
919
+ if (s.ins == -1) {
920
+ let u = r.ins == -1 ? -1 : r.off ? 0 : r.ins;
921
+ y(n, o, u, h), i && u && R(i, n, r.text);
922
+ } else r.ins == -1 ? (y(n, s.off ? 0 : s.len, o, h), i && R(i, n, s.textBit(o))) : (y(n, s.off ? 0 : s.len, r.off ? 0 : r.ins, h), i && !r.off && R(i, n, r.text));
923
+ h = (s.ins > o || r.ins >= 0 && r.len > o) && (h || n.length > a), s.forward2(o), r.forward(o);
924
+ }
925
+ }
926
+ }
927
+ }
928
+ class q {
929
+ constructor(e) {
930
+ this.set = e, this.i = 0, this.next();
931
+ }
932
+ next() {
933
+ let { sections: e } = this.set;
934
+ this.i < e.length ? (this.len = e[this.i++], this.ins = e[this.i++]) : (this.len = 0, this.ins = -2), this.off = 0;
935
+ }
936
+ get done() {
937
+ return this.ins == -2;
938
+ }
939
+ get len2() {
940
+ return this.ins < 0 ? this.len : this.ins;
941
+ }
942
+ get text() {
943
+ let { inserted: e } = this.set, t = this.i - 2 >> 1;
944
+ return t >= e.length ? x.empty : e[t];
945
+ }
946
+ textBit(e) {
947
+ let { inserted: t } = this.set, n = this.i - 2 >> 1;
948
+ return n >= t.length && !e ? x.empty : t[n].slice(this.off, e == null ? void 0 : this.off + e);
949
+ }
950
+ forward(e) {
951
+ e == this.len ? this.next() : (this.len -= e, this.off += e);
952
+ }
953
+ forward2(e) {
954
+ this.ins == -1 ? this.forward(e) : e == this.ins ? this.next() : (this.ins -= e, this.off += e);
955
+ }
956
+ }
957
+ class M {
958
+ constructor(e, t, n, i) {
959
+ this.from = e, this.to = t, this.flags = n, this.goalColumn = i;
960
+ }
961
+ /**
962
+ The anchor of the range—the side that doesn't move when you
963
+ extend it.
964
+ */
965
+ get anchor() {
966
+ return this.flags & 32 ? this.to : this.from;
967
+ }
968
+ /**
969
+ The head of the range, which is moved when the range is
970
+ [extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
971
+ */
972
+ get head() {
973
+ return this.flags & 32 ? this.from : this.to;
974
+ }
975
+ /**
976
+ True when `anchor` and `head` are at the same position.
977
+ */
978
+ get empty() {
979
+ return this.from == this.to;
980
+ }
981
+ /**
982
+ If this is a cursor that is explicitly associated with the
983
+ character on one of its sides, this returns the side. -1 means
984
+ the character before its position, 1 the character after, and 0
985
+ means no association.
986
+ */
987
+ get assoc() {
988
+ return this.flags & 8 ? -1 : this.flags & 16 ? 1 : 0;
989
+ }
990
+ /**
991
+ A flag that, when set, makes some selection-extending commands
992
+ treat the range's head and anchor as exchangeable, so that for
993
+ example Shift-ArrowUp will make the lower side of the selection
994
+ the anchor, even if that was the head before. Used to implement
995
+ MacOS-style undirectional selections.
996
+ */
997
+ get undirectional() {
998
+ return (this.flags & 64) > 0;
999
+ }
1000
+ /**
1001
+ The bidirectional text level associated with this cursor, if
1002
+ any.
1003
+ */
1004
+ get bidiLevel() {
1005
+ let e = this.flags & 7;
1006
+ return e == 7 ? null : e;
1007
+ }
1008
+ /**
1009
+ Map this range through a change, producing a valid range in the
1010
+ updated document.
1011
+ */
1012
+ map(e, t = -1) {
1013
+ let n, i;
1014
+ return this.empty ? n = i = e.mapPos(this.from, t) : (n = e.mapPos(this.from, 1), i = e.mapPos(this.to, -1)), n == this.from && i == this.to ? this : new M(n, i, this.flags, this.goalColumn);
1015
+ }
1016
+ /**
1017
+ Extend this range to cover at least `from` to `to`.
1018
+ */
1019
+ extend(e, t = e, n = 0) {
1020
+ if (e <= this.anchor && t >= this.anchor)
1021
+ return p.range(e, t, void 0, void 0, n);
1022
+ let i = Math.abs(e - this.anchor) > Math.abs(t - this.anchor) ? e : t;
1023
+ return p.range(this.anchor, i, void 0, void 0, n);
1024
+ }
1025
+ /**
1026
+ Compare this range to another range.
1027
+ */
1028
+ eq(e, t = !1) {
1029
+ return this.anchor == e.anchor && this.head == e.head && this.goalColumn == e.goalColumn && (!t || !this.empty || this.assoc == e.assoc);
1030
+ }
1031
+ /**
1032
+ Return a JSON-serializable object representing the range.
1033
+ */
1034
+ toJSON() {
1035
+ return { anchor: this.anchor, head: this.head };
1036
+ }
1037
+ /**
1038
+ Convert a JSON representation of a range to a `SelectionRange`
1039
+ instance.
1040
+ */
1041
+ static fromJSON(e) {
1042
+ if (!e || typeof e.anchor != "number" || typeof e.head != "number")
1043
+ throw new RangeError("Invalid JSON representation for SelectionRange");
1044
+ return p.range(e.anchor, e.head);
1045
+ }
1046
+ /**
1047
+ @internal
1048
+ */
1049
+ static create(e, t, n, i) {
1050
+ return new M(e, t, n, i);
1051
+ }
1052
+ }
1053
+ class p {
1054
+ constructor(e, t) {
1055
+ this.ranges = e, this.mainIndex = t;
1056
+ }
1057
+ /**
1058
+ Map a selection through a change. Used to adjust the selection
1059
+ position for changes.
1060
+ */
1061
+ map(e, t = -1) {
1062
+ return e.empty ? this : p.create(this.ranges.map((n) => n.map(e, t)), this.mainIndex);
1063
+ }
1064
+ /**
1065
+ Compare this selection to another selection. By default, ranges
1066
+ are compared only by position. When `includeAssoc` is true,
1067
+ cursor ranges must also have the same
1068
+ [`assoc`](https://codemirror.net/6/docs/ref/#state.SelectionRange.assoc) value.
1069
+ */
1070
+ eq(e, t = !1) {
1071
+ if (this.ranges.length != e.ranges.length || this.mainIndex != e.mainIndex)
1072
+ return !1;
1073
+ for (let n = 0; n < this.ranges.length; n++)
1074
+ if (!this.ranges[n].eq(e.ranges[n], t))
1075
+ return !1;
1076
+ return !0;
1077
+ }
1078
+ /**
1079
+ Get the primary selection range. Usually, you should make sure
1080
+ your code applies to _all_ ranges, by using methods like
1081
+ [`changeByRange`](https://codemirror.net/6/docs/ref/#state.EditorState.changeByRange).
1082
+ */
1083
+ get main() {
1084
+ return this.ranges[this.mainIndex];
1085
+ }
1086
+ /**
1087
+ Make sure the selection only has one range. Returns a selection
1088
+ holding only the main range from this selection.
1089
+ */
1090
+ asSingle() {
1091
+ return this.ranges.length == 1 ? this : new p([this.main], 0);
1092
+ }
1093
+ /**
1094
+ Extend this selection with an extra range.
1095
+ */
1096
+ addRange(e, t = !0) {
1097
+ return p.create([e].concat(this.ranges), t ? 0 : this.mainIndex + 1);
1098
+ }
1099
+ /**
1100
+ Replace a given range with another range, and then normalize the
1101
+ selection to merge and sort ranges if necessary.
1102
+ */
1103
+ replaceRange(e, t = this.mainIndex) {
1104
+ let n = this.ranges.slice();
1105
+ return n[t] = e, p.create(n, this.mainIndex);
1106
+ }
1107
+ /**
1108
+ Convert this selection to an object that can be serialized to
1109
+ JSON.
1110
+ */
1111
+ toJSON() {
1112
+ return { ranges: this.ranges.map((e) => e.toJSON()), main: this.mainIndex };
1113
+ }
1114
+ /**
1115
+ Create a selection from a JSON representation.
1116
+ */
1117
+ static fromJSON(e) {
1118
+ if (!e || !Array.isArray(e.ranges) || typeof e.main != "number" || e.main >= e.ranges.length)
1119
+ throw new RangeError("Invalid JSON representation for EditorSelection");
1120
+ return new p(e.ranges.map((t) => M.fromJSON(t)), e.main);
1121
+ }
1122
+ /**
1123
+ Create a selection holding a single range.
1124
+ */
1125
+ static single(e, t = e) {
1126
+ return new p([p.range(e, t)], 0);
1127
+ }
1128
+ /**
1129
+ Sort and merge the given set of ranges, creating a valid
1130
+ selection.
1131
+ */
1132
+ static create(e, t = 0) {
1133
+ if (e.length == 0)
1134
+ throw new RangeError("A selection needs at least one range");
1135
+ for (let n = 0, i = 0; i < e.length; i++) {
1136
+ let s = e[i];
1137
+ if (s.empty ? s.from <= n : s.from < n)
1138
+ return p.normalized(e.slice(), t);
1139
+ n = s.to;
1140
+ }
1141
+ return new p(e, t);
1142
+ }
1143
+ /**
1144
+ Create a cursor selection range at the given position. You can
1145
+ safely ignore the optional arguments in most situations.
1146
+ */
1147
+ static cursor(e, t = 0, n, i) {
1148
+ return M.create(e, e, (t == 0 ? 0 : t < 0 ? 8 : 16) | (n == null ? 7 : Math.min(6, n)), i);
1149
+ }
1150
+ /**
1151
+ Create a selection range.
1152
+ */
1153
+ static range(e, t, n, i, s) {
1154
+ let r = i == null ? 7 : Math.min(6, i);
1155
+ return !s && e != t && (s = t < e ? 1 : -1), s && (r |= s < 0 ? 8 : 16), t < e ? M.create(t, e, r | 32, n) : M.create(e, t, r, n);
1156
+ }
1157
+ /**
1158
+ Create an [undirectional](https://codemirror.net/6/docs/ref/#state.SelectionRange.undirectional)
1159
+ selection range.
1160
+ */
1161
+ static undirectionalRange(e, t) {
1162
+ return M.create(e, t, 64, void 0);
1163
+ }
1164
+ /**
1165
+ @internal
1166
+ */
1167
+ static normalized(e, t = 0) {
1168
+ let n = e[t];
1169
+ e.sort((i, s) => i.from - s.from), t = e.indexOf(n);
1170
+ for (let i = 1; i < e.length; i++) {
1171
+ let s = e[i], r = e[i - 1];
1172
+ if (s.empty ? s.from <= r.to : s.from < r.to) {
1173
+ let h = r.from, o = Math.max(s.to, r.to);
1174
+ i <= t && t--, e.splice(--i, 2, s.anchor > s.head ? p.range(o, h) : p.range(h, o));
1175
+ }
1176
+ }
1177
+ return new p(e, t);
1178
+ }
1179
+ }
1180
+ function Je(l, e) {
1181
+ for (let t of l.ranges)
1182
+ if (t.to > e)
1183
+ throw new RangeError("Selection points outside of document");
1184
+ }
1185
+ let me = 0;
1186
+ class A {
1187
+ constructor(e, t, n, i, s) {
1188
+ this.combine = e, this.compareInput = t, this.compare = n, this.isStatic = i, this.id = me++, this.default = e([]), this.extensions = typeof s == "function" ? s(this) : s;
1189
+ }
1190
+ /**
1191
+ Returns a facet reader for this facet, which can be used to
1192
+ [read](https://codemirror.net/6/docs/ref/#state.EditorState.facet) it but not to define values for it.
1193
+ */
1194
+ get reader() {
1195
+ return this;
1196
+ }
1197
+ /**
1198
+ Define a new facet.
1199
+ */
1200
+ static define(e = {}) {
1201
+ return new A(e.combine || ((t) => t), e.compareInput || ((t, n) => t === n), e.compare || (e.combine ? (t, n) => t === n : we), !!e.static, e.enables);
1202
+ }
1203
+ /**
1204
+ Returns an extension that adds the given value to this facet.
1205
+ */
1206
+ of(e) {
1207
+ return new K([], this, 0, e);
1208
+ }
1209
+ /**
1210
+ Create an extension that computes a value for the facet from a
1211
+ state. You must take care to declare the parts of the state that
1212
+ this value depends on, since your function is only called again
1213
+ for a new state when one of those parts changed.
1214
+
1215
+ In cases where your value depends only on a single field, you'll
1216
+ want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
1217
+ */
1218
+ compute(e, t) {
1219
+ if (this.isStatic)
1220
+ throw new Error("Can't compute a static facet");
1221
+ return new K(e, this, 1, t);
1222
+ }
1223
+ /**
1224
+ Create an extension that computes zero or more values for this
1225
+ facet from a state.
1226
+ */
1227
+ computeN(e, t) {
1228
+ if (this.isStatic)
1229
+ throw new Error("Can't compute a static facet");
1230
+ return new K(e, this, 2, t);
1231
+ }
1232
+ from(e, t) {
1233
+ return t || (t = (n) => n), this.compute([e], (n) => t(n.field(e)));
1234
+ }
1235
+ }
1236
+ function we(l, e) {
1237
+ return l == e || l.length == e.length && l.every((t, n) => t === e[n]);
1238
+ }
1239
+ class K {
1240
+ constructor(e, t, n, i) {
1241
+ this.dependencies = e, this.facet = t, this.type = n, this.value = i, this.id = me++;
1242
+ }
1243
+ dynamicSlot(e) {
1244
+ var t;
1245
+ let n = this.value, i = this.facet.compareInput, s = this.id, r = e[s] >> 1, h = this.type == 2, o = !1, a = !1, u = [];
1246
+ for (let f of this.dependencies)
1247
+ f == "doc" ? o = !0 : f == "selection" ? a = !0 : (((t = e[f.id]) !== null && t !== void 0 ? t : 1) & 1) == 0 && u.push(e[f.id]);
1248
+ return {
1249
+ create(f) {
1250
+ return f.values[r] = n(f), 1;
1251
+ },
1252
+ update(f, d) {
1253
+ if (o && d.docChanged || a && (d.docChanged || d.selection) || ae(f, u)) {
1254
+ let c = n(f);
1255
+ if (h ? !Pe(c, f.values[r], i) : !i(c, f.values[r]))
1256
+ return f.values[r] = c, 1;
1257
+ }
1258
+ return 0;
1259
+ },
1260
+ reconfigure: (f, d) => {
1261
+ let c, g = d.config.address[s];
1262
+ if (g != null) {
1263
+ let b = Y(d, g);
1264
+ if (this.dependencies.every((v) => v instanceof A ? d.facet(v) === f.facet(v) : v instanceof L ? d.field(v, !1) == f.field(v, !1) : !0) || (h ? Pe(c = n(f), b, i) : i(c = n(f), b)))
1265
+ return f.values[r] = b, 0;
1266
+ } else
1267
+ c = n(f);
1268
+ return f.values[r] = c, 1;
1269
+ }
1270
+ };
1271
+ }
1272
+ get extension() {
1273
+ return this;
1274
+ }
1275
+ }
1276
+ function Pe(l, e, t) {
1277
+ if (l.length != e.length)
1278
+ return !1;
1279
+ for (let n = 0; n < l.length; n++)
1280
+ if (!t(l[n], e[n]))
1281
+ return !1;
1282
+ return !0;
1283
+ }
1284
+ function ae(l, e) {
1285
+ let t = !1;
1286
+ for (let n of e)
1287
+ $(l, n) & 1 && (t = !0);
1288
+ return t;
1289
+ }
1290
+ function _e(l, e, t) {
1291
+ let n = t.map((o) => l[o.id]), i = t.map((o) => o.type), s = n.filter((o) => !(o & 1)), r = l[e.id] >> 1;
1292
+ function h(o) {
1293
+ let a = [];
1294
+ for (let u = 0; u < n.length; u++) {
1295
+ let f = Y(o, n[u]);
1296
+ if (i[u] == 2)
1297
+ for (let d of f)
1298
+ a.push(d);
1299
+ else
1300
+ a.push(f);
1301
+ }
1302
+ return e.combine(a);
1303
+ }
1304
+ return {
1305
+ create(o) {
1306
+ for (let a of n)
1307
+ $(o, a);
1308
+ return o.values[r] = h(o), 1;
1309
+ },
1310
+ update(o, a) {
1311
+ if (!ae(o, s))
1312
+ return 0;
1313
+ let u = h(o);
1314
+ return e.compare(u, o.values[r]) ? 0 : (o.values[r] = u, 1);
1315
+ },
1316
+ reconfigure(o, a) {
1317
+ let u = ae(o, n), f = a.config.facets[e.id], d = a.facet(e);
1318
+ if (f && !u && we(t, f))
1319
+ return o.values[r] = d, 0;
1320
+ let c = h(o);
1321
+ return e.compare(c, d) ? (o.values[r] = d, 0) : (o.values[r] = c, 1);
1322
+ }
1323
+ };
1324
+ }
1325
+ const H = /* @__PURE__ */ A.define({ static: !0 });
1326
+ class L {
1327
+ constructor(e, t, n, i, s) {
1328
+ this.id = e, this.createF = t, this.updateF = n, this.compareF = i, this.spec = s, this.provides = void 0;
1329
+ }
1330
+ /**
1331
+ Define a state field.
1332
+ */
1333
+ static define(e) {
1334
+ let t = new L(me++, e.create, e.update, e.compare || ((n, i) => n === i), e);
1335
+ return e.provide && (t.provides = e.provide(t)), t;
1336
+ }
1337
+ create(e) {
1338
+ let t = e.facet(H).find((n) => n.field == this);
1339
+ return (t?.create || this.createF)(e);
1340
+ }
1341
+ /**
1342
+ @internal
1343
+ */
1344
+ slot(e) {
1345
+ let t = e[this.id] >> 1;
1346
+ return {
1347
+ create: (n) => (n.values[t] = this.create(n), 1),
1348
+ update: (n, i) => {
1349
+ let s = n.values[t], r = this.updateF(s, i);
1350
+ return this.compareF(s, r) ? 0 : (n.values[t] = r, 1);
1351
+ },
1352
+ reconfigure: (n, i) => {
1353
+ let s = n.facet(H), r = i.facet(H), h;
1354
+ return (h = s.find((o) => o.field == this)) && h != r.find((o) => o.field == this) ? (n.values[t] = h.create(n), 1) : i.config.address[this.id] != null ? (n.values[t] = i.field(this), 0) : (n.values[t] = this.create(n), 1);
1355
+ }
1356
+ };
1357
+ }
1358
+ /**
1359
+ Returns an extension that enables this field and overrides the
1360
+ way it is initialized. Can be useful when you need to provide a
1361
+ non-default starting value for the field.
1362
+ */
1363
+ init(e) {
1364
+ return [this, H.of({ field: this, create: e })];
1365
+ }
1366
+ /**
1367
+ State field instances can be used as
1368
+ [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
1369
+ given state.
1370
+ */
1371
+ get extension() {
1372
+ return this;
1373
+ }
1374
+ }
1375
+ const B = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
1376
+ function D(l) {
1377
+ return (e) => new Le(e, l);
1378
+ }
1379
+ const gt = {
1380
+ /**
1381
+ The highest precedence level, for extensions that should end up
1382
+ near the start of the precedence ordering.
1383
+ */
1384
+ highest: /* @__PURE__ */ D(B.highest),
1385
+ /**
1386
+ A higher-than-default precedence, for extensions that should
1387
+ come before those with default precedence.
1388
+ */
1389
+ high: /* @__PURE__ */ D(B.high),
1390
+ /**
1391
+ The default precedence, which is also used for extensions
1392
+ without an explicit precedence.
1393
+ */
1394
+ default: /* @__PURE__ */ D(B.default),
1395
+ /**
1396
+ A lower-than-default precedence.
1397
+ */
1398
+ low: /* @__PURE__ */ D(B.low),
1399
+ /**
1400
+ The lowest precedence level. Meant for things that should end up
1401
+ near the end of the extension order.
1402
+ */
1403
+ lowest: /* @__PURE__ */ D(B.lowest)
1404
+ };
1405
+ class Le {
1406
+ constructor(e, t) {
1407
+ this.inner = e, this.prec = t;
1408
+ }
1409
+ get extension() {
1410
+ return this;
1411
+ }
1412
+ }
1413
+ class te {
1414
+ /**
1415
+ Create an instance of this compartment to add to your [state
1416
+ configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
1417
+ */
1418
+ of(e) {
1419
+ return new ue(this, e);
1420
+ }
1421
+ /**
1422
+ Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
1423
+ reconfigures this compartment.
1424
+ */
1425
+ reconfigure(e) {
1426
+ return te.reconfigure.of({ compartment: this, extension: e });
1427
+ }
1428
+ /**
1429
+ Get the current content of the compartment in the state, or
1430
+ `undefined` if it isn't present.
1431
+ */
1432
+ get(e) {
1433
+ return e.config.compartments.get(this);
1434
+ }
1435
+ }
1436
+ class ue {
1437
+ constructor(e, t) {
1438
+ this.compartment = e, this.inner = t;
1439
+ }
1440
+ get extension() {
1441
+ return this;
1442
+ }
1443
+ }
1444
+ class X {
1445
+ constructor(e, t, n, i, s, r) {
1446
+ for (this.base = e, this.compartments = t, this.dynamicSlots = n, this.address = i, this.staticValues = s, this.facets = r, this.statusTemplate = []; this.statusTemplate.length < n.length; )
1447
+ this.statusTemplate.push(
1448
+ 0
1449
+ /* SlotStatus.Unresolved */
1450
+ );
1451
+ }
1452
+ staticFacet(e) {
1453
+ let t = this.address[e.id];
1454
+ return t == null ? e.default : this.staticValues[t >> 1];
1455
+ }
1456
+ static resolve(e, t, n) {
1457
+ let i = [], s = /* @__PURE__ */ Object.create(null), r = /* @__PURE__ */ new Map();
1458
+ for (let d of et(e, t, r))
1459
+ d instanceof L ? i.push(d) : (s[d.facet.id] || (s[d.facet.id] = [])).push(d);
1460
+ let h = /* @__PURE__ */ Object.create(null), o = [], a = [];
1461
+ for (let d of i)
1462
+ h[d.id] = a.length << 1, a.push((c) => d.slot(c));
1463
+ let u = n?.config.facets;
1464
+ for (let d in s) {
1465
+ let c = s[d], g = c[0].facet, b = u && u[d] || [];
1466
+ if (c.every(
1467
+ (v) => v.type == 0
1468
+ /* Provider.Static */
1469
+ ))
1470
+ if (h[g.id] = o.length << 1 | 1, we(b, c))
1471
+ o.push(n.facet(g));
1472
+ else {
1473
+ let v = g.combine(c.map((ne) => ne.value));
1474
+ o.push(n && g.compare(v, n.facet(g)) ? n.facet(g) : v);
1475
+ }
1476
+ else {
1477
+ for (let v of c)
1478
+ v.type == 0 ? (h[v.id] = o.length << 1 | 1, o.push(v.value)) : (h[v.id] = a.length << 1, a.push((ne) => v.dynamicSlot(ne)));
1479
+ h[g.id] = a.length << 1, a.push((v) => _e(v, g, c));
1480
+ }
1481
+ }
1482
+ let f = a.map((d) => d(h));
1483
+ return new X(e, r, f, h, o, s);
1484
+ }
1485
+ }
1486
+ function et(l, e, t) {
1487
+ let n = [[], [], [], [], []], i = /* @__PURE__ */ new Map();
1488
+ function s(r, h) {
1489
+ let o = i.get(r);
1490
+ if (o != null) {
1491
+ if (o <= h)
1492
+ return;
1493
+ let a = n[o].indexOf(r);
1494
+ a > -1 && n[o].splice(a, 1), r instanceof ue && t.delete(r.compartment);
1495
+ }
1496
+ if (i.set(r, h), Array.isArray(r))
1497
+ for (let a of r)
1498
+ s(a, h);
1499
+ else if (r instanceof ue) {
1500
+ if (t.has(r.compartment))
1501
+ throw new RangeError("Duplicate use of compartment in extensions");
1502
+ let a = e.get(r.compartment) || r.inner;
1503
+ t.set(r.compartment, a), s(a, h);
1504
+ } else if (r instanceof Le)
1505
+ s(r.inner, r.prec);
1506
+ else if (r instanceof L)
1507
+ n[h].push(r), r.provides && s(r.provides, h);
1508
+ else if (r instanceof K)
1509
+ n[h].push(r), r.facet.extensions && s(r.facet.extensions, B.default);
1510
+ else {
1511
+ let a = r.extension;
1512
+ if (!a)
1513
+ throw new Error(`Unrecognized extension value in extension set (${r}).`);
1514
+ if (a == r)
1515
+ throw new Error(`Unrecognized extension value in extension set (${r}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
1516
+ s(a, h);
1517
+ }
1518
+ }
1519
+ return s(l, B.default), n.reduce((r, h) => r.concat(h));
1520
+ }
1521
+ function $(l, e) {
1522
+ if (e & 1)
1523
+ return 2;
1524
+ let t = e >> 1, n = l.status[t];
1525
+ if (n == 4)
1526
+ throw new Error("Cyclic dependency between fields and/or facets");
1527
+ if (n & 2)
1528
+ return n;
1529
+ l.status[t] = 4;
1530
+ let i = l.computeSlot(l, l.config.dynamicSlots[t]);
1531
+ return l.status[t] = 2 | i;
1532
+ }
1533
+ function Y(l, e) {
1534
+ return e & 1 ? l.config.staticValues[e >> 1] : l.values[e >> 1];
1535
+ }
1536
+ const De = /* @__PURE__ */ A.define(), fe = /* @__PURE__ */ A.define({
1537
+ combine: (l) => l.some((e) => e),
1538
+ static: !0
1539
+ }), Ve = /* @__PURE__ */ A.define({
1540
+ combine: (l) => l.length ? l[0] : void 0,
1541
+ static: !0
1542
+ }), Ne = /* @__PURE__ */ A.define(), $e = /* @__PURE__ */ A.define(), qe = /* @__PURE__ */ A.define(), ze = /* @__PURE__ */ A.define({
1543
+ combine: (l) => l.length ? l[0] : !1
1544
+ });
1545
+ class U {
1546
+ /**
1547
+ @internal
1548
+ */
1549
+ constructor(e, t) {
1550
+ this.type = e, this.value = t;
1551
+ }
1552
+ /**
1553
+ Define a new type of annotation.
1554
+ */
1555
+ static define() {
1556
+ return new tt();
1557
+ }
1558
+ }
1559
+ class tt {
1560
+ /**
1561
+ Create an instance of this annotation.
1562
+ */
1563
+ of(e) {
1564
+ return new U(this, e);
1565
+ }
1566
+ }
1567
+ class nt {
1568
+ /**
1569
+ @internal
1570
+ */
1571
+ constructor(e) {
1572
+ this.map = e;
1573
+ }
1574
+ /**
1575
+ Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
1576
+ type.
1577
+ */
1578
+ of(e) {
1579
+ return new I(this, e);
1580
+ }
1581
+ }
1582
+ class I {
1583
+ /**
1584
+ @internal
1585
+ */
1586
+ constructor(e, t) {
1587
+ this.type = e, this.value = t;
1588
+ }
1589
+ /**
1590
+ Map this effect through a position mapping. Will return
1591
+ `undefined` when that ends up deleting the effect.
1592
+ */
1593
+ map(e) {
1594
+ let t = this.type.map(this.value, e);
1595
+ return t === void 0 ? void 0 : t == this.value ? this : new I(this.type, t);
1596
+ }
1597
+ /**
1598
+ Tells you whether this effect object is of a given
1599
+ [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
1600
+ */
1601
+ is(e) {
1602
+ return this.type == e;
1603
+ }
1604
+ /**
1605
+ Define a new effect type. The type parameter indicates the type
1606
+ of values that his effect holds. It should be a type that
1607
+ doesn't include `undefined`, since that is used in
1608
+ [mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is
1609
+ removed.
1610
+ */
1611
+ static define(e = {}) {
1612
+ return new nt(e.map || ((t) => t));
1613
+ }
1614
+ /**
1615
+ Map an array of effects through a change set.
1616
+ */
1617
+ static mapEffects(e, t) {
1618
+ if (!e.length)
1619
+ return e;
1620
+ let n = [];
1621
+ for (let i of e) {
1622
+ let s = i.map(t);
1623
+ s && n.push(s);
1624
+ }
1625
+ return n;
1626
+ }
1627
+ }
1628
+ I.reconfigure = /* @__PURE__ */ I.define();
1629
+ I.appendConfig = /* @__PURE__ */ I.define();
1630
+ class P {
1631
+ constructor(e, t, n, i, s, r) {
1632
+ this.startState = e, this.changes = t, this.selection = n, this.effects = i, this.annotations = s, this.scrollIntoView = r, this._doc = null, this._state = null, n && Je(n, t.newLength), s.some((h) => h.type == P.time) || (this.annotations = s.concat(P.time.of(Date.now())));
1633
+ }
1634
+ /**
1635
+ @internal
1636
+ */
1637
+ static create(e, t, n, i, s, r) {
1638
+ return new P(e, t, n, i, s, r);
1639
+ }
1640
+ /**
1641
+ The new document produced by the transaction. Contrary to
1642
+ [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
1643
+ force the entire new state to be computed right away, so it is
1644
+ recommended that [transaction
1645
+ filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
1646
+ when they need to look at the new document.
1647
+ */
1648
+ get newDoc() {
1649
+ return this._doc || (this._doc = this.changes.apply(this.startState.doc));
1650
+ }
1651
+ /**
1652
+ The new selection produced by the transaction. If
1653
+ [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
1654
+ this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
1655
+ current selection through the changes made by the transaction.
1656
+ */
1657
+ get newSelection() {
1658
+ return this.selection || this.startState.selection.map(this.changes);
1659
+ }
1660
+ /**
1661
+ The new state created by the transaction. Computed on demand
1662
+ (but retained for subsequent access), so it is recommended not to
1663
+ access it in [transaction
1664
+ filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
1665
+ */
1666
+ get state() {
1667
+ return this._state || this.startState.applyTransaction(this), this._state;
1668
+ }
1669
+ /**
1670
+ Get the value of the given annotation type, if any.
1671
+ */
1672
+ annotation(e) {
1673
+ for (let t of this.annotations)
1674
+ if (t.type == e)
1675
+ return t.value;
1676
+ }
1677
+ /**
1678
+ Indicates whether the transaction changed the document.
1679
+ */
1680
+ get docChanged() {
1681
+ return !this.changes.empty;
1682
+ }
1683
+ /**
1684
+ Indicates whether this transaction reconfigures the state
1685
+ (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
1686
+ with a top-level configuration
1687
+ [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
1688
+ */
1689
+ get reconfigured() {
1690
+ return this.startState.config != this.state.config;
1691
+ }
1692
+ /**
1693
+ Returns true if the transaction has a [user
1694
+ event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
1695
+ or more specific than `event`. For example, if the transaction
1696
+ has `"select.pointer"` as user event, `"select"` and
1697
+ `"select.pointer"` will match it.
1698
+ */
1699
+ isUserEvent(e) {
1700
+ let t = this.annotation(P.userEvent);
1701
+ return !!(t && (t == e || t.length > e.length && t.slice(0, e.length) == e && t[e.length] == "."));
1702
+ }
1703
+ }
1704
+ P.time = /* @__PURE__ */ U.define();
1705
+ P.userEvent = /* @__PURE__ */ U.define();
1706
+ P.addToHistory = /* @__PURE__ */ U.define();
1707
+ P.remote = /* @__PURE__ */ U.define();
1708
+ function it(l, e) {
1709
+ let t = [];
1710
+ for (let n = 0, i = 0; ; ) {
1711
+ let s, r;
1712
+ if (n < l.length && (i == e.length || e[i] >= l[n]))
1713
+ s = l[n++], r = l[n++];
1714
+ else if (i < e.length)
1715
+ s = e[i++], r = e[i++];
1716
+ else
1717
+ return t;
1718
+ !t.length || t[t.length - 1] < s ? t.push(s, r) : t[t.length - 1] < r && (t[t.length - 1] = r);
1719
+ }
1720
+ }
1721
+ function We(l, e, t) {
1722
+ var n;
1723
+ let i, s, r;
1724
+ return t ? (i = e.changes, s = k.empty(e.changes.length), r = l.changes.compose(e.changes)) : (i = e.changes.map(l.changes), s = l.changes.mapDesc(e.changes, !0), r = l.changes.compose(i)), {
1725
+ changes: r,
1726
+ selection: e.selection ? e.selection.map(s) : (n = l.selection) === null || n === void 0 ? void 0 : n.map(i),
1727
+ effects: I.mapEffects(l.effects, i).concat(I.mapEffects(e.effects, s)),
1728
+ annotations: l.annotations.length ? l.annotations.concat(e.annotations) : e.annotations,
1729
+ scrollIntoView: l.scrollIntoView || e.scrollIntoView
1730
+ };
1731
+ }
1732
+ function ce(l, e, t) {
1733
+ let n = e.selection, i = F(e.annotations);
1734
+ return e.userEvent && (i = i.concat(P.userEvent.of(e.userEvent))), {
1735
+ changes: e.changes instanceof k ? e.changes : k.of(e.changes || [], t, l.facet(Ve)),
1736
+ selection: n && (n instanceof p ? n : p.single(n.anchor, n.head)),
1737
+ effects: F(e.effects),
1738
+ annotations: i,
1739
+ scrollIntoView: !!e.scrollIntoView
1740
+ };
1741
+ }
1742
+ function Ue(l, e, t) {
1743
+ let n = ce(l, e.length ? e[0] : {}, l.doc.length);
1744
+ e.length && e[0].filter === !1 && (t = !1);
1745
+ for (let s = 1; s < e.length; s++) {
1746
+ e[s].filter === !1 && (t = !1);
1747
+ let r = !!e[s].sequential;
1748
+ n = We(n, ce(l, e[s], r ? n.changes.newLength : l.doc.length), r);
1749
+ }
1750
+ let i = P.create(l, n.changes, n.selection, n.effects, n.annotations, n.scrollIntoView);
1751
+ return rt(t ? st(i) : i);
1752
+ }
1753
+ function st(l) {
1754
+ let e = l.startState, t = !0;
1755
+ for (let i of e.facet(Ne)) {
1756
+ let s = i(l);
1757
+ if (s === !1) {
1758
+ t = !1;
1759
+ break;
1760
+ }
1761
+ Array.isArray(s) && (t = t === !0 ? s : it(t, s));
1762
+ }
1763
+ if (t !== !0) {
1764
+ let i, s;
1765
+ if (t === !1)
1766
+ s = l.changes.invertedDesc, i = k.empty(e.doc.length);
1767
+ else {
1768
+ let r = l.changes.filter(t);
1769
+ i = r.changes, s = r.filtered.mapDesc(r.changes).invertedDesc;
1770
+ }
1771
+ l = P.create(e, i, l.selection && l.selection.map(s), I.mapEffects(l.effects, s), l.annotations, l.scrollIntoView);
1772
+ }
1773
+ let n = e.facet($e);
1774
+ for (let i = n.length - 1; i >= 0; i--) {
1775
+ let s = n[i](l);
1776
+ s instanceof P ? l = s : Array.isArray(s) && s.length == 1 && s[0] instanceof P ? l = s[0] : l = Ue(e, F(s), !1);
1777
+ }
1778
+ return l;
1779
+ }
1780
+ function rt(l) {
1781
+ let e = l.startState, t = e.facet(qe), n = l;
1782
+ for (let i = t.length - 1; i >= 0; i--) {
1783
+ let s = t[i](l);
1784
+ s && Object.keys(s).length && (n = We(n, ce(e, s, l.changes.newLength), !0));
1785
+ }
1786
+ return n == l ? l : P.create(e, l.changes, l.selection, n.effects, n.annotations, n.scrollIntoView);
1787
+ }
1788
+ const lt = [];
1789
+ function F(l) {
1790
+ return l == null ? lt : Array.isArray(l) ? l : [l];
1791
+ }
1792
+ var T = /* @__PURE__ */ (function(l) {
1793
+ return l[l.Word = 0] = "Word", l[l.Space = 1] = "Space", l[l.Other = 2] = "Other", l;
1794
+ })(T || (T = {}));
1795
+ const ht = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
1796
+ let de;
1797
+ try {
1798
+ de = /* @__PURE__ */ new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
1799
+ } catch {
1800
+ }
1801
+ function ot(l) {
1802
+ if (de)
1803
+ return de.test(l);
1804
+ for (let e = 0; e < l.length; e++) {
1805
+ let t = l[e];
1806
+ if (/\w/.test(t) || t > "€" && (t.toUpperCase() != t.toLowerCase() || ht.test(t)))
1807
+ return !0;
1808
+ }
1809
+ return !1;
1810
+ }
1811
+ function at(l) {
1812
+ return (e) => {
1813
+ if (!/\S/.test(e))
1814
+ return T.Space;
1815
+ if (ot(e))
1816
+ return T.Word;
1817
+ for (let t = 0; t < l.length; t++)
1818
+ if (e.indexOf(l[t]) > -1)
1819
+ return T.Word;
1820
+ return T.Other;
1821
+ };
1822
+ }
1823
+ class w {
1824
+ constructor(e, t, n, i, s, r) {
1825
+ this.config = e, this.doc = t, this.selection = n, this.values = i, this.status = e.statusTemplate.slice(), this.computeSlot = s, r && (r._state = this);
1826
+ for (let h = 0; h < this.config.dynamicSlots.length; h++)
1827
+ $(this, h << 1);
1828
+ this.computeSlot = null;
1829
+ }
1830
+ field(e, t = !0) {
1831
+ let n = this.config.address[e.id];
1832
+ if (n == null) {
1833
+ if (t)
1834
+ throw new RangeError("Field is not present in this state");
1835
+ return;
1836
+ }
1837
+ return $(this, n), Y(this, n);
1838
+ }
1839
+ /**
1840
+ Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
1841
+ state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
1842
+ can be passed. Unless
1843
+ [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
1844
+ [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
1845
+ are assumed to start in the _current_ document (not the document
1846
+ produced by previous specs), and its
1847
+ [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
1848
+ [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
1849
+ to the document created by its _own_ changes. The resulting
1850
+ transaction contains the combined effect of all the different
1851
+ specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
1852
+ specs take precedence over earlier ones.
1853
+ */
1854
+ update(...e) {
1855
+ return Ue(this, e, !0);
1856
+ }
1857
+ /**
1858
+ @internal
1859
+ */
1860
+ applyTransaction(e) {
1861
+ let t = this.config, { base: n, compartments: i } = t;
1862
+ for (let h of e.effects)
1863
+ h.is(te.reconfigure) ? (t && (i = /* @__PURE__ */ new Map(), t.compartments.forEach((o, a) => i.set(a, o)), t = null), i.set(h.value.compartment, h.value.extension)) : h.is(I.reconfigure) ? (t = null, n = h.value) : h.is(I.appendConfig) && (t = null, n = F(n).concat(h.value));
1864
+ let s;
1865
+ t ? s = e.startState.values.slice() : (t = X.resolve(n, i, this), s = new w(t, this.doc, this.selection, t.dynamicSlots.map(() => null), (o, a) => a.reconfigure(o, this), null).values);
1866
+ let r = e.startState.facet(fe) ? e.newSelection : e.newSelection.asSingle();
1867
+ new w(t, e.newDoc, r, s, (h, o) => o.update(h, e), e);
1868
+ }
1869
+ /**
1870
+ Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
1871
+ replaces every selection range with the given content.
1872
+ */
1873
+ replaceSelection(e) {
1874
+ return typeof e == "string" && (e = this.toText(e)), this.changeByRange((t) => ({
1875
+ changes: { from: t.from, to: t.to, insert: e },
1876
+ range: p.cursor(t.from + e.length)
1877
+ }));
1878
+ }
1879
+ /**
1880
+ Create a set of changes and a new selection by running the given
1881
+ function for each range in the active selection. The function
1882
+ can return an optional set of changes (in the coordinate space
1883
+ of the start document), plus an updated range (in the coordinate
1884
+ space of the document produced by the call's own changes). This
1885
+ method will merge all the changes and ranges into a single
1886
+ changeset and selection, and return it as a [transaction
1887
+ spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
1888
+ [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
1889
+ */
1890
+ changeByRange(e) {
1891
+ let t = this.selection, n = e(t.ranges[0]), i = this.changes(n.changes), s = [n.range], r = F(n.effects);
1892
+ for (let h = 1; h < t.ranges.length; h++) {
1893
+ let o = e(t.ranges[h]), a = this.changes(o.changes), u = a.map(i);
1894
+ for (let d = 0; d < h; d++)
1895
+ s[d] = s[d].map(u);
1896
+ let f = i.mapDesc(a, !0);
1897
+ s.push(o.range.map(f)), i = i.compose(u), r = I.mapEffects(r, u).concat(I.mapEffects(F(o.effects), f));
1898
+ }
1899
+ return {
1900
+ changes: i,
1901
+ selection: p.create(s, t.mainIndex),
1902
+ effects: r
1903
+ };
1904
+ }
1905
+ /**
1906
+ Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
1907
+ description, taking the state's document length and line
1908
+ separator into account.
1909
+ */
1910
+ changes(e = []) {
1911
+ return e instanceof k ? e : k.of(e, this.doc.length, this.facet(w.lineSeparator));
1912
+ }
1913
+ /**
1914
+ Using the state's [line
1915
+ separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
1916
+ [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
1917
+ */
1918
+ toText(e) {
1919
+ return x.of(e.split(this.facet(w.lineSeparator) || le));
1920
+ }
1921
+ /**
1922
+ Return the given range of the document as a string.
1923
+ */
1924
+ sliceDoc(e = 0, t = this.doc.length) {
1925
+ return this.doc.sliceString(e, t, this.lineBreak);
1926
+ }
1927
+ /**
1928
+ Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
1929
+ */
1930
+ facet(e) {
1931
+ let t = this.config.address[e.id];
1932
+ return t == null ? e.default : ($(this, t), Y(this, t));
1933
+ }
1934
+ /**
1935
+ Convert this state to a JSON-serializable object. When custom
1936
+ fields should be serialized, you can pass them in as an object
1937
+ mapping property names (in the resulting object, which should
1938
+ not use `doc` or `selection`) to fields.
1939
+ */
1940
+ toJSON(e) {
1941
+ let t = {
1942
+ doc: this.sliceDoc(),
1943
+ selection: this.selection.toJSON()
1944
+ };
1945
+ if (e)
1946
+ for (let n in e) {
1947
+ let i = e[n];
1948
+ i instanceof L && this.config.address[i.id] != null && (t[n] = i.spec.toJSON(this.field(e[n]), this));
1949
+ }
1950
+ return t;
1951
+ }
1952
+ /**
1953
+ Deserialize a state from its JSON representation. When custom
1954
+ fields should be deserialized, pass the same object you passed
1955
+ to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
1956
+ third argument.
1957
+ */
1958
+ static fromJSON(e, t = {}, n) {
1959
+ if (!e || typeof e.doc != "string")
1960
+ throw new RangeError("Invalid JSON representation for EditorState");
1961
+ let i = [];
1962
+ if (n) {
1963
+ for (let s in n)
1964
+ if (Object.prototype.hasOwnProperty.call(e, s)) {
1965
+ let r = n[s], h = e[s];
1966
+ i.push(r.init((o) => r.spec.fromJSON(h, o)));
1967
+ }
1968
+ }
1969
+ return w.create({
1970
+ doc: e.doc,
1971
+ selection: p.fromJSON(e.selection),
1972
+ extensions: t.extensions ? i.concat([t.extensions]) : i
1973
+ });
1974
+ }
1975
+ /**
1976
+ Create a new state. You'll usually only need this when
1977
+ initializing an editor—updated states are created by applying
1978
+ transactions.
1979
+ */
1980
+ static create(e = {}) {
1981
+ let t = X.resolve(e.extensions || [], /* @__PURE__ */ new Map()), n = e.doc instanceof x ? e.doc : x.of((e.doc || "").split(t.staticFacet(w.lineSeparator) || le)), i = e.selection ? e.selection instanceof p ? e.selection : p.single(e.selection.anchor, e.selection.head) : p.single(0);
1982
+ return Je(i, n.length), t.staticFacet(fe) || (i = i.asSingle()), new w(t, n, i, t.dynamicSlots.map(() => null), (s, r) => r.create(s), null);
1983
+ }
1984
+ /**
1985
+ The size (in columns) of a tab in the document, determined by
1986
+ the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
1987
+ */
1988
+ get tabSize() {
1989
+ return this.facet(w.tabSize);
1990
+ }
1991
+ /**
1992
+ Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
1993
+ string for this state.
1994
+ */
1995
+ get lineBreak() {
1996
+ return this.facet(w.lineSeparator) || `
1997
+ `;
1998
+ }
1999
+ /**
2000
+ Returns true when the editor is
2001
+ [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
2002
+ */
2003
+ get readOnly() {
2004
+ return this.facet(ze);
2005
+ }
2006
+ /**
2007
+ Look up a translation for the given phrase (via the
2008
+ [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
2009
+ original string if no translation is found.
2010
+
2011
+ If additional arguments are passed, they will be inserted in
2012
+ place of markers like `$1` (for the first value) and `$2`, etc.
2013
+ A single `$` is equivalent to `$1`, and `$$` will produce a
2014
+ literal dollar sign.
2015
+ */
2016
+ phrase(e, ...t) {
2017
+ for (let n of this.facet(w.phrases))
2018
+ if (Object.prototype.hasOwnProperty.call(n, e)) {
2019
+ e = n[e];
2020
+ break;
2021
+ }
2022
+ return t.length && (e = e.replace(/\$(\$|\d*)/g, (n, i) => {
2023
+ if (i == "$")
2024
+ return "$";
2025
+ let s = +(i || 1);
2026
+ return !s || s > t.length ? n : t[s - 1];
2027
+ })), e;
2028
+ }
2029
+ /**
2030
+ Find the values for a given language data field, provided by the
2031
+ the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
2032
+
2033
+ Examples of language data fields are...
2034
+
2035
+ - [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
2036
+ comment syntax.
2037
+ - [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
2038
+ for providing language-specific completion sources.
2039
+ - [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
2040
+ characters that should be considered part of words in this
2041
+ language.
2042
+ - [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
2043
+ bracket closing behavior.
2044
+ */
2045
+ languageDataAt(e, t, n = -1) {
2046
+ let i = [];
2047
+ for (let s of this.facet(De))
2048
+ for (let r of s(this, t, n))
2049
+ Object.prototype.hasOwnProperty.call(r, e) && i.push(r[e]);
2050
+ return i;
2051
+ }
2052
+ /**
2053
+ Return a function that can categorize strings (expected to
2054
+ represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
2055
+ into one of:
2056
+
2057
+ - Word (contains an alphanumeric character or a character
2058
+ explicitly listed in the local language's `"wordChars"`
2059
+ language data, which should be a string)
2060
+ - Space (contains only whitespace)
2061
+ - Other (anything else)
2062
+ */
2063
+ charCategorizer(e) {
2064
+ let t = this.languageDataAt("wordChars", e);
2065
+ return at(t.length ? t[0] : "");
2066
+ }
2067
+ /**
2068
+ Find the word at the given position, meaning the range
2069
+ containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
2070
+ around it. If no word characters are adjacent to the position,
2071
+ this returns null.
2072
+ */
2073
+ wordAt(e) {
2074
+ let { text: t, from: n, length: i } = this.doc.lineAt(e), s = this.charCategorizer(e), r = e - n, h = e - n;
2075
+ for (; r > 0; ) {
2076
+ let o = Q(t, r, !1);
2077
+ if (s(t.slice(o, r)) != T.Word)
2078
+ break;
2079
+ r = o;
2080
+ }
2081
+ for (; h < i; ) {
2082
+ let o = Q(t, h);
2083
+ if (s(t.slice(h, o)) != T.Word)
2084
+ break;
2085
+ h = o;
2086
+ }
2087
+ return r == h ? null : p.range(r + n, h + n);
2088
+ }
2089
+ }
2090
+ w.allowMultipleSelections = fe;
2091
+ w.tabSize = /* @__PURE__ */ A.define({
2092
+ combine: (l) => l.length ? l[0] : 4
2093
+ });
2094
+ w.lineSeparator = Ve;
2095
+ w.readOnly = ze;
2096
+ w.phrases = /* @__PURE__ */ A.define({
2097
+ compare(l, e) {
2098
+ let t = Object.keys(l), n = Object.keys(e);
2099
+ return t.length == n.length && t.every((i) => l[i] == e[i]);
2100
+ }
2101
+ });
2102
+ w.languageData = De;
2103
+ w.changeFilter = Ne;
2104
+ w.transactionFilter = $e;
2105
+ w.transactionExtender = qe;
2106
+ te.reconfigure = /* @__PURE__ */ I.define();
2107
+ function pt(l, e, t = {}) {
2108
+ let n = {};
2109
+ for (let i of l)
2110
+ for (let s of Object.keys(i)) {
2111
+ let r = i[s], h = n[s];
2112
+ if (h === void 0)
2113
+ n[s] = r;
2114
+ else if (!(h === r || r === void 0)) if (Object.hasOwnProperty.call(t, s))
2115
+ n[s] = t[s](h, r);
2116
+ else
2117
+ throw new Error("Config merge conflict for field " + s);
2118
+ }
2119
+ for (let i in e)
2120
+ n[i] === void 0 && (n[i] = e[i]);
2121
+ return n;
2122
+ }
2123
+ class _ {
2124
+ /**
2125
+ Compare this value with another value. Used when comparing
2126
+ rangesets. The default implementation compares by identity.
2127
+ Unless you are only creating a fixed number of unique instances
2128
+ of your value type, it is a good idea to implement this
2129
+ properly.
2130
+ */
2131
+ eq(e) {
2132
+ return this == e;
2133
+ }
2134
+ /**
2135
+ Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
2136
+ */
2137
+ range(e, t = e) {
2138
+ return z.create(e, t, this);
2139
+ }
2140
+ }
2141
+ _.prototype.startSide = _.prototype.endSide = 0;
2142
+ _.prototype.point = !1;
2143
+ _.prototype.mapMode = O.TrackDel;
2144
+ function ve(l, e) {
2145
+ return l == e || l.constructor == e.constructor && l.eq(e);
2146
+ }
2147
+ class z {
2148
+ constructor(e, t, n) {
2149
+ this.from = e, this.to = t, this.value = n;
2150
+ }
2151
+ /**
2152
+ @internal
2153
+ */
2154
+ static create(e, t, n) {
2155
+ return new z(e, t, n);
2156
+ }
2157
+ }
2158
+ function ge(l, e) {
2159
+ return l.from - e.from || l.value.startSide - e.value.startSide;
2160
+ }
2161
+ class xe {
2162
+ constructor(e, t, n, i) {
2163
+ this.from = e, this.to = t, this.value = n, this.maxPoint = i;
2164
+ }
2165
+ get length() {
2166
+ return this.to[this.to.length - 1];
2167
+ }
2168
+ // Find the index of the given position and side. Use the ranges'
2169
+ // `from` pos when `end == false`, `to` when `end == true`.
2170
+ findIndex(e, t, n, i = 0) {
2171
+ let s = n ? this.to : this.from;
2172
+ for (let r = i, h = s.length; ; ) {
2173
+ if (r == h)
2174
+ return r;
2175
+ let o = r + h >> 1, a = s[o] - e || (n ? this.value[o].endSide : this.value[o].startSide) - t;
2176
+ if (o == r)
2177
+ return a >= 0 ? r : h;
2178
+ a >= 0 ? h = o : r = o + 1;
2179
+ }
2180
+ }
2181
+ between(e, t, n, i) {
2182
+ for (let s = this.findIndex(t, -1e9, !0), r = this.findIndex(n, 1e9, !1, s); s < r; s++)
2183
+ if (i(this.from[s] + e, this.to[s] + e, this.value[s]) === !1)
2184
+ return !1;
2185
+ }
2186
+ map(e, t) {
2187
+ let n = [], i = [], s = [], r = -1, h = -1;
2188
+ for (let o = 0; o < this.value.length; o++) {
2189
+ let a = this.value[o], u = this.from[o] + e, f = this.to[o] + e, d, c;
2190
+ if (u == f) {
2191
+ let g = t.mapPos(u, a.startSide, a.mapMode);
2192
+ if (g == null || (d = c = g, a.startSide != a.endSide && (c = t.mapPos(u, a.endSide), c < d)))
2193
+ continue;
2194
+ } else if (d = t.mapPos(u, a.startSide), c = t.mapPos(f, a.endSide), d > c || d == c && a.startSide > 0 && a.endSide <= 0)
2195
+ continue;
2196
+ (c - d || a.endSide - a.startSide) < 0 || (r < 0 && (r = d), a.point && (h = Math.max(h, c - d)), n.push(a), i.push(d - r), s.push(c - r));
2197
+ }
2198
+ return { mapped: n.length ? new xe(i, s, n, h) : null, pos: r };
2199
+ }
2200
+ }
2201
+ class S {
2202
+ constructor(e, t, n, i) {
2203
+ this.chunkPos = e, this.chunk = t, this.nextLayer = n, this.maxPoint = i;
2204
+ }
2205
+ /**
2206
+ @internal
2207
+ */
2208
+ static create(e, t, n, i) {
2209
+ return new S(e, t, n, i);
2210
+ }
2211
+ /**
2212
+ @internal
2213
+ */
2214
+ get length() {
2215
+ let e = this.chunk.length - 1;
2216
+ return e < 0 ? 0 : Math.max(this.chunkEnd(e), this.nextLayer.length);
2217
+ }
2218
+ /**
2219
+ The number of ranges in the set.
2220
+ */
2221
+ get size() {
2222
+ if (this.isEmpty)
2223
+ return 0;
2224
+ let e = this.nextLayer.size;
2225
+ for (let t of this.chunk)
2226
+ e += t.value.length;
2227
+ return e;
2228
+ }
2229
+ /**
2230
+ @internal
2231
+ */
2232
+ chunkEnd(e) {
2233
+ return this.chunkPos[e] + this.chunk[e].length;
2234
+ }
2235
+ /**
2236
+ Update the range set, optionally adding new ranges or filtering
2237
+ out existing ones.
2238
+
2239
+ (Note: The type parameter is just there as a kludge to work
2240
+ around TypeScript variance issues that prevented `RangeSet<X>`
2241
+ from being a subtype of `RangeSet<Y>` when `X` is a subtype of
2242
+ `Y`.)
2243
+ */
2244
+ update(e) {
2245
+ let { add: t = [], sort: n = !1, filterFrom: i = 0, filterTo: s = this.length } = e, r = e.filter;
2246
+ if (t.length == 0 && !r)
2247
+ return this;
2248
+ if (n && (t = t.slice().sort(ge)), this.isEmpty)
2249
+ return t.length ? S.of(t) : this;
2250
+ let h = new He(this, null, -1).goto(0), o = 0, a = [], u = new ee();
2251
+ for (; h.value || o < t.length; )
2252
+ if (o < t.length && (h.from - t[o].from || h.startSide - t[o].value.startSide) >= 0) {
2253
+ let f = t[o++];
2254
+ u.addInner(f.from, f.to, f.value) || a.push(f);
2255
+ } else h.rangeIndex == 1 && h.chunkIndex < this.chunk.length && (o == t.length || this.chunkEnd(h.chunkIndex) < t[o].from) && (!r || i > this.chunkEnd(h.chunkIndex) || s < this.chunkPos[h.chunkIndex]) && u.addChunk(this.chunkPos[h.chunkIndex], this.chunk[h.chunkIndex]) ? h.nextChunk() : ((!r || i > h.to || s < h.from || r(h.from, h.to, h.value)) && (u.addInner(h.from, h.to, h.value) || a.push(z.create(h.from, h.to, h.value))), h.next());
2256
+ return u.finishInner(this.nextLayer.isEmpty && !a.length ? S.empty : this.nextLayer.update({ add: a, filter: r, filterFrom: i, filterTo: s }));
2257
+ }
2258
+ /**
2259
+ Map this range set through a set of changes, return the new set.
2260
+ */
2261
+ map(e) {
2262
+ if (e.empty || this.isEmpty)
2263
+ return this;
2264
+ let t = [], n = [], i = -1;
2265
+ for (let r = 0; r < this.chunk.length; r++) {
2266
+ let h = this.chunkPos[r], o = this.chunk[r], a = e.touchesRange(h, h + o.length);
2267
+ if (a === !1)
2268
+ i = Math.max(i, o.maxPoint), t.push(o), n.push(e.mapPos(h));
2269
+ else if (a === !0) {
2270
+ let { mapped: u, pos: f } = o.map(h, e);
2271
+ u && (i = Math.max(i, u.maxPoint), t.push(u), n.push(f));
2272
+ }
2273
+ }
2274
+ let s = this.nextLayer.map(e);
2275
+ return t.length == 0 ? s : new S(n, t, s || S.empty, i);
2276
+ }
2277
+ /**
2278
+ Iterate over the ranges that touch the region `from` to `to`,
2279
+ calling `f` for each. There is no guarantee that the ranges will
2280
+ be reported in any specific order. When the callback returns
2281
+ `false`, iteration stops.
2282
+ */
2283
+ between(e, t, n) {
2284
+ if (!this.isEmpty) {
2285
+ for (let i = 0; i < this.chunk.length; i++) {
2286
+ let s = this.chunkPos[i], r = this.chunk[i];
2287
+ if (t >= s && e <= s + r.length && r.between(s, e - s, t - s, n) === !1)
2288
+ return;
2289
+ }
2290
+ this.nextLayer.between(e, t, n);
2291
+ }
2292
+ }
2293
+ /**
2294
+ Iterate over the ranges in this set, in order, including all
2295
+ ranges that end at or after `from`.
2296
+ */
2297
+ iter(e = 0) {
2298
+ return W.from([this]).goto(e);
2299
+ }
2300
+ /**
2301
+ @internal
2302
+ */
2303
+ get isEmpty() {
2304
+ return this.nextLayer == this;
2305
+ }
2306
+ /**
2307
+ Iterate over the ranges in a collection of sets, in order,
2308
+ starting from `from`.
2309
+ */
2310
+ static iter(e, t = 0) {
2311
+ return W.from(e).goto(t);
2312
+ }
2313
+ /**
2314
+ Iterate over two groups of sets, calling methods on `comparator`
2315
+ to notify it of possible differences.
2316
+ */
2317
+ static compare(e, t, n, i, s = -1) {
2318
+ let r = e.filter((f) => f.maxPoint > 0 || !f.isEmpty && f.maxPoint >= s), h = t.filter((f) => f.maxPoint > 0 || !f.isEmpty && f.maxPoint >= s), o = Ae(r, h, n), a = new V(r, o, s), u = new V(h, o, s);
2319
+ n.iterGaps((f, d, c) => be(a, f, u, d, c, i)), n.empty && n.length == 0 && be(a, 0, u, 0, 0, i);
2320
+ }
2321
+ /**
2322
+ Compare the contents of two groups of range sets, returning true
2323
+ if they are equivalent in the given range.
2324
+ */
2325
+ static eq(e, t, n = 0, i) {
2326
+ i == null && (i = 999999999);
2327
+ let s = e.filter((u) => !u.isEmpty && t.indexOf(u) < 0), r = t.filter((u) => !u.isEmpty && e.indexOf(u) < 0);
2328
+ if (s.length != r.length)
2329
+ return !1;
2330
+ if (!s.length)
2331
+ return !0;
2332
+ let h = Ae(s, r), o = new V(s, h, 0).goto(n), a = new V(r, h, 0).goto(n);
2333
+ for (; ; ) {
2334
+ if (o.to != a.to || !pe(o.active, a.active) || o.point && (!a.point || !ve(o.point, a.point)))
2335
+ return !1;
2336
+ if (o.to > i)
2337
+ return !0;
2338
+ o.next(), a.next();
2339
+ }
2340
+ }
2341
+ /**
2342
+ Iterate over a group of range sets at the same time, notifying
2343
+ the iterator about the ranges covering every given piece of
2344
+ content. Returns the open count (see
2345
+ [`SpanIterator.span`](https://codemirror.net/6/docs/ref/#state.SpanIterator.span)) at the end
2346
+ of the iteration.
2347
+ */
2348
+ static spans(e, t, n, i, s = -1) {
2349
+ let r = new V(e, null, s).goto(t), h = t, o = r.openStart;
2350
+ for (; ; ) {
2351
+ let a = Math.min(r.to, n);
2352
+ if (r.point) {
2353
+ let u = r.activeForPoint(r.to), f = r.pointFrom < t ? u.length + 1 : r.point.startSide < 0 ? u.length : Math.min(u.length, o);
2354
+ i.point(h, a, r.point, u, f, r.pointRank), o = Math.min(r.openEnd(a), u.length);
2355
+ } else a > h && (i.span(h, a, r.active, o), o = r.openEnd(a));
2356
+ if (r.to > n)
2357
+ return o + (r.point && r.to > n ? 1 : 0);
2358
+ h = r.to, r.next();
2359
+ }
2360
+ }
2361
+ /**
2362
+ Create a range set for the given range or array of ranges. By
2363
+ default, this expects the ranges to be _sorted_ (by start
2364
+ position and, if two start at the same position,
2365
+ `value.startSide`). You can pass `true` as second argument to
2366
+ cause the method to sort them.
2367
+ */
2368
+ static of(e, t = !1) {
2369
+ let n = new ee();
2370
+ for (let i of e instanceof z ? [e] : t ? ut(e) : e)
2371
+ n.add(i.from, i.to, i.value);
2372
+ return n.finish();
2373
+ }
2374
+ /**
2375
+ Join an array of range sets into a single set.
2376
+ */
2377
+ static join(e) {
2378
+ if (!e.length)
2379
+ return S.empty;
2380
+ let t = e[e.length - 1];
2381
+ for (let n = e.length - 2; n >= 0; n--)
2382
+ for (let i = e[n]; i != S.empty; i = i.nextLayer)
2383
+ t = new S(i.chunkPos, i.chunk, t, Math.max(i.maxPoint, t.maxPoint));
2384
+ return t;
2385
+ }
2386
+ }
2387
+ S.empty = /* @__PURE__ */ new S([], [], null, -1);
2388
+ function ut(l) {
2389
+ if (l.length > 1)
2390
+ for (let e = l[0], t = 1; t < l.length; t++) {
2391
+ let n = l[t];
2392
+ if (ge(e, n) > 0)
2393
+ return l.slice().sort(ge);
2394
+ e = n;
2395
+ }
2396
+ return l;
2397
+ }
2398
+ S.empty.nextLayer = S.empty;
2399
+ class ee {
2400
+ finishChunk(e) {
2401
+ this.chunks.push(new xe(this.from, this.to, this.value, this.maxPoint)), this.chunkPos.push(this.chunkStart), this.chunkStart = -1, this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint), this.maxPoint = -1, e && (this.from = [], this.to = [], this.value = []);
2402
+ }
2403
+ /**
2404
+ Create an empty builder.
2405
+ */
2406
+ constructor() {
2407
+ this.chunks = [], this.chunkPos = [], this.chunkStart = -1, this.last = null, this.lastFrom = -1e9, this.lastTo = -1e9, this.from = [], this.to = [], this.value = [], this.maxPoint = -1, this.setMaxPoint = -1, this.nextLayer = null;
2408
+ }
2409
+ /**
2410
+ Add a range. Ranges should be added in sorted (by `from` and
2411
+ `value.startSide`) order.
2412
+ */
2413
+ add(e, t, n) {
2414
+ this.addInner(e, t, n) || (this.nextLayer || (this.nextLayer = new ee())).add(e, t, n);
2415
+ }
2416
+ /**
2417
+ @internal
2418
+ */
2419
+ addInner(e, t, n) {
2420
+ let i = e - this.lastTo || n.startSide - this.last.endSide;
2421
+ if (i <= 0 && (e - this.lastFrom || n.startSide - this.last.startSide) < 0)
2422
+ throw new Error("Ranges must be added sorted by `from` position and `startSide`");
2423
+ return i < 0 ? !1 : (this.from.length == 250 && this.finishChunk(!0), this.chunkStart < 0 && (this.chunkStart = e), this.from.push(e - this.chunkStart), this.to.push(t - this.chunkStart), this.last = n, this.lastFrom = e, this.lastTo = t, this.value.push(n), n.point && (this.maxPoint = Math.max(this.maxPoint, t - e)), !0);
2424
+ }
2425
+ /**
2426
+ @internal
2427
+ */
2428
+ addChunk(e, t) {
2429
+ if ((e - this.lastTo || t.value[0].startSide - this.last.endSide) < 0)
2430
+ return !1;
2431
+ this.from.length && this.finishChunk(!0), this.setMaxPoint = Math.max(this.setMaxPoint, t.maxPoint), this.chunks.push(t), this.chunkPos.push(e);
2432
+ let n = t.value.length - 1;
2433
+ return this.last = t.value[n], this.lastFrom = t.from[n] + e, this.lastTo = t.to[n] + e, !0;
2434
+ }
2435
+ /**
2436
+ Finish the range set. Returns the new set. The builder can't be
2437
+ used anymore after this has been called.
2438
+ */
2439
+ finish() {
2440
+ return this.finishInner(S.empty);
2441
+ }
2442
+ /**
2443
+ @internal
2444
+ */
2445
+ finishInner(e) {
2446
+ if (this.from.length && this.finishChunk(!1), this.chunks.length == 0)
2447
+ return e;
2448
+ let t = S.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(e) : e, this.setMaxPoint);
2449
+ return this.from = null, t;
2450
+ }
2451
+ }
2452
+ function Ae(l, e, t) {
2453
+ let n = /* @__PURE__ */ new Map();
2454
+ for (let s of l)
2455
+ for (let r = 0; r < s.chunk.length; r++)
2456
+ s.chunk[r].maxPoint <= 0 && n.set(s.chunk[r], s.chunkPos[r]);
2457
+ let i = /* @__PURE__ */ new Set();
2458
+ for (let s of e)
2459
+ for (let r = 0; r < s.chunk.length; r++) {
2460
+ let h = n.get(s.chunk[r]);
2461
+ h != null && (t ? t.mapPos(h) : h) == s.chunkPos[r] && !t?.touchesRange(h, h + s.chunk[r].length) && i.add(s.chunk[r]);
2462
+ }
2463
+ return i;
2464
+ }
2465
+ class He {
2466
+ constructor(e, t, n, i = 0) {
2467
+ this.layer = e, this.skip = t, this.minPoint = n, this.rank = i;
2468
+ }
2469
+ get startSide() {
2470
+ return this.value ? this.value.startSide : 0;
2471
+ }
2472
+ get endSide() {
2473
+ return this.value ? this.value.endSide : 0;
2474
+ }
2475
+ goto(e, t = -1e9) {
2476
+ return this.chunkIndex = this.rangeIndex = 0, this.gotoInner(e, t, !1), this;
2477
+ }
2478
+ gotoInner(e, t, n) {
2479
+ for (; this.chunkIndex < this.layer.chunk.length; ) {
2480
+ let i = this.layer.chunk[this.chunkIndex];
2481
+ if (!(this.skip && this.skip.has(i) || this.layer.chunkEnd(this.chunkIndex) < e || i.maxPoint < this.minPoint))
2482
+ break;
2483
+ this.chunkIndex++, n = !1;
2484
+ }
2485
+ if (this.chunkIndex < this.layer.chunk.length) {
2486
+ let i = this.layer.chunk[this.chunkIndex].findIndex(e - this.layer.chunkPos[this.chunkIndex], t, !0);
2487
+ (!n || this.rangeIndex < i) && this.setRangeIndex(i);
2488
+ }
2489
+ this.next();
2490
+ }
2491
+ forward(e, t) {
2492
+ (this.to - e || this.endSide - t) < 0 && this.gotoInner(e, t, !0);
2493
+ }
2494
+ next() {
2495
+ for (; ; )
2496
+ if (this.chunkIndex == this.layer.chunk.length) {
2497
+ this.from = this.to = 1e9, this.value = null;
2498
+ break;
2499
+ } else {
2500
+ let e = this.layer.chunkPos[this.chunkIndex], t = this.layer.chunk[this.chunkIndex], n = e + t.from[this.rangeIndex];
2501
+ if (this.from = n, this.to = e + t.to[this.rangeIndex], this.value = t.value[this.rangeIndex], this.setRangeIndex(this.rangeIndex + 1), this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
2502
+ break;
2503
+ }
2504
+ }
2505
+ setRangeIndex(e) {
2506
+ if (e == this.layer.chunk[this.chunkIndex].value.length) {
2507
+ if (this.chunkIndex++, this.skip)
2508
+ for (; this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]); )
2509
+ this.chunkIndex++;
2510
+ this.rangeIndex = 0;
2511
+ } else
2512
+ this.rangeIndex = e;
2513
+ }
2514
+ nextChunk() {
2515
+ this.chunkIndex++, this.rangeIndex = 0, this.next();
2516
+ }
2517
+ compare(e) {
2518
+ return this.from - e.from || this.startSide - e.startSide || this.rank - e.rank || this.to - e.to || this.endSide - e.endSide;
2519
+ }
2520
+ }
2521
+ class W {
2522
+ constructor(e) {
2523
+ this.heap = e;
2524
+ }
2525
+ static from(e, t = null, n = -1) {
2526
+ let i = [];
2527
+ for (let s = 0; s < e.length; s++)
2528
+ for (let r = e[s]; !r.isEmpty; r = r.nextLayer)
2529
+ r.maxPoint >= n && i.push(new He(r, t, n, s));
2530
+ return i.length == 1 ? i[0] : new W(i);
2531
+ }
2532
+ get startSide() {
2533
+ return this.value ? this.value.startSide : 0;
2534
+ }
2535
+ goto(e, t = -1e9) {
2536
+ for (let n of this.heap)
2537
+ n.goto(e, t);
2538
+ for (let n = this.heap.length >> 1; n >= 0; n--)
2539
+ se(this.heap, n);
2540
+ return this.next(), this;
2541
+ }
2542
+ forward(e, t) {
2543
+ for (let n of this.heap)
2544
+ n.forward(e, t);
2545
+ for (let n = this.heap.length >> 1; n >= 0; n--)
2546
+ se(this.heap, n);
2547
+ (this.to - e || this.value.endSide - t) < 0 && this.next();
2548
+ }
2549
+ next() {
2550
+ if (this.heap.length == 0)
2551
+ this.from = this.to = 1e9, this.value = null, this.rank = -1;
2552
+ else {
2553
+ let e = this.heap[0];
2554
+ this.from = e.from, this.to = e.to, this.value = e.value, this.rank = e.rank, e.value && e.next(), se(this.heap, 0);
2555
+ }
2556
+ }
2557
+ }
2558
+ function se(l, e) {
2559
+ for (let t = l[e]; ; ) {
2560
+ let n = (e << 1) + 1;
2561
+ if (n >= l.length)
2562
+ break;
2563
+ let i = l[n];
2564
+ if (n + 1 < l.length && i.compare(l[n + 1]) >= 0 && (i = l[n + 1], n++), t.compare(i) < 0)
2565
+ break;
2566
+ l[n] = t, l[e] = i, e = n;
2567
+ }
2568
+ }
2569
+ class V {
2570
+ constructor(e, t, n) {
2571
+ this.minPoint = n, this.active = [], this.activeTo = [], this.activeRank = [], this.minActive = -1, this.point = null, this.pointFrom = 0, this.pointRank = 0, this.to = -1e9, this.endSide = 0, this.openStart = -1, this.cursor = W.from(e, t, n);
2572
+ }
2573
+ goto(e, t = -1e9) {
2574
+ return this.cursor.goto(e, t), this.active.length = this.activeTo.length = this.activeRank.length = 0, this.minActive = -1, this.to = e, this.endSide = t, this.openStart = -1, this.next(), this;
2575
+ }
2576
+ forward(e, t) {
2577
+ for (; this.minActive > -1 && (this.activeTo[this.minActive] - e || this.active[this.minActive].endSide - t) < 0; )
2578
+ this.removeActive(this.minActive);
2579
+ this.cursor.forward(e, t);
2580
+ }
2581
+ removeActive(e) {
2582
+ G(this.active, e), G(this.activeTo, e), G(this.activeRank, e), this.minActive = Ce(this.active, this.activeTo);
2583
+ }
2584
+ addActive(e) {
2585
+ let t = 0, { value: n, to: i, rank: s } = this.cursor;
2586
+ for (; t < this.activeRank.length && (s - this.activeRank[t] || i - this.activeTo[t]) > 0; )
2587
+ t++;
2588
+ j(this.active, t, n), j(this.activeTo, t, i), j(this.activeRank, t, s), e && j(e, t, this.cursor.from), this.minActive = Ce(this.active, this.activeTo);
2589
+ }
2590
+ // After calling this, if `this.point` != null, the next range is a
2591
+ // point. Otherwise, it's a regular range, covered by `this.active`.
2592
+ next() {
2593
+ let e = this.to, t = this.point;
2594
+ this.point = null;
2595
+ let n = this.openStart < 0 ? [] : null;
2596
+ for (; ; ) {
2597
+ let i = this.minActive;
2598
+ if (i > -1 && (this.activeTo[i] - this.cursor.from || this.active[i].endSide - this.cursor.startSide) < 0) {
2599
+ if (this.activeTo[i] > e) {
2600
+ this.to = this.activeTo[i], this.endSide = this.active[i].endSide;
2601
+ break;
2602
+ }
2603
+ this.removeActive(i), n && G(n, i);
2604
+ } else if (this.cursor.value)
2605
+ if (this.cursor.from > e) {
2606
+ this.to = this.cursor.from, this.endSide = this.cursor.startSide;
2607
+ break;
2608
+ } else {
2609
+ let s = this.cursor.value;
2610
+ if (!s.point)
2611
+ this.addActive(n), this.cursor.next();
2612
+ else if (t && this.cursor.to == this.to && this.cursor.from < this.cursor.to)
2613
+ this.cursor.next();
2614
+ else {
2615
+ this.point = s, this.pointFrom = this.cursor.from, this.pointRank = this.cursor.rank, this.to = this.cursor.to, this.endSide = s.endSide, this.cursor.next(), this.forward(this.to, this.endSide);
2616
+ break;
2617
+ }
2618
+ }
2619
+ else {
2620
+ this.to = this.endSide = 1e9;
2621
+ break;
2622
+ }
2623
+ }
2624
+ if (n) {
2625
+ this.openStart = 0;
2626
+ for (let i = n.length - 1; i >= 0 && n[i] < e; i--)
2627
+ this.openStart++;
2628
+ }
2629
+ }
2630
+ activeForPoint(e) {
2631
+ if (!this.active.length)
2632
+ return this.active;
2633
+ let t = [];
2634
+ for (let n = this.active.length - 1; n >= 0 && !(this.activeRank[n] < this.pointRank); n--)
2635
+ (this.activeTo[n] > e || this.activeTo[n] == e && this.active[n].endSide >= this.point.endSide) && t.push(this.active[n]);
2636
+ return t.reverse();
2637
+ }
2638
+ openEnd(e) {
2639
+ let t = 0;
2640
+ for (let n = this.activeTo.length - 1; n >= 0 && this.activeTo[n] > e; n--)
2641
+ t++;
2642
+ return t;
2643
+ }
2644
+ }
2645
+ function be(l, e, t, n, i, s) {
2646
+ l.goto(e), t.goto(n);
2647
+ let r = n + i, h = n, o = n - e, a = !!s.boundChange;
2648
+ for (let u = !1; ; ) {
2649
+ let f = l.to + o - t.to, d = f || l.endSide - t.endSide, c = d < 0 ? l.to + o : t.to, g = Math.min(c, r);
2650
+ if (l.point || t.point ? (l.point && t.point && ve(l.point, t.point) && pe(l.activeForPoint(l.to), t.activeForPoint(t.to)) || s.comparePoint(h, g, l.point, t.point), u = !1) : (u && s.boundChange(h), g > h && !pe(l.active, t.active) && s.compareRange(h, g, l.active, t.active), a && g < r && (f || l.openEnd(c) != t.openEnd(c)) && (u = !0)), c > r)
2651
+ break;
2652
+ h = c, d <= 0 && l.next(), d >= 0 && t.next();
2653
+ }
2654
+ }
2655
+ function pe(l, e) {
2656
+ if (l.length != e.length)
2657
+ return !1;
2658
+ for (let t = 0; t < l.length; t++)
2659
+ if (l[t] != e[t] && !ve(l[t], e[t]))
2660
+ return !1;
2661
+ return !0;
2662
+ }
2663
+ function G(l, e) {
2664
+ for (let t = e, n = l.length - 1; t < n; t++)
2665
+ l[t] = l[t + 1];
2666
+ l.pop();
2667
+ }
2668
+ function j(l, e, t) {
2669
+ for (let n = l.length - 1; n >= e; n--)
2670
+ l[n + 1] = l[n];
2671
+ l[e] = t;
2672
+ }
2673
+ function Ce(l, e) {
2674
+ let t = -1, n = 1e9;
2675
+ for (let i = 0; i < e.length; i++)
2676
+ (e[i] - n || l[i].endSide - l[t].endSide) < 0 && (t = i, n = e[i]);
2677
+ return t;
2678
+ }
2679
+ function mt(l, e, t = l.length) {
2680
+ let n = 0;
2681
+ for (let i = 0; i < t && i < l.length; )
2682
+ l.charCodeAt(i) == 9 ? (n += e - n % e, i++) : (n++, i = Q(l, i));
2683
+ return n;
2684
+ }
2685
+ function wt(l, e, t, n) {
2686
+ for (let i = 0, s = 0; ; ) {
2687
+ if (s >= e)
2688
+ return i;
2689
+ if (i == l.length)
2690
+ break;
2691
+ s += l.charCodeAt(i) == 9 ? t - s % t : 1, i = Q(l, i);
2692
+ }
2693
+ return n === !0 ? -1 : l.length;
2694
+ }
2695
+ export {
2696
+ U as Annotation,
2697
+ tt as AnnotationType,
2698
+ E as ChangeDesc,
2699
+ k as ChangeSet,
2700
+ T as CharCategory,
2701
+ te as Compartment,
2702
+ p as EditorSelection,
2703
+ w as EditorState,
2704
+ A as Facet,
2705
+ Qe as Line,
2706
+ O as MapMode,
2707
+ gt as Prec,
2708
+ z as Range,
2709
+ S as RangeSet,
2710
+ ee as RangeSetBuilder,
2711
+ _ as RangeValue,
2712
+ M as SelectionRange,
2713
+ I as StateEffect,
2714
+ nt as StateEffectType,
2715
+ L as StateField,
2716
+ x as Text,
2717
+ P as Transaction,
2718
+ ft as codePointAt,
2719
+ dt as codePointSize,
2720
+ pt as combineConfig,
2721
+ mt as countColumn,
2722
+ Q as findClusterBreak,
2723
+ wt as findColumn,
2724
+ ct as fromCodePoint
2725
+ };