n8n-editor-ui 1.89.0 → 1.90.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 (119) hide show
  1. package/dist/assets/{AnimatedSpinner-64kuDSMd.js → AnimatedSpinner-C0igC5ki.js} +1 -1
  2. package/dist/assets/{AnnotationTagsDropdown.ee.vue_vue_type_script_setup_true_lang-vU7A4Ql5.js → AnnotationTagsDropdown.ee.vue_vue_type_script_setup_true_lang-DbQJ_5eB.js} +1 -1
  3. package/dist/assets/{AuthView-BtMwWncz.js → AuthView-Dmy9oonN.js} +2 -2
  4. package/dist/assets/CanvasChatSwitch-CaiSjHFG.css +345 -0
  5. package/dist/assets/CanvasChatSwitch-DSRkCJ8D.js +265 -0
  6. package/dist/assets/{ChangePasswordView-ngd6kK9h.js → ChangePasswordView-81JP15Ve.js} +3 -3
  7. package/dist/assets/CollectionParameter-BCR57ofE.js +4 -0
  8. package/dist/assets/{CredentialsView-c9VZrSEP.js → CredentialsView-d6qclioV.js} +6 -6
  9. package/dist/assets/DemoFooter-BmmdCfKA.js +25 -0
  10. package/dist/assets/{ErrorView-M0yTzQxC.js → ErrorView-BmBEg3lf.js} +1 -1
  11. package/dist/assets/{ExecutionsTime-DZHUIJjP.css → ExecutionsTime-BuE0lHT6.css} +24 -15
  12. package/dist/assets/{ExecutionsTime.vue_vue_type_script_setup_true_lang-BsM5P8VY.js → ExecutionsTime.vue_vue_type_script_setup_true_lang-DOoZHzof.js} +20 -15
  13. package/dist/assets/{ExecutionsView-2Ywg0NsP.js → ExecutionsView-DqeBsSpV.js} +8 -8
  14. package/dist/assets/{FileSaver.min-DAXzY4JY.js → FileSaver.min-D0GQjV60.js} +1 -1
  15. package/dist/assets/{FixedCollectionParameter-CNRFXDrN.js → FixedCollectionParameter-DDFHlxvP.js} +1 -1
  16. package/dist/assets/{ForgotMyPasswordView-C1SOW4HN.js → ForgotMyPasswordView-FPvWDVPY.js} +3 -3
  17. package/dist/assets/{InsightsChartAverageRuntime-D_7tKoef.js → InsightsChartAverageRuntime-z_cI-yDg.js} +4 -4
  18. package/dist/assets/{InsightsChartFailed-DDejxv0R.js → InsightsChartFailed-b_700Tmq.js} +4 -4
  19. package/dist/assets/{InsightsChartFailureRate-PS5N1AdB.js → InsightsChartFailureRate-BnqPLE_R.js} +4 -4
  20. package/dist/assets/{InsightsChartTimeSaved-BBw2CgSS.js → InsightsChartTimeSaved-DfGUKtyn.js} +4 -4
  21. package/dist/assets/{InsightsChartTotal-2MVolQhG.js → InsightsChartTotal-DUYYmnvM.js} +4 -4
  22. package/dist/assets/{InsightsDashboard-DCdd_dks.js → InsightsDashboard-Cb4C6pVW.js} +58 -54
  23. package/dist/assets/InsightsPaywall-B7zseef2.js +62 -0
  24. package/dist/assets/{InsightsPaywall-OeXh6LeZ.css → InsightsPaywall-CE5W3W4m.css} +2 -1
  25. package/dist/assets/{InsightsSummary-BzdlA4Dr.js → InsightsSummary-UVWGYFlb.js} +1 -1
  26. package/dist/assets/{InsightsTableWorkflows-CnEuNzZ9.js → InsightsTableWorkflows-CkfPpJ8P.js} +2 -2
  27. package/dist/assets/{Logo-CmGfYtCL.js → Logo-CDa8Ndbk.js} +1 -1
  28. package/dist/assets/{CanvasChatSwitch-DCcRHty_.js → LogsPanel-Bj6SZeBQ.js} +985 -641
  29. package/dist/assets/{CanvasChatSwitch-BDVIAjN6.css → LogsPanel-DmPMCt9w.css} +425 -324
  30. package/dist/assets/{MainHeader-DdjAOCVS.js → MainHeader-BqZnCEkb.js} +9 -9
  31. package/dist/assets/{MainSidebar-CPtfXLom.js → MainSidebar-DyicnyT2.js} +2 -2
  32. package/dist/assets/{NodeCreation-C9WNMB5W.js → NodeCreation-J3ELSEr9.js} +4 -4
  33. package/dist/assets/{NodeCreator-Dt7b_La2.js → NodeCreator-ByGFazbP.js} +3 -3
  34. package/dist/assets/{NodeDetailsView-B2kdGJ7R.css → NodeDetailsView-CGgV4Pn_.css} +27 -1185
  35. package/dist/assets/{NodeDetailsView-BPQgwdWz.js → NodeDetailsView-C_z-nQG3.js} +169 -2683
  36. package/dist/assets/{NodeView-CKF92Cc3.js → NodeView-BTC9x0v8.js} +12 -12
  37. package/dist/assets/{ProjectCardBadge-Ca29o2Nu.js → ProjectCardBadge-DCaP7hKC.js} +5 -9
  38. package/dist/assets/{ProjectHeader-Dq3fVC-9.js → ProjectHeader-DALMab_q.js} +1 -1
  39. package/dist/assets/{ProjectSettings-6oRh_PiD.js → ProjectSettings-Do-lVrea.js} +2 -2
  40. package/dist/assets/{PushConnectionTracker.vue_vue_type_script_setup_true_lang-DtHAaMts.js → PushConnectionTracker.vue_vue_type_script_setup_true_lang-BWqkEjwR.js} +1 -1
  41. package/dist/assets/{ResourcesListLayout-b44J07nq.css → ResourcesListLayout-CglK2dXR.css} +8 -8
  42. package/dist/assets/{ResourcesListLayout-CjpS9ho7.js → ResourcesListLayout-FV3K-wCE.js} +2 -10
  43. package/dist/assets/RunData-BfVvixeD.js +5104 -0
  44. package/dist/assets/RunData-DepHcD2K.css +1833 -0
  45. package/dist/assets/RunDataAi-1YokoJrS.js +750 -0
  46. package/dist/assets/{RunDataAi-CUUDqZRP.css → RunDataAi-BF2gZZGr.css} +0 -408
  47. package/dist/assets/{RunDataJson-CS1Vs4me.js → RunDataJson-UCqamVA8.js} +7 -11
  48. package/dist/assets/{RunDataJsonActions-UEDmvE5v.js → RunDataJsonActions-CEriDRD_.js} +1 -1
  49. package/dist/assets/{RunDataSearch-BjsM_QL7.js → RunDataSearch-DSHgVrIH.js} +1 -1
  50. package/dist/assets/{RunDataTable-CX7gToH4.css → RunDataTable-DyUvXWfl.css} +47 -41
  51. package/dist/assets/{RunDataTable-zY9Z73dm.js → RunDataTable-Svn5sWyr.js} +36 -30
  52. package/dist/assets/{SamlOnboarding-CMQ3F8vU.js → SamlOnboarding-CtXHQJS6.js} +3 -3
  53. package/dist/assets/{SettingsApiView-C7mJo5RT.js → SettingsApiView-B4xEaKM5.js} +5 -5
  54. package/dist/assets/{SettingsCommunityNodesView-oV3f1FYs.js → SettingsCommunityNodesView-Cn7b8yXW.js} +4 -4
  55. package/dist/assets/{SettingsExternalSecrets-Zm50ediz.js → SettingsExternalSecrets-1JQ-XbO6.js} +1 -1
  56. package/dist/assets/{SettingsLdapView-D0lujKk6.js → SettingsLdapView-DN0ooz8k.js} +1 -1
  57. package/dist/assets/{SettingsLogStreamingView-DMRYf3h4.js → SettingsLogStreamingView-B5bjsLmX.js} +1 -1
  58. package/dist/assets/{SettingsPersonalView-BlKM42Fv.js → SettingsPersonalView-DgzC8S8B.js} +1 -1
  59. package/dist/assets/{SettingsSourceControl-BRkqOyBq.js → SettingsSourceControl-Bbax3j0s.js} +1 -1
  60. package/dist/assets/{SettingsSso-ClphkEtx.js → SettingsSso-gZtzdr_j.js} +1 -1
  61. package/dist/assets/{SettingsUsageAndPlan-BnxbFSLN.js → SettingsUsageAndPlan-JQLfWX3N.js} +1 -1
  62. package/dist/assets/{SettingsUsersView-CnqllPG4.js → SettingsUsersView-L2um2aHz.js} +1 -1
  63. package/dist/assets/{SettingsView-CJ4icVTM.js → SettingsView-DmW5uF0Y.js} +1 -1
  64. package/dist/assets/{SetupView-BaUQwZK2.js → SetupView-PUB9CmbM.js} +3 -3
  65. package/dist/assets/{SetupWorkflowCredentialsButton-DiRHCsta.js → SetupWorkflowCredentialsButton-DrNo9bUr.js} +1 -1
  66. package/dist/assets/{SetupWorkflowFromTemplateView-CjiIpX1D.js → SetupWorkflowFromTemplateView-Cv7rilHQ.js} +3 -3
  67. package/dist/assets/{SigninView-DrRmsG64.js → SigninView-C6mgciPa.js} +3 -3
  68. package/dist/assets/{SignoutView-DEK6MH1B.js → SignoutView-DtpsJQNN.js} +1 -1
  69. package/dist/assets/{SignupView-CTdIAp1U.js → SignupView-CsLmno8H.js} +3 -3
  70. package/dist/assets/{TemplateDetails-B6Nnq5_s.js → TemplateDetails-Cc-ra1_d.js} +1 -1
  71. package/dist/assets/{TemplateList-BKmKXiHs.js → TemplateList-BQrF5Bxy.js} +1 -1
  72. package/dist/assets/{TemplatesCollectionView-CXgiZ-fy.js → TemplatesCollectionView-CXji4_pS.js} +5 -5
  73. package/dist/assets/{TemplatesSearchView-BoX9MKRy.js → TemplatesSearchView-DN99kP7F.js} +3 -3
  74. package/dist/assets/{TemplatesView-htM1lafV.js → TemplatesView-DMYw_IGy.js} +1 -1
  75. package/dist/assets/{TemplatesWorkflowView-DIqdCPxB.js → TemplatesWorkflowView-CokDg5W-.js} +5 -5
  76. package/dist/assets/{TestDefinitionEditView-izO1b1I3.js → TestDefinitionEditView-B0ug0pLk.js} +7 -7
  77. package/dist/assets/{TestDefinitionListView-DuLocBuw.js → TestDefinitionListView-CF3nBGlC.js} +1 -1
  78. package/dist/assets/{TestDefinitionNewView-Dg37IAs6.js → TestDefinitionNewView-BIX0zI3Z.js} +2 -2
  79. package/dist/assets/{TestDefinitionRootView-DlG7VKKU.js → TestDefinitionRootView-B8HzwCtp.js} +1 -1
  80. package/dist/assets/{VariablesView-Cq8LInqk.js → VariablesView-dVZn0E-U.js} +3 -3
  81. package/dist/assets/{WorkerView-BTQTq3vI.js → WorkerView-Du18TNPW.js} +6 -6
  82. package/dist/assets/{WorkflowActivator-E1mdIOaC.js → WorkflowActivator-DAF5odet.js} +2 -2
  83. package/dist/assets/{WorkflowExecutionsInfoAccordion-BBtwnPZQ.css → WorkflowExecutionsInfoAccordion-53bC-IXN.css} +10 -8
  84. package/dist/assets/{WorkflowExecutionsInfoAccordion-DxGM_yu-.js → WorkflowExecutionsInfoAccordion-Z-XDWebr.js} +3 -3
  85. package/dist/assets/{WorkflowExecutionsLandingPage-BkftsbSa.js → WorkflowExecutionsLandingPage-DECLkJhn.js} +2 -2
  86. package/dist/assets/{WorkflowExecutionsPreview-w7I_h1ID.js → WorkflowExecutionsPreview-Bs5tSLIj.js} +6 -6
  87. package/dist/assets/{WorkflowExecutionsView-lyjECt6I.js → WorkflowExecutionsView-DtcqQM2k.js} +7 -7
  88. package/dist/assets/{WorkflowHistory-B8_7vx-c.js → WorkflowHistory-CWgCdWmB.js} +3 -3
  89. package/dist/assets/{WorkflowOnboardingView-D2fR8tdw.js → WorkflowOnboardingView-BEU0GnhE.js} +1 -1
  90. package/dist/assets/{WorkflowPreview-CNu7Kd6F.js → WorkflowPreview-DdYqE-TC.js} +1 -1
  91. package/dist/assets/{WorkflowsView-DV1tjQwB.css → WorkflowsView-CsM69PSv.css} +41 -16
  92. package/dist/assets/{WorkflowsView-B_70hdtG.js → WorkflowsView-D-hAQD_u.js} +348 -60
  93. package/dist/assets/{chartjs.utils-3n4f3zmI.js → chartjs.utils-DoypjRBD.js} +2 -2
  94. package/dist/assets/{dateFormatter-C1XlsLk2.js → dateFormatter-BPEQYXYl.js} +1 -1
  95. package/dist/assets/{easyAiWorkflowUtils-CCJdF1g3.js → easyAiWorkflowUtils-CDbznryH.js} +1 -1
  96. package/dist/assets/{global-link-actions-B6woWi9D.js → global-link-actions-By-BzwKw.js} +1 -1
  97. package/dist/assets/{import-curl-BlRUX0EU.js → import-curl-Cu66geT8.js} +1 -1
  98. package/dist/assets/{index-BHGYFXFB.js → index-BhqWgx7T.js} +1 -1
  99. package/dist/assets/{index-DwKuVkBg.css → index-C5OXOcIJ.css} +176 -111
  100. package/dist/assets/{index-B-Y7sDIj.js → index-CZWHLhkg.js} +2548 -2121
  101. package/dist/assets/{pickBy-BdN6wCB-.js → pickBy-D5ei-iUg.js} +1 -1
  102. package/dist/assets/{templateActions-FAVGvEAM.js → templateActions-CofZF1Cm.js} +1 -1
  103. package/dist/assets/{typescript.worker-Bt3bByTc.js → typescript.worker-BsxN2afA.js} +1 -1
  104. package/dist/assets/{useBeforeUnload-oRTjaea2.js → useBeforeUnload-DJezvBb3.js} +1 -1
  105. package/dist/assets/{useCanvasMapping-BkGr1HdJ.css → useCanvasMapping-B260y5FH.css} +4 -4
  106. package/dist/assets/{useCanvasMapping-CmD2j75y.js → useCanvasMapping-CmWAKpr8.js} +11 -4
  107. package/dist/assets/{useCanvasOperations-DYORubSM.js → useCanvasOperations-DnxywX7P.js} +17 -71
  108. package/dist/assets/{useClearExecutionButtonVisible-ReuF4PkZ.js → useClearExecutionButtonVisible-B5CsbsMz.js} +2 -2
  109. package/dist/assets/{useExecutionDebugging-I7MLJdC1.js → useExecutionDebugging-DlTHZIR5.js} +1 -1
  110. package/dist/assets/{useExecutionHelpers-CyZuZAQA.js → useExecutionHelpers-2I0XuUMz.js} +2 -2
  111. package/dist/assets/{useImportCurlCommand-DZVwxoke.js → useImportCurlCommand-CJRT2MGV.js} +2 -2
  112. package/dist/assets/{usePushConnection-SgX-5Lz6.js → usePushConnection-CFsn_rtI.js} +3 -3
  113. package/dist/assets/{useTestDefinitionForm-gWQ_zjEl.js → useTestDefinitionForm-DQ8Qe2LY.js} +1 -1
  114. package/dist/assets/{useWorkflowActivate-CX21vkKl.js → useWorkflowActivate-B-_DuLXg.js} +1 -1
  115. package/dist/index.html +2 -2
  116. package/package.json +1 -1
  117. package/dist/assets/CollectionParameter-NNrH2Qf1.js +0 -4
  118. package/dist/assets/InsightsPaywall-DtIcXb48.js +0 -58
  119. package/dist/assets/RunDataAi-DpuaI4HY.js +0 -3166
