@kg-ui/kg-ui-plus 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +39 -0
  2. package/dist/es/KgCopilot/CopiContent/AnswerHead.vue.mjs +16 -0
  3. package/dist/es/KgCopilot/CopiContent/AnswerHead.vue2.mjs +4 -0
  4. package/dist/es/KgCopilot/CopiContent/UserHead.vue.mjs +26 -0
  5. package/dist/es/KgCopilot/CopiContent/UserHead.vue2.mjs +4 -0
  6. package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue.mjs +7 -0
  7. package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue2.mjs +49 -0
  8. package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue3.mjs +4 -0
  9. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue.mjs +7 -0
  10. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue2.mjs +94 -0
  11. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue3.mjs +4 -0
  12. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue.mjs +7 -0
  13. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue2.mjs +33 -0
  14. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue3.mjs +4 -0
  15. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue.mjs +7 -0
  16. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue2.mjs +140 -0
  17. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue3.mjs +4 -0
  18. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue.mjs +7 -0
  19. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue2.mjs +131 -0
  20. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue3.mjs +4 -0
  21. package/dist/es/KgCopilot/CopiFooter/index.vue.mjs +7 -0
  22. package/dist/es/KgCopilot/CopiFooter/index.vue2.mjs +21 -0
  23. package/dist/es/KgCopilot/CopiFooter/index.vue3.mjs +4 -0
  24. package/dist/es/KgCopilot/dialogue.vue.mjs +7 -0
  25. package/dist/es/KgCopilot/dialogue.vue2.mjs +131 -0
  26. package/dist/es/KgCopilot/dialogue.vue3.mjs +4 -0
  27. package/dist/es/KgCopilot/index.vue.mjs +7 -0
  28. package/dist/es/KgCopilot/index.vue2.mjs +49 -0
  29. package/dist/es/KgCopilot/index.vue3.mjs +4 -0
  30. package/dist/es/KgCopilot/mdInCode.mjs +56 -0
  31. package/dist/es/KgCopilot/readMd.vue.mjs +7 -0
  32. package/dist/es/KgCopilot/readMd.vue2.mjs +87 -0
  33. package/dist/es/KgCopilot/readMd.vue3.mjs +4 -0
  34. package/dist/es/ReIcon/index.mjs +11 -0
  35. package/dist/es/ReIcon/src/iconfont.mjs +46 -0
  36. package/dist/es/ReIcon/src/iconifyIconOffline.mjs +30 -0
  37. package/dist/es/ReIcon/src/iconifyIconOnline.mjs +29 -0
  38. package/dist/es/_virtual/___vite-browser-external.mjs +6 -0
  39. package/dist/es/_virtual/__vite-browser-external.mjs +4 -0
  40. package/dist/es/_virtual/_commonjsHelpers.mjs +34 -0
  41. package/dist/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
  42. package/dist/es/_virtual/index.mjs +13 -0
  43. package/dist/es/api/project.mjs +51 -0
  44. package/dist/es/directives/heighlight/index.mjs +69 -0
  45. package/dist/es/directives/index.mjs +4 -0
  46. package/dist/es/home/LFilter/FilterArea.vue.mjs +7 -0
  47. package/dist/es/home/LFilter/FilterArea.vue2.mjs +507 -0
  48. package/dist/es/home/LFilter/FilterArea.vue3.mjs +4 -0
  49. package/dist/es/home/LFilter/FilterHead.vue.mjs +129 -0
  50. package/dist/es/home/LFilter/FilterHead.vue2.mjs +4 -0
  51. package/dist/es/home/LFilter/FilterItem.vue.mjs +7 -0
  52. package/dist/es/home/LFilter/FilterItem.vue2.mjs +114 -0
  53. package/dist/es/home/LFilter/FilterItem.vue3.mjs +4 -0
  54. package/dist/es/home/LFilter/FilterItemIcon.vue.mjs +7 -0
  55. package/dist/es/home/LFilter/FilterItemIcon.vue2.mjs +171 -0
  56. package/dist/es/home/LFilter/FilterItemIcon.vue3.mjs +4 -0
  57. package/dist/es/home/LFilter/index.vue.mjs +17 -0
  58. package/dist/es/home/LFilter/index.vue2.mjs +4 -0
  59. package/dist/es/home/LProject/index.vue.mjs +7 -0
  60. package/dist/es/home/LProject/index.vue2.mjs +70 -0
  61. package/dist/es/home/LProject/index.vue3.mjs +4 -0
  62. package/dist/es/home/index.vue.mjs +7 -0
  63. package/dist/es/home/index.vue2.mjs +80 -0
  64. package/dist/es/home/index.vue3.mjs +4 -0
  65. package/dist/es/index.mjs +36 -0
  66. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/check.mjs +8 -0
  67. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/circle-plus.mjs +8 -0
  68. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/close.mjs +8 -0
  69. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/microphone.mjs +8 -0
  70. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/paperclip.mjs +8 -0
  71. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/promotion.mjs +8 -0
  72. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/upload.mjs +8 -0
  73. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/copy-simple.mjs +8 -0
  74. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/speaker-high-light.mjs +8 -0
  75. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/thumbs-down-thin.mjs +8 -0
  76. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/thumbs-up-thin.mjs +8 -0
  77. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/warning-bold.mjs +8 -0
  78. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/add-line.mjs +8 -0
  79. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/arrow-down-s-line.mjs +8 -0
  80. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/arrow-up-s-line.mjs +8 -0
  81. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/check-fill.mjs +8 -0
  82. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/download-line.mjs +8 -0
  83. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/more-2-fill.mjs +8 -0
  84. package/dist/es/node_modules/.pnpm/@iconify_vue@4.0.0_vue@3.2.45/node_modules/@iconify/vue/dist/iconify.mjs +1702 -0
  85. package/dist/es/node_modules/.pnpm/@iconify_vue@4.0.0_vue@3.2.45/node_modules/@iconify/vue/dist/offline.mjs +436 -0
  86. package/dist/es/node_modules/.pnpm/@pureadmin_utils@1.8.5_vue@3.2.45/node_modules/@pureadmin/utils/dist/index.mjs +70 -0
  87. package/dist/es/node_modules/.pnpm/call-bind@1.0.7/node_modules/call-bind/callBound.mjs +16 -0
  88. package/dist/es/node_modules/.pnpm/call-bind@1.0.7/node_modules/call-bind/index.mjs +36 -0
  89. package/dist/es/node_modules/.pnpm/define-data-property@1.1.4/node_modules/define-data-property/index.mjs +48 -0
  90. package/dist/es/node_modules/.pnpm/dompurify@3.0.10/node_modules/dompurify/dist/purify.es.mjs +949 -0
  91. package/dist/es/node_modules/.pnpm/es-define-property@1.0.0/node_modules/es-define-property/index.mjs +22 -0
  92. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/eval.mjs +4 -0
  93. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/index.mjs +4 -0
  94. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/range.mjs +4 -0
  95. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/ref.mjs +4 -0
  96. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/syntax.mjs +4 -0
  97. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/type.mjs +4 -0
  98. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/uri.mjs +4 -0
  99. package/dist/es/node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.mjs +72 -0
  100. package/dist/es/node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.mjs +6 -0
  101. package/dist/es/node_modules/.pnpm/get-intrinsic@1.2.4/node_modules/get-intrinsic/index.mjs +320 -0
  102. package/dist/es/node_modules/.pnpm/gopd@1.0.1/node_modules/gopd/index.mjs +14 -0
  103. package/dist/es/node_modules/.pnpm/has-property-descriptors@1.0.2/node_modules/has-property-descriptors/index.mjs +19 -0
  104. package/dist/es/node_modules/.pnpm/has-proto@1.0.3/node_modules/has-proto/index.mjs +11 -0
  105. package/dist/es/node_modules/.pnpm/has-symbols@1.0.3/node_modules/has-symbols/index.mjs +21 -0
  106. package/dist/es/node_modules/.pnpm/has-symbols@1.0.3/node_modules/has-symbols/shams.mjs +48 -0
  107. package/dist/es/node_modules/.pnpm/hasown@2.0.2/node_modules/hasown/index.mjs +8 -0
  108. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/core.mjs +5 -0
  109. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/apache.mjs +91 -0
  110. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/bash.mjs +377 -0
  111. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/basic.mjs +221 -0
  112. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/c.mjs +280 -0
  113. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/css.mjs +732 -0
  114. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dart.mjs +247 -0
  115. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/django.mjs +47 -0
  116. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dns.mjs +71 -0
  117. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dos.mjs +160 -0
  118. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dust.mjs +38 -0
  119. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/erlang.mjs +176 -0
  120. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/go.mjs +135 -0
  121. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/http.mjs +89 -0
  122. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/java.mjs +254 -0
  123. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/javascript.mjs +698 -0
  124. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/json.mjs +40 -0
  125. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/markdown.mjs +227 -0
  126. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/nginx.mjs +144 -0
  127. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/php.mjs +589 -0
  128. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/python.mjs +414 -0
  129. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/ruby.mjs +414 -0
  130. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/stylus.mjs +766 -0
  131. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/swift.mjs +832 -0
  132. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/typescript.mjs +788 -0
  133. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/xml.mjs +227 -0
  134. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/lib/core.mjs +1580 -0
  135. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/styles/paraiso-light.css.mjs +4 -0
  136. package/dist/es/node_modules/.pnpm/marked@12.0.1/node_modules/marked/lib/marked.esm.mjs +2045 -0
  137. package/dist/es/node_modules/.pnpm/object-inspect@1.13.1/node_modules/object-inspect/index.mjs +514 -0
  138. package/dist/es/node_modules/.pnpm/pinyin-match@1.2.4/node_modules/pinyin-match/es/main.mjs +124 -0
  139. package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/formats.mjs +22 -0
  140. package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/index.mjs +14 -0
  141. package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/parse.mjs +199 -0
  142. package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/stringify.mjs +262 -0
  143. package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/utils.mjs +196 -0
  144. package/dist/es/node_modules/.pnpm/set-function-length@1.2.2/node_modules/set-function-length/index.mjs +54 -0
  145. package/dist/es/node_modules/.pnpm/side-channel@1.0.6/node_modules/side-channel/index.mjs +115 -0
  146. package/dist/es/store/index.mjs +8 -0
  147. package/dist/es/store/modules/copilot.mjs +108 -0
  148. package/dist/es/store/modules/filters.mjs +346 -0
  149. package/dist/es/store/modules/types.mjs +19 -0
  150. package/dist/es/style/index.scss.mjs +4 -0
  151. package/dist/es/style/tailwind.css.mjs +4 -0
  152. package/dist/es/style.css +1 -0
  153. package/dist/es/utils/home.mjs +129 -0
  154. package/dist/es/utils/http/index.mjs +90 -0
  155. package/dist/es/utils/message.mjs +42 -0
  156. package/package.json +124 -0
