@marimo-team/islands 0.19.10-dev9 → 0.19.11-dev0

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 (94) hide show
  1. package/dist/Plot-C9vQQj4X.js +172249 -0
  2. package/dist/{any-language-editor-CKEbZakX.js → any-language-editor-t_VsTNa-.js} +16 -16
  3. package/dist/dist-4YNZxwMI.js +8 -0
  4. package/dist/dist-7nR3r2kG.js +5 -0
  5. package/dist/{dist-CBA36Nuy.js → dist-B2-r9y-0.js} +109 -109
  6. package/dist/dist-B2gkyT3r.js +5 -0
  7. package/dist/{dist-DRtGOCCq.js → dist-B4tYJP_i.js} +2 -2
  8. package/dist/{dist-C0e1aNzV.js → dist-B5ATpkxy.js} +2 -2
  9. package/dist/dist-B8G3I6vJ.js +8 -0
  10. package/dist/{dist-DKnxaCRl.js → dist-B94MxrQS.js} +2 -2
  11. package/dist/dist-BJ96Ykfp.js +8 -0
  12. package/dist/dist-BKLIWGw4.js +5 -0
  13. package/dist/{dist-l0KayR2-.js → dist-BLwfpZD-.js} +2 -2
  14. package/dist/{dist-CzKXtzDE.js → dist-BYmtF1W6.js} +2 -2
  15. package/dist/{dist-BJUs1DAG.js → dist-BbBnU4tG.js} +1 -1
  16. package/dist/dist-Bf3ou00A.js +6 -0
  17. package/dist/{dist-CITQGRtG.js → dist-BfactX3G.js} +4 -4
  18. package/dist/{dist-DiCjkKC2.js → dist-BoAHOW2l.js} +2 -2
  19. package/dist/{dist-BsBHh4jO.js → dist-Bsv_ARko.js} +4 -4
  20. package/dist/dist-BvkKXuPm.js +5 -0
  21. package/dist/{dist-DsqQCNKw.js → dist-C2-m5aEk.js} +119 -119
  22. package/dist/dist-C6NJ3n6r.js +5 -0
  23. package/dist/{dist-yI-ah_iK.js → dist-CC9VUnXd.js} +1 -1
  24. package/dist/{dist-tdABwZK5.js → dist-CE43BRmt.js} +1 -1
  25. package/dist/{dist-COp5dkis.js → dist-CJrHMxlI.js} +31 -31
  26. package/dist/{dist-Ct5hkOvC.js → dist-CPTE45iS.js} +1 -1
  27. package/dist/{dist-C-at-5cM.js → dist-CcOGT46m.js} +27 -27
  28. package/dist/dist-CecLPYY5.js +5 -0
  29. package/dist/{dist-BSMZYwqW.js → dist-Cgf353Ki.js} +1 -1
  30. package/dist/dist-Ch0SwRzK.js +5 -0
  31. package/dist/{dist-BqYNqP5W.js → dist-CkEUrAus.js} +2 -2
  32. package/dist/{dist-D4ObdSdT.js → dist-CmZYrgd_.js} +1 -1
  33. package/dist/{dist-D1q38GZb.js → dist-Crk9ejOy.js} +4 -4
  34. package/dist/dist-D6eWHiFh.js +6 -0
  35. package/dist/dist-DCQ710Bv.js +5 -0
  36. package/dist/{dist-r6N_0WG-.js → dist-DOil6y-3.js} +4 -4
  37. package/dist/{dist-CPd_adhw.js → dist-Dc1SFk5I.js} +2 -2
  38. package/dist/dist-Dit9tk8a.js +1242 -0
  39. package/dist/{dist-B7NoEgR4.js → dist-DqJdzAYM.js} +2 -2
  40. package/dist/dist-P_pkS5f-.js +8 -0
  41. package/dist/{dist-CsjsvW0K.js → dist-T4g7Sr6e.js} +3 -3
  42. package/dist/{dist-WETuLs_C.js → dist-glA_fIK_.js} +2 -2
  43. package/dist/{dist-bRBEzJF8.js → dist-iiugPhCC.js} +1 -1
  44. package/dist/{dist-D7jHtwN8.js → dist-r8ecBV-v.js} +135 -65
  45. package/dist/{dist-BlRm4v0e.js → dist-yVJ4xE5n.js} +5 -5
  46. package/dist/{esm-QY6C-Sev.js → esm-BAS2d2Ad.js} +1421 -1454
  47. package/dist/main.js +421 -383
  48. package/package.json +11 -11
  49. package/src/components/data-table/TableActions.tsx +8 -1
  50. package/src/components/data-table/data-table.tsx +2 -0
  51. package/src/components/data-table/download-actions.tsx +6 -1
  52. package/src/components/dependency-graph/dependency-graph-tree.tsx +10 -1
  53. package/src/components/dependency-graph/dependency-graph.tsx +1 -0
  54. package/src/components/dependency-graph/elements.ts +20 -9
  55. package/src/components/dependency-graph/panels.tsx +27 -11
  56. package/src/components/dependency-graph/types.ts +1 -0
  57. package/src/components/editor/chrome/wrapper/app-chrome.tsx +3 -0
  58. package/src/components/editor/package-alert.tsx +4 -4
  59. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +3 -5
  60. package/src/core/codemirror/misc/__tests__/paste.test.ts +18 -0
  61. package/src/core/codemirror/misc/paste.ts +14 -10
  62. package/src/core/kernel/messages.ts +1 -0
  63. package/src/core/static/static-state.ts +5 -0
  64. package/src/core/static/types.ts +2 -0
  65. package/src/core/wasm/__tests__/store.test.ts +33 -0
  66. package/src/core/wasm/bridge.ts +2 -1
  67. package/src/core/wasm/store.ts +13 -1
  68. package/src/mount.tsx +23 -1
  69. package/src/plugins/impl/DataTablePlugin.tsx +4 -0
  70. package/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx +7 -5
  71. package/src/plugins/impl/anywidget/__tests__/model.test.ts +53 -0
  72. package/src/plugins/impl/anywidget/model.ts +13 -10
  73. package/src/plugins/impl/chat/ChatPlugin.tsx +2 -0
  74. package/src/plugins/impl/chat/chat-ui.tsx +10 -1
  75. package/src/plugins/impl/data-frames/DataFramePlugin.tsx +4 -0
  76. package/src/plugins/impl/plotly/Plot.tsx +2 -0
  77. package/src/plugins/impl/plotly/PlotlyPlugin.tsx +36 -0
  78. package/src/theme/ThemeProvider.tsx +2 -0
  79. package/dist/Plot-CmsrWWji.js +0 -169233
  80. package/dist/dist-BKTAAusE.js +0 -5
  81. package/dist/dist-BNXv9Wjt.js +0 -6
  82. package/dist/dist-C-tlm9eD.js +0 -6
  83. package/dist/dist-CFi_P6cs.js +0 -5
  84. package/dist/dist-CgQuqOGS.js +0 -5
  85. package/dist/dist-CgkWmw0c.js +0 -5
  86. package/dist/dist-DGkeEIsV.js +0 -8
  87. package/dist/dist-DOwZz8aI.js +0 -5
  88. package/dist/dist-DRiJGkDN.js +0 -8
  89. package/dist/dist-GR6ABeNk.js +0 -8
  90. package/dist/dist-NcujbSeH.js +0 -8
  91. package/dist/dist-g1p2PEVs.js +0 -1242
  92. package/dist/dist-pNvwCQqJ.js +0 -5
  93. package/dist/dist-wudNDAiO.js +0 -5
  94. package/dist/dist-yK8yJfz2.js +0 -5
