@onerjs/code-input 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { defineComponent as wt, ref as C, computed as V, watch as Be, nextTick as j, onMounted as $t, onBeforeUnmount as Ct, openBlock as S, createElementBlock as E, normalizeStyle as ae, normalizeClass as te, createElementVNode as R, withModifiers as Le, Fragment as Oe, renderList as Ne, toDisplayString as K, createCommentVNode as D, createTextVNode as Tt } from "vue";
2
- const St = [
1
+ import { defineComponent as St, ref as E, computed as K, watch as Be, nextTick as V, onMounted as Et, onBeforeUnmount as Mt, openBlock as I, createElementBlock as L, normalizeStyle as re, normalizeClass as te, createElementVNode as A, withModifiers as Oe, Fragment as Ne, renderList as We, toDisplayString as Y, createCommentVNode as Z, createTextVNode as Rt } from "vue";
2
+ const It = [
3
3
  {
4
4
  label: "Math",
5
5
  kind: "class",
@@ -134,7 +134,51 @@ const St = [
134
134
  kind: "function",
135
135
  detail: "(id: number) => void"
136
136
  }
137
- ], ze = [
137
+ ], Lt = /[\w$]/;
138
+ function _t(n, s) {
139
+ const o = [];
140
+ let e = null;
141
+ for (let C = 0; C < s; C++) {
142
+ const b = n[C];
143
+ if (e) {
144
+ b === e && n[C - 1] !== "\\" && (e = null);
145
+ continue;
146
+ }
147
+ if (b === "'" || b === '"' || b === "`") {
148
+ e = b;
149
+ continue;
150
+ }
151
+ if (b === "(") {
152
+ o.push({ index: C, commas: 0 });
153
+ continue;
154
+ }
155
+ if (b === ")") {
156
+ o.pop();
157
+ continue;
158
+ }
159
+ b === "," && o.length && o[o.length - 1].commas++;
160
+ }
161
+ const i = o[o.length - 1];
162
+ if (!i) return null;
163
+ let r = i.index - 1;
164
+ for (; r >= 0 && /\s/.test(n[r]); ) r--;
165
+ const d = r;
166
+ for (; r >= 0 && Lt.test(n[r]); ) r--;
167
+ const u = n.slice(r + 1, d + 1);
168
+ if (!u) return null;
169
+ let a = s;
170
+ for (; a > 0 && /[\w$'"]/.test(n[a - 1]); ) a--;
171
+ const f = n.slice(a, s);
172
+ let $ = f, z = null;
173
+ return f && (f[0] === "'" || f[0] === '"') && (z = f[0], $ = f.slice(1)), {
174
+ functionName: u,
175
+ paramIndex: i.commas,
176
+ prefix: $,
177
+ replaceStart: a,
178
+ quote: z
179
+ };
180
+ }
181
+ const ze = [
138
182
  "break",
139
183
  "case",
140
184
  "catch",
@@ -179,7 +223,7 @@ const St = [
179
223
  "undefined",
180
224
  "NaN",
181
225
  "Infinity"
182
- ], Et = [
226
+ ], Ht = [
183
227
  "abstract",
184
228
  "any",
185
229
  "as",
@@ -209,534 +253,590 @@ const St = [
209
253
  "type",
210
254
  "unknown"
211
255
  ];
212
- function Ye(l) {
213
- return l === "typescript" ? [...ze, ...Et] : ze;
256
+ function Je(n) {
257
+ return n === "typescript" ? [...ze, ...Ht] : ze;
214
258
  }
215
- function je(l) {
216
- return new Set(Ye(l));
259
+ function De(n) {
260
+ return new Set(Je(n));
217
261
  }
218
- const It = /((?:[A-Za-z_$][\w$]*\??\.)*)([A-Za-z_$][\w$]*)?$/, De = /\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g, Rt = /^[A-Za-z_$]/;
219
- function Je(l, s) {
220
- const a = l.slice(0, s), t = It.exec(a);
221
- if (!t) return { prefix: "", chain: [] };
222
- const o = t[1] ?? "", c = t[2] ?? "", u = o.split(".").filter(Boolean).map((d) => d.replace(/\?$/, ""));
223
- return { prefix: c, chain: u };
262
+ const At = /((?:[A-Za-z_$][\w$]*\??\.)*)([A-Za-z_$][\w$]*)?$/, je = /\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g, Bt = /^[A-Za-z_$]/;
263
+ function Xe(n, s) {
264
+ const o = n.slice(0, s), e = At.exec(o);
265
+ if (!e) return { prefix: "", chain: [] };
266
+ const i = e[1] ?? "", r = e[2] ?? "", d = i.split(".").filter(Boolean).map((u) => u.replace(/\?$/, ""));
267
+ return { prefix: r, chain: d };
224
268
  }
225
- function We(l, s) {
226
- const a = [], t = /* @__PURE__ */ new Set();
227
- let o;
228
- for (De.lastIndex = 0; (o = De.exec(l)) && !(o.index >= s); ) {
229
- const c = o[1];
230
- if (t.has(c)) continue;
231
- t.add(c);
232
- const u = o[0].slice(0, o[0].indexOf(c)).trim();
233
- a.push({
234
- label: c,
235
- kind: u === "function" ? "function" : u === "class" ? "class" : "variable",
269
+ function Fe(n, s) {
270
+ const o = [], e = /* @__PURE__ */ new Set();
271
+ let i;
272
+ for (je.lastIndex = 0; (i = je.exec(n)) && !(i.index >= s); ) {
273
+ const r = i[1];
274
+ if (e.has(r)) continue;
275
+ e.add(r);
276
+ const d = i[0].slice(0, i[0].indexOf(r)).trim();
277
+ o.push({
278
+ label: r,
279
+ kind: d === "function" ? "function" : d === "class" ? "class" : "variable",
236
280
  detail: "当前文件"
237
281
  });
238
282
  }
239
- return a;
283
+ return o;
240
284
  }
241
- function Ge(l, s) {
242
- let a = s;
243
- for (const t of l) {
244
- if (!a) return null;
245
- const o = a.find((c) => c.label === t);
285
+ function Ge(n, s) {
286
+ let o = s;
287
+ for (const e of n) {
246
288
  if (!o) return null;
247
- a = o.members ?? [];
289
+ const i = o.find((r) => r.label === e);
290
+ if (!i) return null;
291
+ o = i.members ?? [];
248
292
  }
249
- return a;
293
+ return o;
250
294
  }
251
- function Mt(l, s) {
252
- const a = l.toLowerCase(), t = s.toLowerCase(), o = a.indexOf(t);
253
- if (o === 0) return 1e3 - a.length;
254
- if (o > 0) return 800 - o;
255
- let c = 0, u = 0, d = -1;
256
- for (let i = 0; i < a.length && c < t.length; i++)
257
- a[i] === t[c] && (d >= 0 && (u += i - d - 1), d = i, c++);
258
- return c !== t.length ? null : 400 - u - a.length;
295
+ function Ot(n, s) {
296
+ const o = n.toLowerCase(), e = s.toLowerCase(), i = o.indexOf(e);
297
+ if (i === 0) return 1e3 - o.length;
298
+ if (i > 0) return 800 - i;
299
+ let r = 0, d = 0, u = -1;
300
+ for (let a = 0; a < o.length && r < e.length; a++)
301
+ o[a] === e[r] && (u >= 0 && (d += a - u - 1), u = a, r++);
302
+ return r !== e.length ? null : 400 - d - o.length;
259
303
  }
260
- function _t(l, s) {
261
- if (!s) return l;
262
- const a = [];
263
- for (const t of l) {
264
- const o = Mt(t.label, s);
265
- o !== null && a.push({ item: t, score: o });
304
+ function Qe(n, s) {
305
+ if (!s) return n;
306
+ const o = [];
307
+ for (const e of n) {
308
+ const i = Ot(e.label, s);
309
+ i !== null && o.push({ item: e, score: i });
266
310
  }
267
- return a.sort((t, o) => o.score - t.score || t.item.label.localeCompare(o.item.label)), a.map((t) => t.item);
311
+ return o.sort((e, i) => i.score - e.score || e.item.label.localeCompare(i.item.label)), o.map((e) => e.item);
268
312
  }
269
- function Ht(l) {
270
- const s = /* @__PURE__ */ new Set(), a = [];
271
- for (const t of l)
272
- s.has(t.label) || (s.add(t.label), a.push(t));
273
- return a;
313
+ function Nt(n) {
314
+ const s = /* @__PURE__ */ new Set(), o = [];
315
+ for (const e of n)
316
+ s.has(e.label) || (s.add(e.label), o.push(e));
317
+ return o;
274
318
  }
275
- function At(l, s, a) {
276
- const { prefix: t, chain: o } = Je(l, s);
277
- if (a.auto && (!t && o.length === 0 || t && !Rt.test(t)))
319
+ function Wt(n, s, o) {
320
+ const { prefix: e, chain: i } = Xe(n, s);
321
+ if (o.auto && (!e && i.length === 0 || e && !Bt.test(e)))
278
322
  return null;
279
- const c = a.declared ?? [], u = [...c, ...a.completions];
280
- let d;
281
- if (o.length > 0) {
282
- const p = Ge(o, u);
283
- if (!p || p.length === 0) return null;
284
- d = p;
323
+ const r = o.declared ?? [], d = [...r, ...o.completions];
324
+ let u;
325
+ if (i.length > 0) {
326
+ const f = Ge(i, d);
327
+ if (!f || f.length === 0) return null;
328
+ u = f;
285
329
  } else
286
- d = [
287
- ...a.completions,
288
- ...c,
289
- ...Ye(a.language).map((p) => ({
290
- label: p,
330
+ u = [
331
+ ...o.completions,
332
+ ...r,
333
+ ...Je(o.language).map((f) => ({
334
+ label: f,
291
335
  kind: "keyword"
292
336
  }))
293
337
  ];
294
- const i = _t(Ht(d), t);
295
- return i.length === 0 ? null : {
296
- items: i,
297
- start: s - t.length,
338
+ const a = Qe(Nt(u), e);
339
+ return a.length === 0 ? null : {
340
+ items: a,
341
+ start: s - e.length,
298
342
  end: s
299
343
  };
300
344
  }
301
- const Bt = /([A-Za-z_$][\w$]*(?:\??\.[A-Za-z_$][\w$]*)*)\??\.\s*$/;
302
- function Lt(l, s, a, t) {
303
- const o = l.slice(s, a);
304
- if (!o) return null;
305
- const c = [...t.declared ?? [], ...t.completions], u = Bt.exec(l.slice(0, s));
306
- if (u) {
307
- const d = u[1].split(".").filter(Boolean).map((M) => M.replace(/\?$/, "")), i = Ge(d, c), p = i == null ? void 0 : i.find((M) => M.label === o);
308
- if (p) return p;
345
+ const zt = /([A-Za-z_$][\w$]*(?:\??\.[A-Za-z_$][\w$]*)*)\??\.\s*$/;
346
+ function Dt(n, s, o, e) {
347
+ const i = n.slice(s, o);
348
+ if (!i) return null;
349
+ const r = [...e.declared ?? [], ...e.completions], d = zt.exec(n.slice(0, s));
350
+ if (d) {
351
+ const u = d[1].split(".").filter(Boolean).map(($) => $.replace(/\?$/, "")), a = Ge(u, r), f = a == null ? void 0 : a.find(($) => $.label === i);
352
+ if (f) return f;
309
353
  }
310
- return c.find((d) => d.label === o) ?? null;
354
+ return r.find((u) => u.label === i) ?? null;
311
355
  }
312
- const Z = "[A-Za-z_$][\\w$]*", Fe = "(?:readonly\\s+|public\\s+|private\\s+|protected\\s+|static\\s+|abstract\\s+)*";
313
- function Pe(l, s) {
314
- let a = 0, t = !1, o = s;
315
- for (let c = s; c < l.length; c++) {
316
- const u = l[c];
317
- for (let d = 0; d < u.length; d++) {
318
- const i = u[d];
319
- i === "{" ? (a++, t = !0) : i === "}" && a--;
320
- }
321
- if (t && a <= 0) {
322
- o = c;
356
+ const U = "[A-Za-z_$][\\w$]*", Pe = "(?:readonly\\s+|public\\s+|private\\s+|protected\\s+|static\\s+|abstract\\s+)*";
357
+ function Ve(n, s) {
358
+ let o = 0, e = !1, i = s;
359
+ for (let r = s; r < n.length; r++) {
360
+ const d = n[r];
361
+ for (let u = 0; u < d.length; u++) {
362
+ const a = d[u];
363
+ a === "{" ? (o++, e = !0) : a === "}" && o--;
364
+ }
365
+ if (e && o <= 0) {
366
+ i = r;
323
367
  break;
324
368
  }
325
369
  }
326
- return { end: o, body: l.slice(s + 1, o) };
370
+ return { end: i, body: n.slice(s + 1, i) };
327
371
  }
328
- function Ve(l) {
329
- return l.trim().replace(/[,;]$/, "").trim();
372
+ function qe(n) {
373
+ return n.trim().replace(/[,;]$/, "").trim();
330
374
  }
331
- function Ot(l) {
375
+ function jt(n) {
332
376
  return /^(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:interface|class|type|function|const|let|var|namespace|enum)\b/.test(
333
- l
377
+ n
334
378
  );
335
379
  }
336
- function ne(l, s) {
337
- const a = l[s];
338
- let t = a.lastIndexOf("}");
339
- const o = a.lastIndexOf(";");
340
- if (o > t && (t = o), t === -1) return;
341
- const c = a.slice(t + 1).replace(/^[\s;]+/, "").trim();
342
- !c || !Ot(c) || (l[s] = a.slice(0, t + 1), l.splice(s + 1, 0, c));
380
+ function ne(n, s) {
381
+ const o = n[s];
382
+ let e = o.lastIndexOf("}");
383
+ const i = o.lastIndexOf(";");
384
+ if (i > e && (e = i), e === -1) return;
385
+ const r = o.slice(e + 1).replace(/^[\s;]+/, "").trim();
386
+ !r || !jt(r) || (n[s] = o.slice(0, e + 1), n.splice(s + 1, 0, r));
343
387
  }
344
- function U(l) {
345
- return l.length ? l.join(`
388
+ function J(n) {
389
+ return n.length ? n.join(`
346
390
  `).replace(/^\s*\/\*\*?/, "").replace(/\*\/\s*$/, "").split(`
347
391
  `).map((s) => s.replace(/^\s*\*+\s?/, "").replace(/^\s*\/\/\s?/, "")).join(`
348
392
  `).replace(/\n{3,}/g, `
349
393
 
350
394
  `).trim() : "";
351
395
  }
352
- function Ke(l) {
353
- return l.split(`
396
+ function Ke(n) {
397
+ return n.split(`
354
398
  `).filter((s) => !/^\s*(\/\/|\/\*|\*)/.test(s)).join(`
355
399
  `).replace(/\n{2,}/g, `
356
400
  `).trim();
357
401
  }
358
- function Ze(l) {
359
- const s = [], a = /* @__PURE__ */ new Set(), t = new RegExp(`^${Fe}(${Z})(\\?)?\\s*\\((.*)\\)\\s*:\\s*(.+?);?$`), o = new RegExp(`^${Fe}(${Z})(\\?)?\\s*:\\s*(.+?);?$`);
360
- let c = [], u = !1;
361
- for (const d of l) {
362
- const i = d.trim();
363
- if (u) {
364
- c.push(i), i.includes("*/") && (u = !1);
402
+ function Ze(n) {
403
+ const s = [], o = /* @__PURE__ */ new Set(), e = new RegExp(`^${Pe}(${U})(\\?)?\\s*\\((.*)\\)\\s*:\\s*(.+?);?$`), i = new RegExp(`^${Pe}(${U})(\\?)?\\s*:\\s*(.+?);?$`);
404
+ let r = [], d = !1;
405
+ for (const u of n) {
406
+ const a = u.trim();
407
+ if (d) {
408
+ r.push(a), a.includes("*/") && (d = !1);
365
409
  continue;
366
410
  }
367
- if (i.startsWith("/*")) {
368
- c.push(i), i.includes("*/") || (u = !0);
411
+ if (a.startsWith("/*")) {
412
+ r.push(a), a.includes("*/") || (d = !0);
369
413
  continue;
370
414
  }
371
- if (i.startsWith("//")) {
372
- c.push(i);
415
+ if (a.startsWith("//")) {
416
+ r.push(a);
373
417
  continue;
374
418
  }
375
- if (!i || i.startsWith("}") || i.startsWith("[")) {
376
- c = [];
419
+ if (!a || a.startsWith("}") || a.startsWith("[")) {
420
+ r = [];
377
421
  continue;
378
422
  }
379
- const p = t.exec(i);
380
- if (p) {
381
- const W = U(c);
382
- c = [];
383
- const g = p[1];
384
- if (a.has(g)) continue;
385
- a.add(g), s.push({
386
- label: g,
423
+ const f = e.exec(a);
424
+ if (f) {
425
+ const z = J(r);
426
+ r = [];
427
+ const C = f[1];
428
+ if (o.has(C)) continue;
429
+ o.add(C), s.push({
430
+ label: C,
387
431
  kind: "function",
388
- detail: `(${p[3].trim()}) => ${Ve(p[4])}`,
389
- documentation: W || void 0
432
+ detail: `(${f[3].trim()}) => ${qe(f[4])}`,
433
+ documentation: z || void 0
390
434
  });
391
435
  continue;
392
436
  }
393
- const M = o.exec(i);
394
- if (M) {
395
- const W = U(c);
396
- c = [];
397
- const g = M[1];
398
- if (a.has(g)) continue;
399
- a.add(g);
400
- const b = Ve(M[3]), H = /^\(|=>/.test(b) ? "function" : "property";
437
+ const $ = i.exec(a);
438
+ if ($) {
439
+ const z = J(r);
440
+ r = [];
441
+ const C = $[1];
442
+ if (o.has(C)) continue;
443
+ o.add(C);
444
+ const b = qe($[3]), y = /^\(|=>/.test(b) ? "function" : "property";
401
445
  s.push({
402
- label: g,
403
- kind: H,
446
+ label: C,
447
+ kind: y,
404
448
  detail: b,
405
- documentation: W || void 0
449
+ documentation: z || void 0
406
450
  });
407
451
  }
408
452
  }
409
453
  return s;
410
454
  }
411
- function Xe(l) {
412
- const s = l.replace(/\[\]/g, "").replace(/<[^>]*>/g, "").replace(/\s*\|\s*null\s*/g, "").trim(), a = new RegExp(`^(${Z})$`).exec(s);
413
- return a ? a[1] : null;
455
+ function et(n) {
456
+ const s = [], o = /(['"])((?:\\.|(?!\1).)*)\1/g;
457
+ let e;
458
+ for (; e = o.exec(n); )
459
+ s.push(e[2]);
460
+ return s;
461
+ }
462
+ function Ft(n, s) {
463
+ const o = [];
464
+ let e = 0, i = "", r = null;
465
+ for (let d = 0; d < n.length; d++) {
466
+ const u = n[d];
467
+ if (r) {
468
+ i += u, u === r && n[d - 1] !== "\\" && (r = null);
469
+ continue;
470
+ }
471
+ if (u === "'" || u === '"' || u === "`") {
472
+ r = u, i += u;
473
+ continue;
474
+ }
475
+ if (u === "(" || u === "<" || u === "[" || u === "{" ? e++ : (u === ")" || u === ">" || u === "]" || u === "}") && e--, u === s && e === 0) {
476
+ o.push(i), i = "";
477
+ continue;
478
+ }
479
+ i += u;
480
+ }
481
+ return o.push(i), o;
482
+ }
483
+ function Pt(n, s) {
484
+ const o = n.trim(), e = et(o);
485
+ if (e.length) return e;
486
+ const i = s.get(o.replace(/\[\]$/, ""));
487
+ return (i == null ? void 0 : i.literals) ?? [];
414
488
  }
415
- function Nt(l) {
416
- const s = l.trim();
489
+ function Vt(n, s) {
490
+ const o = n.trim();
491
+ return o ? Ft(o, ",").map((e) => {
492
+ const i = new RegExp(`^\\s*(${U})\\s*(\\?)?\\s*:\\s*(.+)$`).exec(e);
493
+ if (!i)
494
+ return { name: e.trim(), type: "", optional: !1, literals: [] };
495
+ const r = i[3].replace(/\s*=\s*[^=]*$/, "").trim();
496
+ return {
497
+ name: i[1],
498
+ optional: !!i[2],
499
+ type: r,
500
+ literals: Pt(r, s)
501
+ };
502
+ }) : [];
503
+ }
504
+ function tt(n) {
505
+ const s = n.replace(/\[\]/g, "").replace(/<[^>]*>/g, "").replace(/\s*\|\s*null\s*/g, "").trim(), o = new RegExp(`^(${U})$`).exec(s);
506
+ return o ? o[1] : null;
507
+ }
508
+ function qt(n) {
509
+ const s = n.trim();
417
510
  if (!s || s.endsWith(";")) return !1;
418
- const a = (s.match(/[(<[{]/g) ?? []).length, t = (s.match(/[)>\]}]/g) ?? []).length;
419
- return /[|&,(<]\s*$/.test(s) || a > t;
511
+ const o = (s.match(/[(<[{]/g) ?? []).length, e = (s.match(/[)>\]}]/g) ?? []).length;
512
+ return /[|&,(<]\s*$/.test(s) || o > e;
420
513
  }
421
- function Qe(l, s, a, t = 0) {
422
- return t > 6 ? l : l.map((o) => {
423
- if (o.kind !== "property" || !o.detail) return o;
424
- const c = Xe(o.detail), u = c ? s.get(c) : void 0;
425
- if (!u || a.has(u.label)) return o;
426
- const d = new Set(a);
427
- return d.add(u.label), {
428
- ...o,
429
- type: u.type,
430
- members: Qe(u.members, s, d, t + 1)
514
+ function nt(n, s, o, e = 0) {
515
+ return e > 6 ? n : n.map((i) => {
516
+ if (i.kind !== "property" || !i.detail) return i;
517
+ const r = tt(i.detail), d = r ? s.get(r) : void 0;
518
+ if (!d || o.has(d.label)) return i;
519
+ const u = new Set(o);
520
+ return u.add(d.label), {
521
+ ...i,
522
+ type: d.type,
523
+ members: nt(d.members, s, u, e + 1)
431
524
  };
432
525
  });
433
526
  }
434
- const zt = 50, le = /* @__PURE__ */ new Map();
435
- function jt(l) {
436
- if (!l || !l.trim()) return [];
437
- const s = le.get(l);
527
+ const Kt = 50, le = /* @__PURE__ */ new Map(), Zt = { items: [], signatures: /* @__PURE__ */ new Map() };
528
+ function lt(n) {
529
+ if (!n || !n.trim()) return Zt;
530
+ const s = le.get(n);
438
531
  if (s) return s;
439
- const a = Dt(l);
440
- if (le.size >= zt) {
441
- const t = le.keys().next().value;
442
- t !== void 0 && le.delete(t);
532
+ const o = Jt(n);
533
+ if (le.size >= Kt) {
534
+ const e = le.keys().next().value;
535
+ e !== void 0 && le.delete(e);
443
536
  }
444
- return le.set(l, a), a;
537
+ return le.set(n, o), o;
445
538
  }
446
- function Dt(l) {
447
- const s = l.split(`
448
- `), a = /* @__PURE__ */ new Map(), t = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?interface\\s+(${Z})`), o = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?(?:abstract\\s+)?class\\s+(${Z})`), c = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?type\\s+(${Z})\\s*=`);
449
- let u = [], d = !1;
450
- for (let g = 0; g < s.length; g++) {
451
- const b = s[g].trim();
452
- if (d) {
453
- u.push(b), b.includes("*/") && (d = !1);
539
+ function Ut(n) {
540
+ return lt(n).items;
541
+ }
542
+ function Yt(n) {
543
+ return lt(n).signatures;
544
+ }
545
+ function Jt(n) {
546
+ const s = n.split(`
547
+ `), o = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), i = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?interface\\s+(${U})`), r = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?(?:abstract\\s+)?class\\s+(${U})`), d = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?type\\s+(${U})\\s*=`);
548
+ let u = [], a = !1;
549
+ for (let b = 0; b < s.length; b++) {
550
+ const y = s[b].trim();
551
+ if (a) {
552
+ u.push(y), y.includes("*/") && (a = !1);
454
553
  continue;
455
554
  }
456
- if (b.startsWith("/*")) {
457
- u.push(b), b.includes("*/") || (d = !0);
555
+ if (y.startsWith("/*")) {
556
+ u.push(y), y.includes("*/") || (a = !0);
458
557
  continue;
459
558
  }
460
- if (b.startsWith("//")) {
461
- u.push(b);
559
+ if (y.startsWith("//")) {
560
+ u.push(y);
462
561
  continue;
463
562
  }
464
- if (!b) {
563
+ if (!y) {
465
564
  u = [];
466
565
  continue;
467
566
  }
468
- const H = t.exec(b);
469
- if (H && b.includes("{")) {
470
- const w = U(u);
567
+ const O = i.exec(y);
568
+ if (O && y.includes("{")) {
569
+ const w = J(u);
471
570
  u = [];
472
- const { end: y, body: T } = Pe(s, g), k = H[1];
473
- a.set(k, {
474
- label: k,
571
+ const { end: T, body: _ } = Ve(s, b), g = O[1];
572
+ o.set(g, {
573
+ label: g,
475
574
  type: Ke(
476
- s.slice(g, y + 1).join(`
575
+ s.slice(b, T + 1).join(`
477
576
  `).replace(/^\s*export\s+/, "")
478
577
  ),
479
- members: Ze(T),
578
+ members: Ze(_),
480
579
  kind: "interface",
481
580
  documentation: w || void 0
482
- }), ne(s, y), g = y;
581
+ }), ne(s, T), b = T;
483
582
  continue;
484
583
  }
485
- const O = o.exec(b);
486
- if (O && b.includes("{")) {
487
- const w = U(u);
584
+ const B = r.exec(y);
585
+ if (B && y.includes("{")) {
586
+ const w = J(u);
488
587
  u = [];
489
- const { end: y, body: T } = Pe(s, g), k = O[1];
490
- a.set(k, {
491
- label: k,
588
+ const { end: T, body: _ } = Ve(s, b), g = B[1];
589
+ o.set(g, {
590
+ label: g,
492
591
  type: Ke(
493
- s.slice(g, y + 1).join(`
592
+ s.slice(b, T + 1).join(`
494
593
  `).replace(/^\s*export\s+/, "")
495
594
  ),
496
- members: Ze(T),
595
+ members: Ze(_),
497
596
  kind: "class",
498
597
  documentation: w || void 0
499
- }), ne(s, y), g = y;
598
+ }), ne(s, T), b = T;
500
599
  continue;
501
600
  }
502
- const A = c.exec(b);
503
- if (A) {
504
- const w = U(u);
601
+ const M = d.exec(y);
602
+ if (M) {
603
+ const w = J(u);
505
604
  u = [];
506
- const y = [s[g]];
507
- let T = g;
508
- for (; Nt(y.join(`
509
- `)) && T + 1 < s.length; )
510
- T++, y.push(s[T]);
511
- const k = y.join(`
605
+ const T = [s[b]];
606
+ let _ = b;
607
+ for (; qt(T.join(`
608
+ `)) && _ + 1 < s.length; )
609
+ _++, T.push(s[_]);
610
+ const g = T.join(`
512
611
  `).replace(/^\s*export\s+/, "").replace(/;\s*$/, "").trim();
513
- a.set(A[1], {
514
- label: A[1],
515
- type: k,
612
+ o.set(M[1], {
613
+ label: M[1],
614
+ type: g,
516
615
  members: [],
517
616
  kind: "type",
518
- documentation: w || void 0
519
- }), ne(s, T), g = T;
617
+ documentation: w || void 0,
618
+ literals: et(g)
619
+ }), ne(s, _), b = _;
520
620
  continue;
521
621
  }
522
622
  u = [];
523
623
  }
524
- const i = [], p = /* @__PURE__ */ new Set(), M = new RegExp(
525
- `^(?:export\\s+)?(?:declare\\s+)?function\\s+(${Z})\\s*\\(([^)]*)\\)\\s*:\\s*([^;{]+)`
526
- ), W = new RegExp(
527
- `^(?:export\\s+)?(?:declare\\s+)?(?:const|let|var)\\s+(${Z})\\s*:\\s*([^=;]+)`
624
+ const f = [], $ = /* @__PURE__ */ new Set(), z = new RegExp(
625
+ `^(?:export\\s+)?(?:declare\\s+)?function\\s+(${U})\\s*\\(([^)]*)\\)\\s*:\\s*([^;{]+)`
626
+ ), C = new RegExp(
627
+ `^(?:export\\s+)?(?:declare\\s+)?(?:const|let|var)\\s+(${U})\\s*:\\s*([^=;]+)`
528
628
  );
529
- u = [], d = !1;
530
- for (let g = 0; g < s.length; g++) {
531
- const b = s[g].trim();
532
- if (d) {
533
- u.push(b), b.includes("*/") && (d = !1);
629
+ u = [], a = !1;
630
+ for (let b = 0; b < s.length; b++) {
631
+ const y = s[b].trim();
632
+ if (a) {
633
+ u.push(y), y.includes("*/") && (a = !1);
534
634
  continue;
535
635
  }
536
- if (b.startsWith("/*")) {
537
- u.push(b), b.includes("*/") || (d = !0);
636
+ if (y.startsWith("/*")) {
637
+ u.push(y), y.includes("*/") || (a = !0);
538
638
  continue;
539
639
  }
540
- if (b.startsWith("//")) {
541
- u.push(b);
640
+ if (y.startsWith("//")) {
641
+ u.push(y);
542
642
  continue;
543
643
  }
544
- if (!b) {
644
+ if (!y) {
545
645
  u = [];
546
646
  continue;
547
647
  }
548
- const H = M.exec(b);
549
- if (H) {
550
- ne(s, g);
551
- const A = U(u);
648
+ const O = z.exec(y);
649
+ if (O) {
650
+ ne(s, b);
651
+ const M = J(u);
552
652
  u = [];
553
- const w = H[1];
554
- p.has(w) || (p.add(w), i.push({
653
+ const w = O[1];
654
+ $.has(w) || ($.add(w), f.push({
555
655
  label: w,
556
656
  kind: "function",
557
- detail: `(${H[2].trim()}) => ${H[3].trim()}`,
558
- documentation: A || void 0
559
- }));
657
+ detail: `(${O[2].trim()}) => ${O[3].trim()}`,
658
+ documentation: M || void 0
659
+ })), e.set(w, { name: w, params: Vt(O[2], o) });
560
660
  continue;
561
661
  }
562
- const O = W.exec(b);
563
- if (O) {
564
- ne(s, g);
565
- const A = U(u);
662
+ const B = C.exec(y);
663
+ if (B) {
664
+ ne(s, b);
665
+ const M = J(u);
566
666
  u = [];
567
- const w = O[1];
568
- if (p.has(w)) continue;
569
- p.add(w);
570
- const y = O[2].trim(), T = Xe(y), k = T ? a.get(T) : void 0, $ = (k == null ? void 0 : k.kind) === "class" ? "class" : /^\(|=>/.test(y) ? "function" : "variable";
571
- i.push({
667
+ const w = B[1];
668
+ if ($.has(w)) continue;
669
+ $.add(w);
670
+ const T = B[2].trim(), _ = tt(T), g = _ ? o.get(_) : void 0, ie = (g == null ? void 0 : g.kind) === "class" ? "class" : /^\(|=>/.test(T) ? "function" : "variable";
671
+ f.push({
572
672
  label: w,
573
- kind: $,
574
- detail: y,
575
- type: k == null ? void 0 : k.type,
576
- documentation: A || (k == null ? void 0 : k.documentation) || void 0,
577
- members: k ? Qe(k.members, a, /* @__PURE__ */ new Set([k.label])) : void 0
673
+ kind: ie,
674
+ detail: T,
675
+ type: g == null ? void 0 : g.type,
676
+ documentation: M || (g == null ? void 0 : g.documentation) || void 0,
677
+ members: g ? nt(g.members, o, /* @__PURE__ */ new Set([g.label])) : void 0
578
678
  });
579
679
  continue;
580
680
  }
581
681
  u = [];
582
682
  }
583
- return i;
683
+ return { items: f, signatures: e };
584
684
  }
585
- function ve(l, s, a, t) {
586
- if (!a || !t) return null;
587
- const o = Math.max(0, s - 1), c = l.lastIndexOf(a, o);
588
- if (c === -1 || l.lastIndexOf(t, o) > c) return null;
589
- const d = l.indexOf(t, c + a.length);
685
+ function ke(n, s, o, e) {
686
+ if (!o || !e) return null;
687
+ const i = Math.max(0, s - 1), r = n.lastIndexOf(o, i);
688
+ if (r === -1 || n.lastIndexOf(e, i) > r) return null;
689
+ const u = n.indexOf(e, r + o.length);
590
690
  return {
591
- start: c + a.length,
592
- end: d === -1 ? l.length : d
691
+ start: r + o.length,
692
+ end: u === -1 ? n.length : u
593
693
  };
594
694
  }
595
- function dn(l, s, a, t) {
596
- return ve(l, s, a, t) !== null;
695
+ function wn(n, s, o, e) {
696
+ return ke(n, s, o, e) !== null;
597
697
  }
598
- const qe = /[A-Za-z_$]/, Wt = /[\w$]/, Ue = /\s/;
599
- function se(l, s) {
600
- const a = [], t = l.length;
601
- let o = 0;
602
- for (; o < t; ) {
603
- const c = l[o], u = l[o + 1];
604
- if (Ue.test(c)) {
605
- o++;
698
+ const Ue = /[A-Za-z_$]/, Xt = /[\w$]/, Ye = /\s/;
699
+ function ce(n, s) {
700
+ const o = [], e = n.length;
701
+ let i = 0;
702
+ for (; i < e; ) {
703
+ const r = n[i], d = n[i + 1];
704
+ if (Ye.test(r)) {
705
+ i++;
606
706
  continue;
607
707
  }
608
- if (c === "/" && u === "/") {
609
- let i = l.indexOf(`
610
- `, o);
611
- i === -1 && (i = t), a.push({ start: o, end: i, type: "comment" }), o = i;
708
+ if (r === "/" && d === "/") {
709
+ let a = n.indexOf(`
710
+ `, i);
711
+ a === -1 && (a = e), o.push({ start: i, end: a, type: "comment" }), i = a;
612
712
  continue;
613
713
  }
614
- if (c === "/" && u === "*") {
615
- const i = l.indexOf("*/", o + 2), p = i === -1 ? t : i + 2;
616
- a.push({ start: o, end: p, type: "comment" }), o = p;
714
+ if (r === "/" && d === "*") {
715
+ const a = n.indexOf("*/", i + 2), f = a === -1 ? e : a + 2;
716
+ o.push({ start: i, end: f, type: "comment" }), i = f;
617
717
  continue;
618
718
  }
619
- if (c === '"' || c === "'") {
620
- let i = o + 1;
621
- for (; i < t; ) {
622
- if (l[i] === "\\") {
623
- i += 2;
719
+ if (r === '"' || r === "'") {
720
+ let a = i + 1;
721
+ for (; a < e; ) {
722
+ if (n[a] === "\\") {
723
+ a += 2;
624
724
  continue;
625
725
  }
626
- if (l[i] === `
726
+ if (n[a] === `
627
727
  `) break;
628
- if (l[i] === c) {
629
- i++;
728
+ if (n[a] === r) {
729
+ a++;
630
730
  break;
631
731
  }
632
- i++;
732
+ a++;
633
733
  }
634
- a.push({ start: o, end: i, type: "string" }), o = i;
734
+ o.push({ start: i, end: a, type: "string" }), i = a;
635
735
  continue;
636
736
  }
637
- if (c === "`") {
638
- let i = o + 1;
639
- for (; i < t; ) {
640
- if (l[i] === "\\") {
641
- i += 2;
737
+ if (r === "`") {
738
+ let a = i + 1;
739
+ for (; a < e; ) {
740
+ if (n[a] === "\\") {
741
+ a += 2;
642
742
  continue;
643
743
  }
644
- if (l[i] === "`") {
645
- i++;
744
+ if (n[a] === "`") {
745
+ a++;
646
746
  break;
647
747
  }
648
- i++;
748
+ a++;
649
749
  }
650
- a.push({ start: o, end: i, type: "template" }), o = i;
750
+ o.push({ start: i, end: a, type: "template" }), i = a;
651
751
  continue;
652
752
  }
653
- if (/[0-9]/.test(c) || c === "." && /[0-9]/.test(u ?? "")) {
654
- let i = o + 1;
655
- for (; i < t && /[\w.]/.test(l[i]); ) i++;
656
- a.push({ start: o, end: i, type: "number" }), o = i;
753
+ if (/[0-9]/.test(r) || r === "." && /[0-9]/.test(d ?? "")) {
754
+ let a = i + 1;
755
+ for (; a < e && /[\w.]/.test(n[a]); ) a++;
756
+ o.push({ start: i, end: a, type: "number" }), i = a;
657
757
  continue;
658
758
  }
659
- if (qe.test(c)) {
660
- let i = o + 1;
661
- for (; i < t && Wt.test(l[i]); ) i++;
662
- const p = l.slice(o, i), M = s.keywords.has(p) ? "keyword" : s.builtins.has(p) ? "builtin" : "identifier";
663
- a.push({ start: o, end: i, type: M }), o = i;
759
+ if (Ue.test(r)) {
760
+ let a = i + 1;
761
+ for (; a < e && Xt.test(n[a]); ) a++;
762
+ const f = n.slice(i, a), $ = s.keywords.has(f) ? "keyword" : s.builtins.has(f) ? "builtin" : "identifier";
763
+ o.push({ start: i, end: a, type: $ }), i = a;
664
764
  continue;
665
765
  }
666
- let d = o + 1;
667
- for (; d < t; ) {
668
- const i = l[d];
669
- if (Ue.test(i) || qe.test(i) || /[0-9]/.test(i) || i === '"' || i === "'" || i === "`" || i === "/") break;
670
- d++;
766
+ let u = i + 1;
767
+ for (; u < e; ) {
768
+ const a = n[u];
769
+ if (Ye.test(a) || Ue.test(a) || /[0-9]/.test(a) || a === '"' || a === "'" || a === "`" || a === "/") break;
770
+ u++;
671
771
  }
672
- a.push({ start: o, end: d, type: "punctuation" }), o = d;
772
+ o.push({ start: i, end: u, type: "punctuation" }), i = u;
673
773
  }
674
- return a;
774
+ return o;
675
775
  }
676
- const Ft = {
776
+ const Gt = {
677
777
  "&": "&amp;",
678
778
  "<": "&lt;",
679
779
  ">": "&gt;"
680
780
  };
681
- function Y(l) {
682
- return l.replace(/[&<>]/g, (s) => Ft[s] ?? s);
781
+ function X(n) {
782
+ return n.replace(/[&<>]/g, (s) => Gt[s] ?? s);
683
783
  }
684
- function re(l, s, a = 0) {
685
- let t = "", o = 0;
686
- for (const c of s) {
687
- c.start > o && (t += Y(l.slice(o, c.start)));
688
- const u = Y(l.slice(c.start, c.end));
689
- t += `<span class="tok-${c.type}" data-start="${c.start + a}" data-end="${c.end + a}">${u}</span>`, o = c.end;
784
+ function ue(n, s, o = 0) {
785
+ let e = "", i = 0;
786
+ for (const r of s) {
787
+ r.start > i && (e += X(n.slice(i, r.start)));
788
+ const d = X(n.slice(r.start, r.end));
789
+ e += `<span class="tok-${r.type}" data-start="${r.start + o}" data-end="${r.end + o}">${d}</span>`, i = r.end;
690
790
  }
691
- return o < l.length && (t += Y(l.slice(o))), t;
791
+ return i < n.length && (e += X(n.slice(i))), e;
692
792
  }
693
- function Pt(l, s, a, t) {
694
- if (!a || !t) return re(l, se(l, s));
695
- let o = "", c = 0;
696
- for (; c < l.length; ) {
697
- const u = l.indexOf(a, c);
698
- if (u === -1) {
699
- o += Y(l.slice(c));
793
+ function Qt(n, s, o, e) {
794
+ if (!o || !e) return ue(n, ce(n, s));
795
+ let i = "", r = 0;
796
+ for (; r < n.length; ) {
797
+ const d = n.indexOf(o, r);
798
+ if (d === -1) {
799
+ i += X(n.slice(r));
700
800
  break;
701
801
  }
702
- o += Y(l.slice(c, u));
703
- const d = l.indexOf(t, u + a.length), i = d === -1 ? l.length : d, p = l.slice(u + a.length, i);
704
- o += `<span class="tok-brace">${Y(a)}</span>`, o += re(p, se(p, s), u + a.length), d === -1 ? c = i : (o += `<span class="tok-brace">${Y(t)}</span>`, c = d + t.length);
802
+ i += X(n.slice(r, d));
803
+ const u = n.indexOf(e, d + o.length), a = u === -1 ? n.length : u, f = n.slice(d + o.length, a);
804
+ i += `<span class="tok-brace">${X(o)}</span>`, i += ue(f, ce(f, s), d + o.length), u === -1 ? r = a : (i += `<span class="tok-brace">${X(e)}</span>`, r = u + e.length);
705
805
  }
706
- return o;
806
+ return i;
707
807
  }
708
- const Vt = {
808
+ const en = {
709
809
  key: 0,
710
810
  class: "gutter",
711
811
  "aria-hidden": "true"
712
- }, Kt = ["innerHTML"], Zt = ["value", "readonly", "placeholder"], qt = ["onMouseenter", "onClick"], Ut = { class: "popup-label" }, Yt = {
812
+ }, tn = ["innerHTML"], nn = ["value", "readonly", "placeholder"], ln = ["onMouseenter", "onClick"], on = { class: "popup-label" }, an = {
713
813
  key: 0,
714
814
  class: "popup-detail"
715
- }, Jt = { class: "hover-head" }, Gt = { class: "hover-name" }, Xt = {
815
+ }, sn = { class: "hover-head" }, rn = { class: "hover-name" }, cn = {
716
816
  key: 0,
717
817
  class: "hover-colon"
718
- }, Qt = {
818
+ }, un = {
719
819
  key: 0,
720
820
  class: "hover-type"
721
- }, en = {
821
+ }, dn = {
722
822
  key: 0,
723
823
  class: "hover-doc"
724
- }, tn = {
824
+ }, fn = {
725
825
  key: 1,
726
826
  class: "hover-def"
727
- }, nn = ["innerHTML"], ln = ["title", "aria-label"], on = {
827
+ }, pn = ["innerHTML"], mn = ["title", "aria-label"], hn = {
728
828
  key: 0,
729
829
  viewBox: "0 0 16 16",
730
830
  width: "14",
731
831
  height: "14",
732
832
  "aria-hidden": "true"
733
- }, an = {
833
+ }, gn = {
734
834
  key: 1,
735
835
  viewBox: "0 0 16 16",
736
836
  width: "14",
737
837
  height: "14",
738
838
  "aria-hidden": "true"
739
- }, sn = /* @__PURE__ */ wt({
839
+ }, bn = /* @__PURE__ */ St({
740
840
  __name: "CodeEditor",
741
841
  props: {
742
842
  modelValue: {},
@@ -758,23 +858,26 @@ const Vt = {
758
858
  collapsedHeight: { default: "34px" },
759
859
  collapseOnBlur: { type: Boolean, default: !1 },
760
860
  borderRadius: { default: "4px" },
861
+ background: { default: "" },
862
+ borderColor: { default: "" },
761
863
  minHeight: { default: "260px" }
762
864
  },
763
865
  emits: ["update:modelValue", "change", "expand", "collapse"],
764
- setup(l, { expose: s, emit: a }) {
765
- const t = l, o = a, c = {
866
+ setup(n, { expose: s, emit: o }) {
867
+ const e = n, i = o, r = {
766
868
  variable: "变量",
767
869
  function: "函数",
768
870
  property: "属性",
769
871
  class: "对象",
770
- keyword: "关键字"
771
- }, u = {
872
+ keyword: "关键字",
873
+ value: "值"
874
+ }, d = {
772
875
  "(": ")",
773
876
  "[": "]",
774
877
  "{": "}",
775
878
  '"': '"',
776
879
  "'": "'"
777
- }, d = /* @__PURE__ */ new Set([
880
+ }, u = /* @__PURE__ */ new Set([
778
881
  "ArrowLeft",
779
882
  "ArrowRight",
780
883
  "ArrowUp",
@@ -783,549 +886,578 @@ const Vt = {
783
886
  "End",
784
887
  "PageUp",
785
888
  "PageDown"
786
- ]), i = C(t.modelValue), p = C(), M = C(), W = C(), g = C(), b = C(), H = C(), O = C(), A = C([]), w = C(0), y = C(!1), T = C({ start: 0, end: 0 }), k = C({}), $ = C(null), ye = C({}), et = V(
787
- () => t.tsTypes ? jt(t.tsTypes) : []
788
- ), ke = V(() => [
789
- ...St,
790
- ...et.value,
791
- ...t.completions
792
- ]), ce = V(
793
- () => t.mode === "template" ? [...t.templateCompletions, ...ke.value] : ke.value
794
- ), tt = V(() => {
795
- const e = {
796
- keywords: je(t.language),
797
- builtins: new Set(ce.value.map((n) => n.label))
889
+ ]), a = E(e.modelValue), f = E(), $ = E(), z = E(), C = E(), b = E(), y = E(), O = E(), B = E([]), M = E(0), w = E(!1), T = E({ start: 0, end: 0 }), _ = E({}), g = E(null), ie = E({}), it = K(
890
+ () => e.tsTypes ? Ut(e.tsTypes) : []
891
+ ), ot = K(
892
+ () => e.tsTypes ? Yt(e.tsTypes) : /* @__PURE__ */ new Map()
893
+ ), we = K(() => [
894
+ ...It,
895
+ ...it.value,
896
+ ...e.completions
897
+ ]), de = K(
898
+ () => e.mode === "template" ? [...e.templateCompletions, ...we.value] : we.value
899
+ ), at = K(() => {
900
+ const t = {
901
+ keywords: De(e.language),
902
+ builtins: new Set(de.value.map((l) => l.label))
798
903
  };
799
- return t.mode === "template" ? `${Pt(i.value, e, t.templateOpen, t.templateClose)}
800
- ` : `${re(i.value, se(i.value, e))}
904
+ return e.mode === "template" ? `${Qt(a.value, t, e.templateOpen, e.templateClose)}
905
+ ` : `${ue(a.value, ce(a.value, t))}
801
906
  `;
802
- }), nt = V(() => i.value.split(`
803
- `).length), N = C(t.defaultExpanded), ue = C(!1), de = V(() => t.collapsible && !N.value), lt = V(() => {
804
- const e = {};
805
- return t.collapsible && (e.height = t.collapsedHeight), e;
806
- }), ot = V(() => {
807
- const e = {
808
- "--ce-radius": t.borderRadius,
809
- "--ce-collapsed-height": t.collapsedHeight
907
+ }), st = K(() => a.value.split(`
908
+ `).length), F = E(e.defaultExpanded), fe = E(!1), pe = K(() => e.collapsible && !F.value), rt = K(() => {
909
+ const t = {};
910
+ return e.collapsible && (t.height = e.collapsedHeight), t;
911
+ }), ct = K(() => {
912
+ const t = {
913
+ "--ce-radius": e.borderRadius,
914
+ "--ce-collapsed-height": e.collapsedHeight
810
915
  };
811
- return t.collapsible ? { ...e, height: N.value ? t.minHeight : t.collapsedHeight } : { ...e, height: t.minHeight };
916
+ return e.background && (t["--ce-bg"] = e.background), e.borderColor && (t["--ce-border"] = e.borderColor), e.collapsible ? { ...t, height: F.value ? e.minHeight : e.collapsedHeight } : { ...t, height: e.minHeight };
812
917
  });
813
918
  let xe = 0;
814
- function we(e) {
815
- if (N.value === e) return;
816
- const n = p.value;
817
- e && n && (xe = n.scrollTop), N.value = e, t.collapsible && (ue.value = !0), o(e ? "expand" : "collapse"), I(), L(), j(() => {
818
- if (fe(), !N.value && n) {
819
- const r = Math.max(0, n.scrollHeight - n.clientHeight);
820
- n.scrollTop = Math.max(0, Math.min(xe, r)), z(!0), document.activeElement === n && G();
919
+ function $e(t) {
920
+ if (F.value === t) return;
921
+ const l = f.value;
922
+ t && l && (xe = l.scrollTop), F.value = t, e.collapsible && (fe.value = !0), i(t ? "expand" : "collapse"), H(), j(), V(() => {
923
+ if (me(), !F.value && l) {
924
+ const c = Math.max(0, l.scrollHeight - l.clientHeight);
925
+ l.scrollTop = Math.max(0, Math.min(xe, c)), P(!0), document.activeElement === l && G();
821
926
  return;
822
927
  }
823
- z(!0), e && t.collapseOnBlur && n && document.activeElement !== n && n.focus();
928
+ P(!0), t && e.collapseOnBlur && l && document.activeElement !== l && l.focus();
824
929
  });
825
930
  }
826
- function it() {
827
- ue.value = !1;
931
+ function ut() {
932
+ fe.value = !1;
828
933
  }
829
- function at() {
830
- we(!N.value);
934
+ function dt() {
935
+ $e(!F.value);
831
936
  }
832
937
  Be(
833
- () => t.modelValue,
834
- (e) => {
835
- e !== i.value && (i.value = e, I());
938
+ () => e.modelValue,
939
+ (t) => {
940
+ t !== a.value && (a.value = t, H());
836
941
  }
837
- ), Be(i, () => {
838
- j(() => z(!0));
942
+ ), Be(a, () => {
943
+ V(() => P(!0));
839
944
  });
840
- function $e(e) {
841
- return c[e];
945
+ function Te(t) {
946
+ return r[t];
842
947
  }
843
- function st(e) {
844
- return e ? re(
845
- e,
846
- se(e, { keywords: je("typescript"), builtins: /* @__PURE__ */ new Set() })
948
+ function ft(t) {
949
+ return t ? ue(
950
+ t,
951
+ ce(t, { keywords: De("typescript"), builtins: /* @__PURE__ */ new Set() })
847
952
  ) : "";
848
953
  }
849
- let J = { top: 14, bottom: 14, lineHeight: 22 };
850
- function fe() {
851
- const e = p.value;
852
- if (!e) return;
853
- const n = window.getComputedStyle(e);
854
- J = {
855
- top: parseFloat(n.paddingTop) || 0,
856
- bottom: parseFloat(n.paddingBottom) || 0,
857
- lineHeight: parseFloat(n.lineHeight) || 22
954
+ let D = { top: 14, bottom: 14, left: 16, right: 16, lineHeight: 22 };
955
+ function me() {
956
+ const t = f.value;
957
+ if (!t) return;
958
+ const l = window.getComputedStyle(t);
959
+ D = {
960
+ top: parseFloat(l.paddingTop) || 0,
961
+ bottom: parseFloat(l.paddingBottom) || 0,
962
+ left: parseFloat(l.paddingLeft) || 0,
963
+ right: parseFloat(l.paddingRight) || 0,
964
+ lineHeight: parseFloat(l.lineHeight) || 22
858
965
  };
859
966
  }
860
- function z(e = !1) {
861
- const n = p.value;
862
- if (!n) return;
863
- const r = g.value;
864
- if (r && (r.style.transform = `translate(${-n.scrollLeft}px, ${-n.scrollTop}px)`), b.value && (b.value.style.transform = `translateY(${-n.scrollTop}px)`), e) {
865
- const m = `${i.value}|${t.mode}|${n.clientWidth}|${n.clientHeight}`;
866
- m !== Te && (Te = m, rt());
967
+ function P(t = !1) {
968
+ const l = f.value;
969
+ if (!l) return;
970
+ const c = C.value;
971
+ if (c && (c.style.transform = `translate(${-l.scrollLeft}px, ${-l.scrollTop}px)`), b.value && (b.value.style.transform = `translateY(${-l.scrollTop}px)`), t) {
972
+ const m = `${a.value}|${e.mode}|${l.clientWidth}|${l.clientHeight}`;
973
+ m !== Se && (Se = m, pt());
867
974
  }
868
975
  }
869
976
  function G() {
870
- const e = p.value;
871
- if (!e || !de.value) return;
872
- const n = Se();
873
- if (!n) return;
874
- const r = e.clientHeight - J.top - J.bottom, h = n.top + e.scrollTop - J.top - Math.max(0, (r - n.lineHeight) / 2), f = Math.max(0, e.scrollHeight - e.clientHeight), v = Math.max(0, Math.min(h, f));
875
- Math.abs(v - e.scrollTop) > 0.5 && (e.scrollTop = v, z());
876
- }
877
- let Ce = [], Te = "", oe = 0, pe = -1, me = -1, he = { x: 0, y: 0 };
878
- function rt() {
879
- const e = p.value, n = W.value;
880
- if (!e || !n) return;
881
- const r = e.getBoundingClientRect(), m = [];
882
- n.querySelectorAll("[data-start]").forEach((h) => {
883
- const f = h.getBoundingClientRect();
977
+ const t = f.value;
978
+ if (!t) return;
979
+ const l = Ee();
980
+ if (!l) return;
981
+ let c = t.scrollTop;
982
+ if (pe.value) {
983
+ const q = t.clientHeight - D.top - D.bottom, W = l.top + t.scrollTop - D.top - Math.max(0, (q - l.lineHeight) / 2), se = Math.max(0, t.scrollHeight - t.clientHeight);
984
+ c = Math.max(0, Math.min(W, se));
985
+ }
986
+ const m = t.clientWidth - D.left - D.right, h = l.left + t.scrollLeft, p = t.scrollLeft + D.left, x = t.scrollLeft + D.left + m, k = 8;
987
+ let v = t.scrollLeft;
988
+ h < p + k ? v = Math.max(0, h - D.left - k) : h > x - k && (v = Math.max(0, h - D.left - m + k));
989
+ const S = Math.abs(c - t.scrollTop) > 0.5, R = Math.abs(v - t.scrollLeft) > 0.5;
990
+ !S && !R || (S && (t.scrollTop = c), R && (t.scrollLeft = v), P());
991
+ }
992
+ let Ce = [], Se = "", oe = 0, he = -1, ge = -1, be = { x: 0, y: 0 };
993
+ function pt() {
994
+ const t = f.value, l = z.value;
995
+ if (!t || !l) return;
996
+ const c = t.getBoundingClientRect(), m = [];
997
+ l.querySelectorAll("[data-start]").forEach((h) => {
998
+ const p = h.getBoundingClientRect();
884
999
  m.push({
885
1000
  start: Number(h.dataset.start),
886
1001
  end: Number(h.dataset.end),
887
- left: f.left - r.left + e.scrollLeft,
888
- right: f.right - r.left + e.scrollLeft,
889
- top: f.top - r.top + e.scrollTop,
890
- bottom: f.bottom - r.top + e.scrollTop
1002
+ left: p.left - c.left + t.scrollLeft,
1003
+ right: p.right - c.left + t.scrollLeft,
1004
+ top: p.top - c.top + t.scrollTop,
1005
+ bottom: p.bottom - c.top + t.scrollTop
891
1006
  });
892
1007
  }), Ce = m;
893
1008
  }
894
- function ct(e, n) {
895
- for (const r of Ce)
896
- if (e >= r.left - 1 && e <= r.right + 1 && n >= r.top && n <= r.bottom)
897
- return r;
1009
+ function mt(t, l) {
1010
+ for (const c of Ce)
1011
+ if (t >= c.left - 1 && t <= c.right + 1 && l >= c.top && l <= c.bottom)
1012
+ return c;
898
1013
  return null;
899
1014
  }
900
- function L() {
901
- $.value = null, oe = 0, pe = -1, me = -1;
1015
+ function j() {
1016
+ g.value = null, oe = 0, he = -1, ge = -1;
902
1017
  }
903
- function ut(e) {
904
- const n = O.value, r = p.value;
905
- if (!n || !r) return;
906
- const m = r.getBoundingClientRect(), h = m.left + e.left - r.scrollLeft, f = m.left + e.right - r.scrollLeft, v = m.top + e.top - r.scrollTop, x = m.top + e.bottom - r.scrollTop, _ = 12, B = 8, F = n.offsetWidth, Q = n.offsetHeight;
907
- let P = h, q = x + B;
908
- P + F > window.innerWidth - _ && (P = f - F), q + Q > window.innerHeight - _ && (q = v - Q - B), P = Math.max(_, Math.min(P, window.innerWidth - _ - F)), q = Math.max(_, q), ye.value = { left: `${P}px`, top: `${q}px` };
1018
+ function ht(t) {
1019
+ const l = O.value, c = f.value;
1020
+ if (!l || !c) return;
1021
+ const m = c.getBoundingClientRect(), h = m.left + t.left - c.scrollLeft, p = m.left + t.right - c.scrollLeft, x = m.top + t.top - c.scrollTop, k = m.top + t.bottom - c.scrollTop, v = 12, S = 8, R = l.offsetWidth, q = l.offsetHeight;
1022
+ let N = h, W = k + S;
1023
+ N + R > window.innerWidth - v && (N = p - R), W + q > window.innerHeight - v && (W = x - q - S), N = Math.max(v, Math.min(N, window.innerWidth - v - R)), W = Math.max(v, W), ie.value = { left: `${N}px`, top: `${W}px` };
909
1024
  }
910
- function dt(e, n) {
911
- const r = p.value;
912
- if (!r || t.readonly || !t.hover || y.value) {
913
- L();
1025
+ function gt(t, l) {
1026
+ const c = f.value;
1027
+ if (!c || e.readonly || !e.hover || w.value) {
1028
+ j();
914
1029
  return;
915
1030
  }
916
- if (r.selectionStart !== r.selectionEnd) {
917
- L();
1031
+ if (c.selectionStart !== c.selectionEnd) {
1032
+ j();
918
1033
  return;
919
1034
  }
920
1035
  const m = O.value;
921
- if ($.value && m) {
922
- const x = m.getBoundingClientRect();
923
- if (e >= x.left && e <= x.right && n >= x.top && n <= x.bottom)
1036
+ if (g.value && m) {
1037
+ const k = m.getBoundingClientRect();
1038
+ if (t >= k.left && t <= k.right && l >= k.top && l <= k.bottom)
924
1039
  return;
925
1040
  }
926
- const h = r.getBoundingClientRect(), f = ct(e - h.left + r.scrollLeft, n - h.top + r.scrollTop);
927
- if (!f) {
928
- L();
1041
+ const h = c.getBoundingClientRect(), p = mt(t - h.left + c.scrollLeft, l - h.top + c.scrollTop);
1042
+ if (!p) {
1043
+ j();
929
1044
  return;
930
1045
  }
931
- if ($.value && pe === f.start && me === f.end)
1046
+ if (g.value && he === p.start && ge === p.end)
932
1047
  return;
933
- const v = Lt(r.value, f.start, f.end, {
934
- completions: ce.value,
935
- declared: We(r.value, f.start)
1048
+ const x = Dt(c.value, p.start, p.end, {
1049
+ completions: de.value,
1050
+ declared: Fe(c.value, p.start)
936
1051
  });
937
- if (!v) {
938
- L();
1052
+ if (!x) {
1053
+ j();
939
1054
  return;
940
1055
  }
941
- $.value = v, pe = f.start, me = f.end, j(() => ut(f));
1056
+ g.value = x, he = p.start, ge = p.end, V(() => ht(p));
942
1057
  }
943
- function ft(e) {
944
- he = { x: e.clientX, y: e.clientY }, !oe && (oe = requestAnimationFrame(() => {
945
- oe = 0, dt(he.x, he.y);
1058
+ function bt(t) {
1059
+ be = { x: t.clientX, y: t.clientY }, !oe && (oe = requestAnimationFrame(() => {
1060
+ oe = 0, gt(be.x, be.y);
946
1061
  }));
947
1062
  }
948
- function Se() {
949
- const e = p.value;
950
- if (!e) return null;
951
- const n = window.getComputedStyle(e), r = document.createElement("div"), m = parseFloat(n.paddingLeft) || 0, h = parseFloat(n.paddingRight) || 0, f = e.getBoundingClientRect();
952
- Object.assign(r.style, {
1063
+ function Ee() {
1064
+ const t = f.value;
1065
+ if (!t) return null;
1066
+ const l = window.getComputedStyle(t), c = document.createElement("div"), m = parseFloat(l.paddingLeft) || 0, h = parseFloat(l.paddingRight) || 0, p = t.getBoundingClientRect();
1067
+ Object.assign(c.style, {
953
1068
  position: "fixed",
954
- left: `${f.left}px`,
955
- top: `${f.top}px`,
1069
+ left: `${p.left}px`,
1070
+ top: `${p.top}px`,
956
1071
  visibility: "hidden",
957
1072
  pointerEvents: "none",
958
1073
  zIndex: "-1",
959
- whiteSpace: "pre-wrap",
960
- overflowWrap: "break-word",
961
- wordBreak: "normal",
1074
+ whiteSpace: l.whiteSpace,
1075
+ overflowWrap: l.overflowWrap,
1076
+ wordBreak: l.wordBreak,
962
1077
  boxSizing: "content-box",
963
- width: `${e.clientWidth - m - h}px`,
964
- paddingTop: n.paddingTop,
965
- paddingRight: n.paddingRight,
966
- paddingBottom: n.paddingBottom,
967
- paddingLeft: n.paddingLeft,
1078
+ width: `${t.clientWidth - m - h}px`,
1079
+ paddingTop: l.paddingTop,
1080
+ paddingRight: l.paddingRight,
1081
+ paddingBottom: l.paddingBottom,
1082
+ paddingLeft: l.paddingLeft,
968
1083
  border: "0",
969
- fontFamily: n.fontFamily,
970
- fontSize: n.fontSize,
971
- fontWeight: n.fontWeight,
972
- fontStyle: n.fontStyle,
973
- fontVariant: n.fontVariant,
974
- letterSpacing: n.letterSpacing,
975
- lineHeight: n.lineHeight,
976
- textTransform: n.textTransform,
977
- tabSize: n.tabSize
978
- }), r.textContent = e.value.slice(0, e.selectionStart);
979
- const v = document.createElement("span");
980
- v.textContent = "​", r.appendChild(v), document.body.appendChild(r);
981
- const x = v.getBoundingClientRect();
982
- document.body.removeChild(r);
983
- const _ = parseFloat(n.lineHeight) || 22, B = x.height, F = B > 0 && B < _ ? (_ - B) / 2 : 0;
1084
+ fontFamily: l.fontFamily,
1085
+ fontSize: l.fontSize,
1086
+ fontWeight: l.fontWeight,
1087
+ fontStyle: l.fontStyle,
1088
+ fontVariant: l.fontVariant,
1089
+ letterSpacing: l.letterSpacing,
1090
+ lineHeight: l.lineHeight,
1091
+ textTransform: l.textTransform,
1092
+ tabSize: l.tabSize
1093
+ }), c.textContent = t.value.slice(0, t.selectionStart);
1094
+ const x = document.createElement("span");
1095
+ x.textContent = "​", c.appendChild(x), document.body.appendChild(c);
1096
+ const k = x.getBoundingClientRect();
1097
+ document.body.removeChild(c);
1098
+ const v = parseFloat(l.lineHeight) || 22, S = k.height, R = S > 0 && S < v ? (v - S) / 2 : 0;
984
1099
  return {
985
- left: x.left - f.left - e.scrollLeft,
986
- top: x.top - f.top - e.scrollTop - F,
987
- lineHeight: _
1100
+ left: k.left - p.left - t.scrollLeft,
1101
+ top: k.top - p.top - t.scrollTop - R,
1102
+ lineHeight: v
988
1103
  };
989
1104
  }
990
- async function pt() {
991
- await j();
992
- const e = M.value, n = H.value, r = Se();
993
- if (!e || !n || !r) return;
994
- const m = 4, h = 8, f = window.innerWidth, v = window.innerHeight, x = e.getBoundingClientRect(), _ = n.scrollHeight, B = v - (x.top + r.top + r.lineHeight) - m - h, F = x.top + r.top - m - h, Q = B >= Math.min(_, 180) || B >= F, P = Math.min(248, Math.max(Q ? B : F, 96)), q = Math.min(_, P), Ae = n.offsetWidth || 280;
995
- let ee = r.left;
996
- x.left + ee + Ae > f - h && (ee = f - h - Ae - x.left), ee = Math.max(ee, h - x.left), k.value = {
1105
+ async function Me() {
1106
+ await V();
1107
+ const t = $.value, l = y.value, c = Ee();
1108
+ if (!t || !l || !c) return;
1109
+ const m = 4, h = 8, p = window.innerWidth, x = window.innerHeight, k = t.getBoundingClientRect(), v = l.scrollHeight, S = x - (k.top + c.top + c.lineHeight) - m - h, R = k.top + c.top - m - h, q = S >= Math.min(v, 180) || S >= R, N = Math.min(248, Math.max(q ? S : R, 96)), W = Math.min(v, N), se = l.offsetWidth || 280;
1110
+ let ee = c.left;
1111
+ k.left + ee + se > p - h && (ee = p - h - se - k.left), ee = Math.max(ee, h - k.left), _.value = {
997
1112
  left: `${ee}px`,
998
- top: `${Q ? r.top + r.lineHeight + m : r.top - m - q}px`,
999
- maxHeight: `${P}px`
1113
+ top: `${q ? c.top + c.lineHeight + m : c.top - m - W}px`,
1114
+ maxHeight: `${N}px`
1000
1115
  };
1001
1116
  }
1002
- function I() {
1003
- y.value = !1, A.value = [], w.value = 0, L();
1117
+ function H() {
1118
+ w.value = !1, B.value = [], M.value = 0, j();
1004
1119
  }
1005
- function X(e = !1) {
1006
- const n = p.value;
1007
- if (!n || t.readonly) return;
1008
- if (n.selectionStart !== n.selectionEnd) {
1009
- I();
1120
+ function Q(t = !1) {
1121
+ var k;
1122
+ const l = f.value;
1123
+ if (!l || e.readonly) return;
1124
+ if (l.selectionStart !== l.selectionEnd) {
1125
+ H();
1010
1126
  return;
1011
1127
  }
1012
- const r = n.selectionStart;
1013
- let m = !e;
1014
- if (t.mode === "template") {
1015
- const v = ve(
1016
- n.value,
1017
- r,
1018
- t.templateOpen,
1019
- t.templateClose
1128
+ const c = l.selectionStart;
1129
+ let m = !t;
1130
+ const h = _t(l.value, c);
1131
+ if (h) {
1132
+ const v = (k = ot.value.get(h.functionName)) == null ? void 0 : k.params[h.paramIndex], S = (v == null ? void 0 : v.literals) ?? [];
1133
+ if (S.length) {
1134
+ const R = h.quote ?? "'", q = S.map((W) => ({
1135
+ label: `${R}${W}${R}`,
1136
+ kind: "value",
1137
+ detail: v == null ? void 0 : v.type,
1138
+ insertText: `${R}${W}${R}`
1139
+ })), N = Qe(q, h.prefix);
1140
+ if (N.length) {
1141
+ B.value = N, T.value = { start: h.replaceStart, end: c }, M.value = 0, w.value = !0, Me();
1142
+ return;
1143
+ }
1144
+ }
1145
+ }
1146
+ if (e.mode === "template") {
1147
+ const v = ke(
1148
+ l.value,
1149
+ c,
1150
+ e.templateOpen,
1151
+ e.templateClose
1020
1152
  );
1021
1153
  if (!v) {
1022
- I();
1154
+ H();
1023
1155
  return;
1024
1156
  }
1025
- e && n.value.slice(v.start, r).trim() === "" && (m = !0);
1157
+ t && l.value.slice(v.start, c).trim() === "" && (m = !0);
1026
1158
  }
1027
- const h = At(n.value, r, {
1028
- language: t.language,
1029
- completions: ce.value,
1030
- declared: We(n.value, r),
1159
+ const p = Wt(l.value, c, {
1160
+ language: e.language,
1161
+ completions: de.value,
1162
+ declared: Fe(l.value, c),
1031
1163
  auto: !m
1032
1164
  });
1033
- if (!h) {
1034
- I();
1165
+ if (!p) {
1166
+ H();
1035
1167
  return;
1036
1168
  }
1037
- let f = h.items;
1038
- if (t.completionFilter) {
1039
- const v = Je(n.value, r);
1040
- if (f = t.completionFilter(f, {
1169
+ let x = p.items;
1170
+ if (e.completionFilter) {
1171
+ const v = Xe(l.value, c);
1172
+ if (x = e.completionFilter(x, {
1041
1173
  prefix: v.prefix,
1042
1174
  chain: v.chain,
1043
- text: n.value,
1044
- position: r,
1045
- mode: t.mode,
1046
- language: t.language
1047
- }), f.length === 0) {
1048
- I();
1175
+ text: l.value,
1176
+ position: c,
1177
+ mode: e.mode,
1178
+ language: e.language
1179
+ }), x.length === 0) {
1180
+ H();
1049
1181
  return;
1050
1182
  }
1051
1183
  }
1052
- A.value = f, T.value = { start: h.start, end: h.end }, w.value = 0, y.value = !0, pt();
1184
+ B.value = x, T.value = { start: p.start, end: p.end }, M.value = 0, w.value = !0, Me();
1053
1185
  }
1054
- function mt(e) {
1055
- i.value = e, o("update:modelValue", e), o("change", e);
1186
+ function vt(t) {
1187
+ a.value = t, i("update:modelValue", t), i("change", t);
1056
1188
  }
1057
- function ie(e, n, r, m = e + r.length) {
1058
- const h = p.value;
1189
+ function ae(t, l, c, m = t + c.length) {
1190
+ const h = f.value;
1059
1191
  if (!h) return;
1060
- const f = h.value.slice(0, e) + r + h.value.slice(n);
1061
- mt(f), I(), j(() => {
1062
- h.value = f, h.setSelectionRange(m, m), h.focus(), z(!0), G();
1192
+ const p = h.value.slice(0, t) + c + h.value.slice(l);
1193
+ vt(p), H(), V(() => {
1194
+ h.value = p, h.setSelectionRange(m, m), h.focus(), P(!0), G();
1063
1195
  });
1064
1196
  }
1065
- function Ee(e = A.value[w.value]) {
1066
- if (!e) return;
1067
- const n = e.insertText ?? e.label;
1068
- ie(T.value.start, T.value.end, n), I();
1197
+ function Re(t = B.value[M.value]) {
1198
+ if (!t) return;
1199
+ const l = t.insertText ?? t.label;
1200
+ ae(T.value.start, T.value.end, l), H();
1069
1201
  }
1070
- function Ie(e) {
1071
- const n = A.value.length;
1072
- n && (w.value = (w.value + e + n) % n, j(() => {
1073
- var r, m;
1074
- (m = (r = H.value) == null ? void 0 : r.querySelector(".is-active")) == null || m.scrollIntoView({ block: "nearest" });
1202
+ function Ie(t) {
1203
+ const l = B.value.length;
1204
+ l && (M.value = (M.value + t + l) % l, V(() => {
1205
+ var c, m;
1206
+ (m = (c = y.value) == null ? void 0 : c.querySelector(".is-active")) == null || m.scrollIntoView({ block: "nearest" });
1075
1207
  }));
1076
1208
  }
1077
- function ht(e) {
1078
- const n = e.target;
1079
- i.value = n.value, o("update:modelValue", n.value), o("change", n.value), L(), z(), j(G), X(!0);
1209
+ function yt(t) {
1210
+ const l = t.target;
1211
+ a.value = l.value, i("update:modelValue", l.value), i("change", l.value), j(), P(), V(G), Q(!0);
1080
1212
  }
1081
- function bt(e) {
1082
- if (I(), L(), !t.collapsible || !t.collapseOnBlur || !N.value) return;
1083
- const n = e.relatedTarget;
1084
- n && n.closest(".expand-toggle") || we(!1);
1213
+ function kt(t) {
1214
+ if (H(), j(), !e.collapsible || !e.collapseOnBlur || !F.value) return;
1215
+ const l = t.relatedTarget;
1216
+ l && l.closest(".expand-toggle") || $e(!1);
1085
1217
  }
1086
- function gt() {
1087
- Re(), G();
1218
+ function wt() {
1219
+ Le(), G();
1088
1220
  }
1089
- function Re() {
1090
- const e = p.value;
1091
- if (!e || t.readonly) return;
1092
- if (e.selectionStart !== e.selectionEnd) {
1093
- I();
1221
+ function Le() {
1222
+ const t = f.value;
1223
+ if (!t || e.readonly) return;
1224
+ if (t.selectionStart !== t.selectionEnd) {
1225
+ H();
1094
1226
  return;
1095
1227
  }
1096
- const n = e.selectionStart;
1097
- if (n > 0 && e.value[n - 1] === ".") {
1098
- X(!0);
1228
+ const l = t.selectionStart;
1229
+ if (l > 0 && t.value[l - 1] === ".") {
1230
+ Q(!0);
1099
1231
  return;
1100
1232
  }
1101
- if (t.mode === "template") {
1102
- const r = ve(
1103
- e.value,
1104
- n,
1105
- t.templateOpen,
1106
- t.templateClose
1233
+ if (e.mode === "template") {
1234
+ const c = ke(
1235
+ t.value,
1236
+ l,
1237
+ e.templateOpen,
1238
+ e.templateClose
1107
1239
  );
1108
- if (r && e.value.slice(r.start, n).trim() === "") {
1109
- X(!0);
1240
+ if (c && t.value.slice(c.start, l).trim() === "") {
1241
+ Q(!0);
1110
1242
  return;
1111
1243
  }
1112
1244
  }
1113
- I();
1245
+ H();
1114
1246
  }
1115
- let be = 0;
1116
- function Me() {
1117
- window.clearTimeout(be), be = window.setTimeout(() => {
1118
- be = 0, Re(), G();
1247
+ let ve = 0;
1248
+ function _e() {
1249
+ window.clearTimeout(ve), ve = window.setTimeout(() => {
1250
+ ve = 0, Le(), G();
1119
1251
  }, 0);
1120
1252
  }
1121
- function _e(e) {
1122
- e.target !== p.value && y.value && I();
1253
+ function He(t) {
1254
+ t.target !== f.value && w.value && H();
1123
1255
  }
1124
- function vt() {
1125
- L(), z(), de.value && yt();
1256
+ function xt() {
1257
+ j(), P(), pe.value && $t();
1126
1258
  }
1127
- let ge = 0;
1128
- function yt() {
1129
- window.clearTimeout(ge), ge = window.setTimeout(() => {
1130
- ge = 0, kt();
1259
+ let ye = 0;
1260
+ function $t() {
1261
+ window.clearTimeout(ye), ye = window.setTimeout(() => {
1262
+ ye = 0, Tt();
1131
1263
  }, 120);
1132
1264
  }
1133
- function kt() {
1134
- const e = p.value;
1135
- if (!e) return;
1136
- const n = J.lineHeight, r = e.scrollTop, m = Math.round(r / n) * n;
1137
- Math.abs(m - r) < 0.5 || (e.scrollTop = m, z());
1265
+ function Tt() {
1266
+ const t = f.value;
1267
+ if (!t) return;
1268
+ const l = D.lineHeight, c = t.scrollTop, m = Math.round(c / l) * l;
1269
+ Math.abs(m - c) < 0.5 || (t.scrollTop = m, P());
1138
1270
  }
1139
- function xt(e) {
1271
+ function Ct(t) {
1140
1272
  var h;
1141
- const n = p.value;
1142
- if (!n) return;
1143
- const r = e.metaKey || e.ctrlKey, m = d.has(e.key);
1144
- if (e.key === " " && r) {
1145
- e.preventDefault(), X(!1);
1273
+ const l = f.value;
1274
+ if (!l) return;
1275
+ const c = t.metaKey || t.ctrlKey, m = u.has(t.key);
1276
+ if (t.key === " " && c) {
1277
+ t.preventDefault(), Q(!1);
1146
1278
  return;
1147
1279
  }
1148
- if (y.value) {
1149
- if (e.key === "ArrowDown") {
1150
- e.preventDefault(), Ie(1);
1280
+ if (w.value) {
1281
+ if (t.key === "ArrowDown") {
1282
+ t.preventDefault(), Ie(1);
1151
1283
  return;
1152
1284
  }
1153
- if (e.key === "ArrowUp") {
1154
- e.preventDefault(), Ie(-1);
1285
+ if (t.key === "ArrowUp") {
1286
+ t.preventDefault(), Ie(-1);
1155
1287
  return;
1156
1288
  }
1157
- if (e.key === "Enter" || e.key === "Tab") {
1158
- e.preventDefault(), Ee();
1289
+ if (t.key === "Enter" || t.key === "Tab") {
1290
+ t.preventDefault(), Re();
1159
1291
  return;
1160
1292
  }
1161
- if (e.key === "Escape") {
1162
- e.preventDefault(), I();
1293
+ if (t.key === "Escape") {
1294
+ t.preventDefault(), H();
1163
1295
  return;
1164
1296
  }
1165
- if (m || r) {
1166
- I(), m && !r && Me();
1297
+ if (m || c) {
1298
+ H(), m && !c && _e();
1167
1299
  return;
1168
1300
  }
1169
1301
  }
1170
- if (m && !r) {
1171
- Me();
1302
+ if (m && !c) {
1303
+ _e();
1172
1304
  return;
1173
1305
  }
1174
- if (e.key === "Enter" && !r && !e.shiftKey) {
1175
- const f = n.selectionStart;
1176
- if (f !== n.selectionEnd) return;
1177
- const v = n.value.lastIndexOf(`
1178
- `, f - 1) + 1, x = n.value.slice(v, f), _ = ((h = x.match(/^[ \t]*/)) == null ? void 0 : h[0]) ?? "", B = /[{[(]$/.test(x.trimEnd()) ? " " : "";
1179
- e.preventDefault(), ie(f, f, `
1180
- ${_}${B}`);
1306
+ if (t.key === "Enter" && !c && !t.shiftKey) {
1307
+ const p = l.selectionStart;
1308
+ if (p !== l.selectionEnd) return;
1309
+ const x = l.value.lastIndexOf(`
1310
+ `, p - 1) + 1, k = l.value.slice(x, p), v = ((h = k.match(/^[ \t]*/)) == null ? void 0 : h[0]) ?? "", S = /[{[(]$/.test(k.trimEnd()) ? " " : "";
1311
+ t.preventDefault(), ae(p, p, `
1312
+ ${v}${S}`);
1181
1313
  return;
1182
1314
  }
1183
- if (e.key === "Tab") {
1184
- e.preventDefault(), ie(n.selectionStart, n.selectionEnd, " ");
1315
+ if (t.key === "Tab") {
1316
+ t.preventDefault(), ae(l.selectionStart, l.selectionEnd, " ");
1185
1317
  return;
1186
1318
  }
1187
- if (e.key.length === 1 && !r && !e.altKey && u[e.key]) {
1188
- if (n.selectionStart !== n.selectionEnd) return;
1189
- const f = n.selectionStart, v = n.value[f - 1], x = n.value[f];
1190
- if ((e.key === '"' || e.key === "'") && v && /[\w$]/.test(v) || x !== void 0 && !/[\s)\]},;:]/.test(x)) return;
1191
- e.preventDefault(), ie(f, f, e.key + u[e.key], f + 1), t.mode === "template" && j(() => X(!0));
1319
+ if (t.key.length === 1 && !c && !t.altKey && d[t.key]) {
1320
+ if (l.selectionStart !== l.selectionEnd) return;
1321
+ const p = l.selectionStart, x = l.value[p - 1], k = l.value[p];
1322
+ if ((t.key === '"' || t.key === "'") && x && /[\w$]/.test(x) || k !== void 0 && !/[\s)\]},;:]/.test(k)) return;
1323
+ t.preventDefault(), ae(p, p, t.key + d[t.key], p + 1), e.mode === "template" && V(() => Q(!0));
1192
1324
  }
1193
1325
  }
1194
- function He() {
1195
- y.value && I(), L(), j(() => {
1196
- fe(), z(!0);
1326
+ function Ae() {
1327
+ w.value && H(), j(), V(() => {
1328
+ me(), P(!0);
1197
1329
  });
1198
1330
  }
1199
- return $t(() => {
1200
- window.addEventListener("resize", He), window.addEventListener("scroll", _e, !0), j(() => {
1201
- fe(), z(!0);
1331
+ return Et(() => {
1332
+ window.addEventListener("resize", Ae), window.addEventListener("scroll", He, !0), V(() => {
1333
+ me(), P(!0);
1202
1334
  });
1203
- }), Ct(() => {
1204
- window.removeEventListener("resize", He), window.removeEventListener("scroll", _e, !0);
1335
+ }), Mt(() => {
1336
+ window.removeEventListener("resize", Ae), window.removeEventListener("scroll", He, !0);
1205
1337
  }), s({ focus: () => {
1206
- var e;
1207
- return (e = p.value) == null ? void 0 : e.focus();
1208
- } }), (e, n) => (S(), E("div", {
1209
- class: te(["code-input", { "is-collapsible": l.collapsible }]),
1210
- style: ae(lt.value)
1338
+ var t;
1339
+ return (t = f.value) == null ? void 0 : t.focus();
1340
+ } }), (t, l) => (I(), L("div", {
1341
+ class: te(["code-input", { "is-collapsible": n.collapsible }]),
1342
+ style: re(rt.value)
1211
1343
  }, [
1212
- R("div", {
1344
+ A("div", {
1213
1345
  class: te(["code-editor", {
1214
- "is-readonly": l.readonly,
1215
- "is-dark": l.theme === "dark",
1216
- "is-collapsed": de.value,
1217
- "is-expanding": ue.value
1346
+ "is-readonly": n.readonly,
1347
+ "is-dark": n.theme === "dark",
1348
+ "is-collapsed": pe.value,
1349
+ "is-expanding": fe.value
1218
1350
  }]),
1219
- style: ae(ot.value),
1220
- onAnimationend: Le(it, ["self"])
1351
+ style: re(ct.value),
1352
+ onAnimationend: Oe(ut, ["self"])
1221
1353
  }, [
1222
- l.lineNumbers ? (S(), E("div", Vt, [
1223
- R("div", {
1354
+ n.lineNumbers ? (I(), L("div", en, [
1355
+ A("div", {
1224
1356
  ref_key: "gutterInner",
1225
1357
  ref: b,
1226
1358
  class: "gutter-inner code-font"
1227
1359
  }, [
1228
- (S(!0), E(Oe, null, Ne(nt.value, (r) => (S(), E("div", {
1229
- key: r,
1360
+ (I(!0), L(Ne, null, We(st.value, (c) => (I(), L("div", {
1361
+ key: c,
1230
1362
  class: "gutter-line"
1231
- }, K(r), 1))), 128))
1363
+ }, Y(c), 1))), 128))
1232
1364
  ], 512)
1233
- ])) : D("", !0),
1234
- R("div", {
1365
+ ])) : Z("", !0),
1366
+ A("div", {
1235
1367
  ref_key: "stage",
1236
- ref: M,
1368
+ ref: $,
1237
1369
  class: "stage"
1238
1370
  }, [
1239
- R("div", {
1371
+ A("div", {
1240
1372
  ref_key: "highlightLayer",
1241
- ref: W,
1373
+ ref: z,
1242
1374
  class: "highlight code-font"
1243
1375
  }, [
1244
- R("pre", {
1376
+ A("pre", {
1245
1377
  ref_key: "highlightInner",
1246
- ref: g,
1378
+ ref: C,
1247
1379
  class: "code-font"
1248
1380
  }, [
1249
- R("code", { innerHTML: tt.value }, null, 8, Kt)
1381
+ A("code", { innerHTML: at.value }, null, 8, tn)
1250
1382
  ], 512)
1251
1383
  ], 512),
1252
- R("textarea", {
1384
+ A("textarea", {
1253
1385
  ref_key: "textarea",
1254
- ref: p,
1386
+ ref: f,
1255
1387
  class: "code-font input",
1256
- value: i.value,
1257
- readonly: l.readonly,
1258
- placeholder: l.placeholder,
1388
+ value: a.value,
1389
+ readonly: n.readonly,
1390
+ placeholder: n.placeholder,
1259
1391
  spellcheck: "false",
1260
1392
  autocomplete: "off",
1261
1393
  autocapitalize: "off",
1262
1394
  autocorrect: "off",
1263
- wrap: "soft",
1264
- onInput: ht,
1265
- onKeydown: xt,
1266
- onScroll: vt,
1267
- onClick: gt,
1268
- onMousemove: ft,
1269
- onMouseleave: L,
1270
- onBlur: bt
1271
- }, null, 40, Zt),
1272
- y.value ? (S(), E("ul", {
1395
+ wrap: "off",
1396
+ onInput: yt,
1397
+ onKeydown: Ct,
1398
+ onScroll: xt,
1399
+ onClick: wt,
1400
+ onMousemove: bt,
1401
+ onMouseleave: j,
1402
+ onBlur: kt
1403
+ }, null, 40, nn),
1404
+ w.value ? (I(), L("ul", {
1273
1405
  key: 0,
1274
1406
  ref_key: "popup",
1275
- ref: H,
1407
+ ref: y,
1276
1408
  class: "popup",
1277
- style: ae(k.value),
1278
- onMousedown: n[0] || (n[0] = Le(() => {
1409
+ style: re(_.value),
1410
+ onMousedown: l[0] || (l[0] = Oe(() => {
1279
1411
  }, ["prevent"]))
1280
1412
  }, [
1281
- (S(!0), E(Oe, null, Ne(A.value, (r, m) => (S(), E("li", {
1282
- key: `${r.label}-${m}`,
1283
- class: te(["popup-item", { "is-active": m === w.value }]),
1284
- onMouseenter: (h) => w.value = m,
1285
- onClick: (h) => Ee(r)
1413
+ (I(!0), L(Ne, null, We(B.value, (c, m) => (I(), L("li", {
1414
+ key: `${c.label}-${m}`,
1415
+ class: te(["popup-item", { "is-active": m === M.value }]),
1416
+ onMouseenter: (h) => M.value = m,
1417
+ onClick: (h) => Re(c)
1286
1418
  }, [
1287
- R("span", {
1288
- class: te(["badge", `badge-${r.kind}`])
1289
- }, K($e(r.kind)), 3),
1290
- R("span", Ut, K(r.label), 1),
1291
- r.detail ? (S(), E("span", Yt, K(r.detail), 1)) : D("", !0)
1292
- ], 42, qt))), 128))
1293
- ], 36)) : D("", !0),
1294
- $.value ? (S(), E("div", {
1419
+ A("span", {
1420
+ class: te(["badge", `badge-${c.kind}`])
1421
+ }, Y(Te(c.kind)), 3),
1422
+ A("span", on, Y(c.label), 1),
1423
+ c.detail ? (I(), L("span", an, Y(c.detail), 1)) : Z("", !0)
1424
+ ], 42, ln))), 128))
1425
+ ], 36)) : Z("", !0),
1426
+ g.value ? (I(), L("div", {
1295
1427
  key: 1,
1296
1428
  ref_key: "hoverCard",
1297
1429
  ref: O,
1298
1430
  class: "hover-card",
1299
- style: ae(ye.value)
1431
+ style: re(ie.value)
1300
1432
  }, [
1301
- R("div", Jt, [
1302
- R("span", {
1303
- class: te(["badge", `badge-${$.value.kind}`])
1304
- }, K($e($.value.kind)), 3),
1305
- R("span", Gt, [
1306
- Tt(K($.value.label), 1),
1307
- $.value.detail ? (S(), E("span", Xt, ":")) : D("", !0)
1433
+ A("div", sn, [
1434
+ A("span", {
1435
+ class: te(["badge", `badge-${g.value.kind}`])
1436
+ }, Y(Te(g.value.kind)), 3),
1437
+ A("span", rn, [
1438
+ Rt(Y(g.value.label), 1),
1439
+ g.value.detail ? (I(), L("span", cn, ":")) : Z("", !0)
1308
1440
  ]),
1309
- $.value.detail ? (S(), E("span", Qt, K($.value.detail), 1)) : D("", !0)
1441
+ g.value.detail ? (I(), L("span", un, Y(g.value.detail), 1)) : Z("", !0)
1310
1442
  ]),
1311
- $.value.documentation ? (S(), E("p", en, K($.value.documentation), 1)) : D("", !0),
1312
- $.value.type ? (S(), E("pre", tn, [
1313
- R("code", {
1314
- innerHTML: st($.value.type)
1315
- }, null, 8, nn)
1316
- ])) : D("", !0)
1317
- ], 4)) : D("", !0)
1443
+ g.value.documentation ? (I(), L("p", dn, Y(g.value.documentation), 1)) : Z("", !0),
1444
+ g.value.type ? (I(), L("pre", fn, [
1445
+ A("code", {
1446
+ innerHTML: ft(g.value.type)
1447
+ }, null, 8, pn)
1448
+ ])) : Z("", !0)
1449
+ ], 4)) : Z("", !0)
1318
1450
  ], 512),
1319
- l.collapsible ? (S(), E("button", {
1451
+ n.collapsible ? (I(), L("button", {
1320
1452
  key: 1,
1321
1453
  type: "button",
1322
1454
  class: "expand-toggle",
1323
- title: N.value ? "收起" : "展开",
1324
- "aria-label": N.value ? "收起编辑器" : "展开编辑器",
1325
- onClick: at
1455
+ title: F.value ? "收起" : "展开",
1456
+ "aria-label": F.value ? "收起编辑器" : "展开编辑器",
1457
+ onClick: dt
1326
1458
  }, [
1327
- N.value ? (S(), E("svg", an, [...n[2] || (n[2] = [
1328
- R("path", {
1459
+ F.value ? (I(), L("svg", gn, [...l[2] || (l[2] = [
1460
+ A("path", {
1329
1461
  d: "M11 2 5 8 11 14",
1330
1462
  fill: "none",
1331
1463
  stroke: "currentColor",
@@ -1333,8 +1465,8 @@ ${_}${B}`);
1333
1465
  "stroke-linecap": "round",
1334
1466
  "stroke-linejoin": "round"
1335
1467
  }, null, -1)
1336
- ])])) : (S(), E("svg", on, [...n[1] || (n[1] = [
1337
- R("path", {
1468
+ ])])) : (I(), L("svg", hn, [...l[1] || (l[1] = [
1469
+ A("path", {
1338
1470
  d: "M6 2 12 8 6 14",
1339
1471
  fill: "none",
1340
1472
  stroke: "currentColor",
@@ -1343,33 +1475,35 @@ ${_}${B}`);
1343
1475
  "stroke-linejoin": "round"
1344
1476
  }, null, -1)
1345
1477
  ])]))
1346
- ], 8, ln)) : D("", !0)
1478
+ ], 8, mn)) : Z("", !0)
1347
1479
  ], 38)
1348
1480
  ], 6));
1349
1481
  }
1350
- }), rn = (l, s) => {
1351
- const a = l.__vccOpts || l;
1352
- for (const [t, o] of s)
1353
- a[t] = o;
1354
- return a;
1355
- }, cn = /* @__PURE__ */ rn(sn, [["__scopeId", "data-v-fcbf39fe"]]), fn = {
1356
- install(l) {
1357
- l.component("CodeInput", cn);
1482
+ }), vn = (n, s) => {
1483
+ const o = n.__vccOpts || n;
1484
+ for (const [e, i] of s)
1485
+ o[e] = i;
1486
+ return o;
1487
+ }, yn = /* @__PURE__ */ vn(bn, [["__scopeId", "data-v-fecd5f3c"]]), xn = {
1488
+ install(n) {
1489
+ n.component("CodeInput", yn);
1358
1490
  }
1359
1491
  };
1360
1492
  export {
1361
- cn as CodeEditor,
1362
- At as collectCompletions,
1363
- fn as default,
1364
- St as defaultCompletions,
1365
- ve as findTemplateRange,
1366
- je as getKeywordSet,
1367
- Ye as getKeywords,
1368
- re as highlight,
1369
- Pt as highlightTemplate,
1370
- dn as isInsideTemplate,
1371
- jt as parseTsCompletions,
1372
- Lt as resolveHoverItem,
1373
- We as scanDeclarations,
1374
- se as tokenize
1493
+ yn as CodeEditor,
1494
+ Wt as collectCompletions,
1495
+ xn as default,
1496
+ It as defaultCompletions,
1497
+ _t as findArgumentContext,
1498
+ ke as findTemplateRange,
1499
+ De as getKeywordSet,
1500
+ Je as getKeywords,
1501
+ ue as highlight,
1502
+ Qt as highlightTemplate,
1503
+ wn as isInsideTemplate,
1504
+ Ut as parseTsCompletions,
1505
+ Yt as parseTsSignatures,
1506
+ Dt as resolveHoverItem,
1507
+ Fe as scanDeclarations,
1508
+ ce as tokenize
1375
1509
  };