@@ -1,3166 +0,0 @@
1
- import { ck as getDefaultExportFromCjs, d as defineComponent, ba as useClipboard, a as useToast, dF as useAIAssistantHelpers, bw as useNodeTypesStore, au as useNDVStore, a1 as useRootStore, dq as useAssistantStore, L as useUIStore, q as computed, dG as MAX_DISPLAY_DATA_SIZE, dH as isCommunityPackageName, c as useI18n, h as resolveComponent, cb as resolveDirective, i as createElementBlock, g as openBlock, k as createBaseVNode, f as createCommentVNode, aC as withDirectives, t as toDisplayString, j as createVNode, m as unref, dI as InlineAskAssistantButton, w as withCtx, l as createTextVNode, F as Fragment, D as renderList, dJ as NEW_ASSISTANT_SESSION_MODAL, ch as sanitizeHtml, bu as NodeConnectionTypes, dK as isObjectEmpty, r as ref, o as onMounted, n as normalizeClass, e as createBlock, b4 as VueMarkdown, _ as _export_sfc, b9 as N8nText, J as withModifiers, U as useWorkflowsStore, bC as _sfc_main$6, I as watch, bF as ElTree, B as normalizeStyle } from "./index-B-Y7sDIj.js";
2
- import { d as capitalize } from "./useCanvasOperations-DYORubSM.js";
3
- import { u as useExecutionHelpers } from "./useExecutionHelpers-CyZuZAQA.js";
4
- var core;
5
- var hasRequiredCore;
6
- function requireCore() {
7
- if (hasRequiredCore) return core;
8
- hasRequiredCore = 1;
9
- function deepFreeze(obj) {
10
- if (obj instanceof Map) {
11
- obj.clear = obj.delete = obj.set = function() {
12
- throw new Error("map is read-only");
13
- };
14
- } else if (obj instanceof Set) {
15
- obj.add = obj.clear = obj.delete = function() {
16
- throw new Error("set is read-only");
17
- };
18
- }
19
- Object.freeze(obj);
20
- Object.getOwnPropertyNames(obj).forEach((name) => {
21
- const prop = obj[name];
22
- const type = typeof prop;
23
- if ((type === "object" || type === "function") && !Object.isFrozen(prop)) {
24
- deepFreeze(prop);
25
- }
26
- });
27
- return obj;
28
- }
29
- class Response {
30
- /**
31
- * @param {CompiledMode} mode
32
- */
33
- constructor(mode) {
34
- if (mode.data === void 0) mode.data = {};
35
- this.data = mode.data;
36
- this.isMatchIgnored = false;
37
- }
38
- ignoreMatch() {
39
- this.isMatchIgnored = true;
40
- }
41
- }
42
- function escapeHTML(value) {
43
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
44
- }
45
- function inherit$1(original, ...objects) {
46
- const result = /* @__PURE__ */ Object.create(null);
47
- for (const key in original) {
48
- result[key] = original[key];
49
- }
50
- objects.forEach(function(obj) {
51
- for (const key in obj) {
52
- result[key] = obj[key];
53
- }
54
- });
55
- return (
56
- /** @type {T} */
57
- result
58
- );
59
- }
60
- const SPAN_CLOSE = "</span>";
61
- const emitsWrappingTags = (node) => {
62
- return !!node.scope;
63
- };
64
- const scopeToCSSClass = (name, { prefix }) => {
65
- if (name.startsWith("language:")) {
66
- return name.replace("language:", "language-");
67
- }
68
- if (name.includes(".")) {
69
- const pieces = name.split(".");
70
- return [
71
- `${prefix}${pieces.shift()}`,
72
- ...pieces.map((x, i) => `${x}${"_".repeat(i + 1)}`)
73
- ].join(" ");
74
- }
75
- return `${prefix}${name}`;
76
- };
77
- class HTMLRenderer {
78
- /**
79
- * Creates a new HTMLRenderer
80
- *
81
- * @param {Tree} parseTree - the parse tree (must support `walk` API)
82
- * @param {{classPrefix: string}} options
83
- */
84
- constructor(parseTree, options) {
85
- this.buffer = "";
86
- this.classPrefix = options.classPrefix;
87
- parseTree.walk(this);
88
- }
89
- /**
90
- * Adds texts to the output stream
91
- *
92
- * @param {string} text */
93
- addText(text) {
94
- this.buffer += escapeHTML(text);
95
- }
96
- /**
97
- * Adds a node open to the output stream (if needed)
98
- *
99
- * @param {Node} node */
100
- openNode(node) {
101
- if (!emitsWrappingTags(node)) return;
102
- const className = scopeToCSSClass(
103
- node.scope,
104
- { prefix: this.classPrefix }
105
- );
106
- this.span(className);
107
- }
108
- /**
109
- * Adds a node close to the output stream (if needed)
110
- *
111
- * @param {Node} node */
112
- closeNode(node) {
113
- if (!emitsWrappingTags(node)) return;
114
- this.buffer += SPAN_CLOSE;
115
- }
116
- /**
117
- * returns the accumulated buffer
118
- */
119
- value() {
120
- return this.buffer;
121
- }
122
- // helpers
123
- /**
124
- * Builds a span element
125
- *
126
- * @param {string} className */
127
- span(className) {
128
- this.buffer += `<span class="${className}">`;
129
- }
130
- }
131
- const newNode = (opts = {}) => {
132
- const result = { children: [] };
133
- Object.assign(result, opts);
134
- return result;
135
- };
136
- class TokenTree {
137
- constructor() {
138
- this.rootNode = newNode();
139
- this.stack = [this.rootNode];
140
- }
141
- get top() {
142
- return this.stack[this.stack.length - 1];
143
- }
144
- get root() {
145
- return this.rootNode;
146
- }
147
- /** @param {Node} node */
148
- add(node) {
149
- this.top.children.push(node);
150
- }
151
- /** @param {string} scope */
152
- openNode(scope) {
153
- const node = newNode({ scope });
154
- this.add(node);
155
- this.stack.push(node);
156
- }
157
- closeNode() {
158
- if (this.stack.length > 1) {
159
- return this.stack.pop();
160
- }
161
- return void 0;
162
- }
163
- closeAllNodes() {
164
- while (this.closeNode()) ;
165
- }
166
- toJSON() {
167
- return JSON.stringify(this.rootNode, null, 4);
168
- }
169
- /**
170
- * @typedef { import("./html_renderer").Renderer } Renderer
171
- * @param {Renderer} builder
172
- */
173
- walk(builder) {
174
- return this.constructor._walk(builder, this.rootNode);
175
- }
176
- /**
177
- * @param {Renderer} builder
178
- * @param {Node} node
179
- */
180
- static _walk(builder, node) {
181
- if (typeof node === "string") {
182
- builder.addText(node);
183
- } else if (node.children) {
184
- builder.openNode(node);
185
- node.children.forEach((child) => this._walk(builder, child));
186
- builder.closeNode(node);
187
- }
188
- return builder;
189
- }
190
- /**
191
- * @param {Node} node
192
- */
193
- static _collapse(node) {
194
- if (typeof node === "string") return;
195
- if (!node.children) return;
196
- if (node.children.every((el) => typeof el === "string")) {
197
- node.children = [node.children.join("")];
198
- } else {
199
- node.children.forEach((child) => {
200
- TokenTree._collapse(child);
201
- });
202
- }
203
- }
204
- }
205
- class TokenTreeEmitter extends TokenTree {
206
- /**
207
- * @param {*} options
208
- */
209
- constructor(options) {
210
- super();
211
- this.options = options;
212
- }
213
- /**
214
- * @param {string} text
215
- */
216
- addText(text) {
217
- if (text === "") {
218
- return;
219
- }
220
- this.add(text);
221
- }
222
- /** @param {string} scope */
223
- startScope(scope) {
224
- this.openNode(scope);
225
- }
226
- endScope() {
227
- this.closeNode();
228
- }
229
- /**
230
- * @param {Emitter & {root: DataNode}} emitter
231
- * @param {string} name
232
- */
233
- __addSublanguage(emitter, name) {
234
- const node = emitter.root;
235
- if (name) node.scope = `language:${name}`;
236
- this.add(node);
237
- }
238
- toHTML() {
239
- const renderer = new HTMLRenderer(this, this.options);
240
- return renderer.value();
241
- }
242
- finalize() {
243
- this.closeAllNodes();
244
- return true;
245
- }
246
- }
247
- function source(re) {
248
- if (!re) return null;
249
- if (typeof re === "string") return re;
250
- return re.source;
251
- }
252
- function lookahead(re) {
253
- return concat("(?=", re, ")");
254
- }
255
- function anyNumberOfTimes(re) {
256
- return concat("(?:", re, ")*");
257
- }
258
- function optional(re) {
259
- return concat("(?:", re, ")?");
260
- }
261
- function concat(...args) {
262
- const joined = args.map((x) => source(x)).join("");
263
- return joined;
264
- }
265
- function stripOptionsFromArgs(args) {
266
- const opts = args[args.length - 1];
267
- if (typeof opts === "object" && opts.constructor === Object) {
268
- args.splice(args.length - 1, 1);
269
- return opts;
270
- } else {
271
- return {};
272
- }
273
- }
274
- function either(...args) {
275
- const opts = stripOptionsFromArgs(args);
276
- const joined = "(" + (opts.capture ? "" : "?:") + args.map((x) => source(x)).join("|") + ")";
277
- return joined;
278
- }
279
- function countMatchGroups(re) {
280
- return new RegExp(re.toString() + "|").exec("").length - 1;
281
- }
282
- function startsWith(re, lexeme) {
283
- const match = re && re.exec(lexeme);
284
- return match && match.index === 0;
285
- }
286
- const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
287
- function _rewriteBackreferences(regexps, { joinWith }) {
288
- let numCaptures = 0;
289
- return regexps.map((regex) => {
290
- numCaptures += 1;
291
- const offset = numCaptures;
292
- let re = source(regex);
293
- let out = "";
294
- while (re.length > 0) {
295
- const match = BACKREF_RE.exec(re);
296
- if (!match) {
297
- out += re;
298
- break;
299
- }
300
- out += re.substring(0, match.index);
301
- re = re.substring(match.index + match[0].length);
302
- if (match[0][0] === "\\" && match[1]) {
303
- out += "\\" + String(Number(match[1]) + offset);
304
- } else {
305
- out += match[0];
306
- if (match[0] === "(") {
307
- numCaptures++;
308
- }
309
- }
310
- }
311
- return out;
312
- }).map((re) => `(${re})`).join(joinWith);
313
- }
314
- const MATCH_NOTHING_RE = /\b\B/;
315
- const IDENT_RE = "[a-zA-Z]\\w*";
316
- const UNDERSCORE_IDENT_RE = "[a-zA-Z_]\\w*";
317
- const NUMBER_RE = "\\b\\d+(\\.\\d+)?";
318
- const C_NUMBER_RE = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";
319
- const BINARY_NUMBER_RE = "\\b(0b[01]+)";
320
- const RE_STARTERS_RE = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";
321
- const SHEBANG = (opts = {}) => {
322
- const beginShebang = /^#![ ]*\//;
323
- if (opts.binary) {
324
- opts.begin = concat(
325
- beginShebang,
326
- /.*\b/,
327
- opts.binary,
328
- /\b.*/
329
- );
330
- }
331
- return inherit$1({
332
- scope: "meta",
333
- begin: beginShebang,
334
- end: /$/,
335
- relevance: 0,
336
- /** @type {ModeCallback} */
337
- "on:begin": (m, resp) => {
338
- if (m.index !== 0) resp.ignoreMatch();
339
- }
340
- }, opts);
341
- };
342
- const BACKSLASH_ESCAPE = {
343
- begin: "\\\\[\\s\\S]",
344
- relevance: 0
345
- };
346
- const APOS_STRING_MODE = {
347
- scope: "string",
348
- begin: "'",
349
- end: "'",
350
- illegal: "\\n",
351
- contains: [BACKSLASH_ESCAPE]
352
- };
353
- const QUOTE_STRING_MODE = {
354
- scope: "string",
355
- begin: '"',
356
- end: '"',
357
- illegal: "\\n",
358
- contains: [BACKSLASH_ESCAPE]
359
- };
360
- const PHRASAL_WORDS_MODE = {
361
- 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/
362
- };
363
- const COMMENT = function(begin, end, modeOptions = {}) {
364
- const mode = inherit$1(
365
- {
366
- scope: "comment",
367
- begin,
368
- end,
369
- contains: []
370
- },
371
- modeOptions
372
- );
373
- mode.contains.push({
374
- scope: "doctag",
375
- // hack to avoid the space from being included. the space is necessary to
376
- // match here to prevent the plain text rule below from gobbling up doctags
377
- begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
378
- end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,
379
- excludeBegin: true,
380
- relevance: 0
381
- });
382
- const ENGLISH_WORD = either(
383
- // list of common 1 and 2 letter words in English
384
- "I",
385
- "a",
386
- "is",
387
- "so",
388
- "us",
389
- "to",
390
- "at",
391
- "if",
392
- "in",
393
- "it",
394
- "on",
395
- // note: this is not an exhaustive list of contractions, just popular ones
396
- /[A-Za-z]+['](d|ve|re|ll|t|s|n)/,
397
- // contractions - can't we'd they're let's, etc
398
- /[A-Za-z]+[-][a-z]+/,
399
- // `no-way`, etc.
400
- /[A-Za-z][a-z]{2,}/
401
- // allow capitalized words at beginning of sentences
402
- );
403
- mode.contains.push(
404
- {
405
- // TODO: how to include ", (, ) without breaking grammars that use these for
406
- // comment delimiters?
407
- // begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/
408
- // ---
409
- // this tries to find sequences of 3 english words in a row (without any
410
- // "programming" type syntax) this gives us a strong signal that we've
411
- // TRULY found a comment - vs perhaps scanning with the wrong language.
412
- // It's possible to find something that LOOKS like the start of the
413
- // comment - but then if there is no readable text - good chance it is a
414
- // false match and not a comment.
415
- //
416
- // for a visual example please see:
417
- // https://github.com/highlightjs/highlight.js/issues/2827
418
- begin: concat(
419
- /[ ]+/,
420
- // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */
421
- "(",
422
- ENGLISH_WORD,
423
- /[.]?[:]?([.][ ]|[ ])/,
424
- "){3}"
425
- )
426
- // look for 3 words in a row
427
- }
428
- );
429
- return mode;
430
- };
431
- const C_LINE_COMMENT_MODE = COMMENT("//", "$");
432
- const C_BLOCK_COMMENT_MODE = COMMENT("/\\*", "\\*/");
433
- const HASH_COMMENT_MODE = COMMENT("#", "$");
434
- const NUMBER_MODE = {
435
- scope: "number",
436
- begin: NUMBER_RE,
437
- relevance: 0
438
- };
439
- const C_NUMBER_MODE = {
440
- scope: "number",
441
- begin: C_NUMBER_RE,
442
- relevance: 0
443
- };
444
- const BINARY_NUMBER_MODE = {
445
- scope: "number",
446
- begin: BINARY_NUMBER_RE,
447
- relevance: 0
448
- };
449
- const REGEXP_MODE = {
450
- scope: "regexp",
451
- begin: /\/(?=[^/\n]*\/)/,
452
- end: /\/[gimuy]*/,
453
- contains: [
454
- BACKSLASH_ESCAPE,
455
- {
456
- begin: /\[/,
457
- end: /\]/,
458
- relevance: 0,
459
- contains: [BACKSLASH_ESCAPE]
460
- }
461
- ]
462
- };
463
- const TITLE_MODE = {
464
- scope: "title",
465
- begin: IDENT_RE,
466
- relevance: 0
467
- };
468
- const UNDERSCORE_TITLE_MODE = {
469
- scope: "title",
470
- begin: UNDERSCORE_IDENT_RE,
471
- relevance: 0
472
- };
473
- const METHOD_GUARD = {
474
- // excludes method names from keyword processing
475
- begin: "\\.\\s*" + UNDERSCORE_IDENT_RE,
476
- relevance: 0
477
- };
478
- const END_SAME_AS_BEGIN = function(mode) {
479
- return Object.assign(
480
- mode,
481
- {
482
- /** @type {ModeCallback} */
483
- "on:begin": (m, resp) => {
484
- resp.data._beginMatch = m[1];
485
- },
486
- /** @type {ModeCallback} */
487
- "on:end": (m, resp) => {
488
- if (resp.data._beginMatch !== m[1]) resp.ignoreMatch();
489
- }
490
- }
491
- );
492
- };
493
- var MODES = /* @__PURE__ */ Object.freeze({
494
- __proto__: null,
495
- APOS_STRING_MODE,
496
- BACKSLASH_ESCAPE,
497
- BINARY_NUMBER_MODE,
498
- BINARY_NUMBER_RE,
499
- COMMENT,
500
- C_BLOCK_COMMENT_MODE,
501
- C_LINE_COMMENT_MODE,
502
- C_NUMBER_MODE,
503
- C_NUMBER_RE,
504
- END_SAME_AS_BEGIN,
505
- HASH_COMMENT_MODE,
506
- IDENT_RE,
507
- MATCH_NOTHING_RE,
508
- METHOD_GUARD,
509
- NUMBER_MODE,
510
- NUMBER_RE,
511
- PHRASAL_WORDS_MODE,
512
- QUOTE_STRING_MODE,
513
- REGEXP_MODE,
514
- RE_STARTERS_RE,
515
- SHEBANG,
516
- TITLE_MODE,
517
- UNDERSCORE_IDENT_RE,
518
- UNDERSCORE_TITLE_MODE
519
- });
520
- function skipIfHasPrecedingDot(match, response) {
521
- const before = match.input[match.index - 1];
522
- if (before === ".") {
523
- response.ignoreMatch();
524
- }
525
- }
526
- function scopeClassName(mode, _parent) {
527
- if (mode.className !== void 0) {
528
- mode.scope = mode.className;
529
- delete mode.className;
530
- }
531
- }
532
- function beginKeywords(mode, parent) {
533
- if (!parent) return;
534
- if (!mode.beginKeywords) return;
535
- mode.begin = "\\b(" + mode.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)";
536
- mode.__beforeBegin = skipIfHasPrecedingDot;
537
- mode.keywords = mode.keywords || mode.beginKeywords;
538
- delete mode.beginKeywords;
539
- if (mode.relevance === void 0) mode.relevance = 0;
540
- }
541
- function compileIllegal(mode, _parent) {
542
- if (!Array.isArray(mode.illegal)) return;
543
- mode.illegal = either(...mode.illegal);
544
- }
545
- function compileMatch(mode, _parent) {
546
- if (!mode.match) return;
547
- if (mode.begin || mode.end) throw new Error("begin & end are not supported with match");
548
- mode.begin = mode.match;
549
- delete mode.match;
550
- }
551
- function compileRelevance(mode, _parent) {
552
- if (mode.relevance === void 0) mode.relevance = 1;
553
- }
554
- const beforeMatchExt = (mode, parent) => {
555
- if (!mode.beforeMatch) return;
556
- if (mode.starts) throw new Error("beforeMatch cannot be used with starts");
557
- const originalMode = Object.assign({}, mode);
558
- Object.keys(mode).forEach((key) => {
559
- delete mode[key];
560
- });
561
- mode.keywords = originalMode.keywords;
562
- mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin));
563
- mode.starts = {
564
- relevance: 0,
565
- contains: [
566
- Object.assign(originalMode, { endsParent: true })
567
- ]
568
- };
569
- mode.relevance = 0;
570
- delete originalMode.beforeMatch;
571
- };
572
- const COMMON_KEYWORDS = [
573
- "of",
574
- "and",
575
- "for",
576
- "in",
577
- "not",
578
- "or",
579
- "if",
580
- "then",
581
- "parent",
582
- // common variable name
583
- "list",
584
- // common variable name
585
- "value"
586
- // common variable name
587
- ];
588
- const DEFAULT_KEYWORD_SCOPE = "keyword";
589
- function compileKeywords(rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) {
590
- const compiledKeywords = /* @__PURE__ */ Object.create(null);
591
- if (typeof rawKeywords === "string") {
592
- compileList(scopeName, rawKeywords.split(" "));
593
- } else if (Array.isArray(rawKeywords)) {
594
- compileList(scopeName, rawKeywords);
595
- } else {
596
- Object.keys(rawKeywords).forEach(function(scopeName2) {
597
- Object.assign(
598
- compiledKeywords,
599
- compileKeywords(rawKeywords[scopeName2], caseInsensitive, scopeName2)
600
- );
601
- });
602
- }
603
- return compiledKeywords;
604
- function compileList(scopeName2, keywordList) {
605
- if (caseInsensitive) {
606
- keywordList = keywordList.map((x) => x.toLowerCase());
607
- }
608
- keywordList.forEach(function(keyword) {
609
- const pair = keyword.split("|");
610
- compiledKeywords[pair[0]] = [scopeName2, scoreForKeyword(pair[0], pair[1])];
611
- });
612
- }
613
- }
614
- function scoreForKeyword(keyword, providedScore) {
615
- if (providedScore) {
616
- return Number(providedScore);
617
- }
618
- return commonKeyword(keyword) ? 0 : 1;
619
- }
620
- function commonKeyword(keyword) {
621
- return COMMON_KEYWORDS.includes(keyword.toLowerCase());
622
- }
623
- const seenDeprecations = {};
624
- const error2 = (message) => {
625
- console.error(message);
626
- };
627
- const warn = (message, ...args) => {
628
- console.log(`WARN: ${message}`, ...args);
629
- };
630
- const deprecated = (version2, message) => {
631
- if (seenDeprecations[`${version2}/${message}`]) return;
632
- console.log(`Deprecated as of ${version2}. ${message}`);
633
- seenDeprecations[`${version2}/${message}`] = true;
634
- };
635
- const MultiClassError = new Error();
636
- function remapScopeNames(mode, regexes, { key }) {
637
- let offset = 0;
638
- const scopeNames = mode[key];
639
- const emit = {};
640
- const positions = {};
641
- for (let i = 1; i <= regexes.length; i++) {
642
- positions[i + offset] = scopeNames[i];
643
- emit[i + offset] = true;
644
- offset += countMatchGroups(regexes[i - 1]);
645
- }
646
- mode[key] = positions;
647
- mode[key]._emit = emit;
648
- mode[key]._multi = true;
649
- }
650
- function beginMultiClass(mode) {
651
- if (!Array.isArray(mode.begin)) return;
652
- if (mode.skip || mode.excludeBegin || mode.returnBegin) {
653
- error2("skip, excludeBegin, returnBegin not compatible with beginScope: {}");
654
- throw MultiClassError;
655
- }
656
- if (typeof mode.beginScope !== "object" || mode.beginScope === null) {
657
- error2("beginScope must be object");
658
- throw MultiClassError;
659
- }
660
- remapScopeNames(mode, mode.begin, { key: "beginScope" });
661
- mode.begin = _rewriteBackreferences(mode.begin, { joinWith: "" });
662
- }
663
- function endMultiClass(mode) {
664
- if (!Array.isArray(mode.end)) return;
665
- if (mode.skip || mode.excludeEnd || mode.returnEnd) {
666
- error2("skip, excludeEnd, returnEnd not compatible with endScope: {}");
667
- throw MultiClassError;
668
- }
669
- if (typeof mode.endScope !== "object" || mode.endScope === null) {
670
- error2("endScope must be object");
671
- throw MultiClassError;
672
- }
673
- remapScopeNames(mode, mode.end, { key: "endScope" });
674
- mode.end = _rewriteBackreferences(mode.end, { joinWith: "" });
675
- }
676
- function scopeSugar(mode) {
677
- if (mode.scope && typeof mode.scope === "object" && mode.scope !== null) {
678
- mode.beginScope = mode.scope;
679
- delete mode.scope;
680
- }
681
- }
682
- function MultiClass(mode) {
683
- scopeSugar(mode);
684
- if (typeof mode.beginScope === "string") {
685
- mode.beginScope = { _wrap: mode.beginScope };
686
- }
687
- if (typeof mode.endScope === "string") {
688
- mode.endScope = { _wrap: mode.endScope };
689
- }
690
- beginMultiClass(mode);
691
- endMultiClass(mode);
692
- }
693
- function compileLanguage(language) {
694
- function langRe(value, global) {
695
- return new RegExp(
696
- source(value),
697
- "m" + (language.case_insensitive ? "i" : "") + (language.unicodeRegex ? "u" : "") + (global ? "g" : "")
698
- );
699
- }
700
- class MultiRegex {
701
- constructor() {
702
- this.matchIndexes = {};
703
- this.regexes = [];
704
- this.matchAt = 1;
705
- this.position = 0;
706
- }
707
- // @ts-ignore
708
- addRule(re, opts) {
709
- opts.position = this.position++;
710
- this.matchIndexes[this.matchAt] = opts;
711
- this.regexes.push([opts, re]);
712
- this.matchAt += countMatchGroups(re) + 1;
713
- }
714
- compile() {
715
- if (this.regexes.length === 0) {
716
- this.exec = () => null;
717
- }
718
- const terminators = this.regexes.map((el) => el[1]);
719
- this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: "|" }), true);
720
- this.lastIndex = 0;
721
- }
722
- /** @param {string} s */
723
- exec(s) {
724
- this.matcherRe.lastIndex = this.lastIndex;
725
- const match = this.matcherRe.exec(s);
726
- if (!match) {
727
- return null;
728
- }
729
- const i = match.findIndex((el, i2) => i2 > 0 && el !== void 0);
730
- const matchData = this.matchIndexes[i];
731
- match.splice(0, i);
732
- return Object.assign(match, matchData);
733
- }
734
- }
735
- class ResumableMultiRegex {
736
- constructor() {
737
- this.rules = [];
738
- this.multiRegexes = [];
739
- this.count = 0;
740
- this.lastIndex = 0;
741
- this.regexIndex = 0;
742
- }
743
- // @ts-ignore
744
- getMatcher(index) {
745
- if (this.multiRegexes[index]) return this.multiRegexes[index];
746
- const matcher = new MultiRegex();
747
- this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
748
- matcher.compile();
749
- this.multiRegexes[index] = matcher;
750
- return matcher;
751
- }
752
- resumingScanAtSamePosition() {
753
- return this.regexIndex !== 0;
754
- }
755
- considerAll() {
756
- this.regexIndex = 0;
757
- }
758
- // @ts-ignore
759
- addRule(re, opts) {
760
- this.rules.push([re, opts]);
761
- if (opts.type === "begin") this.count++;
762
- }
763
- /** @param {string} s */
764
- exec(s) {
765
- const m = this.getMatcher(this.regexIndex);
766
- m.lastIndex = this.lastIndex;
767
- let result = m.exec(s);
768
- if (this.resumingScanAtSamePosition()) {
769
- if (result && result.index === this.lastIndex) ;
770
- else {
771
- const m2 = this.getMatcher(0);
772
- m2.lastIndex = this.lastIndex + 1;
773
- result = m2.exec(s);
774
- }
775
- }
776
- if (result) {
777
- this.regexIndex += result.position + 1;
778
- if (this.regexIndex === this.count) {
779
- this.considerAll();
780
- }
781
- }
782
- return result;
783
- }
784
- }
785
- function buildModeRegex(mode) {
786
- const mm = new ResumableMultiRegex();
787
- mode.contains.forEach((term) => mm.addRule(term.begin, { rule: term, type: "begin" }));
788
- if (mode.terminatorEnd) {
789
- mm.addRule(mode.terminatorEnd, { type: "end" });
790
- }
791
- if (mode.illegal) {
792
- mm.addRule(mode.illegal, { type: "illegal" });
793
- }
794
- return mm;
795
- }
796
- function compileMode(mode, parent) {
797
- const cmode = (
798
- /** @type CompiledMode */
799
- mode
800
- );
801
- if (mode.isCompiled) return cmode;
802
- [
803
- scopeClassName,
804
- // do this early so compiler extensions generally don't have to worry about
805
- // the distinction between match/begin
806
- compileMatch,
807
- MultiClass,
808
- beforeMatchExt
809
- ].forEach((ext) => ext(mode, parent));
810
- language.compilerExtensions.forEach((ext) => ext(mode, parent));
811
- mode.__beforeBegin = null;
812
- [
813
- beginKeywords,
814
- // do this later so compiler extensions that come earlier have access to the
815
- // raw array if they wanted to perhaps manipulate it, etc.
816
- compileIllegal,
817
- // default to 1 relevance if not specified
818
- compileRelevance
819
- ].forEach((ext) => ext(mode, parent));
820
- mode.isCompiled = true;
821
- let keywordPattern = null;
822
- if (typeof mode.keywords === "object" && mode.keywords.$pattern) {
823
- mode.keywords = Object.assign({}, mode.keywords);
824
- keywordPattern = mode.keywords.$pattern;
825
- delete mode.keywords.$pattern;
826
- }
827
- keywordPattern = keywordPattern || /\w+/;
828
- if (mode.keywords) {
829
- mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
830
- }
831
- cmode.keywordPatternRe = langRe(keywordPattern, true);
832
- if (parent) {
833
- if (!mode.begin) mode.begin = /\B|\b/;
834
- cmode.beginRe = langRe(cmode.begin);
835
- if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/;
836
- if (mode.end) cmode.endRe = langRe(cmode.end);
837
- cmode.terminatorEnd = source(cmode.end) || "";
838
- if (mode.endsWithParent && parent.terminatorEnd) {
839
- cmode.terminatorEnd += (mode.end ? "|" : "") + parent.terminatorEnd;
840
- }
841
- }
842
- if (mode.illegal) cmode.illegalRe = langRe(
843
- /** @type {RegExp | string} */
844
- mode.illegal
845
- );
846
- if (!mode.contains) mode.contains = [];
847
- mode.contains = [].concat(...mode.contains.map(function(c) {
848
- return expandOrCloneMode(c === "self" ? mode : c);
849
- }));
850
- mode.contains.forEach(function(c) {
851
- compileMode(
852
- /** @type Mode */
853
- c,
854
- cmode
855
- );
856
- });
857
- if (mode.starts) {
858
- compileMode(mode.starts, parent);
859
- }
860
- cmode.matcher = buildModeRegex(cmode);
861
- return cmode;
862
- }
863
- if (!language.compilerExtensions) language.compilerExtensions = [];
864
- if (language.contains && language.contains.includes("self")) {
865
- throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
866
- }
867
- language.classNameAliases = inherit$1(language.classNameAliases || {});
868
- return compileMode(
869
- /** @type Mode */
870
- language
871
- );
872
- }
873
- function dependencyOnParent(mode) {
874
- if (!mode) return false;
875
- return mode.endsWithParent || dependencyOnParent(mode.starts);
876
- }
877
- function expandOrCloneMode(mode) {
878
- if (mode.variants && !mode.cachedVariants) {
879
- mode.cachedVariants = mode.variants.map(function(variant) {
880
- return inherit$1(mode, { variants: null }, variant);
881
- });
882
- }
883
- if (mode.cachedVariants) {
884
- return mode.cachedVariants;
885
- }
886
- if (dependencyOnParent(mode)) {
887
- return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null });
888
- }
889
- if (Object.isFrozen(mode)) {
890
- return inherit$1(mode);
891
- }
892
- return mode;
893
- }
894
- var version = "11.9.0";
895
- class HTMLInjectionError extends Error {
896
- constructor(reason, html) {
897
- super(reason);
898
- this.name = "HTMLInjectionError";
899
- this.html = html;
900
- }
901
- }
902
- const escape = escapeHTML;
903
- const inherit = inherit$1;
904
- const NO_MATCH = Symbol("nomatch");
905
- const MAX_KEYWORD_HITS = 7;
906
- const HLJS = function(hljs) {
907
- const languages = /* @__PURE__ */ Object.create(null);
908
- const aliases = /* @__PURE__ */ Object.create(null);
909
- const plugins = [];
910
- let SAFE_MODE = true;
911
- const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
912
- const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: "Plain text", contains: [] };
913
- let options = {
914
- ignoreUnescapedHTML: false,
915
- throwUnescapedHTML: false,
916
- noHighlightRe: /^(no-?highlight)$/i,
917
- languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
918
- classPrefix: "hljs-",
919
- cssSelector: "pre code",
920
- languages: null,
921
- // beta configuration options, subject to change, welcome to discuss
922
- // https://github.com/highlightjs/highlight.js/issues/1086
923
- __emitter: TokenTreeEmitter
924
- };
925
- function shouldNotHighlight(languageName) {
926
- return options.noHighlightRe.test(languageName);
927
- }
928
- function blockLanguage(block2) {
929
- let classes = block2.className + " ";
930
- classes += block2.parentNode ? block2.parentNode.className : "";
931
- const match = options.languageDetectRe.exec(classes);
932
- if (match) {
933
- const language = getLanguage(match[1]);
934
- if (!language) {
935
- warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
936
- warn("Falling back to no-highlight mode for this block.", block2);
937
- }
938
- return language ? match[1] : "no-highlight";
939
- }
940
- return classes.split(/\s+/).find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
941
- }
942
- function highlight2(codeOrLanguageName, optionsOrCode, ignoreIllegals) {
943
- let code = "";
944
- let languageName = "";
945
- if (typeof optionsOrCode === "object") {
946
- code = codeOrLanguageName;
947
- ignoreIllegals = optionsOrCode.ignoreIllegals;
948
- languageName = optionsOrCode.language;
949
- } else {
950
- deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated.");
951
- deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");
952
- languageName = codeOrLanguageName;
953
- code = optionsOrCode;
954
- }
955
- if (ignoreIllegals === void 0) {
956
- ignoreIllegals = true;
957
- }
958
- const context = {
959
- code,
960
- language: languageName
961
- };
962
- fire("before:highlight", context);
963
- const result = context.result ? context.result : _highlight(context.language, context.code, ignoreIllegals);
964
- result.code = context.code;
965
- fire("after:highlight", result);
966
- return result;
967
- }
968
- function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) {
969
- const keywordHits = /* @__PURE__ */ Object.create(null);
970
- function keywordData(mode, matchText) {
971
- return mode.keywords[matchText];
972
- }
973
- function processKeywords() {
974
- if (!top.keywords) {
975
- emitter.addText(modeBuffer);
976
- return;
977
- }
978
- let lastIndex = 0;
979
- top.keywordPatternRe.lastIndex = 0;
980
- let match = top.keywordPatternRe.exec(modeBuffer);
981
- let buf = "";
982
- while (match) {
983
- buf += modeBuffer.substring(lastIndex, match.index);
984
- const word = language.case_insensitive ? match[0].toLowerCase() : match[0];
985
- const data = keywordData(top, word);
986
- if (data) {
987
- const [kind, keywordRelevance] = data;
988
- emitter.addText(buf);
989
- buf = "";
990
- keywordHits[word] = (keywordHits[word] || 0) + 1;
991
- if (keywordHits[word] <= MAX_KEYWORD_HITS) relevance += keywordRelevance;
992
- if (kind.startsWith("_")) {
993
- buf += match[0];
994
- } else {
995
- const cssClass = language.classNameAliases[kind] || kind;
996
- emitKeyword(match[0], cssClass);
997
- }
998
- } else {
999
- buf += match[0];
1000
- }
1001
- lastIndex = top.keywordPatternRe.lastIndex;
1002
- match = top.keywordPatternRe.exec(modeBuffer);
1003
- }
1004
- buf += modeBuffer.substring(lastIndex);
1005
- emitter.addText(buf);
1006
- }
1007
- function processSubLanguage() {
1008
- if (modeBuffer === "") return;
1009
- let result2 = null;
1010
- if (typeof top.subLanguage === "string") {
1011
- if (!languages[top.subLanguage]) {
1012
- emitter.addText(modeBuffer);
1013
- return;
1014
- }
1015
- result2 = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
1016
- continuations[top.subLanguage] = /** @type {CompiledMode} */
1017
- result2._top;
1018
- } else {
1019
- result2 = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
1020
- }
1021
- if (top.relevance > 0) {
1022
- relevance += result2.relevance;
1023
- }
1024
- emitter.__addSublanguage(result2._emitter, result2.language);
1025
- }
1026
- function processBuffer() {
1027
- if (top.subLanguage != null) {
1028
- processSubLanguage();
1029
- } else {
1030
- processKeywords();
1031
- }
1032
- modeBuffer = "";
1033
- }
1034
- function emitKeyword(keyword, scope) {
1035
- if (keyword === "") return;
1036
- emitter.startScope(scope);
1037
- emitter.addText(keyword);
1038
- emitter.endScope();
1039
- }
1040
- function emitMultiClass(scope, match) {
1041
- let i = 1;
1042
- const max = match.length - 1;
1043
- while (i <= max) {
1044
- if (!scope._emit[i]) {
1045
- i++;
1046
- continue;
1047
- }
1048
- const klass = language.classNameAliases[scope[i]] || scope[i];
1049
- const text = match[i];
1050
- if (klass) {
1051
- emitKeyword(text, klass);
1052
- } else {
1053
- modeBuffer = text;
1054
- processKeywords();
1055
- modeBuffer = "";
1056
- }
1057
- i++;
1058
- }
1059
- }
1060
- function startNewMode(mode, match) {
1061
- if (mode.scope && typeof mode.scope === "string") {
1062
- emitter.openNode(language.classNameAliases[mode.scope] || mode.scope);
1063
- }
1064
- if (mode.beginScope) {
1065
- if (mode.beginScope._wrap) {
1066
- emitKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap);
1067
- modeBuffer = "";
1068
- } else if (mode.beginScope._multi) {
1069
- emitMultiClass(mode.beginScope, match);
1070
- modeBuffer = "";
1071
- }
1072
- }
1073
- top = Object.create(mode, { parent: { value: top } });
1074
- return top;
1075
- }
1076
- function endOfMode(mode, match, matchPlusRemainder) {
1077
- let matched = startsWith(mode.endRe, matchPlusRemainder);
1078
- if (matched) {
1079
- if (mode["on:end"]) {
1080
- const resp = new Response(mode);
1081
- mode["on:end"](match, resp);
1082
- if (resp.isMatchIgnored) matched = false;
1083
- }
1084
- if (matched) {
1085
- while (mode.endsParent && mode.parent) {
1086
- mode = mode.parent;
1087
- }
1088
- return mode;
1089
- }
1090
- }
1091
- if (mode.endsWithParent) {
1092
- return endOfMode(mode.parent, match, matchPlusRemainder);
1093
- }
1094
- }
1095
- function doIgnore(lexeme) {
1096
- if (top.matcher.regexIndex === 0) {
1097
- modeBuffer += lexeme[0];
1098
- return 1;
1099
- } else {
1100
- resumeScanAtSamePosition = true;
1101
- return 0;
1102
- }
1103
- }
1104
- function doBeginMatch(match) {
1105
- const lexeme = match[0];
1106
- const newMode = match.rule;
1107
- const resp = new Response(newMode);
1108
- const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
1109
- for (const cb of beforeCallbacks) {
1110
- if (!cb) continue;
1111
- cb(match, resp);
1112
- if (resp.isMatchIgnored) return doIgnore(lexeme);
1113
- }
1114
- if (newMode.skip) {
1115
- modeBuffer += lexeme;
1116
- } else {
1117
- if (newMode.excludeBegin) {
1118
- modeBuffer += lexeme;
1119
- }
1120
- processBuffer();
1121
- if (!newMode.returnBegin && !newMode.excludeBegin) {
1122
- modeBuffer = lexeme;
1123
- }
1124
- }
1125
- startNewMode(newMode, match);
1126
- return newMode.returnBegin ? 0 : lexeme.length;
1127
- }
1128
- function doEndMatch(match) {
1129
- const lexeme = match[0];
1130
- const matchPlusRemainder = codeToHighlight.substring(match.index);
1131
- const endMode = endOfMode(top, match, matchPlusRemainder);
1132
- if (!endMode) {
1133
- return NO_MATCH;
1134
- }
1135
- const origin = top;
1136
- if (top.endScope && top.endScope._wrap) {
1137
- processBuffer();
1138
- emitKeyword(lexeme, top.endScope._wrap);
1139
- } else if (top.endScope && top.endScope._multi) {
1140
- processBuffer();
1141
- emitMultiClass(top.endScope, match);
1142
- } else if (origin.skip) {
1143
- modeBuffer += lexeme;
1144
- } else {
1145
- if (!(origin.returnEnd || origin.excludeEnd)) {
1146
- modeBuffer += lexeme;
1147
- }
1148
- processBuffer();
1149
- if (origin.excludeEnd) {
1150
- modeBuffer = lexeme;
1151
- }
1152
- }
1153
- do {
1154
- if (top.scope) {
1155
- emitter.closeNode();
1156
- }
1157
- if (!top.skip && !top.subLanguage) {
1158
- relevance += top.relevance;
1159
- }
1160
- top = top.parent;
1161
- } while (top !== endMode.parent);
1162
- if (endMode.starts) {
1163
- startNewMode(endMode.starts, match);
1164
- }
1165
- return origin.returnEnd ? 0 : lexeme.length;
1166
- }
1167
- function processContinuations() {
1168
- const list = [];
1169
- for (let current = top; current !== language; current = current.parent) {
1170
- if (current.scope) {
1171
- list.unshift(current.scope);
1172
- }
1173
- }
1174
- list.forEach((item) => emitter.openNode(item));
1175
- }
1176
- let lastMatch = {};
1177
- function processLexeme(textBeforeMatch, match) {
1178
- const lexeme = match && match[0];
1179
- modeBuffer += textBeforeMatch;
1180
- if (lexeme == null) {
1181
- processBuffer();
1182
- return 0;
1183
- }
1184
- if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") {
1185
- modeBuffer += codeToHighlight.slice(match.index, match.index + 1);
1186
- if (!SAFE_MODE) {
1187
- const err = new Error(`0 width match regex (${languageName})`);
1188
- err.languageName = languageName;
1189
- err.badRule = lastMatch.rule;
1190
- throw err;
1191
- }
1192
- return 1;
1193
- }
1194
- lastMatch = match;
1195
- if (match.type === "begin") {
1196
- return doBeginMatch(match);
1197
- } else if (match.type === "illegal" && !ignoreIllegals) {
1198
- const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || "<unnamed>") + '"');
1199
- err.mode = top;
1200
- throw err;
1201
- } else if (match.type === "end") {
1202
- const processed = doEndMatch(match);
1203
- if (processed !== NO_MATCH) {
1204
- return processed;
1205
- }
1206
- }
1207
- if (match.type === "illegal" && lexeme === "") {
1208
- return 1;
1209
- }
1210
- if (iterations > 1e5 && iterations > match.index * 3) {
1211
- const err = new Error("potential infinite loop, way more iterations than matches");
1212
- throw err;
1213
- }
1214
- modeBuffer += lexeme;
1215
- return lexeme.length;
1216
- }
1217
- const language = getLanguage(languageName);
1218
- if (!language) {
1219
- error2(LANGUAGE_NOT_FOUND.replace("{}", languageName));
1220
- throw new Error('Unknown language: "' + languageName + '"');
1221
- }
1222
- const md = compileLanguage(language);
1223
- let result = "";
1224
- let top = continuation || md;
1225
- const continuations = {};
1226
- const emitter = new options.__emitter(options);
1227
- processContinuations();
1228
- let modeBuffer = "";
1229
- let relevance = 0;
1230
- let index = 0;
1231
- let iterations = 0;
1232
- let resumeScanAtSamePosition = false;
1233
- try {
1234
- if (!language.__emitTokens) {
1235
- top.matcher.considerAll();
1236
- for (; ; ) {
1237
- iterations++;
1238
- if (resumeScanAtSamePosition) {
1239
- resumeScanAtSamePosition = false;
1240
- } else {
1241
- top.matcher.considerAll();
1242
- }
1243
- top.matcher.lastIndex = index;
1244
- const match = top.matcher.exec(codeToHighlight);
1245
- if (!match) break;
1246
- const beforeMatch = codeToHighlight.substring(index, match.index);
1247
- const processedCount = processLexeme(beforeMatch, match);
1248
- index = match.index + processedCount;
1249
- }
1250
- processLexeme(codeToHighlight.substring(index));
1251
- } else {
1252
- language.__emitTokens(codeToHighlight, emitter);
1253
- }
1254
- emitter.finalize();
1255
- result = emitter.toHTML();
1256
- return {
1257
- language: languageName,
1258
- value: result,
1259
- relevance,
1260
- illegal: false,
1261
- _emitter: emitter,
1262
- _top: top
1263
- };
1264
- } catch (err) {
1265
- if (err.message && err.message.includes("Illegal")) {
1266
- return {
1267
- language: languageName,
1268
- value: escape(codeToHighlight),
1269
- illegal: true,
1270
- relevance: 0,
1271
- _illegalBy: {
1272
- message: err.message,
1273
- index,
1274
- context: codeToHighlight.slice(index - 100, index + 100),
1275
- mode: err.mode,
1276
- resultSoFar: result
1277
- },
1278
- _emitter: emitter
1279
- };
1280
- } else if (SAFE_MODE) {
1281
- return {
1282
- language: languageName,
1283
- value: escape(codeToHighlight),
1284
- illegal: false,
1285
- relevance: 0,
1286
- errorRaised: err,
1287
- _emitter: emitter,
1288
- _top: top
1289
- };
1290
- } else {
1291
- throw err;
1292
- }
1293
- }
1294
- }
1295
- function justTextHighlightResult(code) {
1296
- const result = {
1297
- value: escape(code),
1298
- illegal: false,
1299
- relevance: 0,
1300
- _top: PLAINTEXT_LANGUAGE,
1301
- _emitter: new options.__emitter(options)
1302
- };
1303
- result._emitter.addText(code);
1304
- return result;
1305
- }
1306
- function highlightAuto(code, languageSubset) {
1307
- languageSubset = languageSubset || options.languages || Object.keys(languages);
1308
- const plaintext = justTextHighlightResult(code);
1309
- const results = languageSubset.filter(getLanguage).filter(autoDetection).map(
1310
- (name) => _highlight(name, code, false)
1311
- );
1312
- results.unshift(plaintext);
1313
- const sorted = results.sort((a, b) => {
1314
- if (a.relevance !== b.relevance) return b.relevance - a.relevance;
1315
- if (a.language && b.language) {
1316
- if (getLanguage(a.language).supersetOf === b.language) {
1317
- return 1;
1318
- } else if (getLanguage(b.language).supersetOf === a.language) {
1319
- return -1;
1320
- }
1321
- }
1322
- return 0;
1323
- });
1324
- const [best, secondBest] = sorted;
1325
- const result = best;
1326
- result.secondBest = secondBest;
1327
- return result;
1328
- }
1329
- function updateClassName(element, currentLang, resultLang) {
1330
- const language = currentLang && aliases[currentLang] || resultLang;
1331
- element.classList.add("hljs");
1332
- element.classList.add(`language-${language}`);
1333
- }
1334
- function highlightElement(element) {
1335
- let node = null;
1336
- const language = blockLanguage(element);
1337
- if (shouldNotHighlight(language)) return;
1338
- fire(
1339
- "before:highlightElement",
1340
- { el: element, language }
1341
- );
1342
- if (element.dataset.highlighted) {
1343
- console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", element);
1344
- return;
1345
- }
1346
- if (element.children.length > 0) {
1347
- if (!options.ignoreUnescapedHTML) {
1348
- console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk.");
1349
- console.warn("https://github.com/highlightjs/highlight.js/wiki/security");
1350
- console.warn("The element with unescaped HTML:");
1351
- console.warn(element);
1352
- }
1353
- if (options.throwUnescapedHTML) {
1354
- const err = new HTMLInjectionError(
1355
- "One of your code blocks includes unescaped HTML.",
1356
- element.innerHTML
1357
- );
1358
- throw err;
1359
- }
1360
- }
1361
- node = element;
1362
- const text = node.textContent;
1363
- const result = language ? highlight2(text, { language, ignoreIllegals: true }) : highlightAuto(text);
1364
- element.innerHTML = result.value;
1365
- element.dataset.highlighted = "yes";
1366
- updateClassName(element, language, result.language);
1367
- element.result = {
1368
- language: result.language,
1369
- // TODO: remove with version 11.0
1370
- re: result.relevance,
1371
- relevance: result.relevance
1372
- };
1373
- if (result.secondBest) {
1374
- element.secondBest = {
1375
- language: result.secondBest.language,
1376
- relevance: result.secondBest.relevance
1377
- };
1378
- }
1379
- fire("after:highlightElement", { el: element, result, text });
1380
- }
1381
- function configure(userOptions) {
1382
- options = inherit(options, userOptions);
1383
- }
1384
- const initHighlighting = () => {
1385
- highlightAll();
1386
- deprecated("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
1387
- };
1388
- function initHighlightingOnLoad() {
1389
- highlightAll();
1390
- deprecated("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now.");
1391
- }
1392
- let wantsHighlight = false;
1393
- function highlightAll() {
1394
- if (document.readyState === "loading") {
1395
- wantsHighlight = true;
1396
- return;
1397
- }
1398
- const blocks = document.querySelectorAll(options.cssSelector);
1399
- blocks.forEach(highlightElement);
1400
- }
1401
- function boot() {
1402
- if (wantsHighlight) highlightAll();
1403
- }
1404
- if (typeof window !== "undefined" && window.addEventListener) {
1405
- window.addEventListener("DOMContentLoaded", boot, false);
1406
- }
1407
- function registerLanguage(languageName, languageDefinition) {
1408
- let lang = null;
1409
- try {
1410
- lang = languageDefinition(hljs);
1411
- } catch (error$1) {
1412
- error2("Language definition for '{}' could not be registered.".replace("{}", languageName));
1413
- if (!SAFE_MODE) {
1414
- throw error$1;
1415
- } else {
1416
- error2(error$1);
1417
- }
1418
- lang = PLAINTEXT_LANGUAGE;
1419
- }
1420
- if (!lang.name) lang.name = languageName;
1421
- languages[languageName] = lang;
1422
- lang.rawDefinition = languageDefinition.bind(null, hljs);
1423
- if (lang.aliases) {
1424
- registerAliases(lang.aliases, { languageName });
1425
- }
1426
- }
1427
- function unregisterLanguage(languageName) {
1428
- delete languages[languageName];
1429
- for (const alias of Object.keys(aliases)) {
1430
- if (aliases[alias] === languageName) {
1431
- delete aliases[alias];
1432
- }
1433
- }
1434
- }
1435
- function listLanguages() {
1436
- return Object.keys(languages);
1437
- }
1438
- function getLanguage(name) {
1439
- name = (name || "").toLowerCase();
1440
- return languages[name] || languages[aliases[name]];
1441
- }
1442
- function registerAliases(aliasList, { languageName }) {
1443
- if (typeof aliasList === "string") {
1444
- aliasList = [aliasList];
1445
- }
1446
- aliasList.forEach((alias) => {
1447
- aliases[alias.toLowerCase()] = languageName;
1448
- });
1449
- }
1450
- function autoDetection(name) {
1451
- const lang = getLanguage(name);
1452
- return lang && !lang.disableAutodetect;
1453
- }
1454
- function upgradePluginAPI(plugin) {
1455
- if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) {
1456
- plugin["before:highlightElement"] = (data) => {
1457
- plugin["before:highlightBlock"](
1458
- Object.assign({ block: data.el }, data)
1459
- );
1460
- };
1461
- }
1462
- if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) {
1463
- plugin["after:highlightElement"] = (data) => {
1464
- plugin["after:highlightBlock"](
1465
- Object.assign({ block: data.el }, data)
1466
- );
1467
- };
1468
- }
1469
- }
1470
- function addPlugin(plugin) {
1471
- upgradePluginAPI(plugin);
1472
- plugins.push(plugin);
1473
- }
1474
- function removePlugin(plugin) {
1475
- const index = plugins.indexOf(plugin);
1476
- if (index !== -1) {
1477
- plugins.splice(index, 1);
1478
- }
1479
- }
1480
- function fire(event, args) {
1481
- const cb = event;
1482
- plugins.forEach(function(plugin) {
1483
- if (plugin[cb]) {
1484
- plugin[cb](args);
1485
- }
1486
- });
1487
- }
1488
- function deprecateHighlightBlock(el) {
1489
- deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0");
1490
- deprecated("10.7.0", "Please use highlightElement now.");
1491
- return highlightElement(el);
1492
- }
1493
- Object.assign(hljs, {
1494
- highlight: highlight2,
1495
- highlightAuto,
1496
- highlightAll,
1497
- highlightElement,
1498
- // TODO: Remove with v12 API
1499
- highlightBlock: deprecateHighlightBlock,
1500
- configure,
1501
- initHighlighting,
1502
- initHighlightingOnLoad,
1503
- registerLanguage,
1504
- unregisterLanguage,
1505
- listLanguages,
1506
- getLanguage,
1507
- registerAliases,
1508
- autoDetection,
1509
- inherit,
1510
- addPlugin,
1511
- removePlugin
1512
- });
1513
- hljs.debugMode = function() {
1514
- SAFE_MODE = false;
1515
- };
1516
- hljs.safeMode = function() {
1517
- SAFE_MODE = true;
1518
- };
1519
- hljs.versionString = version;
1520
- hljs.regex = {
1521
- concat,
1522
- lookahead,
1523
- either,
1524
- optional,
1525
- anyNumberOfTimes
1526
- };
1527
- for (const key in MODES) {
1528
- if (typeof MODES[key] === "object") {
1529
- deepFreeze(MODES[key]);
1530
- }
1531
- }
1532
- Object.assign(hljs, MODES);
1533
- return hljs;
1534
- };
1535
- const highlight = HLJS({});
1536
- highlight.newInstance = () => HLJS({});
1537
- core = highlight;
1538
- highlight.HighlightJS = highlight;
1539
- highlight.default = highlight;
1540
- return core;
1541
- }
1542
- var coreExports = /* @__PURE__ */ requireCore();
1543
- const HighlightJS = /* @__PURE__ */ getDefaultExportFromCjs(coreExports);
1544
- function createNode(parent, nodeName, currentDepth, runIndex, r, children = []) {
1545
- return {
1546
- parent,
1547
- node: nodeName,
1548
- id: `${nodeName}:${runIndex}`,
1549
- depth: currentDepth,
1550
- startTime: r?.data?.metadata?.startTime ?? 0,
1551
- runIndex,
1552
- children,
1553
- consumedTokens: getConsumedTokens(r?.data)
1554
- };
1555
- }
1556
- function getTreeNodeData(nodeName, workflow, aiData, runIndex) {
1557
- return getTreeNodeDataRec(void 0, nodeName, 0, workflow, aiData, runIndex);
1558
- }
1559
- function getTreeNodeDataRec(parent, nodeName, currentDepth, workflow, aiData, runIndex) {
1560
- const connections = workflow.connectionsByDestinationNode[nodeName];
1561
- const resultData = aiData?.filter(
1562
- (data) => data.node === nodeName && (runIndex === void 0 || runIndex === data.runIndex)
1563
- ) ?? [];
1564
- if (!connections) {
1565
- return resultData.map((d) => createNode(parent, nodeName, currentDepth, d.runIndex, d));
1566
- }
1567
- const connectedSubNodes = workflow.getParentNodes(nodeName, "ALL_NON_MAIN", 1);
1568
- const treeNode2 = createNode(parent, nodeName, currentDepth, runIndex ?? 0);
1569
- const children = (aiData ?? []).flatMap(
1570
- (data) => connectedSubNodes.includes(data.node) && (runIndex === void 0 || data.runIndex === runIndex) ? getTreeNodeDataRec(treeNode2, data.node, currentDepth + 1, workflow, aiData, data.runIndex) : []
1571
- );
1572
- treeNode2.children = children;
1573
- if (resultData.length) {
1574
- return resultData.map(
1575
- (r) => createNode(parent, nodeName, currentDepth, r.runIndex, r, children)
1576
- );
1577
- }
1578
- return [treeNode2];
1579
- }
1580
- function createAiData(nodeName, workflow, getWorkflowResultDataByNodeName) {
1581
- return workflow.getParentNodes(nodeName, "ALL_NON_MAIN").flatMap(
1582
- (node) => (getWorkflowResultDataByNodeName(node) ?? []).map((task, index) => ({ node, task, index }))
1583
- ).sort((a, b) => {
1584
- if (a.task.executionIndex !== void 0 && b.task.executionIndex !== void 0) {
1585
- return a.task.executionIndex - b.task.executionIndex;
1586
- }
1587
- const aTime = a.task.startTime ?? 0;
1588
- const bTime = b.task.startTime ?? 0;
1589
- return aTime - bTime;
1590
- }).map(({ node, task, index }) => ({
1591
- data: getReferencedData(task, false)[0],
1592
- node,
1593
- runIndex: index
1594
- }));
1595
- }
1596
- function getReferencedData(taskData, withInput, withOutput) {
1597
- if (!taskData) {
1598
- return [];
1599
- }
1600
- const returnData = [];
1601
- function addFunction(data, inOut) {
1602
- if (!data) {
1603
- return;
1604
- }
1605
- Object.keys(data).map((type) => {
1606
- returnData.push({
1607
- data: data[type][0],
1608
- inOut,
1609
- type,
1610
- metadata: {
1611
- executionTime: taskData.executionTime,
1612
- startTime: taskData.startTime,
1613
- subExecution: taskData.metadata?.subExecution
1614
- }
1615
- });
1616
- });
1617
- }
1618
- if (withInput) {
1619
- addFunction(taskData.inputOverride, "input");
1620
- }
1621
- {
1622
- addFunction(taskData.data, "output");
1623
- }
1624
- return returnData;
1625
- }
1626
- const emptyTokenUsageData = {
1627
- completionTokens: 0,
1628
- promptTokens: 0,
1629
- totalTokens: 0,
1630
- isEstimate: false
1631
- };
1632
- function addTokenUsageData(one, another) {
1633
- return {
1634
- completionTokens: one.completionTokens + another.completionTokens,
1635
- promptTokens: one.promptTokens + another.promptTokens,
1636
- totalTokens: one.totalTokens + another.totalTokens,
1637
- isEstimate: one.isEstimate || another.isEstimate
1638
- };
1639
- }
1640
- function getConsumedTokens(outputRun) {
1641
- if (!outputRun?.data) {
1642
- return emptyTokenUsageData;
1643
- }
1644
- const tokenUsage = outputRun.data.reduce(
1645
- (acc, curr) => {
1646
- const tokenUsageData = curr.json?.tokenUsage ?? curr.json?.tokenUsageEstimate;
1647
- if (!tokenUsageData) return acc;
1648
- return addTokenUsageData(acc, {
1649
- ...tokenUsageData,
1650
- isEstimate: !!curr.json.tokenUsageEstimate
1651
- });
1652
- },
1653
- emptyTokenUsageData
1654
- );
1655
- return tokenUsage;
1656
- }
1657
- function getTotalConsumedTokens(...usage) {
1658
- return usage.reduce(addTokenUsageData, emptyTokenUsageData);
1659
- }
1660
- function getSubtreeTotalConsumedTokens(treeNode2) {
1661
- return getTotalConsumedTokens(
1662
- treeNode2.consumedTokens,
1663
- ...treeNode2.children.map(getSubtreeTotalConsumedTokens)
1664
- );
1665
- }
1666
- function formatTokenUsageCount(usage, field) {
1667
- const count = field === "total" ? usage.totalTokens : field === "completion" ? usage.completionTokens : usage.promptTokens;
1668
- return usage.isEstimate ? `~${count}` : count.toLocaleString();
1669
- }
1670
- function createLogEntries(workflow, runData2) {
1671
- const runs = Object.entries(runData2).filter(([nodeName]) => workflow.getChildNodes(nodeName, "ALL_NON_MAIN").length === 0).flatMap(
1672
- ([nodeName, taskData]) => taskData.map((task, runIndex) => ({ nodeName, task, runIndex }))
1673
- ).sort((a, b) => {
1674
- if (a.task.executionIndex !== void 0 && b.task.executionIndex !== void 0) {
1675
- return a.task.executionIndex - b.task.executionIndex;
1676
- }
1677
- return a.nodeName === b.nodeName ? a.runIndex - b.runIndex : a.task.startTime - b.task.startTime;
1678
- });
1679
- return runs.flatMap(({ nodeName, runIndex, task }) => {
1680
- if (workflow.getParentNodes(nodeName, "ALL_NON_MAIN").length > 0) {
1681
- return getTreeNodeData(
1682
- nodeName,
1683
- workflow,
1684
- createAiData(nodeName, workflow, (node) => runData2[node] ?? []),
1685
- void 0
1686
- );
1687
- }
1688
- return getTreeNodeData(
1689
- nodeName,
1690
- workflow,
1691
- [
1692
- {
1693
- data: getReferencedData(task, false)[0],
1694
- node: nodeName,
1695
- runIndex
1696
- }
1697
- ],
1698
- runIndex
1699
- );
1700
- });
1701
- }
1702
- const _hoisted_1$4 = { class: "node-error-view" };
1703
- const _hoisted_2$3 = { class: "node-error-view__header" };
1704
- const _hoisted_3$2 = {
1705
- class: "node-error-view__header-message",
1706
- "data-test-id": "node-error-message"
1707
- };
1708
- const _hoisted_4 = {
1709
- key: 0,
1710
- "data-test-id": "node-error-description",
1711
- class: "node-error-view__header-description"
1712
- };
1713
- const _hoisted_5 = { key: 1 };
1714
- const _hoisted_6 = {
1715
- key: 2,
1716
- class: "node-error-view__button",
1717
- "data-test-id": "node-error-view-ask-assistant-button"
1718
- };
1719
- const _hoisted_7 = {
1720
- key: 0,
1721
- class: "node-error-view__info"
1722
- };
1723
- const _hoisted_8 = { class: "node-error-view__info-header" };
1724
- const _hoisted_9 = { class: "node-error-view__info-title" };
1725
- const _hoisted_10 = { class: "copy-button" };
1726
- const _hoisted_11 = { class: "node-error-view__info-content" };
1727
- const _hoisted_12 = {
1728
- key: 0,
1729
- class: "node-error-view__details"
1730
- };
1731
- const _hoisted_13 = { class: "node-error-view__details-summary" };
1732
- const _hoisted_14 = { class: "node-error-view__details-content" };
1733
- const _hoisted_15 = {
1734
- key: 0,
1735
- class: "node-error-view__details-row"
1736
- };
1737
- const _hoisted_16 = { class: "node-error-view__details-label" };
1738
- const _hoisted_17 = { class: "node-error-view__details-value" };
1739
- const _hoisted_18 = {
1740
- key: 1,
1741
- class: "node-error-view__details-row"
1742
- };
1743
- const _hoisted_19 = { class: "node-error-view__details-label" };
1744
- const _hoisted_20 = { class: "node-error-view__details-value" };
1745
- const _hoisted_21 = {
1746
- key: 2,
1747
- class: "node-error-view__details-row"
1748
- };
1749
- const _hoisted_22 = { class: "node-error-view__details-label" };
1750
- const _hoisted_23 = { class: "node-error-view__details-value" };
1751
- const _hoisted_24 = {
1752
- key: 3,
1753
- class: "node-error-view__details-row"
1754
- };
1755
- const _hoisted_25 = { class: "node-error-view__details-label" };
1756
- const _hoisted_26 = { class: "node-error-view__details-value" };
1757
- const _hoisted_27 = {
1758
- key: 4,
1759
- class: "node-error-view__details-row"
1760
- };
1761
- const _hoisted_28 = { class: "node-error-view__details-label" };
1762
- const _hoisted_29 = { class: "node-error-view__details-value" };
1763
- const _hoisted_30 = { class: "node-error-view__details" };
1764
- const _hoisted_31 = { class: "node-error-view__details-summary" };
1765
- const _hoisted_32 = { class: "node-error-view__details-content" };
1766
- const _hoisted_33 = {
1767
- key: 0,
1768
- class: "node-error-view__details-row"
1769
- };
1770
- const _hoisted_34 = { class: "node-error-view__details-label" };
1771
- const _hoisted_35 = { class: "node-error-view__details-value" };
1772
- const _hoisted_36 = {
1773
- key: 1,
1774
- class: "node-error-view__details-row"
1775
- };
1776
- const _hoisted_37 = { class: "node-error-view__details-label" };
1777
- const _hoisted_38 = { class: "node-error-view__details-value" };
1778
- const _hoisted_39 = {
1779
- key: 2,
1780
- class: "node-error-view__details-row"
1781
- };
1782
- const _hoisted_40 = { class: "node-error-view__details-label" };
1783
- const _hoisted_41 = { class: "node-error-view__details-value" };
1784
- const _hoisted_42 = {
1785
- key: 3,
1786
- class: "node-error-view__details-row"
1787
- };
1788
- const _hoisted_43 = { class: "node-error-view__details-label" };
1789
- const _hoisted_44 = { class: "node-error-view__details-value" };
1790
- const _hoisted_45 = {
1791
- key: 4,
1792
- class: "node-error-view__details-row"
1793
- };
1794
- const _hoisted_46 = { class: "node-error-view__details-label" };
1795
- const _hoisted_47 = { class: "node-error-view__details-value" };
1796
- const _hoisted_48 = { class: "node-error-view__details-row" };
1797
- const _hoisted_49 = { class: "node-error-view__details-label" };
1798
- const _hoisted_50 = { class: "node-error-view__details-value" };
1799
- const _hoisted_51 = {
1800
- key: 5,
1801
- class: "node-error-view__details-row"
1802
- };
1803
- const _hoisted_52 = { class: "node-error-view__details-label" };
1804
- const _hoisted_53 = { class: "node-error-view__details-value" };
1805
- const _hoisted_54 = {
1806
- key: 6,
1807
- class: "node-error-view__details-row"
1808
- };
1809
- const _hoisted_55 = { class: "node-error-view__details-label" };
1810
- const _hoisted_56 = { class: "node-error-view__details-value" };
1811
- const _hoisted_57 = {
1812
- key: 7,
1813
- class: "node-error-view__details-row"
1814
- };
1815
- const _hoisted_58 = { class: "node-error-view__details-label" };
1816
- const _hoisted_59 = { class: "node-error-view__details-value" };
1817
- const _hoisted_60 = {
1818
- key: 8,
1819
- class: "node-error-view__details-row"
1820
- };
1821
- const _hoisted_61 = { class: "node-error-view__details-label" };
1822
- const _hoisted_62 = { class: "node-error-view__details-value" };
1823
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1824
- __name: "NodeErrorView",
1825
- props: {
1826
- error: {},
1827
- compact: { type: Boolean }
1828
- },
1829
- setup(__props) {
1830
- const props = __props;
1831
- const clipboard = useClipboard();
1832
- const toast = useToast();
1833
- const i18n = useI18n();
1834
- const assistantHelpers = useAIAssistantHelpers();
1835
- const nodeTypesStore = useNodeTypesStore();
1836
- const ndvStore = useNDVStore();
1837
- const rootStore = useRootStore();
1838
- const assistantStore = useAssistantStore();
1839
- const uiStore = useUIStore();
1840
- const displayCause = computed(() => {
1841
- return JSON.stringify(props.error.cause ?? "").length < MAX_DISPLAY_DATA_SIZE;
1842
- });
1843
- const node = computed(() => {
1844
- return props.error.node || ndvStore.activeNode;
1845
- });
1846
- const parameters = computed(() => {
1847
- if (!node.value) {
1848
- return [];
1849
- }
1850
- const nodeType = nodeTypesStore.getNodeType(node.value.type, node.value.typeVersion);
1851
- if (nodeType === null) {
1852
- return [];
1853
- }
1854
- return nodeType.properties;
1855
- });
1856
- const n8nVersion = computed(() => {
1857
- const baseUrl = rootStore.urlBaseEditor;
1858
- let instanceType = "Self Hosted";
1859
- if (baseUrl.includes("n8n.cloud")) {
1860
- instanceType = "Cloud";
1861
- }
1862
- return rootStore.versionCli + ` (${instanceType})`;
1863
- });
1864
- const hasManyInputItems = computed(() => {
1865
- return ndvStore.ndvInputData.length > 1;
1866
- });
1867
- const nodeDefaultName = computed(() => {
1868
- if (!node.value) {
1869
- return "Node";
1870
- }
1871
- const nodeType = nodeTypesStore.getNodeType(node.value.type, node.value.typeVersion);
1872
- return nodeType?.defaults?.name || node.value.name;
1873
- });
1874
- const prepareRawMessages = computed(() => {
1875
- const returnData = [];
1876
- if (!props.error.messages?.length) {
1877
- return [];
1878
- }
1879
- const errorMessage = getErrorMessage();
1880
- Array.from(new Set(props.error.messages)).forEach((message) => {
1881
- const isParsable = /^\d{3} - \{/.test(message);
1882
- const parts = isParsable ? message.split(" - ").map((part) => part.trim()) : [];
1883
- for (const part of parts) {
1884
- try {
1885
- const parsed = JSON.parse(part);
1886
- if (typeof parsed === "object") {
1887
- returnData.push(parsed);
1888
- return;
1889
- }
1890
- } catch (error2) {
1891
- }
1892
- }
1893
- if (message === errorMessage) return;
1894
- returnData.push(message);
1895
- });
1896
- return returnData;
1897
- });
1898
- const isAskAssistantAvailable = computed(() => {
1899
- if (!node.value || isSubNodeError.value) {
1900
- return false;
1901
- }
1902
- const isCustomNode = node.value.type === void 0 || isCommunityPackageName(node.value.type);
1903
- return assistantStore.canShowAssistantButtonsOnCanvas && !isCustomNode && !nodeIsHidden();
1904
- });
1905
- const assistantAlreadyAsked = computed(() => {
1906
- return assistantStore.isNodeErrorActive({
1907
- error: assistantHelpers.simplifyErrorForAssistant(props.error),
1908
- node: props.error.node || ndvStore.activeNode
1909
- });
1910
- });
1911
- const isSubNodeError = computed(() => {
1912
- return props.error.name === "NodeOperationError" && props.error.functionality === "configuration-node";
1913
- });
1914
- function nodeVersionTag(nodeType) {
1915
- if (!nodeType || "hidden" in nodeType && nodeType.hidden) {
1916
- return i18n.baseText("nodeSettings.deprecated");
1917
- }
1918
- const latestNodeVersion = Math.max(...nodeTypesStore.getNodeVersions(nodeType.type));
1919
- if (latestNodeVersion === nodeType.typeVersion) {
1920
- return i18n.baseText("nodeSettings.latest");
1921
- }
1922
- return i18n.baseText("nodeSettings.latestVersion", {
1923
- interpolate: { version: latestNodeVersion.toString() }
1924
- });
1925
- }
1926
- function prepareDescription(description) {
1927
- return sanitizeHtml(description.replace(/`(.*?)`/g, "<code>$1</code>"));
1928
- }
1929
- function getErrorDescription() {
1930
- if (props.error.context?.descriptionKey) {
1931
- const interpolate = {
1932
- nodeCause: props.error.context.nodeCause,
1933
- runIndex: props.error.context.runIndex ?? "0",
1934
- itemIndex: props.error.context.itemIndex ?? "0"
1935
- };
1936
- return prepareDescription(
1937
- i18n.baseText(
1938
- `nodeErrorView.description.${props.error.context.descriptionKey}`,
1939
- { interpolate }
1940
- )
1941
- );
1942
- }
1943
- if (!props.error.context?.descriptionTemplate) {
1944
- return prepareDescription(props.error.description ?? "");
1945
- }
1946
- const parameterName = parameterDisplayName(props.error.context.parameter);
1947
- return prepareDescription(
1948
- props.error.context.descriptionTemplate.replace(/%%PARAMETER%%/g, parameterName)
1949
- );
1950
- }
1951
- function addItemIndexSuffix(message) {
1952
- let itemIndexSuffix = "";
1953
- if (hasManyInputItems.value && props.error?.context?.itemIndex !== void 0) {
1954
- itemIndexSuffix = `item ${props.error.context.itemIndex}`;
1955
- }
1956
- if (message.includes(itemIndexSuffix)) return message;
1957
- return `${message} [${itemIndexSuffix}]`;
1958
- }
1959
- function getErrorMessage() {
1960
- let message = "";
1961
- const isNonEmptyString = (value) => !!value && typeof value === "string";
1962
- if (isSubNodeError.value) {
1963
- message = i18n.baseText("nodeErrorView.errorSubNode", {
1964
- interpolate: { node: props.error.node.name }
1965
- });
1966
- } else if (isNonEmptyString(props.error.message) && (props.error.message === props.error.description || !props.error.context?.messageTemplate)) {
1967
- message = props.error.message;
1968
- } else if (isNonEmptyString(props.error.context?.messageTemplate) && isNonEmptyString(props.error.context?.parameter)) {
1969
- const parameterName = parameterDisplayName(props.error.context.parameter);
1970
- message = props.error.context.messageTemplate.replace(/%%PARAMETER%%/g, parameterName);
1971
- } else if (Array.isArray(props.error.messages) && props.error.messages.length > 0) {
1972
- message = props.error.messages[0];
1973
- }
1974
- return addItemIndexSuffix(message);
1975
- }
1976
- function parameterDisplayName(path, fullPath = true) {
1977
- try {
1978
- const params = getParameterName(parameters.value, path.split("."));
1979
- if (!params.length) {
1980
- throw new Error();
1981
- }
1982
- if (!fullPath) {
1983
- return params.pop().displayName;
1984
- }
1985
- return params.map((parameter) => parameter.displayName).join(" > ");
1986
- } catch (error2) {
1987
- return `Could not find parameter "${path}"`;
1988
- }
1989
- }
1990
- function getParameterName(params, pathParts) {
1991
- let currentParameterName = pathParts.shift();
1992
- if (currentParameterName === void 0) {
1993
- return [];
1994
- }
1995
- const arrayMatch = currentParameterName.match(/(.*)\[([\d])\]$/);
1996
- if (arrayMatch !== null && arrayMatch.length > 0) {
1997
- currentParameterName = arrayMatch[1];
1998
- }
1999
- const currentParameter = params.find(
2000
- (parameter) => parameter.name === currentParameterName
2001
- );
2002
- if (currentParameter === void 0) {
2003
- throw new Error(`Could not find parameter "${currentParameterName}"`);
2004
- }
2005
- if (pathParts.length === 0) {
2006
- return [currentParameter];
2007
- }
2008
- if (currentParameter.hasOwnProperty("options")) {
2009
- return [
2010
- currentParameter,
2011
- ...getParameterName(currentParameter.options, pathParts)
2012
- ];
2013
- }
2014
- if (currentParameter.hasOwnProperty("values")) {
2015
- return [
2016
- currentParameter,
2017
- ...getParameterName(currentParameter.values, pathParts)
2018
- ];
2019
- }
2020
- return [currentParameter];
2021
- }
2022
- function copyErrorDetails() {
2023
- const error2 = props.error;
2024
- const errorInfo = {
2025
- errorMessage: getErrorMessage()
2026
- };
2027
- if (error2.description) {
2028
- errorInfo.errorDescription = error2.description;
2029
- }
2030
- const errorDetails = {};
2031
- if (error2?.messages?.length) {
2032
- errorDetails.rawErrorMessage = error2.messages;
2033
- }
2034
- if ("httpCode" in error2 && error2.httpCode) {
2035
- errorDetails.httpCode = error2.httpCode;
2036
- }
2037
- if (error2.context && error2.context.data) {
2038
- errorDetails.errorData = error2.context.data;
2039
- }
2040
- if (error2.extra) {
2041
- errorDetails.errorExtra = error2.extra;
2042
- }
2043
- errorInfo.errorDetails = errorDetails;
2044
- const n8nDetails = {};
2045
- if (error2.node) {
2046
- n8nDetails.nodeName = error2.node.name;
2047
- n8nDetails.nodeType = error2.node.type;
2048
- n8nDetails.nodeVersion = error2.node.typeVersion;
2049
- if (error2.node?.parameters?.resource) {
2050
- n8nDetails.resource = error2.node.parameters.resource;
2051
- }
2052
- if (error2?.node?.parameters?.operation) {
2053
- n8nDetails.operation = error2.node.parameters.operation;
2054
- }
2055
- }
2056
- if (error2.context) {
2057
- if (error2.context.itemIndex !== void 0) {
2058
- n8nDetails.itemIndex = error2.context.itemIndex;
2059
- }
2060
- if (error2.context.runIndex !== void 0) {
2061
- n8nDetails.runIndex = error2.context.runIndex;
2062
- }
2063
- if (error2.context.parameter !== void 0) {
2064
- n8nDetails.parameter = error2.context.parameter;
2065
- }
2066
- if (error2.context.causeDetailed) {
2067
- n8nDetails.causeDetailed = error2.context.causeDetailed;
2068
- }
2069
- }
2070
- if (error2.timestamp) {
2071
- n8nDetails.time = new Date(error2.timestamp).toLocaleString();
2072
- }
2073
- n8nDetails.n8nVersion = n8nVersion.value;
2074
- n8nDetails.binaryDataMode = rootStore.binaryDataMode;
2075
- if (error2.cause) {
2076
- n8nDetails.cause = error2.cause;
2077
- }
2078
- n8nDetails.stackTrace = error2.stack?.split("\n");
2079
- errorInfo.n8nDetails = n8nDetails;
2080
- void clipboard.copy(JSON.stringify(errorInfo, null, 2));
2081
- copySuccess();
2082
- }
2083
- function copySuccess() {
2084
- toast.showMessage({
2085
- title: i18n.baseText("nodeErrorView.showMessage.title"),
2086
- type: "info"
2087
- });
2088
- }
2089
- function nodeIsHidden() {
2090
- const nodeType = nodeTypesStore.getNodeType(node?.value.type);
2091
- return nodeType?.hidden ?? false;
2092
- }
2093
- const onOpenErrorNodeDetailClick = () => {
2094
- ndvStore.activeNodeName = props.error.node.name;
2095
- };
2096
- async function onAskAssistantClick() {
2097
- const { message, lineNumber, description } = props.error;
2098
- const sessionInProgress = !assistantStore.isSessionEnded;
2099
- const errorHelp = {
2100
- error: {
2101
- name: props.error.name,
2102
- message,
2103
- lineNumber,
2104
- description: description ?? getErrorDescription(),
2105
- type: "type" in props.error ? props.error.type : void 0
2106
- },
2107
- node: node.value
2108
- };
2109
- if (sessionInProgress) {
2110
- uiStore.openModalWithData({
2111
- name: NEW_ASSISTANT_SESSION_MODAL,
2112
- data: { context: { errorHelp } }
2113
- });
2114
- return;
2115
- }
2116
- await assistantStore.initErrorHelper(errorHelp);
2117
- assistantStore.trackUserOpenedAssistant({
2118
- source: "error",
2119
- task: "error",
2120
- has_existing_session: false
2121
- });
2122
- }
2123
- return (_ctx, _cache) => {
2124
- const _component_n8n_button = resolveComponent("n8n-button");
2125
- const _component_n8n_icon_button = resolveComponent("n8n-icon-button");
2126
- const _component_n8n_tooltip = resolveComponent("n8n-tooltip");
2127
- const _component_font_awesome_icon = resolveComponent("font-awesome-icon");
2128
- const _directive_n8n_html = resolveDirective("n8n-html");
2129
- return openBlock(), createElementBlock("div", _hoisted_1$4, [
2130
- createBaseVNode("div", _hoisted_2$3, [
2131
- createBaseVNode("div", _hoisted_3$2, [
2132
- createBaseVNode("div", null, toDisplayString(getErrorMessage()), 1)
2133
- ]),
2134
- (_ctx.error.description || _ctx.error.context?.descriptionKey) && !isSubNodeError.value ? withDirectives((openBlock(), createElementBlock("div", _hoisted_4, null, 512)), [
2135
- [_directive_n8n_html, getErrorDescription()]
2136
- ]) : createCommentVNode("", true),
2137
- isSubNodeError.value ? (openBlock(), createElementBlock("div", _hoisted_5, [
2138
- createVNode(_component_n8n_button, {
2139
- icon: "arrow-right",
2140
- type: "secondary",
2141
- label: unref(i18n).baseText("pushConnection.executionError.openNode"),
2142
- class: "node-error-view__button",
2143
- "data-test-id": "node-error-view-open-node-button",
2144
- onClick: onOpenErrorNodeDetailClick
2145
- }, null, 8, ["label"])
2146
- ])) : createCommentVNode("", true),
2147
- isAskAssistantAvailable.value ? (openBlock(), createElementBlock("div", _hoisted_6, [
2148
- createVNode(InlineAskAssistantButton, {
2149
- asked: assistantAlreadyAsked.value,
2150
- onClick: onAskAssistantClick
2151
- }, null, 8, ["asked"])
2152
- ])) : createCommentVNode("", true)
2153
- ]),
2154
- !_ctx.compact ? (openBlock(), createElementBlock("div", _hoisted_7, [
2155
- createBaseVNode("div", _hoisted_8, [
2156
- createBaseVNode("p", _hoisted_9, toDisplayString(unref(i18n).baseText("nodeErrorView.details.title")), 1),
2157
- createVNode(_component_n8n_tooltip, {
2158
- class: "item",
2159
- content: unref(i18n).baseText("nodeErrorView.copyToClipboard.tooltip"),
2160
- placement: "left"
2161
- }, {
2162
- default: withCtx(() => [
2163
- createBaseVNode("div", _hoisted_10, [
2164
- createVNode(_component_n8n_icon_button, {
2165
- icon: "copy",
2166
- type: "secondary",
2167
- size: "mini",
2168
- text: "true",
2169
- "transparent-background": "transparent",
2170
- onClick: copyErrorDetails
2171
- })
2172
- ])
2173
- ]),
2174
- _: 1
2175
- }, 8, ["content"])
2176
- ]),
2177
- createBaseVNode("div", _hoisted_11, [
2178
- "httpCode" in _ctx.error && _ctx.error.httpCode || prepareRawMessages.value.length || _ctx.error?.context?.data || _ctx.error.extra ? (openBlock(), createElementBlock("details", _hoisted_12, [
2179
- createBaseVNode("summary", _hoisted_13, [
2180
- createVNode(_component_font_awesome_icon, {
2181
- class: "node-error-view__details-icon",
2182
- icon: "angle-right"
2183
- }),
2184
- createTextVNode(" " + toDisplayString(unref(i18n).baseText("nodeErrorView.details.from", {
2185
- interpolate: { node: `${nodeDefaultName.value}` }
2186
- })), 1)
2187
- ]),
2188
- createBaseVNode("div", _hoisted_14, [
2189
- "httpCode" in _ctx.error && _ctx.error.httpCode ? (openBlock(), createElementBlock("div", _hoisted_15, [
2190
- createBaseVNode("p", _hoisted_16, toDisplayString(unref(i18n).baseText("nodeErrorView.errorCode")), 1),
2191
- createBaseVNode("p", _hoisted_17, [
2192
- createBaseVNode("code", null, toDisplayString(_ctx.error.httpCode), 1)
2193
- ])
2194
- ])) : createCommentVNode("", true),
2195
- prepareRawMessages.value.length ? (openBlock(), createElementBlock("div", _hoisted_18, [
2196
- createBaseVNode("p", _hoisted_19, toDisplayString(unref(i18n).baseText("nodeErrorView.details.rawMessages")), 1),
2197
- createBaseVNode("div", _hoisted_20, [
2198
- (openBlock(true), createElementBlock(Fragment, null, renderList(prepareRawMessages.value, (msg, index) => {
2199
- return openBlock(), createElementBlock("div", { key: index }, [
2200
- createBaseVNode("pre", null, [
2201
- createBaseVNode("code", null, toDisplayString(msg), 1)
2202
- ])
2203
- ]);
2204
- }), 128))
2205
- ])
2206
- ])) : createCommentVNode("", true),
2207
- _ctx.error?.context?.data ? (openBlock(), createElementBlock("div", _hoisted_21, [
2208
- createBaseVNode("p", _hoisted_22, toDisplayString(unref(i18n).baseText("nodeErrorView.details.errorData")), 1),
2209
- createBaseVNode("div", _hoisted_23, [
2210
- createBaseVNode("pre", null, [
2211
- createBaseVNode("code", null, toDisplayString(_ctx.error.context.data), 1)
2212
- ])
2213
- ])
2214
- ])) : createCommentVNode("", true),
2215
- _ctx.error.extra ? (openBlock(), createElementBlock("div", _hoisted_24, [
2216
- createBaseVNode("p", _hoisted_25, toDisplayString(unref(i18n).baseText("nodeErrorView.details.errorExtra")), 1),
2217
- createBaseVNode("div", _hoisted_26, [
2218
- createBaseVNode("pre", null, [
2219
- createBaseVNode("code", null, toDisplayString(_ctx.error.extra), 1)
2220
- ])
2221
- ])
2222
- ])) : createCommentVNode("", true),
2223
- _ctx.error.context && _ctx.error.context.request ? (openBlock(), createElementBlock("div", _hoisted_27, [
2224
- createBaseVNode("p", _hoisted_28, toDisplayString(unref(i18n).baseText("nodeErrorView.details.request")), 1),
2225
- createBaseVNode("div", _hoisted_29, [
2226
- createBaseVNode("pre", null, [
2227
- createBaseVNode("code", null, toDisplayString(_ctx.error.context.request), 1)
2228
- ])
2229
- ])
2230
- ])) : createCommentVNode("", true)
2231
- ])
2232
- ])) : createCommentVNode("", true),
2233
- createBaseVNode("details", _hoisted_30, [
2234
- createBaseVNode("summary", _hoisted_31, [
2235
- createVNode(_component_font_awesome_icon, {
2236
- class: "node-error-view__details-icon",
2237
- icon: "angle-right"
2238
- }),
2239
- createTextVNode(" " + toDisplayString(unref(i18n).baseText("nodeErrorView.details.info")), 1)
2240
- ]),
2241
- createBaseVNode("div", _hoisted_32, [
2242
- _ctx.error.context && _ctx.error.context.itemIndex !== void 0 ? (openBlock(), createElementBlock("div", _hoisted_33, [
2243
- createBaseVNode("p", _hoisted_34, toDisplayString(unref(i18n).baseText("nodeErrorView.itemIndex")), 1),
2244
- createBaseVNode("p", _hoisted_35, [
2245
- createBaseVNode("code", null, toDisplayString(_ctx.error.context.itemIndex), 1)
2246
- ])
2247
- ])) : createCommentVNode("", true),
2248
- _ctx.error.context && _ctx.error.context.runIndex !== void 0 ? (openBlock(), createElementBlock("div", _hoisted_36, [
2249
- createBaseVNode("p", _hoisted_37, toDisplayString(unref(i18n).baseText("nodeErrorView.runIndex")), 1),
2250
- createBaseVNode("p", _hoisted_38, [
2251
- createBaseVNode("code", null, toDisplayString(_ctx.error.context.runIndex), 1)
2252
- ])
2253
- ])) : createCommentVNode("", true),
2254
- _ctx.error.context && _ctx.error.context.parameter !== void 0 ? (openBlock(), createElementBlock("div", _hoisted_39, [
2255
- createBaseVNode("p", _hoisted_40, toDisplayString(unref(i18n).baseText("nodeErrorView.inParameter")), 1),
2256
- createBaseVNode("p", _hoisted_41, [
2257
- createBaseVNode("code", null, toDisplayString(parameterDisplayName(`${_ctx.error.context.parameter}`)), 1)
2258
- ])
2259
- ])) : createCommentVNode("", true),
2260
- _ctx.error.node && _ctx.error.node.type ? (openBlock(), createElementBlock("div", _hoisted_42, [
2261
- createBaseVNode("p", _hoisted_43, toDisplayString(unref(i18n).baseText("nodeErrorView.details.nodeType")), 1),
2262
- createBaseVNode("p", _hoisted_44, [
2263
- createBaseVNode("code", null, toDisplayString(_ctx.error.node.type), 1)
2264
- ])
2265
- ])) : createCommentVNode("", true),
2266
- _ctx.error.node && _ctx.error.node.typeVersion ? (openBlock(), createElementBlock("div", _hoisted_45, [
2267
- createBaseVNode("p", _hoisted_46, toDisplayString(unref(i18n).baseText("nodeErrorView.details.nodeVersion")), 1),
2268
- createBaseVNode("p", _hoisted_47, [
2269
- createBaseVNode("code", null, [
2270
- createBaseVNode("span", null, toDisplayString(_ctx.error.node.typeVersion + " "), 1),
2271
- createBaseVNode("span", null, "(" + toDisplayString(nodeVersionTag(_ctx.error.node)) + ")", 1)
2272
- ])
2273
- ])
2274
- ])) : createCommentVNode("", true),
2275
- createBaseVNode("div", _hoisted_48, [
2276
- createBaseVNode("p", _hoisted_49, toDisplayString(unref(i18n).baseText("nodeErrorView.details.n8nVersion")), 1),
2277
- createBaseVNode("p", _hoisted_50, [
2278
- createBaseVNode("code", null, toDisplayString(n8nVersion.value), 1)
2279
- ])
2280
- ]),
2281
- _ctx.error.timestamp ? (openBlock(), createElementBlock("div", _hoisted_51, [
2282
- createBaseVNode("p", _hoisted_52, toDisplayString(unref(i18n).baseText("nodeErrorView.time")), 1),
2283
- createBaseVNode("p", _hoisted_53, [
2284
- createBaseVNode("code", null, toDisplayString(new Date(_ctx.error.timestamp).toLocaleString()), 1)
2285
- ])
2286
- ])) : createCommentVNode("", true),
2287
- _ctx.error.cause && displayCause.value ? (openBlock(), createElementBlock("div", _hoisted_54, [
2288
- createBaseVNode("p", _hoisted_55, toDisplayString(unref(i18n).baseText("nodeErrorView.details.errorCause")), 1),
2289
- createBaseVNode("pre", _hoisted_56, [
2290
- createBaseVNode("code", null, toDisplayString(_ctx.error.cause), 1)
2291
- ])
2292
- ])) : createCommentVNode("", true),
2293
- _ctx.error.context && _ctx.error.context.causeDetailed ? (openBlock(), createElementBlock("div", _hoisted_57, [
2294
- createBaseVNode("p", _hoisted_58, toDisplayString(unref(i18n).baseText("nodeErrorView.details.causeDetailed")), 1),
2295
- createBaseVNode("pre", _hoisted_59, [
2296
- createBaseVNode("code", null, toDisplayString(_ctx.error.context.causeDetailed), 1)
2297
- ])
2298
- ])) : createCommentVNode("", true),
2299
- _ctx.error.stack ? (openBlock(), createElementBlock("div", _hoisted_60, [
2300
- createBaseVNode("p", _hoisted_61, toDisplayString(unref(i18n).baseText("nodeErrorView.details.stackTrace")), 1),
2301
- createBaseVNode("pre", _hoisted_62, [
2302
- createBaseVNode("code", null, toDisplayString(_ctx.error.stack), 1)
2303
- ])
2304
- ])) : createCommentVNode("", true)
2305
- ])
2306
- ])
2307
- ])
2308
- ])) : createCommentVNode("", true)
2309
- ]);
2310
- };
2311
- }
2312
- });
2313
- const fallbackParser = (execData) => ({
2314
- type: "json",
2315
- data: execData,
2316
- parsed: false
2317
- });
2318
- const outputTypeParsers = {
2319
- [NodeConnectionTypes.AiLanguageModel](execData) {
2320
- const response = execData.response ?? execData;
2321
- if (!response) throw new Error("No response from Language Model");
2322
- if (Array.isArray(response?.messages) && response?.messages.length === 1 && typeof response?.messages[0] === "string") {
2323
- return {
2324
- type: "text",
2325
- data: response.messages[0],
2326
- parsed: true
2327
- };
2328
- }
2329
- if (response.messages && Array.isArray(response.messages)) {
2330
- return outputTypeParsers[NodeConnectionTypes.AiMemory](execData);
2331
- }
2332
- if (response.generations) {
2333
- const generations = response.generations;
2334
- const content = generations.map((generation) => {
2335
- if (generation?.text) return generation.text;
2336
- if (Array.isArray(generation)) {
2337
- return generation.map((item) => item.text ?? item).join("\n\n").trim();
2338
- }
2339
- return generation;
2340
- });
2341
- return {
2342
- type: "json",
2343
- data: content,
2344
- parsed: true
2345
- };
2346
- }
2347
- return {
2348
- type: "json",
2349
- data: response,
2350
- parsed: true
2351
- };
2352
- },
2353
- [NodeConnectionTypes.AiTool]: fallbackParser,
2354
- [NodeConnectionTypes.AiAgent]: fallbackParser,
2355
- [NodeConnectionTypes.AiMemory](execData) {
2356
- const chatHistory = execData.chatHistory ?? execData.messages ?? execData?.response?.chat_history;
2357
- if (Array.isArray(chatHistory)) {
2358
- const responseText = chatHistory.map((content) => {
2359
- if (content.type === "constructor" && content.id?.includes("messages") && content.kwargs) {
2360
- let message = content.kwargs.content;
2361
- if (Array.isArray(message)) {
2362
- message = message.map((item) => {
2363
- const { type, image_url } = item;
2364
- if (type === "image_url" && typeof image_url === "object" && typeof image_url.url === "string") {
2365
- return `![Input image](${image_url.url})`;
2366
- } else if (typeof image_url === "string") {
2367
- return `![Input image](${image_url})`;
2368
- }
2369
- return item.text;
2370
- }).join("\n");
2371
- }
2372
- if (Object.keys(content.kwargs.additional_kwargs).length) {
2373
- message += ` (${JSON.stringify(content.kwargs.additional_kwargs)})`;
2374
- }
2375
- if (content.id.includes("HumanMessage")) {
2376
- message = `**Human:** ${String(message).trim()}`;
2377
- } else if (content.id.includes("AIMessage")) {
2378
- message = `**AI:** ${message}`;
2379
- } else if (content.id.includes("SystemMessage")) {
2380
- message = `**System Message:** ${message}`;
2381
- }
2382
- return message;
2383
- }
2384
- return "";
2385
- }).join("\n\n");
2386
- if (responseText.length === 0) {
2387
- return fallbackParser(execData);
2388
- }
2389
- return {
2390
- type: "markdown",
2391
- data: responseText,
2392
- parsed: true
2393
- };
2394
- }
2395
- return fallbackParser(execData);
2396
- },
2397
- [NodeConnectionTypes.AiOutputParser]: fallbackParser,
2398
- [NodeConnectionTypes.AiRetriever]: fallbackParser,
2399
- [NodeConnectionTypes.AiVectorStore](execData) {
2400
- if (execData.documents) {
2401
- return {
2402
- type: "json",
2403
- data: execData.documents,
2404
- parsed: true
2405
- };
2406
- }
2407
- return fallbackParser(execData);
2408
- },
2409
- [NodeConnectionTypes.AiEmbedding](execData) {
2410
- if (execData.documents) {
2411
- return {
2412
- type: "json",
2413
- data: execData.documents,
2414
- parsed: true
2415
- };
2416
- }
2417
- return fallbackParser(execData);
2418
- },
2419
- [NodeConnectionTypes.AiDocument](execData) {
2420
- if (execData.documents) {
2421
- return {
2422
- type: "json",
2423
- data: execData.documents,
2424
- parsed: true
2425
- };
2426
- }
2427
- return fallbackParser(execData);
2428
- },
2429
- [NodeConnectionTypes.AiTextSplitter](execData) {
2430
- const arrayData = Array.isArray(execData.response) ? execData.response : [execData.textSplitter];
2431
- return {
2432
- type: "text",
2433
- data: arrayData.join("\n\n"),
2434
- parsed: true
2435
- };
2436
- }
2437
- };
2438
- const useAiContentParsers = () => {
2439
- const parseAiRunData = (executionData, endpointType) => {
2440
- if ([NodeConnectionTypes.AiChain, NodeConnectionTypes.Main].includes(
2441
- endpointType
2442
- )) {
2443
- return executionData.map((data) => ({ raw: data.json, parsedContent: null }));
2444
- }
2445
- const contentJson = executionData.map((node) => {
2446
- const hasBinaryData = !isObjectEmpty(node.binary);
2447
- return hasBinaryData ? node.binary : node.json;
2448
- });
2449
- const parser = outputTypeParsers[endpointType];
2450
- if (!parser)
2451
- return [
2452
- {
2453
- raw: contentJson.filter((item) => item !== void 0),
2454
- parsedContent: null
2455
- }
2456
- ];
2457
- const parsedOutput = contentJson.filter((c) => c !== void 0).map((c) => ({ raw: c, parsedContent: parser(c) }));
2458
- return parsedOutput;
2459
- };
2460
- return {
2461
- parseAiRunData
2462
- };
2463
- };
2464
- const _hoisted_1$3 = ["data-content-type"];
2465
- const _hoisted_2$2 = ["textContent"];
2466
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
2467
- __name: "AiRunContentBlock",
2468
- props: {
2469
- runData: {},
2470
- error: {}
2471
- },
2472
- setup(__props) {
2473
- const props = __props;
2474
- const i18n = useI18n();
2475
- const clipboard = useClipboard();
2476
- const { showMessage } = useToast();
2477
- const contentParsers = useAiContentParsers();
2478
- const isExpanded = ref(getInitialExpandedState());
2479
- const renderType = ref("rendered");
2480
- const contentParsed = ref(false);
2481
- const parsedRun = ref(void 0);
2482
- function getInitialExpandedState() {
2483
- const collapsedTypes = {
2484
- input: [
2485
- NodeConnectionTypes.AiDocument,
2486
- NodeConnectionTypes.AiTextSplitter
2487
- ],
2488
- output: [
2489
- NodeConnectionTypes.AiDocument,
2490
- NodeConnectionTypes.AiEmbedding,
2491
- NodeConnectionTypes.AiTextSplitter,
2492
- NodeConnectionTypes.AiVectorStore
2493
- ]
2494
- };
2495
- return !collapsedTypes[props.runData.inOut].includes(props.runData.type);
2496
- }
2497
- function isJsonString(text) {
2498
- try {
2499
- JSON.parse(text);
2500
- return true;
2501
- } catch (e) {
2502
- return false;
2503
- }
2504
- }
2505
- const markdownOptions = {
2506
- highlight(str, lang) {
2507
- if (lang && HighlightJS.getLanguage(lang)) {
2508
- try {
2509
- return HighlightJS.highlight(str, { language: lang }).value;
2510
- } catch {
2511
- }
2512
- }
2513
- return "";
2514
- }
2515
- };
2516
- function parseAiRunData(run) {
2517
- if (!run.data) {
2518
- return;
2519
- }
2520
- const parsedData = contentParsers.parseAiRunData(run.data, run.type);
2521
- return parsedData;
2522
- }
2523
- function isMarkdown(content) {
2524
- if (typeof content !== "string") return false;
2525
- const markdownPatterns = [
2526
- /^# .+/gm,
2527
- // headers
2528
- /\*{1,2}.+\*{1,2}/g,
2529
- // emphasis and strong
2530
- /\[.+\]\(.+\)/g,
2531
- // links
2532
- /```[\s\S]+```/g
2533
- // code blocks
2534
- ];
2535
- return markdownPatterns.some((pattern) => pattern.test(content));
2536
- }
2537
- function formatToJsonMarkdown(data) {
2538
- return "```json\n" + data + "\n```";
2539
- }
2540
- function jsonToMarkdown(data) {
2541
- if (isMarkdown(data)) return data;
2542
- if (Array.isArray(data) && data.length && typeof data[0] !== "number") {
2543
- const markdownArray = data.map((item) => jsonToMarkdown(item));
2544
- return markdownArray.join("\n\n").trim();
2545
- }
2546
- if (typeof data === "string") {
2547
- if (isJsonString(data)) {
2548
- return formatToJsonMarkdown(data);
2549
- }
2550
- return data;
2551
- }
2552
- return formatToJsonMarkdown(JSON.stringify(data, null, 2));
2553
- }
2554
- function setContentParsed(content) {
2555
- contentParsed.value = !!content.find((item) => {
2556
- if (item.parsedContent?.parsed === true) {
2557
- return true;
2558
- }
2559
- return false;
2560
- });
2561
- }
2562
- function onBlockHeaderClick() {
2563
- isExpanded.value = !isExpanded.value;
2564
- }
2565
- function onCopyToClipboard(content) {
2566
- try {
2567
- void clipboard.copy(JSON.stringify(content, void 0, 2));
2568
- showMessage({
2569
- title: i18n.baseText("generic.copiedToClipboard"),
2570
- type: "success"
2571
- });
2572
- } catch (err) {
2573
- }
2574
- }
2575
- function onRenderTypeChange(value) {
2576
- renderType.value = value;
2577
- }
2578
- onMounted(() => {
2579
- parsedRun.value = parseAiRunData(props.runData);
2580
- if (parsedRun.value) {
2581
- setContentParsed(parsedRun.value);
2582
- }
2583
- });
2584
- return (_ctx, _cache) => {
2585
- const _component_font_awesome_icon = resolveComponent("font-awesome-icon");
2586
- const _component_n8n_radio_buttons = resolveComponent("n8n-radio-buttons");
2587
- const _component_NodeErrorView = _sfc_main$5;
2588
- const _component_n8n_icon_button = resolveComponent("n8n-icon-button");
2589
- return openBlock(), createElementBlock("div", {
2590
- class: normalizeClass(_ctx.$style.block)
2591
- }, [
2592
- createBaseVNode("header", {
2593
- class: normalizeClass(_ctx.$style.blockHeader),
2594
- onClick: onBlockHeaderClick
2595
- }, [
2596
- createBaseVNode("button", {
2597
- class: normalizeClass(_ctx.$style.blockToggle)
2598
- }, [
2599
- createVNode(_component_font_awesome_icon, {
2600
- icon: isExpanded.value ? "angle-down" : "angle-right",
2601
- size: "lg"
2602
- }, null, 8, ["icon"])
2603
- ], 2),
2604
- createBaseVNode("p", {
2605
- class: normalizeClass(_ctx.$style.blockTitle)
2606
- }, toDisplayString(unref(capitalize)(_ctx.runData.inOut)), 3),
2607
- contentParsed.value && !_ctx.error && isExpanded.value ? (openBlock(), createBlock(_component_n8n_radio_buttons, {
2608
- key: 0,
2609
- size: "small",
2610
- "model-value": renderType.value,
2611
- class: normalizeClass(_ctx.$style.rawSwitch),
2612
- options: [
2613
- { label: "Rendered", value: "rendered" },
2614
- { label: "JSON", value: "json" }
2615
- ],
2616
- "onUpdate:modelValue": onRenderTypeChange
2617
- }, null, 8, ["model-value", "class"])) : createCommentVNode("", true)
2618
- ], 2),
2619
- createBaseVNode("main", {
2620
- class: normalizeClass({
2621
- [_ctx.$style.blockContent]: true,
2622
- [_ctx.$style.blockContentExpanded]: isExpanded.value
2623
- })
2624
- }, [
2625
- _ctx.error ? (openBlock(), createBlock(_component_NodeErrorView, {
2626
- key: 0,
2627
- error: _ctx.error,
2628
- class: normalizeClass(_ctx.$style.error)
2629
- }, null, 8, ["error", "class"])) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(parsedRun.value, ({ parsedContent, raw }, index) => {
2630
- return openBlock(), createElementBlock("div", {
2631
- key: index,
2632
- class: normalizeClass(_ctx.$style.contentText),
2633
- "data-content-type": parsedContent?.type
2634
- }, [
2635
- parsedContent && renderType.value === "rendered" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2636
- parsedContent.type === "json" ? (openBlock(), createBlock(unref(VueMarkdown), {
2637
- key: 0,
2638
- source: jsonToMarkdown(parsedContent.data),
2639
- class: normalizeClass(_ctx.$style.markdown),
2640
- options: markdownOptions
2641
- }, null, 8, ["source", "class"])) : createCommentVNode("", true),
2642
- parsedContent.type === "markdown" ? (openBlock(), createBlock(unref(VueMarkdown), {
2643
- key: 1,
2644
- source: parsedContent.data,
2645
- class: normalizeClass(_ctx.$style.markdown),
2646
- options: markdownOptions
2647
- }, null, 8, ["source", "class"])) : createCommentVNode("", true),
2648
- parsedContent.type === "text" ? (openBlock(), createElementBlock("p", {
2649
- key: 2,
2650
- class: normalizeClass(_ctx.$style.runText),
2651
- textContent: toDisplayString(parsedContent.data)
2652
- }, null, 10, _hoisted_2$2)) : createCommentVNode("", true)
2653
- ], 64)) : (openBlock(), createElementBlock("div", {
2654
- key: 1,
2655
- class: normalizeClass(_ctx.$style.rawContent)
2656
- }, [
2657
- createVNode(_component_n8n_icon_button, {
2658
- size: "small",
2659
- class: normalizeClass(_ctx.$style.copyToClipboard),
2660
- type: "secondary",
2661
- title: unref(i18n).baseText("nodeErrorView.copyToClipboard"),
2662
- icon: "copy",
2663
- onClick: ($event) => onCopyToClipboard(raw)
2664
- }, null, 8, ["class", "title", "onClick"]),
2665
- createVNode(unref(VueMarkdown), {
2666
- source: jsonToMarkdown(raw),
2667
- class: normalizeClass(_ctx.$style.markdown)
2668
- }, null, 8, ["source", "class"])
2669
- ], 2))
2670
- ], 10, _hoisted_1$3);
2671
- }), 128))
2672
- ], 2)
2673
- ], 2);
2674
- };
2675
- }
2676
- });
2677
- const copyToClipboard = "_copyToClipboard_kaw5r_123";
2678
- const rawContent = "_rawContent_kaw5r_129";
2679
- const markdown = "_markdown_kaw5r_133";
2680
- const contentText = "_contentText_kaw5r_157";
2681
- const block = "_block_kaw5r_164";
2682
- const blockContent = "_blockContent_kaw5r_171";
2683
- const blockContentExpanded = "_blockContentExpanded_kaw5r_175";
2684
- const runText = "_runText_kaw5r_179";
2685
- const rawSwitch = "_rawSwitch_kaw5r_184";
2686
- const blockHeader = "_blockHeader_kaw5r_194";
2687
- const blockTitle = "_blockTitle_kaw5r_207";
2688
- const blockToggle = "_blockToggle_kaw5r_214";
2689
- const error = "_error_kaw5r_222";
2690
- const style0$3 = {
2691
- copyToClipboard,
2692
- rawContent,
2693
- markdown,
2694
- contentText,
2695
- block,
2696
- blockContent,
2697
- blockContentExpanded,
2698
- runText,
2699
- rawSwitch,
2700
- blockHeader,
2701
- blockTitle,
2702
- blockToggle,
2703
- error
2704
- };
2705
- const cssModules$3 = {
2706
- "$style": style0$3
2707
- };
2708
- const AiRunContentBlock = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__cssModules", cssModules$3]]);
2709
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2710
- __name: "ConsumedTokensDetails",
2711
- props: {
2712
- consumedTokens: {}
2713
- },
2714
- setup(__props) {
2715
- const i18n = useI18n();
2716
- return (_ctx, _cache) => {
2717
- return openBlock(), createElementBlock("div", null, [
2718
- createVNode(unref(N8nText), {
2719
- bold: true,
2720
- size: "small"
2721
- }, {
2722
- default: withCtx(() => [
2723
- createTextVNode(toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens.prompt")) + " " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens", {
2724
- interpolate: {
2725
- count: unref(formatTokenUsageCount)(_ctx.consumedTokens, "prompt")
2726
- }
2727
- })), 1)
2728
- ]),
2729
- _: 1
2730
- }),
2731
- _cache[0] || (_cache[0] = createBaseVNode("br", null, null, -1)),
2732
- createVNode(unref(N8nText), {
2733
- bold: true,
2734
- size: "small"
2735
- }, {
2736
- default: withCtx(() => [
2737
- createTextVNode(toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens.completion")) + " " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens", {
2738
- interpolate: {
2739
- count: unref(formatTokenUsageCount)(_ctx.consumedTokens, "completion")
2740
- }
2741
- })), 1)
2742
- ]),
2743
- _: 1
2744
- })
2745
- ]);
2746
- };
2747
- }
2748
- });
2749
- const _hoisted_1$2 = ["href"];
2750
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2751
- __name: "ViewSubExecution",
2752
- props: {
2753
- taskMetadata: {},
2754
- displayMode: {},
2755
- inline: { type: Boolean, default: false }
2756
- },
2757
- setup(__props) {
2758
- const { trackOpeningRelatedExecution, resolveRelatedExecutionUrl } = useExecutionHelpers();
2759
- const i18n = useI18n();
2760
- const props = __props;
2761
- const hasRelatedExecution = computed(() => {
2762
- return Boolean(props.taskMetadata.subExecution ?? props.taskMetadata.parentExecution);
2763
- });
2764
- function getExecutionLinkLabel(task) {
2765
- if (task.parentExecution) {
2766
- return i18n.baseText("runData.openParentExecution", {
2767
- interpolate: { id: task.parentExecution.executionId }
2768
- });
2769
- }
2770
- if (task.subExecution) {
2771
- if (props.taskMetadata.subExecutionsCount === 1) {
2772
- return i18n.baseText("runData.openSubExecutionSingle");
2773
- } else {
2774
- return i18n.baseText("runData.openSubExecutionWithId", {
2775
- interpolate: { id: task.subExecution.executionId }
2776
- });
2777
- }
2778
- }
2779
- return;
2780
- }
2781
- return (_ctx, _cache) => {
2782
- const _component_N8nIcon = resolveComponent("N8nIcon");
2783
- return hasRelatedExecution.value ? (openBlock(), createElementBlock("a", {
2784
- key: 0,
2785
- class: normalizeClass({ [_ctx.$style.relatedExecutionInfo]: !_ctx.inline }),
2786
- "data-test-id": "related-execution-link",
2787
- href: unref(resolveRelatedExecutionUrl)(_ctx.taskMetadata),
2788
- target: "_blank",
2789
- onClick: _cache[0] || (_cache[0] = withModifiers(($event) => unref(trackOpeningRelatedExecution)(_ctx.taskMetadata, _ctx.displayMode), ["stop"]))
2790
- }, [
2791
- createVNode(_component_N8nIcon, {
2792
- icon: "external-link-alt",
2793
- size: "xsmall"
2794
- }),
2795
- createTextVNode(" " + toDisplayString(getExecutionLinkLabel(_ctx.taskMetadata)), 1)
2796
- ], 10, _hoisted_1$2)) : createCommentVNode("", true);
2797
- };
2798
- }
2799
- });
2800
- const relatedExecutionInfo = "_relatedExecutionInfo_saqms_123";
2801
- const style0$2 = {
2802
- relatedExecutionInfo
2803
- };
2804
- const cssModules$2 = {
2805
- "$style": style0$2
2806
- };
2807
- const ViewSubExecution = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__cssModules", cssModules$2]]);
2808
- const _hoisted_1$1 = { key: 0 };
2809
- const _hoisted_2$1 = { key: 1 };
2810
- const _hoisted_3$1 = { key: 2 };
2811
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2812
- __name: "RunDataAiContent",
2813
- props: {
2814
- inputData: {},
2815
- contentIndex: {}
2816
- },
2817
- setup(__props) {
2818
- const props = __props;
2819
- const nodeTypesStore = useNodeTypesStore();
2820
- const workflowsStore = useWorkflowsStore();
2821
- const i18n = useI18n();
2822
- const consumedTokensSum = computed(() => {
2823
- return getConsumedTokens(outputRun.value);
2824
- });
2825
- function extractRunMeta(run) {
2826
- const uiNode = workflowsStore.getNodeByName(props.inputData.node);
2827
- const nodeType = nodeTypesStore.getNodeType(uiNode?.type ?? "");
2828
- const runMeta2 = {
2829
- startTimeMs: run.metadata.startTime,
2830
- executionTimeMs: run.metadata.executionTime,
2831
- node: nodeType,
2832
- type: run.inOut,
2833
- connectionType: run.type,
2834
- subExecution: run.metadata?.subExecution
2835
- };
2836
- return runMeta2;
2837
- }
2838
- const outputRun = computed(() => {
2839
- return props.inputData.data.find((r) => r.inOut === "output");
2840
- });
2841
- const runMeta = computed(() => {
2842
- if (outputRun.value === void 0) {
2843
- return;
2844
- }
2845
- return extractRunMeta(outputRun.value);
2846
- });
2847
- const executionRunData = computed(() => {
2848
- return workflowsStore.getWorkflowExecution?.data?.resultData?.runData;
2849
- });
2850
- const outputError = computed(() => {
2851
- return executionRunData.value?.[props.inputData.node]?.[props.inputData.runIndex]?.error;
2852
- });
2853
- return (_ctx, _cache) => {
2854
- const _component_n8n_tooltip = resolveComponent("n8n-tooltip");
2855
- const _component_n8n_info_tip = resolveComponent("n8n-info-tip");
2856
- return openBlock(), createElementBlock("div", {
2857
- class: normalizeClass(_ctx.$style.container)
2858
- }, [
2859
- createBaseVNode("header", {
2860
- class: normalizeClass(_ctx.$style.header)
2861
- }, [
2862
- runMeta.value?.node ? (openBlock(), createBlock(_sfc_main$6, {
2863
- key: 0,
2864
- class: normalizeClass(_ctx.$style.nodeIcon),
2865
- "node-type": runMeta.value.node,
2866
- size: 20
2867
- }, null, 8, ["class", "node-type"])) : createCommentVNode("", true),
2868
- createBaseVNode("div", {
2869
- class: normalizeClass(_ctx.$style.headerWrap)
2870
- }, [
2871
- createBaseVNode("p", {
2872
- class: normalizeClass(_ctx.$style.title)
2873
- }, toDisplayString(_ctx.inputData.node), 3),
2874
- createBaseVNode("ul", {
2875
- class: normalizeClass(_ctx.$style.meta)
2876
- }, [
2877
- runMeta.value?.startTimeMs ? (openBlock(), createElementBlock("li", _hoisted_1$1, toDisplayString(runMeta.value?.executionTimeMs) + "ms", 1)) : createCommentVNode("", true),
2878
- runMeta.value?.startTimeMs ? (openBlock(), createElementBlock("li", _hoisted_2$1, [
2879
- createVNode(_component_n8n_tooltip, null, {
2880
- content: withCtx(() => [
2881
- createTextVNode(toDisplayString(new Date(runMeta.value?.startTimeMs).toLocaleString()), 1)
2882
- ]),
2883
- default: withCtx(() => [
2884
- createTextVNode(" " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.startedAt", {
2885
- interpolate: {
2886
- startTime: new Date(runMeta.value?.startTimeMs).toLocaleTimeString()
2887
- }
2888
- })), 1)
2889
- ]),
2890
- _: 1
2891
- })
2892
- ])) : createCommentVNode("", true),
2893
- runMeta.value ? (openBlock(), createElementBlock("li", _hoisted_3$1, [
2894
- createVNode(ViewSubExecution, {
2895
- "task-metadata": runMeta.value,
2896
- "display-mode": "ai",
2897
- inline: true
2898
- }, null, 8, ["task-metadata"])
2899
- ])) : createCommentVNode("", true),
2900
- (consumedTokensSum.value?.totalTokens ?? 0) > 0 ? (openBlock(), createElementBlock("li", {
2901
- key: 3,
2902
- class: normalizeClass(_ctx.$style.tokensUsage)
2903
- }, [
2904
- createTextVNode(toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens", {
2905
- interpolate: {
2906
- count: unref(formatTokenUsageCount)(consumedTokensSum.value, "total")
2907
- }
2908
- })) + " ", 1),
2909
- createVNode(_component_n8n_info_tip, {
2910
- type: "tooltip",
2911
- theme: "info-light",
2912
- "tooltip-placement": "right"
2913
- }, {
2914
- default: withCtx(() => [
2915
- createVNode(_sfc_main$3, { "consumed-tokens": consumedTokensSum.value }, null, 8, ["consumed-tokens"])
2916
- ]),
2917
- _: 1
2918
- })
2919
- ], 2)) : createCommentVNode("", true)
2920
- ], 2)
2921
- ], 2)
2922
- ], 2),
2923
- (openBlock(true), createElementBlock(Fragment, null, renderList(props.inputData.data, (run, index) => {
2924
- return openBlock(), createElementBlock("main", {
2925
- key: index,
2926
- class: normalizeClass(_ctx.$style.content)
2927
- }, [
2928
- createVNode(AiRunContentBlock, {
2929
- "run-data": run,
2930
- error: run.inOut === "output" ? outputError.value : void 0
2931
- }, null, 8, ["run-data", "error"])
2932
- ], 2);
2933
- }), 128))
2934
- ], 2);
2935
- };
2936
- }
2937
- });
2938
- const container$1 = "_container_dypaw_2";
2939
- const nodeIcon$1 = "_nodeIcon_dypaw_5";
2940
- const header = "_header_dypaw_8";
2941
- const headerWrap = "_headerWrap_dypaw_14";
2942
- const title$1 = "_title_dypaw_18";
2943
- const meta = "_meta_dypaw_25";
2944
- const tokensUsage = "_tokensUsage_dypaw_41";
2945
- const style0$1 = {
2946
- container: container$1,
2947
- nodeIcon: nodeIcon$1,
2948
- header,
2949
- headerWrap,
2950
- title: title$1,
2951
- meta,
2952
- tokensUsage
2953
- };
2954
- const cssModules$1 = {
2955
- "$style": style0$1
2956
- };
2957
- const RunDataAiContent = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__cssModules", cssModules$1]]);
2958
- const _hoisted_1 = ["data-tree-depth"];
2959
- const _hoisted_2 = ["onClick"];
2960
- const _hoisted_3 = ["textContent"];
2961
- const _sfc_main = /* @__PURE__ */ defineComponent({
2962
- __name: "RunDataAi",
2963
- props: {
2964
- node: {},
2965
- runIndex: { default: 0 },
2966
- slim: { type: Boolean },
2967
- workflow: {}
2968
- },
2969
- setup(__props) {
2970
- const props = __props;
2971
- const workflowsStore = useWorkflowsStore();
2972
- const nodeTypesStore = useNodeTypesStore();
2973
- const selectedRun = ref([]);
2974
- const i18n = useI18n();
2975
- function isTreeNodeSelected(node) {
2976
- return selectedRun.value.some((run) => run.node === node.node && run.runIndex === node.runIndex);
2977
- }
2978
- function toggleTreeItem(node) {
2979
- node.expanded = !node.expanded;
2980
- }
2981
- function onItemClick(data) {
2982
- const matchingRun = aiData.value?.find(
2983
- (run) => run.node === data.node && run.runIndex === data.runIndex
2984
- );
2985
- if (!matchingRun) {
2986
- selectedRun.value = [];
2987
- return;
2988
- }
2989
- const selectedNodeRun = workflowsStore.getWorkflowResultDataByNodeName(data.node)?.[data.runIndex];
2990
- if (!selectedNodeRun) {
2991
- return;
2992
- }
2993
- selectedRun.value = [
2994
- {
2995
- node: data.node,
2996
- runIndex: data.runIndex,
2997
- data: getReferencedData(selectedNodeRun, true)
2998
- }
2999
- ];
3000
- }
3001
- function getNodeType(nodeName) {
3002
- const node = workflowsStore.getNodeByName(nodeName);
3003
- if (!node) {
3004
- return null;
3005
- }
3006
- const nodeType = nodeTypesStore.getNodeType(node?.type);
3007
- return nodeType;
3008
- }
3009
- function selectFirst() {
3010
- if (executionTree.value.length && executionTree.value[0].children.length) {
3011
- onItemClick(executionTree.value[0].children[0]);
3012
- }
3013
- }
3014
- const aiData = computed(
3015
- () => createAiData(props.node.name, props.workflow, workflowsStore.getWorkflowResultDataByNodeName)
3016
- );
3017
- const executionTree = computed(
3018
- () => getTreeNodeData(props.node.name, props.workflow, aiData.value)
3019
- );
3020
- watch(() => props.runIndex, selectFirst, { immediate: true });
3021
- return (_ctx, _cache) => {
3022
- const _component_font_awesome_icon = resolveComponent("font-awesome-icon");
3023
- const _component_n8n_tooltip = resolveComponent("n8n-tooltip");
3024
- const _component_n8n_text = resolveComponent("n8n-text");
3025
- return openBlock(), createElementBlock("div", {
3026
- class: normalizeClass(_ctx.$style.container)
3027
- }, [
3028
- aiData.value.length > 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
3029
- createBaseVNode("div", {
3030
- class: normalizeClass({ [_ctx.$style.tree]: true, [_ctx.$style.slim]: _ctx.slim })
3031
- }, [
3032
- createVNode(unref(ElTree), {
3033
- data: executionTree.value,
3034
- props: { label: "node" },
3035
- "default-expand-all": "",
3036
- indent: 12,
3037
- "expand-on-click-node": false,
3038
- "data-test-id": "lm-chat-logs-tree",
3039
- onNodeClick: onItemClick
3040
- }, {
3041
- default: withCtx(({ node, data }) => [
3042
- createBaseVNode("div", {
3043
- class: normalizeClass({
3044
- [_ctx.$style.treeNode]: true,
3045
- [_ctx.$style.isSelected]: isTreeNodeSelected(data)
3046
- }),
3047
- "data-tree-depth": data.depth,
3048
- style: normalizeStyle({ "--item-depth": data.depth })
3049
- }, [
3050
- data.children.length ? (openBlock(), createElementBlock("button", {
3051
- key: 0,
3052
- class: normalizeClass(_ctx.$style.treeToggle),
3053
- onClick: ($event) => toggleTreeItem(node)
3054
- }, [
3055
- createVNode(_component_font_awesome_icon, {
3056
- icon: node.expanded ? "angle-down" : "angle-right"
3057
- }, null, 8, ["icon"])
3058
- ], 10, _hoisted_2)) : createCommentVNode("", true),
3059
- createVNode(_component_n8n_tooltip, {
3060
- disabled: !_ctx.slim,
3061
- placement: "right"
3062
- }, {
3063
- content: withCtx(() => [
3064
- createTextVNode(toDisplayString(node.label), 1)
3065
- ]),
3066
- default: withCtx(() => [
3067
- createBaseVNode("span", {
3068
- class: normalizeClass(_ctx.$style.leafLabel)
3069
- }, [
3070
- createVNode(_sfc_main$6, {
3071
- "node-type": getNodeType(data.node),
3072
- size: 17,
3073
- class: normalizeClass(_ctx.$style.nodeIcon)
3074
- }, null, 8, ["node-type", "class"]),
3075
- !_ctx.slim ? (openBlock(), createElementBlock("span", {
3076
- key: 0,
3077
- textContent: toDisplayString(node.label)
3078
- }, null, 8, _hoisted_3)) : createCommentVNode("", true)
3079
- ], 2)
3080
- ]),
3081
- _: 2
3082
- }, 1032, ["disabled"])
3083
- ], 14, _hoisted_1)
3084
- ]),
3085
- _: 1
3086
- }, 8, ["data"])
3087
- ], 2),
3088
- createBaseVNode("div", {
3089
- class: normalizeClass(_ctx.$style.runData)
3090
- }, [
3091
- selectedRun.value.length === 0 ? (openBlock(), createElementBlock("div", {
3092
- key: 0,
3093
- class: normalizeClass(_ctx.$style.empty)
3094
- }, [
3095
- createVNode(_component_n8n_text, { size: "large" }, {
3096
- default: withCtx(() => [
3097
- createTextVNode(toDisplayString(unref(i18n).baseText("ndv.output.ai.empty", {
3098
- interpolate: {
3099
- node: props.node.name
3100
- }
3101
- })), 1)
3102
- ]),
3103
- _: 1
3104
- })
3105
- ], 2)) : createCommentVNode("", true),
3106
- (openBlock(true), createElementBlock(Fragment, null, renderList(selectedRun.value, (data, index) => {
3107
- return openBlock(), createElementBlock("div", {
3108
- key: `${data.node}__${data.runIndex}__index`,
3109
- "data-test-id": "lm-chat-logs-entry"
3110
- }, [
3111
- createVNode(RunDataAiContent, {
3112
- "input-data": data,
3113
- "content-index": index
3114
- }, null, 8, ["input-data", "content-index"])
3115
- ]);
3116
- }), 128))
3117
- ], 2)
3118
- ], 64)) : (openBlock(), createElementBlock("div", {
3119
- key: 1,
3120
- class: normalizeClass(_ctx.$style.noData)
3121
- }, toDisplayString(unref(i18n).baseText("ndv.output.ai.waiting")), 3))
3122
- ], 2);
3123
- };
3124
- }
3125
- });
3126
- const treeToggle = "_treeToggle_1qaq4_123";
3127
- const leafLabel = "_leafLabel_1qaq4_131";
3128
- const noData = "_noData_1qaq4_137";
3129
- const empty = "_empty_1qaq4_145";
3130
- const title = "_title_1qaq4_149";
3131
- const tree = "_tree_1qaq4_123";
3132
- const slim = "_slim_1qaq4_161";
3133
- const runData = "_runData_1qaq4_165";
3134
- const container = "_container_1qaq4_171";
3135
- const nodeIcon = "_nodeIcon_1qaq4_198";
3136
- const isSelected = "_isSelected_1qaq4_204";
3137
- const treeNode = "_treeNode_1qaq4_208";
3138
- const style0 = {
3139
- treeToggle,
3140
- leafLabel,
3141
- noData,
3142
- empty,
3143
- title,
3144
- tree,
3145
- slim,
3146
- runData,
3147
- container,
3148
- nodeIcon,
3149
- isSelected,
3150
- treeNode
3151
- };
3152
- const cssModules = {
3153
- "$style": style0
3154
- };
3155
- const RunDataAi = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules]]);
3156
- export {
3157
- HighlightJS as H,
3158
- RunDataAi as R,
3159
- ViewSubExecution as V,
3160
- _sfc_main$3 as _,
3161
- getTotalConsumedTokens as a,
3162
- _sfc_main$5 as b,
3163
- createLogEntries as c,
3164
- formatTokenUsageCount as f,
3165
- getSubtreeTotalConsumedTokens as g
3166
- };