@m4l/components 9.10.1 → 9.10.2-beta-feature-731-m4l-components-code-editor.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/@types/types.d.ts +11 -0
  2. package/components/extended/ReactSimpleCodeEditor/CodeEditor.d.ts +6 -0
  3. package/components/extended/ReactSimpleCodeEditor/CodeEditor.d.ts.map +1 -0
  4. package/components/extended/ReactSimpleCodeEditor/CodeEditor.js +229 -0
  5. package/components/extended/ReactSimpleCodeEditor/CodeEditor.styles.d.ts +3 -0
  6. package/components/extended/ReactSimpleCodeEditor/CodeEditor.styles.d.ts.map +1 -0
  7. package/components/extended/ReactSimpleCodeEditor/CodeEditor.styles.js +265 -0
  8. package/components/extended/ReactSimpleCodeEditor/constants.d.ts +84 -0
  9. package/components/extended/ReactSimpleCodeEditor/constants.d.ts.map +1 -0
  10. package/components/extended/ReactSimpleCodeEditor/constants.js +162 -0
  11. package/components/extended/ReactSimpleCodeEditor/dictionary.d.ts +11 -0
  12. package/components/extended/ReactSimpleCodeEditor/dictionary.d.ts.map +1 -0
  13. package/components/extended/ReactSimpleCodeEditor/dictionary.js +7 -0
  14. package/components/extended/ReactSimpleCodeEditor/helpers/highlighting.d.ts +49 -0
  15. package/components/extended/ReactSimpleCodeEditor/helpers/highlighting.d.ts.map +1 -0
  16. package/components/extended/ReactSimpleCodeEditor/helpers/highlighting.js +1073 -0
  17. package/components/extended/ReactSimpleCodeEditor/helpers/languageIcon.d.ts +6 -0
  18. package/components/extended/ReactSimpleCodeEditor/helpers/languageIcon.d.ts.map +1 -0
  19. package/components/extended/ReactSimpleCodeEditor/helpers/languageIcon.js +9 -0
  20. package/components/extended/ReactSimpleCodeEditor/index.d.ts +4 -0
  21. package/components/extended/ReactSimpleCodeEditor/index.d.ts.map +1 -0
  22. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorEnum.d.ts +18 -0
  23. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorEnum.d.ts.map +1 -0
  24. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorEnum.js +4 -0
  25. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorSlots.d.ts +84 -0
  26. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorSlots.d.ts.map +1 -0
  27. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorSlots.js +63 -0
  28. package/components/extended/ReactSimpleCodeEditor/slots/index.d.ts +3 -0
  29. package/components/extended/ReactSimpleCodeEditor/slots/index.d.ts.map +1 -0
  30. package/components/extended/ReactSimpleCodeEditor/types.d.ts +104 -0
  31. package/components/extended/ReactSimpleCodeEditor/types.d.ts.map +1 -0
  32. package/components/extended/index.d.ts +1 -0
  33. package/components/extended/index.d.ts.map +1 -1
  34. package/components/hook-form/RHFCodeEditor/RHFCodeEditor.d.ts +7 -0
  35. package/components/hook-form/RHFCodeEditor/RHFCodeEditor.d.ts.map +1 -0
  36. package/components/hook-form/RHFCodeEditor/RHFCodeEditor.js +6 -0
  37. package/components/hook-form/RHFCodeEditor/index.d.ts +3 -0
  38. package/components/hook-form/RHFCodeEditor/index.d.ts.map +1 -0
  39. package/components/hook-form/index.d.ts +1 -0
  40. package/components/hook-form/index.d.ts.map +1 -1
  41. package/index.js +512 -502
  42. package/package.json +7 -4
