@bigbinary/neeto-molecules 5.1.19 → 5.1.21

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 (166) hide show
  1. package/dist/FinderModal.js +56 -9
  2. package/dist/FinderModal.js.map +1 -1
  3. package/dist/IpRestriction.js +2 -3175
  4. package/dist/IpRestriction.js.map +1 -1
  5. package/dist/MadeWith.js +3 -74
  6. package/dist/MadeWith.js.map +1 -1
  7. package/dist/NeetoWidget.js +3 -1958
  8. package/dist/NeetoWidget.js.map +1 -1
  9. package/dist/Onboarding.js +3 -400
  10. package/dist/Onboarding.js.map +1 -1
  11. package/dist/chevron-up-B2_LTx_h.js +15 -0
  12. package/dist/chevron-up-B2_LTx_h.js.map +1 -0
  13. package/dist/cjs/FinderModal.js +54 -7
  14. package/dist/cjs/FinderModal.js.map +1 -1
  15. package/dist/cjs/IpRestriction.js +21 -3194
  16. package/dist/cjs/IpRestriction.js.map +1 -1
  17. package/dist/cjs/MadeWith.js +17 -88
  18. package/dist/cjs/MadeWith.js.map +1 -1
  19. package/dist/cjs/NeetoWidget.js +4 -1959
  20. package/dist/cjs/NeetoWidget.js.map +1 -1
  21. package/dist/cjs/Onboarding.js +3 -400
  22. package/dist/cjs/Onboarding.js.map +1 -1
  23. package/dist/cjs/chevron-up-CpzhFWzM.js +17 -0
  24. package/dist/cjs/chevron-up-CpzhFWzM.js.map +1 -0
  25. package/dist/cjs/copy-CerjTcLL.js +20 -0
  26. package/dist/cjs/copy-CerjTcLL.js.map +1 -0
  27. package/dist/cjs/globe-DawgK2Dx.js +21 -0
  28. package/dist/cjs/globe-DawgK2Dx.js.map +1 -0
  29. package/dist/cjs/index-ARGXqXxG.js +78 -0
  30. package/dist/cjs/index-ARGXqXxG.js.map +1 -0
  31. package/dist/cjs/index-BeqE2JWC.js +3180 -0
  32. package/dist/cjs/index-BeqE2JWC.js.map +1 -0
  33. package/dist/cjs/panel-left-close-CLoRPBWH.js +21 -0
  34. package/dist/cjs/panel-left-close-CLoRPBWH.js.map +1 -0
  35. package/dist/cjs/phone-number-Bza7WGZm.js +315 -0
  36. package/dist/cjs/phone-number-Bza7WGZm.js.map +1 -0
  37. package/dist/cjs/prism-tomorrow-BMFuJ5o1.js +1963 -0
  38. package/dist/cjs/prism-tomorrow-BMFuJ5o1.js.map +1 -0
  39. package/dist/cjs/react-confetti-DdGoyZ0y.js +405 -0
  40. package/dist/cjs/react-confetti-DdGoyZ0y.js.map +1 -0
  41. package/dist/cjs/smartphone-ChvEvl-o.js +36 -0
  42. package/dist/cjs/smartphone-ChvEvl-o.js.map +1 -0
  43. package/dist/cjs/trash-2-CotPjU5n.js +23 -0
  44. package/dist/cjs/trash-2-CotPjU5n.js.map +1 -0
  45. package/dist/cjs/triangle-alert-De-qkUXK.js +27 -0
  46. package/dist/cjs/triangle-alert-De-qkUXK.js.map +1 -0
  47. package/dist/cjs/v2/AuditLogs.js +4 -18
  48. package/dist/cjs/v2/AuditLogs.js.map +1 -1
  49. package/dist/cjs/v2/Builder.js +4 -18
  50. package/dist/cjs/v2/Builder.js.map +1 -1
  51. package/dist/cjs/v2/Codeblock.js +1 -0
  52. package/dist/cjs/v2/Codeblock.js.map +1 -1
  53. package/dist/cjs/v2/CopyToClipboardButton.js +3 -16
  54. package/dist/cjs/v2/CopyToClipboardButton.js.map +1 -1
  55. package/dist/cjs/v2/FinderModal.js +48 -14
  56. package/dist/cjs/v2/FinderModal.js.map +1 -1
  57. package/dist/cjs/v2/FloatingActionMenu.js +1 -0
  58. package/dist/cjs/v2/FloatingActionMenu.js.map +1 -1
  59. package/dist/cjs/v2/Insights.js +344 -0
  60. package/dist/cjs/v2/Insights.js.map +1 -0
  61. package/dist/cjs/v2/IntegrationCard.js +222 -0
  62. package/dist/cjs/v2/IntegrationCard.js.map +1 -0
  63. package/dist/cjs/v2/IpRestriction.js +525 -0
  64. package/dist/cjs/v2/IpRestriction.js.map +1 -0
  65. package/dist/cjs/v2/MadeWith.js +73 -0
  66. package/dist/cjs/v2/MadeWith.js.map +1 -0
  67. package/dist/cjs/v2/Metadata.js +215 -0
  68. package/dist/cjs/v2/Metadata.js.map +1 -0
  69. package/dist/cjs/v2/NavigationHeader.js +1 -0
  70. package/dist/cjs/v2/NavigationHeader.js.map +1 -1
  71. package/dist/cjs/v2/NeetoWidget.js +855 -0
  72. package/dist/cjs/v2/NeetoWidget.js.map +1 -0
  73. package/dist/cjs/v2/Onboarding.js +323 -0
  74. package/dist/cjs/v2/Onboarding.js.map +1 -0
  75. package/dist/cjs/v2/OptionFields.js +1291 -0
  76. package/dist/cjs/v2/OptionFields.js.map +1 -0
  77. package/dist/cjs/v2/PhoneNumber.js +20 -307
  78. package/dist/cjs/v2/PhoneNumber.js.map +1 -1
  79. package/dist/cjs/v2/ProductEmbed.js +1870 -0
  80. package/dist/cjs/v2/ProductEmbed.js.map +1 -0
  81. package/dist/cjs/v2/PublishBlock.js +6 -22
  82. package/dist/cjs/v2/PublishBlock.js.map +1 -1
  83. package/dist/cjs/v2/PublishYourItem.js +60 -0
  84. package/dist/cjs/v2/PublishYourItem.js.map +1 -0
  85. package/dist/cjs/v2/ResponsiveDevicePicker.js +88 -0
  86. package/dist/cjs/v2/ResponsiveDevicePicker.js.map +1 -0
  87. package/dist/cjs/v2/SessionEnvironment.js +479 -0
  88. package/dist/cjs/v2/SessionEnvironment.js.map +1 -0
  89. package/dist/copy-DhbOoOav.js +18 -0
  90. package/dist/copy-DhbOoOav.js.map +1 -0
  91. package/dist/globe-rBiI1CjO.js +19 -0
  92. package/dist/globe-rBiI1CjO.js.map +1 -0
  93. package/dist/index-0jnA7dx6.js +3178 -0
  94. package/dist/index-0jnA7dx6.js.map +1 -0
  95. package/dist/index-DF5MKxql.js +76 -0
  96. package/dist/index-DF5MKxql.js.map +1 -0
  97. package/dist/panel-left-close-37jik3GB.js +19 -0
  98. package/dist/panel-left-close-37jik3GB.js.map +1 -0
  99. package/dist/phone-number-CGZtDB_n.js +291 -0
  100. package/dist/phone-number-CGZtDB_n.js.map +1 -0
  101. package/dist/prism-tomorrow-ZUb2Ikm9.js +1961 -0
  102. package/dist/prism-tomorrow-ZUb2Ikm9.js.map +1 -0
  103. package/dist/react-confetti-BnGq_LBE.js +403 -0
  104. package/dist/react-confetti-BnGq_LBE.js.map +1 -0
  105. package/dist/smartphone-B-jv1y8j.js +33 -0
  106. package/dist/smartphone-B-jv1y8j.js.map +1 -0
  107. package/dist/trash-2-N0F6K63L.js +21 -0
  108. package/dist/trash-2-N0F6K63L.js.map +1 -0
  109. package/dist/triangle-alert-Pkh6pc42.js +25 -0
  110. package/dist/triangle-alert-Pkh6pc42.js.map +1 -0
  111. package/dist/v2/AuditLogs.js +3 -17
  112. package/dist/v2/AuditLogs.js.map +1 -1
  113. package/dist/v2/Builder.js +3 -17
  114. package/dist/v2/Builder.js.map +1 -1
  115. package/dist/v2/Codeblock.js +1 -0
  116. package/dist/v2/Codeblock.js.map +1 -1
  117. package/dist/v2/CopyToClipboardButton.js +2 -15
  118. package/dist/v2/CopyToClipboardButton.js.map +1 -1
  119. package/dist/v2/FinderModal.js +49 -15
  120. package/dist/v2/FinderModal.js.map +1 -1
  121. package/dist/v2/FloatingActionMenu.js +1 -0
  122. package/dist/v2/FloatingActionMenu.js.map +1 -1
  123. package/dist/v2/Insights.js +342 -0
  124. package/dist/v2/Insights.js.map +1 -0
  125. package/dist/v2/IntegrationCard.js +220 -0
  126. package/dist/v2/IntegrationCard.js.map +1 -0
  127. package/dist/v2/IpRestriction.js +504 -0
  128. package/dist/v2/IpRestriction.js.map +1 -0
  129. package/dist/v2/MadeWith.js +52 -0
  130. package/dist/v2/MadeWith.js.map +1 -0
  131. package/dist/v2/Metadata.js +213 -0
  132. package/dist/v2/Metadata.js.map +1 -0
  133. package/dist/v2/NavigationHeader.js +1 -0
  134. package/dist/v2/NavigationHeader.js.map +1 -1
  135. package/dist/v2/NeetoWidget.js +834 -0
  136. package/dist/v2/NeetoWidget.js.map +1 -0
  137. package/dist/v2/Onboarding.js +321 -0
  138. package/dist/v2/Onboarding.js.map +1 -0
  139. package/dist/v2/OptionFields.js +1289 -0
  140. package/dist/v2/OptionFields.js.map +1 -0
  141. package/dist/v2/PhoneNumber.js +20 -287
  142. package/dist/v2/PhoneNumber.js.map +1 -1
  143. package/dist/v2/ProductEmbed.js +1868 -0
  144. package/dist/v2/ProductEmbed.js.map +1 -0
  145. package/dist/v2/PublishBlock.js +5 -21
  146. package/dist/v2/PublishBlock.js.map +1 -1
  147. package/dist/v2/PublishYourItem.js +58 -0
  148. package/dist/v2/PublishYourItem.js.map +1 -0
  149. package/dist/v2/ResponsiveDevicePicker.js +86 -0
  150. package/dist/v2/ResponsiveDevicePicker.js.map +1 -0
  151. package/dist/v2/SessionEnvironment.js +477 -0
  152. package/dist/v2/SessionEnvironment.js.map +1 -0
  153. package/package.json +3 -3
  154. package/types/v2/Insights.d.ts +69 -0
  155. package/types/v2/IntegrationCard.d.ts +30 -0
  156. package/types/v2/IpRestriction.d.ts +5 -0
  157. package/types/v2/MadeWith.d.ts +8 -0
  158. package/types/v2/Metadata.d.ts +26 -0
  159. package/types/v2/MobilePreviewHeader.d.ts +8 -0
  160. package/types/v2/NeetoWidget.d.ts +19 -0
  161. package/types/v2/Onboarding.d.ts +22 -0
  162. package/types/v2/OptionFields.d.ts +55 -0
  163. package/types/v2/ProductEmbed.d.ts +90 -0
  164. package/types/v2/PublishYourItem.d.ts +8 -0
  165. package/types/v2/ResponsiveDevicePicker.d.ts +11 -0
  166. package/types/v2/SessionEnvironment.d.ts +34 -0
