@mcp-graph-workflow/mcp-graph 5.32.0 → 5.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/dist/api/router.d.ts.map +1 -1
  2. package/dist/api/router.js +2 -0
  3. package/dist/api/router.js.map +1 -1
  4. package/dist/api/routes/code-graph.d.ts.map +1 -1
  5. package/dist/api/routes/code-graph.js +3 -1
  6. package/dist/api/routes/code-graph.js.map +1 -1
  7. package/dist/api/routes/davinci.d.ts +3 -0
  8. package/dist/api/routes/davinci.d.ts.map +1 -0
  9. package/dist/api/routes/davinci.js +188 -0
  10. package/dist/api/routes/davinci.js.map +1 -0
  11. package/dist/core/analyzer/ac-coverage.d.ts +16 -0
  12. package/dist/core/analyzer/ac-coverage.d.ts.map +1 -0
  13. package/dist/core/analyzer/ac-coverage.js +38 -0
  14. package/dist/core/analyzer/ac-coverage.js.map +1 -0
  15. package/dist/core/analyzer/asset-blockers.d.ts +23 -0
  16. package/dist/core/analyzer/asset-blockers.d.ts.map +1 -0
  17. package/dist/core/analyzer/asset-blockers.js +50 -0
  18. package/dist/core/analyzer/asset-blockers.js.map +1 -0
  19. package/dist/core/analyzer/concurrency-risk.d.ts +26 -0
  20. package/dist/core/analyzer/concurrency-risk.d.ts.map +1 -0
  21. package/dist/core/analyzer/concurrency-risk.js +99 -0
  22. package/dist/core/analyzer/concurrency-risk.js.map +1 -0
  23. package/dist/core/analyzer/config-coverage.d.ts +20 -0
  24. package/dist/core/analyzer/config-coverage.d.ts.map +1 -0
  25. package/dist/core/analyzer/config-coverage.js +49 -0
  26. package/dist/core/analyzer/config-coverage.js.map +1 -0
  27. package/dist/core/analyzer/contract-coverage.d.ts +22 -0
  28. package/dist/core/analyzer/contract-coverage.d.ts.map +1 -0
  29. package/dist/core/analyzer/contract-coverage.js +51 -0
  30. package/dist/core/analyzer/contract-coverage.js.map +1 -0
  31. package/dist/core/analyzer/data-integrity.d.ts +22 -0
  32. package/dist/core/analyzer/data-integrity.d.ts.map +1 -0
  33. package/dist/core/analyzer/data-integrity.js +80 -0
  34. package/dist/core/analyzer/data-integrity.js.map +1 -0
  35. package/dist/core/analyzer/economy-simulator.d.ts +33 -0
  36. package/dist/core/analyzer/economy-simulator.d.ts.map +1 -0
  37. package/dist/core/analyzer/economy-simulator.js +162 -0
  38. package/dist/core/analyzer/economy-simulator.js.map +1 -0
  39. package/dist/core/analyzer/formula-consistency.d.ts +25 -0
  40. package/dist/core/analyzer/formula-consistency.d.ts.map +1 -0
  41. package/dist/core/analyzer/formula-consistency.js +82 -0
  42. package/dist/core/analyzer/formula-consistency.js.map +1 -0
  43. package/dist/core/analyzer/metric-coverage.d.ts +22 -0
  44. package/dist/core/analyzer/metric-coverage.d.ts.map +1 -0
  45. package/dist/core/analyzer/metric-coverage.js +52 -0
  46. package/dist/core/analyzer/metric-coverage.js.map +1 -0
  47. package/dist/core/analyzer/performance-budget-check.d.ts +22 -0
  48. package/dist/core/analyzer/performance-budget-check.d.ts.map +1 -0
  49. package/dist/core/analyzer/performance-budget-check.js +40 -0
  50. package/dist/core/analyzer/performance-budget-check.js.map +1 -0
  51. package/dist/core/analyzer/risk-assessment.d.ts.map +1 -1
  52. package/dist/core/analyzer/risk-assessment.js +9 -0
  53. package/dist/core/analyzer/risk-assessment.js.map +1 -1
  54. package/dist/core/analyzer/scenario-coverage.d.ts +19 -0
  55. package/dist/core/analyzer/scenario-coverage.d.ts.map +1 -0
  56. package/dist/core/analyzer/scenario-coverage.js +59 -0
  57. package/dist/core/analyzer/scenario-coverage.js.map +1 -0
  58. package/dist/core/analyzer/state-completeness.d.ts +22 -0
  59. package/dist/core/analyzer/state-completeness.d.ts.map +1 -0
  60. package/dist/core/analyzer/state-completeness.js +76 -0
  61. package/dist/core/analyzer/state-completeness.js.map +1 -0
  62. package/dist/core/code/code-indexer.d.ts +1 -1
  63. package/dist/core/code/code-indexer.d.ts.map +1 -1
  64. package/dist/core/code/code-indexer.js +50 -3
  65. package/dist/core/code/code-indexer.js.map +1 -1
  66. package/dist/core/code/code-store.js +3 -3
  67. package/dist/core/code/code-store.js.map +1 -1
  68. package/dist/core/code/code-types.d.ts +4 -4
  69. package/dist/core/code/treesitter/treesitter-manager.d.ts.map +1 -1
  70. package/dist/core/code/treesitter/treesitter-manager.js +2 -0
  71. package/dist/core/code/treesitter/treesitter-manager.js.map +1 -1
  72. package/dist/core/davinci/build-runner.d.ts +37 -0
  73. package/dist/core/davinci/build-runner.d.ts.map +1 -0
  74. package/dist/core/davinci/build-runner.js +239 -0
  75. package/dist/core/davinci/build-runner.js.map +1 -0
  76. package/dist/core/davinci/davinci-parser.d.ts +6 -0
  77. package/dist/core/davinci/davinci-parser.d.ts.map +1 -0
  78. package/dist/core/davinci/davinci-parser.js +218 -0
  79. package/dist/core/davinci/davinci-parser.js.map +1 -0
  80. package/dist/core/davinci/davinci-store.d.ts +49 -0
  81. package/dist/core/davinci/davinci-store.d.ts.map +1 -0
  82. package/dist/core/davinci/davinci-store.js +121 -0
  83. package/dist/core/davinci/davinci-store.js.map +1 -0
  84. package/dist/core/davinci/davinci-types.d.ts +241 -0
  85. package/dist/core/davinci/davinci-types.d.ts.map +1 -0
  86. package/dist/core/davinci/davinci-types.js +123 -0
  87. package/dist/core/davinci/davinci-types.js.map +1 -0
  88. package/dist/core/davinci/davinci-validators.d.ts +16 -0
  89. package/dist/core/davinci/davinci-validators.d.ts.map +1 -0
  90. package/dist/core/davinci/davinci-validators.js +86 -0
  91. package/dist/core/davinci/davinci-validators.js.map +1 -0
  92. package/dist/core/davinci/descriptor-generator.d.ts +19 -0
  93. package/dist/core/davinci/descriptor-generator.d.ts.map +1 -0
  94. package/dist/core/davinci/descriptor-generator.js +52 -0
  95. package/dist/core/davinci/descriptor-generator.js.map +1 -0
  96. package/dist/core/davinci/plugin-generator.d.ts +29 -0
  97. package/dist/core/davinci/plugin-generator.d.ts.map +1 -0
  98. package/dist/core/davinci/plugin-generator.js +86 -0
  99. package/dist/core/davinci/plugin-generator.js.map +1 -0
  100. package/dist/core/davinci/plugin-type-detector.d.ts +15 -0
  101. package/dist/core/davinci/plugin-type-detector.d.ts.map +1 -0
  102. package/dist/core/davinci/plugin-type-detector.js +114 -0
  103. package/dist/core/davinci/plugin-type-detector.js.map +1 -0
  104. package/dist/core/davinci/pom-generator.d.ts +4 -0
  105. package/dist/core/davinci/pom-generator.d.ts.map +1 -0
  106. package/dist/core/davinci/pom-generator.js +179 -0
  107. package/dist/core/davinci/pom-generator.js.map +1 -0
  108. package/dist/core/davinci/template-registry.d.ts +25 -0
  109. package/dist/core/davinci/template-registry.d.ts.map +1 -0
  110. package/dist/core/davinci/template-registry.js +280 -0
  111. package/dist/core/davinci/template-registry.js.map +1 -0
  112. package/dist/core/davinci/variable-resolver.d.ts +9 -0
  113. package/dist/core/davinci/variable-resolver.d.ts.map +1 -0
  114. package/dist/core/davinci/variable-resolver.js +62 -0
  115. package/dist/core/davinci/variable-resolver.js.map +1 -0
  116. package/dist/core/designer/adr-validator.d.ts.map +1 -1
  117. package/dist/core/designer/adr-validator.js +12 -4
  118. package/dist/core/designer/adr-validator.js.map +1 -1
  119. package/dist/core/designer/tech-risk-assessor.d.ts +5 -1
  120. package/dist/core/designer/tech-risk-assessor.d.ts.map +1 -1
  121. package/dist/core/designer/tech-risk-assessor.js +39 -11
  122. package/dist/core/designer/tech-risk-assessor.js.map +1 -1
  123. package/dist/core/designer/traceability-matrix.d.ts.map +1 -1
  124. package/dist/core/designer/traceability-matrix.js +14 -3
  125. package/dist/core/designer/traceability-matrix.js.map +1 -1
  126. package/dist/core/graph/auto-sequence.d.ts +10 -0
  127. package/dist/core/graph/auto-sequence.d.ts.map +1 -0
  128. package/dist/core/graph/auto-sequence.js +29 -0
  129. package/dist/core/graph/auto-sequence.js.map +1 -0
  130. package/dist/core/graph/csv-export.d.ts +7 -0
  131. package/dist/core/graph/csv-export.d.ts.map +1 -0
  132. package/dist/core/graph/csv-export.js +43 -0
  133. package/dist/core/graph/csv-export.js.map +1 -0
  134. package/dist/core/graph/graph-types.d.ts +2 -2
  135. package/dist/core/graph/graph-types.d.ts.map +1 -1
  136. package/dist/core/graph/mermaid-export.d.ts +1 -1
  137. package/dist/core/graph/mermaid-export.d.ts.map +1 -1
  138. package/dist/core/graph/mermaid-export.js +101 -0
  139. package/dist/core/graph/mermaid-export.js.map +1 -1
  140. package/dist/core/importer/prd-to-graph.d.ts.map +1 -1
  141. package/dist/core/importer/prd-to-graph.js +8 -1
  142. package/dist/core/importer/prd-to-graph.js.map +1 -1
  143. package/dist/core/listener/backlog-health.d.ts.map +1 -1
  144. package/dist/core/listener/backlog-health.js +15 -3
  145. package/dist/core/listener/backlog-health.js.map +1 -1
  146. package/dist/core/parser/classify.d.ts +4 -0
  147. package/dist/core/parser/classify.d.ts.map +1 -1
  148. package/dist/core/parser/classify.js +18 -0
  149. package/dist/core/parser/classify.js.map +1 -1
  150. package/dist/core/parser/extract.d.ts.map +1 -1
  151. package/dist/core/parser/extract.js +22 -4
  152. package/dist/core/parser/extract.js.map +1 -1
  153. package/dist/core/parser/prd-diff.d.ts +23 -0
  154. package/dist/core/parser/prd-diff.d.ts.map +1 -0
  155. package/dist/core/parser/prd-diff.js +55 -0
  156. package/dist/core/parser/prd-diff.js.map +1 -0
  157. package/dist/core/parser/read-swagger.d.ts.map +1 -1
  158. package/dist/core/parser/read-swagger.js +6 -0
  159. package/dist/core/parser/read-swagger.js.map +1 -1
  160. package/dist/core/parser/segment.d.ts +5 -0
  161. package/dist/core/parser/segment.d.ts.map +1 -1
  162. package/dist/core/parser/segment.js +70 -0
  163. package/dist/core/parser/segment.js.map +1 -1
  164. package/dist/core/planner/auto-ready.d.ts +19 -0
  165. package/dist/core/planner/auto-ready.d.ts.map +1 -0
  166. package/dist/core/planner/auto-ready.js +39 -0
  167. package/dist/core/planner/auto-ready.js.map +1 -0
  168. package/dist/core/planner/planning-report.d.ts +13 -1
  169. package/dist/core/planner/planning-report.d.ts.map +1 -1
  170. package/dist/core/planner/planning-report.js +53 -2
  171. package/dist/core/planner/planning-report.js.map +1 -1
  172. package/dist/core/planner/sprint-health.d.ts +22 -0
  173. package/dist/core/planner/sprint-health.d.ts.map +1 -0
  174. package/dist/core/planner/sprint-health.js +41 -0
  175. package/dist/core/planner/sprint-health.js.map +1 -0
  176. package/dist/core/siebel/sif-parser.d.ts.map +1 -1
  177. package/dist/core/siebel/sif-parser.js +6 -0
  178. package/dist/core/siebel/sif-parser.js.map +1 -1
  179. package/dist/core/siebel/wsdl-parser.d.ts.map +1 -1
  180. package/dist/core/siebel/wsdl-parser.js +6 -0
  181. package/dist/core/siebel/wsdl-parser.js.map +1 -1
  182. package/dist/core/store/migrations.d.ts.map +1 -1
  183. package/dist/core/store/migrations.js +17 -0
  184. package/dist/core/store/migrations.js.map +1 -1
  185. package/dist/core/store/sqlite-store.d.ts +6 -0
  186. package/dist/core/store/sqlite-store.d.ts.map +1 -1
  187. package/dist/core/store/sqlite-store.js +54 -3
  188. package/dist/core/store/sqlite-store.js.map +1 -1
  189. package/dist/core/templates/template-engine.d.ts +36 -0
  190. package/dist/core/templates/template-engine.d.ts.map +1 -0
  191. package/dist/core/templates/template-engine.js +104 -0
  192. package/dist/core/templates/template-engine.js.map +1 -0
  193. package/dist/core/translation/generators/universal-generator.d.ts.map +1 -1
  194. package/dist/core/translation/generators/universal-generator.js +187 -9
  195. package/dist/core/translation/generators/universal-generator.js.map +1 -1
  196. package/dist/core/translation/language-detect.d.ts.map +1 -1
  197. package/dist/core/translation/language-detect.js +37 -14
  198. package/dist/core/translation/language-detect.js.map +1 -1
  199. package/dist/docs-manifest.json +68 -5
  200. package/dist/mcp/app-factory.js +1 -1
  201. package/dist/mcp/app-factory.js.map +1 -1
  202. package/dist/mcp/tools/analyze.d.ts.map +1 -1
  203. package/dist/mcp/tools/analyze.js +100 -1
  204. package/dist/mcp/tools/analyze.js.map +1 -1
  205. package/dist/mcp/tools/davinci-analyze.d.ts +4 -0
  206. package/dist/mcp/tools/davinci-analyze.d.ts.map +1 -0
  207. package/dist/mcp/tools/davinci-analyze.js +31 -0
  208. package/dist/mcp/tools/davinci-analyze.js.map +1 -0
  209. package/dist/mcp/tools/davinci-build.d.ts +4 -0
  210. package/dist/mcp/tools/davinci-build.d.ts.map +1 -0
  211. package/dist/mcp/tools/davinci-build.js +43 -0
  212. package/dist/mcp/tools/davinci-build.js.map +1 -0
  213. package/dist/mcp/tools/davinci-convert.d.ts +4 -0
  214. package/dist/mcp/tools/davinci-convert.d.ts.map +1 -0
  215. package/dist/mcp/tools/davinci-convert.js +61 -0
  216. package/dist/mcp/tools/davinci-convert.js.map +1 -0
  217. package/dist/mcp/tools/edge.d.ts.map +1 -1
  218. package/dist/mcp/tools/edge.js +81 -3
  219. package/dist/mcp/tools/edge.js.map +1 -1
  220. package/dist/mcp/tools/export.d.ts.map +1 -1
  221. package/dist/mcp/tools/export.js +17 -4
  222. package/dist/mcp/tools/export.js.map +1 -1
  223. package/dist/mcp/tools/import-prd.d.ts.map +1 -1
  224. package/dist/mcp/tools/import-prd.js +89 -2
  225. package/dist/mcp/tools/import-prd.js.map +1 -1
  226. package/dist/mcp/tools/index.d.ts.map +1 -1
  227. package/dist/mcp/tools/index.js +12 -0
  228. package/dist/mcp/tools/index.js.map +1 -1
  229. package/dist/mcp/tools/node.d.ts.map +1 -1
  230. package/dist/mcp/tools/node.js +127 -6
  231. package/dist/mcp/tools/node.js.map +1 -1
  232. package/dist/mcp/tools/plan-sprint.d.ts.map +1 -1
  233. package/dist/mcp/tools/plan-sprint.js +6 -2
  234. package/dist/mcp/tools/plan-sprint.js.map +1 -1
  235. package/dist/mcp/tools/show.d.ts.map +1 -1
  236. package/dist/mcp/tools/show.js +11 -4
  237. package/dist/mcp/tools/show.js.map +1 -1
  238. package/dist/mcp/tools/template.d.ts +4 -0
  239. package/dist/mcp/tools/template.d.ts.map +1 -0
  240. package/dist/mcp/tools/template.js +137 -0
  241. package/dist/mcp/tools/template.js.map +1 -0
  242. package/dist/schemas/analyzer-schema.d.ts +2 -2
  243. package/dist/schemas/designer-schema.d.ts +21 -0
  244. package/dist/schemas/designer-schema.d.ts.map +1 -1
  245. package/dist/schemas/designer-schema.js +2 -0
  246. package/dist/schemas/designer-schema.js.map +1 -1
  247. package/dist/schemas/edge.schema.d.ts +6 -0
  248. package/dist/schemas/edge.schema.d.ts.map +1 -1
  249. package/dist/schemas/edge.schema.js +2 -0
  250. package/dist/schemas/edge.schema.js.map +1 -1
  251. package/dist/schemas/graph.schema.d.ts +13 -0
  252. package/dist/schemas/graph.schema.d.ts.map +1 -1
  253. package/dist/schemas/node.schema.d.ts +20 -0
  254. package/dist/schemas/node.schema.d.ts.map +1 -1
  255. package/dist/schemas/node.schema.js +3 -0
  256. package/dist/schemas/node.schema.js.map +1 -1
  257. package/dist/schemas/siebel.schema.d.ts +13 -13
  258. package/dist/web/dashboard/dist/assets/{benchmark-tab-en-UkR66.js → benchmark-tab-Aqr2Xzu5.js} +1 -1
  259. package/dist/web/dashboard/dist/assets/{circle-alert-5GIBBP3L.js → circle-alert-BJTyaShp.js} +1 -1
  260. package/dist/web/dashboard/dist/assets/constants-DLyESMjx.js +1 -0
  261. package/dist/web/dashboard/dist/assets/{context-tab-DjfwQik8.js → context-tab-CbmHGGZh.js} +1 -1
  262. package/dist/web/dashboard/dist/assets/davinci-tab-krxsY7Pp.js +10 -0
  263. package/dist/web/dashboard/dist/assets/{docs-tab-gEBzBEEV.js → docs-tab-AautK0dL.js} +1 -1
  264. package/dist/web/dashboard/dist/assets/file-code-DVOtQrhl.js +11 -0
  265. package/dist/web/dashboard/dist/assets/{gitnexus-tab-BE2pi0xe.js → gitnexus-tab-D5xRYU3u.js} +1 -1
  266. package/dist/web/dashboard/dist/assets/{graph-section-Cwx-Bmeh.js → graph-section-D5y4S3T1.js} +1 -1
  267. package/dist/web/dashboard/dist/assets/{graph-tab-BcS75lY0.js → graph-tab-tmjyMc4q.js} +1 -1
  268. package/dist/web/dashboard/dist/assets/{graph-utils-OY_fOvB3.js → graph-utils-BlwoHdjR.js} +1 -1
  269. package/dist/web/dashboard/dist/assets/index-BcMjWikL.css +1 -0
  270. package/dist/web/dashboard/dist/assets/{index-4X4gmCkA.js → index-C13O-yj1.js} +1 -1
  271. package/dist/web/dashboard/dist/assets/{index-1aGs8JPI.js → index-CAOXRHQq.js} +1 -1
  272. package/dist/web/dashboard/dist/assets/{index-C3Kad9YO.js → index-DrvFzUJS.js} +24 -19
  273. package/dist/web/dashboard/dist/assets/{insights-tab-CP2uIpid.js → insights-tab-9sq9NfBt.js} +1 -1
  274. package/dist/web/dashboard/dist/assets/{journey-tab-ChwNK_8S.js → journey-tab-ujeAoAsS.js} +1 -1
  275. package/dist/web/dashboard/dist/assets/{languages-tab-DnBvSh4N.js → languages-tab-DT-46f7p.js} +24 -39
  276. package/dist/web/dashboard/dist/assets/{loader-circle-Bxe_TLXv.js → loader-circle-DQz_g7p_.js} +1 -1
  277. package/dist/web/dashboard/dist/assets/{logs-tab-BH86QvKe.js → logs-tab-DHj9jG6G.js} +1 -1
  278. package/dist/web/dashboard/dist/assets/{lsp-tab-DUpaQXtx.js → lsp-tab-DGIm2cTM.js} +3 -3
  279. package/dist/web/dashboard/dist/assets/{memories-tab-CkwtNv3t.js → memories-tab-DT7JcHgq.js} +1 -1
  280. package/dist/web/dashboard/dist/assets/{prd-backlog-tab-CPJanaVF.js → prd-backlog-tab-CLzQ5p_3.js} +1 -1
  281. package/dist/web/dashboard/dist/assets/{refresh-cw-DL1dUrhF.js → refresh-cw-C0EeXZ6n.js} +1 -1
  282. package/dist/web/dashboard/dist/assets/{siebel-tab-D7x34UXy.js → siebel-tab-67cdoYQ_.js} +3 -3
  283. package/dist/web/dashboard/dist/assets/{sif-parse.worker-DZrybOHz.js → sif-parse.worker-Cty_N-lP.js} +3 -3
  284. package/dist/web/dashboard/dist/assets/{skills-tab-BuqCMS29.js → skills-tab-DL8-pMo9.js} +1 -1
  285. package/dist/web/dashboard/dist/assets/{style-iy_ryTT6.js → style-DeKQIW_i.js} +1 -1
  286. package/dist/web/dashboard/dist/assets/triangle-alert-cibtv50e.js +16 -0
  287. package/dist/web/dashboard/dist/assets/upload-CZI9Zosi.js +16 -0
  288. package/dist/web/dashboard/dist/index.html +2 -2
  289. package/package.json +3 -1
  290. package/dist/web/dashboard/dist/assets/constants-Dd6A34aQ.js +0 -1
  291. package/dist/web/dashboard/dist/assets/index-BVhCKhGJ.css +0 -1
  292. package/dist/web/dashboard/dist/assets/triangle-alert-CPzksLkC.js +0 -26
