@hep-code-runner/vue3 2.2.1 → 2.2.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.
Files changed (3) hide show
  1. package/dist/index.js +231 -1
  2. package/dist/index.mjs +477 -3162
  3. package/package.json +3 -2
package/dist/index.mjs CHANGED
@@ -1,182 +1,78 @@
1
- import { defineComponent, useCssVars, ref, computed, onMounted, watch, onUnmounted, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, withDirectives, createCommentVNode, Fragment, renderList, toDisplayString, vModelSelect, createTextVNode, createStaticVNode, createVNode, createBlock, Teleport, Transition, withCtx, mergeProps, toHandlers, renderSlot } from "vue";
2
- var w = Object.defineProperty;
3
- var y = (o, e, t) => e in o ? w(o, e, { enumerable: true, configurable: true, writable: true, value: t }) : o[e] = t;
4
- var c = (o, e, t) => y(o, typeof e != "symbol" ? e + "" : e, t);
5
- let u = null;
6
- class W {
7
- constructor(e = {}) {
8
- c(this, "baseUrl");
9
- c(this, "timeout");
10
- this.baseUrl = e.pistonUrl || "/api/piston", this.timeout = e.timeout || 3e3;
1
+ import { defineComponent as oe, useCssVars as me, ref as O, computed as D, onMounted as de, watch as se, onUnmounted as fe, openBlock as A, createElementBlock as T, normalizeClass as B, createElementVNode as v, normalizeStyle as K, withDirectives as be, createCommentVNode as P, Fragment as Ee, renderList as ve, toDisplayString as M, vModelSelect as ye, createTextVNode as ke, createStaticVNode as Se, createVNode as re, createBlock as we, Teleport as Ae, Transition as Te, withCtx as xe, mergeProps as Fe, toHandlers as Ie, renderSlot as _e } from "vue";
2
+ var Re = Object.defineProperty, le = (c, n, i) => ((l, f, b) => f in l ? Re(l, f, { enumerable: !0, configurable: !0, writable: !0, value: b }) : l[f] = b)(c, typeof n != "symbol" ? n + "" : n, i);
3
+ let ne = null;
4
+ class Ne {
5
+ constructor(n = {}) {
6
+ le(this, "baseUrl"), le(this, "timeout"), this.baseUrl = n.pistonUrl || "/api/piston", this.timeout = n.timeout || 3e3;
11
7
  }
12
- async getRuntimes(e = false) {
13
- if (u && !e)
14
- return u;
8
+ async getRuntimes(n = !1) {
9
+ if (ne && !n) return ne;
15
10
  try {
16
- const t = await fetch(`${this.baseUrl}/runtimes`, {
17
- method: "GET",
18
- headers: {
19
- "Content-Type": "application/json"
20
- }
21
- });
22
- if (!t.ok)
23
- throw new Error(`Failed to fetch runtimes: ${t.statusText}`);
24
- const n = await t.json();
25
- return u = n, n;
26
- } catch (t) {
27
- throw console.error("Failed to fetch runtimes:", t), t;
11
+ const i = await fetch(`${this.baseUrl}/runtimes`, { method: "GET", headers: { "Content-Type": "application/json" } });
12
+ if (!i.ok) throw new Error(`Failed to fetch runtimes: ${i.statusText}`);
13
+ const l = await i.json();
14
+ return ne = l, l;
15
+ } catch (i) {
16
+ throw i;
28
17
  }
29
18
  }
30
- async execute(e, t, n = {}) {
31
- const l = (await this.getRuntimes()).find(
32
- (a) => {
33
- var r;
34
- return a.language.toLowerCase() === e.toLowerCase() || ((r = a.aliases) == null ? void 0 : r.some((i) => i.toLowerCase() === e.toLowerCase()));
35
- }
36
- );
37
- if (!l)
38
- throw new Error(`Language '${e}' is not supported`);
39
- const p = this.getFileName(e), h = {
40
- language: l.language,
41
- version: n.version || l.version,
42
- files: [
43
- {
44
- name: p,
45
- content: t
46
- }
47
- ],
48
- stdin: n.stdin || "",
49
- args: n.args || [],
50
- run_timeout: n.runTimeout || this.timeout,
51
- compile_timeout: this.timeout
52
- }, d = Date.now();
19
+ async execute(n, i, l = {}) {
20
+ const f = (await this.getRuntimes()).find((k) => {
21
+ var d;
22
+ return k.language.toLowerCase() === n.toLowerCase() || ((d = k.aliases) == null ? void 0 : d.some((S) => S.toLowerCase() === n.toLowerCase()));
23
+ });
24
+ if (!f) throw new Error(`Language '${n}' is not supported`);
25
+ const b = this.getFileName(n), s = { language: f.language, version: l.version || f.version, files: [{ name: b, content: i }], stdin: l.stdin || "", args: l.args || [], run_timeout: l.runTimeout || this.timeout, compile_timeout: this.timeout }, y = Date.now();
53
26
  try {
54
- const a = await fetch(`${this.baseUrl}/execute`, {
55
- method: "POST",
56
- headers: {
57
- "Content-Type": "application/json"
58
- },
59
- body: JSON.stringify(h)
60
- });
61
- if (!a.ok)
62
- throw new Error(`Execute failed: ${a.statusText}`);
63
- const r = await a.json(), i = Date.now() - d, g = r.run.stdout || "", f = r.run.stderr || "";
64
- return {
65
- success: r.run.code === 0,
66
- output: g,
67
- stderr: f,
68
- code: r.run.code,
69
- executionTime: i,
70
- compile: r.compile ? {
71
- stdout: r.compile.stdout || "",
72
- stderr: r.compile.stderr || "",
73
- code: r.compile.code
74
- } : void 0
75
- };
76
- } catch (a) {
77
- return {
78
- success: false,
79
- output: "",
80
- stderr: a instanceof Error ? a.message : "Unknown error",
81
- code: -1,
82
- executionTime: Date.now() - d
83
- };
27
+ const k = await fetch(`${this.baseUrl}/execute`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(s) });
28
+ if (!k.ok) throw new Error(`Execute failed: ${k.statusText}`);
29
+ const d = await k.json(), S = Date.now() - y, I = d.run.stdout || "", x = d.run.stderr || "";
30
+ return { success: d.run.code === 0, output: I, stderr: x, code: d.run.code, executionTime: S, compile: d.compile ? { stdout: d.compile.stdout || "", stderr: d.compile.stderr || "", code: d.compile.code } : void 0 };
31
+ } catch (k) {
32
+ return { success: !1, output: "", stderr: k instanceof Error ? k.message : "Unknown error", code: -1, executionTime: Date.now() - y };
84
33
  }
85
34
  }
86
- getFileName(e) {
87
- return {
88
- javascript: "main.js",
89
- typescript: "main.ts",
90
- python: "main.py",
91
- python3: "main.py",
92
- go: "main.go",
93
- rust: "main.rs",
94
- java: "Main.java",
95
- c: "main.c",
96
- cpp: "main.cpp",
97
- csharp: "Main.cs",
98
- ruby: "main.rb",
99
- php: "main.php",
100
- bash: "main.sh",
101
- shell: "main.sh",
102
- perl: "main.pl",
103
- lua: "main.lua",
104
- swift: "main.swift",
105
- kotlin: "Main.kt",
106
- scala: "Main.scala",
107
- haskell: "main.hs",
108
- dart: "main.dart",
109
- html: "index.html",
110
- css: "style.css",
111
- sql: "query.sql",
112
- markdown: "readme.md"
113
- }[e.toLowerCase()] || `main.${e}`;
35
+ getFileName(n) {
36
+ return { javascript: "main.js", typescript: "main.ts", python: "main.py", python3: "main.py", go: "main.go", rust: "main.rs", java: "Main.java", c: "main.c", cpp: "main.cpp", csharp: "Main.cs", ruby: "main.rb", php: "main.php", bash: "main.sh", shell: "main.sh", perl: "main.pl", lua: "main.lua", swift: "main.swift", kotlin: "Main.kt", scala: "Main.scala", haskell: "main.hs", dart: "main.dart", html: "index.html", css: "style.css", sql: "query.sql", markdown: "readme.md" }[n.toLowerCase()] || `main.${n}`;
114
37
  }
115
38
  }
116
- const m = {
117
- javascript: 'console.log("Hello, World!");',
118
- typescript: 'console.log("Hello, World!");',
119
- python: 'print("Hello, World!")',
120
- python3: 'print("Hello, World!")',
121
- go: `package main
39
+ const Oe = { javascript: 'console.log("Hello, World!");', typescript: 'console.log("Hello, World!");', python: 'print("Hello, World!")', python3: 'print("Hello, World!")', go: `package main
122
40
 
123
41
  import "fmt"
124
42
 
125
43
  func main() {
126
44
  fmt.Println("Hello, World!")
127
- }`,
128
- rust: `fn main() {
45
+ }`, rust: `fn main() {
129
46
  println!("Hello, World!");
130
- }`,
131
- java: `public class Main {
47
+ }`, java: `public class Main {
132
48
  public static void main(String[] args) {
133
49
  System.out.println("Hello, World!");
134
50
  }
135
- }`,
136
- c: `#include <stdio.h>
51
+ }`, c: `#include <stdio.h>
137
52
 
138
53
  int main() {
139
54
  printf("Hello, World!\\n");
140
55
  return 0;
141
- }`,
142
- cpp: `#include <iostream>
56
+ }`, cpp: `#include <iostream>
143
57
 
144
58
  int main() {
145
59
  std::cout << "Hello, World!" << std::endl;
146
60
  return 0;
147
- }`,
148
- csharp: `using System;
61
+ }`, csharp: `using System;
149
62
 
150
63
  class Main {
151
64
  static void Main() {
152
65
  Console.WriteLine("Hello, World!");
153
66
  }
154
- }`,
155
- ruby: 'puts "Hello, World!"',
156
- php: `<?php
67
+ }`, ruby: 'puts "Hello, World!"', php: `<?php
157
68
  echo "Hello, World!";
158
- ?>`,
159
- bash: 'echo "Hello, World!"',
160
- shell: 'echo "Hello, World!"',
161
- perl: 'print "Hello, World!\\n";',
162
- lua: 'print("Hello, World!")',
163
- r: 'print("Hello, World!")',
164
- swift: 'print("Hello, World!")',
165
- kotlin: `fun main() {
69
+ ?>`, bash: 'echo "Hello, World!"', shell: 'echo "Hello, World!"', perl: 'print "Hello, World!\\n";', lua: 'print("Hello, World!")', r: 'print("Hello, World!")', swift: 'print("Hello, World!")', kotlin: `fun main() {
166
70
  println("Hello, World!")
167
- }`,
168
- scala: `object Main extends App {
71
+ }`, scala: `object Main extends App {
169
72
  println("Hello, World!")
170
- }`,
171
- haskell: 'main = putStrLn "Hello, World!"',
172
- elixir: 'IO.puts "Hello, World!"',
173
- erlang: 'main() -> io:fwrite("Hello, World!~n").',
174
- clojure: '(println "Hello, World!")',
175
- fsharp: 'printfn "Hello, World!"',
176
- dart: `void main() {
73
+ }`, haskell: 'main = putStrLn "Hello, World!"', elixir: 'IO.puts "Hello, World!"', erlang: 'main() -> io:fwrite("Hello, World!~n").', clojure: '(println "Hello, World!")', fsharp: 'printfn "Hello, World!"', dart: `void main() {
177
74
  print("Hello, World!");
178
- }`,
179
- assembly: `section .data
75
+ }`, assembly: `section .data
180
76
  msg db 'Hello, World!', 0
181
77
  section .text
182
78
  global _start
@@ -188,8 +84,7 @@ _start:
188
84
  syscall
189
85
  mov rax, 60
190
86
  xor rdi, rdi
191
- syscall`,
192
- html: `<!DOCTYPE html>
87
+ syscall`, html: `<!DOCTYPE html>
193
88
  <html>
194
89
  <head>
195
90
  <title>Hello</title>
@@ -197,2345 +92,331 @@ _start:
197
92
  <body>
198
93
  <h1>Hello, World!</h1>
199
94
  </body>
200
- </html>`,
201
- css: `body {
95
+ </html>`, css: `body {
202
96
  background-color: #f0f0f0;
203
97
  font-family: Arial, sans-serif;
204
98
  }
205
99
 
206
100
  h1 {
207
101
  color: #333;
208
- }`,
209
- sql: "SELECT 'Hello, World!' AS message;",
210
- markdown: `# Hello, World!
102
+ }`, sql: "SELECT 'Hello, World!' AS message;", markdown: `# Hello, World!
211
103
 
212
- This is a sample markdown document.`
213
- };
214
- function j(o) {
215
- const e = o.toLowerCase();
216
- return m[e] || `// ${o}
104
+ This is a sample markdown document.` };
105
+ function Z(c) {
106
+ const n = c.toLowerCase();
107
+ return Oe[n] || `// ${c}
217
108
  // Write your code here`;
218
109
  }