@@ -0,0 +1,1580 @@
1
+ function deepFreeze(obj) {
2
+ if (obj instanceof Map) {
3
+ obj.clear = obj.delete = obj.set = function() {
4
+ throw new Error("map is read-only");
5
+ };
6
+ } else if (obj instanceof Set) {
7
+ obj.add = obj.clear = obj.delete = function() {
8
+ throw new Error("set is read-only");
9
+ };
10
+ }
11
+ Object.freeze(obj);
12
+ Object.getOwnPropertyNames(obj).forEach((name) => {
13
+ const prop = obj[name];
14
+ const type = typeof prop;
15
+ if ((type === "object" || type === "function") && !Object.isFrozen(prop)) {
16
+ deepFreeze(prop);
17
+ }
18
+ });
19
+ return obj;
20
+ }
21
+ class Response {
22
+ /**
23
+ * @param {CompiledMode} mode
24
+ */
25
+ constructor(mode) {
26
+ if (mode.data === void 0)
27
+ mode.data = {};
28
+ this.data = mode.data;
29
+ this.isMatchIgnored = false;
30
+ }
31
+ ignoreMatch() {
32
+ this.isMatchIgnored = true;
33
+ }
34
+ }
35
+ function escapeHTML(value) {
36
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
37
+ }
38
+ function inherit$1(original, ...objects) {
39
+ const result = /* @__PURE__ */ Object.create(null);
40
+ for (const key in original) {
41
+ result[key] = original[key];
42
+ }
43
+ objects.forEach(function(obj) {
44
+ for (const key in obj) {
45
+ result[key] = obj[key];
46
+ }
47
+ });
48
+ return (
49
+ /** @type {T} */
50
+ result
51
+ );
52
+ }
53
+ const SPAN_CLOSE = "</span>";
54
+ const emitsWrappingTags = (node) => {
55
+ return !!node.scope;
56
+ };
57
+ const scopeToCSSClass = (name, { prefix }) => {
58
+ if (name.startsWith("language:")) {
59
+ return name.replace("language:", "language-");
60
+ }
61
+ if (name.includes(".")) {
62
+ const pieces = name.split(".");
63
+ return [
64
+ `${prefix}${pieces.shift()}`,
65
+ ...pieces.map((x, i) => `${x}${"_".repeat(i + 1)}`)
66
+ ].join(" ");
67
+ }
68
+ return `${prefix}${name}`;
69
+ };
70
+ class HTMLRenderer {
71
+ /**
72
+ * Creates a new HTMLRenderer
73
+ *
74
+ * @param {Tree} parseTree - the parse tree (must support `walk` API)
75
+ * @param {{classPrefix: string}} options
76
+ */
77
+ constructor(parseTree, options) {
78
+ this.buffer = "";
79
+ this.classPrefix = options.classPrefix;
80
+ parseTree.walk(this);
81
+ }
82
+ /**
83
+ * Adds texts to the output stream
84
+ *
85
+ * @param {string} text */
86
+ addText(text) {
87
+ this.buffer += escapeHTML(text);
88
+ }
89
+ /**
90
+ * Adds a node open to the output stream (if needed)
91
+ *
92
+ * @param {Node} node */
93
+ openNode(node) {
94
+ if (!emitsWrappingTags(node))
95
+ return;
96
+ const className = scopeToCSSClass(
97
+ node.scope,
98
+ { prefix: this.classPrefix }
99
+ );
100
+ this.span(className);
101
+ }
102
+ /**
103
+ * Adds a node close to the output stream (if needed)
104
+ *
105
+ * @param {Node} node */
106
+ closeNode(node) {
107
+ if (!emitsWrappingTags(node))
108
+ return;
109
+ this.buffer += SPAN_CLOSE;
110
+ }
111
+ /**
112
+ * returns the accumulated buffer
113
+ */
114
+ value() {
115
+ return this.buffer;
116
+ }
117
+ // helpers
118
+ /**
119
+ * Builds a span element
120
+ *
121
+ * @param {string} className */
122
+ span(className) {
123
+ this.buffer += `<span class="${className}">`;
124
+ }
125
+ }
126
+ const newNode = (opts = {}) => {
127
+ const result = { children: [] };
128
+ Object.assign(result, opts);
129
+ return result;
130
+ };
131
+ class TokenTree {
132
+ constructor() {
133
+ this.rootNode = newNode();
134
+ this.stack = [this.rootNode];
135
+ }
136
+ get top() {
137
+ return this.stack[this.stack.length - 1];
138
+ }
139
+ get root() {
140
+ return this.rootNode;
141
+ }
142
+ /** @param {Node} node */
143
+ add(node) {
144
+ this.top.children.push(node);
145
+ }
146
+ /** @param {string} scope */
147
+ openNode(scope) {
148
+ const node = newNode({ scope });
149
+ this.add(node);
150
+ this.stack.push(node);
151
+ }
152
+ closeNode() {
153
+ if (this.stack.length > 1) {
154
+ return this.stack.pop();
155
+ }
156
+ return void 0;
157
+ }
158
+ closeAllNodes() {
159
+ while (this.closeNode())
160
+ ;
161
+ }
162
+ toJSON() {
163
+ return JSON.stringify(this.rootNode, null, 4);
164
+ }
165
+ /**
166
+ * @typedef { import("./html_renderer").Renderer } Renderer
167
+ * @param {Renderer} builder
168
+ */
169
+ walk(builder) {
170
+ return this.constructor._walk(builder, this.rootNode);
171
+ }
172
+ /**
173
+ * @param {Renderer} builder
174
+ * @param {Node} node
175
+ */
176
+ static _walk(builder, node) {
177
+ if (typeof node === "string") {
178
+ builder.addText(node);
179
+ } else if (node.children) {
180
+ builder.openNode(node);
181
+ node.children.forEach((child) => this._walk(builder, child));
182
+ builder.closeNode(node);
183
+ }
184
+ return builder;
185
+ }
186
+ /**
187
+ * @param {Node} node
188
+ */
189
+ static _collapse(node) {
190
+ if (typeof node === "string")
191
+ return;
192
+ if (!node.children)
193
+ return;
194
+ if (node.children.every((el) => typeof el === "string")) {
195
+ node.children = [node.children.join("")];
196
+ } else {
197
+ node.children.forEach((child) => {
198
+ TokenTree._collapse(child);
199
+ });
200
+ }
201
+ }
202
+ }
203
+ class TokenTreeEmitter extends TokenTree {
204
+ /**
205
+ * @param {*} options
206
+ */
207
+ constructor(options) {
208
+ super();
209
+ this.options = options;
210
+ }
211
+ /**
212
+ * @param {string} text
213
+ */
214
+ addText(text) {
215
+ if (text === "") {
216
+ return;
217
+ }
218
+ this.add(text);
219
+ }
220
+ /** @param {string} scope */
221
+ startScope(scope) {
222
+ this.openNode(scope);
223
+ }
224
+ endScope() {
225
+ this.closeNode();
226
+ }
227
+ /**
228
+ * @param {Emitter & {root: DataNode}} emitter
229
+ * @param {string} name
230
+ */
231
+ __addSublanguage(emitter, name) {
232
+ const node = emitter.root;
233
+ if (name)
234
+ node.scope = `language:${name}`;
235
+ this.add(node);
236
+ }
237
+ toHTML() {
238
+ const renderer = new HTMLRenderer(this, this.options);
239
+ return renderer.value();
240
+ }
241
+ finalize() {
242
+ this.closeAllNodes();
243
+ return true;
244
+ }
245
+ }
246
+ function source(re) {
247
+ if (!re)
248
+ return null;
249
+ if (typeof re === "string")
250
+ return re;
251
+ return re.source;
252
+ }
253
+ function lookahead(re) {
254
+ return concat("(?=", re, ")");
255
+ }
256
+ function anyNumberOfTimes(re) {
257
+ return concat("(?:", re, ")*");
258
+ }
259
+ function optional(re) {
260
+ return concat("(?:", re, ")?");
261
+ }
262
+ function concat(...args) {
263
+ const joined = args.map((x) => source(x)).join("");
264
+ return joined;
265
+ }
266
+ function stripOptionsFromArgs(args) {
267
+ const opts = args[args.length - 1];
268
+ if (typeof opts === "object" && opts.constructor === Object) {
269
+ args.splice(args.length - 1, 1);
270
+ return opts;
271
+ } else {
272
+ return {};
273
+ }
274
+ }
275
+ function either(...args) {
276
+ const opts = stripOptionsFromArgs(args);
277
+ const joined = "(" + (opts.capture ? "" : "?:") + args.map((x) => source(x)).join("|") + ")";
278
+ return joined;
279
+ }
280
+ function countMatchGroups(re) {
281
+ return new RegExp(re.toString() + "|").exec("").length - 1;
282
+ }
283
+ function startsWith(re, lexeme) {
284
+ const match = re && re.exec(lexeme);
285
+ return match && match.index === 0;
286
+ }
287
+ const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
288
+ function _rewriteBackreferences(regexps, { joinWith }) {
289
+ let numCaptures = 0;
290
+ return regexps.map((regex) => {
291
+ numCaptures += 1;
292
+ const offset = numCaptures;
293
+ let re = source(regex);
294
+ let out = "";
295
+ while (re.length > 0) {
296
+ const match = BACKREF_RE.exec(re);
297
+ if (!match) {
298
+ out += re;
299
+ break;
300
+ }
301
+ out += re.substring(0, match.index);
302
+ re = re.substring(match.index + match[0].length);
303
+ if (match[0][0] === "\\" && match[1]) {
304
+ out += "\\" + String(Number(match[1]) + offset);
305
+ } else {
306
+ out += match[0];
307
+ if (match[0] === "(") {
308
+ numCaptures++;
309
+ }
310
+ }
311
+ }
312
+ return out;
313
+ }).map((re) => `(${re})`).join(joinWith);
314
+ }
315
+ const MATCH_NOTHING_RE = /\b\B/;
316
+ const IDENT_RE = "[a-zA-Z]\\w*";
317
+ const UNDERSCORE_IDENT_RE = "[a-zA-Z_]\\w*";
318
+ const NUMBER_RE = "\\b\\d+(\\.\\d+)?";
319
+ const C_NUMBER_RE = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";
320
+ const BINARY_NUMBER_RE = "\\b(0b[01]+)";
321
+ const RE_STARTERS_RE = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";
322
+ const SHEBANG = (opts = {}) => {
323
+ const beginShebang = /^#![ ]*\//;
324
+ if (opts.binary) {
325
+ opts.begin = concat(
326
+ beginShebang,
327
+ /.*\b/,
328
+ opts.binary,
329
+ /\b.*/
330
+ );
331
+ }
332
+ return inherit$1({
333
+ scope: "meta",
334
+ begin: beginShebang,
335
+ end: /$/,
336
+ relevance: 0,
337
+ /** @type {ModeCallback} */
338
+ "on:begin": (m, resp) => {
339
+ if (m.index !== 0)
340
+ resp.ignoreMatch();
341
+ }
342
+ }, opts);
343
+ };
344
+ const BACKSLASH_ESCAPE = {
345
+ begin: "\\\\[\\s\\S]",
346
+ relevance: 0
347
+ };
348
+ const APOS_STRING_MODE = {
349
+ scope: "string",
350
+ begin: "'",
351
+ end: "'",
352
+ illegal: "\\n",
353
+ contains: [BACKSLASH_ESCAPE]
354
+ };
355
+ const QUOTE_STRING_MODE = {
356
+ scope: "string",
357
+ begin: '"',
358
+ end: '"',
359
+ illegal: "\\n",
360
+ contains: [BACKSLASH_ESCAPE]
361
+ };
362
+ const PHRASAL_WORDS_MODE = {
363
+ begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
364
+ };
365
+ const COMMENT = function(begin, end, modeOptions = {}) {
366
+ const mode = inherit$1(
367
+ {
368
+ scope: "comment",
369
+ begin,
370
+ end,
371
+ contains: []
372
+ },
373
+ modeOptions
374
+ );
375
+ mode.contains.push({
376
+ scope: "doctag",
377
+ // hack to avoid the space from being included. the space is necessary to
378
+ // match here to prevent the plain text rule below from gobbling up doctags
379
+ begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
380
+ end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,
381
+ excludeBegin: true,
382
+ relevance: 0
383
+ });
384
+ const ENGLISH_WORD = either(
385
+ // list of common 1 and 2 letter words in English
386
+ "I",
387
+ "a",
388
+ "is",
389
+ "so",
390
+ "us",
391
+ "to",
392
+ "at",
393
+ "if",
394
+ "in",
395
+ "it",
396
+ "on",
397
+ // note: this is not an exhaustive list of contractions, just popular ones
398
+ /[A-Za-z]+['](d|ve|re|ll|t|s|n)/,
399
+ // contractions - can't we'd they're let's, etc
400
+ /[A-Za-z]+[-][a-z]+/,
401
+ // `no-way`, etc.
402
+ /[A-Za-z][a-z]{2,}/
403
+ // allow capitalized words at beginning of sentences
404
+ );
405
+ mode.contains.push(
406
+ {
407
+ // TODO: how to include ", (, ) without breaking grammars that use these for
408
+ // comment delimiters?
409
+ // begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/
410
+ // ---
411
+ // this tries to find sequences of 3 english words in a row (without any
412
+ // "programming" type syntax) this gives us a strong signal that we've
413
+ // TRULY found a comment - vs perhaps scanning with the wrong language.
414
+ // It's possible to find something that LOOKS like the start of the
415
+ // comment - but then if there is no readable text - good chance it is a
416
+ // false match and not a comment.
417
+ //
418
+ // for a visual example please see:
419
+ // https://github.com/highlightjs/highlight.js/issues/2827
420
+ begin: concat(
421
+ /[ ]+/,
422
+ // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */
423
+ "(",
424
+ ENGLISH_WORD,
425
+ /[.]?[:]?([.][ ]|[ ])/,
426
+ "){3}"
427
+ )
428
+ // look for 3 words in a row
429
+ }
430
+ );
431
+ return mode;
432
+ };
433
+ const C_LINE_COMMENT_MODE = COMMENT("//", "$");
434
+ const C_BLOCK_COMMENT_MODE = COMMENT("/\\*", "\\*/");
435
+ const HASH_COMMENT_MODE = COMMENT("#", "$");
436
+ const NUMBER_MODE = {
437
+ scope: "number",
438
+ begin: NUMBER_RE,
439
+ relevance: 0
440
+ };
441
+ const C_NUMBER_MODE = {
442
+ scope: "number",
443
+ begin: C_NUMBER_RE,
444
+ relevance: 0
445
+ };
446
+ const BINARY_NUMBER_MODE = {
447
+ scope: "number",
448
+ begin: BINARY_NUMBER_RE,
449
+ relevance: 0
450
+ };
451
+ const REGEXP_MODE = {
452
+ scope: "regexp",
453
+ begin: /\/(?=[^/\n]*\/)/,
454
+ end: /\/[gimuy]*/,
455
+ contains: [
456
+ BACKSLASH_ESCAPE,
457
+ {
458
+ begin: /\[/,
459
+ end: /\]/,
460
+ relevance: 0,
461
+ contains: [BACKSLASH_ESCAPE]
462
+ }
463
+ ]
464
+ };
465
+ const TITLE_MODE = {
466
+ scope: "title",
467
+ begin: IDENT_RE,
468
+ relevance: 0
469
+ };
470
+ const UNDERSCORE_TITLE_MODE = {
471
+ scope: "title",
472
+ begin: UNDERSCORE_IDENT_RE,
473
+ relevance: 0
474
+ };
475
+ const METHOD_GUARD = {
476
+ // excludes method names from keyword processing
477
+ begin: "\\.\\s*" + UNDERSCORE_IDENT_RE,
478
+ relevance: 0
479
+ };
480
+ const END_SAME_AS_BEGIN = function(mode) {
481
+ return Object.assign(
482
+ mode,
483
+ {
484
+ /** @type {ModeCallback} */
485
+ "on:begin": (m, resp) => {
486
+ resp.data._beginMatch = m[1];
487
+ },
488
+ /** @type {ModeCallback} */
489
+ "on:end": (m, resp) => {
490
+ if (resp.data._beginMatch !== m[1])
491
+ resp.ignoreMatch();
492
+ }
493
+ }
494
+ );
495
+ };
496
+ var MODES = /* @__PURE__ */ Object.freeze({
497
+ __proto__: null,
498
+ APOS_STRING_MODE,
499
+ BACKSLASH_ESCAPE,
500
+ BINARY_NUMBER_MODE,
501
+ BINARY_NUMBER_RE,
502
+ COMMENT,
503
+ C_BLOCK_COMMENT_MODE,
504
+ C_LINE_COMMENT_MODE,
505
+ C_NUMBER_MODE,
506
+ C_NUMBER_RE,
507
+ END_SAME_AS_BEGIN,
508
+ HASH_COMMENT_MODE,
509
+ IDENT_RE,
510
+ MATCH_NOTHING_RE,
511
+ METHOD_GUARD,
512
+ NUMBER_MODE,
513
+ NUMBER_RE,
514
+ PHRASAL_WORDS_MODE,
515
+ QUOTE_STRING_MODE,
516
+ REGEXP_MODE,
517
+ RE_STARTERS_RE,
518
+ SHEBANG,
519
+ TITLE_MODE,
520
+ UNDERSCORE_IDENT_RE,
521
+ UNDERSCORE_TITLE_MODE
522
+ });
523
+ function skipIfHasPrecedingDot(match, response) {
524
+ const before = match.input[match.index - 1];
525
+ if (before === ".") {
526
+ response.ignoreMatch();
527
+ }
528
+ }
529
+ function scopeClassName(mode, _parent) {
530
+ if (mode.className !== void 0) {
531
+ mode.scope = mode.className;
532
+ delete mode.className;
533
+ }
534
+ }
535
+ function beginKeywords(mode, parent) {
536
+ if (!parent)
537
+ return;
538
+ if (!mode.beginKeywords)
539
+ return;
540
+ mode.begin = "\\b(" + mode.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)";
541
+ mode.__beforeBegin = skipIfHasPrecedingDot;
542
+ mode.keywords = mode.keywords || mode.beginKeywords;
543
+ delete mode.beginKeywords;
544
+ if (mode.relevance === void 0)
545
+ mode.relevance = 0;
546
+ }
547
+ function compileIllegal(mode, _parent) {
548
+ if (!Array.isArray(mode.illegal))
549
+ return;
550
+ mode.illegal = either(...mode.illegal);
551
+ }
552
+ function compileMatch(mode, _parent) {
553
+ if (!mode.match)
554
+ return;
555
+ if (mode.begin || mode.end)
556
+ throw new Error("begin & end are not supported with match");
557
+ mode.begin = mode.match;
558
+ delete mode.match;
559
+ }
560
+ function compileRelevance(mode, _parent) {
561
+ if (mode.relevance === void 0)
562
+ mode.relevance = 1;
563
+ }
564
+ const beforeMatchExt = (mode, parent) => {
565
+ if (!mode.beforeMatch)
566
+ return;
567
+ if (mode.starts)
568
+ throw new Error("beforeMatch cannot be used with starts");
569
+ const originalMode = Object.assign({}, mode);
570
+ Object.keys(mode).forEach((key) => {
571
+ delete mode[key];
572
+ });
573
+ mode.keywords = originalMode.keywords;
574
+ mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin));
575
+ mode.starts = {
576
+ relevance: 0,
577
+ contains: [
578
+ Object.assign(originalMode, { endsParent: true })
579
+ ]
580
+ };
581
+ mode.relevance = 0;
582
+ delete originalMode.beforeMatch;
583
+ };
584
+ const COMMON_KEYWORDS = [
585
+ "of",
586
+ "and",
587
+ "for",
588
+ "in",
589
+ "not",
590
+ "or",
591
+ "if",
592
+ "then",
593
+ "parent",
594
+ // common variable name
595
+ "list",
596
+ // common variable name
597
+ "value"
598
+ // common variable name
599
+ ];
600
+ const DEFAULT_KEYWORD_SCOPE = "keyword";
601
+ function compileKeywords(rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) {
602
+ const compiledKeywords = /* @__PURE__ */ Object.create(null);
603
+ if (typeof rawKeywords === "string") {
604
+ compileList(scopeName, rawKeywords.split(" "));
605
+ } else if (Array.isArray(rawKeywords)) {
606
+ compileList(scopeName, rawKeywords);
607
+ } else {
608
+ Object.keys(rawKeywords).forEach(function(scopeName2) {
609
+ Object.assign(
610
+ compiledKeywords,
611
+ compileKeywords(rawKeywords[scopeName2], caseInsensitive, scopeName2)
612
+ );
613
+ });
614
+ }
615
+ return compiledKeywords;
616
+ function compileList(scopeName2, keywordList) {
617
+ if (caseInsensitive) {
618
+ keywordList = keywordList.map((x) => x.toLowerCase());
619
+ }
620
+ keywordList.forEach(function(keyword) {
621
+ const pair = keyword.split("|");
622
+ compiledKeywords[pair[0]] = [scopeName2, scoreForKeyword(pair[0], pair[1])];
623
+ });
624
+ }
625
+ }
626
+ function scoreForKeyword(keyword, providedScore) {
627
+ if (providedScore) {
628
+ return Number(providedScore);
629
+ }
630
+ return commonKeyword(keyword) ? 0 : 1;
631
+ }
632
+ function commonKeyword(keyword) {
633
+ return COMMON_KEYWORDS.includes(keyword.toLowerCase());
634
+ }
635
+ const seenDeprecations = {};
636
+ const error = (message) => {
637
+ console.error(message);
638
+ };
639
+ const warn = (message, ...args) => {
640
+ console.log(`WARN: ${message}`, ...args);
641
+ };
642
+ const deprecated = (version2, message) => {
643
+ if (seenDeprecations[`${version2}/${message}`])
644
+ return;
645
+ console.log(`Deprecated as of ${version2}. ${message}`);
646
+ seenDeprecations[`${version2}/${message}`] = true;
647
+ };
648
+ const MultiClassError = new Error();
649
+ function remapScopeNames(mode, regexes, { key }) {
650
+ let offset = 0;
651
+ const scopeNames = mode[key];
652
+ const emit = {};
653
+ const positions = {};
654
+ for (let i = 1; i <= regexes.length; i++) {
655
+ positions[i + offset] = scopeNames[i];
656
+ emit[i + offset] = true;
657
+ offset += countMatchGroups(regexes[i - 1]);
658
+ }
659
+ mode[key] = positions;
660
+ mode[key]._emit = emit;
661
+ mode[key]._multi = true;
662
+ }
663
+ function beginMultiClass(mode) {
664
+ if (!Array.isArray(mode.begin))
665
+ return;
666
+ if (mode.skip || mode.excludeBegin || mode.returnBegin) {
667
+ error("skip, excludeBegin, returnBegin not compatible with beginScope: {}");
668
+ throw MultiClassError;
669
+ }
670
+ if (typeof mode.beginScope !== "object" || mode.beginScope === null) {
671
+ error("beginScope must be object");
672
+ throw MultiClassError;
673
+ }
674
+ remapScopeNames(mode, mode.begin, { key: "beginScope" });
675
+ mode.begin = _rewriteBackreferences(mode.begin, { joinWith: "" });
676
+ }
677
+ function endMultiClass(mode) {
678
+ if (!Array.isArray(mode.end))
679
+ return;
680
+ if (mode.skip || mode.excludeEnd || mode.returnEnd) {
681
+ error("skip, excludeEnd, returnEnd not compatible with endScope: {}");
682
+ throw MultiClassError;
683
+ }
684
+ if (typeof mode.endScope !== "object" || mode.endScope === null) {
685
+ error("endScope must be object");
686
+ throw MultiClassError;
687
+ }
688
+ remapScopeNames(mode, mode.end, { key: "endScope" });
689
+ mode.end = _rewriteBackreferences(mode.end, { joinWith: "" });
690
+ }
691
+ function scopeSugar(mode) {
692
+ if (mode.scope && typeof mode.scope === "object" && mode.scope !== null) {
693
+ mode.beginScope = mode.scope;
694
+ delete mode.scope;
695
+ }
696
+ }
697
+ function MultiClass(mode) {
698
+ scopeSugar(mode);
699
+ if (typeof mode.beginScope === "string") {
700
+ mode.beginScope = { _wrap: mode.beginScope };
701
+ }
702
+ if (typeof mode.endScope === "string") {
703
+ mode.endScope = { _wrap: mode.endScope };
704
+ }
705
+ beginMultiClass(mode);
706
+ endMultiClass(mode);
707
+ }
708
+ function compileLanguage(language) {
709
+ function langRe(value, global) {
710
+ return new RegExp(
711
+ source(value),
712
+ "m" + (language.case_insensitive ? "i" : "") + (language.unicodeRegex ? "u" : "") + (global ? "g" : "")
713
+ );
714
+ }
715
+ class MultiRegex {
716
+ constructor() {
717
+ this.matchIndexes = {};
718
+ this.regexes = [];
719
+ this.matchAt = 1;
720
+ this.position = 0;
721
+ }
722
+ // @ts-ignore
723
+ addRule(re, opts) {
724
+ opts.position = this.position++;
725
+ this.matchIndexes[this.matchAt] = opts;
726
+ this.regexes.push([opts, re]);
727
+ this.matchAt += countMatchGroups(re) + 1;
728
+ }
729
+ compile() {
730
+ if (this.regexes.length === 0) {
731
+ this.exec = () => null;
732
+ }
733
+ const terminators = this.regexes.map((el) => el[1]);
734
+ this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: "|" }), true);
735
+ this.lastIndex = 0;
736
+ }
737
+ /** @param {string} s */
738
+ exec(s) {
739
+ this.matcherRe.lastIndex = this.lastIndex;
740
+ const match = this.matcherRe.exec(s);
741
+ if (!match) {
742
+ return null;
743
+ }
744
+ const i = match.findIndex((el, i2) => i2 > 0 && el !== void 0);
745
+ const matchData = this.matchIndexes[i];
746
+ match.splice(0, i);
747
+ return Object.assign(match, matchData);
748
+ }
749
+ }
750
+ class ResumableMultiRegex {
751
+ constructor() {
752
+ this.rules = [];
753
+ this.multiRegexes = [];
754
+ this.count = 0;
755
+ this.lastIndex = 0;
756
+ this.regexIndex = 0;
757
+ }
758
+ // @ts-ignore
759
+ getMatcher(index) {
760
+ if (this.multiRegexes[index])
761
+ return this.multiRegexes[index];
762
+ const matcher = new MultiRegex();
763
+ this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
764
+ matcher.compile();
765
+ this.multiRegexes[index] = matcher;
766
+ return matcher;
767
+ }
768
+ resumingScanAtSamePosition() {
769
+ return this.regexIndex !== 0;
770
+ }
771
+ considerAll() {
772
+ this.regexIndex = 0;
773
+ }
774
+ // @ts-ignore
775
+ addRule(re, opts) {
776
+ this.rules.push([re, opts]);
777
+ if (opts.type === "begin")
778
+ this.count++;
779
+ }
780
+ /** @param {string} s */
781
+ exec(s) {
782
+ const m = this.getMatcher(this.regexIndex);
783
+ m.lastIndex = this.lastIndex;
784
+ let result = m.exec(s);
785
+ if (this.resumingScanAtSamePosition()) {
786
+ if (result && result.index === this.lastIndex)
787
+ ;
788
+ else {
789
+ const m2 = this.getMatcher(0);
790
+ m2.lastIndex = this.lastIndex + 1;
791
+ result = m2.exec(s);
792
+ }
793
+ }
794
+ if (result) {
795
+ this.regexIndex += result.position + 1;
796
+ if (this.regexIndex === this.count) {
797
+ this.considerAll();
798
+ }
799
+ }
800
+ return result;
801
+ }
802
+ }
803
+ function buildModeRegex(mode) {
804
+ const mm = new ResumableMultiRegex();
805
+ mode.contains.forEach((term) => mm.addRule(term.begin, { rule: term, type: "begin" }));
806
+ if (mode.terminatorEnd) {
807
+ mm.addRule(mode.terminatorEnd, { type: "end" });
808
+ }
809
+ if (mode.illegal) {
810
+ mm.addRule(mode.illegal, { type: "illegal" });
811
+ }
812
+ return mm;
813
+ }
814
+ function compileMode(mode, parent) {
815
+ const cmode = (
816
+ /** @type CompiledMode */
817
+ mode
818
+ );
819
+ if (mode.isCompiled)
820
+ return cmode;
821
+ [
822
+ scopeClassName,
823
+ // do this early so compiler extensions generally don't have to worry about
824
+ // the distinction between match/begin
825
+ compileMatch,
826
+ MultiClass,
827
+ beforeMatchExt
828
+ ].forEach((ext) => ext(mode, parent));
829
+ language.compilerExtensions.forEach((ext) => ext(mode, parent));
830
+ mode.__beforeBegin = null;
831
+ [
832
+ beginKeywords,
833
+ // do this later so compiler extensions that come earlier have access to the
834
+ // raw array if they wanted to perhaps manipulate it, etc.
835
+ compileIllegal,
836
+ // default to 1 relevance if not specified
837
+ compileRelevance
838
+ ].forEach((ext) => ext(mode, parent));
839
+ mode.isCompiled = true;
840
+ let keywordPattern = null;
841
+ if (typeof mode.keywords === "object" && mode.keywords.$pattern) {
842
+ mode.keywords = Object.assign({}, mode.keywords);
843
+ keywordPattern = mode.keywords.$pattern;
844
+ delete mode.keywords.$pattern;
845
+ }
846
+ keywordPattern = keywordPattern || /\w+/;
847
+ if (mode.keywords) {
848
+ mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
849
+ }
850
+ cmode.keywordPatternRe = langRe(keywordPattern, true);
851
+ if (parent) {
852
+ if (!mode.begin)
853
+ mode.begin = /\B|\b/;
854
+ cmode.beginRe = langRe(cmode.begin);
855
+ if (!mode.end && !mode.endsWithParent)
856
+ mode.end = /\B|\b/;
857
+ if (mode.end)
858
+ cmode.endRe = langRe(cmode.end);
859
+ cmode.terminatorEnd = source(cmode.end) || "";
860
+ if (mode.endsWithParent && parent.terminatorEnd) {
861
+ cmode.terminatorEnd += (mode.end ? "|" : "") + parent.terminatorEnd;
862
+ }
863
+ }
864
+ if (mode.illegal)
865
+ cmode.illegalRe = langRe(
866
+ /** @type {RegExp | string} */
867
+ mode.illegal
868
+ );
869
+ if (!mode.contains)
870
+ mode.contains = [];
871
+ mode.contains = [].concat(...mode.contains.map(function(c) {
872
+ return expandOrCloneMode(c === "self" ? mode : c);
873
+ }));
874
+ mode.contains.forEach(function(c) {
875
+ compileMode(
876
+ /** @type Mode */
877
+ c,
878
+ cmode
879
+ );
880
+ });
881
+ if (mode.starts) {
882
+ compileMode(mode.starts, parent);
883
+ }
884
+ cmode.matcher = buildModeRegex(cmode);
885
+ return cmode;
886
+ }
887
+ if (!language.compilerExtensions)
888
+ language.compilerExtensions = [];
889
+ if (language.contains && language.contains.includes("self")) {
890
+ throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
891
+ }
892
+ language.classNameAliases = inherit$1(language.classNameAliases || {});
893
+ return compileMode(
894
+ /** @type Mode */
895
+ language
896
+ );
897
+ }
898
+ function dependencyOnParent(mode) {
899
+ if (!mode)
900
+ return false;
901
+ return mode.endsWithParent || dependencyOnParent(mode.starts);
902
+ }
903
+ function expandOrCloneMode(mode) {
904
+ if (mode.variants && !mode.cachedVariants) {
905
+ mode.cachedVariants = mode.variants.map(function(variant) {
906
+ return inherit$1(mode, { variants: null }, variant);
907
+ });
908
+ }
909
+ if (mode.cachedVariants) {
910
+ return mode.cachedVariants;
911
+ }
912
+ if (dependencyOnParent(mode)) {
913
+ return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null });
914
+ }
915
+ if (Object.isFrozen(mode)) {
916
+ return inherit$1(mode);
917
+ }
918
+ return mode;
919
+ }
920
+ var version = "11.9.0";
921
+ class HTMLInjectionError extends Error {
922
+ constructor(reason, html) {
923
+ super(reason);
924
+ this.name = "HTMLInjectionError";
925
+ this.html = html;
926
+ }
927
+ }
928
+ const escape = escapeHTML;
929
+ const inherit = inherit$1;
930
+ const NO_MATCH = Symbol("nomatch");
931
+ const MAX_KEYWORD_HITS = 7;
932
+ const HLJS = function(hljs) {
933
+ const languages = /* @__PURE__ */ Object.create(null);
934
+ const aliases = /* @__PURE__ */ Object.create(null);
935
+ const plugins = [];
936
+ let SAFE_MODE = true;
937
+ const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
938
+ const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: "Plain text", contains: [] };
939
+ let options = {
940
+ ignoreUnescapedHTML: false,
941
+ throwUnescapedHTML: false,
942
+ noHighlightRe: /^(no-?highlight)$/i,
943
+ languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
944
+ classPrefix: "hljs-",
945
+ cssSelector: "pre code",
946
+ languages: null,
947
+ // beta configuration options, subject to change, welcome to discuss
948
+ // https://github.com/highlightjs/highlight.js/issues/1086
949
+ __emitter: TokenTreeEmitter
950
+ };
951
+ function shouldNotHighlight(languageName) {
952
+ return options.noHighlightRe.test(languageName);
953
+ }
954
+ function blockLanguage(block) {
955
+ let classes = block.className + " ";
956
+ classes += block.parentNode ? block.parentNode.className : "";
957
+ const match = options.languageDetectRe.exec(classes);
958
+ if (match) {
959
+ const language = getLanguage(match[1]);
960
+ if (!language) {
961
+ warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
962
+ warn("Falling back to no-highlight mode for this block.", block);
963
+ }
964
+ return language ? match[1] : "no-highlight";
965
+ }
966
+ return classes.split(/\s+/).find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
967
+ }
968
+ function highlight2(codeOrLanguageName, optionsOrCode, ignoreIllegals) {
969
+ let code = "";
970
+ let languageName = "";
971
+ if (typeof optionsOrCode === "object") {
972
+ code = codeOrLanguageName;
973
+ ignoreIllegals = optionsOrCode.ignoreIllegals;
974
+ languageName = optionsOrCode.language;
975
+ } else {
976
+ deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated.");
977
+ deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");
978
+ languageName = codeOrLanguageName;
979
+ code = optionsOrCode;
980
+ }
981
+ if (ignoreIllegals === void 0) {
982
+ ignoreIllegals = true;
983
+ }
984
+ const context = {
985
+ code,
986
+ language: languageName
987
+ };
988
+ fire("before:highlight", context);
989
+ const result = context.result ? context.result : _highlight(context.language, context.code, ignoreIllegals);
990
+ result.code = context.code;
991
+ fire("after:highlight", result);
992
+ return result;
993
+ }
994
+ function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) {
995
+ const keywordHits = /* @__PURE__ */ Object.create(null);
996
+ function keywordData(mode, matchText) {
997
+ return mode.keywords[matchText];
998
+ }
999
+ function processKeywords() {
1000
+ if (!top.keywords) {
1001
+ emitter.addText(modeBuffer);
1002
+ return;
1003
+ }
1004
+ let lastIndex = 0;
1005
+ top.keywordPatternRe.lastIndex = 0;
1006
+ let match = top.keywordPatternRe.exec(modeBuffer);
1007
+ let buf = "";
1008
+ while (match) {
1009
+ buf += modeBuffer.substring(lastIndex, match.index);
1010
+ const word = language.case_insensitive ? match[0].toLowerCase() : match[0];
1011
+ const data = keywordData(top, word);
1012
+ if (data) {
1013
+ const [kind, keywordRelevance] = data;
1014
+ emitter.addText(buf);
1015
+ buf = "";
1016
+ keywordHits[word] = (keywordHits[word] || 0) + 1;
1017
+ if (keywordHits[word] <= MAX_KEYWORD_HITS)
1018
+ relevance += keywordRelevance;
1019
+ if (kind.startsWith("_")) {
1020
+ buf += match[0];
1021
+ } else {
1022
+ const cssClass = language.classNameAliases[kind] || kind;
1023
+ emitKeyword(match[0], cssClass);
1024
+ }
1025
+ } else {
1026
+ buf += match[0];
1027
+ }
1028
+ lastIndex = top.keywordPatternRe.lastIndex;
1029
+ match = top.keywordPatternRe.exec(modeBuffer);
1030
+ }
1031
+ buf += modeBuffer.substring(lastIndex);
1032
+ emitter.addText(buf);
1033
+ }
1034
+ function processSubLanguage() {
1035
+ if (modeBuffer === "")
1036
+ return;
1037
+ let result2 = null;
1038
+ if (typeof top.subLanguage === "string") {
1039
+ if (!languages[top.subLanguage]) {
1040
+ emitter.addText(modeBuffer);
1041
+ return;
1042
+ }
1043
+ result2 = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
1044
+ continuations[top.subLanguage] = /** @type {CompiledMode} */
1045
+ result2._top;
1046
+ } else {
1047
+ result2 = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
1048
+ }
1049
+ if (top.relevance > 0) {
1050
+ relevance += result2.relevance;
1051
+ }
1052
+ emitter.__addSublanguage(result2._emitter, result2.language);
1053
+ }
1054
+ function processBuffer() {
1055
+ if (top.subLanguage != null) {
1056
+ processSubLanguage();
1057
+ } else {
1058
+ processKeywords();
1059
+ }
1060
+ modeBuffer = "";
1061
+ }
1062
+ function emitKeyword(keyword, scope) {
1063
+ if (keyword === "")
1064
+ return;
1065
+ emitter.startScope(scope);
1066
+ emitter.addText(keyword);
1067
+ emitter.endScope();
1068
+ }
1069
+ function emitMultiClass(scope, match) {
1070
+ let i = 1;
1071
+ const max = match.length - 1;
1072
+ while (i <= max) {
1073
+ if (!scope._emit[i]) {
1074
+ i++;
1075
+ continue;
1076
+ }
1077
+ const klass = language.classNameAliases[scope[i]] || scope[i];
1078
+ const text = match[i];
1079
+ if (klass) {
1080
+ emitKeyword(text, klass);
1081
+ } else {
1082
+ modeBuffer = text;
1083
+ processKeywords();
1084
+ modeBuffer = "";
1085
+ }
1086
+ i++;
1087
+ }
1088
+ }
1089
+ function startNewMode(mode, match) {
1090
+ if (mode.scope && typeof mode.scope === "string") {
1091
+ emitter.openNode(language.classNameAliases[mode.scope] || mode.scope);
1092
+ }
1093
+ if (mode.beginScope) {
1094
+ if (mode.beginScope._wrap) {
1095
+ emitKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap);
1096
+ modeBuffer = "";
1097
+ } else if (mode.beginScope._multi) {
1098
+ emitMultiClass(mode.beginScope, match);
1099
+ modeBuffer = "";
1100
+ }
1101
+ }
1102
+ top = Object.create(mode, { parent: { value: top } });
1103
+ return top;
1104
+ }
1105
+ function endOfMode(mode, match, matchPlusRemainder) {
1106
+ let matched = startsWith(mode.endRe, matchPlusRemainder);
1107
+ if (matched) {
1108
+ if (mode["on:end"]) {
1109
+ const resp = new Response(mode);
1110
+ mode["on:end"](match, resp);
1111
+ if (resp.isMatchIgnored)
1112
+ matched = false;
1113
+ }
1114
+ if (matched) {
1115
+ while (mode.endsParent && mode.parent) {
1116
+ mode = mode.parent;
1117
+ }
1118
+ return mode;
1119
+ }
1120
+ }
1121
+ if (mode.endsWithParent) {
1122
+ return endOfMode(mode.parent, match, matchPlusRemainder);
1123
+ }
1124
+ }
1125
+ function doIgnore(lexeme) {
1126
+ if (top.matcher.regexIndex === 0) {
1127
+ modeBuffer += lexeme[0];
1128
+ return 1;
1129
+ } else {
1130
+ resumeScanAtSamePosition = true;
1131
+ return 0;
1132
+ }
1133
+ }
1134
+ function doBeginMatch(match) {
1135
+ const lexeme = match[0];
1136
+ const newMode = match.rule;
1137
+ const resp = new Response(newMode);
1138
+ const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
1139
+ for (const cb of beforeCallbacks) {
1140
+ if (!cb)
1141
+ continue;
1142
+ cb(match, resp);
1143
+ if (resp.isMatchIgnored)
1144
+ return doIgnore(lexeme);
1145
+ }
1146
+ if (newMode.skip) {
1147
+ modeBuffer += lexeme;
1148
+ } else {
1149
+ if (newMode.excludeBegin) {
1150
+ modeBuffer += lexeme;
1151
+ }
1152
+ processBuffer();
1153
+ if (!newMode.returnBegin && !newMode.excludeBegin) {
1154
+ modeBuffer = lexeme;
1155
+ }
1156
+ }
1157
+ startNewMode(newMode, match);
1158
+ return newMode.returnBegin ? 0 : lexeme.length;
1159
+ }
1160
+ function doEndMatch(match) {
1161
+ const lexeme = match[0];
1162
+ const matchPlusRemainder = codeToHighlight.substring(match.index);
1163
+ const endMode = endOfMode(top, match, matchPlusRemainder);
1164
+ if (!endMode) {
1165
+ return NO_MATCH;
1166
+ }
1167
+ const origin = top;
1168
+ if (top.endScope && top.endScope._wrap) {
1169
+ processBuffer();
1170
+ emitKeyword(lexeme, top.endScope._wrap);
1171
+ } else if (top.endScope && top.endScope._multi) {
1172
+ processBuffer();
1173
+ emitMultiClass(top.endScope, match);
1174
+ } else if (origin.skip) {
1175
+ modeBuffer += lexeme;
1176
+ } else {
1177
+ if (!(origin.returnEnd || origin.excludeEnd)) {
1178
+ modeBuffer += lexeme;
1179
+ }
1180
+ processBuffer();
1181
+ if (origin.excludeEnd) {
1182
+ modeBuffer = lexeme;
1183
+ }
1184
+ }
1185
+ do {
1186
+ if (top.scope) {
1187
+ emitter.closeNode();
1188
+ }
1189
+ if (!top.skip && !top.subLanguage) {
1190
+ relevance += top.relevance;
1191
+ }
1192
+ top = top.parent;
1193
+ } while (top !== endMode.parent);
1194
+ if (endMode.starts) {
1195
+ startNewMode(endMode.starts, match);
1196
+ }
1197
+ return origin.returnEnd ? 0 : lexeme.length;
1198
+ }
1199
+ function processContinuations() {
1200
+ const list = [];
1201
+ for (let current = top; current !== language; current = current.parent) {
1202
+ if (current.scope) {
1203
+ list.unshift(current.scope);
1204
+ }
1205
+ }
1206
+ list.forEach((item) => emitter.openNode(item));
1207
+ }
1208
+ let lastMatch = {};
1209
+ function processLexeme(textBeforeMatch, match) {
1210
+ const lexeme = match && match[0];
1211
+ modeBuffer += textBeforeMatch;
1212
+ if (lexeme == null) {
1213
+ processBuffer();
1214
+ return 0;
1215
+ }
1216
+ if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") {
1217
+ modeBuffer += codeToHighlight.slice(match.index, match.index + 1);
1218
+ if (!SAFE_MODE) {
1219
+ const err = new Error(`0 width match regex (${languageName})`);
1220
+ err.languageName = languageName;
1221
+ err.badRule = lastMatch.rule;
1222
+ throw err;
1223
+ }
1224
+ return 1;
1225
+ }
1226
+ lastMatch = match;
1227
+ if (match.type === "begin") {
1228
+ return doBeginMatch(match);
1229
+ } else if (match.type === "illegal" && !ignoreIllegals) {
1230
+ const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || "<unnamed>") + '"');
1231
+ err.mode = top;
1232
+ throw err;
1233
+ } else if (match.type === "end") {
1234
+ const processed = doEndMatch(match);
1235
+ if (processed !== NO_MATCH) {
1236
+ return processed;
1237
+ }
1238
+ }
1239
+ if (match.type === "illegal" && lexeme === "") {
1240
+ return 1;
1241
+ }
1242
+ if (iterations > 1e5 && iterations > match.index * 3) {
1243
+ const err = new Error("potential infinite loop, way more iterations than matches");
1244
+ throw err;
1245
+ }
1246
+ modeBuffer += lexeme;
1247
+ return lexeme.length;
1248
+ }
1249
+ const language = getLanguage(languageName);
1250
+ if (!language) {
1251
+ error(LANGUAGE_NOT_FOUND.replace("{}", languageName));
1252
+ throw new Error('Unknown language: "' + languageName + '"');
1253
+ }
1254
+ const md = compileLanguage(language);
1255
+ let result = "";
1256
+ let top = continuation || md;
1257
+ const continuations = {};
1258
+ const emitter = new options.__emitter(options);
1259
+ processContinuations();
1260
+ let modeBuffer = "";
1261
+ let relevance = 0;
1262
+ let index = 0;
1263
+ let iterations = 0;
1264
+ let resumeScanAtSamePosition = false;
1265
+ try {
1266
+ if (!language.__emitTokens) {
1267
+ top.matcher.considerAll();
1268
+ for (; ; ) {
1269
+ iterations++;
1270
+ if (resumeScanAtSamePosition) {
1271
+ resumeScanAtSamePosition = false;
1272
+ } else {
1273
+ top.matcher.considerAll();
1274
+ }
1275
+ top.matcher.lastIndex = index;
1276
+ const match = top.matcher.exec(codeToHighlight);
1277
+ if (!match)
1278
+ break;
1279
+ const beforeMatch = codeToHighlight.substring(index, match.index);
1280
+ const processedCount = processLexeme(beforeMatch, match);
1281
+ index = match.index + processedCount;
1282
+ }
1283
+ processLexeme(codeToHighlight.substring(index));
1284
+ } else {
1285
+ language.__emitTokens(codeToHighlight, emitter);
1286
+ }
1287
+ emitter.finalize();
1288
+ result = emitter.toHTML();
1289
+ return {
1290
+ language: languageName,
1291
+ value: result,
1292
+ relevance,
1293
+ illegal: false,
1294
+ _emitter: emitter,
1295
+ _top: top
1296
+ };
1297
+ } catch (err) {
1298
+ if (err.message && err.message.includes("Illegal")) {
1299
+ return {
1300
+ language: languageName,
1301
+ value: escape(codeToHighlight),
1302
+ illegal: true,
1303
+ relevance: 0,
1304
+ _illegalBy: {
1305
+ message: err.message,
1306
+ index,
1307
+ context: codeToHighlight.slice(index - 100, index + 100),
1308
+ mode: err.mode,
1309
+ resultSoFar: result
1310
+ },
1311
+ _emitter: emitter
1312
+ };
1313
+ } else if (SAFE_MODE) {
1314
+ return {
1315
+ language: languageName,
1316
+ value: escape(codeToHighlight),
1317
+ illegal: false,
1318
+ relevance: 0,
1319
+ errorRaised: err,
1320
+ _emitter: emitter,
1321
+ _top: top
1322
+ };
1323
+ } else {
1324
+ throw err;
1325
+ }
1326
+ }
1327
+ }
1328
+ function justTextHighlightResult(code) {
1329
+ const result = {
1330
+ value: escape(code),
1331
+ illegal: false,
1332
+ relevance: 0,
1333
+ _top: PLAINTEXT_LANGUAGE,
1334
+ _emitter: new options.__emitter(options)
1335
+ };
1336
+ result._emitter.addText(code);
1337
+ return result;
1338
+ }
1339
+ function highlightAuto(code, languageSubset) {
1340
+ languageSubset = languageSubset || options.languages || Object.keys(languages);
1341
+ const plaintext = justTextHighlightResult(code);
1342
+ const results = languageSubset.filter(getLanguage).filter(autoDetection).map(
1343
+ (name) => _highlight(name, code, false)
1344
+ );
1345
+ results.unshift(plaintext);
1346
+ const sorted = results.sort((a, b) => {
1347
+ if (a.relevance !== b.relevance)
1348
+ return b.relevance - a.relevance;
1349
+ if (a.language && b.language) {
1350
+ if (getLanguage(a.language).supersetOf === b.language) {
1351
+ return 1;
1352
+ } else if (getLanguage(b.language).supersetOf === a.language) {
1353
+ return -1;
1354
+ }
1355
+ }
1356
+ return 0;
1357
+ });
1358
+ const [best, secondBest] = sorted;
1359
+ const result = best;
1360
+ result.secondBest = secondBest;
1361
+ return result;
1362
+ }
1363
+ function updateClassName(element, currentLang, resultLang) {
1364
+ const language = currentLang && aliases[currentLang] || resultLang;
1365
+ element.classList.add("hljs");
1366
+ element.classList.add(`language-${language}`);
1367
+ }
1368
+ function highlightElement(element) {
1369
+ let node = null;
1370
+ const language = blockLanguage(element);
1371
+ if (shouldNotHighlight(language))
1372
+ return;
1373
+ fire(
1374
+ "before:highlightElement",
1375
+ { el: element, language }
1376
+ );
1377
+ if (element.dataset.highlighted) {
1378
+ console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", element);
1379
+ return;
1380
+ }
1381
+ if (element.children.length > 0) {
1382
+ if (!options.ignoreUnescapedHTML) {
1383
+ console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk.");
1384
+ console.warn("https://github.com/highlightjs/highlight.js/wiki/security");
1385
+ console.warn("The element with unescaped HTML:");
1386
+ console.warn(element);
1387
+ }
1388
+ if (options.throwUnescapedHTML) {
1389
+ const err = new HTMLInjectionError(
1390
+ "One of your code blocks includes unescaped HTML.",
1391
+ element.innerHTML
1392
+ );
1393
+ throw err;
1394
+ }
1395
+ }
1396
+ node = element;
1397
+ const text = node.textContent;
1398
+ const result = language ? highlight2(text, { language, ignoreIllegals: true }) : highlightAuto(text);
1399
+ element.innerHTML = result.value;
1400
+ element.dataset.highlighted = "yes";
1401
+ updateClassName(element, language, result.language);
1402
+ element.result = {
1403
+ language: result.language,
1404
+ // TODO: remove with version 11.0
1405
+ re: result.relevance,
1406
+ relevance: result.relevance
1407
+ };
1408
+ if (result.secondBest) {
1409
+ element.secondBest = {
1410
+ language: result.secondBest.language,
1411
+ relevance: result.secondBest.relevance
1412
+ };
1413
+ }
1414
+ fire("after:highlightElement", { el: element, result, text });
1415
+ }
1416
+ function configure(userOptions) {
1417
+ options = inherit(options, userOptions);
1418
+ }
1419
+ const initHighlighting = () => {
1420
+ highlightAll();
1421
+ deprecated("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
1422
+ };
1423
+ function initHighlightingOnLoad() {
1424
+ highlightAll();
1425
+ deprecated("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now.");
1426
+ }
1427
+ let wantsHighlight = false;
1428
+ function highlightAll() {
1429
+ if (document.readyState === "loading") {
1430
+ wantsHighlight = true;
1431
+ return;
1432
+ }
1433
+ const blocks = document.querySelectorAll(options.cssSelector);
1434
+ blocks.forEach(highlightElement);
1435
+ }
1436
+ function boot() {
1437
+ if (wantsHighlight)
1438
+ highlightAll();
1439
+ }
1440
+ if (typeof window !== "undefined" && window.addEventListener) {
1441
+ window.addEventListener("DOMContentLoaded", boot, false);
1442
+ }
1443
+ function registerLanguage(languageName, languageDefinition) {
1444
+ let lang = null;
1445
+ try {
1446
+ lang = languageDefinition(hljs);
1447
+ } catch (error$1) {
1448
+ error("Language definition for '{}' could not be registered.".replace("{}", languageName));
1449
+ if (!SAFE_MODE) {
1450
+ throw error$1;
1451
+ } else {
1452
+ error(error$1);
1453
+ }
1454
+ lang = PLAINTEXT_LANGUAGE;
1455
+ }
1456
+ if (!lang.name)
1457
+ lang.name = languageName;
1458
+ languages[languageName] = lang;
1459
+ lang.rawDefinition = languageDefinition.bind(null, hljs);
1460
+ if (lang.aliases) {
1461
+ registerAliases(lang.aliases, { languageName });
1462
+ }
1463
+ }
1464
+ function unregisterLanguage(languageName) {
1465
+ delete languages[languageName];
1466
+ for (const alias of Object.keys(aliases)) {
1467
+ if (aliases[alias] === languageName) {
1468
+ delete aliases[alias];
1469
+ }
1470
+ }
1471
+ }
1472
+ function listLanguages() {
1473
+ return Object.keys(languages);
1474
+ }
1475
+ function getLanguage(name) {
1476
+ name = (name || "").toLowerCase();
1477
+ return languages[name] || languages[aliases[name]];
1478
+ }
1479
+ function registerAliases(aliasList, { languageName }) {
1480
+ if (typeof aliasList === "string") {
1481
+ aliasList = [aliasList];
1482
+ }
1483
+ aliasList.forEach((alias) => {
1484
+ aliases[alias.toLowerCase()] = languageName;
1485
+ });
1486
+ }
1487
+ function autoDetection(name) {
1488
+ const lang = getLanguage(name);
1489
+ return lang && !lang.disableAutodetect;
1490
+ }
1491
+ function upgradePluginAPI(plugin) {
1492
+ if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) {
1493
+ plugin["before:highlightElement"] = (data) => {
1494
+ plugin["before:highlightBlock"](
1495
+ Object.assign({ block: data.el }, data)
1496
+ );
1497
+ };
1498
+ }
1499
+ if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) {
1500
+ plugin["after:highlightElement"] = (data) => {
1501
+ plugin["after:highlightBlock"](
1502
+ Object.assign({ block: data.el }, data)
1503
+ );
1504
+ };
1505
+ }
1506
+ }
1507
+ function addPlugin(plugin) {
1508
+ upgradePluginAPI(plugin);
1509
+ plugins.push(plugin);
1510
+ }
1511
+ function removePlugin(plugin) {
1512
+ const index = plugins.indexOf(plugin);
1513
+ if (index !== -1) {
1514
+ plugins.splice(index, 1);
1515
+ }
1516
+ }
1517
+ function fire(event, args) {
1518
+ const cb = event;
1519
+ plugins.forEach(function(plugin) {
1520
+ if (plugin[cb]) {
1521
+ plugin[cb](args);
1522
+ }
1523
+ });
1524
+ }
1525
+ function deprecateHighlightBlock(el) {
1526
+ deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0");
1527
+ deprecated("10.7.0", "Please use highlightElement now.");
1528
+ return highlightElement(el);
1529
+ }
1530
+ Object.assign(hljs, {
1531
+ highlight: highlight2,
1532
+ highlightAuto,
1533
+ highlightAll,
1534
+ highlightElement,
1535
+ // TODO: Remove with v12 API
1536
+ highlightBlock: deprecateHighlightBlock,
1537
+ configure,
1538
+ initHighlighting,
1539
+ initHighlightingOnLoad,
1540
+ registerLanguage,
1541
+ unregisterLanguage,
1542
+ listLanguages,
1543
+ getLanguage,
1544
+ registerAliases,
1545
+ autoDetection,
1546
+ inherit,
1547
+ addPlugin,
1548
+ removePlugin
1549
+ });
1550
+ hljs.debugMode = function() {
1551
+ SAFE_MODE = false;
1552
+ };
1553
+ hljs.safeMode = function() {
1554
+ SAFE_MODE = true;
1555
+ };
1556
+ hljs.versionString = version;
1557
+ hljs.regex = {
1558
+ concat,
1559
+ lookahead,
1560
+ either,
1561
+ optional,
1562
+ anyNumberOfTimes
1563
+ };
1564
+ for (const key in MODES) {
1565
+ if (typeof MODES[key] === "object") {
1566
+ deepFreeze(MODES[key]);
1567
+ }
1568
+ }
1569
+ Object.assign(hljs, MODES);
1570
+ return hljs;
1571
+ };
1572
+ const highlight = HLJS({});
1573
+ highlight.newInstance = () => HLJS({});
1574
+ var core = highlight;
1575
+ highlight.HighlightJS = highlight;
1576
+ highlight.default = highlight;
1577
+ const HighlightJS = core;
1578
+ export {
1579
+ HighlightJS as default
1580
+ };