@@ -1,4 +1,4 @@
1
- (function(){"use strict";const U=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",te=U+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",ne="["+U+"]["+te+"]*",se=new RegExp("^"+ne+"$");function W(n,e){const t=[];let s=e.exec(n);for(;s;){const i=[];i.startIndex=e.lastIndex-s[0].length;const r=s.length;for(let u=0;u<r;u++)i.push(s[u]);t.push(i),s=e.exec(n)}return t}const x=function(n){const e=se.exec(n);return!(e===null||typeof e>"u")};function re(n){return typeof n<"u"}const k=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Y=["__proto__","constructor","prototype"],ie={allowBooleanAttributes:!1,unpairedTags:[]};function oe(n,e){e=Object.assign({},ie,e);const t=[];let s=!1,i=!1;n[0]==="\uFEFF"&&(n=n.substr(1));for(let r=0;r<n.length;r++)if(n[r]==="<"&&n[r+1]==="?"){if(r+=2,r=G(n,r),r.err)return r}else if(n[r]==="<"){let u=r;if(r++,n[r]==="!"){r=X(n,r);continue}else{let a=!1;n[r]==="/"&&(a=!0,r++);let o="";for(;r<n.length&&n[r]!==">"&&n[r]!==" "&&n[r]!==" "&&n[r]!==`
1
+ (function(){"use strict";const U=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",te=U+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",ne="["+U+"]["+te+"]*",se=new RegExp("^"+ne+"$");function W(n,e){const t=[];let s=e.exec(n);for(;s;){const i=[];i.startIndex=e.lastIndex-s[0].length;const r=s.length;for(let u=0;u<r;u++)i.push(s[u]);t.push(i),s=e.exec(n)}return t}const M=function(n){const e=se.exec(n);return!(e===null||typeof e>"u")};function re(n){return typeof n<"u"}const k=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Y=["__proto__","constructor","prototype"],ie={allowBooleanAttributes:!1,unpairedTags:[]};function oe(n,e){e=Object.assign({},ie,e);const t=[];let s=!1,i=!1;n[0]==="\uFEFF"&&(n=n.substr(1));for(let r=0;r<n.length;r++)if(n[r]==="<"&&n[r+1]==="?"){if(r+=2,r=G(n,r),r.err)return r}else if(n[r]==="<"){let u=r;if(r++,n[r]==="!"){r=X(n,r);continue}else{let a=!1;n[r]==="/"&&(a=!0,r++);let o="";for(;r<n.length&&n[r]!==">"&&n[r]!==" "&&n[r]!==" "&&n[r]!==`
2
2
  `&&n[r]!=="\r";r++)o+=n[r];if(o=o.trim(),o[o.length-1]==="/"&&(o=o.substring(0,o.length-1),r--),!de(o)){let c;return o.trim().length===0?c="Invalid space after '<'.":c="Tag '"+o+"' is an invalid name.",h("InvalidTag",c,g(n,r))}const f=le(n,r);if(f===!1)return h("InvalidAttr","Attributes for '"+o+"' have open quote.",g(n,r));let l=f.value;if(r=f.index,l[l.length-1]==="/"){const c=r-l.length;l=l.substring(0,l.length-1);const p=Z(l,e);if(p===!0)s=!0;else return h(p.err.code,p.err.msg,g(n,c+p.err.line))}else if(a)if(f.tagClosed){if(l.trim().length>0)return h("InvalidTag","Closing tag '"+o+"' can't have attributes or invalid starting.",g(n,u));if(t.length===0)return h("InvalidTag","Closing tag '"+o+"' has not been opened.",g(n,u));{const c=t.pop();if(o!==c.tagName){let p=g(n,c.tagStartPos);return h("InvalidTag","Expected closing tag '"+c.tagName+"' (opened in line "+p.line+", col "+p.col+") instead of closing tag '"+o+"'.",g(n,u))}t.length==0&&(i=!0)}}else return h("InvalidTag","Closing tag '"+o+"' doesn't have proper closing.",g(n,r));else{const c=Z(l,e);if(c!==!0)return h(c.err.code,c.err.msg,g(n,r-l.length+c.err.line));if(i===!0)return h("InvalidXml","Multiple possible root nodes found.",g(n,r));e.unpairedTags.indexOf(o)!==-1||t.push({tagName:o,tagStartPos:u}),s=!0}for(r++;r<n.length;r++)if(n[r]==="<")if(n[r+1]==="!"){r++,r=X(n,r);continue}else if(n[r+1]==="?"){if(r=G(n,++r),r.err)return r}else break;else if(n[r]==="&"){const c=he(n,r);if(c==-1)return h("InvalidChar","char '&' is not expected.",g(n,r));r=c}else if(i===!0&&!z(n[r]))return h("InvalidXml","Extra text at the end",g(n,r));n[r]==="<"&&r--}}else{if(z(n[r]))continue;return h("InvalidChar","char '"+n[r]+"' is not expected.",g(n,r))}if(s){if(t.length==1)return h("InvalidTag","Unclosed tag '"+t[0].tagName+"'.",g(n,t[0].tagStartPos));if(t.length>0)return h("InvalidXml","Invalid '"+JSON.stringify(t.map(r=>r.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return h("InvalidXml","Start tag expected.",1);return!0}function z(n){return n===" "||n===" "||n===`
3
- `||n==="\r"}function G(n,e){const t=e;for(;e<n.length;e++)if(n[e]=="?"||n[e]==" "){const s=n.substr(t,e-t);if(e>5&&s==="xml")return h("InvalidXml","XML declaration allowed only at the start of the document.",g(n,e));if(n[e]=="?"&&n[e+1]==">"){e++;break}else continue}return e}function X(n,e){if(n.length>e+5&&n[e+1]==="-"&&n[e+2]==="-"){for(e+=3;e<n.length;e++)if(n[e]==="-"&&n[e+1]==="-"&&n[e+2]===">"){e+=2;break}}else if(n.length>e+8&&n[e+1]==="D"&&n[e+2]==="O"&&n[e+3]==="C"&&n[e+4]==="T"&&n[e+5]==="Y"&&n[e+6]==="P"&&n[e+7]==="E"){let t=1;for(e+=8;e<n.length;e++)if(n[e]==="<")t++;else if(n[e]===">"&&(t--,t===0))break}else if(n.length>e+9&&n[e+1]==="["&&n[e+2]==="C"&&n[e+3]==="D"&&n[e+4]==="A"&&n[e+5]==="T"&&n[e+6]==="A"&&n[e+7]==="["){for(e+=8;e<n.length;e++)if(n[e]==="]"&&n[e+1]==="]"&&n[e+2]===">"){e+=2;break}}return e}const ae='"',ue="'";function le(n,e){let t="",s="",i=!1;for(;e<n.length;e++){if(n[e]===ae||n[e]===ue)s===""?s=n[e]:s!==n[e]||(s="");else if(n[e]===">"&&s===""){i=!0;break}t+=n[e]}return s!==""?!1:{value:t,index:e,tagClosed:i}}const fe=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Z(n,e){const t=W(n,fe),s={};for(let i=0;i<t.length;i++){if(t[i][1].length===0)return h("InvalidAttr","Attribute '"+t[i][2]+"' has no space in starting.",_(t[i]));if(t[i][3]!==void 0&&t[i][4]===void 0)return h("InvalidAttr","Attribute '"+t[i][2]+"' is without value.",_(t[i]));if(t[i][3]===void 0&&!e.allowBooleanAttributes)return h("InvalidAttr","boolean attribute '"+t[i][2]+"' is not allowed.",_(t[i]));const r=t[i][2];if(!pe(r))return h("InvalidAttr","Attribute '"+r+"' is an invalid name.",_(t[i]));if(!Object.prototype.hasOwnProperty.call(s,r))s[r]=1;else return h("InvalidAttr","Attribute '"+r+"' is repeated.",_(t[i]))}return!0}function ce(n,e){let t=/\d/;for(n[e]==="x"&&(e++,t=/[\da-fA-F]/);e<n.length;e++){if(n[e]===";")return e;if(!n[e].match(t))break}return-1}function he(n,e){if(e++,n[e]===";")return-1;if(n[e]==="#")return e++,ce(n,e);let t=0;for(;e<n.length;e++,t++)if(!(n[e].match(/\w/)&&t<20)){if(n[e]===";")break;return-1}return e}function h(n,e,t){return{err:{code:n,msg:e,line:t.line||t,col:t.col}}}function pe(n){return x(n)}function de(n){return x(n)}function g(n,e){const t=n.substring(0,e).split(/\r?\n/);return{line:t.length,col:t[t.length-1].length+1}}function _(n){return n.startIndex+n[1].length}const J=n=>k.includes(n)?"__"+n:n,ge={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(n,e){return e},attributeValueProcessor:function(n,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(n,e,t){return n},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:J};function Ee(n,e){if(typeof n!="string")return;const t=n.toLowerCase();if(k.some(s=>t===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Y.some(s=>t===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`)}function K(n){return typeof n=="boolean"?{enabled:n,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:typeof n=="object"&&n!==null?{enabled:n.enabled!==!1,maxEntitySize:Math.max(1,n.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,n.maxExpansionDepth??10),maxTotalExpansions:Math.max(1,n.maxTotalExpansions??1e3),maxExpandedLength:Math.max(1,n.maxExpandedLength??1e5),maxEntityCount:Math.max(1,n.maxEntityCount??100),allowedTags:n.allowedTags??null,tagFilter:n.tagFilter??null}:K(!0)}const be=function(n){const e=Object.assign({},ge,n),t=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(const{value:s,name:i}of t)s&&Ee(s,i);return e.onDangerousProperty===null&&(e.onDangerousProperty=J),e.processEntities=K(e.processEntities),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(s=>typeof s=="string"&&s.startsWith("*.")?".."+s.substring(2):s)),e};let v;typeof Symbol!="function"?v="@@xmlMetadata":v=Symbol("XML Node Metadata");class m{constructor(e){this.tagname=e,this.child=[],this[":@"]=Object.create(null)}add(e,t){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),t!==void 0&&(this.child[this.child.length-1][v]={startIndex:t})}static getMetaDataSymbol(){return v}}class ye{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,t){const s=Object.create(null);let i=0;if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let r=1,u=!1,a=!1,o="";for(;t<e.length;t++)if(e[t]==="<"&&!a){if(u&&T(e,"!ENTITY",t)){t+=7;let f,l;if([f,l,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),l.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&i>=this.options.maxEntityCount)throw new Error(`Entity count (${i+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);const c=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");s[f]={regx:RegExp(`&${c};`,"g"),val:l},i++}}else if(u&&T(e,"!ELEMENT",t)){t+=8;const{index:f}=this.readElementExp(e,t+1);t=f}else if(u&&T(e,"!ATTLIST",t))t+=8;else if(u&&T(e,"!NOTATION",t)){t+=9;const{index:f}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=f}else if(T(e,"!--",t))a=!0;else throw new Error("Invalid DOCTYPE");r++,o=""}else if(e[t]===">"){if(a?e[t-1]==="-"&&e[t-2]==="-"&&(a=!1,r--):r--,r===0)break}else e[t]==="["?u=!0:o+=e[t];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:s,i:t}}readEntityExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t])&&e[t]!=='"'&&e[t]!=="'";)t++;let i=e.substring(s,t);if(C(i),t=b(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[t]==="%")throw new Error("Parameter entities are not supported")}let r="";if([t,r]=this.readIdentifierVal(e,t,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&r.length>this.options.maxEntitySize)throw new Error(`Entity "${i}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[i,r,t]}readNotationExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);!this.suppressValidationErr&&C(i),t=b(e,t);const r=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&r!=="SYSTEM"&&r!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);t+=r.length,t=b(e,t);let u=null,a=null;if(r==="PUBLIC")[t,u]=this.readIdentifierVal(e,t,"publicIdentifier"),t=b(e,t),(e[t]==='"'||e[t]==="'")&&([t,a]=this.readIdentifierVal(e,t,"systemIdentifier"));else if(r==="SYSTEM"&&([t,a]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:i,publicIdentifier:u,systemIdentifier:a,index:--t}}readIdentifierVal(e,t,s){let i="";const r=e[t];if(r!=='"'&&r!=="'")throw new Error(`Expected quoted string, found "${r}"`);t++;const u=t;for(;t<e.length&&e[t]!==r;)t++;if(i=e.substring(u,t),e[t]!==r)throw new Error(`Unterminated ${s} value`);return t++,[t,i]}readElementExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);if(!this.suppressValidationErr&&!x(i))throw new Error(`Invalid element name: "${i}"`);t=b(e,t);let r="";if(e[t]==="E"&&T(e,"MPTY",t))t+=4;else if(e[t]==="A"&&T(e,"NY",t))t+=2;else if(e[t]==="("){t++;const u=t;for(;t<e.length&&e[t]!==")";)t++;if(r=e.substring(u,t),e[t]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:i,contentModel:r.trim(),index:t}}readAttlistExp(e,t){t=b(e,t);let s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);for(C(i),t=b(e,t),s=t;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(s,t);if(!C(r))throw new Error(`Invalid attribute name: "${r}"`);t=b(e,t);let u="";if(e.substring(t,t+8).toUpperCase()==="NOTATION"){if(u="NOTATION",t+=8,t=b(e,t),e[t]!=="(")throw new Error(`Expected '(', found "${e[t]}"`);t++;let o=[];for(;t<e.length&&e[t]!==")";){const f=t;for(;t<e.length&&e[t]!=="|"&&e[t]!==")";)t++;let l=e.substring(f,t);if(l=l.trim(),!C(l))throw new Error(`Invalid notation name: "${l}"`);o.push(l),e[t]==="|"&&(t++,t=b(e,t))}if(e[t]!==")")throw new Error("Unterminated list of notations");t++,u+=" ("+o.join("|")+")"}else{const o=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;u+=e.substring(o,t);const f=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!f.includes(u.toUpperCase()))throw new Error(`Invalid attribute type: "${u}"`)}t=b(e,t);let a="";return e.substring(t,t+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",t+=8):e.substring(t,t+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",t+=7):[t,a]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:i,attributeName:r,attributeType:u,defaultValue:a,index:t}}}const b=(n,e)=>{for(;e<n.length&&/\s/.test(n[e]);)e++;return e};function T(n,e,t){for(let s=0;s<e.length;s++)if(e[s]!==n[t+s+1])return!1;return!0}function C(n){if(x(n))return n;throw new Error(`Invalid entity name ${n}`)}const Ne=/^[-+]?0x[a-fA-F0-9]+$/,me=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Te={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function we(n,e={}){if(e=Object.assign({},Te,e),!n||typeof n!="string")return n;let t=n.trim();if(t.length===0)return n;if(e.skipLike!==void 0&&e.skipLike.test(t))return n;if(t==="0")return 0;if(e.hex&&Ne.test(t))return Ce(t,16);if(isFinite(t)){if(t.includes("e")||t.includes("E"))return Se(n,t,e);{const s=me.exec(t);if(s){const i=s[1]||"",r=s[2];let u=_e(s[3]);const a=i?n[r.length+1]===".":n[r.length]===".";if(!e.leadingZeros&&(r.length>1||r.length===1&&!a))return n;{const o=Number(t),f=String(o);if(o===0)return o;if(f.search(/[eE]/)!==-1)return e.eNotation?o:n;if(t.indexOf(".")!==-1)return f==="0"||f===u||f===`${i}${u}`?o:n;let l=r?u:t;return r?l===f||i+l===f?o:n:l===f||l===i+f?o:n}}else return n}}else return Pe(n,Number(t),e)}const Ie=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Se(n,e,t){if(!t.eNotation)return n;const s=e.match(Ie);if(s){let i=s[1]||"";const r=s[3].indexOf("e")===-1?"E":"e",u=s[2],a=i?n[u.length+1]===r:n[u.length]===r;return u.length>1&&a?n:u.length===1&&(s[3].startsWith(`.${r}`)||s[3][0]===r)?Number(e):u.length>0?t.leadingZeros&&!a?(e=(s[1]||"")+s[3],Number(e)):n:Number(e)}else return n}function _e(n){return n&&n.indexOf(".")!==-1&&(n=n.replace(/0+$/,""),n==="."?n="0":n[0]==="."?n="0"+n:n[n.length-1]==="."&&(n=n.substring(0,n.length-1))),n}function Ce(n,e){if(parseInt)return parseInt(n,e);if(Number.parseInt)return Number.parseInt(n,e);if(window&&window.parseInt)return window.parseInt(n,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function Pe(n,e,t){const s=e===1/0;switch(t.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return s?"Infinity":"-Infinity";case"original":default:return n}}function Oe(n){return typeof n=="function"?n:Array.isArray(n)?e=>{for(const t of n)if(typeof t=="string"&&e===t||t instanceof RegExp&&t.test(e))return!0}:()=>!1}class q{constructor(e,t={}){this.pattern=e,this.separator=t.separator||".",this.segments=this._parse(e),this._hasDeepWildcard=this.segments.some(s=>s.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(s=>s.attrName!==void 0),this._hasPositionSelector=this.segments.some(s=>s.position!==void 0)}_parse(e){const t=[];let s=0,i="";for(;s<e.length;)e[s]===this.separator?s+1<e.length&&e[s+1]===this.separator?(i.trim()&&(t.push(this._parseSegment(i.trim())),i=""),t.push({type:"deep-wildcard"}),s+=2):(i.trim()&&t.push(this._parseSegment(i.trim())),i="",s++):(i+=e[s],s++);return i.trim()&&t.push(this._parseSegment(i.trim())),t}_parseSegment(e){const t={type:"tag"};let s=null,i=e;const r=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(r&&(i=r[1]+r[3],r[2])){const l=r[2].slice(1,-1);l&&(s=l)}let u,a=i;if(i.includes("::")){const l=i.indexOf("::");if(u=i.substring(0,l).trim(),a=i.substring(l+2).trim(),!u)throw new Error(`Invalid namespace in pattern: ${e}`)}let o,f=null;if(a.includes(":")){const l=a.lastIndexOf(":"),c=a.substring(0,l).trim(),p=a.substring(l+1).trim();["first","last","odd","even"].includes(p)||/^nth\(\d+\)$/.test(p)?(o=c,f=p):o=a}else o=a;if(!o)throw new Error(`Invalid segment pattern: ${e}`);if(t.tag=o,u&&(t.namespace=u),s)if(s.includes("=")){const l=s.indexOf("=");t.attrName=s.substring(0,l).trim(),t.attrValue=s.substring(l+1).trim()}else t.attrName=s.trim();if(f){const l=f.match(/^nth\((\d+)\)$/);l?(t.position="nth",t.positionValue=parseInt(l[1],10)):t.position=f}return t}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}const Ae=new Set(["push","pop","reset","updateCurrent","restore"]);class Me{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[]}push(e,t=null,s=null){if(this.path.length>0){const l=this.path[this.path.length-1];l.values=void 0}const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);const r=this.siblingStacks[i],u=s?`${s}:${e}`:e,a=r.get(u)||0;let o=0;for(const l of r.values())o+=l;r.set(u,a+1);const f={tag:e,position:o,counter:a};s!=null&&(f.namespace=s),t!=null&&(f.values=t),this.path.push(f)}pop(){if(this.path.length===0)return;const e=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),e}updateCurrent(e){if(this.path.length>0){const t=this.path[this.path.length-1];e!=null&&(t.values=e)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){var s;return this.path.length===0||(s=this.path[this.path.length-1].values)==null?void 0:s[e]}hasAttr(e){if(this.path.length===0)return!1;const t=this.path[this.path.length-1];return t.values!==void 0&&e in t.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){const s=e||this.separator;return this.path.map(i=>t&&i.namespace?`${i.namespace}:${i.tag}`:i.tag).join(s)}toArray(){return this.path.map(e=>e.tag)}reset(){this.path=[],this.siblingStacks=[]}matches(e){const t=e.segments;return t.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t<e.length;t++){const s=e[t],i=this.path[t],r=t===this.path.length-1;if(!this._matchSegment(s,i,r))return!1}return!0}_matchWithDeepWildcard(e){let t=this.path.length-1,s=e.length-1;for(;s>=0&&t>=0;){const i=e[s];if(i.type==="deep-wildcard"){if(s--,s<0)return!0;const r=e[s];let u=!1;for(let a=t;a>=0;a--){const o=a===this.path.length-1;if(this._matchSegment(r,this.path[a],o)){t=a-1,s--,u=!0;break}}if(!u)return!1}else{const r=t===this.path.length-1;if(!this._matchSegment(i,this.path[t],r))return!1;t--,s--}}return s<0}_matchSegment(e,t,s){if(e.tag!=="*"&&e.tag!==t.tag||e.namespace!==void 0&&e.namespace!=="*"&&e.namespace!==t.namespace)return!1;if(e.attrName!==void 0){if(!s||!t.values||!(e.attrName in t.values))return!1;if(e.attrValue!==void 0){const i=t.values[e.attrName];if(String(i)!==String(e.attrValue))return!1}}if(e.position!==void 0){if(!s)return!1;const i=t.counter??0;if(e.position==="first"&&i!==0)return!1;if(e.position==="odd"&&i%2!==1)return!1;if(e.position==="even"&&i%2!==0)return!1;if(e.position==="nth"&&i!==e.positionValue)return!1}return!0}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>new Map(e))}}restore(e){this.path=e.path.map(t=>({...t})),this.siblingStacks=e.siblingStacks.map(t=>new Map(t))}readOnly(){const e=this;return new Proxy(e,{get(t,s,i){if(Ae.has(s))return()=>{throw new TypeError(`Cannot call '${s}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};const r=Reflect.get(t,s,i);return s==="path"||s==="siblingStacks"?Object.freeze(Array.isArray(r)?r.map(u=>u instanceof Map?Object.freeze(new Map(u)):Object.freeze({...u})):r):typeof r=="function"?r.bind(t):r},set(t,s){throw new TypeError(`Cannot set property '${String(s)}' on a read-only Matcher.`)},deleteProperty(t,s){throw new TypeError(`Cannot delete property '${String(s)}' from a read-only Matcher.`)}})}}function xe(n,e){if(!n)return{};const t=e.attributesGroupName?n[e.attributesGroupName]:n;if(!t)return{};const s={};for(const i in t)if(i.startsWith(e.attributeNamePrefix)){const r=i.substring(e.attributeNamePrefix.length);s[r]=t[i]}else s[i]=t[i];return s}function ve(n){if(!n||typeof n!="string")return;const e=n.indexOf(":");if(e!==-1&&e>0){const t=n.substring(0,e);if(t!=="xmlns")return t}}class $e{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,s)=>H(s,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,s)=>H(s,16,"&#x")}},this.addExternalEntities=je,this.parseXml=Fe,this.parseTextData=ke,this.resolveNameSpace=Ve,this.buildAttributesMap=Re,this.isItStopNode=Ye,this.replaceEntitiesValue=Ue,this.readStopNodeData=Ge,this.saveTextToParentTag=We,this.addChild=Be,this.ignoreAttributesFn=Oe(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new Me,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodeExpressions=[];for(let t=0;t<this.options.stopNodes.length;t++){const s=this.options.stopNodes[t];typeof s=="string"?this.stopNodeExpressions.push(new q(s)):s instanceof q&&this.stopNodeExpressions.push(s)}}}}function je(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t],i=s.replace(/[.\-+*:]/g,"\\.");this.lastEntities[s]={regex:new RegExp("&"+i+";","g"),val:n[s]}}}function ke(n,e,t,s,i,r,u){if(n!==void 0&&(this.options.trimValues&&!s&&(n=n.trim()),n.length>0)){u||(n=this.replaceEntitiesValue(n,e,t));const a=this.options.jPath?t.toString():t,o=this.options.tagValueProcessor(e,n,a,i,r);return o==null?n:typeof o!=typeof n||o!==n?o:this.options.trimValues?L(n,this.options.parseTagValue,this.options.numberParseOptions):n.trim()===n?L(n,this.options.parseTagValue,this.options.numberParseOptions):n}}function Ve(n){if(this.options.removeNSPrefix){const e=n.split(":"),t=n.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(n=t+e[1])}return n}const Le=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Re(n,e,t){if(this.options.ignoreAttributes!==!0&&typeof n=="string"){const s=W(n,Le),i=s.length,r={},u={};for(let a=0;a<i;a++){const o=this.resolveNameSpace(s[a][1]),f=s[a][4];if(o.length&&f!==void 0){let l=f;this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,this.readonlyMatcher),u[o]=l}}Object.keys(u).length>0&&typeof e=="object"&&e.updateCurrent&&e.updateCurrent(u);for(let a=0;a<i;a++){const o=this.resolveNameSpace(s[a][1]),f=this.options.jPath?e.toString():this.readonlyMatcher;if(this.ignoreAttributesFn(o,f))continue;let l=s[a][4],c=this.options.attributeNamePrefix+o;if(o.length)if(this.options.transformAttributeName&&(c=this.options.transformAttributeName(c)),c=Q(c,this.options),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,this.readonlyMatcher);const p=this.options.jPath?e.toString():this.readonlyMatcher,y=this.options.attributeValueProcessor(o,l,p);y==null?r[c]=l:typeof y!=typeof l||y!==l?r[c]=y:r[c]=L(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(r[c]=!0)}if(!Object.keys(r).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=r,a}return r}}const Fe=function(n){n=n.replace(/\r\n?/g,`
4
- `);const e=new m("!xml");let t=e,s="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;const i=new ye(this.options.processEntities);for(let r=0;r<n.length;r++)if(n[r]==="<")if(n[r+1]==="/"){const a=w(n,">",r,"Closing Tag is not closed.");let o=n.substring(r+2,a).trim();if(this.options.removeNSPrefix){const l=o.indexOf(":");l!==-1&&(o=o.substr(l+1))}o=R(this.options.transformTagName,o,"",this.options).tagName,t&&(s=this.saveTextToParentTag(s,t,this.readonlyMatcher));const f=this.matcher.getCurrentTag();if(o&&this.options.unpairedTags.indexOf(o)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);f&&this.options.unpairedTags.indexOf(f)!==-1&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,t=this.tagsNodeStack.pop(),s="",r=a}else if(n[r+1]==="?"){let a=V(n,r,!1,"?>");if(!a)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,t,this.readonlyMatcher),!(this.options.ignoreDeclaration&&a.tagName==="?xml"||this.options.ignorePiTags)){const o=new m(a.tagName);o.add(this.options.textNodeName,""),a.tagName!==a.tagExp&&a.attrExpPresent&&(o[":@"]=this.buildAttributesMap(a.tagExp,this.matcher,a.tagName)),this.addChild(t,o,this.readonlyMatcher,r)}r=a.closeIndex+1}else if(n.substr(r+1,3)==="!--"){const a=w(n,"-->",r+4,"Comment is not closed.");if(this.options.commentPropName){const o=n.substring(r+4,a-2);s=this.saveTextToParentTag(s,t,this.readonlyMatcher),t.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}r=a}else if(n.substr(r+1,2)==="!D"){const a=i.readDocType(n,r);this.docTypeEntities=a.entities,r=a.i}else if(n.substr(r+1,2)==="!["){const a=w(n,"]]>",r,"CDATA is not closed.")-2,o=n.substring(r+9,a);s=this.saveTextToParentTag(s,t,this.readonlyMatcher);let f=this.parseTextData(o,t.tagname,this.readonlyMatcher,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?t.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]):t.add(this.options.textNodeName,f),r=a+2}else{let a=V(n,r,this.options.removeNSPrefix);if(!a){const d=n.substring(Math.max(0,r-50),Math.min(n.length,r+50));throw new Error(`readTagExp returned undefined at position ${r}. Context: "${d}"`)}let o=a.tagName;const f=a.rawTagName;let l=a.tagExp,c=a.attrExpPresent,p=a.closeIndex;if({tagName:o,tagExp:l}=R(this.options.transformTagName,o,l,this.options),this.options.strictReservedNames&&(o===this.options.commentPropName||o===this.options.cdataPropName||o===this.options.textNodeName||o===this.options.attributesGroupName))throw new Error(`Invalid tag name: ${o}`);t&&s&&t.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,t,this.readonlyMatcher,!1));const y=t;y&&this.options.unpairedTags.indexOf(y.tagname)!==-1&&(t=this.tagsNodeStack.pop(),this.matcher.pop());let P=!1;l.length>0&&l.lastIndexOf("/")===l.length-1&&(P=!0,o[o.length-1]==="/"?(o=o.substr(0,o.length-1),l=o):l=l.substr(0,l.length-1),c=o!==l);let E=null,O;O=ve(f),o!==e.tagname&&this.matcher.push(o,{},O),o!==l&&c&&(E=this.buildAttributesMap(l,this.matcher,o),E&&xe(E,this.options)),o!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode(this.stopNodeExpressions,this.matcher));const S=r;if(this.isCurrentNodeStopNode){let d="";if(P)r=a.closeIndex;else if(this.options.unpairedTags.indexOf(o)!==-1)r=a.closeIndex;else{const M=this.readStopNodeData(n,f,p+1);if(!M)throw new Error(`Unexpected end of ${f}`);r=M.i,d=M.tagContent}const A=new m(o);E&&(A[":@"]=E),A.add(this.options.textNodeName,d),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(t,A,this.readonlyMatcher,S)}else{if(P){({tagName:o,tagExp:l}=R(this.options.transformTagName,o,l,this.options));const d=new m(o);E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(this.options.unpairedTags.indexOf(o)!==-1){const d=new m(o);E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=a.closeIndex;continue}else{const d=new m(o);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(t),E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),t=d}s="",r=p}}else s+=n[r];return e.child};function Be(n,e,t,s){this.options.captureMetaData||(s=void 0);const i=this.options.jPath?t.toString():t,r=this.options.updateTag(e.tagname,i,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),n.addChild(e,s))}function Ue(n,e,t){const s=this.options.processEntities;if(!s||!s.enabled)return n;if(s.allowedTags){const i=this.options.jPath?t.toString():t;if(!(Array.isArray(s.allowedTags)?s.allowedTags.includes(e):s.allowedTags(e,i)))return n}if(s.tagFilter){const i=this.options.jPath?t.toString():t;if(!s.tagFilter(e,i))return n}for(const i of Object.keys(this.docTypeEntities)){const r=this.docTypeEntities[i],u=n.match(r.regx);if(u){if(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);const a=n.length;if(n=n.replace(r.regx,r.val),s.maxExpandedLength&&(this.currentExpandedLength+=n.length-a,this.currentExpandedLength>s.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${s.maxExpandedLength}`)}}for(const i of Object.keys(this.lastEntities)){const r=this.lastEntities[i],u=n.match(r.regex);if(u&&(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);n=n.replace(r.regex,r.val)}if(n.indexOf("&")===-1)return n;if(this.options.htmlEntities)for(const i of Object.keys(this.htmlEntities)){const r=this.htmlEntities[i],u=n.match(r.regex);if(u&&(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);n=n.replace(r.regex,r.val)}return n=n.replace(this.ampEntity.regex,this.ampEntity.val),n}function We(n,e,t,s){return n&&(s===void 0&&(s=e.child.length===0),n=this.parseTextData(n,e.tagname,t,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,s),n!==void 0&&n!==""&&e.add(this.options.textNodeName,n),n=""),n}function Ye(n,e){if(!n||n.length===0)return!1;for(let t=0;t<n.length;t++)if(e.matches(n[t]))return!0;return!1}function ze(n,e,t=">"){let s,i="";for(let r=e;r<n.length;r++){let u=n[r];if(s)u===s&&(s="");else if(u==='"'||u==="'")s=u;else if(u===t[0])if(t[1]){if(n[r+1]===t[1])return{data:i,index:r}}else return{data:i,index:r};else u===" "&&(u=" ");i+=u}}function w(n,e,t,s){const i=n.indexOf(e,t);if(i===-1)throw new Error(s);return i+e.length-1}function V(n,e,t,s=">"){const i=ze(n,e+1,s);if(!i)return;let r=i.data;const u=i.index,a=r.search(/\s/);let o=r,f=!0;a!==-1&&(o=r.substring(0,a),r=r.substring(a+1).trimStart());const l=o;if(t){const c=o.indexOf(":");c!==-1&&(o=o.substr(c+1),f=o!==i.data.substr(c+1))}return{tagName:o,tagExp:r,closeIndex:u,attrExpPresent:f,rawTagName:l}}function Ge(n,e,t){const s=t;let i=1;for(;t<n.length;t++)if(n[t]==="<")if(n[t+1]==="/"){const r=w(n,">",t,`${e} is not closed`);if(n.substring(t+2,r).trim()===e&&(i--,i===0))return{tagContent:n.substring(s,t),i:r};t=r}else if(n[t+1]==="?")t=w(n,"?>",t+1,"StopNode is not closed.");else if(n.substr(t+1,3)==="!--")t=w(n,"-->",t+3,"StopNode is not closed.");else if(n.substr(t+1,2)==="![")t=w(n,"]]>",t,"StopNode is not closed.")-2;else{const r=V(n,t,">");r&&((r&&r.tagName)===e&&r.tagExp[r.tagExp.length-1]!=="/"&&i++,t=r.closeIndex)}}function L(n,e,t){if(e&&typeof n=="string"){const s=n.trim();return s==="true"?!0:s==="false"?!1:we(n,t)}else return re(n)?n:""}function H(n,e,t){const s=Number.parseInt(n,e);return s>=0&&s<=1114111?String.fromCodePoint(s):t+n+";"}function R(n,e,t,s){if(n){const i=n(e);t===e&&(t=i),e=i}return e=Q(e,s),{tagName:e,tagExp:t}}function Q(n,e){if(Y.includes(n))throw new Error(`[SECURITY] Invalid name: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`);return k.includes(n)?e.onDangerousProperty(n):n}const F=m.getMetaDataSymbol();function Xe(n,e){if(!n||typeof n!="object")return{};if(!e)return n;const t={};for(const s in n)if(s.startsWith(e)){const i=s.substring(e.length);t[i]=n[s]}else t[s]=n[s];return t}function Ze(n,e,t,s){return D(n,e,t,s)}function D(n,e,t,s){let i;const r={};for(let u=0;u<n.length;u++){const a=n[u],o=Je(a);if(o!==void 0&&o!==e.textNodeName){const f=Xe(a[":@"]||{},e.attributeNamePrefix);t.push(o,f)}if(o===e.textNodeName)i===void 0?i=a[o]:i+=""+a[o];else{if(o===void 0)continue;if(a[o]){let f=D(a[o],e,t,s);const l=qe(f,e);if(a[":@"]?Ke(f,a[":@"],s,e):Object.keys(f).length===1&&f[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?f=f[e.textNodeName]:Object.keys(f).length===0&&(e.alwaysCreateTextNode?f[e.textNodeName]="":f=""),a[F]!==void 0&&typeof f=="object"&&f!==null&&(f[F]=a[F]),r[o]!==void 0&&Object.prototype.hasOwnProperty.call(r,o))Array.isArray(r[o])||(r[o]=[r[o]]),r[o].push(f);else{const c=e.jPath?s.toString():s;e.isArray(o,c,l)?r[o]=[f]:r[o]=f}o!==void 0&&o!==e.textNodeName&&t.pop()}}}return typeof i=="string"?i.length>0&&(r[e.textNodeName]=i):i!==void 0&&(r[e.textNodeName]=i),r}function Je(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t];if(s!==":@")return s}}function Ke(n,e,t,s){if(e){const i=Object.keys(e),r=i.length;for(let u=0;u<r;u++){const a=i[u],o=a.startsWith(s.attributeNamePrefix)?a.substring(s.attributeNamePrefix.length):a,f=s.jPath?t.toString()+"."+o:t;s.isArray(a,f,!0,!0)?n[a]=[e[a]]:n[a]=e[a]}}}function qe(n,e){const{textNodeName:t}=e,s=Object.keys(n).length;return!!(s===0||s===1&&(n[t]||typeof n[t]=="boolean"||n[t]===0))}class He{constructor(e){this.externalEntities={},this.options=be(e)}parse(e,t){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(t){t===!0&&(t={});const r=oe(e,t);if(r!==!0)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const s=new $e(this.options);s.addExternalEntities(this.externalEntities);const i=s.parseXml(e);return this.options.preserveOrder||i===void 0?i:Ze(i,this.options,s.matcher,s.readonlyMatcher)}addEntity(e,t){if(t.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(t==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return m.getMetaDataSymbol()}}const Qe={APPLET:"applet",BUSINESS_COMPONENT:"business_component",BUSINESS_OBJECT:"business_object",VIEW:"view",SCREEN:"screen",WORKFLOW:"workflow",INTEGRATION_OBJECT:"integration_object",BUSINESS_SERVICE:"business_service",WEB_TEMPLATE:"web_template",PICK_LIST:"pick_list",TABLE:"table"},De={FIELD:"field",COLUMN:"column",CONTROL:"control",LIST_COLUMN:"list_column",LINK:"link",APPLET_WEB_TEMPLATE:"web_template",VIEW_WEB_TEMPLATE:"web_template",VIEW_APPLET:"applet",SCREEN_VIEW:"view",APPLET_METHOD_MENU_ITEM:"menu_item",BUSINESS_OBJECT_COMPONENT:"business_component",BUSINESS_SERVICE_METHOD:"business_service",WORKFLOW_STEP:"workflow",INTEGRATION_COMPONENT:"business_component"},et=new Set(["NAME","INACTIVE"]);function $(n,e){const t=n[e];return Array.isArray(t)?t:t!=null?[t]:[]}function I(n,e){const t=n[`@_${e}`];return t!=null?String(t):void 0}function ee(n){const e=[];for(const[t,s]of Object.entries(n))t.startsWith("@_")&&!et.has(t.slice(2))&&e.push({name:t.slice(2),value:String(s)});return e}function tt(n,e){const t=[];for(const[s,i]of Object.entries(De))for(const r of $(n,s)){const u=r,a=I(u,"NAME");a&&t.push({name:a,type:i,properties:ee(u),children:[],parentName:e})}return t}function N(n,e){var t;return(t=n.properties.find(s=>s.name===e))==null?void 0:t.value}function nt(n){const e=[],t=new Map;for(const s of n)t.set(`${s.type}:${s.name}`,s);for(const s of n){if(s.type==="applet"){const i=N(s,"BUS_COMP");i&&t.has(`business_component:${i}`)&&e.push({from:{name:s.name,type:"applet"},to:{name:i,type:"business_component"},relationType:"references",inferred:!0})}if(s.type==="view"){const i=N(s,"BUS_OBJECT");i&&t.has(`business_object:${i}`)&&e.push({from:{name:s.name,type:"view"},to:{name:i,type:"business_object"},relationType:"references",inferred:!0});for(const r of s.children)if(r.type==="applet"){const u=N(r,"APPLET")??r.name;t.has(`applet:${u}`)&&e.push({from:{name:s.name,type:"view"},to:{name:u,type:"applet"},relationType:"contains",inferred:!0})}}if(s.type==="screen"){for(const i of s.children)if(i.type==="view"){const r=N(i,"VIEW")??i.name;t.has(`view:${r}`)&&e.push({from:{name:s.name,type:"screen"},to:{name:r,type:"view"},relationType:"contains",inferred:!0})}}if(s.type==="business_object"){for(const i of s.children)if(i.type==="business_component"){const r=N(i,"BUS_COMP")??i.name;t.has(`business_component:${r}`)&&e.push({from:{name:s.name,type:"business_object"},to:{name:r,type:"business_component"},relationType:"contains",inferred:!0})}}if(s.type==="workflow"){const i=N(s,"BUS_OBJECT");i&&t.has(`business_object:${i}`)&&e.push({from:{name:s.name,type:"workflow"},to:{name:i,type:"business_object"},relationType:"references",inferred:!0});for(const r of s.children){const u=N(r,"BUS_SERVICE");u&&t.has(`business_service:${u}`)&&e.push({from:{name:s.name,type:"workflow"},to:{name:u,type:"business_service"},relationType:"uses",inferred:!0})}}if(s.type==="integration_object"){const i=N(s,"BUS_COMP");i&&t.has(`business_component:${i}`)&&e.push({from:{name:s.name,type:"integration_object"},to:{name:i,type:"business_component"},relationType:"references",inferred:!0})}if(s.type==="business_component"){const i=N(s,"TABLE");i&&e.push({from:{name:s.name,type:"business_component"},to:{name:i,type:"table"},relationType:"based_on",inferred:!0});for(const r of s.children)if(r.type==="link"){const u=N(r,"CHILD_BC");u&&t.has(`business_component:${u}`)&&e.push({from:{name:s.name,type:"business_component"},to:{name:u,type:"business_component"},relationType:"linked_to",inferred:!0})}}}return e}self.onmessage=n=>{const{type:e,content:t,fileName:s}=n.data;if(e==="parse")try{self.postMessage({type:"progress",status:"parsing",progress:20});const r=new He({ignoreAttributes:!1,attributeNamePrefix:"@_",allowBooleanAttributes:!0,parseAttributeValue:!1,isArray:()=>!0}).parse(t);self.postMessage({type:"progress",status:"extracting",progress:50});const u=$(r,"REPOSITORY");if(u.length===0){self.postMessage({type:"error",message:"SIF file missing REPOSITORY root element"});return}const a=u[0],o=I(a,"NAME")??"Unknown",f=$(a,"PROJECT"),l=f.length>0?I(f[0],"NAME"):void 0,c=[];for(const E of f){const O=E,S=I(O,"NAME")??"Unknown";for(const[d,A]of Object.entries(Qe))for(const M of $(O,d)){const j=M,B=I(j,"NAME");B&&c.push({name:B,type:A,project:S,properties:ee(j),children:tt(j,B),inactive:I(j,"INACTIVE")==="Y"||void 0})}}self.postMessage({type:"progress",status:"inferring",progress:80});const p=nt(c),y=[...new Set(c.map(E=>E.type))],P={metadata:{fileName:s,repositoryName:o,projectName:l,objectCount:c.length,objectTypes:y,extractedAt:new Date().toISOString()},objects:c,dependencies:p};self.postMessage({type:"progress",status:"done",progress:100}),self.postMessage({type:"result",data:P})}catch(i){self.postMessage({type:"error",message:i instanceof Error?i.message:String(i)})}}})();
3
+ `||n==="\r"}function G(n,e){const t=e;for(;e<n.length;e++)if(n[e]=="?"||n[e]==" "){const s=n.substr(t,e-t);if(e>5&&s==="xml")return h("InvalidXml","XML declaration allowed only at the start of the document.",g(n,e));if(n[e]=="?"&&n[e+1]==">"){e++;break}else continue}return e}function X(n,e){if(n.length>e+5&&n[e+1]==="-"&&n[e+2]==="-"){for(e+=3;e<n.length;e++)if(n[e]==="-"&&n[e+1]==="-"&&n[e+2]===">"){e+=2;break}}else if(n.length>e+8&&n[e+1]==="D"&&n[e+2]==="O"&&n[e+3]==="C"&&n[e+4]==="T"&&n[e+5]==="Y"&&n[e+6]==="P"&&n[e+7]==="E"){let t=1;for(e+=8;e<n.length;e++)if(n[e]==="<")t++;else if(n[e]===">"&&(t--,t===0))break}else if(n.length>e+9&&n[e+1]==="["&&n[e+2]==="C"&&n[e+3]==="D"&&n[e+4]==="A"&&n[e+5]==="T"&&n[e+6]==="A"&&n[e+7]==="["){for(e+=8;e<n.length;e++)if(n[e]==="]"&&n[e+1]==="]"&&n[e+2]===">"){e+=2;break}}return e}const ae='"',ue="'";function le(n,e){let t="",s="",i=!1;for(;e<n.length;e++){if(n[e]===ae||n[e]===ue)s===""?s=n[e]:s!==n[e]||(s="");else if(n[e]===">"&&s===""){i=!0;break}t+=n[e]}return s!==""?!1:{value:t,index:e,tagClosed:i}}const fe=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Z(n,e){const t=W(n,fe),s={};for(let i=0;i<t.length;i++){if(t[i][1].length===0)return h("InvalidAttr","Attribute '"+t[i][2]+"' has no space in starting.",_(t[i]));if(t[i][3]!==void 0&&t[i][4]===void 0)return h("InvalidAttr","Attribute '"+t[i][2]+"' is without value.",_(t[i]));if(t[i][3]===void 0&&!e.allowBooleanAttributes)return h("InvalidAttr","boolean attribute '"+t[i][2]+"' is not allowed.",_(t[i]));const r=t[i][2];if(!pe(r))return h("InvalidAttr","Attribute '"+r+"' is an invalid name.",_(t[i]));if(!Object.prototype.hasOwnProperty.call(s,r))s[r]=1;else return h("InvalidAttr","Attribute '"+r+"' is repeated.",_(t[i]))}return!0}function ce(n,e){let t=/\d/;for(n[e]==="x"&&(e++,t=/[\da-fA-F]/);e<n.length;e++){if(n[e]===";")return e;if(!n[e].match(t))break}return-1}function he(n,e){if(e++,n[e]===";")return-1;if(n[e]==="#")return e++,ce(n,e);let t=0;for(;e<n.length;e++,t++)if(!(n[e].match(/\w/)&&t<20)){if(n[e]===";")break;return-1}return e}function h(n,e,t){return{err:{code:n,msg:e,line:t.line||t,col:t.col}}}function pe(n){return M(n)}function de(n){return M(n)}function g(n,e){const t=n.substring(0,e).split(/\r?\n/);return{line:t.length,col:t[t.length-1].length+1}}function _(n){return n.startIndex+n[1].length}const J=n=>k.includes(n)?"__"+n:n,ge={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(n,e){return e},attributeValueProcessor:function(n,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(n,e,t){return n},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:J};function Ee(n,e){if(typeof n!="string")return;const t=n.toLowerCase();if(k.some(s=>t===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Y.some(s=>t===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`)}function K(n){return typeof n=="boolean"?{enabled:n,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:typeof n=="object"&&n!==null?{enabled:n.enabled!==!1,maxEntitySize:Math.max(1,n.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,n.maxExpansionDepth??10),maxTotalExpansions:Math.max(1,n.maxTotalExpansions??1e3),maxExpandedLength:Math.max(1,n.maxExpandedLength??1e5),maxEntityCount:Math.max(1,n.maxEntityCount??100),allowedTags:n.allowedTags??null,tagFilter:n.tagFilter??null}:K(!0)}const be=function(n){const e=Object.assign({},ge,n),t=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(const{value:s,name:i}of t)s&&Ee(s,i);return e.onDangerousProperty===null&&(e.onDangerousProperty=J),e.processEntities=K(e.processEntities),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(s=>typeof s=="string"&&s.startsWith("*.")?".."+s.substring(2):s)),e};let v;typeof Symbol!="function"?v="@@xmlMetadata":v=Symbol("XML Node Metadata");class N{constructor(e){this.tagname=e,this.child=[],this[":@"]=Object.create(null)}add(e,t){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),t!==void 0&&(this.child[this.child.length-1][v]={startIndex:t})}static getMetaDataSymbol(){return v}}class ye{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,t){const s=Object.create(null);let i=0;if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let r=1,u=!1,a=!1,o="";for(;t<e.length;t++)if(e[t]==="<"&&!a){if(u&&T(e,"!ENTITY",t)){t+=7;let f,l;if([f,l,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),l.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&i>=this.options.maxEntityCount)throw new Error(`Entity count (${i+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);const c=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");s[f]={regx:RegExp(`&${c};`,"g"),val:l},i++}}else if(u&&T(e,"!ELEMENT",t)){t+=8;const{index:f}=this.readElementExp(e,t+1);t=f}else if(u&&T(e,"!ATTLIST",t))t+=8;else if(u&&T(e,"!NOTATION",t)){t+=9;const{index:f}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=f}else if(T(e,"!--",t))a=!0;else throw new Error("Invalid DOCTYPE");r++,o=""}else if(e[t]===">"){if(a?e[t-1]==="-"&&e[t-2]==="-"&&(a=!1,r--):r--,r===0)break}else e[t]==="["?u=!0:o+=e[t];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:s,i:t}}readEntityExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t])&&e[t]!=='"'&&e[t]!=="'";)t++;let i=e.substring(s,t);if(C(i),t=b(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[t]==="%")throw new Error("Parameter entities are not supported")}let r="";if([t,r]=this.readIdentifierVal(e,t,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&r.length>this.options.maxEntitySize)throw new Error(`Entity "${i}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[i,r,t]}readNotationExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);!this.suppressValidationErr&&C(i),t=b(e,t);const r=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&r!=="SYSTEM"&&r!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);t+=r.length,t=b(e,t);let u=null,a=null;if(r==="PUBLIC")[t,u]=this.readIdentifierVal(e,t,"publicIdentifier"),t=b(e,t),(e[t]==='"'||e[t]==="'")&&([t,a]=this.readIdentifierVal(e,t,"systemIdentifier"));else if(r==="SYSTEM"&&([t,a]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:i,publicIdentifier:u,systemIdentifier:a,index:--t}}readIdentifierVal(e,t,s){let i="";const r=e[t];if(r!=='"'&&r!=="'")throw new Error(`Expected quoted string, found "${r}"`);t++;const u=t;for(;t<e.length&&e[t]!==r;)t++;if(i=e.substring(u,t),e[t]!==r)throw new Error(`Unterminated ${s} value`);return t++,[t,i]}readElementExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);if(!this.suppressValidationErr&&!M(i))throw new Error(`Invalid element name: "${i}"`);t=b(e,t);let r="";if(e[t]==="E"&&T(e,"MPTY",t))t+=4;else if(e[t]==="A"&&T(e,"NY",t))t+=2;else if(e[t]==="("){t++;const u=t;for(;t<e.length&&e[t]!==")";)t++;if(r=e.substring(u,t),e[t]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:i,contentModel:r.trim(),index:t}}readAttlistExp(e,t){t=b(e,t);let s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);for(C(i),t=b(e,t),s=t;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(s,t);if(!C(r))throw new Error(`Invalid attribute name: "${r}"`);t=b(e,t);let u="";if(e.substring(t,t+8).toUpperCase()==="NOTATION"){if(u="NOTATION",t+=8,t=b(e,t),e[t]!=="(")throw new Error(`Expected '(', found "${e[t]}"`);t++;let o=[];for(;t<e.length&&e[t]!==")";){const f=t;for(;t<e.length&&e[t]!=="|"&&e[t]!==")";)t++;let l=e.substring(f,t);if(l=l.trim(),!C(l))throw new Error(`Invalid notation name: "${l}"`);o.push(l),e[t]==="|"&&(t++,t=b(e,t))}if(e[t]!==")")throw new Error("Unterminated list of notations");t++,u+=" ("+o.join("|")+")"}else{const o=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;u+=e.substring(o,t);const f=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!f.includes(u.toUpperCase()))throw new Error(`Invalid attribute type: "${u}"`)}t=b(e,t);let a="";return e.substring(t,t+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",t+=8):e.substring(t,t+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",t+=7):[t,a]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:i,attributeName:r,attributeType:u,defaultValue:a,index:t}}}const b=(n,e)=>{for(;e<n.length&&/\s/.test(n[e]);)e++;return e};function T(n,e,t){for(let s=0;s<e.length;s++)if(e[s]!==n[t+s+1])return!1;return!0}function C(n){if(M(n))return n;throw new Error(`Invalid entity name ${n}`)}const me=/^[-+]?0x[a-fA-F0-9]+$/,Ne=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Te={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function we(n,e={}){if(e=Object.assign({},Te,e),!n||typeof n!="string")return n;let t=n.trim();if(t.length===0)return n;if(e.skipLike!==void 0&&e.skipLike.test(t))return n;if(t==="0")return 0;if(e.hex&&me.test(t))return Ce(t,16);if(isFinite(t)){if(t.includes("e")||t.includes("E"))return Se(n,t,e);{const s=Ne.exec(t);if(s){const i=s[1]||"",r=s[2];let u=_e(s[3]);const a=i?n[r.length+1]===".":n[r.length]===".";if(!e.leadingZeros&&(r.length>1||r.length===1&&!a))return n;{const o=Number(t),f=String(o);if(o===0)return o;if(f.search(/[eE]/)!==-1)return e.eNotation?o:n;if(t.indexOf(".")!==-1)return f==="0"||f===u||f===`${i}${u}`?o:n;let l=r?u:t;return r?l===f||i+l===f?o:n:l===f||l===i+f?o:n}}else return n}}else return Pe(n,Number(t),e)}const Ie=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Se(n,e,t){if(!t.eNotation)return n;const s=e.match(Ie);if(s){let i=s[1]||"";const r=s[3].indexOf("e")===-1?"E":"e",u=s[2],a=i?n[u.length+1]===r:n[u.length]===r;return u.length>1&&a?n:u.length===1&&(s[3].startsWith(`.${r}`)||s[3][0]===r)?Number(e):u.length>0?t.leadingZeros&&!a?(e=(s[1]||"")+s[3],Number(e)):n:Number(e)}else return n}function _e(n){return n&&n.indexOf(".")!==-1&&(n=n.replace(/0+$/,""),n==="."?n="0":n[0]==="."?n="0"+n:n[n.length-1]==="."&&(n=n.substring(0,n.length-1))),n}function Ce(n,e){if(parseInt)return parseInt(n,e);if(Number.parseInt)return Number.parseInt(n,e);if(window&&window.parseInt)return window.parseInt(n,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function Pe(n,e,t){const s=e===1/0;switch(t.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return s?"Infinity":"-Infinity";case"original":default:return n}}function Oe(n){return typeof n=="function"?n:Array.isArray(n)?e=>{for(const t of n)if(typeof t=="string"&&e===t||t instanceof RegExp&&t.test(e))return!0}:()=>!1}class q{constructor(e,t={}){this.pattern=e,this.separator=t.separator||".",this.segments=this._parse(e),this._hasDeepWildcard=this.segments.some(s=>s.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(s=>s.attrName!==void 0),this._hasPositionSelector=this.segments.some(s=>s.position!==void 0)}_parse(e){const t=[];let s=0,i="";for(;s<e.length;)e[s]===this.separator?s+1<e.length&&e[s+1]===this.separator?(i.trim()&&(t.push(this._parseSegment(i.trim())),i=""),t.push({type:"deep-wildcard"}),s+=2):(i.trim()&&t.push(this._parseSegment(i.trim())),i="",s++):(i+=e[s],s++);return i.trim()&&t.push(this._parseSegment(i.trim())),t}_parseSegment(e){const t={type:"tag"};let s=null,i=e;const r=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(r&&(i=r[1]+r[3],r[2])){const l=r[2].slice(1,-1);l&&(s=l)}let u,a=i;if(i.includes("::")){const l=i.indexOf("::");if(u=i.substring(0,l).trim(),a=i.substring(l+2).trim(),!u)throw new Error(`Invalid namespace in pattern: ${e}`)}let o,f=null;if(a.includes(":")){const l=a.lastIndexOf(":"),c=a.substring(0,l).trim(),p=a.substring(l+1).trim();["first","last","odd","even"].includes(p)||/^nth\(\d+\)$/.test(p)?(o=c,f=p):o=a}else o=a;if(!o)throw new Error(`Invalid segment pattern: ${e}`);if(t.tag=o,u&&(t.namespace=u),s)if(s.includes("=")){const l=s.indexOf("=");t.attrName=s.substring(0,l).trim(),t.attrValue=s.substring(l+1).trim()}else t.attrName=s.trim();if(f){const l=f.match(/^nth\((\d+)\)$/);l?(t.position="nth",t.positionValue=parseInt(l[1],10)):t.position=f}return t}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}const Ae=new Set(["push","pop","reset","updateCurrent","restore"]);class xe{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[]}push(e,t=null,s=null){if(this.path.length>0){const l=this.path[this.path.length-1];l.values=void 0}const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);const r=this.siblingStacks[i],u=s?`${s}:${e}`:e,a=r.get(u)||0;let o=0;for(const l of r.values())o+=l;r.set(u,a+1);const f={tag:e,position:o,counter:a};s!=null&&(f.namespace=s),t!=null&&(f.values=t),this.path.push(f)}pop(){if(this.path.length===0)return;const e=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),e}updateCurrent(e){if(this.path.length>0){const t=this.path[this.path.length-1];e!=null&&(t.values=e)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){var s;return this.path.length===0||(s=this.path[this.path.length-1].values)==null?void 0:s[e]}hasAttr(e){if(this.path.length===0)return!1;const t=this.path[this.path.length-1];return t.values!==void 0&&e in t.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){const s=e||this.separator;return this.path.map(i=>t&&i.namespace?`${i.namespace}:${i.tag}`:i.tag).join(s)}toArray(){return this.path.map(e=>e.tag)}reset(){this.path=[],this.siblingStacks=[]}matches(e){const t=e.segments;return t.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t<e.length;t++){const s=e[t],i=this.path[t],r=t===this.path.length-1;if(!this._matchSegment(s,i,r))return!1}return!0}_matchWithDeepWildcard(e){let t=this.path.length-1,s=e.length-1;for(;s>=0&&t>=0;){const i=e[s];if(i.type==="deep-wildcard"){if(s--,s<0)return!0;const r=e[s];let u=!1;for(let a=t;a>=0;a--){const o=a===this.path.length-1;if(this._matchSegment(r,this.path[a],o)){t=a-1,s--,u=!0;break}}if(!u)return!1}else{const r=t===this.path.length-1;if(!this._matchSegment(i,this.path[t],r))return!1;t--,s--}}return s<0}_matchSegment(e,t,s){if(e.tag!=="*"&&e.tag!==t.tag||e.namespace!==void 0&&e.namespace!=="*"&&e.namespace!==t.namespace)return!1;if(e.attrName!==void 0){if(!s||!t.values||!(e.attrName in t.values))return!1;if(e.attrValue!==void 0){const i=t.values[e.attrName];if(String(i)!==String(e.attrValue))return!1}}if(e.position!==void 0){if(!s)return!1;const i=t.counter??0;if(e.position==="first"&&i!==0)return!1;if(e.position==="odd"&&i%2!==1)return!1;if(e.position==="even"&&i%2!==0)return!1;if(e.position==="nth"&&i!==e.positionValue)return!1}return!0}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>new Map(e))}}restore(e){this.path=e.path.map(t=>({...t})),this.siblingStacks=e.siblingStacks.map(t=>new Map(t))}readOnly(){const e=this;return new Proxy(e,{get(t,s,i){if(Ae.has(s))return()=>{throw new TypeError(`Cannot call '${s}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};const r=Reflect.get(t,s,i);return s==="path"||s==="siblingStacks"?Object.freeze(Array.isArray(r)?r.map(u=>u instanceof Map?Object.freeze(new Map(u)):Object.freeze({...u})):r):typeof r=="function"?r.bind(t):r},set(t,s){throw new TypeError(`Cannot set property '${String(s)}' on a read-only Matcher.`)},deleteProperty(t,s){throw new TypeError(`Cannot delete property '${String(s)}' from a read-only Matcher.`)}})}}function Me(n,e){if(!n)return{};const t=e.attributesGroupName?n[e.attributesGroupName]:n;if(!t)return{};const s={};for(const i in t)if(i.startsWith(e.attributeNamePrefix)){const r=i.substring(e.attributeNamePrefix.length);s[r]=t[i]}else s[i]=t[i];return s}function ve(n){if(!n||typeof n!="string")return;const e=n.indexOf(":");if(e!==-1&&e>0){const t=n.substring(0,e);if(t!=="xmlns")return t}}class $e{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,s)=>H(s,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,s)=>H(s,16,"&#x")}},this.addExternalEntities=je,this.parseXml=Fe,this.parseTextData=ke,this.resolveNameSpace=Ve,this.buildAttributesMap=Re,this.isItStopNode=Ye,this.replaceEntitiesValue=Ue,this.readStopNodeData=Ge,this.saveTextToParentTag=We,this.addChild=Be,this.ignoreAttributesFn=Oe(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new xe,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodeExpressions=[];for(let t=0;t<this.options.stopNodes.length;t++){const s=this.options.stopNodes[t];typeof s=="string"?this.stopNodeExpressions.push(new q(s)):s instanceof q&&this.stopNodeExpressions.push(s)}}}}function je(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t],i=s.replace(/[.\-+*:]/g,"\\.");this.lastEntities[s]={regex:new RegExp("&"+i+";","g"),val:n[s]}}}function ke(n,e,t,s,i,r,u){if(n!==void 0&&(this.options.trimValues&&!s&&(n=n.trim()),n.length>0)){u||(n=this.replaceEntitiesValue(n,e,t));const a=this.options.jPath?t.toString():t,o=this.options.tagValueProcessor(e,n,a,i,r);return o==null?n:typeof o!=typeof n||o!==n?o:this.options.trimValues?L(n,this.options.parseTagValue,this.options.numberParseOptions):n.trim()===n?L(n,this.options.parseTagValue,this.options.numberParseOptions):n}}function Ve(n){if(this.options.removeNSPrefix){const e=n.split(":"),t=n.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(n=t+e[1])}return n}const Le=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Re(n,e,t){if(this.options.ignoreAttributes!==!0&&typeof n=="string"){const s=W(n,Le),i=s.length,r={},u={};for(let a=0;a<i;a++){const o=this.resolveNameSpace(s[a][1]),f=s[a][4];if(o.length&&f!==void 0){let l=f;this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,this.readonlyMatcher),u[o]=l}}Object.keys(u).length>0&&typeof e=="object"&&e.updateCurrent&&e.updateCurrent(u);for(let a=0;a<i;a++){const o=this.resolveNameSpace(s[a][1]),f=this.options.jPath?e.toString():this.readonlyMatcher;if(this.ignoreAttributesFn(o,f))continue;let l=s[a][4],c=this.options.attributeNamePrefix+o;if(o.length)if(this.options.transformAttributeName&&(c=this.options.transformAttributeName(c)),c=Q(c,this.options),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,this.readonlyMatcher);const p=this.options.jPath?e.toString():this.readonlyMatcher,y=this.options.attributeValueProcessor(o,l,p);y==null?r[c]=l:typeof y!=typeof l||y!==l?r[c]=y:r[c]=L(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(r[c]=!0)}if(!Object.keys(r).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=r,a}return r}}const Fe=function(n){n=n.replace(/\r\n?/g,`
4
+ `);const e=new N("!xml");let t=e,s="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;const i=new ye(this.options.processEntities);for(let r=0;r<n.length;r++)if(n[r]==="<")if(n[r+1]==="/"){const a=w(n,">",r,"Closing Tag is not closed.");let o=n.substring(r+2,a).trim();if(this.options.removeNSPrefix){const l=o.indexOf(":");l!==-1&&(o=o.substr(l+1))}o=R(this.options.transformTagName,o,"",this.options).tagName,t&&(s=this.saveTextToParentTag(s,t,this.readonlyMatcher));const f=this.matcher.getCurrentTag();if(o&&this.options.unpairedTags.indexOf(o)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);f&&this.options.unpairedTags.indexOf(f)!==-1&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,t=this.tagsNodeStack.pop(),s="",r=a}else if(n[r+1]==="?"){let a=V(n,r,!1,"?>");if(!a)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,t,this.readonlyMatcher),!(this.options.ignoreDeclaration&&a.tagName==="?xml"||this.options.ignorePiTags)){const o=new N(a.tagName);o.add(this.options.textNodeName,""),a.tagName!==a.tagExp&&a.attrExpPresent&&(o[":@"]=this.buildAttributesMap(a.tagExp,this.matcher,a.tagName)),this.addChild(t,o,this.readonlyMatcher,r)}r=a.closeIndex+1}else if(n.substr(r+1,3)==="!--"){const a=w(n,"-->",r+4,"Comment is not closed.");if(this.options.commentPropName){const o=n.substring(r+4,a-2);s=this.saveTextToParentTag(s,t,this.readonlyMatcher),t.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}r=a}else if(n.substr(r+1,2)==="!D"){const a=i.readDocType(n,r);this.docTypeEntities=a.entities,r=a.i}else if(n.substr(r+1,2)==="!["){const a=w(n,"]]>",r,"CDATA is not closed.")-2,o=n.substring(r+9,a);s=this.saveTextToParentTag(s,t,this.readonlyMatcher);let f=this.parseTextData(o,t.tagname,this.readonlyMatcher,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?t.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]):t.add(this.options.textNodeName,f),r=a+2}else{let a=V(n,r,this.options.removeNSPrefix);if(!a){const d=n.substring(Math.max(0,r-50),Math.min(n.length,r+50));throw new Error(`readTagExp returned undefined at position ${r}. Context: "${d}"`)}let o=a.tagName;const f=a.rawTagName;let l=a.tagExp,c=a.attrExpPresent,p=a.closeIndex;if({tagName:o,tagExp:l}=R(this.options.transformTagName,o,l,this.options),this.options.strictReservedNames&&(o===this.options.commentPropName||o===this.options.cdataPropName||o===this.options.textNodeName||o===this.options.attributesGroupName))throw new Error(`Invalid tag name: ${o}`);t&&s&&t.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,t,this.readonlyMatcher,!1));const y=t;y&&this.options.unpairedTags.indexOf(y.tagname)!==-1&&(t=this.tagsNodeStack.pop(),this.matcher.pop());let P=!1;l.length>0&&l.lastIndexOf("/")===l.length-1&&(P=!0,o[o.length-1]==="/"?(o=o.substr(0,o.length-1),l=o):l=l.substr(0,l.length-1),c=o!==l);let E=null,O;O=ve(f),o!==e.tagname&&this.matcher.push(o,{},O),o!==l&&c&&(E=this.buildAttributesMap(l,this.matcher,o),E&&Me(E,this.options)),o!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode(this.stopNodeExpressions,this.matcher));const S=r;if(this.isCurrentNodeStopNode){let d="";if(P)r=a.closeIndex;else if(this.options.unpairedTags.indexOf(o)!==-1)r=a.closeIndex;else{const x=this.readStopNodeData(n,f,p+1);if(!x)throw new Error(`Unexpected end of ${f}`);r=x.i,d=x.tagContent}const A=new N(o);E&&(A[":@"]=E),A.add(this.options.textNodeName,d),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(t,A,this.readonlyMatcher,S)}else{if(P){({tagName:o,tagExp:l}=R(this.options.transformTagName,o,l,this.options));const d=new N(o);E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(this.options.unpairedTags.indexOf(o)!==-1){const d=new N(o);E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=a.closeIndex;continue}else{const d=new N(o);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(t),E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),t=d}s="",r=p}}else s+=n[r];return e.child};function Be(n,e,t,s){this.options.captureMetaData||(s=void 0);const i=this.options.jPath?t.toString():t,r=this.options.updateTag(e.tagname,i,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),n.addChild(e,s))}function Ue(n,e,t){const s=this.options.processEntities;if(!s||!s.enabled)return n;if(s.allowedTags){const i=this.options.jPath?t.toString():t;if(!(Array.isArray(s.allowedTags)?s.allowedTags.includes(e):s.allowedTags(e,i)))return n}if(s.tagFilter){const i=this.options.jPath?t.toString():t;if(!s.tagFilter(e,i))return n}for(const i of Object.keys(this.docTypeEntities)){const r=this.docTypeEntities[i],u=n.match(r.regx);if(u){if(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);const a=n.length;if(n=n.replace(r.regx,r.val),s.maxExpandedLength&&(this.currentExpandedLength+=n.length-a,this.currentExpandedLength>s.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${s.maxExpandedLength}`)}}for(const i of Object.keys(this.lastEntities)){const r=this.lastEntities[i],u=n.match(r.regex);if(u&&(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);n=n.replace(r.regex,r.val)}if(n.indexOf("&")===-1)return n;if(this.options.htmlEntities)for(const i of Object.keys(this.htmlEntities)){const r=this.htmlEntities[i],u=n.match(r.regex);if(u&&(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);n=n.replace(r.regex,r.val)}return n=n.replace(this.ampEntity.regex,this.ampEntity.val),n}function We(n,e,t,s){return n&&(s===void 0&&(s=e.child.length===0),n=this.parseTextData(n,e.tagname,t,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,s),n!==void 0&&n!==""&&e.add(this.options.textNodeName,n),n=""),n}function Ye(n,e){if(!n||n.length===0)return!1;for(let t=0;t<n.length;t++)if(e.matches(n[t]))return!0;return!1}function ze(n,e,t=">"){let s,i="";for(let r=e;r<n.length;r++){let u=n[r];if(s)u===s&&(s="");else if(u==='"'||u==="'")s=u;else if(u===t[0])if(t[1]){if(n[r+1]===t[1])return{data:i,index:r}}else return{data:i,index:r};else u===" "&&(u=" ");i+=u}}function w(n,e,t,s){const i=n.indexOf(e,t);if(i===-1)throw new Error(s);return i+e.length-1}function V(n,e,t,s=">"){const i=ze(n,e+1,s);if(!i)return;let r=i.data;const u=i.index,a=r.search(/\s/);let o=r,f=!0;a!==-1&&(o=r.substring(0,a),r=r.substring(a+1).trimStart());const l=o;if(t){const c=o.indexOf(":");c!==-1&&(o=o.substr(c+1),f=o!==i.data.substr(c+1))}return{tagName:o,tagExp:r,closeIndex:u,attrExpPresent:f,rawTagName:l}}function Ge(n,e,t){const s=t;let i=1;for(;t<n.length;t++)if(n[t]==="<")if(n[t+1]==="/"){const r=w(n,">",t,`${e} is not closed`);if(n.substring(t+2,r).trim()===e&&(i--,i===0))return{tagContent:n.substring(s,t),i:r};t=r}else if(n[t+1]==="?")t=w(n,"?>",t+1,"StopNode is not closed.");else if(n.substr(t+1,3)==="!--")t=w(n,"-->",t+3,"StopNode is not closed.");else if(n.substr(t+1,2)==="![")t=w(n,"]]>",t,"StopNode is not closed.")-2;else{const r=V(n,t,">");r&&((r&&r.tagName)===e&&r.tagExp[r.tagExp.length-1]!=="/"&&i++,t=r.closeIndex)}}function L(n,e,t){if(e&&typeof n=="string"){const s=n.trim();return s==="true"?!0:s==="false"?!1:we(n,t)}else return re(n)?n:""}function H(n,e,t){const s=Number.parseInt(n,e);return s>=0&&s<=1114111?String.fromCodePoint(s):t+n+";"}function R(n,e,t,s){if(n){const i=n(e);t===e&&(t=i),e=i}return e=Q(e,s),{tagName:e,tagExp:t}}function Q(n,e){if(Y.includes(n))throw new Error(`[SECURITY] Invalid name: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`);return k.includes(n)?e.onDangerousProperty(n):n}const F=N.getMetaDataSymbol();function Xe(n,e){if(!n||typeof n!="object")return{};if(!e)return n;const t={};for(const s in n)if(s.startsWith(e)){const i=s.substring(e.length);t[i]=n[s]}else t[s]=n[s];return t}function Ze(n,e,t,s){return D(n,e,t,s)}function D(n,e,t,s){let i;const r={};for(let u=0;u<n.length;u++){const a=n[u],o=Je(a);if(o!==void 0&&o!==e.textNodeName){const f=Xe(a[":@"]||{},e.attributeNamePrefix);t.push(o,f)}if(o===e.textNodeName)i===void 0?i=a[o]:i+=""+a[o];else{if(o===void 0)continue;if(a[o]){let f=D(a[o],e,t,s);const l=qe(f,e);if(a[":@"]?Ke(f,a[":@"],s,e):Object.keys(f).length===1&&f[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?f=f[e.textNodeName]:Object.keys(f).length===0&&(e.alwaysCreateTextNode?f[e.textNodeName]="":f=""),a[F]!==void 0&&typeof f=="object"&&f!==null&&(f[F]=a[F]),r[o]!==void 0&&Object.prototype.hasOwnProperty.call(r,o))Array.isArray(r[o])||(r[o]=[r[o]]),r[o].push(f);else{const c=e.jPath?s.toString():s;e.isArray(o,c,l)?r[o]=[f]:r[o]=f}o!==void 0&&o!==e.textNodeName&&t.pop()}}}return typeof i=="string"?i.length>0&&(r[e.textNodeName]=i):i!==void 0&&(r[e.textNodeName]=i),r}function Je(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t];if(s!==":@")return s}}function Ke(n,e,t,s){if(e){const i=Object.keys(e),r=i.length;for(let u=0;u<r;u++){const a=i[u],o=a.startsWith(s.attributeNamePrefix)?a.substring(s.attributeNamePrefix.length):a,f=s.jPath?t.toString()+"."+o:t;s.isArray(a,f,!0,!0)?n[a]=[e[a]]:n[a]=e[a]}}}function qe(n,e){const{textNodeName:t}=e,s=Object.keys(n).length;return!!(s===0||s===1&&(n[t]||typeof n[t]=="boolean"||n[t]===0))}class He{constructor(e){this.externalEntities={},this.options=be(e)}parse(e,t){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(t){t===!0&&(t={});const r=oe(e,t);if(r!==!0)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const s=new $e(this.options);s.addExternalEntities(this.externalEntities);const i=s.parseXml(e);return this.options.preserveOrder||i===void 0?i:Ze(i,this.options,s.matcher,s.readonlyMatcher)}addEntity(e,t){if(t.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(t==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return N.getMetaDataSymbol()}}const Qe={APPLET:"applet",BUSINESS_COMPONENT:"business_component",BUSINESS_OBJECT:"business_object",VIEW:"view",SCREEN:"screen",WORKFLOW:"workflow",INTEGRATION_OBJECT:"integration_object",BUSINESS_SERVICE:"business_service",WEB_TEMPLATE:"web_template",PICK_LIST:"pick_list",TABLE:"table"},De={FIELD:"field",COLUMN:"column",CONTROL:"control",LIST_COLUMN:"list_column",LINK:"link",APPLET_WEB_TEMPLATE:"web_template",VIEW_WEB_TEMPLATE:"web_template",VIEW_APPLET:"applet",SCREEN_VIEW:"view",APPLET_METHOD_MENU_ITEM:"menu_item",BUSINESS_OBJECT_COMPONENT:"business_component",BUSINESS_SERVICE_METHOD:"business_service",WORKFLOW_STEP:"workflow",INTEGRATION_COMPONENT:"business_component"},et=new Set(["NAME","INACTIVE"]);function $(n,e){const t=n[e];return Array.isArray(t)?t:t!=null?[t]:[]}function I(n,e){const t=n[`@_${e}`];return t!=null?String(t):void 0}function ee(n){const e=[];for(const[t,s]of Object.entries(n))t.startsWith("@_")&&!et.has(t.slice(2))&&e.push({name:t.slice(2),value:String(s)});return e}function tt(n,e){const t=[];for(const[s,i]of Object.entries(De))for(const r of $(n,s)){const u=r,a=I(u,"NAME");a&&t.push({name:a,type:i,properties:ee(u),children:[],parentName:e})}return t}function m(n,e){var t;return(t=n.properties.find(s=>s.name===e))==null?void 0:t.value}function nt(n){const e=[],t=new Map;for(const s of n)t.set(`${s.type}:${s.name}`,s);for(const s of n){if(s.type==="applet"){const i=m(s,"BUS_COMP");i&&t.has(`business_component:${i}`)&&e.push({from:{name:s.name,type:"applet"},to:{name:i,type:"business_component"},relationType:"references",inferred:!0})}if(s.type==="view"){const i=m(s,"BUS_OBJECT");i&&t.has(`business_object:${i}`)&&e.push({from:{name:s.name,type:"view"},to:{name:i,type:"business_object"},relationType:"references",inferred:!0});for(const r of s.children)if(r.type==="applet"){const u=m(r,"APPLET")??r.name;t.has(`applet:${u}`)&&e.push({from:{name:s.name,type:"view"},to:{name:u,type:"applet"},relationType:"contains",inferred:!0})}}if(s.type==="screen"){for(const i of s.children)if(i.type==="view"){const r=m(i,"VIEW")??i.name;t.has(`view:${r}`)&&e.push({from:{name:s.name,type:"screen"},to:{name:r,type:"view"},relationType:"contains",inferred:!0})}}if(s.type==="business_object"){for(const i of s.children)if(i.type==="business_component"){const r=m(i,"BUS_COMP")??i.name;t.has(`business_component:${r}`)&&e.push({from:{name:s.name,type:"business_object"},to:{name:r,type:"business_component"},relationType:"contains",inferred:!0})}}if(s.type==="workflow"){const i=m(s,"BUS_OBJECT");i&&t.has(`business_object:${i}`)&&e.push({from:{name:s.name,type:"workflow"},to:{name:i,type:"business_object"},relationType:"references",inferred:!0});for(const r of s.children){const u=m(r,"BUS_SERVICE");u&&t.has(`business_service:${u}`)&&e.push({from:{name:s.name,type:"workflow"},to:{name:u,type:"business_service"},relationType:"uses",inferred:!0})}}if(s.type==="integration_object"){const i=m(s,"BUS_COMP");i&&t.has(`business_component:${i}`)&&e.push({from:{name:s.name,type:"integration_object"},to:{name:i,type:"business_component"},relationType:"references",inferred:!0})}if(s.type==="business_component"){const i=m(s,"TABLE");i&&e.push({from:{name:s.name,type:"business_component"},to:{name:i,type:"table"},relationType:"based_on",inferred:!0});for(const r of s.children)if(r.type==="link"){const u=m(r,"CHILD_BC");u&&t.has(`business_component:${u}`)&&e.push({from:{name:s.name,type:"business_component"},to:{name:u,type:"business_component"},relationType:"linked_to",inferred:!0})}}}return e}self.onmessage=n=>{const{type:e,content:t,fileName:s}=n.data;if(e==="parse")try{self.postMessage({type:"progress",status:"parsing",progress:20});const r=new He({ignoreAttributes:!1,attributeNamePrefix:"@_",allowBooleanAttributes:!0,parseAttributeValue:!1,processEntities:{maxEntityCount:1e5,maxTotalExpansions:1e5,maxExpandedLength:1e7,maxEntitySize:1e5},isArray:()=>!0}).parse(t);self.postMessage({type:"progress",status:"extracting",progress:50});const u=$(r,"REPOSITORY");if(u.length===0){self.postMessage({type:"error",message:"SIF file missing REPOSITORY root element"});return}const a=u[0],o=I(a,"NAME")??"Unknown",f=$(a,"PROJECT"),l=f.length>0?I(f[0],"NAME"):void 0,c=[];for(const E of f){const O=E,S=I(O,"NAME")??"Unknown";for(const[d,A]of Object.entries(Qe))for(const x of $(O,d)){const j=x,B=I(j,"NAME");B&&c.push({name:B,type:A,project:S,properties:ee(j),children:tt(j,B),inactive:I(j,"INACTIVE")==="Y"||void 0})}}self.postMessage({type:"progress",status:"inferring",progress:80});const p=nt(c),y=[...new Set(c.map(E=>E.type))],P={metadata:{fileName:s,repositoryName:o,projectName:l,objectCount:c.length,objectTypes:y,extractedAt:new Date().toISOString()},objects:c,dependencies:p};self.postMessage({type:"progress",status:"done",progress:100}),self.postMessage({type:"result",data:P})}catch(i){self.postMessage({type:"error",message:i instanceof Error?i.message:String(i)})}}})();
@@ -1 +1 @@
1
- import{r as l,a as k,j as e}from"./index-C3Kad9YO.js";import{P,L as B}from"./constants-Dd6A34aQ.js";function $(){const[t,s]=l.useState([]),[u,n]=l.useState([]),[i,c]=l.useState(0),[x,b]=l.useState(!0),[h,f]=l.useState(null),d=l.useCallback(async()=>{b(!0),f(null);try{const[r,m]=await Promise.all([k.getSkills(),k.getRecommendations().catch(()=>({recommendations:[]}))]);s(r.skills),c(r.totalTokens),n(m.recommendations)}catch(r){f(r instanceof Error?r.message:"Failed to load skills")}finally{b(!1)}},[]);l.useEffect(()=>{d()},[d]);const N=l.useCallback(async(r,m)=>{s(C=>C.map(w=>w.name===r?{...w,enabled:m}:w));try{await k.toggleSkill(r,m)}catch{d()}},[d]),p=l.useCallback(async r=>{await k.createCustomSkill(r),d()},[d]),y=l.useCallback(async(r,m)=>{await k.updateCustomSkill(r,m),d()},[d]),j=l.useCallback(async r=>{await k.deleteCustomSkill(r),d()},[d]),g=t.filter(r=>r.enabled).reduce((r,m)=>r+m.estimatedTokens,0);return{skills:t,recommendations:u,totalTokens:i,activeTokens:g,loading:x,error:h,refresh:d,toggleSkill:N,createSkill:p,updateSkill:y,deleteSkill:j}}function D({skill:t,onClose:s,onToggle:u,onDelete:n,onEdit:i}){return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:c=>{c.target===c.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold truncate",children:t.name}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${t.source==="built-in"?"bg-blue-500/10 text-blue-500":t.source==="custom"?"bg-purple-500/10 text-purple-500":"bg-gray-500/10 text-gray-500"}`,children:t.source}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:t.category}),e.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:[t.estimatedTokens.toLocaleString()," tokens"]})]}),t.phases&&t.phases.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:t.phases.map(c=>{const x=P[c]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${x}20`,color:x},children:c},c)})}),e.jsx("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:c=>u(t.name,c.target.checked),className:"w-4 h-4 accent-accent"}),t.enabled?"Enabled":"Disabled"]})}),t.source==="custom"&&e.jsxs("div",{className:"flex gap-2",children:[i&&e.jsx("button",{onClick:()=>i(t),className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Edit"}),n&&t.id&&e.jsx("button",{onClick:()=>n(t.id),className:"px-3 py-1.5 text-sm text-red-500 border border-red-500/30 rounded hover:bg-red-500/10",children:"Delete"})]})]})}):null}const _=["know-me","software-design","security","testing","cost-reducer","research","ddd","frontend-design","other"];function F({open:t,onClose:s,onSubmit:u,editSkill:n}){const[i,c]=l.useState(""),[x,b]=l.useState(""),[h,f]=l.useState("know-me"),[d,N]=l.useState(["IMPLEMENT"]),[p,y]=l.useState(""),[j,g]=l.useState(!1),[r,m]=l.useState(null);l.useEffect(()=>{n?(c(n.name),b(n.description),f(n.category),N(n.phases??["IMPLEMENT"]),y("")):(c(""),b(""),f("know-me"),N(["IMPLEMENT"]),y("")),m(null)},[n,t]);const C=l.useCallback(a=>{N(S=>S.includes(a)?S.filter(T=>T!==a):[...S,a])},[]),w=l.useCallback(async()=>{if(!i.trim()||!x.trim()||!p.trim()||d.length===0){m("All fields are required and at least one phase must be selected.");return}g(!0),m(null);try{await u({name:i.trim(),description:x.trim(),category:h,phases:d,instructions:p.trim()}),s()}catch(a){m(a instanceof Error?a.message:"Failed to save skill")}finally{g(!1)}},[i,x,h,d,p,u,s]);return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[85vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:n?"Edit Skill":"Create Custom Skill"}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:a=>c(a.target.value),placeholder:"my-workflow",disabled:!!n,className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Description"}),e.jsx("input",{type:"text",value:x,onChange:a=>b(a.target.value),placeholder:"What does this skill do?",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Category"}),e.jsx("select",{value:h,onChange:a=>f(a.target.value),className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:_.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Phases"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:B.map(a=>e.jsx("button",{type:"button",onClick:()=>C(a),className:`px-2 py-1 text-[10px] font-medium rounded-full border transition-colors ${d.includes(a)?"bg-accent/10 border-accent text-accent":"border-edge text-muted hover:border-foreground"}`,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Instructions"}),e.jsx("textarea",{value:p,onChange:a=>y(a.target.value),rows:6,placeholder:"Instructions for the AI agent when this skill is active...",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt resize-y"})]}),r&&e.jsx("div",{className:"text-sm p-2 rounded bg-red-500/10 text-red-500",children:r}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:s,className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Cancel"}),e.jsx("button",{onClick:w,disabled:j,className:"px-3 py-1.5 text-sm bg-accent text-white rounded hover:opacity-90 disabled:opacity-50",children:j?"Saving...":n?"Update":"Create"})]})]})]})}):null}const I=4e3;function E({value:t,label:s}){return e.jsxs("div",{className:"p-3 rounded-xl border border-edge bg-surface-alt text-center","data-testid":"metric-card",children:[e.jsx("div",{className:"text-xl font-bold",children:t}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:s})]})}function z({phase:t}){const s=P[t]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${s}20`,color:s},children:t})}function G({source:t}){const s={"built-in":"bg-accent/10 text-accent",filesystem:"bg-muted/10 text-muted",custom:"bg-purple-500/10 text-purple-500"};return e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${s[t]}`,children:t})}function H({skill:t,onToggle:s,onClick:u}){return e.jsxs("div",{className:`p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt cursor-pointer hover:border-accent/50 transition-all ${t.enabled?"":"opacity-50"}`,onClick:()=>u(t),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:t.name}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:n=>{n.stopPropagation(),s(t.name,n.target.checked)},onClick:n=>n.stopPropagation(),className:"w-3.5 h-3.5 accent-accent"}),e.jsx(G,{source:t.source}),e.jsxs("span",{className:"text-[10px] text-muted",children:[t.estimatedTokens.toLocaleString()," tok"]})]})]}),e.jsx("p",{className:"text-xs text-muted line-clamp-2",children:t.description})]})}function A({phase:t,skills:s,onToggle:u,onSkillClick:n}){const[i,c]=l.useState(!0),x=P[t]??"#6b7280",b=s.filter(h=>h.enabled).length;return e.jsxs("div",{className:"rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c(!i),className:"w-full flex items-center justify-between px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:x}}),t,e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-edge text-[10px]",children:[b,"/",s.length]})]}),e.jsx("span",{className:"text-muted",children:i?"▲":"▼"})]}),i&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:s.map(h=>e.jsx(H,{skill:h,onToggle:u,onClick:n},h.name))})]})}function U({rec:t}){return e.jsxs("div",{className:"p-3 rounded-lg bg-surface-alt border border-accent/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:t.skill}),e.jsx(z,{phase:t.phase})]}),e.jsx("p",{className:"text-xs text-muted",children:t.reason})]})}function q({totalTokens:t,activeTokens:s}){const u=Math.min(s/I,1),n=Math.min(t/I,1),i=Math.round(u*100),c=u>.8?"#ef4444":u>.5?"#f59e0b":"#10b981";return e.jsxs("div",{"data-testid":"token-budget-bar",className:"p-4 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-muted",children:[s.toLocaleString()," active / ",t.toLocaleString()," total (",i,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-edge relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-30",style:{width:`${Math.round(n*100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${i}%`,background:c}})]})]})}function Y(){const{skills:t,recommendations:s,totalTokens:u,activeTokens:n,loading:i,error:c,refresh:x,toggleSkill:b,createSkill:h,updateSkill:f,deleteSkill:d}=$(),[N,p]=l.useState(null),[y,j]=l.useState(!1),[g,r]=l.useState(null),m=l.useCallback(async o=>{await d(o),p(null)},[d]),C=l.useCallback(o=>{p(null),r(o),j(!0)},[]),w=l.useCallback(async o=>{g!=null&&g.id?await f(g.id,o):await h(o),r(null)},[g,h,f]);if(c)return e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load skills: ",c]});if(i)return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-6",children:[e.jsx("div",{className:"h-5 w-32 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3",children:Array.from({length:5}).map((o,v)=>e.jsx("div",{className:"h-20 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))}),e.jsx("div",{className:"h-8 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((o,v)=>e.jsx("div",{className:"h-16 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))})]});const a=t.filter(o=>o.source==="built-in").length,S=t.filter(o=>o.source==="custom").length,T=t.filter(o=>o.enabled).length,M=new Map;for(const o of B){const v=t.filter(O=>{var R;return(R=O.phases)==null?void 0:R.includes(o)});v.length>0&&M.set(o,v)}const L=t.filter(o=>!o.phases||o.phases.length===0);return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6 overflow-y-auto h-full",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{r(null),j(!0)},className:"text-xs px-3 py-1.5 rounded-lg border border-accent text-accent hover:bg-accent/10 transition-colors",children:"+ Custom Skill"}),e.jsx("button",{onClick:()=>void x(),className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:opacity-90 transition-opacity",children:"Refresh"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3","data-testid":"skills-stats",children:[e.jsx(E,{value:t.length,label:"Total Skills"}),e.jsx(E,{value:a,label:"Built-in"}),e.jsx(E,{value:S,label:"Custom"}),e.jsx(E,{value:T,label:"Enabled"}),e.jsx(E,{value:n.toLocaleString(),label:"Active Tokens"})]}),e.jsx(q,{totalTokens:u,activeTokens:n}),s.length>0&&e.jsxs("div",{"data-testid":"recommendations-section",className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted uppercase",children:["Recommendations (",s.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2",children:s.map(o=>e.jsx(U,{rec:o},o.skill))})]}),e.jsxs("div",{"data-testid":"skills-by-phase",className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Skills by Lifecycle Phase"}),[...M.entries()].map(([o,v])=>e.jsx(A,{phase:o,skills:v,onToggle:b,onSkillClick:p},o)),L.length>0&&e.jsx(A,{phase:"Other",skills:L,onToggle:b,onSkillClick:p})]}),e.jsx(D,{skill:N,onClose:()=>p(null),onToggle:b,onDelete:m,onEdit:C}),e.jsx(F,{open:y,onClose:()=>{j(!1),r(null)},onSubmit:w,editSkill:g})]})}export{Y as SkillsTab};
1
+ import{r as l,a as k,j as e}from"./index-DrvFzUJS.js";import{P,L as B}from"./constants-DLyESMjx.js";function $(){const[t,s]=l.useState([]),[u,n]=l.useState([]),[i,c]=l.useState(0),[x,b]=l.useState(!0),[h,f]=l.useState(null),d=l.useCallback(async()=>{b(!0),f(null);try{const[r,m]=await Promise.all([k.getSkills(),k.getRecommendations().catch(()=>({recommendations:[]}))]);s(r.skills),c(r.totalTokens),n(m.recommendations)}catch(r){f(r instanceof Error?r.message:"Failed to load skills")}finally{b(!1)}},[]);l.useEffect(()=>{d()},[d]);const N=l.useCallback(async(r,m)=>{s(C=>C.map(w=>w.name===r?{...w,enabled:m}:w));try{await k.toggleSkill(r,m)}catch{d()}},[d]),p=l.useCallback(async r=>{await k.createCustomSkill(r),d()},[d]),y=l.useCallback(async(r,m)=>{await k.updateCustomSkill(r,m),d()},[d]),j=l.useCallback(async r=>{await k.deleteCustomSkill(r),d()},[d]),g=t.filter(r=>r.enabled).reduce((r,m)=>r+m.estimatedTokens,0);return{skills:t,recommendations:u,totalTokens:i,activeTokens:g,loading:x,error:h,refresh:d,toggleSkill:N,createSkill:p,updateSkill:y,deleteSkill:j}}function D({skill:t,onClose:s,onToggle:u,onDelete:n,onEdit:i}){return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:c=>{c.target===c.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold truncate",children:t.name}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${t.source==="built-in"?"bg-blue-500/10 text-blue-500":t.source==="custom"?"bg-purple-500/10 text-purple-500":"bg-gray-500/10 text-gray-500"}`,children:t.source}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:t.category}),e.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:[t.estimatedTokens.toLocaleString()," tokens"]})]}),t.phases&&t.phases.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:t.phases.map(c=>{const x=P[c]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${x}20`,color:x},children:c},c)})}),e.jsx("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:c=>u(t.name,c.target.checked),className:"w-4 h-4 accent-accent"}),t.enabled?"Enabled":"Disabled"]})}),t.source==="custom"&&e.jsxs("div",{className:"flex gap-2",children:[i&&e.jsx("button",{onClick:()=>i(t),className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Edit"}),n&&t.id&&e.jsx("button",{onClick:()=>n(t.id),className:"px-3 py-1.5 text-sm text-red-500 border border-red-500/30 rounded hover:bg-red-500/10",children:"Delete"})]})]})}):null}const _=["know-me","software-design","security","testing","cost-reducer","research","ddd","frontend-design","other"];function F({open:t,onClose:s,onSubmit:u,editSkill:n}){const[i,c]=l.useState(""),[x,b]=l.useState(""),[h,f]=l.useState("know-me"),[d,N]=l.useState(["IMPLEMENT"]),[p,y]=l.useState(""),[j,g]=l.useState(!1),[r,m]=l.useState(null);l.useEffect(()=>{n?(c(n.name),b(n.description),f(n.category),N(n.phases??["IMPLEMENT"]),y("")):(c(""),b(""),f("know-me"),N(["IMPLEMENT"]),y("")),m(null)},[n,t]);const C=l.useCallback(a=>{N(S=>S.includes(a)?S.filter(T=>T!==a):[...S,a])},[]),w=l.useCallback(async()=>{if(!i.trim()||!x.trim()||!p.trim()||d.length===0){m("All fields are required and at least one phase must be selected.");return}g(!0),m(null);try{await u({name:i.trim(),description:x.trim(),category:h,phases:d,instructions:p.trim()}),s()}catch(a){m(a instanceof Error?a.message:"Failed to save skill")}finally{g(!1)}},[i,x,h,d,p,u,s]);return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[85vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:n?"Edit Skill":"Create Custom Skill"}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:a=>c(a.target.value),placeholder:"my-workflow",disabled:!!n,className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Description"}),e.jsx("input",{type:"text",value:x,onChange:a=>b(a.target.value),placeholder:"What does this skill do?",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Category"}),e.jsx("select",{value:h,onChange:a=>f(a.target.value),className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:_.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Phases"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:B.map(a=>e.jsx("button",{type:"button",onClick:()=>C(a),className:`px-2 py-1 text-[10px] font-medium rounded-full border transition-colors ${d.includes(a)?"bg-accent/10 border-accent text-accent":"border-edge text-muted hover:border-foreground"}`,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Instructions"}),e.jsx("textarea",{value:p,onChange:a=>y(a.target.value),rows:6,placeholder:"Instructions for the AI agent when this skill is active...",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt resize-y"})]}),r&&e.jsx("div",{className:"text-sm p-2 rounded bg-red-500/10 text-red-500",children:r}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:s,className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Cancel"}),e.jsx("button",{onClick:w,disabled:j,className:"px-3 py-1.5 text-sm bg-accent text-white rounded hover:opacity-90 disabled:opacity-50",children:j?"Saving...":n?"Update":"Create"})]})]})]})}):null}const I=4e3;function E({value:t,label:s}){return e.jsxs("div",{className:"p-3 rounded-xl border border-edge bg-surface-alt text-center","data-testid":"metric-card",children:[e.jsx("div",{className:"text-xl font-bold",children:t}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:s})]})}function z({phase:t}){const s=P[t]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${s}20`,color:s},children:t})}function G({source:t}){const s={"built-in":"bg-accent/10 text-accent",filesystem:"bg-muted/10 text-muted",custom:"bg-purple-500/10 text-purple-500"};return e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${s[t]}`,children:t})}function H({skill:t,onToggle:s,onClick:u}){return e.jsxs("div",{className:`p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt cursor-pointer hover:border-accent/50 transition-all ${t.enabled?"":"opacity-50"}`,onClick:()=>u(t),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:t.name}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:n=>{n.stopPropagation(),s(t.name,n.target.checked)},onClick:n=>n.stopPropagation(),className:"w-3.5 h-3.5 accent-accent"}),e.jsx(G,{source:t.source}),e.jsxs("span",{className:"text-[10px] text-muted",children:[t.estimatedTokens.toLocaleString()," tok"]})]})]}),e.jsx("p",{className:"text-xs text-muted line-clamp-2",children:t.description})]})}function A({phase:t,skills:s,onToggle:u,onSkillClick:n}){const[i,c]=l.useState(!0),x=P[t]??"#6b7280",b=s.filter(h=>h.enabled).length;return e.jsxs("div",{className:"rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c(!i),className:"w-full flex items-center justify-between px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:x}}),t,e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-edge text-[10px]",children:[b,"/",s.length]})]}),e.jsx("span",{className:"text-muted",children:i?"▲":"▼"})]}),i&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:s.map(h=>e.jsx(H,{skill:h,onToggle:u,onClick:n},h.name))})]})}function U({rec:t}){return e.jsxs("div",{className:"p-3 rounded-lg bg-surface-alt border border-accent/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:t.skill}),e.jsx(z,{phase:t.phase})]}),e.jsx("p",{className:"text-xs text-muted",children:t.reason})]})}function q({totalTokens:t,activeTokens:s}){const u=Math.min(s/I,1),n=Math.min(t/I,1),i=Math.round(u*100),c=u>.8?"#ef4444":u>.5?"#f59e0b":"#10b981";return e.jsxs("div",{"data-testid":"token-budget-bar",className:"p-4 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-muted",children:[s.toLocaleString()," active / ",t.toLocaleString()," total (",i,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-edge relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-30",style:{width:`${Math.round(n*100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${i}%`,background:c}})]})]})}function Y(){const{skills:t,recommendations:s,totalTokens:u,activeTokens:n,loading:i,error:c,refresh:x,toggleSkill:b,createSkill:h,updateSkill:f,deleteSkill:d}=$(),[N,p]=l.useState(null),[y,j]=l.useState(!1),[g,r]=l.useState(null),m=l.useCallback(async o=>{await d(o),p(null)},[d]),C=l.useCallback(o=>{p(null),r(o),j(!0)},[]),w=l.useCallback(async o=>{g!=null&&g.id?await f(g.id,o):await h(o),r(null)},[g,h,f]);if(c)return e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load skills: ",c]});if(i)return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-6",children:[e.jsx("div",{className:"h-5 w-32 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3",children:Array.from({length:5}).map((o,v)=>e.jsx("div",{className:"h-20 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))}),e.jsx("div",{className:"h-8 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((o,v)=>e.jsx("div",{className:"h-16 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))})]});const a=t.filter(o=>o.source==="built-in").length,S=t.filter(o=>o.source==="custom").length,T=t.filter(o=>o.enabled).length,M=new Map;for(const o of B){const v=t.filter(O=>{var R;return(R=O.phases)==null?void 0:R.includes(o)});v.length>0&&M.set(o,v)}const L=t.filter(o=>!o.phases||o.phases.length===0);return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6 overflow-y-auto h-full",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{r(null),j(!0)},className:"text-xs px-3 py-1.5 rounded-lg border border-accent text-accent hover:bg-accent/10 transition-colors",children:"+ Custom Skill"}),e.jsx("button",{onClick:()=>void x(),className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:opacity-90 transition-opacity",children:"Refresh"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3","data-testid":"skills-stats",children:[e.jsx(E,{value:t.length,label:"Total Skills"}),e.jsx(E,{value:a,label:"Built-in"}),e.jsx(E,{value:S,label:"Custom"}),e.jsx(E,{value:T,label:"Enabled"}),e.jsx(E,{value:n.toLocaleString(),label:"Active Tokens"})]}),e.jsx(q,{totalTokens:u,activeTokens:n}),s.length>0&&e.jsxs("div",{"data-testid":"recommendations-section",className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted uppercase",children:["Recommendations (",s.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2",children:s.map(o=>e.jsx(U,{rec:o},o.skill))})]}),e.jsxs("div",{"data-testid":"skills-by-phase",className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Skills by Lifecycle Phase"}),[...M.entries()].map(([o,v])=>e.jsx(A,{phase:o,skills:v,onToggle:b,onSkillClick:p},o)),L.length>0&&e.jsx(A,{phase:"Other",skills:L,onToggle:b,onSkillClick:p})]}),e.jsx(D,{skill:N,onClose:()=>p(null),onToggle:b,onDelete:m,onEdit:C}),e.jsx(F,{open:y,onClose:()=>{j(!1),r(null)},onSubmit:w,editSkill:g})]})}export{Y as SkillsTab};