219
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
220
- function getDefaultExportFromCjs(x) {
221
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
110
+ var ce = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
111
+ function Le(c) {
112
+ return c && c.__esModule && Object.prototype.hasOwnProperty.call(c, "default") ? c.default : c;
222
113
  }
223
- var prism = { exports: {} };
224
- (function(module) {
225
- var _self = typeof window !== "undefined" ? window : typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope ? self : {};
226
- /**
227
- * Prism: Lightweight, robust, elegant syntax highlighting
228
- *
229
- * @license MIT <https://opensource.org/licenses/MIT>
230
- * @author Lea Verou <https://lea.verou.me>
231
- * @namespace
232
- * @public
233
- */
234
- var Prism2 = function(_self2) {
235
- var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
236
- var uniqueId = 0;
237
- var plainTextGrammar = {};
238
- var _ = {
239
- /**
240
- * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
241
- * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
242
- * additional languages or plugins yourself.
243
- *
244
- * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
245
- *
246
- * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
247
- * empty Prism object into the global scope before loading the Prism script like this:
248
- *
249
- * ```js
250
- * window.Prism = window.Prism || {};
251
- * Prism.manual = true;
252
- * // add a new <script> to load Prism's script
253
- * ```
254
- *
255
- * @default false
256
- * @type {boolean}
257
- * @memberof Prism
258
- * @public
259
- */
260
- manual: _self2.Prism && _self2.Prism.manual,
261
- /**
262
- * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
263
- * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
264
- * own worker, you don't want it to do this.
265
- *
266
- * By setting this value to `true`, Prism will not add its own listeners to the worker.
267
- *
268
- * You obviously have to change this value before Prism executes. To do this, you can add an
269
- * empty Prism object into the global scope before loading the Prism script like this:
270
- *
271
- * ```js
272
- * window.Prism = window.Prism || {};
273
- * Prism.disableWorkerMessageHandler = true;
274
- * // Load Prism's script
275
- * ```
276
- *
277
- * @default false
278
- * @type {boolean}
279
- * @memberof Prism
280
- * @public
281
- */
282
- disableWorkerMessageHandler: _self2.Prism && _self2.Prism.disableWorkerMessageHandler,
283
- /**
284
- * A namespace for utility methods.
285
- *
286
- * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
287
- * change or disappear at any time.
288
- *
289
- * @namespace
290
- * @memberof Prism
291
- */
292
- util: {
293
- encode: function encode(tokens) {
294
- if (tokens instanceof Token) {
295
- return new Token(tokens.type, encode(tokens.content), tokens.alias);
296
- } else if (Array.isArray(tokens)) {
297
- return tokens.map(encode);
298
- } else {
299
- return tokens.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/\u00a0/g, " ");
300
- }
301
- },
302
- /**
303
- * Returns the name of the type of the given value.
304
- *
305
- * @param {any} o
306
- * @returns {string}
307
- * @example
308
- * type(null) === 'Null'
309
- * type(undefined) === 'Undefined'
310
- * type(123) === 'Number'
311
- * type('foo') === 'String'
312
- * type(true) === 'Boolean'
313
- * type([1, 2]) === 'Array'
314
- * type({}) === 'Object'
315
- * type(String) === 'Function'
316
- * type(/abc+/) === 'RegExp'
317
- */
318
- type: function(o) {
319
- return Object.prototype.toString.call(o).slice(8, -1);
320
- },
321
- /**
322
- * Returns a unique number for the given object. Later calls will still return the same number.
323
- *
324
- * @param {Object} obj
325
- * @returns {number}
326
- */
327
- objId: function(obj) {
328
- if (!obj["__id"]) {
329
- Object.defineProperty(obj, "__id", { value: ++uniqueId });
330
- }
331
- return obj["__id"];
332
- },
333
- /**
334
- * Creates a deep clone of the given object.
335
- *
336
- * The main intended use of this function is to clone language definitions.
337
- *
338
- * @param {T} o
339
- * @param {Record<number, any>} [visited]
340
- * @returns {T}
341
- * @template T
342
- */
343
- clone: function deepClone(o, visited) {
344
- visited = visited || {};
345
- var clone;
346
- var id;
347
- switch (_.util.type(o)) {
348
- case "Object":
349
- id = _.util.objId(o);
350
- if (visited[id]) {
351
- return visited[id];
352
- }
353
- clone = /** @type {Record<string, any>} */
354
- {};
355
- visited[id] = clone;
356
- for (var key in o) {
357
- if (o.hasOwnProperty(key)) {
358
- clone[key] = deepClone(o[key], visited);
359
- }
360
- }
361
- return (
362
- /** @type {any} */
363
- clone
364
- );
365
- case "Array":
366
- id = _.util.objId(o);
367
- if (visited[id]) {
368
- return visited[id];
369
- }
370
- clone = [];
371
- visited[id] = clone;
372
- /** @type {Array} */
373
- /** @type {any} */
374
- o.forEach(function(v, i) {
375
- clone[i] = deepClone(v, visited);
376
- });
377
- return (
378
- /** @type {any} */
379
- clone
380
- );
381
- default:
382
- return o;
383
- }
384
- },
385
- /**
386
- * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
387
- *
388
- * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
389
- *
390
- * @param {Element} element
391
- * @returns {string}
392
- */
393
- getLanguage: function(element) {
394
- while (element) {
395
- var m2 = lang.exec(element.className);
396
- if (m2) {
397
- return m2[1].toLowerCase();
398
- }
399
- element = element.parentElement;
400
- }
401
- return "none";
402
- },
403
- /**
404
- * Sets the Prism `language-xxxx` class of the given element.
405
- *
406
- * @param {Element} element
407
- * @param {string} language
408
- * @returns {void}
409
- */
410
- setLanguage: function(element, language) {
411
- element.className = element.className.replace(RegExp(lang, "gi"), "");
412
- element.classList.add("language-" + language);
413
- },
414
- /**
415
- * Returns the script element that is currently executing.
416
- *
417
- * This does __not__ work for line script element.
418
- *
419
- * @returns {HTMLScriptElement | null}
420
- */
421
- currentScript: function() {
422
- if (typeof document === "undefined") {
423
- return null;
424
- }
425
- if (document.currentScript && document.currentScript.tagName === "SCRIPT" && 1 < 2) {
426
- return (
427
- /** @type {any} */
428
- document.currentScript
429
- );
430
- }
431
- try {
432
- throw new Error();
433
- } catch (err) {
434
- var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
435
- if (src) {
436
- var scripts = document.getElementsByTagName("script");
437
- for (var i in scripts) {
438
- if (scripts[i].src == src) {
439
- return scripts[i];
440
- }
441
- }
442
- }
443
- return null;
444
- }
445
- },
446
- /**
447
- * Returns whether a given class is active for `element`.
448
- *
449
- * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
450
- * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
451
- * given class is just the given class with a `no-` prefix.
452
- *
453
- * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
454
- * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
455
- * ancestors have the given class or the negated version of it, then the default activation will be returned.
456
- *
457
- * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
458
- * version of it, the class is considered active.
459
- *
460
- * @param {Element} element
461
- * @param {string} className
462
- * @param {boolean} [defaultActivation=false]
463
- * @returns {boolean}
464
- */
465
- isActive: function(element, className, defaultActivation) {
466
- var no = "no-" + className;
467
- while (element) {
468
- var classList = element.classList;
469
- if (classList.contains(className)) {
470
- return true;
471
- }
472
- if (classList.contains(no)) {
473
- return false;
474
- }
475
- element = element.parentElement;
476
- }
477
- return !!defaultActivation;
478
- }
479
- },
480
- /**
481
- * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
482
- *
483
- * @namespace
484
- * @memberof Prism
485
- * @public
486
- */
487
- languages: {
488
- /**
489
- * The grammar for plain, unformatted text.
490
- */
491
- plain: plainTextGrammar,
492
- plaintext: plainTextGrammar,
493
- text: plainTextGrammar,
494
- txt: plainTextGrammar,
495
- /**
496
- * Creates a deep copy of the language with the given id and appends the given tokens.
497
- *
498
- * If a token in `redef` also appears in the copied language, then the existing token in the copied language
499
- * will be overwritten at its original position.
500
- *
501
- * ## Best practices
502
- *
503
- * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
504
- * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
505
- * understand the language definition because, normally, the order of tokens matters in Prism grammars.
506
- *
507
- * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
508
- * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
509
- *
510
- * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
511
- * @param {Grammar} redef The new tokens to append.
512
- * @returns {Grammar} The new language created.
513
- * @public
514
- * @example
515
- * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
516
- * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
517
- * // at its original position
518
- * 'comment': { ... },
519
- * // CSS doesn't have a 'color' token, so this token will be appended
520
- * 'color': /\b(?:red|green|blue)\b/
521
- * });
522
- */
523
- extend: function(id, redef) {
524
- var lang2 = _.util.clone(_.languages[id]);
525
- for (var key in redef) {
526
- lang2[key] = redef[key];
527
- }
528
- return lang2;
529
- },
530
- /**
531
- * Inserts tokens _before_ another token in a language definition or any other grammar.
532
- *
533
- * ## Usage
534
- *
535
- * This helper method makes it easy to modify existing languages. For example, the CSS language definition
536
- * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
537
- * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
538
- * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
539
- * this:
540
- *
541
- * ```js
542
- * Prism.languages.markup.style = {
543
- * // token
544
- * };
545
- * ```
546
- *
547
- * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
548
- * before existing tokens. For the CSS example above, you would use it like this:
549
- *
550
- * ```js
551
- * Prism.languages.insertBefore('markup', 'cdata', {
552
- * 'style': {
553
- * // token
554
- * }
555
- * });
556
- * ```
557
- *
558
- * ## Special cases
559
- *
560
- * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
561
- * will be ignored.
562
- *
563
- * This behavior can be used to insert tokens after `before`:
564
- *
565
- * ```js
566
- * Prism.languages.insertBefore('markup', 'comment', {
567
- * 'comment': Prism.languages.markup.comment,
568
- * // tokens after 'comment'
569
- * });
570
- * ```
571
- *
572
- * ## Limitations
573
- *
574
- * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
575
- * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
576
- * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
577
- * deleting properties which is necessary to insert at arbitrary positions.
578
- *
579
- * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
580
- * Instead, it will create a new object and replace all references to the target object with the new one. This
581
- * can be done without temporarily deleting properties, so the iteration order is well-defined.
582
- *
583
- * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
584
- * you hold the target object in a variable, then the value of the variable will not change.
585
- *
586
- * ```js
587
- * var oldMarkup = Prism.languages.markup;
588
- * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
589
- *
590
- * assert(oldMarkup !== Prism.languages.markup);
591
- * assert(newMarkup === Prism.languages.markup);
592
- * ```
593
- *
594
- * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
595
- * object to be modified.
596
- * @param {string} before The key to insert before.
597
- * @param {Grammar} insert An object containing the key-value pairs to be inserted.
598
- * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
599
- * object to be modified.
600
- *
601
- * Defaults to `Prism.languages`.
602
- * @returns {Grammar} The new grammar object.
603
- * @public
604
- */
605
- insertBefore: function(inside, before, insert, root) {
606
- root = root || /** @type {any} */
607
- _.languages;
608
- var grammar = root[inside];
609
- var ret = {};
610
- for (var token in grammar) {
611
- if (grammar.hasOwnProperty(token)) {
612
- if (token == before) {
613
- for (var newToken in insert) {
614
- if (insert.hasOwnProperty(newToken)) {
615
- ret[newToken] = insert[newToken];
616
- }
617
- }
618
- }
619
- if (!insert.hasOwnProperty(token)) {
620
- ret[token] = grammar[token];
621
- }
622
- }
623
- }
624
- var old = root[inside];
625
- root[inside] = ret;
626
- _.languages.DFS(_.languages, function(key, value) {
627
- if (value === old && key != inside) {
628
- this[key] = ret;
629
- }
630
- });
631
- return ret;
632
- },
633
- // Traverse a language definition with Depth First Search
634
- DFS: function DFS(o, callback, type, visited) {
635
- visited = visited || {};
636
- var objId = _.util.objId;
637
- for (var i in o) {
638
- if (o.hasOwnProperty(i)) {
639
- callback.call(o, i, o[i], type || i);
640
- var property = o[i];
641
- var propertyType = _.util.type(property);
642
- if (propertyType === "Object" && !visited[objId(property)]) {
643
- visited[objId(property)] = true;
644
- DFS(property, callback, null, visited);
645
- } else if (propertyType === "Array" && !visited[objId(property)]) {
646
- visited[objId(property)] = true;
647
- DFS(property, callback, i, visited);
648
- }
649
- }
650
- }
651
- }
652
- },
653
- plugins: {},
654
- /**
655
- * This is the most high-level function in Prism’s API.
656
- * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
657
- * each one of them.
658
- *
659
- * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
660
- *
661
- * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
662
- * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
663
- * @memberof Prism
664
- * @public
665
- */
666
- highlightAll: function(async, callback) {
667
- _.highlightAllUnder(document, async, callback);
668
- },
669
- /**
670
- * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
671
- * {@link Prism.highlightElement} on each one of them.
672
- *
673
- * The following hooks will be run:
674
- * 1. `before-highlightall`
675
- * 2. `before-all-elements-highlight`
676
- * 3. All hooks of {@link Prism.highlightElement} for each element.
677
- *
678
- * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
679
- * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
680
- * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
681
- * @memberof Prism
682
- * @public
683
- */
684
- highlightAllUnder: function(container, async, callback) {
685
- var env = {
686
- callback,
687
- container,
688
- selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
689
- };
690
- _.hooks.run("before-highlightall", env);
691
- env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
692
- _.hooks.run("before-all-elements-highlight", env);
693
- for (var i = 0, element; element = env.elements[i++]; ) {
694
- _.highlightElement(element, async === true, env.callback);
695
- }
696
- },
697
- /**
698
- * Highlights the code inside a single element.
699
- *
700
- * The following hooks will be run:
701
- * 1. `before-sanity-check`
702
- * 2. `before-highlight`
703
- * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
704
- * 4. `before-insert`
705
- * 5. `after-highlight`
706
- * 6. `complete`
707
- *
708
- * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
709
- * the element's language.
710
- *
711
- * @param {Element} element The element containing the code.
712
- * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
713
- * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
714
- * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
715
- * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
716
- *
717
- * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
718
- * asynchronous highlighting to work. You can build your own bundle on the
719
- * [Download page](https://prismjs.com/download.html).
720
- * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
721
- * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
722
- * @memberof Prism
723
- * @public
724
- */
725
- highlightElement: function(element, async, callback) {
726
- var language = _.util.getLanguage(element);
727
- var grammar = _.languages[language];
728
- _.util.setLanguage(element, language);
729
- var parent = element.parentElement;
730
- if (parent && parent.nodeName.toLowerCase() === "pre") {
731
- _.util.setLanguage(parent, language);
732
- }
733
- var code = element.textContent;
734
- var env = {
735
- element,
736
- language,
737
- grammar,
738
- code
739
- };
740
- function insertHighlightedCode(highlightedCode) {
741
- env.highlightedCode = highlightedCode;
742
- _.hooks.run("before-insert", env);
743
- env.element.innerHTML = env.highlightedCode;
744
- _.hooks.run("after-highlight", env);
745
- _.hooks.run("complete", env);
746
- callback && callback.call(env.element);
747
- }
748
- _.hooks.run("before-sanity-check", env);
749
- parent = env.element.parentElement;
750
- if (parent && parent.nodeName.toLowerCase() === "pre" && !parent.hasAttribute("tabindex")) {
751
- parent.setAttribute("tabindex", "0");
752
- }
753
- if (!env.code) {
754
- _.hooks.run("complete", env);
755
- callback && callback.call(env.element);
756
- return;
757
- }
758
- _.hooks.run("before-highlight", env);
759
- if (!env.grammar) {
760
- insertHighlightedCode(_.util.encode(env.code));
761
- return;
762
- }
763
- if (async && _self2.Worker) {
764
- var worker = new Worker(_.filename);
765
- worker.onmessage = function(evt) {
766
- insertHighlightedCode(evt.data);
767
- };
768
- worker.postMessage(JSON.stringify({
769
- language: env.language,
770
- code: env.code,
771
- immediateClose: true
772
- }));
773
- } else {
774
- insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
775
- }
776
- },
777
- /**
778
- * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
779
- * and the language definitions to use, and returns a string with the HTML produced.
780
- *
781
- * The following hooks will be run:
782
- * 1. `before-tokenize`
783
- * 2. `after-tokenize`
784
- * 3. `wrap`: On each {@link Token}.
785
- *
786
- * @param {string} text A string with the code to be highlighted.
787
- * @param {Grammar} grammar An object containing the tokens to use.
788
- *
789
- * Usually a language definition like `Prism.languages.markup`.
790
- * @param {string} language The name of the language definition passed to `grammar`.
791
- * @returns {string} The highlighted HTML.
792
- * @memberof Prism
793
- * @public
794
- * @example
795
- * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
796
- */
797
- highlight: function(text, grammar, language) {
798
- var env = {
799
- code: text,
800
- grammar,
801
- language
802
- };
803
- _.hooks.run("before-tokenize", env);
804
- if (!env.grammar) {
805
- throw new Error('The language "' + env.language + '" has no grammar.');
806
- }
807
- env.tokens = _.tokenize(env.code, env.grammar);
808
- _.hooks.run("after-tokenize", env);
809
- return Token.stringify(_.util.encode(env.tokens), env.language);
810
- },
811
- /**
812
- * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
813
- * and the language definitions to use, and returns an array with the tokenized code.
814
- *
815
- * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
816
- *
817
- * This method could be useful in other contexts as well, as a very crude parser.
818
- *
819
- * @param {string} text A string with the code to be highlighted.
820
- * @param {Grammar} grammar An object containing the tokens to use.
821
- *
822
- * Usually a language definition like `Prism.languages.markup`.
823
- * @returns {TokenStream} An array of strings and tokens, a token stream.
824
- * @memberof Prism
825
- * @public
826
- * @example
827
- * let code = `var foo = 0;`;
828
- * let tokens = Prism.tokenize(code, Prism.languages.javascript);
829
- * tokens.forEach(token => {
830
- * if (token instanceof Prism.Token && token.type === 'number') {
831
- * console.log(`Found numeric literal: ${token.content}`);
832
- * }
833
- * });
834
- */
835
- tokenize: function(text, grammar) {
836
- var rest = grammar.rest;
837
- if (rest) {
838
- for (var token in rest) {
839
- grammar[token] = rest[token];
840
- }
841
- delete grammar.rest;
842
- }
843
- var tokenList = new LinkedList();
844
- addAfter(tokenList, tokenList.head, text);
845
- matchGrammar(text, tokenList, grammar, tokenList.head, 0);
846
- return toArray(tokenList);
847
- },
848
- /**
849
- * @namespace
850
- * @memberof Prism
851
- * @public
852
- */
853
- hooks: {
854
- all: {},
855
- /**
856
- * Adds the given callback to the list of callbacks for the given hook.
857
- *
858
- * The callback will be invoked when the hook it is registered for is run.
859
- * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
860
- *
861
- * One callback function can be registered to multiple hooks and the same hook multiple times.
862
- *
863
- * @param {string} name The name of the hook.
864
- * @param {HookCallback} callback The callback function which is given environment variables.
865
- * @public
866
- */
867
- add: function(name, callback) {
868
- var hooks = _.hooks.all;
869
- hooks[name] = hooks[name] || [];
870
- hooks[name].push(callback);
871
- },
872
- /**
873
- * Runs a hook invoking all registered callbacks with the given environment variables.
874
- *
875
- * Callbacks will be invoked synchronously and in the order in which they were registered.
876
- *
877
- * @param {string} name The name of the hook.
878
- * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
879
- * @public
880
- */
881
- run: function(name, env) {
882
- var callbacks = _.hooks.all[name];
883
- if (!callbacks || !callbacks.length) {
884
- return;
885
- }
886
- for (var i = 0, callback; callback = callbacks[i++]; ) {
887
- callback(env);
888
- }
889
- }
890
- },
891
- Token
892
- };
893
- _self2.Prism = _;
894
- function Token(type, content, alias, matchedStr) {
895
- this.type = type;
896
- this.content = content;
897
- this.alias = alias;
898
- this.length = (matchedStr || "").length | 0;
899
- }
900
- Token.stringify = function stringify(o, language) {
901
- if (typeof o == "string") {
902
- return o;
903
- }
904
- if (Array.isArray(o)) {
905
- var s = "";
906
- o.forEach(function(e) {
907
- s += stringify(e, language);
908
- });
909
- return s;
910
- }
911
- var env = {
912
- type: o.type,
913
- content: stringify(o.content, language),
914
- tag: "span",
915
- classes: ["token", o.type],
916
- attributes: {},
917
- language
918
- };
919
- var aliases = o.alias;
920
- if (aliases) {
921
- if (Array.isArray(aliases)) {
922
- Array.prototype.push.apply(env.classes, aliases);
923
- } else {
924
- env.classes.push(aliases);
925
- }
926
- }
927
- _.hooks.run("wrap", env);
928
- var attributes = "";
929
- for (var name in env.attributes) {
930
- attributes += " " + name + '="' + (env.attributes[name] || "").replace(/"/g, "&quot;") + '"';
931
- }
932
- return "<" + env.tag + ' class="' + env.classes.join(" ") + '"' + attributes + ">" + env.content + "</" + env.tag + ">";
933
- };
934
- function matchPattern(pattern, pos, text, lookbehind) {
935
- pattern.lastIndex = pos;
936
- var match = pattern.exec(text);
937
- if (match && lookbehind && match[1]) {
938
- var lookbehindLength = match[1].length;
939
- match.index += lookbehindLength;
940
- match[0] = match[0].slice(lookbehindLength);
941
- }
942
- return match;
943
- }
944
- function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
945
- for (var token in grammar) {
946
- if (!grammar.hasOwnProperty(token) || !grammar[token]) {
947
- continue;
948
- }
949
- var patterns = grammar[token];
950
- patterns = Array.isArray(patterns) ? patterns : [patterns];
951
- for (var j2 = 0; j2 < patterns.length; ++j2) {
952
- if (rematch && rematch.cause == token + "," + j2) {
953
- return;
954
- }
955
- var patternObj = patterns[j2];
956
- var inside = patternObj.inside;
957
- var lookbehind = !!patternObj.lookbehind;
958
- var greedy = !!patternObj.greedy;
959
- var alias = patternObj.alias;
960
- if (greedy && !patternObj.pattern.global) {
961
- var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
962
- patternObj.pattern = RegExp(patternObj.pattern.source, flags + "g");
114
+ var pe = { exports: {} };
115
+ (function(c) {
116
+ var n = function(i) {
117
+ var l = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i, f = 0, b = {}, s = { manual: i.Prism && i.Prism.manual, disableWorkerMessageHandler: i.Prism && i.Prism.disableWorkerMessageHandler, util: { encode: function t(e) {
118
+ return e instanceof y ? new y(e.type, t(e.content), e.alias) : Array.isArray(e) ? e.map(t) : e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/\u00a0/g, " ");
119
+ }, type: function(t) {
120
+ return Object.prototype.toString.call(t).slice(8, -1);
121
+ }, objId: function(t) {
122
+ return t.__id || Object.defineProperty(t, "__id", { value: ++f }), t.__id;
123
+ }, clone: function t(e, a) {
124
+ var r, o;
125
+ switch (a = a || {}, s.util.type(e)) {
126
+ case "Object":
127
+ if (o = s.util.objId(e), a[o]) return a[o];
128
+ for (var u in r = {}, a[o] = r, e) e.hasOwnProperty(u) && (r[u] = t(e[u], a));
129
+ return r;
130
+ case "Array":
131
+ return o = s.util.objId(e), a[o] ? a[o] : (r = [], a[o] = r, e.forEach(function(p, m) {
132
+ r[m] = t(p, a);
133
+ }), r);
134
+ default:
135
+ return e;
136
+ }
137
+ }, getLanguage: function(t) {
138
+ for (; t; ) {
139
+ var e = l.exec(t.className);
140
+ if (e) return e[1].toLowerCase();
141
+ t = t.parentElement;
142
+ }
143
+ return "none";
144
+ }, setLanguage: function(t, e) {
145
+ t.className = t.className.replace(RegExp(l, "gi"), ""), t.classList.add("language-" + e);
146
+ }, currentScript: function() {
147
+ if (typeof document > "u") return null;
148
+ if (document.currentScript && document.currentScript.tagName === "SCRIPT") return document.currentScript;
149
+ try {
150
+ throw new Error();
151
+ } catch (r) {
152
+ var t = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack) || [])[1];
153
+ if (t) {
154
+ var e = document.getElementsByTagName("script");
155
+ for (var a in e) if (e[a].src == t) return e[a];
156
+ }
157
+ return null;
158
+ }
159
+ }, isActive: function(t, e, a) {
160
+ for (var r = "no-" + e; t; ) {
161
+ var o = t.classList;
162
+ if (o.contains(e)) return !0;
163
+ if (o.contains(r)) return !1;
164
+ t = t.parentElement;
165
+ }
166
+ return !!a;
167
+ } }, languages: { plain: b, plaintext: b, text: b, txt: b, extend: function(t, e) {
168
+ var a = s.util.clone(s.languages[t]);
169
+ for (var r in e) a[r] = e[r];
170
+ return a;
171
+ }, insertBefore: function(t, e, a, r) {
172
+ var o = (r = r || s.languages)[t], u = {};
173
+ for (var p in o) if (o.hasOwnProperty(p)) {
174
+ if (p == e) for (var m in a) a.hasOwnProperty(m) && (u[m] = a[m]);
175
+ a.hasOwnProperty(p) || (u[p] = o[p]);
176
+ }
177
+ var w = r[t];
178
+ return r[t] = u, s.languages.DFS(s.languages, function(_, H) {
179
+ H === w && _ != t && (this[_] = u);
180
+ }), u;
181
+ }, DFS: function t(e, a, r, o) {
182
+ o = o || {};
183
+ var u = s.util.objId;
184
+ for (var p in e) if (e.hasOwnProperty(p)) {
185
+ a.call(e, p, e[p], r || p);
186
+ var m = e[p], w = s.util.type(m);
187
+ w !== "Object" || o[u(m)] ? w !== "Array" || o[u(m)] || (o[u(m)] = !0, t(m, a, p, o)) : (o[u(m)] = !0, t(m, a, null, o));
188
+ }
189
+ } }, plugins: {}, highlightAll: function(t, e) {
190
+ s.highlightAllUnder(document, t, e);
191
+ }, highlightAllUnder: function(t, e, a) {
192
+ var r = { callback: a, container: t, selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code' };
193
+ s.hooks.run("before-highlightall", r), r.elements = Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)), s.hooks.run("before-all-elements-highlight", r);
194
+ for (var o, u = 0; o = r.elements[u++]; ) s.highlightElement(o, e === !0, r.callback);
195
+ }, highlightElement: function(t, e, a) {
196
+ var r = s.util.getLanguage(t), o = s.languages[r];
197
+ s.util.setLanguage(t, r);
198
+ var u = t.parentElement;
199
+ u && u.nodeName.toLowerCase() === "pre" && s.util.setLanguage(u, r);
200
+ var p = { element: t, language: r, grammar: o, code: t.textContent };
201
+ function m(_) {
202
+ p.highlightedCode = _, s.hooks.run("before-insert", p), p.element.innerHTML = p.highlightedCode, s.hooks.run("after-highlight", p), s.hooks.run("complete", p), a && a.call(p.element);
203
+ }
204
+ if (s.hooks.run("before-sanity-check", p), (u = p.element.parentElement) && u.nodeName.toLowerCase() === "pre" && !u.hasAttribute("tabindex") && u.setAttribute("tabindex", "0"), !p.code) return s.hooks.run("complete", p), void (a && a.call(p.element));
205
+ if (s.hooks.run("before-highlight", p), p.grammar) if (e && i.Worker) {
206
+ var w = new Worker(s.filename);
207
+ w.onmessage = function(_) {
208
+ m(_.data);
209
+ }, w.postMessage(JSON.stringify({ language: p.language, code: p.code, immediateClose: !0 }));
210
+ } else m(s.highlight(p.code, p.grammar, p.language));
211
+ else m(s.util.encode(p.code));
212
+ }, highlight: function(t, e, a) {
213
+ var r = { code: t, grammar: e, language: a };
214
+ if (s.hooks.run("before-tokenize", r), !r.grammar) throw new Error('The language "' + r.language + '" has no grammar.');
215
+ return r.tokens = s.tokenize(r.code, r.grammar), s.hooks.run("after-tokenize", r), y.stringify(s.util.encode(r.tokens), r.language);
216
+ }, tokenize: function(t, e) {
217
+ var a = e.rest;
218
+ if (a) {
219
+ for (var r in a) e[r] = a[r];
220
+ delete e.rest;
221
+ }
222
+ var o = new S();
223
+ return I(o, o.head, t), d(t, o, e, o.head, 0), function(u) {
224
+ for (var p = [], m = u.head.next; m !== u.tail; ) p.push(m.value), m = m.next;
225
+ return p;
226
+ }(o);
227
+ }, hooks: { all: {}, add: function(t, e) {
228
+ var a = s.hooks.all;
229
+ a[t] = a[t] || [], a[t].push(e);
230
+ }, run: function(t, e) {
231
+ var a = s.hooks.all[t];
232
+ if (a && a.length) for (var r, o = 0; r = a[o++]; ) r(e);
233
+ } }, Token: y };
234
+ function y(t, e, a, r) {
235
+ this.type = t, this.content = e, this.alias = a, this.length = 0 | (r || "").length;
236
+ }
237
+ function k(t, e, a, r) {
238
+ t.lastIndex = e;
239
+ var o = t.exec(a);
240
+ if (o && r && o[1]) {
241
+ var u = o[1].length;
242
+ o.index += u, o[0] = o[0].slice(u);
243
+ }
244
+ return o;
245
+ }
246
+ function d(t, e, a, r, o, u) {
247
+ for (var p in a) if (a.hasOwnProperty(p) && a[p]) {
248
+ var m = a[p];
249
+ m = Array.isArray(m) ? m : [m];
250
+ for (var w = 0; w < m.length; ++w) {
251
+ if (u && u.cause == p + "," + w) return;
252
+ var _ = m[w], H = _.inside, W = !!_.lookbehind, G = !!_.greedy, J = _.alias;
253
+ if (G && !_.pattern.global) {
254
+ var V = _.pattern.toString().match(/[imsuy]*$/)[0];
255
+ _.pattern = RegExp(_.pattern.source, V + "g");
963
256
  }
964
- var pattern = patternObj.pattern || patternObj;
965
- for (var currentNode = startNode.next, pos = startPos; currentNode !== tokenList.tail; pos += currentNode.value.length, currentNode = currentNode.next) {
966
- if (rematch && pos >= rematch.reach) {
967
- break;
968
- }
969
- var str = currentNode.value;
970
- if (tokenList.length > text.length) {
971
- return;
972
- }
973
- if (str instanceof Token) {
974
- continue;
975
- }
976
- var removeCount = 1;
977
- var match;
978
- if (greedy) {
979
- match = matchPattern(pattern, pos, text, lookbehind);
980
- if (!match || match.index >= text.length) {
981
- break;
982
- }
983
- var from = match.index;
984
- var to = match.index + match[0].length;
985
- var p = pos;
986
- p += currentNode.value.length;
987
- while (from >= p) {
988
- currentNode = currentNode.next;
989
- p += currentNode.value.length;
990
- }
991
- p -= currentNode.value.length;
992
- pos = p;
993
- if (currentNode.value instanceof Token) {
994
- continue;
257
+ for (var j = _.pattern || _, N = r.next, g = o; N !== e.tail && !(u && g >= u.reach); g += N.value.length, N = N.next) {
258
+ var h = N.value;
259
+ if (e.length > t.length) return;
260
+ if (!(h instanceof y)) {
261
+ var E, C = 1;
262
+ if (G) {
263
+ if (!(E = k(j, g, t, W)) || E.index >= t.length) break;
264
+ var $ = E.index, he = E.index + E[0].length, U = g;
265
+ for (U += N.value.length; $ >= U; ) U += (N = N.next).value.length;
266
+ if (g = U -= N.value.length, N.value instanceof y) continue;
267
+ for (var z = N; z !== e.tail && (U < he || typeof z.value == "string"); z = z.next) C++, U += z.value.length;
268
+ C--, h = t.slice(g, U), E.index -= g;
269
+ } else if (!(E = k(j, 0, h, W))) continue;
270
+ $ = E.index;
271
+ var Y = E[0], Q = h.slice(0, $), ie = h.slice($ + Y.length), ee = g + h.length;
272
+ u && ee > u.reach && (u.reach = ee);
273
+ var X = N.prev;
274
+ if (Q && (X = I(e, X, Q), g += Q.length), x(e, X, C), N = I(e, X, new y(p, H ? s.tokenize(Y, H) : Y, J, Y)), ie && I(e, N, ie), C > 1) {
275
+ var te = { cause: p + "," + w, reach: ee };
276
+ d(t, e, a, N.prev, g, te), u && te.reach > u.reach && (u.reach = te.reach);
995
277
  }
996
- for (var k = currentNode; k !== tokenList.tail && (p < to || typeof k.value === "string"); k = k.next) {
997
- removeCount++;
998
- p += k.value.length;
999
- }
1000
- removeCount--;
1001
- str = text.slice(pos, p);
1002
- match.index -= pos;
1003
- } else {
1004
- match = matchPattern(pattern, 0, str, lookbehind);
1005
- if (!match) {
1006
- continue;
1007
- }
1008
- }
1009
- var from = match.index;
1010
- var matchStr = match[0];
1011
- var before = str.slice(0, from);
1012
- var after = str.slice(from + matchStr.length);
1013
- var reach = pos + str.length;
1014
- if (rematch && reach > rematch.reach) {
1015
- rematch.reach = reach;
1016
- }
1017
- var removeFrom = currentNode.prev;
1018
- if (before) {
1019
- removeFrom = addAfter(tokenList, removeFrom, before);
1020
- pos += before.length;
1021
- }
1022
- removeRange(tokenList, removeFrom, removeCount);
1023
- var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
1024
- currentNode = addAfter(tokenList, removeFrom, wrapped);
1025
- if (after) {
1026
- addAfter(tokenList, currentNode, after);
1027
278
  }
1028
- if (removeCount > 1) {
1029
- var nestedRematch = {
1030
- cause: token + "," + j2,
1031
- reach
1032
- };
1033
- matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
1034
- if (rematch && nestedRematch.reach > rematch.reach) {
1035
- rematch.reach = nestedRematch.reach;
1036
- }
1037
- }
1038
- }
1039
- }
1040
- }
1041
- }
1042
- function LinkedList() {
1043
- var head = { value: null, prev: null, next: null };
1044
- var tail = { value: null, prev: head, next: null };
1045
- head.next = tail;
1046
- this.head = head;
1047
- this.tail = tail;
1048
- this.length = 0;
1049
- }
1050
- function addAfter(list, node, value) {
1051
- var next = node.next;
1052
- var newNode = { value, prev: node, next };
1053
- node.next = newNode;
1054
- next.prev = newNode;
1055
- list.length++;
1056
- return newNode;
1057
- }
1058
- function removeRange(list, node, count) {
1059
- var next = node.next;
1060
- for (var i = 0; i < count && next !== list.tail; i++) {
1061
- next = next.next;
1062
- }
1063
- node.next = next;
1064
- next.prev = node;
1065
- list.length -= i;
1066
- }
1067
- function toArray(list) {
1068
- var array = [];
1069
- var node = list.head.next;
1070
- while (node !== list.tail) {
1071
- array.push(node.value);
1072
- node = node.next;
1073
- }
1074
- return array;
1075
- }
1076
- if (!_self2.document) {
1077
- if (!_self2.addEventListener) {
1078
- return _;
1079
- }
1080
- if (!_.disableWorkerMessageHandler) {
1081
- _self2.addEventListener("message", function(evt) {
1082
- var message = JSON.parse(evt.data);
1083
- var lang2 = message.language;
1084
- var code = message.code;
1085
- var immediateClose = message.immediateClose;
1086
- _self2.postMessage(_.highlight(code, _.languages[lang2], lang2));
1087
- if (immediateClose) {
1088
- _self2.close();
1089
279
  }
1090
- }, false);
1091
- }
1092
- return _;
1093
- }
1094
- var script = _.util.currentScript();
1095
- if (script) {
1096
- _.filename = script.src;
1097
- if (script.hasAttribute("data-manual")) {
1098
- _.manual = true;
1099
- }
1100
- }
1101
- function highlightAutomaticallyCallback() {
1102
- if (!_.manual) {
1103
- _.highlightAll();
1104
- }
1105
- }
1106
- if (!_.manual) {
1107
- var readyState = document.readyState;
1108
- if (readyState === "loading" || readyState === "interactive" && script && script.defer) {
1109
- document.addEventListener("DOMContentLoaded", highlightAutomaticallyCallback);
1110
- } else {
1111
- if (window.requestAnimationFrame) {
1112
- window.requestAnimationFrame(highlightAutomaticallyCallback);
1113
- } else {
1114
- window.setTimeout(highlightAutomaticallyCallback, 16);
1115
280
  }
1116
281
  }
1117
282
  }
1118
- return _;
1119
- }(_self);
1120
- if (module.exports) {
1121
- module.exports = Prism2;
1122
- }
1123
- if (typeof commonjsGlobal !== "undefined") {
1124
- commonjsGlobal.Prism = Prism2;
1125
- }
1126
- Prism2.languages.markup = {
1127
- "comment": {
1128
- pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
1129
- greedy: true
1130
- },
1131
- "prolog": {
1132
- pattern: /<\?[\s\S]+?\?>/,
1133
- greedy: true
1134
- },
1135
- "doctype": {
1136
- // https://www.w3.org/TR/xml/#NT-doctypedecl
1137
- pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
1138
- greedy: true,
1139
- inside: {
1140
- "internal-subset": {
1141
- pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
1142
- lookbehind: true,
1143
- greedy: true,
1144
- inside: null
1145
- // see below
1146
- },
1147
- "string": {
1148
- pattern: /"[^"]*"|'[^']*'/,
1149
- greedy: true
1150
- },
1151
- "punctuation": /^<!|>$|[[\]]/,
1152
- "doctype-tag": /^DOCTYPE/i,
1153
- "name": /[^\s<>'"]+/
1154
- }
1155
- },
1156
- "cdata": {
1157
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1158
- greedy: true
1159
- },
1160
- "tag": {
1161
- pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1162
- greedy: true,
1163
- inside: {
1164
- "tag": {
1165
- pattern: /^<\/?[^\s>\/]+/,
1166
- inside: {
1167
- "punctuation": /^<\/?/,
1168
- "namespace": /^[^\s>\/:]+:/
283
+ function S() {
284
+ var t = { value: null, prev: null, next: null }, e = { value: null, prev: t, next: null };
285
+ t.next = e, this.head = t, this.tail = e, this.length = 0;
286
+ }
287
+ function I(t, e, a) {
288
+ var r = e.next, o = { value: a, prev: e, next: r };
289
+ return e.next = o, r.prev = o, t.length++, o;
290
+ }
291
+ function x(t, e, a) {
292
+ for (var r = e.next, o = 0; o < a && r !== t.tail; o++) r = r.next;
293
+ e.next = r, r.prev = e, t.length -= o;
294
+ }
295
+ if (i.Prism = s, y.stringify = function t(e, a) {
296
+ if (typeof e == "string") return e;
297
+ if (Array.isArray(e)) {
298
+ var r = "";
299
+ return e.forEach(function(w) {
300
+ r += t(w, a);
301
+ }), r;
302
+ }
303
+ var o = { type: e.type, content: t(e.content, a), tag: "span", classes: ["token", e.type], attributes: {}, language: a }, u = e.alias;
304
+ u && (Array.isArray(u) ? Array.prototype.push.apply(o.classes, u) : o.classes.push(u)), s.hooks.run("wrap", o);
305
+ var p = "";
306
+ for (var m in o.attributes) p += " " + m + '="' + (o.attributes[m] || "").replace(/"/g, "&quot;") + '"';
307
+ return "<" + o.tag + ' class="' + o.classes.join(" ") + '"' + p + ">" + o.content + "</" + o.tag + ">";
308
+ }, !i.document) return i.addEventListener && (s.disableWorkerMessageHandler || i.addEventListener("message", function(t) {
309
+ var e = JSON.parse(t.data), a = e.language, r = e.code, o = e.immediateClose;
310
+ i.postMessage(s.highlight(r, s.languages[a], a)), o && i.close();
311
+ }, !1)), s;
312
+ var L = s.util.currentScript();
313
+ function R() {
314
+ s.manual || s.highlightAll();
315
+ }
316
+ if (L && (s.filename = L.src, L.hasAttribute("data-manual") && (s.manual = !0)), !s.manual) {
317
+ var F = document.readyState;
318
+ F === "loading" || F === "interactive" && L && L.defer ? document.addEventListener("DOMContentLoaded", R) : window.requestAnimationFrame ? window.requestAnimationFrame(R) : window.setTimeout(R, 16);
319
+ }
320
+ return s;
321
+ }(typeof window < "u" ? window : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? self : {});
322
+ c.exports && (c.exports = n), ce !== void 0 && (ce.Prism = n), n.languages.markup = { comment: { pattern: /<!--(?:(?!<!--)[\s\S])*?-->/, greedy: !0 }, prolog: { pattern: /<\?[\s\S]+?\?>/, greedy: !0 }, doctype: { pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i, greedy: !0, inside: { "internal-subset": { pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/, lookbehind: !0, greedy: !0, inside: null }, string: { pattern: /"[^"]*"|'[^']*'/, greedy: !0 }, punctuation: /^<!|>$|[[\]]/, "doctype-tag": /^DOCTYPE/i, name: /[^\s<>'"]+/ } }, cdata: { pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, greedy: !0 }, tag: { pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/, greedy: !0, inside: { tag: { pattern: /^<\/?[^\s>\/]+/, inside: { punctuation: /^<\/?/, namespace: /^[^\s>\/:]+:/ } }, "special-attr": [], "attr-value": { pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/, inside: { punctuation: [{ pattern: /^=/, alias: "attr-equals" }, { pattern: /^(\s*)["']|["']$/, lookbehind: !0 }] } }, punctuation: /\/?>/, "attr-name": { pattern: /[^\s>\/]+/, inside: { namespace: /^[^\s>\/:]+:/ } } } }, entity: [{ pattern: /&[\da-z]{1,8};/i, alias: "named-entity" }, /&#x?[\da-f]{1,8};/i] }, n.languages.markup.tag.inside["attr-value"].inside.entity = n.languages.markup.entity, n.languages.markup.doctype.inside["internal-subset"].inside = n.languages.markup, n.hooks.add("wrap", function(i) {
323
+ i.type === "entity" && (i.attributes.title = i.content.replace(/&amp;/, "&"));
324
+ }), Object.defineProperty(n.languages.markup.tag, "addInlined", { value: function(i, l) {
325
+ var f = {};
326
+ f["language-" + l] = { pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i, lookbehind: !0, inside: n.languages[l] }, f.cdata = /^<!\[CDATA\[|\]\]>$/i;
327
+ var b = { "included-cdata": { pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, inside: f } };
328
+ b["language-" + l] = { pattern: /[\s\S]+/, inside: n.languages[l] };
329
+ var s = {};
330
+ s[i] = { pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
331
+ return i;
332
+ }), "i"), lookbehind: !0, greedy: !0, inside: b }, n.languages.insertBefore("markup", "cdata", s);
333
+ } }), Object.defineProperty(n.languages.markup.tag, "addAttribute", { value: function(i, l) {
334
+ n.languages.markup.tag.inside["special-attr"].push({ pattern: RegExp(/(^|["'\s])/.source + "(?:" + i + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source, "i"), lookbehind: !0, inside: { "attr-name": /^[^\s=]+/, "attr-value": { pattern: /=[\s\S]+/, inside: { value: { pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/, lookbehind: !0, alias: [l, "language-" + l], inside: n.languages[l] }, punctuation: [{ pattern: /^=/, alias: "attr-equals" }, /"|'/] } } } });
335
+ } }), n.languages.html = n.languages.markup, n.languages.mathml = n.languages.markup, n.languages.svg = n.languages.markup, n.languages.xml = n.languages.extend("markup", {}), n.languages.ssml = n.languages.xml, n.languages.atom = n.languages.xml, n.languages.rss = n.languages.xml, function(i) {
336
+ var l = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
337
+ i.languages.css = { comment: /\/\*[\s\S]*?\*\//, atrule: { pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + l.source + ")*?" + /(?:;|(?=\s*\{))/.source), inside: { rule: /^@[\w-]+/, "selector-function-argument": { pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/, lookbehind: !0, alias: "selector" }, keyword: { pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/, lookbehind: !0 } } }, url: { pattern: RegExp("\\burl\\((?:" + l.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"), greedy: !0, inside: { function: /^url/i, punctuation: /^\(|\)$/, string: { pattern: RegExp("^" + l.source + "$"), alias: "url" } } }, selector: { pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + l.source + ")*(?=\\s*\\{)"), lookbehind: !0 }, string: { pattern: l, greedy: !0 }, property: { pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i, lookbehind: !0 }, important: /!important\b/i, function: { pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i, lookbehind: !0 }, punctuation: /[(){};:,]/ }, i.languages.css.atrule.inside.rest = i.languages.css;
338
+ var f = i.languages.markup;
339
+ f && (f.tag.addInlined("style", "css"), f.tag.addAttribute("style", "css"));
340
+ }(n), n.languages.clike = { comment: [{ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, lookbehind: !0, greedy: !0 }, { pattern: /(^|[^\\:])\/\/.*/, lookbehind: !0, greedy: !0 }], string: { pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, greedy: !0 }, "class-name": { pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i, lookbehind: !0, inside: { punctuation: /[.\\]/ } }, keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/, boolean: /\b(?:false|true)\b/, function: /\b\w+(?=\()/, number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i, operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/, punctuation: /[{}[\];(),.:]/ }, n.languages.javascript = n.languages.extend("clike", { "class-name": [n.languages.clike["class-name"], { pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/, lookbehind: !0 }], keyword: [{ pattern: /((?:^|\})\s*)catch\b/, lookbehind: !0 }, { pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/, lookbehind: !0 }], function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, number: { pattern: RegExp(/(^|[^\w$])/.source + "(?:" + /NaN|Infinity/.source + "|" + /0[bB][01]+(?:_[01]+)*n?/.source + "|" + /0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + /\d+(?:_\d+)*n/.source + "|" + /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source + ")" + /(?![\w$])/.source), lookbehind: !0 }, operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/ }), n.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/, n.languages.insertBefore("javascript", "keyword", { regex: { pattern: RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + /\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source), lookbehind: !0, greedy: !0, inside: { "regex-source": { pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/, lookbehind: !0, alias: "language-regex", inside: n.languages.regex }, "regex-delimiter": /^\/|\/$/, "regex-flags": /^[a-z]+$/ } }, "function-variable": { pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/, alias: "function" }, parameter: [{ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/, lookbehind: !0, inside: n.languages.javascript }, { pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i, lookbehind: !0, inside: n.languages.javascript }, { pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/, lookbehind: !0, inside: n.languages.javascript }, { pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/, lookbehind: !0, inside: n.languages.javascript }], constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/ }), n.languages.insertBefore("javascript", "string", { hashbang: { pattern: /^#!.*/, greedy: !0, alias: "comment" }, "template-string": { pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/, greedy: !0, inside: { "template-punctuation": { pattern: /^`|`$/, alias: "string" }, interpolation: { pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/, lookbehind: !0, inside: { "interpolation-punctuation": { pattern: /^\$\{|\}$/, alias: "punctuation" }, rest: n.languages.javascript } }, string: /[\s\S]+/ } }, "string-property": { pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m, lookbehind: !0, greedy: !0, alias: "property" } }), n.languages.insertBefore("javascript", "operator", { "literal-property": { pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m, lookbehind: !0, alias: "property" } }), n.languages.markup && (n.languages.markup.tag.addInlined("script", "javascript"), n.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, "javascript")), n.languages.js = n.languages.javascript, function() {
341
+ if (n !== void 0 && typeof document < "u") {
342
+ Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector);
343
+ var i = { js: "javascript", py: "python", rb: "ruby", ps1: "powershell", psm1: "powershell", sh: "bash", bat: "batch", h: "c", tex: "latex" }, l = "data-src-status", f = "loading", b = "loaded", s = "pre[data-src]:not([" + l + '="' + b + '"]):not([' + l + '="' + f + '"])';
344
+ n.hooks.add("before-highlightall", function(k) {
345
+ k.selector += ", " + s;
346
+ }), n.hooks.add("before-sanity-check", function(k) {
347
+ var d = k.element;
348
+ if (d.matches(s)) {
349
+ k.code = "", d.setAttribute(l, f);
350
+ var S = d.appendChild(document.createElement("CODE"));
351
+ S.textContent = "Loading…";
352
+ var I = d.getAttribute("data-src"), x = k.language;
353
+ if (x === "none") {
354
+ var L = (/\.(\w+)$/.exec(I) || [, "none"])[1];
355
+ x = i[L] || L;
1169
356
  }
1170
- },
1171
- "special-attr": [],
1172
- "attr-value": {
1173
- pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1174
- inside: {
1175
- "punctuation": [
1176
- {
1177
- pattern: /^=/,
1178
- alias: "attr-equals"
1179
- },
1180
- {
1181
- pattern: /^(\s*)["']|["']$/,
1182
- lookbehind: true
357
+ n.util.setLanguage(S, x), n.util.setLanguage(d, x);
358
+ var R = n.plugins.autoloader;
359
+ R && R.loadLanguages(x), function(F, t, e) {
360
+ var a = new XMLHttpRequest();
361
+ a.open("GET", F, !0), a.onreadystatechange = function() {
362
+ a.readyState == 4 && (a.status < 400 && a.responseText ? t(a.responseText) : a.status >= 400 ? e("✖ Error " + a.status + " while fetching file: " + a.statusText) : e("✖ Error: File does not exist or is empty"));
363
+ }, a.send(null);
364
+ }(I, function(F) {
365
+ d.setAttribute(l, b);
366
+ var t = function(o) {
367
+ var u = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(o || "");
368
+ if (u) {
369
+ var p = Number(u[1]), m = u[2], w = u[3];
370
+ return m ? w ? [p, Number(w)] : [p, void 0] : [p, p];
1183
371
  }
1184
- ]
1185
- }
1186
- },
1187
- "punctuation": /\/?>/,
1188
- "attr-name": {
1189
- pattern: /[^\s>\/]+/,
1190
- inside: {
1191
- "namespace": /^[^\s>\/:]+:/
1192
- }
1193
- }
1194
- }
1195
- },
1196
- "entity": [
1197
- {
1198
- pattern: /&[\da-z]{1,8};/i,
1199
- alias: "named-entity"
1200
- },
1201
- /&#x?[\da-f]{1,8};/i
1202
- ]
1203
- };
1204
- Prism2.languages.markup["tag"].inside["attr-value"].inside["entity"] = Prism2.languages.markup["entity"];
1205
- Prism2.languages.markup["doctype"].inside["internal-subset"].inside = Prism2.languages.markup;
1206
- Prism2.hooks.add("wrap", function(env) {
1207
- if (env.type === "entity") {
1208
- env.attributes["title"] = env.content.replace(/&amp;/, "&");
1209
- }
1210
- });
1211
- Object.defineProperty(Prism2.languages.markup.tag, "addInlined", {
1212
- /**
1213
- * Adds an inlined language to markup.
1214
- *
1215
- * An example of an inlined language is CSS with `<style>` tags.
1216
- *
1217
- * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
1218
- * case insensitive.
1219
- * @param {string} lang The language key.
1220
- * @example
1221
- * addInlined('style', 'css');
1222
- */
1223
- value: function addInlined(tagName, lang) {
1224
- var includedCdataInside = {};
1225
- includedCdataInside["language-" + lang] = {
1226
- pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1227
- lookbehind: true,
1228
- inside: Prism2.languages[lang]
1229
- };
1230
- includedCdataInside["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
1231
- var inside = {
1232
- "included-cdata": {
1233
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1234
- inside: includedCdataInside
1235
- }
1236
- };
1237
- inside["language-" + lang] = {
1238
- pattern: /[\s\S]+/,
1239
- inside: Prism2.languages[lang]
1240
- };
1241
- var def = {};
1242
- def[tagName] = {
1243
- pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
1244
- return tagName;
1245
- }), "i"),
1246
- lookbehind: true,
1247
- greedy: true,
1248
- inside
1249
- };
1250
- Prism2.languages.insertBefore("markup", "cdata", def);
1251
- }
1252
- });
1253
- Object.defineProperty(Prism2.languages.markup.tag, "addAttribute", {
1254
- /**
1255
- * Adds an pattern to highlight languages embedded in HTML attributes.
1256
- *
1257
- * An example of an inlined language is CSS with `style` attributes.
1258
- *
1259
- * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
1260
- * case insensitive.
1261
- * @param {string} lang The language key.
1262
- * @example
1263
- * addAttribute('style', 'css');
1264
- */
1265
- value: function(attrName, lang) {
1266
- Prism2.languages.markup.tag.inside["special-attr"].push({
1267
- pattern: RegExp(
1268
- /(^|["'\s])/.source + "(?:" + attrName + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
1269
- "i"
1270
- ),
1271
- lookbehind: true,
1272
- inside: {
1273
- "attr-name": /^[^\s=]+/,
1274
- "attr-value": {
1275
- pattern: /=[\s\S]+/,
1276
- inside: {
1277
- "value": {
1278
- pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
1279
- lookbehind: true,
1280
- alias: [lang, "language-" + lang],
1281
- inside: Prism2.languages[lang]
1282
- },
1283
- "punctuation": [
1284
- {
1285
- pattern: /^=/,
1286
- alias: "attr-equals"
1287
- },
1288
- /"|'/
1289
- ]
1290
- }
1291
- }
1292
- }
1293
- });
1294
- }
1295
- });
1296
- Prism2.languages.html = Prism2.languages.markup;
1297
- Prism2.languages.mathml = Prism2.languages.markup;
1298
- Prism2.languages.svg = Prism2.languages.markup;
1299
- Prism2.languages.xml = Prism2.languages.extend("markup", {});
1300
- Prism2.languages.ssml = Prism2.languages.xml;
1301
- Prism2.languages.atom = Prism2.languages.xml;
1302
- Prism2.languages.rss = Prism2.languages.xml;
1303
- (function(Prism3) {
1304
- var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
1305
- Prism3.languages.css = {
1306
- "comment": /\/\*[\s\S]*?\*\//,
1307
- "atrule": {
1308
- pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + string.source + ")*?" + /(?:;|(?=\s*\{))/.source),
1309
- inside: {
1310
- "rule": /^@[\w-]+/,
1311
- "selector-function-argument": {
1312
- pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1313
- lookbehind: true,
1314
- alias: "selector"
1315
- },
1316
- "keyword": {
1317
- pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1318
- lookbehind: true
1319
- }
1320
- // See rest below
1321
- }
1322
- },
1323
- "url": {
1324
- // https://drafts.csswg.org/css-values-3/#urls
1325
- pattern: RegExp("\\burl\\((?:" + string.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
1326
- greedy: true,
1327
- inside: {
1328
- "function": /^url/i,
1329
- "punctuation": /^\(|\)$/,
1330
- "string": {
1331
- pattern: RegExp("^" + string.source + "$"),
1332
- alias: "url"
1333
- }
1334
- }
1335
- },
1336
- "selector": {
1337
- pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + string.source + ")*(?=\\s*\\{)"),
1338
- lookbehind: true
1339
- },
1340
- "string": {
1341
- pattern: string,
1342
- greedy: true
1343
- },
1344
- "property": {
1345
- pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
1346
- lookbehind: true
1347
- },
1348
- "important": /!important\b/i,
1349
- "function": {
1350
- pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
1351
- lookbehind: true
1352
- },
1353
- "punctuation": /[(){};:,]/
1354
- };
1355
- Prism3.languages.css["atrule"].inside.rest = Prism3.languages.css;
1356
- var markup = Prism3.languages.markup;
1357
- if (markup) {
1358
- markup.tag.addInlined("style", "css");
1359
- markup.tag.addAttribute("style", "css");
1360
- }
1361
- })(Prism2);
1362
- Prism2.languages.clike = {
1363
- "comment": [
1364
- {
1365
- pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1366
- lookbehind: true,
1367
- greedy: true
1368
- },
1369
- {
1370
- pattern: /(^|[^\\:])\/\/.*/,
1371
- lookbehind: true,
1372
- greedy: true
1373
- }
1374
- ],
1375
- "string": {
1376
- pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1377
- greedy: true
1378
- },
1379
- "class-name": {
1380
- pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
1381
- lookbehind: true,
1382
- inside: {
1383
- "punctuation": /[.\\]/
1384
- }
1385
- },
1386
- "keyword": /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
1387
- "boolean": /\b(?:false|true)\b/,
1388
- "function": /\b\w+(?=\()/,
1389
- "number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1390
- "operator": /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1391
- "punctuation": /[{}[\];(),.:]/
1392
- };
1393
- Prism2.languages.javascript = Prism2.languages.extend("clike", {
1394
- "class-name": [
1395
- Prism2.languages.clike["class-name"],
1396
- {
1397
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
1398
- lookbehind: true
1399
- }
1400
- ],
1401
- "keyword": [
1402
- {
1403
- pattern: /((?:^|\})\s*)catch\b/,
1404
- lookbehind: true
1405
- },
1406
- {
1407
- pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
1408
- lookbehind: true
1409
- }
1410
- ],
1411
- // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1412
- "function": /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1413
- "number": {
1414
- pattern: RegExp(
1415
- /(^|[^\w$])/.source + "(?:" + // constant
1416
- (/NaN|Infinity/.source + "|" + // binary integer
1417
- /0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
1418
- /0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
1419
- /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
1420
- /\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
1421
- /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
1422
- ),
1423
- lookbehind: true
1424
- },
1425
- "operator": /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
1426
- });
1427
- Prism2.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
1428
- Prism2.languages.insertBefore("javascript", "keyword", {
1429
- "regex": {
1430
- pattern: RegExp(
1431
- // lookbehind
1432
- // eslint-disable-next-line regexp/no-dupe-characters-character-class
1433
- /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
1434
- // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
1435
- // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
1436
- // with the only syntax, so we have to define 2 different regex patterns.
1437
- /\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
1438
- /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
1439
- /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
1440
- ),
1441
- lookbehind: true,
1442
- greedy: true,
1443
- inside: {
1444
- "regex-source": {
1445
- pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1446
- lookbehind: true,
1447
- alias: "language-regex",
1448
- inside: Prism2.languages.regex
1449
- },
1450
- "regex-delimiter": /^\/|\/$/,
1451
- "regex-flags": /^[a-z]+$/
1452
- }
1453
- },
1454
- // This must be declared before keyword because we use "function" inside the look-forward
1455
- "function-variable": {
1456
- pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
1457
- alias: "function"
1458
- },
1459
- "parameter": [
1460
- {
1461
- pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1462
- lookbehind: true,
1463
- inside: Prism2.languages.javascript
1464
- },
1465
- {
1466
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1467
- lookbehind: true,
1468
- inside: Prism2.languages.javascript
1469
- },
1470
- {
1471
- pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1472
- lookbehind: true,
1473
- inside: Prism2.languages.javascript
1474
- },
1475
- {
1476
- pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
1477
- lookbehind: true,
1478
- inside: Prism2.languages.javascript
1479
- }
1480
- ],
1481
- "constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/
1482
- });
1483
- Prism2.languages.insertBefore("javascript", "string", {
1484
- "hashbang": {
1485
- pattern: /^#!.*/,
1486
- greedy: true,
1487
- alias: "comment"
1488
- },
1489
- "template-string": {
1490
- pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
1491
- greedy: true,
1492
- inside: {
1493
- "template-punctuation": {
1494
- pattern: /^`|`$/,
1495
- alias: "string"
1496
- },
1497
- "interpolation": {
1498
- pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
1499
- lookbehind: true,
1500
- inside: {
1501
- "interpolation-punctuation": {
1502
- pattern: /^\$\{|\}$/,
1503
- alias: "punctuation"
1504
- },
1505
- rest: Prism2.languages.javascript
1506
- }
1507
- },
1508
- "string": /[\s\S]+/
1509
- }
1510
- },
1511
- "string-property": {
1512
- pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
1513
- lookbehind: true,
1514
- greedy: true,
1515
- alias: "property"
1516
- }
1517
- });
1518
- Prism2.languages.insertBefore("javascript", "operator", {
1519
- "literal-property": {
1520
- pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
1521
- lookbehind: true,
1522
- alias: "property"
1523
- }
1524
- });
1525
- if (Prism2.languages.markup) {
1526
- Prism2.languages.markup.tag.addInlined("script", "javascript");
1527
- Prism2.languages.markup.tag.addAttribute(
1528
- /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
1529
- "javascript"
1530
- );
1531
- }
1532
- Prism2.languages.js = Prism2.languages.javascript;
1533
- (function() {
1534
- if (typeof Prism2 === "undefined" || typeof document === "undefined") {
1535
- return;
1536
- }
1537
- if (!Element.prototype.matches) {
1538
- Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
1539
- }
1540
- var LOADING_MESSAGE = "Loading…";
1541
- var FAILURE_MESSAGE = function(status, message) {
1542
- return "✖ Error " + status + " while fetching file: " + message;
1543
- };
1544
- var FAILURE_EMPTY_MESSAGE = "✖ Error: File does not exist or is empty";
1545
- var EXTENSIONS = {
1546
- "js": "javascript",
1547
- "py": "python",
1548
- "rb": "ruby",
1549
- "ps1": "powershell",
1550
- "psm1": "powershell",
1551
- "sh": "bash",
1552
- "bat": "batch",
1553
- "h": "c",
1554
- "tex": "latex"
1555
- };
1556
- var STATUS_ATTR = "data-src-status";
1557
- var STATUS_LOADING = "loading";
1558
- var STATUS_LOADED = "loaded";
1559
- var STATUS_FAILED = "failed";
1560
- var SELECTOR = "pre[data-src]:not([" + STATUS_ATTR + '="' + STATUS_LOADED + '"]):not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
1561
- function loadFile(src, success, error) {
1562
- var xhr = new XMLHttpRequest();
1563
- xhr.open("GET", src, true);
1564
- xhr.onreadystatechange = function() {
1565
- if (xhr.readyState == 4) {
1566
- if (xhr.status < 400 && xhr.responseText) {
1567
- success(xhr.responseText);
1568
- } else {
1569
- if (xhr.status >= 400) {
1570
- error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
1571
- } else {
1572
- error(FAILURE_EMPTY_MESSAGE);
372
+ }(d.getAttribute("data-range"));
373
+ if (t) {
374
+ var e = F.split(/\r\n?|\n/g), a = t[0], r = t[1] == null ? e.length : t[1];
375
+ a < 0 && (a += e.length), a = Math.max(0, Math.min(a - 1, e.length)), r < 0 && (r += e.length), r = Math.max(0, Math.min(r, e.length)), F = e.slice(a, r).join(`
376
+ `), d.hasAttribute("data-start") || d.setAttribute("data-start", String(a + 1));
1573
377
  }
1574
- }
378
+ S.textContent = F, n.highlightElement(S);
379
+ }, function(F) {
380
+ d.setAttribute(l, "failed"), S.textContent = F;
381
+ });
1575
382
  }
383
+ }), n.plugins.fileHighlight = { highlight: function(k) {
384
+ for (var d, S = (k || document).querySelectorAll(s), I = 0; d = S[I++]; ) n.highlightElement(d);
385
+ } };
386
+ var y = !1;
387
+ n.fileHighlight = function() {
388
+ y || (y = !0), n.plugins.fileHighlight.highlight.apply(this, arguments);
1576
389
  };
1577
- xhr.send(null);
1578
- }
1579
- function parseRange(range) {
1580
- var m2 = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || "");
1581
- if (m2) {
1582
- var start = Number(m2[1]);
1583
- var comma = m2[2];
1584
- var end = m2[3];
1585
- if (!comma) {
1586
- return [start, start];
1587
- }
1588
- if (!end) {
1589
- return [start, void 0];
1590
- }
1591
- return [start, Number(end)];
1592
- }
1593
- return void 0;
1594
- }
1595
- Prism2.hooks.add("before-highlightall", function(env) {
1596
- env.selector += ", " + SELECTOR;
1597
- });
1598
- Prism2.hooks.add("before-sanity-check", function(env) {
1599
- var pre = (
1600
- /** @type {HTMLPreElement} */
1601
- env.element
1602
- );
1603
- if (pre.matches(SELECTOR)) {
1604
- env.code = "";
1605
- pre.setAttribute(STATUS_ATTR, STATUS_LOADING);
1606
- var code = pre.appendChild(document.createElement("CODE"));
1607
- code.textContent = LOADING_MESSAGE;
1608
- var src = pre.getAttribute("data-src");
1609
- var language = env.language;
1610
- if (language === "none") {
1611
- var extension = (/\.(\w+)$/.exec(src) || [, "none"])[1];
1612
- language = EXTENSIONS[extension] || extension;
1613
- }
1614
- Prism2.util.setLanguage(code, language);
1615
- Prism2.util.setLanguage(pre, language);
1616
- var autoloader = Prism2.plugins.autoloader;
1617
- if (autoloader) {
1618
- autoloader.loadLanguages(language);
1619
- }
1620
- loadFile(
1621
- src,
1622
- function(text) {
1623
- pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
1624
- var range = parseRange(pre.getAttribute("data-range"));
1625
- if (range) {
1626
- var lines = text.split(/\r\n?|\n/g);
1627
- var start = range[0];
1628
- var end = range[1] == null ? lines.length : range[1];
1629
- if (start < 0) {
1630
- start += lines.length;
1631
- }
1632
- start = Math.max(0, Math.min(start - 1, lines.length));
1633
- if (end < 0) {
1634
- end += lines.length;
1635
- }
1636
- end = Math.max(0, Math.min(end, lines.length));
1637
- text = lines.slice(start, end).join("\n");
1638
- if (!pre.hasAttribute("data-start")) {
1639
- pre.setAttribute("data-start", String(start + 1));
1640
- }
1641
- }
1642
- code.textContent = text;
1643
- Prism2.highlightElement(code);
1644
- },
1645
- function(error) {
1646
- pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
1647
- code.textContent = error;
1648
- }
1649
- );
1650
- }
1651
- });
1652
- Prism2.plugins.fileHighlight = {
1653
- /**
1654
- * Executes the File Highlight plugin for all matching `pre` elements under the given container.
1655
- *
1656
- * Note: Elements which are already loaded or currently loading will not be touched by this method.
1657
- *
1658
- * @param {ParentNode} [container=document]
1659
- */
1660
- highlight: function highlight(container) {
1661
- var elements = (container || document).querySelectorAll(SELECTOR);
1662
- for (var i = 0, element; element = elements[i++]; ) {
1663
- Prism2.highlightElement(element);
1664
- }
1665
- }
1666
- };
1667
- var logged = false;
1668
- Prism2.fileHighlight = function() {
1669
- if (!logged) {
1670
- console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.");
1671
- logged = true;
1672
- }
1673
- Prism2.plugins.fileHighlight.highlight.apply(this, arguments);
1674
- };
1675
- })();
1676
- })(prism);
1677
- var prismExports = prism.exports;
1678
- const Prism$1 = /* @__PURE__ */ getDefaultExportFromCjs(prismExports);
1679
- Prism.languages.clike = {
1680
- "comment": [
1681
- {
1682
- pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1683
- lookbehind: true,
1684
- greedy: true
1685
- },
1686
- {
1687
- pattern: /(^|[^\\:])\/\/.*/,
1688
- lookbehind: true,
1689
- greedy: true
1690
- }
1691
- ],
1692
- "string": {
1693
- pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1694
- greedy: true
1695
- },
1696
- "class-name": {
1697
- pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
1698
- lookbehind: true,
1699
- inside: {
1700
- "punctuation": /[.\\]/
1701
- }
1702
- },
1703
- "keyword": /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
1704
- "boolean": /\b(?:false|true)\b/,
1705
- "function": /\b\w+(?=\()/,
1706
- "number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1707
- "operator": /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1708
- "punctuation": /[{}[\];(),.:]/
1709
- };
1710
- Prism.languages.javascript = Prism.languages.extend("clike", {
1711
- "class-name": [
1712
- Prism.languages.clike["class-name"],
1713
- {
1714
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
1715
- lookbehind: true
1716
- }
1717
- ],
1718
- "keyword": [
1719
- {
1720
- pattern: /((?:^|\})\s*)catch\b/,
1721
- lookbehind: true
1722
- },
1723
- {
1724
- pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
1725
- lookbehind: true
1726
- }
1727
- ],
1728
- // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1729
- "function": /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1730
- "number": {
1731
- pattern: RegExp(
1732
- /(^|[^\w$])/.source + "(?:" + // constant
1733
- (/NaN|Infinity/.source + "|" + // binary integer
1734
- /0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
1735
- /0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
1736
- /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
1737
- /\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
1738
- /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
1739
- ),
1740
- lookbehind: true
1741
- },
1742
- "operator": /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
1743
- });
1744
- Prism.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
1745
- Prism.languages.insertBefore("javascript", "keyword", {
1746
- "regex": {
1747
- pattern: RegExp(
1748
- // lookbehind
1749
- // eslint-disable-next-line regexp/no-dupe-characters-character-class
1750
- /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
1751
- // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
1752
- // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
1753
- // with the only syntax, so we have to define 2 different regex patterns.
1754
- /\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
1755
- /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
1756
- /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
1757
- ),
1758
- lookbehind: true,
1759
- greedy: true,
1760
- inside: {
1761
- "regex-source": {
1762
- pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1763
- lookbehind: true,
1764
- alias: "language-regex",
1765
- inside: Prism.languages.regex
1766
- },
1767
- "regex-delimiter": /^\/|\/$/,
1768
- "regex-flags": /^[a-z]+$/
1769
- }
1770
- },
1771
- // This must be declared before keyword because we use "function" inside the look-forward
1772
- "function-variable": {
1773
- pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
1774
- alias: "function"
1775
- },
1776
- "parameter": [
1777
- {
1778
- pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1779
- lookbehind: true,
1780
- inside: Prism.languages.javascript
1781
- },
1782
- {
1783
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1784
- lookbehind: true,
1785
- inside: Prism.languages.javascript
1786
- },
1787
- {
1788
- pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1789
- lookbehind: true,
1790
- inside: Prism.languages.javascript
1791
- },
1792
- {
1793
- pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
1794
- lookbehind: true,
1795
- inside: Prism.languages.javascript
1796
- }
1797
- ],
1798
- "constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/
1799
- });
1800
- Prism.languages.insertBefore("javascript", "string", {
1801
- "hashbang": {
1802
- pattern: /^#!.*/,
1803
- greedy: true,
1804
- alias: "comment"
1805
- },
1806
- "template-string": {
1807
- pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
1808
- greedy: true,
1809
- inside: {
1810
- "template-punctuation": {
1811
- pattern: /^`|`$/,
1812
- alias: "string"
1813
- },
1814
- "interpolation": {
1815
- pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
1816
- lookbehind: true,
1817
- inside: {
1818
- "interpolation-punctuation": {
1819
- pattern: /^\$\{|\}$/,
1820
- alias: "punctuation"
1821
- },
1822
- rest: Prism.languages.javascript
1823
- }
1824
- },
1825
- "string": /[\s\S]+/
1826
- }
1827
- },
1828
- "string-property": {
1829
- pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
1830
- lookbehind: true,
1831
- greedy: true,
1832
- alias: "property"
1833
- }
1834
- });
1835
- Prism.languages.insertBefore("javascript", "operator", {
1836
- "literal-property": {
1837
- pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
1838
- lookbehind: true,
1839
- alias: "property"
1840
- }
1841
- });
1842
- if (Prism.languages.markup) {
1843
- Prism.languages.markup.tag.addInlined("script", "javascript");
1844
- Prism.languages.markup.tag.addAttribute(
1845
- /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
1846
- "javascript"
1847
- );
1848
- }
1849
- Prism.languages.js = Prism.languages.javascript;
1850
- Prism.languages.python = {
1851
- "comment": {
1852
- pattern: /(^|[^\\])#.*/,
1853
- lookbehind: true,
1854
- greedy: true
1855
- },
1856
- "string-interpolation": {
1857
- pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
1858
- greedy: true,
1859
- inside: {
1860
- "interpolation": {
1861
- // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
1862
- pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
1863
- lookbehind: true,
1864
- inside: {
1865
- "format-spec": {
1866
- pattern: /(:)[^:(){}]+(?=\}$)/,
1867
- lookbehind: true
1868
- },
1869
- "conversion-option": {
1870
- pattern: /![sra](?=[:}]$)/,
1871
- alias: "punctuation"
1872
- },
1873
- rest: null
1874
- }
1875
- },
1876
- "string": /[\s\S]+/
1877
- }
1878
- },
1879
- "triple-quoted-string": {
1880
- pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
1881
- greedy: true,
1882
- alias: "string"
1883
- },
1884
- "string": {
1885
- pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
1886
- greedy: true
1887
- },
1888
- "function": {
1889
- pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
1890
- lookbehind: true
1891
- },
1892
- "class-name": {
1893
- pattern: /(\bclass\s+)\w+/i,
1894
- lookbehind: true
1895
- },
1896
- "decorator": {
1897
- pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
1898
- lookbehind: true,
1899
- alias: ["annotation", "punctuation"],
1900
- inside: {
1901
- "punctuation": /\./
1902
- }
1903
- },
1904
- "keyword": /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
1905
- "builtin": /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
1906
- "boolean": /\b(?:False|None|True)\b/,
1907
- "number": /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
1908
- "operator": /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
1909
- "punctuation": /[{}[\];(),.:]/
1910
- };
1911
- Prism.languages.python["string-interpolation"].inside["interpolation"].inside.rest = Prism.languages.python;
1912
- Prism.languages.py = Prism.languages.python;
1913
- Prism.languages.go = Prism.languages.extend("clike", {
1914
- "string": {
1915
- pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
1916
- lookbehind: true,
1917
- greedy: true
1918
- },
1919
- "keyword": /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
1920
- "boolean": /\b(?:_|false|iota|nil|true)\b/,
1921
- "number": [
1922
- // binary and octal integers
1923
- /\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
1924
- // hexadecimal integers and floats
1925
- /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
1926
- // decimal integers and floats
1927
- /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
1928
- ],
1929
- "operator": /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
1930
- "builtin": /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
1931
- });
1932
- Prism.languages.insertBefore("go", "string", {
1933
- "char": {
1934
- pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
1935
- greedy: true
1936
- }
1937
- });
1938
- delete Prism.languages.go["class-name"];
1939
- (function(Prism2) {
1940
- var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/;
1941
- var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
1942
- var className = {
1943
- pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
1944
- lookbehind: true,
1945
- inside: {
1946
- "namespace": {
1947
- pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
1948
- inside: {
1949
- "punctuation": /\./
1950
- }
1951
- },
1952
- "punctuation": /\./
1953
- }
1954
- };
1955
- Prism2.languages.java = Prism2.languages.extend("clike", {
1956
- "string": {
1957
- pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
1958
- lookbehind: true,
1959
- greedy: true
1960
- },
1961
- "class-name": [
1962
- className,
1963
- {
1964
- // variables, parameters, and constructor references
1965
- // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
1966
- pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
1967
- lookbehind: true,
1968
- inside: className.inside
1969
- },
1970
- {
1971
- // class names based on keyword
1972
- // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
1973
- pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source),
1974
- lookbehind: true,
1975
- inside: className.inside
1976
- }
1977
- ],
1978
- "keyword": keywords,
1979
- "function": [
1980
- Prism2.languages.clike.function,
1981
- {
1982
- pattern: /(::\s*)[a-z_]\w*/,
1983
- lookbehind: true
1984
- }
1985
- ],
1986
- "number": /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
1987
- "operator": {
1988
- pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
1989
- lookbehind: true
1990
- },
1991
- "constant": /\b[A-Z][A-Z_\d]+\b/
1992
- });
1993
- Prism2.languages.insertBefore("java", "string", {
1994
- "triple-quoted-string": {
1995
- // http://openjdk.java.net/jeps/355#Description
1996
- pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
1997
- greedy: true,
1998
- alias: "string"
1999
- },
2000
- "char": {
2001
- pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
2002
- greedy: true
2003
- }
2004
- });
2005
- Prism2.languages.insertBefore("java", "class-name", {
2006
- "annotation": {
2007
- pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
2008
- lookbehind: true,
2009
- alias: "punctuation"
2010
- },
2011
- "generics": {
2012
- pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
2013
- inside: {
2014
- "class-name": className,
2015
- "keyword": keywords,
2016
- "punctuation": /[<>(),.:]/,
2017
- "operator": /[?&|]/
2018
- }
2019
- },
2020
- "import": [
2021
- {
2022
- pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
2023
- lookbehind: true,
2024
- inside: {
2025
- "namespace": className.inside.namespace,
2026
- "punctuation": /\./,
2027
- "operator": /\*/,
2028
- "class-name": /\w+/
2029
- }
2030
- },
2031
- {
2032
- pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source),
2033
- lookbehind: true,
2034
- alias: "static",
2035
- inside: {
2036
- "namespace": className.inside.namespace,
2037
- "static": /\b\w+$/,
2038
- "punctuation": /\./,
2039
- "operator": /\*/,
2040
- "class-name": /\w+/
2041
- }
2042
- }
2043
- ],
2044
- "namespace": {
2045
- pattern: RegExp(
2046
- /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g, function() {
2047
- return keywords.source;
2048
- })
2049
- ),
2050
- lookbehind: true,
2051
- inside: {
2052
- "punctuation": /\./
2053
- }
2054
390
  }
391
+ }();
392
+ })(pe);
393
+ const ae = Le(pe.exports);
394
+ Prism.languages.clike = { comment: [{ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, lookbehind: !0, greedy: !0 }, { pattern: /(^|[^\\:])\/\/.*/, lookbehind: !0, greedy: !0 }], string: { pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, greedy: !0 }, "class-name": { pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i, lookbehind: !0, inside: { punctuation: /[.\\]/ } }, keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/, boolean: /\b(?:false|true)\b/, function: /\b\w+(?=\()/, number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i, operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/, punctuation: /[{}[\];(),.:]/ }, Prism.languages.javascript = Prism.languages.extend("clike", { "class-name": [Prism.languages.clike["class-name"], { pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/, lookbehind: !0 }], keyword: [{ pattern: /((?:^|\})\s*)catch\b/, lookbehind: !0 }, { pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/, lookbehind: !0 }], function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, number: { pattern: RegExp(/(^|[^\w$])/.source + "(?:" + /NaN|Infinity/.source + "|" + /0[bB][01]+(?:_[01]+)*n?/.source + "|" + /0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + /\d+(?:_\d+)*n/.source + "|" + /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source + ")" + /(?![\w$])/.source), lookbehind: !0 }, operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/ }), Prism.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/, Prism.languages.insertBefore("javascript", "keyword", { regex: { pattern: RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + /\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source), lookbehind: !0, greedy: !0, inside: { "regex-source": { pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/, lookbehind: !0, alias: "language-regex", inside: Prism.languages.regex }, "regex-delimiter": /^\/|\/$/, "regex-flags": /^[a-z]+$/ } }, "function-variable": { pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/, alias: "function" }, parameter: [{ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/, lookbehind: !0, inside: Prism.languages.javascript }, { pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i, lookbehind: !0, inside: Prism.languages.javascript }, { pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/, lookbehind: !0, inside: Prism.languages.javascript }, { pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/, lookbehind: !0, inside: Prism.languages.javascript }], constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/ }), Prism.languages.insertBefore("javascript", "string", { hashbang: { pattern: /^#!.*/, greedy: !0, alias: "comment" }, "template-string": { pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/, greedy: !0, inside: { "template-punctuation": { pattern: /^`|`$/, alias: "string" }, interpolation: { pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/, lookbehind: !0, inside: { "interpolation-punctuation": { pattern: /^\$\{|\}$/, alias: "punctuation" }, rest: Prism.languages.javascript } }, string: /[\s\S]+/ } }, "string-property": { pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m, lookbehind: !0, greedy: !0, alias: "property" } }), Prism.languages.insertBefore("javascript", "operator", { "literal-property": { pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m, lookbehind: !0, alias: "property" } }), Prism.languages.markup && (Prism.languages.markup.tag.addInlined("script", "javascript"), Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, "javascript")), Prism.languages.js = Prism.languages.javascript, Prism.languages.python = { comment: { pattern: /(^|[^\\])#.*/, lookbehind: !0, greedy: !0 }, "string-interpolation": { pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i, greedy: !0, inside: { interpolation: { pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/, lookbehind: !0, inside: { "format-spec": { pattern: /(:)[^:(){}]+(?=\}$)/, lookbehind: !0 }, "conversion-option": { pattern: /![sra](?=[:}]$)/, alias: "punctuation" }, rest: null } }, string: /[\s\S]+/ } }, "triple-quoted-string": { pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i, greedy: !0, alias: "string" }, string: { pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i, greedy: !0 }, function: { pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g, lookbehind: !0 }, "class-name": { pattern: /(\bclass\s+)\w+/i, lookbehind: !0 }, decorator: { pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m, lookbehind: !0, alias: ["annotation", "punctuation"], inside: { punctuation: /\./ } }, keyword: /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/, builtin: /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/, boolean: /\b(?:False|None|True)\b/, number: /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i, operator: /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/, punctuation: /[{}[\];(),.:]/ }, Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest = Prism.languages.python, Prism.languages.py = Prism.languages.python, Prism.languages.go = Prism.languages.extend("clike", { string: { pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/, lookbehind: !0, greedy: !0 }, keyword: /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/, boolean: /\b(?:_|false|iota|nil|true)\b/, number: [/\b0(?:b[01_]+|o[0-7_]+)i?\b/i, /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i, /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i], operator: /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./, builtin: /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/ }), Prism.languages.insertBefore("go", "string", { char: { pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/, greedy: !0 } }), delete Prism.languages.go["class-name"], function(c) {
395
+ var n = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/, i = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source, l = { pattern: RegExp(/(^|[^\w.])/.source + i + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source), lookbehind: !0, inside: { namespace: { pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/, inside: { punctuation: /\./ } }, punctuation: /\./ } };
396
+ c.languages.java = c.languages.extend("clike", { string: { pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/, lookbehind: !0, greedy: !0 }, "class-name": [l, { pattern: RegExp(/(^|[^\w.])/.source + i + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source), lookbehind: !0, inside: l.inside }, { pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + i + /[A-Z]\w*\b/.source), lookbehind: !0, inside: l.inside }], keyword: n, function: [c.languages.clike.function, { pattern: /(::\s*)[a-z_]\w*/, lookbehind: !0 }], number: /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i, operator: { pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m, lookbehind: !0 }, constant: /\b[A-Z][A-Z_\d]+\b/ }), c.languages.insertBefore("java", "string", { "triple-quoted-string": { pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/, greedy: !0, alias: "string" }, char: { pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/, greedy: !0 } }), c.languages.insertBefore("java", "class-name", { annotation: { pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/, lookbehind: !0, alias: "punctuation" }, generics: { pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/, inside: { "class-name": l, keyword: n, punctuation: /[<>(),.:]/, operator: /[?&|]/ } }, import: [{ pattern: RegExp(/(\bimport\s+)/.source + i + /(?:[A-Z]\w*|\*)(?=\s*;)/.source), lookbehind: !0, inside: { namespace: l.inside.namespace, punctuation: /\./, operator: /\*/, "class-name": /\w+/ } }, { pattern: RegExp(/(\bimport\s+static\s+)/.source + i + /(?:\w+|\*)(?=\s*;)/.source), lookbehind: !0, alias: "static", inside: { namespace: l.inside.namespace, static: /\b\w+$/, punctuation: /\./, operator: /\*/, "class-name": /\w+/ } }], namespace: { pattern: RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g, function() {
397
+ return n.source;
398
+ })), lookbehind: !0, inside: { punctuation: /\./ } } });
399
+ }(Prism), Prism.languages.c = Prism.languages.extend("clike", { comment: { pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/, greedy: !0 }, string: { pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/, greedy: !0 }, "class-name": { pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/, lookbehind: !0 }, keyword: /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/, function: /\b[a-z_]\w*(?=\s*\()/i, number: /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i, operator: />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/ }), Prism.languages.insertBefore("c", "string", { char: { pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/, greedy: !0 } }), Prism.languages.insertBefore("c", "string", { macro: { pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im, lookbehind: !0, greedy: !0, alias: "property", inside: { string: [{ pattern: /^(#\s*include\s*)<[^>]+>/, lookbehind: !0 }, Prism.languages.c.string], char: Prism.languages.c.char, comment: Prism.languages.c.comment, "macro-name": [{ pattern: /(^#\s*define\s+)\w+\b(?!\()/i, lookbehind: !0 }, { pattern: /(^#\s*define\s+)\w+\b(?=\()/i, lookbehind: !0, alias: "function" }], directive: { pattern: /^(#\s*)[a-z]+/, lookbehind: !0, alias: "keyword" }, "directive-hash": /^#/, punctuation: /##|\\(?=[\r\n])/, expression: { pattern: /\S[\s\S]*/, inside: Prism.languages.c } } } }), Prism.languages.insertBefore("c", "function", { constant: /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/ }), delete Prism.languages.c.boolean, function(c) {
400
+ for (var n = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source, i = 0; i < 2; i++) n = n.replace(/<self>/g, function() {
401
+ return n;
2055
402
  });
2056
- })(Prism);
2057
- Prism.languages.c = Prism.languages.extend("clike", {
2058
- "comment": {
2059
- pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
2060
- greedy: true
2061
- },
2062
- "string": {
2063
- // https://en.cppreference.com/w/c/language/string_literal
2064
- pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
2065
- greedy: true
2066
- },
2067
- "class-name": {
2068
- pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
2069
- lookbehind: true
2070
- },
2071
- "keyword": /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
2072
- "function": /\b[a-z_]\w*(?=\s*\()/i,
2073
- "number": /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
2074
- "operator": />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
2075
- });
2076
- Prism.languages.insertBefore("c", "string", {
2077
- "char": {
2078
- // https://en.cppreference.com/w/c/language/character_constant
2079
- pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
2080
- greedy: true
2081
- }
2082
- });
2083
- Prism.languages.insertBefore("c", "string", {
2084
- "macro": {
2085
- // allow for multiline macro definitions
2086
- // spaces after the # character compile fine with gcc
2087
- pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
2088
- lookbehind: true,
2089
- greedy: true,
2090
- alias: "property",
2091
- inside: {
2092
- "string": [
2093
- {
2094
- // highlight the path of the include statement as a string
2095
- pattern: /^(#\s*include\s*)<[^>]+>/,
2096
- lookbehind: true
2097
- },
2098
- Prism.languages.c["string"]
2099
- ],
2100
- "char": Prism.languages.c["char"],
2101
- "comment": Prism.languages.c["comment"],
2102
- "macro-name": [
2103
- {
2104
- pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
2105
- lookbehind: true
2106
- },
2107
- {
2108
- pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
2109
- lookbehind: true,
2110
- alias: "function"
2111
- }
2112
- ],
2113
- // highlight macro directives as keywords
2114
- "directive": {
2115
- pattern: /^(#\s*)[a-z]+/,
2116
- lookbehind: true,
2117
- alias: "keyword"
2118
- },
2119
- "directive-hash": /^#/,
2120
- "punctuation": /##|\\(?=[\r\n])/,
2121
- "expression": {
2122
- pattern: /\S[\s\S]*/,
2123
- inside: Prism.languages.c
2124
- }
2125
- }
2126
- }
2127
- });
2128
- Prism.languages.insertBefore("c", "function", {
2129
- // highlight predefined macros as constants
2130
- "constant": /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
2131
- });
2132
- delete Prism.languages.c["boolean"];
2133
- (function(Prism2) {
2134
- var multilineComment = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source;
2135
- for (var i = 0; i < 2; i++) {
2136
- multilineComment = multilineComment.replace(/<self>/g, function() {
2137
- return multilineComment;
2138
- });
2139
- }
2140
- multilineComment = multilineComment.replace(/<self>/g, function() {
403
+ n = n.replace(/<self>/g, function() {
2141
404
  return /[^\s\S]/.source;
2142
- });
2143
- Prism2.languages.rust = {
2144
- "comment": [
2145
- {
2146
- pattern: RegExp(/(^|[^\\])/.source + multilineComment),
2147
- lookbehind: true,
2148
- greedy: true
2149
- },
2150
- {
2151
- pattern: /(^|[^\\:])\/\/.*/,
2152
- lookbehind: true,
2153
- greedy: true
2154
- }
2155
- ],
2156
- "string": {
2157
- pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,
2158
- greedy: true
2159
- },
2160
- "char": {
2161
- pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,
2162
- greedy: true
2163
- },
2164
- "attribute": {
2165
- pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,
2166
- greedy: true,
2167
- alias: "attr-name",
2168
- inside: {
2169
- "string": null
2170
- // see below
2171
- }
2172
- },
2173
- // Closure params should not be confused with bitwise OR |
2174
- "closure-params": {
2175
- pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
2176
- lookbehind: true,
2177
- greedy: true,
2178
- inside: {
2179
- "closure-punctuation": {
2180
- pattern: /^\||\|$/,
2181
- alias: "punctuation"
2182
- },
2183
- rest: null
2184
- // see below
2185
- }
2186
- },
2187
- "lifetime-annotation": {
2188
- pattern: /'\w+/,
2189
- alias: "symbol"
2190
- },
2191
- "fragment-specifier": {
2192
- pattern: /(\$\w+:)[a-z]+/,
2193
- lookbehind: true,
2194
- alias: "punctuation"
2195
- },
2196
- "variable": /\$\w+/,
2197
- "function-definition": {
2198
- pattern: /(\bfn\s+)\w+/,
2199
- lookbehind: true,
2200
- alias: "function"
2201
- },
2202
- "type-definition": {
2203
- pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/,
2204
- lookbehind: true,
2205
- alias: "class-name"
2206
- },
2207
- "module-declaration": [
2208
- {
2209
- pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,
2210
- lookbehind: true,
2211
- alias: "namespace"
2212
- },
2213
- {
2214
- pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,
2215
- lookbehind: true,
2216
- alias: "namespace",
2217
- inside: {
2218
- "punctuation": /::/
2219
- }
2220
- }
2221
- ],
2222
- "keyword": [
2223
- // https://github.com/rust-lang/reference/blob/master/src/keywords.md
2224
- /\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
2225
- // primitives and str
2226
- // https://doc.rust-lang.org/stable/rust-by-example/primitives.html
2227
- /\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/
2228
- ],
2229
- // functions can technically start with an upper-case letter, but this will introduce a lot of false positives
2230
- // and Rust's naming conventions recommend snake_case anyway.
2231
- // https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
2232
- "function": /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
2233
- "macro": {
2234
- pattern: /\b\w+!/,
2235
- alias: "property"
2236
- },
2237
- "constant": /\b[A-Z_][A-Z_\d]+\b/,
2238
- "class-name": /\b[A-Z]\w*\b/,
2239
- "namespace": {
2240
- pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,
2241
- inside: {
2242
- "punctuation": /::/
2243
- }
2244
- },
2245
- // Hex, oct, bin, dec numbers with visual separators and type suffix
2246
- "number": /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,
2247
- "boolean": /\b(?:false|true)\b/,
2248
- "punctuation": /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
2249
- "operator": /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
2250
- };
2251
- Prism2.languages.rust["closure-params"].inside.rest = Prism2.languages.rust;
2252
- Prism2.languages.rust["attribute"].inside["string"] = Prism2.languages.rust["string"];
2253
- })(Prism);
2254
- Prism.languages.sql = {
2255
- "comment": {
2256
- pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
2257
- lookbehind: true
2258
- },
2259
- "variable": [
2260
- {
2261
- pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
2262
- greedy: true
2263
- },
2264
- /@[\w.$]+/
2265
- ],
2266
- "string": {
2267
- pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
2268
- greedy: true,
2269
- lookbehind: true
2270
- },
2271
- "identifier": {
2272
- pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,
2273
- greedy: true,
2274
- lookbehind: true,
2275
- inside: {
2276
- "punctuation": /^`|`$/
2277
- }
2278
- },
2279
- "function": /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
2280
- // Should we highlight user defined functions too?
2281
- "keyword": /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
2282
- "boolean": /\b(?:FALSE|NULL|TRUE)\b/i,
2283
- "number": /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
2284
- "operator": /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
2285
- "punctuation": /[;[\]()`,.]/
2286
- };
2287
- (function(Prism2) {
2288
- var envVars = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b";
2289
- var commandAfterHeredoc = {
2290
- pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
2291
- lookbehind: true,
2292
- alias: "punctuation",
2293
- // this looks reasonably well in all themes
2294
- inside: null
2295
- // see below
2296
- };
2297
- var insideString = {
2298
- "bash": commandAfterHeredoc,
2299
- "environment": {
2300
- pattern: RegExp("\\$" + envVars),
2301
- alias: "constant"
2302
- },
2303
- "variable": [
2304
- // [0]: Arithmetic Environment
2305
- {
2306
- pattern: /\$?\(\([\s\S]+?\)\)/,
2307
- greedy: true,
2308
- inside: {
2309
- // If there is a $ sign at the beginning highlight $(( and )) as variable
2310
- "variable": [
2311
- {
2312
- pattern: /(^\$\(\([\s\S]+)\)\)/,
2313
- lookbehind: true
2314
- },
2315
- /^\$\(\(/
2316
- ],
2317
- "number": /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
2318
- // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
2319
- "operator": /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
2320
- // If there is no $ sign at the beginning highlight (( and )) as punctuation
2321
- "punctuation": /\(\(?|\)\)?|,|;/
2322
- }
2323
- },
2324
- // [1]: Command Substitution
2325
- {
2326
- pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
2327
- greedy: true,
2328
- inside: {
2329
- "variable": /^\$\(|^`|\)$|`$/
2330
- }
2331
- },
2332
- // [2]: Brace expansion
2333
- {
2334
- pattern: /\$\{[^}]+\}/,
2335
- greedy: true,
2336
- inside: {
2337
- "operator": /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
2338
- "punctuation": /[\[\]]/,
2339
- "environment": {
2340
- pattern: RegExp("(\\{)" + envVars),
2341
- lookbehind: true,
2342
- alias: "constant"
2343
- }
2344
- }
2345
- },
2346
- /\$(?:\w+|[#?*!@$])/
2347
- ],
2348
- // Escape sequences from echo and printf's manuals, and escaped quotes.
2349
- "entity": /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
2350
- };
2351
- Prism2.languages.bash = {
2352
- "shebang": {
2353
- pattern: /^#!\s*\/.*/,
2354
- alias: "important"
2355
- },
2356
- "comment": {
2357
- pattern: /(^|[^"{\\$])#.*/,
2358
- lookbehind: true
2359
- },
2360
- "function-name": [
2361
- // a) function foo {
2362
- // b) foo() {
2363
- // c) function foo() {
2364
- // but not “foo {”
2365
- {
2366
- // a) and c)
2367
- pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
2368
- lookbehind: true,
2369
- alias: "function"
2370
- },
2371
- {
2372
- // b)
2373
- pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
2374
- alias: "function"
2375
- }
2376
- ],
2377
- // Highlight variable names as variables in for and select beginnings.
2378
- "for-or-select": {
2379
- pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
2380
- alias: "variable",
2381
- lookbehind: true
2382
- },
2383
- // Highlight variable names as variables in the left-hand part
2384
- // of assignments (“=” and “+=”).
2385
- "assign-left": {
2386
- pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
2387
- inside: {
2388
- "environment": {
2389
- pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
2390
- lookbehind: true,
2391
- alias: "constant"
2392
- }
2393
- },
2394
- alias: "variable",
2395
- lookbehind: true
2396
- },
2397
- // Highlight parameter names as variables
2398
- "parameter": {
2399
- pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
2400
- alias: "variable",
2401
- lookbehind: true
2402
- },
2403
- "string": [
2404
- // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
2405
- {
2406
- pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
2407
- lookbehind: true,
2408
- greedy: true,
2409
- inside: insideString
2410
- },
2411
- // Here-document with quotes around the tag
2412
- // → No expansion (so no “inside”).
2413
- {
2414
- pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
2415
- lookbehind: true,
2416
- greedy: true,
2417
- inside: {
2418
- "bash": commandAfterHeredoc
2419
- }
2420
- },
2421
- // “Normal” string
2422
- {
2423
- // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
2424
- pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
2425
- lookbehind: true,
2426
- greedy: true,
2427
- inside: insideString
2428
- },
2429
- {
2430
- // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
2431
- pattern: /(^|[^$\\])'[^']*'/,
2432
- lookbehind: true,
2433
- greedy: true
2434
- },
2435
- {
2436
- // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
2437
- pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
2438
- greedy: true,
2439
- inside: {
2440
- "entity": insideString.entity
2441
- }
2442
- }
2443
- ],
2444
- "environment": {
2445
- pattern: RegExp("\\$?" + envVars),
2446
- alias: "constant"
2447
- },
2448
- "variable": insideString.variable,
2449
- "function": {
2450
- pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
2451
- lookbehind: true
2452
- },
2453
- "keyword": {
2454
- pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
2455
- lookbehind: true
2456
- },
2457
- // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
2458
- "builtin": {
2459
- pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
2460
- lookbehind: true,
2461
- // Alias added to make those easier to distinguish from strings.
2462
- alias: "class-name"
2463
- },
2464
- "boolean": {
2465
- pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
2466
- lookbehind: true
2467
- },
2468
- "file-descriptor": {
2469
- pattern: /\B&\d\b/,
2470
- alias: "important"
2471
- },
2472
- "operator": {
2473
- // Lots of redirections here, but not just that.
2474
- pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
2475
- inside: {
2476
- "file-descriptor": {
2477
- pattern: /^\d/,
2478
- alias: "important"
2479
- }
2480
- }
2481
- },
2482
- "punctuation": /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
2483
- "number": {
2484
- pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
2485
- lookbehind: true
2486
- }
2487
- };
2488
- commandAfterHeredoc.inside = Prism2.languages.bash;
2489
- var toBeCopied = [
2490
- "comment",
2491
- "function-name",
2492
- "for-or-select",
2493
- "assign-left",
2494
- "parameter",
2495
- "string",
2496
- "environment",
2497
- "function",
2498
- "keyword",
2499
- "builtin",
2500
- "boolean",
2501
- "file-descriptor",
2502
- "operator",
2503
- "punctuation",
2504
- "number"
2505
- ];
2506
- var inside = insideString.variable[1].inside;
2507
- for (var i = 0; i < toBeCopied.length; i++) {
2508
- inside[toBeCopied[i]] = Prism2.languages.bash[toBeCopied[i]];
2509
- }
2510
- Prism2.languages.sh = Prism2.languages.bash;
2511
- Prism2.languages.shell = Prism2.languages.bash;
2512
- })(Prism);
2513
- Prism.languages.json = {
2514
- "property": {
2515
- pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
2516
- lookbehind: true,
2517
- greedy: true
2518
- },
2519
- "string": {
2520
- pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
2521
- lookbehind: true,
2522
- greedy: true
2523
- },
2524
- "comment": {
2525
- pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
2526
- greedy: true
2527
- },
2528
- "number": /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
2529
- "punctuation": /[{}[\],]/,
2530
- "operator": /:/,
2531
- "boolean": /\b(?:false|true)\b/,
2532
- "null": {
2533
- pattern: /\bnull\b/,
2534
- alias: "keyword"
2535
- }
2536
- };
2537
- Prism.languages.webmanifest = Prism.languages.json;
2538
- const prismDarkTheme = `
405
+ }), c.languages.rust = { comment: [{ pattern: RegExp(/(^|[^\\])/.source + n), lookbehind: !0, greedy: !0 }, { pattern: /(^|[^\\:])\/\/.*/, lookbehind: !0, greedy: !0 }], string: { pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/, greedy: !0 }, char: { pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/, greedy: !0 }, attribute: { pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/, greedy: !0, alias: "attr-name", inside: { string: null } }, "closure-params": { pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/, lookbehind: !0, greedy: !0, inside: { "closure-punctuation": { pattern: /^\||\|$/, alias: "punctuation" }, rest: null } }, "lifetime-annotation": { pattern: /'\w+/, alias: "symbol" }, "fragment-specifier": { pattern: /(\$\w+:)[a-z]+/, lookbehind: !0, alias: "punctuation" }, variable: /\$\w+/, "function-definition": { pattern: /(\bfn\s+)\w+/, lookbehind: !0, alias: "function" }, "type-definition": { pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/, lookbehind: !0, alias: "class-name" }, "module-declaration": [{ pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/, lookbehind: !0, alias: "namespace" }, { pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/, lookbehind: !0, alias: "namespace", inside: { punctuation: /::/ } }], keyword: [/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/, /\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/], function: /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/, macro: { pattern: /\b\w+!/, alias: "property" }, constant: /\b[A-Z_][A-Z_\d]+\b/, "class-name": /\b[A-Z]\w*\b/, namespace: { pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/, inside: { punctuation: /::/ } }, number: /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/, boolean: /\b(?:false|true)\b/, punctuation: /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/, operator: /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/ }, c.languages.rust["closure-params"].inside.rest = c.languages.rust, c.languages.rust.attribute.inside.string = c.languages.rust.string;
406
+ }(Prism), Prism.languages.sql = { comment: { pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/, lookbehind: !0 }, variable: [{ pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/, greedy: !0 }, /@[\w.$]+/], string: { pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/, greedy: !0, lookbehind: !0 }, identifier: { pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/, greedy: !0, lookbehind: !0, inside: { punctuation: /^`|`$/ } }, function: /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i, keyword: /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i, boolean: /\b(?:FALSE|NULL|TRUE)\b/i, number: /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i, operator: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i, punctuation: /[;[\]()`,.]/ }, function(c) {
407
+ var n = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b", i = { pattern: /(^(["']?)\w+\2)[ \t]+\S.*/, lookbehind: !0, alias: "punctuation", inside: null }, l = { bash: i, environment: { pattern: RegExp("\\$" + n), alias: "constant" }, variable: [{ pattern: /\$?\(\([\s\S]+?\)\)/, greedy: !0, inside: { variable: [{ pattern: /(^\$\(\([\s\S]+)\)\)/, lookbehind: !0 }, /^\$\(\(/], number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/, operator: /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/, punctuation: /\(\(?|\)\)?|,|;/ } }, { pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/, greedy: !0, inside: { variable: /^\$\(|^`|\)$|`$/ } }, { pattern: /\$\{[^}]+\}/, greedy: !0, inside: { operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/, punctuation: /[\[\]]/, environment: { pattern: RegExp("(\\{)" + n), lookbehind: !0, alias: "constant" } } }, /\$(?:\w+|[#?*!@$])/], entity: /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/ };
408
+ c.languages.bash = { shebang: { pattern: /^#!\s*\/.*/, alias: "important" }, comment: { pattern: /(^|[^"{\\$])#.*/, lookbehind: !0 }, "function-name": [{ pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/, lookbehind: !0, alias: "function" }, { pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/, alias: "function" }], "for-or-select": { pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/, alias: "variable", lookbehind: !0 }, "assign-left": { pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/, inside: { environment: { pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + n), lookbehind: !0, alias: "constant" } }, alias: "variable", lookbehind: !0 }, parameter: { pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/, alias: "variable", lookbehind: !0 }, string: [{ pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/, lookbehind: !0, greedy: !0, inside: l }, { pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/, lookbehind: !0, greedy: !0, inside: { bash: i } }, { pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/, lookbehind: !0, greedy: !0, inside: l }, { pattern: /(^|[^$\\])'[^']*'/, lookbehind: !0, greedy: !0 }, { pattern: /\$'(?:[^'\\]|\\[\s\S])*'/, greedy: !0, inside: { entity: l.entity } }], environment: { pattern: RegExp("\\$?" + n), alias: "constant" }, variable: l.variable, function: { pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/, lookbehind: !0 }, keyword: { pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/, lookbehind: !0 }, builtin: { pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/, lookbehind: !0, alias: "class-name" }, boolean: { pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/, lookbehind: !0 }, "file-descriptor": { pattern: /\B&\d\b/, alias: "important" }, operator: { pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/, inside: { "file-descriptor": { pattern: /^\d/, alias: "important" } } }, punctuation: /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/, number: { pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/, lookbehind: !0 } }, i.inside = c.languages.bash;
409
+ for (var f = ["comment", "function-name", "for-or-select", "assign-left", "parameter", "string", "environment", "function", "keyword", "builtin", "boolean", "file-descriptor", "operator", "punctuation", "number"], b = l.variable[1].inside, s = 0; s < f.length; s++) b[f[s]] = c.languages.bash[f[s]];
410
+ c.languages.sh = c.languages.bash, c.languages.shell = c.languages.bash;
411
+ }(Prism), Prism.languages.json = { property: { pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/, lookbehind: !0, greedy: !0 }, string: { pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/, lookbehind: !0, greedy: !0 }, comment: { pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/, greedy: !0 }, number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i, punctuation: /[{}[\],]/, operator: /:/, boolean: /\b(?:false|true)\b/, null: { pattern: /\bnull\b/, alias: "keyword" } }, Prism.languages.webmanifest = Prism.languages.json;
412
+ const Ce = ["innerHTML"], Pe = ["value", "disabled"], ge = (c, n) => {
413
+ const i = c.__vccOpts || c;
414
+ for (const [l, f] of n) i[l] = f;
415
+ return i;
416
+ }, De = ge(oe({ __name: "CodeEditor", props: { modelValue: {}, language: {}, theme: { default: "dark" }, disabled: { type: Boolean, default: !1 } }, emits: ["update:modelValue", "change"], setup(c, { emit: n }) {
417
+ function i(t) {
418
+ if (typeof document > "u") return;
419
+ const e = "hep-cr-prism-styles", a = document.getElementById(e), r = t === "dark" ? `
2539
420
  /* 默认代码颜色 */
2540
421
  .hep-cr-editor .hep-cr-highlight code,
2541
422
  .hep-cr-editor .hep-cr-highlight pre {
@@ -2621,8 +502,7 @@ const prismDarkTheme = `
2621
502
  .hep-cr-editor .token.console {
2622
503
  color: #f8f8f2 !important;
2623
504
  }
2624
- `;
2625
- const prismLightTheme = `
505
+ ` : `
2626
506
  /* 默认代码颜色 */
2627
507
  .hep-cr-editor .hep-cr-highlight code,
2628
508
  .hep-cr-editor .hep-cr-highlight pre {
@@ -2700,718 +580,153 @@ const prismLightTheme = `
2700
580
  color: #333 !important;
2701
581
  }
2702
582
  `;
2703
- const _hoisted_1$2 = ["innerHTML"];
2704
- const _hoisted_2$2 = ["value", "disabled"];
2705
- const CHANGE_DEBOUNCE_MS = 500;
2706
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2707
- __name: "CodeEditor",
2708
- props: {
2709
- modelValue: {},
2710
- language: {},
2711
- theme: { default: "dark" },
2712
- disabled: { type: Boolean, default: false }
2713
- },
2714
- emits: ["update:modelValue", "change"],
2715
- setup(__props, { emit: __emit }) {
2716
- useCssVars((_ctx) => ({
2717
- "v2b19bab6": editorBackground.value
2718
- }));
2719
- if (typeof window !== "undefined") {
2720
- window.Prism = Prism$1;
2721
- }
2722
- function loadPrismTheme(theme) {
2723
- if (typeof document === "undefined") return;
2724
- const styleId = "hep-cr-prism-styles";
2725
- const oldStyleEl = document.getElementById(styleId);
2726
- const themeContent = theme === "dark" ? prismDarkTheme : prismLightTheme;
2727
- if (oldStyleEl) {
2728
- oldStyleEl.remove();
2729
- }
2730
- const styleEl = document.createElement("style");
2731
- styleEl.id = styleId;
2732
- styleEl.textContent = themeContent;
2733
- document.head.appendChild(styleEl);
2734
- }
2735
- const props = __props;
2736
- const emit = __emit;
2737
- const codeRef = ref(null);
2738
- const highlightRef = ref(null);
2739
- let changeTimer = null;
2740
- function emitChange(value) {
2741
- if (changeTimer) {
2742
- clearTimeout(changeTimer);
2743
- }
2744
- changeTimer = setTimeout(() => {
2745
- emit("change", value);
2746
- }, CHANGE_DEBOUNCE_MS);
2747
- }
2748
- const languageMap = {
2749
- javascript: "javascript",
2750
- js: "javascript",
2751
- typescript: "typescript",
2752
- ts: "typescript",
2753
- python: "python",
2754
- py: "python",
2755
- java: "java",
2756
- c: "c",
2757
- cpp: "cpp",
2758
- "c++": "cpp",
2759
- csharp: "csharp",
2760
- "c#": "csharp",
2761
- go: "go",
2762
- golang: "go",
2763
- rust: "rust",
2764
- ruby: "ruby",
2765
- rb: "ruby",
2766
- php: "php",
2767
- swift: "swift",
2768
- kotlin: "kotlin",
2769
- kt: "kotlin",
2770
- sql: "sql",
2771
- bash: "bash",
2772
- sh: "bash",
2773
- shell: "bash",
2774
- json: "json",
2775
- yaml: "yaml",
2776
- yml: "yaml",
2777
- markdown: "markdown",
2778
- md: "markdown"
2779
- };
2780
- const prismLanguage = computed(() => {
2781
- return languageMap[props.language.toLowerCase()] || "javascript";
2782
- });
2783
- const editorBackground = computed(() => {
2784
- return props.theme === "dark" ? "#1e1e1e" : "#fafafa";
2785
- });
2786
- const highlightedCode = computed(() => {
2787
- try {
2788
- const grammar = Prism$1.languages[prismLanguage.value];
2789
- if (grammar) {
2790
- return Prism$1.highlight(props.modelValue || "", grammar, prismLanguage.value);
2791
- }
2792
- } catch (e) {
2793
- }
2794
- return escapeHtml(props.modelValue || "");
2795
- });
2796
- function escapeHtml(text) {
2797
- const div = document.createElement("div");
2798
- div.textContent = text;
2799
- return div.innerHTML;
2800
- }
2801
- function handleInput(e) {
2802
- const target = e.target;
2803
- emit("update:modelValue", target.value);
2804
- emitChange(target.value);
2805
- }
2806
- function handleScroll() {
2807
- if (codeRef.value && highlightRef.value) {
2808
- highlightRef.value.scrollTop = codeRef.value.scrollTop;
2809
- highlightRef.value.scrollLeft = codeRef.value.scrollLeft;
2810
- }
2811
- }
2812
- function handleKeydown(e) {
2813
- if (e.key === "Tab") {
2814
- e.preventDefault();
2815
- const target = e.target;
2816
- const start = target.selectionStart;
2817
- const end = target.selectionEnd;
2818
- const value = target.value;
2819
- target.value = value.substring(0, start) + " " + value.substring(end);
2820
- target.selectionStart = target.selectionEnd = start + 2;
2821
- emit("update:modelValue", target.value);
2822
- emitChange(target.value);
2823
- }
2824
- }
2825
- onMounted(() => {
2826
- loadPrismTheme(props.theme);
2827
- });
2828
- watch(() => props.theme, (newTheme) => {
2829
- loadPrismTheme(newTheme);
2830
- });
2831
- onUnmounted(() => {
2832
- if (changeTimer) {
2833
- clearTimeout(changeTimer);
2834
- }
2835
- });
2836
- return (_ctx, _cache) => {
2837
- return openBlock(), createElementBlock("div", {
2838
- class: normalizeClass(["hep-cr-editor", `hep-cr-theme-${__props.theme}`])
2839
- }, [
2840
- createElementVNode("pre", {
2841
- ref_key: "highlightRef",
2842
- ref: highlightRef,
2843
- class: normalizeClass(["hep-cr-highlight", [`language-${prismLanguage.value}`, `hep-cr-prism-${__props.theme}`]]),
2844
- "aria-hidden": "true"
2845
- }, [
2846
- createElementVNode("code", { innerHTML: highlightedCode.value }, null, 8, _hoisted_1$2)
2847
- ], 2),
2848
- createElementVNode("textarea", {
2849
- ref_key: "codeRef",
2850
- ref: codeRef,
2851
- class: "hep-cr-input",
2852
- value: __props.modelValue,
2853
- disabled: __props.disabled,
2854
- onInput: handleInput,
2855
- onScroll: handleScroll,
2856
- onKeydown: handleKeydown,
2857
- spellcheck: "false",
2858
- placeholder: "Write your code here..."
2859
- }, null, 40, _hoisted_2$2)
2860
- ], 2);
2861
- };
583
+ a && a.remove();
584
+ const o = document.createElement("style");
585
+ o.id = e, o.textContent = r, document.head.appendChild(o);
2862
586
  }
2863
- });
2864
- const _export_sfc = (sfc, props) => {
2865
- const target = sfc.__vccOpts || sfc;
2866
- for (const [key, val] of props) {
2867
- target[key] = val;
587
+ me((t) => ({ v2b19bab6: I.value })), typeof window < "u" && (window.Prism = ae);
588
+ const l = c, f = n, b = O(null), s = O(null);
589
+ let y = null;
590
+ function k(t) {
591
+ y && clearTimeout(y), y = setTimeout(() => {
592
+ f("change", t);
593
+ }, 500);
2868
594
  }
2869
- return target;
2870
- };
2871
- const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a988ca2a"]]);
2872
- const _hoisted_1$1 = { class: "hep-cr-header" };
2873
- const _hoisted_2$1 = { class: "hep-cr-controls" };
2874
- const _hoisted_3$1 = ["disabled"];
2875
- const _hoisted_4$1 = {
2876
- key: 0,
2877
- value: ""
2878
- };
2879
- const _hoisted_5 = ["value"];
2880
- const _hoisted_6 = { class: "hep-cr-actions" };
2881
- const _hoisted_7 = ["disabled"];
2882
- const _hoisted_8 = {
2883
- key: 0,
2884
- class: "hep-cr-spinner"
2885
- };
2886
- const _hoisted_9 = {
2887
- key: 1,
2888
- class: "hep-cr-run-icon"
2889
- };
2890
- const _hoisted_10 = ["title"];
2891
- const _hoisted_11 = {
2892
- key: 0,
2893
- width: "16",
2894
- height: "16",
2895
- viewBox: "0 0 24 24",
2896
- fill: "none",
2897
- stroke: "currentColor",
2898
- "stroke-width": "2"
2899
- };
2900
- const _hoisted_12 = {
2901
- key: 1,
2902
- width: "16",
2903
- height: "16",
2904
- viewBox: "0 0 24 24",
2905
- fill: "none",
2906
- stroke: "currentColor",
2907
- "stroke-width": "2"
2908
- };
2909
- const _hoisted_13 = {
2910
- key: 0,
2911
- class: "hep-cr-error"
2912
- };
2913
- const _hoisted_14 = { class: "hep-cr-main" };
2914
- const _hoisted_15 = { class: "hep-cr-panel-header" };
2915
- const _hoisted_16 = { class: "hep-cr-output-actions" };
2916
- const _hoisted_17 = { class: "hep-cr-language-badge" };
2917
- const _hoisted_18 = ["disabled", "title"];
2918
- const _hoisted_19 = {
2919
- key: 0,
2920
- width: "14",
2921
- height: "14",
2922
- viewBox: "0 0 24 24",
2923
- fill: "none",
2924
- stroke: "currentColor",
2925
- "stroke-width": "2"
2926
- };
2927
- const _hoisted_20 = {
2928
- key: 1,
2929
- class: "hep-cr-copied-text"
2930
- };
2931
- const _hoisted_21 = { class: "hep-cr-panel-header" };
2932
- const _hoisted_22 = { class: "hep-cr-output-tabs" };
2933
- const _hoisted_23 = { class: "hep-cr-output-actions" };
2934
- const _hoisted_24 = {
2935
- key: 0,
2936
- class: "hep-cr-execution-time"
2937
- };
2938
- const _hoisted_25 = ["disabled", "title"];
2939
- const _hoisted_26 = {
2940
- key: 0,
2941
- width: "14",
2942
- height: "14",
2943
- viewBox: "0 0 24 24",
2944
- fill: "none",
2945
- stroke: "currentColor",
2946
- "stroke-width": "2"
2947
- };
2948
- const _hoisted_27 = {
2949
- key: 1,
2950
- class: "hep-cr-copied-text"
2951
- };
2952
- const _hoisted_28 = { class: "hep-cr-output-content" };
2953
- const _hoisted_29 = { key: 0 };
2954
- const _hoisted_30 = {
2955
- key: 1,
2956
- class: "hep-cr-stderr"
2957
- };
2958
- const STORAGE_KEY = "hep-cr-default-language";
2959
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2960
- __name: "CodeRunner",
2961
- props: {
2962
- pistonUrl: { default: "/api/piston" },
2963
- language: { default: "javascript" },
2964
- theme: { default: "light" },
2965
- themeColor: { default: "" },
2966
- showLanguageSelector: { type: Boolean, default: true },
2967
- showEditor: { type: Boolean, default: true },
2968
- editable: { type: Boolean, default: true },
2969
- defaultCode: {},
2970
- executorLabel: { default: "运行" }
2971
- },
2972
- emits: ["execute-start", "execute-end", "language-change", "change"],
2973
- setup(__props, { emit: __emit }) {
2974
- const props = __props;
2975
- const themeStyle = computed(() => {
2976
- if (!props.themeColor) return {};
2977
- const isDark = props.theme === "dark";
2978
- const color = props.themeColor;
2979
- const isLightColor = isColorLight(color);
2980
- const textColor = isLightColor ? "#000" : "#fff";
2981
- return {
2982
- "--hep-cr-theme-color": color,
2983
- "--hep-cr-theme-color-hover": isDark ? adjustColorBrightness(color, 20) : adjustColorBrightness(color, -20),
2984
- "--hep-cr-tab-active-color": textColor
2985
- };
2986
- });
2987
- function isColorLight(hex) {
2988
- const num = parseInt(hex.replace("#", ""), 16);
2989
- const r = num >> 16 & 255;
2990
- const g = num >> 8 & 255;
2991
- const b = num & 255;
2992
- const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
2993
- return luminance > 0.5;
2994
- }
2995
- function adjustColorBrightness(hex, percent) {
2996
- const num = parseInt(hex.replace("#", ""), 16);
2997
- const amt = Math.round(2.55 * percent);
2998
- const R = Math.min(255, Math.max(0, (num >> 16) + amt));
2999
- const G = Math.min(255, Math.max(0, (num >> 8 & 255) + amt));
3000
- const B = Math.min(255, Math.max(0, (num & 255) + amt));
3001
- return "#" + (16777216 + R * 65536 + G * 256 + B).toString(16).slice(1);
3002
- }
3003
- const emit = __emit;
3004
- const runtimes = ref([]);
3005
- const currentLanguage = ref(getStoredLanguage());
3006
- const currentTheme = ref(props.theme);
3007
- const code = ref("");
3008
- const output = ref("");
3009
- const stderr = ref("");
3010
- const isRunning = ref(false);
3011
- const executionTime = ref(null);
3012
- const activeTab = ref("stdout");
3013
- const error = ref(null);
3014
- const runtimesLoading = ref(false);
3015
- const editorWidth = ref(60);
3016
- function getStoredLanguage() {
3017
- if (typeof window === "undefined") return props.language;
3018
- return localStorage.getItem(STORAGE_KEY) || props.language;
3019
- }
3020
- function toggleTheme() {
3021
- currentTheme.value = currentTheme.value === "light" ? "dark" : "light";
595
+ const d = { javascript: "javascript", js: "javascript", typescript: "typescript", ts: "typescript", python: "python", py: "python", java: "java", c: "c", cpp: "cpp", "c++": "cpp", csharp: "csharp", "c#": "csharp", go: "go", golang: "go", rust: "rust", ruby: "ruby", rb: "ruby", php: "php", swift: "swift", kotlin: "kotlin", kt: "kotlin", sql: "sql", bash: "bash", sh: "bash", shell: "bash", json: "json", yaml: "yaml", yml: "yaml", markdown: "markdown", md: "markdown" }, S = D(() => d[l.language.toLowerCase()] || "javascript"), I = D(() => l.theme === "dark" ? "#1e1e1e" : "#fafafa"), x = D(() => {
596
+ try {
597
+ const t = ae.languages[S.value];
598
+ if (t) return ae.highlight(l.modelValue || "", t, S.value);
599
+ } catch {
600
+ }
601
+ return function(t) {
602
+ const e = document.createElement("div");
603
+ return e.textContent = t, e.innerHTML;
604
+ }(l.modelValue || "");
605
+ });
606
+ function L(t) {
607
+ const e = t.target;
608
+ f("update:modelValue", e.value), k(e.value);
609
+ }
610
+ function R() {
611
+ b.value && s.value && (s.value.scrollTop = b.value.scrollTop, s.value.scrollLeft = b.value.scrollLeft);
612
+ }
613
+ function F(t) {
614
+ if (t.key === "Tab") {
615
+ t.preventDefault();
616
+ const e = t.target, a = e.selectionStart, r = e.selectionEnd, o = e.value;
617
+ e.value = o.substring(0, a) + " " + o.substring(r), e.selectionStart = e.selectionEnd = a + 2, f("update:modelValue", e.value), k(e.value);
3022
618
  }
3023
- const client = computed(
3024
- () => new W({ pistonUrl: props.pistonUrl })
3025
- );
3026
- const languageOptions = computed(() => {
3027
- return runtimes.value.map((r) => ({
3028
- value: `${r.language}:${r.version}`,
3029
- label: `${r.language.charAt(0).toUpperCase() + r.language.slice(1)} ${r.version}`
3030
- }));
3031
- });
3032
- const languageName = computed(() => {
3033
- const lang = currentLanguage.value;
3034
- return lang.includes(":") ? lang.split(":")[0] : lang;
3035
- });
3036
- async function loadRuntimes() {
3037
- runtimesLoading.value = true;
3038
- error.value = null;
619
+ }
620
+ return de(() => {
621
+ i(l.theme);
622
+ }), se(() => l.theme, (t) => {
623
+ i(t);
624
+ }), fe(() => {
625
+ y && clearTimeout(y);
626
+ }), (t, e) => (A(), T("div", { class: B(["hep-cr-editor", `hep-cr-theme-${c.theme}`]) }, [v("pre", { ref_key: "highlightRef", ref: s, class: B(["hep-cr-highlight", [`language-${S.value}`, `hep-cr-prism-${c.theme}`]]), "aria-hidden": "true" }, [v("code", { innerHTML: x.value }, null, 8, Ce)], 2), v("textarea", { ref_key: "codeRef", ref: b, class: "hep-cr-input", value: c.modelValue, disabled: c.disabled, onInput: L, onScroll: R, onKeydown: F, spellcheck: "false", placeholder: "Write your code here..." }, null, 40, Pe)], 2));
627
+ } }), [["__scopeId", "data-v-a988ca2a"]]), $e = { class: "hep-cr-header" }, Me = { class: "hep-cr-controls" }, Ue = ["disabled"], Be = { key: 0, value: "" }, He = ["value"], Ge = { class: "hep-cr-actions" }, je = ["disabled"], ze = { key: 0, class: "hep-cr-spinner" }, We = { key: 1, class: "hep-cr-run-icon" }, Ve = ["title"], Ye = { key: 0, width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, Xe = { key: 1, width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, Ze = { key: 0, class: "hep-cr-error" }, Ke = { class: "hep-cr-main" }, qe = { class: "hep-cr-panel-header" }, Je = { class: "hep-cr-output-actions" }, Qe = { class: "hep-cr-language-badge" }, et = ["disabled", "title"], tt = { key: 0, width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, nt = { key: 1, class: "hep-cr-copied-text" }, at = { class: "hep-cr-panel-header" }, rt = { class: "hep-cr-output-tabs" }, ot = { class: "hep-cr-output-actions" }, st = { key: 0, class: "hep-cr-execution-time" }, it = ["disabled", "title"], lt = { key: 0, width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, ct = { key: 1, class: "hep-cr-copied-text" }, ut = { class: "hep-cr-output-content" }, dt = { key: 0 }, pt = { key: 1, class: "hep-cr-stderr" }, ue = "hep-cr-default-language", q = ge(oe({ __name: "CodeRunner", props: { pistonUrl: { default: "/api/piston" }, language: { default: "javascript" }, theme: { default: "light" }, themeColor: { default: "" }, showLanguageSelector: { type: Boolean, default: !0 }, showEditor: { type: Boolean, default: !0 }, editable: { type: Boolean, default: !0 }, defaultCode: {}, executorLabel: { default: "运行" } }, emits: ["execute-start", "execute-end", "language-change", "change"], setup(c, { emit: n }) {
628
+ const i = c, l = D(() => {
629
+ if (!i.themeColor) return {};
630
+ const g = i.theme === "dark", h = i.themeColor, E = function(C) {
631
+ const $ = parseInt(C.replace("#", ""), 16);
632
+ return (0.299 * ($ >> 16 & 255) + 0.587 * ($ >> 8 & 255) + 0.114 * (255 & $)) / 255 > 0.5;
633
+ }(h) ? "#000" : "#fff";
634
+ return { "--hep-cr-theme-color": h, "--hep-cr-theme-color-hover": f(h, g ? 20 : -20), "--hep-cr-tab-active-color": E };
635
+ });
636
+ function f(g, h) {
637
+ const E = parseInt(g.replace("#", ""), 16), C = Math.round(2.55 * h);
638
+ return "#" + (16777216 + 65536 * Math.min(255, Math.max(0, (E >> 16) + C)) + 256 * Math.min(255, Math.max(0, (E >> 8 & 255) + C)) + Math.min(255, Math.max(0, (255 & E) + C))).toString(16).slice(1);
639
+ }
640
+ const b = n, s = O([]), y = O(typeof window > "u" ? i.language : localStorage.getItem(ue) || i.language), k = O(i.theme), d = O(""), S = O(""), I = O(""), x = O(!1), L = O(null), R = O("stdout"), F = O(null), t = O(!1), e = O(60);
641
+ function a() {
642
+ k.value = k.value === "light" ? "dark" : "light";
643
+ }
644
+ const r = D(() => new Ne({ pistonUrl: i.pistonUrl })), o = D(() => s.value.map((g) => ({ value: `${g.language}:${g.version}`, label: `${g.language.charAt(0).toUpperCase() + g.language.slice(1)} ${g.version}` }))), u = D(() => {
645
+ const g = y.value;
646
+ return g.includes(":") ? g.split(":")[0] : g;
647
+ });
648
+ async function p() {
649
+ if (!x.value) {
650
+ x.value = !0, S.value = "", I.value = "", L.value = null, F.value = null, R.value = "stdout", b("execute-start");
3039
651
  try {
3040
- runtimes.value = await client.value.getRuntimes();
3041
- const langName = currentLanguage.value.split(":")[0];
3042
- const defaultRuntime = runtimes.value.find((r) => r.language === langName);
3043
- if (defaultRuntime && !currentLanguage.value.includes(":")) {
3044
- currentLanguage.value = `${langName}:${defaultRuntime.version}`;
3045
- }
3046
- if (!code.value) {
3047
- code.value = props.defaultCode || j(langName);
3048
- emit("change", code.value);
3049
- }
3050
- emit("language-change", langName, code.value);
3051
- } catch (e) {
3052
- error.value = e instanceof Error ? e.message : "Failed to load runtimes";
652
+ const g = await r.value.execute(u.value, d.value);
653
+ S.value = g.output, I.value = g.stderr, L.value = g.executionTime || null, R.value = g.stderr ? "stderr" : "stdout", b("execute-end", g);
654
+ } catch (g) {
655
+ F.value = g instanceof Error ? g.message : "Execution failed", b("execute-end", { success: !1, output: "", stderr: F.value, code: -1 });
3053
656
  } finally {
3054
- runtimesLoading.value = false;
657
+ x.value = !1;
3055
658
  }
3056
659
  }
3057
- watch(currentLanguage, (newLang) => {
3058
- const langName = newLang.includes(":") ? newLang.split(":")[0] : newLang;
3059
- const newCode = j(langName);
3060
- code.value = newCode;
3061
- emit("language-change", langName, newCode);
3062
- if (typeof window !== "undefined") {
3063
- localStorage.setItem(STORAGE_KEY, newLang);
3064
- }
3065
- });
3066
- async function execute() {
3067
- if (isRunning.value) return;
3068
- isRunning.value = true;
3069
- output.value = "";
3070
- stderr.value = "";
3071
- executionTime.value = null;
3072
- error.value = null;
3073
- activeTab.value = "stdout";
3074
- emit("execute-start");
660
+ }
661
+ se(y, (g) => {
662
+ const h = g.includes(":") ? g.split(":")[0] : g, E = Z(h);
663
+ d.value = E, b("language-change", h, E), typeof window < "u" && localStorage.setItem(ue, g);
664
+ });
665
+ const m = O(!1), w = O(!1);
666
+ async function _() {
667
+ await navigator.clipboard.writeText(d.value), m.value = !0, setTimeout(() => {
668
+ m.value = !1;
669
+ }, 2e3);
670
+ }
671
+ async function H() {
672
+ const g = R.value === "stdout" ? S.value : I.value;
673
+ await navigator.clipboard.writeText(g), w.value = !0, setTimeout(() => {
674
+ w.value = !1;
675
+ }, 2e3);
676
+ }
677
+ function W() {
678
+ d.value = Z(u.value);
679
+ }
680
+ let G = !1;
681
+ function J(g) {
682
+ G = !0, document.addEventListener("mousemove", V), document.addEventListener("mouseup", j), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
683
+ }
684
+ function V(g) {
685
+ if (!G) return;
686
+ const h = document.querySelector(".hep-cr-main");
687
+ if (!h) return;
688
+ const E = h.getBoundingClientRect(), C = (g.clientX - E.left) / E.width * 100;
689
+ e.value = Math.max(20, Math.min(80, C));
690
+ }
691
+ function j() {
692
+ G = !1, document.removeEventListener("mousemove", V), document.removeEventListener("mouseup", j), document.body.style.cursor = "", document.body.style.userSelect = "";
693
+ }
694
+ de(async () => {
695
+ await async function() {
696
+ t.value = !0, F.value = null;
3075
697
  try {
3076
- const result = await client.value.execute(languageName.value, code.value);
3077
- output.value = result.output;
3078
- stderr.value = result.stderr;
3079
- executionTime.value = result.executionTime || null;
3080
- activeTab.value = result.stderr ? "stderr" : "stdout";
3081
- emit("execute-end", result);
3082
- } catch (e) {
3083
- error.value = e instanceof Error ? e.message : "Execution failed";
3084
- emit("execute-end", {
3085
- success: false,
3086
- output: "",
3087
- stderr: error.value,
3088
- code: -1
3089
- });
698
+ s.value = await r.value.getRuntimes();
699
+ const g = y.value.split(":")[0], h = s.value.find((E) => E.language === g);
700
+ h && !y.value.includes(":") && (y.value = `${g}:${h.version}`), d.value || (d.value = i.defaultCode || Z(g), b("change", d.value)), b("language-change", g, d.value);
701
+ } catch (g) {
702
+ F.value = g instanceof Error ? g.message : "Failed to load runtimes";
3090
703
  } finally {
3091
- isRunning.value = false;
704
+ t.value = !1;
3092
705
  }
3093
- }
3094
- const copiedEditor = ref(false);
3095
- const copiedOutput = ref(false);
3096
- async function copyCode() {
3097
- await navigator.clipboard.writeText(code.value);
3098
- copiedEditor.value = true;
3099
- setTimeout(() => {
3100
- copiedEditor.value = false;
3101
- }, 2e3);
3102
- }
3103
- async function copyOutput() {
3104
- const text = activeTab.value === "stdout" ? output.value : stderr.value;
3105
- await navigator.clipboard.writeText(text);
3106
- copiedOutput.value = true;
3107
- setTimeout(() => {
3108
- copiedOutput.value = false;
3109
- }, 2e3);
3110
- }
3111
- function resetCode() {
3112
- code.value = j(languageName.value);
3113
- }
3114
- let isDragging = false;
3115
- function startDrag(e) {
3116
- isDragging = true;
3117
- document.addEventListener("mousemove", onDrag);
3118
- document.addEventListener("mouseup", stopDrag);
3119
- document.body.style.cursor = "col-resize";
3120
- document.body.style.userSelect = "none";
3121
- }
3122
- function onDrag(e) {
3123
- if (!isDragging) return;
3124
- const container = document.querySelector(
3125
- ".hep-cr-main"
3126
- );
3127
- if (!container) return;
3128
- const rect = container.getBoundingClientRect();
3129
- const newWidth = (e.clientX - rect.left) / rect.width * 100;
3130
- editorWidth.value = Math.max(20, Math.min(80, newWidth));
3131
- }
3132
- function stopDrag() {
3133
- isDragging = false;
3134
- document.removeEventListener("mousemove", onDrag);
3135
- document.removeEventListener("mouseup", stopDrag);
3136
- document.body.style.cursor = "";
3137
- document.body.style.userSelect = "";
3138
- }
3139
- onMounted(async () => {
3140
- await loadRuntimes();
3141
- if (!code.value) {
3142
- code.value = props.defaultCode || j(currentLanguage.value);
3143
- emit("change", code.value);
3144
- }
3145
- });
3146
- const themeClass = computed(() => `hep-cr-runner-${currentTheme.value}`);
3147
- return (_ctx, _cache) => {
3148
- return openBlock(), createElementBlock("div", {
3149
- class: normalizeClass(["hep-cr-runner", themeClass.value]),
3150
- style: normalizeStyle(themeStyle.value)
3151
- }, [
3152
- createElementVNode("div", _hoisted_1$1, [
3153
- createElementVNode("div", _hoisted_2$1, [
3154
- __props.showLanguageSelector ? withDirectives((openBlock(), createElementBlock("select", {
3155
- key: 0,
3156
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => currentLanguage.value = $event),
3157
- class: "hep-cr-language-select",
3158
- disabled: isRunning.value
3159
- }, [
3160
- runtimesLoading.value ? (openBlock(), createElementBlock("option", _hoisted_4$1, "加载中...")) : createCommentVNode("", true),
3161
- (openBlock(true), createElementBlock(Fragment, null, renderList(languageOptions.value, (option) => {
3162
- return openBlock(), createElementBlock("option", {
3163
- key: option.value,
3164
- value: option.value
3165
- }, toDisplayString(option.label), 9, _hoisted_5);
3166
- }), 128))
3167
- ], 8, _hoisted_3$1)), [
3168
- [vModelSelect, currentLanguage.value]
3169
- ]) : createCommentVNode("", true)
3170
- ]),
3171
- createElementVNode("div", _hoisted_6, [
3172
- createElementVNode("button", {
3173
- class: "hep-cr-btn hep-cr-btn-run",
3174
- disabled: isRunning.value || runtimesLoading.value,
3175
- onClick: execute
3176
- }, [
3177
- isRunning.value ? (openBlock(), createElementBlock("span", _hoisted_8)) : (openBlock(), createElementBlock("span", _hoisted_9, "▶")),
3178
- createTextVNode(" " + toDisplayString(isRunning.value ? "运行中..." : __props.executorLabel), 1)
3179
- ], 8, _hoisted_7),
3180
- __props.showEditor && __props.editable ? (openBlock(), createElementBlock("button", {
3181
- key: 0,
3182
- class: "hep-cr-btn hep-cr-btn-reset",
3183
- onClick: resetCode
3184
- }, " 重置 ")) : createCommentVNode("", true),
3185
- createElementVNode("button", {
3186
- class: "hep-cr-btn hep-cr-btn-theme",
3187
- onClick: toggleTheme,
3188
- title: currentTheme.value === "light" ? "Switch to dark mode" : "Switch to light mode"
3189
- }, [
3190
- currentTheme.value === "light" ? (openBlock(), createElementBlock("svg", _hoisted_11, [..._cache[5] || (_cache[5] = [
3191
- createElementVNode("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }, null, -1)
3192
- ])])) : (openBlock(), createElementBlock("svg", _hoisted_12, [..._cache[6] || (_cache[6] = [
3193
- createStaticVNode('<circle cx="12" cy="12" r="5" data-v-41977f3b></circle><line x1="12" y1="1" x2="12" y2="3" data-v-41977f3b></line><line x1="12" y1="21" x2="12" y2="23" data-v-41977f3b></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64" data-v-41977f3b></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78" data-v-41977f3b></line><line x1="1" y1="12" x2="3" y2="12" data-v-41977f3b></line><line x1="21" y1="12" x2="23" y2="12" data-v-41977f3b></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36" data-v-41977f3b></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22" data-v-41977f3b></line>', 9)
3194
- ])]))
3195
- ], 8, _hoisted_10)
3196
- ])
3197
- ]),
3198
- error.value ? (openBlock(), createElementBlock("div", _hoisted_13, toDisplayString(error.value), 1)) : createCommentVNode("", true),
3199
- createElementVNode("div", _hoisted_14, [
3200
- __props.showEditor ? (openBlock(), createElementBlock("div", {
3201
- key: 0,
3202
- class: "hep-cr-editor-panel",
3203
- style: normalizeStyle({ width: editorWidth.value + "%" })
3204
- }, [
3205
- createElementVNode("div", _hoisted_15, [
3206
- _cache[8] || (_cache[8] = createElementVNode("span", { class: "hep-cr-panel-title" }, "编辑器", -1)),
3207
- createElementVNode("div", _hoisted_16, [
3208
- createElementVNode("span", _hoisted_17, toDisplayString(languageName.value), 1),
3209
- createElementVNode("button", {
3210
- class: normalizeClass(["hep-cr-btn-icon", { "hep-cr-btn-copied": copiedEditor.value }]),
3211
- disabled: copiedEditor.value,
3212
- onClick: copyCode,
3213
- title: copiedEditor.value ? "已复制" : "复制"
3214
- }, [
3215
- !copiedEditor.value ? (openBlock(), createElementBlock("svg", _hoisted_19, [..._cache[7] || (_cache[7] = [
3216
- createElementVNode("rect", {
3217
- x: "9",
3218
- y: "9",
3219
- width: "13",
3220
- height: "13",
3221
- rx: "2",
3222
- ry: "2"
3223
- }, null, -1),
3224
- createElementVNode("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }, null, -1)
3225
- ])])) : (openBlock(), createElementBlock("span", _hoisted_20, "已复制"))
3226
- ], 10, _hoisted_18)
3227
- ])
3228
- ]),
3229
- createVNode(CodeEditor, {
3230
- modelValue: code.value,
3231
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => code.value = $event),
3232
- language: languageName.value,
3233
- theme: currentTheme.value,
3234
- disabled: !__props.editable || isRunning.value,
3235
- onChange: _cache[2] || (_cache[2] = (val) => emit("change", val))
3236
- }, null, 8, ["modelValue", "language", "theme", "disabled"])
3237
- ], 4)) : createCommentVNode("", true),
3238
- __props.showEditor ? (openBlock(), createElementBlock("div", {
3239
- key: 1,
3240
- class: "hep-cr-resize-handle",
3241
- onMousedown: startDrag
3242
- }, [..._cache[9] || (_cache[9] = [
3243
- createElementVNode("div", { class: "hep-cr-resize-line" }, null, -1)
3244
- ])], 32)) : createCommentVNode("", true),
3245
- createElementVNode("div", {
3246
- class: "hep-cr-output-panel",
3247
- style: normalizeStyle({ width: __props.showEditor ? 100 - editorWidth.value + "%" : "100%" })
3248
- }, [
3249
- createElementVNode("div", _hoisted_21, [
3250
- createElementVNode("div", _hoisted_22, [
3251
- createElementVNode("button", {
3252
- class: normalizeClass(["hep-cr-tab", { active: activeTab.value === "stdout" }]),
3253
- onClick: _cache[3] || (_cache[3] = ($event) => activeTab.value = "stdout")
3254
- }, " 输出 ", 2),
3255
- stderr.value ? (openBlock(), createElementBlock("button", {
3256
- key: 0,
3257
- class: normalizeClass(["hep-cr-tab", "hep-cr-tab-error", { active: activeTab.value === "stderr" }]),
3258
- onClick: _cache[4] || (_cache[4] = ($event) => activeTab.value = "stderr")
3259
- }, " 错误 ", 2)) : createCommentVNode("", true)
3260
- ]),
3261
- createElementVNode("div", _hoisted_23, [
3262
- executionTime.value !== null ? (openBlock(), createElementBlock("span", _hoisted_24, toDisplayString(executionTime.value) + "ms ", 1)) : createCommentVNode("", true),
3263
- createElementVNode("button", {
3264
- class: normalizeClass(["hep-cr-btn-icon", { "hep-cr-btn-copied": copiedOutput.value }]),
3265
- disabled: copiedOutput.value,
3266
- onClick: copyOutput,
3267
- title: copiedOutput.value ? "已复制" : "复制"
3268
- }, [
3269
- !copiedOutput.value ? (openBlock(), createElementBlock("svg", _hoisted_26, [..._cache[10] || (_cache[10] = [
3270
- createElementVNode("rect", {
3271
- x: "9",
3272
- y: "9",
3273
- width: "13",
3274
- height: "13",
3275
- rx: "2",
3276
- ry: "2"
3277
- }, null, -1),
3278
- createElementVNode("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }, null, -1)
3279
- ])])) : (openBlock(), createElementBlock("span", _hoisted_27, "已复制"))
3280
- ], 10, _hoisted_25)
3281
- ])
3282
- ]),
3283
- createElementVNode("div", _hoisted_28, [
3284
- activeTab.value === "stdout" ? (openBlock(), createElementBlock("pre", _hoisted_29, toDisplayString(isRunning.value ? "代码执行中..." : output.value || '点击"运行"执行代码'), 1)) : (openBlock(), createElementBlock("pre", _hoisted_30, toDisplayString(stderr.value), 1))
3285
- ])
3286
- ], 4)
3287
- ])
3288
- ], 6);
3289
- };
3290
- }
3291
- });
3292
- const CodeRunner = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-41977f3b"]]);
3293
- const _hoisted_1 = { class: "hep-cr-dialog-header" };
3294
- const _hoisted_2 = { class: "hep-cr-dialog-title" };
3295
- const _hoisted_3 = { class: "hep-cr-dialog-body" };
3296
- const _hoisted_4 = {
3297
- key: 0,
3298
- class: "hep-cr-dialog-footer"
3299
- };
3300
- const _sfc_main = /* @__PURE__ */ defineComponent({
3301
- __name: "CodeRunnerDialog",
3302
- props: {
3303
- modelValue: { type: Boolean, default: false },
3304
- title: { default: "代码执行器" },
3305
- width: { default: 800 },
3306
- pistonUrl: { default: "/api/piston" },
3307
- language: { default: "javascript" },
3308
- theme: { default: "light" },
3309
- themeColor: { default: "" },
3310
- showLanguageSelector: { type: Boolean, default: true },
3311
- showEditor: { type: Boolean, default: true },
3312
- editable: { type: Boolean, default: true },
3313
- defaultCode: {},
3314
- executorLabel: { default: "运行" }
3315
- },
3316
- emits: ["update:modelValue", "close", "change"],
3317
- setup(__props, { expose: __expose, emit: __emit }) {
3318
- const props = __props;
3319
- const emit = __emit;
3320
- const localVisible = ref(props.modelValue);
3321
- const isVisible = computed(() => {
3322
- if (props.modelValue !== void 0) {
3323
- return props.modelValue;
3324
- }
3325
- return localVisible.value;
3326
- });
3327
- watch(
3328
- () => props.modelValue,
3329
- (val) => {
3330
- if (val !== void 0) {
3331
- localVisible.value = val;
3332
- }
3333
- }
3334
- );
3335
- function close() {
3336
- localVisible.value = false;
3337
- emit("update:modelValue", false);
3338
- emit("close");
3339
- }
3340
- function handleOverlayClick(e) {
3341
- if (e.target === e.currentTarget) {
3342
- close();
3343
- }
3344
- }
3345
- __expose({
3346
- close
3347
- });
3348
- return (_ctx, _cache) => {
3349
- return openBlock(), createBlock(Teleport, { to: "body" }, [
3350
- createVNode(Transition, { name: "hep-cr-dialog-fade" }, {
3351
- default: withCtx(() => [
3352
- isVisible.value ? (openBlock(), createElementBlock("div", {
3353
- key: 0,
3354
- class: "hep-cr-dialog-overlay",
3355
- onClick: handleOverlayClick
3356
- }, [
3357
- createElementVNode("div", {
3358
- class: "hep-cr-dialog-container",
3359
- style: normalizeStyle({ width: typeof __props.width === "number" ? __props.width + "px" : __props.width })
3360
- }, [
3361
- createElementVNode("div", _hoisted_1, [
3362
- createElementVNode("h3", _hoisted_2, toDisplayString(__props.title), 1),
3363
- createElementVNode("button", {
3364
- class: "hep-cr-dialog-close",
3365
- onClick: close
3366
- }, [..._cache[0] || (_cache[0] = [
3367
- createElementVNode("svg", {
3368
- width: "16",
3369
- height: "16",
3370
- viewBox: "0 0 24 24",
3371
- fill: "none",
3372
- stroke: "currentColor",
3373
- "stroke-width": "2"
3374
- }, [
3375
- createElementVNode("line", {
3376
- x1: "18",
3377
- y1: "6",
3378
- x2: "6",
3379
- y2: "18"
3380
- }),
3381
- createElementVNode("line", {
3382
- x1: "6",
3383
- y1: "6",
3384
- x2: "18",
3385
- y2: "18"
3386
- })
3387
- ], -1)
3388
- ])])
3389
- ]),
3390
- createElementVNode("div", _hoisted_3, [
3391
- createVNode(CodeRunner, mergeProps(_ctx.$attrs, toHandlers(_ctx.$attrs)), null, 16)
3392
- ]),
3393
- _ctx.$slots.footer ? (openBlock(), createElementBlock("div", _hoisted_4, [
3394
- renderSlot(_ctx.$slots, "footer", { close })
3395
- ])) : createCommentVNode("", true)
3396
- ], 4)
3397
- ])) : createCommentVNode("", true)
3398
- ]),
3399
- _: 3
3400
- })
3401
- ]);
3402
- };
706
+ }(), d.value || (d.value = i.defaultCode || Z(y.value), b("change", d.value));
707
+ });
708
+ const N = D(() => `hep-cr-runner-${k.value}`);
709
+ return (g, h) => (A(), T("div", { class: B(["hep-cr-runner", N.value]), style: K(l.value) }, [v("div", $e, [v("div", Me, [c.showLanguageSelector ? be((A(), T("select", { key: 0, "onUpdate:modelValue": h[0] || (h[0] = (E) => y.value = E), class: "hep-cr-language-select", disabled: x.value }, [t.value ? (A(), T("option", Be, "加载中...")) : P("", !0), (A(!0), T(Ee, null, ve(o.value, (E) => (A(), T("option", { key: E.value, value: E.value }, M(E.label), 9, He))), 128))], 8, Ue)), [[ye, y.value]]) : P("", !0)]), v("div", Ge, [v("button", { class: "hep-cr-btn hep-cr-btn-run", disabled: x.value || t.value, onClick: p }, [x.value ? (A(), T("span", ze)) : (A(), T("span", We, "▶")), ke(" " + M(x.value ? "运行中..." : c.executorLabel), 1)], 8, je), c.showEditor && c.editable ? (A(), T("button", { key: 0, class: "hep-cr-btn hep-cr-btn-reset", onClick: W }, " 重置 ")) : P("", !0), v("button", { class: "hep-cr-btn hep-cr-btn-theme", onClick: a, title: k.value === "light" ? "Switch to dark mode" : "Switch to light mode" }, [k.value === "light" ? (A(), T("svg", Ye, [...h[5] || (h[5] = [v("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }, null, -1)])])) : (A(), T("svg", Xe, [...h[6] || (h[6] = [Se('<circle cx="12" cy="12" r="5" data-v-41977f3b></circle><line x1="12" y1="1" x2="12" y2="3" data-v-41977f3b></line><line x1="12" y1="21" x2="12" y2="23" data-v-41977f3b></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64" data-v-41977f3b></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78" data-v-41977f3b></line><line x1="1" y1="12" x2="3" y2="12" data-v-41977f3b></line><line x1="21" y1="12" x2="23" y2="12" data-v-41977f3b></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36" data-v-41977f3b></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22" data-v-41977f3b></line>', 9)])]))], 8, Ve)])]), F.value ? (A(), T("div", Ze, M(F.value), 1)) : P("", !0), v("div", Ke, [c.showEditor ? (A(), T("div", { key: 0, class: "hep-cr-editor-panel", style: K({ width: e.value + "%" }) }, [v("div", qe, [h[8] || (h[8] = v("span", { class: "hep-cr-panel-title" }, "编辑器", -1)), v("div", Je, [v("span", Qe, M(u.value), 1), v("button", { class: B(["hep-cr-btn-icon", { "hep-cr-btn-copied": m.value }]), disabled: m.value, onClick: _, title: m.value ? "已复制" : "复制" }, [m.value ? (A(), T("span", nt, "已复制")) : (A(), T("svg", tt, [...h[7] || (h[7] = [v("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }, null, -1), v("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }, null, -1)])]))], 10, et)])]), re(De, { modelValue: d.value, "onUpdate:modelValue": h[1] || (h[1] = (E) => d.value = E), language: u.value, theme: k.value, disabled: !c.editable || x.value, onChange: h[2] || (h[2] = (E) => b("change", E)) }, null, 8, ["modelValue", "language", "theme", "disabled"])], 4)) : P("", !0), c.showEditor ? (A(), T("div", { key: 1, class: "hep-cr-resize-handle", onMousedown: J }, [...h[9] || (h[9] = [v("div", { class: "hep-cr-resize-line" }, null, -1)])], 32)) : P("", !0), v("div", { class: "hep-cr-output-panel", style: K({ width: c.showEditor ? 100 - e.value + "%" : "100%" }) }, [v("div", at, [v("div", rt, [v("button", { class: B(["hep-cr-tab", { active: R.value === "stdout" }]), onClick: h[3] || (h[3] = (E) => R.value = "stdout") }, " 输出 ", 2), I.value ? (A(), T("button", { key: 0, class: B(["hep-cr-tab", "hep-cr-tab-error", { active: R.value === "stderr" }]), onClick: h[4] || (h[4] = (E) => R.value = "stderr") }, " 错误 ", 2)) : P("", !0)]), v("div", ot, [L.value !== null ? (A(), T("span", st, M(L.value) + "ms ", 1)) : P("", !0), v("button", { class: B(["hep-cr-btn-icon", { "hep-cr-btn-copied": w.value }]), disabled: w.value, onClick: H, title: w.value ? "已复制" : "复制" }, [w.value ? (A(), T("span", ct, "已复制")) : (A(), T("svg", lt, [...h[10] || (h[10] = [v("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }, null, -1), v("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }, null, -1)])]))], 10, it)])]), v("div", ut, [R.value === "stdout" ? (A(), T("pre", dt, M(x.value ? "代码执行中..." : S.value || '点击"运行"执行代码'), 1)) : (A(), T("pre", pt, M(I.value), 1))])], 4)])], 6));
710
+ } }), [["__scopeId", "data-v-41977f3b"]]), gt = { class: "hep-cr-dialog-header" }, ht = { class: "hep-cr-dialog-title" }, mt = { class: "hep-cr-dialog-body" }, ft = { key: 0, class: "hep-cr-dialog-footer" }, Et = oe({ __name: "CodeRunnerDialog", props: { modelValue: { type: Boolean, default: !1 }, title: { default: "代码执行器" }, width: { default: 800 }, pistonUrl: { default: "/api/piston" }, language: { default: "javascript" }, theme: { default: "light" }, themeColor: { default: "" }, showLanguageSelector: { type: Boolean, default: !0 }, showEditor: { type: Boolean, default: !0 }, editable: { type: Boolean, default: !0 }, defaultCode: {}, executorLabel: { default: "运行" } }, emits: ["update:modelValue", "close", "change"], setup(c, { expose: n, emit: i }) {
711
+ const l = c, f = i, b = O(l.modelValue), s = D(() => l.modelValue !== void 0 ? l.modelValue : b.value);
712
+ function y() {
713
+ b.value = !1, f("update:modelValue", !1), f("close");
3403
714
  }
3404
- });
3405
- CodeRunner.install = (app) => {
3406
- app.component("CodeRunner", CodeRunner);
3407
- };
3408
- const index = {
3409
- install(app) {
3410
- app.component("CodeRunner", CodeRunner);
715
+ function k(d) {
716
+ d.target === d.currentTarget && y();
3411
717
  }
718
+ return se(() => l.modelValue, (d) => {
719
+ d !== void 0 && (b.value = d);
720
+ }), n({ close: y }), (d, S) => (A(), we(Ae, { to: "body" }, [re(Te, { name: "hep-cr-dialog-fade" }, { default: xe(() => [s.value ? (A(), T("div", { key: 0, class: "hep-cr-dialog-overlay", onClick: k }, [v("div", { class: "hep-cr-dialog-container", style: K({ width: typeof c.width == "number" ? c.width + "px" : c.width }) }, [v("div", gt, [v("h3", ht, M(c.title), 1), v("button", { class: "hep-cr-dialog-close", onClick: y }, [...S[0] || (S[0] = [v("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, [v("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), v("line", { x1: "6", y1: "6", x2: "18", y2: "18" })], -1)])])]), v("div", mt, [re(q, Fe(d.$attrs, Ie(d.$attrs)), null, 16)]), d.$slots.footer ? (A(), T("div", ft, [_e(d.$slots, "footer", { close: y })])) : P("", !0)], 4)])) : P("", !0)]), _: 3 })]));
721
+ } });
722
+ q.install = (c) => {
723
+ c.component("CodeRunner", q);
3412
724
  };
725
+ const vt = { install(c) {
726
+ c.component("CodeRunner", q);
727
+ } };
3413
728
  export {
3414
- CodeRunner,
3415
- _sfc_main as CodeRunnerDialog,
3416
- index as default
729
+ q as CodeRunner,
730
+ Et as CodeRunnerDialog,
731
+ vt as default
3417
732
  };