@@ -0,0 +1,1073 @@
1
+ import { jsx as d, Fragment as ot } from "@emotion/react/jsx-runtime";
2
+ import { typescriptLanguage as St, tsxLanguage as vt, jsxLanguage as Ot, javascriptLanguage as At } from "../../../../node_modules/@codemirror/lang-javascript/dist/index.js";
3
+ import { pythonLanguage as Lt } from "../../../../node_modules/@codemirror/lang-python/dist/index.js";
4
+ import { StandardSQL as bt } from "../../../../node_modules/@codemirror/lang-sql/dist/index.js";
5
+ import { yamlLanguage as _t } from "../../../../node_modules/@codemirror/lang-yaml/dist/index.js";
6
+ import it from "prismjs";
7
+ import "prismjs/components/prism-bash";
8
+ import "prismjs/components/prism-clike";
9
+ import "prismjs/components/prism-javascript";
10
+ import "prismjs/components/prism-json";
11
+ import "prismjs/components/prism-jsx";
12
+ import "prismjs/components/prism-python";
13
+ import "prismjs/components/prism-sql";
14
+ import "prismjs/components/prism-tsx";
15
+ import "prismjs/components/prism-typescript";
16
+ import "prismjs/components/prism-yaml";
17
+ import { Highlight as kt } from "prism-react-renderer";
18
+ import { CODE_EDITOR_AT_TEMPLATE_TOKENS as S, CODE_EDITOR_AT_LANGUAGE as B, CODE_EDITOR_AT_TEMPLATE_NAME as Nt, CODE_EDITOR_AT_TEMPLATE_LANGUAGE_LABEL as Dt, CODE_EDITOR_DEFAULT_LANGUAGE as ct, CODE_EDITOR_LANGUAGE_ALIASES as It, getCodeEditorVSCodeModernPalette as X } from "../constants.js";
19
+ const F = it.languages, Y = {}, Rt = /* @__PURE__ */ new Set(["(", ")", "[", "]", "{", "}"]), Pt = /* @__PURE__ */ new Set([
20
+ "javascript",
21
+ "jsx",
22
+ "typescript",
23
+ "tsx"
24
+ ]), wt = /* @__PURE__ */ new Set([
25
+ "(",
26
+ ")",
27
+ "[",
28
+ "]",
29
+ "{",
30
+ "}",
31
+ ".",
32
+ ",",
33
+ ":",
34
+ ";",
35
+ "=",
36
+ "=>",
37
+ "as",
38
+ "await",
39
+ "case",
40
+ "const",
41
+ "default",
42
+ "export",
43
+ "from",
44
+ "import",
45
+ "in",
46
+ "instanceof",
47
+ "let",
48
+ "new",
49
+ "of",
50
+ "return",
51
+ "throw",
52
+ "typeof",
53
+ "var",
54
+ "yield"
55
+ ]), Mt = /* @__PURE__ */ new Set([
56
+ "(",
57
+ ":",
58
+ "=>",
59
+ "as",
60
+ "case",
61
+ "class",
62
+ "enum",
63
+ "extends",
64
+ "implements",
65
+ "instanceof",
66
+ "interface",
67
+ "new",
68
+ "type",
69
+ "typeof"
70
+ ]), $t = /^[+\-*/%!?&|^~]+$/, C = {
71
+ isValid: !0
72
+ }, st = {
73
+ javascript: {
74
+ label: "JavaScript",
75
+ parser: At.parser
76
+ },
77
+ jsx: {
78
+ label: "JSX",
79
+ parser: Ot.parser
80
+ },
81
+ python: {
82
+ label: "Python",
83
+ parser: Lt.parser
84
+ },
85
+ sql: {
86
+ label: "SQL",
87
+ parser: bt.language.parser
88
+ },
89
+ tsx: {
90
+ label: "TSX",
91
+ parser: vt.parser
92
+ },
93
+ typescript: {
94
+ label: "TypeScript",
95
+ parser: St.parser
96
+ },
97
+ yaml: {
98
+ label: "YAML",
99
+ parser: _t.parser
100
+ }
101
+ }, lt = {
102
+ languageLabel: Dt,
103
+ languageText: B,
104
+ templateName: Nt,
105
+ templateType: B,
106
+ tokens: {
107
+ argumentSeparators: [...S.argumentSeparators],
108
+ commandPrefixes: [...S.commandPrefixes],
109
+ concatenationSeparators: [...S.concatenationSeparators],
110
+ reservedWords: [...S.reservedWords]
111
+ }
112
+ };
113
+ function zt(t) {
114
+ return [...X(t).bracketPalette];
115
+ }
116
+ function Gt(t) {
117
+ const e = X(t);
118
+ return {
119
+ constant: e.syntax.constant,
120
+ type: e.syntax.type,
121
+ variable: e.syntax.variable
122
+ };
123
+ }
124
+ function Ut(t) {
125
+ return Pt.has(t);
126
+ }
127
+ function Bt(t) {
128
+ const e = [], n = Array.from(t.matchAll(/[A-Za-z_$][\w$]*/g));
129
+ let r = 0;
130
+ return n.forEach((s) => {
131
+ const o = s[0], a = s.index ?? 0;
132
+ a > r && e.push({
133
+ content: t.slice(r, a),
134
+ isIdentifier: !1
135
+ }), e.push({
136
+ content: o,
137
+ isIdentifier: !0
138
+ }), r = a + o.length;
139
+ }), r < t.length && e.push({
140
+ content: t.slice(r),
141
+ isIdentifier: !1
142
+ }), e.length ? e : [{ content: t, isIdentifier: !1 }];
143
+ }
144
+ function H(t) {
145
+ const e = t.trimStart();
146
+ if (!e)
147
+ return;
148
+ if (e.startsWith("=>"))
149
+ return "=>";
150
+ const n = e.match(/^[A-Za-z_$][\w$]*/);
151
+ if (n)
152
+ return n[0];
153
+ const r = e.match(/^[+\-*/%!?&|^~]+/);
154
+ return r ? r[0] : e[0];
155
+ }
156
+ function Ft(t, e, n = "") {
157
+ const r = H(
158
+ n
159
+ );
160
+ if (r)
161
+ return r;
162
+ for (let s = e + 1; s < t.length; s += 1) {
163
+ const o = H(
164
+ t[s].content
165
+ );
166
+ if (o)
167
+ return o;
168
+ }
169
+ }
170
+ function Zt(t) {
171
+ return t.length > 1 && t === t.toUpperCase() && /[A-Z]/.test(t);
172
+ }
173
+ function jt(t) {
174
+ return /^[A-Z][A-Za-z0-9]*$/.test(t) && t !== t.toUpperCase();
175
+ }
176
+ function Vt(t, e) {
177
+ return t === ">" && e === "<" ? !1 : [t, e].some(
178
+ (n) => !!n && (wt.has(n) || $t.test(n))
179
+ );
180
+ }
181
+ function Wt(t) {
182
+ if (t.some((e) => ["constant", "symbol"].includes(e)))
183
+ return "constant";
184
+ if (t.some((e) => [
185
+ "builtin",
186
+ "class-name",
187
+ "known-class-name",
188
+ "maybe-class-name",
189
+ "namespace"
190
+ ].includes(e)))
191
+ return "type";
192
+ if (t.some((e) => [
193
+ "alias",
194
+ "imports",
195
+ "literal-property",
196
+ "parameter",
197
+ "property",
198
+ "variable"
199
+ ].includes(e)))
200
+ return "variable";
201
+ }
202
+ function Ht({
203
+ identifier: t,
204
+ nextSignificantText: e,
205
+ previousIdentifierGroup: n,
206
+ previousSignificantText: r
207
+ }) {
208
+ if (Vt(
209
+ r,
210
+ e
211
+ ))
212
+ return r === "." && n === "type" || Zt(t) ? "constant" : jt(t) && (e === "." || e === "(" || r && Mt.has(r)) ? "type" : "variable";
213
+ }
214
+ function I(t, e, n) {
215
+ const r = H(e);
216
+ if (r) {
217
+ if (t.previousSignificantText = r, n) {
218
+ t.previousIdentifierGroup = n;
219
+ return;
220
+ }
221
+ r !== "." && (t.previousIdentifierGroup = void 0);
222
+ }
223
+ }
224
+ function Jt(t) {
225
+ return Rt.has(t);
226
+ }
227
+ function Xt(t, e) {
228
+ if ("([{".includes(t))
229
+ return {
230
+ renderedBracketDepth: e,
231
+ nextBracketDepth: e + 1
232
+ };
233
+ const n = Math.max(e - 1, 0);
234
+ return {
235
+ renderedBracketDepth: n,
236
+ nextBracketDepth: n
237
+ };
238
+ }
239
+ function Yt(t) {
240
+ return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
241
+ }
242
+ function W(t) {
243
+ const e = t?.map((n) => n.trim()).filter(Boolean);
244
+ if (e?.length)
245
+ return e.map(Yt).join("|");
246
+ }
247
+ function Kt(t) {
248
+ const e = W(t.tokens?.commandPrefixes) || "AT\\+", n = W(
249
+ t.tokens?.reservedWords
250
+ ), r = W([
251
+ ...t.tokens?.argumentSeparators || [],
252
+ ...t.tokens?.concatenationSeparators || []
253
+ ]);
254
+ return {
255
+ comment: {
256
+ pattern: /(^|\s)(?:#|\/\/).*$/m,
257
+ lookbehind: !0,
258
+ alias: "comment"
259
+ },
260
+ "at-command": {
261
+ pattern: new RegExp(
262
+ `(?:${e})[A-Z][A-Z0-9_:-]*`,
263
+ "i"
264
+ ),
265
+ inside: {
266
+ operator: new RegExp(`^(?:${e})`, "i"),
267
+ ...n ? {
268
+ keyword: new RegExp(`\\b(?:${n})\\b`, "i")
269
+ } : {},
270
+ function: /\b[A-Z][A-Z0-9_:-]*\b/
271
+ }
272
+ },
273
+ ...n ? {
274
+ keyword: new RegExp(`\\b(?:${n})\\b`, "i")
275
+ } : {},
276
+ property: /\b[A-Z_][A-Z0-9_]*(?=\s*=)/,
277
+ string: {
278
+ pattern: /"(?:\\.|[^"\\])*"/,
279
+ greedy: !0
280
+ },
281
+ boolean: /\b(?:ON|OFF|TRUE|FALSE)\b/i,
282
+ number: /\b\d+(?:\.\d+)?\b/,
283
+ constant: /\b(?:OK|ERROR|CONNECT|READY|BUSY)\b/i,
284
+ punctuation: r ? new RegExp(`(?:${r})|[()[\\]{}.:=]`) : /[()[\]{}.,:;=]/,
285
+ operator: /[+\-*/<>]/
286
+ };
287
+ }
288
+ function ut(t) {
289
+ return t.templateType === B ? Kt(t) : {};
290
+ }
291
+ function Qt(t) {
292
+ const e = t.templateName.trim();
293
+ if (!e)
294
+ return;
295
+ Y[e] = t;
296
+ const n = K(t.languageText);
297
+ F[n] || (F[n] = ut(t));
298
+ }
299
+ Qt(lt);
300
+ function ft(t, e) {
301
+ t.trim() && (F[t] = e);
302
+ }
303
+ function qt(t) {
304
+ const e = t.templateName.trim();
305
+ e && (Y[e] = t, ft(
306
+ t.languageText,
307
+ ut(t)
308
+ ));
309
+ }
310
+ function dt(t) {
311
+ if (t)
312
+ return typeof t == "string" ? Y[t] : t;
313
+ }
314
+ function te(t) {
315
+ const e = dt(t);
316
+ if (e)
317
+ return qt(e), e;
318
+ }
319
+ function ee(t) {
320
+ t && Object.entries(t).forEach(([e, n]) => {
321
+ ft(e, n);
322
+ });
323
+ }
324
+ function K(t) {
325
+ const e = t?.trim().toLowerCase() || ct;
326
+ return It[e] || e;
327
+ }
328
+ function P(t, e) {
329
+ return Math.max(0, Math.min(e, t.length));
330
+ }
331
+ function m(t, e) {
332
+ const n = P(t, e), s = t.slice(0, n).split(`
333
+ `);
334
+ return {
335
+ column: (s[s.length - 1] || "").length + 1,
336
+ line: s.length,
337
+ offset: n
338
+ };
339
+ }
340
+ function mt(t, e, n) {
341
+ const r = t.split(`
342
+ `), s = Math.min(Math.max(e, 1), Math.max(r.length, 1)), o = r.slice(0, s - 1).join(`
343
+ `), a = s === 1 ? 0 : o.length + 1, c = r[s - 1] || "";
344
+ return P(
345
+ t,
346
+ a + Math.max(Math.min(n - 1, c.length), 0)
347
+ );
348
+ }
349
+ function at(t, e) {
350
+ return typeof e.offset == "number" ? m(t, e.offset) : m(
351
+ t,
352
+ mt(t, e.line, e.column)
353
+ );
354
+ }
355
+ function R(t, e, n) {
356
+ const r = P(t, e), s = Math.max(
357
+ r + 1,
358
+ P(t, n)
359
+ );
360
+ return {
361
+ end: m(
362
+ t,
363
+ s - 1
364
+ ),
365
+ start: m(t, r)
366
+ };
367
+ }
368
+ function ne(t, e) {
369
+ if (!e)
370
+ return;
371
+ const n = at(
372
+ t,
373
+ e.start
374
+ ), r = at(
375
+ t,
376
+ e.end ?? e.start
377
+ ), s = Math.min(
378
+ n.offset,
379
+ r.offset
380
+ ), o = Math.max(
381
+ n.offset,
382
+ r.offset
383
+ ) + 1;
384
+ return {
385
+ start: m(
386
+ t,
387
+ s
388
+ ),
389
+ end: m(
390
+ t,
391
+ o
392
+ )
393
+ };
394
+ }
395
+ function Q(t) {
396
+ const e = [];
397
+ let n = 0;
398
+ return t.forEach((r) => {
399
+ e.push(n), n += r.length + 1;
400
+ }), e;
401
+ }
402
+ function v(t, e) {
403
+ const n = t.split(`
404
+ `), r = n[e];
405
+ if (r === void 0)
406
+ return;
407
+ const s = Q(n)[e] || 0, o = r.length - r.trimStart().length, a = r.trimEnd().length, c = s + o, i = s + Math.max(a, o + 1);
408
+ return R(t, c, i);
409
+ }
410
+ function J(t, e) {
411
+ for (let n = e; n >= 0; n -= 1)
412
+ if (!/\s/.test(t[n]))
413
+ return n;
414
+ }
415
+ function re(t, e) {
416
+ const n = e.match(/\bposition\s+(\d+)\b/i);
417
+ if (n)
418
+ return P(t, Number(n[1]));
419
+ const r = e.match(/\bline\s+(\d+)\s+column\s+(\d+)\b/i);
420
+ if (r)
421
+ return mt(
422
+ t,
423
+ Number(r[1]),
424
+ Number(r[2])
425
+ );
426
+ }
427
+ function oe(t, e) {
428
+ const n = re(t, e);
429
+ if (typeof n != "number") {
430
+ const l = J(
431
+ t,
432
+ t.length - 1
433
+ );
434
+ return typeof l != "number" ? void 0 : v(
435
+ t,
436
+ m(t, l).line - 1
437
+ );
438
+ }
439
+ const s = m(
440
+ t,
441
+ n
442
+ ).line - 1, o = t.split(`
443
+ `), a = o[s] || "", c = t[n], i = J(
444
+ t,
445
+ Math.min(n - 1, t.length - 1)
446
+ );
447
+ if ((c === "}" || c === "]") && typeof i == "number" && t[i] === ",")
448
+ return v(
449
+ t,
450
+ m(
451
+ t,
452
+ i
453
+ ).line - 1
454
+ );
455
+ if (a.trim()) {
456
+ const l = Q(o)[s] || 0, w = a.length - a.trimStart().length;
457
+ return R(
458
+ t,
459
+ l + w,
460
+ n + 1
461
+ );
462
+ }
463
+ return typeof i == "number" ? v(
464
+ t,
465
+ m(
466
+ t,
467
+ i
468
+ ).line - 1
469
+ ) : v(t, s);
470
+ }
471
+ function E(t, e) {
472
+ return {
473
+ errorRange: e,
474
+ isValid: !1,
475
+ message: t
476
+ };
477
+ }
478
+ function se(t, e, n) {
479
+ if (e < n)
480
+ return R(t, e, n);
481
+ const r = m(
482
+ t,
483
+ e
484
+ ), s = v(
485
+ t,
486
+ r.line - 1
487
+ );
488
+ if (s)
489
+ return s;
490
+ const o = J(
491
+ t,
492
+ Math.min(e - 1, t.length - 1)
493
+ );
494
+ return typeof o == "number" ? R(
495
+ t,
496
+ o,
497
+ o + 1
498
+ ) : R(t, e, e + 1);
499
+ }
500
+ function ae(t, e) {
501
+ const n = e.parse(t).cursor();
502
+ for (; ; ) {
503
+ if (n.type.isError)
504
+ return se(
505
+ t,
506
+ n.from,
507
+ n.to
508
+ );
509
+ if (!n.firstChild()) {
510
+ for (; !n.nextSibling(); )
511
+ if (!n.parent())
512
+ return;
513
+ }
514
+ }
515
+ }
516
+ function ie(t, e) {
517
+ if (!t.trim())
518
+ return C;
519
+ const n = ae(
520
+ t,
521
+ e.parser
522
+ );
523
+ return n ? E(
524
+ `Invalid ${e.label} syntax.`,
525
+ n
526
+ ) : C;
527
+ }
528
+ function Z(t, e, n) {
529
+ return e.find((r) => t.slice(n, n + r.length).toUpperCase() === r.toUpperCase());
530
+ }
531
+ function q(t, e) {
532
+ let n = 0;
533
+ for (let r = e - 1; r >= 0 && t[r] === "\\"; r -= 1)
534
+ n += 1;
535
+ return n % 2 === 1;
536
+ }
537
+ function ce(t) {
538
+ let e = !1;
539
+ for (let n = 0; n < t.length; n += 1) {
540
+ const r = t[n];
541
+ if (r === '"' && !q(t, n)) {
542
+ e = !e;
543
+ continue;
544
+ }
545
+ if (e)
546
+ continue;
547
+ const s = n > 0 ? t[n - 1] : void 0, o = r === "#" && (n === 0 || /\s/.test(s || "")), a = t.slice(n, n + 2) === "//" && (n === 0 || /\s/.test(s || ""));
548
+ if (o || a)
549
+ return t.slice(0, n).trimEnd();
550
+ }
551
+ return t.trimEnd();
552
+ }
553
+ function le(t, e) {
554
+ if (!e.length)
555
+ return [t];
556
+ const n = [];
557
+ let r = !1, s = 0;
558
+ for (let o = 0; o < t.length; ) {
559
+ if (t[o] === '"' && !q(t, o)) {
560
+ r = !r, o += 1;
561
+ continue;
562
+ }
563
+ if (!r) {
564
+ const c = Z(
565
+ t,
566
+ e,
567
+ o
568
+ );
569
+ if (c) {
570
+ n.push(t.slice(s, o)), o += c.length, s = o;
571
+ continue;
572
+ }
573
+ }
574
+ o += 1;
575
+ }
576
+ return n.push(t.slice(s)), n;
577
+ }
578
+ function ue(t, e, n) {
579
+ let r = e;
580
+ for (; r < t.length && /\s/.test(t[r]); )
581
+ r += 1;
582
+ if (r >= t.length)
583
+ return;
584
+ if (t[r] === '"') {
585
+ for (r += 1; r < t.length; ) {
586
+ if (t[r] === '"' && !q(t, r))
587
+ return {
588
+ nextIndex: r + 1
589
+ };
590
+ r += 1;
591
+ }
592
+ return;
593
+ }
594
+ const s = r;
595
+ for (; r < t.length && !Z(
596
+ t,
597
+ n,
598
+ r
599
+ ); )
600
+ r += 1;
601
+ if (t.slice(s, r).trim())
602
+ return {
603
+ nextIndex: r
604
+ };
605
+ }
606
+ function fe(t, e) {
607
+ const n = t.trim(), r = [
608
+ ...e.tokens?.commandPrefixes || S.commandPrefixes
609
+ ].sort((i, l) => l.length - i.length), s = [
610
+ ...e.tokens?.argumentSeparators || S.argumentSeparators
611
+ ].sort((i, l) => l.length - i.length);
612
+ let o = 0;
613
+ if (!n)
614
+ return E("AT command segments cannot be empty.");
615
+ const a = Z(
616
+ n,
617
+ r,
618
+ o
619
+ );
620
+ if (!a)
621
+ return E("AT commands must start with a configured prefix.");
622
+ o += a.length;
623
+ const c = n.slice(o).match(/^[A-Z][A-Z0-9_:-]*/i);
624
+ if (!c)
625
+ return E("AT commands must include a command name.");
626
+ for (o += c[0].length; o < n.length; ) {
627
+ for (; o < n.length && /\s/.test(n[o]); )
628
+ o += 1;
629
+ if (o >= n.length)
630
+ return C;
631
+ const i = n[o] === "=" ? "=" : Z(n, s, o);
632
+ if (!i)
633
+ return E("AT commands can only continue with assignments or arguments.");
634
+ o += i.length;
635
+ const l = ue(
636
+ n,
637
+ o,
638
+ s
639
+ );
640
+ if (!l)
641
+ return E("AT command arguments must provide a value.");
642
+ o = l.nextIndex;
643
+ }
644
+ return C;
645
+ }
646
+ function de(t, e) {
647
+ const n = e || lt, r = [
648
+ ...n.tokens?.concatenationSeparators || S.concatenationSeparators
649
+ ].sort((o, a) => a.length - o.length), s = t.split(`
650
+ `);
651
+ for (let o = 0; o < s.length; o += 1) {
652
+ const a = ce(s[o]).trim();
653
+ if (!a)
654
+ continue;
655
+ const c = le(a, r);
656
+ if (c.some((i) => !i.trim()))
657
+ return E(
658
+ `Invalid AT commands syntax on line ${o + 1}.`,
659
+ v(t, o)
660
+ );
661
+ for (const i of c)
662
+ if (!fe(
663
+ i,
664
+ n
665
+ ).isValid)
666
+ return E(
667
+ `Invalid AT commands syntax on line ${o + 1}.`,
668
+ v(t, o)
669
+ );
670
+ }
671
+ return C;
672
+ }
673
+ function me(t) {
674
+ if (!t.trim())
675
+ return C;
676
+ try {
677
+ return JSON.parse(t), C;
678
+ } catch (e) {
679
+ return E(
680
+ "Invalid JSON syntax.",
681
+ oe(
682
+ t,
683
+ e instanceof Error ? e.message : "Invalid JSON syntax."
684
+ )
685
+ );
686
+ }
687
+ }
688
+ function Re({
689
+ code: t,
690
+ languageTemplate: e,
691
+ languageText: n
692
+ }) {
693
+ const r = dt(e), s = K(
694
+ n ?? r?.languageText
695
+ );
696
+ switch (s) {
697
+ case B:
698
+ return de(t, r);
699
+ case "json":
700
+ return me(t);
701
+ default:
702
+ return st[s] ? ie(
703
+ t,
704
+ st[s]
705
+ ) : C;
706
+ }
707
+ }
708
+ function Pe(t) {
709
+ return t.split(`
710
+ `).length;
711
+ }
712
+ function A(t, e, n) {
713
+ if (!t)
714
+ return !1;
715
+ const r = Math.max(e + 1, n);
716
+ return e < t.end.offset && t.start.offset < r;
717
+ }
718
+ function pe(t, e, n) {
719
+ const r = e + t.length, s = Math.max(n.start.offset, e), o = Math.min(n.end.offset, r);
720
+ if (s >= o)
721
+ return [{ text: t || " ", hasError: !1 }];
722
+ const a = s - e, c = o - e, i = [];
723
+ return a > 0 && i.push({
724
+ hasError: !1,
725
+ text: t.slice(0, a)
726
+ }), i.push({
727
+ hasError: !0,
728
+ text: t.slice(a, c)
729
+ }), c < t.length && i.push({
730
+ hasError: !1,
731
+ text: t.slice(c)
732
+ }), i.filter((l) => l.text.length > 0);
733
+ }
734
+ function we(t) {
735
+ const e = X(t), n = Gt(t);
736
+ return {
737
+ plain: {
738
+ backgroundColor: "transparent",
739
+ color: e.surface.editorForeground
740
+ },
741
+ bracketPalette: zt(t),
742
+ semanticPalette: n,
743
+ styles: [
744
+ {
745
+ types: ["comment", "prolog", "doctype", "cdata"],
746
+ style: {
747
+ color: e.syntax.comment,
748
+ fontStyle: "italic"
749
+ }
750
+ },
751
+ {
752
+ types: ["punctuation"],
753
+ style: {
754
+ color: e.surface.editorForeground
755
+ }
756
+ },
757
+ {
758
+ types: ["operator"],
759
+ style: {
760
+ color: e.syntax.operator
761
+ }
762
+ },
763
+ {
764
+ types: ["property", "literal-property", "selector"],
765
+ style: {
766
+ color: n.variable
767
+ }
768
+ },
769
+ {
770
+ types: ["attr-name"],
771
+ style: {
772
+ color: e.syntax.attributeName
773
+ }
774
+ },
775
+ {
776
+ types: ["tag"],
777
+ style: {
778
+ color: e.syntax.tag
779
+ }
780
+ },
781
+ {
782
+ types: ["boolean"],
783
+ style: {
784
+ color: e.syntax.boolean
785
+ }
786
+ },
787
+ {
788
+ types: ["number"],
789
+ style: {
790
+ color: e.syntax.number
791
+ }
792
+ },
793
+ {
794
+ types: ["symbol"],
795
+ style: {
796
+ color: e.syntax.constant
797
+ }
798
+ },
799
+ {
800
+ types: ["atrule"],
801
+ style: {
802
+ color: e.syntax.keyword
803
+ }
804
+ },
805
+ {
806
+ types: ["constant"],
807
+ style: {
808
+ color: n.constant
809
+ }
810
+ },
811
+ {
812
+ types: ["string", "char", "inserted"],
813
+ style: {
814
+ color: e.syntax.string
815
+ }
816
+ },
817
+ {
818
+ types: ["regex"],
819
+ style: {
820
+ color: e.syntax.regex
821
+ }
822
+ },
823
+ {
824
+ types: ["constant.character.escape"],
825
+ style: {
826
+ color: e.syntax.escape
827
+ }
828
+ },
829
+ {
830
+ types: ["keyword"],
831
+ style: {
832
+ color: e.syntax.keyword
833
+ }
834
+ },
835
+ {
836
+ types: ["function", "function-variable", "method", "method-variable"],
837
+ style: {
838
+ color: e.syntax.function
839
+ }
840
+ },
841
+ {
842
+ types: ["builtin", "class-name", "known-class-name", "maybe-class-name"],
843
+ style: {
844
+ color: n.type
845
+ }
846
+ },
847
+ {
848
+ types: ["alias", "imports", "parameter", "variable"],
849
+ style: {
850
+ color: n.variable
851
+ }
852
+ },
853
+ {
854
+ types: ["deleted"],
855
+ style: {
856
+ color: e.surface.errorBorderColor
857
+ }
858
+ }
859
+ ]
860
+ };
861
+ }
862
+ function Me({
863
+ code: t,
864
+ customLanguages: e,
865
+ languageTemplate: n,
866
+ languageText: r,
867
+ prismTheme: s,
868
+ syntaxErrorRange: o
869
+ }) {
870
+ const a = te(n);
871
+ ee(e);
872
+ const c = K(
873
+ r ?? a?.languageText
874
+ ), i = F[c], l = t.split(`
875
+ `), w = Q(l), y = ne(
876
+ t,
877
+ o
878
+ );
879
+ return !i || c === ct ? /* @__PURE__ */ d(ot, { children: l.map((L, b) => {
880
+ const _ = w[b] || 0, k = A(
881
+ y,
882
+ _,
883
+ _ + L.length
884
+ ), N = y ? pe(
885
+ L,
886
+ _,
887
+ y
888
+ ) : [{ hasError: !1, text: L || " " }];
889
+ return /* @__PURE__ */ d(
890
+ "div",
891
+ {
892
+ className: "token-line",
893
+ "data-code-editor-error-line": k || void 0,
894
+ children: N.map((M, $) => /* @__PURE__ */ d(
895
+ "span",
896
+ {
897
+ className: "token plain",
898
+ "data-code-editor-error-token": M.hasError || void 0,
899
+ children: M.text || " "
900
+ },
901
+ `plain-line-${b}-segment-${$}`
902
+ ))
903
+ },
904
+ `plain-line-${b}`
905
+ );
906
+ }) }) : /* @__PURE__ */ d(
907
+ kt,
908
+ {
909
+ code: t || " ",
910
+ language: c,
911
+ prism: it,
912
+ theme: s,
913
+ children: ({ tokens: L, getLineProps: b, getTokenProps: _ }) => {
914
+ const k = s.bracketPalette, N = s.semanticPalette, M = !!N && Ut(c);
915
+ let $ = 0;
916
+ const x = {};
917
+ return /* @__PURE__ */ d(ot, { children: L.map((j, O) => {
918
+ const V = w[O] || 0, pt = l[O] || "", gt = A(
919
+ y,
920
+ V,
921
+ V + pt.length
922
+ );
923
+ let tt = 0;
924
+ const ht = b({ line: j });
925
+ return /* @__PURE__ */ d(
926
+ "div",
927
+ {
928
+ ...ht,
929
+ "data-code-editor-error-line": gt || void 0,
930
+ children: j.map((u, z) => {
931
+ const T = V + tt, Et = T + u.content.length, yt = A(
932
+ y,
933
+ T,
934
+ Et
935
+ );
936
+ tt += u.content.length;
937
+ const p = _({ token: u }), et = Wt(
938
+ u.types
939
+ );
940
+ if (M && u.types.includes("plain") && u.content.trim()) {
941
+ const g = Bt(u.content);
942
+ if (g.some((h) => h.isIdentifier)) {
943
+ let h = 0;
944
+ return g.map((f, G) => {
945
+ const D = `token-${O}-${z}-${G}`, nt = T + h, Ct = nt + f.content.length, rt = A(
946
+ y,
947
+ nt,
948
+ Ct
949
+ );
950
+ if (h += f.content.length, !f.isIdentifier || !N)
951
+ return I(
952
+ x,
953
+ f.content
954
+ ), /* @__PURE__ */ d(
955
+ "span",
956
+ {
957
+ className: p.className,
958
+ style: p.style,
959
+ "data-code-editor-error-token": rt || void 0,
960
+ children: f.content
961
+ },
962
+ D
963
+ );
964
+ const xt = g.slice(G + 1).map((Tt) => Tt.content).join(""), U = Ht({
965
+ identifier: f.content,
966
+ nextSignificantText: Ft(
967
+ j,
968
+ z,
969
+ xt
970
+ ),
971
+ previousIdentifierGroup: x.previousIdentifierGroup,
972
+ previousSignificantText: x.previousSignificantText
973
+ });
974
+ return I(
975
+ x,
976
+ f.content,
977
+ U
978
+ ), /* @__PURE__ */ d(
979
+ "span",
980
+ {
981
+ className: p.className,
982
+ style: U ? {
983
+ ...p.style,
984
+ color: N[U]
985
+ } : p.style,
986
+ "data-code-editor-error-token": rt || void 0,
987
+ "data-code-editor-token-group": U,
988
+ children: f.content
989
+ },
990
+ D
991
+ );
992
+ });
993
+ }
994
+ }
995
+ return !k?.length || !u.types.includes("punctuation") || !/[()[\]{}]/.test(u.content) ? (I(
996
+ x,
997
+ u.content,
998
+ et
999
+ ), /* @__PURE__ */ d(
1000
+ "span",
1001
+ {
1002
+ ...p,
1003
+ "data-code-editor-error-token": yt || void 0,
1004
+ "data-code-editor-token-group": et
1005
+ },
1006
+ `token-${O}-${z}`
1007
+ )) : Array.from(u.content).map((g, h) => {
1008
+ const f = `token-${O}-${z}-${h}`;
1009
+ if (!Jt(g))
1010
+ return I(x, g), /* @__PURE__ */ d(
1011
+ "span",
1012
+ {
1013
+ className: p.className,
1014
+ style: p.style,
1015
+ "data-code-editor-error-token": A(
1016
+ y,
1017
+ T + h,
1018
+ T + h + 1
1019
+ ) || void 0,
1020
+ children: g
1021
+ },
1022
+ f
1023
+ );
1024
+ const {
1025
+ nextBracketDepth: G,
1026
+ renderedBracketDepth: D
1027
+ } = Xt(g, $);
1028
+ return $ = G, I(x, g), /* @__PURE__ */ d(
1029
+ "span",
1030
+ {
1031
+ className: p.className,
1032
+ style: {
1033
+ ...p.style,
1034
+ color: k[D % k.length]
1035
+ },
1036
+ "data-code-editor-error-token": A(
1037
+ y,
1038
+ T + h,
1039
+ T + h + 1
1040
+ ) || void 0,
1041
+ "data-code-editor-bracket-depth": D,
1042
+ children: g
1043
+ },
1044
+ f
1045
+ );
1046
+ });
1047
+ })
1048
+ },
1049
+ `token-line-${O}`
1050
+ );
1051
+ }) });
1052
+ }
1053
+ }
1054
+ );
1055
+ }
1056
+ export {
1057
+ lt as DEFAULT_CODE_EDITOR_AT_LANGUAGE_TEMPLATE,
1058
+ Kt as buildAtCommandGrammar,
1059
+ ut as createCodeEditorLanguageGrammar,
1060
+ we as createCodeEditorPrismTheme,
1061
+ W as createTokenAlternation,
1062
+ te as ensureCodeEditorLanguageTemplate,
1063
+ ee as ensureCodeEditorLanguages,
1064
+ Yt as escapeRegExpToken,
1065
+ Pe as getCodeEditorLineCount,
1066
+ Me as highlightCode,
1067
+ ft as registerCodeEditorLanguage,
1068
+ qt as registerCodeEditorLanguageTemplate,
1069
+ K as resolveCodeEditorLanguage,
1070
+ dt as resolveCodeEditorLanguageTemplate,
1071
+ Qt as seedCodeEditorLanguageTemplate,
1072
+ Re as validateCodeEditorSyntax
1073
+ };