@@ -0,0 +1,1961 @@
1
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-BFTU3MAI.js';
2
+ import { n } from './inject-css-C2dztUxs.js';
3
+
4
+ var prism = {exports: {}};
5
+
6
+ (function (module) {
7
+ /* **********************************************
8
+ Begin prism-core.js
9
+ ********************************************** */
10
+
11
+ /// <reference lib="WebWorker"/>
12
+
13
+ var _self = (typeof window !== 'undefined')
14
+ ? window // if in browser
15
+ : (
16
+ (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
17
+ ? self // if in worker
18
+ : {} // if in node js
19
+ );
20
+
21
+ /**
22
+ * Prism: Lightweight, robust, elegant syntax highlighting
23
+ *
24
+ * @license MIT <https://opensource.org/licenses/MIT>
25
+ * @author Lea Verou <https://lea.verou.me>
26
+ * @namespace
27
+ * @public
28
+ */
29
+ var Prism = (function (_self) {
30
+
31
+ // Private helper vars
32
+ var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
33
+ var uniqueId = 0;
34
+
35
+ // The grammar object for plaintext
36
+ var plainTextGrammar = {};
37
+
38
+
39
+ var _ = {
40
+ /**
41
+ * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
42
+ * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
43
+ * additional languages or plugins yourself.
44
+ *
45
+ * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
46
+ *
47
+ * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
48
+ * empty Prism object into the global scope before loading the Prism script like this:
49
+ *
50
+ * ```js
51
+ * window.Prism = window.Prism || {};
52
+ * Prism.manual = true;
53
+ * // add a new <script> to load Prism's script
54
+ * ```
55
+ *
56
+ * @default false
57
+ * @type {boolean}
58
+ * @memberof Prism
59
+ * @public
60
+ */
61
+ manual: _self.Prism && _self.Prism.manual,
62
+ /**
63
+ * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
64
+ * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
65
+ * own worker, you don't want it to do this.
66
+ *
67
+ * By setting this value to `true`, Prism will not add its own listeners to the worker.
68
+ *
69
+ * You obviously have to change this value before Prism executes. To do this, you can add an
70
+ * empty Prism object into the global scope before loading the Prism script like this:
71
+ *
72
+ * ```js
73
+ * window.Prism = window.Prism || {};
74
+ * Prism.disableWorkerMessageHandler = true;
75
+ * // Load Prism's script
76
+ * ```
77
+ *
78
+ * @default false
79
+ * @type {boolean}
80
+ * @memberof Prism
81
+ * @public
82
+ */
83
+ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
84
+
85
+ /**
86
+ * A namespace for utility methods.
87
+ *
88
+ * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
89
+ * change or disappear at any time.
90
+ *
91
+ * @namespace
92
+ * @memberof Prism
93
+ */
94
+ util: {
95
+ encode: function encode(tokens) {
96
+ if (tokens instanceof Token) {
97
+ return new Token(tokens.type, encode(tokens.content), tokens.alias);
98
+ } else if (Array.isArray(tokens)) {
99
+ return tokens.map(encode);
100
+ } else {
101
+ return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
102
+ }
103
+ },
104
+
105
+ /**
106
+ * Returns the name of the type of the given value.
107
+ *
108
+ * @param {any} o
109
+ * @returns {string}
110
+ * @example
111
+ * type(null) === 'Null'
112
+ * type(undefined) === 'Undefined'
113
+ * type(123) === 'Number'
114
+ * type('foo') === 'String'
115
+ * type(true) === 'Boolean'
116
+ * type([1, 2]) === 'Array'
117
+ * type({}) === 'Object'
118
+ * type(String) === 'Function'
119
+ * type(/abc+/) === 'RegExp'
120
+ */
121
+ type: function (o) {
122
+ return Object.prototype.toString.call(o).slice(8, -1);
123
+ },
124
+
125
+ /**
126
+ * Returns a unique number for the given object. Later calls will still return the same number.
127
+ *
128
+ * @param {Object} obj
129
+ * @returns {number}
130
+ */
131
+ objId: function (obj) {
132
+ if (!obj['__id']) {
133
+ Object.defineProperty(obj, '__id', { value: ++uniqueId });
134
+ }
135
+ return obj['__id'];
136
+ },
137
+
138
+ /**
139
+ * Creates a deep clone of the given object.
140
+ *
141
+ * The main intended use of this function is to clone language definitions.
142
+ *
143
+ * @param {T} o
144
+ * @param {Record<number, any>} [visited]
145
+ * @returns {T}
146
+ * @template T
147
+ */
148
+ clone: function deepClone(o, visited) {
149
+ visited = visited || {};
150
+
151
+ var clone; var id;
152
+ switch (_.util.type(o)) {
153
+ case 'Object':
154
+ id = _.util.objId(o);
155
+ if (visited[id]) {
156
+ return visited[id];
157
+ }
158
+ clone = /** @type {Record<string, any>} */ ({});
159
+ visited[id] = clone;
160
+
161
+ for (var key in o) {
162
+ if (o.hasOwnProperty(key)) {
163
+ clone[key] = deepClone(o[key], visited);
164
+ }
165
+ }
166
+
167
+ return /** @type {any} */ (clone);
168
+
169
+ case 'Array':
170
+ id = _.util.objId(o);
171
+ if (visited[id]) {
172
+ return visited[id];
173
+ }
174
+ clone = [];
175
+ visited[id] = clone;
176
+
177
+ (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
178
+ clone[i] = deepClone(v, visited);
179
+ });
180
+
181
+ return /** @type {any} */ (clone);
182
+
183
+ default:
184
+ return o;
185
+ }
186
+ },
187
+
188
+ /**
189
+ * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
190
+ *
191
+ * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
192
+ *
193
+ * @param {Element} element
194
+ * @returns {string}
195
+ */
196
+ getLanguage: function (element) {
197
+ while (element) {
198
+ var m = lang.exec(element.className);
199
+ if (m) {
200
+ return m[1].toLowerCase();
201
+ }
202
+ element = element.parentElement;
203
+ }
204
+ return 'none';
205
+ },
206
+
207
+ /**
208
+ * Sets the Prism `language-xxxx` class of the given element.
209
+ *
210
+ * @param {Element} element
211
+ * @param {string} language
212
+ * @returns {void}
213
+ */
214
+ setLanguage: function (element, language) {
215
+ // remove all `language-xxxx` classes
216
+ // (this might leave behind a leading space)
217
+ element.className = element.className.replace(RegExp(lang, 'gi'), '');
218
+
219
+ // add the new `language-xxxx` class
220
+ // (using `classList` will automatically clean up spaces for us)
221
+ element.classList.add('language-' + language);
222
+ },
223
+
224
+ /**
225
+ * Returns the script element that is currently executing.
226
+ *
227
+ * This does __not__ work for line script element.
228
+ *
229
+ * @returns {HTMLScriptElement | null}
230
+ */
231
+ currentScript: function () {
232
+ if (typeof document === 'undefined') {
233
+ return null;
234
+ }
235
+ if (document.currentScript && document.currentScript.tagName === 'SCRIPT' && 1 < 2 /* hack to trip TS' flow analysis */) {
236
+ return /** @type {any} */ (document.currentScript);
237
+ }
238
+
239
+ // IE11 workaround
240
+ // we'll get the src of the current script by parsing IE11's error stack trace
241
+ // this will not work for inline scripts
242
+
243
+ try {
244
+ throw new Error();
245
+ } catch (err) {
246
+ // Get file src url from stack. Specifically works with the format of stack traces in IE.
247
+ // A stack will look like this:
248
+ //
249
+ // Error
250
+ // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
251
+ // at Global code (http://localhost/components/prism-core.js:606:1)
252
+
253
+ var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
254
+ if (src) {
255
+ var scripts = document.getElementsByTagName('script');
256
+ for (var i in scripts) {
257
+ if (scripts[i].src == src) {
258
+ return scripts[i];
259
+ }
260
+ }
261
+ }
262
+ return null;
263
+ }
264
+ },
265
+
266
+ /**
267
+ * Returns whether a given class is active for `element`.
268
+ *
269
+ * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
270
+ * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
271
+ * given class is just the given class with a `no-` prefix.
272
+ *
273
+ * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
274
+ * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
275
+ * ancestors have the given class or the negated version of it, then the default activation will be returned.
276
+ *
277
+ * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
278
+ * version of it, the class is considered active.
279
+ *
280
+ * @param {Element} element
281
+ * @param {string} className
282
+ * @param {boolean} [defaultActivation=false]
283
+ * @returns {boolean}
284
+ */
285
+ isActive: function (element, className, defaultActivation) {
286
+ var no = 'no-' + className;
287
+
288
+ while (element) {
289
+ var classList = element.classList;
290
+ if (classList.contains(className)) {
291
+ return true;
292
+ }
293
+ if (classList.contains(no)) {
294
+ return false;
295
+ }
296
+ element = element.parentElement;
297
+ }
298
+ return !!defaultActivation;
299
+ }
300
+ },
301
+
302
+ /**
303
+ * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
304
+ *
305
+ * @namespace
306
+ * @memberof Prism
307
+ * @public
308
+ */
309
+ languages: {
310
+ /**
311
+ * The grammar for plain, unformatted text.
312
+ */
313
+ plain: plainTextGrammar,
314
+ plaintext: plainTextGrammar,
315
+ text: plainTextGrammar,
316
+ txt: plainTextGrammar,
317
+
318
+ /**
319
+ * Creates a deep copy of the language with the given id and appends the given tokens.
320
+ *
321
+ * If a token in `redef` also appears in the copied language, then the existing token in the copied language
322
+ * will be overwritten at its original position.
323
+ *
324
+ * ## Best practices
325
+ *
326
+ * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
327
+ * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
328
+ * understand the language definition because, normally, the order of tokens matters in Prism grammars.
329
+ *
330
+ * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
331
+ * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
332
+ *
333
+ * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
334
+ * @param {Grammar} redef The new tokens to append.
335
+ * @returns {Grammar} The new language created.
336
+ * @public
337
+ * @example
338
+ * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
339
+ * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
340
+ * // at its original position
341
+ * 'comment': { ... },
342
+ * // CSS doesn't have a 'color' token, so this token will be appended
343
+ * 'color': /\b(?:red|green|blue)\b/
344
+ * });
345
+ */
346
+ extend: function (id, redef) {
347
+ var lang = _.util.clone(_.languages[id]);
348
+
349
+ for (var key in redef) {
350
+ lang[key] = redef[key];
351
+ }
352
+
353
+ return lang;
354
+ },
355
+
356
+ /**
357
+ * Inserts tokens _before_ another token in a language definition or any other grammar.
358
+ *
359
+ * ## Usage
360
+ *
361
+ * This helper method makes it easy to modify existing languages. For example, the CSS language definition
362
+ * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
363
+ * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
364
+ * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
365
+ * this:
366
+ *
367
+ * ```js
368
+ * Prism.languages.markup.style = {
369
+ * // token
370
+ * };
371
+ * ```
372
+ *
373
+ * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
374
+ * before existing tokens. For the CSS example above, you would use it like this:
375
+ *
376
+ * ```js
377
+ * Prism.languages.insertBefore('markup', 'cdata', {
378
+ * 'style': {
379
+ * // token
380
+ * }
381
+ * });
382
+ * ```
383
+ *
384
+ * ## Special cases
385
+ *
386
+ * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
387
+ * will be ignored.
388
+ *
389
+ * This behavior can be used to insert tokens after `before`:
390
+ *
391
+ * ```js
392
+ * Prism.languages.insertBefore('markup', 'comment', {
393
+ * 'comment': Prism.languages.markup.comment,
394
+ * // tokens after 'comment'
395
+ * });
396
+ * ```
397
+ *
398
+ * ## Limitations
399
+ *
400
+ * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
401
+ * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
402
+ * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
403
+ * deleting properties which is necessary to insert at arbitrary positions.
404
+ *
405
+ * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
406
+ * Instead, it will create a new object and replace all references to the target object with the new one. This
407
+ * can be done without temporarily deleting properties, so the iteration order is well-defined.
408
+ *
409
+ * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
410
+ * you hold the target object in a variable, then the value of the variable will not change.
411
+ *
412
+ * ```js
413
+ * var oldMarkup = Prism.languages.markup;
414
+ * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
415
+ *
416
+ * assert(oldMarkup !== Prism.languages.markup);
417
+ * assert(newMarkup === Prism.languages.markup);
418
+ * ```
419
+ *
420
+ * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
421
+ * object to be modified.
422
+ * @param {string} before The key to insert before.
423
+ * @param {Grammar} insert An object containing the key-value pairs to be inserted.
424
+ * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
425
+ * object to be modified.
426
+ *
427
+ * Defaults to `Prism.languages`.
428
+ * @returns {Grammar} The new grammar object.
429
+ * @public
430
+ */
431
+ insertBefore: function (inside, before, insert, root) {
432
+ root = root || /** @type {any} */ (_.languages);
433
+ var grammar = root[inside];
434
+ /** @type {Grammar} */
435
+ var ret = {};
436
+
437
+ for (var token in grammar) {
438
+ if (grammar.hasOwnProperty(token)) {
439
+
440
+ if (token == before) {
441
+ for (var newToken in insert) {
442
+ if (insert.hasOwnProperty(newToken)) {
443
+ ret[newToken] = insert[newToken];
444
+ }
445
+ }
446
+ }
447
+
448
+ // Do not insert token which also occur in insert. See #1525
449
+ if (!insert.hasOwnProperty(token)) {
450
+ ret[token] = grammar[token];
451
+ }
452
+ }
453
+ }
454
+
455
+ var old = root[inside];
456
+ root[inside] = ret;
457
+
458
+ // Update references in other language definitions
459
+ _.languages.DFS(_.languages, function (key, value) {
460
+ if (value === old && key != inside) {
461
+ this[key] = ret;
462
+ }
463
+ });
464
+
465
+ return ret;
466
+ },
467
+
468
+ // Traverse a language definition with Depth First Search
469
+ DFS: function DFS(o, callback, type, visited) {
470
+ visited = visited || {};
471
+
472
+ var objId = _.util.objId;
473
+
474
+ for (var i in o) {
475
+ if (o.hasOwnProperty(i)) {
476
+ callback.call(o, i, o[i], type || i);
477
+
478
+ var property = o[i];
479
+ var propertyType = _.util.type(property);
480
+
481
+ if (propertyType === 'Object' && !visited[objId(property)]) {
482
+ visited[objId(property)] = true;
483
+ DFS(property, callback, null, visited);
484
+ } else if (propertyType === 'Array' && !visited[objId(property)]) {
485
+ visited[objId(property)] = true;
486
+ DFS(property, callback, i, visited);
487
+ }
488
+ }
489
+ }
490
+ }
491
+ },
492
+
493
+ plugins: {},
494
+
495
+ /**
496
+ * This is the most high-level function in Prism’s API.
497
+ * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
498
+ * each one of them.
499
+ *
500
+ * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
501
+ *
502
+ * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
503
+ * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
504
+ * @memberof Prism
505
+ * @public
506
+ */
507
+ highlightAll: function (async, callback) {
508
+ _.highlightAllUnder(document, async, callback);
509
+ },
510
+
511
+ /**
512
+ * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
513
+ * {@link Prism.highlightElement} on each one of them.
514
+ *
515
+ * The following hooks will be run:
516
+ * 1. `before-highlightall`
517
+ * 2. `before-all-elements-highlight`
518
+ * 3. All hooks of {@link Prism.highlightElement} for each element.
519
+ *
520
+ * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
521
+ * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
522
+ * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
523
+ * @memberof Prism
524
+ * @public
525
+ */
526
+ highlightAllUnder: function (container, async, callback) {
527
+ var env = {
528
+ callback: callback,
529
+ container: container,
530
+ selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
531
+ };
532
+
533
+ _.hooks.run('before-highlightall', env);
534
+
535
+ env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
536
+
537
+ _.hooks.run('before-all-elements-highlight', env);
538
+
539
+ for (var i = 0, element; (element = env.elements[i++]);) {
540
+ _.highlightElement(element, async === true, env.callback);
541
+ }
542
+ },
543
+
544
+ /**
545
+ * Highlights the code inside a single element.
546
+ *
547
+ * The following hooks will be run:
548
+ * 1. `before-sanity-check`
549
+ * 2. `before-highlight`
550
+ * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
551
+ * 4. `before-insert`
552
+ * 5. `after-highlight`
553
+ * 6. `complete`
554
+ *
555
+ * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
556
+ * the element's language.
557
+ *
558
+ * @param {Element} element The element containing the code.
559
+ * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
560
+ * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
561
+ * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
562
+ * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
563
+ *
564
+ * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
565
+ * asynchronous highlighting to work. You can build your own bundle on the
566
+ * [Download page](https://prismjs.com/download.html).
567
+ * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
568
+ * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
569
+ * @memberof Prism
570
+ * @public
571
+ */
572
+ highlightElement: function (element, async, callback) {
573
+ // Find language
574
+ var language = _.util.getLanguage(element);
575
+ var grammar = _.languages[language];
576
+
577
+ // Set language on the element, if not present
578
+ _.util.setLanguage(element, language);
579
+
580
+ // Set language on the parent, for styling
581
+ var parent = element.parentElement;
582
+ if (parent && parent.nodeName.toLowerCase() === 'pre') {
583
+ _.util.setLanguage(parent, language);
584
+ }
585
+
586
+ var code = element.textContent;
587
+
588
+ var env = {
589
+ element: element,
590
+ language: language,
591
+ grammar: grammar,
592
+ code: code
593
+ };
594
+
595
+ function insertHighlightedCode(highlightedCode) {
596
+ env.highlightedCode = highlightedCode;
597
+
598
+ _.hooks.run('before-insert', env);
599
+
600
+ env.element.innerHTML = env.highlightedCode;
601
+
602
+ _.hooks.run('after-highlight', env);
603
+ _.hooks.run('complete', env);
604
+ callback && callback.call(env.element);
605
+ }
606
+
607
+ _.hooks.run('before-sanity-check', env);
608
+
609
+ // plugins may change/add the parent/element
610
+ parent = env.element.parentElement;
611
+ if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
612
+ parent.setAttribute('tabindex', '0');
613
+ }
614
+
615
+ if (!env.code) {
616
+ _.hooks.run('complete', env);
617
+ callback && callback.call(env.element);
618
+ return;
619
+ }
620
+
621
+ _.hooks.run('before-highlight', env);
622
+
623
+ if (!env.grammar) {
624
+ insertHighlightedCode(_.util.encode(env.code));
625
+ return;
626
+ }
627
+
628
+ if (async && _self.Worker) {
629
+ var worker = new Worker(_.filename);
630
+
631
+ worker.onmessage = function (evt) {
632
+ insertHighlightedCode(evt.data);
633
+ };
634
+
635
+ worker.postMessage(JSON.stringify({
636
+ language: env.language,
637
+ code: env.code,
638
+ immediateClose: true
639
+ }));
640
+ } else {
641
+ insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
642
+ }
643
+ },
644
+
645
+ /**
646
+ * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
647
+ * and the language definitions to use, and returns a string with the HTML produced.
648
+ *
649
+ * The following hooks will be run:
650
+ * 1. `before-tokenize`
651
+ * 2. `after-tokenize`
652
+ * 3. `wrap`: On each {@link Token}.
653
+ *
654
+ * @param {string} text A string with the code to be highlighted.
655
+ * @param {Grammar} grammar An object containing the tokens to use.
656
+ *
657
+ * Usually a language definition like `Prism.languages.markup`.
658
+ * @param {string} language The name of the language definition passed to `grammar`.
659
+ * @returns {string} The highlighted HTML.
660
+ * @memberof Prism
661
+ * @public
662
+ * @example
663
+ * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
664
+ */
665
+ highlight: function (text, grammar, language) {
666
+ var env = {
667
+ code: text,
668
+ grammar: grammar,
669
+ language: language
670
+ };
671
+ _.hooks.run('before-tokenize', env);
672
+ if (!env.grammar) {
673
+ throw new Error('The language "' + env.language + '" has no grammar.');
674
+ }
675
+ env.tokens = _.tokenize(env.code, env.grammar);
676
+ _.hooks.run('after-tokenize', env);
677
+ return Token.stringify(_.util.encode(env.tokens), env.language);
678
+ },
679
+
680
+ /**
681
+ * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
682
+ * and the language definitions to use, and returns an array with the tokenized code.
683
+ *
684
+ * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
685
+ *
686
+ * This method could be useful in other contexts as well, as a very crude parser.
687
+ *
688
+ * @param {string} text A string with the code to be highlighted.
689
+ * @param {Grammar} grammar An object containing the tokens to use.
690
+ *
691
+ * Usually a language definition like `Prism.languages.markup`.
692
+ * @returns {TokenStream} An array of strings and tokens, a token stream.
693
+ * @memberof Prism
694
+ * @public
695
+ * @example
696
+ * let code = `var foo = 0;`;
697
+ * let tokens = Prism.tokenize(code, Prism.languages.javascript);
698
+ * tokens.forEach(token => {
699
+ * if (token instanceof Prism.Token && token.type === 'number') {
700
+ * console.log(`Found numeric literal: ${token.content}`);
701
+ * }
702
+ * });
703
+ */
704
+ tokenize: function (text, grammar) {
705
+ var rest = grammar.rest;
706
+ if (rest) {
707
+ for (var token in rest) {
708
+ grammar[token] = rest[token];
709
+ }
710
+
711
+ delete grammar.rest;
712
+ }
713
+
714
+ var tokenList = new LinkedList();
715
+ addAfter(tokenList, tokenList.head, text);
716
+
717
+ matchGrammar(text, tokenList, grammar, tokenList.head, 0);
718
+
719
+ return toArray(tokenList);
720
+ },
721
+
722
+ /**
723
+ * @namespace
724
+ * @memberof Prism
725
+ * @public
726
+ */
727
+ hooks: {
728
+ all: {},
729
+
730
+ /**
731
+ * Adds the given callback to the list of callbacks for the given hook.
732
+ *
733
+ * The callback will be invoked when the hook it is registered for is run.
734
+ * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
735
+ *
736
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
737
+ *
738
+ * @param {string} name The name of the hook.
739
+ * @param {HookCallback} callback The callback function which is given environment variables.
740
+ * @public
741
+ */
742
+ add: function (name, callback) {
743
+ var hooks = _.hooks.all;
744
+
745
+ hooks[name] = hooks[name] || [];
746
+
747
+ hooks[name].push(callback);
748
+ },
749
+
750
+ /**
751
+ * Runs a hook invoking all registered callbacks with the given environment variables.
752
+ *
753
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
754
+ *
755
+ * @param {string} name The name of the hook.
756
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
757
+ * @public
758
+ */
759
+ run: function (name, env) {
760
+ var callbacks = _.hooks.all[name];
761
+
762
+ if (!callbacks || !callbacks.length) {
763
+ return;
764
+ }
765
+
766
+ for (var i = 0, callback; (callback = callbacks[i++]);) {
767
+ callback(env);
768
+ }
769
+ }
770
+ },
771
+
772
+ Token: Token
773
+ };
774
+ _self.Prism = _;
775
+
776
+
777
+ // Typescript note:
778
+ // The following can be used to import the Token type in JSDoc:
779
+ //
780
+ // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
781
+
782
+ /**
783
+ * Creates a new token.
784
+ *
785
+ * @param {string} type See {@link Token#type type}
786
+ * @param {string | TokenStream} content See {@link Token#content content}
787
+ * @param {string|string[]} [alias] The alias(es) of the token.
788
+ * @param {string} [matchedStr=""] A copy of the full string this token was created from.
789
+ * @class
790
+ * @global
791
+ * @public
792
+ */
793
+ function Token(type, content, alias, matchedStr) {
794
+ /**
795
+ * The type of the token.
796
+ *
797
+ * This is usually the key of a pattern in a {@link Grammar}.
798
+ *
799
+ * @type {string}
800
+ * @see GrammarToken
801
+ * @public
802
+ */
803
+ this.type = type;
804
+ /**
805
+ * The strings or tokens contained by this token.
806
+ *
807
+ * This will be a token stream if the pattern matched also defined an `inside` grammar.
808
+ *
809
+ * @type {string | TokenStream}
810
+ * @public
811
+ */
812
+ this.content = content;
813
+ /**
814
+ * The alias(es) of the token.
815
+ *
816
+ * @type {string|string[]}
817
+ * @see GrammarToken
818
+ * @public
819
+ */
820
+ this.alias = alias;
821
+ // Copy of the full string this token was created from
822
+ this.length = (matchedStr || '').length | 0;
823
+ }
824
+
825
+ /**
826
+ * A token stream is an array of strings and {@link Token Token} objects.
827
+ *
828
+ * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
829
+ * them.
830
+ *
831
+ * 1. No adjacent strings.
832
+ * 2. No empty strings.
833
+ *
834
+ * The only exception here is the token stream that only contains the empty string and nothing else.
835
+ *
836
+ * @typedef {Array<string | Token>} TokenStream
837
+ * @global
838
+ * @public
839
+ */
840
+
841
+ /**
842
+ * Converts the given token or token stream to an HTML representation.
843
+ *
844
+ * The following hooks will be run:
845
+ * 1. `wrap`: On each {@link Token}.
846
+ *
847
+ * @param {string | Token | TokenStream} o The token or token stream to be converted.
848
+ * @param {string} language The name of current language.
849
+ * @returns {string} The HTML representation of the token or token stream.
850
+ * @memberof Token
851
+ * @static
852
+ */
853
+ Token.stringify = function stringify(o, language) {
854
+ if (typeof o == 'string') {
855
+ return o;
856
+ }
857
+ if (Array.isArray(o)) {
858
+ var s = '';
859
+ o.forEach(function (e) {
860
+ s += stringify(e, language);
861
+ });
862
+ return s;
863
+ }
864
+
865
+ var env = {
866
+ type: o.type,
867
+ content: stringify(o.content, language),
868
+ tag: 'span',
869
+ classes: ['token', o.type],
870
+ attributes: {},
871
+ language: language
872
+ };
873
+
874
+ var aliases = o.alias;
875
+ if (aliases) {
876
+ if (Array.isArray(aliases)) {
877
+ Array.prototype.push.apply(env.classes, aliases);
878
+ } else {
879
+ env.classes.push(aliases);
880
+ }
881
+ }
882
+
883
+ _.hooks.run('wrap', env);
884
+
885
+ var attributes = '';
886
+ for (var name in env.attributes) {
887
+ attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
888
+ }
889
+
890
+ return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
891
+ };
892
+
893
+ /**
894
+ * @param {RegExp} pattern
895
+ * @param {number} pos
896
+ * @param {string} text
897
+ * @param {boolean} lookbehind
898
+ * @returns {RegExpExecArray | null}
899
+ */
900
+ function matchPattern(pattern, pos, text, lookbehind) {
901
+ pattern.lastIndex = pos;
902
+ var match = pattern.exec(text);
903
+ if (match && lookbehind && match[1]) {
904
+ // change the match to remove the text matched by the Prism lookbehind group
905
+ var lookbehindLength = match[1].length;
906
+ match.index += lookbehindLength;
907
+ match[0] = match[0].slice(lookbehindLength);
908
+ }
909
+ return match;
910
+ }
911
+
912
+ /**
913
+ * @param {string} text
914
+ * @param {LinkedList<string | Token>} tokenList
915
+ * @param {any} grammar
916
+ * @param {LinkedListNode<string | Token>} startNode
917
+ * @param {number} startPos
918
+ * @param {RematchOptions} [rematch]
919
+ * @returns {void}
920
+ * @private
921
+ *
922
+ * @typedef RematchOptions
923
+ * @property {string} cause
924
+ * @property {number} reach
925
+ */
926
+ function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
927
+ for (var token in grammar) {
928
+ if (!grammar.hasOwnProperty(token) || !grammar[token]) {
929
+ continue;
930
+ }
931
+
932
+ var patterns = grammar[token];
933
+ patterns = Array.isArray(patterns) ? patterns : [patterns];
934
+
935
+ for (var j = 0; j < patterns.length; ++j) {
936
+ if (rematch && rematch.cause == token + ',' + j) {
937
+ return;
938
+ }
939
+
940
+ var patternObj = patterns[j];
941
+ var inside = patternObj.inside;
942
+ var lookbehind = !!patternObj.lookbehind;
943
+ var greedy = !!patternObj.greedy;
944
+ var alias = patternObj.alias;
945
+
946
+ if (greedy && !patternObj.pattern.global) {
947
+ // Without the global flag, lastIndex won't work
948
+ var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
949
+ patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
950
+ }
951
+
952
+ /** @type {RegExp} */
953
+ var pattern = patternObj.pattern || patternObj;
954
+
955
+ for ( // iterate the token list and keep track of the current token/string position
956
+ var currentNode = startNode.next, pos = startPos;
957
+ currentNode !== tokenList.tail;
958
+ pos += currentNode.value.length, currentNode = currentNode.next
959
+ ) {
960
+
961
+ if (rematch && pos >= rematch.reach) {
962
+ break;
963
+ }
964
+
965
+ var str = currentNode.value;
966
+
967
+ if (tokenList.length > text.length) {
968
+ // Something went terribly wrong, ABORT, ABORT!
969
+ return;
970
+ }
971
+
972
+ if (str instanceof Token) {
973
+ continue;
974
+ }
975
+
976
+ var removeCount = 1; // this is the to parameter of removeBetween
977
+ var match;
978
+
979
+ if (greedy) {
980
+ match = matchPattern(pattern, pos, text, lookbehind);
981
+ if (!match || match.index >= text.length) {
982
+ break;
983
+ }
984
+
985
+ var from = match.index;
986
+ var to = match.index + match[0].length;
987
+ var p = pos;
988
+
989
+ // find the node that contains the match
990
+ p += currentNode.value.length;
991
+ while (from >= p) {
992
+ currentNode = currentNode.next;
993
+ p += currentNode.value.length;
994
+ }
995
+ // adjust pos (and p)
996
+ p -= currentNode.value.length;
997
+ pos = p;
998
+
999
+ // the current node is a Token, then the match starts inside another Token, which is invalid
1000
+ if (currentNode.value instanceof Token) {
1001
+ continue;
1002
+ }
1003
+
1004
+ // find the last node which is affected by this match
1005
+ for (
1006
+ var k = currentNode;
1007
+ k !== tokenList.tail && (p < to || typeof k.value === 'string');
1008
+ k = k.next
1009
+ ) {
1010
+ removeCount++;
1011
+ p += k.value.length;
1012
+ }
1013
+ removeCount--;
1014
+
1015
+ // replace with the new match
1016
+ str = text.slice(pos, p);
1017
+ match.index -= pos;
1018
+ } else {
1019
+ match = matchPattern(pattern, 0, str, lookbehind);
1020
+ if (!match) {
1021
+ continue;
1022
+ }
1023
+ }
1024
+
1025
+ // eslint-disable-next-line no-redeclare
1026
+ var from = match.index;
1027
+ var matchStr = match[0];
1028
+ var before = str.slice(0, from);
1029
+ var after = str.slice(from + matchStr.length);
1030
+
1031
+ var reach = pos + str.length;
1032
+ if (rematch && reach > rematch.reach) {
1033
+ rematch.reach = reach;
1034
+ }
1035
+
1036
+ var removeFrom = currentNode.prev;
1037
+
1038
+ if (before) {
1039
+ removeFrom = addAfter(tokenList, removeFrom, before);
1040
+ pos += before.length;
1041
+ }
1042
+
1043
+ removeRange(tokenList, removeFrom, removeCount);
1044
+
1045
+ var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
1046
+ currentNode = addAfter(tokenList, removeFrom, wrapped);
1047
+
1048
+ if (after) {
1049
+ addAfter(tokenList, currentNode, after);
1050
+ }
1051
+
1052
+ if (removeCount > 1) {
1053
+ // at least one Token object was removed, so we have to do some rematching
1054
+ // this can only happen if the current pattern is greedy
1055
+
1056
+ /** @type {RematchOptions} */
1057
+ var nestedRematch = {
1058
+ cause: token + ',' + j,
1059
+ reach: reach
1060
+ };
1061
+ matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
1062
+
1063
+ // the reach might have been extended because of the rematching
1064
+ if (rematch && nestedRematch.reach > rematch.reach) {
1065
+ rematch.reach = nestedRematch.reach;
1066
+ }
1067
+ }
1068
+ }
1069
+ }
1070
+ }
1071
+ }
1072
+
1073
+ /**
1074
+ * @typedef LinkedListNode
1075
+ * @property {T} value
1076
+ * @property {LinkedListNode<T> | null} prev The previous node.
1077
+ * @property {LinkedListNode<T> | null} next The next node.
1078
+ * @template T
1079
+ * @private
1080
+ */
1081
+
1082
+ /**
1083
+ * @template T
1084
+ * @private
1085
+ */
1086
+ function LinkedList() {
1087
+ /** @type {LinkedListNode<T>} */
1088
+ var head = { value: null, prev: null, next: null };
1089
+ /** @type {LinkedListNode<T>} */
1090
+ var tail = { value: null, prev: head, next: null };
1091
+ head.next = tail;
1092
+
1093
+ /** @type {LinkedListNode<T>} */
1094
+ this.head = head;
1095
+ /** @type {LinkedListNode<T>} */
1096
+ this.tail = tail;
1097
+ this.length = 0;
1098
+ }
1099
+
1100
+ /**
1101
+ * Adds a new node with the given value to the list.
1102
+ *
1103
+ * @param {LinkedList<T>} list
1104
+ * @param {LinkedListNode<T>} node
1105
+ * @param {T} value
1106
+ * @returns {LinkedListNode<T>} The added node.
1107
+ * @template T
1108
+ */
1109
+ function addAfter(list, node, value) {
1110
+ // assumes that node != list.tail && values.length >= 0
1111
+ var next = node.next;
1112
+
1113
+ var newNode = { value: value, prev: node, next: next };
1114
+ node.next = newNode;
1115
+ next.prev = newNode;
1116
+ list.length++;
1117
+
1118
+ return newNode;
1119
+ }
1120
+ /**
1121
+ * Removes `count` nodes after the given node. The given node will not be removed.
1122
+ *
1123
+ * @param {LinkedList<T>} list
1124
+ * @param {LinkedListNode<T>} node
1125
+ * @param {number} count
1126
+ * @template T
1127
+ */
1128
+ function removeRange(list, node, count) {
1129
+ var next = node.next;
1130
+ for (var i = 0; i < count && next !== list.tail; i++) {
1131
+ next = next.next;
1132
+ }
1133
+ node.next = next;
1134
+ next.prev = node;
1135
+ list.length -= i;
1136
+ }
1137
+ /**
1138
+ * @param {LinkedList<T>} list
1139
+ * @returns {T[]}
1140
+ * @template T
1141
+ */
1142
+ function toArray(list) {
1143
+ var array = [];
1144
+ var node = list.head.next;
1145
+ while (node !== list.tail) {
1146
+ array.push(node.value);
1147
+ node = node.next;
1148
+ }
1149
+ return array;
1150
+ }
1151
+
1152
+
1153
+ if (!_self.document) {
1154
+ if (!_self.addEventListener) {
1155
+ // in Node.js
1156
+ return _;
1157
+ }
1158
+
1159
+ if (!_.disableWorkerMessageHandler) {
1160
+ // In worker
1161
+ _self.addEventListener('message', function (evt) {
1162
+ var message = JSON.parse(evt.data);
1163
+ var lang = message.language;
1164
+ var code = message.code;
1165
+ var immediateClose = message.immediateClose;
1166
+
1167
+ _self.postMessage(_.highlight(code, _.languages[lang], lang));
1168
+ if (immediateClose) {
1169
+ _self.close();
1170
+ }
1171
+ }, false);
1172
+ }
1173
+
1174
+ return _;
1175
+ }
1176
+
1177
+ // Get current script and highlight
1178
+ var script = _.util.currentScript();
1179
+
1180
+ if (script) {
1181
+ _.filename = script.src;
1182
+
1183
+ if (script.hasAttribute('data-manual')) {
1184
+ _.manual = true;
1185
+ }
1186
+ }
1187
+
1188
+ function highlightAutomaticallyCallback() {
1189
+ if (!_.manual) {
1190
+ _.highlightAll();
1191
+ }
1192
+ }
1193
+
1194
+ if (!_.manual) {
1195
+ // If the document state is "loading", then we'll use DOMContentLoaded.
1196
+ // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1197
+ // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1198
+ // might take longer one animation frame to execute which can create a race condition where only some plugins have
1199
+ // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1200
+ // See https://github.com/PrismJS/prism/issues/2102
1201
+ var readyState = document.readyState;
1202
+ if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
1203
+ document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
1204
+ } else {
1205
+ if (window.requestAnimationFrame) {
1206
+ window.requestAnimationFrame(highlightAutomaticallyCallback);
1207
+ } else {
1208
+ window.setTimeout(highlightAutomaticallyCallback, 16);
1209
+ }
1210
+ }
1211
+ }
1212
+
1213
+ return _;
1214
+
1215
+ }(_self));
1216
+
1217
+ if (module.exports) {
1218
+ module.exports = Prism;
1219
+ }
1220
+
1221
+ // hack for components to work correctly in node.js
1222
+ if (typeof commonjsGlobal !== 'undefined') {
1223
+ commonjsGlobal.Prism = Prism;
1224
+ }
1225
+
1226
+ // some additional documentation/types
1227
+
1228
+ /**
1229
+ * The expansion of a simple `RegExp` literal to support additional properties.
1230
+ *
1231
+ * @typedef GrammarToken
1232
+ * @property {RegExp} pattern The regular expression of the token.
1233
+ * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
1234
+ * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
1235
+ * @property {boolean} [greedy=false] Whether the token is greedy.
1236
+ * @property {string|string[]} [alias] An optional alias or list of aliases.
1237
+ * @property {Grammar} [inside] The nested grammar of this token.
1238
+ *
1239
+ * The `inside` grammar will be used to tokenize the text value of each token of this kind.
1240
+ *
1241
+ * This can be used to make nested and even recursive language definitions.
1242
+ *
1243
+ * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
1244
+ * each another.
1245
+ * @global
1246
+ * @public
1247
+ */
1248
+
1249
+ /**
1250
+ * @typedef Grammar
1251
+ * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
1252
+ * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
1253
+ * @global
1254
+ * @public
1255
+ */
1256
+
1257
+ /**
1258
+ * A function which will invoked after an element was successfully highlighted.
1259
+ *
1260
+ * @callback HighlightCallback
1261
+ * @param {Element} element The element successfully highlighted.
1262
+ * @returns {void}
1263
+ * @global
1264
+ * @public
1265
+ */
1266
+
1267
+ /**
1268
+ * @callback HookCallback
1269
+ * @param {Object<string, any>} env The environment variables of the hook.
1270
+ * @returns {void}
1271
+ * @global
1272
+ * @public
1273
+ */
1274
+
1275
+
1276
+ /* **********************************************
1277
+ Begin prism-markup.js
1278
+ ********************************************** */
1279
+
1280
+ Prism.languages.markup = {
1281
+ 'comment': {
1282
+ pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
1283
+ greedy: true
1284
+ },
1285
+ 'prolog': {
1286
+ pattern: /<\?[\s\S]+?\?>/,
1287
+ greedy: true
1288
+ },
1289
+ 'doctype': {
1290
+ // https://www.w3.org/TR/xml/#NT-doctypedecl
1291
+ pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
1292
+ greedy: true,
1293
+ inside: {
1294
+ 'internal-subset': {
1295
+ pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
1296
+ lookbehind: true,
1297
+ greedy: true,
1298
+ inside: null // see below
1299
+ },
1300
+ 'string': {
1301
+ pattern: /"[^"]*"|'[^']*'/,
1302
+ greedy: true
1303
+ },
1304
+ 'punctuation': /^<!|>$|[[\]]/,
1305
+ 'doctype-tag': /^DOCTYPE/i,
1306
+ 'name': /[^\s<>'"]+/
1307
+ }
1308
+ },
1309
+ 'cdata': {
1310
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1311
+ greedy: true
1312
+ },
1313
+ 'tag': {
1314
+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1315
+ greedy: true,
1316
+ inside: {
1317
+ 'tag': {
1318
+ pattern: /^<\/?[^\s>\/]+/,
1319
+ inside: {
1320
+ 'punctuation': /^<\/?/,
1321
+ 'namespace': /^[^\s>\/:]+:/
1322
+ }
1323
+ },
1324
+ 'special-attr': [],
1325
+ 'attr-value': {
1326
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1327
+ inside: {
1328
+ 'punctuation': [
1329
+ {
1330
+ pattern: /^=/,
1331
+ alias: 'attr-equals'
1332
+ },
1333
+ {
1334
+ pattern: /^(\s*)["']|["']$/,
1335
+ lookbehind: true
1336
+ }
1337
+ ]
1338
+ }
1339
+ },
1340
+ 'punctuation': /\/?>/,
1341
+ 'attr-name': {
1342
+ pattern: /[^\s>\/]+/,
1343
+ inside: {
1344
+ 'namespace': /^[^\s>\/:]+:/
1345
+ }
1346
+ }
1347
+
1348
+ }
1349
+ },
1350
+ 'entity': [
1351
+ {
1352
+ pattern: /&[\da-z]{1,8};/i,
1353
+ alias: 'named-entity'
1354
+ },
1355
+ /&#x?[\da-f]{1,8};/i
1356
+ ]
1357
+ };
1358
+
1359
+ Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
1360
+ Prism.languages.markup['entity'];
1361
+ Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
1362
+
1363
+ // Plugin to make entity title show the real entity, idea by Roman Komarov
1364
+ Prism.hooks.add('wrap', function (env) {
1365
+
1366
+ if (env.type === 'entity') {
1367
+ env.attributes['title'] = env.content.replace(/&amp;/, '&');
1368
+ }
1369
+ });
1370
+
1371
+ Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
1372
+ /**
1373
+ * Adds an inlined language to markup.
1374
+ *
1375
+ * An example of an inlined language is CSS with `<style>` tags.
1376
+ *
1377
+ * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
1378
+ * case insensitive.
1379
+ * @param {string} lang The language key.
1380
+ * @example
1381
+ * addInlined('style', 'css');
1382
+ */
1383
+ value: function addInlined(tagName, lang) {
1384
+ var includedCdataInside = {};
1385
+ includedCdataInside['language-' + lang] = {
1386
+ pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1387
+ lookbehind: true,
1388
+ inside: Prism.languages[lang]
1389
+ };
1390
+ includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
1391
+
1392
+ var inside = {
1393
+ 'included-cdata': {
1394
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1395
+ inside: includedCdataInside
1396
+ }
1397
+ };
1398
+ inside['language-' + lang] = {
1399
+ pattern: /[\s\S]+/,
1400
+ inside: Prism.languages[lang]
1401
+ };
1402
+
1403
+ var def = {};
1404
+ def[tagName] = {
1405
+ pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
1406
+ lookbehind: true,
1407
+ greedy: true,
1408
+ inside: inside
1409
+ };
1410
+
1411
+ Prism.languages.insertBefore('markup', 'cdata', def);
1412
+ }
1413
+ });
1414
+ Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
1415
+ /**
1416
+ * Adds an pattern to highlight languages embedded in HTML attributes.
1417
+ *
1418
+ * An example of an inlined language is CSS with `style` attributes.
1419
+ *
1420
+ * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
1421
+ * case insensitive.
1422
+ * @param {string} lang The language key.
1423
+ * @example
1424
+ * addAttribute('style', 'css');
1425
+ */
1426
+ value: function (attrName, lang) {
1427
+ Prism.languages.markup.tag.inside['special-attr'].push({
1428
+ pattern: RegExp(
1429
+ /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
1430
+ 'i'
1431
+ ),
1432
+ lookbehind: true,
1433
+ inside: {
1434
+ 'attr-name': /^[^\s=]+/,
1435
+ 'attr-value': {
1436
+ pattern: /=[\s\S]+/,
1437
+ inside: {
1438
+ 'value': {
1439
+ pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
1440
+ lookbehind: true,
1441
+ alias: [lang, 'language-' + lang],
1442
+ inside: Prism.languages[lang]
1443
+ },
1444
+ 'punctuation': [
1445
+ {
1446
+ pattern: /^=/,
1447
+ alias: 'attr-equals'
1448
+ },
1449
+ /"|'/
1450
+ ]
1451
+ }
1452
+ }
1453
+ }
1454
+ });
1455
+ }
1456
+ });
1457
+
1458
+ Prism.languages.html = Prism.languages.markup;
1459
+ Prism.languages.mathml = Prism.languages.markup;
1460
+ Prism.languages.svg = Prism.languages.markup;
1461
+
1462
+ Prism.languages.xml = Prism.languages.extend('markup', {});
1463
+ Prism.languages.ssml = Prism.languages.xml;
1464
+ Prism.languages.atom = Prism.languages.xml;
1465
+ Prism.languages.rss = Prism.languages.xml;
1466
+
1467
+
1468
+ /* **********************************************
1469
+ Begin prism-css.js
1470
+ ********************************************** */
1471
+
1472
+ (function (Prism) {
1473
+
1474
+ var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
1475
+
1476
+ Prism.languages.css = {
1477
+ 'comment': /\/\*[\s\S]*?\*\//,
1478
+ 'atrule': {
1479
+ pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
1480
+ inside: {
1481
+ 'rule': /^@[\w-]+/,
1482
+ 'selector-function-argument': {
1483
+ pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1484
+ lookbehind: true,
1485
+ alias: 'selector'
1486
+ },
1487
+ 'keyword': {
1488
+ pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1489
+ lookbehind: true
1490
+ }
1491
+ // See rest below
1492
+ }
1493
+ },
1494
+ 'url': {
1495
+ // https://drafts.csswg.org/css-values-3/#urls
1496
+ pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
1497
+ greedy: true,
1498
+ inside: {
1499
+ 'function': /^url/i,
1500
+ 'punctuation': /^\(|\)$/,
1501
+ 'string': {
1502
+ pattern: RegExp('^' + string.source + '$'),
1503
+ alias: 'url'
1504
+ }
1505
+ }
1506
+ },
1507
+ 'selector': {
1508
+ pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
1509
+ lookbehind: true
1510
+ },
1511
+ 'string': {
1512
+ pattern: string,
1513
+ greedy: true
1514
+ },
1515
+ 'property': {
1516
+ pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
1517
+ lookbehind: true
1518
+ },
1519
+ 'important': /!important\b/i,
1520
+ 'function': {
1521
+ pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
1522
+ lookbehind: true
1523
+ },
1524
+ 'punctuation': /[(){};:,]/
1525
+ };
1526
+
1527
+ Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
1528
+
1529
+ var markup = Prism.languages.markup;
1530
+ if (markup) {
1531
+ markup.tag.addInlined('style', 'css');
1532
+ markup.tag.addAttribute('style', 'css');
1533
+ }
1534
+
1535
+ }(Prism));
1536
+
1537
+
1538
+ /* **********************************************
1539
+ Begin prism-clike.js
1540
+ ********************************************** */
1541
+
1542
+ Prism.languages.clike = {
1543
+ 'comment': [
1544
+ {
1545
+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1546
+ lookbehind: true,
1547
+ greedy: true
1548
+ },
1549
+ {
1550
+ pattern: /(^|[^\\:])\/\/.*/,
1551
+ lookbehind: true,
1552
+ greedy: true
1553
+ }
1554
+ ],
1555
+ 'string': {
1556
+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1557
+ greedy: true
1558
+ },
1559
+ 'class-name': {
1560
+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
1561
+ lookbehind: true,
1562
+ inside: {
1563
+ 'punctuation': /[.\\]/
1564
+ }
1565
+ },
1566
+ 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
1567
+ 'boolean': /\b(?:false|true)\b/,
1568
+ 'function': /\b\w+(?=\()/,
1569
+ 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1570
+ 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1571
+ 'punctuation': /[{}[\];(),.:]/
1572
+ };
1573
+
1574
+
1575
+ /* **********************************************
1576
+ Begin prism-javascript.js
1577
+ ********************************************** */
1578
+
1579
+ Prism.languages.javascript = Prism.languages.extend('clike', {
1580
+ 'class-name': [
1581
+ Prism.languages.clike['class-name'],
1582
+ {
1583
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
1584
+ lookbehind: true
1585
+ }
1586
+ ],
1587
+ 'keyword': [
1588
+ {
1589
+ pattern: /((?:^|\})\s*)catch\b/,
1590
+ lookbehind: true
1591
+ },
1592
+ {
1593
+ 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/,
1594
+ lookbehind: true
1595
+ },
1596
+ ],
1597
+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1598
+ 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1599
+ 'number': {
1600
+ pattern: RegExp(
1601
+ /(^|[^\w$])/.source +
1602
+ '(?:' +
1603
+ (
1604
+ // constant
1605
+ /NaN|Infinity/.source +
1606
+ '|' +
1607
+ // binary integer
1608
+ /0[bB][01]+(?:_[01]+)*n?/.source +
1609
+ '|' +
1610
+ // octal integer
1611
+ /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
1612
+ '|' +
1613
+ // hexadecimal integer
1614
+ /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
1615
+ '|' +
1616
+ // decimal bigint
1617
+ /\d+(?:_\d+)*n/.source +
1618
+ '|' +
1619
+ // decimal number (integer or float) but no bigint
1620
+ /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
1621
+ ) +
1622
+ ')' +
1623
+ /(?![\w$])/.source
1624
+ ),
1625
+ lookbehind: true
1626
+ },
1627
+ 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
1628
+ });
1629
+
1630
+ Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
1631
+
1632
+ Prism.languages.insertBefore('javascript', 'keyword', {
1633
+ 'regex': {
1634
+ pattern: RegExp(
1635
+ // lookbehind
1636
+ // eslint-disable-next-line regexp/no-dupe-characters-character-class
1637
+ /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
1638
+ // Regex pattern:
1639
+ // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
1640
+ // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
1641
+ // with the only syntax, so we have to define 2 different regex patterns.
1642
+ /\//.source +
1643
+ '(?:' +
1644
+ /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
1645
+ '|' +
1646
+ // `v` flag syntax. This supports 3 levels of nested character classes.
1647
+ /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
1648
+ ')' +
1649
+ // lookahead
1650
+ /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
1651
+ ),
1652
+ lookbehind: true,
1653
+ greedy: true,
1654
+ inside: {
1655
+ 'regex-source': {
1656
+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1657
+ lookbehind: true,
1658
+ alias: 'language-regex',
1659
+ inside: Prism.languages.regex
1660
+ },
1661
+ 'regex-delimiter': /^\/|\/$/,
1662
+ 'regex-flags': /^[a-z]+$/,
1663
+ }
1664
+ },
1665
+ // This must be declared before keyword because we use "function" inside the look-forward
1666
+ 'function-variable': {
1667
+ 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*=>))/,
1668
+ alias: 'function'
1669
+ },
1670
+ 'parameter': [
1671
+ {
1672
+ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1673
+ lookbehind: true,
1674
+ inside: Prism.languages.javascript
1675
+ },
1676
+ {
1677
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1678
+ lookbehind: true,
1679
+ inside: Prism.languages.javascript
1680
+ },
1681
+ {
1682
+ pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1683
+ lookbehind: true,
1684
+ inside: Prism.languages.javascript
1685
+ },
1686
+ {
1687
+ 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*\{)/,
1688
+ lookbehind: true,
1689
+ inside: Prism.languages.javascript
1690
+ }
1691
+ ],
1692
+ 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
1693
+ });
1694
+
1695
+ Prism.languages.insertBefore('javascript', 'string', {
1696
+ 'hashbang': {
1697
+ pattern: /^#!.*/,
1698
+ greedy: true,
1699
+ alias: 'comment'
1700
+ },
1701
+ 'template-string': {
1702
+ pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
1703
+ greedy: true,
1704
+ inside: {
1705
+ 'template-punctuation': {
1706
+ pattern: /^`|`$/,
1707
+ alias: 'string'
1708
+ },
1709
+ 'interpolation': {
1710
+ pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
1711
+ lookbehind: true,
1712
+ inside: {
1713
+ 'interpolation-punctuation': {
1714
+ pattern: /^\$\{|\}$/,
1715
+ alias: 'punctuation'
1716
+ },
1717
+ rest: Prism.languages.javascript
1718
+ }
1719
+ },
1720
+ 'string': /[\s\S]+/
1721
+ }
1722
+ },
1723
+ 'string-property': {
1724
+ pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
1725
+ lookbehind: true,
1726
+ greedy: true,
1727
+ alias: 'property'
1728
+ }
1729
+ });
1730
+
1731
+ Prism.languages.insertBefore('javascript', 'operator', {
1732
+ 'literal-property': {
1733
+ pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
1734
+ lookbehind: true,
1735
+ alias: 'property'
1736
+ },
1737
+ });
1738
+
1739
+ if (Prism.languages.markup) {
1740
+ Prism.languages.markup.tag.addInlined('script', 'javascript');
1741
+
1742
+ // add attribute support for all DOM events.
1743
+ // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
1744
+ Prism.languages.markup.tag.addAttribute(
1745
+ /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,
1746
+ 'javascript'
1747
+ );
1748
+ }
1749
+
1750
+ Prism.languages.js = Prism.languages.javascript;
1751
+
1752
+
1753
+ /* **********************************************
1754
+ Begin prism-file-highlight.js
1755
+ ********************************************** */
1756
+
1757
+ (function () {
1758
+
1759
+ if (typeof Prism === 'undefined' || typeof document === 'undefined') {
1760
+ return;
1761
+ }
1762
+
1763
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
1764
+ if (!Element.prototype.matches) {
1765
+ Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
1766
+ }
1767
+
1768
+ var LOADING_MESSAGE = 'Loading…';
1769
+ var FAILURE_MESSAGE = function (status, message) {
1770
+ return '✖ Error ' + status + ' while fetching file: ' + message;
1771
+ };
1772
+ var FAILURE_EMPTY_MESSAGE = '✖ Error: File does not exist or is empty';
1773
+
1774
+ var EXTENSIONS = {
1775
+ 'js': 'javascript',
1776
+ 'py': 'python',
1777
+ 'rb': 'ruby',
1778
+ 'ps1': 'powershell',
1779
+ 'psm1': 'powershell',
1780
+ 'sh': 'bash',
1781
+ 'bat': 'batch',
1782
+ 'h': 'c',
1783
+ 'tex': 'latex'
1784
+ };
1785
+
1786
+ var STATUS_ATTR = 'data-src-status';
1787
+ var STATUS_LOADING = 'loading';
1788
+ var STATUS_LOADED = 'loaded';
1789
+ var STATUS_FAILED = 'failed';
1790
+
1791
+ var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])'
1792
+ + ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
1793
+
1794
+ /**
1795
+ * Loads the given file.
1796
+ *
1797
+ * @param {string} src The URL or path of the source file to load.
1798
+ * @param {(result: string) => void} success
1799
+ * @param {(reason: string) => void} error
1800
+ */
1801
+ function loadFile(src, success, error) {
1802
+ var xhr = new XMLHttpRequest();
1803
+ xhr.open('GET', src, true);
1804
+ xhr.onreadystatechange = function () {
1805
+ if (xhr.readyState == 4) {
1806
+ if (xhr.status < 400 && xhr.responseText) {
1807
+ success(xhr.responseText);
1808
+ } else {
1809
+ if (xhr.status >= 400) {
1810
+ error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
1811
+ } else {
1812
+ error(FAILURE_EMPTY_MESSAGE);
1813
+ }
1814
+ }
1815
+ }
1816
+ };
1817
+ xhr.send(null);
1818
+ }
1819
+
1820
+ /**
1821
+ * Parses the given range.
1822
+ *
1823
+ * This returns a range with inclusive ends.
1824
+ *
1825
+ * @param {string | null | undefined} range
1826
+ * @returns {[number, number | undefined] | undefined}
1827
+ */
1828
+ function parseRange(range) {
1829
+ var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || '');
1830
+ if (m) {
1831
+ var start = Number(m[1]);
1832
+ var comma = m[2];
1833
+ var end = m[3];
1834
+
1835
+ if (!comma) {
1836
+ return [start, start];
1837
+ }
1838
+ if (!end) {
1839
+ return [start, undefined];
1840
+ }
1841
+ return [start, Number(end)];
1842
+ }
1843
+ return undefined;
1844
+ }
1845
+
1846
+ Prism.hooks.add('before-highlightall', function (env) {
1847
+ env.selector += ', ' + SELECTOR;
1848
+ });
1849
+
1850
+ Prism.hooks.add('before-sanity-check', function (env) {
1851
+ var pre = /** @type {HTMLPreElement} */ (env.element);
1852
+ if (pre.matches(SELECTOR)) {
1853
+ env.code = ''; // fast-path the whole thing and go to complete
1854
+
1855
+ pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading
1856
+
1857
+ // add code element with loading message
1858
+ var code = pre.appendChild(document.createElement('CODE'));
1859
+ code.textContent = LOADING_MESSAGE;
1860
+
1861
+ var src = pre.getAttribute('data-src');
1862
+
1863
+ var language = env.language;
1864
+ if (language === 'none') {
1865
+ // the language might be 'none' because there is no language set;
1866
+ // in this case, we want to use the extension as the language
1867
+ var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
1868
+ language = EXTENSIONS[extension] || extension;
1869
+ }
1870
+
1871
+ // set language classes
1872
+ Prism.util.setLanguage(code, language);
1873
+ Prism.util.setLanguage(pre, language);
1874
+
1875
+ // preload the language
1876
+ var autoloader = Prism.plugins.autoloader;
1877
+ if (autoloader) {
1878
+ autoloader.loadLanguages(language);
1879
+ }
1880
+
1881
+ // load file
1882
+ loadFile(
1883
+ src,
1884
+ function (text) {
1885
+ // mark as loaded
1886
+ pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
1887
+
1888
+ // handle data-range
1889
+ var range = parseRange(pre.getAttribute('data-range'));
1890
+ if (range) {
1891
+ var lines = text.split(/\r\n?|\n/g);
1892
+
1893
+ // the range is one-based and inclusive on both ends
1894
+ var start = range[0];
1895
+ var end = range[1] == null ? lines.length : range[1];
1896
+
1897
+ if (start < 0) { start += lines.length; }
1898
+ start = Math.max(0, Math.min(start - 1, lines.length));
1899
+ if (end < 0) { end += lines.length; }
1900
+ end = Math.max(0, Math.min(end, lines.length));
1901
+
1902
+ text = lines.slice(start, end).join('\n');
1903
+
1904
+ // add data-start for line numbers
1905
+ if (!pre.hasAttribute('data-start')) {
1906
+ pre.setAttribute('data-start', String(start + 1));
1907
+ }
1908
+ }
1909
+
1910
+ // highlight code
1911
+ code.textContent = text;
1912
+ Prism.highlightElement(code);
1913
+ },
1914
+ function (error) {
1915
+ // mark as failed
1916
+ pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
1917
+
1918
+ code.textContent = error;
1919
+ }
1920
+ );
1921
+ }
1922
+ });
1923
+
1924
+ Prism.plugins.fileHighlight = {
1925
+ /**
1926
+ * Executes the File Highlight plugin for all matching `pre` elements under the given container.
1927
+ *
1928
+ * Note: Elements which are already loaded or currently loading will not be touched by this method.
1929
+ *
1930
+ * @param {ParentNode} [container=document]
1931
+ */
1932
+ highlight: function highlight(container) {
1933
+ var elements = (container || document).querySelectorAll(SELECTOR);
1934
+
1935
+ for (var i = 0, element; (element = elements[i++]);) {
1936
+ Prism.highlightElement(element);
1937
+ }
1938
+ }
1939
+ };
1940
+
1941
+ var logged = false;
1942
+ /** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */
1943
+ Prism.fileHighlight = function () {
1944
+ if (!logged) {
1945
+ console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.');
1946
+ logged = true;
1947
+ }
1948
+ Prism.plugins.fileHighlight.highlight.apply(this, arguments);
1949
+ };
1950
+
1951
+ }());
1952
+ } (prism));
1953
+
1954
+ var prismExports = prism.exports;
1955
+ var Prism = /*@__PURE__*/getDefaultExportFromCjs(prismExports);
1956
+
1957
+ var css = "code[class*=language-],pre[class*=language-]{word-wrap:normal;background:none;color:#ccc;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:1em;-webkit-hyphens:none;hyphens:none;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;text-align:left;white-space:pre;word-break:normal;word-spacing:normal}pre[class*=language-]{margin:.5em 0;overflow:auto;padding:1em}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{border-radius:.3em;padding:.1em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}";
1958
+ n(css,{});
1959
+
1960
+ export { Prism as P };
1961
+ //# sourceMappingURL=prism-tomorrow-ZUb2Ikm9.js.map