@@ -0,0 +1,1242 @@
1
+ import { $ as ViewPlugin, At as Prec, Bt as combineConfig, Et as EditorSelection, Ft as StateField, I as syntaxTree, It as Text, Lt as Transaction, Nt as RangeValue, Ot as Facet, Pt as StateEffect, Rt as codePointAt, Ut as fromCodePoint, X as Direction, Y as Decoration, Z as EditorView, at as getTooltip, dt as keymap, et as WidgetType, j as indentUnit, jt as RangeSet, kt as MapMode, pt as logException, wt as CharCategory, xt as Annotation, yt as showTooltip, zt as codePointSize } from "./dist-r8ecBV-v.js";
2
+ var CompletionContext = class {
3
+ constructor(i8, N, P, F) {
4
+ this.state = i8, this.pos = N, this.explicit = P, this.view = F, this.abortListeners = [], this.abortOnDocChange = false;
5
+ }
6
+ tokenBefore(i8) {
7
+ let N = syntaxTree(this.state).resolveInner(this.pos, -1);
8
+ for (; N && i8.indexOf(N.name) < 0; ) N = N.parent;
9
+ return N ? {
10
+ from: N.from,
11
+ to: this.pos,
12
+ text: this.state.sliceDoc(N.from, this.pos),
13
+ type: N.type
14
+ } : null;
15
+ }
16
+ matchBefore(i8) {
17
+ let N = this.state.doc.lineAt(this.pos), P = Math.max(N.from, this.pos - 250), F = N.text.slice(P - N.from, this.pos - N.from), I = F.search(ensureAnchor(i8, false));
18
+ return I < 0 ? null : {
19
+ from: P + I,
20
+ to: this.pos,
21
+ text: F.slice(I)
22
+ };
23
+ }
24
+ get aborted() {
25
+ return this.abortListeners == null;
26
+ }
27
+ addEventListener(i8, N, P) {
28
+ i8 == "abort" && this.abortListeners && (this.abortListeners.push(N), P && P.onDocChange && (this.abortOnDocChange = true));
29
+ }
30
+ };
31
+ function toSet(i8) {
32
+ let N = Object.keys(i8).join(""), P = /\w/.test(N);
33
+ return P && (N = N.replace(/\w/g, "")), `[${P ? "\\w" : ""}${N.replace(/[^\w\s]/g, "\\$&")}]`;
34
+ }
35
+ function prefixMatch(i8) {
36
+ let N = /* @__PURE__ */ Object.create(null), P = /* @__PURE__ */ Object.create(null);
37
+ for (let { label: F2 } of i8) {
38
+ N[F2[0]] = true;
39
+ for (let i9 = 1; i9 < F2.length; i9++) P[F2[i9]] = true;
40
+ }
41
+ let F = toSet(N) + toSet(P) + "*$";
42
+ return [/* @__PURE__ */ RegExp("^" + F), new RegExp(F)];
43
+ }
44
+ function completeFromList(i8) {
45
+ let N = i8.map((i9) => typeof i9 == "string" ? { label: i9 } : i9), [P, F] = N.every((i9) => /^\w+$/.test(i9.label)) ? [/\w*$/, /\w+$/] : prefixMatch(N);
46
+ return (i9) => {
47
+ let I = i9.matchBefore(F);
48
+ return I || i9.explicit ? {
49
+ from: I ? I.from : i9.pos,
50
+ options: N,
51
+ validFor: P
52
+ } : null;
53
+ };
54
+ }
55
+ function ifNotIn(i8, N) {
56
+ return (P) => {
57
+ for (let N2 = syntaxTree(P.state).resolveInner(P.pos, -1); N2; N2 = N2.parent) {
58
+ if (i8.indexOf(N2.name) > -1) return null;
59
+ if (N2.type.isTop) break;
60
+ }
61
+ return N(P);
62
+ };
63
+ }
64
+ var Option = class {
65
+ constructor(i8, N, P, F) {
66
+ this.completion = i8, this.source = N, this.match = P, this.score = F;
67
+ }
68
+ };
69
+ function cur(i8) {
70
+ return i8.selection.main.from;
71
+ }
72
+ function ensureAnchor(i8, N) {
73
+ let { source: P } = i8, F = N && P[0] != "^", I = P[P.length - 1] != "$";
74
+ return !F && !I ? i8 : RegExp(`${F ? "^" : ""}(?:${P})${I ? "$" : ""}`, i8.flags ?? (i8.ignoreCase ? "i" : ""));
75
+ }
76
+ var pickedCompletion = /* @__PURE__ */ Annotation.define();
77
+ function insertCompletionText(i8, N, P, I) {
78
+ let { main: L } = i8.selection, R = P - L.from, z = I - L.from;
79
+ return {
80
+ ...i8.changeByRange((B) => {
81
+ if (B != L && P != I && i8.sliceDoc(B.from + R, B.from + z) != i8.sliceDoc(P, I)) return { range: B };
82
+ let V = i8.toText(N);
83
+ return {
84
+ changes: {
85
+ from: B.from + R,
86
+ to: I == L.from ? B.to : B.from + z,
87
+ insert: V
88
+ },
89
+ range: EditorSelection.cursor(B.from + R + V.length)
90
+ };
91
+ }),
92
+ scrollIntoView: true,
93
+ userEvent: "input.complete"
94
+ };
95
+ }
96
+ var SourceCache = /* @__PURE__ */ new WeakMap();
97
+ function asSource(i8) {
98
+ if (!Array.isArray(i8)) return i8;
99
+ let N = SourceCache.get(i8);
100
+ return N || SourceCache.set(i8, N = completeFromList(i8)), N;
101
+ }
102
+ var startCompletionEffect = /* @__PURE__ */ StateEffect.define(), closeCompletionEffect = /* @__PURE__ */ StateEffect.define(), FuzzyMatcher = class {
103
+ constructor(i8) {
104
+ this.pattern = i8, this.chars = [], this.folded = [], this.any = [], this.precise = [], this.byWord = [], this.score = 0, this.matched = [];
105
+ for (let N = 0; N < i8.length; ) {
106
+ let P = codePointAt(i8, N), F = codePointSize(P);
107
+ this.chars.push(P);
108
+ let I = i8.slice(N, N + F), L = I.toUpperCase();
109
+ this.folded.push(codePointAt(L == I ? I.toLowerCase() : L, 0)), N += F;
110
+ }
111
+ this.astral = i8.length != this.chars.length;
112
+ }
113
+ ret(i8, N) {
114
+ return this.score = i8, this.matched = N, this;
115
+ }
116
+ match(i8) {
117
+ if (this.pattern.length == 0) return this.ret(-100, []);
118
+ if (i8.length < this.pattern.length) return null;
119
+ let { chars: N, folded: P, any: F, precise: I, byWord: L } = this;
120
+ if (N.length == 1) {
121
+ let F2 = codePointAt(i8, 0), I2 = codePointSize(F2), L2 = I2 == i8.length ? 0 : -100;
122
+ if (F2 != N[0]) if (F2 == P[0]) L2 += -200;
123
+ else return null;
124
+ return this.ret(L2, [0, I2]);
125
+ }
126
+ let R = i8.indexOf(this.pattern);
127
+ if (R == 0) return this.ret(i8.length == this.pattern.length ? 0 : -100, [0, this.pattern.length]);
128
+ let z = N.length, B = 0;
129
+ if (R < 0) {
130
+ for (let I2 = 0, L2 = Math.min(i8.length, 200); I2 < L2 && B < z; ) {
131
+ let L3 = codePointAt(i8, I2);
132
+ (L3 == N[B] || L3 == P[B]) && (F[B++] = I2), I2 += codePointSize(L3);
133
+ }
134
+ if (B < z) return null;
135
+ }
136
+ let V = 0, H = 0, G = false, K = 0, q = -1, J = -1, Y = /[a-z]/.test(i8), X = true;
137
+ for (let F2 = 0, B2 = Math.min(i8.length, 200), Z = 0; F2 < B2 && H < z; ) {
138
+ let B3 = codePointAt(i8, F2);
139
+ R < 0 && (V < z && B3 == N[V] && (I[V++] = F2), K < z && (B3 == N[K] || B3 == P[K] ? (K == 0 && (q = F2), J = F2 + 1, K++) : K = 0));
140
+ let Q, $ = B3 < 255 ? B3 >= 48 && B3 <= 57 || B3 >= 97 && B3 <= 122 ? 2 : B3 >= 65 && B3 <= 90 ? 1 : 0 : (Q = fromCodePoint(B3)) == Q.toLowerCase() ? Q == Q.toUpperCase() ? 0 : 2 : 1;
141
+ (!F2 || $ == 1 && Y || Z == 0 && $ != 0) && (N[H] == B3 || P[H] == B3 && (G = true) ? L[H++] = F2 : L.length && (X = false)), Z = $, F2 += codePointSize(B3);
142
+ }
143
+ return H == z && L[0] == 0 && X ? this.result(-100 + (G ? -200 : 0), L, i8) : K == z && q == 0 ? this.ret(-200 - i8.length + (J == i8.length ? 0 : -100), [0, J]) : R > -1 ? this.ret(-700 - i8.length, [R, R + this.pattern.length]) : K == z ? this.ret(-900 - i8.length, [q, J]) : H == z ? this.result(-100 + (G ? -200 : 0) + -700 + (X ? 0 : -1100), L, i8) : N.length == 2 ? null : this.result((F[0] ? -700 : 0) + -200 + -1100, F, i8);
144
+ }
145
+ result(i8, N, P) {
146
+ let F = [], I = 0;
147
+ for (let i9 of N) {
148
+ let N2 = i9 + (this.astral ? codePointSize(codePointAt(P, i9)) : 1);
149
+ I && F[I - 1] == i9 ? F[I - 1] = N2 : (F[I++] = i9, F[I++] = N2);
150
+ }
151
+ return this.ret(i8 - P.length, F);
152
+ }
153
+ }, StrictMatcher = class {
154
+ constructor(i8) {
155
+ this.pattern = i8, this.matched = [], this.score = 0, this.folded = i8.toLowerCase();
156
+ }
157
+ match(i8) {
158
+ if (i8.length < this.pattern.length) return null;
159
+ let N = i8.slice(0, this.pattern.length), P = N == this.pattern ? 0 : N.toLowerCase() == this.folded ? -200 : null;
160
+ return P == null ? null : (this.matched = [0, N.length], this.score = P + (i8.length == this.pattern.length ? 0 : -100), this);
161
+ }
162
+ }, completionConfig = /* @__PURE__ */ Facet.define({ combine(i8) {
163
+ return combineConfig(i8, {
164
+ activateOnTyping: true,
165
+ activateOnCompletion: () => false,
166
+ activateOnTypingDelay: 100,
167
+ selectOnOpen: true,
168
+ override: null,
169
+ closeOnBlur: true,
170
+ maxRenderedOptions: 100,
171
+ defaultKeymap: true,
172
+ tooltipClass: () => "",
173
+ optionClass: () => "",
174
+ aboveCursor: false,
175
+ icons: true,
176
+ addToOptions: [],
177
+ positionInfo: defaultPositionInfo,
178
+ filterStrict: false,
179
+ compareCompletions: (i9, N) => (i9.sortText || i9.label).localeCompare(N.sortText || N.label),
180
+ interactionDelay: 75,
181
+ updateSyncTime: 100
182
+ }, {
183
+ defaultKeymap: (i9, N) => i9 && N,
184
+ closeOnBlur: (i9, N) => i9 && N,
185
+ icons: (i9, N) => i9 && N,
186
+ tooltipClass: (i9, N) => (P) => joinClass(i9(P), N(P)),
187
+ optionClass: (i9, N) => (P) => joinClass(i9(P), N(P)),
188
+ addToOptions: (i9, N) => i9.concat(N),
189
+ filterStrict: (i9, N) => i9 || N
190
+ });
191
+ } });
192
+ function joinClass(i8, N) {
193
+ return i8 ? N ? i8 + " " + N : i8 : N;
194
+ }
195
+ function defaultPositionInfo(i8, N, P, F, I, L) {
196
+ let R = i8.textDirection == Direction.RTL, z = R, B = false, V = "top", H, U, W = N.left - I.left, K = I.right - N.right, q = F.right - F.left, J = F.bottom - F.top;
197
+ if (z && W < Math.min(q, K) ? z = false : !z && K < Math.min(q, W) && (z = true), q <= (z ? W : K)) H = Math.max(I.top, Math.min(P.top, I.bottom - J)) - N.top, U = Math.min(400, z ? W : K);
198
+ else {
199
+ B = true, U = Math.min(400, (R ? N.right : I.right - N.left) - 30);
200
+ let i9 = I.bottom - N.bottom;
201
+ i9 >= J || i9 > N.top ? H = P.bottom - N.top : (V = "bottom", H = N.bottom - P.top);
202
+ }
203
+ let Y = (N.bottom - N.top) / L.offsetHeight, X = (N.right - N.left) / L.offsetWidth;
204
+ return {
205
+ style: `${V}: ${H / Y}px; max-width: ${U / X}px`,
206
+ class: "cm-completionInfo-" + (B ? R ? "left-narrow" : "right-narrow" : z ? "left" : "right")
207
+ };
208
+ }
209
+ function optionContent(i8) {
210
+ let N = i8.addToOptions.slice();
211
+ return i8.icons && N.push({
212
+ render(i9) {
213
+ let N2 = document.createElement("div");
214
+ return N2.classList.add("cm-completionIcon"), i9.type && N2.classList.add(...i9.type.split(/\s+/g).map((i10) => "cm-completionIcon-" + i10)), N2.setAttribute("aria-hidden", "true"), N2;
215
+ },
216
+ position: 20
217
+ }), N.push({
218
+ render(i9, N2, P, F) {
219
+ let I = document.createElement("span");
220
+ I.className = "cm-completionLabel";
221
+ let L = i9.displayLabel || i9.label, R = 0;
222
+ for (let i10 = 0; i10 < F.length; ) {
223
+ let N3 = F[i10++], P2 = F[i10++];
224
+ N3 > R && I.appendChild(document.createTextNode(L.slice(R, N3)));
225
+ let z = I.appendChild(document.createElement("span"));
226
+ z.appendChild(document.createTextNode(L.slice(N3, P2))), z.className = "cm-completionMatchedText", R = P2;
227
+ }
228
+ return R < L.length && I.appendChild(document.createTextNode(L.slice(R))), I;
229
+ },
230
+ position: 50
231
+ }, {
232
+ render(i9) {
233
+ if (!i9.detail) return null;
234
+ let N2 = document.createElement("span");
235
+ return N2.className = "cm-completionDetail", N2.textContent = i9.detail, N2;
236
+ },
237
+ position: 80
238
+ }), N.sort((i9, N2) => i9.position - N2.position).map((i9) => i9.render);
239
+ }
240
+ function rangeAroundSelected(i8, N, P) {
241
+ if (i8 <= P) return {
242
+ from: 0,
243
+ to: i8
244
+ };
245
+ if (N < 0 && (N = 0), N <= i8 >> 1) {
246
+ let i9 = Math.floor(N / P);
247
+ return {
248
+ from: i9 * P,
249
+ to: (i9 + 1) * P
250
+ };
251
+ }
252
+ let F = Math.floor((i8 - N) / P);
253
+ return {
254
+ from: i8 - (F + 1) * P,
255
+ to: i8 - F * P
256
+ };
257
+ }
258
+ var CompletionTooltip = class {
259
+ constructor(i8, N, P) {
260
+ this.view = i8, this.stateField = N, this.applyCompletion = P, this.info = null, this.infoDestroy = null, this.placeInfoReq = {
261
+ read: () => this.measureInfo(),
262
+ write: (i9) => this.placeInfo(i9),
263
+ key: this
264
+ }, this.space = null, this.currentClass = "";
265
+ let F = i8.state.field(N), { options: I, selected: L } = F.open, R = i8.state.facet(completionConfig);
266
+ this.optionContent = optionContent(R), this.optionClass = R.optionClass, this.tooltipClass = R.tooltipClass, this.range = rangeAroundSelected(I.length, L, R.maxRenderedOptions), this.dom = document.createElement("div"), this.dom.className = "cm-tooltip-autocomplete", this.updateTooltipClass(i8.state), this.dom.addEventListener("mousedown", (P2) => {
267
+ let { options: F2 } = i8.state.field(N).open;
268
+ for (let N2 = P2.target, I2; N2 && N2 != this.dom; N2 = N2.parentNode) if (N2.nodeName == "LI" && (I2 = /-(\d+)$/.exec(N2.id)) && +I2[1] < F2.length) {
269
+ this.applyCompletion(i8, F2[+I2[1]]), P2.preventDefault();
270
+ return;
271
+ }
272
+ }), this.dom.addEventListener("focusout", (N2) => {
273
+ let P2 = i8.state.field(this.stateField, false);
274
+ P2 && P2.tooltip && i8.state.facet(completionConfig).closeOnBlur && N2.relatedTarget != i8.contentDOM && i8.dispatch({ effects: closeCompletionEffect.of(null) });
275
+ }), this.showOptions(I, F.id);
276
+ }
277
+ mount() {
278
+ this.updateSel();
279
+ }
280
+ showOptions(i8, N) {
281
+ this.list && this.list.remove(), this.list = this.dom.appendChild(this.createListBox(i8, N, this.range)), this.list.addEventListener("scroll", () => {
282
+ this.info && this.view.requestMeasure(this.placeInfoReq);
283
+ });
284
+ }
285
+ update(i8) {
286
+ var _a;
287
+ let N = i8.state.field(this.stateField), P = i8.startState.field(this.stateField);
288
+ if (this.updateTooltipClass(i8.state), N != P) {
289
+ let { options: F, selected: I, disabled: L } = N.open;
290
+ (!P.open || P.open.options != F) && (this.range = rangeAroundSelected(F.length, I, i8.state.facet(completionConfig).maxRenderedOptions), this.showOptions(F, N.id)), this.updateSel(), L != ((_a = P.open) == null ? void 0 : _a.disabled) && this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!L);
291
+ }
292
+ }
293
+ updateTooltipClass(i8) {
294
+ let N = this.tooltipClass(i8);
295
+ if (N != this.currentClass) {
296
+ for (let i9 of this.currentClass.split(" ")) i9 && this.dom.classList.remove(i9);
297
+ for (let i9 of N.split(" ")) i9 && this.dom.classList.add(i9);
298
+ this.currentClass = N;
299
+ }
300
+ }
301
+ positioned(i8) {
302
+ this.space = i8, this.info && this.view.requestMeasure(this.placeInfoReq);
303
+ }
304
+ updateSel() {
305
+ let i8 = this.view.state.field(this.stateField), N = i8.open;
306
+ (N.selected > -1 && N.selected < this.range.from || N.selected >= this.range.to) && (this.range = rangeAroundSelected(N.options.length, N.selected, this.view.state.facet(completionConfig).maxRenderedOptions), this.showOptions(N.options, i8.id));
307
+ let P = this.updateSelectedOption(N.selected);
308
+ if (P) {
309
+ this.destroyInfo();
310
+ let { completion: F } = N.options[N.selected], { info: I } = F;
311
+ if (!I) return;
312
+ let L = typeof I == "string" ? document.createTextNode(I) : I(F);
313
+ if (!L) return;
314
+ "then" in L ? L.then((N2) => {
315
+ N2 && this.view.state.field(this.stateField, false) == i8 && this.addInfoPane(N2, F);
316
+ }).catch((i9) => logException(this.view.state, i9, "completion info")) : (this.addInfoPane(L, F), P.setAttribute("aria-describedby", this.info.id));
317
+ }
318
+ }
319
+ addInfoPane(i8, N) {
320
+ this.destroyInfo();
321
+ let P = this.info = document.createElement("div");
322
+ if (P.className = "cm-tooltip cm-completionInfo", P.id = "cm-completionInfo-" + Math.floor(Math.random() * 65535).toString(16), i8.nodeType != null) P.appendChild(i8), this.infoDestroy = null;
323
+ else {
324
+ let { dom: N2, destroy: F } = i8;
325
+ P.appendChild(N2), this.infoDestroy = F || null;
326
+ }
327
+ this.dom.appendChild(P), this.view.requestMeasure(this.placeInfoReq);
328
+ }
329
+ updateSelectedOption(i8) {
330
+ let N = null;
331
+ for (let P = this.list.firstChild, F = this.range.from; P; P = P.nextSibling, F++) P.nodeName != "LI" || !P.id ? F-- : F == i8 ? P.hasAttribute("aria-selected") || (P.setAttribute("aria-selected", "true"), N = P) : P.hasAttribute("aria-selected") && (P.removeAttribute("aria-selected"), P.removeAttribute("aria-describedby"));
332
+ return N && scrollIntoView(this.list, N), N;
333
+ }
334
+ measureInfo() {
335
+ let i8 = this.dom.querySelector("[aria-selected]");
336
+ if (!i8 || !this.info) return null;
337
+ let N = this.dom.getBoundingClientRect(), P = this.info.getBoundingClientRect(), F = i8.getBoundingClientRect(), I = this.space;
338
+ if (!I) {
339
+ let i9 = this.dom.ownerDocument.documentElement;
340
+ I = {
341
+ left: 0,
342
+ top: 0,
343
+ right: i9.clientWidth,
344
+ bottom: i9.clientHeight
345
+ };
346
+ }
347
+ return F.top > Math.min(I.bottom, N.bottom) - 10 || F.bottom < Math.max(I.top, N.top) + 10 ? null : this.view.state.facet(completionConfig).positionInfo(this.view, N, F, P, I, this.dom);
348
+ }
349
+ placeInfo(i8) {
350
+ this.info && (i8 ? (i8.style && (this.info.style.cssText = i8.style), this.info.className = "cm-tooltip cm-completionInfo " + (i8.class || "")) : this.info.style.cssText = "top: -1e6px");
351
+ }
352
+ createListBox(i8, N, P) {
353
+ let F = document.createElement("ul");
354
+ F.id = N, F.setAttribute("role", "listbox"), F.setAttribute("aria-expanded", "true"), F.setAttribute("aria-label", this.view.state.phrase("Completions")), F.addEventListener("mousedown", (i9) => {
355
+ i9.target == F && i9.preventDefault();
356
+ });
357
+ let I = null;
358
+ for (let L = P.from; L < P.to; L++) {
359
+ let { completion: R, match: z } = i8[L], { section: B } = R;
360
+ if (B) {
361
+ let i9 = typeof B == "string" ? B : B.name;
362
+ if (i9 != I && (L > P.from || P.from == 0)) if (I = i9, typeof B != "string" && B.header) F.appendChild(B.header(B));
363
+ else {
364
+ let N2 = F.appendChild(document.createElement("completion-section"));
365
+ N2.textContent = i9;
366
+ }
367
+ }
368
+ let V = F.appendChild(document.createElement("li"));
369
+ V.id = N + "-" + L, V.setAttribute("role", "option");
370
+ let H = this.optionClass(R);
371
+ H && (V.className = H);
372
+ for (let i9 of this.optionContent) {
373
+ let N2 = i9(R, this.view.state, this.view, z);
374
+ N2 && V.appendChild(N2);
375
+ }
376
+ }
377
+ return P.from && F.classList.add("cm-completionListIncompleteTop"), P.to < i8.length && F.classList.add("cm-completionListIncompleteBottom"), F;
378
+ }
379
+ destroyInfo() {
380
+ this.info && (this.info = (this.infoDestroy && this.infoDestroy(), this.info.remove(), null));
381
+ }
382
+ destroy() {
383
+ this.destroyInfo();
384
+ }
385
+ };
386
+ function completionTooltip(i8, N) {
387
+ return (P) => new CompletionTooltip(P, i8, N);
388
+ }
389
+ function scrollIntoView(i8, N) {
390
+ let P = i8.getBoundingClientRect(), F = N.getBoundingClientRect(), I = P.height / i8.offsetHeight;
391
+ F.top < P.top ? i8.scrollTop -= (P.top - F.top) / I : F.bottom > P.bottom && (i8.scrollTop += (F.bottom - P.bottom) / I);
392
+ }
393
+ function score(i8) {
394
+ return (i8.boost || 0) * 100 + (i8.apply ? 10 : 0) + (i8.info ? 5 : 0) + (i8.type ? 1 : 0);
395
+ }
396
+ function sortOptions(i8, N) {
397
+ let P = [], F = null, I = null, L = (i9) => {
398
+ P.push(i9);
399
+ let { section: N2 } = i9.completion;
400
+ if (N2) {
401
+ F || (F = []);
402
+ let i10 = typeof N2 == "string" ? N2 : N2.name;
403
+ F.some((N3) => N3.name == i10) || F.push(typeof N2 == "string" ? { name: i10 } : N2);
404
+ }
405
+ }, R = N.facet(completionConfig);
406
+ for (let F2 of i8) if (F2.hasResult()) {
407
+ let i9 = F2.result.getMatch;
408
+ if (F2.result.filter === false) for (let N2 of F2.result.options) L(new Option(N2, F2.source, i9 ? i9(N2) : [], 1e9 - P.length));
409
+ else {
410
+ let P2 = N.sliceDoc(F2.from, F2.to), z2, B2 = R.filterStrict ? new StrictMatcher(P2) : new FuzzyMatcher(P2);
411
+ for (let N2 of F2.result.options) if (z2 = B2.match(N2.label)) {
412
+ let P3 = N2.displayLabel ? i9 ? i9(N2, z2.matched) : [] : z2.matched, R2 = z2.score + (N2.boost || 0);
413
+ if (L(new Option(N2, F2.source, P3, R2)), typeof N2.section == "object" && N2.section.rank === "dynamic") {
414
+ let { name: i10 } = N2.section;
415
+ I || (I = /* @__PURE__ */ Object.create(null)), I[i10] = Math.max(R2, I[i10] || -1e9);
416
+ }
417
+ }
418
+ }
419
+ }
420
+ if (F) {
421
+ let i9 = /* @__PURE__ */ Object.create(null), N2 = 0, L2 = (i10, N3) => (i10.rank === "dynamic" && N3.rank === "dynamic" ? I[N3.name] - I[i10.name] : 0) || (typeof i10.rank == "number" ? i10.rank : 1e9) - (typeof N3.rank == "number" ? N3.rank : 1e9) || (i10.name < N3.name ? -1 : 1);
422
+ for (let P2 of F.sort(L2)) N2 -= 1e5, i9[P2.name] = N2;
423
+ for (let N3 of P) {
424
+ let { section: P2 } = N3.completion;
425
+ P2 && (N3.score += i9[typeof P2 == "string" ? P2 : P2.name]);
426
+ }
427
+ }
428
+ let z = [], B = null, V = R.compareCompletions;
429
+ for (let i9 of P.sort((i10, N2) => N2.score - i10.score || V(i10.completion, N2.completion))) {
430
+ let N2 = i9.completion;
431
+ !B || B.label != N2.label || B.detail != N2.detail || B.type != null && N2.type != null && B.type != N2.type || B.apply != N2.apply || B.boost != N2.boost ? z.push(i9) : score(i9.completion) > score(B) && (z[z.length - 1] = i9), B = i9.completion;
432
+ }
433
+ return z;
434
+ }
435
+ var CompletionDialog = class i {
436
+ constructor(i8, N, P, F, I, L) {
437
+ this.options = i8, this.attrs = N, this.tooltip = P, this.timestamp = F, this.selected = I, this.disabled = L;
438
+ }
439
+ setSelected(N, P) {
440
+ return N == this.selected || N >= this.options.length ? this : new i(this.options, makeAttrs(P, N), this.tooltip, this.timestamp, N, this.disabled);
441
+ }
442
+ static build(N, P, F, I, L, R) {
443
+ if (I && !R && N.some((i8) => i8.isPending)) return I.setDisabled();
444
+ let z = sortOptions(N, P);
445
+ if (!z.length) return I && N.some((i8) => i8.isPending) ? I.setDisabled() : null;
446
+ let B = P.facet(completionConfig).selectOnOpen ? 0 : -1;
447
+ if (I && I.selected != B && I.selected != -1) {
448
+ let i8 = I.options[I.selected].completion;
449
+ for (let N2 = 0; N2 < z.length; N2++) if (z[N2].completion == i8) {
450
+ B = N2;
451
+ break;
452
+ }
453
+ }
454
+ return new i(z, makeAttrs(F, B), {
455
+ pos: N.reduce((i8, N2) => N2.hasResult() ? Math.min(i8, N2.from) : i8, 1e8),
456
+ create: createTooltip,
457
+ above: L.aboveCursor
458
+ }, I ? I.timestamp : Date.now(), B, false);
459
+ }
460
+ map(N) {
461
+ return new i(this.options, this.attrs, {
462
+ ...this.tooltip,
463
+ pos: N.mapPos(this.tooltip.pos)
464
+ }, this.timestamp, this.selected, this.disabled);
465
+ }
466
+ setDisabled() {
467
+ return new i(this.options, this.attrs, this.tooltip, this.timestamp, this.selected, true);
468
+ }
469
+ }, CompletionState = class i2 {
470
+ constructor(i8, N, P) {
471
+ this.active = i8, this.id = N, this.open = P;
472
+ }
473
+ static start() {
474
+ return new i2(none, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null);
475
+ }
476
+ update(N) {
477
+ let { state: P } = N, F = P.facet(completionConfig), I = (F.override || P.languageDataAt("autocomplete", cur(P)).map(asSource)).map((i8) => (this.active.find((N2) => N2.source == i8) || new ActiveSource(i8, this.active.some((i9) => i9.state != 0) ? 1 : 0)).update(N, F));
478
+ I.length == this.active.length && I.every((i8, N2) => i8 == this.active[N2]) && (I = this.active);
479
+ let L = this.open, R = N.effects.some((i8) => i8.is(setActiveEffect));
480
+ L && N.docChanged && (L = L.map(N.changes)), N.selection || I.some((i8) => i8.hasResult() && N.changes.touchesRange(i8.from, i8.to)) || !sameResults(I, this.active) || R ? L = CompletionDialog.build(I, P, this.id, L, F, R) : L && L.disabled && !I.some((i8) => i8.isPending) && (L = null), !L && I.every((i8) => !i8.isPending) && I.some((i8) => i8.hasResult()) && (I = I.map((i8) => i8.hasResult() ? new ActiveSource(i8.source, 0) : i8));
481
+ for (let i8 of N.effects) i8.is(setSelectedEffect) && (L && (L = L.setSelected(i8.value, this.id)));
482
+ return I == this.active && L == this.open ? this : new i2(I, this.id, L);
483
+ }
484
+ get tooltip() {
485
+ return this.open ? this.open.tooltip : null;
486
+ }
487
+ get attrs() {
488
+ return this.open ? this.open.attrs : this.active.length ? baseAttrs : noAttrs;
489
+ }
490
+ };
491
+ function sameResults(i8, N) {
492
+ if (i8 == N) return true;
493
+ for (let P = 0, F = 0; ; ) {
494
+ for (; P < i8.length && !i8[P].hasResult(); ) P++;
495
+ for (; F < N.length && !N[F].hasResult(); ) F++;
496
+ let I = P == i8.length, L = F == N.length;
497
+ if (I || L) return I == L;
498
+ if (i8[P++].result != N[F++].result) return false;
499
+ }
500
+ }
501
+ var baseAttrs = { "aria-autocomplete": "list" }, noAttrs = {};
502
+ function makeAttrs(i8, N) {
503
+ let P = {
504
+ "aria-autocomplete": "list",
505
+ "aria-haspopup": "listbox",
506
+ "aria-controls": i8
507
+ };
508
+ return N > -1 && (P["aria-activedescendant"] = i8 + "-" + N), P;
509
+ }
510
+ var none = [];
511
+ function getUpdateType(i8, N) {
512
+ if (i8.isUserEvent("input.complete")) {
513
+ let P2 = i8.annotation(pickedCompletion);
514
+ if (P2 && N.activateOnCompletion(P2)) return 12;
515
+ }
516
+ let P = i8.isUserEvent("input.type");
517
+ return P && N.activateOnTyping ? 5 : P ? 1 : i8.isUserEvent("delete.backward") ? 2 : i8.selection ? 8 : i8.docChanged ? 16 : 0;
518
+ }
519
+ var ActiveSource = class i3 {
520
+ constructor(i8, N, P = false) {
521
+ this.source = i8, this.state = N, this.explicit = P;
522
+ }
523
+ hasResult() {
524
+ return false;
525
+ }
526
+ get isPending() {
527
+ return this.state == 1;
528
+ }
529
+ update(N, P) {
530
+ let F = getUpdateType(N, P), I = this;
531
+ (F & 8 || F & 16 && this.touches(N)) && (I = new i3(I.source, 0)), F & 4 && I.state == 0 && (I = new i3(this.source, 1)), I = I.updateFor(N, F);
532
+ for (let P2 of N.effects) if (P2.is(startCompletionEffect)) I = new i3(I.source, 1, P2.value);
533
+ else if (P2.is(closeCompletionEffect)) I = new i3(I.source, 0);
534
+ else if (P2.is(setActiveEffect)) for (let i8 of P2.value) i8.source == I.source && (I = i8);
535
+ return I;
536
+ }
537
+ updateFor(i8, N) {
538
+ return this.map(i8.changes);
539
+ }
540
+ map(i8) {
541
+ return this;
542
+ }
543
+ touches(i8) {
544
+ return i8.changes.touchesRange(cur(i8.state));
545
+ }
546
+ }, ActiveResult = class i4 extends ActiveSource {
547
+ constructor(i8, N, P, F, I, L) {
548
+ super(i8, 3, N), this.limit = P, this.result = F, this.from = I, this.to = L;
549
+ }
550
+ hasResult() {
551
+ return true;
552
+ }
553
+ updateFor(N, P) {
554
+ if (!(P & 3)) return this.map(N.changes);
555
+ let F = this.result;
556
+ F.map && !N.changes.empty && (F = F.map(F, N.changes));
557
+ let I = N.changes.mapPos(this.from), L = N.changes.mapPos(this.to, 1), R = cur(N.state);
558
+ if (R > L || !F || P & 2 && (cur(N.startState) == this.from || R < this.limit)) return new ActiveSource(this.source, P & 4 ? 1 : 0);
559
+ let z = N.changes.mapPos(this.limit);
560
+ return checkValid(F.validFor, N.state, I, L) ? new i4(this.source, this.explicit, z, F, I, L) : F.update && (F = F.update(F, I, L, new CompletionContext(N.state, R, false))) ? new i4(this.source, this.explicit, z, F, F.from, F.to ?? cur(N.state)) : new ActiveSource(this.source, 1, this.explicit);
561
+ }
562
+ map(N) {
563
+ return N.empty ? this : (this.result.map ? this.result.map(this.result, N) : this.result) ? new i4(this.source, this.explicit, N.mapPos(this.limit), this.result, N.mapPos(this.from), N.mapPos(this.to, 1)) : new ActiveSource(this.source, 0);
564
+ }
565
+ touches(i8) {
566
+ return i8.changes.touchesRange(this.from, this.to);
567
+ }
568
+ };
569
+ function checkValid(i8, N, P, F) {
570
+ if (!i8) return false;
571
+ let I = N.sliceDoc(P, F);
572
+ return typeof i8 == "function" ? i8(I, P, F, N) : ensureAnchor(i8, true).test(I);
573
+ }
574
+ var setActiveEffect = /* @__PURE__ */ StateEffect.define({ map(i8, N) {
575
+ return i8.map((i9) => i9.map(N));
576
+ } }), setSelectedEffect = /* @__PURE__ */ StateEffect.define(), completionState = /* @__PURE__ */ StateField.define({
577
+ create() {
578
+ return CompletionState.start();
579
+ },
580
+ update(i8, N) {
581
+ return i8.update(N);
582
+ },
583
+ provide: (i8) => [showTooltip.from(i8, (i9) => i9.tooltip), EditorView.contentAttributes.from(i8, (i9) => i9.attrs)]
584
+ });
585
+ function applyCompletion(i8, N) {
586
+ let P = N.completion.apply || N.completion.label, F = i8.state.field(completionState).active.find((i9) => i9.source == N.source);
587
+ return F instanceof ActiveResult ? (typeof P == "string" ? i8.dispatch({
588
+ ...insertCompletionText(i8.state, P, F.from, F.to),
589
+ annotations: pickedCompletion.of(N.completion)
590
+ }) : P(i8, N.completion, F.from, F.to), true) : false;
591
+ }
592
+ var createTooltip = /* @__PURE__ */ completionTooltip(completionState, applyCompletion);
593
+ function moveCompletionSelection(i8, N = "option") {
594
+ return (P) => {
595
+ let F = P.state.field(completionState, false);
596
+ if (!F || !F.open || F.open.disabled || Date.now() - F.open.timestamp < P.state.facet(completionConfig).interactionDelay) return false;
597
+ let I = 1, L;
598
+ N == "page" && (L = getTooltip(P, F.open.tooltip)) && (I = Math.max(2, Math.floor(L.dom.offsetHeight / L.dom.querySelector("li").offsetHeight) - 1));
599
+ let { length: R } = F.open.options, z = F.open.selected > -1 ? F.open.selected + I * (i8 ? 1 : -1) : i8 ? 0 : R - 1;
600
+ return z < 0 ? z = N == "page" ? 0 : R - 1 : z >= R && (z = N == "page" ? R - 1 : 0), P.dispatch({ effects: setSelectedEffect.of(z) }), true;
601
+ };
602
+ }
603
+ var acceptCompletion = (i8) => {
604
+ let N = i8.state.field(completionState, false);
605
+ return i8.state.readOnly || !N || !N.open || N.open.selected < 0 || N.open.disabled || Date.now() - N.open.timestamp < i8.state.facet(completionConfig).interactionDelay ? false : applyCompletion(i8, N.open.options[N.open.selected]);
606
+ }, startCompletion = (i8) => i8.state.field(completionState, false) ? (i8.dispatch({ effects: startCompletionEffect.of(true) }), true) : false, closeCompletion = (i8) => {
607
+ let N = i8.state.field(completionState, false);
608
+ return !N || !N.active.some((i9) => i9.state != 0) ? false : (i8.dispatch({ effects: closeCompletionEffect.of(null) }), true);
609
+ }, RunningQuery = class {
610
+ constructor(i8, N) {
611
+ this.active = i8, this.context = N, this.time = Date.now(), this.updates = [], this.done = void 0;
612
+ }
613
+ }, MaxUpdateCount = 50, MinAbortTime = 1e3, completionPlugin = /* @__PURE__ */ ViewPlugin.fromClass(class {
614
+ constructor(i8) {
615
+ this.view = i8, this.debounceUpdate = -1, this.running = [], this.debounceAccept = -1, this.pendingStart = false, this.composing = 0;
616
+ for (let N of i8.state.field(completionState).active) N.isPending && this.startQuery(N);
617
+ }
618
+ update(i8) {
619
+ let N = i8.state.field(completionState), P = i8.state.facet(completionConfig);
620
+ if (!i8.selectionSet && !i8.docChanged && i8.startState.field(completionState) == N) return;
621
+ let F = i8.transactions.some((i9) => {
622
+ let N2 = getUpdateType(i9, P);
623
+ return N2 & 8 || (i9.selection || i9.docChanged) && !(N2 & 3);
624
+ });
625
+ for (let N2 = 0; N2 < this.running.length; N2++) {
626
+ let P2 = this.running[N2];
627
+ if (F || P2.context.abortOnDocChange && i8.docChanged || P2.updates.length + i8.transactions.length > MaxUpdateCount && Date.now() - P2.time > MinAbortTime) {
628
+ for (let i9 of P2.context.abortListeners) try {
629
+ i9();
630
+ } catch (i10) {
631
+ logException(this.view.state, i10);
632
+ }
633
+ P2.context.abortListeners = null, this.running.splice(N2--, 1);
634
+ } else P2.updates.push(...i8.transactions);
635
+ }
636
+ this.debounceUpdate > -1 && clearTimeout(this.debounceUpdate), i8.transactions.some((i9) => i9.effects.some((i10) => i10.is(startCompletionEffect))) && (this.pendingStart = true);
637
+ let I = this.pendingStart ? 50 : P.activateOnTypingDelay;
638
+ if (this.debounceUpdate = N.active.some((i9) => i9.isPending && !this.running.some((N2) => N2.active.source == i9.source)) ? setTimeout(() => this.startUpdate(), I) : -1, this.composing != 0) for (let N2 of i8.transactions) N2.isUserEvent("input.type") ? this.composing = 2 : this.composing == 2 && N2.selection && (this.composing = 3);
639
+ }
640
+ startUpdate() {
641
+ this.debounceUpdate = -1, this.pendingStart = false;
642
+ let { state: i8 } = this.view, N = i8.field(completionState);
643
+ for (let i9 of N.active) i9.isPending && !this.running.some((N2) => N2.active.source == i9.source) && this.startQuery(i9);
644
+ this.running.length && N.open && N.open.disabled && (this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime));
645
+ }
646
+ startQuery(i8) {
647
+ let { state: N } = this.view, P = new CompletionContext(N, cur(N), i8.explicit, this.view), F = new RunningQuery(i8, P);
648
+ this.running.push(F), Promise.resolve(i8.source(P)).then((i9) => {
649
+ F.context.aborted || (F.done = i9 || null, this.scheduleAccept());
650
+ }, (i9) => {
651
+ this.view.dispatch({ effects: closeCompletionEffect.of(null) }), logException(this.view.state, i9);
652
+ });
653
+ }
654
+ scheduleAccept() {
655
+ this.running.every((i8) => i8.done !== void 0) ? this.accept() : this.debounceAccept < 0 && (this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime));
656
+ }
657
+ accept() {
658
+ this.debounceAccept > -1 && clearTimeout(this.debounceAccept), this.debounceAccept = -1;
659
+ let i8 = [], N = this.view.state.facet(completionConfig), P = this.view.state.field(completionState);
660
+ for (let F = 0; F < this.running.length; F++) {
661
+ let I = this.running[F];
662
+ if (I.done === void 0) continue;
663
+ if (this.running.splice(F--, 1), I.done) {
664
+ let P2 = cur(I.updates.length ? I.updates[0].startState : this.view.state), F2 = Math.min(P2, I.done.from + (I.active.explicit ? 0 : 1)), L2 = new ActiveResult(I.active.source, I.active.explicit, F2, I.done, I.done.from, I.done.to ?? P2);
665
+ for (let i9 of I.updates) L2 = L2.update(i9, N);
666
+ if (L2.hasResult()) {
667
+ i8.push(L2);
668
+ continue;
669
+ }
670
+ }
671
+ let L = P.active.find((i9) => i9.source == I.active.source);
672
+ if (L && L.isPending) if (I.done == null) {
673
+ let P2 = new ActiveSource(I.active.source, 0);
674
+ for (let i9 of I.updates) P2 = P2.update(i9, N);
675
+ P2.isPending || i8.push(P2);
676
+ } else this.startQuery(L);
677
+ }
678
+ (i8.length || P.open && P.open.disabled) && this.view.dispatch({ effects: setActiveEffect.of(i8) });
679
+ }
680
+ }, { eventHandlers: {
681
+ blur(i8) {
682
+ let N = this.view.state.field(completionState, false);
683
+ if (N && N.tooltip && this.view.state.facet(completionConfig).closeOnBlur) {
684
+ let P = N.open && getTooltip(this.view, N.open.tooltip);
685
+ (!P || !P.dom.contains(i8.relatedTarget)) && setTimeout(() => this.view.dispatch({ effects: closeCompletionEffect.of(null) }), 10);
686
+ }
687
+ },
688
+ compositionstart() {
689
+ this.composing = 1;
690
+ },
691
+ compositionend() {
692
+ this.composing == 3 && setTimeout(() => this.view.dispatch({ effects: startCompletionEffect.of(false) }), 20), this.composing = 0;
693
+ }
694
+ } }), windows = typeof navigator == "object" && /* @__PURE__ */ /Win/.test(navigator.platform), commitCharacters = /* @__PURE__ */ Prec.highest(/* @__PURE__ */ EditorView.domEventHandlers({ keydown(i8, N) {
695
+ let P = N.state.field(completionState, false);
696
+ if (!P || !P.open || P.open.disabled || P.open.selected < 0 || i8.key.length > 1 || i8.ctrlKey && !(windows && i8.altKey) || i8.metaKey) return false;
697
+ let F = P.open.options[P.open.selected], I = P.active.find((i9) => i9.source == F.source), L = F.completion.commitCharacters || I.result.commitCharacters;
698
+ return L && L.indexOf(i8.key) > -1 && applyCompletion(N, F), false;
699
+ } })), baseTheme = /* @__PURE__ */ EditorView.baseTheme({
700
+ ".cm-tooltip.cm-tooltip-autocomplete": { "& > ul": {
701
+ fontFamily: "monospace",
702
+ whiteSpace: "nowrap",
703
+ overflow: "hidden auto",
704
+ maxWidth_fallback: "700px",
705
+ maxWidth: "min(700px, 95vw)",
706
+ minWidth: "250px",
707
+ maxHeight: "10em",
708
+ height: "100%",
709
+ listStyle: "none",
710
+ margin: 0,
711
+ padding: 0,
712
+ "& > li, & > completion-section": {
713
+ padding: "1px 3px",
714
+ lineHeight: 1.2
715
+ },
716
+ "& > li": {
717
+ overflowX: "hidden",
718
+ textOverflow: "ellipsis",
719
+ cursor: "pointer"
720
+ },
721
+ "& > completion-section": {
722
+ display: "list-item",
723
+ borderBottom: "1px solid silver",
724
+ paddingLeft: "0.5em",
725
+ opacity: 0.7
726
+ }
727
+ } },
728
+ "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
729
+ background: "#17c",
730
+ color: "white"
731
+ },
732
+ "&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]": { background: "#777" },
733
+ "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
734
+ background: "#347",
735
+ color: "white"
736
+ },
737
+ "&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]": { background: "#444" },
738
+ ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
739
+ content: '"\xB7\xB7\xB7"',
740
+ opacity: 0.5,
741
+ display: "block",
742
+ textAlign: "center"
743
+ },
744
+ ".cm-tooltip.cm-completionInfo": {
745
+ position: "absolute",
746
+ padding: "3px 9px",
747
+ width: "max-content",
748
+ maxWidth: "400px",
749
+ boxSizing: "border-box",
750
+ whiteSpace: "pre-line"
751
+ },
752
+ ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
753
+ ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
754
+ ".cm-completionInfo.cm-completionInfo-left-narrow": { right: "30px" },
755
+ ".cm-completionInfo.cm-completionInfo-right-narrow": { left: "30px" },
756
+ "&light .cm-snippetField": { backgroundColor: "#00000022" },
757
+ "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
758
+ ".cm-snippetFieldPosition": {
759
+ verticalAlign: "text-top",
760
+ width: 0,
761
+ height: "1.15em",
762
+ display: "inline-block",
763
+ margin: "0 -0.7px -.7em",
764
+ borderLeft: "1.4px dotted #888"
765
+ },
766
+ ".cm-completionMatchedText": { textDecoration: "underline" },
767
+ ".cm-completionDetail": {
768
+ marginLeft: "0.5em",
769
+ fontStyle: "italic"
770
+ },
771
+ ".cm-completionIcon": {
772
+ fontSize: "90%",
773
+ width: ".8em",
774
+ display: "inline-block",
775
+ textAlign: "center",
776
+ paddingRight: ".6em",
777
+ opacity: "0.6",
778
+ boxSizing: "content-box"
779
+ },
780
+ ".cm-completionIcon-function, .cm-completionIcon-method": { "&:after": { content: "'\u0192'" } },
781
+ ".cm-completionIcon-class": { "&:after": { content: "'\u25CB'" } },
782
+ ".cm-completionIcon-interface": { "&:after": { content: "'\u25CC'" } },
783
+ ".cm-completionIcon-variable": { "&:after": { content: "'\u{1D465}'" } },
784
+ ".cm-completionIcon-constant": { "&:after": { content: "'\u{1D436}'" } },
785
+ ".cm-completionIcon-type": { "&:after": { content: "'\u{1D461}'" } },
786
+ ".cm-completionIcon-enum": { "&:after": { content: "'\u222A'" } },
787
+ ".cm-completionIcon-property": { "&:after": { content: "'\u25A1'" } },
788
+ ".cm-completionIcon-keyword": { "&:after": { content: "'\u{1F511}\uFE0E'" } },
789
+ ".cm-completionIcon-namespace": { "&:after": { content: "'\u25A2'" } },
790
+ ".cm-completionIcon-text": { "&:after": {
791
+ content: "'abc'",
792
+ fontSize: "50%",
793
+ verticalAlign: "middle"
794
+ } }
795
+ }), FieldPos = class {
796
+ constructor(i8, N, P, F) {
797
+ this.field = i8, this.line = N, this.from = P, this.to = F;
798
+ }
799
+ }, FieldRange = class i5 {
800
+ constructor(i8, N, P) {
801
+ this.field = i8, this.from = N, this.to = P;
802
+ }
803
+ map(N) {
804
+ let P = N.mapPos(this.from, -1, MapMode.TrackDel), F = N.mapPos(this.to, 1, MapMode.TrackDel);
805
+ return P == null || F == null ? null : new i5(this.field, P, F);
806
+ }
807
+ }, Snippet = class i6 {
808
+ constructor(i8, N) {
809
+ this.lines = i8, this.fieldPositions = N;
810
+ }
811
+ instantiate(i8, N) {
812
+ let P = [], F = [N], I = i8.doc.lineAt(N), L = /^\s*/.exec(I.text)[0];
813
+ for (let I2 of this.lines) {
814
+ if (P.length) {
815
+ let P2 = L, R = /^\t*/.exec(I2)[0].length;
816
+ for (let N2 = 0; N2 < R; N2++) P2 += i8.facet(indentUnit);
817
+ F.push(N + P2.length - R), I2 = P2 + I2.slice(R);
818
+ }
819
+ P.push(I2), N += I2.length + 1;
820
+ }
821
+ return {
822
+ text: P,
823
+ ranges: this.fieldPositions.map((i9) => new FieldRange(i9.field, F[i9.line] + i9.from, F[i9.line] + i9.to))
824
+ };
825
+ }
826
+ static parse(N) {
827
+ let P = [], F = [], I = [], L;
828
+ for (let i8 of N.split(/\r\n?|\n/)) {
829
+ for (; L = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(i8); ) {
830
+ let N2 = L[1] ? +L[1] : null, R = L[2] || L[3] || "", z = -1, B = R.replace(/\\[{}]/g, (i9) => i9[1]);
831
+ for (let i9 = 0; i9 < P.length; i9++) (N2 == null ? B && P[i9].name == B : P[i9].seq == N2) && (z = i9);
832
+ if (z < 0) {
833
+ let i9 = 0;
834
+ for (; i9 < P.length && (N2 == null || P[i9].seq != null && P[i9].seq < N2); ) i9++;
835
+ P.splice(i9, 0, {
836
+ seq: N2,
837
+ name: B
838
+ }), z = i9;
839
+ for (let i10 of I) i10.field >= z && i10.field++;
840
+ }
841
+ for (let i9 of I) if (i9.line == F.length && i9.from > L.index) {
842
+ let N3 = L[2] ? 3 + (L[1] || "").length : 2;
843
+ i9.from -= N3, i9.to -= N3;
844
+ }
845
+ I.push(new FieldPos(z, F.length, L.index, L.index + B.length)), i8 = i8.slice(0, L.index) + R + i8.slice(L.index + L[0].length);
846
+ }
847
+ i8 = i8.replace(/\\([{}])/g, (i9, N2, P2) => {
848
+ for (let i10 of I) i10.line == F.length && i10.from > P2 && (i10.from--, i10.to--);
849
+ return N2;
850
+ }), F.push(i8);
851
+ }
852
+ return new i6(F, I);
853
+ }
854
+ }, fieldMarker = /* @__PURE__ */ Decoration.widget({ widget: /* @__PURE__ */ new class extends WidgetType {
855
+ toDOM() {
856
+ let i8 = document.createElement("span");
857
+ return i8.className = "cm-snippetFieldPosition", i8;
858
+ }
859
+ ignoreEvent() {
860
+ return false;
861
+ }
862
+ }() }), fieldRange = /* @__PURE__ */ Decoration.mark({ class: "cm-snippetField" }), ActiveSnippet = class i7 {
863
+ constructor(i8, N) {
864
+ this.ranges = i8, this.active = N, this.deco = Decoration.set(i8.map((i9) => (i9.from == i9.to ? fieldMarker : fieldRange).range(i9.from, i9.to)), true);
865
+ }
866
+ map(N) {
867
+ let P = [];
868
+ for (let i8 of this.ranges) {
869
+ let F = i8.map(N);
870
+ if (!F) return null;
871
+ P.push(F);
872
+ }
873
+ return new i7(P, this.active);
874
+ }
875
+ selectionInsideField(i8) {
876
+ return i8.ranges.every((i9) => this.ranges.some((N) => N.field == this.active && N.from <= i9.from && N.to >= i9.to));
877
+ }
878
+ }, setActive = /* @__PURE__ */ StateEffect.define({ map(i8, N) {
879
+ return i8 && i8.map(N);
880
+ } }), moveToField = /* @__PURE__ */ StateEffect.define(), snippetState = /* @__PURE__ */ StateField.define({
881
+ create() {
882
+ return null;
883
+ },
884
+ update(i8, N) {
885
+ for (let P of N.effects) {
886
+ if (P.is(setActive)) return P.value;
887
+ if (P.is(moveToField) && i8) return new ActiveSnippet(i8.ranges, P.value);
888
+ }
889
+ return i8 && N.docChanged && (i8 = i8.map(N.changes)), i8 && N.selection && !i8.selectionInsideField(N.selection) && (i8 = null), i8;
890
+ },
891
+ provide: (i8) => EditorView.decorations.from(i8, (i9) => i9 ? i9.deco : Decoration.none)
892
+ });
893
+ function fieldSelection(i8, N) {
894
+ return EditorSelection.create(i8.filter((i9) => i9.field == N).map((i9) => EditorSelection.range(i9.from, i9.to)));
895
+ }
896
+ function snippet(i8) {
897
+ let N = Snippet.parse(i8);
898
+ return (i9, P, F, I) => {
899
+ let { text: L, ranges: B } = N.instantiate(i9.state, F), { main: V } = i9.state.selection, U = {
900
+ changes: {
901
+ from: F,
902
+ to: I == V.from ? V.to : I,
903
+ insert: Text.of(L)
904
+ },
905
+ scrollIntoView: true,
906
+ annotations: P ? [pickedCompletion.of(P), Transaction.userEvent.of("input.complete")] : void 0
907
+ };
908
+ if (B.length && (U.selection = fieldSelection(B, 0)), B.some((i10) => i10.field > 0)) {
909
+ let N2 = new ActiveSnippet(B, 0), P2 = U.effects = [setActive.of(N2)];
910
+ i9.state.field(snippetState, false) === void 0 && P2.push(StateEffect.appendConfig.of([
911
+ snippetState,
912
+ addSnippetKeymap,
913
+ snippetPointerHandler,
914
+ baseTheme
915
+ ]));
916
+ }
917
+ i9.dispatch(i9.state.update(U));
918
+ };
919
+ }
920
+ function moveField(i8) {
921
+ return ({ state: N, dispatch: P }) => {
922
+ let F = N.field(snippetState, false);
923
+ if (!F || i8 < 0 && F.active == 0) return false;
924
+ let I = F.active + i8, L = i8 > 0 && !F.ranges.some((N2) => N2.field == I + i8);
925
+ return P(N.update({
926
+ selection: fieldSelection(F.ranges, I),
927
+ effects: setActive.of(L ? null : new ActiveSnippet(F.ranges, I)),
928
+ scrollIntoView: true
929
+ })), true;
930
+ };
931
+ }
932
+ var defaultSnippetKeymap = [{
933
+ key: "Tab",
934
+ run: /* @__PURE__ */ moveField(1),
935
+ shift: /* @__PURE__ */ moveField(-1)
936
+ }, {
937
+ key: "Escape",
938
+ run: ({ state: i8, dispatch: N }) => i8.field(snippetState, false) ? (N(i8.update({ effects: setActive.of(null) })), true) : false
939
+ }], snippetKeymap = /* @__PURE__ */ Facet.define({ combine(i8) {
940
+ return i8.length ? i8[0] : defaultSnippetKeymap;
941
+ } }), addSnippetKeymap = /* @__PURE__ */ Prec.highest(/* @__PURE__ */ keymap.compute([snippetKeymap], (i8) => i8.facet(snippetKeymap)));
942
+ function snippetCompletion(i8, N) {
943
+ return {
944
+ ...N,
945
+ apply: snippet(i8)
946
+ };
947
+ }
948
+ var snippetPointerHandler = /* @__PURE__ */ EditorView.domEventHandlers({ mousedown(i8, N) {
949
+ let P = N.state.field(snippetState, false), F;
950
+ if (!P || (F = N.posAtCoords({
951
+ x: i8.clientX,
952
+ y: i8.clientY
953
+ })) == null) return false;
954
+ let I = P.ranges.find((i9) => i9.from <= F && i9.to >= F);
955
+ return !I || I.field == P.active ? false : (N.dispatch({
956
+ selection: fieldSelection(P.ranges, I.field),
957
+ effects: setActive.of(P.ranges.some((i9) => i9.field > I.field) ? new ActiveSnippet(P.ranges, I.field) : null),
958
+ scrollIntoView: true
959
+ }), true);
960
+ } }), defaults = {
961
+ brackets: [
962
+ "(",
963
+ "[",
964
+ "{",
965
+ "'",
966
+ '"'
967
+ ],
968
+ before: ")]}:;>",
969
+ stringPrefixes: []
970
+ }, closeBracketEffect = /* @__PURE__ */ StateEffect.define({ map(i8, N) {
971
+ return N.mapPos(i8, -1, MapMode.TrackAfter) ?? void 0;
972
+ } }), closedBracket = /* @__PURE__ */ new class extends RangeValue {
973
+ }();
974
+ closedBracket.startSide = 1, closedBracket.endSide = -1;
975
+ var bracketState = /* @__PURE__ */ StateField.define({
976
+ create() {
977
+ return RangeSet.empty;
978
+ },
979
+ update(i8, N) {
980
+ if (i8 = i8.map(N.changes), N.selection) {
981
+ let P = N.state.doc.lineAt(N.selection.main.head);
982
+ i8 = i8.update({ filter: (i9) => i9 >= P.from && i9 <= P.to });
983
+ }
984
+ for (let P of N.effects) P.is(closeBracketEffect) && (i8 = i8.update({ add: [closedBracket.range(P.value, P.value + 1)] }));
985
+ return i8;
986
+ }
987
+ });
988
+ function closeBrackets() {
989
+ return [inputHandler, bracketState];
990
+ }
991
+ var definedClosing = "()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";
992
+ function closing(i8) {
993
+ for (let N = 0; N < 16; N += 2) if (definedClosing.charCodeAt(N) == i8) return definedClosing.charAt(N + 1);
994
+ return fromCodePoint(i8 < 128 ? i8 : i8 + 1);
995
+ }
996
+ function config(i8, N) {
997
+ return i8.languageDataAt("closeBrackets", N)[0] || defaults;
998
+ }
999
+ var android = typeof navigator == "object" && /* @__PURE__ */ /Android\b/.test(navigator.userAgent), inputHandler = /* @__PURE__ */ EditorView.inputHandler.of((i8, N, P, F) => {
1000
+ if ((android ? i8.composing : i8.compositionStarted) || i8.state.readOnly) return false;
1001
+ let I = i8.state.selection.main;
1002
+ if (F.length > 2 || F.length == 2 && codePointSize(codePointAt(F, 0)) == 1 || N != I.from || P != I.to) return false;
1003
+ let L = insertBracket(i8.state, F);
1004
+ return L ? (i8.dispatch(L), true) : false;
1005
+ }), closeBracketsKeymap = [{
1006
+ key: "Backspace",
1007
+ run: ({ state: i8, dispatch: N }) => {
1008
+ if (i8.readOnly) return false;
1009
+ let P = config(i8, i8.selection.main.head).brackets || defaults.brackets, I = null, L = i8.changeByRange((N2) => {
1010
+ if (N2.empty) {
1011
+ let I2 = prevChar(i8.doc, N2.head);
1012
+ for (let L2 of P) if (L2 == I2 && nextChar(i8.doc, N2.head) == closing(codePointAt(L2, 0))) return {
1013
+ changes: {
1014
+ from: N2.head - L2.length,
1015
+ to: N2.head + L2.length
1016
+ },
1017
+ range: EditorSelection.cursor(N2.head - L2.length)
1018
+ };
1019
+ }
1020
+ return { range: I = N2 };
1021
+ });
1022
+ return I || N(i8.update(L, {
1023
+ scrollIntoView: true,
1024
+ userEvent: "delete.backward"
1025
+ })), !I;
1026
+ }
1027
+ }];
1028
+ function insertBracket(i8, N) {
1029
+ let P = config(i8, i8.selection.main.head), F = P.brackets || defaults.brackets;
1030
+ for (let I of F) {
1031
+ let L = closing(codePointAt(I, 0));
1032
+ if (N == I) return L == I ? handleSame(i8, I, F.indexOf(I + I + I) > -1, P) : handleOpen(i8, I, L, P.before || defaults.before);
1033
+ if (N == L && closedBracketAt(i8, i8.selection.main.from)) return handleClose(i8, I, L);
1034
+ }
1035
+ return null;
1036
+ }
1037
+ function closedBracketAt(i8, N) {
1038
+ let P = false;
1039
+ return i8.field(bracketState).between(0, i8.doc.length, (i9) => {
1040
+ i9 == N && (P = true);
1041
+ }), P;
1042
+ }
1043
+ function nextChar(i8, N) {
1044
+ let P = i8.sliceString(N, N + 2);
1045
+ return P.slice(0, codePointSize(codePointAt(P, 0)));
1046
+ }
1047
+ function prevChar(i8, N) {
1048
+ let P = i8.sliceString(N - 2, N);
1049
+ return codePointSize(codePointAt(P, 0)) == P.length ? P : P.slice(1);
1050
+ }
1051
+ function handleOpen(i8, N, P, I) {
1052
+ let L = null, R = i8.changeByRange((R2) => {
1053
+ if (!R2.empty) return {
1054
+ changes: [{
1055
+ insert: N,
1056
+ from: R2.from
1057
+ }, {
1058
+ insert: P,
1059
+ from: R2.to
1060
+ }],
1061
+ effects: closeBracketEffect.of(R2.to + N.length),
1062
+ range: EditorSelection.range(R2.anchor + N.length, R2.head + N.length)
1063
+ };
1064
+ let z = nextChar(i8.doc, R2.head);
1065
+ return !z || /\s/.test(z) || I.indexOf(z) > -1 ? {
1066
+ changes: {
1067
+ insert: N + P,
1068
+ from: R2.head
1069
+ },
1070
+ effects: closeBracketEffect.of(R2.head + N.length),
1071
+ range: EditorSelection.cursor(R2.head + N.length)
1072
+ } : { range: L = R2 };
1073
+ });
1074
+ return L ? null : i8.update(R, {
1075
+ scrollIntoView: true,
1076
+ userEvent: "input.type"
1077
+ });
1078
+ }
1079
+ function handleClose(i8, N, P) {
1080
+ let I = null, L = i8.changeByRange((N2) => N2.empty && nextChar(i8.doc, N2.head) == P ? {
1081
+ changes: {
1082
+ from: N2.head,
1083
+ to: N2.head + P.length,
1084
+ insert: P
1085
+ },
1086
+ range: EditorSelection.cursor(N2.head + P.length)
1087
+ } : I = { range: N2 });
1088
+ return I ? null : i8.update(L, {
1089
+ scrollIntoView: true,
1090
+ userEvent: "input.type"
1091
+ });
1092
+ }
1093
+ function handleSame(i8, N, P, I) {
1094
+ let L = I.stringPrefixes || defaults.stringPrefixes, R = null, z = i8.changeByRange((I2) => {
1095
+ if (!I2.empty) return {
1096
+ changes: [{
1097
+ insert: N,
1098
+ from: I2.from
1099
+ }, {
1100
+ insert: N,
1101
+ from: I2.to
1102
+ }],
1103
+ effects: closeBracketEffect.of(I2.to + N.length),
1104
+ range: EditorSelection.range(I2.anchor + N.length, I2.head + N.length)
1105
+ };
1106
+ let z2 = I2.head, B = nextChar(i8.doc, z2), V;
1107
+ if (B == N) {
1108
+ if (nodeStart(i8, z2)) return {
1109
+ changes: {
1110
+ insert: N + N,
1111
+ from: z2
1112
+ },
1113
+ effects: closeBracketEffect.of(z2 + N.length),
1114
+ range: EditorSelection.cursor(z2 + N.length)
1115
+ };
1116
+ if (closedBracketAt(i8, z2)) {
1117
+ let I3 = P && i8.sliceDoc(z2, z2 + N.length * 3) == N + N + N ? N + N + N : N;
1118
+ return {
1119
+ changes: {
1120
+ from: z2,
1121
+ to: z2 + I3.length,
1122
+ insert: I3
1123
+ },
1124
+ range: EditorSelection.cursor(z2 + I3.length)
1125
+ };
1126
+ }
1127
+ } else if (P && i8.sliceDoc(z2 - 2 * N.length, z2) == N + N && (V = canStartStringAt(i8, z2 - 2 * N.length, L)) > -1 && nodeStart(i8, V)) return {
1128
+ changes: {
1129
+ insert: N + N + N + N,
1130
+ from: z2
1131
+ },
1132
+ effects: closeBracketEffect.of(z2 + N.length),
1133
+ range: EditorSelection.cursor(z2 + N.length)
1134
+ };
1135
+ else if (i8.charCategorizer(z2)(B) != CharCategory.Word && canStartStringAt(i8, z2, L) > -1 && !probablyInString(i8, z2, N, L)) return {
1136
+ changes: {
1137
+ insert: N + N,
1138
+ from: z2
1139
+ },
1140
+ effects: closeBracketEffect.of(z2 + N.length),
1141
+ range: EditorSelection.cursor(z2 + N.length)
1142
+ };
1143
+ return { range: R = I2 };
1144
+ });
1145
+ return R ? null : i8.update(z, {
1146
+ scrollIntoView: true,
1147
+ userEvent: "input.type"
1148
+ });
1149
+ }
1150
+ function nodeStart(i8, N) {
1151
+ let P = syntaxTree(i8).resolveInner(N + 1);
1152
+ return P.parent && P.from == N;
1153
+ }
1154
+ function probablyInString(i8, N, P, F) {
1155
+ let I = syntaxTree(i8).resolveInner(N, -1), R = F.reduce((i9, N2) => Math.max(i9, N2.length), 0);
1156
+ for (let L = 0; L < 5; L++) {
1157
+ let L2 = i8.sliceDoc(I.from, Math.min(I.to, I.from + P.length + R)), z = L2.indexOf(P);
1158
+ if (!z || z > -1 && F.indexOf(L2.slice(0, z)) > -1) {
1159
+ let N2 = I.firstChild;
1160
+ for (; N2 && N2.from == I.from && N2.to - N2.from > P.length + z; ) {
1161
+ if (i8.sliceDoc(N2.to - P.length, N2.to) == P) return false;
1162
+ N2 = N2.firstChild;
1163
+ }
1164
+ return true;
1165
+ }
1166
+ let B = I.to == N && I.parent;
1167
+ if (!B) break;
1168
+ I = B;
1169
+ }
1170
+ return false;
1171
+ }
1172
+ function canStartStringAt(i8, N, P) {
1173
+ let F = i8.charCategorizer(N);
1174
+ if (F(i8.sliceDoc(N - 1, N)) != CharCategory.Word) return N;
1175
+ for (let I of P) {
1176
+ let P2 = N - I.length;
1177
+ if (i8.sliceDoc(P2, N) == I && F(i8.sliceDoc(P2 - 1, P2)) != CharCategory.Word) return P2;
1178
+ }
1179
+ return -1;
1180
+ }
1181
+ function autocompletion(i8 = {}) {
1182
+ return [
1183
+ commitCharacters,
1184
+ completionState,
1185
+ completionConfig.of(i8),
1186
+ completionPlugin,
1187
+ completionKeymapExt,
1188
+ baseTheme
1189
+ ];
1190
+ }
1191
+ var completionKeymap = [
1192
+ {
1193
+ key: "Ctrl-Space",
1194
+ run: startCompletion
1195
+ },
1196
+ {
1197
+ mac: "Alt-`",
1198
+ run: startCompletion
1199
+ },
1200
+ {
1201
+ mac: "Alt-i",
1202
+ run: startCompletion
1203
+ },
1204
+ {
1205
+ key: "Escape",
1206
+ run: closeCompletion
1207
+ },
1208
+ {
1209
+ key: "ArrowDown",
1210
+ run: /* @__PURE__ */ moveCompletionSelection(true)
1211
+ },
1212
+ {
1213
+ key: "ArrowUp",
1214
+ run: /* @__PURE__ */ moveCompletionSelection(false)
1215
+ },
1216
+ {
1217
+ key: "PageDown",
1218
+ run: /* @__PURE__ */ moveCompletionSelection(true, "page")
1219
+ },
1220
+ {
1221
+ key: "PageUp",
1222
+ run: /* @__PURE__ */ moveCompletionSelection(false, "page")
1223
+ },
1224
+ {
1225
+ key: "Enter",
1226
+ run: acceptCompletion
1227
+ }
1228
+ ], completionKeymapExt = /* @__PURE__ */ Prec.highest(/* @__PURE__ */ keymap.computeN([completionConfig], (i8) => i8.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));
1229
+ export {
1230
+ closeBracketsKeymap as a,
1231
+ completionKeymap as c,
1232
+ snippet as d,
1233
+ snippetCompletion as f,
1234
+ closeBrackets as i,
1235
+ ifNotIn as l,
1236
+ acceptCompletion as n,
1237
+ closeCompletion as o,
1238
+ autocompletion as r,
1239
+ completeFromList as s,
1240
+ CompletionContext as t,
1241
+ insertCompletionText as u
1242
+ };