n8n-editor-ui 1.71.3 → 1.72.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/assets/{AnnotationTagsDropdown.ee.vue_vue_type_script_setup_true_lang-C7YrhVc7.js → AnnotationTagsDropdown.ee.vue_vue_type_script_setup_true_lang-WpdLQ_Lc.js} +1 -1
  2. package/dist/assets/{AuthView-Cnr31xHM.css → AuthView-BP3bsQpK.css} +3 -14
  3. package/dist/assets/{AuthView-BhrVKHQb.js → AuthView-xWm2P-0B.js} +1 -1
  4. package/dist/assets/{CanvasChat-B2z8TKEq.js → CanvasChat-CpplEK_c.js} +76 -104
  5. package/dist/assets/{CanvasChat-BuYT3e9G.css → CanvasChat-DhkdJLy7.css} +18 -81
  6. package/dist/assets/{CanvasControls-Gjw5xMXK.css → CanvasControls-BEOkwFDJ.css} +1 -2
  7. package/dist/assets/{CanvasControls-D3OVjMCG.js → CanvasControls-CNOZvEmR.js} +1 -1
  8. package/dist/assets/{ChangePasswordView-BkoEwfgW.js → ChangePasswordView-Bx4HKBs9.js} +2 -2
  9. package/dist/assets/CollectionParameter-IbNRc-rP.js +4 -0
  10. package/dist/assets/{ConcurrentExecutionsHeader-D99WmQjD.css → ConcurrentExecutionsHeader-ChCLnjVG.css} +7 -17
  11. package/dist/assets/{ConcurrentExecutionsHeader-D_jkbuah.js → ConcurrentExecutionsHeader-dMskl4He.js} +51 -47
  12. package/dist/assets/CredentialsView-CzforIh7.css +36 -0
  13. package/dist/assets/{CredentialsView-WgZTdwDF.js → CredentialsView-DYmrbOcr.js} +15 -25
  14. package/dist/assets/ErrorView-DZCz_7-d.css +22 -0
  15. package/dist/assets/{ErrorView-CCvyR8gc.js → ErrorView-DpKWfKAY.js} +1 -1
  16. package/dist/assets/{ExecutionsView-DNwpODRj.css → ExecutionsView-CLxQdDnP.css} +16 -43
  17. package/dist/assets/{ExecutionsView-BsIeNcoc.js → ExecutionsView-a2Slm2v9.js} +123 -38
  18. package/dist/assets/FileSaver.min-BiLlhrlQ.js +81 -0
  19. package/dist/assets/{FixedCollectionParameter-DzOGMEdq.css → FixedCollectionParameter-CUxLKPYJ.css} +1 -6
  20. package/dist/assets/{FixedCollectionParameter-DMpNSKjt.js → FixedCollectionParameter-DMiADFki.js} +5 -9
  21. package/dist/assets/{ForgotMyPasswordView-m-NI0pKA.js → ForgotMyPasswordView-RLODqWeW.js} +2 -2
  22. package/dist/assets/{MainHeader-DrUbWzLR.css → MainHeader-Bg4Jr0GW.css} +16 -63
  23. package/dist/assets/{MainHeader-CzdjrO1j.js → MainHeader-CZBWRbIF.js} +20 -33
  24. package/dist/assets/{MainSidebar-DL53w2zU.css → MainSidebar-B_Q71vG8.css} +16 -68
  25. package/dist/assets/{MainSidebar-CWZj9hUz.js → MainSidebar-Cm-l0HUG.js} +86 -71
  26. package/dist/assets/{NodeCreation-BNsKR1XL.js → NodeCreation-Bycww9rf.js} +10 -14
  27. package/dist/assets/{NodeCreation-30KXmZi2.css → NodeCreation-DTNNkgVv.css} +1 -5
  28. package/dist/assets/{NodeCreator-nENM_3bV.js → NodeCreator-BrgHuvb2.js} +54 -90
  29. package/dist/assets/{NodeCreator-CvOLgSO_.css → NodeCreator-BvqI_pdC.css} +21 -91
  30. package/dist/assets/{NodeViewSwitcher-tJDzCGJC.js → NodeViewSwitcher-D5JjSNB2.js} +7425 -1780
  31. package/dist/assets/{NodeViewSwitcher-jLTC590F.css → NodeViewSwitcher-DngiUgY8.css} +323 -950
  32. package/dist/assets/{ProjectCardBadge-Dwm_41ZR.js → ProjectCardBadge-B6a5Tl_X.js} +8 -13
  33. package/dist/assets/ProjectHeader-CDl0NBcF.css +21 -0
  34. package/dist/assets/{ProjectHeader-DTRxu2oO.js → ProjectHeader-CUoGk-wO.js} +61 -44
  35. package/dist/assets/{ProjectSettings-hzCZqVHM.js → ProjectSettings-BSOa51jE.js} +24 -42
  36. package/dist/assets/{ProjectSettings-CChpfrTS.css → ProjectSettings-DZws5IzZ.css} +2 -9
  37. package/dist/assets/{PushConnectionTracker.vue_vue_type_script_setup_true_lang-Bv3nXXk5.js → PushConnectionTracker.vue_vue_type_script_setup_true_lang-ouQuoTYp.js} +1 -1
  38. package/dist/assets/{ResourcesListLayout-CKArPHiS.js → ResourcesListLayout-BKk7DIWo.js} +24 -30
  39. package/dist/assets/{ResourcesListLayout-I4rYUdFt.css → ResourcesListLayout-NZz6R66g.css} +11 -47
  40. package/dist/assets/{RunDataJson-jFaJ_yC4.js → RunDataJson-D7Whxi5x.js} +13 -13
  41. package/dist/assets/{RunDataJson-Dtc8i0I7.css → RunDataJson-DW_khHj4.css} +0 -1
  42. package/dist/assets/{RunDataJsonActions-zNKrn8z4.css → RunDataJsonActions-CoiM0oFP.css} +0 -1
  43. package/dist/assets/RunDataJsonActions-hLh8-Su6.js +5514 -0
  44. package/dist/assets/{RunDataSearch-BA0wlJtp.css → RunDataSearch-B4q8H9Ex.css} +0 -1
  45. package/dist/assets/{RunDataSearch-C9VyfwRz.js → RunDataSearch-Ds3EGLA6.js} +5 -7
  46. package/dist/assets/{RunDataTable-enskmmU4.css → RunDataTable-BOaG0Pms.css} +2 -10
  47. package/dist/assets/{RunDataTable-CK4Z05pd.js → RunDataTable-atOC6vYW.js} +9 -14
  48. package/dist/assets/{SamlOnboarding-POzPTpcl.js → SamlOnboarding-DuDPZUey.js} +4 -5
  49. package/dist/assets/{SettingsApiView-BOFUFUqU.js → SettingsApiView-CFlbEwnS.js} +1 -1
  50. package/dist/assets/{SettingsApiView-5wBxahqI.css → SettingsApiView-DX3S-5pa.css} +2 -8
  51. package/dist/assets/{SettingsCommunityNodesView-088VPv0r.js → SettingsCommunityNodesView-CJrxi3vi.js} +3 -3
  52. package/dist/assets/{SettingsCommunityNodesView-BTbugFls.css → SettingsCommunityNodesView-kzxtAoLp.css} +10 -42
  53. package/dist/assets/SettingsExternalSecrets-BnXyxlJd.css +29 -0
  54. package/dist/assets/{SettingsExternalSecrets-DlobsnOy.js → SettingsExternalSecrets-BusSlBVI.js} +14 -17
  55. package/dist/assets/SettingsLdapView-BLPKhtjA.js +2423 -0
  56. package/dist/assets/{SettingsLdapView-cRgzivq6.css → SettingsLdapView-BPh_inzE.css} +2 -8
  57. package/dist/assets/{SettingsLogStreamingView-EW9yIYwY.js → SettingsLogStreamingView-DI9OYnte.js} +20 -37
  58. package/dist/assets/SettingsLogStreamingView-Uz298HNW.css +46 -0
  59. package/dist/assets/{SettingsPersonalView-BOQgHIYm.css → SettingsPersonalView-CqzRUitO.css} +3 -13
  60. package/dist/assets/{SettingsPersonalView-DrJJtUL5.js → SettingsPersonalView-CwLPEQe5.js} +7 -10
  61. package/dist/assets/{SettingsSourceControl-COccchDl.js → SettingsSourceControl-BHiwsbh6.js} +1 -1
  62. package/dist/assets/{SettingsSourceControl-aZrwFtXG.css → SettingsSourceControl-C7H8sLJN.css} +5 -21
  63. package/dist/assets/{SettingsSso-BczGJSZo.js → SettingsSso-BUE-Dg9u.js} +10 -11
  64. package/dist/assets/{SettingsSso-DUkYL_--.css → SettingsSso-Be_ejj46.css} +3 -13
  65. package/dist/assets/{SettingsUsageAndPlan-vijI-va0.css → SettingsUsageAndPlan-C3fKPMTY.css} +13 -54
  66. package/dist/assets/{SettingsUsageAndPlan-OepwN_K0.js → SettingsUsageAndPlan-g8SYxLIm.js} +3 -7
  67. package/dist/assets/{SettingsUsersView-D6xH2uOE.js → SettingsUsersView-DsjbsMkp.js} +8 -15
  68. package/dist/assets/{SettingsView-D30Stwpp.js → SettingsView-BZqGq_NA.js} +3 -4
  69. package/dist/assets/{SettingsView-DOWbkj-V.css → SettingsView-o6uNYu0t.css} +1 -5
  70. package/dist/assets/{SetupView-DLhUy2sO.js → SetupView-DKcifLmN.js} +3 -9
  71. package/dist/assets/{SetupWorkflowCredentialsButton-FAOxK4hC.js → SetupWorkflowCredentialsButton-1FX7DWWs.js} +3 -5
  72. package/dist/assets/{SetupWorkflowFromTemplateView-29le4KEi.js → SetupWorkflowFromTemplateView-BI8db6Bn.js} +5 -9
  73. package/dist/assets/SetupWorkflowFromTemplateView-DjBcyMCl.css +26 -0
  74. package/dist/assets/{SigninView-B3r5QMqu.js → SigninView-DRl5Z9dU.js} +4 -5
  75. package/dist/assets/{SigninView-BEBHcgmK.css → SigninView-DzDE1gJb.css} +3 -14
  76. package/dist/assets/{SignoutView-DiRv1jyS.js → SignoutView-CD6CNCd4.js} +1 -1
  77. package/dist/assets/{SignupView-DepIL1mr.js → SignupView-BUIFD8_L.js} +2 -2
  78. package/dist/assets/{TemplateDetails-BG8YmNsP.js → TemplateDetails-BZy8nHAa.js} +1 -1
  79. package/dist/assets/{TemplateDetails-BjsdeJu8.css → TemplateDetails-p3M6A7jr.css} +1 -4
  80. package/dist/assets/{TemplateList-4lx8vpYf.css → TemplateList-BR3bpDTv.css} +13 -52
  81. package/dist/assets/{TemplateList-CEljIT09.js → TemplateList-DdYIfcdc.js} +1 -1
  82. package/dist/assets/{TemplatesCollectionView-C1BUeMtq.css → TemplatesCollectionView-DJVlK4Bb.css} +1 -5
  83. package/dist/assets/{TemplatesCollectionView-C1katHqi.js → TemplatesCollectionView-a9gOg1oh.js} +5 -5
  84. package/dist/assets/{TemplatesSearchView-BiokbeYf.css → TemplatesSearchView-CFrHWGcY.css} +4 -21
  85. package/dist/assets/{TemplatesSearchView-6ugazm6D.js → TemplatesSearchView-C_qp2w-Y.js} +5 -20
  86. package/dist/assets/{TemplatesView-BfnDbKo5.css → TemplatesView-CBNZZ_X1.css} +3 -16
  87. package/dist/assets/{TemplatesView-BnpZqzSI.js → TemplatesView-Srd2qTc6.js} +1 -1
  88. package/dist/assets/{TemplatesWorkflowView-D-rSlrYy.js → TemplatesWorkflowView-CDkCoN9X.js} +35 -39
  89. package/dist/assets/{TemplatesWorkflowView-BN5JjV6M.css → TemplatesWorkflowView-CVC0fbb6.css} +2 -10
  90. package/dist/assets/{TestDefinitionEditView-szspUG0t.css → TestDefinitionEditView-CVRXpJ4c.css} +13 -54
  91. package/dist/assets/{TestDefinitionEditView-Dw2F_7Ku.js → TestDefinitionEditView-CgQpahO7.js} +3 -4
  92. package/dist/assets/{TestDefinitionListView-Cv9ivpVk.js → TestDefinitionListView-BGJr2Okj.js} +4 -4
  93. package/dist/assets/{TestDefinitionListView-BfUssieW.css → TestDefinitionListView-BJVxwUdb.css} +9 -46
  94. package/dist/assets/{VariablesView-meR15bnW.css → VariablesView-BnGnRwcl.css} +3 -13
  95. package/dist/assets/{VariablesView-BrvfrvgE.js → VariablesView-DBlZthPg.js} +28 -38
  96. package/dist/assets/{VirtualSchema-Be-DGXEU.css → VirtualSchema-CIfwZj8N.css} +11 -48
  97. package/dist/assets/VirtualSchema-DkiHWd9N.js +378 -0
  98. package/dist/assets/{WorkerView-DhAgtBED.js → WorkerView--FWlY_KA.js} +14 -23
  99. package/dist/assets/WorkerView-CvXMClDD.css +123 -0
  100. package/dist/assets/{WorkflowActivator-Def_oRg7.js → WorkflowActivator-BbpMhG1U.js} +2 -2
  101. package/dist/assets/{WorkflowActivator-D8FiI2jP.css → WorkflowActivator-DSBGQvK0.css} +3 -9
  102. package/dist/assets/{WorkflowExecutionsInfoAccordion-lODxxxtv.js → WorkflowExecutionsInfoAccordion-DOpZ49kK.js} +1 -1
  103. package/dist/assets/{WorkflowExecutionsInfoAccordion-DfMew6q4.css → WorkflowExecutionsInfoAccordion-f5tIRAwu.css} +2 -14
  104. package/dist/assets/WorkflowExecutionsLandingPage-BodEQ5Bq.css +23 -0
  105. package/dist/assets/{WorkflowExecutionsLandingPage-Bidi-y5V.js → WorkflowExecutionsLandingPage-CAbWLqG8.js} +2 -2
  106. package/dist/assets/{WorkflowExecutionsPreview-DRCpGEbi.css → WorkflowExecutionsPreview-C-e7WZrK.css} +22 -98
  107. package/dist/assets/{WorkflowExecutionsPreview-d2F04pj8.js → WorkflowExecutionsPreview-CfUWIIgy.js} +39 -71
  108. package/dist/assets/{WorkflowExecutionsView-C6EMZ-AQ.css → WorkflowExecutionsView-CFOgmzpK.css} +18 -74
  109. package/dist/assets/{WorkflowExecutionsView-CHr4rzKW.js → WorkflowExecutionsView-DrfZ7QK8.js} +151 -165
  110. package/dist/assets/{WorkflowHistory-C-lUH0fo.css → WorkflowHistory-D0ufvWsH.css} +14 -57
  111. package/dist/assets/{WorkflowHistory-BSijDFcx.js → WorkflowHistory-eqsh1yXn.js} +16 -29
  112. package/dist/assets/{WorkflowOnboardingView-CvuowIe6.js → WorkflowOnboardingView-Kbe8c2_R.js} +22 -5
  113. package/dist/assets/{WorkflowPreview-CYf78I6t.js → WorkflowPreview-DKTyMYfO.js} +5 -11
  114. package/dist/assets/{WorkflowPreview-Bpiv2_RO.css → WorkflowPreview-DuLM6rtd.css} +4 -15
  115. package/dist/assets/{WorkflowsView-Bc1WW7-8.js → WorkflowsView-ClrcrpKc.js} +110 -120
  116. package/dist/assets/WorkflowsView-D5fBzfD4.css +65 -0
  117. package/dist/assets/{index-D50gpyk6.css → index-Bo70cRA3.css} +350 -1351
  118. package/dist/assets/{index-D57HUAs6.js → index-fCEqBD8K.js} +45117 -40863
  119. package/dist/assets/polyfills-BN5TIqPj.js +5985 -0
  120. package/dist/assets/{pushConnection.store-BrFt2YWH.js → pushConnection.store-Kmly9nV5.js} +2 -3
  121. package/dist/assets/{templateActions-BrLvM4wQ.js → templateActions-xeWyRgrU.js} +1 -1
  122. package/dist/assets/{testDefinition.store.ee-DJ6gErZh.js → testDefinition.store.ee-C9BPbACc.js} +1 -1
  123. package/dist/assets/{useBugReporting-v6zXxGxR.js → useBugReporting-CbgIVUCL.js} +1 -1
  124. package/dist/assets/{useExecutionDebugging-Dhwr-oW3.js → useExecutionDebugging-Cuf88DQE.js} +3 -6
  125. package/dist/assets/{useExecutionHelpers-Ovym9OwA.js → useExecutionHelpers-BIxUwlsh.js} +3 -4
  126. package/dist/assets/{useGlobalEntityCreation-D_NS7_je.js → useGlobalEntityCreation-DGVSN-Im.js} +29 -14
  127. package/dist/assets/{useNodeViewVersionSwitcher-ESq0kPP5.js → useNodeViewVersionSwitcher-Eg-dOWbq.js} +1 -1
  128. package/dist/assets/{usePushConnection-DCkWEVa2.js → usePushConnection-D-iAKJiL.js} +36 -22
  129. package/dist/assets/{useRunWorkflow-B_S0x25z.css → useRunWorkflow-BDl-2MsN.css} +24 -106
  130. package/dist/assets/{useRunWorkflow-g1Tw1vWo.js → useRunWorkflow-BXE6bWp2.js} +1547 -1581
  131. package/dist/assets/{useWorkflowActivate-DibPO-sA.js → useWorkflowActivate-D8cU5eJ_.js} +1 -1
  132. package/dist/index.html +4 -2
  133. package/package.json +1 -1
  134. package/tsconfig.json +2 -1
  135. package/vite.config.mts +11 -0
  136. package/dist/assets/CollectionParameter-D7-YFFFP.js +0 -4
  137. package/dist/assets/CredentialsView-ChjCCSbV.css +0 -56
  138. package/dist/assets/ErrorView-Dzof6SY8.css +0 -35
  139. package/dist/assets/FileSaver.min-BsJSdQo9.js +0 -74
  140. package/dist/assets/ProjectHeader-CTK_rV3h.css +0 -28
  141. package/dist/assets/RunDataJsonActions-CUYH2C-z.js +0 -5509
  142. package/dist/assets/SettingsExternalSecrets-BD5PuMIG.css +0 -50
  143. package/dist/assets/SettingsLdapView-CDm8JWNK.js +0 -2417
  144. package/dist/assets/SettingsLogStreamingView-CWIuI89G.css +0 -75
  145. package/dist/assets/SetupWorkflowFromTemplateView-CvsDVBkh.css +0 -44
  146. package/dist/assets/VirtualSchema-DFybirEh.js +0 -1863
  147. package/dist/assets/WorkerView-C_d54L0W.css +0 -181
  148. package/dist/assets/WorkflowExecutionsLandingPage-B1zCnzh_.css +0 -39
  149. package/dist/assets/WorkflowsView-C1eCTa1K.css +0 -82
  150. /package/dist/assets/{ProjectCardBadge-DPUG4BoB.css → ProjectCardBadge-DQvW5T7s.css} +0 -0
  151. /package/dist/assets/{SettingsUsersView-Ba9S2o-I.css → SettingsUsersView-C13eCMjh.css} +0 -0
