@kern0x1b/penstock-cli 26.11.1 → 26.11.2

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 (302) hide show
  1. package/THIRD-PARTY-NOTICES.md +16 -16
  2. package/dist/chunk-account-BaYNvO18.js +1 -0
  3. package/dist/{chunk-agentLaunch-D21uPuMr.js → chunk-agentLaunch-BnrpVME4.js} +1 -1
  4. package/dist/chunk-agentServe-BeOh1rjE.js +10 -0
  5. package/dist/chunk-agents-CZJoU2u2.js +1 -0
  6. package/dist/chunk-agentsMigrate-DnrqoXNz.js +2 -0
  7. package/dist/{chunk-analyze-BG-rlggA.js → chunk-analyze-ClE2LBCj.js} +1 -1
  8. package/dist/chunk-analyze-DgQqzEgb.js +1 -0
  9. package/dist/{chunk-analyzeFlow-2cYPgjh-.js → chunk-analyzeFlow-F2ZFmJhv.js} +1 -1
  10. package/dist/chunk-apiTemplates-Cl_z63FA.js +1 -0
  11. package/dist/{chunk-bot-DlhStBoG.js → chunk-bot-C2k8yaXA.js} +5 -5
  12. package/dist/chunk-cmmnFindings-DKpYqUZN.js +1 -0
  13. package/dist/{chunk-codeFactSet-LxSnQy8K.js → chunk-codeFactSet-DiAYqvbb.js} +1 -1
  14. package/dist/{chunk-codeIndex-N1gnP_sW.js → chunk-codeIndex-vStNh6Bm.js} +1 -1
  15. package/dist/chunk-codeLinks-BVpn4_Sr.js +1 -0
  16. package/dist/chunk-codeLinks-BrGduhsm.js +1 -0
  17. package/dist/chunk-command-8s6m3ZUw.js +5 -0
  18. package/dist/chunk-command-aMxPQdiV.js +1 -0
  19. package/dist/chunk-command-vH1_y5F0.js +1 -0
  20. package/dist/chunk-commands-B8YVT41b.js +5 -0
  21. package/dist/{chunk-commands-DcjlDt7B.js → chunk-commands-CJCSznbv.js} +1 -1
  22. package/dist/chunk-compose-BUJTvoFX.js +4 -0
  23. package/dist/chunk-connections-Drr67X9U.js +1 -0
  24. package/dist/chunk-connectors-DcMqy0u8.js +1 -0
  25. package/dist/chunk-convert-Ce1MZmsE.js +3 -0
  26. package/dist/chunk-convert-FkMnlxyi.js +1 -0
  27. package/dist/chunk-deploy-BHg8pB9x.js +1 -0
  28. package/dist/chunk-deploy-DZgCTgaY.js +6 -0
  29. package/dist/{chunk-diagrams-BukAOL0g.js → chunk-diagrams-CtGMGTa8.js} +1 -1
  30. package/dist/chunk-diff-9hjavV6V.js +1 -0
  31. package/dist/chunk-diff-Dp3fUALc.js +1 -0
  32. package/dist/chunk-dispatch-o-eqJb9Y.js +7 -0
  33. package/dist/chunk-dmnTests-BOxutoRs.js +1 -0
  34. package/dist/{chunk-dmnTests-ChwX1YVo.js → chunk-dmnTests-BzNA-u2k.js} +1 -1
  35. package/dist/{chunk-docs-D7yEDpa4.js → chunk-docs-B3C3pZpY.js} +17 -17
  36. package/dist/chunk-doctor-CRxbsAm7.js +1 -0
  37. package/dist/{chunk-editPreview-CC2vwhIW.js → chunk-editPreview-DCUnMkTU.js} +1 -1
  38. package/dist/chunk-evidence-ny_2ltVe.js +23 -0
  39. package/dist/{chunk-examples-0HkF-frb.js → chunk-examples-BG0lGXcZ.js} +9 -9
  40. package/dist/chunk-export-Blwjf23H.js +1 -0
  41. package/dist/chunk-export-kt3sBTZu.js +20 -0
  42. package/dist/{chunk-facts-DSVaURw5.js → chunk-facts-Dl5lLriU.js} +1 -1
  43. package/dist/chunk-failure-BRyRvObj.js +1 -0
  44. package/dist/{chunk-file-BswMa3FN.js → chunk-file-1YhfNmPn.js} +1 -1
  45. package/dist/chunk-import-Dh3az4BC.js +6 -0
  46. package/dist/chunk-importCommand-Dhikkmo0.js +1 -0
  47. package/dist/chunk-incident-LJe2-ohi.js +1 -0
  48. package/dist/chunk-init-D34Q4YA8.js +227 -0
  49. package/dist/chunk-lint-CnEhoYRB.js +1 -0
  50. package/dist/{chunk-lsp-7vA_mIt1.js → chunk-lsp-BzeJkpmf.js} +1 -1
  51. package/dist/chunk-main-BZF-ErAx.js +1 -0
  52. package/dist/chunk-mcp-B_B9bet5.js +95 -0
  53. package/dist/{chunk-mcpLaunch-LyfmIF_Z.js → chunk-mcpLaunch-BS709697.js} +1 -1
  54. package/dist/chunk-migrate-DVfXC-iJ.js +1 -0
  55. package/dist/chunk-migrate-DwWg0k5_.js +16 -0
  56. package/dist/{chunk-migrateApply-CzOkgKhB.js → chunk-migrateApply-e8O9oZXP.js} +3 -3
  57. package/dist/chunk-migrateVerify-oIBf-PM3.js +1 -0
  58. package/dist/{chunk-model-f8AzYUK7.js → chunk-model-BulEKnY1.js} +2 -2
  59. package/dist/{chunk-parse-B-uKGDy-.js → chunk-parse-DiOcpdOU.js} +1 -1
  60. package/dist/{chunk-penstockCli-CKMvaZ0O.js → chunk-penstockCli-C41P_G7i.js} +1 -1
  61. package/dist/chunk-policy-BVb7c7G_.js +1 -0
  62. package/dist/chunk-policyGate-BOgKsqLq.js +2 -0
  63. package/dist/chunk-pr-1jKcTNnP.js +1 -0
  64. package/dist/{chunk-project-DBYOlYRi.js → chunk-project-COaBZhMt.js} +1 -1
  65. package/dist/chunk-project-lO_6DX8G.js +1 -0
  66. package/dist/chunk-promotion-CTMPjXjZ.js +2 -0
  67. package/dist/chunk-promotion-DDLrgBqZ.js +1 -0
  68. package/dist/{chunk-promotion-DchO6xoC.js → chunk-promotion-NeRj4uTP.js} +1 -1
  69. package/dist/chunk-receipt-C4NqnSkH.js +1 -0
  70. package/dist/chunk-receiptDeps-B7MehyHT.js +1 -0
  71. package/dist/chunk-receiptGate-BZCKCMTV.js +1 -0
  72. package/dist/chunk-receiptGate-DRcw327y.js +1 -0
  73. package/dist/{chunk-receiptSnapshot-B6ruXw8z.js → chunk-receiptSnapshot-CHSk3_4N.js} +1 -1
  74. package/dist/{chunk-receiptStore-Cy-L0H1u.js → chunk-receiptStore-DhROtI2h.js} +1 -1
  75. package/dist/chunk-refactor-CO3qyIEv.js +17 -0
  76. package/dist/chunk-refactor-CWeCOl7w.js +1 -0
  77. package/dist/{chunk-render-Ci5d6mg4.js → chunk-render-DZd5hScS.js} +1 -1
  78. package/dist/chunk-report-w7YZwhyg.js +1 -0
  79. package/dist/chunk-review-DYMgFDSy.js +1 -0
  80. package/dist/chunk-say-CP1IyOSv.js +1 -0
  81. package/dist/{chunk-security-VgKwtohm.js → chunk-security-pgip-kdY.js} +2 -2
  82. package/dist/chunk-serve-CKt2rO05.js +10 -0
  83. package/dist/{chunk-share-CBV2FuKq.js → chunk-share-rsL0itIM.js} +18 -18
  84. package/dist/chunk-stages-B2sBBxUc.js +3 -0
  85. package/dist/chunk-systemError-O3vQ8hLb.js +1 -0
  86. package/dist/chunk-systemError-n2E6isvg.js +1 -0
  87. package/dist/chunk-taskTest-DWoME1mY.js +2 -0
  88. package/dist/chunk-taskTest-JErgWO6t.js +1 -0
  89. package/dist/{chunk-templateDiagnostics-BwH7RNkz.js → chunk-templateDiagnostics-6txfKwas.js} +2 -2
  90. package/dist/chunk-templates-Y3xfCO_3.js +1 -0
  91. package/dist/chunk-testCases-BwimUfDC.js +4 -0
  92. package/dist/chunk-testCases-DO2Rkyvd.js +1 -0
  93. package/dist/chunk-tests-Cy325OGw.js +1 -0
  94. package/dist/chunk-tests-DNkORsqB.js +23 -0
  95. package/dist/{chunk-trust-DXcsUJaK.js → chunk-trust-DSX-k3by.js} +1 -1
  96. package/dist/{chunk-trust-DubjEjlN.js → chunk-trust-Di4EYPah.js} +1 -1
  97. package/dist/{chunk-variableChecks-KnECGMR3.js → chunk-variableChecks-CBDpmI4d.js} +1 -1
  98. package/dist/{chunk-workerVariables-CajAcbwl.js → chunk-workerVariables-CNnCRijJ.js} +1 -1
  99. package/dist/{chunk-workerVariables-DIDoUpHF.js → chunk-workerVariables-CulLc3YH.js} +1 -1
  100. package/dist/chunk-wrapper-CGYED7G2.js +1 -0
  101. package/dist/chunk-wrapper-CK7Xtes6.js +3 -0
  102. package/dist/grammars/web-tree-sitter.wasm +0 -0
  103. package/dist/penstock.js +1 -1
  104. package/dist/web/assets/{AgentSettings-Cn5Vcph3.js → AgentSettings-D24jOuht.js} +1 -1
  105. package/dist/web/assets/{AgentsDialog-C6WqzlxZ.js → AgentsDialog-BMWv3Gyk.js} +1 -1
  106. package/dist/web/assets/{AgentsDialog-dpbwVSxk.js → AgentsDialog-DbY2O6O5.js} +1 -1
  107. package/dist/web/assets/{AgentsTab-C34OhVkw.js → AgentsTab-D6LbK6sG.js} +2 -2
  108. package/dist/web/assets/{BpmnCanvas-yur9daZa.js → BpmnCanvas-BcQRQ2Br.js} +27 -27
  109. package/dist/web/assets/BpmnDocument-Ce5F4K1e.js +27 -0
  110. package/dist/web/assets/CmmnDocument-C_UlPowC.js +17 -0
  111. package/dist/web/assets/{ConflictDialog-Bb5kduaR.js → ConflictDialog-DfFp8F7n.js} +1 -1
  112. package/dist/web/assets/{ConnectionsDialog-qtF7yDFw.js → ConnectionsDialog-BaYtHD5h.js} +1 -1
  113. package/dist/web/assets/{DiffDocument-LHOif5Ac.js → DiffDocument-BOPdBEN3.js} +1 -1
  114. package/dist/web/assets/{DmnDocument-0f5uS67x.css → DmnDocument-DZ9u2uk2.css} +1 -1
  115. package/dist/web/assets/DmnDocument-vtnARy7Q.js +41 -0
  116. package/dist/web/assets/{DriftDialog-Chl6BX6k.js → DriftDialog-dIbCbSK2.js} +1 -1
  117. package/dist/web/assets/FormDocument-B0q8DF9v.css +1 -0
  118. package/dist/web/assets/FormDocument-DHBUBUzO.js +32 -0
  119. package/dist/web/assets/FormStepView-CbHb32_8.js +1 -0
  120. package/dist/web/assets/{GraphAwareLayoutService-wsos3yPD.js → GraphAwareLayoutService-C5N8K9dm.js} +1 -1
  121. package/dist/web/assets/{MigrationDialog-CBJU7Oe3.js → MigrationDialog-DA3Vrzgw.js} +1 -1
  122. package/dist/web/assets/{NewFileDialog-B7075LWG.js → NewFileDialog-Dev41oA1.js} +1 -1
  123. package/dist/web/assets/PolicyDialog-qR19Csji.js +1 -0
  124. package/dist/web/assets/{QuickOpen-DJQrI7Od.js → QuickOpen-ps-rMjiS.js} +1 -1
  125. package/dist/web/assets/ScriptPane-BQLMNYzc.js +2 -0
  126. package/dist/web/assets/{ScriptRunDialog-BwE4cXnp.js → ScriptRunDialog-YivjHB6j.js} +1 -1
  127. package/dist/web/assets/{SettingsDialog-c307wPsg.js → SettingsDialog-DI0vZ6Ay.js} +1 -1
  128. package/dist/web/assets/ShortcutsDialog-DLXnv4Vm.js +1 -0
  129. package/dist/web/assets/SourceDocument-Cj8cGsoS.js +1 -0
  130. package/dist/web/assets/TemplateDocument-BRyFsofH.js +7 -0
  131. package/dist/web/assets/TextDocument-DB2hEuMA.js +1 -0
  132. package/dist/web/assets/{UnreadableFileLayer-CUP_30X8.js → UnreadableFileLayer-CRW3MM7w.js} +1 -1
  133. package/dist/web/assets/{UploadDialog-CaVBOxUL.js → UploadDialog-D-X6GG98.js} +1 -1
  134. package/dist/web/assets/Viewer-BcpDlvg_.js +4 -0
  135. package/dist/web/assets/apply-Nsj6ek02.js +1 -0
  136. package/dist/web/assets/{bpmnTheme-CZ7xp4R5.js → bpmnTheme-pKgl9Mrn.js} +2 -2
  137. package/dist/web/assets/{data-ZauKnQ2Z.js → data-CdiToGOq.js} +2 -2
  138. package/dist/web/assets/{data-Da5Nxzev.js → data-wU6sw6RY.js} +1 -1
  139. package/dist/web/assets/{dialog-DSLu1Bbo.js → dialog-BDJ5dDiU.js} +1 -1
  140. package/dist/web/assets/{diff-C4hitkRR.js → diff-BhYqTg4l.js} +1 -1
  141. package/dist/web/assets/dist-27z6Phtg.js +23 -0
  142. package/dist/web/assets/{dist-CofBTWz1.js → dist-B7TL-7R3.js} +4 -4
  143. package/dist/web/assets/dist-BEpeEbIu.js +1 -0
  144. package/dist/web/assets/{dist-CYCbBoYQ.js → dist-BTf7NfeQ.js} +1 -1
  145. package/dist/web/assets/{dist-CJKVV2_S.js → dist-BqGv7f4M.js} +10 -10
  146. package/dist/web/assets/dist-C-q1IWjr.js +6 -0
  147. package/dist/web/assets/{dist-Blylfrak.js → dist-CJx_2eBF.js} +2 -2
  148. package/dist/web/assets/dist-COUY_jv5.js +1 -0
  149. package/dist/web/assets/{dist-DpDu6Wz_.js → dist-CWjAtsKe.js} +1 -1
  150. package/dist/web/assets/{dist-gb3IfUZi.js → dist-Cv8_A_95.js} +2 -2
  151. package/dist/web/assets/dist-DDE6BjgI.js +5 -0
  152. package/dist/web/assets/{dist-7VC_hKpw.js → dist-DDNYYQtV.js} +1 -1
  153. package/dist/web/assets/dist-DW-S9iZN.js +1 -0
  154. package/dist/web/assets/dist-OnU5n5o1.js +1 -0
  155. package/dist/web/assets/dmn-Cgoh6wXm.js +3 -0
  156. package/dist/web/assets/{documentBridge-1Eg7H9yI.js → documentBridge-CHw4XsZH.js} +3 -3
  157. package/dist/web/assets/{documents-LG-7CTrn.js → documents-CEtohzAC.js} +1 -1
  158. package/dist/web/assets/duplicate-D_ic-m62.js +342 -0
  159. package/dist/web/assets/{engines-DhO6OW1S.js → engines-lyEvb0pH.js} +1 -1
  160. package/dist/web/assets/{executable-BTarDLry.js → executable--4381_Lf.js} +1 -1
  161. package/dist/web/assets/{file-CIeVSOHy.js → file-BbVBUuIH.js} +1 -1
  162. package/dist/web/assets/formChecks-CSClH9sH.js +1 -0
  163. package/dist/web/assets/frontend-uXAWaalt.js +1 -0
  164. package/dist/web/assets/{httpHost-DBSjdVth.js → httpHost-C973OTRe.js} +1 -1
  165. package/dist/web/assets/{index.es-pigASDxC.js → index.es-CMvq8Bhe.js} +3 -3
  166. package/dist/web/assets/index.es-GbdJvMnO.js +78 -0
  167. package/dist/web/assets/{index.esm-CTLpq4ik.js → index.esm-Ba6q0zSu.js} +1 -1
  168. package/dist/web/assets/{intelligence-_1C71hkQ.js → intelligence-DNqJNmdB.js} +3 -3
  169. package/dist/web/assets/{jspdf.es.min-PgZzOmkT.js → jspdf.es.min-C0L4zezU.js} +6 -6
  170. package/dist/web/assets/{kind-X3_nabTt.js → kind-DDHnk6dW.js} +1 -1
  171. package/dist/web/assets/{lib-BmLAen_d.js → lib-DrkEMJ65.js} +1 -1
  172. package/dist/web/assets/{list-DovB9lWV.js → list-TmXvCwja.js} +1 -1
  173. package/dist/web/assets/{migrationHost-BcguK4K5.js → migrationHost-DCWBb3L6.js} +1 -1
  174. package/dist/web/assets/moddle-f0Q4Guwd.js +1 -0
  175. package/dist/web/assets/{model--Bj28IOj.js → model-afHgSxJs.js} +1 -1
  176. package/dist/web/assets/{nudges-UF9_cBuO.js → nudges-DPG3WpyV.js} +1 -1
  177. package/dist/web/assets/{open-C9Kt9JLw.js → open-Vkx72dYx.js} +1 -1
  178. package/dist/web/assets/platform-G53Cenyw.js +2 -0
  179. package/dist/web/assets/{preload-helper-VRuDKI9K.js → preload-helper-DExCAR_V.js} +1 -1
  180. package/dist/web/assets/{run-BZgz1U9U.js → run-BMfRBe5O.js} +1 -1
  181. package/dist/web/assets/samples-BL3jA_Vd.js +1 -0
  182. package/dist/web/assets/{say-WvEHqIbO.js → say-BkdZMivA.js} +1 -1
  183. package/dist/web/assets/{say-ChFGKK2E.js → say-C7KqKcFr.js} +1 -1
  184. package/dist/web/assets/{sections-N6WYk7b8.js → sections-LJKSRDTS.js} +1 -1
  185. package/dist/web/assets/sharedReader-BsXfiBT8.js +1 -0
  186. package/dist/web/assets/{source-frame-DcptKpVq.js → source-frame-DC4W0A5-.js} +2 -2
  187. package/dist/web/assets/{syntax-DW10Wzg4.js → syntax-00Hk6Xv7.js} +4 -4
  188. package/dist/web/assets/{template-CMl68jPp.js → template-BQP7ZXdK.js} +1 -1
  189. package/dist/web/assets/testCaseRuns-liAhWMg7.js +1 -0
  190. package/dist/web/assets/{trace-DLziNpe2.js → trace-DXQU2N_l.js} +1 -1
  191. package/dist/web/assets/{translator-DLDFsUlE.js → translator-BLCeE6UY.js} +1 -1
  192. package/dist/web/assets/ui-BLtm3Y1J.js +1 -0
  193. package/dist/web/assets/{useTrace-UYBskc2k.js → useTrace-dZdQ805W.js} +1 -1
  194. package/dist/web/assets/web-C4k0NLZ9.js +982 -0
  195. package/dist/web/assets/web-CnDpD6qy.css +1 -0
  196. package/dist/web/assets/{workerVariables-DURgyUbG.js → workerVariables-O6VqwDzr.js} +1 -1
  197. package/dist/web/assets/xml-DIWt4von.js +1 -0
  198. package/dist/web/index.html +39 -40
  199. package/package.json +5 -5
  200. package/dist/chunk-account-CpZu-RTg.js +0 -1
  201. package/dist/chunk-agentServe-BYRtgGGD.js +0 -10
  202. package/dist/chunk-agents-B9oxdPTA.js +0 -1
  203. package/dist/chunk-agentsMigrate-BV8TeRXq.js +0 -2
  204. package/dist/chunk-analyze-pgzR-Cx-.js +0 -1
  205. package/dist/chunk-apiTemplates-cU7C8vap.js +0 -1
  206. package/dist/chunk-cmmnFindings-S2TGSnEp.js +0 -1
  207. package/dist/chunk-codeLinks-C8N6e8k3.js +0 -1
  208. package/dist/chunk-codeLinks-o0a8tBGk.js +0 -1
  209. package/dist/chunk-command-Bqlbgo-2.js +0 -1
  210. package/dist/chunk-command-DT84ioJb.js +0 -5
  211. package/dist/chunk-command-DrGP2kg8.js +0 -1
  212. package/dist/chunk-commands-B4PoZbpX.js +0 -5
  213. package/dist/chunk-compose-CWKKVtN5.js +0 -4
  214. package/dist/chunk-connections-DQpKbIGD.js +0 -1
  215. package/dist/chunk-connectors-PtAvE91B.js +0 -1
  216. package/dist/chunk-convert-CpgtOlZk.js +0 -1
  217. package/dist/chunk-convert-HbFpg8ab.js +0 -3
  218. package/dist/chunk-deploy-l4MdFfn8.js +0 -6
  219. package/dist/chunk-deploy-qRaaKGZb.js +0 -1
  220. package/dist/chunk-diff-BhTFlCE3.js +0 -1
  221. package/dist/chunk-diff-kBF83vzM.js +0 -1
  222. package/dist/chunk-dispatch-BnO-QhMh.js +0 -7
  223. package/dist/chunk-dmnTests-0x_yUH6S.js +0 -1
  224. package/dist/chunk-doctor-BuHK1dTm.js +0 -1
  225. package/dist/chunk-evidence-oLw_C6j8.js +0 -23
  226. package/dist/chunk-export-cIFHDXug.js +0 -1
  227. package/dist/chunk-export-jBVxtmCH.js +0 -20
  228. package/dist/chunk-failure-D5brrYW2.js +0 -1
  229. package/dist/chunk-import-BBOe-5RZ.js +0 -6
  230. package/dist/chunk-importCommand-DRjYoljA.js +0 -1
  231. package/dist/chunk-incident-BK1h37CD.js +0 -1
  232. package/dist/chunk-init-_OALJuKm.js +0 -227
  233. package/dist/chunk-lint-7KJFxyCN.js +0 -1
  234. package/dist/chunk-main-Cw2JXCil.js +0 -1
  235. package/dist/chunk-mcp-K63bhqnF.js +0 -95
  236. package/dist/chunk-migrate-BMwBV5sc.js +0 -16
  237. package/dist/chunk-migrate-CxfVmKt0.js +0 -1
  238. package/dist/chunk-migrateVerify-DSEXSpfR.js +0 -1
  239. package/dist/chunk-policy-BX0Ftdws.js +0 -1
  240. package/dist/chunk-policyGate-dmcufnwB.js +0 -2
  241. package/dist/chunk-pr-ByrGcfam.js +0 -1
  242. package/dist/chunk-project-DA3KnAZH.js +0 -1
  243. package/dist/chunk-promotion-Boedyq43.js +0 -1
  244. package/dist/chunk-promotion-D8Ti-vxp.js +0 -2
  245. package/dist/chunk-receipt-CusJaqNn.js +0 -1
  246. package/dist/chunk-receiptDeps-oVbX156d.js +0 -1
  247. package/dist/chunk-receiptGate-DrGChj7i.js +0 -1
  248. package/dist/chunk-receiptGate-xldHKMyJ.js +0 -1
  249. package/dist/chunk-refactor-B1W_MGTp.js +0 -1
  250. package/dist/chunk-refactor-BJXxEtVs.js +0 -17
  251. package/dist/chunk-report-D9pM09Nu.js +0 -1
  252. package/dist/chunk-review-UcqS5AAi.js +0 -1
  253. package/dist/chunk-say-CYb4HeJD.js +0 -1
  254. package/dist/chunk-serve-Dmqen1yd.js +0 -10
  255. package/dist/chunk-stages-BTQJrAMF.js +0 -3
  256. package/dist/chunk-systemError-BYrMzp2o.js +0 -1
  257. package/dist/chunk-systemError-CXvnhNPK.js +0 -1
  258. package/dist/chunk-taskTest-9gMsx0zu.js +0 -2
  259. package/dist/chunk-taskTest-BjXYpG5p.js +0 -1
  260. package/dist/chunk-templates-D3ouIwHD.js +0 -1
  261. package/dist/chunk-testCases-9jwT_Y7z.js +0 -4
  262. package/dist/chunk-testCases-BcpBPg9L.js +0 -1
  263. package/dist/chunk-tests-CEEXnWOp.js +0 -23
  264. package/dist/chunk-tests-CRVosdWp.js +0 -1
  265. package/dist/chunk-wrapper-B2WnOIoB.js +0 -3
  266. package/dist/chunk-wrapper-DiKCKZti.js +0 -1
  267. package/dist/web/assets/BpmnDocument-C247Rqim.js +0 -27
  268. package/dist/web/assets/CmmnDocument-Dj48bsUd.js +0 -17
  269. package/dist/web/assets/DmnDocument-Cb9Zi9fS.js +0 -41
  270. package/dist/web/assets/FormDocument-DoZaxWd-.js +0 -32
  271. package/dist/web/assets/FormDocument-URLcKn84.css +0 -1
  272. package/dist/web/assets/FormStepView-D8MFcpeI.js +0 -1
  273. package/dist/web/assets/PolicyDialog-CGdglmDn.js +0 -1
  274. package/dist/web/assets/ScriptPane-T6M5f6fc.js +0 -2
  275. package/dist/web/assets/ShortcutsDialog-BAoL9EHu.js +0 -1
  276. package/dist/web/assets/SourceDocument-C9KIzBA5.js +0 -1
  277. package/dist/web/assets/TemplateDocument-CNt2turg.js +0 -7
  278. package/dist/web/assets/TextDocument-CtkHoEqN.js +0 -1
  279. package/dist/web/assets/Viewer-DZske1C5.js +0 -4
  280. package/dist/web/assets/apply-nnKP9HIM.js +0 -1
  281. package/dist/web/assets/dist--PmHUHDp.js +0 -1
  282. package/dist/web/assets/dist-BoPrKCf2.js +0 -5
  283. package/dist/web/assets/dist-C1m02xAO.js +0 -1
  284. package/dist/web/assets/dist-CLqJMzT-.js +0 -1
  285. package/dist/web/assets/dist-D3jqq0XS.js +0 -1
  286. package/dist/web/assets/dist-DA-9F0U9.js +0 -1
  287. package/dist/web/assets/dist-DojzF5q2.js +0 -6
  288. package/dist/web/assets/dist-yvjzrXXf.js +0 -23
  289. package/dist/web/assets/dmn-DwdcYXGr.js +0 -3
  290. package/dist/web/assets/duplicate-D-ilQqKz.js +0 -342
  291. package/dist/web/assets/formChecks-CGox1z7R.js +0 -1
  292. package/dist/web/assets/frontend-Qq5hBH0U.js +0 -1
  293. package/dist/web/assets/index.es-CcNNw3VB.js +0 -78
  294. package/dist/web/assets/moddle-DJxj0oEU.js +0 -1
  295. package/dist/web/assets/platform-BLPhsye9.js +0 -2
  296. package/dist/web/assets/samples-oeXBsJ9Y.js +0 -1
  297. package/dist/web/assets/sharedReader-Bopy7Uk9.js +0 -1
  298. package/dist/web/assets/testCaseRuns-B_XdqGFh.js +0 -1
  299. package/dist/web/assets/ui-BTKMbWYG.js +0 -1
  300. package/dist/web/assets/web-FzNBw1kZ.css +0 -1
  301. package/dist/web/assets/web-jPMZVwbQ.js +0 -982
  302. package/dist/web/assets/xml-DTgZ-B-l.js +0 -1
@@ -0,0 +1,17 @@
1
+ import{r as e}from"./chunk-translator-DNm9zRpP.js";import{t}from"./chunk-context-rCJvBM9p.js";import{_ as n}from"./chunk-load-rfn3E0t5.js";import{a as r,c as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,s as m,t as h,u as g}from"./chunk-jsonScan-DH9djCOu.js";import{a as _,o as v}from"./chunk-moddle-D3Ym38EZ.js";import{i as y,t as b}from"./chunk-variables-CXAMjZIR.js";import{a as x}from"./chunk-safeWrite-RgLbdyzl.js";import{n as S,t as C}from"./chunk-codeScan-C09My9xv.js";import{i as w,r as T}from"./chunk-folders-C7ae1oPV.js";import E from"node:path";import{closeSync as D,constants as O,fstatSync as ee,lstatSync as k,openSync as te,readFileSync as ne,readSync as re,readdirSync as ie,realpathSync as A}from"node:fs";import{spawnSync as ae}from"node:child_process";import{createHash as oe}from"node:crypto";import{parser as se}from"@bpmn-io/lezer-feel";const ce=[`for`,`in`,`return`,`if`,`then`,`else`,`some`,`every`,`satisfies`,`and`,`or`,`between`,`instance`,`of`,`function`,`external`],le=[`true`,`false`],ue=[`**`,`!=`,`<=`,`>=`],de={"(":`open_parenthesis`,")":`close_parenthesis`,"[":`open_bracket`,"]":`close_bracket`,"{":`open_brace`,"}":`close_brace`},fe=/* @__PURE__ */ new Map([[`message`,`MESSAGE`],[`signal`,`SIGNAL`],[`error`,`ERROR`],[`job-type`,`JOB_TYPE`],[`topic`,`TOPIC`],[`decision`,`DECISION`],[`form`,`FORM`],[`process`,`PROCESS`]]),pe=[`variable`,`message`,`signal`,`error`,`escalation`,`job-type`,`topic`,`decision`,`form`,`process`],j=()=>({sites:[],refused:[]}),me=[`getVariable`,`getVariableLocal`,`getVariableTyped`,`getVariableLocalTyped`,`hasVariable`,`hasVariableLocal`,`setVariable`,`setVariableLocal`,`removeVariable`,`removeVariableLocal`,`variable`,`withVariable`,`putValue`,`putValueTyped`,`get_variable`,`set_variable`,`has_variable`,`remove_variable`],he=[`escalationCode`,`throwEscalation`,`escalation_code`],ge=RegExp(`(?<![\\w$])(?:${me.join(`|`)})\\s*\\(\\s*`,`g`),_e=RegExp(`(?<![\\w$])(?:${he.join(`|`)})\\s*(?:\\(\\s*|=\\s*)`,`g`),ve=/@(?:Variable|VariableValue|ZeebeVariable)\s*\(\s*(?:(?:name|value)\s*=\s*)?/g,M=[`"`,`'`,"`"],ye=/@(?:Variable|VariableValue|ZeebeVariable)(?![\w(])/g,be=/^\s*(?:final\s+)?[\w.$<>[\],? ]{1,120}?\s+([A-Za-z_$][\w$]*)\s*[,)=]/,xe=/^\s*(?:val\s+|var\s+)?([A-Za-z_$][\w$]*)\s*:/;function Se(e,t,n){let r=e[t];return M.includes(r)&&e.startsWith(n,t+1)&&e[t+1+n.length]===r}function Ce(e,t,n,r){let i=j();for(let a of e.matchAll(t)){let o=a.index+a[0].length;Se(e,o,n)?i.sites.push({start:o+1,end:o+1+n.length,where:r}):!M.includes(e[o])&&/[\w$]/.test(e[o]??``)&&t===ge&&i.refused.push({start:o,reason:`dynamicName`,where:r})}return i}function we(e,t){let n=j();for(let r of e.matchAll(ye)){let i=r.index+r[0].length,a=e.slice(i,i+160),o=be.exec(a)??xe.exec(a);o?.[1]===t&&n.refused.push({start:i+a.indexOf(t,o.index),reason:`boundByName`,where:`@Variable`})}return n}function Te(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)--n;return n<0?``:e[n]}function Ee(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n+=1;return n<e.length?e[n]:``}function De(e,t,n){let r={sites:[],refused:[...t.refused]};for(let n of t.sites){let t=Te(e,n.start-1),i=Ee(e,n.end+1);t===`+`||i===`+`?r.refused.push({start:n.start,reason:`concatenation`,where:n.where}):r.sites.push(n)}let i=new Set(r.sites.map(e=>e.start));for(let t=e.indexOf(n);t>=0;t=e.indexOf(n,t+1))M.includes(e[t-1]??``)&&e[t-1]===e[t+n.length]&&!i.has(t)&&!r.refused.some(e=>e.start===t)&&r.refused.push({start:t,reason:`literal`,where:`literal`});return r}function Oe(e,t,n){if(!t.includes(n))return j();if(e===`variable`){let e=Ce(t,ge,n,`getVariable`),r=Ce(t,ve,n,`@Variable`),i=we(t,n);return De(t,{sites:[...e.sites,...r.sites],refused:[...e.refused,...i.refused]},n)}return e===`escalation`?De(t,Ce(t,_e,n,`escalationCode`),n):De(t,{sites:p(fe.get(e),n,t).map(e=>({start:e.start,end:e.end,where:e.where})),refused:[]},n)}const ke=/[\p{L}\p{N}_$]/u;function Ae(e,t,n){let r=j();for(let i=e.indexOf(t);i>=0;i=e.indexOf(t,i+1)){let a=e[i-1]??``,o=e[i+t.length]??``;ke.test(a)||ke.test(o)||M.includes(a)||a===`.`||n.has(i)||r.refused.push({start:i,reason:`script`,where:`script`})}return r}const je=4e3,Me=e=>/\.(ya?ml|properties)$/i.test(e),N=e=>e.toLowerCase().replace(/[-_]/g,``);function Ne(e){return e.split(`.`).map(e=>e.replace(/\[[^\]]*]/g,``).trim()).filter(e=>e!==``)}function Pe(e,t){let n=[],r=0;for(let i of e.split(`.`)){let e=i.replace(/\[[^\]]*]/g,``).trim();e!==``&&n.push(e===i?t+r+(i.length-i.trimStart().length):null),r+=i.length+1}return n}function Fe(e,t){let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n+=1;let r=e[n];if((r===`"`||r===`'`)&&e.indexOf(r,n+1)>0){let t=e.indexOf(r,n+1);return{start:n+1,end:t,quoted:!0}}let i=e.length,a=e.indexOf(` #`,n);for(a>=0&&(i=a);i>n&&(e[i-1]===` `||e[i-1]===` `||e[i-1]===`\r`);)--i;return{start:n,end:i,quoted:!1}}function Ie(e){let t=[],n=0;for(let r of e.split(`
2
+ `)){let e=n;if(n+=r.length+1,r.length>je)continue;let i=r.trimStart(),a=r.length-i.length;if(i===``||i[0]===`#`||i[0]===`!`)continue;let o=-1;for(let e=a;e<r.length;e+=1)if(r[e]===`=`||r[e]===`:`){o=e;break}if(o<0)continue;let s=r.slice(a,o).trimEnd(),c=Fe(r,o+1),l=s.lastIndexOf(`.`);t.push({segments:Ne(s),starts:Pe(s,e+a),item:!1,keyStart:e+a+(l<0?0:l+1),keyEnd:e+a+s.length,valueStart:e+c.start,valueEnd:e+c.end,value:r.slice(c.start,c.end)})}return t}function Le(e){let t=e[0];if(t===`"`||t===`'`){let n=e.indexOf(t,1);return n<0||e[n+1]!==`:`?null:{key:e.slice(1,n),end:n+1}}for(let t=0;t<e.length;t+=1){if(e[t]===`:`&&(t+1===e.length||e[t+1]===` `||e[t+1]===` `))return t===0?null:{key:e.slice(0,t).trimEnd(),end:t};if(e[t]===`#`&&t>0&&e[t-1]===` `||e[t]===`{`||e[t]===`[`)return null}return null}function Re(e){let t=[],n=[],r=0;for(let i of e.split(`
3
+ `)){let e=r;if(r+=i.length+1,i.length>je)continue;let a=i.trimStart();if(a===``||a[0]===`#`||a.startsWith(`---`)||a.startsWith(`...`))continue;let o=i.length-a.length,s=a,c=!1;for(;s.startsWith(`- `)||s===`-`;){c=!0;let e=s.length>1?2:1;o+=e,s=s.slice(e).trimStart()}for(;n.length>0&&n[n.length-1].indent>=o;)n.pop();let l=n.length>0?n[n.length-1].segments:[],u=c&&s===``?null:Le(s);if(!u){if(c&&s!==``){let n=Fe(i,i.length-s.length);t.push({segments:l,starts:l.map(()=>null),item:!0,keyStart:e,keyEnd:e,valueStart:e+n.start,valueEnd:e+n.end,value:i.slice(n.start,n.end)})}continue}let d=i.length-s.length,f=[...l,...Ne(u.key)],p=Fe(i,d+u.end+1),m=Ne(u.key),h=s[0]===`"`||s[0]===`'`;t.push({segments:f,starts:[...l.map(()=>null),...h?m.map((t,n)=>n===0&&m.length===1?e+d+1:null):Pe(u.key,e+d)],item:!1,keyStart:e+d+ +(s[0]===`"`||s[0]===`'`),keyEnd:e+d+(s[0]===`"`||s[0]===`'`?u.end-1:u.key.length),valueStart:e+p.start,valueEnd:e+p.end,value:i.slice(p.start,p.end)}),p.start>=p.end&&n.push({indent:o,segments:f})}return t}const ze={topic:[`topicname`],process:[`processdefinitionkey`,`bpmnprocessid`,`processid`],decision:[`decisionid`,`decisiondefinitionkey`],message:[`messagename`],signal:[`signalname`],error:[`errorcode`],escalation:[`escalationcode`],form:[`formid`,`formkey`],"job-type":[`jobtype`]};function Be(e,t){let n=N(t.segments[t.segments.length-1]??``),r=t.segments.map(N);return e===`job-type`&&n===`type`&&(r.includes(`worker`)||r.includes(`workers`)||r.includes(`jobworker`))||e===`process`&&t.item&&n===`processdefinitionkeys`?!0:(ze[e]??[]).includes(n)}function Ve(e,t,n){if(e!==`topic`||t.item)return null;let r=t.segments.map(N).indexOf(`subscriptions`);return(r>=0&&t.segments[r+1]===n?t.starts[r+1]:null)??null}function He(e){let t=[],n=0;for(let r of e.value.split(`,`)){let i=r.length-r.trimStart().length,a=r.trim();a!==``&&t.push({start:e.valueStart+n+i,end:e.valueStart+n+i+a.length,text:a}),n+=r.length+1}return t}function Ue(e,t,n,r){let i=j();if(!n.includes(r)||!Me(t))return i;let a=/\.properties$/i.test(t)?Ie(n):Re(n);for(let t of a){let n=t.segments.join(`.`),a=Ve(e,t,r);if(a!==null){i.sites.push({start:a,end:a+r.length,where:n});continue}let o=t.value.includes(r);if(o||t.segments.includes(r)){if(o&&e===`variable`&&N(t.segments[t.segments.length-1]??``)===`fetchvariables`){let e=He(t).filter(e=>e.text===r);for(let t of e)i.sites.push({start:t.start,end:t.end,where:n});e.length===0&&i.refused.push({start:t.valueStart,reason:`literal`,where:n})}else o&&Be(e,t)?t.value===r?i.sites.push({start:t.valueStart,end:t.valueEnd,where:n}):t.value.includes("${")?i.refused.push({start:t.valueStart,reason:`placeholder`,where:n}):i.refused.push({start:t.valueStart,reason:`literal`,where:n}):(t.value===r||t.value.includes(`"${r}"`)||t.segments.includes(r))&&i.refused.push({start:t.value===r?t.valueStart:t.keyStart,reason:`literal`,where:n})}}return i}const P=/\s/u,We=/\p{Nd}/u,Ge=/[\p{L}\p{Nl}\p{Sc}\p{Pc}]/u,Ke=/[\p{L}\p{Nl}\p{Sc}\p{Pc}\p{Mn}\p{Mc}\p{Nd}\p{Cf}]/u;function F(e,t,n){return t<n?e.charAt(t):``}function qe(e,t,n,r){let i=n;for(;i<r&&e.charAt(i)!==t;)i++;return i}function Je(e,t,n){let r=t;for(;r<n&&P.test(e.charAt(r));)r++;return{kind:`whitespace`,end:r}}function Ye(e,t,n,r){let i=F(e,t,n),a=P.test(i)?Je(e,t,n):Xe(e,t,n,r);return a.kind===`whitespace`?{kind:a.kind,end:a.end,afterDot:r}:{kind:a.kind,end:a.end,afterDot:a.kind===`punctuation`&&i===`.`}}function Xe(e,t,n,r){let i=F(e,t,n),a=F(e,t+1,n);return i===`/`&&a===`/`?{kind:`line_comment`,end:qe(e,`
4
+ `,t,n)}:i===`/`&&a===`*`?Qe(e,t,n):i===`"`?$e(e,t,n,`string`):i===`@`&&a===`"`?$e(e,t+1,n,`temporal`):i==="`"?tt(e,t,n):We.test(i)?{kind:`number`,end:nt(e,t,n)}:Ge.test(i)?at(e,t,n,r):i===`.`&&a===`.`?{kind:`operator`,end:t+2}:i===`.`?{kind:`punctuation`,end:t+1}:ue.includes(i+a)?{kind:`operator`,end:t+2}:i!==``&&`+-*/=<>`.includes(i)?{kind:`operator`,end:t+1}:{kind:Ze(i),end:t+1}}function Ze(e){return e in de?de[e]??`bad`:e!==``&&`,:?;`.includes(e)?`punctuation`:`bad`}function Qe(e,t,n){let r=t+2;for(;r+1<n&&(e.charAt(r)!==`*`||e.charAt(r+1)!==`/`);)r++;return{kind:`block_comment`,end:r+1<n?r+2:n}}function $e(e,t,n,r){let i=et(e,t,n);return i<0?{kind:`bad`,end:n}:{kind:r,end:i+1}}function et(e,t,n){let r=t+1;for(;r<n;){let t=e.charAt(r);if(t===`\\`)r+=2;else if(t===`"`)return r;else r++}return-1}function tt(e,t,n){let r=qe(e,"`",t+1,n);return r<n?{kind:`backtick_name`,end:r+1}:{kind:`bad`,end:n}}function nt(e,t,n){let r=rt(e,t,n);return F(e,r,n)===`.`&&We.test(F(e,r+1,n))&&(r=rt(e,r+1,n)),r}function rt(e,t,n){let r=t;for(;r<n&&We.test(e.charAt(r));)r++;return r}function it(e){return ce.includes(e)||le.includes(e)||e===`null`}function at(e,t,n,r){let i=ot(e,t,n);if(r)return{kind:`property`,end:i};let a=e.slice(t,i);if(a===`date`){let t=ct(e,i,n);if(t!==void 0)return{kind:`function`,end:t}}if(ce.includes(a))return{kind:`keyword`,end:i};if(le.includes(a))return{kind:`boolean`,end:i};if(a===`null`)return{kind:`null`,end:i};let o=st(e,i,n);return{kind:F(e,o,n)===`(`?`function`:`name`,end:o}}function ot(e,t,n){let r=t+1;for(;r<n&&Ke.test(e.charAt(r));)r++;return r}function st(e,t,n){let r=t;for(;r+1<n&&e.charAt(r)===` `&&Ge.test(e.charAt(r+1));){let t=ot(e,r+1,n);if(it(e.slice(r+1,t)))break;r=t}return r}function ct(e,t,n){let r=lt(e,t,n,`and`);if(r===void 0)return;let i=lt(e,r,n,`time`);if(i===void 0)return;let a=i;for(;a<n&&P.test(e.charAt(a));)a++;return F(e,a,n)===`(`?i:void 0}function lt(e,t,n,r){let i=t;for(;i<n&&P.test(e.charAt(i));)i++;if(i===t)return;let a=i+r.length;if(!(a>n||e.slice(i,a)!==r))return a<n&&Ke.test(e.charAt(a))?void 0:a}function I(e){let t=[],n=0,r=!1;for(;n<e.length;){let i=Ye(e,n,e.length,r);i.kind!==`whitespace`&&t.push({kind:i.kind,start:n,end:i.end,text:e.slice(n,i.end)}),r=i.afterDot,n=i.end}return t}function ut(e,t){return t.reduce((e,t)=>t.kind===`backtick_name`?e.slice(0,t.start)+`x`.repeat(t.end-t.start)+e.slice(t.end):e,e)}function dt(e,t=I(e)){return se.parse(ut(e,t))}const ft={open_parenthesis:`close_parenthesis`,open_bracket:`close_bracket`,open_brace:`close_brace`},pt=new Set(Object.values(ft)),mt=/* @__PURE__ */ new Set([`operator`,`keyword`]);function ht(e){let t;return e.iterate({enter(e){e.type.isError&&(t===void 0||e.from<t)&&(t=e.from)}}),t}function gt(e){return e!==void 0&&e.kind===`operator`&&e.text===`=`}function _t(e){return e.flatMap((t,n)=>{let r=e[n+1];return!gt(t)||!gt(r)||r?.start!==t.end?[]:[{problem:`DOUBLE_EQUALS`,start:t.start,end:r.end,text:`==`,replacement:`=`}]})}function vt(e){return e.filter(e=>e.kind===`name`&&e.text.includes(` `)).map(e=>({problem:`SPACED_NAME`,start:e.start,end:e.end,text:e.text,replacement:"`"+e.text+"`"}))}function yt(e){return e.flatMap((t,n)=>{let r=e[n+1];return t.kind!==`number`||r===void 0||r.kind!==`name`||r.start!==t.end?[]:[{problem:`UNEXPECTED_TOKEN`,start:r.start,end:r.end,text:r.text}]})}function bt(e){let t=[];for(let n of e){let e=t[t.length-1];n.kind in ft?t.push(n):e!==void 0&&pt.has(n.kind)&&ft[e.kind]===n.kind&&t.pop()}let n=t[t.length-1];return n?{problem:`UNCLOSED_BRACKET`,start:n.start,end:n.end,text:n.text}:void 0}function xt(e){let t=e.find(e=>e.kind===`keyword`&&e.text===`if`);if(t&&!e.some(e=>e.kind===`keyword`&&e.text===`else`))return{problem:`MISSING_ELSE`,start:t.start,end:t.end,text:t.text}}function St(e){let t=e[e.length-1];return t&&mt.has(t.kind)?{problem:`ENDS_TOO_EARLY`,start:t.start,end:t.end,text:t.text}:void 0}function Ct(e,t){let n=e.find(e=>e.end>t);if(n&&n.kind===`bad`&&`"'`.includes(n.text.charAt(0)))return{problem:`UNTERMINATED_STRING`,start:n.start,end:n.end,text:n.text}}function wt(e,t){let n=e.find(e=>e.end>t);return n?{problem:`UNEXPECTED_TOKEN`,start:n.start,end:n.end,text:n.text}:void 0}function Tt(e){if(e.trim()===``)return;let t=I(e),n=[..._t(t),...vt(t),...yt(t)],r=n.map(e=>e.start),i=ht(dt(e,t));if(i!==void 0&&r.push(i),r.length===0)return;let a=Math.min(...r);return n.find(e=>e.start<=a&&a<e.end)??bt(t)??xt(t)??St(t)??Ct(t,a)??wt(t,a)??{problem:`NOT_FEEL`,start:0,end:e.length,text:e.trim()}}const Et=/* @__PURE__ */ new Set([`for`,`some`,`every`]),Dt=/* @__PURE__ */ new Set([`name`,`property`,`close_bracket`,`close_parenthesis`,`string`,`backtick_name`]);function Ot(e,t){return e!==void 0&&e.kind===`keyword`&&e.text===t}function kt(e,t){return e!==void 0&&e.kind===`punctuation`&&e.text===t}function At(e){return e.kind===`name`?e.text:e.kind===`backtick_name`?e.text.slice(1,-1):null}function jt(e,t){let n=/* @__PURE__ */ new Set;if(e[t]?.kind!==`open_parenthesis`)return n;for(let r=t+1;r<e.length&&e[r].kind!==`close_parenthesis`;r+=1)At(e[r])!==null&&!kt(e[r-1],`:`)&&n.add(r);return n}function Mt(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i.kind===`open_brace`?n.push(!0):i.kind===`close_brace`&&n.pop(),(At(i)??(i.kind===`string`?i.text.slice(1,-1):null))!==t){if(Ot(i,`function`)&&[...jt(e,r+1)].some(n=>At(e[n])===t))return i;continue}let a=e[r-1],o=e[r+1];if(n.length>0&&kt(o,`:`)||a!==void 0&&a.kind===`keyword`&&Et.has(a.text)||Ot(o,`in`)&&(kt(a,`,`)||a!==void 0&&a.kind===`keyword`&&Et.has(a.text)))return i}return null}function Nt(e){let t=[],n=[],r=0;for(let i=0;i<e.length;i+=1){let a=e[i];if(a.kind===`open_bracket`){let n=i>0&&Dt.has(e[i-1].kind);t.push(n),n&&(r+=1)}n.push(r),a.kind===`close_bracket`&&t.length>0&&t.pop()===!0&&--r}return n}function L(e,t){let n=j();if(!e.includes(t))return n;if(Tt(e)!==void 0)return n.refused.push({start:e.indexOf(t),reason:`syntax`,where:`expression`}),n;let r=I(e),i=Mt(r,t);if(i)return n.refused.push({start:i.start,reason:`binding`,where:`expression`}),n;let a=Nt(r);return r.forEach((e,r)=>{if(At(e)!==t)return;let i=+(e.kind===`backtick_name`),o=e.start+i,s=e.end-i;a[r]>0?n.refused.push({start:o,reason:`filter`,where:`expression`}):n.sites.push({start:o,end:s,where:`expression`})}),n}function Pt(e,t){let n=j();if(!e.includes(t))return n;let r=I(e);return r.length===1&&r[0].kind===`string`&&r[0].text===`"${t}"`?(n.sites.push({start:r[0].start+1,end:r[0].end-1,where:`expression`}),n):(n.refused.push({start:e.indexOf(t),reason:`dynamicExpression`,where:`expression`}),n)}const Ft=[[`<!--`,`-->`],[`<![CDATA[`,`]]>`],[`<?`,`?>`]];function It(e,t,n){return e.slice(t,n).replace(/[^\r\n]/g,` `)}function Lt(e){let t=``,n=0,r=e.indexOf(`<`);for(;r>=0;){let i=Ft.find(([t])=>e.startsWith(t,r));if(i===void 0){r=e.indexOf(`<`,r+1);continue}let a=e.indexOf(i[1],r+i[0].length),o=a<0?e.length:a+i[1].length;t+=e.slice(n,r)+It(e,r,o),n=o,r=e.indexOf(`<`,o)}return t+e.slice(n)}const Rt=/[A-Za-z_$][\w$]*/g,zt=/* @__PURE__ */ RegExp(`\\b(?:getVariable|getVariableTyped|getVariableLocal|getVariableLocalTyped|hasVariable|hasVariableLocal|setVariable|setVariableLocal|removeVariable)\\s*\\(\\s*`,`g`);function Bt(e){let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(r!==`"`&&r!==`'`){t+=r;continue}let i=n+1;for(;i<e.length&&e[i]!==r;)i+=e[i]===`\\`?2:1;t+=r+` `.repeat(Math.max(0,Math.min(i,e.length)-n-1))+(i<e.length?r:``),n=i}return t}function Vt(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)--n;return n<0?``:e[n]}function Ht(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n+=1;return e.slice(n,n+64)}function Ut(e){let t=[];for(let n=0;n<e.length-1;n+=1){if(e[n]!==`$`&&e[n]!==`#`||e[n+1]!==`{`)continue;let r=1,i=n+2;for(;i<e.length&&r>0;){let t=e[i];if(t===`"`||t===`'`)for(i+=1;i<e.length&&e[i]!==t;)i+=e[i]===`\\`?2:1;else t===`{`?r+=1:t===`}`&&--r;i+=1}if(r>0)return t;t.push({start:n+2,end:i-1}),n=i-1}return t}function Wt(e,t){let n=j();if(!e.includes(t))return n;for(let r of Ut(e)){let i=e.slice(r.start,r.end),a=Bt(i);if(a.includes(`->`)&&i.includes(t))n.refused.push({start:r.start+i.indexOf(t),reason:`binding`,where:`expression`});else{for(let e of a.matchAll(Rt)){if(e[0]!==t)continue;let i=e.index,o=i+t.length;if(Vt(a,i)===`.`)continue;let s=Ht(a,o);s.startsWith(`(`)||/^:\s*[A-Za-z_$][\w$]*\s*\(/.test(s)||n.sites.push({start:r.start+i,end:r.start+o,where:`expression`})}for(let e of i.matchAll(zt)){let a=e.index+e[0].length,o=i[a];if(o!==`"`&&o!==`'`){n.refused.push({start:r.start+a,reason:`dynamicName`,where:`expression`});continue}let s=i.indexOf(o,a+1);s>0&&i.slice(a+1,s)===t&&n.sites.push({start:r.start+a+1,end:r.start+s,where:`expression`})}}}return n}function Gt(e){for(let t of Ut(e)){let n=e.slice(t.start,t.end);for(let e of n.matchAll(zt)){let t=n[e.index+e[0].length];if(t!==`"`&&t!==`'`)return!0}}return!1}const Kt={target:[`input`,`output`,`in`,`out`],source:[`in`,`out`],name:[`inputParameter`,`outputParameter`],resultVariable:`*`,inputElement:[`loopCharacteristics`],outputCollection:[`loopCharacteristics`],initiator:`*`,errorCodeVariable:`*`,errorMessageVariable:`*`,elementVariable:`*`,collection:`*`,id:[`formField`]},qt=/* @__PURE__ */ new Set([`input`,`output`]),Jt=/* @__PURE__ */ new Set([`delegateExpression`]),Yt=/* @__PURE__ */ new Set([`documentation`,`text`,`textAnnotation`,`extensionElements`]),Xt=/* @__PURE__ */ new Set([`inputExpression`,`literalExpression`]),Zt=/^(camunda-forms:bpmn:)(.+)$/,Qt=(e,t)=>e.includes(t)||e.includes(`&`),R=e=>e.slice(e.indexOf(`:`)+1);function $t(e,t){let n=t.end-t.start;return{value:e.slice(t.start,t.end),starts:Array.from({length:n},(e,n)=>t.start+n),ends:Array.from({length:n},(e,n)=>t.start+n+1)}}function en(e,t){let n={value:``,starts:[],ends:[]};for(let r of t){let t=r.cdata?$t(e,r):l(e,r.start,r.end);n.value+=t.value;for(let e=0;e<t.starts.length;e+=1)n.starts.push(t.starts[e]),n.ends.push(t.ends[e])}return n}function z(e,t,n,r){for(let i of t.sites){let t=g(e,i.start,i.end);t.encoded?n.refused.push({start:t.start,reason:`encoded`,where:r}):n.sites.push({start:t.start,end:t.end,where:r})}for(let i of t.refused){let t=e.starts[Math.min(i.start,e.starts.length-1)]??0;n.refused.push({...i,start:t,where:r})}}function tn(e,t){return{sites:e.sites.map(e=>({...e,start:e.start+t,end:e.end+t})),refused:e.refused.map(e=>({...e,start:e.start+t}))}}function nn(e,t){let n=e.length-e.trimStart().length;return e.slice(n).startsWith(`=`)?tn(L(e.slice(n+1),t),n+1):L(e,t)}function rn(e,t){return{sites:e===t||e.startsWith(t)&&(e[t.length]===`.`||e[t.length]===`[`)?[{start:0,end:t.length,where:``}]:[],refused:[]}}function an(e,t){let n=e.trimStart();return n.startsWith(`=`)?nn(e,t):n.includes("${")||n.includes(`#{`)?Wt(e,t):j()}function on(e,t){let n=Oe(`variable`,e,t),r=Ae(e,t,/* @__PURE__ */ new Set([...n.sites.map(e=>e.start),...n.refused.map(e=>e.start)]));return{sites:n.sites,refused:[...r.refused,...n.refused]}}function sn(e,t){let n=Kt[R(t)];return n===`*`||n!==void 0&&n.includes(e.local)}function cn(e,t,n,r,i){for(let a of t.attributes){if(a.name.startsWith(`xmlns`)||!Qt(e.slice(a.start,a.end),n))continue;let o=l(e,a.start,a.end);if(!o.value.includes(n))continue;let s=`${t.name}@${a.name}`,c=R(a.name),u=o.value;r?(t.local===`inputData`||t.local===`variable`&&t.parent?.local===`inputData`)&&c===`name`&&z(o,rn(u,n),i,s):c===`source`&&qt.has(t.local)?z(o,nn(u,n),i,s):sn(t,a.name)&&!u.includes("${")&&!u.trimStart().startsWith(`=`)?z(o,rn(u,n),i,s):Jt.has(c)||z(o,an(u,n),i,s)}}function ln(e,t,n,r,i){if(t.text.length===0||!r&&Yt.has(t.local)||!t.text.some(t=>Qt(e.slice(t.start,t.end),n)))return;let a=en(e,t.text);a.value.includes(n)&&(r?t.parent!==null&&Xt.has(t.parent.local)&&z(a,L(a.value,n),i,`${t.parent.name}/${t.name}`):t.local===`script`?z(a,on(a.value,n),i,t.name):z(a,an(a.value,n),i,t.name))}function un(e,t,n,r){let i=j();for(let a of t)cn(e,a,n,r,i),ln(e,a,n,r,i);return i}function dn(e,t,n,r,i,a){for(let o of t)for(let t of o.attributes)R(t.name)===n&&e.slice(t.start,t.end)===`${r}${i}`&&a.sites.push({start:t.start+r.length,end:t.end,where:`${o.name}@${t.name}`})}function fn(e,t,n,r,i){let a=t=>e.some(e=>e.local===t&&f(e,`id`)?.value===r);n===`process`&&a(`process`)&&(dn(t,e,`bpmnElement`,``,r,i),dn(t,e,`processRef`,``,r,i)),n===`decision`&&a(`decision`)&&(dn(t,e,`dmnElementRef`,``,r,i),dn(t,e,`href`,`#`,r,i))}function pn(e,t,n){let r=j();for(let i of t)for(let t of i.attributes){if(R(t.name)!==`escalationCode`)continue;let a=l(e,t.start,t.end),o=`${i.name}@${t.name}`;a.value===n?r.sites.push({start:t.start,end:t.end,where:o}):a.value.startsWith(`=`)&&z(a,tn(Pt(a.value.slice(1),n),1),r,o)}return r}function mn(e,t,n,r){for(let i of t)for(let t of i.attributes){if(R(t.name)!==`formKey`)continue;let a=Zt.exec(e.slice(t.start,t.end));a&&a[2]===n&&r.sites.push({start:t.start+a[1].length,end:t.end,where:`${i.name}@${t.name}`})}}function hn(e,t,n,r,i){for(let o of a(n,e)){let e=l(t,o.start,o.end);e.value.startsWith(`=`)&&z(e,tn(Pt(e.value.slice(1),r),1),i,o.where)}}function gn(e){let t=/* @__PURE__ */ new Set,n=e.sites.filter(e=>!t.has(e.start)&&(t.add(e.start),!0)),r=/* @__PURE__ */ new Set;return{sites:n,refused:e.refused.filter(e=>{let n=`${e.start}:${e.reason}`;return t.has(e.start)||r.has(n)?!1:(r.add(n),!0)})}}function _n(e,t,n,r){if(!t.includes(n)&&!t.includes(`&#`))return j();let a=i(t);if(a.problem!==null||a.root===null)return{sites:[],refused:[{start:0,reason:`malformed`,where:`xml`}]};if(e===`variable`)return gn(un(t,a.elements,n,r));if(e===`escalation`)return gn(pn(t,a.elements,n));let o=fe.get(e),s=Lt(t),c=j();for(let e of u(o,n,s))c.sites.push({start:e.start,end:e.end,where:e.where});return hn(s,t,o,n,c),fn(a.elements,t,e,n,c),e===`form`&&mn(t,a.elements,n,c),gn(c)}function vn(e,t){return/\.form$/i.test(e)?`form`:/\.json$/i.test(e)?t.includes(`cpt-test-cases`)?`cases`:t.includes(`element-templates`)||/(^|\/)element-templates\//.test(e.replace(/\\/g,`/`))?`template`:null:null}const yn=/\{\{([^{}]{0,400})}}/g;function bn(e,t,n,r){e.value===t&&(e.plain?r.sites.push({start:e.start,end:e.end,where:n}):r.refused.push({start:e.start,reason:`escaped`,where:n}))}function xn(e,t,n,r){(e.value===t||e.value.startsWith(t)&&(e.value[t.length]===`.`||e.value[t.length]===`[`))&&(e.plain?r.sites.push({start:e.start,end:e.start+t.length,where:n}):r.refused.push({start:e.start,reason:`escaped`,where:n}))}function Sn(e,t,n,r,i){if(!e.value.includes(t))return;let a=e.value.length-e.value.trimStart().length,o=e.value.slice(a),s=[];if(o.startsWith(`=`))s.push({from:a+1,text:o.slice(1)});else if(!i&&o.includes(`{{`))for(let e of o.matchAll(yn))s.push({from:a+e.index+2,text:e[1]});for(let a of s){let o=i?Pt(a.text,t):L(a.text,t);if(!e.plain)(o.sites.length>0||o.refused.length>0)&&r.refused.push({start:e.start,reason:`escaped`,where:n});else{for(let t of o.sites)r.sites.push({start:e.start+a.from+t.start,end:e.start+a.from+t.end,where:n});for(let t of o.refused)r.refused.push({...t,start:e.start+a.from+t.start,where:n})}}}function Cn(e,t){let n=j();return r(e,(e,r,i)=>{e.kind===`string`&&(r?.kind===`object`&&(i===`key`||i===`valuesKey`)?xn(e,t,i,n):Sn(e,t,`expression`,n,!1))}),n}const wn={"zeebe:taskDefinition:type":`job-type`,"zeebe:taskDefinition":`job-type`,"zeebe:calledElement":`process`,"zeebe:calledDecision":`decision`,"zeebe:formDefinition":`form`,"bpmn:Message#property":`message`,"bpmn:Signal#property":`signal`,"bpmn:Error#property":`error`,"bpmn:Escalation#property":`escalation`};function Tn(e,t,n){let i=j();return r(e,e=>{if(e.kind!==`object`)return;let r=h(e,`binding`)?.value,a=c(e,`value`);if(r?.kind!==`object`)return;let o=c(r,`type`)?.value??``;if(t===`variable`){let e=c(r,`name`);(o===`zeebe:input`||o===`camunda:inputParameter`||o===`camunda:outputParameter`)&&e&&xn(e,n,`binding.name`,i);let t=c(r,`source`);t&&(o===`zeebe:output`||o===`camunda:outputParameter`)&&En(t,n,i),a&&o===`zeebe:output`&&xn(a,n,`value`,i),a&&Sn(a,n,`value`,i,!1)}else a&&wn[o]===t&&(bn(a,n,`binding ${o}`,i),Sn(a,n,`binding ${o}`,i,!0))}),i}function En(e,t,n){if(!e.plain){e.value.includes(t)&&n.refused.push({start:e.start,reason:`escaped`,where:`binding.source`});return}let r=/^\s*=?/.exec(e.value)?.[0].length??0,i=L(e.value.slice(r),t);for(let t of i.sites)n.sites.push({start:e.start+r+t.start,end:e.start+r+t.end,where:`binding.source`});for(let t of i.refused)n.refused.push({...t,start:e.start+r+t.start,where:`binding.source`})}const Dn={"job-type":[`jobType`],error:[`errorCode`],process:[`processDefinitionId`],decision:[`decisionDefinitionId`],signal:[`signalName`],escalation:[`escalationCode`]};function On(e,t,n){let i=j();return r(e,(e,r,a)=>{if(t===`variable`){if(e.kind===`object`&&a===`variables`&&r!==null)for(let t of e.members)t.key===n&&(t.keyPlain?i.sites.push({start:t.keyStart,end:t.keyEnd,where:`variables`}):i.refused.push({start:t.keyStart,reason:`escaped`,where:`variables`}))}else e.kind===`string`&&r?.kind===`object`&&a!==null&&((Dn[t]??[]).includes(a)||t===`message`&&a===`name`&&kn(r))&&bn(e,n,a,i)}),i}function kn(e){let t=c(e,`type`)?.value??``;return t===`CORRELATE_MESSAGE`||t===`PUBLISH_MESSAGE`}function An(e,t,n,r){if(!n.includes(r))return j();let i=d(n);return i===null?{sites:[],refused:[{start:0,reason:`malformed`,where:`json`}]}:t===`form`?e===`variable`?Cn(i,r):e===`form`?{sites:s(fe.get(`form`),r,n).map(e=>({start:e.start,end:e.end,where:e.where})),refused:[]}:j():t===`template`?Tn(i,e,r):On(i,e,r)}const jn=/^[\p{L}_$][\p{L}\p{N}_$]*$/u,Mn=/^[\p{L}_][\p{L}\p{N}_.-]*$/u,Nn=/[\p{Cf}\u2028\u2029]/u,Pn=/* @__PURE__ */ new Set([...ce,...le,`null`,`empty`,`eq`,`ne`,`lt`,`gt`,`le`,`ge`,`div`,`mod`,`instanceof`,`execution`,`task`]),Fn=/\.(bpmn|bpmn\.xml|bpmn20\.xml)$/i,In=/\.dmn$/i,Ln=e=>pe.includes(e);function Rn(e,t){return t===``?{code:`empty`,detail:``}:t.length>200?{code:`tooLong`,detail:`200`}:t!==t.trim()||!o(t)||Nn.test(t)?{code:`unwritable`,detail:``}:e===`variable`&&(!jn.test(t)||Pn.has(t))||(e===`process`||e===`decision`)&&!Mn.test(t)||e===`form`&&/\s/.test(t)?{code:`badName`,detail:t}:null}function zn(e){if(!Ln(e.kind))return[{code:`unknownKind`,detail:String(e.kind).slice(0,40)}];let t=[],n=Rn(e.kind,e.from);n&&t.push({...n,detail:n.code===`empty`?`from`:n.detail});let r=Rn(e.kind,e.to);return r?t.push(r):/^\s*=|\$\{|#\{|\{\{/.test(e.to)?t.push({code:`expression`,detail:``}):e.to===e.from&&t.push({code:`same`,detail:``}),t}function Bn(e,t,n){if(Fn.test(t.path))return _n(e,t.text,n,!1);if(In.test(t.path))return _n(e,t.text,n,!0);if(/\.(form|json)$/i.test(t.path)){let r=vn(t.path,t.text);return r===null?null:An(e,r,t.text,n)}return Me(t.path)?Ue(e,t.path,t.text,n):S.test(t.path)?Oe(e,t.text,n):null}function Vn(e){let t=[0];for(let n=e.indexOf(`
5
+ `);n>=0;n=e.indexOf(`
6
+ `,n+1))t.push(n+1);return n=>{let r=0,i=t.length-1;for(;r<i;){let e=r+i+1>>1;t[e]<=n?r=e:i=e-1}let a=e.indexOf(`
7
+ `,t[r]),o=e.slice(t[r],a<0?e.length:a).replace(/\r$/,``);return{line:r+1,column:n-t[r]+1,lineText:o.length>120?o.trim().slice(0,120):o.trim()}}}function Hn(e,t,n,r){let i=Vn(e.text),a=[],o=-1,s=[...t.sites].sort((e,t)=>e.start-t.start||e.end-t.end);for(let t of s){if(t.start===o)continue;let s=i(t.start);e.text.slice(t.start,t.end)!==n.from||t.start<o?r.push({file:e.path,line:s.line,column:s.column,reason:`malformed`,where:t.where,excerpt:s.lineText,blocking:!0}):(o=t.end,a.push({file:e.path,start:t.start,end:t.end,line:s.line,column:s.column,where:t.where,before:n.from,after:n.to,lineText:s.lineText}))}let c=/* @__PURE__ */ new Set;for(let n of[...t.refused].sort((e,t)=>e.start-t.start)){if(n.reason===`dynamicName`){if(c.has(n.reason))continue;c.add(n.reason)}let t=i(n.start);r.push({file:e.path,line:t.line,column:t.column,reason:n.reason,where:n.where,excerpt:t.lineText,blocking:n.blocking??!0})}return a}function Un(e,t,n={}){let r=zn(t),i={request:t,edits:[],refused:[],blockers:r,files:[],scanned:e.length,truncated:!1};if(r.length>0)return i;for(let e of n.skipped??[])i.refused.push({file:e.path,line:0,column:0,reason:e.reason,where:``,excerpt:``,blocking:!0});let a=[...e].sort((e,t)=>e.path<t.path?-1:+(e.path>t.path));for(let e of a){let n=Bn(t.kind,e,t.from);if(n===null||n.sites.length===0&&n.refused.length===0)continue;let a=Hn(e,n,t,i.refused);if(a.length>0&&i.files.push({path:e.path,edits:a.length}),i.edits.push(...a),i.edits.length>2e4||i.refused.length>500)return i.truncated=!0,i.edits.length=Math.min(i.edits.length,2e4),i.refused.length=Math.min(i.refused.length,500),r.push({code:`tooMany`,detail:`20000`}),i}let o=a.reduce((e,n)=>e+(Bn(t.kind,n,t.to)?.sites.length??0),0);return o>0&&r.push({code:`exists`,detail:String(o)}),i.edits.length===0&&r.push({code:`nothing`,detail:``}),i}var Wn=class extends Error{file;constructor(e){super(e),this.file=e}};function Gn(e,t){let n=[...t].sort((e,t)=>e.start-t.start),r=[],i=0;for(let t of n){if(t.start<i||t.end<t.start||e.slice(t.start,t.end)!==t.before)throw new Wn(t.file);r.push(e.slice(i,t.start),t.after),i=t.end}return r.push(e.slice(i)),r.join(``)}function Kn(e,t,n={}){let r=new Map(e.map(e=>[e.path,e.text])),i=new Map(r),a=[],o=/* @__PURE__ */ new Set,s=t.length===0||t.length>500;for(let[e,i]of t.slice(0,500).entries()){let t=Un([...r].map(([e,t])=>({path:e,text:t})),i,e===0?n:{});if(a.push(t),t.blockers.length>0)s=!0;else for(let e of t.files)o.add(e.path),r.set(e.path,Gn(r.get(e.path),t.edits.filter(t=>t.file===e.path)))}let c=[...o].filter(e=>r.get(e)!==i.get(e)).sort();return{steps:a,changed:c,finals:new Map(c.map(e=>[e,r.get(e)])),blocked:s,edits:a.reduce((e,t)=>e+t.edits.length,0),blockingRefusals:a.reduce((e,t)=>e+t.refused.filter(e=>e.blocking).length,0)}}const qn=262144,B=(e,t,n=``)=>({requests:[],problem:{code:e,line:t,detail:n.slice(0,80)}});function Jn(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return B(`badEntry`,t);let{kind:n,from:r,to:i}=e;return typeof n!=`string`||typeof r!=`string`||typeof i!=`string`?B(`badEntry`,t):Ln(n)?{kind:n,from:r,to:i}:B(`badKind`,t,n)}function Yn(e){let t;try{t=JSON.parse(e)}catch{return B(`badJson`,0)}let n=Array.isArray(t)?t:t?.renames;return Array.isArray(n)?Zn(n.map((e,t)=>Jn(e,t+1))):B(`badJson`,0)}function Xn(e){let t=[];return e.split(`
8
+ `).forEach((e,n)=>{let r=e.replace(/\r$/,``);if(r.trim()===``||r.trimStart().startsWith(`#`))return;let i=r.split(`,`);i.length===3?t.push(Jn({kind:i[0].trim(),from:i[1].trim(),to:i[2].trim()},n+1)):t.push(B(`badLine`,n+1))}),Zn(t)}function Zn(e){let t=[];for(let n of e){if(`problem`in n)return n;t.push(n)}return t.length===0?B(`empty`,0):t.length>500?B(`tooMany`,0,`500`):{requests:t,problem:null}}function Qn(e,t){return e.length>262144?B(`tooLarge`,0):t?Yn(e.replace(/^/,``)):Xn(e.replace(/^/,``))}const $n={bpmn:`http://www.omg.org/spec/BPMN/20100524/MODEL`,bpmndi:`http://www.omg.org/spec/BPMN/20100524/DI`,dc:`http://www.omg.org/spec/DD/20100524/DC`,di:`http://www.omg.org/spec/DD/20100524/DI`,zeebe:`http://camunda.org/schema/zeebe/1.0`,camunda:`http://camunda.org/schema/1.0/bpmn`},er=/^[\p{L}_][\p{L}\p{N}_.-]*$/u,tr=/^[A-Za-z_]\w*$/,nr=/* @__PURE__ */ new Set([`task`,`subProcess`,`adHocSubProcess`,`transaction`,`callActivity`,`intermediateCatchEvent`,`intermediateThrowEvent`,`boundaryEvent`]),rr=/* @__PURE__ */ new Set([`serviceTask`,`sendTask`,`userTask`,`businessRuleTask`,`callActivity`,`scriptTask`]),ir=/* @__PURE__ */ new Set([`dataInputAssociation`,`dataOutputAssociation`,`dataObjectReference`,`dataStoreReference`,`ioSpecification`,`property`]),ar=/* @__PURE__ */ new Set([`messageRef`,`signalRef`,`errorRef`,`escalationRef`]),or=/* @__PURE__ */ new Set([`message`,`signal`,`error`,`escalation`]),sr=/* @__PURE__ */ new Set([`input`,`loop element`]),cr=/* @__PURE__ */ new Set([`output`,`loop output`]),lr=/* @__PURE__ */ new Set([`id`,`name`,`triggeredByEvent`,`startQuorum`,`completionQuantity`,`isForCompensation`]),V=(e,t=``)=>({reason:e,detail:t.slice(0,120)}),H=(...e)=>({ok:!1,refusals:e}),U=e=>e.attributes.find(e=>e.name===`id`)?.value??``,W=(e,t)=>e.attributes.find(e=>e.name===t)?.value,ur=e=>e.slice(e.indexOf(`:`)+1),G=e=>e.slice(e.indexOf(`:`)+1);function dr(e){let t={};for(let n of e.attributes){if(n.name!==`xmlns`&&!n.name.startsWith(`xmlns:`))continue;let e=n.name===`xmlns`?``:n.name.slice(6);for(let r of Object.keys($n))$n[r]===n.value&&(t[r]=e)}return t.bpmn===void 0?null:{bpmn:t.bpmn,bpmndi:t.bpmndi??`bpmndi`,dc:t.dc??`dc`,di:t.di??`di`,zeebe:t.zeebe??``,camunda:t.camunda??``}}const K=(e,t)=>e===``?t:`${e}:${t}`;function fr(e,t,n){let r=n=>e[n]!==``&&t.some(t=>t.prefix===e[n]||t.attributes.some(t=>t.name.startsWith(`${e[n]}:`)));return n===`camunda-8`?e.zeebe===``?null:n:n===`camunda-7`?e.camunda===``?null:n:r(`zeebe`)?`camunda-8`:r(`camunda`)?`camunda-7`:e.zeebe===``?e.camunda===``?null:`camunda-7`:`camunda-8`}function q(e,t,n){return t.children.filter(t=>t.local===n&&t.prefix===e.prefix.bpmn)}function pr(e,t){return t.text.map(t=>e.slice(t.start,t.end)).join(``).trim()}function mr(e,t){let n=e.lastIndexOf(`
9
+ `,t-1)+1,r=e.slice(n,t);return/^\s*$/.test(r)?r:``}function hr(e,t){let n=t.start;for(;n>0&&(e[n-1]===` `||e[n-1]===` `);)--n;return n>0&&e[n-1]===`
10
+ `&&(n-=n>1&&e[n-2]===`\r`?2:1),{start:n,end:t.end}}function gr(e,t){let n=[...t].sort((e,t)=>e.start-t.start||e.end-t.end),r=[],i=0;for(let t of n){if(t.start<i)return null;r.push(e.slice(i,t.start),t.text),i=t.end}return r.push(e.slice(i)),r.join(``)}function _r(e,t,n,r){let i=r.filter(e=>e.start>=t&&e.end<=n).map(e=>({start:e.start-t,end:e.end-t,text:e.text}));return gr(e.slice(t,n),i)??e.slice(t,n)}function J(e,t){let n=t;for(let r=2;e.has(n);r+=1)n=`${t}_${r}`;return e.add(n),n}function vr(e,t){let n=e===void 0?void 0:W(e,t),r=n===void 0?NaN:Number(n);return Number.isFinite(r)?r:null}function yr(e){let t=e.children.find(e=>e.local===`Bounds`),[n,r,i,a]=[`x`,`y`,`width`,`height`].map(e=>vr(t,e));return n===null||r===null||i===null||a===null?null:{x:n,y:r,width:i,height:a}}function br(e,t,n,r){let i=[];for(let e of[t,...m(t)])if(e.local===`Bounds`||e.local===`waypoint`)for(let[t,a]of[[`x`,n],[`y`,r]]){let n=e.attributes.find(e=>e.name===t),r=n===void 0?NaN:Number(n.value);n!==void 0&&Number.isFinite(r)&&i.push({start:n.start,end:n.end,text:String(Math.round((r+a)*100)/100)})}return _r(e,t.start,t.end,i)}function xr(e){return new Set(m(e).map(U).filter(e=>e!==``))}function Sr(e,t,n,r){let i=e.elements.filter(e=>e.local===`messageFlow`||e.local===`association`);for(let i of t){ir.has(i.local)&&r.push(V(`dataAssociation`,U(i)||i.name)),(W(i,`isForCompensation`)===`true`||i.local===`compensateEventDefinition`)&&r.push(V(`compensation`,U(i)||i.name)),i.local===`linkEventDefinition`&&r.push(V(`link`,U(i.parent)));for(let t of i.attributes){let a=ur(t.name);if(!a.endsWith(`Ref`)&&a!=="default")continue;let o=G(t.value);n.has(o)||ar.has(a)&&e.byId.has(o)||r.push(V(`outsideReference`,`${U(i)||i.name}@${t.name}`))}}for(let e of i)[`sourceRef`,`targetRef`].map(t=>G(W(e,t)??``)).some(e=>n.has(e))&&r.push(V(e.local===`messageFlow`?`messageFlow`:`artifact`,U(e)))}function Cr(e){return e.some(e=>rr.has(e.local)&&(e.local!==`scriptTask`||e.children.some(e=>e.local===`script`)))}function wr(e){return e.children.filter(e=>e.local.endsWith(`EventDefinition`))}function Tr(e,t,n){if(t.local!==`subProcess`||W(t,`triggeredByEvent`)===`true`)return n.push(V(`subprocessKind`,U(t))),null;let r=q(e,t,`startEvent`),i=q(e,t,`endEvent`);r.length===1?wr(r[0]).length>0&&n.push(V(`unsupportedKind`,U(r[0]))):n.push(V(`entry`,`${U(t)}: ${r.length}`)),i.length===1?wr(i[0]).length>0&&n.push(V(`exitEvent`,U(i[0]))):n.push(V(`exit`,`${U(t)}: ${i.length}`)),t.children.filter(e=>e.local===`extensionElements`).some(e=>e.children.some(e=>e.local===`ioMapping`||e.local===`inputOutput`))&&n.push(V(`ioMapping`,U(t)));let a=m(t),o=xr(t);return{mode:`subprocess`,elements:[t],scope:a,ids:o,scopeIds:o,parent:t.parent,internal:[]}}function Er(e,t,n){let r=t[0].parent;if(r===null||r.local!==`process`&&r.local!==`subProcess`||t.some(e=>e.parent!==r))return n.push(V(`mixedScope`,t.map(U).join(`,`))),null;for(let e of t)!nr.has(e.local)&&!/(Task|Gateway)$/.test(e.local)&&n.push(V(`unsupportedKind`,`${U(e)}: ${e.local}`));if(n.length>0)return null;let i=new Set(t.map(U));for(let t of q(e,r,`boundaryEvent`)){let e=G(W(t,`attachedToRef`)??``);i.has(e)!==i.has(U(t))&&n.push(V(`boundary`,U(t)))}let a=q(e,r,`sequenceFlow`),o=[],s=[],c=[];for(let e of a){let t=G(W(e,`sourceRef`)??``),n=G(W(e,`targetRef`)??``);i.has(t)&&i.has(n)?c.push(e):i.has(n)?o.push(e):i.has(t)&&s.push(e)}if(o.length!==1&&n.push(V(`entry`,String(o.length))),s.length!==1&&n.push(V(`exit`,String(s.length))),n.length>0)return null;let l={flow:o[0],target:e.byId.get(G(W(o[0],`targetRef`)??``))},u={flow:s[0],source:e.byId.get(G(W(s[0],`sourceRef`)??``))};(q(e,u.flow,`conditionExpression`).length>0||G(W(u.source,`default`)??``)===U(u.flow))&&n.push(V(`exitCondition`,U(u.flow)));let d=/* @__PURE__ */ new Set([U(l.target)]);for(let t=!0;t;){t=!1;for(let e of c)d.has(G(W(e,`sourceRef`)??``))&&!d.has(G(W(e,`targetRef`)??``))&&(d.add(G(W(e,`targetRef`)??``)),t=!0);for(let n of q(e,r,`boundaryEvent`))i.has(U(n))&&d.has(G(W(n,`attachedToRef`)??``))&&!d.has(U(n))&&(d.add(U(n)),t=!0)}for(let e of t)d.has(U(e))||n.push(V(`disconnected`,U(e)));let f=t.flatMap(e=>[e,...m(e)]),p=/* @__PURE__ */ new Set([...f.map(U).filter(e=>e!==``),...c.map(U)]);return{mode:`fragment`,elements:t,scope:f,ids:/* @__PURE__ */ new Set([...p,U(l.flow),U(u.flow)]),scopeIds:p,parent:r,entry:l,exit:u,internal:c}}async function Dr(e,t,n){let r=await _(e);if(r===null)return n.push(V(`malformed`)),null;let i=t.scopeIds;for(let e of b(r)){if(!i.has(e.elementId))continue;let t=e.expression;t.startsWith(`=`)&&Tt(t.slice(1))!==void 0?n.push(V(`syntax`,`${e.elementId}: ${e.where}`)):Gt(t)&&n.push(V(`dynamicVariable`,`${e.elementId}: ${e.where}`))}let a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Set;for(let e of y(r).uses)i.has(e.elementId)&&tr.test(e.name)&&(e.writes?sr.has(e.where)||o.add(e.name):cr.has(e.where)||a.add(e.name));let s=Cr(t.scope);return{mappings:{inputs:[...a].sort(),outputs:[...o].sort(),allIn:s,allOut:s}}}function Or(e,t,n,r,i,a,o){let{prefix:s,engine:c}=e,l=e=>K(s.bpmn,e),u=t.elements[0],d=`${o} `,f=[],p=[],m=``,h=``;if(t.mode===`subprocess`){for(let e of u.attributes)!lr.has(e.name)&&e.name!==`isExpanded`&&!e.name.startsWith(`xmlns`)&&p.push(`${e.name}="${e.value}"`);for(let t of u.children)if(t.local===`extensionElements`)for(let n of t.children)f.push(e.text.slice(n.start,n.end));else t.local===`loopCharacteristics`||t.local.endsWith(`LoopCharacteristics`)?m=`\n${d}${e.text.slice(t.start,t.end)}`:t.local===`documentation`&&(h=`\n${d}${e.text.slice(t.start,t.end)}`)}let g=t.mode===`subprocess`?[...u.children.filter(e=>e.local===`incoming`||e.local===`outgoing`)].map(t=>`\n${d}${e.text.slice(t.start,t.end)}`).join(``):`\n${d}<${l(`incoming`)}>${U(t.entry.flow)}</${l(`incoming`)}>\n${d}<${l(`outgoing`)}>${U(t.exit.flow)}</${l(`outgoing`)}>`,_=[];if(c===`camunda-8`){let e=e=>K(s.zeebe,e);if(f.push(`<${e(`calledElement`)} processId="${i}" propagateAllChildVariables="${a.allOut}" propagateAllParentVariables="${a.allIn}" />`),a.inputs.length+a.outputs.length>0){let t=[...a.inputs.map(t=>`${d} <${e(`input`)} source="=${t}" target="${t}" />`),...a.outputs.map(t=>`${d} <${e(`output`)} source="=${t}" target="${t}" />`)];f.push(`<${e(`ioMapping`)}>\n${t.join(`
11
+ `)}\n${d} </${e(`ioMapping`)}>`)}}else{let e=e=>K(s.camunda,e);a.allIn&&_.push(`<${e(`in`)} variables="all" />`);for(let t of a.inputs)_.push(`<${e(`in`)} source="${t}" target="${t}" />`);a.allOut&&_.push(`<${e(`out`)} variables="all" />`);for(let t of a.outputs)_.push(`<${e(`out`)} source="${t}" target="${t}" />`);p.unshift(`calledElement="${i}"`,`${e(`calledElementBinding`)}="latest"`)}let v=[...f,..._],y=v.length===0?``:`\n${d}<${l(`extensionElements`)}>\n${v.map(e=>`${d} ${e}`).join(`
12
+ `)}\n${d}</${l(`extensionElements`)}>`,b=r===null?``:` name="${r}"`;return`<${l(`callActivity`)} id="${n}"${b}${p.length>0?` ${p.join(` `)}`:``}>${h}${y}${g}${m}\n${o}</${l(`callActivity`)}>`}function kr(e,t){let n=/* @__PURE__ */ new Set;for(let e of t)for(let t of e.attributes)ar.has(ur(t.name))&&n.add(G(t.value));return e.root.children.filter(e=>or.has(e.local)&&n.has(U(e))).map(t=>e.text.slice(t.start,t.end))}function Ar(e){let t=/^?<\?xml[^?]*\?>/.exec(e);return t===null?``:`${t[0].replace(/^/,``)}\n`}function jr(e,t){let n=e.root,r=n.attributes.find(e=>e.name===`id`),i=e.text.slice(n.start,n.openEnd);return r===void 0?i:`${i.slice(0,r.start-n.start)}${t}${i.slice(r.end-n.start)}`}async function Mr(e,t){let n=i(e);if(n.problem!==null||n.root===null)return H(V(`malformed`));let r=n.root,a=dr(r);if(a===null||r.local!==`definitions`)return H(V(`malformed`));if(t.elements.length===0)return H(V(`noElements`));if(t.elements.length>200)return H(V(`tooMany`,`200`));if(!er.test(t.processId)||t.processId.length>200)return H(V(`badProcessId`,t.processId));if(t.name!==void 0&&(t.name.trim()===``||t.name.length>200||!o(t.name)))return H(V(`badName`,t.name));let s=fr(a,n.elements,t.engine);if(s===null)return H(V(`noEngine`));let c=/* @__PURE__ */ new Map;for(let e of n.elements){let t=U(e);if(t!==``){if(c.has(t))return H(V(`malformed`,t));c.set(t,e)}}let l={text:e,root:r,elements:n.elements,byId:c,prefix:a,engine:s};if(n.elements.some(e=>e.local===`process`&&U(e)===t.processId)||c.has(t.processId))return H(V(`processIdTaken`,t.processId));let u=[];for(let e of t.elements){let t=c.get(e);if(t===void 0)return H(V(`notFound`,e));u.includes(t)||u.push(t)}let d=[],f=u.length===1&&u[0].local===`subProcess`?Tr(l,u[0],d):Er(l,u,d);if(f===null)return H(...d);Sr(l,f.scope,f.ids,d);let p=await Dr(e,f,d);return d.length>0||p===null?H(...d):await Hr(l,f,p,t)}function Nr(e){let t=e;for(;t.local!==`process`&&t.parent!==null;)t=t.parent;return t}function Pr(e,t){let n=e.attributes.find(e=>e.name===t);return n===void 0?null:{start:n.start,end:n.end,text:``}}function Fr(e,t,n,r){let i=t.elements[0],a=/* @__PURE__ */ new Set([`incoming`,`outgoing`,`extensionElements`,`loopCharacteristics`,`documentation`]),o=i.children.filter(e=>!a.has(e.local)&&!e.local.endsWith(`LoopCharacteristics`)).map(t=>`${r}${e.text.slice(t.start,t.end)}`).join(`
13
+ `);return{edits:[{start:i.start,end:i.end,text:n}],content:o}}function Ir(e,t,n,r,i){let{text:a,prefix:o}=e,s=t.entry,c=t.exit,l=e=>K(o.bpmn,e),u=[];for(let[e,t,n,i]of[[s.target,`incoming`,U(s.flow),r.startFlow],[c.source,`outgoing`,U(c.flow),r.endFlow]])for(let r of e.children)r.local===t&&pr(a,r)===n&&u.push({start:r.openEnd,end:r.closeStart,text:i});let d=[...t.elements,...t.internal].sort((e,t)=>e.start-t.start),f=[];d.forEach((e,t)=>{let r=hr(a,e);f.push({start:r.start,end:r.end,text:t===0?`\n${i}${n}`:``})});let p=new Set(t.elements.map(U));for(let t of e.elements.filter(e=>e.local===`flowNodeRef`&&p.has(pr(a,e))))pr(a,t)===U(s.target)?f.push({start:t.openEnd,end:t.closeStart,text:r.call}):f.push({...hr(a,t),text:``});for(let[e,t]of[[s.flow,`targetRef`],[c.flow,`sourceRef`]]){let n=Pr(e,t);n!==null&&f.push({...n,text:r.call})}let m=d.map(e=>`${i}${_r(a,e.start,e.end,u)}`).join(`
14
+ `);return{edits:f,content:[`${i}<${l(`startEvent`)} id="${r.start}">\n${i} <${l(`outgoing`)}>${r.startFlow}</${l(`outgoing`)}>\n${i}</${l(`startEvent`)}>`,`${i}<${l(`sequenceFlow`)} id="${r.startFlow}" sourceRef="${r.start}" targetRef="${U(s.target)}" />`,m,`${i}<${l(`endEvent`)} id="${r.end}">\n${i} <${l(`incoming`)}>${r.endFlow}</${l(`incoming`)}>\n${i}</${l(`endEvent`)}>`,`${i}<${l(`sequenceFlow`)} id="${r.endFlow}" sourceRef="${U(c.source)}" targetRef="${r.end}" />`].join(`
15
+ `)}}function Lr(e,t){return e.find(e=>G(W(e,`bpmnElement`)??``)===t)}function Rr(e,t){return e.elements.find(e=>e.local===`BPMNEdge`&&G(W(e,`bpmnElement`)??``)===t)}function zr(e,t,n,r,i){let a=e===void 0?[]:e.children.filter(e=>e.local===`waypoint`),o=t===`first`?a[0]:a[a.length-1];if(o!==void 0)for(let[e,t]of[[`x`,n],[`y`,r]]){let n=o.attributes.find(t=>t.name===e);n!==void 0&&i.push({start:n.start,end:n.end,text:String(t)})}}function Br(e,t,n,r,i){let{text:a,prefix:o}=e,s=e.elements.find(e=>e.local===`BPMNPlane`),c=e=>t.scopeIds.has(G(W(e,`bpmnElement`)??``)),l=e.elements.filter(e=>e.local===`BPMNShape`&&c(e)),u=e.elements.filter(e=>e.local===`BPMNEdge`&&c(e)),d=l.map(yr).filter(e=>e!==null);if(s===void 0||d.length===0)return null;let f=e=>K(o.bpmndi,e),p=e=>K(o.dc,e),m=e=>K(o.di,e),h=t.mode===`fragment`,g=Math.min(...d.map(e=>e.x)),_=Math.min(...d.map(e=>e.y)),v=Math.max(...d.map(e=>e.x+e.width)),y=Math.max(...d.map(e=>e.y+e.height)),b=150+(h?106:0)-g,x=150-_,S=[...l,...u].map(e=>`${i} ${br(a,e,b,x)}`),C=[...l,...u].map(e=>({...hr(a,e),text:``}));if(h){let r=t.entry,o=t.exit,s=Lr(l,U(r.target)),c=Lr(l,U(o.source)),u=s===void 0?null:yr(s),d=c===void 0?null:yr(c);if(u===null||d===null)return null;let h=u.y+x+u.height/2,w=d.y+x+d.height/2,T=v+b+70,E=(e,t)=>`<${m(`waypoint`)} x="${e}" y="${t}" />`,D=(e,t,n)=>`${i} <${f(`BPMNShape`)} id="${e}_di" bpmnElement="${e}">\n${i} <${p(`Bounds`)} x="${t}" y="${n-18}" width="36" height="36" />\n${i} </${f(`BPMNShape`)}>`,O=(e,t,n)=>`${i} <${f(`BPMNEdge`)} id="${e}_di" bpmnElement="${e}">\n${i} ${t}\n${i} ${n}\n${i} </${f(`BPMNEdge`)}>`;S.push(D(n.start,150,h),O(n.startFlow,E(186,h),E(u.x+b,h)),D(n.end,T,w),O(n.endFlow,E(d.x+d.width+b,w),E(T,w)));let ee=Math.round((g+v)/2-50),k=Math.round((_+y)/2-40),te=[...l].map(e=>hr(a,e)).sort((e,t)=>e.start-t.start)[0];C.push({start:te.start,end:te.start,text:`\n${i} <${f(`BPMNShape`)} id="${n.call}_di" bpmnElement="${n.call}">\n${i} <${p(`Bounds`)} x="${ee}" y="${k}" width="100" height="80" />\n${i} </${f(`BPMNShape`)}>`}),zr(Rr(e,U(r.flow)),`last`,ee,k+40,C),zr(Rr(e,U(o.flow)),`first`,ee+100,k+40,C)}else{let t=e.elements.find(e=>e.local===`BPMNShape`&&G(W(e,`bpmnElement`)??``)===n.call),r=t===void 0?null:/\sisExpanded="[^"]*"/.exec(a.slice(t.start,t.openEnd));t!==void 0&&r!==null&&C.push({start:t.start+r.index,end:t.start+r.index+r[0].length,text:``})}return{edits:C,text:`\n${i}<${f(`BPMNDiagram`)} id="BPMNDiagram_${r}">\n${i} <${f(`BPMNPlane`)} id="BPMNPlane_${r}" bpmnElement="${r}">\n${S.join(`
16
+ `)}\n${i} </${f(`BPMNPlane`)}>\n${i}</${f(`BPMNDiagram`)}>`}}async function Vr(e){let t=await v(e);return t===null?null:t.warnings.length}async function Hr(e,t,n,r){let{text:i,prefix:a}=e,o=new Set(e.byId.keys()),s=e=>K(a.bpmn,e),c=t.elements[0],l=t.mode===`fragment`,u=mr(i,c.start),d={call:l?J(o,`CallActivity_${r.processId}`):U(c),start:J(o,`StartEvent_${r.processId}`),end:J(o,`EndEvent_${r.processId}`),startFlow:J(o,`Flow_${r.processId}_start`),endFlow:J(o,`Flow_${r.processId}_end`)},f=l?r.name??r.processId:W(c,`name`)??null,p=Or(e,t,d.call,f,r.processId,n.mappings,u),m=l?Ir(e,t,p,d,u):Fr(e,t,p,u),h=Br(e,t,d,r.processId,u.slice(2)),g=[...m.edits,...h?.edits??[]],_=Nr(l?t.parent:c),v=[`isExecutable="true"`],y=_.attributes.find(e=>ur(e.name)===`historyTimeToLive`);y!==void 0&&v.push(`${y.name}="${y.value}"`);let b=l?r.name??r.processId:W(c,`name`),x=b===void 0?``:` name="${b}"`,S=u.slice(2),C=kr(e,t.scope).map(e=>`${S}${e}`),w=`${`${Ar(i)}${jr(e,`Definitions_${r.processId}`)}`}\n${C.length>0?`${C.join(`
17
+ `)}\n`:``}${S}<${s(`process`)} id="${r.processId}"${x} ${v.join(` `)}>\n${m.content}\n${S}</${s(`process`)}>${h?.text??``}\n</${s(`definitions`)}>\n`,T=gr(i,g);if(T===null)return H(V(`invalidResult`,`overlap`));let E=await Vr(i),D=await Vr(T),O=await Vr(w);return E===null||D===null||O===null||D>E||O>E?H(V(`invalidResult`,`moddle`)):{ok:!0,plan:{source:T,created:w,callId:d.call,processId:r.processId,engine:e.engine,mappings:n.mappings,moved:[...t.scopeIds].sort(),diagram:h!==null}}}const Ur=/\.(bpmn|bpmn\.xml|bpmn20\.xml|dmn|form|ya?ml|properties)$/i,Wr=/\.json$/i,Gr=/(test|case|scenario|spec)/i,Kr=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});var qr=class extends Error{files;constructor(e){super(String(e)),this.files=e}};const Y=e=>oe(`sha256`).update(e).digest(`hex`);function Jr(e){let t=E.posix.basename(e);return Ur.test(t)||S.test(t)?!0:Wr.test(t)&&(e.split(`/`).includes(`element-templates`)||Gr.test(t))}function Yr(e,t){try{if(k(e).isSymbolicLink())return`symlink`;if(!n(e,[t]))return`outside`;let r=te(e,O.O_RDONLY|(O.O_NOFOLLOW??0));try{let e=ee(r);if(!e.isFile())return`unreadable`;if(e.size>4194304)return`tooLarge`;let t=Buffer.alloc(e.size),n=0;for(;n<e.size;){let i=re(r,t,n,e.size-n,n);if(i===0)break;n+=i}if(n!==e.size)return`unreadable`;try{return{bytes:t,text:Kr.decode(t)}}catch{return`notText`}}finally{D(r)}}catch{return`unreadable`}}function Xr(e){let t=A(e),n=w(t),r=[],i=[],a=/* @__PURE__ */ new Map,o=0,s=0,c=e=>{let l=ie(e,{withFileTypes:!0}).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name));for(let u of l){n();let l=E.join(e,u.name),d=E.relative(t,l).split(E.sep).join(`/`);if(u.isDirectory()){!C.has(u.name)&&!u.name.startsWith(`.`)&&T(l)&&c(l);continue}if(!Jr(d))continue;if(u.isSymbolicLink()){i.push({path:d,reason:`symlink`});continue}if(!u.isFile())continue;if(s+=1,s>5e3)throw new qr(s);let f=Yr(l,t);if(typeof f==`string`)i.push({path:d,reason:f});else{if(o+=f.bytes.length,o>536870912)throw new qr(s);r.push({path:d,text:f.text}),a.set(d,Y(f.bytes))}}};return c(t),{root:t,files:r,skipped:i,hashes:a}}var X=class extends Error{code;detail;constructor(e,t=``){super(`${e}${t===``?``:`: ${t}`}`),this.code=e,this.detail=t}};function Zr(e,t,n){return Y(JSON.stringify({requests:e.map(e=>[e.kind,e.from,e.to]),files:t.changed.map(e=>[e,n.get(e),Y(t.finals.get(e))]),refused:t.steps.map(e=>e.refused.map(e=>[e.file,e.line,e.column,e.reason])),blockers:t.steps.map(e=>e.blockers.map(e=>e.code))}))}function Qr(e,t){let n;try{n=Xr(e)}catch(e){throw e instanceof qr?new X(`tooLarge`,String(e.files)):e}let r=Kn(n.files,t,{skipped:n.skipped});return{root:n.root,bulk:r,planId:Zr(t,r,n.hashes),hashes:n.hashes}}function $r(e,t,r){let i=Qr(e,t);if(i.planId!==r.planId)throw new X(`planChanged`);let{bulk:a}=i;if(a.blocked||a.changed.length===0)throw new X(`blocked`);if(a.blockingRefusals>0&&!r.acknowledge)throw new X(`refused`,String(a.blockingRefusals));let o=A(i.root),s=[];for(let e of a.changed){let t=E.join(o,...e.split(`/`));if(k(t).isSymbolicLink()||!n(t,[o]))throw new X(`unsafe`,e);let r=Yr(t,o);if(typeof r==`string`)throw new X(`unsafe`,e);if(Y(r.bytes)!==i.hashes.get(e))throw new X(`changed`,e);s.push({path:t,content:a.finals.get(e)})}try{x(s,o,{replace:!0})}catch(e){throw new X(`writeFailed`,e instanceof Error?e.message.slice(0,200):``)}return{files:a.changed,edits:a.edits}}const ei=/\.(bpmn|bpmn\.xml|bpmn20\.xml)$/i;function ti(e,t){let r=A(e),i=t.split(/[\\/]/);if(t===``||E.isAbsolute(t)||i.some(e=>e===`..`||e===``)||!ei.test(t))throw new X(`unsafe`,t.slice(0,200));let a=E.join(r,...i);if(!n(a,[r]))throw new X(`unsafe`,t.slice(0,200));return{root:r,file:a}}function ni(e){try{return k(e),!0}catch{return!1}}async function ri(e,t,n){let{root:r,file:i}=ti(e,t),a=Yr(i,r);if(typeof a==`string`)throw new X(`unsafe`,t.slice(0,200));let o=E.join(E.dirname(i),`${n.processId}.bpmn`),s=E.relative(r,o).split(E.sep).join(`/`),c=await Mr(a.text,n);return c.ok?ni(o)?{ok:!1,refusals:[{reason:`nameTaken`,detail:s.slice(0,120)}]}:{ok:!0,planned:{source:t,created:s,planId:Y(JSON.stringify([t,Y(a.bytes),n.elements,n.processId,n.name??null,n.engine??null,Y(c.plan.source),Y(c.plan.created),s])),hash:Y(a.bytes),plan:c.plan}}:c}async function ii(e,t,n,r){let i=await ri(e,t,n);if(!i.ok)throw new X(`blocked`,i.refusals.map(e=>e.reason).join(`,`));if(i.planned.planId!==r)throw new X(`planChanged`);let{root:a,file:o}=ti(e,t),s=Yr(o,a);if(typeof s==`string`)throw new X(`unsafe`,t.slice(0,200));if(Y(s.bytes)!==i.planned.hash)throw new X(`changed`,t.slice(0,200));let c=E.join(a,...i.planned.created.split(`/`));try{x([{path:o,content:i.planned.plan.source},{path:c,content:i.planned.plan.created}],a,{replace:!0})}catch(e){throw new X(`writeFailed`,e instanceof Error?e.message.slice(0,200):``)}return{source:t,created:i.planned.created}}const ai=(e,t)=>({step:t,file:e.file,line:e.line,column:e.column,where:e.where,before:e.before,after:e.after,lineText:e.lineText});function oi(e,t,n){let r=e.steps.flatMap((e,t)=>e.edits.map(e=>ai(e,t))),i=e.steps.flatMap((e,t)=>e.refused.map(e=>({...e,step:t}))),a=/* @__PURE__ */ new Map;for(let t of e.steps)for(let e of t.files)a.set(e.path,(a.get(e.path)??0)+e.edits);return{requests:t,planId:n,blocked:e.blocked||e.changed.length===0,blockers:e.steps.flatMap((e,t)=>e.blockers.map(e=>({...e,step:t}))),edits:r.slice(0,1e3),editCount:r.length,refused:i.slice(0,300),refusedCount:i.length,blockingRefusals:e.blockingRefusals,files:[...a].map(([e,t])=>({path:e,edits:t})).sort((e,t)=>e.path<t.path?-1:+(e.path>t.path))}}const si=t=>e(`app.refactor.reason.${t}`),ci=t=>e(`app.refactor.blocker.${t.code}`,{detail:t.detail}),li=t=>e(`app.refactor.extract.${t.reason}`,{detail:t.detail}),ui=t=>e(`app.refactor.kind.${t}`);function Z(e){let t=e.replace(/[\u0000-\u001f\u007f]/g,` `).trim();return t.length>160?`${t.slice(0,157)}...`:t}function di(t,n){let r=[];for(let n of t.requests.slice(0,200))r.push(e(`app.refactor.text.request`,{kind:ui(n.kind),from:Z(n.from),to:Z(n.to)}));t.requests.length>200&&r.push(e(`app.refactor.text.more`,{count:t.requests.length-200}));for(let n of t.blockers)r.push(e(`app.refactor.text.blocker`,{step:n.step+1,reason:ci(n)}));let i=``;for(let n of t.edits.slice(0,200))n.file!==i&&(i=n.file,r.push(Z(n.file))),r.push(e(`app.refactor.text.edit`,{line:n.line,column:n.column,where:Z(n.where),before:Z(n.before),after:Z(n.after)}));t.editCount>Math.min(200,t.edits.length)&&r.push(e(`app.refactor.text.more`,{count:t.editCount-Math.min(200,t.edits.length)}));for(let n of t.refused.slice(0,200))r.push(e(n.blocking?`app.refactor.text.refusedBlocking`:`app.refactor.text.refused`,{file:Z(n.file),line:n.line,reason:si(n.reason),where:Z(n.where)}));return t.refusedCount>Math.min(200,t.refused.length)&&r.push(e(`app.refactor.text.more`,{count:t.refusedCount-Math.min(200,t.refused.length)})),r.push(e(n?`app.refactor.text.applied`:`app.refactor.text.summary`,{edits:t.editCount,files:t.files.length,refused:t.refusedCount})),r}function fi(t,n){let r=[e(`app.refactor.text.extractTo`,{created:Z(t.created),call:Z(t.callId)})];r.push(e(`app.refactor.text.extractMoved`,{count:t.moved.length}));let i=t.mappings.allIn?e(`app.refactor.text.everything`):t.mappings.inputs.map(Z).join(`, `)||e(`app.refactor.text.nothing`),a=t.mappings.allOut?e(`app.refactor.text.everything`):t.mappings.outputs.map(Z).join(`, `)||e(`app.refactor.text.nothing`);return r.push(e(`app.refactor.text.extractIn`,{names:i})),r.push(e(`app.refactor.text.extractOut`,{names:a})),r.push(e(n?`app.refactor.text.extractApplied`:`app.refactor.text.extractPreview`)),r}const Q=[`rename`,`bulk`,`extract`];var $=class extends Error{};function pi(t){if(/^[\\/]{2}/.test(t))throw new $(e(`app.refactor.cli.uncRoot`))}function mi(e){let t=ae(`git`,[`rev-parse`,`--is-inside-work-tree`],{cwd:e,encoding:`utf8`});if(t.error!==void 0||t.status===128)return`none`;if(t.status!==0)return`unknown`;let n=ae(`git`,[`status`,`--porcelain`,`--untracked-files=all`,`--`,`.`],{cwd:e,encoding:`utf8`,maxBuffer:67108864});return n.error!==void 0||n.status!==0?`unknown`:n.stdout.trim()===``?`clean`:`dirty`}function hi(e,t){if(t)return null;let n=mi(e);return n===`dirty`||n===`unknown`?`dirty`:null}function gi(e,t,n){pi(e);let r=Qr(e,t),i=oi(r.bulk,t,r.planId),a={mode:`rename`,applied:!1,stopped:null,detail:``,report:i,written:null};if(!n.apply)return a;if(i.blocked)return{...a,stopped:`blocked`};if(n.planId!==void 0&&n.planId!==r.planId)return{...a,stopped:`planChanged`};if(i.blockingRefusals>0&&!n.acknowledge)return{...a,stopped:`refused`,detail:String(i.blockingRefusals)};let o=hi(r.root,n.force);if(o!==null)return{...a,stopped:o};try{let i=$r(e,t,{planId:r.planId,acknowledge:n.acknowledge});return{...a,applied:!0,written:i}}catch(e){if(e instanceof X)return{...a,stopped:e.code,detail:e.detail};throw e}}async function _i(e,t,n,r){pi(e);let i={mode:`extract`,applied:!1,stopped:null,detail:``,plan:null,planId:null,refusals:[],written:null},a;try{a=await ri(e,t,n)}catch(e){if(e instanceof X)return{...i,stopped:e.code,detail:e.detail};throw e}if(!a.ok)return{...i,stopped:`blocked`,refusals:a.refusals};let{source:o,created:s,...c}=a.planned.plan,l={...i,plan:{...c,created:a.planned.created},planId:a.planned.planId};if(!r.apply)return l;if(r.planId!==void 0&&r.planId!==a.planned.planId)return{...l,stopped:`planChanged`};let u=hi(A(e),r.force);if(u!==null)return{...l,stopped:u};try{let r=await ii(e,t,n,a.planned.planId);return{...l,applied:!0,written:r}}catch(e){if(e instanceof X)return{...l,stopped:e.code,detail:e.detail};throw e}}function vi(t,n){return e(`app.refactor.stop.${t}`,{detail:n.slice(0,200)})}function yi(t,r){let i=E.resolve(t),a;try{a=k(i)}catch{throw new $(e(`app.refactor.cli.mappingMissing`,{file:E.basename(i).slice(0,200)}))}if(a.isSymbolicLink()||!a.isFile())throw new $(e(`app.refactor.cli.mappingNotFile`));if(r!==null&&!n(A(i),[A(r)]))throw new $(e(`app.refactor.cli.mappingOutside`));if(a.size>262144)throw new $(e(`app.refactor.mapping.tooLarge`,{detail:``,line:0}));let o=Qn(ne(i,`utf8`),i.toLowerCase().endsWith(`.json`));if(o.problem!==null)throw new $(e(`app.refactor.mapping.${o.problem.code}`,{detail:o.problem.detail,line:o.problem.line}));return o.requests}function bi(t,n,r){if(t===void 0||n===void 0||r===void 0)throw new $(e(`app.refactor.cli.needsRename`));if(!Ln(t))throw new $(e(`app.refactor.cli.unknownKind`,{kind:t.slice(0,80),kinds:pe.join(`, `)}));return{kind:t,from:n,to:r}}function xi(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e!==``)}function Si(t){let n=di(t.report,t.applied);return t.stopped===null?t.applied||n.push(t.report.blocked?e(`app.refactor.text.cannotApply`):e(`app.refactor.text.previewOnly`)):n.push(vi(t.stopped,t.detail)),n}function Ci(e){let t=e.plan===null?e.refusals.map(e=>li(e)):fi(e.plan,e.applied);return e.stopped!==null&&e.refusals.length===0&&t.push(vi(e.stopped,e.detail)),t}function wi(e,t){let n=e.applied||e.stopped===null&&!e.report.blocked;return{ok:n,refused:!n,lines:t?[JSON.stringify(e,null,2)]:Si(e)}}function Ti(e,t){let n=e.applied||e.stopped===null&&e.plan!==null;return{ok:n,refused:!n,lines:t?[JSON.stringify(e,null,2)]:Ci(e)}}async function Ei(n,r){let[i,...a]=n,o=r.format===`json`,s;try{if(s=t(E.resolve(r.project??process.cwd())).root,!k(s).isDirectory())return{ok:!1,refused:!0,lines:[e(`app.cli.web.notAFolder`,{folder:s})]}}catch{return{ok:!1,refused:!0,lines:[e(`app.cli.web.notAFolder`,{folder:r.project??process.cwd()})]}}let c={apply:r.apply,force:r.force,acknowledge:r.acknowledge};try{if(i===Q[0])return wi(gi(s,[bi(a[0],a[1],a[2])],c),o);if(i===Q[1])return a[0]===void 0?{ok:!1,refused:!0,lines:[e(`app.refactor.cli.needsMapping`)]}:wi(gi(s,yi(a[0],null),c),o);if(i===Q[2]){if(a[0]===void 0||a[1]===void 0||a[2]===void 0)return{ok:!1,refused:!0,lines:[e(`app.refactor.cli.needsExtract`)]};let t=E.relative(A(s),E.resolve(a[0])).split(E.sep).join(`/`),n={elements:xi(a[1]),processId:a[2],...r.name===void 0?{}:{name:r.name}};return Ti(await _i(s,t,n,c),o)}}catch(e){if(e instanceof $)return{ok:!1,refused:!0,lines:[e.message]};throw e}return{ok:!1,refused:!0,lines:[e(`app.refactor.cli.unknownAction`,{actions:Q.join(`, `)})]}}export{Qn as _,Ti as a,Ei as c,gi as d,wi as f,qn as g,mi as h,_i as i,pi as l,vi as m,$ as n,xi as o,bi as p,Ci as r,yi as s,Q as t,Si as u,Ln as v,pe as y};
@@ -0,0 +1 @@
1
+ export{c as refactorCommand}from"./chunk-refactor-CO3qyIEv.js";
@@ -1,4 +1,4 @@
1
- import{i as e}from"./chunk-xml-rMelkRIV.js";import{n as t}from"./chunk-parse-B-uKGDy-.js";const n=/\.(cmmn|cmmn11\.xml)$/i;function r(e){return n.test(e)}const i={width:14,height:20},a={column:70,row:28},o={side:24,top:40,bottom:24},s={casePlanModel:[320,200],stage:[200,120],humanTask:[110,70],processTask:[110,70],caseTask:[110,70],decisionTask:[110,70],task:[110,70],milestone:[110,40],eventListener:[36,36],timerListener:[36,36],userListener:[36,36],unknown:[110,70]};function c(e){return s[e]}function l(e,t,n){let r=[];for(let i of e.entry){let a=i.sentryRef?n.get(i.sentryRef):void 0;for(let n of a?.onParts??[])n.sourceRef&&t.has(n.sourceRef)&&n.sourceRef!==e.itemId&&r.push(n.sourceRef)}return r}function u(e,t){let[n,r]=c(e.kind);if(e.children.length===0)return{width:n,height:r,place:(t,i,a)=>void a.set(e.key,{x:t,y:i,width:n,height:r})};let i=new Map(e.children.flatMap(e=>e.itemId?[[e.itemId,e]]:[])),s=/* @__PURE__ */ new Map,d=(e,n)=>{if(!e.itemId)return 0;let r=s.get(e.itemId);if(r!==void 0)return r;if(n.has(e.itemId))return 0;n.add(e.itemId);let a=0;for(let r of l(e,i,t.sentries)){let e=i.get(r);e&&(a=Math.max(a,d(e,n)+1))}return n.delete(e.itemId),s.set(e.itemId,a),a},f=[];for(let t of e.children){let e=Math.min(d(t,/* @__PURE__ */ new Set),12);(f[e]??=[]).push(t)}let p=f.filter(e=>e!==void 0).map(e=>e.map(e=>({entry:e,size:u(e,t)}))),m=p.map(e=>Math.max(...e.map(e=>e.size.width))),h=p.map(e=>e.reduce((e,t)=>e+t.size.height+(t.entry.kind.endsWith(`istener`)||t.entry.kind===`eventListener`?22:0),0)+a.row*(e.length-1)),g=m.reduce((e,t)=>e+t,0)+a.column*(m.length-1),_=Math.max(...h),v=Math.max(n,g+o.side*2),y=Math.max(r,_+o.top+o.bottom);return{width:v,height:y,place:(t,n,r)=>{r.set(e.key,{x:t,y:n,width:v,height:y});let i=t+o.side+(v-o.side*2-g)/2;p.forEach((e,t)=>{let s=n+o.top+(y-o.top-o.bottom-h[t])/2;for(let n of e)n.size.place(i+(m[t]-n.size.width)/2,s,r),s+=n.size.height+a.row+(n.entry.kind.endsWith(`istener`)||n.entry.kind===`eventListener`?22:0);i+=m[t]+a.column})}}}function d(e,t,n,r){let a=(e,a)=>{e.forEach((o,s)=>{if(!o.id)return;let c=r.get(o.id);if(c){n.set(o.id,c);return}let l=t.y+t.height*(s+1)/(e.length+1)-i.height/2;n.set(o.id,{x:a?t.x-i.width/2:t.x+t.width-i.width/2,y:l,width:i.width,height:i.height})})};a(e.entry,!0),a(e.exit,!1)}function f(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=t.x-n,a=t.y-r;if(i===0&&a===0)return{x:n,y:r};let o=Math.min(i===0?1/0:e.width/2/Math.abs(i),a===0?1/0:e.height/2/Math.abs(a));return{x:n+i*o,y:r+a*o}}function p(e){let n=t(e),r=e.diagram.shapes,i=n.length>0&&n.every(e=>r.has(e.key)),a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=[],c=0;for(let t of e.cases){if(!t.plan)continue;let n=[],s=[t.plan];for(let e=s.pop();e;e=s.pop())n.push(e),s.push(...e.children);let l=/* @__PURE__ */ new Map;if(i)for(let e of n){let t=r.get(e.key);t&&l.set(e.key,t)}else u(t.plan,e).place(24,c+24,l);for(let[e,t]of l)a.set(e,t);let f=/* @__PURE__ */ new Map;for(let e of n){let t=l.get(e.key);t&&d(e,t,f,i?r:/* @__PURE__ */ new Map)}for(let[e,t]of f)o.set(e,t);c=Math.max(...[...l.values()].map(e=>e.y+e.height))+24}let l=/* @__PURE__ */ new Map;for(let e of n)for(let t of[...e.entry,...e.exit])t.id&&l.set(t.id,e);let p=/* @__PURE__ */ new Map;for(let e of n)for(let t of e.entry)t.sentryRef&&p.set(t.sentryRef,(p.get(t.sentryRef)??0)+1);for(let t of n)for(let n of[...t.entry,...t.exit]){let t=n.sentryRef?e.sentries.get(n.sentryRef):void 0,r=n.id?o.get(n.id):void 0;if(t&&r)for(let o of t.onParts){let c=o.sourceRef?a.get(o.sourceRef):void 0;if(!c||!o.sourceRef)continue;let l={x:r.x+r.width/2,y:r.y+r.height/2},u=i?e.diagram.edges.find(r=>(r.ref===o.id||r.ref===t.id)&&(r.target===null||e.diagram.shapeRefs.get(r.target)===n.id||p.get(t.id)===1)):void 0,d=u&&u.points.length>=2?u.points:[f(c,l),l];s.push({id:`${o.id||t.id}->${n.id}`,from:o.sourceRef,to:n.id,points:d})}}let m=[...a.values(),...o.values()],h=s.flatMap(e=>e.points),g=[...m.flatMap(e=>[e.x,e.x+e.width]),...h.map(e=>e.x)],_=[...m.flatMap(e=>[e.y,e.y+e.height]),...h.map(e=>e.y)],v=(g.length>0?Math.min(...g):0)-24,y=(_.length>0?Math.min(..._):0)-24,b=(g.length>0?Math.max(...g):0)+24,x=(_.length>0?Math.max(..._):0)+24;return{boxes:a,criteria:o,edges:s,left:v,top:y,width:b-v,height:x-y,fromDiagram:i}}const m=6.6;function h(e){return String(Math.round(e*10)/10)}function g(e,t,n){let r=Math.max(4,Math.floor(t/m)),i=e.split(/\s+/).filter(e=>e!==``),a=[],o=``;for(let e of i){let t=e;for(;t.length>r;)o!==``&&(a.push(o),o=``),a.push(t.slice(0,r)),t=t.slice(r);o===``?o=t:o.length+1+t.length<=r?o+=` ${t}`:(a.push(o),o=t)}if(o!==``&&a.push(o),a.length<=n)return a;let s=a.slice(0,n),c=s[n-1];return s[n-1]=`${c.length>=r?c.slice(0,r-1):c}…`,s}function _(t,n,r,i,a=``){if(t.length===0)return``;let o=t.map((t,r)=>`<tspan x="${h(n)}" dy="${r===0?0:15}">${e(t)}</tspan>`).join(``);return`<text class="cmmn-text ${a}" x="${h(n)}" y="${h(r)}" text-anchor="${i}">${o}</text>`}function v(e,t){let n=t.x+10,r=t.y+8;switch(e){case`humanTask`:return`<g class="cmmn-icon"><circle cx="${n+5}" cy="${r+3}" r="3"/><path d="M${n} ${r+12} q0 -6 5 -6 q5 0 5 6 z"/></g>`;case`processTask`:return`<path class="cmmn-icon" d="M${n} ${r} h7 l4 5 l-4 5 h-7 l4 -5 z"/>`;case`caseTask`:return`<path class="cmmn-icon" d="M${n} ${r+1} h4 l2 2 h5 v8 h-11 z"/>`;case`decisionTask`:return`<g class="cmmn-icon"><rect x="${n}" y="${r}" width="12" height="10"/><path d="M${n} ${r+4} h12 M${n+5} ${r} v10"/></g>`;default:return``}}function y(e,t){let n=e.rules.map(e=>e.kind===`required`?`!`:e.kind===`repetition`?`#`:`▷`);return n.length===0?``:`<text class="cmmn-mark" x="${h(t.x+t.width/2)}" y="${h(t.y+t.height-6)}" text-anchor="middle">${n.join(` `)}</text>`}function b(e,t){let{x:n,y:r,width:i,height:a}=t,o=e.kind===`unknown`?` cmmn-broken`:``;switch(e.kind){case`casePlanModel`:{let t=Math.min(i-20,Math.max(90,Math.min(260,(e.name.length+2)*m+16)));return`<path class="cmmn-shape cmmn-plan" d="M${n} ${r+24} L${n} ${r} H${n+t-10} L${n+t} ${r+24} z"/><rect class="cmmn-shape cmmn-plan" x="${n}" y="${r+24}" width="${i}" height="${a-24}"/>`}case`stage`:return`<path class="cmmn-shape cmmn-stage" d="M${n+10} ${r} H${n+i-10} L${n+i} ${r+10} V${r+a-10} L${n+i-10} ${r+a} H${n+10} L${n} ${r+a-10} V${r+10} z"/>`;case`milestone`:return`<rect class="cmmn-shape" x="${n}" y="${r}" width="${i}" height="${a}" rx="${a/2}"/>`;case`eventListener`:case`timerListener`:case`userListener`:{let t=n+i/2,o=r+a/2,s=e.kind===`timerListener`?`<path class="cmmn-icon" d="M${t} ${o-8} V${o} L${t+5} ${o+3}"/>`:e.kind===`userListener`?`<g class="cmmn-icon"><circle cx="${t}" cy="${o-3}" r="2.5"/><path d="M${t-5} ${o+7} q0 -6 5 -6 q5 0 5 6 z"/></g>`:``;return`<circle class="cmmn-shape" cx="${t}" cy="${o}" r="${i/2}"/><circle class="cmmn-shape" cx="${t}" cy="${o}" r="${i/2-4}"/>${s}`}default:return`<rect class="cmmn-shape${o}" x="${n}" y="${r}" width="${i}" height="${a}" rx="8"/>${v(e.kind,t)}`}}function x(e,t){let n=e.name||(e.kind===`unknown`?e.definitionId??``:``);switch(e.kind){case`casePlanModel`:return _(g(n,t.width-40,1),t.x+10,t.y+16,`start`,`cmmn-title`);case`stage`:return _(g(n,t.width-30,1),t.x+t.width/2,t.y+22,`middle`,`cmmn-title`);case`eventListener`:case`timerListener`:case`userListener`:return _(g(n,110,2),t.x+t.width/2,t.y+t.height+15,`middle`);default:{let r=g(n,t.width-20,Math.max(1,Math.floor((t.height-8)/15))),i=t.y+(t.height-r.length*15)/2+11;return _(r,t.x+t.width/2,e.kind===`milestone`?t.y+t.height/2+4-(r.length-1)*15/2:i+(e.kind===`task`?0:6),`middle`)}}}function S(t,n,r,i){let a=t.x+t.width/2,o=t.y+t.height/2;return`<g class="cmmn-el ${i}" data-id="${e(r)}"><path class="cmmn-${n}" d="M${h(a)} ${h(t.y)} L${h(t.x+t.width)} ${h(o)} L${h(a)} ${h(t.y+t.height)} L${h(t.x)} ${h(o)} z"/></g>`}function C(n,r,i){let a=[],o=i.flagged??/* @__PURE__ */ new Set,s=e=>`${i.selected===e?`is-selected`:``} ${o.has(e)?`is-flagged`:``}`.trim(),c=t(n),l=/* @__PURE__ */ new Map,u=(e,t)=>{l.set(e.key,t);for(let n of e.children)u(n,t+1)};for(let e of n.cases)e.plan&&u(e.plan,0);let d=[...c].sort((e,t)=>(l.get(e.key)??0)-(l.get(t.key)??0));for(let t of d){let n=r.boxes.get(t.key);n&&a.push(`<g class="cmmn-el ${s(t.key)}" data-id="${e(t.key)}">${b(t,n)}${x(t,n)}${y(t,n)}</g>`)}for(let e of r.edges){let t=e.points.map((e,t)=>`${t===0?`M`:`L`}${h(e.x)} ${h(e.y)}`).join(` `);a.push(`<path class="cmmn-link" d="${t}"/>`)}for(let e of c)for(let t of[...e.entry,...e.exit]){let e=r.criteria.get(t.id);e&&a.push(S(e,t.kind,t.id,s(t.id)))}return a.join(``)}function w(e,t={}){let n=p(e),r=n.boxes.size===0,i=r?200:Math.ceil(n.width),a=r?100:Math.ceil(n.height),o=r?0:Math.floor(n.left),s=r?0:Math.floor(n.top);return`<svg xmlns="http://www.w3.org/2000/svg" class="cmmn-svg" width="${i}" height="${a}" viewBox="${o} ${s} ${i} ${a}"><style>
1
+ import{i as e}from"./chunk-xml-rMelkRIV.js";import{n as t}from"./chunk-parse-DiOcpdOU.js";const n=/\.(cmmn|cmmn11\.xml)$/i;function r(e){return n.test(e)}const i={width:14,height:20},a={column:70,row:28},o={side:24,top:40,bottom:24},s={casePlanModel:[320,200],stage:[200,120],humanTask:[110,70],processTask:[110,70],caseTask:[110,70],decisionTask:[110,70],task:[110,70],milestone:[110,40],eventListener:[36,36],timerListener:[36,36],userListener:[36,36],unknown:[110,70]};function c(e){return s[e]}function l(e,t,n){let r=[];for(let i of e.entry){let a=i.sentryRef?n.get(i.sentryRef):void 0;for(let n of a?.onParts??[])n.sourceRef&&t.has(n.sourceRef)&&n.sourceRef!==e.itemId&&r.push(n.sourceRef)}return r}function u(e,t){let[n,r]=c(e.kind);if(e.children.length===0)return{width:n,height:r,place:(t,i,a)=>void a.set(e.key,{x:t,y:i,width:n,height:r})};let i=new Map(e.children.flatMap(e=>e.itemId?[[e.itemId,e]]:[])),s=/* @__PURE__ */ new Map,d=(e,n)=>{if(!e.itemId)return 0;let r=s.get(e.itemId);if(r!==void 0)return r;if(n.has(e.itemId))return 0;n.add(e.itemId);let a=0;for(let r of l(e,i,t.sentries)){let e=i.get(r);e&&(a=Math.max(a,d(e,n)+1))}return n.delete(e.itemId),s.set(e.itemId,a),a},f=[];for(let t of e.children){let e=Math.min(d(t,/* @__PURE__ */ new Set),12);(f[e]??=[]).push(t)}let p=f.filter(e=>e!==void 0).map(e=>e.map(e=>({entry:e,size:u(e,t)}))),m=p.map(e=>Math.max(...e.map(e=>e.size.width))),h=p.map(e=>e.reduce((e,t)=>e+t.size.height+(t.entry.kind.endsWith(`istener`)||t.entry.kind===`eventListener`?22:0),0)+a.row*(e.length-1)),g=m.reduce((e,t)=>e+t,0)+a.column*(m.length-1),_=Math.max(...h),v=Math.max(n,g+o.side*2),y=Math.max(r,_+o.top+o.bottom);return{width:v,height:y,place:(t,n,r)=>{r.set(e.key,{x:t,y:n,width:v,height:y});let i=t+o.side+(v-o.side*2-g)/2;p.forEach((e,t)=>{let s=n+o.top+(y-o.top-o.bottom-h[t])/2;for(let n of e)n.size.place(i+(m[t]-n.size.width)/2,s,r),s+=n.size.height+a.row+(n.entry.kind.endsWith(`istener`)||n.entry.kind===`eventListener`?22:0);i+=m[t]+a.column})}}}function d(e,t,n,r){let a=(e,a)=>{e.forEach((o,s)=>{if(!o.id)return;let c=r.get(o.id);if(c){n.set(o.id,c);return}let l=t.y+t.height*(s+1)/(e.length+1)-i.height/2;n.set(o.id,{x:a?t.x-i.width/2:t.x+t.width-i.width/2,y:l,width:i.width,height:i.height})})};a(e.entry,!0),a(e.exit,!1)}function f(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=t.x-n,a=t.y-r;if(i===0&&a===0)return{x:n,y:r};let o=Math.min(i===0?1/0:e.width/2/Math.abs(i),a===0?1/0:e.height/2/Math.abs(a));return{x:n+i*o,y:r+a*o}}function p(e){let n=t(e),r=e.diagram.shapes,i=n.length>0&&n.every(e=>r.has(e.key)),a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=[],c=0;for(let t of e.cases){if(!t.plan)continue;let n=[],s=[t.plan];for(let e=s.pop();e;e=s.pop())n.push(e),s.push(...e.children);let l=/* @__PURE__ */ new Map;if(i)for(let e of n){let t=r.get(e.key);t&&l.set(e.key,t)}else u(t.plan,e).place(24,c+24,l);for(let[e,t]of l)a.set(e,t);let f=/* @__PURE__ */ new Map;for(let e of n){let t=l.get(e.key);t&&d(e,t,f,i?r:/* @__PURE__ */ new Map)}for(let[e,t]of f)o.set(e,t);c=Math.max(...[...l.values()].map(e=>e.y+e.height))+24}let l=/* @__PURE__ */ new Map;for(let e of n)for(let t of[...e.entry,...e.exit])t.id&&l.set(t.id,e);let p=/* @__PURE__ */ new Map;for(let e of n)for(let t of e.entry)t.sentryRef&&p.set(t.sentryRef,(p.get(t.sentryRef)??0)+1);for(let t of n)for(let n of[...t.entry,...t.exit]){let t=n.sentryRef?e.sentries.get(n.sentryRef):void 0,r=n.id?o.get(n.id):void 0;if(t&&r)for(let o of t.onParts){let c=o.sourceRef?a.get(o.sourceRef):void 0;if(!c||!o.sourceRef)continue;let l={x:r.x+r.width/2,y:r.y+r.height/2},u=i?e.diagram.edges.find(r=>(r.ref===o.id||r.ref===t.id)&&(r.target===null||e.diagram.shapeRefs.get(r.target)===n.id||p.get(t.id)===1)):void 0,d=u&&u.points.length>=2?u.points:[f(c,l),l];s.push({id:`${o.id||t.id}->${n.id}`,from:o.sourceRef,to:n.id,points:d})}}let m=[...a.values(),...o.values()],h=s.flatMap(e=>e.points),g=[...m.flatMap(e=>[e.x,e.x+e.width]),...h.map(e=>e.x)],_=[...m.flatMap(e=>[e.y,e.y+e.height]),...h.map(e=>e.y)],v=(g.length>0?Math.min(...g):0)-24,y=(_.length>0?Math.min(..._):0)-24,b=(g.length>0?Math.max(...g):0)+24,x=(_.length>0?Math.max(..._):0)+24;return{boxes:a,criteria:o,edges:s,left:v,top:y,width:b-v,height:x-y,fromDiagram:i}}const m=6.6;function h(e){return String(Math.round(e*10)/10)}function g(e,t,n){let r=Math.max(4,Math.floor(t/m)),i=e.split(/\s+/).filter(e=>e!==``),a=[],o=``;for(let e of i){let t=e;for(;t.length>r;)o!==``&&(a.push(o),o=``),a.push(t.slice(0,r)),t=t.slice(r);o===``?o=t:o.length+1+t.length<=r?o+=` ${t}`:(a.push(o),o=t)}if(o!==``&&a.push(o),a.length<=n)return a;let s=a.slice(0,n),c=s[n-1];return s[n-1]=`${c.length>=r?c.slice(0,r-1):c}…`,s}function _(t,n,r,i,a=``){if(t.length===0)return``;let o=t.map((t,r)=>`<tspan x="${h(n)}" dy="${r===0?0:15}">${e(t)}</tspan>`).join(``);return`<text class="cmmn-text ${a}" x="${h(n)}" y="${h(r)}" text-anchor="${i}">${o}</text>`}function v(e,t){let n=t.x+10,r=t.y+8;switch(e){case`humanTask`:return`<g class="cmmn-icon"><circle cx="${n+5}" cy="${r+3}" r="3"/><path d="M${n} ${r+12} q0 -6 5 -6 q5 0 5 6 z"/></g>`;case`processTask`:return`<path class="cmmn-icon" d="M${n} ${r} h7 l4 5 l-4 5 h-7 l4 -5 z"/>`;case`caseTask`:return`<path class="cmmn-icon" d="M${n} ${r+1} h4 l2 2 h5 v8 h-11 z"/>`;case`decisionTask`:return`<g class="cmmn-icon"><rect x="${n}" y="${r}" width="12" height="10"/><path d="M${n} ${r+4} h12 M${n+5} ${r} v10"/></g>`;default:return``}}function y(e,t){let n=e.rules.map(e=>e.kind===`required`?`!`:e.kind===`repetition`?`#`:`▷`);return n.length===0?``:`<text class="cmmn-mark" x="${h(t.x+t.width/2)}" y="${h(t.y+t.height-6)}" text-anchor="middle">${n.join(` `)}</text>`}function b(e,t){let{x:n,y:r,width:i,height:a}=t,o=e.kind===`unknown`?` cmmn-broken`:``;switch(e.kind){case`casePlanModel`:{let t=Math.min(i-20,Math.max(90,Math.min(260,(e.name.length+2)*m+16)));return`<path class="cmmn-shape cmmn-plan" d="M${n} ${r+24} L${n} ${r} H${n+t-10} L${n+t} ${r+24} z"/><rect class="cmmn-shape cmmn-plan" x="${n}" y="${r+24}" width="${i}" height="${a-24}"/>`}case`stage`:return`<path class="cmmn-shape cmmn-stage" d="M${n+10} ${r} H${n+i-10} L${n+i} ${r+10} V${r+a-10} L${n+i-10} ${r+a} H${n+10} L${n} ${r+a-10} V${r+10} z"/>`;case`milestone`:return`<rect class="cmmn-shape" x="${n}" y="${r}" width="${i}" height="${a}" rx="${a/2}"/>`;case`eventListener`:case`timerListener`:case`userListener`:{let t=n+i/2,o=r+a/2,s=e.kind===`timerListener`?`<path class="cmmn-icon" d="M${t} ${o-8} V${o} L${t+5} ${o+3}"/>`:e.kind===`userListener`?`<g class="cmmn-icon"><circle cx="${t}" cy="${o-3}" r="2.5"/><path d="M${t-5} ${o+7} q0 -6 5 -6 q5 0 5 6 z"/></g>`:``;return`<circle class="cmmn-shape" cx="${t}" cy="${o}" r="${i/2}"/><circle class="cmmn-shape" cx="${t}" cy="${o}" r="${i/2-4}"/>${s}`}default:return`<rect class="cmmn-shape${o}" x="${n}" y="${r}" width="${i}" height="${a}" rx="8"/>${v(e.kind,t)}`}}function x(e,t){let n=e.name||(e.kind===`unknown`?e.definitionId??``:``);switch(e.kind){case`casePlanModel`:return _(g(n,t.width-40,1),t.x+10,t.y+16,`start`,`cmmn-title`);case`stage`:return _(g(n,t.width-30,1),t.x+t.width/2,t.y+22,`middle`,`cmmn-title`);case`eventListener`:case`timerListener`:case`userListener`:return _(g(n,110,2),t.x+t.width/2,t.y+t.height+15,`middle`);default:{let r=g(n,t.width-20,Math.max(1,Math.floor((t.height-8)/15))),i=t.y+(t.height-r.length*15)/2+11;return _(r,t.x+t.width/2,e.kind===`milestone`?t.y+t.height/2+4-(r.length-1)*15/2:i+(e.kind===`task`?0:6),`middle`)}}}function S(t,n,r,i){let a=t.x+t.width/2,o=t.y+t.height/2;return`<g class="cmmn-el ${i}" data-id="${e(r)}"><path class="cmmn-${n}" d="M${h(a)} ${h(t.y)} L${h(t.x+t.width)} ${h(o)} L${h(a)} ${h(t.y+t.height)} L${h(t.x)} ${h(o)} z"/></g>`}function C(n,r,i){let a=[],o=i.flagged??/* @__PURE__ */ new Set,s=e=>`${i.selected===e?`is-selected`:``} ${o.has(e)?`is-flagged`:``}`.trim(),c=t(n),l=/* @__PURE__ */ new Map,u=(e,t)=>{l.set(e.key,t);for(let n of e.children)u(n,t+1)};for(let e of n.cases)e.plan&&u(e.plan,0);let d=[...c].sort((e,t)=>(l.get(e.key)??0)-(l.get(t.key)??0));for(let t of d){let n=r.boxes.get(t.key);n&&a.push(`<g class="cmmn-el ${s(t.key)}" data-id="${e(t.key)}">${b(t,n)}${x(t,n)}${y(t,n)}</g>`)}for(let e of r.edges){let t=e.points.map((e,t)=>`${t===0?`M`:`L`}${h(e.x)} ${h(e.y)}`).join(` `);a.push(`<path class="cmmn-link" d="${t}"/>`)}for(let e of c)for(let t of[...e.entry,...e.exit]){let e=r.criteria.get(t.id);e&&a.push(S(e,t.kind,t.id,s(t.id)))}return a.join(``)}function w(e,t={}){let n=p(e),r=n.boxes.size===0,i=r?200:Math.ceil(n.width),a=r?100:Math.ceil(n.height),o=r?0:Math.floor(n.left),s=r?0:Math.floor(n.top);return`<svg xmlns="http://www.w3.org/2000/svg" class="cmmn-svg" width="${i}" height="${a}" viewBox="${o} ${s} ${i} ${a}"><style>
2
2
  .cmmn-bg{fill:var(--cmmn-surface,#ffffff)}
3
3
  .cmmn-shape{fill:var(--cmmn-fill,#ffffff);stroke:var(--cmmn-stroke,#2b2b2b);stroke-width:1.5}
4
4
  .cmmn-plan{fill:var(--cmmn-plan-fill,#fbfbfb)}
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-catalog-CXJ23e-I.js";import{i as t,r as n}from"./chunk-docs-BVmrekiH.js";import{r}from"./chunk-translator-DNm9zRpP.js";import i from"node:path";function a(t){return e.find(e=>e.id===t)}function o(e,r){let i=n(e,r.rule);return i?{...r,ruleId:i.id,docs:t(i.id)}:r}function s(e,t){let n=[...new Map(e.map(e=>[e.rule,e])).values()].map(e=>{let t=e.ruleId?a(e.ruleId):void 0;return{id:e.rule,shortDescription:{text:t?.title??e.rule},...t?{help:{text:r(`app.output.whyItMatters`,{why:t.why})+` `+r(`app.output.howToFixIt`,{fix:t.fix})}}:{},...e.docs?{helpUri:e.docs}:{}}});return JSON.stringify({$schema:`https://json.schemastore.org/sarif-2.1.0.json`,version:`2.1.0`,runs:[{tool:{driver:{name:`penstock ${t}`,informationUri:`https://github.com/kern0x1b/penstock-release`,rules:n}},results:e.map(e=>({ruleId:e.rule,level:e.severity,message:{text:e.message},locations:[{physicalLocation:{artifactLocation:{uri:i.relative(process.cwd(),e.file).split(i.sep).join(`/`)},...e.line===void 0?{}:{region:{startLine:e.line}}}}]}))}]},null,2)}function c(e){return e.replace(/%/g,`%25`).replace(/\r/g,`%0D`).replace(/\n/g,`%0A`)}function l(e){return c(e).replace(/:/g,`%3A`).replace(/,/g,`%2C`)}function u(e){return e.map(e=>`::${e.severity===`note`?`notice`:e.severity} file=${l(i.relative(process.cwd(),e.file))}${e.line===void 0?``:`,line=${e.line}`},title=${l(e.rule)}::${c(`${e.message}${e.docs?` ${r(`app.output.see`,{docs:e.docs})}`:``}`)}`)}export{u as n,s as r,o as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./chunk-diff-Dp3fUALc.js";import{t}from"./chunk-export-kt3sBTZu.js";import{n}from"./chunk-diagrams-CtGMGTa8.js";import{r,t as i}from"./chunk-context-rCJvBM9p.js";import{a,d as o,l as s,t as c}from"./chunk-git-57LoLvY3.js";import{r as l}from"./chunk-translator-DNm9zRpP.js";import{n as u}from"./chunk-project-lO_6DX8G.js";import d from"node:path";import{existsSync as f,mkdirSync as p}from"node:fs";async function m(m,h,g){let{root:_}=i(m);if(!s(_))return{ok:!1,lines:[l(`app.cli.notAGitRepository`)]};if(!o(_,g.base)&&f(g.base))return{ok:!1,lines:[l(`app.cli.diff.baseIsPath`,{base:g.base})]};if(h.length===0&&!o(_,g.base))return{ok:!1,lines:[l(`app.cli.diff.baseNotFound`,{base:g.base})]};let v=h.length>0?null:c(_,g.base,!0),y=v?[...v.changed,...v.added]:h.map(e=>d.relative(_,e));if(y.length===0)return{ok:!0,lines:[l(`app.cli.diff.noDifference`,{base:g.base})]};g.images&&p(g.outDir,{recursive:!0});let b=[];for(let i of y){let o=d.join(_,i),s=a(_,g.base,v?.previous[i]??i);if(!s){if(b.push(l(`app.cli.diff.newSince`,{file:i,base:g.base})),g.images&&n(o)===`process`)try{b.push(` ${l(`app.cli.diff.picture`,{file:r(await t(o,d.join(g.outDir,u(i,`.svg`))))})}`)}catch(e){b.push(` ${l(`app.cli.diff.noPicture`,{reason:e instanceof Error?e.message:String(e)})}`)}continue}let c=await e(s,o,!0);if(!c.ok)b.push(`${i}`,...c.lines.map(e=>` ${e}`));else if(b.push(`${i}`,...c.lines.slice(2).map(e=>` ${e}`).filter(e=>e.trim())),g.images&&c.summary&&n(o)===`process`)try{let e=await t(s,d.join(g.outDir,u(i,`.before.svg`)),c.summary.markersBefore),n=await t(o,d.join(g.outDir,u(i,`.after.svg`)),c.summary.markersAfter);b.push(` ${l(`app.cli.diff.before`,{file:r(e)})}`,` ${l(`app.cli.diff.after`,{file:r(n)})}`)}catch(e){b.push(` ${l(`app.cli.diff.noPictures`,{reason:e instanceof Error?e.message:String(e)})}`)}}return{ok:!0,lines:b}}export{m as againstCommand};
@@ -0,0 +1 @@
1
+ import{r as e}from"./chunk-translator-DNm9zRpP.js";import{t}from"./chunk-list-XuNpvC6j.js";import{i as n}from"./chunk-build-BsqW8Yp8.js";import{i as r}from"./chunk-model-C5VKsEOw.js";const i={verified:`app.receipt.verdict.verified`,findings:`app.receipt.verdict.findings`,"not-verified":`app.receipt.verdict.notVerified`},a={"new-errors":`app.receipt.reason.newErrors`,"new-warnings":`app.receipt.reason.newWarnings`,"scenario-failed":`app.receipt.reason.scenarioFailed`,"executable-added":`app.receipt.reason.executableAdded`,"connections-introduced":`app.receipt.reason.connectionsIntroduced`,unreadable:`app.receipt.reason.unreadable`,"too-many-files":`app.receipt.reason.tooManyFiles`,"too-large":`app.receipt.reason.tooLarge`,"check-failed":`app.receipt.reason.checkFailed`,"built-in-rules":`app.receipt.reason.builtInRules`,"scenarios-withheld":`app.receipt.reason.scenariosWithheld`};function o(t){return e(i[t])}function s(t){return e(a[t],{files:200,megabytes:r/1048576})}function c(t){return e(`app.receipt.outcome.${t}`)}function l(t,n,r){return r?n>0?e(`app.receipt.scenariosSomeFailed`,{count:t+n,failed:n}):e(`app.receipt.scenariosPassed`,{count:t}):e(`app.receipt.scenariosNotRun`)}function u(t){let r=`preview`in t,i=r?t.newProblems:n(t),a=r?t.scenarios:{passed:t.scenarios.passed,failed:t.scenarios.failed,ran:t.scenarios.status===`ran`};return e(`app.receipt.summary`,{verdict:o(t.verdict.status),problems:e(`app.receipt.newProblems`,{count:i}),scenarios:l(a.passed,a.failed,a.ran)})}function d(t){if(t.formattingOnly)return e(`app.receipt.formattingOnly`);if(!t.diff)return``;let{added:n,removed:r,changed:i,moved:a}=t.diff,o=[e(`app.receipt.diffCounts`,{added:n,removed:r,changed:i})];return a>0&&o.push(e(`app.receipt.moved`,{count:a})),o.join(`, `)}function f(t){let n=d(t);return`${t.path} ${e(`app.receipt.change.${t.change}`)}${n===``?``:` ${n}`}`}function p(n){let r=[u(n),...n.verdict.reasons.map(e=>` ${s(e)}`)];for(let e of n.files)r.push(` ${f(e)}`);if(n.checks.ran){let i=e=>e.errors+e.warnings;r.push(e(`app.receipt.checkLine`,{before:i(n.checks.before),after:i(n.checks.after),resolved:n.checks.resolved}));for(let i of[...n.checks.fresh,...n.connections.introduced])r.push(` ${e(`app.receipt.freshLine`,{severity:e(`app.receipt.severity.${i.severity}`),rule:i.rule,file:i.file,where:i.elements.length===0?``:` (${t(i.elements)})`})}`)}n.checks.rulesReason&&r.push(e(`app.receipt.rules.${n.checks.rulesReason}`));for(let t of n.executable)r.push(` ${e(`app.receipt.executableLine`,{kind:e(`app.receipt.kind.${t.kind}`),element:t.element,file:t.file})}`);for(let t of n.scenarios.results){let n=t.previous===null?``:` ${e(`app.receipt.wasBefore`,{outcome:c(t.previous)})}`;r.push(` ${t.name}: ${c(t.outcome)}${n}`)}n.scenarios.status===`skipped`&&n.scenarios.reason&&r.push(` ${e(`app.receipt.scenariosSkipped`,{reason:e(`app.receipt.skip.${n.scenarios.reason}`)})}${n.scenarios.about?` (${n.scenarios.about})`:``}`),n.layout.applied&&r.push(e(`app.receipt.layoutApplied`,{count:n.layout.moved}));for(let t of n.attempts)r.push(e(t.handedBack?`app.receipt.attemptHandedBack`:`app.receipt.attempt`,{n:t.n,count:t.newFindings}));return n.exhausted&&r.push(e(`app.receipt.exhausted`,{count:n.maxAttempts})),r}function m(t){return[u(t),e(`app.receipt.previewNote`,{files:t.files})]}function h(t){return t.slice(0,5).map(t=>`${t.at}: ${e(`app.receipt.problem.${t.code}`)}`).join(`; `)}export{o as i,h as n,p as r,m as t};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./chunk-version-CdS8_QQd.js";import{t}from"./chunk-atomicWrite-C6J1gDtO.js";import{C as n,S as r,a as i,b as a,d as o,f as s,m as c,n as l,r as u,u as d,w as f}from"./chunk-license-BG88gpDZ.js";import{r as p,t as m}from"./chunk-translator-DNm9zRpP.js";import{s as h,t as g}from"./chunk-features-C6o8of19.js";import{n as ee,r as te,t as _}from"./chunk-preferencesFile-F6bAlNrk.js";import{D as ne,F as re,G as ie,I as ae,J as oe,K as se,M as ce,P as le,Q as ue,R as de,S as fe,T as pe,W as me,X as he,Y as ge,Z as _e,f as ve,i as ye,k as be,p as v,q as xe,t as Se,u as Ce,w as we,x as Te}from"./chunk-mcpLaunch-LyfmIF_Z.js";import{t as Ee}from"./chunk-redact-Bz1nB1gq.js";import{a as De,i as Oe}from"./chunk-variables-CXAMjZIR.js";import{a as ke}from"./chunk-moddle-D3Ym38EZ.js";import{b as Ae,c as je,l as Me,s as Ne}from"./chunk-engine-CxgdJ2wO.js";import{a as Pe,i as Fe,r as Ie,s as Le}from"./chunk-model-f8AzYUK7.js";import{a as Re,c as ze,d as Be,f as Ve,h as He,i as Ue,l as We,m as y,n as Ge,o as Ke,p as qe,r as Je,s as Ye,t as b}from"./chunk-codeScan-C09My9xv.js";import{a as Xe,o as Ze,r as Qe,t as $e}from"./chunk-workerVariables-DIDoUpHF.js";import{n as et,o as tt,t as nt}from"./chunk-penstockCli-CKMvaZ0O.js";import{t as rt}from"./chunk-examples-0HkF-frb.js";import{i as it}from"./chunk-template-Bh7oqbPl.js";import{i as at,r as ot,t as st}from"./chunk-flows-DSPvoa7f.js";import{a as ct,c as lt,i as ut,l as dt,o as ft,r as pt,s as mt,t as ht}from"./chunk-codeFactSet-LxSnQy8K.js";import{a as gt,c as _t}from"./chunk-variableChecks-KnECGMR3.js";import{t as vt}from"./chunk-codeIndex-N1gnP_sW.js";import{r as yt,t as bt}from"./chunk-connectors-Dk9qoDwI.js";import{A as xt,F as St,I as Ct,L as wt,M as Tt,N as Et,P as Dt,c as Ot,g as kt,i as At,j as jt,l as Mt,m as Nt,o as Pt}from"./chunk-load-rfn3E0t5.js";import{o as Ft}from"./chunk-failure-D5brrYW2.js";import{t as It}from"./chunk-context-rCJvBM9p.js";import{i as Lt,r as Rt}from"./chunk-connections-D_wC6d0W.js";import{a as zt}from"./chunk-promotion-Boedyq43.js";import{t as Bt}from"./chunk-paths-DIxn78bW.js";import{a as Vt}from"./chunk-trust-DubjEjlN.js";import{d as Ht,g as Ut,h as Wt,m as Gt,p as Kt}from"./chunk-jsonScan-DH9djCOu.js";import{_ as qt,d as Jt,i as Yt,n as Xt,v as Zt}from"./chunk-refactor-BJXxEtVs.js";import x from"node:path";import{constants as Qt,homedir as $t}from"node:os";import{accessSync as en,constants as S,createReadStream as tn,existsSync as C,lstatSync as nn,mkdirSync as rn,readFileSync as w,readdirSync as an,readlinkSync as on,realpathSync as T,renameSync as sn,rmSync as cn,statSync as E,watch as ln,writeFileSync as un}from"node:fs";import{execFile as dn,spawn as fn}from"node:child_process";import{createHash as pn,randomBytes as mn,randomUUID as hn,timingSafeEqual as gn}from"node:crypto";import{copyFile as _n,link as vn,lstat as D,mkdir as O,open as yn,opendir as bn,readFile as xn,readdir as k,realpath as Sn,rename as A,rm as Cn,stat as j,unlink as wn,writeFile as Tn}from"node:fs/promises";import{crc32 as En,createDeflateRaw as Dn,deflateRaw as On}from"node:zlib";import{Document as kn,parseDocument as An}from"yaml";import jn from"node:http";import{PROTOCOL_VERSION as Mn,RequestError as Nn,client as Pn,ndJsonStream as Fn}from"@agentclientprotocol/sdk";import{Readable as In,Writable as Ln}from"node:stream";import{pipeline as Rn}from"node:stream/promises";import{promisify as zn}from"node:util";import{isIP as Bn}from"node:net";const Vn=/* @__PURE__ */ new Set([`task`,`subProcess`,`callActivity`,`transaction`,`adHocSubProcess`]);function Hn(e=[],t=[]){return{elements:new Set(e),flows:new Set(t)}}function Un(e,t){return Hn([...e.elements,...t.elements],[...e.flows,...t.flows])}function Wn(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim()!==``):[]}function Gn(e){return Array.isArray(e)?e:[]}function Kn(e,t,n,r){if(typeof t!=`string`||!t)return;let i=e.get(t)??{processId:t,all:Hn(),tests:/* @__PURE__ */ new Map};i.all=Un(i.all,r),n&&i.tests.set(n,Un(i.tests.get(n)??Hn(),r)),e.set(t,i)}function qn(e){return Hn(Wn(e?.completedElements),Wn(e?.takenSequenceFlows))}function Jn(e){let t=/* @__PURE__ */ new Map;return Gn(e).forEach(e=>{let n=typeof e?.modelKey==`string`?e.modelKey:``,r=t.get(n)??Hn();e?.source===`FLOW_NODE`&&e?.type===`END`&&e.definitionKey&&r.elements.add(e.definitionKey),e?.source===`SEQUENCE_FLOW`&&e.definitionKey&&r.flows.add(e.definitionKey),t.set(n,r)}),t}function Yn(e){let t=/* @__PURE__ */ new Map,n;try{n=JSON.parse(e)}catch{return t}return Gn(n?.suites).forEach(e=>{let n=String(e?.name??``).split(`.`).pop()??``;Gn(e?.runs).forEach(e=>{let r=[n,String(e?.name??``)].filter(e=>e).join(`.`);Gn(e?.processCoverages).forEach(e=>Kn(t,e?.processDefinitionId,r,qn(e))),Jn(e?.events).forEach((e,n)=>Kn(t,n,r,e))})}),Gn(n?.processCoverages).forEach(e=>Kn(t,e?.processDefinitionId,null,qn(e))),t}function Xn(e){let t=/* @__PURE__ */ new Map;return e.forEach(e=>e.forEach(e=>{Kn(t,e.processId,null,e.all),e.tests.forEach((n,r)=>Kn(t,e.processId,r,n))})),t}function Zn(e){return e.endsWith(`Task`)||e.endsWith(`Event`)||e.endsWith(`Gateway`)||Vn.has(e)}function Qn(e,t){let n=t.filter(e=>Zn(e.type)),r=t.filter(e=>e.type===`sequenceFlow`),i=n.length+r.length;return i===0?null:(n.filter(t=>e.elements.has(t.id)).length+r.filter(t=>e.flows.has(t.id)).length)/i}function $n(e,t){return{reach:Xn(t.map(e=>Yn(e.text))),reports:t.map(t=>He(e,t.path)),updatedAt:t.length>0?Math.max(...t.map(e=>e.stamp)):null}}function er(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let r=n+1,i=t.length+1,a=Array(i).fill(r),o=Array(i).fill(r);for(let e=0;e<=Math.min(n,t.length);e+=1)a[e]=e;for(let s=0;s<e.length;s+=1){let c=Math.max(0,s-n),l=Math.min(t.length-1,s+n);c>0&&(o[c]=r),o[0]=s+1<=n?s+1:r;let u=c===0?o[0]:r;for(let n=c;n<=l;n+=1){let i=Math.min(a[n+1]+1,o[n]+1,a[n]+(e[s]===t[n]?0:1),r);o[n+1]=i,i<u&&(u=i)}if(l+2<i&&(o[l+2]=r),u>n)return r;[a,o]=[o,a]}return Math.min(a[t.length],r)}function tr(e,t){let n=new Set(t),r=e.toLowerCase(),i=[...n].find(t=>t!==e&&t.toLowerCase()===r);if(i)return i;if(e.length<4)return null;let a=null,o=1/0;return n.forEach(t=>{let n=er(t.toLowerCase(),e.toLowerCase(),2);n>=1&&n<=2&&n<o&&(a=t,o=n)}),a}function nr(e,t={}){switch(e){case`CONDITION`:case`FEEL_CONDITION`:return p(`app.scriptTab.condition`);case`EXECUTION_LISTENER`:return p(`app.scriptTab.executionListener`,{event:t.event??``});case`TASK_LISTENER`:return p(`app.scriptTab.taskListener`,{event:t.event??``});case`PARAMETER`:case`INPUT_MAPPING`:case`OUTPUT_MAPPING`:return t.parameter?.direction===`output`?p(`app.scriptTab.output`,{name:t.parameter.name}):p(`app.scriptTab.input`,{name:t.parameter?.name??``});case`TASK_BODY`:return p(`app.scriptTab.script`)}}function rr(e,t){return p(`app.scriptTab.title`,{name:e,what:t})}function ir(e){return rr(e.shared?p(`app.scriptTab.nameWithId`,{name:e.name,id:e.slot.elementId}):e.name,nr(e.slot.owner,e))}var ar=class e{children;folder;folders=/* @__PURE__ */ new Map;elements=/* @__PURE__ */ new Map;constructor(e,t){this.children=e,this.folder=t}enter(t){let n=this.folders.get(t);if(!n){let r=[],i={kind:`folder`,id:t,count:0,children:r};this.children.push(i),n=new e(r,i),this.folders.set(t,n)}return n.folder&&(n.folder.count+=1),n}add(e){let t=this.elements.get(e.slot.elementId);if(t){t.sites.push(e);return}let n={kind:`element`,elementId:e.slot.elementId,sites:[e],sharedLabel:!1};this.elements.set(e.slot.elementId,n),this.children.push(n)}};function or(e){let t=/* @__PURE__ */ new Map;e.forEach(e=>{if(e.kind!==`element`)return;let n=e.sites[0].name;t.set(n,(t.get(n)??0)+1)}),e.forEach(e=>{e.kind===`element`?e.sharedLabel=(t.get(e.sites[0].name)??0)>1:or(e.children)})}function sr(e){let t=new ar([],null);return e.forEach(e=>{let n=t;e.containers.forEach(e=>{n=n.enter(e)}),n.add(e)}),or(t.children),t.children}function cr(){return[[p(`app.toolWindow.action.createJobWorker`),`spring`],[p(`app.toolWindow.action.createNodeWorker`),`node`],[p(`app.toolWindow.action.createPythonWorker`),`python`]]}function lr(){return[[p(`app.toolWindow.action.jobWorkerSkeleton`),`spring`],[p(`app.toolWindow.action.nodeWorkerSkeleton`),`node`],[p(`app.toolWindow.action.pythonWorkerSkeleton`),`python`]]}const ur={"camunda-8":{label:`app.toolWindow.examples.camunda8Label`,detail:`app.toolWindow.examples.camunda8Detail`},"camunda-7":{label:`app.toolWindow.examples.camunda7Label`,detail:`app.toolWindow.examples.camunda7Detail`},operaton:{label:`app.toolWindow.examples.operatonLabel`,detail:`app.toolWindow.examples.operatonDetail`},"cib-seven":{label:`app.toolWindow.examples.cibSevenLabel`,detail:`app.toolWindow.examples.cibSevenDetail`},flowable:{label:`app.toolWindow.examples.flowableLabel`,detail:`app.toolWindow.examples.flowableDetail`},activiti:{label:`app.toolWindow.examples.activitiLabel`,detail:`app.toolWindow.examples.activitiDetail`}};function dr(e){let t=ur[e];return{label:p(t.label),detail:p(t.detail)}}function fr(e){let t=Ae(e)?.family;return t===`camunda-8`?`JOB_TYPE`:t===`camunda-7`?`TOPIC`:null}function M(e,t){return p(`app.toolWindow.count.${t}s`,{count:e})}function pr(e){return e.slice(e.lastIndexOf(`.`)+1)}function mr(e){return e?e.endsWith(`Event`)?`event`:e.endsWith(`Gateway`)?`gateway`:`task`:`task`}function hr(e){let t=e.toLowerCase();return t.endsWith(`.dmn`)?`decision`:t.endsWith(`.form`)?`form`:`process`}function gr(e){switch(e){case`JOB_TYPE`:return p(`app.toolWindow.kind.jobType`);case`TOPIC`:return p(`app.toolWindow.kind.topic`);case`JAVA_CLASS`:return p(`app.toolWindow.kind.javaClass`);case`BEAN`:return p(`app.toolWindow.kind.bean`)}}function _r(e){let t=e.split(`
1
+ import{n as e}from"./chunk-version-CdS8_QQd.js";import{t}from"./chunk-atomicWrite-C6J1gDtO.js";import{C as n,S as r,a as i,b as a,d as o,f as s,m as c,n as l,r as u,u as d,w as f}from"./chunk-license-BG88gpDZ.js";import{r as p,t as m}from"./chunk-translator-DNm9zRpP.js";import{s as h,t as g}from"./chunk-features-C6o8of19.js";import{n as ee,r as te,t as _}from"./chunk-preferencesFile-F6bAlNrk.js";import{D as ne,F as re,G as ie,I as ae,J as oe,K as se,M as ce,P as le,Q as ue,R as de,S as fe,T as pe,W as me,X as he,Y as ge,Z as _e,f as ve,i as ye,k as be,p as v,q as xe,t as Se,u as Ce,w as we,x as Te}from"./chunk-mcpLaunch-BS709697.js";import{t as Ee}from"./chunk-redact-Bz1nB1gq.js";import{a as De,i as Oe}from"./chunk-variables-CXAMjZIR.js";import{a as ke}from"./chunk-moddle-D3Ym38EZ.js";import{b as Ae,c as je,l as Me,s as Ne}from"./chunk-engine-CxgdJ2wO.js";import{a as Pe,i as Fe,r as Ie,s as Le}from"./chunk-model-BulEKnY1.js";import{a as Re,c as ze,d as Be,f as Ve,h as He,i as Ue,l as We,m as y,n as Ge,o as Ke,p as qe,r as Je,s as Ye,t as b}from"./chunk-codeScan-C09My9xv.js";import{a as Xe,o as Ze,r as Qe,t as $e}from"./chunk-workerVariables-CulLc3YH.js";import{n as et,o as tt,t as nt}from"./chunk-penstockCli-C41P_G7i.js";import{t as rt}from"./chunk-examples-BG0lGXcZ.js";import{i as it}from"./chunk-template-Bh7oqbPl.js";import{i as at,r as ot,t as st}from"./chunk-flows-DSPvoa7f.js";import{a as ct,c as lt,i as ut,l as dt,o as ft,r as pt,s as mt,t as ht}from"./chunk-codeFactSet-DiAYqvbb.js";import{a as gt,c as _t}from"./chunk-variableChecks-CBDpmI4d.js";import{t as vt}from"./chunk-codeIndex-vStNh6Bm.js";import{r as yt,t as bt}from"./chunk-connectors-Dk9qoDwI.js";import{A as xt,F as St,I as Ct,L as wt,M as Tt,N as Et,P as Dt,c as Ot,g as kt,i as At,j as jt,l as Mt,m as Nt,o as Pt}from"./chunk-load-rfn3E0t5.js";import{o as Ft}from"./chunk-failure-BRyRvObj.js";import{t as It}from"./chunk-context-rCJvBM9p.js";import{i as Lt,r as Rt}from"./chunk-connections-D_wC6d0W.js";import{a as zt}from"./chunk-promotion-DDLrgBqZ.js";import{t as Bt}from"./chunk-paths-DIxn78bW.js";import{a as Vt}from"./chunk-trust-Di4EYPah.js";import{d as Ht,g as Ut,h as Wt,m as Gt,p as Kt}from"./chunk-jsonScan-DH9djCOu.js";import{_ as qt,d as Jt,i as Yt,n as Xt,v as Zt}from"./chunk-refactor-CO3qyIEv.js";import x from"node:path";import{constants as Qt,homedir as $t}from"node:os";import{accessSync as en,constants as S,createReadStream as tn,existsSync as C,lstatSync as nn,mkdirSync as rn,readFileSync as w,readdirSync as an,readlinkSync as on,realpathSync as T,renameSync as sn,rmSync as cn,statSync as E,watch as ln,writeFileSync as un}from"node:fs";import{execFile as dn,spawn as fn}from"node:child_process";import{createHash as pn,randomBytes as mn,randomUUID as hn,timingSafeEqual as gn}from"node:crypto";import{copyFile as _n,link as vn,lstat as D,mkdir as O,open as yn,opendir as bn,readFile as xn,readdir as k,realpath as Sn,rename as A,rm as Cn,stat as j,unlink as wn,writeFile as Tn}from"node:fs/promises";import{crc32 as En,createDeflateRaw as Dn,deflateRaw as On}from"node:zlib";import{Document as kn,parseDocument as An}from"yaml";import jn from"node:http";import{PROTOCOL_VERSION as Mn,RequestError as Nn,client as Pn,ndJsonStream as Fn}from"@agentclientprotocol/sdk";import{Readable as In,Writable as Ln}from"node:stream";import{pipeline as Rn}from"node:stream/promises";import{promisify as zn}from"node:util";import{isIP as Bn}from"node:net";const Vn=/* @__PURE__ */ new Set([`task`,`subProcess`,`callActivity`,`transaction`,`adHocSubProcess`]);function Hn(e=[],t=[]){return{elements:new Set(e),flows:new Set(t)}}function Un(e,t){return Hn([...e.elements,...t.elements],[...e.flows,...t.flows])}function Wn(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim()!==``):[]}function Gn(e){return Array.isArray(e)?e:[]}function Kn(e,t,n,r){if(typeof t!=`string`||!t)return;let i=e.get(t)??{processId:t,all:Hn(),tests:/* @__PURE__ */ new Map};i.all=Un(i.all,r),n&&i.tests.set(n,Un(i.tests.get(n)??Hn(),r)),e.set(t,i)}function qn(e){return Hn(Wn(e?.completedElements),Wn(e?.takenSequenceFlows))}function Jn(e){let t=/* @__PURE__ */ new Map;return Gn(e).forEach(e=>{let n=typeof e?.modelKey==`string`?e.modelKey:``,r=t.get(n)??Hn();e?.source===`FLOW_NODE`&&e?.type===`END`&&e.definitionKey&&r.elements.add(e.definitionKey),e?.source===`SEQUENCE_FLOW`&&e.definitionKey&&r.flows.add(e.definitionKey),t.set(n,r)}),t}function Yn(e){let t=/* @__PURE__ */ new Map,n;try{n=JSON.parse(e)}catch{return t}return Gn(n?.suites).forEach(e=>{let n=String(e?.name??``).split(`.`).pop()??``;Gn(e?.runs).forEach(e=>{let r=[n,String(e?.name??``)].filter(e=>e).join(`.`);Gn(e?.processCoverages).forEach(e=>Kn(t,e?.processDefinitionId,r,qn(e))),Jn(e?.events).forEach((e,n)=>Kn(t,n,r,e))})}),Gn(n?.processCoverages).forEach(e=>Kn(t,e?.processDefinitionId,null,qn(e))),t}function Xn(e){let t=/* @__PURE__ */ new Map;return e.forEach(e=>e.forEach(e=>{Kn(t,e.processId,null,e.all),e.tests.forEach((n,r)=>Kn(t,e.processId,r,n))})),t}function Zn(e){return e.endsWith(`Task`)||e.endsWith(`Event`)||e.endsWith(`Gateway`)||Vn.has(e)}function Qn(e,t){let n=t.filter(e=>Zn(e.type)),r=t.filter(e=>e.type===`sequenceFlow`),i=n.length+r.length;return i===0?null:(n.filter(t=>e.elements.has(t.id)).length+r.filter(t=>e.flows.has(t.id)).length)/i}function $n(e,t){return{reach:Xn(t.map(e=>Yn(e.text))),reports:t.map(t=>He(e,t.path)),updatedAt:t.length>0?Math.max(...t.map(e=>e.stamp)):null}}function er(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let r=n+1,i=t.length+1,a=Array(i).fill(r),o=Array(i).fill(r);for(let e=0;e<=Math.min(n,t.length);e+=1)a[e]=e;for(let s=0;s<e.length;s+=1){let c=Math.max(0,s-n),l=Math.min(t.length-1,s+n);c>0&&(o[c]=r),o[0]=s+1<=n?s+1:r;let u=c===0?o[0]:r;for(let n=c;n<=l;n+=1){let i=Math.min(a[n+1]+1,o[n]+1,a[n]+(e[s]===t[n]?0:1),r);o[n+1]=i,i<u&&(u=i)}if(l+2<i&&(o[l+2]=r),u>n)return r;[a,o]=[o,a]}return Math.min(a[t.length],r)}function tr(e,t){let n=new Set(t),r=e.toLowerCase(),i=[...n].find(t=>t!==e&&t.toLowerCase()===r);if(i)return i;if(e.length<4)return null;let a=null,o=1/0;return n.forEach(t=>{let n=er(t.toLowerCase(),e.toLowerCase(),2);n>=1&&n<=2&&n<o&&(a=t,o=n)}),a}function nr(e,t={}){switch(e){case`CONDITION`:case`FEEL_CONDITION`:return p(`app.scriptTab.condition`);case`EXECUTION_LISTENER`:return p(`app.scriptTab.executionListener`,{event:t.event??``});case`TASK_LISTENER`:return p(`app.scriptTab.taskListener`,{event:t.event??``});case`PARAMETER`:case`INPUT_MAPPING`:case`OUTPUT_MAPPING`:return t.parameter?.direction===`output`?p(`app.scriptTab.output`,{name:t.parameter.name}):p(`app.scriptTab.input`,{name:t.parameter?.name??``});case`TASK_BODY`:return p(`app.scriptTab.script`)}}function rr(e,t){return p(`app.scriptTab.title`,{name:e,what:t})}function ir(e){return rr(e.shared?p(`app.scriptTab.nameWithId`,{name:e.name,id:e.slot.elementId}):e.name,nr(e.slot.owner,e))}var ar=class e{children;folder;folders=/* @__PURE__ */ new Map;elements=/* @__PURE__ */ new Map;constructor(e,t){this.children=e,this.folder=t}enter(t){let n=this.folders.get(t);if(!n){let r=[],i={kind:`folder`,id:t,count:0,children:r};this.children.push(i),n=new e(r,i),this.folders.set(t,n)}return n.folder&&(n.folder.count+=1),n}add(e){let t=this.elements.get(e.slot.elementId);if(t){t.sites.push(e);return}let n={kind:`element`,elementId:e.slot.elementId,sites:[e],sharedLabel:!1};this.elements.set(e.slot.elementId,n),this.children.push(n)}};function or(e){let t=/* @__PURE__ */ new Map;e.forEach(e=>{if(e.kind!==`element`)return;let n=e.sites[0].name;t.set(n,(t.get(n)??0)+1)}),e.forEach(e=>{e.kind===`element`?e.sharedLabel=(t.get(e.sites[0].name)??0)>1:or(e.children)})}function sr(e){let t=new ar([],null);return e.forEach(e=>{let n=t;e.containers.forEach(e=>{n=n.enter(e)}),n.add(e)}),or(t.children),t.children}function cr(){return[[p(`app.toolWindow.action.createJobWorker`),`spring`],[p(`app.toolWindow.action.createNodeWorker`),`node`],[p(`app.toolWindow.action.createPythonWorker`),`python`]]}function lr(){return[[p(`app.toolWindow.action.jobWorkerSkeleton`),`spring`],[p(`app.toolWindow.action.nodeWorkerSkeleton`),`node`],[p(`app.toolWindow.action.pythonWorkerSkeleton`),`python`]]}const ur={"camunda-8":{label:`app.toolWindow.examples.camunda8Label`,detail:`app.toolWindow.examples.camunda8Detail`},"camunda-7":{label:`app.toolWindow.examples.camunda7Label`,detail:`app.toolWindow.examples.camunda7Detail`},operaton:{label:`app.toolWindow.examples.operatonLabel`,detail:`app.toolWindow.examples.operatonDetail`},"cib-seven":{label:`app.toolWindow.examples.cibSevenLabel`,detail:`app.toolWindow.examples.cibSevenDetail`},flowable:{label:`app.toolWindow.examples.flowableLabel`,detail:`app.toolWindow.examples.flowableDetail`},activiti:{label:`app.toolWindow.examples.activitiLabel`,detail:`app.toolWindow.examples.activitiDetail`}};function dr(e){let t=ur[e];return{label:p(t.label),detail:p(t.detail)}}function fr(e){let t=Ae(e)?.family;return t===`camunda-8`?`JOB_TYPE`:t===`camunda-7`?`TOPIC`:null}function M(e,t){return p(`app.toolWindow.count.${t}s`,{count:e})}function pr(e){return e.slice(e.lastIndexOf(`.`)+1)}function mr(e){return e?e.endsWith(`Event`)?`event`:e.endsWith(`Gateway`)?`gateway`:`task`:`task`}function hr(e){let t=e.toLowerCase();return t.endsWith(`.dmn`)?`decision`:t.endsWith(`.form`)?`form`:`process`}function gr(e){switch(e){case`JOB_TYPE`:return p(`app.toolWindow.kind.jobType`);case`TOPIC`:return p(`app.toolWindow.kind.topic`);case`JAVA_CLASS`:return p(`app.toolWindow.kind.javaClass`);case`BEAN`:return p(`app.toolWindow.kind.bean`)}}function _r(e){let t=e.split(`
2
2
  `).map(e=>e.trim()).find(e=>e!==``);if(t)return t.length>60?`${t.slice(0,59)}…`:t}function vr(e){return e===`sequenceFlow`?`flow`:mr(e)}function yr(e){return Math.round(e*100)}function br(e){switch(e){case`ready`:return p(`app.toolWindow.migrationStatus.ready`);case`converts`:return p(`app.toolWindow.migrationStatus.converts`);case`needs-work`:return p(`app.toolWindow.migrationStatus.needsWork`);case`blocked`:return p(`app.toolWindow.migrationStatus.blocked`)}}function xr(e,t){let n=He(e,t);return n.includes(`/`)?n.slice(0,n.lastIndexOf(`/`)):void 0}function N(e){return e.filter(e=>typeof e==`string`&&e!==``).join(` · `)||void 0}var Sr=class{actions=/* @__PURE__ */ new Map;next=0;input;constructor(e){this.input=e}action(e,t,n,r,i){let a=`a${this.next+=1}`;return this.actions.set(a,t),{id:a,label:e,icon:n,keys:r,selected:i}}open(e){let t=`a${this.next+=1}`;return this.actions.set(t,e),t}links(e){return this.input.code?.links.get(ze(e))}copy(e){return this.action(p(`app.toolWindow.action.copyId`),{type:`copy`,text:e},`copy`,`COPY`)}usages(e,t){return this.input.code?[this.action(p(`app.toolWindow.action.findUsages`),{type:`findUsages`,subjects:e,title:t},`find`,`FIND_USAGES`)]:[]}testLinks(e,t){return e.length===0?[]:[this.action(p(`app.toolWindow.action.runTests`),{type:`runTests`,handles:e,title:t,debug:!1},`run`),this.action(p(`app.toolWindow.action.debugTests`),{type:`runTests`,handles:e,title:t,debug:!0},`debug`)]}deploy(e,t,n){return this.action(p(`app.toolWindow.action.deploy`),{type:`deploy`,paths:e,profile:t,confirm:n},`deploy`)}model(e){return this.input.files.find(t=>t.path===e)?.model}usageNode(e,t,n){let r=this.model(e),i=r?.processes.find(e=>e.id===t.processId);return{id:`use:${e}#${t.id}:${n??``}`,label:t.label,detail:N([n,i?.label,y(e)]),icon:mr(t.type),open:this.open({type:`reveal`,path:e,elementId:t.id}),actions:[...r?this.usages(We(r,t.id),t.label):[],this.copy(t.id)]}}scriptsOf(e,t){let n=e.model.scripts.filter(e=>e.processId===t);if(n.length===0)return[];let r=n.length<=12?`ALWAYS`:`NONE`;return[{id:`scripts:${e.path}#process:${t}`,label:p(`app.toolWindow.section.scripts`),detail:M(n.length,`script`),icon:`script`,expand:r,children:sr(n).map(t=>this.scriptNode(e,t,r))}]}scriptNode(e,t,n){if(t.kind===`folder`)return this.scriptFolder(e,t,n);let[r]=t.sites,i=`scripts:${e.path}#${t.elementId}`;return t.sites.length>1?{id:i,label:r.name,detail:N([t.sharedLabel&&t.elementId,M(t.sites.length,`script`)]),icon:vr(r.type),expand:n,actions:[this.copy(t.elementId)],children:t.sites.map(t=>this.scriptSlot(e,t))}:this.scriptSite(e,r,t,i)}scriptFolder(e,t,n){let r=e.model.elements.find(e=>e.id===t.id)?.label??t.id;return{id:`scripts:${e.path}#container:${t.id}`,label:r,detail:M(t.count,`script`),icon:`folder`,expand:n,children:t.children.map(t=>this.scriptNode(e,t,n))}}scriptSite(e,t,n,r){return{id:r,label:t.name,detail:N([n.sharedLabel&&t.slot.elementId,nr(t.slot.owner,t),t.language,_r(t.value)]),icon:vr(t.type),open:this.open({type:`script`,path:e.path,slot:t.slot}),actions:[this.copy(t.slot.elementId)]}}scriptSlot(e,t){let{slot:n}=t;return{id:`scripts:${e.path}#${n.elementId}#${n.owner}#${n.index}`,label:nr(t.slot.owner,t),detail:N([t.language,_r(t.value)]),icon:`script`,open:this.open({type:`script`,path:e.path,slot:n})}}coverageOf(e,t,n){let r=this.input.coverage.get(e),i=n?r?.tests.get(n):r?.all;if(!i)return null;let a=Qn(i,t.elements.filter(t=>t.processId===e));return a===null?null:yr(a)}testNode(e,t,n=pr(e.declaration??e.label)){return{id:`test:${e.declaration??e.handle}:${n}`,label:n,detail:t,icon:`test`,open:this.open({type:`openCode`,handles:[e.handle],title:n}),actions:this.testLinks([e.handle],n)}}debugSection(){let e=this.input.debug;if(e.length===0)return null;let t=/* @__PURE__ */ new Set;return{id:`debug`,label:p(`app.toolWindow.section.debug`),detail:e[0].source,icon:`debug`,expand:`ALWAYS`,children:e.flatMap(e=>{let n=this.model(e.path);return[...e.current,...e.active].map((e,t)=>({id:e,number:t})).filter(({id:n},r,i)=>{let a=`debug:${e.path}#${n}`;return!t.has(a)&&(t.add(a),i.findIndex(e=>e.id===n)===r)}).map(({id:t,number:r})=>{let i=n?.elements.find(e=>e.id===t),a=n?.processes.find(e=>e.id===i?.processId),o=r<e.current.length;return{id:`debug:${e.path}#${t}`,label:p(o?`app.toolWindow.debug.pausedAt`:`app.toolWindow.debug.activeAt`,{name:i?.label??t}),detail:N([a?.label,e.instance&&p(`app.toolWindow.detail.instance`,{instance:e.instance}),y(e.path)]),icon:o?`paused`:`active`,open:this.open({type:`reveal`,path:e.path,elementId:t}),actions:[this.copy(t)]}})})}}processes(){let e=this.input.files.flatMap(e=>e.model.processes.map(t=>({file:e,process:t}))),t=new Map(e.map(e=>[e.process.id,e]));return{id:`processes`,label:p(`app.toolWindow.section.processes`),detail:String(e.length),icon:`process`,children:e.map(({file:e,process:n})=>{let r={kind:`PROCESS`,value:n.id},i=(this.links(r)??[]).filter(e=>e.test),a=this.coverageOf(n.id,e.model),o=e.model.calls.filter(t=>e.model.elements.find(e=>e.id===t.elementId)?.processId===n.id),s=this.input.files.flatMap(e=>e.model.calls.filter(e=>e.calledProcessId===n.id).map(t=>({other:e,call:t})));return{id:`process:${e.path}#${n.id}`,label:n.label,detail:N([n.id!==n.label&&n.id,y(e.path),i.length>0&&M(i.length,`test`),a!==null&&p(`app.toolWindow.detail.percentCovered`,{percent:a})]),icon:`process`,open:this.open({type:`reveal`,path:e.path}),actions:[...this.usages([r],n.label),...i.length>0?this.testLinks(i.map(e=>e.handle),n.label):[],this.deploy([e.path]),this.copy(n.id)],children:[...i.map(t=>{let r=this.coverageOf(n.id,e.model,t.declaration);return this.testNode(t,N([p(`app.toolWindow.detail.test`),r!==null&&`${r}%`]))}),...o.map(n=>{let r=t.get(n.calledProcessId),i=e.model.elements.find(e=>e.id===n.elementId);return{id:`calls:${e.path}#${n.elementId}`,label:p(`app.toolWindow.detail.calls`,{name:r?.process.label??n.calledProcessId}),detail:r?i?.label:p(`app.toolWindow.detail.notInProject`),icon:`calls`,warning:!r,open:this.open(r?{type:`reveal`,path:r.file.path}:{type:`reveal`,path:e.path,elementId:n.elementId})}}),...s.map(({other:e,call:t})=>{let n=e.model.elements.find(e=>e.id===t.elementId),r=e.model.processes.find(e=>e.id===n?.processId);return{id:`calledBy:${e.path}#${t.elementId}`,label:p(`app.toolWindow.detail.calledBy`,{name:r?.label??y(e.path)}),detail:n?.label,icon:`calledBy`,open:this.open({type:`reveal`,path:e.path,elementId:t.elementId})}}),...this.scriptsOf(e,n.id)]}})}}tests(){if(!this.input.code?.precise)return null;let e=/* @__PURE__ */ new Map;this.input.files.forEach(({path:t,model:n})=>n.processes.forEach(r=>{(this.links({kind:`PROCESS`,value:r.id})??[]).filter(e=>e.test).forEach(i=>{let a=i.declaration??i.label,o=e.get(a)??{link:i,uses:[]};o.uses.push({path:t,model:n,processId:r.id,label:r.label}),e.set(a,o)})}));let t=/* @__PURE__ */ new Map;[...e.keys()].forEach(e=>{let n=e.includes(`.`)?e.slice(0,e.lastIndexOf(`.`)):p(`app.toolWindow.detail.testGroup`);t.set(n,[...t.get(n)??[],e])});let n=[...e.values()].map(e=>e.link.handle);return{id:`tests`,label:p(`app.toolWindow.section.tests`),detail:String(e.size),icon:`codeTests`,actions:this.testLinks(n,p(`app.toolWindow.title.theProcessTests`)),children:[...t].map(([t,n])=>({id:`testClass:${t}`,label:t,detail:M(n.length,`test`),icon:`class`,actions:this.testLinks(n.flatMap(t=>e.get(t)?.link.handle??[]),t),children:n.flatMap(t=>{let n=e.get(t);if(!n)return[];let r=n.uses.map(e=>{let n=this.coverageOf(e.processId,e.model,t);return n===null?e.label:`${e.label} ${n}%`}).join(`, `);return[this.testNode(n.link,r)]})}))}}workers(){let e=/* @__PURE__ */ new Map;this.input.files.forEach(({path:t,model:n})=>n.workers.forEach(r=>{let i=`${r.kind}:${r.value}`,a=n.elements.find(e=>e.id===r.elementId),o=e.get(i)??{kind:r.kind,value:r.value,uses:[],paths:/* @__PURE__ */ new Set};o.paths.add(t),a&&o.uses.push({path:t,element:a}),e.set(i,o)}));let t=new Map([...e].map(([e,t])=>[e,this.links({kind:Be(t.kind),value:t.value})?.filter(e=>e.implements&&!e.test)])),n=[...t.values()].some(e=>(e?.length??0)>0),r=this.workerGroups([...e.values()]),i=this.input.workersOnEngine??null,a=(i?.checks??[]).flatMap(e=>e.check.problem?[`${e.where}: ${e.check.problem}`]:[]),o=new Set(r.map(e=>e.where));return{id:`workers`,label:p(`app.toolWindow.section.workers`),detail:N([String(e.size),i&&p(`app.toolWindow.detail.checkedAt`,{where:i.at})]),icon:`worker`,warning:a.length>0,tooltip:a.join(`
3
3
  `)||void 0,actions:r.length>0?[this.action(o.size===1?p(`app.toolWindow.action.checkWorkersOn`,{where:[...o][0]}):p(`app.toolWindow.action.checkWorkersOnEngines`),{type:`checkWorkers`,groups:r},`find`)]:[],children:[...e].map(([e,r])=>{let a=t.get(e),o=r.kind===`JAVA_CLASS`&&r.value.includes(`.`)?r.value.slice(0,r.value.lastIndexOf(`.`)):null,s={kind:Be(r.kind),value:r.value},c=n&&Ye(s)&&a!==void 0&&a.length===0,l=a&&a.length>0?{type:`openCode`,handles:a.map(e=>e.handle),title:p(`app.toolWindow.title.implementationsOf`,{name:r.value})}:null,u=(i?.checks??[]).flatMap(e=>{if(fr(e.engine)!==r.kind)return[];let t=e.check.statuses.get(r.value);return t?[{...t,where:e.where}]:[]}),d=u.filter(e=>e.waiting),f=u.length>1?u.map(e=>`${e.where}: ${e.text}`).join(`; `):u[0]?.text,m=c?p(`app.toolWindow.detail.nothingHandlesIt`):d.length>0?d.map(e=>p(`app.toolWindow.detail.onWhere`,{where:e.where,text:e.text})).join(`
4
4
  `):void 0;return{id:`worker:${e}`,label:o?r.value.slice(o.length+1):r.value,detail:N([gr(r.kind),o,M(r.uses.length,`task`),c&&p(`app.toolWindow.detail.noImplementation`),f]),icon:`worker`,warning:c||d.length>0,tooltip:m,open:l?this.open(l):void 0,actions:[...l?[this.action(p(`app.toolWindow.action.goToImplementation`),l,`implementation`,`GO_TO_IMPLEMENTATION`)]:[],...this.contractOf(r.value)?[this.action(p(`app.toolWindow.action.createElementTemplate`),{type:`workerTemplate`,value:r.value},`implementation`)]:[],...this.usages([s],r.value),this.copy(r.value)],children:[...(a??[]).map(t=>({id:`implementation:${e}:${t.label}`,label:t.label,detail:p(`app.toolWindow.detail.implementation`),icon:t.icon===`METHOD`?`method`:t.icon===`CLASS`?`class`:`file`,open:this.open({type:`openCode`,handles:[t.handle],title:t.label})})),...r.uses.map(e=>this.usageNode(e.path,e.element))]}})}}contractOf(e){return(this.input.contracts??[]).find(t=>t.value===e)??null}templatesNode(){let e=this.input.templates??[];if(e.length===0)return null;let t=e.filter(e=>e.drift!==null).length;return{id:`templates`,label:p(`app.toolWindow.section.templates`),detail:N([M(e.length,`template`),t>0&&p(`app.toolWindow.detail.outOfStep`,{number:t})]),icon:`form`,warning:t>0,tooltip:t>0?p(`app.toolWindow.tooltip.templatesOutOfStep`):void 0,children:e.map(({path:e,template:t,drift:n})=>{let r=this.contractOf(t.elementType?.[`zeebe:taskDefinition`]??t.elementType?.[`camunda:topic`]??``);return{id:`template:${e}`,label:at(t,e),detail:N([e.split(`/`).pop(),r&&`${r.file.split(`/`).pop()}:${r.line}`]),icon:`form`,warning:n!==null,tooltip:n?it(n):void 0,open:this.open({type:`reveal`,path:e}),actions:cr().map(([e,n])=>this.action(e,{type:`templateWorker`,id:t.id,language:n,target:`8.8`},`migration`))}})}}connectionsNode(){let e=this.input.connections;if(!e||e.rows.length===0&&e.sources.length===0&&e.findings.length===0)return null;let t=e.rows.filter(e=>e.status===`undefined`).length,n=this.input.root.replace(/[\\/]+$/,``);return{id:`connections`,label:p(`app.toolWindow.section.connections`),detail:t>0?p(`app.toolWindow.detail.connectionsUndefined`,{number:t}):p(`app.toolWindow.detail.connectionsOk`),tooltip:p(`app.toolWindow.tooltip.connections`),icon:`form`,warning:e.findings.length>0,actions:this.input.connectionsScreen?[this.action(p(`app.toolWindow.action.openConnections`),{type:`openConnections`},`find`)]:[],children:e.findings.map((e,t)=>({id:`connection:${t}:${e.file}:${e.line}`,label:Qe(e),detail:N([e.file.split(`/`).pop(),e.line>0?String(e.line):null]),icon:`task`,warning:!0,open:this.open({type:`reveal`,path:`${n}/${e.file}`,...e.elementId?{elementId:e.elementId}:{}}),actions:[this.copy(e.name)]}))}}variables(){let e=this.input.targets.filter(e=>e.kind===`VARIABLE`);if(e.length===0)return null;let t=/* @__PURE__ */ new Map;e.forEach(e=>t.set(e.value,[...t.get(e.value)??[],e]));let n=new Set(e.filter(e=>e.writes).map(e=>e.value)),r=this.input.code?.precise===!0,i=[...t.keys()].sort();return{id:`variables`,label:p(`app.toolWindow.section.variables`),detail:String(i.length),icon:`variable`,children:i.map(e=>{let i=t.get(e)??[],a=r?this.links({kind:`VARIABLE`,value:e}):void 0,o=n.has(e)||(a??[]).some(e=>e.implements),s=i.some(e=>!e.writes),c=!o&&s?tr(e,[...n]):null,l=e=>new Set(i.filter(t=>t.writes===e).map(e=>e.elementId)).size;return{id:`variable:${e}`,label:e,detail:N([l(!0)>0&&p(`app.toolWindow.detail.setBy`,{number:l(!0)}),l(!1)>0&&p(`app.toolWindow.detail.readBy`,{number:l(!1)}),a!==void 0&&a.length>0&&p(`app.toolWindow.detail.inCode`,{number:a.length}),!o&&s&&a!==void 0&&!c&&p(`app.toolWindow.detail.neverSet`),c&&p(`app.toolWindow.detail.setAs`,{name:c})]),icon:`variable`,warning:!!c,tooltip:c?p(`app.toolWindow.tooltip.variableTypo`,{name:e,typo:c}):void 0,actions:[...this.usages([{kind:`VARIABLE`,value:e}],e),this.copy(e)],children:[...i.map(t=>({id:`variableUse:${e}:${t.path}#${t.elementId}:${t.writes}:${t.where}`,label:t.label,detail:N([t.writes?p(`app.toolWindow.detail.sets`):p(`app.toolWindow.detail.reads`),t.where,y(t.path)]),icon:mr(t.elementType),open:this.open({type:`reveal`,path:t.path,elementId:t.elementId})})),...(a??[]).map(t=>({id:`variableCode:${e}:${t.handle}`,label:t.label,detail:t.test?p(`app.toolWindow.detail.test`):t.implements?p(`app.toolWindow.detail.setsInCode`):p(`app.toolWindow.detail.readsInCode`),icon:t.icon===`METHOD`?`method`:t.icon===`CLASS`?`class`:`file`,open:this.open({type:`openCode`,handles:[t.handle],title:t.label})}))]}})}}messages(){let e=this.input.files.flatMap(({path:e,model:t})=>t.messageUses.flatMap(n=>{let r=t.messages.find(e=>e.id===n.messageId),i=t.elements.find(e=>e.id===n.elementId);return r&&i?[{name:r.label,path:e,element:i,catches:n.catches}]:[]})),t=[...new Set(this.input.files.flatMap(({model:e})=>e.messages.map(e=>e.label)))];return{id:`messages`,label:p(`app.toolWindow.section.messages`),detail:String(t.length),icon:`message`,children:t.map(t=>{let n=e.filter(e=>e.name===t),r=n.filter(e=>e.catches).length;return{id:`message:${t}`,label:t,detail:p(`app.toolWindow.detail.caughtThrown`,{caught:r,thrown:n.length-r}),icon:`message`,actions:[...this.usages([{kind:`MESSAGE`,value:t}],t),this.copy(t)],children:n.map(e=>this.usageNode(e.path,e.element,e.catches?p(`app.toolWindow.detail.catches`):p(`app.toolWindow.detail.throws`)))}})}}errors(){let e=this.input.files.flatMap(({path:e,model:t})=>t.errors.flatMap(n=>{let r=t.elements.find(e=>e.id===n.elementId);return r&&n.code?[{code:n.code,path:e,element:r,catches:n.catches}]:[]})),t=[...new Set(e.map(e=>e.code))].sort();if(t.length===0)return null;let n=this.input.files.some(({model:e})=>e.errors.some(e=>e.catches&&!e.code)),r=new Map(t.map(e=>[e,(this.links({kind:`ERROR`,value:e})??[]).filter(e=>e.implements)])),i=this.input.code?.precise===!0&&[...r.values()].some(e=>e.length>0);return{id:`errors`,label:p(`app.toolWindow.section.errors`),detail:String(t.length),icon:`error`,children:t.map(t=>{let a=e.filter(e=>e.code===t),o=a.filter(e=>e.catches).length,s=r.get(t)??[],c=!n&&o===0&&s.length>0,l=i&&o>0&&s.length===0&&a.every(e=>e.catches),u=c?p(`app.toolWindow.tooltip.errorUncaught`):l?p(`app.toolWindow.tooltip.errorNeverThrown`):void 0;return{id:`error:${t}`,label:t,detail:N([p(`app.toolWindow.detail.caught`,{number:o}),p(`app.toolWindow.detail.thrown`,{number:a.length-o+s.length}),c&&p(`app.toolWindow.detail.notCaught`),l&&p(`app.toolWindow.detail.neverThrown`)]),icon:`error`,warning:!!u,tooltip:u,actions:[...this.usages([{kind:`ERROR`,value:t}],t),this.copy(t)],children:[...s.map(e=>({id:`thrower:${t}:${e.handle}`,label:e.label,detail:p(`app.toolWindow.detail.throws`),icon:e.icon===`METHOD`?`method`:e.icon===`CLASS`?`class`:`file`,open:this.open({type:`openCode`,handles:[e.handle],title:e.label})})),...a.map(e=>this.usageNode(e.path,e.element,e.catches?p(`app.toolWindow.detail.catches`):p(`app.toolWindow.detail.throws`)))]}})}}decisions(){let e=this.input.files.flatMap(({path:e,model:t})=>t.decisions.map(t=>({path:e,decision:t}))),t=this.input.files.flatMap(({path:e,model:t})=>t.decisionUses.flatMap(n=>{let r=t.elements.find(e=>e.id===n.elementId);return r?[{path:e,element:r,decisionId:n.decisionId}]:[]})),n=new Set(e.map(e=>e.decision.id)),r=[...new Set(t.map(e=>e.decisionId).filter(e=>!n.has(e)))];return{id:`decisions`,label:p(`app.toolWindow.section.decisions`),detail:String(e.length),icon:`decision`,children:[...e.map(({path:e,decision:n})=>({id:`decision:${e}#${n.id}`,label:n.label,detail:n.id,icon:`decision`,open:this.open({type:`reveal`,path:e}),actions:[...this.usages([{kind:`DECISION`,value:n.id}],n.label),this.copy(n.id)],children:t.filter(e=>e.decisionId===n.id).map(e=>this.usageNode(e.path,e.element))})),...r.map(e=>({id:`decisionMissing:${e}`,label:e,detail:p(`app.toolWindow.detail.notInProject`),icon:`decision`,warning:!0,actions:[this.copy(e)],children:t.filter(t=>t.decisionId===e).map(e=>this.usageNode(e.path,e.element))}))]}}forms(){let e=this.input.files.filter(({path:e})=>e.toLowerCase().endsWith(`.form`)),t=this.input.files.flatMap(({path:e,model:t})=>t.formUses.flatMap(n=>{let r=t.elements.find(e=>e.id===n.elementId);return r?[{path:e,element:r,formId:n.formId,linked:n.linked}]:[]})),n=new Set(e.map(e=>e.model.formId).filter(e=>!!e)),r=[...new Set(t.filter(e=>e.linked&&!n.has(e.formId)).map(e=>e.formId))];return{id:`forms`,label:p(`app.toolWindow.section.forms`),detail:String(e.length),icon:`form`,children:[...e.map(({path:e,model:n})=>({id:`form:${e}`,label:y(e),detail:n.formId&&n.formId!==qe(e)?n.formId:void 0,icon:`form`,open:this.open({type:`reveal`,path:e}),actions:n.formId?[this.copy(n.formId)]:[],children:t.filter(e=>e.formId===n.formId).map(e=>this.usageNode(e.path,e.element))})),...r.map(e=>({id:`formMissing:${e}`,label:e,detail:p(`app.toolWindow.detail.notInProject`),icon:`form`,warning:!0,actions:[this.copy(e)],children:t.filter(t=>t.formId===e).map(e=>this.usageNode(e.path,e.element))}))]}}workerGroups(e){let t=/* @__PURE__ */ new Map;return e.forEach(e=>e.paths.forEach(n=>{let r=this.input.fileTargets?.get(n);if(!r?.ready||fr(r.engine)!==e.kind)return;let i=JSON.stringify([r.profile,r.engine,r.url]),a=t.get(i)??{profile:r.profile,resource:n,engine:r.engine,where:r.profile??r.url??p(`app.toolWindow.detail.theEngine`),jobTypes:[]};a.jobTypes.includes(e.value)||a.jobTypes.push(e.value),t.set(i,a)})),[...t.values()]}deployment(){let e=this.input.deploy?.targets??[],t=this.input.files.map(e=>e.path);return{id:`deployment`,label:p(`app.toolWindow.section.deployment`),detail:String(e.length),icon:`deploy`,children:e.map((e,n)=>({id:`profile:${e.profile??``}:${n}`,label:e.profile??p(`app.toolWindow.detail.defaultProfile`),detail:N([e.profile===this.input.deploy?.active&&p(`app.toolWindow.detail.inForce`),e.url??p(`app.toolWindow.detail.noAddress`),e.lastDeploy&&p(`app.toolWindow.detail.lastDeploy`,{when:e.lastDeploy})]),icon:`deploy`,warning:!e.ready,actions:[this.deploy(t,e.profile??void 0,!0)]}))}}fileLeaf(e,t,n){let r=xr(this.input.root,e.path);return{id:`file:${e.path}`,label:y(e.path),detail:N([n.detail,t&&r]),icon:hr(e.path),path:e.path,open:this.open({type:`reveal`,path:e.path}),actions:[this.deploy([e.path]),...n.actions??[]],children:n.children}}fileTree(e){if(!this.input.preferences.tree)return this.input.files.map(t=>this.fileLeaf(t,!0,e(t)));let t={name:``,path:``,folders:/* @__PURE__ */ new Map,files:[]};this.input.files.forEach(n=>{let r=He(this.input.root,n.path).split(`/`).slice(0,-1),i=t;r.forEach(e=>{let t=i.folders.get(e)??{name:e,path:`${i.path}/${e}`,folders:/* @__PURE__ */ new Map,files:[]};i.folders.set(e,t),i=t}),i.files.push(this.fileLeaf(n,!1,e(n)))});let n=e=>{let t=e,r=e.name;for(;t.files.length===0&&t.folders.size===1;)t=[...t.folders.values()][0],r=`${r}/${t.name}`;return{id:`folder:${t.path}`,label:r,icon:`folder`,path:`${this.input.root}${t.path}`,expand:`SINGLE_CHILD`,children:[...[...t.folders.values()].map(n),...t.files]}};return[...[...t.folders.values()].map(n),...t.files]}files(){return{id:`files`,label:p(`app.toolWindow.section.files`),detail:String(this.input.files.length),icon:`folder`,children:this.fileTree(()=>({children:[]}))}}summary(e,t,n){let r=[...t.workers.filter(e=>e.elementId===n.id).map(e=>`${gr(e.kind)} ${e.value}`),...t.calls.filter(e=>e.elementId===n.id).map(e=>p(`app.toolWindow.detail.calls`,{name:e.calledProcessId})),...t.messageUses.filter(e=>e.elementId===n.id).map(e=>{let n=t.messages.find(t=>t.id===e.messageId)?.label??e.messageId;return e.catches?p(`app.toolWindow.detail.catchesName`,{name:n}):p(`app.toolWindow.detail.throwsName`,{name:n})}),...t.decisionUses.filter(e=>e.elementId===n.id).map(e=>p(`app.toolWindow.detail.decision`,{id:e.decisionId})),...t.formUses.filter(e=>e.elementId===n.id).map(e=>p(`app.toolWindow.detail.form`,{id:e.formId}))];return r.length===0?null:{...this.usageNode(e,n),id:`summary:${e}#${n.id}`,detail:r.join(` · `)}}byFile(){return this.fileTree(e=>{let{path:t,model:n}=e;if(t.toLowerCase().endsWith(`.dmn`))return{children:n.decisions.map(e=>({id:`fileDecision:${t}#${e.id}`,label:e.label,detail:e.id,icon:`decision`,open:this.open({type:`reveal`,path:t}),actions:[this.copy(e.id)]}))};let r=r=>n.elements.filter(e=>e.processId===r).map(e=>this.summary(t,n,e)).filter(e=>e!==null).concat(this.scriptsOf(e,r)),[i,...a]=n.processes;return i&&a.length===0?{children:r(i.id),detail:N([i.label,i.id!==i.label&&i.id]),actions:[this.copy(i.id)]}:{children:n.processes.map(e=>({id:`fileProcess:${t}#${e.id}`,label:e.label,detail:e.id===e.label?void 0:e.id,icon:`process`,open:this.open({type:`reveal`,path:t}),actions:[this.copy(e.id)],children:r(e.id)}))}})}examples(){return this.input.files.length>0?null:{id:`examples`,label:p(`app.toolWindow.section.examples`),detail:p(`app.toolWindow.examples.detail`),icon:`process`,expand:`ALWAYS`,children:rt.map(e=>{let t={type:`createExample`,example:e},n=dr(e);return{id:`example:${e}`,label:n.label,detail:n.detail,icon:`process`,open:this.open(t),actions:[this.action(p(`app.toolWindow.action.createExample`),t,`file`)]}})}}codeLinks(){return this.input.codeLinks===`locked`?{id:`code-links`,label:p(`app.toolWindow.section.code`),detail:p(`app.toolWindow.codeLinks.detail`),tooltip:p(`app.toolWindow.codeLinks.tooltip`),icon:`worker`,actions:[this.action(p(`app.toolWindow.action.buyOrSignIn`),{type:`unlockCode`},`find`)]}:null}migrationFile(e,t){let n=e.findings.filter(e=>e.severity!==`info`);return{id:`migration:file:${e.path}`,label:y(e.path),detail:N([t,br(e.status),N([e.counts.manual>0&&p(`app.toolWindow.detail.toDo`,{number:e.counts.manual}),e.counts.review>0&&p(`app.toolWindow.detail.toCheck`,{number:e.counts.review})])]),icon:hr(e.path),warning:e.status===`needs-work`||e.status===`blocked`,open:this.open({type:`reveal`,path:e.path}),actions:[this.action(p(`app.toolWindow.action.convertToCamunda8`),{type:`migrationConvert`,paths:[e.path]},`migration`)],children:n.map((t,n)=>({id:`migration:finding:${e.path}#${n}`,label:t.title,detail:N([t.where,t.conversion===`manual`?p(`app.toolWindow.detail.toDoOne`):t.conversion===`review`?p(`app.toolWindow.detail.toCheckOne`):p(`app.toolWindow.detail.converts`)]),tooltip:`${t.detail} ${t.action}`,icon:`task`,warning:t.conversion===`manual`,open:this.open({type:`reveal`,path:e.path,elementId:t.elements[0]}),actions:[this.copy(t.rule)]}))}}migrationCode(e){let t=lr();return{id:`migration:code:${e.key}`,label:e.kind===`class`?pr(e.value):e.value,detail:N([e.source?`${e.source.path.split(/[\\/]/).pop()}:${e.source.line}`:p(`app.toolWindow.detail.notInThisProject`),e.role!==`task`&&p(`app.toolWindow.detail.listener`,{event:e.event??``}).trim()]),tooltip:[p(`app.toolWindow.tooltip.becomes`,{what:e.becomes}),...e.notes].join(` `),icon:`worker`,warning:!e.source,...e.source?{open:this.open({type:`reveal`,path:e.source.path})}:{},actions:e.skeleton?t.map(([t,n])=>this.action(t,{type:`migrationWorker`,key:e.key,language:n},`migration`)):[]}}migrationLeads(){let e=this.input.migration;if(!e?.source)return!1;let t=new Set(e.files.map(e=>e.path));return this.input.files.every(e=>t.has(e.path))}migration(){let e=this.input.migration;if(!e?.source)return null;let t=e.totals,n=e.files.map(e=>y(e.path)),r=new Set(n.filter((e,t)=>n.indexOf(e)!==t));return{id:`migration`,label:p(`app.toolWindow.section.migration`),detail:N([M(e.files.length,`file`),t[`needs-work`]>0&&p(`app.toolWindow.detail.filesNeedingWork`,{number:t[`needs-work`]}),t.blocked>0&&p(`app.toolWindow.detail.filesBlocked`,{number:t.blocked})]),tooltip:p(`app.toolWindow.tooltip.migration`,{target:e.target}),icon:`migration`,expand:`ALWAYS`,actions:[...this.input.migrationScreen?[this.action(p(`app.toolWindow.action.openMigration`),{type:`openMigration`},`migration`)]:[],this.action(p(`app.toolWindow.action.migrationReport`),{type:`migrationReport`},`migration`),this.action(p(`app.toolWindow.action.convertAll`),{type:`migrationConvert`,paths:e.files.map(e=>e.path)},`migration`),this.action(p(`app.toolWindow.action.applyMigration`),{type:`migrationApply`,workers:`spring`},`migration`)],children:[...e.files.map(e=>this.migrationFile(e,r.has(y(e.path))?xr(this.input.root,e.path):void 0)),...e.code.length>0?[{id:`migration:code`,label:p(`app.toolWindow.section.code`),detail:String(e.code.length),icon:`worker`,children:e.code.map(e=>this.migrationCode(e))}]:[]]}}toolbar(){let e=this.input.files.flatMap(({model:e})=>e.processes.flatMap(e=>(this.links({kind:`PROCESS`,value:e.id})??[]).filter(e=>e.test).map(e=>e.handle)));return[...this.input.code?.precise&&e.length>0?[this.action(p(`app.toolWindow.action.runAllProcessTests`),{type:`runTests`,handles:[...new Set(e)],title:p(`app.toolWindow.title.theProcessTests`),debug:!1},`runAll`)]:[],this.action(p(`app.toolWindow.action.groupByFiles`),{type:`preference`,key:`toolWindowGroupByFiles`,value:!this.input.preferences.groupByFiles},`groupByFiles`,void 0,this.input.preferences.groupByFiles),this.action(p(`app.toolWindow.action.showFolders`),{type:`preference`,key:`toolWindowTree`,value:!this.input.preferences.tree},`folders`,void 0,this.input.preferences.tree)]}};function Cr(e){let t=new Sr(e),n=t.migrationLeads();return{roots:e.preferences.groupByFiles?[t.examples(),...n?[t.migration()]:[],...t.byFile(),t.connectionsNode(),t.deployment(),...n?[]:[t.migration()]].filter(e=>e!==null):[t.examples(),t.debugSection(),t.codeLinks(),...n?[t.migration()]:[],t.processes(),t.tests(),t.workers(),t.templatesNode(),t.connectionsNode(),t.variables(),t.messages(),t.errors(),t.decisions(),t.forms(),t.deployment(),t.files(),...n?[]:[t.migration()]].filter(e=>e!==null),toolbar:t.toolbar(),actions:t.actions}}function wr(e){let t=/* @__PURE__ */ new Map,n=e=>{e?.id&&(t.set(e.id,typeof e.name==`string`&&e.name.trim()?e.name.trim():e.id),(e.flowElements??[]).forEach(n))};return(e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`).forEach(e=>(e.flowElements??[]).forEach(n)),t}function Tr(e,t,n){return e.path===null?{label:t.get(e.elementId)??e.elementId,elementId:e.elementId,...n?{diagramPath:n}:{},...e.sample===null?{}:{sample:e.sample}}:{label:`${Xe(e.path)}:${e.line??0}`,elementId:e.elementId,path:e.path,...e.line===null?{}:{line:e.line},...e.offset===null?{}:{offset:e.offset}}}function Er(e,t,n,r){return{name:e.name,...e.type===null?{}:{type:e.type},declaredByScript:De(n,e.name),writers:e.writers.map(e=>Tr(e,t,r))}}function Dr(e,t,n){let r={variables:[...Oe(e.definitions).uses,...Ze(e.workers)]},i=Le(e.definitions).flows.get(t)?.target??t,a=_t({model:r,order:Pe(e.definitions),types:e.workers?.types??[],inputs:e.inputs},i,{wholeProcess:!0}),o=wr(e.definitions);return a.variables.map(t=>Er(t,o,n,e.diagramPath))}function Or(e){return[...[...e.jobTypes.keys()].map(e=>({kind:`JOB_TYPE`,value:e})),...[...e.topics.keys()].map(e=>({kind:`TOPIC`,value:e})),...[...e.classes.keys()].map(e=>({kind:`CLASS`,value:e})),...[...e.beans.keys()].map(e=>({kind:`BEAN`,value:e}))]}function kr(e){return[e.kind,e.value,e.file,e.line,e.diagram,e.element??``].join(`\0`)}const Ar={missing:3,ambiguous:2,bound:1,notApplicable:0},jr=/* @__PURE__ */ new WeakMap;function Mr(e){let t=jr.get(e);if(!t){let n=/* @__PURE__ */ new Map;e.classes.forEach((e,t)=>{let r=n.get(e.file);r?r.push({line:e.line,name:t}):n.set(e.file,[{line:e.line,name:t}])}),n.forEach(e=>e.sort((e,t)=>e.line-t.line)),t={byFile:n},jr.set(e,t)}return t}function Nr(e,t){let n=Mr(e).byFile.get(t.file);if(!n)return null;let r=null;for(let e of n){if(e.line>t.line)break;r=e.name}return r}function Pr(e){return e.slice(e.lastIndexOf(`.`)+1)}function Fr(e,t,n){switch(t){case`JOB_TYPE`:case`TOPIC`:case`CLASS`:case`BEAN`:return Je(e,{kind:t,value:n});case`MESSAGE`:return Ue(e,{kind:t,value:n});default:return[]}}function Ir(e){let t=/* @__PURE__ */ new Set;return e.filter(e=>{let n=`${e.file}#${e.line}`;return!t.has(n)&&(t.add(n),!0)})}function Lr(e,t){switch(t){case`JOB_TYPE`:return e.jobTypes.size>0;case`TOPIC`:return e.topics.size>0;case`CLASS`:return e.classes.size>0;case`BEAN`:return e.beans.size>0;default:return!0}}function Rr(e,t){let n=t===`JOB_TYPE`?e.jobTypes.keys():t===`TOPIC`?e.topics.keys():t===`CLASS`?e.classes.keys():t===`BEAN`?e.beans.keys():[],r=[];for(let e of n)if(r.push(e),r.length>=2e4)break;return r}var zr=class{index;lists=/* @__PURE__ */ new Map;bySimple=/* @__PURE__ */ new Map;answers=/* @__PURE__ */ new Map;constructor(e){this.index=e}of(e,t){let n=`${e}\u0000${t}`;if(this.answers.has(n))return this.answers.get(n)??null;if(this.answers.size>=150)return null;let r=this.lists.get(e);r||(r=Rr(this.index,e),this.lists.set(e,r),e===`CLASS`&&r.forEach(e=>{let t=Pr(e);this.bySimple.has(t)||this.bySimple.set(t,e)}));let i=null;if(e===`CLASS`){let e=this.bySimple.get(Pr(t));i=e&&e!==t?e:tr(t,r)}else i=tr(t,r);return this.answers.set(n,i),i}};function Br(e,t,n,r){return r.map(r=>({kind:n.kind,value:n.value,file:r.file,line:r.line,symbol:n.kind===`CLASS`?n.value:Nr(e.index,r),diagram:e.diagram,element:t.elementId}))}function Vr(e,t,n,r){if(!r)return{...n,state:`notApplicable`,reason:`noAssets`,anchors:[],tests:[],near:null};let i=r.get(n.value);if(!i)return{...n,state:`missing`,reason:null,anchors:[],tests:[],near:tr(n.value,r.keys())};let a={kind:n.kind,value:n.value,file:i,line:1,symbol:n.value,diagram:e.diagram,element:t.elementId};return{...n,state:`bound`,reason:null,anchors:[a],tests:[],near:null}}function Hr(e,t,n,r){let i=e=>({...r,state:`notApplicable`,reason:e,anchors:[],tests:[],near:null});if(r.kind===`PROCESS`)return Vr(e,n,r,e.processes);if(r.kind===`DECISION`)return Vr(e,n,r,e.decisions);if(r.value.trim()===``)return i(`unnamed`);if(r.kind===`JOB_TYPE`&&Ke({kind:`JOB_TYPE`,value:r.value}))return i(`connector`);let a=Ir(Fr(e.index,r.kind,r.value)),o=a.filter(e=>!dt(e.file)),s=a.filter(e=>dt(e.file)),c=Br(e,n,r,o),l=Br(e,n,r,s);return r.kind===`MESSAGE`?o.length>0?{...r,state:`bound`,reason:null,anchors:c,tests:l,near:null}:{...i(`external`),tests:l}:o.length===1?{...r,state:`bound`,reason:null,anchors:c,tests:l,near:null}:o.length>1?{...r,state:`ambiguous`,reason:null,anchors:c,tests:l,near:null}:Lr(e.index,r.kind)?{...r,state:`missing`,reason:null,anchors:[],tests:l,near:t.of(r.kind,r.value)}:{...i(`noCode`),tests:l}}function Ur(e,t){let n=`notApplicable`,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map;for(let e of t)Ar[e.state]>Ar[n]&&(n=e.state),e.anchors.forEach(e=>r.set(kr(e),e)),e.tests.forEach(e=>i.set(kr(e),e));return{elementId:e.elementId,elementType:e.elementType,label:e.label,state:n,reason:n===`notApplicable`?t[0]?.reason??`unnamed`:null,bindings:t,anchors:[...r.values()],tests:[...i.values()],reached:null,paused:!1}}function Wr(e,t){let n=new zr(e.index);return t.map(t=>Ur(t,t.bindings.map(r=>Hr(e,n,t,r))))}function Gr(e,t,n){let r=Number.isNaN(n.getTime())?/* @__PURE__ */ new Date:n;if(e===`CAMUNDA_8`){let e={filter:{from:(/* @__PURE__ */ new Date(r.getTime()-864e5)).toISOString(),to:r.toISOString(),jobType:{$in:t}},page:{limit:Math.max(t.length,1)}};return[{method:`POST`,path:`/jobs/statistics/by-types`,body:JSON.stringify(e)}]}return[{method:`GET`,path:`/external-task/topic-names?withUnlockedTasks=true`},{method:`GET`,path:`/external-task/topic-names?withLockedTasks=true`}]}function Kr(e){try{return JSON.parse(e?.body??``)}catch{return null}}function qr(e,t){let n=t.find(e=>!(e.status>=200&&e.status<300));return n?e===`CAMUNDA_8`&&n.status===404?p(`app.rules.workers.noJobStatistics`):n.status===401||n.status===403?p(`app.rules.workers.refusedTheQuestion`,{status:n.status}):p(`app.rules.workers.engineAnswered`,{status:n.status}):null}function Jr(e,t,n){let r=qr(e,n),i=/* @__PURE__ */ new Map;if(r)return{statuses:i,problem:r};if(e===`CAMUNDA_8`){let e=Kr(n[0])?.items,r=(Array.isArray(e)?e:[]).filter(e=>typeof e==`object`&&!!e),a=e=>typeof e==`number`&&Number.isFinite(e)?e:0;return t.forEach(e=>{let t=r.find(t=>t.jobType===e),n=a(t?.workers),o=a(t?.created?.count),s=p(`app.rules.workers.workerCount`,{count:n}),c=p(`app.rules.workers.jobCount`,{count:o});i.set(e,n>0?{waiting:!1,text:p(`app.rules.workers.tookItsJobs`,{workers:s})}:o>0?{waiting:!0,text:p(`app.rules.workers.nobodyTookThem`,{jobs:c})}:{waiting:!1,text:p(`app.rules.workers.noJobs`)})}),{statuses:i,problem:null}}let a=e=>{let t=Kr(e);return new Set((Array.isArray(t)?t:[]).filter(e=>typeof e==`string`))},o=a(n[0]),s=a(n[1]);return t.forEach(e=>{i.set(e,s.has(e)?{waiting:!1,text:p(`app.rules.workers.aWorkerIsWorking`)}:o.has(e)?{waiting:!0,text:p(`app.rules.workers.tasksWait`)}:{waiting:!1,text:p(`app.rules.workers.noOpenTasks`)})}),{statuses:i,problem:null}}const Yr=/^[\w][\w.-]{0,63}$/;function Xr(e,t){return Yr.test(t)?x.join(e,`agents`,t,`options.json`):null}function Zr(e,n,r,i=/* @__PURE__ */ new Date){let a=Xr(e,n);if(a!==null&&r.length!==0)try{let e={readAt:i.toISOString(),options:r.map(({legacy:e,...t})=>t)};t(a,`${JSON.stringify(e,null,2)}\n`)}catch{}}function Qr(e,t){let n=Xr(e,t);if(n===null)return null;try{let e=JSON.parse(w(n,`utf8`)),t=pe(e.options);return typeof e.readAt!=`string`||t.length===0?null:{readAt:e.readAt,options:t}}catch{return null}}var $r=class extends Error{},ei=class extends Error{},ti=class extends Error{how;tail;constructor(e,t){super(e),this.how=e,this.tail=t}};const ni=/* @__PURE__ */ new Set;let ri=!1;function ii(){ri||(ri=!0,process.once(`exit`,()=>{for(let e of ni)e.pid!==void 0&&Ce(e.pid,`SIGKILL`)}))}function P(e,t){return e.catch(()=>void 0),new Promise((n,r)=>{let i=setTimeout(()=>r(new $r),t);e.then(n,r).finally(()=>clearTimeout(i))})}function ai(e){let t=e.split(`
@@ -15,5 +15,5 @@ import{n as e}from"./chunk-version-CdS8_QQd.js";import{t}from"./chunk-atomicWrit
15
15
  \r
16
16
  `);var Hc=class{held=Buffer.alloc(0);onMessage;onBroken;constructor(e,t){this.onMessage=e,this.onBroken=t}push(e){for(this.held=this.held.length===0?e:Buffer.concat([this.held,e]);;){let e=this.held.indexOf(Vc);if(e<0){this.held.length>8192&&this.broken();return}let t=/^content-length:\s*(\d+)\s*$/im.exec(this.held.subarray(0,e).toString(`latin1`)),n=t?Number(t[1]):-1;if(n<0||n>67108864)return this.broken();let r=e+Vc.length;if(this.held.length<r+n)return;let i=this.held.subarray(r,r+n).toString(`utf8`);this.held=this.held.subarray(r+n);try{this.onMessage(JSON.parse(i))}catch{continue}}}broken(){this.held=Buffer.alloc(0),this.onBroken()}};function Uc(e){let t=Buffer.from(JSON.stringify(e),`utf8`);return Buffer.concat([Buffer.from(`Content-Length: ${t.length}\r\n\r\n`,`ascii`),t])}function Wc(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return t.jsonrpc===`2.0`&&(typeof t.method==`string`||`id`in t)}var Gc=class{running=/* @__PURE__ */ new Map;folder;home;env;events;closed=!1;constructor(e,t,n,r){this.folder=e,this.home=t,this.env=n,this.events=r}get count(){return this.running.size}send(e,t,n){if(this.closed)throw B(409,`app.cli.web.reason.noProject`);if(!Ic(t))throw B(400,`app.cli.web.reason.wrongField`,{field:`serverName`});if(!Wc(n))throw B(400,`app.cli.web.reason.wrongField`,{field:`message`});let r=`${e}\u0000${t}`;(this.running.get(r)??this.start(r,e,t)).child.stdin?.write(Uc(n))}forget(e){for(let[t,n]of[...this.running])t.startsWith(`${e}\u0000`)&&this.stop(t,n)}close(){this.closed=!0;for(let[e,t]of[...this.running])this.stop(e,t)}start(e,t,n){let r=Lc(this.home).find(e=>e.id===n);if(!r)throw B(404,`app.cli.web.reason.noLanguageServer`,{server:n});let i={...this.env,...r.env},a=zc(r.command,i);if(!a)throw B(404,`app.cli.web.reason.languageServerMissing`,{command:r.command});if(this.running.size>=6)throw B(409,`app.cli.web.reason.tooManyLanguageServers`,{limit:6});let o;try{o=ue({command:a,args:r.args})}catch{throw B(404,`app.cli.web.reason.languageServerUnsafe`,{command:r.command})}let s=fn(o.command,o.args,{cwd:this.folder,env:i,stdio:[`pipe`,`pipe`,`pipe`],windowsVerbatimArguments:o.verbatim,windowsHide:!0}),c={child:s,spec:r};this.running.set(e,c);let l=new Hc(e=>this.events.publishTo(t,{serverName:n,message:e}),()=>this.stop(e,c));return s.stdout?.on(`data`,e=>l.push(e)),s.stderr?.resume(),s.stdin?.on(`error`,()=>void 0),s.on(`error`,()=>this.drop(e,c)),s.on(`exit`,()=>this.drop(e,c)),c}drop(e,t){this.running.get(e)===t&&this.running.delete(e)}stop(e,t){this.drop(e,t);let{child:n}=t;n.exitCode!==null||n.killed||(n.stdin?.end(),n.kill(),setTimeout(()=>{n.exitCode===null&&n.kill(Qt.signals.SIGKILL)},2e3).unref())}};const Kc={depth:24,visited:25e4,diagrams:2e4},qc=/\.(bpmn|bpmn\.xml|bpmn20\.xml|dmn|form|cmmn|cmmn11\.xml)$/i,Jc=[[`target`,`process-test-coverage`],[`build`,`process-test-coverage`]];async function Yc(e){let t=[];for(let n=0;n<e.length;n+=64){let r=await Promise.all(e.slice(n,n+64).map(async e=>{try{let t=await j(e);return t.isFile()?{path:e,stamp:Math.floor(t.mtimeMs),size:t.size}:null}catch{return null}}));for(let e of r)e&&t.push(e)}return t.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path))}function Xc(e,t){return x.relative(e,x.dirname(t)).split(x.sep).includes(`element-templates`)}async function Zc(e){let t=[],n=async(e,r)=>{let i;try{i=await k(e,{withFileTypes:!0})}catch{return}for(let a of i){if(a.name.startsWith(`.`)||b.has(a.name)||a.isSymbolicLink())continue;let i=x.join(e,a.name);a.isDirectory()?r>0&&await n(i,r-1):a.name===`report.json`&&t.push(i)}};return await n(e,4),t}async function Qc(e,t=Kc){let n=[],r=[],i=[],a=[],o=[],s=0,c=[{directory:e,depth:0}];for(;c.length>0&&s<t.visited;){let{directory:l,depth:u}=c.pop(),d;try{d=await k(l,{withFileTypes:!0})}catch{continue}let f=x.basename(l);for(let p of d){if(s>=t.visited)break;if(s+=1,p.isSymbolicLink())continue;let d=p.name,m=x.join(l,d);if(p.isDirectory()){if(b.has(d)||d.startsWith(`.`)&&d!==`.camunda`||u>=t.depth)continue;!d.startsWith(`.`)&&o.length<2e4&&o.push(x.relative(e,m).split(x.sep).join(`/`)),c.push({directory:m,depth:u+1})}else p.isFile()&&(qc.test(d)?n.length<t.diagrams&&n.push(m):/\.json$/i.test(d)?f===`test-cases`?r.push(m):Xc(e,m)&&i.push(m):a.length<t.diagrams&&Lt(x.relative(e,m))&&a.push(m))}}let l=(await Promise.all(Jc.map(t=>Zc(x.join(e,...t))))).flat(),[u,d,f,p,m]=await Promise.all([Yc(n),Yc(r),Yc(i),Yc(l),Yc(a)]),h=e=>e.map(({path:e,stamp:t})=>({path:e,stamp:t}));return o.sort(),{root:e,files:h(u),reports:h(p),testCases:h(d),templates:h(f),connections:h(m),folders:o}}function $c(e){return[...[e.files,e.reports,e.testCases,e.templates,e.connections].map(e=>e.map(e=>`${e.path}:${e.stamp}`).join(`
17
17
  `)),e.folders.join(`
18
- `)].join(`\0`)}function el(e,t){return $c(e)===$c(t)}var tl=class{root;limits;cached=null;cachedGeneration=-1;generation=0;building=null;scans=0;constructor(e,t=Kc){this.root=e,this.limits=t}peek(){return this.cached}invalidate(){this.generation+=1}async listing(){for(;;){if(this.cached&&this.cachedGeneration===this.generation)return this.cached;if(!this.building){let e=this.generation;this.scans+=1,this.building=Qc(this.root,this.limits).then(t=>(this.cached=t,this.cachedGeneration=e,t)).finally(()=>{this.building=null})}await this.building}}},nl=class{runs=/* @__PURE__ */ new Map;start(e){let t=hn(),n=new AbortController,r={abort:n,status:`running`};return this.runs.set(t,r),e(n.signal).catch(e=>({ok:!1,lines:[e instanceof Error?e.message:String(e)]})).then(e=>{r.status===`running`&&(r.status=`finished`),r.result=e}),t}active(){let e=0;for(let t of this.runs.values())t.status===`running`&&(e+=1);return e}state(e){let t=this.runs.get(e);if(t)return(t.status===`finished`||t.status===`cancelled`&&t.result)&&this.runs.delete(e),{run:e,status:t.status,ok:t.status===`finished`&&(t.result?.ok??!1),lines:t.result?.lines??[]}}cancel(e){let t=this.runs.get(e);t?.status===`running`&&(t.status=`cancelled`,t.abort.abort())}};const rl=/* @__PURE__ */ new Set([`.camunda`]),il=/(~|\.(tmp|swp|swx|bak|lock|crdownload|part))$|^\.#|^\.DS_Store$|^4913$/i;function al(e){let t=e.split(/[\\/]/).filter(e=>e!==``);return il.test(t[t.length-1]??``)?!0:t.slice(0,-1).some(e=>b.has(e)||e.startsWith(`.`)&&!rl.has(e))}var ol=class{root;onBatch;debounceMs;maxWaitMs;firstRetryMs;maxRetryMs;pollMs;open;pending=/* @__PURE__ */ new Set;watcher=null;quiet=null;deadline=null;retry=null;poll=null;retryMs;closed=!1;constructor(e,t,n={}){this.root=e,this.onBatch=t,this.debounceMs=n.debounceMs??80,this.maxWaitMs=n.maxWaitMs??600,this.firstRetryMs=n.retryMs??250,this.maxRetryMs=n.maxRetryMs??5e3,this.pollMs=n.pollMs??3e3,this.retryMs=this.firstRetryMs,this.open=n.open??((e,t)=>ln(e,{recursive:!0,persistent:!1},t))}get active(){return this.watcher!==null||this.poll!==null}start(){this.attach(!1)}close(){this.closed=!0,this.detach();for(let e of[this.quiet,this.deadline,this.retry,this.poll])e&&clearTimeout(e);this.quiet=this.deadline=this.retry=this.poll=null,this.pending.clear()}attach(e){if(!(this.closed||this.watcher||this.poll)){if(!C(this.root))return this.later();try{this.watcher=this.open(this.root,(e,t)=>this.heard(t))}catch(e){return e?.code===`ERR_FEATURE_UNAVAILABLE_ON_PLATFORM`?this.polling():this.later()}this.watcher.on(`error`,()=>{this.detach(),this.heard(null),this.later()}),this.retryMs=this.firstRetryMs,e&&this.heard(null)}}polling(){this.poll=setInterval(()=>this.heard(null),this.pollMs),this.poll.unref()}detach(){let e=this.watcher;if(this.watcher=null,e){e.removeAllListeners(),e.on(`error`,()=>void 0);try{e.close()}catch{}}}later(){this.closed||this.retry||(this.retry=setTimeout(()=>{this.retry=null,this.attach(!0)},this.retryMs),this.retry.unref(),this.retryMs=Math.min(this.retryMs*2,this.maxRetryMs))}heard(e){if(this.closed)return;let t=e===null?`*`:e.toString();t!==`*`&&al(t)||(this.pending.add(t===``?`*`:t),this.quiet&&clearTimeout(this.quiet),this.quiet=setTimeout(()=>this.flush(),this.debounceMs),this.quiet.unref(),this.deadline||(this.deadline=setTimeout(()=>this.flush(),this.maxWaitMs),this.deadline.unref()))}flush(){if(this.quiet&&clearTimeout(this.quiet),this.deadline&&clearTimeout(this.deadline),this.quiet=this.deadline=null,this.closed||this.pending.size===0)return;let e=[...this.pending];this.pending.clear(),this.watcher&&!C(this.root)&&(this.detach(),this.later());try{this.onBatch(e.map(e=>e===`*`?e:x.join(this.root,e)))}catch{}}};const sl={password:`PENSTOCK_PASSWORD`,clientSecret:`PENSTOCK_CLIENT_SECRET`};function cl(e){let t=/* @__PURE__ */ new Map,n=(e,t)=>`${e??``}\u0000${t}`;return{async get(r,i){return t.get(n(r,i))??(e[sl[i]]||void 0)},async set(e,r,i){i?t.set(n(e,r),i):t.delete(n(e,r))}}}const ll=/^penstock(\.local)?\.(ya?ml|json)$/i;function ul(e){let t=e.env??process.env;return{env:t,home:e.home??te(t),fetch:e.fetch??fetch,openLink:e.openLink??(()=>void 0),say:e.say??(()=>void 0),events:new Ri(e.events),limits:e.limits??Kc,sourceLimits:e.sourceLimits,watcher:e.watcher,agent:e.agent??{}}}function dl(e,t){let n=new Ii(e),r=new tl(n.root,t.limits),i=new Ec(n.root,t.env),a=new Nc(n.root,t.sourceLimits),o=t.events,s=new Gc(n.root,t.home,t.env,o),c=o.onForget(e=>s.forget(e)),l=!1,u={id:mn(6).toString(`hex`),open:!0,folder:n.root,confine:n,project:r,configs:i,code:a,servers:s,events:o,env:t.env,home:t.home,secrets:cl(t.env),history:new lo,hooks:new nl,agent:new ye(n.root,t.agent.spawn??(e=>fl(e,t.env)),{home:t.home,env:t.env}),fetch:t.fetch,openLink:t.openLink,say:t.say,async changed(e){if(l)return;let t=r.peek(),n=e.includes(`*`),s=n||e.some(e=>ll.test(x.basename(e))),c=e.some(e=>e!==`*`&&Ge.test(e)),u=n||e.some(e=>/\.(bpmn|bpmn\.xml|bpmn20\.xml|dmn|form)$/i.test(e));r.invalidate(),s&&i.invalidate(),(n||c||u)&&a.invalidate();let d=await r.listing().catch(()=>null);l||(!s&&t&&d&&el(t,d)||o.publish({type:`projectChanged`}),c&&o.publish({type:`codeChanged`}))},close(){l=!0,u.agent.close(),c(),s.close(),d.close()}},d=new ol(n.root,e=>void u.changed(e).catch(()=>void 0),t.watcher);return d.start(),u}function fl(t,n){let r=Se();if(!r)throw new ve(500,p(`app.agent.notFound`));return nt({explicit:et(n),own:r,version:e()},[`agent`,`serve`,`--project`,t]).map(({command:e,args:t,env:n})=>({command:e,args:t,env:n}))}function $(){throw B(409,`app.cli.web.reason.noProject`)}function pl(e){return{id:`closed`,open:!1,folder:``,get confine(){return $()},get project(){return $()},get configs(){return $()},get code(){return $()},get servers(){return $()},get secrets(){return $()},get history(){return $()},get hooks(){return $()},get agent(){return $()},events:e.events,env:e.env,home:e.home,fetch:e.fetch,openLink:e.openLink,say:e.say,async changed(){},close(){}}}function ml(e){return e.HOME||e.USERPROFILE||$t()}function hl(e,t){return e===`~`?t:e.startsWith(`~/`)||e.startsWith(`~\\`)?x.join(t,e.slice(2)):e}function gl(e,t){if(typeof e!=`string`||e.trim()===``||e.length>4096||e.includes(`\0`))throw B(400,`app.cli.web.reason.badFolder`,{folder:String(e).replace(/[\u0000-\u001f\u007f]/g,`?`).slice(0,200)});let n=hl(e.trim(),t);if(!x.isAbsolute(n))throw B(400,`app.cli.web.reason.notAbsolute`,{folder:e.slice(0,200)});return x.resolve(n)}function _l(e){return E(e,{throwIfNoEntry:!1})?.isDirectory()===!0}var vl=class{shared;current;idle;requests=/* @__PURE__ */ new Map;deploys=0;constructor(e){this.shared=ul(e),this.idle=pl(this.shared),this.current=this.idle,e.folder!==void 0&&(this.current=dl(e.folder,this.shared)),this.current.open&&(this.remember(this.current.folder),this.current.project.listing().catch(()=>void 0))}get context(){return this.current}info(){let e=this.current;return e.open?{open:!0,available:e.confine.stands(),id:e.id,name:x.basename(e.folder)||e.folder,folder:e.folder}:{open:!1,available:!1,id:null,name:null,folder:null}}busy(){return this.deploys>0||this.current.open&&this.current.hooks.active()>0}beginDeploy(){this.deploys+=1;let e=!1;return()=>{e||(e=!0,--this.deploys)}}track(e,t){let n=this.requests.get(e);return n||(n=/* @__PURE__ */ new Set,this.requests.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.requests.get(e)===n&&this.requests.delete(e)}}async open(e){let t=gl(e,ml(this.shared.env)),n=E(t,{throwIfNoEntry:!1});if(!n)throw B(404,`app.cli.web.reason.noSuchFolder`,{folder:t.slice(0,200)});if(!n.isDirectory())throw B(400,`app.cli.web.reason.notAFolder`,{folder:t.slice(0,200)});try{await k(t)}catch(e){let n=e.code;throw n===`EACCES`||n===`EPERM`?B(403,`app.cli.web.reason.folderNotReadable`,{folder:t.slice(0,200)}):B(404,`app.cli.web.reason.noSuchFolder`,{folder:t.slice(0,200)})}return this.current.open&&this.current.folder===T.native(t)?this.info():this.swap(()=>dl(t,this.shared))}async close(){return this.swap(()=>this.idle)}swap(e){if(this.busy())throw B(409,`app.cli.web.reason.switchBusy`);let t=this.current,n=e();return this.current=n,this.shared.events.drop(),this.shared.events.publish({type:`projectChanged`}),t.open&&this.retire(t),n.open&&(this.remember(n.folder),n.project.listing().catch(()=>void 0)),this.info()}retire(e){e.close(),setTimeout(()=>{let t=this.requests.get(e);if(t)for(let e of t)e.abort();this.requests.delete(e)},3e3).unref()}recent(){let e=[];try{e=new _(this.shared.home).recentProjects()}catch{}return e.map(e=>({folder:e,name:x.basename(e)||e,present:_l(e)}))}lastProject(){return this.recent().find(e=>e.present)?.folder??null}forget(e){let t=gl(e,ml(this.shared.env));try{new _(this.shared.home).forgetProject(t)}catch{}return this.recent()}remember(e){try{new _(this.shared.home).rememberProject(e)}catch{}}shutdown(){this.current.close();for(let e of this.requests.values())for(let t of e)t.abort();this.requests.clear(),this.shared.events.close()}};const yl=/\.(bpmn|bpmn\.xml|bpmn20\.xml|dmn|form)$/i,bl=/^penstock\.(yaml|yml|json)$/i,xl=new Intl.Collator(`en`,{numeric:!0,sensitivity:`base`});function Sl(e){return bl.test(e)||yl.test(e)}async function Cl(e){let t;try{t=await bn(e)}catch{return!1}try{for(let e=0;e<4e3;e+=1){let e=await t.read();if(!e)return!1;if(Sl(e.name))return!0}return!1}catch{return!1}finally{await t.close().catch(()=>void 0)}}async function wl(){if(process.platform!==`win32`)return[`/`];let e=Array.from({length:26},(e,t)=>String.fromCharCode(65+t)).map(async e=>{let t=`${e}:\\`;return await Promise.race([j(t).then(()=>!0,()=>!1),new Promise(e=>setTimeout(()=>e(!1),300).unref())])?t:null});return(await Promise.all(e)).filter(e=>e!==null)}function Tl(e,t){let n=e.code,r=t.replace(/[\u0000-\u001f\u007f]/g,`?`).slice(0,200);throw n===`EACCES`||n===`EPERM`?B(403,`app.cli.web.reason.folderNotReadable`,{folder:r}):n===`ENOTDIR`?B(400,`app.cli.web.reason.notAFolder`,{folder:r}):n===`ENOENT`||n===`ELOOP`||n===`ENAMETOOLONG`?B(404,`app.cli.web.reason.noSuchFolder`,{folder:r}):e}async function El(e,t){let n=e.lastProject();if(n){let e=x.dirname(n);try{if((await j(e)).isDirectory())return e}catch{}}return t}async function Dl(e,t,n,r=2e4){let i=ml(e.shared.env),a=t===void 0||t===``?await El(e,i):gl(t,i),o;try{if(o=await Sn(a),!(await j(o)).isDirectory())throw B(400,`app.cli.web.reason.notAFolder`,{folder:a.replace(/[\u0000-\u001f\u007f]/g,`?`).slice(0,200)})}catch(e){return Tl(e,a)}let s;try{s=await k(o,{withFileTypes:!0})}catch(e){return Tl(e,o)}let c=[],l=!1,u=0;for(let e of s){let t=e.name;if(e.isDirectory())c.push({name:t,hidden:t.startsWith(`.`),link:!1});else{if(e.isSymbolicLink()||!e.isFile()&&!e.isDirectory())try{if((await j(x.join(o,t))).isDirectory()){c.push({name:t,hidden:t.startsWith(`.`),link:e.isSymbolicLink()});continue}}catch{continue}bl.test(t)?l=!0:yl.test(t)&&(u+=1)}}c.sort((e,t)=>xl.compare(e.name,t.name)||(e.name<t.name?-1:+(e.name>t.name)));let d=c.length,f=d>r?c.slice(0,r):c,p=f.reduce((e,t)=>e+ +!!t.hidden,0),m=!0,h=Date.now()+1500,g=f.filter(e=>!e.link&&(n||!e.hidden)),ee=0;await Promise.all(Array.from({length:Math.min(24,g.length)},async()=>{for(;ee<g.length;){if(Date.now()>h){m=!1;return}let e=g[ee];ee+=1,await Cl(x.join(o,e.name))&&(e.project=!0)}}));let te=x.dirname(o);return{path:o,parent:te===o?null:te,home:i,separator:x.sep,roots:await wl(),entries:f,total:d,truncated:f.length<d,hiddenCount:p,hintsComplete:m,project:l||u>0?{config:l,diagrams:u}:null}}const Ol=[{method:`POST`,path:`/web/folders`,operationId:`listFolders`,limit:L,run:e=>{let t=e.body===void 0?{}:V(e.body);return Dl(e.workspace,U(t,`path`),W(t,`hidden`))}}],kl=[{method:`GET`,path:`/web/project`,operationId:`getCurrentProject`,run:e=>e.workspace.info()},{method:`POST`,path:`/web/project/open`,operationId:`openProject`,limit:L,run:e=>e.workspace.open(H(V(e.body),`folder`))},{method:`POST`,path:`/web/project/close`,operationId:`closeProject`,run:e=>e.workspace.close()},{method:`GET`,path:`/web/project/recent`,operationId:`listRecentProjects`,run:e=>({projects:e.workspace.recent()})},{method:`POST`,path:`/web/project/recent/forget`,operationId:`forgetRecentProject`,limit:L,run:e=>({projects:e.workspace.forget(H(V(e.body),`folder`))})}];function Al(t){let n=new _(t.home).text(`theme`);return{theme:n===`light`?`LIGHT`:n===`dark`?`DARK`:n===`dracula`?`DRACULA`:`SYSTEM`,locale:m(),engine:null,scriptType:`NONE`,bpmnLint:{configPath:null,clientBundlePath:null},elementTemplates:[],elementTemplatesContent:[],elementTemplatesFolder:``,project:``,bpmnFilePath:``,bpmnXml:``,conventions:null,pluginVersion:e()??null}}const jl=[`JOB_TYPE`,`TOPIC`,`CLASS`,`BEAN`,`MESSAGE`];function Ml(e){return jl.includes(e)}function Nl(e,t,n){return t===`MESSAGE`?Ue(e,{kind:t,value:n}):Je(e,{kind:t,value:n})}function Pl(e,t,n){let r=/* @__PURE__ */ new Map;for(let i of n)if(Ml(i.kind)&&i.value!==``)for(let n of Nl(t,i.kind,i.value)){if(n.file!==e)continue;let t=i.elementId??null,a=`${n.line}\u0000${i.kind}\u0000${i.value}\u0000${i.path}\u0000${t}`;if(!r.has(a)&&(r.set(a,{line:n.line,kind:i.kind,value:i.value,diagram:i.path,element:t,name:i.label,elementType:i.elementType??``}),r.size>=500))return Fl(r)}return Fl(r)}function Fl(e){return[...e.values()].sort((e,t)=>e.line-t.line||e.diagram.localeCompare(t.diagram)||e.name.localeCompare(t.name))}function Il(e,t){let n=/* @__PURE__ */ new Map,r=(e,t,r)=>{if(t===``)return;let i=`${e}\u0000${t}`,a=n.get(i);a?a.origin!==r&&(a.origin=`both`):n.set(i,{kind:e,value:t,origin:r})};for(let e of t)Ml(e.kind)&&r(e.kind,e.value,`diagram`);for(let t of e.jobTypes.keys())r(`JOB_TYPE`,t,`code`);for(let t of e.topics.keys())r(`TOPIC`,t,`code`);for(let t of e.classes.keys())r(`CLASS`,t,`code`);for(let t of e.beans.keys())r(`BEAN`,t,`code`);for(let t of e.references.keys())t.startsWith(`MESSAGE:`)&&r(`MESSAGE`,t.slice(8),`code`);return[...n.values()].sort((e,t)=>e.kind.localeCompare(t.kind)||e.value.localeCompare(t.value)).slice(0,5e3)}const Ll=e=>Ht.has(e),Rl=Ut,zl=e=>/\.form$/i.test(e)?`form`:/\.(bpmn|bpmn\.xml|bpmn20\.xml|dmn)$/i.test(e)?`diagram`:`code`;function Bl(e,t,n,r){let i=[];for(let a of e){if(a.path===r)continue;let e=zl(a.path);(e===`form`?Wt(t,n,a.text):e===`diagram`?Gt(t,n,a.text):Kt(t,n,a.text)).forEach(t=>i.push({file:a.path,start:t.start,end:t.end,where:e,label:t.where}))}return i}function Vl(e){let t=new Set(e.map(e=>e.file)).size,n=e.filter(e=>e.where!==`code`).length;return p(`app.vscode.rename.summary`,{files:p(`app.vscode.rename.files`,{count:t}),diagrams:n,code:e.length-n})}const Hl=zn(dn),Ul=4e3,Wl={JAVA_CLASS:[`CLASS`],BEAN:[`BEAN`],JOB_TYPE:[`JOB_TYPE`,`TOPIC`]},Gl=/* @__PURE__ */ new Set([`PROCESS`,`JOB_TYPE`,`TOPIC`,`MESSAGE`,`SIGNAL`,`DECISION`,`FORM`,`CLASS`,`BEAN`,`ERROR`]);function Kl(e){return pn(`sha256`).update(e).digest(`hex`)}async function ql(e,t){let n=V(e.body),r=H(n,`kind`),i=H(n,`value`),a=Wl[r];if(!a)throw B(400,`app.cli.web.reason.wrongField`,{field:`kind`});if(i.length===0||i.length>500)throw B(400,`app.cli.web.reason.wrongField`,{field:`value`});let{index:o}=await t.code.state(()=>t.project.listing()),s=/* @__PURE__ */ new Set;return{places:a.flatMap(e=>Je(o,{kind:e,value:i})).filter(e=>{let t=`${e.file}#${e.line}`;return!s.has(t)&&(s.add(t),!0)}).map(e=>({path:e.file,line:e.line,label:`${x.basename(e.file)}:${e.line}`}))}}async function Jl(e,t){let n=t.confine.resolve(H(V(e.body),`path`)),{index:r,targets:i}=await t.code.state(()=>t.project.listing());return{uses:Pl(n,r,i)}}async function Yl(e,t){let{index:n,targets:r}=await t.code.state(()=>t.project.listing());return{names:Il(n,r)}}async function Xl(e,t){try{return{ok:!0,out:(await Hl(`git`,t,{cwd:e,encoding:`utf8`,timeout:1e4,maxBuffer:67108864,env:{...process.env,GIT_TERMINAL_PROMPT:`0`,GIT_OPTIONAL_LOCKS:`0`}})).stdout}}catch{return{ok:!1,out:``}}}async function Zl(e,t){let n=t.confine.resolve(H(V(e.body),`path`)),r=x.dirname(n),i=await Xl(r,[`rev-parse`,`--is-inside-work-tree`]);if(!i.ok||i.out.trim()!==`true`)return{tracked:!1,before:null};let a=await Xl(r,[`show`,`HEAD:./${x.basename(n)}`]);return{tracked:!0,before:a.ok?a.out:null}}async function Ql(e){try{let t=await j(e);return!t.isFile()||t.size>33554432?null:await xn(e,`utf8`)}catch{return null}}function $l(e,t,n){if(e.confine.writeKind(t))return;let r=e.confine.segments(t),i=r.slice(0,-1).some(e=>e.startsWith(`.`));if(!Ge.test(r[r.length-1]??``)||i)throw B(403,`app.cli.web.reason.notEditable`,{path:n.slice(0,200)})}async function eu(e,t){let n=await e.project.listing(),{sources:r}=await e.code.state(()=>e.project.listing()),i=/* @__PURE__ */ new Set([...n.files.map(e=>e.path),...r.map(e=>e.path)]);if(i.delete(t),i.size>Ul)throw B(400,`app.cli.web.reason.tooMany`);let a=[];for(let e of i){let t=await Ql(e);t!==null&&a.push({path:e,text:t})}return a}function tu(e){let t=V(e.body),n=H(t,`kind`);if(!Gl.has(n))throw B(400,`app.cli.web.reason.wrongField`,{field:`kind`});return{kind:n,from:H(t,`from`),to:H(t,`to`),path:H(t,`path`)}}function nu(e,t){let n=1;for(let r=0;r<t&&r<e.length;r+=1)e.charCodeAt(r)===10&&(n+=1);return n}async function ru(e,t){let n=tu(e),r=t.confine.resolve(n.path),i={offered:!1,sites:[],files:[]};if(!Ll(n.kind)||!n.from.trim()||!Rl(n.to))return{...i,detail:p(`app.vscode.rename.notRenamable`)};if(!await Y(t))return i;let a=await eu(t,r),o=Bl(a,n.kind,n.from,r);if(o.length===0)return{...i,detail:p(`app.vscode.rename.nothingElse`,{name:n.from})};let s=new Map(a.map(e=>[e.path,e.text])),c=[...new Set(o.map(e=>e.file))];return{offered:!0,summary:Vl(o),sites:o.map(e=>({path:e.file,where:e.where,label:e.label,line:nu(s.get(e.file)??``,e.start)})),files:c.map(e=>({path:e,version:Kl(s.get(e)??``)}))}}function iu(e,t,n){let r=e;for(let e of[...t].sort((e,t)=>t.start-e.start))r=`${r.slice(0,e.start)}${n}${r.slice(e.end)}`;return r}async function au(e,t){let n=x.join(x.dirname(e),`.${x.basename(e)}.${process.pid}.${mn(4).toString(`hex`)}.tmp`),r=await j(e).catch(()=>null);return await Tn(n,t,{mode:r?r.mode&511:420}),n}async function ou(e,t){let n=tu(e),r=V(e.body);if(!Ll(n.kind)||!n.from.trim()||!Rl(n.to))throw B(400,`app.cli.web.reason.wrongField`,{field:`to`});if(!await Y(t))throw B(403,`app.cli.webHost.reason.notLicensed`);let i=t.confine.resolve(n.path),a=G(r,`files`).map(e=>{let t=V(e);return{path:H(t,`path`),version:H(t,`version`)}});if(a.length===0||a.length>Ul)throw B(400,`app.cli.web.reason.badFileList`);let o=[];for(let e of a){let n=t.confine.resolve(e.path);if($l(t,n,e.path),n===i)throw B(400,`app.cli.web.reason.wrongField`,{field:`files`});let r=await Ql(n);if(r===null||Kl(r)!==e.version)throw B(409,`app.cli.webHost.reason.changedSince`,{file:t.confine.relative(n).slice(0,200)});o.push({path:n,text:r})}let s=Bl(o,n.kind,n.from,i),c=[];try{for(let e of o){let t=s.filter(t=>t.file===e.path);t.length!==0&&c.push({target:e.path,temporary:await au(e.path,iu(e.text,t,n.to)),before:e.text})}for(let e of c){let n=await Ql(e.target);if(n===null||n!==e.before)throw B(409,`app.cli.webHost.reason.changedSince`,{file:t.confine.relative(e.target).slice(0,200)})}let e=[];try{for(let t of c)await A(t.temporary,t.target),e.push(t)}catch(t){for(let t of e.reverse()){let e=await au(t.target,t.before);await A(e,t.target).catch(()=>Cn(e,{force:!0}))}throw t}}finally{await Promise.all(c.map(e=>Cn(e.temporary,{force:!0}).catch(()=>void 0)))}return{places:s.length,files:c.length}}function su(e){throw e instanceof l?B(400,`app.cli.webHost.reason.licence`,{detail:e.message}):B(502,`app.cli.webHost.reason.licenceService`,{detail:e instanceof Error?e.message:String(e)})}async function cu(e,t){let n=H(V(e.body),`key`).trim();if(n.length<8||n.length>200)throw B(400,`app.cli.webHost.reason.keyShape`);try{await i(n,{env:t.env})}catch(e){su(e)}return Ho(t),Wo(t)}async function lu(e,t){try{if(await o({env:t.env})===`none`)throw B(409,`app.cli.webHost.reason.nothingToRelease`)}catch(e){if(e instanceof Error&&e.name===`WebFailure`)throw e;su(e)}return Ho(t),Wo(t)}async function uu(e,t){let n=V(e.body),r=H(n,`tier`);if(r!==`PRO`&&r!==`TEAM`)throw B(400,`app.cli.web.reason.wrongField`,{field:`tier`});let i=typeof n.email==`string`&&n.email.trim()?n.email.trim().slice(0,200):void 0;try{return{url:(await a(r===`PRO`?`pro`:`team`,i,{env:t.env})).url}}catch(e){throw B(502,`app.cli.webHost.reason.licenceService`,{detail:e instanceof Error?e.message:String(e)})}}async function du(e,t){let n=V(e.body),r=typeof n.since==`string`&&n.since.trim()!==``?n.since.trim().slice(0,200):void 0;if(n.format!==void 0&&n.format!==`zip`&&n.format!==`dir`)throw B(400,`app.cli.web.reason.wrongField`,{field:`format`});if(n.force!==void 0&&typeof n.force!=`boolean`)throw B(400,`app.cli.web.reason.wrongField`,{field:`force`});let i=await J(t);if(!g(i,{env:t.env}))return{ok:!1,pack:null,files:0,sealed:null,lines:h(i,`audit-evidence`,{env:t.env})};let{evidenceBuild:a}=await import(`./chunk-evidence-oLw_C6j8.js`),o=await a({root:t.folder,format:n.format===`dir`?`dir`:`zip`,since:r,force:n.force===!0,json:!1},{tier:async()=>i.tier});return{ok:o.ok,pack:o.pack??null,files:o.files??0,sealed:o.sealed??null,lines:o.lines}}const fu=[{method:`POST`,path:`/web/code/locate`,operationId:`locateCode`,limit:L,run:ql},{method:`POST`,path:`/web/code/uses`,operationId:`findCodeUses`,limit:L,run:Jl},{method:`GET`,path:`/web/code/names`,operationId:`listProjectNames`,run:Yl},{method:`POST`,path:`/web/compare`,operationId:`compareWithHead`,limit:L,run:Zl},{method:`POST`,path:`/web/evidence`,operationId:`buildEvidence`,limit:L,run:du},{method:`POST`,path:`/web/linked-rename/plan`,operationId:`planLinkedRename`,limit:L,run:ru},{method:`POST`,path:`/web/linked-rename/apply`,operationId:`applyLinkedRename`,limit:L,run:ou},{method:`POST`,path:`/web/licence/activate`,operationId:`activateLicence`,limit:L,run:cu},{method:`POST`,path:`/web/licence/checkout`,operationId:`startLicenceCheckout`,limit:L,run:uu},{method:`POST`,path:`/web/licence/deactivate`,operationId:`deactivateLicence`,limit:L,run:lu}],pu=[`RENAME`,`BULK`,`EXTRACT`];function mu(e){if(!e.open||e.folder===``)throw B(409,`app.cli.web.reason.noProject`)}function hu(e){let t=V(e),n=H(t,`mode`);if(!pu.includes(n))throw B(400,`app.cli.web.reason.wrongField`,{field:`mode`});return{mode:n,fields:t,planId:U(t,`planId`),acknowledge:W(t,`acknowledge`),force:W(t,`force`)}}function gu(e){if(e.mode===`RENAME`){let t=H(e.fields,`kind`);if(!Zt(t))throw B(400,`app.cli.web.reason.wrongField`,{field:`kind`});return[{kind:t,from:H(e.fields,`from`),to:H(e.fields,`to`)}]}let t=H(e.fields,`mapping`);if(Buffer.byteLength(t,`utf8`)>262144)throw B(400,`app.refactor.mapping.tooLarge`,{detail:``,line:0});let n=qt(t,/^\s*[[{]/.test(t.slice(0,64)));if(n.problem!==null)throw B(400,`app.refactor.mapping.${n.problem.code}`,{detail:n.problem.detail,line:n.problem.line});return n.requests}function _u(e,t){let n=t.confine.resolve(H(e.fields,`file`)),r=U(e.fields,`name`);return{relative:x.relative(T(t.folder),T(n)).split(x.sep).join(`/`),request:{elements:zi(e.fields,`elements`),processId:H(e.fields,`processId`),...r===void 0||r.trim()===``?{}:{name:r}}}}const vu={allowed:!0,lines:[],stopped:null,detail:``,planId:null,blocked:!1,blockers:[],edits:[],editCount:0,refused:[],refusedCount:0,blockingRefusals:0,files:[],extract:null,extractRefusals:[]};function yu(e,t){let{report:n}=t;return{...vu,mode:e,stopped:t.stopped,detail:t.detail,planId:n.planId,blocked:n.blocked,blockers:n.blockers,edits:n.edits,editCount:n.editCount,refused:n.refused,refusedCount:n.refusedCount,blockingRefusals:n.blockingRefusals,files:n.files}}function bu(e){let t=e.plan;return{...vu,mode:`EXTRACT`,stopped:e.stopped,detail:e.detail,planId:e.planId,blocked:t===null,extractRefusals:e.refusals,extract:t===null?null:{created:t.created,callId:t.callId,processId:t.processId,engine:t.engine,moved:t.moved,inputs:t.mappings.inputs,outputs:t.mappings.outputs,allIn:t.mappings.allIn,allOut:t.mappings.allOut}}}async function xu(e,t){if(e.mode===`RENAME`)return null;let n=await J(t);return g(n,{env:t.env})?null:h(n,`refactor-bulk`,{env:t.env})}async function Su(e,t){mu(t);let n=hu(e.body),r=await xu(n,t);if(r!==null)return{...vu,mode:n.mode,allowed:!1,lines:r};try{if(n.mode===`EXTRACT`){let{relative:e,request:r}=_u(n,t);return bu(await Yt(t.folder,e,r,{apply:!1,force:!1,acknowledge:!1}))}return yu(n.mode,Jt(t.folder,gu(n),{apply:!1,force:!1,acknowledge:!1}))}catch(e){throw e instanceof Xt?B(400,`app.refactor.cli.uncRoot`):e}}async function Cu(e,t){mu(t);let n=hu(e.body);if(n.planId===void 0||n.planId===``)throw B(400,`app.cli.web.reason.missingField`,{field:`planId`});if(await xu(n,t)!==null)throw B(403,`app.cli.webHost.reason.notLicensed`);let r={apply:!0,force:n.force,acknowledge:n.acknowledge,planId:n.planId};try{if(n.mode===`EXTRACT`){let{relative:e,request:i}=_u(n,t),a=await Yt(t.folder,e,i,r);if(!a.applied||a.written===null)throw B(409,`app.refactor.stop.`+(a.stopped??`blocked`),{detail:a.detail});return{files:[a.written.source,a.written.created],edits:2,created:a.written.created}}let e=Jt(t.folder,gu(n),r);if(!e.applied||e.written===null)throw B(409,`app.refactor.stop.`+(e.stopped??`blocked`),{detail:e.detail});return{files:e.written.files,edits:e.written.edits,created:null}}catch(e){throw e instanceof Xt?B(400,`app.refactor.cli.uncRoot`):e}}const wu=[{method:`POST`,path:`/web/refactor/plan`,operationId:`planRefactor`,limit:L,run:Su},{method:`POST`,path:`/web/refactor/apply`,operationId:`applyRefactor`,limit:L,run:Cu}],Tu=[{method:`GET`,path:`/web/lsp/servers`,operationId:`listLanguageServers`,run:(e,t)=>({servers:Bc(t.home,t.env).map(e=>({id:e.id,label:e.command,languages:e.languages,available:e.found!==null,configured:e.configured}))})},{method:`GET`,path:`/web/lsp/messages`,operationId:`nextLspMessages`,held:!0,run:async(e,t)=>({messages:await t.events.nextMessages(e.client,e.signal)})},{method:`POST`,path:`/web/lsp/{serverName}/message`,operationId:`sendLspMessage`,limit:R,run:(e,t)=>{t.servers.send(e.client,e.params.serverName,e.body)}}],Eu=/* @__PURE__ */ new Set([`JOB_TYPE`,`TOPIC`,`CLASS`,`BEAN`,`MESSAGE`,`PROCESS`,`DECISION`]),Du=/* @__PURE__ */ new Set([`execution`,`task`]);function Ou(e,t){if(e.length>500)throw B(400,`app.cli.web.reason.wrongField`,{field:t});return e}function ku(e){let t=V(e),n=H(t,`kind`);if(!Eu.has(n))throw B(400,`app.cli.web.reason.wrongField`,{field:`kind`});let r=t.listener;if(r!==void 0&&(typeof r!=`string`||!Du.has(r)))throw B(400,`app.cli.web.reason.wrongField`,{field:`listener`});return{kind:n,value:Ou(H(t,`value`),`value`),...r?{listener:r}:{}}}function Au(e){let t=V(e),n=G(t,`elements`);if(n.length>2e4)throw B(400,`app.cli.web.reason.tooMany`);return{diagram:Ou(H(t,`diagram`),`diagram`),elements:n.map(e=>{let t=V(e),n=G(t,`bindings`);if(n.length>40)throw B(400,`app.cli.web.reason.tooMany`);return{elementId:Ou(H(t,`elementId`),`elementId`),elementType:Ou(H(t,`elementType`),`elementType`),label:Ou(H(t,`label`),`label`),bindings:n.map(ku)}})}}function ju(e,t){let n=/* @__PURE__ */ new Map;for(let r of e)r.kind===t&&!n.has(r.value)&&n.set(r.value,r.path);return n}function Mu(e,t,n){return{licensed:!0,statuses:Wr({diagram:n.diagram,index:e,processes:ju(t,`PROCESS`),decisions:ju(t,`DECISION`)},n.elements).map(({reached:e,paused:t,...n})=>n)}}function Nu(e,t,n){let r=e.split(/\r\n|\n|\r/);return r[r.length-1]===``&&r.pop(),r.slice(Math.max(0,t-1),Math.max(0,t-1)+n).map(e=>e.replace(/\s+$/,``).slice(0,240))}async function Pu(e){let t;try{let n=await j(e);return!n.isFile()||n.size>1048576?null:(t=await yn(e,`r`),await t.readFile(`utf8`))}catch{return null}finally{await t?.close().catch(()=>void 0)}}const Fu=[{method:`POST`,path:`/web/code/status`,operationId:`findCodeStatus`,limit:R,run:async(e,t)=>{let n=Au(e.body);if(!await Y(t))return{licensed:!1,statuses:[]};let{index:r,targets:i}=await t.code.state(()=>t.project.listing());return Mu(r,i,n)}},{method:`POST`,path:`/web/code/snippet`,operationId:`readCodeSnippet`,limit:L,run:async(e,t)=>{let n=V(e.body),r=H(n,`path`),i=n.line;if(typeof i!=`number`||!Number.isInteger(i)||i<1||i>1e7)throw B(400,`app.cli.web.reason.wrongField`,{field:`line`});let a=n.count;if(a!==void 0&&(typeof a!=`number`||!Number.isInteger(a)||a<1))throw B(400,`app.cli.web.reason.wrongField`,{field:`count`});let o=t.confine.resolve(r);if(!Ge.test(o))throw B(400,`app.cli.web.reason.wrongField`,{field:`path`});let s=await Pu(o);return{path:r,line:i,lines:s===null?[]:Nu(s,i,Math.min(a??12,12))}}}],Iu={workers:[],classes:[],camunda7Imports:[]};var Lu=class{signature=``;analysis={migration:null,facts:Iu};async analysisOf(e,t){let n=pn(`sha1`);e.forEach(e=>n.update(`${e.path}\n${e.text}\n`)),t.forEach(e=>n.update(`${e.file}\n${e.text}\n`));let r=n.digest(`hex`);if(r!==this.signature){let{index:n,facts:i}=await pt(e,t.map(e=>({path:e.file,text:e.text}))),a=await lt({files:e,classes:i.classes,camunda7Imports:i.camunda7Imports,index:n}).catch(()=>null);this.analysis={migration:a,facts:i},this.signature=r}return this.analysis}};function Ru(e){return e.slice(0,Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`),0))}async function zu(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map;for(let i of e){let e=Ru(i);if(!n.has(e)){let r=await t.deployTargets(i).catch(()=>null),a=r?.targets.find(e=>(e.profile??null)===(r.active??null));n.set(e,a?{profile:a.profile??null,engine:a.engine??null,url:a.url??null,ready:a.ready}:null)}let a=n.get(e);a&&r.set(i,a)}return r}function Bu(e,t){let n=t.replace(/\\/g,`/`),r=e.replace(/\\/g,`/`).replace(/\/+$/,``);return n.startsWith(`${r}/`)?n.slice(r.length+1):n}async function Vu(e,t){if(!e.connections||e.connections.length===0)return null;let n=await Promise.all((await t.list().catch(()=>[])).map(async e=>({path:e,text:await t.read(e).catch(()=>null)??``}))),r=[...e.connections.map(t=>({path:Bu(e.root,t.path),text:t.text})),...e.diagrams.map(t=>({path:Bu(e.root,t.path),text:t.text})),...n];return Rt(r)}async function Hu(e,t,n){let r=await t.reports().catch(()=>[]),i=await t.deployTargets().catch(()=>null),a=t.templates(),o=await n.analysisOf(e.diagrams,e.sources),[s,c]=await Promise.all([ot(a),st(a,o.facts.workers)]),l=new Map(c.map(e=>[e.id,e.drift]));return Cr({root:e.root,files:e.files,targets:e.targets,code:e.code,coverage:$n(e.root,r).reach,deploy:i&&{active:i.active,targets:i.targets},debug:[],preferences:{tree:e.preferences?.toolWindowTree!==!1,groupByFiles:e.preferences?.toolWindowGroupByFiles===!0},workersOnEngine:e.workersOnEngine,fileTargets:await zu(e.files.map(e=>e.path),t),codeLinks:e.licensed?`open`:`locked`,migration:o.migration,templates:[...s.values()].map(({path:e,template:t})=>({path:e,template:t,drift:l.get(t.id)??null})),connections:await Vu(e,a),connectionsScreen:e.connectionsScreen===!0,migrationScreen:e.migrationScreen===!0,contracts:o.facts.workers.map(e=>({value:e.value,file:e.file,line:e.line,handler:e.handler??null}))})}function Uu(e,t){return e.elementId===t.elementId&&e.owner===t.owner&&e.index===t.index}async function Wu(e){let t=await ke(e.text),n=Fe(t).find(t=>Uu(t.slot,e.slot));if(!n)return null;let r=Dr({definitions:t,workers:e.workers,diagramPath:e.path},n.slot.elementId,n.value);return{path:e.path,slot:n.slot,language:n.language,value:n.value,title:ir(n),variables:r}}const Gu=2e4;function Ku(e,t){let n=/* @__PURE__ */ new Set,r=[];for(let{handle:i,label:a}of e){if(r.length>=500)break;let e;try{e=t(mt(i))}catch{e=null}if(!e)continue;let o=ft(i)??1,s=`${e}#${o}`;n.has(s)||(n.add(s),r.push({path:e,line:o,label:a??`${x.basename(e)}:${o}`}))}return r}function qu(e){return{kind:`unsupported`,reason:e}}function Ju(e){return e.checks.flatMap(e=>e.check.problem?[`${e.where}: ${e.check.problem}`]:[])}async function Yu(e,t){switch(e.type){case`reveal`:{let n=t.inside(e.path);return n?{kind:`reveal`,path:n,...e.elementId?{elementId:e.elementId}:{}}:qu(p(`app.cli.web.toolWindow.unsupported.outside`))}case`openCode`:return{kind:`openCode`,title:e.title,places:Ku(e.handles.map(e=>({handle:e})),e=>t.inside(e))};case`findUsages`:return await t.paid()?{kind:`findUsages`,title:e.title,places:Ku(await t.usages(e.subjects),e=>t.inside(e))}:{kind:`unlockCode`};case`copy`:return{kind:`copy`,text:e.text.slice(0,Gu)};case`preference`:return t.savePreference(e.key,e.value),{kind:`preference`,key:e.key,value:e.value};case`deploy`:{let n=e.paths.slice(0,1e3).map(e=>t.inside(e)).filter(e=>e!==null);return n.length===0?qu(p(`app.cli.web.toolWindow.unsupported.outside`)):{kind:`deploy`,paths:n,...e.profile?{profile:e.profile}:{},...e.confirm?{confirm:!0}:{}}}case`createExample`:return{kind:`createExample`,example:e.example};case`unlockCode`:return{kind:`unlockCode`};case`openConnections`:return{kind:`openConnections`};case`openMigration`:return{kind:`openMigration`};case`checkWorkers`:{if(!await t.paid())return{kind:`unlockCode`};let n=await t.checkWorkers(e.groups);t.workersChecked(n);let r=Ju(n);return r.length>0?{kind:`notify`,text:r.join(`
18
+ `)].join(`\0`)}function el(e,t){return $c(e)===$c(t)}var tl=class{root;limits;cached=null;cachedGeneration=-1;generation=0;building=null;scans=0;constructor(e,t=Kc){this.root=e,this.limits=t}peek(){return this.cached}invalidate(){this.generation+=1}async listing(){for(;;){if(this.cached&&this.cachedGeneration===this.generation)return this.cached;if(!this.building){let e=this.generation;this.scans+=1,this.building=Qc(this.root,this.limits).then(t=>(this.cached=t,this.cachedGeneration=e,t)).finally(()=>{this.building=null})}await this.building}}},nl=class{runs=/* @__PURE__ */ new Map;start(e){let t=hn(),n=new AbortController,r={abort:n,status:`running`};return this.runs.set(t,r),e(n.signal).catch(e=>({ok:!1,lines:[e instanceof Error?e.message:String(e)]})).then(e=>{r.status===`running`&&(r.status=`finished`),r.result=e}),t}active(){let e=0;for(let t of this.runs.values())t.status===`running`&&(e+=1);return e}state(e){let t=this.runs.get(e);if(t)return(t.status===`finished`||t.status===`cancelled`&&t.result)&&this.runs.delete(e),{run:e,status:t.status,ok:t.status===`finished`&&(t.result?.ok??!1),lines:t.result?.lines??[]}}cancel(e){let t=this.runs.get(e);t?.status===`running`&&(t.status=`cancelled`,t.abort.abort())}};const rl=/* @__PURE__ */ new Set([`.camunda`]),il=/(~|\.(tmp|swp|swx|bak|lock|crdownload|part))$|^\.#|^\.DS_Store$|^4913$/i;function al(e){let t=e.split(/[\\/]/).filter(e=>e!==``);return il.test(t[t.length-1]??``)?!0:t.slice(0,-1).some(e=>b.has(e)||e.startsWith(`.`)&&!rl.has(e))}var ol=class{root;onBatch;debounceMs;maxWaitMs;firstRetryMs;maxRetryMs;pollMs;open;pending=/* @__PURE__ */ new Set;watcher=null;quiet=null;deadline=null;retry=null;poll=null;retryMs;closed=!1;constructor(e,t,n={}){this.root=e,this.onBatch=t,this.debounceMs=n.debounceMs??80,this.maxWaitMs=n.maxWaitMs??600,this.firstRetryMs=n.retryMs??250,this.maxRetryMs=n.maxRetryMs??5e3,this.pollMs=n.pollMs??3e3,this.retryMs=this.firstRetryMs,this.open=n.open??((e,t)=>ln(e,{recursive:!0,persistent:!1},t))}get active(){return this.watcher!==null||this.poll!==null}start(){this.attach(!1)}close(){this.closed=!0,this.detach();for(let e of[this.quiet,this.deadline,this.retry,this.poll])e&&clearTimeout(e);this.quiet=this.deadline=this.retry=this.poll=null,this.pending.clear()}attach(e){if(!(this.closed||this.watcher||this.poll)){if(!C(this.root))return this.later();try{this.watcher=this.open(this.root,(e,t)=>this.heard(t))}catch(e){return e?.code===`ERR_FEATURE_UNAVAILABLE_ON_PLATFORM`?this.polling():this.later()}this.watcher.on(`error`,()=>{this.detach(),this.heard(null),this.later()}),this.retryMs=this.firstRetryMs,e&&this.heard(null)}}polling(){this.poll=setInterval(()=>this.heard(null),this.pollMs),this.poll.unref()}detach(){let e=this.watcher;if(this.watcher=null,e){e.removeAllListeners(),e.on(`error`,()=>void 0);try{e.close()}catch{}}}later(){this.closed||this.retry||(this.retry=setTimeout(()=>{this.retry=null,this.attach(!0)},this.retryMs),this.retry.unref(),this.retryMs=Math.min(this.retryMs*2,this.maxRetryMs))}heard(e){if(this.closed)return;let t=e===null?`*`:e.toString();t!==`*`&&al(t)||(this.pending.add(t===``?`*`:t),this.quiet&&clearTimeout(this.quiet),this.quiet=setTimeout(()=>this.flush(),this.debounceMs),this.quiet.unref(),this.deadline||(this.deadline=setTimeout(()=>this.flush(),this.maxWaitMs),this.deadline.unref()))}flush(){if(this.quiet&&clearTimeout(this.quiet),this.deadline&&clearTimeout(this.deadline),this.quiet=this.deadline=null,this.closed||this.pending.size===0)return;let e=[...this.pending];this.pending.clear(),this.watcher&&!C(this.root)&&(this.detach(),this.later());try{this.onBatch(e.map(e=>e===`*`?e:x.join(this.root,e)))}catch{}}};const sl={password:`PENSTOCK_PASSWORD`,clientSecret:`PENSTOCK_CLIENT_SECRET`};function cl(e){let t=/* @__PURE__ */ new Map,n=(e,t)=>`${e??``}\u0000${t}`;return{async get(r,i){return t.get(n(r,i))??(e[sl[i]]||void 0)},async set(e,r,i){i?t.set(n(e,r),i):t.delete(n(e,r))}}}const ll=/^penstock(\.local)?\.(ya?ml|json)$/i;function ul(e){let t=e.env??process.env;return{env:t,home:e.home??te(t),fetch:e.fetch??fetch,openLink:e.openLink??(()=>void 0),say:e.say??(()=>void 0),events:new Ri(e.events),limits:e.limits??Kc,sourceLimits:e.sourceLimits,watcher:e.watcher,agent:e.agent??{}}}function dl(e,t){let n=new Ii(e),r=new tl(n.root,t.limits),i=new Ec(n.root,t.env),a=new Nc(n.root,t.sourceLimits),o=t.events,s=new Gc(n.root,t.home,t.env,o),c=o.onForget(e=>s.forget(e)),l=!1,u={id:mn(6).toString(`hex`),open:!0,folder:n.root,confine:n,project:r,configs:i,code:a,servers:s,events:o,env:t.env,home:t.home,secrets:cl(t.env),history:new lo,hooks:new nl,agent:new ye(n.root,t.agent.spawn??(e=>fl(e,t.env)),{home:t.home,env:t.env}),fetch:t.fetch,openLink:t.openLink,say:t.say,async changed(e){if(l)return;let t=r.peek(),n=e.includes(`*`),s=n||e.some(e=>ll.test(x.basename(e))),c=e.some(e=>e!==`*`&&Ge.test(e)),u=n||e.some(e=>/\.(bpmn|bpmn\.xml|bpmn20\.xml|dmn|form)$/i.test(e));r.invalidate(),s&&i.invalidate(),(n||c||u)&&a.invalidate();let d=await r.listing().catch(()=>null);l||(!s&&t&&d&&el(t,d)||o.publish({type:`projectChanged`}),c&&o.publish({type:`codeChanged`}))},close(){l=!0,u.agent.close(),c(),s.close(),d.close()}},d=new ol(n.root,e=>void u.changed(e).catch(()=>void 0),t.watcher);return d.start(),u}function fl(t,n){let r=Se();if(!r)throw new ve(500,p(`app.agent.notFound`));return nt({explicit:et(n),own:r,version:e()},[`agent`,`serve`,`--project`,t]).map(({command:e,args:t,env:n})=>({command:e,args:t,env:n}))}function $(){throw B(409,`app.cli.web.reason.noProject`)}function pl(e){return{id:`closed`,open:!1,folder:``,get confine(){return $()},get project(){return $()},get configs(){return $()},get code(){return $()},get servers(){return $()},get secrets(){return $()},get history(){return $()},get hooks(){return $()},get agent(){return $()},events:e.events,env:e.env,home:e.home,fetch:e.fetch,openLink:e.openLink,say:e.say,async changed(){},close(){}}}function ml(e){return e.HOME||e.USERPROFILE||$t()}function hl(e,t){return e===`~`?t:e.startsWith(`~/`)||e.startsWith(`~\\`)?x.join(t,e.slice(2)):e}function gl(e,t){if(typeof e!=`string`||e.trim()===``||e.length>4096||e.includes(`\0`))throw B(400,`app.cli.web.reason.badFolder`,{folder:String(e).replace(/[\u0000-\u001f\u007f]/g,`?`).slice(0,200)});let n=hl(e.trim(),t);if(!x.isAbsolute(n))throw B(400,`app.cli.web.reason.notAbsolute`,{folder:e.slice(0,200)});return x.resolve(n)}function _l(e){return E(e,{throwIfNoEntry:!1})?.isDirectory()===!0}var vl=class{shared;current;idle;requests=/* @__PURE__ */ new Map;deploys=0;constructor(e){this.shared=ul(e),this.idle=pl(this.shared),this.current=this.idle,e.folder!==void 0&&(this.current=dl(e.folder,this.shared)),this.current.open&&(this.remember(this.current.folder),this.current.project.listing().catch(()=>void 0))}get context(){return this.current}info(){let e=this.current;return e.open?{open:!0,available:e.confine.stands(),id:e.id,name:x.basename(e.folder)||e.folder,folder:e.folder}:{open:!1,available:!1,id:null,name:null,folder:null}}busy(){return this.deploys>0||this.current.open&&this.current.hooks.active()>0}beginDeploy(){this.deploys+=1;let e=!1;return()=>{e||(e=!0,--this.deploys)}}track(e,t){let n=this.requests.get(e);return n||(n=/* @__PURE__ */ new Set,this.requests.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.requests.get(e)===n&&this.requests.delete(e)}}async open(e){let t=gl(e,ml(this.shared.env)),n=E(t,{throwIfNoEntry:!1});if(!n)throw B(404,`app.cli.web.reason.noSuchFolder`,{folder:t.slice(0,200)});if(!n.isDirectory())throw B(400,`app.cli.web.reason.notAFolder`,{folder:t.slice(0,200)});try{await k(t)}catch(e){let n=e.code;throw n===`EACCES`||n===`EPERM`?B(403,`app.cli.web.reason.folderNotReadable`,{folder:t.slice(0,200)}):B(404,`app.cli.web.reason.noSuchFolder`,{folder:t.slice(0,200)})}return this.current.open&&this.current.folder===T.native(t)?this.info():this.swap(()=>dl(t,this.shared))}async close(){return this.swap(()=>this.idle)}swap(e){if(this.busy())throw B(409,`app.cli.web.reason.switchBusy`);let t=this.current,n=e();return this.current=n,this.shared.events.drop(),this.shared.events.publish({type:`projectChanged`}),t.open&&this.retire(t),n.open&&(this.remember(n.folder),n.project.listing().catch(()=>void 0)),this.info()}retire(e){e.close(),setTimeout(()=>{let t=this.requests.get(e);if(t)for(let e of t)e.abort();this.requests.delete(e)},3e3).unref()}recent(){let e=[];try{e=new _(this.shared.home).recentProjects()}catch{}return e.map(e=>({folder:e,name:x.basename(e)||e,present:_l(e)}))}lastProject(){return this.recent().find(e=>e.present)?.folder??null}forget(e){let t=gl(e,ml(this.shared.env));try{new _(this.shared.home).forgetProject(t)}catch{}return this.recent()}remember(e){try{new _(this.shared.home).rememberProject(e)}catch{}}shutdown(){this.current.close();for(let e of this.requests.values())for(let t of e)t.abort();this.requests.clear(),this.shared.events.close()}};const yl=/\.(bpmn|bpmn\.xml|bpmn20\.xml|dmn|form)$/i,bl=/^penstock\.(yaml|yml|json)$/i,xl=new Intl.Collator(`en`,{numeric:!0,sensitivity:`base`});function Sl(e){return bl.test(e)||yl.test(e)}async function Cl(e){let t;try{t=await bn(e)}catch{return!1}try{for(let e=0;e<4e3;e+=1){let e=await t.read();if(!e)return!1;if(Sl(e.name))return!0}return!1}catch{return!1}finally{await t.close().catch(()=>void 0)}}async function wl(){if(process.platform!==`win32`)return[`/`];let e=Array.from({length:26},(e,t)=>String.fromCharCode(65+t)).map(async e=>{let t=`${e}:\\`;return await Promise.race([j(t).then(()=>!0,()=>!1),new Promise(e=>setTimeout(()=>e(!1),300).unref())])?t:null});return(await Promise.all(e)).filter(e=>e!==null)}function Tl(e,t){let n=e.code,r=t.replace(/[\u0000-\u001f\u007f]/g,`?`).slice(0,200);throw n===`EACCES`||n===`EPERM`?B(403,`app.cli.web.reason.folderNotReadable`,{folder:r}):n===`ENOTDIR`?B(400,`app.cli.web.reason.notAFolder`,{folder:r}):n===`ENOENT`||n===`ELOOP`||n===`ENAMETOOLONG`?B(404,`app.cli.web.reason.noSuchFolder`,{folder:r}):e}async function El(e,t){let n=e.lastProject();if(n){let e=x.dirname(n);try{if((await j(e)).isDirectory())return e}catch{}}return t}async function Dl(e,t,n,r=2e4){let i=ml(e.shared.env),a=t===void 0||t===``?await El(e,i):gl(t,i),o;try{if(o=await Sn(a),!(await j(o)).isDirectory())throw B(400,`app.cli.web.reason.notAFolder`,{folder:a.replace(/[\u0000-\u001f\u007f]/g,`?`).slice(0,200)})}catch(e){return Tl(e,a)}let s;try{s=await k(o,{withFileTypes:!0})}catch(e){return Tl(e,o)}let c=[],l=!1,u=0;for(let e of s){let t=e.name;if(e.isDirectory())c.push({name:t,hidden:t.startsWith(`.`),link:!1});else{if(e.isSymbolicLink()||!e.isFile()&&!e.isDirectory())try{if((await j(x.join(o,t))).isDirectory()){c.push({name:t,hidden:t.startsWith(`.`),link:e.isSymbolicLink()});continue}}catch{continue}bl.test(t)?l=!0:yl.test(t)&&(u+=1)}}c.sort((e,t)=>xl.compare(e.name,t.name)||(e.name<t.name?-1:+(e.name>t.name)));let d=c.length,f=d>r?c.slice(0,r):c,p=f.reduce((e,t)=>e+ +!!t.hidden,0),m=!0,h=Date.now()+1500,g=f.filter(e=>!e.link&&(n||!e.hidden)),ee=0;await Promise.all(Array.from({length:Math.min(24,g.length)},async()=>{for(;ee<g.length;){if(Date.now()>h){m=!1;return}let e=g[ee];ee+=1,await Cl(x.join(o,e.name))&&(e.project=!0)}}));let te=x.dirname(o);return{path:o,parent:te===o?null:te,home:i,separator:x.sep,roots:await wl(),entries:f,total:d,truncated:f.length<d,hiddenCount:p,hintsComplete:m,project:l||u>0?{config:l,diagrams:u}:null}}const Ol=[{method:`POST`,path:`/web/folders`,operationId:`listFolders`,limit:L,run:e=>{let t=e.body===void 0?{}:V(e.body);return Dl(e.workspace,U(t,`path`),W(t,`hidden`))}}],kl=[{method:`GET`,path:`/web/project`,operationId:`getCurrentProject`,run:e=>e.workspace.info()},{method:`POST`,path:`/web/project/open`,operationId:`openProject`,limit:L,run:e=>e.workspace.open(H(V(e.body),`folder`))},{method:`POST`,path:`/web/project/close`,operationId:`closeProject`,run:e=>e.workspace.close()},{method:`GET`,path:`/web/project/recent`,operationId:`listRecentProjects`,run:e=>({projects:e.workspace.recent()})},{method:`POST`,path:`/web/project/recent/forget`,operationId:`forgetRecentProject`,limit:L,run:e=>({projects:e.workspace.forget(H(V(e.body),`folder`))})}];function Al(t){let n=new _(t.home).text(`theme`);return{theme:n===`light`?`LIGHT`:n===`dark`?`DARK`:n===`dracula`?`DRACULA`:`SYSTEM`,locale:m(),engine:null,scriptType:`NONE`,bpmnLint:{configPath:null,clientBundlePath:null},elementTemplates:[],elementTemplatesContent:[],elementTemplatesFolder:``,project:``,bpmnFilePath:``,bpmnXml:``,conventions:null,pluginVersion:e()??null}}const jl=[`JOB_TYPE`,`TOPIC`,`CLASS`,`BEAN`,`MESSAGE`];function Ml(e){return jl.includes(e)}function Nl(e,t,n){return t===`MESSAGE`?Ue(e,{kind:t,value:n}):Je(e,{kind:t,value:n})}function Pl(e,t,n){let r=/* @__PURE__ */ new Map;for(let i of n)if(Ml(i.kind)&&i.value!==``)for(let n of Nl(t,i.kind,i.value)){if(n.file!==e)continue;let t=i.elementId??null,a=`${n.line}\u0000${i.kind}\u0000${i.value}\u0000${i.path}\u0000${t}`;if(!r.has(a)&&(r.set(a,{line:n.line,kind:i.kind,value:i.value,diagram:i.path,element:t,name:i.label,elementType:i.elementType??``}),r.size>=500))return Fl(r)}return Fl(r)}function Fl(e){return[...e.values()].sort((e,t)=>e.line-t.line||e.diagram.localeCompare(t.diagram)||e.name.localeCompare(t.name))}function Il(e,t){let n=/* @__PURE__ */ new Map,r=(e,t,r)=>{if(t===``)return;let i=`${e}\u0000${t}`,a=n.get(i);a?a.origin!==r&&(a.origin=`both`):n.set(i,{kind:e,value:t,origin:r})};for(let e of t)Ml(e.kind)&&r(e.kind,e.value,`diagram`);for(let t of e.jobTypes.keys())r(`JOB_TYPE`,t,`code`);for(let t of e.topics.keys())r(`TOPIC`,t,`code`);for(let t of e.classes.keys())r(`CLASS`,t,`code`);for(let t of e.beans.keys())r(`BEAN`,t,`code`);for(let t of e.references.keys())t.startsWith(`MESSAGE:`)&&r(`MESSAGE`,t.slice(8),`code`);return[...n.values()].sort((e,t)=>e.kind.localeCompare(t.kind)||e.value.localeCompare(t.value)).slice(0,5e3)}const Ll=e=>Ht.has(e),Rl=Ut,zl=e=>/\.form$/i.test(e)?`form`:/\.(bpmn|bpmn\.xml|bpmn20\.xml|dmn)$/i.test(e)?`diagram`:`code`;function Bl(e,t,n,r){let i=[];for(let a of e){if(a.path===r)continue;let e=zl(a.path);(e===`form`?Wt(t,n,a.text):e===`diagram`?Gt(t,n,a.text):Kt(t,n,a.text)).forEach(t=>i.push({file:a.path,start:t.start,end:t.end,where:e,label:t.where}))}return i}function Vl(e){let t=new Set(e.map(e=>e.file)).size,n=e.filter(e=>e.where!==`code`).length;return p(`app.vscode.rename.summary`,{files:p(`app.vscode.rename.files`,{count:t}),diagrams:n,code:e.length-n})}const Hl=zn(dn),Ul=4e3,Wl={JAVA_CLASS:[`CLASS`],BEAN:[`BEAN`],JOB_TYPE:[`JOB_TYPE`,`TOPIC`]},Gl=/* @__PURE__ */ new Set([`PROCESS`,`JOB_TYPE`,`TOPIC`,`MESSAGE`,`SIGNAL`,`DECISION`,`FORM`,`CLASS`,`BEAN`,`ERROR`]);function Kl(e){return pn(`sha256`).update(e).digest(`hex`)}async function ql(e,t){let n=V(e.body),r=H(n,`kind`),i=H(n,`value`),a=Wl[r];if(!a)throw B(400,`app.cli.web.reason.wrongField`,{field:`kind`});if(i.length===0||i.length>500)throw B(400,`app.cli.web.reason.wrongField`,{field:`value`});let{index:o}=await t.code.state(()=>t.project.listing()),s=/* @__PURE__ */ new Set;return{places:a.flatMap(e=>Je(o,{kind:e,value:i})).filter(e=>{let t=`${e.file}#${e.line}`;return!s.has(t)&&(s.add(t),!0)}).map(e=>({path:e.file,line:e.line,label:`${x.basename(e.file)}:${e.line}`}))}}async function Jl(e,t){let n=t.confine.resolve(H(V(e.body),`path`)),{index:r,targets:i}=await t.code.state(()=>t.project.listing());return{uses:Pl(n,r,i)}}async function Yl(e,t){let{index:n,targets:r}=await t.code.state(()=>t.project.listing());return{names:Il(n,r)}}async function Xl(e,t){try{return{ok:!0,out:(await Hl(`git`,t,{cwd:e,encoding:`utf8`,timeout:1e4,maxBuffer:67108864,env:{...process.env,GIT_TERMINAL_PROMPT:`0`,GIT_OPTIONAL_LOCKS:`0`}})).stdout}}catch{return{ok:!1,out:``}}}async function Zl(e,t){let n=t.confine.resolve(H(V(e.body),`path`)),r=x.dirname(n),i=await Xl(r,[`rev-parse`,`--is-inside-work-tree`]);if(!i.ok||i.out.trim()!==`true`)return{tracked:!1,before:null};let a=await Xl(r,[`show`,`HEAD:./${x.basename(n)}`]);return{tracked:!0,before:a.ok?a.out:null}}async function Ql(e){try{let t=await j(e);return!t.isFile()||t.size>33554432?null:await xn(e,`utf8`)}catch{return null}}function $l(e,t,n){if(e.confine.writeKind(t))return;let r=e.confine.segments(t),i=r.slice(0,-1).some(e=>e.startsWith(`.`));if(!Ge.test(r[r.length-1]??``)||i)throw B(403,`app.cli.web.reason.notEditable`,{path:n.slice(0,200)})}async function eu(e,t){let n=await e.project.listing(),{sources:r}=await e.code.state(()=>e.project.listing()),i=/* @__PURE__ */ new Set([...n.files.map(e=>e.path),...r.map(e=>e.path)]);if(i.delete(t),i.size>Ul)throw B(400,`app.cli.web.reason.tooMany`);let a=[];for(let e of i){let t=await Ql(e);t!==null&&a.push({path:e,text:t})}return a}function tu(e){let t=V(e.body),n=H(t,`kind`);if(!Gl.has(n))throw B(400,`app.cli.web.reason.wrongField`,{field:`kind`});return{kind:n,from:H(t,`from`),to:H(t,`to`),path:H(t,`path`)}}function nu(e,t){let n=1;for(let r=0;r<t&&r<e.length;r+=1)e.charCodeAt(r)===10&&(n+=1);return n}async function ru(e,t){let n=tu(e),r=t.confine.resolve(n.path),i={offered:!1,sites:[],files:[]};if(!Ll(n.kind)||!n.from.trim()||!Rl(n.to))return{...i,detail:p(`app.vscode.rename.notRenamable`)};if(!await Y(t))return i;let a=await eu(t,r),o=Bl(a,n.kind,n.from,r);if(o.length===0)return{...i,detail:p(`app.vscode.rename.nothingElse`,{name:n.from})};let s=new Map(a.map(e=>[e.path,e.text])),c=[...new Set(o.map(e=>e.file))];return{offered:!0,summary:Vl(o),sites:o.map(e=>({path:e.file,where:e.where,label:e.label,line:nu(s.get(e.file)??``,e.start)})),files:c.map(e=>({path:e,version:Kl(s.get(e)??``)}))}}function iu(e,t,n){let r=e;for(let e of[...t].sort((e,t)=>t.start-e.start))r=`${r.slice(0,e.start)}${n}${r.slice(e.end)}`;return r}async function au(e,t){let n=x.join(x.dirname(e),`.${x.basename(e)}.${process.pid}.${mn(4).toString(`hex`)}.tmp`),r=await j(e).catch(()=>null);return await Tn(n,t,{mode:r?r.mode&511:420}),n}async function ou(e,t){let n=tu(e),r=V(e.body);if(!Ll(n.kind)||!n.from.trim()||!Rl(n.to))throw B(400,`app.cli.web.reason.wrongField`,{field:`to`});if(!await Y(t))throw B(403,`app.cli.webHost.reason.notLicensed`);let i=t.confine.resolve(n.path),a=G(r,`files`).map(e=>{let t=V(e);return{path:H(t,`path`),version:H(t,`version`)}});if(a.length===0||a.length>Ul)throw B(400,`app.cli.web.reason.badFileList`);let o=[];for(let e of a){let n=t.confine.resolve(e.path);if($l(t,n,e.path),n===i)throw B(400,`app.cli.web.reason.wrongField`,{field:`files`});let r=await Ql(n);if(r===null||Kl(r)!==e.version)throw B(409,`app.cli.webHost.reason.changedSince`,{file:t.confine.relative(n).slice(0,200)});o.push({path:n,text:r})}let s=Bl(o,n.kind,n.from,i),c=[];try{for(let e of o){let t=s.filter(t=>t.file===e.path);t.length!==0&&c.push({target:e.path,temporary:await au(e.path,iu(e.text,t,n.to)),before:e.text})}for(let e of c){let n=await Ql(e.target);if(n===null||n!==e.before)throw B(409,`app.cli.webHost.reason.changedSince`,{file:t.confine.relative(e.target).slice(0,200)})}let e=[];try{for(let t of c)await A(t.temporary,t.target),e.push(t)}catch(t){for(let t of e.reverse()){let e=await au(t.target,t.before);await A(e,t.target).catch(()=>Cn(e,{force:!0}))}throw t}}finally{await Promise.all(c.map(e=>Cn(e.temporary,{force:!0}).catch(()=>void 0)))}return{places:s.length,files:c.length}}function su(e){throw e instanceof l?B(400,`app.cli.webHost.reason.licence`,{detail:e.message}):B(502,`app.cli.webHost.reason.licenceService`,{detail:e instanceof Error?e.message:String(e)})}async function cu(e,t){let n=H(V(e.body),`key`).trim();if(n.length<8||n.length>200)throw B(400,`app.cli.webHost.reason.keyShape`);try{await i(n,{env:t.env})}catch(e){su(e)}return Ho(t),Wo(t)}async function lu(e,t){try{if(await o({env:t.env})===`none`)throw B(409,`app.cli.webHost.reason.nothingToRelease`)}catch(e){if(e instanceof Error&&e.name===`WebFailure`)throw e;su(e)}return Ho(t),Wo(t)}async function uu(e,t){let n=V(e.body),r=H(n,`tier`);if(r!==`PRO`&&r!==`TEAM`)throw B(400,`app.cli.web.reason.wrongField`,{field:`tier`});let i=typeof n.email==`string`&&n.email.trim()?n.email.trim().slice(0,200):void 0;try{return{url:(await a(r===`PRO`?`pro`:`team`,i,{env:t.env})).url}}catch(e){throw B(502,`app.cli.webHost.reason.licenceService`,{detail:e instanceof Error?e.message:String(e)})}}async function du(e,t){let n=V(e.body),r=typeof n.since==`string`&&n.since.trim()!==``?n.since.trim().slice(0,200):void 0;if(n.format!==void 0&&n.format!==`zip`&&n.format!==`dir`)throw B(400,`app.cli.web.reason.wrongField`,{field:`format`});if(n.force!==void 0&&typeof n.force!=`boolean`)throw B(400,`app.cli.web.reason.wrongField`,{field:`force`});let i=await J(t);if(!g(i,{env:t.env}))return{ok:!1,pack:null,files:0,sealed:null,lines:h(i,`audit-evidence`,{env:t.env})};let{evidenceBuild:a}=await import(`./chunk-evidence-ny_2ltVe.js`),o=await a({root:t.folder,format:n.format===`dir`?`dir`:`zip`,since:r,force:n.force===!0,json:!1},{tier:async()=>i.tier});return{ok:o.ok,pack:o.pack??null,files:o.files??0,sealed:o.sealed??null,lines:o.lines}}const fu=[{method:`POST`,path:`/web/code/locate`,operationId:`locateCode`,limit:L,run:ql},{method:`POST`,path:`/web/code/uses`,operationId:`findCodeUses`,limit:L,run:Jl},{method:`GET`,path:`/web/code/names`,operationId:`listProjectNames`,run:Yl},{method:`POST`,path:`/web/compare`,operationId:`compareWithHead`,limit:L,run:Zl},{method:`POST`,path:`/web/evidence`,operationId:`buildEvidence`,limit:L,run:du},{method:`POST`,path:`/web/linked-rename/plan`,operationId:`planLinkedRename`,limit:L,run:ru},{method:`POST`,path:`/web/linked-rename/apply`,operationId:`applyLinkedRename`,limit:L,run:ou},{method:`POST`,path:`/web/licence/activate`,operationId:`activateLicence`,limit:L,run:cu},{method:`POST`,path:`/web/licence/checkout`,operationId:`startLicenceCheckout`,limit:L,run:uu},{method:`POST`,path:`/web/licence/deactivate`,operationId:`deactivateLicence`,limit:L,run:lu}],pu=[`RENAME`,`BULK`,`EXTRACT`];function mu(e){if(!e.open||e.folder===``)throw B(409,`app.cli.web.reason.noProject`)}function hu(e){let t=V(e),n=H(t,`mode`);if(!pu.includes(n))throw B(400,`app.cli.web.reason.wrongField`,{field:`mode`});return{mode:n,fields:t,planId:U(t,`planId`),acknowledge:W(t,`acknowledge`),force:W(t,`force`)}}function gu(e){if(e.mode===`RENAME`){let t=H(e.fields,`kind`);if(!Zt(t))throw B(400,`app.cli.web.reason.wrongField`,{field:`kind`});return[{kind:t,from:H(e.fields,`from`),to:H(e.fields,`to`)}]}let t=H(e.fields,`mapping`);if(Buffer.byteLength(t,`utf8`)>262144)throw B(400,`app.refactor.mapping.tooLarge`,{detail:``,line:0});let n=qt(t,/^\s*[[{]/.test(t.slice(0,64)));if(n.problem!==null)throw B(400,`app.refactor.mapping.${n.problem.code}`,{detail:n.problem.detail,line:n.problem.line});return n.requests}function _u(e,t){let n=t.confine.resolve(H(e.fields,`file`)),r=U(e.fields,`name`);return{relative:x.relative(T(t.folder),T(n)).split(x.sep).join(`/`),request:{elements:zi(e.fields,`elements`),processId:H(e.fields,`processId`),...r===void 0||r.trim()===``?{}:{name:r}}}}const vu={allowed:!0,lines:[],stopped:null,detail:``,planId:null,blocked:!1,blockers:[],edits:[],editCount:0,refused:[],refusedCount:0,blockingRefusals:0,files:[],extract:null,extractRefusals:[]};function yu(e,t){let{report:n}=t;return{...vu,mode:e,stopped:t.stopped,detail:t.detail,planId:n.planId,blocked:n.blocked,blockers:n.blockers,edits:n.edits,editCount:n.editCount,refused:n.refused,refusedCount:n.refusedCount,blockingRefusals:n.blockingRefusals,files:n.files}}function bu(e){let t=e.plan;return{...vu,mode:`EXTRACT`,stopped:e.stopped,detail:e.detail,planId:e.planId,blocked:t===null,extractRefusals:e.refusals,extract:t===null?null:{created:t.created,callId:t.callId,processId:t.processId,engine:t.engine,moved:t.moved,inputs:t.mappings.inputs,outputs:t.mappings.outputs,allIn:t.mappings.allIn,allOut:t.mappings.allOut}}}async function xu(e,t){if(e.mode===`RENAME`)return null;let n=await J(t);return g(n,{env:t.env})?null:h(n,`refactor-bulk`,{env:t.env})}async function Su(e,t){mu(t);let n=hu(e.body),r=await xu(n,t);if(r!==null)return{...vu,mode:n.mode,allowed:!1,lines:r};try{if(n.mode===`EXTRACT`){let{relative:e,request:r}=_u(n,t);return bu(await Yt(t.folder,e,r,{apply:!1,force:!1,acknowledge:!1}))}return yu(n.mode,Jt(t.folder,gu(n),{apply:!1,force:!1,acknowledge:!1}))}catch(e){throw e instanceof Xt?B(400,`app.refactor.cli.uncRoot`):e}}async function Cu(e,t){mu(t);let n=hu(e.body);if(n.planId===void 0||n.planId===``)throw B(400,`app.cli.web.reason.missingField`,{field:`planId`});if(await xu(n,t)!==null)throw B(403,`app.cli.webHost.reason.notLicensed`);let r={apply:!0,force:n.force,acknowledge:n.acknowledge,planId:n.planId};try{if(n.mode===`EXTRACT`){let{relative:e,request:i}=_u(n,t),a=await Yt(t.folder,e,i,r);if(!a.applied||a.written===null)throw B(409,`app.refactor.stop.`+(a.stopped??`blocked`),{detail:a.detail});return{files:[a.written.source,a.written.created],edits:2,created:a.written.created}}let e=Jt(t.folder,gu(n),r);if(!e.applied||e.written===null)throw B(409,`app.refactor.stop.`+(e.stopped??`blocked`),{detail:e.detail});return{files:e.written.files,edits:e.written.edits,created:null}}catch(e){throw e instanceof Xt?B(400,`app.refactor.cli.uncRoot`):e}}const wu=[{method:`POST`,path:`/web/refactor/plan`,operationId:`planRefactor`,limit:L,run:Su},{method:`POST`,path:`/web/refactor/apply`,operationId:`applyRefactor`,limit:L,run:Cu}],Tu=[{method:`GET`,path:`/web/lsp/servers`,operationId:`listLanguageServers`,run:(e,t)=>({servers:Bc(t.home,t.env).map(e=>({id:e.id,label:e.command,languages:e.languages,available:e.found!==null,configured:e.configured}))})},{method:`GET`,path:`/web/lsp/messages`,operationId:`nextLspMessages`,held:!0,run:async(e,t)=>({messages:await t.events.nextMessages(e.client,e.signal)})},{method:`POST`,path:`/web/lsp/{serverName}/message`,operationId:`sendLspMessage`,limit:R,run:(e,t)=>{t.servers.send(e.client,e.params.serverName,e.body)}}],Eu=/* @__PURE__ */ new Set([`JOB_TYPE`,`TOPIC`,`CLASS`,`BEAN`,`MESSAGE`,`PROCESS`,`DECISION`]),Du=/* @__PURE__ */ new Set([`execution`,`task`]);function Ou(e,t){if(e.length>500)throw B(400,`app.cli.web.reason.wrongField`,{field:t});return e}function ku(e){let t=V(e),n=H(t,`kind`);if(!Eu.has(n))throw B(400,`app.cli.web.reason.wrongField`,{field:`kind`});let r=t.listener;if(r!==void 0&&(typeof r!=`string`||!Du.has(r)))throw B(400,`app.cli.web.reason.wrongField`,{field:`listener`});return{kind:n,value:Ou(H(t,`value`),`value`),...r?{listener:r}:{}}}function Au(e){let t=V(e),n=G(t,`elements`);if(n.length>2e4)throw B(400,`app.cli.web.reason.tooMany`);return{diagram:Ou(H(t,`diagram`),`diagram`),elements:n.map(e=>{let t=V(e),n=G(t,`bindings`);if(n.length>40)throw B(400,`app.cli.web.reason.tooMany`);return{elementId:Ou(H(t,`elementId`),`elementId`),elementType:Ou(H(t,`elementType`),`elementType`),label:Ou(H(t,`label`),`label`),bindings:n.map(ku)}})}}function ju(e,t){let n=/* @__PURE__ */ new Map;for(let r of e)r.kind===t&&!n.has(r.value)&&n.set(r.value,r.path);return n}function Mu(e,t,n){return{licensed:!0,statuses:Wr({diagram:n.diagram,index:e,processes:ju(t,`PROCESS`),decisions:ju(t,`DECISION`)},n.elements).map(({reached:e,paused:t,...n})=>n)}}function Nu(e,t,n){let r=e.split(/\r\n|\n|\r/);return r[r.length-1]===``&&r.pop(),r.slice(Math.max(0,t-1),Math.max(0,t-1)+n).map(e=>e.replace(/\s+$/,``).slice(0,240))}async function Pu(e){let t;try{let n=await j(e);return!n.isFile()||n.size>1048576?null:(t=await yn(e,`r`),await t.readFile(`utf8`))}catch{return null}finally{await t?.close().catch(()=>void 0)}}const Fu=[{method:`POST`,path:`/web/code/status`,operationId:`findCodeStatus`,limit:R,run:async(e,t)=>{let n=Au(e.body);if(!await Y(t))return{licensed:!1,statuses:[]};let{index:r,targets:i}=await t.code.state(()=>t.project.listing());return Mu(r,i,n)}},{method:`POST`,path:`/web/code/snippet`,operationId:`readCodeSnippet`,limit:L,run:async(e,t)=>{let n=V(e.body),r=H(n,`path`),i=n.line;if(typeof i!=`number`||!Number.isInteger(i)||i<1||i>1e7)throw B(400,`app.cli.web.reason.wrongField`,{field:`line`});let a=n.count;if(a!==void 0&&(typeof a!=`number`||!Number.isInteger(a)||a<1))throw B(400,`app.cli.web.reason.wrongField`,{field:`count`});let o=t.confine.resolve(r);if(!Ge.test(o))throw B(400,`app.cli.web.reason.wrongField`,{field:`path`});let s=await Pu(o);return{path:r,line:i,lines:s===null?[]:Nu(s,i,Math.min(a??12,12))}}}],Iu={workers:[],classes:[],camunda7Imports:[]};var Lu=class{signature=``;analysis={migration:null,facts:Iu};async analysisOf(e,t){let n=pn(`sha1`);e.forEach(e=>n.update(`${e.path}\n${e.text}\n`)),t.forEach(e=>n.update(`${e.file}\n${e.text}\n`));let r=n.digest(`hex`);if(r!==this.signature){let{index:n,facts:i}=await pt(e,t.map(e=>({path:e.file,text:e.text}))),a=await lt({files:e,classes:i.classes,camunda7Imports:i.camunda7Imports,index:n}).catch(()=>null);this.analysis={migration:a,facts:i},this.signature=r}return this.analysis}};function Ru(e){return e.slice(0,Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`),0))}async function zu(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map;for(let i of e){let e=Ru(i);if(!n.has(e)){let r=await t.deployTargets(i).catch(()=>null),a=r?.targets.find(e=>(e.profile??null)===(r.active??null));n.set(e,a?{profile:a.profile??null,engine:a.engine??null,url:a.url??null,ready:a.ready}:null)}let a=n.get(e);a&&r.set(i,a)}return r}function Bu(e,t){let n=t.replace(/\\/g,`/`),r=e.replace(/\\/g,`/`).replace(/\/+$/,``);return n.startsWith(`${r}/`)?n.slice(r.length+1):n}async function Vu(e,t){if(!e.connections||e.connections.length===0)return null;let n=await Promise.all((await t.list().catch(()=>[])).map(async e=>({path:e,text:await t.read(e).catch(()=>null)??``}))),r=[...e.connections.map(t=>({path:Bu(e.root,t.path),text:t.text})),...e.diagrams.map(t=>({path:Bu(e.root,t.path),text:t.text})),...n];return Rt(r)}async function Hu(e,t,n){let r=await t.reports().catch(()=>[]),i=await t.deployTargets().catch(()=>null),a=t.templates(),o=await n.analysisOf(e.diagrams,e.sources),[s,c]=await Promise.all([ot(a),st(a,o.facts.workers)]),l=new Map(c.map(e=>[e.id,e.drift]));return Cr({root:e.root,files:e.files,targets:e.targets,code:e.code,coverage:$n(e.root,r).reach,deploy:i&&{active:i.active,targets:i.targets},debug:[],preferences:{tree:e.preferences?.toolWindowTree!==!1,groupByFiles:e.preferences?.toolWindowGroupByFiles===!0},workersOnEngine:e.workersOnEngine,fileTargets:await zu(e.files.map(e=>e.path),t),codeLinks:e.licensed?`open`:`locked`,migration:o.migration,templates:[...s.values()].map(({path:e,template:t})=>({path:e,template:t,drift:l.get(t.id)??null})),connections:await Vu(e,a),connectionsScreen:e.connectionsScreen===!0,migrationScreen:e.migrationScreen===!0,contracts:o.facts.workers.map(e=>({value:e.value,file:e.file,line:e.line,handler:e.handler??null}))})}function Uu(e,t){return e.elementId===t.elementId&&e.owner===t.owner&&e.index===t.index}async function Wu(e){let t=await ke(e.text),n=Fe(t).find(t=>Uu(t.slot,e.slot));if(!n)return null;let r=Dr({definitions:t,workers:e.workers,diagramPath:e.path},n.slot.elementId,n.value);return{path:e.path,slot:n.slot,language:n.language,value:n.value,title:ir(n),variables:r}}const Gu=2e4;function Ku(e,t){let n=/* @__PURE__ */ new Set,r=[];for(let{handle:i,label:a}of e){if(r.length>=500)break;let e;try{e=t(mt(i))}catch{e=null}if(!e)continue;let o=ft(i)??1,s=`${e}#${o}`;n.has(s)||(n.add(s),r.push({path:e,line:o,label:a??`${x.basename(e)}:${o}`}))}return r}function qu(e){return{kind:`unsupported`,reason:e}}function Ju(e){return e.checks.flatMap(e=>e.check.problem?[`${e.where}: ${e.check.problem}`]:[])}async function Yu(e,t){switch(e.type){case`reveal`:{let n=t.inside(e.path);return n?{kind:`reveal`,path:n,...e.elementId?{elementId:e.elementId}:{}}:qu(p(`app.cli.web.toolWindow.unsupported.outside`))}case`openCode`:return{kind:`openCode`,title:e.title,places:Ku(e.handles.map(e=>({handle:e})),e=>t.inside(e))};case`findUsages`:return await t.paid()?{kind:`findUsages`,title:e.title,places:Ku(await t.usages(e.subjects),e=>t.inside(e))}:{kind:`unlockCode`};case`copy`:return{kind:`copy`,text:e.text.slice(0,Gu)};case`preference`:return t.savePreference(e.key,e.value),{kind:`preference`,key:e.key,value:e.value};case`deploy`:{let n=e.paths.slice(0,1e3).map(e=>t.inside(e)).filter(e=>e!==null);return n.length===0?qu(p(`app.cli.web.toolWindow.unsupported.outside`)):{kind:`deploy`,paths:n,...e.profile?{profile:e.profile}:{},...e.confirm?{confirm:!0}:{}}}case`createExample`:return{kind:`createExample`,example:e.example};case`unlockCode`:return{kind:`unlockCode`};case`openConnections`:return{kind:`openConnections`};case`openMigration`:return{kind:`openMigration`};case`checkWorkers`:{if(!await t.paid())return{kind:`unlockCode`};let n=await t.checkWorkers(e.groups);t.workersChecked(n);let r=Ju(n);return r.length>0?{kind:`notify`,text:r.join(`
19
19
  `).slice(0,Gu),error:!0}:{kind:`refresh`}}case`runTests`:return qu(p(`app.cli.web.toolWindow.unsupported.tests`));case`script`:{let n=await t.script(e.path,e.slot);return n?{kind:`openScript`,path:n.path,slot:n.slot,language:n.language,script:n.value,title:n.title,variables:n.variables}:{kind:`notify`,text:p(`app.cli.web.toolWindow.script.missing`)}}case`migrationConvert`:case`migrationApply`:case`migrationReport`:case`migrationWorker`:return qu(p(`app.cli.web.toolWindow.unsupported.migration`));case`workerTemplate`:case`workerTemplateAt`:case`templateWorker`:return qu(p(`app.cli.web.toolWindow.unsupported.templates`))}}const Xu=2097152,Zu=/^[\w .-]{1,80}$/;function Qu(e,t){let n=t,r=!1,i=e=>{let t=[];for(let a of e){if(n<=0){r=!0;break}--n,t.push(a.children&&a.children.length>0?{...a,children:i(a.children)}:a)}return t};return{roots:i(e),truncated:r}}async function $u(e,t){let n;try{let r=await j(e);return!r.isFile()||r.size>t?null:(n=await yn(e,`r`),await n.readFile(`utf8`))}catch{return null}finally{await n?.close().catch(()=>void 0)}}function ed(e,t){let n=e.folder;return{root:async()=>n,list:async()=>t.templates.map(e=>x.relative(n,e.path).split(x.sep).join(`/`)),read:async t=>$u(e.confine.resolve(x.join(n,t)),Xu),write:async(t,r)=>{let i=e.confine.resolve(x.join(n,t));e.confine.writable(i,t),await O(x.dirname(i),{recursive:!0}),await Tn(i,r)}}}async function td(e){return(await Promise.all(e.connections.map(async e=>{let t=await $u(e.path,Xu);return t===null?null:{path:e.path,text:t}}))).filter(e=>e!==null)}async function nd(e){return(await Promise.all(e.reports.map(async e=>{let t=await $u(e.path,16777216);return t===null?null:{path:e.path,stamp:e.stamp,text:t}}))).filter(e=>e!==null)}function rd(e,t,n){let r=new Map(n.diagrams.map(e=>[e.path,e.text]));return{reports:()=>nd(t),deployTargets:async t=>po(ns(e,t??null,t&&r.get(t)||``)),templates:()=>ed(e,t)}}function id(e,t){let n=/* @__PURE__ */ new Map;if(t)for(let t of Re(e.models,e.targets)){let r=ut(e.index,t,e=>ct(e.file,e.line));r.length>0&&n.set(ze(t),r)}return{precise:t,links:n}}var ad=class{current=null;building=null;memo=new Lu;workers=null;serial=0;keyOf(e,t,n){return[e.id,e.project.scans,e.code.builds,e.configs.generation,t?`paid`:`free`,n.toolWindowTree===!1?`flat`:`tree`,n.toolWindowGroupByFiles===!0?`files`:`kinds`,this.serial].join(`.`)}async snapshot(e){let t=await e.project.listing(),n=await e.code.state(()=>e.project.listing()),r=await Y(e),i=new _(e.home).read(),a=this.keyOf(e,r,i);if(this.current?.key===a)return this.current.built;if(this.building?.key===a)return this.building.promise;let o=this.build(e,t,n,r,i,a),s={key:a,promise:o};this.building=s;try{return await o}finally{this.building===s&&(this.building=null)}}async build(e,t,n,r,i,a){let o=await Hu({root:e.folder,files:n.models,targets:n.targets,code:id(n,r),licensed:r,diagrams:n.diagrams,sources:n.sources.map(e=>({file:e.path,text:e.text})),preferences:i,workersOnEngine:this.workers,connections:await td(t),connectionsScreen:!0,migrationScreen:!0},rd(e,t,n),this.memo),{roots:s,truncated:c}=Qu(o.roots,5e4),l={revision:a,roots:s,toolbar:o.toolbar,codeLinks:r?`open`:`locked`,truncated:c,actions:o.actions};return this.current={key:a,built:l},l}async perform(e,t){let n=this.current?.built.actions.get(t);if(!n)throw B(400,`app.cli.web.reason.noSuchAction`);return Yu(n,this.hostFor(e))}revision(){return this.current?.built.revision??null}knows(e){return this.current?.built.actions.has(e)??!1}hostFor(e){return{inside:t=>{try{return e.confine.resolve(t)}catch{return null}},usages:async t=>{let{index:n}=await e.code.state(()=>e.project.listing());return t.flatMap(e=>ut(n,e,e=>ct(e.file,e.line)).map(e=>({handle:e.handle,label:e.label})))},script:async(t,n)=>{let{diagrams:r,workers:i}=await e.code.state(()=>e.project.listing()),a=r.find(e=>e.path===t);return a?Wu({path:t,text:a.text,slot:n,workers:i}):null},paid:()=>Y(e),savePreference:(t,n)=>{let r=new _(e.home);r.write({...r.read(),[t]:n})},checkWorkers:t=>this.checkWorkers(e,t),workersChecked:e=>{this.workers=e,this.serial+=1}}}async checkWorkers(e,t){let n=await Promise.all(t.slice(0,50).map(async t=>{let n=t.jobTypes.slice(0,2e3);try{if(t.profile!==null&&!Zu.test(t.profile))throw new z(400,`profile`);let r=e.confine.resolve(t.resource),i=await Promise.all(Gr(t.engine,n,/* @__PURE__ */ new Date).map(n=>is(e,{method:n.method,path:n.path,body:n.body,parts:n.parts},t.profile,r)));return{where:t.where,engine:t.engine,check:Jr(t.engine,n,i)}}catch(e){return{where:t.where,engine:t.engine,check:{statuses:/* @__PURE__ */ new Map,problem:e instanceof Error?e.message:String(e)}}}}));return{at:(/* @__PURE__ */ new Date()).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),checks:n}}};const od=/* @__PURE__ */ new WeakMap;function sd(e){let t=od.get(e);return t||(t=new ad,od.set(e,t)),t}const cd=[{method:`GET`,path:`/web/tool-window`,operationId:`getToolWindow`,run:async(e,t)=>{let n=e.query.get(`revision`);if(n!==null&&n.length>200)throw B(400,`app.cli.web.reason.wrongField`,{field:`revision`});let{actions:r,...i}=await sd(t).snapshot(t);return n===i.revision?{revision:i.revision,unchanged:!0}:i}},{method:`POST`,path:`/web/tool-window/perform`,operationId:`performToolWindowAction`,limit:L,run:async(e,t)=>{let n=V(e.body),r=H(n,`id`),i=H(n,`revision`);if(r.length>64||i.length>200)throw B(400,`app.cli.web.reason.wrongField`,{field:`id`});let a=sd(t),o=a.revision();if(o===null||o!==i)throw B(409,`app.cli.web.reason.staleToolWindow`);if(!a.knows(r))throw B(400,`app.cli.web.reason.noSuchAction`);return a.perform(t,r)}}],ld=_s.map(e=>e.operationId===`getConfig`?{...e,run:(t,n)=>n.open?e.run(t,n):Al(n)}:e),ud=[...qo,...js,...Rs,...ld,...Ps,...ya,...kl,...Ol,...wc,...tc,...fu,...wu,...Yi,...Fu,...cd,...zs,...Tu],dd=/* @__PURE__ */ new Set([`getLicense`,`requestFeature`,`showLicenceOffer`,`getTheme`,`getPreferences`,`savePreferences`,`getDialogButtonOrder`,`notifyUser`,`openExternalLink`,`nextHostEvent`,`fetchConnectorUrl`,`connectorFile`,`getCurrentProject`,`openProject`,`closeProject`,`listRecentProjects`,`forgetRecentProject`,`listFolders`]),fd=new Set(zs.map(e=>e.operationId));function pd(e){return e.operationId===`getConfig`?`checked`:dd.has(e.operationId)||qi.has(e.operationId)||fd.has(e.operationId)?`none`:`required`}function md(e){let t=e.map(e=>({route:e,parts:e.path.split(`/`)}));return(e,n)=>{let r=n.split(`/`),i=[];for(let{route:n,parts:a}of t){if(a.length!==r.length)continue;let t={},o=!0;for(let e=0;e<a.length&&o;e+=1){let n=a[e];if(n.startsWith(`{`)&&n.endsWith(`}`)){if(r[e]===``){o=!1;break}try{t[n.slice(1,-1)]=decodeURIComponent(r[e])}catch{o=!1}}else n!==r[e]&&(o=!1)}if(o){if(n.method===e)return{kind:`found`,route:n,params:t};i.push(n.method)}}return i.length>0?{kind:`method`,allowed:i}:{kind:`none`}}}const hd=md(ud),gd=/* @__PURE__ */ new Set([`0.0.0.0`,`::`]),_d=[`127.0.0.1`,`localhost`,`[::1]`];function vd(){return mn(32).toString(`base64url`)}function yd(e,t){return typeof e!=`string`||e.length===0||e.length>512?!1:gn(pn(`sha256`).update(e).digest(),pn(`sha256`).update(t).digest())}function bd(e){let t=[],n=e[`x-penstock-token`];typeof n==`string`&&t.push(n);let r=e.cookie;if(typeof r==`string`&&r.length<=8192)for(let e of r.split(`;`)){let n=e.indexOf(`=`);n>0&&e.slice(0,n).trim()===`penstock_web`&&t.push(e.slice(n+1).trim())}return t}function xd(e,t){return bd(e).some(e=>yd(e,t))}function Sd(e){let t=e[`x-penstock-resource`];if(typeof t!=`string`||t.length===0)return null;try{return decodeURIComponent(t)}catch{return t}}function Cd(e){return`penstock_web=${e}; Path=/; HttpOnly; SameSite=Strict`}function wd(e){return e===`::1`||e===`localhost`||e.startsWith(`127.`)}function Td(e){return e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}function Ed(e){let t=/^(\[[0-9a-f:.]+\]):(\d{1,5})$/.exec(e);if(t)return{name:t[1],port:t[2]};let n=/^([a-z0-9.-]+):(\d{1,5})$/.exec(e);return n?{name:n[1],port:n[2]}:null}function Dd(e,t){let n=gd.has(e),r=new Set(_d.map(e=>`${e}:${t}`));return!n&&!wd(e)&&r.add(`${Td(e).toLowerCase()}:${t}`),{allowsHost:e=>{if(typeof e!=`string`||e.length===0||e.length>300)return!1;let i=e.toLowerCase();if(r.has(i))return!0;if(!n)return!1;let a=Ed(i);return a!==null&&Number(a.port)===t&&Bn(a.name.replace(/^\[|\]$/g,``))!==0},allowsOrigin(e,t){return e===void 0||e.toLowerCase()===`http://${t.toLowerCase()}`}}}function Od(e){let t=e[`sec-fetch-site`];return t===void 0||t===`same-origin`||t===`none`}function kd(e,t){return(t===`GET`||t===`HEAD`)&&e[`sec-fetch-mode`]===`navigate`&&e[`sec-fetch-dest`]===`document`}export{mi as A,z as C,L as D,wi as E,si as F,Qr as I,Zr as L,oi as M,ei as N,Ci as O,$r as P,Pi as S,B as T,$i as _,Dd as a,Ki as b,Sd as c,hd as d,md as f,ta as g,na as h,xd as i,ti as j,I as k,yd as l,vl as m,Cd as n,wd as o,pd as p,Od as r,vd as s,Td as t,kd as u,Qi as v,Oi as w,Ii as x,Zi as y};