@neowit/orbit-vue 0.9.0 → 0.9.1

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,1066 +0,0 @@
1
- function Ve(e) {
2
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
3
- }
4
- function we(e) {
5
- return e instanceof Map ? e.clear = e.delete = e.set = function() {
6
- throw new Error("map is read-only");
7
- } : e instanceof Set && (e.add = e.clear = e.delete = function() {
8
- throw new Error("set is read-only");
9
- }), Object.freeze(e), Object.getOwnPropertyNames(e).forEach((t) => {
10
- const i = e[t], u = typeof i;
11
- (u === "object" || u === "function") && !Object.isFrozen(i) && we(i);
12
- }), e;
13
- }
14
- class he {
15
- /**
16
- * @param {CompiledMode} mode
17
- */
18
- constructor(t) {
19
- t.data === void 0 && (t.data = {}), this.data = t.data, this.isMatchIgnored = !1;
20
- }
21
- ignoreMatch() {
22
- this.isMatchIgnored = !0;
23
- }
24
- }
25
- function xe(e) {
26
- return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
27
- }
28
- function B(e, ...t) {
29
- const i = /* @__PURE__ */ Object.create(null);
30
- for (const u in e)
31
- i[u] = e[u];
32
- return t.forEach(function(u) {
33
- for (const b in u)
34
- i[b] = u[b];
35
- }), /** @type {T} */
36
- i;
37
- }
38
- const qe = "</span>", pe = (e) => !!e.scope, Qe = (e, { prefix: t }) => {
39
- if (e.startsWith("language:"))
40
- return e.replace("language:", "language-");
41
- if (e.includes(".")) {
42
- const i = e.split(".");
43
- return [
44
- `${t}${i.shift()}`,
45
- ...i.map((u, b) => `${u}${"_".repeat(b + 1)}`)
46
- ].join(" ");
47
- }
48
- return `${t}${e}`;
49
- };
50
- class me {
51
- /**
52
- * Creates a new HTMLRenderer
53
- *
54
- * @param {Tree} parseTree - the parse tree (must support `walk` API)
55
- * @param {{classPrefix: string}} options
56
- */
57
- constructor(t, i) {
58
- this.buffer = "", this.classPrefix = i.classPrefix, t.walk(this);
59
- }
60
- /**
61
- * Adds texts to the output stream
62
- *
63
- * @param {string} text */
64
- addText(t) {
65
- this.buffer += xe(t);
66
- }
67
- /**
68
- * Adds a node open to the output stream (if needed)
69
- *
70
- * @param {Node} node */
71
- openNode(t) {
72
- if (!pe(t)) return;
73
- const i = Qe(
74
- t.scope,
75
- { prefix: this.classPrefix }
76
- );
77
- this.span(i);
78
- }
79
- /**
80
- * Adds a node close to the output stream (if needed)
81
- *
82
- * @param {Node} node */
83
- closeNode(t) {
84
- pe(t) && (this.buffer += qe);
85
- }
86
- /**
87
- * returns the accumulated buffer
88
- */
89
- value() {
90
- return this.buffer;
91
- }
92
- // helpers
93
- /**
94
- * Builds a span element
95
- *
96
- * @param {string} className */
97
- span(t) {
98
- this.buffer += `<span class="${t}">`;
99
- }
100
- }
101
- const de = (e = {}) => {
102
- const t = { children: [] };
103
- return Object.assign(t, e), t;
104
- };
105
- class te {
106
- constructor() {
107
- this.rootNode = de(), this.stack = [this.rootNode];
108
- }
109
- get top() {
110
- return this.stack[this.stack.length - 1];
111
- }
112
- get root() {
113
- return this.rootNode;
114
- }
115
- /** @param {Node} node */
116
- add(t) {
117
- this.top.children.push(t);
118
- }
119
- /** @param {string} scope */
120
- openNode(t) {
121
- const i = de({ scope: t });
122
- this.add(i), this.stack.push(i);
123
- }
124
- closeNode() {
125
- if (this.stack.length > 1)
126
- return this.stack.pop();
127
- }
128
- closeAllNodes() {
129
- for (; this.closeNode(); ) ;
130
- }
131
- toJSON() {
132
- return JSON.stringify(this.rootNode, null, 4);
133
- }
134
- /**
135
- * @typedef { import("./html_renderer").Renderer } Renderer
136
- * @param {Renderer} builder
137
- */
138
- walk(t) {
139
- return this.constructor._walk(t, this.rootNode);
140
- }
141
- /**
142
- * @param {Renderer} builder
143
- * @param {Node} node
144
- */
145
- static _walk(t, i) {
146
- return typeof i == "string" ? t.addText(i) : i.children && (t.openNode(i), i.children.forEach((u) => this._walk(t, u)), t.closeNode(i)), t;
147
- }
148
- /**
149
- * @param {Node} node
150
- */
151
- static _collapse(t) {
152
- typeof t != "string" && t.children && (t.children.every((i) => typeof i == "string") ? t.children = [t.children.join("")] : t.children.forEach((i) => {
153
- te._collapse(i);
154
- }));
155
- }
156
- }
157
- class et extends te {
158
- /**
159
- * @param {*} options
160
- */
161
- constructor(t) {
162
- super(), this.options = t;
163
- }
164
- /**
165
- * @param {string} text
166
- */
167
- addText(t) {
168
- t !== "" && this.add(t);
169
- }
170
- /** @param {string} scope */
171
- startScope(t) {
172
- this.openNode(t);
173
- }
174
- endScope() {
175
- this.closeNode();
176
- }
177
- /**
178
- * @param {Emitter & {root: DataNode}} emitter
179
- * @param {string} name
180
- */
181
- __addSublanguage(t, i) {
182
- const u = t.root;
183
- i && (u.scope = `language:${i}`), this.add(u);
184
- }
185
- toHTML() {
186
- return new me(this, this.options).value();
187
- }
188
- finalize() {
189
- return this.closeAllNodes(), !0;
190
- }
191
- }
192
- function P(e) {
193
- return e ? typeof e == "string" ? e : e.source : null;
194
- }
195
- function Oe(e) {
196
- return C("(?=", e, ")");
197
- }
198
- function tt(e) {
199
- return C("(?:", e, ")*");
200
- }
201
- function nt(e) {
202
- return C("(?:", e, ")?");
203
- }
204
- function C(...e) {
205
- return e.map((i) => P(i)).join("");
206
- }
207
- function it(e) {
208
- const t = e[e.length - 1];
209
- return typeof t == "object" && t.constructor === Object ? (e.splice(e.length - 1, 1), t) : {};
210
- }
211
- function ne(...e) {
212
- return "(" + (it(e).capture ? "" : "?:") + e.map((u) => P(u)).join("|") + ")";
213
- }
214
- function ye(e) {
215
- return new RegExp(e.toString() + "|").exec("").length - 1;
216
- }
217
- function st(e, t) {
218
- const i = e && e.exec(t);
219
- return i && i.index === 0;
220
- }
221
- const rt = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
222
- function ie(e, { joinWith: t }) {
223
- let i = 0;
224
- return e.map((u) => {
225
- i += 1;
226
- const b = i;
227
- let _ = P(u), c = "";
228
- for (; _.length > 0; ) {
229
- const r = rt.exec(_);
230
- if (!r) {
231
- c += _;
232
- break;
233
- }
234
- c += _.substring(0, r.index), _ = _.substring(r.index + r[0].length), r[0][0] === "\\" && r[1] ? c += "\\" + String(Number(r[1]) + b) : (c += r[0], r[0] === "(" && i++);
235
- }
236
- return c;
237
- }).map((u) => `(${u})`).join(t);
238
- }
239
- const ct = /\b\B/, Re = "[a-zA-Z]\\w*", se = "[a-zA-Z_]\\w*", Se = "\\b\\d+(\\.\\d+)?", Ne = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)", Ae = "\\b(0b[01]+)", ot = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~", at = (e = {}) => {
240
- const t = /^#![ ]*\//;
241
- return e.binary && (e.begin = C(
242
- t,
243
- /.*\b/,
244
- e.binary,
245
- /\b.*/
246
- )), B({
247
- scope: "meta",
248
- begin: t,
249
- end: /$/,
250
- relevance: 0,
251
- /** @type {ModeCallback} */
252
- "on:begin": (i, u) => {
253
- i.index !== 0 && u.ignoreMatch();
254
- }
255
- }, e);
256
- }, U = {
257
- begin: "\\\\[\\s\\S]",
258
- relevance: 0
259
- }, lt = {
260
- scope: "string",
261
- begin: "'",
262
- end: "'",
263
- illegal: "\\n",
264
- contains: [U]
265
- }, ut = {
266
- scope: "string",
267
- begin: '"',
268
- end: '"',
269
- illegal: "\\n",
270
- contains: [U]
271
- }, ft = {
272
- begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
273
- }, Y = function(e, t, i = {}) {
274
- const u = B(
275
- {
276
- scope: "comment",
277
- begin: e,
278
- end: t,
279
- contains: []
280
- },
281
- i
282
- );
283
- u.contains.push({
284
- scope: "doctag",
285
- // hack to avoid the space from being included. the space is necessary to
286
- // match here to prevent the plain text rule below from gobbling up doctags
287
- begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
288
- end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,
289
- excludeBegin: !0,
290
- relevance: 0
291
- });
292
- const b = ne(
293
- // list of common 1 and 2 letter words in English
294
- "I",
295
- "a",
296
- "is",
297
- "so",
298
- "us",
299
- "to",
300
- "at",
301
- "if",
302
- "in",
303
- "it",
304
- "on",
305
- // note: this is not an exhaustive list of contractions, just popular ones
306
- /[A-Za-z]+['](d|ve|re|ll|t|s|n)/,
307
- // contractions - can't we'd they're let's, etc
308
- /[A-Za-z]+[-][a-z]+/,
309
- // `no-way`, etc.
310
- /[A-Za-z][a-z]{2,}/
311
- // allow capitalized words at beginning of sentences
312
- );
313
- return u.contains.push(
314
- {
315
- // TODO: how to include ", (, ) without breaking grammars that use these for
316
- // comment delimiters?
317
- // begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/
318
- // ---
319
- // this tries to find sequences of 3 english words in a row (without any
320
- // "programming" type syntax) this gives us a strong signal that we've
321
- // TRULY found a comment - vs perhaps scanning with the wrong language.
322
- // It's possible to find something that LOOKS like the start of the
323
- // comment - but then if there is no readable text - good chance it is a
324
- // false match and not a comment.
325
- //
326
- // for a visual example please see:
327
- // https://github.com/highlightjs/highlight.js/issues/2827
328
- begin: C(
329
- /[ ]+/,
330
- // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */
331
- "(",
332
- b,
333
- /[.]?[:]?([.][ ]|[ ])/,
334
- "){3}"
335
- )
336
- // look for 3 words in a row
337
- }
338
- ), u;
339
- }, gt = Y("//", "$"), ht = Y("/\\*", "\\*/"), pt = Y("#", "$"), dt = {
340
- scope: "number",
341
- begin: Se,
342
- relevance: 0
343
- }, Et = {
344
- scope: "number",
345
- begin: Ne,
346
- relevance: 0
347
- }, bt = {
348
- scope: "number",
349
- begin: Ae,
350
- relevance: 0
351
- }, _t = {
352
- scope: "regexp",
353
- begin: /\/(?=[^/\n]*\/)/,
354
- end: /\/[gimuy]*/,
355
- contains: [
356
- U,
357
- {
358
- begin: /\[/,
359
- end: /\]/,
360
- relevance: 0,
361
- contains: [U]
362
- }
363
- ]
364
- }, Mt = {
365
- scope: "title",
366
- begin: Re,
367
- relevance: 0
368
- }, wt = {
369
- scope: "title",
370
- begin: se,
371
- relevance: 0
372
- }, xt = {
373
- // excludes method names from keyword processing
374
- begin: "\\.\\s*" + se,
375
- relevance: 0
376
- }, Ot = function(e) {
377
- return Object.assign(
378
- e,
379
- {
380
- /** @type {ModeCallback} */
381
- "on:begin": (t, i) => {
382
- i.data._beginMatch = t[1];
383
- },
384
- /** @type {ModeCallback} */
385
- "on:end": (t, i) => {
386
- i.data._beginMatch !== t[1] && i.ignoreMatch();
387
- }
388
- }
389
- );
390
- };
391
- var z = /* @__PURE__ */ Object.freeze({
392
- __proto__: null,
393
- APOS_STRING_MODE: lt,
394
- BACKSLASH_ESCAPE: U,
395
- BINARY_NUMBER_MODE: bt,
396
- BINARY_NUMBER_RE: Ae,
397
- COMMENT: Y,
398
- C_BLOCK_COMMENT_MODE: ht,
399
- C_LINE_COMMENT_MODE: gt,
400
- C_NUMBER_MODE: Et,
401
- C_NUMBER_RE: Ne,
402
- END_SAME_AS_BEGIN: Ot,
403
- HASH_COMMENT_MODE: pt,
404
- IDENT_RE: Re,
405
- MATCH_NOTHING_RE: ct,
406
- METHOD_GUARD: xt,
407
- NUMBER_MODE: dt,
408
- NUMBER_RE: Se,
409
- PHRASAL_WORDS_MODE: ft,
410
- QUOTE_STRING_MODE: ut,
411
- REGEXP_MODE: _t,
412
- RE_STARTERS_RE: ot,
413
- SHEBANG: at,
414
- TITLE_MODE: Mt,
415
- UNDERSCORE_IDENT_RE: se,
416
- UNDERSCORE_TITLE_MODE: wt
417
- });
418
- function yt(e, t) {
419
- e.input[e.index - 1] === "." && t.ignoreMatch();
420
- }
421
- function Rt(e, t) {
422
- e.className !== void 0 && (e.scope = e.className, delete e.className);
423
- }
424
- function St(e, t) {
425
- t && e.beginKeywords && (e.begin = "\\b(" + e.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)", e.__beforeBegin = yt, e.keywords = e.keywords || e.beginKeywords, delete e.beginKeywords, e.relevance === void 0 && (e.relevance = 0));
426
- }
427
- function Nt(e, t) {
428
- Array.isArray(e.illegal) && (e.illegal = ne(...e.illegal));
429
- }
430
- function At(e, t) {
431
- if (e.match) {
432
- if (e.begin || e.end) throw new Error("begin & end are not supported with match");
433
- e.begin = e.match, delete e.match;
434
- }
435
- }
436
- function kt(e, t) {
437
- e.relevance === void 0 && (e.relevance = 1);
438
- }
439
- const Tt = (e, t) => {
440
- if (!e.beforeMatch) return;
441
- if (e.starts) throw new Error("beforeMatch cannot be used with starts");
442
- const i = Object.assign({}, e);
443
- Object.keys(e).forEach((u) => {
444
- delete e[u];
445
- }), e.keywords = i.keywords, e.begin = C(i.beforeMatch, Oe(i.begin)), e.starts = {
446
- relevance: 0,
447
- contains: [
448
- Object.assign(i, { endsParent: !0 })
449
- ]
450
- }, e.relevance = 0, delete i.beforeMatch;
451
- }, It = [
452
- "of",
453
- "and",
454
- "for",
455
- "in",
456
- "not",
457
- "or",
458
- "if",
459
- "then",
460
- "parent",
461
- // common variable name
462
- "list",
463
- // common variable name
464
- "value"
465
- // common variable name
466
- ], Bt = "keyword";
467
- function ke(e, t, i = Bt) {
468
- const u = /* @__PURE__ */ Object.create(null);
469
- return typeof e == "string" ? b(i, e.split(" ")) : Array.isArray(e) ? b(i, e) : Object.keys(e).forEach(function(_) {
470
- Object.assign(
471
- u,
472
- ke(e[_], t, _)
473
- );
474
- }), u;
475
- function b(_, c) {
476
- t && (c = c.map((r) => r.toLowerCase())), c.forEach(function(r) {
477
- const l = r.split("|");
478
- u[l[0]] = [_, Dt(l[0], l[1])];
479
- });
480
- }
481
- }
482
- function Dt(e, t) {
483
- return t ? Number(t) : vt(e) ? 0 : 1;
484
- }
485
- function vt(e) {
486
- return It.includes(e.toLowerCase());
487
- }
488
- const Ee = {}, v = (e) => {
489
- console.error(e);
490
- }, be = (e, ...t) => {
491
- console.log(`WARN: ${e}`, ...t);
492
- }, L = (e, t) => {
493
- Ee[`${e}/${t}`] || (console.log(`Deprecated as of ${e}. ${t}`), Ee[`${e}/${t}`] = !0);
494
- }, X = new Error();
495
- function Te(e, t, { key: i }) {
496
- let u = 0;
497
- const b = e[i], _ = {}, c = {};
498
- for (let r = 1; r <= t.length; r++)
499
- c[r + u] = b[r], _[r + u] = !0, u += ye(t[r - 1]);
500
- e[i] = c, e[i]._emit = _, e[i]._multi = !0;
501
- }
502
- function Ct(e) {
503
- if (Array.isArray(e.begin)) {
504
- if (e.skip || e.excludeBegin || e.returnBegin)
505
- throw v("skip, excludeBegin, returnBegin not compatible with beginScope: {}"), X;
506
- if (typeof e.beginScope != "object" || e.beginScope === null)
507
- throw v("beginScope must be object"), X;
508
- Te(e, e.begin, { key: "beginScope" }), e.begin = ie(e.begin, { joinWith: "" });
509
- }
510
- }
511
- function Lt(e) {
512
- if (Array.isArray(e.end)) {
513
- if (e.skip || e.excludeEnd || e.returnEnd)
514
- throw v("skip, excludeEnd, returnEnd not compatible with endScope: {}"), X;
515
- if (typeof e.endScope != "object" || e.endScope === null)
516
- throw v("endScope must be object"), X;
517
- Te(e, e.end, { key: "endScope" }), e.end = ie(e.end, { joinWith: "" });
518
- }
519
- }
520
- function jt(e) {
521
- e.scope && typeof e.scope == "object" && e.scope !== null && (e.beginScope = e.scope, delete e.scope);
522
- }
523
- function Ht(e) {
524
- jt(e), typeof e.beginScope == "string" && (e.beginScope = { _wrap: e.beginScope }), typeof e.endScope == "string" && (e.endScope = { _wrap: e.endScope }), Ct(e), Lt(e);
525
- }
526
- function Pt(e) {
527
- function t(c, r) {
528
- return new RegExp(
529
- P(c),
530
- "m" + (e.case_insensitive ? "i" : "") + (e.unicodeRegex ? "u" : "") + (r ? "g" : "")
531
- );
532
- }
533
- class i {
534
- constructor() {
535
- this.matchIndexes = {}, this.regexes = [], this.matchAt = 1, this.position = 0;
536
- }
537
- // @ts-ignore
538
- addRule(r, l) {
539
- l.position = this.position++, this.matchIndexes[this.matchAt] = l, this.regexes.push([l, r]), this.matchAt += ye(r) + 1;
540
- }
541
- compile() {
542
- this.regexes.length === 0 && (this.exec = () => null);
543
- const r = this.regexes.map((l) => l[1]);
544
- this.matcherRe = t(ie(r, { joinWith: "|" }), !0), this.lastIndex = 0;
545
- }
546
- /** @param {string} s */
547
- exec(r) {
548
- this.matcherRe.lastIndex = this.lastIndex;
549
- const l = this.matcherRe.exec(r);
550
- if (!l)
551
- return null;
552
- const x = l.findIndex((H, Z) => Z > 0 && H !== void 0), M = this.matchIndexes[x];
553
- return l.splice(0, x), Object.assign(l, M);
554
- }
555
- }
556
- class u {
557
- constructor() {
558
- this.rules = [], this.multiRegexes = [], this.count = 0, this.lastIndex = 0, this.regexIndex = 0;
559
- }
560
- // @ts-ignore
561
- getMatcher(r) {
562
- if (this.multiRegexes[r]) return this.multiRegexes[r];
563
- const l = new i();
564
- return this.rules.slice(r).forEach(([x, M]) => l.addRule(x, M)), l.compile(), this.multiRegexes[r] = l, l;
565
- }
566
- resumingScanAtSamePosition() {
567
- return this.regexIndex !== 0;
568
- }
569
- considerAll() {
570
- this.regexIndex = 0;
571
- }
572
- // @ts-ignore
573
- addRule(r, l) {
574
- this.rules.push([r, l]), l.type === "begin" && this.count++;
575
- }
576
- /** @param {string} s */
577
- exec(r) {
578
- const l = this.getMatcher(this.regexIndex);
579
- l.lastIndex = this.lastIndex;
580
- let x = l.exec(r);
581
- if (this.resumingScanAtSamePosition() && !(x && x.index === this.lastIndex)) {
582
- const M = this.getMatcher(0);
583
- M.lastIndex = this.lastIndex + 1, x = M.exec(r);
584
- }
585
- return x && (this.regexIndex += x.position + 1, this.regexIndex === this.count && this.considerAll()), x;
586
- }
587
- }
588
- function b(c) {
589
- const r = new u();
590
- return c.contains.forEach((l) => r.addRule(l.begin, { rule: l, type: "begin" })), c.terminatorEnd && r.addRule(c.terminatorEnd, { type: "end" }), c.illegal && r.addRule(c.illegal, { type: "illegal" }), r;
591
- }
592
- function _(c, r) {
593
- const l = (
594
- /** @type CompiledMode */
595
- c
596
- );
597
- if (c.isCompiled) return l;
598
- [
599
- Rt,
600
- // do this early so compiler extensions generally don't have to worry about
601
- // the distinction between match/begin
602
- At,
603
- Ht,
604
- Tt
605
- ].forEach((M) => M(c, r)), e.compilerExtensions.forEach((M) => M(c, r)), c.__beforeBegin = null, [
606
- St,
607
- // do this later so compiler extensions that come earlier have access to the
608
- // raw array if they wanted to perhaps manipulate it, etc.
609
- Nt,
610
- // default to 1 relevance if not specified
611
- kt
612
- ].forEach((M) => M(c, r)), c.isCompiled = !0;
613
- let x = null;
614
- return typeof c.keywords == "object" && c.keywords.$pattern && (c.keywords = Object.assign({}, c.keywords), x = c.keywords.$pattern, delete c.keywords.$pattern), x = x || /\w+/, c.keywords && (c.keywords = ke(c.keywords, e.case_insensitive)), l.keywordPatternRe = t(x, !0), r && (c.begin || (c.begin = /\B|\b/), l.beginRe = t(l.begin), !c.end && !c.endsWithParent && (c.end = /\B|\b/), c.end && (l.endRe = t(l.end)), l.terminatorEnd = P(l.end) || "", c.endsWithParent && r.terminatorEnd && (l.terminatorEnd += (c.end ? "|" : "") + r.terminatorEnd)), c.illegal && (l.illegalRe = t(
615
- /** @type {RegExp | string} */
616
- c.illegal
617
- )), c.contains || (c.contains = []), c.contains = [].concat(...c.contains.map(function(M) {
618
- return Ut(M === "self" ? c : M);
619
- })), c.contains.forEach(function(M) {
620
- _(
621
- /** @type Mode */
622
- M,
623
- l
624
- );
625
- }), c.starts && _(c.starts, r), l.matcher = b(l), l;
626
- }
627
- if (e.compilerExtensions || (e.compilerExtensions = []), e.contains && e.contains.includes("self"))
628
- throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
629
- return e.classNameAliases = B(e.classNameAliases || {}), _(
630
- /** @type Mode */
631
- e
632
- );
633
- }
634
- function Ie(e) {
635
- return e ? e.endsWithParent || Ie(e.starts) : !1;
636
- }
637
- function Ut(e) {
638
- return e.variants && !e.cachedVariants && (e.cachedVariants = e.variants.map(function(t) {
639
- return B(e, { variants: null }, t);
640
- })), e.cachedVariants ? e.cachedVariants : Ie(e) ? B(e, { starts: e.starts ? B(e.starts) : null }) : Object.isFrozen(e) ? B(e) : e;
641
- }
642
- var $t = "11.11.1";
643
- class Gt extends Error {
644
- constructor(t, i) {
645
- super(t), this.name = "HTMLInjectionError", this.html = i;
646
- }
647
- }
648
- const ee = xe, _e = B, Me = Symbol("nomatch"), Wt = 7, Be = function(e) {
649
- const t = /* @__PURE__ */ Object.create(null), i = /* @__PURE__ */ Object.create(null), u = [];
650
- let b = !0;
651
- const _ = "Could not find the language '{}', did you forget to load/include a language module?", c = { disableAutodetect: !0, name: "Plain text", contains: [] };
652
- let r = {
653
- ignoreUnescapedHTML: !1,
654
- throwUnescapedHTML: !1,
655
- noHighlightRe: /^(no-?highlight)$/i,
656
- languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
657
- classPrefix: "hljs-",
658
- cssSelector: "pre code",
659
- languages: null,
660
- // beta configuration options, subject to change, welcome to discuss
661
- // https://github.com/highlightjs/highlight.js/issues/1086
662
- __emitter: et
663
- };
664
- function l(n) {
665
- return r.noHighlightRe.test(n);
666
- }
667
- function x(n) {
668
- let a = n.className + " ";
669
- a += n.parentNode ? n.parentNode.className : "";
670
- const h = r.languageDetectRe.exec(a);
671
- if (h) {
672
- const d = T(h[1]);
673
- return d || (be(_.replace("{}", h[1])), be("Falling back to no-highlight mode for this block.", n)), d ? h[1] : "no-highlight";
674
- }
675
- return a.split(/\s+/).find((d) => l(d) || T(d));
676
- }
677
- function M(n, a, h) {
678
- let d = "", w = "";
679
- typeof a == "object" ? (d = n, h = a.ignoreIllegals, w = a.language) : (L("10.7.0", "highlight(lang, code, ...args) has been deprecated."), L("10.7.0", `Please use highlight(code, options) instead.
680
- https://github.com/highlightjs/highlight.js/issues/2277`), w = n, d = a), h === void 0 && (h = !0);
681
- const S = {
682
- code: d,
683
- language: w
684
- };
685
- G("before:highlight", S);
686
- const I = S.result ? S.result : H(S.language, S.code, h);
687
- return I.code = S.code, G("after:highlight", I), I;
688
- }
689
- function H(n, a, h, d) {
690
- const w = /* @__PURE__ */ Object.create(null);
691
- function S(s, o) {
692
- return s.keywords[o];
693
- }
694
- function I() {
695
- if (!f.keywords) {
696
- O.addText(E);
697
- return;
698
- }
699
- let s = 0;
700
- f.keywordPatternRe.lastIndex = 0;
701
- let o = f.keywordPatternRe.exec(E), g = "";
702
- for (; o; ) {
703
- g += E.substring(s, o.index);
704
- const p = A.case_insensitive ? o[0].toLowerCase() : o[0], y = S(f, p);
705
- if (y) {
706
- const [k, Ze] = y;
707
- if (O.addText(g), g = "", w[p] = (w[p] || 0) + 1, w[p] <= Wt && (F += Ze), k.startsWith("_"))
708
- g += o[0];
709
- else {
710
- const Je = A.classNameAliases[k] || k;
711
- N(o[0], Je);
712
- }
713
- } else
714
- g += o[0];
715
- s = f.keywordPatternRe.lastIndex, o = f.keywordPatternRe.exec(E);
716
- }
717
- g += E.substring(s), O.addText(g);
718
- }
719
- function W() {
720
- if (E === "") return;
721
- let s = null;
722
- if (typeof f.subLanguage == "string") {
723
- if (!t[f.subLanguage]) {
724
- O.addText(E);
725
- return;
726
- }
727
- s = H(f.subLanguage, E, !0, ge[f.subLanguage]), ge[f.subLanguage] = /** @type {CompiledMode} */
728
- s._top;
729
- } else
730
- s = J(E, f.subLanguage.length ? f.subLanguage : null);
731
- f.relevance > 0 && (F += s.relevance), O.__addSublanguage(s._emitter, s.language);
732
- }
733
- function R() {
734
- f.subLanguage != null ? W() : I(), E = "";
735
- }
736
- function N(s, o) {
737
- s !== "" && (O.startScope(o), O.addText(s), O.endScope());
738
- }
739
- function ae(s, o) {
740
- let g = 1;
741
- const p = o.length - 1;
742
- for (; g <= p; ) {
743
- if (!s._emit[g]) {
744
- g++;
745
- continue;
746
- }
747
- const y = A.classNameAliases[s[g]] || s[g], k = o[g];
748
- y ? N(k, y) : (E = k, I(), E = ""), g++;
749
- }
750
- }
751
- function le(s, o) {
752
- return s.scope && typeof s.scope == "string" && O.openNode(A.classNameAliases[s.scope] || s.scope), s.beginScope && (s.beginScope._wrap ? (N(E, A.classNameAliases[s.beginScope._wrap] || s.beginScope._wrap), E = "") : s.beginScope._multi && (ae(s.beginScope, o), E = "")), f = Object.create(s, { parent: { value: f } }), f;
753
- }
754
- function ue(s, o, g) {
755
- let p = st(s.endRe, g);
756
- if (p) {
757
- if (s["on:end"]) {
758
- const y = new he(s);
759
- s["on:end"](o, y), y.isMatchIgnored && (p = !1);
760
- }
761
- if (p) {
762
- for (; s.endsParent && s.parent; )
763
- s = s.parent;
764
- return s;
765
- }
766
- }
767
- if (s.endsWithParent)
768
- return ue(s.parent, o, g);
769
- }
770
- function Ke(s) {
771
- return f.matcher.regexIndex === 0 ? (E += s[0], 1) : (m = !0, 0);
772
- }
773
- function Fe(s) {
774
- const o = s[0], g = s.rule, p = new he(g), y = [g.__beforeBegin, g["on:begin"]];
775
- for (const k of y)
776
- if (k && (k(s, p), p.isMatchIgnored))
777
- return Ke(o);
778
- return g.skip ? E += o : (g.excludeBegin && (E += o), R(), !g.returnBegin && !g.excludeBegin && (E = o)), le(g, s), g.returnBegin ? 0 : o.length;
779
- }
780
- function ze(s) {
781
- const o = s[0], g = a.substring(s.index), p = ue(f, s, g);
782
- if (!p)
783
- return Me;
784
- const y = f;
785
- f.endScope && f.endScope._wrap ? (R(), N(o, f.endScope._wrap)) : f.endScope && f.endScope._multi ? (R(), ae(f.endScope, s)) : y.skip ? E += o : (y.returnEnd || y.excludeEnd || (E += o), R(), y.excludeEnd && (E = o));
786
- do
787
- f.scope && O.closeNode(), !f.skip && !f.subLanguage && (F += f.relevance), f = f.parent;
788
- while (f !== p.parent);
789
- return p.starts && le(p.starts, s), y.returnEnd ? 0 : o.length;
790
- }
791
- function Xe() {
792
- const s = [];
793
- for (let o = f; o !== A; o = o.parent)
794
- o.scope && s.unshift(o.scope);
795
- s.forEach((o) => O.openNode(o));
796
- }
797
- let K = {};
798
- function fe(s, o) {
799
- const g = o && o[0];
800
- if (E += s, g == null)
801
- return R(), 0;
802
- if (K.type === "begin" && o.type === "end" && K.index === o.index && g === "") {
803
- if (E += a.slice(o.index, o.index + 1), !b) {
804
- const p = new Error(`0 width match regex (${n})`);
805
- throw p.languageName = n, p.badRule = K.rule, p;
806
- }
807
- return 1;
808
- }
809
- if (K = o, o.type === "begin")
810
- return Fe(o);
811
- if (o.type === "illegal" && !h) {
812
- const p = new Error('Illegal lexeme "' + g + '" for mode "' + (f.scope || "<unnamed>") + '"');
813
- throw p.mode = f, p;
814
- } else if (o.type === "end") {
815
- const p = ze(o);
816
- if (p !== Me)
817
- return p;
818
- }
819
- if (o.type === "illegal" && g === "")
820
- return E += `
821
- `, 1;
822
- if (Q > 1e5 && Q > o.index * 3)
823
- throw new Error("potential infinite loop, way more iterations than matches");
824
- return E += g, g.length;
825
- }
826
- const A = T(n);
827
- if (!A)
828
- throw v(_.replace("{}", n)), new Error('Unknown language: "' + n + '"');
829
- const Ye = Pt(A);
830
- let q = "", f = d || Ye;
831
- const ge = {}, O = new r.__emitter(r);
832
- Xe();
833
- let E = "", F = 0, D = 0, Q = 0, m = !1;
834
- try {
835
- if (A.__emitTokens)
836
- A.__emitTokens(a, O);
837
- else {
838
- for (f.matcher.considerAll(); ; ) {
839
- Q++, m ? m = !1 : f.matcher.considerAll(), f.matcher.lastIndex = D;
840
- const s = f.matcher.exec(a);
841
- if (!s) break;
842
- const o = a.substring(D, s.index), g = fe(o, s);
843
- D = s.index + g;
844
- }
845
- fe(a.substring(D));
846
- }
847
- return O.finalize(), q = O.toHTML(), {
848
- language: n,
849
- value: q,
850
- relevance: F,
851
- illegal: !1,
852
- _emitter: O,
853
- _top: f
854
- };
855
- } catch (s) {
856
- if (s.message && s.message.includes("Illegal"))
857
- return {
858
- language: n,
859
- value: ee(a),
860
- illegal: !0,
861
- relevance: 0,
862
- _illegalBy: {
863
- message: s.message,
864
- index: D,
865
- context: a.slice(D - 100, D + 100),
866
- mode: s.mode,
867
- resultSoFar: q
868
- },
869
- _emitter: O
870
- };
871
- if (b)
872
- return {
873
- language: n,
874
- value: ee(a),
875
- illegal: !1,
876
- relevance: 0,
877
- errorRaised: s,
878
- _emitter: O,
879
- _top: f
880
- };
881
- throw s;
882
- }
883
- }
884
- function Z(n) {
885
- const a = {
886
- value: ee(n),
887
- illegal: !1,
888
- relevance: 0,
889
- _top: c,
890
- _emitter: new r.__emitter(r)
891
- };
892
- return a._emitter.addText(n), a;
893
- }
894
- function J(n, a) {
895
- a = a || r.languages || Object.keys(t);
896
- const h = Z(n), d = a.filter(T).filter(oe).map(
897
- (R) => H(R, n, !1)
898
- );
899
- d.unshift(h);
900
- const w = d.sort((R, N) => {
901
- if (R.relevance !== N.relevance) return N.relevance - R.relevance;
902
- if (R.language && N.language) {
903
- if (T(R.language).supersetOf === N.language)
904
- return 1;
905
- if (T(N.language).supersetOf === R.language)
906
- return -1;
907
- }
908
- return 0;
909
- }), [S, I] = w, W = S;
910
- return W.secondBest = I, W;
911
- }
912
- function De(n, a, h) {
913
- const d = a && i[a] || h;
914
- n.classList.add("hljs"), n.classList.add(`language-${d}`);
915
- }
916
- function V(n) {
917
- let a = null;
918
- const h = x(n);
919
- if (l(h)) return;
920
- if (G(
921
- "before:highlightElement",
922
- { el: n, language: h }
923
- ), n.dataset.highlighted) {
924
- console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", n);
925
- return;
926
- }
927
- if (n.children.length > 0 && (r.ignoreUnescapedHTML || (console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."), console.warn("https://github.com/highlightjs/highlight.js/wiki/security"), console.warn("The element with unescaped HTML:"), console.warn(n)), r.throwUnescapedHTML))
928
- throw new Gt(
929
- "One of your code blocks includes unescaped HTML.",
930
- n.innerHTML
931
- );
932
- a = n;
933
- const d = a.textContent, w = h ? M(d, { language: h, ignoreIllegals: !0 }) : J(d);
934
- n.innerHTML = w.value, n.dataset.highlighted = "yes", De(n, h, w.language), n.result = {
935
- language: w.language,
936
- // TODO: remove with version 11.0
937
- re: w.relevance,
938
- relevance: w.relevance
939
- }, w.secondBest && (n.secondBest = {
940
- language: w.secondBest.language,
941
- relevance: w.secondBest.relevance
942
- }), G("after:highlightElement", { el: n, result: w, text: d });
943
- }
944
- function ve(n) {
945
- r = _e(r, n);
946
- }
947
- const Ce = () => {
948
- $(), L("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
949
- };
950
- function Le() {
951
- $(), L("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now.");
952
- }
953
- let re = !1;
954
- function $() {
955
- function n() {
956
- $();
957
- }
958
- if (document.readyState === "loading") {
959
- re || window.addEventListener("DOMContentLoaded", n, !1), re = !0;
960
- return;
961
- }
962
- document.querySelectorAll(r.cssSelector).forEach(V);
963
- }
964
- function je(n, a) {
965
- let h = null;
966
- try {
967
- h = a(e);
968
- } catch (d) {
969
- if (v("Language definition for '{}' could not be registered.".replace("{}", n)), b)
970
- v(d);
971
- else
972
- throw d;
973
- h = c;
974
- }
975
- h.name || (h.name = n), t[n] = h, h.rawDefinition = a.bind(null, e), h.aliases && ce(h.aliases, { languageName: n });
976
- }
977
- function He(n) {
978
- delete t[n];
979
- for (const a of Object.keys(i))
980
- i[a] === n && delete i[a];
981
- }
982
- function Pe() {
983
- return Object.keys(t);
984
- }
985
- function T(n) {
986
- return n = (n || "").toLowerCase(), t[n] || t[i[n]];
987
- }
988
- function ce(n, { languageName: a }) {
989
- typeof n == "string" && (n = [n]), n.forEach((h) => {
990
- i[h.toLowerCase()] = a;
991
- });
992
- }
993
- function oe(n) {
994
- const a = T(n);
995
- return a && !a.disableAutodetect;
996
- }
997
- function Ue(n) {
998
- n["before:highlightBlock"] && !n["before:highlightElement"] && (n["before:highlightElement"] = (a) => {
999
- n["before:highlightBlock"](
1000
- Object.assign({ block: a.el }, a)
1001
- );
1002
- }), n["after:highlightBlock"] && !n["after:highlightElement"] && (n["after:highlightElement"] = (a) => {
1003
- n["after:highlightBlock"](
1004
- Object.assign({ block: a.el }, a)
1005
- );
1006
- });
1007
- }
1008
- function $e(n) {
1009
- Ue(n), u.push(n);
1010
- }
1011
- function Ge(n) {
1012
- const a = u.indexOf(n);
1013
- a !== -1 && u.splice(a, 1);
1014
- }
1015
- function G(n, a) {
1016
- const h = n;
1017
- u.forEach(function(d) {
1018
- d[h] && d[h](a);
1019
- });
1020
- }
1021
- function We(n) {
1022
- return L("10.7.0", "highlightBlock will be removed entirely in v12.0"), L("10.7.0", "Please use highlightElement now."), V(n);
1023
- }
1024
- Object.assign(e, {
1025
- highlight: M,
1026
- highlightAuto: J,
1027
- highlightAll: $,
1028
- highlightElement: V,
1029
- // TODO: Remove with v12 API
1030
- highlightBlock: We,
1031
- configure: ve,
1032
- initHighlighting: Ce,
1033
- initHighlightingOnLoad: Le,
1034
- registerLanguage: je,
1035
- unregisterLanguage: He,
1036
- listLanguages: Pe,
1037
- getLanguage: T,
1038
- registerAliases: ce,
1039
- autoDetection: oe,
1040
- inherit: _e,
1041
- addPlugin: $e,
1042
- removePlugin: Ge
1043
- }), e.debugMode = function() {
1044
- b = !1;
1045
- }, e.safeMode = function() {
1046
- b = !0;
1047
- }, e.versionString = $t, e.regex = {
1048
- concat: C,
1049
- lookahead: Oe,
1050
- either: ne,
1051
- optional: nt,
1052
- anyNumberOfTimes: tt
1053
- };
1054
- for (const n in z)
1055
- typeof z[n] == "object" && we(z[n]);
1056
- return Object.assign(e, z), e;
1057
- }, j = Be({});
1058
- j.newInstance = () => Be({});
1059
- var Kt = j;
1060
- j.HighlightJS = j;
1061
- j.default = j;
1062
- const Ft = /* @__PURE__ */ Ve(Kt);
1063
- export {
1064
- Ft as HighlightJS,
1065
- Ft as default
1066
- };