@@ -1,5 +1,5 @@
1
- import { hN as baseSlice, hO as toString, ej as getDefaultExportFromCjs, d as defineComponent, b2 as useClipboard, a as useToast, hP as useAIAssistantHelpers, bk as useNodeTypesStore, at as useNDVStore, Z as useRootStore, hQ as useAssistantStore, K as useUIStore, q as computed, c as openBlock, h as createElementBlock, j as createBaseVNode, t as toDisplayString, ay as withDirectives, f as createCommentVNode, i as createVNode, l as unref, hR as InlineAskAssistantButton, w as withCtx, k as createTextVNode, F as Fragment, A as renderList, g as useI18n, eu as MAX_DISPLAY_DATA_SIZE, dy as isCommunityPackageName, hS as NEW_ASSISTANT_SESSION_MODAL, m as resolveComponent, cI as resolveDirective, hF as sanitizeHtml, bd as NodeConnectionType, hT as isObjectEmpty, r as ref, o as onMounted, n as normalizeClass, e as createBlock, aZ as VueMarkdown, _ as _export_sfc, T as useWorkflowsStore, dx as _sfc_main$4, I as withModifiers, H as watch, B as normalizeStyle, hU as ElTree, hs as isSubNodeType, hV as PIN_DATA_NODE_TYPES_DENYLIST, bc as getNodeOutputs, hW as jsonStringify, hX as toMegaBytes, hY as stringSizeInBytes, em as jsonParse, ak as useTelemetry, aP as useExternalHooks, ht as useDataSchema, hZ as MAX_PINNED_DATA_SIZE, h_ as MAX_WORKFLOW_SIZE, h$ as MAX_EXPECTED_REQUEST_SIZE, bl as useNodeHelpers, a4 as useWorkflowHelpers, au as useExecutionsStore, b3 as CHAT_TRIGGER_NODE_TYPE, bf as get, i0 as SINGLE_WEBHOOK_TRIGGERS, aw as useLocalStorage, i1 as displayForm, eK as isEmpty } from "./index-D57HUAs6.js";
2
- import { u as useExecutionHelpers } from "./useExecutionHelpers-Ovym9OwA.js";
1
+ import { gv as baseSlice, gw as toString, cI as getDefaultExportFromCjs, d as defineComponent, b2 as useClipboard, a as useToast, gx as useAIAssistantHelpers, bk as useNodeTypesStore, at as useNDVStore, Z as useRootStore, gy as useAssistantStore, K as useUIStore, q as computed, c as openBlock, h as createElementBlock, j as createBaseVNode, t as toDisplayString, ay as withDirectives, f as createCommentVNode, i as createVNode, l as unref, gz as InlineAskAssistantButton, w as withCtx, k as createTextVNode, F as Fragment, A as renderList, g as useI18n, cU as MAX_DISPLAY_DATA_SIZE, bA as isCommunityPackageName, gA as NEW_ASSISTANT_SESSION_MODAL, m as resolveComponent, di as resolveDirective, gl as sanitizeHtml, bd as NodeConnectionType, gB as isObjectEmpty, r as ref, o as onMounted, n as normalizeClass, e as createBlock, aZ as VueMarkdown, _ as _export_sfc, T as useWorkflowsStore, bz as _sfc_main$4, I as withModifiers, H as watch, B as normalizeStyle, gC as ElTree, f_ as isSubNodeType, gD as PIN_DATA_NODE_TYPES_DENYLIST, bc as getNodeOutputs, gE as jsonStringify, gF as toMegaBytes, gG as stringSizeInBytes, cL as jsonParse, ak as useTelemetry, aP as useExternalHooks, f$ as useDataSchema, gH as MAX_PINNED_DATA_SIZE, gI as MAX_WORKFLOW_SIZE, gJ as MAX_EXPECTED_REQUEST_SIZE, bl as useNodeHelpers, a4 as useWorkflowHelpers, au as useExecutionsStore, b3 as CHAT_TRIGGER_NODE_TYPE, bf as get, gK as SINGLE_WEBHOOK_TRIGGERS, aw as useLocalStorage, gL as displayForm, da as isEmpty } from "./index-fCEqBD8K.js";
2
+ import { u as useExecutionHelpers } from "./useExecutionHelpers-BIxUwlsh.js";
3
3
  function castSlice(array, start, end) {
4
4
  var length = array.length;
5
5
  end = end === void 0 ? length : end;
@@ -37,1538 +37,1546 @@ var upperFirst = createCaseFirst("toUpperCase");
37
37
  function capitalize(string) {
38
38
  return upperFirst(toString(string).toLowerCase());
39
39
  }
40
- function deepFreeze(obj) {
41
- if (obj instanceof Map) {
42
- obj.clear = obj.delete = obj.set = function() {
43
- throw new Error("map is read-only");
44
- };
45
- } else if (obj instanceof Set) {
46
- obj.add = obj.clear = obj.delete = function() {
47
- throw new Error("set is read-only");
48
- };
49
- }
50
- Object.freeze(obj);
51
- Object.getOwnPropertyNames(obj).forEach((name) => {
52
- const prop = obj[name];
53
- const type = typeof prop;
54
- if ((type === "object" || type === "function") && !Object.isFrozen(prop)) {
55
- deepFreeze(prop);
40
+ var core;
41
+ var hasRequiredCore;
42
+ function requireCore() {
43
+ if (hasRequiredCore) return core;
44
+ hasRequiredCore = 1;
45
+ function deepFreeze(obj) {
46
+ if (obj instanceof Map) {
47
+ obj.clear = obj.delete = obj.set = function() {
48
+ throw new Error("map is read-only");
49
+ };
50
+ } else if (obj instanceof Set) {
51
+ obj.add = obj.clear = obj.delete = function() {
52
+ throw new Error("set is read-only");
53
+ };
56
54
  }
57
- });
58
- return obj;
59
- }
60
- class Response {
61
- /**
62
- * @param {CompiledMode} mode
63
- */
64
- constructor(mode) {
65
- if (mode.data === void 0) mode.data = {};
66
- this.data = mode.data;
67
- this.isMatchIgnored = false;
68
- }
69
- ignoreMatch() {
70
- this.isMatchIgnored = true;
71
- }
72
- }
73
- function escapeHTML(value) {
74
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
75
- }
76
- function inherit$1(original, ...objects) {
77
- const result = /* @__PURE__ */ Object.create(null);
78
- for (const key in original) {
79
- result[key] = original[key];
55
+ Object.freeze(obj);
56
+ Object.getOwnPropertyNames(obj).forEach((name) => {
57
+ const prop = obj[name];
58
+ const type = typeof prop;
59
+ if ((type === "object" || type === "function") && !Object.isFrozen(prop)) {
60
+ deepFreeze(prop);
61
+ }
62
+ });
63
+ return obj;
80
64
  }
81
- objects.forEach(function(obj) {
82
- for (const key in obj) {
83
- result[key] = obj[key];
65
+ class Response {
66
+ /**
67
+ * @param {CompiledMode} mode
68
+ */
69
+ constructor(mode) {
70
+ if (mode.data === void 0) mode.data = {};
71
+ this.data = mode.data;
72
+ this.isMatchIgnored = false;
73
+ }
74
+ ignoreMatch() {
75
+ this.isMatchIgnored = true;
84
76
  }
85
- });
86
- return (
87
- /** @type {T} */
88
- result
89
- );
90
- }
91
- const SPAN_CLOSE = "</span>";
92
- const emitsWrappingTags = (node) => {
93
- return !!node.scope;
94
- };
95
- const scopeToCSSClass = (name, { prefix }) => {
96
- if (name.startsWith("language:")) {
97
- return name.replace("language:", "language-");
98
- }
99
- if (name.includes(".")) {
100
- const pieces = name.split(".");
101
- return [
102
- `${prefix}${pieces.shift()}`,
103
- ...pieces.map((x, i) => `${x}${"_".repeat(i + 1)}`)
104
- ].join(" ");
105
- }
106
- return `${prefix}${name}`;
107
- };
108
- class HTMLRenderer {
109
- /**
110
- * Creates a new HTMLRenderer
111
- *
112
- * @param {Tree} parseTree - the parse tree (must support `walk` API)
113
- * @param {{classPrefix: string}} options
114
- */
115
- constructor(parseTree, options) {
116
- this.buffer = "";
117
- this.classPrefix = options.classPrefix;
118
- parseTree.walk(this);
119
77
  }
120
- /**
121
- * Adds texts to the output stream
122
- *
123
- * @param {string} text */
124
- addText(text) {
125
- this.buffer += escapeHTML(text);
78
+ function escapeHTML(value) {
79
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
126
80
  }
127
- /**
128
- * Adds a node open to the output stream (if needed)
129
- *
130
- * @param {Node} node */
131
- openNode(node) {
132
- if (!emitsWrappingTags(node)) return;
133
- const className = scopeToCSSClass(
134
- node.scope,
135
- { prefix: this.classPrefix }
81
+ function inherit$1(original, ...objects) {
82
+ const result = /* @__PURE__ */ Object.create(null);
83
+ for (const key in original) {
84
+ result[key] = original[key];
85
+ }
86
+ objects.forEach(function(obj) {
87
+ for (const key in obj) {
88
+ result[key] = obj[key];
89
+ }
90
+ });
91
+ return (
92
+ /** @type {T} */
93
+ result
136
94
  );
137
- this.span(className);
138
- }
139
- /**
140
- * Adds a node close to the output stream (if needed)
141
- *
142
- * @param {Node} node */
143
- closeNode(node) {
144
- if (!emitsWrappingTags(node)) return;
145
- this.buffer += SPAN_CLOSE;
146
- }
147
- /**
148
- * returns the accumulated buffer
149
- */
150
- value() {
151
- return this.buffer;
152
- }
153
- // helpers
154
- /**
155
- * Builds a span element
156
- *
157
- * @param {string} className */
158
- span(className) {
159
- this.buffer += `<span class="${className}">`;
160
- }
161
- }
162
- const newNode = (opts = {}) => {
163
- const result = { children: [] };
164
- Object.assign(result, opts);
165
- return result;
166
- };
167
- class TokenTree {
168
- constructor() {
169
- this.rootNode = newNode();
170
- this.stack = [this.rootNode];
171
95
  }
172
- get top() {
173
- return this.stack[this.stack.length - 1];
174
- }
175
- get root() {
176
- return this.rootNode;
177
- }
178
- /** @param {Node} node */
179
- add(node) {
180
- this.top.children.push(node);
181
- }
182
- /** @param {string} scope */
183
- openNode(scope) {
184
- const node = newNode({ scope });
185
- this.add(node);
186
- this.stack.push(node);
187
- }
188
- closeNode() {
189
- if (this.stack.length > 1) {
190
- return this.stack.pop();
96
+ const SPAN_CLOSE = "</span>";
97
+ const emitsWrappingTags = (node) => {
98
+ return !!node.scope;
99
+ };
100
+ const scopeToCSSClass = (name, { prefix }) => {
101
+ if (name.startsWith("language:")) {
102
+ return name.replace("language:", "language-");
191
103
  }
192
- return void 0;
193
- }
194
- closeAllNodes() {
195
- while (this.closeNode()) ;
196
- }
197
- toJSON() {
198
- return JSON.stringify(this.rootNode, null, 4);
199
- }
200
- /**
201
- * @typedef { import("./html_renderer").Renderer } Renderer
202
- * @param {Renderer} builder
203
- */
204
- walk(builder) {
205
- return this.constructor._walk(builder, this.rootNode);
206
- }
207
- /**
208
- * @param {Renderer} builder
209
- * @param {Node} node
210
- */
211
- static _walk(builder, node) {
212
- if (typeof node === "string") {
213
- builder.addText(node);
214
- } else if (node.children) {
215
- builder.openNode(node);
216
- node.children.forEach((child) => this._walk(builder, child));
217
- builder.closeNode(node);
218
- }
219
- return builder;
220
- }
221
- /**
222
- * @param {Node} node
223
- */
224
- static _collapse(node) {
225
- if (typeof node === "string") return;
226
- if (!node.children) return;
227
- if (node.children.every((el) => typeof el === "string")) {
228
- node.children = [node.children.join("")];
229
- } else {
230
- node.children.forEach((child) => {
231
- TokenTree._collapse(child);
232
- });
104
+ if (name.includes(".")) {
105
+ const pieces = name.split(".");
106
+ return [
107
+ `${prefix}${pieces.shift()}`,
108
+ ...pieces.map((x, i) => `${x}${"_".repeat(i + 1)}`)
109
+ ].join(" ");
233
110
  }
234
- }
235
- }
236
- class TokenTreeEmitter extends TokenTree {
237
- /**
238
- * @param {*} options
239
- */
240
- constructor(options) {
241
- super();
242
- this.options = options;
243
- }
244
- /**
245
- * @param {string} text
246
- */
247
- addText(text) {
248
- if (text === "") {
249
- return;
111
+ return `${prefix}${name}`;
112
+ };
113
+ class HTMLRenderer {
114
+ /**
115
+ * Creates a new HTMLRenderer
116
+ *
117
+ * @param {Tree} parseTree - the parse tree (must support `walk` API)
118
+ * @param {{classPrefix: string}} options
119
+ */
120
+ constructor(parseTree, options) {
121
+ this.buffer = "";
122
+ this.classPrefix = options.classPrefix;
123
+ parseTree.walk(this);
124
+ }
125
+ /**
126
+ * Adds texts to the output stream
127
+ *
128
+ * @param {string} text */
129
+ addText(text) {
130
+ this.buffer += escapeHTML(text);
131
+ }
132
+ /**
133
+ * Adds a node open to the output stream (if needed)
134
+ *
135
+ * @param {Node} node */
136
+ openNode(node) {
137
+ if (!emitsWrappingTags(node)) return;
138
+ const className = scopeToCSSClass(
139
+ node.scope,
140
+ { prefix: this.classPrefix }
141
+ );
142
+ this.span(className);
143
+ }
144
+ /**
145
+ * Adds a node close to the output stream (if needed)
146
+ *
147
+ * @param {Node} node */
148
+ closeNode(node) {
149
+ if (!emitsWrappingTags(node)) return;
150
+ this.buffer += SPAN_CLOSE;
151
+ }
152
+ /**
153
+ * returns the accumulated buffer
154
+ */
155
+ value() {
156
+ return this.buffer;
157
+ }
158
+ // helpers
159
+ /**
160
+ * Builds a span element
161
+ *
162
+ * @param {string} className */
163
+ span(className) {
164
+ this.buffer += `<span class="${className}">`;
165
+ }
166
+ }
167
+ const newNode = (opts = {}) => {
168
+ const result = { children: [] };
169
+ Object.assign(result, opts);
170
+ return result;
171
+ };
172
+ class TokenTree {
173
+ constructor() {
174
+ this.rootNode = newNode();
175
+ this.stack = [this.rootNode];
176
+ }
177
+ get top() {
178
+ return this.stack[this.stack.length - 1];
179
+ }
180
+ get root() {
181
+ return this.rootNode;
182
+ }
183
+ /** @param {Node} node */
184
+ add(node) {
185
+ this.top.children.push(node);
186
+ }
187
+ /** @param {string} scope */
188
+ openNode(scope) {
189
+ const node = newNode({ scope });
190
+ this.add(node);
191
+ this.stack.push(node);
192
+ }
193
+ closeNode() {
194
+ if (this.stack.length > 1) {
195
+ return this.stack.pop();
196
+ }
197
+ return void 0;
198
+ }
199
+ closeAllNodes() {
200
+ while (this.closeNode()) ;
201
+ }
202
+ toJSON() {
203
+ return JSON.stringify(this.rootNode, null, 4);
204
+ }
205
+ /**
206
+ * @typedef { import("./html_renderer").Renderer } Renderer
207
+ * @param {Renderer} builder
208
+ */
209
+ walk(builder) {
210
+ return this.constructor._walk(builder, this.rootNode);
211
+ }
212
+ /**
213
+ * @param {Renderer} builder
214
+ * @param {Node} node
215
+ */
216
+ static _walk(builder, node) {
217
+ if (typeof node === "string") {
218
+ builder.addText(node);
219
+ } else if (node.children) {
220
+ builder.openNode(node);
221
+ node.children.forEach((child) => this._walk(builder, child));
222
+ builder.closeNode(node);
223
+ }
224
+ return builder;
225
+ }
226
+ /**
227
+ * @param {Node} node
228
+ */
229
+ static _collapse(node) {
230
+ if (typeof node === "string") return;
231
+ if (!node.children) return;
232
+ if (node.children.every((el) => typeof el === "string")) {
233
+ node.children = [node.children.join("")];
234
+ } else {
235
+ node.children.forEach((child) => {
236
+ TokenTree._collapse(child);
237
+ });
238
+ }
250
239
  }
251
- this.add(text);
252
240
  }
253
- /** @param {string} scope */
254
- startScope(scope) {
255
- this.openNode(scope);
241
+ class TokenTreeEmitter extends TokenTree {
242
+ /**
243
+ * @param {*} options
244
+ */
245
+ constructor(options) {
246
+ super();
247
+ this.options = options;
248
+ }
249
+ /**
250
+ * @param {string} text
251
+ */
252
+ addText(text) {
253
+ if (text === "") {
254
+ return;
255
+ }
256
+ this.add(text);
257
+ }
258
+ /** @param {string} scope */
259
+ startScope(scope) {
260
+ this.openNode(scope);
261
+ }
262
+ endScope() {
263
+ this.closeNode();
264
+ }
265
+ /**
266
+ * @param {Emitter & {root: DataNode}} emitter
267
+ * @param {string} name
268
+ */
269
+ __addSublanguage(emitter, name) {
270
+ const node = emitter.root;
271
+ if (name) node.scope = `language:${name}`;
272
+ this.add(node);
273
+ }
274
+ toHTML() {
275
+ const renderer = new HTMLRenderer(this, this.options);
276
+ return renderer.value();
277
+ }
278
+ finalize() {
279
+ this.closeAllNodes();
280
+ return true;
281
+ }
256
282
  }
257
- endScope() {
258
- this.closeNode();
283
+ function source(re) {
284
+ if (!re) return null;
285
+ if (typeof re === "string") return re;
286
+ return re.source;
259
287
  }
260
- /**
261
- * @param {Emitter & {root: DataNode}} emitter
262
- * @param {string} name
263
- */
264
- __addSublanguage(emitter, name) {
265
- const node = emitter.root;
266
- if (name) node.scope = `language:${name}`;
267
- this.add(node);
288
+ function lookahead(re) {
289
+ return concat("(?=", re, ")");
268
290
  }
269
- toHTML() {
270
- const renderer = new HTMLRenderer(this, this.options);
271
- return renderer.value();
291
+ function anyNumberOfTimes(re) {
292
+ return concat("(?:", re, ")*");
272
293
  }
273
- finalize() {
274
- this.closeAllNodes();
275
- return true;
294
+ function optional(re) {
295
+ return concat("(?:", re, ")?");
276
296
  }
277
- }
278
- function source(re) {
279
- if (!re) return null;
280
- if (typeof re === "string") return re;
281
- return re.source;
282
- }
283
- function lookahead(re) {
284
- return concat("(?=", re, ")");
285
- }
286
- function anyNumberOfTimes(re) {
287
- return concat("(?:", re, ")*");
288
- }
289
- function optional(re) {
290
- return concat("(?:", re, ")?");
291
- }
292
- function concat(...args) {
293
- const joined = args.map((x) => source(x)).join("");
294
- return joined;
295
- }
296
- function stripOptionsFromArgs(args) {
297
- const opts = args[args.length - 1];
298
- if (typeof opts === "object" && opts.constructor === Object) {
299
- args.splice(args.length - 1, 1);
300
- return opts;
301
- } else {
302
- return {};
297
+ function concat(...args) {
298
+ const joined = args.map((x) => source(x)).join("");
299
+ return joined;
303
300
  }
304
- }
305
- function either(...args) {
306
- const opts = stripOptionsFromArgs(args);
307
- const joined = "(" + (opts.capture ? "" : "?:") + args.map((x) => source(x)).join("|") + ")";
308
- return joined;
309
- }
310
- function countMatchGroups(re) {
311
- return new RegExp(re.toString() + "|").exec("").length - 1;
312
- }
313
- function startsWith(re, lexeme) {
314
- const match = re && re.exec(lexeme);
315
- return match && match.index === 0;
316
- }
317
- const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
318
- function _rewriteBackreferences(regexps, { joinWith }) {
319
- let numCaptures = 0;
320
- return regexps.map((regex) => {
321
- numCaptures += 1;
322
- const offset = numCaptures;
323
- let re = source(regex);
324
- let out = "";
325
- while (re.length > 0) {
326
- const match = BACKREF_RE.exec(re);
327
- if (!match) {
328
- out += re;
329
- break;
330
- }
331
- out += re.substring(0, match.index);
332
- re = re.substring(match.index + match[0].length);
333
- if (match[0][0] === "\\" && match[1]) {
334
- out += "\\" + String(Number(match[1]) + offset);
335
- } else {
336
- out += match[0];
337
- if (match[0] === "(") {
338
- numCaptures++;
301
+ function stripOptionsFromArgs(args) {
302
+ const opts = args[args.length - 1];
303
+ if (typeof opts === "object" && opts.constructor === Object) {
304
+ args.splice(args.length - 1, 1);
305
+ return opts;
306
+ } else {
307
+ return {};
308
+ }
309
+ }
310
+ function either(...args) {
311
+ const opts = stripOptionsFromArgs(args);
312
+ const joined = "(" + (opts.capture ? "" : "?:") + args.map((x) => source(x)).join("|") + ")";
313
+ return joined;
314
+ }
315
+ function countMatchGroups(re) {
316
+ return new RegExp(re.toString() + "|").exec("").length - 1;
317
+ }
318
+ function startsWith(re, lexeme) {
319
+ const match = re && re.exec(lexeme);
320
+ return match && match.index === 0;
321
+ }
322
+ const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
323
+ function _rewriteBackreferences(regexps, { joinWith }) {
324
+ let numCaptures = 0;
325
+ return regexps.map((regex) => {
326
+ numCaptures += 1;
327
+ const offset = numCaptures;
328
+ let re = source(regex);
329
+ let out = "";
330
+ while (re.length > 0) {
331
+ const match = BACKREF_RE.exec(re);
332
+ if (!match) {
333
+ out += re;
334
+ break;
335
+ }
336
+ out += re.substring(0, match.index);
337
+ re = re.substring(match.index + match[0].length);
338
+ if (match[0][0] === "\\" && match[1]) {
339
+ out += "\\" + String(Number(match[1]) + offset);
340
+ } else {
341
+ out += match[0];
342
+ if (match[0] === "(") {
343
+ numCaptures++;
344
+ }
339
345
  }
340
346
  }
347
+ return out;
348
+ }).map((re) => `(${re})`).join(joinWith);
349
+ }
350
+ const MATCH_NOTHING_RE = /\b\B/;
351
+ const IDENT_RE = "[a-zA-Z]\\w*";
352
+ const UNDERSCORE_IDENT_RE = "[a-zA-Z_]\\w*";
353
+ const NUMBER_RE = "\\b\\d+(\\.\\d+)?";
354
+ const C_NUMBER_RE = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";
355
+ const BINARY_NUMBER_RE = "\\b(0b[01]+)";
356
+ const RE_STARTERS_RE = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";
357
+ const SHEBANG = (opts = {}) => {
358
+ const beginShebang = /^#![ ]*\//;
359
+ if (opts.binary) {
360
+ opts.begin = concat(
361
+ beginShebang,
362
+ /.*\b/,
363
+ opts.binary,
364
+ /\b.*/
365
+ );
341
366
  }
342
- return out;
343
- }).map((re) => `(${re})`).join(joinWith);
344
- }
345
- const MATCH_NOTHING_RE = /\b\B/;
346
- const IDENT_RE = "[a-zA-Z]\\w*";
347
- const UNDERSCORE_IDENT_RE = "[a-zA-Z_]\\w*";
348
- const NUMBER_RE = "\\b\\d+(\\.\\d+)?";
349
- const C_NUMBER_RE = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";
350
- const BINARY_NUMBER_RE = "\\b(0b[01]+)";
351
- const RE_STARTERS_RE = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";
352
- const SHEBANG = (opts = {}) => {
353
- const beginShebang = /^#![ ]*\//;
354
- if (opts.binary) {
355
- opts.begin = concat(
356
- beginShebang,
357
- /.*\b/,
358
- opts.binary,
359
- /\b.*/
360
- );
361
- }
362
- return inherit$1({
363
- scope: "meta",
364
- begin: beginShebang,
365
- end: /$/,
366
- relevance: 0,
367
- /** @type {ModeCallback} */
368
- "on:begin": (m, resp) => {
369
- if (m.index !== 0) resp.ignoreMatch();
370
- }
371
- }, opts);
372
- };
373
- const BACKSLASH_ESCAPE = {
374
- begin: "\\\\[\\s\\S]",
375
- relevance: 0
376
- };
377
- const APOS_STRING_MODE = {
378
- scope: "string",
379
- begin: "'",
380
- end: "'",
381
- illegal: "\\n",
382
- contains: [BACKSLASH_ESCAPE]
383
- };
384
- const QUOTE_STRING_MODE = {
385
- scope: "string",
386
- begin: '"',
387
- end: '"',
388
- illegal: "\\n",
389
- contains: [BACKSLASH_ESCAPE]
390
- };
391
- const PHRASAL_WORDS_MODE = {
392
- 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/
393
- };
394
- const COMMENT = function(begin, end, modeOptions = {}) {
395
- const mode = inherit$1(
396
- {
397
- scope: "comment",
398
- begin,
399
- end,
400
- contains: []
401
- },
402
- modeOptions
403
- );
404
- mode.contains.push({
405
- scope: "doctag",
406
- // hack to avoid the space from being included. the space is necessary to
407
- // match here to prevent the plain text rule below from gobbling up doctags
408
- begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
409
- end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,
410
- excludeBegin: true,
411
- relevance: 0
412
- });
413
- const ENGLISH_WORD = either(
414
- // list of common 1 and 2 letter words in English
415
- "I",
416
- "a",
417
- "is",
418
- "so",
419
- "us",
420
- "to",
421
- "at",
422
- "if",
423
- "in",
424
- "it",
425
- "on",
426
- // note: this is not an exhaustive list of contractions, just popular ones
427
- /[A-Za-z]+['](d|ve|re|ll|t|s|n)/,
428
- // contractions - can't we'd they're let's, etc
429
- /[A-Za-z]+[-][a-z]+/,
430
- // `no-way`, etc.
431
- /[A-Za-z][a-z]{2,}/
432
- // allow capitalized words at beginning of sentences
433
- );
434
- mode.contains.push(
435
- {
436
- // TODO: how to include ", (, ) without breaking grammars that use these for
437
- // comment delimiters?
438
- // begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/
439
- // ---
440
- // this tries to find sequences of 3 english words in a row (without any
441
- // "programming" type syntax) this gives us a strong signal that we've
442
- // TRULY found a comment - vs perhaps scanning with the wrong language.
443
- // It's possible to find something that LOOKS like the start of the
444
- // comment - but then if there is no readable text - good chance it is a
445
- // false match and not a comment.
446
- //
447
- // for a visual example please see:
448
- // https://github.com/highlightjs/highlight.js/issues/2827
449
- begin: concat(
450
- /[ ]+/,
451
- // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */
452
- "(",
453
- ENGLISH_WORD,
454
- /[.]?[:]?([.][ ]|[ ])/,
455
- "){3}"
456
- )
457
- // look for 3 words in a row
458
- }
459
- );
460
- return mode;
461
- };
462
- const C_LINE_COMMENT_MODE = COMMENT("//", "$");
463
- const C_BLOCK_COMMENT_MODE = COMMENT("/\\*", "\\*/");
464
- const HASH_COMMENT_MODE = COMMENT("#", "$");
465
- const NUMBER_MODE = {
466
- scope: "number",
467
- begin: NUMBER_RE,
468
- relevance: 0
469
- };
470
- const C_NUMBER_MODE = {
471
- scope: "number",
472
- begin: C_NUMBER_RE,
473
- relevance: 0
474
- };
475
- const BINARY_NUMBER_MODE = {
476
- scope: "number",
477
- begin: BINARY_NUMBER_RE,
478
- relevance: 0
479
- };
480
- const REGEXP_MODE = {
481
- scope: "regexp",
482
- begin: /\/(?=[^/\n]*\/)/,
483
- end: /\/[gimuy]*/,
484
- contains: [
485
- BACKSLASH_ESCAPE,
486
- {
487
- begin: /\[/,
488
- end: /\]/,
367
+ return inherit$1({
368
+ scope: "meta",
369
+ begin: beginShebang,
370
+ end: /$/,
489
371
  relevance: 0,
490
- contains: [BACKSLASH_ESCAPE]
491
- }
492
- ]
493
- };
494
- const TITLE_MODE = {
495
- scope: "title",
496
- begin: IDENT_RE,
497
- relevance: 0
498
- };
499
- const UNDERSCORE_TITLE_MODE = {
500
- scope: "title",
501
- begin: UNDERSCORE_IDENT_RE,
502
- relevance: 0
503
- };
504
- const METHOD_GUARD = {
505
- // excludes method names from keyword processing
506
- begin: "\\.\\s*" + UNDERSCORE_IDENT_RE,
507
- relevance: 0
508
- };
509
- const END_SAME_AS_BEGIN = function(mode) {
510
- return Object.assign(
511
- mode,
512
- {
513
372
  /** @type {ModeCallback} */
514
373
  "on:begin": (m, resp) => {
515
- resp.data._beginMatch = m[1];
374
+ if (m.index !== 0) resp.ignoreMatch();
375
+ }
376
+ }, opts);
377
+ };
378
+ const BACKSLASH_ESCAPE = {
379
+ begin: "\\\\[\\s\\S]",
380
+ relevance: 0
381
+ };
382
+ const APOS_STRING_MODE = {
383
+ scope: "string",
384
+ begin: "'",
385
+ end: "'",
386
+ illegal: "\\n",
387
+ contains: [BACKSLASH_ESCAPE]
388
+ };
389
+ const QUOTE_STRING_MODE = {
390
+ scope: "string",
391
+ begin: '"',
392
+ end: '"',
393
+ illegal: "\\n",
394
+ contains: [BACKSLASH_ESCAPE]
395
+ };
396
+ const PHRASAL_WORDS_MODE = {
397
+ 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/
398
+ };
399
+ const COMMENT = function(begin, end, modeOptions = {}) {
400
+ const mode = inherit$1(
401
+ {
402
+ scope: "comment",
403
+ begin,
404
+ end,
405
+ contains: []
516
406
  },
517
- /** @type {ModeCallback} */
518
- "on:end": (m, resp) => {
519
- if (resp.data._beginMatch !== m[1]) resp.ignoreMatch();
407
+ modeOptions
408
+ );
409
+ mode.contains.push({
410
+ scope: "doctag",
411
+ // hack to avoid the space from being included. the space is necessary to
412
+ // match here to prevent the plain text rule below from gobbling up doctags
413
+ begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
414
+ end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,
415
+ excludeBegin: true,
416
+ relevance: 0
417
+ });
418
+ const ENGLISH_WORD = either(
419
+ // list of common 1 and 2 letter words in English
420
+ "I",
421
+ "a",
422
+ "is",
423
+ "so",
424
+ "us",
425
+ "to",
426
+ "at",
427
+ "if",
428
+ "in",
429
+ "it",
430
+ "on",
431
+ // note: this is not an exhaustive list of contractions, just popular ones
432
+ /[A-Za-z]+['](d|ve|re|ll|t|s|n)/,
433
+ // contractions - can't we'd they're let's, etc
434
+ /[A-Za-z]+[-][a-z]+/,
435
+ // `no-way`, etc.
436
+ /[A-Za-z][a-z]{2,}/
437
+ // allow capitalized words at beginning of sentences
438
+ );
439
+ mode.contains.push(
440
+ {
441
+ // TODO: how to include ", (, ) without breaking grammars that use these for
442
+ // comment delimiters?
443
+ // begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/
444
+ // ---
445
+ // this tries to find sequences of 3 english words in a row (without any
446
+ // "programming" type syntax) this gives us a strong signal that we've
447
+ // TRULY found a comment - vs perhaps scanning with the wrong language.
448
+ // It's possible to find something that LOOKS like the start of the
449
+ // comment - but then if there is no readable text - good chance it is a
450
+ // false match and not a comment.
451
+ //
452
+ // for a visual example please see:
453
+ // https://github.com/highlightjs/highlight.js/issues/2827
454
+ begin: concat(
455
+ /[ ]+/,
456
+ // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */
457
+ "(",
458
+ ENGLISH_WORD,
459
+ /[.]?[:]?([.][ ]|[ ])/,
460
+ "){3}"
461
+ )
462
+ // look for 3 words in a row
520
463
  }
521
- }
522
- );
523
- };
524
- var MODES = /* @__PURE__ */ Object.freeze({
525
- __proto__: null,
526
- APOS_STRING_MODE,
527
- BACKSLASH_ESCAPE,
528
- BINARY_NUMBER_MODE,
529
- BINARY_NUMBER_RE,
530
- COMMENT,
531
- C_BLOCK_COMMENT_MODE,
532
- C_LINE_COMMENT_MODE,
533
- C_NUMBER_MODE,
534
- C_NUMBER_RE,
535
- END_SAME_AS_BEGIN,
536
- HASH_COMMENT_MODE,
537
- IDENT_RE,
538
- MATCH_NOTHING_RE,
539
- METHOD_GUARD,
540
- NUMBER_MODE,
541
- NUMBER_RE,
542
- PHRASAL_WORDS_MODE,
543
- QUOTE_STRING_MODE,
544
- REGEXP_MODE,
545
- RE_STARTERS_RE,
546
- SHEBANG,
547
- TITLE_MODE,
548
- UNDERSCORE_IDENT_RE,
549
- UNDERSCORE_TITLE_MODE
550
- });
551
- function skipIfHasPrecedingDot(match, response) {
552
- const before = match.input[match.index - 1];
553
- if (before === ".") {
554
- response.ignoreMatch();
555
- }
556
- }
557
- function scopeClassName(mode, _parent) {
558
- if (mode.className !== void 0) {
559
- mode.scope = mode.className;
560
- delete mode.className;
561
- }
562
- }
563
- function beginKeywords(mode, parent) {
564
- if (!parent) return;
565
- if (!mode.beginKeywords) return;
566
- mode.begin = "\\b(" + mode.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)";
567
- mode.__beforeBegin = skipIfHasPrecedingDot;
568
- mode.keywords = mode.keywords || mode.beginKeywords;
569
- delete mode.beginKeywords;
570
- if (mode.relevance === void 0) mode.relevance = 0;
571
- }
572
- function compileIllegal(mode, _parent) {
573
- if (!Array.isArray(mode.illegal)) return;
574
- mode.illegal = either(...mode.illegal);
575
- }
576
- function compileMatch(mode, _parent) {
577
- if (!mode.match) return;
578
- if (mode.begin || mode.end) throw new Error("begin & end are not supported with match");
579
- mode.begin = mode.match;
580
- delete mode.match;
581
- }
582
- function compileRelevance(mode, _parent) {
583
- if (mode.relevance === void 0) mode.relevance = 1;
584
- }
585
- const beforeMatchExt = (mode, parent) => {
586
- if (!mode.beforeMatch) return;
587
- if (mode.starts) throw new Error("beforeMatch cannot be used with starts");
588
- const originalMode = Object.assign({}, mode);
589
- Object.keys(mode).forEach((key) => {
590
- delete mode[key];
591
- });
592
- mode.keywords = originalMode.keywords;
593
- mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin));
594
- mode.starts = {
595
- relevance: 0,
464
+ );
465
+ return mode;
466
+ };
467
+ const C_LINE_COMMENT_MODE = COMMENT("//", "$");
468
+ const C_BLOCK_COMMENT_MODE = COMMENT("/\\*", "\\*/");
469
+ const HASH_COMMENT_MODE = COMMENT("#", "$");
470
+ const NUMBER_MODE = {
471
+ scope: "number",
472
+ begin: NUMBER_RE,
473
+ relevance: 0
474
+ };
475
+ const C_NUMBER_MODE = {
476
+ scope: "number",
477
+ begin: C_NUMBER_RE,
478
+ relevance: 0
479
+ };
480
+ const BINARY_NUMBER_MODE = {
481
+ scope: "number",
482
+ begin: BINARY_NUMBER_RE,
483
+ relevance: 0
484
+ };
485
+ const REGEXP_MODE = {
486
+ scope: "regexp",
487
+ begin: /\/(?=[^/\n]*\/)/,
488
+ end: /\/[gimuy]*/,
596
489
  contains: [
597
- Object.assign(originalMode, { endsParent: true })
490
+ BACKSLASH_ESCAPE,
491
+ {
492
+ begin: /\[/,
493
+ end: /\]/,
494
+ relevance: 0,
495
+ contains: [BACKSLASH_ESCAPE]
496
+ }
598
497
  ]
599
498
  };
600
- mode.relevance = 0;
601
- delete originalMode.beforeMatch;
602
- };
603
- const COMMON_KEYWORDS = [
604
- "of",
605
- "and",
606
- "for",
607
- "in",
608
- "not",
609
- "or",
610
- "if",
611
- "then",
612
- "parent",
613
- // common variable name
614
- "list",
615
- // common variable name
616
- "value"
617
- // common variable name
618
- ];
619
- const DEFAULT_KEYWORD_SCOPE = "keyword";
620
- function compileKeywords(rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) {
621
- const compiledKeywords = /* @__PURE__ */ Object.create(null);
622
- if (typeof rawKeywords === "string") {
623
- compileList(scopeName, rawKeywords.split(" "));
624
- } else if (Array.isArray(rawKeywords)) {
625
- compileList(scopeName, rawKeywords);
626
- } else {
627
- Object.keys(rawKeywords).forEach(function(scopeName2) {
628
- Object.assign(
629
- compiledKeywords,
630
- compileKeywords(rawKeywords[scopeName2], caseInsensitive, scopeName2)
631
- );
632
- });
633
- }
634
- return compiledKeywords;
635
- function compileList(scopeName2, keywordList) {
636
- if (caseInsensitive) {
637
- keywordList = keywordList.map((x) => x.toLowerCase());
638
- }
639
- keywordList.forEach(function(keyword) {
640
- const pair = keyword.split("|");
641
- compiledKeywords[pair[0]] = [scopeName2, scoreForKeyword(pair[0], pair[1])];
499
+ const TITLE_MODE = {
500
+ scope: "title",
501
+ begin: IDENT_RE,
502
+ relevance: 0
503
+ };
504
+ const UNDERSCORE_TITLE_MODE = {
505
+ scope: "title",
506
+ begin: UNDERSCORE_IDENT_RE,
507
+ relevance: 0
508
+ };
509
+ const METHOD_GUARD = {
510
+ // excludes method names from keyword processing
511
+ begin: "\\.\\s*" + UNDERSCORE_IDENT_RE,
512
+ relevance: 0
513
+ };
514
+ const END_SAME_AS_BEGIN = function(mode) {
515
+ return Object.assign(
516
+ mode,
517
+ {
518
+ /** @type {ModeCallback} */
519
+ "on:begin": (m, resp) => {
520
+ resp.data._beginMatch = m[1];
521
+ },
522
+ /** @type {ModeCallback} */
523
+ "on:end": (m, resp) => {
524
+ if (resp.data._beginMatch !== m[1]) resp.ignoreMatch();
525
+ }
526
+ }
527
+ );
528
+ };
529
+ var MODES = /* @__PURE__ */ Object.freeze({
530
+ __proto__: null,
531
+ APOS_STRING_MODE,
532
+ BACKSLASH_ESCAPE,
533
+ BINARY_NUMBER_MODE,
534
+ BINARY_NUMBER_RE,
535
+ COMMENT,
536
+ C_BLOCK_COMMENT_MODE,
537
+ C_LINE_COMMENT_MODE,
538
+ C_NUMBER_MODE,
539
+ C_NUMBER_RE,
540
+ END_SAME_AS_BEGIN,
541
+ HASH_COMMENT_MODE,
542
+ IDENT_RE,
543
+ MATCH_NOTHING_RE,
544
+ METHOD_GUARD,
545
+ NUMBER_MODE,
546
+ NUMBER_RE,
547
+ PHRASAL_WORDS_MODE,
548
+ QUOTE_STRING_MODE,
549
+ REGEXP_MODE,
550
+ RE_STARTERS_RE,
551
+ SHEBANG,
552
+ TITLE_MODE,
553
+ UNDERSCORE_IDENT_RE,
554
+ UNDERSCORE_TITLE_MODE
555
+ });
556
+ function skipIfHasPrecedingDot(match, response) {
557
+ const before = match.input[match.index - 1];
558
+ if (before === ".") {
559
+ response.ignoreMatch();
560
+ }
561
+ }
562
+ function scopeClassName(mode, _parent) {
563
+ if (mode.className !== void 0) {
564
+ mode.scope = mode.className;
565
+ delete mode.className;
566
+ }
567
+ }
568
+ function beginKeywords(mode, parent) {
569
+ if (!parent) return;
570
+ if (!mode.beginKeywords) return;
571
+ mode.begin = "\\b(" + mode.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)";
572
+ mode.__beforeBegin = skipIfHasPrecedingDot;
573
+ mode.keywords = mode.keywords || mode.beginKeywords;
574
+ delete mode.beginKeywords;
575
+ if (mode.relevance === void 0) mode.relevance = 0;
576
+ }
577
+ function compileIllegal(mode, _parent) {
578
+ if (!Array.isArray(mode.illegal)) return;
579
+ mode.illegal = either(...mode.illegal);
580
+ }
581
+ function compileMatch(mode, _parent) {
582
+ if (!mode.match) return;
583
+ if (mode.begin || mode.end) throw new Error("begin & end are not supported with match");
584
+ mode.begin = mode.match;
585
+ delete mode.match;
586
+ }
587
+ function compileRelevance(mode, _parent) {
588
+ if (mode.relevance === void 0) mode.relevance = 1;
589
+ }
590
+ const beforeMatchExt = (mode, parent) => {
591
+ if (!mode.beforeMatch) return;
592
+ if (mode.starts) throw new Error("beforeMatch cannot be used with starts");
593
+ const originalMode = Object.assign({}, mode);
594
+ Object.keys(mode).forEach((key) => {
595
+ delete mode[key];
642
596
  });
597
+ mode.keywords = originalMode.keywords;
598
+ mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin));
599
+ mode.starts = {
600
+ relevance: 0,
601
+ contains: [
602
+ Object.assign(originalMode, { endsParent: true })
603
+ ]
604
+ };
605
+ mode.relevance = 0;
606
+ delete originalMode.beforeMatch;
607
+ };
608
+ const COMMON_KEYWORDS = [
609
+ "of",
610
+ "and",
611
+ "for",
612
+ "in",
613
+ "not",
614
+ "or",
615
+ "if",
616
+ "then",
617
+ "parent",
618
+ // common variable name
619
+ "list",
620
+ // common variable name
621
+ "value"
622
+ // common variable name
623
+ ];
624
+ const DEFAULT_KEYWORD_SCOPE = "keyword";
625
+ function compileKeywords(rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) {
626
+ const compiledKeywords = /* @__PURE__ */ Object.create(null);
627
+ if (typeof rawKeywords === "string") {
628
+ compileList(scopeName, rawKeywords.split(" "));
629
+ } else if (Array.isArray(rawKeywords)) {
630
+ compileList(scopeName, rawKeywords);
631
+ } else {
632
+ Object.keys(rawKeywords).forEach(function(scopeName2) {
633
+ Object.assign(
634
+ compiledKeywords,
635
+ compileKeywords(rawKeywords[scopeName2], caseInsensitive, scopeName2)
636
+ );
637
+ });
638
+ }
639
+ return compiledKeywords;
640
+ function compileList(scopeName2, keywordList) {
641
+ if (caseInsensitive) {
642
+ keywordList = keywordList.map((x) => x.toLowerCase());
643
+ }
644
+ keywordList.forEach(function(keyword) {
645
+ const pair = keyword.split("|");
646
+ compiledKeywords[pair[0]] = [scopeName2, scoreForKeyword(pair[0], pair[1])];
647
+ });
648
+ }
643
649
  }
644
- }
645
- function scoreForKeyword(keyword, providedScore) {
646
- if (providedScore) {
647
- return Number(providedScore);
648
- }
649
- return commonKeyword(keyword) ? 0 : 1;
650
- }
651
- function commonKeyword(keyword) {
652
- return COMMON_KEYWORDS.includes(keyword.toLowerCase());
653
- }
654
- const seenDeprecations = {};
655
- const error$1 = (message) => {
656
- console.error(message);
657
- };
658
- const warn = (message, ...args) => {
659
- console.log(`WARN: ${message}`, ...args);
660
- };
661
- const deprecated = (version2, message) => {
662
- if (seenDeprecations[`${version2}/${message}`]) return;
663
- console.log(`Deprecated as of ${version2}. ${message}`);
664
- seenDeprecations[`${version2}/${message}`] = true;
665
- };
666
- const MultiClassError = new Error();
667
- function remapScopeNames(mode, regexes, { key }) {
668
- let offset = 0;
669
- const scopeNames = mode[key];
670
- const emit = {};
671
- const positions = {};
672
- for (let i = 1; i <= regexes.length; i++) {
673
- positions[i + offset] = scopeNames[i];
674
- emit[i + offset] = true;
675
- offset += countMatchGroups(regexes[i - 1]);
676
- }
677
- mode[key] = positions;
678
- mode[key]._emit = emit;
679
- mode[key]._multi = true;
680
- }
681
- function beginMultiClass(mode) {
682
- if (!Array.isArray(mode.begin)) return;
683
- if (mode.skip || mode.excludeBegin || mode.returnBegin) {
684
- error$1("skip, excludeBegin, returnBegin not compatible with beginScope: {}");
685
- throw MultiClassError;
686
- }
687
- if (typeof mode.beginScope !== "object" || mode.beginScope === null) {
688
- error$1("beginScope must be object");
689
- throw MultiClassError;
690
- }
691
- remapScopeNames(mode, mode.begin, { key: "beginScope" });
692
- mode.begin = _rewriteBackreferences(mode.begin, { joinWith: "" });
693
- }
694
- function endMultiClass(mode) {
695
- if (!Array.isArray(mode.end)) return;
696
- if (mode.skip || mode.excludeEnd || mode.returnEnd) {
697
- error$1("skip, excludeEnd, returnEnd not compatible with endScope: {}");
698
- throw MultiClassError;
699
- }
700
- if (typeof mode.endScope !== "object" || mode.endScope === null) {
701
- error$1("endScope must be object");
702
- throw MultiClassError;
703
- }
704
- remapScopeNames(mode, mode.end, { key: "endScope" });
705
- mode.end = _rewriteBackreferences(mode.end, { joinWith: "" });
706
- }
707
- function scopeSugar(mode) {
708
- if (mode.scope && typeof mode.scope === "object" && mode.scope !== null) {
709
- mode.beginScope = mode.scope;
710
- delete mode.scope;
711
- }
712
- }
713
- function MultiClass(mode) {
714
- scopeSugar(mode);
715
- if (typeof mode.beginScope === "string") {
716
- mode.beginScope = { _wrap: mode.beginScope };
717
- }
718
- if (typeof mode.endScope === "string") {
719
- mode.endScope = { _wrap: mode.endScope };
650
+ function scoreForKeyword(keyword, providedScore) {
651
+ if (providedScore) {
652
+ return Number(providedScore);
653
+ }
654
+ return commonKeyword(keyword) ? 0 : 1;
720
655
  }
721
- beginMultiClass(mode);
722
- endMultiClass(mode);
723
- }
724
- function compileLanguage(language) {
725
- function langRe(value, global) {
726
- return new RegExp(
727
- source(value),
728
- "m" + (language.case_insensitive ? "i" : "") + (language.unicodeRegex ? "u" : "") + (global ? "g" : "")
729
- );
656
+ function commonKeyword(keyword) {
657
+ return COMMON_KEYWORDS.includes(keyword.toLowerCase());
730
658
  }
731
- class MultiRegex {
732
- constructor() {
733
- this.matchIndexes = {};
734
- this.regexes = [];
735
- this.matchAt = 1;
736
- this.position = 0;
737
- }
738
- // @ts-ignore
739
- addRule(re, opts) {
740
- opts.position = this.position++;
741
- this.matchIndexes[this.matchAt] = opts;
742
- this.regexes.push([opts, re]);
743
- this.matchAt += countMatchGroups(re) + 1;
744
- }
745
- compile() {
746
- if (this.regexes.length === 0) {
747
- this.exec = () => null;
748
- }
749
- const terminators = this.regexes.map((el) => el[1]);
750
- this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: "|" }), true);
751
- this.lastIndex = 0;
752
- }
753
- /** @param {string} s */
754
- exec(s) {
755
- this.matcherRe.lastIndex = this.lastIndex;
756
- const match = this.matcherRe.exec(s);
757
- if (!match) {
758
- return null;
759
- }
760
- const i = match.findIndex((el, i2) => i2 > 0 && el !== void 0);
761
- const matchData = this.matchIndexes[i];
762
- match.splice(0, i);
763
- return Object.assign(match, matchData);
659
+ const seenDeprecations = {};
660
+ const error2 = (message) => {
661
+ console.error(message);
662
+ };
663
+ const warn = (message, ...args) => {
664
+ console.log(`WARN: ${message}`, ...args);
665
+ };
666
+ const deprecated = (version2, message) => {
667
+ if (seenDeprecations[`${version2}/${message}`]) return;
668
+ console.log(`Deprecated as of ${version2}. ${message}`);
669
+ seenDeprecations[`${version2}/${message}`] = true;
670
+ };
671
+ const MultiClassError = new Error();
672
+ function remapScopeNames(mode, regexes, { key }) {
673
+ let offset = 0;
674
+ const scopeNames = mode[key];
675
+ const emit = {};
676
+ const positions = {};
677
+ for (let i = 1; i <= regexes.length; i++) {
678
+ positions[i + offset] = scopeNames[i];
679
+ emit[i + offset] = true;
680
+ offset += countMatchGroups(regexes[i - 1]);
681
+ }
682
+ mode[key] = positions;
683
+ mode[key]._emit = emit;
684
+ mode[key]._multi = true;
685
+ }
686
+ function beginMultiClass(mode) {
687
+ if (!Array.isArray(mode.begin)) return;
688
+ if (mode.skip || mode.excludeBegin || mode.returnBegin) {
689
+ error2("skip, excludeBegin, returnBegin not compatible with beginScope: {}");
690
+ throw MultiClassError;
691
+ }
692
+ if (typeof mode.beginScope !== "object" || mode.beginScope === null) {
693
+ error2("beginScope must be object");
694
+ throw MultiClassError;
695
+ }
696
+ remapScopeNames(mode, mode.begin, { key: "beginScope" });
697
+ mode.begin = _rewriteBackreferences(mode.begin, { joinWith: "" });
698
+ }
699
+ function endMultiClass(mode) {
700
+ if (!Array.isArray(mode.end)) return;
701
+ if (mode.skip || mode.excludeEnd || mode.returnEnd) {
702
+ error2("skip, excludeEnd, returnEnd not compatible with endScope: {}");
703
+ throw MultiClassError;
704
+ }
705
+ if (typeof mode.endScope !== "object" || mode.endScope === null) {
706
+ error2("endScope must be object");
707
+ throw MultiClassError;
708
+ }
709
+ remapScopeNames(mode, mode.end, { key: "endScope" });
710
+ mode.end = _rewriteBackreferences(mode.end, { joinWith: "" });
711
+ }
712
+ function scopeSugar(mode) {
713
+ if (mode.scope && typeof mode.scope === "object" && mode.scope !== null) {
714
+ mode.beginScope = mode.scope;
715
+ delete mode.scope;
716
+ }
717
+ }
718
+ function MultiClass(mode) {
719
+ scopeSugar(mode);
720
+ if (typeof mode.beginScope === "string") {
721
+ mode.beginScope = { _wrap: mode.beginScope };
722
+ }
723
+ if (typeof mode.endScope === "string") {
724
+ mode.endScope = { _wrap: mode.endScope };
725
+ }
726
+ beginMultiClass(mode);
727
+ endMultiClass(mode);
728
+ }
729
+ function compileLanguage(language) {
730
+ function langRe(value, global) {
731
+ return new RegExp(
732
+ source(value),
733
+ "m" + (language.case_insensitive ? "i" : "") + (language.unicodeRegex ? "u" : "") + (global ? "g" : "")
734
+ );
764
735
  }
765
- }
766
- class ResumableMultiRegex {
767
- constructor() {
768
- this.rules = [];
769
- this.multiRegexes = [];
770
- this.count = 0;
771
- this.lastIndex = 0;
772
- this.regexIndex = 0;
773
- }
774
- // @ts-ignore
775
- getMatcher(index) {
776
- if (this.multiRegexes[index]) return this.multiRegexes[index];
777
- const matcher = new MultiRegex();
778
- this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
779
- matcher.compile();
780
- this.multiRegexes[index] = matcher;
781
- return matcher;
782
- }
783
- resumingScanAtSamePosition() {
784
- return this.regexIndex !== 0;
785
- }
786
- considerAll() {
787
- this.regexIndex = 0;
788
- }
789
- // @ts-ignore
790
- addRule(re, opts) {
791
- this.rules.push([re, opts]);
792
- if (opts.type === "begin") this.count++;
793
- }
794
- /** @param {string} s */
795
- exec(s) {
796
- const m = this.getMatcher(this.regexIndex);
797
- m.lastIndex = this.lastIndex;
798
- let result = m.exec(s);
799
- if (this.resumingScanAtSamePosition()) {
800
- if (result && result.index === this.lastIndex) ;
801
- else {
802
- const m2 = this.getMatcher(0);
803
- m2.lastIndex = this.lastIndex + 1;
804
- result = m2.exec(s);
736
+ class MultiRegex {
737
+ constructor() {
738
+ this.matchIndexes = {};
739
+ this.regexes = [];
740
+ this.matchAt = 1;
741
+ this.position = 0;
742
+ }
743
+ // @ts-ignore
744
+ addRule(re, opts) {
745
+ opts.position = this.position++;
746
+ this.matchIndexes[this.matchAt] = opts;
747
+ this.regexes.push([opts, re]);
748
+ this.matchAt += countMatchGroups(re) + 1;
749
+ }
750
+ compile() {
751
+ if (this.regexes.length === 0) {
752
+ this.exec = () => null;
805
753
  }
806
- }
807
- if (result) {
808
- this.regexIndex += result.position + 1;
809
- if (this.regexIndex === this.count) {
810
- this.considerAll();
754
+ const terminators = this.regexes.map((el) => el[1]);
755
+ this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: "|" }), true);
756
+ this.lastIndex = 0;
757
+ }
758
+ /** @param {string} s */
759
+ exec(s) {
760
+ this.matcherRe.lastIndex = this.lastIndex;
761
+ const match = this.matcherRe.exec(s);
762
+ if (!match) {
763
+ return null;
764
+ }
765
+ const i = match.findIndex((el, i2) => i2 > 0 && el !== void 0);
766
+ const matchData = this.matchIndexes[i];
767
+ match.splice(0, i);
768
+ return Object.assign(match, matchData);
769
+ }
770
+ }
771
+ class ResumableMultiRegex {
772
+ constructor() {
773
+ this.rules = [];
774
+ this.multiRegexes = [];
775
+ this.count = 0;
776
+ this.lastIndex = 0;
777
+ this.regexIndex = 0;
778
+ }
779
+ // @ts-ignore
780
+ getMatcher(index) {
781
+ if (this.multiRegexes[index]) return this.multiRegexes[index];
782
+ const matcher = new MultiRegex();
783
+ this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
784
+ matcher.compile();
785
+ this.multiRegexes[index] = matcher;
786
+ return matcher;
787
+ }
788
+ resumingScanAtSamePosition() {
789
+ return this.regexIndex !== 0;
790
+ }
791
+ considerAll() {
792
+ this.regexIndex = 0;
793
+ }
794
+ // @ts-ignore
795
+ addRule(re, opts) {
796
+ this.rules.push([re, opts]);
797
+ if (opts.type === "begin") this.count++;
798
+ }
799
+ /** @param {string} s */
800
+ exec(s) {
801
+ const m = this.getMatcher(this.regexIndex);
802
+ m.lastIndex = this.lastIndex;
803
+ let result = m.exec(s);
804
+ if (this.resumingScanAtSamePosition()) {
805
+ if (result && result.index === this.lastIndex) ;
806
+ else {
807
+ const m2 = this.getMatcher(0);
808
+ m2.lastIndex = this.lastIndex + 1;
809
+ result = m2.exec(s);
810
+ }
811
811
  }
812
+ if (result) {
813
+ this.regexIndex += result.position + 1;
814
+ if (this.regexIndex === this.count) {
815
+ this.considerAll();
816
+ }
817
+ }
818
+ return result;
812
819
  }
813
- return result;
814
820
  }
815
- }
816
- function buildModeRegex(mode) {
817
- const mm = new ResumableMultiRegex();
818
- mode.contains.forEach((term) => mm.addRule(term.begin, { rule: term, type: "begin" }));
819
- if (mode.terminatorEnd) {
820
- mm.addRule(mode.terminatorEnd, { type: "end" });
821
- }
822
- if (mode.illegal) {
823
- mm.addRule(mode.illegal, { type: "illegal" });
821
+ function buildModeRegex(mode) {
822
+ const mm = new ResumableMultiRegex();
823
+ mode.contains.forEach((term) => mm.addRule(term.begin, { rule: term, type: "begin" }));
824
+ if (mode.terminatorEnd) {
825
+ mm.addRule(mode.terminatorEnd, { type: "end" });
826
+ }
827
+ if (mode.illegal) {
828
+ mm.addRule(mode.illegal, { type: "illegal" });
829
+ }
830
+ return mm;
824
831
  }
825
- return mm;
826
- }
827
- function compileMode(mode, parent) {
828
- const cmode = (
829
- /** @type CompiledMode */
830
- mode
831
- );
832
- if (mode.isCompiled) return cmode;
833
- [
834
- scopeClassName,
835
- // do this early so compiler extensions generally don't have to worry about
836
- // the distinction between match/begin
837
- compileMatch,
838
- MultiClass,
839
- beforeMatchExt
840
- ].forEach((ext) => ext(mode, parent));
841
- language.compilerExtensions.forEach((ext) => ext(mode, parent));
842
- mode.__beforeBegin = null;
843
- [
844
- beginKeywords,
845
- // do this later so compiler extensions that come earlier have access to the
846
- // raw array if they wanted to perhaps manipulate it, etc.
847
- compileIllegal,
848
- // default to 1 relevance if not specified
849
- compileRelevance
850
- ].forEach((ext) => ext(mode, parent));
851
- mode.isCompiled = true;
852
- let keywordPattern = null;
853
- if (typeof mode.keywords === "object" && mode.keywords.$pattern) {
854
- mode.keywords = Object.assign({}, mode.keywords);
855
- keywordPattern = mode.keywords.$pattern;
856
- delete mode.keywords.$pattern;
857
- }
858
- keywordPattern = keywordPattern || /\w+/;
859
- if (mode.keywords) {
860
- mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
861
- }
862
- cmode.keywordPatternRe = langRe(keywordPattern, true);
863
- if (parent) {
864
- if (!mode.begin) mode.begin = /\B|\b/;
865
- cmode.beginRe = langRe(cmode.begin);
866
- if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/;
867
- if (mode.end) cmode.endRe = langRe(cmode.end);
868
- cmode.terminatorEnd = source(cmode.end) || "";
869
- if (mode.endsWithParent && parent.terminatorEnd) {
870
- cmode.terminatorEnd += (mode.end ? "|" : "") + parent.terminatorEnd;
871
- }
872
- }
873
- if (mode.illegal) cmode.illegalRe = langRe(
874
- /** @type {RegExp | string} */
875
- mode.illegal
876
- );
877
- if (!mode.contains) mode.contains = [];
878
- mode.contains = [].concat(...mode.contains.map(function(c) {
879
- return expandOrCloneMode(c === "self" ? mode : c);
880
- }));
881
- mode.contains.forEach(function(c) {
882
- compileMode(
883
- /** @type Mode */
884
- c,
885
- cmode
832
+ function compileMode(mode, parent) {
833
+ const cmode = (
834
+ /** @type CompiledMode */
835
+ mode
886
836
  );
887
- });
888
- if (mode.starts) {
889
- compileMode(mode.starts, parent);
890
- }
891
- cmode.matcher = buildModeRegex(cmode);
892
- return cmode;
893
- }
894
- if (!language.compilerExtensions) language.compilerExtensions = [];
895
- if (language.contains && language.contains.includes("self")) {
896
- throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
897
- }
898
- language.classNameAliases = inherit$1(language.classNameAliases || {});
899
- return compileMode(
900
- /** @type Mode */
901
- language
902
- );
903
- }
904
- function dependencyOnParent(mode) {
905
- if (!mode) return false;
906
- return mode.endsWithParent || dependencyOnParent(mode.starts);
907
- }
908
- function expandOrCloneMode(mode) {
909
- if (mode.variants && !mode.cachedVariants) {
910
- mode.cachedVariants = mode.variants.map(function(variant) {
911
- return inherit$1(mode, { variants: null }, variant);
912
- });
913
- }
914
- if (mode.cachedVariants) {
915
- return mode.cachedVariants;
916
- }
917
- if (dependencyOnParent(mode)) {
918
- return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null });
919
- }
920
- if (Object.isFrozen(mode)) {
921
- return inherit$1(mode);
922
- }
923
- return mode;
924
- }
925
- var version = "11.9.0";
926
- class HTMLInjectionError extends Error {
927
- constructor(reason, html) {
928
- super(reason);
929
- this.name = "HTMLInjectionError";
930
- this.html = html;
931
- }
932
- }
933
- const escape = escapeHTML;
934
- const inherit = inherit$1;
935
- const NO_MATCH = Symbol("nomatch");
936
- const MAX_KEYWORD_HITS = 7;
937
- const HLJS = function(hljs) {
938
- const languages = /* @__PURE__ */ Object.create(null);
939
- const aliases = /* @__PURE__ */ Object.create(null);
940
- const plugins = [];
941
- let SAFE_MODE = true;
942
- const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
943
- const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: "Plain text", contains: [] };
944
- let options = {
945
- ignoreUnescapedHTML: false,
946
- throwUnescapedHTML: false,
947
- noHighlightRe: /^(no-?highlight)$/i,
948
- languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
949
- classPrefix: "hljs-",
950
- cssSelector: "pre code",
951
- languages: null,
952
- // beta configuration options, subject to change, welcome to discuss
953
- // https://github.com/highlightjs/highlight.js/issues/1086
954
- __emitter: TokenTreeEmitter
955
- };
956
- function shouldNotHighlight(languageName) {
957
- return options.noHighlightRe.test(languageName);
958
- }
959
- function blockLanguage(block2) {
960
- let classes = block2.className + " ";
961
- classes += block2.parentNode ? block2.parentNode.className : "";
962
- const match = options.languageDetectRe.exec(classes);
963
- if (match) {
964
- const language = getLanguage(match[1]);
965
- if (!language) {
966
- warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
967
- warn("Falling back to no-highlight mode for this block.", block2);
837
+ if (mode.isCompiled) return cmode;
838
+ [
839
+ scopeClassName,
840
+ // do this early so compiler extensions generally don't have to worry about
841
+ // the distinction between match/begin
842
+ compileMatch,
843
+ MultiClass,
844
+ beforeMatchExt
845
+ ].forEach((ext) => ext(mode, parent));
846
+ language.compilerExtensions.forEach((ext) => ext(mode, parent));
847
+ mode.__beforeBegin = null;
848
+ [
849
+ beginKeywords,
850
+ // do this later so compiler extensions that come earlier have access to the
851
+ // raw array if they wanted to perhaps manipulate it, etc.
852
+ compileIllegal,
853
+ // default to 1 relevance if not specified
854
+ compileRelevance
855
+ ].forEach((ext) => ext(mode, parent));
856
+ mode.isCompiled = true;
857
+ let keywordPattern = null;
858
+ if (typeof mode.keywords === "object" && mode.keywords.$pattern) {
859
+ mode.keywords = Object.assign({}, mode.keywords);
860
+ keywordPattern = mode.keywords.$pattern;
861
+ delete mode.keywords.$pattern;
862
+ }
863
+ keywordPattern = keywordPattern || /\w+/;
864
+ if (mode.keywords) {
865
+ mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
866
+ }
867
+ cmode.keywordPatternRe = langRe(keywordPattern, true);
868
+ if (parent) {
869
+ if (!mode.begin) mode.begin = /\B|\b/;
870
+ cmode.beginRe = langRe(cmode.begin);
871
+ if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/;
872
+ if (mode.end) cmode.endRe = langRe(cmode.end);
873
+ cmode.terminatorEnd = source(cmode.end) || "";
874
+ if (mode.endsWithParent && parent.terminatorEnd) {
875
+ cmode.terminatorEnd += (mode.end ? "|" : "") + parent.terminatorEnd;
876
+ }
968
877
  }
969
- return language ? match[1] : "no-highlight";
878
+ if (mode.illegal) cmode.illegalRe = langRe(
879
+ /** @type {RegExp | string} */
880
+ mode.illegal
881
+ );
882
+ if (!mode.contains) mode.contains = [];
883
+ mode.contains = [].concat(...mode.contains.map(function(c) {
884
+ return expandOrCloneMode(c === "self" ? mode : c);
885
+ }));
886
+ mode.contains.forEach(function(c) {
887
+ compileMode(
888
+ /** @type Mode */
889
+ c,
890
+ cmode
891
+ );
892
+ });
893
+ if (mode.starts) {
894
+ compileMode(mode.starts, parent);
895
+ }
896
+ cmode.matcher = buildModeRegex(cmode);
897
+ return cmode;
970
898
  }
971
- return classes.split(/\s+/).find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
972
- }
973
- function highlight2(codeOrLanguageName, optionsOrCode, ignoreIllegals) {
974
- let code = "";
975
- let languageName = "";
976
- if (typeof optionsOrCode === "object") {
977
- code = codeOrLanguageName;
978
- ignoreIllegals = optionsOrCode.ignoreIllegals;
979
- languageName = optionsOrCode.language;
980
- } else {
981
- deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated.");
982
- deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");
983
- languageName = codeOrLanguageName;
984
- code = optionsOrCode;
899
+ if (!language.compilerExtensions) language.compilerExtensions = [];
900
+ if (language.contains && language.contains.includes("self")) {
901
+ throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
985
902
  }
986
- if (ignoreIllegals === void 0) {
987
- ignoreIllegals = true;
903
+ language.classNameAliases = inherit$1(language.classNameAliases || {});
904
+ return compileMode(
905
+ /** @type Mode */
906
+ language
907
+ );
908
+ }
909
+ function dependencyOnParent(mode) {
910
+ if (!mode) return false;
911
+ return mode.endsWithParent || dependencyOnParent(mode.starts);
912
+ }
913
+ function expandOrCloneMode(mode) {
914
+ if (mode.variants && !mode.cachedVariants) {
915
+ mode.cachedVariants = mode.variants.map(function(variant) {
916
+ return inherit$1(mode, { variants: null }, variant);
917
+ });
988
918
  }
989
- const context = {
990
- code,
991
- language: languageName
919
+ if (mode.cachedVariants) {
920
+ return mode.cachedVariants;
921
+ }
922
+ if (dependencyOnParent(mode)) {
923
+ return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null });
924
+ }
925
+ if (Object.isFrozen(mode)) {
926
+ return inherit$1(mode);
927
+ }
928
+ return mode;
929
+ }
930
+ var version = "11.9.0";
931
+ class HTMLInjectionError extends Error {
932
+ constructor(reason, html) {
933
+ super(reason);
934
+ this.name = "HTMLInjectionError";
935
+ this.html = html;
936
+ }
937
+ }
938
+ const escape = escapeHTML;
939
+ const inherit = inherit$1;
940
+ const NO_MATCH = Symbol("nomatch");
941
+ const MAX_KEYWORD_HITS = 7;
942
+ const HLJS = function(hljs) {
943
+ const languages = /* @__PURE__ */ Object.create(null);
944
+ const aliases = /* @__PURE__ */ Object.create(null);
945
+ const plugins = [];
946
+ let SAFE_MODE = true;
947
+ const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
948
+ const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: "Plain text", contains: [] };
949
+ let options = {
950
+ ignoreUnescapedHTML: false,
951
+ throwUnescapedHTML: false,
952
+ noHighlightRe: /^(no-?highlight)$/i,
953
+ languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
954
+ classPrefix: "hljs-",
955
+ cssSelector: "pre code",
956
+ languages: null,
957
+ // beta configuration options, subject to change, welcome to discuss
958
+ // https://github.com/highlightjs/highlight.js/issues/1086
959
+ __emitter: TokenTreeEmitter
992
960
  };
993
- fire("before:highlight", context);
994
- const result = context.result ? context.result : _highlight(context.language, context.code, ignoreIllegals);
995
- result.code = context.code;
996
- fire("after:highlight", result);
997
- return result;
998
- }
999
- function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) {
1000
- const keywordHits = /* @__PURE__ */ Object.create(null);
1001
- function keywordData(mode, matchText) {
1002
- return mode.keywords[matchText];
1003
- }
1004
- function processKeywords() {
1005
- if (!top.keywords) {
1006
- emitter.addText(modeBuffer);
1007
- return;
1008
- }
1009
- let lastIndex = 0;
1010
- top.keywordPatternRe.lastIndex = 0;
1011
- let match = top.keywordPatternRe.exec(modeBuffer);
1012
- let buf = "";
1013
- while (match) {
1014
- buf += modeBuffer.substring(lastIndex, match.index);
1015
- const word = language.case_insensitive ? match[0].toLowerCase() : match[0];
1016
- const data = keywordData(top, word);
1017
- if (data) {
1018
- const [kind, keywordRelevance] = data;
1019
- emitter.addText(buf);
1020
- buf = "";
1021
- keywordHits[word] = (keywordHits[word] || 0) + 1;
1022
- if (keywordHits[word] <= MAX_KEYWORD_HITS) relevance += keywordRelevance;
1023
- if (kind.startsWith("_")) {
1024
- buf += match[0];
1025
- } else {
1026
- const cssClass = language.classNameAliases[kind] || kind;
1027
- emitKeyword(match[0], cssClass);
1028
- }
1029
- } else {
1030
- buf += match[0];
961
+ function shouldNotHighlight(languageName) {
962
+ return options.noHighlightRe.test(languageName);
963
+ }
964
+ function blockLanguage(block2) {
965
+ let classes = block2.className + " ";
966
+ classes += block2.parentNode ? block2.parentNode.className : "";
967
+ const match = options.languageDetectRe.exec(classes);
968
+ if (match) {
969
+ const language = getLanguage(match[1]);
970
+ if (!language) {
971
+ warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
972
+ warn("Falling back to no-highlight mode for this block.", block2);
1031
973
  }
1032
- lastIndex = top.keywordPatternRe.lastIndex;
1033
- match = top.keywordPatternRe.exec(modeBuffer);
974
+ return language ? match[1] : "no-highlight";
1034
975
  }
1035
- buf += modeBuffer.substring(lastIndex);
1036
- emitter.addText(buf);
976
+ return classes.split(/\s+/).find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
1037
977
  }
1038
- function processSubLanguage() {
1039
- if (modeBuffer === "") return;
1040
- let result2 = null;
1041
- if (typeof top.subLanguage === "string") {
1042
- if (!languages[top.subLanguage]) {
1043
- emitter.addText(modeBuffer);
1044
- return;
1045
- }
1046
- result2 = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
1047
- continuations[top.subLanguage] = /** @type {CompiledMode} */
1048
- result2._top;
978
+ function highlight2(codeOrLanguageName, optionsOrCode, ignoreIllegals) {
979
+ let code = "";
980
+ let languageName = "";
981
+ if (typeof optionsOrCode === "object") {
982
+ code = codeOrLanguageName;
983
+ ignoreIllegals = optionsOrCode.ignoreIllegals;
984
+ languageName = optionsOrCode.language;
1049
985
  } else {
1050
- result2 = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
986
+ deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated.");
987
+ deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");
988
+ languageName = codeOrLanguageName;
989
+ code = optionsOrCode;
1051
990
  }
1052
- if (top.relevance > 0) {
1053
- relevance += result2.relevance;
991
+ if (ignoreIllegals === void 0) {
992
+ ignoreIllegals = true;
1054
993
  }
1055
- emitter.__addSublanguage(result2._emitter, result2.language);
994
+ const context = {
995
+ code,
996
+ language: languageName
997
+ };
998
+ fire("before:highlight", context);
999
+ const result = context.result ? context.result : _highlight(context.language, context.code, ignoreIllegals);
1000
+ result.code = context.code;
1001
+ fire("after:highlight", result);
1002
+ return result;
1056
1003
  }
1057
- function processBuffer() {
1058
- if (top.subLanguage != null) {
1059
- processSubLanguage();
1060
- } else {
1061
- processKeywords();
1004
+ function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) {
1005
+ const keywordHits = /* @__PURE__ */ Object.create(null);
1006
+ function keywordData(mode, matchText) {
1007
+ return mode.keywords[matchText];
1062
1008
  }
1063
- modeBuffer = "";
1064
- }
1065
- function emitKeyword(keyword, scope) {
1066
- if (keyword === "") return;
1067
- emitter.startScope(scope);
1068
- emitter.addText(keyword);
1069
- emitter.endScope();
1070
- }
1071
- function emitMultiClass(scope, match) {
1072
- let i = 1;
1073
- const max = match.length - 1;
1074
- while (i <= max) {
1075
- if (!scope._emit[i]) {
1076
- i++;
1077
- continue;
1009
+ function processKeywords() {
1010
+ if (!top.keywords) {
1011
+ emitter.addText(modeBuffer);
1012
+ return;
1078
1013
  }
1079
- const klass = language.classNameAliases[scope[i]] || scope[i];
1080
- const text = match[i];
1081
- if (klass) {
1082
- emitKeyword(text, klass);
1014
+ let lastIndex = 0;
1015
+ top.keywordPatternRe.lastIndex = 0;
1016
+ let match = top.keywordPatternRe.exec(modeBuffer);
1017
+ let buf = "";
1018
+ while (match) {
1019
+ buf += modeBuffer.substring(lastIndex, match.index);
1020
+ const word = language.case_insensitive ? match[0].toLowerCase() : match[0];
1021
+ const data = keywordData(top, word);
1022
+ if (data) {
1023
+ const [kind, keywordRelevance] = data;
1024
+ emitter.addText(buf);
1025
+ buf = "";
1026
+ keywordHits[word] = (keywordHits[word] || 0) + 1;
1027
+ if (keywordHits[word] <= MAX_KEYWORD_HITS) relevance += keywordRelevance;
1028
+ if (kind.startsWith("_")) {
1029
+ buf += match[0];
1030
+ } else {
1031
+ const cssClass = language.classNameAliases[kind] || kind;
1032
+ emitKeyword(match[0], cssClass);
1033
+ }
1034
+ } else {
1035
+ buf += match[0];
1036
+ }
1037
+ lastIndex = top.keywordPatternRe.lastIndex;
1038
+ match = top.keywordPatternRe.exec(modeBuffer);
1039
+ }
1040
+ buf += modeBuffer.substring(lastIndex);
1041
+ emitter.addText(buf);
1042
+ }
1043
+ function processSubLanguage() {
1044
+ if (modeBuffer === "") return;
1045
+ let result2 = null;
1046
+ if (typeof top.subLanguage === "string") {
1047
+ if (!languages[top.subLanguage]) {
1048
+ emitter.addText(modeBuffer);
1049
+ return;
1050
+ }
1051
+ result2 = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
1052
+ continuations[top.subLanguage] = /** @type {CompiledMode} */
1053
+ result2._top;
1083
1054
  } else {
1084
- modeBuffer = text;
1085
- processKeywords();
1086
- modeBuffer = "";
1055
+ result2 = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
1087
1056
  }
1088
- i++;
1089
- }
1090
- }
1091
- function startNewMode(mode, match) {
1092
- if (mode.scope && typeof mode.scope === "string") {
1093
- emitter.openNode(language.classNameAliases[mode.scope] || mode.scope);
1094
- }
1095
- if (mode.beginScope) {
1096
- if (mode.beginScope._wrap) {
1097
- emitKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap);
1098
- modeBuffer = "";
1099
- } else if (mode.beginScope._multi) {
1100
- emitMultiClass(mode.beginScope, match);
1101
- modeBuffer = "";
1057
+ if (top.relevance > 0) {
1058
+ relevance += result2.relevance;
1102
1059
  }
1060
+ emitter.__addSublanguage(result2._emitter, result2.language);
1103
1061
  }
1104
- top = Object.create(mode, { parent: { value: top } });
1105
- return top;
1106
- }
1107
- function endOfMode(mode, match, matchPlusRemainder) {
1108
- let matched = startsWith(mode.endRe, matchPlusRemainder);
1109
- if (matched) {
1110
- if (mode["on:end"]) {
1111
- const resp = new Response(mode);
1112
- mode["on:end"](match, resp);
1113
- if (resp.isMatchIgnored) matched = false;
1062
+ function processBuffer() {
1063
+ if (top.subLanguage != null) {
1064
+ processSubLanguage();
1065
+ } else {
1066
+ processKeywords();
1114
1067
  }
1115
- if (matched) {
1116
- while (mode.endsParent && mode.parent) {
1117
- mode = mode.parent;
1068
+ modeBuffer = "";
1069
+ }
1070
+ function emitKeyword(keyword, scope) {
1071
+ if (keyword === "") return;
1072
+ emitter.startScope(scope);
1073
+ emitter.addText(keyword);
1074
+ emitter.endScope();
1075
+ }
1076
+ function emitMultiClass(scope, match) {
1077
+ let i = 1;
1078
+ const max = match.length - 1;
1079
+ while (i <= max) {
1080
+ if (!scope._emit[i]) {
1081
+ i++;
1082
+ continue;
1118
1083
  }
1119
- return mode;
1084
+ const klass = language.classNameAliases[scope[i]] || scope[i];
1085
+ const text = match[i];
1086
+ if (klass) {
1087
+ emitKeyword(text, klass);
1088
+ } else {
1089
+ modeBuffer = text;
1090
+ processKeywords();
1091
+ modeBuffer = "";
1092
+ }
1093
+ i++;
1120
1094
  }
1121
1095
  }
1122
- if (mode.endsWithParent) {
1123
- return endOfMode(mode.parent, match, matchPlusRemainder);
1096
+ function startNewMode(mode, match) {
1097
+ if (mode.scope && typeof mode.scope === "string") {
1098
+ emitter.openNode(language.classNameAliases[mode.scope] || mode.scope);
1099
+ }
1100
+ if (mode.beginScope) {
1101
+ if (mode.beginScope._wrap) {
1102
+ emitKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap);
1103
+ modeBuffer = "";
1104
+ } else if (mode.beginScope._multi) {
1105
+ emitMultiClass(mode.beginScope, match);
1106
+ modeBuffer = "";
1107
+ }
1108
+ }
1109
+ top = Object.create(mode, { parent: { value: top } });
1110
+ return top;
1124
1111
  }
1125
- }
1126
- function doIgnore(lexeme) {
1127
- if (top.matcher.regexIndex === 0) {
1128
- modeBuffer += lexeme[0];
1129
- return 1;
1130
- } else {
1131
- resumeScanAtSamePosition = true;
1132
- return 0;
1112
+ function endOfMode(mode, match, matchPlusRemainder) {
1113
+ let matched = startsWith(mode.endRe, matchPlusRemainder);
1114
+ if (matched) {
1115
+ if (mode["on:end"]) {
1116
+ const resp = new Response(mode);
1117
+ mode["on:end"](match, resp);
1118
+ if (resp.isMatchIgnored) matched = false;
1119
+ }
1120
+ if (matched) {
1121
+ while (mode.endsParent && mode.parent) {
1122
+ mode = mode.parent;
1123
+ }
1124
+ return mode;
1125
+ }
1126
+ }
1127
+ if (mode.endsWithParent) {
1128
+ return endOfMode(mode.parent, match, matchPlusRemainder);
1129
+ }
1133
1130
  }
1134
- }
1135
- function doBeginMatch(match) {
1136
- const lexeme = match[0];
1137
- const newMode = match.rule;
1138
- const resp = new Response(newMode);
1139
- const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
1140
- for (const cb of beforeCallbacks) {
1141
- if (!cb) continue;
1142
- cb(match, resp);
1143
- if (resp.isMatchIgnored) return doIgnore(lexeme);
1131
+ function doIgnore(lexeme) {
1132
+ if (top.matcher.regexIndex === 0) {
1133
+ modeBuffer += lexeme[0];
1134
+ return 1;
1135
+ } else {
1136
+ resumeScanAtSamePosition = true;
1137
+ return 0;
1138
+ }
1144
1139
  }
1145
- if (newMode.skip) {
1146
- modeBuffer += lexeme;
1147
- } else {
1148
- if (newMode.excludeBegin) {
1140
+ function doBeginMatch(match) {
1141
+ const lexeme = match[0];
1142
+ const newMode = match.rule;
1143
+ const resp = new Response(newMode);
1144
+ const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
1145
+ for (const cb of beforeCallbacks) {
1146
+ if (!cb) continue;
1147
+ cb(match, resp);
1148
+ if (resp.isMatchIgnored) return doIgnore(lexeme);
1149
+ }
1150
+ if (newMode.skip) {
1149
1151
  modeBuffer += lexeme;
1152
+ } else {
1153
+ if (newMode.excludeBegin) {
1154
+ modeBuffer += lexeme;
1155
+ }
1156
+ processBuffer();
1157
+ if (!newMode.returnBegin && !newMode.excludeBegin) {
1158
+ modeBuffer = lexeme;
1159
+ }
1150
1160
  }
1151
- processBuffer();
1152
- if (!newMode.returnBegin && !newMode.excludeBegin) {
1153
- modeBuffer = lexeme;
1161
+ startNewMode(newMode, match);
1162
+ return newMode.returnBegin ? 0 : lexeme.length;
1163
+ }
1164
+ function doEndMatch(match) {
1165
+ const lexeme = match[0];
1166
+ const matchPlusRemainder = codeToHighlight.substring(match.index);
1167
+ const endMode = endOfMode(top, match, matchPlusRemainder);
1168
+ if (!endMode) {
1169
+ return NO_MATCH;
1154
1170
  }
1155
- }
1156
- startNewMode(newMode, match);
1157
- return newMode.returnBegin ? 0 : lexeme.length;
1158
- }
1159
- function doEndMatch(match) {
1160
- const lexeme = match[0];
1161
- const matchPlusRemainder = codeToHighlight.substring(match.index);
1162
- const endMode = endOfMode(top, match, matchPlusRemainder);
1163
- if (!endMode) {
1164
- return NO_MATCH;
1165
- }
1166
- const origin = top;
1167
- if (top.endScope && top.endScope._wrap) {
1168
- processBuffer();
1169
- emitKeyword(lexeme, top.endScope._wrap);
1170
- } else if (top.endScope && top.endScope._multi) {
1171
- processBuffer();
1172
- emitMultiClass(top.endScope, match);
1173
- } else if (origin.skip) {
1174
- modeBuffer += lexeme;
1175
- } else {
1176
- if (!(origin.returnEnd || origin.excludeEnd)) {
1171
+ const origin = top;
1172
+ if (top.endScope && top.endScope._wrap) {
1173
+ processBuffer();
1174
+ emitKeyword(lexeme, top.endScope._wrap);
1175
+ } else if (top.endScope && top.endScope._multi) {
1176
+ processBuffer();
1177
+ emitMultiClass(top.endScope, match);
1178
+ } else if (origin.skip) {
1177
1179
  modeBuffer += lexeme;
1180
+ } else {
1181
+ if (!(origin.returnEnd || origin.excludeEnd)) {
1182
+ modeBuffer += lexeme;
1183
+ }
1184
+ processBuffer();
1185
+ if (origin.excludeEnd) {
1186
+ modeBuffer = lexeme;
1187
+ }
1178
1188
  }
1179
- processBuffer();
1180
- if (origin.excludeEnd) {
1181
- modeBuffer = lexeme;
1189
+ do {
1190
+ if (top.scope) {
1191
+ emitter.closeNode();
1192
+ }
1193
+ if (!top.skip && !top.subLanguage) {
1194
+ relevance += top.relevance;
1195
+ }
1196
+ top = top.parent;
1197
+ } while (top !== endMode.parent);
1198
+ if (endMode.starts) {
1199
+ startNewMode(endMode.starts, match);
1182
1200
  }
1201
+ return origin.returnEnd ? 0 : lexeme.length;
1183
1202
  }
1184
- do {
1185
- if (top.scope) {
1186
- emitter.closeNode();
1203
+ function processContinuations() {
1204
+ const list = [];
1205
+ for (let current = top; current !== language; current = current.parent) {
1206
+ if (current.scope) {
1207
+ list.unshift(current.scope);
1208
+ }
1187
1209
  }
1188
- if (!top.skip && !top.subLanguage) {
1189
- relevance += top.relevance;
1210
+ list.forEach((item) => emitter.openNode(item));
1211
+ }
1212
+ let lastMatch = {};
1213
+ function processLexeme(textBeforeMatch, match) {
1214
+ const lexeme = match && match[0];
1215
+ modeBuffer += textBeforeMatch;
1216
+ if (lexeme == null) {
1217
+ processBuffer();
1218
+ return 0;
1190
1219
  }
1191
- top = top.parent;
1192
- } while (top !== endMode.parent);
1193
- if (endMode.starts) {
1194
- startNewMode(endMode.starts, match);
1195
- }
1196
- return origin.returnEnd ? 0 : lexeme.length;
1197
- }
1198
- function processContinuations() {
1199
- const list = [];
1200
- for (let current = top; current !== language; current = current.parent) {
1201
- if (current.scope) {
1202
- list.unshift(current.scope);
1220
+ if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") {
1221
+ modeBuffer += codeToHighlight.slice(match.index, match.index + 1);
1222
+ if (!SAFE_MODE) {
1223
+ const err = new Error(`0 width match regex (${languageName})`);
1224
+ err.languageName = languageName;
1225
+ err.badRule = lastMatch.rule;
1226
+ throw err;
1227
+ }
1228
+ return 1;
1203
1229
  }
1204
- }
1205
- list.forEach((item) => emitter.openNode(item));
1206
- }
1207
- let lastMatch = {};
1208
- function processLexeme(textBeforeMatch, match) {
1209
- const lexeme = match && match[0];
1210
- modeBuffer += textBeforeMatch;
1211
- if (lexeme == null) {
1212
- processBuffer();
1213
- return 0;
1214
- }
1215
- if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") {
1216
- modeBuffer += codeToHighlight.slice(match.index, match.index + 1);
1217
- if (!SAFE_MODE) {
1218
- const err = new Error(`0 width match regex (${languageName})`);
1219
- err.languageName = languageName;
1220
- err.badRule = lastMatch.rule;
1230
+ lastMatch = match;
1231
+ if (match.type === "begin") {
1232
+ return doBeginMatch(match);
1233
+ } else if (match.type === "illegal" && !ignoreIllegals) {
1234
+ const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || "<unnamed>") + '"');
1235
+ err.mode = top;
1221
1236
  throw err;
1237
+ } else if (match.type === "end") {
1238
+ const processed = doEndMatch(match);
1239
+ if (processed !== NO_MATCH) {
1240
+ return processed;
1241
+ }
1242
+ }
1243
+ if (match.type === "illegal" && lexeme === "") {
1244
+ return 1;
1222
1245
  }
1223
- return 1;
1224
- }
1225
- lastMatch = match;
1226
- if (match.type === "begin") {
1227
- return doBeginMatch(match);
1228
- } else if (match.type === "illegal" && !ignoreIllegals) {
1229
- const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || "<unnamed>") + '"');
1230
- err.mode = top;
1231
- throw err;
1232
- } else if (match.type === "end") {
1233
- const processed = doEndMatch(match);
1234
- if (processed !== NO_MATCH) {
1235
- return processed;
1246
+ if (iterations > 1e5 && iterations > match.index * 3) {
1247
+ const err = new Error("potential infinite loop, way more iterations than matches");
1248
+ throw err;
1236
1249
  }
1250
+ modeBuffer += lexeme;
1251
+ return lexeme.length;
1237
1252
  }
1238
- if (match.type === "illegal" && lexeme === "") {
1239
- return 1;
1240
- }
1241
- if (iterations > 1e5 && iterations > match.index * 3) {
1242
- const err = new Error("potential infinite loop, way more iterations than matches");
1243
- throw err;
1244
- }
1245
- modeBuffer += lexeme;
1246
- return lexeme.length;
1247
- }
1248
- const language = getLanguage(languageName);
1249
- if (!language) {
1250
- error$1(LANGUAGE_NOT_FOUND.replace("{}", languageName));
1251
- throw new Error('Unknown language: "' + languageName + '"');
1252
- }
1253
- const md = compileLanguage(language);
1254
- let result = "";
1255
- let top = continuation || md;
1256
- const continuations = {};
1257
- const emitter = new options.__emitter(options);
1258
- processContinuations();
1259
- let modeBuffer = "";
1260
- let relevance = 0;
1261
- let index = 0;
1262
- let iterations = 0;
1263
- let resumeScanAtSamePosition = false;
1264
- try {
1265
- if (!language.__emitTokens) {
1266
- top.matcher.considerAll();
1267
- for (; ; ) {
1268
- iterations++;
1269
- if (resumeScanAtSamePosition) {
1270
- resumeScanAtSamePosition = false;
1271
- } else {
1272
- top.matcher.considerAll();
1253
+ const language = getLanguage(languageName);
1254
+ if (!language) {
1255
+ error2(LANGUAGE_NOT_FOUND.replace("{}", languageName));
1256
+ throw new Error('Unknown language: "' + languageName + '"');
1257
+ }
1258
+ const md = compileLanguage(language);
1259
+ let result = "";
1260
+ let top = continuation || md;
1261
+ const continuations = {};
1262
+ const emitter = new options.__emitter(options);
1263
+ processContinuations();
1264
+ let modeBuffer = "";
1265
+ let relevance = 0;
1266
+ let index = 0;
1267
+ let iterations = 0;
1268
+ let resumeScanAtSamePosition = false;
1269
+ try {
1270
+ if (!language.__emitTokens) {
1271
+ top.matcher.considerAll();
1272
+ for (; ; ) {
1273
+ iterations++;
1274
+ if (resumeScanAtSamePosition) {
1275
+ resumeScanAtSamePosition = false;
1276
+ } else {
1277
+ top.matcher.considerAll();
1278
+ }
1279
+ top.matcher.lastIndex = index;
1280
+ const match = top.matcher.exec(codeToHighlight);
1281
+ if (!match) break;
1282
+ const beforeMatch = codeToHighlight.substring(index, match.index);
1283
+ const processedCount = processLexeme(beforeMatch, match);
1284
+ index = match.index + processedCount;
1273
1285
  }
1274
- top.matcher.lastIndex = index;
1275
- const match = top.matcher.exec(codeToHighlight);
1276
- if (!match) break;
1277
- const beforeMatch = codeToHighlight.substring(index, match.index);
1278
- const processedCount = processLexeme(beforeMatch, match);
1279
- index = match.index + processedCount;
1286
+ processLexeme(codeToHighlight.substring(index));
1287
+ } else {
1288
+ language.__emitTokens(codeToHighlight, emitter);
1280
1289
  }
1281
- processLexeme(codeToHighlight.substring(index));
1282
- } else {
1283
- language.__emitTokens(codeToHighlight, emitter);
1284
- }
1285
- emitter.finalize();
1286
- result = emitter.toHTML();
1287
- return {
1288
- language: languageName,
1289
- value: result,
1290
- relevance,
1291
- illegal: false,
1292
- _emitter: emitter,
1293
- _top: top
1294
- };
1295
- } catch (err) {
1296
- if (err.message && err.message.includes("Illegal")) {
1290
+ emitter.finalize();
1291
+ result = emitter.toHTML();
1297
1292
  return {
1298
1293
  language: languageName,
1299
- value: escape(codeToHighlight),
1300
- illegal: true,
1301
- relevance: 0,
1302
- _illegalBy: {
1303
- message: err.message,
1304
- index,
1305
- context: codeToHighlight.slice(index - 100, index + 100),
1306
- mode: err.mode,
1307
- resultSoFar: result
1308
- },
1309
- _emitter: emitter
1310
- };
1311
- } else if (SAFE_MODE) {
1312
- return {
1313
- language: languageName,
1314
- value: escape(codeToHighlight),
1294
+ value: result,
1295
+ relevance,
1315
1296
  illegal: false,
1316
- relevance: 0,
1317
- errorRaised: err,
1318
1297
  _emitter: emitter,
1319
1298
  _top: top
1320
1299
  };
1321
- } else {
1322
- throw err;
1300
+ } catch (err) {
1301
+ if (err.message && err.message.includes("Illegal")) {
1302
+ return {
1303
+ language: languageName,
1304
+ value: escape(codeToHighlight),
1305
+ illegal: true,
1306
+ relevance: 0,
1307
+ _illegalBy: {
1308
+ message: err.message,
1309
+ index,
1310
+ context: codeToHighlight.slice(index - 100, index + 100),
1311
+ mode: err.mode,
1312
+ resultSoFar: result
1313
+ },
1314
+ _emitter: emitter
1315
+ };
1316
+ } else if (SAFE_MODE) {
1317
+ return {
1318
+ language: languageName,
1319
+ value: escape(codeToHighlight),
1320
+ illegal: false,
1321
+ relevance: 0,
1322
+ errorRaised: err,
1323
+ _emitter: emitter,
1324
+ _top: top
1325
+ };
1326
+ } else {
1327
+ throw err;
1328
+ }
1323
1329
  }
1324
1330
  }
1325
- }
1326
- function justTextHighlightResult(code) {
1327
- const result = {
1328
- value: escape(code),
1329
- illegal: false,
1330
- relevance: 0,
1331
- _top: PLAINTEXT_LANGUAGE,
1332
- _emitter: new options.__emitter(options)
1333
- };
1334
- result._emitter.addText(code);
1335
- return result;
1336
- }
1337
- function highlightAuto(code, languageSubset) {
1338
- languageSubset = languageSubset || options.languages || Object.keys(languages);
1339
- const plaintext = justTextHighlightResult(code);
1340
- const results = languageSubset.filter(getLanguage).filter(autoDetection).map(
1341
- (name) => _highlight(name, code, false)
1342
- );
1343
- results.unshift(plaintext);
1344
- const sorted = results.sort((a, b) => {
1345
- if (a.relevance !== b.relevance) return b.relevance - a.relevance;
1346
- if (a.language && b.language) {
1347
- if (getLanguage(a.language).supersetOf === b.language) {
1348
- return 1;
1349
- } else if (getLanguage(b.language).supersetOf === a.language) {
1350
- return -1;
1331
+ function justTextHighlightResult(code) {
1332
+ const result = {
1333
+ value: escape(code),
1334
+ illegal: false,
1335
+ relevance: 0,
1336
+ _top: PLAINTEXT_LANGUAGE,
1337
+ _emitter: new options.__emitter(options)
1338
+ };
1339
+ result._emitter.addText(code);
1340
+ return result;
1341
+ }
1342
+ function highlightAuto(code, languageSubset) {
1343
+ languageSubset = languageSubset || options.languages || Object.keys(languages);
1344
+ const plaintext = justTextHighlightResult(code);
1345
+ const results = languageSubset.filter(getLanguage).filter(autoDetection).map(
1346
+ (name) => _highlight(name, code, false)
1347
+ );
1348
+ results.unshift(plaintext);
1349
+ const sorted = results.sort((a, b) => {
1350
+ if (a.relevance !== b.relevance) return b.relevance - a.relevance;
1351
+ if (a.language && b.language) {
1352
+ if (getLanguage(a.language).supersetOf === b.language) {
1353
+ return 1;
1354
+ } else if (getLanguage(b.language).supersetOf === a.language) {
1355
+ return -1;
1356
+ }
1351
1357
  }
1352
- }
1353
- return 0;
1354
- });
1355
- const [best, secondBest] = sorted;
1356
- const result = best;
1357
- result.secondBest = secondBest;
1358
- return result;
1359
- }
1360
- function updateClassName(element, currentLang, resultLang) {
1361
- const language = currentLang && aliases[currentLang] || resultLang;
1362
- element.classList.add("hljs");
1363
- element.classList.add(`language-${language}`);
1364
- }
1365
- function highlightElement(element) {
1366
- let node = null;
1367
- const language = blockLanguage(element);
1368
- if (shouldNotHighlight(language)) return;
1369
- fire(
1370
- "before:highlightElement",
1371
- { el: element, language }
1372
- );
1373
- if (element.dataset.highlighted) {
1374
- console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", element);
1375
- return;
1358
+ return 0;
1359
+ });
1360
+ const [best, secondBest] = sorted;
1361
+ const result = best;
1362
+ result.secondBest = secondBest;
1363
+ return result;
1376
1364
  }
1377
- if (element.children.length > 0) {
1378
- if (!options.ignoreUnescapedHTML) {
1379
- console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk.");
1380
- console.warn("https://github.com/highlightjs/highlight.js/wiki/security");
1381
- console.warn("The element with unescaped HTML:");
1382
- console.warn(element);
1383
- }
1384
- if (options.throwUnescapedHTML) {
1385
- const err = new HTMLInjectionError(
1386
- "One of your code blocks includes unescaped HTML.",
1387
- element.innerHTML
1388
- );
1389
- throw err;
1390
- }
1391
- }
1392
- node = element;
1393
- const text = node.textContent;
1394
- const result = language ? highlight2(text, { language, ignoreIllegals: true }) : highlightAuto(text);
1395
- element.innerHTML = result.value;
1396
- element.dataset.highlighted = "yes";
1397
- updateClassName(element, language, result.language);
1398
- element.result = {
1399
- language: result.language,
1400
- // TODO: remove with version 11.0
1401
- re: result.relevance,
1402
- relevance: result.relevance
1403
- };
1404
- if (result.secondBest) {
1405
- element.secondBest = {
1406
- language: result.secondBest.language,
1407
- relevance: result.secondBest.relevance
1365
+ function updateClassName(element, currentLang, resultLang) {
1366
+ const language = currentLang && aliases[currentLang] || resultLang;
1367
+ element.classList.add("hljs");
1368
+ element.classList.add(`language-${language}`);
1369
+ }
1370
+ function highlightElement(element) {
1371
+ let node = null;
1372
+ const language = blockLanguage(element);
1373
+ if (shouldNotHighlight(language)) return;
1374
+ fire(
1375
+ "before:highlightElement",
1376
+ { el: element, language }
1377
+ );
1378
+ if (element.dataset.highlighted) {
1379
+ console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", element);
1380
+ return;
1381
+ }
1382
+ if (element.children.length > 0) {
1383
+ if (!options.ignoreUnescapedHTML) {
1384
+ console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk.");
1385
+ console.warn("https://github.com/highlightjs/highlight.js/wiki/security");
1386
+ console.warn("The element with unescaped HTML:");
1387
+ console.warn(element);
1388
+ }
1389
+ if (options.throwUnescapedHTML) {
1390
+ const err = new HTMLInjectionError(
1391
+ "One of your code blocks includes unescaped HTML.",
1392
+ element.innerHTML
1393
+ );
1394
+ throw err;
1395
+ }
1396
+ }
1397
+ node = element;
1398
+ const text = node.textContent;
1399
+ const result = language ? highlight2(text, { language, ignoreIllegals: true }) : highlightAuto(text);
1400
+ element.innerHTML = result.value;
1401
+ element.dataset.highlighted = "yes";
1402
+ updateClassName(element, language, result.language);
1403
+ element.result = {
1404
+ language: result.language,
1405
+ // TODO: remove with version 11.0
1406
+ re: result.relevance,
1407
+ relevance: result.relevance
1408
1408
  };
1409
+ if (result.secondBest) {
1410
+ element.secondBest = {
1411
+ language: result.secondBest.language,
1412
+ relevance: result.secondBest.relevance
1413
+ };
1414
+ }
1415
+ fire("after:highlightElement", { el: element, result, text });
1409
1416
  }
1410
- fire("after:highlightElement", { el: element, result, text });
1411
- }
1412
- function configure(userOptions) {
1413
- options = inherit(options, userOptions);
1414
- }
1415
- const initHighlighting = () => {
1416
- highlightAll();
1417
- deprecated("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
1418
- };
1419
- function initHighlightingOnLoad() {
1420
- highlightAll();
1421
- deprecated("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now.");
1422
- }
1423
- let wantsHighlight = false;
1424
- function highlightAll() {
1425
- if (document.readyState === "loading") {
1426
- wantsHighlight = true;
1427
- return;
1417
+ function configure(userOptions) {
1418
+ options = inherit(options, userOptions);
1428
1419
  }
1429
- const blocks = document.querySelectorAll(options.cssSelector);
1430
- blocks.forEach(highlightElement);
1431
- }
1432
- function boot() {
1433
- if (wantsHighlight) highlightAll();
1434
- }
1435
- if (typeof window !== "undefined" && window.addEventListener) {
1436
- window.addEventListener("DOMContentLoaded", boot, false);
1437
- }
1438
- function registerLanguage(languageName, languageDefinition) {
1439
- let lang = null;
1440
- try {
1441
- lang = languageDefinition(hljs);
1442
- } catch (error$1$1) {
1443
- error$1("Language definition for '{}' could not be registered.".replace("{}", languageName));
1444
- if (!SAFE_MODE) {
1445
- throw error$1$1;
1446
- } else {
1447
- error$1(error$1$1);
1420
+ const initHighlighting = () => {
1421
+ highlightAll();
1422
+ deprecated("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
1423
+ };
1424
+ function initHighlightingOnLoad() {
1425
+ highlightAll();
1426
+ deprecated("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now.");
1427
+ }
1428
+ let wantsHighlight = false;
1429
+ function highlightAll() {
1430
+ if (document.readyState === "loading") {
1431
+ wantsHighlight = true;
1432
+ return;
1448
1433
  }
1449
- lang = PLAINTEXT_LANGUAGE;
1434
+ const blocks = document.querySelectorAll(options.cssSelector);
1435
+ blocks.forEach(highlightElement);
1450
1436
  }
1451
- if (!lang.name) lang.name = languageName;
1452
- languages[languageName] = lang;
1453
- lang.rawDefinition = languageDefinition.bind(null, hljs);
1454
- if (lang.aliases) {
1455
- registerAliases(lang.aliases, { languageName });
1437
+ function boot() {
1438
+ if (wantsHighlight) highlightAll();
1456
1439
  }
1457
- }
1458
- function unregisterLanguage(languageName) {
1459
- delete languages[languageName];
1460
- for (const alias of Object.keys(aliases)) {
1461
- if (aliases[alias] === languageName) {
1462
- delete aliases[alias];
1440
+ if (typeof window !== "undefined" && window.addEventListener) {
1441
+ window.addEventListener("DOMContentLoaded", boot, false);
1442
+ }
1443
+ function registerLanguage(languageName, languageDefinition) {
1444
+ let lang = null;
1445
+ try {
1446
+ lang = languageDefinition(hljs);
1447
+ } catch (error$1) {
1448
+ error2("Language definition for '{}' could not be registered.".replace("{}", languageName));
1449
+ if (!SAFE_MODE) {
1450
+ throw error$1;
1451
+ } else {
1452
+ error2(error$1);
1453
+ }
1454
+ lang = PLAINTEXT_LANGUAGE;
1455
+ }
1456
+ if (!lang.name) lang.name = languageName;
1457
+ languages[languageName] = lang;
1458
+ lang.rawDefinition = languageDefinition.bind(null, hljs);
1459
+ if (lang.aliases) {
1460
+ registerAliases(lang.aliases, { languageName });
1463
1461
  }
1464
1462
  }
1465
- }
1466
- function listLanguages() {
1467
- return Object.keys(languages);
1468
- }
1469
- function getLanguage(name) {
1470
- name = (name || "").toLowerCase();
1471
- return languages[name] || languages[aliases[name]];
1472
- }
1473
- function registerAliases(aliasList, { languageName }) {
1474
- if (typeof aliasList === "string") {
1475
- aliasList = [aliasList];
1463
+ function unregisterLanguage(languageName) {
1464
+ delete languages[languageName];
1465
+ for (const alias of Object.keys(aliases)) {
1466
+ if (aliases[alias] === languageName) {
1467
+ delete aliases[alias];
1468
+ }
1469
+ }
1476
1470
  }
1477
- aliasList.forEach((alias) => {
1478
- aliases[alias.toLowerCase()] = languageName;
1479
- });
1480
- }
1481
- function autoDetection(name) {
1482
- const lang = getLanguage(name);
1483
- return lang && !lang.disableAutodetect;
1484
- }
1485
- function upgradePluginAPI(plugin) {
1486
- if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) {
1487
- plugin["before:highlightElement"] = (data) => {
1488
- plugin["before:highlightBlock"](
1489
- Object.assign({ block: data.el }, data)
1490
- );
1491
- };
1471
+ function listLanguages() {
1472
+ return Object.keys(languages);
1492
1473
  }
1493
- if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) {
1494
- plugin["after:highlightElement"] = (data) => {
1495
- plugin["after:highlightBlock"](
1496
- Object.assign({ block: data.el }, data)
1497
- );
1498
- };
1474
+ function getLanguage(name) {
1475
+ name = (name || "").toLowerCase();
1476
+ return languages[name] || languages[aliases[name]];
1499
1477
  }
1500
- }
1501
- function addPlugin(plugin) {
1502
- upgradePluginAPI(plugin);
1503
- plugins.push(plugin);
1504
- }
1505
- function removePlugin(plugin) {
1506
- const index = plugins.indexOf(plugin);
1507
- if (index !== -1) {
1508
- plugins.splice(index, 1);
1478
+ function registerAliases(aliasList, { languageName }) {
1479
+ if (typeof aliasList === "string") {
1480
+ aliasList = [aliasList];
1481
+ }
1482
+ aliasList.forEach((alias) => {
1483
+ aliases[alias.toLowerCase()] = languageName;
1484
+ });
1509
1485
  }
1510
- }
1511
- function fire(event, args) {
1512
- const cb = event;
1513
- plugins.forEach(function(plugin) {
1514
- if (plugin[cb]) {
1515
- plugin[cb](args);
1486
+ function autoDetection(name) {
1487
+ const lang = getLanguage(name);
1488
+ return lang && !lang.disableAutodetect;
1489
+ }
1490
+ function upgradePluginAPI(plugin) {
1491
+ if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) {
1492
+ plugin["before:highlightElement"] = (data) => {
1493
+ plugin["before:highlightBlock"](
1494
+ Object.assign({ block: data.el }, data)
1495
+ );
1496
+ };
1497
+ }
1498
+ if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) {
1499
+ plugin["after:highlightElement"] = (data) => {
1500
+ plugin["after:highlightBlock"](
1501
+ Object.assign({ block: data.el }, data)
1502
+ );
1503
+ };
1516
1504
  }
1505
+ }
1506
+ function addPlugin(plugin) {
1507
+ upgradePluginAPI(plugin);
1508
+ plugins.push(plugin);
1509
+ }
1510
+ function removePlugin(plugin) {
1511
+ const index = plugins.indexOf(plugin);
1512
+ if (index !== -1) {
1513
+ plugins.splice(index, 1);
1514
+ }
1515
+ }
1516
+ function fire(event, args) {
1517
+ const cb = event;
1518
+ plugins.forEach(function(plugin) {
1519
+ if (plugin[cb]) {
1520
+ plugin[cb](args);
1521
+ }
1522
+ });
1523
+ }
1524
+ function deprecateHighlightBlock(el) {
1525
+ deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0");
1526
+ deprecated("10.7.0", "Please use highlightElement now.");
1527
+ return highlightElement(el);
1528
+ }
1529
+ Object.assign(hljs, {
1530
+ highlight: highlight2,
1531
+ highlightAuto,
1532
+ highlightAll,
1533
+ highlightElement,
1534
+ // TODO: Remove with v12 API
1535
+ highlightBlock: deprecateHighlightBlock,
1536
+ configure,
1537
+ initHighlighting,
1538
+ initHighlightingOnLoad,
1539
+ registerLanguage,
1540
+ unregisterLanguage,
1541
+ listLanguages,
1542
+ getLanguage,
1543
+ registerAliases,
1544
+ autoDetection,
1545
+ inherit,
1546
+ addPlugin,
1547
+ removePlugin
1517
1548
  });
1518
- }
1519
- function deprecateHighlightBlock(el) {
1520
- deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0");
1521
- deprecated("10.7.0", "Please use highlightElement now.");
1522
- return highlightElement(el);
1523
- }
1524
- Object.assign(hljs, {
1525
- highlight: highlight2,
1526
- highlightAuto,
1527
- highlightAll,
1528
- highlightElement,
1529
- // TODO: Remove with v12 API
1530
- highlightBlock: deprecateHighlightBlock,
1531
- configure,
1532
- initHighlighting,
1533
- initHighlightingOnLoad,
1534
- registerLanguage,
1535
- unregisterLanguage,
1536
- listLanguages,
1537
- getLanguage,
1538
- registerAliases,
1539
- autoDetection,
1540
- inherit,
1541
- addPlugin,
1542
- removePlugin
1543
- });
1544
- hljs.debugMode = function() {
1545
- SAFE_MODE = false;
1546
- };
1547
- hljs.safeMode = function() {
1548
- SAFE_MODE = true;
1549
- };
1550
- hljs.versionString = version;
1551
- hljs.regex = {
1552
- concat,
1553
- lookahead,
1554
- either,
1555
- optional,
1556
- anyNumberOfTimes
1557
- };
1558
- for (const key in MODES) {
1559
- if (typeof MODES[key] === "object") {
1560
- deepFreeze(MODES[key]);
1549
+ hljs.debugMode = function() {
1550
+ SAFE_MODE = false;
1551
+ };
1552
+ hljs.safeMode = function() {
1553
+ SAFE_MODE = true;
1554
+ };
1555
+ hljs.versionString = version;
1556
+ hljs.regex = {
1557
+ concat,
1558
+ lookahead,
1559
+ either,
1560
+ optional,
1561
+ anyNumberOfTimes
1562
+ };
1563
+ for (const key in MODES) {
1564
+ if (typeof MODES[key] === "object") {
1565
+ deepFreeze(MODES[key]);
1566
+ }
1561
1567
  }
1562
- }
1563
- Object.assign(hljs, MODES);
1564
- return hljs;
1565
- };
1566
- const highlight = HLJS({});
1567
- highlight.newInstance = () => HLJS({});
1568
- var core = highlight;
1569
- highlight.HighlightJS = highlight;
1570
- highlight.default = highlight;
1571
- const HighlightJS = /* @__PURE__ */ getDefaultExportFromCjs(core);
1568
+ Object.assign(hljs, MODES);
1569
+ return hljs;
1570
+ };
1571
+ const highlight = HLJS({});
1572
+ highlight.newInstance = () => HLJS({});
1573
+ core = highlight;
1574
+ highlight.HighlightJS = highlight;
1575
+ highlight.default = highlight;
1576
+ return core;
1577
+ }
1578
+ var coreExports = /* @__PURE__ */ requireCore();
1579
+ const HighlightJS = /* @__PURE__ */ getDefaultExportFromCjs(coreExports);
1572
1580
  const _hoisted_1$3 = { class: "node-error-view" };
1573
1581
  const _hoisted_2$3 = { class: "node-error-view__header" };
1574
1582
  const _hoisted_3$2 = {
@@ -1735,17 +1743,15 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1735
1743
  return ndvStore.ndvInputData.length > 1;
1736
1744
  });
1737
1745
  const nodeDefaultName = computed(() => {
1738
- var _a;
1739
1746
  if (!node.value) {
1740
1747
  return "Node";
1741
1748
  }
1742
1749
  const nodeType = nodeTypesStore.getNodeType(node.value.type, node.value.typeVersion);
1743
- return ((_a = nodeType == null ? void 0 : nodeType.defaults) == null ? void 0 : _a.name) || node.value.name;
1750
+ return nodeType?.defaults?.name || node.value.name;
1744
1751
  });
1745
1752
  const prepareRawMessages = computed(() => {
1746
- var _a;
1747
1753
  const returnData = [];
1748
- if (!((_a = props.error.messages) == null ? void 0 : _a.length)) {
1754
+ if (!props.error.messages?.length) {
1749
1755
  return [];
1750
1756
  }
1751
1757
  const errorMessage = getErrorMessage();
@@ -1799,8 +1805,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1799
1805
  return sanitizeHtml(description.replace(/`(.*?)`/g, "<code>$1</code>"));
1800
1806
  }
1801
1807
  function getErrorDescription() {
1802
- var _a, _b;
1803
- if ((_a = props.error.context) == null ? void 0 : _a.descriptionKey) {
1808
+ if (props.error.context?.descriptionKey) {
1804
1809
  const interpolate = {
1805
1810
  nodeCause: props.error.context.nodeCause,
1806
1811
  runIndex: props.error.context.runIndex ?? "0",
@@ -1813,7 +1818,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1813
1818
  )
1814
1819
  );
1815
1820
  }
1816
- if (!((_b = props.error.context) == null ? void 0 : _b.descriptionTemplate)) {
1821
+ if (!props.error.context?.descriptionTemplate) {
1817
1822
  return prepareDescription(props.error.description ?? "");
1818
1823
  }
1819
1824
  const parameterName = parameterDisplayName(props.error.context.parameter);
@@ -1822,25 +1827,23 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1822
1827
  );
1823
1828
  }
1824
1829
  function addItemIndexSuffix(message) {
1825
- var _a, _b;
1826
1830
  let itemIndexSuffix = "";
1827
- if (hasManyInputItems.value && ((_b = (_a = props.error) == null ? void 0 : _a.context) == null ? void 0 : _b.itemIndex) !== void 0) {
1831
+ if (hasManyInputItems.value && props.error?.context?.itemIndex !== void 0) {
1828
1832
  itemIndexSuffix = `item ${props.error.context.itemIndex}`;
1829
1833
  }
1830
1834
  if (message.includes(itemIndexSuffix)) return message;
1831
1835
  return `${message} [${itemIndexSuffix}]`;
1832
1836
  }
1833
1837
  function getErrorMessage() {
1834
- var _a, _b, _c;
1835
1838
  let message = "";
1836
1839
  const isNonEmptyString = (value) => !!value && typeof value === "string";
1837
1840
  if (isSubNodeError.value) {
1838
1841
  message = i18n.baseText("nodeErrorView.errorSubNode", {
1839
1842
  interpolate: { node: props.error.node.name }
1840
1843
  });
1841
- } else if (isNonEmptyString(props.error.message) && (props.error.message === props.error.description || !((_a = props.error.context) == null ? void 0 : _a.messageTemplate))) {
1844
+ } else if (isNonEmptyString(props.error.message) && (props.error.message === props.error.description || !props.error.context?.messageTemplate)) {
1842
1845
  message = props.error.message;
1843
- } else if (isNonEmptyString((_b = props.error.context) == null ? void 0 : _b.messageTemplate) && isNonEmptyString((_c = props.error.context) == null ? void 0 : _c.parameter)) {
1846
+ } else if (isNonEmptyString(props.error.context?.messageTemplate) && isNonEmptyString(props.error.context?.parameter)) {
1844
1847
  const parameterName = parameterDisplayName(props.error.context.parameter);
1845
1848
  message = props.error.context.messageTemplate.replace(/%%PARAMETER%%/g, parameterName);
1846
1849
  } else if (Array.isArray(props.error.messages) && props.error.messages.length > 0) {
@@ -1895,7 +1898,6 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1895
1898
  return [currentParameter];
1896
1899
  }
1897
1900
  function copyErrorDetails() {
1898
- var _a, _b, _c, _d, _e, _f;
1899
1901
  const error2 = props.error;
1900
1902
  const errorInfo = {
1901
1903
  errorMessage: getErrorMessage()
@@ -1904,7 +1906,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1904
1906
  errorInfo.errorDescription = error2.description;
1905
1907
  }
1906
1908
  const errorDetails = {};
1907
- if ((_a = error2 == null ? void 0 : error2.messages) == null ? void 0 : _a.length) {
1909
+ if (error2?.messages?.length) {
1908
1910
  errorDetails.rawErrorMessage = error2.messages;
1909
1911
  }
1910
1912
  if ("httpCode" in error2 && error2.httpCode) {
@@ -1922,10 +1924,10 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1922
1924
  n8nDetails.nodeName = error2.node.name;
1923
1925
  n8nDetails.nodeType = error2.node.type;
1924
1926
  n8nDetails.nodeVersion = error2.node.typeVersion;
1925
- if ((_c = (_b = error2.node) == null ? void 0 : _b.parameters) == null ? void 0 : _c.resource) {
1927
+ if (error2.node?.parameters?.resource) {
1926
1928
  n8nDetails.resource = error2.node.parameters.resource;
1927
1929
  }
1928
- if ((_e = (_d = error2 == null ? void 0 : error2.node) == null ? void 0 : _d.parameters) == null ? void 0 : _e.operation) {
1930
+ if (error2?.node?.parameters?.operation) {
1929
1931
  n8nDetails.operation = error2.node.parameters.operation;
1930
1932
  }
1931
1933
  }
@@ -1951,7 +1953,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1951
1953
  if (error2.cause) {
1952
1954
  n8nDetails.cause = error2.cause;
1953
1955
  }
1954
- n8nDetails.stackTrace = (_f = error2.stack) == null ? void 0 : _f.split("\n");
1956
+ n8nDetails.stackTrace = error2.stack?.split("\n");
1955
1957
  errorInfo.n8nDetails = n8nDetails;
1956
1958
  void clipboard.copy(JSON.stringify(errorInfo, null, 2));
1957
1959
  copySuccess();
@@ -1963,8 +1965,8 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1963
1965
  });
1964
1966
  }
1965
1967
  function nodeIsHidden() {
1966
- const nodeType = nodeTypesStore.getNodeType(node == null ? void 0 : node.value.type);
1967
- return (nodeType == null ? void 0 : nodeType.hidden) ?? false;
1968
+ const nodeType = nodeTypesStore.getNodeType(node?.value.type);
1969
+ return nodeType?.hidden ?? false;
1968
1970
  }
1969
1971
  const onOpenErrorNodeDetailClick = () => {
1970
1972
  ndvStore.activeNodeName = props.error.node.name;
@@ -1997,7 +1999,6 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1997
1999
  });
1998
2000
  }
1999
2001
  return (_ctx, _cache) => {
2000
- var _a, _b, _c, _d, _e;
2001
2002
  const _component_n8n_button = resolveComponent("n8n-button");
2002
2003
  const _component_n8n_icon_button = resolveComponent("n8n-icon-button");
2003
2004
  const _component_n8n_tooltip = resolveComponent("n8n-tooltip");
@@ -2008,7 +2009,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2008
2009
  createBaseVNode("div", _hoisted_3$2, [
2009
2010
  createBaseVNode("div", null, toDisplayString(getErrorMessage()), 1)
2010
2011
  ]),
2011
- (_ctx.error.description || ((_a = _ctx.error.context) == null ? void 0 : _a.descriptionKey)) && !isSubNodeError.value ? withDirectives((openBlock(), createElementBlock("div", _hoisted_4$1, null, 512)), [
2012
+ (_ctx.error.description || _ctx.error.context?.descriptionKey) && !isSubNodeError.value ? withDirectives((openBlock(), createElementBlock("div", _hoisted_4$1, null, 512)), [
2012
2013
  [_directive_n8n_html, getErrorDescription()]
2013
2014
  ]) : createCommentVNode("", true),
2014
2015
  isSubNodeError.value ? (openBlock(), createElementBlock("div", _hoisted_5, [
@@ -2052,7 +2053,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2052
2053
  }, 8, ["content"])
2053
2054
  ]),
2054
2055
  createBaseVNode("div", _hoisted_11, [
2055
- "httpCode" in _ctx.error && _ctx.error.httpCode || prepareRawMessages.value.length || ((_c = (_b = _ctx.error) == null ? void 0 : _b.context) == null ? void 0 : _c.data) || _ctx.error.extra ? (openBlock(), createElementBlock("details", _hoisted_12, [
2056
+ "httpCode" in _ctx.error && _ctx.error.httpCode || prepareRawMessages.value.length || _ctx.error?.context?.data || _ctx.error.extra ? (openBlock(), createElementBlock("details", _hoisted_12, [
2056
2057
  createBaseVNode("summary", _hoisted_13, [
2057
2058
  createVNode(_component_font_awesome_icon, {
2058
2059
  class: "node-error-view__details-icon",
@@ -2081,7 +2082,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2081
2082
  }), 128))
2082
2083
  ])
2083
2084
  ])) : createCommentVNode("", true),
2084
- ((_e = (_d = _ctx.error) == null ? void 0 : _d.context) == null ? void 0 : _e.data) ? (openBlock(), createElementBlock("div", _hoisted_21, [
2085
+ _ctx.error?.context?.data ? (openBlock(), createElementBlock("div", _hoisted_21, [
2085
2086
  createBaseVNode("p", _hoisted_22, toDisplayString(unref(i18n).baseText("nodeErrorView.details.errorData")), 1),
2086
2087
  createBaseVNode("div", _hoisted_23, [
2087
2088
  createBaseVNode("pre", null, [
@@ -2196,7 +2197,7 @@ const outputTypeParsers = {
2196
2197
  [NodeConnectionType.AiLanguageModel](execData) {
2197
2198
  const response = execData.response ?? execData;
2198
2199
  if (!response) throw new Error("No response from Language Model");
2199
- if (Array.isArray(response == null ? void 0 : response.messages) && (response == null ? void 0 : response.messages.length) === 1 && typeof (response == null ? void 0 : response.messages[0]) === "string") {
2200
+ if (Array.isArray(response?.messages) && response?.messages.length === 1 && typeof response?.messages[0] === "string") {
2200
2201
  return {
2201
2202
  type: "text",
2202
2203
  data: response.messages[0],
@@ -2209,7 +2210,7 @@ const outputTypeParsers = {
2209
2210
  if (response.generations) {
2210
2211
  const generations = response.generations;
2211
2212
  const content = generations.map((generation) => {
2212
- if (generation == null ? void 0 : generation.text) return generation.text;
2213
+ if (generation?.text) return generation.text;
2213
2214
  if (Array.isArray(generation)) {
2214
2215
  return generation.map((item) => item.text ?? item).join("\n\n").trim();
2215
2216
  }
@@ -2230,12 +2231,10 @@ const outputTypeParsers = {
2230
2231
  [NodeConnectionType.AiTool]: fallbackParser,
2231
2232
  [NodeConnectionType.AiAgent]: fallbackParser,
2232
2233
  [NodeConnectionType.AiMemory](execData) {
2233
- var _a;
2234
- const chatHistory = execData.chatHistory ?? execData.messages ?? ((_a = execData == null ? void 0 : execData.response) == null ? void 0 : _a.chat_history);
2234
+ const chatHistory = execData.chatHistory ?? execData.messages ?? execData?.response?.chat_history;
2235
2235
  if (Array.isArray(chatHistory)) {
2236
2236
  const responseText = chatHistory.map((content) => {
2237
- var _a2;
2238
- if (content.type === "constructor" && ((_a2 = content.id) == null ? void 0 : _a2.includes("messages")) && content.kwargs) {
2237
+ if (content.type === "constructor" && content.id?.includes("messages") && content.kwargs) {
2239
2238
  let message = content.kwargs.content;
2240
2239
  if (Array.isArray(message)) {
2241
2240
  message = message.map((item) => {
@@ -2427,8 +2426,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2427
2426
  }
2428
2427
  function setContentParsed(content) {
2429
2428
  contentParsed.value = !!content.find((item) => {
2430
- var _a;
2431
- if (((_a = item.parsedContent) == null ? void 0 : _a.parsed) === true) {
2429
+ if (item.parsedContent?.parsed === true) {
2432
2430
  return true;
2433
2431
  }
2434
2432
  return false;
@@ -2505,7 +2503,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2505
2503
  return openBlock(), createElementBlock("div", {
2506
2504
  key: index,
2507
2505
  class: normalizeClass(_ctx.$style.contentText),
2508
- "data-content-type": parsedContent == null ? void 0 : parsedContent.type
2506
+ "data-content-type": parsedContent?.type
2509
2507
  }, [
2510
2508
  parsedContent && renderType.value === "rendered" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2511
2509
  parsedContent.type === "json" ? (openBlock(), createBlock(unref(VueMarkdown), {
@@ -2598,11 +2596,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2598
2596
  const { trackOpeningRelatedExecution, resolveRelatedExecutionUrl } = useExecutionHelpers();
2599
2597
  const i18n = useI18n();
2600
2598
  const consumedTokensSum = computed(() => {
2601
- var _a, _b;
2602
- const tokenUsage = (_b = (_a = outputRun.value) == null ? void 0 : _a.data) == null ? void 0 : _b.reduce(
2599
+ const tokenUsage = outputRun.value?.data?.reduce(
2603
2600
  (acc, curr) => {
2604
- var _a2, _b2;
2605
- const tokenUsageData = ((_a2 = curr.json) == null ? void 0 : _a2.tokenUsage) ?? ((_b2 = curr.json) == null ? void 0 : _b2.tokenUsageEstimate);
2601
+ const tokenUsageData = curr.json?.tokenUsage ?? curr.json?.tokenUsageEstimate;
2606
2602
  if (!tokenUsageData) return acc;
2607
2603
  return {
2608
2604
  completionTokens: acc.completionTokens + tokenUsageData.completionTokens,
@@ -2619,26 +2615,21 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2619
2615
  return tokenUsage;
2620
2616
  });
2621
2617
  const usingTokensEstimates = computed(() => {
2622
- var _a, _b;
2623
- return (_b = (_a = outputRun.value) == null ? void 0 : _a.data) == null ? void 0 : _b.some((d) => {
2624
- var _a2;
2625
- return (_a2 = d.json) == null ? void 0 : _a2.tokenUsageEstimate;
2626
- });
2618
+ return outputRun.value?.data?.some((d) => d.json?.tokenUsageEstimate);
2627
2619
  });
2628
2620
  function formatTokenUsageCount(count) {
2629
2621
  return usingTokensEstimates.value ? `~${count}` : count.toString();
2630
2622
  }
2631
2623
  function extractRunMeta(run) {
2632
- var _a;
2633
2624
  const uiNode = workflowsStore.getNodeByName(props.inputData.node);
2634
- const nodeType = nodeTypesStore.getNodeType((uiNode == null ? void 0 : uiNode.type) ?? "");
2625
+ const nodeType = nodeTypesStore.getNodeType(uiNode?.type ?? "");
2635
2626
  const runMeta2 = {
2636
2627
  startTimeMs: run.metadata.startTime,
2637
2628
  executionTimeMs: run.metadata.executionTime,
2638
2629
  node: nodeType,
2639
2630
  type: run.inOut,
2640
2631
  connectionType: run.type,
2641
- subExecution: (_a = run.metadata) == null ? void 0 : _a.subExecution
2632
+ subExecution: run.metadata?.subExecution
2642
2633
  };
2643
2634
  return runMeta2;
2644
2635
  }
@@ -2652,15 +2643,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2652
2643
  return extractRunMeta(outputRun.value);
2653
2644
  });
2654
2645
  const executionRunData = computed(() => {
2655
- var _a, _b, _c;
2656
- return (_c = (_b = (_a = workflowsStore.getWorkflowExecution) == null ? void 0 : _a.data) == null ? void 0 : _b.resultData) == null ? void 0 : _c.runData;
2646
+ return workflowsStore.getWorkflowExecution?.data?.resultData?.runData;
2657
2647
  });
2658
2648
  const outputError = computed(() => {
2659
- var _a, _b, _c;
2660
- return (_c = (_b = (_a = executionRunData.value) == null ? void 0 : _a[props.inputData.node]) == null ? void 0 : _b[props.inputData.runIndex]) == null ? void 0 : _c.error;
2649
+ return executionRunData.value?.[props.inputData.node]?.[props.inputData.runIndex]?.error;
2661
2650
  });
2662
2651
  return (_ctx, _cache) => {
2663
- var _a, _b, _c, _d, _e, _f, _g, _h;
2664
2652
  const _component_n8n_tooltip = resolveComponent("n8n-tooltip");
2665
2653
  const _component_N8nIcon = resolveComponent("N8nIcon");
2666
2654
  const _component_n8n_text = resolveComponent("n8n-text");
@@ -2671,7 +2659,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2671
2659
  createBaseVNode("header", {
2672
2660
  class: normalizeClass(_ctx.$style.header)
2673
2661
  }, [
2674
- ((_a = runMeta.value) == null ? void 0 : _a.node) ? (openBlock(), createBlock(_sfc_main$4, {
2662
+ runMeta.value?.node ? (openBlock(), createBlock(_sfc_main$4, {
2675
2663
  key: 0,
2676
2664
  class: normalizeClass(_ctx.$style.nodeIcon),
2677
2665
  "node-type": runMeta.value.node,
@@ -2686,29 +2674,23 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2686
2674
  createBaseVNode("ul", {
2687
2675
  class: normalizeClass(_ctx.$style.meta)
2688
2676
  }, [
2689
- ((_b = runMeta.value) == null ? void 0 : _b.startTimeMs) ? (openBlock(), createElementBlock("li", _hoisted_1$1, toDisplayString((_c = runMeta.value) == null ? void 0 : _c.executionTimeMs) + "ms", 1)) : createCommentVNode("", true),
2690
- ((_d = runMeta.value) == null ? void 0 : _d.startTimeMs) ? (openBlock(), createElementBlock("li", _hoisted_2$1, [
2677
+ runMeta.value?.startTimeMs ? (openBlock(), createElementBlock("li", _hoisted_1$1, toDisplayString(runMeta.value?.executionTimeMs) + "ms", 1)) : createCommentVNode("", true),
2678
+ runMeta.value?.startTimeMs ? (openBlock(), createElementBlock("li", _hoisted_2$1, [
2691
2679
  createVNode(_component_n8n_tooltip, null, {
2692
- content: withCtx(() => {
2693
- var _a2;
2694
- return [
2695
- createTextVNode(toDisplayString(new Date((_a2 = runMeta.value) == null ? void 0 : _a2.startTimeMs).toLocaleString()), 1)
2696
- ];
2697
- }),
2698
- default: withCtx(() => {
2699
- var _a2;
2700
- return [
2701
- createTextVNode(" " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.startedAt", {
2702
- interpolate: {
2703
- startTime: new Date((_a2 = runMeta.value) == null ? void 0 : _a2.startTimeMs).toLocaleTimeString()
2704
- }
2705
- })), 1)
2706
- ];
2707
- }),
2680
+ content: withCtx(() => [
2681
+ createTextVNode(toDisplayString(new Date(runMeta.value?.startTimeMs).toLocaleString()), 1)
2682
+ ]),
2683
+ default: withCtx(() => [
2684
+ createTextVNode(" " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.startedAt", {
2685
+ interpolate: {
2686
+ startTime: new Date(runMeta.value?.startTimeMs).toLocaleTimeString()
2687
+ }
2688
+ })), 1)
2689
+ ]),
2708
2690
  _: 1
2709
2691
  })
2710
2692
  ])) : createCommentVNode("", true),
2711
- ((_e = runMeta.value) == null ? void 0 : _e.subExecution) ? (openBlock(), createElementBlock("li", _hoisted_3$1, [
2693
+ runMeta.value?.subExecution ? (openBlock(), createElementBlock("li", _hoisted_3$1, [
2712
2694
  createBaseVNode("a", {
2713
2695
  href: unref(resolveRelatedExecutionUrl)(runMeta.value),
2714
2696
  target: "_blank",
@@ -2720,18 +2702,18 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2720
2702
  }),
2721
2703
  createTextVNode(" " + toDisplayString(unref(i18n).baseText("runData.openSubExecution", {
2722
2704
  interpolate: {
2723
- id: (_f = runMeta.value.subExecution) == null ? void 0 : _f.executionId
2705
+ id: runMeta.value.subExecution?.executionId
2724
2706
  }
2725
2707
  })), 1)
2726
2708
  ], 8, _hoisted_4)
2727
2709
  ])) : createCommentVNode("", true),
2728
- (((_g = consumedTokensSum.value) == null ? void 0 : _g.totalTokens) ?? 0) > 0 ? (openBlock(), createElementBlock("li", {
2710
+ (consumedTokensSum.value?.totalTokens ?? 0) > 0 ? (openBlock(), createElementBlock("li", {
2729
2711
  key: 3,
2730
2712
  class: normalizeClass(_ctx.$style.tokensUsage)
2731
2713
  }, [
2732
2714
  createTextVNode(toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens", {
2733
2715
  interpolate: {
2734
- count: formatTokenUsageCount(((_h = consumedTokensSum.value) == null ? void 0 : _h.totalTokens) ?? 0)
2716
+ count: formatTokenUsageCount(consumedTokensSum.value?.totalTokens ?? 0)
2735
2717
  }
2736
2718
  })) + " ", 1),
2737
2719
  createVNode(_component_n8n_info_tip, {
@@ -2745,16 +2727,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2745
2727
  bold: true,
2746
2728
  size: "small"
2747
2729
  }, {
2748
- default: withCtx(() => {
2749
- var _a2;
2750
- return [
2751
- createTextVNode(toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens.prompt")) + " " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens", {
2752
- interpolate: {
2753
- count: formatTokenUsageCount(((_a2 = consumedTokensSum.value) == null ? void 0 : _a2.promptTokens) ?? 0)
2754
- }
2755
- })), 1)
2756
- ];
2757
- }),
2730
+ default: withCtx(() => [
2731
+ createTextVNode(toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens.prompt")) + " " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens", {
2732
+ interpolate: {
2733
+ count: formatTokenUsageCount(consumedTokensSum.value?.promptTokens ?? 0)
2734
+ }
2735
+ })), 1)
2736
+ ]),
2758
2737
  _: 1
2759
2738
  }),
2760
2739
  _cache[1] || (_cache[1] = createBaseVNode("br", null, null, -1)),
@@ -2762,16 +2741,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2762
2741
  bold: true,
2763
2742
  size: "small"
2764
2743
  }, {
2765
- default: withCtx(() => {
2766
- var _a2;
2767
- return [
2768
- createTextVNode(toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens.completion")) + " " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens", {
2769
- interpolate: {
2770
- count: formatTokenUsageCount(((_a2 = consumedTokensSum.value) == null ? void 0 : _a2.completionTokens) ?? 0)
2771
- }
2772
- })), 1)
2773
- ];
2774
- }),
2744
+ default: withCtx(() => [
2745
+ createTextVNode(toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens.completion")) + " " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens", {
2746
+ interpolate: {
2747
+ count: formatTokenUsageCount(consumedTokensSum.value?.completionTokens ?? 0)
2748
+ }
2749
+ })), 1)
2750
+ ]),
2775
2751
  _: 1
2776
2752
  })
2777
2753
  ])
@@ -2847,7 +2823,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2847
2823
  return;
2848
2824
  }
2849
2825
  Object.keys(data).map((type) => {
2850
- var _a;
2851
2826
  returnData.push({
2852
2827
  data: data[type][0],
2853
2828
  inOut,
@@ -2855,7 +2830,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2855
2830
  metadata: {
2856
2831
  executionTime: taskData.executionTime,
2857
2832
  startTime: taskData.startTime,
2858
- subExecution: (_a = taskData.metadata) == null ? void 0 : _a.subExecution
2833
+ subExecution: taskData.metadata?.subExecution
2859
2834
  }
2860
2835
  });
2861
2836
  });
@@ -2872,15 +2847,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2872
2847
  node.expanded = !node.expanded;
2873
2848
  }
2874
2849
  function onItemClick(data) {
2875
- var _a, _b;
2876
- const matchingRun = (_a = aiData.value) == null ? void 0 : _a.find(
2850
+ const matchingRun = aiData.value?.find(
2877
2851
  (run) => run.node === data.node && run.runIndex === data.runIndex
2878
2852
  );
2879
2853
  if (!matchingRun) {
2880
2854
  selectedRun.value = [];
2881
2855
  return;
2882
2856
  }
2883
- const selectedNodeRun = (_b = workflowsStore.getWorkflowResultDataByNodeName(data.node)) == null ? void 0 : _b[data.runIndex];
2857
+ const selectedNodeRun = workflowsStore.getWorkflowResultDataByNodeName(data.node)?.[data.runIndex];
2884
2858
  if (!selectedNodeRun) {
2885
2859
  return;
2886
2860
  }
@@ -2897,7 +2871,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2897
2871
  if (!node) {
2898
2872
  return null;
2899
2873
  }
2900
- const nodeType = nodeTypesStore.getNodeType(node == null ? void 0 : node.type);
2874
+ const nodeType = nodeTypesStore.getNodeType(node?.type);
2901
2875
  return nodeType;
2902
2876
  }
2903
2877
  function selectFirst() {
@@ -2905,29 +2879,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2905
2879
  onItemClick(executionTree.value[0].children[0]);
2906
2880
  }
2907
2881
  }
2908
- const createNode = (nodeName, currentDepth, r, children = []) => {
2909
- var _a, _b;
2910
- return {
2911
- node: nodeName,
2912
- id: nodeName,
2913
- depth: currentDepth,
2914
- startTime: ((_b = (_a = r == null ? void 0 : r.data) == null ? void 0 : _a.metadata) == null ? void 0 : _b.startTime) ?? 0,
2915
- runIndex: (r == null ? void 0 : r.runIndex) ?? 0,
2916
- children
2917
- };
2918
- };
2882
+ const createNode = (nodeName, currentDepth, r, children = []) => ({
2883
+ node: nodeName,
2884
+ id: nodeName,
2885
+ depth: currentDepth,
2886
+ startTime: r?.data?.metadata?.startTime ?? 0,
2887
+ runIndex: r?.runIndex ?? 0,
2888
+ children
2889
+ });
2919
2890
  function getTreeNodeData(nodeName, currentDepth) {
2920
- var _a;
2921
2891
  const connections = props.workflow.connectionsByDestinationNode[nodeName];
2922
- const resultData = ((_a = aiData.value) == null ? void 0 : _a.filter((data) => data.node === nodeName)) ?? [];
2892
+ const resultData = aiData.value?.filter((data) => data.node === nodeName) ?? [];
2923
2893
  if (!connections) {
2924
2894
  return resultData.map((d) => createNode(nodeName, currentDepth, d));
2925
2895
  }
2926
2896
  const connectedSubNodes = props.workflow.getParentNodes(nodeName, "ALL_NON_MAIN", 1);
2927
- const children = connectedSubNodes.filter((name) => {
2928
- var _a2;
2929
- return (_a2 = aiData.value) == null ? void 0 : _a2.find((data) => data.node === name);
2930
- }).flatMap((name) => getTreeNodeData(name, currentDepth + 1));
2897
+ const children = connectedSubNodes.filter((name) => aiData.value?.find((data) => data.node === name)).flatMap((name) => getTreeNodeData(name, currentDepth + 1));
2931
2898
  children.sort((a, b) => a.startTime - b.startTime);
2932
2899
  if (resultData.length) {
2933
2900
  return resultData.map((r) => createNode(nodeName, currentDepth, r, children));
@@ -2949,9 +2916,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2949
2916
  });
2950
2917
  });
2951
2918
  result.sort((a, b) => {
2952
- var _a, _b, _c, _d;
2953
- const aTime = ((_b = (_a = a.data) == null ? void 0 : _a.metadata) == null ? void 0 : _b.startTime) ?? 0;
2954
- const bTime = ((_d = (_c = b.data) == null ? void 0 : _c.metadata) == null ? void 0 : _d.startTime) ?? 0;
2919
+ const aTime = a.data?.metadata?.startTime ?? 0;
2920
+ const bTime = b.data?.metadata?.startTime ?? 0;
2955
2921
  return aTime - bTime;
2956
2922
  });
2957
2923
  return result;
@@ -3111,8 +3077,7 @@ function useNodeType(options = {}) {
3111
3077
  });
3112
3078
  const isSubNodeType$1 = computed(() => isSubNodeType(nodeType.value));
3113
3079
  const isMultipleOutputsNodeType = computed(() => {
3114
- var _a;
3115
- const outputs = (_a = nodeType.value) == null ? void 0 : _a.outputs;
3080
+ const outputs = nodeType.value?.outputs;
3116
3081
  if (typeof outputs === "string") return false;
3117
3082
  return (outputs ?? []).length > 1;
3118
3083
  });
@@ -3244,13 +3209,13 @@ function usePinnedData(node, options = {}) {
3244
3209
  }
3245
3210
  return true;
3246
3211
  }
3247
- function onSetDataSuccess({ source: source2 }) {
3212
+ function onSetDataSuccess({ source }) {
3248
3213
  const targetNode = unref(node);
3249
3214
  const displayMode = unref(options.displayMode);
3250
3215
  const runIndex = unref(options.runIndex);
3251
3216
  const telemetryPayload = {
3252
- pinning_source: source2,
3253
- node_type: targetNode == null ? void 0 : targetNode.type,
3217
+ pinning_source: source,
3218
+ node_type: targetNode?.type,
3254
3219
  push_ref: rootStore.pushRef,
3255
3220
  data_size: stringSizeInBytes(data.value),
3256
3221
  view: displayMode,
@@ -3261,14 +3226,14 @@ function usePinnedData(node, options = {}) {
3261
3226
  }
3262
3227
  function onSetDataError({
3263
3228
  errorType,
3264
- source: source2
3229
+ source
3265
3230
  }) {
3266
3231
  const targetNode = unref(node);
3267
3232
  const displayMode = unref(options.displayMode);
3268
3233
  const runIndex = unref(options.runIndex);
3269
3234
  telemetry.track("Ndv data pinning failure", {
3270
- pinning_source: source2,
3271
- node_type: targetNode == null ? void 0 : targetNode.type,
3235
+ pinning_source: source,
3236
+ node_type: targetNode?.type,
3272
3237
  push_ref: rootStore.pushRef,
3273
3238
  data_size: stringSizeInBytes(data.value),
3274
3239
  view: displayMode,
@@ -3276,42 +3241,42 @@ function usePinnedData(node, options = {}) {
3276
3241
  error_type: errorType
3277
3242
  });
3278
3243
  }
3279
- function setData(data2, source2) {
3244
+ function setData(data2, source) {
3280
3245
  const targetNode = unref(node);
3281
3246
  if (!targetNode) {
3282
3247
  return;
3283
3248
  }
3284
3249
  if (typeof data2 === "string") {
3285
3250
  if (!isValidJSON(data2)) {
3286
- onSetDataError({ errorType: "invalid-json", source: source2 });
3251
+ onSetDataError({ errorType: "invalid-json", source });
3287
3252
  throw new Error("Invalid JSON");
3288
3253
  }
3289
3254
  data2 = jsonParse(data2);
3290
3255
  }
3291
3256
  if (!isValidSize(data2)) {
3292
- onSetDataError({ errorType: "data-too-large", source: source2 });
3257
+ onSetDataError({ errorType: "data-too-large", source });
3293
3258
  throw new Error("Data too large");
3294
3259
  }
3295
3260
  workflowsStore.pinData({ node: targetNode, data: data2 });
3296
- onSetDataSuccess({ source: source2 });
3261
+ onSetDataSuccess({ source });
3297
3262
  }
3298
- function onUnsetData({ source: source2 }) {
3263
+ function onUnsetData({ source }) {
3299
3264
  const targetNode = unref(node);
3300
3265
  const runIndex = unref(options.runIndex);
3301
3266
  telemetry.track("User unpinned ndv data", {
3302
- node_type: targetNode == null ? void 0 : targetNode.type,
3267
+ node_type: targetNode?.type,
3303
3268
  push_ref: rootStore.pushRef,
3304
3269
  run_index: runIndex,
3305
- source: source2,
3270
+ source,
3306
3271
  data_size: stringSizeInBytes(data.value)
3307
3272
  });
3308
3273
  }
3309
- function unsetData(source2) {
3274
+ function unsetData(source) {
3310
3275
  const targetNode = unref(node);
3311
3276
  if (!targetNode) {
3312
3277
  return;
3313
3278
  }
3314
- onUnsetData({ source: source2 });
3279
+ onUnsetData({ source });
3315
3280
  workflowsStore.unpinData({ node: targetNode });
3316
3281
  }
3317
3282
  return {
@@ -3374,7 +3339,6 @@ function useRunWorkflow(useRunWorkflowOpts) {
3374
3339
  return response;
3375
3340
  }
3376
3341
  async function runWorkflow(options) {
3377
- var _a, _b, _c, _d, _e, _f;
3378
3342
  const workflow = workflowHelpers.getCurrentWorkflow();
3379
3343
  if (uiStore.isActionActive["workflowRunning"]) {
3380
3344
  return;
@@ -3401,26 +3365,29 @@ function useRunWorkflow(useRunWorkflowOpts) {
3401
3365
  workflow
3402
3366
  );
3403
3367
  const { startNodeNames } = consolidatedData;
3404
- const destinationNodeType = options.destinationNode ? (_a = workflowsStore.getNodeByName(options.destinationNode)) == null ? void 0 : _a.type : "";
3368
+ const destinationNodeType = options.destinationNode ? workflowsStore.getNodeByName(options.destinationNode)?.type : "";
3405
3369
  let { runData: newRunData } = consolidatedData;
3406
3370
  let executedNode;
3371
+ let triggerToStartFrom;
3407
3372
  if (startNodeNames.length === 0 && "destinationNode" in options && options.destinationNode !== void 0) {
3408
3373
  executedNode = options.destinationNode;
3409
3374
  startNodeNames.push(options.destinationNode);
3410
- } else if ("triggerNode" in options && "nodeData" in options) {
3375
+ } else if (options.triggerNode && options.nodeData) {
3411
3376
  startNodeNames.push(
3412
3377
  ...workflow.getChildNodes(options.triggerNode, NodeConnectionType.Main, 1)
3413
3378
  );
3414
- newRunData = {
3415
- [options.triggerNode]: [options.nodeData]
3416
- };
3379
+ newRunData = { [options.triggerNode]: [options.nodeData] };
3417
3380
  executedNode = options.triggerNode;
3381
+ triggerToStartFrom = {
3382
+ name: options.triggerNode,
3383
+ data: options.nodeData
3384
+ };
3418
3385
  }
3419
3386
  if (options.destinationNode && (workflowsStore.checkIfNodeHasChatParent(options.destinationNode) || destinationNodeType === CHAT_TRIGGER_NODE_TYPE)) {
3420
3387
  const startNode = workflow.getStartNode(options.destinationNode);
3421
3388
  if (startNode && startNode.type === CHAT_TRIGGER_NODE_TYPE) {
3422
- const chatHasInputData = ((_b = nodeHelpers.getNodeInputData(startNode, 0, 0, "input")) == null ? void 0 : _b.length) > 0;
3423
- const chatHasPinData = !!((_c = workflowData.pinData) == null ? void 0 : _c[startNode.name]);
3389
+ const chatHasInputData = nodeHelpers.getNodeInputData(startNode, 0, 0, "input")?.length > 0;
3390
+ const chatHasPinData = !!workflowData.pinData?.[startNode.name];
3424
3391
  if (!chatHasInputData && !chatHasPinData) {
3425
3392
  workflowsStore.setPanelOpen("chat", true);
3426
3393
  return;
@@ -3477,7 +3444,8 @@ function useRunWorkflow(useRunWorkflowOpts) {
3477
3444
  // With the new partial execution version the backend decides what run
3478
3445
  // data to use and what to ignore.
3479
3446
  runData: partialExecutionVersion.value === 1 ? runData2 ?? void 0 : newRunData,
3480
- startNodes
3447
+ startNodes,
3448
+ triggerToStartFrom
3481
3449
  };
3482
3450
  if ("destinationNode" in options) {
3483
3451
  startRunData.destinationNode = options.destinationNode;
@@ -3521,15 +3489,14 @@ function useRunWorkflow(useRunWorkflowOpts) {
3521
3489
  const pinData = workflowData.pinData ?? {};
3522
3490
  const getTestUrl = /* @__PURE__ */ (() => {
3523
3491
  return (node) => {
3524
- var _a2;
3525
- const path = node.parameters.path || ((_a2 = node.parameters.options) == null ? void 0 : _a2.path) || node.webhookId;
3492
+ const path = node.parameters.path || node.parameters.options?.path || node.webhookId;
3526
3493
  return `${rootStore.formTestUrl}/${path}`;
3527
3494
  };
3528
3495
  })();
3529
3496
  try {
3530
3497
  displayForm({
3531
3498
  nodes: workflowData.nodes,
3532
- runData: (_f = (_e = (_d = workflowsStore.getWorkflowExecution) == null ? void 0 : _d.data) == null ? void 0 : _e.resultData) == null ? void 0 : _f.runData,
3499
+ runData: workflowsStore.getWorkflowExecution?.data?.resultData?.runData,
3533
3500
  destinationNode: options.destinationNode,
3534
3501
  pinData,
3535
3502
  directParentNodes,
@@ -3550,7 +3517,6 @@ function useRunWorkflow(useRunWorkflowOpts) {
3550
3517
  }
3551
3518
  }
3552
3519
  function consolidateRunDataAndStartNodes(directParentNodes, runData2, pinData, workflow) {
3553
- var _a, _b, _c, _d, _e, _f, _g;
3554
3520
  const startNodeNames = /* @__PURE__ */ new Set();
3555
3521
  let newRunData;
3556
3522
  if (runData2 !== null && Object.keys(runData2).length !== 0) {
@@ -3560,12 +3526,12 @@ function useRunWorkflow(useRunWorkflowOpts) {
3560
3526
  if (workflow.nodes[directParentNode].disabled) continue;
3561
3527
  parentNodes.push(directParentNode);
3562
3528
  for (const parentNode of parentNodes) {
3563
- if (!((_a = runData2[parentNode]) == null ? void 0 : _a.length) && !((_b = pinData == null ? void 0 : pinData[parentNode]) == null ? void 0 : _b.length) || ((_d = (_c = runData2[parentNode]) == null ? void 0 : _c[0]) == null ? void 0 : _d.error) !== void 0) {
3529
+ if (!runData2[parentNode]?.length && !pinData?.[parentNode]?.length || runData2[parentNode]?.[0]?.error !== void 0) {
3564
3530
  startNodeNames.add(parentNode);
3565
3531
  break;
3566
3532
  }
3567
- if (runData2[parentNode] && !((_f = (_e = runData2[parentNode]) == null ? void 0 : _e[0]) == null ? void 0 : _f.error)) {
3568
- newRunData[parentNode] = (_g = runData2[parentNode]) == null ? void 0 : _g.slice(0, 1);
3533
+ if (runData2[parentNode] && !runData2[parentNode]?.[0]?.error) {
3534
+ newRunData[parentNode] = runData2[parentNode]?.slice(0, 1);
3569
3535
  }
3570
3536
  }
3571
3537
  }
@@ -3590,7 +3556,7 @@ function useRunWorkflow(useRunWorkflowOpts) {
3590
3556
  message: i18n.baseText("nodeView.showMessage.stopExecutionCatch.unsaved.message"),
3591
3557
  type: "success"
3592
3558
  });
3593
- } else if (execution == null ? void 0 : execution.finished) {
3559
+ } else if (execution?.finished) {
3594
3560
  const executedData = {
3595
3561
  data: execution.data,
3596
3562
  finished: execution.finished,