@drjoshcsimmons/scl 0.1.0 → 0.1.2

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